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