xref: /freebsd/sys/contrib/dev/mediatek/mt76/testmode.h (revision 7ef62cebc2f965b0f640263e179276928885e33d)
1 /* SPDX-License-Identifier: ISC */
2 /*
3  * Copyright (C) 2020 Felix Fietkau <nbd@nbd.name>
4  */
5 #ifndef __MT76_TESTMODE_H
6 #define __MT76_TESTMODE_H
7 
8 #define MT76_TM_TIMEOUT	10
9 
10 #include <net/netlink.h>
11 
12 /**
13  * enum mt76_testmode_attr - testmode attributes inside NL80211_ATTR_TESTDATA
14  *
15  * @MT76_TM_ATTR_UNSPEC: (invalid attribute)
16  *
17  * @MT76_TM_ATTR_RESET: reset parameters to default (flag)
18  * @MT76_TM_ATTR_STATE: test state (u32), see &enum mt76_testmode_state
19  *
20  * @MT76_TM_ATTR_MTD_PART: mtd partition used for eeprom data (string)
21  * @MT76_TM_ATTR_MTD_OFFSET: offset of eeprom data within the partition (u32)
22  *
23  * @MT76_TM_ATTR_TX_COUNT: configured number of frames to send when setting
24  *	state to MT76_TM_STATE_TX_FRAMES (u32)
25  * @MT76_TM_ATTR_TX_PENDING: pending frames during MT76_TM_STATE_TX_FRAMES (u32)
26  * @MT76_TM_ATTR_TX_LENGTH: packet tx mpdu length (u32)
27  * @MT76_TM_ATTR_TX_RATE_MODE: packet tx mode (u8, see &enum mt76_testmode_tx_mode)
28  * @MT76_TM_ATTR_TX_RATE_NSS: packet tx number of spatial streams (u8)
29  * @MT76_TM_ATTR_TX_RATE_IDX: packet tx rate/MCS index (u8)
30  * @MT76_TM_ATTR_TX_RATE_SGI: packet tx use short guard interval (u8)
31  * @MT76_TM_ATTR_TX_RATE_LDPC: packet tx enable LDPC (u8)
32  * @MT76_TM_ATTR_TX_RATE_STBC: packet tx enable STBC (u8)
33  * @MT76_TM_ATTR_TX_LTF: packet tx LTF, set 0 to 2 for 1x, 2x, and 4x LTF (u8)
34  *
35  * @MT76_TM_ATTR_TX_ANTENNA: tx antenna mask (u8)
36  * @MT76_TM_ATTR_TX_POWER_CONTROL: enable tx power control (u8)
37  * @MT76_TM_ATTR_TX_POWER: per-antenna tx power array (nested, u8 attrs)
38  *
39  * @MT76_TM_ATTR_FREQ_OFFSET: RF frequency offset (u32)
40  *
41  * @MT76_TM_ATTR_STATS: statistics (nested, see &enum mt76_testmode_stats_attr)
42  *
43  * @MT76_TM_ATTR_TX_SPE_IDX: tx spatial extension index (u8)
44  *
45  * @MT76_TM_ATTR_TX_DUTY_CYCLE: packet tx duty cycle (u8)
46  * @MT76_TM_ATTR_TX_IPG: tx inter-packet gap, in unit of us (u32)
47  * @MT76_TM_ATTR_TX_TIME: packet transmission time, in unit of us (u32)
48  *
49  * @MT76_TM_ATTR_DRV_DATA: driver specific netlink attrs (nested)
50  *
51  * @MT76_TM_ATTR_MAC_ADDRS: array of nested MAC addresses (nested)
52  */
53 enum mt76_testmode_attr {
54 	MT76_TM_ATTR_UNSPEC,
55 
56 	MT76_TM_ATTR_RESET,
57 	MT76_TM_ATTR_STATE,
58 
59 	MT76_TM_ATTR_MTD_PART,
60 	MT76_TM_ATTR_MTD_OFFSET,
61 
62 	MT76_TM_ATTR_TX_COUNT,
63 	MT76_TM_ATTR_TX_LENGTH,
64 	MT76_TM_ATTR_TX_RATE_MODE,
65 	MT76_TM_ATTR_TX_RATE_NSS,
66 	MT76_TM_ATTR_TX_RATE_IDX,
67 	MT76_TM_ATTR_TX_RATE_SGI,
68 	MT76_TM_ATTR_TX_RATE_LDPC,
69 	MT76_TM_ATTR_TX_RATE_STBC,
70 	MT76_TM_ATTR_TX_LTF,
71 
72 	MT76_TM_ATTR_TX_ANTENNA,
73 	MT76_TM_ATTR_TX_POWER_CONTROL,
74 	MT76_TM_ATTR_TX_POWER,
75 
76 	MT76_TM_ATTR_FREQ_OFFSET,
77 
78 	MT76_TM_ATTR_STATS,
79 
80 	MT76_TM_ATTR_TX_SPE_IDX,
81 
82 	MT76_TM_ATTR_TX_DUTY_CYCLE,
83 	MT76_TM_ATTR_TX_IPG,
84 	MT76_TM_ATTR_TX_TIME,
85 
86 	MT76_TM_ATTR_DRV_DATA,
87 
88 	MT76_TM_ATTR_MAC_ADDRS,
89 
90 	/* keep last */
91 	NUM_MT76_TM_ATTRS,
92 	MT76_TM_ATTR_MAX = NUM_MT76_TM_ATTRS - 1,
93 };
94 
95 /**
96  * enum mt76_testmode_state - statistics attributes
97  *
98  * @MT76_TM_STATS_ATTR_TX_PENDING: pending tx frames (u32)
99  * @MT76_TM_STATS_ATTR_TX_QUEUED: queued tx frames (u32)
100  * @MT76_TM_STATS_ATTR_TX_QUEUED: completed tx frames (u32)
101  *
102  * @MT76_TM_STATS_ATTR_RX_PACKETS: number of rx packets (u64)
103  * @MT76_TM_STATS_ATTR_RX_FCS_ERROR: number of rx packets with FCS error (u64)
104  * @MT76_TM_STATS_ATTR_LAST_RX: information about the last received packet
105  *	see &enum mt76_testmode_rx_attr
106  */
107 enum mt76_testmode_stats_attr {
108 	MT76_TM_STATS_ATTR_UNSPEC,
109 	MT76_TM_STATS_ATTR_PAD,
110 
111 	MT76_TM_STATS_ATTR_TX_PENDING,
112 	MT76_TM_STATS_ATTR_TX_QUEUED,
113 	MT76_TM_STATS_ATTR_TX_DONE,
114 
115 	MT76_TM_STATS_ATTR_RX_PACKETS,
116 	MT76_TM_STATS_ATTR_RX_FCS_ERROR,
117 	MT76_TM_STATS_ATTR_LAST_RX,
118 
119 	/* keep last */
120 	NUM_MT76_TM_STATS_ATTRS,
121 	MT76_TM_STATS_ATTR_MAX = NUM_MT76_TM_STATS_ATTRS - 1,
122 };
123 
124 
125 /**
126  * enum mt76_testmode_rx_attr - packet rx information
127  *
128  * @MT76_TM_RX_ATTR_FREQ_OFFSET: frequency offset (s32)
129  * @MT76_TM_RX_ATTR_RCPI: received channel power indicator (array, u8)
130  * @MT76_TM_RX_ATTR_IB_RSSI: internal inband RSSI (array, s8)
131  * @MT76_TM_RX_ATTR_WB_RSSI: internal wideband RSSI (array, s8)
132  * @MT76_TM_RX_ATTR_SNR: signal-to-noise ratio (u8)
133  */
134 enum mt76_testmode_rx_attr {
135 	MT76_TM_RX_ATTR_UNSPEC,
136 
137 	MT76_TM_RX_ATTR_FREQ_OFFSET,
138 	MT76_TM_RX_ATTR_RCPI,
139 	MT76_TM_RX_ATTR_IB_RSSI,
140 	MT76_TM_RX_ATTR_WB_RSSI,
141 	MT76_TM_RX_ATTR_SNR,
142 
143 	/* keep last */
144 	NUM_MT76_TM_RX_ATTRS,
145 	MT76_TM_RX_ATTR_MAX = NUM_MT76_TM_RX_ATTRS - 1,
146 };
147 
148 /**
149  * enum mt76_testmode_state - phy test state
150  *
151  * @MT76_TM_STATE_OFF: test mode disabled (normal operation)
152  * @MT76_TM_STATE_IDLE: test mode enabled, but idle
153  * @MT76_TM_STATE_TX_FRAMES: send a fixed number of test frames
154  * @MT76_TM_STATE_RX_FRAMES: receive packets and keep statistics
155  * @MT76_TM_STATE_TX_CONT: waveform tx without time gap
156  * @MT76_TM_STATE_ON: test mode enabled used in offload firmware
157  */
158 enum mt76_testmode_state {
159 	MT76_TM_STATE_OFF,
160 	MT76_TM_STATE_IDLE,
161 	MT76_TM_STATE_TX_FRAMES,
162 	MT76_TM_STATE_RX_FRAMES,
163 	MT76_TM_STATE_TX_CONT,
164 	MT76_TM_STATE_ON,
165 
166 	/* keep last */
167 	NUM_MT76_TM_STATES,
168 	MT76_TM_STATE_MAX = NUM_MT76_TM_STATES - 1,
169 };
170 
171 /**
172  * enum mt76_testmode_tx_mode - packet tx phy mode
173  *
174  * @MT76_TM_TX_MODE_CCK: legacy CCK mode
175  * @MT76_TM_TX_MODE_OFDM: legacy OFDM mode
176  * @MT76_TM_TX_MODE_HT: 802.11n MCS
177  * @MT76_TM_TX_MODE_VHT: 802.11ac MCS
178  * @MT76_TM_TX_MODE_HE_SU: 802.11ax single-user MIMO
179  * @MT76_TM_TX_MODE_HE_EXT_SU: 802.11ax extended-range SU
180  * @MT76_TM_TX_MODE_HE_TB: 802.11ax trigger-based
181  * @MT76_TM_TX_MODE_HE_MU: 802.11ax multi-user MIMO
182  */
183 enum mt76_testmode_tx_mode {
184 	MT76_TM_TX_MODE_CCK,
185 	MT76_TM_TX_MODE_OFDM,
186 	MT76_TM_TX_MODE_HT,
187 	MT76_TM_TX_MODE_VHT,
188 	MT76_TM_TX_MODE_HE_SU,
189 	MT76_TM_TX_MODE_HE_EXT_SU,
190 	MT76_TM_TX_MODE_HE_TB,
191 	MT76_TM_TX_MODE_HE_MU,
192 
193 	/* keep last */
194 	NUM_MT76_TM_TX_MODES,
195 	MT76_TM_TX_MODE_MAX = NUM_MT76_TM_TX_MODES - 1,
196 };
197 
198 extern const struct nla_policy mt76_tm_policy[NUM_MT76_TM_ATTRS];
199 
200 #endif
201