hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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
188
189
190
191
192
193
194
195
196
197
198
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
237
238
239
240
241
242
243
244
245
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
298
299
300
301
302
303
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
/*
 * Common [OS-independent] rate management
 * 802.11 Networking Adapter Device Driver.
 *
 * Broadcom Proprietary and Confidential. Copyright (C) 2020,
 * All Rights Reserved.
 *
 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom;
 * the contents of this file may not be disclosed to third parties,
 * copied or duplicated in any form, in whole or in part, without
 * the prior written permission of Broadcom.
 *
 *
 * <<Broadcom-WL-IPTag/Proprietary:>>
 */
 
#include <typedefs.h>
#ifdef BCMDRIVER
#include <osl.h>
#else
#include <assert.h>
#ifndef ASSERT
#define ASSERT(e)    assert(e)
#endif
#ifndef ASSERT_FP
#define ASSERT_FP(e)    assert(e)
#endif
#endif /* BCMDRIVER */
#include <802.11.h>
#include <802.11ax.h>
#include <bcmutils.h>
 
#include <bcmwifi_rspec.h>
#include <bcmwifi_rates.h>
 
/* TODO: Consolidate rate utility functions from wlc_rate.c and bcmwifi_monitor.c
 * into here if they're shared by non wl layer as well...
 */
 
/* ============================================ */
/* Moved from wlc_rate.c                        */
/* ============================================ */
 
/* HE mcs info */
struct ieee_80211_mcs_rate_info {
   uint8 constellation_bits;
   uint8 coding_q;
   uint8 coding_d;
   uint8 dcm_capable;    /* 1 if dcm capable */
};
 
static const struct ieee_80211_mcs_rate_info wlc_mcs_info[] = {
   { 1, 1, 2, 1 }, /* MCS  0: MOD: BPSK,   CR 1/2, dcm capable */
   { 2, 1, 2, 1 }, /* MCS  1: MOD: QPSK,   CR 1/2, dcm capable */
   { 2, 3, 4, 0 }, /* MCS  2: MOD: QPSK,   CR 3/4, NOT dcm capable */
   { 4, 1, 2, 1 }, /* MCS  3: MOD: 16QAM,  CR 1/2, dcm capable */
   { 4, 3, 4, 1 }, /* MCS  4: MOD: 16QAM,  CR 3/4, dcm capable */
   { 6, 2, 3, 0 }, /* MCS  5: MOD: 64QAM,  CR 2/3, NOT dcm capable */
   { 6, 3, 4, 0 }, /* MCS  6: MOD: 64QAM,  CR 3/4, NOT dcm capable */
   { 6, 5, 6, 0 }, /* MCS  7: MOD: 64QAM,  CR 5/6, NOT dcm capable */
   { 8, 3, 4, 0 }, /* MCS  8: MOD: 256QAM, CR 3/4, NOT dcm capable */
   { 8, 5, 6, 0 }, /* MCS  9: MOD: 256QAM, CR 5/6, NOT dcm capable */
   { 10, 3, 4, 0 }, /* MCS 10: MOD: 1024QAM, CR 3/4, NOT dcm capable */
   { 10, 5, 6, 0 }, /* MCS 11: MOD: 1024QAM, CR 5/6, NOT dcm capable */
#ifdef WL11BE
   /* TODO: for now EHT shares this table with HE,
    * create a new table if needed once we know more
    * about EHT rate calculation...
    */
   { 12, 3, 4, 0 }, /* MCS 12: MOD: 4096QAM, CR 3/4, NOT dcm capable */
   { 12, 5, 6, 0 }, /* MCS 13: MOD: 4096QAM, CR 5/6, NOT dcm capable */
#endif
};
 
/* Nsd values Draft0.4 Table 26.63 onwards */
static const uint wlc_he_nsd[] = {
   234,    /* BW20 */
   468,    /* BW40 */
   980,    /* BW80 */
   1960,    /* BW160 */
#ifdef WL11BE
   /* TODO: for now EHT shares this table with HE,
    * create a new table if needed once we know more
    * about EHT rate calculation...
    */
   2940,    /* BW240 */
   3920    /* BW320 */
#endif
};
 
/* Nsd values Draft3.3 Table 28-15 */
static const uint wlc_he_ru_nsd[] = {
   24,    /* 26T */
   48,    /* 52T */
   102,    /* 106T */
   234,    /* 242T/BW20 */
   468,    /* 484T/BW40 */
   980,    /* 996T/BW80 */
   1960,    /* 2*996T/BW160 */
#ifdef WL11BE
   /* TODO: for now EHT shares this table with HE,
    * create a new table if needed once we know more
    * about EHT rate calculation...
    */
   2940,    /* 3*996T/BW240 */
   3920    /* 4*996T/BW320 */
#endif
};
 
#define HE_RU_TO_NSD(ru_idx)    \
   (ru_idx < ARRAYSIZE(wlc_he_ru_nsd)) ? \
   wlc_he_ru_nsd[ru_idx] : 0
 
/* sym_len = 12.8 us. For calculation purpose, *10 */
#define HE_SYM_LEN_FACTOR        (128)
 
/* GI values = 0.8 , 1.6 or 3.2 us. For calculation purpose, *10 */
#define HE_GI_800us_FACTOR        (8)
#define HE_GI_1600us_FACTOR        (16)
#define HE_GI_3200us_FACTOR        (32)
 
/* To avoid ROM invalidation use the old macro as is... */
#ifdef WL11BE
#define HE_BW_TO_NSD(bwi) \
   ((bwi) > 0u && (bwi) <= ARRAYSIZE(wlc_he_nsd)) ? \
   wlc_he_nsd[(bwi) - 1u] : 0u
#else
#define HE_BW_TO_NSD(bwi) \
   ((bwi) > 0 && ((bwi) << WL_RSPEC_BW_SHIFT) <= WL_RSPEC_BW_160MHZ) ? \
   wlc_he_nsd[(bwi)-1] : 0
#endif /* WL11BE */
 
#define ksps        250 /* kilo symbols per sec, 4 us sym */
 
#ifdef WL11BE
/* Table "wlc_nsd" is derived from HT and VHT #defines below, but extended for HE
 * for rate calculation purpose at a given NSS and bandwidth combination.
 *
 * It should and can only be used in where it wants to know the relative rate in kbps
 * for a different NSS and bandwidth combination at a given mcs e.g. in fallback rate
 * search. It shouldn not and can not be used in where it calculates the absolute rate
 * i.e. the result doesn't agree with what the spec says otherwise.
 *
 * See Std 802.11-2016 "Table 21-61 VHT-MCSs for optional 160 MHz and 80+80 MHz, NSS = 8"
 * for VHT, and P802.11ax/D6.0 "Table 27-111 HE-MCSs for 2x996-tone RU, NSS = 8" for HE,
 * for 160Mhz bandwidth for resulting rate comparison.
 *
 * It's again extended for EHT 240/320Mhz bandwidth, for the same purpose.
 */
static const uint16 wlc_nsd[] = {
   52,    /* 20MHz */
   108,    /* 40MHz */
   234,    /* 80Mhz */
   468,    /* 160MHz */
   702,    /* 240MHz */
   936,    /* 320MHz */
};
 
#define BW_TO_NSD(bwi) \
   ((bwi) > 0u && (bwi) <= ARRAYSIZE(wlc_nsd)) ? \
   wlc_nsd[(bwi) - 1u] : 0u
 
static uint
wf_nsd2ndbps(uint mcs, uint nss, uint nsd, bool dcm)
{
   uint Ndbps;
 
   /* multiply number of spatial streams,
    * bits per number from the constellation,
    * and coding quotient
    */
   Ndbps = nsd * nss *
       wlc_mcs_info[mcs].coding_q * wlc_mcs_info[mcs].constellation_bits;
 
   /* adjust for the coding rate divisor */
   Ndbps = Ndbps / wlc_mcs_info[mcs].coding_d;
 
   /* take care of dcm: dcm divides R by 2. If not dcm mcs, ignore */
   if (dcm) {
       if (wlc_mcs_info[mcs].dcm_capable) {
           Ndbps >>= 1u;
       }
   }
 
   return Ndbps;
}
#else
/* for HT and VHT? */
#define Nsd_20MHz    52
#define Nsd_40MHz    108
#define Nsd_80MHz    234
#define Nsd_160MHz    468
#endif /* WL11BE */
 
uint
wf_he_mcs_to_Ndbps(uint mcs, uint nss, uint bw, bool dcm)
{
   uint Nsd;
   uint Ndbps;
 
   /* find the number of complex numbers per symbol */
   Nsd = HE_BW_TO_NSD(bw >> WL_RSPEC_BW_SHIFT);
 
#ifdef WL11BE
   Ndbps = wf_nsd2ndbps(mcs, nss, Nsd, dcm);
#else
   /* multiply number of spatial streams,
    * bits per number from the constellation,
    * and coding quotient
    */
   Ndbps = Nsd * nss *
       wlc_mcs_info[mcs].coding_q * wlc_mcs_info[mcs].constellation_bits;
 
   /* adjust for the coding rate divisor */
   Ndbps = Ndbps / wlc_mcs_info[mcs].coding_d;
 
   /* take care of dcm: dcm divides R by 2. If not dcm mcs, ignore */
   if (dcm) {
       if (wlc_mcs_info[mcs].dcm_capable) {
           Ndbps >>= 1;
       }
   }
#endif /* WL11BE */
 
   return Ndbps;
}
 
uint32
wf_he_mcs_ru_to_ndbps(uint8 mcs, uint8 nss, bool dcm, uint8 ru_index)
{
   uint32 nsd;
   uint32 ndbps;
 
   /* find the number of complex numbers per symbol */
   nsd = HE_RU_TO_NSD(ru_index);
 
#ifdef WL11BE
   ndbps = wf_nsd2ndbps(mcs, nss, nsd, dcm);
#else
   /* multiply number of spatial streams,
    * bits per number from the constellation,
    * and coding quotient
    * Ndbps = Nss x Nsd x (Nbpscs x R) x (DCM/2)
    */
   ndbps = nsd * nss *
       wlc_mcs_info[mcs].coding_q * wlc_mcs_info[mcs].constellation_bits;
 
   /* adjust for the coding rate divisor */
   ndbps = ndbps / wlc_mcs_info[mcs].coding_d;
 
   /* take care of dcm: dcm divides R by 2. If not dcm mcs, ignore */
   if (dcm && wlc_mcs_info[mcs].dcm_capable) {
       ndbps >>= 1;
   }
#endif /* WL11BE */
   return ndbps;
}
 
/**
 * Returns the rate in [Kbps] units for a caller supplied MCS/bandwidth/Nss/Sgi/dcm combination.
 *     'mcs' : a *single* spatial stream MCS (11ax)
 * formula as per http:
 *    WLAN&preview=/323036249/344457953/11ax_rate_table.xlsx
 * Symbol length = 12.8 usec [given as sym_len/10 below]
 * GI value = 0.8 or 1.6 or 3.2 usec [given as GI_value/10 below]
 * rate (Kbps) = (Nsd * Nbpscs * nss * (coding_q/coding_d) * 1000) / ((sym_len/10) + (GI_value/10))
 *     Note that, for calculation purpose, following is used. [to be careful with overflows]
 * rate (Kbps) = (Nsd * Nbpscs * nss * (coding_q/coding_d) * 1000) / ((sym_len + GI_value) / 10)
 * rate (Kbps) = (Nsd * Nbpscs * nss * (coding_q/coding_d) * 1000) / (sym_len + GI_value) * 10
 */
uint
wf_he_mcs_to_rate(uint mcs, uint nss, uint bw, uint gi, bool dcm)
{
   uint rate;
   uint rate_deno;
 
   rate = HE_BW_TO_NSD(bw >> WL_RSPEC_BW_SHIFT);
 
#ifdef WL11BE
   rate = wf_nsd2ndbps(mcs, nss, rate, dcm);
#else
   /* Nbpscs: multiply by bits per number from the constellation in use */
   rate = rate * wlc_mcs_info[mcs].constellation_bits;
 
   /* Nss: adjust for the number of spatial streams */
   rate = rate * nss;
 
   /* R: adjust for the coding rate given as a quotient and divisor */
   rate = (rate * wlc_mcs_info[mcs].coding_q) / wlc_mcs_info[mcs].coding_d;
 
   /* take care of dcm: dcm divides R by 2. If not dcm mcs, ignore */
   if (dcm) {
       if (wlc_mcs_info[mcs].dcm_capable) {
           rate >>= 1;
       }
   }
#endif /* WL11BE */
 
   /* add sym len factor */
   rate_deno = HE_SYM_LEN_FACTOR;
 
   /* get GI for denominator */
   if (HE_IS_GI_3_2us(gi)) {
       rate_deno += HE_GI_3200us_FACTOR;
   } else if (HE_IS_GI_1_6us(gi)) {
       rate_deno += HE_GI_1600us_FACTOR;
   } else {
       /* assuming HE_GI_0_8us */
       rate_deno += HE_GI_800us_FACTOR;
   }
 
   /* as per above formula */
   rate *= 1000;    /* factor of 10. *100 to accommodate 2 places */
   rate /= rate_deno;
   rate *= 10; /* *100 was already done above. Splitting is done to avoid overflow. */
 
   return rate;
}
 
uint
wf_mcs_to_Ndbps(uint mcs, uint nss, uint bw)
{
   uint Nsd;
   uint Ndbps;
 
   /* This calculation works for 11n HT and 11ac VHT if the HT mcs values
    * are decomposed into a base MCS = MCS % 8, and Nss = 1 + MCS / 8.
    * That is, HT MCS 23 is a base MCS = 7, Nss = 3
    */
 
   /* find the number of complex numbers per symbol */
#ifdef WL11BE
   Nsd = BW_TO_NSD(bw >> WL_RSPEC_BW_SHIFT);
 
   Ndbps = wf_nsd2ndbps(mcs, nss, Nsd, FALSE);
#else
   if (bw == WL_RSPEC_BW_20MHZ) {
       Nsd = Nsd_20MHz;
   } else if (bw == WL_RSPEC_BW_40MHZ) {
       Nsd = Nsd_40MHz;
   } else if (bw == WL_RSPEC_BW_80MHZ) {
       Nsd = Nsd_80MHz;
   } else if (bw == WL_RSPEC_BW_160MHZ) {
       Nsd = Nsd_160MHz;
   } else {
       Nsd = 0;
   }
 
   /* multiply number of spatial streams,
    * bits per number from the constellation,
    * and coding quotient
    */
   Ndbps = Nsd * nss *
       wlc_mcs_info[mcs].coding_q * wlc_mcs_info[mcs].constellation_bits;
 
   /* adjust for the coding rate divisor */
   Ndbps = Ndbps / wlc_mcs_info[mcs].coding_d;
#endif /* WL11BE */
 
   return Ndbps;
}
 
/**
 * Returns the rate in [Kbps] units for a caller supplied MCS/bandwidth/Nss/Sgi combination.
 *     'mcs' : a *single* spatial stream MCS (11n or 11ac)
 */
uint
wf_mcs_to_rate(uint mcs, uint nss, uint bw, int sgi)
{
   uint rate;
 
   if (mcs == 32) {
       /* just return fixed values for mcs32 instead of trying to parametrize */
       rate = (sgi == 0) ? 6000 : 6778;
   } else {
       /* This calculation works for 11n HT, 11ac VHT and 11ax HE if the HT mcs values
        * are decomposed into a base MCS = MCS % 8, and Nss = 1 + MCS / 8.
        * That is, HT MCS 23 is a base MCS = 7, Nss = 3
        */
 
#if defined(WLPROPRIETARY_11N_RATES)
       switch (mcs) {
       case 87:
           mcs = 8; /* MCS  8: MOD: 256QAM, CR 3/4 */
           break;
       case 88:
           mcs = 9; /* MCS  9: MOD: 256QAM, CR 5/6 */
           break;
       default:
           break;
       }
#endif /* WLPROPRIETARY_11N_RATES */
 
#ifdef WL11BE
       rate = wf_mcs_to_Ndbps(mcs, nss, bw);
#else
       /* find the number of complex numbers per symbol */
       if (RSPEC_IS20MHZ(bw)) {
           /* 4360 TODO: eliminate Phy const in rspec bw, then just compare
            * as in 80 and 160 case below instead of RSPEC_IS20MHZ(bw)
            */
           rate = Nsd_20MHz;
       } else if (RSPEC_IS40MHZ(bw)) {
           /* 4360 TODO: eliminate Phy const in rspec bw, then just compare
            * as in 80 and 160 case below instead of RSPEC_IS40MHZ(bw)
            */
           rate = Nsd_40MHz;
       } else if (bw == WL_RSPEC_BW_80MHZ) {
           rate = Nsd_80MHz;
       } else if (bw == WL_RSPEC_BW_160MHZ) {
           rate = Nsd_160MHz;
       } else {
           rate = 0;
       }
 
       /* multiply by bits per number from the constellation in use */
       rate = rate * wlc_mcs_info[mcs].constellation_bits;
 
       /* adjust for the number of spatial streams */
       rate = rate * nss;
 
       /* adjust for the coding rate given as a quotient and divisor */
       rate = (rate * wlc_mcs_info[mcs].coding_q) / wlc_mcs_info[mcs].coding_d;
#endif /* WL11BE */
 
       /* multiply by Kilo symbols per sec to get Kbps */
       rate = rate * ksps;
 
       /* adjust the symbols per sec for SGI
        * symbol duration is 4 us without SGI, and 3.6 us with SGI,
        * so ratio is 10 / 9
        */
       if (sgi) {
           /* add 4 for rounding of division by 9 */
           rate = ((rate * 10) + 4) / 9;
       }
   }
 
   return rate;
} /* wf_mcs_to_rate */
 
/* This function needs update to handle MU frame PLCP as well (MCS is conveyed via VHT-SIGB
 * field in case of MU frames). Currently this support needs to be added in uCode to communicate
 * MCS information for an MU frame
 *
 *    For VHT frame:
 *        bit 0-3 mcs index
 *        bit 6-4 nsts for VHT
 *        bit 7:     1 for VHT
 *    Note: bit 7 is used to indicate to the rate sel the mcs is a non HT mcs!
 *
 * Essentially it's the NSS:MCS portions of the rspec
 */
uint8
wf_vht_plcp_to_rate(uint8 *plcp)
{
   uint8 rate, gid;
   uint nss;
   uint32 plcp0 = plcp[0] + (plcp[1] << 8); /* don't need plcp[2] */
 
   gid = (plcp0 & VHT_SIGA1_GID_MASK) >> VHT_SIGA1_GID_SHIFT;
   if (gid > VHT_SIGA1_GID_TO_AP && gid < VHT_SIGA1_GID_NOT_TO_AP) {
       /* for MU packet we hacked Signal Tail field in VHT-SIG-A2 to save nss and mcs,
        * copy from murate in d11 rx header.
        * nss = bit 18:19 (for 11ac 2 bits to indicate maximum 4 nss)
        * mcs = 20:23
        */
       rate = (plcp[5] & 0xF0) >> 4;
       nss = ((plcp[5] & 0x0C) >> 2) + 1;
   } else {
       rate = (plcp[3] >> VHT_SIGA2_MCS_SHIFT);
       nss = ((plcp0 & VHT_SIGA1_NSTS_SHIFT_MASK_USER0) >>
           VHT_SIGA1_NSTS_SHIFT) + 1;
       if (plcp0 & VHT_SIGA1_STBC)
           nss = nss >> 1;
   }
   rate |= ((nss << WL_RSPEC_VHT_NSS_SHIFT) | WF_NON_HT_MCS);
 
   return rate;
}
 
/**
 * Function for computing NSS:MCS from HE SU PLCP or
 * MCS:LTF-GI from HE MU PLCP
 *
 * based on rev3.10 :
 * https://docs.google.com/spreadsheets/d/
 * 1eP6ZCRrtnF924ds1R-XmbcH0IdQ0WNJpS1-FHmWeb9g/edit#gid=1492656555
 *
 *    For HE SU frame:
 *        bit 0-3 mcs index
 *        bit 6-4 nsts for HE
 *        bit 7:     1 for HE
 *    Note: bit 7 is used to indicate to the rate sel the mcs is a non HT mcs!
 *    Essentially it's the NSS:MCS portions of the rspec
 *
 *    For HE MU frame:
 *        bit 0-3 mcs index
 *        bit 4-5 LTF-GI value
 *        bit 6 STBC
 *    Essentially it's the MCS and LTF-GI portion of the rspec
 */
/* Macros to be used for calculating rate from PLCP */
#define HE_SU_PLCP2RATE_MCS_MASK    0x0F
#define HE_SU_PLCP2RATE_MCS_SHIFT    0
#define HE_SU_PLCP2RATE_NSS_MASK    0x70
#define HE_SU_PLCP2RATE_NSS_SHIFT    4
#define HE_MU_PLCP2RATE_LTF_GI_MASK    0x30
#define HE_MU_PLCP2RATE_LTF_GI_SHIFT    4
#define HE_MU_PLCP2RATE_STBC_MASK    0x40
#define HE_MU_PLCP2RATE_STBC_SHIFT    6
 
uint8
wf_he_plcp_to_rate(uint8 *plcp, bool is_mu)
{
   uint8 rate = 0;
   uint8 nss = 0;
   uint32 plcp0 = 0;
   uint32 plcp1 = 0;
   uint8 he_ltf_gi;
   uint8 stbc;
 
   ASSERT(plcp);
 
   BCM_REFERENCE(nss);
   BCM_REFERENCE(he_ltf_gi);
 
   plcp0 = ((plcp[3] << 24) | (plcp[2] << 16) | (plcp[1] << 8) | plcp[0]);
   plcp1 = ((plcp[5] << 8) | plcp[4]);
 
   if (!is_mu) {
       /* For SU frames return rate in MCS:NSS format */
       rate = ((plcp0 & HE_SU_RE_SIGA_MCS_MASK) >> HE_SU_RE_SIGA_MCS_SHIFT);
       nss = ((plcp0 & HE_SU_RE_SIGA_NSTS_MASK) >> HE_SU_RE_SIGA_NSTS_SHIFT) + 1;
       rate |= ((nss << HE_SU_PLCP2RATE_NSS_SHIFT) | WF_NON_HT_MCS);
   } else {
       /* For MU frames return rate in MCS:LTF-GI format */
       rate = (plcp0 & HE_MU_SIGA_SIGB_MCS_MASK) >> HE_MU_SIGA_SIGB_MCS_SHIFT;
       he_ltf_gi = (plcp0 & HE_MU_SIGA_GI_LTF_MASK) >> HE_MU_SIGA_GI_LTF_SHIFT;
       stbc = (plcp1 & HE_MU_SIGA_STBC_MASK) >> HE_MU_SIGA_STBC_SHIFT;
 
       /* LTF-GI shall take the same position as NSS */
       rate |= (he_ltf_gi << HE_MU_PLCP2RATE_LTF_GI_SHIFT);
 
       /* STBC needs to be filled in bit 6 */
       rate |= (stbc << HE_MU_PLCP2RATE_STBC_SHIFT);
   }
 
   return rate;
}
 
/**
 * Function for computing NSS:MCS from EHT SU PLCP or
 * MCS:LTF-GI from EHT MU PLCP
 *
 * TODO: add link to the HW spec.
 * FIXME: do we really need to support mu?
 */
uint8
wf_eht_plcp_to_rate(uint8 *plcp, bool is_mu)
{
   BCM_REFERENCE(plcp);
   BCM_REFERENCE(is_mu);
   ASSERT(!"wf_eht_plcp_to_rate: not implemented!");
   return 0;
}
 
/* ============================================ */
/* Moved from wlc_rate_def.c                    */
/* ============================================ */
 
/**
 * Some functions require a single stream MCS as an input parameter. Given an MCS, this function
 * returns the single spatial stream MCS equivalent.
 */
uint8
wf_get_single_stream_mcs(uint mcs)
{
   if (mcs < 32) {
       return mcs % 8;
   }
   switch (mcs) {
   case 32:
       return 32;
   case 87:
   case 99:
   case 101:
       return 87;    /* MCS 87: SS 1, MOD: 256QAM, CR 3/4 */
   default:
       return 88;    /* MCS 88: SS 1, MOD: 256QAM, CR 5/6 */
   }
}
 
/* ============================================ */
/* Moved from wlc_phy_iovar.c                   */
/* ============================================ */
 
const uint8 plcp_ofdm_rate_tbl[] = {
   DOT11_RATE_48M, /* 8: 48Mbps */
   DOT11_RATE_24M, /* 9: 24Mbps */
   DOT11_RATE_12M, /* A: 12Mbps */
   DOT11_RATE_6M,  /* B:  6Mbps */
   DOT11_RATE_54M, /* C: 54Mbps */
   DOT11_RATE_36M, /* D: 36Mbps */
   DOT11_RATE_18M, /* E: 18Mbps */
   DOT11_RATE_9M   /* F:  9Mbps */
};