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