developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1 | /* Copyright (C) 2021 Mediatek Inc. */ |
| 2 | #define _GNU_SOURCE |
| 3 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 4 | #include <net/if.h> |
| 5 | |
| 6 | #include "mt76-vendor.h" |
| 7 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 8 | static const char *progname; |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 9 | struct unl unl; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 10 | |
| 11 | void usage(void) |
| 12 | { |
| 13 | static const char *const commands[] = { |
developer | dbc4357 | 2021-06-23 17:20:30 +0800 | [diff] [blame] | 14 | "set csi ctrl=<opt1>,<opt2>,<opt3>,<opt4> (macaddr=<macaddr>)", |
| 15 | "set csi interval=<interval (us)>", |
| 16 | "dump csi <packet num> <filename>", |
developer | e53f087 | 2021-07-23 11:13:49 +0800 | [diff] [blame] | 17 | |
| 18 | "set amnt <index>(0x0~0xf) <mac addr>(xx:xx:xx:xx:xx:xx)", |
developer | 5f18e6c | 2021-07-28 11:55:08 +0800 | [diff] [blame] | 19 | "dump amnt <index> (0x0~0xf or 0xff)", |
| 20 | |
| 21 | "set ap_rfeatures he_gi=<val>", |
| 22 | "set ap_rfeatures he_ltf=<val>", |
developer | 13aaa77 | 2021-09-27 18:09:26 +0800 | [diff] [blame] | 23 | "set ap_rfeatures trig_type=<enable>,<val> (val: 0-7)", |
| 24 | "set ap_rfeatures ack_policy=<val> (val: 0-4)", |
developer | 5f18e6c | 2021-07-28 11:55:08 +0800 | [diff] [blame] | 25 | "set ap_wireless fixed_mcs=<val>", |
developer | 507ff0c | 2021-07-30 14:51:55 +0800 | [diff] [blame] | 26 | "set ap_wireless ofdma=<val> (0: disable, 1: DL, 2: UL)", |
developer | b72be59 | 2021-08-16 10:58:59 +0800 | [diff] [blame] | 27 | "set ap_wireless nusers_ofdma=<val>", |
| 28 | "set ap_wireless ppdu_type=<val> (0: SU, 1: MU, 4: LEGACY)", |
developer | 786d929 | 2021-09-22 11:03:21 +0800 | [diff] [blame] | 29 | "set ap_wireless add_ba_req_bufsize=<val>", |
| 30 | "set ap_wireless mimo=<val> (0: DL, 1: UL)", |
developer | 13aaa77 | 2021-09-27 18:09:26 +0800 | [diff] [blame] | 31 | "set ap_wireless ampdu=<enable>", |
| 32 | "set ap_wireless amsdu=<enable>", |
developer | 07ede8d | 2021-11-16 18:31:21 +0800 | [diff] [blame] | 33 | "set ap_wireless cert=<enable>", |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 34 | }; |
| 35 | int i; |
| 36 | |
| 37 | fprintf(stderr, "Usage:\n"); |
| 38 | for (i = 0; i < ARRAY_SIZE(commands); i++) |
| 39 | printf(" %s wlanX %s\n", progname, commands[i]); |
| 40 | |
| 41 | exit(1); |
| 42 | } |
| 43 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 44 | int main(int argc, char **argv) |
| 45 | { |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 46 | const char *cmd, *subcmd; |
| 47 | int if_idx, ret = 0; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 48 | |
| 49 | progname = argv[0]; |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 50 | if (argc < 4) |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 51 | usage(); |
| 52 | |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 53 | if_idx = if_nametoindex(argv[1]); |
| 54 | if (!if_idx) { |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 55 | fprintf(stderr, "%s\n", strerror(errno)); |
| 56 | return 2; |
| 57 | } |
| 58 | |
| 59 | cmd = argv[2]; |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 60 | subcmd = argv[3]; |
| 61 | argv += 4; |
| 62 | argc -= 4; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 63 | |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 64 | if (!strncmp(cmd, "dump", 4)) { |
| 65 | if (!strncmp(subcmd, "csi", 3)) |
| 66 | ret = mt76_csi_dump(if_idx, argc, argv); |
developer | e53f087 | 2021-07-23 11:13:49 +0800 | [diff] [blame] | 67 | else if (!strncmp(subcmd, "amnt", 4)) |
| 68 | ret = mt76_amnt_dump(if_idx, argc, argv); |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 69 | } else if (!strncmp(cmd, "set", 3)) { |
| 70 | if (!strncmp(subcmd, "csi", 3)) |
| 71 | ret = mt76_csi_set(if_idx, argc, argv); |
developer | e53f087 | 2021-07-23 11:13:49 +0800 | [diff] [blame] | 72 | else if (!strncmp(subcmd, "amnt", 4)) |
| 73 | ret = mt76_amnt_set(if_idx, argc, argv); |
developer | 5f18e6c | 2021-07-28 11:55:08 +0800 | [diff] [blame] | 74 | else if (!strncmp(subcmd, "ap_rfeatures", 12)) |
| 75 | ret = mt76_ap_rfeatures_set(if_idx, argc, argv); |
| 76 | else if (!strncmp(subcmd, "ap_wireless", 11)) |
| 77 | ret = mt76_ap_wireless_set(if_idx, argc, argv); |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 78 | } else { |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 79 | usage(); |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 80 | } |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 81 | |
| 82 | return ret; |
| 83 | } |