dpdk: add device name querying function

pull/8965/head
Lukas Sismis 2 years ago committed by Victor Julien
parent 2feece601a
commit bb2760d221

@ -57,3 +57,23 @@ void DPDKCloseDevice(LiveDevice *ldev)
}
#endif
}
#ifdef HAVE_DPDK
/**
* Retrieves name of the port from port id
* Not thread-safe
* @param pid
* @return static dev_name on success
*/
const char *DPDKGetPortNameByPortID(uint16_t pid)
{
static char dev_name[RTE_ETH_NAME_MAX_LEN];
int32_t ret = rte_eth_dev_get_name_by_port(pid, dev_name);
if (ret < 0) {
FatalError("Port %d: Failed to obtain port name (err: %s)", pid, rte_strerror(-ret));
}
return dev_name;
}
#endif /* HAVE_DPDK */

@ -118,4 +118,8 @@ void DPDKCleanupEAL(void);
void DPDKCloseDevice(LiveDevice *ldev);
#ifdef HAVE_DPDK
const char *DPDKGetPortNameByPortID(uint16_t pid);
#endif /* HAVE_DPDK */
#endif /* UTIL_DPDK_H */

Loading…
Cancel
Save