1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2015 6WIND S.A.
3 * Copyright 2015 Mellanox Technologies, Ltd
11 /* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
13 #pragma GCC diagnostic ignored "-Wpedantic"
15 #include <infiniband/verbs.h>
17 #pragma GCC diagnostic error "-Wpedantic"
20 #include <rte_ethdev_driver.h>
23 #include "mlx5_rxtx.h"
24 #include "mlx5_utils.h"
27 * DPDK callback to enable promiscuous mode.
30 * Pointer to Ethernet device structure.
33 * 0 on success, a negative errno value otherwise and rte_errno is set.
36 mlx5_promiscuous_enable(struct rte_eth_dev *dev)
38 struct mlx5_priv *priv = dev->data->dev_private;
41 dev->data->promiscuous = 1;
44 "port %u cannot enable promiscuous mode"
45 " in flow isolation mode",
49 if (priv->config.vf) {
50 ret = mlx5_nl_promisc(dev, 1);
54 ret = mlx5_traffic_restart(dev);
56 DRV_LOG(ERR, "port %u cannot enable promiscuous mode: %s",
57 dev->data->port_id, strerror(rte_errno));
60 * rte_eth_dev_promiscuous_enable() rollback
61 * dev->data->promiscuous in the case of failure.
67 * DPDK callback to disable promiscuous mode.
70 * Pointer to Ethernet device structure.
73 * 0 on success, a negative errno value otherwise and rte_errno is set.
76 mlx5_promiscuous_disable(struct rte_eth_dev *dev)
78 struct mlx5_priv *priv = dev->data->dev_private;
81 dev->data->promiscuous = 0;
82 if (priv->config.vf) {
83 ret = mlx5_nl_promisc(dev, 0);
87 ret = mlx5_traffic_restart(dev);
89 DRV_LOG(ERR, "port %u cannot disable promiscuous mode: %s",
90 dev->data->port_id, strerror(rte_errno));
93 * rte_eth_dev_promiscuous_disable() rollback
94 * dev->data->promiscuous in the case of failure.
100 * DPDK callback to enable allmulti mode.
103 * Pointer to Ethernet device structure.
106 mlx5_allmulticast_enable(struct rte_eth_dev *dev)
108 struct mlx5_priv *priv = dev->data->dev_private;
111 dev->data->all_multicast = 1;
112 if (priv->isolated) {
114 "port %u cannot enable allmulticast mode"
115 " in flow isolation mode",
120 mlx5_nl_allmulti(dev, 1);
121 ret = mlx5_traffic_restart(dev);
123 DRV_LOG(ERR, "port %u cannot enable allmulicast mode: %s",
124 dev->data->port_id, strerror(rte_errno));
128 * DPDK callback to disable allmulti mode.
131 * Pointer to Ethernet device structure.
134 mlx5_allmulticast_disable(struct rte_eth_dev *dev)
136 struct mlx5_priv *priv = dev->data->dev_private;
139 dev->data->all_multicast = 0;
141 mlx5_nl_allmulti(dev, 0);
142 ret = mlx5_traffic_restart(dev);
144 DRV_LOG(ERR, "port %u cannot disable allmulicast mode: %s",
145 dev->data->port_id, strerror(rte_errno));