diff options
-rw-r--r-- | drivers/staging/cw1200/debug.c | 2 | ||||
-rw-r--r-- | drivers/staging/cw1200/queue.c | 49 | ||||
-rw-r--r-- | drivers/staging/cw1200/queue.h | 16 | ||||
-rw-r--r-- | drivers/staging/cw1200/txrx.c | 47 | ||||
-rw-r--r-- | drivers/staging/cw1200/txrx.h | 8 | ||||
-rw-r--r-- | drivers/staging/cw1200/wsm.c | 22 |
6 files changed, 74 insertions, 70 deletions
diff --git a/drivers/staging/cw1200/debug.c b/drivers/staging/cw1200/debug.c index 6ec0d086d8b..e1fc0a8a748 100644 --- a/drivers/staging/cw1200/debug.c +++ b/drivers/staging/cw1200/debug.c @@ -384,7 +384,7 @@ static ssize_t cw1200_11n_read(struct file *file, } static ssize_t cw1200_11n_write(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos) + const char __user *user_buf, size_t count, loff_t *ppos) { struct cw1200_common *priv = file->private_data; struct ieee80211_supported_band *band[2] = { diff --git a/drivers/staging/cw1200/queue.c b/drivers/staging/cw1200/queue.c index ef7d48488bd..c667c433766 100644 --- a/drivers/staging/cw1200/queue.c +++ b/drivers/staging/cw1200/queue.c @@ -20,16 +20,8 @@ struct list_head head; struct sk_buff *skb; u32 packetID; - /* For safety purposes only. I do not trust device too much. - * It was observed (last time quite long time ago) that it - * indicates TX for a packet several times, so it was not enough - * to use offset or address as an uniquie ID in a - * queue. - */ + struct cw1200_txpriv txpriv; u8 generation; - u8 link_id; - u8 raw_link_id; - u8 tid; }; static inline void __cw1200_queue_lock(struct cw1200_queue *queue, @@ -200,20 +192,18 @@ size_t cw1200_queue_get_num_queued(struct cw1200_queue *queue, } int cw1200_queue_put(struct cw1200_queue *queue, struct cw1200_common *priv, - struct sk_buff *skb, struct tx_info *txinfo, - u8 raw_link_id, u8 tid) + struct sk_buff *skb, struct cw1200_txpriv *txpriv) { int ret; struct wsm_tx *wsm; struct cw1200_queue_stats *stats = queue->stats; - u8 link_id = txinfo->link_id; wsm = (struct wsm_tx *)skb_push(skb, sizeof(struct wsm_tx)); - ret = cw1200_skb_to_wsm(priv, skb, wsm, txinfo); + ret = cw1200_skb_to_wsm(priv, skb, wsm, txpriv); if (ret) return ret; - if (link_id >= queue->stats->map_capacity) + if (txpriv->link_id >= queue->stats->map_capacity) return -EINVAL; spin_lock_bh(&queue->lock); @@ -224,21 +214,19 @@ int cw1200_queue_put(struct cw1200_queue *queue, struct cw1200_common *priv, list_move_tail(&item->head, &queue->queue); item->skb = skb; + item->txpriv = *txpriv; item->generation = 0; item->packetID = cw1200_queue_make_packet_id( queue->generation, queue->queue_id, item->generation, item - queue->pool); wsm->packetID = __cpu_to_le32(item->packetID); - item->link_id = link_id; - item->raw_link_id = raw_link_id; - item->tid = tid; ++queue->num_queued; - ++queue->link_map_cache[link_id]; + ++queue->link_map_cache[txpriv->link_id]; spin_lock_bh(&stats->lock); ++stats->num_queued; - ++stats->link_map_cache[link_id]; + ++stats->link_map_cache[txpriv->link_id]; spin_unlock_bh(&stats->lock); if (queue->num_queued >= queue->capacity) { @@ -256,7 +244,7 @@ int cw1200_queue_get(struct cw1200_queue *queue, u32 link_id_map, struct wsm_tx **tx, struct ieee80211_tx_info **tx_info, - int *link_id) + const struct cw1200_txpriv **txpriv) { int ret = -ENOENT; struct cw1200_queue_item *item; @@ -265,7 +253,7 @@ int cw1200_queue_get(struct cw1200_queue *queue, spin_lock_bh(&queue->lock); list_for_each_entry(item, &queue->queue, head) { - if (link_id_map & BIT(item->link_id)) { + if (link_id_map & BIT(item->txpriv.link_id)) { ret = 0; break; } @@ -274,14 +262,14 @@ int cw1200_queue_get(struct cw1200_queue *queue, if (!WARN_ON(ret)) { *tx = (struct wsm_tx *)item->skb->data; *tx_info = IEEE80211_SKB_CB(item->skb); - *link_id = item->raw_link_id; + *txpriv = &item->txpriv; list_move_tail(&item->head, &queue->pending); ++queue->num_pending; - --queue->link_map_cache[item->link_id]; + --queue->link_map_cache[item->txpriv.link_id]; spin_lock_bh(&stats->lock); --stats->num_queued; - if (!--stats->link_map_cache[item->link_id]) + if (!--stats->link_map_cache[item->txpriv.link_id]) wakeup_stats = true; spin_unlock_bh(&stats->lock); } @@ -316,11 +304,11 @@ int cw1200_queue_requeue(struct cw1200_queue *queue, u32 packetID) } else { struct wsm_tx *wsm = (struct wsm_tx *)item->skb->data; --queue->num_pending; - ++queue->link_map_cache[item->link_id]; + ++queue->link_map_cache[item->txpriv.link_id]; spin_lock_bh(&stats->lock); ++stats->num_queued; - ++stats->link_map_cache[item->link_id]; + ++stats->link_map_cache[item->txpriv.link_id]; spin_unlock_bh(&stats->lock); item->generation = ++item_generation; @@ -343,11 +331,11 @@ int cw1200_queue_requeue_all(struct cw1200_queue *queue) struct wsm_tx *wsm = (struct wsm_tx *)item->skb->data; --queue->num_pending; - ++queue->link_map_cache[item->link_id]; + ++queue->link_map_cache[item->txpriv.link_id]; spin_lock_bh(&stats->lock); ++stats->num_queued; - ++stats->link_map_cache[item->link_id]; + ++stats->link_map_cache[item->txpriv.link_id]; spin_unlock_bh(&stats->lock); ++item->generation; @@ -411,7 +399,8 @@ int cw1200_queue_remove(struct cw1200_queue *queue, struct cw1200_common *priv, } int cw1200_queue_get_skb(struct cw1200_queue *queue, u32 packetID, - struct sk_buff **skb, int *tid) + struct sk_buff **skb, + const struct cw1200_txpriv **txpriv) { int ret = 0; u8 queue_generation, queue_id, item_generation, item_id; @@ -433,7 +422,7 @@ int cw1200_queue_get_skb(struct cw1200_queue *queue, u32 packetID, ret = -ENOENT; } else { *skb = item->skb; - *tid = item->tid; + *txpriv = &item->txpriv; item->skb = NULL; } spin_unlock_bh(&queue->lock); diff --git a/drivers/staging/cw1200/queue.h b/drivers/staging/cw1200/queue.h index d1802c36f02..195d6acb6ec 100644 --- a/drivers/staging/cw1200/queue.h +++ b/drivers/staging/cw1200/queue.h @@ -18,7 +18,7 @@ /* extern */ struct wsm_tx; /* extern */ struct cw1200_common; /* extern */ struct ieee80211_tx_queue_stats; -/* extern */ struct tx_info; +/* extern */ struct cw1200_txpriv; /* forward */ struct cw1200_queue_stats; @@ -48,6 +48,12 @@ struct cw1200_queue_stats { wait_queue_head_t wait_link_id_empty; }; +struct cw1200_txpriv { + u8 link_id; + u8 raw_link_id; + u8 tid; +}; + int cw1200_queue_stats_init(struct cw1200_queue_stats *stats, size_t map_capacity); int cw1200_queue_init(struct cw1200_queue *queue, @@ -61,19 +67,19 @@ void cw1200_queue_deinit(struct cw1200_queue *queue); size_t cw1200_queue_get_num_queued(struct cw1200_queue *queue, u32 link_id_map); int cw1200_queue_put(struct cw1200_queue *queue, struct cw1200_common *cw1200, - struct sk_buff *skb, struct tx_info *txinfo, - u8 raw_link_id, u8 tid); + struct sk_buff *skb, struct cw1200_txpriv *txpriv); int cw1200_queue_get(struct cw1200_queue *queue, u32 link_id_map, struct wsm_tx **tx, struct ieee80211_tx_info **tx_info, - int *link_id); + const struct cw1200_txpriv **txpriv); int cw1200_queue_requeue(struct cw1200_queue *queue, u32 packetID); int cw1200_queue_requeue_all(struct cw1200_queue *queue); int cw1200_queue_remove(struct cw1200_queue *queue, struct cw1200_common *priv, u32 packetID); int cw1200_queue_get_skb(struct cw1200_queue *queue, u32 packetID, - struct sk_buff **skb, int *tid); + struct sk_buff **skb, + const struct cw1200_txpriv **txpriv); void cw1200_queue_lock(struct cw1200_queue *queue, struct cw1200_common *cw1200); void cw1200_queue_unlock(struct cw1200_queue *queue, diff --git a/drivers/staging/cw1200/txrx.c b/drivers/staging/cw1200/txrx.c index b0028ae81dc..5a55386127c 100644 --- a/drivers/staging/cw1200/txrx.c +++ b/drivers/staging/cw1200/txrx.c @@ -24,6 +24,12 @@ #define tx_policy_printk(...) #endif +/* txrx private */ +struct __cw1200_txpriv { + struct cw1200_txpriv super; + u16 ethertype; +}; + static int cw1200_handle_action_rx(struct cw1200_common *priv, struct sk_buff *skb); static int cw1200_handle_action_tx(struct cw1200_common *priv, @@ -371,8 +377,10 @@ cw1200_get_tx_rate(const struct cw1200_common *priv, /* NOTE: cw1200_skb_to_wsm executes in atomic context. */ int cw1200_skb_to_wsm(struct cw1200_common *priv, struct sk_buff *skb, - struct wsm_tx *wsm, struct tx_info *txinfo) + struct wsm_tx *wsm, struct cw1200_txpriv *txpriv) { + struct __cw1200_txpriv *info = + container_of(txpriv, struct __cw1200_txpriv, super); bool tx_policy_renew = false; struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); const struct ieee80211_rate *rate = cw1200_get_tx_rate(priv, @@ -416,7 +424,7 @@ int cw1200_skb_to_wsm(struct cw1200_common *priv, struct sk_buff *skb, struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data + sizeof(struct wsm_tx)); - if (cpu_to_be16(txinfo->ethertype) == ETH_P_PAE) + if (cpu_to_be16(info->ethertype) == ETH_P_PAE) priority = WSM_EPTA_PRIORITY_EAPOL; else if (ieee80211_is_action(hdr->frame_control)) priority = WSM_EPTA_PRIORITY_ACTION; @@ -449,14 +457,15 @@ void cw1200_tx(struct ieee80211_hw *dev, struct sk_buff *skb) struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; int was_buffered = 0; - int tid = CW1200_MAX_TID; const u8 *da = ieee80211_get_DA(hdr); struct cw1200_sta_priv *sta_priv = (struct cw1200_sta_priv *)&tx_info->control.sta->drv_priv; int link_id, raw_link_id; int ret; int i; - struct tx_info txinfo; + struct __cw1200_txpriv txpriv = { + .super.tid = CW1200_MAX_TID, + }; if (likely(tx_info->control.sta && sta_priv->link_id)) raw_link_id = link_id = sta_priv->link_id; @@ -503,15 +512,15 @@ void cw1200_tx(struct ieee80211_hw *dev, struct sk_buff *skb) } else if (ieee80211_is_data_qos(hdr->frame_control) || ieee80211_is_qos_nullfunc(hdr->frame_control)) { u8 *qos = ieee80211_get_qos_ctl(hdr); - tid = qos[0] & IEEE80211_QOS_CTL_TID_MASK; + txpriv.super.tid = qos[0] & IEEE80211_QOS_CTL_TID_MASK; } else if (ieee80211_is_data(hdr->frame_control) || ieee80211_is_nullfunc(hdr->frame_control)) { - tid = 0; + txpriv.super.tid = 0; } /* BT Coex support related configuration */ if (priv->is_BT_Present) { - txinfo.ethertype = 0; + txpriv.ethertype = 0; if (ieee80211_is_data_qos(hdr->frame_control) || ieee80211_is_data(hdr->frame_control)) { @@ -520,7 +529,7 @@ void cw1200_tx(struct ieee80211_hw *dev, struct sk_buff *skb) /* Skip LLC SNAP header (+6) */ if (headerlen > 0) - txinfo.ethertype = + txpriv.ethertype = *((u16 *)(skb->data + headerlen + 6)); } else if (ieee80211_is_assoc_req(hdr->frame_control) || @@ -621,19 +630,20 @@ void cw1200_tx(struct ieee80211_hw *dev, struct sk_buff *skb) &priv->multicast_start_work); } - txinfo.link_id = link_id; - - if (raw_link_id && tid < CW1200_MAX_TID) + if (raw_link_id && txpriv.super.tid < CW1200_MAX_TID) was_buffered = priv->link_id_db[raw_link_id - 1] - .buffered[tid]++; + .buffered[txpriv.super.tid]++; + txpriv.super.link_id = link_id; + txpriv.super.raw_link_id = raw_link_id; ret = cw1200_queue_put(&priv->tx_queue[queue], priv, skb, - &txinfo, raw_link_id, tid); + &txpriv.super); spin_unlock_bh(&priv->buffered_multicasts_lock); - if (raw_link_id && !was_buffered && tid < CW1200_MAX_TID) - ieee80211_sta_set_buffered(tx_info->control.sta, tid, true); + if (raw_link_id && !was_buffered && txpriv.super.tid < CW1200_MAX_TID) + ieee80211_sta_set_buffered(tx_info->control.sta, + txpriv.super.tid, true); if (!WARN_ON(ret)) cw1200_bh_wakeup(priv); @@ -739,7 +749,7 @@ void cw1200_tx_confirm_cb(struct cw1200_common *priv, u8 queue_id = cw1200_queue_get_queue_id(arg->packetID); struct cw1200_queue *queue = &priv->tx_queue[queue_id]; struct sk_buff *skb; - int tid = CW1200_MAX_TID; + const struct cw1200_txpriv *txpriv = NULL; txrx_printk(KERN_DEBUG "[TX] TX confirm: %d, %d.\n", arg->status, arg->ackFailures); @@ -773,7 +783,7 @@ void cw1200_tx_confirm_cb(struct cw1200_common *priv, WARN_ON(cw1200_queue_requeue(queue, arg->packetID)); } else if (!WARN_ON(cw1200_queue_get_skb( - queue, arg->packetID, &skb, &tid))) { + queue, arg->packetID, &skb, &txpriv))) { struct ieee80211_tx_info *tx = IEEE80211_SKB_CB(skb); struct wsm_tx *wsm_tx = (struct wsm_tx *)skb->data; int rate_id = (wsm_tx->flags >> 4) & 0x07; @@ -827,7 +837,8 @@ void cw1200_tx_confirm_cb(struct cw1200_common *priv, } skb_pull(skb, sizeof(struct wsm_tx)); - cw1200_notify_buffered_tx(priv, skb, arg->link_id, tid); + cw1200_notify_buffered_tx(priv, skb, arg->link_id, + txpriv->tid); ieee80211_tx_status(priv->hw, skb); WARN_ON(cw1200_queue_remove(queue, priv, arg->packetID)); } diff --git a/drivers/staging/cw1200/txrx.h b/drivers/staging/cw1200/txrx.h index 4bf792f23a8..87dbdfa949c 100644 --- a/drivers/staging/cw1200/txrx.h +++ b/drivers/staging/cw1200/txrx.h @@ -18,6 +18,7 @@ /* extern */ struct sk_buff; /* extern */ struct wsm_tx; /* extern */ struct wsm_tx_confirm; +/* extern */ struct cw1200_txpriv; struct tx_policy { union { @@ -43,11 +44,6 @@ struct tx_policy_cache { spinlock_t lock; }; -struct tx_info { - u8 link_id; - u16 ethertype; -}; - /* ******************************************************************** */ /* TX policy cache */ /* Intention of TX policy cache is an overcomplicated WSM API. @@ -66,7 +62,7 @@ u32 cw1200_rate_mask_to_wsm(struct cw1200_common *priv, u32 rates); int cw1200_skb_to_wsm(struct cw1200_common *priv, struct sk_buff *skb, struct wsm_tx *wsm, - struct tx_info *txinfo); + struct cw1200_txpriv *txpriv); void cw1200_tx(struct ieee80211_hw *dev, struct sk_buff *skb); void cw1200_notify_buffered_tx(struct cw1200_common *priv, struct sk_buff *skb, int link_id, int tid); diff --git a/drivers/staging/cw1200/wsm.c b/drivers/staging/cw1200/wsm.c index 0a3b564face..415fbcbee59 100644 --- a/drivers/staging/cw1200/wsm.c +++ b/drivers/staging/cw1200/wsm.c @@ -1399,7 +1399,7 @@ static bool wsm_handle_tx_data(struct cw1200_common *priv, * probe responses. * The easiest way to get it back is to convert * probe request into WSM start_scan command. */ - int tid; + const struct cw1200_txpriv *txpriv; int rate_id = (wsm->flags >> 4) & 0x07; struct cw1200_queue *queue = &priv->tx_queue[cw1200_queue_get_queue_id( @@ -1410,7 +1410,7 @@ static bool wsm_handle_tx_data(struct cw1200_common *priv, BUG_ON(priv->scan.probe_skb); BUG_ON(cw1200_queue_get_skb(queue, wsm->packetID, - &priv->scan.probe_skb, &tid)); + &priv->scan.probe_skb, &txpriv)); BUG_ON(cw1200_queue_remove(queue, priv, wsm->packetID)); /* Release used TX rate policy */ @@ -1426,15 +1426,16 @@ static bool wsm_handle_tx_data(struct cw1200_common *priv, * We are dropping everything except AUTH in non-joined mode. */ struct sk_buff *skb; int rate_id = (wsm->flags >> 4) & 0x07; - int tid = 8; + const struct cw1200_txpriv *txpriv = NULL; struct cw1200_queue *queue = &priv->tx_queue[cw1200_queue_get_queue_id( wsm->packetID)]; wsm_printk(KERN_DEBUG "[WSM] Drop frame (0x%.4X):" " not joined.\n", fctl); - BUG_ON(cw1200_queue_get_skb(queue, wsm->packetID, &skb, &tid)); + BUG_ON(cw1200_queue_get_skb(queue, wsm->packetID, + &skb, &txpriv)); skb_pull(skb, sizeof(struct wsm_tx)); - cw1200_notify_buffered_tx(priv, skb, link_id, tid); + cw1200_notify_buffered_tx(priv, skb, link_id, txpriv->tid); BUG_ON(cw1200_queue_remove(queue, priv, wsm->packetID)); /* Release used TX rate policy */ tx_policy_put(priv, rate_id); @@ -1580,7 +1581,7 @@ int wsm_get_tx(struct cw1200_common *priv, u8 **data, struct ieee80211_tx_info *tx_info; struct cw1200_queue *queue; u32 tx_allowed_mask = 0; - int link_id; + const struct cw1200_txpriv *txpriv = NULL; /* * Count was intended as an input for wsm->more flag. * During implementation it was found that wsm->more @@ -1629,17 +1630,18 @@ int wsm_get_tx(struct cw1200_common *priv, u8 **data, if (cw1200_queue_get(queue, tx_allowed_mask, - &wsm, &tx_info, &link_id)) + &wsm, &tx_info, &txpriv)) continue; - if (wsm_handle_tx_data(priv, wsm, tx_info, link_id)) + if (wsm_handle_tx_data(priv, wsm, + tx_info, txpriv->raw_link_id)) continue; /* Handled by WSM */ wsm->hdr.id &= __cpu_to_le16( ~WSM_TX_LINK_ID(WSM_TX_LINK_ID_MAX)); wsm->hdr.id |= cpu_to_le16( - WSM_TX_LINK_ID(link_id)); - priv->pspoll_mask &= ~BIT(link_id); + WSM_TX_LINK_ID(txpriv->raw_link_id)); + priv->pspoll_mask &= ~BIT(txpriv->raw_link_id); *data = (u8 *)wsm; *tx_len = __le16_to_cpu(wsm->hdr.len); |