ath6kl: handle firmware names more dynamically
[cascardo/linux.git] / drivers / net / wireless / ath / ath6kl / core.h
index 31e5c7e..2679577 100644 (file)
@@ -70,10 +70,20 @@ enum ath6kl_fw_ie_type {
        ATH6KL_FW_IE_RESERVED_RAM_SIZE = 5,
        ATH6KL_FW_IE_CAPABILITIES = 6,
        ATH6KL_FW_IE_PATCH_ADDR = 7,
+       ATH6KL_FW_IE_BOARD_ADDR = 8,
+       ATH6KL_FW_IE_VIF_MAX = 9,
 };
 
 enum ath6kl_fw_capability {
        ATH6KL_FW_CAPABILITY_HOST_P2P = 0,
+       ATH6KL_FW_CAPABILITY_SCHED_SCAN = 1,
+
+       /*
+        * Firmware is capable of supporting P2P mgmt operations on a
+        * station interface. After group formation, the station
+        * interface will become a P2P client/GO interface as the case may be
+        */
+       ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX,
 
        /* this needs to be last */
        ATH6KL_FW_CAPABILITY_MAX,
@@ -87,38 +97,49 @@ struct ath6kl_fw_ie {
        u8 data[0];
 };
 
+#define ATH6KL_FW_API2_FILE "fw-2.bin"
+
 /* AR6003 1.0 definitions */
-#define AR6003_REV1_VERSION                 0x300002ba
+#define AR6003_HW_1_0_VERSION                 0x300002ba
 
 /* AR6003 2.0 definitions */
-#define AR6003_REV2_VERSION                 0x30000384
-#define AR6003_REV2_PATCH_DOWNLOAD_ADDRESS  0x57e910
-#define AR6003_REV2_OTP_FILE                "ath6k/AR6003/hw2.0/otp.bin.z77"
-#define AR6003_REV2_FIRMWARE_FILE           "ath6k/AR6003/hw2.0/athwlan.bin.z77"
-#define AR6003_REV2_TCMD_FIRMWARE_FILE      "ath6k/AR6003/hw2.0/athtcmd_ram.bin"
-#define AR6003_REV2_PATCH_FILE              "ath6k/AR6003/hw2.0/data.patch.bin"
-#define AR6003_REV2_FIRMWARE_2_FILE         "ath6k/AR6003/hw2.0/fw-2.bin"
-#define AR6003_REV2_BOARD_DATA_FILE         "ath6k/AR6003/hw2.0/bdata.bin"
-#define AR6003_REV2_DEFAULT_BOARD_DATA_FILE "ath6k/AR6003/hw2.0/bdata.SD31.bin"
+#define AR6003_HW_2_0_VERSION                 0x30000384
+#define AR6003_HW_2_0_PATCH_DOWNLOAD_ADDRESS  0x57e910
+#define AR6003_HW_2_0_FW_DIR                   "ath6k/AR6003/hw2.0"
+#define AR6003_HW_2_0_OTP_FILE                 "otp.bin.z77"
+#define AR6003_HW_2_0_FIRMWARE_FILE            "athwlan.bin.z77"
+#define AR6003_HW_2_0_TCMD_FIRMWARE_FILE       "athtcmd_ram.bin"
+#define AR6003_HW_2_0_PATCH_FILE               "data.patch.bin"
+#define AR6003_HW_2_0_BOARD_DATA_FILE "ath6k/AR6003/hw2.0/bdata.bin"
+#define AR6003_HW_2_0_DEFAULT_BOARD_DATA_FILE \
+                       "ath6k/AR6003/hw2.0/bdata.SD31.bin"
 
 /* AR6003 3.0 definitions */
-#define AR6003_REV3_VERSION                 0x30000582
-#define AR6003_REV3_OTP_FILE                "ath6k/AR6003/hw2.1.1/otp.bin"
-#define AR6003_REV3_FIRMWARE_FILE           "ath6k/AR6003/hw2.1.1/athwlan.bin"
-#define AR6003_REV3_TCMD_FIRMWARE_FILE    "ath6k/AR6003/hw2.1.1/athtcmd_ram.bin"
-#define AR6003_REV3_PATCH_FILE            "ath6k/AR6003/hw2.1.1/data.patch.bin"
-#define AR6003_REV3_FIRMWARE_2_FILE           "ath6k/AR6003/hw2.1.1/fw-2.bin"
-#define AR6003_REV3_BOARD_DATA_FILE       "ath6k/AR6003/hw2.1.1/bdata.bin"
-#define AR6003_REV3_DEFAULT_BOARD_DATA_FILE    \
-       "ath6k/AR6003/hw2.1.1/bdata.SD31.bin"
+#define AR6003_HW_2_1_1_VERSION                 0x30000582
+#define AR6003_HW_2_1_1_FW_DIR                 "ath6k/AR6003/hw2.1.1"
+#define AR6003_HW_2_1_1_OTP_FILE               "otp.bin"
+#define AR6003_HW_2_1_1_FIRMWARE_FILE          "athwlan.bin"
+#define AR6003_HW_2_1_1_TCMD_FIRMWARE_FILE     "athtcmd_ram.bin"
+#define AR6003_HW_2_1_1_PATCH_FILE             "data.patch.bin"
+#define AR6003_HW_2_1_1_BOARD_DATA_FILE "ath6k/AR6003/hw2.1.1/bdata.bin"
+#define AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE        \
+                       "ath6k/AR6003/hw2.1.1/bdata.SD31.bin"
 
 /* AR6004 1.0 definitions */
-#define AR6004_REV1_VERSION                 0x30000623
-#define AR6004_REV1_FIRMWARE_FILE           "ath6k/AR6004/hw6.1/fw.ram.bin"
-#define AR6004_REV1_FIRMWARE_2_FILE         "ath6k/AR6004/hw6.1/fw-2.bin"
-#define AR6004_REV1_BOARD_DATA_FILE         "ath6k/AR6004/hw6.1/bdata.bin"
-#define AR6004_REV1_DEFAULT_BOARD_DATA_FILE "ath6k/AR6004/hw6.1/bdata.DB132.bin"
-#define AR6004_REV1_EPPING_FIRMWARE_FILE "ath6k/AR6004/hw6.1/endpointping.bin"
+#define AR6004_HW_1_0_VERSION                 0x30000623
+#define AR6004_HW_1_0_FW_DIR                   "ath6k/AR6004/hw1.0"
+#define AR6004_HW_1_0_FIRMWARE_FILE            "fw.ram.bin"
+#define AR6004_HW_1_0_BOARD_DATA_FILE         "ath6k/AR6004/hw1.0/bdata.bin"
+#define AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE \
+       "ath6k/AR6004/hw1.0/bdata.DB132.bin"
+
+/* AR6004 1.1 definitions */
+#define AR6004_HW_1_1_VERSION                 0x30000001
+#define AR6004_HW_1_1_FW_DIR                   "ath6k/AR6004/hw1.1"
+#define AR6004_HW_1_1_FIRMWARE_FILE            "fw.ram.bin"
+#define AR6004_HW_1_1_BOARD_DATA_FILE         "ath6k/AR6004/hw1.1/bdata.bin"
+#define AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE \
+       "ath6k/AR6004/hw1.1/bdata.DB132.bin"
 
 /* Per STA data, used in AP mode */
 #define STA_PS_AWAKE           BIT(0)
@@ -166,6 +187,7 @@ struct ath6kl_fw_ie {
 #define ATH6KL_CONF_IGNORE_PS_FAIL_EVT_IN_SCAN  BIT(1)
 #define ATH6KL_CONF_ENABLE_11N                 BIT(2)
 #define ATH6KL_CONF_ENABLE_TX_BURST            BIT(3)
+#define ATH6KL_CONF_SUSPEND_CUTPOWER           BIT(4)
 
 enum wlan_low_pwr_state {
        WLAN_POWER_STATE_ON,
@@ -271,6 +293,8 @@ struct ath6kl_bmi {
        u32 cmd_credits;
        bool done_sent;
        u8 *cmd_buf;
+       u32 max_data_size;
+       u32 max_cmd_size;
 };
 
 struct target_stats {
@@ -380,41 +404,42 @@ struct ath6kl_req_key {
        u8 key_len;
 };
 
-/* Flag info */
-#define WMI_ENABLED    0
-#define WMI_READY      1
-#define CONNECTED      2
-#define STATS_UPDATE_PEND 3
-#define CONNECT_PEND     4
-#define WMM_ENABLED      5
-#define NETQ_STOPPED     6
-#define WMI_CTRL_EP_FULL  7
-#define DTIM_EXPIRED     8
-#define DESTROY_IN_PROGRESS  9
-#define NETDEV_REGISTERED    10
-#define SKIP_SCAN           11
-#define WLAN_ENABLED        12
-#define TESTMODE            13
-#define CLEAR_BSSFILTER_ON_BEACON 14
-#define DTIM_PERIOD_AVAIL    15
-#define ROAM_TBL_PEND        16
+enum ath6kl_hif_type {
+       ATH6KL_HIF_TYPE_SDIO,
+       ATH6KL_HIF_TYPE_USB,
+};
 
-struct ath6kl {
-       struct device *dev;
-       struct net_device *net_dev;
-       struct ath6kl_bmi bmi;
-       const struct ath6kl_hif_ops *hif_ops;
-       struct wmi *wmi;
-       int tx_pending[ENDPOINT_MAX];
-       int total_tx_data_pend;
-       struct htc_target *htc_target;
-       void *hif_priv;
-       spinlock_t lock;
-       struct semaphore sem;
+/*
+ * Driver's maximum limit, note that some firmwares support only one vif
+ * and the runtime (current) limit must be checked from ar->vif_max.
+ */
+#define ATH6KL_VIF_MAX 3
+
+/* vif flags info */
+enum ath6kl_vif_state {
+       CONNECTED,
+       CONNECT_PEND,
+       WMM_ENABLED,
+       NETQ_STOPPED,
+       DTIM_EXPIRED,
+       NETDEV_REGISTERED,
+       CLEAR_BSSFILTER_ON_BEACON,
+       DTIM_PERIOD_AVAIL,
+       WLAN_ENABLED,
+       STATS_UPDATE_PEND,
+};
+
+struct ath6kl_vif {
+       struct list_head list;
+       struct wireless_dev wdev;
+       struct net_device *ndev;
+       struct ath6kl *ar;
+       /* Lock to protect vif specific net_stats and flags */
+       spinlock_t if_lock;
+       u8 fw_vif_idx;
+       unsigned long flags;
        int ssid_len;
        u8 ssid[IEEE80211_MAX_SSID_LEN];
-       u8 next_mode;
-       u8 nw_type;
        u8 dot11_auth_mode;
        u8 auth_mode;
        u8 prwise_crypto;
@@ -422,21 +447,91 @@ struct ath6kl {
        u8 grp_crypto;
        u8 grp_crypto_len;
        u8 def_txkey_index;
-       struct ath6kl_wep_key wep_key_list[WMI_MAX_KEY_INDEX + 1];
+       u8 next_mode;
+       u8 nw_type;
        u8 bssid[ETH_ALEN];
        u8 req_bssid[ETH_ALEN];
        u16 ch_hint;
        u16 bss_ch;
+       struct ath6kl_wep_key wep_key_list[WMI_MAX_KEY_INDEX + 1];
+       struct ath6kl_key keys[WMI_MAX_KEY_INDEX + 1];
+       struct aggr_info *aggr_cntxt;
+
+       struct timer_list disconnect_timer;
+       struct timer_list sched_scan_timer;
+
+       struct cfg80211_scan_request *scan_req;
+       enum sme_state sme_state;
+       int reconnect_flag;
+       u32 last_roc_id;
+       u32 last_cancel_roc_id;
+       u32 send_action_id;
+       bool probe_req_report;
+       u16 next_chan;
+       u16 assoc_bss_beacon_int;
+       u8 assoc_bss_dtim_period;
+       struct net_device_stats net_stats;
+       struct target_stats target_stats;
+};
+
+#define WOW_LIST_ID            0
+#define WOW_HOST_REQ_DELAY     500 /* ms */
+
+#define ATH6KL_SCHED_SCAN_RESULT_DELAY 5000 /* ms */
+
+/* Flag info */
+enum ath6kl_dev_state {
+       WMI_ENABLED,
+       WMI_READY,
+       WMI_CTRL_EP_FULL,
+       TESTMODE,
+       DESTROY_IN_PROGRESS,
+       SKIP_SCAN,
+       ROAM_TBL_PEND,
+       FIRST_BOOT,
+};
+
+enum ath6kl_state {
+       ATH6KL_STATE_OFF,
+       ATH6KL_STATE_ON,
+       ATH6KL_STATE_DEEPSLEEP,
+       ATH6KL_STATE_CUTPOWER,
+       ATH6KL_STATE_WOW,
+       ATH6KL_STATE_SCHED_SCAN,
+};
+
+struct ath6kl {
+       struct device *dev;
+       struct wiphy *wiphy;
+
+       enum ath6kl_state state;
+
+       struct ath6kl_bmi bmi;
+       const struct ath6kl_hif_ops *hif_ops;
+       struct wmi *wmi;
+       int tx_pending[ENDPOINT_MAX];
+       int total_tx_data_pend;
+       struct htc_target *htc_target;
+       enum ath6kl_hif_type hif_type;
+       void *hif_priv;
+       struct list_head vif_list;
+       /* Lock to avoid race in vif_list entries among add/del/traverse */
+       spinlock_t list_lock;
+       u8 num_vif;
+       unsigned int vif_max;
+       u8 max_norm_iface;
+       u8 avail_idx_map;
+       spinlock_t lock;
+       struct semaphore sem;
        u16 listen_intvl_b;
        u16 listen_intvl_t;
        u8 lrssi_roam_threshold;
        struct ath6kl_version version;
        u32 target_type;
        u8 tx_pwr;
-       struct net_device_stats net_stats;
-       struct target_stats target_stats;
        struct ath6kl_node_mapping node_map[MAX_NODE_NUM];
        u8 ibss_ps_enable;
+       bool ibss_if_active;
        u8 node_num;
        u8 next_ep_id;
        struct ath6kl_cookie *cookie_list;
@@ -447,7 +542,7 @@ struct ath6kl {
        u8 hiac_stream_active_pri;
        u8 ep2ac_map[ENDPOINT_MAX];
        enum htc_endpoint_id ctrl_ep;
-       struct htc_credit_state_info credit_state_info;
+       struct ath6kl_htc_credit_info credit_state_info;
        u32 connect_ctrl_flags;
        u32 user_key_ctrl;
        u8 usr_bss_filter;
@@ -457,30 +552,41 @@ struct ath6kl {
        struct sk_buff_head mcastpsq;
        spinlock_t mcastpsq_lock;
        u8 intra_bss;
-       struct aggr_info *aggr_cntxt;
        struct wmi_ap_mode_stat ap_stats;
        u8 ap_country_code[3];
        struct list_head amsdu_rx_buffer_queue;
-       struct timer_list disconnect_timer;
        u8 rx_meta_ver;
-       struct wireless_dev *wdev;
-       struct cfg80211_scan_request *scan_req;
-       struct ath6kl_key keys[WMI_MAX_KEY_INDEX + 1];
-       enum sme_state sme_state;
        enum wlan_low_pwr_state wlan_pwr_state;
-       struct wmi_scan_params_cmd sc_params;
+       u8 mac_addr[ETH_ALEN];
 #define AR_MCAST_FILTER_MAC_ADDR_SIZE  4
        struct {
                void *rx_report;
                size_t rx_report_len;
        } tm;
 
-       struct {
+       struct ath6kl_hw {
+               u32 id;
+               const char *name;
                u32 dataset_patch_addr;
                u32 app_load_addr;
                u32 app_start_override_addr;
                u32 board_ext_data_addr;
                u32 reserved_ram_size;
+               u32 board_addr;
+               u32 refclk_hz;
+               u32 uarttx_pin;
+
+               struct ath6kl_hw_fw {
+                       const char *dir;
+                       const char *otp;
+                       const char *fw;
+                       const char *tcmd;
+                       const char *patch;
+                       const char *api2;
+               } fw;
+
+               const char *fw_board;
+               const char *fw_default_board;
        } hw;
 
        u16 conf_flags;
@@ -488,7 +594,6 @@ struct ath6kl {
        struct ath6kl_mbox_info mbox_info;
 
        struct ath6kl_cookie cookie_mem[MAX_COOKIE_NUM];
-       int reconnect_flag;
        unsigned long flag;
 
        u8 *fw_board;
@@ -509,13 +614,7 @@ struct ath6kl {
 
        struct dentry *debugfs_phy;
 
-       u32 send_action_id;
-       bool probe_req_report;
-       u16 next_chan;
-
        bool p2p;
-       u16 assoc_bss_beacon_int;
-       u8 assoc_bss_dtim_period;
 
 #ifdef CONFIG_ATH6KL_DEBUG
        struct {
@@ -540,19 +639,9 @@ struct ath6kl {
 #endif /* CONFIG_ATH6KL_DEBUG */
 };
 
-static inline void *ath6kl_priv(struct net_device *dev)
+static inline struct ath6kl *ath6kl_priv(struct net_device *dev)
 {
-       return wdev_priv(dev->ieee80211_ptr);
-}
-
-static inline void ath6kl_deposit_credit_to_ep(struct htc_credit_state_info
-                                              *cred_info,
-                                              struct htc_endpoint_credit_dist
-                                              *ep_dist, int credits)
-{
-       ep_dist->credits += credits;
-       ep_dist->cred_assngd += credits;
-       cred_info->cur_free_credits -= credits;
+       return ((struct ath6kl_vif *) netdev_priv(dev))->ar;
 }
 
 static inline u32 ath6kl_get_hi_item_addr(struct ath6kl *ar,
@@ -568,7 +657,6 @@ static inline u32 ath6kl_get_hi_item_addr(struct ath6kl *ar,
        return addr;
 }
 
-void ath6kl_destroy(struct net_device *dev, unsigned int unregister);
 int ath6kl_configure_target(struct ath6kl *ar);
 void ath6kl_detect_error(unsigned long ptr);
 void disconnect_timer_handler(unsigned long ptr);
@@ -586,10 +674,8 @@ int ath6kl_diag_write(struct ath6kl *ar, u32 address, void *data, u32 length);
 int ath6kl_diag_read32(struct ath6kl *ar, u32 address, u32 *value);
 int ath6kl_diag_read(struct ath6kl *ar, u32 address, void *data, u32 length);
 int ath6kl_read_fwlogs(struct ath6kl *ar);
-void ath6kl_init_profile_info(struct ath6kl *ar);
+void ath6kl_init_profile_info(struct ath6kl_vif *vif);
 void ath6kl_tx_data_cleanup(struct ath6kl *ar);
-void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile,
-                         bool get_dbglogs);
 
 struct ath6kl_cookie *ath6kl_alloc_cookie(struct ath6kl *ar);
 void ath6kl_free_cookie(struct ath6kl *ar, struct ath6kl_cookie *cookie);
@@ -605,40 +691,49 @@ struct htc_packet *ath6kl_alloc_amsdu_rxbuf(struct htc_target *target,
 void aggr_module_destroy(struct aggr_info *aggr_info);
 void aggr_reset_state(struct aggr_info *aggr_info);
 
-struct ath6kl_sta *ath6kl_find_sta(struct ath6kl *ar, u8 * node_addr);
+struct ath6kl_sta *ath6kl_find_sta(struct ath6kl_vif *vif, u8 * node_addr);
 struct ath6kl_sta *ath6kl_find_sta_by_aid(struct ath6kl *ar, u8 aid);
 
 void ath6kl_ready_event(void *devt, u8 * datap, u32 sw_ver, u32 abi_ver);
 int ath6kl_control_tx(void *devt, struct sk_buff *skb,
                      enum htc_endpoint_id eid);
-void ath6kl_connect_event(struct ath6kl *ar, u16 channel,
+void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel,
                          u8 *bssid, u16 listen_int,
                          u16 beacon_int, enum network_type net_type,
                          u8 beacon_ie_len, u8 assoc_req_len,
                          u8 assoc_resp_len, u8 *assoc_info);
-void ath6kl_connect_ap_mode_bss(struct ath6kl *ar, u16 channel);
-void ath6kl_connect_ap_mode_sta(struct ath6kl *ar, u16 aid, u8 *mac_addr,
+void ath6kl_connect_ap_mode_bss(struct ath6kl_vif *vif, u16 channel);
+void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr,
                                u8 keymgmt, u8 ucipher, u8 auth,
                                u8 assoc_req_len, u8 *assoc_info);
-void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason,
+void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason,
                             u8 *bssid, u8 assoc_resp_len,
                             u8 *assoc_info, u16 prot_reason_status);
-void ath6kl_tkip_micerr_event(struct ath6kl *ar, u8 keyid, bool ismcast);
+void ath6kl_tkip_micerr_event(struct ath6kl_vif *vif, u8 keyid, bool ismcast);
 void ath6kl_txpwr_rx_evt(void *devt, u8 tx_pwr);
-void ath6kl_scan_complete_evt(struct ath6kl *ar, int status);
-void ath6kl_tgt_stats_event(struct ath6kl *ar, u8 *ptr, u32 len);
+void ath6kl_scan_complete_evt(struct ath6kl_vif *vif, int status);
+void ath6kl_tgt_stats_event(struct ath6kl_vif *vif, u8 *ptr, u32 len);
 void ath6kl_indicate_tx_activity(void *devt, u8 traffic_class, bool active);
 enum htc_endpoint_id ath6kl_ac2_endpoint_id(void *devt, u8 ac);
 
-void ath6kl_pspoll_event(struct ath6kl *ar, u8 aid);
+void ath6kl_pspoll_event(struct ath6kl_vif *vif, u8 aid);
 
-void ath6kl_dtimexpiry_event(struct ath6kl *ar);
-void ath6kl_disconnect(struct ath6kl *ar);
-void ath6kl_deep_sleep_enable(struct ath6kl *ar);
-void aggr_recv_delba_req_evt(struct ath6kl *ar, u8 tid);
-void aggr_recv_addba_req_evt(struct ath6kl *ar, u8 tid, u16 seq_no,
+void ath6kl_dtimexpiry_event(struct ath6kl_vif *vif);
+void ath6kl_disconnect(struct ath6kl_vif *vif);
+void aggr_recv_delba_req_evt(struct ath6kl_vif *vif, u8 tid);
+void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid, u16 seq_no,
                             u8 win_sz);
 void ath6kl_wakeup_event(void *dev);
-void ath6kl_target_failure(struct ath6kl *ar);
+
+void ath6kl_reset_device(struct ath6kl *ar, u32 target_type,
+                        bool wait_fot_compltn, bool cold_reset);
+void ath6kl_init_control_info(struct ath6kl_vif *vif);
+void ath6kl_deinit_if_data(struct ath6kl_vif *vif);
+void ath6kl_core_free(struct ath6kl *ar);
+struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar);
+void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready);
+int ath6kl_init_hw_start(struct ath6kl *ar);
+int ath6kl_init_hw_stop(struct ath6kl *ar);
+void ath6kl_check_wow_status(struct ath6kl *ar);
 
 #endif /* CORE_H */