root/drivers/net/wireless/st/cw1200/cw1200.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. cw1200_is_ht
  2. cw1200_ht_greenfield
  3. cw1200_ht_ampdu_density

   1 /* SPDX-License-Identifier: GPL-2.0-only */
   2 /*
   3  * Common private data for ST-Ericsson CW1200 drivers
   4  *
   5  * Copyright (c) 2010, ST-Ericsson
   6  * Author: Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>
   7  *
   8  * Based on the mac80211 Prism54 code, which is
   9  * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
  10  *
  11  * Based on the islsm (softmac prism54) driver, which is:
  12  * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
  13  */
  14 
  15 #ifndef CW1200_H
  16 #define CW1200_H
  17 
  18 #include <linux/wait.h>
  19 #include <linux/mutex.h>
  20 #include <linux/workqueue.h>
  21 #include <net/mac80211.h>
  22 
  23 #include "queue.h"
  24 #include "wsm.h"
  25 #include "scan.h"
  26 #include "txrx.h"
  27 #include "pm.h"
  28 
  29 /* Forward declarations */
  30 struct hwbus_ops;
  31 struct task_struct;
  32 struct cw1200_debug_priv;
  33 struct firmware;
  34 
  35 #define CW1200_MAX_CTRL_FRAME_LEN       (0x1000)
  36 
  37 #define CW1200_MAX_STA_IN_AP_MODE       (5)
  38 #define CW1200_LINK_ID_AFTER_DTIM       (CW1200_MAX_STA_IN_AP_MODE + 1)
  39 #define CW1200_LINK_ID_UAPSD            (CW1200_MAX_STA_IN_AP_MODE + 2)
  40 #define CW1200_LINK_ID_MAX              (CW1200_MAX_STA_IN_AP_MODE + 3)
  41 #define CW1200_MAX_REQUEUE_ATTEMPTS     (5)
  42 
  43 #define CW1200_MAX_TID                  (8)
  44 
  45 #define CW1200_BLOCK_ACK_CNT            (30)
  46 #define CW1200_BLOCK_ACK_THLD           (800)
  47 #define CW1200_BLOCK_ACK_HIST           (3)
  48 #define CW1200_BLOCK_ACK_INTERVAL       (1 * HZ / CW1200_BLOCK_ACK_HIST)
  49 
  50 #define CW1200_JOIN_TIMEOUT             (1 * HZ)
  51 #define CW1200_AUTH_TIMEOUT             (5 * HZ)
  52 
  53 struct cw1200_ht_info {
  54         struct ieee80211_sta_ht_cap     ht_cap;
  55         enum nl80211_channel_type       channel_type;
  56         u16                             operation_mode;
  57 };
  58 
  59 /* Please keep order */
  60 enum cw1200_join_status {
  61         CW1200_JOIN_STATUS_PASSIVE = 0,
  62         CW1200_JOIN_STATUS_MONITOR,
  63         CW1200_JOIN_STATUS_JOINING,
  64         CW1200_JOIN_STATUS_PRE_STA,
  65         CW1200_JOIN_STATUS_STA,
  66         CW1200_JOIN_STATUS_IBSS,
  67         CW1200_JOIN_STATUS_AP,
  68 };
  69 
  70 enum cw1200_link_status {
  71         CW1200_LINK_OFF,
  72         CW1200_LINK_RESERVE,
  73         CW1200_LINK_SOFT,
  74         CW1200_LINK_HARD,
  75         CW1200_LINK_RESET,
  76         CW1200_LINK_RESET_REMAP,
  77 };
  78 
  79 extern int cw1200_power_mode;
  80 extern const char * const cw1200_fw_types[];
  81 
  82 struct cw1200_link_entry {
  83         unsigned long                   timestamp;
  84         enum cw1200_link_status         status;
  85         enum cw1200_link_status         prev_status;
  86         u8                              mac[ETH_ALEN];
  87         u8                              buffered[CW1200_MAX_TID];
  88         struct sk_buff_head             rx_queue;
  89 };
  90 
  91 struct cw1200_common {
  92         /* interfaces to the rest of the stack */
  93         struct ieee80211_hw             *hw;
  94         struct ieee80211_vif            *vif;
  95         struct device                   *pdev;
  96 
  97         /* Statistics */
  98         struct ieee80211_low_level_stats stats;
  99 
 100         /* Our macaddr */
 101         u8 mac_addr[ETH_ALEN];
 102 
 103         /* Hardware interface */
 104         const struct hwbus_ops          *hwbus_ops;
 105         struct hwbus_priv               *hwbus_priv;
 106 
 107         /* Hardware information */
 108         enum {
 109                 HIF_9000_SILICON_VERSATILE = 0,
 110                 HIF_8601_VERSATILE,
 111                 HIF_8601_SILICON,
 112         } hw_type;
 113         enum {
 114                 CW1200_HW_REV_CUT10 = 10,
 115                 CW1200_HW_REV_CUT11 = 11,
 116                 CW1200_HW_REV_CUT20 = 20,
 117                 CW1200_HW_REV_CUT22 = 22,
 118                 CW1X60_HW_REV       = 40,
 119         } hw_revision;
 120         int                             hw_refclk;
 121         bool                            hw_have_5ghz;
 122         const struct firmware           *sdd;
 123         char                            *sdd_path;
 124 
 125         struct cw1200_debug_priv        *debug;
 126 
 127         struct workqueue_struct         *workqueue;
 128         struct mutex                    conf_mutex;
 129 
 130         struct cw1200_queue             tx_queue[4];
 131         struct cw1200_queue_stats       tx_queue_stats;
 132         int                             tx_burst_idx;
 133 
 134         /* firmware/hardware info */
 135         unsigned int tx_hdr_len;
 136 
 137         /* Radio data */
 138         int output_power;
 139 
 140         /* BBP/MAC state */
 141         struct ieee80211_rate           *rates;
 142         struct ieee80211_rate           *mcs_rates;
 143         struct ieee80211_channel        *channel;
 144         struct wsm_edca_params          edca;
 145         struct wsm_tx_queue_params      tx_queue_params;
 146         struct wsm_mib_association_mode association_mode;
 147         struct wsm_set_bss_params       bss_params;
 148         struct cw1200_ht_info           ht_info;
 149         struct wsm_set_pm               powersave_mode;
 150         struct wsm_set_pm               firmware_ps_mode;
 151         int                             cqm_rssi_thold;
 152         unsigned                        cqm_rssi_hyst;
 153         bool                            cqm_use_rssi;
 154         int                             cqm_beacon_loss_count;
 155         int                             channel_switch_in_progress;
 156         wait_queue_head_t               channel_switch_done;
 157         u8                              long_frame_max_tx_count;
 158         u8                              short_frame_max_tx_count;
 159         int                             mode;
 160         bool                            enable_beacon;
 161         int                             beacon_int;
 162         bool                            listening;
 163         struct wsm_rx_filter            rx_filter;
 164         struct wsm_mib_multicast_filter multicast_filter;
 165         bool                            has_multicast_subscription;
 166         bool                            disable_beacon_filter;
 167         struct work_struct              update_filtering_work;
 168         struct work_struct              set_beacon_wakeup_period_work;
 169 
 170         u8                              ba_rx_tid_mask;
 171         u8                              ba_tx_tid_mask;
 172 
 173         struct cw1200_pm_state          pm_state;
 174 
 175         struct wsm_p2p_ps_modeinfo      p2p_ps_modeinfo;
 176         struct wsm_uapsd_info           uapsd_info;
 177         bool                            setbssparams_done;
 178         bool                            bt_present;
 179         u8                              conf_listen_interval;
 180         u32                             listen_interval;
 181         u32                             erp_info;
 182         u32                             rts_threshold;
 183 
 184         /* BH */
 185         atomic_t                        bh_rx;
 186         atomic_t                        bh_tx;
 187         atomic_t                        bh_term;
 188         atomic_t                        bh_suspend;
 189 
 190         struct workqueue_struct         *bh_workqueue;
 191         struct work_struct              bh_work;
 192 
 193         int                             bh_error;
 194         wait_queue_head_t               bh_wq;
 195         wait_queue_head_t               bh_evt_wq;
 196         u8                              buf_id_tx;
 197         u8                              buf_id_rx;
 198         u8                              wsm_rx_seq;
 199         u8                              wsm_tx_seq;
 200         int                             hw_bufs_used;
 201         bool                            powersave_enabled;
 202         bool                            device_can_sleep;
 203 
 204         /* Scan status */
 205         struct cw1200_scan scan;
 206         /* Keep cw1200 awake (WUP = 1) 1 second after each scan to avoid
 207          * FW issue with sleeping/waking up.
 208          */
 209         atomic_t                        recent_scan;
 210         struct delayed_work             clear_recent_scan_work;
 211 
 212         /* WSM */
 213         struct wsm_startup_ind          wsm_caps;
 214         struct mutex                    wsm_cmd_mux;
 215         struct wsm_buf                  wsm_cmd_buf;
 216         struct wsm_cmd                  wsm_cmd;
 217         wait_queue_head_t               wsm_cmd_wq;
 218         wait_queue_head_t               wsm_startup_done;
 219         int                             firmware_ready;
 220         atomic_t                        tx_lock;
 221 
 222         /* WSM debug */
 223         int                             wsm_enable_wsm_dumps;
 224 
 225         /* WSM Join */
 226         enum cw1200_join_status join_status;
 227         u32                     pending_frame_id;
 228         bool                    join_pending;
 229         struct delayed_work     join_timeout;
 230         struct work_struct      unjoin_work;
 231         struct work_struct      join_complete_work;
 232         int                     join_complete_status;
 233         int                     join_dtim_period;
 234         bool                    delayed_unjoin;
 235 
 236         /* TX/RX and security */
 237         s8                      wep_default_key_id;
 238         struct work_struct      wep_key_work;
 239         u32                     key_map;
 240         struct wsm_add_key      keys[WSM_KEY_MAX_INDEX + 1];
 241 
 242         /* AP powersave */
 243         u32                     link_id_map;
 244         struct cw1200_link_entry link_id_db[CW1200_MAX_STA_IN_AP_MODE];
 245         struct work_struct      link_id_work;
 246         struct delayed_work     link_id_gc_work;
 247         u32                     sta_asleep_mask;
 248         u32                     pspoll_mask;
 249         bool                    aid0_bit_set;
 250         spinlock_t              ps_state_lock; /* Protect power save state */
 251         bool                    buffered_multicasts;
 252         bool                    tx_multicast;
 253         struct work_struct      set_tim_work;
 254         struct work_struct      set_cts_work;
 255         struct work_struct      multicast_start_work;
 256         struct work_struct      multicast_stop_work;
 257         struct timer_list       mcast_timeout;
 258 
 259         /* WSM events and CQM implementation */
 260         spinlock_t              event_queue_lock; /* Protect event queue */
 261         struct list_head        event_queue;
 262         struct work_struct      event_handler;
 263 
 264         struct delayed_work     bss_loss_work;
 265         spinlock_t              bss_loss_lock; /* Protect BSS loss state */
 266         int                     bss_loss_state;
 267         u32                     bss_loss_confirm_id;
 268         int                     delayed_link_loss;
 269         struct work_struct      bss_params_work;
 270 
 271         /* TX rate policy cache */
 272         struct tx_policy_cache tx_policy_cache;
 273         struct work_struct tx_policy_upload_work;
 274 
 275         /* legacy PS mode switch in suspend */
 276         int                     ps_mode_switch_in_progress;
 277         wait_queue_head_t       ps_mode_switch_done;
 278 
 279         /* Workaround for WFD testcase 6.1.10*/
 280         struct work_struct      linkid_reset_work;
 281         u8                      action_frame_sa[ETH_ALEN];
 282         u8                      action_linkid;
 283 };
 284 
 285 struct cw1200_sta_priv {
 286         int link_id;
 287 };
 288 
 289 /* interfaces for the drivers */
 290 int cw1200_core_probe(const struct hwbus_ops *hwbus_ops,
 291                       struct hwbus_priv *hwbus,
 292                       struct device *pdev,
 293                       struct cw1200_common **pself,
 294                       int ref_clk, const u8 *macaddr,
 295                       const char *sdd_path, bool have_5ghz);
 296 void cw1200_core_release(struct cw1200_common *self);
 297 
 298 #define FWLOAD_BLOCK_SIZE (1024)
 299 
 300 static inline int cw1200_is_ht(const struct cw1200_ht_info *ht_info)
 301 {
 302         return ht_info->channel_type != NL80211_CHAN_NO_HT;
 303 }
 304 
 305 static inline int cw1200_ht_greenfield(const struct cw1200_ht_info *ht_info)
 306 {
 307         return cw1200_is_ht(ht_info) &&
 308                 (ht_info->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) &&
 309                 !(ht_info->operation_mode &
 310                   IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
 311 }
 312 
 313 static inline int cw1200_ht_ampdu_density(const struct cw1200_ht_info *ht_info)
 314 {
 315         if (!cw1200_is_ht(ht_info))
 316                 return 0;
 317         return ht_info->ht_cap.ampdu_density;
 318 }
 319 
 320 #endif /* CW1200_H */

/* [<][>][^][v][top][bottom][index][help] */