DPDK patches and discussions
 help / color / mirror / Atom feed
From: Xueming Li <xuemingl@mellanox.com>
To: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>,
	Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: dev@dpdk.org, Xueming Li <xuemingl@mellanox.com>
Subject: [dpdk-dev] [PATCH v2 3/6] net/mlx5: allocate verbs object into shared memory
Date: Fri, 15 Sep 2017 23:59:57 +0800	[thread overview]
Message-ID: <1505491200-72127-3-git-send-email-xuemingl@mellanox.com> (raw)
In-Reply-To: <1505491200-72127-1-git-send-email-xuemingl@mellanox.com>

PMD uses Verbs object which were not available in the shared memory.

This patch modify the location where Verbs objects are allocated (from
process memory address space to shared memory address space) and thus
allow a secondary process to use those object by mapping this shared
memory space its own memory space.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/net/mlx5/mlx5.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index bfa38ba..11490d4 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -132,6 +132,52 @@ struct mlx5_args {
 }
 
 /**
+ * Verbs callback to allocate a memory. This function should allocate the space
+ * according to the size provided residing inside a huge page.
+ * Please note that all allocation must respect the alignment from libmlx5
+ * (i.e. currently sysconf(_SC_PAGESIZE)).
+ *
+ * @param[in] size
+ *   The size in bytes of the memory to allocate.
+ * @param[in] data
+ *   A pointer to the callback data.
+ *
+ * @return
+ *   a pointer to the allocate space.
+ */
+static void *
+mlx5_alloc_verbs_buf(size_t size, void *data)
+{
+	struct priv *priv = data;
+	void *ret;
+	size_t alignment = sysconf(_SC_PAGESIZE);
+
+	assert(data != NULL);
+	assert(!mlx5_is_secondary());
+	ret = rte_malloc_socket(__func__, size, alignment,
+				priv->dev->device->numa_node);
+	DEBUG("Extern alloc size: %lu, align: %lu: %p", size, alignment, ret);
+	return ret;
+}
+
+/**
+ * Verbs callback to free a memory.
+ *
+ * @param[in] ptr
+ *   A pointer to the memory to free.
+ * @param[in] data
+ *   A pointer to the callback data.
+ */
+static void
+mlx5_free_verbs_buf(void *ptr, void *data __rte_unused)
+{
+	assert(data != NULL);
+	assert(!mlx5_is_secondary());
+	DEBUG("Extern free request: %p", ptr);
+	rte_free(ptr);
+}
+
+/**
  * DPDK callback to close the device.
  *
  * Destroy all queues and objects, free memory.
@@ -826,6 +872,15 @@ struct mlx5_args {
 		eth_dev->dev_ops = &mlx5_dev_ops;
 		TAILQ_INIT(&priv->flows);
 
+		/* Hint libmlx5 to use PMD allocator for data plane resources */
+		struct mlx5dv_ctx_allocators alctr = {
+			.alloc = &mlx5_alloc_verbs_buf,
+			.free = &mlx5_free_verbs_buf,
+			.data = priv,
+		};
+		mlx5dv_set_context_attr(ctx, MLX5DV_CTX_ATTR_BUF_ALLOCATORS,
+					(void *)((uintptr_t)&alctr));
+
 		/* Bring Ethernet device up. */
 		DEBUG("forcing Ethernet interface up");
 		priv_set_flags(priv, ~IFF_UP, IFF_UP);
-- 
1.8.3.1

  parent reply	other threads:[~2017-09-15 16:00 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 14:03 [dpdk-dev] [PATCH v1 1/2] net/mlx5: change eth device reference for secondary process Xueming Li
2017-08-24 14:03 ` [dpdk-dev] [PATCH v1 2/2] net/mlx5: add multiple process support Xueming Li
2017-08-25  7:27   ` Nélio Laranjeiro
2017-08-25  6:52 ` [dpdk-dev] [PATCH v1 1/2] net/mlx5: change eth device reference for secondary process Nélio Laranjeiro
2017-08-25  7:15   ` Xueming(Steven) Li
2017-08-25  7:32     ` Nélio Laranjeiro
2017-09-15 15:59 ` [dpdk-dev] [PATCH v2 1/6] " Xueming Li
2017-09-15 15:59   ` [dpdk-dev] [PATCH v2 2/6] net/mlx5: install a socket to exchange a file descriptor Xueming Li
2017-09-15 15:59   ` Xueming Li [this message]
2017-09-15 15:59   ` [dpdk-dev] [PATCH v2 4/6] net/mlx5: remove verbs fork check Xueming Li
2017-09-15 15:59   ` [dpdk-dev] [PATCH v2 5/6] net/mlx5: add operations for secondary process Xueming Li
2017-09-15 16:00   ` [dpdk-dev] [PATCH v2 6/6] net/mlx5: multi-process document update Xueming Li
2017-09-18 14:36 ` [dpdk-dev] [PATCH v3 0/6] net/mlx5 multi-process support Xueming Li
2017-09-18 14:36 ` [dpdk-dev] [PATCH v3 1/6] net/mlx5: change eth device reference for secondary process Xueming Li
2017-09-18 14:36 ` [dpdk-dev] [PATCH v3 2/6] net/mlx5: install a socket to exchange a file descriptor Xueming Li
2017-09-18 14:36 ` [dpdk-dev] [PATCH v3 3/6] net/mlx5: allocate verbs object into shared memory Xueming Li
2017-09-18 14:36 ` [dpdk-dev] [PATCH v3 4/6] net/mlx5: remove verbs fork check Xueming Li
2017-09-18 14:36 ` [dpdk-dev] [PATCH v3 5/6] net/mlx5: add operations for secondary process Xueming Li
2017-09-18 14:36 ` [dpdk-dev] [PATCH v3 6/6] net/mlx5: multi-process document update Xueming Li
2017-09-18 18:47   ` Mcnamara, John
2017-09-19 14:31 ` [dpdk-dev] [PATCH v4 0/5] net/mlx5 multi-process support Xueming Li
2017-09-19 14:41   ` Nélio Laranjeiro
2017-09-19 14:48   ` Ferruh Yigit
2017-09-19 15:02     ` Xueming(Steven) Li
2017-09-20  8:07   ` Nélio Laranjeiro
2017-10-05  0:17   ` Ferruh Yigit
2017-10-06 15:52     ` Xueming(Steven) Li
2017-09-19 14:31 ` [dpdk-dev] [PATCH v4 1/5] net/mlx5: change eth device reference for secondary process Xueming Li
2017-09-19 14:31 ` [dpdk-dev] [PATCH v4 2/5] net/mlx5: install a socket to exchange a file descriptor Xueming Li
2017-09-19 14:31 ` [dpdk-dev] [PATCH v4 3/5] net/mlx5: allocate verbs object into shared memory Xueming Li
2017-09-19 14:31 ` [dpdk-dev] [PATCH v4 4/5] net/mlx5: add operations for secondary process Xueming Li
2017-09-19 14:31 ` [dpdk-dev] [PATCH v4 5/5] net/mlx5: multi-process document update Xueming Li
2017-09-19 16:16   ` Mcnamara, John
2017-10-06 15:45 ` [dpdk-dev] [PATCH v5 0/5] net/mlx5 multi-process support Xueming Li
2017-10-06 18:21   ` Ferruh Yigit
2017-10-06 15:45 ` [dpdk-dev] [PATCH v5 1/5] net/mlx5: change eth device reference for secondary process Xueming Li
2017-10-06 15:45 ` [dpdk-dev] [PATCH v5 2/5] net/mlx5: install a socket to exchange a file descriptor Xueming Li
2017-10-06 18:21   ` Ferruh Yigit
2017-10-06 15:45 ` [dpdk-dev] [PATCH v5 3/5] net/mlx5: allocate verbs object into shared memory Xueming Li
2017-10-06 15:45 ` [dpdk-dev] [PATCH v5 4/5] net/mlx5: add operations for secondary process Xueming Li
2017-10-06 15:45 ` [dpdk-dev] [PATCH v5 5/5] net/mlx5: multi-process document update Xueming Li

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=1505491200-72127-3-git-send-email-xuemingl@mellanox.com \
    --to=xuemingl@mellanox.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=nelio.laranjeiro@6wind.com \
    /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).