18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: ISC */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2020 Felix Fietkau <nbd@nbd.name>
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci#ifndef __MT76_TESTMODE_H
68c2ecf20Sopenharmony_ci#define __MT76_TESTMODE_H
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci/**
98c2ecf20Sopenharmony_ci * enum mt76_testmode_attr - testmode attributes inside NL80211_ATTR_TESTDATA
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_UNSPEC: (invalid attribute)
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_RESET: reset parameters to default (flag)
148c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_STATE: test state (u32), see &enum mt76_testmode_state
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_MTD_PART: mtd partition used for eeprom data (string)
178c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_MTD_OFFSET: offset of eeprom data within the partition (u32)
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_TX_COUNT: configured number of frames to send when setting
208c2ecf20Sopenharmony_ci *	state to MT76_TM_STATE_TX_FRAMES (u32)
218c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_TX_PENDING: pending frames during MT76_TM_STATE_TX_FRAMES (u32)
228c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_TX_LENGTH: packet tx msdu length (u32)
238c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_TX_RATE_MODE: packet tx mode (u8, see &enum mt76_testmode_tx_mode)
248c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_TX_RATE_NSS: packet tx number of spatial streams (u8)
258c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_TX_RATE_IDX: packet tx rate/MCS index (u8)
268c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_TX_RATE_SGI: packet tx use short guard interval (u8)
278c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_TX_RATE_LDPC: packet tx enable LDPC (u8)
288c2ecf20Sopenharmony_ci *
298c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_TX_ANTENNA: tx antenna mask (u8)
308c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_TX_POWER_CONTROL: enable tx power control (u8)
318c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_TX_POWER: per-antenna tx power array (nested, u8 attrs)
328c2ecf20Sopenharmony_ci *
338c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_FREQ_OFFSET: RF frequency offset (u32)
348c2ecf20Sopenharmony_ci *
358c2ecf20Sopenharmony_ci * @MT76_TM_ATTR_STATS: statistics (nested, see &enum mt76_testmode_stats_attr)
368c2ecf20Sopenharmony_ci */
378c2ecf20Sopenharmony_cienum mt76_testmode_attr {
388c2ecf20Sopenharmony_ci	MT76_TM_ATTR_UNSPEC,
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci	MT76_TM_ATTR_RESET,
418c2ecf20Sopenharmony_ci	MT76_TM_ATTR_STATE,
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	MT76_TM_ATTR_MTD_PART,
448c2ecf20Sopenharmony_ci	MT76_TM_ATTR_MTD_OFFSET,
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci	MT76_TM_ATTR_TX_COUNT,
478c2ecf20Sopenharmony_ci	MT76_TM_ATTR_TX_LENGTH,
488c2ecf20Sopenharmony_ci	MT76_TM_ATTR_TX_RATE_MODE,
498c2ecf20Sopenharmony_ci	MT76_TM_ATTR_TX_RATE_NSS,
508c2ecf20Sopenharmony_ci	MT76_TM_ATTR_TX_RATE_IDX,
518c2ecf20Sopenharmony_ci	MT76_TM_ATTR_TX_RATE_SGI,
528c2ecf20Sopenharmony_ci	MT76_TM_ATTR_TX_RATE_LDPC,
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci	MT76_TM_ATTR_TX_ANTENNA,
558c2ecf20Sopenharmony_ci	MT76_TM_ATTR_TX_POWER_CONTROL,
568c2ecf20Sopenharmony_ci	MT76_TM_ATTR_TX_POWER,
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci	MT76_TM_ATTR_FREQ_OFFSET,
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	MT76_TM_ATTR_STATS,
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci	/* keep last */
638c2ecf20Sopenharmony_ci	NUM_MT76_TM_ATTRS,
648c2ecf20Sopenharmony_ci	MT76_TM_ATTR_MAX = NUM_MT76_TM_ATTRS - 1,
658c2ecf20Sopenharmony_ci};
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci/**
688c2ecf20Sopenharmony_ci * enum mt76_testmode_state - statistics attributes
698c2ecf20Sopenharmony_ci *
708c2ecf20Sopenharmony_ci * @MT76_TM_STATS_ATTR_TX_PENDING: pending tx frames (u32)
718c2ecf20Sopenharmony_ci * @MT76_TM_STATS_ATTR_TX_QUEUED: queued tx frames (u32)
728c2ecf20Sopenharmony_ci * @MT76_TM_STATS_ATTR_TX_QUEUED: completed tx frames (u32)
738c2ecf20Sopenharmony_ci *
748c2ecf20Sopenharmony_ci * @MT76_TM_STATS_ATTR_RX_PACKETS: number of rx packets (u64)
758c2ecf20Sopenharmony_ci * @MT76_TM_STATS_ATTR_RX_FCS_ERROR: number of rx packets with FCS error (u64)
768c2ecf20Sopenharmony_ci * @MT76_TM_STATS_ATTR_LAST_RX: information about the last received packet
778c2ecf20Sopenharmony_ci *	see &enum mt76_testmode_rx_attr
788c2ecf20Sopenharmony_ci */
798c2ecf20Sopenharmony_cienum mt76_testmode_stats_attr {
808c2ecf20Sopenharmony_ci	MT76_TM_STATS_ATTR_UNSPEC,
818c2ecf20Sopenharmony_ci	MT76_TM_STATS_ATTR_PAD,
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	MT76_TM_STATS_ATTR_TX_PENDING,
848c2ecf20Sopenharmony_ci	MT76_TM_STATS_ATTR_TX_QUEUED,
858c2ecf20Sopenharmony_ci	MT76_TM_STATS_ATTR_TX_DONE,
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci	MT76_TM_STATS_ATTR_RX_PACKETS,
888c2ecf20Sopenharmony_ci	MT76_TM_STATS_ATTR_RX_FCS_ERROR,
898c2ecf20Sopenharmony_ci	MT76_TM_STATS_ATTR_LAST_RX,
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci	/* keep last */
928c2ecf20Sopenharmony_ci	NUM_MT76_TM_STATS_ATTRS,
938c2ecf20Sopenharmony_ci	MT76_TM_STATS_ATTR_MAX = NUM_MT76_TM_STATS_ATTRS - 1,
948c2ecf20Sopenharmony_ci};
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci/**
988c2ecf20Sopenharmony_ci * enum mt76_testmode_rx_attr - packet rx information
998c2ecf20Sopenharmony_ci *
1008c2ecf20Sopenharmony_ci * @MT76_TM_RX_ATTR_FREQ_OFFSET: frequency offset (s32)
1018c2ecf20Sopenharmony_ci * @MT76_TM_RX_ATTR_RCPI: received channel power indicator (array, u8)
1028c2ecf20Sopenharmony_ci * @MT76_TM_RX_ATTR_IB_RSSI: internal inband RSSI (s8)
1038c2ecf20Sopenharmony_ci * @MT76_TM_RX_ATTR_WB_RSSI: internal wideband RSSI (s8)
1048c2ecf20Sopenharmony_ci */
1058c2ecf20Sopenharmony_cienum mt76_testmode_rx_attr {
1068c2ecf20Sopenharmony_ci	MT76_TM_RX_ATTR_UNSPEC,
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci	MT76_TM_RX_ATTR_FREQ_OFFSET,
1098c2ecf20Sopenharmony_ci	MT76_TM_RX_ATTR_RCPI,
1108c2ecf20Sopenharmony_ci	MT76_TM_RX_ATTR_IB_RSSI,
1118c2ecf20Sopenharmony_ci	MT76_TM_RX_ATTR_WB_RSSI,
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci	/* keep last */
1148c2ecf20Sopenharmony_ci	NUM_MT76_TM_RX_ATTRS,
1158c2ecf20Sopenharmony_ci	MT76_TM_RX_ATTR_MAX = NUM_MT76_TM_RX_ATTRS - 1,
1168c2ecf20Sopenharmony_ci};
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci/**
1198c2ecf20Sopenharmony_ci * enum mt76_testmode_state - phy test state
1208c2ecf20Sopenharmony_ci *
1218c2ecf20Sopenharmony_ci * @MT76_TM_STATE_OFF: test mode disabled (normal operation)
1228c2ecf20Sopenharmony_ci * @MT76_TM_STATE_IDLE: test mode enabled, but idle
1238c2ecf20Sopenharmony_ci * @MT76_TM_STATE_TX_FRAMES: send a fixed number of test frames
1248c2ecf20Sopenharmony_ci * @MT76_TM_STATE_RX_FRAMES: receive packets and keep statistics
1258c2ecf20Sopenharmony_ci */
1268c2ecf20Sopenharmony_cienum mt76_testmode_state {
1278c2ecf20Sopenharmony_ci	MT76_TM_STATE_OFF,
1288c2ecf20Sopenharmony_ci	MT76_TM_STATE_IDLE,
1298c2ecf20Sopenharmony_ci	MT76_TM_STATE_TX_FRAMES,
1308c2ecf20Sopenharmony_ci	MT76_TM_STATE_RX_FRAMES,
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci	/* keep last */
1338c2ecf20Sopenharmony_ci	NUM_MT76_TM_STATES,
1348c2ecf20Sopenharmony_ci	MT76_TM_STATE_MAX = NUM_MT76_TM_STATES - 1,
1358c2ecf20Sopenharmony_ci};
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci/**
1388c2ecf20Sopenharmony_ci * enum mt76_testmode_tx_mode - packet tx phy mode
1398c2ecf20Sopenharmony_ci *
1408c2ecf20Sopenharmony_ci * @MT76_TM_TX_MODE_CCK: legacy CCK mode
1418c2ecf20Sopenharmony_ci * @MT76_TM_TX_MODE_OFDM: legacy OFDM mode
1428c2ecf20Sopenharmony_ci * @MT76_TM_TX_MODE_HT: 802.11n MCS
1438c2ecf20Sopenharmony_ci * @MT76_TM_TX_MODE_VHT: 802.11ac MCS
1448c2ecf20Sopenharmony_ci */
1458c2ecf20Sopenharmony_cienum mt76_testmode_tx_mode {
1468c2ecf20Sopenharmony_ci	MT76_TM_TX_MODE_CCK,
1478c2ecf20Sopenharmony_ci	MT76_TM_TX_MODE_OFDM,
1488c2ecf20Sopenharmony_ci	MT76_TM_TX_MODE_HT,
1498c2ecf20Sopenharmony_ci	MT76_TM_TX_MODE_VHT,
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci	/* keep last */
1528c2ecf20Sopenharmony_ci	NUM_MT76_TM_TX_MODES,
1538c2ecf20Sopenharmony_ci	MT76_TM_TX_MODE_MAX = NUM_MT76_TM_TX_MODES - 1,
1548c2ecf20Sopenharmony_ci};
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci#endif
157