aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorHarvey Harrison <harvey.harrison@gmail.com>2008-06-22 19:45:27 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-06-27 09:09:18 -0400
commit065e9605f941b8bc4dbfa1f14ba98eb0da7e3fbe (patch)
tree1101aae31946acae66715b8d9eb75e39688757aa /net/mac80211
parent70217d7f83a12e0a16c726951ddf8f7f0ba7d1a4 (diff)
mac80211: tx.c use new frame control helpers
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/tx.c54
1 files changed, 25 insertions, 29 deletions
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 7a14a39ebd78..bf3600a04776 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -52,9 +52,8 @@ static inline void ieee80211_include_sequence(struct ieee80211_sub_if_data *sdat
52static void ieee80211_dump_frame(const char *ifname, const char *title, 52static void ieee80211_dump_frame(const char *ifname, const char *title,
53 const struct sk_buff *skb) 53 const struct sk_buff *skb)
54{ 54{
55 const struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 55 const struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
56 u16 fc; 56 unsigned int hdrlen;
57 int hdrlen;
58 DECLARE_MAC_BUF(mac); 57 DECLARE_MAC_BUF(mac);
59 58
60 printk(KERN_DEBUG "%s: %s (len=%d)", ifname, title, skb->len); 59 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 return; 62 return;
64 } 63 }
65 64
66 fc = le16_to_cpu(hdr->frame_control); 65 hdrlen = ieee80211_hdrlen(hdr->frame_control);
67 hdrlen = ieee80211_get_hdrlen(fc);
68 if (hdrlen > skb->len) 66 if (hdrlen > skb->len)
69 hdrlen = skb->len; 67 hdrlen = skb->len;
70 if (hdrlen >= 4) 68 if (hdrlen >= 4)
71 printk(" FC=0x%04x DUR=0x%04x", 69 printk(" FC=0x%04x DUR=0x%04x",
72 fc, le16_to_cpu(hdr->duration_id)); 70 le16_to_cpu(hdr->frame_control), le16_to_cpu(hdr->duration_id));
73 if (hdrlen >= 10) 71 if (hdrlen >= 10)
74 printk(" A1=%s", print_mac(mac, hdr->addr1)); 72 printk(" A1=%s", print_mac(mac, hdr->addr1));
75 if (hdrlen >= 16) 73 if (hdrlen >= 16)
@@ -281,7 +279,7 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
281{ 279{
282 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; 280 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
283 281
284 if (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)) >= 24) 282 if (ieee80211_hdrlen(hdr->frame_control) >= 24)
285 ieee80211_include_sequence(tx->sdata, hdr); 283 ieee80211_include_sequence(tx->sdata, hdr);
286 284
287 return TX_CONTINUE; 285 return TX_CONTINUE;
@@ -542,8 +540,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
542static ieee80211_tx_result 540static ieee80211_tx_result
543ieee80211_tx_h_misc(struct ieee80211_tx_data *tx) 541ieee80211_tx_h_misc(struct ieee80211_tx_data *tx)
544{ 542{
545 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; 543 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
546 u16 fc = le16_to_cpu(hdr->frame_control);
547 u16 dur; 544 u16 dur;
548 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); 545 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
549 struct ieee80211_supported_band *sband; 546 struct ieee80211_supported_band *sband;
@@ -595,7 +592,7 @@ ieee80211_tx_h_misc(struct ieee80211_tx_data *tx)
595 /* Transmit data frames using short preambles if the driver supports 592 /* Transmit data frames using short preambles if the driver supports
596 * short preambles at the selected rate and short preambles are 593 * short preambles at the selected rate and short preambles are
597 * available on the network at the current point in time. */ 594 * available on the network at the current point in time. */
598 if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && 595 if (ieee80211_is_data(hdr->frame_control) &&
599 (sband->bitrates[tx->rate_idx].flags & IEEE80211_RATE_SHORT_PREAMBLE) && 596 (sband->bitrates[tx->rate_idx].flags & IEEE80211_RATE_SHORT_PREAMBLE) &&
600 tx->sdata->bss_conf.use_short_preamble && 597 tx->sdata->bss_conf.use_short_preamble &&
601 (!tx->sta || test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE))) { 598 (!tx->sta || test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE))) {
@@ -647,7 +644,7 @@ ieee80211_tx_h_misc(struct ieee80211_tx_data *tx)
647static ieee80211_tx_result 644static ieee80211_tx_result
648ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) 645ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
649{ 646{
650 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; 647 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
651 size_t hdrlen, per_fragm, num_fragm, payload_len, left; 648 size_t hdrlen, per_fragm, num_fragm, payload_len, left;
652 struct sk_buff **frags, *first, *frag; 649 struct sk_buff **frags, *first, *frag;
653 int i; 650 int i;
@@ -670,7 +667,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
670 667
671 first = tx->skb; 668 first = tx->skb;
672 669
673 hdrlen = ieee80211_get_hdrlen(tx->fc); 670 hdrlen = ieee80211_hdrlen(hdr->frame_control);
674 payload_len = first->len - hdrlen; 671 payload_len = first->len - hdrlen;
675 per_fragm = frag_threshold - hdrlen - FCS_LEN; 672 per_fragm = frag_threshold - hdrlen - FCS_LEN;
676 num_fragm = DIV_ROUND_UP(payload_len, per_fragm); 673 num_fragm = DIV_ROUND_UP(payload_len, per_fragm);
@@ -1395,7 +1392,8 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1395 struct ieee80211_tx_info *info; 1392 struct ieee80211_tx_info *info;
1396 struct ieee80211_sub_if_data *sdata; 1393 struct ieee80211_sub_if_data *sdata;
1397 int ret = 1, head_need; 1394 int ret = 1, head_need;
1398 u16 ethertype, hdrlen, meshhdrlen = 0, fc; 1395 u16 ethertype, hdrlen, meshhdrlen = 0;
1396 __le16 fc;
1399 struct ieee80211_hdr hdr; 1397 struct ieee80211_hdr hdr;
1400 struct ieee80211s_hdr mesh_hdr; 1398 struct ieee80211s_hdr mesh_hdr;
1401 const u8 *encaps_data; 1399 const u8 *encaps_data;
@@ -1418,12 +1416,12 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1418 /* convert Ethernet header to proper 802.11 header (based on 1416 /* convert Ethernet header to proper 802.11 header (based on
1419 * operation mode) */ 1417 * operation mode) */
1420 ethertype = (skb->data[12] << 8) | skb->data[13]; 1418 ethertype = (skb->data[12] << 8) | skb->data[13];
1421 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA; 1419 fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);
1422 1420
1423 switch (sdata->vif.type) { 1421 switch (sdata->vif.type) {
1424 case IEEE80211_IF_TYPE_AP: 1422 case IEEE80211_IF_TYPE_AP:
1425 case IEEE80211_IF_TYPE_VLAN: 1423 case IEEE80211_IF_TYPE_VLAN:
1426 fc |= IEEE80211_FCTL_FROMDS; 1424 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
1427 /* DA BSSID SA */ 1425 /* DA BSSID SA */
1428 memcpy(hdr.addr1, skb->data, ETH_ALEN); 1426 memcpy(hdr.addr1, skb->data, ETH_ALEN);
1429 memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); 1427 memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN);
@@ -1431,7 +1429,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1431 hdrlen = 24; 1429 hdrlen = 24;
1432 break; 1430 break;
1433 case IEEE80211_IF_TYPE_WDS: 1431 case IEEE80211_IF_TYPE_WDS:
1434 fc |= IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS; 1432 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
1435 /* RA TA DA SA */ 1433 /* RA TA DA SA */
1436 memcpy(hdr.addr1, sdata->u.wds.remote_addr, ETH_ALEN); 1434 memcpy(hdr.addr1, sdata->u.wds.remote_addr, ETH_ALEN);
1437 memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); 1435 memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN);
@@ -1441,7 +1439,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1441 break; 1439 break;
1442#ifdef CONFIG_MAC80211_MESH 1440#ifdef CONFIG_MAC80211_MESH
1443 case IEEE80211_IF_TYPE_MESH_POINT: 1441 case IEEE80211_IF_TYPE_MESH_POINT:
1444 fc |= IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS; 1442 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
1445 /* RA TA DA SA */ 1443 /* RA TA DA SA */
1446 if (is_multicast_ether_addr(skb->data)) 1444 if (is_multicast_ether_addr(skb->data))
1447 memcpy(hdr.addr1, skb->data, ETH_ALEN); 1445 memcpy(hdr.addr1, skb->data, ETH_ALEN);
@@ -1471,7 +1469,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1471 break; 1469 break;
1472#endif 1470#endif
1473 case IEEE80211_IF_TYPE_STA: 1471 case IEEE80211_IF_TYPE_STA:
1474 fc |= IEEE80211_FCTL_TODS; 1472 fc |= cpu_to_le16(IEEE80211_FCTL_TODS);
1475 /* BSSID SA DA */ 1473 /* BSSID SA DA */
1476 memcpy(hdr.addr1, sdata->u.sta.bssid, ETH_ALEN); 1474 memcpy(hdr.addr1, sdata->u.sta.bssid, ETH_ALEN);
1477 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); 1475 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
@@ -1506,7 +1504,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1506 /* receiver and we are QoS enabled, use a QoS type frame */ 1504 /* receiver and we are QoS enabled, use a QoS type frame */
1507 if (sta_flags & WLAN_STA_WME && 1505 if (sta_flags & WLAN_STA_WME &&
1508 ieee80211_num_regular_queues(&local->hw) >= 4) { 1506 ieee80211_num_regular_queues(&local->hw) >= 4) {
1509 fc |= IEEE80211_STYPE_QOS_DATA; 1507 fc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA);
1510 hdrlen += 2; 1508 hdrlen += 2;
1511 } 1509 }
1512 1510
@@ -1534,7 +1532,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1534 goto fail; 1532 goto fail;
1535 } 1533 }
1536 1534
1537 hdr.frame_control = cpu_to_le16(fc); 1535 hdr.frame_control = fc;
1538 hdr.duration_id = 0; 1536 hdr.duration_id = 0;
1539 hdr.seq_ctrl = 0; 1537 hdr.seq_ctrl = 0;
1540 1538
@@ -1603,7 +1601,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1603 h_pos += meshhdrlen; 1601 h_pos += meshhdrlen;
1604 } 1602 }
1605 1603
1606 if (fc & IEEE80211_STYPE_QOS_DATA) { 1604 if (ieee80211_is_data_qos(fc)) {
1607 __le16 *qos_control; 1605 __le16 *qos_control;
1608 1606
1609 qos_control = (__le16*) skb_push(skb, 2); 1607 qos_control = (__le16*) skb_push(skb, 2);
@@ -1861,8 +1859,8 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1861 mgmt = (struct ieee80211_mgmt *) 1859 mgmt = (struct ieee80211_mgmt *)
1862 skb_put(skb, 24 + sizeof(mgmt->u.beacon)); 1860 skb_put(skb, 24 + sizeof(mgmt->u.beacon));
1863 memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); 1861 memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
1864 mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, 1862 mgmt->frame_control =
1865 IEEE80211_STYPE_BEACON); 1863 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
1866 memset(mgmt->da, 0xff, ETH_ALEN); 1864 memset(mgmt->da, 0xff, ETH_ALEN);
1867 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); 1865 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
1868 /* BSSID is left zeroed, wildcard value */ 1866 /* BSSID is left zeroed, wildcard value */
@@ -1930,10 +1928,9 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1930 struct ieee80211_rts *rts) 1928 struct ieee80211_rts *rts)
1931{ 1929{
1932 const struct ieee80211_hdr *hdr = frame; 1930 const struct ieee80211_hdr *hdr = frame;
1933 u16 fctl;
1934 1931
1935 fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS; 1932 rts->frame_control =
1936 rts->frame_control = cpu_to_le16(fctl); 1933 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
1937 rts->duration = ieee80211_rts_duration(hw, vif, frame_len, 1934 rts->duration = ieee80211_rts_duration(hw, vif, frame_len,
1938 frame_txctl); 1935 frame_txctl);
1939 memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); 1936 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 struct ieee80211_cts *cts) 1944 struct ieee80211_cts *cts)
1948{ 1945{
1949 const struct ieee80211_hdr *hdr = frame; 1946 const struct ieee80211_hdr *hdr = frame;
1950 u16 fctl;
1951 1947
1952 fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS; 1948 cts->frame_control =
1953 cts->frame_control = cpu_to_le16(fctl); 1949 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
1954 cts->duration = ieee80211_ctstoself_duration(hw, vif, 1950 cts->duration = ieee80211_ctstoself_duration(hw, vif,
1955 frame_len, frame_txctl); 1951 frame_len, frame_txctl);
1956 memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); 1952 memcpy(cts->ra, hdr->addr1, sizeof(cts->ra));