Merge tag 'staging-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[linux-2.6-microblaze.git] / drivers / staging / wfx / queue.c
index ec11a63..0bcc61f 100644 (file)
@@ -175,11 +175,9 @@ void wfx_tx_queues_deinit(struct wfx_dev *wdev)
        wfx_tx_queues_clear(wdev);
 }
 
-size_t wfx_tx_queue_get_num_queued(struct wfx_queue *queue,
-                                  u32 link_id_map)
+int wfx_tx_queue_get_num_queued(struct wfx_queue *queue, u32 link_id_map)
 {
-       size_t ret;
-       int i, bit;
+       int ret, i;
 
        if (!link_id_map)
                return 0;
@@ -189,11 +187,9 @@ size_t wfx_tx_queue_get_num_queued(struct wfx_queue *queue,
                ret = skb_queue_len(&queue->queue);
        } else {
                ret = 0;
-               for (i = 0, bit = 1; i < ARRAY_SIZE(queue->link_map_cache);
-                    ++i, bit <<= 1) {
-                       if (link_id_map & bit)
+               for (i = 0; i < ARRAY_SIZE(queue->link_map_cache); i++)
+                       if (link_id_map & BIT(i))
                                ret += queue->link_map_cache[i];
-               }
        }
        spin_unlock_bh(&queue->queue.lock);
        return ret;
@@ -359,75 +355,38 @@ bool wfx_tx_queues_is_empty(struct wfx_dev *wdev)
 static bool hif_handle_tx_data(struct wfx_vif *wvif, struct sk_buff *skb,
                               struct wfx_queue *queue)
 {
-       bool handled = false;
-       struct wfx_tx_priv *tx_priv = wfx_skb_tx_priv(skb);
        struct hif_req_tx *req = wfx_skb_txreq(skb);
-       struct ieee80211_hdr *frame = (struct ieee80211_hdr *) (req->frame + req->data_flags.fc_offset);
-
-       enum {
-               do_probe,
-               do_drop,
-               do_wep,
-               do_tx,
-       } action = do_tx;
-
-       switch (wvif->vif->type) {
-       case NL80211_IFTYPE_STATION:
-               if (wvif->state < WFX_STATE_PRE_STA)
-                       action = do_drop;
-               break;
-       case NL80211_IFTYPE_AP:
-               if (!wvif->state)
-                       action = do_drop;
-               break;
-       case NL80211_IFTYPE_ADHOC:
-               if (wvif->state != WFX_STATE_IBSS)
-                       action = do_drop;
-               break;
-       case NL80211_IFTYPE_MONITOR:
-       default:
-               action = do_drop;
-               break;
-       }
-
-       if (action == do_tx) {
-               if (ieee80211_is_nullfunc(frame->frame_control)) {
-                       mutex_lock(&wvif->bss_loss_lock);
-                       if (wvif->bss_loss_state) {
-                               wvif->bss_loss_confirm_id = req->packet_id;
-                               req->queue_id.queue_id = HIF_QUEUE_ID_VOICE;
-                       }
-                       mutex_unlock(&wvif->bss_loss_lock);
-               } else if (ieee80211_has_protected(frame->frame_control) &&
-                          tx_priv->hw_key &&
-                          tx_priv->hw_key->keyidx != wvif->wep_default_key_id &&
-                          (tx_priv->hw_key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
-                           tx_priv->hw_key->cipher == WLAN_CIPHER_SUITE_WEP104)) {
-                       action = do_wep;
+       struct ieee80211_key_conf *hw_key = wfx_skb_tx_priv(skb)->hw_key;
+       struct ieee80211_hdr *frame =
+               (struct ieee80211_hdr *)(req->frame + req->data_flags.fc_offset);
+
+       // FIXME: mac80211 is smart enough to handle BSS loss. Driver should not
+       // try to do anything about that.
+       if (ieee80211_is_nullfunc(frame->frame_control)) {
+               mutex_lock(&wvif->bss_loss_lock);
+               if (wvif->bss_loss_state) {
+                       wvif->bss_loss_confirm_id = req->packet_id;
+                       req->queue_id.queue_id = HIF_QUEUE_ID_VOICE;
                }
+               mutex_unlock(&wvif->bss_loss_lock);
        }
 
-       switch (action) {
-       case do_drop:
-               wfx_pending_remove(wvif->wdev, skb);
-               handled = true;
-               break;
-       case do_wep:
+       // FIXME: identify the exact scenario matched by this condition. Does it
+       // happen yet?
+       if (ieee80211_has_protected(frame->frame_control) &&
+           hw_key && hw_key->keyidx != wvif->wep_default_key_id &&
+           (hw_key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
+            hw_key->cipher == WLAN_CIPHER_SUITE_WEP104)) {
                wfx_tx_lock(wvif->wdev);
                WARN_ON(wvif->wep_pending_skb);
-               wvif->wep_default_key_id = tx_priv->hw_key->keyidx;
+               wvif->wep_default_key_id = hw_key->keyidx;
                wvif->wep_pending_skb = skb;
                if (!schedule_work(&wvif->wep_key_work))
                        wfx_tx_unlock(wvif->wdev);
-               handled = true;
-               break;
-       case do_tx:
-               break;
-       default:
-               /* Do nothing */
-               break;
+               return true;
+       } else {
+               return false;
        }
-       return handled;
 }
 
 static int wfx_get_prio_queue(struct wfx_vif *wvif,
@@ -592,7 +551,7 @@ struct hif_msg *wfx_tx_queues_get(struct wfx_dev *wdev)
 
                /* allow bursting if txop is set */
                if (wvif->edca_params[queue_num].txop)
-                       burst = (int)wfx_tx_queue_get_num_queued(queue, tx_allowed_mask) + 1;
+                       burst = wfx_tx_queue_get_num_queued(queue, tx_allowed_mask) + 1;
                else
                        burst = 1;