The SP230 VF does not expose rx/tx counters through the vport statistics path, so aggregate the software queue counters instead to return meaningful ipackets/ibytes/opackets/obytes for VF ports.
Signed-off-by: Jiacheng Ye <[email protected]> --- drivers/net/hinic3/hinic3_ethdev.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c index 32218fa0f6..05382bc6db 100644 --- a/drivers/net/hinic3/hinic3_ethdev.c +++ b/drivers/net/hinic3/hinic3_ethdev.c @@ -2922,13 +2922,16 @@ hinic3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats, struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); struct hinic3_vport_stats vport_stats; uint64_t rx_discards_pmd = 0; + bool sw_stats = HINIC3_IS_VF(nic_dev->hwdev) && HINIC3_IS_SP230_NIC(nic_dev); int err; - err = hinic3_get_vport_stats(nic_dev->hwdev, &vport_stats); - if (err) { - PMD_DRV_LOG(ERR, "Get vport stats from fw failed, nic_dev: %s", - nic_dev->dev_name); - return err; + if (!sw_stats) { + err = hinic3_get_vport_stats(nic_dev->hwdev, &vport_stats); + if (err) { + PMD_DRV_LOG(ERR, "Get vport stats from fw failed, nic_dev: %s", + nic_dev->dev_name); + return err; + } } /* Rx queue stats. */ @@ -2949,6 +2952,12 @@ hinic3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats, stats->ierrors += rxq->rxq_stats.errors; rx_discards_pmd += rxq->rxq_stats.dropped; dev->data->rx_mbuf_alloc_failed += rxq->rxq_stats.rx_nombuf; + + if (sw_stats) { + stats->ipackets += rxq->rxq_stats.packets; + stats->ibytes += rxq->rxq_stats.bytes; + stats->imissed += rxq->rxq_stats.dropped; + } } /* Tx queue stats. */ @@ -2959,8 +2968,16 @@ hinic3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats, qstats[i].q_opackets = txq->txq_stats.packets; qstats[i].q_obytes = txq->txq_stats.bytes; } + + if (sw_stats) { + stats->opackets += txq->txq_stats.packets; + stats->obytes += txq->txq_stats.bytes; + } } + if (sw_stats) + return 0; + /* Vport stats. */ stats->oerrors += vport_stats.tx_discard_vport; -- 2.33.0

