main.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  1. /*
  2. * Copyright (c) 2004-2011 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "core.h"
  17. #include "hif-ops.h"
  18. #include "cfg80211.h"
  19. #include "target.h"
  20. #include "debug.h"
  21. struct ath6kl_sta *ath6kl_find_sta(struct ath6kl_vif *vif, u8 *node_addr)
  22. {
  23. struct ath6kl *ar = vif->ar;
  24. struct ath6kl_sta *conn = NULL;
  25. u8 i, max_conn;
  26. max_conn = (vif->nw_type == AP_NETWORK) ? AP_MAX_NUM_STA : 0;
  27. for (i = 0; i < max_conn; i++) {
  28. if (memcmp(node_addr, ar->sta_list[i].mac, ETH_ALEN) == 0) {
  29. conn = &ar->sta_list[i];
  30. break;
  31. }
  32. }
  33. return conn;
  34. }
  35. struct ath6kl_sta *ath6kl_find_sta_by_aid(struct ath6kl *ar, u8 aid)
  36. {
  37. struct ath6kl_sta *conn = NULL;
  38. u8 ctr;
  39. for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) {
  40. if (ar->sta_list[ctr].aid == aid) {
  41. conn = &ar->sta_list[ctr];
  42. break;
  43. }
  44. }
  45. return conn;
  46. }
  47. static void ath6kl_add_new_sta(struct ath6kl *ar, u8 *mac, u16 aid, u8 *wpaie,
  48. u8 ielen, u8 keymgmt, u8 ucipher, u8 auth)
  49. {
  50. struct ath6kl_sta *sta;
  51. u8 free_slot;
  52. free_slot = aid - 1;
  53. sta = &ar->sta_list[free_slot];
  54. memcpy(sta->mac, mac, ETH_ALEN);
  55. if (ielen <= ATH6KL_MAX_IE)
  56. memcpy(sta->wpa_ie, wpaie, ielen);
  57. sta->aid = aid;
  58. sta->keymgmt = keymgmt;
  59. sta->ucipher = ucipher;
  60. sta->auth = auth;
  61. ar->sta_list_index = ar->sta_list_index | (1 << free_slot);
  62. ar->ap_stats.sta[free_slot].aid = cpu_to_le32(aid);
  63. }
  64. static void ath6kl_sta_cleanup(struct ath6kl *ar, u8 i)
  65. {
  66. struct ath6kl_sta *sta = &ar->sta_list[i];
  67. /* empty the queued pkts in the PS queue if any */
  68. spin_lock_bh(&sta->psq_lock);
  69. skb_queue_purge(&sta->psq);
  70. spin_unlock_bh(&sta->psq_lock);
  71. memset(&ar->ap_stats.sta[sta->aid - 1], 0,
  72. sizeof(struct wmi_per_sta_stat));
  73. memset(sta->mac, 0, ETH_ALEN);
  74. memset(sta->wpa_ie, 0, ATH6KL_MAX_IE);
  75. sta->aid = 0;
  76. sta->sta_flags = 0;
  77. ar->sta_list_index = ar->sta_list_index & ~(1 << i);
  78. }
  79. static u8 ath6kl_remove_sta(struct ath6kl *ar, u8 *mac, u16 reason)
  80. {
  81. u8 i, removed = 0;
  82. if (is_zero_ether_addr(mac))
  83. return removed;
  84. if (is_broadcast_ether_addr(mac)) {
  85. ath6kl_dbg(ATH6KL_DBG_TRC, "deleting all station\n");
  86. for (i = 0; i < AP_MAX_NUM_STA; i++) {
  87. if (!is_zero_ether_addr(ar->sta_list[i].mac)) {
  88. ath6kl_sta_cleanup(ar, i);
  89. removed = 1;
  90. }
  91. }
  92. } else {
  93. for (i = 0; i < AP_MAX_NUM_STA; i++) {
  94. if (memcmp(ar->sta_list[i].mac, mac, ETH_ALEN) == 0) {
  95. ath6kl_dbg(ATH6KL_DBG_TRC,
  96. "deleting station %pM aid=%d reason=%d\n",
  97. mac, ar->sta_list[i].aid, reason);
  98. ath6kl_sta_cleanup(ar, i);
  99. removed = 1;
  100. break;
  101. }
  102. }
  103. }
  104. return removed;
  105. }
  106. enum htc_endpoint_id ath6kl_ac2_endpoint_id(void *devt, u8 ac)
  107. {
  108. struct ath6kl *ar = devt;
  109. return ar->ac2ep_map[ac];
  110. }
  111. struct ath6kl_cookie *ath6kl_alloc_cookie(struct ath6kl *ar)
  112. {
  113. struct ath6kl_cookie *cookie;
  114. cookie = ar->cookie_list;
  115. if (cookie != NULL) {
  116. ar->cookie_list = cookie->arc_list_next;
  117. ar->cookie_count--;
  118. }
  119. return cookie;
  120. }
  121. void ath6kl_cookie_init(struct ath6kl *ar)
  122. {
  123. u32 i;
  124. ar->cookie_list = NULL;
  125. ar->cookie_count = 0;
  126. memset(ar->cookie_mem, 0, sizeof(ar->cookie_mem));
  127. for (i = 0; i < MAX_COOKIE_NUM; i++)
  128. ath6kl_free_cookie(ar, &ar->cookie_mem[i]);
  129. }
  130. void ath6kl_cookie_cleanup(struct ath6kl *ar)
  131. {
  132. ar->cookie_list = NULL;
  133. ar->cookie_count = 0;
  134. }
  135. void ath6kl_free_cookie(struct ath6kl *ar, struct ath6kl_cookie *cookie)
  136. {
  137. /* Insert first */
  138. if (!ar || !cookie)
  139. return;
  140. cookie->arc_list_next = ar->cookie_list;
  141. ar->cookie_list = cookie;
  142. ar->cookie_count++;
  143. }
  144. /* set the window address register (using 4-byte register access ). */
  145. static int ath6kl_set_addrwin_reg(struct ath6kl *ar, u32 reg_addr, u32 addr)
  146. {
  147. int status;
  148. s32 i;
  149. __le32 addr_val;
  150. /*
  151. * Write bytes 1,2,3 of the register to set the upper address bytes,
  152. * the LSB is written last to initiate the access cycle
  153. */
  154. for (i = 1; i <= 3; i++) {
  155. /*
  156. * Fill the buffer with the address byte value we want to
  157. * hit 4 times. No need to worry about endianness as the
  158. * same byte is copied to all four bytes of addr_val at
  159. * any time.
  160. */
  161. memset((u8 *)&addr_val, ((u8 *)&addr)[i], 4);
  162. /*
  163. * Hit each byte of the register address with a 4-byte
  164. * write operation to the same address, this is a harmless
  165. * operation.
  166. */
  167. status = hif_read_write_sync(ar, reg_addr + i, (u8 *)&addr_val,
  168. 4, HIF_WR_SYNC_BYTE_FIX);
  169. if (status)
  170. break;
  171. }
  172. if (status) {
  173. ath6kl_err("failed to write initial bytes of 0x%x to window reg: 0x%X\n",
  174. addr, reg_addr);
  175. return status;
  176. }
  177. /*
  178. * Write the address register again, this time write the whole
  179. * 4-byte value. The effect here is that the LSB write causes the
  180. * cycle to start, the extra 3 byte write to bytes 1,2,3 has no
  181. * effect since we are writing the same values again
  182. */
  183. addr_val = cpu_to_le32(addr);
  184. status = hif_read_write_sync(ar, reg_addr,
  185. (u8 *)&(addr_val),
  186. 4, HIF_WR_SYNC_BYTE_INC);
  187. if (status) {
  188. ath6kl_err("failed to write 0x%x to window reg: 0x%X\n",
  189. addr, reg_addr);
  190. return status;
  191. }
  192. return 0;
  193. }
  194. /*
  195. * Read from the hardware through its diagnostic window. No cooperation
  196. * from the firmware is required for this.
  197. */
  198. int ath6kl_diag_read32(struct ath6kl *ar, u32 address, u32 *value)
  199. {
  200. int ret;
  201. /* set window register to start read cycle */
  202. ret = ath6kl_set_addrwin_reg(ar, WINDOW_READ_ADDR_ADDRESS, address);
  203. if (ret)
  204. return ret;
  205. /* read the data */
  206. ret = hif_read_write_sync(ar, WINDOW_DATA_ADDRESS, (u8 *) value,
  207. sizeof(*value), HIF_RD_SYNC_BYTE_INC);
  208. if (ret) {
  209. ath6kl_warn("failed to read32 through diagnose window: %d\n",
  210. ret);
  211. return ret;
  212. }
  213. return 0;
  214. }
  215. /*
  216. * Write to the ATH6KL through its diagnostic window. No cooperation from
  217. * the Target is required for this.
  218. */
  219. int ath6kl_diag_write32(struct ath6kl *ar, u32 address, __le32 value)
  220. {
  221. int ret;
  222. /* set write data */
  223. ret = hif_read_write_sync(ar, WINDOW_DATA_ADDRESS, (u8 *) &value,
  224. sizeof(value), HIF_WR_SYNC_BYTE_INC);
  225. if (ret) {
  226. ath6kl_err("failed to write 0x%x during diagnose window to 0x%d\n",
  227. address, value);
  228. return ret;
  229. }
  230. /* set window register, which starts the write cycle */
  231. return ath6kl_set_addrwin_reg(ar, WINDOW_WRITE_ADDR_ADDRESS,
  232. address);
  233. }
  234. int ath6kl_diag_read(struct ath6kl *ar, u32 address, void *data, u32 length)
  235. {
  236. u32 count, *buf = data;
  237. int ret;
  238. if (WARN_ON(length % 4))
  239. return -EINVAL;
  240. for (count = 0; count < length / 4; count++, address += 4) {
  241. ret = ath6kl_diag_read32(ar, address, &buf[count]);
  242. if (ret)
  243. return ret;
  244. }
  245. return 0;
  246. }
  247. int ath6kl_diag_write(struct ath6kl *ar, u32 address, void *data, u32 length)
  248. {
  249. u32 count;
  250. __le32 *buf = data;
  251. int ret;
  252. if (WARN_ON(length % 4))
  253. return -EINVAL;
  254. for (count = 0; count < length / 4; count++, address += 4) {
  255. ret = ath6kl_diag_write32(ar, address, buf[count]);
  256. if (ret)
  257. return ret;
  258. }
  259. return 0;
  260. }
  261. int ath6kl_read_fwlogs(struct ath6kl *ar)
  262. {
  263. struct ath6kl_dbglog_hdr debug_hdr;
  264. struct ath6kl_dbglog_buf debug_buf;
  265. u32 address, length, dropped, firstbuf, debug_hdr_addr;
  266. int ret = 0, loop;
  267. u8 *buf;
  268. buf = kmalloc(ATH6KL_FWLOG_PAYLOAD_SIZE, GFP_KERNEL);
  269. if (!buf)
  270. return -ENOMEM;
  271. address = TARG_VTOP(ar->target_type,
  272. ath6kl_get_hi_item_addr(ar,
  273. HI_ITEM(hi_dbglog_hdr)));
  274. ret = ath6kl_diag_read32(ar, address, &debug_hdr_addr);
  275. if (ret)
  276. goto out;
  277. /* Get the contents of the ring buffer */
  278. if (debug_hdr_addr == 0) {
  279. ath6kl_warn("Invalid address for debug_hdr_addr\n");
  280. ret = -EINVAL;
  281. goto out;
  282. }
  283. address = TARG_VTOP(ar->target_type, debug_hdr_addr);
  284. ath6kl_diag_read(ar, address, &debug_hdr, sizeof(debug_hdr));
  285. address = TARG_VTOP(ar->target_type,
  286. le32_to_cpu(debug_hdr.dbuf_addr));
  287. firstbuf = address;
  288. dropped = le32_to_cpu(debug_hdr.dropped);
  289. ath6kl_diag_read(ar, address, &debug_buf, sizeof(debug_buf));
  290. loop = 100;
  291. do {
  292. address = TARG_VTOP(ar->target_type,
  293. le32_to_cpu(debug_buf.buffer_addr));
  294. length = le32_to_cpu(debug_buf.length);
  295. if (length != 0 && (le32_to_cpu(debug_buf.length) <=
  296. le32_to_cpu(debug_buf.bufsize))) {
  297. length = ALIGN(length, 4);
  298. ret = ath6kl_diag_read(ar, address,
  299. buf, length);
  300. if (ret)
  301. goto out;
  302. ath6kl_debug_fwlog_event(ar, buf, length);
  303. }
  304. address = TARG_VTOP(ar->target_type,
  305. le32_to_cpu(debug_buf.next));
  306. ath6kl_diag_read(ar, address, &debug_buf, sizeof(debug_buf));
  307. if (ret)
  308. goto out;
  309. loop--;
  310. if (WARN_ON(loop == 0)) {
  311. ret = -ETIMEDOUT;
  312. goto out;
  313. }
  314. } while (address != firstbuf);
  315. out:
  316. kfree(buf);
  317. return ret;
  318. }
  319. /* FIXME: move to a better place, target.h? */
  320. #define AR6003_RESET_CONTROL_ADDRESS 0x00004000
  321. #define AR6004_RESET_CONTROL_ADDRESS 0x00004000
  322. void ath6kl_reset_device(struct ath6kl *ar, u32 target_type,
  323. bool wait_fot_compltn, bool cold_reset)
  324. {
  325. int status = 0;
  326. u32 address;
  327. __le32 data;
  328. if (target_type != TARGET_TYPE_AR6003 &&
  329. target_type != TARGET_TYPE_AR6004)
  330. return;
  331. data = cold_reset ? cpu_to_le32(RESET_CONTROL_COLD_RST) :
  332. cpu_to_le32(RESET_CONTROL_MBOX_RST);
  333. switch (target_type) {
  334. case TARGET_TYPE_AR6003:
  335. address = AR6003_RESET_CONTROL_ADDRESS;
  336. break;
  337. case TARGET_TYPE_AR6004:
  338. address = AR6004_RESET_CONTROL_ADDRESS;
  339. break;
  340. default:
  341. address = AR6003_RESET_CONTROL_ADDRESS;
  342. break;
  343. }
  344. status = ath6kl_diag_write32(ar, address, data);
  345. if (status)
  346. ath6kl_err("failed to reset target\n");
  347. }
  348. static void ath6kl_install_static_wep_keys(struct ath6kl_vif *vif)
  349. {
  350. u8 index;
  351. u8 keyusage;
  352. for (index = WMI_MIN_KEY_INDEX; index <= WMI_MAX_KEY_INDEX; index++) {
  353. if (vif->wep_key_list[index].key_len) {
  354. keyusage = GROUP_USAGE;
  355. if (index == vif->def_txkey_index)
  356. keyusage |= TX_USAGE;
  357. ath6kl_wmi_addkey_cmd(vif->ar->wmi, vif->fw_vif_idx,
  358. index,
  359. WEP_CRYPT,
  360. keyusage,
  361. vif->wep_key_list[index].key_len,
  362. NULL,
  363. vif->wep_key_list[index].key,
  364. KEY_OP_INIT_VAL, NULL,
  365. NO_SYNC_WMIFLAG);
  366. }
  367. }
  368. }
  369. void ath6kl_connect_ap_mode_bss(struct ath6kl_vif *vif, u16 channel)
  370. {
  371. struct ath6kl *ar = vif->ar;
  372. struct ath6kl_req_key *ik;
  373. int res;
  374. u8 key_rsc[ATH6KL_KEY_SEQ_LEN];
  375. ik = &ar->ap_mode_bkey;
  376. ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "AP mode started on %u MHz\n", channel);
  377. switch (vif->auth_mode) {
  378. case NONE_AUTH:
  379. if (vif->prwise_crypto == WEP_CRYPT)
  380. ath6kl_install_static_wep_keys(vif);
  381. break;
  382. case WPA_PSK_AUTH:
  383. case WPA2_PSK_AUTH:
  384. case (WPA_PSK_AUTH | WPA2_PSK_AUTH):
  385. if (!ik->valid)
  386. break;
  387. ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "Delayed addkey for "
  388. "the initial group key for AP mode\n");
  389. memset(key_rsc, 0, sizeof(key_rsc));
  390. res = ath6kl_wmi_addkey_cmd(
  391. ar->wmi, vif->fw_vif_idx, ik->key_index, ik->key_type,
  392. GROUP_USAGE, ik->key_len, key_rsc, ik->key,
  393. KEY_OP_INIT_VAL, NULL, SYNC_BOTH_WMIFLAG);
  394. if (res) {
  395. ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "Delayed "
  396. "addkey failed: %d\n", res);
  397. }
  398. break;
  399. }
  400. ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx, NONE_BSS_FILTER, 0);
  401. set_bit(CONNECTED, &vif->flags);
  402. netif_carrier_on(vif->ndev);
  403. }
  404. void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr,
  405. u8 keymgmt, u8 ucipher, u8 auth,
  406. u8 assoc_req_len, u8 *assoc_info)
  407. {
  408. struct ath6kl *ar = vif->ar;
  409. u8 *ies = NULL, *wpa_ie = NULL, *pos;
  410. size_t ies_len = 0;
  411. struct station_info sinfo;
  412. ath6kl_dbg(ATH6KL_DBG_TRC, "new station %pM aid=%d\n", mac_addr, aid);
  413. if (assoc_req_len > sizeof(struct ieee80211_hdr_3addr)) {
  414. struct ieee80211_mgmt *mgmt =
  415. (struct ieee80211_mgmt *) assoc_info;
  416. if (ieee80211_is_assoc_req(mgmt->frame_control) &&
  417. assoc_req_len >= sizeof(struct ieee80211_hdr_3addr) +
  418. sizeof(mgmt->u.assoc_req)) {
  419. ies = mgmt->u.assoc_req.variable;
  420. ies_len = assoc_info + assoc_req_len - ies;
  421. } else if (ieee80211_is_reassoc_req(mgmt->frame_control) &&
  422. assoc_req_len >= sizeof(struct ieee80211_hdr_3addr)
  423. + sizeof(mgmt->u.reassoc_req)) {
  424. ies = mgmt->u.reassoc_req.variable;
  425. ies_len = assoc_info + assoc_req_len - ies;
  426. }
  427. }
  428. pos = ies;
  429. while (pos && pos + 1 < ies + ies_len) {
  430. if (pos + 2 + pos[1] > ies + ies_len)
  431. break;
  432. if (pos[0] == WLAN_EID_RSN)
  433. wpa_ie = pos; /* RSN IE */
  434. else if (pos[0] == WLAN_EID_VENDOR_SPECIFIC &&
  435. pos[1] >= 4 &&
  436. pos[2] == 0x00 && pos[3] == 0x50 && pos[4] == 0xf2) {
  437. if (pos[5] == 0x01)
  438. wpa_ie = pos; /* WPA IE */
  439. else if (pos[5] == 0x04) {
  440. wpa_ie = pos; /* WPS IE */
  441. break; /* overrides WPA/RSN IE */
  442. }
  443. }
  444. pos += 2 + pos[1];
  445. }
  446. ath6kl_add_new_sta(ar, mac_addr, aid, wpa_ie,
  447. wpa_ie ? 2 + wpa_ie[1] : 0,
  448. keymgmt, ucipher, auth);
  449. /* send event to application */
  450. memset(&sinfo, 0, sizeof(sinfo));
  451. /* TODO: sinfo.generation */
  452. sinfo.assoc_req_ies = ies;
  453. sinfo.assoc_req_ies_len = ies_len;
  454. sinfo.filled |= STATION_INFO_ASSOC_REQ_IES;
  455. cfg80211_new_sta(vif->ndev, mac_addr, &sinfo, GFP_KERNEL);
  456. netif_wake_queue(vif->ndev);
  457. }
  458. void disconnect_timer_handler(unsigned long ptr)
  459. {
  460. struct net_device *dev = (struct net_device *)ptr;
  461. struct ath6kl_vif *vif = netdev_priv(dev);
  462. ath6kl_init_profile_info(vif);
  463. ath6kl_disconnect(vif);
  464. }
  465. void ath6kl_disconnect(struct ath6kl_vif *vif)
  466. {
  467. if (test_bit(CONNECTED, &vif->flags) ||
  468. test_bit(CONNECT_PEND, &vif->flags)) {
  469. ath6kl_wmi_disconnect_cmd(vif->ar->wmi, vif->fw_vif_idx);
  470. /*
  471. * Disconnect command is issued, clear the connect pending
  472. * flag. The connected flag will be cleared in
  473. * disconnect event notification.
  474. */
  475. clear_bit(CONNECT_PEND, &vif->flags);
  476. }
  477. }
  478. /* WMI Event handlers */
  479. static const char *get_hw_id_string(u32 id)
  480. {
  481. switch (id) {
  482. case AR6003_REV1_VERSION:
  483. return "1.0";
  484. case AR6003_REV2_VERSION:
  485. return "2.0";
  486. case AR6003_REV3_VERSION:
  487. return "2.1.1";
  488. default:
  489. return "unknown";
  490. }
  491. }
  492. void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver)
  493. {
  494. struct ath6kl *ar = devt;
  495. memcpy(ar->mac_addr, datap, ETH_ALEN);
  496. ath6kl_dbg(ATH6KL_DBG_TRC, "%s: mac addr = %pM\n",
  497. __func__, ar->mac_addr);
  498. ar->version.wlan_ver = sw_ver;
  499. ar->version.abi_ver = abi_ver;
  500. snprintf(ar->wiphy->fw_version,
  501. sizeof(ar->wiphy->fw_version),
  502. "%u.%u.%u.%u",
  503. (ar->version.wlan_ver & 0xf0000000) >> 28,
  504. (ar->version.wlan_ver & 0x0f000000) >> 24,
  505. (ar->version.wlan_ver & 0x00ff0000) >> 16,
  506. (ar->version.wlan_ver & 0x0000ffff));
  507. /* indicate to the waiting thread that the ready event was received */
  508. set_bit(WMI_READY, &ar->flag);
  509. wake_up(&ar->event_wq);
  510. if (test_and_clear_bit(FIRST_BOOT, &ar->flag)) {
  511. ath6kl_info("hw %s fw %s%s\n",
  512. get_hw_id_string(ar->wiphy->hw_version),
  513. ar->wiphy->fw_version,
  514. test_bit(TESTMODE, &ar->flag) ? " testmode" : "");
  515. }
  516. }
  517. void ath6kl_scan_complete_evt(struct ath6kl_vif *vif, int status)
  518. {
  519. struct ath6kl *ar = vif->ar;
  520. bool aborted = false;
  521. if (status != WMI_SCAN_STATUS_SUCCESS)
  522. aborted = true;
  523. ath6kl_cfg80211_scan_complete_event(vif, aborted);
  524. if (!ar->usr_bss_filter) {
  525. clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags);
  526. ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
  527. NONE_BSS_FILTER, 0);
  528. }
  529. ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "scan complete: %d\n", status);
  530. }
  531. void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid,
  532. u16 listen_int, u16 beacon_int,
  533. enum network_type net_type, u8 beacon_ie_len,
  534. u8 assoc_req_len, u8 assoc_resp_len,
  535. u8 *assoc_info)
  536. {
  537. struct ath6kl *ar = vif->ar;
  538. ath6kl_cfg80211_connect_event(vif, channel, bssid,
  539. listen_int, beacon_int,
  540. net_type, beacon_ie_len,
  541. assoc_req_len, assoc_resp_len,
  542. assoc_info);
  543. memcpy(vif->bssid, bssid, sizeof(vif->bssid));
  544. vif->bss_ch = channel;
  545. if ((vif->nw_type == INFRA_NETWORK))
  546. ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx,
  547. ar->listen_intvl_t,
  548. ar->listen_intvl_b);
  549. netif_wake_queue(vif->ndev);
  550. /* Update connect & link status atomically */
  551. spin_lock_bh(&vif->if_lock);
  552. set_bit(CONNECTED, &vif->flags);
  553. clear_bit(CONNECT_PEND, &vif->flags);
  554. netif_carrier_on(vif->ndev);
  555. spin_unlock_bh(&vif->if_lock);
  556. aggr_reset_state(vif->aggr_cntxt);
  557. vif->reconnect_flag = 0;
  558. if ((vif->nw_type == ADHOC_NETWORK) && ar->ibss_ps_enable) {
  559. memset(ar->node_map, 0, sizeof(ar->node_map));
  560. ar->node_num = 0;
  561. ar->next_ep_id = ENDPOINT_2;
  562. }
  563. if (!ar->usr_bss_filter) {
  564. set_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags);
  565. ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
  566. CURRENT_BSS_FILTER, 0);
  567. }
  568. }
  569. void ath6kl_tkip_micerr_event(struct ath6kl_vif *vif, u8 keyid, bool ismcast)
  570. {
  571. struct ath6kl_sta *sta;
  572. struct ath6kl *ar = vif->ar;
  573. u8 tsc[6];
  574. /*
  575. * For AP case, keyid will have aid of STA which sent pkt with
  576. * MIC error. Use this aid to get MAC & send it to hostapd.
  577. */
  578. if (vif->nw_type == AP_NETWORK) {
  579. sta = ath6kl_find_sta_by_aid(ar, (keyid >> 2));
  580. if (!sta)
  581. return;
  582. ath6kl_dbg(ATH6KL_DBG_TRC,
  583. "ap tkip mic error received from aid=%d\n", keyid);
  584. memset(tsc, 0, sizeof(tsc)); /* FIX: get correct TSC */
  585. cfg80211_michael_mic_failure(vif->ndev, sta->mac,
  586. NL80211_KEYTYPE_PAIRWISE, keyid,
  587. tsc, GFP_KERNEL);
  588. } else
  589. ath6kl_cfg80211_tkip_micerr_event(vif, keyid, ismcast);
  590. }
  591. static void ath6kl_update_target_stats(struct ath6kl_vif *vif, u8 *ptr, u32 len)
  592. {
  593. struct wmi_target_stats *tgt_stats =
  594. (struct wmi_target_stats *) ptr;
  595. struct ath6kl *ar = vif->ar;
  596. struct target_stats *stats = &vif->target_stats;
  597. struct tkip_ccmp_stats *ccmp_stats;
  598. u8 ac;
  599. if (len < sizeof(*tgt_stats))
  600. return;
  601. ath6kl_dbg(ATH6KL_DBG_TRC, "updating target stats\n");
  602. stats->tx_pkt += le32_to_cpu(tgt_stats->stats.tx.pkt);
  603. stats->tx_byte += le32_to_cpu(tgt_stats->stats.tx.byte);
  604. stats->tx_ucast_pkt += le32_to_cpu(tgt_stats->stats.tx.ucast_pkt);
  605. stats->tx_ucast_byte += le32_to_cpu(tgt_stats->stats.tx.ucast_byte);
  606. stats->tx_mcast_pkt += le32_to_cpu(tgt_stats->stats.tx.mcast_pkt);
  607. stats->tx_mcast_byte += le32_to_cpu(tgt_stats->stats.tx.mcast_byte);
  608. stats->tx_bcast_pkt += le32_to_cpu(tgt_stats->stats.tx.bcast_pkt);
  609. stats->tx_bcast_byte += le32_to_cpu(tgt_stats->stats.tx.bcast_byte);
  610. stats->tx_rts_success_cnt +=
  611. le32_to_cpu(tgt_stats->stats.tx.rts_success_cnt);
  612. for (ac = 0; ac < WMM_NUM_AC; ac++)
  613. stats->tx_pkt_per_ac[ac] +=
  614. le32_to_cpu(tgt_stats->stats.tx.pkt_per_ac[ac]);
  615. stats->tx_err += le32_to_cpu(tgt_stats->stats.tx.err);
  616. stats->tx_fail_cnt += le32_to_cpu(tgt_stats->stats.tx.fail_cnt);
  617. stats->tx_retry_cnt += le32_to_cpu(tgt_stats->stats.tx.retry_cnt);
  618. stats->tx_mult_retry_cnt +=
  619. le32_to_cpu(tgt_stats->stats.tx.mult_retry_cnt);
  620. stats->tx_rts_fail_cnt +=
  621. le32_to_cpu(tgt_stats->stats.tx.rts_fail_cnt);
  622. stats->tx_ucast_rate =
  623. ath6kl_wmi_get_rate(a_sle32_to_cpu(tgt_stats->stats.tx.ucast_rate));
  624. stats->rx_pkt += le32_to_cpu(tgt_stats->stats.rx.pkt);
  625. stats->rx_byte += le32_to_cpu(tgt_stats->stats.rx.byte);
  626. stats->rx_ucast_pkt += le32_to_cpu(tgt_stats->stats.rx.ucast_pkt);
  627. stats->rx_ucast_byte += le32_to_cpu(tgt_stats->stats.rx.ucast_byte);
  628. stats->rx_mcast_pkt += le32_to_cpu(tgt_stats->stats.rx.mcast_pkt);
  629. stats->rx_mcast_byte += le32_to_cpu(tgt_stats->stats.rx.mcast_byte);
  630. stats->rx_bcast_pkt += le32_to_cpu(tgt_stats->stats.rx.bcast_pkt);
  631. stats->rx_bcast_byte += le32_to_cpu(tgt_stats->stats.rx.bcast_byte);
  632. stats->rx_frgment_pkt += le32_to_cpu(tgt_stats->stats.rx.frgment_pkt);
  633. stats->rx_err += le32_to_cpu(tgt_stats->stats.rx.err);
  634. stats->rx_crc_err += le32_to_cpu(tgt_stats->stats.rx.crc_err);
  635. stats->rx_key_cache_miss +=
  636. le32_to_cpu(tgt_stats->stats.rx.key_cache_miss);
  637. stats->rx_decrypt_err += le32_to_cpu(tgt_stats->stats.rx.decrypt_err);
  638. stats->rx_dupl_frame += le32_to_cpu(tgt_stats->stats.rx.dupl_frame);
  639. stats->rx_ucast_rate =
  640. ath6kl_wmi_get_rate(a_sle32_to_cpu(tgt_stats->stats.rx.ucast_rate));
  641. ccmp_stats = &tgt_stats->stats.tkip_ccmp_stats;
  642. stats->tkip_local_mic_fail +=
  643. le32_to_cpu(ccmp_stats->tkip_local_mic_fail);
  644. stats->tkip_cnter_measures_invoked +=
  645. le32_to_cpu(ccmp_stats->tkip_cnter_measures_invoked);
  646. stats->tkip_fmt_err += le32_to_cpu(ccmp_stats->tkip_fmt_err);
  647. stats->ccmp_fmt_err += le32_to_cpu(ccmp_stats->ccmp_fmt_err);
  648. stats->ccmp_replays += le32_to_cpu(ccmp_stats->ccmp_replays);
  649. stats->pwr_save_fail_cnt +=
  650. le32_to_cpu(tgt_stats->pm_stats.pwr_save_failure_cnt);
  651. stats->noise_floor_calib =
  652. a_sle32_to_cpu(tgt_stats->noise_floor_calib);
  653. stats->cs_bmiss_cnt +=
  654. le32_to_cpu(tgt_stats->cserv_stats.cs_bmiss_cnt);
  655. stats->cs_low_rssi_cnt +=
  656. le32_to_cpu(tgt_stats->cserv_stats.cs_low_rssi_cnt);
  657. stats->cs_connect_cnt +=
  658. le16_to_cpu(tgt_stats->cserv_stats.cs_connect_cnt);
  659. stats->cs_discon_cnt +=
  660. le16_to_cpu(tgt_stats->cserv_stats.cs_discon_cnt);
  661. stats->cs_ave_beacon_rssi =
  662. a_sle16_to_cpu(tgt_stats->cserv_stats.cs_ave_beacon_rssi);
  663. stats->cs_last_roam_msec =
  664. tgt_stats->cserv_stats.cs_last_roam_msec;
  665. stats->cs_snr = tgt_stats->cserv_stats.cs_snr;
  666. stats->cs_rssi = a_sle16_to_cpu(tgt_stats->cserv_stats.cs_rssi);
  667. stats->lq_val = le32_to_cpu(tgt_stats->lq_val);
  668. stats->wow_pkt_dropped +=
  669. le32_to_cpu(tgt_stats->wow_stats.wow_pkt_dropped);
  670. stats->wow_host_pkt_wakeups +=
  671. tgt_stats->wow_stats.wow_host_pkt_wakeups;
  672. stats->wow_host_evt_wakeups +=
  673. tgt_stats->wow_stats.wow_host_evt_wakeups;
  674. stats->wow_evt_discarded +=
  675. le16_to_cpu(tgt_stats->wow_stats.wow_evt_discarded);
  676. if (test_bit(STATS_UPDATE_PEND, &vif->flags)) {
  677. clear_bit(STATS_UPDATE_PEND, &vif->flags);
  678. wake_up(&ar->event_wq);
  679. }
  680. }
  681. static void ath6kl_add_le32(__le32 *var, __le32 val)
  682. {
  683. *var = cpu_to_le32(le32_to_cpu(*var) + le32_to_cpu(val));
  684. }
  685. void ath6kl_tgt_stats_event(struct ath6kl_vif *vif, u8 *ptr, u32 len)
  686. {
  687. struct wmi_ap_mode_stat *p = (struct wmi_ap_mode_stat *) ptr;
  688. struct ath6kl *ar = vif->ar;
  689. struct wmi_ap_mode_stat *ap = &ar->ap_stats;
  690. struct wmi_per_sta_stat *st_ap, *st_p;
  691. u8 ac;
  692. if (vif->nw_type == AP_NETWORK) {
  693. if (len < sizeof(*p))
  694. return;
  695. for (ac = 0; ac < AP_MAX_NUM_STA; ac++) {
  696. st_ap = &ap->sta[ac];
  697. st_p = &p->sta[ac];
  698. ath6kl_add_le32(&st_ap->tx_bytes, st_p->tx_bytes);
  699. ath6kl_add_le32(&st_ap->tx_pkts, st_p->tx_pkts);
  700. ath6kl_add_le32(&st_ap->tx_error, st_p->tx_error);
  701. ath6kl_add_le32(&st_ap->tx_discard, st_p->tx_discard);
  702. ath6kl_add_le32(&st_ap->rx_bytes, st_p->rx_bytes);
  703. ath6kl_add_le32(&st_ap->rx_pkts, st_p->rx_pkts);
  704. ath6kl_add_le32(&st_ap->rx_error, st_p->rx_error);
  705. ath6kl_add_le32(&st_ap->rx_discard, st_p->rx_discard);
  706. }
  707. } else {
  708. ath6kl_update_target_stats(vif, ptr, len);
  709. }
  710. }
  711. void ath6kl_wakeup_event(void *dev)
  712. {
  713. struct ath6kl *ar = (struct ath6kl *) dev;
  714. wake_up(&ar->event_wq);
  715. }
  716. void ath6kl_txpwr_rx_evt(void *devt, u8 tx_pwr)
  717. {
  718. struct ath6kl *ar = (struct ath6kl *) devt;
  719. ar->tx_pwr = tx_pwr;
  720. wake_up(&ar->event_wq);
  721. }
  722. void ath6kl_pspoll_event(struct ath6kl_vif *vif, u8 aid)
  723. {
  724. struct ath6kl_sta *conn;
  725. struct sk_buff *skb;
  726. bool psq_empty = false;
  727. struct ath6kl *ar = vif->ar;
  728. conn = ath6kl_find_sta_by_aid(ar, aid);
  729. if (!conn)
  730. return;
  731. /*
  732. * Send out a packet queued on ps queue. When the ps queue
  733. * becomes empty update the PVB for this station.
  734. */
  735. spin_lock_bh(&conn->psq_lock);
  736. psq_empty = skb_queue_empty(&conn->psq);
  737. spin_unlock_bh(&conn->psq_lock);
  738. if (psq_empty)
  739. /* TODO: Send out a NULL data frame */
  740. return;
  741. spin_lock_bh(&conn->psq_lock);
  742. skb = skb_dequeue(&conn->psq);
  743. spin_unlock_bh(&conn->psq_lock);
  744. conn->sta_flags |= STA_PS_POLLED;
  745. ath6kl_data_tx(skb, vif->ndev);
  746. conn->sta_flags &= ~STA_PS_POLLED;
  747. spin_lock_bh(&conn->psq_lock);
  748. psq_empty = skb_queue_empty(&conn->psq);
  749. spin_unlock_bh(&conn->psq_lock);
  750. if (psq_empty)
  751. ath6kl_wmi_set_pvb_cmd(ar->wmi, vif->fw_vif_idx, conn->aid, 0);
  752. }
  753. void ath6kl_dtimexpiry_event(struct ath6kl_vif *vif)
  754. {
  755. bool mcastq_empty = false;
  756. struct sk_buff *skb;
  757. struct ath6kl *ar = vif->ar;
  758. /*
  759. * If there are no associated STAs, ignore the DTIM expiry event.
  760. * There can be potential race conditions where the last associated
  761. * STA may disconnect & before the host could clear the 'Indicate
  762. * DTIM' request to the firmware, the firmware would have just
  763. * indicated a DTIM expiry event. The race is between 'clear DTIM
  764. * expiry cmd' going from the host to the firmware & the DTIM
  765. * expiry event happening from the firmware to the host.
  766. */
  767. if (!ar->sta_list_index)
  768. return;
  769. spin_lock_bh(&ar->mcastpsq_lock);
  770. mcastq_empty = skb_queue_empty(&ar->mcastpsq);
  771. spin_unlock_bh(&ar->mcastpsq_lock);
  772. if (mcastq_empty)
  773. return;
  774. /* set the STA flag to dtim_expired for the frame to go out */
  775. set_bit(DTIM_EXPIRED, &vif->flags);
  776. spin_lock_bh(&ar->mcastpsq_lock);
  777. while ((skb = skb_dequeue(&ar->mcastpsq)) != NULL) {
  778. spin_unlock_bh(&ar->mcastpsq_lock);
  779. ath6kl_data_tx(skb, vif->ndev);
  780. spin_lock_bh(&ar->mcastpsq_lock);
  781. }
  782. spin_unlock_bh(&ar->mcastpsq_lock);
  783. clear_bit(DTIM_EXPIRED, &vif->flags);
  784. /* clear the LSB of the BitMapCtl field of the TIM IE */
  785. ath6kl_wmi_set_pvb_cmd(ar->wmi, vif->fw_vif_idx, MCAST_AID, 0);
  786. }
  787. void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid,
  788. u8 assoc_resp_len, u8 *assoc_info,
  789. u16 prot_reason_status)
  790. {
  791. struct ath6kl *ar = vif->ar;
  792. if (vif->nw_type == AP_NETWORK) {
  793. if (!ath6kl_remove_sta(ar, bssid, prot_reason_status))
  794. return;
  795. /* if no more associated STAs, empty the mcast PS q */
  796. if (ar->sta_list_index == 0) {
  797. spin_lock_bh(&ar->mcastpsq_lock);
  798. skb_queue_purge(&ar->mcastpsq);
  799. spin_unlock_bh(&ar->mcastpsq_lock);
  800. /* clear the LSB of the TIM IE's BitMapCtl field */
  801. if (test_bit(WMI_READY, &ar->flag))
  802. ath6kl_wmi_set_pvb_cmd(ar->wmi, vif->fw_vif_idx,
  803. MCAST_AID, 0);
  804. }
  805. if (!is_broadcast_ether_addr(bssid)) {
  806. /* send event to application */
  807. cfg80211_del_sta(vif->ndev, bssid, GFP_KERNEL);
  808. }
  809. if (memcmp(vif->ndev->dev_addr, bssid, ETH_ALEN) == 0) {
  810. memset(vif->wep_key_list, 0, sizeof(vif->wep_key_list));
  811. clear_bit(CONNECTED, &vif->flags);
  812. }
  813. return;
  814. }
  815. ath6kl_cfg80211_disconnect_event(vif, reason, bssid,
  816. assoc_resp_len, assoc_info,
  817. prot_reason_status);
  818. aggr_reset_state(vif->aggr_cntxt);
  819. del_timer(&vif->disconnect_timer);
  820. ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "disconnect reason is %d\n", reason);
  821. /*
  822. * If the event is due to disconnect cmd from the host, only they
  823. * the target would stop trying to connect. Under any other
  824. * condition, target would keep trying to connect.
  825. */
  826. if (reason == DISCONNECT_CMD) {
  827. if (!ar->usr_bss_filter && test_bit(WMI_READY, &ar->flag))
  828. ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
  829. NONE_BSS_FILTER, 0);
  830. } else {
  831. set_bit(CONNECT_PEND, &vif->flags);
  832. if (((reason == ASSOC_FAILED) &&
  833. (prot_reason_status == 0x11)) ||
  834. ((reason == ASSOC_FAILED) && (prot_reason_status == 0x0)
  835. && (vif->reconnect_flag == 1))) {
  836. set_bit(CONNECTED, &vif->flags);
  837. return;
  838. }
  839. }
  840. /* update connect & link status atomically */
  841. spin_lock_bh(&vif->if_lock);
  842. clear_bit(CONNECTED, &vif->flags);
  843. netif_carrier_off(vif->ndev);
  844. spin_unlock_bh(&vif->if_lock);
  845. if ((reason != CSERV_DISCONNECT) || (vif->reconnect_flag != 1))
  846. vif->reconnect_flag = 0;
  847. if (reason != CSERV_DISCONNECT)
  848. ar->user_key_ctrl = 0;
  849. netif_stop_queue(vif->ndev);
  850. memset(vif->bssid, 0, sizeof(vif->bssid));
  851. vif->bss_ch = 0;
  852. ath6kl_tx_data_cleanup(ar);
  853. }
  854. struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar)
  855. {
  856. struct ath6kl_vif *vif;
  857. spin_lock_bh(&ar->list_lock);
  858. if (list_empty(&ar->vif_list)) {
  859. spin_unlock_bh(&ar->list_lock);
  860. return NULL;
  861. }
  862. vif = list_first_entry(&ar->vif_list, struct ath6kl_vif, list);
  863. spin_unlock_bh(&ar->list_lock);
  864. return vif;
  865. }
  866. static int ath6kl_open(struct net_device *dev)
  867. {
  868. struct ath6kl_vif *vif = netdev_priv(dev);
  869. int ret;
  870. /* FIXME: how to handle multi vif support? */
  871. ret = ath6kl_init_hw_start(vif->ar);
  872. if (ret)
  873. return ret;
  874. set_bit(WLAN_ENABLED, &vif->flags);
  875. if (test_bit(CONNECTED, &vif->flags)) {
  876. netif_carrier_on(dev);
  877. netif_wake_queue(dev);
  878. } else
  879. netif_carrier_off(dev);
  880. return 0;
  881. }
  882. static int ath6kl_close(struct net_device *dev)
  883. {
  884. struct ath6kl *ar = ath6kl_priv(dev);
  885. struct ath6kl_vif *vif = netdev_priv(dev);
  886. int ret;
  887. netif_stop_queue(dev);
  888. ath6kl_disconnect(vif);
  889. if (test_bit(WMI_READY, &ar->flag)) {
  890. if (ath6kl_wmi_scanparams_cmd(ar->wmi, vif->fw_vif_idx, 0xFFFF,
  891. 0, 0, 0, 0, 0, 0, 0, 0, 0))
  892. return -EIO;
  893. }
  894. ath6kl_cfg80211_scan_complete_event(vif, true);
  895. /* FIXME: how to handle multi vif support? */
  896. ret = ath6kl_init_hw_stop(ar);
  897. if (ret)
  898. return ret;
  899. clear_bit(WLAN_ENABLED, &vif->flags);
  900. return 0;
  901. }
  902. static struct net_device_stats *ath6kl_get_stats(struct net_device *dev)
  903. {
  904. struct ath6kl_vif *vif = netdev_priv(dev);
  905. return &vif->net_stats;
  906. }
  907. static struct net_device_ops ath6kl_netdev_ops = {
  908. .ndo_open = ath6kl_open,
  909. .ndo_stop = ath6kl_close,
  910. .ndo_start_xmit = ath6kl_data_tx,
  911. .ndo_get_stats = ath6kl_get_stats,
  912. };
  913. void init_netdev(struct net_device *dev)
  914. {
  915. dev->netdev_ops = &ath6kl_netdev_ops;
  916. dev->destructor = free_netdev;
  917. dev->watchdog_timeo = ATH6KL_TX_TIMEOUT;
  918. dev->needed_headroom = ETH_HLEN;
  919. dev->needed_headroom += sizeof(struct ath6kl_llc_snap_hdr) +
  920. sizeof(struct wmi_data_hdr) + HTC_HDR_LENGTH
  921. + WMI_MAX_TX_META_SZ + ATH6KL_HTC_ALIGN_BYTES;
  922. return;
  923. }