carl9170.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. /*
  2. * Atheros CARL9170 driver
  3. *
  4. * Driver specific definitions
  5. *
  6. * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
  7. * Copyright 2009, 2010, Christian Lamparter <chunkeey@googlemail.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; see the file COPYING. If not, see
  21. * http://www.gnu.org/licenses/.
  22. *
  23. * This file incorporates work covered by the following copyright and
  24. * permission notice:
  25. * Copyright (c) 2007-2008 Atheros Communications, Inc.
  26. *
  27. * Permission to use, copy, modify, and/or distribute this software for any
  28. * purpose with or without fee is hereby granted, provided that the above
  29. * copyright notice and this permission notice appear in all copies.
  30. *
  31. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  32. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  33. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  34. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  35. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  36. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  37. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  38. */
  39. #ifndef __CARL9170_H
  40. #define __CARL9170_H
  41. #include <linux/kernel.h>
  42. #include <linux/firmware.h>
  43. #include <linux/completion.h>
  44. #include <linux/spinlock.h>
  45. #include <linux/hw_random.h>
  46. #include <net/cfg80211.h>
  47. #include <net/mac80211.h>
  48. #include <linux/usb.h>
  49. #ifdef CONFIG_CARL9170_LEDS
  50. #include <linux/leds.h>
  51. #endif /* CONFIG_CARL9170_LEDS */
  52. #ifdef CONFIG_CARL9170_WPC
  53. #include <linux/input.h>
  54. #endif /* CONFIG_CARL9170_WPC */
  55. #include "eeprom.h"
  56. #include "wlan.h"
  57. #include "hw.h"
  58. #include "fwdesc.h"
  59. #include "fwcmd.h"
  60. #include "../regd.h"
  61. #ifdef CONFIG_CARL9170_DEBUGFS
  62. #include "debug.h"
  63. #endif /* CONFIG_CARL9170_DEBUGFS */
  64. #define CARL9170FW_NAME "carl9170-1.fw"
  65. #define PAYLOAD_MAX (CARL9170_MAX_CMD_LEN / 4 - 1)
  66. static const u8 ar9170_qmap[__AR9170_NUM_TXQ] = { 3, 2, 1, 0 };
  67. enum carl9170_rf_init_mode {
  68. CARL9170_RFI_NONE,
  69. CARL9170_RFI_WARM,
  70. CARL9170_RFI_COLD,
  71. };
  72. #define CARL9170_MAX_RX_BUFFER_SIZE 8192
  73. enum carl9170_device_state {
  74. CARL9170_UNKNOWN_STATE,
  75. CARL9170_STOPPED,
  76. CARL9170_IDLE,
  77. CARL9170_STARTED,
  78. };
  79. #define CARL9170_NUM_TID 16
  80. #define WME_BA_BMP_SIZE 64
  81. #define CARL9170_TX_USER_RATE_TRIES 3
  82. #define WME_AC_BE 2
  83. #define WME_AC_BK 3
  84. #define WME_AC_VI 1
  85. #define WME_AC_VO 0
  86. #define TID_TO_WME_AC(_tid) \
  87. ((((_tid) == 0) || ((_tid) == 3)) ? WME_AC_BE : \
  88. (((_tid) == 1) || ((_tid) == 2)) ? WME_AC_BK : \
  89. (((_tid) == 4) || ((_tid) == 5)) ? WME_AC_VI : \
  90. WME_AC_VO)
  91. #define SEQ_DIFF(_start, _seq) \
  92. (((_start) - (_seq)) & 0x0fff)
  93. #define SEQ_PREV(_seq) \
  94. (((_seq) - 1) & 0x0fff)
  95. #define SEQ_NEXT(_seq) \
  96. (((_seq) + 1) & 0x0fff)
  97. #define BAW_WITHIN(_start, _bawsz, _seqno) \
  98. ((((_seqno) - (_start)) & 0xfff) < (_bawsz))
  99. enum carl9170_tid_state {
  100. CARL9170_TID_STATE_INVALID,
  101. CARL9170_TID_STATE_KILLED,
  102. CARL9170_TID_STATE_SHUTDOWN,
  103. CARL9170_TID_STATE_SUSPEND,
  104. CARL9170_TID_STATE_PROGRESS,
  105. CARL9170_TID_STATE_IDLE,
  106. CARL9170_TID_STATE_XMIT,
  107. };
  108. #define CARL9170_BAW_BITS (2 * WME_BA_BMP_SIZE)
  109. #define CARL9170_BAW_SIZE (BITS_TO_LONGS(CARL9170_BAW_BITS))
  110. #define CARL9170_BAW_LEN (DIV_ROUND_UP(CARL9170_BAW_BITS, BITS_PER_BYTE))
  111. struct carl9170_sta_tid {
  112. /* must be the first entry! */
  113. struct list_head list;
  114. /* temporary list for RCU unlink procedure */
  115. struct list_head tmp_list;
  116. /* lock for the following data structures */
  117. spinlock_t lock;
  118. unsigned int counter;
  119. enum carl9170_tid_state state;
  120. u8 tid; /* TID number ( 0 - 15 ) */
  121. u16 max; /* max. AMPDU size */
  122. u16 snx; /* awaiting _next_ frame */
  123. u16 hsn; /* highest _queued_ sequence */
  124. u16 bsn; /* base of the tx/agg bitmap */
  125. unsigned long bitmap[CARL9170_BAW_SIZE];
  126. /* Preaggregation reorder queue */
  127. struct sk_buff_head queue;
  128. };
  129. #define CARL9170_QUEUE_TIMEOUT 256
  130. #define CARL9170_BUMP_QUEUE 1000
  131. #define CARL9170_TX_TIMEOUT 2500
  132. #define CARL9170_JANITOR_DELAY 128
  133. #define CARL9170_QUEUE_STUCK_TIMEOUT 5500
  134. #define CARL9170_STAT_WORK 30000
  135. #define CARL9170_NUM_TX_AGG_MAX 30
  136. /*
  137. * Tradeoff between stability/latency and speed.
  138. *
  139. * AR9170_TXQ_DEPTH is devised by dividing the amount of available
  140. * tx buffers with the size of a full ethernet frame + overhead.
  141. *
  142. * Naturally: The higher the limit, the faster the device CAN send.
  143. * However, even a slight over-commitment at the wrong time and the
  144. * hardware is doomed to send all already-queued frames at suboptimal
  145. * rates. This in turn leads to an enormous amount of unsuccessful
  146. * retries => Latency goes up, whereas the throughput goes down. CRASH!
  147. */
  148. #define CARL9170_NUM_TX_LIMIT_HARD ((AR9170_TXQ_DEPTH * 3) / 2)
  149. #define CARL9170_NUM_TX_LIMIT_SOFT (AR9170_TXQ_DEPTH)
  150. struct carl9170_tx_queue_stats {
  151. unsigned int count;
  152. unsigned int limit;
  153. unsigned int len;
  154. };
  155. struct carl9170_vif {
  156. unsigned int id;
  157. struct ieee80211_vif __rcu *vif;
  158. };
  159. struct carl9170_vif_info {
  160. struct list_head list;
  161. bool active;
  162. unsigned int id;
  163. struct sk_buff *beacon;
  164. bool enable_beacon;
  165. };
  166. #define AR9170_NUM_RX_URBS 16
  167. #define AR9170_NUM_RX_URBS_MUL 2
  168. #define AR9170_NUM_TX_URBS 8
  169. #define AR9170_NUM_RX_URBS_POOL (AR9170_NUM_RX_URBS_MUL * AR9170_NUM_RX_URBS)
  170. enum carl9170_device_features {
  171. CARL9170_WPS_BUTTON = BIT(0),
  172. CARL9170_ONE_LED = BIT(1),
  173. };
  174. #ifdef CONFIG_CARL9170_LEDS
  175. struct ar9170;
  176. struct carl9170_led {
  177. struct ar9170 *ar;
  178. struct led_classdev l;
  179. char name[32];
  180. unsigned int toggled;
  181. bool last_state;
  182. bool registered;
  183. };
  184. #endif /* CONFIG_CARL9170_LEDS */
  185. enum carl9170_restart_reasons {
  186. CARL9170_RR_NO_REASON = 0,
  187. CARL9170_RR_FATAL_FIRMWARE_ERROR,
  188. CARL9170_RR_TOO_MANY_FIRMWARE_ERRORS,
  189. CARL9170_RR_WATCHDOG,
  190. CARL9170_RR_STUCK_TX,
  191. CARL9170_RR_UNRESPONSIVE_DEVICE,
  192. CARL9170_RR_COMMAND_TIMEOUT,
  193. CARL9170_RR_TOO_MANY_PHY_ERRORS,
  194. CARL9170_RR_LOST_RSP,
  195. CARL9170_RR_INVALID_RSP,
  196. CARL9170_RR_USER_REQUEST,
  197. __CARL9170_RR_LAST,
  198. };
  199. enum carl9170_erp_modes {
  200. CARL9170_ERP_INVALID,
  201. CARL9170_ERP_AUTO,
  202. CARL9170_ERP_MAC80211,
  203. CARL9170_ERP_OFF,
  204. CARL9170_ERP_CTS,
  205. CARL9170_ERP_RTS,
  206. __CARL9170_ERP_NUM,
  207. };
  208. struct ar9170 {
  209. struct ath_common common;
  210. struct ieee80211_hw *hw;
  211. struct mutex mutex;
  212. enum carl9170_device_state state;
  213. spinlock_t state_lock;
  214. enum carl9170_restart_reasons last_reason;
  215. bool registered;
  216. /* USB */
  217. struct usb_device *udev;
  218. struct usb_interface *intf;
  219. struct usb_anchor rx_anch;
  220. struct usb_anchor rx_work;
  221. struct usb_anchor rx_pool;
  222. struct usb_anchor tx_wait;
  223. struct usb_anchor tx_anch;
  224. struct usb_anchor tx_cmd;
  225. struct usb_anchor tx_err;
  226. struct tasklet_struct usb_tasklet;
  227. atomic_t tx_cmd_urbs;
  228. atomic_t tx_anch_urbs;
  229. atomic_t rx_anch_urbs;
  230. atomic_t rx_work_urbs;
  231. atomic_t rx_pool_urbs;
  232. kernel_ulong_t features;
  233. /* firmware settings */
  234. struct completion fw_load_wait;
  235. struct completion fw_boot_wait;
  236. struct {
  237. const struct carl9170fw_desc_head *desc;
  238. const struct firmware *fw;
  239. unsigned int offset;
  240. unsigned int address;
  241. unsigned int cmd_bufs;
  242. unsigned int api_version;
  243. unsigned int vif_num;
  244. unsigned int err_counter;
  245. unsigned int bug_counter;
  246. u32 beacon_addr;
  247. unsigned int beacon_max_len;
  248. bool rx_stream;
  249. bool tx_stream;
  250. bool rx_filter;
  251. bool hw_counters;
  252. unsigned int mem_blocks;
  253. unsigned int mem_block_size;
  254. unsigned int rx_size;
  255. unsigned int tx_seq_table;
  256. } fw;
  257. /* interface configuration combinations */
  258. struct ieee80211_iface_limit if_comb_limits[1];
  259. struct ieee80211_iface_combination if_combs[1];
  260. /* reset / stuck frames/queue detection */
  261. struct work_struct restart_work;
  262. struct work_struct ping_work;
  263. unsigned int restart_counter;
  264. unsigned long queue_stop_timeout[__AR9170_NUM_TXQ];
  265. unsigned long max_queue_stop_timeout[__AR9170_NUM_TXQ];
  266. bool needs_full_reset;
  267. atomic_t pending_restarts;
  268. /* interface mode settings */
  269. struct list_head vif_list;
  270. unsigned long vif_bitmap;
  271. unsigned int vifs;
  272. struct carl9170_vif vif_priv[AR9170_MAX_VIRTUAL_MAC];
  273. /* beaconing */
  274. spinlock_t beacon_lock;
  275. unsigned int global_pretbtt;
  276. unsigned int global_beacon_int;
  277. struct carl9170_vif_info __rcu *beacon_iter;
  278. unsigned int beacon_enabled;
  279. /* cryptographic engine */
  280. u64 usedkeys;
  281. bool rx_software_decryption;
  282. bool disable_offload;
  283. /* filter settings */
  284. u64 cur_mc_hash;
  285. u32 cur_filter;
  286. unsigned int filter_state;
  287. unsigned int rx_filter_caps;
  288. bool sniffer_enabled;
  289. /* MAC */
  290. enum carl9170_erp_modes erp_mode;
  291. /* PHY */
  292. struct ieee80211_channel *channel;
  293. unsigned int num_channels;
  294. int noise[4];
  295. unsigned int chan_fail;
  296. unsigned int total_chan_fail;
  297. u8 heavy_clip;
  298. u8 ht_settings;
  299. struct {
  300. u64 active; /* usec */
  301. u64 cca; /* usec */
  302. u64 tx_time; /* usec */
  303. u64 rx_total;
  304. u64 rx_overrun;
  305. } tally;
  306. struct delayed_work stat_work;
  307. struct survey_info *survey;
  308. /* power calibration data */
  309. u8 power_5G_leg[4];
  310. u8 power_2G_cck[4];
  311. u8 power_2G_ofdm[4];
  312. u8 power_5G_ht20[8];
  313. u8 power_5G_ht40[8];
  314. u8 power_2G_ht20[8];
  315. u8 power_2G_ht40[8];
  316. #ifdef CONFIG_CARL9170_LEDS
  317. /* LED */
  318. struct delayed_work led_work;
  319. struct carl9170_led leds[AR9170_NUM_LEDS];
  320. #endif /* CONFIG_CARL9170_LEDS */
  321. /* qos queue settings */
  322. spinlock_t tx_stats_lock;
  323. struct carl9170_tx_queue_stats tx_stats[__AR9170_NUM_TXQ];
  324. struct ieee80211_tx_queue_params edcf[5];
  325. struct completion tx_flush;
  326. /* CMD */
  327. int cmd_seq;
  328. int readlen;
  329. u8 *readbuf;
  330. spinlock_t cmd_lock;
  331. struct completion cmd_wait;
  332. union {
  333. __le32 cmd_buf[PAYLOAD_MAX + 1];
  334. struct carl9170_cmd cmd;
  335. struct carl9170_rsp rsp;
  336. };
  337. /* statistics */
  338. unsigned int tx_dropped;
  339. unsigned int tx_ack_failures;
  340. unsigned int tx_fcs_errors;
  341. unsigned int rx_dropped;
  342. /* EEPROM */
  343. struct ar9170_eeprom eeprom;
  344. /* tx queuing */
  345. struct sk_buff_head tx_pending[__AR9170_NUM_TXQ];
  346. struct sk_buff_head tx_status[__AR9170_NUM_TXQ];
  347. struct delayed_work tx_janitor;
  348. unsigned long tx_janitor_last_run;
  349. bool tx_schedule;
  350. /* tx ampdu */
  351. struct work_struct ampdu_work;
  352. spinlock_t tx_ampdu_list_lock;
  353. struct carl9170_sta_tid __rcu *tx_ampdu_iter;
  354. struct list_head tx_ampdu_list;
  355. atomic_t tx_ampdu_upload;
  356. atomic_t tx_ampdu_scheduler;
  357. atomic_t tx_total_pending;
  358. atomic_t tx_total_queued;
  359. unsigned int tx_ampdu_list_len;
  360. int current_density;
  361. int current_factor;
  362. bool tx_ampdu_schedule;
  363. /* internal memory management */
  364. spinlock_t mem_lock;
  365. unsigned long *mem_bitmap;
  366. atomic_t mem_free_blocks;
  367. atomic_t mem_allocs;
  368. /* rxstream mpdu merge */
  369. struct ar9170_rx_head rx_plcp;
  370. bool rx_has_plcp;
  371. struct sk_buff *rx_failover;
  372. int rx_failover_missing;
  373. #ifdef CONFIG_CARL9170_WPC
  374. struct {
  375. bool pbc_state;
  376. struct input_dev *pbc;
  377. char name[32];
  378. char phys[32];
  379. } wps;
  380. #endif /* CONFIG_CARL9170_WPC */
  381. #ifdef CONFIG_CARL9170_DEBUGFS
  382. struct carl9170_debug debug;
  383. struct dentry *debug_dir;
  384. #endif /* CONFIG_CARL9170_DEBUGFS */
  385. /* PSM */
  386. struct work_struct ps_work;
  387. struct {
  388. unsigned int dtim_counter;
  389. unsigned long last_beacon;
  390. unsigned long last_action;
  391. unsigned long last_slept;
  392. unsigned int sleep_ms;
  393. unsigned int off_override;
  394. bool state;
  395. } ps;
  396. #ifdef CONFIG_CARL9170_HWRNG
  397. # define CARL9170_HWRNG_CACHE_SIZE CARL9170_MAX_CMD_PAYLOAD_LEN
  398. struct {
  399. struct hwrng rng;
  400. bool initialized;
  401. char name[30 + 1];
  402. u16 cache[CARL9170_HWRNG_CACHE_SIZE / sizeof(u16)];
  403. unsigned int cache_idx;
  404. } rng;
  405. #endif /* CONFIG_CARL9170_HWRNG */
  406. };
  407. enum carl9170_ps_off_override_reasons {
  408. PS_OFF_VIF = BIT(0),
  409. PS_OFF_BCN = BIT(1),
  410. };
  411. struct carl9170_ba_stats {
  412. u8 ampdu_len;
  413. u8 ampdu_ack_len;
  414. bool clear;
  415. bool req;
  416. };
  417. struct carl9170_sta_info {
  418. bool ht_sta;
  419. bool sleeping;
  420. atomic_t pending_frames;
  421. unsigned int ampdu_max_len;
  422. struct carl9170_sta_tid __rcu *agg[CARL9170_NUM_TID];
  423. struct carl9170_ba_stats stats[CARL9170_NUM_TID];
  424. };
  425. struct carl9170_tx_info {
  426. unsigned long timeout;
  427. struct ar9170 *ar;
  428. struct kref ref;
  429. };
  430. #define CHK_DEV_STATE(a, s) (((struct ar9170 *)a)->state >= (s))
  431. #define IS_INITIALIZED(a) (CHK_DEV_STATE(a, CARL9170_STOPPED))
  432. #define IS_ACCEPTING_CMD(a) (CHK_DEV_STATE(a, CARL9170_IDLE))
  433. #define IS_STARTED(a) (CHK_DEV_STATE(a, CARL9170_STARTED))
  434. static inline void __carl9170_set_state(struct ar9170 *ar,
  435. enum carl9170_device_state newstate)
  436. {
  437. ar->state = newstate;
  438. }
  439. static inline void carl9170_set_state(struct ar9170 *ar,
  440. enum carl9170_device_state newstate)
  441. {
  442. unsigned long flags;
  443. spin_lock_irqsave(&ar->state_lock, flags);
  444. __carl9170_set_state(ar, newstate);
  445. spin_unlock_irqrestore(&ar->state_lock, flags);
  446. }
  447. static inline void carl9170_set_state_when(struct ar9170 *ar,
  448. enum carl9170_device_state min, enum carl9170_device_state newstate)
  449. {
  450. unsigned long flags;
  451. spin_lock_irqsave(&ar->state_lock, flags);
  452. if (CHK_DEV_STATE(ar, min))
  453. __carl9170_set_state(ar, newstate);
  454. spin_unlock_irqrestore(&ar->state_lock, flags);
  455. }
  456. /* exported interface */
  457. void *carl9170_alloc(size_t priv_size);
  458. int carl9170_register(struct ar9170 *ar);
  459. void carl9170_unregister(struct ar9170 *ar);
  460. void carl9170_free(struct ar9170 *ar);
  461. void carl9170_restart(struct ar9170 *ar, const enum carl9170_restart_reasons r);
  462. void carl9170_ps_check(struct ar9170 *ar);
  463. /* USB back-end */
  464. int carl9170_usb_open(struct ar9170 *ar);
  465. void carl9170_usb_stop(struct ar9170 *ar);
  466. void carl9170_usb_tx(struct ar9170 *ar, struct sk_buff *skb);
  467. void carl9170_usb_handle_tx_err(struct ar9170 *ar);
  468. int carl9170_exec_cmd(struct ar9170 *ar, const enum carl9170_cmd_oids,
  469. u32 plen, void *payload, u32 rlen, void *resp);
  470. int __carl9170_exec_cmd(struct ar9170 *ar, struct carl9170_cmd *cmd,
  471. const bool free_buf);
  472. int carl9170_usb_restart(struct ar9170 *ar);
  473. void carl9170_usb_reset(struct ar9170 *ar);
  474. /* MAC */
  475. int carl9170_init_mac(struct ar9170 *ar);
  476. int carl9170_set_qos(struct ar9170 *ar);
  477. int carl9170_update_multicast(struct ar9170 *ar, const u64 mc_hast);
  478. int carl9170_mod_virtual_mac(struct ar9170 *ar, const unsigned int id,
  479. const u8 *mac);
  480. int carl9170_set_operating_mode(struct ar9170 *ar);
  481. int carl9170_set_beacon_timers(struct ar9170 *ar);
  482. int carl9170_set_dyn_sifs_ack(struct ar9170 *ar);
  483. int carl9170_set_rts_cts_rate(struct ar9170 *ar);
  484. int carl9170_set_ampdu_settings(struct ar9170 *ar);
  485. int carl9170_set_slot_time(struct ar9170 *ar);
  486. int carl9170_set_mac_rates(struct ar9170 *ar);
  487. int carl9170_set_hwretry_limit(struct ar9170 *ar, const u32 max_retry);
  488. int carl9170_upload_key(struct ar9170 *ar, const u8 id, const u8 *mac,
  489. const u8 ktype, const u8 keyidx, const u8 *keydata, const int keylen);
  490. int carl9170_disable_key(struct ar9170 *ar, const u8 id);
  491. /* RX */
  492. void carl9170_rx(struct ar9170 *ar, void *buf, unsigned int len);
  493. void carl9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len);
  494. /* TX */
  495. void carl9170_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
  496. void carl9170_tx_janitor(struct work_struct *work);
  497. void carl9170_tx_process_status(struct ar9170 *ar,
  498. const struct carl9170_rsp *cmd);
  499. void carl9170_tx_status(struct ar9170 *ar, struct sk_buff *skb,
  500. const bool success);
  501. void carl9170_tx_callback(struct ar9170 *ar, struct sk_buff *skb);
  502. void carl9170_tx_drop(struct ar9170 *ar, struct sk_buff *skb);
  503. void carl9170_tx_scheduler(struct ar9170 *ar);
  504. void carl9170_tx_get_skb(struct sk_buff *skb);
  505. int carl9170_tx_put_skb(struct sk_buff *skb);
  506. int carl9170_update_beacon(struct ar9170 *ar, const bool submit);
  507. /* LEDs */
  508. #ifdef CONFIG_CARL9170_LEDS
  509. int carl9170_led_register(struct ar9170 *ar);
  510. void carl9170_led_unregister(struct ar9170 *ar);
  511. #endif /* CONFIG_CARL9170_LEDS */
  512. int carl9170_led_init(struct ar9170 *ar);
  513. int carl9170_led_set_state(struct ar9170 *ar, const u32 led_state);
  514. /* PHY / RF */
  515. int carl9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel,
  516. enum nl80211_channel_type bw, enum carl9170_rf_init_mode rfi);
  517. int carl9170_get_noisefloor(struct ar9170 *ar);
  518. /* FW */
  519. int carl9170_parse_firmware(struct ar9170 *ar);
  520. int carl9170_fw_fix_eeprom(struct ar9170 *ar);
  521. extern struct ieee80211_rate __carl9170_ratetable[];
  522. extern int modparam_noht;
  523. static inline struct ar9170 *carl9170_get_priv(struct carl9170_vif *carl_vif)
  524. {
  525. return container_of(carl_vif, struct ar9170,
  526. vif_priv[carl_vif->id]);
  527. }
  528. static inline struct ieee80211_hdr *carl9170_get_hdr(struct sk_buff *skb)
  529. {
  530. return (void *)((struct _carl9170_tx_superframe *)
  531. skb->data)->frame_data;
  532. }
  533. static inline u16 get_seq_h(struct ieee80211_hdr *hdr)
  534. {
  535. return le16_to_cpu(hdr->seq_ctrl) >> 4;
  536. }
  537. static inline u16 carl9170_get_seq(struct sk_buff *skb)
  538. {
  539. return get_seq_h(carl9170_get_hdr(skb));
  540. }
  541. static inline u16 get_tid_h(struct ieee80211_hdr *hdr)
  542. {
  543. return (ieee80211_get_qos_ctl(hdr))[0] & IEEE80211_QOS_CTL_TID_MASK;
  544. }
  545. static inline u16 carl9170_get_tid(struct sk_buff *skb)
  546. {
  547. return get_tid_h(carl9170_get_hdr(skb));
  548. }
  549. static inline struct ieee80211_vif *
  550. carl9170_get_vif(struct carl9170_vif_info *priv)
  551. {
  552. return container_of((void *)priv, struct ieee80211_vif, drv_priv);
  553. }
  554. /* Protected by ar->mutex or RCU */
  555. static inline struct ieee80211_vif *carl9170_get_main_vif(struct ar9170 *ar)
  556. {
  557. struct carl9170_vif_info *cvif;
  558. list_for_each_entry_rcu(cvif, &ar->vif_list, list) {
  559. if (cvif->active)
  560. return carl9170_get_vif(cvif);
  561. }
  562. return NULL;
  563. }
  564. static inline bool is_main_vif(struct ar9170 *ar, struct ieee80211_vif *vif)
  565. {
  566. bool ret;
  567. rcu_read_lock();
  568. ret = (carl9170_get_main_vif(ar) == vif);
  569. rcu_read_unlock();
  570. return ret;
  571. }
  572. #endif /* __CARL9170_H */