]> git.droids-corp.org - dpdk.git/commitdiff
ethdev: allow stop function to return an error
authorIvan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Thu, 15 Oct 2020 13:30:35 +0000 (14:30 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 16 Oct 2020 20:26:41 +0000 (22:26 +0200)
Change rte_eth_dev_stop() return value from void to int
and return negative errno values in case of error conditions.
Also update the usage of the function in ethdev according to
the new return type.

Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
doc/guides/rel_notes/deprecation.rst
doc/guides/rel_notes/release_20_11.rst
lib/librte_ethdev/rte_ethdev.c
lib/librte_ethdev/rte_ethdev.h

index b5582491ff1459bbe6debc13eaad621b4f31df92..de0f3277bba3a55e5b0897eac58028c04d01c489 100644 (file)
@@ -123,12 +123,6 @@ Deprecation Notices
   ``rte_eth_dev_l2_tunnel_offload_set`` which were not marked as deprecated,
   will be removed in DPDK 20.11.
 
-* ethdev: Update API functions returning ``void`` to return ``int`` with
-  negative errno values to indicate various error conditions (e.g.
-  invalid port ID, unsupported operation, failed operation):
-
-  - ``rte_eth_dev_stop``
-
 * ethdev: New offload flags ``DEV_RX_OFFLOAD_FLOW_MARK`` will be added in 19.11.
   This will allow application to enable or disable PMDs from updating
   ``rte_mbuf::hash::fdir``.
index 5f1ef125baafb6a84310996756c8c0d6ea7e4de0..c1c2b0d2b1c41bc1f969e188df20cf9dd7c890d1 100644 (file)
@@ -422,6 +422,9 @@ API Changes
 
 * ethdev: Added capability to query age flow action.
 
+* ethdev: Changed ``rte_eth_dev_stop`` return value from ``void`` to
+  ``int`` to provide a way to report various error conditions.
+
 * ethdev: Added ``int`` return type to ``rte_eth_dev_close()``.
 
 * ethdev: Renamed internal functions:
index 9e838be8bc1bbc8fd3484fdc02fb412b779f959d..9e1167169fca307b8ade92765aace55e41113d5b 100644 (file)
@@ -1677,7 +1677,7 @@ rte_eth_dev_start(uint16_t port_id)
        struct rte_eth_dev *dev;
        struct rte_eth_dev_info dev_info;
        int diag;
-       int ret;
+       int ret, ret_stop;
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
@@ -1711,7 +1711,13 @@ rte_eth_dev_start(uint16_t port_id)
                RTE_ETHDEV_LOG(ERR,
                        "Error during restoring configuration for device (port %u): %s\n",
                        port_id, rte_strerror(-ret));
-               rte_eth_dev_stop(port_id);
+               ret_stop = rte_eth_dev_stop(port_id);
+               if (ret_stop != 0) {
+                       RTE_ETHDEV_LOG(ERR,
+                               "Failed to stop device (port %u): %s\n",
+                               port_id, rte_strerror(-ret_stop));
+               }
+
                return ret;
        }
 
@@ -1724,26 +1730,28 @@ rte_eth_dev_start(uint16_t port_id)
        return 0;
 }
 
-void
+int
 rte_eth_dev_stop(uint16_t port_id)
 {
        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];
 
-       RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop);
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_stop, -ENOTSUP);
 
        if (dev->data->dev_started == 0) {
                RTE_ETHDEV_LOG(INFO,
                        "Device with port_id=%"PRIu16" already stopped\n",
                        port_id);
-               return;
+               return 0;
        }
 
        dev->data->dev_started = 0;
        (*dev->dev_ops->dev_stop)(dev);
        rte_ethdev_trace_stop(port_id);
+
+       return 0;
 }
 
 int
@@ -1804,7 +1812,12 @@ rte_eth_dev_reset(uint16_t port_id)
 
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_reset, -ENOTSUP);
 
-       rte_eth_dev_stop(port_id);
+       ret = rte_eth_dev_stop(port_id);
+       if (ret != 0) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Failed to stop device (port %u) before reset: %s - ignore\n",
+                       port_id, rte_strerror(-ret));
+       }
        ret = dev->dev_ops->dev_reset(dev);
 
        return eth_err(port_id, ret);
index f4c06243088de71acb7bced51157f90a750ae843..77f9df7e5af1d5f004d8be49dad1bfeb40d801ac 100644 (file)
@@ -2479,8 +2479,11 @@ int rte_eth_dev_start(uint16_t port_id);
  *
  * @param port_id
  *   The port identifier of the Ethernet device.
+ * @return
+ *   - 0: Success, Ethernet device stopped.
+ *   - <0: Error code of the driver device stop function.
  */
-void rte_eth_dev_stop(uint16_t port_id);
+int rte_eth_dev_stop(uint16_t port_id);
 
 /**
  * Link up an Ethernet device.