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