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 * @MT76_TM_ATTR_DRV_DATA: driver specific netlink attrs (nested) 48 */ 49 enum mt76_testmode_attr { 50 MT76_TM_ATTR_UNSPEC, 51 52 MT76_TM_ATTR_RESET, 53 MT76_TM_ATTR_STATE, 54 55 MT76_TM_ATTR_MTD_PART, 56 MT76_TM_ATTR_MTD_OFFSET, 57 58 MT76_TM_ATTR_TX_COUNT, 59 MT76_TM_ATTR_TX_LENGTH, 60 MT76_TM_ATTR_TX_RATE_MODE, 61 MT76_TM_ATTR_TX_RATE_NSS, 62 MT76_TM_ATTR_TX_RATE_IDX, 63 MT76_TM_ATTR_TX_RATE_SGI, 64 MT76_TM_ATTR_TX_RATE_LDPC, 65 MT76_TM_ATTR_TX_RATE_STBC, 66 MT76_TM_ATTR_TX_LTF, 67 68 MT76_TM_ATTR_TX_ANTENNA, 69 MT76_TM_ATTR_TX_POWER_CONTROL, 70 MT76_TM_ATTR_TX_POWER, 71 72 MT76_TM_ATTR_FREQ_OFFSET, 73 74 MT76_TM_ATTR_STATS, 75 76 MT76_TM_ATTR_TX_SPE_IDX, 77 78 MT76_TM_ATTR_TX_DUTY_CYCLE, 79 MT76_TM_ATTR_TX_IPG, 80 MT76_TM_ATTR_TX_TIME, 81 82 MT76_TM_ATTR_DRV_DATA, 83 84 /* keep last */ 85 NUM_MT76_TM_ATTRS, 86 MT76_TM_ATTR_MAX = NUM_MT76_TM_ATTRS - 1, 87 }; 88 89 /** 90 * enum mt76_testmode_state - statistics attributes 91 * 92 * @MT76_TM_STATS_ATTR_TX_PENDING: pending tx frames (u32) 93 * @MT76_TM_STATS_ATTR_TX_QUEUED: queued tx frames (u32) 94 * @MT76_TM_STATS_ATTR_TX_QUEUED: completed tx frames (u32) 95 * 96 * @MT76_TM_STATS_ATTR_RX_PACKETS: number of rx packets (u64) 97 * @MT76_TM_STATS_ATTR_RX_FCS_ERROR: number of rx packets with FCS error (u64) 98 * @MT76_TM_STATS_ATTR_LAST_RX: information about the last received packet 99 * see &enum mt76_testmode_rx_attr 100 */ 101 enum mt76_testmode_stats_attr { 102 MT76_TM_STATS_ATTR_UNSPEC, 103 MT76_TM_STATS_ATTR_PAD, 104 105 MT76_TM_STATS_ATTR_TX_PENDING, 106 MT76_TM_STATS_ATTR_TX_QUEUED, 107 MT76_TM_STATS_ATTR_TX_DONE, 108 109 MT76_TM_STATS_ATTR_RX_PACKETS, 110 MT76_TM_STATS_ATTR_RX_FCS_ERROR, 111 MT76_TM_STATS_ATTR_LAST_RX, 112 113 /* keep last */ 114 NUM_MT76_TM_STATS_ATTRS, 115 MT76_TM_STATS_ATTR_MAX = NUM_MT76_TM_STATS_ATTRS - 1, 116 }; 117 118 119 /** 120 * enum mt76_testmode_rx_attr - packet rx information 121 * 122 * @MT76_TM_RX_ATTR_FREQ_OFFSET: frequency offset (s32) 123 * @MT76_TM_RX_ATTR_RCPI: received channel power indicator (array, u8) 124 * @MT76_TM_RX_ATTR_IB_RSSI: internal inband RSSI (array, s8) 125 * @MT76_TM_RX_ATTR_WB_RSSI: internal wideband RSSI (array, s8) 126 * @MT76_TM_RX_ATTR_SNR: signal-to-noise ratio (u8) 127 */ 128 enum mt76_testmode_rx_attr { 129 MT76_TM_RX_ATTR_UNSPEC, 130 131 MT76_TM_RX_ATTR_FREQ_OFFSET, 132 MT76_TM_RX_ATTR_RCPI, 133 MT76_TM_RX_ATTR_IB_RSSI, 134 MT76_TM_RX_ATTR_WB_RSSI, 135 MT76_TM_RX_ATTR_SNR, 136 137 /* keep last */ 138 NUM_MT76_TM_RX_ATTRS, 139 MT76_TM_RX_ATTR_MAX = NUM_MT76_TM_RX_ATTRS - 1, 140 }; 141 142 /** 143 * enum mt76_testmode_state - phy test state 144 * 145 * @MT76_TM_STATE_OFF: test mode disabled (normal operation) 146 * @MT76_TM_STATE_IDLE: test mode enabled, but idle 147 * @MT76_TM_STATE_TX_FRAMES: send a fixed number of test frames 148 * @MT76_TM_STATE_RX_FRAMES: receive packets and keep statistics 149 * @MT76_TM_STATE_TX_CONT: waveform tx without time gap 150 * @MT76_TM_STATE_ON: test mode enabled used in offload firmware 151 */ 152 enum mt76_testmode_state { 153 MT76_TM_STATE_OFF, 154 MT76_TM_STATE_IDLE, 155 MT76_TM_STATE_TX_FRAMES, 156 MT76_TM_STATE_RX_FRAMES, 157 MT76_TM_STATE_TX_CONT, 158 MT76_TM_STATE_ON, 159 160 /* keep last */ 161 NUM_MT76_TM_STATES, 162 MT76_TM_STATE_MAX = NUM_MT76_TM_STATES - 1, 163 }; 164 165 /** 166 * enum mt76_testmode_tx_mode - packet tx phy mode 167 * 168 * @MT76_TM_TX_MODE_CCK: legacy CCK mode 169 * @MT76_TM_TX_MODE_OFDM: legacy OFDM mode 170 * @MT76_TM_TX_MODE_HT: 802.11n MCS 171 * @MT76_TM_TX_MODE_VHT: 802.11ac MCS 172 * @MT76_TM_TX_MODE_HE_SU: 802.11ax single-user MIMO 173 * @MT76_TM_TX_MODE_HE_EXT_SU: 802.11ax extended-range SU 174 * @MT76_TM_TX_MODE_HE_TB: 802.11ax trigger-based 175 * @MT76_TM_TX_MODE_HE_MU: 802.11ax multi-user MIMO 176 */ 177 enum mt76_testmode_tx_mode { 178 MT76_TM_TX_MODE_CCK, 179 MT76_TM_TX_MODE_OFDM, 180 MT76_TM_TX_MODE_HT, 181 MT76_TM_TX_MODE_VHT, 182 MT76_TM_TX_MODE_HE_SU, 183 MT76_TM_TX_MODE_HE_EXT_SU, 184 MT76_TM_TX_MODE_HE_TB, 185 MT76_TM_TX_MODE_HE_MU, 186 187 /* keep last */ 188 NUM_MT76_TM_TX_MODES, 189 MT76_TM_TX_MODE_MAX = NUM_MT76_TM_TX_MODES - 1, 190 }; 191 192 extern const struct nla_policy mt76_tm_policy[NUM_MT76_TM_ATTRS]; 193 194 #endif 195