From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by dpdk.org (Postfix) with ESMTP id B99A92BCD for ; Thu, 2 Feb 2017 11:35:08 +0100 (CET) Received: by mail-wm0-f54.google.com with SMTP id c85so83605807wmi.1 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=r1pofmTmZrTLByhCmNTQJNbxGvks6avvfqCDRj4epQiTKLAMacxydXiod2dXP+RnUc AmxEc3lD6b6B275UZFgBP6hS645iLnz+DBbXi9OtUezu0fQvqMF7aYemusQWsds7yvFf L0kjPGlYlYVxpd+PIc/zW7ybDIVe6qd+LiaHYV88rIYHeGr0QRtNSlUC/nKEn2QxgGXz 8lBjUkMAjeFE3MXTcPyR/LYr22LdTpSLhZO/jBUJuGUvh7X0O7QW7TBWTyorVehlLe51 2w8j0sddULDwyPbyDxVqeDu/5Z4Ka1LQnbBc+aYzUQm1g3GrI7ahbOjuoebXuoHkpV6s TBjg== X-Gm-Message-State: AIkVDXKkki80It6ckzDPWpTrS0tGuKsn9wk89aDBxZi1MWwQhZAgeeE2cvAeVImeLnDYS/Cv 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-stable] [PATCH 3/3] net/mlx5: fix inline WQE consumption X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Feb 2017 10:35:09 -0000 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 + -- 2.1.4