[dpdk-dev,RFC,v2,09/28] ethdev: Add rte_eth_dev_get_port_by_addr
Commit Message
The function returns a port identifier of a ethdev specified by pci
address.
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
lib/librte_ether/rte_ethdev.c | 13 +++++++++++++
lib/librte_ether/rte_ethdev.h | 13 +++++++++++++
2 files changed, 26 insertions(+)
@@ -421,6 +421,19 @@ rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)
return 0;
}
+int
+rte_eth_dev_get_port_by_addr(struct rte_pci_addr *addr, uint8_t *port_id)
+{
+ struct rte_pci_addr *tmp;
+
+ for (*port_id = 0; *port_id < RTE_MAX_ETHPORTS; (*port_id)++) {
+ tmp = &rte_eth_devices[*port_id].pci_dev->addr;
+ if (eal_compare_pci_addr(tmp, addr))
+ return 0;
+ }
+ return -1;
+}
+
static int
rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
{
@@ -1652,6 +1652,19 @@ extern int rte_eth_dev_get_addr_by_port(
uint8_t port_id, struct rte_pci_addr *addr);
/**
+ * Function for internal use by port hotplug functions.
+ * Returns a port identifier of a ethdev specified by pci address.
+ * @param addr
+ * The pointer to the pci address of the Ethernet device.
+ * @param port_id
+ * The pointer to the port identifier
+ * @return
+ * - 0 on success, negative on error
+ */
+extern int rte_eth_dev_get_port_by_addr(
+ struct rte_pci_addr *addr, uint8_t *port_id);
+
+/**
* Function for internal use by dummy drivers primarily, e.g. ring-based
* driver.
* Allocates a new ethdev slot for an ethernet device and returns the pointer