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 | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 17 | }; |
| 18 | int i; |
| 19 | |
| 20 | fprintf(stderr, "Usage:\n"); |
| 21 | for (i = 0; i < ARRAY_SIZE(commands); i++) |
| 22 | printf(" %s wlanX %s\n", progname, commands[i]); |
| 23 | |
| 24 | exit(1); |
| 25 | } |
| 26 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 27 | int main(int argc, char **argv) |
| 28 | { |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 29 | const char *cmd, *subcmd; |
| 30 | int if_idx, ret = 0; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 31 | |
| 32 | progname = argv[0]; |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 33 | if (argc < 4) |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 34 | usage(); |
| 35 | |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 36 | if_idx = if_nametoindex(argv[1]); |
| 37 | if (!if_idx) { |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 38 | fprintf(stderr, "%s\n", strerror(errno)); |
| 39 | return 2; |
| 40 | } |
| 41 | |
| 42 | cmd = argv[2]; |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 43 | subcmd = argv[3]; |
| 44 | argv += 4; |
| 45 | argc -= 4; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 46 | |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 47 | if (!strncmp(cmd, "dump", 4)) { |
| 48 | if (!strncmp(subcmd, "csi", 3)) |
| 49 | ret = mt76_csi_dump(if_idx, argc, argv); |
| 50 | } else if (!strncmp(cmd, "set", 3)) { |
| 51 | if (!strncmp(subcmd, "csi", 3)) |
| 52 | ret = mt76_csi_set(if_idx, argc, argv); |
| 53 | } else { |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 54 | usage(); |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 55 | } |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 56 | |
| 57 | return ret; |
| 58 | } |