Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (c) 2014 Redpine Signals Inc. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __RSI_MAIN_H__ |
| 18 | #define __RSI_MAIN_H__ |
| 19 | |
| 20 | #include <linux/string.h> |
| 21 | #include <linux/skbuff.h> |
| 22 | #include <net/mac80211.h> |
| 23 | |
| 24 | #define ERR_ZONE BIT(0) /* For Error Msgs */ |
| 25 | #define INFO_ZONE BIT(1) /* For General Status Msgs */ |
| 26 | #define INIT_ZONE BIT(2) /* For Driver Init Seq Msgs */ |
| 27 | #define MGMT_TX_ZONE BIT(3) /* For TX Mgmt Path Msgs */ |
| 28 | #define MGMT_RX_ZONE BIT(4) /* For RX Mgmt Path Msgs */ |
| 29 | #define DATA_TX_ZONE BIT(5) /* For TX Data Path Msgs */ |
| 30 | #define DATA_RX_ZONE BIT(6) /* For RX Data Path Msgs */ |
| 31 | #define FSM_ZONE BIT(7) /* For State Machine Msgs */ |
| 32 | #define ISR_ZONE BIT(8) /* For Interrupt Msgs */ |
| 33 | |
Amitkumar Karwar | 4833c95 | 2017-06-16 20:05:37 +0530 | [diff] [blame] | 34 | enum RSI_FSM_STATES { |
Prameela Rani Garnepudi | 015e367 | 2017-06-16 20:05:38 +0530 | [diff] [blame] | 35 | FSM_FW_NOT_LOADED, |
Amitkumar Karwar | 4833c95 | 2017-06-16 20:05:37 +0530 | [diff] [blame] | 36 | FSM_CARD_NOT_READY, |
Prameela Rani Garnepudi | 9920322 | 2017-06-16 20:12:05 +0530 | [diff] [blame] | 37 | FSM_COMMON_DEV_PARAMS_SENT, |
Amitkumar Karwar | 4833c95 | 2017-06-16 20:05:37 +0530 | [diff] [blame] | 38 | FSM_BOOT_PARAMS_SENT, |
| 39 | FSM_EEPROM_READ_MAC_ADDR, |
| 40 | FSM_RESET_MAC_SENT, |
| 41 | FSM_RADIO_CAPS_SENT, |
| 42 | FSM_BB_RF_PROG_SENT, |
| 43 | FSM_MAC_INIT_DONE |
| 44 | }; |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 45 | |
| 46 | extern u32 rsi_zone_enabled; |
Joe Perches | 5fe1b76 | 2014-03-18 17:59:47 -0700 | [diff] [blame] | 47 | extern __printf(2, 3) void rsi_dbg(u32 zone, const char *fmt, ...); |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 48 | |
| 49 | #define RSI_MAX_VIFS 1 |
| 50 | #define NUM_EDCA_QUEUES 4 |
| 51 | #define IEEE80211_ADDR_LEN 6 |
| 52 | #define FRAME_DESC_SZ 16 |
| 53 | #define MIN_802_11_HDR_LEN 24 |
| 54 | |
| 55 | #define DATA_QUEUE_WATER_MARK 400 |
| 56 | #define MIN_DATA_QUEUE_WATER_MARK 300 |
| 57 | #define MULTICAST_WATER_MARK 200 |
| 58 | #define MAC_80211_HDR_FRAME_CONTROL 0 |
| 59 | #define WME_NUM_AC 4 |
| 60 | #define NUM_SOFT_QUEUES 5 |
| 61 | #define MAX_HW_QUEUES 8 |
| 62 | #define INVALID_QUEUE 0xff |
| 63 | #define MAX_CONTINUOUS_VO_PKTS 8 |
| 64 | #define MAX_CONTINUOUS_VI_PKTS 4 |
| 65 | |
| 66 | /* Queue information */ |
Prameela Rani Garnepudi | 61f2a6f | 2017-06-16 20:05:39 +0530 | [diff] [blame] | 67 | #define RSI_COEX_Q 0x0 |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 68 | #define RSI_WIFI_MGMT_Q 0x4 |
| 69 | #define RSI_WIFI_DATA_Q 0x5 |
| 70 | #define IEEE80211_MGMT_FRAME 0x00 |
| 71 | #define IEEE80211_CTL_FRAME 0x04 |
| 72 | |
| 73 | #define IEEE80211_QOS_TID 0x0f |
| 74 | #define IEEE80211_NONQOS_TID 16 |
| 75 | |
| 76 | #define MAX_DEBUGFS_ENTRIES 4 |
| 77 | |
| 78 | #define TID_TO_WME_AC(_tid) ( \ |
| 79 | ((_tid) == 0 || (_tid) == 3) ? BE_Q : \ |
| 80 | ((_tid) < 3) ? BK_Q : \ |
| 81 | ((_tid) < 6) ? VI_Q : \ |
| 82 | VO_Q) |
| 83 | |
| 84 | #define WME_AC(_q) ( \ |
| 85 | ((_q) == BK_Q) ? IEEE80211_AC_BK : \ |
| 86 | ((_q) == BE_Q) ? IEEE80211_AC_BE : \ |
| 87 | ((_q) == VI_Q) ? IEEE80211_AC_VI : \ |
| 88 | IEEE80211_AC_VO) |
| 89 | |
Prameela Rani Garnepudi | b78e91b | 2017-05-16 15:31:16 +0530 | [diff] [blame] | 90 | #define RSI_DEV_9113 1 |
| 91 | |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 92 | struct version_info { |
| 93 | u16 major; |
| 94 | u16 minor; |
| 95 | u16 release_num; |
| 96 | u16 patch_num; |
| 97 | } __packed; |
| 98 | |
| 99 | struct skb_info { |
| 100 | s8 rssi; |
| 101 | u32 flags; |
| 102 | u16 channel; |
| 103 | s8 tid; |
| 104 | s8 sta_id; |
| 105 | }; |
| 106 | |
| 107 | enum edca_queue { |
| 108 | BK_Q, |
| 109 | BE_Q, |
| 110 | VI_Q, |
| 111 | VO_Q, |
| 112 | MGMT_SOFT_Q |
| 113 | }; |
| 114 | |
| 115 | struct security_info { |
| 116 | bool security_enable; |
| 117 | u32 ptk_cipher; |
| 118 | u32 gtk_cipher; |
| 119 | }; |
| 120 | |
| 121 | struct wmm_qinfo { |
| 122 | s32 weight; |
| 123 | s32 wme_params; |
| 124 | s32 pkt_contended; |
Jahnavi Meher | 360accb | 2014-06-16 19:45:03 +0530 | [diff] [blame] | 125 | s32 txop; |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | struct transmit_q_stats { |
| 129 | u32 total_tx_pkt_send[NUM_EDCA_QUEUES + 1]; |
| 130 | u32 total_tx_pkt_freed[NUM_EDCA_QUEUES + 1]; |
| 131 | }; |
| 132 | |
| 133 | struct vif_priv { |
| 134 | bool is_ht; |
| 135 | bool sgi; |
| 136 | u16 seq_start; |
| 137 | }; |
| 138 | |
| 139 | struct rsi_event { |
| 140 | atomic_t event_condition; |
| 141 | wait_queue_head_t event_queue; |
| 142 | }; |
| 143 | |
| 144 | struct rsi_thread { |
| 145 | void (*thread_function)(void *); |
| 146 | struct completion completion; |
| 147 | struct task_struct *task; |
| 148 | struct rsi_event event; |
| 149 | atomic_t thread_done; |
| 150 | }; |
| 151 | |
Jahnavi Meher | 686a254 | 2014-06-16 19:46:48 +0530 | [diff] [blame] | 152 | struct cqm_info { |
| 153 | s8 last_cqm_event_rssi; |
| 154 | int rssi_thold; |
| 155 | u32 rssi_hyst; |
| 156 | }; |
| 157 | |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 158 | struct rsi_hw; |
| 159 | |
| 160 | struct rsi_common { |
| 161 | struct rsi_hw *priv; |
| 162 | struct vif_priv vif_info[RSI_MAX_VIFS]; |
| 163 | |
| 164 | bool mgmt_q_block; |
| 165 | struct version_info driver_ver; |
| 166 | struct version_info fw_ver; |
| 167 | |
| 168 | struct rsi_thread tx_thread; |
| 169 | struct sk_buff_head tx_queue[NUM_EDCA_QUEUES + 1]; |
| 170 | /* Mutex declaration */ |
| 171 | struct mutex mutex; |
| 172 | /* Mutex used between tx/rx threads */ |
| 173 | struct mutex tx_rxlock; |
| 174 | u8 endpoint; |
| 175 | |
| 176 | /* Channel/band related */ |
| 177 | u8 band; |
| 178 | u8 channel_width; |
| 179 | |
| 180 | u16 rts_threshold; |
| 181 | u16 bitrate_mask[2]; |
| 182 | u32 fixedrate_mask[2]; |
| 183 | |
| 184 | u8 rf_reset; |
| 185 | struct transmit_q_stats tx_stats; |
| 186 | struct security_info secinfo; |
| 187 | struct wmm_qinfo tx_qinfo[NUM_EDCA_QUEUES]; |
| 188 | struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES]; |
| 189 | u8 mac_addr[IEEE80211_ADDR_LEN]; |
| 190 | |
| 191 | /* state related */ |
| 192 | u32 fsm_state; |
| 193 | bool init_done; |
| 194 | u8 bb_rf_prog_count; |
| 195 | bool iface_down; |
| 196 | |
| 197 | /* Generic */ |
| 198 | u8 channel; |
| 199 | u8 *rx_data_pkt; |
| 200 | u8 mac_id; |
| 201 | u8 radio_id; |
| 202 | u16 rate_pwr[20]; |
| 203 | u16 min_rate; |
| 204 | |
| 205 | /* WMM algo related */ |
| 206 | u8 selected_qnum; |
| 207 | u32 pkt_cnt; |
| 208 | u8 min_weight; |
Jahnavi Meher | 360accb | 2014-06-16 19:45:03 +0530 | [diff] [blame] | 209 | |
Jahnavi Meher | 686a254 | 2014-06-16 19:46:48 +0530 | [diff] [blame] | 210 | /* bgscan related */ |
| 211 | struct cqm_info cqm_info; |
| 212 | |
Jahnavi Meher | 360accb | 2014-06-16 19:45:03 +0530 | [diff] [blame] | 213 | bool hw_data_qs_blocked; |
Prameela Rani Garnepudi | 9920322 | 2017-06-16 20:12:05 +0530 | [diff] [blame] | 214 | u8 driver_mode; |
Prameela Rani Garnepudi | b78e91b | 2017-05-16 15:31:16 +0530 | [diff] [blame] | 215 | u8 coex_mode; |
Prameela Rani Garnepudi | 9920322 | 2017-06-16 20:12:05 +0530 | [diff] [blame] | 216 | u16 oper_mode; |
| 217 | u8 lp_ps_handshake_mode; |
| 218 | u8 ulp_ps_handshake_mode; |
| 219 | u8 rf_power_val; |
| 220 | u8 wlan_rf_power_mode; |
| 221 | u8 obm_ant_sel_val; |
Prameela Rani Garnepudi | 8b36de8 | 2016-11-18 16:08:04 +0530 | [diff] [blame] | 222 | int tx_power; |
Prameela Rani Garnepudi | 4edbcd1 | 2016-11-18 16:08:22 +0530 | [diff] [blame] | 223 | u8 ant_in_use; |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 224 | }; |
| 225 | |
Prameela Rani Garnepudi | a2ce952 | 2017-05-16 15:31:14 +0530 | [diff] [blame] | 226 | enum host_intf { |
| 227 | RSI_HOST_INTF_SDIO = 0, |
| 228 | RSI_HOST_INTF_USB |
| 229 | }; |
| 230 | |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 231 | struct rsi_hw { |
| 232 | struct rsi_common *priv; |
Prameela Rani Garnepudi | b78e91b | 2017-05-16 15:31:16 +0530 | [diff] [blame] | 233 | u8 device_model; |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 234 | struct ieee80211_hw *hw; |
| 235 | struct ieee80211_vif *vifs[RSI_MAX_VIFS]; |
| 236 | struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES]; |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 237 | struct ieee80211_supported_band sbands[NUM_NL80211_BANDS]; |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 238 | |
| 239 | struct device *device; |
| 240 | u8 sc_nvifs; |
| 241 | |
Prameela Rani Garnepudi | a2ce952 | 2017-05-16 15:31:14 +0530 | [diff] [blame] | 242 | enum host_intf rsi_host_intf; |
Prameela Rani Garnepudi | b78e91b | 2017-05-16 15:31:16 +0530 | [diff] [blame] | 243 | u16 block_size; |
Prameela Rani Garnepudi | 9920322 | 2017-06-16 20:12:05 +0530 | [diff] [blame] | 244 | u32 usb_buffer_status_reg; |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 245 | #ifdef CONFIG_RSI_DEBUGFS |
| 246 | struct rsi_debugfs *dfsentry; |
| 247 | u8 num_debugfs_entries; |
| 248 | #endif |
Prameela Rani Garnepudi | b78e91b | 2017-05-16 15:31:16 +0530 | [diff] [blame] | 249 | char *fw_file_name; |
| 250 | struct timer_list bl_cmd_timer; |
| 251 | bool blcmd_timer_expired; |
| 252 | u32 flash_capacity; |
Prameela Rani Garnepudi | 61d1084 | 2016-11-18 16:08:43 +0530 | [diff] [blame] | 253 | u8 dfs_region; |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 254 | void *rsi_dev; |
Prameela Rani Garnepudi | a2ce952 | 2017-05-16 15:31:14 +0530 | [diff] [blame] | 255 | struct rsi_host_intf_ops *host_intf_ops; |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 256 | int (*check_hw_queue_status)(struct rsi_hw *adapter, u8 q_num); |
| 257 | int (*rx_urb_submit)(struct rsi_hw *adapter); |
| 258 | int (*determine_event_timeout)(struct rsi_hw *adapter); |
| 259 | }; |
Prameela Rani Garnepudi | a2ce952 | 2017-05-16 15:31:14 +0530 | [diff] [blame] | 260 | |
| 261 | struct rsi_host_intf_ops { |
| 262 | int (*read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len); |
| 263 | int (*write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len); |
Prameela Rani Garnepudi | b78e91b | 2017-05-16 15:31:16 +0530 | [diff] [blame] | 264 | int (*master_access_msword)(struct rsi_hw *adapter, u16 ms_word); |
Prameela Rani Garnepudi | a2ce952 | 2017-05-16 15:31:14 +0530 | [diff] [blame] | 265 | int (*read_reg_multiple)(struct rsi_hw *adapter, u32 addr, |
| 266 | u8 *data, u16 count); |
| 267 | int (*write_reg_multiple)(struct rsi_hw *adapter, u32 addr, |
| 268 | u8 *data, u16 count); |
Prameela Rani Garnepudi | b97e9b9 | 2017-05-16 15:31:15 +0530 | [diff] [blame] | 269 | int (*master_reg_read)(struct rsi_hw *adapter, u32 addr, |
| 270 | u32 *read_buf, u16 size); |
| 271 | int (*master_reg_write)(struct rsi_hw *adapter, |
| 272 | unsigned long addr, unsigned long data, |
| 273 | u16 size); |
| 274 | int (*load_data_master_write)(struct rsi_hw *adapter, u32 addr, |
| 275 | u32 instructions_size, u16 block_size, |
| 276 | u8 *fw); |
Prameela Rani Garnepudi | a2ce952 | 2017-05-16 15:31:14 +0530 | [diff] [blame] | 277 | }; |
Fariya Fatima | dad0d04 | 2014-03-16 03:47:02 +0530 | [diff] [blame] | 278 | #endif |