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 54E6B45C22; Fri, 1 Nov 2024 03:50:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D5DC043283; Fri, 1 Nov 2024 03:50:02 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.57]) by mails.dpdk.org (Postfix) with ESMTP id EEBFE40265 for ; Fri, 1 Nov 2024 03:50:01 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PDfkhMXwE1Iy6nAge0lfSbCqYALb+iS2sivSjE1W+f8CVXozI0DRJJPwp8RAAzqnqKsue8OWQCEmX7SC4GPB8TrEkgSQRJjHaKEru/VyPX2ffuQvlnoQMTEboKz8rHuj8ycTEdsmqTL2lgO1gA+VUJZBLltvlx1brD8cFT3ORCeEATWH6LEz6MHgIM8VxeWREG7d0xp+bwiv/lJAVJCoRwac3YXbOj6YMHmCUGfQtL0Un9AqCtxk4JTnWFwQhrOon53vDN1s50N/TDTND+m55eXutRpY+TglITmuOZUKmWtx7esonUt+xrSVl2SIPHV/dJLIQEseFpbo1/4PB1lTOQ== 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=g2reGf5KpDQcu+fqhPvAcR41yhqwKfT0YXufvV3K0SA=; b=SKa5VlwYLK4sbIxff16yOW6ow7CexH5UWCLwHnlhtJ5pAEzLNRN7PrF5X6REG4r0BZwoKwz7sDgmI5JIZRF0kuTvDH1KoRjlj+GaPKgoStf2J8TgEAU5tRZlsd1pCKiXBMaqI5qojlRTBCbQCX3jQ7s2ycUP/89rQfkwT8Lq2GepVRbArkWY7XNS5EkWI52I2Zt18hV0Cw/b4aXpbvAHZWspyrXRqVEMVgklV/5+KrYtUFEo2czZXU5lMGUhdccIdy1bPUXi+f/5NPpfh4yF/lkSGBrQuiGbeOE8vB2GRCM8Au/a/JkQCiOu62o7gHF5zE3cM1KDE4IcCdBDjCj5vQ== 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=g2reGf5KpDQcu+fqhPvAcR41yhqwKfT0YXufvV3K0SA=; b=QQ1QAG4v/7yJdlWn7KVe5y5RnvGgonLG0/WLUOylblft32pAXPD00AsG8NJkwQXK8rMlaDyFEQM8iSz1aRijexoeLUglqFkmxvKWB58OtXAYs231RYcqSZ+VkMd8WRfuct5agCqTZoDayMBG2fTRQmcCfdSxdoEJELkSP4tLhqc= 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 SN7PR12MB6929.namprd12.prod.outlook.com (2603:10b6:806:263::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Fri, 1 Nov 2024 02:49:59 +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 02:49:59 +0000 Message-ID: <755d1711-c63d-4101-ad5b-b6fc1d5dd4a2@amd.com> Date: Fri, 1 Nov 2024 02:49:53 +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> <402cfb9a-d84a-4bb6-919d-68c7b3ccc0f3@amd.com> <03c701db2c00$b2825670$17870350$@trustnetic.com> Content-Language: en-US From: Ferruh Yigit In-Reply-To: <03c701db2c00$b2825670$17870350$@trustnetic.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO6P265CA0005.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:339::13) To SJ2PR12MB8830.namprd12.prod.outlook.com (2603:10b6:a03:4d0::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ2PR12MB8830:EE_|SN7PR12MB6929:EE_ X-MS-Office365-Filtering-Correlation-Id: e54ccaa8-fd93-4fd7-2b32-08dcfa1fe029 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?B?T1dXTDFoRE1TNWJ3bThGL3N3a0hsU0JvRUdrQkIvdUd3Vi9hZE9Nck5PMjlR?= =?utf-8?B?OHhIWmMzR2t0aExldUlCRUF4bjE1bzJ0blduUjNQd0RjbDBsSlJrUzg4b0lF?= =?utf-8?B?U3F3U1Y2ZDNVN3Nmd0d0NXpoWXpUK284ZXVaaUdCM1B0RDFLMVUzeUMxWGxo?= =?utf-8?B?Q2hUNGwxWWlSVmw3bmlZSkhhakpOMGVUMU9hRFJWelQwMUszNFcvc01WWjB2?= =?utf-8?B?ckdobW9yWDA5QzZ3aXhSRys5dCt4TlNPb054MklvaDYzTUpiV2x4bGtpeEk2?= =?utf-8?B?SG43a1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TJieHFld3NM?= =?utf-8?B?b0N5Wm1NV1EzYzdhOU9MSmszYTVlQXY2UE1jYU1WTk4vMk0ycS9YeUY1WkF5?= =?utf-8?B?RVpsaUJ5dkJ1NkljYlpDZHNkY2JXQ0VCMVUvT3pRczVwNlhudkRCNWNQWU93?= =?utf-8?B?S29HNXRCbW5WbDZzR2ZUV3BxWjRFeHl3amdrenpDZytzV3ZFdW82YkhyRDNJ?= =?utf-8?B?bjRnc0N1YS9tYnRzaHpZODI4WS94WWFKbjVPVEFidUF0b2R1WTU4T0VWd1FG?= =?utf-8?B?VXV5WmpBaTJBTnMzcmtuODZWM011TXZBZk9TaDRsQUFUZmlFQW9uR3hvRlIx?= =?utf-8?B?MkZNMC9pby9URStUMnI3Z2ZOUEFuNzRjY0xZUHJ4YWw4ZFRzeXF1eDZobHdZ?= =?utf-8?B?ckxNS3JBRDFnSjdaNUtNWGJoUitrOEVPcDFuV1ZmbjQrS1RvK1hXNzNzeTlo?= =?utf-8?B?RTZnaENra1BSUDRKcStEMktWcSsrWWozVFhaS2xXODlwMXpuNm1HSVl1Y0ZD?= =?utf-8?B?UFNnZkdtNEQyUDgzcFVhb3RvOTVINmgwWk9FMmY0VEdtMmhISHViYlRtRzJ3?= =?utf-8?Q?uI6dVuRcYE5ro//ohjN3tJpy8Afal6yMARFOrTr?= 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)(376014)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SktIUVkwTUdUQ3JNMnlZcFJDb2xvVm1uSnl3M29uMFFYOU5qTndHMjYxWkxF?= =?utf-8?B?djQ5MW1Hb0VRdCthSmhDZk1LVEVlV3dsMG1HY3dkRjQvNHZIeW54RjNiem1z?=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kVMNlQ5cGNEWVRBeEtrRGphOGl1?= =?utf-8?B?dGFTbVU1dFNpTi96c1hqNy9JN0V1QlpNNEtRRkk0Uk5US2hseDltNmxjV214?= =?utf-8?B?alJ0MVpGU1c3bWJtbm9EZ3YvVXIvNFp6VFdndXRpRS8xZ3VxSi90QUlSQS85?= =?utf-8?B?MWZnYUFLOXZLUzRSbEdnaVlOVVRWb2YrSWpkczZzMzVBYit0UmlTNDRZOTFR?= =?utf-8?Q?wlB9DzR6tqgseauwzxSXZ06s1?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e54ccaa8-fd93-4fd7-2b32-08dcfa1fe029 X-MS-Exchange-CrossTenant-AuthSource: SJ2PR12MB8830.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 02:49:59.3670 (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: d/YKb1EWFmI1Olskant4yHK5toxm5vAie5+IZCyPqDlbhzonkLLGV3CQJDZh356O X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6929 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 11/1/2024 1:52 AM, Jiawen Wu wrote: > 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? > > I had the same thought, that is why I am not suggesting to add these checks to .tx_pkt_prepare() function. But still these generic checks can go into a new static inline function for drivers to use, not for end users, and any other driver can call this function. Your two drivers already using the same function. This is not hard requirement, but if there is a common code for multiple drivers, that can go into a helper function in ethdev_driver.h