2 ******************************************************************************
6 * @brief File containing the definition of HW descriptors.
8 * Contains the definition and structures used by HW
10 * Copyright (C) ESWIN 2015-2020
12 ******************************************************************************
18 #include "lmac_types.h"
20 #define ECRNX_MACHW_NX 1
21 #define ECRNX_MACHW_HE 2
22 /* Rate and policy table */
26 #define N_HT (8 * 2 * 2 * 4)
27 #define N_VHT (10 * 4 * 2 * 8)
28 #define N_HE_SU (12 * 4 * 3 * 8)
29 #define N_HE_MU (12 * 6 * 3 * 8)
31 /* conversion table from NL80211 to MACHW enum */
32 extern const int chnl2bw[];
34 /* conversion table from MACHW to NL80211 enum */
35 extern const int bw2chnl[];
37 struct ecrnx_legrate {
39 u16 rate; // in 100Kbps
41 extern const struct ecrnx_legrate legrates_lut[];
42 /* Values for formatModTx */
43 #define FORMATMOD_NON_HT 0
44 #define FORMATMOD_NON_HT_DUP_OFDM 1
45 #define FORMATMOD_HT_MF 2
46 #define FORMATMOD_HT_GF 3
47 #define FORMATMOD_VHT 4
48 #define FORMATMOD_HE_SU 5
49 #define FORMATMOD_HE_MU 6
50 #define FORMATMOD_HE_ER 7
51 #define FORMATMOD_HE_TB 8
53 /* Values for navProtFrmEx */
54 #define NAV_PROT_NO_PROT_BIT 0
55 #define NAV_PROT_SELF_CTS_BIT 1
56 #define NAV_PROT_RTS_CTS_BIT 2
57 #define NAV_PROT_RTS_CTS_WITH_QAP_BIT 3
58 #define NAV_PROT_STBC_BIT 4
60 /* THD MACCTRLINFO2 fields, used in struct umacdesc umac.flags */
61 /// WhichDescriptor definition - contains aMPDU bit and position value
62 /// Offset of WhichDescriptor field in the MAC CONTROL INFO 2 word
63 #define WHICHDESC_OFT 19
64 /// Mask of the WhichDescriptor field
65 #define WHICHDESC_MSK (0x07 << WHICHDESC_OFT)
66 /// Only 1 THD possible, describing an unfragmented MSDU
67 #define WHICHDESC_UNFRAGMENTED_MSDU (0x00 << WHICHDESC_OFT)
68 /// THD describing the first MPDU of a fragmented MSDU
69 #define WHICHDESC_FRAGMENTED_MSDU_FIRST (0x01 << WHICHDESC_OFT)
70 /// THD describing intermediate MPDUs of a fragmented MSDU
71 #define WHICHDESC_FRAGMENTED_MSDU_INT (0x02 << WHICHDESC_OFT)
72 /// THD describing the last MPDU of a fragmented MSDU
73 #define WHICHDESC_FRAGMENTED_MSDU_LAST (0x03 << WHICHDESC_OFT)
74 /// THD for extra descriptor starting an AMPDU
75 #define WHICHDESC_AMPDU_EXTRA (0x04 << WHICHDESC_OFT)
76 /// THD describing the first MPDU of an A-MPDU
77 #define WHICHDESC_AMPDU_FIRST (0x05 << WHICHDESC_OFT)
78 /// THD describing intermediate MPDUs of an A-MPDU
79 #define WHICHDESC_AMPDU_INT (0x06 << WHICHDESC_OFT)
80 /// THD describing the last MPDU of an A-MPDU
81 #define WHICHDESC_AMPDU_LAST (0x07 << WHICHDESC_OFT)
86 #define AMPDU_BIT CO_BIT(AMPDU_OFT)
88 union ecrnx_mcs_index {
104 union ecrnx_rate_ctrl_info {
108 u32 giAndPreTypeTx : 2;
110 #ifdef CONFIG_ECRNX_FULLMAC
113 u32 navProtFrmEx : 3;
114 u32 mcsIndexProtTx : 7;
116 u32 formatModProtTx : 3;
123 struct ecrnx_power_ctrl_info {
124 u32 txPwrLevelPT : 8;
125 u32 txPwrLevelProtPT : 8;
129 union ecrnx_pol_phy_ctrl_info_1 {
143 union ecrnx_pol_phy_ctrl_info_2 {
152 union ecrnx_pol_mac_ctrl_info_1 {
154 u32 keySRamIndex : 10;
155 u32 keySRamIndexRA : 10;
160 union ecrnx_pol_mac_ctrl_info_2 {
162 u32 longRetryLimit : 8;
163 u32 shortRetryLimit : 8;
164 u32 rtsThreshold : 12;
169 #define POLICY_TABLE_PATTERN 0xBADCAB1E
171 struct tx_policy_tbl {
172 /* Unique Pattern at the start of Policy Table */
174 /* PHY Control 1 Information used by MAC HW */
175 union ecrnx_pol_phy_ctrl_info_1 phyctrlinfo_1;
176 /* PHY Control 2 Information used by MAC HW */
177 union ecrnx_pol_phy_ctrl_info_2 phyctrlinfo_2;
178 /* MAC Control 1 Information used by MAC HW */
179 union ecrnx_pol_mac_ctrl_info_1 macctrlinfo_1;
180 /* MAC Control 2 Information used by MAC HW */
181 union ecrnx_pol_mac_ctrl_info_2 macctrlinfo_2;
183 union ecrnx_rate_ctrl_info ratectrlinfos[NX_TX_MAX_RATES];
184 struct ecrnx_power_ctrl_info powerctrlinfos[NX_TX_MAX_RATES];
187 #ifdef CONFIG_ECRNX_SOFTMAC
189 union ecrnx_hw_txstatus {
191 u32 num_rts_retries : 8;
192 u32 num_mpdu_retries : 8;
193 u32 retry_limit_reached : 1;
194 u32 lifetime_expired : 1;
195 u32 baFrameReceived : 1;
197 u32 frm_successful_tx : 1;
198 u32 transmission_bw : 2;
199 u32 which_descriptor_sw : 4;
200 u32 descriptor_done_swtx : 1;
201 u32 descriptor_done_hwtx : 1;
206 // WhichDescriptor for AMPDUs (_under BA Policy_)
207 #define __WD_AMPDU_BAPOL 0xC
208 #define __WD_AMPDU_EXTRA 0xC
209 #define __WD_AMPDU_FIRST 0xD
210 #define __WD_AMPDU_INT 0xE
211 #define __WD_AMPDU_LAST 0xF
213 #define ECRNX_WD_IS_AMPDU(whichdesc) \
214 (((whichdesc) & __WD_AMPDU_BAPOL) == __WD_AMPDU_BAPOL)
215 #define ECRNX_WD_IS_FIRST(whichdesc) \
216 ((whichdesc) == __WD_AMPDU_FIRST)
217 #define ECRNX_WD_IS_LAST(whichdesc) \
218 ((whichdesc) == __WD_AMPDU_LAST)
220 union ecrnx_thd_phy_ctrl_info {
224 u32 smoothingProtTx : 1;
225 u32 useBWSignalingTx : 1;
227 u32 dozeNotAllowedTx : 1;
228 u32 continuousTx : 1;
231 u32 userPositionTx : 2;
235 u32 partialAIDTx : 9;
240 #define EXPECTED_ACK_NO_ACK 0
241 #define EXPECTED_ACK_NORMAL_ACK 1
242 #define EXPECTED_ACK_BLOCK_ACK 2
243 #define EXPECTED_ACK_COMPRESSED_BLOCK_ACK 3
245 union ecrnx_thd_mac_ctrl_info_1 {
251 u32 lowRateRetry : 1;
260 * struct ecrnx_hw_txhdr - Hardware part of tx header
262 * @policy: Policy table to use for transmission
263 * @mac_ctrl_info: MAC configuration to use for transmission
264 * @phy_ctrl_info: PHY configuration to use for transmission
266 * @status: Status updated by fw/hardware after transmission
268 struct ecrnx_hw_txhdr {
269 struct tx_policy_tbl policy;
270 union ecrnx_thd_mac_ctrl_info_1 mac_ctrl_info;
271 union ecrnx_thd_phy_ctrl_info phy_ctrl_info;
272 union ecrnx_hw_txstatus status;
275 #else /* !CONFIG_ECRNX_SOFTMAC */
278 * struct ecrnx_hw_txstatus - Bitfield of confirmation status
280 * @tx_done: packet has been processed by the firmware.
281 * @retry_required: packet has been transmitted but not acknoledged.
282 * Driver must repush it.
283 * @sw_retry_required: packet has not been transmitted (FW wasn't able to push
284 * it when it received it: not active channel ...). Driver must repush it.
285 * @acknowledged: packet has been acknowledged by peer
287 union ecrnx_hw_txstatus {
290 u32 retry_required : 1;
291 u32 sw_retry_required : 1;
292 u32 acknowledged : 1;
299 * struct tx_cfm_tag - Structure indicating the status and other
300 * information about the transmission
302 * @pn: PN that was used for the transmission
303 * @sn: Sequence number of the packet
304 * @timestamp: Timestamp of first transmission of this MPDU
305 * @credits: Number of credits to be reallocated for the txq that push this
306 * buffer (can be 0 or 1)
307 * @ampdu_size: Size of the ampdu in which the frame has been transmitted if
308 * this was the last frame of the a-mpdu, and 0 if the frame is not the last
310 * 1 means that the frame has been transmitted as a singleton.
311 * @amsdu_size: Size, in bytes, allowed to create a-msdu.
312 * @status: transmission status
321 #ifdef CONFIG_ECRNX_SPLIT_TX_BUF
325 #ifdef CONFIG_ECRNX_ESWIN
329 union ecrnx_hw_txstatus status;
333 * struct ecrnx_hw_txhdr - Hardware part of tx header
335 * @cfm: Information updated by fw/hardware after sending a frame
337 struct ecrnx_hw_txhdr {
338 struct tx_cfm_tag cfm;
341 #endif /* CONFIG_ECRNX_SOFTMAC */
343 #define ECRNX_RX_HD_NX_DECR_UNENC 0 // Frame unencrypted
344 #define ECRNX_RX_HD_NX_DECR_ICVFAIL 1 // WEP/TKIP ICV failure
345 #define ECRNX_RX_HD_NX_DECR_CCMPFAIL 2 // CCMP failure
346 #define ECRNX_RX_HD_NX_DECR_AMSDUDISCARD 3 // A-MSDU discarded at HW
347 #define ECRNX_RX_HD_NX_DECR_NULLKEY 4 // NULL key found
348 #define ECRNX_RX_HD_NX_DECR_WEPSUCCESS 5 // Security type WEP
349 #define ECRNX_RX_HD_NX_DECR_TKIPSUCCESS 6 // Security type TKIP
350 #define ECRNX_RX_HD_NX_DECR_CCMPSUCCESS 7 // Security type CCMP (or WPI)
351 #define ECRNX_RX_HD_DECR_UNENC 0 // Frame unencrypted
352 #define ECRNX_RX_HD_DECR_WEP 1 // Security type WEP
353 #define ECRNX_RX_HD_DECR_TKIP 2 // Security type TKIP
354 #define ECRNX_RX_HD_DECR_CCMP128 3 // Security type CCMP (128 bits)
355 #define ECRNX_RX_HD_DECR_CCMP256 4 // Security type CCMP (256 bits)
356 #define ECRNX_RX_HD_DECR_GCMP128 5 // Security type GCMP (128 bits)
357 #define ECRNX_RX_HD_DECR_GCMP256 6 // Security type GCMP (256 bits)
358 #define ECRNX_RX_HD_DECR_WAPI 7 // Security type WAPI
359 #define ECRNX_RX_HD_DECR_NULLKEY 15 // NULL key found
360 struct rx_vector_1_nx {
364 u32 _ht_length : 4; // FIXME
379 u32 doze_not_allowed : 1;
390 struct rx_vector_2_nx {
396 u32 reserved2b_1 : 8;
397 u32 reserved2b_2 : 8;
398 u32 reserved2b_3 : 8;
400 struct mpdu_status_nx {
401 u32 rx_vect2_valid : 1;
404 u32 rx_fifo_oflow : 1;
408 u32 addr_mismatch : 1;
411 u32 frm_successful_rx : 1;
412 u32 desc_done_rx : 1;
413 u32 key_sram_index : 10;
414 u32 key_sram_valid : 1;
420 u8 dyn_bw_in_non_ht : 1;
421 u8 chn_bw_in_non_ht : 2;
445 u8 doze_not_allowed : 1;
472 u8 txop_duration : 7;
475 u8 spatial_reuse : 4;
476 u8 sig_b_comp_mode : 1;
497 struct rx_leg_vect leg;
498 struct rx_ht_vect ht;
499 struct rx_vht_vect vht;
500 struct rx_he_vect he;
514 u32 rx_vect2_valid : 1;
520 u32 addr_mismatch : 1;
523 u32 frm_successful_rx : 1;
524 u32 desc_done_rx : 1;
525 u32 key_sram_index : 10;
539 /** Receive Vector 1 */
540 struct rx_vector_1 rx_vect1;
541 /** Receive Vector 2 */
542 struct rx_vector_2 rx_vect2;
544 /** MPDU status information */
545 struct mpdu_status status;
548 struct phy_channel_info_desc {
549 /** PHY channel information 1 */
551 u32 phy_channel_type : 8;
552 u32 phy_prim20_freq : 16;
554 /** PHY channel information 2 */
555 u32 phy_center1_freq : 16;
556 u32 phy_center2_freq : 16;
559 int ecrnx_machw_type(uint32_t machw_version_2);
560 void ecrnx_rx_vector_convert(int machw_type, struct rx_vector_1 *rx_vect1,
561 struct rx_vector_2 *rx_vect2);
562 void ecrnx_rx_status_convert(int machw_type, struct mpdu_status *status);
564 /******************************************************************************
566 ******************************************************************************/
567 #define MDM_PHY_CONFIG_TRIDENT 0
568 #define MDM_PHY_CONFIG_CATAXIA 1
569 #define MDM_PHY_CONFIG_KARST 2
571 // MODEM features (from reg_mdm_stat.h)
572 /// MUMIMOTX field bit
573 #define MDM_MUMIMOTX_BIT ((u32)0x80000000)
574 /// MUMIMOTX field position
575 #define MDM_MUMIMOTX_POS 31
576 /// MUMIMORX field bit
577 #define MDM_MUMIMORX_BIT ((u32)0x40000000)
578 /// MUMIMORX field position
579 #define MDM_MUMIMORX_POS 30
581 #define MDM_BFMER_BIT ((u32)0x20000000)
582 /// BFMER field position
583 #define MDM_BFMER_POS 29
585 #define MDM_BFMEE_BIT ((u32)0x10000000)
586 /// BFMEE field position
587 #define MDM_BFMEE_POS 28
588 /// LDPCDEC field bit
589 #define MDM_LDPCDEC_BIT ((u32)0x08000000)
590 /// LDPCDEC field position
591 #define MDM_LDPCDEC_POS 27
592 /// LDPCENC field bit
593 #define MDM_LDPCENC_BIT ((u32)0x04000000)
594 /// LDPCENC field position
595 #define MDM_LDPCENC_POS 26
597 #define MDM_CHBW_MASK ((u32)0x03000000)
598 /// CHBW field LSB position
599 #define MDM_CHBW_LSB 24
601 #define MDM_CHBW_WIDTH ((u32)0x00000002)
602 /// DSSSCCK field bit
603 #define MDM_DSSSCCK_BIT ((u32)0x00800000)
604 /// DSSSCCK field position
605 #define MDM_DSSSCCK_POS 23
607 #define MDM_VHT_BIT ((u32)0x00400000)
608 /// VHT field position
609 #define MDM_VHT_POS 22
611 #define MDM_HE_BIT ((u32)0x00200000)
612 /// HE field position
613 #define MDM_HE_POS 21
615 #define MDM_ESS_BIT ((u32)0x00100000)
616 /// ESS field position
617 #define MDM_ESS_POS 20
618 /// RFMODE field mask
619 #define MDM_RFMODE_MASK ((u32)0x000F0000)
620 /// RFMODE field LSB position
621 #define MDM_RFMODE_LSB 16
622 /// RFMODE field width
623 #define MDM_RFMODE_WIDTH ((u32)0x00000004)
625 #define MDM_NSTS_MASK ((u32)0x0000F000)
626 /// NSTS field LSB position
627 #define MDM_NSTS_LSB 12
629 #define MDM_NSTS_WIDTH ((u32)0x00000004)
631 #define MDM_NSS_MASK ((u32)0x00000F00)
632 /// NSS field LSB position
633 #define MDM_NSS_LSB 8
635 #define MDM_NSS_WIDTH ((u32)0x00000004)
637 #define MDM_NTX_MASK ((u32)0x000000F0)
638 /// NTX field LSB position
639 #define MDM_NTX_LSB 4
641 #define MDM_NTX_WIDTH ((u32)0x00000004)
643 #define MDM_NRX_MASK ((u32)0x0000000F)
644 /// NRX field LSB position
645 #define MDM_NRX_LSB 0
647 #define MDM_NRX_WIDTH ((u32)0x00000004)
649 #define __MDM_PHYCFG_FROM_VERS(v) (((v) & MDM_RFMODE_MASK) >> MDM_RFMODE_LSB)
651 #define RIU_FCU_PRESENT_MASK ((u32)0xFF000000)
652 #define RIU_FCU_PRESENT_LSB 24
654 #define __RIU_FCU_PRESENT(v) (((v) & RIU_FCU_PRESENT_MASK) >> RIU_FCU_PRESENT_LSB == 5)
656 /// AGC load version field mask
657 #define RIU_AGC_LOAD_MASK ((u32)0x00C00000)
658 /// AGC load version field LSB position
659 #define RIU_AGC_LOAD_LSB 22
661 #define __RIU_AGCLOAD_FROM_VERS(v) (((v) & RIU_AGC_LOAD_MASK) >> RIU_AGC_LOAD_LSB)
663 #define __FPGA_TYPE(v) (((v) & 0xFFFF0000) >> 16)
665 #define __MDM_MAJOR_VERSION(v) (((v) & 0xFF000000) >> 24)
666 #define __MDM_MINOR_VERSION(v) (((v) & 0x00FF0000) >> 16)
667 #define __MDM_VERSION(v) ((__MDM_MAJOR_VERSION(v) + 2) * 10 + __MDM_MINOR_VERSION(v))
670 #endif // _HAL_DESC_H_