net/failsafe: check code of allmulticast mode switch
authorIvan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Tue, 24 Sep 2019 12:56:08 +0000 (13:56 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 7 Oct 2019 13:00:55 +0000 (15:00 +0200)
rte_eth_allmulticast_enable()/rte_eth_allmulticast_disable() return
value was changed from void to int, so this patch modify usage
of these functions across net/failsafe according to new return type.

Try to keep all-multicast mode consistent across all active
devices in the case of failure.

Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com>
drivers/net/failsafe/failsafe_ether.c
drivers/net/failsafe/failsafe_ops.c

index bd38f1c..93deacd 100644 (file)
@@ -140,9 +140,13 @@ fs_eth_dev_conf_apply(struct rte_eth_dev *dev,
        if (dev->data->all_multicast != edev->data->all_multicast) {
                DEBUG("Configuring all_multicast");
                if (dev->data->all_multicast)
-                       rte_eth_allmulticast_enable(PORT_ID(sdev));
+                       ret = rte_eth_allmulticast_enable(PORT_ID(sdev));
                else
-                       rte_eth_allmulticast_disable(PORT_ID(sdev));
+                       ret = rte_eth_allmulticast_disable(PORT_ID(sdev));
+               if (ret != 0) {
+                       ERROR("Failed to apply allmulticast mode");
+                       return ret;
+               }
        } else {
                DEBUG("all_multicast already set");
        }
index 91aa56c..b382661 100644 (file)
@@ -723,10 +723,28 @@ fs_allmulticast_enable(struct rte_eth_dev *dev)
 {
        struct sub_device *sdev;
        uint8_t i;
+       int ret = 0;
 
        fs_lock(dev, 0);
-       FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
-               rte_eth_allmulticast_enable(PORT_ID(sdev));
+       FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
+               ret = rte_eth_allmulticast_enable(PORT_ID(sdev));
+               ret = fs_err(sdev, ret);
+               if (ret != 0) {
+                       ERROR("All-multicast mode enable failed for subdevice %d",
+                               PORT_ID(sdev));
+                       break;
+               }
+       }
+       if (ret != 0) {
+               /* Rollback in the case of failure */
+               FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
+                       ret = rte_eth_allmulticast_disable(PORT_ID(sdev));
+                       ret = fs_err(sdev, ret);
+                       if (ret != 0)
+                               ERROR("All-multicast mode disable during rollback failed for subdevice %d",
+                                       PORT_ID(sdev));
+               }
+       }
        fs_unlock(dev, 0);
 }
 
@@ -735,10 +753,28 @@ fs_allmulticast_disable(struct rte_eth_dev *dev)
 {
        struct sub_device *sdev;
        uint8_t i;
+       int ret = 0;
 
        fs_lock(dev, 0);
-       FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
-               rte_eth_allmulticast_disable(PORT_ID(sdev));
+       FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
+               ret = rte_eth_allmulticast_disable(PORT_ID(sdev));
+               ret = fs_err(sdev, ret);
+               if (ret != 0) {
+                       ERROR("All-multicast mode disable failed for subdevice %d",
+                               PORT_ID(sdev));
+                       break;
+               }
+       }
+       if (ret != 0) {
+               /* Rollback in the case of failure */
+               FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
+                       ret = rte_eth_allmulticast_enable(PORT_ID(sdev));
+                       ret = fs_err(sdev, ret);
+                       if (ret != 0)
+                               ERROR("All-multicast mode enable during rollback failed for subdevice %d",
+                                       PORT_ID(sdev));
+               }
+       }
        fs_unlock(dev, 0);
 }