diff options
author | Bob Copeland <me@bobcopeland.com> | 2008-12-18 23:23:05 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-12-19 15:24:02 -0500 |
commit | fd6effcaf8a894c0a0f602b943dbc54a170d4418 (patch) | |
tree | 121c93ef571292b7a9d9e89294ba88f29c75ae3e | |
parent | 520eb82076993b7f55ef9b80771d264272e5127b (diff) |
ath5k: correct packet length in tx descriptors
Packet length calculation (which includes frame check sequence)
should take into account whether we add a pad field or not.
Extract the calculation into a helper and use it in both places.
Changes to desc.c
Changes-licensed-under: ISC
Changes to ath5k.h, base.c
Changes-licensed-under: 3-Clause-BSD
Signed-off-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/ath5k/ath5k.h | 5 | ||||
-rw-r--r-- | drivers/net/wireless/ath5k/base.c | 8 | ||||
-rw-r--r-- | drivers/net/wireless/ath5k/desc.c | 4 |
3 files changed, 11 insertions, 6 deletions
diff --git a/drivers/net/wireless/ath5k/ath5k.h b/drivers/net/wireless/ath5k/ath5k.h index 13df1191b070..183ffc8e62ca 100644 --- a/drivers/net/wireless/ath5k/ath5k.h +++ b/drivers/net/wireless/ath5k/ath5k.h | |||
@@ -1350,4 +1350,9 @@ static inline u32 ath5k_hw_bitswap(u32 val, unsigned int bits) | |||
1350 | return retval; | 1350 | return retval; |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | static inline int ath5k_pad_size(int hdrlen) | ||
1354 | { | ||
1355 | return (hdrlen < 24) ? 0 : hdrlen & 3; | ||
1356 | } | ||
1357 | |||
1353 | #endif | 1358 | #endif |
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c index 9b5f31aab574..4af2607deec0 100644 --- a/drivers/net/wireless/ath5k/base.c +++ b/drivers/net/wireless/ath5k/base.c | |||
@@ -1762,8 +1762,8 @@ accept: | |||
1762 | * not try to remove padding from short control frames that do | 1762 | * not try to remove padding from short control frames that do |
1763 | * not have payload. */ | 1763 | * not have payload. */ |
1764 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); | 1764 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); |
1765 | padsize = hdrlen & 3; | 1765 | padsize = ath5k_pad_size(hdrlen); |
1766 | if (padsize && hdrlen >= 24) { | 1766 | if (padsize) { |
1767 | memmove(skb->data + padsize, skb->data, hdrlen); | 1767 | memmove(skb->data + padsize, skb->data, hdrlen); |
1768 | skb_pull(skb, padsize); | 1768 | skb_pull(skb, padsize); |
1769 | } | 1769 | } |
@@ -2638,8 +2638,8 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
2638 | * if this is not the case we add the padding after the header | 2638 | * if this is not the case we add the padding after the header |
2639 | */ | 2639 | */ |
2640 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); | 2640 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); |
2641 | padsize = hdrlen & 3; | 2641 | padsize = ath5k_pad_size(hdrlen); |
2642 | if (padsize && hdrlen >= 24) { | 2642 | if (padsize) { |
2643 | 2643 | ||
2644 | if (skb_headroom(skb) < padsize) { | 2644 | if (skb_headroom(skb) < padsize) { |
2645 | ATH5K_ERR(sc, "tx hdrlen not %%4: %d not enough" | 2645 | ATH5K_ERR(sc, "tx hdrlen not %%4: %d not enough" |
diff --git a/drivers/net/wireless/ath5k/desc.c b/drivers/net/wireless/ath5k/desc.c index 5e362a7a3620..b40a9287a39a 100644 --- a/drivers/net/wireless/ath5k/desc.c +++ b/drivers/net/wireless/ath5k/desc.c | |||
@@ -71,7 +71,7 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, | |||
71 | /* Verify and set frame length */ | 71 | /* Verify and set frame length */ |
72 | 72 | ||
73 | /* remove padding we might have added before */ | 73 | /* remove padding we might have added before */ |
74 | frame_len = pkt_len - (hdr_len & 3) + FCS_LEN; | 74 | frame_len = pkt_len - ath5k_pad_size(hdr_len) + FCS_LEN; |
75 | 75 | ||
76 | if (frame_len & ~AR5K_2W_TX_DESC_CTL0_FRAME_LEN) | 76 | if (frame_len & ~AR5K_2W_TX_DESC_CTL0_FRAME_LEN) |
77 | return -EINVAL; | 77 | return -EINVAL; |
@@ -202,7 +202,7 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah, | |||
202 | /* Verify and set frame length */ | 202 | /* Verify and set frame length */ |
203 | 203 | ||
204 | /* remove padding we might have added before */ | 204 | /* remove padding we might have added before */ |
205 | frame_len = pkt_len - (hdr_len & 3) + FCS_LEN; | 205 | frame_len = pkt_len - ath5k_pad_size(hdr_len) + FCS_LEN; |
206 | 206 | ||
207 | if (frame_len & ~AR5K_4W_TX_DESC_CTL0_FRAME_LEN) | 207 | if (frame_len & ~AR5K_4W_TX_DESC_CTL0_FRAME_LEN) |
208 | return -EINVAL; | 208 | return -EINVAL; |