[dpdk-dev] [PATCH 28/29] net/sfc/base: provide API to fetch vPort statistics

Andrew Rybchenko arybchenko at solarflare.com
Mon Jun 10 09:38:43 CEST 2019


From: Gautam Dawar <gdawar at solarflare.com>

Hypervisor should be able to track VF statistics.

Signed-off-by: Gautam Dawar <gdawar at solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko at solarflare.com>
---
 drivers/net/sfc/base/ef10_evb.c  | 13 +++++++++++++
 drivers/net/sfc/base/ef10_impl.h |  7 +++++++
 drivers/net/sfc/base/efx.h       |  8 ++++++++
 drivers/net/sfc/base/efx_evb.c   | 40 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/sfc/base/efx_impl.h  | 18 ++++++++++++++++++
 drivers/net/sfc/base/efx_mcdi.c  | 30 +++++++++++++-----------------
 6 files changed, 99 insertions(+), 17 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_evb.c b/drivers/net/sfc/base/ef10_evb.c
index 6b6d7cc..1788a2c 100644
--- a/drivers/net/sfc/base/ef10_evb.c
+++ b/drivers/net/sfc/base/ef10_evb.c
@@ -536,5 +536,18 @@
 			addrp, fn_resetp));
 }
 
+	__checkReturn	efx_rc_t
+ef10_evb_vport_stats(
+	__in		efx_nic_t *enp,
+	__in		efx_vswitch_id_t vswitch_id,
+	__in		efx_vport_id_t vport_id,
+	__in		efsys_mem_t *esmp)
+{
+	_NOTE(ARGUNUSED(vswitch_id))
+
+	return (efx_mcdi_mac_stats(enp, vport_id, esmp,
+			EFX_STATS_UPLOAD, 0));
+}
+
 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 #endif /* EFSYS_OPT_EVB */
diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 20f2a5c..09f97f8 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -1351,6 +1351,13 @@ extern	__checkReturn	__success(return != B_FALSE)	boolean_t
 	__in_bcount_opt(EFX_MAC_ADDR_LEN)	uint8_t *addrp,
 	__out_opt				boolean_t *fn_resetp);
 
+extern	__checkReturn	efx_rc_t
+ef10_evb_vport_stats(
+	__in		efx_nic_t *enp,
+	__in		efx_vswitch_id_t vswitch_id,
+	__in		efx_vport_id_t vport_id,
+	__out		efsys_mem_t *esmp);
+
 #endif  /* EFSYS_OPT_EVB */
 
 #if EFSYS_OPT_MCDI_PROXY_AUTH_SERVER
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 0e6e842..a43ddd9 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -3444,6 +3444,14 @@ extern	__checkReturn	__success(return != B_FALSE)	boolean_t
 	__in_bcount(EFX_MAC_ADDR_LEN)	uint8_t *addrp,
 	__in				uint16_t vid,
 	__out				boolean_t *is_fn_resetp);
+
+extern	__checkReturn	efx_rc_t
+efx_evb_vport_stats(
+	__in		efx_nic_t *enp,
+	__in		efx_vswitch_t *evp,
+	__in		efx_vport_id_t vport_id,
+	__out		efsys_mem_t *stats_bufferp);
+
 #endif /* EFSYS_OPT_EVB */
 
 #if EFSYS_OPT_MCDI_PROXY_AUTH_SERVER
diff --git a/drivers/net/sfc/base/efx_evb.c b/drivers/net/sfc/base/efx_evb.c
index d48e1d7..dd64bc7 100644
--- a/drivers/net/sfc/base/efx_evb.c
+++ b/drivers/net/sfc/base/efx_evb.c
@@ -24,6 +24,7 @@
 	NULL,		/* eeo_vadaptor_free */
 	NULL,		/* eeo_vport_assign */
 	NULL,		/* eeo_vport_reconfigure */
+	NULL,		/* eeo_vport_stats */
 };
 #endif /* EFSYS_OPT_SIENA */
 
@@ -41,6 +42,7 @@
 	ef10_evb_vadaptor_free,		/* eeo_vadaptor_free */
 	ef10_evb_vport_assign,		/* eeo_vport_assign */
 	ef10_evb_vport_reconfigure,	/* eeo_vport_reconfigure */
+	ef10_evb_vport_stats,		/* eeo_vport_stats */
 };
 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
@@ -501,4 +503,42 @@
 	return (rc);
 }
 
+	__checkReturn	efx_rc_t
+efx_evb_vport_stats(
+	__in		efx_nic_t *enp,
+	__in		efx_vswitch_t *evp,
+	__in		efx_vport_id_t vport_id,
+	__out		efsys_mem_t *stats_bufferp)
+{
+	efx_rc_t rc;
+	const efx_evb_ops_t *eeop = enp->en_eeop;
+
+	EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_EVB);
+
+	if (eeop->eeo_vport_stats == NULL) {
+		rc = ENOTSUP;
+		goto fail1;
+	}
+
+	if (stats_bufferp == NULL) {
+		rc = EINVAL;
+		goto fail2;
+	}
+
+	rc = eeop->eeo_vport_stats(enp, evp->ev_vswitch_id,
+		vport_id, stats_bufferp);
+	if (rc != 0)
+		goto fail3;
+
+	return (0);
+
+fail3:
+	EFSYS_PROBE(fail3);
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+	return (rc);
+}
+
 #endif
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index fd31a6d..3e8b26a 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/base/efx_impl.h
@@ -688,6 +688,8 @@ struct efx_vswitch_s {
 							efx_vport_id_t,
 							uint16_t *, uint8_t *,
 							boolean_t *);
+	efx_rc_t	(*eeo_vport_stats)(efx_nic_t *, efx_vswitch_id_t,
+						efx_vport_id_t, efsys_mem_t *);
 } efx_evb_ops_t;
 
 extern __checkReturn	boolean_t
@@ -1358,6 +1360,14 @@ struct efx_mac_stats_range {
 	efx_mac_stat_t		last;
 };
 
+typedef enum efx_stats_action_e {
+	EFX_STATS_CLEAR,
+	EFX_STATS_UPLOAD,
+	EFX_STATS_ENABLE_NOEVENTS,
+	EFX_STATS_ENABLE_EVENTS,
+	EFX_STATS_DISABLE,
+} efx_stats_action_t;
+
 extern					efx_rc_t
 efx_mac_stats_mask_add_ranges(
 	__inout_bcount(mask_size)	uint32_t *maskp,
@@ -1365,6 +1375,14 @@ struct efx_mac_stats_range {
 	__in_ecount(rng_count)		const struct efx_mac_stats_range *rngp,
 	__in				unsigned int rng_count);
 
+extern	__checkReturn	efx_rc_t
+efx_mcdi_mac_stats(
+	__in		efx_nic_t *enp,
+	__in		uint32_t vport_id,
+	__in_opt	efsys_mem_t *esmp,
+	__in		efx_stats_action_t action,
+	__in		uint16_t period_ms);
+
 #endif	/* EFSYS_OPT_MAC_STATS */
 
 #ifdef	__cplusplus
diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index e840401..477b128 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/base/efx_mcdi.c
@@ -1834,17 +1834,10 @@
 
 #if EFSYS_OPT_MAC_STATS
 
-typedef enum efx_stats_action_e {
-	EFX_STATS_CLEAR,
-	EFX_STATS_UPLOAD,
-	EFX_STATS_ENABLE_NOEVENTS,
-	EFX_STATS_ENABLE_EVENTS,
-	EFX_STATS_DISABLE,
-} efx_stats_action_t;
-
-static	__checkReturn	efx_rc_t
+	__checkReturn	efx_rc_t
 efx_mcdi_mac_stats(
 	__in		efx_nic_t *enp,
+	__in		uint32_t vport_id,
 	__in_opt	efsys_mem_t *esmp,
 	__in		efx_stats_action_t action,
 	__in		uint16_t period_ms)
@@ -1910,7 +1903,7 @@
 	 *	 vadapter has already been deleted.
 	 */
 	MCDI_IN_SET_DWORD(req, MAC_STATS_IN_PORT_ID,
-	    (disable ? EVB_PORT_ID_NULL : enp->en_vport_id));
+		(disable ? EVB_PORT_ID_NULL : vport_id));
 
 	efx_mcdi_execute(enp, &req);
 
@@ -1943,7 +1936,8 @@
 {
 	efx_rc_t rc;
 
-	if ((rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_CLEAR, 0)) != 0)
+	if ((rc = efx_mcdi_mac_stats(enp, enp->en_vport_id, NULL,
+			EFX_STATS_CLEAR, 0)) != 0)
 		goto fail1;
 
 	return (0);
@@ -1966,7 +1960,8 @@
 	 * avoid having to pull the statistics buffer into the cache to
 	 * maintain cumulative statistics.
 	 */
-	if ((rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_UPLOAD, 0)) != 0)
+	if ((rc = efx_mcdi_mac_stats(enp, enp->en_vport_id, esmp,
+			EFX_STATS_UPLOAD, 0)) != 0)
 		goto fail1;
 
 	return (0);
@@ -1994,13 +1989,14 @@
 	 * Medford uses a fixed 1sec period before v6.2.1.1033 firmware.
 	 */
 	if (period_ms == 0)
-		rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_DISABLE, 0);
+		rc = efx_mcdi_mac_stats(enp, enp->en_vport_id, NULL,
+			EFX_STATS_DISABLE, 0);
 	else if (events)
-		rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_EVENTS,
-		    period_ms);
+		rc = efx_mcdi_mac_stats(enp, enp->en_vport_id, esmp,
+			EFX_STATS_ENABLE_EVENTS, period_ms);
 	else
-		rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_NOEVENTS,
-		    period_ms);
+		rc = efx_mcdi_mac_stats(enp, enp->en_vport_id, esmp,
+			EFX_STATS_ENABLE_NOEVENTS, period_ms);
 
 	if (rc != 0)
 		goto fail1;
-- 
1.8.3.1



More information about the dev mailing list