summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <shemming@brocade.com>2015-06-10 15:06:24 -0700
committerThomas Monjalon <thomas.monjalon@6wind.com>2015-07-20 02:47:38 +0200
commit393775d5c0d35fb74e139c0b4ec9cc2304b70581 (patch)
treee02762d20a145aba95ddcdf5dae4406167e5df7f
parenta20d5f06e2e19d3622620d838006ea4eaaa594fb (diff)
downloaddpdk-393775d5c0d35fb74e139c0b4ec9cc2304b70581.zip
dpdk-393775d5c0d35fb74e139c0b4ec9cc2304b70581.tar.gz
dpdk-393775d5c0d35fb74e139c0b4ec9cc2304b70581.tar.xz
ethdev: export function to check port validity
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> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
-rw-r--r--lib/librte_ether/rte_ethdev.c2
-rw-r--r--lib/librte_ether/rte_ethdev.h11
-rw-r--r--lib/librte_ether/rte_ether_version.map1
3 files changed, 13 insertions, 1 deletions
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 748e2be..94104ce 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -409,7 +409,7 @@ rte_eth_driver_register(struct eth_driver *eth_drv)
rte_eal_pci_register(&eth_drv->pci_drv);
}
-static int
+int
rte_eth_dev_is_valid_port(uint8_t port_id)
{
if (port_id >= RTE_MAX_ETHPORTS ||
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 8b04edc..c901a2c 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1930,6 +1930,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.
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index b7e4d56..23cfee9 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -114,6 +114,7 @@ DPDK_2.1 {
rte_eth_dev_get_eeprom_length;
rte_eth_dev_get_reg_info;
rte_eth_dev_get_reg_length;
+ rte_eth_dev_is_valid_port;
rte_eth_dev_set_eeprom;
rte_eth_dev_set_mc_addr_list;
rte_eth_timesync_disable;