diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 972d32606d..1594f934ba 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -422,7 +422,7 @@ int sfc_port_start(struct sfc_adapter *sa); void sfc_port_stop(struct sfc_adapter *sa); void sfc_port_link_mode_to_info(efx_link_mode_t link_mode, struct rte_eth_link *link_info); -int sfc_port_update_mac_stats(struct sfc_adapter *sa); +int sfc_port_update_mac_stats(struct sfc_adapter *sa, boolean_t manual_update); int sfc_port_reset_mac_stats(struct sfc_adapter *sa); int sfc_set_rx_mode(struct sfc_adapter *sa); int sfc_set_rx_mode_unchecked(struct sfc_adapter *sa); diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index ae9304f90f..bbc22723f6 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -615,7 +615,7 @@ sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) sfc_adapter_lock(sa); - ret = sfc_port_update_mac_stats(sa); + ret = sfc_port_update_mac_stats(sa, B_FALSE); if (ret != 0) goto unlock; @@ -733,7 +733,7 @@ sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, sfc_adapter_lock(sa); - rc = sfc_port_update_mac_stats(sa); + rc = sfc_port_update_mac_stats(sa, B_FALSE); if (rc != 0) { SFC_ASSERT(rc > 0); nstats = -rc; @@ -797,7 +797,7 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, sfc_adapter_lock(sa); - rc = sfc_port_update_mac_stats(sa); + rc = sfc_port_update_mac_stats(sa, B_FALSE); if (rc != 0) { SFC_ASSERT(rc > 0); ret = -rc; diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index bb9e01d96b..8c432c15f5 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -26,7 +26,8 @@ /** * Update MAC statistics in the buffer. * - * @param sa Adapter + * @param sa Adapter + * @param force_upload Flag to upload MAC stats in any case * * @return Status code * @retval 0 Success @@ -34,7 +35,7 @@ * @retval ENOMEM Memory allocation failure */ int -sfc_port_update_mac_stats(struct sfc_adapter *sa) +sfc_port_update_mac_stats(struct sfc_adapter *sa, boolean_t force_upload) { struct sfc_port *port = &sa->port; efsys_mem_t *esmp = &port->mac_stats_dma_mem; @@ -46,14 +47,14 @@ sfc_port_update_mac_stats(struct sfc_adapter *sa) SFC_ASSERT(sfc_adapter_is_locked(sa)); if (sa->state != SFC_ADAPTER_STARTED) - return EINVAL; + return 0; /* * If periodic statistics DMA'ing is off or if not supported, * make a manual request and keep an eye on timer if need be */ if (!port->mac_stats_periodic_dma_supported || - (port->mac_stats_update_period_ms == 0)) { + (port->mac_stats_update_period_ms == 0) || force_upload) { if (port->mac_stats_update_period_ms != 0) { uint64_t timestamp = sfc_get_system_msecs(); @@ -367,6 +368,8 @@ sfc_port_stop(struct sfc_adapter *sa) (void)efx_mac_stats_periodic(sa->nic, &sa->port.mac_stats_dma_mem, 0, B_FALSE); + sfc_port_update_mac_stats(sa, B_TRUE); + efx_port_fini(sa->nic); efx_filter_fini(sa->nic);