From: Xiaoyun Wang Date: Fri, 10 Apr 2020 09:21:47 +0000 (+0800) Subject: net/hinic: adds Tx queue xstats members X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=54faba2295bdc5406cbbbe150189619c7b552fe8 net/hinic: adds Tx queue xstats members 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 --- diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c index 4091cf18b8..cfbca64053 100644 --- a/drivers/net/hinic/hinic_pmd_ethdev.c +++ b/drivers/net/hinic/hinic_pmd_ethdev.c @@ -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) / \ diff --git a/drivers/net/hinic/hinic_pmd_tx.c b/drivers/net/hinic/hinic_pmd_tx.c index f24e3e4202..258f2c1c4a 100644 --- a/drivers/net/hinic/hinic_pmd_tx.c +++ b/drivers/net/hinic/hinic_pmd_tx.c @@ -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)) diff --git a/drivers/net/hinic/hinic_pmd_tx.h b/drivers/net/hinic/hinic_pmd_tx.h index dabbc6c1d8..d98abad8da 100644 --- a/drivers/net/hinic/hinic_pmd_tx.h +++ b/drivers/net/hinic/hinic_pmd_tx.h @@ -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 {