From: Gautam Dawar Date: Mon, 10 Jun 2019 07:38:43 +0000 (+0100) Subject: net/sfc/base: provide API to fetch vPort statistics X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=03b8724119b74ba3dc446440c4f891c917f65e53;p=dpdk.git net/sfc/base: provide API to fetch vPort statistics Hypervisor should be able to track VF statistics. Signed-off-by: Gautam Dawar Signed-off-by: Andrew Rybchenko --- diff --git a/drivers/net/sfc/base/ef10_evb.c b/drivers/net/sfc/base/ef10_evb.c index 6b6d7cca9e..1788a2c96a 100644 --- a/drivers/net/sfc/base/ef10_evb.c +++ b/drivers/net/sfc/base/ef10_evb.c @@ -536,5 +536,18 @@ ef10_evb_vport_reconfigure( 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 20f2a5cc73..09f97f8b1a 100644 --- a/drivers/net/sfc/base/ef10_impl.h +++ b/drivers/net/sfc/base/ef10_impl.h @@ -1351,6 +1351,13 @@ ef10_evb_vport_reconfigure( __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 0e6e8423f7..a43ddd95e2 100644 --- a/drivers/net/sfc/base/efx.h +++ b/drivers/net/sfc/base/efx.h @@ -3444,6 +3444,14 @@ efx_evb_vport_reset( __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 d48e1d77ea..dd64bc7854 100644 --- a/drivers/net/sfc/base/efx_evb.c +++ b/drivers/net/sfc/base/efx_evb.c @@ -24,6 +24,7 @@ static const efx_evb_ops_t __efx_evb_dummy_ops = { NULL, /* eeo_vadaptor_free */ NULL, /* eeo_vport_assign */ NULL, /* eeo_vport_reconfigure */ + NULL, /* eeo_vport_stats */ }; #endif /* EFSYS_OPT_SIENA */ @@ -41,6 +42,7 @@ static const efx_evb_ops_t __efx_evb_ef10_ops = { 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 @@ fail1: 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 fd31a6d907..3e8b26a299 100644 --- a/drivers/net/sfc/base/efx_impl.h +++ b/drivers/net/sfc/base/efx_impl.h @@ -688,6 +688,8 @@ typedef struct efx_evb_ops_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 @@ efx_mac_stats_mask_add_ranges( __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 e840401be8..477b128686 100644 --- a/drivers/net/sfc/base/efx_mcdi.c +++ b/drivers/net/sfc/base/efx_mcdi.c @@ -1834,17 +1834,10 @@ fail1: #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 @@ efx_mcdi_mac_stats( * 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_mcdi_mac_stats_clear( { 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 @@ efx_mcdi_mac_stats_upload( * 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 @@ efx_mcdi_mac_stats_periodic( * 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;