DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: dev@dpdk.org, Ferruh Yigit <ferruh.yigit@intel.com>,
	Gaetan Rivet <gaetan.rivet@6wind.com>,
	Jan Blunck <jblunck@infradead.org>
Subject: [dpdk-dev] [PATCH v2 3/3] ethdev: use device name from device structure
Date: Fri,  9 Jun 2017 19:36:06 +0100	[thread overview]
Message-ID: <20170609183606.34596-3-ferruh.yigit@intel.com> (raw)
In-Reply-To: <20170609183606.34596-1-ferruh.yigit@intel.com>

Device name resides in two different locations, in rte_device->name and
in ethernet device private data.

For now, the copy in the ethernet device private data is required for
multi process support, the name is the how secondary process finds about
primary process device.

But in the ethdev library some eth_dev->data->name usage can be
converted to rte_device->name.

This patch updates ethdev to use rte_device->name when possible.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
Cc: Jan Blunck <jblunck@infradead.org>
---
 lib/librte_ether/rte_ethdev.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index d257406..1cbe9b9 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -178,9 +178,11 @@ rte_eth_dev_allocated(const char *name)
 	unsigned i;
 
 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
-		if ((rte_eth_devices[i].state == RTE_ETH_DEV_ATTACHED) &&
-		    strcmp(rte_eth_devices[i].data->name, name) == 0)
-			return &rte_eth_devices[i];
+		if (rte_eth_devices[i].state == RTE_ETH_DEV_ATTACHED &&
+				rte_eth_devices[i].device) {
+			if (!strcmp(rte_eth_devices[i].device->name, name))
+				return &rte_eth_devices[i];
+		}
 	}
 	return NULL;
 }
@@ -310,7 +312,7 @@ rte_eth_dev_count(void)
 int
 rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 {
-	char *tmp;
+	const char *tmp;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
@@ -321,7 +323,7 @@ rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 
 	/* shouldn't check 'rte_eth_devices[i].data',
 	 * because it might be overwritten by VDEV PMD */
-	tmp = rte_eth_dev_data[port_id].name;
+	tmp = rte_eth_devices[port_id].device->name;
 	strcpy(name, tmp);
 	return 0;
 }
@@ -329,6 +331,7 @@ rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 int
 rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id)
 {
+	int ret;
 	int i;
 
 	if (name == NULL) {
@@ -341,11 +344,14 @@ rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id)
 
 	*port_id = RTE_MAX_ETHPORTS;
 	RTE_ETH_FOREACH_DEV(i) {
-		if (!strncmp(name,
-			rte_eth_dev_data[i].name, strlen(name))) {
+		if (!rte_eth_devices[i].device)
+			continue;
 
-			*port_id = i;
+		ret = strncmp(name, rte_eth_devices[i].device->name,
+			strlen(name));
 
+		if (!ret) {
+			*port_id = i;
 			return 0;
 		}
 	}
@@ -438,8 +444,8 @@ rte_eth_dev_detach(uint8_t port_id, char *name)
 	if (rte_eth_dev_is_detachable(port_id))
 		goto err;
 
-	snprintf(name, sizeof(rte_eth_devices[port_id].data->name),
-		 "%s", rte_eth_devices[port_id].data->name);
+	snprintf(name, sizeof(rte_eth_devices[port_id].device->name),
+		 "%s", rte_eth_devices[port_id].device->name);
 	ret = rte_eal_dev_detach(name);
 	if (ret < 0)
 		goto err;
-- 
2.9.4

  parent reply	other threads:[~2017-06-09 18:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26 16:11 [dpdk-dev] [PATCH 1/2] ethdev: ensure same name size for device and ethdev Ferruh Yigit
2017-05-26 16:11 ` [dpdk-dev] [PATCH 2/2] drivers/net: use device name from device structure Ferruh Yigit
2017-06-09 13:52   ` Thomas Monjalon
2017-06-09 14:16     ` Ferruh Yigit
2017-06-10  7:35     ` Jan Blunck
2017-06-12  8:57       ` Ferruh Yigit
2017-06-09 18:36 ` [dpdk-dev] [PATCH v2 1/3] ethdev: ensure same name size for device and ethdev Ferruh Yigit
2017-06-09 18:36   ` [dpdk-dev] [PATCH v2 2/3] drivers/net: use device name from device structure Ferruh Yigit
2017-06-09 18:36   ` Ferruh Yigit [this message]
2017-07-05 22:11     ` [dpdk-dev] [PATCH v2 3/3] ethdev: " Thomas Monjalon

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=20170609183606.34596-3-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=gaetan.rivet@6wind.com \
    --cc=jblunck@infradead.org \
    --cc=thomas@monjalon.net \
    /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).