34 #ifndef _RTE_ETHDEV_H_
35 #define _RTE_ETHDEV_H_
178 #define RTE_ETHDEV_HAS_LRO_SUPPORT
187 #include "rte_dev_info.h"
206 uint64_t
q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
208 uint64_t
q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
210 uint64_t
q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
212 uint64_t
q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
214 uint64_t
q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
221 #define ETH_LINK_SPEED_AUTONEG (0 << 0)
222 #define ETH_LINK_SPEED_FIXED (1 << 0)
223 #define ETH_LINK_SPEED_10M_HD (1 << 1)
224 #define ETH_LINK_SPEED_10M (1 << 2)
225 #define ETH_LINK_SPEED_100M_HD (1 << 3)
226 #define ETH_LINK_SPEED_100M (1 << 4)
227 #define ETH_LINK_SPEED_1G (1 << 5)
228 #define ETH_LINK_SPEED_2_5G (1 << 6)
229 #define ETH_LINK_SPEED_5G (1 << 7)
230 #define ETH_LINK_SPEED_10G (1 << 8)
231 #define ETH_LINK_SPEED_20G (1 << 9)
232 #define ETH_LINK_SPEED_25G (1 << 10)
233 #define ETH_LINK_SPEED_40G (1 << 11)
234 #define ETH_LINK_SPEED_50G (1 << 12)
235 #define ETH_LINK_SPEED_56G (1 << 13)
236 #define ETH_LINK_SPEED_100G (1 << 14)
241 #define ETH_SPEED_NUM_NONE 0
242 #define ETH_SPEED_NUM_10M 10
243 #define ETH_SPEED_NUM_100M 100
244 #define ETH_SPEED_NUM_1G 1000
245 #define ETH_SPEED_NUM_2_5G 2500
246 #define ETH_SPEED_NUM_5G 5000
247 #define ETH_SPEED_NUM_10G 10000
248 #define ETH_SPEED_NUM_20G 20000
249 #define ETH_SPEED_NUM_25G 25000
250 #define ETH_SPEED_NUM_40G 40000
251 #define ETH_SPEED_NUM_50G 50000
252 #define ETH_SPEED_NUM_56G 56000
253 #define ETH_SPEED_NUM_100G 100000
258 struct rte_eth_link {
260 uint16_t link_duplex : 1;
261 uint16_t link_autoneg : 1;
262 uint16_t link_status : 1;
263 } __attribute__((aligned(8)));
266 #define ETH_LINK_HALF_DUPLEX 0
267 #define ETH_LINK_FULL_DUPLEX 1
268 #define ETH_LINK_DOWN 0
269 #define ETH_LINK_UP 1
270 #define ETH_LINK_FIXED 0
271 #define ETH_LINK_AUTONEG 1
277 struct rte_eth_thresh {
286 #define ETH_MQ_RX_RSS_FLAG 0x1
287 #define ETH_MQ_RX_DCB_FLAG 0x2
288 #define ETH_MQ_RX_VMDQ_FLAG 0x4
319 #define ETH_RSS ETH_MQ_RX_RSS
320 #define VMDQ_DCB ETH_MQ_RX_VMDQ_DCB
321 #define ETH_DCB_RX ETH_MQ_RX_DCB
337 #define ETH_DCB_NONE ETH_MQ_TX_NONE
338 #define ETH_VMDQ_DCB_TX ETH_MQ_TX_VMDQ_DCB
339 #define ETH_DCB_TX ETH_MQ_TX_DCB
365 ETH_VLAN_TYPE_UNKNOWN = 0,
400 #define ETH_RSS_IPV4 (1ULL << RTE_ETH_FLOW_IPV4)
401 #define ETH_RSS_FRAG_IPV4 (1ULL << RTE_ETH_FLOW_FRAG_IPV4)
402 #define ETH_RSS_NONFRAG_IPV4_TCP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_TCP)
403 #define ETH_RSS_NONFRAG_IPV4_UDP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_UDP)
404 #define ETH_RSS_NONFRAG_IPV4_SCTP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_SCTP)
405 #define ETH_RSS_NONFRAG_IPV4_OTHER (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_OTHER)
406 #define ETH_RSS_IPV6 (1ULL << RTE_ETH_FLOW_IPV6)
407 #define ETH_RSS_FRAG_IPV6 (1ULL << RTE_ETH_FLOW_FRAG_IPV6)
408 #define ETH_RSS_NONFRAG_IPV6_TCP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_TCP)
409 #define ETH_RSS_NONFRAG_IPV6_UDP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_UDP)
410 #define ETH_RSS_NONFRAG_IPV6_SCTP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_SCTP)
411 #define ETH_RSS_NONFRAG_IPV6_OTHER (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_OTHER)
412 #define ETH_RSS_L2_PAYLOAD (1ULL << RTE_ETH_FLOW_L2_PAYLOAD)
413 #define ETH_RSS_IPV6_EX (1ULL << RTE_ETH_FLOW_IPV6_EX)
414 #define ETH_RSS_IPV6_TCP_EX (1ULL << RTE_ETH_FLOW_IPV6_TCP_EX)
415 #define ETH_RSS_IPV6_UDP_EX (1ULL << RTE_ETH_FLOW_IPV6_UDP_EX)
416 #define ETH_RSS_PORT (1ULL << RTE_ETH_FLOW_PORT)
417 #define ETH_RSS_VXLAN (1ULL << RTE_ETH_FLOW_VXLAN)
418 #define ETH_RSS_GENEVE (1ULL << RTE_ETH_FLOW_GENEVE)
419 #define ETH_RSS_NVGRE (1ULL << RTE_ETH_FLOW_NVGRE)
421 #define ETH_RSS_IP ( \
423 ETH_RSS_FRAG_IPV4 | \
424 ETH_RSS_NONFRAG_IPV4_OTHER | \
426 ETH_RSS_FRAG_IPV6 | \
427 ETH_RSS_NONFRAG_IPV6_OTHER | \
430 #define ETH_RSS_UDP ( \
431 ETH_RSS_NONFRAG_IPV4_UDP | \
432 ETH_RSS_NONFRAG_IPV6_UDP | \
435 #define ETH_RSS_TCP ( \
436 ETH_RSS_NONFRAG_IPV4_TCP | \
437 ETH_RSS_NONFRAG_IPV6_TCP | \
440 #define ETH_RSS_SCTP ( \
441 ETH_RSS_NONFRAG_IPV4_SCTP | \
442 ETH_RSS_NONFRAG_IPV6_SCTP)
444 #define ETH_RSS_TUNNEL ( \
451 #define ETH_RSS_PROTO_MASK ( \
453 ETH_RSS_FRAG_IPV4 | \
454 ETH_RSS_NONFRAG_IPV4_TCP | \
455 ETH_RSS_NONFRAG_IPV4_UDP | \
456 ETH_RSS_NONFRAG_IPV4_SCTP | \
457 ETH_RSS_NONFRAG_IPV4_OTHER | \
459 ETH_RSS_FRAG_IPV6 | \
460 ETH_RSS_NONFRAG_IPV6_TCP | \
461 ETH_RSS_NONFRAG_IPV6_UDP | \
462 ETH_RSS_NONFRAG_IPV6_SCTP | \
463 ETH_RSS_NONFRAG_IPV6_OTHER | \
464 ETH_RSS_L2_PAYLOAD | \
466 ETH_RSS_IPV6_TCP_EX | \
467 ETH_RSS_IPV6_UDP_EX | \
478 #define ETH_RSS_RETA_SIZE_64 64
479 #define ETH_RSS_RETA_SIZE_128 128
480 #define ETH_RSS_RETA_SIZE_256 256
481 #define ETH_RSS_RETA_SIZE_512 512
482 #define RTE_RETA_GROUP_SIZE 64
485 #define ETH_VMDQ_MAX_VLAN_FILTERS 64
486 #define ETH_DCB_NUM_USER_PRIORITIES 8
487 #define ETH_VMDQ_DCB_NUM_QUEUES 128
488 #define ETH_DCB_NUM_QUEUES 128
491 #define ETH_DCB_PG_SUPPORT 0x00000001
492 #define ETH_DCB_PFC_SUPPORT 0x00000002
495 #define ETH_VLAN_STRIP_OFFLOAD 0x0001
496 #define ETH_VLAN_FILTER_OFFLOAD 0x0002
497 #define ETH_VLAN_EXTEND_OFFLOAD 0x0004
500 #define ETH_VLAN_STRIP_MASK 0x0001
501 #define ETH_VLAN_FILTER_MASK 0x0002
502 #define ETH_VLAN_EXTEND_MASK 0x0004
503 #define ETH_VLAN_ID_MAX 0x0FFF
506 #define ETH_NUM_RECEIVE_MAC_ADDR 128
509 #define ETH_VMDQ_NUM_UC_HASH_ARRAY 128
512 #define ETH_VMDQ_ACCEPT_UNTAG 0x0001
513 #define ETH_VMDQ_ACCEPT_HASH_MC 0x0002
514 #define ETH_VMDQ_ACCEPT_HASH_UC 0x0004
515 #define ETH_VMDQ_ACCEPT_BROADCAST 0x0008
516 #define ETH_VMDQ_ACCEPT_MULTICAST 0x0010
519 #define ETH_MIRROR_MAX_VLANS 64
521 #define ETH_MIRROR_VIRTUAL_POOL_UP 0x01
522 #define ETH_MIRROR_UPLINK_PORT 0x02
523 #define ETH_MIRROR_DOWNLINK_PORT 0x04
524 #define ETH_MIRROR_VLAN 0x08
525 #define ETH_MIRROR_VIRTUAL_POOL_DOWN 0x10
530 struct rte_eth_vlan_mirror {
556 uint16_t
reta[RTE_RETA_GROUP_SIZE];
581 struct rte_eth_dcb_rx_conf {
587 struct rte_eth_vmdq_dcb_tx_conf {
593 struct rte_eth_dcb_tx_conf {
599 struct rte_eth_vmdq_tx_conf {
627 struct rte_eth_vmdq_rx_conf {
629 uint8_t enable_default_pool;
630 uint8_t default_pool;
631 uint8_t enable_loop_back;
632 uint8_t nb_pool_maps;
666 #define ETH_TXQ_FLAGS_NOMULTSEGS 0x0001
667 #define ETH_TXQ_FLAGS_NOREFCOUNT 0x0002
668 #define ETH_TXQ_FLAGS_NOMULTMEMP 0x0004
669 #define ETH_TXQ_FLAGS_NOVLANOFFL 0x0100
670 #define ETH_TXQ_FLAGS_NOXSUMSCTP 0x0200
671 #define ETH_TXQ_FLAGS_NOXSUMUDP 0x0400
672 #define ETH_TXQ_FLAGS_NOXSUMTCP 0x0800
673 #define ETH_TXQ_FLAGS_NOOFFLOADS \
674 (ETH_TXQ_FLAGS_NOVLANOFFL | ETH_TXQ_FLAGS_NOXSUMSCTP | \
675 ETH_TXQ_FLAGS_NOXSUMUDP | ETH_TXQ_FLAGS_NOXSUMTCP)
676 #define ETH_TXQ_FLAGS_NOXSUMS \
677 (ETH_TXQ_FLAGS_NOXSUMSCTP | ETH_TXQ_FLAGS_NOXSUMUDP | \
678 ETH_TXQ_FLAGS_NOXSUMTCP)
847 #define DEV_RX_OFFLOAD_VLAN_STRIP 0x00000001
848 #define DEV_RX_OFFLOAD_IPV4_CKSUM 0x00000002
849 #define DEV_RX_OFFLOAD_UDP_CKSUM 0x00000004
850 #define DEV_RX_OFFLOAD_TCP_CKSUM 0x00000008
851 #define DEV_RX_OFFLOAD_TCP_LRO 0x00000010
852 #define DEV_RX_OFFLOAD_QINQ_STRIP 0x00000020
853 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000040
858 #define DEV_TX_OFFLOAD_VLAN_INSERT 0x00000001
859 #define DEV_TX_OFFLOAD_IPV4_CKSUM 0x00000002
860 #define DEV_TX_OFFLOAD_UDP_CKSUM 0x00000004
861 #define DEV_TX_OFFLOAD_TCP_CKSUM 0x00000008
862 #define DEV_TX_OFFLOAD_SCTP_CKSUM 0x00000010
863 #define DEV_TX_OFFLOAD_TCP_TSO 0x00000020
864 #define DEV_TX_OFFLOAD_UDP_TSO 0x00000040
865 #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080
866 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
881 uint32_t max_hash_mac_addrs;
926 #define RTE_ETH_XSTATS_NAME_SIZE 64
950 #define ETH_DCB_NUM_TCS 8
951 #define ETH_MAX_VMDQ_POOL 64
962 }
tc_rxq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
967 }
tc_txq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
985 #define RTE_ETH_QUEUE_STATE_STOPPED 0
986 #define RTE_ETH_QUEUE_STATE_STARTED 1
990 struct rte_eth_dev_callback;
992 TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
995 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
996 #define RTE_PMD_DEBUG_TRACE(...) \
997 rte_pmd_debug_trace(__func__, __VA_ARGS__)
999 #define RTE_PMD_DEBUG_TRACE(...)
1004 #define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \
1005 if (!rte_eth_dev_is_valid_port(port_id)) { \
1006 RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
1011 #define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \
1012 if (!rte_eth_dev_is_valid_port(port_id)) { \
1013 RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
1023 #define ETH_L2_TUNNEL_ENABLE_MASK 0x00000001
1025 #define ETH_L2_TUNNEL_INSERTION_MASK 0x00000002
1027 #define ETH_L2_TUNNEL_STRIPPING_MASK 0x00000004
1029 #define ETH_L2_TUNNEL_FORWARDING_MASK 0x00000008
1037 typedef int (*eth_dev_configure_t)(
struct rte_eth_dev *dev);
1040 typedef int (*eth_dev_start_t)(
struct rte_eth_dev *dev);
1043 typedef void (*eth_dev_stop_t)(
struct rte_eth_dev *dev);
1046 typedef int (*eth_dev_set_link_up_t)(
struct rte_eth_dev *dev);
1049 typedef int (*eth_dev_set_link_down_t)(
struct rte_eth_dev *dev);
1052 typedef void (*eth_dev_close_t)(
struct rte_eth_dev *dev);
1055 typedef void (*eth_promiscuous_enable_t)(
struct rte_eth_dev *dev);
1058 typedef void (*eth_promiscuous_disable_t)(
struct rte_eth_dev *dev);
1061 typedef void (*eth_allmulticast_enable_t)(
struct rte_eth_dev *dev);
1064 typedef void (*eth_allmulticast_disable_t)(
struct rte_eth_dev *dev);
1067 typedef int (*eth_link_update_t)(
struct rte_eth_dev *dev,
1068 int wait_to_complete);
1071 typedef void (*eth_stats_get_t)(
struct rte_eth_dev *dev,
1075 typedef void (*eth_stats_reset_t)(
struct rte_eth_dev *dev);
1078 typedef int (*eth_xstats_get_t)(
struct rte_eth_dev *dev,
1082 typedef void (*eth_xstats_reset_t)(
struct rte_eth_dev *dev);
1085 typedef int (*eth_xstats_get_names_t)(
struct rte_eth_dev *dev,
1089 typedef int (*eth_queue_stats_mapping_set_t)(
struct rte_eth_dev *dev,
1095 typedef void (*eth_dev_infos_get_t)(
struct rte_eth_dev *dev,
1099 typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(
struct rte_eth_dev *dev);
1102 typedef int (*eth_queue_start_t)(
struct rte_eth_dev *dev,
1106 typedef int (*eth_queue_stop_t)(
struct rte_eth_dev *dev,
1110 typedef int (*eth_rx_queue_setup_t)(
struct rte_eth_dev *dev,
1111 uint16_t rx_queue_id,
1112 uint16_t nb_rx_desc,
1113 unsigned int socket_id,
1118 typedef int (*eth_tx_queue_setup_t)(
struct rte_eth_dev *dev,
1119 uint16_t tx_queue_id,
1120 uint16_t nb_tx_desc,
1121 unsigned int socket_id,
1125 typedef int (*eth_rx_enable_intr_t)(
struct rte_eth_dev *dev,
1126 uint16_t rx_queue_id);
1129 typedef int (*eth_rx_disable_intr_t)(
struct rte_eth_dev *dev,
1130 uint16_t rx_queue_id);
1133 typedef void (*eth_queue_release_t)(
void *queue);
1136 typedef uint32_t (*eth_rx_queue_count_t)(
struct rte_eth_dev *dev,
1137 uint16_t rx_queue_id);
1140 typedef int (*eth_rx_descriptor_done_t)(
void *rxq, uint16_t offset);
1143 typedef void (*eth_rxq_info_get_t)(
struct rte_eth_dev *dev,
1146 typedef void (*eth_txq_info_get_t)(
struct rte_eth_dev *dev,
1149 typedef int (*mtu_set_t)(
struct rte_eth_dev *dev, uint16_t mtu);
1152 typedef int (*vlan_filter_set_t)(
struct rte_eth_dev *dev,
1157 typedef int (*vlan_tpid_set_t)(
struct rte_eth_dev *dev,
1161 typedef void (*vlan_offload_set_t)(
struct rte_eth_dev *dev,
int mask);
1164 typedef int (*vlan_pvid_set_t)(
struct rte_eth_dev *dev,
1169 typedef void (*vlan_strip_queue_set_t)(
struct rte_eth_dev *dev,
1170 uint16_t rx_queue_id,
1174 typedef uint16_t (*eth_rx_burst_t)(
void *rxq,
1179 typedef uint16_t (*eth_tx_burst_t)(
void *txq,
1184 typedef int (*flow_ctrl_get_t)(
struct rte_eth_dev *dev,
1188 typedef int (*flow_ctrl_set_t)(
struct rte_eth_dev *dev,
1192 typedef int (*priority_flow_ctrl_set_t)(
struct rte_eth_dev *dev,
1196 typedef int (*reta_update_t)(
struct rte_eth_dev *dev,
1198 uint16_t reta_size);
1201 typedef int (*reta_query_t)(
struct rte_eth_dev *dev,
1203 uint16_t reta_size);
1206 typedef int (*rss_hash_update_t)(
struct rte_eth_dev *dev,
1210 typedef int (*rss_hash_conf_get_t)(
struct rte_eth_dev *dev,
1214 typedef int (*eth_dev_led_on_t)(
struct rte_eth_dev *dev);
1217 typedef int (*eth_dev_led_off_t)(
struct rte_eth_dev *dev);
1220 typedef void (*eth_mac_addr_remove_t)(
struct rte_eth_dev *dev, uint32_t index);
1223 typedef void (*eth_mac_addr_add_t)(
struct rte_eth_dev *dev,
1229 typedef void (*eth_mac_addr_set_t)(
struct rte_eth_dev *dev,
1233 typedef int (*eth_uc_hash_table_set_t)(
struct rte_eth_dev *dev,
1238 typedef int (*eth_uc_all_hash_table_set_t)(
struct rte_eth_dev *dev,
1242 typedef int (*eth_set_vf_rx_mode_t)(
struct rte_eth_dev *dev,
1248 typedef int (*eth_set_vf_rx_t)(
struct rte_eth_dev *dev,
1253 typedef int (*eth_set_vf_tx_t)(
struct rte_eth_dev *dev,
1258 typedef int (*eth_set_vf_vlan_filter_t)(
struct rte_eth_dev *dev,
1264 typedef int (*eth_set_queue_rate_limit_t)(
struct rte_eth_dev *dev,
1269 typedef int (*eth_set_vf_rate_limit_t)(
struct rte_eth_dev *dev,
1275 typedef int (*eth_mirror_rule_set_t)(
struct rte_eth_dev *dev,
1281 typedef int (*eth_mirror_rule_reset_t)(
struct rte_eth_dev *dev,
1285 typedef int (*eth_udp_tunnel_port_add_t)(
struct rte_eth_dev *dev,
1289 typedef int (*eth_udp_tunnel_port_del_t)(
struct rte_eth_dev *dev,
1293 typedef int (*eth_set_mc_addr_list_t)(
struct rte_eth_dev *dev,
1295 uint32_t nb_mc_addr);
1298 typedef int (*eth_timesync_enable_t)(
struct rte_eth_dev *dev);
1301 typedef int (*eth_timesync_disable_t)(
struct rte_eth_dev *dev);
1304 typedef int (*eth_timesync_read_rx_timestamp_t)(
struct rte_eth_dev *dev,
1305 struct timespec *timestamp,
1309 typedef int (*eth_timesync_read_tx_timestamp_t)(
struct rte_eth_dev *dev,
1310 struct timespec *timestamp);
1313 typedef int (*eth_timesync_adjust_time)(
struct rte_eth_dev *dev, int64_t);
1316 typedef int (*eth_timesync_read_time)(
struct rte_eth_dev *dev,
1317 struct timespec *timestamp);
1320 typedef int (*eth_timesync_write_time)(
struct rte_eth_dev *dev,
1321 const struct timespec *timestamp);
1324 typedef int (*eth_get_reg_t)(
struct rte_eth_dev *dev,
1325 struct rte_dev_reg_info *info);
1328 typedef int (*eth_get_eeprom_length_t)(
struct rte_eth_dev *dev);
1331 typedef int (*eth_get_eeprom_t)(
struct rte_eth_dev *dev,
1332 struct rte_dev_eeprom_info *info);
1335 typedef int (*eth_set_eeprom_t)(
struct rte_eth_dev *dev,
1336 struct rte_dev_eeprom_info *info);
1339 typedef int (*eth_l2_tunnel_eth_type_conf_t)
1343 typedef int (*eth_l2_tunnel_offload_set_t)
1344 (
struct rte_eth_dev *dev,
1350 #ifdef RTE_NIC_BYPASS
1353 RTE_BYPASS_MODE_NONE,
1354 RTE_BYPASS_MODE_NORMAL,
1355 RTE_BYPASS_MODE_BYPASS,
1356 RTE_BYPASS_MODE_ISOLATE,
1357 RTE_BYPASS_MODE_NUM,
1360 #define RTE_BYPASS_MODE_VALID(x) \
1361 ((x) > RTE_BYPASS_MODE_NONE && (x) < RTE_BYPASS_MODE_NUM)
1364 RTE_BYPASS_EVENT_NONE,
1365 RTE_BYPASS_EVENT_START,
1366 RTE_BYPASS_EVENT_OS_ON = RTE_BYPASS_EVENT_START,
1367 RTE_BYPASS_EVENT_POWER_ON,
1368 RTE_BYPASS_EVENT_OS_OFF,
1369 RTE_BYPASS_EVENT_POWER_OFF,
1370 RTE_BYPASS_EVENT_TIMEOUT,
1371 RTE_BYPASS_EVENT_NUM
1374 #define RTE_BYPASS_EVENT_VALID(x) \
1375 ((x) > RTE_BYPASS_EVENT_NONE && (x) < RTE_BYPASS_MODE_NUM)
1379 RTE_BYPASS_TMT_1_5_SEC,
1380 RTE_BYPASS_TMT_2_SEC,
1381 RTE_BYPASS_TMT_3_SEC,
1382 RTE_BYPASS_TMT_4_SEC,
1383 RTE_BYPASS_TMT_8_SEC,
1384 RTE_BYPASS_TMT_16_SEC,
1385 RTE_BYPASS_TMT_32_SEC,
1389 #define RTE_BYPASS_TMT_VALID(x) \
1390 ((x) == RTE_BYPASS_TMT_OFF || \
1391 ((x) > RTE_BYPASS_TMT_OFF && (x) < RTE_BYPASS_TMT_NUM))
1393 typedef void (*bypass_init_t)(
struct rte_eth_dev *dev);
1394 typedef int32_t (*bypass_state_set_t)(
struct rte_eth_dev *dev, uint32_t *new_state);
1395 typedef int32_t (*bypass_state_show_t)(
struct rte_eth_dev *dev, uint32_t *state);
1396 typedef int32_t (*bypass_event_set_t)(
struct rte_eth_dev *dev, uint32_t state, uint32_t event);
1397 typedef int32_t (*bypass_event_show_t)(
struct rte_eth_dev *dev, uint32_t event_shift, uint32_t *event);
1398 typedef int32_t (*bypass_wd_timeout_set_t)(
struct rte_eth_dev *dev, uint32_t timeout);
1399 typedef int32_t (*bypass_wd_timeout_show_t)(
struct rte_eth_dev *dev, uint32_t *wd_timeout);
1400 typedef int32_t (*bypass_ver_show_t)(
struct rte_eth_dev *dev, uint32_t *ver);
1401 typedef int32_t (*bypass_wd_reset_t)(
struct rte_eth_dev *dev);
1404 typedef int (*eth_filter_ctrl_t)(
struct rte_eth_dev *dev,
1410 typedef int (*eth_get_dcb_info)(
struct rte_eth_dev *dev,
1417 struct eth_dev_ops {
1418 eth_dev_configure_t dev_configure;
1419 eth_dev_start_t dev_start;
1420 eth_dev_stop_t dev_stop;
1421 eth_dev_set_link_up_t dev_set_link_up;
1422 eth_dev_set_link_down_t dev_set_link_down;
1423 eth_dev_close_t dev_close;
1424 eth_promiscuous_enable_t promiscuous_enable;
1425 eth_promiscuous_disable_t promiscuous_disable;
1426 eth_allmulticast_enable_t allmulticast_enable;
1427 eth_allmulticast_disable_t allmulticast_disable;
1428 eth_link_update_t link_update;
1429 eth_stats_get_t stats_get;
1430 eth_stats_reset_t stats_reset;
1431 eth_xstats_get_t xstats_get;
1432 eth_xstats_reset_t xstats_reset;
1433 eth_xstats_get_names_t xstats_get_names;
1435 eth_queue_stats_mapping_set_t queue_stats_mapping_set;
1437 eth_dev_infos_get_t dev_infos_get;
1438 eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
1441 vlan_filter_set_t vlan_filter_set;
1442 vlan_tpid_set_t vlan_tpid_set;
1443 vlan_strip_queue_set_t vlan_strip_queue_set;
1444 vlan_offload_set_t vlan_offload_set;
1445 vlan_pvid_set_t vlan_pvid_set;
1446 eth_queue_start_t rx_queue_start;
1447 eth_queue_stop_t rx_queue_stop;
1448 eth_queue_start_t tx_queue_start;
1449 eth_queue_stop_t tx_queue_stop;
1450 eth_rx_queue_setup_t rx_queue_setup;
1451 eth_queue_release_t rx_queue_release;
1452 eth_rx_queue_count_t rx_queue_count;
1453 eth_rx_descriptor_done_t rx_descriptor_done;
1455 eth_rx_enable_intr_t rx_queue_intr_enable;
1457 eth_rx_disable_intr_t rx_queue_intr_disable;
1458 eth_tx_queue_setup_t tx_queue_setup;
1459 eth_queue_release_t tx_queue_release;
1460 eth_dev_led_on_t dev_led_on;
1461 eth_dev_led_off_t dev_led_off;
1462 flow_ctrl_get_t flow_ctrl_get;
1463 flow_ctrl_set_t flow_ctrl_set;
1464 priority_flow_ctrl_set_t priority_flow_ctrl_set;
1465 eth_mac_addr_remove_t mac_addr_remove;
1466 eth_mac_addr_add_t mac_addr_add;
1467 eth_mac_addr_set_t mac_addr_set;
1468 eth_uc_hash_table_set_t uc_hash_table_set;
1469 eth_uc_all_hash_table_set_t uc_all_hash_table_set;
1470 eth_mirror_rule_set_t mirror_rule_set;
1471 eth_mirror_rule_reset_t mirror_rule_reset;
1472 eth_set_vf_rx_mode_t set_vf_rx_mode;
1473 eth_set_vf_rx_t set_vf_rx;
1474 eth_set_vf_tx_t set_vf_tx;
1475 eth_set_vf_vlan_filter_t set_vf_vlan_filter;
1477 eth_udp_tunnel_port_add_t udp_tunnel_port_add;
1479 eth_udp_tunnel_port_del_t udp_tunnel_port_del;
1480 eth_set_queue_rate_limit_t set_queue_rate_limit;
1481 eth_set_vf_rate_limit_t set_vf_rate_limit;
1483 reta_update_t reta_update;
1485 reta_query_t reta_query;
1487 eth_get_reg_t get_reg;
1489 eth_get_eeprom_length_t get_eeprom_length;
1491 eth_get_eeprom_t get_eeprom;
1493 eth_set_eeprom_t set_eeprom;
1496 #ifdef RTE_NIC_BYPASS
1497 bypass_init_t bypass_init;
1498 bypass_state_set_t bypass_state_set;
1499 bypass_state_show_t bypass_state_show;
1500 bypass_event_set_t bypass_event_set;
1501 bypass_event_show_t bypass_event_show;
1502 bypass_wd_timeout_set_t bypass_wd_timeout_set;
1503 bypass_wd_timeout_show_t bypass_wd_timeout_show;
1504 bypass_ver_show_t bypass_ver_show;
1505 bypass_wd_reset_t bypass_wd_reset;
1509 rss_hash_update_t rss_hash_update;
1511 rss_hash_conf_get_t rss_hash_conf_get;
1512 eth_filter_ctrl_t filter_ctrl;
1514 eth_set_mc_addr_list_t set_mc_addr_list;
1515 eth_rxq_info_get_t rxq_info_get;
1517 eth_txq_info_get_t txq_info_get;
1520 eth_timesync_enable_t timesync_enable;
1522 eth_timesync_disable_t timesync_disable;
1524 eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
1526 eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
1529 eth_get_dcb_info get_dcb_info;
1531 eth_timesync_adjust_time timesync_adjust_time;
1533 eth_timesync_read_time timesync_read_time;
1535 eth_timesync_write_time timesync_write_time;
1537 eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
1539 eth_l2_tunnel_offload_set_t l2_tunnel_offload_set;
1565 struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts,
1589 struct rte_mbuf *pkts[], uint16_t nb_pkts,
void *user_param);
1596 struct rte_eth_rxtx_callback {
1597 struct rte_eth_rxtx_callback *next;
1626 struct rte_eth_dev {
1627 eth_rx_burst_t rx_pkt_burst;
1628 eth_tx_burst_t tx_pkt_burst;
1629 struct rte_eth_dev_data *data;
1630 const struct eth_driver *driver;
1631 const struct eth_dev_ops *dev_ops;
1634 struct rte_eth_dev_cb_list link_intr_cbs;
1639 struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
1644 struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
1649 struct rte_eth_dev_sriov {
1651 uint8_t nb_q_per_pool;
1652 uint16_t def_vmdq_idx;
1653 uint16_t def_pool_q_idx;
1655 #define RTE_ETH_DEV_SRIOV(dev) ((dev)->data->sriov)
1657 #define RTE_ETH_NAME_MAX_LEN (32)
1666 struct rte_eth_dev_data {
1667 char name[RTE_ETH_NAME_MAX_LEN];
1671 uint16_t nb_rx_queues;
1672 uint16_t nb_tx_queues;
1674 struct rte_eth_dev_sriov sriov;
1684 uint32_t min_rx_buf_size;
1687 uint64_t rx_mbuf_alloc_failed;
1694 uint8_t promiscuous : 1,
1699 uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
1701 uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
1704 enum rte_kernel_driver kdrv;
1706 const char *drv_name;
1710 #define RTE_ETH_DEV_DETACHABLE 0x0001
1712 #define RTE_ETH_DEV_INTR_LSC 0x0002
1714 #define RTE_ETH_DEV_BONDED_SLAVE 0x0004
1721 extern struct rte_eth_dev rte_eth_devices[];
1747 struct rte_eth_dev *rte_eth_dev_allocated(
const char *name);
1759 struct rte_eth_dev *rte_eth_dev_allocate(
const char *name,
1771 int rte_eth_dev_release_port(
struct rte_eth_dev *eth_dev);
1832 typedef int (*eth_dev_init_t)(
struct rte_eth_dev *eth_dev);
1849 typedef int (*eth_dev_uninit_t)(
struct rte_eth_dev *eth_dev);
1868 eth_dev_init_t eth_dev_init;
1869 eth_dev_uninit_t eth_dev_uninit;
1870 unsigned int dev_private_size;
1883 void rte_eth_driver_register(
struct eth_driver *eth_drv);
1928 uint16_t nb_tx_queue,
const struct rte_eth_conf *eth_conf);
1970 uint16_t nb_rx_desc,
unsigned int socket_id,
2018 uint16_t nb_tx_desc,
unsigned int socket_id,
2356 uint16_t tx_queue_id, uint8_t stat_idx);
2376 uint16_t rx_queue_id,
2440 uint32_t *ptypes,
int num);
2667 static inline uint16_t
2669 struct rte_mbuf **rx_pkts,
const uint16_t nb_pkts)
2671 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2673 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
2674 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
2675 RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
2677 if (queue_id >= dev->data->nb_rx_queues) {
2678 RTE_PMD_DEBUG_TRACE(
"Invalid RX queue_id=%d\n", queue_id);
2682 int16_t nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
2685 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
2686 struct rte_eth_rxtx_callback *cb = dev->post_rx_burst_cbs[queue_id];
2690 nb_rx = cb->fn.rx(port_id, queue_id, rx_pkts, nb_rx,
2691 nb_pkts, cb->param);
2693 }
while (cb != NULL);
2715 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2716 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
2717 RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
2718 return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
2739 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2740 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
2741 RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
2742 return (*dev->dev_ops->rx_descriptor_done)( \
2743 dev->data->rx_queues[queue_id], offset);
2805 static inline uint16_t
2807 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
2809 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2811 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
2812 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
2813 RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
2815 if (queue_id >= dev->data->nb_tx_queues) {
2816 RTE_PMD_DEBUG_TRACE(
"Invalid TX queue_id=%d\n", queue_id);
2821 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
2822 struct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id];
2826 nb_pkts = cb->fn.tx(port_id, queue_id, tx_pkts, nb_pkts,
2829 }
while (cb != NULL);
2833 return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
2836 typedef void (*buffer_tx_error_fn)(
struct rte_mbuf **unsent, uint16_t count,
2844 buffer_tx_error_fn error_callback;
2845 void *error_userdata;
2858 #define RTE_ETH_TX_BUFFER_SIZE(sz) \
2859 (sizeof(struct rte_eth_dev_tx_buffer) + (sz) * sizeof(struct rte_mbuf *))
2896 static inline uint16_t
2901 uint16_t to_send = buffer->
length;
2912 buffer->error_callback(&buffer->
pkts[sent], to_send - sent,
2913 buffer->error_userdata);
2948 static inline uint16_t __attribute__((always_inline))
2952 buffer->pkts[buffer->length++] = tx_pkt;
2953 if (buffer->length < buffer->size)
2985 buffer_tx_error_fn callback,
void *
userdata);
3113 void _rte_eth_dev_callback_process(
struct rte_eth_dev *dev,
3200 int epfd,
int op,
void *data);
3349 uint16_t reta_size);
3368 uint16_t reta_size);
3575 uint16_t tx_rate, uint64_t q_msk);
3921 void *rte_eth_add_first_rx_callback(uint8_t port_id, uint16_t queue_id,
3982 struct rte_eth_rxtx_callback *user_cb);
4015 struct rte_eth_rxtx_callback *user_cb);
4139 uint32_t nb_mc_addr);
4185 struct timespec *timestamp, uint32_t flags);
4202 struct timespec *timestamp);
4292 uint16_t queue_id,
size_t size,