1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2016-2018 Solarflare Communications Inc.
6 * This software was jointly developed between OKTET Labs (under contract
7 * for Solarflare) and Solarflare Communications, Inc.
13 #include <rte_ethdev_driver.h>
22 * Generic transmit queue information used on data path.
23 * It must be kept as small as it is possible since it is built into
24 * the structure used on datapath.
27 struct sfc_dp_queue dpq;
31 * Datapath transmit queue creation information.
33 * The structure is used just to pass information from control path to
34 * datapath. It could be just function arguments, but it would be hardly
37 struct sfc_dp_tx_qcreate_info {
38 /** Maximum number of pushed Tx descriptors */
39 unsigned int max_fill_level;
40 /** Minimum number of unused Tx descriptors to do reap */
41 unsigned int free_thresh;
42 /** Offloads enabled on the transmit queue */
45 unsigned int txq_entries;
46 /** Maximum size of data in the DMA descriptor */
47 uint16_t dma_desc_size_max;
48 /** DMA-mapped Tx descriptors ring */
50 /** Associated event queue size */
51 unsigned int evq_entries;
52 /** Hardware event ring */
54 /** The queue index in hardware (required to push right doorbell) */
55 unsigned int hw_index;
56 /** Virtual address of the memory-mapped BAR to push Tx doorbell */
57 volatile void *mem_bar;
58 /** VI window size shift */
59 unsigned int vi_window_shift;
61 * Maximum number of bytes into the packet the TCP header can start for
62 * the hardware to apply TSO packet edits.
64 uint16_t tso_tcp_header_offset_limit;
68 * Get Tx datapath specific device info.
70 * @param dev_info Device info to be adjusted
72 typedef void (sfc_dp_tx_get_dev_info_t)(struct rte_eth_dev_info *dev_info);
75 * Get size of transmit and event queue rings by the number of Tx
78 * @param nb_tx_desc Number of Tx descriptors
79 * @param txq_entries Location for number of Tx ring entries
80 * @param evq_entries Location for number of event ring entries
81 * @param txq_max_fill_level Location for maximum Tx ring fill level
83 * @return 0 or positive errno.
85 typedef int (sfc_dp_tx_qsize_up_rings_t)(uint16_t nb_tx_desc,
86 unsigned int *txq_entries,
87 unsigned int *evq_entries,
88 unsigned int *txq_max_fill_level);
91 * Allocate and initialize datapath transmit queue.
93 * @param port_id The port identifier
94 * @param queue_id The queue identifier
95 * @param pci_addr PCI function address
96 * @param socket_id Socket identifier to allocate memory
97 * @param info Tx queue details wrapped in structure
98 * @param dp_txqp Location for generic datapath transmit queue pointer
100 * @return 0 or positive errno.
102 typedef int (sfc_dp_tx_qcreate_t)(uint16_t port_id, uint16_t queue_id,
103 const struct rte_pci_addr *pci_addr,
105 const struct sfc_dp_tx_qcreate_info *info,
106 struct sfc_dp_txq **dp_txqp);
109 * Free resources allocated for datapath transmit queue.
111 typedef void (sfc_dp_tx_qdestroy_t)(struct sfc_dp_txq *dp_txq);
114 * Transmit queue start callback.
116 * It handovers EvQ to the datapath.
118 typedef int (sfc_dp_tx_qstart_t)(struct sfc_dp_txq *dp_txq,
119 unsigned int evq_read_ptr,
120 unsigned int txq_desc_index);
123 * Transmit queue stop function called before the queue flush.
125 * It returns EvQ to the control path.
127 typedef void (sfc_dp_tx_qstop_t)(struct sfc_dp_txq *dp_txq,
128 unsigned int *evq_read_ptr);
131 * Transmit event handler used during queue flush only.
133 typedef bool (sfc_dp_tx_qtx_ev_t)(struct sfc_dp_txq *dp_txq, unsigned int id);
136 * Transmit queue function called after the queue flush.
138 typedef void (sfc_dp_tx_qreap_t)(struct sfc_dp_txq *dp_txq);
141 * Check Tx descriptor status
143 typedef int (sfc_dp_tx_qdesc_status_t)(struct sfc_dp_txq *dp_txq,
146 /** Transmit datapath definition */
150 unsigned int features;
151 #define SFC_DP_TX_FEAT_VLAN_INSERT 0x1
152 #define SFC_DP_TX_FEAT_TSO 0x2
153 #define SFC_DP_TX_FEAT_MULTI_SEG 0x4
154 #define SFC_DP_TX_FEAT_MULTI_PROCESS 0x8
155 #define SFC_DP_TX_FEAT_MULTI_POOL 0x10
156 #define SFC_DP_TX_FEAT_REFCNT 0x20
157 sfc_dp_tx_get_dev_info_t *get_dev_info;
158 sfc_dp_tx_qsize_up_rings_t *qsize_up_rings;
159 sfc_dp_tx_qcreate_t *qcreate;
160 sfc_dp_tx_qdestroy_t *qdestroy;
161 sfc_dp_tx_qstart_t *qstart;
162 sfc_dp_tx_qstop_t *qstop;
163 sfc_dp_tx_qtx_ev_t *qtx_ev;
164 sfc_dp_tx_qreap_t *qreap;
165 sfc_dp_tx_qdesc_status_t *qdesc_status;
166 eth_tx_burst_t pkt_burst;
169 static inline struct sfc_dp_tx *
170 sfc_dp_find_tx_by_name(struct sfc_dp_list *head, const char *name)
172 struct sfc_dp *p = sfc_dp_find_by_name(head, SFC_DP_TX, name);
174 return (p == NULL) ? NULL : container_of(p, struct sfc_dp_tx, dp);
177 static inline struct sfc_dp_tx *
178 sfc_dp_find_tx_by_caps(struct sfc_dp_list *head, unsigned int avail_caps)
180 struct sfc_dp *p = sfc_dp_find_by_caps(head, SFC_DP_TX, avail_caps);
182 return (p == NULL) ? NULL : container_of(p, struct sfc_dp_tx, dp);
185 extern struct sfc_dp_tx sfc_efx_tx;
186 extern struct sfc_dp_tx sfc_ef10_tx;
187 extern struct sfc_dp_tx sfc_ef10_simple_tx;
192 #endif /* _SFC_DP_TX_H */