diff mbox series

[v2,38/41] net/mlx5: set promisc and allmulti modes

Message ID 20211007184350.73858-39-srikanth.k@oneconvergence.com (mailing list archive)
State New
Delegated to: Raslan Darawsheh
Headers show
Series add MLX5 FreeBSD support | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Srikanth Kaka Oct. 7, 2021, 6:43 p.m. UTC
Using INET socket, promisc and allmulti modes are set/unset
In FreeBSD, allmulti mode cannot be toggled from userspace
thus it can only be unset in DPDK but not at device level.

Signed-off-by: Srikanth Kaka <srikanth.k@oneconvergence.com>
Signed-off-by: Vag Singh <vag.singh@oneconvergence.com>
Signed-off-by: Anand Thulasiram <avelu@juniper.net>
---
 drivers/net/mlx5/freebsd/mlx5_os.c | 52 ++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/mlx5/freebsd/mlx5_os.c b/drivers/net/mlx5/freebsd/mlx5_os.c
index 9992cb1d6a..fef5cdaf34 100644
--- a/drivers/net/mlx5/freebsd/mlx5_os.c
+++ b/drivers/net/mlx5/freebsd/mlx5_os.c
@@ -2480,6 +2480,58 @@  mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv,
 	return ret;
 }
 
+/**
+ * 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;
+	char ifname[IF_NAMESIZE];
+	int ret;
+
+	ret = mlx5_get_ifname_sysfs(priv->sh->ibdev_path, ifname);
+	if (!ret)
+		ret = mlx5_inet_promisc(priv->nl_socket_route,
+				 ifname, enable,
+				 dev->data->port_id);
+	return ret;
+}
+
+/**
+ * Set device allmulti 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;
+	char ifname[IF_NAMESIZE];
+	int ret;
+
+	RTE_SET_USED(enable);
+	ret = mlx5_get_ifname_sysfs(priv->sh->ibdev_path, ifname);
+	if (!ret)
+		ret = mlx5_inet_check_allmulti_flag(priv->nl_socket_route,
+					     ifname, dev->data->port_id);
+	return ret;
+}
+
 /**
  * Flush device MAC addresses
  *