Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Atheros CARL9170 driver
0003  *
0004  * Driver specific definitions
0005  *
0006  * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
0007  * Copyright 2009, 2010, Christian Lamparter <chunkeey@googlemail.com>
0008  *
0009  * This program is free software; you can redistribute it and/or modify
0010  * it under the terms of the GNU General Public License as published by
0011  * the Free Software Foundation; either version 2 of the License, or
0012  * (at your option) any later version.
0013  *
0014  * This program is distributed in the hope that it will be useful,
0015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  * GNU General Public License for more details.
0018  *
0019  * You should have received a copy of the GNU General Public License
0020  * along with this program; see the file COPYING.  If not, see
0021  * http://www.gnu.org/licenses/.
0022  *
0023  * This file incorporates work covered by the following copyright and
0024  * permission notice:
0025  *    Copyright (c) 2007-2008 Atheros Communications, Inc.
0026  *
0027  *    Permission to use, copy, modify, and/or distribute this software for any
0028  *    purpose with or without fee is hereby granted, provided that the above
0029  *    copyright notice and this permission notice appear in all copies.
0030  *
0031  *    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0032  *    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0033  *    MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0034  *    ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0035  *    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0036  *    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0037  *    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0038  */
0039 #ifndef __CARL9170_H
0040 #define __CARL9170_H
0041 
0042 #include <linux/kernel.h>
0043 #include <linux/firmware.h>
0044 #include <linux/completion.h>
0045 #include <linux/spinlock.h>
0046 #include <linux/hw_random.h>
0047 #include <net/cfg80211.h>
0048 #include <net/mac80211.h>
0049 #include <linux/usb.h>
0050 #ifdef CONFIG_CARL9170_LEDS
0051 #include <linux/leds.h>
0052 #endif /* CONFIG_CARL9170_LEDS */
0053 #ifdef CONFIG_CARL9170_WPC
0054 #include <linux/input.h>
0055 #endif /* CONFIG_CARL9170_WPC */
0056 #include "eeprom.h"
0057 #include "wlan.h"
0058 #include "hw.h"
0059 #include "fwdesc.h"
0060 #include "fwcmd.h"
0061 #include "../regd.h"
0062 
0063 #ifdef CONFIG_CARL9170_DEBUGFS
0064 #include "debug.h"
0065 #endif /* CONFIG_CARL9170_DEBUGFS */
0066 
0067 #define CARL9170FW_NAME "carl9170-1.fw"
0068 
0069 #define PAYLOAD_MAX (CARL9170_MAX_CMD_LEN / 4 - 1)
0070 
0071 static inline u8 ar9170_qmap(u8 idx)
0072 {
0073     return 3 - idx; /* { 3, 2, 1, 0 } */
0074 }
0075 
0076 #define CARL9170_MAX_RX_BUFFER_SIZE     8192
0077 
0078 enum carl9170_device_state {
0079     CARL9170_UNKNOWN_STATE,
0080     CARL9170_STOPPED,
0081     CARL9170_IDLE,
0082     CARL9170_STARTED,
0083 };
0084 
0085 #define WME_BA_BMP_SIZE         64
0086 #define CARL9170_TX_USER_RATE_TRIES 3
0087 
0088 #define TID_TO_WME_AC(_tid)             \
0089     ((((_tid) == 0) || ((_tid) == 3)) ? IEEE80211_AC_BE :   \
0090      (((_tid) == 1) || ((_tid) == 2)) ? IEEE80211_AC_BK :   \
0091      (((_tid) == 4) || ((_tid) == 5)) ? IEEE80211_AC_VI :   \
0092      IEEE80211_AC_VO)
0093 
0094 #define SEQ_DIFF(_start, _seq) \
0095     (((_start) - (_seq)) & 0x0fff)
0096 #define SEQ_PREV(_seq) \
0097     (((_seq) - 1) & 0x0fff)
0098 #define SEQ_NEXT(_seq) \
0099     (((_seq) + 1) & 0x0fff)
0100 #define BAW_WITHIN(_start, _bawsz, _seqno) \
0101     ((((_seqno) - (_start)) & 0xfff) < (_bawsz))
0102 
0103 enum carl9170_tid_state {
0104     CARL9170_TID_STATE_INVALID,
0105     CARL9170_TID_STATE_KILLED,
0106     CARL9170_TID_STATE_SHUTDOWN,
0107     CARL9170_TID_STATE_SUSPEND,
0108     CARL9170_TID_STATE_PROGRESS,
0109     CARL9170_TID_STATE_IDLE,
0110     CARL9170_TID_STATE_XMIT,
0111 };
0112 
0113 #define CARL9170_BAW_BITS (2 * WME_BA_BMP_SIZE)
0114 #define CARL9170_BAW_SIZE (BITS_TO_LONGS(CARL9170_BAW_BITS))
0115 #define CARL9170_BAW_LEN (DIV_ROUND_UP(CARL9170_BAW_BITS, BITS_PER_BYTE))
0116 
0117 struct carl9170_sta_tid {
0118     /* must be the first entry! */
0119     struct list_head list;
0120 
0121     /* temporary list for RCU unlink procedure */
0122     struct list_head tmp_list;
0123 
0124     /* lock for the following data structures */
0125     spinlock_t lock;
0126 
0127     unsigned int counter;
0128     enum carl9170_tid_state state;
0129     u8 tid;     /* TID number ( 0 - 15 ) */
0130     u16 max;    /* max. AMPDU size */
0131 
0132     u16 snx;    /* awaiting _next_ frame */
0133     u16 hsn;    /* highest _queued_ sequence */
0134     u16 bsn;    /* base of the tx/agg bitmap */
0135     unsigned long bitmap[CARL9170_BAW_SIZE];
0136 
0137     /* Preaggregation reorder queue */
0138     struct sk_buff_head queue;
0139 
0140     struct ieee80211_sta *sta;
0141     struct ieee80211_vif *vif;
0142 };
0143 
0144 #define CARL9170_QUEUE_TIMEOUT      256
0145 #define CARL9170_BUMP_QUEUE     1000
0146 #define CARL9170_TX_TIMEOUT     2500
0147 #define CARL9170_JANITOR_DELAY      128
0148 #define CARL9170_QUEUE_STUCK_TIMEOUT    5500
0149 #define CARL9170_STAT_WORK      30000
0150 
0151 #define CARL9170_NUM_TX_AGG_MAX     30
0152 
0153 /*
0154  * Tradeoff between stability/latency and speed.
0155  *
0156  * AR9170_TXQ_DEPTH is devised by dividing the amount of available
0157  * tx buffers with the size of a full ethernet frame + overhead.
0158  *
0159  * Naturally: The higher the limit, the faster the device CAN send.
0160  * However, even a slight over-commitment at the wrong time and the
0161  * hardware is doomed to send all already-queued frames at suboptimal
0162  * rates. This in turn leads to an enormous amount of unsuccessful
0163  * retries => Latency goes up, whereas the throughput goes down. CRASH!
0164  */
0165 #define CARL9170_NUM_TX_LIMIT_HARD  ((AR9170_TXQ_DEPTH * 3) / 2)
0166 #define CARL9170_NUM_TX_LIMIT_SOFT  (AR9170_TXQ_DEPTH)
0167 
0168 struct carl9170_tx_queue_stats {
0169     unsigned int count;
0170     unsigned int limit;
0171     unsigned int len;
0172 };
0173 
0174 struct carl9170_vif {
0175     unsigned int id;
0176     struct ieee80211_vif __rcu *vif;
0177 };
0178 
0179 struct carl9170_vif_info {
0180     struct list_head list;
0181     bool active;
0182     unsigned int id;
0183     struct sk_buff *beacon;
0184     bool enable_beacon;
0185 };
0186 
0187 #define AR9170_NUM_RX_URBS  16
0188 #define AR9170_NUM_RX_URBS_MUL  2
0189 #define AR9170_NUM_TX_URBS  8
0190 #define AR9170_NUM_RX_URBS_POOL (AR9170_NUM_RX_URBS_MUL * AR9170_NUM_RX_URBS)
0191 
0192 enum carl9170_device_features {
0193     CARL9170_WPS_BUTTON     = BIT(0),
0194     CARL9170_ONE_LED        = BIT(1),
0195 };
0196 
0197 #ifdef CONFIG_CARL9170_LEDS
0198 struct ar9170;
0199 
0200 struct carl9170_led {
0201     struct ar9170 *ar;
0202     struct led_classdev l;
0203     char name[32];
0204     unsigned int toggled;
0205     bool last_state;
0206     bool registered;
0207 };
0208 #endif /* CONFIG_CARL9170_LEDS */
0209 
0210 enum carl9170_restart_reasons {
0211     CARL9170_RR_NO_REASON = 0,
0212     CARL9170_RR_FATAL_FIRMWARE_ERROR,
0213     CARL9170_RR_TOO_MANY_FIRMWARE_ERRORS,
0214     CARL9170_RR_WATCHDOG,
0215     CARL9170_RR_STUCK_TX,
0216     CARL9170_RR_UNRESPONSIVE_DEVICE,
0217     CARL9170_RR_COMMAND_TIMEOUT,
0218     CARL9170_RR_TOO_MANY_PHY_ERRORS,
0219     CARL9170_RR_LOST_RSP,
0220     CARL9170_RR_INVALID_RSP,
0221     CARL9170_RR_USER_REQUEST,
0222 
0223     __CARL9170_RR_LAST,
0224 };
0225 
0226 enum carl9170_erp_modes {
0227     CARL9170_ERP_INVALID,
0228     CARL9170_ERP_AUTO,
0229     CARL9170_ERP_MAC80211,
0230     CARL9170_ERP_OFF,
0231     CARL9170_ERP_CTS,
0232     CARL9170_ERP_RTS,
0233     __CARL9170_ERP_NUM,
0234 };
0235 
0236 struct ar9170 {
0237     struct ath_common common;
0238     struct ieee80211_hw *hw;
0239     struct mutex mutex;
0240     enum carl9170_device_state state;
0241     spinlock_t state_lock;
0242     enum carl9170_restart_reasons last_reason;
0243     bool registered;
0244 
0245     /* USB */
0246     struct usb_device *udev;
0247     struct usb_interface *intf;
0248     struct usb_anchor rx_anch;
0249     struct usb_anchor rx_work;
0250     struct usb_anchor rx_pool;
0251     struct usb_anchor tx_wait;
0252     struct usb_anchor tx_anch;
0253     struct usb_anchor tx_cmd;
0254     struct usb_anchor tx_err;
0255     struct tasklet_struct usb_tasklet;
0256     atomic_t tx_cmd_urbs;
0257     atomic_t tx_anch_urbs;
0258     atomic_t rx_anch_urbs;
0259     atomic_t rx_work_urbs;
0260     atomic_t rx_pool_urbs;
0261     kernel_ulong_t features;
0262     bool usb_ep_cmd_is_bulk;
0263 
0264     /* firmware settings */
0265     struct completion fw_load_wait;
0266     struct completion fw_boot_wait;
0267     struct {
0268         const struct carl9170fw_desc_head *desc;
0269         const struct firmware *fw;
0270         unsigned int offset;
0271         unsigned int address;
0272         unsigned int cmd_bufs;
0273         unsigned int api_version;
0274         unsigned int vif_num;
0275         unsigned int err_counter;
0276         unsigned int bug_counter;
0277         u32 beacon_addr;
0278         unsigned int beacon_max_len;
0279         bool rx_stream;
0280         bool tx_stream;
0281         bool rx_filter;
0282         bool hw_counters;
0283         unsigned int mem_blocks;
0284         unsigned int mem_block_size;
0285         unsigned int rx_size;
0286         unsigned int tx_seq_table;
0287         bool ba_filter;
0288         bool disable_offload_fw;
0289     } fw;
0290 
0291     /* interface configuration combinations */
0292     struct ieee80211_iface_limit if_comb_limits[1];
0293     struct ieee80211_iface_combination if_combs[1];
0294 
0295     /* reset / stuck frames/queue detection */
0296     struct work_struct restart_work;
0297     struct work_struct ping_work;
0298     unsigned int restart_counter;
0299     unsigned long queue_stop_timeout[__AR9170_NUM_TXQ];
0300     unsigned long max_queue_stop_timeout[__AR9170_NUM_TXQ];
0301     bool needs_full_reset;
0302     bool force_usb_reset;
0303     atomic_t pending_restarts;
0304 
0305     /* interface mode settings */
0306     struct list_head vif_list;
0307     unsigned long vif_bitmap;
0308     unsigned int vifs;
0309     struct carl9170_vif vif_priv[AR9170_MAX_VIRTUAL_MAC];
0310 
0311     /* beaconing */
0312     spinlock_t beacon_lock;
0313     unsigned int global_pretbtt;
0314     unsigned int global_beacon_int;
0315     struct carl9170_vif_info __rcu *beacon_iter;
0316     unsigned int beacon_enabled;
0317 
0318     /* cryptographic engine */
0319     u64 usedkeys;
0320     bool rx_software_decryption;
0321     bool disable_offload;
0322 
0323     /* filter settings */
0324     u64 cur_mc_hash;
0325     u32 cur_filter;
0326     unsigned int filter_state;
0327     unsigned int rx_filter_caps;
0328     bool sniffer_enabled;
0329 
0330     /* MAC */
0331     enum carl9170_erp_modes erp_mode;
0332 
0333     /* PHY */
0334     struct ieee80211_channel *channel;
0335     unsigned int num_channels;
0336     int noise[4];
0337     unsigned int chan_fail;
0338     unsigned int total_chan_fail;
0339     u8 heavy_clip;
0340     u8 ht_settings;
0341     struct {
0342         u64 active; /* usec */
0343         u64 cca;    /* usec */
0344         u64 tx_time;    /* usec */
0345         u64 rx_total;
0346         u64 rx_overrun;
0347     } tally;
0348     struct delayed_work stat_work;
0349     struct survey_info *survey;
0350 
0351     /* power calibration data */
0352     u8 power_5G_leg[4];
0353     u8 power_2G_cck[4];
0354     u8 power_2G_ofdm[4];
0355     u8 power_5G_ht20[8];
0356     u8 power_5G_ht40[8];
0357     u8 power_2G_ht20[8];
0358     u8 power_2G_ht40[8];
0359 
0360 #ifdef CONFIG_CARL9170_LEDS
0361     /* LED */
0362     struct delayed_work led_work;
0363     struct carl9170_led leds[AR9170_NUM_LEDS];
0364 #endif /* CONFIG_CARL9170_LEDS */
0365 
0366     /* qos queue settings */
0367     spinlock_t tx_stats_lock;
0368     struct carl9170_tx_queue_stats tx_stats[__AR9170_NUM_TXQ];
0369     struct ieee80211_tx_queue_params edcf[5];
0370     struct completion tx_flush;
0371 
0372     /* CMD */
0373     int cmd_seq;
0374     int readlen;
0375     u8 *readbuf;
0376     spinlock_t cmd_lock;
0377     struct completion cmd_wait;
0378     union {
0379         __le32 cmd_buf[PAYLOAD_MAX + 1];
0380         struct carl9170_cmd cmd;
0381         struct carl9170_rsp rsp;
0382     };
0383 
0384     /* statistics */
0385     unsigned int tx_dropped;
0386     unsigned int tx_ack_failures;
0387     unsigned int tx_fcs_errors;
0388     unsigned int rx_dropped;
0389 
0390     /* EEPROM */
0391     struct ar9170_eeprom eeprom;
0392 
0393     /* tx queuing */
0394     struct sk_buff_head tx_pending[__AR9170_NUM_TXQ];
0395     struct sk_buff_head tx_status[__AR9170_NUM_TXQ];
0396     struct delayed_work tx_janitor;
0397     unsigned long tx_janitor_last_run;
0398     bool tx_schedule;
0399 
0400     /* tx ampdu */
0401     struct work_struct ampdu_work;
0402     spinlock_t tx_ampdu_list_lock;
0403     struct carl9170_sta_tid __rcu *tx_ampdu_iter;
0404     struct list_head tx_ampdu_list;
0405     atomic_t tx_ampdu_upload;
0406     atomic_t tx_ampdu_scheduler;
0407     atomic_t tx_total_pending;
0408     atomic_t tx_total_queued;
0409     unsigned int tx_ampdu_list_len;
0410     int current_density;
0411     int current_factor;
0412     bool tx_ampdu_schedule;
0413 
0414     /* internal memory management */
0415     spinlock_t mem_lock;
0416     unsigned long *mem_bitmap;
0417     atomic_t mem_free_blocks;
0418     atomic_t mem_allocs;
0419 
0420     /* rxstream mpdu merge */
0421     struct ar9170_rx_head rx_plcp;
0422     bool rx_has_plcp;
0423     struct sk_buff *rx_failover;
0424     int rx_failover_missing;
0425     u32 ampdu_ref;
0426 
0427     /* FIFO for collecting outstanding BlockAckRequest */
0428     struct list_head bar_list[__AR9170_NUM_TXQ];
0429     spinlock_t bar_list_lock[__AR9170_NUM_TXQ];
0430 
0431 #ifdef CONFIG_CARL9170_WPC
0432     struct {
0433         bool pbc_state;
0434         struct input_dev *pbc;
0435         char name[32];
0436         char phys[32];
0437     } wps;
0438 #endif /* CONFIG_CARL9170_WPC */
0439 
0440 #ifdef CONFIG_CARL9170_DEBUGFS
0441     struct carl9170_debug debug;
0442     struct dentry *debug_dir;
0443 #endif /* CONFIG_CARL9170_DEBUGFS */
0444 
0445     /* PSM */
0446     struct work_struct ps_work;
0447     struct {
0448         unsigned int dtim_counter;
0449         unsigned long last_beacon;
0450         unsigned long last_action;
0451         unsigned long last_slept;
0452         unsigned int sleep_ms;
0453         unsigned int off_override;
0454         bool state;
0455     } ps;
0456 
0457 #ifdef CONFIG_CARL9170_HWRNG
0458 # define CARL9170_HWRNG_CACHE_SIZE  CARL9170_MAX_CMD_PAYLOAD_LEN
0459     struct {
0460         struct hwrng rng;
0461         char name[30 + 1];
0462         u16 cache[CARL9170_HWRNG_CACHE_SIZE / sizeof(u16)];
0463         unsigned int cache_idx;
0464     } rng;
0465 #endif /* CONFIG_CARL9170_HWRNG */
0466 };
0467 
0468 enum carl9170_ps_off_override_reasons {
0469     PS_OFF_VIF  = BIT(0),
0470     PS_OFF_BCN  = BIT(1),
0471 };
0472 
0473 struct carl9170_bar_list_entry {
0474     struct list_head list;
0475     struct rcu_head head;
0476     struct sk_buff *skb;
0477 };
0478 
0479 struct carl9170_ba_stats {
0480     u8 ampdu_len;
0481     u8 ampdu_ack_len;
0482     bool clear;
0483     bool req;
0484 };
0485 
0486 struct carl9170_sta_info {
0487     bool ht_sta;
0488     bool sleeping;
0489     atomic_t pending_frames;
0490     unsigned int ampdu_max_len;
0491     struct carl9170_sta_tid __rcu *agg[IEEE80211_NUM_TIDS];
0492     struct carl9170_ba_stats stats[IEEE80211_NUM_TIDS];
0493 };
0494 
0495 struct carl9170_tx_info {
0496     unsigned long timeout;
0497     struct ar9170 *ar;
0498     struct kref ref;
0499 };
0500 
0501 #define CHK_DEV_STATE(a, s) (((struct ar9170 *)a)->state >= (s))
0502 #define IS_INITIALIZED(a)   (CHK_DEV_STATE(a, CARL9170_STOPPED))
0503 #define IS_ACCEPTING_CMD(a) (CHK_DEV_STATE(a, CARL9170_IDLE))
0504 #define IS_STARTED(a)       (CHK_DEV_STATE(a, CARL9170_STARTED))
0505 
0506 static inline void __carl9170_set_state(struct ar9170 *ar,
0507     enum carl9170_device_state newstate)
0508 {
0509     ar->state = newstate;
0510 }
0511 
0512 static inline void carl9170_set_state(struct ar9170 *ar,
0513     enum carl9170_device_state newstate)
0514 {
0515     unsigned long flags;
0516 
0517     spin_lock_irqsave(&ar->state_lock, flags);
0518     __carl9170_set_state(ar, newstate);
0519     spin_unlock_irqrestore(&ar->state_lock, flags);
0520 }
0521 
0522 static inline void carl9170_set_state_when(struct ar9170 *ar,
0523     enum carl9170_device_state min, enum carl9170_device_state newstate)
0524 {
0525     unsigned long flags;
0526 
0527     spin_lock_irqsave(&ar->state_lock, flags);
0528     if (CHK_DEV_STATE(ar, min))
0529         __carl9170_set_state(ar, newstate);
0530     spin_unlock_irqrestore(&ar->state_lock, flags);
0531 }
0532 
0533 /* exported interface */
0534 void *carl9170_alloc(size_t priv_size);
0535 int carl9170_register(struct ar9170 *ar);
0536 void carl9170_unregister(struct ar9170 *ar);
0537 void carl9170_free(struct ar9170 *ar);
0538 void carl9170_restart(struct ar9170 *ar, const enum carl9170_restart_reasons r);
0539 void carl9170_ps_check(struct ar9170 *ar);
0540 
0541 /* USB back-end */
0542 int carl9170_usb_open(struct ar9170 *ar);
0543 void carl9170_usb_stop(struct ar9170 *ar);
0544 void carl9170_usb_tx(struct ar9170 *ar, struct sk_buff *skb);
0545 void carl9170_usb_handle_tx_err(struct ar9170 *ar);
0546 int carl9170_exec_cmd(struct ar9170 *ar, const enum carl9170_cmd_oids,
0547               u32 plen, void *payload, u32 rlen, void *resp);
0548 int __carl9170_exec_cmd(struct ar9170 *ar, struct carl9170_cmd *cmd,
0549             const bool free_buf);
0550 int carl9170_usb_restart(struct ar9170 *ar);
0551 void carl9170_usb_reset(struct ar9170 *ar);
0552 
0553 /* MAC */
0554 int carl9170_init_mac(struct ar9170 *ar);
0555 int carl9170_set_qos(struct ar9170 *ar);
0556 int carl9170_update_multicast(struct ar9170 *ar, const u64 mc_hast);
0557 int carl9170_mod_virtual_mac(struct ar9170 *ar, const unsigned int id,
0558                  const u8 *mac);
0559 int carl9170_set_operating_mode(struct ar9170 *ar);
0560 int carl9170_set_beacon_timers(struct ar9170 *ar);
0561 int carl9170_set_dyn_sifs_ack(struct ar9170 *ar);
0562 int carl9170_set_rts_cts_rate(struct ar9170 *ar);
0563 int carl9170_set_ampdu_settings(struct ar9170 *ar);
0564 int carl9170_set_slot_time(struct ar9170 *ar);
0565 int carl9170_set_mac_rates(struct ar9170 *ar);
0566 int carl9170_set_hwretry_limit(struct ar9170 *ar, const u32 max_retry);
0567 int carl9170_upload_key(struct ar9170 *ar, const u8 id, const u8 *mac,
0568     const u8 ktype, const u8 keyidx, const u8 *keydata, const int keylen);
0569 int carl9170_disable_key(struct ar9170 *ar, const u8 id);
0570 int carl9170_set_mac_tpc(struct ar9170 *ar, struct ieee80211_channel *channel);
0571 
0572 /* RX */
0573 void carl9170_rx(struct ar9170 *ar, void *buf, unsigned int len);
0574 void carl9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len);
0575 
0576 /* TX */
0577 void carl9170_op_tx(struct ieee80211_hw *hw,
0578             struct ieee80211_tx_control *control,
0579             struct sk_buff *skb);
0580 void carl9170_tx_janitor(struct work_struct *work);
0581 void carl9170_tx_process_status(struct ar9170 *ar,
0582                 const struct carl9170_rsp *cmd);
0583 void carl9170_tx_status(struct ar9170 *ar, struct sk_buff *skb,
0584             const bool success);
0585 void carl9170_tx_callback(struct ar9170 *ar, struct sk_buff *skb);
0586 void carl9170_tx_drop(struct ar9170 *ar, struct sk_buff *skb);
0587 void carl9170_tx_scheduler(struct ar9170 *ar);
0588 void carl9170_tx_get_skb(struct sk_buff *skb);
0589 int carl9170_tx_put_skb(struct sk_buff *skb);
0590 int carl9170_update_beacon(struct ar9170 *ar, const bool submit);
0591 
0592 /* LEDs */
0593 #ifdef CONFIG_CARL9170_LEDS
0594 int carl9170_led_register(struct ar9170 *ar);
0595 void carl9170_led_unregister(struct ar9170 *ar);
0596 #endif /* CONFIG_CARL9170_LEDS */
0597 int carl9170_led_init(struct ar9170 *ar);
0598 int carl9170_led_set_state(struct ar9170 *ar, const u32 led_state);
0599 
0600 /* PHY / RF */
0601 int carl9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel,
0602              enum nl80211_channel_type bw);
0603 int carl9170_get_noisefloor(struct ar9170 *ar);
0604 
0605 /* FW */
0606 int carl9170_parse_firmware(struct ar9170 *ar);
0607 
0608 extern struct ieee80211_rate __carl9170_ratetable[];
0609 extern int modparam_noht;
0610 
0611 static inline struct ar9170 *carl9170_get_priv(struct carl9170_vif *carl_vif)
0612 {
0613     return container_of(carl_vif, struct ar9170,
0614                 vif_priv[carl_vif->id]);
0615 }
0616 
0617 static inline struct ieee80211_hdr *carl9170_get_hdr(struct sk_buff *skb)
0618 {
0619     return (void *)((struct _carl9170_tx_superframe *)
0620         skb->data)->frame_data;
0621 }
0622 
0623 static inline u16 get_seq_h(struct ieee80211_hdr *hdr)
0624 {
0625     return le16_to_cpu(hdr->seq_ctrl) >> 4;
0626 }
0627 
0628 static inline u16 carl9170_get_seq(struct sk_buff *skb)
0629 {
0630     return get_seq_h(carl9170_get_hdr(skb));
0631 }
0632 
0633 static inline u16 carl9170_get_tid(struct sk_buff *skb)
0634 {
0635     return ieee80211_get_tid(carl9170_get_hdr(skb));
0636 }
0637 
0638 static inline struct ieee80211_vif *
0639 carl9170_get_vif(struct carl9170_vif_info *priv)
0640 {
0641     return container_of((void *)priv, struct ieee80211_vif, drv_priv);
0642 }
0643 
0644 /* Protected by ar->mutex or RCU */
0645 static inline struct ieee80211_vif *carl9170_get_main_vif(struct ar9170 *ar)
0646 {
0647     struct carl9170_vif_info *cvif;
0648 
0649     list_for_each_entry_rcu(cvif, &ar->vif_list, list) {
0650         if (cvif->active)
0651             return carl9170_get_vif(cvif);
0652     }
0653 
0654     return NULL;
0655 }
0656 
0657 static inline bool is_main_vif(struct ar9170 *ar, struct ieee80211_vif *vif)
0658 {
0659     bool ret;
0660 
0661     rcu_read_lock();
0662     ret = (carl9170_get_main_vif(ar) == vif);
0663     rcu_read_unlock();
0664     return ret;
0665 }
0666 
0667 #endif /* __CARL9170_H */