ath6kl: Add tx_complete() to struct htc_ep_callbacks
[cascardo/linux.git] / drivers / net / wireless / ath / ath6kl / core.h
index c863a28..f1ce003 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2010-2011 Atheros Communications Inc.
+ * Copyright (c) 2011-2012 Qualcomm Atheros, 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
 #define ATH6KL_MAX_ENDPOINTS   4
 #define MAX_NODE_NUM           15
 
+#define ATH6KL_APSD_ALL_FRAME          0xFFFF
+#define ATH6KL_APSD_NUM_OF_AC          0x4
+#define ATH6KL_APSD_FRAME_MASK         0xF
+
 /* Extra bytes for htc header alignment */
 #define ATH6KL_HTC_ALIGN_BYTES 3
 
@@ -55,8 +60,9 @@
 #define MAX_DEFAULT_SEND_QUEUE_DEPTH      (MAX_DEF_COOKIE_NUM / WMM_NUM_AC)
 
 #define DISCON_TIMER_INTVAL               10000  /* in msec */
-#define A_DEFAULT_LISTEN_INTERVAL         100
-#define A_MAX_WOW_LISTEN_INTERVAL         1000
+
+/* Channel dwell time in fg scan */
+#define ATH6KL_FG_SCAN_INTERVAL                50 /* in ms */
 
 /* includes also the null byte */
 #define ATH6KL_FIRMWARE_MAGIC               "QCA-ATH6KL"
@@ -85,6 +91,12 @@ enum ath6kl_fw_capability {
         */
        ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX,
 
+       /*
+        * Firmware has support to cleanup inactive stations
+        * in AP mode.
+        */
+       ATH6KL_FW_CAPABILITY_INACTIVITY_TIMEOUT,
+
        /* this needs to be last */
        ATH6KL_FW_CAPABILITY_MAX,
 };
@@ -97,45 +109,49 @@ struct ath6kl_fw_ie {
        u8 data[0];
 };
 
+#define ATH6KL_FW_API2_FILE "fw-2.bin"
+#define ATH6KL_FW_API3_FILE "fw-3.bin"
+
 /* AR6003 1.0 definitions */
 #define AR6003_HW_1_0_VERSION                 0x300002ba
 
 /* AR6003 2.0 definitions */
 #define AR6003_HW_2_0_VERSION                 0x30000384
 #define AR6003_HW_2_0_PATCH_DOWNLOAD_ADDRESS  0x57e910
-#define AR6003_HW_2_0_OTP_FILE "ath6k/AR6003/hw2.0/otp.bin.z77"
-#define AR6003_HW_2_0_FIRMWARE_FILE "ath6k/AR6003/hw2.0/athwlan.bin.z77"
-#define AR6003_HW_2_0_TCMD_FIRMWARE_FILE "ath6k/AR6003/hw2.0/athtcmd_ram.bin"
-#define AR6003_HW_2_0_PATCH_FILE "ath6k/AR6003/hw2.0/data.patch.bin"
-#define AR6003_HW_2_0_FIRMWARE_2_FILE "ath6k/AR6003/hw2.0/fw-2.bin"
+#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_HW_2_1_1_VERSION                 0x30000582
-#define AR6003_HW_2_1_1_OTP_FILE "ath6k/AR6003/hw2.1.1/otp.bin"
-#define AR6003_HW_2_1_1_FIRMWARE_FILE "ath6k/AR6003/hw2.1.1/athwlan.bin"
-#define AR6003_HW_2_1_1_TCMD_FIRMWARE_FILE \
-                       "ath6k/AR6003/hw2.1.1/athtcmd_ram.bin"
-#define AR6003_HW_2_1_1_PATCH_FILE "ath6k/AR6003/hw2.1.1/data.patch.bin"
-#define AR6003_HW_2_1_1_FIRMWARE_2_FILE "ath6k/AR6003/hw2.1.1/fw-2.bin"
+#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_UTF_FIRMWARE_FILE      "utf.bin"
+#define AR6003_HW_2_1_1_TESTSCRIPT_FILE        "nullTestFlow.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_HW_1_0_VERSION                 0x30000623
-#define AR6004_HW_1_0_FIRMWARE_2_FILE         "ath6k/AR6004/hw1.0/fw-2.bin"
-#define AR6004_HW_1_0_FIRMWARE_FILE           "ath6k/AR6004/hw1.0/fw.ram.bin"
+#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_FIRMWARE_2_FILE         "ath6k/AR6004/hw1.1/fw-2.bin"
-#define AR6004_HW_1_1_FIRMWARE_FILE           "ath6k/AR6004/hw1.1/fw.ram.bin"
+#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"
@@ -144,6 +160,8 @@ struct ath6kl_fw_ie {
 #define STA_PS_AWAKE           BIT(0)
 #define        STA_PS_SLEEP            BIT(1)
 #define        STA_PS_POLLED           BIT(2)
+#define STA_PS_APSD_TRIGGER     BIT(3)
+#define STA_PS_APSD_EOSP        BIT(4)
 
 /* HTC TX packet tagging definitions */
 #define ATH6KL_CONTROL_PKT_TAG    HTC_TX_PACKET_TAG_USER_DEFINED
@@ -173,6 +191,11 @@ struct ath6kl_fw_ie {
 
 #define MBOX_YIELD_LIMIT 99
 
+#define ATH6KL_DEFAULT_LISTEN_INTVAL   100 /* in TUs */
+#define ATH6KL_DEFAULT_BMISS_TIME      1500
+#define ATH6KL_MAX_WOW_LISTEN_INTL     300 /* in TUs */
+#define ATH6KL_MAX_BMISS_TIME          5000
+
 /* configuration lags */
 /*
  * ATH6KL_CONF_IGNORE_ERP_BARKER: Ignore the barker premable in
@@ -186,7 +209,9 @@ 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)
+#define ATH6KL_CONF_UART_DEBUG                 BIT(4)
+
+#define P2P_WILDCARD_SSID_LEN                  7 /* DIRECT- */
 
 enum wlan_low_pwr_state {
        WLAN_POWER_STATE_ON,
@@ -216,6 +241,12 @@ struct rxtid {
        u32 hold_q_sz;
        struct skb_hold_q *hold_q;
        struct sk_buff_head q;
+
+       /*
+        * FIXME: No clue what this should protect. Apparently it should
+        * protect some of the fields above but they are also accessed
+        * without taking the lock.
+        */
        spinlock_t lock;
 };
 
@@ -231,14 +262,19 @@ struct rxtid_stats {
        u32 num_bar;
 };
 
-struct aggr_info {
+struct aggr_info_conn {
        u8 aggr_sz;
        u8 timer_scheduled;
        struct timer_list timer;
        struct net_device *dev;
        struct rxtid rx_tid[NUM_OF_TIDS];
-       struct sk_buff_head free_q;
        struct rxtid_stats stat[NUM_OF_TIDS];
+       struct aggr_info *aggr_info;
+};
+
+struct aggr_info {
+       struct aggr_info_conn *aggr_conn;
+       struct sk_buff_head rx_amsdu_freeq;
 };
 
 struct ath6kl_wep_key {
@@ -270,6 +306,16 @@ struct ath6kl_cookie {
        struct ath6kl_cookie *arc_list_next;
 };
 
+struct ath6kl_mgmt_buff {
+       struct list_head list;
+       u32 freq;
+       u32 wait;
+       u32 id;
+       bool no_cck;
+       size_t len;
+       u8 buf[0];
+};
+
 struct ath6kl_sta {
        u16 sta_flags;
        u8 mac[ETH_ALEN];
@@ -279,7 +325,15 @@ struct ath6kl_sta {
        u8 auth;
        u8 wpa_ie[ATH6KL_MAX_IE];
        struct sk_buff_head psq;
+
+       /* protects psq, mgmt_psq, apsdq, and mgmt_psq_len fields */
        spinlock_t psq_lock;
+
+       struct list_head mgmt_psq;
+       size_t mgmt_psq_len;
+       u8 apsd_info;
+       struct sk_buff_head apsdq;
+       struct aggr_info_conn *aggr_conn;
 };
 
 struct ath6kl_version {
@@ -408,6 +462,13 @@ enum ath6kl_hif_type {
        ATH6KL_HIF_TYPE_USB,
 };
 
+/* Max number of filters that hw supports */
+#define ATH6K_MAX_MC_FILTERS_PER_LIST 7
+struct ath6kl_mc_filter {
+       struct list_head list;
+       char hw_addr[ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE];
+};
+
 /*
  * Driver's maximum limit, note that some firmwares support only one vif
  * and the runtime (current) limit must be checked from ar->vif_max.
@@ -426,6 +487,7 @@ enum ath6kl_vif_state {
        DTIM_PERIOD_AVAIL,
        WLAN_ENABLED,
        STATS_UPDATE_PEND,
+       HOST_SLEEP_MODE_CMD_PROCESSED,
 };
 
 struct ath6kl_vif {
@@ -468,9 +530,13 @@ struct ath6kl_vif {
        bool probe_req_report;
        u16 next_chan;
        u16 assoc_bss_beacon_int;
+       u16 listen_intvl_t;
+       u16 bmiss_time_t;
        u8 assoc_bss_dtim_period;
        struct net_device_stats net_stats;
        struct target_stats target_stats;
+
+       struct list_head mc_filter;
 };
 
 #define WOW_LIST_ID            0
@@ -493,6 +559,8 @@ enum ath6kl_dev_state {
 enum ath6kl_state {
        ATH6KL_STATE_OFF,
        ATH6KL_STATE_ON,
+       ATH6KL_STATE_SUSPENDING,
+       ATH6KL_STATE_RESUMING,
        ATH6KL_STATE_DEEPSLEEP,
        ATH6KL_STATE_CUTPOWER,
        ATH6KL_STATE_WOW,
@@ -504,6 +572,7 @@ struct ath6kl {
        struct wiphy *wiphy;
 
        enum ath6kl_state state;
+       unsigned int testmode;
 
        struct ath6kl_bmi bmi;
        const struct ath6kl_hif_ops *hif_ops;
@@ -520,10 +589,14 @@ struct ath6kl {
        unsigned int vif_max;
        u8 max_norm_iface;
        u8 avail_idx_map;
+
+       /*
+        * Protects at least amsdu_rx_buffer_queue, ath6kl_alloc_cookie()
+        * calls, tx_pending and total_tx_data_pend.
+        */
        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;
@@ -549,7 +622,13 @@ struct ath6kl {
        u8 sta_list_index;
        struct ath6kl_req_key ap_mode_bkey;
        struct sk_buff_head mcastpsq;
+
+       /*
+        * FIXME: protects access to mcastpsq but is actually useless as
+        * all skbe_queue_*() functions provide serialisation themselves
+        */
        spinlock_t mcastpsq_lock;
+
        u8 intra_bss;
        struct wmi_ap_mode_stat ap_stats;
        u8 ap_country_code[3];
@@ -574,17 +653,25 @@ struct ath6kl {
                u32 board_addr;
                u32 refclk_hz;
                u32 uarttx_pin;
+               u32 testscript_addr;
+
+               struct ath6kl_hw_fw {
+                       const char *dir;
+                       const char *otp;
+                       const char *fw;
+                       const char *tcmd;
+                       const char *patch;
+                       const char *utf;
+                       const char *testscript;
+               } fw;
 
-               const char *fw_otp;
-               const char *fw;
-               const char *fw_tcmd;
-               const char *fw_patch;
-               const char *fw_api2;
                const char *fw_board;
                const char *fw_default_board;
        } hw;
 
        u16 conf_flags;
+       u16 suspend_mode;
+       u16 wow_suspend_mode;
        wait_queue_head_t event_wq;
        struct ath6kl_mbox_info mbox_info;
 
@@ -603,6 +690,10 @@ struct ath6kl {
        u8 *fw_patch;
        size_t fw_patch_len;
 
+       u8 *fw_testscript;
+       size_t fw_testscript_len;
+
+       unsigned int fw_api;
        unsigned long fw_capabilities[ATH6KL_CAPABILITY_LEN];
 
        struct workqueue_struct *ath6kl_wq;
@@ -611,12 +702,16 @@ struct ath6kl {
 
        bool p2p;
 
+       bool wiphy_registered;
+
 #ifdef CONFIG_ATH6KL_DEBUG
        struct {
-               struct circ_buf fwlog_buf;
-               spinlock_t fwlog_lock;
-               void *fwlog_tmp;
+               struct sk_buff_head fwlog_queue;
+               struct completion fwlog_completion;
+               bool fwlog_open;
+
                u32 fwlog_mask;
+
                unsigned int dbgfs_diag_reg;
                u32 diag_reg_addr_wr;
                u32 diag_reg_val_wr;
@@ -659,7 +754,8 @@ void init_netdev(struct net_device *dev);
 void ath6kl_cookie_init(struct ath6kl *ar);
 void ath6kl_cookie_cleanup(struct ath6kl *ar);
 void ath6kl_rx(struct htc_target *target, struct htc_packet *packet);
-void ath6kl_tx_complete(void *context, struct list_head *packet_queue);
+void ath6kl_tx_complete(struct htc_target *context,
+                       struct list_head *packet_queue);
 enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target,
                                               struct htc_packet *packet);
 void ath6kl_stop_txrx(struct ath6kl *ar);
@@ -676,7 +772,9 @@ struct ath6kl_cookie *ath6kl_alloc_cookie(struct ath6kl *ar);
 void ath6kl_free_cookie(struct ath6kl *ar, struct ath6kl_cookie *cookie);
 int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev);
 
-struct aggr_info *aggr_init(struct net_device *dev);
+struct aggr_info *aggr_init(struct ath6kl_vif *vif);
+void aggr_conn_init(struct ath6kl_vif *vif, struct aggr_info *aggr_info,
+                   struct aggr_info_conn *aggr_conn);
 void ath6kl_rx_refill(struct htc_target *target,
                      enum htc_endpoint_id endpoint);
 void ath6kl_refill_amsdu_rxbufs(struct ath6kl *ar, int count);
@@ -684,12 +782,12 @@ struct htc_packet *ath6kl_alloc_amsdu_rxbuf(struct htc_target *target,
                                            enum htc_endpoint_id endpoint,
                                            int len);
 void aggr_module_destroy(struct aggr_info *aggr_info);
-void aggr_reset_state(struct aggr_info *aggr_info);
+void aggr_reset_state(struct aggr_info_conn *aggr_conn);
 
-struct ath6kl_sta *ath6kl_find_sta(struct ath6kl_vif *vif, 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);
+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_vif *vif, u16 channel,
@@ -700,7 +798,7 @@ void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel,
 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);
+                               u8 assoc_req_len, u8 *assoc_info, u8 apsd_info);
 void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason,
                             u8 *bssid, u8 assoc_resp_len,
                             u8 *assoc_info, u16 prot_reason_status);
@@ -723,12 +821,18 @@ void ath6kl_wakeup_event(void *dev);
 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);
+int ath6kl_init_fetch_firmwares(struct ath6kl *ar);
+int ath6kl_init_hw_params(struct ath6kl *ar);
+
 void ath6kl_check_wow_status(struct ath6kl *ar);
 
+struct ath6kl *ath6kl_core_create(struct device *dev);
+int ath6kl_core_init(struct ath6kl *ar);
+void ath6kl_core_cleanup(struct ath6kl *ar);
+void ath6kl_core_destroy(struct ath6kl *ar);
+
 #endif /* CORE_H */