net/mlx5: separate Tx function declarations to another file
[dpdk.git] / drivers / net / mlx5 / mlx5_rxmode.c
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 #include <ethdev_driver.h>
11
12 #include <mlx5_glue.h>
13 #include "mlx5.h"
14 #include "mlx5_utils.h"
15
16 /**
17  * DPDK callback to enable promiscuous mode.
18  *
19  * @param dev
20  *   Pointer to Ethernet device structure.
21  *
22  * @return
23  *   0 on success, a negative errno value otherwise and rte_errno is set.
24  */
25 int
26 mlx5_promiscuous_enable(struct rte_eth_dev *dev)
27 {
28         struct mlx5_priv *priv = dev->data->dev_private;
29         int ret;
30
31         dev->data->promiscuous = 1;
32         if (priv->isolated) {
33                 DRV_LOG(WARNING,
34                         "port %u cannot enable promiscuous mode"
35                         " in flow isolation mode",
36                         dev->data->port_id);
37                 return 0;
38         }
39         if (priv->config.vf) {
40                 ret = mlx5_os_set_promisc(dev, 1);
41                 if (ret)
42                         return ret;
43         }
44         ret = mlx5_traffic_restart(dev);
45         if (ret)
46                 DRV_LOG(ERR, "port %u cannot enable promiscuous mode: %s",
47                         dev->data->port_id, strerror(rte_errno));
48
49         /*
50          * rte_eth_dev_promiscuous_enable() rollback
51          * dev->data->promiscuous in the case of failure.
52          */
53         return ret;
54 }
55
56 /**
57  * DPDK callback to disable promiscuous mode.
58  *
59  * @param dev
60  *   Pointer to Ethernet device structure.
61  *
62  * @return
63  *   0 on success, a negative errno value otherwise and rte_errno is set.
64  */
65 int
66 mlx5_promiscuous_disable(struct rte_eth_dev *dev)
67 {
68         struct mlx5_priv *priv = dev->data->dev_private;
69         int ret;
70
71         dev->data->promiscuous = 0;
72         if (priv->config.vf) {
73                 ret = mlx5_os_set_promisc(dev, 0);
74                 if (ret)
75                         return ret;
76         }
77         ret = mlx5_traffic_restart(dev);
78         if (ret)
79                 DRV_LOG(ERR, "port %u cannot disable promiscuous mode: %s",
80                         dev->data->port_id, strerror(rte_errno));
81
82         /*
83          * rte_eth_dev_promiscuous_disable() rollback
84          * dev->data->promiscuous in the case of failure.
85          */
86         return ret;
87 }
88
89 /**
90  * DPDK callback to enable allmulti mode.
91  *
92  * @param dev
93  *   Pointer to Ethernet device structure.
94  *
95  * @return
96  *   0 on success, a negative errno value otherwise and rte_errno is set.
97  */
98 int
99 mlx5_allmulticast_enable(struct rte_eth_dev *dev)
100 {
101         struct mlx5_priv *priv = dev->data->dev_private;
102         int ret;
103
104         dev->data->all_multicast = 1;
105         if (priv->isolated) {
106                 DRV_LOG(WARNING,
107                         "port %u cannot enable allmulticast mode"
108                         " in flow isolation mode",
109                         dev->data->port_id);
110                 return 0;
111         }
112         if (priv->config.vf) {
113                 ret = mlx5_os_set_allmulti(dev, 1);
114                 if (ret)
115                         goto error;
116         }
117         ret = mlx5_traffic_restart(dev);
118         if (ret)
119                 DRV_LOG(ERR, "port %u cannot enable allmulicast mode: %s",
120                         dev->data->port_id, strerror(rte_errno));
121 error:
122         /*
123          * rte_eth_allmulticast_enable() rollback
124          * dev->data->all_multicast in the case of failure.
125          */
126         return ret;
127 }
128
129 /**
130  * DPDK callback to disable allmulti mode.
131  *
132  * @param dev
133  *   Pointer to Ethernet device structure.
134  *
135  * @return
136  *   0 on success, a negative errno value otherwise and rte_errno is set.
137  */
138 int
139 mlx5_allmulticast_disable(struct rte_eth_dev *dev)
140 {
141         struct mlx5_priv *priv = dev->data->dev_private;
142         int ret;
143
144         dev->data->all_multicast = 0;
145         if (priv->config.vf) {
146                 ret = mlx5_os_set_allmulti(dev, 0);
147                 if (ret)
148                         goto error;
149         }
150         ret = mlx5_traffic_restart(dev);
151         if (ret)
152                 DRV_LOG(ERR, "port %u cannot disable allmulicast mode: %s",
153                         dev->data->port_id, strerror(rte_errno));
154 error:
155         /*
156          * rte_eth_allmulticast_disable() rollback
157          * dev->data->all_multicast in the case of failure.
158          */
159         return ret;
160 }