From: Ciara Power Date: Mon, 21 Oct 2019 12:22:37 +0000 (+0100) Subject: ethdev: check device promiscuous state X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=400d758182669035203ba619001b0c03234b9121;p=dpdk.git ethdev: check device promiscuous state The promiscuous enable and disable functions now check the promiscuous state of the device before checking if the dev_ops function exists for the device. This change is necessary to allow sample applications run on virtual PMDs, as previously -ENOTSUP returned when the promiscuous enable function was called. This caused the sample application to fail unnecessarily. Signed-off-by: Ciara Power Reviewed-by: Ferruh Yigit Reviewed-by: Andrew Rybchenko --- diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index acc4b748d3..78da293979 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1952,12 +1952,13 @@ rte_eth_promiscuous_enable(uint16_t port_id) RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; + if (dev->data->promiscuous == 1) + return 0; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->promiscuous_enable, -ENOTSUP); - if (dev->data->promiscuous == 0) { - diag = (*dev->dev_ops->promiscuous_enable)(dev); - dev->data->promiscuous = (diag == 0) ? 1 : 0; - } + diag = (*dev->dev_ops->promiscuous_enable)(dev); + dev->data->promiscuous = (diag == 0) ? 1 : 0; return eth_err(port_id, diag); } @@ -1971,14 +1972,15 @@ rte_eth_promiscuous_disable(uint16_t port_id) RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; + if (dev->data->promiscuous == 0) + return 0; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->promiscuous_disable, -ENOTSUP); - if (dev->data->promiscuous == 1) { - dev->data->promiscuous = 0; - diag = (*dev->dev_ops->promiscuous_disable)(dev); - if (diag != 0) - dev->data->promiscuous = 1; - } + dev->data->promiscuous = 0; + diag = (*dev->dev_ops->promiscuous_disable)(dev); + if (diag != 0) + dev->data->promiscuous = 1; return eth_err(port_id, diag); }