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 EB6AD45C22; Fri, 1 Nov 2024 02:22:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BB0A443283; Fri, 1 Nov 2024 02:22:57 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2089.outbound.protection.outlook.com [40.107.236.89]) by mails.dpdk.org (Postfix) with ESMTP id 5E60040265 for ; Fri, 1 Nov 2024 02:22:56 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bc5mPi3DNzFMuG0AxBGUyXGDyOka26mVfc7dcVALN2N3yHt2n/rI1ku6GvqfP6fkyQjQe/MKYgrSAM/l/yg2L8F3H9wYdtyKOXtim5a1mTA6Th6D/+oxa5y/xj6s/jgdPmTTSpZ6ip8+pN3GZcBKTFAx16f6ZglMG71tY16kI6xmtM3L6Cbr6R92IzxjoPnZHzn74kpxl6ifVO+1J9gVuyjwPHbEWV3ZKEYvoWibIZEUEQ+M67TP84sl4GXxBaUiaS3irf1zhtQu8cYOsF4nMcz0wO0PE022a8nNnT1omD/sd/e2iwBNs64lNzV4wT4T4WdkHcZflNEwzpeb3M+LIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NpII5F7ADSeVE7rcqIvFu5G32bKWZG36Mp5gx4txYdk=; b=UCY/wAKyW/6eAzU4si7HdbwRS7e5ufSZn7brWyI9ZRhka0X3Bjf592hFst5YnWTSp/QL8bbaIWHJINIVMrUJ+H0enPtRc4NhIq1S5qta/v/pwAswrUmhD0UrdU7qQTxGF54ZNOcXggHUqo9+6VEZOgyDhrU+uUDdmkMm6FPAoDblh9nmPqM6i8OqPlQw9RtXtVRD7LD63e6foNYuDfSXo+GcSSQ++OdP1OdITsgtEZx5ORHNhwhiRuoNy0a3mGbYvJAeQv9Q9E86/2LKAv0CyGAZComMsxSX+e45b7WKE2JA4I3zLRrFYlqawY/OnuMOL6GmTeZ+bNUm/YjFDE+bHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NpII5F7ADSeVE7rcqIvFu5G32bKWZG36Mp5gx4txYdk=; b=nYnOR+sHN8QC1daV8u9aKkqVHhGISWXl4FpRr3zTER75+IsbBSlSgY36FZAMNz0JpxZ1hDTu4fT5Cx4hJuzpZ6lgvwQ0iVMtOOfJaBaRHdycjUrp8wJHwUPPOjsny2xnsKw4+f3TdgErdRDqbg7zJd7p0DODTeLyIC07CY75Ekk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from SJ2PR12MB8830.namprd12.prod.outlook.com (2603:10b6:a03:4d0::9) by CY8PR12MB7266.namprd12.prod.outlook.com (2603:10b6:930:56::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Fri, 1 Nov 2024 01:22:54 +0000 Received: from SJ2PR12MB8830.namprd12.prod.outlook.com ([fe80::c3eb:df02:eaa9:2055]) by SJ2PR12MB8830.namprd12.prod.outlook.com ([fe80::c3eb:df02:eaa9:2055%4]) with mapi id 15.20.8093.024; Fri, 1 Nov 2024 01:22:54 +0000 Message-ID: <402cfb9a-d84a-4bb6-919d-68c7b3ccc0f3@amd.com> Date: Fri, 1 Nov 2024 01:22:47 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 06/13] net/txgbe: check length of Tx packets To: Jiawen Wu , dev@dpdk.org References: <20241023064836.2017879-1-jiawenwu@trustnetic.com> <20241028023147.60157-1-jiawenwu@trustnetic.com> <20241028023147.60157-7-jiawenwu@trustnetic.com> Content-Language: en-US From: Ferruh Yigit In-Reply-To: <20241028023147.60157-7-jiawenwu@trustnetic.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0233.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:315::19) To SJ2PR12MB8830.namprd12.prod.outlook.com (2603:10b6:a03:4d0::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ2PR12MB8830:EE_|CY8PR12MB7266:EE_ X-MS-Office365-Filtering-Correlation-Id: ed0fdc37-e9a9-4133-9a9f-08dcfa13b598 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?bmN2Q2U3WWZnVklzcGpaQmpxNHNkd3NNOEdTcXJxUVZTMmpzeUdvSzVpTXdR?= =?utf-8?B?VnBlYWlvdVpvNk9mM2JLajMraTc3OU5lZ3E0ZGYySzhiS0MyK0hCR1ZHVWdp?= =?utf-8?B?azJRMTEwRjZTWXRhUEtRTmpxRXprcGtndXBYcXBKZXBhSXhxVjRtaXNaMDRB?= =?utf-8?B?S3M2UGJkY1lTQWU2RVlBNTNBTGVIeERBUzhnT3FyVlNOY1gxbTQzTGVsZVJT?= =?utf-8?B?YVh3d2VTWlNUa1Q3Q1NLbzVmb0pnMllnY09xVXVpQy9sdytMQUNkSFZIczll?= =?utf-8?B?ZjlLb05rNDdHbk5GaksyMW01SmpkWkdEaG94RGNIMUhibDlhckFUTm0rTmhv?= =?ut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4aTZVVmpKaGNZM21uMGZFRjR1?= =?utf-8?B?Q0tRNUcyalE1ZE5DbzJrM0xvWW1xTERaQXBSUXZGeHM0S3VZOThlZldkRW9M?= =?utf-8?B?VkVtZFgyb1dJSTlzNFVnOEt3c0pxTVlGMWhSckU3VlpXV2JqRDcrVkUvUllq?= =?utf-8?B?NStaSUJxcnJyTGFLY25tWDl0SWpoOW5NSTRnUWF0WE9QckF0NzU5SW9XVFNo?= =?utf-8?B?N3YyUEJSY0JJM1ppVytzYUljTUVFekt0YURwNC8waGp6bkcrUmlON284enAw?= =?utf-8?B?Zm5zbUFlL0VVYWxVSjR4U1dQeWRBcjRxNWlkR0JldFdkaWgzeFRTM0VaZ2pX?= =?utf-8?B?clF5Rk5QNHdSNU1TMFhkK1NjcHVrc3h4VFZ1aW0yQ2JSejY3N05KMUNwbXJz?= =?utf-8?B?Yy9WV3MvWEYzQ0NkbkdvZHhsZlQvZG9MV05FWXJpOUZINitQU003S05BdExi?= =?utf-8?B?UERpRnppRTYrNGF1djNsQ1JtV3hxMWhCSWk2UUQ2dk5JWUpFMHBNaDBCdFpI?= =?utf-8?Q?xvFVNSQ8zmiMWYdVAZ+5KL5Q5S7mFHWvvsdJRHg?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ2PR12MB8830.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VkFMc0YxbC93cjdZY2xTbXBjVjE2Rml5U2VTWUg0dXQ4QUk0UHI3cWZjRjlk?= =?utf-8?B?Ny8wcWtSay9qZjUxbVpYbldIa1hMUWtXUGVVNG1Mc2xRYkpRRTZ2TGs0TkYy?= =?utf-8?B?NWVZS0RuR2FHTHdtSDA4QW9FK1ZDcEo5VzlNbUltWl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?= =?utf-8?B?VmlvWHJWdG43bWlSd01qYUNOQ3hLMGJTYVJNbUowdWtuOGNibW9DNStTdmpk?= =?utf-8?B?SjhweVg0cEhvOG5CR3c0RWY5R2o4dHdOdi9YNURBVHhzYldvUU52bVdOcjky?= =?utf-8?B?TXc2RHlEZFBodmR6aGJMck44Zk9idDNXcjB2TnhRMkNFS3lvdXBwcmpuTml4?= =?utf-8?Q?Q2xmmdbi1PN54vC3aRMi71Zn/?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed0fdc37-e9a9-4133-9a9f-08dcfa13b598 X-MS-Exchange-CrossTenant-AuthSource: SJ2PR12MB8830.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 01:22:54.0550 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DCF4acVOelD0QU0A6rskJti/vMNgmndlzr9IIzA8N+bSRTgJ2UZU7IRtrl74OZXp X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7266 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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?