From patchwork Tue Nov 17 11:26:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Leroy X-Patchwork-Id: 84268 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 60801A04DB; Tue, 17 Nov 2020 12:27:16 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E5A145928; Tue, 17 Nov 2020 12:27:08 +0100 (CET) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id 37FD35928 for ; Tue, 17 Nov 2020 12:27:07 +0100 (CET) Received: by mail-wr1-f68.google.com with SMTP id m6so5618701wrg.7 for ; Tue, 17 Nov 2020 03:27:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a5DPaEVfhghLzmgDlc0wCxFfdnGmdTpJeXFqzldBI2A=; b=agqgg/BaX0AUVbb1SYWi3wbGNJxRZ7K04WwRxYceISHjL5H1gdB5Nq698hGG1qpzKQ nx8Drl5gStG1FHb2Y4Y+10R1OBcAxf7VX13pytdYYu6aaCRKbS37BOiNoRvQbVp/TQoz D3eaz98EofqWbVyBX4j7dnibNz3sS6+a1l98TMV1pMZNt1y5FOxbqcaT1NoKc+UJdBQB PclROuY7iiJRlLM6Z+oPQgHqwopQB3sLozs5r/FAr+luLQws5OwOBIbwVtX2KQGqQ1Bi HvanFO2X5v8E+BCrQ/+VWU2akSFJQMnsXBYXjGb0Ltvi6dZhhF8zzCRq5Wpprmb+5EIh wwSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a5DPaEVfhghLzmgDlc0wCxFfdnGmdTpJeXFqzldBI2A=; b=L1Q11hPgph9eneedzxhTG1lK4dMEw+JqebPLgcmJacdWsxBIxN1B3NaDF4m6KnzmAS AYwtcl8zLypD181vHkmdFX5fetd467gc6/W0mAYFMCIPkytgzjvOgesImFwQKI/rE2X8 SFXUpqKfWp+/E2PeePtyfMEpW8HZOetUGR/0QCq6GMfafudiA30pcSzMiCp4d1Zk/xRD OmMF454ykMdE3ldJIxyIoCDw5SCKXOyO4BUqSdh7uz/71UWBUeB1rchkPPurmQjNEdFM dtS0riu5QI1RKMZRWHwbVdr4+jKvuoWpkpjgyEVjl7OIks+gCmA9O39RlkaxTPhpGqIc kosw== X-Gm-Message-State: AOAM531KGZ4a86cZ09R4l2rVwDGNT5M9ft57eopA61z4lEvj2ZxXV6C4 IFo/8eCvHGW/PCad1gtrJI5iKA== X-Google-Smtp-Source: ABdhPJy7w1vlFHJ9cJnOCK1aI7BKhm+DJXXU8tUVQEjgEkrIRKTEUxx9g1kkccDePM4S1kfxbVuo2g== X-Received: by 2002:a5d:4e4c:: with SMTP id r12mr24563615wrt.348.1605612425982; Tue, 17 Nov 2020 03:27:05 -0800 (PST) Received: from bolet.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id o17sm3136265wmd.34.2020.11.17.03.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2020 03:27:05 -0800 (PST) From: Maxime Leroy To: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko , Alexander Kozyrev Cc: dev@dpdk.org, Nelio Laranjeiro Date: Tue, 17 Nov 2020 12:26:46 +0100 Message-Id: <20201117112648.29725-2-maxime.leroy@6wind.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201117112648.29725-1-maxime.leroy@6wind.com> References: <20201117112648.29725-1-maxime.leroy@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4 1/2] net/mlx5: fix Rx queue count calculation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The commit d2d57605522d ("net/mlx5: fix Rx queue count calculation") is incorrect because the count calculation is wrong for the next cqe: Example: Compressed Set of packets 1 | Compressed Set of packets 2 C | a | e0 | e1 | e2 | e3 | e4 | e5 | C | a | e0 There are 2 compressed set of packets in the first queue. For the first set, n is computed correctly. But for the second, n is not computed properly. Because the zip context is for the first set. The second set is not yet decompressed, so there are no context. To fix the issue, we should only use the zip context for the first CQEs series. Fixes: d2d57605522d ("net/mlx5: fix Rx queue count calculation") Signed-off-by: Maxime Leroy Signed-off-by: Nelio Laranjeiro Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_rxtx.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 844a1c63..2733dcd3 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -462,11 +462,18 @@ rx_queue_count(struct mlx5_rxq_data *rxq) { struct rxq_zip *zip = &rxq->zip; volatile struct mlx5_cqe *cqe; - unsigned int cq_ci = rxq->cq_ci; const unsigned int cqe_n = (1 << rxq->cqe_n); const unsigned int cqe_cnt = cqe_n - 1; - unsigned int used = 0; + unsigned int cq_ci, used; + /* if we are processing a compressed cqe */ + if (zip->ai) { + used = zip->cqe_cnt - zip->ai; + cq_ci = zip->cq_ci; + } else { + used = 0; + cq_ci = rxq->cq_ci; + } cqe = &(*rxq->cqes)[cq_ci & cqe_cnt]; while (check_cqe(cqe, cqe_n, cq_ci) != MLX5_CQE_STATUS_HW_OWN) { int8_t op_own; @@ -474,10 +481,7 @@ rx_queue_count(struct mlx5_rxq_data *rxq) op_own = cqe->op_own; if (MLX5_CQE_FORMAT(op_own) == MLX5_COMPRESSED) - if (unlikely(zip->ai)) - n = zip->cqe_cnt - zip->ai; - else - n = rte_be_to_cpu_32(cqe->byte_cnt); + n = rte_be_to_cpu_32(cqe->byte_cnt); else n = 1; cq_ci += n;