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