4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
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 Intel Corporation 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.
34 #include <sys/types.h>
35 #include <sys/queue.h>
44 #include <netinet/in.h>
46 #include <rte_byteorder.h>
48 #include <rte_debug.h>
49 #include <rte_interrupts.h>
51 #include <rte_memory.h>
52 #include <rte_memcpy.h>
53 #include <rte_memzone.h>
54 #include <rte_launch.h>
55 #include <rte_tailq.h>
57 #include <rte_per_lcore.h>
58 #include <rte_lcore.h>
59 #include <rte_atomic.h>
60 #include <rte_branch_prediction.h>
61 #include <rte_common.h>
63 #include <rte_mempool.h>
64 #include <rte_malloc.h>
66 #include <rte_errno.h>
67 #include <rte_spinlock.h>
69 #include "rte_ether.h"
70 #include "rte_ethdev.h"
72 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
73 #define PMD_DEBUG_TRACE(fmt, args...) do { \
74 RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args); \
77 #define PMD_DEBUG_TRACE(fmt, args...)
80 /* Macros for checking for restricting functions to primary instance only */
81 #define PROC_PRIMARY_OR_ERR_RET(retval) do { \
82 if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \
83 PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
87 #define PROC_PRIMARY_OR_RET() do { \
88 if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \
89 PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
94 /* Macros to check for invlaid function pointers in dev_ops structure */
95 #define FUNC_PTR_OR_ERR_RET(func, retval) do { \
96 if ((func) == NULL) { \
97 PMD_DEBUG_TRACE("Function not supported\n"); \
101 #define FUNC_PTR_OR_RET(func) do { \
102 if ((func) == NULL) { \
103 PMD_DEBUG_TRACE("Function not supported\n"); \
108 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
109 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
110 static struct rte_eth_dev_data *rte_eth_dev_data = NULL;
111 static uint8_t nb_ports = 0;
113 /* spinlock for eth device callbacks */
114 static rte_spinlock_t rte_eth_dev_cb_lock = RTE_SPINLOCK_INITIALIZER;
117 * The user application callback description.
119 * It contains callback address to be registered by user application,
120 * the pointer to the parameters for callback, and the event type.
122 struct rte_eth_dev_callback {
123 TAILQ_ENTRY(rte_eth_dev_callback) next; /**< Callbacks list */
124 rte_eth_dev_cb_fn cb_fn; /**< Callback address */
125 void *cb_arg; /**< Parameter for callback */
126 enum rte_eth_event_type event; /**< Interrupt event type */
127 uint32_t active; /**< Callback is executing */
136 rte_eth_dev_data_alloc(void)
138 const unsigned flags = 0;
139 const struct rte_memzone *mz;
141 if (rte_eal_process_type() == RTE_PROC_PRIMARY){
142 mz = rte_memzone_reserve(MZ_RTE_ETH_DEV_DATA,
143 RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data),
144 rte_socket_id(), flags);
146 mz = rte_memzone_lookup(MZ_RTE_ETH_DEV_DATA);
148 rte_panic("Cannot allocate memzone for ethernet port data\n");
150 rte_eth_dev_data = mz->addr;
151 if (rte_eal_process_type() == RTE_PROC_PRIMARY)
152 memset(rte_eth_dev_data, 0,
153 RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data));
157 rte_eth_dev_allocate(void)
159 struct rte_eth_dev *eth_dev;
161 if (nb_ports == RTE_MAX_ETHPORTS) {
162 PMD_DEBUG_TRACE("Reached maximum number of ethernet ports\n");
166 if (rte_eth_dev_data == NULL)
167 rte_eth_dev_data_alloc();
169 eth_dev = &rte_eth_devices[nb_ports];
170 eth_dev->data = &rte_eth_dev_data[nb_ports];
171 eth_dev->data->port_id = nb_ports++;
176 rte_eth_dev_init(struct rte_pci_driver *pci_drv,
177 struct rte_pci_device *pci_dev)
179 struct eth_driver *eth_drv;
180 struct rte_eth_dev *eth_dev;
183 eth_drv = (struct eth_driver *)pci_drv;
185 eth_dev = rte_eth_dev_allocate();
189 if (rte_eal_process_type() == RTE_PROC_PRIMARY){
190 eth_dev->data->dev_private = rte_zmalloc("ethdev private structure",
191 eth_drv->dev_private_size,
193 if (eth_dev->data->dev_private == NULL)
194 rte_panic("Cannot allocate memzone for private port data\n");
196 eth_dev->pci_dev = pci_dev;
197 eth_dev->driver = eth_drv;
198 eth_dev->data->rx_mbuf_alloc_failed = 0;
200 /* init user callbacks */
201 TAILQ_INIT(&(eth_dev->callbacks));
204 * Set the default maximum frame size.
206 eth_dev->data->max_frame_size = ETHER_MAX_LEN;
208 /* Invoke PMD device initialization function */
209 diag = (*eth_drv->eth_dev_init)(eth_drv, eth_dev);
213 PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x)"
214 " failed\n", pci_drv->name,
215 (unsigned) pci_dev->id.vendor_id,
216 (unsigned) pci_dev->id.device_id);
217 if (rte_eal_process_type() == RTE_PROC_PRIMARY)
218 rte_free(eth_dev->data->dev_private);
224 * Register an Ethernet [Poll Mode] driver.
226 * Function invoked by the initialization function of an Ethernet driver
227 * to simultaneously register itself as a PCI driver and as an Ethernet
229 * Invokes the rte_eal_pci_register() function to register the *pci_drv*
230 * structure embedded in the *eth_drv* structure, after having stored the
231 * address of the rte_eth_dev_init() function in the *devinit* field of
232 * the *pci_drv* structure.
233 * During the PCI probing phase, the rte_eth_dev_init() function is
234 * invoked for each PCI [Ethernet device] matching the embedded PCI
235 * identifiers provided by the driver.
238 rte_eth_driver_register(struct eth_driver *eth_drv)
240 eth_drv->pci_drv.devinit = rte_eth_dev_init;
241 rte_eal_pci_register(ð_drv->pci_drv);
245 rte_eth_dev_socket_id(uint8_t port_id)
247 if (port_id >= nb_ports)
249 return rte_eth_devices[port_id].pci_dev->numa_node;
253 rte_eth_dev_count(void)
259 rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
261 uint16_t old_nb_queues = dev->data->nb_rx_queues;
265 if (dev->data->rx_queues == NULL) { /* first time configuration */
266 dev->data->rx_queues = rte_zmalloc("ethdev->rx_queues",
267 sizeof(dev->data->rx_queues[0]) * nb_queues,
269 if (dev->data->rx_queues == NULL) {
270 dev->data->nb_rx_queues = 0;
273 } else { /* re-configure */
274 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
276 rxq = dev->data->rx_queues;
278 for (i = nb_queues; i < old_nb_queues; i++)
279 (*dev->dev_ops->rx_queue_release)(rxq[i]);
280 rxq = rte_realloc(rxq, sizeof(rxq[0]) * nb_queues,
285 if (nb_queues > old_nb_queues)
286 memset(rxq + old_nb_queues, 0,
287 sizeof(rxq[0]) * (nb_queues - old_nb_queues));
289 dev->data->rx_queues = rxq;
292 dev->data->nb_rx_queues = nb_queues;
297 rte_eth_dev_rx_queue_start(uint8_t port_id, uint16_t rx_queue_id)
299 struct rte_eth_dev *dev;
301 /* This function is only safe when called from the primary process
302 * in a multi-process setup*/
303 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
305 if (port_id >= nb_ports) {
306 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
310 dev = &rte_eth_devices[port_id];
311 if (rx_queue_id >= dev->data->nb_rx_queues) {
312 PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
316 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_start, -ENOTSUP);
318 return dev->dev_ops->rx_queue_start(dev, rx_queue_id);
323 rte_eth_dev_rx_queue_stop(uint8_t port_id, uint16_t rx_queue_id)
325 struct rte_eth_dev *dev;
327 /* This function is only safe when called from the primary process
328 * in a multi-process setup*/
329 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
331 if (port_id >= nb_ports) {
332 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
336 dev = &rte_eth_devices[port_id];
337 if (rx_queue_id >= dev->data->nb_rx_queues) {
338 PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
342 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_stop, -ENOTSUP);
344 return dev->dev_ops->rx_queue_stop(dev, rx_queue_id);
349 rte_eth_dev_tx_queue_start(uint8_t port_id, uint16_t tx_queue_id)
351 struct rte_eth_dev *dev;
353 /* This function is only safe when called from the primary process
354 * in a multi-process setup*/
355 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
357 if (port_id >= nb_ports) {
358 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
362 dev = &rte_eth_devices[port_id];
363 if (tx_queue_id >= dev->data->nb_tx_queues) {
364 PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
368 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_start, -ENOTSUP);
370 return dev->dev_ops->tx_queue_start(dev, tx_queue_id);
375 rte_eth_dev_tx_queue_stop(uint8_t port_id, uint16_t tx_queue_id)
377 struct rte_eth_dev *dev;
379 /* This function is only safe when called from the primary process
380 * in a multi-process setup*/
381 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
383 if (port_id >= nb_ports) {
384 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
388 dev = &rte_eth_devices[port_id];
389 if (tx_queue_id >= dev->data->nb_tx_queues) {
390 PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
394 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_stop, -ENOTSUP);
396 return dev->dev_ops->tx_queue_stop(dev, tx_queue_id);
401 rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
403 uint16_t old_nb_queues = dev->data->nb_tx_queues;
407 if (dev->data->tx_queues == NULL) { /* first time configuration */
408 dev->data->tx_queues = rte_zmalloc("ethdev->tx_queues",
409 sizeof(dev->data->tx_queues[0]) * nb_queues,
411 if (dev->data->tx_queues == NULL) {
412 dev->data->nb_tx_queues = 0;
415 } else { /* re-configure */
416 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);
418 txq = dev->data->tx_queues;
420 for (i = nb_queues; i < old_nb_queues; i++)
421 (*dev->dev_ops->tx_queue_release)(txq[i]);
422 txq = rte_realloc(txq, sizeof(txq[0]) * nb_queues,
427 if (nb_queues > old_nb_queues)
428 memset(txq + old_nb_queues, 0,
429 sizeof(txq[0]) * (nb_queues - old_nb_queues));
431 dev->data->tx_queues = txq;
434 dev->data->nb_tx_queues = nb_queues;
439 rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
440 const struct rte_eth_conf *dev_conf)
442 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
444 if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
445 /* check multi-queue mode */
446 if ((dev_conf->rxmode.mq_mode == ETH_MQ_RX_RSS) ||
447 (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) ||
448 (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB_RSS) ||
449 (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB)) {
450 /* SRIOV only works in VMDq enable mode */
451 PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
453 "wrong VMDQ mq_mode rx %u tx %u\n",
455 dev_conf->rxmode.mq_mode,
456 dev_conf->txmode.mq_mode);
460 switch (dev_conf->rxmode.mq_mode) {
461 case ETH_MQ_RX_VMDQ_RSS:
462 case ETH_MQ_RX_VMDQ_DCB:
463 case ETH_MQ_RX_VMDQ_DCB_RSS:
464 /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
465 PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
467 "unsupported VMDQ mq_mode rx %u\n",
468 port_id, dev_conf->rxmode.mq_mode);
470 default: /* ETH_MQ_RX_VMDQ_ONLY or ETH_MQ_RX_NONE */
471 /* if nothing mq mode configure, use default scheme */
472 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_ONLY;
473 if (RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool > 1)
474 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
478 switch (dev_conf->txmode.mq_mode) {
479 case ETH_MQ_TX_VMDQ_DCB:
480 /* DCB VMDQ in SRIOV mode, not implement yet */
481 PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
483 "unsupported VMDQ mq_mode tx %u\n",
484 port_id, dev_conf->txmode.mq_mode);
486 default: /* ETH_MQ_TX_VMDQ_ONLY or ETH_MQ_TX_NONE */
487 /* if nothing mq mode configure, use default scheme */
488 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_ONLY;
489 if (RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool > 1)
490 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
494 /* check valid queue number */
495 if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
496 (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
497 PMD_DEBUG_TRACE("ethdev port_id=%d SRIOV active, "
498 "queue number must less equal to %d\n",
499 port_id, RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
503 /* For vmdb+dcb mode check our configuration before we go further */
504 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB) {
505 const struct rte_eth_vmdq_dcb_conf *conf;
507 if (nb_rx_q != ETH_VMDQ_DCB_NUM_QUEUES) {
508 PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_rx_q "
510 port_id, ETH_VMDQ_DCB_NUM_QUEUES);
513 conf = &(dev_conf->rx_adv_conf.vmdq_dcb_conf);
514 if (! (conf->nb_queue_pools == ETH_16_POOLS ||
515 conf->nb_queue_pools == ETH_32_POOLS)) {
516 PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
517 "nb_queue_pools must be %d or %d\n",
518 port_id, ETH_16_POOLS, ETH_32_POOLS);
522 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_VMDQ_DCB) {
523 const struct rte_eth_vmdq_dcb_tx_conf *conf;
525 if (nb_tx_q != ETH_VMDQ_DCB_NUM_QUEUES) {
526 PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_tx_q "
528 port_id, ETH_VMDQ_DCB_NUM_QUEUES);
531 conf = &(dev_conf->tx_adv_conf.vmdq_dcb_tx_conf);
532 if (! (conf->nb_queue_pools == ETH_16_POOLS ||
533 conf->nb_queue_pools == ETH_32_POOLS)) {
534 PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
535 "nb_queue_pools != %d or nb_queue_pools "
537 port_id, ETH_16_POOLS, ETH_32_POOLS);
542 /* For DCB mode check our configuration before we go further */
543 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) {
544 const struct rte_eth_dcb_rx_conf *conf;
546 if (nb_rx_q != ETH_DCB_NUM_QUEUES) {
547 PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_rx_q "
549 port_id, ETH_DCB_NUM_QUEUES);
552 conf = &(dev_conf->rx_adv_conf.dcb_rx_conf);
553 if (! (conf->nb_tcs == ETH_4_TCS ||
554 conf->nb_tcs == ETH_8_TCS)) {
555 PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
556 "nb_tcs != %d or nb_tcs "
558 port_id, ETH_4_TCS, ETH_8_TCS);
563 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB) {
564 const struct rte_eth_dcb_tx_conf *conf;
566 if (nb_tx_q != ETH_DCB_NUM_QUEUES) {
567 PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_tx_q "
569 port_id, ETH_DCB_NUM_QUEUES);
572 conf = &(dev_conf->tx_adv_conf.dcb_tx_conf);
573 if (! (conf->nb_tcs == ETH_4_TCS ||
574 conf->nb_tcs == ETH_8_TCS)) {
575 PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
576 "nb_tcs != %d or nb_tcs "
578 port_id, ETH_4_TCS, ETH_8_TCS);
587 rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
588 const struct rte_eth_conf *dev_conf)
590 struct rte_eth_dev *dev;
591 struct rte_eth_dev_info dev_info;
594 /* This function is only safe when called from the primary process
595 * in a multi-process setup*/
596 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
598 if (port_id >= nb_ports || port_id >= RTE_MAX_ETHPORTS) {
599 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
602 dev = &rte_eth_devices[port_id];
604 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
605 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
607 if (dev->data->dev_started) {
609 "port %d must be stopped to allow configuration\n", port_id);
614 * Check that the numbers of RX and TX queues are not greater
615 * than the maximum number of RX and TX queues supported by the
618 (*dev->dev_ops->dev_infos_get)(dev, &dev_info);
619 if (nb_rx_q > dev_info.max_rx_queues) {
620 PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_queues=%d > %d\n",
621 port_id, nb_rx_q, dev_info.max_rx_queues);
625 PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_q == 0\n", port_id);
629 if (nb_tx_q > dev_info.max_tx_queues) {
630 PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_queues=%d > %d\n",
631 port_id, nb_tx_q, dev_info.max_tx_queues);
635 PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_q == 0\n", port_id);
639 /* Copy the dev_conf parameter into the dev structure */
640 memcpy(&dev->data->dev_conf, dev_conf, sizeof(dev->data->dev_conf));
643 * If jumbo frames are enabled, check that the maximum RX packet
644 * length is supported by the configured device.
646 if (dev_conf->rxmode.jumbo_frame == 1) {
647 if (dev_conf->rxmode.max_rx_pkt_len >
648 dev_info.max_rx_pktlen) {
649 PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
650 " > max valid value %u\n",
652 (unsigned)dev_conf->rxmode.max_rx_pkt_len,
653 (unsigned)dev_info.max_rx_pktlen);
656 else if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN) {
657 PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
658 " < min valid value %u\n",
660 (unsigned)dev_conf->rxmode.max_rx_pkt_len,
661 (unsigned)ETHER_MIN_LEN);
665 if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN ||
666 dev_conf->rxmode.max_rx_pkt_len > ETHER_MAX_LEN)
667 /* Use default value */
668 dev->data->dev_conf.rxmode.max_rx_pkt_len =
672 /* multipe queue mode checking */
673 diag = rte_eth_dev_check_mq_mode(port_id, nb_rx_q, nb_tx_q, dev_conf);
675 PMD_DEBUG_TRACE("port%d rte_eth_dev_check_mq_mode = %d\n",
681 * Setup new number of RX/TX queues and reconfigure device.
683 diag = rte_eth_dev_rx_queue_config(dev, nb_rx_q);
685 PMD_DEBUG_TRACE("port%d rte_eth_dev_rx_queue_config = %d\n",
690 diag = rte_eth_dev_tx_queue_config(dev, nb_tx_q);
692 PMD_DEBUG_TRACE("port%d rte_eth_dev_tx_queue_config = %d\n",
694 rte_eth_dev_rx_queue_config(dev, 0);
698 diag = (*dev->dev_ops->dev_configure)(dev);
700 PMD_DEBUG_TRACE("port%d dev_configure = %d\n",
702 rte_eth_dev_rx_queue_config(dev, 0);
703 rte_eth_dev_tx_queue_config(dev, 0);
711 rte_eth_dev_config_restore(uint8_t port_id)
713 struct rte_eth_dev *dev;
714 struct rte_eth_dev_info dev_info;
715 struct ether_addr addr;
719 dev = &rte_eth_devices[port_id];
721 rte_eth_dev_info_get(port_id, &dev_info);
723 if (RTE_ETH_DEV_SRIOV(dev).active)
724 pool = RTE_ETH_DEV_SRIOV(dev).def_vmdq_idx;
726 /* replay MAC address configuration */
727 for (i = 0; i < dev_info.max_mac_addrs; i++) {
728 addr = dev->data->mac_addrs[i];
730 /* skip zero address */
731 if (is_zero_ether_addr(&addr))
734 /* add address to the hardware */
735 if (*dev->dev_ops->mac_addr_add)
736 (*dev->dev_ops->mac_addr_add)(dev, &addr, i, pool);
738 PMD_DEBUG_TRACE("port %d: MAC address array not supported\n",
740 /* exit the loop but not return an error */
745 /* replay promiscuous configuration */
746 if (rte_eth_promiscuous_get(port_id) == 1)
747 rte_eth_promiscuous_enable(port_id);
748 else if (rte_eth_promiscuous_get(port_id) == 0)
749 rte_eth_promiscuous_disable(port_id);
751 /* replay allmulticast configuration */
752 if (rte_eth_allmulticast_get(port_id) == 1)
753 rte_eth_allmulticast_enable(port_id);
754 else if (rte_eth_allmulticast_get(port_id) == 0)
755 rte_eth_allmulticast_disable(port_id);
759 rte_eth_dev_start(uint8_t port_id)
761 struct rte_eth_dev *dev;
764 /* This function is only safe when called from the primary process
765 * in a multi-process setup*/
766 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
768 if (port_id >= nb_ports) {
769 PMD_DEBUG_TRACE("Invalid port_id=%" PRIu8 "\n", port_id);
772 dev = &rte_eth_devices[port_id];
774 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
776 if (dev->data->dev_started != 0) {
777 PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
778 " already started\n",
783 diag = (*dev->dev_ops->dev_start)(dev);
785 dev->data->dev_started = 1;
789 rte_eth_dev_config_restore(port_id);
795 rte_eth_dev_stop(uint8_t port_id)
797 struct rte_eth_dev *dev;
799 /* This function is only safe when called from the primary process
800 * in a multi-process setup*/
801 PROC_PRIMARY_OR_RET();
803 if (port_id >= nb_ports) {
804 PMD_DEBUG_TRACE("Invalid port_id=%" PRIu8 "\n", port_id);
807 dev = &rte_eth_devices[port_id];
809 FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop);
811 if (dev->data->dev_started == 0) {
812 PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
813 " already stopped\n",
818 dev->data->dev_started = 0;
819 (*dev->dev_ops->dev_stop)(dev);
823 rte_eth_dev_set_link_up(uint8_t port_id)
825 struct rte_eth_dev *dev;
827 /* This function is only safe when called from the primary process
828 * in a multi-process setup*/
829 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
831 if (port_id >= nb_ports) {
832 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
835 dev = &rte_eth_devices[port_id];
837 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_up, -ENOTSUP);
838 return (*dev->dev_ops->dev_set_link_up)(dev);
842 rte_eth_dev_set_link_down(uint8_t port_id)
844 struct rte_eth_dev *dev;
846 /* This function is only safe when called from the primary process
847 * in a multi-process setup*/
848 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
850 if (port_id >= nb_ports) {
851 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
854 dev = &rte_eth_devices[port_id];
856 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_down, -ENOTSUP);
857 return (*dev->dev_ops->dev_set_link_down)(dev);
861 rte_eth_dev_close(uint8_t port_id)
863 struct rte_eth_dev *dev;
865 /* This function is only safe when called from the primary process
866 * in a multi-process setup*/
867 PROC_PRIMARY_OR_RET();
869 if (port_id >= nb_ports) {
870 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
874 dev = &rte_eth_devices[port_id];
876 FUNC_PTR_OR_RET(*dev->dev_ops->dev_close);
877 dev->data->dev_started = 0;
878 (*dev->dev_ops->dev_close)(dev);
882 rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
883 uint16_t nb_rx_desc, unsigned int socket_id,
884 const struct rte_eth_rxconf *rx_conf,
885 struct rte_mempool *mp)
888 uint32_t mbp_buf_size;
889 struct rte_eth_dev *dev;
890 struct rte_pktmbuf_pool_private *mbp_priv;
891 struct rte_eth_dev_info dev_info;
893 /* This function is only safe when called from the primary process
894 * in a multi-process setup*/
895 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
897 if (port_id >= nb_ports) {
898 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
901 dev = &rte_eth_devices[port_id];
902 if (rx_queue_id >= dev->data->nb_rx_queues) {
903 PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
907 if (dev->data->dev_started) {
909 "port %d must be stopped to allow configuration\n", port_id);
913 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
914 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP);
917 * Check the size of the mbuf data buffer.
918 * This value must be provided in the private data of the memory pool.
919 * First check that the memory pool has a valid private data.
921 (*dev->dev_ops->dev_infos_get)(dev, &dev_info);
922 if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) {
923 PMD_DEBUG_TRACE("%s private_data_size %d < %d\n",
924 mp->name, (int) mp->private_data_size,
925 (int) sizeof(struct rte_pktmbuf_pool_private));
928 mbp_priv = rte_mempool_get_priv(mp);
929 mbp_buf_size = mbp_priv->mbuf_data_room_size;
931 if ((mbp_buf_size - RTE_PKTMBUF_HEADROOM) < dev_info.min_rx_bufsize) {
932 PMD_DEBUG_TRACE("%s mbuf_data_room_size %d < %d "
933 "(RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)"
937 (int)(RTE_PKTMBUF_HEADROOM +
938 dev_info.min_rx_bufsize),
939 (int)RTE_PKTMBUF_HEADROOM,
940 (int)dev_info.min_rx_bufsize);
944 ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
945 socket_id, rx_conf, mp);
947 if (!dev->data->min_rx_buf_size ||
948 dev->data->min_rx_buf_size > mbp_buf_size)
949 dev->data->min_rx_buf_size = mbp_buf_size;
956 rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
957 uint16_t nb_tx_desc, unsigned int socket_id,
958 const struct rte_eth_txconf *tx_conf)
960 struct rte_eth_dev *dev;
962 /* This function is only safe when called from the primary process
963 * in a multi-process setup*/
964 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
966 if (port_id >= RTE_MAX_ETHPORTS || port_id >= nb_ports) {
967 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
970 dev = &rte_eth_devices[port_id];
971 if (tx_queue_id >= dev->data->nb_tx_queues) {
972 PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
976 if (dev->data->dev_started) {
978 "port %d must be stopped to allow configuration\n", port_id);
982 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_setup, -ENOTSUP);
983 return (*dev->dev_ops->tx_queue_setup)(dev, tx_queue_id, nb_tx_desc,
988 rte_eth_promiscuous_enable(uint8_t port_id)
990 struct rte_eth_dev *dev;
992 if (port_id >= nb_ports) {
993 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
996 dev = &rte_eth_devices[port_id];
998 FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_enable);
999 (*dev->dev_ops->promiscuous_enable)(dev);
1000 dev->data->promiscuous = 1;
1004 rte_eth_promiscuous_disable(uint8_t port_id)
1006 struct rte_eth_dev *dev;
1008 if (port_id >= nb_ports) {
1009 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1012 dev = &rte_eth_devices[port_id];
1014 FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_disable);
1015 dev->data->promiscuous = 0;
1016 (*dev->dev_ops->promiscuous_disable)(dev);
1020 rte_eth_promiscuous_get(uint8_t port_id)
1022 struct rte_eth_dev *dev;
1024 if (port_id >= nb_ports) {
1025 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1029 dev = &rte_eth_devices[port_id];
1030 return dev->data->promiscuous;
1034 rte_eth_allmulticast_enable(uint8_t port_id)
1036 struct rte_eth_dev *dev;
1038 if (port_id >= nb_ports) {
1039 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1042 dev = &rte_eth_devices[port_id];
1044 FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_enable);
1045 (*dev->dev_ops->allmulticast_enable)(dev);
1046 dev->data->all_multicast = 1;
1050 rte_eth_allmulticast_disable(uint8_t port_id)
1052 struct rte_eth_dev *dev;
1054 if (port_id >= nb_ports) {
1055 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1058 dev = &rte_eth_devices[port_id];
1060 FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_disable);
1061 dev->data->all_multicast = 0;
1062 (*dev->dev_ops->allmulticast_disable)(dev);
1066 rte_eth_allmulticast_get(uint8_t port_id)
1068 struct rte_eth_dev *dev;
1070 if (port_id >= nb_ports) {
1071 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1075 dev = &rte_eth_devices[port_id];
1076 return dev->data->all_multicast;
1080 rte_eth_dev_atomic_read_link_status(struct rte_eth_dev *dev,
1081 struct rte_eth_link *link)
1083 struct rte_eth_link *dst = link;
1084 struct rte_eth_link *src = &(dev->data->dev_link);
1086 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
1087 *(uint64_t *)src) == 0)
1094 rte_eth_link_get(uint8_t port_id, struct rte_eth_link *eth_link)
1096 struct rte_eth_dev *dev;
1098 if (port_id >= nb_ports) {
1099 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1102 dev = &rte_eth_devices[port_id];
1103 FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
1105 if (dev->data->dev_conf.intr_conf.lsc != 0)
1106 rte_eth_dev_atomic_read_link_status(dev, eth_link);
1108 (*dev->dev_ops->link_update)(dev, 1);
1109 *eth_link = dev->data->dev_link;
1114 rte_eth_link_get_nowait(uint8_t port_id, struct rte_eth_link *eth_link)
1116 struct rte_eth_dev *dev;
1118 if (port_id >= nb_ports) {
1119 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1122 dev = &rte_eth_devices[port_id];
1123 FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
1125 if (dev->data->dev_conf.intr_conf.lsc != 0)
1126 rte_eth_dev_atomic_read_link_status(dev, eth_link);
1128 (*dev->dev_ops->link_update)(dev, 0);
1129 *eth_link = dev->data->dev_link;
1134 rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats)
1136 struct rte_eth_dev *dev;
1138 if (port_id >= nb_ports) {
1139 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1142 dev = &rte_eth_devices[port_id];
1143 memset(stats, 0, sizeof(*stats));
1145 FUNC_PTR_OR_RET(*dev->dev_ops->stats_get);
1146 (*dev->dev_ops->stats_get)(dev, stats);
1147 stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
1151 rte_eth_stats_reset(uint8_t port_id)
1153 struct rte_eth_dev *dev;
1155 if (port_id >= nb_ports) {
1156 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1159 dev = &rte_eth_devices[port_id];
1161 FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);
1162 (*dev->dev_ops->stats_reset)(dev);
1167 set_queue_stats_mapping(uint8_t port_id, uint16_t queue_id, uint8_t stat_idx,
1170 struct rte_eth_dev *dev;
1172 if (port_id >= nb_ports) {
1173 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1176 dev = &rte_eth_devices[port_id];
1178 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_stats_mapping_set, -ENOTSUP);
1179 return (*dev->dev_ops->queue_stats_mapping_set)
1180 (dev, queue_id, stat_idx, is_rx);
1185 rte_eth_dev_set_tx_queue_stats_mapping(uint8_t port_id, uint16_t tx_queue_id,
1188 return set_queue_stats_mapping(port_id, tx_queue_id, stat_idx,
1194 rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
1197 return set_queue_stats_mapping(port_id, rx_queue_id, stat_idx,
1203 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
1205 struct rte_eth_dev *dev;
1207 if (port_id >= nb_ports) {
1208 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1211 dev = &rte_eth_devices[port_id];
1213 /* Default device offload capabilities to zero */
1214 dev_info->rx_offload_capa = 0;
1215 dev_info->tx_offload_capa = 0;
1216 dev_info->if_index = 0;
1217 FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
1218 (*dev->dev_ops->dev_infos_get)(dev, dev_info);
1219 dev_info->pci_dev = dev->pci_dev;
1221 dev_info->driver_name = dev->driver->pci_drv.name;
1225 rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr)
1227 struct rte_eth_dev *dev;
1229 if (port_id >= nb_ports) {
1230 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1233 dev = &rte_eth_devices[port_id];
1234 ether_addr_copy(&dev->data->mac_addrs[0], mac_addr);
1238 rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t vlan_id, int on)
1240 struct rte_eth_dev *dev;
1242 if (port_id >= nb_ports) {
1243 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1246 dev = &rte_eth_devices[port_id];
1247 if (! (dev->data->dev_conf.rxmode.hw_vlan_filter)) {
1248 PMD_DEBUG_TRACE("port %d: vlan-filtering disabled\n", port_id);
1252 if (vlan_id > 4095) {
1253 PMD_DEBUG_TRACE("(port_id=%d) invalid vlan_id=%u > 4095\n",
1254 port_id, (unsigned) vlan_id);
1257 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_filter_set, -ENOTSUP);
1258 (*dev->dev_ops->vlan_filter_set)(dev, vlan_id, on);
1263 rte_eth_dev_set_vlan_strip_on_queue(uint8_t port_id, uint16_t rx_queue_id, int on)
1265 struct rte_eth_dev *dev;
1267 if (port_id >= nb_ports) {
1268 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1272 dev = &rte_eth_devices[port_id];
1273 if (rx_queue_id >= dev->data->nb_rx_queues) {
1274 PMD_DEBUG_TRACE("Invalid rx_queue_id=%d\n", port_id);
1278 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
1279 (*dev->dev_ops->vlan_strip_queue_set)(dev, rx_queue_id, on);
1285 rte_eth_dev_set_vlan_ether_type(uint8_t port_id, uint16_t tpid)
1287 struct rte_eth_dev *dev;
1289 if (port_id >= nb_ports) {
1290 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1294 dev = &rte_eth_devices[port_id];
1295 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_tpid_set, -ENOTSUP);
1296 (*dev->dev_ops->vlan_tpid_set)(dev, tpid);
1302 rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask)
1304 struct rte_eth_dev *dev;
1309 if (port_id >= nb_ports) {
1310 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1314 dev = &rte_eth_devices[port_id];
1316 /*check which option changed by application*/
1317 cur = !!(offload_mask & ETH_VLAN_STRIP_OFFLOAD);
1318 org = !!(dev->data->dev_conf.rxmode.hw_vlan_strip);
1320 dev->data->dev_conf.rxmode.hw_vlan_strip = (uint8_t)cur;
1321 mask |= ETH_VLAN_STRIP_MASK;
1324 cur = !!(offload_mask & ETH_VLAN_FILTER_OFFLOAD);
1325 org = !!(dev->data->dev_conf.rxmode.hw_vlan_filter);
1327 dev->data->dev_conf.rxmode.hw_vlan_filter = (uint8_t)cur;
1328 mask |= ETH_VLAN_FILTER_MASK;
1331 cur = !!(offload_mask & ETH_VLAN_EXTEND_OFFLOAD);
1332 org = !!(dev->data->dev_conf.rxmode.hw_vlan_extend);
1334 dev->data->dev_conf.rxmode.hw_vlan_extend = (uint8_t)cur;
1335 mask |= ETH_VLAN_EXTEND_MASK;
1342 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP);
1343 (*dev->dev_ops->vlan_offload_set)(dev, mask);
1349 rte_eth_dev_get_vlan_offload(uint8_t port_id)
1351 struct rte_eth_dev *dev;
1354 if (port_id >= nb_ports) {
1355 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1359 dev = &rte_eth_devices[port_id];
1361 if (dev->data->dev_conf.rxmode.hw_vlan_strip)
1362 ret |= ETH_VLAN_STRIP_OFFLOAD ;
1364 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
1365 ret |= ETH_VLAN_FILTER_OFFLOAD ;
1367 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
1368 ret |= ETH_VLAN_EXTEND_OFFLOAD ;
1374 rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on)
1376 struct rte_eth_dev *dev;
1378 if (port_id >= nb_ports) {
1379 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1382 dev = &rte_eth_devices[port_id];
1383 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_pvid_set, -ENOTSUP);
1384 (*dev->dev_ops->vlan_pvid_set)(dev, pvid, on);
1390 rte_eth_dev_fdir_add_signature_filter(uint8_t port_id,
1391 struct rte_fdir_filter *fdir_filter,
1394 struct rte_eth_dev *dev;
1396 if (port_id >= nb_ports) {
1397 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1401 dev = &rte_eth_devices[port_id];
1403 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
1404 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1405 port_id, dev->data->dev_conf.fdir_conf.mode);
1409 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1410 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1411 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1412 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1413 "None l4type, source & destinations ports " \
1414 "should be null!\n");
1418 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_add_signature_filter, -ENOTSUP);
1419 return (*dev->dev_ops->fdir_add_signature_filter)(dev, fdir_filter,
1424 rte_eth_dev_fdir_update_signature_filter(uint8_t port_id,
1425 struct rte_fdir_filter *fdir_filter,
1428 struct rte_eth_dev *dev;
1430 if (port_id >= nb_ports) {
1431 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1435 dev = &rte_eth_devices[port_id];
1437 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
1438 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1439 port_id, dev->data->dev_conf.fdir_conf.mode);
1443 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1444 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1445 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1446 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1447 "None l4type, source & destinations ports " \
1448 "should be null!\n");
1452 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_update_signature_filter, -ENOTSUP);
1453 return (*dev->dev_ops->fdir_update_signature_filter)(dev, fdir_filter,
1459 rte_eth_dev_fdir_remove_signature_filter(uint8_t port_id,
1460 struct rte_fdir_filter *fdir_filter)
1462 struct rte_eth_dev *dev;
1464 if (port_id >= nb_ports) {
1465 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1469 dev = &rte_eth_devices[port_id];
1471 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
1472 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1473 port_id, dev->data->dev_conf.fdir_conf.mode);
1477 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1478 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1479 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1480 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1481 "None l4type source & destinations ports " \
1482 "should be null!\n");
1486 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_signature_filter, -ENOTSUP);
1487 return (*dev->dev_ops->fdir_remove_signature_filter)(dev, fdir_filter);
1491 rte_eth_dev_fdir_get_infos(uint8_t port_id, struct rte_eth_fdir *fdir)
1493 struct rte_eth_dev *dev;
1495 if (port_id >= nb_ports) {
1496 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1500 dev = &rte_eth_devices[port_id];
1501 if (! (dev->data->dev_conf.fdir_conf.mode)) {
1502 PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
1506 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_infos_get, -ENOTSUP);
1508 (*dev->dev_ops->fdir_infos_get)(dev, fdir);
1513 rte_eth_dev_fdir_add_perfect_filter(uint8_t port_id,
1514 struct rte_fdir_filter *fdir_filter,
1515 uint16_t soft_id, uint8_t queue,
1518 struct rte_eth_dev *dev;
1520 if (port_id >= nb_ports) {
1521 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1525 dev = &rte_eth_devices[port_id];
1527 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
1528 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1529 port_id, dev->data->dev_conf.fdir_conf.mode);
1533 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1534 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1535 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1536 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1537 "None l4type, source & destinations ports " \
1538 "should be null!\n");
1542 /* For now IPv6 is not supported with perfect filter */
1543 if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
1546 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_add_perfect_filter, -ENOTSUP);
1547 return (*dev->dev_ops->fdir_add_perfect_filter)(dev, fdir_filter,
1553 rte_eth_dev_fdir_update_perfect_filter(uint8_t port_id,
1554 struct rte_fdir_filter *fdir_filter,
1555 uint16_t soft_id, uint8_t queue,
1558 struct rte_eth_dev *dev;
1560 if (port_id >= nb_ports) {
1561 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1565 dev = &rte_eth_devices[port_id];
1567 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
1568 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1569 port_id, dev->data->dev_conf.fdir_conf.mode);
1573 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1574 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1575 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1576 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1577 "None l4type, source & destinations ports " \
1578 "should be null!\n");
1582 /* For now IPv6 is not supported with perfect filter */
1583 if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
1586 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_update_perfect_filter, -ENOTSUP);
1587 return (*dev->dev_ops->fdir_update_perfect_filter)(dev, fdir_filter,
1588 soft_id, queue, drop);
1592 rte_eth_dev_fdir_remove_perfect_filter(uint8_t port_id,
1593 struct rte_fdir_filter *fdir_filter,
1596 struct rte_eth_dev *dev;
1598 if (port_id >= nb_ports) {
1599 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1603 dev = &rte_eth_devices[port_id];
1605 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
1606 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1607 port_id, dev->data->dev_conf.fdir_conf.mode);
1611 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1612 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1613 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1614 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1615 "None l4type, source & destinations ports " \
1616 "should be null!\n");
1620 /* For now IPv6 is not supported with perfect filter */
1621 if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
1624 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_perfect_filter, -ENOTSUP);
1625 return (*dev->dev_ops->fdir_remove_perfect_filter)(dev, fdir_filter,
1630 rte_eth_dev_fdir_set_masks(uint8_t port_id, struct rte_fdir_masks *fdir_mask)
1632 struct rte_eth_dev *dev;
1634 if (port_id >= nb_ports) {
1635 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1639 dev = &rte_eth_devices[port_id];
1640 if (! (dev->data->dev_conf.fdir_conf.mode)) {
1641 PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
1645 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_set_masks, -ENOTSUP);
1646 return (*dev->dev_ops->fdir_set_masks)(dev, fdir_mask);
1650 rte_eth_dev_flow_ctrl_get(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
1652 struct rte_eth_dev *dev;
1654 if (port_id >= nb_ports) {
1655 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1659 dev = &rte_eth_devices[port_id];
1660 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_get, -ENOTSUP);
1661 memset(fc_conf, 0, sizeof(*fc_conf));
1662 return (*dev->dev_ops->flow_ctrl_get)(dev, fc_conf);
1666 rte_eth_dev_flow_ctrl_set(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
1668 struct rte_eth_dev *dev;
1670 if (port_id >= nb_ports) {
1671 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1675 if ((fc_conf->send_xon != 0) && (fc_conf->send_xon != 1)) {
1676 PMD_DEBUG_TRACE("Invalid send_xon, only 0/1 allowed\n");
1680 dev = &rte_eth_devices[port_id];
1681 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_set, -ENOTSUP);
1682 return (*dev->dev_ops->flow_ctrl_set)(dev, fc_conf);
1686 rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id, struct rte_eth_pfc_conf *pfc_conf)
1688 struct rte_eth_dev *dev;
1690 if (port_id >= nb_ports) {
1691 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1695 if (pfc_conf->priority > (ETH_DCB_NUM_USER_PRIORITIES - 1)) {
1696 PMD_DEBUG_TRACE("Invalid priority, only 0-7 allowed\n");
1700 dev = &rte_eth_devices[port_id];
1701 /* High water, low water validation are device specific */
1702 if (*dev->dev_ops->priority_flow_ctrl_set)
1703 return (*dev->dev_ops->priority_flow_ctrl_set)(dev, pfc_conf);
1708 rte_eth_dev_rss_reta_update(uint8_t port_id, struct rte_eth_rss_reta *reta_conf)
1710 struct rte_eth_dev *dev;
1714 if (port_id >= nb_ports) {
1715 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1719 /* Invalid mask bit(s) setting */
1720 if ((reta_conf->mask_lo == 0) && (reta_conf->mask_hi == 0)) {
1721 PMD_DEBUG_TRACE("Invalid update mask bits for port=%d\n",port_id);
1725 dev = &rte_eth_devices[port_id];
1726 max_rxq = (dev->data->nb_rx_queues <= ETH_RSS_RETA_MAX_QUEUE) ?
1727 dev->data->nb_rx_queues : ETH_RSS_RETA_MAX_QUEUE;
1728 if (reta_conf->mask_lo != 0) {
1729 for (i = 0; i < ETH_RSS_RETA_NUM_ENTRIES/2; i++) {
1730 if ((reta_conf->mask_lo & (1ULL << i)) &&
1731 (reta_conf->reta[i] >= max_rxq)) {
1732 PMD_DEBUG_TRACE("RETA hash index output"
1733 "configration for port=%d,invalid"
1734 "queue=%d\n",port_id,reta_conf->reta[i]);
1741 if (reta_conf->mask_hi != 0) {
1742 for (i = 0; i< ETH_RSS_RETA_NUM_ENTRIES/2; i++) {
1743 j = (uint8_t)(i + ETH_RSS_RETA_NUM_ENTRIES/2);
1745 /* Check if the max entry >= 128 */
1746 if ((reta_conf->mask_hi & (1ULL << i)) &&
1747 (reta_conf->reta[j] >= max_rxq)) {
1748 PMD_DEBUG_TRACE("RETA hash index output"
1749 "configration for port=%d,invalid"
1750 "queue=%d\n",port_id,reta_conf->reta[j]);
1757 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_update, -ENOTSUP);
1758 return (*dev->dev_ops->reta_update)(dev, reta_conf);
1762 rte_eth_dev_rss_reta_query(uint8_t port_id, struct rte_eth_rss_reta *reta_conf)
1764 struct rte_eth_dev *dev;
1766 if (port_id >= nb_ports) {
1767 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1771 if((reta_conf->mask_lo == 0) && (reta_conf->mask_hi == 0)) {
1772 PMD_DEBUG_TRACE("Invalid update mask bits for the port=%d\n",port_id);
1776 dev = &rte_eth_devices[port_id];
1777 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_query, -ENOTSUP);
1778 return (*dev->dev_ops->reta_query)(dev, reta_conf);
1782 rte_eth_dev_rss_hash_update(uint8_t port_id, struct rte_eth_rss_conf *rss_conf)
1784 struct rte_eth_dev *dev;
1785 uint16_t rss_hash_protos;
1787 if (port_id >= nb_ports) {
1788 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1791 rss_hash_protos = rss_conf->rss_hf;
1792 if ((rss_hash_protos != 0) &&
1793 ((rss_hash_protos & ETH_RSS_PROTO_MASK) == 0)) {
1794 PMD_DEBUG_TRACE("Invalid rss_hash_protos=0x%x\n",
1798 dev = &rte_eth_devices[port_id];
1799 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP);
1800 return (*dev->dev_ops->rss_hash_update)(dev, rss_conf);
1804 rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
1805 struct rte_eth_rss_conf *rss_conf)
1807 struct rte_eth_dev *dev;
1809 if (port_id >= nb_ports) {
1810 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1813 dev = &rte_eth_devices[port_id];
1814 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
1815 return (*dev->dev_ops->rss_hash_conf_get)(dev, rss_conf);
1819 rte_eth_led_on(uint8_t port_id)
1821 struct rte_eth_dev *dev;
1823 if (port_id >= nb_ports) {
1824 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1828 dev = &rte_eth_devices[port_id];
1829 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_on, -ENOTSUP);
1830 return ((*dev->dev_ops->dev_led_on)(dev));
1834 rte_eth_led_off(uint8_t port_id)
1836 struct rte_eth_dev *dev;
1838 if (port_id >= nb_ports) {
1839 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1843 dev = &rte_eth_devices[port_id];
1844 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_off, -ENOTSUP);
1845 return ((*dev->dev_ops->dev_led_off)(dev));
1849 * Returns index into MAC address array of addr. Use 00:00:00:00:00:00 to find
1853 get_mac_addr_index(uint8_t port_id, struct ether_addr *addr)
1855 struct rte_eth_dev_info dev_info;
1856 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
1859 rte_eth_dev_info_get(port_id, &dev_info);
1861 for (i = 0; i < dev_info.max_mac_addrs; i++)
1862 if (memcmp(addr, &dev->data->mac_addrs[i], ETHER_ADDR_LEN) == 0)
1868 static struct ether_addr null_mac_addr = {{0, 0, 0, 0, 0, 0}};
1871 rte_eth_dev_mac_addr_add(uint8_t port_id, struct ether_addr *addr,
1874 struct rte_eth_dev *dev;
1878 if (port_id >= nb_ports) {
1879 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1882 dev = &rte_eth_devices[port_id];
1883 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
1885 if (is_zero_ether_addr(addr)) {
1886 PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
1890 if (pool >= ETH_64_POOLS) {
1891 PMD_DEBUG_TRACE("pool id must be 0-%d\n",ETH_64_POOLS - 1);
1895 index = get_mac_addr_index(port_id, addr);
1897 index = get_mac_addr_index(port_id, &null_mac_addr);
1899 PMD_DEBUG_TRACE("port %d: MAC address array full\n",
1904 pool_mask = dev->data->mac_pool_sel[index];
1906 /* Check if both MAC address and pool is alread there, and do nothing */
1907 if (pool_mask & (1ULL << pool))
1912 (*dev->dev_ops->mac_addr_add)(dev, addr, index, pool);
1914 /* Update address in NIC data structure */
1915 ether_addr_copy(addr, &dev->data->mac_addrs[index]);
1917 /* Update pool bitmap in NIC data structure */
1918 dev->data->mac_pool_sel[index] |= (1ULL << pool);
1924 rte_eth_dev_mac_addr_remove(uint8_t port_id, struct ether_addr *addr)
1926 struct rte_eth_dev *dev;
1929 if (port_id >= nb_ports) {
1930 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1933 dev = &rte_eth_devices[port_id];
1934 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
1936 index = get_mac_addr_index(port_id, addr);
1938 PMD_DEBUG_TRACE("port %d: Cannot remove default MAC address\n", port_id);
1939 return (-EADDRINUSE);
1940 } else if (index < 0)
1941 return 0; /* Do nothing if address wasn't found */
1944 (*dev->dev_ops->mac_addr_remove)(dev, index);
1946 /* Update address in NIC data structure */
1947 ether_addr_copy(&null_mac_addr, &dev->data->mac_addrs[index]);
1953 rte_eth_dev_set_vf_rxmode(uint8_t port_id, uint16_t vf,
1954 uint16_t rx_mode, uint8_t on)
1957 struct rte_eth_dev *dev;
1958 struct rte_eth_dev_info dev_info;
1960 if (port_id >= nb_ports) {
1961 PMD_DEBUG_TRACE("set VF RX mode:Invalid port_id=%d\n",
1966 dev = &rte_eth_devices[port_id];
1967 rte_eth_dev_info_get(port_id, &dev_info);
1969 num_vfs = dev_info.max_vfs;
1972 PMD_DEBUG_TRACE("set VF RX mode:invalid VF id %d\n", vf);
1977 PMD_DEBUG_TRACE("set VF RX mode:mode mask ca not be zero\n");
1980 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx_mode, -ENOTSUP);
1981 return (*dev->dev_ops->set_vf_rx_mode)(dev, vf, rx_mode, on);
1985 * Returns index into MAC address array of addr. Use 00:00:00:00:00:00 to find
1989 get_hash_mac_addr_index(uint8_t port_id, struct ether_addr *addr)
1991 struct rte_eth_dev_info dev_info;
1992 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
1995 rte_eth_dev_info_get(port_id, &dev_info);
1996 if (!dev->data->hash_mac_addrs)
1999 for (i = 0; i < dev_info.max_hash_mac_addrs; i++)
2000 if (memcmp(addr, &dev->data->hash_mac_addrs[i],
2001 ETHER_ADDR_LEN) == 0)
2008 rte_eth_dev_uc_hash_table_set(uint8_t port_id, struct ether_addr *addr,
2013 struct rte_eth_dev *dev;
2015 if (port_id >= nb_ports) {
2016 PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=%d\n",
2021 dev = &rte_eth_devices[port_id];
2022 if (is_zero_ether_addr(addr)) {
2023 PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
2028 index = get_hash_mac_addr_index(port_id, addr);
2029 /* Check if it's already there, and do nothing */
2030 if ((index >= 0) && (on))
2035 PMD_DEBUG_TRACE("port %d: the MAC address was not"
2036 "set in UTA\n", port_id);
2040 index = get_hash_mac_addr_index(port_id, &null_mac_addr);
2042 PMD_DEBUG_TRACE("port %d: MAC address array full\n",
2048 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_hash_table_set, -ENOTSUP);
2049 ret = (*dev->dev_ops->uc_hash_table_set)(dev, addr, on);
2051 /* Update address in NIC data structure */
2053 ether_addr_copy(addr,
2054 &dev->data->hash_mac_addrs[index]);
2056 ether_addr_copy(&null_mac_addr,
2057 &dev->data->hash_mac_addrs[index]);
2064 rte_eth_dev_uc_all_hash_table_set(uint8_t port_id, uint8_t on)
2066 struct rte_eth_dev *dev;
2068 if (port_id >= nb_ports) {
2069 PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=%d\n",
2074 dev = &rte_eth_devices[port_id];
2076 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_all_hash_table_set, -ENOTSUP);
2077 return (*dev->dev_ops->uc_all_hash_table_set)(dev, on);
2081 rte_eth_dev_set_vf_rx(uint8_t port_id,uint16_t vf, uint8_t on)
2084 struct rte_eth_dev *dev;
2085 struct rte_eth_dev_info dev_info;
2087 if (port_id >= nb_ports) {
2088 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2092 dev = &rte_eth_devices[port_id];
2093 rte_eth_dev_info_get(port_id, &dev_info);
2095 num_vfs = dev_info.max_vfs;
2098 PMD_DEBUG_TRACE("port %d: invalid vf id\n", port_id);
2102 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx, -ENOTSUP);
2103 return (*dev->dev_ops->set_vf_rx)(dev, vf,on);
2107 rte_eth_dev_set_vf_tx(uint8_t port_id,uint16_t vf, uint8_t on)
2110 struct rte_eth_dev *dev;
2111 struct rte_eth_dev_info dev_info;
2113 if (port_id >= nb_ports) {
2114 PMD_DEBUG_TRACE("set pool tx:Invalid port_id=%d\n", port_id);
2118 dev = &rte_eth_devices[port_id];
2119 rte_eth_dev_info_get(port_id, &dev_info);
2121 num_vfs = dev_info.max_vfs;
2124 PMD_DEBUG_TRACE("set pool tx:invalid pool id=%d\n", vf);
2128 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_tx, -ENOTSUP);
2129 return (*dev->dev_ops->set_vf_tx)(dev, vf,on);
2133 rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, uint16_t vlan_id,
2134 uint64_t vf_mask,uint8_t vlan_on)
2136 struct rte_eth_dev *dev;
2138 if (port_id >= nb_ports) {
2139 PMD_DEBUG_TRACE("VF VLAN filter:invalid port id=%d\n",
2143 dev = &rte_eth_devices[port_id];
2145 if(vlan_id > ETHER_MAX_VLAN_ID)
2147 PMD_DEBUG_TRACE("VF VLAN filter:invalid VLAN id=%d\n",
2153 PMD_DEBUG_TRACE("VF VLAN filter:pool_mask can not be 0\n");
2157 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_filter, -ENOTSUP);
2158 return (*dev->dev_ops->set_vf_vlan_filter)(dev, vlan_id,
2162 int rte_eth_set_queue_rate_limit(uint8_t port_id, uint16_t queue_idx,
2165 struct rte_eth_dev *dev;
2166 struct rte_eth_dev_info dev_info;
2167 struct rte_eth_link link;
2169 if (port_id >= nb_ports) {
2170 PMD_DEBUG_TRACE("set queue rate limit:invalid port id=%d\n",
2175 dev = &rte_eth_devices[port_id];
2176 rte_eth_dev_info_get(port_id, &dev_info);
2177 link = dev->data->dev_link;
2179 if (queue_idx > dev_info.max_tx_queues) {
2180 PMD_DEBUG_TRACE("set queue rate limit:port %d: "
2181 "invalid queue id=%d\n", port_id, queue_idx);
2185 if (tx_rate > link.link_speed) {
2186 PMD_DEBUG_TRACE("set queue rate limit:invalid tx_rate=%d, "
2187 "bigger than link speed= %d\n",
2188 tx_rate, link_speed);
2192 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_queue_rate_limit, -ENOTSUP);
2193 return (*dev->dev_ops->set_queue_rate_limit)(dev, queue_idx, tx_rate);
2196 int rte_eth_set_vf_rate_limit(uint8_t port_id, uint16_t vf, uint16_t tx_rate,
2199 struct rte_eth_dev *dev;
2200 struct rte_eth_dev_info dev_info;
2201 struct rte_eth_link link;
2206 if (port_id >= nb_ports) {
2207 PMD_DEBUG_TRACE("set VF rate limit:invalid port id=%d\n",
2212 dev = &rte_eth_devices[port_id];
2213 rte_eth_dev_info_get(port_id, &dev_info);
2214 link = dev->data->dev_link;
2216 if (vf > dev_info.max_vfs) {
2217 PMD_DEBUG_TRACE("set VF rate limit:port %d: "
2218 "invalid vf id=%d\n", port_id, vf);
2222 if (tx_rate > link.link_speed) {
2223 PMD_DEBUG_TRACE("set VF rate limit:invalid tx_rate=%d, "
2224 "bigger than link speed= %d\n",
2225 tx_rate, link_speed);
2229 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rate_limit, -ENOTSUP);
2230 return (*dev->dev_ops->set_vf_rate_limit)(dev, vf, tx_rate, q_msk);
2234 rte_eth_mirror_rule_set(uint8_t port_id,
2235 struct rte_eth_vmdq_mirror_conf *mirror_conf,
2236 uint8_t rule_id, uint8_t on)
2238 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2240 if (port_id >= nb_ports) {
2241 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2245 if (mirror_conf->rule_type_mask == 0) {
2246 PMD_DEBUG_TRACE("mirror rule type can not be 0.\n");
2250 if (mirror_conf->dst_pool >= ETH_64_POOLS) {
2251 PMD_DEBUG_TRACE("Invalid dst pool, pool id must"
2252 "be 0-%d\n",ETH_64_POOLS - 1);
2256 if ((mirror_conf->rule_type_mask & ETH_VMDQ_POOL_MIRROR) &&
2257 (mirror_conf->pool_mask == 0)) {
2258 PMD_DEBUG_TRACE("Invalid mirror pool, pool mask can not"
2263 if(rule_id >= ETH_VMDQ_NUM_MIRROR_RULE)
2265 PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
2266 ETH_VMDQ_NUM_MIRROR_RULE - 1);
2270 dev = &rte_eth_devices[port_id];
2271 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_set, -ENOTSUP);
2273 return (*dev->dev_ops->mirror_rule_set)(dev, mirror_conf, rule_id, on);
2277 rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)
2279 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2281 if (port_id >= nb_ports) {
2282 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2286 if(rule_id >= ETH_VMDQ_NUM_MIRROR_RULE)
2288 PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
2289 ETH_VMDQ_NUM_MIRROR_RULE-1);
2293 dev = &rte_eth_devices[port_id];
2294 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_reset, -ENOTSUP);
2296 return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
2299 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
2301 rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
2302 struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
2304 struct rte_eth_dev *dev;
2306 if (port_id >= nb_ports) {
2307 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2310 dev = &rte_eth_devices[port_id];
2311 FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, -ENOTSUP);
2312 if (queue_id >= dev->data->nb_rx_queues) {
2313 PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
2316 return (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
2321 rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
2322 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
2324 struct rte_eth_dev *dev;
2326 if (port_id >= nb_ports) {
2327 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2330 dev = &rte_eth_devices[port_id];
2332 FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, -ENOTSUP);
2333 if (queue_id >= dev->data->nb_tx_queues) {
2334 PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
2337 return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id],
2342 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
2344 struct rte_eth_dev *dev;
2346 if (port_id >= nb_ports) {
2347 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2350 dev = &rte_eth_devices[port_id];
2351 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
2352 return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
2356 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
2358 struct rte_eth_dev *dev;
2360 if (port_id >= nb_ports) {
2361 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2364 dev = &rte_eth_devices[port_id];
2365 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
2366 return (*dev->dev_ops->rx_descriptor_done)( \
2367 dev->data->rx_queues[queue_id], offset);
2372 rte_eth_dev_callback_register(uint8_t port_id,
2373 enum rte_eth_event_type event,
2374 rte_eth_dev_cb_fn cb_fn, void *cb_arg)
2376 struct rte_eth_dev *dev;
2377 struct rte_eth_dev_callback *user_cb;
2381 if (port_id >= nb_ports) {
2382 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2386 dev = &rte_eth_devices[port_id];
2387 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2389 TAILQ_FOREACH(user_cb, &(dev->callbacks), next) {
2390 if (user_cb->cb_fn == cb_fn &&
2391 user_cb->cb_arg == cb_arg &&
2392 user_cb->event == event) {
2397 /* create a new callback. */
2398 if (user_cb == NULL && (user_cb = rte_zmalloc("INTR_USER_CALLBACK",
2399 sizeof(struct rte_eth_dev_callback), 0)) != NULL) {
2400 user_cb->cb_fn = cb_fn;
2401 user_cb->cb_arg = cb_arg;
2402 user_cb->event = event;
2403 TAILQ_INSERT_TAIL(&(dev->callbacks), user_cb, next);
2406 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2407 return ((user_cb == NULL) ? -ENOMEM : 0);
2411 rte_eth_dev_callback_unregister(uint8_t port_id,
2412 enum rte_eth_event_type event,
2413 rte_eth_dev_cb_fn cb_fn, void *cb_arg)
2416 struct rte_eth_dev *dev;
2417 struct rte_eth_dev_callback *cb, *next;
2421 if (port_id >= nb_ports) {
2422 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2426 dev = &rte_eth_devices[port_id];
2427 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2430 for (cb = TAILQ_FIRST(&dev->callbacks); cb != NULL; cb = next) {
2432 next = TAILQ_NEXT(cb, next);
2434 if (cb->cb_fn != cb_fn || cb->event != event ||
2435 (cb->cb_arg != (void *)-1 &&
2436 cb->cb_arg != cb_arg))
2440 * if this callback is not executing right now,
2443 if (cb->active == 0) {
2444 TAILQ_REMOVE(&(dev->callbacks), cb, next);
2451 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2456 _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
2457 enum rte_eth_event_type event)
2459 struct rte_eth_dev_callback *cb_lst;
2460 struct rte_eth_dev_callback dev_cb;
2462 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2463 TAILQ_FOREACH(cb_lst, &(dev->callbacks), next) {
2464 if (cb_lst->cb_fn == NULL || cb_lst->event != event)
2468 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2469 dev_cb.cb_fn(dev->data->port_id, dev_cb.event,
2471 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2474 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2476 #ifdef RTE_NIC_BYPASS
2477 int rte_eth_dev_bypass_init(uint8_t port_id)
2479 struct rte_eth_dev *dev;
2481 if (port_id >= nb_ports) {
2482 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2486 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2487 PMD_DEBUG_TRACE("Invalid port device\n");
2491 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_init, -ENOTSUP);
2492 (*dev->dev_ops->bypass_init)(dev);
2497 rte_eth_dev_bypass_state_show(uint8_t port_id, uint32_t *state)
2499 struct rte_eth_dev *dev;
2501 if (port_id >= nb_ports) {
2502 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2506 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2507 PMD_DEBUG_TRACE("Invalid port device\n");
2510 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
2511 (*dev->dev_ops->bypass_state_show)(dev, state);
2516 rte_eth_dev_bypass_state_set(uint8_t port_id, uint32_t *new_state)
2518 struct rte_eth_dev *dev;
2520 if (port_id >= nb_ports) {
2521 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2525 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2526 PMD_DEBUG_TRACE("Invalid port device\n");
2530 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_set, -ENOTSUP);
2531 (*dev->dev_ops->bypass_state_set)(dev, new_state);
2536 rte_eth_dev_bypass_event_show(uint8_t port_id, uint32_t event, uint32_t *state)
2538 struct rte_eth_dev *dev;
2540 if (port_id >= nb_ports) {
2541 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2545 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2546 PMD_DEBUG_TRACE("Invalid port device\n");
2550 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
2551 (*dev->dev_ops->bypass_event_show)(dev, event, state);
2556 rte_eth_dev_bypass_event_store(uint8_t port_id, uint32_t event, uint32_t state)
2558 struct rte_eth_dev *dev;
2560 if (port_id >= nb_ports) {
2561 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2565 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2566 PMD_DEBUG_TRACE("Invalid port device\n");
2570 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_event_set, -ENOTSUP);
2571 (*dev->dev_ops->bypass_event_set)(dev, event, state);
2576 rte_eth_dev_wd_timeout_store(uint8_t port_id, uint32_t timeout)
2578 struct rte_eth_dev *dev;
2580 if (port_id >= nb_ports) {
2581 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2585 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2586 PMD_DEBUG_TRACE("Invalid port device\n");
2590 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_set, -ENOTSUP);
2591 (*dev->dev_ops->bypass_wd_timeout_set)(dev, timeout);
2596 rte_eth_dev_bypass_ver_show(uint8_t port_id, uint32_t *ver)
2598 struct rte_eth_dev *dev;
2600 if (port_id >= nb_ports) {
2601 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2605 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2606 PMD_DEBUG_TRACE("Invalid port device\n");
2610 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_ver_show, -ENOTSUP);
2611 (*dev->dev_ops->bypass_ver_show)(dev, ver);
2616 rte_eth_dev_bypass_wd_timeout_show(uint8_t port_id, uint32_t *wd_timeout)
2618 struct rte_eth_dev *dev;
2620 if (port_id >= nb_ports) {
2621 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2625 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2626 PMD_DEBUG_TRACE("Invalid port device\n");
2630 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_show, -ENOTSUP);
2631 (*dev->dev_ops->bypass_wd_timeout_show)(dev, wd_timeout);
2636 rte_eth_dev_bypass_wd_reset(uint8_t port_id)
2638 struct rte_eth_dev *dev;
2640 if (port_id >= nb_ports) {
2641 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2645 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2646 PMD_DEBUG_TRACE("Invalid port device\n");
2650 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_reset, -ENOTSUP);
2651 (*dev->dev_ops->bypass_wd_reset)(dev);
2657 rte_eth_dev_add_syn_filter(uint8_t port_id,
2658 struct rte_syn_filter *filter, uint16_t rx_queue)
2660 struct rte_eth_dev *dev;
2662 if (port_id >= nb_ports) {
2663 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2667 dev = &rte_eth_devices[port_id];
2668 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_syn_filter, -ENOTSUP);
2669 return (*dev->dev_ops->add_syn_filter)(dev, filter, rx_queue);
2673 rte_eth_dev_remove_syn_filter(uint8_t port_id)
2675 struct rte_eth_dev *dev;
2677 if (port_id >= nb_ports) {
2678 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2682 dev = &rte_eth_devices[port_id];
2683 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_syn_filter, -ENOTSUP);
2684 return (*dev->dev_ops->remove_syn_filter)(dev);
2688 rte_eth_dev_get_syn_filter(uint8_t port_id,
2689 struct rte_syn_filter *filter, uint16_t *rx_queue)
2691 struct rte_eth_dev *dev;
2693 if (filter == NULL || rx_queue == NULL)
2696 if (port_id >= nb_ports) {
2697 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2701 dev = &rte_eth_devices[port_id];
2702 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_syn_filter, -ENOTSUP);
2703 return (*dev->dev_ops->get_syn_filter)(dev, filter, rx_queue);
2707 rte_eth_dev_add_ethertype_filter(uint8_t port_id, uint16_t index,
2708 struct rte_ethertype_filter *filter, uint16_t rx_queue)
2710 struct rte_eth_dev *dev;
2712 if (port_id >= nb_ports) {
2713 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2716 if (filter->ethertype == ETHER_TYPE_IPv4 ||
2717 filter->ethertype == ETHER_TYPE_IPv6){
2718 PMD_DEBUG_TRACE("IP and IPv6 are not supported"
2719 " in ethertype filter\n");
2722 dev = &rte_eth_devices[port_id];
2723 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_ethertype_filter, -ENOTSUP);
2724 return (*dev->dev_ops->add_ethertype_filter)(dev, index,
2729 rte_eth_dev_remove_ethertype_filter(uint8_t port_id, uint16_t index)
2731 struct rte_eth_dev *dev;
2733 if (port_id >= nb_ports) {
2734 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2738 dev = &rte_eth_devices[port_id];
2739 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_ethertype_filter, -ENOTSUP);
2740 return (*dev->dev_ops->remove_ethertype_filter)(dev, index);
2744 rte_eth_dev_get_ethertype_filter(uint8_t port_id, uint16_t index,
2745 struct rte_ethertype_filter *filter, uint16_t *rx_queue)
2747 struct rte_eth_dev *dev;
2749 if (filter == NULL || rx_queue == NULL)
2752 if (port_id >= nb_ports) {
2753 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2757 dev = &rte_eth_devices[port_id];
2758 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_ethertype_filter, -ENOTSUP);
2759 return (*dev->dev_ops->get_ethertype_filter)(dev, index,
2764 rte_eth_dev_add_2tuple_filter(uint8_t port_id, uint16_t index,
2765 struct rte_2tuple_filter *filter, uint16_t rx_queue)
2767 struct rte_eth_dev *dev;
2769 if (port_id >= nb_ports) {
2770 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2773 if (filter->protocol != IPPROTO_TCP &&
2774 filter->tcp_flags != 0){
2775 PMD_DEBUG_TRACE("tcp flags is 0x%x, but the protocol value"
2781 dev = &rte_eth_devices[port_id];
2782 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_2tuple_filter, -ENOTSUP);
2783 return (*dev->dev_ops->add_2tuple_filter)(dev, index, filter, rx_queue);
2787 rte_eth_dev_remove_2tuple_filter(uint8_t port_id, uint16_t index)
2789 struct rte_eth_dev *dev;
2791 if (port_id >= nb_ports) {
2792 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2796 dev = &rte_eth_devices[port_id];
2797 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_2tuple_filter, -ENOTSUP);
2798 return (*dev->dev_ops->remove_2tuple_filter)(dev, index);
2802 rte_eth_dev_get_2tuple_filter(uint8_t port_id, uint16_t index,
2803 struct rte_2tuple_filter *filter, uint16_t *rx_queue)
2805 struct rte_eth_dev *dev;
2807 if (filter == NULL || rx_queue == NULL)
2810 if (port_id >= nb_ports) {
2811 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2815 dev = &rte_eth_devices[port_id];
2816 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_2tuple_filter, -ENOTSUP);
2817 return (*dev->dev_ops->get_2tuple_filter)(dev, index, filter, rx_queue);
2821 rte_eth_dev_add_5tuple_filter(uint8_t port_id, uint16_t index,
2822 struct rte_5tuple_filter *filter, uint16_t rx_queue)
2824 struct rte_eth_dev *dev;
2826 if (port_id >= nb_ports) {
2827 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2831 if (filter->protocol != IPPROTO_TCP &&
2832 filter->tcp_flags != 0){
2833 PMD_DEBUG_TRACE("tcp flags is 0x%x, but the protocol value"
2839 dev = &rte_eth_devices[port_id];
2840 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_5tuple_filter, -ENOTSUP);
2841 return (*dev->dev_ops->add_5tuple_filter)(dev, index, filter, rx_queue);
2845 rte_eth_dev_remove_5tuple_filter(uint8_t port_id, uint16_t index)
2847 struct rte_eth_dev *dev;
2849 if (port_id >= nb_ports) {
2850 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2854 dev = &rte_eth_devices[port_id];
2855 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_5tuple_filter, -ENOTSUP);
2856 return (*dev->dev_ops->remove_5tuple_filter)(dev, index);
2860 rte_eth_dev_get_5tuple_filter(uint8_t port_id, uint16_t index,
2861 struct rte_5tuple_filter *filter, uint16_t *rx_queue)
2863 struct rte_eth_dev *dev;
2865 if (filter == NULL || rx_queue == NULL)
2868 if (port_id >= nb_ports) {
2869 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2873 dev = &rte_eth_devices[port_id];
2874 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_5tuple_filter, -ENOTSUP);
2875 return (*dev->dev_ops->get_5tuple_filter)(dev, index, filter,
2880 rte_eth_dev_add_flex_filter(uint8_t port_id, uint16_t index,
2881 struct rte_flex_filter *filter, uint16_t rx_queue)
2883 struct rte_eth_dev *dev;
2885 if (port_id >= nb_ports) {
2886 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2890 dev = &rte_eth_devices[port_id];
2891 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_flex_filter, -ENOTSUP);
2892 return (*dev->dev_ops->add_flex_filter)(dev, index, filter, rx_queue);
2896 rte_eth_dev_remove_flex_filter(uint8_t port_id, uint16_t index)
2898 struct rte_eth_dev *dev;
2900 if (port_id >= nb_ports) {
2901 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2905 dev = &rte_eth_devices[port_id];
2906 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_flex_filter, -ENOTSUP);
2907 return (*dev->dev_ops->remove_flex_filter)(dev, index);
2911 rte_eth_dev_get_flex_filter(uint8_t port_id, uint16_t index,
2912 struct rte_flex_filter *filter, uint16_t *rx_queue)
2914 struct rte_eth_dev *dev;
2916 if (filter == NULL || rx_queue == NULL)
2919 if (port_id >= nb_ports) {
2920 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2924 dev = &rte_eth_devices[port_id];
2925 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_flex_filter, -ENOTSUP);
2926 return (*dev->dev_ops->get_flex_filter)(dev, index, filter,