1 /****************************************************************************** 2 * 3 * Copyright(c) 2007 - 2017 Realtek Corporation. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 *****************************************************************************/ 15 #ifndef __COMMON_C2H_H__ 16 #define __COMMON_C2H_H__ 17 18 #define C2H_TYPE_REG 0 19 #define C2H_TYPE_PKT 1 20 21 /* 22 * C2H event format: 23 * Fields TRIGGER PAYLOAD SEQ PLEN ID 24 * BITS [127:120] [119:16] [15:8] [7:4] [3:0] 25 */ 26 #define C2H_ID(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)), 0, 4) 27 #define C2H_PLEN(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)), 4, 4) 28 #define C2H_SEQ(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)) + 1, 0, 8) 29 #define C2H_PAYLOAD(_c2h) (((u8*)(_c2h)) + 2) 30 31 #define SET_C2H_ID(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)), 0, 4, _val) 32 #define SET_C2H_PLEN(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)), 4, 4, _val) 33 #define SET_C2H_SEQ(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)) + 1 , 0, 8, _val) 34 35 /* 36 * C2H event format: 37 * Fields TRIGGER PLEN PAYLOAD SEQ ID 38 * BITS [127:120] [119:112] [111:16] [15:8] [7:0] 39 */ 40 #define C2H_ID_88XX(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)), 0, 8) 41 #define C2H_SEQ_88XX(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)) + 1, 0, 8) 42 #define C2H_PAYLOAD_88XX(_c2h) (((u8*)(_c2h)) + 2) 43 #define C2H_PLEN_88XX(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)) + 14, 0, 8) 44 #define C2H_TRIGGER_88XX(_c2h) LE_BITS_TO_1BYTE(((u8*)(_c2h)) + 15, 0, 8) 45 46 #define SET_C2H_ID_88XX(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)), 0, 8, _val) 47 #define SET_C2H_SEQ_88XX(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)) + 1, 0, 8, _val) 48 #define SET_C2H_PLEN_88XX(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)) + 14, 0, 8, _val) 49 50 typedef enum _C2H_EVT { 51 C2H_DBG = 0x00, 52 C2H_LB = 0x01, 53 C2H_TXBF = 0x02, 54 C2H_CCX_TX_RPT = 0x03, 55 C2H_AP_REQ_TXRPT = 0x04, 56 C2H_FW_SCAN_COMPLETE = 0x7, 57 C2H_BT_INFO = 0x09, 58 C2H_BT_MP_INFO = 0x0B, 59 C2H_RA_RPT = 0x0C, 60 C2H_SPC_STAT = 0x0D, 61 C2H_RA_PARA_RPT = 0x0E, 62 C2H_FW_CHNL_SWITCH_COMPLETE = 0x10, 63 C2H_IQK_FINISH = 0x11, 64 C2H_MAILBOX_STATUS = 0x15, 65 C2H_P2P_RPORT = 0x16, 66 C2H_MCC = 0x17, 67 C2H_MAC_HIDDEN_RPT = 0x19, 68 C2H_MAC_HIDDEN_RPT_2 = 0x1A, 69 C2H_BCN_EARLY_RPT = 0x1E, 70 C2H_DEFEATURE_DBG = 0x22, 71 C2H_CUSTOMER_STR_RPT = 0x24, 72 C2H_CUSTOMER_STR_RPT_2 = 0x25, 73 C2H_WLAN_INFO = 0x27, 74 #ifdef RTW_PER_CMD_SUPPORT_FW 75 C2H_PER_RATE_RPT = 0x2c, 76 #endif 77 C2H_LPS_STATUS_RPT = 0x32, 78 C2H_SET_TXPWR_FINISH = 0x70, 79 C2H_DEFEATURE_RSVD = 0xFD, 80 C2H_EXTEND = 0xff, 81 } C2H_EVT; 82 83 typedef enum _EXTEND_C2H_EVT { 84 EXTEND_C2H_DBG_PRINT = 0 85 } EXTEND_C2H_EVT; 86 87 #define C2H_REG_LEN 16 88 89 /* C2H_IQK_FINISH, 0x11 */ 90 #define IQK_OFFLOAD_LEN 1 91 void c2h_iqk_offload(_adapter *adapter, u8 *data, u8 len); 92 int c2h_iqk_offload_wait(_adapter *adapter, u32 timeout_ms); 93 #define rtl8812_iqk_wait c2h_iqk_offload_wait /* TODO: remove this after phydm call c2h_iqk_offload_wait instead */ 94 95 #ifdef CONFIG_RTW_MAC_HIDDEN_RPT 96 /* C2H_MAC_HIDDEN_RPT, 0x19 */ 97 #define MAC_HIDDEN_RPT_LEN 8 98 int c2h_mac_hidden_rpt_hdl(_adapter *adapter, u8 *data, u8 len); 99 100 /* C2H_MAC_HIDDEN_RPT_2, 0x1A */ 101 #define MAC_HIDDEN_RPT_2_LEN 5 102 int c2h_mac_hidden_rpt_2_hdl(_adapter *adapter, u8 *data, u8 len); 103 int hal_read_mac_hidden_rpt(_adapter *adapter); 104 #else 105 #define hal_read_mac_hidden_rpt(adapter) _SUCCESS 106 #endif /* CONFIG_RTW_MAC_HIDDEN_RPT */ 107 108 /* C2H_DEFEATURE_DBG, 0x22 */ 109 #define DEFEATURE_DBG_LEN 1 110 int c2h_defeature_dbg_hdl(_adapter *adapter, u8 *data, u8 len); 111 112 #ifdef CONFIG_RTW_CUSTOMER_STR 113 /* C2H_CUSTOMER_STR_RPT, 0x24 */ 114 #define CUSTOMER_STR_RPT_LEN 8 115 int c2h_customer_str_rpt_hdl(_adapter *adapter, u8 *data, u8 len); 116 117 /* C2H_CUSTOMER_STR_RPT_2, 0x25 */ 118 #define CUSTOMER_STR_RPT_2_LEN 8 119 int c2h_customer_str_rpt_2_hdl(_adapter *adapter, u8 *data, u8 len); 120 #endif /* CONFIG_RTW_CUSTOMER_STR */ 121 122 #ifdef RTW_PER_CMD_SUPPORT_FW 123 /* C2H_PER_RATE_RPT, 0x2c */ 124 int c2h_per_rate_rpt_hdl(_adapter *adapter, u8 *data, u8 len); 125 #endif 126 127 #ifdef CONFIG_LPS_ACK 128 /* C2H_LPS_STATUS_RPT, 0x32 */ 129 #define LPS_STATUS_RPT_LEN 2 130 int c2h_lps_status_rpt(PADAPTER adapter, u8 *data, u8 len); 131 #endif /* CONFIG_LPS_ACK */ 132 133 #ifdef CONFIG_FW_OFFLOAD_SET_TXPWR_IDX 134 /* C2H_SET_TXPWR_FINISH, 0x70 */ 135 #define SET_TXPWR_FINISH_LEN 1 136 void c2h_txpwr_idx_offload_done(_adapter *adapter, u8 *data, u8 len); 137 int c2h_txpwr_idx_offload_wait(_adapter *adapter); 138 #endif 139 140 void rtw_hal_bcn_early_rpt_c2h_handler(_adapter *adapter); 141 142 #endif /* __COMMON_C2H_H__ */ 143