txrx.c 44 KB

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