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