net/mlx5: wrap Linux promiscuous and multicast functions
authorOphir Munk <ophirmu@mellanox.com>
Sun, 19 Jul 2020 10:18:12 +0000 (10:18 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Jul 2020 13:46:30 +0000 (15:46 +0200)
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 <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
drivers/net/mlx5/linux/mlx5_os.c
drivers/net/mlx5/mlx5.h
drivers/net/mlx5/mlx5_rxmode.c

index dea4ee7..bffcfc5 100644 (file)
@@ -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,
index 88cfed8..605ff52 100644 (file)
@@ -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 */
 
index 84c8b05..80b1256 100644 (file)
@@ -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;
        }