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 AE465A054A for ; Tue, 25 Oct 2022 17:09:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A9C5842C52; Tue, 25 Oct 2022 17:09:34 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 2BAEE42C3C for ; Tue, 25 Oct 2022 17:09:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666710572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WtHsKfH0OJpQmDW0iSmc+kJhAzOhg+459NnurRkXVpg=; b=Z+uB/aoUPAoCNu/o8IutAUmgHovnfuj1Eg8FPlqRUXkLCIeFepfeYkBC8Hu/r7yTSpIUzr jc68Pxsnm3IIBqqqyKh0vszHlkT/Jg7sQmLl/zxSUZl4YIdNVvAT6hR2PIoYjiqangMaq3 0khvGC47EW3a2PwiJIM9QrWSoX0u9s0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-515-LyQoSoT2PRiIl8XUh2dzkw-1; Tue, 25 Oct 2022 11:09:31 -0400 X-MC-Unique: LyQoSoT2PRiIl8XUh2dzkw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A7071185A792; Tue, 25 Oct 2022 15:09:30 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id E768D47505E; Tue, 25 Oct 2022 15:09:29 +0000 (UTC) From: Kevin Traynor To: Viacheslav Ovsiienko Cc: dpdk stable Subject: patch 'net/mlx5: fix check for orphan wait descriptor' has been queued to stable release 21.11.3 Date: Tue, 25 Oct 2022 16:07:01 +0100 Message-Id: <20221025150734.142189-66-ktraynor@redhat.com> In-Reply-To: <20221025150734.142189-1-ktraynor@redhat.com> References: <20221025150734.142189-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 21.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/01/22. 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/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/b5e5d926b224bdda168d2d9fd2d8cce0e5dbcec0 Thanks. Kevin --- >From b5e5d926b224bdda168d2d9fd2d8cce0e5dbcec0 Mon Sep 17 00:00:00 2001 From: Viacheslav Ovsiienko Date: Thu, 11 Aug 2022 08:50:58 +0300 Subject: [PATCH] net/mlx5: fix check for orphan wait descriptor [ upstream commit 37d6fc30c1ad03485ef707140b67623b95498d0d ] The mlx5 PMD supports send scheduling feature, it allows to send packets at specified moment of time, to do that PMD pushes special wait descriptor (WQE) to the hardware queue and then pushes descriptor for packet data as usual. If queue is close to be full or there is no enough elts buffers to store mbufs being sent the data descriptors might be not pushed and the orphan wait WQE (not followed by the data) might reside in queue on tx_burst routine exit. To avoid orphan wait WQEs there was the check for enough free space in the queue WQE buffer and enough amount of the free elts in queue mbuf storage. This check was incomplete and did not cover all the cases for Enhanced Multi-Packet Write descriptors. Fixes: 2f827f5ea6e1 ("net/mlx5: support scheduling on send routine template") Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_tx.h | 78 +++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/drivers/net/mlx5/mlx5_tx.h b/drivers/net/mlx5/mlx5_tx.h index 6ed00f722e..bd3a060963 100644 --- a/drivers/net/mlx5/mlx5_tx.h +++ b/drivers/net/mlx5/mlx5_tx.h @@ -1623,4 +1623,5 @@ static __rte_always_inline enum mlx5_txcmp_code mlx5_tx_schedule_send(struct mlx5_txq_data *restrict txq, struct mlx5_txq_local *restrict loc, + uint16_t elts, unsigned int olx) { @@ -1637,5 +1638,5 @@ mlx5_tx_schedule_send(struct mlx5_txq_data *restrict txq, */ if (loc->wqe_free <= MLX5_WQE_SIZE_MAX / MLX5_WQE_SIZE || - loc->elts_free < NB_SEGS(loc->mbuf)) + loc->elts_free < elts) return MLX5_TXCMP_CODE_EXIT; /* Convert the timestamp into completion to wait. */ @@ -1667,4 +1668,7 @@ mlx5_tx_schedule_send(struct mlx5_txq_data *restrict txq, * @param loc * Pointer to burst routine local context. + * @param elts + * Number of free elements in elts buffer to be checked, for zero + * value the check is optimized out by compiler. * @param olx * Configured Tx offloads mask. It is fully defined at @@ -1684,9 +1688,10 @@ mlx5_tx_packet_multi_tso(struct mlx5_txq_data *__rte_restrict txq, unsigned int ds, dlen, inlen, ntcp, vlan = 0; + MLX5_ASSERT(loc->elts_free >= NB_SEGS(loc->mbuf)); if (MLX5_TXOFF_CONFIG(TXPP)) { enum mlx5_txcmp_code wret; /* Generate WAIT for scheduling if requested. */ - wret = mlx5_tx_schedule_send(txq, loc, olx); + wret = mlx5_tx_schedule_send(txq, loc, 0, olx); if (wret == MLX5_TXCMP_CODE_EXIT) return MLX5_TXCMP_CODE_EXIT; @@ -1782,9 +1787,10 @@ mlx5_tx_packet_multi_send(struct mlx5_txq_data *__rte_restrict txq, MLX5_ASSERT(NB_SEGS(loc->mbuf) > 1); + MLX5_ASSERT(loc->elts_free >= NB_SEGS(loc->mbuf)); if (MLX5_TXOFF_CONFIG(TXPP)) { enum mlx5_txcmp_code wret; /* Generate WAIT for scheduling if requested. */ - wret = mlx5_tx_schedule_send(txq, loc, olx); + wret = mlx5_tx_schedule_send(txq, loc, 0, olx); if (wret == MLX5_TXCMP_CODE_EXIT) return MLX5_TXCMP_CODE_EXIT; @@ -1897,14 +1903,5 @@ mlx5_tx_packet_multi_inline(struct mlx5_txq_data *__rte_restrict txq, MLX5_ASSERT(MLX5_TXOFF_CONFIG(INLINE)); MLX5_ASSERT(NB_SEGS(loc->mbuf) > 1); - if (MLX5_TXOFF_CONFIG(TXPP)) { - enum mlx5_txcmp_code wret; - - /* Generate WAIT for scheduling if requested. */ - wret = mlx5_tx_schedule_send(txq, loc, olx); - if (wret == MLX5_TXCMP_CODE_EXIT) - return MLX5_TXCMP_CODE_EXIT; - if (wret == MLX5_TXCMP_CODE_ERROR) - return MLX5_TXCMP_CODE_ERROR; - } + MLX5_ASSERT(loc->elts_free >= NB_SEGS(loc->mbuf)); /* * First calculate data length to be inlined @@ -2012,4 +2009,14 @@ do_align: */ do_build: + if (MLX5_TXOFF_CONFIG(TXPP)) { + enum mlx5_txcmp_code wret; + + /* Generate WAIT for scheduling if requested. */ + wret = mlx5_tx_schedule_send(txq, loc, 0, olx); + if (wret == MLX5_TXCMP_CODE_EXIT) + return MLX5_TXCMP_CODE_EXIT; + if (wret == MLX5_TXCMP_CODE_ERROR) + return MLX5_TXCMP_CODE_ERROR; + } MLX5_ASSERT(inlen <= txq->inlen_send); ds = NB_SEGS(loc->mbuf) + 2 + (inlen - @@ -2172,5 +2179,5 @@ mlx5_tx_burst_tso(struct mlx5_txq_data *__rte_restrict txq, /* Generate WAIT for scheduling if requested. */ - wret = mlx5_tx_schedule_send(txq, loc, olx); + wret = mlx5_tx_schedule_send(txq, loc, 1, olx); if (wret == MLX5_TXCMP_CODE_EXIT) return MLX5_TXCMP_CODE_EXIT; @@ -2550,14 +2557,4 @@ mlx5_tx_burst_empw_simple(struct mlx5_txq_data *__rte_restrict txq, next_empw: MLX5_ASSERT(NB_SEGS(loc->mbuf) == 1); - if (MLX5_TXOFF_CONFIG(TXPP)) { - enum mlx5_txcmp_code wret; - - /* Generate WAIT for scheduling if requested. */ - wret = mlx5_tx_schedule_send(txq, loc, olx); - if (wret == MLX5_TXCMP_CODE_EXIT) - return MLX5_TXCMP_CODE_EXIT; - if (wret == MLX5_TXCMP_CODE_ERROR) - return MLX5_TXCMP_CODE_ERROR; - } part = RTE_MIN(pkts_n, MLX5_TXOFF_CONFIG(MPW) ? MLX5_MPW_MAX_PACKETS : @@ -2570,4 +2567,14 @@ next_empw: part = loc->elts_free; } + if (MLX5_TXOFF_CONFIG(TXPP)) { + enum mlx5_txcmp_code wret; + + /* Generate WAIT for scheduling if requested. */ + wret = mlx5_tx_schedule_send(txq, loc, 0, olx); + if (wret == MLX5_TXCMP_CODE_EXIT) + return MLX5_TXCMP_CODE_EXIT; + if (wret == MLX5_TXCMP_CODE_ERROR) + return MLX5_TXCMP_CODE_ERROR; + } /* Check whether we have enough WQEs */ if (unlikely(loc->wqe_free < ((2 + part + 3) / 4))) { @@ -2724,14 +2731,4 @@ mlx5_tx_burst_empw_inline(struct mlx5_txq_data *__rte_restrict txq, MLX5_ASSERT(NB_SEGS(loc->mbuf) == 1); - if (MLX5_TXOFF_CONFIG(TXPP)) { - enum mlx5_txcmp_code wret; - - /* Generate WAIT for scheduling if requested. */ - wret = mlx5_tx_schedule_send(txq, loc, olx); - if (wret == MLX5_TXCMP_CODE_EXIT) - return MLX5_TXCMP_CODE_EXIT; - if (wret == MLX5_TXCMP_CODE_ERROR) - return MLX5_TXCMP_CODE_ERROR; - } /* * Limits the amount of packets in one WQE @@ -2741,4 +2738,14 @@ mlx5_tx_burst_empw_inline(struct mlx5_txq_data *__rte_restrict txq, MLX5_MPW_INLINE_MAX_PACKETS : MLX5_EMPW_MAX_PACKETS); + if (MLX5_TXOFF_CONFIG(TXPP)) { + enum mlx5_txcmp_code wret; + + /* Generate WAIT for scheduling if requested. */ + wret = mlx5_tx_schedule_send(txq, loc, nlim, olx); + if (wret == MLX5_TXCMP_CODE_EXIT) + return MLX5_TXCMP_CODE_EXIT; + if (wret == MLX5_TXCMP_CODE_ERROR) + return MLX5_TXCMP_CODE_ERROR; + } /* Check whether we have minimal amount WQEs */ if (unlikely(loc->wqe_free < @@ -3023,9 +3030,10 @@ mlx5_tx_burst_single_send(struct mlx5_txq_data *__rte_restrict txq, MLX5_ASSERT(NB_SEGS(loc->mbuf) == 1); + MLX5_ASSERT(loc->elts_free); if (MLX5_TXOFF_CONFIG(TXPP)) { enum mlx5_txcmp_code wret; /* Generate WAIT for scheduling if requested. */ - wret = mlx5_tx_schedule_send(txq, loc, olx); + wret = mlx5_tx_schedule_send(txq, loc, 0, olx); if (wret == MLX5_TXCMP_CODE_EXIT) return MLX5_TXCMP_CODE_EXIT; -- 2.37.3 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-10-25 14:19:00.039429874 +0100 +++ 0066-net-mlx5-fix-check-for-orphan-wait-descriptor.patch 2022-10-25 14:18:58.473798313 +0100 @@ -1 +1 @@ -From 37d6fc30c1ad03485ef707140b67623b95498d0d Mon Sep 17 00:00:00 2001 +From b5e5d926b224bdda168d2d9fd2d8cce0e5dbcec0 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 37d6fc30c1ad03485ef707140b67623b95498d0d ] + @@ -22 +23,0 @@ -Cc: stable@dpdk.org @@ -30 +31 @@ -index 20776919c2..f081921ffc 100644 +index 6ed00f722e..bd3a060963 100644 @@ -33,9 +34 @@ -@@ -1643,4 +1643,7 @@ dseg_done: - * @param loc - * Pointer to burst routine local context. -+ * @param elts -+ * Number of free elements in elts buffer to be checked, for zero -+ * value the check is optimized out by compiler. - * @param olx - * Configured Tx offloads mask. It is fully defined at -@@ -1656,4 +1659,5 @@ static __rte_always_inline enum mlx5_txcmp_code +@@ -1623,4 +1623,5 @@ static __rte_always_inline enum mlx5_txcmp_code @@ -47 +40 @@ -@@ -1670,5 +1674,5 @@ mlx5_tx_schedule_send(struct mlx5_txq_data *restrict txq, +@@ -1637,5 +1638,5 @@ mlx5_tx_schedule_send(struct mlx5_txq_data *restrict txq, @@ -54 +47,9 @@ -@@ -1736,9 +1740,10 @@ mlx5_tx_packet_multi_tso(struct mlx5_txq_data *__rte_restrict txq, +@@ -1667,4 +1668,7 @@ mlx5_tx_schedule_send(struct mlx5_txq_data *restrict txq, + * @param loc + * Pointer to burst routine local context. ++ * @param elts ++ * Number of free elements in elts buffer to be checked, for zero ++ * value the check is optimized out by compiler. + * @param olx + * Configured Tx offloads mask. It is fully defined at +@@ -1684,9 +1688,10 @@ mlx5_tx_packet_multi_tso(struct mlx5_txq_data *__rte_restrict txq, @@ -66 +67 @@ -@@ -1834,9 +1839,10 @@ mlx5_tx_packet_multi_send(struct mlx5_txq_data *__rte_restrict txq, +@@ -1782,9 +1787,10 @@ mlx5_tx_packet_multi_send(struct mlx5_txq_data *__rte_restrict txq, @@ -78 +79 @@ -@@ -1949,14 +1955,5 @@ mlx5_tx_packet_multi_inline(struct mlx5_txq_data *__rte_restrict txq, +@@ -1897,14 +1903,5 @@ mlx5_tx_packet_multi_inline(struct mlx5_txq_data *__rte_restrict txq, @@ -94 +95 @@ -@@ -2064,4 +2061,14 @@ do_align: +@@ -2012,4 +2009,14 @@ do_align: @@ -109 +110 @@ -@@ -2224,5 +2231,5 @@ mlx5_tx_burst_tso(struct mlx5_txq_data *__rte_restrict txq, +@@ -2172,5 +2179,5 @@ mlx5_tx_burst_tso(struct mlx5_txq_data *__rte_restrict txq, @@ -116 +117 @@ -@@ -2602,14 +2609,4 @@ mlx5_tx_burst_empw_simple(struct mlx5_txq_data *__rte_restrict txq, +@@ -2550,14 +2557,4 @@ mlx5_tx_burst_empw_simple(struct mlx5_txq_data *__rte_restrict txq, @@ -131 +132 @@ -@@ -2622,4 +2619,14 @@ next_empw: +@@ -2570,4 +2567,14 @@ next_empw: @@ -146 +147 @@ -@@ -2776,14 +2783,4 @@ mlx5_tx_burst_empw_inline(struct mlx5_txq_data *__rte_restrict txq, +@@ -2724,14 +2731,4 @@ mlx5_tx_burst_empw_inline(struct mlx5_txq_data *__rte_restrict txq, @@ -161 +162 @@ -@@ -2793,4 +2790,14 @@ mlx5_tx_burst_empw_inline(struct mlx5_txq_data *__rte_restrict txq, +@@ -2741,4 +2738,14 @@ mlx5_tx_burst_empw_inline(struct mlx5_txq_data *__rte_restrict txq, @@ -176 +177 @@ -@@ -3075,9 +3082,10 @@ mlx5_tx_burst_single_send(struct mlx5_txq_data *__rte_restrict txq, +@@ -3023,9 +3030,10 @@ mlx5_tx_burst_single_send(struct mlx5_txq_data *__rte_restrict txq,