2014-03-16 06:17:02 +08:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2014 Redpine Signals Inc.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __RSI_MAIN_H__
|
|
|
|
#define __RSI_MAIN_H__
|
|
|
|
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <net/mac80211.h>
|
|
|
|
|
2017-08-16 21:13:08 +08:00
|
|
|
struct rsi_sta {
|
|
|
|
struct ieee80211_sta *sta;
|
|
|
|
s16 sta_id;
|
|
|
|
u16 seq_start[IEEE80211_NUM_TIDS];
|
|
|
|
bool start_tx_aggr[IEEE80211_NUM_TIDS];
|
|
|
|
};
|
|
|
|
|
2017-08-03 22:28:59 +08:00
|
|
|
struct rsi_hw;
|
|
|
|
|
|
|
|
#include "rsi_ps.h"
|
|
|
|
|
2014-03-16 06:17:02 +08:00
|
|
|
#define ERR_ZONE BIT(0) /* For Error Msgs */
|
|
|
|
#define INFO_ZONE BIT(1) /* For General Status Msgs */
|
|
|
|
#define INIT_ZONE BIT(2) /* For Driver Init Seq Msgs */
|
|
|
|
#define MGMT_TX_ZONE BIT(3) /* For TX Mgmt Path Msgs */
|
|
|
|
#define MGMT_RX_ZONE BIT(4) /* For RX Mgmt Path Msgs */
|
|
|
|
#define DATA_TX_ZONE BIT(5) /* For TX Data Path Msgs */
|
|
|
|
#define DATA_RX_ZONE BIT(6) /* For RX Data Path Msgs */
|
|
|
|
#define FSM_ZONE BIT(7) /* For State Machine Msgs */
|
|
|
|
#define ISR_ZONE BIT(8) /* For Interrupt Msgs */
|
|
|
|
|
2017-06-16 22:35:37 +08:00
|
|
|
enum RSI_FSM_STATES {
|
2017-06-16 22:35:38 +08:00
|
|
|
FSM_FW_NOT_LOADED,
|
2017-06-16 22:35:37 +08:00
|
|
|
FSM_CARD_NOT_READY,
|
2017-06-16 22:42:05 +08:00
|
|
|
FSM_COMMON_DEV_PARAMS_SENT,
|
2017-06-16 22:35:37 +08:00
|
|
|
FSM_BOOT_PARAMS_SENT,
|
|
|
|
FSM_EEPROM_READ_MAC_ADDR,
|
2017-07-06 22:37:05 +08:00
|
|
|
FSM_EEPROM_READ_RF_TYPE,
|
2017-06-16 22:35:37 +08:00
|
|
|
FSM_RESET_MAC_SENT,
|
|
|
|
FSM_RADIO_CAPS_SENT,
|
|
|
|
FSM_BB_RF_PROG_SENT,
|
2017-07-06 22:37:04 +08:00
|
|
|
FSM_MAC_INIT_DONE,
|
|
|
|
|
|
|
|
NUM_FSM_STATES
|
2017-06-16 22:35:37 +08:00
|
|
|
};
|
2014-03-16 06:17:02 +08:00
|
|
|
|
|
|
|
extern u32 rsi_zone_enabled;
|
2014-03-19 08:59:47 +08:00
|
|
|
extern __printf(2, 3) void rsi_dbg(u32 zone, const char *fmt, ...);
|
2014-03-16 06:17:02 +08:00
|
|
|
|
2017-08-30 17:38:22 +08:00
|
|
|
#define RSI_MAX_VIFS 3
|
2014-03-16 06:17:02 +08:00
|
|
|
#define NUM_EDCA_QUEUES 4
|
|
|
|
#define IEEE80211_ADDR_LEN 6
|
|
|
|
#define FRAME_DESC_SZ 16
|
|
|
|
#define MIN_802_11_HDR_LEN 24
|
2017-08-03 22:29:04 +08:00
|
|
|
#define RSI_DEF_KEEPALIVE 90
|
2017-10-27 19:25:55 +08:00
|
|
|
#define RSI_WOW_KEEPALIVE 5
|
|
|
|
#define RSI_BCN_MISS_THRESHOLD 24
|
2014-03-16 06:17:02 +08:00
|
|
|
|
|
|
|
#define DATA_QUEUE_WATER_MARK 400
|
|
|
|
#define MIN_DATA_QUEUE_WATER_MARK 300
|
|
|
|
#define MULTICAST_WATER_MARK 200
|
|
|
|
#define MAC_80211_HDR_FRAME_CONTROL 0
|
|
|
|
#define WME_NUM_AC 4
|
2017-08-16 21:13:11 +08:00
|
|
|
#define NUM_SOFT_QUEUES 6
|
2017-07-10 20:40:34 +08:00
|
|
|
#define MAX_HW_QUEUES 12
|
2014-03-16 06:17:02 +08:00
|
|
|
#define INVALID_QUEUE 0xff
|
|
|
|
#define MAX_CONTINUOUS_VO_PKTS 8
|
|
|
|
#define MAX_CONTINUOUS_VI_PKTS 4
|
|
|
|
|
2017-07-10 20:40:34 +08:00
|
|
|
/* Hardware queue info */
|
|
|
|
#define BROADCAST_HW_Q 9
|
|
|
|
#define MGMT_HW_Q 10
|
|
|
|
#define BEACON_HW_Q 11
|
|
|
|
|
2014-03-16 06:17:02 +08:00
|
|
|
/* Queue information */
|
2017-06-16 22:35:39 +08:00
|
|
|
#define RSI_COEX_Q 0x0
|
2014-03-16 06:17:02 +08:00
|
|
|
#define RSI_WIFI_MGMT_Q 0x4
|
|
|
|
#define RSI_WIFI_DATA_Q 0x5
|
|
|
|
#define IEEE80211_MGMT_FRAME 0x00
|
|
|
|
#define IEEE80211_CTL_FRAME 0x04
|
|
|
|
|
2017-08-16 21:13:09 +08:00
|
|
|
#define RSI_MAX_ASSOC_STAS 32
|
2014-03-16 06:17:02 +08:00
|
|
|
#define IEEE80211_QOS_TID 0x0f
|
|
|
|
#define IEEE80211_NONQOS_TID 16
|
|
|
|
|
|
|
|
#define MAX_DEBUGFS_ENTRIES 4
|
|
|
|
|
|
|
|
#define TID_TO_WME_AC(_tid) ( \
|
|
|
|
((_tid) == 0 || (_tid) == 3) ? BE_Q : \
|
|
|
|
((_tid) < 3) ? BK_Q : \
|
|
|
|
((_tid) < 6) ? VI_Q : \
|
|
|
|
VO_Q)
|
|
|
|
|
|
|
|
#define WME_AC(_q) ( \
|
|
|
|
((_q) == BK_Q) ? IEEE80211_AC_BK : \
|
|
|
|
((_q) == BE_Q) ? IEEE80211_AC_BE : \
|
|
|
|
((_q) == VI_Q) ? IEEE80211_AC_VI : \
|
|
|
|
IEEE80211_AC_VO)
|
|
|
|
|
2017-10-27 19:25:55 +08:00
|
|
|
/* WoWLAN flags */
|
|
|
|
#define RSI_WOW_ENABLED BIT(0)
|
|
|
|
#define RSI_WOW_NO_CONNECTION BIT(1)
|
|
|
|
|
2017-05-16 18:01:16 +08:00
|
|
|
#define RSI_DEV_9113 1
|
|
|
|
|
2014-03-16 06:17:02 +08:00
|
|
|
struct version_info {
|
|
|
|
u16 major;
|
|
|
|
u16 minor;
|
2017-09-21 20:50:34 +08:00
|
|
|
u8 release_num;
|
|
|
|
u8 patch_num;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u8 fw_ver[8];
|
|
|
|
} info;
|
|
|
|
} ver;
|
2014-03-16 06:17:02 +08:00
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct skb_info {
|
|
|
|
s8 rssi;
|
|
|
|
u32 flags;
|
|
|
|
u16 channel;
|
|
|
|
s8 tid;
|
|
|
|
s8 sta_id;
|
2017-07-06 22:37:16 +08:00
|
|
|
u8 internal_hdr_size;
|
2017-08-30 17:38:24 +08:00
|
|
|
struct ieee80211_vif *vif;
|
|
|
|
u8 vap_id;
|
2014-03-16 06:17:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum edca_queue {
|
|
|
|
BK_Q,
|
|
|
|
BE_Q,
|
|
|
|
VI_Q,
|
|
|
|
VO_Q,
|
2017-08-16 21:13:11 +08:00
|
|
|
MGMT_SOFT_Q,
|
|
|
|
MGMT_BEACON_Q
|
2014-03-16 06:17:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct security_info {
|
|
|
|
bool security_enable;
|
|
|
|
u32 ptk_cipher;
|
|
|
|
u32 gtk_cipher;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wmm_qinfo {
|
|
|
|
s32 weight;
|
|
|
|
s32 wme_params;
|
|
|
|
s32 pkt_contended;
|
2014-06-16 22:15:03 +08:00
|
|
|
s32 txop;
|
2014-03-16 06:17:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct transmit_q_stats {
|
2017-08-16 21:13:11 +08:00
|
|
|
u32 total_tx_pkt_send[NUM_EDCA_QUEUES + 2];
|
|
|
|
u32 total_tx_pkt_freed[NUM_EDCA_QUEUES + 2];
|
2014-03-16 06:17:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct vif_priv {
|
|
|
|
bool is_ht;
|
|
|
|
bool sgi;
|
|
|
|
u16 seq_start;
|
2017-08-30 17:38:22 +08:00
|
|
|
int vap_id;
|
2014-03-16 06:17:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rsi_event {
|
|
|
|
atomic_t event_condition;
|
|
|
|
wait_queue_head_t event_queue;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rsi_thread {
|
|
|
|
void (*thread_function)(void *);
|
|
|
|
struct completion completion;
|
|
|
|
struct task_struct *task;
|
|
|
|
struct rsi_event event;
|
|
|
|
atomic_t thread_done;
|
|
|
|
};
|
|
|
|
|
2014-06-16 22:16:48 +08:00
|
|
|
struct cqm_info {
|
|
|
|
s8 last_cqm_event_rssi;
|
|
|
|
int rssi_thold;
|
|
|
|
u32 rssi_hyst;
|
|
|
|
};
|
|
|
|
|
2017-07-06 22:37:16 +08:00
|
|
|
struct xtended_desc {
|
|
|
|
u8 confirm_frame_type;
|
|
|
|
u8 retry_cnt;
|
|
|
|
u16 reserved;
|
|
|
|
};
|
|
|
|
|
2017-07-10 20:40:48 +08:00
|
|
|
enum rsi_dfs_regions {
|
|
|
|
RSI_REGION_FCC = 0,
|
|
|
|
RSI_REGION_ETSI,
|
|
|
|
RSI_REGION_TELEC,
|
|
|
|
RSI_REGION_WORLD
|
|
|
|
};
|
|
|
|
|
2014-03-16 06:17:02 +08:00
|
|
|
struct rsi_common {
|
|
|
|
struct rsi_hw *priv;
|
|
|
|
struct vif_priv vif_info[RSI_MAX_VIFS];
|
|
|
|
|
|
|
|
bool mgmt_q_block;
|
2017-09-21 20:50:34 +08:00
|
|
|
struct version_info lmac_ver;
|
2014-03-16 06:17:02 +08:00
|
|
|
|
|
|
|
struct rsi_thread tx_thread;
|
2017-08-16 21:13:11 +08:00
|
|
|
struct sk_buff_head tx_queue[NUM_EDCA_QUEUES + 2];
|
2017-10-27 19:25:56 +08:00
|
|
|
struct completion wlan_init_completion;
|
2014-03-16 06:17:02 +08:00
|
|
|
/* Mutex declaration */
|
|
|
|
struct mutex mutex;
|
2017-07-06 22:37:24 +08:00
|
|
|
/* Mutex used for tx thread */
|
|
|
|
struct mutex tx_lock;
|
2017-07-06 22:37:23 +08:00
|
|
|
/* Mutex used for rx thread */
|
|
|
|
struct mutex rx_lock;
|
2014-03-16 06:17:02 +08:00
|
|
|
u8 endpoint;
|
|
|
|
|
|
|
|
/* Channel/band related */
|
|
|
|
u8 band;
|
2017-07-06 22:37:05 +08:00
|
|
|
u8 num_supp_bands;
|
2014-03-16 06:17:02 +08:00
|
|
|
u8 channel_width;
|
|
|
|
|
|
|
|
u16 rts_threshold;
|
|
|
|
u16 bitrate_mask[2];
|
|
|
|
u32 fixedrate_mask[2];
|
|
|
|
|
|
|
|
u8 rf_reset;
|
|
|
|
struct transmit_q_stats tx_stats;
|
|
|
|
struct security_info secinfo;
|
|
|
|
struct wmm_qinfo tx_qinfo[NUM_EDCA_QUEUES];
|
|
|
|
struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
|
|
|
|
u8 mac_addr[IEEE80211_ADDR_LEN];
|
|
|
|
|
|
|
|
/* state related */
|
|
|
|
u32 fsm_state;
|
|
|
|
bool init_done;
|
|
|
|
u8 bb_rf_prog_count;
|
|
|
|
bool iface_down;
|
|
|
|
|
|
|
|
/* Generic */
|
|
|
|
u8 channel;
|
|
|
|
u8 *rx_data_pkt;
|
|
|
|
u8 mac_id;
|
|
|
|
u8 radio_id;
|
|
|
|
u16 rate_pwr[20];
|
|
|
|
u16 min_rate;
|
|
|
|
|
|
|
|
/* WMM algo related */
|
|
|
|
u8 selected_qnum;
|
|
|
|
u32 pkt_cnt;
|
|
|
|
u8 min_weight;
|
2014-06-16 22:15:03 +08:00
|
|
|
|
2014-06-16 22:16:48 +08:00
|
|
|
/* bgscan related */
|
|
|
|
struct cqm_info cqm_info;
|
|
|
|
|
2014-06-16 22:15:03 +08:00
|
|
|
bool hw_data_qs_blocked;
|
2017-06-16 22:42:05 +08:00
|
|
|
u8 driver_mode;
|
2017-05-16 18:01:16 +08:00
|
|
|
u8 coex_mode;
|
2017-06-16 22:42:05 +08:00
|
|
|
u16 oper_mode;
|
|
|
|
u8 lp_ps_handshake_mode;
|
|
|
|
u8 ulp_ps_handshake_mode;
|
2017-08-03 22:29:00 +08:00
|
|
|
u8 uapsd_bitmap;
|
2017-06-16 22:42:05 +08:00
|
|
|
u8 rf_power_val;
|
|
|
|
u8 wlan_rf_power_mode;
|
|
|
|
u8 obm_ant_sel_val;
|
2016-11-18 18:38:04 +08:00
|
|
|
int tx_power;
|
2016-11-18 18:38:22 +08:00
|
|
|
u8 ant_in_use;
|
2017-10-27 19:25:56 +08:00
|
|
|
bool hibernate_resume;
|
|
|
|
bool reinit_hw;
|
2017-10-27 19:25:55 +08:00
|
|
|
u8 wow_flags;
|
2017-07-10 20:40:40 +08:00
|
|
|
u16 beacon_interval;
|
|
|
|
u8 dtim_cnt;
|
2017-08-16 21:13:08 +08:00
|
|
|
|
|
|
|
/* AP mode parameters */
|
2017-08-16 21:13:11 +08:00
|
|
|
u8 beacon_enabled;
|
|
|
|
u16 beacon_cnt;
|
2017-08-16 21:13:09 +08:00
|
|
|
struct rsi_sta stations[RSI_MAX_ASSOC_STAS + 1];
|
|
|
|
int num_stations;
|
2017-08-16 21:13:08 +08:00
|
|
|
int max_stations;
|
2017-08-16 21:13:18 +08:00
|
|
|
struct ieee80211_key_conf *key;
|
2017-08-30 17:38:22 +08:00
|
|
|
|
|
|
|
/* Wi-Fi direct mode related */
|
|
|
|
bool p2p_enabled;
|
2017-08-30 17:38:23 +08:00
|
|
|
struct timer_list roc_timer;
|
|
|
|
struct ieee80211_vif *roc_vif;
|
2014-03-16 06:17:02 +08:00
|
|
|
};
|
|
|
|
|
2017-05-16 18:01:14 +08:00
|
|
|
enum host_intf {
|
|
|
|
RSI_HOST_INTF_SDIO = 0,
|
|
|
|
RSI_HOST_INTF_USB
|
|
|
|
};
|
|
|
|
|
2017-07-06 22:37:05 +08:00
|
|
|
struct eepromrw_info {
|
|
|
|
u32 offset;
|
|
|
|
u32 length;
|
|
|
|
u8 write;
|
|
|
|
u16 eeprom_erase;
|
|
|
|
u8 data[480];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct eeprom_read {
|
|
|
|
u16 length;
|
|
|
|
u16 off_set;
|
|
|
|
};
|
|
|
|
|
2014-03-16 06:17:02 +08:00
|
|
|
struct rsi_hw {
|
|
|
|
struct rsi_common *priv;
|
2017-05-16 18:01:16 +08:00
|
|
|
u8 device_model;
|
2014-03-16 06:17:02 +08:00
|
|
|
struct ieee80211_hw *hw;
|
|
|
|
struct ieee80211_vif *vifs[RSI_MAX_VIFS];
|
|
|
|
struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
|
2016-04-12 21:56:15 +08:00
|
|
|
struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
|
2014-03-16 06:17:02 +08:00
|
|
|
|
|
|
|
struct device *device;
|
|
|
|
u8 sc_nvifs;
|
|
|
|
|
2017-05-16 18:01:14 +08:00
|
|
|
enum host_intf rsi_host_intf;
|
2017-05-16 18:01:16 +08:00
|
|
|
u16 block_size;
|
2017-08-03 22:28:59 +08:00
|
|
|
enum ps_state ps_state;
|
|
|
|
struct rsi_ps_info ps_info;
|
|
|
|
spinlock_t ps_lock; /*To protect power save config*/
|
2017-06-16 22:42:05 +08:00
|
|
|
u32 usb_buffer_status_reg;
|
2014-03-16 06:17:02 +08:00
|
|
|
#ifdef CONFIG_RSI_DEBUGFS
|
|
|
|
struct rsi_debugfs *dfsentry;
|
|
|
|
u8 num_debugfs_entries;
|
|
|
|
#endif
|
2017-05-16 18:01:16 +08:00
|
|
|
char *fw_file_name;
|
|
|
|
struct timer_list bl_cmd_timer;
|
|
|
|
bool blcmd_timer_expired;
|
|
|
|
u32 flash_capacity;
|
2017-07-06 22:37:05 +08:00
|
|
|
struct eepromrw_info eeprom;
|
2017-07-06 22:37:22 +08:00
|
|
|
u32 interrupt_status;
|
2016-11-18 18:38:43 +08:00
|
|
|
u8 dfs_region;
|
2017-07-10 20:40:48 +08:00
|
|
|
char country[2];
|
2014-03-16 06:17:02 +08:00
|
|
|
void *rsi_dev;
|
2017-05-16 18:01:14 +08:00
|
|
|
struct rsi_host_intf_ops *host_intf_ops;
|
2014-03-16 06:17:02 +08:00
|
|
|
int (*check_hw_queue_status)(struct rsi_hw *adapter, u8 q_num);
|
2018-02-27 22:26:11 +08:00
|
|
|
int (*rx_urb_submit)(struct rsi_hw *adapter, u8 ep_num);
|
2014-03-16 06:17:02 +08:00
|
|
|
int (*determine_event_timeout)(struct rsi_hw *adapter);
|
|
|
|
};
|
2017-05-16 18:01:14 +08:00
|
|
|
|
2017-09-21 20:50:34 +08:00
|
|
|
void rsi_print_version(struct rsi_common *common);
|
|
|
|
|
2017-05-16 18:01:14 +08:00
|
|
|
struct rsi_host_intf_ops {
|
|
|
|
int (*read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
|
|
|
|
int (*write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
|
2017-05-16 18:01:16 +08:00
|
|
|
int (*master_access_msword)(struct rsi_hw *adapter, u16 ms_word);
|
2017-05-16 18:01:14 +08:00
|
|
|
int (*read_reg_multiple)(struct rsi_hw *adapter, u32 addr,
|
|
|
|
u8 *data, u16 count);
|
|
|
|
int (*write_reg_multiple)(struct rsi_hw *adapter, u32 addr,
|
|
|
|
u8 *data, u16 count);
|
2017-05-16 18:01:15 +08:00
|
|
|
int (*master_reg_read)(struct rsi_hw *adapter, u32 addr,
|
|
|
|
u32 *read_buf, u16 size);
|
|
|
|
int (*master_reg_write)(struct rsi_hw *adapter,
|
|
|
|
unsigned long addr, unsigned long data,
|
|
|
|
u16 size);
|
|
|
|
int (*load_data_master_write)(struct rsi_hw *adapter, u32 addr,
|
|
|
|
u32 instructions_size, u16 block_size,
|
|
|
|
u8 *fw);
|
2017-10-27 19:25:56 +08:00
|
|
|
int (*reinit_device)(struct rsi_hw *adapter);
|
2017-05-16 18:01:14 +08:00
|
|
|
};
|
2014-03-16 06:17:02 +08:00
|
|
|
#endif
|