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 5904B4569C for ; Wed, 24 Jul 2024 13:34:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 531A042D89; Wed, 24 Jul 2024 13:34:31 +0200 (CEST) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mails.dpdk.org (Postfix) with ESMTP id 64B0042D28 for ; Wed, 24 Jul 2024 13:34:30 +0200 (CEST) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-427d8f1f363so39593125e9.2 for ; Wed, 24 Jul 2024 04:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721820870; x=1722425670; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bseLQQLE3tJazOxexQetJwyZntt7rVHnMedt2Ge178A=; b=kgB0hyGB4pUzIRiQBDTUTLylzBUsM85/FZ87sKMFX7T9/xQoOop+xy1/soMZNbM1FX 5mJgRJtmstj8wrFl52j+PgZJE+7HWQy6w6QCXY1TeHgvWameN9e5RQoWdqF/chbyGIRV zxT5BW2mblpquznr57HxJz+jqJjO+id2M8JSkYlfVnZS+DV/5ZeDnGkv/FqWOYzmnxDd QIeBu+UbnzXRbUJ1pyuBUVtOK2Yf8NWWYCrrvIsBAB7IasJ1O7Glbl3/7SmNNAaoH4iJ RIiFkBLcPN82qrSGX2RBGQBYBl2TTfMuNpzaPEGkru+BzyTKAAXfxQSBtx+isXCExhkQ EtLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721820870; x=1722425670; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bseLQQLE3tJazOxexQetJwyZntt7rVHnMedt2Ge178A=; b=juu+UsYNJwweOMW94chT8b6+rIksAAWpmfYmljW5PtdR4YANX19jizaoy3KEgiO7ND zdDuhRZ/FhX7BZrr2QEv+M16hvepgMt3bvxsDJK6fz8qKaL6oOHs2l0dPI9jM613P8Ek wNWk40v8zkMpsoJTK6kLFXm33ynFKj5X7dIIY3zDkAyti7XqewE25NCKsKsvoARqmK4h wfAHk4njPhRD0NDjRQcbUKvfi7+9t2LUwZqOBb9d4dyWRqUMaIAnY2OgR3gMKHLVnSYJ YbmNj81sKxeYbcviEmOxWDBc3khY0FXCi23FJK8o7Fmgz8hUq0LrhD3x7IXSXCxUt/1N CbfQ== X-Forwarded-Encrypted: i=1; AJvYcCUyi+x7L1oiiGTX3PPFJIVbKAgZ8PW8OVCXbiXkM8kBamr1nW9FxUjFs0iG4dd3UaQIusRNHkCyDRRfetqhy/E= X-Gm-Message-State: AOJu0YyAb75xMTFbhybppJRXNc9aCS4p6CRaucChy87Ir+mOFXsWknlE wap0JW6dfXzTMEqevxjohOlZnqzUb1ySSRmJwXNkU+9U9dIOuhFBiiY3g+lo X-Google-Smtp-Source: AGHT+IHuoQSO3vWJuB9uzmerKk7gAg/IpxTx9fTIo+frnDarv49z4As2rx8JOP2+XC68WmNv3WuLSQ== X-Received: by 2002:a05:600c:4f43:b0:426:5269:1a50 with SMTP id 5b1f17b1804b1-427dc51d33emr74143725e9.11.1721820869771; Wed, 24 Jul 2024 04:34:29 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:7aef:1aaa:3dff:d546]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f938f31bsm24443455e9.26.2024.07.24.04.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 04:34:29 -0700 (PDT) From: luca.boccassi@gmail.com To: Ed Czeck Cc: Ferruh Yigit , dpdk stable Subject: patch 'net/ark: fix index arithmetic' has been queued to stable release 22.11.6 Date: Wed, 24 Jul 2024 12:32:59 +0100 Message-Id: <20240724113318.616754-21-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240724113318.616754-1-luca.boccassi@gmail.com> References: <20240715152704.2229503-86-luca.boccassi@gmail.com> <20240724113318.616754-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 22.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/26/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://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/becd25a54aa3ab2765856edd541a2ba78278ce65 Thanks. Luca Boccassi --- >From becd25a54aa3ab2765856edd541a2ba78278ce65 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 [ 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.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-07-24 12:29:22.398679084 +0100 +++ 0021-net-ark-fix-index-arithmetic.patch 2024-07-24 12:29:20.771026131 +0100 @@ -1 +1 @@ -From 73c0e26c8ed9f59f867ff251fbb2a50c8dfa06c5 Mon Sep 17 00:00:00 2001 +From becd25a54aa3ab2765856edd541a2ba78278ce65 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 73c0e26c8ed9f59f867ff251fbb2a50c8dfa06c5 ] + @@ -13 +14,0 @@ -Cc: stable@dpdk.org @@ -22 +23 @@ -index 9c89c85f50..ca6cd297a1 100644 +index 4792754f19..8f1f90b1a4 100644 @@ -25 +26 @@ -@@ -39,8 +39,8 @@ struct __rte_cache_aligned ark_tx_queue { +@@ -39,8 +39,8 @@ struct ark_tx_queue { @@ -36 +37 @@ -@@ -49,7 +49,7 @@ struct __rte_cache_aligned ark_tx_queue { +@@ -49,7 +49,7 @@ struct ark_tx_queue { @@ -39 +40 @@ - alignas(RTE_CACHE_LINE_MIN_SIZE) RTE_MARKER cacheline1; + RTE_MARKER cacheline1 __rte_cache_min_aligned; @@ -42 +43 @@ - }; + } __rte_cache_aligned;