This source file includes following definitions.
- wil_skb_rxstatus
- wil_rx_status_get_length
- wil_rx_status_get_mcs
- wil_rx_status_get_cb_mode
- wil_rx_status_get_flow_id
- wil_rx_status_get_mcast
- wil_rx_status_get_cid
- wil_rx_status_get_tid
- wil_rx_status_get_eop
- wil_rx_status_reset_buff_id
- wil_rx_status_get_buff_id
- wil_rx_status_get_data_offset
- wil_rx_status_get_frame_type
- wil_rx_status_get_fc1
- wil_rx_status_get_seq
- wil_rx_status_get_retry
- wil_rx_status_get_mid
- wil_rx_status_get_error
- wil_rx_status_get_l2_rx_status
- wil_rx_status_get_l3_rx_status
- wil_rx_status_get_l4_rx_status
- wil_rx_status_get_checksum
- wil_rx_status_get_security
- wil_rx_status_get_key_id
- wil_tx_status_get_mcs
- wil_ring_next_head
- wil_desc_set_addr_edma
- wil_tx_desc_get_addr_edma
- wil_rx_desc_get_addr_edma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #ifndef WIL6210_TXRX_EDMA_H
18 #define WIL6210_TXRX_EDMA_H
19
20 #include "wil6210.h"
21
22
23 #define WIL_SRING_SIZE_ORDER_MIN (WIL_RING_SIZE_ORDER_MIN)
24 #define WIL_SRING_SIZE_ORDER_MAX (WIL_RING_SIZE_ORDER_MAX)
25
26 #define WIL_RX_SRING_SIZE_ORDER_DEFAULT (12)
27 #define WIL_TX_SRING_SIZE_ORDER_DEFAULT (14)
28 #define WIL_RX_BUFF_ARR_SIZE_DEFAULT (2600)
29
30 #define WIL_DEFAULT_RX_STATUS_RING_ID 0
31 #define WIL_RX_DESC_RING_ID 0
32 #define WIL_RX_STATUS_IRQ_IDX 0
33 #define WIL_TX_STATUS_IRQ_IDX 1
34
35 #define WIL_EDMA_AGG_WATERMARK (0xffff)
36 #define WIL_EDMA_AGG_WATERMARK_POS (16)
37
38 #define WIL_EDMA_IDLE_TIME_LIMIT_USEC (50)
39 #define WIL_EDMA_TIME_UNIT_CLK_CYCLES (330)
40
41
42 #define WIL_RX_EDMA_ERROR_MIC (1)
43 #define WIL_RX_EDMA_ERROR_KEY (2)
44 #define WIL_RX_EDMA_ERROR_REPLAY (3)
45 #define WIL_RX_EDMA_ERROR_AMSDU (4)
46 #define WIL_RX_EDMA_ERROR_FCS (7)
47
48 #define WIL_RX_EDMA_ERROR_L3_ERR (BIT(0) | BIT(1))
49 #define WIL_RX_EDMA_ERROR_L4_ERR (BIT(0) | BIT(1))
50
51 #define WIL_RX_EDMA_DLPF_LU_MISS_BIT BIT(11)
52 #define WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK 0x7
53 #define WIL_RX_EDMA_DLPF_LU_HIT_CID_TID_MASK 0xf
54
55 #define WIL_RX_EDMA_DLPF_LU_MISS_CID_POS 2
56 #define WIL_RX_EDMA_DLPF_LU_HIT_CID_POS 4
57
58 #define WIL_RX_EDMA_DLPF_LU_MISS_TID_POS 5
59
60 #define WIL_RX_EDMA_MID_VALID_BIT BIT(22)
61
62 #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_POS 16
63 #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_LEN 6
64
65 #define WIL_EDMA_DESC_TX_CFG_EOP_POS 0
66 #define WIL_EDMA_DESC_TX_CFG_EOP_LEN 1
67
68 #define WIL_EDMA_DESC_TX_CFG_TSO_DESC_TYPE_POS 3
69 #define WIL_EDMA_DESC_TX_CFG_TSO_DESC_TYPE_LEN 2
70
71 #define WIL_EDMA_DESC_TX_CFG_SEG_EN_POS 5
72 #define WIL_EDMA_DESC_TX_CFG_SEG_EN_LEN 1
73
74 #define WIL_EDMA_DESC_TX_CFG_INSERT_IP_CHKSUM_POS 6
75 #define WIL_EDMA_DESC_TX_CFG_INSERT_IP_CHKSUM_LEN 1
76
77 #define WIL_EDMA_DESC_TX_CFG_INSERT_TCP_CHKSUM_POS 7
78 #define WIL_EDMA_DESC_TX_CFG_INSERT_TCP_CHKSUM_LEN 1
79
80 #define WIL_EDMA_DESC_TX_CFG_L4_TYPE_POS 15
81 #define WIL_EDMA_DESC_TX_CFG_L4_TYPE_LEN 1
82
83 #define WIL_EDMA_DESC_TX_CFG_PSEUDO_HEADER_CALC_EN_POS 5
84 #define WIL_EDMA_DESC_TX_CFG_PSEUDO_HEADER_CALC_EN_LEN 1
85
86
87
88
89
90
91
92
93
94 struct wil_ring_rx_enhanced_mac {
95 u32 d[3];
96 __le16 buff_id;
97 u16 reserved;
98 } __packed;
99
100
101
102
103
104
105
106
107
108
109
110
111 struct wil_ring_rx_enhanced_dma {
112 u32 d0;
113 struct wil_ring_dma_addr addr;
114 u16 w5;
115 __le16 addr_high_high;
116 __le16 length;
117 } __packed;
118
119 struct wil_rx_enhanced_desc {
120 struct wil_ring_rx_enhanced_mac mac;
121 struct wil_ring_rx_enhanced_dma dma;
122 } __packed;
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139 struct wil_ring_tx_enhanced_dma {
140 u8 l4_hdr_len;
141 u8 cmd;
142 u16 w1;
143 struct wil_ring_dma_addr addr;
144 u8 ip_length;
145 u8 b11;
146 __le16 addr_high_high;
147 __le16 length;
148 } __packed;
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187 struct wil_ring_tx_enhanced_mac {
188 u32 d[3];
189 __le16 tso_mss;
190 u16 scratchpad;
191 } __packed;
192
193 struct wil_tx_enhanced_desc {
194 struct wil_ring_tx_enhanced_mac mac;
195 struct wil_ring_tx_enhanced_dma dma;
196 } __packed;
197
198 #define TX_STATUS_DESC_READY_POS 7
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236 struct wil_ring_tx_status {
237 u8 num_descriptors;
238 u8 ring_id;
239 u8 status;
240 u8 desc_ready;
241 u32 timestamp;
242 u32 d2;
243 u16 seq_number;
244 u16 w7;
245 } __packed;
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297 struct wil_rx_status_compressed {
298 u32 d0;
299 u32 d1;
300 __le16 buff_id;
301 __le16 length;
302 u32 timestamp;
303 } __packed;
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340 struct wil_rx_status_extension {
341 u32 d0;
342 u32 d1;
343 __le16 seq_num;
344 u16 pn_15_0;
345 u32 pn_47_16;
346 } __packed;
347
348 struct wil_rx_status_extended {
349 struct wil_rx_status_compressed comp;
350 struct wil_rx_status_extension ext;
351 } __packed;
352
353 static inline void *wil_skb_rxstatus(struct sk_buff *skb)
354 {
355 return (void *)skb->cb;
356 }
357
358 static inline __le16 wil_rx_status_get_length(void *msg)
359 {
360 return ((struct wil_rx_status_compressed *)msg)->length;
361 }
362
363 static inline u8 wil_rx_status_get_mcs(void *msg)
364 {
365 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
366 16, 21);
367 }
368
369 static inline u8 wil_rx_status_get_cb_mode(void *msg)
370 {
371 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
372 22, 23);
373 }
374
375 static inline u16 wil_rx_status_get_flow_id(void *msg)
376 {
377 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
378 8, 19);
379 }
380
381 static inline u8 wil_rx_status_get_mcast(void *msg)
382 {
383 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
384 26, 26);
385 }
386
387
388
389
390
391
392
393
394
395
396
397 static inline u8 wil_rx_status_get_cid(void *msg)
398 {
399 u16 val = wil_rx_status_get_flow_id(msg);
400
401 if (val & WIL_RX_EDMA_DLPF_LU_MISS_BIT)
402
403 return (val >> WIL_RX_EDMA_DLPF_LU_MISS_CID_POS) &
404 WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK;
405 else
406
407 return (val >> WIL_RX_EDMA_DLPF_LU_HIT_CID_POS) &
408 WIL_RX_EDMA_DLPF_LU_HIT_CID_TID_MASK;
409 }
410
411 static inline u8 wil_rx_status_get_tid(void *msg)
412 {
413 u16 val = wil_rx_status_get_flow_id(msg);
414
415 if (val & WIL_RX_EDMA_DLPF_LU_MISS_BIT)
416
417 return (val >> WIL_RX_EDMA_DLPF_LU_MISS_TID_POS) &
418 WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK;
419 else
420
421 return val & WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK;
422 }
423
424 static inline int wil_rx_status_get_eop(void *msg)
425 {
426 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
427 30, 30);
428 }
429
430 static inline void wil_rx_status_reset_buff_id(struct wil_status_ring *s)
431 {
432 ((struct wil_rx_status_compressed *)
433 (s->va + (s->elem_size * s->swhead)))->buff_id = 0;
434 }
435
436 static inline __le16 wil_rx_status_get_buff_id(void *msg)
437 {
438 return ((struct wil_rx_status_compressed *)msg)->buff_id;
439 }
440
441 static inline u8 wil_rx_status_get_data_offset(void *msg)
442 {
443 u8 val = WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
444 24, 27);
445
446 switch (val) {
447 case 0: return 0;
448 case 3: return 2;
449 default: return 0xFF;
450 }
451 }
452
453 static inline int wil_rx_status_get_frame_type(struct wil6210_priv *wil,
454 void *msg)
455 {
456 if (wil->use_compressed_rx_status)
457 return IEEE80211_FTYPE_DATA;
458
459 return WIL_GET_BITS(((struct wil_rx_status_extended *)msg)->ext.d1,
460 0, 1) << 2;
461 }
462
463 static inline int wil_rx_status_get_fc1(struct wil6210_priv *wil, void *msg)
464 {
465 if (wil->use_compressed_rx_status)
466 return 0;
467
468 return WIL_GET_BITS(((struct wil_rx_status_extended *)msg)->ext.d1,
469 0, 5) << 2;
470 }
471
472 static inline __le16 wil_rx_status_get_seq(struct wil6210_priv *wil, void *msg)
473 {
474 if (wil->use_compressed_rx_status)
475 return 0;
476
477 return ((struct wil_rx_status_extended *)msg)->ext.seq_num;
478 }
479
480 static inline u8 wil_rx_status_get_retry(void *msg)
481 {
482
483 return 1;
484 }
485
486 static inline int wil_rx_status_get_mid(void *msg)
487 {
488 if (!(((struct wil_rx_status_compressed *)msg)->d0 &
489 WIL_RX_EDMA_MID_VALID_BIT))
490 return 0;
491
492 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
493 20, 21);
494 }
495
496 static inline int wil_rx_status_get_error(void *msg)
497 {
498 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
499 29, 29);
500 }
501
502 static inline int wil_rx_status_get_l2_rx_status(void *msg)
503 {
504 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
505 0, 2);
506 }
507
508 static inline int wil_rx_status_get_l3_rx_status(void *msg)
509 {
510 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
511 3, 4);
512 }
513
514 static inline int wil_rx_status_get_l4_rx_status(void *msg)
515 {
516 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
517 5, 6);
518 }
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534 static inline int wil_rx_status_get_checksum(void *msg,
535 struct wil_net_stats *stats)
536 {
537 int l3_rx_status = wil_rx_status_get_l3_rx_status(msg);
538 int l4_rx_status = wil_rx_status_get_l4_rx_status(msg);
539
540 if (l4_rx_status == 1)
541 return CHECKSUM_UNNECESSARY;
542
543 if (l4_rx_status == 0 && l3_rx_status == 1)
544 return CHECKSUM_UNNECESSARY;
545
546 if (l3_rx_status == 0 && l4_rx_status == 0)
547
548 return CHECKSUM_NONE;
549
550
551
552
553
554
555 stats->rx_csum_err++;
556 return CHECKSUM_NONE;
557 }
558
559 static inline int wil_rx_status_get_security(void *msg)
560 {
561 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
562 28, 28);
563 }
564
565 static inline u8 wil_rx_status_get_key_id(void *msg)
566 {
567 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
568 31, 31);
569 }
570
571 static inline u8 wil_tx_status_get_mcs(struct wil_ring_tx_status *msg)
572 {
573 return WIL_GET_BITS(msg->d2, 0, 4);
574 }
575
576 static inline u32 wil_ring_next_head(struct wil_ring *ring)
577 {
578 return (ring->swhead + 1) % ring->size;
579 }
580
581 static inline void wil_desc_set_addr_edma(struct wil_ring_dma_addr *addr,
582 __le16 *addr_high_high,
583 dma_addr_t pa)
584 {
585 addr->addr_low = cpu_to_le32(lower_32_bits(pa));
586 addr->addr_high = cpu_to_le16((u16)upper_32_bits(pa));
587 *addr_high_high = cpu_to_le16((u16)(upper_32_bits(pa) >> 16));
588 }
589
590 static inline
591 dma_addr_t wil_tx_desc_get_addr_edma(struct wil_ring_tx_enhanced_dma *dma)
592 {
593 return le32_to_cpu(dma->addr.addr_low) |
594 ((u64)le16_to_cpu(dma->addr.addr_high) << 32) |
595 ((u64)le16_to_cpu(dma->addr_high_high) << 48);
596 }
597
598 static inline
599 dma_addr_t wil_rx_desc_get_addr_edma(struct wil_ring_rx_enhanced_dma *dma)
600 {
601 return le32_to_cpu(dma->addr.addr_low) |
602 ((u64)le16_to_cpu(dma->addr.addr_high) << 32) |
603 ((u64)le16_to_cpu(dma->addr_high_high) << 48);
604 }
605
606 void wil_configure_interrupt_moderation_edma(struct wil6210_priv *wil);
607 int wil_tx_sring_handler(struct wil6210_priv *wil,
608 struct wil_status_ring *sring);
609 void wil_rx_handle_edma(struct wil6210_priv *wil, int *quota);
610 void wil_init_txrx_ops_edma(struct wil6210_priv *wil);
611
612 #endif
613