This commit adds Linux implementation of routines mlx5_os_set_promisc() and mlx5_os_set_promisc(). The routines call netlink APIs.
Signed-off-by: Ophir Munk <ophi...@mellanox.com> Acked-by: Matan Azrad <ma...@mellanox.com> --- drivers/net/mlx5/linux/mlx5_os.c | 40 ++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5.h | 2 ++ drivers/net/mlx5/mlx5_rxmode.c | 12 ++++-------- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index b5993a7..7de57a4 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -2371,6 +2371,46 @@ mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, (priv->nl_socket_route, iface_idx, mac_addr, vf_index); } +/** + * Set device promiscuous mode + * + * @param dev + * Pointer to Ethernet device structure. + * @param enable + * 0 - promiscuous is disabled, otherwise - enabled + * + * @return + * 0 on success, a negative error value otherwise + */ +int +mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable) +{ + struct mlx5_priv *priv = dev->data->dev_private; + + return mlx5_nl_promisc(priv->nl_socket_route, + mlx5_ifindex(dev), !!enable); +} + +/** + * Set device promiscuous mode + * + * @param dev + * Pointer to Ethernet device structure. + * @param enable + * 0 - all multicase is disabled, otherwise - enabled + * + * @return + * 0 on success, a negative error value otherwise + */ +int +mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable) +{ + struct mlx5_priv *priv = dev->data->dev_private; + + return mlx5_nl_allmulti(priv->nl_socket_route, + mlx5_ifindex(dev), !!enable); +} + const struct eth_dev_ops mlx5_os_dev_ops = { .dev_configure = mlx5_dev_configure, .dev_start = mlx5_dev_start, diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index bf1d97a..f719cfc 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -945,4 +945,6 @@ int mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, int mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, unsigned int iface_idx, struct rte_ether_addr *mac_addr, int vf_index); +int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable); +int mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable); #endif /* RTE_PMD_MLX5_H_ */ diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c index 84c8b05..80b1256 100644 --- a/drivers/net/mlx5/mlx5_rxmode.c +++ b/drivers/net/mlx5/mlx5_rxmode.c @@ -47,8 +47,7 @@ mlx5_promiscuous_enable(struct rte_eth_dev *dev) return 0; } if (priv->config.vf) { - ret = mlx5_nl_promisc(priv->nl_socket_route, mlx5_ifindex(dev), - 1); + ret = mlx5_os_set_promisc(dev, 1); if (ret) return ret; } @@ -81,8 +80,7 @@ mlx5_promiscuous_disable(struct rte_eth_dev *dev) dev->data->promiscuous = 0; if (priv->config.vf) { - ret = mlx5_nl_promisc(priv->nl_socket_route, mlx5_ifindex(dev), - 0); + ret = mlx5_os_set_promisc(dev, 0); if (ret) return ret; } @@ -122,8 +120,7 @@ mlx5_allmulticast_enable(struct rte_eth_dev *dev) return 0; } if (priv->config.vf) { - ret = mlx5_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev), - 1); + ret = mlx5_os_set_allmulti(dev, 1); if (ret) goto error; } @@ -156,8 +153,7 @@ mlx5_allmulticast_disable(struct rte_eth_dev *dev) dev->data->all_multicast = 0; if (priv->config.vf) { - ret = mlx5_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev), - 0); + ret = mlx5_os_set_allmulti(dev, 0); if (ret) goto error; } -- 2.8.4