developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: ISC |
| 2 | /* Copyright (C) 2020 Felix Fietkau <nbd@nbd.name> */ |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 3 | #ifndef __MT76_VENDOR_H |
| 4 | #define __MT76_VENDOR_H |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 5 | |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 6 | #include <errno.h> |
| 7 | #include <linux/nl80211.h> |
| 8 | #include <netlink/attr.h> |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 9 | #include <stdbool.h> |
| 10 | #include <stdint.h> |
| 11 | #include <stdio.h> |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 12 | #include <unl.h> |
| 13 | |
| 14 | typedef uint8_t u8; |
| 15 | typedef uint16_t u16; |
| 16 | typedef uint32_t u32; |
| 17 | typedef uint64_t u64; |
| 18 | typedef int8_t s8; |
| 19 | typedef int16_t s16; |
| 20 | typedef int32_t s32; |
| 21 | typedef int64_t s64, ktime_t; |
| 22 | |
| 23 | #define MTK_NL80211_VENDOR_ID 0x0ce7 |
| 24 | |
| 25 | #ifndef ARRAY_SIZE |
| 26 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) |
| 27 | #endif |
| 28 | |
| 29 | #ifndef DIV_ROUND_UP |
| 30 | #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) |
| 31 | #endif |
| 32 | |
| 33 | struct nl_msg; |
| 34 | struct nlattr; |
| 35 | |
| 36 | enum mtk_nl80211_vendor_subcmds { |
developer | e53f087 | 2021-07-23 11:13:49 +0800 | [diff] [blame] | 37 | MTK_NL80211_VENDOR_SUBCMD_AMNT_CTRL = 0xae, |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 38 | MTK_NL80211_VENDOR_SUBCMD_CSI_CTRL = 0xc2, |
developer | 5f18e6c | 2021-07-28 11:55:08 +0800 | [diff] [blame] | 39 | MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL = 0xc3, |
| 40 | MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL = 0xc4, |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | enum mtk_vendor_attr_csi_ctrl { |
| 44 | MTK_VENDOR_ATTR_CSI_CTRL_UNSPEC, |
| 45 | |
| 46 | MTK_VENDOR_ATTR_CSI_CTRL_CFG, |
| 47 | MTK_VENDOR_ATTR_CSI_CTRL_CFG_MODE, |
| 48 | MTK_VENDOR_ATTR_CSI_CTRL_CFG_TYPE, |
| 49 | MTK_VENDOR_ATTR_CSI_CTRL_CFG_VAL1, |
| 50 | MTK_VENDOR_ATTR_CSI_CTRL_CFG_VAL2, |
| 51 | MTK_VENDOR_ATTR_CSI_CTRL_MAC_ADDR, |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 52 | MTK_VENDOR_ATTR_CSI_CTRL_INTERVAL, |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 53 | |
| 54 | MTK_VENDOR_ATTR_CSI_CTRL_DUMP_NUM, |
| 55 | |
| 56 | MTK_VENDOR_ATTR_CSI_CTRL_DATA, |
| 57 | |
| 58 | /* keep last */ |
| 59 | NUM_MTK_VENDOR_ATTRS_CSI_CTRL, |
| 60 | MTK_VENDOR_ATTR_CSI_CTRL_MAX = |
| 61 | NUM_MTK_VENDOR_ATTRS_CSI_CTRL - 1 |
| 62 | }; |
| 63 | |
| 64 | enum mtk_vendor_attr_csi_data { |
| 65 | MTK_VENDOR_ATTR_CSI_DATA_UNSPEC, |
| 66 | MTK_VENDOR_ATTR_CSI_DATA_PAD, |
| 67 | |
| 68 | MTK_VENDOR_ATTR_CSI_DATA_VER, |
| 69 | MTK_VENDOR_ATTR_CSI_DATA_TS, |
| 70 | MTK_VENDOR_ATTR_CSI_DATA_RSSI, |
| 71 | MTK_VENDOR_ATTR_CSI_DATA_SNR, |
| 72 | MTK_VENDOR_ATTR_CSI_DATA_BW, |
| 73 | MTK_VENDOR_ATTR_CSI_DATA_CH_IDX, |
| 74 | MTK_VENDOR_ATTR_CSI_DATA_TA, |
| 75 | MTK_VENDOR_ATTR_CSI_DATA_I, |
| 76 | MTK_VENDOR_ATTR_CSI_DATA_Q, |
| 77 | MTK_VENDOR_ATTR_CSI_DATA_INFO, |
| 78 | MTK_VENDOR_ATTR_CSI_DATA_RSVD1, |
| 79 | MTK_VENDOR_ATTR_CSI_DATA_RSVD2, |
| 80 | MTK_VENDOR_ATTR_CSI_DATA_RSVD3, |
| 81 | MTK_VENDOR_ATTR_CSI_DATA_RSVD4, |
| 82 | MTK_VENDOR_ATTR_CSI_DATA_TX_ANT, |
| 83 | MTK_VENDOR_ATTR_CSI_DATA_RX_ANT, |
| 84 | MTK_VENDOR_ATTR_CSI_DATA_MODE, |
| 85 | MTK_VENDOR_ATTR_CSI_DATA_H_IDX, |
| 86 | |
| 87 | /* keep last */ |
| 88 | NUM_MTK_VENDOR_ATTRS_CSI_DATA, |
| 89 | MTK_VENDOR_ATTR_CSI_DATA_MAX = |
| 90 | NUM_MTK_VENDOR_ATTRS_CSI_DATA - 1 |
| 91 | }; |
| 92 | |
developer | e53f087 | 2021-07-23 11:13:49 +0800 | [diff] [blame] | 93 | enum mtk_vendor_attr_mnt_ctrl { |
| 94 | MTK_VENDOR_ATTR_AMNT_CTRL_UNSPEC, |
| 95 | |
| 96 | MTK_VENDOR_ATTR_AMNT_CTRL_SET, |
| 97 | MTK_VENDOR_ATTR_AMNT_CTRL_DUMP, |
| 98 | /* keep last */ |
| 99 | NUM_MTK_VENDOR_ATTRS_AMNT_CTRL, |
| 100 | MTK_VENDOR_ATTR_AMNT_CTRL_MAX = |
| 101 | NUM_MTK_VENDOR_ATTRS_AMNT_CTRL - 1 |
| 102 | }; |
| 103 | |
| 104 | enum mtk_vendor_attr_mnt_set { |
| 105 | MTK_VENDOR_ATTR_AMNT_SET_UNSPEC, |
| 106 | |
| 107 | MTK_VENDOR_ATTR_AMNT_SET_INDEX, |
| 108 | MTK_VENDOR_ATTR_AMNT_SET_MACADDR, |
| 109 | |
| 110 | /* keep last */ |
| 111 | NUM_MTK_VENDOR_ATTRS_AMNT_SET, |
| 112 | MTK_VENDOR_ATTR_AMNT_SET_MAX = |
| 113 | NUM_MTK_VENDOR_ATTRS_AMNT_SET - 1 |
| 114 | }; |
| 115 | |
| 116 | enum mtk_vendor_attr_mnt_dump { |
| 117 | MTK_VENDOR_ATTR_AMNT_DUMP_UNSPEC, |
| 118 | |
| 119 | MTK_VENDOR_ATTR_AMNT_DUMP_INDEX, |
| 120 | MTK_VENDOR_ATTR_AMNT_DUMP_LEN, |
| 121 | MTK_VENDOR_ATTR_AMNT_DUMP_RESULT, |
| 122 | |
| 123 | /* keep last */ |
| 124 | NUM_MTK_VENDOR_ATTRS_AMNT_DUMP, |
| 125 | MTK_VENDOR_ATTR_AMNT_DUMP_MAX = |
| 126 | NUM_MTK_VENDOR_ATTRS_AMNT_DUMP - 1 |
| 127 | }; |
| 128 | |
developer | 5f18e6c | 2021-07-28 11:55:08 +0800 | [diff] [blame] | 129 | enum mtk_vendor_attr_wireless_ctrl { |
| 130 | MTK_VENDOR_ATTR_WIRELESS_CTRL_UNSPEC, |
| 131 | |
| 132 | MTK_VENDOR_ATTR_WIRELESS_CTRL_FIXED_MCS, |
developer | 507ff0c | 2021-07-30 14:51:55 +0800 | [diff] [blame] | 133 | MTK_VENDOR_ATTR_WIRELESS_CTRL_FIXED_OFDMA, |
developer | b72be59 | 2021-08-16 10:58:59 +0800 | [diff] [blame] | 134 | MTK_VENDOR_ATTR_WIRELESS_CTRL_PPDU_TX_TYPE, |
| 135 | MTK_VENDOR_ATTR_WIRELESS_CTRL_NUSERS_OFDMA, |
developer | 786d929 | 2021-09-22 11:03:21 +0800 | [diff] [blame] | 136 | MTK_VENDOR_ATTR_WIRELESS_CTRL_BA_BUFFER_SIZE, |
| 137 | MTK_VENDOR_ATTR_WIRELESS_CTRL_MIMO, |
developer | 3a5765c | 2021-09-23 16:19:12 +0800 | [diff] [blame] | 138 | MTK_VENDOR_ATTR_WIRELESS_CTRL_AMPDU, |
| 139 | MTK_VENDOR_ATTR_WIRELESS_CTRL_AMSDU, |
developer | 07ede8d | 2021-11-16 18:31:21 +0800 | [diff] [blame] | 140 | MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT, |
developer | 5f18e6c | 2021-07-28 11:55:08 +0800 | [diff] [blame] | 141 | |
| 142 | /* keep last */ |
| 143 | NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL, |
| 144 | MTK_VENDOR_ATTR_WIRELESS_CTRL_MAX = |
| 145 | NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL - 1 |
| 146 | }; |
| 147 | |
| 148 | enum mtk_vendor_attr_rfeature_ctrl { |
| 149 | MTK_VENDOR_ATTR_RFEATURE_CTRL_UNSPEC, |
| 150 | |
| 151 | MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_GI, |
| 152 | MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_LTF, |
developer | 13aaa77 | 2021-09-27 18:09:26 +0800 | [diff] [blame] | 153 | MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE_CFG, |
| 154 | MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE_EN, |
developer | 31b1a28 | 2021-08-04 14:13:00 +0800 | [diff] [blame] | 155 | MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE, |
| 156 | MTK_VENDOR_ATTR_RFEATURE_CTRL_ACK_PLCY, |
developer | 5f18e6c | 2021-07-28 11:55:08 +0800 | [diff] [blame] | 157 | |
| 158 | /* keep last */ |
| 159 | NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL, |
| 160 | MTK_VENDOR_ATTR_RFEATURE_CTRL_MAX = |
| 161 | NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL - 1 |
| 162 | }; |
| 163 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 164 | #define CSI_MAX_COUNT 256 |
| 165 | #define ETH_ALEN 6 |
| 166 | |
| 167 | struct csi_data { |
| 168 | s16 data_i[CSI_MAX_COUNT]; |
| 169 | s16 data_q[CSI_MAX_COUNT]; |
| 170 | s8 rssi; |
| 171 | u8 snr; |
developer | a1e20de | 2021-06-17 10:33:53 +0800 | [diff] [blame] | 172 | u32 ts; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 173 | u8 data_bw; |
| 174 | u8 pri_ch_idx; |
| 175 | u8 ta[ETH_ALEN]; |
| 176 | u32 info; |
| 177 | u8 rx_mode; |
| 178 | u32 h_idx; |
| 179 | u16 tx_idx; |
| 180 | u16 rx_idx; |
| 181 | }; |
| 182 | |
developer | e53f087 | 2021-07-23 11:13:49 +0800 | [diff] [blame] | 183 | struct amnt_data { |
| 184 | u8 idx; |
| 185 | u8 addr[ETH_ALEN]; |
| 186 | s8 rssi[4]; |
| 187 | u32 last_seen; |
| 188 | }; |
| 189 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 190 | extern struct unl unl; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 191 | |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 192 | int mt76_csi_set(int idx, int argc, char **argv); |
| 193 | int mt76_csi_dump(int idx, int argc, char **argv); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 194 | |
developer | e53f087 | 2021-07-23 11:13:49 +0800 | [diff] [blame] | 195 | int mt76_amnt_set(int idx, int argc, char **argv); |
| 196 | int mt76_amnt_dump(int idx, int argc, char **argv); |
| 197 | |
developer | 5f18e6c | 2021-07-28 11:55:08 +0800 | [diff] [blame] | 198 | int mt76_ap_rfeatures_set(int idx, int argc, char **argv); |
| 199 | int mt76_ap_wireless_set(int idx, int argc, char **argv); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 200 | #endif |