DPDK  19.02.0
rte_ethdev.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2017 Intel Corporation
3  */
4 
5 #ifndef _RTE_ETHDEV_H_
6 #define _RTE_ETHDEV_H_
7 
140 #ifdef __cplusplus
141 extern "C" {
142 #endif
143 
144 #include <stdint.h>
145 
146 /* Use this macro to check if LRO API is supported */
147 #define RTE_ETHDEV_HAS_LRO_SUPPORT
148 
149 #include <rte_compat.h>
150 #include <rte_log.h>
151 #include <rte_interrupts.h>
152 #include <rte_dev.h>
153 #include <rte_devargs.h>
154 #include <rte_errno.h>
155 #include <rte_common.h>
156 #include <rte_config.h>
157 
158 #include "rte_ether.h"
159 #include "rte_eth_ctrl.h"
160 #include "rte_dev_info.h"
161 
162 extern int rte_eth_dev_logtype;
163 
164 #define RTE_ETHDEV_LOG(level, ...) \
165  rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, "" __VA_ARGS__)
166 
167 struct rte_mbuf;
168 
185 int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs);
186 
201 uint16_t rte_eth_iterator_next(struct rte_dev_iterator *iter);
202 
215 void rte_eth_iterator_cleanup(struct rte_dev_iterator *iter);
216 
230 #define RTE_ETH_FOREACH_MATCHING_DEV(id, devargs, iter) \
231  for (rte_eth_iterator_init(iter, devargs), \
232  id = rte_eth_iterator_next(iter); \
233  id != RTE_MAX_ETHPORTS; \
234  id = rte_eth_iterator_next(iter))
235 
243  uint64_t ipackets;
244  uint64_t opackets;
245  uint64_t ibytes;
246  uint64_t obytes;
247  uint64_t imissed;
251  uint64_t ierrors;
252  uint64_t oerrors;
253  uint64_t rx_nombuf;
254  uint64_t q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
256  uint64_t q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
258  uint64_t q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
260  uint64_t q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
262  uint64_t q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
264 };
265 
269 #define ETH_LINK_SPEED_AUTONEG (0 << 0)
270 #define ETH_LINK_SPEED_FIXED (1 << 0)
271 #define ETH_LINK_SPEED_10M_HD (1 << 1)
272 #define ETH_LINK_SPEED_10M (1 << 2)
273 #define ETH_LINK_SPEED_100M_HD (1 << 3)
274 #define ETH_LINK_SPEED_100M (1 << 4)
275 #define ETH_LINK_SPEED_1G (1 << 5)
276 #define ETH_LINK_SPEED_2_5G (1 << 6)
277 #define ETH_LINK_SPEED_5G (1 << 7)
278 #define ETH_LINK_SPEED_10G (1 << 8)
279 #define ETH_LINK_SPEED_20G (1 << 9)
280 #define ETH_LINK_SPEED_25G (1 << 10)
281 #define ETH_LINK_SPEED_40G (1 << 11)
282 #define ETH_LINK_SPEED_50G (1 << 12)
283 #define ETH_LINK_SPEED_56G (1 << 13)
284 #define ETH_LINK_SPEED_100G (1 << 14)
289 #define ETH_SPEED_NUM_NONE 0
290 #define ETH_SPEED_NUM_10M 10
291 #define ETH_SPEED_NUM_100M 100
292 #define ETH_SPEED_NUM_1G 1000
293 #define ETH_SPEED_NUM_2_5G 2500
294 #define ETH_SPEED_NUM_5G 5000
295 #define ETH_SPEED_NUM_10G 10000
296 #define ETH_SPEED_NUM_20G 20000
297 #define ETH_SPEED_NUM_25G 25000
298 #define ETH_SPEED_NUM_40G 40000
299 #define ETH_SPEED_NUM_50G 50000
300 #define ETH_SPEED_NUM_56G 56000
301 #define ETH_SPEED_NUM_100G 100000
306 __extension__
307 struct rte_eth_link {
308  uint32_t link_speed;
309  uint16_t link_duplex : 1;
310  uint16_t link_autoneg : 1;
311  uint16_t link_status : 1;
312 } __attribute__((aligned(8)));
314 /* Utility constants */
315 #define ETH_LINK_HALF_DUPLEX 0
316 #define ETH_LINK_FULL_DUPLEX 1
317 #define ETH_LINK_DOWN 0
318 #define ETH_LINK_UP 1
319 #define ETH_LINK_FIXED 0
320 #define ETH_LINK_AUTONEG 1
326 struct rte_eth_thresh {
327  uint8_t pthresh;
328  uint8_t hthresh;
329  uint8_t wthresh;
330 };
331 
335 #define ETH_MQ_RX_RSS_FLAG 0x1
336 #define ETH_MQ_RX_DCB_FLAG 0x2
337 #define ETH_MQ_RX_VMDQ_FLAG 0x4
338 
346 
350  ETH_MQ_RX_DCB = ETH_MQ_RX_DCB_FLAG,
352  ETH_MQ_RX_DCB_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_DCB_FLAG,
353 
355  ETH_MQ_RX_VMDQ_ONLY = ETH_MQ_RX_VMDQ_FLAG,
357  ETH_MQ_RX_VMDQ_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_VMDQ_FLAG,
359  ETH_MQ_RX_VMDQ_DCB = ETH_MQ_RX_VMDQ_FLAG | ETH_MQ_RX_DCB_FLAG,
362  ETH_MQ_RX_VMDQ_FLAG,
363 };
364 
368 #define ETH_RSS ETH_MQ_RX_RSS
369 #define VMDQ_DCB ETH_MQ_RX_VMDQ_DCB
370 #define ETH_DCB_RX ETH_MQ_RX_DCB
371 
381 };
382 
386 #define ETH_DCB_NONE ETH_MQ_TX_NONE
387 #define ETH_VMDQ_DCB_TX ETH_MQ_TX_VMDQ_DCB
388 #define ETH_DCB_TX ETH_MQ_TX_DCB
389 
396  uint32_t max_rx_pkt_len;
397  uint16_t split_hdr_size;
403  uint64_t offloads;
404 };
405 
411  ETH_VLAN_TYPE_UNKNOWN = 0,
414  ETH_VLAN_TYPE_MAX,
415 };
416 
422  uint64_t ids[64];
423 };
424 
443  uint8_t *rss_key;
444  uint8_t rss_key_len;
445  uint64_t rss_hf;
446 };
447 
448 /*
449  * The RSS offload types are defined based on flow types which are defined
450  * in rte_eth_ctrl.h. Different NIC hardwares may support different RSS offload
451  * types. The supported flow types or RSS offload types can be queried by
452  * rte_eth_dev_info_get().
453  */
454 #define ETH_RSS_IPV4 (1ULL << RTE_ETH_FLOW_IPV4)
455 #define ETH_RSS_FRAG_IPV4 (1ULL << RTE_ETH_FLOW_FRAG_IPV4)
456 #define ETH_RSS_NONFRAG_IPV4_TCP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_TCP)
457 #define ETH_RSS_NONFRAG_IPV4_UDP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_UDP)
458 #define ETH_RSS_NONFRAG_IPV4_SCTP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_SCTP)
459 #define ETH_RSS_NONFRAG_IPV4_OTHER (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_OTHER)
460 #define ETH_RSS_IPV6 (1ULL << RTE_ETH_FLOW_IPV6)
461 #define ETH_RSS_FRAG_IPV6 (1ULL << RTE_ETH_FLOW_FRAG_IPV6)
462 #define ETH_RSS_NONFRAG_IPV6_TCP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_TCP)
463 #define ETH_RSS_NONFRAG_IPV6_UDP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_UDP)
464 #define ETH_RSS_NONFRAG_IPV6_SCTP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_SCTP)
465 #define ETH_RSS_NONFRAG_IPV6_OTHER (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_OTHER)
466 #define ETH_RSS_L2_PAYLOAD (1ULL << RTE_ETH_FLOW_L2_PAYLOAD)
467 #define ETH_RSS_IPV6_EX (1ULL << RTE_ETH_FLOW_IPV6_EX)
468 #define ETH_RSS_IPV6_TCP_EX (1ULL << RTE_ETH_FLOW_IPV6_TCP_EX)
469 #define ETH_RSS_IPV6_UDP_EX (1ULL << RTE_ETH_FLOW_IPV6_UDP_EX)
470 #define ETH_RSS_PORT (1ULL << RTE_ETH_FLOW_PORT)
471 #define ETH_RSS_VXLAN (1ULL << RTE_ETH_FLOW_VXLAN)
472 #define ETH_RSS_GENEVE (1ULL << RTE_ETH_FLOW_GENEVE)
473 #define ETH_RSS_NVGRE (1ULL << RTE_ETH_FLOW_NVGRE)
474 
475 #define ETH_RSS_IP ( \
476  ETH_RSS_IPV4 | \
477  ETH_RSS_FRAG_IPV4 | \
478  ETH_RSS_NONFRAG_IPV4_OTHER | \
479  ETH_RSS_IPV6 | \
480  ETH_RSS_FRAG_IPV6 | \
481  ETH_RSS_NONFRAG_IPV6_OTHER | \
482  ETH_RSS_IPV6_EX)
483 
484 #define ETH_RSS_UDP ( \
485  ETH_RSS_NONFRAG_IPV4_UDP | \
486  ETH_RSS_NONFRAG_IPV6_UDP | \
487  ETH_RSS_IPV6_UDP_EX)
488 
489 #define ETH_RSS_TCP ( \
490  ETH_RSS_NONFRAG_IPV4_TCP | \
491  ETH_RSS_NONFRAG_IPV6_TCP | \
492  ETH_RSS_IPV6_TCP_EX)
493 
494 #define ETH_RSS_SCTP ( \
495  ETH_RSS_NONFRAG_IPV4_SCTP | \
496  ETH_RSS_NONFRAG_IPV6_SCTP)
497 
498 #define ETH_RSS_TUNNEL ( \
499  ETH_RSS_VXLAN | \
500  ETH_RSS_GENEVE | \
501  ETH_RSS_NVGRE)
502 
504 #define ETH_RSS_PROTO_MASK ( \
505  ETH_RSS_IPV4 | \
506  ETH_RSS_FRAG_IPV4 | \
507  ETH_RSS_NONFRAG_IPV4_TCP | \
508  ETH_RSS_NONFRAG_IPV4_UDP | \
509  ETH_RSS_NONFRAG_IPV4_SCTP | \
510  ETH_RSS_NONFRAG_IPV4_OTHER | \
511  ETH_RSS_IPV6 | \
512  ETH_RSS_FRAG_IPV6 | \
513  ETH_RSS_NONFRAG_IPV6_TCP | \
514  ETH_RSS_NONFRAG_IPV6_UDP | \
515  ETH_RSS_NONFRAG_IPV6_SCTP | \
516  ETH_RSS_NONFRAG_IPV6_OTHER | \
517  ETH_RSS_L2_PAYLOAD | \
518  ETH_RSS_IPV6_EX | \
519  ETH_RSS_IPV6_TCP_EX | \
520  ETH_RSS_IPV6_UDP_EX | \
521  ETH_RSS_PORT | \
522  ETH_RSS_VXLAN | \
523  ETH_RSS_GENEVE | \
524  ETH_RSS_NVGRE)
525 
526 /*
527  * Definitions used for redirection table entry size.
528  * Some RSS RETA sizes may not be supported by some drivers, check the
529  * documentation or the description of relevant functions for more details.
530  */
531 #define ETH_RSS_RETA_SIZE_64 64
532 #define ETH_RSS_RETA_SIZE_128 128
533 #define ETH_RSS_RETA_SIZE_256 256
534 #define ETH_RSS_RETA_SIZE_512 512
535 #define RTE_RETA_GROUP_SIZE 64
536 
537 /* Definitions used for VMDQ and DCB functionality */
538 #define ETH_VMDQ_MAX_VLAN_FILTERS 64
539 #define ETH_DCB_NUM_USER_PRIORITIES 8
540 #define ETH_VMDQ_DCB_NUM_QUEUES 128
541 #define ETH_DCB_NUM_QUEUES 128
543 /* DCB capability defines */
544 #define ETH_DCB_PG_SUPPORT 0x00000001
545 #define ETH_DCB_PFC_SUPPORT 0x00000002
547 /* Definitions used for VLAN Offload functionality */
548 #define ETH_VLAN_STRIP_OFFLOAD 0x0001
549 #define ETH_VLAN_FILTER_OFFLOAD 0x0002
550 #define ETH_VLAN_EXTEND_OFFLOAD 0x0004
552 /* Definitions used for mask VLAN setting */
553 #define ETH_VLAN_STRIP_MASK 0x0001
554 #define ETH_VLAN_FILTER_MASK 0x0002
555 #define ETH_VLAN_EXTEND_MASK 0x0004
556 #define ETH_VLAN_ID_MAX 0x0FFF
558 /* Definitions used for receive MAC address */
559 #define ETH_NUM_RECEIVE_MAC_ADDR 128
561 /* Definitions used for unicast hash */
562 #define ETH_VMDQ_NUM_UC_HASH_ARRAY 128
564 /* Definitions used for VMDQ pool rx mode setting */
565 #define ETH_VMDQ_ACCEPT_UNTAG 0x0001
566 #define ETH_VMDQ_ACCEPT_HASH_MC 0x0002
567 #define ETH_VMDQ_ACCEPT_HASH_UC 0x0004
568 #define ETH_VMDQ_ACCEPT_BROADCAST 0x0008
569 #define ETH_VMDQ_ACCEPT_MULTICAST 0x0010
572 #define ETH_MIRROR_MAX_VLANS 64
573 
574 #define ETH_MIRROR_VIRTUAL_POOL_UP 0x01
575 #define ETH_MIRROR_UPLINK_PORT 0x02
576 #define ETH_MIRROR_DOWNLINK_PORT 0x04
577 #define ETH_MIRROR_VLAN 0x08
578 #define ETH_MIRROR_VIRTUAL_POOL_DOWN 0x10
583 struct rte_eth_vlan_mirror {
584  uint64_t vlan_mask;
586  uint16_t vlan_id[ETH_MIRROR_MAX_VLANS];
587 };
588 
593  uint8_t rule_type;
594  uint8_t dst_pool;
595  uint64_t pool_mask;
598 };
599 
607  uint64_t mask;
609  uint16_t reta[RTE_RETA_GROUP_SIZE];
611 };
612 
618  ETH_4_TCS = 4,
620 };
621 
631 };
632 
633 /* This structure may be extended in future. */
634 struct rte_eth_dcb_rx_conf {
635  enum rte_eth_nb_tcs nb_tcs;
637  uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
638 };
639 
640 struct rte_eth_vmdq_dcb_tx_conf {
641  enum rte_eth_nb_pools nb_queue_pools;
643  uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
644 };
645 
646 struct rte_eth_dcb_tx_conf {
647  enum rte_eth_nb_tcs nb_tcs;
649  uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
650 };
651 
652 struct rte_eth_vmdq_tx_conf {
653  enum rte_eth_nb_pools nb_queue_pools;
654 };
655 
670  uint8_t default_pool;
671  uint8_t nb_pool_maps;
672  struct {
673  uint16_t vlan_id;
674  uint64_t pools;
678 };
679 
701  uint8_t default_pool;
703  uint8_t nb_pool_maps;
704  uint32_t rx_mode;
705  struct {
706  uint16_t vlan_id;
707  uint64_t pools;
709 };
710 
721  uint64_t offloads;
722 
723  /* For i40e specifically */
724  uint16_t pvid;
725  __extension__
726  uint8_t hw_vlan_reject_tagged : 1,
732 };
733 
739  uint16_t rx_free_thresh;
740  uint8_t rx_drop_en;
747  uint64_t offloads;
748 };
749 
755  uint16_t tx_rs_thresh;
756  uint16_t tx_free_thresh;
765  uint64_t offloads;
766 };
767 
772  uint16_t nb_max;
773  uint16_t nb_min;
774  uint16_t nb_align;
784  uint16_t nb_seg_max;
785 
797  uint16_t nb_mtu_seg_max;
798 };
799 
808 };
809 
816  uint32_t high_water;
817  uint32_t low_water;
818  uint16_t pause_time;
819  uint16_t send_xon;
822  uint8_t autoneg;
823 };
824 
832  uint8_t priority;
833 };
834 
843 };
844 
852 };
853 
865  uint8_t drop_queue;
866  struct rte_eth_fdir_masks mask;
869 };
870 
879  uint16_t udp_port;
880  uint8_t prot_type;
881 };
882 
888  uint32_t lsc:1;
890  uint32_t rxq:1;
892  uint32_t rmv:1;
893 };
894 
900 struct rte_eth_conf {
901  uint32_t link_speeds;
910  uint32_t lpbk_mode;
915  struct {
919  struct rte_eth_dcb_rx_conf dcb_rx_conf;
923  } rx_adv_conf;
924  union {
925  struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf;
927  struct rte_eth_dcb_tx_conf dcb_tx_conf;
929  struct rte_eth_vmdq_tx_conf vmdq_tx_conf;
931  } tx_adv_conf;
937 };
938 
942 #define DEV_RX_OFFLOAD_VLAN_STRIP 0x00000001
943 #define DEV_RX_OFFLOAD_IPV4_CKSUM 0x00000002
944 #define DEV_RX_OFFLOAD_UDP_CKSUM 0x00000004
945 #define DEV_RX_OFFLOAD_TCP_CKSUM 0x00000008
946 #define DEV_RX_OFFLOAD_TCP_LRO 0x00000010
947 #define DEV_RX_OFFLOAD_QINQ_STRIP 0x00000020
948 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000040
949 #define DEV_RX_OFFLOAD_MACSEC_STRIP 0x00000080
950 #define DEV_RX_OFFLOAD_HEADER_SPLIT 0x00000100
951 #define DEV_RX_OFFLOAD_VLAN_FILTER 0x00000200
952 #define DEV_RX_OFFLOAD_VLAN_EXTEND 0x00000400
953 #define DEV_RX_OFFLOAD_JUMBO_FRAME 0x00000800
954 #define DEV_RX_OFFLOAD_SCATTER 0x00002000
955 #define DEV_RX_OFFLOAD_TIMESTAMP 0x00004000
956 #define DEV_RX_OFFLOAD_SECURITY 0x00008000
957 #define DEV_RX_OFFLOAD_KEEP_CRC 0x00010000
958 #define DEV_RX_OFFLOAD_SCTP_CKSUM 0x00020000
959 #define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM 0x00040000
960 
961 #define DEV_RX_OFFLOAD_CHECKSUM (DEV_RX_OFFLOAD_IPV4_CKSUM | \
962  DEV_RX_OFFLOAD_UDP_CKSUM | \
963  DEV_RX_OFFLOAD_TCP_CKSUM)
964 #define DEV_RX_OFFLOAD_VLAN (DEV_RX_OFFLOAD_VLAN_STRIP | \
965  DEV_RX_OFFLOAD_VLAN_FILTER | \
966  DEV_RX_OFFLOAD_VLAN_EXTEND)
967 
968 /*
969  * If new Rx offload capabilities are defined, they also must be
970  * mentioned in rte_rx_offload_names in rte_ethdev.c file.
971  */
972 
976 #define DEV_TX_OFFLOAD_VLAN_INSERT 0x00000001
977 #define DEV_TX_OFFLOAD_IPV4_CKSUM 0x00000002
978 #define DEV_TX_OFFLOAD_UDP_CKSUM 0x00000004
979 #define DEV_TX_OFFLOAD_TCP_CKSUM 0x00000008
980 #define DEV_TX_OFFLOAD_SCTP_CKSUM 0x00000010
981 #define DEV_TX_OFFLOAD_TCP_TSO 0x00000020
982 #define DEV_TX_OFFLOAD_UDP_TSO 0x00000040
983 #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080
984 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
985 #define DEV_TX_OFFLOAD_VXLAN_TNL_TSO 0x00000200
986 #define DEV_TX_OFFLOAD_GRE_TNL_TSO 0x00000400
987 #define DEV_TX_OFFLOAD_IPIP_TNL_TSO 0x00000800
988 #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO 0x00001000
989 #define DEV_TX_OFFLOAD_MACSEC_INSERT 0x00002000
990 #define DEV_TX_OFFLOAD_MT_LOCKFREE 0x00004000
991 
994 #define DEV_TX_OFFLOAD_MULTI_SEGS 0x00008000
995 
996 #define DEV_TX_OFFLOAD_MBUF_FAST_FREE 0x00010000
997 
1001 #define DEV_TX_OFFLOAD_SECURITY 0x00020000
1002 
1007 #define DEV_TX_OFFLOAD_UDP_TNL_TSO 0x00040000
1008 
1013 #define DEV_TX_OFFLOAD_IP_TNL_TSO 0x00080000
1014 
1015 #define DEV_TX_OFFLOAD_OUTER_UDP_CKSUM 0x00100000
1016 
1020 #define DEV_TX_OFFLOAD_MATCH_METADATA 0x00200000
1021 
1022 #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP 0x00000001
1023 
1024 #define RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP 0x00000002
1025 
1027 /*
1028  * If new Tx offload capabilities are defined, they also must be
1029  * mentioned in rte_tx_offload_names in rte_ethdev.c file.
1030  */
1031 
1032 /*
1033  * Fallback default preferred Rx/Tx port parameters.
1034  * These are used if an application requests default parameters
1035  * but the PMD does not provide preferred values.
1036  */
1037 #define RTE_ETH_DEV_FALLBACK_RX_RINGSIZE 512
1038 #define RTE_ETH_DEV_FALLBACK_TX_RINGSIZE 512
1039 #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
1040 #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
1041 
1048  uint16_t burst_size;
1049  uint16_t ring_size;
1050  uint16_t nb_queues;
1051 };
1052 
1057 #define RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID (0)
1058 
1063  const char *name;
1064  uint16_t domain_id;
1065  uint16_t port_id;
1073 };
1074 
1085  struct rte_device *device;
1086  const char *driver_name;
1087  unsigned int if_index;
1089  const uint32_t *dev_flags;
1090  uint32_t min_rx_bufsize;
1091  uint32_t max_rx_pktlen;
1092  uint16_t max_rx_queues;
1093  uint16_t max_tx_queues;
1094  uint32_t max_mac_addrs;
1095  uint32_t max_hash_mac_addrs;
1097  uint16_t max_vfs;
1098  uint16_t max_vmdq_pools;
1099  uint64_t rx_offload_capa;
1101  uint64_t tx_offload_capa;
1103  uint64_t rx_queue_offload_capa;
1105  uint64_t tx_queue_offload_capa;
1107  uint16_t reta_size;
1109  uint8_t hash_key_size;
1114  uint16_t vmdq_queue_base;
1115  uint16_t vmdq_queue_num;
1116  uint16_t vmdq_pool_base;
1119  uint32_t speed_capa;
1121  uint16_t nb_rx_queues;
1122  uint16_t nb_tx_queues;
1128  uint64_t dev_capa;
1134 };
1135 
1141  struct rte_mempool *mp;
1143  uint8_t scattered_rx;
1144  uint16_t nb_desc;
1146 
1153  uint16_t nb_desc;
1155 
1157 #define RTE_ETH_XSTATS_NAME_SIZE 64
1158 
1169  uint64_t id;
1170  uint64_t value;
1171 };
1172 
1182 };
1183 
1184 #define ETH_DCB_NUM_TCS 8
1185 #define ETH_MAX_VMDQ_POOL 64
1186 
1193  struct {
1194  uint8_t base;
1195  uint8_t nb_queue;
1196  } tc_rxq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
1198  struct {
1199  uint8_t base;
1200  uint8_t nb_queue;
1201  } tc_txq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
1202 };
1203 
1209  uint8_t nb_tcs;
1211  uint8_t tc_bws[ETH_DCB_NUM_TCS];
1214 };
1215 
1219 #define RTE_ETH_QUEUE_STATE_STOPPED 0
1220 #define RTE_ETH_QUEUE_STATE_STARTED 1
1221 
1222 #define RTE_ETH_ALL RTE_MAX_ETHPORTS
1223 
1224 /* Macros to check for valid port */
1225 #define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \
1226  if (!rte_eth_dev_is_valid_port(port_id)) { \
1227  RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
1228  return retval; \
1229  } \
1230 } while (0)
1231 
1232 #define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \
1233  if (!rte_eth_dev_is_valid_port(port_id)) { \
1234  RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
1235  return; \
1236  } \
1237 } while (0)
1238 
1244 #define ETH_L2_TUNNEL_ENABLE_MASK 0x00000001
1245 
1246 #define ETH_L2_TUNNEL_INSERTION_MASK 0x00000002
1247 
1248 #define ETH_L2_TUNNEL_STRIPPING_MASK 0x00000004
1249 
1250 #define ETH_L2_TUNNEL_FORWARDING_MASK 0x00000008
1251 
1274 typedef uint16_t (*rte_rx_callback_fn)(uint16_t port_id, uint16_t queue,
1275  struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts,
1276  void *user_param);
1277 
1298 typedef uint16_t (*rte_tx_callback_fn)(uint16_t port_id, uint16_t queue,
1299  struct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param);
1300 
1311 };
1312 
1313 struct rte_eth_dev_sriov {
1314  uint8_t active;
1315  uint8_t nb_q_per_pool;
1316  uint16_t def_vmdq_idx;
1317  uint16_t def_pool_q_idx;
1318 };
1319 #define RTE_ETH_DEV_SRIOV(dev) ((dev)->data->sriov)
1320 
1321 #define RTE_ETH_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
1322 
1323 #define RTE_ETH_DEV_NO_OWNER 0
1324 
1325 #define RTE_ETH_MAX_OWNER_NAME_LEN 64
1326 
1327 struct rte_eth_dev_owner {
1328  uint64_t id;
1329  char name[RTE_ETH_MAX_OWNER_NAME_LEN];
1330 };
1331 
1336 #define RTE_ETH_DEV_CLOSE_REMOVE 0x0001
1337 
1338 #define RTE_ETH_DEV_INTR_LSC 0x0002
1339 
1340 #define RTE_ETH_DEV_BONDED_SLAVE 0x0004
1341 
1342 #define RTE_ETH_DEV_INTR_RMV 0x0008
1343 
1344 #define RTE_ETH_DEV_REPRESENTOR 0x0010
1345 
1346 #define RTE_ETH_DEV_NOLIVE_MAC_ADDR 0x0020
1347 
1359 uint64_t rte_eth_find_next_owned_by(uint16_t port_id,
1360  const uint64_t owner_id);
1361 
1365 #define RTE_ETH_FOREACH_DEV_OWNED_BY(p, o) \
1366  for (p = rte_eth_find_next_owned_by(0, o); \
1367  (unsigned int)p < (unsigned int)RTE_MAX_ETHPORTS; \
1368  p = rte_eth_find_next_owned_by(p + 1, o))
1369 
1378 uint16_t rte_eth_find_next(uint16_t port_id);
1379 
1383 #define RTE_ETH_FOREACH_DEV(p) \
1384  RTE_ETH_FOREACH_DEV_OWNED_BY(p, RTE_ETH_DEV_NO_OWNER)
1385 
1386 
1400 int __rte_experimental rte_eth_dev_owner_new(uint64_t *owner_id);
1401 
1415 int __rte_experimental rte_eth_dev_owner_set(const uint16_t port_id,
1416  const struct rte_eth_dev_owner *owner);
1417 
1431 int __rte_experimental rte_eth_dev_owner_unset(const uint16_t port_id,
1432  const uint64_t owner_id);
1433 
1443 void __rte_experimental rte_eth_dev_owner_delete(const uint64_t owner_id);
1444 
1458 int __rte_experimental rte_eth_dev_owner_get(const uint16_t port_id,
1459  struct rte_eth_dev_owner *owner);
1460 
1473 __rte_deprecated
1474 uint16_t rte_eth_dev_count(void);
1475 
1486 uint16_t rte_eth_dev_count_avail(void);
1487 
1496 uint16_t __rte_experimental rte_eth_dev_count_total(void);
1497 
1509 uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
1510 
1519 const char *rte_eth_dev_rx_offload_name(uint64_t offload);
1520 
1529 const char *rte_eth_dev_tx_offload_name(uint64_t offload);
1530 
1570 int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue,
1571  uint16_t nb_tx_queue, const struct rte_eth_conf *eth_conf);
1572 
1584 int __rte_experimental
1585 rte_eth_dev_is_removed(uint16_t port_id);
1586 
1636 int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
1637  uint16_t nb_rx_desc, unsigned int socket_id,
1638  const struct rte_eth_rxconf *rx_conf,
1639  struct rte_mempool *mb_pool);
1640 
1689 int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
1690  uint16_t nb_tx_desc, unsigned int socket_id,
1691  const struct rte_eth_txconf *tx_conf);
1692 
1703 int rte_eth_dev_socket_id(uint16_t port_id);
1704 
1714 int rte_eth_dev_is_valid_port(uint16_t port_id);
1715 
1732 int rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id);
1733 
1749 int rte_eth_dev_rx_queue_stop(uint16_t port_id, uint16_t rx_queue_id);
1750 
1767 int rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id);
1768 
1784 int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);
1785 
1805 int rte_eth_dev_start(uint16_t port_id);
1806 
1814 void rte_eth_dev_stop(uint16_t port_id);
1815 
1828 int rte_eth_dev_set_link_up(uint16_t port_id);
1829 
1839 int rte_eth_dev_set_link_down(uint16_t port_id);
1840 
1849 void rte_eth_dev_close(uint16_t port_id);
1850 
1888 int rte_eth_dev_reset(uint16_t port_id);
1889 
1896 void rte_eth_promiscuous_enable(uint16_t port_id);
1897 
1904 void rte_eth_promiscuous_disable(uint16_t port_id);
1905 
1916 int rte_eth_promiscuous_get(uint16_t port_id);
1917 
1924 void rte_eth_allmulticast_enable(uint16_t port_id);
1925 
1932 void rte_eth_allmulticast_disable(uint16_t port_id);
1933 
1944 int rte_eth_allmulticast_get(uint16_t port_id);
1945 
1957 void rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
1958 
1970 void rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
1971 
1989 int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats);
1990 
2001 int rte_eth_stats_reset(uint16_t port_id);
2002 
2032 int rte_eth_xstats_get_names(uint16_t port_id,
2033  struct rte_eth_xstat_name *xstats_names,
2034  unsigned int size);
2035 
2065 int rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats,
2066  unsigned int n);
2067 
2090 int
2091 rte_eth_xstats_get_names_by_id(uint16_t port_id,
2092  struct rte_eth_xstat_name *xstats_names, unsigned int size,
2093  uint64_t *ids);
2094 
2118 int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
2119  uint64_t *values, unsigned int size);
2120 
2139 int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
2140  uint64_t *id);
2141 
2148 void rte_eth_xstats_reset(uint16_t port_id);
2149 
2167 int rte_eth_dev_set_tx_queue_stats_mapping(uint16_t port_id,
2168  uint16_t tx_queue_id, uint8_t stat_idx);
2169 
2187 int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t port_id,
2188  uint16_t rx_queue_id,
2189  uint8_t stat_idx);
2190 
2200 void rte_eth_macaddr_get(uint16_t port_id, struct ether_addr *mac_addr);
2201 
2211 void rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info);
2212 
2232 int rte_eth_dev_fw_version_get(uint16_t port_id,
2233  char *fw_version, size_t fw_size);
2234 
2273 int rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
2274  uint32_t *ptypes, int num);
2275 
2287 int rte_eth_dev_get_mtu(uint16_t port_id, uint16_t *mtu);
2288 
2304 int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu);
2305 
2325 int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on);
2326 
2346 int rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
2347  int on);
2348 
2366 int rte_eth_dev_set_vlan_ether_type(uint16_t port_id,
2367  enum rte_vlan_type vlan_type,
2368  uint16_t tag_type);
2369 
2391 int rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask);
2392 
2405 int rte_eth_dev_get_vlan_offload(uint16_t port_id);
2406 
2421 int rte_eth_dev_set_vlan_pvid(uint16_t port_id, uint16_t pvid, int on);
2422 
2423 typedef void (*buffer_tx_error_fn)(struct rte_mbuf **unsent, uint16_t count,
2424  void *userdata);
2425 
2431  buffer_tx_error_fn error_callback;
2432  void *error_userdata;
2433  uint16_t size;
2434  uint16_t length;
2435  struct rte_mbuf *pkts[];
2437 };
2438 
2445 #define RTE_ETH_TX_BUFFER_SIZE(sz) \
2446  (sizeof(struct rte_eth_dev_tx_buffer) + (sz) * sizeof(struct rte_mbuf *))
2447 
2458 int
2459 rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size);
2460 
2485 int
2487  buffer_tx_error_fn callback, void *userdata);
2488 
2511 void
2512 rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_t unsent,
2513  void *userdata);
2514 
2538 void
2539 rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent,
2540  void *userdata);
2541 
2567 int
2568 rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt);
2569 
2585 };
2586 
2594  uint64_t metadata;
2608 };
2609 
2627 };
2628 
2629 typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
2630  enum rte_eth_event_type event, void *cb_arg, void *ret_param);
2650 int rte_eth_dev_callback_register(uint16_t port_id,
2651  enum rte_eth_event_type event,
2652  rte_eth_dev_cb_fn cb_fn, void *cb_arg);
2653 
2672 int rte_eth_dev_callback_unregister(uint16_t port_id,
2673  enum rte_eth_event_type event,
2674  rte_eth_dev_cb_fn cb_fn, void *cb_arg);
2675 
2697 int rte_eth_dev_rx_intr_enable(uint16_t port_id, uint16_t queue_id);
2698 
2719 int rte_eth_dev_rx_intr_disable(uint16_t port_id, uint16_t queue_id);
2720 
2738 int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data);
2739 
2761 int rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id,
2762  int epfd, int op, void *data);
2763 
2781 int __rte_experimental
2782 rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id);
2783 
2797 int rte_eth_led_on(uint16_t port_id);
2798 
2812 int rte_eth_led_off(uint16_t port_id);
2813 
2827 int rte_eth_dev_flow_ctrl_get(uint16_t port_id,
2828  struct rte_eth_fc_conf *fc_conf);
2829 
2844 int rte_eth_dev_flow_ctrl_set(uint16_t port_id,
2845  struct rte_eth_fc_conf *fc_conf);
2846 
2862 int rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id,
2863  struct rte_eth_pfc_conf *pfc_conf);
2864 
2884 int rte_eth_dev_mac_addr_add(uint16_t port_id, struct ether_addr *mac_addr,
2885  uint32_t pool);
2886 
2900 int rte_eth_dev_mac_addr_remove(uint16_t port_id, struct ether_addr *mac_addr);
2901 
2915 int rte_eth_dev_default_mac_addr_set(uint16_t port_id,
2916  struct ether_addr *mac_addr);
2917 
2934 int rte_eth_dev_rss_reta_update(uint16_t port_id,
2935  struct rte_eth_rss_reta_entry64 *reta_conf,
2936  uint16_t reta_size);
2937 
2954 int rte_eth_dev_rss_reta_query(uint16_t port_id,
2955  struct rte_eth_rss_reta_entry64 *reta_conf,
2956  uint16_t reta_size);
2957 
2977 int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct ether_addr *addr,
2978  uint8_t on);
2979 
2998 int rte_eth_dev_uc_all_hash_table_set(uint16_t port_id, uint8_t on);
2999 
3022 int rte_eth_mirror_rule_set(uint16_t port_id,
3023  struct rte_eth_mirror_conf *mirror_conf,
3024  uint8_t rule_id,
3025  uint8_t on);
3026 
3041 int rte_eth_mirror_rule_reset(uint16_t port_id,
3042  uint8_t rule_id);
3043 
3060 int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
3061  uint16_t tx_rate);
3062 
3077 int rte_eth_dev_rss_hash_update(uint16_t port_id,
3078  struct rte_eth_rss_conf *rss_conf);
3079 
3094 int
3095 rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
3096  struct rte_eth_rss_conf *rss_conf);
3097 
3116 int
3117 rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
3118  struct rte_eth_udp_tunnel *tunnel_udp);
3119 
3139 int
3140 rte_eth_dev_udp_tunnel_port_delete(uint16_t port_id,
3141  struct rte_eth_udp_tunnel *tunnel_udp);
3142 
3157 int rte_eth_dev_filter_supported(uint16_t port_id,
3158  enum rte_filter_type filter_type);
3159 
3179 int rte_eth_dev_filter_ctrl(uint16_t port_id, enum rte_filter_type filter_type,
3180  enum rte_filter_op filter_op, void *arg);
3181 
3195 int rte_eth_dev_get_dcb_info(uint16_t port_id,
3196  struct rte_eth_dcb_info *dcb_info);
3197 
3198 struct rte_eth_rxtx_callback;
3199 
3224 const struct rte_eth_rxtx_callback *
3225 rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
3226  rte_rx_callback_fn fn, void *user_param);
3227 
3253 const struct rte_eth_rxtx_callback *
3254 rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id,
3255  rte_rx_callback_fn fn, void *user_param);
3256 
3281 const struct rte_eth_rxtx_callback *
3282 rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
3283  rte_tx_callback_fn fn, void *user_param);
3284 
3315 int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
3316  const struct rte_eth_rxtx_callback *user_cb);
3317 
3348 int rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
3349  const struct rte_eth_rxtx_callback *user_cb);
3350 
3368 int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
3369  struct rte_eth_rxq_info *qinfo);
3370 
3388 int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
3389  struct rte_eth_txq_info *qinfo);
3390 
3408 int rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info);
3409 
3422 int rte_eth_dev_get_eeprom_length(uint16_t port_id);
3423 
3439 int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
3440 
3456 int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
3457 
3475 int __rte_experimental
3476 rte_eth_dev_get_module_info(uint16_t port_id,
3477  struct rte_eth_dev_module_info *modinfo);
3478 
3497 int __rte_experimental
3498 rte_eth_dev_get_module_eeprom(uint16_t port_id,
3499  struct rte_dev_eeprom_info *info);
3500 
3519 int rte_eth_dev_set_mc_addr_list(uint16_t port_id,
3520  struct ether_addr *mc_addr_set,
3521  uint32_t nb_mc_addr);
3522 
3535 int rte_eth_timesync_enable(uint16_t port_id);
3536 
3549 int rte_eth_timesync_disable(uint16_t port_id);
3550 
3569 int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,
3570  struct timespec *timestamp, uint32_t flags);
3571 
3587 int rte_eth_timesync_read_tx_timestamp(uint16_t port_id,
3588  struct timespec *timestamp);
3589 
3607 int rte_eth_timesync_adjust_time(uint16_t port_id, int64_t delta);
3608 
3623 int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time);
3624 
3643 int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);
3644 
3660 int
3661 rte_eth_dev_l2_tunnel_eth_type_conf(uint16_t port_id,
3662  struct rte_eth_l2_tunnel_conf *l2_tunnel);
3663 
3688 int
3689 rte_eth_dev_l2_tunnel_offload_set(uint16_t port_id,
3690  struct rte_eth_l2_tunnel_conf *l2_tunnel,
3691  uint32_t mask,
3692  uint8_t en);
3693 
3709 int
3710 rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id);
3711 
3726 int
3727 rte_eth_dev_get_name_by_port(uint16_t port_id, char *name);
3728 
3745 int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id,
3746  uint16_t *nb_rx_desc,
3747  uint16_t *nb_tx_desc);
3748 
3763 int
3764 rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool);
3765 
3775 void *
3776 rte_eth_dev_get_sec_ctx(uint16_t port_id);
3777 
3778 
3779 #include <rte_ethdev_core.h>
3780 
3863 static inline uint16_t
3864 rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
3865  struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
3866 {
3867  struct rte_eth_dev *dev = &rte_eth_devices[port_id];
3868  uint16_t nb_rx;
3869 
3870 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
3871  RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
3872  RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
3873 
3874  if (queue_id >= dev->data->nb_rx_queues) {
3875  RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", queue_id);
3876  return 0;
3877  }
3878 #endif
3879  nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
3880  rx_pkts, nb_pkts);
3881 
3882 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
3883  if (unlikely(dev->post_rx_burst_cbs[queue_id] != NULL)) {
3884  struct rte_eth_rxtx_callback *cb =
3885  dev->post_rx_burst_cbs[queue_id];
3886 
3887  do {
3888  nb_rx = cb->fn.rx(port_id, queue_id, rx_pkts, nb_rx,
3889  nb_pkts, cb->param);
3890  cb = cb->next;
3891  } while (cb != NULL);
3892  }
3893 #endif
3894 
3895  return nb_rx;
3896 }
3897 
3910 static inline int
3911 rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id)
3912 {
3913  struct rte_eth_dev *dev;
3914 
3915  RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
3916  dev = &rte_eth_devices[port_id];
3917  RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
3918  if (queue_id >= dev->data->nb_rx_queues)
3919  return -EINVAL;
3920 
3921  return (int)(*dev->dev_ops->rx_queue_count)(dev, queue_id);
3922 }
3923 
3939 static inline int
3940 rte_eth_rx_descriptor_done(uint16_t port_id, uint16_t queue_id, uint16_t offset)
3941 {
3942  struct rte_eth_dev *dev = &rte_eth_devices[port_id];
3943  RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
3944  RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
3945  return (*dev->dev_ops->rx_descriptor_done)( \
3946  dev->data->rx_queues[queue_id], offset);
3947 }
3948 
3949 #define RTE_ETH_RX_DESC_AVAIL 0
3950 #define RTE_ETH_RX_DESC_DONE 1
3951 #define RTE_ETH_RX_DESC_UNAVAIL 2
3986 static inline int
3987 rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
3988  uint16_t offset)
3989 {
3990  struct rte_eth_dev *dev;
3991  void *rxq;
3992 
3993 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
3994  RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
3995 #endif
3996  dev = &rte_eth_devices[port_id];
3997 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
3998  if (queue_id >= dev->data->nb_rx_queues)
3999  return -ENODEV;
4000 #endif
4001  RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_status, -ENOTSUP);
4002  rxq = dev->data->rx_queues[queue_id];
4003 
4004  return (*dev->dev_ops->rx_descriptor_status)(rxq, offset);
4005 }
4006 
4007 #define RTE_ETH_TX_DESC_FULL 0
4008 #define RTE_ETH_TX_DESC_DONE 1
4009 #define RTE_ETH_TX_DESC_UNAVAIL 2
4044 static inline int rte_eth_tx_descriptor_status(uint16_t port_id,
4045  uint16_t queue_id, uint16_t offset)
4046 {
4047  struct rte_eth_dev *dev;
4048  void *txq;
4049 
4050 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
4051  RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
4052 #endif
4053  dev = &rte_eth_devices[port_id];
4054 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
4055  if (queue_id >= dev->data->nb_tx_queues)
4056  return -ENODEV;
4057 #endif
4058  RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_descriptor_status, -ENOTSUP);
4059  txq = dev->data->tx_queues[queue_id];
4060 
4061  return (*dev->dev_ops->tx_descriptor_status)(txq, offset);
4062 }
4063 
4130 static inline uint16_t
4131 rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
4132  struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
4133 {
4134  struct rte_eth_dev *dev = &rte_eth_devices[port_id];
4135 
4136 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
4137  RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
4138  RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
4139 
4140  if (queue_id >= dev->data->nb_tx_queues) {
4141  RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", queue_id);
4142  return 0;
4143  }
4144 #endif
4145 
4146 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
4147  struct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id];
4148 
4149  if (unlikely(cb != NULL)) {
4150  do {
4151  nb_pkts = cb->fn.tx(port_id, queue_id, tx_pkts, nb_pkts,
4152  cb->param);
4153  cb = cb->next;
4154  } while (cb != NULL);
4155  }
4156 #endif
4157 
4158  return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
4159 }
4160 
4214 #ifndef RTE_ETHDEV_TX_PREPARE_NOOP
4215 
4216 static inline uint16_t
4217 rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id,
4218  struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
4219 {
4220  struct rte_eth_dev *dev;
4221 
4222 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
4223  if (!rte_eth_dev_is_valid_port(port_id)) {
4224  RTE_ETHDEV_LOG(ERR, "Invalid TX port_id=%u\n", port_id);
4225  rte_errno = EINVAL;
4226  return 0;
4227  }
4228 #endif
4229 
4230  dev = &rte_eth_devices[port_id];
4231 
4232 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
4233  if (queue_id >= dev->data->nb_tx_queues) {
4234  RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", queue_id);
4235  rte_errno = EINVAL;
4236  return 0;
4237  }
4238 #endif
4239 
4240  if (!dev->tx_pkt_prepare)
4241  return nb_pkts;
4242 
4243  return (*dev->tx_pkt_prepare)(dev->data->tx_queues[queue_id],
4244  tx_pkts, nb_pkts);
4245 }
4246 
4247 #else
4248 
4249 /*
4250  * Native NOOP operation for compilation targets which doesn't require any
4251  * preparations steps, and functional NOOP may introduce unnecessary performance
4252  * drop.
4253  *
4254  * Generally this is not a good idea to turn it on globally and didn't should
4255  * be used if behavior of tx_preparation can change.
4256  */
4257 
4258 static inline uint16_t
4259 rte_eth_tx_prepare(__rte_unused uint16_t port_id,
4260  __rte_unused uint16_t queue_id,
4261  __rte_unused struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
4262 {
4263  return nb_pkts;
4264 }
4265 
4266 #endif
4267 
4290 static inline uint16_t
4291 rte_eth_tx_buffer_flush(uint16_t port_id, uint16_t queue_id,
4292  struct rte_eth_dev_tx_buffer *buffer)
4293 {
4294  uint16_t sent;
4295  uint16_t to_send = buffer->length;
4296 
4297  if (to_send == 0)
4298  return 0;
4299 
4300  sent = rte_eth_tx_burst(port_id, queue_id, buffer->pkts, to_send);
4301 
4302  buffer->length = 0;
4303 
4304  /* All packets sent, or to be dealt with by callback below */
4305  if (unlikely(sent != to_send))
4306  buffer->error_callback(&buffer->pkts[sent],
4307  (uint16_t)(to_send - sent),
4308  buffer->error_userdata);
4309 
4310  return sent;
4311 }
4312 
4343 static __rte_always_inline uint16_t
4344 rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,
4345  struct rte_eth_dev_tx_buffer *buffer, struct rte_mbuf *tx_pkt)
4346 {
4347  buffer->pkts[buffer->length++] = tx_pkt;
4348  if (buffer->length < buffer->size)
4349  return 0;
4350 
4351  return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
4352 }
4353 
4354 #ifdef __cplusplus
4355 }
4356 #endif
4357 
4358 #endif /* _RTE_ETHDEV_H_ */