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 | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 41 | MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5, |
developer | 29b831d | 2022-06-21 10:01:42 -0700 | [diff] [blame] | 42 | MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL = 0xc6, |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | enum mtk_vendor_attr_csi_ctrl { |
| 46 | MTK_VENDOR_ATTR_CSI_CTRL_UNSPEC, |
| 47 | |
| 48 | MTK_VENDOR_ATTR_CSI_CTRL_CFG, |
| 49 | MTK_VENDOR_ATTR_CSI_CTRL_CFG_MODE, |
| 50 | MTK_VENDOR_ATTR_CSI_CTRL_CFG_TYPE, |
| 51 | MTK_VENDOR_ATTR_CSI_CTRL_CFG_VAL1, |
| 52 | MTK_VENDOR_ATTR_CSI_CTRL_CFG_VAL2, |
| 53 | MTK_VENDOR_ATTR_CSI_CTRL_MAC_ADDR, |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 54 | MTK_VENDOR_ATTR_CSI_CTRL_INTERVAL, |
developer | 0fad892 | 2023-11-28 20:15:39 +0800 | [diff] [blame] | 55 | MTK_VENDOR_ATTR_CSI_CTRL_STA_INTERVAL, |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 56 | |
| 57 | MTK_VENDOR_ATTR_CSI_CTRL_DUMP_NUM, |
| 58 | |
| 59 | MTK_VENDOR_ATTR_CSI_CTRL_DATA, |
| 60 | |
| 61 | /* keep last */ |
| 62 | NUM_MTK_VENDOR_ATTRS_CSI_CTRL, |
| 63 | MTK_VENDOR_ATTR_CSI_CTRL_MAX = |
| 64 | NUM_MTK_VENDOR_ATTRS_CSI_CTRL - 1 |
| 65 | }; |
| 66 | |
| 67 | enum mtk_vendor_attr_csi_data { |
| 68 | MTK_VENDOR_ATTR_CSI_DATA_UNSPEC, |
| 69 | MTK_VENDOR_ATTR_CSI_DATA_PAD, |
| 70 | |
| 71 | MTK_VENDOR_ATTR_CSI_DATA_VER, |
| 72 | MTK_VENDOR_ATTR_CSI_DATA_TS, |
| 73 | MTK_VENDOR_ATTR_CSI_DATA_RSSI, |
| 74 | MTK_VENDOR_ATTR_CSI_DATA_SNR, |
| 75 | MTK_VENDOR_ATTR_CSI_DATA_BW, |
| 76 | MTK_VENDOR_ATTR_CSI_DATA_CH_IDX, |
| 77 | MTK_VENDOR_ATTR_CSI_DATA_TA, |
developer | 0fad892 | 2023-11-28 20:15:39 +0800 | [diff] [blame] | 78 | MTK_VENDOR_ATTR_CSI_DATA_NUM, |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 79 | MTK_VENDOR_ATTR_CSI_DATA_I, |
| 80 | MTK_VENDOR_ATTR_CSI_DATA_Q, |
| 81 | MTK_VENDOR_ATTR_CSI_DATA_INFO, |
| 82 | MTK_VENDOR_ATTR_CSI_DATA_RSVD1, |
| 83 | MTK_VENDOR_ATTR_CSI_DATA_RSVD2, |
| 84 | MTK_VENDOR_ATTR_CSI_DATA_RSVD3, |
| 85 | MTK_VENDOR_ATTR_CSI_DATA_RSVD4, |
| 86 | MTK_VENDOR_ATTR_CSI_DATA_TX_ANT, |
| 87 | MTK_VENDOR_ATTR_CSI_DATA_RX_ANT, |
| 88 | MTK_VENDOR_ATTR_CSI_DATA_MODE, |
developer | 0fad892 | 2023-11-28 20:15:39 +0800 | [diff] [blame] | 89 | MTK_VENDOR_ATTR_CSI_DATA_CHAIN_INFO, |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 90 | |
| 91 | /* keep last */ |
| 92 | NUM_MTK_VENDOR_ATTRS_CSI_DATA, |
| 93 | MTK_VENDOR_ATTR_CSI_DATA_MAX = |
| 94 | NUM_MTK_VENDOR_ATTRS_CSI_DATA - 1 |
| 95 | }; |
| 96 | |
developer | e53f087 | 2021-07-23 11:13:49 +0800 | [diff] [blame] | 97 | enum mtk_vendor_attr_mnt_ctrl { |
| 98 | MTK_VENDOR_ATTR_AMNT_CTRL_UNSPEC, |
| 99 | |
| 100 | MTK_VENDOR_ATTR_AMNT_CTRL_SET, |
| 101 | MTK_VENDOR_ATTR_AMNT_CTRL_DUMP, |
| 102 | /* keep last */ |
| 103 | NUM_MTK_VENDOR_ATTRS_AMNT_CTRL, |
| 104 | MTK_VENDOR_ATTR_AMNT_CTRL_MAX = |
| 105 | NUM_MTK_VENDOR_ATTRS_AMNT_CTRL - 1 |
| 106 | }; |
| 107 | |
| 108 | enum mtk_vendor_attr_mnt_set { |
| 109 | MTK_VENDOR_ATTR_AMNT_SET_UNSPEC, |
| 110 | |
| 111 | MTK_VENDOR_ATTR_AMNT_SET_INDEX, |
| 112 | MTK_VENDOR_ATTR_AMNT_SET_MACADDR, |
| 113 | |
| 114 | /* keep last */ |
| 115 | NUM_MTK_VENDOR_ATTRS_AMNT_SET, |
| 116 | MTK_VENDOR_ATTR_AMNT_SET_MAX = |
| 117 | NUM_MTK_VENDOR_ATTRS_AMNT_SET - 1 |
| 118 | }; |
| 119 | |
| 120 | enum mtk_vendor_attr_mnt_dump { |
| 121 | MTK_VENDOR_ATTR_AMNT_DUMP_UNSPEC, |
| 122 | |
| 123 | MTK_VENDOR_ATTR_AMNT_DUMP_INDEX, |
| 124 | MTK_VENDOR_ATTR_AMNT_DUMP_LEN, |
| 125 | MTK_VENDOR_ATTR_AMNT_DUMP_RESULT, |
| 126 | |
| 127 | /* keep last */ |
| 128 | NUM_MTK_VENDOR_ATTRS_AMNT_DUMP, |
| 129 | MTK_VENDOR_ATTR_AMNT_DUMP_MAX = |
| 130 | NUM_MTK_VENDOR_ATTRS_AMNT_DUMP - 1 |
| 131 | }; |
| 132 | |
developer | 5f18e6c | 2021-07-28 11:55:08 +0800 | [diff] [blame] | 133 | enum mtk_vendor_attr_wireless_ctrl { |
| 134 | MTK_VENDOR_ATTR_WIRELESS_CTRL_UNSPEC, |
| 135 | |
| 136 | MTK_VENDOR_ATTR_WIRELESS_CTRL_FIXED_MCS, |
developer | 507ff0c | 2021-07-30 14:51:55 +0800 | [diff] [blame] | 137 | MTK_VENDOR_ATTR_WIRELESS_CTRL_FIXED_OFDMA, |
developer | b72be59 | 2021-08-16 10:58:59 +0800 | [diff] [blame] | 138 | MTK_VENDOR_ATTR_WIRELESS_CTRL_PPDU_TX_TYPE, |
| 139 | MTK_VENDOR_ATTR_WIRELESS_CTRL_NUSERS_OFDMA, |
developer | 786d929 | 2021-09-22 11:03:21 +0800 | [diff] [blame] | 140 | MTK_VENDOR_ATTR_WIRELESS_CTRL_BA_BUFFER_SIZE, |
| 141 | MTK_VENDOR_ATTR_WIRELESS_CTRL_MIMO, |
developer | 3a5765c | 2021-09-23 16:19:12 +0800 | [diff] [blame] | 142 | MTK_VENDOR_ATTR_WIRELESS_CTRL_AMPDU, |
| 143 | MTK_VENDOR_ATTR_WIRELESS_CTRL_AMSDU, |
developer | 07ede8d | 2021-11-16 18:31:21 +0800 | [diff] [blame] | 144 | MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT, |
developer | a98a5ea | 2023-01-24 14:23:34 +0800 | [diff] [blame] | 145 | MTK_VENDOR_ATTR_WIRELESS_CTRL_RTS_SIGTA, |
developer | 5f18e6c | 2021-07-28 11:55:08 +0800 | [diff] [blame] | 146 | |
| 147 | /* keep last */ |
| 148 | NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL, |
| 149 | MTK_VENDOR_ATTR_WIRELESS_CTRL_MAX = |
| 150 | NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL - 1 |
| 151 | }; |
| 152 | |
developer | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 153 | enum mtk_vendor_attr_mu_ctrl { |
| 154 | MTK_VENDOR_ATTR_MU_CTRL_UNSPEC, |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 155 | |
developer | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 156 | MTK_VENDOR_ATTR_MU_CTRL_ONOFF, |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 157 | |
| 158 | /* keep last */ |
developer | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 159 | NUM_MTK_VENDOR_ATTRS_MU_CTRL, |
| 160 | MTK_VENDOR_ATTR_MU_CTRL_MAX = |
| 161 | NUM_MTK_VENDOR_ATTRS_MU_CTRL - 1 |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 162 | }; |
| 163 | |
developer | 5f18e6c | 2021-07-28 11:55:08 +0800 | [diff] [blame] | 164 | enum mtk_vendor_attr_rfeature_ctrl { |
| 165 | MTK_VENDOR_ATTR_RFEATURE_CTRL_UNSPEC, |
| 166 | |
| 167 | MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_GI, |
| 168 | MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_LTF, |
developer | 13aaa77 | 2021-09-27 18:09:26 +0800 | [diff] [blame] | 169 | MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE_CFG, |
| 170 | MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE_EN, |
developer | 31b1a28 | 2021-08-04 14:13:00 +0800 | [diff] [blame] | 171 | MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE, |
| 172 | MTK_VENDOR_ATTR_RFEATURE_CTRL_ACK_PLCY, |
developer | 5f18e6c | 2021-07-28 11:55:08 +0800 | [diff] [blame] | 173 | |
| 174 | /* keep last */ |
| 175 | NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL, |
| 176 | MTK_VENDOR_ATTR_RFEATURE_CTRL_MAX = |
| 177 | NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL - 1 |
| 178 | }; |
| 179 | |
developer | 29b831d | 2022-06-21 10:01:42 -0700 | [diff] [blame] | 180 | enum mtk_vendor_attr_phy_capa_ctrl { |
| 181 | MTK_VENDOR_ATTR_PHY_CAPA_CTRL_UNSPEC, |
| 182 | |
| 183 | MTK_VENDOR_ATTR_PHY_CAPA_CTRL_SET, |
| 184 | MTK_VENDOR_ATTR_PHY_CAPA_CTRL_DUMP, |
| 185 | |
| 186 | /* keep last */ |
| 187 | NUM_MTK_VENDOR_ATTRS_PHY_CAPA_CTRL, |
| 188 | MTK_VENDOR_ATTR_PHY_CAPA_CTRL_MAX = |
| 189 | NUM_MTK_VENDOR_ATTRS_PHY_CAPA_CTRL - 1 |
| 190 | }; |
| 191 | |
| 192 | enum mtk_vendor_attr_phy_capa_dump { |
| 193 | MTK_VENDOR_ATTR_PHY_CAPA_DUMP_UNSPEC, |
| 194 | |
| 195 | MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX_SUPPORTED_BSS, |
| 196 | MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX_SUPPORTED_STA, |
| 197 | |
| 198 | /* keep last */ |
| 199 | NUM_MTK_VENDOR_ATTRS_PHY_CAPA_DUMP, |
| 200 | MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX = |
| 201 | NUM_MTK_VENDOR_ATTRS_PHY_CAPA_DUMP - 1 |
| 202 | }; |
| 203 | |
developer | 0fad892 | 2023-11-28 20:15:39 +0800 | [diff] [blame] | 204 | #define CSI_BW20_DATA_COUNT 64 |
| 205 | #define CSI_BW40_DATA_COUNT 128 |
| 206 | #define CSI_BW80_DATA_COUNT 256 |
| 207 | #define CSI_BW160_DATA_COUNT 512 |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 208 | #define ETH_ALEN 6 |
| 209 | |
| 210 | struct csi_data { |
developer | 0fad892 | 2023-11-28 20:15:39 +0800 | [diff] [blame] | 211 | u8 ch_bw; |
| 212 | u16 data_num; |
| 213 | s16 data_i[CSI_BW160_DATA_COUNT]; |
| 214 | s16 data_q[CSI_BW160_DATA_COUNT]; |
| 215 | u8 band; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 216 | s8 rssi; |
| 217 | u8 snr; |
developer | a1e20de | 2021-06-17 10:33:53 +0800 | [diff] [blame] | 218 | u32 ts; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 219 | u8 data_bw; |
| 220 | u8 pri_ch_idx; |
| 221 | u8 ta[ETH_ALEN]; |
developer | 0fad892 | 2023-11-28 20:15:39 +0800 | [diff] [blame] | 222 | u32 ext_info; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 223 | u8 rx_mode; |
developer | 0fad892 | 2023-11-28 20:15:39 +0800 | [diff] [blame] | 224 | u32 chain_info; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 225 | u16 tx_idx; |
| 226 | u16 rx_idx; |
developer | 0fad892 | 2023-11-28 20:15:39 +0800 | [diff] [blame] | 227 | u32 segment_num; |
| 228 | u8 remain_last; |
| 229 | u16 pkt_sn; |
| 230 | u8 tr_stream; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 231 | }; |
| 232 | |
developer | e53f087 | 2021-07-23 11:13:49 +0800 | [diff] [blame] | 233 | struct amnt_data { |
| 234 | u8 idx; |
| 235 | u8 addr[ETH_ALEN]; |
| 236 | s8 rssi[4]; |
| 237 | u32 last_seen; |
| 238 | }; |
| 239 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 240 | extern struct unl unl; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 241 | |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 242 | int mt76_csi_set(int idx, int argc, char **argv); |
| 243 | int mt76_csi_dump(int idx, int argc, char **argv); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 244 | |
developer | e53f087 | 2021-07-23 11:13:49 +0800 | [diff] [blame] | 245 | int mt76_amnt_set(int idx, int argc, char **argv); |
| 246 | int mt76_amnt_dump(int idx, int argc, char **argv); |
| 247 | |
developer | 5f18e6c | 2021-07-28 11:55:08 +0800 | [diff] [blame] | 248 | int mt76_ap_rfeatures_set(int idx, int argc, char **argv); |
| 249 | int mt76_ap_wireless_set(int idx, int argc, char **argv); |
developer | 7f1a58f | 2022-05-26 16:00:32 -0700 | [diff] [blame] | 250 | |
developer | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 251 | int mt76_mu_onoff_set(int idx, int argc, char **argv); |
developer | 29b831d | 2022-06-21 10:01:42 -0700 | [diff] [blame] | 252 | |
| 253 | int mt76_phy_capa_dump(int idx, int argc, char **argv); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 254 | #endif |