Allow application to query whether link state will work.
This is also part of abstracting dependency on PCI.

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 lib/librte_ether/rte_ethdev.c          |   14 ++++++++++++++
 lib/librte_ether/rte_ethdev.h          |   12 ++++++++++++
 lib/librte_ether/rte_ether_version.map |    1 +
 3 files changed, 27 insertions(+)

--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1091,6 +1091,23 @@ rte_eth_dev_start(uint8_t port_id)
        return 0;
 }

+int
+rte_eth_has_link_state(uint8_t port_id)
+{
+       struct rte_eth_dev *dev;
+
+       if (!rte_eth_dev_is_valid_port(port_id)) {
+               RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+               return 0;
+       }
+       dev = &rte_eth_devices[port_id];
+
+       if (!dev->driver || !dev->pci_dev)
+               return 0;
+
+       return (dev->pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC) != 0;
+}
+
 void
 rte_eth_dev_stop(uint8_t port_id)
 {
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2149,6 +2149,18 @@ extern void rte_eth_link_get_nowait(uint
                                struct rte_eth_link *link);

 /**
+ * Test whether device supports link state interrupt mode.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @return
+ *   - (1) if link state interrupt is supported
+ *   - (0) if link state interrupt is not supported
+ */
+extern int
+rte_eth_has_link_state(uint8_t port_id);
+
+/**
  * Retrieve the general I/O statistics of an Ethernet device.
  *
  * @param port_id
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -83,6 +83,7 @@ DPDK_2.2 {
        rte_eth_dev_wd_timeout_store;
        rte_eth_dma_zone_reserve;
        rte_eth_driver_register;
+       rte_eth_has_link_state;
        rte_eth_led_off;
        rte_eth_led_on;
        rte_eth_link;

Reply via email to