1
2
3
4
5
6#ifndef _TXGBE_RXTX_H_
7#define _TXGBE_RXTX_H_
8
9
10
11
12struct txgbe_rx_desc {
13 struct {
14 union {
15 __le32 dw0;
16 struct {
17 __le16 pkt;
18 __le16 hdr;
19 } lo;
20 };
21 union {
22 __le32 dw1;
23 struct {
24 __le16 ipid;
25 __le16 csum;
26 } hi;
27 };
28 } qw0;
29 struct {
30 union {
31 __le32 dw2;
32 struct {
33 __le32 status;
34 } lo;
35 };
36 union {
37 __le32 dw3;
38 struct {
39 __le16 len;
40 __le16 tag;
41 } hi;
42 };
43 } qw1;
44};
45
46
47#define TXGBE_RXD_PKTADDR(rxd, v) \
48 (((volatile __le64 *)(rxd))[0] = cpu_to_le64(v))
49
50
51#define TXGBE_RXD_HDRADDR(rxd, v) \
52 (((volatile __le64 *)(rxd))[1] = cpu_to_le64(v))
53
54
55#define TXGBE_RXD_RSSTYPE(dw) RS(dw, 0, 0xF)
56#define TXGBE_RSSTYPE_NONE 0
57#define TXGBE_RSSTYPE_IPV4TCP 1
58#define TXGBE_RSSTYPE_IPV4 2
59#define TXGBE_RSSTYPE_IPV6TCP 3
60#define TXGBE_RSSTYPE_IPV4SCTP 4
61#define TXGBE_RSSTYPE_IPV6 5
62#define TXGBE_RSSTYPE_IPV6SCTP 6
63#define TXGBE_RSSTYPE_IPV4UDP 7
64#define TXGBE_RSSTYPE_IPV6UDP 8
65#define TXGBE_RSSTYPE_FDIR 15
66#define TXGBE_RXD_SECTYPE(dw) RS(dw, 4, 0x3)
67#define TXGBE_RXD_SECTYPE_NONE LS(0, 4, 0x3)
68#define TXGBE_RXD_SECTYPE_LINKSEC LS(1, 4, 0x3)
69#define TXGBE_RXD_SECTYPE_IPSECESP LS(2, 4, 0x3)
70#define TXGBE_RXD_SECTYPE_IPSECAH LS(3, 4, 0x3)
71#define TXGBE_RXD_TPIDSEL(dw) RS(dw, 6, 0x7)
72#define TXGBE_RXD_PTID(dw) RS(dw, 9, 0xFF)
73#define TXGBE_RXD_RSCCNT(dw) RS(dw, 17, 0xF)
74#define TXGBE_RXD_HDRLEN(dw) RS(dw, 21, 0x3FF)
75#define TXGBE_RXD_SPH MS(31, 0x1)
76
77
78
79#define TXGBE_RXD_RSSHASH(rxd) ((rxd)->qw0.dw1)
80
81
82#define TXGBE_RXD_IPID(rxd) ((rxd)->qw0.hi.ipid)
83#define TXGBE_RXD_CSUM(rxd) ((rxd)->qw0.hi.csum)
84
85
86#define TXGBE_RXD_FDIRID(rxd) ((rxd)->qw0.hi.dw1)
87
88
89#define TXGBE_RXD_STATUS(rxd) ((rxd)->qw1.lo.status)
90
91#define TXGBE_RXD_STAT_DD MS(0, 0x1)
92#define TXGBE_RXD_STAT_EOP MS(1, 0x1)
93
94#define TXGBE_RXD_NEXTP_RESV(v) LS(v, 2, 0x3)
95#define TXGBE_RXD_NEXTP(dw) RS(dw, 4, 0xFFFF)
96
97#define TXGBE_RXD_PKT_CLS_MASK MS(2, 0x7)
98#define TXGBE_RXD_PKT_CLS_TC_RSS LS(0, 2, 0x7)
99#define TXGBE_RXD_PKT_CLS_FLM LS(1, 2, 0x7)
100#define TXGBE_RXD_PKT_CLS_SYN LS(2, 2, 0x7)
101#define TXGBE_RXD_PKT_CLS_5TUPLE LS(3, 2, 0x7)
102#define TXGBE_RXD_PKT_CLS_ETF LS(4, 2, 0x7)
103#define TXGBE_RXD_STAT_VLAN MS(5, 0x1)
104#define TXGBE_RXD_STAT_UDPCS MS(6, 0x1)
105#define TXGBE_RXD_STAT_L4CS MS(7, 0x1)
106#define TXGBE_RXD_STAT_IPCS MS(8, 0x1)
107#define TXGBE_RXD_STAT_PIF MS(9, 0x1)
108#define TXGBE_RXD_STAT_EIPCS MS(10, 0x1)
109#define TXGBE_RXD_STAT_VEXT MS(11, 0x1)
110#define TXGBE_RXD_STAT_IPV6EX MS(12, 0x1)
111#define TXGBE_RXD_STAT_LLINT MS(13, 0x1)
112#define TXGBE_RXD_STAT_1588 MS(14, 0x1)
113#define TXGBE_RXD_STAT_SECP MS(15, 0x1)
114#define TXGBE_RXD_STAT_LB MS(16, 0x1)
115
116#define TXGBE_RXD_STAT_BMC MS(17, 0x1)
117#define TXGBE_RXD_ERR_FDIR_LEN MS(20, 0x1)
118#define TXGBE_RXD_ERR_FDIR_DROP MS(21, 0x1)
119#define TXGBE_RXD_ERR_FDIR_COLL MS(22, 0x1)
120#define TXGBE_RXD_ERR_HBO MS(23, 0x1)
121#define TXGBE_RXD_ERR_EIPCS MS(26, 0x1)
122#define TXGBE_RXD_ERR_SECERR MS(27, 0x1)
123#define TXGBE_RXD_ERR_RXE MS(29, 0x1)
124#define TXGBE_RXD_ERR_L4CS MS(30, 0x1)
125#define TXGBE_RXD_ERR_IPCS MS(31, 0x1)
126#define TXGBE_RXD_ERR_CSUM(dw) RS(dw, 30, 0x3)
127
128#define TXGBE_RXD_STAT_FCOEFS MS(17, 0x1)
129#define TXGBE_RXD_FCSTAT_MASK MS(18, 0x3)
130#define TXGBE_RXD_FCSTAT_NOMTCH LS(0, 18, 0x3)
131#define TXGBE_RXD_FCSTAT_NODDP LS(1, 18, 0x3)
132#define TXGBE_RXD_FCSTAT_FCPRSP LS(2, 18, 0x3)
133#define TXGBE_RXD_FCSTAT_DDP LS(3, 18, 0x3)
134#define TXGBE_RXD_FCERR_MASK MS(20, 0x7)
135#define TXGBE_RXD_FCERR_0 LS(0, 20, 0x7)
136#define TXGBE_RXD_FCERR_1 LS(1, 20, 0x7)
137#define TXGBE_RXD_FCERR_2 LS(2, 20, 0x7)
138#define TXGBE_RXD_FCERR_3 LS(3, 20, 0x7)
139#define TXGBE_RXD_FCERR_4 LS(4, 20, 0x7)
140#define TXGBE_RXD_FCERR_5 LS(5, 20, 0x7)
141#define TXGBE_RXD_FCERR_6 LS(6, 20, 0x7)
142#define TXGBE_RXD_FCERR_7 LS(7, 20, 0x7)
143
144
145#define TXGBE_RXD_LENGTH(rxd) ((rxd)->qw1.hi.len)
146#define TXGBE_RXD_VLAN(rxd) ((rxd)->qw1.hi.tag)
147
148
149
150
151
152
153
154struct txgbe_tx_ctx_desc {
155 __le32 dw0;
156 __le32 dw1;
157 __le32 dw2;
158 __le32 dw3;
159};
160
161
162#define TXGBE_TXD_IPLEN(v) LS(v, 0, 0x1FF)
163#define TXGBE_TXD_MACLEN(v) LS(v, 9, 0x7F)
164#define TXGBE_TXD_VLAN(v) LS(v, 16, 0xFFFF)
165
166
167
168#define TXGBE_TXD_IPSEC_SAIDX(v) LS(v, 0, 0x3FF)
169#define TXGBE_TXD_ETYPE(v) LS(v, 11, 0x1)
170#define TXGBE_TXD_ETYPE_UDP LS(0, 11, 0x1)
171#define TXGBE_TXD_ETYPE_GRE LS(1, 11, 0x1)
172#define TXGBE_TXD_EIPLEN(v) LS(v, 12, 0x7F)
173#define TXGBE_TXD_DTYP_FCOE MS(16, 0x1)
174#define TXGBE_TXD_ETUNLEN(v) LS(v, 21, 0xFF)
175#define TXGBE_TXD_DECTTL(v) LS(v, 29, 0xF)
176
177#define TXGBE_TXD_FCOEF_EOF_MASK MS(10, 0x3)
178#define TXGBE_TXD_FCOEF_EOF_N LS(0, 10, 0x3)
179#define TXGBE_TXD_FCOEF_EOF_T LS(1, 10, 0x3)
180#define TXGBE_TXD_FCOEF_EOF_NI LS(2, 10, 0x3)
181#define TXGBE_TXD_FCOEF_EOF_A LS(3, 10, 0x3)
182#define TXGBE_TXD_FCOEF_SOF MS(12, 0x1)
183#define TXGBE_TXD_FCOEF_PARINC MS(13, 0x1)
184#define TXGBE_TXD_FCOEF_ORIE MS(14, 0x1)
185#define TXGBE_TXD_FCOEF_ORIS MS(15, 0x1)
186
187
188#define TXGBE_TXD_IPSEC_ESPLEN(v) LS(v, 1, 0x1FF)
189#define TXGBE_TXD_SNAP MS(10, 0x1)
190#define TXGBE_TXD_TPID_SEL(v) LS(v, 11, 0x7)
191#define TXGBE_TXD_IPSEC_ESP MS(14, 0x1)
192#define TXGBE_TXD_IPSEC_ESPENC MS(15, 0x1)
193#define TXGBE_TXD_CTXT MS(20, 0x1)
194#define TXGBE_TXD_PTID(v) LS(v, 24, 0xFF)
195
196#define TXGBE_TXD_DD MS(0, 0x1)
197#define TXGBE_TXD_IDX(v) LS(v, 4, 0x1)
198#define TXGBE_TXD_L4LEN(v) LS(v, 8, 0xFF)
199#define TXGBE_TXD_MSS(v) LS(v, 16, 0xFFFF)
200
201
202
203
204struct txgbe_tx_desc {
205 __le64 qw0;
206 __le32 dw2;
207 __le32 dw3;
208};
209
210
211
212#define TXGBE_TXD_DATLEN(v) ((0xFFFF & (v)))
213#define TXGBE_TXD_1588 ((0x1) << 19)
214#define TXGBE_TXD_DATA ((0x0) << 20)
215#define TXGBE_TXD_EOP ((0x1) << 24)
216#define TXGBE_TXD_FCS ((0x1) << 25)
217#define TXGBE_TXD_LINKSEC ((0x1) << 26)
218#define TXGBE_TXD_ECU ((0x1) << 28)
219#define TXGBE_TXD_CNTAG ((0x1) << 29)
220#define TXGBE_TXD_VLE ((0x1) << 30)
221#define TXGBE_TXD_TSE ((0x1) << 31)
222
223#define TXGBE_TXD_FLAGS (TXGBE_TXD_FCS | TXGBE_TXD_EOP)
224
225
226#define TXGBE_TXD_DD_UNUSED TXGBE_TXD_DD
227#define TXGBE_TXD_IDX_UNUSED(v) TXGBE_TXD_IDX(v)
228#define TXGBE_TXD_CC ((0x1) << 7)
229#define TXGBE_TXD_IPSEC ((0x1) << 8)
230#define TXGBE_TXD_L4CS ((0x1) << 9)
231#define TXGBE_TXD_IPCS ((0x1) << 10)
232#define TXGBE_TXD_EIPCS ((0x1) << 11)
233#define TXGBE_TXD_MNGFLT ((0x1) << 12)
234#define TXGBE_TXD_PAYLEN(v) ((0x7FFFF & (v)) << 13)
235
236#define RTE_PMD_TXGBE_TX_MAX_BURST 32
237#define RTE_PMD_TXGBE_RX_MAX_BURST 32
238#define RTE_TXGBE_TX_MAX_FREE_BUF_SZ 64
239
240#define RX_RING_SZ ((TXGBE_RING_DESC_MAX + RTE_PMD_TXGBE_RX_MAX_BURST) * \
241 sizeof(struct txgbe_rx_desc))
242
243#define rte_packet_prefetch(p) rte_prefetch1(p)
244
245#define RTE_TXGBE_REGISTER_POLL_WAIT_10_MS 10
246#define RTE_TXGBE_WAIT_100_US 100
247
248#define TXGBE_TX_MAX_SEG 40
249
250
251
252
253struct txgbe_rx_entry {
254 struct rte_mbuf *mbuf;
255};
256
257struct txgbe_scattered_rx_entry {
258 struct rte_mbuf *fbuf;
259};
260
261
262
263
264struct txgbe_tx_entry {
265 struct rte_mbuf *mbuf;
266 uint16_t next_id;
267 uint16_t last_id;
268};
269
270
271
272
273struct txgbe_tx_entry_v {
274 struct rte_mbuf *mbuf;
275};
276
277
278
279
280struct txgbe_rx_queue {
281 struct rte_mempool *mb_pool;
282 volatile struct txgbe_rx_desc *rx_ring;
283 uint64_t rx_ring_phys_addr;
284 volatile uint32_t *rdt_reg_addr;
285 volatile uint32_t *rdh_reg_addr;
286 struct txgbe_rx_entry *sw_ring;
287
288 struct txgbe_scattered_rx_entry *sw_sc_ring;
289 struct rte_mbuf *pkt_first_seg;
290 struct rte_mbuf *pkt_last_seg;
291 uint16_t nb_rx_desc;
292 uint16_t rx_tail;
293 uint16_t nb_rx_hold;
294 uint16_t rx_nb_avail;
295 uint16_t rx_next_avail;
296 uint16_t rx_free_trigger;
297#ifdef RTE_LIB_SECURITY
298 uint8_t using_ipsec;
299
300#endif
301 uint16_t rx_free_thresh;
302 uint16_t queue_id;
303 uint16_t reg_idx;
304
305 uint16_t pkt_type_mask;
306 uint16_t port_id;
307 uint8_t crc_len;
308 uint8_t drop_en;
309 uint8_t rx_deferred_start;
310
311 uint64_t vlan_flags;
312 uint64_t offloads;
313
314 struct rte_mbuf fake_mbuf;
315
316 struct rte_mbuf *rx_stage[RTE_PMD_TXGBE_RX_MAX_BURST * 2];
317};
318
319
320
321
322enum txgbe_ctx_num {
323 TXGBE_CTX_0 = 0,
324 TXGBE_CTX_1 = 1,
325 TXGBE_CTX_NUM = 2,
326};
327
328
329union txgbe_tx_offload {
330 uint64_t data[2];
331 struct {
332 uint64_t ptid:8;
333 uint64_t l2_len:7;
334 uint64_t l3_len:9;
335 uint64_t l4_len:8;
336 uint64_t tso_segsz:16;
337 uint64_t vlan_tci:16;
338
339
340
341 uint64_t outer_tun_len:8;
342 uint64_t outer_l2_len:8;
343 uint64_t outer_l3_len:16;
344#ifdef RTE_LIB_SECURITY
345
346 uint64_t sa_idx:8;
347 uint64_t sec_pad_len:4;
348#endif
349 };
350};
351
352
353
354
355struct txgbe_ctx_info {
356 uint64_t flags;
357
358 union txgbe_tx_offload tx_offload;
359
360 union txgbe_tx_offload tx_offload_mask;
361};
362
363
364
365
366struct txgbe_tx_queue {
367
368 volatile struct txgbe_tx_desc *tx_ring;
369 uint64_t tx_ring_phys_addr;
370 union {
371
372 struct txgbe_tx_entry *sw_ring;
373
374 struct txgbe_tx_entry_v *sw_ring_v;
375 };
376 volatile uint32_t *tdt_reg_addr;
377 volatile uint32_t *tdc_reg_addr;
378 uint16_t nb_tx_desc;
379 uint16_t tx_tail;
380
381
382
383 uint16_t tx_free_thresh;
384
385 uint16_t last_desc_cleaned;
386
387 uint16_t nb_tx_free;
388 uint16_t tx_next_dd;
389 uint16_t queue_id;
390 uint16_t reg_idx;
391 uint16_t port_id;
392 uint8_t pthresh;
393 uint8_t hthresh;
394 uint8_t wthresh;
395 uint64_t offloads;
396 uint32_t ctx_curr;
397
398 struct txgbe_ctx_info ctx_cache[TXGBE_CTX_NUM];
399 const struct txgbe_txq_ops *ops;
400 uint8_t tx_deferred_start;
401#ifdef RTE_LIB_SECURITY
402 uint8_t using_ipsec;
403
404#endif
405};
406
407struct txgbe_txq_ops {
408 void (*release_mbufs)(struct txgbe_tx_queue *txq);
409 void (*free_swring)(struct txgbe_tx_queue *txq);
410 void (*reset)(struct txgbe_tx_queue *txq);
411};
412
413
414
415
416
417void txgbe_set_tx_function(struct rte_eth_dev *dev, struct txgbe_tx_queue *txq);
418
419void txgbe_set_rx_function(struct rte_eth_dev *dev);
420int txgbe_dev_tx_done_cleanup(void *tx_queue, uint32_t free_cnt);
421
422uint64_t txgbe_get_tx_port_offloads(struct rte_eth_dev *dev);
423uint64_t txgbe_get_rx_queue_offloads(struct rte_eth_dev *dev);
424uint64_t txgbe_get_rx_port_offloads(struct rte_eth_dev *dev);
425uint64_t txgbe_get_tx_queue_offloads(struct rte_eth_dev *dev);
426
427#endif
428