net/sfc: fix MAC stats update for stopped device

Return the latest stats snapshot in stopped state
instead of returning an error.

Fixes: 1caab2f1e6 ("net/sfc: add basic statistics")
Cc: stable@dpdk.org

Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
This commit is contained in:
Ivan Ilchenko 2021-07-23 16:15:11 +03:00 committed by Thomas Monjalon
parent 7d466e5fd8
commit 1827b073ed
3 changed files with 11 additions and 8 deletions

View File

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

View File

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

View File

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