From patchwork Thu Feb 2 10:34:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?N=C3=A9lio_Laranjeiro?= X-Patchwork-Id: 20123 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 53B42BD32; Thu, 2 Feb 2017 11:35:38 +0100 (CET) Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by dpdk.org (Postfix) with ESMTP id B1719DE3 for ; Thu, 2 Feb 2017 11:35:08 +0100 (CET) Received: by mail-wm0-f52.google.com with SMTP id b65so83683832wmf.0 for ; Thu, 02 Feb 2017 02:35:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=FQqdl70NftS7k4/+gE9cA2++LyyG53VjwOwExh/OiS4=; b=iGwLmSwZyWY262GgvgNYj96Z+7obkLWwgYrYTeOmBWLcKh9RgQfUqmPIxB1L40tSid mOGyEqKY6chvkxGpLmBZbb/PEyhxp5PhAsYvrpNq5Q9y2cF5tYsYCUux2gNFJlHu5bjf Znax7Z7el5d4m9uhVtivHHO+WzYhoiVugEqBFHDEURq1Mi5Q2EUqDGWmRZo43yEpyBkH JW1gCnPEkIhKnHQcM6o8KiXeFkmUcjORQPLs0pSkIGQ/TbOKMBCz62XPss7Wonnxx0GU 0zBU3T6zcsJv/B1CqyUDCp9xBQpO0f/qy9hQlBlZpTCWam/i0sdiZwon2/Z5ABePsr6j c2hA== 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:in-reply-to:references; bh=FQqdl70NftS7k4/+gE9cA2++LyyG53VjwOwExh/OiS4=; b=ka+5MIgsdMn3mXtFjB92hWYd5RsRar001QUOa6ZtsBap39eoSXA9gGMO4/aBbh4mbv 3srDLELvgh+2THPLBwL959QrUtPstCj6PrCJnjYEdsTsAgQw1psvAOEJFV5XkFiSlEcc 3JAFs/7O6mtWk1AMTi9qVFMIBoYsrnLCLjXpiNFzeWddCiKwB4dZH7baxHBjvG//M1kd hi/mFyTC0nL21+7XoZoE6VZUEeVotFCOmrNsQo35k6TiXsWO0YJwL304fZ6AzMOLAo8c yW40AHGoYCseg23F0mgrK47XIAFZZaAYOgpHh8r0h1kZvQaBeK31muJz7DEu5JPps7aj 0zrQ== X-Gm-Message-State: AIkVDXJHSnPvxx23mlzEdaMP5LlSN3NoRSTmSCWthZ+YAn3d9mxnLIh2Jlp6N5Sswdm13jbn X-Received: by 10.223.172.136 with SMTP id o8mr6891036wrc.76.1486031708389; Thu, 02 Feb 2017 02:35:08 -0800 (PST) Received: from ping.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id v67sm39053808wrc.45.2017.02.02.02.35.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Feb 2017 02:35:07 -0800 (PST) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Adrien Mazarguil , stable@dpdk.org, Yongseok Koh Date: Thu, 2 Feb 2017 11:34:13 +0100 Message-Id: <29aa766d79a43a79f738a14e4884e5a3b6428264.1486031307.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 3/3] net/mlx5: fix inline WQE consumption 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" For some sizes of packets, the number of bytes copied in the work queue element could be greater than the available size of the inline. In such situation it could consumed one more work queue element where it should not. Fixes: 0e8679fcddc4 ("net/mlx5: fix inline logic") Cc: stable@dpdk.org Reported-by: Elad Persiko Signed-off-by: Yongseok Koh Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_rxtx.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index a0e15ac..40f2c47 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -466,33 +466,28 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) addr += pkt_inline_sz; } /* Inline if enough room. */ - if (txq->max_inline != 0) { + if (txq->max_inline) { uintptr_t end = (uintptr_t) (((uintptr_t)txq->wqes) + (1 << txq->wqe_n) * MLX5_WQE_SIZE); - uint16_t max_inline = - txq->max_inline * RTE_CACHE_LINE_SIZE; - uint16_t room; + unsigned int max_inline = txq->max_inline * + RTE_CACHE_LINE_SIZE - + MLX5_WQE_DWORD_SIZE; + uintptr_t addr_end = (addr + max_inline) & + ~(RTE_CACHE_LINE_SIZE - 1); + unsigned int copy_b = (addr_end > addr) ? + RTE_MIN((addr_end - addr), length) : + 0; - /* - * raw starts two bytes before the boundary to - * continue the above copy of packet data. - */ raw += MLX5_WQE_DWORD_SIZE; - room = end - (uintptr_t)raw; - if (room > max_inline) { - uintptr_t addr_end = (addr + max_inline) & - ~(RTE_CACHE_LINE_SIZE - 1); - unsigned int copy_b = - RTE_MIN((addr_end - addr), length); - uint16_t n; - + if (copy_b && ((end - (uintptr_t)raw) > copy_b)) { /* * One Dseg remains in the current WQE. To * keep the computation positive, it is * removed after the bytes to Dseg conversion. */ - n = (MLX5_WQE_DS(copy_b) - 1 + 3) / 4; + uint16_t n = (MLX5_WQE_DS(copy_b) - 1 + 3) / 4; + if (unlikely(max_wqe < n)) break; max_wqe -= n; @@ -500,8 +495,6 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) addr += copy_b; length -= copy_b; pkt_inline_sz += copy_b; - /* Sanity check. */ - assert(addr <= addr_end); } /* * 2 DWORDs consumed by the WQE header + ETH segment +