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 1FAC4A0524 for ; Fri, 5 Feb 2021 12:39:38 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1B18E188A6F; Fri, 5 Feb 2021 12:39:38 +0100 (CET) Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by mails.dpdk.org (Postfix) with ESMTP id 26CD0188A67 for ; Fri, 5 Feb 2021 12:39:37 +0100 (CET) Received: by mail-wr1-f43.google.com with SMTP id m13so7290118wro.12 for ; Fri, 05 Feb 2021 03:39:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0xFs2nGW5PAfCJL4Z+iwquxsq/xbuN+myqoJwywn6lE=; b=kOJJXo/R1SiIGSI7jl68bsBUOQSPS6nAHSdW5aoAfoRwFykY7vimuaUgS4meQEpl1v et4+1v3pQMhL8pX049sGzA5Bvm6I+9ViENaIqctWxxdTRKrf4bHM+OjQMh4TjZVy0uzT 3YNl6DhEmgqOriO+j3+8hduI9QWQEfAaPTwvYN8fCCGIkBrjWPPnQnAJA5zMnSjUBXkW 2JmEOKrFmb4s09HFHqGtTOBL0knqi+zl4/yAn5y+yoi4q4H8ODPLsxvnUTTRV2aa9+yo lE4688Rt3dEkKfl24hdugQOwov2wlytGhoIWxySIuteFSyDvRHJpjPBIaE+Z4dmNFG6y 1/EA== 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=0xFs2nGW5PAfCJL4Z+iwquxsq/xbuN+myqoJwywn6lE=; b=i2yyQkUcYvSEMRl46jz17D/Tq3dpae6kE19GPXFyKAF7x85cMn0aOo7O/vYh+j3onU 9SRbz/wSvZWnN+ZG7YNiR+W8MYmfsZldnpWyTRWO2/PeLuUiaEtYXEZ0fLqAiCEqETsN hF6hCSaNHtyv0nzB8wcBTOl6Kig/gT+3XYU+E2G9Y8AaLY3UjJxjaFIPQkz8mcj4cWOO MET3nIFYZL7OAVh8sbxGaO78To2fg5yS2mqCNN32aF6mPNr2MrlGox55pov+hRcLYCTB p9HRABSSk9bg3w7TIc2Wj9F1KOlPd81Kl27Fm8VDN1c0tz99lly1qCqa8RwX60nsbAOp lJ2g== X-Gm-Message-State: AOAM531nSVAKf8/JiHA4/rvcLgpVpaRzPVsbOzBTo+Fa9dWf7TBWesJZ jBwjIzfC1DjnJMxpQY3hy2igRj/OFqlmdS5B X-Google-Smtp-Source: ABdhPJykIKgyjzoSUsr7QOAQKPgOHSrqRKoq3shj2wyAhLsiOVrMlU8alez6/wnNxd5c8TiuXHGQ9g== X-Received: by 2002:adf:e50e:: with SMTP id j14mr4695139wrm.162.1612525176956; Fri, 05 Feb 2021 03:39:36 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id u3sm13116079wre.54.2021.02.05.03.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 03:39:36 -0800 (PST) From: luca.boccassi@gmail.com To: Michal Krawczyk Cc: Ido Segev , Igor Chauskin , dpdk stable Date: Fri, 5 Feb 2021 11:19:16 +0000 Message-Id: <20210205111920.1272063-270-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210205111920.1272063-1-luca.boccassi@gmail.com> References: <20210205111920.1272063-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/ena: validate Rx req ID upon acquiring descriptor' has been queued to stable release 20.11.1 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 Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/07/21. 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/97e85ace6bb679f54e034aef92099ac21501467f Thanks. Luca Boccassi --- >From 97e85ace6bb679f54e034aef92099ac21501467f Mon Sep 17 00:00:00 2001 From: Michal Krawczyk Date: Tue, 26 Jan 2021 19:32:24 +0100 Subject: [PATCH] net/ena: validate Rx req ID upon acquiring descriptor [ upstream commit 05cffdcfa0f1940e0b2c5495aa7194c474cfe197 ] Instead of verifying the Rx descriptor each time it's being used in the driver code, now the verification happens on the HAL side. This simplifies code a lot as instead of doing 2 validations, only single one is needed. The driver have to check the rc value returned by the ena_com upon reading the Rx descriptor and trigger the reset if needed. It was previously the responsibility of the validate_rx_req_id() function. As part of the change, the version of the driver was bumped to v2.2.1. Fixes: 2061fe41f212 ("net/ena: linearize Tx mbuf") Signed-off-by: Ido Segev Signed-off-by: Michal Krawczyk Reviewed-by: Igor Chauskin --- drivers/net/ena/base/ena_eth_com.c | 3 +++ drivers/net/ena/base/ena_plat_dpdk.h | 1 + drivers/net/ena/ena_ethdev.c | 38 ++++++++-------------------- 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/drivers/net/ena/base/ena_eth_com.c b/drivers/net/ena/base/ena_eth_com.c index a35d92fbd3..5583a310a1 100644 --- a/drivers/net/ena/base/ena_eth_com.c +++ b/drivers/net/ena/base/ena_eth_com.c @@ -531,6 +531,7 @@ int ena_com_rx_pkt(struct ena_com_io_cq *io_cq, { struct ena_com_rx_buf_info *ena_buf = &ena_rx_ctx->ena_bufs[0]; struct ena_eth_io_rx_cdesc_base *cdesc = NULL; + u16 q_depth = io_cq->q_depth; u16 cdesc_idx = 0; u16 nb_hw_desc; u16 i = 0; @@ -559,6 +560,8 @@ int ena_com_rx_pkt(struct ena_com_io_cq *io_cq, do { ena_buf[i].len = cdesc->length; ena_buf[i].req_id = cdesc->req_id; + if (unlikely(ena_buf[i].req_id >= q_depth)) + return ENA_COM_EIO; if (++i >= nb_hw_desc) break; diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h index 48c77f0c19..a1d749f83f 100644 --- a/drivers/net/ena/base/ena_plat_dpdk.h +++ b/drivers/net/ena/base/ena_plat_dpdk.h @@ -51,6 +51,7 @@ typedef uint64_t dma_addr_t; #define ENA_COM_FAULT -EFAULT #define ENA_COM_TRY_AGAIN -EAGAIN #define ENA_COM_UNSUPPORTED -EOPNOTSUPP +#define ENA_COM_EIO -EIO #define ____cacheline_aligned __rte_cache_aligned diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index 111e830bfa..9ee9de6eb9 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -28,7 +28,7 @@ #define DRV_MODULE_VER_MAJOR 2 #define DRV_MODULE_VER_MINOR 2 -#define DRV_MODULE_VER_SUBMINOR 0 +#define DRV_MODULE_VER_SUBMINOR 1 #define ENA_IO_TXQ_IDX(q) (2 * (q)) #define ENA_IO_RXQ_IDX(q) (2 * (q) + 1) @@ -380,20 +380,6 @@ static inline void ena_tx_mbuf_prepare(struct rte_mbuf *mbuf, } } -static inline int validate_rx_req_id(struct ena_ring *rx_ring, uint16_t req_id) -{ - if (likely(req_id < rx_ring->ring_size)) - return 0; - - PMD_DRV_LOG(ERR, "Invalid rx req_id: %hu\n", req_id); - - rx_ring->adapter->reset_reason = ENA_REGS_RESET_INV_RX_REQ_ID; - rx_ring->adapter->trigger_reset = true; - ++rx_ring->rx_stats.bad_req_id; - - return -EFAULT; -} - static int validate_tx_req_id(struct ena_ring *tx_ring, u16 req_id) { struct ena_tx_buffer *tx_info = NULL; @@ -1486,10 +1472,6 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count) rte_prefetch0(mbufs[i + 4]); req_id = rxq->empty_rx_reqs[next_to_use]; - rc = validate_rx_req_id(rxq, req_id); - if (unlikely(rc)) - break; - rx_info = &rxq->rx_buffer_info[req_id]; rc = ena_add_single_rx_desc(rxq->ena_com_io_sq, mbuf, req_id); @@ -2114,8 +2096,6 @@ static struct rte_mbuf *ena_rx_mbuf(struct ena_ring *rx_ring, len = ena_bufs[buf].len; req_id = ena_bufs[buf].req_id; - if (unlikely(validate_rx_req_id(rx_ring, req_id))) - return NULL; rx_info = &rx_ring->rx_buffer_info[req_id]; @@ -2139,10 +2119,6 @@ static struct rte_mbuf *ena_rx_mbuf(struct ena_ring *rx_ring, ++buf; len = ena_bufs[buf].len; req_id = ena_bufs[buf].req_id; - if (unlikely(validate_rx_req_id(rx_ring, req_id))) { - rte_mbuf_raw_free(mbuf_head); - return NULL; - } rx_info = &rx_ring->rx_buffer_info[req_id]; RTE_ASSERT(rx_info->mbuf != NULL); @@ -2230,10 +2206,16 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, &ena_rx_ctx); if (unlikely(rc)) { PMD_DRV_LOG(ERR, "ena_com_rx_pkt error %d\n", rc); - rx_ring->adapter->reset_reason = - ENA_REGS_RESET_TOO_MANY_RX_DESCS; + if (rc == ENA_COM_NO_SPACE) { + ++rx_ring->rx_stats.bad_desc_num; + rx_ring->adapter->reset_reason = + ENA_REGS_RESET_TOO_MANY_RX_DESCS; + } else { + ++rx_ring->rx_stats.bad_req_id; + rx_ring->adapter->reset_reason = + ENA_REGS_RESET_INV_RX_REQ_ID; + } rx_ring->adapter->trigger_reset = true; - ++rx_ring->rx_stats.bad_desc_num; return 0; } -- 2.29.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-05 11:18:41.095524635 +0000 +++ 0270-net-ena-validate-Rx-req-ID-upon-acquiring-descriptor.patch 2021-02-05 11:18:29.354701545 +0000 @@ -1 +1 @@ -From 05cffdcfa0f1940e0b2c5495aa7194c474cfe197 Mon Sep 17 00:00:00 2001 +From 97e85ace6bb679f54e034aef92099ac21501467f Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 05cffdcfa0f1940e0b2c5495aa7194c474cfe197 ] + @@ -18 +19,0 @@ -Cc: stable@dpdk.org @@ -63 +64 @@ -index 623b6dd2a0..1728ceb9a8 100644 +index 111e830bfa..9ee9de6eb9 100644