From: Andrew Rybchenko <arybchenko@solarflare.com> To: Neil Horman <nhorman@tuxdriver.com>, John McNamara <john.mcnamara@intel.com>, Marko Kovacevic <marko.kovacevic@intel.com>, Bernard Iremonger <bernard.iremonger@intel.com>, Ori Kam <orika@mellanox.com>, Bruce Richardson <bruce.richardson@intel.com>, "Pablo de Lara" <pablo.de.lara.guarch@intel.com>, Radu Nicolau <radu.nicolau@intel.com>, Akhil Goyal <akhil.goyal@nxp.com>, Tomasz Kantecki <tomasz.kantecki@intel.com>, Harry van Haaren <harry.van.haaren@intel.com>, Xiaoyun Li <xiaoyun.li@intel.com>, Thomas Monjalon <thomas@monjalon.net>, Ferruh Yigit <ferruh.yigit@intel.com> Cc: <dev@dpdk.org>, Ivan Ilchenko <Ivan.Ilchenko@oktetlabs.ru> Subject: [dpdk-dev] [PATCH 01/13] ethdev: change promiscuous mode controllers to return errors Date: Thu, 5 Sep 2019 17:10:39 +0100 Message-ID: <1567699852-31693-2-git-send-email-arybchenko@solarflare.com> (raw) In-Reply-To: <1567699852-31693-1-git-send-email-arybchenko@solarflare.com> From: Ivan Ilchenko <Ivan.Ilchenko@oktetlabs.ru> Change rte_eth_promiscuous_enable()/rte_eth_promiscuous_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 <Ivan.Ilchenko@oktetlabs.ru> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com> --- doc/guides/rel_notes/deprecation.rst | 1 - doc/guides/rel_notes/release_19_11.rst | 4 ++ doc/guides/sample_app_ug/flow_classify.rst | 6 ++- doc/guides/sample_app_ug/flow_filtering.rst | 15 +++++- doc/guides/sample_app_ug/rxtx_callbacks.rst | 5 +- doc/guides/sample_app_ug/skeleton.rst | 6 ++- lib/librte_ethdev/rte_ethdev.c | 52 ++++++++++++++++----- lib/librte_ethdev/rte_ethdev.h | 14 +++++- 8 files changed, 80 insertions(+), 23 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index cbb4c34efd..b2e0a1fc7c 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_promiscuous_enable`` and ``rte_eth_promiscuous_disable`` - ``rte_eth_allmulticast_enable`` and ``rte_eth_allmulticast_disable`` - ``rte_eth_link_get`` and ``rte_eth_link_get_nowait`` - ``rte_eth_dev_stop`` diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst index 152f120197..5299157df7 100644 --- a/doc/guides/rel_notes/release_19_11.rst +++ b/doc/guides/rel_notes/release_19_11.rst @@ -97,6 +97,10 @@ API Changes * ethdev: changed ``rte_eth_dev_infos_get`` return value from ``void`` to ``int`` to provide a way to report various error conditions. +* ethdev: changed ``rte_eth_promiscuous_enable`` and + ``rte_eth_promiscuous_disable`` return value from ``void`` to ``int`` to + provide a way to report various error conditions. + ABI Changes ----------- diff --git a/doc/guides/sample_app_ug/flow_classify.rst b/doc/guides/sample_app_ug/flow_classify.rst index 96a5c66d0f..7c2b6dcf83 100644 --- a/doc/guides/sample_app_ug/flow_classify.rst +++ b/doc/guides/sample_app_ug/flow_classify.rst @@ -315,7 +315,9 @@ Forwarding application is shown below: addr.addr_bytes[4], addr.addr_bytes[5]); /* Enable RX in promiscuous mode for the Ethernet device. */ - rte_eth_promiscuous_enable(port); + retval = rte_eth_promiscuous_enable(port); + if (retval != 0) + return retval; return 0; } @@ -343,7 +345,7 @@ Finally the RX port is set in promiscuous mode: .. code-block:: c - rte_eth_promiscuous_enable(port); + retval = rte_eth_promiscuous_enable(port); The Add Rules function ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/guides/sample_app_ug/flow_filtering.rst b/doc/guides/sample_app_ug/flow_filtering.rst index 02fc675506..de3e4ab0b6 100644 --- a/doc/guides/sample_app_ug/flow_filtering.rst +++ b/doc/guides/sample_app_ug/flow_filtering.rst @@ -193,7 +193,13 @@ application is shown below: } } - rte_eth_promiscuous_enable(port_id); + ret = rte_eth_promiscuous_enable(port_id); + if (ret != 0) { + rte_exit(EXIT_FAILURE, + ":: cannot enable promiscuous mode: err=%d, port=%u\n", + ret, port_id); + } + ret = rte_eth_dev_start(port_id); if (ret < 0) { rte_exit(EXIT_FAILURE, @@ -278,7 +284,12 @@ We are setting the RX port to promiscuous mode: .. code-block:: c - rte_eth_promiscuous_enable(port_id); + ret = rte_eth_promiscuous_enable(port_id); + if (ret != 0) { + rte_exit(EXIT_FAILURE, + ":: cannot enable promiscuous mode: err=%d, port=%u\n", + ret, port_id); + } The last step is to start the port. diff --git a/doc/guides/sample_app_ug/rxtx_callbacks.rst b/doc/guides/sample_app_ug/rxtx_callbacks.rst index 32c120992f..0a69ec71ab 100644 --- a/doc/guides/sample_app_ug/rxtx_callbacks.rst +++ b/doc/guides/sample_app_ug/rxtx_callbacks.rst @@ -117,8 +117,9 @@ comments: return retval; /* Enable RX in promiscuous mode for the Ethernet device. */ - rte_eth_promiscuous_enable(port); - + retval = rte_eth_promiscuous_enable(port); + if (retval != 0) + return retval; /* Add the callbacks for RX and TX.*/ rte_eth_add_rx_callback(port, 0, add_timestamps, NULL); diff --git a/doc/guides/sample_app_ug/skeleton.rst b/doc/guides/sample_app_ug/skeleton.rst index 59ca511d33..1d0a2760d4 100644 --- a/doc/guides/sample_app_ug/skeleton.rst +++ b/doc/guides/sample_app_ug/skeleton.rst @@ -149,7 +149,9 @@ Forwarding application is shown below: return retval; /* Enable RX in promiscuous mode for the Ethernet device. */ - rte_eth_promiscuous_enable(port); + retval = rte_eth_promiscuous_enable(port); + if (retval != 0) + return retval; return 0; } @@ -177,7 +179,7 @@ Finally the RX port is set in promiscuous mode: .. code-block:: c - rte_eth_promiscuous_enable(port); + retval = rte_eth_promiscuous_enable(port); The Lcores Main diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 4b6cbe2343..0f6dedbe23 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1381,24 +1381,41 @@ rte_eth_dev_mac_restore(struct rte_eth_dev *dev, } } -static void +static int rte_eth_dev_config_restore(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info, uint16_t port_id) { + int ret; + if (!(*dev_info->dev_flags & RTE_ETH_DEV_NOLIVE_MAC_ADDR)) rte_eth_dev_mac_restore(dev, dev_info); /* replay promiscuous configuration */ - if (rte_eth_promiscuous_get(port_id) == 1) - rte_eth_promiscuous_enable(port_id); - else if (rte_eth_promiscuous_get(port_id) == 0) - rte_eth_promiscuous_disable(port_id); + if (rte_eth_promiscuous_get(port_id) == 1) { + ret = rte_eth_promiscuous_enable(port_id); + if (ret != 0 && ret != -ENOTSUP) { + RTE_ETHDEV_LOG(ERR, + "Failed to enable promiscuous mode for device (port %u): %s\n", + port_id, rte_strerror(-ret)); + return ret; + } + } else if (rte_eth_promiscuous_get(port_id) == 0) { + ret = rte_eth_promiscuous_disable(port_id); + if (ret != 0 && ret != -ENOTSUP) { + RTE_ETHDEV_LOG(ERR, + "Failed to disable promiscuous mode for device (port %u): %s\n", + port_id, rte_strerror(-ret)); + return ret; + } + } /* 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); + + return 0; } int @@ -1436,7 +1453,14 @@ rte_eth_dev_start(uint16_t port_id) else return eth_err(port_id, diag); - rte_eth_dev_config_restore(dev, &dev_info, port_id); + ret = rte_eth_dev_config_restore(dev, &dev_info, port_id); + if (ret != 0) { + 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); + return ret; + } if (dev->data->dev_conf.intr_conf.lsc == 0) { RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP); @@ -1864,30 +1888,34 @@ rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt) return eth_err(port_id, ret); } -void +int rte_eth_promiscuous_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->promiscuous_enable); + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->promiscuous_enable, -ENOTSUP); (*dev->dev_ops->promiscuous_enable)(dev); dev->data->promiscuous = 1; + + return 0; } -void +int rte_eth_promiscuous_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->promiscuous_disable); + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->promiscuous_disable, -ENOTSUP); dev->data->promiscuous = 0; (*dev->dev_ops->promiscuous_disable)(dev); + + return 0; } int diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index eda9e5c628..56e47b96be 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -2022,16 +2022,26 @@ int rte_eth_dev_reset(uint16_t port_id); * * @param port_id * The port identifier of the Ethernet device. + * @return + * - (0) if successful. + * - (-ENOTSUP) if support for promiscuous_enable() does not exist + * for the device. + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_promiscuous_enable(uint16_t port_id); +int rte_eth_promiscuous_enable(uint16_t port_id); /** * Disable receipt in promiscuous mode for an Ethernet device. * * @param port_id * The port identifier of the Ethernet device. + * @return + * - (0) if successful. + * - (-ENOTSUP) if support for promiscuous_disable() does not exist + * for the device. + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_promiscuous_disable(uint16_t port_id); +int rte_eth_promiscuous_disable(uint16_t port_id); /** * Return the value of promiscuous mode for an Ethernet device. -- 2.17.1
next prev parent reply index Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-09-05 16:10 [dpdk-dev] [PATCH 00/13] ethdev: change promiscuous mode functions to return status Andrew Rybchenko 2019-09-05 16:10 ` Andrew Rybchenko [this message] 2019-09-05 16:10 ` [dpdk-dev] [PATCH 02/13] net/failsafe: check code of promiscuous mode switch Andrew Rybchenko 2019-09-05 16:25 ` Gaëtan Rivet 2019-09-05 16:32 ` Andrew Rybchenko 2019-09-05 16:36 ` Stephen Hemminger 2019-09-05 16:38 ` Andrew Rybchenko 2019-09-06 9:24 ` Gaëtan Rivet 2019-09-06 10:08 ` Andrew Rybchenko 2019-09-05 16:40 ` Stephen Hemminger 2019-09-05 16:49 ` Andrew Rybchenko 2019-09-05 17:13 ` Stephen Hemminger 2019-09-05 16:10 ` [dpdk-dev] [PATCH 03/13] net/bonding: " Andrew Rybchenko 2019-09-05 16:10 ` [dpdk-dev] [PATCH 04/13] ethdev: change promiscuous callbacks to return status Andrew Rybchenko 2019-09-05 16:10 ` [dpdk-dev] [PATCH 05/13] ethdev: do nothing if promiscuous mode is applied again Andrew Rybchenko 2019-09-05 16:10 ` [dpdk-dev] [PATCH 06/13] app/pipeline: check code of promiscuous mode switch Andrew Rybchenko 2019-09-05 16:10 ` [dpdk-dev] [PATCH 07/13] app/testpmd: " Andrew Rybchenko 2019-09-05 16:10 ` [dpdk-dev] [PATCH 08/13] app/eventdev: " Andrew Rybchenko 2019-09-05 16:10 ` [dpdk-dev] [PATCH 09/13] app/pdump: " Andrew Rybchenko 2019-09-05 16:10 ` [dpdk-dev] [PATCH 10/13] app/test: " Andrew Rybchenko 2019-09-05 16:10 ` [dpdk-dev] [PATCH 11/13] kni: " Andrew Rybchenko 2019-09-05 16:10 ` [dpdk-dev] [PATCH 12/13] test/bonding: " Andrew Rybchenko 2019-09-05 16:10 ` [dpdk-dev] [PATCH 13/13] examples: take promiscuous mode switch result into account Andrew Rybchenko 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 00/13] ethdev: change promiscuous mode functions to return status Andrew Rybchenko 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 01/13] ethdev: change promiscuous mode controllers to return errors Andrew Rybchenko 2019-09-13 15:35 ` Ferruh Yigit 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 02/13] net/failsafe: check code of promiscuous mode switch Andrew Rybchenko 2019-09-09 12:48 ` Gaëtan Rivet 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 03/13] net/bonding: " Andrew Rybchenko 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 04/13] ethdev: change promiscuous callbacks to return status Andrew Rybchenko 2019-09-10 7:53 ` Matan Azrad 2019-09-13 21:05 ` Andrew Rybchenko 2019-09-11 8:46 ` Hyong Youb Kim (hyonkim) 2019-09-13 21:06 ` Andrew Rybchenko 2019-09-16 6:48 ` Hyong Youb Kim (hyonkim) 2019-09-13 15:34 ` Ferruh Yigit 2019-09-13 15:54 ` Andrew Rybchenko 2019-09-13 16:33 ` Ferruh Yigit 2019-09-13 15:39 ` Ferruh Yigit 2019-09-13 16:05 ` Andrew Rybchenko 2019-09-13 16:34 ` Ferruh Yigit 2019-09-13 19:57 ` Andrew Rybchenko 2019-09-16 13:22 ` Ferruh Yigit 2019-09-16 15:45 ` Andrew Rybchenko 2019-09-16 15:58 ` Ferruh Yigit 2019-09-13 16:43 ` Ferruh Yigit 2019-09-13 20:33 ` Andrew Rybchenko 2019-09-13 16:56 ` Ferruh Yigit 2019-09-13 20:38 ` Andrew Rybchenko 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 05/13] ethdev: do nothing if promiscuous mode is applied again Andrew Rybchenko 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 06/13] app/pipeline: check code of promiscuous mode switch Andrew Rybchenko 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 07/13] app/testpmd: " Andrew Rybchenko 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 08/13] app/eventdev: " Andrew Rybchenko 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 09/13] app/pdump: " Andrew Rybchenko 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 10/13] app/test: " Andrew Rybchenko 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 11/13] kni: " Andrew Rybchenko 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 12/13] test/bonding: " Andrew Rybchenko 2019-09-09 11:58 ` [dpdk-dev] [PATCH v2 13/13] examples: take promiscuous mode switch result into account Andrew Rybchenko 2019-09-13 16:40 ` Ferruh Yigit 2019-09-13 18:30 ` Andrew Rybchenko 2019-09-13 16:37 ` [dpdk-dev] [PATCH v2 00/13] ethdev: change promiscuous mode functions to return status Ferruh Yigit 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 " Andrew Rybchenko 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 01/13] ethdev: change promiscuous mode controllers to return errors Andrew Rybchenko 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 02/13] net/failsafe: check code of promiscuous mode switch Andrew Rybchenko 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 03/13] net/bonding: " Andrew Rybchenko 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 04/13] ethdev: change promiscuous callbacks to return status Andrew Rybchenko 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 05/13] ethdev: do nothing if promiscuous mode is applied again Andrew Rybchenko 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 06/13] app/pipeline: check code of promiscuous mode switch Andrew Rybchenko 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 07/13] app/testpmd: " Andrew Rybchenko 2019-09-16 13:18 ` Iremonger, Bernard 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 08/13] app/eventdev: " Andrew Rybchenko 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 09/13] app/pdump: " Andrew Rybchenko 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 10/13] app/test: " Andrew Rybchenko 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 11/13] kni: " Andrew Rybchenko 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 12/13] test/bonding: " Andrew Rybchenko 2019-09-14 11:37 ` [dpdk-dev] [PATCH v3 13/13] examples: take promiscuous mode switch result into account Andrew Rybchenko 2019-09-24 7:31 ` [dpdk-dev] [PATCH v3 00/13] ethdev: change promiscuous mode functions to return status Ferruh Yigit
Reply instructions: You may reply publically to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1567699852-31693-2-git-send-email-arybchenko@solarflare.com \ --to=arybchenko@solarflare.com \ --cc=Ivan.Ilchenko@oktetlabs.ru \ --cc=akhil.goyal@nxp.com \ --cc=bernard.iremonger@intel.com \ --cc=bruce.richardson@intel.com \ --cc=dev@dpdk.org \ --cc=ferruh.yigit@intel.com \ --cc=harry.van.haaren@intel.com \ --cc=john.mcnamara@intel.com \ --cc=marko.kovacevic@intel.com \ --cc=nhorman@tuxdriver.com \ --cc=orika@mellanox.com \ --cc=pablo.de.lara.guarch@intel.com \ --cc=radu.nicolau@intel.com \ --cc=thomas@monjalon.net \ --cc=tomasz.kantecki@intel.com \ --cc=xiaoyun.li@intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
DPDK-dev Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/dpdk-dev/0 dpdk-dev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 dpdk-dev dpdk-dev/ https://lore.kernel.org/dpdk-dev \ dev@dpdk.org public-inbox-index dpdk-dev Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.dpdk.dev AGPL code for this site: git clone https://public-inbox.org/public-inbox.git