1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2015 6WIND S.A.
3 * Copyright 2015 Mellanox Technologies, Ltd
10 #include <rte_ethdev_driver.h>
12 #include <mlx5_glue.h>
14 #include "mlx5_rxtx.h"
15 #include "mlx5_utils.h"
18 * DPDK callback to enable promiscuous mode.
21 * Pointer to Ethernet device structure.
24 * 0 on success, a negative errno value otherwise and rte_errno is set.
27 mlx5_promiscuous_enable(struct rte_eth_dev *dev)
29 struct mlx5_priv *priv = dev->data->dev_private;
32 dev->data->promiscuous = 1;
35 "port %u cannot enable promiscuous mode"
36 " in flow isolation mode",
40 if (priv->config.vf) {
41 ret = mlx5_os_set_promisc(dev, 1);
45 ret = mlx5_traffic_restart(dev);
47 DRV_LOG(ERR, "port %u cannot enable promiscuous mode: %s",
48 dev->data->port_id, strerror(rte_errno));
51 * rte_eth_dev_promiscuous_enable() rollback
52 * dev->data->promiscuous in the case of failure.
58 * DPDK callback to disable promiscuous mode.
61 * Pointer to Ethernet device structure.
64 * 0 on success, a negative errno value otherwise and rte_errno is set.
67 mlx5_promiscuous_disable(struct rte_eth_dev *dev)
69 struct mlx5_priv *priv = dev->data->dev_private;
72 dev->data->promiscuous = 0;
73 if (priv->config.vf) {
74 ret = mlx5_os_set_promisc(dev, 0);
78 ret = mlx5_traffic_restart(dev);
80 DRV_LOG(ERR, "port %u cannot disable promiscuous mode: %s",
81 dev->data->port_id, strerror(rte_errno));
84 * rte_eth_dev_promiscuous_disable() rollback
85 * dev->data->promiscuous in the case of failure.
91 * DPDK callback to enable allmulti mode.
94 * Pointer to Ethernet device structure.
97 * 0 on success, a negative errno value otherwise and rte_errno is set.
100 mlx5_allmulticast_enable(struct rte_eth_dev *dev)
102 struct mlx5_priv *priv = dev->data->dev_private;
105 dev->data->all_multicast = 1;
106 if (priv->isolated) {
108 "port %u cannot enable allmulticast mode"
109 " in flow isolation mode",
113 if (priv->config.vf) {
114 ret = mlx5_os_set_allmulti(dev, 1);
118 ret = mlx5_traffic_restart(dev);
120 DRV_LOG(ERR, "port %u cannot enable allmulicast mode: %s",
121 dev->data->port_id, strerror(rte_errno));
124 * rte_eth_allmulticast_enable() rollback
125 * dev->data->all_multicast in the case of failure.
131 * DPDK callback to disable allmulti mode.
134 * Pointer to Ethernet device structure.
137 * 0 on success, a negative errno value otherwise and rte_errno is set.
140 mlx5_allmulticast_disable(struct rte_eth_dev *dev)
142 struct mlx5_priv *priv = dev->data->dev_private;
145 dev->data->all_multicast = 0;
146 if (priv->config.vf) {
147 ret = mlx5_os_set_allmulti(dev, 0);
151 ret = mlx5_traffic_restart(dev);
153 DRV_LOG(ERR, "port %u cannot disable allmulicast mode: %s",
154 dev->data->port_id, strerror(rte_errno));
157 * rte_eth_allmulticast_disable() rollback
158 * dev->data->all_multicast in the case of failure.