Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2018 Intel Corporation
3 : : */
4 : :
5 : : #ifndef _ICE_RXTX_H_
6 : : #define _ICE_RXTX_H_
7 : :
8 : : #include "../common/rx.h"
9 : : #include "../common/tx.h"
10 : : #include "ice_ethdev.h"
11 : :
12 : : #define FIELD_GET(_mask, _reg) \
13 : : (__extension__ ({ \
14 : : typeof(_mask) _x = (_mask); \
15 : : (typeof(_x))(((_reg) & (_x)) >> rte_bsf32(_x)); \
16 : : }))
17 : : #define FIELD_PREP(_mask, _val) \
18 : : (__extension__ ({ \
19 : : typeof(_mask) _x = (_mask); \
20 : : ((typeof(_x))(_val) << rte_bsf32(_x)) & (_x); \
21 : : }))
22 : :
23 : : #define ICE_ALIGN_RING_DESC 32
24 : : #define ICE_MIN_RING_DESC 64
25 : : #define ICE_MAX_RING_DESC (8192 - 32)
26 : : #define ICE_MAX_RING_DESC_E830 8096
27 : : #define ICE_MAX_NUM_DESC_BY_MAC(hw) ((hw)->phy_model == \
28 : : ICE_PHY_E830 ? \
29 : : ICE_MAX_RING_DESC_E830 : \
30 : : ICE_MAX_RING_DESC)
31 : : #define ICE_DMA_MEM_ALIGN 4096
32 : : #define ICE_RING_BASE_ALIGN 128
33 : :
34 : : #define ICE_TXTIME_TX_DESC_IDX_M RTE_GENMASK32(12, 0)
35 : : #define ICE_TXTIME_STAMP_M RTE_GENMASK32(31, 13)
36 : : #define ICE_REQ_DESC_MULTIPLE 32
37 : :
38 : : #define ICE_RX_MAX_BURST CI_RX_MAX_BURST
39 : : #define ICE_TX_MAX_BURST 32
40 : :
41 : : /* Maximal number of segments to split. */
42 : : #define ICE_RX_MAX_NSEG CI_RX_MAX_NSEG
43 : :
44 : : #define ICE_CHK_Q_ENA_COUNT 100
45 : : #define ICE_CHK_Q_ENA_INTERVAL_US 100
46 : :
47 : : #define ICE_SUPPORT_CHAIN_NUM 5
48 : :
49 : : #define ICE_TD_CMD ICE_TX_DESC_CMD_EOP
50 : :
51 : : #define ICE_VPMD_RX_BURST CI_VPMD_RX_BURST
52 : : #define ICE_VPMD_TX_BURST 32
53 : : #define ICE_VPMD_RXQ_REARM_THRESH CI_VPMD_RX_REARM_THRESH
54 : : #define ICE_TX_MAX_FREE_BUF_SZ 64
55 : : #define ICE_VPMD_DESCS_PER_LOOP CI_VPMD_DESCS_PER_LOOP
56 : : #define ICE_VPMD_DESCS_PER_LOOP_WIDE CI_VPMD_DESCS_PER_LOOP_WIDE
57 : :
58 : : #define ICE_FDIR_PKT_LEN 512
59 : :
60 : : #define ICE_RXDID_COMMS_OVS 22
61 : :
62 : : #define ICE_TX_MIN_PKT_LEN 17
63 : :
64 : : #define ICE_TX_OFFLOAD_MASK ( \
65 : : RTE_MBUF_F_TX_OUTER_IPV6 | \
66 : : RTE_MBUF_F_TX_OUTER_IPV4 | \
67 : : RTE_MBUF_F_TX_OUTER_IP_CKSUM | \
68 : : RTE_MBUF_F_TX_VLAN | \
69 : : RTE_MBUF_F_TX_IPV6 | \
70 : : RTE_MBUF_F_TX_IPV4 | \
71 : : RTE_MBUF_F_TX_IP_CKSUM | \
72 : : RTE_MBUF_F_TX_L4_MASK | \
73 : : RTE_MBUF_F_TX_IEEE1588_TMST | \
74 : : RTE_MBUF_F_TX_TCP_SEG | \
75 : : RTE_MBUF_F_TX_QINQ | \
76 : : RTE_MBUF_F_TX_TUNNEL_MASK | \
77 : : RTE_MBUF_F_TX_UDP_SEG | \
78 : : RTE_MBUF_F_TX_OUTER_UDP_CKSUM)
79 : :
80 : : #define ICE_TX_OFFLOAD_NOTSUP_MASK \
81 : : (RTE_MBUF_F_TX_OFFLOAD_MASK ^ ICE_TX_OFFLOAD_MASK)
82 : :
83 : : /* Max header size can be 2K - 64 bytes */
84 : : #define ICE_RX_HDR_BUF_SIZE (2048 - 64)
85 : :
86 : : /* Max data buffer size must be 16K - 128 bytes */
87 : : #define ICE_RX_MAX_DATA_BUF_SIZE (16 * 1024 - 128)
88 : :
89 : : #define ICE_HEADER_SPLIT_ENA BIT(0)
90 : :
91 : : #define ICE_TX_MTU_SEG_MAX 8
92 : :
93 : : typedef void (*ice_rxd_to_pkt_fields_t)(struct ci_rx_queue *rxq,
94 : : struct rte_mbuf *mb,
95 : : volatile union ci_rx_flex_desc *rxdp);
96 : :
97 : : enum ice_rx_dtype {
98 : : ICE_RX_DTYPE_NO_SPLIT = 0,
99 : : ICE_RX_DTYPE_HEADER_SPLIT = 1,
100 : : ICE_RX_DTYPE_SPLIT_ALWAYS = 2,
101 : : };
102 : :
103 : : /**
104 : : * Structure associated with Tx Time based queue
105 : : */
106 : : struct ice_txtime {
107 : : volatile struct ice_ts_desc *ice_ts_ring; /* Tx time ring virtual address */
108 : : uint16_t nb_ts_desc; /* number of Tx Time descriptors */
109 : : uint16_t ts_tail; /* current value of tail register */
110 : : int ts_offset; /* dynamic mbuf Tx timestamp field offset */
111 : : uint64_t ts_flag; /* dynamic mbuf Tx timestamp flag */
112 : : const struct rte_memzone *ts_mz;
113 : : };
114 : :
115 : : /* Offload features */
116 : : union ice_tx_offload {
117 : : uint64_t data;
118 : : struct {
119 : : uint64_t l2_len:7; /* L2 (MAC) Header Length. */
120 : : uint64_t l3_len:9; /* L3 (IP) Header Length. */
121 : : uint64_t l4_len:8; /* L4 Header Length. */
122 : : uint64_t tso_segsz:16; /* TCP TSO segment size */
123 : : uint64_t outer_l2_len:8; /* outer L2 Header Length */
124 : : uint64_t outer_l3_len:16; /* outer L3 Header Length */
125 : : };
126 : : };
127 : :
128 : : /* Rx Flex Descriptor for Comms Package Profile
129 : : * RxDID Profile ID 22 (swap Hash and FlowID)
130 : : * Flex-field 0: Flow ID lower 16-bits
131 : : * Flex-field 1: Flow ID upper 16-bits
132 : : * Flex-field 2: RSS hash lower 16-bits
133 : : * Flex-field 3: RSS hash upper 16-bits
134 : : * Flex-field 4: AUX0
135 : : * Flex-field 5: AUX1
136 : : */
137 : : struct ice_32b_rx_flex_desc_comms_ovs {
138 : : /* Qword 0 */
139 : : u8 rxdid;
140 : : u8 mir_id_umb_cast;
141 : : __le16 ptype_flexi_flags0;
142 : : __le16 pkt_len;
143 : : __le16 hdr_len_sph_flex_flags1;
144 : :
145 : : /* Qword 1 */
146 : : __le16 status_error0;
147 : : __le16 l2tag1;
148 : : __le32 flow_id;
149 : :
150 : : /* Qword 2 */
151 : : __le16 status_error1;
152 : : u8 flexi_flags2;
153 : : u8 ts_low;
154 : : __le16 l2tag2_1st;
155 : : __le16 l2tag2_2nd;
156 : :
157 : : /* Qword 3 */
158 : : __le32 rss_hash;
159 : : union {
160 : : struct {
161 : : __le16 aux0;
162 : : __le16 aux1;
163 : : } flex;
164 : : __le32 ts_high;
165 : : } flex_ts;
166 : : };
167 : :
168 : : int ice_rx_queue_setup(struct rte_eth_dev *dev,
169 : : uint16_t queue_idx,
170 : : uint16_t nb_desc,
171 : : unsigned int socket_id,
172 : : const struct rte_eth_rxconf *rx_conf,
173 : : struct rte_mempool *mp);
174 : : int ice_tx_queue_setup(struct rte_eth_dev *dev,
175 : : uint16_t queue_idx,
176 : : uint16_t nb_desc,
177 : : unsigned int socket_id,
178 : : const struct rte_eth_txconf *tx_conf);
179 : : int ice_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
180 : : int ice_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
181 : : int ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
182 : : int ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
183 : : int ice_fdir_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
184 : : int ice_fdir_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
185 : : int ice_fdir_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
186 : : int ice_fdir_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
187 : : void ice_rx_queue_release(void *rxq);
188 : : void ice_tx_queue_release(void *txq);
189 : : void ice_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
190 : : void ice_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
191 : : void ice_free_queues(struct rte_eth_dev *dev);
192 : : int ice_fdir_setup_tx_resources(struct ice_pf *pf);
193 : : int ice_fdir_setup_rx_resources(struct ice_pf *pf);
194 : : uint16_t ice_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
195 : : uint16_t nb_pkts);
196 : : uint16_t ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
197 : : uint16_t nb_pkts);
198 : : void ice_set_rx_function(struct rte_eth_dev *dev);
199 : : uint16_t ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
200 : : uint16_t nb_pkts);
201 : : void ice_set_tx_function_flag(struct rte_eth_dev *dev,
202 : : struct ci_tx_queue *txq);
203 : : void ice_set_tx_function(struct rte_eth_dev *dev);
204 : : uint32_t ice_rx_queue_count(void *rx_queue);
205 : : void ice_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
206 : : struct rte_eth_rxq_info *qinfo);
207 : : void ice_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
208 : : struct rte_eth_txq_info *qinfo);
209 : : int ice_rx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id,
210 : : struct rte_eth_burst_mode *mode);
211 : : int ice_tx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id,
212 : : struct rte_eth_burst_mode *mode);
213 : : int ice_rx_descriptor_status(void *rx_queue, uint16_t offset);
214 : : int ice_tx_descriptor_status(void *tx_queue, uint16_t offset);
215 : : void ice_set_default_ptype_table(struct rte_eth_dev *dev);
216 : : const uint32_t *ice_dev_supported_ptypes_get(struct rte_eth_dev *dev,
217 : : size_t *no_of_elements);
218 : : void ice_select_rxd_to_pkt_fields_handler(struct ci_rx_queue *rxq,
219 : : uint32_t rxdid);
220 : :
221 : : int ice_rx_vec_dev_check(struct rte_eth_dev *dev);
222 : : int ice_tx_vec_dev_check(struct rte_eth_dev *dev);
223 : : int ice_rxq_vec_setup(struct ci_rx_queue *rxq);
224 : : int ice_txq_vec_setup(struct ci_tx_queue *txq);
225 : : uint16_t ice_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
226 : : uint16_t nb_pkts);
227 : : uint16_t ice_recv_scattered_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
228 : : uint16_t nb_pkts);
229 : : uint16_t ice_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
230 : : uint16_t nb_pkts);
231 : : uint16_t ice_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts,
232 : : uint16_t nb_pkts);
233 : : uint16_t ice_recv_pkts_vec_avx2_offload(void *rx_queue, struct rte_mbuf **rx_pkts,
234 : : uint16_t nb_pkts);
235 : : uint16_t ice_recv_scattered_pkts_vec_avx2(void *rx_queue,
236 : : struct rte_mbuf **rx_pkts,
237 : : uint16_t nb_pkts);
238 : : uint16_t ice_recv_scattered_pkts_vec_avx2_offload(void *rx_queue,
239 : : struct rte_mbuf **rx_pkts,
240 : : uint16_t nb_pkts);
241 : : uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
242 : : uint16_t nb_pkts);
243 : : uint16_t ice_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
244 : : uint16_t nb_pkts);
245 : : uint16_t ice_recv_pkts_vec_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
246 : : uint16_t nb_pkts);
247 : : uint16_t ice_recv_pkts_vec_avx512_offload(void *rx_queue,
248 : : struct rte_mbuf **rx_pkts,
249 : : uint16_t nb_pkts);
250 : : uint16_t ice_recv_scattered_pkts_vec_avx512(void *rx_queue,
251 : : struct rte_mbuf **rx_pkts,
252 : : uint16_t nb_pkts);
253 : : uint16_t ice_recv_scattered_pkts_vec_avx512_offload(void *rx_queue,
254 : : struct rte_mbuf **rx_pkts,
255 : : uint16_t nb_pkts);
256 : : uint16_t ice_xmit_pkts_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
257 : : uint16_t nb_pkts);
258 : : uint16_t ice_xmit_pkts_vec_avx512_offload(void *tx_queue,
259 : : struct rte_mbuf **tx_pkts,
260 : : uint16_t nb_pkts);
261 : : int ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc);
262 : : int ice_tx_done_cleanup(void *txq, uint32_t free_cnt);
263 : : int ice_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc);
264 : :
265 : : #define FDIR_PARSING_ENABLE_PER_QUEUE(ad, on) do { \
266 : : int i; \
267 : : for (i = 0; i < (ad)->pf.dev_data->nb_rx_queues; i++) { \
268 : : struct ci_rx_queue *rxq = (ad)->pf.dev_data->rx_queues[i]; \
269 : : if (!rxq) \
270 : : continue; \
271 : : rxq->fdir_enabled = on; \
272 : : } \
273 : : PMD_DRV_LOG(DEBUG, "FDIR processing on RX set to %d", on); \
274 : : } while (0)
275 : :
276 : : /* Enable/disable flow director parsing from Rx descriptor in data path. */
277 : : static inline
278 : 0 : void ice_fdir_rx_parsing_enable(struct ice_adapter *ad, bool on)
279 : : {
280 [ # # ]: 0 : if (on) {
281 : : /* Enable flow director parsing from Rx descriptor */
282 [ # # # # ]: 0 : FDIR_PARSING_ENABLE_PER_QUEUE(ad, on);
283 : 0 : ad->fdir_ref_cnt++;
284 : : } else {
285 [ # # ]: 0 : if (ad->fdir_ref_cnt >= 1) {
286 : 0 : ad->fdir_ref_cnt--;
287 : :
288 [ # # ]: 0 : if (ad->fdir_ref_cnt == 0)
289 [ # # # # ]: 0 : FDIR_PARSING_ENABLE_PER_QUEUE(ad, on);
290 : : }
291 : : }
292 : 0 : }
293 : :
294 : : #define ICE_TIMESYNC_REG_WRAP_GUARD_BAND 10000
295 : :
296 : : /* Helper function to convert a 32b nanoseconds timestamp to 64b. */
297 : : static inline
298 : 0 : uint64_t ice_tstamp_convert_32b_64b(struct ice_hw *hw, struct ice_adapter *ad,
299 : : uint32_t flag, uint32_t in_timestamp)
300 : : {
301 : 0 : uint8_t tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc;
302 : : const uint64_t mask = 0xFFFFFFFF;
303 : : uint32_t hi, lo, lo2, delta;
304 : : uint64_t ns;
305 : :
306 [ # # ]: 0 : if (flag) {
307 : 0 : lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
308 : 0 : hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx));
309 : :
310 : : /*
311 : : * On typical system, the delta between lo and lo2 is ~1000ns,
312 : : * so 10000 seems a large-enough but not overly-big guard band.
313 : : */
314 [ # # ]: 0 : if (lo > (UINT32_MAX - ICE_TIMESYNC_REG_WRAP_GUARD_BAND))
315 : 0 : lo2 = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
316 : : else
317 : : lo2 = lo;
318 : :
319 [ # # ]: 0 : if (lo2 < lo) {
320 : 0 : lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
321 : 0 : hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx));
322 : : }
323 : :
324 : 0 : ad->time_hw = ((uint64_t)hi << 32) | lo;
325 : : }
326 : :
327 : 0 : delta = (in_timestamp - (uint32_t)(ad->time_hw & mask));
328 [ # # ]: 0 : if (delta > (mask / 2)) {
329 : 0 : delta = ((uint32_t)(ad->time_hw & mask) - in_timestamp);
330 : 0 : ns = ad->time_hw - delta;
331 : : } else {
332 : 0 : ns = ad->time_hw + delta;
333 : : }
334 : :
335 : 0 : return ns;
336 : : }
337 : :
338 : : #endif /* _ICE_RXTX_H_ */
|