ethdev: change link status get functions to return int
authorIgor Romanov <igor.romanov@oktetlabs.ru>
Tue, 10 Sep 2019 08:25:42 +0000 (09:25 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 7 Oct 2019 13:00:54 +0000 (15:00 +0200)
Change rte_eth_link_get() and rte_eth_link_get_nowait() return value
from void to int and return negative errno values in case of error
conditions.

Return value of link_update callback is ignored since the callback
returns not errors but whether link up status has changed or not.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
doc/guides/rel_notes/deprecation.rst
doc/guides/rel_notes/release_19_11.rst
doc/guides/sample_app_ug/link_status_intr.rst
drivers/net/bonding/rte_eth_bond_pmd.c
lib/librte_ethdev/rte_ethdev.c
lib/librte_ethdev/rte_ethdev.h

index beb9cc3..38a6e53 100644 (file)
@@ -89,7 +89,6 @@ Deprecation Notices
   invalid port ID, unsupported operation, failed operation):
 
   - ``rte_eth_allmulticast_enable`` and ``rte_eth_allmulticast_disable``
   invalid port ID, unsupported operation, failed operation):
 
   - ``rte_eth_allmulticast_enable`` and ``rte_eth_allmulticast_disable``
-  - ``rte_eth_link_get`` and ``rte_eth_link_get_nowait``
   - ``rte_eth_dev_stop``
   - ``rte_eth_dev_close``
   - ``rte_eth_macaddr_get``
   - ``rte_eth_dev_stop``
   - ``rte_eth_dev_close``
   - ``rte_eth_macaddr_get``
index 9d150b8..2c79210 100644 (file)
@@ -133,6 +133,10 @@ API Changes
 * ethdev: changed ``rte_eth_dev_xstats_reset`` return value from ``void`` to
   ``int`` to provide a way to report various error conditions.
 
 * ethdev: changed ``rte_eth_dev_xstats_reset`` return value from ``void`` to
   ``int`` to provide a way to report various error conditions.
 
+* ethdev: changed ``rte_eth_link_get`` and ``rte_eth_link_get_nowait``
+  return value from ``void`` to ``int`` to provide a way to report various
+  error conditions.
+
 
 ABI Changes
 -----------
 
 ABI Changes
 -----------
index cfb1bcd..5283be8 100644 (file)
@@ -164,6 +164,7 @@ An example callback function that has been written as indicated below.
     lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param)
     {
         struct rte_eth_link link;
     lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param)
     {
         struct rte_eth_link link;
+        int ret;
 
         RTE_SET_USED(param);
 
 
         RTE_SET_USED(param);
 
@@ -171,9 +172,11 @@ An example callback function that has been written as indicated below.
 
         printf("Event type: %s\n", type == RTE_ETH_EVENT_INTR_LSC ? "LSC interrupt" : "unknown event");
 
 
         printf("Event type: %s\n", type == RTE_ETH_EVENT_INTR_LSC ? "LSC interrupt" : "unknown event");
 
-        rte_eth_link_get_nowait(port_id, &link);
-
-        if (link.link_status) {
+        ret = rte_eth_link_get_nowait(port_id, &link);
+        if (ret < 0) {
+            printf("Failed to get port %d link status: %s\n\n",
+                   port_id, rte_strerror(-ret));
+        } else if (link.link_status) {
             printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed,
                   (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex"));
         } else
             printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed,
                   (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex"));
         } else
index 4c517e6..627d8de 100644 (file)
@@ -2358,7 +2358,7 @@ bond_ethdev_slave_link_status_change_monitor(void *cb_arg)
 static int
 bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete)
 {
 static int
 bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete)
 {
-       void (*link_update)(uint16_t port_id, struct rte_eth_link *eth_link);
+       int (*link_update)(uint16_t port_id, struct rte_eth_link *eth_link);
 
        struct bond_dev_private *bond_ctx;
        struct rte_eth_link slave_link;
 
        struct bond_dev_private *bond_ctx;
        struct rte_eth_link slave_link;
index cdd854c..2f5338c 100644 (file)
@@ -1984,40 +1984,44 @@ rte_eth_allmulticast_get(uint16_t port_id)
        return dev->data->all_multicast;
 }
 
        return dev->data->all_multicast;
 }
 
-void
+int
 rte_eth_link_get(uint16_t port_id, struct rte_eth_link *eth_link)
 {
        struct rte_eth_dev *dev;
 
 rte_eth_link_get(uint16_t port_id, struct rte_eth_link *eth_link)
 {
        struct rte_eth_dev *dev;
 
-       RTE_ETH_VALID_PORTID_OR_RET(port_id);
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        dev = &rte_eth_devices[port_id];
 
        if (dev->data->dev_conf.intr_conf.lsc &&
            dev->data->dev_started)
                rte_eth_linkstatus_get(dev, eth_link);
        else {
        dev = &rte_eth_devices[port_id];
 
        if (dev->data->dev_conf.intr_conf.lsc &&
            dev->data->dev_started)
                rte_eth_linkstatus_get(dev, eth_link);
        else {
-               RTE_FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
+               RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
                (*dev->dev_ops->link_update)(dev, 1);
                *eth_link = dev->data->dev_link;
        }
                (*dev->dev_ops->link_update)(dev, 1);
                *eth_link = dev->data->dev_link;
        }
+
+       return 0;
 }
 
 }
 
-void
+int
 rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)
 {
        struct rte_eth_dev *dev;
 
 rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)
 {
        struct rte_eth_dev *dev;
 
-       RTE_ETH_VALID_PORTID_OR_RET(port_id);
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        dev = &rte_eth_devices[port_id];
 
        if (dev->data->dev_conf.intr_conf.lsc &&
            dev->data->dev_started)
                rte_eth_linkstatus_get(dev, eth_link);
        else {
        dev = &rte_eth_devices[port_id];
 
        if (dev->data->dev_conf.intr_conf.lsc &&
            dev->data->dev_started)
                rte_eth_linkstatus_get(dev, eth_link);
        else {
-               RTE_FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
+               RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
                (*dev->dev_ops->link_update)(dev, 0);
                *eth_link = dev->data->dev_link;
        }
                (*dev->dev_ops->link_update)(dev, 0);
                *eth_link = dev->data->dev_link;
        }
+
+       return 0;
 }
 
 int
 }
 
 int
index 4ea8579..b55f012 100644 (file)
@@ -2093,8 +2093,12 @@ int rte_eth_allmulticast_get(uint16_t port_id);
  * @param link
  *   A pointer to an *rte_eth_link* structure to be filled with
  *   the status, the speed and the mode of the Ethernet device link.
  * @param link
  *   A pointer to an *rte_eth_link* structure to be filled with
  *   the status, the speed and the mode of the Ethernet device link.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if the function is not supported in PMD driver.
+ *   - (-ENODEV) if *port_id* invalid.
  */
  */
-void rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
+int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
 
 /**
  * Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX
 
 /**
  * Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX
@@ -2106,8 +2110,12 @@ void rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
  * @param link
  *   A pointer to an *rte_eth_link* structure to be filled with
  *   the status, the speed and the mode of the Ethernet device link.
  * @param link
  *   A pointer to an *rte_eth_link* structure to be filled with
  *   the status, the speed and the mode of the Ethernet device link.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if the function is not supported in PMD driver.
+ *   - (-ENODEV) if *port_id* invalid.
  */
  */
-void rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
+int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
 
 /**
  * Retrieve the general I/O statistics of an Ethernet device.
 
 /**
  * Retrieve the general I/O statistics of an Ethernet device.