1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2017 6WIND S.A.
3 * Copyright 2017 Mellanox Technologies, Ltd
10 #include <rte_debug.h>
11 #include <rte_atomic.h>
12 #include <rte_ethdev_driver.h>
13 #include <rte_malloc.h>
15 #include <rte_cycles.h>
16 #include <rte_ethdev.h>
18 #include "failsafe_private.h"
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,
33 .nb_seg_max = UINT16_MAX,
34 .nb_mtu_seg_max = UINT16_MAX,
40 .nb_seg_max = UINT16_MAX,
41 .nb_mtu_seg_max = UINT16_MAX,
44 * Set of capabilities that can be verified upon
45 * configuring a sub-device.
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,
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 =
92 fs_dev_configure(struct rte_eth_dev *dev)
94 struct sub_device *sdev;
99 FOREACH_SUBDEV(sdev, i, dev) {
100 int rmv_interrupt = 0;
101 int lsc_interrupt = 0;
104 if (sdev->state != DEV_PROBED &&
105 !(PRIV(dev)->alarm_lock == 0 && sdev->state == DEV_ACTIVE))
108 rmv_interrupt = ETH(sdev)->data->dev_flags &
109 RTE_ETH_DEV_INTR_RMV;
111 DEBUG("Enabling RMV interrupts for sub_device %d", i);
112 dev->data->dev_conf.intr_conf.rmv = 1;
114 DEBUG("sub_device %d does not support RMV event", i);
116 lsc_enabled = dev->data->dev_conf.intr_conf.lsc;
117 lsc_interrupt = lsc_enabled &&
118 (ETH(sdev)->data->dev_flags &
119 RTE_ETH_DEV_INTR_LSC);
121 DEBUG("Enabling LSC interrupts for sub_device %d", i);
122 dev->data->dev_conf.intr_conf.lsc = 1;
123 } else if (lsc_enabled && !lsc_interrupt) {
124 DEBUG("Disabling LSC interrupts for sub_device %d", i);
125 dev->data->dev_conf.intr_conf.lsc = 0;
127 DEBUG("Configuring sub-device %d", i);
128 ret = rte_eth_dev_configure(PORT_ID(sdev),
129 dev->data->nb_rx_queues,
130 dev->data->nb_tx_queues,
131 &dev->data->dev_conf);
133 if (!fs_err(sdev, ret))
135 ERROR("Could not configure sub_device %d", i);
139 if (rmv_interrupt && sdev->rmv_callback == 0) {
140 ret = rte_eth_dev_callback_register(PORT_ID(sdev),
141 RTE_ETH_EVENT_INTR_RMV,
142 failsafe_eth_rmv_event_callback,
145 WARN("Failed to register RMV callback for sub_device %d",
148 sdev->rmv_callback = 1;
150 dev->data->dev_conf.intr_conf.rmv = 0;
151 if (lsc_interrupt && sdev->lsc_callback == 0) {
152 ret = rte_eth_dev_callback_register(PORT_ID(sdev),
153 RTE_ETH_EVENT_INTR_LSC,
154 failsafe_eth_lsc_event_callback,
157 WARN("Failed to register LSC callback for sub_device %d",
160 sdev->lsc_callback = 1;
162 dev->data->dev_conf.intr_conf.lsc = lsc_enabled;
163 sdev->state = DEV_ACTIVE;
165 if (PRIV(dev)->state < DEV_ACTIVE)
166 PRIV(dev)->state = DEV_ACTIVE;
172 fs_dev_start(struct rte_eth_dev *dev)
174 struct sub_device *sdev;
179 ret = failsafe_rx_intr_install(dev);
184 FOREACH_SUBDEV(sdev, i, dev) {
185 if (sdev->state != DEV_ACTIVE)
187 DEBUG("Starting sub_device %d", i);
188 ret = rte_eth_dev_start(PORT_ID(sdev));
190 if (!fs_err(sdev, ret))
195 ret = failsafe_rx_intr_install_subdevice(sdev);
197 if (!fs_err(sdev, ret))
199 rte_eth_dev_stop(PORT_ID(sdev));
203 sdev->state = DEV_STARTED;
205 if (PRIV(dev)->state < DEV_STARTED)
206 PRIV(dev)->state = DEV_STARTED;
207 fs_switch_dev(dev, NULL);
213 fs_dev_stop(struct rte_eth_dev *dev)
215 struct sub_device *sdev;
219 PRIV(dev)->state = DEV_STARTED - 1;
220 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_STARTED) {
221 rte_eth_dev_stop(PORT_ID(sdev));
222 failsafe_rx_intr_uninstall_subdevice(sdev);
223 sdev->state = DEV_STARTED - 1;
225 failsafe_rx_intr_uninstall(dev);
230 fs_dev_set_link_up(struct rte_eth_dev *dev)
232 struct sub_device *sdev;
237 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
238 DEBUG("Calling rte_eth_dev_set_link_up on sub_device %d", i);
239 ret = rte_eth_dev_set_link_up(PORT_ID(sdev));
240 if ((ret = fs_err(sdev, ret))) {
241 ERROR("Operation rte_eth_dev_set_link_up failed for sub_device %d"
242 " with error %d", i, ret);
252 fs_dev_set_link_down(struct rte_eth_dev *dev)
254 struct sub_device *sdev;
259 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
260 DEBUG("Calling rte_eth_dev_set_link_down on sub_device %d", i);
261 ret = rte_eth_dev_set_link_down(PORT_ID(sdev));
262 if ((ret = fs_err(sdev, ret))) {
263 ERROR("Operation rte_eth_dev_set_link_down failed for sub_device %d"
264 " with error %d", i, ret);
273 static void fs_dev_free_queues(struct rte_eth_dev *dev);
275 fs_dev_close(struct rte_eth_dev *dev)
277 struct sub_device *sdev;
281 failsafe_hotplug_alarm_cancel(dev);
282 if (PRIV(dev)->state == DEV_STARTED)
283 dev->dev_ops->dev_stop(dev);
284 PRIV(dev)->state = DEV_ACTIVE - 1;
285 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
286 DEBUG("Closing sub_device %d", i);
287 failsafe_eth_dev_unregister_callbacks(sdev);
288 rte_eth_dev_close(PORT_ID(sdev));
289 sdev->state = DEV_ACTIVE - 1;
291 fs_dev_free_queues(dev);
296 fs_rx_queue_release(void *queue)
298 struct rte_eth_dev *dev;
299 struct sub_device *sdev;
306 dev = rxq->priv->dev;
308 if (rxq->event_fd > 0)
309 close(rxq->event_fd);
310 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
311 if (ETH(sdev)->data->rx_queues != NULL &&
312 ETH(sdev)->data->rx_queues[rxq->qid] != NULL) {
313 SUBOPS(sdev, rx_queue_release)
314 (ETH(sdev)->data->rx_queues[rxq->qid]);
317 dev->data->rx_queues[rxq->qid] = NULL;
323 fs_rx_queue_setup(struct rte_eth_dev *dev,
324 uint16_t rx_queue_id,
326 unsigned int socket_id,
327 const struct rte_eth_rxconf *rx_conf,
328 struct rte_mempool *mb_pool)
331 * FIXME: Add a proper interface in rte_eal_interrupts for
332 * allocating eventfd as an interrupt vector.
333 * For the time being, fake as if we are using MSIX interrupts,
334 * this will cause rte_intr_efd_enable to allocate an eventfd for us.
336 struct rte_intr_handle intr_handle = {
337 .type = RTE_INTR_HANDLE_VFIO_MSIX,
340 struct sub_device *sdev;
346 rxq = dev->data->rx_queues[rx_queue_id];
348 fs_rx_queue_release(rxq);
349 dev->data->rx_queues[rx_queue_id] = NULL;
351 rxq = rte_zmalloc(NULL,
353 sizeof(rte_atomic64_t) * PRIV(dev)->subs_tail,
354 RTE_CACHE_LINE_SIZE);
359 FOREACH_SUBDEV(sdev, i, dev)
360 rte_atomic64_init(&rxq->refcnt[i]);
361 rxq->qid = rx_queue_id;
362 rxq->socket_id = socket_id;
363 rxq->info.mp = mb_pool;
364 rxq->info.conf = *rx_conf;
365 rxq->info.nb_desc = nb_rx_desc;
366 rxq->priv = PRIV(dev);
367 rxq->sdev = PRIV(dev)->subs;
368 ret = rte_intr_efd_enable(&intr_handle, 1);
373 rxq->event_fd = intr_handle.efds[0];
374 dev->data->rx_queues[rx_queue_id] = rxq;
375 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
376 ret = rte_eth_rx_queue_setup(PORT_ID(sdev),
378 nb_rx_desc, socket_id,
380 if ((ret = fs_err(sdev, ret))) {
381 ERROR("RX queue setup failed for sub_device %d", i);
388 fs_rx_queue_release(rxq);
394 fs_rx_intr_enable(struct rte_eth_dev *dev, uint16_t idx)
397 struct sub_device *sdev;
403 if (idx >= dev->data->nb_rx_queues) {
407 rxq = dev->data->rx_queues[idx];
408 if (rxq == NULL || rxq->event_fd <= 0) {
412 /* Fail if proxy service is nor running. */
413 if (PRIV(dev)->rxp.sstate != SS_RUNNING) {
414 ERROR("failsafe interrupt services are not running");
418 rxq->enable_events = 1;
419 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
420 ret = rte_eth_dev_rx_intr_enable(PORT_ID(sdev), idx);
421 ret = fs_err(sdev, ret);
433 fs_rx_intr_disable(struct rte_eth_dev *dev, uint16_t idx)
436 struct sub_device *sdev;
443 if (idx >= dev->data->nb_rx_queues) {
447 rxq = dev->data->rx_queues[idx];
448 if (rxq == NULL || rxq->event_fd <= 0) {
452 rxq->enable_events = 0;
453 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
454 ret = rte_eth_dev_rx_intr_disable(PORT_ID(sdev), idx);
455 ret = fs_err(sdev, ret);
459 /* Clear pending events */
460 while (read(rxq->event_fd, &u64, sizeof(uint64_t)) > 0)
470 fs_tx_queue_release(void *queue)
472 struct rte_eth_dev *dev;
473 struct sub_device *sdev;
480 dev = txq->priv->dev;
482 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
483 if (ETH(sdev)->data->tx_queues != NULL &&
484 ETH(sdev)->data->tx_queues[txq->qid] != NULL) {
485 SUBOPS(sdev, tx_queue_release)
486 (ETH(sdev)->data->tx_queues[txq->qid]);
489 dev->data->tx_queues[txq->qid] = NULL;
495 fs_tx_queue_setup(struct rte_eth_dev *dev,
496 uint16_t tx_queue_id,
498 unsigned int socket_id,
499 const struct rte_eth_txconf *tx_conf)
501 struct sub_device *sdev;
507 txq = dev->data->tx_queues[tx_queue_id];
509 fs_tx_queue_release(txq);
510 dev->data->tx_queues[tx_queue_id] = NULL;
512 txq = rte_zmalloc("ethdev TX queue",
514 sizeof(rte_atomic64_t) * PRIV(dev)->subs_tail,
515 RTE_CACHE_LINE_SIZE);
520 FOREACH_SUBDEV(sdev, i, dev)
521 rte_atomic64_init(&txq->refcnt[i]);
522 txq->qid = tx_queue_id;
523 txq->socket_id = socket_id;
524 txq->info.conf = *tx_conf;
525 txq->info.nb_desc = nb_tx_desc;
526 txq->priv = PRIV(dev);
527 dev->data->tx_queues[tx_queue_id] = txq;
528 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
529 ret = rte_eth_tx_queue_setup(PORT_ID(sdev),
531 nb_tx_desc, socket_id,
533 if ((ret = fs_err(sdev, ret))) {
534 ERROR("TX queue setup failed for sub_device %d", i);
541 fs_tx_queue_release(txq);
547 fs_dev_free_queues(struct rte_eth_dev *dev)
551 for (i = 0; i < dev->data->nb_rx_queues; i++) {
552 fs_rx_queue_release(dev->data->rx_queues[i]);
553 dev->data->rx_queues[i] = NULL;
555 dev->data->nb_rx_queues = 0;
556 for (i = 0; i < dev->data->nb_tx_queues; i++) {
557 fs_tx_queue_release(dev->data->tx_queues[i]);
558 dev->data->tx_queues[i] = NULL;
560 dev->data->nb_tx_queues = 0;
564 fs_promiscuous_enable(struct rte_eth_dev *dev)
566 struct sub_device *sdev;
570 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
571 rte_eth_promiscuous_enable(PORT_ID(sdev));
576 fs_promiscuous_disable(struct rte_eth_dev *dev)
578 struct sub_device *sdev;
582 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
583 rte_eth_promiscuous_disable(PORT_ID(sdev));
588 fs_allmulticast_enable(struct rte_eth_dev *dev)
590 struct sub_device *sdev;
594 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
595 rte_eth_allmulticast_enable(PORT_ID(sdev));
600 fs_allmulticast_disable(struct rte_eth_dev *dev)
602 struct sub_device *sdev;
606 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
607 rte_eth_allmulticast_disable(PORT_ID(sdev));
612 fs_link_update(struct rte_eth_dev *dev,
613 int wait_to_complete)
615 struct sub_device *sdev;
620 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
621 DEBUG("Calling link_update on sub_device %d", i);
622 ret = (SUBOPS(sdev, link_update))(ETH(sdev), wait_to_complete);
623 if (ret && ret != -1 && sdev->remove == 0 &&
624 rte_eth_dev_is_removed(PORT_ID(sdev)) == 0) {
625 ERROR("Link update failed for sub_device %d with error %d",
631 if (TX_SUBDEV(dev)) {
632 struct rte_eth_link *l1;
633 struct rte_eth_link *l2;
635 l1 = &dev->data->dev_link;
636 l2 = Ð(TX_SUBDEV(dev))->data->dev_link;
637 if (memcmp(l1, l2, sizeof(*l1))) {
648 fs_stats_get(struct rte_eth_dev *dev,
649 struct rte_eth_stats *stats)
651 struct rte_eth_stats backup;
652 struct sub_device *sdev;
657 rte_memcpy(stats, &PRIV(dev)->stats_accumulator, sizeof(*stats));
658 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
659 struct rte_eth_stats *snapshot = &sdev->stats_snapshot.stats;
660 uint64_t *timestamp = &sdev->stats_snapshot.timestamp;
662 rte_memcpy(&backup, snapshot, sizeof(backup));
663 ret = rte_eth_stats_get(PORT_ID(sdev), snapshot);
665 if (!fs_err(sdev, ret)) {
666 rte_memcpy(snapshot, &backup, sizeof(backup));
669 ERROR("Operation rte_eth_stats_get failed for sub_device %d with error %d",
675 *timestamp = rte_rdtsc();
677 failsafe_stats_increment(stats, snapshot);
684 fs_stats_reset(struct rte_eth_dev *dev)
686 struct sub_device *sdev;
690 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
691 rte_eth_stats_reset(PORT_ID(sdev));
692 memset(&sdev->stats_snapshot, 0, sizeof(struct rte_eth_stats));
694 memset(&PRIV(dev)->stats_accumulator, 0, sizeof(struct rte_eth_stats));
699 * Fail-safe dev_infos_get rules:
703 * Use the maximum possible values for any field, so as not
704 * to impede any further configuration effort.
706 * Limits capabilities to those that are understood by the
707 * fail-safe PMD. This understanding stems from the fail-safe
708 * being capable of verifying that the related capability is
709 * expressed within the device configuration (struct rte_eth_conf).
711 * At least one probed sub_device:
713 * Uses values from the active probed sub_device
714 * The rationale here is that if any sub_device is less capable
715 * (for example concerning the number of queues) than the active
716 * sub_device, then its subsequent configuration will fail.
717 * It is impossible to foresee this failure when the failing sub_device
718 * is supposed to be plugged-in later on, so the configuration process
719 * is the single point of failure and error reporting.
721 * Uses a logical AND of RX capabilities among
722 * all sub_devices and the default capabilities.
723 * Uses a logical AND of TX capabilities among
724 * the active probed sub_device and the default capabilities.
728 fs_dev_infos_get(struct rte_eth_dev *dev,
729 struct rte_eth_dev_info *infos)
731 struct sub_device *sdev;
734 sdev = TX_SUBDEV(dev);
736 DEBUG("No probed device, using default infos");
737 rte_memcpy(&PRIV(dev)->infos, &default_infos,
738 sizeof(default_infos));
740 uint64_t rx_offload_capa;
741 uint64_t rxq_offload_capa;
742 uint64_t rss_hf_offload_capa;
744 rx_offload_capa = default_infos.rx_offload_capa;
745 rxq_offload_capa = default_infos.rx_queue_offload_capa;
746 rss_hf_offload_capa = default_infos.flow_type_rss_offloads;
747 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) {
748 rte_eth_dev_info_get(PORT_ID(sdev),
750 rx_offload_capa &= PRIV(dev)->infos.rx_offload_capa;
752 PRIV(dev)->infos.rx_queue_offload_capa;
753 rss_hf_offload_capa &=
754 PRIV(dev)->infos.flow_type_rss_offloads;
756 sdev = TX_SUBDEV(dev);
757 rte_eth_dev_info_get(PORT_ID(sdev), &PRIV(dev)->infos);
758 PRIV(dev)->infos.rx_offload_capa = rx_offload_capa;
759 PRIV(dev)->infos.rx_queue_offload_capa = rxq_offload_capa;
760 PRIV(dev)->infos.flow_type_rss_offloads = rss_hf_offload_capa;
761 PRIV(dev)->infos.tx_offload_capa &=
762 default_infos.tx_offload_capa;
763 PRIV(dev)->infos.tx_queue_offload_capa &=
764 default_infos.tx_queue_offload_capa;
766 rte_memcpy(infos, &PRIV(dev)->infos, sizeof(*infos));
769 static const uint32_t *
770 fs_dev_supported_ptypes_get(struct rte_eth_dev *dev)
772 struct sub_device *sdev;
773 struct rte_eth_dev *edev;
777 sdev = TX_SUBDEV(dev);
783 /* ENOTSUP: counts as no supported ptypes */
784 if (SUBOPS(sdev, dev_supported_ptypes_get) == NULL) {
789 * The API does not permit to do a clean AND of all ptypes,
790 * It is also incomplete by design and we do not really care
791 * to have a best possible value in this context.
792 * We just return the ptypes of the device of highest
793 * priority, usually the PREFERRED device.
795 ret = SUBOPS(sdev, dev_supported_ptypes_get)(edev);
802 fs_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
804 struct sub_device *sdev;
809 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
810 DEBUG("Calling rte_eth_dev_set_mtu on sub_device %d", i);
811 ret = rte_eth_dev_set_mtu(PORT_ID(sdev), mtu);
812 if ((ret = fs_err(sdev, ret))) {
813 ERROR("Operation rte_eth_dev_set_mtu failed for sub_device %d with error %d",
824 fs_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
826 struct sub_device *sdev;
831 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
832 DEBUG("Calling rte_eth_dev_vlan_filter on sub_device %d", i);
833 ret = rte_eth_dev_vlan_filter(PORT_ID(sdev), vlan_id, on);
834 if ((ret = fs_err(sdev, ret))) {
835 ERROR("Operation rte_eth_dev_vlan_filter failed for sub_device %d"
836 " with error %d", i, ret);
846 fs_flow_ctrl_get(struct rte_eth_dev *dev,
847 struct rte_eth_fc_conf *fc_conf)
849 struct sub_device *sdev;
853 sdev = TX_SUBDEV(dev);
858 if (SUBOPS(sdev, flow_ctrl_get) == NULL) {
862 ret = SUBOPS(sdev, flow_ctrl_get)(ETH(sdev), fc_conf);
869 fs_flow_ctrl_set(struct rte_eth_dev *dev,
870 struct rte_eth_fc_conf *fc_conf)
872 struct sub_device *sdev;
877 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
878 DEBUG("Calling rte_eth_dev_flow_ctrl_set on sub_device %d", i);
879 ret = rte_eth_dev_flow_ctrl_set(PORT_ID(sdev), fc_conf);
880 if ((ret = fs_err(sdev, ret))) {
881 ERROR("Operation rte_eth_dev_flow_ctrl_set failed for sub_device %d"
882 " with error %d", i, ret);
892 fs_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
894 struct sub_device *sdev;
898 /* No check: already done within the rte_eth_dev_mac_addr_remove
899 * call for the fail-safe device.
901 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
902 rte_eth_dev_mac_addr_remove(PORT_ID(sdev),
903 &dev->data->mac_addrs[index]);
904 PRIV(dev)->mac_addr_pool[index] = 0;
909 fs_mac_addr_add(struct rte_eth_dev *dev,
910 struct ether_addr *mac_addr,
914 struct sub_device *sdev;
918 RTE_ASSERT(index < FAILSAFE_MAX_ETHADDR);
920 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
921 ret = rte_eth_dev_mac_addr_add(PORT_ID(sdev), mac_addr, vmdq);
922 if ((ret = fs_err(sdev, ret))) {
923 ERROR("Operation rte_eth_dev_mac_addr_add failed for sub_device %"
924 PRIu8 " with error %d", i, ret);
929 if (index >= PRIV(dev)->nb_mac_addr) {
930 DEBUG("Growing mac_addrs array");
931 PRIV(dev)->nb_mac_addr = index;
933 PRIV(dev)->mac_addr_pool[index] = vmdq;
939 fs_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
941 struct sub_device *sdev;
946 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
947 ret = rte_eth_dev_default_mac_addr_set(PORT_ID(sdev), mac_addr);
948 ret = fs_err(sdev, ret);
950 ERROR("Operation rte_eth_dev_mac_addr_set failed for sub_device %d with error %d",
962 fs_rss_hash_update(struct rte_eth_dev *dev,
963 struct rte_eth_rss_conf *rss_conf)
965 struct sub_device *sdev;
970 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
971 ret = rte_eth_dev_rss_hash_update(PORT_ID(sdev), rss_conf);
972 ret = fs_err(sdev, ret);
974 ERROR("Operation rte_eth_dev_rss_hash_update"
975 " failed for sub_device %d with error %d",
987 fs_filter_ctrl(struct rte_eth_dev *dev,
988 enum rte_filter_type type,
989 enum rte_filter_op op,
992 struct sub_device *sdev;
996 if (type == RTE_ETH_FILTER_GENERIC &&
997 op == RTE_ETH_FILTER_GET) {
998 *(const void **)arg = &fs_flow_ops;
1002 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
1003 DEBUG("Calling rte_eth_dev_filter_ctrl on sub_device %d", i);
1004 ret = rte_eth_dev_filter_ctrl(PORT_ID(sdev), type, op, arg);
1005 if ((ret = fs_err(sdev, ret))) {
1006 ERROR("Operation rte_eth_dev_filter_ctrl failed for sub_device %d"
1007 " with error %d", i, ret);
1016 const struct eth_dev_ops failsafe_ops = {
1017 .dev_configure = fs_dev_configure,
1018 .dev_start = fs_dev_start,
1019 .dev_stop = fs_dev_stop,
1020 .dev_set_link_down = fs_dev_set_link_down,
1021 .dev_set_link_up = fs_dev_set_link_up,
1022 .dev_close = fs_dev_close,
1023 .promiscuous_enable = fs_promiscuous_enable,
1024 .promiscuous_disable = fs_promiscuous_disable,
1025 .allmulticast_enable = fs_allmulticast_enable,
1026 .allmulticast_disable = fs_allmulticast_disable,
1027 .link_update = fs_link_update,
1028 .stats_get = fs_stats_get,
1029 .stats_reset = fs_stats_reset,
1030 .dev_infos_get = fs_dev_infos_get,
1031 .dev_supported_ptypes_get = fs_dev_supported_ptypes_get,
1032 .mtu_set = fs_mtu_set,
1033 .vlan_filter_set = fs_vlan_filter_set,
1034 .rx_queue_setup = fs_rx_queue_setup,
1035 .tx_queue_setup = fs_tx_queue_setup,
1036 .rx_queue_release = fs_rx_queue_release,
1037 .tx_queue_release = fs_tx_queue_release,
1038 .rx_queue_intr_enable = fs_rx_intr_enable,
1039 .rx_queue_intr_disable = fs_rx_intr_disable,
1040 .flow_ctrl_get = fs_flow_ctrl_get,
1041 .flow_ctrl_set = fs_flow_ctrl_set,
1042 .mac_addr_remove = fs_mac_addr_remove,
1043 .mac_addr_add = fs_mac_addr_add,
1044 .mac_addr_set = fs_mac_addr_set,
1045 .rss_hash_update = fs_rss_hash_update,
1046 .filter_ctrl = fs_filter_ctrl,