1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2015 6WIND S.A.
3 * Copyright 2015 Mellanox Technologies, Ltd
10 #include <ethdev_driver.h>
12 #include <mlx5_glue.h>
14 #include "mlx5_utils.h"
17 * DPDK callback to enable promiscuous mode.
20 * Pointer to Ethernet device structure.
23 * 0 on success, a negative errno value otherwise and rte_errno is set.
26 mlx5_promiscuous_enable(struct rte_eth_dev *dev)
28 struct mlx5_priv *priv = dev->data->dev_private;
31 dev->data->promiscuous = 1;
34 "port %u cannot enable promiscuous mode"
35 " in flow isolation mode",
39 if (priv->config.vf || priv->config.sf) {
40 ret = mlx5_os_set_promisc(dev, 1);
44 ret = mlx5_traffic_restart(dev);
46 DRV_LOG(ERR, "port %u cannot enable promiscuous mode: %s",
47 dev->data->port_id, strerror(rte_errno));
50 * rte_eth_dev_promiscuous_enable() rollback
51 * dev->data->promiscuous in the case of failure.
57 * DPDK callback to disable promiscuous mode.
60 * Pointer to Ethernet device structure.
63 * 0 on success, a negative errno value otherwise and rte_errno is set.
66 mlx5_promiscuous_disable(struct rte_eth_dev *dev)
68 struct mlx5_priv *priv = dev->data->dev_private;
71 dev->data->promiscuous = 0;
72 if (priv->config.vf || priv->config.sf) {
73 ret = mlx5_os_set_promisc(dev, 0);
77 ret = mlx5_traffic_restart(dev);
79 DRV_LOG(ERR, "port %u cannot disable promiscuous mode: %s",
80 dev->data->port_id, strerror(rte_errno));
83 * rte_eth_dev_promiscuous_disable() rollback
84 * dev->data->promiscuous in the case of failure.
90 * DPDK callback to enable allmulti mode.
93 * Pointer to Ethernet device structure.
96 * 0 on success, a negative errno value otherwise and rte_errno is set.
99 mlx5_allmulticast_enable(struct rte_eth_dev *dev)
101 struct mlx5_priv *priv = dev->data->dev_private;
104 dev->data->all_multicast = 1;
105 if (priv->isolated) {
107 "port %u cannot enable allmulticast mode"
108 " in flow isolation mode",
112 if (priv->config.vf || priv->config.sf) {
113 ret = mlx5_os_set_allmulti(dev, 1);
117 ret = mlx5_traffic_restart(dev);
119 DRV_LOG(ERR, "port %u cannot enable allmulicast mode: %s",
120 dev->data->port_id, strerror(rte_errno));
123 * rte_eth_allmulticast_enable() rollback
124 * dev->data->all_multicast in the case of failure.
130 * DPDK callback to disable allmulti mode.
133 * Pointer to Ethernet device structure.
136 * 0 on success, a negative errno value otherwise and rte_errno is set.
139 mlx5_allmulticast_disable(struct rte_eth_dev *dev)
141 struct mlx5_priv *priv = dev->data->dev_private;
144 dev->data->all_multicast = 0;
145 if (priv->config.vf || priv->config.sf) {
146 ret = mlx5_os_set_allmulti(dev, 0);
150 ret = mlx5_traffic_restart(dev);
152 DRV_LOG(ERR, "port %u cannot disable allmulicast mode: %s",
153 dev->data->port_id, strerror(rte_errno));
156 * rte_eth_allmulticast_disable() rollback
157 * dev->data->all_multicast in the case of failure.