From 03dd710655b8b31bb1dfd7f2f3e17d9a57454be7 Mon Sep 17 00:00:00 2001 From: spuligil Date: Thu, 16 Aug 2018 00:03:55 -0700 Subject: [PATCH] fw-api: CL 5189165 - update fw common interface files ath10k: provide channel state information, HTT CFR indication Change-Id: I507e4a4aef7d321d3ad834a0ee1f9b8fc1238113 CRs-Fixed: 2262693 --- fw/htt.h | 493 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 493 insertions(+) diff --git a/fw/htt.h b/fw/htt.h index 7143337e3f5a..8c8b7af56598 100644 --- a/fw/htt.h +++ b/fw/htt.h @@ -5597,6 +5597,7 @@ enum htt_t2h_msg_type { HTT_T2H_MSG_TYPE_PEER_UNMAP_V2 = 0x1f, HTT_T2H_MSG_TYPE_MONITOR_MAC_HEADER_IND = 0x20, HTT_T2H_MSG_TYPE_FLOW_POOL_RESIZE = 0x21, + HTT_T2H_MSG_TYPE_CFR_DUMP_COMPL_IND = 0x22, HTT_T2H_MSG_TYPE_TEST, /* keep this last */ @@ -10589,4 +10590,496 @@ PREPACK struct htt_flow_pool_resize_t { ((_var) |= ((_val) << HTT_FLOW_POOL_RESIZE_FLOW_POOL_NEW_SIZE_S)); \ } while (0) +/** + * @brief host -> target channel change message + * + * @details + * the meesage is generated by FW every time FW changes channel. This will be used by host mainly + * to associate RX frames to correct channel they were received on. + * The following field definitions describe the format of the HTT target + * to host channel change message. + * |31 16|15 8|7 5|4 0| + * |------------------------------------------------------------| + * | reserved | MSG_TYPE | + * |------------------------------------------------------------| + * | CHAN_MHZ | + * |------------------------------------------------------------| + * | BAND_CENTER_FREQ1 | + * |------------------------------------------------------------| + * | BAND_CENTER_FREQ2 | + * |------------------------------------------------------------| + * | CHAN_PHY_MODE | + * |------------------------------------------------------------| + * Header fields: + * - MSG_TYPE + * Bits 7:0 + * Value: 0xf + * - CHAN_MHZ + * Bits 31:0 + * Purpose: frequency of the primary 20mhz channel. + * - BAND_CENTER_FREQ1 + * Bits 31:0 + * Purpose: centre frequency of the full channel. + * - BAND_CENTER_FREQ2 + * Bits 31:0 + * Purpose: centre frequency2 of the channel. is only valid for 11acvht 80plus80. + * - CHAN_PHY_MODE + * Bits 31:0 + * Purpose: phy mode of the channel. +*/ + +PREPACK struct htt_chan_change_msg { + A_UINT32 chan_mhz; /* frequency in mhz */ + + A_UINT32 band_center_freq1; /* Center frequency 1 in MHz*/ + + A_UINT32 band_center_freq2; /* Center frequency 2 in MHz - valid only for 11acvht 80plus80 mode*/ + + A_UINT32 chan_mode; /* WLAN_PHY_MODE of the channel defined in wlan_defs.h */ +} POSTPACK; + +#define HTT_CFR_CAPTURE_MAGIC_PATTERN 0xCCCCCCCC +#define HTT_CFR_CAPTURE_READ_INDEX_OFFSET 0 /* bytes */ +#define HTT_CFR_CAPTURE_SIZEOF_READ_INDEX_BYTES 4 +#define HTT_CFR_CAPTURE_WRITE_INDEX_OFFSET /* bytes */ \ + (HTT_CFR_CAPTURE_READ_INDEX_OFFSET + HTT_CFR_CAPTURE_SIZEOF_READ_INDEX_BYTES) +#define HTT_CFR_CAPTURE_SIZEOF_WRITE_INDEX_BYTES 4 +#define HTT_CFR_CAPTURE_SIZEOF_MAGIC_PATTERN_BYTES 4 +/* + * The read and write indices point to the data within the host buffer. + * Because the first 4 bytes of the host buffer is used for the read index and + * the next 4 bytes for the write index, the data itself starts at offset 8. + * The read index and write index are the byte offsets from the base of the + * meta-data buffer, and thus have a minimum value of 8 rather than 0. + * Refer the ASCII text picture below. + */ +#define HTT_CFR_CAPTURE_INITIAL_RW_START_INDEX \ + (HTT_CFR_CAPTURE_SIZEOF_READ_INDEX_BYTES + \ + HTT_CFR_CAPTURE_SIZEOF_WRITE_INDEX_BYTES) + +/* + *************************************************************************** + * + * Layout when CFR capture message type is 'HTT_PEER_CFR_CAPTURE_MSG_TYPE_1' + * + *************************************************************************** + * + * The memory allocated by WMI_CHANNEL_CAPTURE_HOST_MEM_REQ_ID is used + * in the below format. The HTT message 'htt_cfr_dump_compl_ind' is sent by + * FW to Host whenever a CFR capture (CFR data1 or CFR data2 etc.,) is + * written into the Host memory region mentioned below. + * + * Read index is updated by the Host. At any point of time, the read index will + * indicate the index that will next be read by the Host. The read index is + * in units of bytes offset from the base of the meta-data buffer. + * + * Write index is updated by the FW. At any point of time, the write index will + * indicate from where the FW can start writing any new data. The write index is + * in units of bytes offset from the base of the meta-data buffer. + * + * If the Host is not fast enough in reading the CFR data, any new capture data + * would be dropped if there is no space left to write the new captures. + * + * The last 4 bytes of the memory region will have the magic pattern + * HTT_CFR_CAPTURE_MAGIC_PATTERN. This can be used to ensure that the FW does + * not overrun the host buffer. + * + * ,--------------------. read and write indices store the + * | | byte offset from the base of the + * | ,--------+--------. meta-data buffer to the next + * | | | | location within the data buffer + * | | v v that will be read / written + * ************************************************************************ + * * Read * Write * * Magic * + * * index * index * CFR data1 ...... CFR data N * pattern * + * * (4 bytes) * (4 bytes) * * (4 bytes)* + * ************************************************************************ + * |<---------- data buffer ---------->| + * + * |<----------------- meta-data buffer allocated in Host ----------------| + * + * Note: + * - Considering the 4 bytes needed to store the Read index (R) and the + * Write index (W), the initial value is as follows: + * R = W = HTT_CFR_CAPTURE_INITIAL_RW_START_INDEX + * - Buffer empty condition: + * R = W + * + * Regarding CFR data format: + * -------------------------- + * + * Each CFR tone is stored in HW as 16-bits with the following format: + * {bits[15:12], bits[11:6], bits[5:0]} = + * {unsigned exponent (4 bits), + * signed mantissa_real (6 bits), + * signed mantissa_imag (6 bits)} + * + * CFR_real = mantissa_real * 2^(exponent-5) + * CFR_imag = mantissa_imag * 2^(exponent-5) + * + * + * The CFR data is written to the 16-bit unsigned output array (buff) in + * ascending tone order. For example, the Legacy20 CFR is output as follows: + * + * buff[0]: [CFR_exp[-26], CFR_mant_real[-26], CFR_mant_imag[-26]] + * buff[1]: [CFR_exp[-25], CFR_mant_real[-25], CFR_mant_imag[-25]] + * . + * . + * . + * buff[N-2]: [CFR_exp[25], CFR_mant_real[25], CFR_mant_imag[25]] + * buff[N-1]: [CFR_exp[26], CFR_mant_real[26], CFR_mant_imag[26]] + */ + +/* Bandwidth of peer CFR captures */ +typedef enum { + HTT_PEER_CFR_CAPTURE_BW_20MHZ = 0, + HTT_PEER_CFR_CAPTURE_BW_40MHZ = 1, + HTT_PEER_CFR_CAPTURE_BW_80MHZ = 2, + HTT_PEER_CFR_CAPTURE_BW_160MHZ = 3, + HTT_PEER_CFR_CAPTURE_BW_80_80MHZ = 4, + HTT_PEER_CFR_CAPTURE_BW_MAX, +} HTT_PEER_CFR_CAPTURE_BW; + +/* Mode of the peer CFR captures. The type of RX frame for which the CFR + * was captured + */ +typedef enum { + HTT_PEER_CFR_CAPTURE_MODE_LEGACY = 0, + HTT_PEER_CFR_CAPTURE_MODE_DUP_LEGACY = 1, + HTT_PEER_CFR_CAPTURE_MODE_HT = 2, + HTT_PEER_CFR_CAPTURE_MODE_VHT = 3, + HTT_PEER_CFR_CAPTURE_MODE_MAX, +} HTT_PEER_CFR_CAPTURE_MODE; + +typedef enum { + /* This message type is currently used for the below purpose: + * + * - capture_method = WMI_PEER_CFR_CAPTURE_METHOD_NULL_FRAME in the + * wmi_peer_cfr_capture_cmd. The associated memory region gets allocated + * through WMI_CHANNEL_CAPTURE_HOST_MEM_REQ_ID + */ + HTT_PEER_CFR_CAPTURE_MSG_TYPE_1 = 0x1, + + /* Always keep this last */ + HTT_PEER_CFR_CAPTURE_MSG_TYPE_MAX, +} HTT_PEER_CFR_CAPTURE_MSG_TYPE; + +/** + * @brief target -> host CFR dump completion indication message definition + * htt_cfr_dump_compl_ind when the version is HTT_PEER_CFR_CAPTURE_MSG_TYPE_1. + * + * @details + * The following diagram shows the format of the Channel Frequency Response + * (CFR) dump completion indication. This inidcation is sent to the Host when + * the channel capture of a peer is copied by Firmware into the Host memory + * + * ************************************************************************** + * + * Message format when the CFR capture message type is + * 'HTT_PEER_CFR_CAPTURE_MSG_TYPE_1' + * + * ************************************************************************** + * + * |31 16|15 |7 0| + * |----------------------------------------------------------------| + * header: | reserved | msg_type | + * word 0 | | | + * |----------------------------------------------------------------| + * payload: | cfr_capture_msg_type | + * word 1 | | + * |----------------------------------------------------------------| + * | vdev_id | captype | chbw | sts | mode | capbw |S| req_id | + * word 2 | | | | | | | | | + * |----------------------------------------------------------------| + * | mac_addr31to0 | + * word 3 | | + * |----------------------------------------------------------------| + * | unused / reserved | mac_addr47to32 | + * word 4 | | | + * |----------------------------------------------------------------| + * | index | + * word 5 | | + * |----------------------------------------------------------------| + * | length | + * word 6 | | + * |----------------------------------------------------------------| + * | timestamp | + * word 7 | | + * |----------------------------------------------------------------| + * | counter | + * word 8 | | + * |----------------------------------------------------------------| + * | chan_mhz | + * word 9 | | + * |----------------------------------------------------------------| + * | band_center_freq1 | + * word 10 | | + * |----------------------------------------------------------------| + * | band_center_freq2 | + * word 11 | | + * |----------------------------------------------------------------| + * | chan_phy_mode | + * word 12 | | + * |----------------------------------------------------------------| + * where, + * req_id - memory request id (mem_req_id explained below) + * S - status field (status explained below) + * capbw - capture bandwidth (capture_bw explained below) + * mode - mode of capture (mode explained below) + * sts - space time streams (sts_count explained below) + * chbw - channel bandwidth (channel_bw explained below) + * captype - capture type (cap_type explained below) + * + * The following field definitions describe the format of the CFR dump + * completion indication sent from the target to the host + * + * Header fields: + * + * Word 0 + * - msg_type + * Bits 7:0 + * Purpose: Identifies this as CFR TX completion indication + * Value: HTT_T2H_MSG_TYPE_CFR_DUMP_COMPL_IND + * - reserved + * Bits 31:8 + * Purpose: Reserved + * Value: 0 + * + * Payload fields: + * + * Word 1 + * - cfr_capture_msg_type + * Bits 31:0 + * Purpose: Contains the type of the message HTT_PEER_CFR_CAPTURE_MSG_TYPE + * to specify the format used for the remainder of the message + * Value: HTT_PEER_CFR_CAPTURE_MSG_TYPE_1 + * (currently only MSG_TYPE_1 is defined) + * + * Word 2 + * - mem_req_id + * Bits 6:0 + * Purpose: Contain the mem request id of the region where the CFR capture + * has been stored - of type WMI_HOST_MEM_REQ_ID + * Value: WMI_CHANNEL_CAPTURE_HOST_MEM_REQ_ID + * - status + * Bit 7 + * Purpose: Boolean value carrying the status of the CFR capture of the peer + * Value: 1 (True) - Successful; 0 (False) - Not successful + * - capture_bw + * Bits 10:8 + * Purpose: Carry the bandwidth of the CFR capture + * Value: Bandwidth of the CFR capture of type HTT_PEER_CFR_CAPTURE_BW + * - mode + * Bits 13:11 + * Purpose: Carry the mode of the rx frame for which the CFR was captured + * Value: Mode of the CFR capture of type HTT_PEER_CFR_CAPTURE_MODE + * - sts_count + * Bits 16:14 + * Purpose: Carry the number of space time streams + * Value: Number of space time streams + * - channel_bw + * Bits 19:17 + * Purpose: Carry the bandwidth of the channel of the vdev performing the + * measurement + * Value: Bandwidth of the channel (of type HTT_PEER_CFR_CAPTURE_BW) + * - cap_type + * Bits 23:20 + * Purpose: Carry the type of the capture + * Value: Capture type (of type WMI_PEER_CFR_CAPTURE_METHOD) + * - vdev_id + * Bits 31:24 + * Purpose: Carry the virtual device id + * Value: vdev ID + * + * Word 3 + * - mac_addr31to0 + * Bits 31:0 + * Purpose: Contain the bits 31:0 of the peer MAC address + * Value: Bits 31:0 of the peer MAC address + * + * Word 4 + * - mac_addr47to32 + * Bits 15:0 + * Purpose: Contain the bits 47:32 of the peer MAC address + * Value: Bits 47:32 of the peer MAC address + * + * Word 5 + * - index + * Bits 31:0 + * Purpose: Contain the index at which this CFR dump was written in the Host + * allocated memory. This index is the number of bytes from the base address. + * Value: Index position + * + * Word 6 + * - length + * Bits 31:0 + * Purpose: Carry the length of the CFR capture of the peer, in bytes + * Value: Length of the CFR capture of the peer + * + * Word 7 + * - timestamp + * Bits 31:0 + * Purpose: Carry the time at which the CFR was captured in the hardware. The + * clock used for this timestamp is private to the target and not visible to + * the host i.e., Host can interpret only the relative timestamp deltas from + * one message to the next, but can't interpret the absolute timestamp from a + * single message. + * Value: Timestamp in microseconds + * + * Word 8 + * - counter + * Bits 31:0 + * Purpose: Carry the count of the current CFR capture from FW. This is + * helpful to identify any drops in FW in any scenario (e.g., lack of space + * in host memory) + * Value: Count of the current CFR capture + * + * Word 9 + * - chan_mhz + * Bits 31:0 + * Purpose: Carry the primary 20 MHz channel frequency in MHz of the VDEV + * Value: Primary 20 channel frequency + * + * Word 10 + * - band_center_freq1 + * Bits 31:0 + * Purpose: Carry the center frequency 1 in MHz of the VDEV + * Value: Center frequency 1 in MHz + * + * Word 11 + * - band_center_freq2 + * Bits 31:0 + * Purpose: Carry the center frequency 2 in MHz. valid only for 11acvht of + * the VDEV + * 80plus80 mode + * Value: Center frequency 2 in MHz + * + * Word 12 + * - chan_phy_mode + * Bits 31:0 + * Purpose: Carry the phy mode of the channel, of the VDEV + * Value: WLAN_PHY_MODE of the channel defined in wlan_defs.h + */ +PREPACK struct htt_cfr_dump_ind_type_1 { + A_UINT32 mem_req_id:7, + status:1, + capture_bw:3, + mode:3, + sts_count:3, + channel_bw:3, + cap_type:4, + vdev_id:8; + htt_mac_addr addr; + A_UINT32 index; + A_UINT32 length; + A_UINT32 timestamp; + A_UINT32 counter; + struct htt_chan_change_msg chan; +} POSTPACK; + +PREPACK struct htt_cfr_dump_compl_ind { + A_UINT32 msg_type; /* HTT_PEER_CFR_CAPTURE_MSG_TYPE */ + union { + /* Message format when msg_type = HTT_PEER_CFR_CAPTURE_MSG_TYPE_1 */ + struct htt_cfr_dump_ind_type_1 htt_cfr_dump_compl_ind_type_1; + /* If there is a need to change the memory layout and its associated + * HTT indication format, a new CFR capture message type can be + * introduced and added into this union. + */ + }; +} POSTPACK; + +/* + * Get / set macros for the bit fields within WORD-2 of htt_cfr_dump_compl_ind, + * msg_type = HTT_PEER_CFR_CAPTURE_MSG_TYPE_1 + */ +#define HTT_T2H_CFR_DUMP_TYPE1_MEM_REQ_ID_M 0X0000007F +#define HTT_T2H_CFR_DUMP_TYPE1_MEM_REQ_ID_S 0 +#define HTT_T2H_CFR_DUMP_TYPE1_STATUS_M 0X00000080 +#define HTT_T2H_CFR_DUMP_TYPE1_STATUS_S 7 +#define HTT_T2H_CFR_DUMP_TYPE1_CAP_BW_M 0X00000700 +#define HTT_T2H_CFR_DUMP_TYPE1_CAP_BW_S 8 +#define HTT_T2H_CFR_DUMP_TYPE1_MODE_M 0X00003800 +#define HTT_T2H_CFR_DUMP_TYPE1_MODE_S 11 +#define HTT_T2H_CFR_DUMP_TYPE1_STS_M 0X0001C000 +#define HTT_T2H_CFR_DUMP_TYPE1_STS_S 14 +#define HTT_T2H_CFR_DUMP_TYPE1_CHAN_BW_M 0X000E0000 +#define HTT_T2H_CFR_DUMP_TYPE1_CHAN_BW_S 17 +#define HTT_T2H_CFR_DUMP_TYPE1_CAP_TYPE_M 0X00F00000 +#define HTT_T2H_CFR_DUMP_TYPE1_CAP_TYPE_S 20 +#define HTT_T2H_CFR_DUMP_TYPE1_VDEV_ID_M 0XFF000000 +#define HTT_T2H_CFR_DUMP_TYPE1_VDEV_ID_S 24 + +#define HTT_T2H_CFR_DUMP_TYPE1_MEM_REQ_ID_SET(word, value) \ + do { \ + HTT_CHECK_SET_VAL(HTT_T2H_CFR_DUMP_TYPE1_MEM_REQ_ID, value); \ + (word) |= (value) << HTT_T2H_CFR_DUMP_TYPE1_MEM_REQ_ID_S; \ + } while (0) +#define HTT_T2H_CFR_DUMP_TYPE1_MEM_REQ_ID_GET(word) \ + (((word) & HTT_T2H_CFR_DUMP_TYPE1_MEM_REQ_ID_M) >> \ + HTT_T2H_CFR_DUMP_TYPE1_MEM_REQ_ID_S) + +#define HTT_T2H_CFR_DUMP_TYPE1_STATUS_SET(word, value) \ + do { \ + HTT_CHECK_SET_VAL(HTT_T2H_CFR_DUMP_TYPE1_STATUS, value); \ + (word) |= (value) << HTT_T2H_CFR_DUMP_TYPE1_STATUS_S; \ + } while (0) +#define HTT_T2H_CFR_DUMP_TYPE1_STATUS_GET(word) \ + (((word) & HTT_T2H_CFR_DUMP_TYPE1_STATUS_M) >> \ + HTT_T2H_CFR_DUMP_TYPE1_STATUS_S) + +#define HTT_T2H_CFR_DUMP_TYPE1_CAP_BW_SET(word, value) \ + do { \ + HTT_CHECK_SET_VAL(HTT_T2H_CFR_DUMP_TYPE1_CAP_BW, value); \ + (word) |= (value) << HTT_T2H_CFR_DUMP_TYPE1_CAP_BW_S; \ + } while (0) +#define HTT_T2H_CFR_DUMP_TYPE1_CAP_BW_GET(word) \ + (((word) & HTT_T2H_CFR_DUMP_TYPE1_CAP_BW_M) >> \ + HTT_T2H_CFR_DUMP_TYPE1_CAP_BW_S) + +#define HTT_T2H_CFR_DUMP_TYPE1_MODE_SET(word, value) \ + do { \ + HTT_CHECK_SET_VAL(HTT_T2H_CFR_DUMP_TYPE1_MODE, value); \ + (word) |= (value) << HTT_T2H_CFR_DUMP_TYPE1_MODE_S; \ + } while (0) +#define HTT_T2H_CFR_DUMP_TYPE1_MODE_GET(word) \ + (((word) & HTT_T2H_CFR_DUMP_TYPE1_MODE_M) >> \ + HTT_T2H_CFR_DUMP_TYPE1_MODE_S) + +#define HTT_T2H_CFR_DUMP_TYPE1_STS_SET(word, value) \ + do { \ + HTT_CHECK_SET_VAL(HTT_T2H_CFR_DUMP_TYPE1_STS, value); \ + (word) |= (value) << HTT_T2H_CFR_DUMP_TYPE1_STS_S; \ + } while (0) +#define HTT_T2H_CFR_DUMP_TYPE1_STS_GET(word) \ + (((word) & HTT_T2H_CFR_DUMP_TYPE1_STS_M) >> \ + HTT_T2H_CFR_DUMP_TYPE1_STS_S) + +#define HTT_T2H_CFR_DUMP_TYPE1_CHAN_BW_SET(word, value) \ + do { \ + HTT_CHECK_SET_VAL(HTT_T2H_CFR_DUMP_TYPE1_CHAN_BW, value); \ + (word) |= (value) << HTT_T2H_CFR_DUMP_TYPE1_CHAN_BW_S; \ + } while (0) +#define HTT_T2H_CFR_DUMP_TYPE1_CHAN_BW_GET(word) \ + (((word) & HTT_T2H_CFR_DUMP_TYPE1_CHAN_BW_M) >> \ + HTT_T2H_CFR_DUMP_TYPE1_CHAN_BW_S) + +#define HTT_T2H_CFR_DUMP_TYPE1_CAP_TYPE_SET(word, value) \ + do { \ + HTT_CHECK_SET_VAL(HTT_T2H_CFR_DUMP_TYPE1_CAP_TYPE, value); \ + (word) |= (value) << HTT_T2H_CFR_DUMP_TYPE1_CAP_TYPE_S; \ + } while (0) +#define HTT_T2H_CFR_DUMP_TYPE1_CAP_TYPE_GET(word) \ + (((word) & HTT_T2H_CFR_DUMP_TYPE1_CAP_TYPE_M) >> \ + HTT_T2H_CFR_DUMP_TYPE1_CAP_TYPE_S) + +#define HTT_T2H_CFR_DUMP_TYPE1_VDEV_ID_SET(word, value) \ + do { \ + HTT_CHECK_SET_VAL(HTT_T2H_CFR_DUMP_TYPE1_VDEV_ID, value); \ + (word) |= (value) << HTT_T2H_CFR_DUMP_TYPE1_VDEV_ID_S; \ + } while (0) +#define HTT_T2H_CFR_DUMP_TYPE1_VDEV_ID_GET(word) \ + (((word) & HTT_T2H_CFR_DUMP_TYPE1_VDEV_ID_M) >> \ + HTT_T2H_CFR_DUMP_TYPE1_VDEV_ID_S) + #endif