net/hinic: adds Tx queue xstats members
authorXiaoyun Wang <cloud.wangxiaoyun@huawei.com>
Fri, 10 Apr 2020 09:21:47 +0000 (17:21 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Apr 2020 11:57:07 +0000 (13:57 +0200)
Because some apps may pass illegal parameters, driver increases
checks on illegal parameters and DFX statistics, which includes
sge_len0 and mbuf_null txq xstats member.

Signed-off-by: Xiaoyun Wang <cloud.wangxiaoyun@huawei.com>
drivers/net/hinic/hinic_pmd_ethdev.c
drivers/net/hinic/hinic_pmd_tx.c
drivers/net/hinic/hinic_pmd_tx.h

index 4091cf1..cfbca64 100644 (file)
@@ -225,6 +225,8 @@ static const struct hinic_xstats_name_off hinic_txq_stats_strings[] = {
        {"copy_pkts", offsetof(struct hinic_txq_stats, cpy_pkts)},
        {"rl_drop", offsetof(struct hinic_txq_stats, rl_drop)},
        {"burst_pkts", offsetof(struct hinic_txq_stats, burst_pkts)},
+       {"sge_len0", offsetof(struct hinic_txq_stats, sge_len0)},
+       {"mbuf_null", offsetof(struct hinic_txq_stats, mbuf_null)},
 };
 
 #define HINIC_TXQ_XSTATS_NUM (sizeof(hinic_txq_stats_strings) / \
index f24e3e4..258f2c1 100644 (file)
@@ -334,7 +334,16 @@ static inline bool hinic_mbuf_dma_map_sge(struct hinic_txq *txq,
                i = 0;
                for (sge_idx = sges; (u64)sge_idx <= txq->sq_bot_sge_addr;
                     sge_idx++) {
+                       if (unlikely(mbuf == NULL)) {
+                               txq->txq_stats.mbuf_null++;
+                               return false;
+                       }
+
                        dma_addr = rte_mbuf_data_iova(mbuf);
+                       if (unlikely(mbuf->data_len == 0)) {
+                               txq->txq_stats.sge_len0++;
+                               return false;
+                       }
                        hinic_set_sge((struct hinic_sge *)sge_idx, dma_addr,
                                      mbuf->data_len);
                        mbuf = mbuf->next;
@@ -345,7 +354,16 @@ static inline bool hinic_mbuf_dma_map_sge(struct hinic_txq *txq,
                sge_idx = (struct hinic_sq_bufdesc *)
                                ((void *)txq->sq_head_addr);
                for (; i < nb_segs; i++) {
+                       if (unlikely(mbuf == NULL)) {
+                               txq->txq_stats.mbuf_null++;
+                               return false;
+                       }
+
                        dma_addr = rte_mbuf_data_iova(mbuf);
+                       if (unlikely(mbuf->data_len == 0)) {
+                               txq->txq_stats.sge_len0++;
+                               return false;
+                       }
                        hinic_set_sge((struct hinic_sge *)sge_idx, dma_addr,
                                      mbuf->data_len);
                        mbuf = mbuf->next;
@@ -357,7 +375,16 @@ static inline bool hinic_mbuf_dma_map_sge(struct hinic_txq *txq,
        } else {
                /* wqe is in continuous space */
                for (i = 0; i < nb_segs; i++) {
+                       if (unlikely(mbuf == NULL)) {
+                               txq->txq_stats.mbuf_null++;
+                               return false;
+                       }
+
                        dma_addr = rte_mbuf_data_iova(mbuf);
+                       if (unlikely(mbuf->data_len == 0)) {
+                               txq->txq_stats.sge_len0++;
+                               return false;
+                       }
                        hinic_set_sge((struct hinic_sge *)sge_idx, dma_addr,
                                      mbuf->data_len);
                        mbuf = mbuf->next;
@@ -378,6 +405,10 @@ static inline bool hinic_mbuf_dma_map_sge(struct hinic_txq *txq,
 
                /* deal with the last mbuf */
                dma_addr = rte_mbuf_data_iova(mbuf);
+               if (unlikely(mbuf->data_len == 0)) {
+                       txq->txq_stats.sge_len0++;
+                       return false;
+               }
                hinic_set_sge((struct hinic_sge *)sge_idx, dma_addr,
                              mbuf->data_len);
                if (unlikely(sqe_info->around))
index dabbc6c..d98abad 100644 (file)
@@ -93,6 +93,8 @@ struct hinic_txq_stats {
        u64 off_errs;
        u64 cpy_pkts;
        u64 burst_pkts;
+       u64 sge_len0;
+       u64 mbuf_null;
 };
 
 struct hinic_tx_info {