OSDN Git Service

mac80211: add get TID helper
authorSara Sharon <sara.sharon@intel.com>
Mon, 19 Feb 2018 12:48:40 +0000 (14:48 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 22 Feb 2018 20:13:03 +0000 (21:13 +0100)
Extracting the TID from the QOS header is common enough
to justify helper.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/linux/ieee80211.h
net/mac80211/iface.c
net/mac80211/michael.c
net/mac80211/mlme.c
net/mac80211/rc80211_minstrel_ht.c
net/mac80211/rx.c
net/mac80211/tx.c
net/mac80211/wpa.c

index e4cba33..8fe7e43 100644 (file)
@@ -8,6 +8,7 @@
  * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
  * Copyright (c) 2013 - 2014 Intel Mobile Communications GmbH
  * Copyright (c) 2016 - 2017 Intel Deutschland GmbH
+ * Copyright (c) 2018        Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -2502,6 +2503,17 @@ static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
 }
 
 /**
+ * ieee80211_get_tid - get qos TID
+ * @hdr: the frame
+ */
+static inline u8 ieee80211_get_tid(struct ieee80211_hdr *hdr)
+{
+       u8 *qc = ieee80211_get_qos_ctl(hdr);
+
+       return qc[0] & IEEE80211_QOS_CTL_TID_MASK;
+}
+
+/**
  * ieee80211_get_SA - get pointer to SA
  * @hdr: the frame
  *
index 5fe01f8..d13ba06 100644 (file)
@@ -1324,8 +1324,7 @@ static void ieee80211_iface_work(struct work_struct *work)
                        mutex_lock(&local->sta_mtx);
                        sta = sta_info_get_bss(sdata, mgmt->sa);
                        if (sta) {
-                               u16 tid = *ieee80211_get_qos_ctl(hdr) &
-                                               IEEE80211_QOS_CTL_TID_MASK;
+                               u16 tid = ieee80211_get_tid(hdr);
 
                                __ieee80211_stop_rx_ba_session(
                                        sta, tid, WLAN_BACK_RECIPIENT,
index 408649b..37e1727 100644 (file)
@@ -35,7 +35,7 @@ static void michael_mic_hdr(struct michael_mic_ctx *mctx, const u8 *key,
        da = ieee80211_get_DA(hdr);
        sa = ieee80211_get_SA(hdr);
        if (ieee80211_is_data_qos(hdr->frame_control))
-               tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
+               tid = ieee80211_get_tid(hdr);
        else
                tid = 0;
 
index 39b660b..010b127 100644 (file)
@@ -2151,7 +2151,7 @@ static void ieee80211_sta_tx_wmm_ac_notify(struct ieee80211_sub_if_data *sdata,
                                           u16 tx_time)
 {
        struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
-       u16 tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
+       u16 tid = ieee80211_get_tid(hdr);
        int ac = ieee80211_ac_from_tid(tid);
        struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
        unsigned long now = jiffies;
index 4a5bdad..fb586b6 100644 (file)
@@ -669,7 +669,7 @@ minstrel_aggr_check(struct ieee80211_sta *pubsta, struct sk_buff *skb)
        if (unlikely(skb->protocol == cpu_to_be16(ETH_P_PAE)))
                return;
 
-       tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
+       tid = ieee80211_get_tid(hdr);
        if (likely(sta->ampdu_mlme.tid_tx[tid]))
                return;
 
index 478a9c7..3dc162d 100644 (file)
@@ -1189,7 +1189,7 @@ static void ieee80211_rx_reorder_ampdu(struct ieee80211_rx_data *rx,
 
        ack_policy = *ieee80211_get_qos_ctl(hdr) &
                     IEEE80211_QOS_CTL_ACK_POLICY_MASK;
-       tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
+       tid = ieee80211_get_tid(hdr);
 
        tid_agg_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]);
        if (!tid_agg_rx) {
@@ -1528,9 +1528,7 @@ ieee80211_rx_h_uapsd_and_pspoll(struct ieee80211_rx_data *rx)
                   ieee80211_has_pm(hdr->frame_control) &&
                   (ieee80211_is_data_qos(hdr->frame_control) ||
                    ieee80211_is_qos_nullfunc(hdr->frame_control))) {
-               u8 tid;
-
-               tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
+               u8 tid = ieee80211_get_tid(hdr);
 
                ieee80211_sta_uapsd_trigger(&rx->sta->sta, tid);
        }
index 5decd0f..7643178 100644 (file)
@@ -797,7 +797,6 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
 {
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
-       u8 *qc;
        int tid;
 
        /*
@@ -844,9 +843,7 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
                return TX_CONTINUE;
 
        /* include per-STA, per-TID sequence counter */
-
-       qc = ieee80211_get_qos_ctl(hdr);
-       tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
+       tid = ieee80211_get_tid(hdr);
        tx->sta->tx_stats.msdu[tid]++;
 
        hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
@@ -1158,7 +1155,6 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_hdr *hdr;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        int tid;
-       u8 *qc;
 
        memset(tx, 0, sizeof(*tx));
        tx->skb = skb;
@@ -1198,8 +1194,7 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata,
            !ieee80211_hw_check(&local->hw, TX_AMPDU_SETUP_IN_HW)) {
                struct tid_ampdu_tx *tid_tx;
 
-               qc = ieee80211_get_qos_ctl(hdr);
-               tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
+               tid = ieee80211_get_tid(hdr);
 
                tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]);
                if (tid_tx) {
index 785056c..58d0b25 100644 (file)
@@ -340,7 +340,7 @@ static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *b_0, u8 *aad)
        a4_included = ieee80211_has_a4(hdr->frame_control);
 
        if (ieee80211_is_data_qos(hdr->frame_control))
-               qos_tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
+               qos_tid = ieee80211_get_tid(hdr);
        else
                qos_tid = 0;
 
@@ -601,8 +601,7 @@ static void gcmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *j_0, u8 *aad)
        aad[23] = 0;
 
        if (ieee80211_is_data_qos(hdr->frame_control))
-               qos_tid = *ieee80211_get_qos_ctl(hdr) &
-                       IEEE80211_QOS_CTL_TID_MASK;
+               qos_tid = ieee80211_get_tid(hdr);
        else
                qos_tid = 0;
 
@@ -867,8 +866,7 @@ ieee80211_crypto_cs_decrypt(struct ieee80211_rx_data *rx)
                return RX_DROP_UNUSABLE;
 
        if (ieee80211_is_data_qos(hdr->frame_control))
-               qos_tid = *ieee80211_get_qos_ctl(hdr) &
-                               IEEE80211_QOS_CTL_TID_MASK;
+               qos_tid = ieee80211_get_tid(hdr);
        else
                qos_tid = 0;