Re: [PATCH 2/2] mac80211: add NEED_ALIGNED4_SKBS hw flag

2016-04-05 Thread Johannes Berg
On Tue, 2016-02-23 at 17:15 +0100, Johannes Berg wrote:

> > > Perhaps we could live with this being done only for the fast-xmit
> > > case?
> > I don't think we should pass padded vs non-padded frames depending
> > on
> > whether fast-xmit was used. The non-fast-xmit codepath could simply
> > do the memmove at the end of the tx handlers though.
> I guess that's fair. Would it be sufficent though?
> 

So it turns out the patch 1/2 actually makes the code *bigger* for some
reason.

Janusz, can you see if the above suggestion would be good enough?

Hopefully high-tpt cases would all run through fast-xmit anyway.

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] mac80211: add NEED_ALIGNED4_SKBS hw flag

2016-02-23 Thread Johannes Berg
On Tue, 2016-02-23 at 15:53 +0100, Felix Fietkau wrote:

> > Perhaps we could live with this being done only for the fast-xmit
> > case?
> I don't think we should pass padded vs non-padded frames depending on
> whether fast-xmit was used. The non-fast-xmit codepath could simply
> do the memmove at the end of the tx handlers though.

I guess that's fair. Would it be sufficent though?

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] mac80211: add NEED_ALIGNED4_SKBS hw flag

2016-02-23 Thread Felix Fietkau
On 2016-02-23 15:29, Johannes Berg wrote:
> On Fri, 2016-02-19 at 11:01 +0100, Janusz Dziedzic wrote:
>> HW/driver should set NEED_ALIGNED4_SKBS flag in case
>> require aligned skbs to four-byte boundaries.
>> This affect only TX direction.
>> 
>> Padding is added after ieee80211_hdr, before IV/LLC.
> 
> I'm still not super happy with how invasive these patches are.
> 
> Perhaps we could live with this being done only for the fast-xmit case?
I don't think we should pass padded vs non-padded frames depending on
whether fast-xmit was used. The non-fast-xmit codepath could simply do
the memmove at the end of the tx handlers though.

- Felix
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] mac80211: add NEED_ALIGNED4_SKBS hw flag

2016-02-23 Thread Johannes Berg
On Fri, 2016-02-19 at 11:01 +0100, Janusz Dziedzic wrote:
> HW/driver should set NEED_ALIGNED4_SKBS flag in case
> require aligned skbs to four-byte boundaries.
> This affect only TX direction.
> 
> Padding is added after ieee80211_hdr, before IV/LLC.

I'm still not super happy with how invasive these patches are.

Perhaps we could live with this being done only for the fast-xmit case?

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] mac80211: add NEED_ALIGNED4_SKBS hw flag

2016-02-19 Thread Janusz Dziedzic
HW/driver should set NEED_ALIGNED4_SKBS flag in case
require aligned skbs to four-byte boundaries.
This affect only TX direction.

Padding is added after ieee80211_hdr, before IV/LLC.

Before we have to do memmove(hdrlen) twice in the
dirver. Once before we pass this to HW and next
in tx completion (to be sure monitor will report
this tx frame correctly).

With this patch we can skip this memmove() and save CPU.

Currently this was tested with ath9k, both hw/sw crypt for
wep/tkip/ccmp.

Signed-off-by: Janusz Dziedzic 
---
 include/net/mac80211.h |  3 +++
 net/mac80211/debugfs.c |  1 +
 net/mac80211/ieee80211_i.h | 23 +++
 net/mac80211/sta_info.h|  2 +-
 net/mac80211/status.c  | 13 +
 net/mac80211/tkip.c|  4 +++-
 net/mac80211/tx.c  | 21 +++--
 net/mac80211/util.c|  3 ++-
 8 files changed, 61 insertions(+), 9 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 31337f8..561605c 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1961,6 +1961,8 @@ struct ieee80211_txq {
  * reordering buffer internally, guaranteeing mac80211 receives frames in
  * order and does not need to manage its own reorder buffer or BA session
  * timeout.
+ * @IEEE80211_HW_NEEDS_ALIGNED4_SKBS: Driver need aligned skbs to four-byte.
+ * Padding will be added after ieee80211_hdr, before IV/LLC.
  *
  * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
  */
@@ -1999,6 +2001,7 @@ enum ieee80211_hw_flags {
IEEE80211_HW_BEACON_TX_STATUS,
IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR,
IEEE80211_HW_SUPPORTS_REORDERING_BUFFER,
+   IEEE80211_HW_NEEDS_ALIGNED4_SKBS,
 
/* keep last, obviously */
NUM_IEEE80211_HW_FLAGS
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index 4ab5c52..c48905e 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -127,6 +127,7 @@ static const char *hw_flag_names[] = {
FLAG(BEACON_TX_STATUS),
FLAG(NEEDS_UNIQUE_STA_ADDR),
FLAG(SUPPORTS_REORDERING_BUFFER),
+   FLAG(NEEDS_ALIGNED4_SKBS),
 #undef FLAG
 };
 
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 81a476a..0687f94 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1476,6 +1476,29 @@ ieee80211_have_rx_timestamp(struct ieee80211_rx_status 
*status)
return false;
 }
 
+static inline unsigned int
+ieee80211_hdr_padsize(struct ieee80211_hw *hw, unsigned int hdrlen)
+{
+   /*
+* While hdrlen is already aligned to two-byte boundaries,
+* simple check with & 2 will return correct padsize.
+*/
+   if (ieee80211_hw_check(hw, NEEDS_ALIGNED4_SKBS))
+   return hdrlen & 2;
+   return 0;
+}
+
+static inline unsigned int
+ieee80211_padded_hdrlen(struct ieee80211_hw *hw, __le16 fc)
+{
+   unsigned int hdrlen;
+
+   hdrlen = ieee80211_hdrlen(fc);
+   hdrlen += ieee80211_hdr_padsize(hw, hdrlen);
+
+   return hdrlen;
+}
+
 u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
 struct ieee80211_rx_status *status,
 unsigned int mpdu_len,
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index f4d3899..c432f4a 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -271,7 +271,7 @@ struct ieee80211_fast_tx {
u8 hdr_len;
u8 sa_offs, da_offs, pn_offs;
u8 band;
-   u8 hdr[30 + 2 + IEEE80211_FAST_XMIT_MAX_IV +
+   u8 hdr[30 + 2 + 2 + IEEE80211_FAST_XMIT_MAX_IV +
   sizeof(rfc1042_header)];
 
struct rcu_head rcu_head;
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index 6101deb..d2b0273 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -683,9 +683,22 @@ void ieee80211_tx_monitor(struct ieee80211_local *local, 
struct sk_buff *skb,
struct sk_buff *skb2;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct ieee80211_sub_if_data *sdata;
+   struct ieee80211_hdr *hdr = (void *)skb->data;
struct net_device *prev_dev = NULL;
+   unsigned int hdrlen, padsize;
int rtap_len;
 
+   /* Remove padding if was added */
+   if (ieee80211_hw_check(&local->hw, NEEDS_ALIGNED4_SKBS)) {
+   hdrlen = ieee80211_hdrlen(hdr->frame_control);
+   padsize = ieee80211_hdr_padsize(&local->hw, hdrlen);
+
+   if (padsize && skb->len > hdrlen + padsize) {
+   memmove(skb->data + padsize, skb->data, hdrlen);
+   skb_pull(skb, padsize);
+   }
+   }
+
/* send frame to monitor interfaces now */
rtap_len = ieee80211_tx_radiotap_len(info);
if (WARN_ON_ONCE(skb_headroom(skb) < rtap_len)) {
diff --git a/net/mac80211/tkip.c b/net/mac80211/tkip.c
index 0ae2077..b3ab779 100644
--- a/net/ma