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 6057AA0547 for ; Mon, 8 Feb 2021 12:14:39 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 513E840693; Mon, 8 Feb 2021 12:14:39 +0100 (CET) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id 6E7B040693 for ; Mon, 8 Feb 2021 12:14:37 +0100 (CET) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l94V3-00019C-6c; Mon, 08 Feb 2021 11:14:37 +0000 From: Christian Ehrhardt To: Suanming Mou Cc: Viacheslav Ovsiienko , dpdk stable Date: Mon, 8 Feb 2021 12:14:14 +0100 Message-Id: <20210208111429.1875789-2-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208111429.1875789-1-christian.ehrhardt@canonical.com> References: <20210204112954.2488123-1-christian.ehrhardt@canonical.com> <20210208111429.1875789-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/mlx5: fix port attach in secondary process' has been queued to stable release 19.11.7 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 19.11.7 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/10/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/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/740893f42b87432184a73ee0c713051ae56be614 Thanks. Christian Ehrhardt --- >From 740893f42b87432184a73ee0c713051ae56be614 Mon Sep 17 00:00:00 2001 From: Suanming Mou Date: Mon, 8 Feb 2021 11:04:01 +0800 Subject: [PATCH] net/mlx5: fix port attach in secondary process [ upstream commit 2b36c30b8cd87585502dec0d2b89e76193f13fc3 ] 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 was requested to initialize the port when primary process did not complete the device configuration and the port Tx queue number is not configured yet. Hence, the secondary process gets the zero Tx queue number during probing, causing the UAR registers not be mapped in the correct fashion. This commit checks the configured number of Tx queues in secondary process when the port start is requested. In case the Tx queue number mismatch found the UAR mapping is reinitialized accordingly. Fixes: 2aac5b5d119f ("net/mlx5: sync stop/start with secondary process") Cc: stable@dpdk.org Signed-off-by: Suanming Mou Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 6 +++++- drivers/net/mlx5/mlx5_mp.c | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index ac4745295c..f8de9e329e 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1268,7 +1268,7 @@ mlx5_proc_priv_init(struct rte_eth_dev *dev) * @param dev * Pointer to Ethernet device structure. */ -static void +void mlx5_proc_priv_uninit(struct rte_eth_dev *dev) { if (!dev->process_private) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 206c8e9fa8..0e4a5f870d 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -699,7 +699,10 @@ struct mlx5_ibv_shared { struct mlx5_ibv_shared_port port[]; /* per device port data array. */ }; -/* Per-process private structure. */ +/* + * Per-process private structure. + * Caution, secondary process may rebuild the struct during port start. + */ struct mlx5_proc_priv { size_t uar_table_sz; /* Size of UAR register table. */ @@ -799,6 +802,7 @@ int64_t mlx5_get_dbr(struct rte_eth_dev *dev, struct mlx5_devx_dbr_page **dbr_page); int32_t mlx5_release_dbr(struct rte_eth_dev *dev, uint32_t umem_id, uint64_t offset); +void mlx5_proc_priv_uninit(struct rte_eth_dev *dev); int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev, struct rte_eth_udp_tunnel *udp_tunnel); uint16_t mlx5_eth_find_next(uint16_t port_id, struct rte_pci_device *pci_dev); diff --git a/drivers/net/mlx5/mlx5_mp.c b/drivers/net/mlx5/mlx5_mp.c index 2a031e2610..e889247871 100644 --- a/drivers/net/mlx5/mlx5_mp.c +++ b/drivers/net/mlx5/mlx5_mp.c @@ -119,6 +119,8 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer) const struct mlx5_mp_param *param = (const struct mlx5_mp_param *)mp_msg->param; struct rte_eth_dev *dev; + struct mlx5_proc_priv *ppriv; + struct mlx5_priv *priv; int ret; assert(rte_eal_process_type() == RTE_PROC_SECONDARY); @@ -128,12 +130,27 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer) return -rte_errno; } dev = &rte_eth_devices[param->port_id]; + priv = dev->data->dev_private; switch (param->type) { case MLX5_MP_REQ_START_RXTX: DRV_LOG(INFO, "port %u starting datapath", dev->data->port_id); rte_mb(); dev->rx_pkt_burst = mlx5_select_rx_function(dev); dev->tx_pkt_burst = mlx5_select_tx_function(dev); + ppriv = (struct mlx5_proc_priv *)dev->process_private; + /* If Tx queue number changes, re-initialize UAR. */ + if (ppriv->uar_table_sz != priv->txqs_n) { + mlx5_tx_uar_uninit_secondary(dev); + mlx5_proc_priv_uninit(dev); + ret = mlx5_proc_priv_init(dev); + if (ret) + return -rte_errno; + ret = mlx5_tx_uar_init_secondary(dev, mp_msg->fds[0]); + if (ret) { + mlx5_proc_priv_uninit(dev); + return -rte_errno; + } + } mp_init_msg(dev, &mp_res, param->type); res->result = 0; ret = rte_mp_reply(&mp_res, peer); @@ -172,6 +189,7 @@ mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx5_mp_req_type type) struct rte_mp_reply mp_rep; struct mlx5_mp_param *res; struct timespec ts = {.tv_sec = MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec = 0}; + struct mlx5_priv *priv = dev->data->dev_private; int ret; int i; @@ -184,6 +202,10 @@ mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx5_mp_req_type type) return; } mp_init_msg(dev, &mp_req, type); + if (type == MLX5_MP_REQ_START_RXTX) { + mp_req.num_fds = 1; + mp_req.fds[0] = ((struct ibv_context *)priv->sh->ctx)->cmd_fd; + } ret = rte_mp_request_sync(&mp_req, &mp_rep, &ts); if (ret) { if (rte_errno != ENOTSUP) -- 2.30.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-08 12:04:29.626003442 +0100 +++ 0002-net-mlx5-fix-port-attach-in-secondary-process.patch 2021-02-08 12:04:29.523496792 +0100 @@ -1 +1 @@ -From 2b36c30b8cd87585502dec0d2b89e76193f13fc3 Mon Sep 17 00:00:00 2001 +From 740893f42b87432184a73ee0c713051ae56be614 Mon Sep 17 00:00:00 2001 @@ -3 +3 @@ -Date: Sun, 24 Jan 2021 19:02:05 +0800 +Date: Mon, 8 Feb 2021 11:04:01 +0800 @@ -5,0 +6,2 @@ +[ upstream commit 2b36c30b8cd87585502dec0d2b89e76193f13fc3 ] + @@ -26,10 +28,47 @@ - drivers/net/mlx5/linux/mlx5_mp_os.c | 19 +++++++++++++++++++ - drivers/net/mlx5/mlx5.c | 2 +- - drivers/net/mlx5/mlx5.h | 6 +++++- - 3 files changed, 25 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/mlx5/linux/mlx5_mp_os.c b/drivers/net/mlx5/linux/mlx5_mp_os.c -index 60fdee22a1..8011ca87d7 100644 ---- a/drivers/net/mlx5/linux/mlx5_mp_os.c -+++ b/drivers/net/mlx5/linux/mlx5_mp_os.c -@@ -115,6 +115,7 @@ struct rte_mp_msg mp_res; + drivers/net/mlx5/mlx5.c | 2 +- + drivers/net/mlx5/mlx5.h | 6 +++++- + drivers/net/mlx5/mlx5_mp.c | 22 ++++++++++++++++++++++ + 3 files changed, 28 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c +index ac4745295c..f8de9e329e 100644 +--- a/drivers/net/mlx5/mlx5.c ++++ b/drivers/net/mlx5/mlx5.c +@@ -1268,7 +1268,7 @@ mlx5_proc_priv_init(struct rte_eth_dev *dev) + * @param dev + * Pointer to Ethernet device structure. + */ +-static void ++void + mlx5_proc_priv_uninit(struct rte_eth_dev *dev) + { + if (!dev->process_private) +diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h +index 206c8e9fa8..0e4a5f870d 100644 +--- a/drivers/net/mlx5/mlx5.h ++++ b/drivers/net/mlx5/mlx5.h +@@ -699,7 +699,10 @@ struct mlx5_ibv_shared { + struct mlx5_ibv_shared_port port[]; /* per device port data array. */ + }; + +-/* Per-process private structure. */ ++/* ++ * Per-process private structure. ++ * Caution, secondary process may rebuild the struct during port start. ++ */ + struct mlx5_proc_priv { + size_t uar_table_sz; + /* Size of UAR register table. */ +@@ -799,6 +802,7 @@ int64_t mlx5_get_dbr(struct rte_eth_dev *dev, + struct mlx5_devx_dbr_page **dbr_page); + int32_t mlx5_release_dbr(struct rte_eth_dev *dev, uint32_t umem_id, + uint64_t offset); ++void mlx5_proc_priv_uninit(struct rte_eth_dev *dev); + int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev, + struct rte_eth_udp_tunnel *udp_tunnel); + uint16_t mlx5_eth_find_next(uint16_t port_id, struct rte_pci_device *pci_dev); +diff --git a/drivers/net/mlx5/mlx5_mp.c b/drivers/net/mlx5/mlx5_mp.c +index 2a031e2610..e889247871 100644 +--- a/drivers/net/mlx5/mlx5_mp.c ++++ b/drivers/net/mlx5/mlx5_mp.c +@@ -119,6 +119,8 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer) @@ -40 +79 @@ - struct mlx5_priv *priv; ++ struct mlx5_priv *priv; @@ -43 +82,9 @@ -@@ -132,6 +133,20 @@ struct rte_mp_msg mp_res; + assert(rte_eal_process_type() == RTE_PROC_SECONDARY); +@@ -128,12 +130,27 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer) + return -rte_errno; + } + dev = &rte_eth_devices[param->port_id]; ++ priv = dev->data->dev_private; + switch (param->type) { + case MLX5_MP_REQ_START_RXTX: + DRV_LOG(INFO, "port %u starting datapath", dev->data->port_id); @@ -61 +108 @@ - mp_init_msg(&priv->mp_id, &mp_res, param->type); + mp_init_msg(dev, &mp_res, param->type); @@ -64 +111,9 @@ -@@ -183,6 +198,10 @@ mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx5_mp_req_type type) +@@ -172,6 +189,7 @@ mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx5_mp_req_type type) + struct rte_mp_reply mp_rep; + struct mlx5_mp_param *res; + struct timespec ts = {.tv_sec = MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec = 0}; ++ struct mlx5_priv *priv = dev->data->dev_private; + int ret; + int i; + +@@ -184,6 +202,10 @@ mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx5_mp_req_type type) @@ -67 +122 @@ - mp_init_msg(&priv->mp_id, &mp_req, type); + mp_init_msg(dev, &mp_req, type); @@ -75,37 +129,0 @@ -diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c -index 93629e5b05..aae2ef9af7 100644 ---- a/drivers/net/mlx5/mlx5.c -+++ b/drivers/net/mlx5/mlx5.c -@@ -1268,7 +1268,7 @@ mlx5_proc_priv_init(struct rte_eth_dev *dev) - * @param dev - * Pointer to Ethernet device structure. - */ --static void -+void - mlx5_proc_priv_uninit(struct rte_eth_dev *dev) - { - if (!dev->process_private) -diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h -index 4bbf628885..5196a9ea76 100644 ---- a/drivers/net/mlx5/mlx5.h -+++ b/drivers/net/mlx5/mlx5.h -@@ -743,7 +743,10 @@ struct mlx5_dev_ctx_shared { - struct mlx5_dev_shared_port port[]; /* per device port data array. */ - }; - --/* Per-process private structure. */ -+/* -+ * Per-process private structure. -+ * Caution, secondary process may rebuild the struct during port start. -+ */ - struct mlx5_proc_priv { - size_t uar_table_sz; - /* Size of UAR register table. */ -@@ -998,6 +1001,7 @@ struct rte_hairpin_peer_info { - - int mlx5_getenv_int(const char *); - int mlx5_proc_priv_init(struct rte_eth_dev *dev); -+void mlx5_proc_priv_uninit(struct rte_eth_dev *dev); - int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev, - struct rte_eth_udp_tunnel *udp_tunnel); - uint16_t mlx5_eth_find_next(uint16_t port_id, struct rte_pci_device *pci_dev);