2018-02-09 18:51:05

by Felix Fietkau

[permalink] [raw]
Subject: [PATCH] mac80211: round IEEE80211_TX_STATUS_HEADROOM up to multiple of 4

This ensures that mac80211 allocated management frames are properly
aligned, which makes copying them more efficient.
For instance, mt76 uses iowrite32_copy to copy beacon frames to beacon
template memory on the chip.
Misaligned 32-bit accesses cause CPU exceptions on MIPS and should be
avoided.

Signed-off-by: Felix Fietkau <[email protected]>
---
include/net/mac80211.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 906e90223066..d999b8c8a44b 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -4149,7 +4149,7 @@ void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *sta, u8 tid);
* The TX headroom reserved by mac80211 for its own tx_status functions.
* This is enough for the radiotap header.
*/
-#define IEEE80211_TX_STATUS_HEADROOM 14
+#define IEEE80211_TX_STATUS_HEADROOM 16

/**
* ieee80211_sta_set_buffered - inform mac80211 about driver-buffered frames
--
2.14.2


2018-02-09 19:10:49

by Arend Van Spriel

[permalink] [raw]
Subject: Re: [PATCH] mac80211: round IEEE80211_TX_STATUS_HEADROOM up to multiple of 4

On 2/9/2018 7:51 PM, Felix Fietkau wrote:
> This ensures that mac80211 allocated management frames are properly
> aligned, which makes copying them more efficient.
> For instance, mt76 uses iowrite32_copy to copy beacon frames to beacon
> template memory on the chip.
> Misaligned 32-bit accesses cause CPU exceptions on MIPS and should be
> avoided.
>
> Signed-off-by: Felix Fietkau <[email protected]>
> ---
> include/net/mac80211.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/net/mac80211.h b/include/net/mac80211.h
> index 906e90223066..d999b8c8a44b 100644
> --- a/include/net/mac80211.h
> +++ b/include/net/mac80211.h
> @@ -4149,7 +4149,7 @@ void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *sta, u8 tid);
> * The TX headroom reserved by mac80211 for its own tx_status functions.
> * This is enough for the radiotap header.

Hi Felix,

Maybe useful to mention the alignment requirement in this comment block.

> */
> -#define IEEE80211_TX_STATUS_HEADROOM 14
> +#define IEEE80211_TX_STATUS_HEADROOM 16

Regards,
Arend

2018-02-09 19:41:35

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: round IEEE80211_TX_STATUS_HEADROOM up to multiple of 4

On Fri, 2018-02-09 at 20:10 +0100, Arend van Spriel wrote:
>
> > @@ -4149,7 +4149,7 @@ void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *sta, u8 tid);
> > * The TX headroom reserved by mac80211 for its own tx_status functions.
> > * This is enough for the radiotap header.
>
> Hi Felix,
>
> Maybe useful to mention the alignment requirement in this comment block.
>
> > */
> > -#define IEEE80211_TX_STATUS_HEADROOM 14
> > +#define IEEE80211_TX_STATUS_HEADROOM 16
>
Or better yet, just define it as ALIGN(14, 4) ?

johannes