34 #ifndef _RTE_ETHDEV_H_
35 #define _RTE_ETHDEV_H_
178 #define RTE_ETHDEV_HAS_LRO_SUPPORT
187 #include "rte_dev_info.h"
224 uint64_t
q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
226 uint64_t
q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
228 uint64_t
q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
230 uint64_t
q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
232 uint64_t
q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
247 #define ETH_LINK_SPEED_AUTONEG (0 << 0)
248 #define ETH_LINK_SPEED_FIXED (1 << 0)
249 #define ETH_LINK_SPEED_10M_HD (1 << 1)
250 #define ETH_LINK_SPEED_10M (1 << 2)
251 #define ETH_LINK_SPEED_100M_HD (1 << 3)
252 #define ETH_LINK_SPEED_100M (1 << 4)
253 #define ETH_LINK_SPEED_1G (1 << 5)
254 #define ETH_LINK_SPEED_2_5G (1 << 6)
255 #define ETH_LINK_SPEED_5G (1 << 7)
256 #define ETH_LINK_SPEED_10G (1 << 8)
257 #define ETH_LINK_SPEED_20G (1 << 9)
258 #define ETH_LINK_SPEED_25G (1 << 10)
259 #define ETH_LINK_SPEED_40G (1 << 11)
260 #define ETH_LINK_SPEED_50G (1 << 12)
261 #define ETH_LINK_SPEED_56G (1 << 13)
262 #define ETH_LINK_SPEED_100G (1 << 14)
267 #define ETH_SPEED_NUM_NONE 0
268 #define ETH_SPEED_NUM_10M 10
269 #define ETH_SPEED_NUM_100M 100
270 #define ETH_SPEED_NUM_1G 1000
271 #define ETH_SPEED_NUM_2_5G 2500
272 #define ETH_SPEED_NUM_5G 5000
273 #define ETH_SPEED_NUM_10G 10000
274 #define ETH_SPEED_NUM_20G 20000
275 #define ETH_SPEED_NUM_25G 25000
276 #define ETH_SPEED_NUM_40G 40000
277 #define ETH_SPEED_NUM_50G 50000
278 #define ETH_SPEED_NUM_56G 56000
279 #define ETH_SPEED_NUM_100G 100000
284 struct rte_eth_link {
286 uint16_t link_duplex : 1;
287 uint16_t link_autoneg : 1;
288 uint16_t link_status : 1;
289 } __attribute__((aligned(8)));
292 #define ETH_LINK_HALF_DUPLEX 0
293 #define ETH_LINK_FULL_DUPLEX 1
294 #define ETH_LINK_DOWN 0
295 #define ETH_LINK_UP 1
296 #define ETH_LINK_FIXED 0
297 #define ETH_LINK_AUTONEG 1
303 struct rte_eth_thresh {
312 #define ETH_MQ_RX_RSS_FLAG 0x1
313 #define ETH_MQ_RX_DCB_FLAG 0x2
314 #define ETH_MQ_RX_VMDQ_FLAG 0x4
345 #define ETH_RSS ETH_MQ_RX_RSS
346 #define VMDQ_DCB ETH_MQ_RX_VMDQ_DCB
347 #define ETH_DCB_RX ETH_MQ_RX_DCB
363 #define ETH_DCB_NONE ETH_MQ_TX_NONE
364 #define ETH_VMDQ_DCB_TX ETH_MQ_TX_VMDQ_DCB
365 #define ETH_DCB_TX ETH_MQ_TX_DCB
391 ETH_VLAN_TYPE_UNKNOWN = 0,
426 #define ETH_RSS_IPV4 (1ULL << RTE_ETH_FLOW_IPV4)
427 #define ETH_RSS_FRAG_IPV4 (1ULL << RTE_ETH_FLOW_FRAG_IPV4)
428 #define ETH_RSS_NONFRAG_IPV4_TCP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_TCP)
429 #define ETH_RSS_NONFRAG_IPV4_UDP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_UDP)
430 #define ETH_RSS_NONFRAG_IPV4_SCTP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_SCTP)
431 #define ETH_RSS_NONFRAG_IPV4_OTHER (1ULL << RTE_ETH_FLOW_NONFRAG_IPV4_OTHER)
432 #define ETH_RSS_IPV6 (1ULL << RTE_ETH_FLOW_IPV6)
433 #define ETH_RSS_FRAG_IPV6 (1ULL << RTE_ETH_FLOW_FRAG_IPV6)
434 #define ETH_RSS_NONFRAG_IPV6_TCP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_TCP)
435 #define ETH_RSS_NONFRAG_IPV6_UDP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_UDP)
436 #define ETH_RSS_NONFRAG_IPV6_SCTP (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_SCTP)
437 #define ETH_RSS_NONFRAG_IPV6_OTHER (1ULL << RTE_ETH_FLOW_NONFRAG_IPV6_OTHER)
438 #define ETH_RSS_L2_PAYLOAD (1ULL << RTE_ETH_FLOW_L2_PAYLOAD)
439 #define ETH_RSS_IPV6_EX (1ULL << RTE_ETH_FLOW_IPV6_EX)
440 #define ETH_RSS_IPV6_TCP_EX (1ULL << RTE_ETH_FLOW_IPV6_TCP_EX)
441 #define ETH_RSS_IPV6_UDP_EX (1ULL << RTE_ETH_FLOW_IPV6_UDP_EX)
443 #define ETH_RSS_IP ( \
445 ETH_RSS_FRAG_IPV4 | \
446 ETH_RSS_NONFRAG_IPV4_OTHER | \
448 ETH_RSS_FRAG_IPV6 | \
449 ETH_RSS_NONFRAG_IPV6_OTHER | \
452 #define ETH_RSS_UDP ( \
453 ETH_RSS_NONFRAG_IPV4_UDP | \
454 ETH_RSS_NONFRAG_IPV6_UDP | \
457 #define ETH_RSS_TCP ( \
458 ETH_RSS_NONFRAG_IPV4_TCP | \
459 ETH_RSS_NONFRAG_IPV6_TCP | \
462 #define ETH_RSS_SCTP ( \
463 ETH_RSS_NONFRAG_IPV4_SCTP | \
464 ETH_RSS_NONFRAG_IPV6_SCTP)
467 #define ETH_RSS_PROTO_MASK ( \
469 ETH_RSS_FRAG_IPV4 | \
470 ETH_RSS_NONFRAG_IPV4_TCP | \
471 ETH_RSS_NONFRAG_IPV4_UDP | \
472 ETH_RSS_NONFRAG_IPV4_SCTP | \
473 ETH_RSS_NONFRAG_IPV4_OTHER | \
475 ETH_RSS_FRAG_IPV6 | \
476 ETH_RSS_NONFRAG_IPV6_TCP | \
477 ETH_RSS_NONFRAG_IPV6_UDP | \
478 ETH_RSS_NONFRAG_IPV6_SCTP | \
479 ETH_RSS_NONFRAG_IPV6_OTHER | \
480 ETH_RSS_L2_PAYLOAD | \
482 ETH_RSS_IPV6_TCP_EX | \
490 #define ETH_RSS_RETA_SIZE_64 64
491 #define ETH_RSS_RETA_SIZE_128 128
492 #define ETH_RSS_RETA_SIZE_512 512
493 #define RTE_RETA_GROUP_SIZE 64
496 #define ETH_VMDQ_MAX_VLAN_FILTERS 64
497 #define ETH_DCB_NUM_USER_PRIORITIES 8
498 #define ETH_VMDQ_DCB_NUM_QUEUES 128
499 #define ETH_DCB_NUM_QUEUES 128
502 #define ETH_DCB_PG_SUPPORT 0x00000001
503 #define ETH_DCB_PFC_SUPPORT 0x00000002
506 #define ETH_VLAN_STRIP_OFFLOAD 0x0001
507 #define ETH_VLAN_FILTER_OFFLOAD 0x0002
508 #define ETH_VLAN_EXTEND_OFFLOAD 0x0004
511 #define ETH_VLAN_STRIP_MASK 0x0001
512 #define ETH_VLAN_FILTER_MASK 0x0002
513 #define ETH_VLAN_EXTEND_MASK 0x0004
514 #define ETH_VLAN_ID_MAX 0x0FFF
517 #define ETH_NUM_RECEIVE_MAC_ADDR 128
520 #define ETH_VMDQ_NUM_UC_HASH_ARRAY 128
523 #define ETH_VMDQ_ACCEPT_UNTAG 0x0001
524 #define ETH_VMDQ_ACCEPT_HASH_MC 0x0002
525 #define ETH_VMDQ_ACCEPT_HASH_UC 0x0004
526 #define ETH_VMDQ_ACCEPT_BROADCAST 0x0008
527 #define ETH_VMDQ_ACCEPT_MULTICAST 0x0010
530 #define ETH_MIRROR_MAX_VLANS 64
532 #define ETH_MIRROR_VIRTUAL_POOL_UP 0x01
533 #define ETH_MIRROR_UPLINK_PORT 0x02
534 #define ETH_MIRROR_DOWNLINK_PORT 0x04
535 #define ETH_MIRROR_VLAN 0x08
536 #define ETH_MIRROR_VIRTUAL_POOL_DOWN 0x10
541 struct rte_eth_vlan_mirror {
567 uint16_t
reta[RTE_RETA_GROUP_SIZE];
592 struct rte_eth_dcb_rx_conf {
598 struct rte_eth_vmdq_dcb_tx_conf {
604 struct rte_eth_dcb_tx_conf {
610 struct rte_eth_vmdq_tx_conf {
638 struct rte_eth_vmdq_rx_conf {
640 uint8_t enable_default_pool;
641 uint8_t default_pool;
642 uint8_t enable_loop_back;
643 uint8_t nb_pool_maps;
677 #define ETH_TXQ_FLAGS_NOMULTSEGS 0x0001
678 #define ETH_TXQ_FLAGS_NOREFCOUNT 0x0002
679 #define ETH_TXQ_FLAGS_NOMULTMEMP 0x0004
680 #define ETH_TXQ_FLAGS_NOVLANOFFL 0x0100
681 #define ETH_TXQ_FLAGS_NOXSUMSCTP 0x0200
682 #define ETH_TXQ_FLAGS_NOXSUMUDP 0x0400
683 #define ETH_TXQ_FLAGS_NOXSUMTCP 0x0800
684 #define ETH_TXQ_FLAGS_NOOFFLOADS \
685 (ETH_TXQ_FLAGS_NOVLANOFFL | ETH_TXQ_FLAGS_NOXSUMSCTP | \
686 ETH_TXQ_FLAGS_NOXSUMUDP | ETH_TXQ_FLAGS_NOXSUMTCP)
687 #define ETH_TXQ_FLAGS_NOXSUMS \
688 (ETH_TXQ_FLAGS_NOXSUMSCTP | ETH_TXQ_FLAGS_NOXSUMUDP | \
689 ETH_TXQ_FLAGS_NOXSUMTCP)
858 #define DEV_RX_OFFLOAD_VLAN_STRIP 0x00000001
859 #define DEV_RX_OFFLOAD_IPV4_CKSUM 0x00000002
860 #define DEV_RX_OFFLOAD_UDP_CKSUM 0x00000004
861 #define DEV_RX_OFFLOAD_TCP_CKSUM 0x00000008
862 #define DEV_RX_OFFLOAD_TCP_LRO 0x00000010
863 #define DEV_RX_OFFLOAD_QINQ_STRIP 0x00000020
864 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000040
869 #define DEV_TX_OFFLOAD_VLAN_INSERT 0x00000001
870 #define DEV_TX_OFFLOAD_IPV4_CKSUM 0x00000002
871 #define DEV_TX_OFFLOAD_UDP_CKSUM 0x00000004
872 #define DEV_TX_OFFLOAD_TCP_CKSUM 0x00000008
873 #define DEV_TX_OFFLOAD_SCTP_CKSUM 0x00000010
874 #define DEV_TX_OFFLOAD_TCP_TSO 0x00000020
875 #define DEV_TX_OFFLOAD_UDP_TSO 0x00000040
876 #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080
877 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
892 uint32_t max_hash_mac_addrs;
934 #define RTE_ETH_XSTATS_NAME_SIZE 64
948 #define ETH_DCB_NUM_TCS 8
949 #define ETH_MAX_VMDQ_POOL 64
960 }
tc_rxq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
965 }
tc_txq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
983 #define RTE_ETH_QUEUE_STATE_STOPPED 0
984 #define RTE_ETH_QUEUE_STATE_STARTED 1
988 struct rte_eth_dev_callback;
990 TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
993 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
994 #define RTE_PMD_DEBUG_TRACE(...) \
995 rte_pmd_debug_trace(__func__, __VA_ARGS__)
997 #define RTE_PMD_DEBUG_TRACE(...)
1002 #define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \
1003 if (!rte_eth_dev_is_valid_port(port_id)) { \
1004 RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
1009 #define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \
1010 if (!rte_eth_dev_is_valid_port(port_id)) { \
1011 RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
1021 #define ETH_L2_TUNNEL_ENABLE_MASK 0x00000001
1023 #define ETH_L2_TUNNEL_INSERTION_MASK 0x00000002
1025 #define ETH_L2_TUNNEL_STRIPPING_MASK 0x00000004
1027 #define ETH_L2_TUNNEL_FORWARDING_MASK 0x00000008
1035 typedef int (*eth_dev_configure_t)(
struct rte_eth_dev *dev);
1038 typedef int (*eth_dev_start_t)(
struct rte_eth_dev *dev);
1041 typedef void (*eth_dev_stop_t)(
struct rte_eth_dev *dev);
1044 typedef int (*eth_dev_set_link_up_t)(
struct rte_eth_dev *dev);
1047 typedef int (*eth_dev_set_link_down_t)(
struct rte_eth_dev *dev);
1050 typedef void (*eth_dev_close_t)(
struct rte_eth_dev *dev);
1053 typedef void (*eth_promiscuous_enable_t)(
struct rte_eth_dev *dev);
1056 typedef void (*eth_promiscuous_disable_t)(
struct rte_eth_dev *dev);
1059 typedef void (*eth_allmulticast_enable_t)(
struct rte_eth_dev *dev);
1062 typedef void (*eth_allmulticast_disable_t)(
struct rte_eth_dev *dev);
1065 typedef int (*eth_link_update_t)(
struct rte_eth_dev *dev,
1066 int wait_to_complete);
1069 typedef void (*eth_stats_get_t)(
struct rte_eth_dev *dev,
1073 typedef void (*eth_stats_reset_t)(
struct rte_eth_dev *dev);
1076 typedef int (*eth_xstats_get_t)(
struct rte_eth_dev *dev,
1080 typedef void (*eth_xstats_reset_t)(
struct rte_eth_dev *dev);
1083 typedef int (*eth_queue_stats_mapping_set_t)(
struct rte_eth_dev *dev,
1089 typedef void (*eth_dev_infos_get_t)(
struct rte_eth_dev *dev,
1093 typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(
struct rte_eth_dev *dev);
1096 typedef int (*eth_queue_start_t)(
struct rte_eth_dev *dev,
1100 typedef int (*eth_queue_stop_t)(
struct rte_eth_dev *dev,
1104 typedef int (*eth_rx_queue_setup_t)(
struct rte_eth_dev *dev,
1105 uint16_t rx_queue_id,
1106 uint16_t nb_rx_desc,
1107 unsigned int socket_id,
1112 typedef int (*eth_tx_queue_setup_t)(
struct rte_eth_dev *dev,
1113 uint16_t tx_queue_id,
1114 uint16_t nb_tx_desc,
1115 unsigned int socket_id,
1119 typedef int (*eth_rx_enable_intr_t)(
struct rte_eth_dev *dev,
1120 uint16_t rx_queue_id);
1123 typedef int (*eth_rx_disable_intr_t)(
struct rte_eth_dev *dev,
1124 uint16_t rx_queue_id);
1127 typedef void (*eth_queue_release_t)(
void *queue);
1130 typedef uint32_t (*eth_rx_queue_count_t)(
struct rte_eth_dev *dev,
1131 uint16_t rx_queue_id);
1134 typedef int (*eth_rx_descriptor_done_t)(
void *rxq, uint16_t offset);
1137 typedef void (*eth_rxq_info_get_t)(
struct rte_eth_dev *dev,
1140 typedef void (*eth_txq_info_get_t)(
struct rte_eth_dev *dev,
1143 typedef int (*mtu_set_t)(
struct rte_eth_dev *dev, uint16_t mtu);
1146 typedef int (*vlan_filter_set_t)(
struct rte_eth_dev *dev,
1151 typedef int (*vlan_tpid_set_t)(
struct rte_eth_dev *dev,
1155 typedef void (*vlan_offload_set_t)(
struct rte_eth_dev *dev,
int mask);
1158 typedef int (*vlan_pvid_set_t)(
struct rte_eth_dev *dev,
1163 typedef void (*vlan_strip_queue_set_t)(
struct rte_eth_dev *dev,
1164 uint16_t rx_queue_id,
1168 typedef uint16_t (*eth_rx_burst_t)(
void *rxq,
1173 typedef uint16_t (*eth_tx_burst_t)(
void *txq,
1178 typedef int (*flow_ctrl_get_t)(
struct rte_eth_dev *dev,
1182 typedef int (*flow_ctrl_set_t)(
struct rte_eth_dev *dev,
1186 typedef int (*priority_flow_ctrl_set_t)(
struct rte_eth_dev *dev,
1190 typedef int (*reta_update_t)(
struct rte_eth_dev *dev,
1192 uint16_t reta_size);
1195 typedef int (*reta_query_t)(
struct rte_eth_dev *dev,
1197 uint16_t reta_size);
1200 typedef int (*rss_hash_update_t)(
struct rte_eth_dev *dev,
1204 typedef int (*rss_hash_conf_get_t)(
struct rte_eth_dev *dev,
1208 typedef int (*eth_dev_led_on_t)(
struct rte_eth_dev *dev);
1211 typedef int (*eth_dev_led_off_t)(
struct rte_eth_dev *dev);
1214 typedef void (*eth_mac_addr_remove_t)(
struct rte_eth_dev *dev, uint32_t index);
1217 typedef void (*eth_mac_addr_add_t)(
struct rte_eth_dev *dev,
1223 typedef void (*eth_mac_addr_set_t)(
struct rte_eth_dev *dev,
1227 typedef int (*eth_uc_hash_table_set_t)(
struct rte_eth_dev *dev,
1232 typedef int (*eth_uc_all_hash_table_set_t)(
struct rte_eth_dev *dev,
1236 typedef int (*eth_set_vf_rx_mode_t)(
struct rte_eth_dev *dev,
1242 typedef int (*eth_set_vf_rx_t)(
struct rte_eth_dev *dev,
1247 typedef int (*eth_set_vf_tx_t)(
struct rte_eth_dev *dev,
1252 typedef int (*eth_set_vf_vlan_filter_t)(
struct rte_eth_dev *dev,
1258 typedef int (*eth_set_queue_rate_limit_t)(
struct rte_eth_dev *dev,
1263 typedef int (*eth_set_vf_rate_limit_t)(
struct rte_eth_dev *dev,
1269 typedef int (*eth_mirror_rule_set_t)(
struct rte_eth_dev *dev,
1275 typedef int (*eth_mirror_rule_reset_t)(
struct rte_eth_dev *dev,
1279 typedef int (*eth_udp_tunnel_port_add_t)(
struct rte_eth_dev *dev,
1283 typedef int (*eth_udp_tunnel_port_del_t)(
struct rte_eth_dev *dev,
1287 typedef int (*eth_set_mc_addr_list_t)(
struct rte_eth_dev *dev,
1289 uint32_t nb_mc_addr);
1292 typedef int (*eth_timesync_enable_t)(
struct rte_eth_dev *dev);
1295 typedef int (*eth_timesync_disable_t)(
struct rte_eth_dev *dev);
1298 typedef int (*eth_timesync_read_rx_timestamp_t)(
struct rte_eth_dev *dev,
1299 struct timespec *timestamp,
1303 typedef int (*eth_timesync_read_tx_timestamp_t)(
struct rte_eth_dev *dev,
1304 struct timespec *timestamp);
1307 typedef int (*eth_timesync_adjust_time)(
struct rte_eth_dev *dev, int64_t);
1310 typedef int (*eth_timesync_read_time)(
struct rte_eth_dev *dev,
1311 struct timespec *timestamp);
1314 typedef int (*eth_timesync_write_time)(
struct rte_eth_dev *dev,
1315 const struct timespec *timestamp);
1318 typedef int (*eth_get_reg_length_t)(
struct rte_eth_dev *dev);
1321 typedef int (*eth_get_reg_t)(
struct rte_eth_dev *dev,
1322 struct rte_dev_reg_info *info);
1325 typedef int (*eth_get_eeprom_length_t)(
struct rte_eth_dev *dev);
1328 typedef int (*eth_get_eeprom_t)(
struct rte_eth_dev *dev,
1329 struct rte_dev_eeprom_info *info);
1332 typedef int (*eth_set_eeprom_t)(
struct rte_eth_dev *dev,
1333 struct rte_dev_eeprom_info *info);
1336 typedef int (*eth_l2_tunnel_eth_type_conf_t)
1340 typedef int (*eth_l2_tunnel_offload_set_t)
1341 (
struct rte_eth_dev *dev,
1347 #ifdef RTE_NIC_BYPASS
1350 RTE_BYPASS_MODE_NONE,
1351 RTE_BYPASS_MODE_NORMAL,
1352 RTE_BYPASS_MODE_BYPASS,
1353 RTE_BYPASS_MODE_ISOLATE,
1354 RTE_BYPASS_MODE_NUM,
1357 #define RTE_BYPASS_MODE_VALID(x) \
1358 ((x) > RTE_BYPASS_MODE_NONE && (x) < RTE_BYPASS_MODE_NUM)
1361 RTE_BYPASS_EVENT_NONE,
1362 RTE_BYPASS_EVENT_START,
1363 RTE_BYPASS_EVENT_OS_ON = RTE_BYPASS_EVENT_START,
1364 RTE_BYPASS_EVENT_POWER_ON,
1365 RTE_BYPASS_EVENT_OS_OFF,
1366 RTE_BYPASS_EVENT_POWER_OFF,
1367 RTE_BYPASS_EVENT_TIMEOUT,
1368 RTE_BYPASS_EVENT_NUM
1371 #define RTE_BYPASS_EVENT_VALID(x) \
1372 ((x) > RTE_BYPASS_EVENT_NONE && (x) < RTE_BYPASS_MODE_NUM)
1376 RTE_BYPASS_TMT_1_5_SEC,
1377 RTE_BYPASS_TMT_2_SEC,
1378 RTE_BYPASS_TMT_3_SEC,
1379 RTE_BYPASS_TMT_4_SEC,
1380 RTE_BYPASS_TMT_8_SEC,
1381 RTE_BYPASS_TMT_16_SEC,
1382 RTE_BYPASS_TMT_32_SEC,
1386 #define RTE_BYPASS_TMT_VALID(x) \
1387 ((x) == RTE_BYPASS_TMT_OFF || \
1388 ((x) > RTE_BYPASS_TMT_OFF && (x) < RTE_BYPASS_TMT_NUM))
1390 typedef void (*bypass_init_t)(
struct rte_eth_dev *dev);
1391 typedef int32_t (*bypass_state_set_t)(
struct rte_eth_dev *dev, uint32_t *new_state);
1392 typedef int32_t (*bypass_state_show_t)(
struct rte_eth_dev *dev, uint32_t *state);
1393 typedef int32_t (*bypass_event_set_t)(
struct rte_eth_dev *dev, uint32_t state, uint32_t event);
1394 typedef int32_t (*bypass_event_show_t)(
struct rte_eth_dev *dev, uint32_t event_shift, uint32_t *event);
1395 typedef int32_t (*bypass_wd_timeout_set_t)(
struct rte_eth_dev *dev, uint32_t timeout);
1396 typedef int32_t (*bypass_wd_timeout_show_t)(
struct rte_eth_dev *dev, uint32_t *wd_timeout);
1397 typedef int32_t (*bypass_ver_show_t)(
struct rte_eth_dev *dev, uint32_t *ver);
1398 typedef int32_t (*bypass_wd_reset_t)(
struct rte_eth_dev *dev);
1401 typedef int (*eth_filter_ctrl_t)(
struct rte_eth_dev *dev,
1407 typedef int (*eth_get_dcb_info)(
struct rte_eth_dev *dev,
1414 struct eth_dev_ops {
1415 eth_dev_configure_t dev_configure;
1416 eth_dev_start_t dev_start;
1417 eth_dev_stop_t dev_stop;
1418 eth_dev_set_link_up_t dev_set_link_up;
1419 eth_dev_set_link_down_t dev_set_link_down;
1420 eth_dev_close_t dev_close;
1421 eth_promiscuous_enable_t promiscuous_enable;
1422 eth_promiscuous_disable_t promiscuous_disable;
1423 eth_allmulticast_enable_t allmulticast_enable;
1424 eth_allmulticast_disable_t allmulticast_disable;
1425 eth_link_update_t link_update;
1426 eth_stats_get_t stats_get;
1427 eth_stats_reset_t stats_reset;
1428 eth_xstats_get_t xstats_get;
1429 eth_xstats_reset_t xstats_reset;
1430 eth_queue_stats_mapping_set_t queue_stats_mapping_set;
1432 eth_dev_infos_get_t dev_infos_get;
1433 eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
1436 vlan_filter_set_t vlan_filter_set;
1437 vlan_tpid_set_t vlan_tpid_set;
1438 vlan_strip_queue_set_t vlan_strip_queue_set;
1439 vlan_offload_set_t vlan_offload_set;
1440 vlan_pvid_set_t vlan_pvid_set;
1441 eth_queue_start_t rx_queue_start;
1442 eth_queue_stop_t rx_queue_stop;
1443 eth_queue_start_t tx_queue_start;
1444 eth_queue_stop_t tx_queue_stop;
1445 eth_rx_queue_setup_t rx_queue_setup;
1446 eth_queue_release_t rx_queue_release;
1447 eth_rx_queue_count_t rx_queue_count;
1448 eth_rx_descriptor_done_t rx_descriptor_done;
1450 eth_rx_enable_intr_t rx_queue_intr_enable;
1452 eth_rx_disable_intr_t rx_queue_intr_disable;
1453 eth_tx_queue_setup_t tx_queue_setup;
1454 eth_queue_release_t tx_queue_release;
1455 eth_dev_led_on_t dev_led_on;
1456 eth_dev_led_off_t dev_led_off;
1457 flow_ctrl_get_t flow_ctrl_get;
1458 flow_ctrl_set_t flow_ctrl_set;
1459 priority_flow_ctrl_set_t priority_flow_ctrl_set;
1460 eth_mac_addr_remove_t mac_addr_remove;
1461 eth_mac_addr_add_t mac_addr_add;
1462 eth_mac_addr_set_t mac_addr_set;
1463 eth_uc_hash_table_set_t uc_hash_table_set;
1464 eth_uc_all_hash_table_set_t uc_all_hash_table_set;
1465 eth_mirror_rule_set_t mirror_rule_set;
1466 eth_mirror_rule_reset_t mirror_rule_reset;
1467 eth_set_vf_rx_mode_t set_vf_rx_mode;
1468 eth_set_vf_rx_t set_vf_rx;
1469 eth_set_vf_tx_t set_vf_tx;
1470 eth_set_vf_vlan_filter_t set_vf_vlan_filter;
1472 eth_udp_tunnel_port_add_t udp_tunnel_port_add;
1474 eth_udp_tunnel_port_del_t udp_tunnel_port_del;
1475 eth_set_queue_rate_limit_t set_queue_rate_limit;
1476 eth_set_vf_rate_limit_t set_vf_rate_limit;
1478 reta_update_t reta_update;
1480 reta_query_t reta_query;
1482 eth_get_reg_length_t get_reg_length;
1484 eth_get_reg_t get_reg;
1486 eth_get_eeprom_length_t get_eeprom_length;
1488 eth_get_eeprom_t get_eeprom;
1490 eth_set_eeprom_t set_eeprom;
1493 #ifdef RTE_NIC_BYPASS
1494 bypass_init_t bypass_init;
1495 bypass_state_set_t bypass_state_set;
1496 bypass_state_show_t bypass_state_show;
1497 bypass_event_set_t bypass_event_set;
1498 bypass_event_show_t bypass_event_show;
1499 bypass_wd_timeout_set_t bypass_wd_timeout_set;
1500 bypass_wd_timeout_show_t bypass_wd_timeout_show;
1501 bypass_ver_show_t bypass_ver_show;
1502 bypass_wd_reset_t bypass_wd_reset;
1506 rss_hash_update_t rss_hash_update;
1508 rss_hash_conf_get_t rss_hash_conf_get;
1509 eth_filter_ctrl_t filter_ctrl;
1511 eth_set_mc_addr_list_t set_mc_addr_list;
1512 eth_rxq_info_get_t rxq_info_get;
1514 eth_txq_info_get_t txq_info_get;
1517 eth_timesync_enable_t timesync_enable;
1519 eth_timesync_disable_t timesync_disable;
1521 eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
1523 eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
1526 eth_get_dcb_info get_dcb_info;
1528 eth_timesync_adjust_time timesync_adjust_time;
1530 eth_timesync_read_time timesync_read_time;
1532 eth_timesync_write_time timesync_write_time;
1534 eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
1536 eth_l2_tunnel_offload_set_t l2_tunnel_offload_set;
1562 struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts,
1586 struct rte_mbuf *pkts[], uint16_t nb_pkts,
void *user_param);
1593 struct rte_eth_rxtx_callback {
1594 struct rte_eth_rxtx_callback *next;
1623 struct rte_eth_dev {
1624 eth_rx_burst_t rx_pkt_burst;
1625 eth_tx_burst_t tx_pkt_burst;
1626 struct rte_eth_dev_data *data;
1627 const struct eth_driver *driver;
1628 const struct eth_dev_ops *dev_ops;
1631 struct rte_eth_dev_cb_list link_intr_cbs;
1636 struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
1641 struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
1646 struct rte_eth_dev_sriov {
1648 uint8_t nb_q_per_pool;
1649 uint16_t def_vmdq_idx;
1650 uint16_t def_pool_q_idx;
1652 #define RTE_ETH_DEV_SRIOV(dev) ((dev)->data->sriov)
1654 #define RTE_ETH_NAME_MAX_LEN (32)
1663 struct rte_eth_dev_data {
1664 char name[RTE_ETH_NAME_MAX_LEN];
1668 uint16_t nb_rx_queues;
1669 uint16_t nb_tx_queues;
1671 struct rte_eth_dev_sriov sriov;
1681 uint32_t min_rx_buf_size;
1684 uint64_t rx_mbuf_alloc_failed;
1691 uint8_t promiscuous : 1,
1696 uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
1698 uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
1701 enum rte_kernel_driver kdrv;
1703 const char *drv_name;
1707 #define RTE_ETH_DEV_DETACHABLE 0x0001
1709 #define RTE_ETH_DEV_INTR_LSC 0x0002
1711 #define RTE_ETH_DEV_BONDED_SLAVE 0x0004
1718 extern struct rte_eth_dev rte_eth_devices[];
1744 struct rte_eth_dev *rte_eth_dev_allocated(
const char *name);
1756 struct rte_eth_dev *rte_eth_dev_allocate(
const char *name,
1768 int rte_eth_dev_release_port(
struct rte_eth_dev *eth_dev);
1829 typedef int (*eth_dev_init_t)(
struct rte_eth_dev *eth_dev);
1846 typedef int (*eth_dev_uninit_t)(
struct rte_eth_dev *eth_dev);
1865 eth_dev_init_t eth_dev_init;
1866 eth_dev_uninit_t eth_dev_uninit;
1867 unsigned int dev_private_size;
1880 void rte_eth_driver_register(
struct eth_driver *eth_drv);
1925 uint16_t nb_tx_queue,
const struct rte_eth_conf *eth_conf);
1967 uint16_t nb_rx_desc,
unsigned int socket_id,
2015 uint16_t nb_tx_desc,
unsigned int socket_id,
2028 int rte_eth_dev_socket_id(uint8_t port_id);
2039 int rte_eth_dev_is_valid_port(uint8_t port_id);
2057 int rte_eth_dev_rx_queue_start(uint8_t port_id, uint16_t rx_queue_id);
2073 int rte_eth_dev_rx_queue_stop(uint8_t port_id, uint16_t rx_queue_id);
2090 int rte_eth_dev_tx_queue_start(uint8_t port_id, uint16_t tx_queue_id);
2106 int rte_eth_dev_tx_queue_stop(uint8_t port_id, uint16_t tx_queue_id);
2331 uint16_t tx_queue_id, uint8_t stat_idx);
2351 uint16_t rx_queue_id,
2400 uint32_t *ptypes,
int num);
2626 static inline uint16_t
2628 struct rte_mbuf **rx_pkts,
const uint16_t nb_pkts)
2630 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2632 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
2633 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
2634 RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
2636 if (queue_id >= dev->data->nb_rx_queues) {
2637 RTE_PMD_DEBUG_TRACE(
"Invalid RX queue_id=%d\n", queue_id);
2641 int16_t nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
2644 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
2645 struct rte_eth_rxtx_callback *cb = dev->post_rx_burst_cbs[queue_id];
2649 nb_rx = cb->fn.rx(port_id, queue_id, rx_pkts, nb_rx,
2650 nb_pkts, cb->param);
2652 }
while (cb != NULL);
2674 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2675 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
2676 RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
2677 return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
2698 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2699 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
2700 RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
2701 return (*dev->dev_ops->rx_descriptor_done)( \
2702 dev->data->rx_queues[queue_id], offset);
2763 static inline uint16_t
2765 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
2767 struct rte_eth_dev *dev = &rte_eth_devices[port_id];
2769 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
2770 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
2771 RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
2773 if (queue_id >= dev->data->nb_tx_queues) {
2774 RTE_PMD_DEBUG_TRACE(
"Invalid TX queue_id=%d\n", queue_id);
2779 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
2780 struct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id];
2784 nb_pkts = cb->fn.tx(port_id, queue_id, tx_pkts, nb_pkts,
2787 }
while (cb != NULL);
2791 return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
2794 typedef void (*buffer_tx_error_fn)(
struct rte_mbuf **unsent, uint16_t count,
2802 buffer_tx_error_fn error_callback;
2803 void *error_userdata;
2816 #define RTE_ETH_TX_BUFFER_SIZE(sz) \
2817 (sizeof(struct rte_eth_dev_tx_buffer) + (sz) * sizeof(struct rte_mbuf *))
2854 static inline uint16_t
2859 uint16_t to_send = buffer->
length;
2870 buffer->error_callback(&buffer->
pkts[sent], to_send - sent,
2871 buffer->error_userdata);
2906 static inline uint16_t __attribute__((always_inline))
2910 buffer->pkts[buffer->length++] = tx_pkt;
2911 if (buffer->length < buffer->size)
2943 buffer_tx_error_fn callback,
void *
userdata);
3071 void _rte_eth_dev_callback_process(
struct rte_eth_dev *dev,
3158 int epfd,
int op,
void *data);
3307 uint16_t reta_size);
3326 uint16_t reta_size);
3533 uint16_t tx_rate, uint64_t q_msk);
3912 struct rte_eth_rxtx_callback *user_cb);
3945 struct rte_eth_rxtx_callback *user_cb);
3998 int rte_eth_dev_get_reg_length(uint8_t port_id);
4079 uint32_t nb_mc_addr);
4125 struct timespec *timestamp, uint32_t flags);
4142 struct timespec *timestamp);
4232 uint16_t queue_id,
size_t size,