From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A583A41BAB for ; Thu, 2 Feb 2023 10:25:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9B2BA42D75; Thu, 2 Feb 2023 10:25:53 +0100 (CET) Received: from smtpbg151.qq.com (smtpbg151.qq.com [18.169.211.239]) by mails.dpdk.org (Postfix) with ESMTP id B255D42D59; Thu, 2 Feb 2023 10:25:49 +0100 (CET) X-QQ-mid: bizesmtp85t1675329946txmn6fua Received: from wxdbg.localdomain.com ( [183.129.236.74]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 02 Feb 2023 17:25:45 +0800 (CST) X-QQ-SSF: 01400000002000H0Y000B00A0000000 X-QQ-FEAT: +oIWmpEafD9keW1LoSZX9BYloMI7NuLPscTz5aHzVmub5/rKvGeLV4vl9uCFn jigv48R5M5Z53kJnbaqkQwMjZRCBEPWOsqC7/5cLencfsuEm4QyJXY20bWVAH9acx7/eRle GVXwL13inyQJTg/0TE8oqWqGPukjzuzP1oU6UQt5Y53QOs91cutZkL7P2MZot/dpL+wZOlg m2L1aneSKHuBkMdIV4hAZQ1J9NvKJvIwcFJOgSyfoM2ghl/3dsXeYZpR82N09mIV9/so12d 7j0qi761LxZAIYF/WftFpl4jgyinmjLHwGcfCZW3zwYzafRwUgbckjx3XdgfsSE4S/O9tv2 3tbfKutxbDbHEDiaS80N7GkBoH45KK5zed7USu0MT2JTjTo5GRPWMDX/60TYQE64XGTTyx7 x/KU1f/SqlnZ9eri7Wflgw== X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu , stable@dpdk.org Subject: [PATCH v2 04/10] net/txgbe: fix packet type to parse from offload flags Date: Thu, 2 Feb 2023 17:21:26 +0800 Message-Id: <20230202092132.3271910-5-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230202092132.3271910-1-jiawenwu@trustnetic.com> References: <20230118060039.3074016-1-jiawenwu@trustnetic.com> <20230202092132.3271910-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybglogicsvr:qybglogicsvr5 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Context descriptors which contains the length of each packet layer and the packet type are needed when Tx checksum offload or TSO is on. If the packet type and length do not strictly match, it will cause Tx ring hang. In some external applications, developers may fill in wrong packet_type in rte_mbuf for Tx path. For example, they encap/decap the packets but did not refill the packet_type. To prevent this, change it to parse from ol_flags. Fixes: ca46fcd753b1 ("net/txgbe: support Tx with hardware offload") Cc: stable@dpdk.org Signed-off-by: Jiawen Wu --- drivers/net/txgbe/txgbe_rxtx.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/net/txgbe/txgbe_rxtx.c b/drivers/net/txgbe/txgbe_rxtx.c index 328406908d..f7e3159dc9 100644 --- a/drivers/net/txgbe/txgbe_rxtx.c +++ b/drivers/net/txgbe/txgbe_rxtx.c @@ -516,20 +516,21 @@ tx_desc_ol_flags_to_cmdtype(uint64_t ol_flags) return cmdtype; } -static inline uint8_t -tx_desc_ol_flags_to_ptid(uint64_t oflags, uint32_t ptype) +static inline uint32_t +tx_desc_ol_flags_to_ptype(uint64_t oflags) { + uint32_t ptype; bool tun; - if (ptype) - return txgbe_encode_ptype(ptype); - /* Only support flags in TXGBE_TX_OFFLOAD_MASK */ tun = !!(oflags & RTE_MBUF_F_TX_TUNNEL_MASK); /* L2 level */ ptype = RTE_PTYPE_L2_ETHER; if (oflags & RTE_MBUF_F_TX_VLAN) + ptype |= (tun ? RTE_PTYPE_INNER_L2_ETHER_VLAN : RTE_PTYPE_L2_ETHER_VLAN); + + if (oflags & RTE_MBUF_F_TX_QINQ) /* tunnel + QINQ is not supported */ ptype |= RTE_PTYPE_L2_ETHER_VLAN; /* L3 level */ @@ -587,6 +588,16 @@ tx_desc_ol_flags_to_ptid(uint64_t oflags, uint32_t ptype) break; } + return ptype; +} + +static inline uint8_t +tx_desc_ol_flags_to_ptid(uint64_t oflags) +{ + uint32_t ptype; + + ptype = tx_desc_ol_flags_to_ptype(oflags); + return txgbe_encode_ptype(ptype); } @@ -776,8 +787,7 @@ txgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, /* If hardware offload required */ tx_ol_req = ol_flags & TXGBE_TX_OFFLOAD_MASK; if (tx_ol_req) { - tx_offload.ptid = tx_desc_ol_flags_to_ptid(tx_ol_req, - tx_pkt->packet_type); + tx_offload.ptid = tx_desc_ol_flags_to_ptid(tx_ol_req); if (tx_offload.ptid & TXGBE_PTID_PKT_TUN) tx_offload.ptid |= txgbe_parse_tun_ptid(tx_pkt); tx_offload.l2_len = tx_pkt->l2_len; -- 2.27.0