4925fd893f7beca489917c7827d568b3f35d0f45
[dpdk.git] / drivers / net / mlx5 / windows / mlx5_ethdev_os.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2020 Mellanox Technologies, Ltd
3  */
4 #include <stdio.h>
5
6 #include <rte_errno.h>
7 #include <rte_ether.h>
8 #include <rte_ethdev_driver.h>
9 #include <rte_interrupts.h>
10
11 #include <mlx5_glue.h>
12 #include <mlx5_devx_cmds.h>
13 #include <mlx5_common.h>
14 #include <mlx5_win_ext.h>
15 #include <mlx5_malloc.h>
16 #include <mlx5.h>
17
18 /**
19  * Get MAC address by querying netdevice.
20  *
21  * @param[in] dev
22  *   Pointer to Ethernet device.
23  * @param[out] mac
24  *   MAC address output buffer.
25  *
26  * @return
27  *   0 on success, a negative errno value otherwise and rte_errno is set.
28  */
29 int
30 mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
31 {
32         struct mlx5_priv *priv;
33         mlx5_context_st *context_obj;
34
35         if (!dev) {
36                 rte_errno = EINVAL;
37                 return -rte_errno;
38         }
39         priv = dev->data->dev_private;
40         context_obj = (mlx5_context_st *)priv->sh->ctx;
41         memcpy(mac, context_obj->mlx5_dev.eth_mac, RTE_ETHER_ADDR_LEN);
42         return 0;
43 }
44
45 /**
46  * Set device MTU.
47  *
48  * @param dev
49  *   Pointer to Ethernet device.
50  * @param mtu
51  *   MTU value to set.
52  *
53  * @return
54  *   0 on success, a negative errno value otherwise and rte_errno is set.
55  */
56 int
57 mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
58 {
59         RTE_SET_USED(dev);
60         RTE_SET_USED(mtu);
61         return -ENOTSUP;
62 }
63
64 /*
65  * Unregister callback handler safely. The handler may be active
66  * while we are trying to unregister it, in this case code -EAGAIN
67  * is returned by rte_intr_callback_unregister(). This routine checks
68  * the return code and tries to unregister handler again.
69  *
70  * @param handle
71  *   interrupt handle
72  * @param cb_fn
73  *   pointer to callback routine
74  * @cb_arg
75  *   opaque callback parameter
76  */
77 void
78 mlx5_intr_callback_unregister(const struct rte_intr_handle *handle,
79                               rte_intr_callback_fn cb_fn, void *cb_arg)
80 {
81         RTE_SET_USED(handle);
82         RTE_SET_USED(cb_fn);
83         RTE_SET_USED(cb_arg);
84 }
85
86 /**
87  * DPDK callback to get flow control status.
88  *
89  * @param dev
90  *   Pointer to Ethernet device structure.
91  * @param[out] fc_conf
92  *   Flow control output buffer.
93  *
94  * @return
95  *   0 on success, a negative errno value otherwise and rte_errno is set.
96  */
97 int
98 mlx5_dev_get_flow_ctrl(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
99 {
100         RTE_SET_USED(dev);
101         RTE_SET_USED(fc_conf);
102         return -ENOTSUP;
103 }
104
105 /**
106  * DPDK callback to modify flow control parameters.
107  *
108  * @param dev
109  *   Pointer to Ethernet device structure.
110  * @param[in] fc_conf
111  *   Flow control parameters.
112  *
113  * @return
114  *   0 on success, a negative errno value otherwise and rte_errno is set.
115  */
116 int
117 mlx5_dev_set_flow_ctrl(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
118 {
119         RTE_SET_USED(dev);
120         RTE_SET_USED(fc_conf);
121         return -ENOTSUP;
122 }
123
124 /**
125  * Query the number of statistics provided by ETHTOOL.
126  *
127  * @param dev
128  *   Pointer to Ethernet device.
129  *
130  * @return
131  *   Number of statistics on success, negative errno value otherwise and
132  *   rte_errno is set.
133  */
134 int
135 mlx5_os_get_stats_n(struct rte_eth_dev *dev)
136 {
137         RTE_SET_USED(dev);
138         return -ENOTSUP;
139 }
140
141 /**
142  * Init the structures to read device counters.
143  *
144  * @param dev
145  *   Pointer to Ethernet device.
146  */
147 void
148 mlx5_os_stats_init(struct rte_eth_dev *dev)
149 {
150         RTE_SET_USED(dev);
151 }
152
153 /**
154  * Read device counters table.
155  *
156  * @param dev
157  *   Pointer to Ethernet device.
158  * @param[out] stats
159  *   Counters table output buffer.
160  *
161  * @return
162  *   0 on success and stats is filled, negative errno value otherwise and
163  *   rte_errno is set.
164  */
165 int
166 mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats)
167 {
168         RTE_SET_USED(dev);
169         RTE_SET_USED(stats);
170         return -ENOTSUP;
171 }
172
173 /**
174  * DPDK callback to bring the link DOWN.
175  *
176  * @param dev
177  *   Pointer to Ethernet device structure.
178  *
179  * @return
180  *   0 on success, a negative errno value otherwise
181  */
182 int
183 mlx5_set_link_down(struct rte_eth_dev *dev)
184 {
185         RTE_SET_USED(dev);
186         return -ENOTSUP;
187 }
188
189 /**
190  * DPDK callback to bring the link UP.
191  *
192  * @param dev
193  *   Pointer to Ethernet device structure.
194  *
195  * @return
196  *   0 on success, a negative errno value otherwise
197  */
198 int
199 mlx5_set_link_up(struct rte_eth_dev *dev)
200 {
201         RTE_SET_USED(dev);
202         return -ENOTSUP;
203 }
204
205 /**
206  * DPDK callback to retrieve plug-in module EEPROM information (type and size).
207  *
208  * @param dev
209  *   Pointer to Ethernet device structure.
210  * @param[out] modinfo
211  *   Storage for plug-in module EEPROM information.
212  *
213  * @return
214  *   0 on success, a negative errno value otherwise and rte_errno is set.
215  */
216 int
217 mlx5_get_module_info(struct rte_eth_dev *dev,
218                      struct rte_eth_dev_module_info *modinfo)
219 {
220         RTE_SET_USED(dev);
221         RTE_SET_USED(modinfo);
222         return -ENOTSUP;
223 }
224
225 /**
226  * DPDK callback to retrieve plug-in module EEPROM data.
227  *
228  * @param dev
229  *   Pointer to Ethernet device structure.
230  * @param[out] info
231  *   Storage for plug-in module EEPROM data.
232  *
233  * @return
234  *   0 on success, a negative errno value otherwise and rte_errno is set.
235  */
236 int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
237                            struct rte_dev_eeprom_info *info)
238 {
239         RTE_SET_USED(dev);
240         RTE_SET_USED(info);
241         return -ENOTSUP;
242 }