|
@@ -70,8 +70,65 @@ static void wl1271_free_tx_id(struct wl1271 *wl, int id)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static void wl1271_tx_ap_update_inconnection_sta(struct wl1271 *wl,
|
|
|
+ struct sk_buff *skb)
|
|
|
+{
|
|
|
+ struct ieee80211_hdr *hdr;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * add the station to the known list before transmitting the
|
|
|
+ * authentication response. this way it won't get de-authed by FW
|
|
|
+ * when transmitting too soon.
|
|
|
+ */
|
|
|
+ hdr = (struct ieee80211_hdr *)(skb->data +
|
|
|
+ sizeof(struct wl1271_tx_hw_descr));
|
|
|
+ if (ieee80211_is_auth(hdr->frame_control))
|
|
|
+ wl1271_acx_set_inconnection_sta(wl, hdr->addr1);
|
|
|
+}
|
|
|
+
|
|
|
+static void wl1271_tx_regulate_link(struct wl1271 *wl, u8 hlid)
|
|
|
+{
|
|
|
+ bool fw_ps;
|
|
|
+ u8 tx_blks;
|
|
|
+
|
|
|
+ /* only regulate station links */
|
|
|
+ if (hlid < WL1271_AP_STA_HLID_START)
|
|
|
+ return;
|
|
|
+
|
|
|
+ fw_ps = test_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map);
|
|
|
+ tx_blks = wl->links[hlid].allocated_blks;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * if in FW PS and there is enough data in FW we can put the link
|
|
|
+ * into high-level PS and clean out its TX queues.
|
|
|
+ */
|
|
|
+ if (fw_ps && tx_blks >= WL1271_PS_STA_MAX_BLOCKS)
|
|
|
+ wl1271_ps_link_start(wl, hlid, true);
|
|
|
+}
|
|
|
+
|
|
|
+u8 wl1271_tx_get_hlid(struct sk_buff *skb)
|
|
|
+{
|
|
|
+ struct ieee80211_tx_info *control = IEEE80211_SKB_CB(skb);
|
|
|
+
|
|
|
+ if (control->control.sta) {
|
|
|
+ struct wl1271_station *wl_sta;
|
|
|
+
|
|
|
+ wl_sta = (struct wl1271_station *)
|
|
|
+ control->control.sta->drv_priv;
|
|
|
+ return wl_sta->hlid;
|
|
|
+ } else {
|
|
|
+ struct ieee80211_hdr *hdr;
|
|
|
+
|
|
|
+ hdr = (struct ieee80211_hdr *)skb->data;
|
|
|
+ if (ieee80211_is_mgmt(hdr->frame_control))
|
|
|
+ return WL1271_AP_GLOBAL_HLID;
|
|
|
+ else
|
|
|
+ return WL1271_AP_BROADCAST_HLID;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra,
|
|
|
- u32 buf_offset)
|
|
|
+ u32 buf_offset, u8 hlid)
|
|
|
{
|
|
|
struct wl1271_tx_hw_descr *desc;
|
|
|
u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra;
|
|
@@ -100,6 +157,9 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra,
|
|
|
|
|
|
wl->tx_blocks_available -= total_blocks;
|
|
|
|
|
|
+ if (wl->bss_type == BSS_TYPE_AP_BSS)
|
|
|
+ wl->links[hlid].allocated_blks += total_blocks;
|
|
|
+
|
|
|
ret = 0;
|
|
|
|
|
|
wl1271_debug(DEBUG_TX,
|
|
@@ -113,7 +173,8 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra,
|
|
|
}
|
|
|
|
|
|
static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb,
|
|
|
- u32 extra, struct ieee80211_tx_info *control)
|
|
|
+ u32 extra, struct ieee80211_tx_info *control,
|
|
|
+ u8 hlid)
|
|
|
{
|
|
|
struct timespec ts;
|
|
|
struct wl1271_tx_hw_descr *desc;
|
|
@@ -149,7 +210,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb,
|
|
|
desc->tid = ac;
|
|
|
|
|
|
if (wl->bss_type != BSS_TYPE_AP_BSS) {
|
|
|
- desc->aid = TX_HW_DEFAULT_AID;
|
|
|
+ desc->aid = hlid;
|
|
|
|
|
|
/* if the packets are destined for AP (have a STA entry)
|
|
|
send them with AP rate policies, otherwise use default
|
|
@@ -159,25 +220,17 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb,
|
|
|
else
|
|
|
rate_idx = ACX_TX_BASIC_RATE;
|
|
|
} else {
|
|
|
- if (control->control.sta) {
|
|
|
- struct wl1271_station *wl_sta;
|
|
|
-
|
|
|
- wl_sta = (struct wl1271_station *)
|
|
|
- control->control.sta->drv_priv;
|
|
|
- desc->hlid = wl_sta->hlid;
|
|
|
+ desc->hlid = hlid;
|
|
|
+ switch (hlid) {
|
|
|
+ case WL1271_AP_GLOBAL_HLID:
|
|
|
+ rate_idx = ACX_TX_AP_MODE_MGMT_RATE;
|
|
|
+ break;
|
|
|
+ case WL1271_AP_BROADCAST_HLID:
|
|
|
+ rate_idx = ACX_TX_AP_MODE_BCST_RATE;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
rate_idx = ac;
|
|
|
- } else {
|
|
|
- struct ieee80211_hdr *hdr;
|
|
|
-
|
|
|
- hdr = (struct ieee80211_hdr *)
|
|
|
- (skb->data + sizeof(*desc));
|
|
|
- if (ieee80211_is_mgmt(hdr->frame_control)) {
|
|
|
- desc->hlid = WL1271_AP_GLOBAL_HLID;
|
|
|
- rate_idx = ACX_TX_AP_MODE_MGMT_RATE;
|
|
|
- } else {
|
|
|
- desc->hlid = WL1271_AP_BROADCAST_HLID;
|
|
|
- rate_idx = ACX_TX_AP_MODE_BCST_RATE;
|
|
|
- }
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -185,7 +238,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb,
|
|
|
desc->reserved = 0;
|
|
|
|
|
|
/* align the length (and store in terms of words) */
|
|
|
- pad = WL1271_TX_ALIGN(skb->len);
|
|
|
+ pad = ALIGN(skb->len, WL1271_TX_ALIGN_TO);
|
|
|
desc->length = cpu_to_le16(pad >> 2);
|
|
|
|
|
|
/* calculate number of padding bytes */
|
|
@@ -208,6 +261,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb,
|
|
|
u32 extra = 0;
|
|
|
int ret = 0;
|
|
|
u32 total_len;
|
|
|
+ u8 hlid;
|
|
|
|
|
|
if (!skb)
|
|
|
return -EINVAL;
|
|
@@ -234,18 +288,28 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- ret = wl1271_tx_allocate(wl, skb, extra, buf_offset);
|
|
|
+ if (wl->bss_type == BSS_TYPE_AP_BSS)
|
|
|
+ hlid = wl1271_tx_get_hlid(skb);
|
|
|
+ else
|
|
|
+ hlid = TX_HW_DEFAULT_AID;
|
|
|
+
|
|
|
+ ret = wl1271_tx_allocate(wl, skb, extra, buf_offset, hlid);
|
|
|
if (ret < 0)
|
|
|
return ret;
|
|
|
|
|
|
- wl1271_tx_fill_hdr(wl, skb, extra, info);
|
|
|
+ if (wl->bss_type == BSS_TYPE_AP_BSS) {
|
|
|
+ wl1271_tx_ap_update_inconnection_sta(wl, skb);
|
|
|
+ wl1271_tx_regulate_link(wl, hlid);
|
|
|
+ }
|
|
|
+
|
|
|
+ wl1271_tx_fill_hdr(wl, skb, extra, info, hlid);
|
|
|
|
|
|
/*
|
|
|
* The length of each packet is stored in terms of words. Thus, we must
|
|
|
* pad the skb data to make sure its length is aligned.
|
|
|
* The number of padding bytes is computed and set in wl1271_tx_fill_hdr
|
|
|
*/
|
|
|
- total_len = WL1271_TX_ALIGN(skb->len);
|
|
|
+ total_len = ALIGN(skb->len, WL1271_TX_ALIGN_TO);
|
|
|
memcpy(wl->aggr_buf + buf_offset, skb->data, skb->len);
|
|
|
memset(wl->aggr_buf + buf_offset + skb->len, 0, total_len - skb->len);
|
|
|
|
|
@@ -279,7 +343,7 @@ u32 wl1271_tx_enabled_rates_get(struct wl1271 *wl, u32 rate_set)
|
|
|
return enabled_rates;
|
|
|
}
|
|
|
|
|
|
-static void handle_tx_low_watermark(struct wl1271 *wl)
|
|
|
+void wl1271_handle_tx_low_watermark(struct wl1271 *wl)
|
|
|
{
|
|
|
unsigned long flags;
|
|
|
|
|
@@ -293,7 +357,7 @@ static void handle_tx_low_watermark(struct wl1271 *wl)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl)
|
|
|
+static struct sk_buff *wl1271_sta_skb_dequeue(struct wl1271 *wl)
|
|
|
{
|
|
|
struct sk_buff *skb = NULL;
|
|
|
unsigned long flags;
|
|
@@ -319,12 +383,69 @@ out:
|
|
|
return skb;
|
|
|
}
|
|
|
|
|
|
+static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl)
|
|
|
+{
|
|
|
+ struct sk_buff *skb = NULL;
|
|
|
+ unsigned long flags;
|
|
|
+ int i, h, start_hlid;
|
|
|
+
|
|
|
+ /* start from the link after the last one */
|
|
|
+ start_hlid = (wl->last_tx_hlid + 1) % AP_MAX_LINKS;
|
|
|
+
|
|
|
+ /* dequeue according to AC, round robin on each link */
|
|
|
+ for (i = 0; i < AP_MAX_LINKS; i++) {
|
|
|
+ h = (start_hlid + i) % AP_MAX_LINKS;
|
|
|
+
|
|
|
+ skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_VO]);
|
|
|
+ if (skb)
|
|
|
+ goto out;
|
|
|
+ skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_VI]);
|
|
|
+ if (skb)
|
|
|
+ goto out;
|
|
|
+ skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_BE]);
|
|
|
+ if (skb)
|
|
|
+ goto out;
|
|
|
+ skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_BK]);
|
|
|
+ if (skb)
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
+out:
|
|
|
+ if (skb) {
|
|
|
+ wl->last_tx_hlid = h;
|
|
|
+ spin_lock_irqsave(&wl->wl_lock, flags);
|
|
|
+ wl->tx_queue_count--;
|
|
|
+ spin_unlock_irqrestore(&wl->wl_lock, flags);
|
|
|
+ } else {
|
|
|
+ wl->last_tx_hlid = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ return skb;
|
|
|
+}
|
|
|
+
|
|
|
+static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl)
|
|
|
+{
|
|
|
+ if (wl->bss_type == BSS_TYPE_AP_BSS)
|
|
|
+ return wl1271_ap_skb_dequeue(wl);
|
|
|
+
|
|
|
+ return wl1271_sta_skb_dequeue(wl);
|
|
|
+}
|
|
|
+
|
|
|
static void wl1271_skb_queue_head(struct wl1271 *wl, struct sk_buff *skb)
|
|
|
{
|
|
|
unsigned long flags;
|
|
|
int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));
|
|
|
|
|
|
- skb_queue_head(&wl->tx_queue[q], skb);
|
|
|
+ if (wl->bss_type == BSS_TYPE_AP_BSS) {
|
|
|
+ u8 hlid = wl1271_tx_get_hlid(skb);
|
|
|
+ skb_queue_head(&wl->links[hlid].tx_queue[q], skb);
|
|
|
+
|
|
|
+ /* make sure we dequeue the same packet next time */
|
|
|
+ wl->last_tx_hlid = (hlid + AP_MAX_LINKS - 1) % AP_MAX_LINKS;
|
|
|
+ } else {
|
|
|
+ skb_queue_head(&wl->tx_queue[q], skb);
|
|
|
+ }
|
|
|
+
|
|
|
spin_lock_irqsave(&wl->wl_lock, flags);
|
|
|
wl->tx_queue_count++;
|
|
|
spin_unlock_irqrestore(&wl->wl_lock, flags);
|
|
@@ -387,7 +508,7 @@ out_ack:
|
|
|
if (sent_packets) {
|
|
|
/* interrupt the firmware with the new packets */
|
|
|
wl1271_write32(wl, WL1271_HOST_WR_ACCESS, wl->tx_packets_count);
|
|
|
- handle_tx_low_watermark(wl);
|
|
|
+ wl1271_handle_tx_low_watermark(wl);
|
|
|
}
|
|
|
|
|
|
out:
|
|
@@ -504,32 +625,76 @@ void wl1271_tx_complete(struct wl1271 *wl)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid)
|
|
|
+{
|
|
|
+ struct sk_buff *skb;
|
|
|
+ int i, total = 0;
|
|
|
+ unsigned long flags;
|
|
|
+ struct ieee80211_tx_info *info;
|
|
|
+
|
|
|
+ for (i = 0; i < NUM_TX_QUEUES; i++) {
|
|
|
+ while ((skb = skb_dequeue(&wl->links[hlid].tx_queue[i]))) {
|
|
|
+ wl1271_debug(DEBUG_TX, "link freeing skb 0x%p", skb);
|
|
|
+ info = IEEE80211_SKB_CB(skb);
|
|
|
+ info->status.rates[0].idx = -1;
|
|
|
+ info->status.rates[0].count = 0;
|
|
|
+ ieee80211_tx_status(wl->hw, skb);
|
|
|
+ total++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ spin_lock_irqsave(&wl->wl_lock, flags);
|
|
|
+ wl->tx_queue_count -= total;
|
|
|
+ spin_unlock_irqrestore(&wl->wl_lock, flags);
|
|
|
+
|
|
|
+ wl1271_handle_tx_low_watermark(wl);
|
|
|
+}
|
|
|
+
|
|
|
/* caller must hold wl->mutex */
|
|
|
void wl1271_tx_reset(struct wl1271 *wl)
|
|
|
{
|
|
|
int i;
|
|
|
struct sk_buff *skb;
|
|
|
+ struct ieee80211_tx_info *info;
|
|
|
|
|
|
/* TX failure */
|
|
|
- for (i = 0; i < NUM_TX_QUEUES; i++) {
|
|
|
- while ((skb = skb_dequeue(&wl->tx_queue[i]))) {
|
|
|
- wl1271_debug(DEBUG_TX, "freeing skb 0x%p", skb);
|
|
|
- ieee80211_tx_status(wl->hw, skb);
|
|
|
+ if (wl->bss_type == BSS_TYPE_AP_BSS) {
|
|
|
+ for (i = 0; i < AP_MAX_LINKS; i++) {
|
|
|
+ wl1271_tx_reset_link_queues(wl, i);
|
|
|
+ wl->links[i].allocated_blks = 0;
|
|
|
+ wl->links[i].prev_freed_blks = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ wl->last_tx_hlid = 0;
|
|
|
+ } else {
|
|
|
+ for (i = 0; i < NUM_TX_QUEUES; i++) {
|
|
|
+ while ((skb = skb_dequeue(&wl->tx_queue[i]))) {
|
|
|
+ wl1271_debug(DEBUG_TX, "freeing skb 0x%p",
|
|
|
+ skb);
|
|
|
+ info = IEEE80211_SKB_CB(skb);
|
|
|
+ info->status.rates[0].idx = -1;
|
|
|
+ info->status.rates[0].count = 0;
|
|
|
+ ieee80211_tx_status(wl->hw, skb);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
wl->tx_queue_count = 0;
|
|
|
|
|
|
/*
|
|
|
* Make sure the driver is at a consistent state, in case this
|
|
|
* function is called from a context other than interface removal.
|
|
|
*/
|
|
|
- handle_tx_low_watermark(wl);
|
|
|
+ wl1271_handle_tx_low_watermark(wl);
|
|
|
|
|
|
for (i = 0; i < ACX_TX_DESCRIPTORS; i++)
|
|
|
if (wl->tx_frames[i] != NULL) {
|
|
|
skb = wl->tx_frames[i];
|
|
|
wl1271_free_tx_id(wl, i);
|
|
|
wl1271_debug(DEBUG_TX, "freeing skb 0x%p", skb);
|
|
|
+ info = IEEE80211_SKB_CB(skb);
|
|
|
+ info->status.rates[0].idx = -1;
|
|
|
+ info->status.rates[0].count = 0;
|
|
|
ieee80211_tx_status(wl->hw, skb);
|
|
|
}
|
|
|
}
|
|
@@ -544,8 +709,8 @@ void wl1271_tx_flush(struct wl1271 *wl)
|
|
|
|
|
|
while (!time_after(jiffies, timeout)) {
|
|
|
mutex_lock(&wl->mutex);
|
|
|
- wl1271_debug(DEBUG_TX, "flushing tx buffer: %d",
|
|
|
- wl->tx_frames_cnt);
|
|
|
+ wl1271_debug(DEBUG_TX, "flushing tx buffer: %d %d",
|
|
|
+ wl->tx_frames_cnt, wl->tx_queue_count);
|
|
|
if ((wl->tx_frames_cnt == 0) && (wl->tx_queue_count == 0)) {
|
|
|
mutex_unlock(&wl->mutex);
|
|
|
return;
|