X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fmlx5%2Fmlx5_rxmode.c;h=7613ff770d77190e69cbe35f5630cc414024f432;hb=4defbc8cbb6d5b520f13ee7f2396b0a31516d370;hp=0c1e9eb2a57f3ccbd268b7cf4dedd5ce2a02150e;hpb=a6d83b6a9209a198fa5a7d2f9cbb37190e256f9c;p=dpdk.git diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c index 0c1e9eb2a5..7613ff770d 100644 --- a/drivers/net/mlx5/mlx5_rxmode.c +++ b/drivers/net/mlx5/mlx5_rxmode.c @@ -1,24 +1,15 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright 2015 6WIND S.A. - * Copyright 2015 Mellanox. + * Copyright 2015 Mellanox Technologies, Ltd */ #include #include #include -/* Verbs header. */ -/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */ -#ifdef PEDANTIC -#pragma GCC diagnostic ignored "-Wpedantic" -#endif -#include -#ifdef PEDANTIC -#pragma GCC diagnostic error "-Wpedantic" -#endif - #include +#include #include "mlx5.h" #include "mlx5_rxtx.h" #include "mlx5_utils.h" @@ -28,17 +19,39 @@ * * @param dev * Pointer to Ethernet device structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. */ -void +int mlx5_promiscuous_enable(struct rte_eth_dev *dev) { + struct mlx5_priv *priv = dev->data->dev_private; int ret; dev->data->promiscuous = 1; + if (priv->isolated) { + DRV_LOG(WARNING, + "port %u cannot enable promiscuous mode" + " in flow isolation mode", + dev->data->port_id); + return 0; + } + if (priv->config.vf) { + ret = mlx5_os_set_promisc(dev, 1); + if (ret) + return ret; + } ret = mlx5_traffic_restart(dev); if (ret) - ERROR("%p cannot enable promiscuous mode: %s", (void *)dev, - strerror(rte_errno)); + DRV_LOG(ERR, "port %u cannot enable promiscuous mode: %s", + dev->data->port_id, strerror(rte_errno)); + + /* + * rte_eth_dev_promiscuous_enable() rollback + * dev->data->promiscuous in the case of failure. + */ + return ret; } /** @@ -46,17 +59,32 @@ mlx5_promiscuous_enable(struct rte_eth_dev *dev) * * @param dev * Pointer to Ethernet device structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. */ -void +int mlx5_promiscuous_disable(struct rte_eth_dev *dev) { + struct mlx5_priv *priv = dev->data->dev_private; int ret; dev->data->promiscuous = 0; + if (priv->config.vf) { + ret = mlx5_os_set_promisc(dev, 0); + if (ret) + return ret; + } ret = mlx5_traffic_restart(dev); if (ret) - ERROR("%p cannot disable promiscuous mode: %s", (void *)dev, - strerror(rte_errno)); + DRV_LOG(ERR, "port %u cannot disable promiscuous mode: %s", + dev->data->port_id, strerror(rte_errno)); + + /* + * rte_eth_dev_promiscuous_disable() rollback + * dev->data->promiscuous in the case of failure. + */ + return ret; } /** @@ -64,17 +92,39 @@ mlx5_promiscuous_disable(struct rte_eth_dev *dev) * * @param dev * Pointer to Ethernet device structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. */ -void +int mlx5_allmulticast_enable(struct rte_eth_dev *dev) { + struct mlx5_priv *priv = dev->data->dev_private; int ret; dev->data->all_multicast = 1; + if (priv->isolated) { + DRV_LOG(WARNING, + "port %u cannot enable allmulticast mode" + " in flow isolation mode", + dev->data->port_id); + return 0; + } + if (priv->config.vf) { + ret = mlx5_os_set_allmulti(dev, 1); + if (ret) + goto error; + } ret = mlx5_traffic_restart(dev); if (ret) - ERROR("%p cannot enable allmulicast mode: %s", (void *)dev, - strerror(rte_errno)); + DRV_LOG(ERR, "port %u cannot enable allmulicast mode: %s", + dev->data->port_id, strerror(rte_errno)); +error: + /* + * rte_eth_allmulticast_enable() rollback + * dev->data->all_multicast in the case of failure. + */ + return ret; } /** @@ -82,15 +132,30 @@ mlx5_allmulticast_enable(struct rte_eth_dev *dev) * * @param dev * Pointer to Ethernet device structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. */ -void +int mlx5_allmulticast_disable(struct rte_eth_dev *dev) { + struct mlx5_priv *priv = dev->data->dev_private; int ret; dev->data->all_multicast = 0; + if (priv->config.vf) { + ret = mlx5_os_set_allmulti(dev, 0); + if (ret) + goto error; + } ret = mlx5_traffic_restart(dev); if (ret) - ERROR("%p cannot disable allmulicast mode: %s", (void *)dev, - strerror(rte_errno)); + DRV_LOG(ERR, "port %u cannot disable allmulicast mode: %s", + dev->data->port_id, strerror(rte_errno)); +error: + /* + * rte_eth_allmulticast_disable() rollback + * dev->data->all_multicast in the case of failure. + */ + return ret; }