DPDK patches and discussions
 help / color / mirror / Atom feed
From: Kumara Parameshwaran <kumaraparamesh92@gmail.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, Kumara Parameshwaran <kparameshwar@vmware.com>
Subject: [PATCH v1] drivers/net: use internal API to get eth dev from name
Date: Thu,  3 Feb 2022 13:54:12 +0530	[thread overview]
Message-ID: <20220203082412.79028-1-kumaraparamesh92@gmail.com> (raw)

From: Kumara Parameshwaran <kparameshwar@vmware.com>

Make changes in PMDs to use the new function where
rte_eth_dev_get_port_by_name is used to get port_id
to access rte_eth_devices

Signed-off-by: Kumara Parameshwaran <kparameshwar@vmware.com>
---
v1
* Replace rte_eth_get_get_port_by_name in PMDs with rte_eth_dev_get_by_name
  where port_id is used to retrieve rte_eth_dev data structure

 drivers/net/bonding/rte_eth_bond_api.c       | 10 +++++-----
 drivers/net/ipn3ke/ipn3ke_ethdev.c           |  9 +++------
 drivers/net/memif/rte_eth_memif.c            |  7 ++-----
 drivers/net/softnic/rte_eth_softnic_thread.c |  8 +++-----
 drivers/net/tap/rte_eth_tap.c                |  7 ++-----
 5 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 8840d9e17b..b78867b125 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -151,8 +151,8 @@ int
 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 {
 	struct bond_dev_private *internals;
+	struct rte_eth_dev *bond_dev;
 	char devargs[52];
-	uint16_t port_id;
 	int ret;
 
 	if (name == NULL) {
@@ -169,8 +169,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	if (ret)
 		return ret;
 
-	ret = rte_eth_dev_get_port_by_name(name, &port_id);
-	RTE_ASSERT(!ret);
+	bond_dev = rte_eth_dev_get_by_name(name);
+	RTE_ASSERT(bond_dev);
 
 	/*
 	 * To make bond_ethdev_configure() happy we need to free the
@@ -178,11 +178,11 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	 *
 	 * Also see comment in bond_ethdev_configure().
 	 */
-	internals = rte_eth_devices[port_id].data->dev_private;
+	internals = bond_dev->data->dev_private;
 	rte_kvargs_free(internals->kvlist);
 	internals->kvlist = NULL;
 
-	return port_id;
+	return bond_dev->data->port_id;
 }
 
 int
diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
index 014e438dd5..550a8b0466 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
@@ -469,7 +469,6 @@ static int ipn3ke_vswitch_probe(struct rte_afu_device *afu_dev)
 	struct ipn3ke_hw *hw;
 	struct rte_eth_dev *i40e_eth;
 	struct ifpga_rawdev *ifpga_dev;
-	uint16_t port_id;
 	int i, j, retval;
 	char *fvl_bdf;
 
@@ -519,14 +518,12 @@ static int ipn3ke_vswitch_probe(struct rte_afu_device *afu_dev)
 
 		for (; j < 8; j++) {
 			fvl_bdf = ifpga_dev->fvl_bdf[j];
-			retval = rte_eth_dev_get_port_by_name(fvl_bdf,
-				&port_id);
-			if (retval) {
+			i40e_eth = rte_eth_dev_get_by_name(fvl_bdf);
+			if (!i40e_eth) {
 				continue;
 			} else {
-				i40e_eth = &rte_eth_devices[port_id];
 				rpst.i40e_pf_eth = i40e_eth;
-				rpst.i40e_pf_eth_port_id = port_id;
+				rpst.i40e_pf_eth_port_id = i40e_eth->data->port_id;
 
 				j++;
 				break;
diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index d3459c5007..5700c6a2bf 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -88,17 +88,14 @@ memif_mp_send_region(const struct rte_mp_msg *msg, const void *peer)
 	const struct mp_region_msg *msg_param = (const struct mp_region_msg *)msg->param;
 	struct rte_mp_msg reply;
 	struct mp_region_msg *reply_param = (struct mp_region_msg *)reply.param;
-	uint16_t port_id;
-	int ret;
 
 	/* Get requested port */
-	ret = rte_eth_dev_get_port_by_name(msg_param->port_name, &port_id);
-	if (ret) {
+	dev = rte_eth_dev_get_by_name(msg_param->port_name);
+	if (!dev) {
 		MIF_LOG(ERR, "Failed to get port id for %s",
 			msg_param->port_name);
 		return -1;
 	}
-	dev = &rte_eth_devices[port_id];
 	proc_private = dev->process_private;
 
 	memset(&reply, 0, sizeof(reply));
diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c
index a8c26a5b23..4a9f2fa6a4 100644
--- a/drivers/net/softnic/rte_eth_softnic_thread.c
+++ b/drivers/net/softnic/rte_eth_softnic_thread.c
@@ -129,14 +129,12 @@ thread_sc_service_up(struct pmd_internals *softnic, uint32_t thread_id)
 	struct softnic_thread *t = &softnic->thread[thread_id];
 	struct rte_eth_dev *dev;
 	int status;
-	uint16_t port_id;
 
 	/* service params */
-	status = rte_eth_dev_get_port_by_name(softnic->params.name, &port_id);
-	if (status)
-		return status;
+	dev = rte_eth_dev_get_by_name(softnic->params.name);
+	if (!dev)
+		return -EINVAL;
 
-	dev = &rte_eth_devices[port_id];
 	snprintf(service_params.name, sizeof(service_params.name), "%s_%u",
 		softnic->params.name,
 		thread_id);
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 111037de65..bc3d56a311 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -2428,19 +2428,16 @@ tap_mp_sync_queues(const struct rte_mp_msg *request, const void *peer)
 		(const struct ipc_queues *)request->param;
 	struct ipc_queues *reply_param =
 		(struct ipc_queues *)reply.param;
-	uint16_t port_id;
 	int queue;
-	int ret;
 
 	/* Get requested port */
 	TAP_LOG(DEBUG, "Received IPC request for %s", request_param->port_name);
-	ret = rte_eth_dev_get_port_by_name(request_param->port_name, &port_id);
-	if (ret) {
+	dev = rte_eth_dev_get_by_name(request_param->port_name);
+	if (!dev) {
 		TAP_LOG(ERR, "Failed to get port id for %s",
 			request_param->port_name);
 		return -1;
 	}
-	dev = &rte_eth_devices[port_id];
 	process_private = dev->process_private;
 
 	/* Fill file descriptors for all queues */
-- 
2.17.1


             reply	other threads:[~2022-02-03  8:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03  8:24 Kumara Parameshwaran [this message]
2022-02-03 11:09 ` kumaraparameshwaran rathinavel
2022-02-03 11:31   ` Ferruh Yigit
2022-02-07 16:08     ` Ali Alnubani
2022-02-07 16:36       ` Ferruh Yigit
2022-02-07 16:47         ` Ali Alnubani
2022-02-07 17:25           ` Ferruh Yigit
2022-02-07 19:58             ` Owen Hilyard
2022-02-10 20:44               ` Yigit, Ferruh
2022-02-10 22:06                 ` Owen Hilyard
2022-02-03 12:31 ` Ferruh Yigit
2022-02-04 13:46   ` Ferruh Yigit
2022-02-03 12:34 ` Ferruh Yigit
2022-02-03 12:35 ` Ferruh Yigit
2022-02-04  9:51   ` Singh, Jasvinder

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=20220203082412.79028-1-kumaraparamesh92@gmail.com \
    --to=kumaraparamesh92@gmail.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=kparameshwar@vmware.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).