Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2014 Redpine Signals Inc.
0003  *
0004  * Permission to use, copy, modify, and/or distribute this software for any
0005  * purpose with or without fee is hereby granted, provided that the above
0006  * copyright notice and this permission notice appear in all copies.
0007  *
0008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0011  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0013  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0014  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0015  */
0016 
0017 #ifndef __RSI_MAIN_H__
0018 #define __RSI_MAIN_H__
0019 
0020 #include <linux/string.h>
0021 #include <linux/skbuff.h>
0022 #include <net/mac80211.h>
0023 #include <net/rsi_91x.h>
0024 
0025 struct rsi_sta {
0026     struct ieee80211_sta *sta;
0027     s16 sta_id;
0028     u16 seq_start[IEEE80211_NUM_TIDS];
0029     bool start_tx_aggr[IEEE80211_NUM_TIDS];
0030 };
0031 
0032 struct rsi_hw;
0033 
0034 #include "rsi_ps.h"
0035 
0036 #define ERR_ZONE                        BIT(0)  /* For Error Msgs             */
0037 #define INFO_ZONE                       BIT(1)  /* For General Status Msgs    */
0038 #define INIT_ZONE                       BIT(2)  /* For Driver Init Seq Msgs   */
0039 #define MGMT_TX_ZONE                    BIT(3)  /* For TX Mgmt Path Msgs      */
0040 #define MGMT_RX_ZONE                    BIT(4)  /* For RX Mgmt Path Msgs      */
0041 #define DATA_TX_ZONE                    BIT(5)  /* For TX Data Path Msgs      */
0042 #define DATA_RX_ZONE                    BIT(6)  /* For RX Data Path Msgs      */
0043 #define FSM_ZONE                        BIT(7)  /* For State Machine Msgs     */
0044 #define ISR_ZONE                        BIT(8)  /* For Interrupt Msgs         */
0045 
0046 enum RSI_FSM_STATES {
0047     FSM_FW_NOT_LOADED,
0048     FSM_CARD_NOT_READY,
0049     FSM_COMMON_DEV_PARAMS_SENT,
0050     FSM_BOOT_PARAMS_SENT,
0051     FSM_EEPROM_READ_MAC_ADDR,
0052     FSM_EEPROM_READ_RF_TYPE,
0053     FSM_RESET_MAC_SENT,
0054     FSM_RADIO_CAPS_SENT,
0055     FSM_BB_RF_PROG_SENT,
0056     FSM_MAC_INIT_DONE,
0057 
0058     NUM_FSM_STATES
0059 };
0060 
0061 extern u32 rsi_zone_enabled;
0062 extern __printf(2, 3) void rsi_dbg(u32 zone, const char *fmt, ...);
0063 
0064 #define RSI_MAX_BANDS           2
0065 #define RSI_MAX_VIFS                    3
0066 #define NUM_EDCA_QUEUES                 4
0067 #define IEEE80211_ADDR_LEN              6
0068 #define FRAME_DESC_SZ                   16
0069 #define MIN_802_11_HDR_LEN              24
0070 #define RSI_DEF_KEEPALIVE               90
0071 #define RSI_WOW_KEEPALIVE                5
0072 #define RSI_BCN_MISS_THRESHOLD           24
0073 
0074 #define DATA_QUEUE_WATER_MARK           400
0075 #define MIN_DATA_QUEUE_WATER_MARK       300
0076 #define MULTICAST_WATER_MARK            200
0077 #define MAC_80211_HDR_FRAME_CONTROL     0
0078 #define WME_NUM_AC                      4
0079 #define NUM_SOFT_QUEUES                 6
0080 #define MAX_HW_QUEUES                   12
0081 #define INVALID_QUEUE                   0xff
0082 #define MAX_CONTINUOUS_VO_PKTS          8
0083 #define MAX_CONTINUOUS_VI_PKTS          4
0084 
0085 /* Hardware queue info */
0086 #define BROADCAST_HW_Q          9
0087 #define MGMT_HW_Q           10
0088 #define BEACON_HW_Q         11
0089 
0090 #define IEEE80211_MGMT_FRAME            0x00
0091 #define IEEE80211_CTL_FRAME             0x04
0092 
0093 #define RSI_MAX_ASSOC_STAS      32
0094 #define IEEE80211_QOS_TID               0x0f
0095 #define IEEE80211_NONQOS_TID            16
0096 
0097 #define MAX_DEBUGFS_ENTRIES             4
0098 
0099 #define TID_TO_WME_AC(_tid) (      \
0100     ((_tid) == 0 || (_tid) == 3) ? BE_Q : \
0101     ((_tid) < 3) ? BK_Q : \
0102     ((_tid) < 6) ? VI_Q : \
0103     VO_Q)
0104 
0105 #define WME_AC(_q) (    \
0106     ((_q) == BK_Q) ? IEEE80211_AC_BK : \
0107     ((_q) == BE_Q) ? IEEE80211_AC_BE : \
0108     ((_q) == VI_Q) ? IEEE80211_AC_VI : \
0109     IEEE80211_AC_VO)
0110 
0111 /* WoWLAN flags */
0112 #define RSI_WOW_ENABLED         BIT(0)
0113 #define RSI_WOW_NO_CONNECTION       BIT(1)
0114 
0115 #define RSI_MAX_RX_PKTS     64
0116 
0117 enum rsi_dev_model {
0118     RSI_DEV_9113 = 0,
0119     RSI_DEV_9116
0120 };
0121 
0122 struct version_info {
0123     u16 major;
0124     u16 minor;
0125     u8 release_num;
0126     u8 patch_num;
0127     union {
0128         struct {
0129             u8 fw_ver[8];
0130         } info;
0131     } ver;
0132 } __packed;
0133 
0134 struct skb_info {
0135     s8 rssi;
0136     u32 flags;
0137     u16 channel;
0138     s8 tid;
0139     s8 sta_id;
0140     u8 internal_hdr_size;
0141     struct ieee80211_vif *vif;
0142     u8 vap_id;
0143     bool have_key;
0144 };
0145 
0146 enum edca_queue {
0147     BK_Q,
0148     BE_Q,
0149     VI_Q,
0150     VO_Q,
0151     MGMT_SOFT_Q,
0152     MGMT_BEACON_Q
0153 };
0154 
0155 struct security_info {
0156     u32 ptk_cipher;
0157     u32 gtk_cipher;
0158 };
0159 
0160 struct wmm_qinfo {
0161     s32 weight;
0162     s32 wme_params;
0163     s32 pkt_contended;
0164     s32 txop;
0165 };
0166 
0167 struct transmit_q_stats {
0168     u32 total_tx_pkt_send[NUM_EDCA_QUEUES + 2];
0169     u32 total_tx_pkt_freed[NUM_EDCA_QUEUES + 2];
0170 };
0171 
0172 #define MAX_BGSCAN_CHANNELS_DUAL_BAND   38
0173 #define MAX_BGSCAN_PROBE_REQ_LEN    0x64
0174 #define RSI_DEF_BGSCAN_THRLD        0x0
0175 #define RSI_DEF_ROAM_THRLD      0xa
0176 #define RSI_BGSCAN_PERIODICITY      0x1e
0177 #define RSI_ACTIVE_SCAN_TIME        0x14
0178 #define RSI_PASSIVE_SCAN_TIME       0x46
0179 #define RSI_CHANNEL_SCAN_TIME       20
0180 struct rsi_bgscan_params {
0181     u16 bgscan_threshold;
0182     u16 roam_threshold;
0183     u16 bgscan_periodicity;
0184     u8 num_bgscan_channels;
0185     u8 two_probe;
0186     u16 active_scan_duration;
0187     u16 passive_scan_duration;
0188 };
0189 
0190 struct vif_priv {
0191     bool is_ht;
0192     bool sgi;
0193     u16 seq_start;
0194     int vap_id;
0195 };
0196 
0197 struct rsi_event {
0198     atomic_t event_condition;
0199     wait_queue_head_t event_queue;
0200 };
0201 
0202 struct rsi_thread {
0203     void (*thread_function)(void *);
0204     struct completion completion;
0205     struct task_struct *task;
0206     struct rsi_event event;
0207     atomic_t thread_done;
0208 };
0209 
0210 struct cqm_info {
0211     s8 last_cqm_event_rssi;
0212     int rssi_thold;
0213     u32 rssi_hyst;
0214 };
0215 
0216 enum rsi_dfs_regions {
0217     RSI_REGION_FCC = 0,
0218     RSI_REGION_ETSI,
0219     RSI_REGION_TELEC,
0220     RSI_REGION_WORLD
0221 };
0222 
0223 struct rsi_9116_features {
0224     u8 pll_mode;
0225     u8 rf_type;
0226     u8 wireless_mode;
0227     u8 afe_type;
0228     u8 enable_ppe;
0229     u8 dpd;
0230     u32 sifs_tx_enable;
0231     u32 ps_options;
0232 };
0233 
0234 struct rsi_rate_config {
0235     u32 configured_mask;    /* configured by mac80211 bits 0-11=legacy 12+ mcs */
0236     u16 fixed_hw_rate;
0237     bool fixed_enabled;
0238 };
0239 
0240 struct rsi_common {
0241     struct rsi_hw *priv;
0242     struct vif_priv vif_info[RSI_MAX_VIFS];
0243 
0244     void *coex_cb;
0245     bool mgmt_q_block;
0246     struct version_info lmac_ver;
0247 
0248     struct rsi_thread tx_thread;
0249     struct sk_buff_head tx_queue[NUM_EDCA_QUEUES + 2];
0250     struct completion wlan_init_completion;
0251     /* Mutex declaration */
0252     struct mutex mutex;
0253     /* Mutex used for tx thread */
0254     struct mutex tx_lock;
0255     /* Mutex used for rx thread */
0256     struct mutex rx_lock;
0257     u8 endpoint;
0258 
0259     /* Channel/band related */
0260     u8 band;
0261     u8 num_supp_bands;
0262     u8 channel_width;
0263 
0264     u16 rts_threshold;
0265     u32 bitrate_mask[RSI_MAX_BANDS];
0266     struct rsi_rate_config rate_config[RSI_MAX_BANDS];
0267 
0268     u8 rf_reset;
0269     struct transmit_q_stats tx_stats;
0270     struct security_info secinfo;
0271     struct wmm_qinfo tx_qinfo[NUM_EDCA_QUEUES];
0272     struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
0273     u8 mac_addr[IEEE80211_ADDR_LEN];
0274 
0275     /* state related */
0276     u32 fsm_state;
0277     bool init_done;
0278     u8 bb_rf_prog_count;
0279     bool iface_down;
0280 
0281     /* Generic */
0282     u8 channel;
0283     u8 *rx_data_pkt;
0284     u8 mac_id;
0285     u8 radio_id;
0286     u16 rate_pwr[20];
0287 
0288     /* WMM algo related */
0289     u8 selected_qnum;
0290     u32 pkt_cnt;
0291     u8 min_weight;
0292 
0293     /* bgscan related */
0294     struct cqm_info cqm_info;
0295 
0296     bool hw_data_qs_blocked;
0297     u8 driver_mode;
0298     u8 coex_mode;
0299     u16 oper_mode;
0300     u8 lp_ps_handshake_mode;
0301     u8 ulp_ps_handshake_mode;
0302     u8 uapsd_bitmap;
0303     u8 rf_power_val;
0304     u8 wlan_rf_power_mode;
0305     u8 obm_ant_sel_val;
0306     int tx_power;
0307     u8 ant_in_use;
0308     /* Mutex used for writing packet to bus */
0309     struct mutex tx_bus_mutex;
0310     bool hibernate_resume;
0311     bool reinit_hw;
0312     u8 wow_flags;
0313     u16 beacon_interval;
0314     u8 dtim_cnt;
0315 
0316     /* AP mode parameters */
0317     u8 beacon_enabled;
0318     u16 beacon_cnt;
0319     struct rsi_sta stations[RSI_MAX_ASSOC_STAS + 1];
0320     int num_stations;
0321     int max_stations;
0322     struct ieee80211_key_conf *key;
0323 
0324     /* Wi-Fi direct mode related */
0325     bool p2p_enabled;
0326     struct timer_list roc_timer;
0327     struct ieee80211_vif *roc_vif;
0328 
0329     bool eapol4_confirm;
0330     bool bt_defer_attach;
0331     void *bt_adapter;
0332 
0333     struct cfg80211_scan_request *hwscan;
0334     struct rsi_bgscan_params bgscan;
0335     struct rsi_9116_features w9116_features;
0336     u8 bgscan_en;
0337     u8 mac_ops_resumed;
0338 };
0339 
0340 struct eepromrw_info {
0341     u32 offset;
0342     u32 length;
0343     u8  write;
0344     u16 eeprom_erase;
0345     u8 data[480];
0346 };
0347 
0348 struct eeprom_read {
0349     u16 length;
0350     u16 off_set;
0351 };
0352 
0353 struct rsi_hw {
0354     struct rsi_common *priv;
0355     enum rsi_dev_model device_model;
0356     struct ieee80211_hw *hw;
0357     struct ieee80211_vif *vifs[RSI_MAX_VIFS];
0358     struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
0359     struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
0360 
0361     struct device *device;
0362     u8 sc_nvifs;
0363 
0364     enum rsi_host_intf rsi_host_intf;
0365     u16 block_size;
0366     enum ps_state ps_state;
0367     struct rsi_ps_info ps_info;
0368     spinlock_t ps_lock; /*To protect power save config*/
0369     u32 usb_buffer_status_reg;
0370 #ifdef CONFIG_RSI_DEBUGFS
0371     struct rsi_debugfs *dfsentry;
0372     u8 num_debugfs_entries;
0373 #endif
0374     char *fw_file_name;
0375     struct timer_list bl_cmd_timer;
0376     bool blcmd_timer_expired;
0377     u32 flash_capacity;
0378     struct eepromrw_info eeprom;
0379     u32 interrupt_status;
0380     u8 dfs_region;
0381     char country[2];
0382     void *rsi_dev;
0383     struct rsi_host_intf_ops *host_intf_ops;
0384     int (*check_hw_queue_status)(struct rsi_hw *adapter, u8 q_num);
0385     int (*determine_event_timeout)(struct rsi_hw *adapter);
0386 };
0387 
0388 void rsi_print_version(struct rsi_common *common);
0389 
0390 struct rsi_host_intf_ops {
0391     int (*read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
0392     int (*write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
0393     int (*master_access_msword)(struct rsi_hw *adapter, u16 ms_word);
0394     int (*read_reg_multiple)(struct rsi_hw *adapter, u32 addr,
0395                  u8 *data, u16 count);
0396     int (*write_reg_multiple)(struct rsi_hw *adapter, u32 addr,
0397                   u8 *data, u16 count);
0398     int (*master_reg_read)(struct rsi_hw *adapter, u32 addr,
0399                    u32 *read_buf, u16 size);
0400     int (*master_reg_write)(struct rsi_hw *adapter,
0401                 unsigned long addr, unsigned long data,
0402                 u16 size);
0403     int (*load_data_master_write)(struct rsi_hw *adapter, u32 addr,
0404                       u32 instructions_size, u16 block_size,
0405                       u8 *fw);
0406     int (*reinit_device)(struct rsi_hw *adapter);
0407     int (*ta_reset)(struct rsi_hw *adapter);
0408 };
0409 
0410 enum rsi_host_intf rsi_get_host_intf(void *priv);
0411 void rsi_set_bt_context(void *priv, void *bt_context);
0412 void rsi_attach_bt(struct rsi_common *common);
0413 
0414 #endif