[dpdk-dev,1/2] ethdev: make rte_eth_dev_is_valid_port public
Commit Message
From: Stephen Hemminger <shemming@brocade.com>
The function rte_eth_dev_is_valid_port is good way to have all
drivers using same function and solves several hotplug related
bugs from drivers not checking attached flag.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_ether/rte_ethdev.c | 2 +-
lib/librte_ether/rte_ethdev.h | 11 +++++++++++
lib/librte_ether/rte_ether_version.map | 1 +
3 files changed, 13 insertions(+), 1 deletion(-)
Comments
On Wed, Jun 10, 2015 at 03:06:24PM -0700, Stephen Hemminger wrote:
> From: Stephen Hemminger <shemming@brocade.com>
>
> The function rte_eth_dev_is_valid_port is good way to have all
> drivers using same function and solves several hotplug related
> bugs from drivers not checking attached flag.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Just yesterday I was working on a patch to do the same thing!
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
@@ -401,7 +401,7 @@ rte_eth_driver_register(struct eth_driver *eth_drv)
rte_eal_pci_register(ð_drv->pci_drv);
}
-static int
+int
rte_eth_dev_is_valid_port(uint8_t port_id)
{
if (port_id >= RTE_MAX_ETHPORTS ||
@@ -1853,6 +1853,17 @@ extern int rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
extern int rte_eth_dev_socket_id(uint8_t port_id);
/*
+ * Check if port_id of device is attached
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device
+ * @return
+ * 0 if port is out of range or not attached
+ * 1 if device is attached
+ */
+extern int rte_eth_dev_is_valid_port(uint8_t port_id);
+
+/*
* Allocate mbuf from mempool, setup the DMA physical address
* and then start RX for specified queue of a port. It is used
* when rx_deferred_start flag of the specified queue is true.
@@ -63,6 +63,7 @@ DPDK_2.0 {
rte_eth_dev_set_vlan_offload;
rte_eth_dev_set_vlan_pvid;
rte_eth_dev_set_vlan_strip_on_queue;
+ rte_eth_dev_is_valid_port;
rte_eth_dev_socket_id;
rte_eth_dev_start;
rte_eth_dev_stop;