hostap: convert usage of net/ieee80211.h to linux/ieee80211.h
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / hostap / hostap_80211_tx.c
index 921c984416f8b03270e57b199b2be839a6e61b50..6693423f63feb3b032681276af06ed5666e89927 100644 (file)
@@ -15,11 +15,10 @@ static unsigned char bridge_tunnel_header[] =
 
 void hostap_dump_tx_80211(const char *name, struct sk_buff *skb)
 {
-       struct ieee80211_hdr_4addr *hdr;
+       struct ieee80211_hdr *hdr;
        u16 fc;
-       DECLARE_MAC_BUF(mac);
 
-       hdr = (struct ieee80211_hdr_4addr *) skb->data;
+       hdr = (struct ieee80211_hdr *) skb->data;
 
        printk(KERN_DEBUG "%s: TX len=%d jiffies=%ld\n",
               name, skb->len, jiffies);
@@ -27,9 +26,10 @@ void hostap_dump_tx_80211(const char *name, struct sk_buff *skb)
        if (skb->len < 2)
                return;
 
-       fc = le16_to_cpu(hdr->frame_ctl);
+       fc = le16_to_cpu(hdr->frame_control);
        printk(KERN_DEBUG "   FC=0x%04x (type=%d:%d)%s%s",
-              fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4,
+              fc, (fc & IEEE80211_FCTL_FTYPE) >> 2,
+              (fc & IEEE80211_FCTL_STYPE) >> 4,
               fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "",
               fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : "");
 
@@ -39,13 +39,13 @@ void hostap_dump_tx_80211(const char *name, struct sk_buff *skb)
        }
 
        printk(" dur=0x%04x seq=0x%04x\n", le16_to_cpu(hdr->duration_id),
-              le16_to_cpu(hdr->seq_ctl));
+              le16_to_cpu(hdr->seq_ctrl));
 
-       printk(KERN_DEBUG "   A1=%s", print_mac(mac, hdr->addr1));
-       printk(" A2=%s", print_mac(mac, hdr->addr2));
-       printk(" A3=%s", print_mac(mac, hdr->addr3));
+       printk(KERN_DEBUG "   A1=%pM", hdr->addr1);
+       printk(" A2=%pM", hdr->addr2);
+       printk(" A3=%pM", hdr->addr3);
        if (skb->len >= 30)
-               printk(" A4=%s", print_mac(mac, hdr->addr4));
+               printk(" A4=%pM", hdr->addr4);
        printk("\n");
 }
 
@@ -58,7 +58,7 @@ int hostap_data_start_xmit(struct sk_buff *skb, struct net_device *dev)
        struct hostap_interface *iface;
        local_info_t *local;
        int need_headroom, need_tailroom = 0;
-       struct ieee80211_hdr_4addr hdr;
+       struct ieee80211_hdr hdr;
        u16 fc, ethertype = 0;
        enum {
                WDS_NO = 0, WDS_OWN_FRAME, WDS_COMPLIANT_FRAME
@@ -202,7 +202,7 @@ int hostap_data_start_xmit(struct sk_buff *skb, struct net_device *dev)
                memcpy(&hdr.addr3, local->bssid, ETH_ALEN);
        }
 
-       hdr.frame_ctl = cpu_to_le16(fc);
+       hdr.frame_control = cpu_to_le16(fc);
 
        skb_pull(skb, skip_header_bytes);
        need_headroom = local->func->need_tx_headroom + hdr_len + encaps_len;
@@ -266,7 +266,7 @@ int hostap_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev)
        struct hostap_interface *iface;
        local_info_t *local;
        struct hostap_skb_tx_data *meta;
-       struct ieee80211_hdr_4addr *hdr;
+       struct ieee80211_hdr *hdr;
        u16 fc;
 
        iface = netdev_priv(dev);
@@ -288,10 +288,10 @@ int hostap_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev)
        meta->iface = iface;
 
        if (skb->len >= IEEE80211_DATA_HDR3_LEN + sizeof(rfc1042_header) + 2) {
-               hdr = (struct ieee80211_hdr_4addr *) skb->data;
-               fc = le16_to_cpu(hdr->frame_ctl);
-               if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
-                   WLAN_FC_GET_STYPE(fc) == IEEE80211_STYPE_DATA) {
+               hdr = (struct ieee80211_hdr *) skb->data;
+               fc = le16_to_cpu(hdr->frame_control);
+               if (ieee80211_is_data(hdr->frame_control) &&
+                   (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_DATA) {
                        u8 *pos = &skb->data[IEEE80211_DATA_HDR3_LEN +
                                             sizeof(rfc1042_header)];
                        meta->ethertype = (pos[0] << 8) | pos[1];
@@ -307,12 +307,11 @@ int hostap_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 /* Called only from software IRQ */
 static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
-                                         struct ieee80211_crypt_data *crypt)
+                                         struct lib80211_crypt_data *crypt)
 {
        struct hostap_interface *iface;
        local_info_t *local;
-       struct ieee80211_hdr_4addr *hdr;
-       u16 fc;
+       struct ieee80211_hdr *hdr;
        int prefix_len, postfix_len, hdr_len, res;
 
        iface = netdev_priv(skb->dev);
@@ -325,13 +324,11 @@ static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
 
        if (local->tkip_countermeasures &&
            strcmp(crypt->ops->name, "TKIP") == 0) {
-               hdr = (struct ieee80211_hdr_4addr *) skb->data;
+               hdr = (struct ieee80211_hdr *) skb->data;
                if (net_ratelimit()) {
                        printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
-                              "TX packet to " MAC_FMT "\n",
-                              local->dev->name,
-                              hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
-                              hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
+                              "TX packet to %pM\n",
+                              local->dev->name, hdr->addr1);
                }
                kfree_skb(skb);
                return NULL;
@@ -352,9 +349,8 @@ static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
                return NULL;
        }
 
-       hdr = (struct ieee80211_hdr_4addr *) skb->data;
-       fc = le16_to_cpu(hdr->frame_ctl);
-       hdr_len = hostap_80211_get_hdrlen(fc);
+       hdr = (struct ieee80211_hdr *) skb->data;
+       hdr_len = hostap_80211_get_hdrlen(hdr->frame_control);
 
        /* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so
         * call both MSDU and MPDU encryption functions from here. */
@@ -387,7 +383,7 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
        ap_tx_ret tx_ret;
        struct hostap_skb_tx_data *meta;
        int no_encrypt = 0;
-       struct ieee80211_hdr_4addr *hdr;
+       struct ieee80211_hdr *hdr;
 
        iface = netdev_priv(dev);
        local = iface->local;
@@ -408,7 +404,7 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if (local->host_encrypt) {
                /* Set crypt to default algorithm and key; will be replaced in
                 * AP code if STA has own alg/key */
-               tx.crypt = local->crypt[local->tx_keyidx];
+               tx.crypt = local->crypt_info.crypt[local->crypt_info.tx_keyidx];
                tx.host_encrypt = 1;
        } else {
                tx.crypt = NULL;
@@ -430,14 +426,14 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
        tx_ret = hostap_handle_sta_tx(local, &tx);
        skb = tx.skb;
        meta = (struct hostap_skb_tx_data *) skb->cb;
-       hdr = (struct ieee80211_hdr_4addr *) skb->data;
-       fc = le16_to_cpu(hdr->frame_ctl);
+       hdr = (struct ieee80211_hdr *) skb->data;
+       fc = le16_to_cpu(hdr->frame_control);
        switch (tx_ret) {
        case AP_TX_CONTINUE:
                break;
        case AP_TX_CONTINUE_NOT_AUTHORIZED:
                if (local->ieee_802_1x &&
-                   WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
+                   ieee80211_is_data(hdr->frame_control) &&
                    meta->ethertype != ETH_P_PAE &&
                    !(meta->flags & HOSTAP_TX_FLAGS_WDS)) {
                        printk(KERN_DEBUG "%s: dropped frame to unauthorized "
@@ -472,10 +468,10 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
                /* remove special version from the frame header */
                fc &= ~IEEE80211_FCTL_VERS;
-               hdr->frame_ctl = cpu_to_le16(fc);
+               hdr->frame_control = cpu_to_le16(fc);
        }
 
-       if (WLAN_FC_GET_TYPE(fc) != IEEE80211_FTYPE_DATA) {
+       if (!ieee80211_is_data(hdr->frame_control)) {
                no_encrypt = 1;
                tx.crypt = NULL;
        }
@@ -490,13 +486,15 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        if (tx.crypt && (!tx.crypt->ops || !tx.crypt->ops->encrypt_mpdu))
                tx.crypt = NULL;
-       else if ((tx.crypt || local->crypt[local->tx_keyidx]) && !no_encrypt) {
+       else if ((tx.crypt ||
+                local->crypt_info.crypt[local->crypt_info.tx_keyidx]) &&
+                !no_encrypt) {
                /* Add ISWEP flag both for firmware and host based encryption
                 */
                fc |= IEEE80211_FCTL_PROTECTED;
-               hdr->frame_ctl = cpu_to_le16(fc);
+               hdr->frame_control = cpu_to_le16(fc);
        } else if (local->drop_unencrypted &&
-                  WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
+                  ieee80211_is_data(hdr->frame_control) &&
                   meta->ethertype != ETH_P_PAE) {
                if (net_ratelimit()) {
                        printk(KERN_DEBUG "%s: dropped unencrypted TX data "