blob: 61b04268e553e0de7e8dcc056681e4e316792441 [file] [log] [blame]
developerfd40db22021-04-29 10:08:25 +08001// SPDX-License-Identifier: ISC
2/* Copyright (C) 2020 Felix Fietkau <nbd@nbd.name> */
developer175704f2021-06-22 17:33:53 +08003#ifndef __MT76_VENDOR_H
4#define __MT76_VENDOR_H
developerfd40db22021-04-29 10:08:25 +08005
developer175704f2021-06-22 17:33:53 +08006#include <errno.h>
7#include <linux/nl80211.h>
8#include <netlink/attr.h>
developerfd40db22021-04-29 10:08:25 +08009#include <stdbool.h>
10#include <stdint.h>
11#include <stdio.h>
developerfd40db22021-04-29 10:08:25 +080012#include <unl.h>
13
14typedef uint8_t u8;
15typedef uint16_t u16;
16typedef uint32_t u32;
17typedef uint64_t u64;
18typedef int8_t s8;
19typedef int16_t s16;
20typedef int32_t s32;
21typedef 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
33struct nl_msg;
34struct nlattr;
35
36enum mtk_nl80211_vendor_subcmds {
developere53f0872021-07-23 11:13:49 +080037 MTK_NL80211_VENDOR_SUBCMD_AMNT_CTRL = 0xae,
developerfd40db22021-04-29 10:08:25 +080038 MTK_NL80211_VENDOR_SUBCMD_CSI_CTRL = 0xc2,
developer5f18e6c2021-07-28 11:55:08 +080039 MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL = 0xc3,
40 MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL = 0xc4,
developer57de9b72023-02-20 11:15:54 +080041 MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
developer29b831d2022-06-21 10:01:42 -070042 MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL = 0xc6,
developerfd40db22021-04-29 10:08:25 +080043};
44
45enum 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,
developer175704f2021-06-22 17:33:53 +080054 MTK_VENDOR_ATTR_CSI_CTRL_INTERVAL,
developerfd40db22021-04-29 10:08:25 +080055
56 MTK_VENDOR_ATTR_CSI_CTRL_DUMP_NUM,
57
58 MTK_VENDOR_ATTR_CSI_CTRL_DATA,
59
60 /* keep last */
61 NUM_MTK_VENDOR_ATTRS_CSI_CTRL,
62 MTK_VENDOR_ATTR_CSI_CTRL_MAX =
63 NUM_MTK_VENDOR_ATTRS_CSI_CTRL - 1
64};
65
66enum mtk_vendor_attr_csi_data {
67 MTK_VENDOR_ATTR_CSI_DATA_UNSPEC,
68 MTK_VENDOR_ATTR_CSI_DATA_PAD,
69
70 MTK_VENDOR_ATTR_CSI_DATA_VER,
71 MTK_VENDOR_ATTR_CSI_DATA_TS,
72 MTK_VENDOR_ATTR_CSI_DATA_RSSI,
73 MTK_VENDOR_ATTR_CSI_DATA_SNR,
74 MTK_VENDOR_ATTR_CSI_DATA_BW,
75 MTK_VENDOR_ATTR_CSI_DATA_CH_IDX,
76 MTK_VENDOR_ATTR_CSI_DATA_TA,
77 MTK_VENDOR_ATTR_CSI_DATA_I,
78 MTK_VENDOR_ATTR_CSI_DATA_Q,
79 MTK_VENDOR_ATTR_CSI_DATA_INFO,
80 MTK_VENDOR_ATTR_CSI_DATA_RSVD1,
81 MTK_VENDOR_ATTR_CSI_DATA_RSVD2,
82 MTK_VENDOR_ATTR_CSI_DATA_RSVD3,
83 MTK_VENDOR_ATTR_CSI_DATA_RSVD4,
84 MTK_VENDOR_ATTR_CSI_DATA_TX_ANT,
85 MTK_VENDOR_ATTR_CSI_DATA_RX_ANT,
86 MTK_VENDOR_ATTR_CSI_DATA_MODE,
87 MTK_VENDOR_ATTR_CSI_DATA_H_IDX,
88
89 /* keep last */
90 NUM_MTK_VENDOR_ATTRS_CSI_DATA,
91 MTK_VENDOR_ATTR_CSI_DATA_MAX =
92 NUM_MTK_VENDOR_ATTRS_CSI_DATA - 1
93};
94
developere53f0872021-07-23 11:13:49 +080095enum mtk_vendor_attr_mnt_ctrl {
96 MTK_VENDOR_ATTR_AMNT_CTRL_UNSPEC,
97
98 MTK_VENDOR_ATTR_AMNT_CTRL_SET,
99 MTK_VENDOR_ATTR_AMNT_CTRL_DUMP,
100 /* keep last */
101 NUM_MTK_VENDOR_ATTRS_AMNT_CTRL,
102 MTK_VENDOR_ATTR_AMNT_CTRL_MAX =
103 NUM_MTK_VENDOR_ATTRS_AMNT_CTRL - 1
104};
105
106enum mtk_vendor_attr_mnt_set {
107 MTK_VENDOR_ATTR_AMNT_SET_UNSPEC,
108
109 MTK_VENDOR_ATTR_AMNT_SET_INDEX,
110 MTK_VENDOR_ATTR_AMNT_SET_MACADDR,
111
112 /* keep last */
113 NUM_MTK_VENDOR_ATTRS_AMNT_SET,
114 MTK_VENDOR_ATTR_AMNT_SET_MAX =
115 NUM_MTK_VENDOR_ATTRS_AMNT_SET - 1
116};
117
118enum mtk_vendor_attr_mnt_dump {
119 MTK_VENDOR_ATTR_AMNT_DUMP_UNSPEC,
120
121 MTK_VENDOR_ATTR_AMNT_DUMP_INDEX,
122 MTK_VENDOR_ATTR_AMNT_DUMP_LEN,
123 MTK_VENDOR_ATTR_AMNT_DUMP_RESULT,
124
125 /* keep last */
126 NUM_MTK_VENDOR_ATTRS_AMNT_DUMP,
127 MTK_VENDOR_ATTR_AMNT_DUMP_MAX =
128 NUM_MTK_VENDOR_ATTRS_AMNT_DUMP - 1
129};
130
developer5f18e6c2021-07-28 11:55:08 +0800131enum mtk_vendor_attr_wireless_ctrl {
132 MTK_VENDOR_ATTR_WIRELESS_CTRL_UNSPEC,
133
134 MTK_VENDOR_ATTR_WIRELESS_CTRL_FIXED_MCS,
developer507ff0c2021-07-30 14:51:55 +0800135 MTK_VENDOR_ATTR_WIRELESS_CTRL_FIXED_OFDMA,
developerb72be592021-08-16 10:58:59 +0800136 MTK_VENDOR_ATTR_WIRELESS_CTRL_PPDU_TX_TYPE,
137 MTK_VENDOR_ATTR_WIRELESS_CTRL_NUSERS_OFDMA,
developer786d9292021-09-22 11:03:21 +0800138 MTK_VENDOR_ATTR_WIRELESS_CTRL_BA_BUFFER_SIZE,
139 MTK_VENDOR_ATTR_WIRELESS_CTRL_MIMO,
developer3a5765c2021-09-23 16:19:12 +0800140 MTK_VENDOR_ATTR_WIRELESS_CTRL_AMPDU,
141 MTK_VENDOR_ATTR_WIRELESS_CTRL_AMSDU,
developer07ede8d2021-11-16 18:31:21 +0800142 MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT,
developera98a5ea2023-01-24 14:23:34 +0800143 MTK_VENDOR_ATTR_WIRELESS_CTRL_RTS_SIGTA,
developer5f18e6c2021-07-28 11:55:08 +0800144
145 /* keep last */
146 NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL,
147 MTK_VENDOR_ATTR_WIRELESS_CTRL_MAX =
148 NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL - 1
149};
150
developer57de9b72023-02-20 11:15:54 +0800151enum mtk_vendor_attr_mu_ctrl {
152 MTK_VENDOR_ATTR_MU_CTRL_UNSPEC,
developer7f1a58f2022-05-26 16:00:32 -0700153
developer57de9b72023-02-20 11:15:54 +0800154 MTK_VENDOR_ATTR_MU_CTRL_ONOFF,
developer7f1a58f2022-05-26 16:00:32 -0700155
156 /* keep last */
developer57de9b72023-02-20 11:15:54 +0800157 NUM_MTK_VENDOR_ATTRS_MU_CTRL,
158 MTK_VENDOR_ATTR_MU_CTRL_MAX =
159 NUM_MTK_VENDOR_ATTRS_MU_CTRL - 1
developer7f1a58f2022-05-26 16:00:32 -0700160};
161
developer5f18e6c2021-07-28 11:55:08 +0800162enum mtk_vendor_attr_rfeature_ctrl {
163 MTK_VENDOR_ATTR_RFEATURE_CTRL_UNSPEC,
164
165 MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_GI,
166 MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_LTF,
developer13aaa772021-09-27 18:09:26 +0800167 MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE_CFG,
168 MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE_EN,
developer31b1a282021-08-04 14:13:00 +0800169 MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE,
170 MTK_VENDOR_ATTR_RFEATURE_CTRL_ACK_PLCY,
developer5f18e6c2021-07-28 11:55:08 +0800171
172 /* keep last */
173 NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL,
174 MTK_VENDOR_ATTR_RFEATURE_CTRL_MAX =
175 NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL - 1
176};
177
developer29b831d2022-06-21 10:01:42 -0700178enum mtk_vendor_attr_phy_capa_ctrl {
179 MTK_VENDOR_ATTR_PHY_CAPA_CTRL_UNSPEC,
180
181 MTK_VENDOR_ATTR_PHY_CAPA_CTRL_SET,
182 MTK_VENDOR_ATTR_PHY_CAPA_CTRL_DUMP,
183
184 /* keep last */
185 NUM_MTK_VENDOR_ATTRS_PHY_CAPA_CTRL,
186 MTK_VENDOR_ATTR_PHY_CAPA_CTRL_MAX =
187 NUM_MTK_VENDOR_ATTRS_PHY_CAPA_CTRL - 1
188};
189
190enum mtk_vendor_attr_phy_capa_dump {
191 MTK_VENDOR_ATTR_PHY_CAPA_DUMP_UNSPEC,
192
193 MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX_SUPPORTED_BSS,
194 MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX_SUPPORTED_STA,
195
196 /* keep last */
197 NUM_MTK_VENDOR_ATTRS_PHY_CAPA_DUMP,
198 MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX =
199 NUM_MTK_VENDOR_ATTRS_PHY_CAPA_DUMP - 1
200};
201
developerfd40db22021-04-29 10:08:25 +0800202#define CSI_MAX_COUNT 256
203#define ETH_ALEN 6
204
205struct csi_data {
206 s16 data_i[CSI_MAX_COUNT];
207 s16 data_q[CSI_MAX_COUNT];
208 s8 rssi;
209 u8 snr;
developera1e20de2021-06-17 10:33:53 +0800210 u32 ts;
developerfd40db22021-04-29 10:08:25 +0800211 u8 data_bw;
212 u8 pri_ch_idx;
213 u8 ta[ETH_ALEN];
214 u32 info;
215 u8 rx_mode;
216 u32 h_idx;
217 u16 tx_idx;
218 u16 rx_idx;
219};
220
developere53f0872021-07-23 11:13:49 +0800221struct amnt_data {
222 u8 idx;
223 u8 addr[ETH_ALEN];
224 s8 rssi[4];
225 u32 last_seen;
226};
227
developerfd40db22021-04-29 10:08:25 +0800228extern struct unl unl;
developerfd40db22021-04-29 10:08:25 +0800229
developer175704f2021-06-22 17:33:53 +0800230int mt76_csi_set(int idx, int argc, char **argv);
231int mt76_csi_dump(int idx, int argc, char **argv);
developerfd40db22021-04-29 10:08:25 +0800232
developere53f0872021-07-23 11:13:49 +0800233int mt76_amnt_set(int idx, int argc, char **argv);
234int mt76_amnt_dump(int idx, int argc, char **argv);
235
developer5f18e6c2021-07-28 11:55:08 +0800236int mt76_ap_rfeatures_set(int idx, int argc, char **argv);
237int mt76_ap_wireless_set(int idx, int argc, char **argv);
developer7f1a58f2022-05-26 16:00:32 -0700238
developer57de9b72023-02-20 11:15:54 +0800239int mt76_mu_onoff_set(int idx, int argc, char **argv);
developer29b831d2022-06-21 10:01:42 -0700240
241int mt76_phy_capa_dump(int idx, int argc, char **argv);
developerfd40db22021-04-29 10:08:25 +0800242#endif