treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / net / wireless / realtek / rtlwifi / rtl8192de / trx.h
blobd01578875cd5ff9cdc6127716292238ba5974fea
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2012 Realtek Corporation.*/
4 #ifndef __RTL92DE_TRX_H__
5 #define __RTL92DE_TRX_H__
7 #define TX_DESC_SIZE 64
8 #define TX_DESC_AGGR_SUBFRAME_SIZE 32
10 #define RX_DESC_SIZE 32
11 #define RX_DRV_INFO_SIZE_UNIT 8
13 #define TX_DESC_NEXT_DESC_OFFSET 40
14 #define USB_HWDESC_HEADER_LEN 32
15 #define CRCLENGTH 4
17 /* macros to read/write various fields in RX or TX descriptors */
19 static inline void set_tx_desc_pkt_size(__le32 *__pdesc, u32 __val)
21 le32p_replace_bits(__pdesc, __val, GENMASK(15, 0));
24 static inline void set_tx_desc_offset(__le32 *__pdesc, u32 __val)
26 le32p_replace_bits(__pdesc, __val, GENMASK(23, 16));
29 static inline void set_tx_desc_htc(__le32 *__pdesc, u32 __val)
31 le32p_replace_bits(__pdesc, __val, BIT(25));
34 static inline void set_tx_desc_last_seg(__le32 *__pdesc, u32 __val)
36 le32p_replace_bits(__pdesc, __val, BIT(26));
39 static inline void set_tx_desc_first_seg(__le32 *__pdesc, u32 __val)
41 le32p_replace_bits(__pdesc, __val, BIT(27));
44 static inline void set_tx_desc_linip(__le32 *__pdesc, u32 __val)
46 le32p_replace_bits(__pdesc, __val, BIT(28));
49 static inline void set_tx_desc_own(__le32 *__pdesc, u32 __val)
51 le32p_replace_bits(__pdesc, __val, BIT(31));
54 static inline u32 get_tx_desc_own(__le32 *__pdesc)
56 return le32_get_bits(*__pdesc, BIT(31));
59 static inline void set_tx_desc_macid(__le32 *__pdesc, u32 __val)
61 le32p_replace_bits((__pdesc + 1), __val, GENMASK(4, 0));
64 static inline void set_tx_desc_agg_enable(__le32 *__pdesc, u32 __val)
66 le32p_replace_bits((__pdesc + 1), __val, BIT(5));
69 static inline void set_tx_desc_rdg_enable(__le32 *__pdesc, u32 __val)
71 le32p_replace_bits((__pdesc + 1), __val, BIT(7));
74 static inline void set_tx_desc_queue_sel(__le32 *__pdesc, u32 __val)
76 le32p_replace_bits((__pdesc + 1), __val, GENMASK(12, 8));
79 static inline void set_tx_desc_rate_id(__le32 *__pdesc, u32 __val)
81 le32p_replace_bits((__pdesc + 1), __val, GENMASK(19, 16));
84 static inline void set_tx_desc_sec_type(__le32 *__pdesc, u32 __val)
86 le32p_replace_bits((__pdesc + 1), __val, GENMASK(23, 22));
89 static inline void set_tx_desc_pkt_offset(__le32 *__pdesc, u32 __val)
91 le32p_replace_bits((__pdesc + 1), __val, GENMASK(30, 26));
94 static inline void set_tx_desc_more_frag(__le32 *__pdesc, u32 __val)
96 le32p_replace_bits((__pdesc + 2), __val, BIT(17));
99 static inline void set_tx_desc_ampdu_density(__le32 *__pdesc, u32 __val)
101 le32p_replace_bits((__pdesc + 2), __val, GENMASK(22, 20));
104 static inline void set_tx_desc_seq(__le32 *__pdesc, u32 __val)
106 le32p_replace_bits((__pdesc + 3), __val, GENMASK(27, 16));
109 static inline void set_tx_desc_pkt_id(__le32 *__pdesc, u32 __val)
111 le32p_replace_bits((__pdesc + 3), __val, GENMASK(31, 28));
114 static inline void set_tx_desc_rts_rate(__le32 *__pdesc, u32 __val)
116 le32p_replace_bits((__pdesc + 4), __val, GENMASK(4, 0));
119 static inline void set_tx_desc_qos(__le32 *__pdesc, u32 __val)
121 le32p_replace_bits((__pdesc + 4), __val, BIT(6));
124 static inline void set_tx_desc_hwseq_en(__le32 *__pdesc, u32 __val)
126 le32p_replace_bits((__pdesc + 4), __val, BIT(7));
129 static inline void set_tx_desc_use_rate(__le32 *__pdesc, u32 __val)
131 le32p_replace_bits((__pdesc + 4), __val, BIT(8));
134 static inline void set_tx_desc_disable_fb(__le32 *__pdesc, u32 __val)
136 le32p_replace_bits((__pdesc + 4), __val, BIT(10));
139 static inline void set_tx_desc_cts2self(__le32 *__pdesc, u32 __val)
141 le32p_replace_bits((__pdesc + 4), __val, BIT(11));
144 static inline void set_tx_desc_rts_enable(__le32 *__pdesc, u32 __val)
146 le32p_replace_bits((__pdesc + 4), __val, BIT(12));
149 static inline void set_tx_desc_hw_rts_enable(__le32 *__pdesc, u32 __val)
151 le32p_replace_bits((__pdesc + 4), __val, BIT(13));
154 static inline void set_tx_desc_tx_sub_carrier(__le32 *__pdesc, u32 __val)
156 le32p_replace_bits((__pdesc + 4), __val, GENMASK(21, 20));
159 static inline void set_tx_desc_data_bw(__le32 *__pdesc, u32 __val)
161 le32p_replace_bits((__pdesc + 4), __val, BIT(25));
164 static inline void set_tx_desc_rts_short(__le32 *__pdesc, u32 __val)
166 le32p_replace_bits((__pdesc + 4), __val, BIT(26));
169 static inline void set_tx_desc_rts_bw(__le32 *__pdesc, u32 __val)
171 le32p_replace_bits((__pdesc + 4), __val, BIT(27));
174 static inline void set_tx_desc_rts_sc(__le32 *__pdesc, u32 __val)
176 le32p_replace_bits((__pdesc + 4), __val, GENMASK(29, 28));
179 static inline void set_tx_desc_rts_stbc(__le32 *__pdesc, u32 __val)
181 le32p_replace_bits((__pdesc + 4), __val, GENMASK(31, 30));
184 static inline void set_tx_desc_tx_rate(__le32 *__pdesc, u32 __val)
186 le32p_replace_bits((__pdesc + 5), __val, GENMASK(5, 0));
189 static inline void set_tx_desc_data_shortgi(__le32 *__pdesc, u32 __val)
191 le32p_replace_bits((__pdesc + 5), __val, BIT(6));
194 static inline void set_tx_desc_data_rate_fb_limit(__le32 *__pdesc, u32 __val)
196 le32p_replace_bits((__pdesc + 5), __val, GENMASK(12, 8));
199 static inline void set_tx_desc_rts_rate_fb_limit(__le32 *__pdesc, u32 __val)
201 le32p_replace_bits((__pdesc + 5), __val, GENMASK(16, 13));
204 static inline void set_tx_desc_max_agg_num(__le32 *__pdesc, u32 __val)
206 le32p_replace_bits((__pdesc + 6), __val, GENMASK(15, 11));
209 static inline void set_tx_desc_tx_buffer_size(__le32 *__pdesc, u32 __val)
211 le32p_replace_bits((__pdesc + 7), __val, GENMASK(15, 0));
214 static inline void set_tx_desc_tx_buffer_address(__le32 *__pdesc, u32 __val)
216 *(__pdesc + 8) = cpu_to_le32(__val);
219 static inline u32 get_tx_desc_tx_buffer_address(__le32 *__pdesc)
221 return le32_to_cpu(*(__pdesc + 8));
224 static inline void set_tx_desc_next_desc_address(__le32 *__pdesc, u32 __val)
226 *(__pdesc + 10) = cpu_to_le32(__val);
229 static inline u32 get_rx_desc_pkt_len(__le32 *__pdesc)
231 return le32_get_bits(*__pdesc, GENMASK(13, 0));
234 static inline u32 get_rx_desc_crc32(__le32 *__pdesc)
236 return le32_get_bits(*__pdesc, BIT(14));
239 static inline u32 get_rx_desc_icv(__le32 *__pdesc)
241 return le32_get_bits(*__pdesc, BIT(15));
244 static inline u32 get_rx_desc_drv_info_size(__le32 *__pdesc)
246 return le32_get_bits(*__pdesc, GENMASK(19, 16));
249 static inline u32 get_rx_desc_shift(__le32 *__pdesc)
251 return le32_get_bits(*__pdesc, GENMASK(25, 24));
254 static inline u32 get_rx_desc_physt(__le32 *__pdesc)
256 return le32_get_bits(*__pdesc, BIT(26));
259 static inline u32 get_rx_desc_swdec(__le32 *__pdesc)
261 return le32_get_bits(*__pdesc, BIT(27));
264 static inline u32 get_rx_desc_own(__le32 *__pdesc)
266 return le32_get_bits(*__pdesc, BIT(31));
269 static inline void set_rx_desc_pkt_len(__le32 *__pdesc, u32 __val)
271 le32p_replace_bits(__pdesc, __val, GENMASK(13, 0));
274 static inline void set_rx_desc_eor(__le32 *__pdesc, u32 __val)
276 le32p_replace_bits(__pdesc, __val, BIT(30));
279 static inline void set_rx_desc_own(__le32 *__pdesc, u32 __val)
281 le32p_replace_bits(__pdesc, __val, BIT(31));
284 static inline u32 get_rx_desc_paggr(__le32 *__pdesc)
286 return le32_get_bits(*(__pdesc + 1), BIT(14));
289 static inline u32 get_rx_desc_faggr(__le32 *__pdesc)
291 return le32_get_bits(*(__pdesc + 1), BIT(15));
294 static inline u32 get_rx_desc_rxmcs(__le32 *__pdesc)
296 return le32_get_bits(*(__pdesc + 3), GENMASK(5, 0));
299 static inline u32 get_rx_desc_rxht(__le32 *__pdesc)
301 return le32_get_bits(*(__pdesc + 3), BIT(6));
304 static inline u32 get_rx_desc_splcp(__le32 *__pdesc)
306 return le32_get_bits(*(__pdesc + 3), BIT(8));
309 static inline u32 get_rx_desc_bw(__le32 *__pdesc)
311 return le32_get_bits(*(__pdesc + 3), BIT(9));
314 static inline u32 get_rx_desc_tsfl(__le32 *__pdesc)
316 return le32_to_cpu(*(__pdesc + 5));
319 static inline u32 get_rx_desc_buff_addr(__le32 *__pdesc)
321 return le32_to_cpu(*(__pdesc + 6));
324 static inline void set_rx_desc_buff_addr(__le32 *__pdesc, u32 __val)
326 *(__pdesc + 6) = cpu_to_le32(__val);
329 static inline void clear_pci_tx_desc_content(__le32 *__pdesc, u32 _size)
331 memset((void *)__pdesc, 0,
332 min_t(size_t, _size, TX_DESC_NEXT_DESC_OFFSET));
335 /* For 92D early mode */
336 static inline void set_earlymode_pktnum(__le32 *__paddr, u32 __value)
338 le32p_replace_bits(__paddr, __value, GENMASK(2, 0));
341 static inline void set_earlymode_len0(__le32 *__paddr, u32 __value)
343 le32p_replace_bits(__paddr, __value, GENMASK(15, 4));
346 static inline void set_earlymode_len1(__le32 *__paddr, u32 __value)
348 le32p_replace_bits(__paddr, __value, GENMASK(27, 16));
351 static inline void set_earlymode_len2_1(__le32 *__paddr, u32 __value)
353 le32p_replace_bits(__paddr, __value, GENMASK(31, 28));
356 static inline void set_earlymode_len2_2(__le32 *__paddr, u32 __value)
358 le32p_replace_bits((__paddr + 1), __value, GENMASK(7, 0));
361 static inline void set_earlymode_len3(__le32 *__paddr, u32 __value)
363 le32p_replace_bits((__paddr + 1), __value, GENMASK(19, 8));
366 static inline void set_earlymode_len4(__le32 *__paddr, u32 __value)
368 le32p_replace_bits((__paddr + 1), __value, GENMASK(31, 20));
371 struct rx_fwinfo_92d {
372 u8 gain_trsw[4];
373 u8 pwdb_all;
374 u8 cfosho[4];
375 u8 cfotail[4];
376 s8 rxevm[2];
377 s8 rxsnr[4];
378 u8 pdsnr[2];
379 u8 csi_current[2];
380 u8 csi_target[2];
381 u8 sigevm;
382 u8 max_ex_pwr;
383 u8 ex_intf_flag:1;
384 u8 sgi_en:1;
385 u8 rxsc:2;
386 u8 reserve:4;
387 } __packed;
389 struct tx_desc_92d {
390 u32 pktsize:16;
391 u32 offset:8;
392 u32 bmc:1;
393 u32 htc:1;
394 u32 lastseg:1;
395 u32 firstseg:1;
396 u32 linip:1;
397 u32 noacm:1;
398 u32 gf:1;
399 u32 own:1;
401 u32 macid:5;
402 u32 agg_en:1;
403 u32 bk:1;
404 u32 rdg_en:1;
405 u32 queuesel:5;
406 u32 rd_nav_ext:1;
407 u32 lsig_txop_en:1;
408 u32 pifs:1;
409 u32 rateid:4;
410 u32 nav_usehdr:1;
411 u32 en_descid:1;
412 u32 sectype:2;
413 u32 pktoffset:8;
415 u32 rts_rc:6;
416 u32 data_rc:6;
417 u32 rsvd0:2;
418 u32 bar_retryht:2;
419 u32 rsvd1:1;
420 u32 morefrag:1;
421 u32 raw:1;
422 u32 ccx:1;
423 u32 ampdudensity:3;
424 u32 rsvd2:1;
425 u32 ant_sela:1;
426 u32 ant_selb:1;
427 u32 txant_cck:2;
428 u32 txant_l:2;
429 u32 txant_ht:2;
431 u32 nextheadpage:8;
432 u32 tailpage:8;
433 u32 seq:12;
434 u32 pktid:4;
436 u32 rtsrate:5;
437 u32 apdcfe:1;
438 u32 qos:1;
439 u32 hwseq_enable:1;
440 u32 userrate:1;
441 u32 dis_rtsfb:1;
442 u32 dis_datafb:1;
443 u32 cts2self:1;
444 u32 rts_en:1;
445 u32 hwrts_en:1;
446 u32 portid:1;
447 u32 rsvd3:3;
448 u32 waitdcts:1;
449 u32 cts2ap_en:1;
450 u32 txsc:2;
451 u32 stbc:2;
452 u32 txshort:1;
453 u32 txbw:1;
454 u32 rtsshort:1;
455 u32 rtsbw:1;
456 u32 rtssc:2;
457 u32 rtsstbc:2;
459 u32 txrate:6;
460 u32 shortgi:1;
461 u32 ccxt:1;
462 u32 txrate_fb_lmt:5;
463 u32 rtsrate_fb_lmt:4;
464 u32 retrylmt_en:1;
465 u32 txretrylmt:6;
466 u32 usb_txaggnum:8;
468 u32 txagca:5;
469 u32 txagcb:5;
470 u32 usemaxlen:1;
471 u32 maxaggnum:5;
472 u32 mcsg1maxlen:4;
473 u32 mcsg2maxlen:4;
474 u32 mcsg3maxlen:4;
475 u32 mcs7sgimaxlen:4;
477 u32 txbuffersize:16;
478 u32 mcsg4maxlen:4;
479 u32 mcsg5maxlen:4;
480 u32 mcsg6maxlen:4;
481 u32 mcsg15sgimaxlen:4;
483 u32 txbuffaddr;
484 u32 txbufferaddr64;
485 u32 nextdescaddress;
486 u32 nextdescaddress64;
488 u32 reserve_pass_pcie_mm_limit[4];
489 } __packed;
491 struct rx_desc_92d {
492 u32 length:14;
493 u32 crc32:1;
494 u32 icverror:1;
495 u32 drv_infosize:4;
496 u32 security:3;
497 u32 qos:1;
498 u32 shift:2;
499 u32 phystatus:1;
500 u32 swdec:1;
501 u32 lastseg:1;
502 u32 firstseg:1;
503 u32 eor:1;
504 u32 own:1;
506 u32 macid:5;
507 u32 tid:4;
508 u32 hwrsvd:5;
509 u32 paggr:1;
510 u32 faggr:1;
511 u32 a1_fit:4;
512 u32 a2_fit:4;
513 u32 pam:1;
514 u32 pwr:1;
515 u32 moredata:1;
516 u32 morefrag:1;
517 u32 type:2;
518 u32 mc:1;
519 u32 bc:1;
521 u32 seq:12;
522 u32 frag:4;
523 u32 nextpktlen:14;
524 u32 nextind:1;
525 u32 rsvd:1;
527 u32 rxmcs:6;
528 u32 rxht:1;
529 u32 amsdu:1;
530 u32 splcp:1;
531 u32 bandwidth:1;
532 u32 htc:1;
533 u32 tcpchk_rpt:1;
534 u32 ipcchk_rpt:1;
535 u32 tcpchk_valid:1;
536 u32 hwpcerr:1;
537 u32 hwpcind:1;
538 u32 iv0:16;
540 u32 iv1;
542 u32 tsfl;
544 u32 bufferaddress;
545 u32 bufferaddress64;
547 } __packed;
549 void rtl92de_tx_fill_desc(struct ieee80211_hw *hw,
550 struct ieee80211_hdr *hdr, u8 *pdesc,
551 u8 *pbd_desc_tx, struct ieee80211_tx_info *info,
552 struct ieee80211_sta *sta,
553 struct sk_buff *skb, u8 hw_queue,
554 struct rtl_tcb_desc *ptcb_desc);
555 bool rtl92de_rx_query_desc(struct ieee80211_hw *hw,
556 struct rtl_stats *stats,
557 struct ieee80211_rx_status *rx_status,
558 u8 *pdesc, struct sk_buff *skb);
559 void rtl92de_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx,
560 u8 desc_name, u8 *val);
561 u64 rtl92de_get_desc(struct ieee80211_hw *hw,
562 u8 *p_desc, bool istx, u8 desc_name);
563 bool rtl92de_is_tx_desc_closed(struct ieee80211_hw *hw,
564 u8 hw_queue, u16 index);
565 void rtl92de_tx_polling(struct ieee80211_hw *hw, u8 hw_queue);
566 void rtl92de_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc,
567 bool b_firstseg, bool b_lastseg,
568 struct sk_buff *skb);
570 #endif