Count the number of packets not sent due to Tx descriptor error.

Signed-off-by: Jiawen Wu <jiawe...@trustnetic.com>
---
 drivers/net/ngbe/ngbe_ethdev.c | 6 ++++++
 drivers/net/ngbe/ngbe_rxtx.c   | 2 ++
 drivers/net/ngbe/ngbe_rxtx.h   | 1 +
 3 files changed, 9 insertions(+)

diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c
index 6c45ffaad3..d9d2daf656 100644
--- a/drivers/net/ngbe/ngbe_ethdev.c
+++ b/drivers/net/ngbe/ngbe_ethdev.c
@@ -1507,6 +1507,7 @@ ngbe_dev_stats_get(struct rte_eth_dev *dev, struct 
rte_eth_stats *stats)
        struct ngbe_hw_stats *hw_stats = NGBE_DEV_STATS(dev);
        struct ngbe_stat_mappings *stat_mappings =
                        NGBE_DEV_STAT_MAPPINGS(dev);
+       struct ngbe_tx_queue *txq;
        uint32_t i, j;
 
        ngbe_read_stats_registers(hw, hw_stats);
@@ -1559,6 +1560,11 @@ ngbe_dev_stats_get(struct rte_eth_dev *dev, struct 
rte_eth_stats *stats)
 
        /* Tx Errors */
        stats->oerrors  = 0;
+       for (i = 0; i < dev->data->nb_tx_queues; i++) {
+               txq = dev->data->tx_queues[i];
+               stats->oerrors += txq->desc_error;
+       }
+
        return 0;
 }
 
diff --git a/drivers/net/ngbe/ngbe_rxtx.c b/drivers/net/ngbe/ngbe_rxtx.c
index 25a314f10a..8d31d47de9 100644
--- a/drivers/net/ngbe/ngbe_rxtx.c
+++ b/drivers/net/ngbe/ngbe_rxtx.c
@@ -629,6 +629,7 @@ ngbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
                tx_pkt = *tx_pkts++;
                if (ngbe_check_pkt_err(tx_pkt)) {
                        rte_pktmbuf_free(tx_pkt);
+                       txq->desc_error++;
                        continue;
                }
 
@@ -2100,6 +2101,7 @@ ngbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
        ngbe_set_tx_function(dev, txq);
 
        txq->ops->reset(txq);
+       txq->desc_error = 0;
 
        dev->data->tx_queues[queue_idx] = txq;
 
diff --git a/drivers/net/ngbe/ngbe_rxtx.h b/drivers/net/ngbe/ngbe_rxtx.h
index 7574db32d8..8534ec123a 100644
--- a/drivers/net/ngbe/ngbe_rxtx.h
+++ b/drivers/net/ngbe/ngbe_rxtx.h
@@ -375,6 +375,7 @@ struct ngbe_tx_queue {
 
        const struct ngbe_txq_ops *ops;       /**< txq ops */
        const struct rte_memzone *mz;
+       uint64_t            desc_error;
 };
 
 struct ngbe_txq_ops {
-- 
2.27.0

Reply via email to