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 43916A0524 for ; Fri, 5 Feb 2021 12:38:15 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3DA98188A4B; Fri, 5 Feb 2021 12:38:15 +0100 (CET) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by mails.dpdk.org (Postfix) with ESMTP id 30D01188A4F for ; Fri, 5 Feb 2021 12:38:14 +0100 (CET) Received: by mail-wr1-f48.google.com with SMTP id p15so7287597wrq.8 for ; Fri, 05 Feb 2021 03:38:14 -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=ynvaPAokuLuWHgD+KBFbflP3/fdHUOYQWR+ayEynfG0=; b=YmPsKySuqsspJLSp7bE7rmvnX2zj19v8fvg/o21yy/4ZQ7tt75iGfxRDktNsa/aej+ jKSKWETxrE6jfJ0GT9OgQlPnITnIQc4c/bKQldG7akmCGSu64n3GZ5g8U1RYhmzn1FJt NlIhys6XWevyJ5e5ABAV3oZ7eecWpvq1QG/M6wohBqqrqiPpWDNL2jVaogmI8+e4ErLR RKhpGlUu2UgKA6McuZGlh5bSKxQNAzl54Hzlk1vNJ/SYGWPUxK21bzCBrCA6yw4931nV Va7GKIHJgbLSLGa6tdKejjfNLENSo2G06go3f2zIo5SXZ95p1Vve84n4F5+xgOD7KlST R5+w== 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=ynvaPAokuLuWHgD+KBFbflP3/fdHUOYQWR+ayEynfG0=; b=UoUZLRRZfOZCAxBiBvfMS8xjRF6KFCcWMfr3zWWhCVV/8+ZbwOorkmg7XnTUsrDiHq f+MgPGsiispff6cnl/h26GpsP9e5KfZ9J1TeFQxr6ozPWL88W3YuuoKZDduOFc1kT81C 7AgLdptAnE/QN3XUvP3ymujTaryRUoqPOr77nBROeKZmdWBwPpYr6sHDa3ZisOEUU5nZ zyrhGfe0GEMN3IzZocciQWJ+20v+1dVRxphEQxBngWfLYoj4ZDr7KcQvohGauEd8zoiC xU3ZrIqj9gDM66CDhdrPJMRomlbllr843IvepWoJW+lpNDeKQ9WL87+O9qakI61+wBt0 zN8A== X-Gm-Message-State: AOAM530Elzni6mo9TPpATvXd2xvPm7NZW27w0n0RnmOsrzJ9ygYX3wU9 QjspD62Etam/LI9Jt4wO9TFD/sF3BTTu+BZs X-Google-Smtp-Source: ABdhPJwk9ob+lWOFmE8+/TJOPVSf1+2K4RzCm8vJfrRt8XahoFRbhMEKuQ+cdmDFj8CoOLhLfVjKZQ== X-Received: by 2002:a5d:4d8b:: with SMTP id b11mr4552565wru.215.1612525093973; Fri, 05 Feb 2021 03:38:13 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id k4sm12742482wrm.53.2021.02.05.03.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 03:38:13 -0800 (PST) From: luca.boccassi@gmail.com To: Suanming Mou Cc: Viacheslav Ovsiienko , dpdk stable Date: Fri, 5 Feb 2021 11:18:50 +0000 Message-Id: <20210205111920.1272063-244-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/mlx4: fix port attach in secondary process' 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/bc0c3f60819b589e136cd5ce7078553d7d839144 Thanks. Luca Boccassi --- >From bc0c3f60819b589e136cd5ce7078553d7d839144 Mon Sep 17 00:00:00 2001 From: Suanming Mou Date: Sun, 24 Jan 2021 19:02:06 +0800 Subject: [PATCH] net/mlx4: fix port attach in secondary process [ upstream commit ed879add1ba7529d69c69a35d3260114f871750a ] Currently, the secondary process port UAR register mapping used by Tx queue is done during port initializing. Unluckily, in port hot-plug case, the secondary process will be requested to initialize the port when primary process probe the port. At that time, the port Tx queue number is still not configured, the secondary process get Tx queue number as 0. This causes the UAR register not be mapped as secondary process get Tx queue number 0. This commit adds the check of Tx queue number in secondary process when port starts is requested. Once the Tx queue number is not matching, do UAR mapping with the latest Tx queue number. Fixes: 0203d33a1059 ("net/mlx4: support secondary process") Signed-off-by: Suanming Mou Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx4/mlx4.c | 10 +++++----- drivers/net/mlx4/mlx4.h | 4 ++++ drivers/net/mlx4/mlx4_mp.c | 24 ++++++++++++++++++++++++ drivers/net/mlx4/mlx4_rxtx.h | 1 + drivers/net/mlx4/mlx4_txq.c | 28 ++++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 5 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 495b4fc8bd..919a9347f9 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -195,7 +195,7 @@ mlx4_free_verbs_buf(void *ptr, void *data __rte_unused) * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ -static int +int mlx4_proc_priv_init(struct rte_eth_dev *dev) { struct mlx4_proc_priv *ppriv; @@ -207,13 +207,13 @@ mlx4_proc_priv_init(struct rte_eth_dev *dev) */ ppriv_size = sizeof(struct mlx4_proc_priv) + dev->data->nb_tx_queues * sizeof(void *); - ppriv = rte_malloc_socket("mlx4_proc_priv", ppriv_size, - RTE_CACHE_LINE_SIZE, dev->device->numa_node); + ppriv = rte_zmalloc_socket("mlx4_proc_priv", ppriv_size, + RTE_CACHE_LINE_SIZE, dev->device->numa_node); if (!ppriv) { rte_errno = ENOMEM; return -rte_errno; } - ppriv->uar_table_sz = ppriv_size; + ppriv->uar_table_sz = dev->data->nb_tx_queues; dev->process_private = ppriv; return 0; } @@ -224,7 +224,7 @@ mlx4_proc_priv_init(struct rte_eth_dev *dev) * @param dev * Pointer to Ethernet device structure. */ -static void +void mlx4_proc_priv_uninit(struct rte_eth_dev *dev) { if (!dev->process_private) diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index c6cb29493e..87710d3996 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -197,6 +197,10 @@ struct mlx4_priv { #define PORT_ID(priv) ((priv)->dev_data->port_id) #define ETH_DEV(priv) (&rte_eth_devices[PORT_ID(priv)]) +int mlx4_proc_priv_init(struct rte_eth_dev *dev); +void mlx4_proc_priv_uninit(struct rte_eth_dev *dev); + + /* mlx4_ethdev.c */ int mlx4_get_ifname(const struct mlx4_priv *priv, char (*ifname)[IF_NAMESIZE]); diff --git a/drivers/net/mlx4/mlx4_mp.c b/drivers/net/mlx4/mlx4_mp.c index eca0c20a8a..3622d61075 100644 --- a/drivers/net/mlx4/mlx4_mp.c +++ b/drivers/net/mlx4/mlx4_mp.c @@ -111,6 +111,9 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer) const struct mlx4_mp_param *param = (const struct mlx4_mp_param *)mp_msg->param; struct rte_eth_dev *dev; +#ifdef HAVE_IBV_MLX4_UAR_MMAP_OFFSET + struct mlx4_proc_priv *ppriv; +#endif int ret; MLX4_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY); @@ -126,6 +129,21 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer) rte_mb(); dev->tx_pkt_burst = mlx4_tx_burst; dev->rx_pkt_burst = mlx4_rx_burst; +#ifdef HAVE_IBV_MLX4_UAR_MMAP_OFFSET + ppriv = (struct mlx4_proc_priv *)dev->process_private; + if (ppriv->uar_table_sz != dev->data->nb_tx_queues) { + mlx4_tx_uar_uninit_secondary(dev); + mlx4_proc_priv_uninit(dev); + ret = mlx4_proc_priv_init(dev); + if (ret) + return -rte_errno; + ret = mlx4_tx_uar_init_secondary(dev, mp_msg->fds[0]); + if (ret) { + mlx4_proc_priv_uninit(dev); + return -rte_errno; + } + } +#endif mp_init_msg(dev, &mp_res, param->type); res->result = 0; ret = rte_mp_reply(&mp_res, peer); @@ -163,6 +181,7 @@ mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx4_mp_req_type type) struct rte_mp_reply mp_rep; struct mlx4_mp_param *res __rte_unused; struct timespec ts = {.tv_sec = MLX4_MP_REQ_TIMEOUT_SEC, .tv_nsec = 0}; + struct mlx4_priv *priv; int ret; int i; @@ -175,6 +194,11 @@ mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx4_mp_req_type type) return; } mp_init_msg(dev, &mp_req, type); + if (type == MLX4_MP_REQ_START_RXTX) { + priv = dev->data->dev_private; + mp_req.num_fds = 1; + mp_req.fds[0] = priv->ctx->cmd_fd; + } ret = rte_mp_request_sync(&mp_req, &mp_rep, &ts); if (ret) { if (rte_errno != ENOTSUP) diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index 9de6c59411..136ca56ca4 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -157,6 +157,7 @@ uint16_t mlx4_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts, /* mlx4_txq.c */ int mlx4_tx_uar_init_secondary(struct rte_eth_dev *dev, int fd); +void mlx4_tx_uar_uninit_secondary(struct rte_eth_dev *dev); uint64_t mlx4_get_tx_port_offloads(struct mlx4_priv *priv); int mlx4_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket, diff --git a/drivers/net/mlx4/mlx4_txq.c b/drivers/net/mlx4/mlx4_txq.c index 37b84413fb..60560d9545 100644 --- a/drivers/net/mlx4/mlx4_txq.c +++ b/drivers/net/mlx4/mlx4_txq.c @@ -157,6 +157,27 @@ error: } while (i--); return -rte_errno; } + +void +mlx4_tx_uar_uninit_secondary(struct rte_eth_dev *dev) +{ + struct mlx4_proc_priv *ppriv = + (struct mlx4_proc_priv *)dev->process_private; + const size_t page_size = sysconf(_SC_PAGESIZE); + void *addr; + size_t i; + + if (page_size == (size_t)-1) { + ERROR("Failed to get mem page size"); + return; + } + for (i = 0; i < ppriv->uar_table_sz; i++) { + addr = ppriv->uar_table[i]; + if (addr) + munmap(RTE_PTR_ALIGN_FLOOR(addr, page_size), page_size); + } +} + #else int mlx4_tx_uar_init_secondary(struct rte_eth_dev *dev __rte_unused, @@ -167,6 +188,13 @@ mlx4_tx_uar_init_secondary(struct rte_eth_dev *dev __rte_unused, rte_errno = ENOTSUP; return -rte_errno; } + +void +mlx4_tx_uar_uninit_secondary(struct rte_eth_dev *dev __rte_unused) +{ + assert(rte_eal_process_type() == RTE_PROC_SECONDARY); + ERROR("UAR remap is not supported"); +} #endif /** -- 2.29.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-05 11:18:39.931402942 +0000 +++ 0244-net-mlx4-fix-port-attach-in-secondary-process.patch 2021-02-05 11:18:29.250699565 +0000 @@ -1 +1 @@ -From ed879add1ba7529d69c69a35d3260114f871750a Mon Sep 17 00:00:00 2001 +From bc0c3f60819b589e136cd5ce7078553d7d839144 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit ed879add1ba7529d69c69a35d3260114f871750a ] + @@ -20 +21,0 @@ -Cc: stable@dpdk.org @@ -33 +34 @@ -index 284dcb9dd0..041c1934f5 100644 +index 495b4fc8bd..919a9347f9 100644 @@ -72 +73 @@ -index 63df8fcf2b..e07b1d2386 100644 +index c6cb29493e..87710d3996 100644 @@ -87 +88 @@ -index e05da89c0e..ddf7bdb9ef 100644 +index eca0c20a8a..3622d61075 100644 @@ -143 +144 @@ -index 7c72ce6d17..c838afc242 100644 +index 9de6c59411..136ca56ca4 100644 @@ -155 +156 @@ -index 8262071505..31ab308050 100644 +index 37b84413fb..60560d9545 100644