Skip to content

Commit

Permalink
ethdev: add internal function to device struct from name
Browse files Browse the repository at this point in the history
[ upstream commit 961fb40 ]

The PMDs would need a function to access the rte_eth_devices
without accessing the global rte_eth_device array.

Signed-off-by: Kumara Parameshwaran <kparameshwar@vmware.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  • Loading branch information
param1992 authored and bluca committed Feb 17, 2022
1 parent b040eaa commit eea12b2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/librte_ethdev/rte_ethdev.c
Expand Up @@ -839,6 +839,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)
{
Expand Down
18 changes: 18 additions & 0 deletions lib/librte_ethdev/rte_ethdev_driver.h
Expand Up @@ -1326,6 +1326,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
Expand Down
1 change: 1 addition & 0 deletions lib/librte_ethdev/version.map
Expand Up @@ -251,6 +251,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;
Expand Down

0 comments on commit eea12b2

Please sign in to comment.