DPDK patches and discussions
 help / color / mirror / Atom feed
From: Xiaoyun wang <cloud.wangxiaoyun@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <bluca@debian.org>,
	<luoxianjun@huawei.com>, <luoxingyu@huawei.com>,
	<zhouguoyang@huawei.com>, <shahar.belkar@huawei.com>,
	 <yin.yinshi@huawei.com>,
	Xiaoyun wang <cloud.wangxiaoyun@huawei.com>
Subject: [dpdk-dev] [PATCH v4 3/3] net/hinic: adds txq xstats member
Date: Fri, 10 Apr 2020 17:21:47 +0800	[thread overview]
Message-ID: <f76a4393b6944a235f94f7aabf6a27c4920a9ca6.1586508802.git.cloud.wangxiaoyun@huawei.com> (raw)
In-Reply-To: <cover.1586508802.git.cloud.wangxiaoyun@huawei.com>

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 |  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


  parent reply	other threads:[~2020-04-10  8:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-10  9:21 [dpdk-dev] [PATCH v4 0/3] Fix and add txq xstats Xiaoyun wang
2020-04-10  9:21 ` [dpdk-dev] [PATCH v4 1/3] net/hinic/base: fix PF firmware hotactive problem Xiaoyun wang
2020-04-10  9:21 ` [dpdk-dev] [PATCH v4 2/3] net/hinic/base: optimize log style Xiaoyun wang
2020-04-10  9:21 ` Xiaoyun wang [this message]
2020-04-10 13:42 ` [dpdk-dev] [PATCH v4 0/3] Fix and add txq xstats Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f76a4393b6944a235f94f7aabf6a27c4920a9ca6.1586508802.git.cloud.wangxiaoyun@huawei.com \
    --to=cloud.wangxiaoyun@huawei.com \
    --cc=bluca@debian.org \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=luoxianjun@huawei.com \
    --cc=luoxingyu@huawei.com \
    --cc=shahar.belkar@huawei.com \
    --cc=yin.yinshi@huawei.com \
    --cc=zhouguoyang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).