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 MTU.
206 eth_dev->data->mtu = ETHER_MTU;
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 link state interrupt is enabled, check that the
644 * device supports it.
646 if (dev_conf->intr_conf.lsc == 1) {
647 const struct rte_pci_driver *pci_drv = &dev->driver->pci_drv;
649 if (!(pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
650 PMD_DEBUG_TRACE("driver %s does not support lsc\n",
657 * If jumbo frames are enabled, check that the maximum RX packet
658 * length is supported by the configured device.
660 if (dev_conf->rxmode.jumbo_frame == 1) {
661 if (dev_conf->rxmode.max_rx_pkt_len >
662 dev_info.max_rx_pktlen) {
663 PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
664 " > max valid value %u\n",
666 (unsigned)dev_conf->rxmode.max_rx_pkt_len,
667 (unsigned)dev_info.max_rx_pktlen);
670 else if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN) {
671 PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
672 " < min valid value %u\n",
674 (unsigned)dev_conf->rxmode.max_rx_pkt_len,
675 (unsigned)ETHER_MIN_LEN);
679 if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN ||
680 dev_conf->rxmode.max_rx_pkt_len > ETHER_MAX_LEN)
681 /* Use default value */
682 dev->data->dev_conf.rxmode.max_rx_pkt_len =
686 /* multipe queue mode checking */
687 diag = rte_eth_dev_check_mq_mode(port_id, nb_rx_q, nb_tx_q, dev_conf);
689 PMD_DEBUG_TRACE("port%d rte_eth_dev_check_mq_mode = %d\n",
695 * Setup new number of RX/TX queues and reconfigure device.
697 diag = rte_eth_dev_rx_queue_config(dev, nb_rx_q);
699 PMD_DEBUG_TRACE("port%d rte_eth_dev_rx_queue_config = %d\n",
704 diag = rte_eth_dev_tx_queue_config(dev, nb_tx_q);
706 PMD_DEBUG_TRACE("port%d rte_eth_dev_tx_queue_config = %d\n",
708 rte_eth_dev_rx_queue_config(dev, 0);
712 diag = (*dev->dev_ops->dev_configure)(dev);
714 PMD_DEBUG_TRACE("port%d dev_configure = %d\n",
716 rte_eth_dev_rx_queue_config(dev, 0);
717 rte_eth_dev_tx_queue_config(dev, 0);
725 rte_eth_dev_config_restore(uint8_t port_id)
727 struct rte_eth_dev *dev;
728 struct rte_eth_dev_info dev_info;
729 struct ether_addr addr;
733 dev = &rte_eth_devices[port_id];
735 rte_eth_dev_info_get(port_id, &dev_info);
737 if (RTE_ETH_DEV_SRIOV(dev).active)
738 pool = RTE_ETH_DEV_SRIOV(dev).def_vmdq_idx;
740 /* replay MAC address configuration */
741 for (i = 0; i < dev_info.max_mac_addrs; i++) {
742 addr = dev->data->mac_addrs[i];
744 /* skip zero address */
745 if (is_zero_ether_addr(&addr))
748 /* add address to the hardware */
749 if (*dev->dev_ops->mac_addr_add)
750 (*dev->dev_ops->mac_addr_add)(dev, &addr, i, pool);
752 PMD_DEBUG_TRACE("port %d: MAC address array not supported\n",
754 /* exit the loop but not return an error */
759 /* replay promiscuous configuration */
760 if (rte_eth_promiscuous_get(port_id) == 1)
761 rte_eth_promiscuous_enable(port_id);
762 else if (rte_eth_promiscuous_get(port_id) == 0)
763 rte_eth_promiscuous_disable(port_id);
765 /* replay allmulticast configuration */
766 if (rte_eth_allmulticast_get(port_id) == 1)
767 rte_eth_allmulticast_enable(port_id);
768 else if (rte_eth_allmulticast_get(port_id) == 0)
769 rte_eth_allmulticast_disable(port_id);
773 rte_eth_dev_start(uint8_t port_id)
775 struct rte_eth_dev *dev;
778 /* This function is only safe when called from the primary process
779 * in a multi-process setup*/
780 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
782 if (port_id >= nb_ports) {
783 PMD_DEBUG_TRACE("Invalid port_id=%" PRIu8 "\n", port_id);
786 dev = &rte_eth_devices[port_id];
788 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
790 if (dev->data->dev_started != 0) {
791 PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
792 " already started\n",
797 diag = (*dev->dev_ops->dev_start)(dev);
799 dev->data->dev_started = 1;
803 rte_eth_dev_config_restore(port_id);
809 rte_eth_dev_stop(uint8_t port_id)
811 struct rte_eth_dev *dev;
813 /* This function is only safe when called from the primary process
814 * in a multi-process setup*/
815 PROC_PRIMARY_OR_RET();
817 if (port_id >= nb_ports) {
818 PMD_DEBUG_TRACE("Invalid port_id=%" PRIu8 "\n", port_id);
821 dev = &rte_eth_devices[port_id];
823 FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop);
825 if (dev->data->dev_started == 0) {
826 PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
827 " already stopped\n",
832 dev->data->dev_started = 0;
833 (*dev->dev_ops->dev_stop)(dev);
837 rte_eth_dev_set_link_up(uint8_t port_id)
839 struct rte_eth_dev *dev;
841 /* This function is only safe when called from the primary process
842 * in a multi-process setup*/
843 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
845 if (port_id >= nb_ports) {
846 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
849 dev = &rte_eth_devices[port_id];
851 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_up, -ENOTSUP);
852 return (*dev->dev_ops->dev_set_link_up)(dev);
856 rte_eth_dev_set_link_down(uint8_t port_id)
858 struct rte_eth_dev *dev;
860 /* This function is only safe when called from the primary process
861 * in a multi-process setup*/
862 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
864 if (port_id >= nb_ports) {
865 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
868 dev = &rte_eth_devices[port_id];
870 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_down, -ENOTSUP);
871 return (*dev->dev_ops->dev_set_link_down)(dev);
875 rte_eth_dev_close(uint8_t port_id)
877 struct rte_eth_dev *dev;
879 /* This function is only safe when called from the primary process
880 * in a multi-process setup*/
881 PROC_PRIMARY_OR_RET();
883 if (port_id >= nb_ports) {
884 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
888 dev = &rte_eth_devices[port_id];
890 FUNC_PTR_OR_RET(*dev->dev_ops->dev_close);
891 dev->data->dev_started = 0;
892 (*dev->dev_ops->dev_close)(dev);
896 rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
897 uint16_t nb_rx_desc, unsigned int socket_id,
898 const struct rte_eth_rxconf *rx_conf,
899 struct rte_mempool *mp)
902 uint32_t mbp_buf_size;
903 struct rte_eth_dev *dev;
904 struct rte_pktmbuf_pool_private *mbp_priv;
905 struct rte_eth_dev_info dev_info;
907 /* This function is only safe when called from the primary process
908 * in a multi-process setup*/
909 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
911 if (port_id >= nb_ports) {
912 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
915 dev = &rte_eth_devices[port_id];
916 if (rx_queue_id >= dev->data->nb_rx_queues) {
917 PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
921 if (dev->data->dev_started) {
923 "port %d must be stopped to allow configuration\n", port_id);
927 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
928 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP);
931 * Check the size of the mbuf data buffer.
932 * This value must be provided in the private data of the memory pool.
933 * First check that the memory pool has a valid private data.
935 (*dev->dev_ops->dev_infos_get)(dev, &dev_info);
936 if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) {
937 PMD_DEBUG_TRACE("%s private_data_size %d < %d\n",
938 mp->name, (int) mp->private_data_size,
939 (int) sizeof(struct rte_pktmbuf_pool_private));
942 mbp_priv = rte_mempool_get_priv(mp);
943 mbp_buf_size = mbp_priv->mbuf_data_room_size;
945 if ((mbp_buf_size - RTE_PKTMBUF_HEADROOM) < dev_info.min_rx_bufsize) {
946 PMD_DEBUG_TRACE("%s mbuf_data_room_size %d < %d "
947 "(RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)"
951 (int)(RTE_PKTMBUF_HEADROOM +
952 dev_info.min_rx_bufsize),
953 (int)RTE_PKTMBUF_HEADROOM,
954 (int)dev_info.min_rx_bufsize);
958 ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
959 socket_id, rx_conf, mp);
961 if (!dev->data->min_rx_buf_size ||
962 dev->data->min_rx_buf_size > mbp_buf_size)
963 dev->data->min_rx_buf_size = mbp_buf_size;
970 rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
971 uint16_t nb_tx_desc, unsigned int socket_id,
972 const struct rte_eth_txconf *tx_conf)
974 struct rte_eth_dev *dev;
976 /* This function is only safe when called from the primary process
977 * in a multi-process setup*/
978 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
980 if (port_id >= RTE_MAX_ETHPORTS || port_id >= nb_ports) {
981 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
984 dev = &rte_eth_devices[port_id];
985 if (tx_queue_id >= dev->data->nb_tx_queues) {
986 PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
990 if (dev->data->dev_started) {
992 "port %d must be stopped to allow configuration\n", port_id);
996 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_setup, -ENOTSUP);
997 return (*dev->dev_ops->tx_queue_setup)(dev, tx_queue_id, nb_tx_desc,
1002 rte_eth_promiscuous_enable(uint8_t port_id)
1004 struct rte_eth_dev *dev;
1006 if (port_id >= nb_ports) {
1007 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1010 dev = &rte_eth_devices[port_id];
1012 FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_enable);
1013 (*dev->dev_ops->promiscuous_enable)(dev);
1014 dev->data->promiscuous = 1;
1018 rte_eth_promiscuous_disable(uint8_t port_id)
1020 struct rte_eth_dev *dev;
1022 if (port_id >= nb_ports) {
1023 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1026 dev = &rte_eth_devices[port_id];
1028 FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_disable);
1029 dev->data->promiscuous = 0;
1030 (*dev->dev_ops->promiscuous_disable)(dev);
1034 rte_eth_promiscuous_get(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);
1043 dev = &rte_eth_devices[port_id];
1044 return dev->data->promiscuous;
1048 rte_eth_allmulticast_enable(uint8_t port_id)
1050 struct rte_eth_dev *dev;
1052 if (port_id >= nb_ports) {
1053 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1056 dev = &rte_eth_devices[port_id];
1058 FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_enable);
1059 (*dev->dev_ops->allmulticast_enable)(dev);
1060 dev->data->all_multicast = 1;
1064 rte_eth_allmulticast_disable(uint8_t port_id)
1066 struct rte_eth_dev *dev;
1068 if (port_id >= nb_ports) {
1069 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1072 dev = &rte_eth_devices[port_id];
1074 FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_disable);
1075 dev->data->all_multicast = 0;
1076 (*dev->dev_ops->allmulticast_disable)(dev);
1080 rte_eth_allmulticast_get(uint8_t port_id)
1082 struct rte_eth_dev *dev;
1084 if (port_id >= nb_ports) {
1085 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1089 dev = &rte_eth_devices[port_id];
1090 return dev->data->all_multicast;
1094 rte_eth_dev_atomic_read_link_status(struct rte_eth_dev *dev,
1095 struct rte_eth_link *link)
1097 struct rte_eth_link *dst = link;
1098 struct rte_eth_link *src = &(dev->data->dev_link);
1100 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
1101 *(uint64_t *)src) == 0)
1108 rte_eth_link_get(uint8_t port_id, struct rte_eth_link *eth_link)
1110 struct rte_eth_dev *dev;
1112 if (port_id >= nb_ports) {
1113 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1116 dev = &rte_eth_devices[port_id];
1118 if (dev->data->dev_conf.intr_conf.lsc != 0)
1119 rte_eth_dev_atomic_read_link_status(dev, eth_link);
1121 FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
1122 (*dev->dev_ops->link_update)(dev, 1);
1123 *eth_link = dev->data->dev_link;
1128 rte_eth_link_get_nowait(uint8_t port_id, struct rte_eth_link *eth_link)
1130 struct rte_eth_dev *dev;
1132 if (port_id >= nb_ports) {
1133 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1136 dev = &rte_eth_devices[port_id];
1138 if (dev->data->dev_conf.intr_conf.lsc != 0)
1139 rte_eth_dev_atomic_read_link_status(dev, eth_link);
1141 FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
1142 (*dev->dev_ops->link_update)(dev, 0);
1143 *eth_link = dev->data->dev_link;
1148 rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats)
1150 struct rte_eth_dev *dev;
1152 if (port_id >= nb_ports) {
1153 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1156 dev = &rte_eth_devices[port_id];
1157 memset(stats, 0, sizeof(*stats));
1159 FUNC_PTR_OR_RET(*dev->dev_ops->stats_get);
1160 (*dev->dev_ops->stats_get)(dev, stats);
1161 stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
1165 rte_eth_stats_reset(uint8_t port_id)
1167 struct rte_eth_dev *dev;
1169 if (port_id >= nb_ports) {
1170 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1173 dev = &rte_eth_devices[port_id];
1175 FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);
1176 (*dev->dev_ops->stats_reset)(dev);
1181 set_queue_stats_mapping(uint8_t port_id, uint16_t queue_id, uint8_t stat_idx,
1184 struct rte_eth_dev *dev;
1186 if (port_id >= nb_ports) {
1187 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1190 dev = &rte_eth_devices[port_id];
1192 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_stats_mapping_set, -ENOTSUP);
1193 return (*dev->dev_ops->queue_stats_mapping_set)
1194 (dev, queue_id, stat_idx, is_rx);
1199 rte_eth_dev_set_tx_queue_stats_mapping(uint8_t port_id, uint16_t tx_queue_id,
1202 return set_queue_stats_mapping(port_id, tx_queue_id, stat_idx,
1208 rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
1211 return set_queue_stats_mapping(port_id, rx_queue_id, stat_idx,
1217 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
1219 struct rte_eth_dev *dev;
1221 if (port_id >= nb_ports) {
1222 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1225 dev = &rte_eth_devices[port_id];
1227 /* Default device offload capabilities to zero */
1228 dev_info->rx_offload_capa = 0;
1229 dev_info->tx_offload_capa = 0;
1230 dev_info->if_index = 0;
1231 FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
1232 (*dev->dev_ops->dev_infos_get)(dev, dev_info);
1233 dev_info->pci_dev = dev->pci_dev;
1235 dev_info->driver_name = dev->driver->pci_drv.name;
1239 rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr)
1241 struct rte_eth_dev *dev;
1243 if (port_id >= nb_ports) {
1244 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1247 dev = &rte_eth_devices[port_id];
1248 ether_addr_copy(&dev->data->mac_addrs[0], mac_addr);
1253 rte_eth_dev_get_mtu(uint8_t port_id, uint16_t *mtu)
1255 struct rte_eth_dev *dev;
1257 if (port_id >= nb_ports) {
1258 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1262 dev = &rte_eth_devices[port_id];
1263 *mtu = dev->data->mtu;
1268 rte_eth_dev_set_mtu(uint8_t port_id, uint16_t mtu)
1271 struct rte_eth_dev *dev;
1273 if (port_id >= nb_ports) {
1274 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1278 dev = &rte_eth_devices[port_id];
1279 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mtu_set, -ENOTSUP);
1281 ret = (*dev->dev_ops->mtu_set)(dev, mtu);
1283 dev->data->mtu = mtu;
1289 rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t vlan_id, int on)
1291 struct rte_eth_dev *dev;
1293 if (port_id >= nb_ports) {
1294 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1297 dev = &rte_eth_devices[port_id];
1298 if (! (dev->data->dev_conf.rxmode.hw_vlan_filter)) {
1299 PMD_DEBUG_TRACE("port %d: vlan-filtering disabled\n", port_id);
1303 if (vlan_id > 4095) {
1304 PMD_DEBUG_TRACE("(port_id=%d) invalid vlan_id=%u > 4095\n",
1305 port_id, (unsigned) vlan_id);
1308 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_filter_set, -ENOTSUP);
1309 (*dev->dev_ops->vlan_filter_set)(dev, vlan_id, on);
1314 rte_eth_dev_set_vlan_strip_on_queue(uint8_t port_id, uint16_t rx_queue_id, int on)
1316 struct rte_eth_dev *dev;
1318 if (port_id >= nb_ports) {
1319 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1323 dev = &rte_eth_devices[port_id];
1324 if (rx_queue_id >= dev->data->nb_rx_queues) {
1325 PMD_DEBUG_TRACE("Invalid rx_queue_id=%d\n", port_id);
1329 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
1330 (*dev->dev_ops->vlan_strip_queue_set)(dev, rx_queue_id, on);
1336 rte_eth_dev_set_vlan_ether_type(uint8_t port_id, uint16_t tpid)
1338 struct rte_eth_dev *dev;
1340 if (port_id >= nb_ports) {
1341 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1345 dev = &rte_eth_devices[port_id];
1346 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_tpid_set, -ENOTSUP);
1347 (*dev->dev_ops->vlan_tpid_set)(dev, tpid);
1353 rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask)
1355 struct rte_eth_dev *dev;
1360 if (port_id >= nb_ports) {
1361 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1365 dev = &rte_eth_devices[port_id];
1367 /*check which option changed by application*/
1368 cur = !!(offload_mask & ETH_VLAN_STRIP_OFFLOAD);
1369 org = !!(dev->data->dev_conf.rxmode.hw_vlan_strip);
1371 dev->data->dev_conf.rxmode.hw_vlan_strip = (uint8_t)cur;
1372 mask |= ETH_VLAN_STRIP_MASK;
1375 cur = !!(offload_mask & ETH_VLAN_FILTER_OFFLOAD);
1376 org = !!(dev->data->dev_conf.rxmode.hw_vlan_filter);
1378 dev->data->dev_conf.rxmode.hw_vlan_filter = (uint8_t)cur;
1379 mask |= ETH_VLAN_FILTER_MASK;
1382 cur = !!(offload_mask & ETH_VLAN_EXTEND_OFFLOAD);
1383 org = !!(dev->data->dev_conf.rxmode.hw_vlan_extend);
1385 dev->data->dev_conf.rxmode.hw_vlan_extend = (uint8_t)cur;
1386 mask |= ETH_VLAN_EXTEND_MASK;
1393 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP);
1394 (*dev->dev_ops->vlan_offload_set)(dev, mask);
1400 rte_eth_dev_get_vlan_offload(uint8_t port_id)
1402 struct rte_eth_dev *dev;
1405 if (port_id >= nb_ports) {
1406 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1410 dev = &rte_eth_devices[port_id];
1412 if (dev->data->dev_conf.rxmode.hw_vlan_strip)
1413 ret |= ETH_VLAN_STRIP_OFFLOAD ;
1415 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
1416 ret |= ETH_VLAN_FILTER_OFFLOAD ;
1418 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
1419 ret |= ETH_VLAN_EXTEND_OFFLOAD ;
1425 rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on)
1427 struct rte_eth_dev *dev;
1429 if (port_id >= nb_ports) {
1430 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1433 dev = &rte_eth_devices[port_id];
1434 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_pvid_set, -ENOTSUP);
1435 (*dev->dev_ops->vlan_pvid_set)(dev, pvid, on);
1441 rte_eth_dev_fdir_add_signature_filter(uint8_t port_id,
1442 struct rte_fdir_filter *fdir_filter,
1445 struct rte_eth_dev *dev;
1447 if (port_id >= nb_ports) {
1448 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1452 dev = &rte_eth_devices[port_id];
1454 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
1455 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1456 port_id, dev->data->dev_conf.fdir_conf.mode);
1460 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1461 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1462 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1463 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1464 "None l4type, source & destinations ports " \
1465 "should be null!\n");
1469 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_add_signature_filter, -ENOTSUP);
1470 return (*dev->dev_ops->fdir_add_signature_filter)(dev, fdir_filter,
1475 rte_eth_dev_fdir_update_signature_filter(uint8_t port_id,
1476 struct rte_fdir_filter *fdir_filter,
1479 struct rte_eth_dev *dev;
1481 if (port_id >= nb_ports) {
1482 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1486 dev = &rte_eth_devices[port_id];
1488 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
1489 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1490 port_id, dev->data->dev_conf.fdir_conf.mode);
1494 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1495 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1496 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1497 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1498 "None l4type, source & destinations ports " \
1499 "should be null!\n");
1503 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_update_signature_filter, -ENOTSUP);
1504 return (*dev->dev_ops->fdir_update_signature_filter)(dev, fdir_filter,
1510 rte_eth_dev_fdir_remove_signature_filter(uint8_t port_id,
1511 struct rte_fdir_filter *fdir_filter)
1513 struct rte_eth_dev *dev;
1515 if (port_id >= nb_ports) {
1516 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1520 dev = &rte_eth_devices[port_id];
1522 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
1523 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1524 port_id, dev->data->dev_conf.fdir_conf.mode);
1528 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1529 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1530 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1531 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1532 "None l4type source & destinations ports " \
1533 "should be null!\n");
1537 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_signature_filter, -ENOTSUP);
1538 return (*dev->dev_ops->fdir_remove_signature_filter)(dev, fdir_filter);
1542 rte_eth_dev_fdir_get_infos(uint8_t port_id, struct rte_eth_fdir *fdir)
1544 struct rte_eth_dev *dev;
1546 if (port_id >= nb_ports) {
1547 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1551 dev = &rte_eth_devices[port_id];
1552 if (! (dev->data->dev_conf.fdir_conf.mode)) {
1553 PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
1557 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_infos_get, -ENOTSUP);
1559 (*dev->dev_ops->fdir_infos_get)(dev, fdir);
1564 rte_eth_dev_fdir_add_perfect_filter(uint8_t port_id,
1565 struct rte_fdir_filter *fdir_filter,
1566 uint16_t soft_id, uint8_t queue,
1569 struct rte_eth_dev *dev;
1571 if (port_id >= nb_ports) {
1572 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1576 dev = &rte_eth_devices[port_id];
1578 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
1579 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1580 port_id, dev->data->dev_conf.fdir_conf.mode);
1584 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1585 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1586 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1587 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1588 "None l4type, source & destinations ports " \
1589 "should be null!\n");
1593 /* For now IPv6 is not supported with perfect filter */
1594 if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
1597 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_add_perfect_filter, -ENOTSUP);
1598 return (*dev->dev_ops->fdir_add_perfect_filter)(dev, fdir_filter,
1604 rte_eth_dev_fdir_update_perfect_filter(uint8_t port_id,
1605 struct rte_fdir_filter *fdir_filter,
1606 uint16_t soft_id, uint8_t queue,
1609 struct rte_eth_dev *dev;
1611 if (port_id >= nb_ports) {
1612 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1616 dev = &rte_eth_devices[port_id];
1618 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
1619 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1620 port_id, dev->data->dev_conf.fdir_conf.mode);
1624 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1625 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1626 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1627 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1628 "None l4type, source & destinations ports " \
1629 "should be null!\n");
1633 /* For now IPv6 is not supported with perfect filter */
1634 if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
1637 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_update_perfect_filter, -ENOTSUP);
1638 return (*dev->dev_ops->fdir_update_perfect_filter)(dev, fdir_filter,
1639 soft_id, queue, drop);
1643 rte_eth_dev_fdir_remove_perfect_filter(uint8_t port_id,
1644 struct rte_fdir_filter *fdir_filter,
1647 struct rte_eth_dev *dev;
1649 if (port_id >= nb_ports) {
1650 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1654 dev = &rte_eth_devices[port_id];
1656 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
1657 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1658 port_id, dev->data->dev_conf.fdir_conf.mode);
1662 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1663 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1664 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1665 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1666 "None l4type, source & destinations ports " \
1667 "should be null!\n");
1671 /* For now IPv6 is not supported with perfect filter */
1672 if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
1675 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_perfect_filter, -ENOTSUP);
1676 return (*dev->dev_ops->fdir_remove_perfect_filter)(dev, fdir_filter,
1681 rte_eth_dev_fdir_set_masks(uint8_t port_id, struct rte_fdir_masks *fdir_mask)
1683 struct rte_eth_dev *dev;
1685 if (port_id >= nb_ports) {
1686 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1690 dev = &rte_eth_devices[port_id];
1691 if (! (dev->data->dev_conf.fdir_conf.mode)) {
1692 PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
1696 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_set_masks, -ENOTSUP);
1697 return (*dev->dev_ops->fdir_set_masks)(dev, fdir_mask);
1701 rte_eth_dev_flow_ctrl_get(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
1703 struct rte_eth_dev *dev;
1705 if (port_id >= nb_ports) {
1706 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1710 dev = &rte_eth_devices[port_id];
1711 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_get, -ENOTSUP);
1712 memset(fc_conf, 0, sizeof(*fc_conf));
1713 return (*dev->dev_ops->flow_ctrl_get)(dev, fc_conf);
1717 rte_eth_dev_flow_ctrl_set(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
1719 struct rte_eth_dev *dev;
1721 if (port_id >= nb_ports) {
1722 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1726 if ((fc_conf->send_xon != 0) && (fc_conf->send_xon != 1)) {
1727 PMD_DEBUG_TRACE("Invalid send_xon, only 0/1 allowed\n");
1731 dev = &rte_eth_devices[port_id];
1732 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_set, -ENOTSUP);
1733 return (*dev->dev_ops->flow_ctrl_set)(dev, fc_conf);
1737 rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id, struct rte_eth_pfc_conf *pfc_conf)
1739 struct rte_eth_dev *dev;
1741 if (port_id >= nb_ports) {
1742 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1746 if (pfc_conf->priority > (ETH_DCB_NUM_USER_PRIORITIES - 1)) {
1747 PMD_DEBUG_TRACE("Invalid priority, only 0-7 allowed\n");
1751 dev = &rte_eth_devices[port_id];
1752 /* High water, low water validation are device specific */
1753 if (*dev->dev_ops->priority_flow_ctrl_set)
1754 return (*dev->dev_ops->priority_flow_ctrl_set)(dev, pfc_conf);
1759 rte_eth_dev_rss_reta_update(uint8_t port_id, struct rte_eth_rss_reta *reta_conf)
1761 struct rte_eth_dev *dev;
1765 if (port_id >= nb_ports) {
1766 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1770 /* Invalid mask bit(s) setting */
1771 if ((reta_conf->mask_lo == 0) && (reta_conf->mask_hi == 0)) {
1772 PMD_DEBUG_TRACE("Invalid update mask bits for port=%d\n",port_id);
1776 dev = &rte_eth_devices[port_id];
1777 max_rxq = (dev->data->nb_rx_queues <= ETH_RSS_RETA_MAX_QUEUE) ?
1778 dev->data->nb_rx_queues : ETH_RSS_RETA_MAX_QUEUE;
1779 if (reta_conf->mask_lo != 0) {
1780 for (i = 0; i < ETH_RSS_RETA_NUM_ENTRIES/2; i++) {
1781 if ((reta_conf->mask_lo & (1ULL << i)) &&
1782 (reta_conf->reta[i] >= max_rxq)) {
1783 PMD_DEBUG_TRACE("RETA hash index output"
1784 "configration for port=%d,invalid"
1785 "queue=%d\n",port_id,reta_conf->reta[i]);
1792 if (reta_conf->mask_hi != 0) {
1793 for (i = 0; i< ETH_RSS_RETA_NUM_ENTRIES/2; i++) {
1794 j = (uint8_t)(i + ETH_RSS_RETA_NUM_ENTRIES/2);
1796 /* Check if the max entry >= 128 */
1797 if ((reta_conf->mask_hi & (1ULL << i)) &&
1798 (reta_conf->reta[j] >= max_rxq)) {
1799 PMD_DEBUG_TRACE("RETA hash index output"
1800 "configration for port=%d,invalid"
1801 "queue=%d\n",port_id,reta_conf->reta[j]);
1808 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_update, -ENOTSUP);
1809 return (*dev->dev_ops->reta_update)(dev, reta_conf);
1813 rte_eth_dev_rss_reta_query(uint8_t port_id, struct rte_eth_rss_reta *reta_conf)
1815 struct rte_eth_dev *dev;
1817 if (port_id >= nb_ports) {
1818 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1822 if((reta_conf->mask_lo == 0) && (reta_conf->mask_hi == 0)) {
1823 PMD_DEBUG_TRACE("Invalid update mask bits for the port=%d\n",port_id);
1827 dev = &rte_eth_devices[port_id];
1828 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_query, -ENOTSUP);
1829 return (*dev->dev_ops->reta_query)(dev, reta_conf);
1833 rte_eth_dev_rss_hash_update(uint8_t port_id, struct rte_eth_rss_conf *rss_conf)
1835 struct rte_eth_dev *dev;
1836 uint16_t rss_hash_protos;
1838 if (port_id >= nb_ports) {
1839 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1842 rss_hash_protos = rss_conf->rss_hf;
1843 if ((rss_hash_protos != 0) &&
1844 ((rss_hash_protos & ETH_RSS_PROTO_MASK) == 0)) {
1845 PMD_DEBUG_TRACE("Invalid rss_hash_protos=0x%x\n",
1849 dev = &rte_eth_devices[port_id];
1850 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP);
1851 return (*dev->dev_ops->rss_hash_update)(dev, rss_conf);
1855 rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
1856 struct rte_eth_rss_conf *rss_conf)
1858 struct rte_eth_dev *dev;
1860 if (port_id >= nb_ports) {
1861 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1864 dev = &rte_eth_devices[port_id];
1865 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
1866 return (*dev->dev_ops->rss_hash_conf_get)(dev, rss_conf);
1870 rte_eth_led_on(uint8_t port_id)
1872 struct rte_eth_dev *dev;
1874 if (port_id >= nb_ports) {
1875 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1879 dev = &rte_eth_devices[port_id];
1880 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_on, -ENOTSUP);
1881 return ((*dev->dev_ops->dev_led_on)(dev));
1885 rte_eth_led_off(uint8_t port_id)
1887 struct rte_eth_dev *dev;
1889 if (port_id >= nb_ports) {
1890 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1894 dev = &rte_eth_devices[port_id];
1895 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_off, -ENOTSUP);
1896 return ((*dev->dev_ops->dev_led_off)(dev));
1900 * Returns index into MAC address array of addr. Use 00:00:00:00:00:00 to find
1904 get_mac_addr_index(uint8_t port_id, struct ether_addr *addr)
1906 struct rte_eth_dev_info dev_info;
1907 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
1910 rte_eth_dev_info_get(port_id, &dev_info);
1912 for (i = 0; i < dev_info.max_mac_addrs; i++)
1913 if (memcmp(addr, &dev->data->mac_addrs[i], ETHER_ADDR_LEN) == 0)
1919 static struct ether_addr null_mac_addr = {{0, 0, 0, 0, 0, 0}};
1922 rte_eth_dev_mac_addr_add(uint8_t port_id, struct ether_addr *addr,
1925 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_add, -ENOTSUP);
1936 if (is_zero_ether_addr(addr)) {
1937 PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
1941 if (pool >= ETH_64_POOLS) {
1942 PMD_DEBUG_TRACE("pool id must be 0-%d\n",ETH_64_POOLS - 1);
1946 index = get_mac_addr_index(port_id, addr);
1948 index = get_mac_addr_index(port_id, &null_mac_addr);
1950 PMD_DEBUG_TRACE("port %d: MAC address array full\n",
1955 pool_mask = dev->data->mac_pool_sel[index];
1957 /* Check if both MAC address and pool is alread there, and do nothing */
1958 if (pool_mask & (1ULL << pool))
1963 (*dev->dev_ops->mac_addr_add)(dev, addr, index, pool);
1965 /* Update address in NIC data structure */
1966 ether_addr_copy(addr, &dev->data->mac_addrs[index]);
1968 /* Update pool bitmap in NIC data structure */
1969 dev->data->mac_pool_sel[index] |= (1ULL << pool);
1975 rte_eth_dev_mac_addr_remove(uint8_t port_id, struct ether_addr *addr)
1977 struct rte_eth_dev *dev;
1980 if (port_id >= nb_ports) {
1981 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1984 dev = &rte_eth_devices[port_id];
1985 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
1987 index = get_mac_addr_index(port_id, addr);
1989 PMD_DEBUG_TRACE("port %d: Cannot remove default MAC address\n", port_id);
1990 return (-EADDRINUSE);
1991 } else if (index < 0)
1992 return 0; /* Do nothing if address wasn't found */
1995 (*dev->dev_ops->mac_addr_remove)(dev, index);
1997 /* Update address in NIC data structure */
1998 ether_addr_copy(&null_mac_addr, &dev->data->mac_addrs[index]);
2004 rte_eth_dev_set_vf_rxmode(uint8_t port_id, uint16_t vf,
2005 uint16_t rx_mode, uint8_t on)
2008 struct rte_eth_dev *dev;
2009 struct rte_eth_dev_info dev_info;
2011 if (port_id >= nb_ports) {
2012 PMD_DEBUG_TRACE("set VF RX mode:Invalid port_id=%d\n",
2017 dev = &rte_eth_devices[port_id];
2018 rte_eth_dev_info_get(port_id, &dev_info);
2020 num_vfs = dev_info.max_vfs;
2023 PMD_DEBUG_TRACE("set VF RX mode:invalid VF id %d\n", vf);
2028 PMD_DEBUG_TRACE("set VF RX mode:mode mask ca not be zero\n");
2031 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx_mode, -ENOTSUP);
2032 return (*dev->dev_ops->set_vf_rx_mode)(dev, vf, rx_mode, on);
2036 * Returns index into MAC address array of addr. Use 00:00:00:00:00:00 to find
2040 get_hash_mac_addr_index(uint8_t port_id, struct ether_addr *addr)
2042 struct rte_eth_dev_info dev_info;
2043 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2046 rte_eth_dev_info_get(port_id, &dev_info);
2047 if (!dev->data->hash_mac_addrs)
2050 for (i = 0; i < dev_info.max_hash_mac_addrs; i++)
2051 if (memcmp(addr, &dev->data->hash_mac_addrs[i],
2052 ETHER_ADDR_LEN) == 0)
2059 rte_eth_dev_uc_hash_table_set(uint8_t port_id, struct ether_addr *addr,
2064 struct rte_eth_dev *dev;
2066 if (port_id >= nb_ports) {
2067 PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=%d\n",
2072 dev = &rte_eth_devices[port_id];
2073 if (is_zero_ether_addr(addr)) {
2074 PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
2079 index = get_hash_mac_addr_index(port_id, addr);
2080 /* Check if it's already there, and do nothing */
2081 if ((index >= 0) && (on))
2086 PMD_DEBUG_TRACE("port %d: the MAC address was not"
2087 "set in UTA\n", port_id);
2091 index = get_hash_mac_addr_index(port_id, &null_mac_addr);
2093 PMD_DEBUG_TRACE("port %d: MAC address array full\n",
2099 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_hash_table_set, -ENOTSUP);
2100 ret = (*dev->dev_ops->uc_hash_table_set)(dev, addr, on);
2102 /* Update address in NIC data structure */
2104 ether_addr_copy(addr,
2105 &dev->data->hash_mac_addrs[index]);
2107 ether_addr_copy(&null_mac_addr,
2108 &dev->data->hash_mac_addrs[index]);
2115 rte_eth_dev_uc_all_hash_table_set(uint8_t port_id, uint8_t on)
2117 struct rte_eth_dev *dev;
2119 if (port_id >= nb_ports) {
2120 PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=%d\n",
2125 dev = &rte_eth_devices[port_id];
2127 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_all_hash_table_set, -ENOTSUP);
2128 return (*dev->dev_ops->uc_all_hash_table_set)(dev, on);
2132 rte_eth_dev_set_vf_rx(uint8_t port_id,uint16_t vf, uint8_t on)
2135 struct rte_eth_dev *dev;
2136 struct rte_eth_dev_info dev_info;
2138 if (port_id >= nb_ports) {
2139 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2143 dev = &rte_eth_devices[port_id];
2144 rte_eth_dev_info_get(port_id, &dev_info);
2146 num_vfs = dev_info.max_vfs;
2149 PMD_DEBUG_TRACE("port %d: invalid vf id\n", port_id);
2153 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx, -ENOTSUP);
2154 return (*dev->dev_ops->set_vf_rx)(dev, vf,on);
2158 rte_eth_dev_set_vf_tx(uint8_t port_id,uint16_t vf, uint8_t on)
2161 struct rte_eth_dev *dev;
2162 struct rte_eth_dev_info dev_info;
2164 if (port_id >= nb_ports) {
2165 PMD_DEBUG_TRACE("set pool tx:Invalid port_id=%d\n", port_id);
2169 dev = &rte_eth_devices[port_id];
2170 rte_eth_dev_info_get(port_id, &dev_info);
2172 num_vfs = dev_info.max_vfs;
2175 PMD_DEBUG_TRACE("set pool tx:invalid pool id=%d\n", vf);
2179 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_tx, -ENOTSUP);
2180 return (*dev->dev_ops->set_vf_tx)(dev, vf,on);
2184 rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, uint16_t vlan_id,
2185 uint64_t vf_mask,uint8_t vlan_on)
2187 struct rte_eth_dev *dev;
2189 if (port_id >= nb_ports) {
2190 PMD_DEBUG_TRACE("VF VLAN filter:invalid port id=%d\n",
2194 dev = &rte_eth_devices[port_id];
2196 if(vlan_id > ETHER_MAX_VLAN_ID)
2198 PMD_DEBUG_TRACE("VF VLAN filter:invalid VLAN id=%d\n",
2204 PMD_DEBUG_TRACE("VF VLAN filter:pool_mask can not be 0\n");
2208 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_filter, -ENOTSUP);
2209 return (*dev->dev_ops->set_vf_vlan_filter)(dev, vlan_id,
2213 int rte_eth_set_queue_rate_limit(uint8_t port_id, uint16_t queue_idx,
2216 struct rte_eth_dev *dev;
2217 struct rte_eth_dev_info dev_info;
2218 struct rte_eth_link link;
2220 if (port_id >= nb_ports) {
2221 PMD_DEBUG_TRACE("set queue rate limit:invalid port id=%d\n",
2226 dev = &rte_eth_devices[port_id];
2227 rte_eth_dev_info_get(port_id, &dev_info);
2228 link = dev->data->dev_link;
2230 if (queue_idx > dev_info.max_tx_queues) {
2231 PMD_DEBUG_TRACE("set queue rate limit:port %d: "
2232 "invalid queue id=%d\n", port_id, queue_idx);
2236 if (tx_rate > link.link_speed) {
2237 PMD_DEBUG_TRACE("set queue rate limit:invalid tx_rate=%d, "
2238 "bigger than link speed= %d\n",
2239 tx_rate, link_speed);
2243 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_queue_rate_limit, -ENOTSUP);
2244 return (*dev->dev_ops->set_queue_rate_limit)(dev, queue_idx, tx_rate);
2247 int rte_eth_set_vf_rate_limit(uint8_t port_id, uint16_t vf, uint16_t tx_rate,
2250 struct rte_eth_dev *dev;
2251 struct rte_eth_dev_info dev_info;
2252 struct rte_eth_link link;
2257 if (port_id >= nb_ports) {
2258 PMD_DEBUG_TRACE("set VF rate limit:invalid port id=%d\n",
2263 dev = &rte_eth_devices[port_id];
2264 rte_eth_dev_info_get(port_id, &dev_info);
2265 link = dev->data->dev_link;
2267 if (vf > dev_info.max_vfs) {
2268 PMD_DEBUG_TRACE("set VF rate limit:port %d: "
2269 "invalid vf id=%d\n", port_id, vf);
2273 if (tx_rate > link.link_speed) {
2274 PMD_DEBUG_TRACE("set VF rate limit:invalid tx_rate=%d, "
2275 "bigger than link speed= %d\n",
2276 tx_rate, link_speed);
2280 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rate_limit, -ENOTSUP);
2281 return (*dev->dev_ops->set_vf_rate_limit)(dev, vf, tx_rate, q_msk);
2285 rte_eth_mirror_rule_set(uint8_t port_id,
2286 struct rte_eth_vmdq_mirror_conf *mirror_conf,
2287 uint8_t rule_id, uint8_t on)
2289 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2291 if (port_id >= nb_ports) {
2292 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2296 if (mirror_conf->rule_type_mask == 0) {
2297 PMD_DEBUG_TRACE("mirror rule type can not be 0.\n");
2301 if (mirror_conf->dst_pool >= ETH_64_POOLS) {
2302 PMD_DEBUG_TRACE("Invalid dst pool, pool id must"
2303 "be 0-%d\n",ETH_64_POOLS - 1);
2307 if ((mirror_conf->rule_type_mask & ETH_VMDQ_POOL_MIRROR) &&
2308 (mirror_conf->pool_mask == 0)) {
2309 PMD_DEBUG_TRACE("Invalid mirror pool, pool mask can not"
2314 if(rule_id >= ETH_VMDQ_NUM_MIRROR_RULE)
2316 PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
2317 ETH_VMDQ_NUM_MIRROR_RULE - 1);
2321 dev = &rte_eth_devices[port_id];
2322 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_set, -ENOTSUP);
2324 return (*dev->dev_ops->mirror_rule_set)(dev, mirror_conf, rule_id, on);
2328 rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)
2330 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2332 if (port_id >= nb_ports) {
2333 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2337 if(rule_id >= ETH_VMDQ_NUM_MIRROR_RULE)
2339 PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
2340 ETH_VMDQ_NUM_MIRROR_RULE-1);
2344 dev = &rte_eth_devices[port_id];
2345 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_reset, -ENOTSUP);
2347 return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
2350 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
2352 rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
2353 struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
2355 struct rte_eth_dev *dev;
2357 if (port_id >= nb_ports) {
2358 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2361 dev = &rte_eth_devices[port_id];
2362 FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, -ENOTSUP);
2363 if (queue_id >= dev->data->nb_rx_queues) {
2364 PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
2367 return (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
2372 rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
2373 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
2375 struct rte_eth_dev *dev;
2377 if (port_id >= nb_ports) {
2378 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2381 dev = &rte_eth_devices[port_id];
2383 FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, -ENOTSUP);
2384 if (queue_id >= dev->data->nb_tx_queues) {
2385 PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
2388 return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id],
2393 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
2395 struct rte_eth_dev *dev;
2397 if (port_id >= nb_ports) {
2398 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2401 dev = &rte_eth_devices[port_id];
2402 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
2403 return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
2407 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
2409 struct rte_eth_dev *dev;
2411 if (port_id >= nb_ports) {
2412 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2415 dev = &rte_eth_devices[port_id];
2416 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
2417 return (*dev->dev_ops->rx_descriptor_done)( \
2418 dev->data->rx_queues[queue_id], offset);
2423 rte_eth_dev_callback_register(uint8_t port_id,
2424 enum rte_eth_event_type event,
2425 rte_eth_dev_cb_fn cb_fn, void *cb_arg)
2427 struct rte_eth_dev *dev;
2428 struct rte_eth_dev_callback *user_cb;
2432 if (port_id >= nb_ports) {
2433 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2437 dev = &rte_eth_devices[port_id];
2438 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2440 TAILQ_FOREACH(user_cb, &(dev->callbacks), next) {
2441 if (user_cb->cb_fn == cb_fn &&
2442 user_cb->cb_arg == cb_arg &&
2443 user_cb->event == event) {
2448 /* create a new callback. */
2449 if (user_cb == NULL && (user_cb = rte_zmalloc("INTR_USER_CALLBACK",
2450 sizeof(struct rte_eth_dev_callback), 0)) != NULL) {
2451 user_cb->cb_fn = cb_fn;
2452 user_cb->cb_arg = cb_arg;
2453 user_cb->event = event;
2454 TAILQ_INSERT_TAIL(&(dev->callbacks), user_cb, next);
2457 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2458 return ((user_cb == NULL) ? -ENOMEM : 0);
2462 rte_eth_dev_callback_unregister(uint8_t port_id,
2463 enum rte_eth_event_type event,
2464 rte_eth_dev_cb_fn cb_fn, void *cb_arg)
2467 struct rte_eth_dev *dev;
2468 struct rte_eth_dev_callback *cb, *next;
2472 if (port_id >= nb_ports) {
2473 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2477 dev = &rte_eth_devices[port_id];
2478 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2481 for (cb = TAILQ_FIRST(&dev->callbacks); cb != NULL; cb = next) {
2483 next = TAILQ_NEXT(cb, next);
2485 if (cb->cb_fn != cb_fn || cb->event != event ||
2486 (cb->cb_arg != (void *)-1 &&
2487 cb->cb_arg != cb_arg))
2491 * if this callback is not executing right now,
2494 if (cb->active == 0) {
2495 TAILQ_REMOVE(&(dev->callbacks), cb, next);
2502 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2507 _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
2508 enum rte_eth_event_type event)
2510 struct rte_eth_dev_callback *cb_lst;
2511 struct rte_eth_dev_callback dev_cb;
2513 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2514 TAILQ_FOREACH(cb_lst, &(dev->callbacks), next) {
2515 if (cb_lst->cb_fn == NULL || cb_lst->event != event)
2519 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2520 dev_cb.cb_fn(dev->data->port_id, dev_cb.event,
2522 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2525 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2527 #ifdef RTE_NIC_BYPASS
2528 int rte_eth_dev_bypass_init(uint8_t port_id)
2530 struct rte_eth_dev *dev;
2532 if (port_id >= nb_ports) {
2533 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2537 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2538 PMD_DEBUG_TRACE("Invalid port device\n");
2542 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_init, -ENOTSUP);
2543 (*dev->dev_ops->bypass_init)(dev);
2548 rte_eth_dev_bypass_state_show(uint8_t port_id, uint32_t *state)
2550 struct rte_eth_dev *dev;
2552 if (port_id >= nb_ports) {
2553 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2557 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2558 PMD_DEBUG_TRACE("Invalid port device\n");
2561 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
2562 (*dev->dev_ops->bypass_state_show)(dev, state);
2567 rte_eth_dev_bypass_state_set(uint8_t port_id, uint32_t *new_state)
2569 struct rte_eth_dev *dev;
2571 if (port_id >= nb_ports) {
2572 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2576 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2577 PMD_DEBUG_TRACE("Invalid port device\n");
2581 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_set, -ENOTSUP);
2582 (*dev->dev_ops->bypass_state_set)(dev, new_state);
2587 rte_eth_dev_bypass_event_show(uint8_t port_id, uint32_t event, uint32_t *state)
2589 struct rte_eth_dev *dev;
2591 if (port_id >= nb_ports) {
2592 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2596 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2597 PMD_DEBUG_TRACE("Invalid port device\n");
2601 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
2602 (*dev->dev_ops->bypass_event_show)(dev, event, state);
2607 rte_eth_dev_bypass_event_store(uint8_t port_id, uint32_t event, uint32_t state)
2609 struct rte_eth_dev *dev;
2611 if (port_id >= nb_ports) {
2612 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2616 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2617 PMD_DEBUG_TRACE("Invalid port device\n");
2621 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_event_set, -ENOTSUP);
2622 (*dev->dev_ops->bypass_event_set)(dev, event, state);
2627 rte_eth_dev_wd_timeout_store(uint8_t port_id, uint32_t timeout)
2629 struct rte_eth_dev *dev;
2631 if (port_id >= nb_ports) {
2632 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2636 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2637 PMD_DEBUG_TRACE("Invalid port device\n");
2641 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_set, -ENOTSUP);
2642 (*dev->dev_ops->bypass_wd_timeout_set)(dev, timeout);
2647 rte_eth_dev_bypass_ver_show(uint8_t port_id, uint32_t *ver)
2649 struct rte_eth_dev *dev;
2651 if (port_id >= nb_ports) {
2652 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2656 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2657 PMD_DEBUG_TRACE("Invalid port device\n");
2661 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_ver_show, -ENOTSUP);
2662 (*dev->dev_ops->bypass_ver_show)(dev, ver);
2667 rte_eth_dev_bypass_wd_timeout_show(uint8_t port_id, uint32_t *wd_timeout)
2669 struct rte_eth_dev *dev;
2671 if (port_id >= nb_ports) {
2672 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2676 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2677 PMD_DEBUG_TRACE("Invalid port device\n");
2681 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_show, -ENOTSUP);
2682 (*dev->dev_ops->bypass_wd_timeout_show)(dev, wd_timeout);
2687 rte_eth_dev_bypass_wd_reset(uint8_t port_id)
2689 struct rte_eth_dev *dev;
2691 if (port_id >= nb_ports) {
2692 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2696 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2697 PMD_DEBUG_TRACE("Invalid port device\n");
2701 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_reset, -ENOTSUP);
2702 (*dev->dev_ops->bypass_wd_reset)(dev);
2708 rte_eth_dev_add_syn_filter(uint8_t port_id,
2709 struct rte_syn_filter *filter, uint16_t rx_queue)
2711 struct rte_eth_dev *dev;
2713 if (port_id >= nb_ports) {
2714 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2718 dev = &rte_eth_devices[port_id];
2719 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_syn_filter, -ENOTSUP);
2720 return (*dev->dev_ops->add_syn_filter)(dev, filter, rx_queue);
2724 rte_eth_dev_remove_syn_filter(uint8_t port_id)
2726 struct rte_eth_dev *dev;
2728 if (port_id >= nb_ports) {
2729 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2733 dev = &rte_eth_devices[port_id];
2734 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_syn_filter, -ENOTSUP);
2735 return (*dev->dev_ops->remove_syn_filter)(dev);
2739 rte_eth_dev_get_syn_filter(uint8_t port_id,
2740 struct rte_syn_filter *filter, uint16_t *rx_queue)
2742 struct rte_eth_dev *dev;
2744 if (filter == NULL || rx_queue == NULL)
2747 if (port_id >= nb_ports) {
2748 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2752 dev = &rte_eth_devices[port_id];
2753 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_syn_filter, -ENOTSUP);
2754 return (*dev->dev_ops->get_syn_filter)(dev, filter, rx_queue);
2758 rte_eth_dev_add_ethertype_filter(uint8_t port_id, uint16_t index,
2759 struct rte_ethertype_filter *filter, uint16_t rx_queue)
2761 struct rte_eth_dev *dev;
2763 if (port_id >= nb_ports) {
2764 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2767 if (filter->ethertype == ETHER_TYPE_IPv4 ||
2768 filter->ethertype == ETHER_TYPE_IPv6){
2769 PMD_DEBUG_TRACE("IP and IPv6 are not supported"
2770 " in ethertype filter\n");
2773 dev = &rte_eth_devices[port_id];
2774 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_ethertype_filter, -ENOTSUP);
2775 return (*dev->dev_ops->add_ethertype_filter)(dev, index,
2780 rte_eth_dev_remove_ethertype_filter(uint8_t port_id, uint16_t index)
2782 struct rte_eth_dev *dev;
2784 if (port_id >= nb_ports) {
2785 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2789 dev = &rte_eth_devices[port_id];
2790 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_ethertype_filter, -ENOTSUP);
2791 return (*dev->dev_ops->remove_ethertype_filter)(dev, index);
2795 rte_eth_dev_get_ethertype_filter(uint8_t port_id, uint16_t index,
2796 struct rte_ethertype_filter *filter, uint16_t *rx_queue)
2798 struct rte_eth_dev *dev;
2800 if (filter == NULL || rx_queue == NULL)
2803 if (port_id >= nb_ports) {
2804 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2808 dev = &rte_eth_devices[port_id];
2809 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_ethertype_filter, -ENOTSUP);
2810 return (*dev->dev_ops->get_ethertype_filter)(dev, index,
2815 rte_eth_dev_add_2tuple_filter(uint8_t port_id, uint16_t index,
2816 struct rte_2tuple_filter *filter, uint16_t rx_queue)
2818 struct rte_eth_dev *dev;
2820 if (port_id >= nb_ports) {
2821 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2824 if (filter->protocol != IPPROTO_TCP &&
2825 filter->tcp_flags != 0){
2826 PMD_DEBUG_TRACE("tcp flags is 0x%x, but the protocol value"
2832 dev = &rte_eth_devices[port_id];
2833 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_2tuple_filter, -ENOTSUP);
2834 return (*dev->dev_ops->add_2tuple_filter)(dev, index, filter, rx_queue);
2838 rte_eth_dev_remove_2tuple_filter(uint8_t port_id, uint16_t index)
2840 struct rte_eth_dev *dev;
2842 if (port_id >= nb_ports) {
2843 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2847 dev = &rte_eth_devices[port_id];
2848 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_2tuple_filter, -ENOTSUP);
2849 return (*dev->dev_ops->remove_2tuple_filter)(dev, index);
2853 rte_eth_dev_get_2tuple_filter(uint8_t port_id, uint16_t index,
2854 struct rte_2tuple_filter *filter, uint16_t *rx_queue)
2856 struct rte_eth_dev *dev;
2858 if (filter == NULL || rx_queue == NULL)
2861 if (port_id >= nb_ports) {
2862 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2866 dev = &rte_eth_devices[port_id];
2867 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_2tuple_filter, -ENOTSUP);
2868 return (*dev->dev_ops->get_2tuple_filter)(dev, index, filter, rx_queue);
2872 rte_eth_dev_add_5tuple_filter(uint8_t port_id, uint16_t index,
2873 struct rte_5tuple_filter *filter, uint16_t rx_queue)
2875 struct rte_eth_dev *dev;
2877 if (port_id >= nb_ports) {
2878 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2882 if (filter->protocol != IPPROTO_TCP &&
2883 filter->tcp_flags != 0){
2884 PMD_DEBUG_TRACE("tcp flags is 0x%x, but the protocol value"
2890 dev = &rte_eth_devices[port_id];
2891 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_5tuple_filter, -ENOTSUP);
2892 return (*dev->dev_ops->add_5tuple_filter)(dev, index, filter, rx_queue);
2896 rte_eth_dev_remove_5tuple_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_5tuple_filter, -ENOTSUP);
2907 return (*dev->dev_ops->remove_5tuple_filter)(dev, index);
2911 rte_eth_dev_get_5tuple_filter(uint8_t port_id, uint16_t index,
2912 struct rte_5tuple_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_5tuple_filter, -ENOTSUP);
2926 return (*dev->dev_ops->get_5tuple_filter)(dev, index, filter,
2931 rte_eth_dev_add_flex_filter(uint8_t port_id, uint16_t index,
2932 struct rte_flex_filter *filter, uint16_t rx_queue)
2934 struct rte_eth_dev *dev;
2936 if (port_id >= nb_ports) {
2937 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2941 dev = &rte_eth_devices[port_id];
2942 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_flex_filter, -ENOTSUP);
2943 return (*dev->dev_ops->add_flex_filter)(dev, index, filter, rx_queue);
2947 rte_eth_dev_remove_flex_filter(uint8_t port_id, uint16_t index)
2949 struct rte_eth_dev *dev;
2951 if (port_id >= nb_ports) {
2952 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2956 dev = &rte_eth_devices[port_id];
2957 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_flex_filter, -ENOTSUP);
2958 return (*dev->dev_ops->remove_flex_filter)(dev, index);
2962 rte_eth_dev_get_flex_filter(uint8_t port_id, uint16_t index,
2963 struct rte_flex_filter *filter, uint16_t *rx_queue)
2965 struct rte_eth_dev *dev;
2967 if (filter == NULL || rx_queue == NULL)
2970 if (port_id >= nb_ports) {
2971 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2975 dev = &rte_eth_devices[port_id];
2976 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_flex_filter, -ENOTSUP);
2977 return (*dev->dev_ops->get_flex_filter)(dev, index, filter,