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(priv->nl_socket_route, mlx5_ifindex(dev),
55 ret = mlx5_traffic_restart(dev);
57 DRV_LOG(ERR, "port %u cannot enable promiscuous mode: %s",
58 dev->data->port_id, strerror(rte_errno));
61 * rte_eth_dev_promiscuous_enable() rollback
62 * dev->data->promiscuous in the case of failure.
68 * DPDK callback to disable promiscuous mode.
71 * Pointer to Ethernet device structure.
74 * 0 on success, a negative errno value otherwise and rte_errno is set.
77 mlx5_promiscuous_disable(struct rte_eth_dev *dev)
79 struct mlx5_priv *priv = dev->data->dev_private;
82 dev->data->promiscuous = 0;
83 if (priv->config.vf) {
84 ret = mlx5_nl_promisc(priv->nl_socket_route, mlx5_ifindex(dev),
89 ret = mlx5_traffic_restart(dev);
91 DRV_LOG(ERR, "port %u cannot disable promiscuous mode: %s",
92 dev->data->port_id, strerror(rte_errno));
95 * rte_eth_dev_promiscuous_disable() rollback
96 * dev->data->promiscuous in the case of failure.
102 * DPDK callback to enable allmulti mode.
105 * Pointer to Ethernet device structure.
108 * 0 on success, a negative errno value otherwise and rte_errno is set.
111 mlx5_allmulticast_enable(struct rte_eth_dev *dev)
113 struct mlx5_priv *priv = dev->data->dev_private;
116 dev->data->all_multicast = 1;
117 if (priv->isolated) {
119 "port %u cannot enable allmulticast mode"
120 " in flow isolation mode",
124 if (priv->config.vf) {
125 ret = mlx5_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev),
130 ret = mlx5_traffic_restart(dev);
132 DRV_LOG(ERR, "port %u cannot enable allmulicast mode: %s",
133 dev->data->port_id, strerror(rte_errno));
136 * rte_eth_allmulticast_enable() rollback
137 * dev->data->all_multicast in the case of failure.
143 * DPDK callback to disable allmulti mode.
146 * Pointer to Ethernet device structure.
149 * 0 on success, a negative errno value otherwise and rte_errno is set.
152 mlx5_allmulticast_disable(struct rte_eth_dev *dev)
154 struct mlx5_priv *priv = dev->data->dev_private;
157 dev->data->all_multicast = 0;
158 if (priv->config.vf) {
159 ret = mlx5_nl_allmulti(priv->nl_socket_route, mlx5_ifindex(dev),
164 ret = mlx5_traffic_restart(dev);
166 DRV_LOG(ERR, "port %u cannot disable allmulicast mode: %s",
167 dev->data->port_id, strerror(rte_errno));
170 * rte_eth_allmulticast_disable() rollback
171 * dev->data->all_multicast in the case of failure.