]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/dpdk/drivers/net/mlx5/mlx5_rxmode.c
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / dpdk / drivers / net / mlx5 / mlx5_rxmode.c
CommitLineData
11fdf7f2
TL
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2015 6WIND S.A.
3 * Copyright 2015 Mellanox Technologies, Ltd
4 */
5
6#include <stddef.h>
7#include <errno.h>
8#include <string.h>
9
10/* Verbs header. */
11/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
12#ifdef PEDANTIC
13#pragma GCC diagnostic ignored "-Wpedantic"
14#endif
15#include <infiniband/verbs.h>
16#ifdef PEDANTIC
17#pragma GCC diagnostic error "-Wpedantic"
18#endif
19
20#include <rte_ethdev_driver.h>
21
22#include "mlx5.h"
23#include "mlx5_rxtx.h"
24#include "mlx5_utils.h"
25
26/**
27 * DPDK callback to enable promiscuous mode.
28 *
29 * @param dev
30 * Pointer to Ethernet device structure.
31 */
32void
33mlx5_promiscuous_enable(struct rte_eth_dev *dev)
34{
9f95a23c 35 struct mlx5_priv *priv = dev->data->dev_private;
11fdf7f2
TL
36 int ret;
37
38 dev->data->promiscuous = 1;
39 if (priv->isolated) {
40 DRV_LOG(WARNING,
41 "port %u cannot enable promiscuous mode"
42 " in flow isolation mode",
43 dev->data->port_id);
44 return;
45 }
46 if (priv->config.vf)
47 mlx5_nl_promisc(dev, 1);
48 ret = mlx5_traffic_restart(dev);
49 if (ret)
50 DRV_LOG(ERR, "port %u cannot enable promiscuous mode: %s",
51 dev->data->port_id, strerror(rte_errno));
52}
53
54/**
55 * DPDK callback to disable promiscuous mode.
56 *
57 * @param dev
58 * Pointer to Ethernet device structure.
59 */
60void
61mlx5_promiscuous_disable(struct rte_eth_dev *dev)
62{
9f95a23c 63 struct mlx5_priv *priv = dev->data->dev_private;
11fdf7f2
TL
64 int ret;
65
66 dev->data->promiscuous = 0;
67 if (priv->config.vf)
68 mlx5_nl_promisc(dev, 0);
69 ret = mlx5_traffic_restart(dev);
70 if (ret)
71 DRV_LOG(ERR, "port %u cannot disable promiscuous mode: %s",
72 dev->data->port_id, strerror(rte_errno));
73}
74
75/**
76 * DPDK callback to enable allmulti mode.
77 *
78 * @param dev
79 * Pointer to Ethernet device structure.
80 */
81void
82mlx5_allmulticast_enable(struct rte_eth_dev *dev)
83{
9f95a23c 84 struct mlx5_priv *priv = dev->data->dev_private;
11fdf7f2
TL
85 int ret;
86
87 dev->data->all_multicast = 1;
88 if (priv->isolated) {
89 DRV_LOG(WARNING,
90 "port %u cannot enable allmulticast mode"
91 " in flow isolation mode",
92 dev->data->port_id);
93 return;
94 }
95 if (priv->config.vf)
96 mlx5_nl_allmulti(dev, 1);
97 ret = mlx5_traffic_restart(dev);
98 if (ret)
99 DRV_LOG(ERR, "port %u cannot enable allmulicast mode: %s",
100 dev->data->port_id, strerror(rte_errno));
101}
102
103/**
104 * DPDK callback to disable allmulti mode.
105 *
106 * @param dev
107 * Pointer to Ethernet device structure.
108 */
109void
110mlx5_allmulticast_disable(struct rte_eth_dev *dev)
111{
9f95a23c 112 struct mlx5_priv *priv = dev->data->dev_private;
11fdf7f2
TL
113 int ret;
114
115 dev->data->all_multicast = 0;
116 if (priv->config.vf)
117 mlx5_nl_allmulti(dev, 0);
118 ret = mlx5_traffic_restart(dev);
119 if (ret)
120 DRV_LOG(ERR, "port %u cannot disable allmulicast mode: %s",
121 dev->data->port_id, strerror(rte_errno));
122}