DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Wei Hu (Xavier)" <xavier.huwei@tom.com>
To: dev@dpdk.org, stable@dpdk.org
Cc: xavier_huwei@163.com, xavier.huwei@tom.com, huwei87@hisilicon.com
Subject: [dpdk-dev] [PATCH 3/6] net/hns3: fix the failure sending packets less than 60 bytes
Date: Fri, 22 Nov 2019 20:06:21 +0800	[thread overview]
Message-ID: <20191122120624.4963-4-xavier.huwei@tom.com> (raw)
In-Reply-To: <20191122120624.4963-1-xavier.huwei@tom.com>

From: "Wei Hu (Xavier)" <xavier_huwei@163.com>

Ethernet minimum packet length is 64 bytes. If upper application
sends packets with less than 60 bytes in length(no CRC), driver
adds padding processing to avoid failure.

Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier_huwei@163.com>
---
 drivers/net/hns3/hns3_ethdev.h |  1 +
 drivers/net/hns3/hns3_rxtx.c   | 24 ++++++++++++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index 9710e45fb..e9a3fe410 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -43,6 +43,7 @@
 #define HNS3_MAX_MTU	(HNS3_MAX_FRAME_LEN - HNS3_ETH_OVERHEAD)
 #define HNS3_DEFAULT_MTU		1500UL
 #define HNS3_DEFAULT_FRAME_LEN		(HNS3_DEFAULT_MTU + HNS3_ETH_OVERHEAD)
+#define HNS3_MIN_PKT_SIZE		60
 
 #define HNS3_4_TCS			4
 #define HNS3_8_TCS			8
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 1de238b4c..34cb7faf9 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -1598,13 +1598,29 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		}
 
 		/*
-		 * If the length of the packet is too long or zero, the packet
-		 * will be ignored.
+		 * If packet length is greater than HNS3_MAX_FRAME_LEN
+		 * driver support, the packet will be ignored.
 		 */
-		if (unlikely(tx_pkt->pkt_len > HNS3_MAX_FRAME_LEN ||
-			     tx_pkt->pkt_len == 0))
+		if (unlikely(rte_pktmbuf_pkt_len(tx_pkt) > HNS3_MAX_FRAME_LEN))
 			break;
 
+		/*
+		 * If packet length is less than minimum packet size, driver
+		 * need to pad it.
+		 */
+		if (unlikely(rte_pktmbuf_pkt_len(tx_pkt) < HNS3_MIN_PKT_SIZE)) {
+			uint16_t add_len;
+			char *appended;
+
+			add_len = HNS3_MIN_PKT_SIZE -
+					 rte_pktmbuf_pkt_len(tx_pkt);
+			appended = rte_pktmbuf_append(tx_pkt, add_len);
+			if (appended == NULL)
+				break;
+
+			memset(appended, 0, add_len);
+		}
+
 		m_seg = tx_pkt;
 		if (unlikely(nb_buf > HNS3_MAX_TX_BD_PER_PKT)) {
 			if (hns3_reassemble_tx_pkts(txq, tx_pkt, &new_pkt))
-- 
2.23.0


  parent reply	other threads:[~2019-11-22 14:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22 12:06 [dpdk-dev] [PATCH 0/6] Fixes for hns3 PMD driver Wei Hu (Xavier)
2019-11-22 12:06 ` [dpdk-dev] [PATCH 1/6] net/hns3: fix RSS hardware configuration restore failure Wei Hu (Xavier)
2019-11-22 12:06 ` [dpdk-dev] [PATCH 2/6] net/hns3: fix VF configuration table entries " Wei Hu (Xavier)
2019-11-22 15:42   ` Ferruh Yigit
2019-11-22 12:06 ` Wei Hu (Xavier) [this message]
2019-11-22 12:06 ` [dpdk-dev] [PATCH 4/6] net/hns3: fix the error length limit of maiblox response Wei Hu (Xavier)
2019-11-22 12:06 ` [dpdk-dev] [PATCH 5/6] net/hns3: fix the strategy of getting link status for VF Wei Hu (Xavier)
2019-11-22 12:06 ` [dpdk-dev] [PATCH 6/6] net/hns3: fix duplicate VLAN Wei Hu (Xavier)
2019-11-22 16:31 ` [dpdk-dev] [PATCH 0/6] Fixes for hns3 PMD driver 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=20191122120624.4963-4-xavier.huwei@tom.com \
    --to=xavier.huwei@tom.com \
    --cc=dev@dpdk.org \
    --cc=huwei87@hisilicon.com \
    --cc=stable@dpdk.org \
    --cc=xavier_huwei@163.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).