New upstream version 18.11-rc1
[deb_dpdk.git] / drivers / net / failsafe / failsafe_ops.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2017 6WIND S.A.
3  * Copyright 2017 Mellanox Technologies, Ltd
4  */
5
6 #include <stdbool.h>
7 #include <stdint.h>
8 #include <unistd.h>
9
10 #include <rte_debug.h>
11 #include <rte_atomic.h>
12 #include <rte_ethdev_driver.h>
13 #include <rte_malloc.h>
14 #include <rte_flow.h>
15 #include <rte_cycles.h>
16 #include <rte_ethdev.h>
17
18 #include "failsafe_private.h"
19
20 static struct rte_eth_dev_info default_infos = {
21         /* Max possible number of elements */
22         .max_rx_pktlen = UINT32_MAX,
23         .max_rx_queues = RTE_MAX_QUEUES_PER_PORT,
24         .max_tx_queues = RTE_MAX_QUEUES_PER_PORT,
25         .max_mac_addrs = FAILSAFE_MAX_ETHADDR,
26         .max_hash_mac_addrs = UINT32_MAX,
27         .max_vfs = UINT16_MAX,
28         .max_vmdq_pools = UINT16_MAX,
29         .rx_desc_lim = {
30                 .nb_max = UINT16_MAX,
31                 .nb_min = 0,
32                 .nb_align = 1,
33                 .nb_seg_max = UINT16_MAX,
34                 .nb_mtu_seg_max = UINT16_MAX,
35         },
36         .tx_desc_lim = {
37                 .nb_max = UINT16_MAX,
38                 .nb_min = 0,
39                 .nb_align = 1,
40                 .nb_seg_max = UINT16_MAX,
41                 .nb_mtu_seg_max = UINT16_MAX,
42         },
43         /*
44          * Set of capabilities that can be verified upon
45          * configuring a sub-device.
46          */
47         .rx_offload_capa =
48                 DEV_RX_OFFLOAD_VLAN_STRIP |
49                 DEV_RX_OFFLOAD_IPV4_CKSUM |
50                 DEV_RX_OFFLOAD_UDP_CKSUM |
51                 DEV_RX_OFFLOAD_TCP_CKSUM |
52                 DEV_RX_OFFLOAD_TCP_LRO |
53                 DEV_RX_OFFLOAD_QINQ_STRIP |
54                 DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM |
55                 DEV_RX_OFFLOAD_MACSEC_STRIP |
56                 DEV_RX_OFFLOAD_HEADER_SPLIT |
57                 DEV_RX_OFFLOAD_VLAN_FILTER |
58                 DEV_RX_OFFLOAD_VLAN_EXTEND |
59                 DEV_RX_OFFLOAD_JUMBO_FRAME |
60                 DEV_RX_OFFLOAD_SCATTER |
61                 DEV_RX_OFFLOAD_TIMESTAMP |
62                 DEV_RX_OFFLOAD_SECURITY,
63         .rx_queue_offload_capa =
64                 DEV_RX_OFFLOAD_VLAN_STRIP |
65                 DEV_RX_OFFLOAD_IPV4_CKSUM |
66                 DEV_RX_OFFLOAD_UDP_CKSUM |
67                 DEV_RX_OFFLOAD_TCP_CKSUM |
68                 DEV_RX_OFFLOAD_TCP_LRO |
69                 DEV_RX_OFFLOAD_QINQ_STRIP |
70                 DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM |
71                 DEV_RX_OFFLOAD_MACSEC_STRIP |
72                 DEV_RX_OFFLOAD_HEADER_SPLIT |
73                 DEV_RX_OFFLOAD_VLAN_FILTER |
74                 DEV_RX_OFFLOAD_VLAN_EXTEND |
75                 DEV_RX_OFFLOAD_JUMBO_FRAME |
76                 DEV_RX_OFFLOAD_SCATTER |
77                 DEV_RX_OFFLOAD_TIMESTAMP |
78                 DEV_RX_OFFLOAD_SECURITY,
79         .tx_offload_capa =
80                 DEV_TX_OFFLOAD_MULTI_SEGS |
81                 DEV_TX_OFFLOAD_IPV4_CKSUM |
82                 DEV_TX_OFFLOAD_UDP_CKSUM |
83                 DEV_TX_OFFLOAD_TCP_CKSUM |
84                 DEV_TX_OFFLOAD_TCP_TSO,
85         .flow_type_rss_offloads =
86                         ETH_RSS_IP |
87                         ETH_RSS_UDP |
88                         ETH_RSS_TCP,
89         .dev_capa =
90                 RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
91                 RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP,
92 };
93
94 static int
95 fs_dev_configure(struct rte_eth_dev *dev)
96 {
97         struct sub_device *sdev;
98         uint8_t i;
99         int ret;
100
101         fs_lock(dev, 0);
102         FOREACH_SUBDEV(sdev, i, dev) {
103                 int rmv_interrupt = 0;
104                 int lsc_interrupt = 0;
105                 int lsc_enabled;
106
107                 if (sdev->state != DEV_PROBED &&
108                     !(PRIV(dev)->alarm_lock == 0 && sdev->state == DEV_ACTIVE))
109                         continue;
110
111                 rmv_interrupt = ETH(sdev)->data->dev_flags &
112                                 RTE_ETH_DEV_INTR_RMV;
113                 if (rmv_interrupt) {
114                         DEBUG("Enabling RMV interrupts for sub_device %d", i);
115                         dev->data->dev_conf.intr_conf.rmv = 1;
116                 } else {
117                         DEBUG("sub_device %d does not support RMV event", i);
118                 }
119                 lsc_enabled = dev->data->dev_conf.intr_conf.lsc;
120                 lsc_interrupt = lsc_enabled &&
121                                 (ETH(sdev)->data->dev_flags &
122                                  RTE_ETH_DEV_INTR_LSC);
123                 if (lsc_interrupt) {
124                         DEBUG("Enabling LSC interrupts for sub_device %d", i);
125                         dev->data->dev_conf.intr_conf.lsc = 1;
126                 } else if (lsc_enabled && !lsc_interrupt) {
127                         DEBUG("Disabling LSC interrupts for sub_device %d", i);
128                         dev->data->dev_conf.intr_conf.lsc = 0;
129                 }
130                 DEBUG("Configuring sub-device %d", i);
131                 ret = rte_eth_dev_configure(PORT_ID(sdev),
132                                         dev->data->nb_rx_queues,
133                                         dev->data->nb_tx_queues,
134                                         &dev->data->dev_conf);
135                 if (ret) {
136                         if (!fs_err(sdev, ret))
137                                 continue;
138                         ERROR("Could not configure sub_device %d", i);
139                         fs_unlock(dev, 0);
140                         return ret;
141                 }
142                 if (rmv_interrupt && sdev->rmv_callback == 0) {
143                         ret = rte_eth_dev_callback_register(PORT_ID(sdev),
144                                         RTE_ETH_EVENT_INTR_RMV,
145                                         failsafe_eth_rmv_event_callback,
146                                         sdev);
147                         if (ret)
148                                 WARN("Failed to register RMV callback for sub_device %d",
149                                      SUB_ID(sdev));
150                         else
151                                 sdev->rmv_callback = 1;
152                 }
153                 dev->data->dev_conf.intr_conf.rmv = 0;
154                 if (lsc_interrupt && sdev->lsc_callback == 0) {
155                         ret = rte_eth_dev_callback_register(PORT_ID(sdev),
156                                                 RTE_ETH_EVENT_INTR_LSC,
157                                                 failsafe_eth_lsc_event_callback,
158                                                 dev);
159                         if (ret)
160                                 WARN("Failed to register LSC callback for sub_device %d",
161                                      SUB_ID(sdev));
162                         else
163                                 sdev->lsc_callback = 1;
164                 }
165                 dev->data->dev_conf.intr_conf.lsc = lsc_enabled;
166                 sdev->state = DEV_ACTIVE;
167         }
168         if (PRIV(dev)->state < DEV_ACTIVE)
169                 PRIV(dev)->state = DEV_ACTIVE;
170         fs_unlock(dev, 0);
171         return 0;
172 }
173
174 static void
175 fs_set_queues_state_start(struct rte_eth_dev *dev)
176 {
177         struct rxq *rxq;
178         struct txq *txq;
179         uint16_t i;
180
181         for (i = 0; i < dev->data->nb_rx_queues; i++) {
182                 rxq = dev->data->rx_queues[i];
183                 if (rxq != NULL && !rxq->info.conf.rx_deferred_start)
184                         dev->data->rx_queue_state[i] =
185                                                 RTE_ETH_QUEUE_STATE_STARTED;
186         }
187         for (i = 0; i < dev->data->nb_tx_queues; i++) {
188                 txq = dev->data->tx_queues[i];
189                 if (txq != NULL && !txq->info.conf.tx_deferred_start)
190                         dev->data->tx_queue_state[i] =
191                                                 RTE_ETH_QUEUE_STATE_STARTED;
192         }
193 }
194
195 static int
196 fs_dev_start(struct rte_eth_dev *dev)
197 {
198         struct sub_device *sdev;
199         uint8_t i;
200         int ret;
201
202         fs_lock(dev, 0);
203         ret = failsafe_rx_intr_install(dev);
204         if (ret) {
205                 fs_unlock(dev, 0);
206                 return ret;
207         }
208         FOREACH_SUBDEV(sdev, i, dev) {
209                 if (sdev->state != DEV_ACTIVE)
210                         continue;
211                 DEBUG("Starting sub_device %d", i);
212                 ret = rte_eth_dev_start(PORT_ID(sdev));
213                 if (ret) {
214                         if (!fs_err(sdev, ret))
215                                 continue;
216                         fs_unlock(dev, 0);
217                         return ret;
218                 }
219                 ret = failsafe_rx_intr_install_subdevice(sdev);
220                 if (ret) {
221                         if (!fs_err(sdev, ret))
222                                 continue;
223                         rte_eth_dev_stop(PORT_ID(sdev));
224                         fs_unlock(dev, 0);
225                         return ret;
226                 }
227                 sdev->state = DEV_STARTED;
228         }
229         if (PRIV(dev)->state < DEV_STARTED) {
230                 PRIV(dev)->state = DEV_STARTED;
231                 fs_set_queues_state_start(dev);
232         }
233         fs_switch_dev(dev, NULL);
234         fs_unlock(dev, 0);
235         return 0;
236 }
237
238 static void
239 fs_set_queues_state_stop(struct rte_eth_dev *dev)
240 {
241         uint16_t i;
242
243         for (i = 0; i < dev->data->nb_rx_queues; i++)
244                 if (dev->data->rx_queues[i] != NULL)
245                         dev->data->rx_queue_state[i] =
246                                                 RTE_ETH_QUEUE_STATE_STOPPED;
247         for (i = 0; i < dev->data->nb_tx_queues; i++)
248                 if (dev->data->tx_queues[i] != NULL)
249                         dev->data->tx_queue_state[i] =
250                                                 RTE_ETH_QUEUE_STATE_STOPPED;
251 }
252
253 static void
254 fs_dev_stop(struct rte_eth_dev *dev)
255 {
256         struct sub_device *sdev;
257         uint8_t i;
258
259         fs_lock(dev, 0);
260         PRIV(dev)->state = DEV_STARTED - 1;
261         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_STARTED) {
262                 rte_eth_dev_stop(PORT_ID(sdev));
263                 failsafe_rx_intr_uninstall_subdevice(sdev);
264                 sdev->state = DEV_STARTED - 1;
265         }
266         failsafe_rx_intr_uninstall(dev);
267         fs_set_queues_state_stop(dev);
268         fs_unlock(dev, 0);
269 }
270
271 static int
272 fs_dev_set_link_up(struct rte_eth_dev *dev)
273 {
274         struct sub_device *sdev;
275         uint8_t i;
276         int ret;
277
278         fs_lock(dev, 0);
279         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
280                 DEBUG("Calling rte_eth_dev_set_link_up on sub_device %d", i);
281                 ret = rte_eth_dev_set_link_up(PORT_ID(sdev));
282                 if ((ret = fs_err(sdev, ret))) {
283                         ERROR("Operation rte_eth_dev_set_link_up failed for sub_device %d"
284                               " with error %d", i, ret);
285                         fs_unlock(dev, 0);
286                         return ret;
287                 }
288         }
289         fs_unlock(dev, 0);
290         return 0;
291 }
292
293 static int
294 fs_dev_set_link_down(struct rte_eth_dev *dev)
295 {
296         struct sub_device *sdev;
297         uint8_t i;
298         int ret;
299
300         fs_lock(dev, 0);
301         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
302                 DEBUG("Calling rte_eth_dev_set_link_down on sub_device %d", i);
303                 ret = rte_eth_dev_set_link_down(PORT_ID(sdev));
304                 if ((ret = fs_err(sdev, ret))) {
305                         ERROR("Operation rte_eth_dev_set_link_down failed for sub_device %d"
306                               " with error %d", i, ret);
307                         fs_unlock(dev, 0);
308                         return ret;
309                 }
310         }
311         fs_unlock(dev, 0);
312         return 0;
313 }
314
315 static void fs_dev_free_queues(struct rte_eth_dev *dev);
316 static void
317 fs_dev_close(struct rte_eth_dev *dev)
318 {
319         struct sub_device *sdev;
320         uint8_t i;
321
322         fs_lock(dev, 0);
323         failsafe_hotplug_alarm_cancel(dev);
324         if (PRIV(dev)->state == DEV_STARTED)
325                 dev->dev_ops->dev_stop(dev);
326         PRIV(dev)->state = DEV_ACTIVE - 1;
327         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
328                 DEBUG("Closing sub_device %d", i);
329                 failsafe_eth_dev_unregister_callbacks(sdev);
330                 rte_eth_dev_close(PORT_ID(sdev));
331                 sdev->state = DEV_ACTIVE - 1;
332         }
333         fs_dev_free_queues(dev);
334         fs_unlock(dev, 0);
335 }
336
337 static int
338 fs_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
339 {
340         struct sub_device *sdev;
341         uint8_t i;
342         int ret;
343         int err = 0;
344         bool failure = true;
345
346         fs_lock(dev, 0);
347         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
348                 uint16_t port_id = ETH(sdev)->data->port_id;
349
350                 ret = rte_eth_dev_rx_queue_stop(port_id, rx_queue_id);
351                 ret = fs_err(sdev, ret);
352                 if (ret) {
353                         ERROR("Rx queue stop failed for subdevice %d", i);
354                         err = ret;
355                 } else {
356                         failure = false;
357                 }
358         }
359         dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
360         fs_unlock(dev, 0);
361         /* Return 0 in case of at least one successful queue stop */
362         return (failure) ? err : 0;
363 }
364
365 static int
366 fs_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
367 {
368         struct sub_device *sdev;
369         uint8_t i;
370         int ret;
371
372         fs_lock(dev, 0);
373         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
374                 uint16_t port_id = ETH(sdev)->data->port_id;
375
376                 ret = rte_eth_dev_rx_queue_start(port_id, rx_queue_id);
377                 ret = fs_err(sdev, ret);
378                 if (ret) {
379                         ERROR("Rx queue start failed for subdevice %d", i);
380                         fs_rx_queue_stop(dev, rx_queue_id);
381                         fs_unlock(dev, 0);
382                         return ret;
383                 }
384         }
385         dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
386         fs_unlock(dev, 0);
387         return 0;
388 }
389
390 static int
391 fs_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
392 {
393         struct sub_device *sdev;
394         uint8_t i;
395         int ret;
396         int err = 0;
397         bool failure = true;
398
399         fs_lock(dev, 0);
400         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
401                 uint16_t port_id = ETH(sdev)->data->port_id;
402
403                 ret = rte_eth_dev_tx_queue_stop(port_id, tx_queue_id);
404                 ret = fs_err(sdev, ret);
405                 if (ret) {
406                         ERROR("Tx queue stop failed for subdevice %d", i);
407                         err = ret;
408                 } else {
409                         failure = false;
410                 }
411         }
412         dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
413         fs_unlock(dev, 0);
414         /* Return 0 in case of at least one successful queue stop */
415         return (failure) ? err : 0;
416 }
417
418 static int
419 fs_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
420 {
421         struct sub_device *sdev;
422         uint8_t i;
423         int ret;
424
425         fs_lock(dev, 0);
426         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
427                 uint16_t port_id = ETH(sdev)->data->port_id;
428
429                 ret = rte_eth_dev_tx_queue_start(port_id, tx_queue_id);
430                 ret = fs_err(sdev, ret);
431                 if (ret) {
432                         ERROR("Tx queue start failed for subdevice %d", i);
433                         fs_tx_queue_stop(dev, tx_queue_id);
434                         fs_unlock(dev, 0);
435                         return ret;
436                 }
437         }
438         dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
439         fs_unlock(dev, 0);
440         return 0;
441 }
442
443 static void
444 fs_rx_queue_release(void *queue)
445 {
446         struct rte_eth_dev *dev;
447         struct sub_device *sdev;
448         uint8_t i;
449         struct rxq *rxq;
450
451         if (queue == NULL)
452                 return;
453         rxq = queue;
454         dev = rxq->priv->dev;
455         fs_lock(dev, 0);
456         if (rxq->event_fd > 0)
457                 close(rxq->event_fd);
458         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
459                 if (ETH(sdev)->data->rx_queues != NULL &&
460                     ETH(sdev)->data->rx_queues[rxq->qid] != NULL) {
461                         SUBOPS(sdev, rx_queue_release)
462                                 (ETH(sdev)->data->rx_queues[rxq->qid]);
463                 }
464         }
465         dev->data->rx_queues[rxq->qid] = NULL;
466         rte_free(rxq);
467         fs_unlock(dev, 0);
468 }
469
470 static int
471 fs_rx_queue_setup(struct rte_eth_dev *dev,
472                 uint16_t rx_queue_id,
473                 uint16_t nb_rx_desc,
474                 unsigned int socket_id,
475                 const struct rte_eth_rxconf *rx_conf,
476                 struct rte_mempool *mb_pool)
477 {
478         /*
479          * FIXME: Add a proper interface in rte_eal_interrupts for
480          * allocating eventfd as an interrupt vector.
481          * For the time being, fake as if we are using MSIX interrupts,
482          * this will cause rte_intr_efd_enable to allocate an eventfd for us.
483          */
484         struct rte_intr_handle intr_handle = {
485                 .type = RTE_INTR_HANDLE_VFIO_MSIX,
486                 .efds = { -1, },
487         };
488         struct sub_device *sdev;
489         struct rxq *rxq;
490         uint8_t i;
491         int ret;
492
493         fs_lock(dev, 0);
494         if (rx_conf->rx_deferred_start) {
495                 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) {
496                         if (SUBOPS(sdev, rx_queue_start) == NULL) {
497                                 ERROR("Rx queue deferred start is not "
498                                         "supported for subdevice %d", i);
499                                 fs_unlock(dev, 0);
500                                 return -EINVAL;
501                         }
502                 }
503         }
504         rxq = dev->data->rx_queues[rx_queue_id];
505         if (rxq != NULL) {
506                 fs_rx_queue_release(rxq);
507                 dev->data->rx_queues[rx_queue_id] = NULL;
508         }
509         rxq = rte_zmalloc(NULL,
510                           sizeof(*rxq) +
511                           sizeof(rte_atomic64_t) * PRIV(dev)->subs_tail,
512                           RTE_CACHE_LINE_SIZE);
513         if (rxq == NULL) {
514                 fs_unlock(dev, 0);
515                 return -ENOMEM;
516         }
517         FOREACH_SUBDEV(sdev, i, dev)
518                 rte_atomic64_init(&rxq->refcnt[i]);
519         rxq->qid = rx_queue_id;
520         rxq->socket_id = socket_id;
521         rxq->info.mp = mb_pool;
522         rxq->info.conf = *rx_conf;
523         rxq->info.nb_desc = nb_rx_desc;
524         rxq->priv = PRIV(dev);
525         rxq->sdev = PRIV(dev)->subs;
526         ret = rte_intr_efd_enable(&intr_handle, 1);
527         if (ret < 0) {
528                 fs_unlock(dev, 0);
529                 return ret;
530         }
531         rxq->event_fd = intr_handle.efds[0];
532         dev->data->rx_queues[rx_queue_id] = rxq;
533         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
534                 ret = rte_eth_rx_queue_setup(PORT_ID(sdev),
535                                 rx_queue_id,
536                                 nb_rx_desc, socket_id,
537                                 rx_conf, mb_pool);
538                 if ((ret = fs_err(sdev, ret))) {
539                         ERROR("RX queue setup failed for sub_device %d", i);
540                         goto free_rxq;
541                 }
542         }
543         fs_unlock(dev, 0);
544         return 0;
545 free_rxq:
546         fs_rx_queue_release(rxq);
547         fs_unlock(dev, 0);
548         return ret;
549 }
550
551 static int
552 fs_rx_intr_enable(struct rte_eth_dev *dev, uint16_t idx)
553 {
554         struct rxq *rxq;
555         struct sub_device *sdev;
556         uint8_t i;
557         int ret;
558         int rc = 0;
559
560         fs_lock(dev, 0);
561         if (idx >= dev->data->nb_rx_queues) {
562                 rc = -EINVAL;
563                 goto unlock;
564         }
565         rxq = dev->data->rx_queues[idx];
566         if (rxq == NULL || rxq->event_fd <= 0) {
567                 rc = -EINVAL;
568                 goto unlock;
569         }
570         /* Fail if proxy service is nor running. */
571         if (PRIV(dev)->rxp.sstate != SS_RUNNING) {
572                 ERROR("failsafe interrupt services are not running");
573                 rc = -EAGAIN;
574                 goto unlock;
575         }
576         rxq->enable_events = 1;
577         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
578                 ret = rte_eth_dev_rx_intr_enable(PORT_ID(sdev), idx);
579                 ret = fs_err(sdev, ret);
580                 if (ret)
581                         rc = ret;
582         }
583 unlock:
584         fs_unlock(dev, 0);
585         if (rc)
586                 rte_errno = -rc;
587         return rc;
588 }
589
590 static int
591 fs_rx_intr_disable(struct rte_eth_dev *dev, uint16_t idx)
592 {
593         struct rxq *rxq;
594         struct sub_device *sdev;
595         uint64_t u64;
596         uint8_t i;
597         int rc = 0;
598         int ret;
599
600         fs_lock(dev, 0);
601         if (idx >= dev->data->nb_rx_queues) {
602                 rc = -EINVAL;
603                 goto unlock;
604         }
605         rxq = dev->data->rx_queues[idx];
606         if (rxq == NULL || rxq->event_fd <= 0) {
607                 rc = -EINVAL;
608                 goto unlock;
609         }
610         rxq->enable_events = 0;
611         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
612                 ret = rte_eth_dev_rx_intr_disable(PORT_ID(sdev), idx);
613                 ret = fs_err(sdev, ret);
614                 if (ret)
615                         rc = ret;
616         }
617         /* Clear pending events */
618         while (read(rxq->event_fd, &u64, sizeof(uint64_t)) >  0)
619                 ;
620 unlock:
621         fs_unlock(dev, 0);
622         if (rc)
623                 rte_errno = -rc;
624         return rc;
625 }
626
627 static void
628 fs_tx_queue_release(void *queue)
629 {
630         struct rte_eth_dev *dev;
631         struct sub_device *sdev;
632         uint8_t i;
633         struct txq *txq;
634
635         if (queue == NULL)
636                 return;
637         txq = queue;
638         dev = txq->priv->dev;
639         fs_lock(dev, 0);
640         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
641                 if (ETH(sdev)->data->tx_queues != NULL &&
642                     ETH(sdev)->data->tx_queues[txq->qid] != NULL) {
643                         SUBOPS(sdev, tx_queue_release)
644                                 (ETH(sdev)->data->tx_queues[txq->qid]);
645                 }
646         }
647         dev->data->tx_queues[txq->qid] = NULL;
648         rte_free(txq);
649         fs_unlock(dev, 0);
650 }
651
652 static int
653 fs_tx_queue_setup(struct rte_eth_dev *dev,
654                 uint16_t tx_queue_id,
655                 uint16_t nb_tx_desc,
656                 unsigned int socket_id,
657                 const struct rte_eth_txconf *tx_conf)
658 {
659         struct sub_device *sdev;
660         struct txq *txq;
661         uint8_t i;
662         int ret;
663
664         fs_lock(dev, 0);
665         if (tx_conf->tx_deferred_start) {
666                 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) {
667                         if (SUBOPS(sdev, tx_queue_start) == NULL) {
668                                 ERROR("Tx queue deferred start is not "
669                                         "supported for subdevice %d", i);
670                                 fs_unlock(dev, 0);
671                                 return -EINVAL;
672                         }
673                 }
674         }
675         txq = dev->data->tx_queues[tx_queue_id];
676         if (txq != NULL) {
677                 fs_tx_queue_release(txq);
678                 dev->data->tx_queues[tx_queue_id] = NULL;
679         }
680         txq = rte_zmalloc("ethdev TX queue",
681                           sizeof(*txq) +
682                           sizeof(rte_atomic64_t) * PRIV(dev)->subs_tail,
683                           RTE_CACHE_LINE_SIZE);
684         if (txq == NULL) {
685                 fs_unlock(dev, 0);
686                 return -ENOMEM;
687         }
688         FOREACH_SUBDEV(sdev, i, dev)
689                 rte_atomic64_init(&txq->refcnt[i]);
690         txq->qid = tx_queue_id;
691         txq->socket_id = socket_id;
692         txq->info.conf = *tx_conf;
693         txq->info.nb_desc = nb_tx_desc;
694         txq->priv = PRIV(dev);
695         dev->data->tx_queues[tx_queue_id] = txq;
696         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
697                 ret = rte_eth_tx_queue_setup(PORT_ID(sdev),
698                                 tx_queue_id,
699                                 nb_tx_desc, socket_id,
700                                 tx_conf);
701                 if ((ret = fs_err(sdev, ret))) {
702                         ERROR("TX queue setup failed for sub_device %d", i);
703                         goto free_txq;
704                 }
705         }
706         fs_unlock(dev, 0);
707         return 0;
708 free_txq:
709         fs_tx_queue_release(txq);
710         fs_unlock(dev, 0);
711         return ret;
712 }
713
714 static void
715 fs_dev_free_queues(struct rte_eth_dev *dev)
716 {
717         uint16_t i;
718
719         for (i = 0; i < dev->data->nb_rx_queues; i++) {
720                 fs_rx_queue_release(dev->data->rx_queues[i]);
721                 dev->data->rx_queues[i] = NULL;
722         }
723         dev->data->nb_rx_queues = 0;
724         for (i = 0; i < dev->data->nb_tx_queues; i++) {
725                 fs_tx_queue_release(dev->data->tx_queues[i]);
726                 dev->data->tx_queues[i] = NULL;
727         }
728         dev->data->nb_tx_queues = 0;
729 }
730
731 static void
732 fs_promiscuous_enable(struct rte_eth_dev *dev)
733 {
734         struct sub_device *sdev;
735         uint8_t i;
736
737         fs_lock(dev, 0);
738         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
739                 rte_eth_promiscuous_enable(PORT_ID(sdev));
740         fs_unlock(dev, 0);
741 }
742
743 static void
744 fs_promiscuous_disable(struct rte_eth_dev *dev)
745 {
746         struct sub_device *sdev;
747         uint8_t i;
748
749         fs_lock(dev, 0);
750         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
751                 rte_eth_promiscuous_disable(PORT_ID(sdev));
752         fs_unlock(dev, 0);
753 }
754
755 static void
756 fs_allmulticast_enable(struct rte_eth_dev *dev)
757 {
758         struct sub_device *sdev;
759         uint8_t i;
760
761         fs_lock(dev, 0);
762         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
763                 rte_eth_allmulticast_enable(PORT_ID(sdev));
764         fs_unlock(dev, 0);
765 }
766
767 static void
768 fs_allmulticast_disable(struct rte_eth_dev *dev)
769 {
770         struct sub_device *sdev;
771         uint8_t i;
772
773         fs_lock(dev, 0);
774         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
775                 rte_eth_allmulticast_disable(PORT_ID(sdev));
776         fs_unlock(dev, 0);
777 }
778
779 static int
780 fs_link_update(struct rte_eth_dev *dev,
781                 int wait_to_complete)
782 {
783         struct sub_device *sdev;
784         uint8_t i;
785         int ret;
786
787         fs_lock(dev, 0);
788         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
789                 DEBUG("Calling link_update on sub_device %d", i);
790                 ret = (SUBOPS(sdev, link_update))(ETH(sdev), wait_to_complete);
791                 if (ret && ret != -1 && sdev->remove == 0 &&
792                     rte_eth_dev_is_removed(PORT_ID(sdev)) == 0) {
793                         ERROR("Link update failed for sub_device %d with error %d",
794                               i, ret);
795                         fs_unlock(dev, 0);
796                         return ret;
797                 }
798         }
799         if (TX_SUBDEV(dev)) {
800                 struct rte_eth_link *l1;
801                 struct rte_eth_link *l2;
802
803                 l1 = &dev->data->dev_link;
804                 l2 = &ETH(TX_SUBDEV(dev))->data->dev_link;
805                 if (memcmp(l1, l2, sizeof(*l1))) {
806                         *l1 = *l2;
807                         fs_unlock(dev, 0);
808                         return 0;
809                 }
810         }
811         fs_unlock(dev, 0);
812         return -1;
813 }
814
815 static int
816 fs_stats_get(struct rte_eth_dev *dev,
817              struct rte_eth_stats *stats)
818 {
819         struct rte_eth_stats backup;
820         struct sub_device *sdev;
821         uint8_t i;
822         int ret;
823
824         fs_lock(dev, 0);
825         rte_memcpy(stats, &PRIV(dev)->stats_accumulator, sizeof(*stats));
826         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
827                 struct rte_eth_stats *snapshot = &sdev->stats_snapshot.stats;
828                 uint64_t *timestamp = &sdev->stats_snapshot.timestamp;
829
830                 rte_memcpy(&backup, snapshot, sizeof(backup));
831                 ret = rte_eth_stats_get(PORT_ID(sdev), snapshot);
832                 if (ret) {
833                         if (!fs_err(sdev, ret)) {
834                                 rte_memcpy(snapshot, &backup, sizeof(backup));
835                                 goto inc;
836                         }
837                         ERROR("Operation rte_eth_stats_get failed for sub_device %d with error %d",
838                                   i, ret);
839                         *timestamp = 0;
840                         fs_unlock(dev, 0);
841                         return ret;
842                 }
843                 *timestamp = rte_rdtsc();
844 inc:
845                 failsafe_stats_increment(stats, snapshot);
846         }
847         fs_unlock(dev, 0);
848         return 0;
849 }
850
851 static void
852 fs_stats_reset(struct rte_eth_dev *dev)
853 {
854         struct sub_device *sdev;
855         uint8_t i;
856
857         fs_lock(dev, 0);
858         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
859                 rte_eth_stats_reset(PORT_ID(sdev));
860                 memset(&sdev->stats_snapshot, 0, sizeof(struct rte_eth_stats));
861         }
862         memset(&PRIV(dev)->stats_accumulator, 0, sizeof(struct rte_eth_stats));
863         fs_unlock(dev, 0);
864 }
865
866 /**
867  * Fail-safe dev_infos_get rules:
868  *
869  * No sub_device:
870  *   Numerables:
871  *      Use the maximum possible values for any field, so as not
872  *      to impede any further configuration effort.
873  *   Capabilities:
874  *      Limits capabilities to those that are understood by the
875  *      fail-safe PMD. This understanding stems from the fail-safe
876  *      being capable of verifying that the related capability is
877  *      expressed within the device configuration (struct rte_eth_conf).
878  *
879  * At least one probed sub_device:
880  *   Numerables:
881  *      Uses values from the active probed sub_device
882  *      The rationale here is that if any sub_device is less capable
883  *      (for example concerning the number of queues) than the active
884  *      sub_device, then its subsequent configuration will fail.
885  *      It is impossible to foresee this failure when the failing sub_device
886  *      is supposed to be plugged-in later on, so the configuration process
887  *      is the single point of failure and error reporting.
888  *   Capabilities:
889  *      Uses a logical AND of RX capabilities among
890  *      all sub_devices and the default capabilities.
891  *      Uses a logical AND of TX capabilities among
892  *      the active probed sub_device and the default capabilities.
893  *      Uses a logical AND of device capabilities among
894  *      all sub_devices and the default capabilities.
895  *
896  */
897 static void
898 fs_dev_infos_get(struct rte_eth_dev *dev,
899                   struct rte_eth_dev_info *infos)
900 {
901         struct sub_device *sdev;
902         uint8_t i;
903
904         sdev = TX_SUBDEV(dev);
905         if (sdev == NULL) {
906                 DEBUG("No probed device, using default infos");
907                 rte_memcpy(&PRIV(dev)->infos, &default_infos,
908                            sizeof(default_infos));
909         } else {
910                 uint64_t rx_offload_capa;
911                 uint64_t rxq_offload_capa;
912                 uint64_t rss_hf_offload_capa;
913                 uint64_t dev_capa;
914
915                 rx_offload_capa = default_infos.rx_offload_capa;
916                 rxq_offload_capa = default_infos.rx_queue_offload_capa;
917                 rss_hf_offload_capa = default_infos.flow_type_rss_offloads;
918                 dev_capa = default_infos.dev_capa;
919                 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) {
920                         rte_eth_dev_info_get(PORT_ID(sdev),
921                                         &PRIV(dev)->infos);
922                         rx_offload_capa &= PRIV(dev)->infos.rx_offload_capa;
923                         rxq_offload_capa &=
924                                         PRIV(dev)->infos.rx_queue_offload_capa;
925                         rss_hf_offload_capa &=
926                                         PRIV(dev)->infos.flow_type_rss_offloads;
927                         dev_capa &= PRIV(dev)->infos.dev_capa;
928                 }
929                 sdev = TX_SUBDEV(dev);
930                 rte_eth_dev_info_get(PORT_ID(sdev), &PRIV(dev)->infos);
931                 PRIV(dev)->infos.rx_offload_capa = rx_offload_capa;
932                 PRIV(dev)->infos.rx_queue_offload_capa = rxq_offload_capa;
933                 PRIV(dev)->infos.flow_type_rss_offloads = rss_hf_offload_capa;
934                 PRIV(dev)->infos.dev_capa = dev_capa;
935                 PRIV(dev)->infos.tx_offload_capa &=
936                                         default_infos.tx_offload_capa;
937                 PRIV(dev)->infos.tx_queue_offload_capa &=
938                                         default_infos.tx_queue_offload_capa;
939         }
940         rte_memcpy(infos, &PRIV(dev)->infos, sizeof(*infos));
941 }
942
943 static const uint32_t *
944 fs_dev_supported_ptypes_get(struct rte_eth_dev *dev)
945 {
946         struct sub_device *sdev;
947         struct rte_eth_dev *edev;
948         const uint32_t *ret;
949
950         fs_lock(dev, 0);
951         sdev = TX_SUBDEV(dev);
952         if (sdev == NULL) {
953                 ret = NULL;
954                 goto unlock;
955         }
956         edev = ETH(sdev);
957         /* ENOTSUP: counts as no supported ptypes */
958         if (SUBOPS(sdev, dev_supported_ptypes_get) == NULL) {
959                 ret = NULL;
960                 goto unlock;
961         }
962         /*
963          * The API does not permit to do a clean AND of all ptypes,
964          * It is also incomplete by design and we do not really care
965          * to have a best possible value in this context.
966          * We just return the ptypes of the device of highest
967          * priority, usually the PREFERRED device.
968          */
969         ret = SUBOPS(sdev, dev_supported_ptypes_get)(edev);
970 unlock:
971         fs_unlock(dev, 0);
972         return ret;
973 }
974
975 static int
976 fs_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
977 {
978         struct sub_device *sdev;
979         uint8_t i;
980         int ret;
981
982         fs_lock(dev, 0);
983         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
984                 DEBUG("Calling rte_eth_dev_set_mtu on sub_device %d", i);
985                 ret = rte_eth_dev_set_mtu(PORT_ID(sdev), mtu);
986                 if ((ret = fs_err(sdev, ret))) {
987                         ERROR("Operation rte_eth_dev_set_mtu failed for sub_device %d with error %d",
988                               i, ret);
989                         fs_unlock(dev, 0);
990                         return ret;
991                 }
992         }
993         fs_unlock(dev, 0);
994         return 0;
995 }
996
997 static int
998 fs_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
999 {
1000         struct sub_device *sdev;
1001         uint8_t i;
1002         int ret;
1003
1004         fs_lock(dev, 0);
1005         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
1006                 DEBUG("Calling rte_eth_dev_vlan_filter on sub_device %d", i);
1007                 ret = rte_eth_dev_vlan_filter(PORT_ID(sdev), vlan_id, on);
1008                 if ((ret = fs_err(sdev, ret))) {
1009                         ERROR("Operation rte_eth_dev_vlan_filter failed for sub_device %d"
1010                               " with error %d", i, ret);
1011                         fs_unlock(dev, 0);
1012                         return ret;
1013                 }
1014         }
1015         fs_unlock(dev, 0);
1016         return 0;
1017 }
1018
1019 static int
1020 fs_flow_ctrl_get(struct rte_eth_dev *dev,
1021                 struct rte_eth_fc_conf *fc_conf)
1022 {
1023         struct sub_device *sdev;
1024         int ret;
1025
1026         fs_lock(dev, 0);
1027         sdev = TX_SUBDEV(dev);
1028         if (sdev == NULL) {
1029                 ret = 0;
1030                 goto unlock;
1031         }
1032         if (SUBOPS(sdev, flow_ctrl_get) == NULL) {
1033                 ret = -ENOTSUP;
1034                 goto unlock;
1035         }
1036         ret = SUBOPS(sdev, flow_ctrl_get)(ETH(sdev), fc_conf);
1037 unlock:
1038         fs_unlock(dev, 0);
1039         return ret;
1040 }
1041
1042 static int
1043 fs_flow_ctrl_set(struct rte_eth_dev *dev,
1044                 struct rte_eth_fc_conf *fc_conf)
1045 {
1046         struct sub_device *sdev;
1047         uint8_t i;
1048         int ret;
1049
1050         fs_lock(dev, 0);
1051         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
1052                 DEBUG("Calling rte_eth_dev_flow_ctrl_set on sub_device %d", i);
1053                 ret = rte_eth_dev_flow_ctrl_set(PORT_ID(sdev), fc_conf);
1054                 if ((ret = fs_err(sdev, ret))) {
1055                         ERROR("Operation rte_eth_dev_flow_ctrl_set failed for sub_device %d"
1056                               " with error %d", i, ret);
1057                         fs_unlock(dev, 0);
1058                         return ret;
1059                 }
1060         }
1061         fs_unlock(dev, 0);
1062         return 0;
1063 }
1064
1065 static void
1066 fs_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
1067 {
1068         struct sub_device *sdev;
1069         uint8_t i;
1070
1071         fs_lock(dev, 0);
1072         /* No check: already done within the rte_eth_dev_mac_addr_remove
1073          * call for the fail-safe device.
1074          */
1075         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
1076                 rte_eth_dev_mac_addr_remove(PORT_ID(sdev),
1077                                 &dev->data->mac_addrs[index]);
1078         PRIV(dev)->mac_addr_pool[index] = 0;
1079         fs_unlock(dev, 0);
1080 }
1081
1082 static int
1083 fs_mac_addr_add(struct rte_eth_dev *dev,
1084                 struct ether_addr *mac_addr,
1085                 uint32_t index,
1086                 uint32_t vmdq)
1087 {
1088         struct sub_device *sdev;
1089         int ret;
1090         uint8_t i;
1091
1092         RTE_ASSERT(index < FAILSAFE_MAX_ETHADDR);
1093         fs_lock(dev, 0);
1094         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
1095                 ret = rte_eth_dev_mac_addr_add(PORT_ID(sdev), mac_addr, vmdq);
1096                 if ((ret = fs_err(sdev, ret))) {
1097                         ERROR("Operation rte_eth_dev_mac_addr_add failed for sub_device %"
1098                               PRIu8 " with error %d", i, ret);
1099                         fs_unlock(dev, 0);
1100                         return ret;
1101                 }
1102         }
1103         if (index >= PRIV(dev)->nb_mac_addr) {
1104                 DEBUG("Growing mac_addrs array");
1105                 PRIV(dev)->nb_mac_addr = index;
1106         }
1107         PRIV(dev)->mac_addr_pool[index] = vmdq;
1108         fs_unlock(dev, 0);
1109         return 0;
1110 }
1111
1112 static int
1113 fs_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
1114 {
1115         struct sub_device *sdev;
1116         uint8_t i;
1117         int ret;
1118
1119         fs_lock(dev, 0);
1120         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
1121                 ret = rte_eth_dev_default_mac_addr_set(PORT_ID(sdev), mac_addr);
1122                 ret = fs_err(sdev, ret);
1123                 if (ret) {
1124                         ERROR("Operation rte_eth_dev_mac_addr_set failed for sub_device %d with error %d",
1125                                 i, ret);
1126                         fs_unlock(dev, 0);
1127                         return ret;
1128                 }
1129         }
1130         fs_unlock(dev, 0);
1131
1132         return 0;
1133 }
1134
1135 static int
1136 fs_set_mc_addr_list(struct rte_eth_dev *dev,
1137                     struct ether_addr *mc_addr_set, uint32_t nb_mc_addr)
1138 {
1139         struct sub_device *sdev;
1140         uint8_t i;
1141         int ret;
1142         void *mcast_addrs;
1143
1144         fs_lock(dev, 0);
1145
1146         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
1147                 ret = rte_eth_dev_set_mc_addr_list(PORT_ID(sdev),
1148                                                    mc_addr_set, nb_mc_addr);
1149                 if (ret != 0) {
1150                         ERROR("Operation rte_eth_dev_set_mc_addr_list failed for sub_device %d with error %d",
1151                               i, ret);
1152                         goto rollback;
1153                 }
1154         }
1155
1156         mcast_addrs = rte_realloc(PRIV(dev)->mcast_addrs,
1157                 nb_mc_addr * sizeof(PRIV(dev)->mcast_addrs[0]), 0);
1158         if (mcast_addrs == NULL && nb_mc_addr > 0) {
1159                 ret = -ENOMEM;
1160                 goto rollback;
1161         }
1162         rte_memcpy(mcast_addrs, mc_addr_set,
1163                    nb_mc_addr * sizeof(PRIV(dev)->mcast_addrs[0]));
1164         PRIV(dev)->nb_mcast_addr = nb_mc_addr;
1165         PRIV(dev)->mcast_addrs = mcast_addrs;
1166
1167         fs_unlock(dev, 0);
1168         return 0;
1169
1170 rollback:
1171         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
1172                 int rc = rte_eth_dev_set_mc_addr_list(PORT_ID(sdev),
1173                         PRIV(dev)->mcast_addrs, PRIV(dev)->nb_mcast_addr);
1174                 if (rc != 0) {
1175                         ERROR("Multicast MAC address list rollback for sub_device %d failed with error %d",
1176                               i, rc);
1177                 }
1178         }
1179
1180         fs_unlock(dev, 0);
1181         return ret;
1182 }
1183
1184 static int
1185 fs_rss_hash_update(struct rte_eth_dev *dev,
1186                         struct rte_eth_rss_conf *rss_conf)
1187 {
1188         struct sub_device *sdev;
1189         uint8_t i;
1190         int ret;
1191
1192         fs_lock(dev, 0);
1193         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
1194                 ret = rte_eth_dev_rss_hash_update(PORT_ID(sdev), rss_conf);
1195                 ret = fs_err(sdev, ret);
1196                 if (ret) {
1197                         ERROR("Operation rte_eth_dev_rss_hash_update"
1198                                 " failed for sub_device %d with error %d",
1199                                 i, ret);
1200                         fs_unlock(dev, 0);
1201                         return ret;
1202                 }
1203         }
1204         fs_unlock(dev, 0);
1205
1206         return 0;
1207 }
1208
1209 static int
1210 fs_filter_ctrl(struct rte_eth_dev *dev,
1211                 enum rte_filter_type type,
1212                 enum rte_filter_op op,
1213                 void *arg)
1214 {
1215         struct sub_device *sdev;
1216         uint8_t i;
1217         int ret;
1218
1219         if (type == RTE_ETH_FILTER_GENERIC &&
1220             op == RTE_ETH_FILTER_GET) {
1221                 *(const void **)arg = &fs_flow_ops;
1222                 return 0;
1223         }
1224         fs_lock(dev, 0);
1225         FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
1226                 DEBUG("Calling rte_eth_dev_filter_ctrl on sub_device %d", i);
1227                 ret = rte_eth_dev_filter_ctrl(PORT_ID(sdev), type, op, arg);
1228                 if ((ret = fs_err(sdev, ret))) {
1229                         ERROR("Operation rte_eth_dev_filter_ctrl failed for sub_device %d"
1230                               " with error %d", i, ret);
1231                         fs_unlock(dev, 0);
1232                         return ret;
1233                 }
1234         }
1235         fs_unlock(dev, 0);
1236         return 0;
1237 }
1238
1239 const struct eth_dev_ops failsafe_ops = {
1240         .dev_configure = fs_dev_configure,
1241         .dev_start = fs_dev_start,
1242         .dev_stop = fs_dev_stop,
1243         .dev_set_link_down = fs_dev_set_link_down,
1244         .dev_set_link_up = fs_dev_set_link_up,
1245         .dev_close = fs_dev_close,
1246         .promiscuous_enable = fs_promiscuous_enable,
1247         .promiscuous_disable = fs_promiscuous_disable,
1248         .allmulticast_enable = fs_allmulticast_enable,
1249         .allmulticast_disable = fs_allmulticast_disable,
1250         .link_update = fs_link_update,
1251         .stats_get = fs_stats_get,
1252         .stats_reset = fs_stats_reset,
1253         .dev_infos_get = fs_dev_infos_get,
1254         .dev_supported_ptypes_get = fs_dev_supported_ptypes_get,
1255         .mtu_set = fs_mtu_set,
1256         .vlan_filter_set = fs_vlan_filter_set,
1257         .rx_queue_start = fs_rx_queue_start,
1258         .rx_queue_stop = fs_rx_queue_stop,
1259         .tx_queue_start = fs_tx_queue_start,
1260         .tx_queue_stop = fs_tx_queue_stop,
1261         .rx_queue_setup = fs_rx_queue_setup,
1262         .tx_queue_setup = fs_tx_queue_setup,
1263         .rx_queue_release = fs_rx_queue_release,
1264         .tx_queue_release = fs_tx_queue_release,
1265         .rx_queue_intr_enable = fs_rx_intr_enable,
1266         .rx_queue_intr_disable = fs_rx_intr_disable,
1267         .flow_ctrl_get = fs_flow_ctrl_get,
1268         .flow_ctrl_set = fs_flow_ctrl_set,
1269         .mac_addr_remove = fs_mac_addr_remove,
1270         .mac_addr_add = fs_mac_addr_add,
1271         .mac_addr_set = fs_mac_addr_set,
1272         .set_mc_addr_list = fs_set_mc_addr_list,
1273         .rss_hash_update = fs_rss_hash_update,
1274         .filter_ctrl = fs_filter_ctrl,
1275 };