4 * Copyright 2017 6WIND S.A.
5 * Copyright 2017 Mellanox.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of 6WIND S.A. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include <rte_debug.h>
37 #include <rte_atomic.h>
38 #include <rte_ethdev.h>
39 #include <rte_malloc.h>
41 #include <rte_cycles.h>
43 #include "failsafe_private.h"
45 static struct rte_eth_dev_info default_infos = {
46 /* Max possible number of elements */
47 .max_rx_pktlen = UINT32_MAX,
48 .max_rx_queues = RTE_MAX_QUEUES_PER_PORT,
49 .max_tx_queues = RTE_MAX_QUEUES_PER_PORT,
50 .max_mac_addrs = FAILSAFE_MAX_ETHADDR,
51 .max_hash_mac_addrs = UINT32_MAX,
52 .max_vfs = UINT16_MAX,
53 .max_vmdq_pools = UINT16_MAX,
58 .nb_seg_max = UINT16_MAX,
59 .nb_mtu_seg_max = UINT16_MAX,
65 .nb_seg_max = UINT16_MAX,
66 .nb_mtu_seg_max = UINT16_MAX,
69 * Set of capabilities that can be verified upon
70 * configuring a sub-device.
73 DEV_RX_OFFLOAD_VLAN_STRIP |
74 DEV_RX_OFFLOAD_QINQ_STRIP |
75 DEV_RX_OFFLOAD_IPV4_CKSUM |
76 DEV_RX_OFFLOAD_UDP_CKSUM |
77 DEV_RX_OFFLOAD_TCP_CKSUM |
78 DEV_RX_OFFLOAD_TCP_LRO,
79 .tx_offload_capa = 0x0,
80 .flow_type_rss_offloads = 0x0,
84 * Check whether a specific offloading capability
85 * is supported by a sub_device.
88 * 0: all requested capabilities are supported by the sub_device
89 * positive value: This flag at least is not supported by the sub_device
92 fs_port_offload_validate(struct rte_eth_dev *dev,
93 struct sub_device *sdev)
95 struct rte_eth_dev_info infos = {0};
96 struct rte_eth_conf *cf;
99 cf = &dev->data->dev_conf;
100 SUBOPS(sdev, dev_infos_get)(ETH(sdev), &infos);
101 /* RX capabilities */
102 cap = infos.rx_offload_capa;
103 if (cf->rxmode.hw_vlan_strip &&
104 ((cap & DEV_RX_OFFLOAD_VLAN_STRIP) == 0)) {
105 WARN("VLAN stripping offload requested but not supported by sub_device %d",
107 return DEV_RX_OFFLOAD_VLAN_STRIP;
109 if (cf->rxmode.hw_ip_checksum &&
110 ((cap & (DEV_RX_OFFLOAD_IPV4_CKSUM |
111 DEV_RX_OFFLOAD_UDP_CKSUM |
112 DEV_RX_OFFLOAD_TCP_CKSUM)) !=
113 (DEV_RX_OFFLOAD_IPV4_CKSUM |
114 DEV_RX_OFFLOAD_UDP_CKSUM |
115 DEV_RX_OFFLOAD_TCP_CKSUM))) {
116 WARN("IP checksum offload requested but not supported by sub_device %d",
118 return DEV_RX_OFFLOAD_IPV4_CKSUM |
119 DEV_RX_OFFLOAD_UDP_CKSUM |
120 DEV_RX_OFFLOAD_TCP_CKSUM;
122 if (cf->rxmode.enable_lro &&
123 ((cap & DEV_RX_OFFLOAD_TCP_LRO) == 0)) {
124 WARN("TCP LRO offload requested but not supported by sub_device %d",
126 return DEV_RX_OFFLOAD_TCP_LRO;
128 if (cf->rxmode.hw_vlan_extend &&
129 ((cap & DEV_RX_OFFLOAD_QINQ_STRIP) == 0)) {
130 WARN("Stacked VLAN stripping offload requested but not supported by sub_device %d",
132 return DEV_RX_OFFLOAD_QINQ_STRIP;
134 /* TX capabilities */
135 /* Nothing to do, no tx capa supported */
140 * Disable the dev_conf flag related to an offload capability flag
141 * within an ethdev configuration.
144 fs_port_disable_offload(struct rte_eth_conf *cf,
148 case DEV_RX_OFFLOAD_VLAN_STRIP:
149 INFO("Disabling VLAN stripping offload");
150 cf->rxmode.hw_vlan_strip = 0;
152 case DEV_RX_OFFLOAD_IPV4_CKSUM:
153 case DEV_RX_OFFLOAD_UDP_CKSUM:
154 case DEV_RX_OFFLOAD_TCP_CKSUM:
155 case (DEV_RX_OFFLOAD_IPV4_CKSUM |
156 DEV_RX_OFFLOAD_UDP_CKSUM |
157 DEV_RX_OFFLOAD_TCP_CKSUM):
158 INFO("Disabling IP checksum offload");
159 cf->rxmode.hw_ip_checksum = 0;
161 case DEV_RX_OFFLOAD_TCP_LRO:
162 INFO("Disabling TCP LRO offload");
163 cf->rxmode.enable_lro = 0;
165 case DEV_RX_OFFLOAD_QINQ_STRIP:
166 INFO("Disabling stacked VLAN stripping offload");
167 cf->rxmode.hw_vlan_extend = 0;
170 DEBUG("Unable to disable offload capability: %" PRIx32,
178 fs_dev_configure(struct rte_eth_dev *dev)
180 struct sub_device *sdev;
185 FOREACH_SUBDEV(sdev, i, dev) {
186 if (sdev->state != DEV_PROBED)
188 DEBUG("Checking capabilities for sub_device %d", i);
189 while ((capa_flag = fs_port_offload_validate(dev, sdev))) {
191 * Refuse to change configuration if multiple devices
192 * are present and we already have configured at least
195 if (PRIV(dev)->state >= DEV_ACTIVE &&
196 PRIV(dev)->subs_tail > 1) {
197 ERROR("device already configured, cannot fix live configuration");
200 ret = fs_port_disable_offload(&dev->data->dev_conf,
203 ERROR("Unable to disable offload capability");
208 FOREACH_SUBDEV(sdev, i, dev) {
209 int rmv_interrupt = 0;
210 int lsc_interrupt = 0;
213 if (sdev->state != DEV_PROBED)
216 rmv_interrupt = ETH(sdev)->data->dev_flags &
217 RTE_ETH_DEV_INTR_RMV;
219 DEBUG("Enabling RMV interrupts for sub_device %d", i);
220 dev->data->dev_conf.intr_conf.rmv = 1;
222 DEBUG("sub_device %d does not support RMV event", i);
224 lsc_enabled = dev->data->dev_conf.intr_conf.lsc;
225 lsc_interrupt = lsc_enabled &&
226 (ETH(sdev)->data->dev_flags &
227 RTE_ETH_DEV_INTR_LSC);
229 DEBUG("Enabling LSC interrupts for sub_device %d", i);
230 dev->data->dev_conf.intr_conf.lsc = 1;
231 } else if (lsc_enabled && !lsc_interrupt) {
232 DEBUG("Disabling LSC interrupts for sub_device %d", i);
233 dev->data->dev_conf.intr_conf.lsc = 0;
235 DEBUG("Configuring sub-device %d", i);
237 ret = rte_eth_dev_configure(PORT_ID(sdev),
238 dev->data->nb_rx_queues,
239 dev->data->nb_tx_queues,
240 &dev->data->dev_conf);
242 ERROR("Could not configure sub_device %d", i);
246 ret = rte_eth_dev_callback_register(PORT_ID(sdev),
247 RTE_ETH_EVENT_INTR_RMV,
248 failsafe_eth_rmv_event_callback,
251 WARN("Failed to register RMV callback for sub_device %d",
254 dev->data->dev_conf.intr_conf.rmv = 0;
256 ret = rte_eth_dev_callback_register(PORT_ID(sdev),
257 RTE_ETH_EVENT_INTR_LSC,
258 failsafe_eth_lsc_event_callback,
261 WARN("Failed to register LSC callback for sub_device %d",
264 dev->data->dev_conf.intr_conf.lsc = lsc_enabled;
265 sdev->state = DEV_ACTIVE;
267 if (PRIV(dev)->state < DEV_ACTIVE)
268 PRIV(dev)->state = DEV_ACTIVE;
273 fs_dev_start(struct rte_eth_dev *dev)
275 struct sub_device *sdev;
279 FOREACH_SUBDEV(sdev, i, dev) {
280 if (sdev->state != DEV_ACTIVE)
282 DEBUG("Starting sub_device %d", i);
283 ret = rte_eth_dev_start(PORT_ID(sdev));
286 sdev->state = DEV_STARTED;
288 if (PRIV(dev)->state < DEV_STARTED)
289 PRIV(dev)->state = DEV_STARTED;
290 fs_switch_dev(dev, NULL);
295 fs_dev_stop(struct rte_eth_dev *dev)
297 struct sub_device *sdev;
300 PRIV(dev)->state = DEV_STARTED - 1;
301 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_STARTED) {
302 rte_eth_dev_stop(PORT_ID(sdev));
303 sdev->state = DEV_STARTED - 1;
308 fs_dev_set_link_up(struct rte_eth_dev *dev)
310 struct sub_device *sdev;
314 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
315 DEBUG("Calling rte_eth_dev_set_link_up on sub_device %d", i);
316 ret = rte_eth_dev_set_link_up(PORT_ID(sdev));
318 ERROR("Operation rte_eth_dev_set_link_up failed for sub_device %d"
319 " with error %d", i, ret);
327 fs_dev_set_link_down(struct rte_eth_dev *dev)
329 struct sub_device *sdev;
333 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
334 DEBUG("Calling rte_eth_dev_set_link_down on sub_device %d", i);
335 ret = rte_eth_dev_set_link_down(PORT_ID(sdev));
337 ERROR("Operation rte_eth_dev_set_link_down failed for sub_device %d"
338 " with error %d", i, ret);
345 static void fs_dev_free_queues(struct rte_eth_dev *dev);
347 fs_dev_close(struct rte_eth_dev *dev)
349 struct sub_device *sdev;
352 failsafe_hotplug_alarm_cancel(dev);
353 if (PRIV(dev)->state == DEV_STARTED)
354 dev->dev_ops->dev_stop(dev);
355 PRIV(dev)->state = DEV_ACTIVE - 1;
356 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
357 DEBUG("Closing sub_device %d", i);
358 rte_eth_dev_close(PORT_ID(sdev));
359 sdev->state = DEV_ACTIVE - 1;
361 fs_dev_free_queues(dev);
365 fs_rx_queue_release(void *queue)
367 struct rte_eth_dev *dev;
368 struct sub_device *sdev;
375 dev = rxq->priv->dev;
376 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
377 SUBOPS(sdev, rx_queue_release)
378 (ETH(sdev)->data->rx_queues[rxq->qid]);
379 dev->data->rx_queues[rxq->qid] = NULL;
384 fs_rx_queue_setup(struct rte_eth_dev *dev,
385 uint16_t rx_queue_id,
387 unsigned int socket_id,
388 const struct rte_eth_rxconf *rx_conf,
389 struct rte_mempool *mb_pool)
391 struct sub_device *sdev;
396 rxq = dev->data->rx_queues[rx_queue_id];
398 fs_rx_queue_release(rxq);
399 dev->data->rx_queues[rx_queue_id] = NULL;
401 rxq = rte_zmalloc(NULL,
403 sizeof(rte_atomic64_t) * PRIV(dev)->subs_tail,
404 RTE_CACHE_LINE_SIZE);
407 FOREACH_SUBDEV(sdev, i, dev)
408 rte_atomic64_init(&rxq->refcnt[i]);
409 rxq->qid = rx_queue_id;
410 rxq->socket_id = socket_id;
411 rxq->info.mp = mb_pool;
412 rxq->info.conf = *rx_conf;
413 rxq->info.nb_desc = nb_rx_desc;
414 rxq->priv = PRIV(dev);
415 dev->data->rx_queues[rx_queue_id] = rxq;
416 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
417 ret = rte_eth_rx_queue_setup(PORT_ID(sdev),
419 nb_rx_desc, socket_id,
422 ERROR("RX queue setup failed for sub_device %d", i);
428 fs_rx_queue_release(rxq);
433 fs_tx_queue_release(void *queue)
435 struct rte_eth_dev *dev;
436 struct sub_device *sdev;
443 dev = txq->priv->dev;
444 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
445 SUBOPS(sdev, tx_queue_release)
446 (ETH(sdev)->data->tx_queues[txq->qid]);
447 dev->data->tx_queues[txq->qid] = NULL;
452 fs_tx_queue_setup(struct rte_eth_dev *dev,
453 uint16_t tx_queue_id,
455 unsigned int socket_id,
456 const struct rte_eth_txconf *tx_conf)
458 struct sub_device *sdev;
463 txq = dev->data->tx_queues[tx_queue_id];
465 fs_tx_queue_release(txq);
466 dev->data->tx_queues[tx_queue_id] = NULL;
468 txq = rte_zmalloc("ethdev TX queue",
470 sizeof(rte_atomic64_t) * PRIV(dev)->subs_tail,
471 RTE_CACHE_LINE_SIZE);
474 FOREACH_SUBDEV(sdev, i, dev)
475 rte_atomic64_init(&txq->refcnt[i]);
476 txq->qid = tx_queue_id;
477 txq->socket_id = socket_id;
478 txq->info.conf = *tx_conf;
479 txq->info.nb_desc = nb_tx_desc;
480 txq->priv = PRIV(dev);
481 dev->data->tx_queues[tx_queue_id] = txq;
482 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
483 ret = rte_eth_tx_queue_setup(PORT_ID(sdev),
485 nb_tx_desc, socket_id,
488 ERROR("TX queue setup failed for sub_device %d", i);
494 fs_tx_queue_release(txq);
499 fs_dev_free_queues(struct rte_eth_dev *dev)
503 for (i = 0; i < dev->data->nb_rx_queues; i++) {
504 fs_rx_queue_release(dev->data->rx_queues[i]);
505 dev->data->rx_queues[i] = NULL;
507 dev->data->nb_rx_queues = 0;
508 for (i = 0; i < dev->data->nb_tx_queues; i++) {
509 fs_tx_queue_release(dev->data->tx_queues[i]);
510 dev->data->tx_queues[i] = NULL;
512 dev->data->nb_tx_queues = 0;
516 fs_promiscuous_enable(struct rte_eth_dev *dev)
518 struct sub_device *sdev;
521 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
522 rte_eth_promiscuous_enable(PORT_ID(sdev));
526 fs_promiscuous_disable(struct rte_eth_dev *dev)
528 struct sub_device *sdev;
531 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
532 rte_eth_promiscuous_disable(PORT_ID(sdev));
536 fs_allmulticast_enable(struct rte_eth_dev *dev)
538 struct sub_device *sdev;
541 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
542 rte_eth_allmulticast_enable(PORT_ID(sdev));
546 fs_allmulticast_disable(struct rte_eth_dev *dev)
548 struct sub_device *sdev;
551 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
552 rte_eth_allmulticast_disable(PORT_ID(sdev));
556 fs_link_update(struct rte_eth_dev *dev,
557 int wait_to_complete)
559 struct sub_device *sdev;
563 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
564 DEBUG("Calling link_update on sub_device %d", i);
565 ret = (SUBOPS(sdev, link_update))(ETH(sdev), wait_to_complete);
566 if (ret && ret != -1) {
567 ERROR("Link update failed for sub_device %d with error %d",
572 if (TX_SUBDEV(dev)) {
573 struct rte_eth_link *l1;
574 struct rte_eth_link *l2;
576 l1 = &dev->data->dev_link;
577 l2 = Ð(TX_SUBDEV(dev))->data->dev_link;
578 if (memcmp(l1, l2, sizeof(*l1))) {
587 fs_stats_get(struct rte_eth_dev *dev,
588 struct rte_eth_stats *stats)
590 struct sub_device *sdev;
594 rte_memcpy(stats, &PRIV(dev)->stats_accumulator, sizeof(*stats));
595 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
596 struct rte_eth_stats *snapshot = &sdev->stats_snapshot.stats;
597 uint64_t *timestamp = &sdev->stats_snapshot.timestamp;
599 ret = rte_eth_stats_get(PORT_ID(sdev), snapshot);
601 ERROR("Operation rte_eth_stats_get failed for sub_device %d with error %d",
606 *timestamp = rte_rdtsc();
607 failsafe_stats_increment(stats, snapshot);
613 fs_stats_reset(struct rte_eth_dev *dev)
615 struct sub_device *sdev;
618 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
619 rte_eth_stats_reset(PORT_ID(sdev));
620 memset(&sdev->stats_snapshot, 0, sizeof(struct rte_eth_stats));
622 memset(&PRIV(dev)->stats_accumulator, 0, sizeof(struct rte_eth_stats));
626 * Fail-safe dev_infos_get rules:
630 * Use the maximum possible values for any field, so as not
631 * to impede any further configuration effort.
633 * Limits capabilities to those that are understood by the
634 * fail-safe PMD. This understanding stems from the fail-safe
635 * being capable of verifying that the related capability is
636 * expressed within the device configuration (struct rte_eth_conf).
638 * At least one probed sub_device:
640 * Uses values from the active probed sub_device
641 * The rationale here is that if any sub_device is less capable
642 * (for example concerning the number of queues) than the active
643 * sub_device, then its subsequent configuration will fail.
644 * It is impossible to foresee this failure when the failing sub_device
645 * is supposed to be plugged-in later on, so the configuration process
646 * is the single point of failure and error reporting.
648 * Uses a logical AND of RX capabilities among
649 * all sub_devices and the default capabilities.
650 * Uses a logical AND of TX capabilities among
651 * the active probed sub_device and the default capabilities.
655 fs_dev_infos_get(struct rte_eth_dev *dev,
656 struct rte_eth_dev_info *infos)
658 struct sub_device *sdev;
661 sdev = TX_SUBDEV(dev);
663 DEBUG("No probed device, using default infos");
664 rte_memcpy(&PRIV(dev)->infos, &default_infos,
665 sizeof(default_infos));
667 uint32_t rx_offload_capa;
669 rx_offload_capa = default_infos.rx_offload_capa;
670 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) {
671 rte_eth_dev_info_get(PORT_ID(sdev),
673 rx_offload_capa &= PRIV(dev)->infos.rx_offload_capa;
675 sdev = TX_SUBDEV(dev);
676 rte_eth_dev_info_get(PORT_ID(sdev), &PRIV(dev)->infos);
677 PRIV(dev)->infos.rx_offload_capa = rx_offload_capa;
678 PRIV(dev)->infos.tx_offload_capa &=
679 default_infos.tx_offload_capa;
680 PRIV(dev)->infos.flow_type_rss_offloads &=
681 default_infos.flow_type_rss_offloads;
683 rte_memcpy(infos, &PRIV(dev)->infos, sizeof(*infos));
686 static const uint32_t *
687 fs_dev_supported_ptypes_get(struct rte_eth_dev *dev)
689 struct sub_device *sdev;
690 struct rte_eth_dev *edev;
692 sdev = TX_SUBDEV(dev);
696 /* ENOTSUP: counts as no supported ptypes */
697 if (SUBOPS(sdev, dev_supported_ptypes_get) == NULL)
700 * The API does not permit to do a clean AND of all ptypes,
701 * It is also incomplete by design and we do not really care
702 * to have a best possible value in this context.
703 * We just return the ptypes of the device of highest
704 * priority, usually the PREFERRED device.
706 return SUBOPS(sdev, dev_supported_ptypes_get)(edev);
710 fs_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
712 struct sub_device *sdev;
716 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
717 DEBUG("Calling rte_eth_dev_set_mtu on sub_device %d", i);
718 ret = rte_eth_dev_set_mtu(PORT_ID(sdev), mtu);
720 ERROR("Operation rte_eth_dev_set_mtu failed for sub_device %d with error %d",
729 fs_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
731 struct sub_device *sdev;
735 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
736 DEBUG("Calling rte_eth_dev_vlan_filter on sub_device %d", i);
737 ret = rte_eth_dev_vlan_filter(PORT_ID(sdev), vlan_id, on);
739 ERROR("Operation rte_eth_dev_vlan_filter failed for sub_device %d"
740 " with error %d", i, ret);
748 fs_flow_ctrl_get(struct rte_eth_dev *dev,
749 struct rte_eth_fc_conf *fc_conf)
751 struct sub_device *sdev;
753 sdev = TX_SUBDEV(dev);
756 if (SUBOPS(sdev, flow_ctrl_get) == NULL)
758 return SUBOPS(sdev, flow_ctrl_get)(ETH(sdev), fc_conf);
762 fs_flow_ctrl_set(struct rte_eth_dev *dev,
763 struct rte_eth_fc_conf *fc_conf)
765 struct sub_device *sdev;
769 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
770 DEBUG("Calling rte_eth_dev_flow_ctrl_set on sub_device %d", i);
771 ret = rte_eth_dev_flow_ctrl_set(PORT_ID(sdev), fc_conf);
773 ERROR("Operation rte_eth_dev_flow_ctrl_set failed for sub_device %d"
774 " with error %d", i, ret);
782 fs_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
784 struct sub_device *sdev;
787 /* No check: already done within the rte_eth_dev_mac_addr_remove
788 * call for the fail-safe device.
790 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
791 rte_eth_dev_mac_addr_remove(PORT_ID(sdev),
792 &dev->data->mac_addrs[index]);
793 PRIV(dev)->mac_addr_pool[index] = 0;
797 fs_mac_addr_add(struct rte_eth_dev *dev,
798 struct ether_addr *mac_addr,
802 struct sub_device *sdev;
806 RTE_ASSERT(index < FAILSAFE_MAX_ETHADDR);
807 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
808 ret = rte_eth_dev_mac_addr_add(PORT_ID(sdev), mac_addr, vmdq);
810 ERROR("Operation rte_eth_dev_mac_addr_add failed for sub_device %"
811 PRIu8 " with error %d", i, ret);
815 if (index >= PRIV(dev)->nb_mac_addr) {
816 DEBUG("Growing mac_addrs array");
817 PRIV(dev)->nb_mac_addr = index;
819 PRIV(dev)->mac_addr_pool[index] = vmdq;
824 fs_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
826 struct sub_device *sdev;
829 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
830 rte_eth_dev_default_mac_addr_set(PORT_ID(sdev), mac_addr);
834 fs_filter_ctrl(struct rte_eth_dev *dev,
835 enum rte_filter_type type,
836 enum rte_filter_op op,
839 struct sub_device *sdev;
843 if (type == RTE_ETH_FILTER_GENERIC &&
844 op == RTE_ETH_FILTER_GET) {
845 *(const void **)arg = &fs_flow_ops;
848 FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
849 DEBUG("Calling rte_eth_dev_filter_ctrl on sub_device %d", i);
850 ret = rte_eth_dev_filter_ctrl(PORT_ID(sdev), type, op, arg);
852 ERROR("Operation rte_eth_dev_filter_ctrl failed for sub_device %d"
853 " with error %d", i, ret);
860 const struct eth_dev_ops failsafe_ops = {
861 .dev_configure = fs_dev_configure,
862 .dev_start = fs_dev_start,
863 .dev_stop = fs_dev_stop,
864 .dev_set_link_down = fs_dev_set_link_down,
865 .dev_set_link_up = fs_dev_set_link_up,
866 .dev_close = fs_dev_close,
867 .promiscuous_enable = fs_promiscuous_enable,
868 .promiscuous_disable = fs_promiscuous_disable,
869 .allmulticast_enable = fs_allmulticast_enable,
870 .allmulticast_disable = fs_allmulticast_disable,
871 .link_update = fs_link_update,
872 .stats_get = fs_stats_get,
873 .stats_reset = fs_stats_reset,
874 .dev_infos_get = fs_dev_infos_get,
875 .dev_supported_ptypes_get = fs_dev_supported_ptypes_get,
876 .mtu_set = fs_mtu_set,
877 .vlan_filter_set = fs_vlan_filter_set,
878 .rx_queue_setup = fs_rx_queue_setup,
879 .tx_queue_setup = fs_tx_queue_setup,
880 .rx_queue_release = fs_rx_queue_release,
881 .tx_queue_release = fs_tx_queue_release,
882 .flow_ctrl_get = fs_flow_ctrl_get,
883 .flow_ctrl_set = fs_flow_ctrl_set,
884 .mac_addr_remove = fs_mac_addr_remove,
885 .mac_addr_add = fs_mac_addr_add,
886 .mac_addr_set = fs_mac_addr_set,
887 .filter_ctrl = fs_filter_ctrl,