From 4b0db43df31753c12f4f6fad5154861e0ac4eebb Mon Sep 17 00:00:00 2001 From: Ivan Ilchenko Date: Tue, 24 Sep 2019 13:56:07 +0100 Subject: [PATCH] ethdev: change allmulticast mode API to return errors Change rte_eth_allmulticast_enable()/rte_eth_allmulticast_disable() return value from void to int and return negative errno values in case of error conditions. Modify usage of these functions across the ethdev according to new return type. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko --- doc/guides/rel_notes/deprecation.rst | 1 - doc/guides/rel_notes/release_19_11.rst | 4 +++ lib/librte_ethdev/rte_ethdev.c | 37 +++++++++++++++++++------- lib/librte_ethdev/rte_ethdev.h | 14 ++++++++-- 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 8f9cd2ad1f..237813b647 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -88,7 +88,6 @@ Deprecation Notices negative errno values to indicate various error conditions (e.g. invalid port ID, unsupported operation, failed operation): - - ``rte_eth_allmulticast_enable`` and ``rte_eth_allmulticast_disable`` - ``rte_eth_dev_stop`` - ``rte_eth_dev_close`` diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst index 458601ef98..da326e1c82 100644 --- a/doc/guides/rel_notes/release_19_11.rst +++ b/doc/guides/rel_notes/release_19_11.rst @@ -130,6 +130,10 @@ API Changes ``rte_eth_promiscuous_disable`` return value from ``void`` to ``int`` to provide a way to report various error conditions. +* ethdev: changed ``rte_eth_allmulticast_enable`` and + ``rte_eth_allmulticast_disable`` 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. diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 2f65143e24..df7e9916f7 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1422,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; } @@ -1951,30 +1964,34 @@ 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; - 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); + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->allmulticast_enable, -ENOTSUP); (*dev->dev_ops->allmulticast_enable)(dev); dev->data->all_multicast = 1; + + return 0; } -void +int rte_eth_allmulticast_disable(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->allmulticast_disable); + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->allmulticast_disable, -ENOTSUP); dev->data->all_multicast = 0; (*dev->dev_ops->allmulticast_disable)(dev); + + return 0; } int diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 1bc7e08dce..d937fb4293 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -2062,16 +2062,26 @@ int rte_eth_promiscuous_get(uint16_t port_id); * * @param port_id * The port identifier of the Ethernet device. + * @return + * - (0) if successful. + * - (-ENOTSUP) if support for allmulticast_enable() does not exist + * for the device. + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_allmulticast_enable(uint16_t port_id); +int rte_eth_allmulticast_enable(uint16_t port_id); /** * Disable the receipt of all multicast frames by an Ethernet device. * * @param port_id * The port identifier of the Ethernet device. + * @return + * - (0) if successful. + * - (-ENOTSUP) if support for allmulticast_disable() does not exist + * for the device. + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_allmulticast_disable(uint16_t port_id); +int rte_eth_allmulticast_disable(uint16_t port_id); /** * Return the value of allmulticast mode for an Ethernet device. -- 2.20.1