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>
68 #include <rte_string_fns.h>
70 #include "rte_ether.h"
71 #include "rte_ethdev.h"
73 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
74 #define PMD_DEBUG_TRACE(fmt, args...) do { \
75 RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args); \
78 #define PMD_DEBUG_TRACE(fmt, args...)
81 /* Macros for checking for restricting functions to primary instance only */
82 #define PROC_PRIMARY_OR_ERR_RET(retval) do { \
83 if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \
84 PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
88 #define PROC_PRIMARY_OR_RET() do { \
89 if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \
90 PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
95 /* Macros to check for invlaid function pointers in dev_ops structure */
96 #define FUNC_PTR_OR_ERR_RET(func, retval) do { \
97 if ((func) == NULL) { \
98 PMD_DEBUG_TRACE("Function not supported\n"); \
102 #define FUNC_PTR_OR_RET(func) do { \
103 if ((func) == NULL) { \
104 PMD_DEBUG_TRACE("Function not supported\n"); \
109 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
110 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
111 static struct rte_eth_dev_data *rte_eth_dev_data = NULL;
112 static uint8_t nb_ports = 0;
114 /* spinlock for eth device callbacks */
115 static rte_spinlock_t rte_eth_dev_cb_lock = RTE_SPINLOCK_INITIALIZER;
118 * The user application callback description.
120 * It contains callback address to be registered by user application,
121 * the pointer to the parameters for callback, and the event type.
123 struct rte_eth_dev_callback {
124 TAILQ_ENTRY(rte_eth_dev_callback) next; /**< Callbacks list */
125 rte_eth_dev_cb_fn cb_fn; /**< Callback address */
126 void *cb_arg; /**< Parameter for callback */
127 enum rte_eth_event_type event; /**< Interrupt event type */
128 uint32_t active; /**< Callback is executing */
137 rte_eth_dev_data_alloc(void)
139 const unsigned flags = 0;
140 const struct rte_memzone *mz;
142 if (rte_eal_process_type() == RTE_PROC_PRIMARY){
143 mz = rte_memzone_reserve(MZ_RTE_ETH_DEV_DATA,
144 RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data),
145 rte_socket_id(), flags);
147 mz = rte_memzone_lookup(MZ_RTE_ETH_DEV_DATA);
149 rte_panic("Cannot allocate memzone for ethernet port data\n");
151 rte_eth_dev_data = mz->addr;
152 if (rte_eal_process_type() == RTE_PROC_PRIMARY)
153 memset(rte_eth_dev_data, 0,
154 RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data));
157 static struct rte_eth_dev *
158 rte_eth_dev_allocated(const char *name)
162 for (i = 0; i < nb_ports; i++) {
163 if (strcmp(rte_eth_devices[i].data->name, name) == 0)
164 return &rte_eth_devices[i];
170 rte_eth_dev_allocate(const char *name)
172 struct rte_eth_dev *eth_dev;
174 if (nb_ports == RTE_MAX_ETHPORTS) {
175 PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
179 if (rte_eth_dev_data == NULL)
180 rte_eth_dev_data_alloc();
182 if (rte_eth_dev_allocated(name) != NULL) {
183 PMD_DEBUG_TRACE("Ethernet Device with name %s already allocated!\n", name);
187 eth_dev = &rte_eth_devices[nb_ports];
188 eth_dev->data = &rte_eth_dev_data[nb_ports];
189 snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
190 eth_dev->data->port_id = nb_ports++;
195 rte_eth_dev_init(struct rte_pci_driver *pci_drv,
196 struct rte_pci_device *pci_dev)
198 struct eth_driver *eth_drv;
199 struct rte_eth_dev *eth_dev;
200 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
204 eth_drv = (struct eth_driver *)pci_drv;
206 /* Create unique Ethernet device name using PCI address */
207 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "%d:%d.%d",
208 pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);
210 eth_dev = rte_eth_dev_allocate(ethdev_name);
214 if (rte_eal_process_type() == RTE_PROC_PRIMARY){
215 eth_dev->data->dev_private = rte_zmalloc("ethdev private structure",
216 eth_drv->dev_private_size,
218 if (eth_dev->data->dev_private == NULL)
219 rte_panic("Cannot allocate memzone for private port data\n");
221 eth_dev->pci_dev = pci_dev;
222 eth_dev->driver = eth_drv;
223 eth_dev->data->rx_mbuf_alloc_failed = 0;
225 /* init user callbacks */
226 TAILQ_INIT(&(eth_dev->callbacks));
229 * Set the default MTU.
231 eth_dev->data->mtu = ETHER_MTU;
233 /* Invoke PMD device initialization function */
234 diag = (*eth_drv->eth_dev_init)(eth_drv, eth_dev);
238 PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x)"
239 " failed\n", pci_drv->name,
240 (unsigned) pci_dev->id.vendor_id,
241 (unsigned) pci_dev->id.device_id);
242 if (rte_eal_process_type() == RTE_PROC_PRIMARY)
243 rte_free(eth_dev->data->dev_private);
249 * Register an Ethernet [Poll Mode] driver.
251 * Function invoked by the initialization function of an Ethernet driver
252 * to simultaneously register itself as a PCI driver and as an Ethernet
254 * Invokes the rte_eal_pci_register() function to register the *pci_drv*
255 * structure embedded in the *eth_drv* structure, after having stored the
256 * address of the rte_eth_dev_init() function in the *devinit* field of
257 * the *pci_drv* structure.
258 * During the PCI probing phase, the rte_eth_dev_init() function is
259 * invoked for each PCI [Ethernet device] matching the embedded PCI
260 * identifiers provided by the driver.
263 rte_eth_driver_register(struct eth_driver *eth_drv)
265 eth_drv->pci_drv.devinit = rte_eth_dev_init;
266 rte_eal_pci_register(ð_drv->pci_drv);
270 rte_eth_dev_socket_id(uint8_t port_id)
272 if (port_id >= nb_ports)
274 return rte_eth_devices[port_id].pci_dev->numa_node;
278 rte_eth_dev_count(void)
284 rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
286 uint16_t old_nb_queues = dev->data->nb_rx_queues;
290 if (dev->data->rx_queues == NULL) { /* first time configuration */
291 dev->data->rx_queues = rte_zmalloc("ethdev->rx_queues",
292 sizeof(dev->data->rx_queues[0]) * nb_queues,
294 if (dev->data->rx_queues == NULL) {
295 dev->data->nb_rx_queues = 0;
298 } else { /* re-configure */
299 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
301 rxq = dev->data->rx_queues;
303 for (i = nb_queues; i < old_nb_queues; i++)
304 (*dev->dev_ops->rx_queue_release)(rxq[i]);
305 rxq = rte_realloc(rxq, sizeof(rxq[0]) * nb_queues,
310 if (nb_queues > old_nb_queues)
311 memset(rxq + old_nb_queues, 0,
312 sizeof(rxq[0]) * (nb_queues - old_nb_queues));
314 dev->data->rx_queues = rxq;
317 dev->data->nb_rx_queues = nb_queues;
322 rte_eth_dev_rx_queue_start(uint8_t port_id, uint16_t rx_queue_id)
324 struct rte_eth_dev *dev;
326 /* This function is only safe when called from the primary process
327 * in a multi-process setup*/
328 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
330 if (port_id >= nb_ports) {
331 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
335 dev = &rte_eth_devices[port_id];
336 if (rx_queue_id >= dev->data->nb_rx_queues) {
337 PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
341 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_start, -ENOTSUP);
343 return dev->dev_ops->rx_queue_start(dev, rx_queue_id);
348 rte_eth_dev_rx_queue_stop(uint8_t port_id, uint16_t rx_queue_id)
350 struct rte_eth_dev *dev;
352 /* This function is only safe when called from the primary process
353 * in a multi-process setup*/
354 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
356 if (port_id >= nb_ports) {
357 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
361 dev = &rte_eth_devices[port_id];
362 if (rx_queue_id >= dev->data->nb_rx_queues) {
363 PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
367 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_stop, -ENOTSUP);
369 return dev->dev_ops->rx_queue_stop(dev, rx_queue_id);
374 rte_eth_dev_tx_queue_start(uint8_t port_id, uint16_t tx_queue_id)
376 struct rte_eth_dev *dev;
378 /* This function is only safe when called from the primary process
379 * in a multi-process setup*/
380 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
382 if (port_id >= nb_ports) {
383 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
387 dev = &rte_eth_devices[port_id];
388 if (tx_queue_id >= dev->data->nb_tx_queues) {
389 PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
393 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_start, -ENOTSUP);
395 return dev->dev_ops->tx_queue_start(dev, tx_queue_id);
400 rte_eth_dev_tx_queue_stop(uint8_t port_id, uint16_t tx_queue_id)
402 struct rte_eth_dev *dev;
404 /* This function is only safe when called from the primary process
405 * in a multi-process setup*/
406 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
408 if (port_id >= nb_ports) {
409 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
413 dev = &rte_eth_devices[port_id];
414 if (tx_queue_id >= dev->data->nb_tx_queues) {
415 PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
419 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_stop, -ENOTSUP);
421 return dev->dev_ops->tx_queue_stop(dev, tx_queue_id);
426 rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
428 uint16_t old_nb_queues = dev->data->nb_tx_queues;
432 if (dev->data->tx_queues == NULL) { /* first time configuration */
433 dev->data->tx_queues = rte_zmalloc("ethdev->tx_queues",
434 sizeof(dev->data->tx_queues[0]) * nb_queues,
436 if (dev->data->tx_queues == NULL) {
437 dev->data->nb_tx_queues = 0;
440 } else { /* re-configure */
441 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);
443 txq = dev->data->tx_queues;
445 for (i = nb_queues; i < old_nb_queues; i++)
446 (*dev->dev_ops->tx_queue_release)(txq[i]);
447 txq = rte_realloc(txq, sizeof(txq[0]) * nb_queues,
452 if (nb_queues > old_nb_queues)
453 memset(txq + old_nb_queues, 0,
454 sizeof(txq[0]) * (nb_queues - old_nb_queues));
456 dev->data->tx_queues = txq;
459 dev->data->nb_tx_queues = nb_queues;
464 rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
465 const struct rte_eth_conf *dev_conf)
467 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
469 if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
470 /* check multi-queue mode */
471 if ((dev_conf->rxmode.mq_mode == ETH_MQ_RX_RSS) ||
472 (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) ||
473 (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB_RSS) ||
474 (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB)) {
475 /* SRIOV only works in VMDq enable mode */
476 PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
478 "wrong VMDQ mq_mode rx %u tx %u\n",
480 dev_conf->rxmode.mq_mode,
481 dev_conf->txmode.mq_mode);
485 switch (dev_conf->rxmode.mq_mode) {
486 case ETH_MQ_RX_VMDQ_RSS:
487 case ETH_MQ_RX_VMDQ_DCB:
488 case ETH_MQ_RX_VMDQ_DCB_RSS:
489 /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
490 PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
492 "unsupported VMDQ mq_mode rx %u\n",
493 port_id, dev_conf->rxmode.mq_mode);
495 default: /* ETH_MQ_RX_VMDQ_ONLY or ETH_MQ_RX_NONE */
496 /* if nothing mq mode configure, use default scheme */
497 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_ONLY;
498 if (RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool > 1)
499 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
503 switch (dev_conf->txmode.mq_mode) {
504 case ETH_MQ_TX_VMDQ_DCB:
505 /* DCB VMDQ in SRIOV mode, not implement yet */
506 PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
508 "unsupported VMDQ mq_mode tx %u\n",
509 port_id, dev_conf->txmode.mq_mode);
511 default: /* ETH_MQ_TX_VMDQ_ONLY or ETH_MQ_TX_NONE */
512 /* if nothing mq mode configure, use default scheme */
513 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_ONLY;
514 if (RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool > 1)
515 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
519 /* check valid queue number */
520 if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
521 (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
522 PMD_DEBUG_TRACE("ethdev port_id=%d SRIOV active, "
523 "queue number must less equal to %d\n",
524 port_id, RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
528 /* For vmdb+dcb mode check our configuration before we go further */
529 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB) {
530 const struct rte_eth_vmdq_dcb_conf *conf;
532 if (nb_rx_q != ETH_VMDQ_DCB_NUM_QUEUES) {
533 PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_rx_q "
535 port_id, ETH_VMDQ_DCB_NUM_QUEUES);
538 conf = &(dev_conf->rx_adv_conf.vmdq_dcb_conf);
539 if (! (conf->nb_queue_pools == ETH_16_POOLS ||
540 conf->nb_queue_pools == ETH_32_POOLS)) {
541 PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
542 "nb_queue_pools must be %d or %d\n",
543 port_id, ETH_16_POOLS, ETH_32_POOLS);
547 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_VMDQ_DCB) {
548 const struct rte_eth_vmdq_dcb_tx_conf *conf;
550 if (nb_tx_q != ETH_VMDQ_DCB_NUM_QUEUES) {
551 PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_tx_q "
553 port_id, ETH_VMDQ_DCB_NUM_QUEUES);
556 conf = &(dev_conf->tx_adv_conf.vmdq_dcb_tx_conf);
557 if (! (conf->nb_queue_pools == ETH_16_POOLS ||
558 conf->nb_queue_pools == ETH_32_POOLS)) {
559 PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
560 "nb_queue_pools != %d or nb_queue_pools "
562 port_id, ETH_16_POOLS, ETH_32_POOLS);
567 /* For DCB mode check our configuration before we go further */
568 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) {
569 const struct rte_eth_dcb_rx_conf *conf;
571 if (nb_rx_q != ETH_DCB_NUM_QUEUES) {
572 PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_rx_q "
574 port_id, ETH_DCB_NUM_QUEUES);
577 conf = &(dev_conf->rx_adv_conf.dcb_rx_conf);
578 if (! (conf->nb_tcs == ETH_4_TCS ||
579 conf->nb_tcs == ETH_8_TCS)) {
580 PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
581 "nb_tcs != %d or nb_tcs "
583 port_id, ETH_4_TCS, ETH_8_TCS);
588 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB) {
589 const struct rte_eth_dcb_tx_conf *conf;
591 if (nb_tx_q != ETH_DCB_NUM_QUEUES) {
592 PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_tx_q "
594 port_id, ETH_DCB_NUM_QUEUES);
597 conf = &(dev_conf->tx_adv_conf.dcb_tx_conf);
598 if (! (conf->nb_tcs == ETH_4_TCS ||
599 conf->nb_tcs == ETH_8_TCS)) {
600 PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
601 "nb_tcs != %d or nb_tcs "
603 port_id, ETH_4_TCS, ETH_8_TCS);
612 rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
613 const struct rte_eth_conf *dev_conf)
615 struct rte_eth_dev *dev;
616 struct rte_eth_dev_info dev_info;
619 /* This function is only safe when called from the primary process
620 * in a multi-process setup*/
621 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
623 if (port_id >= nb_ports || port_id >= RTE_MAX_ETHPORTS) {
624 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
627 dev = &rte_eth_devices[port_id];
629 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
630 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
632 if (dev->data->dev_started) {
634 "port %d must be stopped to allow configuration\n", port_id);
639 * Check that the numbers of RX and TX queues are not greater
640 * than the maximum number of RX and TX queues supported by the
643 (*dev->dev_ops->dev_infos_get)(dev, &dev_info);
644 if (nb_rx_q > dev_info.max_rx_queues) {
645 PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_queues=%d > %d\n",
646 port_id, nb_rx_q, dev_info.max_rx_queues);
650 PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_q == 0\n", port_id);
654 if (nb_tx_q > dev_info.max_tx_queues) {
655 PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_queues=%d > %d\n",
656 port_id, nb_tx_q, dev_info.max_tx_queues);
660 PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_q == 0\n", port_id);
664 /* Copy the dev_conf parameter into the dev structure */
665 memcpy(&dev->data->dev_conf, dev_conf, sizeof(dev->data->dev_conf));
668 * If link state interrupt is enabled, check that the
669 * device supports it.
671 if (dev_conf->intr_conf.lsc == 1) {
672 const struct rte_pci_driver *pci_drv = &dev->driver->pci_drv;
674 if (!(pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
675 PMD_DEBUG_TRACE("driver %s does not support lsc\n",
682 * If jumbo frames are enabled, check that the maximum RX packet
683 * length is supported by the configured device.
685 if (dev_conf->rxmode.jumbo_frame == 1) {
686 if (dev_conf->rxmode.max_rx_pkt_len >
687 dev_info.max_rx_pktlen) {
688 PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
689 " > max valid value %u\n",
691 (unsigned)dev_conf->rxmode.max_rx_pkt_len,
692 (unsigned)dev_info.max_rx_pktlen);
695 else if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN) {
696 PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
697 " < min valid value %u\n",
699 (unsigned)dev_conf->rxmode.max_rx_pkt_len,
700 (unsigned)ETHER_MIN_LEN);
704 if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN ||
705 dev_conf->rxmode.max_rx_pkt_len > ETHER_MAX_LEN)
706 /* Use default value */
707 dev->data->dev_conf.rxmode.max_rx_pkt_len =
711 /* multipe queue mode checking */
712 diag = rte_eth_dev_check_mq_mode(port_id, nb_rx_q, nb_tx_q, dev_conf);
714 PMD_DEBUG_TRACE("port%d rte_eth_dev_check_mq_mode = %d\n",
720 * Setup new number of RX/TX queues and reconfigure device.
722 diag = rte_eth_dev_rx_queue_config(dev, nb_rx_q);
724 PMD_DEBUG_TRACE("port%d rte_eth_dev_rx_queue_config = %d\n",
729 diag = rte_eth_dev_tx_queue_config(dev, nb_tx_q);
731 PMD_DEBUG_TRACE("port%d rte_eth_dev_tx_queue_config = %d\n",
733 rte_eth_dev_rx_queue_config(dev, 0);
737 diag = (*dev->dev_ops->dev_configure)(dev);
739 PMD_DEBUG_TRACE("port%d dev_configure = %d\n",
741 rte_eth_dev_rx_queue_config(dev, 0);
742 rte_eth_dev_tx_queue_config(dev, 0);
750 rte_eth_dev_config_restore(uint8_t port_id)
752 struct rte_eth_dev *dev;
753 struct rte_eth_dev_info dev_info;
754 struct ether_addr addr;
758 dev = &rte_eth_devices[port_id];
760 rte_eth_dev_info_get(port_id, &dev_info);
762 if (RTE_ETH_DEV_SRIOV(dev).active)
763 pool = RTE_ETH_DEV_SRIOV(dev).def_vmdq_idx;
765 /* replay MAC address configuration */
766 for (i = 0; i < dev_info.max_mac_addrs; i++) {
767 addr = dev->data->mac_addrs[i];
769 /* skip zero address */
770 if (is_zero_ether_addr(&addr))
773 /* add address to the hardware */
774 if (*dev->dev_ops->mac_addr_add)
775 (*dev->dev_ops->mac_addr_add)(dev, &addr, i, pool);
777 PMD_DEBUG_TRACE("port %d: MAC address array not supported\n",
779 /* exit the loop but not return an error */
784 /* replay promiscuous configuration */
785 if (rte_eth_promiscuous_get(port_id) == 1)
786 rte_eth_promiscuous_enable(port_id);
787 else if (rte_eth_promiscuous_get(port_id) == 0)
788 rte_eth_promiscuous_disable(port_id);
790 /* replay allmulticast configuration */
791 if (rte_eth_allmulticast_get(port_id) == 1)
792 rte_eth_allmulticast_enable(port_id);
793 else if (rte_eth_allmulticast_get(port_id) == 0)
794 rte_eth_allmulticast_disable(port_id);
798 rte_eth_dev_start(uint8_t port_id)
800 struct rte_eth_dev *dev;
803 /* This function is only safe when called from the primary process
804 * in a multi-process setup*/
805 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
807 if (port_id >= nb_ports) {
808 PMD_DEBUG_TRACE("Invalid port_id=%" PRIu8 "\n", port_id);
811 dev = &rte_eth_devices[port_id];
813 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
815 if (dev->data->dev_started != 0) {
816 PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
817 " already started\n",
822 diag = (*dev->dev_ops->dev_start)(dev);
824 dev->data->dev_started = 1;
828 rte_eth_dev_config_restore(port_id);
834 rte_eth_dev_stop(uint8_t port_id)
836 struct rte_eth_dev *dev;
838 /* This function is only safe when called from the primary process
839 * in a multi-process setup*/
840 PROC_PRIMARY_OR_RET();
842 if (port_id >= nb_ports) {
843 PMD_DEBUG_TRACE("Invalid port_id=%" PRIu8 "\n", port_id);
846 dev = &rte_eth_devices[port_id];
848 FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop);
850 if (dev->data->dev_started == 0) {
851 PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
852 " already stopped\n",
857 dev->data->dev_started = 0;
858 (*dev->dev_ops->dev_stop)(dev);
862 rte_eth_dev_set_link_up(uint8_t port_id)
864 struct rte_eth_dev *dev;
866 /* This function is only safe when called from the primary process
867 * in a multi-process setup*/
868 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
870 if (port_id >= nb_ports) {
871 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
874 dev = &rte_eth_devices[port_id];
876 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_up, -ENOTSUP);
877 return (*dev->dev_ops->dev_set_link_up)(dev);
881 rte_eth_dev_set_link_down(uint8_t port_id)
883 struct rte_eth_dev *dev;
885 /* This function is only safe when called from the primary process
886 * in a multi-process setup*/
887 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
889 if (port_id >= nb_ports) {
890 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
893 dev = &rte_eth_devices[port_id];
895 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_down, -ENOTSUP);
896 return (*dev->dev_ops->dev_set_link_down)(dev);
900 rte_eth_dev_close(uint8_t port_id)
902 struct rte_eth_dev *dev;
904 /* This function is only safe when called from the primary process
905 * in a multi-process setup*/
906 PROC_PRIMARY_OR_RET();
908 if (port_id >= nb_ports) {
909 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
913 dev = &rte_eth_devices[port_id];
915 FUNC_PTR_OR_RET(*dev->dev_ops->dev_close);
916 dev->data->dev_started = 0;
917 (*dev->dev_ops->dev_close)(dev);
921 rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
922 uint16_t nb_rx_desc, unsigned int socket_id,
923 const struct rte_eth_rxconf *rx_conf,
924 struct rte_mempool *mp)
927 uint32_t mbp_buf_size;
928 struct rte_eth_dev *dev;
929 struct rte_pktmbuf_pool_private *mbp_priv;
930 struct rte_eth_dev_info dev_info;
932 /* This function is only safe when called from the primary process
933 * in a multi-process setup*/
934 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
936 if (port_id >= nb_ports) {
937 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
940 dev = &rte_eth_devices[port_id];
941 if (rx_queue_id >= dev->data->nb_rx_queues) {
942 PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
946 if (dev->data->dev_started) {
948 "port %d must be stopped to allow configuration\n", port_id);
952 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
953 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP);
956 * Check the size of the mbuf data buffer.
957 * This value must be provided in the private data of the memory pool.
958 * First check that the memory pool has a valid private data.
960 (*dev->dev_ops->dev_infos_get)(dev, &dev_info);
961 if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) {
962 PMD_DEBUG_TRACE("%s private_data_size %d < %d\n",
963 mp->name, (int) mp->private_data_size,
964 (int) sizeof(struct rte_pktmbuf_pool_private));
967 mbp_priv = rte_mempool_get_priv(mp);
968 mbp_buf_size = mbp_priv->mbuf_data_room_size;
970 if ((mbp_buf_size - RTE_PKTMBUF_HEADROOM) < dev_info.min_rx_bufsize) {
971 PMD_DEBUG_TRACE("%s mbuf_data_room_size %d < %d "
972 "(RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)"
976 (int)(RTE_PKTMBUF_HEADROOM +
977 dev_info.min_rx_bufsize),
978 (int)RTE_PKTMBUF_HEADROOM,
979 (int)dev_info.min_rx_bufsize);
983 ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
984 socket_id, rx_conf, mp);
986 if (!dev->data->min_rx_buf_size ||
987 dev->data->min_rx_buf_size > mbp_buf_size)
988 dev->data->min_rx_buf_size = mbp_buf_size;
995 rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
996 uint16_t nb_tx_desc, unsigned int socket_id,
997 const struct rte_eth_txconf *tx_conf)
999 struct rte_eth_dev *dev;
1001 /* This function is only safe when called from the primary process
1002 * in a multi-process setup*/
1003 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
1005 if (port_id >= RTE_MAX_ETHPORTS || port_id >= nb_ports) {
1006 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1009 dev = &rte_eth_devices[port_id];
1010 if (tx_queue_id >= dev->data->nb_tx_queues) {
1011 PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
1015 if (dev->data->dev_started) {
1017 "port %d must be stopped to allow configuration\n", port_id);
1021 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_setup, -ENOTSUP);
1022 return (*dev->dev_ops->tx_queue_setup)(dev, tx_queue_id, nb_tx_desc,
1023 socket_id, tx_conf);
1027 rte_eth_promiscuous_enable(uint8_t port_id)
1029 struct rte_eth_dev *dev;
1031 if (port_id >= nb_ports) {
1032 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1035 dev = &rte_eth_devices[port_id];
1037 FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_enable);
1038 (*dev->dev_ops->promiscuous_enable)(dev);
1039 dev->data->promiscuous = 1;
1043 rte_eth_promiscuous_disable(uint8_t port_id)
1045 struct rte_eth_dev *dev;
1047 if (port_id >= nb_ports) {
1048 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1051 dev = &rte_eth_devices[port_id];
1053 FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_disable);
1054 dev->data->promiscuous = 0;
1055 (*dev->dev_ops->promiscuous_disable)(dev);
1059 rte_eth_promiscuous_get(uint8_t port_id)
1061 struct rte_eth_dev *dev;
1063 if (port_id >= nb_ports) {
1064 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1068 dev = &rte_eth_devices[port_id];
1069 return dev->data->promiscuous;
1073 rte_eth_allmulticast_enable(uint8_t port_id)
1075 struct rte_eth_dev *dev;
1077 if (port_id >= nb_ports) {
1078 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1081 dev = &rte_eth_devices[port_id];
1083 FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_enable);
1084 (*dev->dev_ops->allmulticast_enable)(dev);
1085 dev->data->all_multicast = 1;
1089 rte_eth_allmulticast_disable(uint8_t port_id)
1091 struct rte_eth_dev *dev;
1093 if (port_id >= nb_ports) {
1094 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1097 dev = &rte_eth_devices[port_id];
1099 FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_disable);
1100 dev->data->all_multicast = 0;
1101 (*dev->dev_ops->allmulticast_disable)(dev);
1105 rte_eth_allmulticast_get(uint8_t port_id)
1107 struct rte_eth_dev *dev;
1109 if (port_id >= nb_ports) {
1110 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1114 dev = &rte_eth_devices[port_id];
1115 return dev->data->all_multicast;
1119 rte_eth_dev_atomic_read_link_status(struct rte_eth_dev *dev,
1120 struct rte_eth_link *link)
1122 struct rte_eth_link *dst = link;
1123 struct rte_eth_link *src = &(dev->data->dev_link);
1125 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
1126 *(uint64_t *)src) == 0)
1133 rte_eth_link_get(uint8_t port_id, struct rte_eth_link *eth_link)
1135 struct rte_eth_dev *dev;
1137 if (port_id >= nb_ports) {
1138 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1141 dev = &rte_eth_devices[port_id];
1143 if (dev->data->dev_conf.intr_conf.lsc != 0)
1144 rte_eth_dev_atomic_read_link_status(dev, eth_link);
1146 FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
1147 (*dev->dev_ops->link_update)(dev, 1);
1148 *eth_link = dev->data->dev_link;
1153 rte_eth_link_get_nowait(uint8_t port_id, struct rte_eth_link *eth_link)
1155 struct rte_eth_dev *dev;
1157 if (port_id >= nb_ports) {
1158 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1161 dev = &rte_eth_devices[port_id];
1163 if (dev->data->dev_conf.intr_conf.lsc != 0)
1164 rte_eth_dev_atomic_read_link_status(dev, eth_link);
1166 FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
1167 (*dev->dev_ops->link_update)(dev, 0);
1168 *eth_link = dev->data->dev_link;
1173 rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats)
1175 struct rte_eth_dev *dev;
1177 if (port_id >= nb_ports) {
1178 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1181 dev = &rte_eth_devices[port_id];
1182 memset(stats, 0, sizeof(*stats));
1184 FUNC_PTR_OR_RET(*dev->dev_ops->stats_get);
1185 (*dev->dev_ops->stats_get)(dev, stats);
1186 stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
1190 rte_eth_stats_reset(uint8_t port_id)
1192 struct rte_eth_dev *dev;
1194 if (port_id >= nb_ports) {
1195 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1198 dev = &rte_eth_devices[port_id];
1200 FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);
1201 (*dev->dev_ops->stats_reset)(dev);
1206 set_queue_stats_mapping(uint8_t port_id, uint16_t queue_id, uint8_t stat_idx,
1209 struct rte_eth_dev *dev;
1211 if (port_id >= nb_ports) {
1212 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1215 dev = &rte_eth_devices[port_id];
1217 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_stats_mapping_set, -ENOTSUP);
1218 return (*dev->dev_ops->queue_stats_mapping_set)
1219 (dev, queue_id, stat_idx, is_rx);
1224 rte_eth_dev_set_tx_queue_stats_mapping(uint8_t port_id, uint16_t tx_queue_id,
1227 return set_queue_stats_mapping(port_id, tx_queue_id, stat_idx,
1233 rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
1236 return set_queue_stats_mapping(port_id, rx_queue_id, stat_idx,
1242 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
1244 struct rte_eth_dev *dev;
1246 if (port_id >= nb_ports) {
1247 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1250 dev = &rte_eth_devices[port_id];
1252 /* Default device offload capabilities to zero */
1253 dev_info->rx_offload_capa = 0;
1254 dev_info->tx_offload_capa = 0;
1255 dev_info->if_index = 0;
1256 FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
1257 (*dev->dev_ops->dev_infos_get)(dev, dev_info);
1258 dev_info->pci_dev = dev->pci_dev;
1260 dev_info->driver_name = dev->driver->pci_drv.name;
1264 rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr)
1266 struct rte_eth_dev *dev;
1268 if (port_id >= nb_ports) {
1269 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1272 dev = &rte_eth_devices[port_id];
1273 ether_addr_copy(&dev->data->mac_addrs[0], mac_addr);
1278 rte_eth_dev_get_mtu(uint8_t port_id, uint16_t *mtu)
1280 struct rte_eth_dev *dev;
1282 if (port_id >= nb_ports) {
1283 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1287 dev = &rte_eth_devices[port_id];
1288 *mtu = dev->data->mtu;
1293 rte_eth_dev_set_mtu(uint8_t port_id, uint16_t mtu)
1296 struct rte_eth_dev *dev;
1298 if (port_id >= nb_ports) {
1299 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1303 dev = &rte_eth_devices[port_id];
1304 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mtu_set, -ENOTSUP);
1306 ret = (*dev->dev_ops->mtu_set)(dev, mtu);
1308 dev->data->mtu = mtu;
1314 rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t vlan_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);
1322 dev = &rte_eth_devices[port_id];
1323 if (! (dev->data->dev_conf.rxmode.hw_vlan_filter)) {
1324 PMD_DEBUG_TRACE("port %d: vlan-filtering disabled\n", port_id);
1328 if (vlan_id > 4095) {
1329 PMD_DEBUG_TRACE("(port_id=%d) invalid vlan_id=%u > 4095\n",
1330 port_id, (unsigned) vlan_id);
1333 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_filter_set, -ENOTSUP);
1334 (*dev->dev_ops->vlan_filter_set)(dev, vlan_id, on);
1339 rte_eth_dev_set_vlan_strip_on_queue(uint8_t port_id, uint16_t rx_queue_id, int on)
1341 struct rte_eth_dev *dev;
1343 if (port_id >= nb_ports) {
1344 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1348 dev = &rte_eth_devices[port_id];
1349 if (rx_queue_id >= dev->data->nb_rx_queues) {
1350 PMD_DEBUG_TRACE("Invalid rx_queue_id=%d\n", port_id);
1354 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
1355 (*dev->dev_ops->vlan_strip_queue_set)(dev, rx_queue_id, on);
1361 rte_eth_dev_set_vlan_ether_type(uint8_t port_id, uint16_t tpid)
1363 struct rte_eth_dev *dev;
1365 if (port_id >= nb_ports) {
1366 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1370 dev = &rte_eth_devices[port_id];
1371 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_tpid_set, -ENOTSUP);
1372 (*dev->dev_ops->vlan_tpid_set)(dev, tpid);
1378 rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask)
1380 struct rte_eth_dev *dev;
1385 if (port_id >= nb_ports) {
1386 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1390 dev = &rte_eth_devices[port_id];
1392 /*check which option changed by application*/
1393 cur = !!(offload_mask & ETH_VLAN_STRIP_OFFLOAD);
1394 org = !!(dev->data->dev_conf.rxmode.hw_vlan_strip);
1396 dev->data->dev_conf.rxmode.hw_vlan_strip = (uint8_t)cur;
1397 mask |= ETH_VLAN_STRIP_MASK;
1400 cur = !!(offload_mask & ETH_VLAN_FILTER_OFFLOAD);
1401 org = !!(dev->data->dev_conf.rxmode.hw_vlan_filter);
1403 dev->data->dev_conf.rxmode.hw_vlan_filter = (uint8_t)cur;
1404 mask |= ETH_VLAN_FILTER_MASK;
1407 cur = !!(offload_mask & ETH_VLAN_EXTEND_OFFLOAD);
1408 org = !!(dev->data->dev_conf.rxmode.hw_vlan_extend);
1410 dev->data->dev_conf.rxmode.hw_vlan_extend = (uint8_t)cur;
1411 mask |= ETH_VLAN_EXTEND_MASK;
1418 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP);
1419 (*dev->dev_ops->vlan_offload_set)(dev, mask);
1425 rte_eth_dev_get_vlan_offload(uint8_t port_id)
1427 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.rxmode.hw_vlan_strip)
1438 ret |= ETH_VLAN_STRIP_OFFLOAD ;
1440 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
1441 ret |= ETH_VLAN_FILTER_OFFLOAD ;
1443 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
1444 ret |= ETH_VLAN_EXTEND_OFFLOAD ;
1450 rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on)
1452 struct rte_eth_dev *dev;
1454 if (port_id >= nb_ports) {
1455 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1458 dev = &rte_eth_devices[port_id];
1459 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_pvid_set, -ENOTSUP);
1460 (*dev->dev_ops->vlan_pvid_set)(dev, pvid, on);
1466 rte_eth_dev_fdir_add_signature_filter(uint8_t port_id,
1467 struct rte_fdir_filter *fdir_filter,
1470 struct rte_eth_dev *dev;
1472 if (port_id >= nb_ports) {
1473 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1477 dev = &rte_eth_devices[port_id];
1479 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
1480 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1481 port_id, dev->data->dev_conf.fdir_conf.mode);
1485 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1486 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1487 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1488 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1489 "None l4type, source & destinations ports " \
1490 "should be null!\n");
1494 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_add_signature_filter, -ENOTSUP);
1495 return (*dev->dev_ops->fdir_add_signature_filter)(dev, fdir_filter,
1500 rte_eth_dev_fdir_update_signature_filter(uint8_t port_id,
1501 struct rte_fdir_filter *fdir_filter,
1504 struct rte_eth_dev *dev;
1506 if (port_id >= nb_ports) {
1507 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1511 dev = &rte_eth_devices[port_id];
1513 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
1514 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1515 port_id, dev->data->dev_conf.fdir_conf.mode);
1519 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1520 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1521 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1522 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1523 "None l4type, source & destinations ports " \
1524 "should be null!\n");
1528 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_update_signature_filter, -ENOTSUP);
1529 return (*dev->dev_ops->fdir_update_signature_filter)(dev, fdir_filter,
1535 rte_eth_dev_fdir_remove_signature_filter(uint8_t port_id,
1536 struct rte_fdir_filter *fdir_filter)
1538 struct rte_eth_dev *dev;
1540 if (port_id >= nb_ports) {
1541 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1545 dev = &rte_eth_devices[port_id];
1547 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
1548 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1549 port_id, dev->data->dev_conf.fdir_conf.mode);
1553 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1554 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1555 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1556 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1557 "None l4type source & destinations ports " \
1558 "should be null!\n");
1562 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_signature_filter, -ENOTSUP);
1563 return (*dev->dev_ops->fdir_remove_signature_filter)(dev, fdir_filter);
1567 rte_eth_dev_fdir_get_infos(uint8_t port_id, struct rte_eth_fdir *fdir)
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];
1577 if (! (dev->data->dev_conf.fdir_conf.mode)) {
1578 PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
1582 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_infos_get, -ENOTSUP);
1584 (*dev->dev_ops->fdir_infos_get)(dev, fdir);
1589 rte_eth_dev_fdir_add_perfect_filter(uint8_t port_id,
1590 struct rte_fdir_filter *fdir_filter,
1591 uint16_t soft_id, uint8_t queue,
1594 struct rte_eth_dev *dev;
1596 if (port_id >= nb_ports) {
1597 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1601 dev = &rte_eth_devices[port_id];
1603 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
1604 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1605 port_id, dev->data->dev_conf.fdir_conf.mode);
1609 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1610 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1611 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1612 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1613 "None l4type, source & destinations ports " \
1614 "should be null!\n");
1618 /* For now IPv6 is not supported with perfect filter */
1619 if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
1622 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_add_perfect_filter, -ENOTSUP);
1623 return (*dev->dev_ops->fdir_add_perfect_filter)(dev, fdir_filter,
1629 rte_eth_dev_fdir_update_perfect_filter(uint8_t port_id,
1630 struct rte_fdir_filter *fdir_filter,
1631 uint16_t soft_id, uint8_t queue,
1634 struct rte_eth_dev *dev;
1636 if (port_id >= nb_ports) {
1637 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1641 dev = &rte_eth_devices[port_id];
1643 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
1644 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1645 port_id, dev->data->dev_conf.fdir_conf.mode);
1649 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1650 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1651 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1652 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1653 "None l4type, source & destinations ports " \
1654 "should be null!\n");
1658 /* For now IPv6 is not supported with perfect filter */
1659 if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
1662 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_update_perfect_filter, -ENOTSUP);
1663 return (*dev->dev_ops->fdir_update_perfect_filter)(dev, fdir_filter,
1664 soft_id, queue, drop);
1668 rte_eth_dev_fdir_remove_perfect_filter(uint8_t port_id,
1669 struct rte_fdir_filter *fdir_filter,
1672 struct rte_eth_dev *dev;
1674 if (port_id >= nb_ports) {
1675 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1679 dev = &rte_eth_devices[port_id];
1681 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
1682 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1683 port_id, dev->data->dev_conf.fdir_conf.mode);
1687 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1688 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1689 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1690 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1691 "None l4type, source & destinations ports " \
1692 "should be null!\n");
1696 /* For now IPv6 is not supported with perfect filter */
1697 if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
1700 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_perfect_filter, -ENOTSUP);
1701 return (*dev->dev_ops->fdir_remove_perfect_filter)(dev, fdir_filter,
1706 rte_eth_dev_fdir_set_masks(uint8_t port_id, struct rte_fdir_masks *fdir_mask)
1708 struct rte_eth_dev *dev;
1710 if (port_id >= nb_ports) {
1711 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1715 dev = &rte_eth_devices[port_id];
1716 if (! (dev->data->dev_conf.fdir_conf.mode)) {
1717 PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
1721 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_set_masks, -ENOTSUP);
1722 return (*dev->dev_ops->fdir_set_masks)(dev, fdir_mask);
1726 rte_eth_dev_flow_ctrl_get(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
1728 struct rte_eth_dev *dev;
1730 if (port_id >= nb_ports) {
1731 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1735 dev = &rte_eth_devices[port_id];
1736 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_get, -ENOTSUP);
1737 memset(fc_conf, 0, sizeof(*fc_conf));
1738 return (*dev->dev_ops->flow_ctrl_get)(dev, fc_conf);
1742 rte_eth_dev_flow_ctrl_set(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
1744 struct rte_eth_dev *dev;
1746 if (port_id >= nb_ports) {
1747 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1751 if ((fc_conf->send_xon != 0) && (fc_conf->send_xon != 1)) {
1752 PMD_DEBUG_TRACE("Invalid send_xon, only 0/1 allowed\n");
1756 dev = &rte_eth_devices[port_id];
1757 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_set, -ENOTSUP);
1758 return (*dev->dev_ops->flow_ctrl_set)(dev, fc_conf);
1762 rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id, struct rte_eth_pfc_conf *pfc_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 (pfc_conf->priority > (ETH_DCB_NUM_USER_PRIORITIES - 1)) {
1772 PMD_DEBUG_TRACE("Invalid priority, only 0-7 allowed\n");
1776 dev = &rte_eth_devices[port_id];
1777 /* High water, low water validation are device specific */
1778 if (*dev->dev_ops->priority_flow_ctrl_set)
1779 return (*dev->dev_ops->priority_flow_ctrl_set)(dev, pfc_conf);
1784 rte_eth_dev_rss_reta_update(uint8_t port_id, struct rte_eth_rss_reta *reta_conf)
1786 struct rte_eth_dev *dev;
1790 if (port_id >= nb_ports) {
1791 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1795 /* Invalid mask bit(s) setting */
1796 if ((reta_conf->mask_lo == 0) && (reta_conf->mask_hi == 0)) {
1797 PMD_DEBUG_TRACE("Invalid update mask bits for port=%d\n",port_id);
1801 dev = &rte_eth_devices[port_id];
1802 max_rxq = (dev->data->nb_rx_queues <= ETH_RSS_RETA_MAX_QUEUE) ?
1803 dev->data->nb_rx_queues : ETH_RSS_RETA_MAX_QUEUE;
1804 if (reta_conf->mask_lo != 0) {
1805 for (i = 0; i < ETH_RSS_RETA_NUM_ENTRIES/2; i++) {
1806 if ((reta_conf->mask_lo & (1ULL << i)) &&
1807 (reta_conf->reta[i] >= max_rxq)) {
1808 PMD_DEBUG_TRACE("RETA hash index output"
1809 "configration for port=%d,invalid"
1810 "queue=%d\n",port_id,reta_conf->reta[i]);
1817 if (reta_conf->mask_hi != 0) {
1818 for (i = 0; i< ETH_RSS_RETA_NUM_ENTRIES/2; i++) {
1819 j = (uint8_t)(i + ETH_RSS_RETA_NUM_ENTRIES/2);
1821 /* Check if the max entry >= 128 */
1822 if ((reta_conf->mask_hi & (1ULL << i)) &&
1823 (reta_conf->reta[j] >= max_rxq)) {
1824 PMD_DEBUG_TRACE("RETA hash index output"
1825 "configration for port=%d,invalid"
1826 "queue=%d\n",port_id,reta_conf->reta[j]);
1833 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_update, -ENOTSUP);
1834 return (*dev->dev_ops->reta_update)(dev, reta_conf);
1838 rte_eth_dev_rss_reta_query(uint8_t port_id, struct rte_eth_rss_reta *reta_conf)
1840 struct rte_eth_dev *dev;
1842 if (port_id >= nb_ports) {
1843 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1847 if((reta_conf->mask_lo == 0) && (reta_conf->mask_hi == 0)) {
1848 PMD_DEBUG_TRACE("Invalid update mask bits for the port=%d\n",port_id);
1852 dev = &rte_eth_devices[port_id];
1853 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_query, -ENOTSUP);
1854 return (*dev->dev_ops->reta_query)(dev, reta_conf);
1858 rte_eth_dev_rss_hash_update(uint8_t port_id, struct rte_eth_rss_conf *rss_conf)
1860 struct rte_eth_dev *dev;
1861 uint16_t rss_hash_protos;
1863 if (port_id >= nb_ports) {
1864 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1867 rss_hash_protos = rss_conf->rss_hf;
1868 if ((rss_hash_protos != 0) &&
1869 ((rss_hash_protos & ETH_RSS_PROTO_MASK) == 0)) {
1870 PMD_DEBUG_TRACE("Invalid rss_hash_protos=0x%x\n",
1874 dev = &rte_eth_devices[port_id];
1875 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP);
1876 return (*dev->dev_ops->rss_hash_update)(dev, rss_conf);
1880 rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
1881 struct rte_eth_rss_conf *rss_conf)
1883 struct rte_eth_dev *dev;
1885 if (port_id >= nb_ports) {
1886 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1889 dev = &rte_eth_devices[port_id];
1890 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
1891 return (*dev->dev_ops->rss_hash_conf_get)(dev, rss_conf);
1895 rte_eth_led_on(uint8_t port_id)
1897 struct rte_eth_dev *dev;
1899 if (port_id >= nb_ports) {
1900 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1904 dev = &rte_eth_devices[port_id];
1905 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_on, -ENOTSUP);
1906 return ((*dev->dev_ops->dev_led_on)(dev));
1910 rte_eth_led_off(uint8_t port_id)
1912 struct rte_eth_dev *dev;
1914 if (port_id >= nb_ports) {
1915 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1919 dev = &rte_eth_devices[port_id];
1920 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_off, -ENOTSUP);
1921 return ((*dev->dev_ops->dev_led_off)(dev));
1925 * Returns index into MAC address array of addr. Use 00:00:00:00:00:00 to find
1929 get_mac_addr_index(uint8_t port_id, struct ether_addr *addr)
1931 struct rte_eth_dev_info dev_info;
1932 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
1935 rte_eth_dev_info_get(port_id, &dev_info);
1937 for (i = 0; i < dev_info.max_mac_addrs; i++)
1938 if (memcmp(addr, &dev->data->mac_addrs[i], ETHER_ADDR_LEN) == 0)
1944 static struct ether_addr null_mac_addr = {{0, 0, 0, 0, 0, 0}};
1947 rte_eth_dev_mac_addr_add(uint8_t port_id, struct ether_addr *addr,
1950 struct rte_eth_dev *dev;
1954 if (port_id >= nb_ports) {
1955 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1958 dev = &rte_eth_devices[port_id];
1959 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
1961 if (is_zero_ether_addr(addr)) {
1962 PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
1966 if (pool >= ETH_64_POOLS) {
1967 PMD_DEBUG_TRACE("pool id must be 0-%d\n",ETH_64_POOLS - 1);
1971 index = get_mac_addr_index(port_id, addr);
1973 index = get_mac_addr_index(port_id, &null_mac_addr);
1975 PMD_DEBUG_TRACE("port %d: MAC address array full\n",
1980 pool_mask = dev->data->mac_pool_sel[index];
1982 /* Check if both MAC address and pool is alread there, and do nothing */
1983 if (pool_mask & (1ULL << pool))
1988 (*dev->dev_ops->mac_addr_add)(dev, addr, index, pool);
1990 /* Update address in NIC data structure */
1991 ether_addr_copy(addr, &dev->data->mac_addrs[index]);
1993 /* Update pool bitmap in NIC data structure */
1994 dev->data->mac_pool_sel[index] |= (1ULL << pool);
2000 rte_eth_dev_mac_addr_remove(uint8_t port_id, struct ether_addr *addr)
2002 struct rte_eth_dev *dev;
2005 if (port_id >= nb_ports) {
2006 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2009 dev = &rte_eth_devices[port_id];
2010 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
2012 index = get_mac_addr_index(port_id, addr);
2014 PMD_DEBUG_TRACE("port %d: Cannot remove default MAC address\n", port_id);
2015 return (-EADDRINUSE);
2016 } else if (index < 0)
2017 return 0; /* Do nothing if address wasn't found */
2020 (*dev->dev_ops->mac_addr_remove)(dev, index);
2022 /* Update address in NIC data structure */
2023 ether_addr_copy(&null_mac_addr, &dev->data->mac_addrs[index]);
2029 rte_eth_dev_set_vf_rxmode(uint8_t port_id, uint16_t vf,
2030 uint16_t rx_mode, uint8_t on)
2033 struct rte_eth_dev *dev;
2034 struct rte_eth_dev_info dev_info;
2036 if (port_id >= nb_ports) {
2037 PMD_DEBUG_TRACE("set VF RX mode:Invalid port_id=%d\n",
2042 dev = &rte_eth_devices[port_id];
2043 rte_eth_dev_info_get(port_id, &dev_info);
2045 num_vfs = dev_info.max_vfs;
2048 PMD_DEBUG_TRACE("set VF RX mode:invalid VF id %d\n", vf);
2053 PMD_DEBUG_TRACE("set VF RX mode:mode mask ca not be zero\n");
2056 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx_mode, -ENOTSUP);
2057 return (*dev->dev_ops->set_vf_rx_mode)(dev, vf, rx_mode, on);
2061 * Returns index into MAC address array of addr. Use 00:00:00:00:00:00 to find
2065 get_hash_mac_addr_index(uint8_t port_id, struct ether_addr *addr)
2067 struct rte_eth_dev_info dev_info;
2068 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2071 rte_eth_dev_info_get(port_id, &dev_info);
2072 if (!dev->data->hash_mac_addrs)
2075 for (i = 0; i < dev_info.max_hash_mac_addrs; i++)
2076 if (memcmp(addr, &dev->data->hash_mac_addrs[i],
2077 ETHER_ADDR_LEN) == 0)
2084 rte_eth_dev_uc_hash_table_set(uint8_t port_id, struct ether_addr *addr,
2089 struct rte_eth_dev *dev;
2091 if (port_id >= nb_ports) {
2092 PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=%d\n",
2097 dev = &rte_eth_devices[port_id];
2098 if (is_zero_ether_addr(addr)) {
2099 PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
2104 index = get_hash_mac_addr_index(port_id, addr);
2105 /* Check if it's already there, and do nothing */
2106 if ((index >= 0) && (on))
2111 PMD_DEBUG_TRACE("port %d: the MAC address was not"
2112 "set in UTA\n", port_id);
2116 index = get_hash_mac_addr_index(port_id, &null_mac_addr);
2118 PMD_DEBUG_TRACE("port %d: MAC address array full\n",
2124 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_hash_table_set, -ENOTSUP);
2125 ret = (*dev->dev_ops->uc_hash_table_set)(dev, addr, on);
2127 /* Update address in NIC data structure */
2129 ether_addr_copy(addr,
2130 &dev->data->hash_mac_addrs[index]);
2132 ether_addr_copy(&null_mac_addr,
2133 &dev->data->hash_mac_addrs[index]);
2140 rte_eth_dev_uc_all_hash_table_set(uint8_t port_id, uint8_t on)
2142 struct rte_eth_dev *dev;
2144 if (port_id >= nb_ports) {
2145 PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=%d\n",
2150 dev = &rte_eth_devices[port_id];
2152 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_all_hash_table_set, -ENOTSUP);
2153 return (*dev->dev_ops->uc_all_hash_table_set)(dev, on);
2157 rte_eth_dev_set_vf_rx(uint8_t port_id,uint16_t vf, uint8_t on)
2160 struct rte_eth_dev *dev;
2161 struct rte_eth_dev_info dev_info;
2163 if (port_id >= nb_ports) {
2164 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2168 dev = &rte_eth_devices[port_id];
2169 rte_eth_dev_info_get(port_id, &dev_info);
2171 num_vfs = dev_info.max_vfs;
2174 PMD_DEBUG_TRACE("port %d: invalid vf id\n", port_id);
2178 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx, -ENOTSUP);
2179 return (*dev->dev_ops->set_vf_rx)(dev, vf,on);
2183 rte_eth_dev_set_vf_tx(uint8_t port_id,uint16_t vf, uint8_t on)
2186 struct rte_eth_dev *dev;
2187 struct rte_eth_dev_info dev_info;
2189 if (port_id >= nb_ports) {
2190 PMD_DEBUG_TRACE("set pool tx:Invalid port_id=%d\n", port_id);
2194 dev = &rte_eth_devices[port_id];
2195 rte_eth_dev_info_get(port_id, &dev_info);
2197 num_vfs = dev_info.max_vfs;
2200 PMD_DEBUG_TRACE("set pool tx:invalid pool id=%d\n", vf);
2204 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_tx, -ENOTSUP);
2205 return (*dev->dev_ops->set_vf_tx)(dev, vf,on);
2209 rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, uint16_t vlan_id,
2210 uint64_t vf_mask,uint8_t vlan_on)
2212 struct rte_eth_dev *dev;
2214 if (port_id >= nb_ports) {
2215 PMD_DEBUG_TRACE("VF VLAN filter:invalid port id=%d\n",
2219 dev = &rte_eth_devices[port_id];
2221 if(vlan_id > ETHER_MAX_VLAN_ID)
2223 PMD_DEBUG_TRACE("VF VLAN filter:invalid VLAN id=%d\n",
2229 PMD_DEBUG_TRACE("VF VLAN filter:pool_mask can not be 0\n");
2233 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_filter, -ENOTSUP);
2234 return (*dev->dev_ops->set_vf_vlan_filter)(dev, vlan_id,
2238 int rte_eth_set_queue_rate_limit(uint8_t port_id, uint16_t queue_idx,
2241 struct rte_eth_dev *dev;
2242 struct rte_eth_dev_info dev_info;
2243 struct rte_eth_link link;
2245 if (port_id >= nb_ports) {
2246 PMD_DEBUG_TRACE("set queue rate limit:invalid port id=%d\n",
2251 dev = &rte_eth_devices[port_id];
2252 rte_eth_dev_info_get(port_id, &dev_info);
2253 link = dev->data->dev_link;
2255 if (queue_idx > dev_info.max_tx_queues) {
2256 PMD_DEBUG_TRACE("set queue rate limit:port %d: "
2257 "invalid queue id=%d\n", port_id, queue_idx);
2261 if (tx_rate > link.link_speed) {
2262 PMD_DEBUG_TRACE("set queue rate limit:invalid tx_rate=%d, "
2263 "bigger than link speed= %d\n",
2264 tx_rate, link.link_speed);
2268 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_queue_rate_limit, -ENOTSUP);
2269 return (*dev->dev_ops->set_queue_rate_limit)(dev, queue_idx, tx_rate);
2272 int rte_eth_set_vf_rate_limit(uint8_t port_id, uint16_t vf, uint16_t tx_rate,
2275 struct rte_eth_dev *dev;
2276 struct rte_eth_dev_info dev_info;
2277 struct rte_eth_link link;
2282 if (port_id >= nb_ports) {
2283 PMD_DEBUG_TRACE("set VF rate limit:invalid port id=%d\n",
2288 dev = &rte_eth_devices[port_id];
2289 rte_eth_dev_info_get(port_id, &dev_info);
2290 link = dev->data->dev_link;
2292 if (vf > dev_info.max_vfs) {
2293 PMD_DEBUG_TRACE("set VF rate limit:port %d: "
2294 "invalid vf id=%d\n", port_id, vf);
2298 if (tx_rate > link.link_speed) {
2299 PMD_DEBUG_TRACE("set VF rate limit:invalid tx_rate=%d, "
2300 "bigger than link speed= %d\n",
2301 tx_rate, link.link_speed);
2305 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rate_limit, -ENOTSUP);
2306 return (*dev->dev_ops->set_vf_rate_limit)(dev, vf, tx_rate, q_msk);
2310 rte_eth_mirror_rule_set(uint8_t port_id,
2311 struct rte_eth_vmdq_mirror_conf *mirror_conf,
2312 uint8_t rule_id, uint8_t on)
2314 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2316 if (port_id >= nb_ports) {
2317 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2321 if (mirror_conf->rule_type_mask == 0) {
2322 PMD_DEBUG_TRACE("mirror rule type can not be 0.\n");
2326 if (mirror_conf->dst_pool >= ETH_64_POOLS) {
2327 PMD_DEBUG_TRACE("Invalid dst pool, pool id must"
2328 "be 0-%d\n",ETH_64_POOLS - 1);
2332 if ((mirror_conf->rule_type_mask & ETH_VMDQ_POOL_MIRROR) &&
2333 (mirror_conf->pool_mask == 0)) {
2334 PMD_DEBUG_TRACE("Invalid mirror pool, pool mask can not"
2339 if(rule_id >= ETH_VMDQ_NUM_MIRROR_RULE)
2341 PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
2342 ETH_VMDQ_NUM_MIRROR_RULE - 1);
2346 dev = &rte_eth_devices[port_id];
2347 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_set, -ENOTSUP);
2349 return (*dev->dev_ops->mirror_rule_set)(dev, mirror_conf, rule_id, on);
2353 rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)
2355 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2357 if (port_id >= nb_ports) {
2358 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2362 if(rule_id >= ETH_VMDQ_NUM_MIRROR_RULE)
2364 PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
2365 ETH_VMDQ_NUM_MIRROR_RULE-1);
2369 dev = &rte_eth_devices[port_id];
2370 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_reset, -ENOTSUP);
2372 return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
2375 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
2377 rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
2378 struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
2380 struct rte_eth_dev *dev;
2382 if (port_id >= nb_ports) {
2383 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2386 dev = &rte_eth_devices[port_id];
2387 FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, -ENOTSUP);
2388 if (queue_id >= dev->data->nb_rx_queues) {
2389 PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
2392 return (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
2397 rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
2398 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
2400 struct rte_eth_dev *dev;
2402 if (port_id >= nb_ports) {
2403 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2406 dev = &rte_eth_devices[port_id];
2408 FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, -ENOTSUP);
2409 if (queue_id >= dev->data->nb_tx_queues) {
2410 PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
2413 return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id],
2418 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
2420 struct rte_eth_dev *dev;
2422 if (port_id >= nb_ports) {
2423 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2426 dev = &rte_eth_devices[port_id];
2427 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
2428 return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
2432 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
2434 struct rte_eth_dev *dev;
2436 if (port_id >= nb_ports) {
2437 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2440 dev = &rte_eth_devices[port_id];
2441 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
2442 return (*dev->dev_ops->rx_descriptor_done)( \
2443 dev->data->rx_queues[queue_id], offset);
2448 rte_eth_dev_callback_register(uint8_t port_id,
2449 enum rte_eth_event_type event,
2450 rte_eth_dev_cb_fn cb_fn, void *cb_arg)
2452 struct rte_eth_dev *dev;
2453 struct rte_eth_dev_callback *user_cb;
2457 if (port_id >= nb_ports) {
2458 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2462 dev = &rte_eth_devices[port_id];
2463 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2465 TAILQ_FOREACH(user_cb, &(dev->callbacks), next) {
2466 if (user_cb->cb_fn == cb_fn &&
2467 user_cb->cb_arg == cb_arg &&
2468 user_cb->event == event) {
2473 /* create a new callback. */
2474 if (user_cb == NULL && (user_cb = rte_zmalloc("INTR_USER_CALLBACK",
2475 sizeof(struct rte_eth_dev_callback), 0)) != NULL) {
2476 user_cb->cb_fn = cb_fn;
2477 user_cb->cb_arg = cb_arg;
2478 user_cb->event = event;
2479 TAILQ_INSERT_TAIL(&(dev->callbacks), user_cb, next);
2482 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2483 return ((user_cb == NULL) ? -ENOMEM : 0);
2487 rte_eth_dev_callback_unregister(uint8_t port_id,
2488 enum rte_eth_event_type event,
2489 rte_eth_dev_cb_fn cb_fn, void *cb_arg)
2492 struct rte_eth_dev *dev;
2493 struct rte_eth_dev_callback *cb, *next;
2497 if (port_id >= nb_ports) {
2498 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2502 dev = &rte_eth_devices[port_id];
2503 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2506 for (cb = TAILQ_FIRST(&dev->callbacks); cb != NULL; cb = next) {
2508 next = TAILQ_NEXT(cb, next);
2510 if (cb->cb_fn != cb_fn || cb->event != event ||
2511 (cb->cb_arg != (void *)-1 &&
2512 cb->cb_arg != cb_arg))
2516 * if this callback is not executing right now,
2519 if (cb->active == 0) {
2520 TAILQ_REMOVE(&(dev->callbacks), cb, next);
2527 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2532 _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
2533 enum rte_eth_event_type event)
2535 struct rte_eth_dev_callback *cb_lst;
2536 struct rte_eth_dev_callback dev_cb;
2538 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2539 TAILQ_FOREACH(cb_lst, &(dev->callbacks), next) {
2540 if (cb_lst->cb_fn == NULL || cb_lst->event != event)
2544 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2545 dev_cb.cb_fn(dev->data->port_id, dev_cb.event,
2547 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2550 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2552 #ifdef RTE_NIC_BYPASS
2553 int rte_eth_dev_bypass_init(uint8_t port_id)
2555 struct rte_eth_dev *dev;
2557 if (port_id >= nb_ports) {
2558 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2562 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2563 PMD_DEBUG_TRACE("Invalid port device\n");
2567 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_init, -ENOTSUP);
2568 (*dev->dev_ops->bypass_init)(dev);
2573 rte_eth_dev_bypass_state_show(uint8_t port_id, uint32_t *state)
2575 struct rte_eth_dev *dev;
2577 if (port_id >= nb_ports) {
2578 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2582 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2583 PMD_DEBUG_TRACE("Invalid port device\n");
2586 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
2587 (*dev->dev_ops->bypass_state_show)(dev, state);
2592 rte_eth_dev_bypass_state_set(uint8_t port_id, uint32_t *new_state)
2594 struct rte_eth_dev *dev;
2596 if (port_id >= nb_ports) {
2597 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2601 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2602 PMD_DEBUG_TRACE("Invalid port device\n");
2606 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_set, -ENOTSUP);
2607 (*dev->dev_ops->bypass_state_set)(dev, new_state);
2612 rte_eth_dev_bypass_event_show(uint8_t port_id, uint32_t event, uint32_t *state)
2614 struct rte_eth_dev *dev;
2616 if (port_id >= nb_ports) {
2617 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2621 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2622 PMD_DEBUG_TRACE("Invalid port device\n");
2626 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
2627 (*dev->dev_ops->bypass_event_show)(dev, event, state);
2632 rte_eth_dev_bypass_event_store(uint8_t port_id, uint32_t event, uint32_t state)
2634 struct rte_eth_dev *dev;
2636 if (port_id >= nb_ports) {
2637 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2641 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2642 PMD_DEBUG_TRACE("Invalid port device\n");
2646 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_event_set, -ENOTSUP);
2647 (*dev->dev_ops->bypass_event_set)(dev, event, state);
2652 rte_eth_dev_wd_timeout_store(uint8_t port_id, uint32_t timeout)
2654 struct rte_eth_dev *dev;
2656 if (port_id >= nb_ports) {
2657 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2661 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2662 PMD_DEBUG_TRACE("Invalid port device\n");
2666 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_set, -ENOTSUP);
2667 (*dev->dev_ops->bypass_wd_timeout_set)(dev, timeout);
2672 rte_eth_dev_bypass_ver_show(uint8_t port_id, uint32_t *ver)
2674 struct rte_eth_dev *dev;
2676 if (port_id >= nb_ports) {
2677 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2681 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2682 PMD_DEBUG_TRACE("Invalid port device\n");
2686 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_ver_show, -ENOTSUP);
2687 (*dev->dev_ops->bypass_ver_show)(dev, ver);
2692 rte_eth_dev_bypass_wd_timeout_show(uint8_t port_id, uint32_t *wd_timeout)
2694 struct rte_eth_dev *dev;
2696 if (port_id >= nb_ports) {
2697 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2701 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2702 PMD_DEBUG_TRACE("Invalid port device\n");
2706 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_show, -ENOTSUP);
2707 (*dev->dev_ops->bypass_wd_timeout_show)(dev, wd_timeout);
2712 rte_eth_dev_bypass_wd_reset(uint8_t port_id)
2714 struct rte_eth_dev *dev;
2716 if (port_id >= nb_ports) {
2717 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2721 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2722 PMD_DEBUG_TRACE("Invalid port device\n");
2726 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_reset, -ENOTSUP);
2727 (*dev->dev_ops->bypass_wd_reset)(dev);
2733 rte_eth_dev_add_syn_filter(uint8_t port_id,
2734 struct rte_syn_filter *filter, uint16_t rx_queue)
2736 struct rte_eth_dev *dev;
2738 if (port_id >= nb_ports) {
2739 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2743 dev = &rte_eth_devices[port_id];
2744 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_syn_filter, -ENOTSUP);
2745 return (*dev->dev_ops->add_syn_filter)(dev, filter, rx_queue);
2749 rte_eth_dev_remove_syn_filter(uint8_t port_id)
2751 struct rte_eth_dev *dev;
2753 if (port_id >= nb_ports) {
2754 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2758 dev = &rte_eth_devices[port_id];
2759 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_syn_filter, -ENOTSUP);
2760 return (*dev->dev_ops->remove_syn_filter)(dev);
2764 rte_eth_dev_get_syn_filter(uint8_t port_id,
2765 struct rte_syn_filter *filter, uint16_t *rx_queue)
2767 struct rte_eth_dev *dev;
2769 if (filter == NULL || rx_queue == NULL)
2772 if (port_id >= nb_ports) {
2773 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2777 dev = &rte_eth_devices[port_id];
2778 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_syn_filter, -ENOTSUP);
2779 return (*dev->dev_ops->get_syn_filter)(dev, filter, rx_queue);
2783 rte_eth_dev_add_ethertype_filter(uint8_t port_id, uint16_t index,
2784 struct rte_ethertype_filter *filter, uint16_t rx_queue)
2786 struct rte_eth_dev *dev;
2788 if (port_id >= nb_ports) {
2789 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2792 if (filter->ethertype == ETHER_TYPE_IPv4 ||
2793 filter->ethertype == ETHER_TYPE_IPv6){
2794 PMD_DEBUG_TRACE("IP and IPv6 are not supported"
2795 " in ethertype filter\n");
2798 dev = &rte_eth_devices[port_id];
2799 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_ethertype_filter, -ENOTSUP);
2800 return (*dev->dev_ops->add_ethertype_filter)(dev, index,
2805 rte_eth_dev_remove_ethertype_filter(uint8_t port_id, uint16_t index)
2807 struct rte_eth_dev *dev;
2809 if (port_id >= nb_ports) {
2810 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2814 dev = &rte_eth_devices[port_id];
2815 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_ethertype_filter, -ENOTSUP);
2816 return (*dev->dev_ops->remove_ethertype_filter)(dev, index);
2820 rte_eth_dev_get_ethertype_filter(uint8_t port_id, uint16_t index,
2821 struct rte_ethertype_filter *filter, uint16_t *rx_queue)
2823 struct rte_eth_dev *dev;
2825 if (filter == NULL || rx_queue == NULL)
2828 if (port_id >= nb_ports) {
2829 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2833 dev = &rte_eth_devices[port_id];
2834 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_ethertype_filter, -ENOTSUP);
2835 return (*dev->dev_ops->get_ethertype_filter)(dev, index,
2840 rte_eth_dev_add_2tuple_filter(uint8_t port_id, uint16_t index,
2841 struct rte_2tuple_filter *filter, uint16_t rx_queue)
2843 struct rte_eth_dev *dev;
2845 if (port_id >= nb_ports) {
2846 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2849 if (filter->protocol != IPPROTO_TCP &&
2850 filter->tcp_flags != 0){
2851 PMD_DEBUG_TRACE("tcp flags is 0x%x, but the protocol value"
2857 dev = &rte_eth_devices[port_id];
2858 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_2tuple_filter, -ENOTSUP);
2859 return (*dev->dev_ops->add_2tuple_filter)(dev, index, filter, rx_queue);
2863 rte_eth_dev_remove_2tuple_filter(uint8_t port_id, uint16_t index)
2865 struct rte_eth_dev *dev;
2867 if (port_id >= nb_ports) {
2868 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2872 dev = &rte_eth_devices[port_id];
2873 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_2tuple_filter, -ENOTSUP);
2874 return (*dev->dev_ops->remove_2tuple_filter)(dev, index);
2878 rte_eth_dev_get_2tuple_filter(uint8_t port_id, uint16_t index,
2879 struct rte_2tuple_filter *filter, uint16_t *rx_queue)
2881 struct rte_eth_dev *dev;
2883 if (filter == NULL || rx_queue == NULL)
2886 if (port_id >= nb_ports) {
2887 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2891 dev = &rte_eth_devices[port_id];
2892 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_2tuple_filter, -ENOTSUP);
2893 return (*dev->dev_ops->get_2tuple_filter)(dev, index, filter, rx_queue);
2897 rte_eth_dev_add_5tuple_filter(uint8_t port_id, uint16_t index,
2898 struct rte_5tuple_filter *filter, uint16_t rx_queue)
2900 struct rte_eth_dev *dev;
2902 if (port_id >= nb_ports) {
2903 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2907 if (filter->protocol != IPPROTO_TCP &&
2908 filter->tcp_flags != 0){
2909 PMD_DEBUG_TRACE("tcp flags is 0x%x, but the protocol value"
2915 dev = &rte_eth_devices[port_id];
2916 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_5tuple_filter, -ENOTSUP);
2917 return (*dev->dev_ops->add_5tuple_filter)(dev, index, filter, rx_queue);
2921 rte_eth_dev_remove_5tuple_filter(uint8_t port_id, uint16_t index)
2923 struct rte_eth_dev *dev;
2925 if (port_id >= nb_ports) {
2926 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2930 dev = &rte_eth_devices[port_id];
2931 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_5tuple_filter, -ENOTSUP);
2932 return (*dev->dev_ops->remove_5tuple_filter)(dev, index);
2936 rte_eth_dev_get_5tuple_filter(uint8_t port_id, uint16_t index,
2937 struct rte_5tuple_filter *filter, uint16_t *rx_queue)
2939 struct rte_eth_dev *dev;
2941 if (filter == NULL || rx_queue == NULL)
2944 if (port_id >= nb_ports) {
2945 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2949 dev = &rte_eth_devices[port_id];
2950 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_5tuple_filter, -ENOTSUP);
2951 return (*dev->dev_ops->get_5tuple_filter)(dev, index, filter,
2956 rte_eth_dev_add_flex_filter(uint8_t port_id, uint16_t index,
2957 struct rte_flex_filter *filter, uint16_t rx_queue)
2959 struct rte_eth_dev *dev;
2961 if (port_id >= nb_ports) {
2962 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2966 dev = &rte_eth_devices[port_id];
2967 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->add_flex_filter, -ENOTSUP);
2968 return (*dev->dev_ops->add_flex_filter)(dev, index, filter, rx_queue);
2972 rte_eth_dev_remove_flex_filter(uint8_t port_id, uint16_t index)
2974 struct rte_eth_dev *dev;
2976 if (port_id >= nb_ports) {
2977 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2981 dev = &rte_eth_devices[port_id];
2982 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->remove_flex_filter, -ENOTSUP);
2983 return (*dev->dev_ops->remove_flex_filter)(dev, index);
2987 rte_eth_dev_get_flex_filter(uint8_t port_id, uint16_t index,
2988 struct rte_flex_filter *filter, uint16_t *rx_queue)
2990 struct rte_eth_dev *dev;
2992 if (filter == NULL || rx_queue == NULL)
2995 if (port_id >= nb_ports) {
2996 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
3000 dev = &rte_eth_devices[port_id];
3001 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_flex_filter, -ENOTSUP);
3002 return (*dev->dev_ops->get_flex_filter)(dev, index, filter,