ethdev: change allmulticast callbacks to return status
[dpdk.git] / lib / librte_ethdev / rte_ethdev.c
index 56875bb..5cb651e 100644 (file)
@@ -687,10 +687,11 @@ rte_eth_dev_owner_unset(const uint16_t port_id, const uint64_t owner_id)
        return ret;
 }
 
-void
+int
 rte_eth_dev_owner_delete(const uint64_t owner_id)
 {
        uint16_t port_id;
+       int ret = 0;
 
        rte_eth_dev_shared_data_prepare();
 
@@ -708,9 +709,12 @@ rte_eth_dev_owner_delete(const uint64_t owner_id)
                RTE_ETHDEV_LOG(ERR,
                               "Invalid owner id=%016"PRIx64"\n",
                               owner_id);
+               ret = -EINVAL;
        }
 
        rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
+
+       return ret;
 }
 
 int
@@ -1418,10 +1422,23 @@ rte_eth_dev_config_restore(struct rte_eth_dev *dev,
        }
 
        /* replay all multicast configuration */
-       if (rte_eth_allmulticast_get(port_id) == 1)
-               rte_eth_allmulticast_enable(port_id);
-       else if (rte_eth_allmulticast_get(port_id) == 0)
-               rte_eth_allmulticast_disable(port_id);
+       if (rte_eth_allmulticast_get(port_id) == 1) {
+               ret = rte_eth_allmulticast_enable(port_id);
+               if (ret != 0 && ret != -ENOTSUP) {
+                       RTE_ETHDEV_LOG(ERR,
+                               "Failed to enable allmulticast mode for device (port %u): %s\n",
+                               port_id, rte_strerror(-ret));
+                       return ret;
+               }
+       } else if (rte_eth_allmulticast_get(port_id) == 0) {
+               ret = rte_eth_allmulticast_disable(port_id);
+               if (ret != 0 && ret != -ENOTSUP) {
+                       RTE_ETHDEV_LOG(ERR,
+                               "Failed to disable allmulticast mode for device (port %u): %s\n",
+                               port_id, rte_strerror(-ret));
+                       return ret;
+               }
+       }
 
        return 0;
 }
@@ -1947,30 +1964,42 @@ rte_eth_promiscuous_get(uint16_t port_id)
        return dev->data->promiscuous;
 }
 
-void
+int
 rte_eth_allmulticast_enable(uint16_t port_id)
 {
        struct rte_eth_dev *dev;
+       uint8_t old_allmulticast;
+       int diag;
 
-       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->allmulticast_enable);
-       (*dev->dev_ops->allmulticast_enable)(dev);
-       dev->data->all_multicast = 1;
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->allmulticast_enable, -ENOTSUP);
+       old_allmulticast = dev->data->all_multicast;
+       diag = (*dev->dev_ops->allmulticast_enable)(dev);
+       dev->data->all_multicast = (diag == 0) ? 1 : old_allmulticast;
+
+       return eth_err(port_id, diag);
 }
 
-void
+int
 rte_eth_allmulticast_disable(uint16_t port_id)
 {
        struct rte_eth_dev *dev;
+       uint8_t old_allmulticast;
+       int diag;
 
-       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->allmulticast_disable);
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->allmulticast_disable, -ENOTSUP);
+       old_allmulticast = dev->data->all_multicast;
        dev->data->all_multicast = 0;
-       (*dev->dev_ops->allmulticast_disable)(dev);
+       diag = (*dev->dev_ops->allmulticast_disable)(dev);
+       if (diag != 0)
+               dev->data->all_multicast = old_allmulticast;
+
+       return eth_err(port_id, diag);
 }
 
 int