forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/bcmwifi_rates.h
....@@ -1,15 +1,16 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * Indices for 802.11 a/b/g/n/ac 1-3 chain symmetric transmit rates
43 *
5
- * Copyright (C) 1999-2019, Broadcom Corporation
6
- *
4
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
5
+ *
6
+ * Copyright (C) 1999-2017, Broadcom Corporation
7
+ *
78 * Unless you and Broadcom execute a separate written software license
89 * agreement governing use of this software, this software is licensed to you
910 * under the terms of the GNU General Public License version 2 (the "GPL"),
1011 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
1112 * following added to such license:
12
- *
13
+ *
1314 * As a special exception, the copyright holders of this software give you
1415 * permission to link this software with independent modules, and to copy and
1516 * distribute the resulting executable under terms of your choice, provided that
....@@ -17,7 +18,7 @@
1718 * the license of that module. An independent module is a module which is not
1819 * derived from this software. The special exception does not apply to any
1920 * modifications of the software.
20
- *
21
+ *
2122 * Notwithstanding the above, under no circumstances may you combine this
2223 * software in any way with any other Broadcom software provided under a license
2324 * other than the GPL, without Broadcom's express prior written consent.
....@@ -25,27 +26,25 @@
2526 *
2627 * <<Broadcom-WL-IPTag/Open:>>
2728 *
28
- * $Id: bcmwifi_rates.h 5187 2012-06-29 06:17:50Z $
29
+ * $Id: bcmwifi_rates.h 697006 2017-05-01 19:13:40Z $
2930 */
3031
3132 #ifndef _bcmwifi_rates_h_
3233 #define _bcmwifi_rates_h_
3334
35
+#include <typedefs.h>
36
+
3437 #ifdef __cplusplus
3538 extern "C" {
3639 #endif /* __cplusplus */
3740
38
-
3941 #define WL_RATESET_SZ_DSSS 4
4042 #define WL_RATESET_SZ_OFDM 8
41
-#define WL_RATESET_SZ_VHT_MCS 10
42
-#define WL_RATESET_SZ_VHT_MCS_P 12
43
+#define WL_RATESET_SZ_VHT_MCS 10
44
+#define WL_RATESET_SZ_VHT_MCS_P 12 /* 10 VHT rates + 2 proprietary rates */
45
+#define WL_RATESET_SZ_HE_MCS 12 /* 12 HE rates (mcs 0-11) */
4346
44
-#if defined(WLPROPRIETARY_11N_RATES)
45
-#define WL_RATESET_SZ_HT_MCS WL_RATESET_SZ_VHT_MCS
46
-#else
4747 #define WL_RATESET_SZ_HT_MCS 8
48
-#endif
4948
5049 #define WL_RATESET_SZ_HT_IOCTL 8 /* MAC histogram, compatibility with wl utility */
5150
....@@ -76,7 +75,6 @@
7675 WL_TX_BW_10
7776 } wl_tx_bw_t;
7877
79
-
8078 /*
8179 * Transmit modes.
8280 * Not all modes are listed here, only those required for disambiguation. e.g. SPEXP is not listed
....@@ -89,7 +87,6 @@
8987 WL_NUM_TX_MODES
9088 } wl_tx_mode_t;
9189
92
-
9390 /* Number of transmit chains */
9491 typedef enum wl_tx_chains {
9592 WL_TX_CHAINS_1 = 1,
....@@ -97,7 +94,6 @@
9794 WL_TX_CHAINS_3,
9895 WL_TX_CHAINS_4
9996 } wl_tx_chains_t;
100
-
10197
10298 /* Number of transmit streams */
10399 typedef enum wl_tx_nss {
....@@ -107,147 +103,9 @@
107103 WL_TX_NSS_4
108104 } wl_tx_nss_t;
109105
110
-
111106 /* This enum maps each rate to a CLM index */
112107
113108 typedef enum clm_rates {
114
-#ifdef WL_OLDPPR
115
- /************
116
- * 1 chain *
117
- ************
118
- */
119
-
120
- CLM_RATE_1X1_DSSS_1 = 0,
121
- CLM_RATE_1X1_DSSS_2 = 1,
122
- CLM_RATE_1X1_DSSS_5_5 = 2,
123
- CLM_RATE_1X1_DSSS_11 = 3,
124
-
125
- CLM_RATE_1X1_OFDM_6 = 4,
126
- CLM_RATE_1X1_OFDM_9 = 5,
127
- CLM_RATE_1X1_OFDM_12 = 6,
128
- CLM_RATE_1X1_OFDM_18 = 7,
129
- CLM_RATE_1X1_OFDM_24 = 8,
130
- CLM_RATE_1X1_OFDM_36 = 9,
131
- CLM_RATE_1X1_OFDM_48 = 10,
132
- CLM_RATE_1X1_OFDM_54 = 11,
133
-
134
- CLM_RATE_1X1_MCS0 = 12,
135
- CLM_RATE_1X1_MCS1 = 13,
136
- CLM_RATE_1X1_MCS2 = 14,
137
- CLM_RATE_1X1_MCS3 = 15,
138
- CLM_RATE_1X1_MCS4 = 16,
139
- CLM_RATE_1X1_MCS5 = 17,
140
- CLM_RATE_1X1_MCS6 = 18,
141
- CLM_RATE_1X1_MCS7 = 19,
142
-
143
- /************
144
- * 2 chains *
145
- ************
146
- */
147
-
148
- /* 1 Stream expanded + 1 */
149
- CLM_RATE_1X2_DSSS_1 = 20,
150
- CLM_RATE_1X2_DSSS_2 = 21,
151
- CLM_RATE_1X2_DSSS_5_5 = 22,
152
- CLM_RATE_1X2_DSSS_11 = 23,
153
-
154
- CLM_RATE_1X2_CDD_OFDM_6 = 24,
155
- CLM_RATE_1X2_CDD_OFDM_9 = 25,
156
- CLM_RATE_1X2_CDD_OFDM_12 = 26,
157
- CLM_RATE_1X2_CDD_OFDM_18 = 27,
158
- CLM_RATE_1X2_CDD_OFDM_24 = 28,
159
- CLM_RATE_1X2_CDD_OFDM_36 = 29,
160
- CLM_RATE_1X2_CDD_OFDM_48 = 30,
161
- CLM_RATE_1X2_CDD_OFDM_54 = 31,
162
-
163
- CLM_RATE_1X2_CDD_MCS0 = 32,
164
- CLM_RATE_1X2_CDD_MCS1 = 33,
165
- CLM_RATE_1X2_CDD_MCS2 = 34,
166
- CLM_RATE_1X2_CDD_MCS3 = 35,
167
- CLM_RATE_1X2_CDD_MCS4 = 36,
168
- CLM_RATE_1X2_CDD_MCS5 = 37,
169
- CLM_RATE_1X2_CDD_MCS6 = 38,
170
- CLM_RATE_1X2_CDD_MCS7 = 39,
171
-
172
- /* 2 Streams */
173
- CLM_RATE_2X2_STBC_MCS0 = 40,
174
- CLM_RATE_2X2_STBC_MCS1 = 41,
175
- CLM_RATE_2X2_STBC_MCS2 = 42,
176
- CLM_RATE_2X2_STBC_MCS3 = 43,
177
- CLM_RATE_2X2_STBC_MCS4 = 44,
178
- CLM_RATE_2X2_STBC_MCS5 = 45,
179
- CLM_RATE_2X2_STBC_MCS6 = 46,
180
- CLM_RATE_2X2_STBC_MCS7 = 47,
181
-
182
- CLM_RATE_2X2_SDM_MCS8 = 48,
183
- CLM_RATE_2X2_SDM_MCS9 = 49,
184
- CLM_RATE_2X2_SDM_MCS10 = 50,
185
- CLM_RATE_2X2_SDM_MCS11 = 51,
186
- CLM_RATE_2X2_SDM_MCS12 = 52,
187
- CLM_RATE_2X2_SDM_MCS13 = 53,
188
- CLM_RATE_2X2_SDM_MCS14 = 54,
189
- CLM_RATE_2X2_SDM_MCS15 = 55,
190
-
191
-
192
- /************
193
- * 3 chains *
194
- ************
195
- */
196
-
197
- /* 1 Stream expanded + 2 */
198
- CLM_RATE_1X3_DSSS_1 = 56,
199
- CLM_RATE_1X3_DSSS_2 = 57,
200
- CLM_RATE_1X3_DSSS_5_5 = 58,
201
- CLM_RATE_1X3_DSSS_11 = 59,
202
-
203
- CLM_RATE_1X3_CDD_OFDM_6 = 60,
204
- CLM_RATE_1X3_CDD_OFDM_9 = 61,
205
- CLM_RATE_1X3_CDD_OFDM_12 = 62,
206
- CLM_RATE_1X3_CDD_OFDM_18 = 63,
207
- CLM_RATE_1X3_CDD_OFDM_24 = 64,
208
- CLM_RATE_1X3_CDD_OFDM_36 = 65,
209
- CLM_RATE_1X3_CDD_OFDM_48 = 66,
210
- CLM_RATE_1X3_CDD_OFDM_54 = 67,
211
-
212
- CLM_RATE_1X3_CDD_MCS0 = 68,
213
- CLM_RATE_1X3_CDD_MCS1 = 69,
214
- CLM_RATE_1X3_CDD_MCS2 = 70,
215
- CLM_RATE_1X3_CDD_MCS3 = 71,
216
- CLM_RATE_1X3_CDD_MCS4 = 72,
217
- CLM_RATE_1X3_CDD_MCS5 = 73,
218
- CLM_RATE_1X3_CDD_MCS6 = 74,
219
- CLM_RATE_1X3_CDD_MCS7 = 75,
220
-
221
- /* 2 Streams expanded + 1 */
222
- CLM_RATE_2X3_STBC_MCS0 = 76,
223
- CLM_RATE_2X3_STBC_MCS1 = 77,
224
- CLM_RATE_2X3_STBC_MCS2 = 78,
225
- CLM_RATE_2X3_STBC_MCS3 = 79,
226
- CLM_RATE_2X3_STBC_MCS4 = 80,
227
- CLM_RATE_2X3_STBC_MCS5 = 81,
228
- CLM_RATE_2X3_STBC_MCS6 = 82,
229
- CLM_RATE_2X3_STBC_MCS7 = 83,
230
-
231
- CLM_RATE_2X3_SDM_MCS8 = 84,
232
- CLM_RATE_2X3_SDM_MCS9 = 85,
233
- CLM_RATE_2X3_SDM_MCS10 = 86,
234
- CLM_RATE_2X3_SDM_MCS11 = 87,
235
- CLM_RATE_2X3_SDM_MCS12 = 88,
236
- CLM_RATE_2X3_SDM_MCS13 = 89,
237
- CLM_RATE_2X3_SDM_MCS14 = 90,
238
- CLM_RATE_2X3_SDM_MCS15 = 91,
239
-
240
- /* 3 Streams */
241
- CLM_RATE_3X3_SDM_MCS16 = 92,
242
- CLM_RATE_3X3_SDM_MCS17 = 93,
243
- CLM_RATE_3X3_SDM_MCS18 = 94,
244
- CLM_RATE_3X3_SDM_MCS19 = 95,
245
- CLM_RATE_3X3_SDM_MCS20 = 96,
246
- CLM_RATE_3X3_SDM_MCS21 = 97,
247
- CLM_RATE_3X3_SDM_MCS22 = 98,
248
- CLM_RATE_3X3_SDM_MCS23 = 99,
249
-#endif /* WL_OLDPPR */
250
-
251109 /************
252110 * 1 chain *
253111 ************
....@@ -291,7 +149,6 @@
291149 WL_RATE_1X1_VHT9SS1 = 21,
292150 WL_RATE_P_1X1_VHT10SS1 = 22,
293151 WL_RATE_P_1X1_VHT11SS1 = 23,
294
-
295152
296153 /************
297154 * 2 chains *
....@@ -450,7 +307,6 @@
450307 WL_RATE_P_2X2_TXBF_VHT10SS2 = 102,
451308 WL_RATE_P_2X2_TXBF_VHT11SS2 = 103,
452309
453
-
454310 /************
455311 * 3 chains *
456312 ************
....@@ -569,7 +425,6 @@
569425 WL_RATE_P_3X3_VHT10SS3 = 162,
570426 WL_RATE_P_3X3_VHT11SS3 = 163,
571427
572
-
573428 /****************************
574429 * TX Beamforming, 3 chains *
575430 ****************************
....@@ -658,7 +513,6 @@
658513 WL_RATE_3X3_TXBF_VHT9SS3 = 205,
659514 WL_RATE_P_3X3_TXBF_VHT10SS3 = 206,
660515 WL_RATE_P_3X3_TXBF_VHT11SS3 = 207,
661
-
662516
663517 /************
664518 * 4 chains *
....@@ -778,7 +632,6 @@
778632 WL_RATE_P_3X4_VHT10SS3 = 266,
779633 WL_RATE_P_3X4_VHT11SS3 = 267,
780634
781
-
782635 /* 4 Streams */
783636 WL_RATE_4X4_SDM_MCS24 = 268,
784637 WL_RATE_4X4_SDM_MCS25 = 269,
....@@ -803,7 +656,6 @@
803656 WL_RATE_4X4_VHT9SS4 = 277,
804657 WL_RATE_P_4X4_VHT10SS4 = 278,
805658 WL_RATE_P_4X4_VHT11SS4 = 279,
806
-
807659
808660 /****************************
809661 * TX Beamforming, 4 chains *
....@@ -924,6 +776,56 @@
924776 /* Number of rate codes */
925777 #define WL_NUMRATES 336
926778
779
+/* MCS rates */
780
+#define WLC_MAX_VHT_MCS 11 /**< Std VHT MCS 0-9 plus prop VHT MCS 10-11 */
781
+#define WLC_MAX_HE_MCS 11 /**< Std HE MCS 0-11 */
782
+
783
+/* Convert encoded rate value in plcp header to numerical rates in 500 KHz increments */
784
+#define OFDM_PHY2MAC_RATE(rlpt) plcp_ofdm_rate_tbl[(rlpt) & 0x7]
785
+#define CCK_PHY2MAC_RATE(signal) ((signal)/5)
786
+
787
+/* given a proprietary MCS, get number of spatial streams */
788
+#define GET_PROPRIETARY_11N_MCS_NSS(mcs) (1 + ((mcs) - 85) / 8)
789
+
790
+#define GET_11N_MCS_NSS(mcs) ((mcs) < 32 ? (1 + ((mcs) / 8)) : \
791
+ ((mcs) == 32 ? 1 : GET_PROPRIETARY_11N_MCS_NSS(mcs)))
792
+
793
+#define IS_PROPRIETARY_11N_MCS(mcs) FALSE
794
+#define IS_PROPRIETARY_11N_SS_MCS(mcs) FALSE /**< is proprietary HT single stream MCS */
795
+
796
+/* Store HE mcs map for all NSS in a compact form:
797
+ *
798
+ * bit[0:2] mcs code for NSS 1
799
+ * bit[3:5] mcs code for NSS 2
800
+ * ...
801
+ * bit[21:23] mcs code for NSS 8
802
+ */
803
+
804
+/**
805
+ * 3 bits are used for encoding each NSS mcs map (HE MCS MAP is 24 bits)
806
+ */
807
+#define HE_CAP_MCS_CODE_NONE 7
808
+
809
+/* macros to access above compact format */
810
+#define HE_CAP_MCS_NSS_SET_MASK 0x00ffffff /* Field is to be 24 bits long */
811
+#define HE_CAP_MCS_NSS_GET_SS_IDX(nss) (((nss)-1) * HE_CAP_MCS_CODE_SIZE)
812
+#define HE_CAP_MCS_NSS_GET_MCS(nss, mcs_nss_map) \
813
+ (((mcs_nss_map) >> HE_CAP_MCS_NSS_GET_SS_IDX(nss)) & HE_CAP_MCS_CODE_MASK)
814
+#define HE_CAP_MCS_NSS_SET_MCS(nss, mcs_code, mcs_nss_map) \
815
+ do { \
816
+ (mcs_nss_map) &= (~(HE_CAP_MCS_CODE_MASK << HE_CAP_MCS_NSS_GET_SS_IDX(nss))); \
817
+ (mcs_nss_map) |= (((mcs_code) & HE_CAP_MCS_CODE_MASK) << HE_CAP_MCS_NSS_GET_SS_IDX(nss)); \
818
+ (mcs_nss_map) &= (HE_CAP_MCS_NSS_SET_MASK); \
819
+ } while (0)
820
+
821
+extern const uint8 plcp_ofdm_rate_tbl[];
822
+
823
+uint8 wf_get_single_stream_mcs(uint mcs);
824
+
825
+uint8 wf_vht_plcp_to_rate(uint8 *plcp);
826
+uint wf_mcs_to_rate(uint mcs, uint nss, uint bw, int sgi);
827
+uint wf_he_mcs_to_rate(uint mcs, uint nss, uint bw, uint gi, bool dcm);
828
+uint wf_mcs_to_Ndbps(uint mcs, uint nss, uint bw);
927829 #ifdef __cplusplus
928830 }
929831 #endif /* __cplusplus */