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 98CB2457A1 for ; Mon, 12 Aug 2024 15:03:25 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8E8594065A; Mon, 12 Aug 2024 15:03:25 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2079.outbound.protection.outlook.com [40.107.100.79]) by mails.dpdk.org (Postfix) with ESMTP id BF9D9402C3 for ; Mon, 12 Aug 2024 15:03:24 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=maD2sNr5ri3ELtoQJnHQNKRBG8wuaFrkeW/IDuwMHgLHvBIBHMbjdN9Sfv1GnA4TVN49vkPpu2ySYNK24dG9iac7qrSt1V6h0BMhL7iu4CyOR7+GiyiY3yRNVm1Iu5xWtftVdiySiKZ4gQ/VwyNm9hg3D57b9R1qEulI162PpfpVoaS6wvYHgzkVe2DwU/3ihDqyWFn/r/pRLv6Lp5UGBc9eo2gLLnq4fQM8KhkVWuAiKjjh8zWj88eK6pZWKo+wCABFpHIZEkhj3+LTWKXDSKaDlTOXh88uvKUGhQ/rXuAGEzm1jlPEu2IK90w9i0NuWnYwiau7axo6xC+I7HKwgw== 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=fiDnqNksrSBel0DHkFfZpd2zVRQi5YDYPxrQQ/9sSGQ=; b=GNWgWmeQ76mTNhFpH7wu2n1D5r4fv0IvjLBVSzNDklp8EFlALp2Z+OoyomhwyeypnVcaArav3My4sZMBpbxqyZleixIHSkXGNwVoZygGkvmWNQeJmFy3/tlCpuNWkCeT5rK3Fqa5M2R5Va2BRVShURaU1JJyAPsMsCX3ei+pHkpWjUFRHjrHlT4wTWqzZC15VGPhOMkjMWWVITwtA2xSUN+TYunv7VX9re8JnWbPjvMRmQGm0g80FRkVDVy3ydEve6YjsehoqreP53nsJnJnZ8GfhbDTGBKpcgx3qRDInl8fZgQNl5bo0RD5KfGi2Vn8ucnJfufVHI4sYkOoNjx3CA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=atomicrules.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fiDnqNksrSBel0DHkFfZpd2zVRQi5YDYPxrQQ/9sSGQ=; b=tflU0WUc/V/CWx/+S+YsnlhAqs1R+6B0gqaYyLNiD5QFQfzmLm6ZrLHaFT0QhJN6W1WYtriAb3QBOXCFFZCVbVNYUNdyu7nDzJOKw+bcol9OasjER+Rtd02RziEa44nOR0ci5UKNcR1K8W9mZ18DdWdiy918rfrbFbhP/KhVUjpGZAJA4ajk0H0jZNdGL/oSpiAWEtNl9rsDEVaf62sXDnJJO/guAY9ZsrXrh7vXuWzK7pu5pfCfWJ6z6gX0zsr6PU50TgQIx4V0X2TPDg1//OfCom9NRaokEHriRga9f97KMk143toZNVh4FtztiXYgBcPkWsJM1wUeIhQNzsAIPQ== Received: from SA0PR11CA0016.namprd11.prod.outlook.com (2603:10b6:806:d3::21) by DS0PR12MB8293.namprd12.prod.outlook.com (2603:10b6:8:f3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.22; Mon, 12 Aug 2024 13:03:20 +0000 Received: from SN1PEPF00026367.namprd02.prod.outlook.com (2603:10b6:806:d3:cafe::70) by SA0PR11CA0016.outlook.office365.com (2603:10b6:806:d3::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.33 via Frontend Transport; Mon, 12 Aug 2024 13:03:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SN1PEPF00026367.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Mon, 12 Aug 2024 13:03:20 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 12 Aug 2024 06:03:05 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 12 Aug 2024 06:03:03 -0700 From: Xueming Li To: Ed Czeck CC: , Ferruh Yigit , dpdk stable Subject: patch 'net/ark: fix index arithmetic' has been queued to stable release 23.11.2 Date: Mon, 12 Aug 2024 20:50:07 +0800 Message-ID: <20240812125035.389667-131-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240812125035.389667-1-xuemingl@nvidia.com> References: <20240712110153.309690-23-xuemingl@nvidia.com> <20240812125035.389667-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026367:EE_|DS0PR12MB8293:EE_ X-MS-Office365-Filtering-Correlation-Id: ed03f431-29e6-4ab8-612d-08dcbacf2426 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?s2thi4Fzgm3qWve/ozebV/HPBdnDUh1Ptjw9dd7OxhBABZhZ8rTHWlJSDYmE?= =?us-ascii?Q?wRTLl9a8ZsBm3qyA9BWGJOCsfWSkfNy38h/3YTAQw6UAhj2dspz1MQ/qbOLb?= =?us-ascii?Q?9uqtcOSWeoWlt3FMnyNTdyaqlDzBFmSNxO04Tcy8qYTRzZKd9TTVcP3cVExm?= =?us-ascii?Q?uRL4JvXvKgymZt54qChM64ZOZP7A6cP6MHFatcTYWeQP0z743MQpQcHeHw/J?= =?us-ascii?Q?1BH9Fb8Urg84z8Baq2X64o1SZo6zPpc1gl7lw3qFH/GUuN58omHgpQSyb2hp?= =?us-ascii?Q?iM/s4kDwbAzbweLezNMsL1iVLS6ReGtwigfXlFdXhF+ZX4RGbmKFWPHOqGvH?= =?us-ascii?Q?3ouKHs2buSXUq4v9fBVy/msayD+vxgR4jH7P1vz0LxB06JgM+qBl+v9l/ay3?= =?us-ascii?Q?gJtNAcPccHMv499X/ywY9z+QzbvKXj4qa4JhlNd73E7/uWVkaHx3UuMfY7By?= =?us-ascii?Q?PDslmLk2Sr0yWWytNovTuocKhkFLObLs4YT2xuti0BuZgKt8Vgr60VnhL0aq?= =?us-ascii?Q?REXJ6Z3n7T16RCYwb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efront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2024 13:03:20.6009 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed03f431-29e6-4ab8-612d-08dcbacf2426 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00026367.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8293 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 Hi, FYI, your patch has been queued to stable release 23.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/14/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://git.dpdk.org/dpdk-stable/log/?h=23.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=e2b3b0a5d4cee408f6d1638010669df467e7398b Thanks. Xueming Li --- >From e2b3b0a5d4cee408f6d1638010669df467e7398b Mon Sep 17 00:00:00 2001 From: Ed Czeck Date: Wed, 17 Jul 2024 16:38:30 -0400 Subject: [PATCH] net/ark: fix index arithmetic Cc: Xueming Li [ upstream commit 73c0e26c8ed9f59f867ff251fbb2a50c8dfa06c5 ] Behavior for signed integer overflow is not defined which can causes undesired behavior at values near max and min bounds. The used of unsigned is defined as to use modulo arithmetic which is the desired behavior. This patch replaces int32_t with uint32_t except for necessary casts. Fixes: 9ee9e0d3b85e ("net/ark: update to reflect FPGA updates") Signed-off-by: Ed Czeck Acked-by: Ferruh Yigit --- drivers/net/ark/ark_ethdev_tx.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/net/ark/ark_ethdev_tx.c b/drivers/net/ark/ark_ethdev_tx.c index 4792754f19..8f1f90b1a4 100644 --- a/drivers/net/ark/ark_ethdev_tx.c +++ b/drivers/net/ark/ark_ethdev_tx.c @@ -39,8 +39,8 @@ struct ark_tx_queue { uint32_t queue_mask; /* 3 indexes to the paired data rings. */ - int32_t prod_index; /* where to put the next one */ - int32_t free_index; /* mbuf has been freed */ + uint32_t prod_index; /* where to put the next one */ + uint32_t free_index; /* mbuf has been freed */ /* The queue Id is used to identify the HW Q */ uint16_t phys_qid; @@ -49,7 +49,7 @@ struct ark_tx_queue { /* next cache line - fields written by device */ RTE_MARKER cacheline1 __rte_cache_min_aligned; - volatile int32_t cons_index; /* hw is done, can be freed */ + volatile uint32_t cons_index; /* hw is done, can be freed */ } __rte_cache_aligned; /* Forward declarations */ @@ -108,7 +108,7 @@ eth_ark_xmit_pkts(void *vtxq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) uint32_t user_meta[5]; int stat; - int32_t prod_index_limit; + uint32_t prod_index_limit; uint16_t nb; uint8_t user_len = 0; const uint32_t min_pkt_len = ARK_MIN_TX_PKTLEN; @@ -123,8 +123,13 @@ eth_ark_xmit_pkts(void *vtxq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) /* leave 4 elements mpu data */ prod_index_limit = queue->queue_size + queue->free_index - 4; + /* Populate the buffer bringing prod_index up to or slightly beyond + * prod_index_limit. Prod_index will increment by 2 or more each + * iteration. Note: indexes are uint32_t, cast to (signed) int32_t + * to catch the slight overage case; e.g. (200 - 201) + */ for (nb = 0; - (nb < nb_pkts) && (prod_index_limit - queue->prod_index) > 0; + (nb < nb_pkts) && (int32_t)(prod_index_limit - queue->prod_index) > 0; ++nb) { mbuf = tx_pkts[nb]; @@ -194,13 +199,13 @@ eth_ark_tx_jumbo(struct ark_tx_queue *queue, struct rte_mbuf *mbuf, uint32_t *user_meta, uint8_t meta_cnt) { struct rte_mbuf *next; - int32_t free_queue_space; + uint32_t free_queue_space; uint8_t flags = ARK_DDM_SOP; free_queue_space = queue->queue_mask - (queue->prod_index - queue->free_index); /* We need up to 4 mbufs for first header and 2 for subsequent ones */ - if (unlikely(free_queue_space < (2 + (2 * mbuf->nb_segs)))) + if (unlikely(free_queue_space < (2U + (2U * mbuf->nb_segs)))) return -1; while (mbuf != NULL) { @@ -392,10 +397,11 @@ free_completed_tx(struct ark_tx_queue *queue) { struct rte_mbuf *mbuf; union ark_tx_meta *meta; - int32_t top_index; + uint32_t top_index; top_index = queue->cons_index; /* read once */ - while ((top_index - queue->free_index) > 0) { + + while ((int32_t)(top_index - queue->free_index) > 0) { meta = &queue->meta_q[queue->free_index & queue->queue_mask]; if (likely((meta->flags & ARK_DDM_SOP) != 0)) { mbuf = queue->bufs[queue->free_index & -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-08-12 20:44:06.642847471 +0800 +++ 0130-net-ark-fix-index-arithmetic.patch 2024-08-12 20:44:02.525069379 +0800 @@ -1 +1 @@ -From 73c0e26c8ed9f59f867ff251fbb2a50c8dfa06c5 Mon Sep 17 00:00:00 2001 +From e2b3b0a5d4cee408f6d1638010669df467e7398b Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 73c0e26c8ed9f59f867ff251fbb2a50c8dfa06c5 ] @@ -13 +15,0 @@ -Cc: stable@dpdk.org @@ -22 +24 @@ -index 9c89c85f50..ca6cd297a1 100644 +index 4792754f19..8f1f90b1a4 100644 @@ -25 +27 @@ -@@ -39,8 +39,8 @@ struct __rte_cache_aligned ark_tx_queue { +@@ -39,8 +39,8 @@ struct ark_tx_queue { @@ -36 +38 @@ -@@ -49,7 +49,7 @@ struct __rte_cache_aligned ark_tx_queue { +@@ -49,7 +49,7 @@ struct ark_tx_queue { @@ -39 +41 @@ - alignas(RTE_CACHE_LINE_MIN_SIZE) RTE_MARKER cacheline1; + RTE_MARKER cacheline1 __rte_cache_min_aligned; @@ -42 +44 @@ - }; + } __rte_cache_aligned;