Re: [net-next:master 17/24] DockBook: net/core/skbuff.c:4404: warning: No description found for parameter 'mtu'

2016-06-03 Thread David Miller
From: kbuild test robot 
Date: Sat, 4 Jun 2016 08:48:17 +0800

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 
> master
> head:   330348d94223346f855357fab2517f6c903001c7
> commit: ae7ef81ef000adeee7a87585b9135ff8a8064acc [17/24] skbuff: introduce 
> skb_gso_validate_mtu
> reproduce: make htmldocs
> 
> All warnings (new ones prefixed by >>):
> 
>include/linux/skbuff.h:928: warning: No description found for parameter 
> 'sk'
>include/net/sock.h:449: warning: No description found for parameter 
> 'sk_padding'
>include/net/sock.h:449: warning: No description found for parameter 
> 'sk_rcu'
>>> net/core/skbuff.c:4404: warning: No description found for parameter 'mtu'
>net/core/gen_stats.c:65: warning: No description found for parameter 
> 'padattr'
>net/core/gen_stats.c:100: warning: No description found for parameter 
> 'padattr'

Fixed as follows:


net: Add docbook description for 'mtu' arg to skb_gso_validate_mtu()

Signed-off-by: David S. Miller 
---
 net/core/skbuff.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index b6e0f95..e7ec6d3 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4399,6 +4399,7 @@ EXPORT_SYMBOL_GPL(skb_gso_transport_seglen);
  * skb_gso_validate_mtu - Return in case such skb fits a given MTU
  *
  * @skb: GSO skb
+ * @mtu: MTU to validate against
  *
  * skb_gso_validate_mtu validates if a given skb will fit a wanted MTU
  * once split.
-- 
2.1.0



Re: [net-next:master 20/29] net/sctp/output.c:185:21: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}'

2016-06-03 Thread David Miller

I fixed this as follows:


[PATCH] sctp: Fix warning in sctp_packet_transmit_chunk()

size_t objects should be printed with %Z printf format.

Reported-by: kbuild test robot 
Signed-off-by: David S. Miller 
---
 net/sctp/output.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sctp/output.c b/net/sctp/output.c
index 90d2e12..1541a91 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -182,7 +182,7 @@ sctp_xmit_t sctp_packet_transmit_chunk(struct sctp_packet 
*packet,
sctp_xmit_t retval;
int error = 0;
 
-   pr_debug("%s: packet:%p size:%lu chunk:%p size:%d\n", __func__,
+   pr_debug("%s: packet:%p size:%Zu chunk:%p size:%d\n", __func__,
 packet, packet->size, chunk, chunk->skb ? chunk->skb->len : 
-1);
 
switch ((retval = (sctp_packet_append_chunk(packet, chunk {
-- 
2.1.0



RE: [PATCH net] bnx2x: allow adding VLANs while interface is down

2016-06-03 Thread Yuval Mintz
> Since implementing VLAN filtering in commit 05cc5a39ddb74
> ("bnx2x: add vlan filtering offload") bnx2x refuses to add a VLAN while the
> interface is down.

Hi Michal - thanks; I'll review this one on Sunday.


Re: [PATCH net-next] qed: Fix next-ptr chains for BE / 32-bit

2016-06-03 Thread David Miller
From: Yuval Mintz 
Date: Sat, 4 Jun 2016 08:20:16 +0300

> Commit a91eb52abb50 ("qed: Revisit chain implementation") contains an
> incorrect implementation for BE platforms, as device's regpairs containing
> addresses are LE and they're not converted correctly when read back.
> In addition, it raises a compilation warning for 32-bit platforms where
> dma_addr_t is a 32-bit variable.
> 
> Reported-by: kbuild test robot 
> Signed-off-by: Yuval Mintz 

Applied, thanks.


Re: [PATCH net-next 00/17] New DSA bind, switches as devices

2016-06-03 Thread David Miller
From: Andrew Lunn 
Date: Fri,  3 Jun 2016 18:43:59 +0200

> The interesting patches here are the last three. They implement a new
> binding for DSA, which removes a few limitations of the current DSA
> binding. In particular, it allows switches to be true Linux devices.
> These devices can be on any type of bus, unlike the old DSA binding
> which assumes MDIO. See the commit log for more details. The second to
> last patch modifies an existing boards device tree to use the new
> binding, giving a good example of how switches can be true MDIO
> devices. The last patch documents the new binding.
> 
> I know both John Crispin and Bryan Whitehead are interesting in
> implementing DSA drivers, hence i have CC: you. Comments welcome.
> 
> Thanks go to Florian and Vivien for reviewing, testing and bug fixing
> these patches.

Florian's feedback wrt. patch #15 seems legitimate.  Please address
and respin this series, it looks ready to go.


[PATCH net-next] qed: Fix next-ptr chains for BE / 32-bit

2016-06-03 Thread Yuval Mintz
Commit a91eb52abb50 ("qed: Revisit chain implementation") contains an
incorrect implementation for BE platforms, as device's regpairs containing
addresses are LE and they're not converted correctly when read back.
In addition, it raises a compilation warning for 32-bit platforms where
dma_addr_t is a 32-bit variable.

Reported-by: kbuild test robot 
Signed-off-by: Yuval Mintz 
---
Dave,

Please consider applying this to `net-next'.

Thanks,
Yuval
---
 include/linux/qed/qed_chain.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/linux/qed/qed_chain.h b/include/linux/qed/qed_chain.h
index eceaa9e..7e441bd 100644
--- a/include/linux/qed/qed_chain.h
+++ b/include/linux/qed/qed_chain.h
@@ -25,10 +25,9 @@
} while (0)
 
 #define HILO_GEN(hi, lo, type)  type)(hi)) << 32) + (lo))
-#define HILO_DMA(hi, lo)HILO_GEN(hi, lo, dma_addr_t)
 #define HILO_64(hi, lo) HILO_GEN((le32_to_cpu(hi)), (le32_to_cpu(lo)), u64)
-#define HILO_DMA_REGPAIR(regpair)   (HILO_DMA(regpair.hi, regpair.lo))
 #define HILO_64_REGPAIR(regpair)(HILO_64(regpair.hi, regpair.lo))
+#define HILO_DMA_REGPAIR(regpair)  ((dma_addr_t)HILO_64_REGPAIR(regpair))
 
 enum qed_chain_mode {
/* Each Page contains a next pointer at its end */
-- 
1.9.3



[PATCH v2 2/2] b43: Completely remove support for phy_a

2016-06-03 Thread Guenter Roeck
Per Michael Büsch: "All a-phy code is usused", so remove it all.

Signed-off-by: Guenter Roeck 
---
v2: Added patch

 drivers/net/wireless/broadcom/b43/main.c |  31 +---
 drivers/net/wireless/broadcom/b43/wa.c   | 283 +++
 drivers/net/wireless/broadcom/b43/xmit.c |  17 +-
 3 files changed, 24 insertions(+), 307 deletions(-)

diff --git a/drivers/net/wireless/broadcom/b43/main.c 
b/drivers/net/wireless/broadcom/b43/main.c
index 4ee5c5853f9f..6e5d9095b195 100644
--- a/drivers/net/wireless/broadcom/b43/main.c
+++ b/drivers/net/wireless/broadcom/b43/main.c
@@ -3180,7 +3180,6 @@ static void b43_rate_memory_write(struct b43_wldev *dev, 
u16 rate, int is_ofdm)
 static void b43_rate_memory_init(struct b43_wldev *dev)
 {
switch (dev->phy.type) {
-   case B43_PHYTYPE_A:
case B43_PHYTYPE_G:
case B43_PHYTYPE_N:
case B43_PHYTYPE_LP:
@@ -3194,8 +3193,6 @@ static void b43_rate_memory_init(struct b43_wldev *dev)
b43_rate_memory_write(dev, B43_OFDM_RATE_36MB, 1);
b43_rate_memory_write(dev, B43_OFDM_RATE_48MB, 1);
b43_rate_memory_write(dev, B43_OFDM_RATE_54MB, 1);
-   if (dev->phy.type == B43_PHYTYPE_A)
-   break;
/* fallthrough */
case B43_PHYTYPE_B:
b43_rate_memory_write(dev, B43_CCK_RATE_1MB, 0);
@@ -4604,14 +4601,6 @@ static int b43_phy_versioning(struct b43_wldev *dev)
if (radio_manuf != 0x17F /* Broadcom */)
unsupported = 1;
switch (phy_type) {
-   case B43_PHYTYPE_A:
-   if (radio_id != 0x2060)
-   unsupported = 1;
-   if (radio_rev != 1)
-   unsupported = 1;
-   if (radio_manuf != 0x17F)
-   unsupported = 1;
-   break;
case B43_PHYTYPE_B:
if ((radio_id & 0xFFF0) != 0x2050)
unsupported = 1;
@@ -4766,10 +4755,7 @@ static void b43_set_synth_pu_delay(struct b43_wldev 
*dev, bool idle)
u16 pu_delay;
 
/* The time value is in microseconds. */
-   if (dev->phy.type == B43_PHYTYPE_A)
-   pu_delay = 3700;
-   else
-   pu_delay = 1050;
+   pu_delay = 1050;
if (b43_is_mode(dev->wl, NL80211_IFTYPE_ADHOC) || idle)
pu_delay = 500;
if ((dev->phy.radio_ver == 0x2050) && (dev->phy.radio_rev == 8))
@@ -4784,14 +4770,10 @@ static void b43_set_pretbtt(struct b43_wldev *dev)
u16 pretbtt;
 
/* The time value is in microseconds. */
-   if (b43_is_mode(dev->wl, NL80211_IFTYPE_ADHOC)) {
+   if (b43_is_mode(dev->wl, NL80211_IFTYPE_ADHOC))
pretbtt = 2;
-   } else {
-   if (dev->phy.type == B43_PHYTYPE_A)
-   pretbtt = 120;
-   else
-   pretbtt = 250;
-   }
+   else
+   pretbtt = 250;
b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_PRETBTT, pretbtt);
b43_write16(dev, B43_MMIO_TSF_CFP_PRETBTT, pretbtt);
 }
@@ -5380,10 +5362,6 @@ static void b43_supported_bands(struct b43_wldev *dev, 
bool *have_2ghz_phy,
 
/* As a fallback, try to guess using PHY type */
switch (dev->phy.type) {
-   case B43_PHYTYPE_A:
-   *have_2ghz_phy = false;
-   *have_5ghz_phy = true;
-   return;
case B43_PHYTYPE_G:
case B43_PHYTYPE_N:
case B43_PHYTYPE_LP:
@@ -5455,7 +5433,6 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
/* We don't support 5 GHz on some PHYs yet */
if (have_5ghz_phy) {
switch (dev->phy.type) {
-   case B43_PHYTYPE_A:
case B43_PHYTYPE_G:
case B43_PHYTYPE_LP:
case B43_PHYTYPE_HT:
diff --git a/drivers/net/wireless/broadcom/b43/wa.c 
b/drivers/net/wireless/broadcom/b43/wa.c
index c218c08fb2f5..0e96c08d1e17 100644
--- a/drivers/net/wireless/broadcom/b43/wa.c
+++ b/drivers/net/wireless/broadcom/b43/wa.c
@@ -30,33 +30,6 @@
 #include "phy_common.h"
 #include "wa.h"
 
-static void b43_wa_papd(struct b43_wldev *dev)
-{
-   u16 backup;
-
-   backup = b43_ofdmtab_read16(dev, B43_OFDMTAB_PWRDYN2, 0);
-   b43_ofdmtab_write16(dev, B43_OFDMTAB_PWRDYN2, 0, 7);
-   b43_ofdmtab_write16(dev, B43_OFDMTAB_UNKNOWN_APHY, 0, 0);
-   b43_dummy_transmission(dev, true, true);
-   b43_ofdmtab_write16(dev, B43_OFDMTAB_PWRDYN2, 0, backup);
-}
-
-static void b43_wa_auxclipthr(struct b43_wldev *dev)
-{
-   b43_phy_write(dev, B43_PHY_OFDM(0x8E), 0x3800);
-}
-
-static void b43_wa_afcdac(struct b43_wldev *dev)
-{
-   b43_phy_write(dev, 0x0035, 0x03FF);
-   b43_phy_write(dev, 0x0036, 0x0400);
-}
-
-static void b43_wa_txdc_offset(struct b43_wldev *dev)
-{
-   b43_ofdmtab_write16(dev, B43_OFDMTAB_DC, 0, 0x0051);
-}
-
 void b43_wa_initgains(struct b43_wldev 

[PATCH v2 1/2] b43: Remove unused phy_a code

2016-06-03 Thread Guenter Roeck
gcc-6 reports the following error with -Werror=unused-const-variable.

drivers/net/wireless/broadcom/b43/phy_a.c:576:40: error:
'b43_phyops_a' defined but not used

Per Michael Büsch: "All a-phy code is usused", so remove phy_a.c
completely. Move the remaining Type-G initialization code into phy_g.c.

Reported-by: Fengguang Wu  [0-day test robot]
Signed-off-by: Guenter Roeck 
---
v2: Remove phy_a.c; move left-over code into phy_g.c
Remove now unused data structure

 drivers/net/wireless/broadcom/b43/Makefile |   2 +-
 drivers/net/wireless/broadcom/b43/phy_a.c  | 595 -
 drivers/net/wireless/broadcom/b43/phy_a.h  |  22 -
 drivers/net/wireless/broadcom/b43/phy_common.h |   3 -
 drivers/net/wireless/broadcom/b43/phy_g.c  |  27 +-
 5 files changed, 22 insertions(+), 627 deletions(-)
 delete mode 100644 drivers/net/wireless/broadcom/b43/phy_a.c

diff --git a/drivers/net/wireless/broadcom/b43/Makefile 
b/drivers/net/wireless/broadcom/b43/Makefile
index ddc4df46656f..27fab958e3d5 100644
--- a/drivers/net/wireless/broadcom/b43/Makefile
+++ b/drivers/net/wireless/broadcom/b43/Makefile
@@ -1,6 +1,6 @@
 b43-y  += main.o
 b43-y  += bus.o
-b43-$(CONFIG_B43_PHY_G)+= phy_a.o phy_g.o tables.o lo.o wa.o
+b43-$(CONFIG_B43_PHY_G)+= phy_g.o tables.o lo.o wa.o
 b43-$(CONFIG_B43_PHY_N)+= tables_nphy.o
 b43-$(CONFIG_B43_PHY_N)+= radio_2055.o
 b43-$(CONFIG_B43_PHY_N)+= radio_2056.o
diff --git a/drivers/net/wireless/broadcom/b43/phy_a.c 
b/drivers/net/wireless/broadcom/b43/phy_a.c
deleted file mode 100644
index 99c036f5ecb7..
--- a/drivers/net/wireless/broadcom/b43/phy_a.c
+++ /dev/null
@@ -1,595 +0,0 @@
-/*
-
-  Broadcom B43 wireless driver
-  IEEE 802.11a PHY driver
-
-  Copyright (c) 2005 Martin Langer ,
-  Copyright (c) 2005-2007 Stefano Brivio 
-  Copyright (c) 2005-2008 Michael Buesch 
-  Copyright (c) 2005, 2006 Danny van Dyk 
-  Copyright (c) 2005, 2006 Andreas Jaggi 
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; see the file COPYING.  If not, write to
-  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
-  Boston, MA 02110-1301, USA.
-
-*/
-
-#include 
-
-#include "b43.h"
-#include "phy_a.h"
-#include "phy_common.h"
-#include "wa.h"
-#include "tables.h"
-#include "main.h"
-
-
-/* Get the freq, as it has to be written to the device. */
-static inline u16 channel2freq_a(u8 channel)
-{
-   B43_WARN_ON(channel > 200);
-
-   return (5000 + 5 * channel);
-}
-
-static inline u16 freq_r3A_value(u16 frequency)
-{
-   u16 value;
-
-   if (frequency < 5091)
-   value = 0x0040;
-   else if (frequency < 5321)
-   value = 0x;
-   else if (frequency < 5806)
-   value = 0x0080;
-   else
-   value = 0x0040;
-
-   return value;
-}
-
-#if 0
-/* This function converts a TSSI value to dBm in Q5.2 */
-static s8 b43_aphy_estimate_power_out(struct b43_wldev *dev, s8 tssi)
-{
-   struct b43_phy *phy = >phy;
-   struct b43_phy_a *aphy = phy->a;
-   s8 dbm = 0;
-   s32 tmp;
-
-   tmp = (aphy->tgt_idle_tssi - aphy->cur_idle_tssi + tssi);
-   tmp += 0x80;
-   tmp = clamp_val(tmp, 0x00, 0xFF);
-   dbm = aphy->tssi2dbm[tmp];
-   //TODO: There's a FIXME on the specs
-
-   return dbm;
-}
-#endif
-
-static void b43_radio_set_tx_iq(struct b43_wldev *dev)
-{
-   static const u8 data_high[5] = { 0x00, 0x40, 0x80, 0x90, 0xD0 };
-   static const u8 data_low[5] = { 0x00, 0x01, 0x05, 0x06, 0x0A };
-   u16 tmp = b43_radio_read16(dev, 0x001E);
-   int i, j;
-
-   for (i = 0; i < 5; i++) {
-   for (j = 0; j < 5; j++) {
-   if (tmp == (data_high[i] << 4 | data_low[j])) {
-   b43_phy_write(dev, 0x0069,
- (i - j) << 8 | 0x00C0);
-   return;
-   }
-   }
-   }
-}
-
-static void aphy_channel_switch(struct b43_wldev *dev, unsigned int channel)
-{
-   u16 freq, r8, tmp;
-
-   freq = channel2freq_a(channel);
-
-   r8 = b43_radio_read16(dev, 0x0008);
-   

[net-next:master 25/29] drivers/net/ethernet/qlogic/qed/qed_dev.c:1802:57: warning: left shift count >= width of type

2016-06-03 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 
master
head:   03c7f70beee4c5d34881e5d3dd2b6f3e848047ef
commit: a91eb52abb504a1dd3248a5d07b54e7f95d5fcf1 [25/29] qed: Revisit chain 
implementation
config: i386-allyesconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
git checkout a91eb52abb504a1dd3248a5d07b54e7f95d5fcf1
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/qlogic/qed/qed_dev.c: In function 
'qed_chain_free_next_ptr':
>> drivers/net/ethernet/qlogic/qed/qed_dev.c:1802:57: warning: left shift count 
>> >= width of type [-Wshift-count-overflow]
  p_phys_next = HILO_DMA_REGPAIR(p_next->next_phys);
^ 

vim +1802 drivers/net/ethernet/qlogic/qed/qed_dev.c

  1786  void *p_virt = p_chain->p_virt_addr, *p_virt_next = NULL;
  1787  dma_addr_t p_phys = p_chain->p_phys_addr, p_phys_next = 0;
  1788  struct qed_chain_next *p_next;
  1789  u32 size, i;
  1790  
  1791  if (!p_virt)
  1792  return;
  1793  
  1794  size = p_chain->elem_size * p_chain->usable_per_page;
  1795  
  1796  for (i = 0; i < p_chain->page_cnt; i++) {
  1797  if (!p_virt)
  1798  break;
  1799  
  1800  p_next = (struct qed_chain_next *)((u8 *)p_virt + size);
  1801  p_virt_next = p_next->next_virt;
> 1802  p_phys_next = HILO_DMA_REGPAIR(p_next->next_phys);
  1803  
  1804  dma_free_coherent(>pdev->dev,
  1805QED_CHAIN_PAGE_SIZE, p_virt, p_phys);
  1806  
  1807  p_virt = p_virt_next;
  1808  p_phys = p_phys_next;
  1809  }
  1810  }

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[net-next:master 20/29] net/sctp/output.c:185:21: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}'

2016-06-03 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 
master
head:   03c7f70beee4c5d34881e5d3dd2b6f3e848047ef
commit: 942b3235bf77e5600a05d6e85f0415bdeb8068bb [20/29] sctp: improve debug 
message to also log curr pkt and new chunk size
config: i386-allyesconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
git checkout 942b3235bf77e5600a05d6e85f0415bdeb8068bb
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   net/sctp/output.c: In function 'sctp_packet_transmit_chunk':
>> net/sctp/output.c:185:21: warning: format '%lu' expects argument of type 
>> 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' 
>> [-Wformat=]
 pr_debug("%s: packet:%p size:%lu chunk:%p size:%d\n", __func__,
^~

vim +185 net/sctp/output.c

   169  }
   170  
   171  /* This routine tries to append the chunk to the offered packet. If 
adding
   172   * the chunk causes the packet to exceed the path MTU and COOKIE_ECHO 
chunk
   173   * is not present in the packet, it transmits the input packet.
   174   * Data can be bundled with a packet containing a COOKIE_ECHO chunk as 
long
   175   * as it can fit in the packet, but any more data that does not fit in 
this
   176   * packet can be sent only after receiving the COOKIE_ACK.
   177   */
   178  sctp_xmit_t sctp_packet_transmit_chunk(struct sctp_packet *packet,
   179 struct sctp_chunk *chunk,
   180 int one_packet, gfp_t gfp)
   181  {
   182  sctp_xmit_t retval;
   183  int error = 0;
   184  
 > 185  pr_debug("%s: packet:%p size:%lu chunk:%p size:%d\n", __func__,
   186   packet, packet->size, chunk, chunk->skb ? 
chunk->skb->len : -1);
   187  
   188  switch ((retval = (sctp_packet_append_chunk(packet, chunk {
   189  case SCTP_XMIT_PMTU_FULL:
   190  if (!packet->has_cookie_echo) {
   191  error = sctp_packet_transmit(packet, gfp);
   192  if (error < 0)
   193  chunk->skb->sk->sk_err = -error;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[net-next:master 25/29] include/linux/qed/qed_chain.h:27:48: warning: left shift count >= width of type

2016-06-03 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 
master
head:   03c7f70beee4c5d34881e5d3dd2b6f3e848047ef
commit: a91eb52abb504a1dd3248a5d07b54e7f95d5fcf1 [25/29] qed: Revisit chain 
implementation
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
git checkout a91eb52abb504a1dd3248a5d07b54e7f95d5fcf1
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from drivers/net/ethernet/qlogic/qed/qed_dev.c:22:0:
   drivers/net/ethernet/qlogic/qed/qed_dev.c: In function 
'qed_chain_free_next_ptr':
>> include/linux/qed/qed_chain.h:27:48: warning: left shift count >= width of 
>> type [-Wshift-count-overflow]
#define HILO_GEN(hi, lo, type)  type)(hi)) << 32) + (lo))
   ^
>> include/linux/qed/qed_chain.h:28:33: note: in expansion of macro 'HILO_GEN'
#define HILO_DMA(hi, lo)HILO_GEN(hi, lo, dma_addr_t)
^~~~
>> include/linux/qed/qed_chain.h:30:42: note: in expansion of macro 'HILO_DMA'
#define HILO_DMA_REGPAIR(regpair)   (HILO_DMA(regpair.hi, regpair.lo))
 ^~~~
>> drivers/net/ethernet/qlogic/qed/qed_dev.c:1802:17: note: in expansion of 
>> macro 'HILO_DMA_REGPAIR'
  p_phys_next = HILO_DMA_REGPAIR(p_next->next_phys);
^~~~

vim +27 include/linux/qed/qed_chain.h

fe56b9e6 Yuval Mintz 2015-10-26  21  #define DMA_HI_LE(x)
cpu_to_le32(upper_32_bits(x))
94494598 Yuval Mintz 2016-02-21  22  #define DMA_REGPAIR_LE(x, val)  do { \
94494598 Yuval Mintz 2016-02-21  23 (x).hi 
= DMA_HI_LE((val)); \
94494598 Yuval Mintz 2016-02-21  24 (x).lo 
= DMA_LO_LE((val)); \
94494598 Yuval Mintz 2016-02-21  25 } while (0)
fe56b9e6 Yuval Mintz 2015-10-26  26  
fe56b9e6 Yuval Mintz 2015-10-26 @27  #define HILO_GEN(hi, lo, type)  
type)(hi)) << 32) + (lo))
fe56b9e6 Yuval Mintz 2015-10-26 @28  #define HILO_DMA(hi, lo)
HILO_GEN(hi, lo, dma_addr_t)
fe56b9e6 Yuval Mintz 2015-10-26  29  #define HILO_64(hi, lo) 
HILO_GEN((le32_to_cpu(hi)), (le32_to_cpu(lo)), u64)
fe56b9e6 Yuval Mintz 2015-10-26 @30  #define HILO_DMA_REGPAIR(regpair)   
(HILO_DMA(regpair.hi, regpair.lo))
fe56b9e6 Yuval Mintz 2015-10-26  31  #define HILO_64_REGPAIR(regpair)
(HILO_64(regpair.hi, regpair.lo))
fe56b9e6 Yuval Mintz 2015-10-26  32  
fe56b9e6 Yuval Mintz 2015-10-26  33  enum qed_chain_mode {

:: The code at line 27 was first introduced by commit
:: fe56b9e6a8d957d6a20729d626027f800c17a2da qed: Add module with basic 
common support

:: TO: Yuval Mintz 
:: CC: David S. Miller 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH 2/3] staging: r8712u: Fix leak of skb

2016-06-03 Thread Larry Finger
There are two types of messages queued for RX. The major type, which does
I/O on the device, was being handled properly. The skbs that communicated
with the firmware were being leaked.

While rewriting the code that sets up the skb, it was possible to remove
the private variable indicating that the old skb could be reused.

Signed-off-by: Larry Finger 
---
 drivers/staging/rtl8712/recv_linux.c|  1 -
 drivers/staging/rtl8712/rtl8712_recv.h  |  1 -
 drivers/staging/rtl8712/usb_ops_linux.c | 24 
 3 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/rtl8712/recv_linux.c 
b/drivers/staging/rtl8712/recv_linux.c
index 735a0ea..576c15d 100644
--- a/drivers/staging/rtl8712/recv_linux.c
+++ b/drivers/staging/rtl8712/recv_linux.c
@@ -60,7 +60,6 @@ int r8712_os_recvbuf_resource_alloc(struct _adapter *padapter,
if (!precvbuf->purb)
res = _FAIL;
precvbuf->pskb = NULL;
-   precvbuf->reuse = false;
precvbuf->pallocated_buf = NULL;
precvbuf->pbuf = NULL;
precvbuf->pdata = NULL;
diff --git a/drivers/staging/rtl8712/rtl8712_recv.h 
b/drivers/staging/rtl8712/rtl8712_recv.h
index fd9e3fc..925ec74 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.h
+++ b/drivers/staging/rtl8712/rtl8712_recv.h
@@ -103,7 +103,6 @@ struct recv_buf {
struct _adapter  *adapter;
struct urb *purb;
_pkt *pskb;
-   u8 reuse;
u8  irp_pending;
u32  transfer_len;
uint  len;
diff --git a/drivers/staging/rtl8712/usb_ops_linux.c 
b/drivers/staging/rtl8712/usb_ops_linux.c
index a79c35e..9a54c3b 100644
--- a/drivers/staging/rtl8712/usb_ops_linux.c
+++ b/drivers/staging/rtl8712/usb_ops_linux.c
@@ -202,26 +202,23 @@ static void r8712_usb_read_port_complete(struct urb *purb)
if (purb->status == 0) { /* SUCCESS */
if ((purb->actual_length > (MAX_RECVBUF_SZ)) ||
(purb->actual_length < RXDESC_SIZE)) {
-   precvbuf->reuse = true;
r8712_read_port(padapter, precvpriv->ff_hwaddr, 0,
  (unsigned char *)precvbuf);
} else {
+   _pkt *pskb = precvbuf->pskb;
+
precvbuf->transfer_len = purb->actual_length;
pbuf = (uint *)precvbuf->pbuf;
isevt = le32_to_cpu(*(pbuf + 1)) & 0x1ff;
if ((isevt & 0x1ff) == 0x1ff) {
r8712_rxcmd_event_hdl(padapter, pbuf);
-   precvbuf->reuse = true;
+   skb_queue_tail(>rx_skb_queue, pskb);
r8712_read_port(padapter, precvpriv->ff_hwaddr,
0, (unsigned char *)precvbuf);
} else {
-   _pkt *pskb = precvbuf->pskb;
-
skb_put(pskb, purb->actual_length);
skb_queue_tail(>rx_skb_queue, pskb);
tasklet_hi_schedule(>recv_tasklet);
-   precvbuf->pskb = NULL;
-   precvbuf->reuse = false;
r8712_read_port(padapter, precvpriv->ff_hwaddr,
0, (unsigned char *)precvbuf);
}
@@ -241,7 +238,6 @@ static void r8712_usb_read_port_complete(struct urb *purb)
}
/* Fall through. */
case -EPROTO:
-   precvbuf->reuse = true;
r8712_read_port(padapter, precvpriv->ff_hwaddr, 0,
  (unsigned char *)precvbuf);
break;
@@ -272,14 +268,11 @@ u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 
addr, u32 cnt, u8 *rmem)
if (adapter->bDriverStopped || adapter->bSurpriseRemoved ||
adapter->pwrctrlpriv.pnp_bstop_trx || !precvbuf)
return _FAIL;
-   if (precvbuf->reuse || !precvbuf->pskb) {
-   precvbuf->pskb = skb_dequeue(>free_recv_skb_queue);
-   if (precvbuf->pskb != NULL)
-   precvbuf->reuse = true;
-   }
r8712_init_recvbuf(adapter, precvbuf);
-   /* re-assign for linux based on skb */
-   if (!precvbuf->reuse || !precvbuf->pskb) {
+   /* Try to use skb from the free queue */
+   precvbuf->pskb = skb_dequeue(>free_recv_skb_queue);
+
+   if (!precvbuf->pskb) {
precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev,
 MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
if (!precvbuf->pskb)
@@ -293,13 +286,12 @@ u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 
addr, u32 cnt, u8 *rmem)
precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
   

[PATCH 3/3] staging: r8712u: Handle some false positives from kmemleak

2016-06-03 Thread Larry Finger
When this driver preallocates some URBs, kmemleak is unable to find that
allocated memory when it scans. When the driver is unloaded, that memory
is reclaimed, therefore, the report is a false positive.

Signed-off-by: Larry Finger 
---
 drivers/staging/rtl8712/xmit_linux.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtl8712/xmit_linux.c 
b/drivers/staging/rtl8712/xmit_linux.c
index 695f9b9..7f52953 100644
--- a/drivers/staging/rtl8712/xmit_linux.c
+++ b/drivers/staging/rtl8712/xmit_linux.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "osdep_service.h"
 #include "drv_types.h"
@@ -132,6 +133,7 @@ int r8712_xmit_resource_alloc(struct _adapter *padapter,
netdev_err(padapter->pnetdev, "pxmitbuf->pxmit_urb[i] 
== NULL\n");
return _FAIL;
}
+   kmemleak_not_leak(pxmitbuf->pxmit_urb[i]);
}
return _SUCCESS;
 }
-- 
2.1.4



[PATCH 0/3] Some fixes got r8712u

2016-06-03 Thread Larry Finger
While testing the patches that removed the semaphores from this driver,
kmemleak reported some leaked skbs. There were also some false positives.
I also found code that dereferenced a pointer before it was checked. All
of these conditions are fixed.

Signed-off-by: Larry Finger 


Larry Finger (3):
  staging: r8712u: Check pointer before use
  staging: r8712u: Fix leak of skb
  staging: r8712u: Handle some false positives from kmemleak

 drivers/staging/rtl8712/recv_linux.c|  1 -
 drivers/staging/rtl8712/rtl8712_recv.h  |  1 -
 drivers/staging/rtl8712/usb_ops_linux.c | 86 ++---
 drivers/staging/rtl8712/xmit_linux.c|  2 +
 4 files changed, 39 insertions(+), 51 deletions(-)

-- 
2.1.4



[PATCH 1/3] staging: r8712u: Check pointer before use

2016-06-03 Thread Larry Finger
Routine r8712_usb_read_port() dereferences "precvbuf" before testing it
for NULL.

Signed-off-by: Larry Finger 
---
 drivers/staging/rtl8712/usb_ops_linux.c | 72 -
 1 file changed, 34 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/rtl8712/usb_ops_linux.c 
b/drivers/staging/rtl8712/usb_ops_linux.c
index 6f12345..a79c35e 100644
--- a/drivers/staging/rtl8712/usb_ops_linux.c
+++ b/drivers/staging/rtl8712/usb_ops_linux.c
@@ -270,51 +270,47 @@ u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 
addr, u32 cnt, u8 *rmem)
struct usb_device *pusbd = pdvobj->pusbdev;
 
if (adapter->bDriverStopped || adapter->bSurpriseRemoved ||
-   adapter->pwrctrlpriv.pnp_bstop_trx)
+   adapter->pwrctrlpriv.pnp_bstop_trx || !precvbuf)
return _FAIL;
if (precvbuf->reuse || !precvbuf->pskb) {
precvbuf->pskb = skb_dequeue(>free_recv_skb_queue);
if (precvbuf->pskb != NULL)
precvbuf->reuse = true;
}
-   if (precvbuf != NULL) {
-   r8712_init_recvbuf(adapter, precvbuf);
-   /* re-assign for linux based on skb */
-   if (!precvbuf->reuse || !precvbuf->pskb) {
-   precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev,
-MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
-   if (!precvbuf->pskb)
-   return _FAIL;
-   tmpaddr = (addr_t)precvbuf->pskb->data;
-   alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1);
-   skb_reserve(precvbuf->pskb,
-   (RECVBUFF_ALIGN_SZ - alignment));
-   precvbuf->phead = precvbuf->pskb->head;
-   precvbuf->pdata = precvbuf->pskb->data;
-   precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
-   precvbuf->pend = skb_end_pointer(precvbuf->pskb);
-   precvbuf->pbuf = precvbuf->pskb->data;
-   } else { /* reuse skb */
-   precvbuf->phead = precvbuf->pskb->head;
-   precvbuf->pdata = precvbuf->pskb->data;
-   precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
-   precvbuf->pend = skb_end_pointer(precvbuf->pskb);
-   precvbuf->pbuf = precvbuf->pskb->data;
-   precvbuf->reuse = false;
-   }
-   purb = precvbuf->purb;
-   /* translate DMA FIFO addr to pipehandle */
-   pipe = ffaddr2pipehdl(pdvobj, addr);
-   usb_fill_bulk_urb(purb, pusbd, pipe,
- precvbuf->pbuf, MAX_RECVBUF_SZ,
- r8712_usb_read_port_complete,
- precvbuf);
-   err = usb_submit_urb(purb, GFP_ATOMIC);
-   if ((err) && (err != (-EPERM)))
-   ret = _FAIL;
-   } else {
-   ret = _FAIL;
+   r8712_init_recvbuf(adapter, precvbuf);
+   /* re-assign for linux based on skb */
+   if (!precvbuf->reuse || !precvbuf->pskb) {
+   precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev,
+MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
+   if (!precvbuf->pskb)
+   return _FAIL;
+   tmpaddr = (addr_t)precvbuf->pskb->data;
+   alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1);
+   skb_reserve(precvbuf->pskb,
+   (RECVBUFF_ALIGN_SZ - alignment));
+   precvbuf->phead = precvbuf->pskb->head;
+   precvbuf->pdata = precvbuf->pskb->data;
+   precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
+   precvbuf->pend = skb_end_pointer(precvbuf->pskb);
+   precvbuf->pbuf = precvbuf->pskb->data;
+   } else { /* reuse skb */
+   precvbuf->phead = precvbuf->pskb->head;
+   precvbuf->pdata = precvbuf->pskb->data;
+   precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
+   precvbuf->pend = skb_end_pointer(precvbuf->pskb);
+   precvbuf->pbuf = precvbuf->pskb->data;
+   precvbuf->reuse = false;
}
+   purb = precvbuf->purb;
+   /* translate DMA FIFO addr to pipehandle */
+   pipe = ffaddr2pipehdl(pdvobj, addr);
+   usb_fill_bulk_urb(purb, pusbd, pipe,
+ precvbuf->pbuf, MAX_RECVBUF_SZ,
+ r8712_usb_read_port_complete,
+ precvbuf);
+   err = usb_submit_urb(purb, GFP_ATOMIC);
+   if ((err) && (err != (-EPERM)))
+   ret = _FAIL;
return ret;
 }
 
-- 
2.1.4



[net-next:master 17/24] DockBook: net/core/skbuff.c:4404: warning: No description found for parameter 'mtu'

2016-06-03 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 
master
head:   330348d94223346f855357fab2517f6c903001c7
commit: ae7ef81ef000adeee7a87585b9135ff8a8064acc [17/24] skbuff: introduce 
skb_gso_validate_mtu
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   include/linux/skbuff.h:928: warning: No description found for parameter 'sk'
   include/net/sock.h:449: warning: No description found for parameter 
'sk_padding'
   include/net/sock.h:449: warning: No description found for parameter 'sk_rcu'
>> net/core/skbuff.c:4404: warning: No description found for parameter 'mtu'
   net/core/gen_stats.c:65: warning: No description found for parameter 
'padattr'
   net/core/gen_stats.c:100: warning: No description found for parameter 
'padattr'

vim +/mtu +4404 net/core/skbuff.c

  4388   * payload, i.e. the size of the L4 (UDP) header is already
  4389   * accounted for.
  4390   */
  4391  return thlen + shinfo->gso_size;
  4392  }
  4393  EXPORT_SYMBOL_GPL(skb_gso_transport_seglen);
  4394  
  4395  /**
  4396   * skb_gso_validate_mtu - Return in case such skb fits a given MTU
  4397   *
  4398   * @skb: GSO skb
  4399   *
  4400   * skb_gso_validate_mtu validates if a given skb will fit a wanted MTU
  4401   * once split.
  4402   */
  4403  bool skb_gso_validate_mtu(const struct sk_buff *skb, unsigned int mtu)
> 4404  {
  4405  const struct skb_shared_info *shinfo = skb_shinfo(skb);
  4406  const struct sk_buff *iter;
  4407  unsigned int hlen;
  4408  
  4409  hlen = skb_gso_network_seglen(skb);
  4410  
  4411  if (shinfo->gso_size != GSO_BY_FRAGS)
  4412  return hlen <= mtu;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH] b43: Remove unused phy_a code

2016-06-03 Thread Guenter Roeck

On 06/03/2016 02:35 PM, Michael Büsch wrote:

On Fri,  3 Jun 2016 14:32:46 -0700
Guenter Roeck  wrote:


gcc-6 reports the following error with -Werror=unused-const-variable.

drivers/net/wireless/broadcom/b43/phy_a.c:576:40: error:
'b43_phyops_a' defined but not used

Turns out a lot of code in this file is unused, so let's remove it.



All a-phy code is usused.
So you can basically remove the whole file and any other A-PHY code.


I love removing code. I'll resend with more code removed.

Guenter



[net-next:master 20/24] net/sctp/output.c:37:21: note: in expansion of macro 'KBUILD_MODNAME'

2016-06-03 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 
master
head:   330348d94223346f855357fab2517f6c903001c7
commit: 942b3235bf77e5600a05d6e85f0415bdeb8068bb [20/24] sctp: improve debug 
message to also log curr pkt and new chunk size
config: sh-allyesconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 942b3235bf77e5600a05d6e85f0415bdeb8068bb
# save the attached .config to linux build tree
make.cross ARCH=sh 

All warnings (new ones prefixed by >>):

   net/sctp/output.c: In function 'sctp_packet_transmit_chunk':
   :0:16: warning: format '%lu' expects argument of type 'long 
unsigned int', but argument 5 has type 'size_t {aka unsigned int}' [-Wformat=]
>> net/sctp/output.c:37:21: note: in expansion of macro 'KBUILD_MODNAME'
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^
   include/linux/dynamic_debug.h:78:35: note: in expansion of macro 'pr_fmt'
  __dynamic_pr_debug(, pr_fmt(fmt), \
  ^
   include/linux/printk.h:295:2: note: in expansion of macro 'dynamic_pr_debug'
 dynamic_pr_debug(fmt, ##__VA_ARGS__)
 ^
   net/sctp/output.c:185:2: note: in expansion of macro 'pr_debug'
 pr_debug("%s: packet:%p size:%lu chunk:%p size:%d\n", __func__,
 ^

vim +/KBUILD_MODNAME +37 net/sctp/output.c

^1da177e Linus Torvalds  2005-04-16  21   *
^1da177e Linus Torvalds  2005-04-16  22   * You should have received a copy of 
the GNU General Public License
4b2f13a2 Jeff Kirsher2013-12-06  23   * along with GNU CC; see the file 
COPYING.  If not, see
4b2f13a2 Jeff Kirsher2013-12-06  24   * .
^1da177e Linus Torvalds  2005-04-16  25   *
^1da177e Linus Torvalds  2005-04-16  26   * Please send any bug reports or 
fixes you make to the
^1da177e Linus Torvalds  2005-04-16  27   * email address(es):
91705c61 Daniel Borkmann 2013-07-23  28   *lksctp developers 

^1da177e Linus Torvalds  2005-04-16  29   *
^1da177e Linus Torvalds  2005-04-16  30   * Written or modified by:
^1da177e Linus Torvalds  2005-04-16  31   *La Monte H.P. Yarroll 

^1da177e Linus Torvalds  2005-04-16  32   *Karl Knutson  

^1da177e Linus Torvalds  2005-04-16  33   *Jon Grimm 

^1da177e Linus Torvalds  2005-04-16  34   *Sridhar Samudrala 

^1da177e Linus Torvalds  2005-04-16  35   */
^1da177e Linus Torvalds  2005-04-16  36  
145ce502 Joe Perches 2010-08-24 @37  #define pr_fmt(fmt) KBUILD_MODNAME ": 
" fmt
145ce502 Joe Perches 2010-08-24  38  
^1da177e Linus Torvalds  2005-04-16  39  #include 
^1da177e Linus Torvalds  2005-04-16  40  #include 
^1da177e Linus Torvalds  2005-04-16  41  #include 
^1da177e Linus Torvalds  2005-04-16  42  #include 
^1da177e Linus Torvalds  2005-04-16  43  #include 
^1da177e Linus Torvalds  2005-04-16  44  #include 
^1da177e Linus Torvalds  2005-04-16  45  #include 

:: The code at line 37 was first introduced by commit
:: 145ce502e44b57c074c72cfdc87e19026999 net/sctp: Use pr_fmt and 
pr_

:: TO: Joe Perches 
:: CC: David S. Miller 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[net-next:master 20/24] net/sctp/output.c:185:2: note: in expansion of macro 'pr_debug'

2016-06-03 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 
master
head:   330348d94223346f855357fab2517f6c903001c7
commit: 942b3235bf77e5600a05d6e85f0415bdeb8068bb [20/24] sctp: improve debug 
message to also log curr pkt and new chunk size
config: m68k-allyesconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 942b3235bf77e5600a05d6e85f0415bdeb8068bb
# save the attached .config to linux build tree
make.cross ARCH=m68k 

All warnings (new ones prefixed by >>):

   In file included from include/linux/printk.h:289:0,
from include/linux/kernel.h:13,
from net/sctp/output.c:40:
   net/sctp/output.c: In function 'sctp_packet_transmit_chunk':
>> include/linux/dynamic_debug.h:64:16: warning: format '%lu' expects argument 
>> of type 'long unsigned int', but argument 5 has type 'size_t' [-Wformat=]
 static struct _ddebug  __aligned(8)   \
   ^
   include/linux/dynamic_debug.h:76:2: note: in expansion of macro 
'DEFINE_DYNAMIC_DEBUG_METADATA'
 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);  \
 ^
   include/linux/printk.h:295:2: note: in expansion of macro 'dynamic_pr_debug'
 dynamic_pr_debug(fmt, ##__VA_ARGS__)
 ^
>> net/sctp/output.c:185:2: note: in expansion of macro 'pr_debug'
 pr_debug("%s: packet:%p size:%lu chunk:%p size:%d\n", __func__,
 ^

vim +/pr_debug +185 net/sctp/output.c

   169  }
   170  
   171  /* This routine tries to append the chunk to the offered packet. If 
adding
   172   * the chunk causes the packet to exceed the path MTU and COOKIE_ECHO 
chunk
   173   * is not present in the packet, it transmits the input packet.
   174   * Data can be bundled with a packet containing a COOKIE_ECHO chunk as 
long
   175   * as it can fit in the packet, but any more data that does not fit in 
this
   176   * packet can be sent only after receiving the COOKIE_ACK.
   177   */
   178  sctp_xmit_t sctp_packet_transmit_chunk(struct sctp_packet *packet,
   179 struct sctp_chunk *chunk,
   180 int one_packet, gfp_t gfp)
   181  {
   182  sctp_xmit_t retval;
   183  int error = 0;
   184  
 > 185  pr_debug("%s: packet:%p size:%lu chunk:%p size:%d\n", __func__,
   186   packet, packet->size, chunk, chunk->skb ? 
chunk->skb->len : -1);
   187  
   188  switch ((retval = (sctp_packet_append_chunk(packet, chunk {
   189  case SCTP_XMIT_PMTU_FULL:
   190  if (!packet->has_cookie_echo) {
   191  error = sctp_packet_transmit(packet, gfp);
   192  if (error < 0)
   193  chunk->skb->sk->sk_err = -error;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH net-next 0/4] qed: RocE & iSCSI infrastructure

2016-06-03 Thread David Miller
From: Yuval Mintz 
Date: Fri, 3 Jun 2016 14:35:31 +0300

> We plan on sending 2 new protocol drivers in the imminent future -
> both our RoCE [qedr] and iSCSI [qedi] drivers. As both submissions
> would be rather massive and in order to avoid collisions between them,
> the common infrastructure on the qed side was prepared as an independent
> patch-series to be sent ahead of those 2 submissions.
> 
> This patch series introduces in QED 2 new 'ids' - one for iscsi and
> one for roce. It then goes and adds logic required for configuring
> said protocols in HW. Notice it *doesn't* actually add any client using
> said ids, but rather only the infrastructure to allow their later usage.
> 
> What this patch doesn't contain is the slowpath protocol-configuration
> toward the firmware. I.e., it contains register-setting logic, memory
> allocations, etc., but not actual flow-related configuration specific
> to the protocl. Those would be sent as part of the protocol driver
> submissions.

Series applied to net-next, thanks.


Re: [PATCH net-next 0/9] net: dsa: misc improvements

2016-06-03 Thread Florian Fainelli
On 06/03/2016 05:05 PM, Florian Fainelli wrote:
> Hi all,
> 
> This patch series builds on top of Andrew's "New DSA bind, switches as 
> devices"
> patch set and does the following:
> 
> - add support for the old DSA binding with the new dsa_register_switch() API
>   which is needed by some platforms where the Device Tree is pretty much 
> frozen
> 
> - add a few helper functions/goodies for net/dsa/dsa2.c to be as close as 
> possible
>   from net/dsa/dsa.c in terms of what drivers can expect, in particular the 
> slave
>   MDIO bus and the enabled_port_mask and phy_mii_mask
> 
> - fix the CPU port ethtools ops to work in a multiple tree setup since we can
>   no longer assume a single tree is supported
> 
> - finally conver the bcm_sf2 driver to be a true platform device driver and
>   slightly rework its internal vs. external MDIO bus indirect read/writes to
>   be cleaner

David, I cleaned up my mess in patchwork to leave just the relevant
patches for you to review and apply, sorry about that, it's Friday.
-- 
Florian


[net-next:master 20/24] net/sctp/output.c:185:2: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'size_t'

2016-06-03 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 
master
head:   330348d94223346f855357fab2517f6c903001c7
commit: 942b3235bf77e5600a05d6e85f0415bdeb8068bb [20/24] sctp: improve debug 
message to also log curr pkt and new chunk size
config: cris-allyesconfig (attached as .config)
compiler: cris-linux-gcc (GCC) 4.6.3
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 942b3235bf77e5600a05d6e85f0415bdeb8068bb
# save the attached .config to linux build tree
make.cross ARCH=cris 

All warnings (new ones prefixed by >>):

   net/sctp/output.c: In function 'sctp_packet_transmit_chunk':
>> net/sctp/output.c:185:2: warning: format '%lu' expects argument of type 
>> 'long unsigned int', but argument 5 has type 'size_t' [-Wformat]

vim +185 net/sctp/output.c

   169  }
   170  
   171  /* This routine tries to append the chunk to the offered packet. If 
adding
   172   * the chunk causes the packet to exceed the path MTU and COOKIE_ECHO 
chunk
   173   * is not present in the packet, it transmits the input packet.
   174   * Data can be bundled with a packet containing a COOKIE_ECHO chunk as 
long
   175   * as it can fit in the packet, but any more data that does not fit in 
this
   176   * packet can be sent only after receiving the COOKIE_ACK.
   177   */
   178  sctp_xmit_t sctp_packet_transmit_chunk(struct sctp_packet *packet,
   179 struct sctp_chunk *chunk,
   180 int one_packet, gfp_t gfp)
   181  {
   182  sctp_xmit_t retval;
   183  int error = 0;
   184  
 > 185  pr_debug("%s: packet:%p size:%lu chunk:%p size:%d\n", __func__,
   186   packet, packet->size, chunk, chunk->skb ? 
chunk->skb->len : -1);
   187  
   188  switch ((retval = (sctp_packet_append_chunk(packet, chunk {
   189  case SCTP_XMIT_PMTU_FULL:
   190  if (!packet->has_cookie_echo) {
   191  error = sctp_packet_transmit(packet, gfp);
   192  if (error < 0)
   193  chunk->skb->sk->sk_err = -error;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH 1/5] ethernet: add sun8i-emac driver

2016-06-03 Thread David Miller
From: LABBE Corentin 
Date: Fri,  3 Jun 2016 11:56:26 +0200

> +static int nbdesc_tx = 256;
> +module_param(nbdesc_tx, int, S_IRUGO | S_IWUSR);
> +MODULE_PARM_DESC(nbdesc_tx, "Number of descriptors in the TX list");
> +static int nbdesc_rx = 128;
> +module_param(nbdesc_rx, int, S_IRUGO | S_IWUSR);
> +MODULE_PARM_DESC(nbdesc_rx, "Number of descriptors in the RX list");

Module parameters are not appropriate.

Please use the proper ethtool configuration facilities to control
the size of the RX and TX queues.

Thanks.


[PATCH net-next 5/9] net: dsa: Export suspend/resume functions

2016-06-03 Thread Florian Fainelli
In preparation for allowing switch drivers to implement system-wide
suspend/resume functions, export dsa_switch_suspend and
dsa_switch_resume() such that these are callable from the appropriate
driver specific suspend/resume functions.

Signed-off-by: Florian Fainelli 
---
 include/net/dsa.h | 14 ++
 net/dsa/dsa.c |  6 --
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index d6ed5dee73e5..c5abaeda84f3 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -382,4 +382,18 @@ static inline bool dsa_uses_tagged_protocol(struct 
dsa_switch_tree *dst)
 
 void dsa_unregister_switch(struct dsa_switch *ds);
 int dsa_register_switch(struct dsa_switch *ds, struct device_node *np);
+#ifdef CONFIG_PM_SLEEP
+int dsa_switch_suspend(struct dsa_switch *ds);
+int dsa_switch_resume(struct dsa_switch *ds);
+#else
+static inline int dsa_switch_suspend(struct dsa_switch *ds)
+{
+   return 0;
+}
+static inline int dsa_switch_resume(struct dsa_switch *ds)
+{
+   return 0;
+}
+#endif /* CONFIG_PM_SLEEP */
+
 #endif
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index d8cb2acd4f0a..ebc29a1bee08 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -500,7 +500,7 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
 }
 
 #ifdef CONFIG_PM_SLEEP
-static int dsa_switch_suspend(struct dsa_switch *ds)
+int dsa_switch_suspend(struct dsa_switch *ds)
 {
int i, ret = 0;
 
@@ -519,8 +519,9 @@ static int dsa_switch_suspend(struct dsa_switch *ds)
 
return ret;
 }
+EXPORT_SYMBOL_GPL(dsa_switch_suspend);
 
-static int dsa_switch_resume(struct dsa_switch *ds)
+int dsa_switch_resume(struct dsa_switch *ds)
 {
int i, ret = 0;
 
@@ -542,6 +543,7 @@ static int dsa_switch_resume(struct dsa_switch *ds)
 
return 0;
 }
+EXPORT_SYMBOL_GPL(dsa_switch_resume);
 #endif
 
 /* platform driver init and cleanup */
-- 
2.7.4



[PATCH net-next 7/7] net: dsa: bcm_sf2: Register our slave MDIO bus

2016-06-03 Thread Florian Fainelli
Register a slave MDIO bus which allows us to divert problematic
read/writes towards conflicting pseudo-PHY address (30). Do no longer
rely on DSA's slave_mii_bus, but instead provide our own implementation
which offers more flexibility as to what to do, and when to register it.

Signed-off-by: Florian Fainelli 
---
 drivers/net/dsa/bcm_sf2.c | 141 --
 drivers/net/dsa/bcm_sf2.h |   6 ++
 2 files changed, 106 insertions(+), 41 deletions(-)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 8dac74a6b5df..502ca65435bf 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -948,23 +949,6 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
bcm_sf2_port_disable(ds, port, NULL);
}
 
-   /* Include the pseudo-PHY address and the broadcast PHY address to
-* divert reads towards our workaround. This is only required for
-* 7445D0, since 7445E0 disconnects the internal switch pseudo-PHY such
-* that we can use the regular SWITCH_MDIO master controller instead.
-*
-* By default, DSA initializes ds->phys_mii_mask to
-* ds->enabled_port_mask to have a 1:1 mapping between Port address
-* and PHY address in order to utilize the slave_mii_bus instance to
-* read from Port PHYs. This is not what we want here, so we
-* initialize phys_mii_mask 0 to always utilize the "master" MDIO
-* bus backed by the "mdio-unimac" driver.
-*/
-   if (of_machine_is_compatible("brcm,bcm7445d0"))
-   ds->phys_mii_mask |= ((1 << BRCM_PSEUDO_PHY_ADDR) | (1 << 0));
-   else
-   ds->phys_mii_mask = 0;
-
return 0;
 }
 
@@ -985,10 +969,9 @@ static u32 bcm_sf2_sw_get_phy_flags(struct dsa_switch *ds, 
int port)
return priv->hw_params.gphy_rev;
 }
 
-static int bcm_sf2_sw_indir_rw(struct dsa_switch *ds, int op, int addr,
+static int bcm_sf2_sw_indir_rw(struct bcm_sf2_priv *priv, int op, int addr,
   int regnum, u16 val)
 {
-   struct bcm_sf2_priv *priv = ds_to_priv(ds);
int ret = 0;
u32 reg;
 
@@ -1017,32 +1000,31 @@ static int bcm_sf2_sw_indir_rw(struct dsa_switch *ds, 
int op, int addr,
return ret & 0x;
 }
 
-static int bcm_sf2_sw_phy_read(struct dsa_switch *ds, int addr, int regnum)
+static int bcm_sf2_sw_phy_read(struct mii_bus *bus, int addr, int regnum)
 {
-   /* Intercept reads from the MDIO broadcast address or Broadcom
-* pseudo-PHY address
+   struct bcm_sf2_priv *priv = bus->priv;
+
+   /* Intercept reads from Broadcom pseudo-PHY address, else, send
+* them to our master MDIO bus controller
 */
-   switch (addr) {
-   case 0:
-   case BRCM_PSEUDO_PHY_ADDR:
-   return bcm_sf2_sw_indir_rw(ds, 1, addr, regnum, 0);
-   default:
-   return 0x;
-   }
+   if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr))
+   return bcm_sf2_sw_indir_rw(priv, 1, addr, regnum, 0);
+   else
+   return mdiobus_read(priv->master_mii_bus, addr, regnum);
 }
 
-static int bcm_sf2_sw_phy_write(struct dsa_switch *ds, int addr, int regnum,
+static int bcm_sf2_sw_phy_write(struct mii_bus *bus, int addr, int regnum,
u16 val)
 {
-   /* Intercept writes to the MDIO broadcast address or Broadcom
-* pseudo-PHY address
+   struct bcm_sf2_priv *priv = bus->priv;
+
+   /* Intercept writes to the Broadcom pseudo-PHY address, else,
+* send them to our master MDIO bus controller
 */
-   switch (addr) {
-   case 0:
-   case BRCM_PSEUDO_PHY_ADDR:
-   bcm_sf2_sw_indir_rw(ds, 0, addr, regnum, val);
-   break;
-   }
+   if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr))
+   bcm_sf2_sw_indir_rw(priv, 0, addr, regnum, val);
+   else
+   mdiobus_write(priv->master_mii_bus, addr, regnum, val);
 
return 0;
 }
@@ -1283,8 +1265,6 @@ static struct dsa_switch_driver bcm_sf2_switch_ops = {
.setup  = bcm_sf2_sw_setup,
.set_addr   = bcm_sf2_sw_set_addr,
.get_phy_flags  = bcm_sf2_sw_get_phy_flags,
-   .phy_read   = bcm_sf2_sw_phy_read,
-   .phy_write  = bcm_sf2_sw_phy_write,
.get_strings= bcm_sf2_sw_get_strings,
.get_ethtool_stats  = bcm_sf2_sw_get_ethtool_stats,
.get_sset_count = bcm_sf2_sw_get_sset_count,
@@ -1307,6 +1287,75 @@ static struct dsa_switch_driver bcm_sf2_switch_ops = {
.port_fdb_dump  = bcm_sf2_sw_fdb_dump,
 };
 
+static int bcm_sf2_mdio_register(struct dsa_switch *ds)
+{
+   struct bcm_sf2_priv *priv = 

[PATCH net-next 4/9] net: dsa: Initialize ds->enabled_port_mask and ds->phys_mii_mask

2016-06-03 Thread Florian Fainelli
Some drivers heavily rely on these two bitmasks to contain the correct
values for them to successfully probe and initialize at drv->setup()
time, calculate correct values to put in both masks.

To avoid multiple ports lookup, we also try to set dst->cpu_port during
dsa_parse_ports_dn(), which is mostly useful for the case where we probe
using the legacy binding which has properties/nodes in different places
and does not use dsa_dst_parse().

Signed-off-by: Florian Fainelli 
---
 net/dsa/dsa2.c | 59 ++
 1 file changed, 47 insertions(+), 12 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 23273fd984a8..e8386157de30 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -281,6 +281,7 @@ static void dsa_user_port_unapply(struct device_node *port, 
u32 index,
if (ds->ports[index].netdev) {
dsa_slave_destroy(ds->ports[index].netdev);
ds->ports[index].netdev = NULL;
+   ds->enabled_port_mask &= ~(1 << index);
}
 }
 
@@ -290,6 +291,13 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, 
struct dsa_switch *ds)
u32 index;
int err;
 
+   /* Initialize ds->phys_mii_mask before registering the slave MDIO bus
+* driver and before drv->setup() has run, since the switch drivers and
+* the slave MDIO bus driver rely on these values for probing PHY
+* devices or not
+*/
+   ds->phys_mii_mask = ds->enabled_port_mask;
+
err = ds->drv->setup(ds);
if (err < 0)
return err;
@@ -302,6 +310,18 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, 
struct dsa_switch *ds)
if (err < 0)
return err;
 
+   if (!ds->slave_mii_bus && ds->drv->phy_read) {
+   ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
+   if (!ds->slave_mii_bus)
+   return err;
+
+   dsa_slave_mii_bus_init(ds);
+
+   err = mdiobus_register(ds->slave_mii_bus);
+   if (err < 0)
+   return err;
+   }
+
for (index = 0; index < DSA_MAX_PORTS; index++) {
port = ds->ports[index].dn;
if (!port)
@@ -421,7 +441,11 @@ static int _dsa_cpu_parse(struct dsa_switch_tree *dst,
 
if (dst->cpu_switch == -1) {
dst->cpu_switch = ds->index;
-   dst->cpu_port = index;
+   /* Only assign dst->cpu_port if not done already by
+* dsa_parse_ports_dn
+*/
+   if (!dst->cpu_port)
+   dst->cpu_port = index;
}
 
dst->tag_ops = dsa_resolve_tag_protocol(ds->drv->tag_protocol);
@@ -517,6 +541,15 @@ static int dsa_parse_ports_dn(struct device_node *ports, 
struct dsa_switch *ds)
return -EINVAL;
 
ds->ports[reg].dn = port;
+
+   if (dsa_port_is_cpu(port))
+   ds->dst->cpu_port = reg;
+   else
+   /* Initialize enabled_port_mask now for drv->setup()
+* to have access to a correct value, just like what
+* net/dsa/dsa.c::dsa_switch_setup_one does.
+*/
+   ds->enabled_port_mask |= 1 << reg;
}
 
return 0;
@@ -585,10 +618,6 @@ static int _dsa_register_switch_legacy(struct dsa_switch 
*ds, struct device_node
if (index >= DSA_MAX_SWITCHES)
return -EINVAL;
 
-   err = dsa_parse_ports_dn(np->child, ds);
-   if (err)
-   return err;
-
dst = dsa_get_dst(tree);
if (!dst) {
dst = dsa_add_dst(tree);
@@ -596,12 +625,17 @@ static int _dsa_register_switch_legacy(struct dsa_switch 
*ds, struct device_node
return -ENOMEM;
}
 
+   ds->dst = dst;
+
+   err = dsa_parse_ports_dn(np->child, ds);
+   if (err)
+   return err;
+
if (dst->ds[index]) {
err = -EBUSY;
goto out;
}
 
-   ds->dst = dst;
ds->index = index;
dsa_dst_add_ds(dst, ds, index);
 
@@ -633,7 +667,7 @@ static int _dsa_register_switch_legacy(struct dsa_switch 
*ds, struct device_node
goto out_del_dst;
}
 
-   err = _dsa_cpu_parse(dst, ds, ethernet_dev, index);
+   err = _dsa_cpu_parse(dst, ds, ethernet_dev, dst->cpu_port);
if (err)
goto out_del_dst;
 
@@ -676,10 +710,6 @@ static int __dsa_register_switch(struct dsa_switch *ds, 
struct device_node *np)
if (IS_ERR(ports))
return PTR_ERR(ports);
 
-   err = dsa_parse_ports_dn(ports, ds);
-   if (err)
-   return err;
-
dst = dsa_get_dst(tree);
if (!dst) {
dst = dsa_add_dst(tree);
@@ -687,12 +717,17 @@ static int __dsa_register_switch(struct dsa_switch 

Re: [PATCH net-next] net: dsa: bcm_sf2: Implement FDB operations

2016-06-03 Thread Florian Fainelli
On 06/03/2016 05:05 PM, Florian Fainelli wrote:
> Add support for the FDB add, delete, and dump operations. The add and
> delete operations are implemented using directed ARL operations using
> the specified MAC address and consist in a read operation, write and
> readback operation.
> 
> The dump operation consists in using the ARL search and software
> filtering entries which are not for the desired port.

And this one too should be discarded.
-- 
Florian


[PATCH net-next 6/9] net: dsa: Add initialization helper for CPU port ethtool_ops

2016-06-03 Thread Florian Fainelli
Add a helper function: dsa_cpu_port_ethtool_init() which initializes a
custom ethtool_ops structure with custom DSA ethtool operations for CPU
ports. This is a preliminary change to move the initialization outside
of net/dsa/slave.c.

Signed-off-by: Florian Fainelli 
---
 net/dsa/dsa_priv.h |  1 +
 net/dsa/slave.c| 14 --
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index b42f1a5f95f3..106a9f067f94 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -58,6 +58,7 @@ const struct dsa_device_ops *dsa_resolve_tag_protocol(int 
tag_protocol);
 /* slave.c */
 extern const struct dsa_device_ops notag_netdev_ops;
 void dsa_slave_mii_bus_init(struct dsa_switch *ds);
+void dsa_cpu_port_ethtool_init(struct ethtool_ops *ops);
 int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
 int port, const char *name);
 void dsa_slave_destroy(struct net_device *slave_dev);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index a51dfedf0014..8d159932e082 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -865,6 +865,13 @@ static void dsa_slave_poll_controller(struct net_device 
*dev)
 }
 #endif
 
+void dsa_cpu_port_ethtool_init(struct ethtool_ops *ops)
+{
+   ops->get_sset_count = dsa_cpu_port_get_sset_count;
+   ops->get_ethtool_stats = dsa_cpu_port_get_ethtool_stats;
+   ops->get_strings = dsa_cpu_port_get_strings;
+}
+
 static const struct ethtool_ops dsa_slave_ethtool_ops = {
.get_settings   = dsa_slave_get_settings,
.set_settings   = dsa_slave_set_settings,
@@ -1124,12 +1131,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct 
device *parent,
   sizeof(struct ethtool_ops));
memcpy(_cpu_port_ethtool_ops, >master_ethtool_ops,
   sizeof(struct ethtool_ops));
-   dsa_cpu_port_ethtool_ops.get_sset_count =
-   dsa_cpu_port_get_sset_count;
-   dsa_cpu_port_ethtool_ops.get_ethtool_stats =
-   dsa_cpu_port_get_ethtool_stats;
-   dsa_cpu_port_ethtool_ops.get_strings =
-   dsa_cpu_port_get_strings;
+   dsa_cpu_port_ethtool_init(_cpu_port_ethtool_ops);
master->ethtool_ops = _cpu_port_ethtool_ops;
}
eth_hw_addr_inherit(slave_dev, master);
-- 
2.7.4



[PATCH net-next 7/9] net: dsa: Initialize CPU port ethtool ops per tree

2016-06-03 Thread Florian Fainelli
Now that we can properly support multiple distinct trees in the system,
using a global variable: dsa_cpu_port_ethtool_ops is getting clobbered
as soon as the second switch tree gets probed, and we don't want that.

We need to move this to be dynamically allocated, and since we can't
really be comparing addresses anymore to determine first time
initialization versus any other times, just move this to dsa.c and
dsa2.c where the remainder of the dst/ds initialization happens.

Signed-off-by: Florian Fainelli 
---
 net/dsa/dsa.c  | 28 
 net/dsa/dsa2.c |  2 +-
 net/dsa/dsa_priv.h |  2 ++
 net/dsa/slave.c| 10 --
 4 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index ebc29a1bee08..8fb8de6fb82d 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -266,6 +266,30 @@ const struct dsa_device_ops *dsa_resolve_tag_protocol(int 
tag_protocol)
return ops;
 }
 
+int dsa_cpu_port_ethtool_setup(struct dsa_switch_tree *dst,
+  struct dsa_switch *ds)
+{
+   struct net_device *master;
+   struct ethtool_ops *cpu_ops;
+
+   master = ds->dst->master_netdev;
+   if (ds->master_netdev)
+   master = ds->master_netdev;
+
+   cpu_ops = devm_kzalloc(ds->dev, sizeof(*cpu_ops), GFP_KERNEL);
+   if (!cpu_ops)
+   return -ENOMEM;
+
+   memcpy(>master_ethtool_ops, master->ethtool_ops,
+  sizeof(struct ethtool_ops));
+   memcpy(cpu_ops, >master_ethtool_ops,
+  sizeof(struct ethtool_ops));
+   dsa_cpu_port_ethtool_init(cpu_ops);
+   master->ethtool_ops = cpu_ops;
+
+   return 0;
+}
+
 static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
 {
struct dsa_switch_driver *drv = ds->drv;
@@ -379,6 +403,10 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, 
struct device *parent)
ret = 0;
}
 
+   ret = dsa_cpu_port_ethtool_setup(dst, ds);
+   if (ret)
+   return ret;
+
 #ifdef CONFIG_NET_DSA_HWMON
/* If the switch provides a temperature sensor,
 * register with hardware monitoring subsystem.
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index e8386157de30..938262010524 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -346,7 +346,7 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct 
dsa_switch *ds)
continue;
}
 
-   return 0;
+   return dsa_cpu_port_ethtool_setup(dst, ds);
 }
 
 static void dsa_ds_unapply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 106a9f067f94..3bb88b2fb580 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -54,6 +54,8 @@ int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device 
*dev,
  struct device_node *port_dn, int port);
 void dsa_cpu_dsa_destroy(struct device_node *port_dn);
 const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);
+int dsa_cpu_port_ethtool_setup(struct dsa_switch_tree *dst,
+  struct dsa_switch *ds);
 
 /* slave.c */
 extern const struct dsa_device_ops notag_netdev_ops;
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 8d159932e082..7236eb26dc97 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -892,8 +892,6 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = {
.get_eee= dsa_slave_get_eee,
 };
 
-static struct ethtool_ops dsa_cpu_port_ethtool_ops;
-
 static const struct net_device_ops dsa_slave_netdev_ops = {
.ndo_open   = dsa_slave_open,
.ndo_stop   = dsa_slave_close,
@@ -1126,14 +1124,6 @@ int dsa_slave_create(struct dsa_switch *ds, struct 
device *parent,
 
slave_dev->features = master->vlan_features;
slave_dev->ethtool_ops = _slave_ethtool_ops;
-   if (master->ethtool_ops != _cpu_port_ethtool_ops) {
-   memcpy(>master_ethtool_ops, master->ethtool_ops,
-  sizeof(struct ethtool_ops));
-   memcpy(_cpu_port_ethtool_ops, >master_ethtool_ops,
-  sizeof(struct ethtool_ops));
-   dsa_cpu_port_ethtool_init(_cpu_port_ethtool_ops);
-   master->ethtool_ops = _cpu_port_ethtool_ops;
-   }
eth_hw_addr_inherit(slave_dev, master);
slave_dev->priv_flags |= IFF_NO_QUEUE;
slave_dev->netdev_ops = _slave_netdev_ops;
-- 
2.7.4



[PATCH net-next 2/9] net: dsa: Add support for parsing the old binding

2016-06-03 Thread Florian Fainelli
Extend dsa2.c to support parsing for the old binding, which mostly means
looking for more or less the same properties in different places.

Signed-off-by: Florian Fainelli 
---
 net/dsa/dsa2.c | 142 ++---
 1 file changed, 126 insertions(+), 16 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index b5640d8ffbae..23273fd984a8 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -408,21 +408,11 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
dst->applied = false;
 }
 
-static int dsa_cpu_parse(struct device_node *port, u32 index,
-struct dsa_switch_tree *dst,
-struct dsa_switch *ds)
+static int _dsa_cpu_parse(struct dsa_switch_tree *dst,
+  struct dsa_switch *ds,
+  struct net_device *ethernet_dev,
+  u32 index)
 {
-   struct net_device *ethernet_dev;
-   struct device_node *ethernet;
-
-   ethernet = of_parse_phandle(port, "ethernet", 0);
-   if (!ethernet)
-   return -EINVAL;
-
-   ethernet_dev = of_find_net_device_by_node(ethernet);
-   if (!ethernet_dev)
-   return -EPROBE_DEFER;
-
if (!ds->master_netdev)
ds->master_netdev = ethernet_dev;
 
@@ -445,6 +435,24 @@ static int dsa_cpu_parse(struct device_node *port, u32 
index,
return 0;
 }
 
+static int dsa_cpu_parse(struct device_node *port, u32 index,
+struct dsa_switch_tree *dst,
+struct dsa_switch *ds)
+{
+   struct net_device *ethernet_dev;
+   struct device_node *ethernet;
+
+   ethernet = of_parse_phandle(port, "ethernet", 0);
+   if (!ethernet)
+   return -EINVAL;
+
+   ethernet_dev = of_find_net_device_by_node(ethernet);
+   if (!ethernet_dev)
+   return -EPROBE_DEFER;
+
+   return _dsa_cpu_parse(dst, ds, ethernet_dev, index);
+}
+
 static int dsa_ds_parse(struct dsa_switch_tree *dst, struct dsa_switch *ds)
 {
struct device_node *port;
@@ -552,6 +560,108 @@ static struct device_node *dsa_get_ports(struct 
dsa_switch *ds,
return ports;
 }
 
+static int _dsa_register_switch_legacy(struct dsa_switch *ds, struct 
device_node *np)
+{
+   const char *compat = of_get_property(np, "compatible", NULL);
+   struct device_node *dn, *ethernet;
+   struct net_device *ethernet_dev;
+   struct dsa_switch_tree *dst;
+   u32 tree = 0, index;
+   int err;
+
+   /* Tree is implied by how many devices are present in the DT with the
+* supported compatible strings from net/dsa/dsa.c
+*/
+   for_each_compatible_node(dn, NULL, compat) {
+   if (dn != np)
+   tree++;
+   }
+
+   /* index is present in the "reg" property, second cell */
+   err = of_property_read_u32_index(np->child, "reg", 1, );
+   if (err)
+   return err;
+
+   if (index >= DSA_MAX_SWITCHES)
+   return -EINVAL;
+
+   err = dsa_parse_ports_dn(np->child, ds);
+   if (err)
+   return err;
+
+   dst = dsa_get_dst(tree);
+   if (!dst) {
+   dst = dsa_add_dst(tree);
+   if (!dst)
+   return -ENOMEM;
+   }
+
+   if (dst->ds[index]) {
+   err = -EBUSY;
+   goto out;
+   }
+
+   ds->dst = dst;
+   ds->index = index;
+   dsa_dst_add_ds(dst, ds, index);
+
+   err = dsa_dst_complete(dst);
+   if (err < 0)
+   goto out;
+
+   if (err == 1) {
+   /* Not all switches registered yet */
+   err = 0;
+   goto out;
+   }
+
+   if (dst->applied) {
+   pr_info("DSA: Disjoint trees?\n");
+   err = -EINVAL;
+   goto out_del_dst;
+   }
+
+   ethernet = of_parse_phandle(np, "dsa,ethernet", 0);
+   if (!ethernet) {
+   err = -EINVAL;
+   goto out_del_dst;
+   }
+
+   ethernet_dev = of_find_net_device_by_node(ethernet);
+   if (!ethernet_dev) {
+   err = -EPROBE_DEFER;
+   goto out_del_dst;
+   }
+
+   err = _dsa_cpu_parse(dst, ds, ethernet_dev, index);
+   if (err)
+   goto out_del_dst;
+
+   if (!dst->master_netdev) {
+   pr_warn("Tree has no master device\n");
+   goto out_del_dst;
+   }
+
+   pr_info("DSA: tree %d parsed\n", dst->tree);
+
+   err = dsa_dst_apply(dst);
+   if (err) {
+   dsa_dst_unapply(dst);
+   goto out_del_dst;
+   }
+
+   dsa_put_dst(dst);
+
+   return 0;
+
+out_del_dst:
+   dsa_dst_del_ds(dst, ds, ds->index);
+out:
+   dsa_put_dst(dst);
+
+   return err;
+}
+
 static int __dsa_register_switch(struct dsa_switch *ds, struct device_node *np)
 {
struct device_node 

[PATCH net-next 9/9] net: dsa: bcm_sf2: Register our slave MDIO bus

2016-06-03 Thread Florian Fainelli
Register a slave MDIO bus which allows us to divert problematic
read/writes towards conflicting pseudo-PHY address (30). Do no longer
rely on DSA's slave_mii_bus, but instead provide our own implementation
which offers more flexibility as to what to do, and when to register it.

Signed-off-by: Florian Fainelli 
---
 drivers/net/dsa/bcm_sf2.c | 141 --
 drivers/net/dsa/bcm_sf2.h |   6 ++
 2 files changed, 106 insertions(+), 41 deletions(-)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 8dac74a6b5df..502ca65435bf 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -948,23 +949,6 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
bcm_sf2_port_disable(ds, port, NULL);
}
 
-   /* Include the pseudo-PHY address and the broadcast PHY address to
-* divert reads towards our workaround. This is only required for
-* 7445D0, since 7445E0 disconnects the internal switch pseudo-PHY such
-* that we can use the regular SWITCH_MDIO master controller instead.
-*
-* By default, DSA initializes ds->phys_mii_mask to
-* ds->enabled_port_mask to have a 1:1 mapping between Port address
-* and PHY address in order to utilize the slave_mii_bus instance to
-* read from Port PHYs. This is not what we want here, so we
-* initialize phys_mii_mask 0 to always utilize the "master" MDIO
-* bus backed by the "mdio-unimac" driver.
-*/
-   if (of_machine_is_compatible("brcm,bcm7445d0"))
-   ds->phys_mii_mask |= ((1 << BRCM_PSEUDO_PHY_ADDR) | (1 << 0));
-   else
-   ds->phys_mii_mask = 0;
-
return 0;
 }
 
@@ -985,10 +969,9 @@ static u32 bcm_sf2_sw_get_phy_flags(struct dsa_switch *ds, 
int port)
return priv->hw_params.gphy_rev;
 }
 
-static int bcm_sf2_sw_indir_rw(struct dsa_switch *ds, int op, int addr,
+static int bcm_sf2_sw_indir_rw(struct bcm_sf2_priv *priv, int op, int addr,
   int regnum, u16 val)
 {
-   struct bcm_sf2_priv *priv = ds_to_priv(ds);
int ret = 0;
u32 reg;
 
@@ -1017,32 +1000,31 @@ static int bcm_sf2_sw_indir_rw(struct dsa_switch *ds, 
int op, int addr,
return ret & 0x;
 }
 
-static int bcm_sf2_sw_phy_read(struct dsa_switch *ds, int addr, int regnum)
+static int bcm_sf2_sw_phy_read(struct mii_bus *bus, int addr, int regnum)
 {
-   /* Intercept reads from the MDIO broadcast address or Broadcom
-* pseudo-PHY address
+   struct bcm_sf2_priv *priv = bus->priv;
+
+   /* Intercept reads from Broadcom pseudo-PHY address, else, send
+* them to our master MDIO bus controller
 */
-   switch (addr) {
-   case 0:
-   case BRCM_PSEUDO_PHY_ADDR:
-   return bcm_sf2_sw_indir_rw(ds, 1, addr, regnum, 0);
-   default:
-   return 0x;
-   }
+   if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr))
+   return bcm_sf2_sw_indir_rw(priv, 1, addr, regnum, 0);
+   else
+   return mdiobus_read(priv->master_mii_bus, addr, regnum);
 }
 
-static int bcm_sf2_sw_phy_write(struct dsa_switch *ds, int addr, int regnum,
+static int bcm_sf2_sw_phy_write(struct mii_bus *bus, int addr, int regnum,
u16 val)
 {
-   /* Intercept writes to the MDIO broadcast address or Broadcom
-* pseudo-PHY address
+   struct bcm_sf2_priv *priv = bus->priv;
+
+   /* Intercept writes to the Broadcom pseudo-PHY address, else,
+* send them to our master MDIO bus controller
 */
-   switch (addr) {
-   case 0:
-   case BRCM_PSEUDO_PHY_ADDR:
-   bcm_sf2_sw_indir_rw(ds, 0, addr, regnum, val);
-   break;
-   }
+   if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr))
+   bcm_sf2_sw_indir_rw(priv, 0, addr, regnum, val);
+   else
+   mdiobus_write(priv->master_mii_bus, addr, regnum, val);
 
return 0;
 }
@@ -1283,8 +1265,6 @@ static struct dsa_switch_driver bcm_sf2_switch_ops = {
.setup  = bcm_sf2_sw_setup,
.set_addr   = bcm_sf2_sw_set_addr,
.get_phy_flags  = bcm_sf2_sw_get_phy_flags,
-   .phy_read   = bcm_sf2_sw_phy_read,
-   .phy_write  = bcm_sf2_sw_phy_write,
.get_strings= bcm_sf2_sw_get_strings,
.get_ethtool_stats  = bcm_sf2_sw_get_ethtool_stats,
.get_sset_count = bcm_sf2_sw_get_sset_count,
@@ -1307,6 +1287,75 @@ static struct dsa_switch_driver bcm_sf2_switch_ops = {
.port_fdb_dump  = bcm_sf2_sw_fdb_dump,
 };
 
+static int bcm_sf2_mdio_register(struct dsa_switch *ds)
+{
+   struct bcm_sf2_priv *priv = 

Re: [PATCH net-next] net: dsa: Provide CPU port statistics to master netdev

2016-06-03 Thread Florian Fainelli
On 06/03/2016 05:05 PM, Florian Fainelli wrote:
> This patch overloads the DSA master netdev, aka CPU Ethernet MAC to also
> include switch-side statistics, which is useful for debugging purposes,
> when the switch is not properly connected to the Ethernet MAC (duplex
> mismatch, (RG)MII electrical issues etc.).
> 
> We accomplish this by retaining the original copy of the master netdev's
> ethtool_ops, and just overload the 3 operations we care about:
> get_sset_count, get_strings and get_ethtool_stats so as to intercept
> these calls and call into the original master_netdev ethtool_ops, plus
> our own.
> 
> We take this approach as opposed to providing a set of DSA helper
> functions that would retrive the CPU port's statistics, because the
> entire purpose of DSA is to allow unmodified Ethernet MAC drivers to be
> used as CPU conduit interfaces, therefore, statistics overlay in such
> drivers would simply not scale.

Disregard this patch, it was left in the patches folder...
-- 
Florian


[PATCH net-next 3/9] net: dsa: Provide unique DSA slave MII bus names

2016-06-03 Thread Florian Fainelli
In case we have multiples trees and switches with the same index, we
need to add another discriminating id: the switch tree.

Signed-off-by: Florian Fainelli 
---
 net/dsa/slave.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 15a492261895..a51dfedf0014 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -49,7 +49,8 @@ void dsa_slave_mii_bus_init(struct dsa_switch *ds)
ds->slave_mii_bus->name = "dsa slave smi";
ds->slave_mii_bus->read = dsa_slave_phy_read;
ds->slave_mii_bus->write = dsa_slave_phy_write;
-   snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "dsa-%d", ds->index);
+   snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "dsa-%d.%d",
+ds->dst->tree, ds->index);
ds->slave_mii_bus->parent = ds->dev;
ds->slave_mii_bus->phy_mask = ~ds->phys_mii_mask;
 }
-- 
2.7.4



[PATCH net-next 6/7] net: dsa: bcm_sf2: Make it a real platform device driver

2016-06-03 Thread Florian Fainelli
The Broadcom Starfighter 2 switch driver should be a proper platform
driver, now that the DSA code has been updated to allow that, register a
switch device, feed it with the proper configuration data coming from
Device Tree and register our switch device with DSA.

The bulk of the changes consist in moving what bcm_sf2_sw_setup() did
into the platform driver probe function.

Signed-off-by: Florian Fainelli 
---
 drivers/net/dsa/bcm_sf2.c | 251 --
 net/dsa/dsa.c |   1 -
 2 files changed, 151 insertions(+), 101 deletions(-)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 73df91bb0466..8dac74a6b5df 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -934,77 +934,8 @@ static void bcm_sf2_identify_ports(struct bcm_sf2_priv 
*priv,
 
 static int bcm_sf2_sw_setup(struct dsa_switch *ds)
 {
-   const char *reg_names[BCM_SF2_REGS_NUM] = BCM_SF2_REGS_NAME;
struct bcm_sf2_priv *priv = ds_to_priv(ds);
-   struct device_node *dn;
-   void __iomem **base;
unsigned int port;
-   unsigned int i;
-   u32 reg, rev;
-   int ret;
-
-   spin_lock_init(>indir_lock);
-   mutex_init(>stats_mutex);
-
-   /* All the interesting properties are at the parent device_node
-* level
-*/
-   dn = ds->cd->of_node->parent;
-   bcm_sf2_identify_ports(priv, ds->cd->of_node);
-
-   priv->irq0 = irq_of_parse_and_map(dn, 0);
-   priv->irq1 = irq_of_parse_and_map(dn, 1);
-
-   base = >core;
-   for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
-   *base = of_iomap(dn, i);
-   if (*base == NULL) {
-   pr_err("unable to find register: %s\n", reg_names[i]);
-   ret = -ENOMEM;
-   goto out_unmap;
-   }
-   base++;
-   }
-
-   ret = bcm_sf2_sw_rst(priv);
-   if (ret) {
-   pr_err("unable to software reset switch: %d\n", ret);
-   goto out_unmap;
-   }
-
-   /* Disable all interrupts and request them */
-   bcm_sf2_intr_disable(priv);
-
-   ret = request_irq(priv->irq0, bcm_sf2_switch_0_isr, 0,
- "switch_0", priv);
-   if (ret < 0) {
-   pr_err("failed to request switch_0 IRQ\n");
-   goto out_unmap;
-   }
-
-   ret = request_irq(priv->irq1, bcm_sf2_switch_1_isr, 0,
- "switch_1", priv);
-   if (ret < 0) {
-   pr_err("failed to request switch_1 IRQ\n");
-   goto out_free_irq0;
-   }
-
-   /* Reset the MIB counters */
-   reg = core_readl(priv, CORE_GMNCFGCFG);
-   reg |= RST_MIB_CNT;
-   core_writel(priv, reg, CORE_GMNCFGCFG);
-   reg &= ~RST_MIB_CNT;
-   core_writel(priv, reg, CORE_GMNCFGCFG);
-
-   /* Get the maximum number of ports for this switch */
-   priv->hw_params.num_ports = core_readl(priv, CORE_IMP0_PRT_ID) + 1;
-   if (priv->hw_params.num_ports > DSA_MAX_PORTS)
-   priv->hw_params.num_ports = DSA_MAX_PORTS;
-
-   /* Assume a single GPHY setup if we can't read that property */
-   if (of_property_read_u32(dn, "brcm,num-gphy",
->hw_params.num_gphy))
-   priv->hw_params.num_gphy = 1;
 
/* Enable all valid ports and disable those unused */
for (port = 0; port < priv->hw_params.num_ports; port++) {
@@ -1034,31 +965,7 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
else
ds->phys_mii_mask = 0;
 
-   rev = reg_readl(priv, REG_SWITCH_REVISION);
-   priv->hw_params.top_rev = (rev >> SWITCH_TOP_REV_SHIFT) &
-   SWITCH_TOP_REV_MASK;
-   priv->hw_params.core_rev = (rev & SF2_REV_MASK);
-
-   rev = reg_readl(priv, REG_PHY_REVISION);
-   priv->hw_params.gphy_rev = rev & PHY_REVISION_MASK;
-
-   pr_info("Starfighter 2 top: %x.%02x, core: %x.%02x base: 0x%p, IRQs: 
%d, %d\n",
-   priv->hw_params.top_rev >> 8, priv->hw_params.top_rev & 0xff,
-   priv->hw_params.core_rev >> 8, priv->hw_params.core_rev & 0xff,
-   priv->core, priv->irq0, priv->irq1);
-
return 0;
-
-out_free_irq0:
-   free_irq(priv->irq0, priv);
-out_unmap:
-   base = >core;
-   for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
-   if (*base)
-   iounmap(*base);
-   base++;
-   }
-   return ret;
 }
 
 static int bcm_sf2_sw_set_addr(struct dsa_switch *ds, u8 *addr)
@@ -1370,7 +1277,7 @@ static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int 
port,
return p->ethtool_ops->set_wol(p, wol);
 }
 
-static struct dsa_switch_driver bcm_sf2_switch_driver = {
+static struct dsa_switch_driver bcm_sf2_switch_ops = {
.tag_protocol   = DSA_TAG_PROTO_BRCM,
.probe  = 

[PATCH net-next] net: dsa: bcm_sf2: Implement FDB operations

2016-06-03 Thread Florian Fainelli
Add support for the FDB add, delete, and dump operations. The add and
delete operations are implemented using directed ARL operations using
the specified MAC address and consist in a read operation, write and
readback operation.

The dump operation consists in using the ARL search and software
filtering entries which are not for the desired port.

Signed-off-by: Florian Fainelli 
---
 drivers/net/dsa/bcm_sf2.c  | 236 +
 drivers/net/dsa/bcm_sf2.h  |  56 ++
 drivers/net/dsa/bcm_sf2_regs.h |  43 
 3 files changed, 335 insertions(+)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 9d56515f4c4d..4f32b8a530bf 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -25,6 +25,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "bcm_sf2.h"
 #include "bcm_sf2_regs.h"
@@ -555,6 +557,236 @@ static int bcm_sf2_sw_br_set_stp_state(struct dsa_switch 
*ds, int port,
return 0;
 }
 
+/* Address Resolution Logic routines */
+static int bcm_sf2_arl_op_wait(struct bcm_sf2_priv *priv)
+{
+   unsigned int timeout = 10;
+   u32 reg;
+
+   do {
+   reg = core_readl(priv, CORE_ARLA_RWCTL);
+   if (!(reg & ARL_STRTDN))
+   return 0;
+
+   usleep_range(1000, 2000);
+   } while (timeout--);
+
+   return -ETIMEDOUT;
+}
+
+static int bcm_sf2_arl_rw_op(struct bcm_sf2_priv *priv, unsigned int op)
+{
+   u32 cmd;
+
+   if (op > ARL_RW)
+   return -EINVAL;
+
+   cmd = core_readl(priv, CORE_ARLA_RWCTL);
+   cmd &= ~IVL_SVL_SELECT;
+   cmd |= ARL_STRTDN;
+   if (op)
+   cmd |= ARL_RW;
+   else
+   cmd &= ~ARL_RW;
+   core_writel(priv, cmd, CORE_ARLA_RWCTL);
+
+   return bcm_sf2_arl_op_wait(priv);
+}
+
+static int bcm_sf2_arl_read(struct bcm_sf2_priv *priv, u64 mac,
+   u16 vid, struct bcm_sf2_arl_entry *ent, u8 *idx,
+   bool is_valid)
+{
+   unsigned int i;
+   int ret;
+
+   ret = bcm_sf2_arl_op_wait(priv);
+   if (ret)
+   return ret;
+
+   /* Read the 4 bins */
+   for (i = 0; i < 4; i++) {
+   u64 mac_vid;
+   u32 fwd_entry;
+
+   mac_vid = core_readq(priv, CORE_ARLA_MACVID_ENTRY(i));
+   fwd_entry = core_readl(priv, CORE_ARLA_FWD_ENTRY(i));
+   bcm_sf2_arl_to_entry(ent, mac_vid, fwd_entry);
+
+   if (ent->is_valid && is_valid) {
+   *idx = i;
+   return 0;
+   }
+
+   /* This is the MAC we just deleted */
+   if (!is_valid && (mac_vid & mac))
+   return 0;
+   }
+
+   return -ENOENT;
+}
+
+static int bcm_sf2_arl_op(struct bcm_sf2_priv *priv, int op, int port,
+ const unsigned char *addr, u16 vid, bool is_valid)
+{
+   struct bcm_sf2_arl_entry ent;
+   u32 fwd_entry;
+   u64 mac, mac_vid = 0;
+   u8 idx = 0;
+   int ret;
+
+   /* Convert the array into a 64-bit MAC */
+   mac = bcm_sf2_mac_to_u64(addr);
+
+   /* Perform a read for the given MAC and VID */
+   core_writeq(priv, mac, CORE_ARLA_MAC);
+   core_writel(priv, vid, CORE_ARLA_VID);
+
+   /* Issue a read operation for this MAC */
+   ret = bcm_sf2_arl_rw_op(priv, 1);
+   if (ret)
+   return ret;
+
+   ret = bcm_sf2_arl_read(priv, mac, vid, , , is_valid);
+   /* If this is a read, just finish now */
+   if (op)
+   return ret;
+
+   /* We could not find a matching MAC, so reset to a new entry */
+   if (ret) {
+   fwd_entry = 0;
+   idx = 0;
+   }
+
+   memset(, 0, sizeof(ent));
+   ent.port = port;
+   ent.is_valid = is_valid;
+   ent.vid = vid;
+   ent.is_static = true;
+   memcpy(ent.mac, addr, ETH_ALEN);
+   bcm_sf2_arl_from_entry(_vid, _entry, );
+
+   core_writeq(priv, mac_vid, CORE_ARLA_MACVID_ENTRY(idx));
+   core_writel(priv, fwd_entry, CORE_ARLA_FWD_ENTRY(idx));
+
+   ret = bcm_sf2_arl_rw_op(priv, 0);
+   if (ret)
+   return ret;
+
+   /* Re-read the entry to check */
+   return bcm_sf2_arl_read(priv, mac, vid, , , is_valid);
+}
+
+static int bcm_sf2_sw_fdb_prepare(struct dsa_switch *ds, int port,
+ const struct switchdev_obj_port_fdb *fdb,
+ struct switchdev_trans *trans)
+{
+   /* We do not need to do anything specific here yet */
+   return 0;
+}
+
+static int bcm_sf2_sw_fdb_add(struct dsa_switch *ds, int port,
+ const struct switchdev_obj_port_fdb *fdb,
+ struct switchdev_trans *trans)
+{
+   struct bcm_sf2_priv *priv = ds_to_priv(ds);
+
+   return bcm_sf2_arl_op(priv, 0, 

[PATCH net-next 8/9] net: dsa: bcm_sf2: Make it a real platform device driver

2016-06-03 Thread Florian Fainelli
The Broadcom Starfighter 2 switch driver should be a proper platform
driver, now that the DSA code has been updated to allow that, register a
switch device, feed it with the proper configuration data coming from
Device Tree and register our switch device with DSA.

The bulk of the changes consist in moving what bcm_sf2_sw_setup() did
into the platform driver probe function.

Signed-off-by: Florian Fainelli 
---
 drivers/net/dsa/bcm_sf2.c | 251 --
 net/dsa/dsa.c |   1 -
 2 files changed, 151 insertions(+), 101 deletions(-)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 73df91bb0466..8dac74a6b5df 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -934,77 +934,8 @@ static void bcm_sf2_identify_ports(struct bcm_sf2_priv 
*priv,
 
 static int bcm_sf2_sw_setup(struct dsa_switch *ds)
 {
-   const char *reg_names[BCM_SF2_REGS_NUM] = BCM_SF2_REGS_NAME;
struct bcm_sf2_priv *priv = ds_to_priv(ds);
-   struct device_node *dn;
-   void __iomem **base;
unsigned int port;
-   unsigned int i;
-   u32 reg, rev;
-   int ret;
-
-   spin_lock_init(>indir_lock);
-   mutex_init(>stats_mutex);
-
-   /* All the interesting properties are at the parent device_node
-* level
-*/
-   dn = ds->cd->of_node->parent;
-   bcm_sf2_identify_ports(priv, ds->cd->of_node);
-
-   priv->irq0 = irq_of_parse_and_map(dn, 0);
-   priv->irq1 = irq_of_parse_and_map(dn, 1);
-
-   base = >core;
-   for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
-   *base = of_iomap(dn, i);
-   if (*base == NULL) {
-   pr_err("unable to find register: %s\n", reg_names[i]);
-   ret = -ENOMEM;
-   goto out_unmap;
-   }
-   base++;
-   }
-
-   ret = bcm_sf2_sw_rst(priv);
-   if (ret) {
-   pr_err("unable to software reset switch: %d\n", ret);
-   goto out_unmap;
-   }
-
-   /* Disable all interrupts and request them */
-   bcm_sf2_intr_disable(priv);
-
-   ret = request_irq(priv->irq0, bcm_sf2_switch_0_isr, 0,
- "switch_0", priv);
-   if (ret < 0) {
-   pr_err("failed to request switch_0 IRQ\n");
-   goto out_unmap;
-   }
-
-   ret = request_irq(priv->irq1, bcm_sf2_switch_1_isr, 0,
- "switch_1", priv);
-   if (ret < 0) {
-   pr_err("failed to request switch_1 IRQ\n");
-   goto out_free_irq0;
-   }
-
-   /* Reset the MIB counters */
-   reg = core_readl(priv, CORE_GMNCFGCFG);
-   reg |= RST_MIB_CNT;
-   core_writel(priv, reg, CORE_GMNCFGCFG);
-   reg &= ~RST_MIB_CNT;
-   core_writel(priv, reg, CORE_GMNCFGCFG);
-
-   /* Get the maximum number of ports for this switch */
-   priv->hw_params.num_ports = core_readl(priv, CORE_IMP0_PRT_ID) + 1;
-   if (priv->hw_params.num_ports > DSA_MAX_PORTS)
-   priv->hw_params.num_ports = DSA_MAX_PORTS;
-
-   /* Assume a single GPHY setup if we can't read that property */
-   if (of_property_read_u32(dn, "brcm,num-gphy",
->hw_params.num_gphy))
-   priv->hw_params.num_gphy = 1;
 
/* Enable all valid ports and disable those unused */
for (port = 0; port < priv->hw_params.num_ports; port++) {
@@ -1034,31 +965,7 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
else
ds->phys_mii_mask = 0;
 
-   rev = reg_readl(priv, REG_SWITCH_REVISION);
-   priv->hw_params.top_rev = (rev >> SWITCH_TOP_REV_SHIFT) &
-   SWITCH_TOP_REV_MASK;
-   priv->hw_params.core_rev = (rev & SF2_REV_MASK);
-
-   rev = reg_readl(priv, REG_PHY_REVISION);
-   priv->hw_params.gphy_rev = rev & PHY_REVISION_MASK;
-
-   pr_info("Starfighter 2 top: %x.%02x, core: %x.%02x base: 0x%p, IRQs: 
%d, %d\n",
-   priv->hw_params.top_rev >> 8, priv->hw_params.top_rev & 0xff,
-   priv->hw_params.core_rev >> 8, priv->hw_params.core_rev & 0xff,
-   priv->core, priv->irq0, priv->irq1);
-
return 0;
-
-out_free_irq0:
-   free_irq(priv->irq0, priv);
-out_unmap:
-   base = >core;
-   for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
-   if (*base)
-   iounmap(*base);
-   base++;
-   }
-   return ret;
 }
 
 static int bcm_sf2_sw_set_addr(struct dsa_switch *ds, u8 *addr)
@@ -1370,7 +1277,7 @@ static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int 
port,
return p->ethtool_ops->set_wol(p, wol);
 }
 
-static struct dsa_switch_driver bcm_sf2_switch_driver = {
+static struct dsa_switch_driver bcm_sf2_switch_ops = {
.tag_protocol   = DSA_TAG_PROTO_BRCM,
.probe  = 

[PATCH net-next 1/9] net: dsa: Prepare to support legacy DT binding

2016-06-03 Thread Florian Fainelli
In preparation for supporting the legacy DT binding, call
dsa_get_ports() early on to allow two different parsing code paths to be
called.

Signed-off-by: Florian Fainelli 
---
 net/dsa/dsa2.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 4e5051bed643..b5640d8ffbae 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -552,7 +552,7 @@ static struct device_node *dsa_get_ports(struct dsa_switch 
*ds,
return ports;
 }
 
-static int _dsa_register_switch(struct dsa_switch *ds, struct device_node *np)
+static int __dsa_register_switch(struct dsa_switch *ds, struct device_node *np)
 {
struct device_node *ports = dsa_get_ports(ds, np);
struct dsa_switch_tree *dst;
@@ -622,6 +622,16 @@ out:
return err;
 }
 
+static int _dsa_register_switch(struct dsa_switch *ds, struct device_node *np)
+{
+   struct device_node *ports = dsa_get_ports(ds, np);
+
+   if (IS_ERR(ports))
+   return PTR_ERR(ports);
+
+   return __dsa_register_switch(ds, np);
+}
+
 int dsa_register_switch(struct dsa_switch *ds, struct device_node *np)
 {
int err;
-- 
2.7.4



[PATCH net-next 0/9] net: dsa: misc improvements

2016-06-03 Thread Florian Fainelli
Hi all,

This patch series builds on top of Andrew's "New DSA bind, switches as devices"
patch set and does the following:

- add support for the old DSA binding with the new dsa_register_switch() API
  which is needed by some platforms where the Device Tree is pretty much frozen

- add a few helper functions/goodies for net/dsa/dsa2.c to be as close as 
possible
  from net/dsa/dsa.c in terms of what drivers can expect, in particular the 
slave
  MDIO bus and the enabled_port_mask and phy_mii_mask

- fix the CPU port ethtools ops to work in a multiple tree setup since we can
  no longer assume a single tree is supported

- finally conver the bcm_sf2 driver to be a true platform device driver and
  slightly rework its internal vs. external MDIO bus indirect read/writes to
  be cleaner

Florian Fainelli (9):
  net: dsa: Prepare to support legacy DT binding
  net: dsa: Add support for parsing the old binding
  net: dsa: Provide unique DSA slave MII bus names
  net: dsa: Initialize ds->enabled_port_mask and ds->phys_mii_mask
  net: dsa: Export suspend/resume functions
  net: dsa: Add initialization helper for CPU port ethtool_ops
  net: dsa: Initialize CPU port ethtool ops per tree
  net: dsa: bcm_sf2: Make it a real platform device driver
  net: dsa: bcm_sf2: Register our slave MDIO bus

 drivers/net/dsa/bcm_sf2.c | 390 +-
 drivers/net/dsa/bcm_sf2.h |   6 +
 include/net/dsa.h |  14 ++
 net/dsa/dsa.c |  35 -
 net/dsa/dsa2.c| 199 ---
 net/dsa/dsa_priv.h|   3 +
 net/dsa/slave.c   |  25 ++-
 7 files changed, 491 insertions(+), 181 deletions(-)

-- 
2.7.4



[PATCH net-next] net: dsa: Provide CPU port statistics to master netdev

2016-06-03 Thread Florian Fainelli
This patch overloads the DSA master netdev, aka CPU Ethernet MAC to also
include switch-side statistics, which is useful for debugging purposes,
when the switch is not properly connected to the Ethernet MAC (duplex
mismatch, (RG)MII electrical issues etc.).

We accomplish this by retaining the original copy of the master netdev's
ethtool_ops, and just overload the 3 operations we care about:
get_sset_count, get_strings and get_ethtool_stats so as to intercept
these calls and call into the original master_netdev ethtool_ops, plus
our own.

We take this approach as opposed to providing a set of DSA helper
functions that would retrive the CPU port's statistics, because the
entire purpose of DSA is to allow unmodified Ethernet MAC drivers to be
used as CPU conduit interfaces, therefore, statistics overlay in such
drivers would simply not scale.

The new ethtool -S  output would therefore look like this now:
 statistics
p<2 digits cpu port number>_

Signed-off-by: Florian Fainelli 
---
Changes from RFC:

- prepend the CPU port as a prefix to make it clear what the stats are
  about, master netdev interface stats are unchanged

 include/net/dsa.h |  5 
 net/dsa/slave.c   | 88 +++
 2 files changed, 93 insertions(+)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 2d280aba97e2..8e86af87c84f 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -111,6 +111,11 @@ struct dsa_switch_tree {
enum dsa_tag_protocol   tag_protocol;
 
/*
+* Original copy of the master netdev ethtool_ops
+*/
+   struct ethtool_ops  master_ethtool_ops;
+
+   /*
 * The switch and port to which the CPU is attached.
 */
s8  cpu_switch;
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 3b6750f5e68b..5ea8a40c8d33 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -666,6 +666,78 @@ static void dsa_slave_get_strings(struct net_device *dev,
}
 }
 
+static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev,
+  struct ethtool_stats *stats,
+  uint64_t *data)
+{
+   struct dsa_switch_tree *dst = dev->dsa_ptr;
+   struct dsa_switch *ds = dst->ds[0];
+   s8 cpu_port = dst->cpu_port;
+   int count = 0;
+
+   if (dst->master_ethtool_ops.get_sset_count) {
+   count = dst->master_ethtool_ops.get_sset_count(dev,
+  ETH_SS_STATS);
+   dst->master_ethtool_ops.get_ethtool_stats(dev, stats, data);
+   }
+
+   if (ds->drv->get_ethtool_stats)
+   ds->drv->get_ethtool_stats(ds, cpu_port, data + count);
+}
+
+static int dsa_cpu_port_get_sset_count(struct net_device *dev, int sset)
+{
+   struct dsa_switch_tree *dst = dev->dsa_ptr;
+   struct dsa_switch *ds = dst->ds[0];
+   int count = 0;
+
+   if (dst->master_ethtool_ops.get_sset_count)
+   count += dst->master_ethtool_ops.get_sset_count(dev, sset);
+
+   if (sset == ETH_SS_STATS && ds->drv->get_sset_count)
+   count += ds->drv->get_sset_count(ds);
+
+   return count;
+}
+
+static void dsa_cpu_port_get_strings(struct net_device *dev,
+uint32_t stringset, uint8_t *data)
+{
+   struct dsa_switch_tree *dst = dev->dsa_ptr;
+   struct dsa_switch *ds = dst->ds[0];
+   s8 cpu_port = dst->cpu_port;
+   int len = ETH_GSTRING_LEN;
+   int mcount = 0, count;
+   unsigned int i;
+   uint8_t pfx[4];
+   uint8_t *ndata;
+
+   snprintf(pfx, sizeof(pfx), "p%.2d", cpu_port);
+   /* We do not want to be NULL-terminated, since this is a prefix */
+   pfx[sizeof(pfx) - 1] = '_';
+
+   if (dst->master_ethtool_ops.get_sset_count) {
+   mcount = dst->master_ethtool_ops.get_sset_count(dev,
+   ETH_SS_STATS);
+   dst->master_ethtool_ops.get_strings(dev, stringset, data);
+   }
+
+   if (stringset == ETH_SS_STATS && ds->drv->get_strings) {
+   ndata = data + mcount * len;
+   /* This function copies ETH_GSTRINGS_LEN bytes, we will mangle
+* the output after to prepend our CPU port prefix we
+* constructed earlier
+*/
+   ds->drv->get_strings(ds, cpu_port, ndata);
+   count = ds->drv->get_sset_count(ds);
+   for (i = 0; i < count; i++) {
+   memmove(ndata + (i * len + sizeof(pfx)),
+   ndata + i * len, len - sizeof(pfx));
+   memcpy(ndata + i * len, pfx, sizeof(pfx));
+   }
+   }
+}
+
 static void dsa_slave_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats,
  

Re: [PATCH V4 0/4] net-next: mediatek: improve phy support

2016-06-03 Thread David Miller
From: John Crispin 
Date: Fri,  3 Jun 2016 10:17:05 +0200

> The current driver did not handle the RGMII delay modes and asymmetric flow
> control properly. The mii_bus is not freed properly. Also add support for
> fixed-phy allowing the driver to work on SoCs that have an internal gigabit
> switch.

Series applied, thanks John.


Re: [PATCH net] ethernet/sfc: report supported link speeds on SFP connections

2016-06-03 Thread David Miller
From: Jarod Wilson 
Date: Thu,  2 Jun 2016 21:33:24 -0400

> My solarflare cards connected to a 10GbE switch with an SFP+ module/cable
> don't currently report any supported link speeds:
 ...
> CC: Solarflare linux maintainers 
> CC: Edward Cree 
> CC: Bert Kenward 
> CC: netdev@vger.kernel.org
> Signed-off-by: Jarod Wilson 

Solarflare maintainers, please review.


Re: [PATCH v4 net-next 00/13] net: hns: add support of ACPI

2016-06-03 Thread David Miller
From: "Rafael J. Wysocki" 
Date: Fri, 03 Jun 2016 23:34:50 +0200

> On Friday, June 03, 2016 10:55:08 AM Yisen Zhuang wrote:
>> From: Kejian Yan 
 ...
>> Kejian Yan (13):
>>   ACPI: bus: add stub acpi_dev_found() to linux/acpi.h
>>   ACPI: bus: add stub acpi_evaluate_dsm() to linux/acpi.h
> 
> Which patches need these stubs?

10 and 12


Re: [PATCH] net: ethernet: ti: cpsw: remove unused priv lock

2016-06-03 Thread David Miller
From: Ivan Khoronzhuk 
Date: Fri,  3 Jun 2016 01:37:08 +0300

> There is no reason in this lock. At least for now.
> 
> Signed-off-by: Ivan Khoronzhuk 

Applied to net-next.


Re: [PATCH] rxrpc: Use pr_ and pr_fmt, reduce object size a few KB

2016-06-03 Thread David Miller
From: Joe Perches 
Date: Thu,  2 Jun 2016 12:08:52 -0700

> Use the more common kernel logging style and reduce object size.
> 
> The logging message prefix changes from a mixture of
> "RxRPC:" and "RXRPC:" to "af_rxrpc: ".
> 
> $ size net/rxrpc/built-in.o*
>text  data bss dec hex filename
>   64172  19728304   74448   122d0 net/rxrpc/built-in.o.new
>   67512  19728304   77788   12fdc net/rxrpc/built-in.o.old
> 
> Miscellanea:
> 
> o Consolidate the ASSERT macros to use a single pr_err call with
>   decimal and hexadecimal output and a stringified #OP argument
> 
> Signed-off-by: Joe Perches 

Looks good to me, applied, thanks Joe.


Re: [PATCH net-next] hv_netvsc: Fix VF register on vlan devices

2016-06-03 Thread David Miller
From: Haiyang Zhang 
Date: Thu,  2 Jun 2016 12:02:04 -0700

> Added a condition to avoid vlan devices with same MAC registering
> as VF.
> 
> Signed-off-by: Haiyang Zhang 
> Reviewed-by: K. Y. Srinivasan 

Applied.


Re: [PATCH v3 0/7] sctp: Add GSO support

2016-06-03 Thread David Miller
From: Marcelo Ricardo Leitner 
Date: Thu,  2 Jun 2016 15:05:37 -0300

> This patchset adds sctp GSO support.
> 
> Performance tests indicates that increases throughput by 10% if using
> bigger chunk sizes, specially if bigger than MTU. For small chunks, it
> doesn't help much if not using heavy firewall rules.
> 
> For small chunks it will probably be of more use once we get something
> like MSG_MORE as David Laight had suggested.
> 
> overall changes:
> v1->v2:
> Added support for receiving GSO frames on SCTP stack, as requested by
> Dave Miller.
> 
> v2->v3:
> Consider sctphdr size in skb_gso_transport_seglen()
> rebased due to 5c7cdf339af5 ("gso: Remove arbitrary checks for
> unsupported GSO")

Series applied, thanks Marcelo.


Re: [PATCH] net: ethernet: ti: cpsw: fix rx-usecs interrupt pacing consistency

2016-06-03 Thread David Miller
From: Ivan Khoronzhuk 
Date: Thu,  2 Jun 2016 16:14:52 +0300

> The rx-usecs shouldn't be changed while interface down/up.
> Currently, for instance, if it's set to 100us, after interface
> down/up it's 500us. It's a hidden bug that can lead to lavish
> interrupt pacing time increasing while "down/up" up to max value.
> 
> Steps to reproduce:
> - set rx-usecs to be 100us
> - down/up interface
> - read new unexpected rx-usecs
> 
> Signed-off-by: Ivan Khoronzhuk 

Applied.


Re: [PATCH] gianfar: fix the last transmit buffer descriptor

2016-06-03 Thread David Miller
From: Yangbo Lu 
Date: Thu, 2 Jun 2016 17:36:28 +0800

> When the transmit hardware timestamping is enabled, an additional
> TxBD would be added and would be set as the last TxBD with TXBD_LAST
> and TXBD_INTERRUPT. However this has been broken by a patch recently.
> This made the software couldn't get transmit hardware timestamps and
> resulted in call trace. So, this patch is to fix this issue.
> 
> Fixes: 48963b4492e9 ("gianfar: Remove redundant ops for do_tstamp
>from xmit()")
> Signed-off-by: Yangbo Lu 

Applied, thanks.


Re: [Patch net] act_police: fix a crash during removal

2016-06-03 Thread David Miller
From: Cong Wang 
Date: Wed,  1 Jun 2016 16:15:20 -0700

> The police action is using its own code to initialize tcf hash
> info, which makes us to forgot to initialize a->hinfo correctly.
> Fix this by calling the helper function tcf_hash_create() directly.
> 
> This patch fixed the following crash:
 ...
> Fixes: ddf97ccdd7cb ("net_sched: add network namespace support for tc 
> actions")
> Cc: Jamal Hadi Salim 
> Signed-off-by: Cong Wang 

This adds a new warning, please resubmit with this fixed.

net/sched/act_police.c: In function ‘tcf_act_police_locate’:
net/sched/act_police.c:247:3: warning: ‘police’ may be used uninitialized in 
this function [-Wmaybe-uninitialized]


Re: [Patch net] sch_prio: update backlog as well

2016-06-03 Thread David Miller
From: Cong Wang 
Date: Wed,  1 Jun 2016 16:15:16 -0700

> We need to update backlog too when we update qlen.
> 
> Joint work with Stas.
> 
> Reported-by: Stas Nichiporovich 
> Tested-by: Stas Nichiporovich 
> Fixes: 2f5fb43f ("net_sched: update hierarchical backlog too")
> Cc: Jamal Hadi Salim 
> Signed-off-by: Cong Wang 

Applied.


Re: [Patch net] sch_tbf: update backlog as well

2016-06-03 Thread David Miller
From: Cong Wang 
Date: Wed,  1 Jun 2016 16:15:19 -0700

> Fixes: 2f5fb43f ("net_sched: update hierarchical backlog too")
> Cc: Jamal Hadi Salim 
> Signed-off-by: Cong Wang 

Applied.


Re: [Patch net] sch_hfsc: always keep backlog updated

2016-06-03 Thread David Miller
From: Cong Wang 
Date: Wed,  1 Jun 2016 16:15:15 -0700

> hfsc updates backlog lazily, that is only when we
> dump the stats. This is problematic after we begin to
> update backlog in qdisc_tree_reduce_backlog().
> 
> Reported-by: Stas Nichiporovich 
> Tested-by: Stas Nichiporovich 
> Fixes: 2f5fb43f ("net_sched: update hierarchical backlog too")
> Cc: Jamal Hadi Salim 
> Signed-off-by: Cong Wang 

Applied.


Re: [Patch net] sch_red: update backlog as well

2016-06-03 Thread David Miller
From: Cong Wang 
Date: Wed,  1 Jun 2016 16:15:18 -0700

> Fixes: 2f5fb43f ("net_sched: update hierarchical backlog too")
> Cc: Jamal Hadi Salim 
> Signed-off-by: Cong Wang 

Applied.


Re: [Patch net] sch_drr: update backlog as well

2016-06-03 Thread David Miller
From: Cong Wang 
Date: Wed,  1 Jun 2016 16:15:17 -0700

> Fixes: 2f5fb43f ("net_sched: update hierarchical backlog too")
> Cc: Jamal Hadi Salim 
> Signed-off-by: Cong Wang 

Applied.


Re: latest net-next does not build on sparc?

2016-06-03 Thread David Miller
From: Sowmini Varadhan 
Date: Fri, 3 Jun 2016 18:39:25 -0400

> Just pulled 4.7.0-rc1, and I find a build error
> 
> kernel/locking/rwsem.c: In function ?down_write_killable?:
> kernel/locking/rwsem.c:65: error: implicit declaration of function 
> ?__down_write_killable?
> make[2]: *** [kernel/locking/rwsem.o] Error 1
> 
> I had to pull in this patch:
>   http://lkml.iu.edu/hypermail/linux/kernel/1602.3/04431.html
> to get it  to build- did I just miss something in my pull?

That change isn't even in Linus's tree.


[PATCH 4.4-stable 1/3] vxlan: Relax MTU constraints

2016-06-03 Thread Dan Streetman
From: David Wragg 

Allow the MTU of vxlan devices without an underlying device to be set
to larger values (up to a maximum based on IP packet limits and vxlan
overhead).

Previously, their MTUs could not be set to higher than the
conventional ethernet value of 1500.  This is a very arbitrary value
in the context of vxlan, and prevented vxlan devices from being able
to take advantage of jumbo frames etc.

The default MTU remains 1500, for compatibility.

Signed-off-by: David Wragg 
Acked-by: Roopa Prabhu 
Signed-off-by: David S. Miller 
---
 drivers/net/vxlan.c | 36 +---
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 3c0df70..9a1a4ec 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2370,29 +2370,43 @@ static void vxlan_set_multicast_list(struct net_device 
*dev)
 {
 }
 
-static int vxlan_change_mtu(struct net_device *dev, int new_mtu)
+static int __vxlan_change_mtu(struct net_device *dev,
+ struct net_device *lowerdev,
+ struct vxlan_rdst *dst, int new_mtu, bool strict)
 {
-   struct vxlan_dev *vxlan = netdev_priv(dev);
-   struct vxlan_rdst *dst = >default_dst;
-   struct net_device *lowerdev;
-   int max_mtu;
+   int max_mtu = IP_MAX_MTU;
 
-   lowerdev = __dev_get_by_index(vxlan->net, dst->remote_ifindex);
-   if (lowerdev == NULL)
-   return eth_change_mtu(dev, new_mtu);
+   if (lowerdev)
+   max_mtu = lowerdev->mtu;
 
if (dst->remote_ip.sa.sa_family == AF_INET6)
-   max_mtu = lowerdev->mtu - VXLAN6_HEADROOM;
+   max_mtu -= VXLAN6_HEADROOM;
else
-   max_mtu = lowerdev->mtu - VXLAN_HEADROOM;
+   max_mtu -= VXLAN_HEADROOM;
 
-   if (new_mtu < 68 || new_mtu > max_mtu)
+   if (new_mtu < 68)
return -EINVAL;
 
+   if (new_mtu > max_mtu) {
+   if (strict)
+   return -EINVAL;
+
+   new_mtu = max_mtu;
+   }
+
dev->mtu = new_mtu;
return 0;
 }
 
+static int vxlan_change_mtu(struct net_device *dev, int new_mtu)
+{
+   struct vxlan_dev *vxlan = netdev_priv(dev);
+   struct vxlan_rdst *dst = >default_dst;
+   struct net_device *lowerdev = __dev_get_by_index(vxlan->net,
+dst->remote_ifindex);
+   return __vxlan_change_mtu(dev, lowerdev, dst, new_mtu, true);
+}
+
 static int egress_ipv4_tun_info(struct net_device *dev, struct sk_buff *skb,
struct ip_tunnel_info *info,
__be16 sport, __be16 dport)
-- 
2.7.4



[PATCH 4.4-stable 2/3] geneve: Relax MTU constraints

2016-06-03 Thread Dan Streetman
From: David Wragg 

Allow the MTU of geneve devices to be set to large values, in order to
exploit underlying networks with larger frame sizes.

GENEVE does not have a fixed encapsulation overhead (an openvswitch
rule can add variable length options), so there is no relevant maximum
MTU to enforce.  A maximum of IP_MAX_MTU is used instead.
Encapsulated packets that are too big for the underlying network will
get dropped on the floor.

Signed-off-by: David Wragg 
Signed-off-by: David S. Miller 
---
 drivers/net/geneve.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 58efdec..0fb2ced 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -998,6 +998,17 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct 
net_device *dev)
return geneve_xmit_skb(skb, dev, info);
 }
 
+static int geneve_change_mtu(struct net_device *dev, int new_mtu)
+{
+   /* GENEVE overhead is not fixed, so we can't enforce a more
+* precise max MTU.
+*/
+   if (new_mtu < 68 || new_mtu > IP_MAX_MTU)
+   return -EINVAL;
+   dev->mtu = new_mtu;
+   return 0;
+}
+
 static int geneve_fill_metadata_dst(struct net_device *dev, struct sk_buff 
*skb)
 {
struct ip_tunnel_info *info = skb_tunnel_info(skb);
@@ -1042,7 +1053,7 @@ static const struct net_device_ops geneve_netdev_ops = {
.ndo_stop   = geneve_stop,
.ndo_start_xmit = geneve_xmit,
.ndo_get_stats64= ip_tunnel_get_stats64,
-   .ndo_change_mtu = eth_change_mtu,
+   .ndo_change_mtu = geneve_change_mtu,
.ndo_validate_addr  = eth_validate_addr,
.ndo_set_mac_address= eth_mac_addr,
.ndo_fill_metadata_dst  = geneve_fill_metadata_dst,
-- 
2.7.4



[PATCH 4.4-stable 0/3] Set a large MTU on ovs-created tunnel devices

2016-06-03 Thread Dan Streetman
Can you queue these for 4.4 stable?  The first 2 are cherry-picked cleanly
into 4.4, the last required only context changes to apply.

The commits are only needed in 4.4, as the bugs they fix were introduced
after 4.1.

David Wragg (3):
  vxlan: Relax MTU constraints
  geneve: Relax MTU constraints
  vxlan, gre, geneve: Set a large MTU on ovs-created tunnel devices

 drivers/net/geneve.c  | 31 +++-
 drivers/net/vxlan.c   | 47 ++-
 include/net/ip_tunnels.h  |  1 +
 net/ipv4/ip_gre.c |  8 
 net/ipv4/ip_tunnel.c  | 20 +++---
 net/openvswitch/vport-vxlan.c |  2 ++
 6 files changed, 87 insertions(+), 22 deletions(-)

-- 
2.7.4



[PATCH 4.4-stable 3/3] vxlan, gre, geneve: Set a large MTU on ovs-created tunnel devices

2016-06-03 Thread Dan Streetman
From: David Wragg 

Prior to 4.3, openvswitch tunnel vports (vxlan, gre and geneve) could
transmit vxlan packets of any size, constrained only by the ability to
send out the resulting packets.  4.3 introduced netdevs corresponding
to tunnel vports.  These netdevs have an MTU, which limits the size of
a packet that can be successfully encapsulated.  The default MTU
values are low (1500 or less), which is awkwardly small in the context
of physical networks supporting jumbo frames, and leads to a
conspicuous change in behaviour for userspace.

Instead, set the MTU on openvswitch-created netdevs to be the relevant
maximum (i.e. the maximum IP packet size minus any relevant overhead),
effectively restoring the behaviour prior to 4.3.

Signed-off-by: David Wragg 
Signed-off-by: David S. Miller 
---
 drivers/net/geneve.c  | 18 ++
 drivers/net/vxlan.c   | 11 ---
 include/net/ip_tunnels.h  |  1 +
 net/ipv4/ip_gre.c |  8 
 net/ipv4/ip_tunnel.c  | 20 +---
 net/openvswitch/vport-vxlan.c |  2 ++
 6 files changed, 50 insertions(+), 10 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 0fb2ced..d675f09 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -1360,11 +1360,21 @@ struct net_device *geneve_dev_create_fb(struct net 
*net, const char *name,
 
err = geneve_configure(net, dev, _remote_unspec,
   0, 0, 0, htons(dst_port), true);
-   if (err) {
-   free_netdev(dev);
-   return ERR_PTR(err);
-   }
+   if (err)
+   goto err;
+
+   /* openvswitch users expect packet sizes to be unrestricted,
+* so set the largest MTU we can.
+*/
+   err = geneve_change_mtu(dev, IP_MAX_MTU);
+   if (err)
+   goto err;
+
return dev;
+
+ err:
+   free_netdev(dev);
+   return ERR_PTR(err);
 }
 EXPORT_SYMBOL_GPL(geneve_dev_create_fb);
 
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 9a1a4ec..ca3dbaa 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2782,6 +2782,7 @@ static int vxlan_dev_configure(struct net *src_net, 
struct net_device *dev,
int err;
bool use_ipv6 = false;
__be16 default_port = vxlan->cfg.dst_port;
+   struct net_device *lowerdev = NULL;
 
vxlan->net = src_net;
 
@@ -2802,9 +2803,7 @@ static int vxlan_dev_configure(struct net *src_net, 
struct net_device *dev,
}
 
if (conf->remote_ifindex) {
-   struct net_device *lowerdev
-= __dev_get_by_index(src_net, conf->remote_ifindex);
-
+   lowerdev = __dev_get_by_index(src_net, conf->remote_ifindex);
dst->remote_ifindex = conf->remote_ifindex;
 
if (!lowerdev) {
@@ -2828,6 +2827,12 @@ static int vxlan_dev_configure(struct net *src_net, 
struct net_device *dev,
needed_headroom = lowerdev->hard_header_len;
}
 
+   if (conf->mtu) {
+   err = __vxlan_change_mtu(dev, lowerdev, dst, conf->mtu, false);
+   if (err)
+   return err;
+   }
+
if (use_ipv6 || conf->flags & VXLAN_F_COLLECT_METADATA)
needed_headroom += VXLAN6_HEADROOM;
else
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 62a750a..af40bc5 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -230,6 +230,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device 
*dev,
 int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd);
 int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t,
u8 *protocol, struct flowi4 *fl4);
+int __ip_tunnel_change_mtu(struct net_device *dev, int new_mtu, bool strict);
 int ip_tunnel_change_mtu(struct net_device *dev, int new_mtu);
 
 struct rtnl_link_stats64 *ip_tunnel_get_stats64(struct net_device *dev,
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 7dc962b..3e41840 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -1247,6 +1247,14 @@ struct net_device *gretap_fb_dev_create(struct net *net, 
const char *name,
err = ipgre_newlink(net, dev, tb, NULL);
if (err < 0)
goto out;
+
+   /* openvswitch users expect packet sizes to be unrestricted,
+* so set the largest MTU we can.
+*/
+   err = __ip_tunnel_change_mtu(dev, IP_MAX_MTU, false);
+   if (err)
+   goto out;
+
return dev;
 out:
free_netdev(dev);
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index ce30c8b..3310ac7 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -948,17 +948,31 @@ done:
 }
 EXPORT_SYMBOL_GPL(ip_tunnel_ioctl);
 
-int ip_tunnel_change_mtu(struct net_device *dev, int new_mtu)
+int __ip_tunnel_change_mtu(struct net_device *dev, int 

latest net-next does not build on sparc?

2016-06-03 Thread Sowmini Varadhan
Just pulled 4.7.0-rc1, and I find a build error

kernel/locking/rwsem.c: In function ?down_write_killable?:
kernel/locking/rwsem.c:65: error: implicit declaration of function 
?__down_write_killable?
make[2]: *** [kernel/locking/rwsem.o] Error 1

I had to pull in this patch:
  http://lkml.iu.edu/hypermail/linux/kernel/1602.3/04431.html
to get it  to build- did I just miss something in my pull?

--Sowmini


Re: [PATCH v2] soreuseport: add compat case for setsockopt SO_ATTACH_REUSEPORT_CBPF

2016-06-03 Thread Daniel Borkmann

On 06/03/2016 11:49 PM, Helge Deller wrote:

Commit 538950a1b752 ("soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF")
missed to add the compat case for the SO_ATTACH_REUSEPORT_CBPF option.

Signed-off-by: Helge Deller 


LGTM, thanks!

Acked-by: Daniel Borkmann 

[ Cc Willem: I believe we also need something similar for PACKET_FANOUT_DATA
  when PACKET_FANOUT_CBPF is requested since we have the same issue with the
  pointer in struct sock_fprog there, too. ]


diff --git a/net/compat.c b/net/compat.c
index 5cfd26a..1373947 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -354,7 +354,8 @@ static int do_set_sock_timeout(struct socket *sock, int 
level,
  static int compat_sock_setsockopt(struct socket *sock, int level, int optname,
char __user *optval, unsigned int optlen)
  {
-   if (optname == SO_ATTACH_FILTER)
+   if (optname == SO_ATTACH_FILTER ||
+   optname == SO_ATTACH_REUSEPORT_CBPF)
return do_set_attach_filter(sock, level, optname,
optval, optlen);
if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)





Re: [PATCH] b43: Remove unused phy_a code

2016-06-03 Thread Michael Büsch
On Fri,  3 Jun 2016 14:32:46 -0700
Guenter Roeck  wrote:

> gcc-6 reports the following error with -Werror=unused-const-variable.
> 
> drivers/net/wireless/broadcom/b43/phy_a.c:576:40: error:
>   'b43_phyops_a' defined but not used
> 
> Turns out a lot of code in this file is unused, so let's remove it.


All a-phy code is usused.
So you can basically remove the whole file and any other A-PHY code.
... or just leave it as-is.


-- 
Michael


pgp1cjpfcyKcc.pgp
Description: OpenPGP digital signature


[Patch net] net_sched: keep backlog updated with qlen

2016-06-03 Thread Cong Wang
For gso_skb we only update qlen, backlog should be updated too.

Note, it is correct to just update these stats at one layer,
because the gso_skb is cached there.

Reported-by: Stas Nichiporovich 
Fixes: 2f5fb43f ("net_sched: update hierarchical backlog too")
Cc: Jamal Hadi Salim 
Signed-off-by: Cong Wang 
---
 include/net/sch_generic.h | 5 -
 net/sched/sch_generic.c   | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index a1fd76c..6803af1 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -691,9 +691,11 @@ static inline struct sk_buff *qdisc_peek_dequeued(struct 
Qdisc *sch)
/* we can reuse ->gso_skb because peek isn't called for root qdiscs */
if (!sch->gso_skb) {
sch->gso_skb = sch->dequeue(sch);
-   if (sch->gso_skb)
+   if (sch->gso_skb) {
/* it's still part of the queue */
+   qdisc_qstats_backlog_inc(sch, sch->gso_skb);
sch->q.qlen++;
+   }
}
 
return sch->gso_skb;
@@ -706,6 +708,7 @@ static inline struct sk_buff *qdisc_dequeue_peeked(struct 
Qdisc *sch)
 
if (skb) {
sch->gso_skb = NULL;
+   qdisc_qstats_backlog_dec(sch, skb);
sch->q.qlen--;
} else {
skb = sch->dequeue(sch);
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 269dd71..f9e0e9c 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -49,6 +49,7 @@ static inline int dev_requeue_skb(struct sk_buff *skb, struct 
Qdisc *q)
 {
q->gso_skb = skb;
q->qstats.requeues++;
+   qdisc_qstats_backlog_inc(q, skb);
q->q.qlen++;/* it's still part of the queue */
__netif_schedule(q);
 
@@ -92,6 +93,7 @@ static struct sk_buff *dequeue_skb(struct Qdisc *q, bool 
*validate,
txq = skb_get_tx_queue(txq->dev, skb);
if (!netif_xmit_frozen_or_stopped(txq)) {
q->gso_skb = NULL;
+   qdisc_qstats_backlog_dec(q, skb);
q->q.qlen--;
} else
skb = NULL;
-- 
2.1.0



Re: [PATCH v2] soreuseport: add compat case for setsockopt SO_ATTACH_REUSEPORT_CBPF

2016-06-03 Thread Helge Deller
Commit 538950a1b752 ("soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF")
missed to add the compat case for the SO_ATTACH_REUSEPORT_CBPF option.

Signed-off-by: Helge Deller 

diff --git a/net/compat.c b/net/compat.c
index 5cfd26a..1373947 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -354,7 +354,8 @@ static int do_set_sock_timeout(struct socket *sock, int 
level,
 static int compat_sock_setsockopt(struct socket *sock, int level, int optname,
char __user *optval, unsigned int optlen)
 {
-   if (optname == SO_ATTACH_FILTER)
+   if (optname == SO_ATTACH_FILTER ||
+   optname == SO_ATTACH_REUSEPORT_CBPF)
return do_set_attach_filter(sock, level, optname,
optval, optlen);
if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)


[PATCH] iwlwifi: Remove unused array 'iwlagn_loose_lookup'

2016-06-03 Thread Guenter Roeck
gcc-6 reports the following error if -Werror=unused-const-variable
is enabled.

drivers/net/wireless/intel/iwlwifi/dvm/lib.c:210:21: error:
'iwlagn_loose_lookup' defined but not used

Signed-off-by: Guenter Roeck 
---
 drivers/net/wireless/intel/iwlwifi/dvm/lib.c | 17 -
 1 file changed, 17 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/lib.c 
b/drivers/net/wireless/intel/iwlwifi/dvm/lib.c
index 8dda52ae3bb5..6c2d6da7eec6 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/lib.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/lib.c
@@ -205,23 +205,6 @@ static const __le32 
iwlagn_def_3w_lookup[IWLAGN_BT_DECISION_LUT_SIZE] = {
cpu_to_le32(0xf0005000),
 };
 
-
-/* Loose Coex */
-static const __le32 iwlagn_loose_lookup[IWLAGN_BT_DECISION_LUT_SIZE] = {
-   cpu_to_le32(0x),
-   cpu_to_le32(0x),
-   cpu_to_le32(0xaeaa),
-   cpu_to_le32(0x),
-   cpu_to_le32(0xcc00ff28),
-   cpu_to_le32(0x),
-   cpu_to_le32(0xcc00),
-   cpu_to_le32(0x),
-   cpu_to_le32(0x),
-   cpu_to_le32(0x),
-   cpu_to_le32(0xf0005000),
-   cpu_to_le32(0xf0005000),
-};
-
 /* Full concurrency */
 static const __le32 iwlagn_concurrent_lookup[IWLAGN_BT_DECISION_LUT_SIZE] = {
cpu_to_le32(0x),
-- 
2.5.0



Re: [PATCH] soreuseport: add compat case for setsockopt SO_ATTACH_REUSEPORT_CBPF

2016-06-03 Thread Alexei Starovoitov
On Fri, Jun 03, 2016 at 05:33:09PM -0400, Craig Gallek wrote:
> On Fri, Jun 3, 2016 at 5:09 PM, Helge Deller  wrote:
> > Any idea for a better naming than "do_sockopt_fix_sock_fprog()" ?
> Thanks for catching and fixing this.  I'd suggest simply leaving the
> function name as-is.  Your fix to the condition in that function is
> sufficient to address the issue.

+1
and thanks for the fixes!



[PATCH] b43: Remove unused phy_a code

2016-06-03 Thread Guenter Roeck
gcc-6 reports the following error with -Werror=unused-const-variable.

drivers/net/wireless/broadcom/b43/phy_a.c:576:40: error:
'b43_phyops_a' defined but not used

Turns out a lot of code in this file is unused, so let's remove it.

Reported-by: Fengguang Wu  [0-day test robot]
Signed-off-by: Guenter Roeck 
---
 drivers/net/wireless/broadcom/b43/phy_a.c | 298 --
 1 file changed, 298 deletions(-)

diff --git a/drivers/net/wireless/broadcom/b43/phy_a.c 
b/drivers/net/wireless/broadcom/b43/phy_a.c
index 99c036f5ecb7..d9212dc276d0 100644
--- a/drivers/net/wireless/broadcom/b43/phy_a.c
+++ b/drivers/net/wireless/broadcom/b43/phy_a.c
@@ -60,25 +60,6 @@ static inline u16 freq_r3A_value(u16 frequency)
return value;
 }
 
-#if 0
-/* This function converts a TSSI value to dBm in Q5.2 */
-static s8 b43_aphy_estimate_power_out(struct b43_wldev *dev, s8 tssi)
-{
-   struct b43_phy *phy = >phy;
-   struct b43_phy_a *aphy = phy->a;
-   s8 dbm = 0;
-   s32 tmp;
-
-   tmp = (aphy->tgt_idle_tssi - aphy->cur_idle_tssi + tssi);
-   tmp += 0x80;
-   tmp = clamp_val(tmp, 0x00, 0xFF);
-   dbm = aphy->tssi2dbm[tmp];
-   //TODO: There's a FIXME on the specs
-
-   return dbm;
-}
-#endif
-
 static void b43_radio_set_tx_iq(struct b43_wldev *dev)
 {
static const u8 data_high[5] = { 0x00, 0x40, 0x80, 0x90, 0xD0 };
@@ -314,282 +295,3 @@ void b43_phy_inita(struct b43_wldev *dev)
b43_phy_maskset(dev, B43_PHY_OFDM(0x6E), 0xE000, 0x3CF);
}
 }
-
-/* Initialise the TSSI->dBm lookup table */
-static int b43_aphy_init_tssi2dbm_table(struct b43_wldev *dev)
-{
-   struct b43_phy *phy = >phy;
-   struct b43_phy_a *aphy = phy->a;
-   s16 pab0, pab1, pab2;
-
-   pab0 = (s16) (dev->dev->bus_sprom->pa1b0);
-   pab1 = (s16) (dev->dev->bus_sprom->pa1b1);
-   pab2 = (s16) (dev->dev->bus_sprom->pa1b2);
-
-   if (pab0 != 0 && pab1 != 0 && pab2 != 0 &&
-   pab0 != -1 && pab1 != -1 && pab2 != -1) {
-   /* The pabX values are set in SPROM. Use them. */
-   if ((s8) dev->dev->bus_sprom->itssi_a != 0 &&
-   (s8) dev->dev->bus_sprom->itssi_a != -1)
-   aphy->tgt_idle_tssi =
-   (s8) (dev->dev->bus_sprom->itssi_a);
-   else
-   aphy->tgt_idle_tssi = 62;
-   aphy->tssi2dbm = b43_generate_dyn_tssi2dbm_tab(dev, pab0,
-  pab1, pab2);
-   if (!aphy->tssi2dbm)
-   return -ENOMEM;
-   } else {
-   /* pabX values not set in SPROM,
-* but APHY needs a generated table. */
-   aphy->tssi2dbm = NULL;
-   b43err(dev->wl, "Could not generate tssi2dBm "
-  "table (wrong SPROM info)!\n");
-   return -ENODEV;
-   }
-
-   return 0;
-}
-
-static int b43_aphy_op_allocate(struct b43_wldev *dev)
-{
-   struct b43_phy_a *aphy;
-   int err;
-
-   aphy = kzalloc(sizeof(*aphy), GFP_KERNEL);
-   if (!aphy)
-   return -ENOMEM;
-   dev->phy.a = aphy;
-
-   err = b43_aphy_init_tssi2dbm_table(dev);
-   if (err)
-   goto err_free_aphy;
-
-   return 0;
-
-err_free_aphy:
-   kfree(aphy);
-   dev->phy.a = NULL;
-
-   return err;
-}
-
-static void b43_aphy_op_prepare_structs(struct b43_wldev *dev)
-{
-   struct b43_phy *phy = >phy;
-   struct b43_phy_a *aphy = phy->a;
-   const void *tssi2dbm;
-   int tgt_idle_tssi;
-
-   /* tssi2dbm table is constant, so it is initialized at alloc time.
-* Save a copy of the pointer. */
-   tssi2dbm = aphy->tssi2dbm;
-   tgt_idle_tssi = aphy->tgt_idle_tssi;
-
-   /* Zero out the whole PHY structure. */
-   memset(aphy, 0, sizeof(*aphy));
-
-   aphy->tssi2dbm = tssi2dbm;
-   aphy->tgt_idle_tssi = tgt_idle_tssi;
-
-   //TODO init struct b43_phy_a
-
-}
-
-static void b43_aphy_op_free(struct b43_wldev *dev)
-{
-   struct b43_phy *phy = >phy;
-   struct b43_phy_a *aphy = phy->a;
-
-   kfree(aphy->tssi2dbm);
-   aphy->tssi2dbm = NULL;
-
-   kfree(aphy);
-   dev->phy.a = NULL;
-}
-
-static int b43_aphy_op_init(struct b43_wldev *dev)
-{
-   b43_phy_inita(dev);
-
-   return 0;
-}
-
-static inline u16 adjust_phyreg(struct b43_wldev *dev, u16 offset)
-{
-   /* OFDM registers are base-registers for the A-PHY. */
-   if ((offset & B43_PHYROUTE) == B43_PHYROUTE_OFDM_GPHY) {
-   offset &= ~B43_PHYROUTE;
-   offset |= B43_PHYROUTE_BASE;
-   }
-
-#if B43_DEBUG
-   if ((offset & B43_PHYROUTE) == B43_PHYROUTE_EXT_GPHY) {
-   /* Ext-G registers are only available on G-PHYs */
-   b43err(dev->wl, "Invalid EXT-G PHY access at "
-  "0x%04X on 

Re: [PATCH] soreuseport: add compat case for setsockopt SO_ATTACH_REUSEPORT_CBPF

2016-06-03 Thread Craig Gallek
On Fri, Jun 3, 2016 at 5:09 PM, Helge Deller  wrote:
> Any idea for a better naming than "do_sockopt_fix_sock_fprog()" ?
Thanks for catching and fixing this.  I'd suggest simply leaving the
function name as-is.  Your fix to the condition in that function is
sufficient to address the issue.

Craig


Re: [PATCH net-next 16/17] arm: dt: vf610-zii-devel-b: Make use of new DSA binding

2016-06-03 Thread Vivien Didelot
Andrew Lunn  writes:

> Hang the three switches of the three MDIO busses using the new DSA
> binding. Also, make use of the mdio-bus and explicitly list the phys
> on one device. This is not required, but good for testing.
>
> Signed-off-by: Andrew Lunn 

Reviewed-by: Vivien Didelot 


Re: [PATCH v4 net-next 00/13] net: hns: add support of ACPI

2016-06-03 Thread Rafael J. Wysocki
On Friday, June 03, 2016 10:55:08 AM Yisen Zhuang wrote:
> From: Kejian Yan 
> 
> This series adds HNS support of acpi. The routine will call some ACPI
> helper functions, like acpi_dev_found() and acpi_evaluate_dsm(), which
> are not included in other cases. In order to make system compile
> successfully in other cases except ACPI, it needs to add relative stub
> functions to linux/acpi.h. And we use device property functions instead
> of serial helper functions to suport both DT and ACPI cases. And then
> add the supports of ACPI for HNS.
> 
> change log:
>  v3->v4:
>   mii-id gets from dev-name instead of address
> 
>  v2->v3:
>  1. add Review-by: Andy Shevchenko
>  2. fix the potential memory leak
> 
>  v1 -> v2:
>  1. use acpi_dev_found() instead of acpi_match_device_ids() to check if
> it is a acpi node.
>  2. use is_of_node() instead of IS_ENABLED() to check if it is a DT node.
>  3. split the patch("add support of acpi for hns-mdio") into two patches:
> 3.1 Move to use fwnode_handle
> 3.2 Add ACPI
>  4. add the patch which subject is dsaf misc operation method
>  5. fix the comments by Andy Shevchenko
> 
> Kejian Yan (13):
>   ACPI: bus: add stub acpi_dev_found() to linux/acpi.h
>   ACPI: bus: add stub acpi_evaluate_dsm() to linux/acpi.h

Which patches need these stubs?

Thanks,
Rafael



Re: [PATCH] soreuseport: Fix reuseport_bpf testcase on 32bit architectures

2016-06-03 Thread Craig Gallek
On Fri, Jun 3, 2016 at 1:19 PM, Helge Deller  wrote:
> This fixes the following compiler warnings when compiling the
> reuseport_bpf testcase on a 32 bit platform:
>
> reuseport_bpf.c: In function ‘attach_ebpf’:
> reuseport_bpf.c:114:15: warning: cast from pointer to integer of ifferent 
> size [-Wpointer-to-int-cast]
>
> Signed-off-by: Helge Deller 
Acked-by: Craig Gallek 

Thanks!


Re: [PATCH net-next 17/17] net: dsa: Document new binding

2016-06-03 Thread Vivien Didelot
Andrew Lunn  writes:

> Add the new binding to the documentation of the existing binding.
> Mark the old binding as deprecated.
>
> Signed-off-by: Andrew Lunn 
> Signed-off-by: Florian Fainelli 

Reviewed-by: Vivien Didelot 


Re: [PATCH net-next 09/17] net: dsa: Split up creating/destroying of DSA and CPU ports

2016-06-03 Thread Florian Fainelli
On 06/03/2016 09:44 AM, Andrew Lunn wrote:
> Refactor the code to setup a single DSA/CPU port into a function of
> its own, and export it, so it can be used by the new binding.
> 
> Similarly, refactor the destroy code into a function.  When destroying
> the ports, don't put the of node. They should be released at the end
> along with the normal ports.
> 
> Signed-off-by: Andrew Lunn 

Reviewed-by: Florian Fainelli 
-- 
Florian


Re: [PATCH net-next 08/17] net: dsa: Copy the routing table into the switch structure

2016-06-03 Thread Florian Fainelli
On 06/03/2016 09:44 AM, Andrew Lunn wrote:
> The new binding will not have a chip data structure, it will place the
> routing directly into the switch structure. To enable backwards
> compatibility, copy the routing from the chip data into the switch
> structure.
> 
> Signed-off-by: Andrew Lunn 

Reviewed-by: Florian Fainelli 
-- 
Florian


Re: [PATCH net-next 10/17] net: dsa: mv88e6xxx: Only support EDSA tagging

2016-06-03 Thread Florian Fainelli
On 06/03/2016 09:44 AM, Andrew Lunn wrote:
> The merged driver no longer offers the option to use DSA tagging. So
> remove the code to setup the switch to do DSA tagging and hard code
> the use of EDSA.
> 
> Signed-off-by: Andrew Lunn 

Reviewed-by: Florian Fainelli 
-- 
Florian


Re: [PATCH net-next 15/17] net: dsa: Add new binding implementation

2016-06-03 Thread Florian Fainelli
On 06/03/2016 09:44 AM, Andrew Lunn wrote:
> The existing DSA binding has a number of limitations and problems. The
> main problem is that it cannot represent a switch as a linux device,
> hanging off some bus. It is limited to one CPU port. The DSA platform
> device is artificial, and does not really represent hardware.
> 
> Implement a new binding which can be embedded into any type of node on
> a bus to represent one switch device, and its links to other switches.
> 
> Signed-off-by: Andrew Lunn 
> Signed-off-by: Florian Fainelli 

Just a few nits that I had not seen before...


> diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
> index 6c314f300424..d8cb2acd4f0a 100644
> --- a/net/dsa/dsa.c
> +++ b/net/dsa/dsa.c
> @@ -294,6 +294,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, 
> struct device *parent)
>   }
>   dst->cpu_switch = index;
>   dst->cpu_port = i;
> + ds->cpu_port_mask |= 1 << i;
>   } else if (!strcmp(name, "dsa")) {
>   ds->dsa_port_mask |= 1 << i;
>   } else {

We might want to undo setting the cpu_port_mask bit in
dsa_cpu_dsa_destroy()?

[snip]

> +static int dsa_ds_complete(struct dsa_switch_tree *dst, struct dsa_switch 
> *ds)
> +{
> + struct device_node *port;
> + u32 index;
> + int err;
> +
> + for (index = 0; index < DSA_MAX_PORTS; index++) {
> + port = ds->ports[index].dn;
> + if (!port)
> + continue;
> +
> + if (!dsa_port_is_dsa(port))
> + continue;
> +
> + ds->dsa_port_mask |= 1 << index;
> +
> + err = dsa_port_complete(dst, ds, port, index);
> + if (err != 0)

Should we move ds->dsa_port_mask |= 1 << index into dsa_port_complete,
for a) symetry with code undoing this, and b) avoid letting this bit be
set in case dsa_port_complete() returns an error?
-- 
Florian


Re: [PATCH net-next 02/17] net: dsa: mv88e6xxx: fix circular lock in PPU work

2016-06-03 Thread Florian Fainelli
On 06/03/2016 09:44 AM, Andrew Lunn wrote:
> From: Vivien Didelot 
> 
> Lock debugging shows that there is a possible circular lock in the PPU
> work code. Switch the lock order of smi_mutex and ppu_mutex to fix this.
> 
> Here's the full trace:
> 
> [4.341325] ==
> [4.347519] [ INFO: possible circular locking dependency detected ]
> [4.353800] 4.6.0 #4 Not tainted
> [4.357039] ---
> [4.363315] kworker/0:1/328 is trying to acquire lock:
> [4.368463]  (>smi_mutex){+.+.+.}, at: [<8049c758>] 
> mv88e6xxx_reg_read+0x30/0x54
> [4.376313]
> [4.376313] but task is already holding lock:
> [4.382160]  (>ppu_mutex){+.+...}, at: [<8049cac0>] 
> mv88e6xxx_ppu_reenable_work+0x28/0xd4
> [4.390772]
> [4.390772] which lock already depends on the new lock.
> [4.390772]
> [4.398963]
> [4.398963] the existing dependency chain (in reverse order) is:
> [4.406461]
> [4.406461] -> #1 (>ppu_mutex){+.+...}:
> [4.410897][<806d86bc>] mutex_lock_nested+0x54/0x360
> [4.416606][<8049a800>] mv88e6xxx_ppu_access_get+0x28/0x100
> [4.422906][<8049b778>] mv88e6xxx_phy_read+0x90/0xdc
> [4.428599][<806a4534>] dsa_slave_phy_read+0x3c/0x40
> [4.434300][<804943ec>] mdiobus_read+0x68/0x80
> [4.439481][<804939d4>] get_phy_device+0x58/0x1d8
> [4.444914][<80493ed0>] mdiobus_scan+0x24/0xf4
> [4.450078][<8049409c>] __mdiobus_register+0xfc/0x1ac
> [4.455857][<806a40b0>] dsa_probe+0x860/0xca8
> [4.460934][<8043246c>] platform_drv_probe+0x5c/0xc0
> [4.466627][<804305a0>] driver_probe_device+0x118/0x450
> [4.472589][<80430b00>] __device_attach_driver+0xac/0x128
> [4.478724][<8042e350>] bus_for_each_drv+0x74/0xa8
> [4.484235][<804302d8>] __device_attach+0xc4/0x154
> [4.489755][<80430cec>] device_initial_probe+0x1c/0x20
> [4.495612][<8042f620>] bus_probe_device+0x98/0xa0
> [4.501123][<8042fbd0>] deferred_probe_work_func+0x4c/0xd4
> [4.507328][<8013a794>] process_one_work+0x1a8/0x604
> [4.513030][<8013ac54>] worker_thread+0x64/0x528
> [4.518367][<801409e8>] kthread+0xec/0x100
> [4.523201][<80108f30>] ret_from_fork+0x14/0x24
> [4.528462]
> [4.528462] -> #0 (>smi_mutex){+.+.+.}:
> [4.532895][<8015ad5c>] lock_acquire+0xb4/0x1dc
> [4.538154][<806d86bc>] mutex_lock_nested+0x54/0x360
> [4.543856][<8049c758>] mv88e6xxx_reg_read+0x30/0x54
> [4.549549][<8049cad8>] mv88e6xxx_ppu_reenable_work+0x40/0xd4
> [4.556022][<8013a794>] process_one_work+0x1a8/0x604
> [4.561707][<8013ac54>] worker_thread+0x64/0x528
> [4.567053][<801409e8>] kthread+0xec/0x100
> [4.571878][<80108f30>] ret_from_fork+0x14/0x24
> [4.577139]
> [4.577139] other info that might help us debug this:
> [4.577139]
> [4.585159]  Possible unsafe locking scenario:
> [4.585159]
> [4.591093]CPU0CPU1
> [4.595631]
> [4.600169]   lock(>ppu_mutex);
> [4.603693]lock(>smi_mutex);
> [4.609742]lock(>ppu_mutex);
> [4.615790]   lock(>smi_mutex);
> [4.619314]
> [4.619314]  *** DEADLOCK ***
> [4.619314]
> [4.625256] 3 locks held by kworker/0:1/328:
> [4.629537]  #0:  ("events"){.+.+..}, at: [<8013a704>] 
> process_one_work+0x118/0x604
> [4.637288]  #1:  ((>ppu_work)){+.+...}, at: [<8013a704>] 
> process_one_work+0x118/0x604
> [4.645653]  #2:  (>ppu_mutex){+.+...}, at: [<8049cac0>] 
> mv88e6xxx_ppu_reenable_work+0x28/0xd4
> [4.654714]
> [4.654714] stack backtrace:
> [4.659098] CPU: 0 PID: 328 Comm: kworker/0:1 Not tainted 4.6.0 #4
> [4.665286] Hardware name: Freescale Vybrid VF5xx/VF6xx (Device Tree)
> [4.671748] Workqueue: events mv88e6xxx_ppu_reenable_work
> [4.677174] Backtrace:
> [4.679674] [<8010d354>] (dump_backtrace) from [<8010d5a0>] 
> (show_stack+0x20/0x24)
> [4.687252]  r6:80fb3c88 r5:80fb3c88 r4:80fb4728 r3:0002
> [4.693003] [<8010d580>] (show_stack) from [<803b45e8>] 
> (dump_stack+0x24/0x28)
> [4.700246] [<803b45c4>] (dump_stack) from [<80157398>] 
> (print_circular_bug+0x208/0x32c)
> [4.708361] [<80157190>] (print_circular_bug) from [<8015a630>] 
> (__lock_acquire+0x185c/0x1b80)
> [4.716982]  r10:9ec22a00 

Re: [PATCH net-next 07/17] net: dsa: Remove dynamic allocate of routing table

2016-06-03 Thread Florian Fainelli
On 06/03/2016 09:44 AM, Andrew Lunn wrote:
> With a maximum of four switches, the size of the routing table is the
> same as the pointer to it. Removing it makes the code simpler.
> 
> Signed-off-by: Andrew Lunn 

Reviewed-by: Florian Fainelli 
-- 
Florian


Re: [PATCH] soreuseport: add compat case for setsockopt SO_ATTACH_REUSEPORT_CBPF

2016-06-03 Thread Helge Deller
On 03.06.2016 20:11, Sergei Shtylyov wrote:
> Hello.
> 
> On 06/03/2016 08:18 PM, Helge Deller wrote:
> 
>> Commit 538950a ("soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF")
> 
>At least 12 digits must be specified for SHA1. checkpatch.pl should've 
> caught this.

Ok.

>> missed to add the compat case for the SO_ATTACH_REUSEPORT_CBPF
>> setsockoption() option.
>>
>> Since both SO_ATTACH_FILTER and SO_ATTACH_REUSEPORT_CBPF use a struct
>> sock_fprog let's combine the handling of both.
>>
>> Signed-off-by: Helge Deller 
>>
>> diff --git a/net/compat.c b/net/compat.c
>> index 5cfd26a..7e2aac9 100644
>> --- a/net/compat.c
>> +++ b/net/compat.c
>> @@ -309,7 +309,7 @@ void scm_detach_fds_compat(struct msghdr *kmsg, struct 
>> scm_cookie *scm)
>>  __scm_destroy(scm);
>>  }
>>
>> -static int do_set_attach_filter(struct socket *sock, int level, int optname,
>> +static int do_sockopt_fix_sock_fprog(struct socket *sock, int level, int 
>> optname,
>>  char __user *optval, unsigned int optlen)
> 
>You need to realign this line now.

Sure, I will send an updated patch.

Any idea for a better naming than "do_sockopt_fix_sock_fprog()" ?

Helge


[PATCHv2 net-next] net: igb: Only dma sync frame length

2016-06-03 Thread Andrew Lunn
On some platforms, syncing a buffer for DMA is expensive. Rather than
sync the whole 2K receive buffer, only synchronise the length of the
frame, which will typically be the MTU, or a much smaller TCP ACK.

For an IMX6Q, this gives around 6% increased TCP receive performance,
which is cache operations bound and reduces CPU load for TCP transmit.

Signed-off-by: Andrew Lunn 
---
v2:
Christmas tree the local variables
Pass size into igb_add_rx_frag() rather than repeating the endiness swap.
---
 drivers/net/ethernet/intel/igb/igb_main.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index 0a289dda604a..8fa9e6e8c3b0 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -6856,12 +6856,12 @@ static bool igb_can_reuse_rx_page(struct igb_rx_buffer 
*rx_buffer,
  **/
 static bool igb_add_rx_frag(struct igb_ring *rx_ring,
struct igb_rx_buffer *rx_buffer,
+   unsigned int size,
union e1000_adv_rx_desc *rx_desc,
struct sk_buff *skb)
 {
struct page *page = rx_buffer->page;
unsigned char *va = page_address(page) + rx_buffer->page_offset;
-   unsigned int size = le16_to_cpu(rx_desc->wb.upper.length);
 #if (PAGE_SIZE < 8192)
unsigned int truesize = IGB_RX_BUFSZ;
 #else
@@ -6913,6 +6913,7 @@ static struct sk_buff *igb_fetch_rx_buffer(struct 
igb_ring *rx_ring,
   union e1000_adv_rx_desc *rx_desc,
   struct sk_buff *skb)
 {
+   unsigned int size = le16_to_cpu(rx_desc->wb.upper.length);
struct igb_rx_buffer *rx_buffer;
struct page *page;
 
@@ -6948,11 +6949,11 @@ static struct sk_buff *igb_fetch_rx_buffer(struct 
igb_ring *rx_ring,
dma_sync_single_range_for_cpu(rx_ring->dev,
  rx_buffer->dma,
  rx_buffer->page_offset,
- IGB_RX_BUFSZ,
+ size,
  DMA_FROM_DEVICE);
 
/* pull page into skb */
-   if (igb_add_rx_frag(rx_ring, rx_buffer, rx_desc, skb)) {
+   if (igb_add_rx_frag(rx_ring, rx_buffer, size, rx_desc, skb)) {
/* hand second half of page back to the ring */
igb_reuse_rx_page(rx_ring, rx_buffer);
} else {
-- 
2.8.1



[PATCH v3] virtio-net: Add initial MTU advice feature

2016-06-03 Thread Aaron Conole
This commit adds the feature bit and associated mtu device entry for the
virtio network device.  When a virtio device comes up, it checks the
feature bit for the VIRTIO_NET_F_MTU feature.  If such feature bit is
enabled, the driver will read the advised MTU and use it as the initial
value.

Signed-off-by: Aaron Conole 
---
v2->v3:
* Added a check for the MTU, and a bit clear for it being out of range.

 drivers/net/virtio_net.c| 10 ++
 include/uapi/linux/virtio_net.h |  3 +++
 2 files changed, 13 insertions(+)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index e0638e5..192f321 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1780,6 +1780,7 @@ static int virtnet_probe(struct virtio_device *vdev)
struct net_device *dev;
struct virtnet_info *vi;
u16 max_queue_pairs;
+   int mtu;
 
if (!vdev->config->get) {
dev_err(>dev, "%s failure: config access disabled\n",
@@ -1896,6 +1897,14 @@ static int virtnet_probe(struct virtio_device *vdev)
if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ))
vi->has_cvq = true;
 
+   if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) {
+   mtu = virtio_cread16(vdev,
+offsetof(struct virtio_net_config,
+ mtu));
+   if (virtnet_change_mtu(dev, mtu))
+   __virtio_clear_bit(vdev, VIRTIO_NET_F_MTU);
+   }
+
if (vi->any_header_sg)
dev->needed_headroom = vi->hdr_len;
 
@@ -2067,6 +2076,7 @@ static unsigned int features[] = {
VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,
VIRTIO_NET_F_CTRL_MAC_ADDR,
VIRTIO_F_ANY_LAYOUT,
+   VIRTIO_NET_F_MTU,
 };
 
 static struct virtio_driver virtio_net_driver = {
diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
index ec32293..1ab4ea6 100644
--- a/include/uapi/linux/virtio_net.h
+++ b/include/uapi/linux/virtio_net.h
@@ -55,6 +55,7 @@
 #define VIRTIO_NET_F_MQ22  /* Device supports Receive Flow
 * Steering */
 #define VIRTIO_NET_F_CTRL_MAC_ADDR 23  /* Set MAC address */
+#define VIRTIO_NET_F_MTU 25/* Initial MTU advice */
 
 #ifndef VIRTIO_NET_NO_LEGACY
 #define VIRTIO_NET_F_GSO   6   /* Host handles pkts w/ any GSO type */
@@ -73,6 +74,8 @@ struct virtio_net_config {
 * Legal values are between 1 and 0x8000
 */
__u16 max_virtqueue_pairs;
+   /* Default maximum transmit unit advice */
+   __u16 mtu;
 } __attribute__((packed));
 
 /*
-- 
2.5.5



Re: [RFC PATCH 0/4] Make inotify instance/watches be accounted per userns

2016-06-03 Thread Eric W. Biederman
Nikolay Borisov  writes:

> On 06/02/2016 07:58 PM, Eric W. Biederman wrote:
>> 
>> Nikolay please see my question for you at the end.
[snip] 
>> All of that said there is definitely a practical question that needs to
>> be asked.  Nikolay how did you get into this situation?  A typical user
>> namespace configuration will set up uid and gid maps with the help of a
>> privileged program and not map the uid of the user who created the user
>> namespace.  Thus avoiding exhausting the limits of the user who created
>> the container.
>
> Right but imagine having multiple containers with identical uid/gid maps
> for LXC-based setups imagine this:
>
> lxc.id_map = u 0 1337 65536

So I am only moderately concerned when the containers have overlapping
ids.  Because at some level overlapping ids means they are the same
user.  This is certainly true for file permissions and for other
permissions.  To isolate one container from another it fundamentally
needs to have separate uids and gids on the host system.

> Now all processes which are running with the same user on different
> containers will actually share the underlying user_struct thus the
> inotify limits. In such cases even running multiple instances of 'tail'
> in one container will eventually use all allowed inotify/mark instances.
> For this to happen you needn't also have complete overlap of the uid
> map, it's enough to have at least one UID between 2 containers overlap.
>
>
> So the risk of exhaustion doesn't apply to the privileged user that
> created the container and the uid mapping, but rather the users under
> which the various processes in the container are running. Does that make
> it clear?

Yes.  That is clear.

>> Which makes me personally more worried about escaping the existing
>> limits than exhausting the limits of a particular user.
>
> So I thought bit about it and I guess a solution can be concocted which
> utilize the hierarchical nature of page counter, and the inotify limits
> are set per namespace if you have capable(CAP_SYS_ADMIN). That way the
> admin can set one fairly large on the init_user_ns and then in every
> namespace created one can set smaller limits. That way for a branch in
> the tree (in the nomenclature you used in your previous reply to me) you
> will really be upper-bound to the limit set in the namespace which have
> ->level = 1. For the width of the tree, you will be bound by the
> "global" init_user_ns limits. How does that sound?

As a addendum to that design.  I think there should be an additional
sysctl or two that specifies how much the limit decreases when creating
a new user namespace and when creating a new user in that user
namespace.  That way with a good selection of limits and a limit
decrease people can use the kernel defaults without needing to change
them.

Having default settings that are good enough 99% of the time and that
people don't need to tune, would be my biggest requirement (aside from
being light-weight) for merging something like this.

If things are set and forget and even the continer case does not need to
be aware then I think we have a design sufficiently robust and different
from what cgroups is doing to make it worth while to have a userns based
solution.

I can see a lot of different limits implemented this way.

Eric


[PATCH] libertas_tf: Drop unused variable and define

2016-06-03 Thread Guenter Roeck
gcc-6 reports:

drivers/net/wireless/marvell/libertas_tf/main.c:30:19: error:
'lbtf_driver_version' defined but not used

with -Werror=unused-const-variable=.

Reported-by: Fengguang Wu  [0-day test robot]
Signed-off-by: Guenter Roeck 
---
 drivers/net/wireless/marvell/libertas_tf/main.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/net/wireless/marvell/libertas_tf/main.c 
b/drivers/net/wireless/marvell/libertas_tf/main.c
index 0bf8916a02cf..75bf0c8a2f6f 100644
--- a/drivers/net/wireless/marvell/libertas_tf/main.c
+++ b/drivers/net/wireless/marvell/libertas_tf/main.c
@@ -16,7 +16,6 @@
 #include 
 #include "libertas_tf.h"
 
-#define DRIVER_RELEASE_VERSION "004.p0"
 /* thinfirm version: 5.132.X.pX */
 #define LBTF_FW_VER_MIN0x05840300
 #define LBTF_FW_VER_MAX0x0584
@@ -27,12 +26,6 @@ unsigned int lbtf_debug;
 EXPORT_SYMBOL_GPL(lbtf_debug);
 module_param_named(libertas_tf_debug, lbtf_debug, int, 0644);
 
-static const char lbtf_driver_version[] = "THINFIRM-USB8388-" 
DRIVER_RELEASE_VERSION
-#ifdef DEBUG
-   "-dbg"
-#endif
-   "";
-
 struct workqueue_struct *lbtf_wq;
 
 static const struct ieee80211_channel lbtf_channels[] = {
-- 
2.5.0



[PATCH net-next 0/2] tcp: add NV congestion control

2016-06-03 Thread Lawrence Brakmo
This version of NV does much better than previous versions when things are
very congested and also adds a couple of experimental features.

Tested in a rack using between 1 and 380 active TCP-NV flows.

Consists of the following patches:
[PATCH net-next 1/2] tcp: add in_flight to tcp_skb_cb
[PATCH net-next 2/2] tcp: add NV congestion control

Signed-off-by: Lawrence Brakmo 

include/net/tcp.h |   2 +
net/ipv4/Kconfig  |  16 ++
net/ipv4/Makefile |   1 +
net/ipv4/tcp_input.c  |   5 +-
net/ipv4/tcp_nv.c | 597 

net/ipv4/tcp_output.c |   4 +-
6 files changed, 623 insertions(+), 2 deletions(-)


[PATCH net-next 1/2] tcp: add in_flight to tcp_skb_cb

2016-06-03 Thread Lawrence Brakmo
Add in_flight (bytes in flight when packet was sent) field
to tx component of tcp_skb_cb and make it available to
congestion modules' pkts_acked() function through the
ack_sample function argument.

Signed-off-by: Lawrence Brakmo 
Acked-by: Yuchung Cheng 
---
 include/net/tcp.h | 2 ++
 net/ipv4/tcp_input.c  | 5 -
 net/ipv4/tcp_output.c | 4 +++-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 0bcc70f..a79894b 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -767,6 +767,7 @@ struct tcp_skb_cb {
union {
struct {
/* There is space for up to 20 bytes */
+   __u32 in_flight;/* Bytes in flight when packet sent */
} tx;   /* only used for outgoing skbs */
union {
struct inet_skb_parmh4;
@@ -859,6 +860,7 @@ union tcp_cc_info;
 struct ack_sample {
u32 pkts_acked;
s32 rtt_us;
+   u32 in_flight;
 };
 
 struct tcp_congestion_ops {
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index d6c8f4cd0..c7f33f0 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3115,6 +3115,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int 
prior_fackets,
long ca_rtt_us = -1L;
struct sk_buff *skb;
u32 pkts_acked = 0;
+   u32 last_in_flight = 0;
bool rtt_update;
int flag = 0;
 
@@ -3154,6 +3155,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int 
prior_fackets,
if (!first_ackt.v64)
first_ackt = last_ackt;
 
+   last_in_flight = TCP_SKB_CB(skb)->tx.in_flight;
reord = min(pkts_acked, reord);
if (!after(scb->end_seq, tp->high_seq))
flag |= FLAG_ORIG_SACK_ACKED;
@@ -3250,7 +3252,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, int 
prior_fackets,
 
if (icsk->icsk_ca_ops->pkts_acked) {
struct ack_sample sample = { .pkts_acked = pkts_acked,
-.rtt_us = ca_rtt_us };
+.rtt_us = ca_rtt_us,
+.in_flight = last_in_flight };
 
icsk->icsk_ca_ops->pkts_acked(sk, );
}
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 8bd9911..b1bcba0 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -911,9 +911,12 @@ static int tcp_transmit_skb(struct sock *sk, struct 
sk_buff *skb, int clone_it,
int err;
 
BUG_ON(!skb || !tcp_skb_pcount(skb));
+   tp = tcp_sk(sk);
 
if (clone_it) {
skb_mstamp_get(>skb_mstamp);
+   TCP_SKB_CB(skb)->tx.in_flight = TCP_SKB_CB(skb)->end_seq
+   - tp->snd_una;
 
if (unlikely(skb_cloned(skb)))
skb = pskb_copy(skb, gfp_mask);
@@ -924,7 +927,6 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff 
*skb, int clone_it,
}
 
inet = inet_sk(sk);
-   tp = tcp_sk(sk);
tcb = TCP_SKB_CB(skb);
memset(, 0, sizeof(opts));
 
-- 
2.8.0.rc2



Re: [PATCH net-next 00/17] New DSA bind, switches as devices

2016-06-03 Thread Vivien Didelot
Andrew Lunn  writes:

> The interesting patches here are the last three. They implement a new
> binding for DSA, which removes a few limitations of the current DSA
> binding. In particular, it allows switches to be true Linux devices.
> These devices can be on any type of bus, unlike the old DSA binding
> which assumes MDIO. See the commit log for more details. The second to
> last patch modifies an existing boards device tree to use the new
> binding, giving a good example of how switches can be true MDIO
> devices. The last patch documents the new binding.
>
> I know both John Crispin and Bryan Whitehead are interesting in
> implementing DSA drivers, hence i have CC: you. Comments welcome.
>
> Thanks go to Florian and Vivien for reviewing, testing and bug fixing
> these patches.
>
> Since RFC:
>
> * Split the mv88e6xxx MDIO refactor into a rename patch and a refactor
>   patch.
> * Extend commit message with comment about wrong of_node_put()
> * Fix destroy of cpu and dsa ports.
> * Rename _DSA_TAG_LAST to DSA_TAG_LAST and add a comment.

This patchset works fine on a 3-mv88e6xxx setup with the old bindings.

Tested-by: Vivien Didelot 

Thanks,

Vivien


[PATCH net-next 2/2] tcp: add NV congestion control

2016-06-03 Thread Lawrence Brakmo
TCP-NV (New Vegas) is a major update to TCP-Vegas.
An earlier version of NV was presented at 2010's LPC.
It is a delayed based congestion avoidance for the
data center. This version has been tested within a
10G rack where the HW RTTs are 20-50us.

A description of TCP-NV, including implementation
details as well as experimental results, can be found at:
http://www.brakmo.org/networking/tcp-nv/TCPNV.html

The current version includes many module parameters to support
experimentation with the parameters.

Signed-off-by: Lawrence Brakmo 
---
 net/ipv4/Kconfig  |  16 ++
 net/ipv4/Makefile |   1 +
 net/ipv4/tcp_nv.c | 597 ++
 3 files changed, 614 insertions(+)
 create mode 100644 net/ipv4/tcp_nv.c

diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index 238225b..50d6a9b 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -532,6 +532,22 @@ config TCP_CONG_VEGAS
window. TCP Vegas should provide less packet loss, but it is
not as aggressive as TCP Reno.
 
+config TCP_CONG_NV
+   tristate "TCP NV"
+   default n
+   ---help---
+   TCP NV is a follow up to TCP Vegas. It has been modified to deal with
+   10G networks, measurement noise introduced by LRO, GRO and interrupt
+   coalescence. In addition, it will decrease its cwnd multiplicatively
+   instead of linearly.
+
+   Note that in general congestion avoidance (cwnd decreased when # packets
+   queued grows) cannot coexist with congestion control (cwnd decreased 
only
+   when there is packet loss) due to fairness issues. One scenario when 
they
+   can coexist safely is when the CA flows have RTTs << CC flows RTTs.
+
+   For further details see http://www.brakmo.org/networking/tcp-nv/
+
 config TCP_CONG_SCALABLE
tristate "Scalable TCP"
default n
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
index bfa1336..24629b6 100644
--- a/net/ipv4/Makefile
+++ b/net/ipv4/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_TCP_CONG_HSTCP) += tcp_highspeed.o
 obj-$(CONFIG_TCP_CONG_HYBLA) += tcp_hybla.o
 obj-$(CONFIG_TCP_CONG_HTCP) += tcp_htcp.o
 obj-$(CONFIG_TCP_CONG_VEGAS) += tcp_vegas.o
+obj-$(CONFIG_TCP_CONG_NV) += tcp_nv.o
 obj-$(CONFIG_TCP_CONG_VENO) += tcp_veno.o
 obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o
 obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o
diff --git a/net/ipv4/tcp_nv.c b/net/ipv4/tcp_nv.c
new file mode 100644
index 000..1a69215
--- /dev/null
+++ b/net/ipv4/tcp_nv.c
@@ -0,0 +1,597 @@
+/*
+ * TCP NV: TCP with Congestion Avoidance
+ *
+ * TCP-NV is a successor of TCP-Vegas that has been developed to
+ * deal with the issues that occur in modern networks.
+ * Like TCP-Vegas, TCP-NV supports true congestion avoidance,
+ * the ability to detect congestion before packet losses occur.
+ * When congestion (queue buildup) starts to occur, TCP-NV
+ * predicts what the cwnd size should be for the current
+ * throughput and it reduces the cwnd proportionally to
+ * the difference between the current cwnd and the predicted cwnd.
+ * TCP-NV behaves like Reno when no congestion is detected, or when
+ * recovering from packet losses.
+ *
+ * Note: High NIC coalescence values may lower the performance of NV
+ * due to the increased noise in RTT values. In particular, we have
+ * seen issues with rx-frames values greater than 8.
+ *
+ * TODO:
+ * 1) Add mechanism to deal with reverse congestion.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* TCP NV parameters
+ *
+ * nv_enable   Behaves like Reno if disabled
+ * nv_pad  Packets queued to trigger congestion detection
+ * nv_pad_buffer   Below this packets queued trigger cwnd growth
+ * nv_reset_period Who often (in) seconds)to reset min_rtt
+ * nv_min_cwnd Don't decrease cwnd below this if there are no losses
+ * nv_cong_dec_multDecrease cwnd by X% (30%) of congestion when detected
+ * nv_ssthresh_factor  On congestion set ssthresh to this *  / 8
+ * nv_rtt_factor   RTT averaging factor
+ * nv_rtt_cnt_dec_delta Periodically decrease cwnd for this many RTTs
+ * nv_dec_factor and this factor (temp cwnd = cwnd * this / 8)
+ * nv_loss_dec_factor  Decrease cwnd by this (50%) when losses occur
+ * nv_dec_eval_min_calls   Wait this many RTT measurements before dec cwnd
+ * nv_inc_eval_min_calls   Wait this many RTT measurements before inc cwnd
+ * nv_ssthresh_eval_min_calls  Wait this many RTT measurements before stopping
+ * slow-start due to congestion
+ * nv_stop_rtt_cnt Only grow cwnd for this many RTTs after non-congestion
+ * nv_rtt_min_cnt  Wait these many RTTs before making congesion decision
+ * nv_min_min_rtt  Lower bound for min_rtt
+ * nv_max_min_rtt  Upper bound for min_rtt
+ * Experimental feature. NV is unlikely to converge to an accurate minRTT
+ * in very congested networks. Both these parameters allow setting
+ * appropriate bounds to 

Re: [Intel-wired-lan] [PATCH] net: igb: Only dma sync frame length

2016-06-03 Thread Alexander Duyck
On Fri, Jun 3, 2016 at 10:45 AM, Andrew Lunn  wrote:
> On some platforms, syncing a buffer for DMA is expensive. Rather than
> sync the whole 2K receive buffer, only synchronise the length of the
> frame, which will typically be the MTU, or a much smaller TCP ACK.
>
> For an IMX6Q, this gives around 6% increased TCP receive performance,
> which is cache operations bound and reduces CPU load for TCP transmit.
>
> Signed-off-by: Andrew Lunn 
> ---
>  drivers/net/ethernet/intel/igb/igb_main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
> b/drivers/net/ethernet/intel/igb/igb_main.c
> index 0a289dda604a..670e3d612283 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -6915,6 +6915,7 @@ static struct sk_buff *igb_fetch_rx_buffer(struct 
> igb_ring *rx_ring,
>  {
> struct igb_rx_buffer *rx_buffer;
> struct page *page;
> +   unsigned int size = le16_to_cpu(rx_desc->wb.upper.length);
>

You should probably place this variable at the top of the declaration
list.  The preference for the netdev tree is to have variables in a
reverse xmas tree order where the longest declarations are at the top
and the shortest are at the bottom.

> rx_buffer = _ring->rx_buffer_info[rx_ring->next_to_clean];
> page = rx_buffer->page;
> @@ -6948,7 +6949,7 @@ static struct sk_buff *igb_fetch_rx_buffer(struct 
> igb_ring *rx_ring,
> dma_sync_single_range_for_cpu(rx_ring->dev,
>   rx_buffer->dma,
>   rx_buffer->page_offset,
> - IGB_RX_BUFSZ,
> + size,
>   DMA_FROM_DEVICE);
>
> /* pull page into skb */

You might also want to consider adding size as a variable to
igb_add_rx_frag.  That way you don't have to worry about it being read
and byte-swapped a second time.

- Alex


Re: [PATCH net-next] cxgb4: Reduce resource allocation in kdump kernel

2016-06-03 Thread Casey Leedom
  Looks good to me.  Of course I came up with those changes so maybe we should 
get another reviewer? :-)  Also, don't forget to mention "Bug #29998" in the 
commit message ...

Casey


From: Hariprasad Shenai 
Sent: Friday, June 3, 2016 10:35:45 AM
To: da...@davemloft.net
Cc: netdev@vger.kernel.org; Casey Leedom; Nirranjan Kirubaharan; Hariprasad S
Subject: [PATCH net-next] cxgb4: Reduce resource allocation in kdump kernel

When is_kdump_kernel() is true, reduce our memory footprint by only using
a single "Queue Set" and Forcing Master so we can reinitialize the
Firmware/Chip.

Signed-off-by: Hariprasad Shenai 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 477db477b133..5317187d0073 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -64,6 +64,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "cxgb4.h"
 #include "t4_regs.h"
@@ -3735,7 +3736,8 @@ static int adap_init0(struct adapter *adap)
return ret;

/* Contact FW, advertising Master capability */
-   ret = t4_fw_hello(adap, adap->mbox, adap->mbox, MASTER_MAY, );
+   ret = t4_fw_hello(adap, adap->mbox, adap->mbox,
+ is_kdump_kernel() ? MASTER_MUST : MASTER_MAY, );
if (ret < 0) {
dev_err(adap->pdev_dev, "could not connect to FW, error %d\n",
ret);
@@ -4366,6 +4368,14 @@ static void cfg_queues(struct adapter *adap)
if (q10g > netif_get_num_default_rss_queues())
q10g = netif_get_num_default_rss_queues();

+   /* Reduce memory usage in kdump environment by using only one queue
+* and disable all offload.
+*/
+   if (is_kdump_kernel()) {
+   q10g = 1;
+   adap->params.offload = 0;
+   }
+
for_each_port(adap, i) {
struct port_info *pi = adap2pinfo(adap, i);

--
2.3.4



Re: [PATCH stable] Set a large MTU on ovs-created tunnel devices

2016-06-03 Thread Dan Streetman
On Fri, Jun 3, 2016 at 2:44 PM, David Miller  wrote:
> From: Dan Streetman 
> Date: Fri, 3 Jun 2016 13:49:09 -0400
>
>> Can you queue up these commits for stable?
>
> This stuff doesn't cleanly backport, I tried several times already.

ah sorry.  i'll get a backport.

>
> Therfore, someone knowledgable with OVS is going to have to do the
> backport, test it, and post it for me to submit.
>
> Thanks.


Re: [PATCH net-next 15/17] net: dsa: Add new binding implementation

2016-06-03 Thread Vivien Didelot
Andrew Lunn  writes:

> The existing DSA binding has a number of limitations and problems. The
> main problem is that it cannot represent a switch as a linux device,
> hanging off some bus. It is limited to one CPU port. The DSA platform
> device is artificial, and does not really represent hardware.
>
> Implement a new binding which can be embedded into any type of node on
> a bus to represent one switch device, and its links to other switches.
>
> Signed-off-by: Andrew Lunn 
> Signed-off-by: Florian Fainelli 

Reviewed-by: Vivien Didelot 


Re: [PATCH net-next 14/17] net: dsa: mv88e6xxx: Refactor MDIO so driver registers mdio bus

2016-06-03 Thread Vivien Didelot
Andrew Lunn  writes:

> Have the switch driver register its own MDIO bus. This allows for an
> mdio property in the device tree, with child nodes for phys, which
> can be referenced via phandles, etc.
>
> Signed-off-by: Andrew Lunn 

Reviewed-by: Vivien Didelot 


Re: [PATCH net-next] tcp: accept RST if SEQ matches right edge of SACK block

2016-06-03 Thread Neal Cardwell
On Fri, Jun 3, 2016 at 3:44 PM, Neal Cardwell  wrote:
> On Fri, Jun 3, 2016 at 12:24 PM, Eric Dumazet  wrote:
>> On Fri, 2016-06-03 at 11:45 -0400, Neal Cardwell wrote:
>>> But I would also vote to tighten up the proposed logic slightly, and
>>> only check the seq of the incoming RST against the right edge of the
>>> *right-most* SACK block. That is, the code could loop through the
>>> tp->selective_acks to find the right-most of the right edges of the
>>> SACK blocks (the end_seq that has no other end_seq after() it). AFAICT
>>> it makes sense to expect that a legitimate incoming RST might match
>>> rcv_nxt, or might match the right-most edge of the right-most SACK.
>>> But allowing a RST to match a sequence of some SACK in the middle of
>>> the sequence range would seem to only increase the attack surface for
>>> RST attacks.
>>
>> Well, the most recent info would be in [0], no need to iterate, right ?
>>
>> So only look at the first sack block in the array, even if we have 3 or
>> 4 blocks there.
>
> Yes, good point. It should only need to check the first SACK block in
> the selective_acks  array.

Well, hmm. The most recent SACK block may not be the right-most one,
if there is reordering or packets are retransmitted. So AFAICT if we
wanted to try hard to just use the right-most SACK block we'd need to
check all the blocks.

But just checking the first SACK block seems like a reasonable
trade-off in terms of simplicity.

I don't feel strongly either way.

neal


Re: [PATCH net-next] tcp: accept RST if SEQ matches right edge of SACK block

2016-06-03 Thread Neal Cardwell
On Fri, Jun 3, 2016 at 12:24 PM, Eric Dumazet  wrote:
> On Fri, 2016-06-03 at 11:45 -0400, Neal Cardwell wrote:
>> But I would also vote to tighten up the proposed logic slightly, and
>> only check the seq of the incoming RST against the right edge of the
>> *right-most* SACK block. That is, the code could loop through the
>> tp->selective_acks to find the right-most of the right edges of the
>> SACK blocks (the end_seq that has no other end_seq after() it). AFAICT
>> it makes sense to expect that a legitimate incoming RST might match
>> rcv_nxt, or might match the right-most edge of the right-most SACK.
>> But allowing a RST to match a sequence of some SACK in the middle of
>> the sequence range would seem to only increase the attack surface for
>> RST attacks.
>
> Well, the most recent info would be in [0], no need to iterate, right ?
>
> So only look at the first sack block in the array, even if we have 3 or
> 4 blocks there.

Yes, good point. It should only need to check the first SACK block in
the selective_acks  array.

neal


Re: [PATCH net-next 13/17] net: dsa: mv88e6xxx: Rename _phy_ to _mdio_

2016-06-03 Thread Vivien Didelot
Andrew Lunn  writes:

> The switch implements a generic MDIO bus, which could host more than
> PHYs. It is conventional to use _mdio_ or _mii_ in the function name,
> so rename them. Also postfix make the historically first read/write
> function with _direct, to help distinguish it from _indirect and _ppu.
>
> While touching these functions, remove some of the _ prefixes, which
> we are deprecating.
>
> Signed-off-by: Andrew Lunn 

Reviewed-by: Vivien Didelot 


[PATCH net-next v3 1/2] net: Add l3mdev rule

2016-06-03 Thread David Ahern
Currently, VRFs require 1 oif and 1 iif rule per address family per
VRF. As the number of VRF devices increases it brings scalability
issues with the increasing rule list. All of the VRF rules have the
same format with the exception of the specific table id to direct the
lookup. Since the table id is available from the oif or iif in the
loopup, the VRF rules can be consolidated to a single rule that pulls
the table from the VRF device.

This patch introduces a new rule attribute l3mdev. The l3mdev rule
means the table id used for the lookup is pulled from the L3 master
device (e.g., VRF) rather than being statically defined. With the
l3mdev rule all of the basic VRF FIB rules are reduced to 1 l3mdev
rule per address family (IPv4 and IPv6).

If an admin wishes to insert higher priority rules for specific VRFs
those rules will co-exist with the l3mdev rule. This capability means
current VRF scripts will co-exist with this new simpler implementation.

Currently, the rules list for both ipv4 and ipv6 look like this:
$ ip  ru ls
1000:   from all oif vrf1 lookup 1001
1000:   from all iif vrf1 lookup 1001
1000:   from all oif vrf2 lookup 1002
1000:   from all iif vrf2 lookup 1002
1000:   from all oif vrf3 lookup 1003
1000:   from all iif vrf3 lookup 1003
1000:   from all oif vrf4 lookup 1004
1000:   from all iif vrf4 lookup 1004
1000:   from all oif vrf5 lookup 1005
1000:   from all iif vrf5 lookup 1005
1000:   from all oif vrf6 lookup 1006
1000:   from all iif vrf6 lookup 1006
1000:   from all oif vrf7 lookup 1007
1000:   from all iif vrf7 lookup 1007
1000:   from all oif vrf8 lookup 1008
1000:   from all iif vrf8 lookup 1008
...
32765:  from all lookup local
32766:  from all lookup main
32767:  from all lookup default

With the l3mdev rule the list is just the following regardless of the
number of VRFs:
$ ip ru ls
1000:   from all lookup [l3mdev table]
32765:  from all lookup local
32766:  from all lookup main
32767:  from all lookup default

(Note: the above pretty print of the rule is based on an iproute2
   prototype. Actual verbage may change)

Signed-off-by: David Ahern 
---
v3
- no change to this patch

v2
- if CONFIG_NET_L3_MASTER_DEV is not enabled changed the inline
  l3mdev_fib_rule_match function to return 1 rather than 0 allowing
  the compiler to completely drop the check:
 if (rule->l3mdev && !l3mdev_fib_rule_match())

- moved setting of tb_id down to its use fib4_rule_action which
  addresses Dave's comment about reverse xmas tree order. Same
  change for ipv6 version.

 include/net/fib_rules.h| 24 ++--
 include/net/l3mdev.h   | 12 
 include/uapi/linux/fib_rules.h |  1 +
 net/core/fib_rules.c   | 33 -
 net/ipv4/fib_rules.c   |  6 --
 net/ipv6/fib6_rules.c  |  6 --
 net/l3mdev/l3mdev.c| 38 ++
 7 files changed, 109 insertions(+), 11 deletions(-)

diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index 59160de702b6..456e4a6006ab 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -17,7 +17,8 @@ struct fib_rule {
u32 flags;
u32 table;
u8  action;
-   /* 3 bytes hole, try to use */
+   u8  l3mdev;
+   /* 2 bytes hole, try to use */
u32 target;
__be64  tun_id;
struct fib_rule __rcu   *ctarget;
@@ -36,6 +37,7 @@ struct fib_lookup_arg {
void*lookup_ptr;
void*result;
struct fib_rule *rule;
+   u32 table;
int flags;
 #define FIB_LOOKUP_NOREF   1
 #define FIB_LOOKUP_IGNORE_LINKSTATE2
@@ -89,7 +91,8 @@ struct fib_rules_ops {
[FRA_TABLE] = { .type = NLA_U32 }, \
[FRA_SUPPRESS_PREFIXLEN] = { .type = NLA_U32 }, \
[FRA_SUPPRESS_IFGROUP] = { .type = NLA_U32 }, \
-   [FRA_GOTO]  = { .type = NLA_U32 }
+   [FRA_GOTO]  = { .type = NLA_U32 }, \
+   [FRA_L3MDEV]= { .type = NLA_U8 }
 
 static inline void fib_rule_get(struct fib_rule *rule)
 {
@@ -102,6 +105,20 @@ static inline void fib_rule_put(struct fib_rule *rule)
kfree_rcu(rule, rcu);
 }
 
+#ifdef CONFIG_NET_L3_MASTER_DEV
+static inline u32 fib_rule_get_table(struct fib_rule *rule,
+struct fib_lookup_arg *arg)
+{
+   return rule->l3mdev ? arg->table : rule->table;
+}
+#else
+static inline u32 fib_rule_get_table(struct fib_rule *rule,
+struct fib_lookup_arg *arg)
+{
+   return rule->table;
+}

[PATCH net-next v3 0/2] net: vrf: Improve use of FIB rules

2016-06-03 Thread David Ahern
Currently, VRFs require 1 oif and 1 iif rule per address family per
VRF. As the number of VRF devices increases it brings scalability
issues with the increasing rule list. All of the VRF rules have the
same format with the exception of the specific table id to direct the
lookup. Since the table id is available from the oif or iif in the
loopup, the VRF rules can be consolidated to a single rule that pulls
the table from the VRF device.

This solution still allows a user to insert their own rules for VRFs,
including rules with additional attributes. Accordingly, it is backwards
compatible with existing setups and allows other policy routing as
desired.

David Ahern (2):
  net: Add l3mdev rule
  net: vrf: Add l3mdev rules on first device create

 drivers/net/vrf.c  | 120 -
 include/net/fib_rules.h|  24 -
 include/net/l3mdev.h   |  12 +
 include/uapi/linux/fib_rules.h |   1 +
 net/core/fib_rules.c   |  33 ++--
 net/ipv4/fib_rules.c   |   6 ++-
 net/ipv6/fib6_rules.c  |   6 ++-
 net/l3mdev/l3mdev.c|  38 +
 8 files changed, 228 insertions(+), 12 deletions(-)

-- 
2.1.4



[PATCH net-next v3 2/2] net: vrf: Add l3mdev rules on first device create

2016-06-03 Thread David Ahern
Add l3mdev rule per address family when the first VRF device is
created. Remove them when the last is deleted.

Signed-off-by: David Ahern 
---
v3
- per Nik's comment changed num_vrfs from atomic to unsigned int; all
  accesses are with rtnl held

v2
- added EXCL flag and EEXISTS check. Appropriate once the exclude fib rule
  patch is accepted
- changed 3rd arg to vrf_fib_rule from 0/1 to false/true

 drivers/net/vrf.c | 120 +-
 1 file changed, 119 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index d356f5d0f7b0..d81eabe951f5 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define RT_FL_TOS(oldflp4) \
((oldflp4)->flowi4_tos & (IPTOS_RT_MASK | RTO_ONLINK))
@@ -42,6 +43,12 @@
 #define DRV_NAME   "vrf"
 #define DRV_VERSION"1.0"
 
+/* only referenced with rtnl held */
+static unsigned int num_vrfs;
+
+static u32 rule_pref = 1000;
+module_param(rule_pref, uint,  S_IRUGO);
+
 struct net_vrf {
struct rtable __rcu *rth;
struct rt6_info __rcu   *rt6;
@@ -729,6 +736,98 @@ static const struct ethtool_ops vrf_ethtool_ops = {
.get_drvinfo= vrf_get_drvinfo,
 };
 
+static inline size_t vrf_fib_rule_nl_size(void)
+{
+   size_t sz;
+
+   sz  = NLMSG_ALIGN(sizeof(struct fib_rule_hdr));
+   sz += nla_total_size(sizeof(u8));   /* FRA_L3MDEV */
+   sz += nla_total_size(sizeof(u32));  /* FRA_PRIORITY */
+
+   return sz;
+}
+
+static int vrf_fib_rule(const struct net_device *dev, __u8 family, bool add_it)
+{
+   struct fib_rule_hdr *frh;
+   struct nlmsghdr *nlh;
+   struct sk_buff *skb;
+   int err;
+
+   skb = nlmsg_new(vrf_fib_rule_nl_size(), GFP_KERNEL);
+   if (!skb)
+   return -ENOMEM;
+
+   nlh = nlmsg_put(skb, 0, 0, 0, sizeof(*frh), 0);
+   if (!nlh)
+   goto nla_put_failure;
+
+   /* rule only needs to appear once */
+   nlh->nlmsg_flags &= NLM_F_EXCL;
+
+   frh = nlmsg_data(nlh);
+   memset(frh, 0, sizeof(*frh));
+   frh->family = family;
+   frh->action = FR_ACT_TO_TBL;
+
+   if (nla_put_u32(skb, FRA_L3MDEV, 1))
+   goto nla_put_failure;
+
+   if (nla_put_u32(skb, FRA_PRIORITY, rule_pref))
+   goto nla_put_failure;
+
+   nlmsg_end(skb, nlh);
+
+   /* fib_nl_{new,del}rule handling looks for net from skb->sk */
+   skb->sk = dev_net(dev)->rtnl;
+   if (add_it) {
+   err = fib_nl_newrule(skb, nlh);
+   if (err == -EEXIST)
+   err = 0;
+   } else {
+   err = fib_nl_delrule(skb, nlh);
+   if (err == -ENOENT)
+   err = 0;
+   }
+   nlmsg_free(skb);
+
+   return err;
+
+nla_put_failure:
+   nlmsg_free(skb);
+
+   return -EMSGSIZE;
+}
+
+static void vrf_del_fib_rules(const struct net_device *dev)
+{
+   if (vrf_fib_rule(dev, AF_INET,  false) ||
+   vrf_fib_rule(dev, AF_INET6, false)) {
+   netdev_err(dev, "Failed to delete FIB rules.\n");
+   }
+}
+
+static int vrf_add_fib_rules(const struct net_device *dev)
+{
+   int err;
+
+   err = vrf_fib_rule(dev, AF_INET,  true);
+   if (err < 0)
+   goto out_err;
+
+   err = vrf_fib_rule(dev, AF_INET6, true);
+   if (err < 0)
+   goto out_err;
+
+   return 0;
+
+out_err:
+   netdev_err(dev, "Failed to add FIB rules.\n");
+   vrf_del_fib_rules(dev);
+
+   return err;
+}
+
 static void vrf_setup(struct net_device *dev)
 {
ether_setup(dev);
@@ -763,12 +862,17 @@ static int vrf_validate(struct nlattr *tb[], struct 
nlattr *data[])
 static void vrf_dellink(struct net_device *dev, struct list_head *head)
 {
unregister_netdevice_queue(dev, head);
+
+   num_vrfs--;
+   if (!num_vrfs)
+   vrf_del_fib_rules(dev);
 }
 
 static int vrf_newlink(struct net *src_net, struct net_device *dev,
   struct nlattr *tb[], struct nlattr *data[])
 {
struct net_vrf *vrf = netdev_priv(dev);
+   int err;
 
if (!data || !data[IFLA_VRF_TABLE])
return -EINVAL;
@@ -777,7 +881,21 @@ static int vrf_newlink(struct net *src_net, struct 
net_device *dev,
 
dev->priv_flags |= IFF_L3MDEV_MASTER;
 
-   return register_netdevice(dev);
+   err = register_netdevice(dev);
+   if (err)
+   goto out;
+
+   if (!num_vrfs) {
+   err = vrf_add_fib_rules(dev);
+   if (err) {
+   unregister_netdevice(dev);
+   goto out;
+   }
+   }
+
+   num_vrfs++;
+out:
+   return err;
 }
 
 static size_t vrf_nl_getsize(const struct net_device *dev)
-- 
2.1.4



Re: [PATCH] net: ethernet: ti: cpsw: remove rx_descs property

2016-06-03 Thread Ivan Khoronzhuk



On 03.06.16 22:13, Grygorii Strashko wrote:

On 06/03/2016 09:25 PM, Ivan Khoronzhuk wrote:



On 03.06.16 19:50, Grygorii Strashko wrote:

On 06/03/2016 01:43 AM, Ivan Khoronzhuk wrote:

There is no reason to hold s/w dependent parameter in device tree.
Even more, there is no reason in this parameter because davinici_cpdma
driver splits pool of descriptors equally between tx and rx channels.
That is, if number of descriptors 256, 128 of them are for rx
channels. While receiving, the descriptor is freed to the pool and
then allocated with new skb. And if in DT the "rx_descs" is set to
64, then 128 - 64 = 64 descriptors are always in the pool and cannot
be used, for tx, for instance. It's not correct resource usage,
better to set it to half of pool, then the rx pool can be used in
full. It will not have any impact on performance, as anyway, the
"redundant" descriptors were unused.

Signed-off-by: Ivan Khoronzhuk 
---

Based on master

   Documentation/devicetree/bindings/net/cpsw.txt |  3 ---
   arch/arm/boot/dts/am33xx.dtsi  |  1 -
   arch/arm/boot/dts/am4372.dtsi  |  1 -
   arch/arm/boot/dts/dm814x.dtsi  |  1 -
   arch/arm/boot/dts/dra7.dtsi|  1 -



Pls, split DT and non-DT changes, seems code changes should go first.

Ok.




   drivers/net/ethernet/ti/cpsw.c | 13 +++--
   drivers/net/ethernet/ti/cpsw.h |  1 -
   drivers/net/ethernet/ti/davinci_cpdma.c|  6 ++
   drivers/net/ethernet/ti/davinci_cpdma.h|  1 +
   9 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/cpsw.txt
b/Documentation/devicetree/bindings/net/cpsw.txt
index 0ae0649..5fe6239 100644
--- a/Documentation/devicetree/bindings/net/cpsw.txt
+++ b/Documentation/devicetree/bindings/net/cpsw.txt
@@ -15,7 +15,6 @@ Required properties:
   - cpdma_channels : Specifies number of channels in CPDMA
   - ale_entries: Specifies No of entries ALE can hold
   - bd_ram_size: Specifies internal descriptor RAM size
-- rx_descs: Specifies number of Rx descriptors
   - mac_control: Specifies Default MAC control register content
 for the specific platform
   - slaves: Specifies number for slaves
@@ -70,7 +69,6 @@ Examples:


[]


   slaves = <2>;
   active_slave = <0>;
diff --git a/drivers/net/ethernet/ti/cpsw.c
b/drivers/net/ethernet/ti/cpsw.c
index 4b08a2f..635be3e 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1277,6 +1277,7 @@ static int cpsw_ndo_open(struct net_device *ndev)
 ALE_ALL_PORTS, ALE_ALL_PORTS, 0, 0);

   if (!cpsw_common_res_usage_state(priv)) {
+int buf_num;
   struct cpsw_priv *priv_sl0 = cpsw_get_slave_priv(priv, 0);

   /* setup tx dma to fixed prio and zero offset */
@@ -1305,10 +1306,8 @@ static int cpsw_ndo_open(struct net_device *ndev)
   enable_irq(priv->irqs_table[0]);
   }

-if (WARN_ON(!priv->data.rx_descs))
-priv->data.rx_descs = 128;
-
-for (i = 0; i < priv->data.rx_descs; i++) {
+buf_num = cpdma_chan_get_buf_num(priv->dma) / 2;


Could you get rid of "/ 2", pls?


Why? compiler is smart enough to translate it to shift.
And this is not time critical place.
Anyway, will change it to >> 1 while splitting.



I mean here that cpsw, in general, should not have any knowledge about rules
  used by cpdma to split pool on rx and tx part. How about 
cpdma_chan_get_rx_buf_num()?

Yes, it be correct.
Will change it in v2






--
Regards,
Ivan Khoronzhuk


Re: [PATCH] rtl8xxxu: fix typo on variable name, compare against correct variable

2016-06-03 Thread Jes Sorensen
Colin King  writes:
> From: Colin Ian King 
>
> path_b_ok is being assigned but immediately after path_a_ok is being
> compared to the value 0x03.  This appears to be a typo on the
> variable name, compare path_b_ok instead.
>
> Signed-off-by: Colin Ian King 
> ---
>  drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c 
> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
> index fe19ace..b04cf30 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
> @@ -1149,7 +1149,7 @@ static void rtl8192eu_phy_iqcalibrate(struct 
> rtl8xxxu_priv *priv,
>  
>   for (i = 0; i < retry; i++) {
>   path_b_ok = rtl8192eu_rx_iqk_path_b(priv);
> - if (path_a_ok == 0x03) {
> + if (path_b_ok == 0x03) {
>   val32 = rtl8xxxu_read32(priv,
>   
> REG_RX_POWER_BEFORE_IQK_B_2);
>   result[t][6] = (val32 >> 16) & 0x3ff;

Nice catch, that does indeed look like a bug!

Thanks, I want to test it, but I plan to apply it to rtl8xxxu-devel
shortly.

Cheers,
Jes


  1   2   3   >