1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2017 Intel Corporation 3 */ 4 5 #ifndef _RTE_ETHDEV_CORE_H_ 6 #define _RTE_ETHDEV_CORE_H_ 7 8 #include <pthread.h> 9 10 /** 11 * @file 12 * 13 * RTE Ethernet Device internal header. 14 * 15 * This header contains internal data types. But they are still part of the 16 * public API because they are used by inline functions in the published API. 17 * 18 * Applications should not use these directly. 19 */ 20 21 struct rte_eth_dev_callback; 22 /** @internal Structure to keep track of registered callbacks */ 23 RTE_TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback); 24 25 struct rte_eth_dev; 26 27 /** 28 * @internal Retrieve input packets from a receive queue of an Ethernet device. 29 */ 30 typedef uint16_t (*eth_rx_burst_t)(void *rxq, 31 struct rte_mbuf **rx_pkts, 32 uint16_t nb_pkts); 33 34 /** 35 * @internal Send output packets on a transmit queue of an Ethernet device. 36 */ 37 typedef uint16_t (*eth_tx_burst_t)(void *txq, 38 struct rte_mbuf **tx_pkts, 39 uint16_t nb_pkts); 40 41 /** 42 * @internal Prepare output packets on a transmit queue of an Ethernet device. 43 */ 44 typedef uint16_t (*eth_tx_prep_t)(void *txq, 45 struct rte_mbuf **tx_pkts, 46 uint16_t nb_pkts); 47 48 49 /** @internal Get number of used descriptors on a receive queue. */ 50 typedef uint32_t (*eth_rx_queue_count_t)(void *rxq); 51 52 /** @internal Check the status of a Rx descriptor */ 53 typedef int (*eth_rx_descriptor_status_t)(void *rxq, uint16_t offset); 54 55 /** @internal Check the status of a Tx descriptor */ 56 typedef int (*eth_tx_descriptor_status_t)(void *txq, uint16_t offset); 57 58 /** 59 * @internal 60 * Structure used to hold opaque pointers to internal ethdev Rx/Tx 61 * queues data. 62 * The main purpose to expose these pointers at all - allow compiler 63 * to fetch this data for fast-path ethdev inline functions in advance. 64 */ 65 struct rte_ethdev_qdata { 66 /** points to array of internal queue data pointers */ 67 void **data; 68 /** points to array of queue callback data pointers */ 69 void **clbk; 70 }; 71 72 /** 73 * @internal 74 * fast-path ethdev functions and related data are hold in a flat array. 75 * One entry per ethdev. 76 * On 64-bit systems contents of this structure occupy exactly two 64B lines. 77 * On 32-bit systems contents of this structure fits into one 64B line. 78 */ 79 struct rte_eth_fp_ops { 80 81 /**@{*/ 82 /** 83 * Rx fast-path functions and related data. 84 * 64-bit systems: occupies first 64B line 85 */ 86 /** PMD receive function. */ 87 eth_rx_burst_t rx_pkt_burst; 88 /** Get the number of used Rx descriptors. */ 89 eth_rx_queue_count_t rx_queue_count; 90 /** Check the status of a Rx descriptor. */ 91 eth_rx_descriptor_status_t rx_descriptor_status; 92 /** Rx queues data. */ 93 struct rte_ethdev_qdata rxq; 94 uintptr_t reserved1[3]; 95 /**@}*/ 96 97 /**@{*/ 98 /** 99 * Tx fast-path functions and related data. 100 * 64-bit systems: occupies second 64B line 101 */ 102 /** PMD transmit function. */ 103 eth_tx_burst_t tx_pkt_burst; 104 /** PMD transmit prepare function. */ 105 eth_tx_prep_t tx_pkt_prepare; 106 /** Check the status of a Tx descriptor. */ 107 eth_tx_descriptor_status_t tx_descriptor_status; 108 /** Tx queues data. */ 109 struct rte_ethdev_qdata txq; 110 uintptr_t reserved2[3]; 111 /**@}*/ 112 113 } __rte_cache_aligned; 114 115 extern struct rte_eth_fp_ops rte_eth_fp_ops[RTE_MAX_ETHPORTS]; 116 117 #endif /* _RTE_ETHDEV_CORE_H_ */ 118