From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6ECCEA059B; Fri, 10 Apr 2020 10:58:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B09D21D442; Fri, 10 Apr 2020 10:57:54 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id 85B301D41E for ; Fri, 10 Apr 2020 10:57:53 +0200 (CEST) Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 2B1E5FB247F91BF55994; Fri, 10 Apr 2020 16:57:52 +0800 (CST) Received: from tester.localdomain (10.175.119.39) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Fri, 10 Apr 2020 16:57:45 +0800 From: Xiaoyun wang To: CC: , , , , , , , Xiaoyun wang Date: Fri, 10 Apr 2020 17:21:47 +0800 Message-ID: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.119.39] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v4 3/3] net/hinic: adds txq xstats member X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- drivers/net/hinic/hinic_pmd_ethdev.c | 2 ++ drivers/net/hinic/hinic_pmd_tx.c | 31 +++++++++++++++++++++++++++++++ drivers/net/hinic/hinic_pmd_tx.h | 2 ++ 3 files changed, 35 insertions(+) diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c index 4091cf1..cfbca64 100644 --- a/drivers/net/hinic/hinic_pmd_ethdev.c +++ b/drivers/net/hinic/hinic_pmd_ethdev.c @@ -225,6 +225,8 @@ struct hinic_xstats_name_off { {"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 f24e3e4..258f2c1 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 dabbc6c..d98abad 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 { -- 1.8.3.1