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>
45 #include <rte_byteorder.h>
47 #include <rte_debug.h>
48 #include <rte_interrupts.h>
50 #include <rte_memory.h>
51 #include <rte_memcpy.h>
52 #include <rte_memzone.h>
53 #include <rte_launch.h>
54 #include <rte_tailq.h>
56 #include <rte_per_lcore.h>
57 #include <rte_lcore.h>
58 #include <rte_atomic.h>
59 #include <rte_branch_prediction.h>
60 #include <rte_common.h>
62 #include <rte_mempool.h>
63 #include <rte_malloc.h>
65 #include <rte_errno.h>
66 #include <rte_spinlock.h>
68 #include "rte_ether.h"
69 #include "rte_ethdev.h"
71 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
72 #define PMD_DEBUG_TRACE(fmt, args...) do { \
73 RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args); \
76 #define PMD_DEBUG_TRACE(fmt, args...)
79 /* Macros for checking for restricting functions to primary instance only */
80 #define PROC_PRIMARY_OR_ERR_RET(retval) do { \
81 if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \
82 PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
86 #define PROC_PRIMARY_OR_RET() do { \
87 if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \
88 PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
93 /* Macros to check for invlaid function pointers in dev_ops structure */
94 #define FUNC_PTR_OR_ERR_RET(func, retval) do { \
95 if ((func) == NULL) { \
96 PMD_DEBUG_TRACE("Function not supported\n"); \
100 #define FUNC_PTR_OR_RET(func) do { \
101 if ((func) == NULL) { \
102 PMD_DEBUG_TRACE("Function not supported\n"); \
107 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
108 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
109 static struct rte_eth_dev_data *rte_eth_dev_data = NULL;
110 static uint8_t nb_ports = 0;
112 /* spinlock for eth device callbacks */
113 static rte_spinlock_t rte_eth_dev_cb_lock = RTE_SPINLOCK_INITIALIZER;
116 * The user application callback description.
118 * It contains callback address to be registered by user application,
119 * the pointer to the parameters for callback, and the event type.
121 struct rte_eth_dev_callback {
122 TAILQ_ENTRY(rte_eth_dev_callback) next; /**< Callbacks list */
123 rte_eth_dev_cb_fn cb_fn; /**< Callback address */
124 void *cb_arg; /**< Parameter for callback */
125 enum rte_eth_event_type event; /**< Interrupt event type */
126 uint32_t active; /**< Callback is executing */
135 rte_eth_dev_data_alloc(void)
137 const unsigned flags = 0;
138 const struct rte_memzone *mz;
140 if (rte_eal_process_type() == RTE_PROC_PRIMARY){
141 mz = rte_memzone_reserve(MZ_RTE_ETH_DEV_DATA,
142 RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data),
143 rte_socket_id(), flags);
145 mz = rte_memzone_lookup(MZ_RTE_ETH_DEV_DATA);
147 rte_panic("Cannot allocate memzone for ethernet port data\n");
149 rte_eth_dev_data = mz->addr;
150 if (rte_eal_process_type() == RTE_PROC_PRIMARY)
151 memset(rte_eth_dev_data, 0,
152 RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data));
156 rte_eth_dev_allocate(void)
158 struct rte_eth_dev *eth_dev;
160 if (nb_ports == RTE_MAX_ETHPORTS) {
161 PMD_DEBUG_TRACE("Reached maximum number of ethernet ports\n");
165 if (rte_eth_dev_data == NULL)
166 rte_eth_dev_data_alloc();
168 eth_dev = &rte_eth_devices[nb_ports];
169 eth_dev->data = &rte_eth_dev_data[nb_ports];
170 eth_dev->data->port_id = nb_ports++;
175 rte_eth_dev_init(struct rte_pci_driver *pci_drv,
176 struct rte_pci_device *pci_dev)
178 struct eth_driver *eth_drv;
179 struct rte_eth_dev *eth_dev;
182 eth_drv = (struct eth_driver *)pci_drv;
184 eth_dev = rte_eth_dev_allocate();
188 if (rte_eal_process_type() == RTE_PROC_PRIMARY){
189 eth_dev->data->dev_private = rte_zmalloc("ethdev private structure",
190 eth_drv->dev_private_size,
192 if (eth_dev->data->dev_private == NULL)
193 rte_panic("Cannot allocate memzone for private port data\n");
195 eth_dev->pci_dev = pci_dev;
196 eth_dev->driver = eth_drv;
197 eth_dev->data->rx_mbuf_alloc_failed = 0;
199 /* init user callbacks */
200 TAILQ_INIT(&(eth_dev->callbacks));
203 * Set the default maximum frame size.
205 eth_dev->data->max_frame_size = ETHER_MAX_LEN;
207 /* Invoke PMD device initialization function */
208 diag = (*eth_drv->eth_dev_init)(eth_drv, eth_dev);
212 PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x)"
213 " failed\n", pci_drv->name,
214 (unsigned) pci_dev->id.vendor_id,
215 (unsigned) pci_dev->id.device_id);
216 if (rte_eal_process_type() == RTE_PROC_PRIMARY)
217 rte_free(eth_dev->data->dev_private);
223 * Register an Ethernet [Poll Mode] driver.
225 * Function invoked by the initialization function of an Ethernet driver
226 * to simultaneously register itself as a PCI driver and as an Ethernet
228 * Invokes the rte_eal_pci_register() function to register the *pci_drv*
229 * structure embedded in the *eth_drv* structure, after having stored the
230 * address of the rte_eth_dev_init() function in the *devinit* field of
231 * the *pci_drv* structure.
232 * During the PCI probing phase, the rte_eth_dev_init() function is
233 * invoked for each PCI [Ethernet device] matching the embedded PCI
234 * identifiers provided by the driver.
237 rte_eth_driver_register(struct eth_driver *eth_drv)
239 eth_drv->pci_drv.devinit = rte_eth_dev_init;
240 rte_eal_pci_register(ð_drv->pci_drv);
244 rte_eth_dev_socket_id(uint8_t port_id)
246 if (port_id >= nb_ports)
248 return rte_eth_devices[port_id].pci_dev->numa_node;
252 rte_eth_dev_count(void)
258 rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
260 uint16_t old_nb_queues = dev->data->nb_rx_queues;
264 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
266 if (dev->data->rx_queues == NULL) {
267 dev->data->rx_queues = rte_zmalloc("ethdev->rx_queues",
268 sizeof(dev->data->rx_queues[0]) * nb_queues,
270 if (dev->data->rx_queues == NULL) {
271 dev->data->nb_rx_queues = 0;
275 rxq = dev->data->rx_queues;
277 for (i = nb_queues; i < old_nb_queues; i++)
278 (*dev->dev_ops->rx_queue_release)(rxq[i]);
279 rxq = rte_realloc(rxq, sizeof(rxq[0]) * nb_queues,
284 if (nb_queues > old_nb_queues)
285 memset(rxq + old_nb_queues, 0,
286 sizeof(rxq[0]) * (nb_queues - old_nb_queues));
288 dev->data->rx_queues = rxq;
291 dev->data->nb_rx_queues = nb_queues;
296 rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
298 uint16_t old_nb_queues = dev->data->nb_tx_queues;
302 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);
304 if (dev->data->tx_queues == NULL) {
305 dev->data->tx_queues = rte_zmalloc("ethdev->tx_queues",
306 sizeof(dev->data->tx_queues[0]) * nb_queues,
308 if (dev->data->tx_queues == NULL) {
309 dev->data->nb_tx_queues = 0;
313 txq = dev->data->tx_queues;
315 for (i = nb_queues; i < old_nb_queues; i++)
316 (*dev->dev_ops->tx_queue_release)(txq[i]);
317 txq = rte_realloc(txq, sizeof(txq[0]) * nb_queues,
322 if (nb_queues > old_nb_queues)
323 memset(txq + old_nb_queues, 0,
324 sizeof(txq[0]) * (nb_queues - old_nb_queues));
326 dev->data->tx_queues = txq;
329 dev->data->nb_tx_queues = nb_queues;
334 rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
335 const struct rte_eth_conf *dev_conf)
337 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
339 if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
340 /* check multi-queue mode */
341 if ((dev_conf->rxmode.mq_mode == ETH_MQ_RX_RSS) ||
342 (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) ||
343 (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB_RSS) ||
344 (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB)) {
345 /* SRIOV only works in VMDq enable mode */
346 PMD_DEBUG_TRACE("ethdev port_id=%hhu SRIOV active, "
347 "wrong VMDQ mq_mode rx %u tx %u\n",
349 dev_conf->rxmode.mq_mode,
350 dev_conf->txmode.mq_mode);
354 switch (dev_conf->rxmode.mq_mode) {
355 case ETH_MQ_RX_VMDQ_RSS:
356 case ETH_MQ_RX_VMDQ_DCB:
357 case ETH_MQ_RX_VMDQ_DCB_RSS:
358 /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
359 PMD_DEBUG_TRACE("ethdev port_id=%hhu SRIOV active, "
360 "unsupported VMDQ mq_mode rx %u\n",
361 port_id, dev_conf->rxmode.mq_mode);
363 default: /* ETH_MQ_RX_VMDQ_ONLY or ETH_MQ_RX_NONE */
364 /* if nothing mq mode configure, use default scheme */
365 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_ONLY;
366 if (RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool > 1)
367 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
371 switch (dev_conf->txmode.mq_mode) {
372 case ETH_MQ_TX_VMDQ_DCB:
373 /* DCB VMDQ in SRIOV mode, not implement yet */
374 PMD_DEBUG_TRACE("ethdev port_id=%hhu SRIOV active, "
375 "unsupported VMDQ mq_mode tx %u\n",
376 port_id, dev_conf->txmode.mq_mode);
378 default: /* ETH_MQ_TX_VMDQ_ONLY or ETH_MQ_TX_NONE */
379 /* if nothing mq mode configure, use default scheme */
380 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_ONLY;
381 if (RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool > 1)
382 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
386 /* check valid queue number */
387 if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
388 (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
389 PMD_DEBUG_TRACE("ethdev port_id=%d SRIOV active, "
390 "queue number must less equal to %d\n",
391 port_id, RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
395 /* For vmdb+dcb mode check our configuration before we go further */
396 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB) {
397 const struct rte_eth_vmdq_dcb_conf *conf;
399 if (nb_rx_q != ETH_VMDQ_DCB_NUM_QUEUES) {
400 PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_rx_q "
402 port_id, ETH_VMDQ_DCB_NUM_QUEUES);
405 conf = &(dev_conf->rx_adv_conf.vmdq_dcb_conf);
406 if (! (conf->nb_queue_pools == ETH_16_POOLS ||
407 conf->nb_queue_pools == ETH_32_POOLS)) {
408 PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
409 "nb_queue_pools must be %d or %d\n",
410 port_id, ETH_16_POOLS, ETH_32_POOLS);
414 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_VMDQ_DCB) {
415 const struct rte_eth_vmdq_dcb_tx_conf *conf;
417 if (nb_tx_q != ETH_VMDQ_DCB_NUM_QUEUES) {
418 PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_tx_q "
420 port_id, ETH_VMDQ_DCB_NUM_QUEUES);
423 conf = &(dev_conf->tx_adv_conf.vmdq_dcb_tx_conf);
424 if (! (conf->nb_queue_pools == ETH_16_POOLS ||
425 conf->nb_queue_pools == ETH_32_POOLS)) {
426 PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
427 "nb_queue_pools != %d or nb_queue_pools "
429 port_id, ETH_16_POOLS, ETH_32_POOLS);
434 /* For DCB mode check our configuration before we go further */
435 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) {
436 const struct rte_eth_dcb_rx_conf *conf;
438 if (nb_rx_q != ETH_DCB_NUM_QUEUES) {
439 PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_rx_q "
441 port_id, ETH_DCB_NUM_QUEUES);
444 conf = &(dev_conf->rx_adv_conf.dcb_rx_conf);
445 if (! (conf->nb_tcs == ETH_4_TCS ||
446 conf->nb_tcs == ETH_8_TCS)) {
447 PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
448 "nb_tcs != %d or nb_tcs "
450 port_id, ETH_4_TCS, ETH_8_TCS);
455 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB) {
456 const struct rte_eth_dcb_tx_conf *conf;
458 if (nb_tx_q != ETH_DCB_NUM_QUEUES) {
459 PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_tx_q "
461 port_id, ETH_DCB_NUM_QUEUES);
464 conf = &(dev_conf->tx_adv_conf.dcb_tx_conf);
465 if (! (conf->nb_tcs == ETH_4_TCS ||
466 conf->nb_tcs == ETH_8_TCS)) {
467 PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
468 "nb_tcs != %d or nb_tcs "
470 port_id, ETH_4_TCS, ETH_8_TCS);
479 rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
480 const struct rte_eth_conf *dev_conf)
482 struct rte_eth_dev *dev;
483 struct rte_eth_dev_info dev_info;
486 /* This function is only safe when called from the primary process
487 * in a multi-process setup*/
488 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
490 if (port_id >= nb_ports || port_id >= RTE_MAX_ETHPORTS) {
491 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
494 dev = &rte_eth_devices[port_id];
496 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
497 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
499 if (dev->data->dev_started) {
501 "port %d must be stopped to allow configuration\n", port_id);
506 * Check that the numbers of RX and TX queues are not greater
507 * than the maximum number of RX and TX queues supported by the
510 (*dev->dev_ops->dev_infos_get)(dev, &dev_info);
511 if (nb_rx_q > dev_info.max_rx_queues) {
512 PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_queues=%d > %d\n",
513 port_id, nb_rx_q, dev_info.max_rx_queues);
517 PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_q == 0\n", port_id);
521 if (nb_tx_q > dev_info.max_tx_queues) {
522 PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_queues=%d > %d\n",
523 port_id, nb_tx_q, dev_info.max_tx_queues);
527 PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_q == 0\n", port_id);
531 /* Copy the dev_conf parameter into the dev structure */
532 memcpy(&dev->data->dev_conf, dev_conf, sizeof(dev->data->dev_conf));
535 * If jumbo frames are enabled, check that the maximum RX packet
536 * length is supported by the configured device.
538 if (dev_conf->rxmode.jumbo_frame == 1) {
539 if (dev_conf->rxmode.max_rx_pkt_len >
540 dev_info.max_rx_pktlen) {
541 PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
542 " > max valid value %u\n",
544 (unsigned)dev_conf->rxmode.max_rx_pkt_len,
545 (unsigned)dev_info.max_rx_pktlen);
548 else if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN) {
549 PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
550 " < min valid value %u\n",
552 (unsigned)dev_conf->rxmode.max_rx_pkt_len,
553 (unsigned)ETHER_MIN_LEN);
557 /* Use default value */
558 dev->data->dev_conf.rxmode.max_rx_pkt_len = ETHER_MAX_LEN;
560 /* multipe queue mode checking */
561 diag = rte_eth_dev_check_mq_mode(port_id, nb_rx_q, nb_tx_q, dev_conf);
563 PMD_DEBUG_TRACE("port%d rte_eth_dev_check_mq_mode = %d\n",
569 * Setup new number of RX/TX queues and reconfigure device.
571 diag = rte_eth_dev_rx_queue_config(dev, nb_rx_q);
573 PMD_DEBUG_TRACE("port%d rte_eth_dev_rx_queue_config = %d\n",
578 diag = rte_eth_dev_tx_queue_config(dev, nb_tx_q);
580 PMD_DEBUG_TRACE("port%d rte_eth_dev_tx_queue_config = %d\n",
582 rte_eth_dev_rx_queue_config(dev, 0);
586 diag = (*dev->dev_ops->dev_configure)(dev);
588 PMD_DEBUG_TRACE("port%d dev_configure = %d\n",
590 rte_eth_dev_rx_queue_config(dev, 0);
591 rte_eth_dev_tx_queue_config(dev, 0);
599 rte_eth_dev_config_restore(uint8_t port_id)
601 struct rte_eth_dev *dev;
602 struct rte_eth_dev_info dev_info;
603 struct ether_addr addr;
607 dev = &rte_eth_devices[port_id];
609 rte_eth_dev_info_get(port_id, &dev_info);
611 if (RTE_ETH_DEV_SRIOV(dev).active)
612 pool = RTE_ETH_DEV_SRIOV(dev).def_vmdq_idx;
614 /* replay MAC address configuration */
615 for (i = 0; i < dev_info.max_mac_addrs; i++) {
616 addr = dev->data->mac_addrs[i];
618 /* skip zero address */
619 if (is_zero_ether_addr(&addr))
622 /* add address to the hardware */
623 if (*dev->dev_ops->mac_addr_add)
624 (*dev->dev_ops->mac_addr_add)(dev, &addr, i, pool);
626 PMD_DEBUG_TRACE("port %d: MAC address array not supported\n",
628 /* exit the loop but not return an error */
633 /* replay promiscuous configuration */
634 if (rte_eth_promiscuous_get(port_id) == 1)
635 rte_eth_promiscuous_enable(port_id);
636 else if (rte_eth_promiscuous_get(port_id) == 0)
637 rte_eth_promiscuous_disable(port_id);
639 /* replay allmulticast configuration */
640 if (rte_eth_allmulticast_get(port_id) == 1)
641 rte_eth_allmulticast_enable(port_id);
642 else if (rte_eth_allmulticast_get(port_id) == 0)
643 rte_eth_allmulticast_disable(port_id);
647 rte_eth_dev_start(uint8_t port_id)
649 struct rte_eth_dev *dev;
652 /* This function is only safe when called from the primary process
653 * in a multi-process setup*/
654 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
656 if (port_id >= nb_ports) {
657 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
660 dev = &rte_eth_devices[port_id];
662 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
663 diag = (*dev->dev_ops->dev_start)(dev);
665 dev->data->dev_started = 1;
669 rte_eth_dev_config_restore(port_id);
675 rte_eth_dev_stop(uint8_t port_id)
677 struct rte_eth_dev *dev;
679 /* This function is only safe when called from the primary process
680 * in a multi-process setup*/
681 PROC_PRIMARY_OR_RET();
683 if (port_id >= nb_ports) {
684 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
687 dev = &rte_eth_devices[port_id];
689 FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop);
690 dev->data->dev_started = 0;
691 (*dev->dev_ops->dev_stop)(dev);
695 rte_eth_dev_close(uint8_t port_id)
697 struct rte_eth_dev *dev;
699 /* This function is only safe when called from the primary process
700 * in a multi-process setup*/
701 PROC_PRIMARY_OR_RET();
703 if (port_id >= nb_ports) {
704 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
708 dev = &rte_eth_devices[port_id];
710 FUNC_PTR_OR_RET(*dev->dev_ops->dev_close);
711 dev->data->dev_started = 0;
712 (*dev->dev_ops->dev_close)(dev);
716 rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
717 uint16_t nb_rx_desc, unsigned int socket_id,
718 const struct rte_eth_rxconf *rx_conf,
719 struct rte_mempool *mp)
721 struct rte_eth_dev *dev;
722 struct rte_pktmbuf_pool_private *mbp_priv;
723 struct rte_eth_dev_info dev_info;
725 /* This function is only safe when called from the primary process
726 * in a multi-process setup*/
727 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
729 if (port_id >= nb_ports) {
730 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
733 dev = &rte_eth_devices[port_id];
734 if (rx_queue_id >= dev->data->nb_rx_queues) {
735 PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
739 if (dev->data->dev_started) {
741 "port %d must be stopped to allow configuration\n", port_id);
745 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
746 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP);
749 * Check the size of the mbuf data buffer.
750 * This value must be provided in the private data of the memory pool.
751 * First check that the memory pool has a valid private data.
753 (*dev->dev_ops->dev_infos_get)(dev, &dev_info);
754 if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) {
755 PMD_DEBUG_TRACE("%s private_data_size %d < %d\n",
756 mp->name, (int) mp->private_data_size,
757 (int) sizeof(struct rte_pktmbuf_pool_private));
760 mbp_priv = rte_mempool_get_priv(mp);
761 if ((uint32_t) (mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM) <
762 dev_info.min_rx_bufsize) {
763 PMD_DEBUG_TRACE("%s mbuf_data_room_size %d < %d "
764 "(RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)"
767 (int)mbp_priv->mbuf_data_room_size,
768 (int)(RTE_PKTMBUF_HEADROOM +
769 dev_info.min_rx_bufsize),
770 (int)RTE_PKTMBUF_HEADROOM,
771 (int)dev_info.min_rx_bufsize);
775 return (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
776 socket_id, rx_conf, mp);
780 rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
781 uint16_t nb_tx_desc, unsigned int socket_id,
782 const struct rte_eth_txconf *tx_conf)
784 struct rte_eth_dev *dev;
786 /* This function is only safe when called from the primary process
787 * in a multi-process setup*/
788 PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
790 if (port_id >= RTE_MAX_ETHPORTS || port_id >= nb_ports) {
791 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
794 dev = &rte_eth_devices[port_id];
795 if (tx_queue_id >= dev->data->nb_tx_queues) {
796 PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
800 if (dev->data->dev_started) {
802 "port %d must be stopped to allow configuration\n", port_id);
806 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_setup, -ENOTSUP);
807 return (*dev->dev_ops->tx_queue_setup)(dev, tx_queue_id, nb_tx_desc,
812 rte_eth_promiscuous_enable(uint8_t port_id)
814 struct rte_eth_dev *dev;
816 if (port_id >= nb_ports) {
817 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
820 dev = &rte_eth_devices[port_id];
822 FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_enable);
823 (*dev->dev_ops->promiscuous_enable)(dev);
824 dev->data->promiscuous = 1;
828 rte_eth_promiscuous_disable(uint8_t port_id)
830 struct rte_eth_dev *dev;
832 if (port_id >= nb_ports) {
833 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
836 dev = &rte_eth_devices[port_id];
838 FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_disable);
839 dev->data->promiscuous = 0;
840 (*dev->dev_ops->promiscuous_disable)(dev);
844 rte_eth_promiscuous_get(uint8_t port_id)
846 struct rte_eth_dev *dev;
848 if (port_id >= nb_ports) {
849 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
853 dev = &rte_eth_devices[port_id];
854 return dev->data->promiscuous;
858 rte_eth_allmulticast_enable(uint8_t port_id)
860 struct rte_eth_dev *dev;
862 if (port_id >= nb_ports) {
863 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
866 dev = &rte_eth_devices[port_id];
868 FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_enable);
869 (*dev->dev_ops->allmulticast_enable)(dev);
870 dev->data->all_multicast = 1;
874 rte_eth_allmulticast_disable(uint8_t port_id)
876 struct rte_eth_dev *dev;
878 if (port_id >= nb_ports) {
879 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
882 dev = &rte_eth_devices[port_id];
884 FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_disable);
885 dev->data->all_multicast = 0;
886 (*dev->dev_ops->allmulticast_disable)(dev);
890 rte_eth_allmulticast_get(uint8_t port_id)
892 struct rte_eth_dev *dev;
894 if (port_id >= nb_ports) {
895 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
899 dev = &rte_eth_devices[port_id];
900 return dev->data->all_multicast;
904 rte_eth_dev_atomic_read_link_status(struct rte_eth_dev *dev,
905 struct rte_eth_link *link)
907 struct rte_eth_link *dst = link;
908 struct rte_eth_link *src = &(dev->data->dev_link);
910 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
911 *(uint64_t *)src) == 0)
918 rte_eth_link_get(uint8_t port_id, struct rte_eth_link *eth_link)
920 struct rte_eth_dev *dev;
922 if (port_id >= nb_ports) {
923 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
926 dev = &rte_eth_devices[port_id];
927 FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
929 if (dev->data->dev_conf.intr_conf.lsc != 0)
930 rte_eth_dev_atomic_read_link_status(dev, eth_link);
932 (*dev->dev_ops->link_update)(dev, 1);
933 *eth_link = dev->data->dev_link;
938 rte_eth_link_get_nowait(uint8_t port_id, struct rte_eth_link *eth_link)
940 struct rte_eth_dev *dev;
942 if (port_id >= nb_ports) {
943 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
946 dev = &rte_eth_devices[port_id];
947 FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
949 if (dev->data->dev_conf.intr_conf.lsc != 0)
950 rte_eth_dev_atomic_read_link_status(dev, eth_link);
952 (*dev->dev_ops->link_update)(dev, 0);
953 *eth_link = dev->data->dev_link;
958 rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats)
960 struct rte_eth_dev *dev;
962 if (port_id >= nb_ports) {
963 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
966 dev = &rte_eth_devices[port_id];
967 memset(stats, 0, sizeof(*stats));
969 FUNC_PTR_OR_RET(*dev->dev_ops->stats_get);
970 (*dev->dev_ops->stats_get)(dev, stats);
971 stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
975 rte_eth_stats_reset(uint8_t port_id)
977 struct rte_eth_dev *dev;
979 if (port_id >= nb_ports) {
980 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
983 dev = &rte_eth_devices[port_id];
985 FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);
986 (*dev->dev_ops->stats_reset)(dev);
991 set_queue_stats_mapping(uint8_t port_id, uint16_t queue_id, uint8_t stat_idx,
994 struct rte_eth_dev *dev;
996 if (port_id >= nb_ports) {
997 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1000 dev = &rte_eth_devices[port_id];
1002 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_stats_mapping_set, -ENOTSUP);
1003 return (*dev->dev_ops->queue_stats_mapping_set)
1004 (dev, queue_id, stat_idx, is_rx);
1009 rte_eth_dev_set_tx_queue_stats_mapping(uint8_t port_id, uint16_t tx_queue_id,
1012 return set_queue_stats_mapping(port_id, tx_queue_id, stat_idx,
1018 rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id,
1021 return set_queue_stats_mapping(port_id, rx_queue_id, stat_idx,
1027 rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
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->dev_infos_get);
1038 (*dev->dev_ops->dev_infos_get)(dev, dev_info);
1039 dev_info->pci_dev = dev->pci_dev;
1041 dev_info->driver_name = dev->driver->pci_drv.name;
1045 rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr)
1047 struct rte_eth_dev *dev;
1049 if (port_id >= nb_ports) {
1050 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1053 dev = &rte_eth_devices[port_id];
1054 ether_addr_copy(&dev->data->mac_addrs[0], mac_addr);
1058 rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t vlan_id, int on)
1060 struct rte_eth_dev *dev;
1062 if (port_id >= nb_ports) {
1063 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1066 dev = &rte_eth_devices[port_id];
1067 if (! (dev->data->dev_conf.rxmode.hw_vlan_filter)) {
1068 PMD_DEBUG_TRACE("port %d: vlan-filtering disabled\n", port_id);
1072 if (vlan_id > 4095) {
1073 PMD_DEBUG_TRACE("(port_id=%d) invalid vlan_id=%u > 4095\n",
1074 port_id, (unsigned) vlan_id);
1077 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_filter_set, -ENOTSUP);
1078 (*dev->dev_ops->vlan_filter_set)(dev, vlan_id, on);
1083 rte_eth_dev_set_vlan_strip_on_queue(uint8_t port_id, uint16_t rx_queue_id, int on)
1085 struct rte_eth_dev *dev;
1087 if (port_id >= nb_ports) {
1088 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1092 dev = &rte_eth_devices[port_id];
1093 if (rx_queue_id >= dev->data->nb_rx_queues) {
1094 PMD_DEBUG_TRACE("Invalid rx_queue_id=%d\n", port_id);
1098 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
1099 (*dev->dev_ops->vlan_strip_queue_set)(dev, rx_queue_id, on);
1105 rte_eth_dev_set_vlan_ether_type(uint8_t port_id, uint16_t tpid)
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 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_tpid_set, -ENOTSUP);
1116 (*dev->dev_ops->vlan_tpid_set)(dev, tpid);
1122 rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask)
1124 struct rte_eth_dev *dev;
1129 if (port_id >= nb_ports) {
1130 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1134 dev = &rte_eth_devices[port_id];
1136 /*check which option changed by application*/
1137 cur = !!(offload_mask & ETH_VLAN_STRIP_OFFLOAD);
1138 org = !!(dev->data->dev_conf.rxmode.hw_vlan_strip);
1140 dev->data->dev_conf.rxmode.hw_vlan_strip = (uint8_t)cur;
1141 mask |= ETH_VLAN_STRIP_MASK;
1144 cur = !!(offload_mask & ETH_VLAN_FILTER_OFFLOAD);
1145 org = !!(dev->data->dev_conf.rxmode.hw_vlan_filter);
1147 dev->data->dev_conf.rxmode.hw_vlan_filter = (uint8_t)cur;
1148 mask |= ETH_VLAN_FILTER_MASK;
1151 cur = !!(offload_mask & ETH_VLAN_EXTEND_OFFLOAD);
1152 org = !!(dev->data->dev_conf.rxmode.hw_vlan_extend);
1154 dev->data->dev_conf.rxmode.hw_vlan_extend = (uint8_t)cur;
1155 mask |= ETH_VLAN_EXTEND_MASK;
1162 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP);
1163 (*dev->dev_ops->vlan_offload_set)(dev, mask);
1169 rte_eth_dev_get_vlan_offload(uint8_t port_id)
1171 struct rte_eth_dev *dev;
1174 if (port_id >= nb_ports) {
1175 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1179 dev = &rte_eth_devices[port_id];
1181 if (dev->data->dev_conf.rxmode.hw_vlan_strip)
1182 ret |= ETH_VLAN_STRIP_OFFLOAD ;
1184 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
1185 ret |= ETH_VLAN_FILTER_OFFLOAD ;
1187 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
1188 ret |= ETH_VLAN_EXTEND_OFFLOAD ;
1195 rte_eth_dev_fdir_add_signature_filter(uint8_t port_id,
1196 struct rte_fdir_filter *fdir_filter,
1199 struct rte_eth_dev *dev;
1201 if (port_id >= nb_ports) {
1202 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1206 dev = &rte_eth_devices[port_id];
1208 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
1209 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1210 port_id, dev->data->dev_conf.fdir_conf.mode);
1214 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1215 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1216 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1217 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1218 "None l4type, source & destinations ports " \
1219 "should be null!\n");
1223 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_add_signature_filter, -ENOTSUP);
1224 return (*dev->dev_ops->fdir_add_signature_filter)(dev, fdir_filter,
1229 rte_eth_dev_fdir_update_signature_filter(uint8_t port_id,
1230 struct rte_fdir_filter *fdir_filter,
1233 struct rte_eth_dev *dev;
1235 if (port_id >= nb_ports) {
1236 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1240 dev = &rte_eth_devices[port_id];
1242 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
1243 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1244 port_id, dev->data->dev_conf.fdir_conf.mode);
1248 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1249 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1250 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1251 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1252 "None l4type, source & destinations ports " \
1253 "should be null!\n");
1257 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_update_signature_filter, -ENOTSUP);
1258 return (*dev->dev_ops->fdir_update_signature_filter)(dev, fdir_filter,
1264 rte_eth_dev_fdir_remove_signature_filter(uint8_t port_id,
1265 struct rte_fdir_filter *fdir_filter)
1267 struct rte_eth_dev *dev;
1269 if (port_id >= nb_ports) {
1270 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1274 dev = &rte_eth_devices[port_id];
1276 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
1277 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1278 port_id, dev->data->dev_conf.fdir_conf.mode);
1282 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1283 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1284 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1285 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1286 "None l4type source & destinations ports " \
1287 "should be null!\n");
1291 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_signature_filter, -ENOTSUP);
1292 return (*dev->dev_ops->fdir_remove_signature_filter)(dev, fdir_filter);
1296 rte_eth_dev_fdir_get_infos(uint8_t port_id, struct rte_eth_fdir *fdir)
1298 struct rte_eth_dev *dev;
1300 if (port_id >= nb_ports) {
1301 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1305 dev = &rte_eth_devices[port_id];
1306 if (! (dev->data->dev_conf.fdir_conf.mode)) {
1307 PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
1311 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_infos_get, -ENOTSUP);
1313 (*dev->dev_ops->fdir_infos_get)(dev, fdir);
1318 rte_eth_dev_fdir_add_perfect_filter(uint8_t port_id,
1319 struct rte_fdir_filter *fdir_filter,
1320 uint16_t soft_id, uint8_t queue,
1323 struct rte_eth_dev *dev;
1325 if (port_id >= nb_ports) {
1326 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1330 dev = &rte_eth_devices[port_id];
1332 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
1333 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1334 port_id, dev->data->dev_conf.fdir_conf.mode);
1338 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1339 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1340 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1341 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1342 "None l4type, source & destinations ports " \
1343 "should be null!\n");
1347 /* For now IPv6 is not supported with perfect filter */
1348 if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
1351 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_add_perfect_filter, -ENOTSUP);
1352 return (*dev->dev_ops->fdir_add_perfect_filter)(dev, fdir_filter,
1358 rte_eth_dev_fdir_update_perfect_filter(uint8_t port_id,
1359 struct rte_fdir_filter *fdir_filter,
1360 uint16_t soft_id, uint8_t queue,
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];
1372 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
1373 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1374 port_id, dev->data->dev_conf.fdir_conf.mode);
1378 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1379 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1380 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1381 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1382 "None l4type, source & destinations ports " \
1383 "should be null!\n");
1387 /* For now IPv6 is not supported with perfect filter */
1388 if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
1391 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_update_perfect_filter, -ENOTSUP);
1392 return (*dev->dev_ops->fdir_update_perfect_filter)(dev, fdir_filter,
1393 soft_id, queue, drop);
1397 rte_eth_dev_fdir_remove_perfect_filter(uint8_t port_id,
1398 struct rte_fdir_filter *fdir_filter,
1401 struct rte_eth_dev *dev;
1403 if (port_id >= nb_ports) {
1404 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1408 dev = &rte_eth_devices[port_id];
1410 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
1411 PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
1412 port_id, dev->data->dev_conf.fdir_conf.mode);
1416 if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
1417 || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
1418 && (fdir_filter->port_src || fdir_filter->port_dst)) {
1419 PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
1420 "None l4type, source & destinations ports " \
1421 "should be null!\n");
1425 /* For now IPv6 is not supported with perfect filter */
1426 if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
1429 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_perfect_filter, -ENOTSUP);
1430 return (*dev->dev_ops->fdir_remove_perfect_filter)(dev, fdir_filter,
1435 rte_eth_dev_fdir_set_masks(uint8_t port_id, struct rte_fdir_masks *fdir_mask)
1437 struct rte_eth_dev *dev;
1439 if (port_id >= nb_ports) {
1440 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1444 dev = &rte_eth_devices[port_id];
1445 if (! (dev->data->dev_conf.fdir_conf.mode)) {
1446 PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
1450 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_set_masks, -ENOTSUP);
1451 return (*dev->dev_ops->fdir_set_masks)(dev, fdir_mask);
1455 rte_eth_dev_flow_ctrl_set(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
1457 struct rte_eth_dev *dev;
1459 if (port_id >= nb_ports) {
1460 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1464 if ((fc_conf->send_xon != 0) && (fc_conf->send_xon != 1)) {
1465 PMD_DEBUG_TRACE("Invalid send_xon, only 0/1 allowed\n");
1469 dev = &rte_eth_devices[port_id];
1470 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_set, -ENOTSUP);
1471 return (*dev->dev_ops->flow_ctrl_set)(dev, fc_conf);
1475 rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id, struct rte_eth_pfc_conf *pfc_conf)
1477 struct rte_eth_dev *dev;
1479 if (port_id >= nb_ports) {
1480 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1484 if (pfc_conf->priority > (ETH_DCB_NUM_USER_PRIORITIES - 1)) {
1485 PMD_DEBUG_TRACE("Invalid priority, only 0-7 allowed\n");
1489 dev = &rte_eth_devices[port_id];
1490 /* High water, low water validation are device specific */
1491 if (*dev->dev_ops->priority_flow_ctrl_set)
1492 return (*dev->dev_ops->priority_flow_ctrl_set)(dev, pfc_conf);
1497 rte_eth_dev_rss_reta_update(uint8_t port_id, struct rte_eth_rss_reta *reta_conf)
1499 struct rte_eth_dev *dev;
1502 if (port_id >= nb_ports) {
1503 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1507 /* Invalid mask bit(s) setting */
1508 if ((reta_conf->mask_lo == 0) && (reta_conf->mask_hi == 0)) {
1509 PMD_DEBUG_TRACE("Invalid update mask bits for port=%d\n",port_id);
1513 if (reta_conf->mask_lo != 0) {
1514 for (i = 0; i < ETH_RSS_RETA_NUM_ENTRIES/2; i++) {
1515 if ((reta_conf->mask_lo & (1ULL << i)) &&
1516 (reta_conf->reta[i] >= ETH_RSS_RETA_MAX_QUEUE)) {
1517 PMD_DEBUG_TRACE("RETA hash index output"
1518 "configration for port=%d,invalid"
1519 "queue=%d\n",port_id,reta_conf->reta[i]);
1526 if (reta_conf->mask_hi != 0) {
1527 for (i = 0; i< ETH_RSS_RETA_NUM_ENTRIES/2; i++) {
1528 j = (uint8_t)(i + ETH_RSS_RETA_NUM_ENTRIES/2);
1530 /* Check if the max entry >= 128 */
1531 if ((reta_conf->mask_hi & (1ULL << i)) &&
1532 (reta_conf->reta[j] >= ETH_RSS_RETA_MAX_QUEUE)) {
1533 PMD_DEBUG_TRACE("RETA hash index output"
1534 "configration for port=%d,invalid"
1535 "queue=%d\n",port_id,reta_conf->reta[j]);
1542 dev = &rte_eth_devices[port_id];
1544 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_update, -ENOTSUP);
1545 return (*dev->dev_ops->reta_update)(dev, reta_conf);
1549 rte_eth_dev_rss_reta_query(uint8_t port_id, struct rte_eth_rss_reta *reta_conf)
1551 struct rte_eth_dev *dev;
1553 if (port_id >= nb_ports) {
1554 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1558 if((reta_conf->mask_lo == 0) && (reta_conf->mask_hi == 0)) {
1559 PMD_DEBUG_TRACE("Invalid update mask bits for the port=%d\n",port_id);
1563 dev = &rte_eth_devices[port_id];
1564 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_query, -ENOTSUP);
1565 return (*dev->dev_ops->reta_query)(dev, reta_conf);
1569 rte_eth_led_on(uint8_t port_id)
1571 struct rte_eth_dev *dev;
1573 if (port_id >= nb_ports) {
1574 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1578 dev = &rte_eth_devices[port_id];
1579 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_on, -ENOTSUP);
1580 return ((*dev->dev_ops->dev_led_on)(dev));
1584 rte_eth_led_off(uint8_t port_id)
1586 struct rte_eth_dev *dev;
1588 if (port_id >= nb_ports) {
1589 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1593 dev = &rte_eth_devices[port_id];
1594 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_off, -ENOTSUP);
1595 return ((*dev->dev_ops->dev_led_off)(dev));
1599 * Returns index into MAC address array of addr. Use 00:00:00:00:00:00 to find
1603 get_mac_addr_index(uint8_t port_id, struct ether_addr *addr)
1605 struct rte_eth_dev_info dev_info;
1606 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
1609 rte_eth_dev_info_get(port_id, &dev_info);
1611 for (i = 0; i < dev_info.max_mac_addrs; i++)
1612 if (memcmp(addr, &dev->data->mac_addrs[i], ETHER_ADDR_LEN) == 0)
1618 static struct ether_addr null_mac_addr = {{0, 0, 0, 0, 0, 0}};
1621 rte_eth_dev_mac_addr_add(uint8_t port_id, struct ether_addr *addr,
1624 struct rte_eth_dev *dev;
1628 if (port_id >= nb_ports) {
1629 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1632 dev = &rte_eth_devices[port_id];
1633 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
1635 if (is_zero_ether_addr(addr)) {
1636 PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
1640 if (pool >= ETH_64_POOLS) {
1641 PMD_DEBUG_TRACE("pool id must be 0-%d\n",ETH_64_POOLS - 1);
1645 index = get_mac_addr_index(port_id, addr);
1647 index = get_mac_addr_index(port_id, &null_mac_addr);
1649 PMD_DEBUG_TRACE("port %d: MAC address array full\n",
1654 pool_mask = dev->data->mac_pool_sel[index];
1656 /* Check if both MAC address and pool is alread there, and do nothing */
1657 if (pool_mask & (1ULL << pool))
1662 (*dev->dev_ops->mac_addr_add)(dev, addr, index, pool);
1664 /* Update address in NIC data structure */
1665 ether_addr_copy(addr, &dev->data->mac_addrs[index]);
1667 /* Update pool bitmap in NIC data structure */
1668 dev->data->mac_pool_sel[index] |= (1ULL << pool);
1674 rte_eth_dev_mac_addr_remove(uint8_t port_id, struct ether_addr *addr)
1676 struct rte_eth_dev *dev;
1679 if (port_id >= nb_ports) {
1680 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1683 dev = &rte_eth_devices[port_id];
1684 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
1686 index = get_mac_addr_index(port_id, addr);
1688 PMD_DEBUG_TRACE("port %d: Cannot remove default MAC address\n", port_id);
1689 return (-EADDRINUSE);
1690 } else if (index < 0)
1691 return 0; /* Do nothing if address wasn't found */
1694 (*dev->dev_ops->mac_addr_remove)(dev, index);
1696 /* Update address in NIC data structure */
1697 ether_addr_copy(&null_mac_addr, &dev->data->mac_addrs[index]);
1703 rte_eth_dev_set_vf_rxmode(uint8_t port_id, uint16_t vf,
1704 uint16_t rx_mode, uint8_t on)
1707 struct rte_eth_dev *dev;
1708 struct rte_eth_dev_info dev_info;
1710 if (port_id >= nb_ports) {
1711 PMD_DEBUG_TRACE("set VF RX mode:Invalid port_id=%d\n",
1716 dev = &rte_eth_devices[port_id];
1717 rte_eth_dev_info_get(port_id, &dev_info);
1719 num_vfs = dev_info.max_vfs;
1722 PMD_DEBUG_TRACE("set VF RX mode:invalid VF id %d\n", vf);
1727 PMD_DEBUG_TRACE("set VF RX mode:mode mask ca not be zero\n");
1730 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx_mode, -ENOTSUP);
1731 return (*dev->dev_ops->set_vf_rx_mode)(dev, vf, rx_mode, on);
1735 * Returns index into MAC address array of addr. Use 00:00:00:00:00:00 to find
1739 get_hash_mac_addr_index(uint8_t port_id, struct ether_addr *addr)
1741 struct rte_eth_dev_info dev_info;
1742 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
1745 rte_eth_dev_info_get(port_id, &dev_info);
1746 if (!dev->data->hash_mac_addrs)
1749 for (i = 0; i < dev_info.max_hash_mac_addrs; i++)
1750 if (memcmp(addr, &dev->data->hash_mac_addrs[i],
1751 ETHER_ADDR_LEN) == 0)
1758 rte_eth_dev_uc_hash_table_set(uint8_t port_id, struct ether_addr *addr,
1763 struct rte_eth_dev *dev;
1765 if (port_id >= nb_ports) {
1766 PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=%d\n",
1771 dev = &rte_eth_devices[port_id];
1772 if (is_zero_ether_addr(addr)) {
1773 PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
1778 index = get_hash_mac_addr_index(port_id, addr);
1779 /* Check if it's already there, and do nothing */
1780 if ((index >= 0) && (on))
1785 PMD_DEBUG_TRACE("port %d: the MAC address was not"
1786 "set in UTA\n", port_id);
1790 index = get_hash_mac_addr_index(port_id, &null_mac_addr);
1792 PMD_DEBUG_TRACE("port %d: MAC address array full\n",
1798 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_hash_table_set, -ENOTSUP);
1799 ret = (*dev->dev_ops->uc_hash_table_set)(dev, addr, on);
1801 /* Update address in NIC data structure */
1803 ether_addr_copy(addr,
1804 &dev->data->hash_mac_addrs[index]);
1806 ether_addr_copy(&null_mac_addr,
1807 &dev->data->hash_mac_addrs[index]);
1814 rte_eth_dev_uc_all_hash_table_set(uint8_t port_id, uint8_t on)
1816 struct rte_eth_dev *dev;
1818 if (port_id >= nb_ports) {
1819 PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=%d\n",
1824 dev = &rte_eth_devices[port_id];
1826 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_all_hash_table_set, -ENOTSUP);
1827 return (*dev->dev_ops->uc_all_hash_table_set)(dev, on);
1831 rte_eth_dev_set_vf_rx(uint8_t port_id,uint16_t vf, uint8_t on)
1834 struct rte_eth_dev *dev;
1835 struct rte_eth_dev_info dev_info;
1837 if (port_id >= nb_ports) {
1838 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1842 dev = &rte_eth_devices[port_id];
1843 rte_eth_dev_info_get(port_id, &dev_info);
1845 num_vfs = dev_info.max_vfs;
1848 PMD_DEBUG_TRACE("port %d: invalid vf id\n", port_id);
1852 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx, -ENOTSUP);
1853 return (*dev->dev_ops->set_vf_rx)(dev, vf,on);
1857 rte_eth_dev_set_vf_tx(uint8_t port_id,uint16_t vf, uint8_t on)
1860 struct rte_eth_dev *dev;
1861 struct rte_eth_dev_info dev_info;
1863 if (port_id >= nb_ports) {
1864 PMD_DEBUG_TRACE("set pool tx:Invalid port_id=%d\n", port_id);
1868 dev = &rte_eth_devices[port_id];
1869 rte_eth_dev_info_get(port_id, &dev_info);
1871 num_vfs = dev_info.max_vfs;
1874 PMD_DEBUG_TRACE("set pool tx:invalid pool id=%d\n", vf);
1878 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_tx, -ENOTSUP);
1879 return (*dev->dev_ops->set_vf_tx)(dev, vf,on);
1883 rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, uint16_t vlan_id,
1884 uint64_t vf_mask,uint8_t vlan_on)
1886 struct rte_eth_dev *dev;
1888 if (port_id >= nb_ports) {
1889 PMD_DEBUG_TRACE("VF VLAN filter:invalid port id=%d\n",
1893 dev = &rte_eth_devices[port_id];
1895 if(vlan_id > ETHER_MAX_VLAN_ID)
1897 PMD_DEBUG_TRACE("VF VLAN filter:invalid VLAN id=%d\n",
1903 PMD_DEBUG_TRACE("VF VLAN filter:pool_mask can not be 0\n");
1907 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_filter, -ENOTSUP);
1908 return (*dev->dev_ops->set_vf_vlan_filter)(dev, vlan_id,
1913 rte_eth_mirror_rule_set(uint8_t port_id,
1914 struct rte_eth_vmdq_mirror_conf *mirror_conf,
1915 uint8_t rule_id, uint8_t on)
1917 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
1919 if (port_id >= nb_ports) {
1920 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1924 if (mirror_conf->rule_type_mask == 0) {
1925 PMD_DEBUG_TRACE("mirror rule type can not be 0.\n");
1929 if (mirror_conf->dst_pool >= ETH_64_POOLS) {
1930 PMD_DEBUG_TRACE("Invalid dst pool, pool id must"
1931 "be 0-%d\n",ETH_64_POOLS - 1);
1935 if ((mirror_conf->rule_type_mask & ETH_VMDQ_POOL_MIRROR) &&
1936 (mirror_conf->pool_mask == 0)) {
1937 PMD_DEBUG_TRACE("Invalid mirror pool, pool mask can not"
1942 if(rule_id >= ETH_VMDQ_NUM_MIRROR_RULE)
1944 PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
1945 ETH_VMDQ_NUM_MIRROR_RULE - 1);
1949 dev = &rte_eth_devices[port_id];
1950 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_set, -ENOTSUP);
1952 return (*dev->dev_ops->mirror_rule_set)(dev, mirror_conf, rule_id, on);
1956 rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)
1958 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
1960 if (port_id >= nb_ports) {
1961 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1965 if(rule_id >= ETH_VMDQ_NUM_MIRROR_RULE)
1967 PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
1968 ETH_VMDQ_NUM_MIRROR_RULE-1);
1972 dev = &rte_eth_devices[port_id];
1973 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_reset, -ENOTSUP);
1975 return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
1978 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
1980 rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
1981 struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
1983 struct rte_eth_dev *dev;
1985 if (port_id >= nb_ports) {
1986 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
1989 dev = &rte_eth_devices[port_id];
1990 FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, -ENOTSUP);
1991 if (queue_id >= dev->data->nb_rx_queues) {
1992 PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
1995 return (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
2000 rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
2001 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
2003 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];
2011 FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, -ENOTSUP);
2012 if (queue_id >= dev->data->nb_tx_queues) {
2013 PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
2016 return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id],
2021 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
2023 struct rte_eth_dev *dev;
2025 if (port_id >= nb_ports) {
2026 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2029 dev = &rte_eth_devices[port_id];
2030 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
2031 return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
2035 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
2037 struct rte_eth_dev *dev;
2039 if (port_id >= nb_ports) {
2040 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2043 dev = &rte_eth_devices[port_id];
2044 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
2045 return (*dev->dev_ops->rx_descriptor_done)( \
2046 dev->data->rx_queues[queue_id], offset);
2051 rte_eth_dev_callback_register(uint8_t port_id,
2052 enum rte_eth_event_type event,
2053 rte_eth_dev_cb_fn cb_fn, void *cb_arg)
2055 struct rte_eth_dev *dev;
2056 struct rte_eth_dev_callback *user_cb;
2060 if (port_id >= nb_ports) {
2061 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2065 dev = &rte_eth_devices[port_id];
2066 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2068 TAILQ_FOREACH(user_cb, &(dev->callbacks), next) {
2069 if (user_cb->cb_fn == cb_fn &&
2070 user_cb->cb_arg == cb_arg &&
2071 user_cb->event == event) {
2076 /* create a new callback. */
2077 if (user_cb == NULL && (user_cb = rte_zmalloc("INTR_USER_CALLBACK",
2078 sizeof(struct rte_eth_dev_callback), 0)) != NULL) {
2079 user_cb->cb_fn = cb_fn;
2080 user_cb->cb_arg = cb_arg;
2081 user_cb->event = event;
2082 TAILQ_INSERT_TAIL(&(dev->callbacks), user_cb, next);
2085 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2086 return ((user_cb == NULL) ? -ENOMEM : 0);
2090 rte_eth_dev_callback_unregister(uint8_t port_id,
2091 enum rte_eth_event_type event,
2092 rte_eth_dev_cb_fn cb_fn, void *cb_arg)
2095 struct rte_eth_dev *dev;
2096 struct rte_eth_dev_callback *cb, *next;
2100 if (port_id >= nb_ports) {
2101 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2105 dev = &rte_eth_devices[port_id];
2106 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2109 for (cb = TAILQ_FIRST(&dev->callbacks); cb != NULL; cb = next) {
2111 next = TAILQ_NEXT(cb, next);
2113 if (cb->cb_fn != cb_fn || cb->event != event ||
2114 (cb->cb_arg != (void *)-1 &&
2115 cb->cb_arg != cb_arg))
2119 * if this callback is not executing right now,
2122 if (cb->active == 0) {
2123 TAILQ_REMOVE(&(dev->callbacks), cb, next);
2130 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2135 _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
2136 enum rte_eth_event_type event)
2138 struct rte_eth_dev_callback *cb_lst;
2139 struct rte_eth_dev_callback dev_cb;
2141 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2142 TAILQ_FOREACH(cb_lst, &(dev->callbacks), next) {
2143 if (cb_lst->cb_fn == NULL || cb_lst->event != event)
2147 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2148 dev_cb.cb_fn(dev->data->port_id, dev_cb.event,
2150 rte_spinlock_lock(&rte_eth_dev_cb_lock);
2153 rte_spinlock_unlock(&rte_eth_dev_cb_lock);
2155 #ifdef RTE_NIC_BYPASS
2156 int rte_eth_dev_bypass_init(uint8_t port_id)
2158 struct rte_eth_dev *dev;
2160 if (port_id >= nb_ports) {
2161 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2165 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2166 PMD_DEBUG_TRACE("Invalid port device\n");
2170 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_init, -ENOTSUP);
2171 (*dev->dev_ops->bypass_init)(dev);
2176 rte_eth_dev_bypass_state_show(uint8_t port_id, uint32_t *state)
2178 struct rte_eth_dev *dev;
2180 if (port_id >= nb_ports) {
2181 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2185 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2186 PMD_DEBUG_TRACE("Invalid port device\n");
2189 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
2190 (*dev->dev_ops->bypass_state_show)(dev, state);
2195 rte_eth_dev_bypass_state_set(uint8_t port_id, uint32_t *new_state)
2197 struct rte_eth_dev *dev;
2199 if (port_id >= nb_ports) {
2200 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2204 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2205 PMD_DEBUG_TRACE("Invalid port device\n");
2209 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_set, -ENOTSUP);
2210 (*dev->dev_ops->bypass_state_set)(dev, new_state);
2215 rte_eth_dev_bypass_event_show(uint8_t port_id, uint32_t event, uint32_t *state)
2217 struct rte_eth_dev *dev;
2219 if (port_id >= nb_ports) {
2220 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2224 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2225 PMD_DEBUG_TRACE("Invalid port device\n");
2229 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
2230 (*dev->dev_ops->bypass_event_show)(dev, event, state);
2235 rte_eth_dev_bypass_event_store(uint8_t port_id, uint32_t event, uint32_t state)
2237 struct rte_eth_dev *dev;
2239 if (port_id >= nb_ports) {
2240 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2244 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2245 PMD_DEBUG_TRACE("Invalid port device\n");
2249 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_event_set, -ENOTSUP);
2250 (*dev->dev_ops->bypass_event_set)(dev, event, state);
2255 rte_eth_dev_wd_timeout_store(uint8_t port_id, uint32_t timeout)
2257 struct rte_eth_dev *dev;
2259 if (port_id >= nb_ports) {
2260 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2264 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2265 PMD_DEBUG_TRACE("Invalid port device\n");
2269 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_set, -ENOTSUP);
2270 (*dev->dev_ops->bypass_wd_timeout_set)(dev, timeout);
2275 rte_eth_dev_bypass_ver_show(uint8_t port_id, uint32_t *ver)
2277 struct rte_eth_dev *dev;
2279 if (port_id >= nb_ports) {
2280 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2284 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2285 PMD_DEBUG_TRACE("Invalid port device\n");
2289 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_ver_show, -ENOTSUP);
2290 (*dev->dev_ops->bypass_ver_show)(dev, ver);
2295 rte_eth_dev_bypass_wd_timeout_show(uint8_t port_id, uint32_t *wd_timeout)
2297 struct rte_eth_dev *dev;
2299 if (port_id >= nb_ports) {
2300 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2304 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2305 PMD_DEBUG_TRACE("Invalid port device\n");
2309 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_show, -ENOTSUP);
2310 (*dev->dev_ops->bypass_wd_timeout_show)(dev, wd_timeout);
2315 rte_eth_dev_bypass_wd_reset(uint8_t port_id)
2317 struct rte_eth_dev *dev;
2319 if (port_id >= nb_ports) {
2320 PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
2324 if ((dev= &rte_eth_devices[port_id]) == NULL) {
2325 PMD_DEBUG_TRACE("Invalid port device\n");
2329 FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_reset, -ENOTSUP);
2330 (*dev->dev_ops->bypass_wd_reset)(dev);