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  *
29  * @MT76_TM_ATTR_TX_ANTENNA: tx antenna mask (u8)
30  * @MT76_TM_ATTR_TX_POWER_CONTROL: enable tx power control (u8)
31  * @MT76_TM_ATTR_TX_POWER: per-antenna tx power array (nested, u8 attrs)
32  *
33  * @MT76_TM_ATTR_FREQ_OFFSET: RF frequency offset (u32)
34  *
35  * @MT76_TM_ATTR_STATS: statistics (nested, see &enum mt76_testmode_stats_attr)
36  */
37 enum mt76_testmode_attr {
38 	MT76_TM_ATTR_UNSPEC,
39 
40 	MT76_TM_ATTR_RESET,
41 	MT76_TM_ATTR_STATE,
42 
43 	MT76_TM_ATTR_MTD_PART,
44 	MT76_TM_ATTR_MTD_OFFSET,
45 
46 	MT76_TM_ATTR_TX_COUNT,
47 	MT76_TM_ATTR_TX_LENGTH,
48 	MT76_TM_ATTR_TX_RATE_MODE,
49 	MT76_TM_ATTR_TX_RATE_NSS,
50 	MT76_TM_ATTR_TX_RATE_IDX,
51 	MT76_TM_ATTR_TX_RATE_SGI,
52 	MT76_TM_ATTR_TX_RATE_LDPC,
53 
54 	MT76_TM_ATTR_TX_ANTENNA,
55 	MT76_TM_ATTR_TX_POWER_CONTROL,
56 	MT76_TM_ATTR_TX_POWER,
57 
58 	MT76_TM_ATTR_FREQ_OFFSET,
59 
60 	MT76_TM_ATTR_STATS,
61 
62 	/* keep last */
63 	NUM_MT76_TM_ATTRS,
64 	MT76_TM_ATTR_MAX = NUM_MT76_TM_ATTRS - 1,
65 };
66 
67 /**
68  * enum mt76_testmode_state - statistics attributes
69  *
70  * @MT76_TM_STATS_ATTR_TX_PENDING: pending tx frames (u32)
71  * @MT76_TM_STATS_ATTR_TX_QUEUED: queued tx frames (u32)
72  * @MT76_TM_STATS_ATTR_TX_QUEUED: completed tx frames (u32)
73  *
74  * @MT76_TM_STATS_ATTR_RX_PACKETS: number of rx packets (u64)
75  * @MT76_TM_STATS_ATTR_RX_FCS_ERROR: number of rx packets with FCS error (u64)
76  * @MT76_TM_STATS_ATTR_LAST_RX: information about the last received packet
77  *	see &enum mt76_testmode_rx_attr
78  */
79 enum mt76_testmode_stats_attr {
80 	MT76_TM_STATS_ATTR_UNSPEC,
81 	MT76_TM_STATS_ATTR_PAD,
82 
83 	MT76_TM_STATS_ATTR_TX_PENDING,
84 	MT76_TM_STATS_ATTR_TX_QUEUED,
85 	MT76_TM_STATS_ATTR_TX_DONE,
86 
87 	MT76_TM_STATS_ATTR_RX_PACKETS,
88 	MT76_TM_STATS_ATTR_RX_FCS_ERROR,
89 	MT76_TM_STATS_ATTR_LAST_RX,
90 
91 	/* keep last */
92 	NUM_MT76_TM_STATS_ATTRS,
93 	MT76_TM_STATS_ATTR_MAX = NUM_MT76_TM_STATS_ATTRS - 1,
94 };
95 
96 
97 /**
98  * enum mt76_testmode_rx_attr - packet rx information
99  *
100  * @MT76_TM_RX_ATTR_FREQ_OFFSET: frequency offset (s32)
101  * @MT76_TM_RX_ATTR_RCPI: received channel power indicator (array, u8)
102  * @MT76_TM_RX_ATTR_IB_RSSI: internal inband RSSI (s8)
103  * @MT76_TM_RX_ATTR_WB_RSSI: internal wideband RSSI (s8)
104  */
105 enum mt76_testmode_rx_attr {
106 	MT76_TM_RX_ATTR_UNSPEC,
107 
108 	MT76_TM_RX_ATTR_FREQ_OFFSET,
109 	MT76_TM_RX_ATTR_RCPI,
110 	MT76_TM_RX_ATTR_IB_RSSI,
111 	MT76_TM_RX_ATTR_WB_RSSI,
112 
113 	/* keep last */
114 	NUM_MT76_TM_RX_ATTRS,
115 	MT76_TM_RX_ATTR_MAX = NUM_MT76_TM_RX_ATTRS - 1,
116 };
117 
118 /**
119  * enum mt76_testmode_state - phy test state
120  *
121  * @MT76_TM_STATE_OFF: test mode disabled (normal operation)
122  * @MT76_TM_STATE_IDLE: test mode enabled, but idle
123  * @MT76_TM_STATE_TX_FRAMES: send a fixed number of test frames
124  * @MT76_TM_STATE_RX_FRAMES: receive packets and keep statistics
125  */
126 enum mt76_testmode_state {
127 	MT76_TM_STATE_OFF,
128 	MT76_TM_STATE_IDLE,
129 	MT76_TM_STATE_TX_FRAMES,
130 	MT76_TM_STATE_RX_FRAMES,
131 
132 	/* keep last */
133 	NUM_MT76_TM_STATES,
134 	MT76_TM_STATE_MAX = NUM_MT76_TM_STATES - 1,
135 };
136 
137 /**
138  * enum mt76_testmode_tx_mode - packet tx phy mode
139  *
140  * @MT76_TM_TX_MODE_CCK: legacy CCK mode
141  * @MT76_TM_TX_MODE_OFDM: legacy OFDM mode
142  * @MT76_TM_TX_MODE_HT: 802.11n MCS
143  * @MT76_TM_TX_MODE_VHT: 802.11ac MCS
144  */
145 enum mt76_testmode_tx_mode {
146 	MT76_TM_TX_MODE_CCK,
147 	MT76_TM_TX_MODE_OFDM,
148 	MT76_TM_TX_MODE_HT,
149 	MT76_TM_TX_MODE_VHT,
150 
151 	/* keep last */
152 	NUM_MT76_TM_TX_MODES,
153 	MT76_TM_TX_MODE_MAX = NUM_MT76_TM_TX_MODES - 1,
154 };
155 
156 #endif
157