DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yongseok Koh <yskoh@mellanox.com>
To: shahafs@mellanox.com
Cc: dev@dpdk.org, stable@dpdk.org
Subject: [dpdk-dev] [PATCH v3 2/6] net/mlx5: fix external memory registration
Date: Mon,  1 Apr 2019 14:17:53 -0700	[thread overview]
Message-ID: <20190401211757.26241-3-yskoh@mellanox.com> (raw)
Message-ID: <20190401211753.sstfaFDqbJanRLVUvQ7U32Zt9-VI0tnVbR9wkpo7v00@z> (raw)
In-Reply-To: <20190401211757.26241-1-yskoh@mellanox.com>

Secondary process is not allowed to register MR due to a restriction of
library and kernel driver.

Fixes: 7e43a32ee060 ("net/mlx5: support externally allocated static memory")
Cc: stable@dpdk.org

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
---
 doc/guides/nics/mlx5.rst   |  5 +++++
 drivers/net/mlx5/mlx5_mr.c | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index f4db921f7f..fa9bf73da7 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -86,6 +86,11 @@ Limitations
 
   - Forked secondary process not supported.
   - All mempools must be initialized before rte_eth_dev_start().
+  - External memory unregistered in EAL memseg list cannot be used for DMA
+    unless such memory has been registered by ``mlx5_mr_update_ext_mp()`` in
+    primary process and remapped to the same virtual address in secondary
+    process. If the external memory is registered by primary process but has
+    different virtual address in secondary process, unexpected error may happen.
 
 - Flow pattern without any specific vlan will match for vlan packets as well:
 
diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 3718877299..e7f55be6e1 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -1185,6 +1185,7 @@ mlx5_mr_update_ext_mp_cb(struct rte_mempool *mp, void *opaque,
 	struct mlx5_mr_cache entry;
 	uint32_t lkey;
 
+	assert(rte_eal_process_type() == RTE_PROC_PRIMARY);
 	/* If already registered, it should return. */
 	rte_rwlock_read_lock(&priv->mr.rwlock);
 	lkey = mr_lookup_dev(dev, &entry, addr);
@@ -1400,6 +1401,15 @@ mlx5_tx_update_ext_mp(struct mlx5_txq_data *txq, uintptr_t addr,
 	struct mlx5_mr_ctrl *mr_ctrl = &txq->mr_ctrl;
 	struct mlx5_priv *priv = txq_ctrl->priv;
 
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		DRV_LOG(WARNING,
+			"port %u using address (%p) from unregistered mempool"
+			" having externally allocated memory"
+			" in secondary process, please create mempool"
+			" prior to rte_eth_dev_start()",
+			PORT_ID(priv), (void *)addr);
+		return UINT32_MAX;
+	}
 	mlx5_mr_update_ext_mp(ETH_DEV(priv), mr_ctrl, mp);
 	return mlx5_tx_addr2mr_bh(txq, addr);
 }
-- 
2.11.0


  parent reply	other threads:[~2019-04-01 21:18 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-07  7:41 [dpdk-dev] [PATCH 0/6] net/mlx: enable secondary process to register DMA memory Yongseok Koh
2019-03-07  7:41 ` [dpdk-dev] [PATCH 1/6] net/mlx: remove debug messages on datapath Yongseok Koh
2019-03-07  7:41 ` [dpdk-dev] [PATCH 2/6] net/mlx5: fix external memory registration Yongseok Koh
2019-03-07  7:41 ` [dpdk-dev] [PATCH 3/6] net/mlx5: add control of excessive memory pinning by kernel Yongseok Koh
2019-03-07  7:41 ` [dpdk-dev] [PATCH 4/6] net/mlx5: enable secondary process to register DMA memory Yongseok Koh
2019-03-07  7:41 ` [dpdk-dev] [PATCH 5/6] net/mlx4: add control of excessive memory pinning by kernel Yongseok Koh
2019-03-07  7:41 ` [dpdk-dev] [PATCH 6/6] net/mlx4: enable secondary process to register DMA memory Yongseok Koh
2019-03-07  7:55 ` [dpdk-dev] [PATCH 0/6] net/mlx: " Yongseok Koh
2019-03-14 12:45 ` Shahaf Shuler
2019-03-14 12:45   ` Shahaf Shuler
2019-03-25 19:22 ` [dpdk-dev] [PATCH v2 " Yongseok Koh
2019-03-25 19:22   ` Yongseok Koh
2019-03-25 19:22   ` [dpdk-dev] [PATCH v2 1/6] net/mlx: remove debug messages on datapath Yongseok Koh
2019-03-25 19:22     ` Yongseok Koh
2019-03-25 19:22   ` [dpdk-dev] [PATCH v2 2/6] net/mlx5: fix external memory registration Yongseok Koh
2019-03-25 19:22     ` Yongseok Koh
2019-03-25 19:22   ` [dpdk-dev] [PATCH v2 3/6] net/mlx5: add control of excessive memory pinning by kernel Yongseok Koh
2019-03-25 19:22     ` Yongseok Koh
2019-03-25 19:22   ` [dpdk-dev] [PATCH v2 4/6] net/mlx5: enable secondary process to register DMA memory Yongseok Koh
2019-03-25 19:22     ` Yongseok Koh
2019-03-25 19:22   ` [dpdk-dev] [PATCH v2 5/6] net/mlx4: add control of excessive memory pinning by kernel Yongseok Koh
2019-03-25 19:22     ` Yongseok Koh
2019-03-25 19:22   ` [dpdk-dev] [PATCH v2 6/6] net/mlx4: enable secondary process to register DMA memory Yongseok Koh
2019-03-25 19:22     ` Yongseok Koh
2019-04-01 21:17 ` [dpdk-dev] [PATCH v3 0/6] net/mlx: " Yongseok Koh
2019-04-01 21:17   ` Yongseok Koh
2019-04-01 21:17   ` [dpdk-dev] [PATCH v3 1/6] net/mlx: remove debug messages on datapath Yongseok Koh
2019-04-01 21:17     ` Yongseok Koh
2019-04-01 21:17   ` Yongseok Koh [this message]
2019-04-01 21:17     ` [dpdk-dev] [PATCH v3 2/6] net/mlx5: fix external memory registration Yongseok Koh
2019-04-01 21:17   ` [dpdk-dev] [PATCH v3 3/6] net/mlx5: add control of excessive memory pinning by kernel Yongseok Koh
2019-04-01 21:17     ` Yongseok Koh
2019-04-01 21:17   ` [dpdk-dev] [PATCH v3 4/6] net/mlx5: enable secondary process to register DMA memory Yongseok Koh
2019-04-01 21:17     ` Yongseok Koh
2019-04-01 21:17   ` [dpdk-dev] [PATCH v3 5/6] net/mlx4: add control of excessive memory pinning by kernel Yongseok Koh
2019-04-01 21:17     ` Yongseok Koh
2019-05-14  4:52     ` Stephen Hemminger
2019-05-14  4:52       ` Stephen Hemminger
2019-05-14  4:54       ` Stephen Hemminger
2019-05-14  4:54         ` Stephen Hemminger
2019-04-01 21:17   ` [dpdk-dev] [PATCH v3 6/6] net/mlx4: enable secondary process to register DMA memory Yongseok Koh
2019-04-01 21:17     ` Yongseok Koh
2019-04-02  7:13   ` [dpdk-dev] [PATCH v3 0/6] net/mlx: " Shahaf Shuler
2019-04-02  7:13     ` Shahaf Shuler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190401211757.26241-3-yskoh@mellanox.com \
    --to=yskoh@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=shahafs@mellanox.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).