txrx.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837
  1. /*
  2. * Copyright (c) 2004-2011 Atheros Communications Inc.
  3. * Copyright (c) 2011-2012 Qualcomm Atheros, Inc.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #include "core.h"
  18. #include "debug.h"
  19. /*
  20. * tid - tid_mux0..tid_mux3
  21. * aid - tid_mux4..tid_mux7
  22. */
  23. #define ATH6KL_TID_MASK 0xf
  24. #define ATH6KL_AID_SHIFT 4
  25. static inline u8 ath6kl_get_tid(u8 tid_mux)
  26. {
  27. return tid_mux & ATH6KL_TID_MASK;
  28. }
  29. static inline u8 ath6kl_get_aid(u8 tid_mux)
  30. {
  31. return tid_mux >> ATH6KL_AID_SHIFT;
  32. }
  33. static u8 ath6kl_ibss_map_epid(struct sk_buff *skb, struct net_device *dev,
  34. u32 *map_no)
  35. {
  36. struct ath6kl *ar = ath6kl_priv(dev);
  37. struct ethhdr *eth_hdr;
  38. u32 i, ep_map = -1;
  39. u8 *datap;
  40. *map_no = 0;
  41. datap = skb->data;
  42. eth_hdr = (struct ethhdr *) (datap + sizeof(struct wmi_data_hdr));
  43. if (is_multicast_ether_addr(eth_hdr->h_dest))
  44. return ENDPOINT_2;
  45. for (i = 0; i < ar->node_num; i++) {
  46. if (memcmp(eth_hdr->h_dest, ar->node_map[i].mac_addr,
  47. ETH_ALEN) == 0) {
  48. *map_no = i + 1;
  49. ar->node_map[i].tx_pend++;
  50. return ar->node_map[i].ep_id;
  51. }
  52. if ((ep_map == -1) && !ar->node_map[i].tx_pend)
  53. ep_map = i;
  54. }
  55. if (ep_map == -1) {
  56. ep_map = ar->node_num;
  57. ar->node_num++;
  58. if (ar->node_num > MAX_NODE_NUM)
  59. return ENDPOINT_UNUSED;
  60. }
  61. memcpy(ar->node_map[ep_map].mac_addr, eth_hdr->h_dest, ETH_ALEN);
  62. for (i = ENDPOINT_2; i <= ENDPOINT_5; i++) {
  63. if (!ar->tx_pending[i]) {
  64. ar->node_map[ep_map].ep_id = i;
  65. break;
  66. }
  67. /*
  68. * No free endpoint is available, start redistribution on
  69. * the inuse endpoints.
  70. */
  71. if (i == ENDPOINT_5) {
  72. ar->node_map[ep_map].ep_id = ar->next_ep_id;
  73. ar->next_ep_id++;
  74. if (ar->next_ep_id > ENDPOINT_5)
  75. ar->next_ep_id = ENDPOINT_2;
  76. }
  77. }
  78. *map_no = ep_map + 1;
  79. ar->node_map[ep_map].tx_pend++;
  80. return ar->node_map[ep_map].ep_id;
  81. }
  82. static bool ath6kl_process_uapsdq(struct ath6kl_sta *conn,
  83. struct ath6kl_vif *vif,
  84. struct sk_buff *skb,
  85. u32 *flags)
  86. {
  87. struct ath6kl *ar = vif->ar;
  88. bool is_apsdq_empty = false;
  89. struct ethhdr *datap = (struct ethhdr *) skb->data;
  90. u8 up = 0, traffic_class, *ip_hdr;
  91. u16 ether_type;
  92. struct ath6kl_llc_snap_hdr *llc_hdr;
  93. if (conn->sta_flags & STA_PS_APSD_TRIGGER) {
  94. /*
  95. * This tx is because of a uAPSD trigger, determine
  96. * more and EOSP bit. Set EOSP if queue is empty
  97. * or sufficient frames are delivered for this trigger.
  98. */
  99. spin_lock_bh(&conn->psq_lock);
  100. if (!skb_queue_empty(&conn->apsdq))
  101. *flags |= WMI_DATA_HDR_FLAGS_MORE;
  102. else if (conn->sta_flags & STA_PS_APSD_EOSP)
  103. *flags |= WMI_DATA_HDR_FLAGS_EOSP;
  104. *flags |= WMI_DATA_HDR_FLAGS_UAPSD;
  105. spin_unlock_bh(&conn->psq_lock);
  106. return false;
  107. } else if (!conn->apsd_info)
  108. return false;
  109. if (test_bit(WMM_ENABLED, &vif->flags)) {
  110. ether_type = be16_to_cpu(datap->h_proto);
  111. if (is_ethertype(ether_type)) {
  112. /* packet is in DIX format */
  113. ip_hdr = (u8 *)(datap + 1);
  114. } else {
  115. /* packet is in 802.3 format */
  116. llc_hdr = (struct ath6kl_llc_snap_hdr *)
  117. (datap + 1);
  118. ether_type = be16_to_cpu(llc_hdr->eth_type);
  119. ip_hdr = (u8 *)(llc_hdr + 1);
  120. }
  121. if (ether_type == IP_ETHERTYPE)
  122. up = ath6kl_wmi_determine_user_priority(
  123. ip_hdr, 0);
  124. }
  125. traffic_class = ath6kl_wmi_get_traffic_class(up);
  126. if ((conn->apsd_info & (1 << traffic_class)) == 0)
  127. return false;
  128. /* Queue the frames if the STA is sleeping */
  129. spin_lock_bh(&conn->psq_lock);
  130. is_apsdq_empty = skb_queue_empty(&conn->apsdq);
  131. skb_queue_tail(&conn->apsdq, skb);
  132. spin_unlock_bh(&conn->psq_lock);
  133. /*
  134. * If this is the first pkt getting queued
  135. * for this STA, update the PVB for this STA
  136. */
  137. if (is_apsdq_empty) {
  138. ath6kl_wmi_set_apsd_bfrd_traf(ar->wmi,
  139. vif->fw_vif_idx,
  140. conn->aid, 1, 0);
  141. }
  142. *flags |= WMI_DATA_HDR_FLAGS_UAPSD;
  143. return true;
  144. }
  145. static bool ath6kl_process_psq(struct ath6kl_sta *conn,
  146. struct ath6kl_vif *vif,
  147. struct sk_buff *skb,
  148. u32 *flags)
  149. {
  150. bool is_psq_empty = false;
  151. struct ath6kl *ar = vif->ar;
  152. if (conn->sta_flags & STA_PS_POLLED) {
  153. spin_lock_bh(&conn->psq_lock);
  154. if (!skb_queue_empty(&conn->psq))
  155. *flags |= WMI_DATA_HDR_FLAGS_MORE;
  156. spin_unlock_bh(&conn->psq_lock);
  157. return false;
  158. }
  159. /* Queue the frames if the STA is sleeping */
  160. spin_lock_bh(&conn->psq_lock);
  161. is_psq_empty = skb_queue_empty(&conn->psq);
  162. skb_queue_tail(&conn->psq, skb);
  163. spin_unlock_bh(&conn->psq_lock);
  164. /*
  165. * If this is the first pkt getting queued
  166. * for this STA, update the PVB for this
  167. * STA.
  168. */
  169. if (is_psq_empty)
  170. ath6kl_wmi_set_pvb_cmd(ar->wmi,
  171. vif->fw_vif_idx,
  172. conn->aid, 1);
  173. return true;
  174. }
  175. static bool ath6kl_powersave_ap(struct ath6kl_vif *vif, struct sk_buff *skb,
  176. u32 *flags)
  177. {
  178. struct ethhdr *datap = (struct ethhdr *) skb->data;
  179. struct ath6kl_sta *conn = NULL;
  180. bool ps_queued = false;
  181. struct ath6kl *ar = vif->ar;
  182. if (is_multicast_ether_addr(datap->h_dest)) {
  183. u8 ctr = 0;
  184. bool q_mcast = false;
  185. for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) {
  186. if (ar->sta_list[ctr].sta_flags & STA_PS_SLEEP) {
  187. q_mcast = true;
  188. break;
  189. }
  190. }
  191. if (q_mcast) {
  192. /*
  193. * If this transmit is not because of a Dtim Expiry
  194. * q it.
  195. */
  196. if (!test_bit(DTIM_EXPIRED, &vif->flags)) {
  197. bool is_mcastq_empty = false;
  198. spin_lock_bh(&ar->mcastpsq_lock);
  199. is_mcastq_empty =
  200. skb_queue_empty(&ar->mcastpsq);
  201. skb_queue_tail(&ar->mcastpsq, skb);
  202. spin_unlock_bh(&ar->mcastpsq_lock);
  203. /*
  204. * If this is the first Mcast pkt getting
  205. * queued indicate to the target to set the
  206. * BitmapControl LSB of the TIM IE.
  207. */
  208. if (is_mcastq_empty)
  209. ath6kl_wmi_set_pvb_cmd(ar->wmi,
  210. vif->fw_vif_idx,
  211. MCAST_AID, 1);
  212. ps_queued = true;
  213. } else {
  214. /*
  215. * This transmit is because of Dtim expiry.
  216. * Determine if MoreData bit has to be set.
  217. */
  218. spin_lock_bh(&ar->mcastpsq_lock);
  219. if (!skb_queue_empty(&ar->mcastpsq))
  220. *flags |= WMI_DATA_HDR_FLAGS_MORE;
  221. spin_unlock_bh(&ar->mcastpsq_lock);
  222. }
  223. }
  224. } else {
  225. conn = ath6kl_find_sta(vif, datap->h_dest);
  226. if (!conn) {
  227. dev_kfree_skb(skb);
  228. /* Inform the caller that the skb is consumed */
  229. return true;
  230. }
  231. if (conn->sta_flags & STA_PS_SLEEP) {
  232. ps_queued = ath6kl_process_uapsdq(conn,
  233. vif, skb, flags);
  234. if (!(*flags & WMI_DATA_HDR_FLAGS_UAPSD))
  235. ps_queued = ath6kl_process_psq(conn,
  236. vif, skb, flags);
  237. }
  238. }
  239. return ps_queued;
  240. }
  241. /* Tx functions */
  242. int ath6kl_control_tx(void *devt, struct sk_buff *skb,
  243. enum htc_endpoint_id eid)
  244. {
  245. struct ath6kl *ar = devt;
  246. int status = 0;
  247. struct ath6kl_cookie *cookie = NULL;
  248. if (WARN_ON_ONCE(ar->state == ATH6KL_STATE_WOW))
  249. return -EACCES;
  250. spin_lock_bh(&ar->lock);
  251. ath6kl_dbg(ATH6KL_DBG_WLAN_TX,
  252. "%s: skb=0x%p, len=0x%x eid =%d\n", __func__,
  253. skb, skb->len, eid);
  254. if (test_bit(WMI_CTRL_EP_FULL, &ar->flag) && (eid == ar->ctrl_ep)) {
  255. /*
  256. * Control endpoint is full, don't allocate resources, we
  257. * are just going to drop this packet.
  258. */
  259. cookie = NULL;
  260. ath6kl_err("wmi ctrl ep full, dropping pkt : 0x%p, len:%d\n",
  261. skb, skb->len);
  262. } else
  263. cookie = ath6kl_alloc_cookie(ar);
  264. if (cookie == NULL) {
  265. spin_unlock_bh(&ar->lock);
  266. status = -ENOMEM;
  267. goto fail_ctrl_tx;
  268. }
  269. ar->tx_pending[eid]++;
  270. if (eid != ar->ctrl_ep)
  271. ar->total_tx_data_pend++;
  272. spin_unlock_bh(&ar->lock);
  273. cookie->skb = skb;
  274. cookie->map_no = 0;
  275. set_htc_pkt_info(&cookie->htc_pkt, cookie, skb->data, skb->len,
  276. eid, ATH6KL_CONTROL_PKT_TAG);
  277. /*
  278. * This interface is asynchronous, if there is an error, cleanup
  279. * will happen in the TX completion callback.
  280. */
  281. ath6kl_htc_tx(ar->htc_target, &cookie->htc_pkt);
  282. return 0;
  283. fail_ctrl_tx:
  284. dev_kfree_skb(skb);
  285. return status;
  286. }
  287. int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev)
  288. {
  289. struct ath6kl *ar = ath6kl_priv(dev);
  290. struct ath6kl_cookie *cookie = NULL;
  291. enum htc_endpoint_id eid = ENDPOINT_UNUSED;
  292. struct ath6kl_vif *vif = netdev_priv(dev);
  293. u32 map_no = 0;
  294. u16 htc_tag = ATH6KL_DATA_PKT_TAG;
  295. u8 ac = 99 ; /* initialize to unmapped ac */
  296. bool chk_adhoc_ps_mapping = false;
  297. int ret;
  298. struct wmi_tx_meta_v2 meta_v2;
  299. void *meta;
  300. u8 csum_start = 0, csum_dest = 0, csum = skb->ip_summed;
  301. u8 meta_ver = 0;
  302. u32 flags = 0;
  303. ath6kl_dbg(ATH6KL_DBG_WLAN_TX,
  304. "%s: skb=0x%p, data=0x%p, len=0x%x\n", __func__,
  305. skb, skb->data, skb->len);
  306. /* If target is not associated */
  307. if (!test_bit(CONNECTED, &vif->flags)) {
  308. dev_kfree_skb(skb);
  309. return 0;
  310. }
  311. if (WARN_ON_ONCE(ar->state != ATH6KL_STATE_ON)) {
  312. dev_kfree_skb(skb);
  313. return 0;
  314. }
  315. if (!test_bit(WMI_READY, &ar->flag))
  316. goto fail_tx;
  317. /* AP mode Power saving processing */
  318. if (vif->nw_type == AP_NETWORK) {
  319. if (ath6kl_powersave_ap(vif, skb, &flags))
  320. return 0;
  321. }
  322. if (test_bit(WMI_ENABLED, &ar->flag)) {
  323. if ((dev->features & NETIF_F_IP_CSUM) &&
  324. (csum == CHECKSUM_PARTIAL)) {
  325. csum_start = skb->csum_start -
  326. (skb_network_header(skb) - skb->head) +
  327. sizeof(struct ath6kl_llc_snap_hdr);
  328. csum_dest = skb->csum_offset + csum_start;
  329. }
  330. if (skb_headroom(skb) < dev->needed_headroom) {
  331. struct sk_buff *tmp_skb = skb;
  332. skb = skb_realloc_headroom(skb, dev->needed_headroom);
  333. kfree_skb(tmp_skb);
  334. if (skb == NULL) {
  335. vif->net_stats.tx_dropped++;
  336. return 0;
  337. }
  338. }
  339. if (ath6kl_wmi_dix_2_dot3(ar->wmi, skb)) {
  340. ath6kl_err("ath6kl_wmi_dix_2_dot3 failed\n");
  341. goto fail_tx;
  342. }
  343. if ((dev->features & NETIF_F_IP_CSUM) &&
  344. (csum == CHECKSUM_PARTIAL)) {
  345. meta_v2.csum_start = csum_start;
  346. meta_v2.csum_dest = csum_dest;
  347. /* instruct target to calculate checksum */
  348. meta_v2.csum_flags = WMI_META_V2_FLAG_CSUM_OFFLOAD;
  349. meta_ver = WMI_META_VERSION_2;
  350. meta = &meta_v2;
  351. } else {
  352. meta_ver = 0;
  353. meta = NULL;
  354. }
  355. ret = ath6kl_wmi_data_hdr_add(ar->wmi, skb,
  356. DATA_MSGTYPE, flags, 0,
  357. meta_ver,
  358. meta, vif->fw_vif_idx);
  359. if (ret) {
  360. ath6kl_warn("failed to add wmi data header:%d\n"
  361. , ret);
  362. goto fail_tx;
  363. }
  364. if ((vif->nw_type == ADHOC_NETWORK) &&
  365. ar->ibss_ps_enable && test_bit(CONNECTED, &vif->flags))
  366. chk_adhoc_ps_mapping = true;
  367. else {
  368. /* get the stream mapping */
  369. ret = ath6kl_wmi_implicit_create_pstream(ar->wmi,
  370. vif->fw_vif_idx, skb,
  371. 0, test_bit(WMM_ENABLED, &vif->flags), &ac);
  372. if (ret)
  373. goto fail_tx;
  374. }
  375. } else
  376. goto fail_tx;
  377. spin_lock_bh(&ar->lock);
  378. if (chk_adhoc_ps_mapping)
  379. eid = ath6kl_ibss_map_epid(skb, dev, &map_no);
  380. else
  381. eid = ar->ac2ep_map[ac];
  382. if (eid == 0 || eid == ENDPOINT_UNUSED) {
  383. ath6kl_err("eid %d is not mapped!\n", eid);
  384. spin_unlock_bh(&ar->lock);
  385. goto fail_tx;
  386. }
  387. /* allocate resource for this packet */
  388. cookie = ath6kl_alloc_cookie(ar);
  389. if (!cookie) {
  390. spin_unlock_bh(&ar->lock);
  391. goto fail_tx;
  392. }
  393. /* update counts while the lock is held */
  394. ar->tx_pending[eid]++;
  395. ar->total_tx_data_pend++;
  396. spin_unlock_bh(&ar->lock);
  397. if (!IS_ALIGNED((unsigned long) skb->data - HTC_HDR_LENGTH, 4) &&
  398. skb_cloned(skb)) {
  399. /*
  400. * We will touch (move the buffer data to align it. Since the
  401. * skb buffer is cloned and not only the header is changed, we
  402. * have to copy it to allow the changes. Since we are copying
  403. * the data here, we may as well align it by reserving suitable
  404. * headroom to avoid the memmove in ath6kl_htc_tx_buf_align().
  405. */
  406. struct sk_buff *nskb;
  407. nskb = skb_copy_expand(skb, HTC_HDR_LENGTH, 0, GFP_ATOMIC);
  408. if (nskb == NULL)
  409. goto fail_tx;
  410. kfree_skb(skb);
  411. skb = nskb;
  412. }
  413. cookie->skb = skb;
  414. cookie->map_no = map_no;
  415. set_htc_pkt_info(&cookie->htc_pkt, cookie, skb->data, skb->len,
  416. eid, htc_tag);
  417. ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, __func__, "tx ",
  418. skb->data, skb->len);
  419. /*
  420. * HTC interface is asynchronous, if this fails, cleanup will
  421. * happen in the ath6kl_tx_complete callback.
  422. */
  423. ath6kl_htc_tx(ar->htc_target, &cookie->htc_pkt);
  424. return 0;
  425. fail_tx:
  426. dev_kfree_skb(skb);
  427. vif->net_stats.tx_dropped++;
  428. vif->net_stats.tx_aborted_errors++;
  429. return 0;
  430. }
  431. /* indicate tx activity or inactivity on a WMI stream */
  432. void ath6kl_indicate_tx_activity(void *devt, u8 traffic_class, bool active)
  433. {
  434. struct ath6kl *ar = devt;
  435. enum htc_endpoint_id eid;
  436. int i;
  437. eid = ar->ac2ep_map[traffic_class];
  438. if (!test_bit(WMI_ENABLED, &ar->flag))
  439. goto notify_htc;
  440. spin_lock_bh(&ar->lock);
  441. ar->ac_stream_active[traffic_class] = active;
  442. if (active) {
  443. /*
  444. * Keep track of the active stream with the highest
  445. * priority.
  446. */
  447. if (ar->ac_stream_pri_map[traffic_class] >
  448. ar->hiac_stream_active_pri)
  449. /* set the new highest active priority */
  450. ar->hiac_stream_active_pri =
  451. ar->ac_stream_pri_map[traffic_class];
  452. } else {
  453. /*
  454. * We may have to search for the next active stream
  455. * that is the highest priority.
  456. */
  457. if (ar->hiac_stream_active_pri ==
  458. ar->ac_stream_pri_map[traffic_class]) {
  459. /*
  460. * The highest priority stream just went inactive
  461. * reset and search for the "next" highest "active"
  462. * priority stream.
  463. */
  464. ar->hiac_stream_active_pri = 0;
  465. for (i = 0; i < WMM_NUM_AC; i++) {
  466. if (ar->ac_stream_active[i] &&
  467. (ar->ac_stream_pri_map[i] >
  468. ar->hiac_stream_active_pri))
  469. /*
  470. * Set the new highest active
  471. * priority.
  472. */
  473. ar->hiac_stream_active_pri =
  474. ar->ac_stream_pri_map[i];
  475. }
  476. }
  477. }
  478. spin_unlock_bh(&ar->lock);
  479. notify_htc:
  480. /* notify HTC, this may cause credit distribution changes */
  481. ath6kl_htc_indicate_activity_change(ar->htc_target, eid, active);
  482. }
  483. enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target,
  484. struct htc_packet *packet)
  485. {
  486. struct ath6kl *ar = target->dev->ar;
  487. struct ath6kl_vif *vif;
  488. enum htc_endpoint_id endpoint = packet->endpoint;
  489. enum htc_send_full_action action = HTC_SEND_FULL_KEEP;
  490. if (endpoint == ar->ctrl_ep) {
  491. /*
  492. * Under normal WMI if this is getting full, then something
  493. * is running rampant the host should not be exhausting the
  494. * WMI queue with too many commands the only exception to
  495. * this is during testing using endpointping.
  496. */
  497. set_bit(WMI_CTRL_EP_FULL, &ar->flag);
  498. ath6kl_err("wmi ctrl ep is full\n");
  499. return action;
  500. }
  501. if (packet->info.tx.tag == ATH6KL_CONTROL_PKT_TAG)
  502. return action;
  503. /*
  504. * The last MAX_HI_COOKIE_NUM "batch" of cookies are reserved for
  505. * the highest active stream.
  506. */
  507. if (ar->ac_stream_pri_map[ar->ep2ac_map[endpoint]] <
  508. ar->hiac_stream_active_pri &&
  509. ar->cookie_count <=
  510. target->endpoint[endpoint].tx_drop_packet_threshold)
  511. /*
  512. * Give preference to the highest priority stream by
  513. * dropping the packets which overflowed.
  514. */
  515. action = HTC_SEND_FULL_DROP;
  516. /* FIXME: Locking */
  517. spin_lock_bh(&ar->list_lock);
  518. list_for_each_entry(vif, &ar->vif_list, list) {
  519. if (vif->nw_type == ADHOC_NETWORK ||
  520. action != HTC_SEND_FULL_DROP) {
  521. spin_unlock_bh(&ar->list_lock);
  522. set_bit(NETQ_STOPPED, &vif->flags);
  523. netif_stop_queue(vif->ndev);
  524. return action;
  525. }
  526. }
  527. spin_unlock_bh(&ar->list_lock);
  528. return action;
  529. }
  530. /* TODO this needs to be looked at */
  531. static void ath6kl_tx_clear_node_map(struct ath6kl_vif *vif,
  532. enum htc_endpoint_id eid, u32 map_no)
  533. {
  534. struct ath6kl *ar = vif->ar;
  535. u32 i;
  536. if (vif->nw_type != ADHOC_NETWORK)
  537. return;
  538. if (!ar->ibss_ps_enable)
  539. return;
  540. if (eid == ar->ctrl_ep)
  541. return;
  542. if (map_no == 0)
  543. return;
  544. map_no--;
  545. ar->node_map[map_no].tx_pend--;
  546. if (ar->node_map[map_no].tx_pend)
  547. return;
  548. if (map_no != (ar->node_num - 1))
  549. return;
  550. for (i = ar->node_num; i > 0; i--) {
  551. if (ar->node_map[i - 1].tx_pend)
  552. break;
  553. memset(&ar->node_map[i - 1], 0,
  554. sizeof(struct ath6kl_node_mapping));
  555. ar->node_num--;
  556. }
  557. }
  558. void ath6kl_tx_complete(void *context, struct list_head *packet_queue)
  559. {
  560. struct ath6kl *ar = context;
  561. struct sk_buff_head skb_queue;
  562. struct htc_packet *packet;
  563. struct sk_buff *skb;
  564. struct ath6kl_cookie *ath6kl_cookie;
  565. u32 map_no = 0;
  566. int status;
  567. enum htc_endpoint_id eid;
  568. bool wake_event = false;
  569. bool flushing[ATH6KL_VIF_MAX] = {false};
  570. u8 if_idx;
  571. struct ath6kl_vif *vif;
  572. skb_queue_head_init(&skb_queue);
  573. /* lock the driver as we update internal state */
  574. spin_lock_bh(&ar->lock);
  575. /* reap completed packets */
  576. while (!list_empty(packet_queue)) {
  577. packet = list_first_entry(packet_queue, struct htc_packet,
  578. list);
  579. list_del(&packet->list);
  580. ath6kl_cookie = (struct ath6kl_cookie *)packet->pkt_cntxt;
  581. if (!ath6kl_cookie)
  582. goto fatal;
  583. status = packet->status;
  584. skb = ath6kl_cookie->skb;
  585. eid = packet->endpoint;
  586. map_no = ath6kl_cookie->map_no;
  587. if (!skb || !skb->data)
  588. goto fatal;
  589. __skb_queue_tail(&skb_queue, skb);
  590. if (!status && (packet->act_len != skb->len))
  591. goto fatal;
  592. ar->tx_pending[eid]--;
  593. if (eid != ar->ctrl_ep)
  594. ar->total_tx_data_pend--;
  595. if (eid == ar->ctrl_ep) {
  596. if (test_bit(WMI_CTRL_EP_FULL, &ar->flag))
  597. clear_bit(WMI_CTRL_EP_FULL, &ar->flag);
  598. if (ar->tx_pending[eid] == 0)
  599. wake_event = true;
  600. }
  601. if (eid == ar->ctrl_ep) {
  602. if_idx = wmi_cmd_hdr_get_if_idx(
  603. (struct wmi_cmd_hdr *) packet->buf);
  604. } else {
  605. if_idx = wmi_data_hdr_get_if_idx(
  606. (struct wmi_data_hdr *) packet->buf);
  607. }
  608. vif = ath6kl_get_vif_by_index(ar, if_idx);
  609. if (!vif) {
  610. ath6kl_free_cookie(ar, ath6kl_cookie);
  611. continue;
  612. }
  613. if (status) {
  614. if (status == -ECANCELED)
  615. /* a packet was flushed */
  616. flushing[if_idx] = true;
  617. vif->net_stats.tx_errors++;
  618. if (status != -ENOSPC && status != -ECANCELED)
  619. ath6kl_warn("tx complete error: %d\n", status);
  620. ath6kl_dbg(ATH6KL_DBG_WLAN_TX,
  621. "%s: skb=0x%p data=0x%p len=0x%x eid=%d %s\n",
  622. __func__, skb, packet->buf, packet->act_len,
  623. eid, "error!");
  624. } else {
  625. ath6kl_dbg(ATH6KL_DBG_WLAN_TX,
  626. "%s: skb=0x%p data=0x%p len=0x%x eid=%d %s\n",
  627. __func__, skb, packet->buf, packet->act_len,
  628. eid, "OK");
  629. flushing[if_idx] = false;
  630. vif->net_stats.tx_packets++;
  631. vif->net_stats.tx_bytes += skb->len;
  632. }
  633. ath6kl_tx_clear_node_map(vif, eid, map_no);
  634. ath6kl_free_cookie(ar, ath6kl_cookie);
  635. if (test_bit(NETQ_STOPPED, &vif->flags))
  636. clear_bit(NETQ_STOPPED, &vif->flags);
  637. }
  638. spin_unlock_bh(&ar->lock);
  639. __skb_queue_purge(&skb_queue);
  640. /* FIXME: Locking */
  641. spin_lock_bh(&ar->list_lock);
  642. list_for_each_entry(vif, &ar->vif_list, list) {
  643. if (test_bit(CONNECTED, &vif->flags) &&
  644. !flushing[vif->fw_vif_idx]) {
  645. spin_unlock_bh(&ar->list_lock);
  646. netif_wake_queue(vif->ndev);
  647. spin_lock_bh(&ar->list_lock);
  648. }
  649. }
  650. spin_unlock_bh(&ar->list_lock);
  651. if (wake_event)
  652. wake_up(&ar->event_wq);
  653. return;
  654. fatal:
  655. WARN_ON(1);
  656. spin_unlock_bh(&ar->lock);
  657. return;
  658. }
  659. void ath6kl_tx_data_cleanup(struct ath6kl *ar)
  660. {
  661. int i;
  662. /* flush all the data (non-control) streams */
  663. for (i = 0; i < WMM_NUM_AC; i++)
  664. ath6kl_htc_flush_txep(ar->htc_target, ar->ac2ep_map[i],
  665. ATH6KL_DATA_PKT_TAG);
  666. }
  667. /* Rx functions */
  668. static void ath6kl_deliver_frames_to_nw_stack(struct net_device *dev,
  669. struct sk_buff *skb)
  670. {
  671. if (!skb)
  672. return;
  673. skb->dev = dev;
  674. if (!(skb->dev->flags & IFF_UP)) {
  675. dev_kfree_skb(skb);
  676. return;
  677. }
  678. skb->protocol = eth_type_trans(skb, skb->dev);
  679. netif_rx_ni(skb);
  680. }
  681. static void ath6kl_alloc_netbufs(struct sk_buff_head *q, u16 num)
  682. {
  683. struct sk_buff *skb;
  684. while (num) {
  685. skb = ath6kl_buf_alloc(ATH6KL_BUFFER_SIZE);
  686. if (!skb) {
  687. ath6kl_err("netbuf allocation failed\n");
  688. return;
  689. }
  690. skb_queue_tail(q, skb);
  691. num--;
  692. }
  693. }
  694. static struct sk_buff *aggr_get_free_skb(struct aggr_info *p_aggr)
  695. {
  696. struct sk_buff *skb = NULL;
  697. if (skb_queue_len(&p_aggr->rx_amsdu_freeq) <
  698. (AGGR_NUM_OF_FREE_NETBUFS >> 2))
  699. ath6kl_alloc_netbufs(&p_aggr->rx_amsdu_freeq,
  700. AGGR_NUM_OF_FREE_NETBUFS);
  701. skb = skb_dequeue(&p_aggr->rx_amsdu_freeq);
  702. return skb;
  703. }
  704. void ath6kl_rx_refill(struct htc_target *target, enum htc_endpoint_id endpoint)
  705. {
  706. struct ath6kl *ar = target->dev->ar;
  707. struct sk_buff *skb;
  708. int rx_buf;
  709. int n_buf_refill;
  710. struct htc_packet *packet;
  711. struct list_head queue;
  712. n_buf_refill = ATH6KL_MAX_RX_BUFFERS -
  713. ath6kl_htc_get_rxbuf_num(ar->htc_target, endpoint);
  714. if (n_buf_refill <= 0)
  715. return;
  716. INIT_LIST_HEAD(&queue);
  717. ath6kl_dbg(ATH6KL_DBG_WLAN_RX,
  718. "%s: providing htc with %d buffers at eid=%d\n",
  719. __func__, n_buf_refill, endpoint);
  720. for (rx_buf = 0; rx_buf < n_buf_refill; rx_buf++) {
  721. skb = ath6kl_buf_alloc(ATH6KL_BUFFER_SIZE);
  722. if (!skb)
  723. break;
  724. packet = (struct htc_packet *) skb->head;
  725. if (!IS_ALIGNED((unsigned long) skb->data, 4))
  726. skb->data = PTR_ALIGN(skb->data - 4, 4);
  727. set_htc_rxpkt_info(packet, skb, skb->data,
  728. ATH6KL_BUFFER_SIZE, endpoint);
  729. list_add_tail(&packet->list, &queue);
  730. }
  731. if (!list_empty(&queue))
  732. ath6kl_htc_add_rxbuf_multiple(ar->htc_target, &queue);
  733. }
  734. void ath6kl_refill_amsdu_rxbufs(struct ath6kl *ar, int count)
  735. {
  736. struct htc_packet *packet;
  737. struct sk_buff *skb;
  738. while (count) {
  739. skb = ath6kl_buf_alloc(ATH6KL_AMSDU_BUFFER_SIZE);
  740. if (!skb)
  741. return;
  742. packet = (struct htc_packet *) skb->head;
  743. if (!IS_ALIGNED((unsigned long) skb->data, 4))
  744. skb->data = PTR_ALIGN(skb->data - 4, 4);
  745. set_htc_rxpkt_info(packet, skb, skb->data,
  746. ATH6KL_AMSDU_BUFFER_SIZE, 0);
  747. spin_lock_bh(&ar->lock);
  748. list_add_tail(&packet->list, &ar->amsdu_rx_buffer_queue);
  749. spin_unlock_bh(&ar->lock);
  750. count--;
  751. }
  752. }
  753. /*
  754. * Callback to allocate a receive buffer for a pending packet. We use a
  755. * pre-allocated list of buffers of maximum AMSDU size (4K).
  756. */
  757. struct htc_packet *ath6kl_alloc_amsdu_rxbuf(struct htc_target *target,
  758. enum htc_endpoint_id endpoint,
  759. int len)
  760. {
  761. struct ath6kl *ar = target->dev->ar;
  762. struct htc_packet *packet = NULL;
  763. struct list_head *pkt_pos;
  764. int refill_cnt = 0, depth = 0;
  765. ath6kl_dbg(ATH6KL_DBG_WLAN_RX, "%s: eid=%d, len:%d\n",
  766. __func__, endpoint, len);
  767. if ((len <= ATH6KL_BUFFER_SIZE) ||
  768. (len > ATH6KL_AMSDU_BUFFER_SIZE))
  769. return NULL;
  770. spin_lock_bh(&ar->lock);
  771. if (list_empty(&ar->amsdu_rx_buffer_queue)) {
  772. spin_unlock_bh(&ar->lock);
  773. refill_cnt = ATH6KL_MAX_AMSDU_RX_BUFFERS;
  774. goto refill_buf;
  775. }
  776. packet = list_first_entry(&ar->amsdu_rx_buffer_queue,
  777. struct htc_packet, list);
  778. list_del(&packet->list);
  779. list_for_each(pkt_pos, &ar->amsdu_rx_buffer_queue)
  780. depth++;
  781. refill_cnt = ATH6KL_MAX_AMSDU_RX_BUFFERS - depth;
  782. spin_unlock_bh(&ar->lock);
  783. /* set actual endpoint ID */
  784. packet->endpoint = endpoint;
  785. refill_buf:
  786. if (refill_cnt >= ATH6KL_AMSDU_REFILL_THRESHOLD)
  787. ath6kl_refill_amsdu_rxbufs(ar, refill_cnt);
  788. return packet;
  789. }
  790. static void aggr_slice_amsdu(struct aggr_info *p_aggr,
  791. struct rxtid *rxtid, struct sk_buff *skb)
  792. {
  793. struct sk_buff *new_skb;
  794. struct ethhdr *hdr;
  795. u16 frame_8023_len, payload_8023_len, mac_hdr_len, amsdu_len;
  796. u8 *framep;
  797. mac_hdr_len = sizeof(struct ethhdr);
  798. framep = skb->data + mac_hdr_len;
  799. amsdu_len = skb->len - mac_hdr_len;
  800. while (amsdu_len > mac_hdr_len) {
  801. hdr = (struct ethhdr *) framep;
  802. payload_8023_len = ntohs(hdr->h_proto);
  803. if (payload_8023_len < MIN_MSDU_SUBFRAME_PAYLOAD_LEN ||
  804. payload_8023_len > MAX_MSDU_SUBFRAME_PAYLOAD_LEN) {
  805. ath6kl_err("802.3 AMSDU frame bound check failed. len %d\n",
  806. payload_8023_len);
  807. break;
  808. }
  809. frame_8023_len = payload_8023_len + mac_hdr_len;
  810. new_skb = aggr_get_free_skb(p_aggr);
  811. if (!new_skb) {
  812. ath6kl_err("no buffer available\n");
  813. break;
  814. }
  815. memcpy(new_skb->data, framep, frame_8023_len);
  816. skb_put(new_skb, frame_8023_len);
  817. if (ath6kl_wmi_dot3_2_dix(new_skb)) {
  818. ath6kl_err("dot3_2_dix error\n");
  819. dev_kfree_skb(new_skb);
  820. break;
  821. }
  822. skb_queue_tail(&rxtid->q, new_skb);
  823. /* Is this the last subframe within this aggregate ? */
  824. if ((amsdu_len - frame_8023_len) == 0)
  825. break;
  826. /* Add the length of A-MSDU subframe padding bytes -
  827. * Round to nearest word.
  828. */
  829. frame_8023_len = ALIGN(frame_8023_len, 4);
  830. framep += frame_8023_len;
  831. amsdu_len -= frame_8023_len;
  832. }
  833. dev_kfree_skb(skb);
  834. }
  835. static void aggr_deque_frms(struct aggr_info_conn *agg_conn, u8 tid,
  836. u16 seq_no, u8 order)
  837. {
  838. struct sk_buff *skb;
  839. struct rxtid *rxtid;
  840. struct skb_hold_q *node;
  841. u16 idx, idx_end, seq_end;
  842. struct rxtid_stats *stats;
  843. rxtid = &agg_conn->rx_tid[tid];
  844. stats = &agg_conn->stat[tid];
  845. idx = AGGR_WIN_IDX(rxtid->seq_next, rxtid->hold_q_sz);
  846. /*
  847. * idx_end is typically the last possible frame in the window,
  848. * but changes to 'the' seq_no, when BAR comes. If seq_no
  849. * is non-zero, we will go up to that and stop.
  850. * Note: last seq no in current window will occupy the same
  851. * index position as index that is just previous to start.
  852. * An imp point : if win_sz is 7, for seq_no space of 4095,
  853. * then, there would be holes when sequence wrap around occurs.
  854. * Target should judiciously choose the win_sz, based on
  855. * this condition. For 4095, (TID_WINDOW_SZ = 2 x win_sz
  856. * 2, 4, 8, 16 win_sz works fine).
  857. * We must deque from "idx" to "idx_end", including both.
  858. */
  859. seq_end = seq_no ? seq_no : rxtid->seq_next;
  860. idx_end = AGGR_WIN_IDX(seq_end, rxtid->hold_q_sz);
  861. spin_lock_bh(&rxtid->lock);
  862. do {
  863. node = &rxtid->hold_q[idx];
  864. if ((order == 1) && (!node->skb))
  865. break;
  866. if (node->skb) {
  867. if (node->is_amsdu)
  868. aggr_slice_amsdu(agg_conn->aggr_info, rxtid,
  869. node->skb);
  870. else
  871. skb_queue_tail(&rxtid->q, node->skb);
  872. node->skb = NULL;
  873. } else
  874. stats->num_hole++;
  875. rxtid->seq_next = ATH6KL_NEXT_SEQ_NO(rxtid->seq_next);
  876. idx = AGGR_WIN_IDX(rxtid->seq_next, rxtid->hold_q_sz);
  877. } while (idx != idx_end);
  878. spin_unlock_bh(&rxtid->lock);
  879. stats->num_delivered += skb_queue_len(&rxtid->q);
  880. while ((skb = skb_dequeue(&rxtid->q)))
  881. ath6kl_deliver_frames_to_nw_stack(agg_conn->dev, skb);
  882. }
  883. static bool aggr_process_recv_frm(struct aggr_info_conn *agg_conn, u8 tid,
  884. u16 seq_no,
  885. bool is_amsdu, struct sk_buff *frame)
  886. {
  887. struct rxtid *rxtid;
  888. struct rxtid_stats *stats;
  889. struct sk_buff *skb;
  890. struct skb_hold_q *node;
  891. u16 idx, st, cur, end;
  892. bool is_queued = false;
  893. u16 extended_end;
  894. rxtid = &agg_conn->rx_tid[tid];
  895. stats = &agg_conn->stat[tid];
  896. stats->num_into_aggr++;
  897. if (!rxtid->aggr) {
  898. if (is_amsdu) {
  899. aggr_slice_amsdu(agg_conn->aggr_info, rxtid, frame);
  900. is_queued = true;
  901. stats->num_amsdu++;
  902. while ((skb = skb_dequeue(&rxtid->q)))
  903. ath6kl_deliver_frames_to_nw_stack(agg_conn->dev,
  904. skb);
  905. }
  906. return is_queued;
  907. }
  908. /* Check the incoming sequence no, if it's in the window */
  909. st = rxtid->seq_next;
  910. cur = seq_no;
  911. end = (st + rxtid->hold_q_sz-1) & ATH6KL_MAX_SEQ_NO;
  912. if (((st < end) && (cur < st || cur > end)) ||
  913. ((st > end) && (cur > end) && (cur < st))) {
  914. extended_end = (end + rxtid->hold_q_sz - 1) &
  915. ATH6KL_MAX_SEQ_NO;
  916. if (((end < extended_end) &&
  917. (cur < end || cur > extended_end)) ||
  918. ((end > extended_end) && (cur > extended_end) &&
  919. (cur < end))) {
  920. aggr_deque_frms(agg_conn, tid, 0, 0);
  921. if (cur >= rxtid->hold_q_sz - 1)
  922. rxtid->seq_next = cur - (rxtid->hold_q_sz - 1);
  923. else
  924. rxtid->seq_next = ATH6KL_MAX_SEQ_NO -
  925. (rxtid->hold_q_sz - 2 - cur);
  926. } else {
  927. /*
  928. * Dequeue only those frames that are outside the
  929. * new shifted window.
  930. */
  931. if (cur >= rxtid->hold_q_sz - 1)
  932. st = cur - (rxtid->hold_q_sz - 1);
  933. else
  934. st = ATH6KL_MAX_SEQ_NO -
  935. (rxtid->hold_q_sz - 2 - cur);
  936. aggr_deque_frms(agg_conn, tid, st, 0);
  937. }
  938. stats->num_oow++;
  939. }
  940. idx = AGGR_WIN_IDX(seq_no, rxtid->hold_q_sz);
  941. node = &rxtid->hold_q[idx];
  942. spin_lock_bh(&rxtid->lock);
  943. /*
  944. * Is the cur frame duplicate or something beyond our window(hold_q
  945. * -> which is 2x, already)?
  946. *
  947. * 1. Duplicate is easy - drop incoming frame.
  948. * 2. Not falling in current sliding window.
  949. * 2a. is the frame_seq_no preceding current tid_seq_no?
  950. * -> drop the frame. perhaps sender did not get our ACK.
  951. * this is taken care of above.
  952. * 2b. is the frame_seq_no beyond window(st, TID_WINDOW_SZ);
  953. * -> Taken care of it above, by moving window forward.
  954. */
  955. dev_kfree_skb(node->skb);
  956. stats->num_dups++;
  957. node->skb = frame;
  958. is_queued = true;
  959. node->is_amsdu = is_amsdu;
  960. node->seq_no = seq_no;
  961. if (node->is_amsdu)
  962. stats->num_amsdu++;
  963. else
  964. stats->num_mpdu++;
  965. spin_unlock_bh(&rxtid->lock);
  966. aggr_deque_frms(agg_conn, tid, 0, 1);
  967. if (agg_conn->timer_scheduled)
  968. rxtid->progress = true;
  969. else
  970. for (idx = 0 ; idx < rxtid->hold_q_sz; idx++) {
  971. if (rxtid->hold_q[idx].skb) {
  972. /*
  973. * There is a frame in the queue and no
  974. * timer so start a timer to ensure that
  975. * the frame doesn't remain stuck
  976. * forever.
  977. */
  978. agg_conn->timer_scheduled = true;
  979. mod_timer(&agg_conn->timer,
  980. (jiffies +
  981. HZ * (AGGR_RX_TIMEOUT) / 1000));
  982. rxtid->progress = false;
  983. rxtid->timer_mon = true;
  984. break;
  985. }
  986. }
  987. return is_queued;
  988. }
  989. static void ath6kl_uapsd_trigger_frame_rx(struct ath6kl_vif *vif,
  990. struct ath6kl_sta *conn)
  991. {
  992. struct ath6kl *ar = vif->ar;
  993. bool is_apsdq_empty, is_apsdq_empty_at_start;
  994. u32 num_frames_to_deliver, flags;
  995. struct sk_buff *skb = NULL;
  996. /*
  997. * If the APSD q for this STA is not empty, dequeue and
  998. * send a pkt from the head of the q. Also update the
  999. * More data bit in the WMI_DATA_HDR if there are
  1000. * more pkts for this STA in the APSD q.
  1001. * If there are no more pkts for this STA,
  1002. * update the APSD bitmap for this STA.
  1003. */
  1004. num_frames_to_deliver = (conn->apsd_info >> ATH6KL_APSD_NUM_OF_AC) &
  1005. ATH6KL_APSD_FRAME_MASK;
  1006. /*
  1007. * Number of frames to send in a service period is
  1008. * indicated by the station
  1009. * in the QOS_INFO of the association request
  1010. * If it is zero, send all frames
  1011. */
  1012. if (!num_frames_to_deliver)
  1013. num_frames_to_deliver = ATH6KL_APSD_ALL_FRAME;
  1014. spin_lock_bh(&conn->psq_lock);
  1015. is_apsdq_empty = skb_queue_empty(&conn->apsdq);
  1016. spin_unlock_bh(&conn->psq_lock);
  1017. is_apsdq_empty_at_start = is_apsdq_empty;
  1018. while ((!is_apsdq_empty) && (num_frames_to_deliver)) {
  1019. spin_lock_bh(&conn->psq_lock);
  1020. skb = skb_dequeue(&conn->apsdq);
  1021. is_apsdq_empty = skb_queue_empty(&conn->apsdq);
  1022. spin_unlock_bh(&conn->psq_lock);
  1023. /*
  1024. * Set the STA flag to Trigger delivery,
  1025. * so that the frame will go out
  1026. */
  1027. conn->sta_flags |= STA_PS_APSD_TRIGGER;
  1028. num_frames_to_deliver--;
  1029. /* Last frame in the service period, set EOSP or queue empty */
  1030. if ((is_apsdq_empty) || (!num_frames_to_deliver))
  1031. conn->sta_flags |= STA_PS_APSD_EOSP;
  1032. ath6kl_data_tx(skb, vif->ndev);
  1033. conn->sta_flags &= ~(STA_PS_APSD_TRIGGER);
  1034. conn->sta_flags &= ~(STA_PS_APSD_EOSP);
  1035. }
  1036. if (is_apsdq_empty) {
  1037. if (is_apsdq_empty_at_start)
  1038. flags = WMI_AP_APSD_NO_DELIVERY_FRAMES;
  1039. else
  1040. flags = 0;
  1041. ath6kl_wmi_set_apsd_bfrd_traf(ar->wmi,
  1042. vif->fw_vif_idx,
  1043. conn->aid, 0, flags);
  1044. }
  1045. return;
  1046. }
  1047. void ath6kl_rx(struct htc_target *target, struct htc_packet *packet)
  1048. {
  1049. struct ath6kl *ar = target->dev->ar;
  1050. struct sk_buff *skb = packet->pkt_cntxt;
  1051. struct wmi_rx_meta_v2 *meta;
  1052. struct wmi_data_hdr *dhdr;
  1053. int min_hdr_len;
  1054. u8 meta_type, dot11_hdr = 0;
  1055. int status = packet->status;
  1056. enum htc_endpoint_id ept = packet->endpoint;
  1057. bool is_amsdu, prev_ps, ps_state = false;
  1058. bool trig_state = false;
  1059. struct ath6kl_sta *conn = NULL;
  1060. struct sk_buff *skb1 = NULL;
  1061. struct ethhdr *datap = NULL;
  1062. struct ath6kl_vif *vif;
  1063. struct aggr_info_conn *aggr_conn;
  1064. u16 seq_no, offset;
  1065. u8 tid, if_idx;
  1066. ath6kl_dbg(ATH6KL_DBG_WLAN_RX,
  1067. "%s: ar=0x%p eid=%d, skb=0x%p, data=0x%p, len=0x%x status:%d",
  1068. __func__, ar, ept, skb, packet->buf,
  1069. packet->act_len, status);
  1070. if (status || !(skb->data + HTC_HDR_LENGTH)) {
  1071. dev_kfree_skb(skb);
  1072. return;
  1073. }
  1074. skb_put(skb, packet->act_len + HTC_HDR_LENGTH);
  1075. skb_pull(skb, HTC_HDR_LENGTH);
  1076. ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, __func__, "rx ",
  1077. skb->data, skb->len);
  1078. if (ept == ar->ctrl_ep) {
  1079. if (test_bit(WMI_ENABLED, &ar->flag)) {
  1080. ath6kl_check_wow_status(ar);
  1081. ath6kl_wmi_control_rx(ar->wmi, skb);
  1082. return;
  1083. }
  1084. if_idx =
  1085. wmi_cmd_hdr_get_if_idx((struct wmi_cmd_hdr *) skb->data);
  1086. } else {
  1087. if_idx =
  1088. wmi_data_hdr_get_if_idx((struct wmi_data_hdr *) skb->data);
  1089. }
  1090. vif = ath6kl_get_vif_by_index(ar, if_idx);
  1091. if (!vif) {
  1092. dev_kfree_skb(skb);
  1093. return;
  1094. }
  1095. /*
  1096. * Take lock to protect buffer counts and adaptive power throughput
  1097. * state.
  1098. */
  1099. spin_lock_bh(&vif->if_lock);
  1100. vif->net_stats.rx_packets++;
  1101. vif->net_stats.rx_bytes += packet->act_len;
  1102. spin_unlock_bh(&vif->if_lock);
  1103. skb->dev = vif->ndev;
  1104. if (!test_bit(WMI_ENABLED, &ar->flag)) {
  1105. if (EPPING_ALIGNMENT_PAD > 0)
  1106. skb_pull(skb, EPPING_ALIGNMENT_PAD);
  1107. ath6kl_deliver_frames_to_nw_stack(vif->ndev, skb);
  1108. return;
  1109. }
  1110. ath6kl_check_wow_status(ar);
  1111. min_hdr_len = sizeof(struct ethhdr) + sizeof(struct wmi_data_hdr) +
  1112. sizeof(struct ath6kl_llc_snap_hdr);
  1113. dhdr = (struct wmi_data_hdr *) skb->data;
  1114. /*
  1115. * In the case of AP mode we may receive NULL data frames
  1116. * that do not have LLC hdr. They are 16 bytes in size.
  1117. * Allow these frames in the AP mode.
  1118. */
  1119. if (vif->nw_type != AP_NETWORK &&
  1120. ((packet->act_len < min_hdr_len) ||
  1121. (packet->act_len > WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH))) {
  1122. ath6kl_info("frame len is too short or too long\n");
  1123. vif->net_stats.rx_errors++;
  1124. vif->net_stats.rx_length_errors++;
  1125. dev_kfree_skb(skb);
  1126. return;
  1127. }
  1128. /* Get the Power save state of the STA */
  1129. if (vif->nw_type == AP_NETWORK) {
  1130. meta_type = wmi_data_hdr_get_meta(dhdr);
  1131. ps_state = !!((dhdr->info >> WMI_DATA_HDR_PS_SHIFT) &
  1132. WMI_DATA_HDR_PS_MASK);
  1133. offset = sizeof(struct wmi_data_hdr);
  1134. trig_state = !!(le16_to_cpu(dhdr->info3) & WMI_DATA_HDR_TRIG);
  1135. switch (meta_type) {
  1136. case 0:
  1137. break;
  1138. case WMI_META_VERSION_1:
  1139. offset += sizeof(struct wmi_rx_meta_v1);
  1140. break;
  1141. case WMI_META_VERSION_2:
  1142. offset += sizeof(struct wmi_rx_meta_v2);
  1143. break;
  1144. default:
  1145. break;
  1146. }
  1147. datap = (struct ethhdr *) (skb->data + offset);
  1148. conn = ath6kl_find_sta(vif, datap->h_source);
  1149. if (!conn) {
  1150. dev_kfree_skb(skb);
  1151. return;
  1152. }
  1153. /*
  1154. * If there is a change in PS state of the STA,
  1155. * take appropriate steps:
  1156. *
  1157. * 1. If Sleep-->Awake, flush the psq for the STA
  1158. * Clear the PVB for the STA.
  1159. * 2. If Awake-->Sleep, Starting queueing frames
  1160. * the STA.
  1161. */
  1162. prev_ps = !!(conn->sta_flags & STA_PS_SLEEP);
  1163. if (ps_state)
  1164. conn->sta_flags |= STA_PS_SLEEP;
  1165. else
  1166. conn->sta_flags &= ~STA_PS_SLEEP;
  1167. /* Accept trigger only when the station is in sleep */
  1168. if ((conn->sta_flags & STA_PS_SLEEP) && trig_state)
  1169. ath6kl_uapsd_trigger_frame_rx(vif, conn);
  1170. if (prev_ps ^ !!(conn->sta_flags & STA_PS_SLEEP)) {
  1171. if (!(conn->sta_flags & STA_PS_SLEEP)) {
  1172. struct sk_buff *skbuff = NULL;
  1173. bool is_apsdq_empty;
  1174. struct ath6kl_mgmt_buff *mgmt;
  1175. u8 idx;
  1176. spin_lock_bh(&conn->psq_lock);
  1177. while (conn->mgmt_psq_len > 0) {
  1178. mgmt = list_first_entry(
  1179. &conn->mgmt_psq,
  1180. struct ath6kl_mgmt_buff,
  1181. list);
  1182. list_del(&mgmt->list);
  1183. conn->mgmt_psq_len--;
  1184. spin_unlock_bh(&conn->psq_lock);
  1185. idx = vif->fw_vif_idx;
  1186. ath6kl_wmi_send_mgmt_cmd(ar->wmi,
  1187. idx,
  1188. mgmt->id,
  1189. mgmt->freq,
  1190. mgmt->wait,
  1191. mgmt->buf,
  1192. mgmt->len,
  1193. mgmt->no_cck);
  1194. kfree(mgmt);
  1195. spin_lock_bh(&conn->psq_lock);
  1196. }
  1197. conn->mgmt_psq_len = 0;
  1198. while ((skbuff = skb_dequeue(&conn->psq))) {
  1199. spin_unlock_bh(&conn->psq_lock);
  1200. ath6kl_data_tx(skbuff, vif->ndev);
  1201. spin_lock_bh(&conn->psq_lock);
  1202. }
  1203. is_apsdq_empty = skb_queue_empty(&conn->apsdq);
  1204. while ((skbuff = skb_dequeue(&conn->apsdq))) {
  1205. spin_unlock_bh(&conn->psq_lock);
  1206. ath6kl_data_tx(skbuff, vif->ndev);
  1207. spin_lock_bh(&conn->psq_lock);
  1208. }
  1209. spin_unlock_bh(&conn->psq_lock);
  1210. if (!is_apsdq_empty)
  1211. ath6kl_wmi_set_apsd_bfrd_traf(
  1212. ar->wmi,
  1213. vif->fw_vif_idx,
  1214. conn->aid, 0, 0);
  1215. /* Clear the PVB for this STA */
  1216. ath6kl_wmi_set_pvb_cmd(ar->wmi, vif->fw_vif_idx,
  1217. conn->aid, 0);
  1218. }
  1219. }
  1220. /* drop NULL data frames here */
  1221. if ((packet->act_len < min_hdr_len) ||
  1222. (packet->act_len >
  1223. WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH)) {
  1224. dev_kfree_skb(skb);
  1225. return;
  1226. }
  1227. }
  1228. is_amsdu = wmi_data_hdr_is_amsdu(dhdr) ? true : false;
  1229. tid = wmi_data_hdr_get_up(dhdr);
  1230. seq_no = wmi_data_hdr_get_seqno(dhdr);
  1231. meta_type = wmi_data_hdr_get_meta(dhdr);
  1232. dot11_hdr = wmi_data_hdr_get_dot11(dhdr);
  1233. skb_pull(skb, sizeof(struct wmi_data_hdr));
  1234. switch (meta_type) {
  1235. case WMI_META_VERSION_1:
  1236. skb_pull(skb, sizeof(struct wmi_rx_meta_v1));
  1237. break;
  1238. case WMI_META_VERSION_2:
  1239. meta = (struct wmi_rx_meta_v2 *) skb->data;
  1240. if (meta->csum_flags & 0x1) {
  1241. skb->ip_summed = CHECKSUM_COMPLETE;
  1242. skb->csum = (__force __wsum) meta->csum;
  1243. }
  1244. skb_pull(skb, sizeof(struct wmi_rx_meta_v2));
  1245. break;
  1246. default:
  1247. break;
  1248. }
  1249. if (dot11_hdr)
  1250. status = ath6kl_wmi_dot11_hdr_remove(ar->wmi, skb);
  1251. else if (!is_amsdu)
  1252. status = ath6kl_wmi_dot3_2_dix(skb);
  1253. if (status) {
  1254. /*
  1255. * Drop frames that could not be processed (lack of
  1256. * memory, etc.)
  1257. */
  1258. dev_kfree_skb(skb);
  1259. return;
  1260. }
  1261. if (!(vif->ndev->flags & IFF_UP)) {
  1262. dev_kfree_skb(skb);
  1263. return;
  1264. }
  1265. if (vif->nw_type == AP_NETWORK) {
  1266. datap = (struct ethhdr *) skb->data;
  1267. if (is_multicast_ether_addr(datap->h_dest))
  1268. /*
  1269. * Bcast/Mcast frames should be sent to the
  1270. * OS stack as well as on the air.
  1271. */
  1272. skb1 = skb_copy(skb, GFP_ATOMIC);
  1273. else {
  1274. /*
  1275. * Search for a connected STA with dstMac
  1276. * as the Mac address. If found send the
  1277. * frame to it on the air else send the
  1278. * frame up the stack.
  1279. */
  1280. conn = ath6kl_find_sta(vif, datap->h_dest);
  1281. if (conn && ar->intra_bss) {
  1282. skb1 = skb;
  1283. skb = NULL;
  1284. } else if (conn && !ar->intra_bss) {
  1285. dev_kfree_skb(skb);
  1286. skb = NULL;
  1287. }
  1288. }
  1289. if (skb1)
  1290. ath6kl_data_tx(skb1, vif->ndev);
  1291. if (skb == NULL) {
  1292. /* nothing to deliver up the stack */
  1293. return;
  1294. }
  1295. }
  1296. datap = (struct ethhdr *) skb->data;
  1297. if (is_unicast_ether_addr(datap->h_dest)) {
  1298. if (vif->nw_type == AP_NETWORK) {
  1299. conn = ath6kl_find_sta(vif, datap->h_source);
  1300. if (!conn)
  1301. return;
  1302. aggr_conn = conn->aggr_conn;
  1303. } else
  1304. aggr_conn = vif->aggr_cntxt->aggr_conn;
  1305. if (aggr_process_recv_frm(aggr_conn, tid, seq_no,
  1306. is_amsdu, skb)) {
  1307. /* aggregation code will handle the skb */
  1308. return;
  1309. }
  1310. }
  1311. ath6kl_deliver_frames_to_nw_stack(vif->ndev, skb);
  1312. }
  1313. static void aggr_timeout(unsigned long arg)
  1314. {
  1315. u8 i, j;
  1316. struct aggr_info_conn *aggr_conn = (struct aggr_info_conn *) arg;
  1317. struct rxtid *rxtid;
  1318. struct rxtid_stats *stats;
  1319. for (i = 0; i < NUM_OF_TIDS; i++) {
  1320. rxtid = &aggr_conn->rx_tid[i];
  1321. stats = &aggr_conn->stat[i];
  1322. if (!rxtid->aggr || !rxtid->timer_mon || rxtid->progress)
  1323. continue;
  1324. stats->num_timeouts++;
  1325. ath6kl_dbg(ATH6KL_DBG_AGGR,
  1326. "aggr timeout (st %d end %d)\n",
  1327. rxtid->seq_next,
  1328. ((rxtid->seq_next + rxtid->hold_q_sz-1) &
  1329. ATH6KL_MAX_SEQ_NO));
  1330. aggr_deque_frms(aggr_conn, i, 0, 0);
  1331. }
  1332. aggr_conn->timer_scheduled = false;
  1333. for (i = 0; i < NUM_OF_TIDS; i++) {
  1334. rxtid = &aggr_conn->rx_tid[i];
  1335. if (rxtid->aggr && rxtid->hold_q) {
  1336. for (j = 0; j < rxtid->hold_q_sz; j++) {
  1337. if (rxtid->hold_q[j].skb) {
  1338. aggr_conn->timer_scheduled = true;
  1339. rxtid->timer_mon = true;
  1340. rxtid->progress = false;
  1341. break;
  1342. }
  1343. }
  1344. if (j >= rxtid->hold_q_sz)
  1345. rxtid->timer_mon = false;
  1346. }
  1347. }
  1348. if (aggr_conn->timer_scheduled)
  1349. mod_timer(&aggr_conn->timer,
  1350. jiffies + msecs_to_jiffies(AGGR_RX_TIMEOUT));
  1351. }
  1352. static void aggr_delete_tid_state(struct aggr_info_conn *aggr_conn, u8 tid)
  1353. {
  1354. struct rxtid *rxtid;
  1355. struct rxtid_stats *stats;
  1356. if (!aggr_conn || tid >= NUM_OF_TIDS)
  1357. return;
  1358. rxtid = &aggr_conn->rx_tid[tid];
  1359. stats = &aggr_conn->stat[tid];
  1360. if (rxtid->aggr)
  1361. aggr_deque_frms(aggr_conn, tid, 0, 0);
  1362. rxtid->aggr = false;
  1363. rxtid->progress = false;
  1364. rxtid->timer_mon = false;
  1365. rxtid->win_sz = 0;
  1366. rxtid->seq_next = 0;
  1367. rxtid->hold_q_sz = 0;
  1368. kfree(rxtid->hold_q);
  1369. rxtid->hold_q = NULL;
  1370. memset(stats, 0, sizeof(struct rxtid_stats));
  1371. }
  1372. void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid_mux, u16 seq_no,
  1373. u8 win_sz)
  1374. {
  1375. struct ath6kl_sta *sta;
  1376. struct aggr_info_conn *aggr_conn = NULL;
  1377. struct rxtid *rxtid;
  1378. struct rxtid_stats *stats;
  1379. u16 hold_q_size;
  1380. u8 tid, aid;
  1381. if (vif->nw_type == AP_NETWORK) {
  1382. aid = ath6kl_get_aid(tid_mux);
  1383. sta = ath6kl_find_sta_by_aid(vif->ar, aid);
  1384. if (sta)
  1385. aggr_conn = sta->aggr_conn;
  1386. } else
  1387. aggr_conn = vif->aggr_cntxt->aggr_conn;
  1388. if (!aggr_conn)
  1389. return;
  1390. tid = ath6kl_get_tid(tid_mux);
  1391. if (tid >= NUM_OF_TIDS)
  1392. return;
  1393. rxtid = &aggr_conn->rx_tid[tid];
  1394. stats = &aggr_conn->stat[tid];
  1395. if (win_sz < AGGR_WIN_SZ_MIN || win_sz > AGGR_WIN_SZ_MAX)
  1396. ath6kl_dbg(ATH6KL_DBG_WLAN_RX, "%s: win_sz %d, tid %d\n",
  1397. __func__, win_sz, tid);
  1398. if (rxtid->aggr)
  1399. aggr_delete_tid_state(aggr_conn, tid);
  1400. rxtid->seq_next = seq_no;
  1401. hold_q_size = TID_WINDOW_SZ(win_sz) * sizeof(struct skb_hold_q);
  1402. rxtid->hold_q = kzalloc(hold_q_size, GFP_KERNEL);
  1403. if (!rxtid->hold_q)
  1404. return;
  1405. rxtid->win_sz = win_sz;
  1406. rxtid->hold_q_sz = TID_WINDOW_SZ(win_sz);
  1407. if (!skb_queue_empty(&rxtid->q))
  1408. return;
  1409. rxtid->aggr = true;
  1410. }
  1411. void aggr_conn_init(struct ath6kl_vif *vif, struct aggr_info *aggr_info,
  1412. struct aggr_info_conn *aggr_conn)
  1413. {
  1414. struct rxtid *rxtid;
  1415. u8 i;
  1416. aggr_conn->aggr_sz = AGGR_SZ_DEFAULT;
  1417. aggr_conn->dev = vif->ndev;
  1418. init_timer(&aggr_conn->timer);
  1419. aggr_conn->timer.function = aggr_timeout;
  1420. aggr_conn->timer.data = (unsigned long) aggr_conn;
  1421. aggr_conn->aggr_info = aggr_info;
  1422. aggr_conn->timer_scheduled = false;
  1423. for (i = 0; i < NUM_OF_TIDS; i++) {
  1424. rxtid = &aggr_conn->rx_tid[i];
  1425. rxtid->aggr = false;
  1426. rxtid->progress = false;
  1427. rxtid->timer_mon = false;
  1428. skb_queue_head_init(&rxtid->q);
  1429. spin_lock_init(&rxtid->lock);
  1430. }
  1431. }
  1432. struct aggr_info *aggr_init(struct ath6kl_vif *vif)
  1433. {
  1434. struct aggr_info *p_aggr = NULL;
  1435. p_aggr = kzalloc(sizeof(struct aggr_info), GFP_KERNEL);
  1436. if (!p_aggr) {
  1437. ath6kl_err("failed to alloc memory for aggr_node\n");
  1438. return NULL;
  1439. }
  1440. p_aggr->aggr_conn = kzalloc(sizeof(struct aggr_info_conn), GFP_KERNEL);
  1441. if (!p_aggr->aggr_conn) {
  1442. ath6kl_err("failed to alloc memory for connection specific aggr info\n");
  1443. kfree(p_aggr);
  1444. return NULL;
  1445. }
  1446. aggr_conn_init(vif, p_aggr, p_aggr->aggr_conn);
  1447. skb_queue_head_init(&p_aggr->rx_amsdu_freeq);
  1448. ath6kl_alloc_netbufs(&p_aggr->rx_amsdu_freeq, AGGR_NUM_OF_FREE_NETBUFS);
  1449. return p_aggr;
  1450. }
  1451. void aggr_recv_delba_req_evt(struct ath6kl_vif *vif, u8 tid_mux)
  1452. {
  1453. struct ath6kl_sta *sta;
  1454. struct rxtid *rxtid;
  1455. struct aggr_info_conn *aggr_conn = NULL;
  1456. u8 tid, aid;
  1457. if (vif->nw_type == AP_NETWORK) {
  1458. aid = ath6kl_get_aid(tid_mux);
  1459. sta = ath6kl_find_sta_by_aid(vif->ar, aid);
  1460. if (sta)
  1461. aggr_conn = sta->aggr_conn;
  1462. } else
  1463. aggr_conn = vif->aggr_cntxt->aggr_conn;
  1464. if (!aggr_conn)
  1465. return;
  1466. tid = ath6kl_get_tid(tid_mux);
  1467. if (tid >= NUM_OF_TIDS)
  1468. return;
  1469. rxtid = &aggr_conn->rx_tid[tid];
  1470. if (rxtid->aggr)
  1471. aggr_delete_tid_state(aggr_conn, tid);
  1472. }
  1473. void aggr_reset_state(struct aggr_info_conn *aggr_conn)
  1474. {
  1475. u8 tid;
  1476. if (!aggr_conn)
  1477. return;
  1478. if (aggr_conn->timer_scheduled) {
  1479. del_timer(&aggr_conn->timer);
  1480. aggr_conn->timer_scheduled = false;
  1481. }
  1482. for (tid = 0; tid < NUM_OF_TIDS; tid++)
  1483. aggr_delete_tid_state(aggr_conn, tid);
  1484. }
  1485. /* clean up our amsdu buffer list */
  1486. void ath6kl_cleanup_amsdu_rxbufs(struct ath6kl *ar)
  1487. {
  1488. struct htc_packet *packet, *tmp_pkt;
  1489. spin_lock_bh(&ar->lock);
  1490. if (list_empty(&ar->amsdu_rx_buffer_queue)) {
  1491. spin_unlock_bh(&ar->lock);
  1492. return;
  1493. }
  1494. list_for_each_entry_safe(packet, tmp_pkt, &ar->amsdu_rx_buffer_queue,
  1495. list) {
  1496. list_del(&packet->list);
  1497. spin_unlock_bh(&ar->lock);
  1498. dev_kfree_skb(packet->pkt_cntxt);
  1499. spin_lock_bh(&ar->lock);
  1500. }
  1501. spin_unlock_bh(&ar->lock);
  1502. }
  1503. void aggr_module_destroy(struct aggr_info *aggr_info)
  1504. {
  1505. if (!aggr_info)
  1506. return;
  1507. aggr_reset_state(aggr_info->aggr_conn);
  1508. skb_queue_purge(&aggr_info->rx_amsdu_freeq);
  1509. kfree(aggr_info->aggr_conn);
  1510. kfree(aggr_info);
  1511. }