net: icmp vs udp_poll race?

2017-06-02 Thread Levin, Alexander (Sasha Levin)
Hi all,

On the latest linux-next I'm seeing issues that look like an icmp
socket destruction racing with poll(). It manifests in two ways, first:

BUG: KASAN: slab-out-of-bounds in skb_queue_empty include/linux/skbuff.h:1197 
[inline]
BUG: KASAN: slab-out-of-bounds in udp_poll+0x5fb/0x6f0 net/ipv4/udp.c:2443
Read of size 8 at addr 88006941a200 by task syz-executor5/9052

CPU: 2 PID: 9052 Comm: syz-executor5 Not tainted 4.12.0-rc3-next-20170601+ #47
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-1ubuntu1 
04/01/2014
Call Trace:
 __dump_stack lib/dump_stack.c:16 [inline]
 dump_stack+0x115/0x1d1 lib/dump_stack.c:52
 print_address_description+0xe7/0x370 mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report+0x1b0/0x450 mm/kasan/report.c:408
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:429
 skb_queue_empty include/linux/skbuff.h:1197 [inline]
 udp_poll+0x5fb/0x6f0 net/ipv4/udp.c:2443
 sock_poll+0x169/0x410 net/socket.c:1101
 do_pollfd fs/select.c:825 [inline]
 do_poll fs/select.c:875 [inline]
 do_sys_poll+0x7a7/0x13b0 fs/select.c:969
 SYSC_poll fs/select.c:1027 [inline]
 SyS_poll+0x106/0x460 fs/select.c:1015
 do_syscall_64+0x275/0x810 arch/x86/entry/common.c:284
 entry_SYSCALL64_slow_path+0x25/0x25
RIP: 0033:0x451429
RSP: 002b:7fee2df0dc08 EFLAGS: 0216 ORIG_RAX: 0007
RAX: ffda RBX: 2fb0 RCX: 00451429
RDX: 001f RSI: 000a RDI: 2fb0
RBP: 00718000 R08:  R09: 
R10:  R11: 0216 R12: 
R13: 000a R14: 03c4 R15: 7fee2df0e700

Allocated by task 9052:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x43/0xd0 mm/kasan/kasan.c:513
 set_track mm/kasan/kasan.c:525 [inline]
 kasan_kmalloc+0xae/0xe0 mm/kasan/kasan.c:617
 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:555
 slab_post_alloc_hook mm/slab.h:456 [inline]
 slab_alloc_node mm/slub.c:2712 [inline]
 slab_alloc mm/slub.c:2720 [inline]
 kmem_cache_alloc+0x12f/0x610 mm/slub.c:2725
 sk_prot_alloc+0x6e/0x300 net/core/sock.c:1422
 sk_alloc+0x82/0x880 net/core/sock.c:1484
 inet_create+0x519/0x11b0 net/ipv4/af_inet.c:318
 __sock_create+0x52e/0xa50 net/socket.c:1249
 sock_create net/socket.c:1289 [inline]
 SYSC_socket net/socket.c:1319 [inline]
 SyS_socket+0x105/0x260 net/socket.c:1299
 do_syscall_64+0x275/0x810 arch/x86/entry/common.c:284
 return_from_SYSCALL_64+0x0/0x7a

Freed by task 8076:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x43/0xd0 mm/kasan/kasan.c:513
 set_track mm/kasan/kasan.c:525 [inline]
 kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:590
 slab_free_hook mm/slub.c:1357 [inline]
 slab_free_freelist_hook mm/slub.c:1379 [inline]
 slab_free mm/slub.c:2955 [inline]
 kmem_cache_free+0xec/0x630 mm/slub.c:2977
 sk_prot_free net/core/sock.c:1465 [inline]
 __sk_destruct+0x6a1/0xb40 net/core/sock.c:1546
 sk_destruct+0x57/0xb0 net/core/sock.c:1554
 __sk_free+0x62/0x260 net/core/sock.c:1562
 sk_free+0x28/0x40 net/core/sock.c:1573
 sock_put include/net/sock.h:1655 [inline]
 sk_common_release+0x241/0x3c0 net/core/sock.c:2902
 ping_close+0x15/0x20 net/ipv4/ping.c:295
 inet_release+0x108/0x240 net/ipv4/af_inet.c:425
 sock_release+0x96/0x260 net/socket.c:597
 SYSC_socketpair net/socket.c:1436 [inline]
 SyS_socketpair+0x522/0x710 net/socket.c:1340
 do_syscall_64+0x275/0x810 arch/x86/entry/common.c:284
 return_from_SYSCALL_64+0x0/0x7a

The buggy address belongs to the object at 880069419c40
 which belongs to the cache PING of size 1392
The buggy address is located 80 bytes to the right of
 1392-byte region [880069419c40, 88006941a1b0)
The buggy address belongs to the page:
page:ea0001a50600 count:1 mapcount:0 mapping:  (null) 
index:0x88006941d440 compound_mapcount: 0
flags: 0x5fffc008100(slab|head)
raw: 05fffc008100  88006941d440 000100120005
raw: 88006c5ba490 88006c5ba490 88006b197c40 
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 88006941a100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 88006941a180: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc
>88006941a200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
   ^
 88006941a280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 88006941a300: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb

And second:

INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.
CPU: 3 PID: 12664 Comm: syz-executor7 Not tainted 4.12.0-rc3-next-20170601+ #47
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-1ubuntu1 
04/01/2014
Call Trace:
 __dump_stack lib/dump_stack.c:16 [inline]
 dump_stack+0x115/0x1d1 lib/dump_stack.c:52
 register_lock_class+0x5a5/0x2ce0 

[PATCH net] net: dsa: Fix stale cpu_switch reference after unbind then bind

2017-06-02 Thread Florian Fainelli
Commit 9520ed8fb841 ("net: dsa: use cpu_switch instead of ds[0]")
replaced the use of dst->ds[0] with dst->cpu_switch since that is
functionally equivalent, however, we can now run into an use after free
scenario after unbinding then rebinding the switch driver.

The use after free happens because we do correctly initialize
dst->cpu_switch the first time we probe in dsa_cpu_parse(), then we
unbind the driver: dsa_dst_unapply() is called, and we rebind again.
dst->cpu_switch now points to a freed "ds" structure, and so when we
finally dereference it in dsa_cpu_port_ethtool_setup(), we oops.

To fix this, simply set dst->cpu_switch to NULL in dsa_dst_unapply()
which guarantees that we always correctly re-assign dst->cpu_switch in
dsa_cpu_parse().

Fixes: 9520ed8fb841 ("net: dsa: use cpu_switch instead of ds[0]")
Signed-off-by: Florian Fainelli 
---
David, please queue this up for 4.11-stable as well, thanks!

 net/dsa/dsa2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 033b3bfb63dc..7796580e99ee 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -484,8 +484,10 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
dsa_ds_unapply(dst, ds);
}
 
-   if (dst->cpu_switch)
+   if (dst->cpu_switch) {
dsa_cpu_port_ethtool_restore(dst->cpu_switch);
+   dst->cpu_switch = NULL;
+   }
 
pr_info("DSA: tree %d unapplied\n", dst->tree);
dst->applied = false;
-- 
2.9.3



[PATCH v2 2/3] PCI: Enable PCIe Relaxed Ordering if supported

2017-06-02 Thread Ding Tianhong
The PCIe Device Control Register use the bit 4 to indicate that
whether the device is permitted to enable relaxed ordering or not.
But relaxed ordering is not safe for some platform which could only
use strong write ordering, so devices are allowed (but not required)
to enable relaxed ordering bit by default.

If a platform support relaxed ordering but does not enable it by
default, enable it in the PCIe configuration. This allows some device
to send TLPs with the relaxed ordering attributes set, which may
improve the performance.

Signed-off-by: Ding Tianhong 
---
 drivers/pci/pci.c   | 42 ++
 drivers/pci/probe.c | 11 +++
 include/linux/pci.h |  3 +++
 3 files changed, 56 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b01bd5b..f57a374 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4878,6 +4878,48 @@ int pcie_set_mps(struct pci_dev *dev, int mps)
 EXPORT_SYMBOL(pcie_set_mps);
 
 /**
+ * pcie_set_relaxed_ordering - set PCI Express relexed ordering bit
+ * @dev: PCI device to query
+ *
+ * If possible sets relaxed ordering
+ */
+int pcie_set_relaxed_ordering(struct pci_dev *dev)
+{
+   return pcie_capability_set_word(dev, PCI_EXP_DEVCTL, 
PCI_EXP_DEVCTL_RELAX_EN);
+}
+EXPORT_SYMBOL(pcie_set_relaxed_ordering);
+
+/**
+ * pcie_clear_relaxed_ordering - clear PCI Express relexed ordering bit
+ * @dev: PCI device to query
+ *
+ * If possible clear relaxed ordering
+ */
+int pcie_clear_relaxed_ordering(struct pci_dev *dev)
+{
+   return pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, 
PCI_EXP_DEVCTL_RELAX_EN);
+}
+EXPORT_SYMBOL(pcie_clear_relaxed_ordering);
+
+/**
+ * pcie_get_relaxed_ordering - check PCI Express relexed ordering bit
+ * @dev: PCI device to query
+ *
+ * Returns true if relaxed ordering is been set
+ */
+int pcie_get_relaxed_ordering(struct pci_dev *dev)
+{
+   u16 v;
+
+   pcie_capability_read_word(dev, PCI_EXP_DEVCTL, );
+
+   return (v & PCI_EXP_DEVCTL_RELAX_EN) >> 4;
+}
+EXPORT_SYMBOL(pcie_get_relaxed_ordering);
+
+/**
+ * pcie_set_mps - set PCI Express maximum payload size
+/**
  * pcie_get_minimum_link - determine minimum link settings of a PCI device
  * @dev: PCI device to query
  * @speed: storage for minimum speed
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 19c8950..aeb22b5 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1701,6 +1701,16 @@ static void pci_configure_extended_tags(struct pci_dev 
*dev)
 PCI_EXP_DEVCTL_EXT_TAG);
 }
 
+static void pci_configure_relaxed_ordering(struct pci_dev *dev)
+{
+   int ret;
+
+   if (dev && (dev->dev_flags & PCI_DEV_FLAGS_NO_RELAXED_ORDERING))
+   pcie_set_relaxed_ordering(dev);
+   else
+   pcie_clear_relaxed_ordering(dev);
+}
+
 static void pci_configure_device(struct pci_dev *dev)
 {
struct hotplug_params hpp;
@@ -1708,6 +1718,7 @@ static void pci_configure_device(struct pci_dev *dev)
 
pci_configure_mps(dev);
pci_configure_extended_tags(dev);
+   pci_configure_relaxed_ordering(dev);
 
memset(, 0, sizeof(hpp));
ret = pci_get_hp_params(dev, );
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e1e8428..84bd6af 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1105,6 +1105,9 @@ int __pci_enable_wake(struct pci_dev *dev, pci_power_t 
state,
 void pci_pme_wakeup_bus(struct pci_bus *bus);
 void pci_d3cold_enable(struct pci_dev *dev);
 void pci_d3cold_disable(struct pci_dev *dev);
+int pcie_set_relaxed_ordering(struct pci_dev *dev);
+int pcie_clear_relaxed_ordering(struct pci_dev *dev);
+int pcie_get_relaxed_ordering(struct pci_dev *dev);
 
 static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
  bool enable)
-- 
1.9.0




[PATCH v2 3/3] net/cxgb4: Use new PCI_DEV_FLAGS_NO_RELAXED_ORDERING flag

2017-06-02 Thread Ding Tianhong
From: Casey Leedom 

cxgb4 Ethernet driver now queries Root Complex Port to determine if it can
send TLPs to it with the Relaxed Ordering Attribute set.

Signed-off-by: Casey Leedom 
Signed-off-by: Ding Tianhong 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |  1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 17 +
 drivers/net/ethernet/chelsio/cxgb4/sge.c|  5 +++--
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index e88c180..478f25a 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -521,6 +521,7 @@ enum { /* adapter flags */
USING_SOFT_PARAMS  = (1 << 6),
MASTER_PF  = (1 << 7),
FW_OFLD_CONN   = (1 << 9),
+   ROOT_NO_RELAXED_ORDERING = (1 << 10),
 };
 
 enum {
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 38a5c67..fbfe341 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4628,6 +4628,7 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 #ifdef CONFIG_PCI_IOV
u32 v, port_vec;
 #endif
+   struct pci_dev *root;
 
printk_once(KERN_INFO "%s - version %s\n", DRV_DESC, DRV_VERSION);
 
@@ -4726,6 +4727,22 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
adapter->msg_enable = DFLT_MSG_ENABLE;
memset(adapter->chan_map, 0xff, sizeof(adapter->chan_map));
 
+   /* If possible, we use PCIe Relaxed Ordering Attribute to deliver
+* Ingress Packet Data to Free List Buffers in order to allow for
+* chipset performance optimizations between the Root Complex and
+* Memory Controllers.  (Messages to the associated Ingress Queue
+* notifying new Packet Placement in the Free Lists Buffers will be
+* send without the Relaxed Ordering Attribute thus guaranteing that
+* all preceding PCIe Transaction Layer Packets will be processed
+* first.)  But some Root Complexes have various issues with Upstream
+* Transaction Layer Packets with the Relaxed Ordering Attribute set.
+* So we check our Root Complex to see if it's flaged with advice
+* against using Relaxed Ordering.
+*/
+   root = pci_find_pcie_root_port(adapter->pdev);
+   if (pcie_get_relaxed_ordering(root))
+   adapter->flags |= ROOT_NO_RELAXED_ORDERING;
+
spin_lock_init(>stats_lock);
spin_lock_init(>tid_release_lock);
spin_lock_init(>win0_lock);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index f05f0d4..ac229a3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2571,6 +2571,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct 
sge_rspq *iq, bool fwevtq,
struct fw_iq_cmd c;
struct sge *s = >sge;
struct port_info *pi = netdev_priv(dev);
+   int relaxed = !(adap->flags & ROOT_NO_RELAXED_ORDERING);
 
/* Size needs to be multiple of 16, including status entry. */
iq->size = roundup(iq->size, 16);
@@ -2624,8 +2625,8 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct 
sge_rspq *iq, bool fwevtq,
 
flsz = fl->size / 8 + s->stat_len / sizeof(struct tx_desc);
c.iqns_to_fl0congen |= htonl(FW_IQ_CMD_FL0PACKEN_F |
-FW_IQ_CMD_FL0FETCHRO_F |
-FW_IQ_CMD_FL0DATARO_F |
+FW_IQ_CMD_FL0FETCHRO_V(relaxed) |
+FW_IQ_CMD_FL0DATARO_V(relaxed) |
 FW_IQ_CMD_FL0PADEN_F);
if (cong >= 0)
c.iqns_to_fl0congen |=
-- 
1.9.0




[PATCH v2 1/3] PCI: Add new PCIe Fabric End Node flag, PCI_DEV_FLAGS_NO_RELAXED_ORDERING

2017-06-02 Thread Ding Tianhong
From: Casey Leedom 

The new flag PCI_DEV_FLAGS_NO_RELAXED_ORDERING indicates that the Relaxed
Ordering Attribute should not be used on Transaction Layer Packets destined
for the PCIe End Node so flagged.  Initially flagged this way are Intel
E5-26xx Root Complex Ports which suffer from a Flow Control Credit
Performance Problem and AMD A1100 ARM ("SEATTLE") Root Complex Ports which
don't obey PCIe 3.0 ordering rules which can lead to Data Corruption.

Signed-off-by: Casey Leedom 
Signed-off-by: Ding Tianhong 
---
 drivers/pci/quirks.c | 38 ++
 include/linux/pci.h  |  2 ++
 2 files changed, 40 insertions(+)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 085fb78..58bdd23 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3999,6 +3999,44 @@ static void quirk_tw686x_class(struct pci_dev *pdev)
  quirk_tw686x_class);
 
 /*
+ * Some devices have problems with Transaction Layer Packets with the Relaxed
+ * Ordering Attribute set.  Such devices should mark themselves and other
+ * Device Drivers should check before sending TLPs with RO set.
+ */
+static void quirk_relaxedordering_disable(struct pci_dev *dev)
+{
+   dev->dev_flags |= PCI_DEV_FLAGS_NO_RELAXED_ORDERING;
+}
+
+/*
+ * Intel E5-26xx Root Complex has a Flow Control Credit issue which can
+ * cause performance problems with Upstream Transaction Layer Packets with
+ * Relaxed Ordering set.
+ */
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f02, 
PCI_CLASS_NOT_DEFINED, 8,
+ quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f04, 
PCI_CLASS_NOT_DEFINED, 8,
+ quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f08, 
PCI_CLASS_NOT_DEFINED, 8,
+ quirk_relaxedordering_disable);
+
+/*
+ * The AMD ARM A1100 (AKA "SEATTLE") SoC has a bug in its PCIe Root Complex
+ * where Upstream Transaction Layer Packets with the Relaxed Ordering
+ * Attribute clear are allowed to bypass earlier TLPs with Relaxed Ordering
+ * set.  This is a violation of the PCIe 3.0 Transaction Ordering Rules
+ * outlined in Section 2.4.1 (PCI Express(r) Base Specification Revision 3.0
+ * November 10, 2010).  As a result, on this platform we can't use Relaxed
+ * Ordering for Upstream TLPs.
+ */
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a00, 
PCI_CLASS_NOT_DEFINED, 8,
+ quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a01, 
PCI_CLASS_NOT_DEFINED, 8,
+ quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a02, 
PCI_CLASS_NOT_DEFINED, 8,
+ quirk_relaxedordering_disable);
+
+/*
  * Per PCIe r3.0, sec 2.2.9, "Completion headers must supply the same
  * values for the Attribute as were supplied in the header of the
  * corresponding Request, except as explicitly allowed when IDO is used."
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 33c2b0b..e1e8428 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -183,6 +183,8 @@ enum pci_dev_flags {
PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT = (__force pci_dev_flags_t) (1 << 9),
/* Do not use FLR even if device advertises PCI_AF_CAP */
PCI_DEV_FLAGS_NO_FLR_RESET = (__force pci_dev_flags_t) (1 << 10),
+   /* Don't use Relaxed Ordering for TLPs directed at this device */
+   PCI_DEV_FLAGS_NO_RELAXED_ORDERING = (__force pci_dev_flags_t) (1 << 11),
 };
 
 enum pci_irq_reroute_variant {
-- 
1.9.0




[PATCH v2 0/3] Add new PCI_DEV_FLAGS_NO_RELAXED_ORDERING flag

2017-06-02 Thread Ding Tianhong
Some devices have problems with Transaction Layer Packets with the Relaxed
Ordering Attribute set.  This patch set adds a new PCIe Device Flag,
PCI_DEV_FLAGS_NO_RELAXED_ORDERING, a set of PCI Quirks to catch some known
devices with Relaxed Ordering issues, and a use of this new flag by the
cxgb4 driver to avoid using Relaxed Ordering with problematic Root Complex
Ports.

It's been years since I've submitted kernel.org patches, I appolgise for the
almost certain submission errors.

v2: Alexander point out that the v1 was only a part of the whole solution,
some platform which has some issues could use the new flag to indicate
that it is not safe to enable relaxed ordering attribute, then we need
to clear the relaxed ordering enable bits in the PCI configuration when
initializing the device. So add a new second patch to modify the PCI
initialization code to clear the relaxed ordering enable bit in the
event that the root complex doesn't want relaxed ordering enabled.

The third patch was base on the v1's second patch and only be changed
to query the relaxed ordering enable bit in the PCI configuration space
to allow the Chelsio NIC to send TLPs with the relaxed ordering attributes
set.

This version didn't plan to drop the defines for Intel Drivers to use the
new checking way to enable relaxed ordering because it is not the hardest
part of the moment, we could fix it in next patchset when this patches
reach the goal.  

Casey Leedom (2):
  PCI: Add new PCIe Fabric End Node flag,
PCI_DEV_FLAGS_NO_RELAXED_ORDERING
  net/cxgb4: Use new PCI_DEV_FLAGS_NO_RELAXED_ORDERING flag

Ding Tianhong (1):
  PCI: Enable PCIe Relaxed Ordering if supported

 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |  1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 17 ++
 drivers/net/ethernet/chelsio/cxgb4/sge.c|  5 +--
 drivers/pci/pci.c   | 42 +
 drivers/pci/probe.c | 11 +++
 drivers/pci/quirks.c| 38 ++
 include/linux/pci.h |  5 +++
 7 files changed, 117 insertions(+), 2 deletions(-)

-- 
1.9.0




[PATCH v4 net-next 0/3] bpf: Add BPF support to all perf_event

2017-06-02 Thread Alexei Starovoitov
v3->v4: one more tweak to reject unsupported events at map
update time as Peter suggested

v2->v3: more refactoring to address Peter's feedback.
Now all perf_events are attachable and readable

v1->v2: address Peter's feedback. Refactor patch 1 to allow attaching
bpf programs to all event types and reading counters from all of them as well
patch 2 - more tests
patch 3 - address Dave's feedback and document bpf_perf_event_read()
and bpf_perf_event_output() properly

Alexei Starovoitov (1):
  perf, bpf: Add BPF support to all perf_event types

Teng Qin (2):
  samples/bpf: add tests for more perf event types
  bpf: update perf event helper functions documentation

 include/linux/perf_event.h |   7 +-
 include/uapi/linux/bpf.h   |  11 ++-
 kernel/bpf/arraymap.c  |  28 ++-
 kernel/events/core.c   |  47 ++-
 kernel/trace/bpf_trace.c   |  21 ++---
 samples/bpf/bpf_helpers.h  |   3 +-
 samples/bpf/trace_event_user.c |  73 ++---
 samples/bpf/tracex6_kern.c |  28 +--
 samples/bpf/tracex6_user.c | 180 -
 tools/include/uapi/linux/bpf.h |  11 ++-
 10 files changed, 290 insertions(+), 119 deletions(-)

-- 
2.9.3



[PATCH v4 net-next 1/3] perf, bpf: Add BPF support to all perf_event types

2017-06-02 Thread Alexei Starovoitov
Allow BPF_PROG_TYPE_PERF_EVENT program types to attach to all
perf_event types, including HW_CACHE, RAW, and dynamic pmu events.
Only tracepoint/kprobe events are treated differently which require
BPF_PROG_TYPE_TRACEPOINT/BPF_PROG_TYPE_KPROBE program types accordingly.

Also add support for reading all event counters using
bpf_perf_event_read() helper.

Signed-off-by: Alexei Starovoitov 
---
 include/linux/perf_event.h |  7 +--
 kernel/bpf/arraymap.c  | 28 +++
 kernel/events/core.c   | 47 +++---
 kernel/trace/bpf_trace.c   | 21 -
 4 files changed, 48 insertions(+), 55 deletions(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 24a635887f28..8fc5f0fada5e 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -896,7 +896,7 @@ perf_event_create_kernel_counter(struct perf_event_attr 
*attr,
void *context);
 extern void perf_pmu_migrate_context(struct pmu *pmu,
int src_cpu, int dst_cpu);
-extern u64 perf_event_read_local(struct perf_event *event);
+int perf_event_read_local(struct perf_event *event, u64 *value);
 extern u64 perf_event_read_value(struct perf_event *event,
 u64 *enabled, u64 *running);
 
@@ -1301,7 +1301,10 @@ static inline const struct perf_event_attr 
*perf_event_attrs(struct perf_event *
 {
return ERR_PTR(-EINVAL);
 }
-static inline u64 perf_event_read_local(struct perf_event *event)  { 
return -EINVAL; }
+static inline int perf_event_read_local(struct perf_event *event, u64 *value)
+{
+   return -EINVAL;
+}
 static inline void perf_event_print_debug(void)
{ }
 static inline int perf_event_task_disable(void)
{ return -EINVAL; }
 static inline int perf_event_task_enable(void) { 
return -EINVAL; }
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index 172dc8ee0e3b..ecb43542246e 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -452,38 +452,24 @@ static void bpf_event_entry_free_rcu(struct 
bpf_event_entry *ee)
 static void *perf_event_fd_array_get_ptr(struct bpf_map *map,
 struct file *map_file, int fd)
 {
-   const struct perf_event_attr *attr;
struct bpf_event_entry *ee;
struct perf_event *event;
struct file *perf_file;
+   u64 value;
 
perf_file = perf_event_get(fd);
if (IS_ERR(perf_file))
return perf_file;
 
+   ee = ERR_PTR(-EOPNOTSUPP);
event = perf_file->private_data;
-   ee = ERR_PTR(-EINVAL);
-
-   attr = perf_event_attrs(event);
-   if (IS_ERR(attr) || attr->inherit)
+   if (perf_event_read_local(event, ) == -EOPNOTSUPP)
goto err_out;
 
-   switch (attr->type) {
-   case PERF_TYPE_SOFTWARE:
-   if (attr->config != PERF_COUNT_SW_BPF_OUTPUT)
-   goto err_out;
-   /* fall-through */
-   case PERF_TYPE_RAW:
-   case PERF_TYPE_HARDWARE:
-   ee = bpf_event_entry_gen(perf_file, map_file);
-   if (ee)
-   return ee;
-   ee = ERR_PTR(-ENOMEM);
-   /* fall-through */
-   default:
-   break;
-   }
-
+   ee = bpf_event_entry_gen(perf_file, map_file);
+   if (ee)
+   return ee;
+   ee = ERR_PTR(-ENOMEM);
 err_out:
fput(perf_file);
return ee;
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 6e75a5c9412d..51e40e4876c0 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3636,10 +3636,10 @@ static inline u64 perf_event_count(struct perf_event 
*event)
  * will not be local and we cannot read them atomically
  *   - must not have a pmu::count method
  */
-u64 perf_event_read_local(struct perf_event *event)
+int perf_event_read_local(struct perf_event *event, u64 *value)
 {
unsigned long flags;
-   u64 val;
+   int ret = 0;
 
/*
 * Disabling interrupts avoids all counter scheduling (context
@@ -3647,25 +3647,37 @@ u64 perf_event_read_local(struct perf_event *event)
 */
local_irq_save(flags);
 
-   /* If this is a per-task event, it must be for current */
-   WARN_ON_ONCE((event->attach_state & PERF_ATTACH_TASK) &&
-event->hw.target != current);
-
-   /* If this is a per-CPU event, it must be for this CPU */
-   WARN_ON_ONCE(!(event->attach_state & PERF_ATTACH_TASK) &&
-event->cpu != smp_processor_id());
-
/*
 * It must not be an event with inherit set, we cannot read
 * all child counters from atomic context.
 */
-   WARN_ON_ONCE(event->attr.inherit);
+   if (event->attr.inherit) {
+   ret = -EOPNOTSUPP;
+

[PATCH v4 net-next 2/3] samples/bpf: add tests for more perf event types

2017-06-02 Thread Alexei Starovoitov
From: Teng Qin 

$ trace_event

tests attaching BPF program to HW_CPU_CYCLES, SW_CPU_CLOCK, HW_CACHE_L1D and 
other events.
It runs 'dd' in the background while bpf program collects user and kernel
stack trace on counter overflow.
User space expects to see sys_read and sys_write in the kernel stack.

$ tracex6

tests reading of various perf counters from BPF program.

Both tests were refactored to increase coverage and be more accurate.

Signed-off-by: Teng Qin 
Signed-off-by: Alexei Starovoitov 
---
 samples/bpf/bpf_helpers.h  |   3 +-
 samples/bpf/trace_event_user.c |  73 ++---
 samples/bpf/tracex6_kern.c |  28 +--
 samples/bpf/tracex6_user.c | 180 -
 4 files changed, 228 insertions(+), 56 deletions(-)

diff --git a/samples/bpf/bpf_helpers.h b/samples/bpf/bpf_helpers.h
index 9a9c95f2c9fb..51e567bc70fc 100644
--- a/samples/bpf/bpf_helpers.h
+++ b/samples/bpf/bpf_helpers.h
@@ -31,7 +31,8 @@ static unsigned long long (*bpf_get_current_uid_gid)(void) =
(void *) BPF_FUNC_get_current_uid_gid;
 static int (*bpf_get_current_comm)(void *buf, int buf_size) =
(void *) BPF_FUNC_get_current_comm;
-static int (*bpf_perf_event_read)(void *map, int index) =
+static unsigned long long (*bpf_perf_event_read)(void *map,
+unsigned long long flags) =
(void *) BPF_FUNC_perf_event_read;
 static int (*bpf_clone_redirect)(void *ctx, int ifindex, int flags) =
(void *) BPF_FUNC_clone_redirect;
diff --git a/samples/bpf/trace_event_user.c b/samples/bpf/trace_event_user.c
index fa4336423da5..7bd827b84a67 100644
--- a/samples/bpf/trace_event_user.c
+++ b/samples/bpf/trace_event_user.c
@@ -75,7 +75,10 @@ static void print_stack(struct key_t *key, __u64 count)
for (i = PERF_MAX_STACK_DEPTH - 1; i >= 0; i--)
print_addr(ip[i]);
}
-   printf("\n");
+   if (count < 6)
+   printf("\r");
+   else
+   printf("\n");
 
if (key->kernstack == -EEXIST && !warned) {
printf("stackmap collisions seen. Consider increasing size\n");
@@ -105,7 +108,7 @@ static void print_stacks(void)
bpf_map_delete_elem(fd, _key);
key = next_key;
}
-
+   printf("\n");
if (!sys_read_seen || !sys_write_seen) {
printf("BUG kernel stack doesn't contain sys_read() and 
sys_write()\n");
int_exit(0);
@@ -122,24 +125,29 @@ static void test_perf_event_all_cpu(struct 
perf_event_attr *attr)
 {
int nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
int *pmu_fd = malloc(nr_cpus * sizeof(int));
-   int i;
+   int i, error = 0;
 
/* open perf_event on all cpus */
for (i = 0; i < nr_cpus; i++) {
pmu_fd[i] = sys_perf_event_open(attr, -1, i, -1, 0);
if (pmu_fd[i] < 0) {
printf("sys_perf_event_open failed\n");
+   error = 1;
goto all_cpu_err;
}
assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 
0);
-   assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_ENABLE, 0) == 0);
+   assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_ENABLE) == 0);
}
-   system("dd if=/dev/zero of=/dev/null count=5000k");
+   system("dd if=/dev/zero of=/dev/null count=5000k status=none");
print_stacks();
 all_cpu_err:
-   for (i--; i >= 0; i--)
+   for (i--; i >= 0; i--) {
+   ioctl(pmu_fd[i], PERF_EVENT_IOC_DISABLE);
close(pmu_fd[i]);
+   }
free(pmu_fd);
+   if (error)
+   int_exit(0);
 }
 
 static void test_perf_event_task(struct perf_event_attr *attr)
@@ -150,12 +158,13 @@ static void test_perf_event_task(struct perf_event_attr 
*attr)
pmu_fd = sys_perf_event_open(attr, 0, -1, -1, 0);
if (pmu_fd < 0) {
printf("sys_perf_event_open failed\n");
-   return;
+   int_exit(0);
}
assert(ioctl(pmu_fd, PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0);
-   assert(ioctl(pmu_fd, PERF_EVENT_IOC_ENABLE, 0) == 0);
-   system("dd if=/dev/zero of=/dev/null count=5000k");
+   assert(ioctl(pmu_fd, PERF_EVENT_IOC_ENABLE) == 0);
+   system("dd if=/dev/zero of=/dev/null count=5000k status=none");
print_stacks();
+   ioctl(pmu_fd, PERF_EVENT_IOC_DISABLE);
close(pmu_fd);
 }
 
@@ -175,11 +184,56 @@ static void test_bpf_perf_event(void)
.config = PERF_COUNT_SW_CPU_CLOCK,
.inherit = 1,
};
+   struct perf_event_attr attr_hw_cache_l1d = {
+   .sample_freq = SAMPLE_FREQ,
+   .freq = 1,
+   .type = PERF_TYPE_HW_CACHE,
+   .config =
+   PERF_COUNT_HW_CACHE_L1D |
+   

[PATCH v4 net-next 3/3] bpf: update perf event helper functions documentation

2017-06-02 Thread Alexei Starovoitov
From: Teng Qin 

This commit updates documentation of the bpf_perf_event_output and
bpf_perf_event_read helpers to match their implementation.

Signed-off-by: Teng Qin 
Signed-off-by: Alexei Starovoitov 
---
 include/uapi/linux/bpf.h   | 11 +++
 tools/include/uapi/linux/bpf.h | 11 +++
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 94dfa9def355..e78aece03628 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -313,8 +313,11 @@ union bpf_attr {
  * @flags: room for future extensions
  * Return: 0 on success or negative error
  *
- * u64 bpf_perf_event_read(, index)
- * Return: Number events read or error code
+ * u64 bpf_perf_event_read(map, flags)
+ * read perf event counter value
+ * @map: pointer to perf_event_array map
+ * @flags: index of event in the map or bitmask flags
+ * Return: value of perf event counter read or error code
  *
  * int bpf_redirect(ifindex, flags)
  * redirect to another netdev
@@ -328,11 +331,11 @@ union bpf_attr {
  * @skb: pointer to skb
  * Return: realm if != 0
  *
- * int bpf_perf_event_output(ctx, map, index, data, size)
+ * int bpf_perf_event_output(ctx, map, flags, data, size)
  * output perf raw sample
  * @ctx: struct pt_regs*
  * @map: pointer to perf_event_array map
- * @index: index of event in the map
+ * @flags: index of event in the map or bitmask flags
  * @data: data on stack to be output as raw data
  * @size: size of data
  * Return: 0 on success or negative error
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 94dfa9def355..e78aece03628 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -313,8 +313,11 @@ union bpf_attr {
  * @flags: room for future extensions
  * Return: 0 on success or negative error
  *
- * u64 bpf_perf_event_read(, index)
- * Return: Number events read or error code
+ * u64 bpf_perf_event_read(map, flags)
+ * read perf event counter value
+ * @map: pointer to perf_event_array map
+ * @flags: index of event in the map or bitmask flags
+ * Return: value of perf event counter read or error code
  *
  * int bpf_redirect(ifindex, flags)
  * redirect to another netdev
@@ -328,11 +331,11 @@ union bpf_attr {
  * @skb: pointer to skb
  * Return: realm if != 0
  *
- * int bpf_perf_event_output(ctx, map, index, data, size)
+ * int bpf_perf_event_output(ctx, map, flags, data, size)
  * output perf raw sample
  * @ctx: struct pt_regs*
  * @map: pointer to perf_event_array map
- * @index: index of event in the map
+ * @flags: index of event in the map or bitmask flags
  * @data: data on stack to be output as raw data
  * @size: size of data
  * Return: 0 on success or negative error
-- 
2.9.3



RE: [PATCH net-next] net: phy: smsc: Implement PHY statistics

2017-06-02 Thread Woojung.Huh
>> Just cosmetic thing.
>> How about aligning with other members in structure like
>
>Yes, i can do that. v2 tomorrow sometime.
Thanks.

>
>Can you confirm the LAN911x Internal PHY don't have this. The register
>is not listed in the switch datasheet.
>
This register is NOT in LAN911x internal phy.
http://ww1.microchip.com/downloads/en/DeviceDoc/2266A.pdf

- Woojung


Re: [PATCH v2 net-next 0/8] Introduce bpf ID

2017-06-02 Thread Martin KaFai Lau
On Wed, May 31, 2017 at 07:35:18PM -0400, David Miller wrote:
> From: Martin KaFai Lau 
> Date: Wed, 31 May 2017 11:58:54 -0700
>
> > This patch series:
> > 1) Introduce ID for both bpf_prog and bpf_map.
> > 2) Add bpf commands to iterate the prog IDs and map
> >IDs of the system.
> > 3) Add bpf commands to get a prog/map fd from an ID
> > 4) Add bpf command to get prog/map info from a fd.
> >The prog/map info is a jump start in this patchset
> >and it is not meant to be a complete list.  They can
> >be extended in the future patches.
> >
> > v2:
> > Compiler warning fixes:
> > - Remove lockdep_is_held() usage.  Add comment
> >   to explain the lock situation instead.
> > - Add static for idr related variables
> > - Add __user to the uattr param in bpf_prog_get_info_by_fd()
> >   and bpf_map_get_info_by_fd().
>
> Series applied, thanks Martin.
Patch 1 may not apply cleanly due to another newly added
field in 'struct bpf_prog_aux' on May 31.

Should I respin?


Re: [PATCH net-next] net: phy: smsc: Implement PHY statistics

2017-06-02 Thread Andrew Lunn
Hi Woojung

> Just cosmetic thing.
> How about aligning with other members in structure like

Yes, i can do that. v2 tomorrow sometime.

> > +   .get_sset_count = smsc_get_sset_count,
> > +   .get_strings = smsc_get_strings,
> > +   .get_stats= smsc_get_stats,
> 
> Reviewed-By: Woojung Huh 

Thanks.

Can you confirm the LAN911x Internal PHY don't have this. The register
is not listed in the switch datasheet.

Thanks
Andrew


Re: [PATCH net-next] net: phy: smsc: Implement PHY statistics

2017-06-02 Thread Florian Fainelli
On 06/02/2017 02:24 PM, Andrew Lunn wrote:
> Most of the PHYs supported by the SMSC driver have a counter of symbol
> errors. This is 16 bit wide and wraps around when it reaches its
> maximum value.
> 
> Signed-off-by: Andrew Lunn 

Reviewed-by: Florian Fainelli 
-- 
Florian


[PATCH v3 7/7] net: pch_gbe: Allow build on MIPS platforms

2017-06-02 Thread Paul Burton
Allow the pch_gbe driver to be built on MIPS platforms, in preparation
for its use on the MIPS Boston board.

Signed-off-by: Paul Burton 
Cc: David S. Miller 
Cc: Eric Dumazet 
Cc: Jarod Wilson 
Cc: Tobias Klauser 
Cc: linux-m...@linux-mips.org
Cc: netdev@vger.kernel.org

---

Changes in v3: None
Changes in v2: None

 drivers/net/ethernet/oki-semi/pch_gbe/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig 
b/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig
index 5f7a35212796..4d3809ae75e1 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig
@@ -4,7 +4,7 @@
 
 config PCH_GBE
tristate "OKI SEMICONDUCTOR IOH(ML7223/ML7831) GbE"
-   depends on PCI && (X86_32 || COMPILE_TEST)
+   depends on PCI && (X86_32 || MIPS || COMPILE_TEST)
select MII
select PTP_1588_CLOCK_PCH
select NET_PTP_CLASSIFY
-- 
2.13.0



Re: [PATCH net-next] liquidio: Fix checkpatch errors with references crossing single line

2017-06-02 Thread Joe Perches
On Fri, 2017-06-02 at 23:11 +, Chickles, Derek wrote:
> > -Original Message-
> > From: Joe Perches [mailto:j...@perches.com]
p[
> > Subject: Re: [PATCH net-next] liquidio: Fix checkpatch errors with
> > references crossing single line
[]
> >   Did you see the patch I sent?
[]
> We'll take your patch, try it, and test it on our cards then resubmit
> if it checks out.

Thanks though there will have to be some mods to the patch now.



[PATCH v3 6/7] net: pch_gbe: Allow longer for resets

2017-06-02 Thread Paul Burton
Resets of the EG20T MAC on the MIPS Boston development board take longer
than the 1000 loops that pch_gbe_wait_clr_bit was performing. Rather
than simply increasing the number of loops, switch to using
readl_poll_timeout_atomic() from linux/iopoll.h in order to provide some
independence from the speed of the CPU.

Signed-off-by: Paul Burton 
Cc: David S. Miller 
Cc: Eric Dumazet 
Cc: Jarod Wilson 
Cc: Tobias Klauser 
Cc: linux-m...@linux-mips.org
Cc: netdev@vger.kernel.org

---

Changes in v3:
- Switch to using readl_poll_timeout_atomic().

Changes in v2: None

 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c 
b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index f8791be7b3b5..3d0f4c8b1742 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define DRV_VERSION "1.01"
@@ -318,13 +319,11 @@ s32 pch_gbe_mac_read_mac_addr(struct pch_gbe_hw *hw)
  */
 static void pch_gbe_wait_clr_bit(void *reg, u32 bit)
 {
+   int err;
u32 tmp;
 
-   /* wait busy */
-   tmp = 1000;
-   while ((ioread32(reg) & bit) && --tmp)
-   cpu_relax();
-   if (!tmp)
+   err = readl_poll_timeout_atomic(reg, tmp, !(tmp & bit), 10, 500);
+   if (err)
pr_err("Error: busy bit is not cleared\n");
 }
 
-- 
2.13.0



[PATCH v3 5/7] net: pch_gbe: Always reset PHY along with MAC

2017-06-02 Thread Paul Burton
On the MIPS Boston development board, the EG20T MAC does not report
receiving the RX clock from the (RGMII) RTL8211E PHY unless the PHY is
reset at the same time as the MAC. Since the pch_gbe driver resets the
MAC a number of times - twice during probe, and when taking down the
network interface - we need to reset the PHY at all the same times. Do
that from pch_gbe_mac_reset_hw which is used to reset the MAC in all
cases.

Signed-off-by: Paul Burton 
Cc: David S. Miller 
Cc: Eric Dumazet 
Cc: Jarod Wilson 
Cc: Tobias Klauser 
Cc: linux-m...@linux-mips.org
Cc: netdev@vger.kernel.org
---

Changes in v3: None
Changes in v2: None

 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c 
b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 59a42c20d433..f8791be7b3b5 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -380,10 +380,13 @@ static void pch_gbe_mac_reset_hw(struct pch_gbe_hw *hw)
 {
/* Read the MAC address. and store to the private data */
pch_gbe_mac_read_mac_addr(hw);
+   pch_gbe_phy_set_reset(hw, 1);
iowrite32(PCH_GBE_ALL_RST, >reg->RESET);
 #ifdef PCH_GBE_MAC_IFOP_RGMII
iowrite32(PCH_GBE_MODE_GMII_ETHER, >reg->MODE);
 #endif
+   pch_gbe_phy_set_reset(hw, 0);
+   usleep_range(1250, 1500);
pch_gbe_wait_clr_bit(>reg->RESET, PCH_GBE_ALL_RST);
/* Setup the receive addresses */
pch_gbe_mac_mar_set(hw, hw->mac.addr, 0);
-- 
2.13.0



[PATCH v3 3/7] dt-bindings: net: Document Intel pch_gbe binding

2017-06-02 Thread Paul Burton
Introduce documentation for a device tree binding for the Intel Platform
Controller Hub (PCH) GigaBit Ethernet (GBE) device. Although this is a
PCIe device & thus largely auto-detectable, this binding will be used to
provide the driver with the PHY reset GPIO.

Signed-off-by: Paul Burton 
Cc: David S. Miller 
Cc: Eric Dumazet 
Cc: Jarod Wilson 
Cc: Mark Rutland 
Cc: Rob Herring 
Cc: Tobias Klauser 
Cc: devicet...@vger.kernel.org
Cc: linux-m...@linux-mips.org
Cc: netdev@vger.kernel.org

---

Changes in v3:
- New patch.

Changes in v2: None

 Documentation/devicetree/bindings/net/pch_gbe.txt | 25 +++
 1 file changed, 25 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/pch_gbe.txt

diff --git a/Documentation/devicetree/bindings/net/pch_gbe.txt 
b/Documentation/devicetree/bindings/net/pch_gbe.txt
new file mode 100644
index ..5de479c26b04
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/pch_gbe.txt
@@ -0,0 +1,25 @@
+Intel Platform Controller Hub (PCH) GigaBit Ethernet (GBE)
+
+Required properties:
+- compatible:  Should be the PCI vendor & device ID, eg. 
"pci8086,8802".
+- reg: Should be a PCI device number as specified by the PCI 
bus
+   binding to IEEE Std 1275-1994.
+- phy-reset-gpios: Should be a GPIO list containing a single GPIO that
+   resets the attached PHY when active.
+
+Example:
+
+   eg20t_mac@2,0,1 {
+   compatible = "pci8086,8802";
+   reg = <0x00020100 0 0 0 0>;
+   phy-reset-gpios = <_gpio 6
+  GPIO_ACTIVE_LOW>;
+   };
+
+   eg20t_gpio: eg20t_gpio@2,0,2 {
+   compatible = "pci8086,8803";
+   reg = <0x00020200 0 0 0 0>;
+
+   gpio-controller;
+   #gpio-cells = <2>;
+   };
-- 
2.13.0



[PATCH v3 4/7] net: pch_gbe: Add device tree support

2017-06-02 Thread Paul Burton
Introduce support for retrieving the PHY reset GPIO from device tree,
which will be used on the MIPS Boston development board. This requires
support for probe deferral in order to work correctly, since the order
of device probe is not guaranteed & typically the EG20T GPIO controller
device will be probed after the ethernet MAC.

Signed-off-by: Paul Burton 
Cc: David S. Miller 
Cc: Eric Dumazet 
Cc: Jarod Wilson 
Cc: Tobias Klauser 
Cc: linux-m...@linux-mips.org
Cc: netdev@vger.kernel.org
---

Changes in v3: None

Changes in v2:
- Tidy up handling of parsing private data, drop err_out.

 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   | 31 +-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c 
b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index cb9b904786e4..59a42c20d433 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -23,6 +23,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define DRV_VERSION "1.01"
 const char pch_driver_version[] = DRV_VERSION;
@@ -2565,13 +2567,40 @@ static void pch_gbe_remove(struct pci_dev *pdev)
free_netdev(netdev);
 }
 
+static struct pch_gbe_privdata *
+pch_gbe_get_priv(struct pci_dev *pdev, const struct pci_device_id *pci_id)
+{
+   struct pch_gbe_privdata *pdata;
+   struct gpio_desc *gpio;
+
+   if (!IS_ENABLED(CONFIG_OF))
+   return (struct pch_gbe_privdata *)pci_id->driver_data;
+
+   pdata = devm_kzalloc(>dev, sizeof(*pdata), GFP_KERNEL);
+   if (!pdata)
+   return ERR_PTR(-ENOMEM);
+
+   gpio = devm_gpiod_get(>dev, "phy-reset", GPIOD_ASIS);
+   if (!IS_ERR(gpio))
+   pdata->phy_reset_gpio = gpio;
+   else if (PTR_ERR(gpio) != -ENOENT)
+   return ERR_PTR(PTR_ERR(gpio));
+
+   return pdata;
+}
+
 static int pch_gbe_probe(struct pci_dev *pdev,
  const struct pci_device_id *pci_id)
 {
struct net_device *netdev;
struct pch_gbe_adapter *adapter;
+   struct pch_gbe_privdata *pdata;
int ret;
 
+   pdata = pch_gbe_get_priv(pdev, pci_id);
+   if (IS_ERR(pdata))
+   return PTR_ERR(pdata);
+
ret = pcim_enable_device(pdev);
if (ret)
return ret;
@@ -2609,7 +2638,7 @@ static int pch_gbe_probe(struct pci_dev *pdev,
adapter->pdev = pdev;
adapter->hw.back = adapter;
adapter->hw.reg = pcim_iomap_table(pdev)[PCH_GBE_PCI_BAR];
-   adapter->pdata = (struct pch_gbe_privdata *)pci_id->driver_data;
+   adapter->pdata = pdata;
if (adapter->pdata && adapter->pdata->platform_init)
adapter->pdata->platform_init(pdev, adapter->pdata);
 
-- 
2.13.0



[PATCH v3 2/7] net: pch_gbe: Pull PHY GPIO handling out of Minnow code

2017-06-02 Thread Paul Burton
The MIPS Boston development board uses the Intel EG20T Platform
Controller Hub, including its gigabit ethernet controller, and requires
that its RTL8211E PHY be reset much like the Minnow platform. Pull the
PHY reset GPIO handling out of Minnow-specific code such that it can be
shared by later patches.

Signed-off-by: Paul Burton 
Cc: David S. Miller 
Cc: Eric Dumazet 
Cc: Jarod Wilson 
Cc: Tobias Klauser 
Cc: linux-m...@linux-mips.org
Cc: netdev@vger.kernel.org
---

Changes in v3:
- Use adapter->pdata as arg to platform_init, to fix bisectability.

Changes in v2: None

 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h|  4 ++-
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   | 33 +++---
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h 
b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
index 8d710a3b4db0..de1dd08050f4 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
@@ -580,15 +580,17 @@ struct pch_gbe_hw_stats {
 
 /**
  * struct pch_gbe_privdata - PCI Device ID driver data
+ * @phy_reset_gpio:PHY reset GPIO descriptor.
  * @phy_tx_clk_delay:  Bool, configure the PHY TX delay in software
  * @phy_disable_hibernate: Bool, disable PHY hibernation
  * @platform_init: Platform initialization callback, called from
  * probe, prior to PHY initialization.
  */
 struct pch_gbe_privdata {
+   struct gpio_desc *phy_reset_gpio;
bool phy_tx_clk_delay;
bool phy_disable_hibernate;
-   int (*platform_init)(struct pci_dev *pdev);
+   int (*platform_init)(struct pci_dev *, struct pch_gbe_privdata *);
 };
 
 /**
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c 
b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index d38198718005..cb9b904786e4 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -360,6 +360,16 @@ static void pch_gbe_mac_mar_set(struct pch_gbe_hw *hw, u8 
* addr, u32 index)
pch_gbe_wait_clr_bit(>reg->ADDR_MASK, PCH_GBE_BUSY);
 }
 
+static void pch_gbe_phy_set_reset(struct pch_gbe_hw *hw, int value)
+{
+   struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
+
+   if (!adapter->pdata || !adapter->pdata->phy_reset_gpio)
+   return;
+
+   gpiod_set_value(adapter->pdata->phy_reset_gpio, value);
+}
+
 /**
  * pch_gbe_mac_reset_hw - Reset hardware
  * @hw:Pointer to the HW structure
@@ -2601,7 +2611,14 @@ static int pch_gbe_probe(struct pci_dev *pdev,
adapter->hw.reg = pcim_iomap_table(pdev)[PCH_GBE_PCI_BAR];
adapter->pdata = (struct pch_gbe_privdata *)pci_id->driver_data;
if (adapter->pdata && adapter->pdata->platform_init)
-   adapter->pdata->platform_init(pdev);
+   adapter->pdata->platform_init(pdev, adapter->pdata);
+
+   if (adapter->pdata && adapter->pdata->phy_reset_gpio) {
+   pch_gbe_phy_set_reset(>hw, 1);
+   usleep_range(1250, 1500);
+   pch_gbe_phy_set_reset(>hw, 0);
+   usleep_range(1250, 1500);
+   }
 
adapter->ptp_pdev = pci_get_bus_and_slot(adapter->pdev->bus->number,
   PCI_DEVFN(12, 4));
@@ -2694,7 +2711,8 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 /* The AR803X PHY on the MinnowBoard requires a physical pin to be toggled to
  * ensure it is awake for probe and init. Request the line and reset the PHY.
  */
-static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
+static int pch_gbe_minnow_platform_init(struct pci_dev *pdev,
+   struct pch_gbe_privdata *pdata)
 {
unsigned long flags = GPIOF_DIR_OUT | GPIOF_INIT_LOW |
GPIOF_EXPORT | GPIOF_ACTIVE_LOW;
@@ -2703,16 +2721,11 @@ static int pch_gbe_minnow_platform_init(struct pci_dev 
*pdev)
 
ret = devm_gpio_request_one(>dev, gpio, flags,
"minnow_phy_reset");
-   if (ret) {
+   if (!ret)
+   pdata->phy_reset_gpio = gpio_to_desc(gpio);
+   else
dev_err(>dev,
"ERR: Can't request PHY reset GPIO line '%d'\n", gpio);
-   return ret;
-   }
-
-   gpio_set_value(gpio, 1);
-   usleep_range(1250, 1500);
-   gpio_set_value(gpio, 0);
-   usleep_range(1250, 1500);
 
return ret;
 }
-- 
2.13.0



[PATCH v3 1/7] net: pch_gbe: Mark Minnow PHY reset GPIO active low

2017-06-02 Thread Paul Burton
The Minnow PHY reset GPIO is set to 0 to enter reset & 1 to leave reset
- that is, it is an active low GPIO. In order to allow for the code to
be made more generic by further patches, indicate to the GPIO subsystem
that the GPIO is active low & invert the values it is set to such that
they reflect logically whether the device is being reset or not.

Signed-off-by: Paul Burton 
Cc: David S. Miller 
Cc: Eric Dumazet 
Cc: Jarod Wilson 
Cc: Tobias Klauser 
Cc: linux-m...@linux-mips.org
Cc: netdev@vger.kernel.org
---

Changes in v3: None
Changes in v2: None

 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c 
b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 5ae9681a2da7..d38198718005 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -2696,7 +2696,8 @@ static int pch_gbe_probe(struct pci_dev *pdev,
  */
 static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
 {
-   unsigned long flags = GPIOF_DIR_OUT | GPIOF_INIT_HIGH | GPIOF_EXPORT;
+   unsigned long flags = GPIOF_DIR_OUT | GPIOF_INIT_LOW |
+   GPIOF_EXPORT | GPIOF_ACTIVE_LOW;
unsigned gpio = MINNOW_PHY_RESET_GPIO;
int ret;
 
@@ -2708,10 +2709,10 @@ static int pch_gbe_minnow_platform_init(struct pci_dev 
*pdev)
return ret;
}
 
-   gpio_set_value(gpio, 0);
-   usleep_range(1250, 1500);
gpio_set_value(gpio, 1);
usleep_range(1250, 1500);
+   gpio_set_value(gpio, 0);
+   usleep_range(1250, 1500);
 
return ret;
 }
-- 
2.13.0



[PATCH v3 0/7] net: pch_gbe: Fixes & MIPS support

2017-06-02 Thread Paul Burton
The Intel EG20T Platform Controller Hub is used on the MIPS Boston
development board to provide various peripherals including ethernet.
This series fixes some issues with the pch_gbe driver discovered whilst
in use on the Boston board, and implements support for device tree which
we use to provide the PHY reset GPIO.

Applies atop v4.12-rc3.

Paul Burton (7):
  net: pch_gbe: Mark Minnow PHY reset GPIO active low
  net: pch_gbe: Pull PHY GPIO handling out of Minnow code
  dt-bindings: net: Document Intel pch_gbe binding
  net: pch_gbe: Add device tree support
  net: pch_gbe: Always reset PHY along with MAC
  net: pch_gbe: Allow longer for resets
  net: pch_gbe: Allow build on MIPS platforms

 Documentation/devicetree/bindings/net/pch_gbe.txt  | 25 +++
 drivers/net/ethernet/oki-semi/pch_gbe/Kconfig  |  2 +-
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h|  4 +-
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   | 79 +-
 4 files changed, 91 insertions(+), 19 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/pch_gbe.txt

-- 
2.13.0



RE: [PATCH net-next] net: phy: smsc: Implement PHY statistics

2017-06-02 Thread Woojung.Huh
Andrew,

>  static int smsc_phy_probe(struct phy_device *phydev)
>  {
>   struct device *dev = >mdio.dev;
> @@ -206,6 +258,11 @@ static struct phy_driver smsc_phy_driver[] = {
>   .ack_interrupt  = smsc_phy_ack_interrupt,
>   .config_intr= smsc_phy_config_intr,
> 
> + /* Statistics */
> + .get_sset_count = smsc_get_sset_count,
> + .get_strings = smsc_get_strings,
> + .get_stats = smsc_get_stats,
> +
...
> 
> + /* Statistics */
> + .get_sset_count = smsc_get_sset_count,
> + .get_strings = smsc_get_strings,
> + .get_stats = smsc_get_stats,
> +
...
> + /* Statistics */
> + .get_sset_count = smsc_get_sset_count,
> + .get_strings = smsc_get_strings,
> + .get_stats = smsc_get_stats,
> +
...
> + /* Statistics */
> + .get_sset_count = smsc_get_sset_count,
> + .get_strings = smsc_get_strings,
> + .get_stats = smsc_get_stats,
> +
Just cosmetic thing.
How about aligning with other members in structure like
> + .get_sset_count = smsc_get_sset_count,
> + .get_strings = smsc_get_strings,
> + .get_stats= smsc_get_stats,

Reviewed-By: Woojung Huh 



Re: loosing netdevices with namespaces and unshare?

2017-06-02 Thread Cong Wang
On Wed, May 31, 2017 at 11:32 PM, Eric W. Biederman
 wrote:
> Cong Wang  writes:
>> Network namespace does not special-case the physical devices,
>> it treats them all equally as abstract net devices.
>
> Absolutely not true.
>
> The relevant code is in net/core/dev.c:default_device_exit
>
> If a network device does not implement rntl_link_ops it is returned to
> the initial network namespace.   Anything else will loose physical
> devices.

Hmm, I never noticed that if check...

>
> Only for pure software based devices do we delete them.  Perhaps your
> sub interface implements rtnl_link_ops?  Either that or something is
> still holding a reference to your network namespace, which would prevent
> the network device from being returned.
>

But this simply sucks:

snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex);
err = dev_change_net_namespace(dev, _net, fb_name);
if (err) {
pr_emerg("%s: failed to move %s to init_net: %d\n",
 __func__, dev->name, err);
BUG();
}

It is essentially hard to handle the error here, but it is quite easy to
trigger such BUG() by naming other device devX, it is no better
than just losing it.


RE: [PATCH net-next] liquidio: Fix checkpatch errors with references crossing single line

2017-06-02 Thread Chickles, Derek


> -Original Message-
> From: Joe Perches [mailto:j...@perches.com]
> Sent: Friday, June 02, 2017 3:44 PM
> To: David Miller ; Manlunas, Felix
> 
> Cc: netdev@vger.kernel.org; Vatsavayi, Raghu ;
> Chickles, Derek ; Burla, Satananda
> 
> Subject: Re: [PATCH net-next] liquidio: Fix checkpatch errors with
> references crossing single line
> 
> On Fri, 2017-06-02 at 14:17 -0400, David Miller wrote:
> > From: Felix Manlunas 
> > Date: Wed, 31 May 2017 10:45:15 -0700
> >
> > > From: Satanand Burla 
> > >
> > > Signed-off-by: Satanand Burla 
> > > Signed-off-by: Derek Chickles 
> > > Signed-off-by: Felix Manlunas 
> >
> > Applied.
> 
>   Did you see the patch I sent?

Hi Joe,

We'll take your patch, try it, and test it on our cards then resubmit
if it checks out.

Thanks,
Derek


Re: [PATCH net-next] liquidio: Fix checkpatch errors with references crossing single line

2017-06-02 Thread Joe Perches
On Fri, 2017-06-02 at 14:17 -0400, David Miller wrote:
> From: Felix Manlunas 
> Date: Wed, 31 May 2017 10:45:15 -0700
> 
> > From: Satanand Burla 
> > 
> > Signed-off-by: Satanand Burla 
> > Signed-off-by: Derek Chickles 
> > Signed-off-by: Felix Manlunas 
> 
> Applied.

  Did you see the patch I sent?


[PATCH v2] brcmfmac: Fix glom_skb leak in brcmf_sdiod_recv_chain

2017-06-02 Thread Peter S. Housel
An earlier change to this function (3bdae810721b) fixed a leak in the
case of an unsuccessful call to brcmf_sdiod_buffrw(). However, the
glom_skb buffer, used for emulating a scattering read, is never used
or referenced after its contents are copied into the destination
buffers, and therefore always needs to be freed by the end of the
function.

Fixes: 3bdae810721b ("brcmfmac: Fix glob_skb leak in brcmf_sdiod_recv_chain")
Fixes: a413e39a38573 ("brcmfmac: fix brcmf_sdcard_recv_chain() for host without 
sg support")
Signed-off-by: Peter S. Housel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index 9b970dc..30fb54e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -727,15 +727,13 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev,
return -ENOMEM;
err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr,
 glom_skb);
-   if (err) {
-   brcmu_pkt_buf_free_skb(glom_skb);
-   goto done;
-   }
-
-   skb_queue_walk(pktq, skb) {
-   memcpy(skb->data, glom_skb->data, skb->len);
-   skb_pull(glom_skb, skb->len);
+   if (!err) {
+   skb_queue_walk(pktq, skb) {
+   memcpy(skb->data, glom_skb->data, skb->len);
+   skb_pull(glom_skb, skb->len);
+   }
}
+   brcmu_pkt_buf_free_skb(glom_skb);
} else
err = brcmf_sdiod_sglist_rw(sdiodev, SDIO_FUNC_2, false, addr,
pktq);
-- 
2.7.4



Re: [PATCH v6 00/21] net-next: stmmac: add dwmac-sun8i ethernet driver

2017-06-02 Thread Maxime Ripard
Hi,

On Fri, Jun 02, 2017 at 10:22:05AM -0400, David Miller wrote:
> From: Maxime Ripard 
> Date: Fri, 2 Jun 2017 11:13:20 +0200
> 
> > On Fri, Jun 02, 2017 at 08:37:52AM +0200, Maxime Ripard wrote:
> >> On Thu, Jun 01, 2017 at 02:58:19PM -0400, David Miller wrote:
> >> > From: Corentin Labbe 
> >> > Date: Wed, 31 May 2017 09:18:31 +0200
> >> > 
> >> > > This patch series add the driver for dwmac-sun8i which handle the 
> >> > > Ethernet MAC
> >> > > present on Allwinner H3/H5/A83T/A64 SoCs.
> >> > 
> >> > Series applied, but wow that's a lot of DT file changes :-(
> >> 
> >> The DT patches should not go through your tree, but arm-soc, so I
> >> guess this is not an issue for you?
> > 
> > Ok, so I saw that you actually merged them. Can you revert or drop
> > that merge for the DT part?
> > 
> > This will generate a lot of conflicts with our tree, and I'm not sure
> > this would be efficient to make you take all the entirely unrelated to
> > next patches.
> 
> Please tell me which specific changes to revert.
> 
> Thank you.

Ideally everything from 2c0cba482e79 ("arm: sun8i: sunxi-h3-h5: Add dt
node for the syscon control module") to 2428fd0fe550 ("arm64:
defconfig: Enable dwmac-sun8i driver on defconfig")

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


signature.asc
Description: PGP signature


ath9k - Division by zero in kernel (as well as firmware panic)

2017-06-02 Thread Nathan Royce
ODroid XU4

$ uname -a
Linux computer 4.12.0-rc3-dirty #1 SMP Wed May 31 15:02:05 CDT 2017
armv7l GNU/Linux

$ lsusb
...
Bus 001 Device 002: ID 2109:2813 VIA Labs, Inc.
Bus 001 Device 010: ID 0cf3:7015 Qualcomm Atheros Communications
TP-Link TL-WN821N v3 / TL-WN822N v2 802.11n [Atheros AR7010+AR9287]
...

*
Jun 02 16:20:11 computer hostapd[14954]: vwlan0: interface state
COUNTRY_UPDATE->HT_SCAN
Jun 02 16:20:17 computer hostapd[14954]: 20/40 MHz operation not
permitted on channel pri=7 sec=3 based on overlapping BSSes
Jun 02 16:20:18 computer kernel: Division by zero in kernel.
Jun 02 16:20:18 computer kernel: CPU: 1 PID: 14507 Comm: kworker/u16:2
Tainted: GW   4.12.0-rc3-dirty #1
Jun 02 16:20:18 computer kernel: Hardware name: SAMSUNG EXYNOS
(Flattened Device Tree)
Jun 02 16:20:18 computer kernel: Workqueue: phy5 ieee80211_scan_work [mac80211]
Jun 02 16:20:18 computer kernel: [] (unwind_backtrace) from
[] (show_stack+0x10/0x14)
Jun 02 16:20:18 computer kernel: [] (show_stack) from
[] (dump_stack+0x88/0x9c)
Jun 02 16:20:18 computer kernel: [] (dump_stack) from
[] (Ldiv0_64+0x8/0x18)
Jun 02 16:20:18 computer kernel: [] (Ldiv0_64) from
[] (ath9k_get_next_tbtt+0x58/0x5c [ath9k_common])
Jun 02 16:20:18 computer kernel: [] (ath9k_get_next_tbtt
[ath9k_common]) from [] (ath9k_cmn_beacon_config
Jun 02 16:20:18 computer kernel: []
(ath9k_cmn_beacon_config_ap [ath9k_common]) from []
(ath9k_htc_beacon
Jun 02 16:20:18 computer kernel: []
(ath9k_htc_beacon_config_ap [ath9k_htc]) from []
(ath9k_htc_vif_recon
Jun 02 16:20:18 computer kernel: [] (ath9k_htc_vif_reconfig
[ath9k_htc]) from [] (ath9k_htc_sw_scan_compl
Jun 02 16:20:18 computer kernel: []
(ath9k_htc_sw_scan_complete [ath9k_htc]) from []
(__ieee80211_scan_co
Jun 02 16:20:18 computer kernel: []
(__ieee80211_scan_completed [mac80211]) from []
(ieee80211_scan_work+
Jun 02 16:20:18 computer kernel: [] (ieee80211_scan_work
[mac80211]) from [] (process_one_work+0x1d8/0x40
Jun 02 16:20:18 computer kernel: [] (process_one_work) from
[] (worker_thread+0x4c/0x564)
Jun 02 16:20:18 computer kernel: [] (worker_thread) from
[] (kthread+0x14c/0x154)
Jun 02 16:20:18 computer kernel: [] (kthread) from
[] (ret_from_fork+0x14/0x3c)
Jun 02 16:20:18 computer hostapd[14954]: Using interface wlan0 with
hwaddr  and ssid ""
Jun 02 16:20:18 computer kernel: IPv6: ADDRCONF(NETDEV_CHANGE):
vwlan0: link becomes ready
*
This is a new one on me.

The "normal" problem (search shows to be a very old issue) I
consistently (daily or multiple times/day) encounter is:
*
Jun 02 14:55:30 computer kernel: usb 1-1.1: ath: firmware panic!
exccause: 0x000d; pc: 0x0090ae81; badvaddr: 0x10ff4038.
Jun 02 14:55:30 computer kernel: usb 1-1.1: USB disconnect, device number 9
Jun 02 14:55:30 computer systemd-networkd[11959]: vwlan0: Lost carrier
Jun 02 14:55:30 computer kernel: br0: port 2(vwlan0) entered disabled state
Jun 02 14:55:30 computer kernel: wlan0: deauthenticating from
 by local choice (Reason: 3=DEAUTH_LEAVING)
Jun 02 14:55:30 computer kernel: ath: phy4: Failed to wakeup in 500us
Jun 02 14:55:30 computer kernel: ath: phy4: Failed to wakeup in 500us
Jun 02 14:55:30 computer kernel: ath: phy4: Failed to wakeup in 500us
Jun 02 14:55:30 computer kernel: ath: phy4: Failed to wakeup in 500us
Jun 02 14:55:30 computer systemd-networkd[11959]: wlan0: Lost carrier
Jun 02 14:55:30 computer systemd[1]: Stopping A simple WPA encrypted
wireless connection using a static IP...
-- Subject: Unit netctl@wlan0.service has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit netctl@wlan0.service has begun shutting down.
Jun 02 14:55:30 computer kernel: device vwlan0 left promiscuous mode
Jun 02 14:55:30 computer kernel: br0: port 2(vwlan0) entered disabled state
Jun 02 14:55:30 computer audit: ANOM_PROMISCUOUS dev=vwlan0 prom=0
old_prom=256 auid=4294967295 uid=0 gid=0 ses=4294967295
Jun 02 14:55:30 computer hostapd[13218]: vwlan0: AP-STA-DISCONNECTED 
Jun 02 14:55:30 computer hostapd[13218]: Failed to set beacon parameters
Jun 02 14:55:30 computer hostapd[13218]: vwlan0: INTERFACE-DISABLED
Jun 02 14:55:30 computer kernel: usb 1-1.1: ath9k_htc: USB layer deinitialized
Jun 02 14:55:30 computer systemd[1]: Starting Load/Save RF Kill Switch Status...
-- Subject: Unit systemd-rfkill.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-rfkill.service has begun starting up.
Jun 02 14:55:30 computer systemd[1]: Started Load/Save RF Kill Switch Status.
-- Subject: Unit systemd-rfkill.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-rfkill.service has finished starting up.
--
-- The start-up result is done.
Jun 02 14:55:30 computer network[13261]: Stopping network profile 'wlan0'...
Jun 02 14:55:30 computer kernel: usb 1-1.1: new high-speed USB 

Re: [PATCH][net-next] rxrpc: remove redundant proc_remove call

2017-06-02 Thread David Howells
Colin King  wrote:

> From: Colin Ian King 
> 
> The proc_remove call is dead code as it occurs after a return and
> hence can never be called. Remove it.
> 
> Detected by CoverityScan, CID#1437743 ("Logically dead code")
> 
> Signed-off-by: Colin Ian King 

Acked-by: David Howells 


Re: Cherry pick commit *net: better skb->sender_cpu and skb->napi_id cohabitation* to 4.4 series?

2017-06-02 Thread Paul Menzel

Dear David,


On 2017-06-02 20:37, David Miller wrote:

From: Cong Wang 
Date: Fri, 2 Jun 2017 10:51:39 -0700

On Thu, Jun 1, 2017 at 10:32 AM, Paul Menzel  
wrote:



On 06/01/17 18:19, David Miller wrote:


Neither of us have anything to do with the 4.4 -stable series.  We 
only

manage stable backport submissions for the most recent two releases.



Thank you for the prompt response. Should the netdev FAQ be updated 
then to

contain that information?


+1

It is quite helpful to know which stable releases contain network 
fixes
which don't, especially for those who rely on stable releases, at 
least

we could do backport by ourselves when we know they are missing.


The people who maintain the -stable releases older than the ones Greg 
KH
are doing typically scan the ones that Greg applies and tries to 
integrate

them into their -stable releases when appropriate.


My understanding is, that Greg maintains the 4.4 (LTS) and 4.9 (LTS) 
series.


If someone wants to write an accurate description of that and how it 
works,

and add it to the FAQ, sure.


I can do that, when I understand the policy.


Kind regards,

Paul


Re: [PATCH net-next 0/2] Fixes for mv88e6161

2017-06-02 Thread Vivien Didelot
Hi Andrew,

Andrew Lunn  writes:

> Testing a board with an mv88e6161 turned up two issues. The PHYs were
> not found, because the wrong method to access them was used. The
> statistics did not work, because the wrong snapshot method was used

Thanks for testing!


Re: [PATCH net-next 1/2] net: dsa: mv88e6xxx: 6161 uses global 2 for PHY access

2017-06-02 Thread Vivien Didelot
Andrew Lunn  writes:

> Access to the internal PHYs of the 6161 and 6123 go through global 2
> SMI registers. Fix the ops structure.
>
> Signed-off-by: Andrew Lunn 

Reviewed-by: Vivien Didelot 


Re: [PATCH net-next 2/2] net: dsa: mv88e6xxx: mv88e6161 uses mv88e6320 stats snapshot

2017-06-02 Thread Vivien Didelot
Andrew Lunn  writes:

> The mv88e6161 was using the wrong method to perform statistics
> snapshot.
>
> Signed-off-by: Andrew Lunn 

Reviewed-by: Vivien Didelot 


[PATCH net-next] net: phy: smsc: Implement PHY statistics

2017-06-02 Thread Andrew Lunn
Most of the PHYs supported by the SMSC driver have a counter of symbol
errors. This is 16 bit wide and wraps around when it reaches its
maximum value.

Signed-off-by: Andrew Lunn 
---
 drivers/net/phy/smsc.c | 72 ++
 1 file changed, 72 insertions(+)

diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index 67c9f2b26c8e..d78b0cd3a435 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -25,6 +25,16 @@
 #include 
 #include 
 
+struct smsc_hw_stat {
+   const char *string;
+   u8 reg;
+   u8 bits;
+};
+
+static struct smsc_hw_stat smsc_hw_stats[] = {
+   { "phy_symbol_errors", 26, 16},
+};
+
 struct smsc_phy_priv {
bool energy_enable;
 };
@@ -143,6 +153,48 @@ static int lan87xx_read_status(struct phy_device *phydev)
return err;
 }
 
+static int smsc_get_sset_count(struct phy_device *phydev)
+{
+   return ARRAY_SIZE(smsc_hw_stats);
+}
+
+static void smsc_get_strings(struct phy_device *phydev, u8 *data)
+{
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(smsc_hw_stats); i++) {
+   memcpy(data + i * ETH_GSTRING_LEN,
+  smsc_hw_stats[i].string, ETH_GSTRING_LEN);
+   }
+}
+
+#ifndef UINT64_MAX
+#define UINT64_MAX  (u64)(~((u64)0))
+#endif
+static u64 smsc_get_stat(struct phy_device *phydev, int i)
+{
+   struct smsc_hw_stat stat = smsc_hw_stats[i];
+   int val;
+   u64 ret;
+
+   val = phy_read(phydev, stat.reg);
+   if (val < 0)
+   ret = UINT64_MAX;
+   else
+   ret = val;
+
+   return ret;
+}
+
+static void smsc_get_stats(struct phy_device *phydev,
+  struct ethtool_stats *stats, u64 *data)
+{
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(smsc_hw_stats); i++)
+   data[i] = smsc_get_stat(phydev, i);
+}
+
 static int smsc_phy_probe(struct phy_device *phydev)
 {
struct device *dev = >mdio.dev;
@@ -206,6 +258,11 @@ static struct phy_driver smsc_phy_driver[] = {
.ack_interrupt  = smsc_phy_ack_interrupt,
.config_intr= smsc_phy_config_intr,
 
+   /* Statistics */
+   .get_sset_count = smsc_get_sset_count,
+   .get_strings = smsc_get_strings,
+   .get_stats = smsc_get_stats,
+
.suspend= genphy_suspend,
.resume = genphy_resume,
 }, {
@@ -228,6 +285,11 @@ static struct phy_driver smsc_phy_driver[] = {
.ack_interrupt  = smsc_phy_ack_interrupt,
.config_intr= smsc_phy_config_intr,
 
+   /* Statistics */
+   .get_sset_count = smsc_get_sset_count,
+   .get_strings = smsc_get_strings,
+   .get_stats = smsc_get_stats,
+
.suspend= genphy_suspend,
.resume = genphy_resume,
 }, {
@@ -271,6 +333,11 @@ static struct phy_driver smsc_phy_driver[] = {
.ack_interrupt  = smsc_phy_ack_interrupt,
.config_intr= smsc_phy_config_intr,
 
+   /* Statistics */
+   .get_sset_count = smsc_get_sset_count,
+   .get_strings = smsc_get_strings,
+   .get_stats = smsc_get_stats,
+
.suspend= genphy_suspend,
.resume = genphy_resume,
 }, {
@@ -293,6 +360,11 @@ static struct phy_driver smsc_phy_driver[] = {
.ack_interrupt  = smsc_phy_ack_interrupt,
.config_intr= smsc_phy_config_intr,
 
+   /* Statistics */
+   .get_sset_count = smsc_get_sset_count,
+   .get_strings = smsc_get_strings,
+   .get_stats = smsc_get_stats,
+
.suspend= genphy_suspend,
.resume = genphy_resume,
 } };
-- 
2.11.0



[PATCH net-next 0/2] Fixes for mv88e6161

2017-06-02 Thread Andrew Lunn
Testing a board with an mv88e6161 turned up two issues. The PHYs were
not found, because the wrong method to access them was used. The
statistics did not work, because the wrong snapshot method was used

Andrew Lunn (2):
  net: dsa: mv88e6xxx: mv88e6161 uses global 2 for PHY access
  net: dsa: mv88e6xxx: mv88e6161 uses mv88e6320 stats snapshot

 drivers/net/dsa/mv88e6xxx/chip.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

-- 
2.11.0



[PATCH net-next 2/2] net: dsa: mv88e6xxx: mv88e6161 uses mv88e6320 stats snapshot

2017-06-02 Thread Andrew Lunn
The mv88e6161 was using the wrong method to perform statistics
snapshot.

Signed-off-by: Andrew Lunn 
---
 drivers/net/dsa/mv88e6xxx/chip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 80ed4ab84028..084bc655020a 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2464,7 +2464,7 @@ static const struct mv88e6xxx_ops mv88e6123_ops = {
.port_set_egress_floods = mv88e6352_port_set_egress_floods,
.port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
.port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
-   .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
+   .stats_snapshot = mv88e6320_g1_stats_snapshot,
.stats_get_sset_count = mv88e6095_stats_get_sset_count,
.stats_get_strings = mv88e6095_stats_get_strings,
.stats_get_stats = mv88e6095_stats_get_stats,
@@ -2558,7 +2558,7 @@ static const struct mv88e6xxx_ops mv88e6161_ops = {
.port_pause_config = mv88e6097_port_pause_config,
.port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
.port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
-   .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
+   .stats_snapshot = mv88e6320_g1_stats_snapshot,
.stats_get_sset_count = mv88e6095_stats_get_sset_count,
.stats_get_strings = mv88e6095_stats_get_strings,
.stats_get_stats = mv88e6095_stats_get_stats,
-- 
2.11.0



[PATCH net-next 1/2] net: dsa: mv88e6xxx: 6161 uses global 2 for PHY access

2017-06-02 Thread Andrew Lunn
Access to the internal PHYs of the 6161 and 6123 go through global 2
SMI registers. Fix the ops structure.

Signed-off-by: Andrew Lunn 
---
 drivers/net/dsa/mv88e6xxx/chip.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 7cf470c3e662..80ed4ab84028 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2455,8 +2455,8 @@ static const struct mv88e6xxx_ops mv88e6097_ops = {
 static const struct mv88e6xxx_ops mv88e6123_ops = {
/* MV88E6XXX_FAMILY_6165 */
.set_switch_mac = mv88e6xxx_g2_set_switch_mac,
-   .phy_read = mv88e6165_phy_read,
-   .phy_write = mv88e6165_phy_write,
+   .phy_read = mv88e6xxx_g2_smi_phy_read,
+   .phy_write = mv88e6xxx_g2_smi_phy_write,
.port_set_link = mv88e6xxx_port_set_link,
.port_set_duplex = mv88e6xxx_port_set_duplex,
.port_set_speed = mv88e6185_port_set_speed,
@@ -2544,8 +2544,8 @@ static const struct mv88e6xxx_ops mv88e6141_ops = {
 static const struct mv88e6xxx_ops mv88e6161_ops = {
/* MV88E6XXX_FAMILY_6165 */
.set_switch_mac = mv88e6xxx_g2_set_switch_mac,
-   .phy_read = mv88e6165_phy_read,
-   .phy_write = mv88e6165_phy_write,
+   .phy_read = mv88e6xxx_g2_smi_phy_read,
+   .phy_write = mv88e6xxx_g2_smi_phy_write,
.port_set_link = mv88e6xxx_port_set_link,
.port_set_duplex = mv88e6xxx_port_set_duplex,
.port_set_speed = mv88e6185_port_set_speed,
-- 
2.11.0



Re: [PATCH net-next 0/5] net: dsa: mv88e6xxx: move registers macros

2017-06-02 Thread Andrew Lunn
On Fri, Jun 02, 2017 at 05:06:14PM -0400, Vivien Didelot wrote:
> This patchset brings no functional changes.
> 
> It is the first step of a cleanup renaming the chip header file and
> moving the Register definitions _as is_ in their proper header files.
> 
> A following patchset will prefix them with the appropriate model
> (MV88E6XXX_ or e.g. MV88E6390_) to respect an implicit namespace and
> easily identify model subtleties in registers layout, as correctly done
> in the newly added serdes.h header.

Reviewed-by: Andrew Lunn 

Andrew


[PATCH net-next 4/5] net: dsa: mv88e6xxx: move the Global 1 macros

2017-06-02 Thread Vivien Didelot
Move the GLOBAL_* macros where they belong, in the related global1.h
header. Include it in global2.c which uses GLOBAL_STATUS_IRQ_DEVICE.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/mv88e6xxx/chip.h| 141 
 drivers/net/dsa/mv88e6xxx/global1.h | 141 
 drivers/net/dsa/mv88e6xxx/global2.c |   1 +
 3 files changed, 142 insertions(+), 141 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h
index a7c71a43503b..7e558e9ba35d 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.h
+++ b/drivers/net/dsa/mv88e6xxx/chip.h
@@ -33,147 +33,6 @@
 #define SMI_CMD_OP_45_READ_DATA_INC((3 << 10) | SMI_CMD_BUSY)
 #define SMI_DATA   0x01
 
-#define GLOBAL_STATUS  0x00
-#define GLOBAL_STATUS_PPU_STATE BIT(15) /* 6351 and 6171 */
-#define GLOBAL_STATUS_PPU_STATE_MASK   (0x3 << 14) /* 6165 6185 */
-#define GLOBAL_STATUS_PPU_STATE_DISABLED_RST   (0x0 << 14)
-#define GLOBAL_STATUS_PPU_STATE_INITIALIZING   (0x1 << 14)
-#define GLOBAL_STATUS_PPU_STATE_DISABLED   (0x2 << 14)
-#define GLOBAL_STATUS_PPU_STATE_POLLING(0x3 << 14)
-#define GLOBAL_STATUS_INIT_READY   BIT(11)
-#define GLOBAL_STATUS_IRQ_AVB  8
-#define GLOBAL_STATUS_IRQ_DEVICE   7
-#define GLOBAL_STATUS_IRQ_STATS6
-#define GLOBAL_STATUS_IRQ_VTU_PROBLEM  5
-#define GLOBAL_STATUS_IRQ_VTU_DONE 4
-#define GLOBAL_STATUS_IRQ_ATU_PROBLEM  3
-#define GLOBAL_STATUS_IRQ_ATU_DONE 2
-#define GLOBAL_STATUS_IRQ_TCAM_DONE1
-#define GLOBAL_STATUS_IRQ_EEPROM_DONE  0
-#define GLOBAL_MAC_01  0x01
-#define GLOBAL_MAC_23  0x02
-#define GLOBAL_MAC_45  0x03
-#define GLOBAL_ATU_FID 0x01
-#define GLOBAL_VTU_FID 0x02
-#define GLOBAL_VTU_FID_MASK0xfff
-#define GLOBAL_VTU_SID 0x03/* 6097 6165 6351 6352 */
-#define GLOBAL_VTU_SID_MASK0x3f
-#define GLOBAL_CONTROL 0x04
-#define GLOBAL_CONTROL_SW_RESETBIT(15)
-#define GLOBAL_CONTROL_PPU_ENABLE  BIT(14)
-#define GLOBAL_CONTROL_DISCARD_EXCESS  BIT(13) /* 6352 */
-#define GLOBAL_CONTROL_SCHED_PRIO  BIT(11) /* 6152 */
-#define GLOBAL_CONTROL_MAX_FRAME_1632  BIT(10) /* 6152 */
-#define GLOBAL_CONTROL_RELOAD_EEPROM   BIT(9)  /* 6152 */
-#define GLOBAL_CONTROL_DEVICE_EN   BIT(7)
-#define GLOBAL_CONTROL_STATS_DONE_EN   BIT(6)
-#define GLOBAL_CONTROL_VTU_PROBLEM_EN  BIT(5)
-#define GLOBAL_CONTROL_VTU_DONE_EN BIT(4)
-#define GLOBAL_CONTROL_ATU_PROBLEM_EN  BIT(3)
-#define GLOBAL_CONTROL_ATU_DONE_EN BIT(2)
-#define GLOBAL_CONTROL_TCAM_EN BIT(1)
-#define GLOBAL_CONTROL_EEPROM_DONE_EN  BIT(0)
-#define GLOBAL_VTU_OP  0x05
-#define GLOBAL_VTU_OP_BUSY BIT(15)
-#define GLOBAL_VTU_OP_FLUSH_ALL((0x01 << 12) | 
GLOBAL_VTU_OP_BUSY)
-#define GLOBAL_VTU_OP_VTU_LOAD_PURGE   ((0x03 << 12) | GLOBAL_VTU_OP_BUSY)
-#define GLOBAL_VTU_OP_VTU_GET_NEXT ((0x04 << 12) | GLOBAL_VTU_OP_BUSY)
-#define GLOBAL_VTU_OP_STU_LOAD_PURGE   ((0x05 << 12) | GLOBAL_VTU_OP_BUSY)
-#define GLOBAL_VTU_OP_STU_GET_NEXT ((0x06 << 12) | GLOBAL_VTU_OP_BUSY)
-#define GLOBAL_VTU_VID 0x06
-#define GLOBAL_VTU_VID_MASK0xfff
-#define GLOBAL_VTU_VID_PAGEBIT(13)
-#define GLOBAL_VTU_VID_VALID   BIT(12)
-#define GLOBAL_VTU_DATA_0_30x07
-#define GLOBAL_VTU_DATA_4_70x08
-#define GLOBAL_VTU_DATA_8_11   0x09
-#define GLOBAL_VTU_STU_DATA_MASK   0x03
-#define GLOBAL_VTU_DATA_MEMBER_TAG_UNMODIFIED  0x00
-#define GLOBAL_VTU_DATA_MEMBER_TAG_UNTAGGED0x01
-#define GLOBAL_VTU_DATA_MEMBER_TAG_TAGGED  0x02
-#define GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER  0x03
-#define GLOBAL_STU_DATA_PORT_STATE_DISABLED0x00
-#define GLOBAL_STU_DATA_PORT_STATE_BLOCKING0x01
-#define GLOBAL_STU_DATA_PORT_STATE_LEARNING0x02
-#define GLOBAL_STU_DATA_PORT_STATE_FORWARDING  0x03
-#define GLOBAL_ATU_CONTROL 0x0a
-#define GLOBAL_ATU_CONTROL_LEARN2ALL   BIT(3)
-#define GLOBAL_ATU_OP  0x0b
-#define GLOBAL_ATU_OP_BUSY BIT(15)
-#define GLOBAL_ATU_OP_NOP  (0 << 12)
-#define GLOBAL_ATU_OP_FLUSH_MOVE_ALL   ((1 << 12) | GLOBAL_ATU_OP_BUSY)
-#define GLOBAL_ATU_OP_FLUSH_MOVE_NON_STATIC((2 << 12) | GLOBAL_ATU_OP_BUSY)
-#define GLOBAL_ATU_OP_LOAD_DB  ((3 << 12) | GLOBAL_ATU_OP_BUSY)
-#define GLOBAL_ATU_OP_GET_NEXT_DB  ((4 << 12) | GLOBAL_ATU_OP_BUSY)
-#define GLOBAL_ATU_OP_FLUSH_MOVE_ALL_DB((5 << 12) | 
GLOBAL_ATU_OP_BUSY)
-#define GLOBAL_ATU_OP_FLUSH_MOVE_NON_STATIC_DB ((6 << 12) | GLOBAL_ATU_OP_BUSY)
-#define GLOBAL_ATU_OP_GET_CLR_VIOLATION  ((7 << 12) | 
GLOBAL_ATU_OP_BUSY)
-#define GLOBAL_ATU_DATA0x0c
-#define GLOBAL_ATU_DATA_TRUNK  BIT(15)
-#define GLOBAL_ATU_DATA_TRUNK_ID_MASK  0x00f0
-#define GLOBAL_ATU_DATA_TRUNK_ID_SHIFT 4
-#define GLOBAL_ATU_DATA_PORT_VECTOR_MASK   0x3ff0
-#define 

[PATCH net-next 5/5] net: dsa: mv88e6xxx: move the Global 2 macros

2017-06-02 Thread Vivien Didelot
Move the GLOBAL2_* macros where they belong, in the related global2.h
header.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/mv88e6xxx/chip.h| 101 ---
 drivers/net/dsa/mv88e6xxx/global2.c |   2 -
 drivers/net/dsa/mv88e6xxx/global2.h | 103 
 3 files changed, 103 insertions(+), 103 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h
index 7e558e9ba35d..98c24af977fd 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.h
+++ b/drivers/net/dsa/mv88e6xxx/chip.h
@@ -33,107 +33,6 @@
 #define SMI_CMD_OP_45_READ_DATA_INC((3 << 10) | SMI_CMD_BUSY)
 #define SMI_DATA   0x01
 
-#define GLOBAL2_INT_SOURCE 0x00
-#define GLOBAL2_INT_SOURCE_WATCHDOG15
-#define GLOBAL2_INT_MASK   0x01
-#define GLOBAL2_MGMT_EN_2X 0x02
-#define GLOBAL2_MGMT_EN_0X 0x03
-#define GLOBAL2_FLOW_CONTROL   0x04
-#define GLOBAL2_SWITCH_MGMT0x05
-#define GLOBAL2_SWITCH_MGMT_USE_DOUBLE_TAG_DATABIT(15)
-#define GLOBAL2_SWITCH_MGMT_PREVENT_LOOPS  BIT(14)
-#define GLOBAL2_SWITCH_MGMT_FLOW_CONTROL_MSG   BIT(13)
-#define GLOBAL2_SWITCH_MGMT_FORCE_FLOW_CTRL_PRIBIT(7)
-#define GLOBAL2_SWITCH_MGMT_RSVD2CPU   BIT(3)
-#define GLOBAL2_DEVICE_MAPPING 0x06
-#define GLOBAL2_DEVICE_MAPPING_UPDATE  BIT(15)
-#define GLOBAL2_DEVICE_MAPPING_TARGET_SHIFT8
-#define GLOBAL2_DEVICE_MAPPING_PORT_MASK   0x0f
-#define GLOBAL2_TRUNK_MASK 0x07
-#define GLOBAL2_TRUNK_MASK_UPDATE  BIT(15)
-#define GLOBAL2_TRUNK_MASK_NUM_SHIFT   12
-#define GLOBAL2_TRUNK_MASK_HASKBIT(11)
-#define GLOBAL2_TRUNK_MAPPING  0x08
-#define GLOBAL2_TRUNK_MAPPING_UPDATE   BIT(15)
-#define GLOBAL2_TRUNK_MAPPING_ID_SHIFT 11
-#define GLOBAL2_IRL_CMD0x09
-#define GLOBAL2_IRL_CMD_BUSY   BIT(15)
-#define GLOBAL2_IRL_CMD_OP_INIT_ALL((0x001 << 12) | GLOBAL2_IRL_CMD_BUSY)
-#define GLOBAL2_IRL_CMD_OP_INIT_SEL((0x010 << 12) | GLOBAL2_IRL_CMD_BUSY)
-#define GLOBAL2_IRL_CMD_OP_WRITE_SEL   ((0x011 << 12) | GLOBAL2_IRL_CMD_BUSY)
-#define GLOBAL2_IRL_CMD_OP_READ_SEL((0x100 << 12) | GLOBAL2_IRL_CMD_BUSY)
-#define GLOBAL2_IRL_DATA   0x0a
-#define GLOBAL2_PVT_ADDR   0x0b
-#define GLOBAL2_PVT_ADDR_BUSY  BIT(15)
-#define GLOBAL2_PVT_ADDR_OP_INIT_ONES  ((0x01 << 12) | GLOBAL2_PVT_ADDR_BUSY)
-#define GLOBAL2_PVT_ADDR_OP_WRITE_PVLAN((0x03 << 12) | 
GLOBAL2_PVT_ADDR_BUSY)
-#define GLOBAL2_PVT_ADDR_OP_READ   ((0x04 << 12) | GLOBAL2_PVT_ADDR_BUSY)
-#define GLOBAL2_PVT_DATA   0x0c
-#define GLOBAL2_SWITCH_MAC 0x0d
-#define GLOBAL2_ATU_STATS  0x0e
-#define GLOBAL2_PRIO_OVERRIDE  0x0f
-#define GLOBAL2_PRIO_OVERRIDE_FORCE_SNOOP  BIT(7)
-#define GLOBAL2_PRIO_OVERRIDE_SNOOP_SHIFT  4
-#define GLOBAL2_PRIO_OVERRIDE_FORCE_ARPBIT(3)
-#define GLOBAL2_PRIO_OVERRIDE_ARP_SHIFT0
-#define GLOBAL2_EEPROM_CMD 0x14
-#define GLOBAL2_EEPROM_CMD_BUSYBIT(15)
-#define GLOBAL2_EEPROM_CMD_OP_WRITE((0x3 << 12) | GLOBAL2_EEPROM_CMD_BUSY)
-#define GLOBAL2_EEPROM_CMD_OP_READ ((0x4 << 12) | GLOBAL2_EEPROM_CMD_BUSY)
-#define GLOBAL2_EEPROM_CMD_OP_LOAD ((0x6 << 12) | GLOBAL2_EEPROM_CMD_BUSY)
-#define GLOBAL2_EEPROM_CMD_RUNNING BIT(11)
-#define GLOBAL2_EEPROM_CMD_WRITE_ENBIT(10)
-#define GLOBAL2_EEPROM_CMD_ADDR_MASK   0xff
-#define GLOBAL2_EEPROM_DATA0x15
-#define GLOBAL2_EEPROM_ADDR0x15 /* 6390, 6341 */
-#define GLOBAL2_PTP_AVB_OP 0x16
-#define GLOBAL2_PTP_AVB_DATA   0x17
-#define GLOBAL2_SMI_PHY_CMD0x18
-#define GLOBAL2_SMI_PHY_CMD_BUSY   BIT(15)
-#define GLOBAL2_SMI_PHY_CMD_EXTERNAL   BIT(13)
-#define GLOBAL2_SMI_PHY_CMD_MODE_22BIT(12)
-#define GLOBAL2_SMI_PHY_CMD_OP_22_WRITE_DATA   ((0x1 << 10) | \
-GLOBAL2_SMI_PHY_CMD_MODE_22 | \
-GLOBAL2_SMI_PHY_CMD_BUSY)
-#define GLOBAL2_SMI_PHY_CMD_OP_22_READ_DATA((0x2 << 10) | \
-GLOBAL2_SMI_PHY_CMD_MODE_22 | \
-GLOBAL2_SMI_PHY_CMD_BUSY)
-#define GLOBAL2_SMI_PHY_CMD_OP_45_WRITE_ADDR   ((0x0 << 10) | \
-GLOBAL2_SMI_PHY_CMD_BUSY)
-#define GLOBAL2_SMI_PHY_CMD_OP_45_WRITE_DATA   ((0x1 << 10) | \
-GLOBAL2_SMI_PHY_CMD_BUSY)
-#define GLOBAL2_SMI_PHY_CMD_OP_45_READ_DATA((0x3 << 10) | \
-GLOBAL2_SMI_PHY_CMD_BUSY)
-
-#define GLOBAL2_SMI_PHY_DATA   0x19
-#define GLOBAL2_SCRATCH_MISC   0x1a
-#define GLOBAL2_SCRATCH_BUSY   BIT(15)
-#define GLOBAL2_SCRATCH_REGISTER_SHIFT 8
-#define GLOBAL2_SCRATCH_VALUE_MASK 0xff
-#define GLOBAL2_WDOG_CONTROL   0x1b
-#define 

[PATCH net-next 3/5] net: dsa: mv88e6xxx: move the Port macros

2017-06-02 Thread Vivien Didelot
Move the PORT_* macros where they belong, in the related port.h header.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/mv88e6xxx/chip.h | 160 ---
 drivers/net/dsa/mv88e6xxx/port.h | 160 +++
 2 files changed, 160 insertions(+), 160 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h
index 2929132fb52d..a7c71a43503b 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.h
+++ b/drivers/net/dsa/mv88e6xxx/chip.h
@@ -33,166 +33,6 @@
 #define SMI_CMD_OP_45_READ_DATA_INC((3 << 10) | SMI_CMD_BUSY)
 #define SMI_DATA   0x01
 
-#define PORT_STATUS0x00
-#define PORT_STATUS_PAUSE_EN   BIT(15)
-#define PORT_STATUS_MY_PAUSE   BIT(14)
-#define PORT_STATUS_HD_FLOWBIT(13)
-#define PORT_STATUS_PHY_DETECT BIT(12)
-#define PORT_STATUS_LINK   BIT(11)
-#define PORT_STATUS_DUPLEX BIT(10)
-#define PORT_STATUS_SPEED_MASK 0x0300
-#define PORT_STATUS_SPEED_10   0x
-#define PORT_STATUS_SPEED_100  0x0100
-#define PORT_STATUS_SPEED_1000 0x0200
-#define PORT_STATUS_EEEBIT(6) /* 6352 */
-#define PORT_STATUS_AM_DIS BIT(6) /* 6165 */
-#define PORT_STATUS_MGMII  BIT(6) /* 6185 */
-#define PORT_STATUS_TX_PAUSED  BIT(5)
-#define PORT_STATUS_FLOW_CTRL  BIT(4)
-#define PORT_STATUS_CMODE_MASK 0x0f
-#define PORT_STATUS_CMODE_100BASE_X0x8
-#define PORT_STATUS_CMODE_1000BASE_X   0x9
-#define PORT_STATUS_CMODE_SGMII0xa
-#define PORT_STATUS_CMODE_2500BASEX0xb
-#define PORT_STATUS_CMODE_XAUI 0xc
-#define PORT_STATUS_CMODE_RXAUI0xd
-#define PORT_PCS_CTRL  0x01
-#define PORT_PCS_CTRL_RGMII_DELAY_RXCLKBIT(15)
-#define PORT_PCS_CTRL_RGMII_DELAY_TXCLKBIT(14)
-#define PORT_PCS_CTRL_FORCE_SPEED  BIT(13) /* 6390 */
-#define PORT_PCS_CTRL_ALTSPEED BIT(12) /* 6390 */
-#define PORT_PCS_CTRL_200BASE  BIT(12) /* 6352 */
-#define PORT_PCS_CTRL_FC   BIT(7)
-#define PORT_PCS_CTRL_FORCE_FC BIT(6)
-#define PORT_PCS_CTRL_LINK_UP  BIT(5)
-#define PORT_PCS_CTRL_FORCE_LINK   BIT(4)
-#define PORT_PCS_CTRL_DUPLEX_FULL  BIT(3)
-#define PORT_PCS_CTRL_FORCE_DUPLEX BIT(2)
-#define PORT_PCS_CTRL_SPEED_MASK   (0x03)
-#define PORT_PCS_CTRL_SPEED_10 (0x00)
-#define PORT_PCS_CTRL_SPEED_100(0x01)
-#define PORT_PCS_CTRL_SPEED_200(0x02) /* 6065 and non Gb chips 
*/
-#define PORT_PCS_CTRL_SPEED_1000   (0x02)
-#define PORT_PCS_CTRL_SPEED_1  (0x03) /* 6390X */
-#define PORT_PCS_CTRL_SPEED_UNFORCED   (0x03)
-#define PORT_PAUSE_CTRL0x02
-#define PORT_FLOW_CTRL_LIMIT_IN((0x00 << 8) | BIT(15))
-#define PORT_FLOW_CTRL_LIMIT_OUT   ((0x01 << 8) | BIT(15))
-#define PORT_SWITCH_ID 0x03
-#define PORT_SWITCH_ID_PROD_NUM_6085   0x04a
-#define PORT_SWITCH_ID_PROD_NUM_6095   0x095
-#define PORT_SWITCH_ID_PROD_NUM_6097   0x099
-#define PORT_SWITCH_ID_PROD_NUM_6131   0x106
-#define PORT_SWITCH_ID_PROD_NUM_6320   0x115
-#define PORT_SWITCH_ID_PROD_NUM_6123   0x121
-#define PORT_SWITCH_ID_PROD_NUM_6141   0x340
-#define PORT_SWITCH_ID_PROD_NUM_6161   0x161
-#define PORT_SWITCH_ID_PROD_NUM_6165   0x165
-#define PORT_SWITCH_ID_PROD_NUM_6171   0x171
-#define PORT_SWITCH_ID_PROD_NUM_6172   0x172
-#define PORT_SWITCH_ID_PROD_NUM_6175   0x175
-#define PORT_SWITCH_ID_PROD_NUM_6176   0x176
-#define PORT_SWITCH_ID_PROD_NUM_6185   0x1a7
-#define PORT_SWITCH_ID_PROD_NUM_6190   0x190
-#define PORT_SWITCH_ID_PROD_NUM_6190X  0x0a0
-#define PORT_SWITCH_ID_PROD_NUM_6191   0x191
-#define PORT_SWITCH_ID_PROD_NUM_6240   0x240
-#define PORT_SWITCH_ID_PROD_NUM_6290   0x290
-#define PORT_SWITCH_ID_PROD_NUM_6321   0x310
-#define PORT_SWITCH_ID_PROD_NUM_6341   0x341
-#define PORT_SWITCH_ID_PROD_NUM_6352   0x352
-#define PORT_SWITCH_ID_PROD_NUM_6350   0x371
-#define PORT_SWITCH_ID_PROD_NUM_6351   0x375
-#define PORT_SWITCH_ID_PROD_NUM_6390   0x390
-#define PORT_SWITCH_ID_PROD_NUM_6390X  0x0a1
-#define PORT_CONTROL   0x04
-#define PORT_CONTROL_USE_CORE_TAG  BIT(15)
-#define PORT_CONTROL_DROP_ON_LOCK  BIT(14)
-#define PORT_CONTROL_EGRESS_UNMODIFIED (0x0 << 12)
-#define PORT_CONTROL_EGRESS_UNTAGGED   (0x1 << 12)
-#define PORT_CONTROL_EGRESS_TAGGED (0x2 << 12)
-#define PORT_CONTROL_EGRESS_ADD_TAG(0x3 << 12)
-#define PORT_CONTROL_EGRESS_MASK   (0x3 << 12)
-#define PORT_CONTROL_HEADERBIT(11)
-#define PORT_CONTROL_IGMP_MLD_SNOOPBIT(10)
-#define PORT_CONTROL_DOUBLE_TAGBIT(9)
-#define PORT_CONTROL_FRAME_MODE_NORMAL (0x0 << 8)
-#define PORT_CONTROL_FRAME_MODE_DSA(0x1 << 8)
-#define PORT_CONTROL_FRAME_MODE_PROVIDER   (0x2 << 8)
-#define PORT_CONTROL_FRAME_ETHER_TYPE_DSA  (0x3 << 8)
-#define PORT_CONTROL_FRAME_MASK(0x3 << 8)
-#define PORT_CONTROL_DSA_TAG   BIT(8)
-#define 

[PATCH net-next 2/5] net: dsa: mv88e6xxx: move PHY macros

2017-06-02 Thread Vivien Didelot
Move the PHY_* macros where they belong, in the related phy.h header.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/mv88e6xxx/chip.h | 4 
 drivers/net/dsa/mv88e6xxx/phy.h  | 3 +++
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h
index ae7aed533aa5..2929132fb52d 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.h
+++ b/drivers/net/dsa/mv88e6xxx/chip.h
@@ -33,10 +33,6 @@
 #define SMI_CMD_OP_45_READ_DATA_INC((3 << 10) | SMI_CMD_BUSY)
 #define SMI_DATA   0x01
 
-/* PHY Registers */
-#define PHY_PAGE   0x16
-#define PHY_PAGE_COPPER0x00
-
 #define PORT_STATUS0x00
 #define PORT_STATUS_PAUSE_EN   BIT(15)
 #define PORT_STATUS_MY_PAUSE   BIT(14)
diff --git a/drivers/net/dsa/mv88e6xxx/phy.h b/drivers/net/dsa/mv88e6xxx/phy.h
index 91fe3c3e9aea..4131a4e8206a 100644
--- a/drivers/net/dsa/mv88e6xxx/phy.h
+++ b/drivers/net/dsa/mv88e6xxx/phy.h
@@ -14,6 +14,9 @@
 #ifndef _MV88E6XXX_PHY_H
 #define _MV88E6XXX_PHY_H
 
+#define PHY_PAGE   0x16
+#define PHY_PAGE_COPPER0x00
+
 /* PHY Registers accesses implementations */
 int mv88e6165_phy_read(struct mv88e6xxx_chip *chip, struct mii_bus *bus,
   int addr, int reg, u16 *val);
-- 
2.13.0



[PATCH net-next 0/5] net: dsa: mv88e6xxx: move registers macros

2017-06-02 Thread Vivien Didelot
This patchset brings no functional changes.

It is the first step of a cleanup renaming the chip header file and
moving the Register definitions _as is_ in their proper header files.

A following patchset will prefix them with the appropriate model
(MV88E6XXX_ or e.g. MV88E6390_) to respect an implicit namespace and
easily identify model subtleties in registers layout, as correctly done
in the newly added serdes.h header.

Vivien Didelot (5):
  net: dsa: mv88e6xxx: rename chip header
  net: dsa: mv88e6xxx: move PHY macros
  net: dsa: mv88e6xxx: move the Port macros
  net: dsa: mv88e6xxx: move the Global 1 macros
  net: dsa: mv88e6xxx: move the Global 2 macros

 drivers/net/dsa/mv88e6xxx/chip.c|   2 +-
 drivers/net/dsa/mv88e6xxx/chip.h| 522 ++
 drivers/net/dsa/mv88e6xxx/global1.c |   2 +-
 drivers/net/dsa/mv88e6xxx/global1.h | 143 -
 drivers/net/dsa/mv88e6xxx/global1_atu.c |   2 +-
 drivers/net/dsa/mv88e6xxx/global1_vtu.c |   2 +-
 drivers/net/dsa/mv88e6xxx/global2.c |   6 +-
 drivers/net/dsa/mv88e6xxx/global2.h | 105 +++-
 drivers/net/dsa/mv88e6xxx/mv88e6xxx.h   | 927 
 drivers/net/dsa/mv88e6xxx/phy.c |   2 +-
 drivers/net/dsa/mv88e6xxx/phy.h |   3 +
 drivers/net/dsa/mv88e6xxx/port.c|   3 +-
 drivers/net/dsa/mv88e6xxx/port.h| 162 +-
 drivers/net/dsa/mv88e6xxx/serdes.c  |   2 +-
 drivers/net/dsa/mv88e6xxx/serdes.h  |   2 +-
 15 files changed, 944 insertions(+), 941 deletions(-)
 create mode 100644 drivers/net/dsa/mv88e6xxx/chip.h
 delete mode 100644 drivers/net/dsa/mv88e6xxx/mv88e6xxx.h

-- 
2.13.0



[PATCH net-next 1/5] net: dsa: mv88e6xxx: rename chip header

2017-06-02 Thread Vivien Didelot
The mv88e6xxx.h is meant to contains the chip structures and data.
Rename it to chip.h, as for other source/header pairs of the driver.

At the same time, ensure that relative header inclusions are separated
by a newline and sorted alphabetically.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/mv88e6xxx/chip.c  | 2 +-
 drivers/net/dsa/mv88e6xxx/{mv88e6xxx.h => chip.h} | 9 +
 drivers/net/dsa/mv88e6xxx/global1.c   | 2 +-
 drivers/net/dsa/mv88e6xxx/global1.h   | 2 +-
 drivers/net/dsa/mv88e6xxx/global1_atu.c   | 2 +-
 drivers/net/dsa/mv88e6xxx/global1_vtu.c   | 2 +-
 drivers/net/dsa/mv88e6xxx/global2.c   | 3 ++-
 drivers/net/dsa/mv88e6xxx/global2.h   | 2 +-
 drivers/net/dsa/mv88e6xxx/phy.c   | 2 +-
 drivers/net/dsa/mv88e6xxx/port.c  | 3 ++-
 drivers/net/dsa/mv88e6xxx/port.h  | 2 +-
 drivers/net/dsa/mv88e6xxx/serdes.c| 2 +-
 drivers/net/dsa/mv88e6xxx/serdes.h| 2 +-
 13 files changed, 19 insertions(+), 16 deletions(-)
 rename drivers/net/dsa/mv88e6xxx/{mv88e6xxx.h => chip.h} (99%)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 7cf470c3e662..0176254cb3c7 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -33,7 +33,7 @@
 #include 
 #include 
 
-#include "mv88e6xxx.h"
+#include "chip.h"
 #include "global1.h"
 #include "global2.h"
 #include "phy.h"
diff --git a/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h 
b/drivers/net/dsa/mv88e6xxx/chip.h
similarity index 99%
rename from drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
rename to drivers/net/dsa/mv88e6xxx/chip.h
index 9087cb009cc3..ae7aed533aa5 100644
--- a/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx/chip.h
@@ -1,5 +1,5 @@
 /*
- * Marvell 88e6xxx common definitions
+ * Marvell 88E6xxx Ethernet switch single-chip definition
  *
  * Copyright (c) 2008 Marvell Semiconductor
  *
@@ -9,8 +9,8 @@
  * (at your option) any later version.
  */
 
-#ifndef __MV88E6XXX_H
-#define __MV88E6XXX_H
+#ifndef _MV88E6XXX_CHIP_H
+#define _MV88E6XXX_CHIP_H
 
 #include 
 #include 
@@ -924,4 +924,5 @@ int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, 
int reg,
 u16 update);
 int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask);
 struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip);
-#endif
+
+#endif /* _MV88E6XXX_CHIP_H */
diff --git a/drivers/net/dsa/mv88e6xxx/global1.c 
b/drivers/net/dsa/mv88e6xxx/global1.c
index 39825837a1c9..4081ff0d38a0 100644
--- a/drivers/net/dsa/mv88e6xxx/global1.c
+++ b/drivers/net/dsa/mv88e6xxx/global1.c
@@ -12,7 +12,7 @@
  * (at your option) any later version.
  */
 
-#include "mv88e6xxx.h"
+#include "chip.h"
 #include "global1.h"
 
 int mv88e6xxx_g1_read(struct mv88e6xxx_chip *chip, int reg, u16 *val)
diff --git a/drivers/net/dsa/mv88e6xxx/global1.h 
b/drivers/net/dsa/mv88e6xxx/global1.h
index 46a4ea0f8c47..3b8f356b348c 100644
--- a/drivers/net/dsa/mv88e6xxx/global1.h
+++ b/drivers/net/dsa/mv88e6xxx/global1.h
@@ -15,7 +15,7 @@
 #ifndef _MV88E6XXX_GLOBAL1_H
 #define _MV88E6XXX_GLOBAL1_H
 
-#include "mv88e6xxx.h"
+#include "chip.h"
 
 int mv88e6xxx_g1_read(struct mv88e6xxx_chip *chip, int reg, u16 *val);
 int mv88e6xxx_g1_write(struct mv88e6xxx_chip *chip, int reg, u16 val);
diff --git a/drivers/net/dsa/mv88e6xxx/global1_atu.c 
b/drivers/net/dsa/mv88e6xxx/global1_atu.c
index fa7e7db5171b..6b0cf44dc07d 100644
--- a/drivers/net/dsa/mv88e6xxx/global1_atu.c
+++ b/drivers/net/dsa/mv88e6xxx/global1_atu.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include "mv88e6xxx.h"
+#include "chip.h"
 #include "global1.h"
 
 /* Offset 0x01: ATU FID Register */
diff --git a/drivers/net/dsa/mv88e6xxx/global1_vtu.c 
b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
index 9aea22d4c9e2..bf593c7aaa9b 100644
--- a/drivers/net/dsa/mv88e6xxx/global1_vtu.c
+++ b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
@@ -11,7 +11,7 @@
  * (at your option) any later version.
  */
 
-#include "mv88e6xxx.h"
+#include "chip.h"
 #include "global1.h"
 
 /* Offset 0x02: VTU FID Register */
diff --git a/drivers/net/dsa/mv88e6xxx/global2.c 
b/drivers/net/dsa/mv88e6xxx/global2.c
index b3fea55071e3..0defce71e381 100644
--- a/drivers/net/dsa/mv88e6xxx/global2.c
+++ b/drivers/net/dsa/mv88e6xxx/global2.c
@@ -15,7 +15,8 @@
 
 #include 
 #include 
-#include "mv88e6xxx.h"
+
+#include "chip.h"
 #include "global2.h"
 
 #define ADDR_GLOBAL2   0x1c
diff --git a/drivers/net/dsa/mv88e6xxx/global2.h 
b/drivers/net/dsa/mv88e6xxx/global2.h
index 96046bb12ca1..b5cfe041ee59 100644
--- a/drivers/net/dsa/mv88e6xxx/global2.h
+++ b/drivers/net/dsa/mv88e6xxx/global2.h
@@ -15,7 +15,7 @@
 #ifndef _MV88E6XXX_GLOBAL2_H
 #define _MV88E6XXX_GLOBAL2_H
 
-#include "mv88e6xxx.h"
+#include "chip.h"
 
 #ifdef CONFIG_NET_DSA_MV88E6XXX_GLOBAL2
 
diff --git 

Re: [PATCH] amd-xgbe: use PAGE_ALLOC_COSTLY_ORDER in xgbe_map_rx_buffer

2017-06-02 Thread Tom Lendacky

On 6/2/2017 10:54 AM, Michal Hocko wrote:

From: Michal Hocko 

xgbe_map_rx_buffer is rather confused about what PAGE_ALLOC_COSTLY_ORDER
means. It uses PAGE_ALLOC_COSTLY_ORDER-1 assuming that
PAGE_ALLOC_COSTLY_ORDER is the first costly order which is not the case
actually because orders larger than that are costly. And even that
applies only to sleeping allocations which is not the case here. We
simply do not perform any costly operations like reclaim or compaction
for those. Simplify the code by dropping the order calculation and use
PAGE_ALLOC_COSTLY_ORDER directly.

Signed-off-by: Michal Hocko 


Acked-by: Tom Lendacky 


---
  drivers/net/ethernet/amd/xgbe/xgbe-desc.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c 
b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
index b3bc87fe3764..0a98c369df20 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
@@ -324,7 +324,7 @@ static int xgbe_map_rx_buffer(struct xgbe_prv_data *pdata,
  struct xgbe_ring *ring,
  struct xgbe_ring_data *rdata)
  {
-   int order, ret;
+   int ret;
  
  	if (!ring->rx_hdr_pa.pages) {

ret = xgbe_alloc_pages(pdata, >rx_hdr_pa, GFP_ATOMIC, 0);
@@ -333,9 +333,8 @@ static int xgbe_map_rx_buffer(struct xgbe_prv_data *pdata,
}
  
  	if (!ring->rx_buf_pa.pages) {

-   order = max_t(int, PAGE_ALLOC_COSTLY_ORDER - 1, 0);
ret = xgbe_alloc_pages(pdata, >rx_buf_pa, GFP_ATOMIC,
-  order);
+  PAGE_ALLOC_COSTLY_ORDER);
if (ret)
return ret;
}



Re: [for-next 4/6] net/mlx5: FPGA, Add basic support for Innova

2017-06-02 Thread Doug Ledford
On Fri, 2017-06-02 at 16:31 -0400, Jes Sorensen wrote:
> 
> > It is already modular like that. See CONFIG_MLX5_FPGA.
> 
> [jes@xpeas netdev.git]$ grep CONFIG_MLX5_FPGA 
> drivers/net/ethernet/mellanox/mlx5/core/*
> [jes@xpeas netdev.git]$
> 
> Which git tree am I supposed to look at?

net-next

-- 
Doug Ledford 
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD



Re: [for-next 4/6] net/mlx5: FPGA, Add basic support for Innova

2017-06-02 Thread Jes Sorensen

On 05/28/2017 03:24 AM, Ilan Tayari wrote:

-Original Message-
From: Jes Sorensen [mailto:jsoren...@fb.com]

On 05/26/2017 04:29 AM, Saeed Mahameed wrote:

On Thu, May 25, 2017 at 11:48 PM, Jes Sorensen  wrote:

On 05/25/2017 06:40 AM, Saeed Mahameed wrote:

Hi Jes,

No, It is clearly stated in the commit message :

"The FPGA is a bump-on-the-wire and thus affects operation of
the mlx5_core driver on the ConnectX ASIC."

Which means mlx5 FPGA user can only write logic which affects only
packets going in/out
A ConnectX chip - so it is only network stuff -.


We have this with other devices in the kernel where a primary device

driver

provides an interface for an additional sub-driver to access another

device

behind it. Like bt-coexist in some of the wifi drivers allowing access

to a

bluetooth device behind it.


Blutooth over wifi or vise versa is a very good example to what you
are requesting.
But, it doesn't fit to what we are trying to do here. mlx5 FGPA is a
ConnectX card feature, not a new protocol.


In that case it would need to be an optional module that can be enabled
or disabled at build time.


Jes,

It is already modular like that. See CONFIG_MLX5_FPGA.


[jes@xpeas netdev.git]$ grep CONFIG_MLX5_FPGA 
drivers/net/ethernet/mellanox/mlx5/core/*

[jes@xpeas netdev.git]$

Which git tree am I supposed to look at?

Jes


Re: [PATCH] virtio_net: lower limit on buffer size

2017-06-02 Thread J. Bruce Fields
On Fri, Jun 02, 2017 at 12:34:57PM +0300, Sergei Shtylyov wrote:
> Hello!
> 
> On 6/2/2017 2:56 AM, Michael S. Tsirkin wrote:
> 
> >commit d85b758f72b0 "virtio_net: fix support for small rings"
> 
>Commit d85b758f72b0 ("virtio_net: fix support for small rings")
> 
> >was supposed to increase the buffer size for small rings
> >but had an unintentional side effect of decreasing
> >it for large rings. This seems to break some setups -
> >it's not yet clear why, but increasing buffer size
> >back to what it was before helps.
> >
> >Fixes: d85b758f72b0 "virtio_net: fix support for small rings"
> 
> Fixes: d85b758f72b0 ("virtio_net: fix support for small rings")

I may be bikeshedding, but, personally I never do the parens--they're
redundant given the quotes, and space is often tight.

--b.

> 
> >Reported-by: Mikulas Patocka 
> >Reported-by: "J. Bruce Fields" 
> >Signed-off-by: Michael S. Tsirkin 
> [...]
> 
> MBR, Sergei


Re: [PATCH 7/7] mlx5: Do not build eswitch_offloads if CONFIG_MLX5_EN_ESWITCH_OFFLOADS is set

2017-06-02 Thread Jes Sorensen

On 05/28/2017 02:03 AM, Or Gerlitz wrote:

On Sun, May 28, 2017 at 5:23 AM, Jes Sorensen  wrote:

On 05/27/2017 05:02 PM, Or Gerlitz wrote:


On Sat, May 27, 2017 at 12:16 AM, Jes Sorensen 
wrote:


This gets rid of the temporary #ifdef spaghetti and allows the code to
compile without offload support enabled.



I am pretty sure we can do that exercise you're up to without any
spaghetti cooking and even put more code under that CONFIG directive
(en_rep.c), I'll take that with Saeed.



I want to avoid adding #ifdef CONFIG_foo to the main code in order to keep
it readable. I did it gradually to make sure I didn't break anything and to
allow for it to be bisected in case something did break. If we can move out
more code from places like en_rep.c into eswitch_offload.c and get it
disabled that way that would be great, but I like to limit the number of
#ifdefs we add to the actual code.


FWIW (see below), squashing your seven patches to one resulted in a
fairly simple/clear
patch, so if we go that way, no need to have seven commits just for this piece.


Squashing patches into jumbo patches is inherently broken and bad coding 
practice! It makes it way more complicated to debug and bisect in case a 
minor detail broke in the process.



Just wondering, you are motivated by a wish to put some mlx5
functionalities under their own CONFIG directives which could be
useful when backporting the latest upstream driver into older kernel
and being able not to deal with parts of it, right? in that respect,
are you using SRIOV but not the offloads mode?



The motivation is two-fold, the primary is to be able to disable features
not being used for those who compile a custom kernel and who wish to reduce
the codebase compiled. It also makes it more flexible when back porting the
code to older kernels since it is easier to pick out a smaller subset. I was
going to look into making TC support etc. optional next, but I wanted to
have a discussion about this patchset first.


OKay, I got you.

Re SRIOV, I don't think it would be correct to break the support info few
CONFIG directives. If we want to allow someone to build the driver w.o
SRIOV that's fine, but I don't think we should further go down and disable
some of the SRIOV sub-modes.

Re TC offload support, that's make sense.


OK, so disabling SRIOV and disabling TC makes sense - I'll look at that.

Jes


Re: [PATCH 3/3] net: dsa: Initialize all CPU and enabled ports masks in dsa_ds_parse()

2017-06-02 Thread Vivien Didelot
Florian Fainelli  writes:

> There was no reason for duplicating the code that initializes
> ds->enabled_port_mask in both dsa_parse_ports_dn() and
> dsa_parse_ports(), instead move this to dsa_ds_parse() which is early
> enough before ops->setup() has run.
>
> While at it, we can now make dsa_is_cpu_port() check ds->cpu_port_mask
> which is a step towards being multi-CPU port capable.
>
> Signed-off-by: Florian Fainelli 

Reviewed-by: Vivien Didelot 


Re: [PATCH 1/3] net: dsa: Pass dsa_port reference to ethtool setup/restore

2017-06-02 Thread Vivien Didelot
Florian Fainelli  writes:

> We do not need to have a reference to a dsa_switch, instead we should
> pass a reference to a CPU dsa_port, change that. This is a preliminary
> change to better support multiple CPU ports.
>
> Signed-off-by: Florian Fainelli 

Reviewed-by: Vivien Didelot 


Re: [PATCH 2/3] net: dsa: Consistently use dsa_port for dsa_*_port_{apply,unapply}

2017-06-02 Thread Vivien Didelot
Florian Fainelli  writes:

> We have all the information we need in dsa_port, so use it instead of
> repeating the same arguments over and over again.
>
> Suggested-by: Vivien Didelot 
> Signed-off-by: Florian Fainelli 

Reviewed-by: Vivien Didelot 


[PATCH 2/3] net: dsa: Consistently use dsa_port for dsa_*_port_{apply,unapply}

2017-06-02 Thread Florian Fainelli
We have all the information we need in dsa_port, so use it instead of
repeating the same arguments over and over again.

Suggested-by: Vivien Didelot 
Signed-off-by: Florian Fainelli 
---
 net/dsa/dsa2.c | 90 ++
 1 file changed, 41 insertions(+), 49 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 7f9bf1456a65..067daec644c1 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -214,66 +214,61 @@ static int dsa_dst_complete(struct dsa_switch_tree *dst)
return 0;
 }
 
-static int dsa_dsa_port_apply(struct dsa_port *port, u32 index,
- struct dsa_switch *ds)
+static int dsa_dsa_port_apply(struct dsa_port *port)
 {
+   struct dsa_switch *ds = port->ds;
int err;
 
-   err = dsa_cpu_dsa_setup(ds, ds->dev, port, index);
+   err = dsa_cpu_dsa_setup(ds, ds->dev, port, port->index);
if (err) {
dev_warn(ds->dev, "Failed to setup dsa port %d: %d\n",
-index, err);
+port->index, err);
return err;
}
 
-   memset(>ports[index].devlink_port, 0,
-  sizeof(ds->ports[index].devlink_port));
+   memset(>devlink_port, 0, sizeof(port->devlink_port));
 
-   return devlink_port_register(ds->devlink,
->ports[index].devlink_port,
-index);
+   return devlink_port_register(ds->devlink, >devlink_port,
+port->index);
 }
 
-static void dsa_dsa_port_unapply(struct dsa_port *port, u32 index,
-struct dsa_switch *ds)
+static void dsa_dsa_port_unapply(struct dsa_port *port)
 {
-   devlink_port_unregister(>ports[index].devlink_port);
+   devlink_port_unregister(>devlink_port);
dsa_cpu_dsa_destroy(port);
 }
 
-static int dsa_cpu_port_apply(struct dsa_port *port, u32 index,
- struct dsa_switch *ds)
+static int dsa_cpu_port_apply(struct dsa_port *port)
 {
+   struct dsa_switch *ds = port->ds;
int err;
 
-   err = dsa_cpu_dsa_setup(ds, ds->dev, port, index);
+   err = dsa_cpu_dsa_setup(ds, ds->dev, port, port->index);
if (err) {
dev_warn(ds->dev, "Failed to setup cpu port %d: %d\n",
-index, err);
+port->index, err);
return err;
}
 
-   ds->cpu_port_mask |= BIT(index);
+   ds->cpu_port_mask |= BIT(port->index);
 
-   memset(>ports[index].devlink_port, 0,
-  sizeof(ds->ports[index].devlink_port));
-   err = devlink_port_register(ds->devlink, >ports[index].devlink_port,
-   index);
+   memset(>devlink_port, 0, sizeof(port->devlink_port));
+   err = devlink_port_register(ds->devlink, >devlink_port,
+   port->index);
return err;
 }
 
-static void dsa_cpu_port_unapply(struct dsa_port *port, u32 index,
-struct dsa_switch *ds)
+static void dsa_cpu_port_unapply(struct dsa_port *port)
 {
-   devlink_port_unregister(>ports[index].devlink_port);
+   devlink_port_unregister(>devlink_port);
dsa_cpu_dsa_destroy(port);
-   ds->cpu_port_mask &= ~BIT(index);
+   port->ds->cpu_port_mask &= ~BIT(port->index);
 
 }
 
-static int dsa_user_port_apply(struct dsa_port *port, u32 index,
-  struct dsa_switch *ds)
+static int dsa_user_port_apply(struct dsa_port *port)
 {
+   struct dsa_switch *ds = port->ds;
const char *name = port->name;
int err;
 
@@ -282,35 +277,32 @@ static int dsa_user_port_apply(struct dsa_port *port, u32 
index,
if (!name)
name = "eth%d";
 
-   err = dsa_slave_create(ds, ds->dev, index, name);
+   err = dsa_slave_create(ds, ds->dev, port->index, name);
if (err) {
dev_warn(ds->dev, "Failed to create slave %d: %d\n",
-index, err);
-   ds->ports[index].netdev = NULL;
+port->index, err);
+   port->netdev = NULL;
return err;
}
 
-   memset(>ports[index].devlink_port, 0,
-  sizeof(ds->ports[index].devlink_port));
-   err = devlink_port_register(ds->devlink, >ports[index].devlink_port,
-   index);
+   memset(>devlink_port, 0, sizeof(port->devlink_port));
+   err = devlink_port_register(ds->devlink, >devlink_port,
+   port->index);
if (err)
return err;
 
-   devlink_port_type_eth_set(>ports[index].devlink_port,
- ds->ports[index].netdev);
+   devlink_port_type_eth_set(>devlink_port, port->netdev);
 
return 0;
 }
 
-static void 

[PATCH 3/3] net: dsa: Initialize all CPU and enabled ports masks in dsa_ds_parse()

2017-06-02 Thread Florian Fainelli
There was no reason for duplicating the code that initializes
ds->enabled_port_mask in both dsa_parse_ports_dn() and
dsa_parse_ports(), instead move this to dsa_ds_parse() which is early
enough before ops->setup() has run.

While at it, we can now make dsa_is_cpu_port() check ds->cpu_port_mask
which is a step towards being multi-CPU port capable.

Signed-off-by: Florian Fainelli 
---
 include/net/dsa.h |  2 +-
 net/dsa/dsa2.c| 33 +++--
 2 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 448d8bc77707..2effb0af9d7c 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -254,7 +254,7 @@ struct dsa_switch {
 
 static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p)
 {
-   return ds->dst->cpu_dp == >ports[p];
+   return !!(ds->cpu_port_mask & (1 << p));
 }
 
 static inline bool dsa_is_dsa_port(struct dsa_switch *ds, int p)
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 067daec644c1..cd13bb54a30c 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -250,8 +250,6 @@ static int dsa_cpu_port_apply(struct dsa_port *port)
return err;
}
 
-   ds->cpu_port_mask |= BIT(port->index);
-
memset(>devlink_port, 0, sizeof(port->devlink_port));
err = devlink_port_register(ds->devlink, >devlink_port,
port->index);
@@ -522,6 +520,12 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
 
dst->rcv = dst->tag_ops->rcv;
 
+   /* Initialize cpu_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->cpu_port_mask |= BIT(index);
+
return 0;
 }
 
@@ -533,14 +537,22 @@ static int dsa_ds_parse(struct dsa_switch_tree *dst, 
struct dsa_switch *ds)
 
for (index = 0; index < ds->num_ports; index++) {
port = >ports[index];
-   if (!dsa_port_is_valid(port))
+   if (!dsa_port_is_valid(port) ||
+   dsa_port_is_dsa(port))
continue;
 
if (dsa_port_is_cpu(port)) {
err = dsa_cpu_parse(port, index, dst, ds);
if (err)
return err;
+   } 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 |= BIT(index);
}
+
}
 
pr_info("DSA: switch %d %d parsed\n", dst->tree, ds->index);
@@ -589,13 +601,6 @@ static int dsa_parse_ports_dn(struct device_node *ports, 
struct dsa_switch *ds)
return -EINVAL;
 
ds->ports[reg].dn = port;
-
-   /* Initialize enabled_port_mask now for ops->setup()
-* to have access to a correct value, just like what
-* net/dsa/dsa.c::dsa_switch_setup_one does.
-*/
-   if (!dsa_port_is_cpu(>ports[reg]))
-   ds->enabled_port_mask |= 1 << reg;
}
 
return 0;
@@ -611,14 +616,6 @@ static int dsa_parse_ports(struct dsa_chip_data *cd, 
struct dsa_switch *ds)
continue;
 
ds->ports[i].name = cd->port_names[i];
-
-   /* 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.
-*/
-   if (!dsa_port_is_cpu(>ports[i]))
-   ds->enabled_port_mask |= 1 << i;
-
valid_name_found = true;
}
 
-- 
2.9.3



[PATCH 0/3] net: dsa: Cleanups before multi-CPU port

2017-06-02 Thread Florian Fainelli
Hi all,

This patch series does a bunch of cleanups before we start adding support
for multiple CPU ports.

Florian Fainelli (3):
  net: dsa: Pass dsa_port reference to ethtool setup/restore
  net: dsa: Consistently use dsa_port for dsa_*_port_{apply,unapply}
  net: dsa: Initialize all CPU and enabled ports masks in dsa_ds_parse()

 include/net/dsa.h  |   2 +-
 net/dsa/dsa.c  |   6 ++-
 net/dsa/dsa2.c | 125 -
 net/dsa/dsa_priv.h |   4 +-
 net/dsa/legacy.c   |   4 +-
 5 files changed, 66 insertions(+), 75 deletions(-)

-- 
2.9.3



[PATCH 1/3] net: dsa: Pass dsa_port reference to ethtool setup/restore

2017-06-02 Thread Florian Fainelli
We do not need to have a reference to a dsa_switch, instead we should
pass a reference to a CPU dsa_port, change that. This is a preliminary
change to better support multiple CPU ports.

Signed-off-by: Florian Fainelli 
---
 net/dsa/dsa.c  | 6 --
 net/dsa/dsa2.c | 4 ++--
 net/dsa/dsa_priv.h | 4 ++--
 net/dsa/legacy.c   | 4 ++--
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 402459e73f33..fdc448b30e56 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -112,8 +112,9 @@ const struct dsa_device_ops *dsa_resolve_tag_protocol(int 
tag_protocol)
return ops;
 }
 
-int dsa_cpu_port_ethtool_setup(struct dsa_switch *ds)
+int dsa_cpu_port_ethtool_setup(struct dsa_port *cpu_dp)
 {
+   struct dsa_switch *ds = cpu_dp->ds;
struct net_device *master;
struct ethtool_ops *cpu_ops;
 
@@ -136,8 +137,9 @@ int dsa_cpu_port_ethtool_setup(struct dsa_switch *ds)
return 0;
 }
 
-void dsa_cpu_port_ethtool_restore(struct dsa_switch *ds)
+void dsa_cpu_port_ethtool_restore(struct dsa_port *cpu_dp)
 {
+   struct dsa_switch *ds = cpu_dp->ds;
struct net_device *master;
 
master = ds->dst->master_netdev;
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 21b44a9828f6..7f9bf1456a65 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -444,7 +444,7 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)
}
 
if (dst->cpu_dp) {
-   err = dsa_cpu_port_ethtool_setup(dst->cpu_dp->ds);
+   err = dsa_cpu_port_ethtool_setup(dst->cpu_dp);
if (err)
return err;
}
@@ -485,7 +485,7 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
}
 
if (dst->cpu_dp)
-   dsa_cpu_port_ethtool_restore(dst->cpu_dp->ds);
+   dsa_cpu_port_ethtool_restore(dst->cpu_dp);
 
pr_info("DSA: tree %d unapplied\n", dst->tree);
dst->applied = false;
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index db2a7b9edfb8..66ee248796c8 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -103,8 +103,8 @@ int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device 
*dev,
  struct dsa_port *dport, int port);
 void dsa_cpu_dsa_destroy(struct dsa_port *dport);
 const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);
-int dsa_cpu_port_ethtool_setup(struct dsa_switch *ds);
-void dsa_cpu_port_ethtool_restore(struct dsa_switch *ds);
+int dsa_cpu_port_ethtool_setup(struct dsa_port *cpu_dp);
+void dsa_cpu_port_ethtool_restore(struct dsa_port *cpu_dp);
 
 /* legacy.c */
 int dsa_legacy_register(void);
diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c
index d70a1a788d17..d534d8f4b9cf 100644
--- a/net/dsa/legacy.c
+++ b/net/dsa/legacy.c
@@ -205,7 +205,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, 
struct device *parent)
netdev_err(dst->master_netdev, "[%d] : can't configure CPU and 
DSA ports\n",
   index);
 
-   ret = dsa_cpu_port_ethtool_setup(ds);
+   ret = dsa_cpu_port_ethtool_setup(ds->dst->cpu_dp);
if (ret)
return ret;
 
@@ -733,7 +733,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
dsa_switch_destroy(ds);
}
 
-   dsa_cpu_port_ethtool_restore(dst->cpu_dp->ds);
+   dsa_cpu_port_ethtool_restore(dst->cpu_dp);
 
dev_put(dst->master_netdev);
 }
-- 
2.9.3



Re: Leak in ipv6_gso_segment()?

2017-06-02 Thread Craig Gallek
On Fri, Jun 2, 2017 at 2:25 PM, Craig Gallek  wrote:
> On Fri, Jun 2, 2017 at 2:05 PM, David Miller  wrote:
>> From: Ben Hutchings 
>> Date: Wed, 31 May 2017 13:26:02 +0100
>>
>>> If I'm not mistaken, ipv6_gso_segment() now leaks segs if
>>> ip6_find_1stfragopt() fails.  I'm not sure whether the fix would be as
>>> simple as adding a kfree_skb(segs) or whether more complex cleanup is
>>> needed.
>>
>> I think we need to use kfree_skb_list(), like the following.
> I think this is problematic as well.  ipv6_gso_segment could
> previously return errors, in which case the caller uses kfree_skb (ex
> validate_xmit_skb() -> skb_gso_segment -> ...
> callbacks.gso_segment()).  Having the kfree_skb_list here would cause
> a double free if I'm reading this correctly.
>
> My first guess was going to be skb_gso_error_unwind(), but I'm still
> trying to understand that code...
>
> Sorry again for the fallout from this bug fix.  This is my first time
> down this code path and I clearly didn't understand it fully :/

Ok, I take it back.  I believe your kfree_skb_list suggestion is correct.

I was assuming that skb_segment consumed the original skb upon
successful segmentation.  It does not.  This is exactly why
validate_xmit_skb calls consume_skb when segments are returned.
Further, there is at least one existing example of kfree_skb_list in a
similar post-semgent cleanup path (esp6_gso_segment).


[PATCH net] geneve: fix needed_headroom and max_mtu for collect_metadata

2017-06-02 Thread Eric Garver
Since commit 9b4437a5b870 ("geneve: Unify LWT and netdev handling.")
when using COLLECT_METADATA geneve devices are created with too small of
a needed_headroom and too large of a max_mtu. This is because
ip_tunnel_info_af() is not valid with the device level info when using
COLLECT_METADATA and we mistakenly fall into the IPv4 case.

For COLLECT_METADATA, always use the worst case of ipv6 since both
sockets are created.

Fixes: 9b4437a5b870 ("geneve: Unify LWT and netdev handling.")
Signed-off-by: Eric Garver 
---
 drivers/net/geneve.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 959fd12d2e67..6ebb0f559a42 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -1133,7 +1133,7 @@ static int geneve_configure(struct net *net, struct 
net_device *dev,
 
/* make enough headroom for basic scenario */
encap_len = GENEVE_BASE_HLEN + ETH_HLEN;
-   if (ip_tunnel_info_af(info) == AF_INET) {
+   if (!metadata && ip_tunnel_info_af(info) == AF_INET) {
encap_len += sizeof(struct iphdr);
dev->max_mtu -= sizeof(struct iphdr);
} else {
-- 
2.12.0



Re: [PATCH] brcmfmac: Fix glob_skb leak in brcmf_sdiod_recv_chain

2017-06-02 Thread Franky Lin
On Fri, Jun 2, 2017 at 10:22 AM, Peter S. Housel  wrote:
> An earlier change to this function (3bdae810721b) fixed a leak in the
> case of an unsuccessful call to brcmf_sdiod_buffrw(). However, the
> glob_skb buffer, used for emulating a scattering read, is never used
> or referenced after its contents are copied into the destination
> buffers, and therefore always needs to be freed by the end of the
> function.
>
> Signed-off-by: Peter S. Housel 
> ---
>  drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c 
> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> index 9b970dc..4c5064f 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> @@ -727,15 +727,16 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev 
> *sdiodev,
> return -ENOMEM;
> err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr,
>  glom_skb);
> -   if (err) {
> -   brcmu_pkt_buf_free_skb(glom_skb);
> -   goto done;
> -   }
> +   if (err)
> +   goto free_glom_skb;
>
> skb_queue_walk(pktq, skb) {
> memcpy(skb->data, glom_skb->data, skb->len);
> skb_pull(glom_skb, skb->len);
> }
> +
> +free_glom_skb:
> +   brcmu_pkt_buf_free_skb(glom_skb);

What about
if (!err) {
skb_queue_walk(pktq, skb) {
memcpy(skb->data, glom_skb->data, skb->len);
skb_pull(glom_skb, skb->len);
}
}
brcmu_pkt_buf_free_skb(glom_skb);

Then no goto is needed.

Thanks,
Franky

> } else
> err = brcmf_sdiod_sglist_rw(sdiodev, SDIO_FUNC_2, false, addr,
> pktq);
> --
> 2.7.4
>


Re: [PATCH] brcmfmac: Fix glob_skb leak in brcmf_sdiod_recv_chain

2017-06-02 Thread Florian Fainelli
On 06/02/2017 10:22 AM, Peter S. Housel wrote:
> An earlier change to this function (3bdae810721b) fixed a leak in the
> case of an unsuccessful call to brcmf_sdiod_buffrw(). However, the
> glob_skb buffer, used for emulating a scattering read, is never used
> or referenced after its contents are copied into the destination
> buffers, and therefore always needs to be freed by the end of the
> function.

That looks correct, could you add the relevant Fixes tag for this?

Fixes: 3bdae810721b ("brcmfmac: Fix glob_skb leak in
brcmf_sdiod_recv_chain")
Fixes: a413e39a38573 ("brcmfmac: fix brcmf_sdcard_recv_chain() for host
without sg support")

BTW, you made the same typo that I did, it's actually glom_skb ;)

> 
> Signed-off-by: Peter S. Housel 
> ---
>  drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c 
> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> index 9b970dc..4c5064f 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> @@ -727,15 +727,16 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev 
> *sdiodev,
>   return -ENOMEM;
>   err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr,
>glom_skb);
> - if (err) {
> - brcmu_pkt_buf_free_skb(glom_skb);
> - goto done;
> - }
> + if (err)
> + goto free_glom_skb;
>  
>   skb_queue_walk(pktq, skb) {
>   memcpy(skb->data, glom_skb->data, skb->len);
>   skb_pull(glom_skb, skb->len);
>   }
> +
> +free_glom_skb:
> + brcmu_pkt_buf_free_skb(glom_skb);
>   } else
>   err = brcmf_sdiod_sglist_rw(sdiodev, SDIO_FUNC_2, false, addr,
>   pktq);
> 


-- 
Florian


Re: [PATCH V5 net-next] neigh: Really delete an arp/neigh entry on "ip neigh delete" or "arp -d"

2017-06-02 Thread Julian Anastasov

Hello,

On Fri, 2 Jun 2017, Sowmini Varadhan wrote:

> The command
>   # arp -s 62.2.0.1 a:b:c:d:e:f dev eth2
> adds an entry like the following (listed by "arp -an")
>   ? (62.2.0.1) at 0a:0b:0c:0d:0e:0f [ether] PERM on eth2
> but the symmetric deletion command
>   # arp -i eth2 -d 62.2.0.1
> does not remove the PERM entry from the table, and instead leaves behind
>   ? (62.2.0.1) at  on eth2
> 
> The reason is that there is a refcnt of 1 for the arp_tbl itself
> (neigh_alloc starts off the entry with a refcnt of 1), thus
> the neigh_release() call from arp_invalidate() will (at best) just
> decrement the ref to 1, but will never actually free it from the
> table.
> 
> To fix this, we need to do something like neigh_forced_gc: if
> the refcnt is 1 (i.e., on the table's ref), remove the entry from
> the table and free it. This patch refactors and shares common code
> between neigh_forced_gc and the newly added neigh_remove_one.
> 
> A similar issue exists for IPv6 Neighbor Cache entries, and is fixed
> in a similar manner by this patch.
> 
> Signed-off-by: Sowmini Varadhan 
> Reviewed-by: Julian Anastasov 

Very good, thanks!

> ---
> v2: kbuild-test-robot compile error
> v3: do not export_symbol neigh_remove_one (David Miller comment)
> v4: rearrange locking for tbl->lock (Julian Anastasov comment)
> v5: minor touch-ups: removed retval from neigh_remove_one (Julian Anastasov),
> got rid of checkpatch warnings, explicitly add net-next to subject line.
> 
>  include/net/neighbour.h |1 +
>  net/core/neighbour.c|   60 ++
>  net/ipv4/arp.c  |4 +++
>  3 files changed, 54 insertions(+), 11 deletions(-)
> 
> diff --git a/include/net/neighbour.h b/include/net/neighbour.h
> index e4dd3a2..639b675 100644
> --- a/include/net/neighbour.h
> +++ b/include/net/neighbour.h
> @@ -317,6 +317,7 @@ struct neighbour *__neigh_create(struct neigh_table *tbl, 
> const void *pkey,
>  int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, u32 
> flags,
>u32 nlmsg_pid);
>  void __neigh_set_probe_once(struct neighbour *neigh);
> +bool neigh_remove_one(struct neighbour *ndel, struct neigh_table *tbl);
>  void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);
>  int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
>  int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb);
> diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> index d274f81..dadb5ee 100644
> --- a/net/core/neighbour.c
> +++ b/net/core/neighbour.c
> @@ -118,6 +118,50 @@ unsigned long neigh_rand_reach_time(unsigned long base)
>  EXPORT_SYMBOL(neigh_rand_reach_time);
>  
>  
> +static bool neigh_del(struct neighbour *n, __u8 state,
> +   struct neighbour __rcu **np, struct neigh_table *tbl)
> +{
> + bool retval = false;
> +
> + write_lock(>lock);
> + if (atomic_read(>refcnt) == 1 && !(n->nud_state & state)) {
> + struct neighbour *neigh;
> +
> + neigh = rcu_dereference_protected(n->next,
> +   lockdep_is_held(>lock));
> + rcu_assign_pointer(*np, neigh);
> + n->dead = 1;
> + retval = true;
> + }
> + write_unlock(>lock);
> + if (retval)
> + neigh_cleanup_and_release(n);
> + return retval;
> +}
> +
> +bool neigh_remove_one(struct neighbour *ndel, struct neigh_table *tbl)
> +{
> + struct neigh_hash_table *nht;
> + void *pkey = ndel->primary_key;
> + u32 hash_val;
> + struct neighbour *n;
> + struct neighbour __rcu **np;
> +
> + nht = rcu_dereference_protected(tbl->nht,
> + lockdep_is_held(>lock));
> + hash_val = tbl->hash(pkey, ndel->dev, nht->hash_rnd);
> + hash_val = hash_val >> (32 - nht->hash_shift);
> +
> + np = >hash_buckets[hash_val];
> + while ((n = rcu_dereference_protected(*np,
> +   lockdep_is_held(>lock {
> + if (n == ndel)
> + return neigh_del(n, 0, np, tbl);
> + np = >next;
> + }
> + return false;
> +}
> +
>  static int neigh_forced_gc(struct neigh_table *tbl)
>  {
>   int shrunk = 0;
> @@ -140,19 +184,10 @@ static int neigh_forced_gc(struct neigh_table *tbl)
>* - nobody refers to it.
>* - it is not permanent
>*/
> - write_lock(>lock);
> - if (atomic_read(>refcnt) == 1 &&
> - !(n->nud_state & NUD_PERMANENT)) {
> - rcu_assign_pointer(*np,
> - rcu_dereference_protected(n->next,
> -   lockdep_is_held(>lock)));
> - n->dead = 1;
> - 

Re: Cherry pick commit *net: better skb->sender_cpu and skb->napi_id cohabitation* to 4.4 series?

2017-06-02 Thread David Miller
From: Cong Wang 
Date: Fri, 2 Jun 2017 10:51:39 -0700

> On Thu, Jun 1, 2017 at 10:32 AM, Paul Menzel  wrote:
>> Dear David,
>>
>>
>> On 06/01/17 18:19, David Miller wrote:
>>>
>>> Neither of us have anything to do with the 4.4 -stable series.  We only
>>> manage stable backport submissions for the most recent two releases.
>>
>>
>> Thank you for the prompt response. Should the netdev FAQ be updated then to
>> contain that information?
> 
> +1
> 
> It is quite helpful to know which stable releases contain network fixes
> which don't, especially for those who rely on stable releases, at least
> we could do backport by ourselves when we know they are missing.

The people who maintain the -stable releases older than the ones Greg KH
are doing typically scan the ones that Greg applies and tries to integrate
them into their -stable releases when appropriate.

If someone wants to write an accurate description of that and how it works,
and add it to the FAQ, sure.


Re: [PATCH v2] virtio_net: lower limit on buffer size

2017-06-02 Thread David Miller
From: "Michael S. Tsirkin" 
Date: Fri, 2 Jun 2017 17:54:33 +0300

> commit d85b758f72b0 ("virtio_net: fix support for small rings")
> was supposed to increase the buffer size for small rings but had an
> unintentional side effect of decreasing it for large rings. This seems
> to break some setups - it's not yet clear why, but increasing buffer
> size back to what it was before helps.
> 
> Fixes: d85b758f72b0 ("virtio_net: fix support for small rings")
> Reported-by: Mikulas Patocka 
> Reported-by: "J. Bruce Fields" 
> Tested-by: Mikulas Patocka 
> Tested-by: "J. Bruce Fields" 
> Signed-off-by: Michael S. Tsirkin 
> ---
> 
> Patch tested, pls merge.
> 
> changes from v2:
>   commit log tweaks to address comments by Sergei Shtylyov

Applied, thanks Michael.


Re: [PATCH net 1/1] qlcnic: Fix tunnel offload for 82xx adapters

2017-06-02 Thread David Miller
From: Manish Chopra 
Date: Fri, 2 Jun 2017 06:52:54 -0700

> Qlogic's 82xx series adapter doesn't support
> tunnel offloads, driver incorrectly assumes that it is
> supported and causes firmware hang while running tunnel IO.
> 
> This patch fixes this by not advertising tunnel offloads
> for 82xx adapters.
> 
> Signed-off-by: Manish Chopra 

Applied, thank you.


Re: [net,V2] vxlan: fix use-after-free on deletion

2017-06-02 Thread David Miller
From: Mark Bloch 
Date: Fri,  2 Jun 2017 03:24:08 +0300

> Adding a vxlan interface to a socket isn't symmetrical, while adding
> is done in vxlan_open() the deletion is done in vxlan_dellink().
> This can cause a use-after-free error when we close the vxlan
> interface before deleting it.
> 
> We add vxlan_vs_del_dev() to match vxlan_vs_add_dev() and call
> it from vxlan_stop() to match the call from vxlan_open().
> 
> Fixes: 56ef9c909b40 ("vxlan: Move socket initialization to within rtnl scope")
> Acked-by: Jiri Benc 
> Tested-by: Roi Dayan 
> Signed-off-by: Mark Bloch 
> ---
> V2: Added a Fixes tag.
> Added Acked-by and Tested-by from Jiri and Roi.

Applied and queued up for -stable, thanks.


Re: [PATCH net-next] tcp: remove unnecessary skb_reset_tail_pointer()

2017-06-02 Thread David Miller
From: Eric Dumazet 
Date: Thu, 01 Jun 2017 14:18:36 -0700

> From: Eric Dumazet 
> 
> __pskb_trim_head() does not need to reset skb tail pointer.
> 
> Also change the comments, __pskb_pull_head() does not exist.
> 
> Signed-off-by: Eric Dumazet 

Applied, thanks Eric.


Re: [PATCH net v2] ibmvnic: Remove module author mailing address

2017-06-02 Thread David Miller
From: Thomas Falcon 
Date: Thu,  1 Jun 2017 15:32:34 -0500

> The original author left the project and so far has not
> responded to emails sent to the listed address.
> 
> Signed-off-by: John Allen 
> Signed-off-by: Thomas Falcon 
> ---
> v2: only remove invalid email address

Applied, thanks.


Re: [PATCH net-next v2 2/2] bpf: Remove the capability check for cgroup skb eBPF program

2017-06-02 Thread David Miller
From: Chenbo Feng 
Date: Wed, 31 May 2017 18:16:00 -0700

> From: Chenbo Feng 
> 
> Currently loading a cgroup skb eBPF program require a CAP_SYS_ADMIN
> capability while attaching the program to a cgroup only requires the
> user have CAP_NET_ADMIN privilege. We can escape the capability
> check when load the program just like socket filter program to make
> the capability requirement consistent.
> 
> Change since v1:
> Change the code style in order to be compliant with checkpatch.pl
> preference
> 
> Signed-off-by: Chenbo Feng 

Applied.


Re: Leak in ipv6_gso_segment()?

2017-06-02 Thread Craig Gallek
On Fri, Jun 2, 2017 at 2:05 PM, David Miller  wrote:
> From: Ben Hutchings 
> Date: Wed, 31 May 2017 13:26:02 +0100
>
>> If I'm not mistaken, ipv6_gso_segment() now leaks segs if
>> ip6_find_1stfragopt() fails.  I'm not sure whether the fix would be as
>> simple as adding a kfree_skb(segs) or whether more complex cleanup is
>> needed.
>
> I think we need to use kfree_skb_list(), like the following.
I think this is problematic as well.  ipv6_gso_segment could
previously return errors, in which case the caller uses kfree_skb (ex
validate_xmit_skb() -> skb_gso_segment -> ...
callbacks.gso_segment()).  Having the kfree_skb_list here would cause
a double free if I'm reading this correctly.

My first guess was going to be skb_gso_error_unwind(), but I'm still
trying to understand that code...

Sorry again for the fallout from this bug fix.  This is my first time
down this code path and I clearly didn't understand it fully :/

> Can someone please audit and review this for me?  We need to
> get this to -stable.
>
> Thanks.
>
> diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
> index 280268f..cdb3728 100644
> --- a/net/ipv6/ip6_offload.c
> +++ b/net/ipv6/ip6_offload.c
> @@ -116,8 +116,10 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff 
> *skb,
>
> if (udpfrag) {
> int err = ip6_find_1stfragopt(skb, );
> -   if (err < 0)
> +   if (err < 0) {
> +   kfree_skb_list(segs);
> return ERR_PTR(err);
> +   }
> fptr = (struct frag_hdr *)((u8 *)ipv6h + err);
> fptr->frag_off = htons(offset);
> if (skb->next)


Re: [PATCH net-next v2 1/2] bpf: Allow CGROUP_SKB eBPF program to access sk_buff

2017-06-02 Thread David Miller
From: Chenbo Feng 
Date: Wed, 31 May 2017 18:15:59 -0700

> From: Chenbo Feng 
> 
> This allows cgroup eBPF program to classify packet based on their
> protocol or other detail information. Currently program need
> CAP_NET_ADMIN privilege to attach a cgroup eBPF program, and A
> process with CAP_NET_ADMIN can already see all packets on the system,
> for example, by creating an iptables rules that causes the packet to
> be passed to userspace via NFLOG.
> 
> Signed-off-by: Chenbo Feng 

Applied.


Re: [PATCH net-next] net: phy: use of_mdio_parse_addr

2017-06-02 Thread David Miller
From: Jon Mason 
Date: Wed, 31 May 2017 15:43:30 -0400

> use of_mdio_parse_addr() in place of an OF read of reg and a bounds
> check (which is litterally the exact same thing that
> of_mdio_parse_addr() does)
> 
> Signed-off-by: Jon Mason 

Applied, thanks Jon.


Re: [PATCH] net: ethernet: stmmac: Fix altr_tse_pcs SGMII Initialization

2017-06-02 Thread David Miller
From: thor.tha...@linux.intel.com
Date: Wed, 31 May 2017 14:28:47 -0500

> From: Thor Thayer 
> 
> Fix NETDEV WATCHDOG timeout on startup by adding missing register
> writes that properly setup SGMII.
> 
> Signed-off-by: Thor Thayer 

Applied, thank you.


Re: [PATCH net-next] tcp: use TS opt on RTTs for congestion control

2017-06-02 Thread David Miller
From: Yuchung Cheng 
Date: Wed, 31 May 2017 11:30:53 -0700

> Currently when a data packet is retransmitted, we do not compute an
> RTT sample for congestion control due to Kern's check. Therefore the
> congestion control that uses RTT signals may not receive any update
> during loss recovery which could last many round trips. For example,
> BBR and Vegas may not be able to update its min RTT estimation if the
> network path has shortened until it recovers from losses. This patch
> mitigates that by using TCP timestamp options for RTT measurement
> for congestion control. Note that we already use timestamps for
> RTT estimation.
> 
> Signed-off-by: Yuchung Cheng 
> Signed-off-by: Soheil Hassas Yeganeh 
> Signed-off-by: Neal Cardwell 
> Signed-off-by: Eric Dumazet 

Also applied, thank you.


Re: [PATCH net] tcp: disallow cwnd undo when switching congestion control

2017-06-02 Thread David Miller
From: Yuchung Cheng 
Date: Wed, 31 May 2017 11:21:27 -0700

> When the sender switches its congestion control during loss
> recovery, if the recovery is spurious then it may incorrectly
> revert cwnd and ssthresh to the older values set by a previous
> congestion control. Consider a congestion control (like BBR)
> that does not use ssthresh and keeps it infinite: the connection
> may incorrectly revert cwnd to an infinite value when switching
> from BBR to another congestion control.
> 
> This patch fixes it by disallowing such cwnd undo operation
> upon switching congestion control.  Note that undo_marker
> is not reset s.t. the packets that were incorrectly marked
> lost would be corrected. We only avoid undoing the cwnd in
> tcp_undo_cwnd_reduction().
> 
> Signed-off-by: Yuchung Cheng 
> Signed-off-by: Soheil Hassas Yeganeh 
> Signed-off-by: Neal Cardwell 
> Signed-off-by: Eric Dumazet 

Applied and queued up for -stable, thanks!


Re: [PATCH net-next] liquidio: Fix checkpatch errors with references crossing single line

2017-06-02 Thread David Miller
From: Felix Manlunas 
Date: Wed, 31 May 2017 10:45:15 -0700

> From: Satanand Burla 
> 
> Signed-off-by: Satanand Burla 
> Signed-off-by: Derek Chickles 
> Signed-off-by: Felix Manlunas 

Applied.


Re: [PATCH net-next, 2/2] tools: hv: set hotplug for VF on Suse

2017-06-02 Thread David Miller
From: Simon Xiao 
Date: Wed, 31 May 2017 10:28:27 -0700

> On HyperV, the VF interface can be offered by a host at any time.
> Mark the VF interface as hotplug, to make sure it will be brought up
> automatically when it is registered.
> 
> Signed-off-by: Simon Xiao 
> Reviewed-by: Haiyang Zhang 

Applied.


Re: [PATCH net-next, 1/2] tools: hv: set allow-hotplug for VF on Ubuntu

2017-06-02 Thread David Miller
From: Simon Xiao 
Date: Wed, 31 May 2017 10:28:13 -0700

> On HyperV, the VF interface can be offered by a host at any time.
> Mark the VF interface as hotplug, to make sure it will be brought up
> automatically when it is registered.
> 
> Signed-off-by: Simon Xiao 
> Reviewed-by: Haiyang Zhang 

Applied.


Re: [PATCH v2 1/1] e1000e: Undo e1000e_pm_freeze if __e1000_shutdown fails

2017-06-02 Thread David Miller
From: Jani Nikula 
Date: Wed, 31 May 2017 18:50:43 +0300

> From: Chris Wilson 
> 
> An error during suspend (e100e_pm_suspend),
 ...
> lead to complete failure:
 ...
> The unwind failures stems from commit 2800209994f8 ("e1000e: Refactor PM
> flows"), but it may be a later patch that introduced the non-recoverable
> behaviour.
> 
> Fixes: 2800209994f8 ("e1000e: Refactor PM flows")
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99847
> Cc: Tvrtko Ursulin 
> Cc: Jeff Kirsher 
> Cc: Dave Ertman 
> Cc: Bruce Allan 
> Cc: intel-wired-...@lists.osuosl.org
> Cc: netdev@vger.kernel.org
> Signed-off-by: Chris Wilson 
> [Jani: bikeshed repainted]
> Signed-off-by: Jani Nikula 

Jeff, please make sure this gets submitted to me soon.

Thanks.


Re: [PATCH net-next] liquidio: VF interrupt initialization cleanup

2017-06-02 Thread David Miller
From: Felix Manlunas 
Date: Wed, 31 May 2017 09:48:09 -0700

> From: Rick Farrington 
> 
> Set initialization state variable to (reflect interrupt initialization) at
> correct time (immediately after having configured interrupts).  This fixes
> problem of inconsistent IRQ allocation in case of [obscure] failure when
> negotiating with PF driver during init.
> 
> Clean-up of interrupt enablement during initialization & avoid potential
> race condition with chip-specific code (i.e. perform interrupt control in
> main driver module).  Added explanatory comments regarding interrupt
> enablement.
> 
> Signed-off-by: Rick Farrington 
> Signed-off-by: Satanand Burla 
> Signed-off-by: Felix Manlunas 

Applied, thank you.


Re: [PATCH] net: davicom: dm9000: Avoid spinlock recursion during dm9000_timeout routine

2017-06-02 Thread David Miller
From: Liu Xiang 
Date: Wed, 31 May 2017 23:06:42 +0800

> On the DM9000B, dm9000_phy_write() is called after the main spinlock
> is held, during the dm9000_timeout() routine. Spinlock recursion
> occurs because the main spinlock is requested again in
> dm9000_phy_write(). So spinlock should be avoided in dm9000_phy_write()
> during the dm9000_timeout() routine.
> 
> Signed-off-by: Liu Xiang 

It think this is racy.

Now, during a timeout device reset, another thread of control can come
in and access phy registers without any synchronization whatsoever.


Re: [PATCH net-next] cxgb4: fix incorrect cim_la output for T6

2017-06-02 Thread David Miller
From: Ganesh Goudar 
Date: Wed, 31 May 2017 19:10:21 +0530

> take care of UpDbgLaRdPtr[0-3] restriction for T6.
> 
> Signed-off-by: Ganesh Goudar 
> ---
> v2:
> - not using loop to increment UPDBGLARDPTR

Applied, thank you.


Re: [PATCH net] cxgb4: avoid enabling napi twice to the same queue

2017-06-02 Thread David Miller
From: Ganesh Goudar 
Date: Wed, 31 May 2017 18:26:28 +0530

> Take uld mutex to avoid race between cxgb_up() and
> cxgb4_register_uld() to enable napi for the same uld
> queue.
> 
> Signed-off-by: Ganesh Goudar 

Applied and queued up for -stable, thanks.


Re: Leak in ipv6_gso_segment()?

2017-06-02 Thread David Miller
From: Ben Hutchings 
Date: Wed, 31 May 2017 13:26:02 +0100

> If I'm not mistaken, ipv6_gso_segment() now leaks segs if
> ip6_find_1stfragopt() fails.  I'm not sure whether the fix would be as
> simple as adding a kfree_skb(segs) or whether more complex cleanup is
> needed.

I think we need to use kfree_skb_list(), like the following.

Can someone please audit and review this for me?  We need to
get this to -stable.

Thanks.

diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
index 280268f..cdb3728 100644
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
@@ -116,8 +116,10 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff 
*skb,
 
if (udpfrag) {
int err = ip6_find_1stfragopt(skb, );
-   if (err < 0)
+   if (err < 0) {
+   kfree_skb_list(segs);
return ERR_PTR(err);
+   }
fptr = (struct frag_hdr *)((u8 *)ipv6h + err);
fptr->frag_off = htons(offset);
if (skb->next)


ethtool 4.11 released

2017-06-02 Thread John W. Linville
ethtool version 4.11 has been released.

Home page: https://www.kernel.org/pub/software/network/ethtool/
Download link:
https://www.kernel.org/pub/software/network/ethtool/ethtool-4.11.tar.xz

Release notes:

* Feature: Support for configurable RSS hash function
* Feature: support queue and VF fields for rxclass filters
* Feature: Add support for 2500baseT/5000baseT link modes
* Fix: Fix SFF 8079 cable technology bit parsing
* Fix: sync help output for -x/-X with man page

John
-- 
John W. LinvilleSomeday the world will need a hero, and you
linvi...@tuxdriver.com  might be all we have.  Be ready.



Re: [PATCH net] ipv6: xfrm: Handle errors reported by xfrm6_find_1stfragopt()

2017-06-02 Thread David Miller
From: Ben Hutchings 
Date: Wed, 31 May 2017 13:15:41 +0100

> xfrm6_find_1stfragopt() may now return an error code and we must
> not treat it as a length.
> 
> Fixes: 2423496af35d ("ipv6: Prevent overrun when parsing v6 header options")
> Signed-off-by: Ben Hutchings 

Applied and queued up for -stable, thanks Ben.


Re: [PATCH net-next 0/2] sctp: improve asoc streams management

2017-06-02 Thread David Miller
From: Xin Long 
Date: Wed, 31 May 2017 16:36:30 +0800

> This patchset changes to define asoc->stream as an object, and also
> improve some codes to make it more clearly.

Series applied, thank you.


Re: [net-next 00/14][pull request] 40GbE Intel Wired LAN Driver Updates 2017-06-01

2017-06-02 Thread David Miller
From: Jeff Kirsher 
Date: Thu,  1 Jun 2017 14:38:26 -0700

> This series contains updates to i40e, i40evf and the "new" AVF virtchnl.
> 
> This is the introduction of the Intel(R) Ethernet Adaptive Virtual
> Function driver code and device ID, as presented at the NetDEV 1.2
> conference in 2016.
> http://netdevconf.org/1.2/session.html?anjali-singhai
> 
> The idea is to convert the interface between the i40evf driver
> and the parent i40e PF driver to be generic, as the i40evf driver
> should in the future be able to run on top of other Intel PF
> drivers, and negotiate any features beyond a "base expected" set.
> 
> The following are changes since commit 
> 0266f79778de0afadd070941aae493c28529d974:
>   mlxsw: spectrum: Add bridge dependency for spectrum
> and are available in the git repository at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue 40GbE

Ok, doesn't look too bad.

I might have preferred if patch #11 used a compile time BUILD_BUG_ON()
of some sort in a core init function or similar.  But I can understand
the desire to use a scheme that allows annotations right next to the
datastructure definitions themselves.

Pulled, th anks.


Re: Cherry pick commit *net: better skb->sender_cpu and skb->napi_id cohabitation* to 4.4 series?

2017-06-02 Thread Cong Wang
On Thu, Jun 1, 2017 at 10:32 AM, Paul Menzel  wrote:
> Dear David,
>
>
> On 06/01/17 18:19, David Miller wrote:
>>
>> Neither of us have anything to do with the 4.4 -stable series.  We only
>> manage stable backport submissions for the most recent two releases.
>
>
> Thank you for the prompt response. Should the netdev FAQ be updated then to
> contain that information?

+1

It is quite helpful to know which stable releases contain network fixes
which don't, especially for those who rely on stable releases, at least
we could do backport by ourselves when we know they are missing.


[PATCH] brcmfmac: Fix glob_skb leak in brcmf_sdiod_recv_chain

2017-06-02 Thread Peter S. Housel
An earlier change to this function (3bdae810721b) fixed a leak in the
case of an unsuccessful call to brcmf_sdiod_buffrw(). However, the
glob_skb buffer, used for emulating a scattering read, is never used
or referenced after its contents are copied into the destination
buffers, and therefore always needs to be freed by the end of the
function.

Signed-off-by: Peter S. Housel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index 9b970dc..4c5064f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -727,15 +727,16 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev,
return -ENOMEM;
err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr,
 glom_skb);
-   if (err) {
-   brcmu_pkt_buf_free_skb(glom_skb);
-   goto done;
-   }
+   if (err)
+   goto free_glom_skb;
 
skb_queue_walk(pktq, skb) {
memcpy(skb->data, glom_skb->data, skb->len);
skb_pull(glom_skb, skb->len);
}
+
+free_glom_skb:
+   brcmu_pkt_buf_free_skb(glom_skb);
} else
err = brcmf_sdiod_sglist_rw(sdiodev, SDIO_FUNC_2, false, addr,
pktq);
-- 
2.7.4



Re: [PATCH][wireless-next] qtnfmac: check band before allocating cmd_skb to avoid resource leak

2017-06-02 Thread Igor Mitsyanko

On 06/02/2017 08:40 AM, Colin King wrote:

External Email


From: Colin Ian King 

The current code allocates cmd_skb and then will leak this if band->band
is an illegal value. It is simpler to sanity check the band first before
allocating cmd_skb so that we don't have to free cmd_skb if an invalid
band occurs.

Detected by CoverityScan, CID#1437561 ("Resource Leak")

Signed-off-by: Colin Ian King 
---
  drivers/net/wireless/quantenna/qtnfmac/commands.c | 12 ++--
  1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c 
b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index f0a0cfa7d8a1..cce62f39edaf 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -1300,12 +1300,6 @@ int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac,
 int ret = 0;
 u8 qband;

-   cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0,
-   QLINK_CMD_CHANS_INFO_GET,
-   sizeof(*cmd));
-   if (!cmd_skb)
-   return -ENOMEM;
-
 switch (band->band) {
 case NL80211_BAND_2GHZ:
 qband = QLINK_BAND_2GHZ;
@@ -1320,6 +1314,12 @@ int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac,
 return -EINVAL;
 }

+   cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0,
+   QLINK_CMD_CHANS_INFO_GET,
+   sizeof(*cmd));
+   if (!cmd_skb)
+   return -ENOMEM;
+
 cmd = (struct qlink_cmd_chans_info_get *)cmd_skb->data;
 cmd->band = qband;
 ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, _skb, _code,
--
2.11.0


Reviewed-by: Igor Mitsyanko 


[PATCH] ip: link add vxcan support

2017-06-02 Thread Oliver Hartkopp
Since commit a8f820a380a2a06 ('can: add Virtual CAN Tunnel driver (vxcan)')
for Linux 4.12 a virtual CAN tunnel driver analogue to veth is available in
Linux.

This patch adds the ability to create vxcan device pairs.

Signed-off-by: Oliver Hartkopp 
---
 include/linux/can/vxcan.h | 12 ++
 ip/Makefile   |  2 +-
 ip/iplink_vxcan.c | 99 +++
 3 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 include/linux/can/vxcan.h
 create mode 100644 ip/iplink_vxcan.c

diff --git a/include/linux/can/vxcan.h b/include/linux/can/vxcan.h
new file mode 100644
index ..ffb0b715
--- /dev/null
+++ b/include/linux/can/vxcan.h
@@ -0,0 +1,12 @@
+#ifndef _UAPI_CAN_VXCAN_H
+#define _UAPI_CAN_VXCAN_H
+
+enum {
+   VXCAN_INFO_UNSPEC,
+   VXCAN_INFO_PEER,
+
+   __VXCAN_INFO_MAX
+#define VXCAN_INFO_MAX (__VXCAN_INFO_MAX - 1)
+};
+
+#endif
diff --git a/ip/Makefile b/ip/Makefile
index e08c170a..8424b1f6 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -2,7 +2,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o 
ipnetns.o \
 rtm_map.o iptunnel.o ip6tunnel.o tunnel.o ipneigh.o ipntable.o iplink.o \
 ipmaddr.o ipmonitor.o ipmroute.o ipprefix.o iptuntap.o iptoken.o \
 ipxfrm.o xfrm_state.o xfrm_policy.o xfrm_monitor.o iplink_dummy.o \
-iplink_ifb.o iplink_nlmon.o iplink_team.o iplink_vcan.o \
+iplink_ifb.o iplink_nlmon.o iplink_team.o iplink_vcan.o iplink_vxcan.o \
 iplink_vlan.o link_veth.o link_gre.o iplink_can.o iplink_xdp.o \
 iplink_macvlan.o ipl2tp.o link_vti.o link_vti6.o \
 iplink_vxlan.o tcp_metrics.o iplink_ipoib.o ipnetconf.o link_ip6tnl.o \
diff --git a/ip/iplink_vxcan.c b/ip/iplink_vxcan.c
new file mode 100644
index ..680f640f
--- /dev/null
+++ b/ip/iplink_vxcan.c
@@ -0,0 +1,99 @@
+/*
+ * iplink_vxcan.c  vxcan device support (Virtual CAN Tunnel)
+ *
+ * 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.
+ *
+ * Author: Oliver Hartkopp 
+ * Based on:   link_veth.c from Pavel Emelianov 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "utils.h"
+#include "ip_common.h"
+
+static void print_usage(FILE *f)
+{
+   printf("Usage: ip link  type vxcan [peer ]\n"
+  "To get  type 'ip link add help'\n");
+}
+
+static void usage(void)
+{
+   print_usage(stderr);
+}
+
+static int vxcan_parse_opt(struct link_util *lu, int argc, char **argv,
+ struct nlmsghdr *hdr)
+{
+   char *dev = NULL;
+   char *name = NULL;
+   char *link = NULL;
+   char *type = NULL;
+   int index = 0;
+   int err, len;
+   struct rtattr *data;
+   int group;
+   struct ifinfomsg *ifm, *peer_ifm;
+   unsigned int ifi_flags, ifi_change;
+
+   if (strcmp(argv[0], "peer") != 0) {
+   usage();
+   return -1;
+   }
+
+   ifm = NLMSG_DATA(hdr);
+   ifi_flags = ifm->ifi_flags;
+   ifi_change = ifm->ifi_change;
+   ifm->ifi_flags = 0;
+   ifm->ifi_change = 0;
+
+   data = NLMSG_TAIL(hdr);
+   addattr_l(hdr, 1024, VXCAN_INFO_PEER, NULL, 0);
+
+   hdr->nlmsg_len += sizeof(struct ifinfomsg);
+
+   err = iplink_parse(argc - 1, argv + 1, (struct iplink_req *)hdr,
+  , , , , , );
+   if (err < 0)
+   return err;
+
+   if (name) {
+   len = strlen(name) + 1;
+   if (len > IFNAMSIZ)
+   invarg("\"name\" too long\n", *argv);
+   addattr_l(hdr, 1024, IFLA_IFNAME, name, len);
+   }
+
+   peer_ifm = RTA_DATA(data);
+   peer_ifm->ifi_index = index;
+   peer_ifm->ifi_flags = ifm->ifi_flags;
+   peer_ifm->ifi_change = ifm->ifi_change;
+   ifm->ifi_flags = ifi_flags;
+   ifm->ifi_change = ifi_change;
+
+   if (group != -1)
+   addattr32(hdr, 1024, IFLA_GROUP, group);
+
+   data->rta_len = (void *)NLMSG_TAIL(hdr) - (void *)data;
+   return argc - 1 - err;
+}
+
+static void vxcan_print_help(struct link_util *lu, int argc, char **argv,
+   FILE *f)
+{
+   print_usage(f);
+}
+
+struct link_util vxcan_link_util = {
+   .id = "vxcan",
+   .parse_opt = vxcan_parse_opt,
+   .print_help = vxcan_print_help,
+};
-- 
2.11.0



Re: [pull request][for-next 0/6] Mellanox mlx5 updates 2017-05-23

2017-06-02 Thread Alexei Starovoitov
On Fri, Jun 02, 2017 at 12:08:39PM -0400, David Miller wrote:
> From: Alexei Starovoitov 
> Date: Fri, 2 Jun 2017 09:06:43 -0700
> 
> > On Fri, Jun 02, 2017 at 06:39:40PM +0300, Leon Romanovsky wrote:
> >> On Thu, Jun 01, 2017 at 06:57:59PM -0400, Doug Ledford wrote:
> >> > On Thu, 2017-05-25 at 12:02 -0400, David Miller wrote:
> >> > > From: Saeed Mahameed 
> >> > > Date: Tue, 23 May 2017 14:43:58 +0300
> >> > >
> >> > > > Hi Dave and Doug,
> >> > > > 
> >> > > > This series introduces some small updates and FPGA support to the
> >> > > mlx5
> >> > > > core/ethernet and IB drivers.
> >> > > > 
> >> > > > For more details please see below.
> >> > > > 
> >> > > > Please pull and let me know if there's any problem.
> >> > >
> >> > > Ok, I've pulled this into net-next.
> >> > >
> >> > > Doug let me know if there are any merge hassles we need to coordinate
> >> > > on.
> >> > >
> >> > > Thanks.
> >> >
> >> > Will do.  But is the question of a possible revert settled?  Because
> >> > once I pull, a revert means I have to pull all the way up to the revert
> >> > as well...
> >> 
> >> Revert is unlikely to happen, Saeed is working with Alexey to resolve
> >> his raised concerns.
> > 
> > I still think the direction is absolutely wrong.
> > Reinventing fpga interfaces via nic driver is no-go.
> > mlx needs to send a patch to revert it to show that they are willing
> > to listen to the community.
> 
> "Two people from Facebook" is not the commnity Alexei. :-)

I've read the thread that fpga folks are not excited about
fpga behind the nic either... but yeah i'm mainly expressing
my opinions here.

> And ironically, you guys will want to be one of the main users of
> these facilities for the KTLS offload bits, so the desire to separate
> it out and make "backports easier" really confuses me.

We will not be using ktls offload via hidden fpga which
is not properly exposed to the kernel.
We've learned our lesson with eswitch.

ktls patches are independent of hw offload. It's great that
mlx fpga can accelerate ktls tx which is extra confirmation
that ktls api is on the right track. There is still 'ktls rx'
to finish and 'ktls rx offload' is even trickier, since it's
more intrusive into the core networking. Once crypto scatter gather
is improved, we expect to see 8% perf gain out of sw ktls alone.
So ktls hw offload is complementary and not mandatory.

Back to eswitch analogy. All I hear from mlx is "at this stage
it's not approriate ...". Well, I've been asking to do
'the right thing' for eswitch for months now and eswitch was
in the driver for years. What are the chances that this fpga
will ever be exposed? Once the code is merged there is no
incentive for the vendor to do it differently.



Re: [PATCH][V2] net: phy: marvell: make some functions static

2017-06-02 Thread Florian Fainelli


On 06/02/2017 07:13 AM, Colin King wrote:
> From: Colin Ian King 
> 
> functions m88e1510_get_temp_critical, m88e1510_set_temp_critical and
> m88e1510_get_temp_alarm can be made static as they not need to be
> in global scope.
> 
> Cleans up sparse warnings:
>  "symbol 'm88e1510_get_temp_alarm' was not declared. Should it be static?"
>  "symbol 'm88e1510_get_temp_critical' was not declared. Should it be
>   static?"
> 
> Signed-off-by: Colin Ian King 

Reviewed-by: Florian Fainelli 
-- 
Florian


[PATCH net] sock: reset sk_err when the error queue is empty

2017-06-02 Thread Soheil Hassas Yeganeh
From: Soheil Hassas Yeganeh 

Prior to f5f99309fa74 (sock: do not set sk_err in
sock_dequeue_err_skb), sk_err was reset to the error of
the skb on the head of the error queue.

Applications, most notably ping, are relying on this
behavior to reset sk_err for ICMP packets.

Set sk_err to the ICMP error when there is an ICMP packet
at the head of the error queue.

Fixes: f5f99309fa74 (sock: do not set sk_err in sock_dequeue_err_skb)
Reported-by: Cyril Hrubis 
Test-by: Cyril Hrubis 
Signed-off-by: Soheil Hassas Yeganeh 
Signed-off-by: Eric Dumazet 
Signed-off-by: Willem de Bruijn 
---
 net/core/skbuff.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 346d3e85dfbc..b1be7c01efe2 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3754,8 +3754,11 @@ struct sk_buff *sock_dequeue_err_skb(struct sock *sk)
 
spin_lock_irqsave(>lock, flags);
skb = __skb_dequeue(q);
-   if (skb && (skb_next = skb_peek(q)))
+   if (skb && (skb_next = skb_peek(q))) {
icmp_next = is_icmp_err_skb(skb_next);
+   if (icmp_next)
+   sk->sk_err = SKB_EXT_ERR(skb_next)->ee.ee_origin;
+   }
spin_unlock_irqrestore(>lock, flags);
 
if (is_icmp_err_skb(skb) && !icmp_next)
-- 
2.13.0.506.g27d5fe0cd-goog



Re: [pull request][for-next 0/6] Mellanox mlx5 updates 2017-05-23

2017-06-02 Thread David Miller
From: Alexei Starovoitov 
Date: Fri, 2 Jun 2017 09:06:43 -0700

> On Fri, Jun 02, 2017 at 06:39:40PM +0300, Leon Romanovsky wrote:
>> On Thu, Jun 01, 2017 at 06:57:59PM -0400, Doug Ledford wrote:
>> > On Thu, 2017-05-25 at 12:02 -0400, David Miller wrote:
>> > > From: Saeed Mahameed 
>> > > Date: Tue, 23 May 2017 14:43:58 +0300
>> > >
>> > > > Hi Dave and Doug,
>> > > > 
>> > > > This series introduces some small updates and FPGA support to the
>> > > mlx5
>> > > > core/ethernet and IB drivers.
>> > > > 
>> > > > For more details please see below.
>> > > > 
>> > > > Please pull and let me know if there's any problem.
>> > >
>> > > Ok, I've pulled this into net-next.
>> > >
>> > > Doug let me know if there are any merge hassles we need to coordinate
>> > > on.
>> > >
>> > > Thanks.
>> >
>> > Will do.  But is the question of a possible revert settled?  Because
>> > once I pull, a revert means I have to pull all the way up to the revert
>> > as well...
>> 
>> Revert is unlikely to happen, Saeed is working with Alexey to resolve
>> his raised concerns.
> 
> I still think the direction is absolutely wrong.
> Reinventing fpga interfaces via nic driver is no-go.
> mlx needs to send a patch to revert it to show that they are willing
> to listen to the community.

"Two people from Facebook" is not the commnity Alexei. :-)

And ironically, you guys will want to be one of the main users of
these facilities for the KTLS offload bits, so the desire to separate
it out and make "backports easier" really confuses me.


Re: [pull request][for-next 0/6] Mellanox mlx5 updates 2017-05-23

2017-06-02 Thread Alexei Starovoitov
On Fri, Jun 02, 2017 at 06:39:40PM +0300, Leon Romanovsky wrote:
> On Thu, Jun 01, 2017 at 06:57:59PM -0400, Doug Ledford wrote:
> > On Thu, 2017-05-25 at 12:02 -0400, David Miller wrote:
> > > From: Saeed Mahameed 
> > > Date: Tue, 23 May 2017 14:43:58 +0300
> > >
> > > > Hi Dave and Doug,
> > > > 
> > > > This series introduces some small updates and FPGA support to the
> > > mlx5
> > > > core/ethernet and IB drivers.
> > > > 
> > > > For more details please see below.
> > > > 
> > > > Please pull and let me know if there's any problem.
> > >
> > > Ok, I've pulled this into net-next.
> > >
> > > Doug let me know if there are any merge hassles we need to coordinate
> > > on.
> > >
> > > Thanks.
> >
> > Will do.  But is the question of a possible revert settled?  Because
> > once I pull, a revert means I have to pull all the way up to the revert
> > as well...
> 
> Revert is unlikely to happen, Saeed is working with Alexey to resolve
> his raised concerns.

I still think the direction is absolutely wrong.
Reinventing fpga interfaces via nic driver is no-go.
mlx needs to send a patch to revert it to show that they are willing
to listen to the community.



[PATCH V5 net-next] neigh: Really delete an arp/neigh entry on "ip neigh delete" or "arp -d"

2017-06-02 Thread Sowmini Varadhan
The command
  # arp -s 62.2.0.1 a:b:c:d:e:f dev eth2
adds an entry like the following (listed by "arp -an")
  ? (62.2.0.1) at 0a:0b:0c:0d:0e:0f [ether] PERM on eth2
but the symmetric deletion command
  # arp -i eth2 -d 62.2.0.1
does not remove the PERM entry from the table, and instead leaves behind
  ? (62.2.0.1) at  on eth2

The reason is that there is a refcnt of 1 for the arp_tbl itself
(neigh_alloc starts off the entry with a refcnt of 1), thus
the neigh_release() call from arp_invalidate() will (at best) just
decrement the ref to 1, but will never actually free it from the
table.

To fix this, we need to do something like neigh_forced_gc: if
the refcnt is 1 (i.e., on the table's ref), remove the entry from
the table and free it. This patch refactors and shares common code
between neigh_forced_gc and the newly added neigh_remove_one.

A similar issue exists for IPv6 Neighbor Cache entries, and is fixed
in a similar manner by this patch.

Signed-off-by: Sowmini Varadhan 
Reviewed-by: Julian Anastasov 
---
v2: kbuild-test-robot compile error
v3: do not export_symbol neigh_remove_one (David Miller comment)
v4: rearrange locking for tbl->lock (Julian Anastasov comment)
v5: minor touch-ups: removed retval from neigh_remove_one (Julian Anastasov),
got rid of checkpatch warnings, explicitly add net-next to subject line.

 include/net/neighbour.h |1 +
 net/core/neighbour.c|   60 ++
 net/ipv4/arp.c  |4 +++
 3 files changed, 54 insertions(+), 11 deletions(-)

diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index e4dd3a2..639b675 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -317,6 +317,7 @@ struct neighbour *__neigh_create(struct neigh_table *tbl, 
const void *pkey,
 int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, u32 flags,
 u32 nlmsg_pid);
 void __neigh_set_probe_once(struct neighbour *neigh);
+bool neigh_remove_one(struct neighbour *ndel, struct neigh_table *tbl);
 void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);
 int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
 int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index d274f81..dadb5ee 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -118,6 +118,50 @@ unsigned long neigh_rand_reach_time(unsigned long base)
 EXPORT_SYMBOL(neigh_rand_reach_time);
 
 
+static bool neigh_del(struct neighbour *n, __u8 state,
+ struct neighbour __rcu **np, struct neigh_table *tbl)
+{
+   bool retval = false;
+
+   write_lock(>lock);
+   if (atomic_read(>refcnt) == 1 && !(n->nud_state & state)) {
+   struct neighbour *neigh;
+
+   neigh = rcu_dereference_protected(n->next,
+ lockdep_is_held(>lock));
+   rcu_assign_pointer(*np, neigh);
+   n->dead = 1;
+   retval = true;
+   }
+   write_unlock(>lock);
+   if (retval)
+   neigh_cleanup_and_release(n);
+   return retval;
+}
+
+bool neigh_remove_one(struct neighbour *ndel, struct neigh_table *tbl)
+{
+   struct neigh_hash_table *nht;
+   void *pkey = ndel->primary_key;
+   u32 hash_val;
+   struct neighbour *n;
+   struct neighbour __rcu **np;
+
+   nht = rcu_dereference_protected(tbl->nht,
+   lockdep_is_held(>lock));
+   hash_val = tbl->hash(pkey, ndel->dev, nht->hash_rnd);
+   hash_val = hash_val >> (32 - nht->hash_shift);
+
+   np = >hash_buckets[hash_val];
+   while ((n = rcu_dereference_protected(*np,
+ lockdep_is_held(>lock {
+   if (n == ndel)
+   return neigh_del(n, 0, np, tbl);
+   np = >next;
+   }
+   return false;
+}
+
 static int neigh_forced_gc(struct neigh_table *tbl)
 {
int shrunk = 0;
@@ -140,19 +184,10 @@ static int neigh_forced_gc(struct neigh_table *tbl)
 * - nobody refers to it.
 * - it is not permanent
 */
-   write_lock(>lock);
-   if (atomic_read(>refcnt) == 1 &&
-   !(n->nud_state & NUD_PERMANENT)) {
-   rcu_assign_pointer(*np,
-   rcu_dereference_protected(n->next,
- lockdep_is_held(>lock)));
-   n->dead = 1;
-   shrunk  = 1;
-   write_unlock(>lock);
-   neigh_cleanup_and_release(n);
+   if (neigh_del(n, NUD_PERMANENT, np, tbl)) {
+   shrunk = 1;

[PATCH] amd-xgbe: use PAGE_ALLOC_COSTLY_ORDER in xgbe_map_rx_buffer

2017-06-02 Thread Michal Hocko
From: Michal Hocko 

xgbe_map_rx_buffer is rather confused about what PAGE_ALLOC_COSTLY_ORDER
means. It uses PAGE_ALLOC_COSTLY_ORDER-1 assuming that
PAGE_ALLOC_COSTLY_ORDER is the first costly order which is not the case
actually because orders larger than that are costly. And even that
applies only to sleeping allocations which is not the case here. We
simply do not perform any costly operations like reclaim or compaction
for those. Simplify the code by dropping the order calculation and use
PAGE_ALLOC_COSTLY_ORDER directly.

Signed-off-by: Michal Hocko 
---
 drivers/net/ethernet/amd/xgbe/xgbe-desc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c 
b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
index b3bc87fe3764..0a98c369df20 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
@@ -324,7 +324,7 @@ static int xgbe_map_rx_buffer(struct xgbe_prv_data *pdata,
  struct xgbe_ring *ring,
  struct xgbe_ring_data *rdata)
 {
-   int order, ret;
+   int ret;
 
if (!ring->rx_hdr_pa.pages) {
ret = xgbe_alloc_pages(pdata, >rx_hdr_pa, GFP_ATOMIC, 0);
@@ -333,9 +333,8 @@ static int xgbe_map_rx_buffer(struct xgbe_prv_data *pdata,
}
 
if (!ring->rx_buf_pa.pages) {
-   order = max_t(int, PAGE_ALLOC_COSTLY_ORDER - 1, 0);
ret = xgbe_alloc_pages(pdata, >rx_buf_pa, GFP_ATOMIC,
-  order);
+  PAGE_ALLOC_COSTLY_ORDER);
if (ret)
return ret;
}
-- 
2.11.0



  1   2   >