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 0C29545C22; Fri, 1 Nov 2024 02:52:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CC7B843283; Fri, 1 Nov 2024 02:52:39 +0100 (CET) Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) by mails.dpdk.org (Postfix) with ESMTP id D0F7F40265 for ; Fri, 1 Nov 2024 02:52:36 +0100 (CET) X-QQ-mid: Yeas2t1730425945t196t60051 Received: from 3DB253DBDE8942B29385B9DFB0B7E889 (jiawenwu@trustnetic.com [60.177.96.245]) X-QQ-SSF: 0000000000000000000000000000000 From: =?utf-8?b?Smlhd2VuIFd1?= X-BIZMAIL-ID: 8550227309244248367 To: "'Ferruh Yigit'" , References: <20241023064836.2017879-1-jiawenwu@trustnetic.com> <20241028023147.60157-1-jiawenwu@trustnetic.com> <20241028023147.60157-7-jiawenwu@trustnetic.com> <402cfb9a-d84a-4bb6-919d-68c7b3ccc0f3@amd.com> In-Reply-To: <402cfb9a-d84a-4bb6-919d-68c7b3ccc0f3@amd.com> Subject: RE: [PATCH v2 06/13] net/txgbe: check length of Tx packets Date: Fri, 1 Nov 2024 09:52:24 +0800 Message-ID: <03c701db2c00$b2825670$17870350$@trustnetic.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQGXIFrpZ1KNQpKKY/LzcUfCKsmTCQHAYxNLAmwQS/cCW9xWhLL1fCZg Content-Language: zh-cn X-QQ-SENDSIZE: 520 Feedback-ID: Yeas:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz8a-1 X-QQ-XMAILINFO: MWsoaJIuuiAXy2NLXLjc8TDEGC+XJqh3pfH/BeHrFtbVff26P3uNM2O6 3HOA1hjh5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PDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Fri, Nov 1, 2024 9:23 AM, Ferruh Yigit wrote: > On 10/28/2024 2:31 AM, Jiawen Wu wrote: > > Add checking of the Tx packet length to avoid TDM fatal error as far as > > possible. Set the pkt_len=1518 for invalid packet in simple Tx code path, > > and drop it directly in featured Tx code path. > > > > Signed-off-by: Jiawen Wu > > --- > > drivers/net/txgbe/txgbe_rxtx.c | 33 +++++++++++++++++++++++++ > > drivers/net/txgbe/txgbe_rxtx_vec_neon.c | 10 +++++--- > > drivers/net/txgbe/txgbe_rxtx_vec_sse.c | 11 ++++++--- > > 3 files changed, 48 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/net/txgbe/txgbe_rxtx.c b/drivers/net/txgbe/txgbe_rxtx.c > > index 2d2b437643..06acbd0881 100644 > > --- a/drivers/net/txgbe/txgbe_rxtx.c > > +++ b/drivers/net/txgbe/txgbe_rxtx.c > > @@ -160,6 +160,8 @@ tx4(volatile struct txgbe_tx_desc *txdp, struct rte_mbuf **pkts) > > for (i = 0; i < 4; ++i, ++txdp, ++pkts) { > > buf_dma_addr = rte_mbuf_data_iova(*pkts); > > pkt_len = (*pkts)->data_len; > > + if (pkt_len < RTE_ETHER_HDR_LEN) > > + pkt_len = TXGBE_FRAME_SIZE_DFT; > > > > /* write data to descriptor */ > > txdp->qw0 = rte_cpu_to_le_64(buf_dma_addr); > > @@ -180,6 +182,8 @@ tx1(volatile struct txgbe_tx_desc *txdp, struct rte_mbuf **pkts) > > > > buf_dma_addr = rte_mbuf_data_iova(*pkts); > > pkt_len = (*pkts)->data_len; > > + if (pkt_len < RTE_ETHER_HDR_LEN) > > + pkt_len = TXGBE_FRAME_SIZE_DFT; > > > > /* write data to descriptor */ > > txdp->qw0 = cpu_to_le64(buf_dma_addr); > > @@ -813,6 +817,30 @@ txgbe_parse_tun_ptid(struct rte_mbuf *tx_pkt, uint8_t tun_len) > > return ptid; > > } > > > > +static inline bool > > +txgbe_check_pkt_err(struct rte_mbuf *tx_pkt) > > +{ > > + uint32_t total_len = 0, nb_seg = 0; > > + struct rte_mbuf *mseg; > > + > > + mseg = tx_pkt; > > + do { > > + if (mseg->data_len == 0) > > + return true; > > + total_len += mseg->data_len; > > + nb_seg++; > > + mseg = mseg->next; > > + } while (mseg != NULL); > > + > > + if (tx_pkt->pkt_len != total_len || tx_pkt->pkt_len == 0) > > + return true; > > + > > + if (tx_pkt->nb_segs != nb_seg || tx_pkt->nb_segs > 64) > > + return true; > > + > > + return false; > > +} > > + > > > > Hi Jiawen, > > Above are generic checks, we may add this function to ethdev driver > header (ethdev_driver.h) so that any PMD can use it, what do you think? In fact, the limitation of tx_pkt->nb_segs is already implemented in .tx_pkt_prepare. But users developing their own apps don't necessarily call this function. So I'd like to add these in txgbe_xmit_pkts(). What are you going to do about it?