[PATCH net-next 4/5] treewide: replace dev->trans_start update with helper

2016-05-03 Thread Florian Westphal
Replace all trans_start updates with netif_trans_update helper.
change was done via spatch:

struct net_device *d;
@@
- d->trans_start = jiffies
+ netif_trans_update(d)

Compile tested only.

Cc: user-mode-linux-de...@lists.sourceforge.net
Cc: linux-xte...@linux-xtensa.org
Cc: linux1394-de...@lists.sourceforge.net
Cc: linux-r...@vger.kernel.org
Cc: net...@vger.kernel.org
Cc: mpt-fusionlinux@broadcom.com
Cc: linux-s...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Cc: linux-par...@vger.kernel.org
Cc: linux-o...@vger.kernel.org
Cc: linux-h...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Cc: linux-wireless@vger.kernel.org
Cc: linux-s...@vger.kernel.org
Cc: de...@driverdev.osuosl.org
Cc: b.a.t.m@lists.open-mesh.org
Cc: linux-blueto...@vger.kernel.org
Signed-off-by: Florian Westphal <f...@strlen.de>
---
 Checkpatch complains about whitespace damage, but
 this extra whitespace already exists before this patch.

 arch/um/drivers/net_kern.c | 4 ++--
 arch/xtensa/platforms/iss/network.c| 2 +-
 drivers/char/pcmcia/synclink_cs.c  | 4 ++--
 drivers/firewire/net.c | 2 +-
 drivers/infiniband/hw/nes/nes_nic.c| 2 +-
 drivers/infiniband/ulp/ipoib/ipoib_cm.c| 2 +-
 drivers/infiniband/ulp/ipoib/ipoib_ib.c| 2 +-
 drivers/isdn/hysdn/hysdn_net.c | 2 +-
 drivers/isdn/i4l/isdn_net.c| 4 ++--
 drivers/isdn/i4l/isdn_x25iface.c   | 2 +-
 drivers/message/fusion/mptlan.c| 2 +-
 drivers/net/appletalk/cops.c   | 2 +-
 drivers/net/can/mscan/mscan.c  | 4 ++--
 drivers/net/can/usb/ems_usb.c  | 4 ++--
 drivers/net/can/usb/esd_usb2.c | 4 ++--
 drivers/net/can/usb/peak_usb/pcan_usb_core.c   | 4 ++--
 drivers/net/cris/eth_v10.c | 2 +-
 drivers/net/ethernet/3com/3c509.c  | 2 +-
 drivers/net/ethernet/3com/3c515.c  | 2 +-
 drivers/net/ethernet/3com/3c574_cs.c   | 2 +-
 drivers/net/ethernet/3com/3c589_cs.c   | 2 +-
 drivers/net/ethernet/3com/3c59x.c  | 2 +-
 drivers/net/ethernet/8390/axnet_cs.c   | 6 +++---
 drivers/net/ethernet/8390/lib8390.c| 4 ++--
 drivers/net/ethernet/adaptec/starfire.c| 2 +-
 drivers/net/ethernet/adi/bfin_mac.c| 2 +-
 drivers/net/ethernet/agere/et131x.c| 4 ++--
 drivers/net/ethernet/allwinner/sun4i-emac.c| 6 +++---
 drivers/net/ethernet/amd/7990.c| 4 ++--
 drivers/net/ethernet/amd/a2065.c   | 2 +-
 drivers/net/ethernet/amd/atarilance.c  | 2 +-
 drivers/net/ethernet/amd/au1000_eth.c  | 2 +-
 drivers/net/ethernet/amd/declance.c| 2 +-
 drivers/net/ethernet/amd/lance.c   | 2 +-
 drivers/net/ethernet/amd/ni65.c| 4 ++--
 drivers/net/ethernet/amd/nmclan_cs.c   | 2 +-
 drivers/net/ethernet/amd/pcnet32.c | 4 ++--
 drivers/net/ethernet/amd/sunlance.c| 2 +-
 drivers/net/ethernet/atheros/alx/main.c| 2 +-
 drivers/net/ethernet/broadcom/bcmsysport.c | 2 +-
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +-
 drivers/net/ethernet/broadcom/sb1250-mac.c | 2 +-
 drivers/net/ethernet/broadcom/tg3.c| 2 +-
 drivers/net/ethernet/cavium/liquidio/lio_main.c| 4 ++--
 drivers/net/ethernet/cavium/octeon/octeon_mgmt.c   | 2 +-
 drivers/net/ethernet/cavium/thunder/nicvf_main.c   | 2 +-
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c | 2 +-
 drivers/net/ethernet/davicom/dm9000.c  | 4 ++--
 drivers/net/ethernet/dec/tulip/de4x5.c | 4 ++--
 drivers/net/ethernet/dec/tulip/dmfe.c  | 6 +++---
 drivers/net/ethernet/dec/tulip/pnic.c  | 6 +++---
 drivers/net/ethernet/dec/tulip/tulip_core.c| 2 +-
 drivers/net/ethernet/dec/tulip/uli526x.c   | 4 ++--
 drivers/net/ethernet/dec/tulip/winbond-840.c   | 2 +-
 drivers/net/ethernet/dlink/dl2k.c  | 2 +-
 drivers/net/ethernet/dlink/sundance.c  | 2 +-
 drivers/net/ethernet/fealnx.c  | 2 +-
 drivers/net/ethernet/freescale/gianfar.c   | 2 +-
 drivers/net/ethernet/fujitsu/fmvj18x_cs.c  | 2 +-
 drivers/net/ethernet/hisilicon/hix5hd2_gmac.c  | 2 +-
 drivers/net/ethernet/hisilicon/hns/hns_enet.c  | 6 +++---
 drivers/net/ethernet/hp/hp100.c| 2 +-
 drivers/net/ethernet/i825xx/82596.c| 2 +-
 drivers/net/ethernet/i825xx/l

[PATCH next] drivers: wireless: carl9170: shrink carl9170_tx_info

2015-03-13 Thread Florian Westphal
its embededded inside rate_driver_data of the ieee80211_tx_info struct,
which in turn is stored in skb-cb[].

In order to shrink cb, we need to shrink ieee80211_tx_info which means
to downsize all users first.

Alternatively, one might be able to remove kref but
its less intrusive/simpler to use u32 for timeout handling.

Signed-off-by: Florian Westphal f...@strlen.de
---
 drivers/net/wireless/ath/carl9170/carl9170.h |  4 ++--
 drivers/net/wireless/ath/carl9170/debug.c|  2 +-
 drivers/net/wireless/ath/carl9170/tx.c   | 24 +++-
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/carl9170/carl9170.h 
b/drivers/net/wireless/ath/carl9170/carl9170.h
index 237d0cd..a785300 100644
--- a/drivers/net/wireless/ath/carl9170/carl9170.h
+++ b/drivers/net/wireless/ath/carl9170/carl9170.h
@@ -491,9 +491,9 @@ struct carl9170_sta_info {
 };
 
 struct carl9170_tx_info {
-   unsigned long timeout;
-   struct ar9170 *ar;
+   u32 timeout32;
struct kref ref;
+   struct ar9170 *ar;
 };
 
 #define CHK_DEV_STATE(a, s)(((struct ar9170 *)a)-state = (s))
diff --git a/drivers/net/wireless/ath/carl9170/debug.c 
b/drivers/net/wireless/ath/carl9170/debug.c
index 6808db4..d00ab9d 100644
--- a/drivers/net/wireless/ath/carl9170/debug.c
+++ b/drivers/net/wireless/ath/carl9170/debug.c
@@ -291,7 +291,7 @@ static void carl9170_debugfs_format_frame(struct ar9170 *ar,
pc:%.8x, to:%d ms\n, prefix, skb, txc-s.cookie,
ieee80211_get_DA(hdr), get_seq_h(hdr),
le16_to_cpu(txc-f.mac_control), le32_to_cpu(txc-f.phy_control),
-   jiffies_to_msecs(jiffies - arinfo-timeout));
+   jiffies_to_msecs(((u32)jiffies) - arinfo-timeout32));
 }
 
 
diff --git a/drivers/net/wireless/ath/carl9170/tx.c 
b/drivers/net/wireless/ath/carl9170/tx.c
index ae86a600..d576747 100644
--- a/drivers/net/wireless/ath/carl9170/tx.c
+++ b/drivers/net/wireless/ath/carl9170/tx.c
@@ -555,6 +555,20 @@ static void carl9170_tx_fill_rateinfo(struct ar9170 *ar, 
unsigned int rix,
}
 }
 
+static inline bool carl9170_time_is_before_jiffies(u32 timeout)
+{
+   u32 now = (u32)jiffies;
+
+   return (s32)(now - timeout) = 0;
+}
+
+static inline bool carl9170_time_is_after_jiffies(u32 timeout)
+{
+   u32 now = (u32)jiffies;
+
+   return (s32)(now - timeout)  0;
+}
+
 static void carl9170_check_queue_stop_timeout(struct ar9170 *ar)
 {
int i;
@@ -574,8 +588,8 @@ static void carl9170_check_queue_stop_timeout(struct ar9170 
*ar)
txinfo = IEEE80211_SKB_CB(skb);
arinfo = (void *) txinfo-rate_driver_data;
 
-   if (time_is_before_jiffies(arinfo-timeout +
-   msecs_to_jiffies(CARL9170_QUEUE_STUCK_TIMEOUT)) == true)
+   if (carl9170_time_is_before_jiffies(arinfo-timeout32 +
+   (u32)msecs_to_jiffies(CARL9170_QUEUE_STUCK_TIMEOUT)))
restart = true;
 
 next:
@@ -620,7 +634,7 @@ static void carl9170_tx_ampdu_timeout(struct ar9170 *ar)
 
txinfo = IEEE80211_SKB_CB(skb);
arinfo = (void *)txinfo-rate_driver_data;
-   if (time_is_after_jiffies(arinfo-timeout +
+   if (carl9170_time_is_after_jiffies(arinfo-timeout32 +
msecs_to_jiffies(CARL9170_QUEUE_TIMEOUT)))
goto unlock;
 
@@ -1066,7 +1080,7 @@ static int carl9170_tx_prepare(struct ar9170 *ar,
txc-f.mac_control = mac_tmp;
 
arinfo = (void *)info-rate_driver_data;
-   arinfo-timeout = jiffies;
+   arinfo-timeout32 = (u32)jiffies;
arinfo-ar = ar;
kref_init(arinfo-ref);
return 0;
@@ -1259,7 +1273,7 @@ static struct sk_buff *carl9170_tx_pick_skb(struct ar9170 
*ar,
info = IEEE80211_SKB_CB(skb);
arinfo = (void *) info-rate_driver_data;
 
-   arinfo-timeout = jiffies;
+   arinfo-timeout32 = (u32)jiffies;
return skb;
 
 err_unlock:
-- 
2.0.5

--
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 next] drivers: wireless: ar5523: use container_of

2015-03-10 Thread Florian Westphal
If we want to shrink skb-cb then we'd have to see about
reducing struct ieee80211_tx_info, which gets embedded inside
skb-cb[].

It provides a scratch space to be used by wireless drivers.
ar5523 uses the maximum space available today (40 bytes), but it seems
we don't need this -- data-skb pointer seems to always point back to the
skb whose cb buffer the data structure resides, iow, given a pointer to the
embedded control buffer we can infer the skb address.

Tested-by: Pontus Fuchs pontus.fu...@gmail.com
Signed-off-by: Florian Westphal f...@strlen.de
---
 drivers/net/wireless/ath/ar5523/ar5523.c | 9 +
 drivers/net/wireless/ath/ar5523/ar5523.h | 1 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ar5523/ar5523.c 
b/drivers/net/wireless/ath/ar5523/ar5523.c
index f920506..5147ebe 100644
--- a/drivers/net/wireless/ath/ar5523/ar5523.c
+++ b/drivers/net/wireless/ath/ar5523/ar5523.c
@@ -779,8 +779,6 @@ static void ar5523_tx(struct ieee80211_hw *hw,
ieee80211_stop_queues(hw);
}
 
-   data-skb = skb;
-
spin_lock_irqsave(ar-tx_data_list_lock, flags);
list_add_tail(data-list, ar-tx_queue_pending);
spin_unlock_irqrestore(ar-tx_data_list_lock, flags);
@@ -817,10 +815,13 @@ static void ar5523_tx_work_locked(struct ar5523 *ar)
if (!data)
break;
 
-   skb = data-skb;
+   txi = container_of((void *)data, struct ieee80211_tx_info,
+  driver_data);
txqid = 0;
-   txi = IEEE80211_SKB_CB(skb);
+
+   skb = container_of((void *)txi, struct sk_buff, cb);
paylen = skb-len;
+
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) {
ar5523_err(ar, Failed to allocate TX urb\n);
diff --git a/drivers/net/wireless/ath/ar5523/ar5523.h 
b/drivers/net/wireless/ath/ar5523/ar5523.h
index 00c6fd3..9a322a6 100644
--- a/drivers/net/wireless/ath/ar5523/ar5523.h
+++ b/drivers/net/wireless/ath/ar5523/ar5523.h
@@ -74,7 +74,6 @@ struct ar5523_tx_cmd {
 struct ar5523_tx_data {
struct list_headlist;
struct ar5523   *ar;
-   struct sk_buff  *skb;
struct urb  *urb;
 };
 
-- 
2.0.5

--
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 next] ath9k: make ath_frame_info fit into reduced-size rate_driver_data

2015-03-10 Thread Florian Westphal
pre-requisite to shrink size of ieee80211_tx_info which in turn is
needed to shrink skb-cb to 40 bytes again.

Signed-off-by: Florian Westphal f...@strlen.de
---
 drivers/net/wireless/ath/ath9k/ath9k.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h 
b/drivers/net/wireless/ath/ath9k/ath9k.h
index 7e89236..a7a81b3 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -184,12 +184,12 @@ struct ath_frame_info {
struct ath_buf *bf;
u16 framelen;
s8 txq;
-   enum ath9k_key_type keytype;
u8 keyix;
u8 rtscts_rate;
u8 retries : 7;
u8 baw_tracked : 1;
u8 tx_power;
+   enum ath9k_key_type keytype:2;
 };
 
 struct ath_rxbuf {
-- 
2.0.5

--
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 RFC 00/14] shrink skb cb to 44 bytes

2015-03-03 Thread Florian Westphal
David Miller da...@davemloft.net wrote:
 From: Eric Dumazet eric.duma...@gmail.com
 Date: Mon, 02 Mar 2015 20:02:05 -0800
 
  About the GRO layout change, reason why 'struct sk_buff *last;' is at
  the end of struct napi_gro_cb is that this field is not used in fast
  path.
 
 Understood.

Moved it back to end, thanks!

 While reviewing this I noticed that the jiffies timestamp in GRO cb
 could really be u32 if we want instead of full unsigned long.

Made it an u16 at the moment -- then __packed is no longer needed
and it fits in 40 bytes.

  Note : We could try to use one bit in skb to advertise zero shinfo(skb).
  
  Many skbs have a zeroed shinfo() (but shinfo-dataref == 1) , and
  dereferencing skb_shinfo adds a cache line miss. 
  
  - We could avoid memset(shinfo, 0, offsetof(struct skb_shared_info,
  dataref))  atomic_set(shinfo-dataref, 1); 
  
   in alloc_skb() and friends completely.
  
  Unfortunately this kind of change would be quite invasive...

 Right, all these kinds of things touch everything.

Indeed, but thanks for the hint Eric -- I'll investigate.
--
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 RFC 00/14] shrink skb cb to 44 bytes

2015-03-02 Thread Florian Westphal
Eric Dumazet eric.duma...@gmail.com wrote:
  remarks/known issues:
  - adds __packet attribute to a few structures.
Its needed to not have padding at end of the structure, else
we get build assertion errors even if all members fit into cb[].
  - checkpatch isn't happy yet.
  - dccp changes are untested (its on my todo list)
  - rxrpc change is untested (on todo list).
  - wireless changes are untested, I don't own any of the affected hw.
  
  The idea is to figure out what needs to be done to make build_skb() and
  friends only touch the first 3 cachelines of the skb on all architectures.
  
  We'd need to reduce skbuff by 40 bytes to achieve this for allyesconfig.
  
  Other sk_buff reduction ideas being worked:
  
  - move truesize to shinfo (which has 4 byte hole)
  - turn -data into offset on 64bit platforms (intrusive,  1000 files
affected)
  - move pointers that are ususally not needed (nf_bridge, secpath) to the 
  end,
with flag field that tells us when pointer is valid (so we don't have
to memset() them unconditionally at allocation time).
  - seems we could already to this for the inner header fields since the're 
  only
valid once -encapsulation / inner_protocol_type is set.
  
  Comments and more ideas welcome.
 
 Size of skb-cb[] is not the major factor. Trying to gain 4 or 8 bytes
 is not going to improve performance a lot.

Thats right, goal is to have build_skb etc. only touch 3 cachelines,
and have those layers that need some particular feature initialise it on
demand.

We could move skb-cb to end of skb, so that its not covered by the
initial allocation memset anymore.

Obviously that won't buy us anything at this point since gro needs
to zero it out (GRO skb cb is 48 bytes).

 The real problem is that we clear it in skb_alloc()/build_skb(), instead
 of each layer doing so at demand, and only the part that matters for
 this layer.

Thats right.  Do you think its worth to already move cb[] near the end
of skb and alter build_skb to not clear it anymore?

Which of the ideas, in your opinion, is worth pursuing first (if any)?

I'd love to get rid of nf_bridge* pointer and use percpu storage
area for it but I did not yet find a simple way to deal with when
skb that uses this percpu state leaves bridge code and is then dropped
or queued later -- we need to make sure that another skb isn't accidentally
believed to have valid nf_bridge context.

kfree_skb doesn't seem to be a nice place to add bridge crap to, and
neither is netif_rx...
--
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 RFC 09/14] net: wireless: mac80211: shrink private driver area

2015-03-02 Thread Florian Westphal
This makes the structure fit 44-byte sized skb-cb[].

Cc: linux-wireless@vger.kernel.org
Signed-off-by: Florian Westphal f...@strlen.de
---
 drivers/net/wireless/ath/ath9k/ath9k.h | 2 +-
 include/net/mac80211.h | 8 +++-
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h 
b/drivers/net/wireless/ath/ath9k/ath9k.h
index 0f8e946..2ed77cf 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -184,12 +184,12 @@ struct ath_frame_info {
struct ath_buf *bf;
u16 framelen;
s8 txq;
-   enum ath9k_key_type keytype;
u8 keyix;
u8 rtscts_rate;
u8 retries : 7;
u8 baw_tracked : 1;
u8 tx_power;
+   enum ath9k_key_type keytype:2;
 };
 
 struct ath_rxbuf {
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 36c2599..372c25a 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -627,11 +627,11 @@ enum mac80211_rate_control_flags {
 };
 
 
-/* there are 40 bytes if you don't need the rateset to be kept */
-#define IEEE80211_TX_INFO_DRIVER_DATA_SIZE 40
+/* there are 32 bytes if you don't need the rateset to be kept */
+#define IEEE80211_TX_INFO_DRIVER_DATA_SIZE 32
 
 /* if you do need the rateset, then you have less space */
-#define IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE 24
+#define IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE 16
 
 /* maximum number of rate stages */
 #define IEEE80211_TX_MAX_RATES 4
@@ -765,8 +765,6 @@ struct ieee80211_tx_info {
struct {
struct ieee80211_tx_rate driver_rates[
IEEE80211_TX_MAX_RATES];
-   u8 pad[4];
-
void *rate_driver_data[
IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE / 
sizeof(void *)];
};
-- 
2.0.5

--
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 RFC 06/14] drivers: wireless: carl9170: shrink carl9170_tx_info

2015-03-02 Thread Florian Westphal
compile tested only.

its embededded inside rate_driver_data of the ieee80211_tx_info struct,
which in turn is stored in skb-cb[].

In order to shrink cb, we need to shrink ieee80211_tx_info
which means to downsize the users.

Alternatively, one might be able to remove kref but
its less intrusive/simpler to use a u32 for timeout handling.

Cc: linux-wireless@vger.kernel.org
Signed-off-by: Florian Westphal f...@strlen.de
---
 drivers/net/wireless/ath/carl9170/carl9170.h |  4 ++--
 drivers/net/wireless/ath/carl9170/debug.c|  2 +-
 drivers/net/wireless/ath/carl9170/tx.c   | 22 +-
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/carl9170/carl9170.h 
b/drivers/net/wireless/ath/carl9170/carl9170.h
index 237d0cd..a785300 100644
--- a/drivers/net/wireless/ath/carl9170/carl9170.h
+++ b/drivers/net/wireless/ath/carl9170/carl9170.h
@@ -491,9 +491,9 @@ struct carl9170_sta_info {
 };
 
 struct carl9170_tx_info {
-   unsigned long timeout;
-   struct ar9170 *ar;
+   u32 timeout32;
struct kref ref;
+   struct ar9170 *ar;
 };
 
 #define CHK_DEV_STATE(a, s)(((struct ar9170 *)a)-state = (s))
diff --git a/drivers/net/wireless/ath/carl9170/debug.c 
b/drivers/net/wireless/ath/carl9170/debug.c
index 6808db4..d00ab9d 100644
--- a/drivers/net/wireless/ath/carl9170/debug.c
+++ b/drivers/net/wireless/ath/carl9170/debug.c
@@ -291,7 +291,7 @@ static void carl9170_debugfs_format_frame(struct ar9170 *ar,
pc:%.8x, to:%d ms\n, prefix, skb, txc-s.cookie,
ieee80211_get_DA(hdr), get_seq_h(hdr),
le16_to_cpu(txc-f.mac_control), le32_to_cpu(txc-f.phy_control),
-   jiffies_to_msecs(jiffies - arinfo-timeout));
+   jiffies_to_msecs(((u32)jiffies) - arinfo-timeout32));
 }
 
 
diff --git a/drivers/net/wireless/ath/carl9170/tx.c 
b/drivers/net/wireless/ath/carl9170/tx.c
index ae86a600..85687aaf4 100644
--- a/drivers/net/wireless/ath/carl9170/tx.c
+++ b/drivers/net/wireless/ath/carl9170/tx.c
@@ -555,6 +555,18 @@ static void carl9170_tx_fill_rateinfo(struct ar9170 *ar, 
unsigned int rix,
}
 }
 
+static inline bool carl9170_time_is_before_jiffies(u32 timeout)
+{
+   u32 now = (u32) jiffies;
+   return (s32)(now - timeout) = 0;
+}
+
+static inline bool carl9170_time_is_after_jiffies(u32 timeout)
+{
+   u32 now = (u32) jiffies;
+   return (s32)(now - timeout)  0;
+}
+
 static void carl9170_check_queue_stop_timeout(struct ar9170 *ar)
 {
int i;
@@ -574,8 +586,8 @@ static void carl9170_check_queue_stop_timeout(struct ar9170 
*ar)
txinfo = IEEE80211_SKB_CB(skb);
arinfo = (void *) txinfo-rate_driver_data;
 
-   if (time_is_before_jiffies(arinfo-timeout +
-   msecs_to_jiffies(CARL9170_QUEUE_STUCK_TIMEOUT)) == true)
+   if (carl9170_time_is_before_jiffies(arinfo-timeout32 +
+   (u32)msecs_to_jiffies(CARL9170_QUEUE_STUCK_TIMEOUT)) == 
true)
restart = true;
 
 next:
@@ -620,7 +632,7 @@ static void carl9170_tx_ampdu_timeout(struct ar9170 *ar)
 
txinfo = IEEE80211_SKB_CB(skb);
arinfo = (void *)txinfo-rate_driver_data;
-   if (time_is_after_jiffies(arinfo-timeout +
+   if (carl9170_time_is_after_jiffies(arinfo-timeout32 +
msecs_to_jiffies(CARL9170_QUEUE_TIMEOUT)))
goto unlock;
 
@@ -1066,7 +1078,7 @@ static int carl9170_tx_prepare(struct ar9170 *ar,
txc-f.mac_control = mac_tmp;
 
arinfo = (void *)info-rate_driver_data;
-   arinfo-timeout = jiffies;
+   arinfo-timeout32 = (u32) jiffies;
arinfo-ar = ar;
kref_init(arinfo-ref);
return 0;
@@ -1259,7 +1271,7 @@ static struct sk_buff *carl9170_tx_pick_skb(struct ar9170 
*ar,
info = IEEE80211_SKB_CB(skb);
arinfo = (void *) info-rate_driver_data;
 
-   arinfo-timeout = jiffies;
+   arinfo-timeout32 = (u32) jiffies;
return skb;
 
 err_unlock:
-- 
2.0.5

--
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 RFC 07/14] net: wireless: iwlwifi: shrink status private area

2015-03-02 Thread Florian Westphal
iwlwifi is only driver to use status_driver_data, and it only wants to
store u8 counter.

This is one patch needed to reduce size of ieee80211_tx_info,
which in turn is needed to allow reducing size of skb-cb[].

Cc: linux-wireless@vger.kernel.org
Signed-off-by: Florian Westphal f...@strlen.de
---
 drivers/net/wireless/iwlwifi/mvm/rs.c | 2 +-
 drivers/net/wireless/iwlwifi/mvm/tx.c | 8 +++-
 include/net/mac80211.h| 2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.c 
b/drivers/net/wireless/iwlwifi/mvm/rs.c
index 194bd1f..e29092b 100644
--- a/drivers/net/wireless/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/iwlwifi/mvm/rs.c
@@ -1054,7 +1054,7 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct 
ieee80211_sta *sta,
u32 ucode_rate;
struct rs_rate rate;
struct iwl_scale_tbl_info *curr_tbl, *other_tbl, *tmp_tbl;
-   u8 reduced_txp = (uintptr_t)info-status.status_driver_data[0];
+   u8 reduced_txp = (u8)info-status.status_driver_data[0];
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
struct iwl_lq_sta *lq_sta = mvmsta-lq_sta;
 
diff --git a/drivers/net/wireless/iwlwifi/mvm/tx.c 
b/drivers/net/wireless/iwlwifi/mvm/tx.c
index 07304e1..450635f 100644
--- a/drivers/net/wireless/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/iwlwifi/mvm/tx.c
@@ -683,9 +683,8 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,
 */
info-status.tx_time =
le16_to_cpu(tx_resp-wireless_media_time);
-   BUILD_BUG_ON(ARRAY_SIZE(info-status.status_driver_data)  1);
-   info-status.status_driver_data[0] =
-   (void *)(uintptr_t)tx_resp-reduced_tpc;
+   BUILD_BUG_ON(sizeof(info-status.status_driver_data)  1);
+   info-status.status_driver_data[0] = tx_resp-reduced_tpc;
 
ieee80211_tx_status(mvm-hw, skb);
}
@@ -907,8 +906,7 @@ static void iwl_mvm_tx_info_from_ba_notif(struct 
ieee80211_tx_info *info,
info);
/* TODO: not accounted if the whole A-MPDU failed */
info-status.tx_time = tid_data-tx_time;
-   info-status.status_driver_data[0] =
-   (void *)(uintptr_t)tid_data-reduced_tpc;
+   info-status.status_driver_data[0] = tid_data-reduced_tpc;
 }
 
 int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index d52914b..63c3708 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -755,7 +755,7 @@ struct ieee80211_tx_info {
u8 ampdu_len;
u8 antenna;
u16 tx_time;
-   void *status_driver_data[19 / sizeof(void *)];
+   u8 status_driver_data[1];
} status;
struct {
struct ieee80211_tx_rate driver_rates[
-- 
2.0.5

--
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 RFC 05/14] drivers: wireless: ar5523: use container_of

2015-03-02 Thread Florian Westphal
Compile tested only due to lack of hw.

If we want to shrink skb-cb then we'd have to see about
reducing struct ieee80211_tx_info, which gets embedded inside
skb-cb[].

It provides a scratch space to be used by wireless drivers.
ar5523 uses the maximum space available today (40 bytes), but it seems
we don't need this -- data-skb pointer seems to always point back to the
skb whose cb buffer the data structure resides, iow, given a pointer to the
embedded control buffer we can infer the skb address.

Cc: linux-wireless@vger.kernel.org
Signed-off-by: Florian Westphal f...@strlen.de
---
 drivers/net/wireless/ath/ar5523/ar5523.c | 8 
 drivers/net/wireless/ath/ar5523/ar5523.h | 1 -
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ar5523/ar5523.c 
b/drivers/net/wireless/ath/ar5523/ar5523.c
index f920506..7410ac0 100644
--- a/drivers/net/wireless/ath/ar5523/ar5523.c
+++ b/drivers/net/wireless/ath/ar5523/ar5523.c
@@ -779,8 +779,6 @@ static void ar5523_tx(struct ieee80211_hw *hw,
ieee80211_stop_queues(hw);
}
 
-   data-skb = skb;
-
spin_lock_irqsave(ar-tx_data_list_lock, flags);
list_add_tail(data-list, ar-tx_queue_pending);
spin_unlock_irqrestore(ar-tx_data_list_lock, flags);
@@ -817,10 +815,12 @@ static void ar5523_tx_work_locked(struct ar5523 *ar)
if (!data)
break;
 
-   skb = data-skb;
+   txi = container_of((void *)data, struct ieee80211_tx_info, 
driver_data);
txqid = 0;
-   txi = IEEE80211_SKB_CB(skb);
+
+   skb = container_of((void *) txi, struct sk_buff, cb);
paylen = skb-len;
+
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) {
ar5523_err(ar, Failed to allocate TX urb\n);
diff --git a/drivers/net/wireless/ath/ar5523/ar5523.h 
b/drivers/net/wireless/ath/ar5523/ar5523.h
index 00c6fd3..9a322a6 100644
--- a/drivers/net/wireless/ath/ar5523/ar5523.h
+++ b/drivers/net/wireless/ath/ar5523/ar5523.h
@@ -74,7 +74,6 @@ struct ar5523_tx_cmd {
 struct ar5523_tx_data {
struct list_headlist;
struct ar5523   *ar;
-   struct sk_buff  *skb;
struct urb  *urb;
 };
 
-- 
2.0.5

--
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 RFC 08/14] net: wireless: mac80211: shrink ieee80211_tx_info

2015-03-02 Thread Florian Westphal
to make it fit into (future) 44-byte sized skb-cb[].

This works, since flags is only used to store values
from mac80211_tx_control_flags enum, and these are just 2 bits.
We can thus move this to the padding hole inside the union.

Also add BUILD_BUG_ON magic to make sure that the new flags
field doesn't share storage w. other members of the union.

Cc: linux-wireless@vger.kernel.org
Signed-off-by: Florian Westphal f...@strlen.de
---
 include/net/mac80211.h | 11 ---
 net/mac80211/main.c|  3 +++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 63c3708..36c2599 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -737,16 +737,21 @@ struct ieee80211_tx_info {
u8 use_cts_prot:1;
u8 short_preamble:1;
u8 skip_table:1;
-   /* 2 bytes free */
+   enum mac80211_tx_control_flags flags:2;
+   /* used for BUILD_BUG_ON validation 
that -flags won't
+* overlap with jiffies below */
+   char flags_end[0];
};
/* only needed before rate control */
unsigned long jiffies;
+
+   /* used for BUILD_BUG_ON validation that 
-flags won't
+* overlap with other members of this union. */
+   char union_end[0];
};
/* NB: vif can be NULL for injected frames */
struct ieee80211_vif *vif;
struct ieee80211_key_conf *hw_key;
-   u32 flags;
-   /* 4 bytes free */
} control;
struct {
struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES];
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 5e09d35..9e8c807 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -1218,6 +1218,9 @@ static int __init ieee80211_init(void)
BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, driver_data) +
 IEEE80211_TX_INFO_DRIVER_DATA_SIZE  sizeof(skb-cb));
 
+   BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, control.flags_end) 
+offsetof(struct ieee80211_tx_info, control.union_end));
+
ret = rc80211_minstrel_init();
if (ret)
return ret;
-- 
2.0.5

--
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 RFC 04/14] drivers: wireless: rt2x00: move skb_dma to queue entry

2015-03-02 Thread Florian Westphal
... to shrink size needed for the skb frame desc.

Note that this is just the lowest hanging fruit I found, if you find
better/other means to shrink the space needed in skb-cb
(or to shrink it even further) -- great.

Cc: linux-wireless@vger.kernel.org
Signed-off-by: Florian Westphal f...@strlen.de
---
 drivers/net/wireless/rt2x00/rt2400pci.c   |  5 ++---
 drivers/net/wireless/rt2x00/rt2500pci.c   |  5 ++---
 drivers/net/wireless/rt2x00/rt2800mmio.c  |  7 +++
 drivers/net/wireless/rt2x00/rt2x00queue.c | 10 +-
 drivers/net/wireless/rt2x00/rt2x00queue.h | 17 -
 drivers/net/wireless/rt2x00/rt61pci.c |  5 ++---
 6 files changed, 22 insertions(+), 27 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c 
b/drivers/net/wireless/rt2x00/rt2400pci.c
index bdf5590..5c7927c 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -739,7 +739,6 @@ static bool rt2400pci_get_entry_state(struct queue_entry 
*entry)
 static void rt2400pci_clear_entry(struct queue_entry *entry)
 {
struct queue_entry_priv_mmio *entry_priv = entry-priv_data;
-   struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry-skb);
u32 word;
 
if (entry-queue-qid == QID_RX) {
@@ -748,7 +747,7 @@ static void rt2400pci_clear_entry(struct queue_entry *entry)
rt2x00_desc_write(entry_priv-desc, 2, word);
 
rt2x00_desc_read(entry_priv-desc, 1, word);
-   rt2x00_set_field32(word, RXD_W1_BUFFER_ADDRESS, 
skbdesc-skb_dma);
+   rt2x00_set_field32(word, RXD_W1_BUFFER_ADDRESS, 
entry-skb_dma);
rt2x00_desc_write(entry_priv-desc, 1, word);
 
rt2x00_desc_read(entry_priv-desc, 0, word);
@@ -,7 +1110,7 @@ static void rt2400pci_write_tx_desc(struct queue_entry 
*entry,
 * Start writing the descriptor words.
 */
rt2x00_desc_read(txd, 1, word);
-   rt2x00_set_field32(word, TXD_W1_BUFFER_ADDRESS, skbdesc-skb_dma);
+   rt2x00_set_field32(word, TXD_W1_BUFFER_ADDRESS, entry-skb_dma);
rt2x00_desc_write(txd, 1, word);
 
rt2x00_desc_read(txd, 2, word);
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c 
b/drivers/net/wireless/rt2x00/rt2500pci.c
index 79f4fe6..907d7c2 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -828,12 +828,11 @@ static bool rt2500pci_get_entry_state(struct queue_entry 
*entry)
 static void rt2500pci_clear_entry(struct queue_entry *entry)
 {
struct queue_entry_priv_mmio *entry_priv = entry-priv_data;
-   struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry-skb);
u32 word;
 
if (entry-queue-qid == QID_RX) {
rt2x00_desc_read(entry_priv-desc, 1, word);
-   rt2x00_set_field32(word, RXD_W1_BUFFER_ADDRESS, 
skbdesc-skb_dma);
+   rt2x00_set_field32(word, RXD_W1_BUFFER_ADDRESS, 
entry-skb_dma);
rt2x00_desc_write(entry_priv-desc, 1, word);
 
rt2x00_desc_read(entry_priv-desc, 0, word);
@@ -1264,7 +1263,7 @@ static void rt2500pci_write_tx_desc(struct queue_entry 
*entry,
 * Start writing the descriptor words.
 */
rt2x00_desc_read(txd, 1, word);
-   rt2x00_set_field32(word, TXD_W1_BUFFER_ADDRESS, skbdesc-skb_dma);
+   rt2x00_set_field32(word, TXD_W1_BUFFER_ADDRESS, entry-skb_dma);
rt2x00_desc_write(txd, 1, word);
 
rt2x00_desc_read(txd, 2, word);
diff --git a/drivers/net/wireless/rt2x00/rt2800mmio.c 
b/drivers/net/wireless/rt2x00/rt2800mmio.c
index de4790b..45772a1 100644
--- a/drivers/net/wireless/rt2x00/rt2800mmio.c
+++ b/drivers/net/wireless/rt2x00/rt2800mmio.c
@@ -66,7 +66,7 @@ void rt2800mmio_write_tx_desc(struct queue_entry *entry,
 * Initialize TX descriptor
 */
word = 0;
-   rt2x00_set_field32(word, TXD_W0_SD_PTR0, skbdesc-skb_dma);
+   rt2x00_set_field32(word, TXD_W0_SD_PTR0, entry-skb_dma);
rt2x00_desc_write(txd, 0, word);
 
word = 0;
@@ -82,7 +82,7 @@ void rt2800mmio_write_tx_desc(struct queue_entry *entry,
 
word = 0;
rt2x00_set_field32(word, TXD_W2_SD_PTR1,
-  skbdesc-skb_dma + txwi_size);
+  entry-skb_dma + txwi_size);
rt2x00_desc_write(txd, 2, word);
 
word = 0;
@@ -710,13 +710,12 @@ EXPORT_SYMBOL_GPL(rt2800mmio_get_entry_state);
 void rt2800mmio_clear_entry(struct queue_entry *entry)
 {
struct queue_entry_priv_mmio *entry_priv = entry-priv_data;
-   struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry-skb);
struct rt2x00_dev *rt2x00dev = entry-queue-rt2x00dev;
u32 word;
 
if (entry-queue-qid == QID_RX) {
rt2x00_desc_read(entry_priv-desc, 0, word);
-   rt2x00_set_field32(word, RXD_W0_SDP0, skbdesc-skb_dma);
+   rt2x00_set_field32(word, RXD_W0_SDP0, entry-skb_dma

Re: [PATCH RFC 08/14] net: wireless: mac80211: shrink ieee80211_tx_info

2015-03-02 Thread Florian Westphal
Johannes Berg johan...@sipsolutions.net wrote:
 On Mon, 2015-03-02 at 18:40 +0100, Florian Westphal wrote:
  to make it fit into (future) 44-byte sized skb-cb[].
  
  This works, since flags is only used to store values
  from mac80211_tx_control_flags enum, and these are just 2 bits.
  We can thus move this to the padding hole inside the union.
  
  Also add BUILD_BUG_ON magic to make sure that the new flags
  field doesn't share storage w. other members of the union.
 
 This is really ugly - what's the point of this?

Eventually reducing skb size to make it fit into 3 cachelines again even
on 64bit architectures.  For that 40 bytes need to go.

 Mind you - we are actually acutely out of space and would rather have
 *more*, not less.

:-(

I'm not familiar with mac80211, aside from that it seemed to me
that 40 byte cb would be doable, given enough work.

Where are to main problems, exactly?

I known that pushing something into -cb is a lot easier than e.g. keeping
extra state on stack, but, IMO cb should really only be used when you
need to associate data strictly with an skb so that this data is still
availabe even when skb gets queued somewehere.

Is there a document somewhere that lists all of the per-skb data that
mac80211 needs to store (or wants to store)?

Thanks,
Florian
--
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