* [PATCHv5 1/2] mac80211: avoid extra memcpy in A-MSDU head creation
@ 2016-10-15 11:28 Michael Braun
2016-10-15 11:28 ` [PATCHv5 2/2] mac80211: fix A-MSDU outer SA/DA Michael Braun
2016-10-17 9:41 ` [PATCHv5 1/2] mac80211: avoid extra memcpy in A-MSDU head creation Johannes Berg
0 siblings, 2 replies; 6+ messages in thread
From: Michael Braun @ 2016-10-15 11:28 UTC (permalink / raw)
To: johannes; +Cc: Michael Braun, linux-wireless, projekt-wlan, Felix Fietkau
Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
---
net/mac80211/tx.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 5023966..56a883b 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3046,11 +3046,11 @@ static bool ieee80211_amsdu_prepare_head(struct ieee80211_sub_if_data *sdata,
struct ieee80211_local *local = sdata->local;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct ieee80211_hdr *hdr;
- struct ethhdr amsdu_hdr;
+ struct ethhdr *amsdu_hdr;
int hdr_len = fast_tx->hdr_len - sizeof(rfc1042_header);
int subframe_len = skb->len - hdr_len;
void *data;
- u8 *qc;
+ u8 *qc, *h_80211_src, *h_80211_dst;
if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)
return false;
@@ -3058,19 +3058,22 @@ static bool ieee80211_amsdu_prepare_head(struct ieee80211_sub_if_data *sdata,
if (info->control.flags & IEEE80211_TX_CTRL_AMSDU)
return true;
- if (!ieee80211_amsdu_realloc_pad(local, skb, sizeof(amsdu_hdr),
+ if (!ieee80211_amsdu_realloc_pad(local, skb, sizeof(*amsdu_hdr),
&subframe_len))
return false;
- amsdu_hdr.h_proto = cpu_to_be16(subframe_len);
- memcpy(amsdu_hdr.h_source, skb->data + fast_tx->sa_offs, ETH_ALEN);
- memcpy(amsdu_hdr.h_dest, skb->data + fast_tx->da_offs, ETH_ALEN);
+ data = skb_push(skb, sizeof(*amsdu_hdr));
+ memmove(data, data + sizeof(*amsdu_hdr), hdr_len);
+ hdr = data;
+ amsdu_hdr = data + hdr_len;
+ /* h_80211_src/dst is addr* field within hdr */
+ h_80211_src = data + fast_tx->sa_offs;
+ h_80211_dst = data + fast_tx->da_offs;
- data = skb_push(skb, sizeof(amsdu_hdr));
- memmove(data, data + sizeof(amsdu_hdr), hdr_len);
- memcpy(data + hdr_len, &amsdu_hdr, sizeof(amsdu_hdr));
+ amsdu_hdr->h_proto = cpu_to_be16(subframe_len);
+ ether_addr_copy(amsdu_hdr->h_source, h_80211_src);
+ ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst);
- hdr = data;
qc = ieee80211_get_qos_ctl(hdr);
*qc |= IEEE80211_QOS_CTL_A_MSDU_PRESENT;
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCHv5 2/2] mac80211: fix A-MSDU outer SA/DA
2016-10-15 11:28 [PATCHv5 1/2] mac80211: avoid extra memcpy in A-MSDU head creation Michael Braun
@ 2016-10-15 11:28 ` Michael Braun
2016-10-17 9:44 ` Johannes Berg
2016-10-17 9:41 ` [PATCHv5 1/2] mac80211: avoid extra memcpy in A-MSDU head creation Johannes Berg
1 sibling, 1 reply; 6+ messages in thread
From: Michael Braun @ 2016-10-15 11:28 UTC (permalink / raw)
To: johannes; +Cc: Michael Braun, linux-wireless, projekt-wlan, Felix Fietkau
According to IEEE 802.11-2012 section 8.3.2 table 8-19, the outer SA/DA
of A-MSDU frames need to be changed depending on FromDS/ToDS values.
Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
--
v5:
- single out amsdu_hdr to ptr conversion before
v4:
- h_80211_src/dst has been memmove'd and thus needs to be fixed
v3:
- write to outer 802.11 header instead of inner amsdu subframe header
v2:
- avoid the extra write to amsdu_hdr
- avoid copy of asmdu_hdr into skb, use ptr instead
---
net/mac80211/tx.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 56a883b..7fcd4b6 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3051,6 +3051,7 @@ static bool ieee80211_amsdu_prepare_head(struct ieee80211_sub_if_data *sdata,
int subframe_len = skb->len - hdr_len;
void *data;
u8 *qc, *h_80211_src, *h_80211_dst;
+ const u8 *bssid;
if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)
return false;
@@ -3074,6 +3075,28 @@ static bool ieee80211_amsdu_prepare_head(struct ieee80211_sub_if_data *sdata,
ether_addr_copy(amsdu_hdr->h_source, h_80211_src);
ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst);
+ /* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer SA/DA
+ * fields needs to be changed to BSSID for A-MSDU frames depending
+ * on FromDS/ToDS values.
+ */
+ switch (sdata->vif.type) {
+ case NL80211_IFTYPE_STATION:
+ bssid = sdata->u.mgd.bssid;
+ break;
+ case NL80211_IFTYPE_AP:
+ case NL80211_IFTYPE_AP_VLAN:
+ bssid = sdata->vif.addr;
+ break;
+ default:
+ bssid = NULL;
+ }
+
+ if (bssid && ieee80211_has_fromds(hdr->frame_control))
+ memcpy(h_80211_src, bssid, ETH_ALEN);
+
+ if (bssid && ieee80211_has_tods(hdr->frame_control))
+ memcpy(h_80211_dst, bssid, ETH_ALEN);
+
qc = ieee80211_get_qos_ctl(hdr);
*qc |= IEEE80211_QOS_CTL_A_MSDU_PRESENT;
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCHv5 1/2] mac80211: avoid extra memcpy in A-MSDU head creation
2016-10-15 11:28 [PATCHv5 1/2] mac80211: avoid extra memcpy in A-MSDU head creation Michael Braun
2016-10-15 11:28 ` [PATCHv5 2/2] mac80211: fix A-MSDU outer SA/DA Michael Braun
@ 2016-10-17 9:41 ` Johannes Berg
1 sibling, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2016-10-17 9:41 UTC (permalink / raw)
To: Michael Braun; +Cc: linux-wireless, projekt-wlan, Felix Fietkau
On Sat, 2016-10-15 at 13:28 +0200, Michael Braun wrote:
> Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
>
Applied.
johannes
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv5 2/2] mac80211: fix A-MSDU outer SA/DA
2016-10-15 11:28 ` [PATCHv5 2/2] mac80211: fix A-MSDU outer SA/DA Michael Braun
@ 2016-10-17 9:44 ` Johannes Berg
2016-10-17 10:29 ` [Projekt-wlan] " michael-dev
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2016-10-17 9:44 UTC (permalink / raw)
To: Michael Braun; +Cc: linux-wireless, projekt-wlan, Felix Fietkau
On Sat, 2016-10-15 at 13:28 +0200, Michael Braun wrote:
> According to IEEE 802.11-2012 section 8.3.2 table 8-19, the outer
> SA/DA
> of A-MSDU frames need to be changed depending on FromDS/ToDS values.
Also applied,
> + if (bssid && ieee80211_has_fromds(hdr->frame_control))
> + memcpy(h_80211_src, bssid, ETH_ALEN);
> +
> + if (bssid && ieee80211_has_tods(hdr->frame_control))
> + memcpy(h_80211_dst, bssid, ETH_ALEN);
but I also changed these to ether_addr_copy()
johannes
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Projekt-wlan] [PATCHv5 2/2] mac80211: fix A-MSDU outer SA/DA
2016-10-17 9:44 ` Johannes Berg
@ 2016-10-17 10:29 ` michael-dev
2016-10-17 10:39 ` Johannes Berg
0 siblings, 1 reply; 6+ messages in thread
From: michael-dev @ 2016-10-17 10:29 UTC (permalink / raw)
To: Johannes Berg; +Cc: projekt-wlan, Fietkau, Felix, linux-wireless
Am 17.10.2016 11:44, schrieb Johannes Berg:
>> + if (bssid && ieee80211_has_fromds(hdr->frame_control))
>> + memcpy(h_80211_src, bssid, ETH_ALEN);
>> +
>> + if (bssid && ieee80211_has_tods(hdr->frame_control))
>> + memcpy(h_80211_dst, bssid, ETH_ALEN);
>
> but I also changed these to ether_addr_copy()
ether_addr_copy requires both arguments to be __aligned(2) according to
include/linux/etherdevice.h.
bssid might be sdata->u.mgd.bssid, which is bssid in struct
ieee80211_if_managed, but neither sdata->u, sdata->u.mgd nor
sdata->u.mgd.bssid seem to be declared as __aligned(2).
So ether_addr_copy should not be used.
What am I missing?
Regards,
M. Braun
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Projekt-wlan] [PATCHv5 2/2] mac80211: fix A-MSDU outer SA/DA
2016-10-17 10:29 ` [Projekt-wlan] " michael-dev
@ 2016-10-17 10:39 ` Johannes Berg
0 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2016-10-17 10:39 UTC (permalink / raw)
To: michael-dev; +Cc: projekt-wlan, Fietkau, Felix, linux-wireless
On Mon, 2016-10-17 at 12:29 +0200, michael-dev wrote:
>
> ether_addr_copy requires both arguments to be __aligned(2) according
> to
> include/linux/etherdevice.h.
> bssid might be sdata->u.mgd.bssid, which is bssid in struct
> ieee80211_if_managed, but neither sdata->u, sdata->u.mgd nor
> sdata->u.mgd.bssid seem to be declared as __aligned(2).So
> ether_addr_copy should not be used.
They are in fact aligned today, given that they occur after a pointer.
However, I did add the __aligned(2) annotation to make that plenty
clear for the future.
johannes
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-10-17 10:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-15 11:28 [PATCHv5 1/2] mac80211: avoid extra memcpy in A-MSDU head creation Michael Braun
2016-10-15 11:28 ` [PATCHv5 2/2] mac80211: fix A-MSDU outer SA/DA Michael Braun
2016-10-17 9:44 ` Johannes Berg
2016-10-17 10:29 ` [Projekt-wlan] " michael-dev
2016-10-17 10:39 ` Johannes Berg
2016-10-17 9:41 ` [PATCHv5 1/2] mac80211: avoid extra memcpy in A-MSDU head creation Johannes Berg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.