1 /** @file wlan_test_mode_tests.c
2 *
3 * @brief This file provides WLAN Test Mode APIs
4 *
5 * Copyright 2008-2024 NXP
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 *
9 */
10
11 #include <wlan.h>
12 #include <wifi_shell.h>
13 #include <cli_utils.h>
14 #include <string.h>
15 #include <wm_net.h> /* for net_inet_aton */
16 #include <wifi.h>
17 #include <wlan_tests.h>
18
19 /*
20 * NXP Test Framework (MTF) functions
21 */
22
23 #if CONFIG_RF_TEST_MODE
24
25 static bool rf_test_mode = false;
26
dump_wlan_set_rf_test_mode_usage(void)27 static void dump_wlan_set_rf_test_mode_usage(void)
28 {
29 (void)PRINTF("Usage:\r\n");
30 (void)PRINTF("wlan-set-rf-test-mode \r\n");
31 (void)PRINTF("\r\n");
32 }
33
dump_wlan_set_rf_test_mode(void)34 static void dump_wlan_set_rf_test_mode(void)
35 {
36 (void)PRINTF("RF Test Mode is not set\r\n");
37 dump_wlan_set_rf_test_mode_usage();
38 }
39
wlan_rf_test_mode_set(int argc,char * argv[])40 static void wlan_rf_test_mode_set(int argc, char *argv[])
41 {
42 int ret;
43
44 if (argc != 1)
45 {
46 dump_wlan_set_rf_test_mode_usage();
47 return;
48 }
49
50 ret = wlan_set_rf_test_mode();
51 if (ret == WM_SUCCESS)
52 {
53 rf_test_mode = true;
54 (void)PRINTF("RF Test Mode Set configuration successful\r\n");
55 }
56 else
57 {
58 (void)PRINTF("RF Test Mode Set configuration failed\r\n");
59 dump_wlan_set_rf_test_mode_usage();
60 }
61 }
62
dump_wlan_unset_rf_test_mode_usage(void)63 static void dump_wlan_unset_rf_test_mode_usage(void)
64 {
65 (void)PRINTF("Usage:\r\n");
66 (void)PRINTF("wlan-unset-rf-test-mode \r\n");
67 (void)PRINTF("\r\n");
68 }
69
wlan_rf_test_mode_unset(int argc,char * argv[])70 static void wlan_rf_test_mode_unset(int argc, char *argv[])
71 {
72 int ret;
73
74 if (argc != 1)
75 {
76 dump_wlan_unset_rf_test_mode_usage();
77 return;
78 }
79
80 ret = wlan_unset_rf_test_mode();
81 if (ret == WM_SUCCESS)
82 {
83 rf_test_mode = false;
84 (void)PRINTF("RF Test Mode Unset configuration successful\r\n");
85 }
86 else
87 {
88 (void)PRINTF("RF Test Mode Unset configuration failed\r\n");
89 dump_wlan_unset_rf_test_mode_usage();
90 }
91 }
92
dump_wlan_set_channel_usage(void)93 static void dump_wlan_set_channel_usage(void)
94 {
95 (void)PRINTF("Usage:\r\n");
96 (void)PRINTF("wlan-set-rf-channel <channel> \r\n");
97 (void)PRINTF("\r\n");
98 }
99
dump_wlan_set_radio_mode_usage()100 static void dump_wlan_set_radio_mode_usage()
101 {
102 (void)PRINTF("Usage:\r\n");
103 (void)PRINTF("wlan-set-rf-radio-mode <radio_mode> \r\n");
104 (void)PRINTF("0: set the radio in power down mode\r\n");
105 (void)PRINTF("3: sets the radio in 5GHz band, 1X1 mode(path A)\r\n");
106 (void)PRINTF("11: sets the radio in 2.4GHz band, 1X1 mode(path A)\r\n");
107 (void)PRINTF("\r\n");
108 }
109
wlan_rf_channel_set(int argc,char * argv[])110 static void wlan_rf_channel_set(int argc, char *argv[])
111 {
112 int ret;
113 uint8_t channel;
114
115 if (!rf_test_mode)
116 {
117 dump_wlan_set_rf_test_mode();
118 return;
119 }
120
121 if (argc != 2)
122 {
123 dump_wlan_set_channel_usage();
124 return;
125 }
126
127 channel = strtol(argv[1], NULL, 10);
128
129 ret = wlan_set_rf_channel(channel);
130 if (ret == WM_SUCCESS)
131 {
132 (void)PRINTF("Channel configuration successful\r\n");
133 }
134 else
135 {
136 (void)PRINTF("Channel configuration failed\r\n");
137 dump_wlan_set_channel_usage();
138 }
139 }
140
dump_wlan_get_radio_mode_usage()141 static void dump_wlan_get_radio_mode_usage()
142 {
143 (void)PRINTF("Usage:\r\n");
144 (void)PRINTF("wlan-get-rf-radio-mode \r\n");
145 }
146
wlan_rf_radio_mode_get(int argc,char * argv[])147 static void wlan_rf_radio_mode_get(int argc, char *argv[])
148 {
149 int ret;
150 uint8_t radio_mode;
151
152 if (!rf_test_mode)
153 {
154 dump_wlan_set_rf_test_mode();
155 return;
156 }
157
158 if (argc != 1)
159 {
160 dump_wlan_get_radio_mode_usage();
161 return;
162 }
163
164 ret = wlan_get_rf_radio_mode(&radio_mode);
165 if (ret == WM_SUCCESS)
166 {
167 (void)PRINTF("Configured radio mode is: %d\r\n", radio_mode);
168 }
169 else
170 {
171 (void)PRINTF("Radio mode configuration read failed\r\n");
172 dump_wlan_get_radio_mode_usage();
173 }
174 }
175
dump_wlan_get_channel_usage(void)176 static void dump_wlan_get_channel_usage(void)
177 {
178 (void)PRINTF("Usage:\r\n");
179 (void)PRINTF("wlan-get-rf-channel \r\n");
180 }
181
wlan_rf_channel_get(int argc,char * argv[])182 static void wlan_rf_channel_get(int argc, char *argv[])
183 {
184 int ret;
185 uint8_t channel;
186
187 if (!rf_test_mode)
188 {
189 dump_wlan_set_rf_test_mode();
190 return;
191 }
192
193 if (argc != 1)
194 {
195 dump_wlan_get_channel_usage();
196 return;
197 }
198
199 ret = wlan_get_rf_channel(&channel);
200 if (ret == WM_SUCCESS)
201 {
202 (void)PRINTF("Configured channel is: %d\r\n", channel);
203 }
204 else
205 {
206 (void)PRINTF("Channel configuration read failed\r\n");
207 dump_wlan_get_channel_usage();
208 }
209 }
210
dump_wlan_set_rf_band_usage(void)211 static void dump_wlan_set_rf_band_usage(void)
212 {
213 (void)PRINTF("Usage:\r\n");
214 (void)PRINTF("wlan-set-rf-band <band> \r\n");
215 #if CONFIG_5GHz_SUPPORT
216 (void)PRINTF("band: 0=2.4G, 1=5G \r\n");
217 #else
218 (void)PRINTF("band: 0=2.4G \r\n");
219 #endif
220 (void)PRINTF("\r\n");
221 }
222
wlan_rf_band_set(int argc,char * argv[])223 static void wlan_rf_band_set(int argc, char *argv[])
224 {
225 int ret;
226 uint8_t band;
227
228 if (!rf_test_mode)
229 {
230 dump_wlan_set_rf_test_mode();
231 return;
232 }
233
234 if (argc != 2)
235 {
236 dump_wlan_set_rf_band_usage();
237 return;
238 }
239
240 band = strtol(argv[1], NULL, 10);
241
242 if (band != 0U
243 #if CONFIG_5GHz_SUPPORT
244 && band != 1U
245 #endif
246 )
247 {
248 dump_wlan_set_rf_band_usage();
249 return;
250 }
251
252 ret = wlan_set_rf_band(band);
253 if (ret == WM_SUCCESS)
254 {
255 (void)PRINTF("RF Band configuration successful\r\n");
256 }
257 else
258 {
259 (void)PRINTF("RF Band configuration failed\r\n");
260 dump_wlan_set_rf_band_usage();
261 }
262 }
263
dump_wlan_get_rf_band_usage(void)264 static void dump_wlan_get_rf_band_usage(void)
265 {
266 (void)PRINTF("Usage:\r\n");
267 (void)PRINTF("wlan-get-rf-band \r\n");
268 }
269
wlan_rf_band_get(int argc,char * argv[])270 static void wlan_rf_band_get(int argc, char *argv[])
271 {
272 int ret;
273 uint8_t band;
274
275 if (!rf_test_mode)
276 {
277 dump_wlan_set_rf_test_mode();
278 return;
279 }
280
281 if (argc != 1)
282 {
283 dump_wlan_get_rf_band_usage();
284 return;
285 }
286
287 ret = wlan_get_rf_band(&band);
288 if (ret == WM_SUCCESS)
289 {
290 (void)PRINTF("Configured RF Band is: %s\r\n", band ? "5G" : "2.4G");
291 }
292 else
293 {
294 (void)PRINTF("RF Band configuration read failed\r\n");
295 dump_wlan_get_rf_band_usage();
296 }
297 }
298
dump_wlan_set_bandwidth_usage(void)299 static void dump_wlan_set_bandwidth_usage(void)
300 {
301 (void)PRINTF("Usage:\r\n");
302 (void)PRINTF("wlan-set-bandwidth <bandwidth> \r\n");
303 (void)PRINTF("\r\n");
304 (void)PRINTF("\t<bandwidth>: \r\n");
305 (void)PRINTF("\t 0: 20MHz\r\n");
306 #if CONFIG_5GHz_SUPPORT
307 (void)PRINTF("\t 1: 40MHz\r\n");
308 #endif
309 #if CONFIG_11AC
310 (void)PRINTF("\t 4: 80MHz\r\n");
311 #endif
312 (void)PRINTF("\r\n");
313 }
314
wlan_rf_bandwidth_set(int argc,char * argv[])315 static void wlan_rf_bandwidth_set(int argc, char *argv[])
316 {
317 int ret;
318 uint8_t bandwidth;
319
320 if (!rf_test_mode)
321 {
322 dump_wlan_set_rf_test_mode();
323 return;
324 }
325
326 if (argc != 2)
327 {
328 dump_wlan_set_bandwidth_usage();
329 return;
330 }
331
332 bandwidth = strtol(argv[1], NULL, 10);
333
334 ret = wlan_set_rf_bandwidth(bandwidth);
335 if (ret == WM_SUCCESS)
336 {
337 (void)PRINTF("Bandwidth configuration successful\r\n");
338 }
339 else
340 {
341 (void)PRINTF("Bandwidth configuration failed\r\n");
342 dump_wlan_set_bandwidth_usage();
343 }
344 }
345
dump_wlan_get_bandwidth_usage(void)346 static void dump_wlan_get_bandwidth_usage(void)
347 {
348 (void)PRINTF("Usage:\r\n");
349 (void)PRINTF("wlan-get-rf-bandwidth \r\n");
350 }
351
wlan_rf_bandwidth_get(int argc,char * argv[])352 static void wlan_rf_bandwidth_get(int argc, char *argv[])
353 {
354 int ret;
355 uint8_t bandwidth;
356
357 if (!rf_test_mode)
358 {
359 dump_wlan_set_rf_test_mode();
360 return;
361 }
362
363 if (argc != 1)
364 {
365 dump_wlan_get_bandwidth_usage();
366 return;
367 }
368
369 ret = wlan_get_rf_bandwidth(&bandwidth);
370 if (ret == WM_SUCCESS)
371 {
372 (void)PRINTF("Configured bandwidth is: %s\r\n", bandwidth == 0 ? "20MHz" : bandwidth == 1U ? "40MHz" : "80MHz");
373 }
374 else
375 {
376 (void)PRINTF("Bandwidth configuration read failed\r\n");
377 dump_wlan_get_bandwidth_usage();
378 }
379 }
380
dump_wlan_get_and_reset_per_usage(void)381 static void dump_wlan_get_and_reset_per_usage(void)
382 {
383 (void)PRINTF("Usage:\r\n");
384 (void)PRINTF("wlan-get-rf-per \r\n");
385 }
386
wlan_rf_per_get(int argc,char * argv[])387 static void wlan_rf_per_get(int argc, char *argv[])
388 {
389 int ret;
390 uint32_t rx_tot_pkt_count, rx_mcast_bcast_count, rx_pkt_fcs_error;
391
392 if (!rf_test_mode)
393 {
394 dump_wlan_set_rf_test_mode();
395 return;
396 }
397
398 if (argc != 1)
399 {
400 dump_wlan_get_and_reset_per_usage();
401 return;
402 }
403
404 ret = wlan_get_rf_per(&rx_tot_pkt_count, &rx_mcast_bcast_count, &rx_pkt_fcs_error);
405 if (ret == WM_SUCCESS)
406 {
407 (void)PRINTF("PER is as below: \r\n");
408 (void)PRINTF(" Total Rx Packet Count : %d\r\n", rx_tot_pkt_count);
409 (void)PRINTF(" Total Rx Multicast/Broadcast Packet Count: %d\r\n", rx_mcast_bcast_count);
410 (void)PRINTF(" Total Rx Packets with FCS error : %d\r\n", rx_pkt_fcs_error);
411 }
412 else
413 {
414 (void)PRINTF("PER configuration read failed\r\n");
415 dump_wlan_get_and_reset_per_usage();
416 }
417 }
418
dump_wlan_set_tx_cont_mode_usage(void)419 static void dump_wlan_set_tx_cont_mode_usage(void)
420 {
421 (void)PRINTF("Usage:\r\n");
422 (void)PRINTF(
423 "wlan-set-rf-tx-cont-mode <enable_tx> <cw_mode> <payload_pattern> <cs_mode> <act_sub_ch> <tx_rate> \r\n");
424 (void)PRINTF("Enable (0:disable, 1:enable)\r\n");
425 (void)PRINTF("Continuous Wave Mode (0:disable, 1:enable)\r\n");
426 (void)PRINTF("Payload Pattern (0 to 0xFFFFFFFF) (Enter hexadecimal value)\r\n");
427 (void)PRINTF("CS Mode (Applicable only when continuous wave is disabled) (0:disable, 1:enable)\r\n");
428 (void)PRINTF("Active SubChannel (0:low, 1:upper, 3:both)\r\n");
429 (void)PRINTF("Tx Data Rate (Rate Index corresponding to legacy/HT/VHT rates)\r\n");
430 (void)PRINTF("\r\n");
431 (void)PRINTF("To Disable:\r\n");
432 #ifdef SD9177
433 (void)PRINTF("Set all parameters with expected values\r\n");
434 #else
435 (void)PRINTF(" In Continuous Wave Mode:\r\n");
436 (void)PRINTF(" Step1: wlan-set-rf-tx-cont-mode 0 1 0 0 0 0 \r\n");
437 (void)PRINTF(" Step2: wlan-set-rf-tx-cont-mode 0 \r\n");
438 (void)PRINTF(" In none continuous Wave Mode:\r\n");
439 (void)PRINTF(" Step1: wlan-set-rf-tx-cont-mode 0 \r\n");
440 #endif
441 (void)PRINTF("\r\n");
442 }
443
wlan_rf_tx_cont_mode_set(int argc,char * argv[])444 static void wlan_rf_tx_cont_mode_set(int argc, char *argv[])
445 {
446 int ret;
447 uint32_t enable_tx, cw_mode, payload_pattern, cs_mode, act_sub_ch, tx_rate;
448
449 if (!rf_test_mode)
450 {
451 dump_wlan_set_rf_test_mode();
452 return;
453 }
454
455 if (argc == 2 && strtol(argv[1], NULL, 10) == 0)
456 {
457 enable_tx = 0;
458 cw_mode = 0;
459 payload_pattern = 0;
460 cs_mode = 0;
461 act_sub_ch = 0;
462 tx_rate = 0;
463 goto disable;
464 }
465 else if (argc != 7)
466 {
467 dump_wlan_set_tx_cont_mode_usage();
468 return;
469 }
470 else
471 { /*Do nothing*/
472 }
473
474 enable_tx = strtol(argv[1], NULL, 10);
475 cw_mode = strtol(argv[2], NULL, 10);
476 errno = 0;
477 payload_pattern = strtol(argv[3], NULL, 16);
478 if (errno != 0)
479 {
480 (void)PRINTF("Error during strtoul errno:%d", errno);
481 }
482 cs_mode = strtol(argv[4], NULL, 10);
483 act_sub_ch = strtol(argv[5], NULL, 10);
484 tx_rate = strtol(argv[6], NULL, 10);
485
486 disable:
487 ret = wlan_set_rf_tx_cont_mode(enable_tx, cw_mode, payload_pattern, cs_mode, act_sub_ch, tx_rate);
488 if (ret == WM_SUCCESS)
489 {
490 (void)PRINTF("Tx continuous configuration successful\r\n");
491 (void)PRINTF(" Enable : %s\r\n", enable_tx ? "enable" : "disable");
492 (void)PRINTF(" Continuous Wave Mode : %s\r\n", cw_mode ? "enable" : "disable");
493 (void)PRINTF(" Payload Pattern : 0x%08X\r\n", payload_pattern);
494 (void)PRINTF(" CS Mode : %s\r\n", cs_mode ? "enable" : "disable");
495 (void)PRINTF(" Active SubChannel : %s\r\n", act_sub_ch == 0U ? "low" :
496 act_sub_ch == 1U ? "upper" :
497 "both");
498 (void)PRINTF(" Tx Data Rate : %d\r\n", tx_rate);
499 }
500 else
501 {
502 (void)PRINTF("Tx continuous configuration failed\r\n");
503 dump_wlan_set_tx_cont_mode_usage();
504 }
505 }
506
dump_wlan_set_tx_antenna_usage(void)507 static void dump_wlan_set_tx_antenna_usage(void)
508 {
509 (void)PRINTF("Usage:\r\n");
510 (void)PRINTF("wlan-set-rf-tx-antenna <antenna> \r\n");
511 (void)PRINTF("antenna: 1=Main, 2=Aux \r\n");
512 (void)PRINTF("\r\n");
513 }
514
wlan_rf_tx_antenna_set(int argc,char * argv[])515 static void wlan_rf_tx_antenna_set(int argc, char *argv[])
516 {
517 int ret;
518 uint8_t ant;
519
520 if (!rf_test_mode)
521 {
522 dump_wlan_set_rf_test_mode();
523 return;
524 }
525
526 if (argc != 2)
527 {
528 dump_wlan_set_tx_antenna_usage();
529 return;
530 }
531
532 ant = strtol(argv[1], NULL, 10);
533
534 if (ant != 1U && ant != 2U)
535 {
536 dump_wlan_set_tx_antenna_usage();
537 return;
538 }
539
540 ret = wlan_set_rf_tx_antenna(ant);
541 if (ret == WM_SUCCESS)
542 {
543 (void)PRINTF("Tx Antenna configuration successful\r\n");
544 }
545 else
546 {
547 (void)PRINTF("Tx Antenna configuration failed\r\n");
548 dump_wlan_set_tx_antenna_usage();
549 }
550 }
551
dump_wlan_get_tx_antenna_usage(void)552 static void dump_wlan_get_tx_antenna_usage(void)
553 {
554 (void)PRINTF("Usage:\r\n");
555 (void)PRINTF("wlan-get-rf-tx-antenna \r\n");
556 }
557
wlan_rf_tx_antenna_get(int argc,char * argv[])558 static void wlan_rf_tx_antenna_get(int argc, char *argv[])
559 {
560 int ret;
561 uint8_t ant;
562
563 if (!rf_test_mode)
564 {
565 dump_wlan_set_rf_test_mode();
566 return;
567 }
568
569 if (argc != 1)
570 {
571 dump_wlan_get_tx_antenna_usage();
572 return;
573 }
574
575 ret = wlan_get_rf_tx_antenna(&ant);
576 if (ret == WM_SUCCESS)
577 {
578 (void)PRINTF("Configured Tx Antenna is: %s\r\n", ant == 1U ? "Main" : "Aux");
579 }
580 else
581 {
582 (void)PRINTF("Tx Antenna configuration read failed\r\n");
583 dump_wlan_get_tx_antenna_usage();
584 }
585 }
586
dump_wlan_set_rx_antenna_usage(void)587 static void dump_wlan_set_rx_antenna_usage(void)
588 {
589 (void)PRINTF("Usage:\r\n");
590 (void)PRINTF("wlan-set-rf-rx-antenna <antenna> \r\n");
591 (void)PRINTF("antenna: 1=Main, 2=Aux \r\n");
592 (void)PRINTF("\r\n");
593 }
594
wlan_rf_rx_antenna_set(int argc,char * argv[])595 static void wlan_rf_rx_antenna_set(int argc, char *argv[])
596 {
597 int ret;
598 uint8_t ant;
599
600 if (!rf_test_mode)
601 {
602 dump_wlan_set_rf_test_mode();
603 return;
604 }
605
606 if (argc != 2)
607 {
608 dump_wlan_set_rx_antenna_usage();
609 return;
610 }
611
612 ant = strtol(argv[1], NULL, 10);
613
614 if (ant != 1U && ant != 2U)
615 {
616 dump_wlan_set_rx_antenna_usage();
617 return;
618 }
619
620 ret = wlan_set_rf_rx_antenna(ant);
621 if (ret == WM_SUCCESS)
622 {
623 (void)PRINTF("Rx Antenna configuration successful\r\n");
624 }
625 else
626 {
627 (void)PRINTF("Rx Antenna configuration failed\r\n");
628 dump_wlan_set_rx_antenna_usage();
629 }
630 }
631
dump_wlan_get_rx_antenna_usage(void)632 static void dump_wlan_get_rx_antenna_usage(void)
633 {
634 (void)PRINTF("Usage:\r\n");
635 (void)PRINTF("wlan-get-rf-rx-antenna \r\n");
636 }
637
wlan_rf_rx_antenna_get(int argc,char * argv[])638 static void wlan_rf_rx_antenna_get(int argc, char *argv[])
639 {
640 int ret;
641 uint8_t ant;
642
643 if (!rf_test_mode)
644 {
645 dump_wlan_set_rf_test_mode();
646 return;
647 }
648
649 if (argc != 1)
650 {
651 dump_wlan_get_rx_antenna_usage();
652 return;
653 }
654
655 ret = wlan_get_rf_rx_antenna(&ant);
656 if (ret == WM_SUCCESS)
657 {
658 (void)PRINTF("Configured Rx Antenna is: %s\r\n", ant == 1U ? "Main" : "Aux");
659 }
660 else
661 {
662 (void)PRINTF("Rx Antenna configuration read failed\r\n");
663 dump_wlan_get_rx_antenna_usage();
664 }
665 }
666
dump_wlan_set_tx_power_usage(void)667 static void dump_wlan_set_tx_power_usage(void)
668 {
669 (void)PRINTF("Usage:\r\n");
670 (void)PRINTF("wlan-set-rf-tx-power <tx_power> <modulation> <path_id> \r\n");
671 #ifdef RW610
672 (void)PRINTF("Power (0 to 20 dBm)\r\n");
673 #else
674 (void)PRINTF("Power (0 to 24 dBm)\r\n");
675 #endif
676 (void)PRINTF("Modulation (0: CCK, 1:OFDM, 2:MCS)\r\n");
677 (void)PRINTF("Path ID (0: PathA, 1:PathB, 2:PathA+B)\r\n");
678 (void)PRINTF("\r\n");
679 }
680
681 #if !defined(SD8978) && !defined(SD8987) && !defined(SD9177) && !defined(SD8801)
682 /*
683 * @brief PowerLevelToDUT11Bits
684 *
685 * @param Pwr A user txpwr values of type int
686 * @param PowerLevel A Pointer of uint32 type for converted txpwr vals
687 * @return nothing just exit
688 */
PowerLevelToDUT11Bits(int Pwr,uint32_t * PowerLevel)689 static void PowerLevelToDUT11Bits(int Pwr, uint32_t *PowerLevel)
690 {
691 int Z = 0;
692
693 if ((Pwr > 64) || (Pwr < -64))
694 return;
695
696 Z = (int)(Pwr * 16);
697 if (Z < 0)
698 {
699 Z = Z + (1 << 11);
700 }
701 (*PowerLevel) = (uint32_t)Z;
702
703 return;
704 }
705 #endif
706
wlan_rf_tx_power_set(int argc,char * argv[])707 static void wlan_rf_tx_power_set(int argc, char *argv[])
708 {
709 int ret;
710 uint32_t power;
711 uint8_t mod;
712 uint8_t path_id;
713 #if !defined(SD8978) && !defined(SD8987) && !defined(SD9177) && !defined(SD8801)
714 uint32_t power_converted = 0xffffffff;
715 #endif
716
717 if (!rf_test_mode)
718 {
719 dump_wlan_set_rf_test_mode();
720 return;
721 }
722
723 if (argc != 4)
724 {
725 dump_wlan_set_tx_power_usage();
726 return;
727 }
728
729 power = strtol(argv[1], NULL, 10);
730 mod = strtol(argv[2], NULL, 10);
731 path_id = strtol(argv[3], NULL, 10);
732
733 #ifdef RW610
734 if (power > 20U)
735 #else
736 if (power > 24U)
737 #endif
738 {
739 dump_wlan_set_tx_power_usage();
740 return;
741 }
742
743 if (mod != 0U && mod != 1U && mod != 2U)
744 {
745 dump_wlan_set_tx_power_usage();
746 return;
747 }
748
749 if (path_id != 0U && path_id != 1U && path_id != 2U)
750 {
751 dump_wlan_set_tx_power_usage();
752 return;
753 }
754
755 #if !defined(SD8978) && !defined(SD8987) && !defined(SD9177) && !defined(SD8801)
756 /* We need to convert user power vals including -ve vals as per labtool */
757 PowerLevelToDUT11Bits((int)power, &power_converted);
758 ret = wlan_set_rf_tx_power(power_converted, mod, path_id);
759 #else
760 ret = wlan_set_rf_tx_power(power, mod, path_id);
761 #endif
762 if (ret == WM_SUCCESS)
763 {
764 (void)PRINTF("Tx Power configuration successful\r\n");
765 (void)PRINTF(" Power : %d dBm\r\n", power);
766 (void)PRINTF(" Modulation : %s\r\n", mod == 0 ? "CCK" : mod == 1 ? "OFDM" : "MCS");
767 (void)PRINTF(" Path ID : %s\r\n", path_id == 0 ? "PathA" : path_id == 1 ? "PathB" : "PathA+B");
768 }
769 else
770 {
771 (void)PRINTF("Tx Power configuration failed\r\n");
772 dump_wlan_set_tx_power_usage();
773 }
774 }
775
dump_wlan_set_tx_frame_usage(void)776 static void dump_wlan_set_tx_frame_usage(void)
777 {
778 (void)PRINTF("Usage:\r\n");
779 (void)PRINTF(
780 "wlan-set-rf-tx-frame <start> <data_rate> <frame_pattern> <frame_len> <adjust_burst_sifs> <burst_sifs_in_us> "
781 "<short_preamble> <act_sub_ch> <short_gi> <adv_coding> <tx_bf> <gf_mode> <stbc> <bssid>\r\n");
782 (void)PRINTF("Enable (0:disable, 1:enable)\r\n");
783 (void)PRINTF(
784 "Tx Data Rate (Rate Index corresponding to legacy/HT/VHT rates)(Enter hexadecimal value)\r\n");
785 (void)PRINTF("Payload Pattern (0 to 0xFFFFFFFF) (Enter hexadecimal value)\r\n");
786 (void)PRINTF("Payload Length (1 to 0x400) (Enter hexadecimal value)\r\n");
787 (void)PRINTF("Adjust Burst SIFS3 Gap (0:disable, 1:enable)\r\n");
788 (void)PRINTF("Burst SIFS in us (0 to 255us)\r\n");
789 (void)PRINTF("Short Preamble (0:disable, 1:enable)\r\n");
790 (void)PRINTF("Active SubChannel (0:low, 1:upper, 3:both)\r\n");
791 (void)PRINTF("Short GI (0:disable, 1:enable)\r\n");
792 (void)PRINTF("Adv Coding (0:disable, 1:enable)\r\n");
793 (void)PRINTF("Beamforming (0:disable, 1:enable)\r\n");
794 (void)PRINTF("GreenField Mode (0:disable, 1:enable)\r\n");
795 (void)PRINTF("STBC (0:disable, 1:enable)\r\n");
796 (void)PRINTF("BSSID (xx:xx:xx:xx:xx:xx)\r\n");
797 (void)PRINTF("\r\n");
798 (void)PRINTF("To Disable:\r\n");
799 (void)PRINTF("wlan-set-rf-tx-frame 0\r\n");
800 (void)PRINTF("\r\n");
801 }
802
wlan_rf_tx_frame_set(int argc,char * argv[])803 static void wlan_rf_tx_frame_set(int argc, char *argv[])
804 {
805 int ret;
806 uint32_t enable;
807 uint32_t data_rate;
808 uint32_t frame_pattern;
809 uint32_t frame_length;
810 uint16_t adjust_burst_sifs;
811 uint32_t burst_sifs_in_us;
812 uint32_t short_preamble;
813 uint32_t act_sub_ch;
814 uint32_t short_gi;
815 uint32_t adv_coding;
816 uint32_t tx_bf;
817 uint32_t gf_mode;
818 uint32_t stbc;
819 uint8_t bssid[MLAN_MAC_ADDR_LENGTH];
820
821 if (!rf_test_mode)
822 {
823 dump_wlan_set_rf_test_mode();
824 return;
825 }
826
827 if (argc == 2 && strtol(argv[1], NULL, 10) == 0)
828 {
829 enable = 0;
830 data_rate = 0;
831 frame_pattern = 0;
832 frame_length = 1;
833 adjust_burst_sifs = 0;
834 burst_sifs_in_us = 0;
835 short_preamble = 0;
836 act_sub_ch = 0;
837 short_gi = 0;
838 adv_coding = 0;
839 tx_bf = 0;
840 gf_mode = 0;
841 stbc = 0;
842 (void)memset(bssid, 0, MLAN_MAC_ADDR_LENGTH);
843 goto disable;
844 }
845 else if (argc != 15)
846 {
847 dump_wlan_set_tx_frame_usage();
848 return;
849 }
850
851 enable = strtol(argv[1], NULL, 10);
852 data_rate = strtol(argv[2], NULL, 16);
853 errno = 0;
854 frame_pattern = strtoul(argv[3], NULL, 16);
855 if (errno != 0)
856 {
857 (void)PRINTF("Error during strtoul errno:%d", errno);
858 }
859 errno = 0;
860 frame_length = strtol(argv[4], NULL, 16);
861 if (errno != 0)
862 {
863 (void)PRINTF("Error during strtoul errno:%d", errno);
864 }
865 adjust_burst_sifs = strtol(argv[5], NULL, 10);
866 burst_sifs_in_us = strtol(argv[6], NULL, 10);
867 short_preamble = strtol(argv[7], NULL, 10);
868 act_sub_ch = strtol(argv[8], NULL, 10);
869 short_gi = strtol(argv[9], NULL, 10);
870 adv_coding = strtol(argv[10], NULL, 10);
871 tx_bf = strtol(argv[11], NULL, 10);
872 gf_mode = strtol(argv[12], NULL, 10);
873 stbc = strtol(argv[13], NULL, 10);
874 ret = get_mac((const char *)argv[14], (char *)bssid, ':');
875 if (ret != 0U)
876 {
877 dump_wlan_set_tx_frame_usage();
878 return;
879 }
880
881 if (enable > 1U || frame_length < 1 || frame_length > 0x400U || burst_sifs_in_us > 255U || short_preamble > 1U ||
882 act_sub_ch == 2 || act_sub_ch > 3 || short_gi > 1U || adv_coding > 1U || tx_bf > 1U || gf_mode > 1U ||
883 stbc > 1U)
884 {
885 dump_wlan_set_tx_frame_usage();
886 return;
887 }
888
889 disable:
890 ret = wlan_set_rf_tx_frame(enable, data_rate, frame_pattern, frame_length, adjust_burst_sifs, burst_sifs_in_us,
891 short_preamble, act_sub_ch, short_gi, adv_coding, tx_bf, gf_mode, stbc, bssid);
892 if (ret == WM_SUCCESS)
893 {
894 (void)PRINTF("Tx Frame configuration successful\r\n");
895 (void)PRINTF(" Enable : %s\r\n", enable ? "enable" : "disable");
896 (void)PRINTF(" Tx Data Rate : %d\r\n", data_rate);
897 (void)PRINTF(" Payload Pattern : 0x%X\r\n", frame_pattern);
898 (void)PRINTF(" Payload Length : 0x%X\r\n", frame_length);
899 (void)PRINTF(" Adjust Burst SIFS3 Gap : %s\r\n", adjust_burst_sifs ? "enable" : "disable");
900 (void)PRINTF(" Burst SIFS in us : %d us\r\n", burst_sifs_in_us);
901 (void)PRINTF(" Short Preamble : %s\r\n", short_preamble ? "enable" : "disable");
902 (void)PRINTF(" Active SubChannel : %s\r\n", act_sub_ch == 0U ? "low" :
903 act_sub_ch == 1U ? "upper" :
904 "both");
905 (void)PRINTF(" Short GI : %s\r\n", short_gi ? "enable" : "disable");
906 (void)PRINTF(" Adv Coding : %s\r\n", adv_coding ? "enable" : "disable");
907 (void)PRINTF(" Beamforming : %s\r\n", tx_bf ? "enable" : "disable");
908 (void)PRINTF(" GreenField Mode : %s\r\n", gf_mode ? "enable" : "disable");
909 (void)PRINTF(" STBC : %s\r\n", stbc ? "enable" : "disable");
910 (void)PRINTF(" BSSID : ");
911 print_mac((const char *)bssid);
912 (void)PRINTF("\r\n");
913 }
914 else
915 {
916 (void)PRINTF("Tx Frame configuration failed\r\n");
917 dump_wlan_set_tx_frame_usage();
918 }
919 }
920
dump_wlan_set_rf_trigger_frame_cfg_usage(void)921 static void dump_wlan_set_rf_trigger_frame_cfg_usage(void)
922 {
923 (void)PRINTF("Usage:\r\n");
924 (void)PRINTF(
925 "wlan-set-rf-trigger-frame-cfg <Enable_tx> <Standalone_hetb> <FRAME_CTRL_TYPE> <FRAME_CTRL_SUBTYPE> "
926 "<FRAME_DURATION>"
927 "<TriggerType> <UlLen> <MoreTF> <CSRequired> <UlBw> <LTFType> <LTFMode>"
928 "<LTFSymbol> <UlSTBC> <LdpcESS> <ApTxPwr> <PreFecPadFct> <PeDisambig> <SpatialReuse>"
929 "<Doppler> <HeSig2> <AID12> <RUAllocReg> <RUAlloc> <UlCodingType> <UlMCS> <UlDCM>"
930 "<SSAlloc> <UlTargetRSSI> <MPDU_MU_SF> <TID_AL> <AC_PL> <Pref_AC>\r\n");
931 (void)PRINTF("Enable_tx (Enable/Disable trigger frame transmission)\r\n");
932 (void)PRINTF("Standalone_hetb (Enable/Disable Standalone HE TB support.)\r\n");
933 (void)PRINTF("FRAME_CTRL_TYPE (Frame control type)\r\n");
934 (void)PRINTF("FRAME_CTRL_SUBTYPE (Frame control subtype)\r\n");
935 (void)PRINTF("FRAME_DURATION (Max Duration time)\r\n");
936 (void)PRINTF("TriggerType (Identifies the Trigger frame variant and its encoding)\r\n");
937 (void)PRINTF(
938 "UlLen (Indicates the value of the L-SIG LENGTH field of the solicited HE TB PPDU)\r\n");
939 (void)PRINTF(
940 "MoreTF (Indicates whether a subsequent Trigger frame is scheduled for transmission)\r\n");
941 (void)PRINTF(
942 "CSRequired (Required to use ED to sense the medium and to consider the medium state and the "
943 "NAV in determining whether to respond)\r\n");
944 (void)PRINTF("UlBw (Indicates the bandwidth in the HE-SIG-A field of the HE TB PPDU)\r\n");
945 (void)PRINTF("LTFType (Indicates the LTF type of the HE TB PPDU response)\r\n");
946 (void)PRINTF("LTFMode (Indicates the LTF mode for an HE TB PPDU)\r\n");
947 (void)PRINTF("LTFSymbol (Indicates the number of LTF symbols present in the HE TB PPDU)\r\n");
948 (void)PRINTF(
949 "UlSTBC (Indicates the status of STBC encoding for the solicited HE TB PPDUs)\r\n");
950 (void)PRINTF("LdpcESS (Indicates the status of the LDPC extra symbol segment)\r\n");
951 (void)PRINTF(
952 "ApTxPwr (Indicates the AP’s combined transmit power at the transmit antenna connector of "
953 "all the antennas used to transmit the triggering PPDU)\r\n");
954 (void)PRINTF("PreFecPadFct (Indicates the pre-FEC padding factor)\r\n");
955 (void)PRINTF("PeDisambig (Indicates PE disambiguity)\r\n");
956 (void)PRINTF(
957 "SpatialReuse (Carries the values to be included in the Spatial Reuse fields in the HE-SIG-A "
958 "field of the solicited HE TB PPDUs)\r\n");
959 (void)PRINTF("Doppler (Indicate that a midamble is present in the HE TB PPDU)\r\n");
960 (void)PRINTF(
961 "HeSig2 (Carries the value to be included in the Reserved field in the HE-SIG-A2 subfield "
962 "of the solicited HE TB PPDUs)\r\n");
963 (void)PRINTF(
964 "AID12 (If set to 0 allocates one or more contiguous RA-RUs for associated STAs)\r\n");
965 (void)PRINTF("RUAllocReg (RUAllocReg)\r\n");
966 (void)PRINTF("RUAlloc (Identifies the size and the location of the RU)\r\n");
967 (void)PRINTF("UlCodingType (Indicates the code type of the solicited HE TB PPDU)\r\n");
968 (void)PRINTF("UlMCS (Indicates the HE-MCS of the solicited HE TB PPDU)\r\n");
969 (void)PRINTF("UlDCM (Indicates DCM of the solicited HE TB PPDU)\r\n");
970 (void)PRINTF("SSAlloc (Indicates the spatial streams of the solicited HE TB PPDU)\r\n");
971 (void)PRINTF("UlTargetRSSI (Indicates the expected receive signal power)\r\n");
972 (void)PRINTF(
973 "MPDU_MU_SF (Used for calculating the value by which the minimum MPDU start spacing is "
974 "multiplied)\r\n");
975 (void)PRINTF(
976 "TID_AL (Indicates the MPDUs allowed in an A-MPDU carried in the HE TB PPDU and the "
977 "maximum number of TIDs that can be aggregated by the STA in the A-MPDU)\r\n");
978 (void)PRINTF("AC_PL (Reserved)\r\n");
979 (void)PRINTF(
980 "Pref_AC (Indicates the lowest AC that is recommended for aggregation of MPDUs in the "
981 "A-MPDU contained in the HE TB PPDU sent as a response to the Trigger frame)\r\n");
982 }
983
wlan_set_rf_trigger_frame_cfg(int argc,char * argv[])984 static void wlan_set_rf_trigger_frame_cfg(int argc, char *argv[])
985 {
986 int ret;
987 uint32_t Enable_tx;
988 uint32_t Standalone_hetb;
989 uint8_t FRAME_CTRL_TYPE;
990 uint8_t FRAME_CTRL_SUBTYPE;
991 uint16_t FRAME_DURATION;
992 uint64_t TriggerType;
993 uint64_t UlLen;
994 uint64_t MoreTF;
995 uint64_t CSRequired;
996 uint64_t UlBw;
997 uint64_t LTFType;
998 uint64_t LTFMode;
999 uint64_t LTFSymbol;
1000 uint64_t UlSTBC;
1001 uint64_t LdpcESS;
1002 uint64_t ApTxPwr;
1003 uint64_t PreFecPadFct;
1004 uint64_t PeDisambig;
1005 uint64_t SpatialReuse;
1006 uint64_t Doppler;
1007 uint64_t HeSig2;
1008 uint32_t AID12;
1009 uint32_t RUAllocReg;
1010 uint32_t RUAlloc;
1011 uint32_t UlCodingType;
1012 uint32_t UlMCS;
1013 uint32_t UlDCM;
1014 uint32_t SSAlloc;
1015 uint8_t UlTargetRSSI;
1016 uint8_t MPDU_MU_SF;
1017 uint8_t TID_AL;
1018 uint8_t AC_PL;
1019 uint8_t Pref_AC;
1020
1021 if (!rf_test_mode)
1022 {
1023 dump_wlan_set_rf_test_mode();
1024 return;
1025 }
1026
1027 if (argc != 34)
1028 {
1029 dump_wlan_set_rf_trigger_frame_cfg_usage();
1030 return;
1031 }
1032
1033 Enable_tx = strtol(argv[1], NULL, 10);
1034 Standalone_hetb = strtol(argv[2], NULL, 10);
1035 FRAME_CTRL_TYPE = strtol(argv[3], NULL, 10);
1036 FRAME_CTRL_SUBTYPE = strtol(argv[4], NULL, 10);
1037 FRAME_DURATION = strtol(argv[5], NULL, 10);
1038 TriggerType = strtol(argv[6], NULL, 10);
1039 UlLen = strtol(argv[7], NULL, 10);
1040 MoreTF = strtol(argv[8], NULL, 10);
1041 CSRequired = strtol(argv[9], NULL, 10);
1042 UlBw = strtol(argv[10], NULL, 10);
1043 LTFType = strtol(argv[11], NULL, 10);
1044 LTFMode = strtol(argv[12], NULL, 10);
1045 LTFSymbol = strtol(argv[13], NULL, 10);
1046 UlSTBC = strtol(argv[14], NULL, 10);
1047 LdpcESS = strtol(argv[15], NULL, 10);
1048 ApTxPwr = strtol(argv[16], NULL, 10);
1049 PreFecPadFct = strtol(argv[17], NULL, 10);
1050 PeDisambig = strtol(argv[18], NULL, 10);
1051 SpatialReuse = strtol(argv[19], NULL, 10);
1052 Doppler = strtol(argv[20], NULL, 10);
1053 HeSig2 = strtol(argv[21], NULL, 10);
1054 AID12 = strtol(argv[22], NULL, 10);
1055 RUAllocReg = strtol(argv[23], NULL, 10);
1056 RUAlloc = strtol(argv[24], NULL, 10);
1057 UlCodingType = strtol(argv[25], NULL, 10);
1058 UlMCS = strtol(argv[26], NULL, 10);
1059 UlDCM = strtol(argv[27], NULL, 10);
1060 SSAlloc = strtol(argv[28], NULL, 10);
1061 UlTargetRSSI = strtol(argv[29], NULL, 10);
1062 MPDU_MU_SF = strtol(argv[30], NULL, 10);
1063 TID_AL = strtol(argv[31], NULL, 10);
1064 AC_PL = strtol(argv[32], NULL, 10);
1065 Pref_AC = strtol(argv[33], NULL, 10);
1066
1067 ret = wlan_rf_trigger_frame_cfg(Enable_tx, Standalone_hetb, FRAME_CTRL_TYPE, FRAME_CTRL_SUBTYPE, FRAME_DURATION,
1068 TriggerType, UlLen, MoreTF, CSRequired, UlBw, LTFType, LTFMode, LTFSymbol, UlSTBC,
1069 LdpcESS, ApTxPwr, PreFecPadFct, PeDisambig, SpatialReuse, Doppler, HeSig2, AID12,
1070 RUAllocReg, RUAlloc, UlCodingType, UlMCS, UlDCM, SSAlloc, UlTargetRSSI, MPDU_MU_SF,
1071 TID_AL, AC_PL, Pref_AC);
1072 if (ret == WM_SUCCESS)
1073 {
1074 (void)PRINTF("RF Trigger Frame configuration successful\r\n");
1075 (void)PRINTF("Enable_tx : %d\r\n", Enable_tx);
1076 (void)PRINTF("Standalone_hetb : %d\r\n", Standalone_hetb);
1077 (void)PRINTF("FRAME_CTRL_TYPE : %d\r\n", FRAME_CTRL_TYPE);
1078 (void)PRINTF("FRAME_CTRL_SUBTYPE : %d\r\n", FRAME_CTRL_SUBTYPE);
1079 (void)PRINTF("FRAME_DURATION : %d\r\n", FRAME_DURATION);
1080 (void)PRINTF("TriggerType : %lld\r\n", TriggerType);
1081 (void)PRINTF("UlLen : %lld\r\n", UlLen);
1082 (void)PRINTF("MoreTF : %lld\r\n", MoreTF);
1083 (void)PRINTF("CSRequired : %lld\r\n", CSRequired);
1084 (void)PRINTF("UlBw : %lld\r\n", UlBw);
1085 (void)PRINTF("LTFType : %lld\r\n", LTFType);
1086 (void)PRINTF("LTFMode : %lld\r\n", LTFMode);
1087 (void)PRINTF("LTFSymbol : %lld\r\n", LTFSymbol);
1088 (void)PRINTF("UlSTBC : %lld\r\n", UlSTBC);
1089 (void)PRINTF("LdpcESS : %lld\r\n", LdpcESS);
1090 (void)PRINTF("ApTxPwr : %lld\r\n", ApTxPwr);
1091 (void)PRINTF("PreFecPadFct : %lld\r\n", PreFecPadFct);
1092 (void)PRINTF("PeDisambig : %lld\r\n", PeDisambig);
1093 (void)PRINTF("SpatialReuse : %lld\r\n", SpatialReuse);
1094 (void)PRINTF("Doppler : %lld\r\n", Doppler);
1095 (void)PRINTF("HeSig2 : %lld\r\n", HeSig2);
1096 (void)PRINTF("AID12 : %d\r\n", AID12);
1097 (void)PRINTF("RUAllocReg : %d\r\n", RUAllocReg);
1098 (void)PRINTF("RUAlloc : %d\r\n", RUAlloc);
1099 (void)PRINTF("UlCodingType : %d\r\n", UlCodingType);
1100 (void)PRINTF("UlMCS : %d\r\n", UlMCS);
1101 (void)PRINTF("UlDCM : %d\r\n", UlDCM);
1102 (void)PRINTF("SSAlloc : %d\r\n", SSAlloc);
1103 (void)PRINTF("UlTargetRSSI : %d\r\n", UlTargetRSSI);
1104 (void)PRINTF("MPDU_MU_SF : %d\r\n", MPDU_MU_SF);
1105 (void)PRINTF("TID_AL : %d\r\n", TID_AL);
1106 (void)PRINTF("AC_PL : %d\r\n", AC_PL);
1107 (void)PRINTF("Pref_AC : %d\r\n", Pref_AC);
1108 }
1109 else
1110 {
1111 (void)PRINTF("RF Trigger Frame configuration failed\r\n");
1112 dump_wlan_set_rf_trigger_frame_cfg_usage();
1113 }
1114 }
1115
dump_wlan_set_rf_he_tb_tx_usage(void)1116 static void dump_wlan_set_rf_he_tb_tx_usage(void)
1117 {
1118 (void)PRINTF("Usage:\r\n");
1119 (void)PRINTF("wlan-set-rf-he-tb-tx <enable> <qnum> <uint16_t aid> <axq_mu_timer> <tx_power>\r\n");
1120 (void)PRINTF("Enable (Enable/Disable trigger response mode)\r\n");
1121 (void)PRINTF("qnum (AXQ to be used for the trigger response frame)\r\n");
1122 (void)PRINTF("aid (AID of the peer to which response is to be generated)\r\n");
1123 (void)PRINTF("axq_mu_timer (MU timer for the AXQ on which response is sent)\r\n");
1124 (void)PRINTF("tx_power (TxPwr to be configured for the response)\r\n");
1125 }
1126
wlan_set_rf_he_tb_tx(int argc,char * argv[])1127 static void wlan_set_rf_he_tb_tx(int argc, char *argv[])
1128 {
1129 int ret;
1130
1131 uint16_t enable;
1132 uint16_t qnum;
1133 uint16_t aid;
1134 uint16_t axq_mu_timer;
1135 int16_t tx_power;
1136
1137 if (!rf_test_mode)
1138 {
1139 dump_wlan_set_rf_test_mode();
1140 return;
1141 }
1142
1143 if (argc != 6)
1144 {
1145 dump_wlan_set_rf_he_tb_tx_usage();
1146 return;
1147 }
1148
1149 enable = strtol(argv[1], NULL, 10);
1150 qnum = strtol(argv[2], NULL, 10);
1151 aid = strtol(argv[3], NULL, 10);
1152 axq_mu_timer = strtol(argv[4], NULL, 10);
1153 tx_power = strtol(argv[5], NULL, 10);
1154
1155 ret = wlan_cfg_rf_he_tb_tx(enable, qnum, aid, axq_mu_timer, tx_power);
1156 if (ret == WM_SUCCESS)
1157 {
1158 (void)PRINTF("HE TB Tx configuration successful\r\n");
1159 (void)PRINTF("Enable : %d\r\n", enable);
1160 (void)PRINTF("qnum : %d\r\n", qnum);
1161 (void)PRINTF("aid : %d\r\n", aid);
1162 (void)PRINTF("axq_mu_timer : %d\r\n", axq_mu_timer);
1163 (void)PRINTF("tx_power : %d\r\n", tx_power);
1164 }
1165 else
1166 {
1167 (void)PRINTF("Wrong he tb tx configurations\r\n");
1168 dump_wlan_set_rf_he_tb_tx_usage();
1169 }
1170 }
1171
wlan_rf_radio_mode_set(int argc,char * argv[])1172 static void wlan_rf_radio_mode_set(int argc, char *argv[])
1173 {
1174 int ret;
1175 uint8_t radio_mode;
1176
1177 if (!rf_test_mode)
1178 {
1179 dump_wlan_set_rf_test_mode();
1180 return;
1181 }
1182
1183 if (argc != 2)
1184 {
1185 dump_wlan_set_radio_mode_usage();
1186 return;
1187 }
1188
1189 radio_mode = atoi(argv[1]);
1190 ret = wlan_set_rf_radio_mode(radio_mode);
1191 if (ret == WM_SUCCESS)
1192 {
1193 (void)PRINTF("Set radio mode successful\r\n");
1194 }
1195 else
1196 {
1197 (void)PRINTF("Set radio mode failed!\r\n");
1198 dump_wlan_set_radio_mode_usage();
1199 }
1200 }
1201
dump_wlan_set_otp_mac_addr_usage(void)1202 static void dump_wlan_set_otp_mac_addr_usage(void)
1203 {
1204 (void)PRINTF("Usage:\r\n");
1205 (void)PRINTF("wlan-set-rf-otp-mac-addr <mac_addr> \r\n");
1206 }
1207
wlan_rf_otp_mac_addr_set(int argc,char * argv[])1208 static void wlan_rf_otp_mac_addr_set(int argc, char *argv[])
1209 {
1210 int ret;
1211 uint8_t mac_addr[MLAN_MAC_ADDR_LENGTH];
1212
1213 if (!rf_test_mode)
1214 {
1215 dump_wlan_set_rf_test_mode();
1216 return;
1217 }
1218
1219 if (argc != 2)
1220 {
1221 dump_wlan_set_otp_mac_addr_usage();
1222 return;
1223 }
1224
1225 ret = get_mac(argv[1], (char *)mac_addr, ':');
1226 if (ret != 0)
1227 {
1228 (void)PRINTF("Error: invalid MAC argument\r\n");
1229 return;
1230 }
1231
1232 ret = wlan_set_rf_otp_mac_addr(mac_addr);
1233 if (ret == WM_SUCCESS)
1234 {
1235 (void)PRINTF("OTP MAC address configuration successful\r\n");
1236 }
1237 else
1238 {
1239 (void)PRINTF("OTP MAC address configuration failed\r\n");
1240 dump_wlan_set_otp_mac_addr_usage();
1241 }
1242 }
1243
dump_wlan_get_otp_mac_addr_usage(void)1244 static void dump_wlan_get_otp_mac_addr_usage(void)
1245 {
1246 (void)PRINTF("Usage:\r\n");
1247 (void)PRINTF("wlan-get-rf-otp-mac-addr \r\n");
1248 }
1249
wlan_rf_otp_mac_addr_get(int argc,char * argv[])1250 static void wlan_rf_otp_mac_addr_get(int argc, char *argv[])
1251 {
1252 int ret;
1253 uint8_t mac_addr[MLAN_MAC_ADDR_LENGTH];
1254
1255 if (!rf_test_mode)
1256 {
1257 dump_wlan_set_rf_test_mode();
1258 return;
1259 }
1260
1261 if (argc != 1)
1262 {
1263 dump_wlan_get_otp_mac_addr_usage();
1264 return;
1265 }
1266
1267 ret = wlan_get_rf_otp_mac_addr(mac_addr);
1268 if (ret == WM_SUCCESS)
1269 {
1270 (void)PRINTF("OTP MAC address: %02X:%02X:%02X:%02X:%02X:%02X\r\n", mac_addr[0], mac_addr[1], mac_addr[2],
1271 mac_addr[3], mac_addr[4], mac_addr[5]);
1272 }
1273 else
1274 {
1275 (void)PRINTF("OTP MAC address read failed\r\n");
1276 dump_wlan_get_otp_mac_addr_usage();
1277 }
1278 }
1279
1280 const uint8_t otp_cal_data[] = {
1281 0x01, 0x00, 0x0F, 0x00, 0x88, 0x00, 0x00, 0x20, 0x44, 0x0F, 0x00, 0x00, 0x00, 0x20, 0xFF, 0xFF, 0x40, 0x00,
1282 0x77, 0x00, 0x29, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x6A, 0xB1, 0x02, 0x00, 0x00, 0x3F, 0x01, 0x00,
1283 0x00, 0x0D, 0x00, 0x18, 0x97, 0x53, 0x00, 0x00, 0x00, 0x38, 0x39, 0x22, 0x3C, 0x55, 0xBC, 0x68, 0x6A, 0x37,
1284 0xBE, 0x82, 0x22, 0xB4, 0x41, 0x64, 0x8D, 0xCE, 0x00, 0x1C, 0x9F, 0x37, 0x00, 0x00, 0x00, 0x54, 0x02, 0x04,
1285 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x2D, 0xC6, 0xC0, 0x43, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x50,
1286 0x00, 0x1C, 0x49, 0x5F, 0x00, 0x00, 0x00, 0x70, 0x02, 0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x2D,
1287 0xC6, 0xC0, 0x43, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x50, 0x00, 0x18, 0xB2, 0x68, 0xFF, 0xFF, 0xFF, 0xFF,
1288 0xD3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1289
dump_wlan_set_otp_cal_data_usage(void)1290 static void dump_wlan_set_otp_cal_data_usage(void)
1291 {
1292 (void)PRINTF("Usage:\r\n");
1293 (void)PRINTF("wlan-set-rf-otp-cal-data\r\n");
1294 }
1295
wlan_rf_otp_cal_data_set(int argc,char * argv[])1296 static void wlan_rf_otp_cal_data_set(int argc, char *argv[])
1297 {
1298 int ret;
1299
1300 if (!rf_test_mode)
1301 {
1302 dump_wlan_set_rf_test_mode();
1303 return;
1304 }
1305
1306 ret = wlan_set_rf_otp_cal_data(otp_cal_data, sizeof(otp_cal_data));
1307 if (ret == WM_SUCCESS)
1308 {
1309 (void)PRINTF("OTP cal data configuration successful\r\n");
1310 }
1311 else
1312 {
1313 (void)PRINTF("OTP cal data configuration failed\r\n");
1314 dump_wlan_set_otp_cal_data_usage();
1315 }
1316 }
1317
dump_wlan_get_otp_cal_data_usage(void)1318 static void dump_wlan_get_otp_cal_data_usage(void)
1319 {
1320 (void)PRINTF("Usage:\r\n");
1321 (void)PRINTF("wlan-get-rf-otp-cal-data \r\n");
1322 }
1323
wlan_rf_otp_cal_data_get(int argc,char * argv[])1324 static void wlan_rf_otp_cal_data_get(int argc, char *argv[])
1325 {
1326 int ret;
1327 // int i = 0;
1328 uint8_t *cal_data = NULL;
1329
1330 if (!rf_test_mode)
1331 {
1332 dump_wlan_set_rf_test_mode();
1333 return;
1334 }
1335
1336 if (argc != 1)
1337 {
1338 dump_wlan_get_otp_cal_data_usage();
1339 return;
1340 }
1341
1342 cal_data = (uint8_t *)OSA_MemoryAllocate(CAL_DATA_LEN);
1343 if (!cal_data)
1344 {
1345 (void)PRINTF("Error: failed to alloc memory!\r\n");
1346 return;
1347 }
1348
1349 ret = wlan_get_rf_otp_cal_data(cal_data);
1350 if (ret == WM_SUCCESS)
1351 {
1352 (void)PRINTF("OTP cal data read successfully: 1\r\n");
1353 #if 0
1354 while (i < CAL_DATA_LEN)
1355 {
1356 (void)PRINTF("%02x ", cal_data[i++]);
1357 if (!(i % 16))
1358 {
1359 (void)PRINTF("\r\n");
1360 }
1361 }
1362 #endif
1363 }
1364 else
1365 {
1366 (void)PRINTF("OTP cal data read failed: 0\r\n");
1367 dump_wlan_get_otp_cal_data_usage();
1368 }
1369
1370 (void)OSA_MemoryFree(cal_data);
1371 }
1372
1373 static struct cli_command wlan_test_mode_commands[] = {
1374 {"wlan-set-rf-test-mode", NULL, wlan_rf_test_mode_set},
1375 {"wlan-unset-rf-test-mode", NULL, wlan_rf_test_mode_unset},
1376 {"wlan-set-rf-tx-antenna", "<antenna>", wlan_rf_tx_antenna_set},
1377 {"wlan-get-rf-tx-antenna", NULL, wlan_rf_tx_antenna_get},
1378 {"wlan-set-rf-rx-antenna", "<antenna>", wlan_rf_rx_antenna_set},
1379 {"wlan-get-rf-rx-antenna", NULL, wlan_rf_rx_antenna_get},
1380 {"wlan-set-rf-band", "<band>", wlan_rf_band_set},
1381 {"wlan-get-rf-band", NULL, wlan_rf_band_get},
1382 {"wlan-set-rf-bandwidth", "<bandwidth>", wlan_rf_bandwidth_set},
1383 {"wlan-get-rf-bandwidth", NULL, wlan_rf_bandwidth_get},
1384 {"wlan-set-rf-channel", "<channel>", wlan_rf_channel_set},
1385 {"wlan-get-rf-channel", NULL, wlan_rf_channel_get},
1386 {"wlan-set-rf-radio-mode", "<radio_mode>", wlan_rf_radio_mode_set},
1387 {"wlan-get-rf-radio-mode", NULL, wlan_rf_radio_mode_get},
1388 {"wlan-set-rf-tx-power", "<tx_power> <modulation> <path_id>", wlan_rf_tx_power_set},
1389 {"wlan-set-rf-tx-cont-mode", "<enable_tx> <cw_mode> <payload_pattern> <cs_mode> <act_sub_ch> <tx_rate>",
1390 wlan_rf_tx_cont_mode_set},
1391 {"wlan-set-rf-tx-frame",
1392 "<start> <data_rate> <frame_pattern> <frame_len> <adjust_burst_sifs> <burst_sifs_in_us> <short_preamble> "
1393 "<act_sub_ch> <short_gi> <adv_coding> <tx_bf> <gf_mode> <stbc> <bssid>",
1394 wlan_rf_tx_frame_set},
1395 {"wlan-set-rf-trigger-frame-cfg",
1396 "<Enable_tx> <Standalone_hetb> <FRAME_CTRL_TYPE> <FRAME_CTRL_SUBTYPE> <FRAME_DURATION>"
1397 "<TriggerType> <UlLen> <MoreTF> <CSRequired> <UlBw> <LTFType> <LTFMode>"
1398 "<LTFSymbol> <UlSTBC> <LdpcESS> <ApTxPwr> <PreFecPadFct> <PeDisambig> <SpatialReuse>"
1399 "<Doppler> <HeSig2> <AID12> <RUAllocReg> <RUAlloc> <UlCodingType> <UlMCS> <UlDCM>"
1400 "<SSAlloc> <UlTargetRSSI> <MPDU_MU_SF> <TID_AL> <AC_PL> <Pref_AC> ",
1401 wlan_set_rf_trigger_frame_cfg},
1402 {"wlan-set-rf-he-tb-tx", "<enable> <qnum> <aid> <axq_mu_timer> <tx_power>", wlan_set_rf_he_tb_tx},
1403 {"wlan-get-and-reset-rf-per", NULL, wlan_rf_per_get},
1404 {"wlan-set-rf-otp-mac-addr", "<mac_addr>", wlan_rf_otp_mac_addr_set},
1405 {"wlan-get-rf-otp-mac-addr", NULL, wlan_rf_otp_mac_addr_get},
1406 {"wlan-set-rf-otp-cal-data", NULL, wlan_rf_otp_cal_data_set},
1407 {"wlan-get-rf-otp-cal-data", NULL, wlan_rf_otp_cal_data_get},
1408 };
1409
wlan_test_mode_cli_init(void)1410 int wlan_test_mode_cli_init(void)
1411 {
1412 if (cli_register_commands(wlan_test_mode_commands, sizeof(wlan_test_mode_commands) / sizeof(struct cli_command)) !=
1413 0U)
1414 {
1415 return -WM_FAIL;
1416 }
1417
1418 return WM_SUCCESS;
1419 }
1420
wlan_test_mode_cli_deinit(void)1421 int wlan_test_mode_cli_deinit(void)
1422 {
1423 if (cli_unregister_commands(wlan_test_mode_commands,
1424 sizeof(wlan_test_mode_commands) / sizeof(struct cli_command)) != 0U)
1425 {
1426 return -WM_FAIL;
1427 }
1428
1429 return WM_SUCCESS;
1430 }
1431 #endif
1432