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>
16 #include "sfc_debug.h"
23 * Generic transmit queue information used on data path.
24 * It must be kept as small as it is possible since it is built into
25 * the structure used on datapath.
28 struct sfc_dp_queue dpq;
31 /** Datapath transmit queue descriptor number limitations */
32 struct sfc_dp_tx_hw_limits {
33 unsigned int txq_max_entries;
34 unsigned int txq_min_entries;
38 * Datapath transmit queue creation information.
40 * The structure is used just to pass information from control path to
41 * datapath. It could be just function arguments, but it would be hardly
44 struct sfc_dp_tx_qcreate_info {
45 /** Maximum number of pushed Tx descriptors */
46 unsigned int max_fill_level;
47 /** Minimum number of unused Tx descriptors to do reap */
48 unsigned int free_thresh;
49 /** Offloads enabled on the transmit queue */
52 unsigned int txq_entries;
53 /** Maximum size of data in the DMA descriptor */
54 uint16_t dma_desc_size_max;
55 /** DMA-mapped Tx descriptors ring */
57 /** Associated event queue size */
58 unsigned int evq_entries;
59 /** Hardware event ring */
61 /** The queue index in hardware (required to push right doorbell) */
62 unsigned int hw_index;
63 /** Virtual address of the memory-mapped BAR to push Tx doorbell */
64 volatile void *mem_bar;
65 /** VI window size shift */
66 unsigned int vi_window_shift;
68 * Maximum number of bytes into the packet the TCP header can start for
69 * the hardware to apply TSO packet edits.
71 uint16_t tso_tcp_header_offset_limit;
75 * Get Tx datapath specific device info.
77 * @param dev_info Device info to be adjusted
79 typedef void (sfc_dp_tx_get_dev_info_t)(struct rte_eth_dev_info *dev_info);
82 * Get size of transmit and event queue rings by the number of Tx
85 * @param nb_tx_desc Number of Tx descriptors
86 * @param txq_entries Location for number of Tx ring entries
87 * @param evq_entries Location for number of event ring entries
88 * @param txq_max_fill_level Location for maximum Tx ring fill level
90 * @return 0 or positive errno.
92 typedef int (sfc_dp_tx_qsize_up_rings_t)(uint16_t nb_tx_desc,
93 struct sfc_dp_tx_hw_limits *limits,
94 unsigned int *txq_entries,
95 unsigned int *evq_entries,
96 unsigned int *txq_max_fill_level);
99 * Allocate and initialize datapath transmit queue.
101 * @param port_id The port identifier
102 * @param queue_id The queue identifier
103 * @param pci_addr PCI function address
104 * @param socket_id Socket identifier to allocate memory
105 * @param info Tx queue details wrapped in structure
106 * @param dp_txqp Location for generic datapath transmit queue pointer
108 * @return 0 or positive errno.
110 typedef int (sfc_dp_tx_qcreate_t)(uint16_t port_id, uint16_t queue_id,
111 const struct rte_pci_addr *pci_addr,
113 const struct sfc_dp_tx_qcreate_info *info,
114 struct sfc_dp_txq **dp_txqp);
117 * Free resources allocated for datapath transmit queue.
119 typedef void (sfc_dp_tx_qdestroy_t)(struct sfc_dp_txq *dp_txq);
122 * Transmit queue start callback.
124 * It handovers EvQ to the datapath.
126 typedef int (sfc_dp_tx_qstart_t)(struct sfc_dp_txq *dp_txq,
127 unsigned int evq_read_ptr,
128 unsigned int txq_desc_index);
131 * Transmit queue stop function called before the queue flush.
133 * It returns EvQ to the control path.
135 typedef void (sfc_dp_tx_qstop_t)(struct sfc_dp_txq *dp_txq,
136 unsigned int *evq_read_ptr);
139 * Transmit event handler used during queue flush only.
141 typedef bool (sfc_dp_tx_qtx_ev_t)(struct sfc_dp_txq *dp_txq, unsigned int id);
144 * Transmit queue function called after the queue flush.
146 typedef void (sfc_dp_tx_qreap_t)(struct sfc_dp_txq *dp_txq);
149 * Check Tx descriptor status
151 typedef int (sfc_dp_tx_qdesc_status_t)(struct sfc_dp_txq *dp_txq,
154 /** Transmit datapath definition */
158 unsigned int features;
159 #define SFC_DP_TX_FEAT_VLAN_INSERT 0x1
160 #define SFC_DP_TX_FEAT_TSO 0x2
161 #define SFC_DP_TX_FEAT_MULTI_SEG 0x4
162 #define SFC_DP_TX_FEAT_MULTI_PROCESS 0x8
163 #define SFC_DP_TX_FEAT_MULTI_POOL 0x10
164 #define SFC_DP_TX_FEAT_REFCNT 0x20
165 sfc_dp_tx_get_dev_info_t *get_dev_info;
166 sfc_dp_tx_qsize_up_rings_t *qsize_up_rings;
167 sfc_dp_tx_qcreate_t *qcreate;
168 sfc_dp_tx_qdestroy_t *qdestroy;
169 sfc_dp_tx_qstart_t *qstart;
170 sfc_dp_tx_qstop_t *qstop;
171 sfc_dp_tx_qtx_ev_t *qtx_ev;
172 sfc_dp_tx_qreap_t *qreap;
173 sfc_dp_tx_qdesc_status_t *qdesc_status;
174 eth_tx_prep_t pkt_prepare;
175 eth_tx_burst_t pkt_burst;
178 static inline struct sfc_dp_tx *
179 sfc_dp_find_tx_by_name(struct sfc_dp_list *head, const char *name)
181 struct sfc_dp *p = sfc_dp_find_by_name(head, SFC_DP_TX, name);
183 return (p == NULL) ? NULL : container_of(p, struct sfc_dp_tx, dp);
186 static inline struct sfc_dp_tx *
187 sfc_dp_find_tx_by_caps(struct sfc_dp_list *head, unsigned int avail_caps)
189 struct sfc_dp *p = sfc_dp_find_by_caps(head, SFC_DP_TX, avail_caps);
191 return (p == NULL) ? NULL : container_of(p, struct sfc_dp_tx, dp);
194 /** Get Tx datapath ops by the datapath TxQ handle */
195 const struct sfc_dp_tx *sfc_dp_tx_by_dp_txq(const struct sfc_dp_txq *dp_txq);
198 sfc_dp_tx_prepare_pkt(struct rte_mbuf *m,
199 uint32_t tso_tcp_header_offset_limit)
201 #ifdef RTE_LIBRTE_SFC_EFX_DEBUG
204 ret = rte_validate_tx_offload(m);
207 * Negative error code is returned by rte_validate_tx_offload(),
208 * but positive are used inside net/sfc PMD.
215 if (m->ol_flags & PKT_TX_TCP_SEG) {
216 unsigned int tcph_off = m->l2_len + m->l3_len;
218 if (unlikely(tcph_off > tso_tcp_header_offset_limit))
225 extern struct sfc_dp_tx sfc_efx_tx;
226 extern struct sfc_dp_tx sfc_ef10_tx;
227 extern struct sfc_dp_tx sfc_ef10_simple_tx;
232 #endif /* _SFC_DP_TX_H */