From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D5F59A051C for ; Tue, 11 Feb 2020 12:41:04 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CB9091BFF5; Tue, 11 Feb 2020 12:41:04 +0100 (CET) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id A11361DB9 for ; Tue, 11 Feb 2020 12:41:03 +0100 (CET) Received: by mail-wr1-f66.google.com with SMTP id z3so11970228wru.3 for ; Tue, 11 Feb 2020 03:41:03 -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=biuiLDVslK6tCcm3AD8ED8hUzchWqTDH39K7tDEyzG4=; b=uswdOaczpl3DgEhPOZMusUFYFMJIb1qU8SyfqaLH1vkABTNSlBMqzH0eiwto6u95jN tvQJh6LDT2xWDpn4UD5g135C9nQj6ZMUuI0brHmz5aEibcgKWZ6eq22EtulYsSj4M237 NJ0y/U0fPgtG6wz1OYV04iN87lx7TnhvziCtmPrEFUYwb3uALo/krRspwNzetbY1gmeA MfIfAm7irUH33I1ADCCnTbDk160fIxQfrEEYBqoUbMPoETnu5xz+A1ehJrWGhsdyIGl5 zWht+wYSdM6gSA5Vqsju77hZw8wyP6hfAh5Y88aHa6r7eTqCcngt4U8ZAgmyPD+zOw62 dV9Q== 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=biuiLDVslK6tCcm3AD8ED8hUzchWqTDH39K7tDEyzG4=; b=UIqgyB7PQPsNfvTIKpXdS5+pC35T6itk6q2J4GOalslhxAKaXv8K2dXDaE43EkqyFn 1AvU9c5BAbXkT0jQJaSAUn80kvd8Kvn/6JFZUo2Za42NO4EvsOJW7eSsXMDx32njdqKS WbQwvPqkefrlJG7cEXKQ1JA0ZoaRpjpurkV/1VjokjM9irDjxT3y9NEE2CwZeXrYOOdc dyLqbXhUMFgsb0/82Ky8z0ZQFgp8vwGHwA6F9s/bpoLwa3aO9xX4E/4qeBU9feTg67/F yjpGr+l1yrcwT1ShRlpPWit9Od30wFxThFpMGjT72LNzMMReqXN7JFCRK7cshfOfG+N9 bAPg== X-Gm-Message-State: APjAAAWiaNP+FYdZkylU0Ef3fxTL1yUfftirmnmInn8mXg036CJh6J40 pYudO5ygw8llLIfNn6U9hM3pNnnr2pU= X-Google-Smtp-Source: APXvYqzxQ5EXvnTffECiAB/dWGwfpMnIOXC3NYe5iiAOj3SgXKxo7CuAA0lIv6/tSDTVQYbk7FxsIw== X-Received: by 2002:a5d:5704:: with SMTP id a4mr8714804wrv.198.1581421262327; Tue, 11 Feb 2020 03:41:02 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id e18sm4919981wrw.70.2020.02.11.03.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 03:41:01 -0800 (PST) From: luca.boccassi@gmail.com To: Rasesh Mody Cc: dpdk stable Date: Tue, 11 Feb 2020 11:21:44 +0000 Message-Id: <20200211112216.3929-158-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200211112216.3929-1-luca.boccassi@gmail.com> References: <20200211112216.3929-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/bnx2x: fix to sync fastpath Rx queue access' has been queued to stable release 19.11.1 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: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.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/13/20. 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. Thanks. Luca Boccassi --- >From 5fb6087d0e72af502978ae25ee537550fe250af5 Mon Sep 17 00:00:00 2001 From: Rasesh Mody Date: Sun, 26 Jan 2020 14:54:19 -0800 Subject: [PATCH] net/bnx2x: fix to sync fastpath Rx queue access [ upstream commit 141c86f55f734c4f8b9ad3129b6e58807b5c4577 ] PMD handles fast path completions in the Rx handler and control path completions in the interrupt handler. They both are processing completions from the same fastpath completion queue. There is a potential for race condition when these two paths are processing the completions from the same queue and trying to updating Rx Producer. Add a fastpath Rx lock between these two paths to close this race. Fixes: 540a211084a7 ("bnx2x: driver core") Signed-off-by: Rasesh Mody --- drivers/net/bnx2x/bnx2x.c | 12 ++++++++++++ drivers/net/bnx2x/bnx2x.h | 3 +++ drivers/net/bnx2x/bnx2x_rxtx.c | 8 +++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c index 50e289b286..0b4030e2b9 100644 --- a/drivers/net/bnx2x/bnx2x.c +++ b/drivers/net/bnx2x/bnx2x.c @@ -1167,6 +1167,10 @@ static int bnx2x_has_rx_work(struct bnx2x_fastpath *fp) if (unlikely((rx_cq_cons_sb & MAX_RCQ_ENTRIES(rxq)) == MAX_RCQ_ENTRIES(rxq))) rx_cq_cons_sb++; + + PMD_RX_LOG(DEBUG, "hw CQ cons = %d, sw CQ cons = %d", + rx_cq_cons_sb, rxq->rx_cq_head); + return rxq->rx_cq_head != rx_cq_cons_sb; } @@ -1249,9 +1253,12 @@ static uint8_t bnx2x_rxeof(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp) uint16_t bd_cons, bd_prod, bd_prod_fw, comp_ring_cons; uint16_t hw_cq_cons, sw_cq_cons, sw_cq_prod; + rte_spinlock_lock(&(fp)->rx_mtx); + rxq = sc->rx_queues[fp->index]; if (!rxq) { PMD_RX_LOG(ERR, "RX queue %d is NULL", fp->index); + rte_spinlock_unlock(&(fp)->rx_mtx); return 0; } @@ -1321,9 +1328,14 @@ next_cqe: rxq->rx_cq_head = sw_cq_cons; rxq->rx_cq_tail = sw_cq_prod; + PMD_RX_LOG(DEBUG, "BD prod = %d, sw CQ prod = %d", + bd_prod_fw, sw_cq_prod); + /* Update producers */ bnx2x_update_rx_prod(sc, fp, bd_prod_fw, sw_cq_prod); + rte_spinlock_unlock(&(fp)->rx_mtx); + return sw_cq_cons != hw_cq_cons; } diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h index 3383c76759..1dbc98197d 100644 --- a/drivers/net/bnx2x/bnx2x.h +++ b/drivers/net/bnx2x/bnx2x.h @@ -360,6 +360,9 @@ struct bnx2x_fastpath { /* pointer back to parent structure */ struct bnx2x_softc *sc; + /* Used to synchronize fastpath Rx access */ + rte_spinlock_t rx_mtx; + /* status block */ struct bnx2x_dma sb_dma; union bnx2x_host_hc_status_block status_block; diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c index ae97dfee36..0d77035844 100644 --- a/drivers/net/bnx2x/bnx2x_rxtx.c +++ b/drivers/net/bnx2x/bnx2x_rxtx.c @@ -346,6 +346,8 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) uint16_t len, pad; struct rte_mbuf *rx_mb = NULL; + rte_spinlock_lock(&(fp)->rx_mtx); + hw_cq_cons = le16toh(*fp->rx_cq_cons_sb); if ((hw_cq_cons & USABLE_RCQ_ENTRIES_PER_PAGE) == USABLE_RCQ_ENTRIES_PER_PAGE) { @@ -357,8 +359,10 @@ bnx2x_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) sw_cq_cons = rxq->rx_cq_head; sw_cq_prod = rxq->rx_cq_tail; - if (sw_cq_cons == hw_cq_cons) + if (sw_cq_cons == hw_cq_cons) { + rte_spinlock_unlock(&(fp)->rx_mtx); return 0; + } while (nb_rx < nb_pkts && sw_cq_cons != hw_cq_cons) { @@ -439,6 +443,8 @@ next_rx: bnx2x_upd_rx_prod_fast(sc, fp, bd_prod, sw_cq_prod); + rte_spinlock_unlock(&(fp)->rx_mtx); + return nb_rx; } -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-02-11 11:17:44.121928415 +0000 +++ 0158-net-bnx2x-fix-to-sync-fastpath-Rx-queue-access.patch 2020-02-11 11:17:38.760008079 +0000 @@ -1,8 +1,10 @@ -From 141c86f55f734c4f8b9ad3129b6e58807b5c4577 Mon Sep 17 00:00:00 2001 +From 5fb6087d0e72af502978ae25ee537550fe250af5 Mon Sep 17 00:00:00 2001 From: Rasesh Mody Date: Sun, 26 Jan 2020 14:54:19 -0800 Subject: [PATCH] net/bnx2x: fix to sync fastpath Rx queue access +[ upstream commit 141c86f55f734c4f8b9ad3129b6e58807b5c4577 ] + PMD handles fast path completions in the Rx handler and control path completions in the interrupt handler. They both are processing completions from the same fastpath completion queue. There is a @@ -12,7 +14,6 @@ Add a fastpath Rx lock between these two paths to close this race. Fixes: 540a211084a7 ("bnx2x: driver core") -Cc: stable@dpdk.org Signed-off-by: Rasesh Mody ---