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 5B33BA04C3; Fri, 22 Nov 2019 15:16:49 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9F7505B3E; Fri, 22 Nov 2019 15:16:02 +0100 (CET) Received: from smtp.tom.com (smtprz14.163.net [106.3.154.247]) by dpdk.org (Postfix) with ESMTP id 4A48C2C08 for ; Fri, 22 Nov 2019 13:17:44 +0100 (CET) Received: from my-app01.tom.com (my-app01.tom.com [127.0.0.1]) by freemail01.tom.com (Postfix) with ESMTP id 042181C81A49 for ; Fri, 22 Nov 2019 20:06:38 +0800 (CST) Received: from my-app01.tom.com (HELO smtp.tom.com) ([127.0.0.1]) by my-app01 (TOM SMTP Server) with SMTP ID -604769835 for ; Fri, 22 Nov 2019 20:06:38 +0800 (CST) Received: from antispam1.tom.com (unknown [172.25.16.55]) by freemail01.tom.com (Postfix) with ESMTP id 005841C81A1F for ; Fri, 22 Nov 2019 20:06:37 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tom.com; s=201807; t=1574424398; bh=7W4WK+qM7clPkaCnQs3bArPuBbKunpoExc59NEdMfBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=epGjeJzaCaAzGtvr2xauAVDOaqz5cza7kp5L5wz3EMDEOebzuOD0zRBl2vv87VEo8 q3iKYS4TOPMub441la+2YeRNjxKcjYlMcNu9ujm3DxlfW5Jh37mA9l4DduP3UgGICY 3SSlRsTtI2u5PDtiAdh6BMDAgQepN6EKLYO+v6jI= Received: from antispam1.tom.com (antispam1.tom.com [127.0.0.1]) by antispam1.tom.com (Postfix) with ESMTP id 0467B1001873 for ; Fri, 22 Nov 2019 20:06:09 +0800 (CST) X-Virus-Scanned: Debian amavisd-new at antispam1.tom.com Received: from antispam1.tom.com ([127.0.0.1]) by antispam1.tom.com (antispam1.tom.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aBIi5DL8IbvQ for ; Fri, 22 Nov 2019 20:06:08 +0800 (CST) Received: from localhost.localdomain (unknown [203.160.91.226]) by antispam1.tom.com (Postfix) with ESMTPA id C436710017BC; Fri, 22 Nov 2019 20:06:07 +0800 (CST) From: "Wei Hu (Xavier)" To: dev@dpdk.org, stable@dpdk.org Cc: xavier_huwei@163.com, xavier.huwei@tom.com, huwei87@hisilicon.com Date: Fri, 22 Nov 2019 20:06:21 +0800 Message-Id: <20191122120624.4963-4-xavier.huwei@tom.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191122120624.4963-1-xavier.huwei@tom.com> References: <20191122120624.4963-1-xavier.huwei@tom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 22 Nov 2019 15:15:52 +0100 Subject: [dpdk-dev] [PATCH 3/6] net/hns3: fix the failure sending packets less than 60 bytes 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" From: "Wei Hu (Xavier)" 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 Signed-off-by: Wei Hu (Xavier) --- 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