X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fmlx5%2Fmlx5_rxmode.c;h=84c8b05269ce1432007a265e00a8dddcdaaf8683;hb=1b7b9f170fcebbbd0708fab554dcb5a7badef8cf;hp=3c0373bb4dbe107644c6c24f883f9efad6e17419;hpb=24b068ad71229139f74a1c45bd45dcf9f4611f89;p=dpdk.git diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c index 3c0373bb4d..84c8b05269 100644 --- a/drivers/net/mlx5/mlx5_rxmode.c +++ b/drivers/net/mlx5/mlx5_rxmode.c @@ -28,11 +28,14 @@ * * @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 priv *priv = dev->data->dev_private; + struct mlx5_priv *priv = dev->data->dev_private; int ret; dev->data->promiscuous = 1; @@ -41,14 +44,24 @@ mlx5_promiscuous_enable(struct rte_eth_dev *dev) "port %u cannot enable promiscuous mode" " in flow isolation mode", dev->data->port_id); - return; + return 0; + } + if (priv->config.vf) { + ret = mlx5_nl_promisc(priv->nl_socket_route, mlx5_ifindex(dev), + 1); + if (ret) + return ret; } - if (priv->config.vf) - mlx5_nl_promisc(dev, 1); ret = mlx5_traffic_restart(dev); if (ret) 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; } /** @@ -56,20 +69,33 @@ 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 priv *priv = dev->data->dev_private; + struct mlx5_priv *priv = dev->data->dev_private; int ret; dev->data->promiscuous = 0; - if (priv->config.vf) - mlx5_nl_promisc(dev, 0); + if (priv->config.vf) { + ret = mlx5_nl_promisc(priv->nl_socket_route, mlx5_ifindex(dev), + 0); + if (ret) + return ret; + } ret = mlx5_traffic_restart(dev); if (ret) 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; } /** @@ -77,19 +103,40 @@ 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 (((struct priv *)dev->data->dev_private)->config.vf) - mlx5_nl_allmulti(dev, 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_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev), + 1); + if (ret) + goto error; + } ret = mlx5_traffic_restart(dev); if (ret) 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; } /** @@ -97,17 +144,31 @@ 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 (((struct priv *)dev->data->dev_private)->config.vf) - mlx5_nl_allmulti(dev, 0); + if (priv->config.vf) { + ret = mlx5_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev), + 0); + if (ret) + goto error; + } ret = mlx5_traffic_restart(dev); if (ret) 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; }