From: Ophir Munk Date: Sun, 19 Jul 2020 10:18:12 +0000 (+0000) Subject: net/mlx5: wrap Linux promiscuous and multicast functions X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4d18abd13068a60589706c2ba4a634ae8e7f9d32;p=dpdk.git net/mlx5: wrap Linux promiscuous and multicast functions 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 Acked-by: Matan Azrad --- diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index dea4ee70fb..bffcfc5b0d 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -2462,6 +2462,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 88cfed87aa..605ff526ae 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1031,6 +1031,8 @@ 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); /* mlx5_txpp.c */ diff --git a/drivers/net/mlx5/mlx5_rxmode.c b/drivers/net/mlx5/mlx5_rxmode.c index 84c8b05269..80b125653d 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; }