* [dpdk-dev] [PATCH 1/2] ethdev: add return value to stats get dev op @ 2017-10-09 16:12 Matan Azrad 2017-10-09 16:12 ` [dpdk-dev] [PATCH 2/2] doc: update stats get API change Matan Azrad ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Matan Azrad @ 2017-10-09 16:12 UTC (permalink / raw) To: dev; +Cc: Ferruh Yigit The stats_get dev op API doesn't include return value, so PMD cannot return an error in case of failure at stats getting process time. Since PCI devices can be removed and there is a time between the physical removal to the RMV interrupt, the user may get invalid stats without any indication. This patch changes the stats_get API return value to be int instead of void. All the net PMDs stats_get dev ops are adjusted by this patch. Signed-off-by: Matan Azrad <matan@mellanox.com> --- drivers/net/af_packet/rte_eth_af_packet.c | 3 ++- drivers/net/ark/ark_ethdev.c | 9 +++++---- drivers/net/ark/ark_ext.h | 2 +- drivers/net/ark/ark_global.h | 2 +- drivers/net/avp/avp_ethdev.c | 6 ++++-- drivers/net/bnx2x/bnx2x_ethdev.c | 4 +++- drivers/net/bnxt/bnxt_stats.c | 16 ++++++++++++---- drivers/net/bnxt/bnxt_stats.h | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 4 +++- drivers/net/cxgbe/cxgbe_ethdev.c | 3 ++- drivers/net/dpaa2/dpaa2_ethdev.c | 10 +++++----- drivers/net/e1000/em_ethdev.c | 7 ++++--- drivers/net/e1000/igb_ethdev.c | 14 ++++++++------ drivers/net/ena/ena_ethdev.c | 9 +++++---- drivers/net/enic/enic.h | 2 +- drivers/net/enic/enic_ethdev.c | 4 ++-- drivers/net/enic/enic_main.c | 8 +++++--- drivers/net/failsafe/failsafe_ops.c | 11 +++++++++-- drivers/net/fm10k/fm10k_ethdev.c | 3 ++- drivers/net/i40e/i40e_ethdev.c | 5 +++-- drivers/net/i40e/i40e_ethdev_vf.c | 5 +++-- drivers/net/ixgbe/ixgbe_ethdev.c | 14 ++++++++------ drivers/net/kni/rte_eth_kni.c | 4 +++- drivers/net/liquidio/lio_ethdev.c | 4 +++- drivers/net/mlx4/mlx4.h | 2 +- drivers/net/mlx4/mlx4_ethdev.c | 3 ++- drivers/net/mlx5/mlx5.h | 2 +- drivers/net/mlx5/mlx5_stats.c | 3 ++- drivers/net/nfp/nfp_net.c | 9 ++++++--- drivers/net/null/rte_eth_null.c | 6 ++++-- drivers/net/octeontx/octeontx_ethdev.c | 8 ++++++-- drivers/net/pcap/rte_eth_pcap.c | 4 +++- drivers/net/qede/qede_ethdev.c | 4 +++- drivers/net/ring/rte_eth_ring.c | 4 +++- drivers/net/sfc/sfc_ethdev.c | 7 +++++-- drivers/net/szedata2/rte_eth_szedata2.c | 4 +++- drivers/net/tap/rte_eth_tap.c | 3 ++- drivers/net/thunderx/nicvf_ethdev.c | 4 +++- drivers/net/vhost/rte_eth_vhost.c | 4 +++- drivers/net/virtio/virtio_ethdev.c | 6 ++++-- drivers/net/vmxnet3/vmxnet3_ethdev.c | 6 ++++-- lib/librte_ether/rte_ethdev.c | 3 +-- lib/librte_ether/rte_ethdev.h | 2 +- 43 files changed, 152 insertions(+), 83 deletions(-) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 295b7a7..46b8250 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -331,7 +331,7 @@ struct pmd_internals { dev_info->min_rx_bufsize = 0; } -static void +static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) { unsigned i, imax; @@ -364,6 +364,7 @@ struct pmd_internals { igb_stats->opackets = tx_total; igb_stats->oerrors = tx_err_total; igb_stats->obytes = tx_bytes_total; + return 0; } static void diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c index 0d60846..dae1f3d 100644 --- a/drivers/net/ark/ark_ethdev.c +++ b/drivers/net/ark/ark_ethdev.c @@ -65,7 +65,7 @@ static int eth_ark_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); static int eth_ark_dev_set_link_up(struct rte_eth_dev *dev); static int eth_ark_dev_set_link_down(struct rte_eth_dev *dev); -static void eth_ark_dev_stats_get(struct rte_eth_dev *dev, +static int eth_ark_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static void eth_ark_dev_stats_reset(struct rte_eth_dev *dev); static void eth_ark_set_default_mac_addr(struct rte_eth_dev *dev, @@ -241,7 +241,7 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, (int (*)(struct rte_eth_dev *, void *)) dlsym(ark->d_handle, "dev_set_link_down"); ark->user_ext.stats_get = - (void (*)(struct rte_eth_dev *, struct rte_eth_stats *, + (int (*)(struct rte_eth_dev *, struct rte_eth_stats *, void *)) dlsym(ark->d_handle, "stats_get"); ark->user_ext.stats_reset = @@ -816,7 +816,7 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, return 0; } -static void +static int eth_ark_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { uint16_t i; @@ -835,8 +835,9 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, for (i = 0; i < dev->data->nb_rx_queues; i++) eth_rx_queue_stats_get(dev->data->rx_queues[i], stats); if (ark->user_ext.stats_get) - ark->user_ext.stats_get(dev, stats, + return ark->user_ext.stats_get(dev, stats, ark->user_data[dev->data->port_id]); + return 0; } static void diff --git a/drivers/net/ark/ark_ext.h b/drivers/net/ark/ark_ext.h index 63b7a26..d26c819 100644 --- a/drivers/net/ark/ark_ext.h +++ b/drivers/net/ark/ark_ext.h @@ -91,7 +91,7 @@ int dev_set_link_up(struct rte_eth_dev *dev, int dev_set_link_down(struct rte_eth_dev *dev, void *user_data); -void stats_get(struct rte_eth_dev *dev, +int stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats, void *user_data); diff --git a/drivers/net/ark/ark_global.h b/drivers/net/ark/ark_global.h index 2a6375f..aef2cf7 100644 --- a/drivers/net/ark/ark_global.h +++ b/drivers/net/ark/ark_global.h @@ -97,7 +97,7 @@ struct ark_user_ext { int (*link_update)(struct rte_eth_dev *, int wait_to_complete, void *); int (*dev_set_link_up)(struct rte_eth_dev *, void *); int (*dev_set_link_down)(struct rte_eth_dev *, void *); - void (*stats_get)(struct rte_eth_dev *, struct rte_eth_stats *, void *); + int (*stats_get)(struct rte_eth_dev *, struct rte_eth_stats *, void *); void (*stats_reset)(struct rte_eth_dev *, void *); void (*mac_addr_add)(struct rte_eth_dev *, struct ether_addr *, diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c index b5cc955..b97a90c 100644 --- a/drivers/net/avp/avp_ethdev.c +++ b/drivers/net/avp/avp_ethdev.c @@ -107,7 +107,7 @@ static uint16_t avp_xmit_pkts(void *tx_queue, static void avp_dev_rx_queue_release(void *rxq); static void avp_dev_tx_queue_release(void *txq); -static void avp_dev_stats_get(struct rte_eth_dev *dev, +static int avp_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static void avp_dev_stats_reset(struct rte_eth_dev *dev); @@ -2241,7 +2241,7 @@ struct avp_queue { } } -static void +static int avp_dev_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats) { struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); @@ -2274,6 +2274,8 @@ struct avp_queue { stats->q_errors[i] += txq->errors; } } + + return 0; } static void diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c index 6f62a37..95861a0 100644 --- a/drivers/net/bnx2x/bnx2x_ethdev.c +++ b/drivers/net/bnx2x/bnx2x_ethdev.c @@ -329,7 +329,7 @@ struct rte_bnx2x_xstats_name_off { return old_link_status == dev->data->dev_link.link_status ? -1 : 0; } -static void +static int bnx2x_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct bnx2x_softc *sc = dev->data->dev_private; @@ -389,6 +389,8 @@ struct rte_bnx2x_xstats_name_off { stats->imissed = brb_drops + brb_truncates + brb_truncate_discard + stats->rx_nombuf; + + return 0; } static int diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index 87feac6..fe83d37 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -228,9 +228,10 @@ void bnxt_free_stats(struct bnxt *bp) } } -void bnxt_stats_get_op(struct rte_eth_dev *eth_dev, +int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, struct rte_eth_stats *bnxt_stats) { + int rc = 0; unsigned int i; struct bnxt *bp = eth_dev->data->dev_private; @@ -240,19 +241,26 @@ void bnxt_stats_get_op(struct rte_eth_dev *eth_dev, struct bnxt_rx_queue *rxq = bp->rx_queues[i]; struct bnxt_cp_ring_info *cpr = rxq->cp_ring; - bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i, + rc = bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i, bnxt_stats, 1); + if (unlikely(rc)) + return rc; } for (i = 0; i < bp->tx_cp_nr_rings; i++) { struct bnxt_tx_queue *txq = bp->tx_queues[i]; struct bnxt_cp_ring_info *cpr = txq->cp_ring; - bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i, + rc = bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i, bnxt_stats, 0); + if (unlikely(rc)) + return rc; } - bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats); + rc = bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats); + if (unlikely(rc)) + return rc; bnxt_stats->rx_nombuf = rte_atomic64_read(&bp->rx_mbuf_alloc_fail); + return rc; } void bnxt_stats_reset_op(struct rte_eth_dev *eth_dev) diff --git a/drivers/net/bnxt/bnxt_stats.h b/drivers/net/bnxt/bnxt_stats.h index daeb3d9..51d16f5 100644 --- a/drivers/net/bnxt/bnxt_stats.h +++ b/drivers/net/bnxt/bnxt_stats.h @@ -37,7 +37,7 @@ #include <rte_ethdev.h> void bnxt_free_stats(struct bnxt *bp); -void bnxt_stats_get_op(struct rte_eth_dev *eth_dev, +int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, struct rte_eth_stats *bnxt_stats); void bnxt_stats_reset_op(struct rte_eth_dev *eth_dev); int bnxt_dev_xstats_get_names_op(__rte_unused struct rte_eth_dev *eth_dev, diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 4bc5329..eb40348 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -2370,7 +2370,7 @@ struct bwg_slave { } -static void +static int bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct bond_dev_private *internals = dev->data->dev_private; @@ -2398,6 +2398,8 @@ struct bwg_slave { } } + + return 0; } static void diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index 7bca456..02b4f62 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -647,7 +647,7 @@ static void cxgbe_dev_rx_queue_release(void *q) /* * Get port statistics. */ -static void cxgbe_dev_stats_get(struct rte_eth_dev *eth_dev, +static int cxgbe_dev_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *eth_stats) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); @@ -690,6 +690,7 @@ static void cxgbe_dev_stats_get(struct rte_eth_dev *eth_dev, eth_stats->q_obytes[i] = txq->stats.tx_bytes; eth_stats->q_errors[i] = txq->stats.mapping_err; } + return 0; } /* diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 39c32b3..1ac607c 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -1061,7 +1061,7 @@ static int dpaa2_dev_link_update(struct rte_eth_dev *dev, "error: Setting the MAC ADDR failed %d\n", ret); } static -void dpaa2_dev_stats_get(struct rte_eth_dev *dev, +int dpaa2_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct dpaa2_dev_priv *priv = dev->data->dev_private; @@ -1076,12 +1076,12 @@ void dpaa2_dev_stats_get(struct rte_eth_dev *dev, if (!dpni) { RTE_LOG(ERR, PMD, "dpni is NULL\n"); - return; + return -EINVAL; } if (!stats) { RTE_LOG(ERR, PMD, "stats is NULL\n"); - return; + return -EINVAL; } /*Get Counters from page_0*/ @@ -1116,11 +1116,11 @@ void dpaa2_dev_stats_get(struct rte_eth_dev *dev, stats->oerrors = value.page_2.egress_discarded_frames; stats->imissed = value.page_2.ingress_nobuffer_discards; - return; + return 0; err: RTE_LOG(ERR, PMD, "Operation not completed:Error Code = %d\n", retcode); - return; + return retcode; }; static int diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c index a59947d..e724205 100644 --- a/drivers/net/e1000/em_ethdev.c +++ b/drivers/net/e1000/em_ethdev.c @@ -72,7 +72,7 @@ static void eth_em_allmulticast_disable(struct rte_eth_dev *dev); static int eth_em_link_update(struct rte_eth_dev *dev, int wait_to_complete); -static void eth_em_stats_get(struct rte_eth_dev *dev, +static int eth_em_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); static void eth_em_stats_reset(struct rte_eth_dev *dev); static void eth_em_infos_get(struct rte_eth_dev *dev, @@ -906,7 +906,7 @@ static int eth_em_pci_remove(struct rte_pci_device *pci_dev) } /* This function is based on em_update_stats_counters() in e1000/if_em.c */ -static void +static int eth_em_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats) { struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -1006,7 +1006,7 @@ static int eth_em_pci_remove(struct rte_pci_device *pci_dev) } if (rte_stats == NULL) - return; + return -EINVAL; /* Rx Errors */ rte_stats->imissed = stats->mpc; @@ -1021,6 +1021,7 @@ static int eth_em_pci_remove(struct rte_pci_device *pci_dev) rte_stats->opackets = stats->gptc; rte_stats->ibytes = stats->gorc; rte_stats->obytes = stats->gotc; + return 0; } static void diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 040dd9f..f3b1d70 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -112,7 +112,7 @@ static void eth_igb_allmulticast_disable(struct rte_eth_dev *dev); static int eth_igb_link_update(struct rte_eth_dev *dev, int wait_to_complete); -static void eth_igb_stats_get(struct rte_eth_dev *dev, +static int eth_igb_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); static int eth_igb_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); @@ -188,7 +188,7 @@ static void eth_igb_default_mac_addr_set(struct rte_eth_dev *dev, static void igbvf_allmulticast_enable(struct rte_eth_dev *dev); static void igbvf_allmulticast_disable(struct rte_eth_dev *dev); static int eth_igbvf_link_update(struct e1000_hw *hw); -static void eth_igbvf_stats_get(struct rte_eth_dev *dev, +static int eth_igbvf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); static int eth_igbvf_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); @@ -1830,7 +1830,7 @@ static int eth_igbvf_pci_remove(struct rte_pci_device *pci_dev) stats->tsctfc += E1000_READ_REG(hw, E1000_TSCTFC); } -static void +static int eth_igb_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats) { struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -1840,7 +1840,7 @@ static int eth_igbvf_pci_remove(struct rte_pci_device *pci_dev) igb_read_stats_registers(hw, stats); if (rte_stats == NULL) - return; + return -EINVAL; /* Rx Errors */ rte_stats->imissed = stats->mpc; @@ -1855,6 +1855,7 @@ static int eth_igbvf_pci_remove(struct rte_pci_device *pci_dev) rte_stats->opackets = stats->gptc; rte_stats->ibytes = stats->gorc; rte_stats->obytes = stats->gotc; + return 0; } static void @@ -2095,7 +2096,7 @@ static int eth_igbvf_xstats_get_names(__rte_unused struct rte_eth_dev *dev, return IGBVF_NB_XSTATS; } -static void +static int eth_igbvf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats) { struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -2105,12 +2106,13 @@ static int eth_igbvf_xstats_get_names(__rte_unused struct rte_eth_dev *dev, igbvf_read_stats_registers(hw, hw_stats); if (rte_stats == NULL) - return; + return -EINVAL; rte_stats->ipackets = hw_stats->gprc; rte_stats->ibytes = hw_stats->gorc; rte_stats->opackets = hw_stats->gptc; rte_stats->obytes = hw_stats->gotc; + return 0; } static void diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index 80ce1f3..a62c398 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -205,7 +205,7 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, static int ena_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); static int ena_start(struct rte_eth_dev *dev); static void ena_close(struct rte_eth_dev *dev); -static void ena_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); +static int ena_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static void ena_rx_queue_release_all(struct rte_eth_dev *dev); static void ena_tx_queue_release_all(struct rte_eth_dev *dev); static void ena_rx_queue_release(void *queue); @@ -811,7 +811,7 @@ static void ena_stats_restart(struct rte_eth_dev *dev) rte_atomic64_init(&adapter->drv_stats->rx_nombuf); } -static void ena_stats_get(struct rte_eth_dev *dev, +static int ena_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct ena_admin_basic_stats ena_stats; @@ -821,13 +821,13 @@ static void ena_stats_get(struct rte_eth_dev *dev, int rc; if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return; + return -ENOTSUP; memset(&ena_stats, 0, sizeof(ena_stats)); rc = ena_com_get_dev_basic_stats(ena_dev, &ena_stats); if (unlikely(rc)) { RTE_LOG(ERR, PMD, "Could not retrieve statistics from ENA"); - return; + return rc; } /* Set of basic statistics from ENA */ @@ -846,6 +846,7 @@ static void ena_stats_get(struct rte_eth_dev *dev, stats->ierrors = rte_atomic64_read(&adapter->drv_stats->ierrors); stats->oerrors = rte_atomic64_read(&adapter->drv_stats->oerrors); stats->rx_nombuf = rte_atomic64_read(&adapter->drv_stats->rx_nombuf); + return 0; } static int ena_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index e28f223..da0c176 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -287,7 +287,7 @@ extern int enic_alloc_rq(struct enic *enic, uint16_t queue_idx, extern int enic_disable(struct enic *enic); extern void enic_remove(struct enic *enic); extern int enic_get_link_status(struct enic *enic); -extern void enic_dev_stats_get(struct enic *enic, +extern int enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats); extern void enic_dev_stats_clear(struct enic *enic); extern void enic_add_packet_filter(struct enic *enic); diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 33a3f87..5386b2a 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -468,13 +468,13 @@ static int enicpmd_dev_link_update(struct rte_eth_dev *eth_dev, return enic_link_update(enic); } -static void enicpmd_dev_stats_get(struct rte_eth_dev *eth_dev, +static int enicpmd_dev_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats) { struct enic *enic = pmd_priv(eth_dev); ENICPMD_FUNC_TRACE(); - enic_dev_stats_get(enic, stats); + return enic_dev_stats_get(enic, stats); } static void enicpmd_dev_stats_reset(struct rte_eth_dev *eth_dev) diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 9b0439b..48cfb82 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -156,16 +156,17 @@ void enic_dev_stats_clear(struct enic *enic) enic_clear_soft_stats(enic); } -void enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats) +int enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats) { struct vnic_stats *stats; struct enic_soft_stats *soft_stats = &enic->soft_stats; int64_t rx_truncated; uint64_t rx_packet_errors; + int ret = vnic_dev_stats_dump(enic->vdev, &stats); - if (vnic_dev_stats_dump(enic->vdev, &stats)) { + if (ret) { dev_err(enic, "Error in getting stats\n"); - return; + return ret; } /* The number of truncated packets can only be calculated by @@ -191,6 +192,7 @@ void enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats) r_stats->imissed = stats->rx.rx_no_bufs + rx_truncated; r_stats->rx_nombuf = rte_atomic64_read(&soft_stats->rx_nombuf); + return 0; } void enic_del_mac_address(struct enic *enic, int mac_index) diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index e0f1b0b..d360965 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -582,18 +582,25 @@ return -1; } -static void +static int fs_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct sub_device *sdev; uint8_t i; + int ret; rte_memcpy(stats, &PRIV(dev)->stats_accumulator, sizeof(*stats)); FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { - rte_eth_stats_get(PORT_ID(sdev), &sdev->stats_snapshot); + ret = rte_eth_stats_get(PORT_ID(sdev), &sdev->stats_snapshot); + if (ret) { + ERROR("Operation rte_eth_stats_get failed for sub_device %d with error %d", + i, ret); + return ret; + } failsafe_stats_increment(stats, &sdev->stats_snapshot); } + return 0; } static void diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 15ea2a5..2d351c1 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -1346,7 +1346,7 @@ static int fm10k_xstats_get_names(__rte_unused struct rte_eth_dev *dev, return FM10K_NB_XSTATS; } -static void +static int fm10k_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { uint64_t ipackets, opackets, ibytes, obytes; @@ -1376,6 +1376,7 @@ static int fm10k_xstats_get_names(__rte_unused struct rte_eth_dev *dev, stats->opackets = opackets; stats->ibytes = ibytes; stats->obytes = obytes; + return 0; } static void diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 536365d..f7dfb97 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -258,7 +258,7 @@ static void i40e_dev_allmulticast_disable(struct rte_eth_dev *dev); static int i40e_dev_set_link_up(struct rte_eth_dev *dev); static int i40e_dev_set_link_down(struct rte_eth_dev *dev); -static void i40e_dev_stats_get(struct rte_eth_dev *dev, +static int i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); @@ -2728,7 +2728,7 @@ static inline void i40e_GLQF_reg_init(struct i40e_hw *hw) } /* Get all statistics of a port */ -static void +static int i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); @@ -2828,6 +2828,7 @@ static inline void i40e_GLQF_reg_init(struct i40e_hw *hw) ns->checksum_error); PMD_DRV_LOG(DEBUG, "fdir_match: %"PRIu64"", ns->fd_sb_match); PMD_DRV_LOG(DEBUG, "***************** PF stats end ********************"); + return 0; } /* Reset the statistics */ diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 111ac39..a52321a 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -108,7 +108,7 @@ static void i40evf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); static int i40evf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); -static void i40evf_dev_stats_get(struct rte_eth_dev *dev, +static int i40evf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int i40evf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); @@ -2230,7 +2230,7 @@ static int eth_i40evf_pci_remove(struct rte_pci_device *pci_dev) }; } -static void +static int i40evf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { int ret; @@ -2253,6 +2253,7 @@ static int eth_i40evf_pci_remove(struct rte_pci_device *pci_dev) } else { PMD_DRV_LOG(ERR, "Get statistics failed"); } + return ret; } static void diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index a7d7acc..d22d7ac 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -176,7 +176,7 @@ static void ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev); static int ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); -static void ixgbe_dev_stats_get(struct rte_eth_dev *dev, +static int ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); @@ -269,7 +269,7 @@ static int ixgbevf_dev_link_update(struct rte_eth_dev *dev, static int ixgbevf_dev_reset(struct rte_eth_dev *dev); static void ixgbevf_intr_disable(struct ixgbe_hw *hw); static void ixgbevf_intr_enable(struct ixgbe_hw *hw); -static void ixgbevf_dev_stats_get(struct rte_eth_dev *dev, +static int ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev); static int ixgbevf_vlan_filter_set(struct rte_eth_dev *dev, @@ -3104,7 +3104,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) /* * This function is based on ixgbe_update_stats_counters() in ixgbe/ixgbe.c */ -static void +static int ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct ixgbe_hw *hw = @@ -3126,7 +3126,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) &total_qbrc, &total_qprc, &total_qprdc); if (stats == NULL) - return; + return -EINVAL; /* Fill out the rte_eth_stats statistics structure */ stats->ipackets = total_qprc; @@ -3157,6 +3157,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) /* Tx Errors */ stats->oerrors = 0; + return 0; } static void @@ -3568,7 +3569,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, return IXGBEVF_NB_XSTATS; } -static void +static int ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *) @@ -3577,12 +3578,13 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, ixgbevf_update_stats(dev); if (stats == NULL) - return; + return -EINVAL; stats->ipackets = hw_stats->vfgprc; stats->ibytes = hw_stats->vfgorc; stats->opackets = hw_stats->vfgptc; stats->obytes = hw_stats->vfgotc; + return 0; } static void diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c index 72a2733..d290c79 100644 --- a/drivers/net/kni/rte_eth_kni.c +++ b/drivers/net/kni/rte_eth_kni.c @@ -283,7 +283,7 @@ struct pmd_internals { return 0; } -static void +static int eth_kni_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { unsigned long rx_packets_total = 0, rx_bytes_total = 0; @@ -320,6 +320,8 @@ struct pmd_internals { stats->opackets = tx_packets_total; stats->obytes = tx_bytes_total; stats->oerrors = tx_packets_err_total; + + return 0; } static void diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index a3c8e67..5407e39 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -311,7 +311,7 @@ struct rte_lio_xstats_name_off { } /* Retrieve the device statistics (# packets in/out, # bytes in/out, etc */ -static void +static int lio_dev_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats) { @@ -359,6 +359,8 @@ struct rte_lio_xstats_name_off { stats->ibytes = bytes; stats->ipackets = pkts; stats->ierrors = drop; + + return 0; } static void diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index 93e5502..9bd2acc 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -117,7 +117,7 @@ struct priv { int mlx4_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); int mlx4_dev_set_link_down(struct rte_eth_dev *dev); int mlx4_dev_set_link_up(struct rte_eth_dev *dev); -void mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); +int mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); void mlx4_stats_reset(struct rte_eth_dev *dev); void mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info); diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index a9e8059..8962be1 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -571,7 +571,7 @@ * @param[out] stats * Stats structure output buffer. */ -void +int mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct rte_eth_stats tmp; @@ -613,6 +613,7 @@ tmp.oerrors += txq->stats.odropped; } *stats = tmp; + return 0; } /** diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 928aeb6..12be6de 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -254,7 +254,7 @@ int mlx5_dev_rss_reta_update(struct rte_eth_dev *, /* mlx5_stats.c */ void priv_xstats_init(struct priv *); -void mlx5_stats_get(struct rte_eth_dev *, struct rte_eth_stats *); +int mlx5_stats_get(struct rte_eth_dev *, struct rte_eth_stats *); void mlx5_stats_reset(struct rte_eth_dev *); int mlx5_xstats_get(struct rte_eth_dev *, struct rte_eth_xstat *, unsigned int); diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c index 06348c8..0e9ba3a 100644 --- a/drivers/net/mlx5/mlx5_stats.c +++ b/drivers/net/mlx5/mlx5_stats.c @@ -318,7 +318,7 @@ struct mlx5_counter_ctrl { * @param[out] stats * Stats structure output buffer. */ -void +int mlx5_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct priv *priv = mlx5_get_priv(dev); @@ -373,6 +373,7 @@ struct mlx5_counter_ctrl { #endif *stats = tmp; priv_unlock(priv); + return 0; } /** diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index 4ef9d2b..0917b9c 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -88,7 +88,7 @@ static int nfp_net_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_txconf *tx_conf); static int nfp_net_start(struct rte_eth_dev *dev); -static void nfp_net_stats_get(struct rte_eth_dev *dev, +static int nfp_net_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static void nfp_net_stats_reset(struct rte_eth_dev *dev); static void nfp_net_stop(struct rte_eth_dev *dev); @@ -1027,7 +1027,7 @@ enum nfp_qcp_ptr { return -1; } -static void +static int nfp_net_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { int i; @@ -1113,8 +1113,11 @@ enum nfp_qcp_ptr { nfp_dev_stats.imissed -= hw->eth_stats_base.imissed; - if (stats) + if (stats) { memcpy(stats, &nfp_dev_stats, sizeof(*stats)); + return 0; + } + return -EINVAL; } static void diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index fa9313d..47c7b14 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -298,7 +298,7 @@ struct pmd_internals { dev_info->flow_type_rss_offloads = internals->flow_type_rss_offloads; } -static void +static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) { unsigned i, num_stats; @@ -306,7 +306,7 @@ struct pmd_internals { const struct pmd_internals *internal; if ((dev == NULL) || (igb_stats == NULL)) - return; + return -EINVAL; internal = dev->data->dev_private; num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS, @@ -333,6 +333,8 @@ struct pmd_internals { igb_stats->ipackets = rx_total; igb_stats->opackets = tx_total; igb_stats->oerrors = tx_err_total; + + return 0; } static void diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index d41904f..5199661 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -199,7 +199,7 @@ enum octeontx_link_speed { nic->port_id, en ? "set" : "unset"); } -static void +static int octeontx_port_stats(struct octeontx_nic *nic, struct rte_eth_stats *stats) { octeontx_mbox_bgx_port_stats_t bgx_stats; @@ -208,8 +208,10 @@ enum octeontx_link_speed { PMD_INIT_FUNC_TRACE(); res = octeontx_bgx_port_stats(nic->port_id, &bgx_stats); - if (res < 0) + if (res < 0) { octeontx_log_err("failed to get port stats %d", nic->port_id); + return res; + } stats->ipackets = bgx_stats.rx_packets; stats->ibytes = bgx_stats.rx_bytes; @@ -221,6 +223,8 @@ enum octeontx_link_speed { octeontx_log_dbg("port %d get stats done inpkts=%ld outpkts=%ld", nic->port_id, stats->ipackets, stats->opackets); + + return 0; } static void diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index b51f16c..1b8a74e 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -560,7 +560,7 @@ struct pmd_devargs { dev_info->min_rx_bufsize = 0; } -static void +static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { unsigned int i; @@ -592,6 +592,8 @@ struct pmd_devargs { stats->opackets = tx_packets_total; stats->obytes = tx_bytes_total; stats->oerrors = tx_packets_err_total; + + return 0; } static void diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c index fe130d4..a238781 100644 --- a/drivers/net/qede/qede_ethdev.c +++ b/drivers/net/qede/qede_ethdev.c @@ -1460,7 +1460,7 @@ static void qede_dev_close(struct rte_eth_dev *eth_dev) rte_eal_alarm_cancel(qede_poll_sp_sb_cb, (void *)eth_dev); } -static void +static int qede_get_stats(struct rte_eth_dev *eth_dev, struct rte_eth_stats *eth_stats) { struct qede_dev *qdev = eth_dev->data->dev_private; @@ -1544,6 +1544,8 @@ static void qede_dev_close(struct rte_eth_dev *eth_dev) if (j == txq_stat_cntrs) break; } + + return 0; } static unsigned diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index e3fa7b0..61473ca 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -190,7 +190,7 @@ struct pmd_internals { dev_info->min_rx_bufsize = 0; } -static void +static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { unsigned i; @@ -214,6 +214,8 @@ struct pmd_internals { stats->ipackets = rx_total; stats->opackets = tx_total; stats->oerrors = tx_err_total; + + return 0; } static void diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 7a57472..5b089dc 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -521,16 +521,18 @@ sfc_adapter_unlock(sa); } -static void +static int sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct sfc_adapter *sa = dev->data->dev_private; struct sfc_port *port = &sa->port; uint64_t *mac_stats; + int ret; rte_spinlock_lock(&port->mac_stats_lock); - if (sfc_port_update_mac_stats(sa) != 0) + ret = sfc_port_update_mac_stats(sa); + if (ret != 0) goto unlock; mac_stats = port->mac_stats_buf; @@ -587,6 +589,7 @@ unlock: rte_spinlock_unlock(&port->mac_stats_lock); + return ret; } static void diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c index d141acf..c5486b7 100644 --- a/drivers/net/szedata2/rte_eth_szedata2.c +++ b/drivers/net/szedata2/rte_eth_szedata2.c @@ -1042,7 +1042,7 @@ struct pmd_internals { dev_info->speed_capa = ETH_LINK_SPEED_100G; } -static void +static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { @@ -1077,6 +1077,8 @@ struct pmd_internals { stats->ibytes = rx_total_bytes; stats->obytes = tx_total_bytes; stats->oerrors = tx_err_total; + + return 0; } static void diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 52380b4..61c6774 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -687,7 +687,7 @@ enum ioctl_mode { DEV_TX_OFFLOAD_TCP_CKSUM); } -static void +static int tap_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *tap_stats) { unsigned int i, imax; @@ -728,6 +728,7 @@ enum ioctl_mode { tap_stats->opackets = tx_total; tap_stats->oerrors = tx_err_total; tap_stats->obytes = tx_bytes_total; + return 0; } static void diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index 4654a4c..551b371 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -242,7 +242,7 @@ static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic, return -ENOTSUP; } -static void +static int nicvf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { uint16_t qidx; @@ -332,6 +332,8 @@ static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic, stats->opackets += port_stats.tx_bcast_frames_ok; stats->opackets += port_stats.tx_mcast_frames_ok; stats->oerrors = port_stats.tx_drops; + + return 0; } static const uint32_t * diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 04179b4..3534649 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -890,7 +890,7 @@ struct vhost_xstats_name_off { dev_info->min_rx_bufsize = 0; } -static void +static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { unsigned i; @@ -928,6 +928,8 @@ struct vhost_xstats_name_off { stats->oerrors = tx_missed_total; stats->ibytes = rx_total_bytes; stats->obytes = tx_total_bytes; + + return 0; } static void diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index e320811..8660074 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -76,7 +76,7 @@ static int virtio_dev_link_update(struct rte_eth_dev *dev, static void virtio_set_hwaddr(struct virtio_hw *hw); static void virtio_get_hwaddr(struct virtio_hw *hw); -static void virtio_dev_stats_get(struct rte_eth_dev *dev, +static int virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int virtio_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); @@ -964,10 +964,12 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev, return count; } -static void +static int virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { virtio_update_stats(dev, stats); + + return 0; } static void diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index 1cc3ffd..58bc4f2 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -87,7 +87,7 @@ static int __vmxnet3_dev_link_update(struct rte_eth_dev *dev, static int vmxnet3_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); static void vmxnet3_hw_stats_save(struct vmxnet3_hw *hw); -static void vmxnet3_dev_stats_get(struct rte_eth_dev *dev, +static int vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int vmxnet3_dev_xstats_get_names(struct rte_eth_dev *dev, struct rte_eth_xstat_name *xstats, @@ -1034,7 +1034,7 @@ static int eth_vmxnet3_pci_remove(struct rte_pci_device *pci_dev) return count; } -static void +static int vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { unsigned int i; @@ -1080,6 +1080,8 @@ static int eth_vmxnet3_pci_remove(struct rte_pci_device *pci_dev) stats->ierrors += rxStats.pktsRxError; stats->rx_nombuf += rxStats.pktsRxOutOfBuf; } + + return 0; } static void diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index f20cb25..883c998 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1531,8 +1531,7 @@ struct rte_eth_dev * RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, -ENOTSUP); stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed; - (*dev->dev_ops->stats_get)(dev, stats); - return 0; + return (*dev->dev_ops->stats_get)(dev, stats); } void diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 8bc1477..605ef50 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1207,7 +1207,7 @@ typedef int (*eth_link_update_t)(struct rte_eth_dev *dev, int wait_to_complete); /**< @internal Get link speed, duplex mode and state (up/down) of an Ethernet device. */ -typedef void (*eth_stats_get_t)(struct rte_eth_dev *dev, +typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats); /**< @internal Get global I/O statistics of an Ethernet device. */ -- 1.8.3.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH 2/2] doc: update stats get API change 2017-10-09 16:12 [dpdk-dev] [PATCH 1/2] ethdev: add return value to stats get dev op Matan Azrad @ 2017-10-09 16:12 ` Matan Azrad 2017-10-09 21:07 ` Thomas Monjalon 2017-10-09 23:57 ` [dpdk-dev] [PATCH 1/2] ethdev: add return value to stats get dev op Ferruh Yigit 2017-10-10 20:20 ` [dpdk-dev] [PATCH v2] " Matan Azrad 2 siblings, 1 reply; 10+ messages in thread From: Matan Azrad @ 2017-10-09 16:12 UTC (permalink / raw) To: dev; +Cc: Ferruh Yigit [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=y, Size: 1410 bytes --] Updated change info in release_17.11. Signed-off-by: Matan Azrad <matan@mellanox.com> --- doc/guides/rel_notes/release_17_11.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/guides/rel_notes/release_17_11.rst b/doc/guides/rel_notes/release_17_11.rst index 36139e5..b62083d 100644 --- a/doc/guides/rel_notes/release_17_11.rst +++ b/doc/guides/rel_notes/release_17_11.rst @@ -75,7 +75,7 @@ New Features The Membership Library is an extension and generalization of a traditional filter (for example Bloom Filter) structure that has multiple usages in a wide variety of workloads and applications. In general, the Membership Library is a - data structure that provides a “set-summary” and responds to set-membership + data structure that provides a ���set-summary��� and responds to set-membership queries whether a certain member belongs to a set(s). See the :ref:`Membership Library <Member_Library>` documentation in @@ -199,6 +199,12 @@ API Changes * ``rte_mem_phy2mch`` was used in Xen dom0 to obtain the physical address; remove this API as Xen dom0 support was removed. +* **Add return value to stats_get dev op API** + + The stats_get dev op API return value has been changed to be int. + By this way PMDs can return an error value in case of failure at stats + getting process time. + ABI Changes ----------- -- 1.8.3.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH 2/2] doc: update stats get API change 2017-10-09 16:12 ` [dpdk-dev] [PATCH 2/2] doc: update stats get API change Matan Azrad @ 2017-10-09 21:07 ` Thomas Monjalon 0 siblings, 0 replies; 10+ messages in thread From: Thomas Monjalon @ 2017-10-09 21:07 UTC (permalink / raw) To: Matan Azrad; +Cc: dev, Ferruh Yigit 09/10/2017 18:12, Matan Azrad: > Updated change info in release_17.11. > > Signed-off-by: Matan Azrad <matan@mellanox.com> > --- > doc/guides/rel_notes/release_17_11.rst | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/doc/guides/rel_notes/release_17_11.rst b/doc/guides/rel_notes/release_17_11.rst > index 36139e5..b62083d 100644 > --- a/doc/guides/rel_notes/release_17_11.rst > +++ b/doc/guides/rel_notes/release_17_11.rst > @@ -75,7 +75,7 @@ New Features > The Membership Library is an extension and generalization of a traditional > filter (for example Bloom Filter) structure that has multiple usages in a wide > variety of workloads and applications. In general, the Membership Library is a > - data structure that provides a âset-summaryâ and responds to set-membership > + data structure that provides a ���set-summary��� and responds to set-membership This change seems to be an encoding error. [...] > +* **Add return value to stats_get dev op API** > + > + The stats_get dev op API return value has been changed to be int. > + By this way PMDs can return an error value in case of failure at stats > + getting process time. > + This change can be squashed with the previous patch (i.e. code and release notes in the same patch). ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH 1/2] ethdev: add return value to stats get dev op 2017-10-09 16:12 [dpdk-dev] [PATCH 1/2] ethdev: add return value to stats get dev op Matan Azrad 2017-10-09 16:12 ` [dpdk-dev] [PATCH 2/2] doc: update stats get API change Matan Azrad @ 2017-10-09 23:57 ` Ferruh Yigit 2017-10-10 20:20 ` [dpdk-dev] [PATCH v2] " Matan Azrad 2 siblings, 0 replies; 10+ messages in thread From: Ferruh Yigit @ 2017-10-09 23:57 UTC (permalink / raw) To: Matan Azrad, dev On 10/9/2017 5:12 PM, Matan Azrad wrote: > The stats_get dev op API doesn't include return value, so PMD cannot > return an error in case of failure at stats getting process time. > > Since PCI devices can be removed and there is a time between the > physical removal to the RMV interrupt, the user may get invalid stats > without any indication. > > This patch changes the stats_get API return value to be int instead of > void. > > All the net PMDs stats_get dev ops are adjusted by this patch. > > Signed-off-by: Matan Azrad <matan@mellanox.com> Hi Matan, Can you please rebase on top of latest next-net? There are new PMDs in repo not covered by your patch: - dpaa - octeontx - mrvl - (perhaps softnic, waiting an updated version of it) Thanks, ferruh ^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v2] ethdev: add return value to stats get dev op 2017-10-09 16:12 [dpdk-dev] [PATCH 1/2] ethdev: add return value to stats get dev op Matan Azrad 2017-10-09 16:12 ` [dpdk-dev] [PATCH 2/2] doc: update stats get API change Matan Azrad 2017-10-09 23:57 ` [dpdk-dev] [PATCH 1/2] ethdev: add return value to stats get dev op Ferruh Yigit @ 2017-10-10 20:20 ` Matan Azrad 2017-10-11 2:01 ` Ferruh Yigit 2 siblings, 1 reply; 10+ messages in thread From: Matan Azrad @ 2017-10-10 20:20 UTC (permalink / raw) To: dev; +Cc: Ferruh Yigit The stats_get dev op API doesn't include return value, so PMD cannot return an error in case of failure at stats getting process time. Since PCI devices can be removed and there is a time between the physical removal to the RMV interrupt, the user may get invalid stats without any indication. This patch changes the stats_get API return value to be int instead of void. All the net PMDs stats_get dev ops are adjusted by this patch. Signed-off-by: Matan Azrad <matan@mellanox.com> --- V2: Rebased patch with next_net master. Adjusted dpaa, octeontx and mrvl PMDs. Merged release notes patch. doc/guides/rel_notes/release_17_11.rst | 6 ++++++ drivers/net/af_packet/rte_eth_af_packet.c | 3 ++- drivers/net/ark/ark_ethdev.c | 9 +++++---- drivers/net/ark/ark_ext.h | 2 +- drivers/net/ark/ark_global.h | 2 +- drivers/net/avp/avp_ethdev.c | 6 ++++-- drivers/net/bnx2x/bnx2x_ethdev.c | 4 +++- drivers/net/bnxt/bnxt_stats.c | 16 ++++++++++++---- drivers/net/bnxt/bnxt_stats.h | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 4 +++- drivers/net/cxgbe/cxgbe_ethdev.c | 3 ++- drivers/net/dpaa/dpaa_ethdev.c | 3 ++- drivers/net/dpaa2/dpaa2_ethdev.c | 10 +++++----- drivers/net/e1000/em_ethdev.c | 7 ++++--- drivers/net/e1000/igb_ethdev.c | 14 ++++++++------ drivers/net/ena/ena_ethdev.c | 9 +++++---- drivers/net/enic/enic.h | 2 +- drivers/net/enic/enic_ethdev.c | 4 ++-- drivers/net/enic/enic_main.c | 8 +++++--- drivers/net/failsafe/failsafe_ops.c | 11 +++++++++-- drivers/net/fm10k/fm10k_ethdev.c | 3 ++- drivers/net/i40e/i40e_ethdev.c | 5 +++-- drivers/net/i40e/i40e_ethdev_vf.c | 5 +++-- drivers/net/ixgbe/ixgbe_ethdev.c | 14 ++++++++------ drivers/net/kni/rte_eth_kni.c | 4 +++- drivers/net/liquidio/lio_ethdev.c | 4 +++- drivers/net/mlx4/mlx4.h | 2 +- drivers/net/mlx4/mlx4_ethdev.c | 3 ++- drivers/net/mlx5/mlx5.h | 2 +- drivers/net/mlx5/mlx5_stats.c | 3 ++- drivers/net/mrvl/mrvl_ethdev.c | 9 +++++++-- drivers/net/nfp/nfp_net.c | 9 ++++++--- drivers/net/null/rte_eth_null.c | 6 ++++-- drivers/net/octeontx/octeontx_ethdev.c | 12 ++++++++---- drivers/net/pcap/rte_eth_pcap.c | 4 +++- drivers/net/qede/qede_ethdev.c | 4 +++- drivers/net/ring/rte_eth_ring.c | 4 +++- drivers/net/sfc/sfc_ethdev.c | 7 +++++-- drivers/net/szedata2/rte_eth_szedata2.c | 4 +++- drivers/net/tap/rte_eth_tap.c | 3 ++- drivers/net/thunderx/nicvf_ethdev.c | 4 +++- drivers/net/vhost/rte_eth_vhost.c | 4 +++- drivers/net/virtio/virtio_ethdev.c | 6 ++++-- drivers/net/vmxnet3/vmxnet3_ethdev.c | 6 ++++-- lib/librte_ether/rte_ethdev.c | 3 +-- lib/librte_ether/rte_ethdev.h | 2 +- 46 files changed, 169 insertions(+), 88 deletions(-) diff --git a/doc/guides/rel_notes/release_17_11.rst b/doc/guides/rel_notes/release_17_11.rst index c184f1e..0513b95 100644 --- a/doc/guides/rel_notes/release_17_11.rst +++ b/doc/guides/rel_notes/release_17_11.rst @@ -216,6 +216,12 @@ API Changes * ``rte_mem_phy2mch`` was used in Xen dom0 to obtain the physical address; remove this API as Xen dom0 support was removed. +* **Add return value to stats_get dev op API** + + The ``stats_get`` dev op API return value has been changed to be int. + By this way PMDs can return an error value in case of failure at stats + getting process time. + ABI Changes ----------- diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 295b7a7..46b8250 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -331,7 +331,7 @@ struct pmd_internals { dev_info->min_rx_bufsize = 0; } -static void +static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) { unsigned i, imax; @@ -364,6 +364,7 @@ struct pmd_internals { igb_stats->opackets = tx_total; igb_stats->oerrors = tx_err_total; igb_stats->obytes = tx_bytes_total; + return 0; } static void diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c index 0d60846..dae1f3d 100644 --- a/drivers/net/ark/ark_ethdev.c +++ b/drivers/net/ark/ark_ethdev.c @@ -65,7 +65,7 @@ static int eth_ark_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); static int eth_ark_dev_set_link_up(struct rte_eth_dev *dev); static int eth_ark_dev_set_link_down(struct rte_eth_dev *dev); -static void eth_ark_dev_stats_get(struct rte_eth_dev *dev, +static int eth_ark_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static void eth_ark_dev_stats_reset(struct rte_eth_dev *dev); static void eth_ark_set_default_mac_addr(struct rte_eth_dev *dev, @@ -241,7 +241,7 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, (int (*)(struct rte_eth_dev *, void *)) dlsym(ark->d_handle, "dev_set_link_down"); ark->user_ext.stats_get = - (void (*)(struct rte_eth_dev *, struct rte_eth_stats *, + (int (*)(struct rte_eth_dev *, struct rte_eth_stats *, void *)) dlsym(ark->d_handle, "stats_get"); ark->user_ext.stats_reset = @@ -816,7 +816,7 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, return 0; } -static void +static int eth_ark_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { uint16_t i; @@ -835,8 +835,9 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, for (i = 0; i < dev->data->nb_rx_queues; i++) eth_rx_queue_stats_get(dev->data->rx_queues[i], stats); if (ark->user_ext.stats_get) - ark->user_ext.stats_get(dev, stats, + return ark->user_ext.stats_get(dev, stats, ark->user_data[dev->data->port_id]); + return 0; } static void diff --git a/drivers/net/ark/ark_ext.h b/drivers/net/ark/ark_ext.h index 63b7a26..d26c819 100644 --- a/drivers/net/ark/ark_ext.h +++ b/drivers/net/ark/ark_ext.h @@ -91,7 +91,7 @@ int dev_set_link_up(struct rte_eth_dev *dev, int dev_set_link_down(struct rte_eth_dev *dev, void *user_data); -void stats_get(struct rte_eth_dev *dev, +int stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats, void *user_data); diff --git a/drivers/net/ark/ark_global.h b/drivers/net/ark/ark_global.h index 2a6375f..aef2cf7 100644 --- a/drivers/net/ark/ark_global.h +++ b/drivers/net/ark/ark_global.h @@ -97,7 +97,7 @@ struct ark_user_ext { int (*link_update)(struct rte_eth_dev *, int wait_to_complete, void *); int (*dev_set_link_up)(struct rte_eth_dev *, void *); int (*dev_set_link_down)(struct rte_eth_dev *, void *); - void (*stats_get)(struct rte_eth_dev *, struct rte_eth_stats *, void *); + int (*stats_get)(struct rte_eth_dev *, struct rte_eth_stats *, void *); void (*stats_reset)(struct rte_eth_dev *, void *); void (*mac_addr_add)(struct rte_eth_dev *, struct ether_addr *, diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c index b5cc955..b97a90c 100644 --- a/drivers/net/avp/avp_ethdev.c +++ b/drivers/net/avp/avp_ethdev.c @@ -107,7 +107,7 @@ static uint16_t avp_xmit_pkts(void *tx_queue, static void avp_dev_rx_queue_release(void *rxq); static void avp_dev_tx_queue_release(void *txq); -static void avp_dev_stats_get(struct rte_eth_dev *dev, +static int avp_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static void avp_dev_stats_reset(struct rte_eth_dev *dev); @@ -2241,7 +2241,7 @@ struct avp_queue { } } -static void +static int avp_dev_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats) { struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); @@ -2274,6 +2274,8 @@ struct avp_queue { stats->q_errors[i] += txq->errors; } } + + return 0; } static void diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c index 6f62a37..95861a0 100644 --- a/drivers/net/bnx2x/bnx2x_ethdev.c +++ b/drivers/net/bnx2x/bnx2x_ethdev.c @@ -329,7 +329,7 @@ struct rte_bnx2x_xstats_name_off { return old_link_status == dev->data->dev_link.link_status ? -1 : 0; } -static void +static int bnx2x_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct bnx2x_softc *sc = dev->data->dev_private; @@ -389,6 +389,8 @@ struct rte_bnx2x_xstats_name_off { stats->imissed = brb_drops + brb_truncates + brb_truncate_discard + stats->rx_nombuf; + + return 0; } static int diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index 87feac6..fe83d37 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -228,9 +228,10 @@ void bnxt_free_stats(struct bnxt *bp) } } -void bnxt_stats_get_op(struct rte_eth_dev *eth_dev, +int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, struct rte_eth_stats *bnxt_stats) { + int rc = 0; unsigned int i; struct bnxt *bp = eth_dev->data->dev_private; @@ -240,19 +241,26 @@ void bnxt_stats_get_op(struct rte_eth_dev *eth_dev, struct bnxt_rx_queue *rxq = bp->rx_queues[i]; struct bnxt_cp_ring_info *cpr = rxq->cp_ring; - bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i, + rc = bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i, bnxt_stats, 1); + if (unlikely(rc)) + return rc; } for (i = 0; i < bp->tx_cp_nr_rings; i++) { struct bnxt_tx_queue *txq = bp->tx_queues[i]; struct bnxt_cp_ring_info *cpr = txq->cp_ring; - bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i, + rc = bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i, bnxt_stats, 0); + if (unlikely(rc)) + return rc; } - bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats); + rc = bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats); + if (unlikely(rc)) + return rc; bnxt_stats->rx_nombuf = rte_atomic64_read(&bp->rx_mbuf_alloc_fail); + return rc; } void bnxt_stats_reset_op(struct rte_eth_dev *eth_dev) diff --git a/drivers/net/bnxt/bnxt_stats.h b/drivers/net/bnxt/bnxt_stats.h index daeb3d9..51d16f5 100644 --- a/drivers/net/bnxt/bnxt_stats.h +++ b/drivers/net/bnxt/bnxt_stats.h @@ -37,7 +37,7 @@ #include <rte_ethdev.h> void bnxt_free_stats(struct bnxt *bp); -void bnxt_stats_get_op(struct rte_eth_dev *eth_dev, +int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, struct rte_eth_stats *bnxt_stats); void bnxt_stats_reset_op(struct rte_eth_dev *eth_dev); int bnxt_dev_xstats_get_names_op(__rte_unused struct rte_eth_dev *eth_dev, diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 4bc5329..eb40348 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -2370,7 +2370,7 @@ struct bwg_slave { } -static void +static int bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct bond_dev_private *internals = dev->data->dev_private; @@ -2398,6 +2398,8 @@ struct bwg_slave { } } + + return 0; } static void diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index 7bca456..02b4f62 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -647,7 +647,7 @@ static void cxgbe_dev_rx_queue_release(void *q) /* * Get port statistics. */ -static void cxgbe_dev_stats_get(struct rte_eth_dev *eth_dev, +static int cxgbe_dev_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *eth_stats) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); @@ -690,6 +690,7 @@ static void cxgbe_dev_stats_get(struct rte_eth_dev *eth_dev, eth_stats->q_obytes[i] = txq->stats.tx_bytes; eth_stats->q_errors[i] = txq->stats.mapping_err; } + return 0; } /* diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 9f33e44..551da20 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -283,7 +283,7 @@ static int dpaa_eth_link_update(struct rte_eth_dev *dev, return 0; } -static void dpaa_eth_stats_get(struct rte_eth_dev *dev, +static int dpaa_eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct dpaa_if *dpaa_intf = dev->data->dev_private; @@ -291,6 +291,7 @@ static void dpaa_eth_stats_get(struct rte_eth_dev *dev, PMD_INIT_FUNC_TRACE(); fman_if_stats_get(dpaa_intf->fif, stats); + return 0; } static void dpaa_eth_stats_reset(struct rte_eth_dev *dev) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 39c32b3..1ac607c 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -1061,7 +1061,7 @@ static int dpaa2_dev_link_update(struct rte_eth_dev *dev, "error: Setting the MAC ADDR failed %d\n", ret); } static -void dpaa2_dev_stats_get(struct rte_eth_dev *dev, +int dpaa2_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct dpaa2_dev_priv *priv = dev->data->dev_private; @@ -1076,12 +1076,12 @@ void dpaa2_dev_stats_get(struct rte_eth_dev *dev, if (!dpni) { RTE_LOG(ERR, PMD, "dpni is NULL\n"); - return; + return -EINVAL; } if (!stats) { RTE_LOG(ERR, PMD, "stats is NULL\n"); - return; + return -EINVAL; } /*Get Counters from page_0*/ @@ -1116,11 +1116,11 @@ void dpaa2_dev_stats_get(struct rte_eth_dev *dev, stats->oerrors = value.page_2.egress_discarded_frames; stats->imissed = value.page_2.ingress_nobuffer_discards; - return; + return 0; err: RTE_LOG(ERR, PMD, "Operation not completed:Error Code = %d\n", retcode); - return; + return retcode; }; static int diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c index a59947d..e724205 100644 --- a/drivers/net/e1000/em_ethdev.c +++ b/drivers/net/e1000/em_ethdev.c @@ -72,7 +72,7 @@ static void eth_em_allmulticast_disable(struct rte_eth_dev *dev); static int eth_em_link_update(struct rte_eth_dev *dev, int wait_to_complete); -static void eth_em_stats_get(struct rte_eth_dev *dev, +static int eth_em_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); static void eth_em_stats_reset(struct rte_eth_dev *dev); static void eth_em_infos_get(struct rte_eth_dev *dev, @@ -906,7 +906,7 @@ static int eth_em_pci_remove(struct rte_pci_device *pci_dev) } /* This function is based on em_update_stats_counters() in e1000/if_em.c */ -static void +static int eth_em_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats) { struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -1006,7 +1006,7 @@ static int eth_em_pci_remove(struct rte_pci_device *pci_dev) } if (rte_stats == NULL) - return; + return -EINVAL; /* Rx Errors */ rte_stats->imissed = stats->mpc; @@ -1021,6 +1021,7 @@ static int eth_em_pci_remove(struct rte_pci_device *pci_dev) rte_stats->opackets = stats->gptc; rte_stats->ibytes = stats->gorc; rte_stats->obytes = stats->gotc; + return 0; } static void diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 040dd9f..f3b1d70 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -112,7 +112,7 @@ static void eth_igb_allmulticast_disable(struct rte_eth_dev *dev); static int eth_igb_link_update(struct rte_eth_dev *dev, int wait_to_complete); -static void eth_igb_stats_get(struct rte_eth_dev *dev, +static int eth_igb_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); static int eth_igb_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); @@ -188,7 +188,7 @@ static void eth_igb_default_mac_addr_set(struct rte_eth_dev *dev, static void igbvf_allmulticast_enable(struct rte_eth_dev *dev); static void igbvf_allmulticast_disable(struct rte_eth_dev *dev); static int eth_igbvf_link_update(struct e1000_hw *hw); -static void eth_igbvf_stats_get(struct rte_eth_dev *dev, +static int eth_igbvf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); static int eth_igbvf_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); @@ -1830,7 +1830,7 @@ static int eth_igbvf_pci_remove(struct rte_pci_device *pci_dev) stats->tsctfc += E1000_READ_REG(hw, E1000_TSCTFC); } -static void +static int eth_igb_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats) { struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -1840,7 +1840,7 @@ static int eth_igbvf_pci_remove(struct rte_pci_device *pci_dev) igb_read_stats_registers(hw, stats); if (rte_stats == NULL) - return; + return -EINVAL; /* Rx Errors */ rte_stats->imissed = stats->mpc; @@ -1855,6 +1855,7 @@ static int eth_igbvf_pci_remove(struct rte_pci_device *pci_dev) rte_stats->opackets = stats->gptc; rte_stats->ibytes = stats->gorc; rte_stats->obytes = stats->gotc; + return 0; } static void @@ -2095,7 +2096,7 @@ static int eth_igbvf_xstats_get_names(__rte_unused struct rte_eth_dev *dev, return IGBVF_NB_XSTATS; } -static void +static int eth_igbvf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats) { struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -2105,12 +2106,13 @@ static int eth_igbvf_xstats_get_names(__rte_unused struct rte_eth_dev *dev, igbvf_read_stats_registers(hw, hw_stats); if (rte_stats == NULL) - return; + return -EINVAL; rte_stats->ipackets = hw_stats->gprc; rte_stats->ibytes = hw_stats->gorc; rte_stats->opackets = hw_stats->gptc; rte_stats->obytes = hw_stats->gotc; + return 0; } static void diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index 80ce1f3..a62c398 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -205,7 +205,7 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, static int ena_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); static int ena_start(struct rte_eth_dev *dev); static void ena_close(struct rte_eth_dev *dev); -static void ena_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); +static int ena_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static void ena_rx_queue_release_all(struct rte_eth_dev *dev); static void ena_tx_queue_release_all(struct rte_eth_dev *dev); static void ena_rx_queue_release(void *queue); @@ -811,7 +811,7 @@ static void ena_stats_restart(struct rte_eth_dev *dev) rte_atomic64_init(&adapter->drv_stats->rx_nombuf); } -static void ena_stats_get(struct rte_eth_dev *dev, +static int ena_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct ena_admin_basic_stats ena_stats; @@ -821,13 +821,13 @@ static void ena_stats_get(struct rte_eth_dev *dev, int rc; if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return; + return -ENOTSUP; memset(&ena_stats, 0, sizeof(ena_stats)); rc = ena_com_get_dev_basic_stats(ena_dev, &ena_stats); if (unlikely(rc)) { RTE_LOG(ERR, PMD, "Could not retrieve statistics from ENA"); - return; + return rc; } /* Set of basic statistics from ENA */ @@ -846,6 +846,7 @@ static void ena_stats_get(struct rte_eth_dev *dev, stats->ierrors = rte_atomic64_read(&adapter->drv_stats->ierrors); stats->oerrors = rte_atomic64_read(&adapter->drv_stats->oerrors); stats->rx_nombuf = rte_atomic64_read(&adapter->drv_stats->rx_nombuf); + return 0; } static int ena_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index e28f223..da0c176 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -287,7 +287,7 @@ extern int enic_alloc_rq(struct enic *enic, uint16_t queue_idx, extern int enic_disable(struct enic *enic); extern void enic_remove(struct enic *enic); extern int enic_get_link_status(struct enic *enic); -extern void enic_dev_stats_get(struct enic *enic, +extern int enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats); extern void enic_dev_stats_clear(struct enic *enic); extern void enic_add_packet_filter(struct enic *enic); diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 33a3f87..5386b2a 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -468,13 +468,13 @@ static int enicpmd_dev_link_update(struct rte_eth_dev *eth_dev, return enic_link_update(enic); } -static void enicpmd_dev_stats_get(struct rte_eth_dev *eth_dev, +static int enicpmd_dev_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats) { struct enic *enic = pmd_priv(eth_dev); ENICPMD_FUNC_TRACE(); - enic_dev_stats_get(enic, stats); + return enic_dev_stats_get(enic, stats); } static void enicpmd_dev_stats_reset(struct rte_eth_dev *eth_dev) diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 9b0439b..48cfb82 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -156,16 +156,17 @@ void enic_dev_stats_clear(struct enic *enic) enic_clear_soft_stats(enic); } -void enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats) +int enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats) { struct vnic_stats *stats; struct enic_soft_stats *soft_stats = &enic->soft_stats; int64_t rx_truncated; uint64_t rx_packet_errors; + int ret = vnic_dev_stats_dump(enic->vdev, &stats); - if (vnic_dev_stats_dump(enic->vdev, &stats)) { + if (ret) { dev_err(enic, "Error in getting stats\n"); - return; + return ret; } /* The number of truncated packets can only be calculated by @@ -191,6 +192,7 @@ void enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats) r_stats->imissed = stats->rx.rx_no_bufs + rx_truncated; r_stats->rx_nombuf = rte_atomic64_read(&soft_stats->rx_nombuf); + return 0; } void enic_del_mac_address(struct enic *enic, int mac_index) diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index e0f1b0b..d360965 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -582,18 +582,25 @@ return -1; } -static void +static int fs_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct sub_device *sdev; uint8_t i; + int ret; rte_memcpy(stats, &PRIV(dev)->stats_accumulator, sizeof(*stats)); FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { - rte_eth_stats_get(PORT_ID(sdev), &sdev->stats_snapshot); + ret = rte_eth_stats_get(PORT_ID(sdev), &sdev->stats_snapshot); + if (ret) { + ERROR("Operation rte_eth_stats_get failed for sub_device %d with error %d", + i, ret); + return ret; + } failsafe_stats_increment(stats, &sdev->stats_snapshot); } + return 0; } static void diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 15ea2a5..2d351c1 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -1346,7 +1346,7 @@ static int fm10k_xstats_get_names(__rte_unused struct rte_eth_dev *dev, return FM10K_NB_XSTATS; } -static void +static int fm10k_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { uint64_t ipackets, opackets, ibytes, obytes; @@ -1376,6 +1376,7 @@ static int fm10k_xstats_get_names(__rte_unused struct rte_eth_dev *dev, stats->opackets = opackets; stats->ibytes = ibytes; stats->obytes = obytes; + return 0; } static void diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 536365d..f7dfb97 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -258,7 +258,7 @@ static void i40e_dev_allmulticast_disable(struct rte_eth_dev *dev); static int i40e_dev_set_link_up(struct rte_eth_dev *dev); static int i40e_dev_set_link_down(struct rte_eth_dev *dev); -static void i40e_dev_stats_get(struct rte_eth_dev *dev, +static int i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); @@ -2728,7 +2728,7 @@ static inline void i40e_GLQF_reg_init(struct i40e_hw *hw) } /* Get all statistics of a port */ -static void +static int i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); @@ -2828,6 +2828,7 @@ static inline void i40e_GLQF_reg_init(struct i40e_hw *hw) ns->checksum_error); PMD_DRV_LOG(DEBUG, "fdir_match: %"PRIu64"", ns->fd_sb_match); PMD_DRV_LOG(DEBUG, "***************** PF stats end ********************"); + return 0; } /* Reset the statistics */ diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 111ac39..a52321a 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -108,7 +108,7 @@ static void i40evf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); static int i40evf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); -static void i40evf_dev_stats_get(struct rte_eth_dev *dev, +static int i40evf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int i40evf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); @@ -2230,7 +2230,7 @@ static int eth_i40evf_pci_remove(struct rte_pci_device *pci_dev) }; } -static void +static int i40evf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { int ret; @@ -2253,6 +2253,7 @@ static int eth_i40evf_pci_remove(struct rte_pci_device *pci_dev) } else { PMD_DRV_LOG(ERR, "Get statistics failed"); } + return ret; } static void diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index a7d7acc..d22d7ac 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -176,7 +176,7 @@ static void ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev); static int ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); -static void ixgbe_dev_stats_get(struct rte_eth_dev *dev, +static int ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); @@ -269,7 +269,7 @@ static int ixgbevf_dev_link_update(struct rte_eth_dev *dev, static int ixgbevf_dev_reset(struct rte_eth_dev *dev); static void ixgbevf_intr_disable(struct ixgbe_hw *hw); static void ixgbevf_intr_enable(struct ixgbe_hw *hw); -static void ixgbevf_dev_stats_get(struct rte_eth_dev *dev, +static int ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev); static int ixgbevf_vlan_filter_set(struct rte_eth_dev *dev, @@ -3104,7 +3104,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) /* * This function is based on ixgbe_update_stats_counters() in ixgbe/ixgbe.c */ -static void +static int ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct ixgbe_hw *hw = @@ -3126,7 +3126,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) &total_qbrc, &total_qprc, &total_qprdc); if (stats == NULL) - return; + return -EINVAL; /* Fill out the rte_eth_stats statistics structure */ stats->ipackets = total_qprc; @@ -3157,6 +3157,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) /* Tx Errors */ stats->oerrors = 0; + return 0; } static void @@ -3568,7 +3569,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, return IXGBEVF_NB_XSTATS; } -static void +static int ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *) @@ -3577,12 +3578,13 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, ixgbevf_update_stats(dev); if (stats == NULL) - return; + return -EINVAL; stats->ipackets = hw_stats->vfgprc; stats->ibytes = hw_stats->vfgorc; stats->opackets = hw_stats->vfgptc; stats->obytes = hw_stats->vfgotc; + return 0; } static void diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c index 72a2733..d290c79 100644 --- a/drivers/net/kni/rte_eth_kni.c +++ b/drivers/net/kni/rte_eth_kni.c @@ -283,7 +283,7 @@ struct pmd_internals { return 0; } -static void +static int eth_kni_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { unsigned long rx_packets_total = 0, rx_bytes_total = 0; @@ -320,6 +320,8 @@ struct pmd_internals { stats->opackets = tx_packets_total; stats->obytes = tx_bytes_total; stats->oerrors = tx_packets_err_total; + + return 0; } static void diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index a3c8e67..5407e39 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -311,7 +311,7 @@ struct rte_lio_xstats_name_off { } /* Retrieve the device statistics (# packets in/out, # bytes in/out, etc */ -static void +static int lio_dev_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats) { @@ -359,6 +359,8 @@ struct rte_lio_xstats_name_off { stats->ibytes = bytes; stats->ipackets = pkts; stats->ierrors = drop; + + return 0; } static void diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index 93e5502..9bd2acc 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -117,7 +117,7 @@ struct priv { int mlx4_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); int mlx4_dev_set_link_down(struct rte_eth_dev *dev); int mlx4_dev_set_link_up(struct rte_eth_dev *dev); -void mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); +int mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); void mlx4_stats_reset(struct rte_eth_dev *dev); void mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info); diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index a9e8059..8962be1 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -571,7 +571,7 @@ * @param[out] stats * Stats structure output buffer. */ -void +int mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct rte_eth_stats tmp; @@ -613,6 +613,7 @@ tmp.oerrors += txq->stats.odropped; } *stats = tmp; + return 0; } /** diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 643bab6..bcdcc26 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -236,7 +236,7 @@ int mlx5_dev_rss_reta_update(struct rte_eth_dev *, /* mlx5_stats.c */ void priv_xstats_init(struct priv *); -void mlx5_stats_get(struct rte_eth_dev *, struct rte_eth_stats *); +int mlx5_stats_get(struct rte_eth_dev *, struct rte_eth_stats *); void mlx5_stats_reset(struct rte_eth_dev *); int mlx5_xstats_get(struct rte_eth_dev *, struct rte_eth_xstat *, unsigned int); diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c index 6b4772c..5e225d3 100644 --- a/drivers/net/mlx5/mlx5_stats.c +++ b/drivers/net/mlx5/mlx5_stats.c @@ -318,7 +318,7 @@ struct mlx5_counter_ctrl { * @param[out] stats * Stats structure output buffer. */ -void +int mlx5_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct priv *priv = mlx5_get_priv(dev); @@ -373,6 +373,7 @@ struct mlx5_counter_ctrl { #endif *stats = tmp; priv_unlock(priv); + return 0; } /** diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c index 46879a4..4beaa1d 100644 --- a/drivers/net/mrvl/mrvl_ethdev.c +++ b/drivers/net/mrvl/mrvl_ethdev.c @@ -845,8 +845,11 @@ struct mrvl_txq { * Pointer to Ethernet device structure. * @param stats * Stats structure output buffer. + * + * @return + * 0 on success, negative error value otherwise. */ -static void +static int mrvl_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct mrvl_priv *priv = dev->data->dev_private; @@ -919,7 +922,7 @@ struct mrvl_txq { ret = pp2_ppio_get_statistics(priv->ppio, &ppio_stats, 0); if (unlikely(ret)) { RTE_LOG(ERR, PMD, "Failed to update port statistics\n"); - return; + return ret; } stats->ipackets += ppio_stats.rx_packets - drop_mac; @@ -930,6 +933,8 @@ struct mrvl_txq { ppio_stats.rx_fifo_dropped + ppio_stats.rx_cls_dropped; stats->ierrors = drop_mac; + + return 0; } /** diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index 4ef9d2b..0917b9c 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -88,7 +88,7 @@ static int nfp_net_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_txconf *tx_conf); static int nfp_net_start(struct rte_eth_dev *dev); -static void nfp_net_stats_get(struct rte_eth_dev *dev, +static int nfp_net_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static void nfp_net_stats_reset(struct rte_eth_dev *dev); static void nfp_net_stop(struct rte_eth_dev *dev); @@ -1027,7 +1027,7 @@ enum nfp_qcp_ptr { return -1; } -static void +static int nfp_net_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { int i; @@ -1113,8 +1113,11 @@ enum nfp_qcp_ptr { nfp_dev_stats.imissed -= hw->eth_stats_base.imissed; - if (stats) + if (stats) { memcpy(stats, &nfp_dev_stats, sizeof(*stats)); + return 0; + } + return -EINVAL; } static void diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index fa9313d..47c7b14 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -298,7 +298,7 @@ struct pmd_internals { dev_info->flow_type_rss_offloads = internals->flow_type_rss_offloads; } -static void +static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) { unsigned i, num_stats; @@ -306,7 +306,7 @@ struct pmd_internals { const struct pmd_internals *internal; if ((dev == NULL) || (igb_stats == NULL)) - return; + return -EINVAL; internal = dev->data->dev_private; num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS, @@ -333,6 +333,8 @@ struct pmd_internals { igb_stats->ipackets = rx_total; igb_stats->opackets = tx_total; igb_stats->oerrors = tx_err_total; + + return 0; } static void diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index d41904f..d5f236e 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -199,7 +199,7 @@ enum octeontx_link_speed { nic->port_id, en ? "set" : "unset"); } -static void +static int octeontx_port_stats(struct octeontx_nic *nic, struct rte_eth_stats *stats) { octeontx_mbox_bgx_port_stats_t bgx_stats; @@ -208,8 +208,10 @@ enum octeontx_link_speed { PMD_INIT_FUNC_TRACE(); res = octeontx_bgx_port_stats(nic->port_id, &bgx_stats); - if (res < 0) + if (res < 0) { octeontx_log_err("failed to get port stats %d", nic->port_id); + return res; + } stats->ipackets = bgx_stats.rx_packets; stats->ibytes = bgx_stats.rx_bytes; @@ -221,6 +223,8 @@ enum octeontx_link_speed { octeontx_log_dbg("port %d get stats done inpkts=%ld outpkts=%ld", nic->port_id, stats->ipackets, stats->opackets); + + return 0; } static void @@ -574,13 +578,13 @@ enum octeontx_link_speed { return octeontx_atomic_write_link_status(dev, &link); } -static void +static int octeontx_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct octeontx_nic *nic = octeontx_pmd_priv(dev); PMD_INIT_FUNC_TRACE(); - octeontx_port_stats(nic, stats); + return octeontx_port_stats(nic, stats); } static void diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index b51f16c..1b8a74e 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -560,7 +560,7 @@ struct pmd_devargs { dev_info->min_rx_bufsize = 0; } -static void +static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { unsigned int i; @@ -592,6 +592,8 @@ struct pmd_devargs { stats->opackets = tx_packets_total; stats->obytes = tx_bytes_total; stats->oerrors = tx_packets_err_total; + + return 0; } static void diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c index fe130d4..a238781 100644 --- a/drivers/net/qede/qede_ethdev.c +++ b/drivers/net/qede/qede_ethdev.c @@ -1460,7 +1460,7 @@ static void qede_dev_close(struct rte_eth_dev *eth_dev) rte_eal_alarm_cancel(qede_poll_sp_sb_cb, (void *)eth_dev); } -static void +static int qede_get_stats(struct rte_eth_dev *eth_dev, struct rte_eth_stats *eth_stats) { struct qede_dev *qdev = eth_dev->data->dev_private; @@ -1544,6 +1544,8 @@ static void qede_dev_close(struct rte_eth_dev *eth_dev) if (j == txq_stat_cntrs) break; } + + return 0; } static unsigned diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index e3fa7b0..61473ca 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -190,7 +190,7 @@ struct pmd_internals { dev_info->min_rx_bufsize = 0; } -static void +static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { unsigned i; @@ -214,6 +214,8 @@ struct pmd_internals { stats->ipackets = rx_total; stats->opackets = tx_total; stats->oerrors = tx_err_total; + + return 0; } static void diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 7a57472..5b089dc 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -521,16 +521,18 @@ sfc_adapter_unlock(sa); } -static void +static int sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct sfc_adapter *sa = dev->data->dev_private; struct sfc_port *port = &sa->port; uint64_t *mac_stats; + int ret; rte_spinlock_lock(&port->mac_stats_lock); - if (sfc_port_update_mac_stats(sa) != 0) + ret = sfc_port_update_mac_stats(sa); + if (ret != 0) goto unlock; mac_stats = port->mac_stats_buf; @@ -587,6 +589,7 @@ unlock: rte_spinlock_unlock(&port->mac_stats_lock); + return ret; } static void diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c index d141acf..c5486b7 100644 --- a/drivers/net/szedata2/rte_eth_szedata2.c +++ b/drivers/net/szedata2/rte_eth_szedata2.c @@ -1042,7 +1042,7 @@ struct pmd_internals { dev_info->speed_capa = ETH_LINK_SPEED_100G; } -static void +static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { @@ -1077,6 +1077,8 @@ struct pmd_internals { stats->ibytes = rx_total_bytes; stats->obytes = tx_total_bytes; stats->oerrors = tx_err_total; + + return 0; } static void diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 52380b4..61c6774 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -687,7 +687,7 @@ enum ioctl_mode { DEV_TX_OFFLOAD_TCP_CKSUM); } -static void +static int tap_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *tap_stats) { unsigned int i, imax; @@ -728,6 +728,7 @@ enum ioctl_mode { tap_stats->opackets = tx_total; tap_stats->oerrors = tx_err_total; tap_stats->obytes = tx_bytes_total; + return 0; } static void diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index 4654a4c..551b371 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -242,7 +242,7 @@ static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic, return -ENOTSUP; } -static void +static int nicvf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { uint16_t qidx; @@ -332,6 +332,8 @@ static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic, stats->opackets += port_stats.tx_bcast_frames_ok; stats->opackets += port_stats.tx_mcast_frames_ok; stats->oerrors = port_stats.tx_drops; + + return 0; } static const uint32_t * diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 04179b4..3534649 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -890,7 +890,7 @@ struct vhost_xstats_name_off { dev_info->min_rx_bufsize = 0; } -static void +static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { unsigned i; @@ -928,6 +928,8 @@ struct vhost_xstats_name_off { stats->oerrors = tx_missed_total; stats->ibytes = rx_total_bytes; stats->obytes = tx_total_bytes; + + return 0; } static void diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index e320811..8660074 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -76,7 +76,7 @@ static int virtio_dev_link_update(struct rte_eth_dev *dev, static void virtio_set_hwaddr(struct virtio_hw *hw); static void virtio_get_hwaddr(struct virtio_hw *hw); -static void virtio_dev_stats_get(struct rte_eth_dev *dev, +static int virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int virtio_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); @@ -964,10 +964,12 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev, return count; } -static void +static int virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { virtio_update_stats(dev, stats); + + return 0; } static void diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index 1cc3ffd..58bc4f2 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -87,7 +87,7 @@ static int __vmxnet3_dev_link_update(struct rte_eth_dev *dev, static int vmxnet3_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); static void vmxnet3_hw_stats_save(struct vmxnet3_hw *hw); -static void vmxnet3_dev_stats_get(struct rte_eth_dev *dev, +static int vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int vmxnet3_dev_xstats_get_names(struct rte_eth_dev *dev, struct rte_eth_xstat_name *xstats, @@ -1034,7 +1034,7 @@ static int eth_vmxnet3_pci_remove(struct rte_pci_device *pci_dev) return count; } -static void +static int vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { unsigned int i; @@ -1080,6 +1080,8 @@ static int eth_vmxnet3_pci_remove(struct rte_pci_device *pci_dev) stats->ierrors += rxStats.pktsRxError; stats->rx_nombuf += rxStats.pktsRxOutOfBuf; } + + return 0; } static void diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 3c5441e..d88f734 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1531,8 +1531,7 @@ struct rte_eth_dev * RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, -ENOTSUP); stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed; - (*dev->dev_ops->stats_get)(dev, stats); - return 0; + return (*dev->dev_ops->stats_get)(dev, stats); } int diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 8e928da..71e6b33 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1207,7 +1207,7 @@ typedef int (*eth_link_update_t)(struct rte_eth_dev *dev, int wait_to_complete); /**< @internal Get link speed, duplex mode and state (up/down) of an Ethernet device. */ -typedef void (*eth_stats_get_t)(struct rte_eth_dev *dev, +typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats); /**< @internal Get global I/O statistics of an Ethernet device. */ -- 1.8.3.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v2] ethdev: add return value to stats get dev op 2017-10-10 20:20 ` [dpdk-dev] [PATCH v2] " Matan Azrad @ 2017-10-11 2:01 ` Ferruh Yigit 2017-10-11 2:09 ` Ferruh Yigit 0 siblings, 1 reply; 10+ messages in thread From: Ferruh Yigit @ 2017-10-11 2:01 UTC (permalink / raw) To: Matan Azrad, dev On 10/10/2017 9:20 PM, Matan Azrad wrote: > The stats_get dev op API doesn't include return value, so PMD cannot > return an error in case of failure at stats getting process time. > > Since PCI devices can be removed and there is a time between the > physical removal to the RMV interrupt, the user may get invalid stats > without any indication. > > This patch changes the stats_get API return value to be int instead of > void. > > All the net PMDs stats_get dev ops are adjusted by this patch. > > Signed-off-by: Matan Azrad <matan@mellanox.com> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v2] ethdev: add return value to stats get dev op 2017-10-11 2:01 ` Ferruh Yigit @ 2017-10-11 2:09 ` Ferruh Yigit 2017-10-11 10:46 ` Thomas Monjalon 0 siblings, 1 reply; 10+ messages in thread From: Ferruh Yigit @ 2017-10-11 2:09 UTC (permalink / raw) To: Matan Azrad, dev On 10/11/2017 3:01 AM, Ferruh Yigit wrote: > On 10/10/2017 9:20 PM, Matan Azrad wrote: >> The stats_get dev op API doesn't include return value, so PMD cannot >> return an error in case of failure at stats getting process time. >> >> Since PCI devices can be removed and there is a time between the >> physical removal to the RMV interrupt, the user may get invalid stats >> without any indication. >> >> This patch changes the stats_get API return value to be int instead of >> void. >> >> All the net PMDs stats_get dev ops are adjusted by this patch. >> >> Signed-off-by: Matan Azrad <matan@mellanox.com> > > Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com> Applied to dpdk-next-net/master, thanks. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v2] ethdev: add return value to stats get dev op 2017-10-11 2:09 ` Ferruh Yigit @ 2017-10-11 10:46 ` Thomas Monjalon 2017-10-11 13:09 ` Andrew Rybchenko 0 siblings, 1 reply; 10+ messages in thread From: Thomas Monjalon @ 2017-10-11 10:46 UTC (permalink / raw) To: Ferruh Yigit, Matan Azrad; +Cc: dev 11/10/2017 04:09, Ferruh Yigit: > On 10/11/2017 3:01 AM, Ferruh Yigit wrote: > > On 10/10/2017 9:20 PM, Matan Azrad wrote: > >> The stats_get dev op API doesn't include return value, so PMD cannot > >> return an error in case of failure at stats getting process time. > >> > >> Since PCI devices can be removed and there is a time between the > >> physical removal to the RMV interrupt, the user may get invalid stats > >> without any indication. > >> > >> This patch changes the stats_get API return value to be int instead of > >> void. > >> > >> All the net PMDs stats_get dev ops are adjusted by this patch. > >> > >> Signed-off-by: Matan Azrad <matan@mellanox.com> > > > > Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com> > > Applied to dpdk-next-net/master, thanks. It is breaking compilation of tests: test/test/virtual_pmd.c:256:15: fatal error: incompatible pointer types initializing 'eth_stats_get_t' (aka 'int (*)(struct rte_eth_dev *, struct rte_eth_stats *)') with an expression of type 'void (struct rte_eth_dev *, struct rte_eth_stats *)' [-Wincompatible-pointer-types] .stats_get = virtual_ethdev_stats_get, ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v2] ethdev: add return value to stats get dev op 2017-10-11 10:46 ` Thomas Monjalon @ 2017-10-11 13:09 ` Andrew Rybchenko 2017-10-11 13:14 ` Thomas Monjalon 0 siblings, 1 reply; 10+ messages in thread From: Andrew Rybchenko @ 2017-10-11 13:09 UTC (permalink / raw) To: Thomas Monjalon, Ferruh Yigit, Matan Azrad; +Cc: dev On 10/11/2017 01:46 PM, Thomas Monjalon wrote: > 11/10/2017 04:09, Ferruh Yigit: >> On 10/11/2017 3:01 AM, Ferruh Yigit wrote: >>> On 10/10/2017 9:20 PM, Matan Azrad wrote: >>>> The stats_get dev op API doesn't include return value, so PMD cannot >>>> return an error in case of failure at stats getting process time. >>>> >>>> Since PCI devices can be removed and there is a time between the >>>> physical removal to the RMV interrupt, the user may get invalid stats >>>> without any indication. >>>> >>>> This patch changes the stats_get API return value to be int instead of >>>> void. >>>> >>>> All the net PMDs stats_get dev ops are adjusted by this patch. >>>> >>>> Signed-off-by: Matan Azrad <matan@mellanox.com> >>> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com> >> Applied to dpdk-next-net/master, thanks. > It is breaking compilation of tests: > > test/test/virtual_pmd.c:256:15: fatal error: incompatible pointer types > initializing 'eth_stats_get_t' (aka 'int (*)(struct rte_eth_dev *, struct rte_eth_stats *)') > with an expression of type 'void (struct rte_eth_dev *, struct rte_eth_stats *)' > [-Wincompatible-pointer-types] > .stats_get = virtual_ethdev_stats_get, I've bumped into it this morning as well: http://dpdk.org/dev/patchwork/patch/30090/ ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v2] ethdev: add return value to stats get dev op 2017-10-11 13:09 ` Andrew Rybchenko @ 2017-10-11 13:14 ` Thomas Monjalon 0 siblings, 0 replies; 10+ messages in thread From: Thomas Monjalon @ 2017-10-11 13:14 UTC (permalink / raw) To: Andrew Rybchenko; +Cc: Ferruh Yigit, Matan Azrad, dev 11/10/2017 15:09, Andrew Rybchenko: > On 10/11/2017 01:46 PM, Thomas Monjalon wrote: > > 11/10/2017 04:09, Ferruh Yigit: > >> On 10/11/2017 3:01 AM, Ferruh Yigit wrote: > >>> On 10/10/2017 9:20 PM, Matan Azrad wrote: > >>>> The stats_get dev op API doesn't include return value, so PMD cannot > >>>> return an error in case of failure at stats getting process time. > >>>> > >>>> Since PCI devices can be removed and there is a time between the > >>>> physical removal to the RMV interrupt, the user may get invalid stats > >>>> without any indication. > >>>> > >>>> This patch changes the stats_get API return value to be int instead of > >>>> void. > >>>> > >>>> All the net PMDs stats_get dev ops are adjusted by this patch. > >>>> > >>>> Signed-off-by: Matan Azrad <matan@mellanox.com> > >>> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com> > >> Applied to dpdk-next-net/master, thanks. > > It is breaking compilation of tests: > > > > test/test/virtual_pmd.c:256:15: fatal error: incompatible pointer types > > initializing 'eth_stats_get_t' (aka 'int (*)(struct rte_eth_dev *, struct rte_eth_stats *)') > > with an expression of type 'void (struct rte_eth_dev *, struct rte_eth_stats *)' > > [-Wincompatible-pointer-types] > > .stats_get = virtual_ethdev_stats_get, > > I've bumped into it this morning as well: > http://dpdk.org/dev/patchwork/patch/30090/ Thank you Andrew. Ferruh, please squash Andrew's patches to avoid any compilation issue. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-10-11 13:14 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-10-09 16:12 [dpdk-dev] [PATCH 1/2] ethdev: add return value to stats get dev op Matan Azrad 2017-10-09 16:12 ` [dpdk-dev] [PATCH 2/2] doc: update stats get API change Matan Azrad 2017-10-09 21:07 ` Thomas Monjalon 2017-10-09 23:57 ` [dpdk-dev] [PATCH 1/2] ethdev: add return value to stats get dev op Ferruh Yigit 2017-10-10 20:20 ` [dpdk-dev] [PATCH v2] " Matan Azrad 2017-10-11 2:01 ` Ferruh Yigit 2017-10-11 2:09 ` Ferruh Yigit 2017-10-11 10:46 ` Thomas Monjalon 2017-10-11 13:09 ` Andrew Rybchenko 2017-10-11 13:14 ` Thomas Monjalon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).