net/sfc/base: provide API to fetch vPort statistics

Hypervisor should be able to track VF statistics.

Signed-off-by: Gautam Dawar <gdawar@solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
This commit is contained in:
Gautam Dawar 2019-06-10 08:38:43 +01:00 committed by Ferruh Yigit
parent ea94d14dbe
commit 03b8724119
6 changed files with 99 additions and 17 deletions

View File

@ -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 */

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;