carl9170.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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. bool ba_filter;
  257. } fw;
  258. /* interface configuration combinations */
  259. struct ieee80211_iface_limit if_comb_limits[1];
  260. struct ieee80211_iface_combination if_combs[1];
  261. /* reset / stuck frames/queue detection */
  262. struct work_struct restart_work;
  263. struct work_struct ping_work;
  264. unsigned int restart_counter;
  265. unsigned long queue_stop_timeout[__AR9170_NUM_TXQ];
  266. unsigned long max_queue_stop_timeout[__AR9170_NUM_TXQ];
  267. bool needs_full_reset;
  268. bool force_usb_reset;
  269. atomic_t pending_restarts;
  270. /* interface mode settings */
  271. struct list_head vif_list;
  272. unsigned long vif_bitmap;
  273. unsigned int vifs;
  274. struct carl9170_vif vif_priv[AR9170_MAX_VIRTUAL_MAC];
  275. /* beaconing */
  276. spinlock_t beacon_lock;
  277. unsigned int global_pretbtt;
  278. unsigned int global_beacon_int;
  279. struct carl9170_vif_info __rcu *beacon_iter;
  280. unsigned int beacon_enabled;
  281. /* cryptographic engine */
  282. u64 usedkeys;
  283. bool rx_software_decryption;
  284. bool disable_offload;
  285. /* filter settings */
  286. u64 cur_mc_hash;
  287. u32 cur_filter;
  288. unsigned int filter_state;
  289. unsigned int rx_filter_caps;
  290. bool sniffer_enabled;
  291. /* MAC */
  292. enum carl9170_erp_modes erp_mode;
  293. /* PHY */
  294. struct ieee80211_channel *channel;
  295. unsigned int num_channels;
  296. int noise[4];
  297. unsigned int chan_fail;
  298. unsigned int total_chan_fail;
  299. u8 heavy_clip;
  300. u8 ht_settings;
  301. struct {
  302. u64 active; /* usec */
  303. u64 cca; /* usec */
  304. u64 tx_time; /* usec */
  305. u64 rx_total;
  306. u64 rx_overrun;
  307. } tally;
  308. struct delayed_work stat_work;
  309. struct survey_info *survey;
  310. /* power calibration data */
  311. u8 power_5G_leg[4];
  312. u8 power_2G_cck[4];
  313. u8 power_2G_ofdm[4];
  314. u8 power_5G_ht20[8];
  315. u8 power_5G_ht40[8];
  316. u8 power_2G_ht20[8];
  317. u8 power_2G_ht40[8];
  318. #ifdef CONFIG_CARL9170_LEDS
  319. /* LED */
  320. struct delayed_work led_work;
  321. struct carl9170_led leds[AR9170_NUM_LEDS];
  322. #endif /* CONFIG_CARL9170_LEDS */
  323. /* qos queue settings */
  324. spinlock_t tx_stats_lock;
  325. struct carl9170_tx_queue_stats tx_stats[__AR9170_NUM_TXQ];
  326. struct ieee80211_tx_queue_params edcf[5];
  327. struct completion tx_flush;
  328. /* CMD */
  329. int cmd_seq;
  330. int readlen;
  331. u8 *readbuf;
  332. spinlock_t cmd_lock;
  333. struct completion cmd_wait;
  334. union {
  335. __le32 cmd_buf[PAYLOAD_MAX + 1];
  336. struct carl9170_cmd cmd;
  337. struct carl9170_rsp rsp;
  338. };
  339. /* statistics */
  340. unsigned int tx_dropped;
  341. unsigned int tx_ack_failures;
  342. unsigned int tx_fcs_errors;
  343. unsigned int rx_dropped;
  344. /* EEPROM */
  345. struct ar9170_eeprom eeprom;
  346. /* tx queuing */
  347. struct sk_buff_head tx_pending[__AR9170_NUM_TXQ];
  348. struct sk_buff_head tx_status[__AR9170_NUM_TXQ];
  349. struct delayed_work tx_janitor;
  350. unsigned long tx_janitor_last_run;
  351. bool tx_schedule;
  352. /* tx ampdu */
  353. struct work_struct ampdu_work;
  354. spinlock_t tx_ampdu_list_lock;
  355. struct carl9170_sta_tid __rcu *tx_ampdu_iter;
  356. struct list_head tx_ampdu_list;
  357. atomic_t tx_ampdu_upload;
  358. atomic_t tx_ampdu_scheduler;
  359. atomic_t tx_total_pending;
  360. atomic_t tx_total_queued;
  361. unsigned int tx_ampdu_list_len;
  362. int current_density;
  363. int current_factor;
  364. bool tx_ampdu_schedule;
  365. /* internal memory management */
  366. spinlock_t mem_lock;
  367. unsigned long *mem_bitmap;
  368. atomic_t mem_free_blocks;
  369. atomic_t mem_allocs;
  370. /* rxstream mpdu merge */
  371. struct ar9170_rx_head rx_plcp;
  372. bool rx_has_plcp;
  373. struct sk_buff *rx_failover;
  374. int rx_failover_missing;
  375. u32 ampdu_ref;
  376. /* FIFO for collecting outstanding BlockAckRequest */
  377. struct list_head bar_list[__AR9170_NUM_TXQ];
  378. spinlock_t bar_list_lock[__AR9170_NUM_TXQ];
  379. #ifdef CONFIG_CARL9170_WPC
  380. struct {
  381. bool pbc_state;
  382. struct input_dev *pbc;
  383. char name[32];
  384. char phys[32];
  385. } wps;
  386. #endif /* CONFIG_CARL9170_WPC */
  387. #ifdef CONFIG_CARL9170_DEBUGFS
  388. struct carl9170_debug debug;
  389. struct dentry *debug_dir;
  390. #endif /* CONFIG_CARL9170_DEBUGFS */
  391. /* PSM */
  392. struct work_struct ps_work;
  393. struct {
  394. unsigned int dtim_counter;
  395. unsigned long last_beacon;
  396. unsigned long last_action;
  397. unsigned long last_slept;
  398. unsigned int sleep_ms;
  399. unsigned int off_override;
  400. bool state;
  401. } ps;
  402. #ifdef CONFIG_CARL9170_HWRNG
  403. # define CARL9170_HWRNG_CACHE_SIZE CARL9170_MAX_CMD_PAYLOAD_LEN
  404. struct {
  405. struct hwrng rng;
  406. bool initialized;
  407. char name[30 + 1];
  408. u16 cache[CARL9170_HWRNG_CACHE_SIZE / sizeof(u16)];
  409. unsigned int cache_idx;
  410. } rng;
  411. #endif /* CONFIG_CARL9170_HWRNG */
  412. };
  413. enum carl9170_ps_off_override_reasons {
  414. PS_OFF_VIF = BIT(0),
  415. PS_OFF_BCN = BIT(1),
  416. };
  417. struct carl9170_bar_list_entry {
  418. struct list_head list;
  419. struct rcu_head head;
  420. struct sk_buff *skb;
  421. };
  422. struct carl9170_ba_stats {
  423. u8 ampdu_len;
  424. u8 ampdu_ack_len;
  425. bool clear;
  426. bool req;
  427. };
  428. struct carl9170_sta_info {
  429. bool ht_sta;
  430. bool sleeping;
  431. atomic_t pending_frames;
  432. unsigned int ampdu_max_len;
  433. struct carl9170_sta_tid __rcu *agg[CARL9170_NUM_TID];
  434. struct carl9170_ba_stats stats[CARL9170_NUM_TID];
  435. };
  436. struct carl9170_tx_info {
  437. unsigned long timeout;
  438. struct ar9170 *ar;
  439. struct kref ref;
  440. };
  441. #define CHK_DEV_STATE(a, s) (((struct ar9170 *)a)->state >= (s))
  442. #define IS_INITIALIZED(a) (CHK_DEV_STATE(a, CARL9170_STOPPED))
  443. #define IS_ACCEPTING_CMD(a) (CHK_DEV_STATE(a, CARL9170_IDLE))
  444. #define IS_STARTED(a) (CHK_DEV_STATE(a, CARL9170_STARTED))
  445. static inline void __carl9170_set_state(struct ar9170 *ar,
  446. enum carl9170_device_state newstate)
  447. {
  448. ar->state = newstate;
  449. }
  450. static inline void carl9170_set_state(struct ar9170 *ar,
  451. enum carl9170_device_state newstate)
  452. {
  453. unsigned long flags;
  454. spin_lock_irqsave(&ar->state_lock, flags);
  455. __carl9170_set_state(ar, newstate);
  456. spin_unlock_irqrestore(&ar->state_lock, flags);
  457. }
  458. static inline void carl9170_set_state_when(struct ar9170 *ar,
  459. enum carl9170_device_state min, enum carl9170_device_state newstate)
  460. {
  461. unsigned long flags;
  462. spin_lock_irqsave(&ar->state_lock, flags);
  463. if (CHK_DEV_STATE(ar, min))
  464. __carl9170_set_state(ar, newstate);
  465. spin_unlock_irqrestore(&ar->state_lock, flags);
  466. }
  467. /* exported interface */
  468. void *carl9170_alloc(size_t priv_size);
  469. int carl9170_register(struct ar9170 *ar);
  470. void carl9170_unregister(struct ar9170 *ar);
  471. void carl9170_free(struct ar9170 *ar);
  472. void carl9170_restart(struct ar9170 *ar, const enum carl9170_restart_reasons r);
  473. void carl9170_ps_check(struct ar9170 *ar);
  474. /* USB back-end */
  475. int carl9170_usb_open(struct ar9170 *ar);
  476. void carl9170_usb_stop(struct ar9170 *ar);
  477. void carl9170_usb_tx(struct ar9170 *ar, struct sk_buff *skb);
  478. void carl9170_usb_handle_tx_err(struct ar9170 *ar);
  479. int carl9170_exec_cmd(struct ar9170 *ar, const enum carl9170_cmd_oids,
  480. u32 plen, void *payload, u32 rlen, void *resp);
  481. int __carl9170_exec_cmd(struct ar9170 *ar, struct carl9170_cmd *cmd,
  482. const bool free_buf);
  483. int carl9170_usb_restart(struct ar9170 *ar);
  484. void carl9170_usb_reset(struct ar9170 *ar);
  485. /* MAC */
  486. int carl9170_init_mac(struct ar9170 *ar);
  487. int carl9170_set_qos(struct ar9170 *ar);
  488. int carl9170_update_multicast(struct ar9170 *ar, const u64 mc_hast);
  489. int carl9170_mod_virtual_mac(struct ar9170 *ar, const unsigned int id,
  490. const u8 *mac);
  491. int carl9170_set_operating_mode(struct ar9170 *ar);
  492. int carl9170_set_beacon_timers(struct ar9170 *ar);
  493. int carl9170_set_dyn_sifs_ack(struct ar9170 *ar);
  494. int carl9170_set_rts_cts_rate(struct ar9170 *ar);
  495. int carl9170_set_ampdu_settings(struct ar9170 *ar);
  496. int carl9170_set_slot_time(struct ar9170 *ar);
  497. int carl9170_set_mac_rates(struct ar9170 *ar);
  498. int carl9170_set_hwretry_limit(struct ar9170 *ar, const u32 max_retry);
  499. int carl9170_upload_key(struct ar9170 *ar, const u8 id, const u8 *mac,
  500. const u8 ktype, const u8 keyidx, const u8 *keydata, const int keylen);
  501. int carl9170_disable_key(struct ar9170 *ar, const u8 id);
  502. int carl9170_set_mac_tpc(struct ar9170 *ar, struct ieee80211_channel *channel);
  503. /* RX */
  504. void carl9170_rx(struct ar9170 *ar, void *buf, unsigned int len);
  505. void carl9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len);
  506. /* TX */
  507. void carl9170_op_tx(struct ieee80211_hw *hw,
  508. struct ieee80211_tx_control *control,
  509. struct sk_buff *skb);
  510. void carl9170_tx_janitor(struct work_struct *work);
  511. void carl9170_tx_process_status(struct ar9170 *ar,
  512. const struct carl9170_rsp *cmd);
  513. void carl9170_tx_status(struct ar9170 *ar, struct sk_buff *skb,
  514. const bool success);
  515. void carl9170_tx_callback(struct ar9170 *ar, struct sk_buff *skb);
  516. void carl9170_tx_drop(struct ar9170 *ar, struct sk_buff *skb);
  517. void carl9170_tx_scheduler(struct ar9170 *ar);
  518. void carl9170_tx_get_skb(struct sk_buff *skb);
  519. int carl9170_tx_put_skb(struct sk_buff *skb);
  520. int carl9170_update_beacon(struct ar9170 *ar, const bool submit);
  521. /* LEDs */
  522. #ifdef CONFIG_CARL9170_LEDS
  523. int carl9170_led_register(struct ar9170 *ar);
  524. void carl9170_led_unregister(struct ar9170 *ar);
  525. #endif /* CONFIG_CARL9170_LEDS */
  526. int carl9170_led_init(struct ar9170 *ar);
  527. int carl9170_led_set_state(struct ar9170 *ar, const u32 led_state);
  528. /* PHY / RF */
  529. int carl9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel,
  530. enum nl80211_channel_type bw, enum carl9170_rf_init_mode rfi);
  531. int carl9170_get_noisefloor(struct ar9170 *ar);
  532. /* FW */
  533. int carl9170_parse_firmware(struct ar9170 *ar);
  534. extern struct ieee80211_rate __carl9170_ratetable[];
  535. extern int modparam_noht;
  536. static inline struct ar9170 *carl9170_get_priv(struct carl9170_vif *carl_vif)
  537. {
  538. return container_of(carl_vif, struct ar9170,
  539. vif_priv[carl_vif->id]);
  540. }
  541. static inline struct ieee80211_hdr *carl9170_get_hdr(struct sk_buff *skb)
  542. {
  543. return (void *)((struct _carl9170_tx_superframe *)
  544. skb->data)->frame_data;
  545. }
  546. static inline u16 get_seq_h(struct ieee80211_hdr *hdr)
  547. {
  548. return le16_to_cpu(hdr->seq_ctrl) >> 4;
  549. }
  550. static inline u16 carl9170_get_seq(struct sk_buff *skb)
  551. {
  552. return get_seq_h(carl9170_get_hdr(skb));
  553. }
  554. static inline u16 get_tid_h(struct ieee80211_hdr *hdr)
  555. {
  556. return (ieee80211_get_qos_ctl(hdr))[0] & IEEE80211_QOS_CTL_TID_MASK;
  557. }
  558. static inline u16 carl9170_get_tid(struct sk_buff *skb)
  559. {
  560. return get_tid_h(carl9170_get_hdr(skb));
  561. }
  562. static inline struct ieee80211_vif *
  563. carl9170_get_vif(struct carl9170_vif_info *priv)
  564. {
  565. return container_of((void *)priv, struct ieee80211_vif, drv_priv);
  566. }
  567. /* Protected by ar->mutex or RCU */
  568. static inline struct ieee80211_vif *carl9170_get_main_vif(struct ar9170 *ar)
  569. {
  570. struct carl9170_vif_info *cvif;
  571. list_for_each_entry_rcu(cvif, &ar->vif_list, list) {
  572. if (cvif->active)
  573. return carl9170_get_vif(cvif);
  574. }
  575. return NULL;
  576. }
  577. static inline bool is_main_vif(struct ar9170 *ar, struct ieee80211_vif *vif)
  578. {
  579. bool ret;
  580. rcu_read_lock();
  581. ret = (carl9170_get_main_vif(ar) == vif);
  582. rcu_read_unlock();
  583. return ret;
  584. }
  585. #endif /* __CARL9170_H */