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 v3 1/2] ethdev: define a function to get eth dev structure
Date: Mon, 31 Jan 2022 19:51:36 +0530	[thread overview]
Message-ID: <20220131142137.14260-1-kumaraparamesh92@gmail.com> (raw)
In-Reply-To: <20220121042944.23929-1-kumaraparamesh92@gmail.com>

From: Kumara Parameshwaran <kparameshwar@vmware.com>

The PMDs would need a function to access the rte_eth_devices
global array

Cc:stable@dpdk.org

Signed-off-by: Kumara Parameshwaran <kparameshwar@vmware.com>
---
 lib/ethdev/ethdev_driver.h | 18 ++++++++++++++++++
 lib/ethdev/rte_ethdev.c    | 11 +++++++++++
 lib/ethdev/version.map     |  1 +
 3 files changed, 30 insertions(+)

diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index d95605a355..7d27781f7d 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -1629,6 +1629,24 @@ rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue,
 				struct rte_hairpin_peer_info *peer_info,
 				uint32_t direction);
 
+/**
+ * @internal
+ * Get rte_eth_dev from device name. The device name should be specified
+ * as below:
+ * - PCIe address (Domain:Bus:Device.Function), for example- 0000:2:00.0
+ * - SoC device name, for example- fsl-gmac0
+ * - vdev dpdk name, for example- net_[pcap0|null0|tap0]
+ *
+ * @param name
+ *  pci address or name of the device
+ * @return
+ *   - rte_eth_dev if successful
+ *   - NULL on failure
+ */
+__rte_internal
+struct rte_eth_dev*
+rte_eth_dev_get_by_name(const char *name);
+
 /**
  * @internal
  * Reset the current queue state and configuration to disconnect (unbind) it
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index a1d475a292..968475d107 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -894,6 +894,17 @@ rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id)
 	return -ENODEV;
 }
 
+struct rte_eth_dev *
+rte_eth_dev_get_by_name(const char *name)
+{
+	uint16_t pid;
+
+	if (rte_eth_dev_get_port_by_name(name, &pid))
+		return NULL;
+
+	return &rte_eth_devices[pid];
+}
+
 static int
 eth_err(uint16_t port_id, int ret)
 {
diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
index c2fb0669a4..1f7359c846 100644
--- a/lib/ethdev/version.map
+++ b/lib/ethdev/version.map
@@ -267,6 +267,7 @@ INTERNAL {
 	rte_eth_dev_callback_process;
 	rte_eth_dev_create;
 	rte_eth_dev_destroy;
+	rte_eth_dev_get_by_name;
 	rte_eth_dev_is_rx_hairpin_queue;
 	rte_eth_dev_is_tx_hairpin_queue;
 	rte_eth_dev_probing_finish;
-- 
2.17.1


  parent reply	other threads:[~2022-01-31 14:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-21  4:29 [PATCH] net/tap: Bug fix to populate fds in secondary process Kumara Parameshwaran
2022-01-24  9:47 ` Ferruh Yigit
2022-01-24 12:12 ` [PATCH v2] net/tap: " Kumara Parameshwaran
2022-01-24 12:35   ` Ferruh Yigit
2022-01-24 12:48     ` Kumara Parameshwaran
2022-01-24 12:54     ` kumaraparameshwaran rathinavel
2022-01-24 13:05       ` Ferruh Yigit
2022-01-28  9:55     ` kumaraparameshwaran rathinavel
2022-01-28 12:55       ` Ferruh Yigit
2022-01-24 12:37 ` Kumara Parameshwaran
2022-01-24 13:06   ` Ferruh Yigit
2022-01-31 14:21 ` Kumara Parameshwaran [this message]
2022-01-31 14:21   ` [PATCH v3 2/2] " Kumara Parameshwaran
2022-01-31 14:32 ` [PATCH v3 1/2] ethdev: define a function to get eth dev structure Kumara Parameshwaran
2022-01-31 14:32   ` [PATCH v3 2/2] net/tap: fix to populate fds in secondary process Kumara Parameshwaran
2022-02-01 16:57     ` Ferruh Yigit
2022-02-01 16:56   ` [PATCH v3 1/2] ethdev: define a function to get eth dev structure Ferruh Yigit
2022-02-01 17:12     ` Ferruh Yigit
2022-02-01 17:15     ` 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=20220131142137.14260-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).