Commit 065e9605 authored by Harvey Harrison's avatar Harvey Harrison Committed by John W. Linville

mac80211: tx.c use new frame control helpers

Signed-off-by: default avatarHarvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 70217d7f
...@@ -52,9 +52,8 @@ static inline void ieee80211_include_sequence(struct ieee80211_sub_if_data *sdat ...@@ -52,9 +52,8 @@ static inline void ieee80211_include_sequence(struct ieee80211_sub_if_data *sdat
static void ieee80211_dump_frame(const char *ifname, const char *title, static void ieee80211_dump_frame(const char *ifname, const char *title,
const struct sk_buff *skb) const struct sk_buff *skb)
{ {
const struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; const struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
u16 fc; unsigned int hdrlen;
int hdrlen;
DECLARE_MAC_BUF(mac); DECLARE_MAC_BUF(mac);
printk(KERN_DEBUG "%s: %s (len=%d)", ifname, title, skb->len); printk(KERN_DEBUG "%s: %s (len=%d)", ifname, title, skb->len);
...@@ -63,13 +62,12 @@ static void ieee80211_dump_frame(const char *ifname, const char *title, ...@@ -63,13 +62,12 @@ static void ieee80211_dump_frame(const char *ifname, const char *title,
return; return;
} }
fc = le16_to_cpu(hdr->frame_control); hdrlen = ieee80211_hdrlen(hdr->frame_control);
hdrlen = ieee80211_get_hdrlen(fc);
if (hdrlen > skb->len) if (hdrlen > skb->len)
hdrlen = skb->len; hdrlen = skb->len;
if (hdrlen >= 4) if (hdrlen >= 4)
printk(" FC=0x%04x DUR=0x%04x", printk(" FC=0x%04x DUR=0x%04x",
fc, le16_to_cpu(hdr->duration_id)); le16_to_cpu(hdr->frame_control), le16_to_cpu(hdr->duration_id));
if (hdrlen >= 10) if (hdrlen >= 10)
printk(" A1=%s", print_mac(mac, hdr->addr1)); printk(" A1=%s", print_mac(mac, hdr->addr1));
if (hdrlen >= 16) if (hdrlen >= 16)
...@@ -281,7 +279,7 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx) ...@@ -281,7 +279,7 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
{ {
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
if (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)) >= 24) if (ieee80211_hdrlen(hdr->frame_control) >= 24)
ieee80211_include_sequence(tx->sdata, hdr); ieee80211_include_sequence(tx->sdata, hdr);
return TX_CONTINUE; return TX_CONTINUE;
...@@ -542,8 +540,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) ...@@ -542,8 +540,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
static ieee80211_tx_result static ieee80211_tx_result
ieee80211_tx_h_misc(struct ieee80211_tx_data *tx) ieee80211_tx_h_misc(struct ieee80211_tx_data *tx)
{ {
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
u16 fc = le16_to_cpu(hdr->frame_control);
u16 dur; u16 dur;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
struct ieee80211_supported_band *sband; struct ieee80211_supported_band *sband;
...@@ -595,7 +592,7 @@ ieee80211_tx_h_misc(struct ieee80211_tx_data *tx) ...@@ -595,7 +592,7 @@ ieee80211_tx_h_misc(struct ieee80211_tx_data *tx)
/* Transmit data frames using short preambles if the driver supports /* Transmit data frames using short preambles if the driver supports
* short preambles at the selected rate and short preambles are * short preambles at the selected rate and short preambles are
* available on the network at the current point in time. */ * available on the network at the current point in time. */
if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && if (ieee80211_is_data(hdr->frame_control) &&
(sband->bitrates[tx->rate_idx].flags & IEEE80211_RATE_SHORT_PREAMBLE) && (sband->bitrates[tx->rate_idx].flags & IEEE80211_RATE_SHORT_PREAMBLE) &&
tx->sdata->bss_conf.use_short_preamble && tx->sdata->bss_conf.use_short_preamble &&
(!tx->sta || test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE))) { (!tx->sta || test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE))) {
...@@ -647,7 +644,7 @@ ieee80211_tx_h_misc(struct ieee80211_tx_data *tx) ...@@ -647,7 +644,7 @@ ieee80211_tx_h_misc(struct ieee80211_tx_data *tx)
static ieee80211_tx_result static ieee80211_tx_result
ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
{ {
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
size_t hdrlen, per_fragm, num_fragm, payload_len, left; size_t hdrlen, per_fragm, num_fragm, payload_len, left;
struct sk_buff **frags, *first, *frag; struct sk_buff **frags, *first, *frag;
int i; int i;
...@@ -670,7 +667,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) ...@@ -670,7 +667,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
first = tx->skb; first = tx->skb;
hdrlen = ieee80211_get_hdrlen(tx->fc); hdrlen = ieee80211_hdrlen(hdr->frame_control);
payload_len = first->len - hdrlen; payload_len = first->len - hdrlen;
per_fragm = frag_threshold - hdrlen - FCS_LEN; per_fragm = frag_threshold - hdrlen - FCS_LEN;
num_fragm = DIV_ROUND_UP(payload_len, per_fragm); num_fragm = DIV_ROUND_UP(payload_len, per_fragm);
...@@ -1395,7 +1392,8 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, ...@@ -1395,7 +1392,8 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
struct ieee80211_tx_info *info; struct ieee80211_tx_info *info;
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
int ret = 1, head_need; int ret = 1, head_need;
u16 ethertype, hdrlen, meshhdrlen = 0, fc; u16 ethertype, hdrlen, meshhdrlen = 0;
__le16 fc;
struct ieee80211_hdr hdr; struct ieee80211_hdr hdr;
struct ieee80211s_hdr mesh_hdr; struct ieee80211s_hdr mesh_hdr;
const u8 *encaps_data; const u8 *encaps_data;
...@@ -1418,12 +1416,12 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, ...@@ -1418,12 +1416,12 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
/* convert Ethernet header to proper 802.11 header (based on /* convert Ethernet header to proper 802.11 header (based on
* operation mode) */ * operation mode) */
ethertype = (skb->data[12] << 8) | skb->data[13]; ethertype = (skb->data[12] << 8) | skb->data[13];
fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA; fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);
switch (sdata->vif.type) { switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_AP: case IEEE80211_IF_TYPE_AP:
case IEEE80211_IF_TYPE_VLAN: case IEEE80211_IF_TYPE_VLAN:
fc |= IEEE80211_FCTL_FROMDS; fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
/* DA BSSID SA */ /* DA BSSID SA */
memcpy(hdr.addr1, skb->data, ETH_ALEN); memcpy(hdr.addr1, skb->data, ETH_ALEN);
memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN);
...@@ -1431,7 +1429,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, ...@@ -1431,7 +1429,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
hdrlen = 24; hdrlen = 24;
break; break;
case IEEE80211_IF_TYPE_WDS: case IEEE80211_IF_TYPE_WDS:
fc |= IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS; fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
/* RA TA DA SA */ /* RA TA DA SA */
memcpy(hdr.addr1, sdata->u.wds.remote_addr, ETH_ALEN); memcpy(hdr.addr1, sdata->u.wds.remote_addr, ETH_ALEN);
memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN);
...@@ -1441,7 +1439,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, ...@@ -1441,7 +1439,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
break; break;
#ifdef CONFIG_MAC80211_MESH #ifdef CONFIG_MAC80211_MESH
case IEEE80211_IF_TYPE_MESH_POINT: case IEEE80211_IF_TYPE_MESH_POINT:
fc |= IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS; fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
/* RA TA DA SA */ /* RA TA DA SA */
if (is_multicast_ether_addr(skb->data)) if (is_multicast_ether_addr(skb->data))
memcpy(hdr.addr1, skb->data, ETH_ALEN); memcpy(hdr.addr1, skb->data, ETH_ALEN);
...@@ -1471,7 +1469,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, ...@@ -1471,7 +1469,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
break; break;
#endif #endif
case IEEE80211_IF_TYPE_STA: case IEEE80211_IF_TYPE_STA:
fc |= IEEE80211_FCTL_TODS; fc |= cpu_to_le16(IEEE80211_FCTL_TODS);
/* BSSID SA DA */ /* BSSID SA DA */
memcpy(hdr.addr1, sdata->u.sta.bssid, ETH_ALEN); memcpy(hdr.addr1, sdata->u.sta.bssid, ETH_ALEN);
memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
...@@ -1506,7 +1504,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, ...@@ -1506,7 +1504,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
/* receiver and we are QoS enabled, use a QoS type frame */ /* receiver and we are QoS enabled, use a QoS type frame */
if (sta_flags & WLAN_STA_WME && if (sta_flags & WLAN_STA_WME &&
ieee80211_num_regular_queues(&local->hw) >= 4) { ieee80211_num_regular_queues(&local->hw) >= 4) {
fc |= IEEE80211_STYPE_QOS_DATA; fc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA);
hdrlen += 2; hdrlen += 2;
} }
...@@ -1534,7 +1532,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, ...@@ -1534,7 +1532,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
goto fail; goto fail;
} }
hdr.frame_control = cpu_to_le16(fc); hdr.frame_control = fc;
hdr.duration_id = 0; hdr.duration_id = 0;
hdr.seq_ctrl = 0; hdr.seq_ctrl = 0;
...@@ -1603,7 +1601,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, ...@@ -1603,7 +1601,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
h_pos += meshhdrlen; h_pos += meshhdrlen;
} }
if (fc & IEEE80211_STYPE_QOS_DATA) { if (ieee80211_is_data_qos(fc)) {
__le16 *qos_control; __le16 *qos_control;
qos_control = (__le16*) skb_push(skb, 2); qos_control = (__le16*) skb_push(skb, 2);
...@@ -1861,8 +1859,8 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, ...@@ -1861,8 +1859,8 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
mgmt = (struct ieee80211_mgmt *) mgmt = (struct ieee80211_mgmt *)
skb_put(skb, 24 + sizeof(mgmt->u.beacon)); skb_put(skb, 24 + sizeof(mgmt->u.beacon));
memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, mgmt->frame_control =
IEEE80211_STYPE_BEACON); cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
memset(mgmt->da, 0xff, ETH_ALEN); memset(mgmt->da, 0xff, ETH_ALEN);
memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
/* BSSID is left zeroed, wildcard value */ /* BSSID is left zeroed, wildcard value */
...@@ -1930,10 +1928,9 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, ...@@ -1930,10 +1928,9 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct ieee80211_rts *rts) struct ieee80211_rts *rts)
{ {
const struct ieee80211_hdr *hdr = frame; const struct ieee80211_hdr *hdr = frame;
u16 fctl;
fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS; rts->frame_control =
rts->frame_control = cpu_to_le16(fctl); cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
rts->duration = ieee80211_rts_duration(hw, vif, frame_len, rts->duration = ieee80211_rts_duration(hw, vif, frame_len,
frame_txctl); frame_txctl);
memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); memcpy(rts->ra, hdr->addr1, sizeof(rts->ra));
...@@ -1947,10 +1944,9 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, ...@@ -1947,10 +1944,9 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct ieee80211_cts *cts) struct ieee80211_cts *cts)
{ {
const struct ieee80211_hdr *hdr = frame; const struct ieee80211_hdr *hdr = frame;
u16 fctl;
fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS; cts->frame_control =
cts->frame_control = cpu_to_le16(fctl); cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
cts->duration = ieee80211_ctstoself_duration(hw, vif, cts->duration = ieee80211_ctstoself_duration(hw, vif,
frame_len, frame_txctl); frame_len, frame_txctl);
memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); memcpy(cts->ra, hdr->addr1, sizeof(cts->ra));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment