DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: dev@dpdk.org, Ferruh Yigit <ferruh.yigit@intel.com>
Subject: [dpdk-dev] [PATCH v5 2/3] net/ring: use EAL APIs in PMD specific API
Date: Mon, 12 Jun 2017 16:25:11 +0100	[thread overview]
Message-ID: <20170612152512.11970-2-ferruh.yigit@intel.com> (raw)
In-Reply-To: <20170612152512.11970-1-ferruh.yigit@intel.com>

When ring PMD created via PMD specific API instead of EAL abstraction
it is missing the virtual device creation done by EAL vdev.

And this makes eth_dev unusable exact same as other PMDs used, because
of some missing fields, like rte_device->name.

Now API calls EAL APIs to create ring PMDs.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---

v5:
* fix build error
* add sanity check where addr get
---
 drivers/net/ring/rte_eth_ring.c | 83 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 77 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 6feb137..73ec2e4 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -45,12 +45,23 @@
 #define ETH_RING_NUMA_NODE_ACTION_ARG	"nodeaction"
 #define ETH_RING_ACTION_CREATE		"CREATE"
 #define ETH_RING_ACTION_ATTACH		"ATTACH"
+#define ETH_RING_INTERNAL_ARG		"internal"
 
 static const char *valid_arguments[] = {
 	ETH_RING_NUMA_NODE_ACTION_ARG,
+	ETH_RING_INTERNAL_ARG,
 	NULL
 };
 
+struct ring_internal_args {
+	struct rte_ring * const *rx_queues;
+	const unsigned int nb_rx_queues;
+	struct rte_ring * const *tx_queues;
+	const unsigned int nb_tx_queues;
+	const unsigned int numa_node;
+	void *addr; /* self addr for sanity check */
+};
+
 enum dev_action {
 	DEV_CREATE,
 	DEV_ATTACH
@@ -372,7 +383,18 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned nb_tx_queues,
 		const unsigned numa_node)
 {
-	struct rte_eth_dev *eth_dev = NULL;
+	struct ring_internal_args args = {
+		.rx_queues = rx_queues,
+		.nb_rx_queues = nb_rx_queues,
+		.tx_queues = tx_queues,
+		.nb_tx_queues = nb_tx_queues,
+		.numa_node = numa_node,
+		.addr = &args,
+	};
+	char args_str[32] = { 0 };
+	char ring_name[32] = { 0 };
+	uint8_t port_id = RTE_MAX_ETHPORTS;
+	int ret;
 
 	/* do some parameter checking */
 	if (rx_queues == NULL && nb_rx_queues > 0) {
@@ -388,9 +410,18 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		return -1;
 	}
 
-	return do_eth_dev_ring_create(name, rx_queues, nb_rx_queues,
-			tx_queues, nb_tx_queues, numa_node, DEV_ATTACH,
-			&eth_dev);
+	snprintf(args_str, 32, "%s=%p", ETH_RING_INTERNAL_ARG, &args);
+	snprintf(ring_name, 32, "net_ring_%s", name);
+
+	ret = rte_vdev_init(ring_name, args_str);
+	if (ret) {
+		rte_errno = EINVAL;
+		return -1;
+	}
+
+	rte_eth_dev_get_port_by_name(ring_name, &port_id);
+
+	return port_id;
 }
 
 int
@@ -508,6 +539,23 @@ static int parse_kvlist (const char *key __rte_unused, const char *value, void *
 }
 
 static int
+parse_internal_args(const char *key __rte_unused, const char *value,
+		void *data)
+{
+	struct ring_internal_args **internal_args = data;
+	void *args;
+
+	sscanf(value, "%p", &args);
+
+	*internal_args = args;
+
+	if ((*internal_args)->addr != args)
+		return -1;
+
+	return 0;
+}
+
+static int
 rte_pmd_ring_probe(struct rte_vdev_device *dev)
 {
 	const char *name, *params;
@@ -515,6 +563,7 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 	int ret = 0;
 	struct node_action_list *info = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
+	struct ring_internal_args *internal_args;
 
 	name = rte_vdev_device_name(dev);
 	params = rte_vdev_device_args(dev);
@@ -530,8 +579,7 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 			ret = eth_dev_ring_create(name, rte_socket_id(),
 						  DEV_ATTACH, &eth_dev);
 		}
-	}
-	else {
+	} else {
 		kvlist = rte_kvargs_parse(params, valid_arguments);
 
 		if (!kvlist) {
@@ -546,7 +594,30 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev)
 				ret = eth_dev_ring_create(name, rte_socket_id(),
 							  DEV_ATTACH, &eth_dev);
 			}
+
+			if (eth_dev)
+				eth_dev->device = &dev->device;
+
 			return ret;
+		}
+
+		if (rte_kvargs_count(kvlist, ETH_RING_INTERNAL_ARG) == 1) {
+			ret = rte_kvargs_process(kvlist, ETH_RING_INTERNAL_ARG,
+						 parse_internal_args,
+						 &internal_args);
+			if (ret < 0)
+				goto out_free;
+
+			ret = do_eth_dev_ring_create(name,
+				internal_args->rx_queues,
+				internal_args->nb_rx_queues,
+				internal_args->tx_queues,
+				internal_args->nb_tx_queues,
+				internal_args->numa_node,
+				DEV_ATTACH,
+				&eth_dev);
+			if (ret >= 0)
+				ret = 0;
 		} else {
 			ret = rte_kvargs_count(kvlist, ETH_RING_NUMA_NODE_ACTION_ARG);
 			info = rte_zmalloc("struct node_action_list",
-- 
2.9.4

  reply	other threads:[~2017-06-12 15:25 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26 11:15 [dpdk-dev] [PATCH] ethdev: remove driver name from device private data Ferruh Yigit
2017-06-06 15:10 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
2017-06-06 15:31   ` Gaëtan Rivet
2017-06-07  4:52   ` Shreyansh Jain
2017-06-07 16:11   ` Jan Blunck
2017-06-09 14:22     ` Ferruh Yigit
2017-06-09 15:49       ` Ferruh Yigit
2017-06-08 20:58   ` Thomas Monjalon
2017-06-09 10:51     ` Ferruh Yigit
2017-06-09 17:51   ` [dpdk-dev] [PATCH v3 1/3] net/ring: set ethernet device field Ferruh Yigit
2017-06-09 17:51     ` [dpdk-dev] [PATCH v3 2/3] net/ring: create vdev from PMD specific API Ferruh Yigit
2017-06-12 13:25       ` Bruce Richardson
2017-06-12 14:08         ` Ferruh Yigit
2017-06-12 14:19           ` Bruce Richardson
2017-06-12 14:38             ` Ferruh Yigit
2017-06-09 17:51     ` [dpdk-dev] [PATCH v3 3/3] ethdev: remove driver name from device private data Ferruh Yigit
2017-06-12 14:13     ` [dpdk-dev] [PATCH v4 1/3] net/ring: set ethernet device field Ferruh Yigit
2017-06-12 14:13       ` [dpdk-dev] [PATCH v4 2/3] net/ring: use EAL APIs in PMD specific API Ferruh Yigit
2017-06-12 14:20         ` Bruce Richardson
2017-06-12 14:13       ` [dpdk-dev] [PATCH v4 3/3] ethdev: remove driver name from device private data Ferruh Yigit
2017-06-12 15:25       ` [dpdk-dev] [PATCH v5 1/3] net/ring: set ethernet device field Ferruh Yigit
2017-06-12 15:25         ` Ferruh Yigit [this message]
2017-06-12 15:25         ` [dpdk-dev] [PATCH v5 3/3] ethdev: remove driver name from device private data Ferruh Yigit
2017-06-12 15:37         ` [dpdk-dev] [PATCH v5 1/3] net/ring: set ethernet device field Ferruh Yigit

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=20170612152512.11970-2-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@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).