summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/mwifiex/11n_rxreorder.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/mwifiex/11n_rxreorder.c')
-rw-r--r--drivers/net/wireless/mwifiex/11n_rxreorder.c211
1 files changed, 101 insertions, 110 deletions
diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.c b/drivers/net/wireless/mwifiex/11n_rxreorder.c
index 681d3f2a4c28..9c44088054dd 100644
--- a/drivers/net/wireless/mwifiex/11n_rxreorder.c
+++ b/drivers/net/wireless/mwifiex/11n_rxreorder.c
@@ -27,31 +27,31 @@
#include "11n_rxreorder.h"
/*
- * This function dispatches all packets in the Rx reorder table.
+ * This function dispatches all packets in the Rx reorder table until the
+ * start window.
*
* There could be holes in the buffer, which are skipped by the function.
* Since the buffer is linear, the function uses rotation to simulate
* circular buffer.
*/
static void
-mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv,
- struct mwifiex_rx_reorder_tbl
- *rx_reor_tbl_ptr, int start_win)
+mwifiex_11n_dispatch_pkt(struct mwifiex_private *priv,
+ struct mwifiex_rx_reorder_tbl *tbl, int start_win)
{
- int no_pkt_to_send, i;
+ int pkt_to_send, i;
void *rx_tmp_ptr;
unsigned long flags;
- no_pkt_to_send = (start_win > rx_reor_tbl_ptr->start_win) ?
- min((start_win - rx_reor_tbl_ptr->start_win),
- rx_reor_tbl_ptr->win_size) : rx_reor_tbl_ptr->win_size;
+ pkt_to_send = (start_win > tbl->start_win) ?
+ min((start_win - tbl->start_win), tbl->win_size) :
+ tbl->win_size;
- for (i = 0; i < no_pkt_to_send; ++i) {
+ for (i = 0; i < pkt_to_send; ++i) {
spin_lock_irqsave(&priv->rx_pkt_lock, flags);
rx_tmp_ptr = NULL;
- if (rx_reor_tbl_ptr->rx_reorder_ptr[i]) {
- rx_tmp_ptr = rx_reor_tbl_ptr->rx_reorder_ptr[i];
- rx_reor_tbl_ptr->rx_reorder_ptr[i] = NULL;
+ if (tbl->rx_reorder_ptr[i]) {
+ rx_tmp_ptr = tbl->rx_reorder_ptr[i];
+ tbl->rx_reorder_ptr[i] = NULL;
}
spin_unlock_irqrestore(&priv->rx_pkt_lock, flags);
if (rx_tmp_ptr)
@@ -63,13 +63,12 @@ mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv,
* We don't have a circular buffer, hence use rotation to simulate
* circular buffer
*/
- for (i = 0; i < rx_reor_tbl_ptr->win_size - no_pkt_to_send; ++i) {
- rx_reor_tbl_ptr->rx_reorder_ptr[i] =
- rx_reor_tbl_ptr->rx_reorder_ptr[no_pkt_to_send + i];
- rx_reor_tbl_ptr->rx_reorder_ptr[no_pkt_to_send + i] = NULL;
+ for (i = 0; i < tbl->win_size - pkt_to_send; ++i) {
+ tbl->rx_reorder_ptr[i] = tbl->rx_reorder_ptr[pkt_to_send + i];
+ tbl->rx_reorder_ptr[pkt_to_send + i] = NULL;
}
- rx_reor_tbl_ptr->start_win = start_win;
+ tbl->start_win = start_win;
spin_unlock_irqrestore(&priv->rx_pkt_lock, flags);
}
@@ -83,20 +82,20 @@ mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv,
*/
static void
mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv,
- struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr)
+ struct mwifiex_rx_reorder_tbl *tbl)
{
int i, j, xchg;
void *rx_tmp_ptr;
unsigned long flags;
- for (i = 0; i < rx_reor_tbl_ptr->win_size; ++i) {
+ for (i = 0; i < tbl->win_size; ++i) {
spin_lock_irqsave(&priv->rx_pkt_lock, flags);
- if (!rx_reor_tbl_ptr->rx_reorder_ptr[i]) {
+ if (!tbl->rx_reorder_ptr[i]) {
spin_unlock_irqrestore(&priv->rx_pkt_lock, flags);
break;
}
- rx_tmp_ptr = rx_reor_tbl_ptr->rx_reorder_ptr[i];
- rx_reor_tbl_ptr->rx_reorder_ptr[i] = NULL;
+ rx_tmp_ptr = tbl->rx_reorder_ptr[i];
+ tbl->rx_reorder_ptr[i] = NULL;
spin_unlock_irqrestore(&priv->rx_pkt_lock, flags);
mwifiex_process_rx_packet(priv->adapter, rx_tmp_ptr);
}
@@ -107,15 +106,13 @@ mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv,
* circular buffer
*/
if (i > 0) {
- xchg = rx_reor_tbl_ptr->win_size - i;
+ xchg = tbl->win_size - i;
for (j = 0; j < xchg; ++j) {
- rx_reor_tbl_ptr->rx_reorder_ptr[j] =
- rx_reor_tbl_ptr->rx_reorder_ptr[i + j];
- rx_reor_tbl_ptr->rx_reorder_ptr[i + j] = NULL;
+ tbl->rx_reorder_ptr[j] = tbl->rx_reorder_ptr[i + j];
+ tbl->rx_reorder_ptr[i + j] = NULL;
}
}
- rx_reor_tbl_ptr->start_win = (rx_reor_tbl_ptr->start_win + i)
- &(MAX_TID_VALUE - 1);
+ tbl->start_win = (tbl->start_win + i) & (MAX_TID_VALUE - 1);
spin_unlock_irqrestore(&priv->rx_pkt_lock, flags);
}
@@ -126,28 +123,25 @@ mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv,
* pending packets in the Rx reorder table before deletion.
*/
static void
-mwifiex_11n_delete_rx_reorder_tbl_entry(struct mwifiex_private *priv,
- struct mwifiex_rx_reorder_tbl
- *rx_reor_tbl_ptr)
+mwifiex_del_rx_reorder_entry(struct mwifiex_private *priv,
+ struct mwifiex_rx_reorder_tbl *tbl)
{
unsigned long flags;
- if (!rx_reor_tbl_ptr)
+ if (!tbl)
return;
- mwifiex_11n_dispatch_pkt_until_start_win(priv, rx_reor_tbl_ptr,
- (rx_reor_tbl_ptr->start_win +
- rx_reor_tbl_ptr->win_size)
- &(MAX_TID_VALUE - 1));
+ mwifiex_11n_dispatch_pkt(priv, tbl, (tbl->start_win + tbl->win_size) &
+ (MAX_TID_VALUE - 1));
- del_timer(&rx_reor_tbl_ptr->timer_context.timer);
+ del_timer(&tbl->timer_context.timer);
spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags);
- list_del(&rx_reor_tbl_ptr->list);
+ list_del(&tbl->list);
spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags);
- kfree(rx_reor_tbl_ptr->rx_reorder_ptr);
- kfree(rx_reor_tbl_ptr);
+ kfree(tbl->rx_reorder_ptr);
+ kfree(tbl);
}
/*
@@ -157,16 +151,15 @@ mwifiex_11n_delete_rx_reorder_tbl_entry(struct mwifiex_private *priv,
static struct mwifiex_rx_reorder_tbl *
mwifiex_11n_get_rx_reorder_tbl(struct mwifiex_private *priv, int tid, u8 *ta)
{
- struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr;
+ struct mwifiex_rx_reorder_tbl *tbl;
unsigned long flags;
spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags);
- list_for_each_entry(rx_reor_tbl_ptr, &priv->rx_reorder_tbl_ptr, list) {
- if ((!memcmp(rx_reor_tbl_ptr->ta, ta, ETH_ALEN))
- && (rx_reor_tbl_ptr->tid == tid)) {
+ list_for_each_entry(tbl, &priv->rx_reorder_tbl_ptr, list) {
+ if (!memcmp(tbl->ta, ta, ETH_ALEN) && tbl->tid == tid) {
spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock,
flags);
- return rx_reor_tbl_ptr;
+ return tbl;
}
}
spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags);
@@ -200,19 +193,19 @@ mwifiex_11n_find_last_seq_num(struct mwifiex_rx_reorder_tbl *rx_reorder_tbl_ptr)
static void
mwifiex_flush_data(unsigned long context)
{
- struct reorder_tmr_cnxt *reorder_cnxt =
+ struct reorder_tmr_cnxt *ctx =
(struct reorder_tmr_cnxt *) context;
int start_win;
- start_win = mwifiex_11n_find_last_seq_num(reorder_cnxt->ptr);
- if (start_win >= 0) {
- dev_dbg(reorder_cnxt->priv->adapter->dev,
- "info: flush data %d\n", start_win);
- mwifiex_11n_dispatch_pkt_until_start_win(reorder_cnxt->priv,
- reorder_cnxt->ptr,
- ((reorder_cnxt->ptr->start_win +
- start_win + 1) & (MAX_TID_VALUE - 1)));
- }
+ start_win = mwifiex_11n_find_last_seq_num(ctx->ptr);
+
+ if (start_win < 0)
+ return;
+
+ dev_dbg(ctx->priv->adapter->dev, "info: flush data %d\n", start_win);
+ mwifiex_11n_dispatch_pkt(ctx->priv, ctx->ptr,
+ (ctx->ptr->start_win + start_win + 1) &
+ (MAX_TID_VALUE - 1));
}
/*
@@ -227,10 +220,10 @@ mwifiex_flush_data(unsigned long context)
*/
static void
mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta,
- int tid, int win_size, int seq_num)
+ int tid, int win_size, int seq_num)
{
int i;
- struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr, *new_node;
+ struct mwifiex_rx_reorder_tbl *tbl, *new_node;
u16 last_seq = 0;
unsigned long flags;
@@ -238,17 +231,16 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta,
* If we get a TID, ta pair which is already present dispatch all the
* the packets and move the window size until the ssn
*/
- rx_reor_tbl_ptr = mwifiex_11n_get_rx_reorder_tbl(priv, tid, ta);
- if (rx_reor_tbl_ptr) {
- mwifiex_11n_dispatch_pkt_until_start_win(priv, rx_reor_tbl_ptr,
- seq_num);
+ tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, ta);
+ if (tbl) {
+ mwifiex_11n_dispatch_pkt(priv, tbl, seq_num);
return;
}
- /* if !rx_reor_tbl_ptr then create one */
+ /* if !tbl then create one */
new_node = kzalloc(sizeof(struct mwifiex_rx_reorder_tbl), GFP_KERNEL);
if (!new_node) {
dev_err(priv->adapter->dev, "%s: failed to alloc new_node\n",
- __func__);
+ __func__);
return;
}
@@ -360,7 +352,8 @@ int mwifiex_cmd_11n_addba_rsp_gen(struct mwifiex_private *priv,
cmd_addba_req->block_ack_param_set = cpu_to_le16(block_ack_param_set);
mwifiex_11n_create_rx_reorder_tbl(priv, cmd_addba_req->peer_mac_addr,
- tid, win_size, le16_to_cpu(cmd_addba_req->ssn));
+ tid, win_size,
+ le16_to_cpu(cmd_addba_req->ssn));
return 0;
}
@@ -401,35 +394,34 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
u16 seq_num, u16 tid,
u8 *ta, u8 pkt_type, void *payload)
{
- struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr;
+ struct mwifiex_rx_reorder_tbl *tbl;
int start_win, end_win, win_size;
u16 pkt_index;
- rx_reor_tbl_ptr =
- mwifiex_11n_get_rx_reorder_tbl((struct mwifiex_private *) priv,
- tid, ta);
- if (!rx_reor_tbl_ptr) {
+ tbl = mwifiex_11n_get_rx_reorder_tbl((struct mwifiex_private *) priv,
+ tid, ta);
+ if (!tbl) {
if (pkt_type != PKT_TYPE_BAR)
mwifiex_process_rx_packet(priv->adapter, payload);
return 0;
}
- start_win = rx_reor_tbl_ptr->start_win;
- win_size = rx_reor_tbl_ptr->win_size;
+ start_win = tbl->start_win;
+ win_size = tbl->win_size;
end_win = ((start_win + win_size) - 1) & (MAX_TID_VALUE - 1);
- del_timer(&rx_reor_tbl_ptr->timer_context.timer);
- mod_timer(&rx_reor_tbl_ptr->timer_context.timer, jiffies
- + (MIN_FLUSH_TIMER_MS * win_size * HZ) / 1000);
+ del_timer(&tbl->timer_context.timer);
+ mod_timer(&tbl->timer_context.timer,
+ jiffies + (MIN_FLUSH_TIMER_MS * win_size * HZ) / 1000);
/*
* If seq_num is less then starting win then ignore and drop the
* packet
*/
if ((start_win + TWOPOW11) > (MAX_TID_VALUE - 1)) {/* Wrap */
- if (seq_num >= ((start_win + (TWOPOW11)) & (MAX_TID_VALUE - 1))
- && (seq_num < start_win))
+ if (seq_num >= ((start_win + TWOPOW11) &
+ (MAX_TID_VALUE - 1)) && (seq_num < start_win))
return -1;
- } else if ((seq_num < start_win)
- || (seq_num > (start_win + (TWOPOW11)))) {
+ } else if ((seq_num < start_win) ||
+ (seq_num > (start_win + TWOPOW11))) {
return -1;
}
@@ -440,17 +432,17 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
if (pkt_type == PKT_TYPE_BAR)
seq_num = ((seq_num + win_size) - 1) & (MAX_TID_VALUE - 1);
- if (((end_win < start_win)
- && (seq_num < (TWOPOW11 - (MAX_TID_VALUE - start_win)))
- && (seq_num > end_win)) || ((end_win > start_win)
- && ((seq_num > end_win) || (seq_num < start_win)))) {
+ if (((end_win < start_win) &&
+ (seq_num < (TWOPOW11 - (MAX_TID_VALUE - start_win))) &&
+ (seq_num > end_win)) ||
+ ((end_win > start_win) && ((seq_num > end_win) ||
+ (seq_num < start_win)))) {
end_win = seq_num;
if (((seq_num - win_size) + 1) >= 0)
start_win = (end_win - win_size) + 1;
else
start_win = (MAX_TID_VALUE - (win_size - seq_num)) + 1;
- mwifiex_11n_dispatch_pkt_until_start_win(priv,
- rx_reor_tbl_ptr, start_win);
+ mwifiex_11n_dispatch_pkt(priv, tbl, start_win);
}
if (pkt_type != PKT_TYPE_BAR) {
@@ -459,17 +451,17 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
else
pkt_index = (seq_num+MAX_TID_VALUE) - start_win;
- if (rx_reor_tbl_ptr->rx_reorder_ptr[pkt_index])
+ if (tbl->rx_reorder_ptr[pkt_index])
return -1;
- rx_reor_tbl_ptr->rx_reorder_ptr[pkt_index] = payload;
+ tbl->rx_reorder_ptr[pkt_index] = payload;
}
/*
* Dispatch all packets sequentially from start_win until a
* hole is found and adjust the start_win appropriately
*/
- mwifiex_11n_scan_and_dispatch(priv, rx_reor_tbl_ptr);
+ mwifiex_11n_scan_and_dispatch(priv, tbl);
return 0;
}
@@ -480,10 +472,10 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
* The TID/TA are taken from del BA event body.
*/
void
-mwifiex_11n_delete_ba_stream_tbl(struct mwifiex_private *priv, int tid,
- u8 *peer_mac, u8 type, int initiator)
+mwifiex_del_ba_tbl(struct mwifiex_private *priv, int tid, u8 *peer_mac,
+ u8 type, int initiator)
{
- struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr;
+ struct mwifiex_rx_reorder_tbl *tbl;
struct mwifiex_tx_ba_stream_tbl *ptx_tbl;
u8 cleanup_rx_reorder_tbl;
unsigned long flags;
@@ -493,23 +485,23 @@ mwifiex_11n_delete_ba_stream_tbl(struct mwifiex_private *priv, int tid,
else
cleanup_rx_reorder_tbl = (initiator) ? false : true;
- dev_dbg(priv->adapter->dev, "event: DELBA: %pM tid=%d, "
- "initiator=%d\n", peer_mac, tid, initiator);
+ dev_dbg(priv->adapter->dev, "event: DELBA: %pM tid=%d initiator=%d\n",
+ peer_mac, tid, initiator);
if (cleanup_rx_reorder_tbl) {
- rx_reor_tbl_ptr = mwifiex_11n_get_rx_reorder_tbl(priv, tid,
+ tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid,
peer_mac);
- if (!rx_reor_tbl_ptr) {
+ if (!tbl) {
dev_dbg(priv->adapter->dev,
- "event: TID, TA not found in table\n");
+ "event: TID, TA not found in table\n");
return;
}
- mwifiex_11n_delete_rx_reorder_tbl_entry(priv, rx_reor_tbl_ptr);
+ mwifiex_del_rx_reorder_entry(priv, tbl);
} else {
- ptx_tbl = mwifiex_11n_get_tx_ba_stream_tbl(priv, tid, peer_mac);
+ ptx_tbl = mwifiex_get_ba_tbl(priv, tid, peer_mac);
if (!ptx_tbl) {
dev_dbg(priv->adapter->dev,
- "event: TID, RA not found in table\n");
+ "event: TID, RA not found in table\n");
return;
}
@@ -532,7 +524,7 @@ int mwifiex_ret_11n_addba_resp(struct mwifiex_private *priv,
(struct host_cmd_ds_11n_addba_rsp *)
&resp->params.add_ba_rsp;
int tid, win_size;
- struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr;
+ struct mwifiex_rx_reorder_tbl *tbl;
uint16_t block_ack_param_set;
block_ack_param_set = le16_to_cpu(add_ba_rsp->block_ack_param_set);
@@ -548,19 +540,18 @@ int mwifiex_ret_11n_addba_resp(struct mwifiex_private *priv,
IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK)
>> BLOCKACKPARAM_WINSIZE_POS;
- dev_dbg(priv->adapter->dev, "cmd: ADDBA RSP: %pM"
- " tid=%d ssn=%d win_size=%d\n",
- add_ba_rsp->peer_mac_addr,
- tid, add_ba_rsp->ssn, win_size);
+ dev_dbg(priv->adapter->dev,
+ "cmd: ADDBA RSP: %pM tid=%d ssn=%d win_size=%d\n",
+ add_ba_rsp->peer_mac_addr, tid,
+ add_ba_rsp->ssn, win_size);
} else {
dev_err(priv->adapter->dev, "ADDBA RSP: failed %pM tid=%d)\n",
- add_ba_rsp->peer_mac_addr, tid);
+ add_ba_rsp->peer_mac_addr, tid);
- rx_reor_tbl_ptr = mwifiex_11n_get_rx_reorder_tbl(priv,
- tid, add_ba_rsp->peer_mac_addr);
- if (rx_reor_tbl_ptr)
- mwifiex_11n_delete_rx_reorder_tbl_entry(priv,
- rx_reor_tbl_ptr);
+ tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid,
+ add_ba_rsp->peer_mac_addr);
+ if (tbl)
+ mwifiex_del_rx_reorder_entry(priv, tbl);
}
return 0;
@@ -599,7 +590,7 @@ void mwifiex_11n_cleanup_reorder_tbl(struct mwifiex_private *priv)
list_for_each_entry_safe(del_tbl_ptr, tmp_node,
&priv->rx_reorder_tbl_ptr, list) {
spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags);
- mwifiex_11n_delete_rx_reorder_tbl_entry(priv, del_tbl_ptr);
+ mwifiex_del_rx_reorder_entry(priv, del_tbl_ptr);
spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags);
}
spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags);