txrx.c 44 KB

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