DPDK  18.08.1
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 
176  uint64_t ipackets;
177  uint64_t opackets;
178  uint64_t ibytes;
179  uint64_t obytes;
180  uint64_t imissed;
184  uint64_t ierrors;
185  uint64_t oerrors;
186  uint64_t rx_nombuf;
187  uint64_t q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
189  uint64_t q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
191  uint64_t q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
193  uint64_t q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
195  uint64_t q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
197 };
198 
202 #define ETH_LINK_SPEED_AUTONEG (0 << 0)
203 #define ETH_LINK_SPEED_FIXED (1 << 0)
204 #define ETH_LINK_SPEED_10M_HD (1 << 1)
205 #define ETH_LINK_SPEED_10M (1 << 2)
206 #define ETH_LINK_SPEED_100M_HD (1 << 3)
207 #define ETH_LINK_SPEED_100M (1 << 4)
208 #define ETH_LINK_SPEED_1G (1 << 5)
209 #define ETH_LINK_SPEED_2_5G (1 << 6)
210 #define ETH_LINK_SPEED_5G (1 << 7)
211 #define ETH_LINK_SPEED_10G (1 << 8)
212 #define ETH_LINK_SPEED_20G (1 << 9)
213 #define ETH_LINK_SPEED_25G (1 << 10)
214 #define ETH_LINK_SPEED_40G (1 << 11)
215 #define ETH_LINK_SPEED_50G (1 << 12)
216 #define ETH_LINK_SPEED_56G (1 << 13)
217 #define ETH_LINK_SPEED_100G (1 << 14)
222 #define ETH_SPEED_NUM_NONE 0
223 #define ETH_SPEED_NUM_10M 10
224 #define ETH_SPEED_NUM_100M 100
225 #define ETH_SPEED_NUM_1G 1000
226 #define ETH_SPEED_NUM_2_5G 2500
227 #define ETH_SPEED_NUM_5G 5000
228 #define ETH_SPEED_NUM_10G 10000
229 #define ETH_SPEED_NUM_20G 20000
230 #define ETH_SPEED_NUM_25G 25000
231 #define ETH_SPEED_NUM_40G 40000
232 #define ETH_SPEED_NUM_50G 50000
233 #define ETH_SPEED_NUM_56G 56000
234 #define ETH_SPEED_NUM_100G 100000
239 __extension__
240 struct rte_eth_link {
241  uint32_t link_speed;
242  uint16_t link_duplex : 1;
243  uint16_t link_autoneg : 1;
244  uint16_t link_status : 1;
245 } __attribute__((aligned(8)));
247 /* Utility constants */
248 #define ETH_LINK_HALF_DUPLEX 0
249 #define ETH_LINK_FULL_DUPLEX 1
250 #define ETH_LINK_DOWN 0
251 #define ETH_LINK_UP 1
252 #define ETH_LINK_FIXED 0
253 #define ETH_LINK_AUTONEG 1
259 struct rte_eth_thresh {
260  uint8_t pthresh;
261  uint8_t hthresh;
262  uint8_t wthresh;
263 };
264 
268 #define ETH_MQ_RX_RSS_FLAG 0x1
269 #define ETH_MQ_RX_DCB_FLAG 0x2
270 #define ETH_MQ_RX_VMDQ_FLAG 0x4
271 
279 
283  ETH_MQ_RX_DCB = ETH_MQ_RX_DCB_FLAG,
285  ETH_MQ_RX_DCB_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_DCB_FLAG,
286 
288  ETH_MQ_RX_VMDQ_ONLY = ETH_MQ_RX_VMDQ_FLAG,
290  ETH_MQ_RX_VMDQ_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_VMDQ_FLAG,
292  ETH_MQ_RX_VMDQ_DCB = ETH_MQ_RX_VMDQ_FLAG | ETH_MQ_RX_DCB_FLAG,
295  ETH_MQ_RX_VMDQ_FLAG,
296 };
297 
301 #define ETH_RSS ETH_MQ_RX_RSS
302 #define VMDQ_DCB ETH_MQ_RX_VMDQ_DCB
303 #define ETH_DCB_RX ETH_MQ_RX_DCB
304 
314 };
315 
319 #define ETH_DCB_NONE ETH_MQ_TX_NONE
320 #define ETH_VMDQ_DCB_TX ETH_MQ_TX_VMDQ_DCB
321 #define ETH_DCB_TX ETH_MQ_TX_DCB
322 
329  uint32_t max_rx_pkt_len;
330  uint16_t split_hdr_size;
336  uint64_t offloads;
337 };
338 
344  ETH_VLAN_TYPE_UNKNOWN = 0,
347  ETH_VLAN_TYPE_MAX,
348 };
349 
355  uint64_t ids[64];
356 };
357 
376  uint8_t *rss_key;
377  uint8_t rss_key_len;
378  uint64_t rss_hf;
379 };
380 
381 /*
382  * The RSS offload types are defined based on flow types which are defined
383  * in rte_eth_ctrl.h. Different NIC hardwares may support different RSS offload
384  * types. The supported flow types or RSS offload types can be queried by
385  * rte_eth_dev_info_get().
386  */
387 #define ETH_RSS_IPV4 (1ULL << RTE_ETH_FLOW_IPV4)
388 #define ETH_RSS_FRAG_IPV4 (1ULL << RTE_ETH_FLOW_FRAG_IPV4)
389 #define ETH_RSS_NONFRAG_IPV4_TCP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_TCP)
390 #define ETH_RSS_NONFRAG_IPV4_UDP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_UDP)
391 #define ETH_RSS_NONFRAG_IPV4_SCTP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_SCTP)
392 #define ETH_RSS_NONFRAG_IPV4_OTHER (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_OTHER)
393 #define ETH_RSS_IPV6 (1ULL << RTE_ETH_FLOW_IPV6)
394 #define ETH_RSS_FRAG_IPV6 (1ULL << RTE_ETH_FLOW_FRAG_IPV6)
395 #define ETH_RSS_NONFRAG_IPV6_TCP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_TCP)
396 #define ETH_RSS_NONFRAG_IPV6_UDP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_UDP)
397 #define ETH_RSS_NONFRAG_IPV6_SCTP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_SCTP)
398 #define ETH_RSS_NONFRAG_IPV6_OTHER (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_OTHER)
399 #define ETH_RSS_L2_PAYLOAD (1ULL << RTE_ETH_FLOW_L2_PAYLOAD)
400 #define ETH_RSS_IPV6_EX (1ULL << RTE_ETH_FLOW_IPV6_EX)
401 #define ETH_RSS_IPV6_TCP_EX (1ULL << RTE_ETH_FLOW_IPV6_TCP_EX)
402 #define ETH_RSS_IPV6_UDP_EX (1ULL << RTE_ETH_FLOW_IPV6_UDP_EX)
403 #define ETH_RSS_PORT (1ULL << RTE_ETH_FLOW_PORT)
404 #define ETH_RSS_VXLAN (1ULL << RTE_ETH_FLOW_VXLAN)
405 #define ETH_RSS_GENEVE (1ULL << RTE_ETH_FLOW_GENEVE)
406 #define ETH_RSS_NVGRE (1ULL << RTE_ETH_FLOW_NVGRE)
407 
408 #define ETH_RSS_IP ( \
409  ETH_RSS_IPV4 | \
410  ETH_RSS_FRAG_IPV4 | \
411  ETH_RSS_NONFRAG_IPV4_OTHER | \
412  ETH_RSS_IPV6 | \
413  ETH_RSS_FRAG_IPV6 | \
414  ETH_RSS_NONFRAG_IPV6_OTHER | \
415  ETH_RSS_IPV6_EX)
416 
417 #define ETH_RSS_UDP ( \
418  ETH_RSS_NONFRAG_IPV4_UDP | \
419  ETH_RSS_NONFRAG_IPV6_UDP | \
420  ETH_RSS_IPV6_UDP_EX)
421 
422 #define ETH_RSS_TCP ( \
423  ETH_RSS_NONFRAG_IPV4_TCP | \
424  ETH_RSS_NONFRAG_IPV6_TCP | \
425  ETH_RSS_IPV6_TCP_EX)
426 
427 #define ETH_RSS_SCTP ( \
428  ETH_RSS_NONFRAG_IPV4_SCTP | \
429  ETH_RSS_NONFRAG_IPV6_SCTP)
430 
431 #define ETH_RSS_TUNNEL ( \
432  ETH_RSS_VXLAN | \
433  ETH_RSS_GENEVE | \
434  ETH_RSS_NVGRE)
435 
437 #define ETH_RSS_PROTO_MASK ( \
438  ETH_RSS_IPV4 | \
439  ETH_RSS_FRAG_IPV4 | \
440  ETH_RSS_NONFRAG_IPV4_TCP | \
441  ETH_RSS_NONFRAG_IPV4_UDP | \
442  ETH_RSS_NONFRAG_IPV4_SCTP | \
443  ETH_RSS_NONFRAG_IPV4_OTHER | \
444  ETH_RSS_IPV6 | \
445  ETH_RSS_FRAG_IPV6 | \
446  ETH_RSS_NONFRAG_IPV6_TCP | \
447  ETH_RSS_NONFRAG_IPV6_UDP | \
448  ETH_RSS_NONFRAG_IPV6_SCTP | \
449  ETH_RSS_NONFRAG_IPV6_OTHER | \
450  ETH_RSS_L2_PAYLOAD | \
451  ETH_RSS_IPV6_EX | \
452  ETH_RSS_IPV6_TCP_EX | \
453  ETH_RSS_IPV6_UDP_EX | \
454  ETH_RSS_PORT | \
455  ETH_RSS_VXLAN | \
456  ETH_RSS_GENEVE | \
457  ETH_RSS_NVGRE)
458 
459 /*
460  * Definitions used for redirection table entry size.
461  * Some RSS RETA sizes may not be supported by some drivers, check the
462  * documentation or the description of relevant functions for more details.
463  */
464 #define ETH_RSS_RETA_SIZE_64 64
465 #define ETH_RSS_RETA_SIZE_128 128
466 #define ETH_RSS_RETA_SIZE_256 256
467 #define ETH_RSS_RETA_SIZE_512 512
468 #define RTE_RETA_GROUP_SIZE 64
469 
470 /* Definitions used for VMDQ and DCB functionality */
471 #define ETH_VMDQ_MAX_VLAN_FILTERS 64
472 #define ETH_DCB_NUM_USER_PRIORITIES 8
473 #define ETH_VMDQ_DCB_NUM_QUEUES 128
474 #define ETH_DCB_NUM_QUEUES 128
476 /* DCB capability defines */
477 #define ETH_DCB_PG_SUPPORT 0x00000001
478 #define ETH_DCB_PFC_SUPPORT 0x00000002
480 /* Definitions used for VLAN Offload functionality */
481 #define ETH_VLAN_STRIP_OFFLOAD 0x0001
482 #define ETH_VLAN_FILTER_OFFLOAD 0x0002
483 #define ETH_VLAN_EXTEND_OFFLOAD 0x0004
485 /* Definitions used for mask VLAN setting */
486 #define ETH_VLAN_STRIP_MASK 0x0001
487 #define ETH_VLAN_FILTER_MASK 0x0002
488 #define ETH_VLAN_EXTEND_MASK 0x0004
489 #define ETH_VLAN_ID_MAX 0x0FFF
491 /* Definitions used for receive MAC address */
492 #define ETH_NUM_RECEIVE_MAC_ADDR 128
494 /* Definitions used for unicast hash */
495 #define ETH_VMDQ_NUM_UC_HASH_ARRAY 128
497 /* Definitions used for VMDQ pool rx mode setting */
498 #define ETH_VMDQ_ACCEPT_UNTAG 0x0001
499 #define ETH_VMDQ_ACCEPT_HASH_MC 0x0002
500 #define ETH_VMDQ_ACCEPT_HASH_UC 0x0004
501 #define ETH_VMDQ_ACCEPT_BROADCAST 0x0008
502 #define ETH_VMDQ_ACCEPT_MULTICAST 0x0010
505 #define ETH_MIRROR_MAX_VLANS 64
506 
507 #define ETH_MIRROR_VIRTUAL_POOL_UP 0x01
508 #define ETH_MIRROR_UPLINK_PORT 0x02
509 #define ETH_MIRROR_DOWNLINK_PORT 0x04
510 #define ETH_MIRROR_VLAN 0x08
511 #define ETH_MIRROR_VIRTUAL_POOL_DOWN 0x10
516 struct rte_eth_vlan_mirror {
517  uint64_t vlan_mask;
519  uint16_t vlan_id[ETH_MIRROR_MAX_VLANS];
520 };
521 
526  uint8_t rule_type;
527  uint8_t dst_pool;
528  uint64_t pool_mask;
531 };
532 
540  uint64_t mask;
542  uint16_t reta[RTE_RETA_GROUP_SIZE];
544 };
545 
551  ETH_4_TCS = 4,
553 };
554 
564 };
565 
566 /* This structure may be extended in future. */
567 struct rte_eth_dcb_rx_conf {
568  enum rte_eth_nb_tcs nb_tcs;
570  uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
571 };
572 
573 struct rte_eth_vmdq_dcb_tx_conf {
574  enum rte_eth_nb_pools nb_queue_pools;
576  uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
577 };
578 
579 struct rte_eth_dcb_tx_conf {
580  enum rte_eth_nb_tcs nb_tcs;
582  uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
583 };
584 
585 struct rte_eth_vmdq_tx_conf {
586  enum rte_eth_nb_pools nb_queue_pools;
587 };
588 
603  uint8_t default_pool;
604  uint8_t nb_pool_maps;
605  struct {
606  uint16_t vlan_id;
607  uint64_t pools;
611 };
612 
634  uint8_t default_pool;
636  uint8_t nb_pool_maps;
637  uint32_t rx_mode;
638  struct {
639  uint16_t vlan_id;
640  uint64_t pools;
642 };
643 
654  uint64_t offloads;
655 
656  /* For i40e specifically */
657  uint16_t pvid;
658  __extension__
659  uint8_t hw_vlan_reject_tagged : 1,
665 };
666 
672  uint16_t rx_free_thresh;
673  uint8_t rx_drop_en;
680  uint64_t offloads;
681 };
682 
688  uint16_t tx_rs_thresh;
689  uint16_t tx_free_thresh;
698  uint64_t offloads;
699 };
700 
705  uint16_t nb_max;
706  uint16_t nb_min;
707  uint16_t nb_align;
717  uint16_t nb_seg_max;
718 
730  uint16_t nb_mtu_seg_max;
731 };
732 
741 };
742 
749  uint32_t high_water;
750  uint32_t low_water;
751  uint16_t pause_time;
752  uint16_t send_xon;
755  uint8_t autoneg;
756 };
757 
765  uint8_t priority;
766 };
767 
776 };
777 
785 };
786 
798  uint8_t drop_queue;
799  struct rte_eth_fdir_masks mask;
802 };
803 
812  uint16_t udp_port;
813  uint8_t prot_type;
814 };
815 
821  uint32_t lsc:1;
823  uint32_t rxq:1;
825  uint32_t rmv:1;
826 };
827 
833 struct rte_eth_conf {
834  uint32_t link_speeds;
843  uint32_t lpbk_mode;
848  struct {
852  struct rte_eth_dcb_rx_conf dcb_rx_conf;
856  } rx_adv_conf;
857  union {
858  struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf;
860  struct rte_eth_dcb_tx_conf dcb_tx_conf;
862  struct rte_eth_vmdq_tx_conf vmdq_tx_conf;
864  } tx_adv_conf;
870 };
871 
875 #define DEV_RX_OFFLOAD_VLAN_STRIP 0x00000001
876 #define DEV_RX_OFFLOAD_IPV4_CKSUM 0x00000002
877 #define DEV_RX_OFFLOAD_UDP_CKSUM 0x00000004
878 #define DEV_RX_OFFLOAD_TCP_CKSUM 0x00000008
879 #define DEV_RX_OFFLOAD_TCP_LRO 0x00000010
880 #define DEV_RX_OFFLOAD_QINQ_STRIP 0x00000020
881 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000040
882 #define DEV_RX_OFFLOAD_MACSEC_STRIP 0x00000080
883 #define DEV_RX_OFFLOAD_HEADER_SPLIT 0x00000100
884 #define DEV_RX_OFFLOAD_VLAN_FILTER 0x00000200
885 #define DEV_RX_OFFLOAD_VLAN_EXTEND 0x00000400
886 #define DEV_RX_OFFLOAD_JUMBO_FRAME 0x00000800
887 #define DEV_RX_OFFLOAD_CRC_STRIP 0x00001000
888 #define DEV_RX_OFFLOAD_SCATTER 0x00002000
889 #define DEV_RX_OFFLOAD_TIMESTAMP 0x00004000
890 #define DEV_RX_OFFLOAD_SECURITY 0x00008000
891 
896 #define DEV_RX_OFFLOAD_KEEP_CRC 0x00010000
897 #define DEV_RX_OFFLOAD_CHECKSUM (DEV_RX_OFFLOAD_IPV4_CKSUM | \
898  DEV_RX_OFFLOAD_UDP_CKSUM | \
899  DEV_RX_OFFLOAD_TCP_CKSUM)
900 #define DEV_RX_OFFLOAD_VLAN (DEV_RX_OFFLOAD_VLAN_STRIP | \
901  DEV_RX_OFFLOAD_VLAN_FILTER | \
902  DEV_RX_OFFLOAD_VLAN_EXTEND)
903 
904 /*
905  * If new Rx offload capabilities are defined, they also must be
906  * mentioned in rte_rx_offload_names in rte_ethdev.c file.
907  */
908 
912 #define DEV_TX_OFFLOAD_VLAN_INSERT 0x00000001
913 #define DEV_TX_OFFLOAD_IPV4_CKSUM 0x00000002
914 #define DEV_TX_OFFLOAD_UDP_CKSUM 0x00000004
915 #define DEV_TX_OFFLOAD_TCP_CKSUM 0x00000008
916 #define DEV_TX_OFFLOAD_SCTP_CKSUM 0x00000010
917 #define DEV_TX_OFFLOAD_TCP_TSO 0x00000020
918 #define DEV_TX_OFFLOAD_UDP_TSO 0x00000040
919 #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080
920 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
921 #define DEV_TX_OFFLOAD_VXLAN_TNL_TSO 0x00000200
922 #define DEV_TX_OFFLOAD_GRE_TNL_TSO 0x00000400
923 #define DEV_TX_OFFLOAD_IPIP_TNL_TSO 0x00000800
924 #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO 0x00001000
925 #define DEV_TX_OFFLOAD_MACSEC_INSERT 0x00002000
926 #define DEV_TX_OFFLOAD_MT_LOCKFREE 0x00004000
927 
930 #define DEV_TX_OFFLOAD_MULTI_SEGS 0x00008000
931 
932 #define DEV_TX_OFFLOAD_MBUF_FAST_FREE 0x00010000
933 
937 #define DEV_TX_OFFLOAD_SECURITY 0x00020000
938 
943 #define DEV_TX_OFFLOAD_UDP_TNL_TSO 0x00040000
944 
949 #define DEV_TX_OFFLOAD_IP_TNL_TSO 0x00080000
950 
951 #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP 0x00000001
952 
953 #define RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP 0x00000002
954 
956 /*
957  * If new Tx offload capabilities are defined, they also must be
958  * mentioned in rte_tx_offload_names in rte_ethdev.c file.
959  */
960 
961 /*
962  * Fallback default preferred Rx/Tx port parameters.
963  * These are used if an application requests default parameters
964  * but the PMD does not provide preferred values.
965  */
966 #define RTE_ETH_DEV_FALLBACK_RX_RINGSIZE 512
967 #define RTE_ETH_DEV_FALLBACK_TX_RINGSIZE 512
968 #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
969 #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
970 
977  uint16_t burst_size;
978  uint16_t ring_size;
979  uint16_t nb_queues;
980 };
981 
986 #define RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID (0)
987 
992  const char *name;
993  uint16_t domain_id;
994  uint16_t port_id;
1002 };
1003 
1014  struct rte_device *device;
1015  const char *driver_name;
1016  unsigned int if_index;
1018  const uint32_t *dev_flags;
1019  uint32_t min_rx_bufsize;
1020  uint32_t max_rx_pktlen;
1021  uint16_t max_rx_queues;
1022  uint16_t max_tx_queues;
1023  uint32_t max_mac_addrs;
1024  uint32_t max_hash_mac_addrs;
1026  uint16_t max_vfs;
1027  uint16_t max_vmdq_pools;
1028  uint64_t rx_offload_capa;
1030  uint64_t tx_offload_capa;
1032  uint64_t rx_queue_offload_capa;
1034  uint64_t tx_queue_offload_capa;
1036  uint16_t reta_size;
1038  uint8_t hash_key_size;
1043  uint16_t vmdq_queue_base;
1044  uint16_t vmdq_queue_num;
1045  uint16_t vmdq_pool_base;
1048  uint32_t speed_capa;
1050  uint16_t nb_rx_queues;
1051  uint16_t nb_tx_queues;
1057  uint64_t dev_capa;
1063 };
1064 
1070  struct rte_mempool *mp;
1072  uint8_t scattered_rx;
1073  uint16_t nb_desc;
1075 
1082  uint16_t nb_desc;
1084 
1086 #define RTE_ETH_XSTATS_NAME_SIZE 64
1087 
1098  uint64_t id;
1099  uint64_t value;
1100 };
1101 
1111 };
1112 
1113 #define ETH_DCB_NUM_TCS 8
1114 #define ETH_MAX_VMDQ_POOL 64
1115 
1122  struct {
1123  uint8_t base;
1124  uint8_t nb_queue;
1125  } tc_rxq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
1127  struct {
1128  uint8_t base;
1129  uint8_t nb_queue;
1130  } tc_txq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
1131 };
1132 
1138  uint8_t nb_tcs;
1140  uint8_t tc_bws[ETH_DCB_NUM_TCS];
1143 };
1144 
1148 #define RTE_ETH_QUEUE_STATE_STOPPED 0
1149 #define RTE_ETH_QUEUE_STATE_STARTED 1
1150 
1151 #define RTE_ETH_ALL RTE_MAX_ETHPORTS
1152 
1153 /* Macros to check for valid port */
1154 #define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \
1155  if (!rte_eth_dev_is_valid_port(port_id)) { \
1156  RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
1157  return retval; \
1158  } \
1159 } while (0)
1160 
1161 #define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \
1162  if (!rte_eth_dev_is_valid_port(port_id)) { \
1163  RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
1164  return; \
1165  } \
1166 } while (0)
1167 
1173 #define ETH_L2_TUNNEL_ENABLE_MASK 0x00000001
1174 
1175 #define ETH_L2_TUNNEL_INSERTION_MASK 0x00000002
1176 
1177 #define ETH_L2_TUNNEL_STRIPPING_MASK 0x00000004
1178 
1179 #define ETH_L2_TUNNEL_FORWARDING_MASK 0x00000008
1180 
1203 typedef uint16_t (*rte_rx_callback_fn)(uint16_t port_id, uint16_t queue,
1204  struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts,
1205  void *user_param);
1206 
1227 typedef uint16_t (*rte_tx_callback_fn)(uint16_t port_id, uint16_t queue,
1228  struct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param);
1229 
1242 };
1243 
1244 struct rte_eth_dev_sriov {
1245  uint8_t active;
1246  uint8_t nb_q_per_pool;
1247  uint16_t def_vmdq_idx;
1248  uint16_t def_pool_q_idx;
1249 };
1250 #define RTE_ETH_DEV_SRIOV(dev) ((dev)->data->sriov)
1251 
1252 #define RTE_ETH_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
1253 
1254 #define RTE_ETH_DEV_NO_OWNER 0
1255 
1256 #define RTE_ETH_MAX_OWNER_NAME_LEN 64
1257 
1258 struct rte_eth_dev_owner {
1259  uint64_t id;
1260  char name[RTE_ETH_MAX_OWNER_NAME_LEN];
1261 };
1262 
1264 #define RTE_ETH_DEV_INTR_LSC 0x0002
1265 
1266 #define RTE_ETH_DEV_BONDED_SLAVE 0x0004
1267 
1268 #define RTE_ETH_DEV_INTR_RMV 0x0008
1269 
1270 #define RTE_ETH_DEV_REPRESENTOR 0x0010
1271 
1272 #define RTE_ETH_DEV_NOLIVE_MAC_ADDR 0x0020
1273 
1285 uint64_t rte_eth_find_next_owned_by(uint16_t port_id,
1286  const uint64_t owner_id);
1287 
1291 #define RTE_ETH_FOREACH_DEV_OWNED_BY(p, o) \
1292  for (p = rte_eth_find_next_owned_by(0, o); \
1293  (unsigned int)p < (unsigned int)RTE_MAX_ETHPORTS; \
1294  p = rte_eth_find_next_owned_by(p + 1, o))
1295 
1304 uint16_t rte_eth_find_next(uint16_t port_id);
1305 
1309 #define RTE_ETH_FOREACH_DEV(p) \
1310  RTE_ETH_FOREACH_DEV_OWNED_BY(p, RTE_ETH_DEV_NO_OWNER)
1311 
1312 
1326 int __rte_experimental rte_eth_dev_owner_new(uint64_t *owner_id);
1327 
1341 int __rte_experimental rte_eth_dev_owner_set(const uint16_t port_id,
1342  const struct rte_eth_dev_owner *owner);
1343 
1357 int __rte_experimental rte_eth_dev_owner_unset(const uint16_t port_id,
1358  const uint64_t owner_id);
1359 
1369 void __rte_experimental rte_eth_dev_owner_delete(const uint64_t owner_id);
1370 
1384 int __rte_experimental rte_eth_dev_owner_get(const uint16_t port_id,
1385  struct rte_eth_dev_owner *owner);
1386 
1399 __rte_deprecated
1400 uint16_t rte_eth_dev_count(void);
1401 
1412 uint16_t rte_eth_dev_count_avail(void);
1413 
1422 uint16_t __rte_experimental rte_eth_dev_count_total(void);
1423 
1436 __rte_deprecated
1437 int rte_eth_dev_attach(const char *devargs, uint16_t *port_id);
1438 
1452 __rte_deprecated
1453 int rte_eth_dev_detach(uint16_t port_id, char *devname);
1454 
1466 uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
1467 
1479 const char * __rte_experimental rte_eth_dev_rx_offload_name(uint64_t offload);
1480 
1492 const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload);
1493 
1533 int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue,
1534  uint16_t nb_tx_queue, const struct rte_eth_conf *eth_conf);
1535 
1547 int __rte_experimental
1548 rte_eth_dev_is_removed(uint16_t port_id);
1549 
1599 int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
1600  uint16_t nb_rx_desc, unsigned int socket_id,
1601  const struct rte_eth_rxconf *rx_conf,
1602  struct rte_mempool *mb_pool);
1603 
1652 int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
1653  uint16_t nb_tx_desc, unsigned int socket_id,
1654  const struct rte_eth_txconf *tx_conf);
1655 
1666 int rte_eth_dev_socket_id(uint16_t port_id);
1667 
1677 int rte_eth_dev_is_valid_port(uint16_t port_id);
1678 
1695 int rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id);
1696 
1712 int rte_eth_dev_rx_queue_stop(uint16_t port_id, uint16_t rx_queue_id);
1713 
1730 int rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id);
1731 
1747 int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);
1748 
1768 int rte_eth_dev_start(uint16_t port_id);
1769 
1777 void rte_eth_dev_stop(uint16_t port_id);
1778 
1791 int rte_eth_dev_set_link_up(uint16_t port_id);
1792 
1802 int rte_eth_dev_set_link_down(uint16_t port_id);
1803 
1812 void rte_eth_dev_close(uint16_t port_id);
1813 
1851 int rte_eth_dev_reset(uint16_t port_id);
1852 
1859 void rte_eth_promiscuous_enable(uint16_t port_id);
1860 
1867 void rte_eth_promiscuous_disable(uint16_t port_id);
1868 
1879 int rte_eth_promiscuous_get(uint16_t port_id);
1880 
1887 void rte_eth_allmulticast_enable(uint16_t port_id);
1888 
1895 void rte_eth_allmulticast_disable(uint16_t port_id);
1896 
1907 int rte_eth_allmulticast_get(uint16_t port_id);
1908 
1920 void rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
1921 
1933 void rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
1934 
1952 int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats);
1953 
1964 int rte_eth_stats_reset(uint16_t port_id);
1965 
1995 int rte_eth_xstats_get_names(uint16_t port_id,
1996  struct rte_eth_xstat_name *xstats_names,
1997  unsigned int size);
1998 
2028 int rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats,
2029  unsigned int n);
2030 
2053 int
2054 rte_eth_xstats_get_names_by_id(uint16_t port_id,
2055  struct rte_eth_xstat_name *xstats_names, unsigned int size,
2056  uint64_t *ids);
2057 
2081 int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
2082  uint64_t *values, unsigned int size);
2083 
2102 int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
2103  uint64_t *id);
2104 
2111 void rte_eth_xstats_reset(uint16_t port_id);
2112 
2130 int rte_eth_dev_set_tx_queue_stats_mapping(uint16_t port_id,
2131  uint16_t tx_queue_id, uint8_t stat_idx);
2132 
2150 int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t port_id,
2151  uint16_t rx_queue_id,
2152  uint8_t stat_idx);
2153 
2163 void rte_eth_macaddr_get(uint16_t port_id, struct ether_addr *mac_addr);
2164 
2174 void rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info);
2175 
2195 int rte_eth_dev_fw_version_get(uint16_t port_id,
2196  char *fw_version, size_t fw_size);
2197 
2236 int rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
2237  uint32_t *ptypes, int num);
2238 
2250 int rte_eth_dev_get_mtu(uint16_t port_id, uint16_t *mtu);
2251 
2267 int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu);
2268 
2288 int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on);
2289 
2309 int rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
2310  int on);
2311 
2329 int rte_eth_dev_set_vlan_ether_type(uint16_t port_id,
2330  enum rte_vlan_type vlan_type,
2331  uint16_t tag_type);
2332 
2354 int rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask);
2355 
2368 int rte_eth_dev_get_vlan_offload(uint16_t port_id);
2369 
2384 int rte_eth_dev_set_vlan_pvid(uint16_t port_id, uint16_t pvid, int on);
2385 
2386 typedef void (*buffer_tx_error_fn)(struct rte_mbuf **unsent, uint16_t count,
2387  void *userdata);
2388 
2394  buffer_tx_error_fn error_callback;
2395  void *error_userdata;
2396  uint16_t size;
2397  uint16_t length;
2398  struct rte_mbuf *pkts[];
2400 };
2401 
2408 #define RTE_ETH_TX_BUFFER_SIZE(sz) \
2409  (sizeof(struct rte_eth_dev_tx_buffer) + (sz) * sizeof(struct rte_mbuf *))
2410 
2421 int
2422 rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size);
2423 
2448 int
2450  buffer_tx_error_fn callback, void *userdata);
2451 
2474 void
2475 rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_t unsent,
2476  void *userdata);
2477 
2501 void
2502 rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent,
2503  void *userdata);
2504 
2530 int
2531 rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt);
2532 
2548 };
2549 
2557  uint64_t metadata;
2571 };
2572 
2590 };
2591 
2592 typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
2593  enum rte_eth_event_type event, void *cb_arg, void *ret_param);
2613 int rte_eth_dev_callback_register(uint16_t port_id,
2614  enum rte_eth_event_type event,
2615  rte_eth_dev_cb_fn cb_fn, void *cb_arg);
2616 
2635 int rte_eth_dev_callback_unregister(uint16_t port_id,
2636  enum rte_eth_event_type event,
2637  rte_eth_dev_cb_fn cb_fn, void *cb_arg);
2638 
2660 int rte_eth_dev_rx_intr_enable(uint16_t port_id, uint16_t queue_id);
2661 
2682 int rte_eth_dev_rx_intr_disable(uint16_t port_id, uint16_t queue_id);
2683 
2701 int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data);
2702 
2724 int rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id,
2725  int epfd, int op, void *data);
2726 
2740 int rte_eth_led_on(uint16_t port_id);
2741 
2755 int rte_eth_led_off(uint16_t port_id);
2756 
2770 int rte_eth_dev_flow_ctrl_get(uint16_t port_id,
2771  struct rte_eth_fc_conf *fc_conf);
2772 
2787 int rte_eth_dev_flow_ctrl_set(uint16_t port_id,
2788  struct rte_eth_fc_conf *fc_conf);
2789 
2805 int rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id,
2806  struct rte_eth_pfc_conf *pfc_conf);
2807 
2827 int rte_eth_dev_mac_addr_add(uint16_t port_id, struct ether_addr *mac_addr,
2828  uint32_t pool);
2829 
2843 int rte_eth_dev_mac_addr_remove(uint16_t port_id, struct ether_addr *mac_addr);
2844 
2858 int rte_eth_dev_default_mac_addr_set(uint16_t port_id,
2859  struct ether_addr *mac_addr);
2860 
2877 int rte_eth_dev_rss_reta_update(uint16_t port_id,
2878  struct rte_eth_rss_reta_entry64 *reta_conf,
2879  uint16_t reta_size);
2880 
2897 int rte_eth_dev_rss_reta_query(uint16_t port_id,
2898  struct rte_eth_rss_reta_entry64 *reta_conf,
2899  uint16_t reta_size);
2900 
2920 int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct ether_addr *addr,
2921  uint8_t on);
2922 
2941 int rte_eth_dev_uc_all_hash_table_set(uint16_t port_id, uint8_t on);
2942 
2965 int rte_eth_mirror_rule_set(uint16_t port_id,
2966  struct rte_eth_mirror_conf *mirror_conf,
2967  uint8_t rule_id,
2968  uint8_t on);
2969 
2984 int rte_eth_mirror_rule_reset(uint16_t port_id,
2985  uint8_t rule_id);
2986 
3003 int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
3004  uint16_t tx_rate);
3005 
3020 int rte_eth_dev_rss_hash_update(uint16_t port_id,
3021  struct rte_eth_rss_conf *rss_conf);
3022 
3037 int
3038 rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
3039  struct rte_eth_rss_conf *rss_conf);
3040 
3059 int
3060 rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
3061  struct rte_eth_udp_tunnel *tunnel_udp);
3062 
3082 int
3083 rte_eth_dev_udp_tunnel_port_delete(uint16_t port_id,
3084  struct rte_eth_udp_tunnel *tunnel_udp);
3085 
3100 int rte_eth_dev_filter_supported(uint16_t port_id,
3101  enum rte_filter_type filter_type);
3102 
3122 int rte_eth_dev_filter_ctrl(uint16_t port_id, enum rte_filter_type filter_type,
3123  enum rte_filter_op filter_op, void *arg);
3124 
3138 int rte_eth_dev_get_dcb_info(uint16_t port_id,
3139  struct rte_eth_dcb_info *dcb_info);
3140 
3141 struct rte_eth_rxtx_callback;
3142 
3167 const struct rte_eth_rxtx_callback *
3168 rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
3169  rte_rx_callback_fn fn, void *user_param);
3170 
3196 const struct rte_eth_rxtx_callback *
3197 rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id,
3198  rte_rx_callback_fn fn, void *user_param);
3199 
3224 const struct rte_eth_rxtx_callback *
3225 rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
3226  rte_tx_callback_fn fn, void *user_param);
3227 
3258 int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
3259  const struct rte_eth_rxtx_callback *user_cb);
3260 
3291 int rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
3292  const struct rte_eth_rxtx_callback *user_cb);
3293 
3311 int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
3312  struct rte_eth_rxq_info *qinfo);
3313 
3331 int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
3332  struct rte_eth_txq_info *qinfo);
3333 
3351 int rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info);
3352 
3365 int rte_eth_dev_get_eeprom_length(uint16_t port_id);
3366 
3382 int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
3383 
3399 int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
3400 
3418 int __rte_experimental
3419 rte_eth_dev_get_module_info(uint16_t port_id,
3420  struct rte_eth_dev_module_info *modinfo);
3421 
3440 int __rte_experimental
3441 rte_eth_dev_get_module_eeprom(uint16_t port_id,
3442  struct rte_dev_eeprom_info *info);
3443 
3462 int rte_eth_dev_set_mc_addr_list(uint16_t port_id,
3463  struct ether_addr *mc_addr_set,
3464  uint32_t nb_mc_addr);
3465 
3478 int rte_eth_timesync_enable(uint16_t port_id);
3479 
3492 int rte_eth_timesync_disable(uint16_t port_id);
3493 
3512 int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,
3513  struct timespec *timestamp, uint32_t flags);
3514 
3530 int rte_eth_timesync_read_tx_timestamp(uint16_t port_id,
3531  struct timespec *timestamp);
3532 
3550 int rte_eth_timesync_adjust_time(uint16_t port_id, int64_t delta);
3551 
3566 int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time);
3567 
3586 int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);
3587 
3603 int
3604 rte_eth_dev_l2_tunnel_eth_type_conf(uint16_t port_id,
3605  struct rte_eth_l2_tunnel_conf *l2_tunnel);
3606 
3631 int
3632 rte_eth_dev_l2_tunnel_offload_set(uint16_t port_id,
3633  struct rte_eth_l2_tunnel_conf *l2_tunnel,
3634  uint32_t mask,
3635  uint8_t en);
3636 
3652 int
3653 rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id);
3654 
3669 int
3670 rte_eth_dev_get_name_by_port(uint16_t port_id, char *name);
3671 
3688 int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id,
3689  uint16_t *nb_rx_desc,
3690  uint16_t *nb_tx_desc);
3691 
3706 int
3707 rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool);
3708 
3718 void *
3719 rte_eth_dev_get_sec_ctx(uint16_t port_id);
3720 
3721 
3722 #include <rte_ethdev_core.h>
3723 
3806 static inline uint16_t
3807 rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
3808  struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
3809 {
3810  struct rte_eth_dev *dev = &rte_eth_devices[port_id];
3811  uint16_t nb_rx;
3812 
3813 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
3814  RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
3815  RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
3816 
3817  if (queue_id >= dev->data->nb_rx_queues) {
3818  RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", queue_id);
3819  return 0;
3820  }
3821 #endif
3822  nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
3823  rx_pkts, nb_pkts);
3824 
3825 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
3826  if (unlikely(dev->post_rx_burst_cbs[queue_id] != NULL)) {
3827  struct rte_eth_rxtx_callback *cb =
3828  dev->post_rx_burst_cbs[queue_id];
3829 
3830  do {
3831  nb_rx = cb->fn.rx(port_id, queue_id, rx_pkts, nb_rx,
3832  nb_pkts, cb->param);
3833  cb = cb->next;
3834  } while (cb != NULL);
3835  }
3836 #endif
3837 
3838  return nb_rx;
3839 }
3840 
3853 static inline int
3854 rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id)
3855 {
3856  struct rte_eth_dev *dev;
3857 
3858  RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
3859  dev = &rte_eth_devices[port_id];
3860  RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
3861  if (queue_id >= dev->data->nb_rx_queues)
3862  return -EINVAL;
3863 
3864  return (int)(*dev->dev_ops->rx_queue_count)(dev, queue_id);
3865 }
3866 
3882 static inline int
3883 rte_eth_rx_descriptor_done(uint16_t port_id, uint16_t queue_id, uint16_t offset)
3884 {
3885  struct rte_eth_dev *dev = &rte_eth_devices[port_id];
3886  RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
3887  RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
3888  return (*dev->dev_ops->rx_descriptor_done)( \
3889  dev->data->rx_queues[queue_id], offset);
3890 }
3891 
3892 #define RTE_ETH_RX_DESC_AVAIL 0
3893 #define RTE_ETH_RX_DESC_DONE 1
3894 #define RTE_ETH_RX_DESC_UNAVAIL 2
3929 static inline int
3930 rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
3931  uint16_t offset)
3932 {
3933  struct rte_eth_dev *dev;
3934  void *rxq;
3935 
3936 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
3937  RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
3938 #endif
3939  dev = &rte_eth_devices[port_id];
3940 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
3941  if (queue_id >= dev->data->nb_rx_queues)
3942  return -ENODEV;
3943 #endif
3944  RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_status, -ENOTSUP);
3945  rxq = dev->data->rx_queues[queue_id];
3946 
3947  return (*dev->dev_ops->rx_descriptor_status)(rxq, offset);
3948 }
3949 
3950 #define RTE_ETH_TX_DESC_FULL 0
3951 #define RTE_ETH_TX_DESC_DONE 1
3952 #define RTE_ETH_TX_DESC_UNAVAIL 2
3987 static inline int rte_eth_tx_descriptor_status(uint16_t port_id,
3988  uint16_t queue_id, uint16_t offset)
3989 {
3990  struct rte_eth_dev *dev;
3991  void *txq;
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_tx_queues)
3999  return -ENODEV;
4000 #endif
4001  RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_descriptor_status, -ENOTSUP);
4002  txq = dev->data->tx_queues[queue_id];
4003 
4004  return (*dev->dev_ops->tx_descriptor_status)(txq, offset);
4005 }
4006 
4073 static inline uint16_t
4074 rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
4075  struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
4076 {
4077  struct rte_eth_dev *dev = &rte_eth_devices[port_id];
4078 
4079 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
4080  RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
4081  RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
4082 
4083  if (queue_id >= dev->data->nb_tx_queues) {
4084  RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", queue_id);
4085  return 0;
4086  }
4087 #endif
4088 
4089 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
4090  struct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id];
4091 
4092  if (unlikely(cb != NULL)) {
4093  do {
4094  nb_pkts = cb->fn.tx(port_id, queue_id, tx_pkts, nb_pkts,
4095  cb->param);
4096  cb = cb->next;
4097  } while (cb != NULL);
4098  }
4099 #endif
4100 
4101  return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
4102 }
4103 
4160 #ifndef RTE_ETHDEV_TX_PREPARE_NOOP
4161 
4162 static inline uint16_t
4163 rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id,
4164  struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
4165 {
4166  struct rte_eth_dev *dev;
4167 
4168 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
4169  if (!rte_eth_dev_is_valid_port(port_id)) {
4170  RTE_ETHDEV_LOG(ERR, "Invalid TX port_id=%u\n", port_id);
4171  rte_errno = -EINVAL;
4172  return 0;
4173  }
4174 #endif
4175 
4176  dev = &rte_eth_devices[port_id];
4177 
4178 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
4179  if (queue_id >= dev->data->nb_tx_queues) {
4180  RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", queue_id);
4181  rte_errno = -EINVAL;
4182  return 0;
4183  }
4184 #endif
4185 
4186  if (!dev->tx_pkt_prepare)
4187  return nb_pkts;
4188 
4189  return (*dev->tx_pkt_prepare)(dev->data->tx_queues[queue_id],
4190  tx_pkts, nb_pkts);
4191 }
4192 
4193 #else
4194 
4195 /*
4196  * Native NOOP operation for compilation targets which doesn't require any
4197  * preparations steps, and functional NOOP may introduce unnecessary performance
4198  * drop.
4199  *
4200  * Generally this is not a good idea to turn it on globally and didn't should
4201  * be used if behavior of tx_preparation can change.
4202  */
4203 
4204 static inline uint16_t
4205 rte_eth_tx_prepare(__rte_unused uint16_t port_id,
4206  __rte_unused uint16_t queue_id,
4207  __rte_unused struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
4208 {
4209  return nb_pkts;
4210 }
4211 
4212 #endif
4213 
4236 static inline uint16_t
4237 rte_eth_tx_buffer_flush(uint16_t port_id, uint16_t queue_id,
4238  struct rte_eth_dev_tx_buffer *buffer)
4239 {
4240  uint16_t sent;
4241  uint16_t to_send = buffer->length;
4242 
4243  if (to_send == 0)
4244  return 0;
4245 
4246  sent = rte_eth_tx_burst(port_id, queue_id, buffer->pkts, to_send);
4247 
4248  buffer->length = 0;
4249 
4250  /* All packets sent, or to be dealt with by callback below */
4251  if (unlikely(sent != to_send))
4252  buffer->error_callback(&buffer->pkts[sent],
4253  (uint16_t)(to_send - sent),
4254  buffer->error_userdata);
4255 
4256  return sent;
4257 }
4258 
4289 static __rte_always_inline uint16_t
4290 rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,
4291  struct rte_eth_dev_tx_buffer *buffer, struct rte_mbuf *tx_pkt)
4292 {
4293  buffer->pkts[buffer->length++] = tx_pkt;
4294  if (buffer->length < buffer->size)
4295  return 0;
4296 
4297  return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
4298 }
4299 
4300 #ifdef __cplusplus
4301 }
4302 #endif
4303 
4304 #endif /* _RTE_ETHDEV_H_ */