Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Common private data for ST-Ericsson CW1200 drivers
0004  *
0005  * Copyright (c) 2010, ST-Ericsson
0006  * Author: Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>
0007  *
0008  * Based on the mac80211 Prism54 code, which is
0009  * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
0010  *
0011  * Based on the islsm (softmac prism54) driver, which is:
0012  * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
0013  */
0014 
0015 #ifndef CW1200_H
0016 #define CW1200_H
0017 
0018 #include <linux/wait.h>
0019 #include <linux/mutex.h>
0020 #include <linux/workqueue.h>
0021 #include <net/mac80211.h>
0022 
0023 #include "queue.h"
0024 #include "wsm.h"
0025 #include "scan.h"
0026 #include "txrx.h"
0027 #include "pm.h"
0028 
0029 /* Forward declarations */
0030 struct hwbus_ops;
0031 struct task_struct;
0032 struct cw1200_debug_priv;
0033 struct firmware;
0034 
0035 #define CW1200_MAX_CTRL_FRAME_LEN   (0x1000)
0036 
0037 #define CW1200_MAX_STA_IN_AP_MODE   (5)
0038 #define CW1200_LINK_ID_AFTER_DTIM   (CW1200_MAX_STA_IN_AP_MODE + 1)
0039 #define CW1200_LINK_ID_UAPSD        (CW1200_MAX_STA_IN_AP_MODE + 2)
0040 #define CW1200_LINK_ID_MAX      (CW1200_MAX_STA_IN_AP_MODE + 3)
0041 #define CW1200_MAX_REQUEUE_ATTEMPTS (5)
0042 
0043 #define CW1200_MAX_TID          (8)
0044 
0045 #define CW1200_BLOCK_ACK_CNT        (30)
0046 #define CW1200_BLOCK_ACK_THLD       (800)
0047 #define CW1200_BLOCK_ACK_HIST       (3)
0048 #define CW1200_BLOCK_ACK_INTERVAL   (1 * HZ / CW1200_BLOCK_ACK_HIST)
0049 
0050 #define CW1200_JOIN_TIMEOUT     (1 * HZ)
0051 #define CW1200_AUTH_TIMEOUT     (5 * HZ)
0052 
0053 struct cw1200_ht_info {
0054     struct ieee80211_sta_ht_cap     ht_cap;
0055     enum nl80211_channel_type       channel_type;
0056     u16                             operation_mode;
0057 };
0058 
0059 /* Please keep order */
0060 enum cw1200_join_status {
0061     CW1200_JOIN_STATUS_PASSIVE = 0,
0062     CW1200_JOIN_STATUS_MONITOR,
0063     CW1200_JOIN_STATUS_JOINING,
0064     CW1200_JOIN_STATUS_PRE_STA,
0065     CW1200_JOIN_STATUS_STA,
0066     CW1200_JOIN_STATUS_IBSS,
0067     CW1200_JOIN_STATUS_AP,
0068 };
0069 
0070 enum cw1200_link_status {
0071     CW1200_LINK_OFF,
0072     CW1200_LINK_RESERVE,
0073     CW1200_LINK_SOFT,
0074     CW1200_LINK_HARD,
0075     CW1200_LINK_RESET,
0076     CW1200_LINK_RESET_REMAP,
0077 };
0078 
0079 extern int cw1200_power_mode;
0080 extern const char * const cw1200_fw_types[];
0081 
0082 struct cw1200_link_entry {
0083     unsigned long           timestamp;
0084     enum cw1200_link_status     status;
0085     enum cw1200_link_status     prev_status;
0086     u8              mac[ETH_ALEN];
0087     u8              buffered[CW1200_MAX_TID];
0088     struct sk_buff_head     rx_queue;
0089 };
0090 
0091 struct cw1200_common {
0092     /* interfaces to the rest of the stack */
0093     struct ieee80211_hw     *hw;
0094     struct ieee80211_vif        *vif;
0095     struct device           *pdev;
0096 
0097     /* Statistics */
0098     struct ieee80211_low_level_stats stats;
0099 
0100     /* Our macaddr */
0101     u8 mac_addr[ETH_ALEN];
0102 
0103     /* Hardware interface */
0104     const struct hwbus_ops      *hwbus_ops;
0105     struct hwbus_priv       *hwbus_priv;
0106 
0107     /* Hardware information */
0108     enum {
0109         HIF_9000_SILICON_VERSATILE = 0,
0110         HIF_8601_VERSATILE,
0111         HIF_8601_SILICON,
0112     } hw_type;
0113     enum {
0114         CW1200_HW_REV_CUT10 = 10,
0115         CW1200_HW_REV_CUT11 = 11,
0116         CW1200_HW_REV_CUT20 = 20,
0117         CW1200_HW_REV_CUT22 = 22,
0118         CW1X60_HW_REV       = 40,
0119     } hw_revision;
0120     int                             hw_refclk;
0121     bool                hw_have_5ghz;
0122     const struct firmware       *sdd;
0123     char                            *sdd_path;
0124 
0125     struct cw1200_debug_priv    *debug;
0126 
0127     struct workqueue_struct     *workqueue;
0128     struct mutex            conf_mutex;
0129 
0130     struct cw1200_queue     tx_queue[4];
0131     struct cw1200_queue_stats   tx_queue_stats;
0132     int             tx_burst_idx;
0133 
0134     /* firmware/hardware info */
0135     unsigned int tx_hdr_len;
0136 
0137     /* Radio data */
0138     int output_power;
0139 
0140     /* BBP/MAC state */
0141     struct ieee80211_rate       *rates;
0142     struct ieee80211_rate       *mcs_rates;
0143     struct ieee80211_channel    *channel;
0144     struct wsm_edca_params      edca;
0145     struct wsm_tx_queue_params  tx_queue_params;
0146     struct wsm_mib_association_mode association_mode;
0147     struct wsm_set_bss_params   bss_params;
0148     struct cw1200_ht_info       ht_info;
0149     struct wsm_set_pm       powersave_mode;
0150     struct wsm_set_pm       firmware_ps_mode;
0151     int             cqm_rssi_thold;
0152     unsigned            cqm_rssi_hyst;
0153     bool                cqm_use_rssi;
0154     int             cqm_beacon_loss_count;
0155     int             channel_switch_in_progress;
0156     wait_queue_head_t       channel_switch_done;
0157     u8              long_frame_max_tx_count;
0158     u8              short_frame_max_tx_count;
0159     int             mode;
0160     bool                enable_beacon;
0161     int             beacon_int;
0162     bool                listening;
0163     struct wsm_rx_filter        rx_filter;
0164     struct wsm_mib_multicast_filter multicast_filter;
0165     bool                has_multicast_subscription;
0166     bool                disable_beacon_filter;
0167     struct work_struct      update_filtering_work;
0168     struct work_struct      set_beacon_wakeup_period_work;
0169 
0170     u8              ba_rx_tid_mask;
0171     u8              ba_tx_tid_mask;
0172 
0173     struct cw1200_pm_state      pm_state;
0174 
0175     struct wsm_p2p_ps_modeinfo  p2p_ps_modeinfo;
0176     struct wsm_uapsd_info       uapsd_info;
0177     bool                setbssparams_done;
0178     bool                bt_present;
0179     u8              conf_listen_interval;
0180     u32             listen_interval;
0181     u32             erp_info;
0182     u32             rts_threshold;
0183 
0184     /* BH */
0185     atomic_t            bh_rx;
0186     atomic_t            bh_tx;
0187     atomic_t            bh_term;
0188     atomic_t            bh_suspend;
0189 
0190     struct workqueue_struct         *bh_workqueue;
0191     struct work_struct              bh_work;
0192 
0193     int             bh_error;
0194     wait_queue_head_t       bh_wq;
0195     wait_queue_head_t       bh_evt_wq;
0196     u8              buf_id_tx;
0197     u8              buf_id_rx;
0198     u8              wsm_rx_seq;
0199     u8              wsm_tx_seq;
0200     int             hw_bufs_used;
0201     bool                powersave_enabled;
0202     bool                device_can_sleep;
0203 
0204     /* Scan status */
0205     struct cw1200_scan scan;
0206     /* Keep cw1200 awake (WUP = 1) 1 second after each scan to avoid
0207      * FW issue with sleeping/waking up.
0208      */
0209     atomic_t            recent_scan;
0210     struct delayed_work     clear_recent_scan_work;
0211 
0212     /* WSM */
0213     struct wsm_startup_ind      wsm_caps;
0214     struct mutex            wsm_cmd_mux;
0215     struct wsm_buf          wsm_cmd_buf;
0216     struct wsm_cmd          wsm_cmd;
0217     wait_queue_head_t       wsm_cmd_wq;
0218     wait_queue_head_t       wsm_startup_done;
0219     int                             firmware_ready;
0220     atomic_t            tx_lock;
0221 
0222     /* WSM debug */
0223     int             wsm_enable_wsm_dumps;
0224 
0225     /* WSM Join */
0226     enum cw1200_join_status join_status;
0227     u32         pending_frame_id;
0228     bool            join_pending;
0229     struct delayed_work join_timeout;
0230     struct work_struct  unjoin_work;
0231     struct work_struct  join_complete_work;
0232     int         join_complete_status;
0233     int         join_dtim_period;
0234     bool            delayed_unjoin;
0235 
0236     /* TX/RX and security */
0237     s8          wep_default_key_id;
0238     struct work_struct  wep_key_work;
0239     u32         key_map;
0240     struct wsm_add_key  keys[WSM_KEY_MAX_INDEX + 1];
0241 
0242     /* AP powersave */
0243     u32         link_id_map;
0244     struct cw1200_link_entry link_id_db[CW1200_MAX_STA_IN_AP_MODE];
0245     struct work_struct  link_id_work;
0246     struct delayed_work link_id_gc_work;
0247     u32         sta_asleep_mask;
0248     u32         pspoll_mask;
0249     bool            aid0_bit_set;
0250     spinlock_t      ps_state_lock; /* Protect power save state */
0251     bool            buffered_multicasts;
0252     bool            tx_multicast;
0253     struct work_struct  set_tim_work;
0254     struct work_struct  set_cts_work;
0255     struct work_struct  multicast_start_work;
0256     struct work_struct  multicast_stop_work;
0257     struct timer_list   mcast_timeout;
0258 
0259     /* WSM events and CQM implementation */
0260     spinlock_t      event_queue_lock; /* Protect event queue */
0261     struct list_head    event_queue;
0262     struct work_struct  event_handler;
0263 
0264     struct delayed_work bss_loss_work;
0265     spinlock_t      bss_loss_lock; /* Protect BSS loss state */
0266     int                     bss_loss_state;
0267     u32                     bss_loss_confirm_id;
0268     int         delayed_link_loss;
0269     struct work_struct  bss_params_work;
0270 
0271     /* TX rate policy cache */
0272     struct tx_policy_cache tx_policy_cache;
0273     struct work_struct tx_policy_upload_work;
0274 
0275     /* legacy PS mode switch in suspend */
0276     int         ps_mode_switch_in_progress;
0277     wait_queue_head_t   ps_mode_switch_done;
0278 
0279     /* Workaround for WFD testcase 6.1.10*/
0280     struct work_struct  linkid_reset_work;
0281     u8          action_frame_sa[ETH_ALEN];
0282     u8          action_linkid;
0283 };
0284 
0285 struct cw1200_sta_priv {
0286     int link_id;
0287 };
0288 
0289 /* interfaces for the drivers */
0290 int cw1200_core_probe(const struct hwbus_ops *hwbus_ops,
0291               struct hwbus_priv *hwbus,
0292               struct device *pdev,
0293               struct cw1200_common **pself,
0294               int ref_clk, const u8 *macaddr,
0295               const char *sdd_path, bool have_5ghz);
0296 void cw1200_core_release(struct cw1200_common *self);
0297 
0298 #define FWLOAD_BLOCK_SIZE (1024)
0299 
0300 static inline int cw1200_is_ht(const struct cw1200_ht_info *ht_info)
0301 {
0302     return ht_info->channel_type != NL80211_CHAN_NO_HT;
0303 }
0304 
0305 static inline int cw1200_ht_greenfield(const struct cw1200_ht_info *ht_info)
0306 {
0307     return cw1200_is_ht(ht_info) &&
0308         (ht_info->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) &&
0309         !(ht_info->operation_mode &
0310           IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
0311 }
0312 
0313 static inline int cw1200_ht_ampdu_density(const struct cw1200_ht_info *ht_info)
0314 {
0315     if (!cw1200_is_ht(ht_info))
0316         return 0;
0317     return ht_info->ht_cap.ampdu_density;
0318 }
0319 
0320 #endif /* CW1200_H */