[NetDev] [ANNOUNCE] Netdev 1.2 weekly updates (6th September, 2016)

2016-09-06 Thread Hajime Tazaki

Hello folks,

Tokyo is still being in a hot weather but it'll start
comfortable autumn very soon.

Here is an weekly update of Netdev 1.2 Tokyo.

We again extended the deadline of early bird registration.
Please don't miss the discount ticket - and your early
registration will be definitely helpful to prepare the
conference.

http://netdevconf.org/1.2/registration.html


== Newly accepted sessions ==

Here is newly accepted sessions in the last week.  We're
going to announce keynote talks once we confirmed so, stay
tune for a while.

Full list of accepted sessions is available here.

http://netdevconf.org/1.2/accepted-sessions.html

* Workshop

- nftables workshop
  by Pablo Neira Ayuso

* Talk

- Data center networking stack
  by Tom Herbert

- Single Virtual function driver for current and future Intel Network devices
  by Anjali Singhai Jain, Mitch Williams, Jesse Brandeburg

- Stacked Vlan: Performance Improvement and Challenges
  by Toshiaki Makita

- eBPF/XDP hardware offload to SmartNICs
  by Jakub Kicinski, Nic Viljoen

- Using SR-IOV offload with application like openVswitch
  by Rony Efraim, Or Gerlitz

* BoF

- Accelerating container network with channel based IO
  by Rony Efraim, Or Gerlitz


== Our sponsors ==

- Platinum
Verizon, Facebook, Cumulus Networks
- Gold
Mojatatu Networks, VMWare, Google, NTT, LinkedIn
- Silver
NetApp, IIJ, Netronome, SolarFlare, Mellanox, Sophos
- Bronze
Zen Load Balancer

Twitter: https://twitter.com/netdev01
Web: http://netdevconf.org/1.2/

== Others ==

Be prepared for your travel ! Hotel and travel information
are available on the web pages.

http://netdevconf.org/1.2/travel.html
http://netdevconf.org/1.2/hotel.html


Looking forward to seeing you in Tokyo very soon.

-- Hajime




Re: [RFC PATCH 1/2] macb: Add 1588 support in Cadence GEM.

2016-09-06 Thread Harini Katakam
Hi Andrei,

Adding Richard Cochran for PTP.

On Fri, Sep 2, 2016 at 6:23 PM, Andrei Pistirica
 wrote:
> From: Harini Katakam 
>
> Cadence GEM provides a 102 bit time counter with 48 bits for seconds,
> 30 bits for nsecs and 24 bits for sub-nsecs to control 1588 timestamping.
>
> This patch does the following:
> - Registers to ptp clock framework
> - Timer initialization is done by writing time of day to the timer counter.
> - ns increment register is programmed as NSEC_PER_SEC/TSU_CLK.
>   For a 24 bit subns precision, the subns increment equals
>   remainder of (NS_PER_SEC/TSU_CLK) * (2^24).
> - HW time stamp capabilities are advertised via ethtool and macb ioctl is
>   updated accordingly.
> - Timestamps are obtained from the TX/RX PTP event/PEER registers.
>   The timestamp obtained thus is updated in skb for upper layers to access.
> - The drivers register functions with ptp to perform time and frequency
>   adjustment.
> - Time adjustment is done by writing to the 1558_ADJUST register.
>   The controller will read the delta in this register and update the timer
>   counter register. Alternatively, for large time offset adjustments,
>   the driver reads the secs and nsecs counter values, adds/subtracts the
>   delta and updates the timer counter.
> - Frequency adjustment is not directly supported by this IP.
>   addend is the initial value ns increment and similarly addendesub.
>   The ppb (parts per billion) provided is used as
>   ns_incr = addend +/- (ppb/rate).
>   Similarly the remainder of the above is used to populate subns increment.
>   In case the ppb requested is negative AND subns adjustment greater than
>   the addendsub, ns_incr is reduced by 1 and subns_incr is adjusted in
>   positive accordingly.
>
> Signed-off-by: Harini Katakam 
> Signed-off-by: Andrei Pistirica 
> ---
> This patch is based on original Harini's patch, implemented in a
> separate file to ease the review/maintanance and integration with
> other platforms (e.g. Zynq Ultrascale+ MPSoC).
> Feature was tested on SAMA5D2 platform using ptp4l v1.6 from linuxptp
> project and also with ptpd2 version 2.3.1. PTP was tested over
> IPv4,IPv6 and 802.3 protocols.
>
> Hariani, please let me know if you are ok with this patch, and if you
> want to be stated as author/signed-off?
>

Thanks for the patch. It seems ok. I'm making some changes on
top of this, especially in your second patch for picking RX timestamp,
since that is handled from indication in the BD for ZynqMP.

Regards,
Harini


Re: [RFC PATCH 2/2] macb: Enable 1588 support in SAMA5D2 platform.

2016-09-06 Thread Harini Katakam
Hi Andrei,

+Richard Cochran

On Fri, Sep 2, 2016 at 6:23 PM, Andrei Pistirica
 wrote:
> Hardware time stamp on the PTP Ethernet packets are received using the
> SO_TIMESTAMPING API. Timers are obtained from the PTP event/peer
> gem registers.
>
> Signed-off-by: Andrei Pistirica 
> ---
> Integration with SAMA5D2 only. This feature wasn't tested on any
> other platform that might use cadence/gem.
>
> Patch is not completely ported to the very latest version of net-next,
> and it will be after review.
>

> @@ -853,6 +858,11 @@ static int gem_rx(struct macb *bp, int budget)
> GEM_BFEXT(RX_CSUM, ctrl) & GEM_RX_CSUM_CHECKED_MASK)
> skb->ip_summed = CHECKSUM_UNNECESSARY;
>
> +/* guard the hot-path */
> +#ifdef CONFIG_MACB_USE_HWSTAMP
> +   if (bp->hwts_rx_en)
> +   macb_ptp_do_rxstamp(bp, skb);
> +#endif

I'm just wondering if the same #ifdef can be used for timestamping
in all versions of this IP.
As you know, ZynqMP uses the timestamp from BD and older
versions of do not have an indication or extended BD support.
So, it might useful to add a dependency/check on the product family,
through config structure.
That way, both version can use their respective RX timestamp methods
based on the compatible string.
Please let me know if you have any other ideas.

Regards,
Harini


[PATCH iproute2] ip route: check ftell, fseek return value

2016-09-06 Thread Hangbin Liu
ftell() may return -1 in error case, which is not handled and therefore pass a
negative offset to fseek(). The return code of fseek() is also not checked.

Reported-by: Phil Sutter 
Signed-off-by: Hangbin Liu 
---
 ip/iproute.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/ip/iproute.c b/ip/iproute.c
index 3da23af..ba877dc 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -1859,7 +1859,11 @@ static int iproute_restore(void)
if (route_dump_check_magic())
exit(-1);
 
-   pos = ftell(stdin);
+   if ((pos = ftell(stdin)) == -1) {
+   perror("Failed to restore: ftell");
+   exit(errno);
+   }
+
for (prio = 0; prio < 3; prio++) {
int err;
 
@@ -1867,7 +1871,10 @@ static int iproute_restore(void)
if (err)
exit(err);
 
-   fseek(stdin, pos, SEEK_SET);
+   if (fseek(stdin, pos, SEEK_SET) == -1) {
+   perror("Failed to restore: fseek");
+   exit(errno);
+   }
}
 
exit(0);
-- 
2.5.5



[PATCH iproute] gitignore: Ignore 'tags' file generated by ctags

2016-09-06 Thread Hangbin Liu
Signed-off-by: Hangbin Liu 
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index ef03b17..74a5496 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@ Config
 # cscope
 cscope.*
 ncscope.*
+tags
 TAGS
 
 # git files that we don't want to ignore even it they are dot-files
-- 
2.5.5



[PATCH iproute2] ip link: fix up bond/bridge slave id

2016-09-06 Thread Hangbin Liu
Signed-off-by: Hangbin Liu 
---
 ip/iplink_bond_slave.c   | 2 +-
 ip/iplink_bridge_slave.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ip/iplink_bond_slave.c b/ip/iplink_bond_slave.c
index 9c60dea..8a3104b 100644
--- a/ip/iplink_bond_slave.c
+++ b/ip/iplink_bond_slave.c
@@ -130,7 +130,7 @@ static void bond_slave_print_help(struct link_util *lu, int 
argc, char **argv,
 }
 
 struct link_util bond_slave_link_util = {
-   .id = "bond",
+   .id = "bond_slave",
.maxattr= IFLA_BOND_SLAVE_MAX,
.print_opt  = bond_slave_print_opt,
.parse_opt  = bond_slave_parse_opt,
diff --git a/ip/iplink_bridge_slave.c b/ip/iplink_bridge_slave.c
index a44d4e4..58563e0 100644
--- a/ip/iplink_bridge_slave.c
+++ b/ip/iplink_bridge_slave.c
@@ -293,7 +293,7 @@ static void bridge_slave_print_help(struct link_util *lu, 
int argc, char **argv,
 }
 
 struct link_util bridge_slave_link_util = {
-   .id = "bridge",
+   .id = "bridge_slave",
.maxattr= IFLA_BRPORT_MAX,
.print_opt  = bridge_slave_print_opt,
.parse_opt  = bridge_slave_parse_opt,
-- 
2.5.5



[v11, 5/8] soc: fsl: add GUTS driver for QorIQ platforms

2016-09-06 Thread Yangbo Lu
The global utilities block controls power management, I/O device
enabling, power-onreset(POR) configuration monitoring, alternate
function selection for multiplexed signals,and clock control.

This patch adds a driver to manage and access global utilities block.
Initially only reading SVR and registering soc device are supported.
Other guts accesses, such as reading RCW, should eventually be moved
into this driver as well.

Signed-off-by: Yangbo Lu 
Signed-off-by: Scott Wood 
---
Changes for v4:
- Added this patch
Changes for v5:
- Modified copyright info
- Changed MODULE_LICENSE to GPL
- Changed EXPORT_SYMBOL_GPL to EXPORT_SYMBOL
- Made FSL_GUTS user-invisible
- Added a complete compatible list for GUTS
- Stored guts info in file-scope variable
- Added mfspr() getting SVR
- Redefined GUTS APIs
- Called fsl_guts_init rather than using platform driver
- Removed useless parentheses
- Removed useless 'extern' key words
Changes for v6:
- Made guts thread safe in fsl_guts_init
Changes for v7:
- Removed 'ifdef' for function declaration in guts.h
Changes for v8:
- Fixes lines longer than 80 characters checkpatch issue
- Added 'Acked-by: Scott Wood'
Changes for v9:
- None
Changes for v10:
- None
Changes for v11:
- Changed to platform driver
- Registered soc device
---
 drivers/soc/Kconfig  |   2 +-
 drivers/soc/fsl/Kconfig  |  20 ++
 drivers/soc/fsl/Makefile |   1 +
 drivers/soc/fsl/guts.c   | 483 +++
 include/linux/fsl/guts.h | 127 -
 5 files changed, 584 insertions(+), 49 deletions(-)
 create mode 100644 drivers/soc/fsl/Kconfig
 create mode 100644 drivers/soc/fsl/guts.c

diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index fe42a2f..f31bceb 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -1,7 +1,7 @@
 menu "SOC (System On Chip) specific Drivers"
 
 source "drivers/soc/bcm/Kconfig"
-source "drivers/soc/fsl/qe/Kconfig"
+source "drivers/soc/fsl/Kconfig"
 source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/qcom/Kconfig"
 source "drivers/soc/rockchip/Kconfig"
diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
new file mode 100644
index 000..439998d
--- /dev/null
+++ b/drivers/soc/fsl/Kconfig
@@ -0,0 +1,20 @@
+#
+# Freescale SOC drivers
+#
+
+source "drivers/soc/fsl/qe/Kconfig"
+
+config FSL_GUTS
+   bool "Freescale QorIQ GUTS driver"
+   select SOC_BUS
+   select GLOB
+   help
+ The global utilities block controls power management, I/O device
+ enabling, power-onreset(POR) configuration monitoring, alternate
+ function selection for multiplexed signals,and clock control.
+ This driver is to manage and access global utilities block.
+ Initially only reading SVR and registering soc device are supported.
+ Other guts accesses, such as reading RCW, should eventually be moved
+ into this driver as well.
+
+ If you want GUTS driver support, you should say Y here.
diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
index 203307f..02afb7f 100644
--- a/drivers/soc/fsl/Makefile
+++ b/drivers/soc/fsl/Makefile
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_QUICC_ENGINE) += qe/
 obj-$(CONFIG_CPM)  += qe/
+obj-$(CONFIG_FSL_GUTS) += guts.o
diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
new file mode 100644
index 000..93c39315
--- /dev/null
+++ b/drivers/soc/fsl/guts.c
@@ -0,0 +1,483 @@
+/*
+ * Freescale QorIQ Platforms GUTS Driver
+ *
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct guts {
+   struct ccsr_guts __iomem *regs;
+   bool little_endian;
+};
+
+static struct guts *guts;
+static struct soc_device_attribute *soc_dev_attr;
+static struct soc_device *soc_dev;
+
+
+/* SoC attribute definition for QorIQ platform */
+static const struct soc_device_attribute qoriq_soc[] = {
+#ifdef CONFIG_PPC
+   /*
+* Power Architecture-based SoCs T Series
+*/
+
+   /* SoC: T1024/T1014/T1023/T1013 Rev: 1.0 */
+   { .soc_id   = "svr:0x85400010,name:T1024,die:T1024",
+ .revision = "1.0",
+   },
+   { .soc_id   = "svr:0x85480010,name:T1024E,die:T1024",
+ .revision = "1.0",
+   },
+   { .soc_id   = "svr:0x85440010,name:T1014,die:T1024",
+ .revision = "1.0",
+   },
+   { .soc_id   = 

[v11, 3/8] dt: bindings: move guts devicetree doc out of powerpc directory

2016-09-06 Thread Yangbo Lu
Move guts devicetree doc to Documentation/devicetree/bindings/soc/fsl/
since it's used by not only PowerPC but also ARM. And add a specification
for 'little-endian' property.

Signed-off-by: Yangbo Lu 
Acked-by: Rob Herring 
Acked-by: Scott Wood 
---
Changes for v4:
- Added this patch
Changes for v5:
- Modified the description for little-endian property
Changes for v6:
- None
Changes for v7:
- None
Changes for v8:
- Added 'Acked-by: Scott Wood'
- Added 'Acked-by: Rob Herring'
Changes for v9:
- None
Changes for v10:
- None
Changes for v11:
- None
---
 Documentation/devicetree/bindings/{powerpc => soc}/fsl/guts.txt | 3 +++
 1 file changed, 3 insertions(+)
 rename Documentation/devicetree/bindings/{powerpc => soc}/fsl/guts.txt (91%)

diff --git a/Documentation/devicetree/bindings/powerpc/fsl/guts.txt 
b/Documentation/devicetree/bindings/soc/fsl/guts.txt
similarity index 91%
rename from Documentation/devicetree/bindings/powerpc/fsl/guts.txt
rename to Documentation/devicetree/bindings/soc/fsl/guts.txt
index b71b203..07adca9 100644
--- a/Documentation/devicetree/bindings/powerpc/fsl/guts.txt
+++ b/Documentation/devicetree/bindings/soc/fsl/guts.txt
@@ -25,6 +25,9 @@ Recommended properties:
  - fsl,liodn-bits : Indicates the number of defined bits in the LIODN
registers, for those SOCs that have a PAMU device.
 
+ - little-endian : Indicates that the global utilities block is little
+   endian. The default is big endian.
+
 Examples:
global-utilities@e {/* global utilities block */
compatible = "fsl,mpc8548-guts";
-- 
2.1.0.27.g96db324



[v11, 8/8] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

2016-09-06 Thread Yangbo Lu
The eSDHC of T4240-R1.0-R2.0 has incorrect vender version and spec version.
Acturally the right version numbers should be VVN=0x13 and SVN = 0x1.
This patch adds the GUTS driver support for eSDHC driver to match SoC.
And fix host version to avoid that incorrect version numbers break down
the ADMA data transfer.

Signed-off-by: Yangbo Lu 
Acked-by: Ulf Hansson 
Acked-by: Scott Wood 
---
Changes for v2:
- Got SVR through iomap instead of dts
Changes for v3:
- Managed GUTS through syscon instead of iomap in eSDHC driver
Changes for v4:
- Got SVR by GUTS driver instead of SYSCON
Changes for v5:
- Changed to get SVR through API fsl_guts_get_svr()
- Combined patch 4, patch 5 and patch 6 into one
Changes for v6:
- Added 'Acked-by: Ulf Hansson'
Changes for v7:
- None
Changes for v8:
- Added 'Acked-by: Scott Wood'
Changes for v9:
- None
Changes for v10:
- None
Changes for v11:
- Changed to use soc_device_match
---
 drivers/mmc/host/Kconfig  |  1 +
 drivers/mmc/host/sdhci-of-esdhc.c | 20 
 2 files changed, 21 insertions(+)

diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 5274f50..a1135a9 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -144,6 +144,7 @@ config MMC_SDHCI_OF_ESDHC
depends on MMC_SDHCI_PLTFM
depends on PPC || ARCH_MXC || ARCH_LAYERSCAPE
select MMC_SDHCI_IO_ACCESSORS
+   select FSL_GUTS
help
  This selects the Freescale eSDHC controller support.
 
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c 
b/drivers/mmc/host/sdhci-of-esdhc.c
index fb71c86..0a31aa5 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "sdhci-pltfm.h"
 #include "sdhci-esdhc.h"
@@ -28,6 +29,7 @@
 struct sdhci_esdhc {
u8 vendor_ver;
u8 spec_ver;
+   bool quirk_incorrect_hostver;
 };
 
 /**
@@ -73,6 +75,8 @@ static u32 esdhc_readl_fixup(struct sdhci_host *host,
 static u16 esdhc_readw_fixup(struct sdhci_host *host,
 int spec_reg, u32 value)
 {
+   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+   struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host);
u16 ret;
int shift = (spec_reg & 0x2) * 8;
 
@@ -80,6 +84,12 @@ static u16 esdhc_readw_fixup(struct sdhci_host *host,
ret = value & 0x;
else
ret = (value >> shift) & 0x;
+   /* Workaround for T4240-R1.0-R2.0 eSDHC which has incorrect
+* vendor version and spec version information.
+*/
+   if ((spec_reg == SDHCI_HOST_VERSION) &&
+   (esdhc->quirk_incorrect_hostver))
+   ret = (VENDOR_V_23 << SDHCI_VENDOR_VER_SHIFT) | SDHCI_SPEC_200;
return ret;
 }
 
@@ -558,6 +568,12 @@ static const struct sdhci_pltfm_data sdhci_esdhc_le_pdata 
= {
.ops = _esdhc_le_ops,
 };
 
+static struct soc_device_attribute soc_incorrect_hostver[] = {
+   { .soc_id = "*name:T4240*", .revision = "1.0", },
+   { .soc_id = "*name:T4240*", .revision = "2.0", },
+   { },
+};
+
 static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host)
 {
struct sdhci_pltfm_host *pltfm_host;
@@ -571,6 +587,10 @@ static void esdhc_init(struct platform_device *pdev, 
struct sdhci_host *host)
esdhc->vendor_ver = (host_ver & SDHCI_VENDOR_VER_MASK) >>
 SDHCI_VENDOR_VER_SHIFT;
esdhc->spec_ver = host_ver & SDHCI_SPEC_VER_MASK;
+   if (soc_device_match(soc_incorrect_hostver))
+   esdhc->quirk_incorrect_hostver = true;
+   else
+   esdhc->quirk_incorrect_hostver = false;
 }
 
 static int sdhci_esdhc_probe(struct platform_device *pdev)
-- 
2.1.0.27.g96db324



[v11, 7/8] base: soc: introduce soc_device_match() interface

2016-09-06 Thread Yangbo Lu
We keep running into cases where device drivers want to know the exact
version of the a SoC they are currently running on. In the past, this has
usually been done through a vendor specific API that can be called by a
driver, or by directly accessing some kind of version register that is
not part of the device itself but that belongs to a global register area
of the chip.

Common reasons for doing this include:

- A machine is not using devicetree or similar for passing data about
  on-chip devices, but just announces their presence using boot-time
  platform devices, and the machine code itself does not care about the
  revision.

- There is existing firmware or boot loaders with existing DT binaries
  with generic compatible strings that do not identify the particular
  revision of each device, but the driver knows which SoC revisions
  include which part.

- A prerelease version of a chip has some quirks and we are using the same
  version of the bootloader and the DT blob on both the prerelease and the
  final version. An update of the DT binding seems inappropriate because
  that would involve maintaining multiple copies of the dts and/or
  bootloader.

This patch introduces the soc_device_match() interface that is meant to
work like of_match_node() but instead of identifying the version of a
device, it identifies the SoC itself using a vendor-agnostic interface.

Unlike of_match_node(), we do not do an exact string compare but instead
use glob_match() to allow wildcards in strings.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Yangbo Lu 
---
Changes for v11:
- Added this patch for soc match
---
 drivers/base/Kconfig|  1 +
 drivers/base/soc.c  | 61 +
 include/linux/sys_soc.h |  3 +++
 3 files changed, 65 insertions(+)

diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 98504ec..f1591ad2 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -225,6 +225,7 @@ config GENERIC_CPU_AUTOPROBE
 
 config SOC_BUS
bool
+   select GLOB
 
 source "drivers/base/regmap/Kconfig"
 
diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 75b98aa..5c4e84a 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static DEFINE_IDA(soc_ida);
 
@@ -168,3 +169,63 @@ static void __exit soc_bus_unregister(void)
bus_unregister(_bus_type);
 }
 module_exit(soc_bus_unregister);
+
+static int soc_device_match_one(struct device *dev, void *arg)
+{
+   struct soc_device *soc_dev = container_of(dev, struct soc_device, dev);
+   const struct soc_device_attribute *match = arg;
+
+   if (match->machine &&
+   !glob_match(match->machine, soc_dev->attr->machine))
+   return 0;
+
+   if (match->family &&
+   !glob_match(match->family, soc_dev->attr->family))
+   return 0;
+
+   if (match->revision &&
+   !glob_match(match->revision, soc_dev->attr->revision))
+   return 0;
+
+   if (match->soc_id &&
+   !glob_match(match->soc_id, soc_dev->attr->soc_id))
+   return 0;
+
+   return 1;
+}
+
+/*
+ * soc_device_match - identify the SoC in the machine
+ * @matches: zero-terminated array of possible matches
+ *
+ * returns the first matching entry of the argument array, or NULL
+ * if none of them match.
+ *
+ * This function is meant as a helper in place of of_match_node()
+ * in cases where either no device tree is available or the information
+ * in a device node is insufficient to identify a particular variant
+ * by its compatible strings or other properties. For new devices,
+ * the DT binding should always provide unique compatible strings
+ * that allow the use of of_match_node() instead.
+ *
+ * The calling function can use the .data entry of the
+ * soc_device_attribute to pass a structure or function pointer for
+ * each entry.
+ */
+const struct soc_device_attribute *soc_device_match(
+   const struct soc_device_attribute *matches)
+{
+   struct device *dev;
+   int ret;
+
+   for (ret = 0; ret == 0; matches++) {
+   if (!(matches->machine || matches->family ||
+ matches->revision || matches->soc_id))
+   return NULL;
+   dev = NULL;
+   ret = bus_for_each_dev(_bus_type, dev, (void *)matches,
+  soc_device_match_one);
+   }
+   return matches;
+}
+EXPORT_SYMBOL_GPL(soc_device_match);
diff --git a/include/linux/sys_soc.h b/include/linux/sys_soc.h
index 2739ccb..9f5eb06 100644
--- a/include/linux/sys_soc.h
+++ b/include/linux/sys_soc.h
@@ -13,6 +13,7 @@ struct soc_device_attribute {
const char *family;
const char *revision;
const char *soc_id;
+   const void *data;
 };
 
 /**
@@ -34,4 +35,6 @@ void soc_device_unregister(struct soc_device *soc_dev);
  */
 struct device 

RE: linux-next: manual merge of the char-misc tree with the net-next tree

2016-09-06 Thread KY Srinivasan


> -Original Message-
> From: Greg KH [mailto:g...@kroah.com]
> Sent: Monday, September 5, 2016 5:04 PM
> To: Stephen Rothwell 
> Cc: Arnd Bergmann ; David Miller ;
> Networking ; linux-n...@vger.kernel.org; linux-
> ker...@vger.kernel.org; Stephen Hemminger ;
> Vitaly Kuznetsov ; KY Srinivasan 
> Subject: Re: linux-next: manual merge of the char-misc tree with the net-next
> tree
> 
> On Mon, Sep 05, 2016 at 04:56:50PM +1000, Stephen Rothwell wrote:
> > Hi all,
> >
> > Today's linux-next merge of the char-misc tree got a conflict in:
> >
> >   include/linux/hyperv.h
> >
> > between commit:
> >
> >   30d1de08c87d ("hv_netvsc: make inline functions static")
> >
> > from the net-next tree and commit:
> >
> >   bb08d431a914 ("Drivers: hv: ring_buffer: count on wrap around mappings in
> get_next_pkt_raw()")
> >
> > from the char-misc tree.
> >
> > I fixed it up (the former moved the code modified by the latter, so the
> > below patch applies to the new location of the code) and can carry the
> > fix as necessary. This is now fixed as far as linux-next is concerned,
> > but any non trivial conflicts should be mentioned to your upstream
> > maintainer when your tree is submitted for merging.  You may also want
> > to consider cooperating with the maintainer of the conflicting tree to
> > minimise any particularly complex conflicts.
> >
> > From: Stephen Rothwell 
> > Date: Mon, 5 Sep 2016 16:53:06 +1000
> > Subject: [PATCH] Drivers: hv: ring_buffer: merge fix up for "hv_netvsc: make
> >  inline functions static"
> >
> > Signed-off-by: Stephen Rothwell 
> > ---
> >  drivers/net/hyperv/netvsc.c | 32 +++-
> >  1 file changed, 11 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
> > index 2a9ccc4d9e3c..026df6556068 100644
> > --- a/drivers/net/hyperv/netvsc.c
> > +++ b/drivers/net/hyperv/netvsc.c
> > @@ -42,31 +42,23 @@ static struct vmpacket_descriptor *
> >  get_next_pkt_raw(struct vmbus_channel *channel)
> >  {
> > struct hv_ring_buffer_info *ring_info = >inbound;
> > -   u32 read_loc = ring_info->priv_read_index;
> > +   u32 priv_read_loc = ring_info->priv_read_index;
> > void *ring_buffer = hv_get_ring_buffer(ring_info);
> > -   struct vmpacket_descriptor *cur_desc;
> > -   u32 packetlen;
> > u32 dsize = ring_info->ring_datasize;
> > -   u32 delta = read_loc - ring_info->ring_buffer->read_index;
> > +   /*
> > +* delta is the difference between what is available to read and
> > +* what was already consumed in place. We commit read index after
> > +* the whole batch is processed.
> > +*/
> > +   u32 delta = priv_read_loc >= ring_info->ring_buffer->read_index ?
> > +   priv_read_loc - ring_info->ring_buffer->read_index :
> > +   (dsize - ring_info->ring_buffer->read_index) + priv_read_loc;
> > u32 bytes_avail_toread = (hv_get_bytes_to_read(ring_info) - delta);
> >
> > if (bytes_avail_toread < sizeof(struct vmpacket_descriptor))
> > return NULL;
> >
> > -   if ((read_loc + sizeof(*cur_desc)) > dsize)
> > -   return NULL;
> > -
> > -   cur_desc = ring_buffer + read_loc;
> > -   packetlen = cur_desc->len8 << 3;
> > -
> > -   /*
> > -* If the packet under consideration is wrapping around,
> > -* return failure.
> > -*/
> > -   if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > (dsize - 1))
> > -   return NULL;
> > -
> > -   return cur_desc;
> > +   return ring_buffer + priv_read_loc;
> >  }
> >
> >  /*
> > @@ -78,16 +70,14 @@ static void put_pkt_raw(struct vmbus_channel
> *channel,
> > struct vmpacket_descriptor *desc)
> >  {
> > struct hv_ring_buffer_info *ring_info = >inbound;
> > -   u32 read_loc = ring_info->priv_read_index;
> > u32 packetlen = desc->len8 << 3;
> > u32 dsize = ring_info->ring_datasize;
> >
> > -   BUG_ON((read_loc + packetlen + VMBUS_PKT_TRAILER) > dsize);
> > -
> > /*
> >  * Include the packet trailer.
> >  */
> > ring_info->priv_read_index += packetlen + VMBUS_PKT_TRAILER;
> > +   ring_info->priv_read_index %= dsize;
> >  }
> >
> >  /*
> 
> Ugh, messy.  Thanks for this.
> 
> KY, how did this happen?
Thanks Stephen. Greg, sorry about this. We should have split Vitaly's patch to 
avoid this inter-tree issue. Vitaly and I will work to fix this.

Regards,

K. Y 

> 
> greg k-h


[v11, 0/8] Fix eSDHC host version register bug

2016-09-06 Thread Yangbo Lu
This patchset is used to fix a host version register bug in the T4240-R1.0-R2.0
eSDHC controller. To match the SoC version and revision, 10 previous version
patchsets had tried many methods but all of them were rejected by reviewers.
Such as
- dts compatible method
- syscon method
- ifdef PPC method
- GUTS driver getting SVR method
Anrd suggested a soc_device_match method in v10, and this is the only available
method left now. This v11 patchset introduces the soc_device_match interface in
soc driver.

The first six patches are to add the GUTS driver. This is used to register a
soc device which contain soc version and revision information.
The following two patches introduce the soc_device_match method in soc driver
and apply it on esdhc driver to fix this bug.

Yangbo Lu (8):
  dt: bindings: update Freescale DCFG compatible
  ARM64: dts: ls2080a: add device configuration node
  dt: bindings: move guts devicetree doc out of powerpc directory
  powerpc/fsl: move mpc85xx.h to include/linux/fsl
  soc: fsl: add GUTS driver for QorIQ platforms
  MAINTAINERS: add entry for Freescale SoC drivers
  base: soc: introduce soc_device_match() interface
  mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

 Documentation/devicetree/bindings/arm/fsl.txt  |   6 +-
 .../bindings/{powerpc => soc}/fsl/guts.txt |   3 +
 MAINTAINERS|  11 +-
 arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi |   6 +
 arch/powerpc/kernel/cpu_setup_fsl_booke.S  |   2 +-
 arch/powerpc/sysdev/fsl_pci.c  |   2 +-
 drivers/base/Kconfig   |   1 +
 drivers/base/soc.c |  61 +++
 drivers/clk/clk-qoriq.c|   3 +-
 drivers/i2c/busses/i2c-mpc.c   |   2 +-
 drivers/iommu/fsl_pamu.c   |   3 +-
 drivers/mmc/host/Kconfig   |   1 +
 drivers/mmc/host/sdhci-of-esdhc.c  |  20 +
 drivers/net/ethernet/freescale/gianfar.c   |   2 +-
 drivers/soc/Kconfig|   2 +-
 drivers/soc/fsl/Kconfig|  20 +
 drivers/soc/fsl/Makefile   |   1 +
 drivers/soc/fsl/guts.c | 483 +
 include/linux/fsl/guts.h   | 127 --
 .../asm/mpc85xx.h => include/linux/fsl/svr.h   |   4 +-
 include/linux/sys_soc.h|   3 +
 21 files changed, 702 insertions(+), 61 deletions(-)
 rename Documentation/devicetree/bindings/{powerpc => soc}/fsl/guts.txt (91%)
 create mode 100644 drivers/soc/fsl/Kconfig
 create mode 100644 drivers/soc/fsl/guts.c
 rename arch/powerpc/include/asm/mpc85xx.h => include/linux/fsl/svr.h (97%)

-- 
2.1.0.27.g96db324



[v11, 6/8] MAINTAINERS: add entry for Freescale SoC drivers

2016-09-06 Thread Yangbo Lu
Add maintainer entry for Freescale SoC drivers including
the QE library and the GUTS driver now. Also add maintainer
for QE library.

Signed-off-by: Yangbo Lu 
Acked-by: Scott Wood 
Acked-by: Qiang Zhao 
---
Changes for v8:
- Added this patch
Changes for v9:
- Added linux-arm mail list
- Removed GUTS driver entry
Changes for v10:
- Changed 'DRIVER' to 'DRIVERS'
- Added 'Acked-by' of Scott and Qiang
Changes for v11:
- None
---
 MAINTAINERS | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 71aa5da..3954c0c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4969,9 +4969,18 @@ F:   drivers/net/ethernet/freescale/fec_ptp.c
 F: drivers/net/ethernet/freescale/fec.h
 F: Documentation/devicetree/bindings/net/fsl-fec.txt
 
+FREESCALE SOC DRIVERS
+M: Scott Wood 
+L: linuxppc-...@lists.ozlabs.org
+L: linux-arm-ker...@lists.infradead.org
+S: Maintained
+F: drivers/soc/fsl/
+F: include/linux/fsl/
+
 FREESCALE QUICC ENGINE LIBRARY
+M: Qiang Zhao 
 L: linuxppc-...@lists.ozlabs.org
-S: Orphan
+S: Maintained
 F: drivers/soc/fsl/qe/
 F: include/soc/fsl/*qe*.h
 F: include/soc/fsl/*ucc*.h
-- 
2.1.0.27.g96db324



Re: [PATCH net-next 2/3] smsc95xx: Add register define

2016-09-06 Thread David Miller
From: Joe Perches 
Date: Fri, 02 Sep 2016 13:40:01 -0700

> On Fri, 2016-09-02 at 20:34 +, woojung@microchip.com wrote:
>> From: Woojung Huh 
>> 
>> Add STRAP_STATUS defines.
> []
>> diff --git a/drivers/net/usb/smsc95xx.h b/drivers/net/usb/smsc95xx.h
> []
>> @@ -144,6 +144,14 @@
>>  
>>  #define BURST_CAP   (0x38)
>>  
>> +#define STRAP_STATUS(0x3C)
>> +#define STRAP_STATUS_PWR_SEL_   (0x0020)
>> +#define STRAP_STATUS_AMDIX_EN_  (0x0010)
>> +#define STRAP_STATUS_PORT_SWAP_ (0x0008)
>> +#define STRAP_STATUS_EEP_SIZE_  (0x0004)
>> +#define STRAP_STATUS_RMT_WKP_   (0x0002)
>> +#define STRAP_STATUS_EEP_DISABLE_   (0x0001)
> 
> Using BIT would be more common.
> 
> Ending the #defines with an underscore is just odd
> and unappealing.

But that's what the rest of this file is doing already.

If we want to change this, it's a separate follow-up change.


Re: [PATCH net-next 0/3] smsc95xx: patch serises

2016-09-06 Thread David Miller
From: 
Date: Fri, 2 Sep 2016 20:34:17 +

> From: Woojung Huh 

Series applied, thanks.


Re: [ethtool PATCH v1 0/2] ethtool: add support for 1000BaseX and missing 10G link mode

2016-09-06 Thread John W. Linville
On Sun, Aug 28, 2016 at 11:56:48PM -0700, Vidya Sagar Ravipati wrote:
> From: Vidya Sagar Ravipati 
> 
> This patchset enhances ethtool link mode bitmap to include
> missing interface modes for 1G/10G speeds
> 
> Vidya Sagar Ravipati (2):
>   ethtool-copy.h:sync with net
>   ethtool: add support for 1000BaseX and missing 10G link mode
> 
>  ethtool-copy.h | 11 +--
>  ethtool.c  | 19 +++
>  2 files changed, 28 insertions(+), 2 deletions(-)
> 
> -- 
> 2.1.4

LGTM -- applied

Would you care to fix-up the man page as well?

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


Re: [ethtool PATCH v1 0/2] ethtool: add support for 1000BaseX and missing 10G link mode

2016-09-06 Thread Vidya Sagar Ravipati
Will send out man page fix. Missed it.

On Tue, Sep 6, 2016 at 1:32 PM, Vidya Sagar Ravipati
 wrote:
> Will send out man page fix too. Missed it.
>
> On Tue, Sep 6, 2016 at 1:16 PM, John W. Linville 
> wrote:
>>
>> On Sun, Aug 28, 2016 at 11:56:48PM -0700, Vidya Sagar Ravipati wrote:
>> > From: Vidya Sagar Ravipati 
>> >
>> > This patchset enhances ethtool link mode bitmap to include
>> > missing interface modes for 1G/10G speeds
>> >
>> > Vidya Sagar Ravipati (2):
>> >   ethtool-copy.h:sync with net
>> >   ethtool: add support for 1000BaseX and missing 10G link mode
>> >
>> >  ethtool-copy.h | 11 +--
>> >  ethtool.c  | 19 +++
>> >  2 files changed, 28 insertions(+), 2 deletions(-)
>> >
>> > --
>> > 2.1.4
>>
>> LGTM -- applied
>>
>> Would you care to fix-up the man page as well?
>>
>> John
>> --
>> John W. LinvilleSomeday the world will need a hero, and
>> you
>> linvi...@tuxdriver.com  might be all we have.  Be ready.
>
>


Re: [PATCH] vxlan: Update tx_errors statistics if vxlan_build_skb return err.

2016-09-06 Thread David Miller
From: Haishuang Yan 
Date: Sun,  4 Sep 2016 18:52:51 +0800

> If vxlan_build_skb return err < 0, tx_errors should be also increased.
> 
> Signed-off-by: Haishuang Yan 

Applied to net-next.


Re: [PATCH repost net-next] bnx2x: Add support for segmentation of tunnels with outer checksums

2016-09-06 Thread David Miller
From: Yuval Mintz 
Date: Mon, 5 Sep 2016 13:26:33 +0300

> From: Alexander Duyck 
> 
> Signed-off-by: Alexander Duyck 
> Tested-by: Yuval Mintz 

Applied.


Re: [PATCH] ipv6: addrconf: fix dev refcont leak when DAD failed

2016-09-06 Thread David Miller
From: Wei Yongjun 
Date: Mon, 5 Sep 2016 16:06:31 +0800

> In general, when DAD detected IPv6 duplicate address, ifp->state
> will be set to INET6_IFADDR_STATE_ERRDAD and DAD is stopped by a
> delayed work, the call tree should be like this:
> 
> ndisc_recv_ns
>   -> addrconf_dad_failure<- missing ifp put
>  -> addrconf_mod_dad_work
>-> schedule addrconf_dad_work()
>  -> addrconf_dad_stop()  <- missing ifp hold before call it
> 
> addrconf_dad_failure() called with ifp refcont holding but not put.
> addrconf_dad_work() call addrconf_dad_stop() without extra holding
> refcount. This will not cause any issue normally.
> 
> But the race between addrconf_dad_failure() and addrconf_dad_work()
> may cause ifp refcount leak and netdevice can not be unregister,
> dmesg show the following messages:
> 
> IPv6: eth0: IPv6 duplicate address fe80::XX:::XX detected!
> ...
> unregister_netdevice: waiting for eth0 to become free. Usage count = 1
> 
> Cc: sta...@vger.kernel.org
> Fixes: c15b1ccadb32 ("ipv6: move DAD and addrconf_verify processing
> to workqueue")
> Signed-off-by: Wei Yongjun 

Applied and queued up for -stable.


[PATCH] smsc95xx: Remove trailing underscores from macros and uses

2016-09-06 Thread Joe Perches
Make the #defines a bit more sensible to read.

Done with:

$ sed -r -i -e 's/\b([A-Z0-9_][A-Za-z0-9_]+)_\b/\U\1\E/g' \
  drivers/net/usb/smsc95xx.[ch]

and a little editing of the .h file to realign tabstop define values.

There are 3 [RT]x_COE_ defines that were also uppercased.

No change in defconfig objects.

Signed-off-by: Joe Perches 
---
 drivers/net/usb/smsc95xx.c | 198 +--
 drivers/net/usb/smsc95xx.h | 330 ++---
 2 files changed, 264 insertions(+), 264 deletions(-)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 831aa33..c657fe1 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -178,7 +178,7 @@ static int __must_check __smsc95xx_phy_wait_not_busy(struct 
usbnet *dev,
return ret;
}
 
-   if (!(val & MII_BUSY_))
+   if (!(val & MII_BUSY))
return 0;
} while (!time_after(jiffies, start_time + HZ));
 
@@ -204,7 +204,7 @@ static int __smsc95xx_mdio_read(struct net_device *netdev, 
int phy_id, int idx,
/* set the address, index & direction (read from PHY) */
phy_id &= dev->mii.phy_id_mask;
idx &= dev->mii.reg_num_mask;
-   addr = (phy_id << 11) | (idx << 6) | MII_READ_ | MII_BUSY_;
+   addr = (phy_id << 11) | (idx << 6) | MII_READ | MII_BUSY;
ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm);
if (ret < 0) {
netdev_warn(dev->net, "Error writing MII_ADDR\n");
@@ -256,7 +256,7 @@ static void __smsc95xx_mdio_write(struct net_device 
*netdev, int phy_id,
/* set the address, index & direction (write to PHY) */
phy_id &= dev->mii.phy_id_mask;
idx &= dev->mii.reg_num_mask;
-   addr = (phy_id << 11) | (idx << 6) | MII_WRITE_ | MII_BUSY_;
+   addr = (phy_id << 11) | (idx << 6) | MII_WRITE | MII_BUSY;
ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm);
if (ret < 0) {
netdev_warn(dev->net, "Error writing MII_ADDR\n");
@@ -309,12 +309,12 @@ static int __must_check smsc95xx_wait_eeprom(struct 
usbnet *dev)
return ret;
}
 
-   if (!(val & E2P_CMD_BUSY_) || (val & E2P_CMD_TIMEOUT_))
+   if (!(val & E2P_CMD_BUSY) || (val & E2P_CMD_TIMEOUT))
break;
udelay(40);
} while (!time_after(jiffies, start_time + HZ));
 
-   if (val & (E2P_CMD_TIMEOUT_ | E2P_CMD_BUSY_)) {
+   if (val & (E2P_CMD_TIMEOUT | E2P_CMD_BUSY)) {
netdev_warn(dev->net, "EEPROM read operation timeout\n");
return -EIO;
}
@@ -335,7 +335,7 @@ static int __must_check 
smsc95xx_eeprom_confirm_not_busy(struct usbnet *dev)
return ret;
}
 
-   if (!(val & E2P_CMD_BUSY_))
+   if (!(val & E2P_CMD_BUSY))
return 0;
 
udelay(40);
@@ -359,7 +359,7 @@ static int smsc95xx_read_eeprom(struct usbnet *dev, u32 
offset, u32 length,
return ret;
 
for (i = 0; i < length; i++) {
-   val = E2P_CMD_BUSY_ | E2P_CMD_READ_ | (offset & E2P_CMD_ADDR_);
+   val = E2P_CMD_BUSY | E2P_CMD_READ | (offset & E2P_CMD_ADDR);
ret = smsc95xx_write_reg(dev, E2P_CMD, val);
if (ret < 0) {
netdev_warn(dev->net, "Error writing E2P_CMD\n");
@@ -397,7 +397,7 @@ static int smsc95xx_write_eeprom(struct usbnet *dev, u32 
offset, u32 length,
return ret;
 
/* Issue write/erase enable command */
-   val = E2P_CMD_BUSY_ | E2P_CMD_EWEN_;
+   val = E2P_CMD_BUSY | E2P_CMD_EWEN;
ret = smsc95xx_write_reg(dev, E2P_CMD, val);
if (ret < 0) {
netdev_warn(dev->net, "Error writing E2P_DATA\n");
@@ -419,7 +419,7 @@ static int smsc95xx_write_eeprom(struct usbnet *dev, u32 
offset, u32 length,
}
 
/* Send "write" command */
-   val = E2P_CMD_BUSY_ | E2P_CMD_WRITE_ | (offset & E2P_CMD_ADDR_);
+   val = E2P_CMD_BUSY | E2P_CMD_WRITE | (offset & E2P_CMD_ADDR);
ret = smsc95xx_write_reg(dev, E2P_CMD, val);
if (ret < 0) {
netdev_warn(dev->net, "Error writing E2P_CMD\n");
@@ -478,17 +478,17 @@ static void smsc95xx_set_multicast(struct net_device 
*netdev)
 
if (dev->net->flags & IFF_PROMISC) {
netif_dbg(dev, drv, dev->net, "promiscuous mode enabled\n");
-   pdata->mac_cr |= MAC_CR_PRMS_;
-   pdata->mac_cr &= ~(MAC_CR_MCPAS_ | MAC_CR_HPFILT_);
+   pdata->mac_cr |= MAC_CR_PRMS;
+   pdata->mac_cr &= ~(MAC_CR_MCPAS | MAC_CR_HPFILT);
} else if (dev->net->flags & IFF_ALLMULTI) {
netif_dbg(dev, drv, dev->net, "receive all multicast 
enabled\n");
- 

Re: [PATCH net-next] sfc: check MTU against minimum threshold

2016-09-06 Thread Jarod Wilson
On Tue, Sep 06, 2016 at 05:50:00PM +0100, Bert Kenward wrote:
> Reported-by: Ma Yuying 
> Suggested-by: Jarod Wilson 
> Signed-off-by: Bert Kenward 

Works for me, until we can get some dialog going about possible
centralization (or not) of MTU checking, so we don't have this slightly
crazy proliferation of *_MIN_MTU anymore. :)

Reviewed-by: Jarod Wilson 

-- 
Jarod Wilson
ja...@redhat.com



[PATCH v5 6/6] net: stmmac: update the module description of the dwmac-meson driver

2016-09-06 Thread Martin Blumenstingl
The dwmac-meson glue driver supports Meson6 and Meson8 SoCs. Newer SoCs
are supported by the dwmac-meson8b driver.

Signed-off-by: Martin Blumenstingl 
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
index c1bac19..309d995 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
@@ -1,5 +1,5 @@
 /*
- * Amlogic Meson DWMAC glue layer
+ * Amlogic Meson6 and Meson8 DWMAC glue layer
  *
  * Copyright (C) 2014 Beniamino Galvani 
  *
@@ -96,5 +96,5 @@ static struct platform_driver meson6_dwmac_driver = {
 module_platform_driver(meson6_dwmac_driver);
 
 MODULE_AUTHOR("Beniamino Galvani ");
-MODULE_DESCRIPTION("Amlogic Meson DWMAC glue layer");
+MODULE_DESCRIPTION("Amlogic Meson6 and Meson8 DWMAC glue layer");
 MODULE_LICENSE("GPL v2");
-- 
2.9.3



[PATCH v5 2/6] clk: gxbb: expose MPLL2 clock for use by DT

2016-09-06 Thread Martin Blumenstingl
This exposes the MPLL2 clock as this is one of the input clocks of the
ethernet controller's internal mux.

Signed-off-by: Martin Blumenstingl 
---
 drivers/clk/meson/gxbb.h  | 2 +-
 include/dt-bindings/clock/gxbb-clkc.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/meson/gxbb.h b/drivers/clk/meson/gxbb.h
index 217df51..3606e875 100644
--- a/drivers/clk/meson/gxbb.h
+++ b/drivers/clk/meson/gxbb.h
@@ -183,7 +183,7 @@
 /* CLKID_CLK81 */
 #define CLKID_MPLL0  13
 #define CLKID_MPLL1  14
-#define CLKID_MPLL2  15
+/* CLKID_MPLL2 */
 #define CLKID_DDR16
 #define CLKID_DOS17
 #define CLKID_ISA18
diff --git a/include/dt-bindings/clock/gxbb-clkc.h 
b/include/dt-bindings/clock/gxbb-clkc.h
index 7d41864..244ea6e 100644
--- a/include/dt-bindings/clock/gxbb-clkc.h
+++ b/include/dt-bindings/clock/gxbb-clkc.h
@@ -8,6 +8,7 @@
 #define CLKID_CPUCLK   1
 #define CLKID_FCLK_DIV24
 #define CLKID_CLK8112
+#define CLKID_MPLL215
 #define CLKID_ETH  36
 #define CLKID_SD_EMMC_A94
 #define CLKID_SD_EMMC_B95
-- 
2.9.3



Re: [PATCH 0/2] hso: neatening

2016-09-06 Thread David Miller
From: Joe Perches 
Date: Fri,  2 Sep 2016 15:58:00 -0700

> This seems to be the only code in the kernel that uses
> macro defines with a trailing underscore.  Fix that.

Series applied, thanks.


Re: [PATCH v2] net/mlx4_en: protect ring->xdp_prog with rcu_read_lock

2016-09-06 Thread David Miller
From: Brenden Blanco 
Date: Sat,  3 Sep 2016 21:29:58 -0700

> Depending on the preempt mode, the bpf_prog stored in xdp_prog may be
> freed despite the use of call_rcu inside bpf_prog_put. The situation is
> possible when running in PREEMPT_RCU=y mode, for instance, since the rcu
> callback for destroying the bpf prog can run even during the bh handling
> in the mlx4 rx path.
> 
> Several options were considered before this patch was settled on:
 ...
> v2:
> Remove extra rcu_read_lock in mlx4_en_process_rx_cq body
> Annotate xdp_prog with __rcu, and convert all usages to rcu_assign or
> rcu_dereference[_protected] as appropriate.
> Add explicit mutex lock around rcu_assign instead of xchg loop.
> 
> Fixes: d576acf0a22 ("net/mlx4_en: add page recycle to prepare rx ring for tx 
> support")
> Acked-by: Daniel Borkmann 
> Acked-by: Alexei Starovoitov 
> Signed-off-by: Brenden Blanco 

Applied.


Re: [PATCH v3] net: macb: initialize checksum when using checksum offloading

2016-09-06 Thread David Miller
From: Helmut Buchsbaum 
Date: Sun,  4 Sep 2016 18:09:47 +0200

> I'm still struggling to get this fix right..
> 
> Changes since v2:
>  - do not blindly modify SKB contents according to Dave's legitimate
>objection
> 
> Changes since v1:
>  - dropped disabling HW checksum offload for Zynq
>  - initialize checksum similar to net/ethernet/freescale/fec_main.c
> 
> -- >8 --
> MACB/GEM needs the checksum field initialized to 0 to get correct
> results on transmit in all cases, e.g. on Zynq, UDP packets with
> payload <= 2 otherwise contain a wrong checksums.
> 
> Signed-off-by: Helmut Buchsbaum 

Applied.


Re: [net-next PATCH V2] qed: Remove OOM messages

2016-09-06 Thread David Miller
From: Joe Perches 
Date: Sun,  4 Sep 2016 14:24:03 -0700

> These messages are unnecessary as OOM allocation failures already do
> a dump_stack() giving more or less the same information.
> 
> $ size drivers/net/ethernet/qlogic/qed/built-in.o* (defconfig x86-64)
>text  data bss dec hex filename
>  127817 27969   32800  188586   2e0aa 
> drivers/net/ethernet/qlogic/qed/built-in.o.new
>  132474 27969   32800  193243   2f2db 
> drivers/net/ethernet/qlogic/qed/built-in.o.old
> 
> Miscellanea:
> 
> o Change allocs to the generally preferred forms where possible.
> 
> Signed-off-by: Joe Perches 

Applied.


Re: [PATCH net] bnxt_en: Fix TX push operation on ARM64.

2016-09-06 Thread David Miller
From: Michael Chan 
Date: Mon,  5 Sep 2016 01:57:35 -0400

> There is a code path where we are calling __iowrite64_copy() on
> an address that is not 64-bit aligned.  This causes an exception on
> some architectures such as arm64.  Fix that code path by using
> __iowrite32_copy().
> 
> Reported-by: JD Zheng 
> Signed-off-by: Michael Chan 

Applied and queued up for -stable, thanks.


Re: XPS configuration question (on tg3)

2016-09-06 Thread Michal Soltys
On 2016-09-06 22:21, Alexander Duyck wrote:
> On Tue, Sep 6, 2016 at 11:46 AM, Michal Soltys  wrote:
>> Hi,
>>
>> I've been testing different configurations and I didn't manage to get XPS to 
>> "behave" correctly - so I'm probably misunderstanding or forgetting 
>> something. The nic in question (under tg3 driver - BCM5720 and BCM5719 
>> models) was configured to 3 tx and 4 rx queues. 3 irqs were shared (tx and 
>> rx), 1 was unused (this got me scratching my head a bit) and the remaining 
>> one was for the last rx (though due to another bug recently fixed the 4th rx 
>> queue was inconfigurable on receive side). The names were: eth1b-0, 
>> eth1b-txrx-1, eth1b-txrx-2, eth1b-txrx-3, eth1b-rx-4.
>>
>> The XPS was configured as:
>>
>> echo f >/sys/class/net/eth1b/queues/tx-0/xps_cpus
>> echo f0 >/sys/class/net/eth1b/queues/tx-1/xps_cpus
>> echo ff00 >/sys/class/net/eth1b/queues/tx-2/xps_cpus
>>
>> So as far as I understand - cpus 0-3 should be allowed to use tx-0 queue 
>> only, 4-7 tx-1 and 8-15 tx-2.
>>
>> Just in case rx side could get in the way as far as flows go, relevant irqs 
>> were pinned to specific cpus - txrx-1 to 2, txrx-2 to 4, txrx-3 to 10 - 
>> falling into groups defined by the above masks.
>>
>> I tested both with mq and multiq scheduler, essentially either this:
>>
>> qdisc mq 2: root
>> qdisc pfifo_fast 0: parent 2:1 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 
>> 1 1
>> qdisc pfifo_fast 0: parent 2:2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 
>> 1 1
>> qdisc pfifo_fast 0: parent 2:3 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 
>> 1 1
>>
>> or this (for the record, skbaction queue_mapping was behaving correctly with 
>> the one below):
>>
>> qdisc multiq 3: root refcnt 6 bands 3/5
>> qdisc pfifo_fast 31: parent 3:1 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 
>> 1 1
>> qdisc pfifo_fast 32: parent 3:2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 
>> 1 1
>> qdisc pfifo_fast 33: parent 3:3 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 
>> 1 1
>>
>> Now, do I understand correctly, that under the above setup - commands such as
>>
>> taskset 400 nc -p $prt host_ip 12345 > or
>> yancat -i /dev/zero -o t:host_ip:12345 -u 10 -U 10
>>
>> ITOW - pinning simple nc command on cpu #10 (or using a tool that supports 
>> affinity by itself) and sending data to some other host on the net - should 
>> *always* use tx-2 queue ?
>> I also tested variation such as: taskset 400 nc -l -p host_ip 12345 
>> >
>> In my case, what queue it used was basically random (on top of that it 
>> sometimes changed the used queue mid-transfer) what could be easily 
>> confirmed through both /proc/interrupts and tc -s qdisc show. And I'm a bit 
>> at loss now, as I though xps configuration should be absolute.
>>
>> Well, I'd be greatful for some pointers / hints.
> 
> So it sounds like you have everything configured correctly.  The one
> question I would have is if we are certain the CPU pinning is working
> for the application.  You might try using something like perf to
> verify what is running on CPU 10, and what is running on the CPUs that
> the queues are associated with.
> 

I did verify with 'top' in this case. I'll double check tommorow just to
be sure. Other than testing, there was nothing else running on the machine.

> Also after you have configured things you may want to double check and
> verify the xps_cpus value is still set.  I know under some
> circumstances the value can be reset by a device driver if the number
> of queues changes, or if the interface toggles between being
> administratively up/down.

Hmm, none of this was happening during tests.

Are there any other circumstances where xps settings could be ignored or
changed during the test (that is during the actual transfer, not between
separate attempts) ?

One thing I'm a bit afraid is that kernel was not exactly the newest
(3.16), maybe I'm missing some crucial fixes, though xps was added much
earlier than that. Either way, I'll try to redo tests with current
kernel tommorow.



Re: [RFC Patch net-next 2/6] net_sched: introduce tcf_hash_replace()

2016-09-06 Thread Cong Wang
On Tue, Sep 6, 2016 at 5:52 AM, Jamal Hadi Salim  wrote:
> On 16-09-02 01:57 AM, Cong Wang wrote:
>
>> Cc: Jamal Hadi Salim 
>> Signed-off-by: Cong Wang 
>> ---
>>  include/net/act_api.h |  2 ++
>>  net/sched/act_api.c   | 20 
>>  2 files changed, 22 insertions(+)
>>
>> diff --git a/include/net/act_api.h b/include/net/act_api.h
>> index 82f3c91..a374bab 100644
>> --- a/include/net/act_api.h
>
>
>>
>> +void tcf_hash_replace(struct tc_action_net *tn, struct tc_action **old,
>> + struct tc_action *new, int bind)
>> +{
>> +   struct tcf_hashinfo *hinfo = tn->hinfo;
>> +   unsigned int h = tcf_hash(new->tcfa_index, hinfo->hmask);
>> +
>
>
> WWhy do you need to recreate the index?
> Old index was fine since this is just a replacement..

A new index is possible created by tcf_hash_create(), but later
overwritten by tcf_hash_copy(). I know this is a bit ugly, so
feel free to suggest any better API here.


>
> The rest of the patches seem fine - will let Eric comment on the
> mirred.
>
> Note: I am going to still push forward with skbmod action and I think
> so should the new tunnel action code i.e we make them independent.
> I'd like to switch to this when we think it is stable.

You don't have to rebase or change, I will take care of it because they
will probably be merged before this patchset. At least I can hold on
this for a while to let that happen. ;)

Thanks.


Re: PROBLEM: TPROXY and DNAT broken (bisected to 079096f103fa)

2016-09-06 Thread Florian Westphal
Brandon Cazander  wrote:

[ cc netfilter-devel ]

> Sorry to resurrect this so much later—I just got back from holidays and this 
> was still on my desk.
> 
> Will anyone have another chance to look at this? It appears that the DIVERT 
> rule is not working in our case, and I wonder if it is possible to fix the 
> TPROXY target as well as the socket target fix that Florian provided.

Are there reproducer instructions available for this?

I don't see how TPROXY can be 'fixed' because when skb (tcp syn) is in
mangle PREROUTING nat transformation(s) have not been set up (yet).

So ip header addresses are all we have.

Only the ack (that finishes 3whs) or retransmitted syns will
have the post-nat address info available.

Ack should work fine with (changed) -m socket since the
socket should already be in the main ehash table.

Syn should also work just fine because Erics changes
should not affect initial listener lookup done by TPROXY.

> It appears as though nobody else has encountered this regression, so I can 
> appreciate that it comes up pretty low on the priority list. If it is not 
> realistic that this will be looked at further, then we will have to look at 
> replacing TPROXY.

If you already need NAT anyway you can also use -j REDIRECT (or exclude
tproxied packets from nat).


Re: [PATCH] lan78xx: mark symbols static where possible

2016-09-06 Thread David Miller
From: Baoyou Xie 
Date: Tue,  6 Sep 2016 16:19:02 +0800

> We get a few warnings when building kernel with W=1:
> drivers/net/usb/lan78xx.c:1182:6: warning: no previous prototype for 
> 'lan78xx_defer_kevent' [-Wmissing-prototypes]
> drivers/net/usb/lan78xx.c:1409:5: warning: no previous prototype for 
> 'lan78xx_nway_reset' [-Wmissing-prototypes]
> drivers/net/usb/lan78xx.c:2000:5: warning: no previous prototype for 
> 'lan78xx_set_mac_addr' [-Wmissing-prototypes]
> 
> 
> In fact, these functions are only used in the file in which they are
> declared and don't need a declaration, but can be made static.
> so this patch marks these functions with 'static'.
> 
> Signed-off-by: Baoyou Xie 

Applied.


Re: [PATCH] net: arc_emac: mark arc_mdio_reset() static

2016-09-06 Thread David Miller
From: Baoyou Xie 
Date: Tue,  6 Sep 2016 16:21:56 +0800

> We get 1 warning when building kernel with W=1:
> drivers/net/ethernet/arc/emac_mdio.c:107:5: warning: no previous prototype 
> for 'arc_mdio_reset' [-Wmissing-prototypes]
> 
> In fact, this function is only used in the file in which it is
> declared and don't need a declaration, but can be made static.
> so this patch marks this function with 'static'.
> 
> Signed-off-by: Baoyou Xie 

Applied.


Re: [PATCH] vmxnet3: mark vmxnet3_rq_destroy_all_rxdataring() static

2016-09-06 Thread David Miller
From: Baoyou Xie 
Date: Tue,  6 Sep 2016 16:11:59 +0800

> We get 1 warning when building kernel with W=1:
> drivers/net/vmxnet3/vmxnet3_drv.c:1643:1: warning: no previous prototype for 
> 'vmxnet3_rq_destroy_all_rxdataring' [-Wmissing-prototypes]
> 
> In fact, this function is only used in the file in which it is
> declared and don't need a declaration, but can be made static.
> so this patch marks this function with 'static'.
> 
> Signed-off-by: Baoyou Xie 

This doesn't apply cleanly to net-next.


[PATCH 1/2] lan78xx: Remove locally defined trailing underscores from defines and uses

2016-09-06 Thread Joe Perches
Macro defines with trailing underscore are hard to read.

These locally defined ones with trailing underscores are all unique
without the trailing underscore, so remove them from the defines and uses.

Global defines that start with LAN88XX_ that are excluded.

Done with:

$ perl -p -i -e 's/\b(?!LAN88XX_)([A-Z0-9_][A-Za-z0-9_]+)_\b/\U\1\E/g' \
  drivers/net/usb/lan78xx.[ch]

and some editing to realign columns in the .h file.

No change in defconfig object.

Signed-off-by: Joe Perches 
---
 drivers/net/usb/lan78xx.c |  340 +++
 drivers/net/usb/lan78xx.h | 1068 ++---
 2 files changed, 704 insertions(+), 704 deletions(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 432b8a3..b6d6d0f 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -548,7 +548,7 @@ static int lan78xx_phy_wait_not_busy(struct lan78xx_net 
*dev)
if (unlikely(ret < 0))
return -EIO;
 
-   if (!(val & MII_ACC_MII_BUSY_))
+   if (!(val & MII_ACC_MII_BUSY))
return 0;
} while (!time_after(jiffies, start_time + HZ));
 
@@ -559,13 +559,13 @@ static inline u32 mii_access(int id, int index, int read)
 {
u32 ret;
 
-   ret = ((u32)id << MII_ACC_PHY_ADDR_SHIFT_) & MII_ACC_PHY_ADDR_MASK_;
-   ret |= ((u32)index << MII_ACC_MIIRINDA_SHIFT_) & MII_ACC_MIIRINDA_MASK_;
+   ret = ((u32)id << MII_ACC_PHY_ADDR_SHIFT) & MII_ACC_PHY_ADDR_MASK;
+   ret |= ((u32)index << MII_ACC_MIIRINDA_SHIFT) & MII_ACC_MIIRINDA_MASK;
if (read)
-   ret |= MII_ACC_MII_READ_;
+   ret |= MII_ACC_MII_READ;
else
-   ret |= MII_ACC_MII_WRITE_;
-   ret |= MII_ACC_MII_BUSY_;
+   ret |= MII_ACC_MII_WRITE;
+   ret |= MII_ACC_MII_BUSY;
 
return ret;
 }
@@ -581,13 +581,13 @@ static int lan78xx_wait_eeprom(struct lan78xx_net *dev)
if (unlikely(ret < 0))
return -EIO;
 
-   if (!(val & E2P_CMD_EPC_BUSY_) ||
-   (val & E2P_CMD_EPC_TIMEOUT_))
+   if (!(val & E2P_CMD_EPC_BUSY) ||
+   (val & E2P_CMD_EPC_TIMEOUT))
break;
usleep_range(40, 100);
} while (!time_after(jiffies, start_time + HZ));
 
-   if (val & (E2P_CMD_EPC_TIMEOUT_ | E2P_CMD_EPC_BUSY_)) {
+   if (val & (E2P_CMD_EPC_TIMEOUT | E2P_CMD_EPC_BUSY)) {
netdev_warn(dev->net, "EEPROM read operation timeout");
return -EIO;
}
@@ -606,7 +606,7 @@ static int lan78xx_eeprom_confirm_not_busy(struct 
lan78xx_net *dev)
if (unlikely(ret < 0))
return -EIO;
 
-   if (!(val & E2P_CMD_EPC_BUSY_))
+   if (!(val & E2P_CMD_EPC_BUSY))
return 0;
 
usleep_range(40, 100);
@@ -629,8 +629,8 @@ static int lan78xx_read_raw_eeprom(struct lan78xx_net *dev, 
u32 offset,
 */
ret = lan78xx_read_reg(dev, HW_CFG, );
saved = val;
-   if (dev->chipid == ID_REV_CHIP_ID_7800_) {
-   val &= ~(HW_CFG_LED1_EN_ | HW_CFG_LED0_EN_);
+   if (dev->chipid == ID_REV_CHIP_ID_7800) {
+   val &= ~(HW_CFG_LED1_EN | HW_CFG_LED0_EN);
ret = lan78xx_write_reg(dev, HW_CFG, val);
}
 
@@ -639,8 +639,8 @@ static int lan78xx_read_raw_eeprom(struct lan78xx_net *dev, 
u32 offset,
return retval;
 
for (i = 0; i < length; i++) {
-   val = E2P_CMD_EPC_BUSY_ | E2P_CMD_EPC_CMD_READ_;
-   val |= (offset & E2P_CMD_EPC_ADDR_MASK_);
+   val = E2P_CMD_EPC_BUSY | E2P_CMD_EPC_CMD_READ;
+   val |= (offset & E2P_CMD_EPC_ADDR_MASK);
ret = lan78xx_write_reg(dev, E2P_CMD, val);
if (unlikely(ret < 0)) {
retval = -EIO;
@@ -663,7 +663,7 @@ static int lan78xx_read_raw_eeprom(struct lan78xx_net *dev, 
u32 offset,
 
retval = 0;
 exit:
-   if (dev->chipid == ID_REV_CHIP_ID_7800_)
+   if (dev->chipid == ID_REV_CHIP_ID_7800)
ret = lan78xx_write_reg(dev, HW_CFG, saved);
 
return retval;
@@ -697,8 +697,8 @@ static int lan78xx_write_raw_eeprom(struct lan78xx_net 
*dev, u32 offset,
 */
ret = lan78xx_read_reg(dev, HW_CFG, );
saved = val;
-   if (dev->chipid == ID_REV_CHIP_ID_7800_) {
-   val &= ~(HW_CFG_LED1_EN_ | HW_CFG_LED0_EN_);
+   if (dev->chipid == ID_REV_CHIP_ID_7800) {
+   val &= ~(HW_CFG_LED1_EN | HW_CFG_LED0_EN);
ret = lan78xx_write_reg(dev, HW_CFG, val);
}
 
@@ -707,7 +707,7 @@ static int lan78xx_write_raw_eeprom(struct lan78xx_net 
*dev, u32 offset,
goto exit;
 
/* Issue write/erase enable command */
-   val = E2P_CMD_EPC_BUSY_ | E2P_CMD_EPC_CMD_EWEN_;
+   val = 

RE: [PATCH 0/2] lan78xx: Remove trailing underscores from macros

2016-09-06 Thread Woojung.Huh
> Joe Perches (2):
>   lan78xx: Remove locally defined trailing underscores from defines and uses
>   microchipphy.h and uses: Remove trailing underscores from defines and
> uses
> 
>  drivers/net/phy/microchip.c  |4 +-
>  drivers/net/usb/lan78xx.c|  368 +++
>  drivers/net/usb/lan78xx.h| 1068 +-
> 
>  include/linux/microchipphy.h |   72 +--
>  4 files changed, 756 insertions(+), 756 deletions(-)

Because there is no specific rule how to name defines, I'm not sure it is worth 
to change 1000+ lines.
It may be better to set guideline for new submissions.

Welcome any comments.


Re: [PATCH] net: hns: declare function as static

2016-09-06 Thread David Miller
From: Kefeng Wang 
Date: Tue, 6 Sep 2016 19:53:11 +0800

> Declare function as static to kill warning about missing-prototypes.
> 
> Cc: Yisen Zhuang 
> Cc: Kejian Yan 
> Signed-off-by: Kefeng Wang 
 ...
> @@ -73,7 +73,7 @@ static struct ring_pair_cb *hns_ae_get_ring_pair(struct 
> hnae_queue *q)
>   return container_of(q, struct ring_pair_cb, q);
>  }
>  
> -struct hnae_handle *hns_ae_get_handle(struct hnae_ae_dev *dev,
> +static struct hnae_handle *hns_ae_get_handle(struct hnae_ae_dev *dev,
> u32 port_id)

You have to adjust the indentation of the arguments on the following lines
if you change where the openning parenthesis is.  They must start exactly
at the column folling that openning parenthesis.



Re: [RFC Patch net-next 1/6] net_sched: use RCU for action hash table

2016-09-06 Thread Cong Wang
On Tue, Sep 6, 2016 at 5:47 AM, Jamal Hadi Salim  wrote:
> On 16-09-02 01:57 AM, Cong Wang wrote:
>>
>> We already free tc actions in a RCU callback, so here
>> we just need to convert the hash table operations to
>> RCU API's.
>>
>> Cc: Jamal Hadi Salim 
>> Signed-off-by: Cong Wang 
>
>
> This one stands on its own merit, no?

Yes, I think so. I think it is fine to carry it in this patchset too.


> So:
> Acked-by: Jamal Hadi Salim 
>
>

Thanks.


Re: [RFC PATCH v2 1/6] proc: Reduce cache miss in {snmp,netstat}_seq_show

2016-09-06 Thread David Miller
From: Jia He 
Date: Tue,  6 Sep 2016 10:30:04 +0800

> +#define MAX(a, b) ((u32)(a) >= (u32)(b) ? (a) : (b))

Please do not define private min/max macros, use the existing max_t()
or similar as needed.


[PATCH 2/2] microchipphy.h and uses: Remove trailing underscores from defines and uses

2016-09-06 Thread Joe Perches
Macro defines with trailing underscore are hard to read.

These uses with trailing underscores are all unique to this .h file,
so remove them from the defines and uses.

Done with:

$ sed -r -i -e 's/\b([A-Z0-9_][A-Za-z0-9_]+)_\b/\U\1\E/g' \
  include/linux/microchipphy.h \
  drivers/net/usb/lan78xx.c \
  drivers/net/phy/microchip.c

and some editing to realign columns in the .h file.

No change in defconfig objects.

Signed-off-by: Joe Perches 
---
 drivers/net/phy/microchip.c  |  4 +--
 drivers/net/usb/lan78xx.c| 28 -
 include/linux/microchipphy.h | 72 ++--
 3 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/drivers/net/phy/microchip.c b/drivers/net/phy/microchip.c
index 15f8206..d8ea811 100644
--- a/drivers/net/phy/microchip.c
+++ b/drivers/net/phy/microchip.c
@@ -39,8 +39,8 @@ static int lan88xx_phy_config_intr(struct phy_device *phydev)
rc = phy_write(phydev, LAN88XX_INT_MASK, 0x7FFF);
rc = phy_read(phydev, LAN88XX_INT_STS);
rc = phy_write(phydev, LAN88XX_INT_MASK,
-  LAN88XX_INT_MASK_MDINTPIN_EN_ |
-  LAN88XX_INT_MASK_LINK_CHANGE_);
+  LAN88XX_INT_MASK_MDINTPIN_EN |
+  LAN88XX_INT_MASK_LINK_CHANGE);
} else {
rc = phy_write(phydev, LAN88XX_INT_MASK, 0);
}
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index b6d6d0f..5e870cc 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1457,27 +1457,27 @@ static void lan78xx_set_mdix_status(struct net_device 
*net, __u8 mdix_ctrl)
phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS,
  LAN88XX_EXT_PAGE_SPACE_1);
buf = phy_read(phydev, LAN88XX_EXT_MODE_CTRL);
-   buf &= ~LAN88XX_EXT_MODE_CTRL_MDIX_MASK_;
+   buf &= ~LAN88XX_EXT_MODE_CTRL_MDIX_MASK;
phy_write(phydev, LAN88XX_EXT_MODE_CTRL,
- buf | LAN88XX_EXT_MODE_CTRL_MDI_);
+ buf | LAN88XX_EXT_MODE_CTRL_MDI);
phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS,
  LAN88XX_EXT_PAGE_SPACE_0);
} else if (mdix_ctrl == ETH_TP_MDI_X) {
phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS,
  LAN88XX_EXT_PAGE_SPACE_1);
buf = phy_read(phydev, LAN88XX_EXT_MODE_CTRL);
-   buf &= ~LAN88XX_EXT_MODE_CTRL_MDIX_MASK_;
+   buf &= ~LAN88XX_EXT_MODE_CTRL_MDIX_MASK;
phy_write(phydev, LAN88XX_EXT_MODE_CTRL,
- buf | LAN88XX_EXT_MODE_CTRL_MDI_X_);
+ buf | LAN88XX_EXT_MODE_CTRL_MDI_X);
phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS,
  LAN88XX_EXT_PAGE_SPACE_0);
} else if (mdix_ctrl == ETH_TP_MDI_AUTO) {
phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS,
  LAN88XX_EXT_PAGE_SPACE_1);
buf = phy_read(phydev, LAN88XX_EXT_MODE_CTRL);
-   buf &= ~LAN88XX_EXT_MODE_CTRL_MDIX_MASK_;
+   buf &= ~LAN88XX_EXT_MODE_CTRL_MDIX_MASK;
phy_write(phydev, LAN88XX_EXT_MODE_CTRL,
- buf | LAN88XX_EXT_MODE_CTRL_AUTO_MDIX_);
+ buf | LAN88XX_EXT_MODE_CTRL_AUTO_MDIX);
phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS,
  LAN88XX_EXT_PAGE_SPACE_0);
}
@@ -1499,14 +1499,14 @@ static int lan78xx_get_settings(struct net_device *net, 
struct ethtool_cmd *cmd)
 
buf = lan78xx_get_mdix_status(net);
 
-   buf &= LAN88XX_EXT_MODE_CTRL_MDIX_MASK_;
-   if (buf == LAN88XX_EXT_MODE_CTRL_AUTO_MDIX_) {
+   buf &= LAN88XX_EXT_MODE_CTRL_MDIX_MASK;
+   if (buf == LAN88XX_EXT_MODE_CTRL_AUTO_MDIX) {
cmd->eth_tp_mdix = ETH_TP_MDI_AUTO;
cmd->eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO;
-   } else if (buf == LAN88XX_EXT_MODE_CTRL_MDI_) {
+   } else if (buf == LAN88XX_EXT_MODE_CTRL_MDI) {
cmd->eth_tp_mdix = ETH_TP_MDI;
cmd->eth_tp_mdix_ctrl = ETH_TP_MDI;
-   } else if (buf == LAN88XX_EXT_MODE_CTRL_MDI_X_) {
+   } else if (buf == LAN88XX_EXT_MODE_CTRL_MDI_X) {
cmd->eth_tp_mdix = ETH_TP_MDI_X;
cmd->eth_tp_mdix_ctrl = ETH_TP_MDI_X;
}
@@ -1815,7 +1815,7 @@ static void lan78xx_link_status_change(struct net_device 
*net)
if (!phydev->autoneg && (phydev->speed == 100)) {
/* disable phy interrupt */
temp = phy_read(phydev, LAN88XX_INT_MASK);
-   temp &= ~LAN88XX_INT_MASK_MDINTPIN_EN_;
+   temp &= ~LAN88XX_INT_MASK_MDINTPIN_EN;
ret = phy_write(phydev, LAN88XX_INT_MASK, temp);
 
temp = phy_read(phydev, MII_BMCR);
@@ -1829,7 +1829,7 @@ 

[PATCH 0/2] lan78xx: Remove trailing underscores from macros

2016-09-06 Thread Joe Perches
Joe Perches (2):
  lan78xx: Remove locally defined trailing underscores from defines and uses
  microchipphy.h and uses: Remove trailing underscores from defines and uses

 drivers/net/phy/microchip.c  |4 +-
 drivers/net/usb/lan78xx.c|  368 +++
 drivers/net/usb/lan78xx.h| 1068 +-
 include/linux/microchipphy.h |   72 +--
 4 files changed, 756 insertions(+), 756 deletions(-)

-- 
2.10.0.rc2.1.g053435c



Re: [PATCH v4 1/4] soc: qcom: wcnss_ctrl: Stub wcnss_ctrl API

2016-09-06 Thread Marcel Holtmann
Hi Bjorn,

> Stub the wcnss_ctrl API to allow compile testing wcnss function drivers.
> 
> Cc: Marcel Holtmann 
> Signed-off-by: Bjorn Andersson 
> ---
> 
> There are no other pending changes colliding with this, so if Andy is okay 
> with
> this it could be merged through Kalle's tree - together with the other 
> patches.
> 
> Marcel, with this applied we can drop the depends on QCOM_SMD from the
> btqcomsmd driver as well.

sounds great. As soon as this lands in net-next, then please send a patch to 
remove the dependency. I will pull in net-next into bluetooth-next then.

Regards

Marcel



[PATCH] lan78xx: mark symbols static where possible

2016-09-06 Thread Baoyou Xie
We get a few warnings when building kernel with W=1:
drivers/net/usb/lan78xx.c:1182:6: warning: no previous prototype for 
'lan78xx_defer_kevent' [-Wmissing-prototypes]
drivers/net/usb/lan78xx.c:1409:5: warning: no previous prototype for 
'lan78xx_nway_reset' [-Wmissing-prototypes]
drivers/net/usb/lan78xx.c:2000:5: warning: no previous prototype for 
'lan78xx_set_mac_addr' [-Wmissing-prototypes]


In fact, these functions are only used in the file in which they are
declared and don't need a declaration, but can be made static.
so this patch marks these functions with 'static'.

Signed-off-by: Baoyou Xie 
---
 drivers/net/usb/lan78xx.c | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 6a9d474..8c467a5 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1179,7 +1179,7 @@ static int lan78xx_link_reset(struct lan78xx_net *dev)
  * NOTE:  annoying asymmetry:  if it's active, schedule_work() fails,
  * but tasklet_schedule() doesn't. hope the failure is rare.
  */
-void lan78xx_defer_kevent(struct lan78xx_net *dev, int work)
+static void lan78xx_defer_kevent(struct lan78xx_net *dev, int work)
 {
set_bit(work, >flags);
if (!schedule_delayed_work(>wq, 0))
@@ -1406,7 +1406,7 @@ static u32 lan78xx_get_link(struct net_device *net)
return net->phydev->link;
 }
 
-int lan78xx_nway_reset(struct net_device *net)
+static int lan78xx_nway_reset(struct net_device *net)
 {
return phy_start_aneg(net->phydev);
 }
@@ -1997,7 +1997,7 @@ static int lan78xx_change_mtu(struct net_device *netdev, 
int new_mtu)
return 0;
 }
 
-int lan78xx_set_mac_addr(struct net_device *netdev, void *p)
+static int lan78xx_set_mac_addr(struct net_device *netdev, void *p)
 {
struct lan78xx_net *dev = netdev_priv(netdev);
struct sockaddr *addr = p;
@@ -2371,7 +2371,7 @@ static void lan78xx_terminate_urbs(struct lan78xx_net 
*dev)
remove_wait_queue(_wakeup, );
 }
 
-int lan78xx_stop(struct net_device *net)
+static int lan78xx_stop(struct net_device *net)
 {
struct lan78xx_net  *dev = netdev_priv(net);
 
@@ -2533,7 +2533,8 @@ static void lan78xx_queue_skb(struct sk_buff_head *list,
entry->state = state;
 }
 
-netdev_tx_t lan78xx_start_xmit(struct sk_buff *skb, struct net_device *net)
+static netdev_tx_t
+lan78xx_start_xmit(struct sk_buff *skb, struct net_device *net)
 {
struct lan78xx_net *dev = netdev_priv(net);
struct sk_buff *skb2 = NULL;
@@ -2562,7 +2563,8 @@ netdev_tx_t lan78xx_start_xmit(struct sk_buff *skb, 
struct net_device *net)
return NETDEV_TX_OK;
 }
 
-int lan78xx_get_endpoints(struct lan78xx_net *dev, struct usb_interface *intf)
+static int
+lan78xx_get_endpoints(struct lan78xx_net *dev, struct usb_interface *intf)
 {
int tmp;
struct usb_host_interface *alt = NULL;
@@ -2700,7 +2702,7 @@ static void lan78xx_rx_csum_offload(struct lan78xx_net 
*dev,
}
 }
 
-void lan78xx_skb_return(struct lan78xx_net *dev, struct sk_buff *skb)
+static void lan78xx_skb_return(struct lan78xx_net *dev, struct sk_buff *skb)
 {
int status;
 
@@ -3285,7 +3287,7 @@ static void lan78xx_disconnect(struct usb_interface *intf)
usb_put_dev(udev);
 }
 
-void lan78xx_tx_timeout(struct net_device *net)
+static void lan78xx_tx_timeout(struct net_device *net)
 {
struct lan78xx_net *dev = netdev_priv(net);
 
@@ -3605,7 +3607,7 @@ static int lan78xx_set_suspend(struct lan78xx_net *dev, 
u32 wol)
return 0;
 }
 
-int lan78xx_suspend(struct usb_interface *intf, pm_message_t message)
+static int lan78xx_suspend(struct usb_interface *intf, pm_message_t message)
 {
struct lan78xx_net *dev = usb_get_intfdata(intf);
struct lan78xx_priv *pdata = (struct lan78xx_priv *)(dev->data[0]);
@@ -3701,7 +3703,7 @@ out:
return ret;
 }
 
-int lan78xx_resume(struct usb_interface *intf)
+static int lan78xx_resume(struct usb_interface *intf)
 {
struct lan78xx_net *dev = usb_get_intfdata(intf);
struct sk_buff *skb;
@@ -3768,7 +3770,7 @@ int lan78xx_resume(struct usb_interface *intf)
return 0;
 }
 
-int lan78xx_reset_resume(struct usb_interface *intf)
+static int lan78xx_reset_resume(struct usb_interface *intf)
 {
struct lan78xx_net *dev = usb_get_intfdata(intf);
 
-- 
2.7.4



[PATCH] vmxnet3: mark vmxnet3_rq_destroy_all_rxdataring() static

2016-09-06 Thread Baoyou Xie
We get 1 warning when building kernel with W=1:
drivers/net/vmxnet3/vmxnet3_drv.c:1643:1: warning: no previous prototype for 
'vmxnet3_rq_destroy_all_rxdataring' [-Wmissing-prototypes]

In fact, this function is only used in the file in which it is
declared and don't need a declaration, but can be made static.
so this patch marks this function with 'static'.

Signed-off-by: Baoyou Xie 
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index c68fe49..fc68dd4 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1639,7 +1639,7 @@ static void vmxnet3_rq_destroy(struct vmxnet3_rx_queue 
*rq,
}
 }
 
-void
+static void
 vmxnet3_rq_destroy_all_rxdataring(struct vmxnet3_adapter *adapter)
 {
int i;
-- 
2.7.4



[PATCH] net: arc_emac: mark arc_mdio_reset() static

2016-09-06 Thread Baoyou Xie
We get 1 warning when building kernel with W=1:
drivers/net/ethernet/arc/emac_mdio.c:107:5: warning: no previous prototype for 
'arc_mdio_reset' [-Wmissing-prototypes]

In fact, this function is only used in the file in which it is
declared and don't need a declaration, but can be made static.
so this patch marks this function with 'static'.

Signed-off-by: Baoyou Xie 
---
 drivers/net/ethernet/arc/emac_mdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/arc/emac_mdio.c 
b/drivers/net/ethernet/arc/emac_mdio.c
index 058460b..a22403c 100644
--- a/drivers/net/ethernet/arc/emac_mdio.c
+++ b/drivers/net/ethernet/arc/emac_mdio.c
@@ -104,7 +104,7 @@ static int arc_mdio_write(struct mii_bus *bus, int phy_addr,
  * @bus: points to the mii_bus structure
  * Description: reset the MII bus
  */
-int arc_mdio_reset(struct mii_bus *bus)
+static int arc_mdio_reset(struct mii_bus *bus)
 {
struct arc_emac_priv *priv = bus->priv;
struct arc_emac_mdio_bus_data *data = >bus_data;
-- 
2.7.4



Re: [PATCH iproute2] ip link: fix up bond/bridge slave id

2016-09-06 Thread Nikolay Aleksandrov

> On Sep 6, 2016, at 10:44 AM, Hangbin Liu  wrote:
> 
> Signed-off-by: Hangbin Liu 
> ---
> ip/iplink_bond_slave.c   | 2 +-
> ip/iplink_bridge_slave.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/ip/iplink_bond_slave.c b/ip/iplink_bond_slave.c
> index 9c60dea..8a3104b 100644
> --- a/ip/iplink_bond_slave.c
> +++ b/ip/iplink_bond_slave.c
> @@ -130,7 +130,7 @@ static void bond_slave_print_help(struct link_util *lu, 
> int argc, char **argv,
> }
> 
> struct link_util bond_slave_link_util = {
> - .id = "bond",
> + .id = "bond_slave",
>   .maxattr= IFLA_BOND_SLAVE_MAX,
>   .print_opt  = bond_slave_print_opt,
>   .parse_opt  = bond_slave_parse_opt,
> diff --git a/ip/iplink_bridge_slave.c b/ip/iplink_bridge_slave.c
> index a44d4e4..58563e0 100644
> --- a/ip/iplink_bridge_slave.c
> +++ b/ip/iplink_bridge_slave.c
> @@ -293,7 +293,7 @@ static void bridge_slave_print_help(struct link_util *lu, 
> int argc, char **argv,
> }
> 
> struct link_util bridge_slave_link_util = {
> - .id = "bridge",
> + .id = "bridge_slave",
>   .maxattr= IFLA_BRPORT_MAX,
>   .print_opt  = bridge_slave_print_opt,
>   .parse_opt  = bridge_slave_parse_opt,
> -- 
> 2.5.5
> 

NAK, this will actually force the iplink slave logic to always lookup the 
linkutil symbol. Please check iplink.c and how slave linkutil structs are found.
The first part of the “bridge/bond_slave” is extracted from the requested type 
(e.g. bond_slave -> bond) and is
looked up with the slave flag set to true, in case that fails the symbol 
(%s_slave_link_util) is looked up and added to the
linkutil list for later use, but in this case we can end up with linkutil list 
head pointing to itself (the same slave link util added twice if f.e. we have
more than 1 slave of that type) and since it doesn’t match - we’ll loop forever.

Just try adding 2 or more bond slaves with this patch and then do:
ip -d link show





RE: [PATCH -next v2] net: hns: fix return value check in hns_dsaf_get_cfg()

2016-09-06 Thread Salil Mehta


> -Original Message-
> From: David Miller [mailto:da...@davemloft.net]
> Sent: Monday, September 05, 2016 8:43 PM
> To: Salil Mehta
> Cc: weiyj...@163.com; Zhuangyuzeng (Yisen); Yankejian (Hackim Yim);
> yongjun_...@trendmicro.com.cn; netdev@vger.kernel.org
> Subject: Re: [PATCH -next v2] net: hns: fix return value check in
> hns_dsaf_get_cfg()
> 
> From: Salil Mehta 
> Date: Mon, 5 Sep 2016 14:20:33 +
> 
> > This patch will conflict with Doug Ledford's hns-roce's HNS driver.
> > This might lead to problems later during this merge window of 4.9.
> 
> You don't need to say this three times.
Sorry about this
> 
> These changes will not be reverted, instead the conflicts will need
> to simply be resolved during the merges just like any other conflict
> that ever happens in our trees.
Fine, got your point.


[v11, 1/8] dt: bindings: update Freescale DCFG compatible

2016-09-06 Thread Yangbo Lu
Update Freescale DCFG compatible with 'fsl,-dcfg' instead
of 'fsl,ls1021a-dcfg' to include more chips such as ls1021a,
ls1043a, and ls2080a.

Signed-off-by: Yangbo Lu 
Acked-by: Rob Herring 
Signed-off-by: Scott Wood 
---
Changes for v8:
- Added this patch
Changes for v9:
- Added a list for the possible compatibles
Changes for v10:
- None
Changes for v11:
- Added 'Acked-by: Rob Herring'
- Updated commit message by Scott
---
 Documentation/devicetree/bindings/arm/fsl.txt | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/fsl.txt 
b/Documentation/devicetree/bindings/arm/fsl.txt
index dbbc095..713c1ae 100644
--- a/Documentation/devicetree/bindings/arm/fsl.txt
+++ b/Documentation/devicetree/bindings/arm/fsl.txt
@@ -119,7 +119,11 @@ Freescale DCFG
 configuration and status for the device. Such as setting the secondary
 core start address and release the secondary core from holdoff and startup.
   Required properties:
-  - compatible: should be "fsl,ls1021a-dcfg"
+  - compatible: should be "fsl,-dcfg"
+Possible compatibles:
+   "fsl,ls1021a-dcfg"
+   "fsl,ls1043a-dcfg"
+   "fsl,ls2080a-dcfg"
   - reg : should contain base address and length of DCFG memory-mapped 
registers
 
 Example:
-- 
2.1.0.27.g96db324



[v11, 4/8] powerpc/fsl: move mpc85xx.h to include/linux/fsl

2016-09-06 Thread Yangbo Lu
Move mpc85xx.h to include/linux/fsl and rename it to svr.h as a common
header file.  This SVR numberspace is used on some ARM chips as well as
PPC, and even to check for a PPC SVR multi-arch drivers would otherwise
need to ifdef the header inclusion and all references to the SVR symbols.

Signed-off-by: Yangbo Lu 
Acked-by: Wolfram Sang 
Acked-by: Stephen Boyd 
Acked-by: Joerg Roedel 
[scottwood: update description]
Signed-off-by: Scott Wood 
---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- Changed to Move mpc85xx.h to include/linux/fsl/
- Adjusted '#include ' position in file
Changes for v6:
- None
Changes for v7:
- Added 'Acked-by: Wolfram Sang' for I2C part
- Also applied to arch/powerpc/kernel/cpu_setup_fsl_booke.S
Changes for v8:
- Added 'Acked-by: Stephen Boyd' for clk part
- Added 'Acked-by: Scott Wood'
- Added 'Acked-by: Joerg Roedel' for iommu part
Changes for v9:
- None
Changes for v10:
- None
Changes for v11:
- Updated description by Scott
---
 arch/powerpc/kernel/cpu_setup_fsl_booke.S | 2 +-
 arch/powerpc/sysdev/fsl_pci.c | 2 +-
 drivers/clk/clk-qoriq.c   | 3 +--
 drivers/i2c/busses/i2c-mpc.c  | 2 +-
 drivers/iommu/fsl_pamu.c  | 3 +--
 drivers/net/ethernet/freescale/gianfar.c  | 2 +-
 arch/powerpc/include/asm/mpc85xx.h => include/linux/fsl/svr.h | 4 ++--
 7 files changed, 8 insertions(+), 10 deletions(-)
 rename arch/powerpc/include/asm/mpc85xx.h => include/linux/fsl/svr.h (97%)

diff --git a/arch/powerpc/kernel/cpu_setup_fsl_booke.S 
b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
index 462aed9..2b0284e 100644
--- a/arch/powerpc/kernel/cpu_setup_fsl_booke.S
+++ b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
@@ -13,13 +13,13 @@
  *
  */
 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 _GLOBAL(__e500_icache_setup)
mfspr   r0, SPRN_L1CSR1
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 0ef9df4..0fd1895 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -37,7 +38,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
index 58566a17..4b6c438 100644
--- a/drivers/clk/clk-qoriq.c
+++ b/drivers/clk/clk-qoriq.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1149,8 +1150,6 @@ bad_args:
 }
 
 #ifdef CONFIG_PPC
-#include 
-
 static const u32 a4510_svrs[] __initconst = {
(SVR_P2040 << 8) | 0x10,/* P2040 1.0 */
(SVR_P2040 << 8) | 0x11,/* P2040 1.1 */
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 48ecffe..600704c 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -27,9 +27,9 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
-#include 
 #include 
 
 #define DRV_NAME "mpc-i2c"
diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c
index a34355f..af8fb27 100644
--- a/drivers/iommu/fsl_pamu.c
+++ b/drivers/iommu/fsl_pamu.c
@@ -21,11 +21,10 @@
 #include "fsl_pamu.h"
 
 #include 
+#include 
 #include 
 #include 
 
-#include 
-
 /* define indexes for each operation mapping scenario */
 #define OMI_QMAN0x00
 #define OMI_FMAN0x01
diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index d20935d..b8dac84 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -86,11 +86,11 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #ifdef CONFIG_PPC
 #include 
-#include 
 #endif
 #include 
 #include 
diff --git a/arch/powerpc/include/asm/mpc85xx.h b/include/linux/fsl/svr.h
similarity index 97%
rename from arch/powerpc/include/asm/mpc85xx.h
rename to include/linux/fsl/svr.h
index 213f3a8..8d13836 100644
--- a/arch/powerpc/include/asm/mpc85xx.h
+++ b/include/linux/fsl/svr.h
@@ -9,8 +9,8 @@
  * (at your option) any later version.
  */
 
-#ifndef __ASM_PPC_MPC85XX_H
-#define __ASM_PPC_MPC85XX_H
+#ifndef FSL_SVR_H
+#define FSL_SVR_H
 
 #define SVR_REV(svr)   ((svr) & 0xFF)  /* SOC design resision */
 #define SVR_MAJ(svr)   (((svr) >>  4) & 0xF)   /* Major revision field*/
-- 
2.1.0.27.g96db324



[v11, 2/8] ARM64: dts: ls2080a: add device configuration node

2016-09-06 Thread Yangbo Lu
Add the dts node for device configuration unit that provides
general purpose configuration and status for the device.

Signed-off-by: Yangbo Lu 
Acked-by: Scott Wood 
---
Changes for v5:
- Added this patch
Changes for v6:
- None
Changes for v7:
- None
Changes for v8:
- Added 'Acked-by: Scott Wood'
Changes for v9:
- None
Changes for v10:
- None
Changes for v11:
- None
---
 arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi
index 21023a3..39f7743 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi
@@ -215,6 +215,12 @@
clocks = <>;
};
 
+   dcfg: dcfg@1e0 {
+   compatible = "fsl,ls2080a-dcfg", "syscon";
+   reg = <0x0 0x1e0 0x0 0x1>;
+   little-endian;
+   };
+
serial0: serial@21c0500 {
compatible = "fsl,ns16550", "ns16550a";
reg = <0x0 0x21c0500 0x0 0x100>;
-- 
2.1.0.27.g96db324



Re: [PATCH 0/2] lan78xx: Remove trailing underscores from macros

2016-09-06 Thread Joe Perches
On Wed, 2016-09-07 at 02:00 +, ronnie.ku...@microchip.com wrote:
> Microchip's internal convention is for register (offset) definitions
> to be capitalized (i.e.: MY_REGISTER). Our convention for bits
> (position) definitions within a register is to carry as a prefix the
> name of the register and suffix it with the bit name and adding a
> trailing underscore (i.e. MY_REGISTER_MY_BIT_). The trailing
> underscore is what easily lets us distinguish a bit from a register
> definition when reading code. We have been using this convention for
> many years and has worked very well for us across all projects (by now
> hundreds).

I think it's kind of an ugly convention, but  no
skin off my nose really.

> > Is there anything other than a one-time cost
> > to apply these?  Is the same code used for
> > other platforms?
> 
> Yes, a single header file with the definition of registers and bits is
> shared (either as a standalone file or with its contents pasted into a
> native environment "carrier" header file) across all drivers (and
> other non driver software projects as well) for the same device. So a
> change like this indeed has a high cost for Microchip and we'd rather
> not do this unless it is an absolutely mandated requirement. 

No worries, if you don't like it, don't apply it.

Send a NAK too so David Miller doesn't apply it either.





Re: [RFC PATCH v2 1/6] proc: Reduce cache miss in {snmp,netstat}_seq_show

2016-09-06 Thread hejianet



On 9/7/16 6:57 AM, David Miller wrote:

From: Jia He 
Date: Tue,  6 Sep 2016 10:30:04 +0800


+#define MAX(a, b) ((u32)(a) >= (u32)(b) ? (a) : (b))

Thanks
B.R.
Jia


Please do not define private min/max macros, use the existing max_t()
or similar as needed.





Re: [RFC PATCH v2 0/6] Reduce cache miss for snmp_fold_field

2016-09-06 Thread hejianet

Hi Marcelo

Thanks for the suggestion

Will consider that

B.R.

Jia


On 9/6/16 8:44 PM, Marcelo Ricardo Leitner wrote:

On Tue, Sep 06, 2016 at 10:30:03AM +0800, Jia He wrote:
...

v2:
- 1/6 fix bug in udplite statistics.
- 1/6 snmp_seq_show is split into 2 parts

Jia He (6):
   proc: Reduce cache miss in {snmp,netstat}_seq_show
   proc: Reduce cache miss in snmp6_seq_show
   proc: Reduce cache miss in sctp_snmp_seq_show
   proc: Reduce cache miss in xfrm_statistics_seq_show
   ipv6: Remove useless parameter in __snmp6_fill_statsdev
   net: Suppress the "Comparison to NULL could be written" warning

Hi Jia,

Did you try to come up with a generic interface for this, like
snmp_fold_fields64() (note the fieldS) or snmp_fold_field64_batch() ?

Sounds like we have the same code in several places and seems they all
operate very similarly. They have a percpu table, an identified max, a
destination buffer..

If this is possible, this would reduce the possibility of hiccups in a
particular code.

   Marcelo






RE: linux-next: manual merge of the char-misc tree with the net-next tree

2016-09-06 Thread KY Srinivasan


> -Original Message-
> From: KY Srinivasan
> Sent: Tuesday, September 6, 2016 11:06 AM
> To: 'Greg KH' ; Stephen Rothwell 
> Cc: Arnd Bergmann ; David Miller ;
> Networking ; linux-n...@vger.kernel.org; linux-
> ker...@vger.kernel.org; Stephen Hemminger ;
> Vitaly Kuznetsov 
> Subject: RE: linux-next: manual merge of the char-misc tree with the net-next
> tree
> 
> 
> 
> > -Original Message-
> > From: Greg KH [mailto:g...@kroah.com]
> > Sent: Monday, September 5, 2016 5:04 PM
> > To: Stephen Rothwell 
> > Cc: Arnd Bergmann ; David Miller
> ;
> > Networking ; linux-n...@vger.kernel.org; linux-
> > ker...@vger.kernel.org; Stephen Hemminger ;
> > Vitaly Kuznetsov ; KY Srinivasan
> 
> > Subject: Re: linux-next: manual merge of the char-misc tree with the 
> > net-next
> > tree
> >
> > On Mon, Sep 05, 2016 at 04:56:50PM +1000, Stephen Rothwell wrote:
> > > Hi all,
> > >
> > > Today's linux-next merge of the char-misc tree got a conflict in:
> > >
> > >   include/linux/hyperv.h
> > >
> > > between commit:
> > >
> > >   30d1de08c87d ("hv_netvsc: make inline functions static")
> > >
> > > from the net-next tree and commit:
> > >
> > >   bb08d431a914 ("Drivers: hv: ring_buffer: count on wrap around mappings
> in
> > get_next_pkt_raw()")
> > >
> > > from the char-misc tree.
> > >
> > > I fixed it up (the former moved the code modified by the latter, so the
> > > below patch applies to the new location of the code) and can carry the
> > > fix as necessary. This is now fixed as far as linux-next is concerned,
> > > but any non trivial conflicts should be mentioned to your upstream
> > > maintainer when your tree is submitted for merging.  You may also want
> > > to consider cooperating with the maintainer of the conflicting tree to
> > > minimise any particularly complex conflicts.
> > >
> > > From: Stephen Rothwell 
> > > Date: Mon, 5 Sep 2016 16:53:06 +1000
> > > Subject: [PATCH] Drivers: hv: ring_buffer: merge fix up for "hv_netvsc:
> make
> > >  inline functions static"
> > >
> > > Signed-off-by: Stephen Rothwell 
> > > ---
> > >  drivers/net/hyperv/netvsc.c | 32 +++-
> > >  1 file changed, 11 insertions(+), 21 deletions(-)
> > >
> > > diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
> > > index 2a9ccc4d9e3c..026df6556068 100644
> > > --- a/drivers/net/hyperv/netvsc.c
> > > +++ b/drivers/net/hyperv/netvsc.c
> > > @@ -42,31 +42,23 @@ static struct vmpacket_descriptor *
> > >  get_next_pkt_raw(struct vmbus_channel *channel)
> > >  {
> > >   struct hv_ring_buffer_info *ring_info = >inbound;
> > > - u32 read_loc = ring_info->priv_read_index;
> > > + u32 priv_read_loc = ring_info->priv_read_index;
> > >   void *ring_buffer = hv_get_ring_buffer(ring_info);
> > > - struct vmpacket_descriptor *cur_desc;
> > > - u32 packetlen;
> > >   u32 dsize = ring_info->ring_datasize;
> > > - u32 delta = read_loc - ring_info->ring_buffer->read_index;
> > > + /*
> > > +  * delta is the difference between what is available to read and
> > > +  * what was already consumed in place. We commit read index after
> > > +  * the whole batch is processed.
> > > +  */
> > > + u32 delta = priv_read_loc >= ring_info->ring_buffer->read_index ?
> > > + priv_read_loc - ring_info->ring_buffer->read_index :
> > > + (dsize - ring_info->ring_buffer->read_index) + priv_read_loc;
> > >   u32 bytes_avail_toread = (hv_get_bytes_to_read(ring_info) - delta);
> > >
> > >   if (bytes_avail_toread < sizeof(struct vmpacket_descriptor))
> > >   return NULL;
> > >
> > > - if ((read_loc + sizeof(*cur_desc)) > dsize)
> > > - return NULL;
> > > -
> > > - cur_desc = ring_buffer + read_loc;
> > > - packetlen = cur_desc->len8 << 3;
> > > -
> > > - /*
> > > -  * If the packet under consideration is wrapping around,
> > > -  * return failure.
> > > -  */
> > > - if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > (dsize - 1))
> > > - return NULL;
> > > -
> > > - return cur_desc;
> > > + return ring_buffer + priv_read_loc;
> > >  }
> > >
> > >  /*
> > > @@ -78,16 +70,14 @@ static void put_pkt_raw(struct vmbus_channel
> > *channel,
> > >   struct vmpacket_descriptor *desc)
> > >  {
> > >   struct hv_ring_buffer_info *ring_info = >inbound;
> > > - u32 read_loc = ring_info->priv_read_index;
> > >   u32 packetlen = desc->len8 << 3;
> > >   u32 dsize = ring_info->ring_datasize;
> > >
> > > - BUG_ON((read_loc + packetlen + VMBUS_PKT_TRAILER) > dsize);
> > > -
> > >   /*
> > >* Include the packet trailer.
> > >*/
> > >   ring_info->priv_read_index += packetlen + VMBUS_PKT_TRAILER;
> > > + ring_info->priv_read_index %= 

Re: [v11, 7/8] base: soc: introduce soc_device_match() interface

2016-09-06 Thread Ulf Hansson
On 6 September 2016 at 10:28, Yangbo Lu  wrote:
> We keep running into cases where device drivers want to know the exact
> version of the a SoC they are currently running on. In the past, this has
> usually been done through a vendor specific API that can be called by a
> driver, or by directly accessing some kind of version register that is
> not part of the device itself but that belongs to a global register area
> of the chip.
>
> Common reasons for doing this include:
>
> - A machine is not using devicetree or similar for passing data about
>   on-chip devices, but just announces their presence using boot-time
>   platform devices, and the machine code itself does not care about the
>   revision.
>
> - There is existing firmware or boot loaders with existing DT binaries
>   with generic compatible strings that do not identify the particular
>   revision of each device, but the driver knows which SoC revisions
>   include which part.
>
> - A prerelease version of a chip has some quirks and we are using the same
>   version of the bootloader and the DT blob on both the prerelease and the
>   final version. An update of the DT binding seems inappropriate because
>   that would involve maintaining multiple copies of the dts and/or
>   bootloader.
>
> This patch introduces the soc_device_match() interface that is meant to
> work like of_match_node() but instead of identifying the version of a
> device, it identifies the SoC itself using a vendor-agnostic interface.
>
> Unlike of_match_node(), we do not do an exact string compare but instead
> use glob_match() to allow wildcards in strings.

Overall, this change make sense to me, although some minor comment below.

>
> Signed-off-by: Arnd Bergmann 
> Signed-off-by: Yangbo Lu 
> ---
> Changes for v11:
> - Added this patch for soc match
> ---
>  drivers/base/Kconfig|  1 +
>  drivers/base/soc.c  | 61 
> +
>  include/linux/sys_soc.h |  3 +++
>  3 files changed, 65 insertions(+)
>
> diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
> index 98504ec..f1591ad2 100644
> --- a/drivers/base/Kconfig
> +++ b/drivers/base/Kconfig
> @@ -225,6 +225,7 @@ config GENERIC_CPU_AUTOPROBE
>
>  config SOC_BUS
> bool
> +   select GLOB
>
>  source "drivers/base/regmap/Kconfig"
>
> diff --git a/drivers/base/soc.c b/drivers/base/soc.c
> index 75b98aa..5c4e84a 100644
> --- a/drivers/base/soc.c
> +++ b/drivers/base/soc.c
> @@ -14,6 +14,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  static DEFINE_IDA(soc_ida);
>
> @@ -168,3 +169,63 @@ static void __exit soc_bus_unregister(void)
> bus_unregister(_bus_type);
>  }
>  module_exit(soc_bus_unregister);
> +
> +static int soc_device_match_one(struct device *dev, void *arg)
> +{
> +   struct soc_device *soc_dev = container_of(dev, struct soc_device, 
> dev);
> +   const struct soc_device_attribute *match = arg;
> +
> +   if (match->machine &&
> +   !glob_match(match->machine, soc_dev->attr->machine))
> +   return 0;
> +
> +   if (match->family &&
> +   !glob_match(match->family, soc_dev->attr->family))
> +   return 0;
> +
> +   if (match->revision &&
> +   !glob_match(match->revision, soc_dev->attr->revision))
> +   return 0;
> +
> +   if (match->soc_id &&
> +   !glob_match(match->soc_id, soc_dev->attr->soc_id))
> +   return 0;
> +
> +   return 1;
> +}
> +
> +/*
> + * soc_device_match - identify the SoC in the machine
> + * @matches: zero-terminated array of possible matches

Perhaps also express the constraint on the matching entries. As you
need at least one of the ->machine(), ->family(), ->revision() or
->soc_id() callbacks implemented, right!?

> + *
> + * returns the first matching entry of the argument array, or NULL
> + * if none of them match.
> + *
> + * This function is meant as a helper in place of of_match_node()
> + * in cases where either no device tree is available or the information
> + * in a device node is insufficient to identify a particular variant
> + * by its compatible strings or other properties. For new devices,
> + * the DT binding should always provide unique compatible strings
> + * that allow the use of of_match_node() instead.
> + *
> + * The calling function can use the .data entry of the
> + * soc_device_attribute to pass a structure or function pointer for
> + * each entry.

I don't get the use case behind this, could you elaborate?

Perhaps we should postpone adding the .data entry until we actually
see a need for it?

> + */
> +const struct soc_device_attribute *soc_device_match(
> +   const struct soc_device_attribute *matches)
> +{
> +   struct device *dev;
> +   int ret;
> +
> +   for (ret = 0; ret == 0; matches++) {

This loop looks a bit weird and unsafe.

1) Perhaps using a while loop makes this more readable?
2) As this is an 

Re: mwifiex: propagate error if IRQ request fails in mwifiex_sdio_of()

2016-09-06 Thread Javier Martinez Canillas
Hello Kalle,

On 09/03/2016 12:35 PM, Kalle Valo wrote:
> Javier Martinez Canillas  wrote:
>> If request_irq() fails in mwifiex_sdio_probe_of(), only an error message
>> is printed but the actual error is not propagated to the caller function.
>>
>> Signed-off-by: Javier Martinez Canillas 
> 
> What's the conclusion with this patch? Should I drop it or take it?
> 
> (The discussion is available from the patchwork link in the signature.)
> 

My understanding is that Arend agrees with the patch and that the question
raised was caused by looking at an older kernel version. IOW, the patch is
OK and should be picked.

I'm adding Arend to cc, so can comment in case I misunderstood him though.

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America


Re: Centralizing support for TCAM?

2016-09-06 Thread Jamal Hadi Salim

On 16-09-05 11:44 PM, Alexei Starovoitov wrote:


lol :)
compiling bpf into fixed pipeline asic is definitely not easy.
The problem with adding new cls classifieris and actions to match
what configurable hw does isn't pretty either. The fixed pipeline
isn't interesting beyond l2/l3 and flow-based hw features are mostly
useless in the tor.


openflow cargo cult grew around those ACLs (before pragmatism
of table sizes and that there is more reality to networking
than some silly ACLs or defining everything as a table).
But that doesnt make things outside of L2/3 useless. A few
players like google are using those ASIC ACLs quiet effectively.


I'm not against adding new classifiers, since it's
better than sdk, but we won't be using such tc features either.


We are seeing use of those ACLs on TORs and spines (with tc). Yes, tiny
table spaces are a problem but new hardware allows for expansion
and people who use those tables are factoring in these issues.
You are not going to beat the performance numbers these things
offer. There is a lifespan of maybe 3-4 years where you are
not going to beat those numbers with s/ware without spending
more $ and space.


Since this thread about tcam... my 0.02 here is it's pretty bad in
the nic(host) due to power consumption and in the tor it's only good as
a part of algorithmic lpm solutions. There it won't be even seen as tcam.
Instead the fancy algorithms will use exact match + tcam + aux data to pack
as many routes into such 'algorithmic lpm' as possible, so I cannot see
what tcam as actual tcam can be good for.



Agreed on tcams.

cheers,
jamal


[PATCH] net: hns: declare function as static

2016-09-06 Thread Kefeng Wang
Declare function as static to kill warning about missing-prototypes.

Cc: Yisen Zhuang 
Cc: Kejian Yan 
Signed-off-by: Kefeng Wang 
---

The warning is shown when make with W=1.

 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c  | 22 +++---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c |  2 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  |  4 ++--
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c |  4 ++--
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c |  2 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c  |  6 +++---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c  |  4 ++--
 .../net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c|  2 +-
 drivers/net/ethernet/hisilicon/hns/hns_enet.c  |  8 
 drivers/net/ethernet/hisilicon/hns/hns_ethtool.c   | 16 
 10 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c 
b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index e28d960..cb47c23 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -73,7 +73,7 @@ static struct ring_pair_cb *hns_ae_get_ring_pair(struct 
hnae_queue *q)
return container_of(q, struct ring_pair_cb, q);
 }
 
-struct hnae_handle *hns_ae_get_handle(struct hnae_ae_dev *dev,
+static struct hnae_handle *hns_ae_get_handle(struct hnae_ae_dev *dev,
  u32 port_id)
 {
int vfnum_per_port;
@@ -271,7 +271,7 @@ static int hns_ae_start(struct hnae_handle *handle)
return 0;
 }
 
-void hns_ae_stop(struct hnae_handle *handle)
+static void hns_ae_stop(struct hnae_handle *handle)
 {
struct hns_mac_cb *mac_cb = hns_get_mac_cb(handle);
 
@@ -299,7 +299,7 @@ static void hns_ae_reset(struct hnae_handle *handle)
}
 }
 
-void hns_ae_toggle_ring_irq(struct hnae_ring *ring, u32 mask)
+static void hns_ae_toggle_ring_irq(struct hnae_ring *ring, u32 mask)
 {
u32 flag;
 
@@ -487,7 +487,7 @@ static void hns_ae_get_coalesce_range(struct hnae_handle 
*handle,
*rx_usecs_high  = HNS_RCB_MAX_COALESCED_USECS;
 }
 
-void hns_ae_update_stats(struct hnae_handle *handle,
+static void hns_ae_update_stats(struct hnae_handle *handle,
 struct net_device_stats *net_stats)
 {
int port;
@@ -570,7 +570,7 @@ void hns_ae_update_stats(struct hnae_handle *handle,
net_stats->multicast = mac_cb->hw_stats.rx_mc_pkts;
 }
 
-void hns_ae_get_stats(struct hnae_handle *handle, u64 *data)
+static void hns_ae_get_stats(struct hnae_handle *handle, u64 *data)
 {
int idx;
struct hns_mac_cb *mac_cb;
@@ -602,7 +602,7 @@ void hns_ae_get_stats(struct hnae_handle *handle, u64 *data)
hns_dsaf_get_stats(vf_cb->dsaf_dev, p, vf_cb->port_index);
 }
 
-void hns_ae_get_strings(struct hnae_handle *handle,
+static void hns_ae_get_strings(struct hnae_handle *handle,
u32 stringset, u8 *data)
 {
int port;
@@ -635,7 +635,7 @@ void hns_ae_get_strings(struct hnae_handle *handle,
hns_dsaf_get_strings(stringset, p, port, dsaf_dev);
 }
 
-int hns_ae_get_sset_count(struct hnae_handle *handle, int stringset)
+static int hns_ae_get_sset_count(struct hnae_handle *handle, int stringset)
 {
u32 sset_count = 0;
struct hns_mac_cb *mac_cb;
@@ -684,7 +684,7 @@ static int hns_ae_config_loopback(struct hnae_handle 
*handle,
return ret;
 }
 
-void hns_ae_update_led_status(struct hnae_handle *handle)
+static void hns_ae_update_led_status(struct hnae_handle *handle)
 {
struct hns_mac_cb *mac_cb;
 
@@ -695,7 +695,7 @@ void hns_ae_update_led_status(struct hnae_handle *handle)
hns_set_led_opt(mac_cb);
 }
 
-int hns_ae_cpld_set_led_id(struct hnae_handle *handle,
+static int hns_ae_cpld_set_led_id(struct hnae_handle *handle,
   enum hnae_led_state status)
 {
struct hns_mac_cb *mac_cb;
@@ -707,7 +707,7 @@ int hns_ae_cpld_set_led_id(struct hnae_handle *handle,
return hns_cpld_led_set_id(mac_cb, status);
 }
 
-void hns_ae_get_regs(struct hnae_handle *handle, void *data)
+static void hns_ae_get_regs(struct hnae_handle *handle, void *data)
 {
u32 *p = data;
int i;
@@ -732,7 +732,7 @@ void hns_ae_get_regs(struct hnae_handle *handle, void *data)
hns_dsaf_get_regs(vf_cb->dsaf_dev, vf_cb->port_index, p);
 }
 
-int hns_ae_get_regs_len(struct hnae_handle *handle)
+static int hns_ae_get_regs_len(struct hnae_handle *handle)
 {
u32 total_num;
struct hnae_vf_cb *vf_cb = hns_ae_get_vf_cb(handle);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
index 1e1eb92..f0c63c8 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
@@ -327,7 

[PATCH 3/3] ath10k: do not check if reset is NULL

2016-09-06 Thread Masahiro Yamada
Since reset_control_get() never returns NULL, we can use IS_ERR()
instead of IS_ERR_OR_NULL().  The return statements can be simpler
as well.

Signed-off-by: Masahiro Yamada 
---

 drivers/net/wireless/ath/ath10k/ahb.c | 25 ++---
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/ahb.c 
b/drivers/net/wireless/ath/ath10k/ahb.c
index 6b355ee..b29dc4d 100644
--- a/drivers/net/wireless/ath/ath10k/ahb.c
+++ b/drivers/net/wireless/ath/ath10k/ahb.c
@@ -195,43 +195,38 @@ static int ath10k_ahb_rst_ctrl_init(struct ath10k *ar)
dev = _ahb->pdev->dev;
 
ar_ahb->core_cold_rst = devm_reset_control_get(dev, "wifi_core_cold");
-   if (IS_ERR_OR_NULL(ar_ahb->core_cold_rst)) {
+   if (IS_ERR(ar_ahb->core_cold_rst)) {
ath10k_err(ar, "failed to get core cold rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->core_cold_rst));
-   return ar_ahb->core_cold_rst ?
-   PTR_ERR(ar_ahb->core_cold_rst) : -ENODEV;
+   return PTR_ERR(ar_ahb->core_cold_rst);
}
 
ar_ahb->radio_cold_rst = devm_reset_control_get(dev, "wifi_radio_cold");
-   if (IS_ERR_OR_NULL(ar_ahb->radio_cold_rst)) {
+   if (IS_ERR(ar_ahb->radio_cold_rst)) {
ath10k_err(ar, "failed to get radio cold rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->radio_cold_rst));
-   return ar_ahb->radio_cold_rst ?
-   PTR_ERR(ar_ahb->radio_cold_rst) : -ENODEV;
+   return PTR_ERR(ar_ahb->radio_cold_rst);
}
 
ar_ahb->radio_warm_rst = devm_reset_control_get(dev, "wifi_radio_warm");
-   if (IS_ERR_OR_NULL(ar_ahb->radio_warm_rst)) {
+   if (IS_ERR(ar_ahb->radio_warm_rst)) {
ath10k_err(ar, "failed to get radio warm rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->radio_warm_rst));
-   return ar_ahb->radio_warm_rst ?
-   PTR_ERR(ar_ahb->radio_warm_rst) : -ENODEV;
+   return PTR_ERR(ar_ahb->radio_warm_rst);
}
 
ar_ahb->radio_srif_rst = devm_reset_control_get(dev, "wifi_radio_srif");
-   if (IS_ERR_OR_NULL(ar_ahb->radio_srif_rst)) {
+   if (IS_ERR(ar_ahb->radio_srif_rst)) {
ath10k_err(ar, "failed to get radio srif rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->radio_srif_rst));
-   return ar_ahb->radio_srif_rst ?
-   PTR_ERR(ar_ahb->radio_srif_rst) : -ENODEV;
+   return PTR_ERR(ar_ahb->radio_srif_rst);
}
 
ar_ahb->cpu_init_rst = devm_reset_control_get(dev, "wifi_cpu_init");
-   if (IS_ERR_OR_NULL(ar_ahb->cpu_init_rst)) {
+   if (IS_ERR(ar_ahb->cpu_init_rst)) {
ath10k_err(ar, "failed to get cpu init rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->cpu_init_rst));
-   return ar_ahb->cpu_init_rst ?
-   PTR_ERR(ar_ahb->cpu_init_rst) : -ENODEV;
+   return PTR_ERR(ar_ahb->cpu_init_rst);
}
 
return 0;
-- 
1.9.1



Re: [PATCH net-next V5 4/4] net/sched: Introduce act_tunnel_key

2016-09-06 Thread Jamal Hadi Salim

On 16-09-04 06:55 AM, Hadar Hen Zion wrote:

From: Amir Vadai 

This action could be used before redirecting packets to a shared tunnel
device, or when redirecting packets arriving from a such a device.

The action will release the metadata created by the tunnel device
(decap), or set the metadata with the specified values for encap
operation.

For example, the following flower filter will forward all ICMP packets
destined to 11.11.11.2 through the shared vxlan device 'vxlan0'. Before
redirecting, a metadata for the vxlan tunnel is created using the
tunnel_key action and it's arguments:

$ filter add dev net0 protocol ip parent : \
flower \
  ip_proto 1 \
  dst_ip 11.11.11.2 \
action tunnel_key set \
  src_ip 11.11.0.1 \
  dst_ip 11.11.0.2 \
  id 11 \
action mirred egress redirect dev vxlan0




Syntax error above. Regardless:
Please verify by running a test and send a packet or two
and verify that stats are incremented (I know it may sound silly to
ask but it is important).


+static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a,
+ struct tcf_result *res)
+{
+   struct tcf_tunnel_key *t = to_tunnel_key(a);
+   struct tcf_tunnel_key_params *params;
+   int action;
+
+   rcu_read_lock();
+
+   params = rcu_dereference(t->params);
+
+   tcf_lastuse_update(>tcf_tm);
+   bstats_cpu_update(this_cpu_ptr(t->common.cpu_bstats), skb);
+   action = params->action;
+
+   switch (params->tcft_action) {
+   case TCA_TUNNEL_KEY_ACT_RELEASE:
+   skb_dst_drop(skb);
+   break;
+   case TCA_TUNNEL_KEY_ACT_SET:
+   skb_dst_drop(skb);
+   skb_dst_set(skb, dst_clone(>tcft_enc_metadata->dst));
+   break;
+   default:
+   WARN_ONCE(1, "Bad tunnel_key action.\n");
+   break;



slow path (_init()) is already checking for a bad tcft_act so it seems
unnecessary to have the default.
If you have to keep default would be useful to print the value as well.

Other than that looks good.
Acked-by: Jamal Hadi Salim 

cheers,
jamal


Re: [RFC PATCH v2 0/6] Reduce cache miss for snmp_fold_field

2016-09-06 Thread Marcelo Ricardo Leitner
On Tue, Sep 06, 2016 at 10:30:03AM +0800, Jia He wrote:
...
> v2:
> - 1/6 fix bug in udplite statistics. 
> - 1/6 snmp_seq_show is split into 2 parts
> 
> Jia He (6):
>   proc: Reduce cache miss in {snmp,netstat}_seq_show
>   proc: Reduce cache miss in snmp6_seq_show
>   proc: Reduce cache miss in sctp_snmp_seq_show
>   proc: Reduce cache miss in xfrm_statistics_seq_show
>   ipv6: Remove useless parameter in __snmp6_fill_statsdev
>   net: Suppress the "Comparison to NULL could be written" warning

Hi Jia,

Did you try to come up with a generic interface for this, like
snmp_fold_fields64() (note the fieldS) or snmp_fold_field64_batch() ?

Sounds like we have the same code in several places and seems they all
operate very similarly. They have a percpu table, an identified max, a
destination buffer.. 

If this is possible, this would reduce the possibility of hiccups in a
particular code.

  Marcelo



Re: Centralizing support for TCAM?

2016-09-06 Thread Andrew Lunn
> >Since this thread about tcam... my 0.02 here is it's pretty bad in
> >the nic(host) due to power consumption and in the tor it's only good as
> >a part of algorithmic lpm solutions. There it won't be even seen as tcam.
> >Instead the fancy algorithms will use exact match + tcam + aux data to pack
> >as many routes into such 'algorithmic lpm' as possible, so I cannot see
> >what tcam as actual tcam can be good for.
> >
> 
> Agreed on tcams.

So if i'm reading this right, you are talking about big switches, top
of racks, etc. And you don't see much use for the TCAM.

Florian and I are interested in the other end of the scale. Little
5-10 port switches in SoHo, STB, WiFi Access points etc. At the
moment, firewalling in such devices is done by the CPU. If we can
offload some of the firewall rules to the TCAM, we would be happy.

Andrew


Re: [PATCH] rxrpc: remove duplicate 'error' variable

2016-09-06 Thread Arnd Bergmann
On Tuesday, September 6, 2016 2:34:02 PM CEST David Howells wrote:
> Arnd Bergmann  wrote:
> 
> > The rxrpc_process_call function has debug code to print a failure code,
> > but instead of printing the code from the rxrpc_call structure, it
> > prints an uninitialized variable:
> > 
> > net/rxrpc/call_event.c: In function 'rxrpc_process_call':
> > net/rxrpc/call_event.c:879:58: error: 'error' may be used uninitialized in 
> > this function [-Werror=maybe-uninitialized]
> > 
> > This removes the extraneous variable and prints the correct
> > code instead.
> > 
> > Signed-off-by: Arnd Bergmann 
> > Fixes: f5c17aaeb2ae ("rxrpc: Calls should only have one terminal state")
> 
> I've already posted a fix and it's waiting on DaveM.
> 
> https://patchwork.ozlabs.org/patch/665550/
> 
> http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/commit/?h=rxrpc-rewrite=00b5407e427ac2588a2496b92035a94602b3cd1b

Ok, good. At least I'm glad my patch is correct this time (being identical
to yours).

Arnd



[patch net-next RFC 0/2] fib4 offload: notifier to let hw to be aware of all prefixes

2016-09-06 Thread Jiri Pirko
From: Jiri Pirko 

This is RFC, unfinished. I came across some issues in the process so I would
like to share those and restart the fib offload discussion in order to make it
really usable.

So the goal of this patchset is to allow driver to propagate all prefixes
configured in kernel down HW. This is necessary for routing to work
as expected. If we don't do that HW might forward prefixes known to kernel
incorrectly. Take an example when default route is set in switch HW and there
is an IP address set on a management (non-switch) port.

Currently, only fibs related to the switch port netdev are offloaded using
switchdev ops. This model is not extendable so the first patch introduces
a replacement: notifier to propagate fib additions and removals to whoever
interested. The second patch makes mlxsw to adopt this new way, registering
one notifier block for each mlxsw (asic) instance.

Using switchdev ops, "abort" is called by switchdev core whenever there is
an error during fib add offload. This leads to removal of all offloaded fibs on
system by fib_trie code.

Now the new notifier assumes the driver takes care of the abort action.
Here's why:
1) The fact that one HW cannot offload fib does not mean that the others can't
   do it. So let only one entity to abort and leave the rest to work happily.
2) The driver knows what to in order to properly abort. For example, currently
   abort is broken for mlxsw as for Spectrum there is a need to set 0.0.0.0/0
   trap in RALUE register.

Issues:
1) RTNH_F_OFFLOAD is originally set in switchdev core. There the assumption is
   that only one offload device exists. But for fib notifier, we assume
   multiple offload devices. When should the offload flag be set and by who?
   I think that it would make sense to have a per-fib reference counter
   for this:
   0 means RTNH_F_OFFLOAD is not set, no device offloads this entry
   n means RTNH_F_OFFLOAD is set and the fib entry is offloaded by n devices

2) Unabort? Would be nice. Currently when add_failure->abort happens,
   user's only option is to reboot the machine. I would like to make this
   nicer for the fib notifier implementation. Perhaps to provide some button in
   devlink which would tell driver to try to offload entries again? Not sure.

3) Policies. Not directly connected to this patchset but this issues
   we have been discussing couple of times and I still believe that
   the current state is not good.
   Software-only forwarding now happens in case of abort and makes the ASIC
   ports to act like dummy separate NICs. In case of Spectrum, the bandwidth
   of CPU port is something around 4Gbit. For 32x100Gbit ports this is
   simply not possible to handle. In case of abort, the system is broken
   as it really could not forward packets at a speed not even close
   to the expected.
   Here the policies come to the picture, allowing the user to set the
   system to behave according his expectations. For example rather
   fail to add the route than to abort to software forward.
   This policy could be per-ASIC, configurable by devlink.

Thoughts please?

Jiri Pirko (2):
  fib: introduce fib notification infrastructure
  mlxsw: spectrum_router: Use FIB notifications instead of switchdev
calls

 drivers/net/ethernet/mellanox/mlxsw/spectrum.h |   8 +-
 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  | 257 ++---
 .../ethernet/mellanox/mlxsw/spectrum_switchdev.c   |   9 -
 include/net/ip_fib.h   |  19 ++
 net/ipv4/fib_trie.c|  43 
 5 files changed, 181 insertions(+), 155 deletions(-)

-- 
2.5.5



[patch net-next RFC 1/2] fib: introduce fib notification infrastructure

2016-09-06 Thread Jiri Pirko
From: Jiri Pirko 

This allows to pass information about added/deleted fib entries to
whoever is interested. This is done in a very similar way as devinet
notifies address additions/removals.

Signed-off-by: Jiri Pirko 
---
 include/net/ip_fib.h | 19 +++
 net/ipv4/fib_trie.c  | 43 +++
 2 files changed, 62 insertions(+)

diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 4079fc1..9ad7ba9 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct fib_config {
u8  fc_dst_len;
@@ -184,6 +185,24 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct 
fib_nh *nh);
 #define FIB_RES_PREFSRC(net, res)  ((res).fi->fib_prefsrc ? : \
 FIB_RES_SADDR(net, res))
 
+struct fib_notifier_info {
+   u32 dst;
+   int dst_len;
+   struct fib_info *fi;
+   u8 tos;
+   u8 type;
+   u32 tb_id;
+   u32 nlflags;
+};
+
+enum fib_event_type {
+   FIB_EVENT_TYPE_ADD,
+   FIB_EVENT_TYPE_DEL,
+};
+
+int register_fib_notifier(struct notifier_block *nb);
+int unregister_fib_notifier(struct notifier_block *nb);
+
 struct fib_table {
struct hlist_node   tb_hlist;
u32 tb_id;
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index e2ffc2a..19ec471 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -73,6 +73,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -84,6 +85,36 @@
 #include 
 #include "fib_lookup.h"
 
+static BLOCKING_NOTIFIER_HEAD(fib_chain);
+
+int register_fib_notifier(struct notifier_block *nb)
+{
+   return blocking_notifier_chain_register(_chain, nb);
+}
+EXPORT_SYMBOL(register_fib_notifier);
+
+int unregister_fib_notifier(struct notifier_block *nb)
+{
+   return blocking_notifier_chain_unregister(_chain, nb);
+}
+EXPORT_SYMBOL(unregister_fib_notifier);
+
+static int call_fib_notifiers(enum fib_event_type event_type, u32 dst,
+ int dst_len, struct fib_info *fi,
+ u8 tos, u8 type, u32 tb_id, u32 nlflags)
+{
+   struct fib_notifier_info info = {
+   .dst = dst,
+   .dst_len = dst_len,
+   .fi = fi,
+   .tos = tos,
+   .type = type,
+   .tb_id = tb_id,
+   .nlflags = nlflags,
+   };
+   return blocking_notifier_call_chain(_chain, event_type, );
+}
+
 #define MAX_STAT_DEPTH 32
 
 #define KEYLENGTH  (8*sizeof(t_key))
@@ -1190,6 +1221,10 @@ int fib_table_insert(struct fib_table *tb, struct 
fib_config *cfg)
fib_release_info(fi_drop);
if (state & FA_S_ACCESSED)
rt_cache_flush(cfg->fc_nlinfo.nl_net);
+
+   call_fib_notifiers(FIB_EVENT_TYPE_ADD, key, plen, fi,
+  new_fa->fa_tos, cfg->fc_type,
+  tb->tb_id, cfg->fc_nlflags);
rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen,
tb->tb_id, >fc_nlinfo, NLM_F_REPLACE);
 
@@ -1241,6 +1276,8 @@ int fib_table_insert(struct fib_table *tb, struct 
fib_config *cfg)
tb->tb_num_default++;
 
rt_cache_flush(cfg->fc_nlinfo.nl_net);
+   call_fib_notifiers(FIB_EVENT_TYPE_ADD, key, plen, fi, tos,
+  cfg->fc_type, tb->tb_id, cfg->fc_nlflags);
rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, new_fa->tb_id,
  >fc_nlinfo, nlflags);
 succeeded:
@@ -1542,6 +1579,8 @@ int fib_table_delete(struct fib_table *tb, struct 
fib_config *cfg)
switchdev_fib_ipv4_del(key, plen, fa_to_delete->fa_info, tos,
   cfg->fc_type, tb->tb_id);
 
+   call_fib_notifiers(FIB_EVENT_TYPE_DEL, key, plen, fa_to_delete->fa_info,
+  tos, cfg->fc_type, tb->tb_id, 0);
rtmsg_fib(RTM_DELROUTE, htonl(key), fa_to_delete, plen, tb->tb_id,
  >fc_nlinfo, 0);
 
@@ -1857,6 +1896,10 @@ int fib_table_flush(struct fib_table *tb)
switchdev_fib_ipv4_del(n->key, KEYLENGTH - fa->fa_slen,
   fi, fa->fa_tos, fa->fa_type,
   tb->tb_id);
+   call_fib_notifiers(FIB_EVENT_TYPE_DEL, n->key,
+  KEYLENGTH - fa->fa_slen,
+  fi, fa->fa_tos, fa->fa_type,
+  tb->tb_id, 0);
hlist_del_rcu(>fa_list);
fib_release_info(fa->fa_info);
alias_free_mem_rcu(fa);
-- 
2.5.5



[patch net-next RFC 2/2] mlxsw: spectrum_router: Use FIB notifications instead of switchdev calls

2016-09-06 Thread Jiri Pirko
From: Jiri Pirko 

Until now, in order to offload a FIB entry to HW we use switchdev op.
However that has limits. Mainly in case we need to make the HW aware of
all route prefixes configured in kernel. HW needs to know those in order
to properly trap appropriate packets and pass the to kernel to do
the forwarding.

Signed-off-by: Jiri Pirko 
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h |   8 +-
 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  | 257 ++---
 .../ethernet/mellanox/mlxsw/spectrum_switchdev.c   |   9 -
 3 files changed, 119 insertions(+), 155 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
index 49f4caf..03b97da 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
@@ -45,7 +45,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "port.h"
 #include "core.h"
@@ -302,6 +302,7 @@ struct mlxsw_sp {
struct mlxsw_sp_span_entry *entries;
int entries_count;
} span;
+   struct notifier_block fib_nb;
 };
 
 static inline struct mlxsw_sp_upper *
@@ -587,11 +588,6 @@ static inline void mlxsw_sp_port_dcb_fini(struct 
mlxsw_sp_port *mlxsw_sp_port)
 
 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp);
 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
-int mlxsw_sp_router_fib4_add(struct mlxsw_sp_port *mlxsw_sp_port,
-const struct switchdev_obj_ipv4_fib *fib4,
-struct switchdev_trans *trans);
-int mlxsw_sp_router_fib4_del(struct mlxsw_sp_port *mlxsw_sp_port,
-const struct switchdev_obj_ipv4_fib *fib4);
 int mlxsw_sp_router_neigh_construct(struct net_device *dev,
struct neighbour *n);
 void mlxsw_sp_router_neigh_destroy(struct net_device *dev,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 3f5c51d..7330439 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "spectrum.h"
 #include "core.h"
@@ -1489,50 +1490,6 @@ static void mlxsw_sp_nexthop_group_put(struct mlxsw_sp 
*mlxsw_sp,
mlxsw_sp_nexthop_group_destroy(mlxsw_sp, nh_grp);
 }
 
-static int __mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp)
-{
-   char rgcr_pl[MLXSW_REG_RGCR_LEN];
-
-   mlxsw_reg_rgcr_pack(rgcr_pl, true);
-   mlxsw_reg_rgcr_max_router_interfaces_set(rgcr_pl, MLXSW_SP_RIF_MAX);
-   return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rgcr), rgcr_pl);
-}
-
-static void __mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp)
-{
-   char rgcr_pl[MLXSW_REG_RGCR_LEN];
-
-   mlxsw_reg_rgcr_pack(rgcr_pl, false);
-   mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rgcr), rgcr_pl);
-}
-
-int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp)
-{
-   int err;
-
-   INIT_LIST_HEAD(_sp->router.nexthop_neighs_list);
-   INIT_LIST_HEAD(_sp->router.nexthop_group_list);
-   err = __mlxsw_sp_router_init(mlxsw_sp);
-   if (err)
-   return err;
-   mlxsw_sp_lpm_init(mlxsw_sp);
-   mlxsw_sp_vrs_init(mlxsw_sp);
-   err = mlxsw_sp_neigh_init(mlxsw_sp);
-   if (err)
-   goto err_neigh_init;
-   return 0;
-
-err_neigh_init:
-   __mlxsw_sp_router_fini(mlxsw_sp);
-   return err;
-}
-
-void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp)
-{
-   mlxsw_sp_neigh_fini(mlxsw_sp);
-   __mlxsw_sp_router_fini(mlxsw_sp);
-}
-
 static int mlxsw_sp_fib_entry_op4_remote(struct mlxsw_sp *mlxsw_sp,
 struct mlxsw_sp_fib_entry *fib_entry,
 enum mlxsw_reg_ralue_op op)
@@ -1637,45 +1594,34 @@ static int mlxsw_sp_fib_entry_del(struct mlxsw_sp 
*mlxsw_sp,
 MLXSW_REG_RALUE_OP_WRITE_DELETE);
 }
 
-struct mlxsw_sp_router_fib4_add_info {
-   struct switchdev_trans_item tritem;
-   struct mlxsw_sp *mlxsw_sp;
-   struct mlxsw_sp_fib_entry *fib_entry;
-};
-
-static void mlxsw_sp_router_fib4_add_info_destroy(void const *data)
-{
-   const struct mlxsw_sp_router_fib4_add_info *info = data;
-   struct mlxsw_sp_fib_entry *fib_entry = info->fib_entry;
-   struct mlxsw_sp *mlxsw_sp = info->mlxsw_sp;
-   struct mlxsw_sp_vr *vr = fib_entry->vr;
-
-   mlxsw_sp_fib_entry_destroy(fib_entry);
-   mlxsw_sp_vr_put(mlxsw_sp, vr);
-   kfree(info);
-}
-
 static int
 mlxsw_sp_router_fib4_entry_init(struct mlxsw_sp *mlxsw_sp,
-   const struct switchdev_obj_ipv4_fib *fib4,
+   const struct fib_notifier_info *fn_info,
struct mlxsw_sp_fib_entry *fib_entry)
 {
-   

Re: [PATCH v3 net-next 1/1] net_sched: Introduce skbmod action

2016-09-06 Thread Jamal Hadi Salim

ng
On 16-08-30 08:44 AM, Eric Dumazet wrote:

On Tue, 2016-08-30 at 07:57 -0400, Jamal Hadi Salim wrote:

if (flags & SKBMOD_F_SWAPMAC) {
u8 tmpaddr[ETH_ALEN];
/*XXX: I am sure we can come up with something more efficient */
ether_addr_copy(tmpaddr, eth_hdr(skb)->h_dest);
ether_addr_copy(eth_hdr(skb)->h_dest, eth_hdr(skb)->h_source);
ether_addr_copy(eth_hdr(skb)->h_source, tmpaddr);
}


While ether_addr_copy() is accepting u8 pointers, data must be aligned to u16 
at least.

(See comments in include/linux/etherdevice.h)

Some arches/compilers might do things here that would generate a trap
if tmpaddr is not aligned.



Hrm. How do you suggest dealing with this?

cheers,
jamal


[PATCH 2/3] ath10k: use devm_reset_control_get() instead of reset_control_get()

2016-09-06 Thread Masahiro Yamada
Use the managed variant of reset_control_get() to simplify the
failure path and the .remove callback.

Signed-off-by: Masahiro Yamada 
---

 drivers/net/wireless/ath/ath10k/ahb.c | 56 +++
 1 file changed, 10 insertions(+), 46 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/ahb.c 
b/drivers/net/wireless/ath/ath10k/ahb.c
index 8a55c0c..6b355ee 100644
--- a/drivers/net/wireless/ath/ath10k/ahb.c
+++ b/drivers/net/wireless/ath/ath10k/ahb.c
@@ -191,92 +191,56 @@ static int ath10k_ahb_rst_ctrl_init(struct ath10k *ar)
 {
struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
struct device *dev;
-   int ret;
 
dev = _ahb->pdev->dev;
 
-   ar_ahb->core_cold_rst = reset_control_get(dev, "wifi_core_cold");
+   ar_ahb->core_cold_rst = devm_reset_control_get(dev, "wifi_core_cold");
if (IS_ERR_OR_NULL(ar_ahb->core_cold_rst)) {
ath10k_err(ar, "failed to get core cold rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->core_cold_rst));
-   ret = ar_ahb->core_cold_rst ?
+   return ar_ahb->core_cold_rst ?
PTR_ERR(ar_ahb->core_cold_rst) : -ENODEV;
-   goto out;
}
 
-   ar_ahb->radio_cold_rst = reset_control_get(dev, "wifi_radio_cold");
+   ar_ahb->radio_cold_rst = devm_reset_control_get(dev, "wifi_radio_cold");
if (IS_ERR_OR_NULL(ar_ahb->radio_cold_rst)) {
ath10k_err(ar, "failed to get radio cold rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->radio_cold_rst));
-   ret = ar_ahb->radio_cold_rst ?
+   return ar_ahb->radio_cold_rst ?
PTR_ERR(ar_ahb->radio_cold_rst) : -ENODEV;
-   goto err_core_cold_rst_put;
}
 
-   ar_ahb->radio_warm_rst = reset_control_get(dev, "wifi_radio_warm");
+   ar_ahb->radio_warm_rst = devm_reset_control_get(dev, "wifi_radio_warm");
if (IS_ERR_OR_NULL(ar_ahb->radio_warm_rst)) {
ath10k_err(ar, "failed to get radio warm rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->radio_warm_rst));
-   ret = ar_ahb->radio_warm_rst ?
+   return ar_ahb->radio_warm_rst ?
PTR_ERR(ar_ahb->radio_warm_rst) : -ENODEV;
-   goto err_radio_cold_rst_put;
}
 
-   ar_ahb->radio_srif_rst = reset_control_get(dev, "wifi_radio_srif");
+   ar_ahb->radio_srif_rst = devm_reset_control_get(dev, "wifi_radio_srif");
if (IS_ERR_OR_NULL(ar_ahb->radio_srif_rst)) {
ath10k_err(ar, "failed to get radio srif rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->radio_srif_rst));
-   ret = ar_ahb->radio_srif_rst ?
+   return ar_ahb->radio_srif_rst ?
PTR_ERR(ar_ahb->radio_srif_rst) : -ENODEV;
-   goto err_radio_warm_rst_put;
}
 
-   ar_ahb->cpu_init_rst = reset_control_get(dev, "wifi_cpu_init");
+   ar_ahb->cpu_init_rst = devm_reset_control_get(dev, "wifi_cpu_init");
if (IS_ERR_OR_NULL(ar_ahb->cpu_init_rst)) {
ath10k_err(ar, "failed to get cpu init rst ctrl: %ld\n",
   PTR_ERR(ar_ahb->cpu_init_rst));
-   ret = ar_ahb->cpu_init_rst ?
+   return ar_ahb->cpu_init_rst ?
PTR_ERR(ar_ahb->cpu_init_rst) : -ENODEV;
-   goto err_radio_srif_rst_put;
}
 
return 0;
-
-err_radio_srif_rst_put:
-   reset_control_put(ar_ahb->radio_srif_rst);
-
-err_radio_warm_rst_put:
-   reset_control_put(ar_ahb->radio_warm_rst);
-
-err_radio_cold_rst_put:
-   reset_control_put(ar_ahb->radio_cold_rst);
-
-err_core_cold_rst_put:
-   reset_control_put(ar_ahb->core_cold_rst);
-
-out:
-   return ret;
 }
 
 static void ath10k_ahb_rst_ctrl_deinit(struct ath10k *ar)
 {
struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
 
-   if (!IS_ERR_OR_NULL(ar_ahb->core_cold_rst))
-   reset_control_put(ar_ahb->core_cold_rst);
-
-   if (!IS_ERR_OR_NULL(ar_ahb->radio_cold_rst))
-   reset_control_put(ar_ahb->radio_cold_rst);
-
-   if (!IS_ERR_OR_NULL(ar_ahb->radio_warm_rst))
-   reset_control_put(ar_ahb->radio_warm_rst);
-
-   if (!IS_ERR_OR_NULL(ar_ahb->radio_srif_rst))
-   reset_control_put(ar_ahb->radio_srif_rst);
-
-   if (!IS_ERR_OR_NULL(ar_ahb->cpu_init_rst))
-   reset_control_put(ar_ahb->cpu_init_rst);
-
ar_ahb->core_cold_rst = NULL;
ar_ahb->radio_cold_rst = NULL;
ar_ahb->radio_warm_rst = NULL;
-- 
1.9.1



Re: [PATCH net-next V5 4/4] net/sched: Introduce act_tunnel_key

2016-09-06 Thread Jamal Hadi Salim

On 16-09-06 07:03 AM, Hadar Hen Zion wrote:

On Tue, Sep 6, 2016 at 1:49 PM, Jamal Hadi Salim  wrote:



Please verify by running a test and send a packet or two
and verify that stats are incremented (I know it may sound silly to
ask but it is important).


Already tested that tc filter stats are working and incremented as expected :-)


I did see issue with per-cpu counters when i updated to rcu.
But the test was on a VM. So i changed skbmod to use global stats.
Maybe the kernel i was testing had issues.
Eric may have some insights.

cheers,
jamal



Re: [PATCH v4 nf] netfilter: seqadj: Drop the packet directly when fail to add seqadj extension to avoid dereference NULL pointer later

2016-09-06 Thread Gao Feng
inline

On Tue, Sep 6, 2016 at 6:17 PM, Pablo Neira Ayuso  wrote:
> On Tue, Sep 06, 2016 at 09:57:23AM +0800, f...@ikuai8.com wrote:
>> From: Gao Feng 
>>
>> When memory is exhausted, nfct_seqadj_ext_add may fail to add the seqadj
>> extension. But the function nf_ct_seqadj_init doesn't check if get valid
>> seqadj pointer by the nfct_seqadj.
>>
>> Now drop the packet directly when fail to add seqadj extension to avoid
>> dereference NULL pointer in nf_ct_seqadj_init.
>>
>> Signed-off-by: Gao Feng 
>> ---
>>  v4: Drop the packet directly when fail to add seqadj extension;
>>  v3: Remove the warning log when seqadj is null;
>>  v2: Remove the unnessary seqadj check in nf_ct_seq_adjust
>>  v1: Initial patch
>>
>>  net/netfilter/nf_conntrack_core.c | 6 +-
>>  net/netfilter/nf_nat_core.c   | 3 ++-
>>  2 files changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/netfilter/nf_conntrack_core.c 
>> b/net/netfilter/nf_conntrack_core.c
>> index dd2c43a..dfa76ce 100644
>> --- a/net/netfilter/nf_conntrack_core.c
>> +++ b/net/netfilter/nf_conntrack_core.c
>> @@ -1036,7 +1036,11 @@ init_conntrack(struct net *net, struct nf_conn *tmpl,
>>   return (struct nf_conntrack_tuple_hash *)ct;
>>
>>   if (tmpl && nfct_synproxy(tmpl)) {
>> - nfct_seqadj_ext_add(ct);
>> + if (!nfct_seqadj_ext_add(ct)) {
>> + nf_conntrack_free(ct);
>> + pr_debug("Can't add seqadj extension\n");
>> + return NULL;
>> + }
>>   nfct_synproxy_ext_add(ct);
>
> I think this is part of the same logical change, ie. nf_ct_ext_add()
> returns NULL, then I would also fix nfct_synproxy_ext_add() in this
> go.
>
Sorry, I am not clear well.
Need I modify the logic of this part?

>>   }
>>
>> diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
>> index de31818..b82282a 100644
>> --- a/net/netfilter/nf_nat_core.c
>> +++ b/net/netfilter/nf_nat_core.c
>> @@ -441,7 +441,8 @@ nf_nat_setup_info(struct nf_conn *ct,
>>   ct->status |= IPS_DST_NAT;
>>
>>   if (nfct_help(ct))
>> - nfct_seqadj_ext_add(ct);
>> + if (!nfct_seqadj_ext_add(ct))
>> + return NF_DROP;
>
> ctnetlink may have created a conntrack with seqadj in place by when we
> call nf_nat_setup_info() so NF_ACCEPT would be more conservative, eg.
> via conntrackd state synchronization.
>
> Actually, after a quick look at ctnetlink, I don't see any any call to
> nfct_seqadj_ext_add() from there, so I suspect this is broken since
> SYNPROXY was introduced. It would be great if you can review this and
> send us patches to fix this, if indeed needed.
>
> Thanks!

Let me confirm the problem, or I am afraid I would misunderstand our meaning.
This patch only need to modify the "NF_DROP" to "NF_ACCEPT", is it?

Then I could commit another patch to fix the ctnetlink lost nfct_seqadj_ext_add.

Best Regards
Feng




[PATCH, net-next] perf, bpf: fix conditional call to bpf_overflow_handler

2016-09-06 Thread Arnd Bergmann
The newly added bpf_overflow_handler function is only built of both
CONFIG_EVENT_TRACING and CONFIG_BPF_SYSCALL are enabled, but the caller
only checks the latter:

kernel/events/core.c: In function 'perf_event_alloc':
kernel/events/core.c:9106:27: error: 'bpf_overflow_handler' undeclared (first 
use in this function)

This changes the caller so we also skip this call if CONFIG_EVENT_TRACING
is disabled entirely.

Signed-off-by: Arnd Bergmann 
Fixes: aa6a5f3cb2b2 ("perf, bpf: add perf events core support for 
BPF_PROG_TYPE_PERF_EVENT programs")
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I'm not entirely sure if this is the correct solution, please check before 
applying

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 73d0c6ddfd5b..d3f6374326d8 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -9110,7 +9110,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
if (!overflow_handler && parent_event) {
overflow_handler = parent_event->overflow_handler;
context = parent_event->overflow_handler_context;
-#ifdef CONFIG_BPF_SYSCALL
+#if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_EVENT_TRACING)
if (overflow_handler == bpf_overflow_handler) {
struct bpf_prog *prog = 
bpf_prog_inc(parent_event->prog);
 
-- 
2.9.0



Re: [PATCH net-next V5 4/4] net/sched: Introduce act_tunnel_key

2016-09-06 Thread Hadar Hen Zion
On Tue, Sep 6, 2016 at 1:49 PM, Jamal Hadi Salim  wrote:
> On 16-09-04 06:55 AM, Hadar Hen Zion wrote:
>>
>> From: Amir Vadai 
>>
>> This action could be used before redirecting packets to a shared tunnel
>> device, or when redirecting packets arriving from a such a device.
>>
>> The action will release the metadata created by the tunnel device
>> (decap), or set the metadata with the specified values for encap
>> operation.
>>
>> For example, the following flower filter will forward all ICMP packets
>> destined to 11.11.11.2 through the shared vxlan device 'vxlan0'. Before
>> redirecting, a metadata for the vxlan tunnel is created using the
>> tunnel_key action and it's arguments:
>>
>> $ filter add dev net0 protocol ip parent : \
>> flower \
>>   ip_proto 1 \
>>   dst_ip 11.11.11.2 \
>> action tunnel_key set \
>>   src_ip 11.11.0.1 \
>>   dst_ip 11.11.0.2 \
>>   id 11 \
>> action mirred egress redirect dev vxlan0
>>
>
>
> Syntax error above. Regardless:

ack, will be fixed.

> Please verify by running a test and send a packet or two
> and verify that stats are incremented (I know it may sound silly to
> ask but it is important).

Already tested that tc filter stats are working and incremented as expected :-)
.
>
>
>> +static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a,
>> + struct tcf_result *res)
>> +{
>> +   struct tcf_tunnel_key *t = to_tunnel_key(a);
>> +   struct tcf_tunnel_key_params *params;
>> +   int action;
>> +
>> +   rcu_read_lock();
>> +
>> +   params = rcu_dereference(t->params);
>> +
>> +   tcf_lastuse_update(>tcf_tm);
>> +   bstats_cpu_update(this_cpu_ptr(t->common.cpu_bstats), skb);
>> +   action = params->action;
>> +
>> +   switch (params->tcft_action) {
>> +   case TCA_TUNNEL_KEY_ACT_RELEASE:
>> +   skb_dst_drop(skb);
>> +   break;
>> +   case TCA_TUNNEL_KEY_ACT_SET:
>> +   skb_dst_drop(skb);
>> +   skb_dst_set(skb,
>> dst_clone(>tcft_enc_metadata->dst));
>> +   break;
>> +   default:
>> +   WARN_ONCE(1, "Bad tunnel_key action.\n");
>> +   break;
>
>
>
> slow path (_init()) is already checking for a bad tcft_act so it seems
> unnecessary to have the default.
> If you have to keep default would be useful to print the value as well.

ack.

>
> Other than that looks good.
> Acked-by: Jamal Hadi Salim 
>
> cheers,
> jamal


RE: [PATCH iproute2] ip route: check ftell, fseek return value

2016-09-06 Thread David Laight
From: Hangbin Liu
> Sent: 06 September 2016 07:40
> ftell() may return -1 in error case, which is not handled and therefore pass a
> negative offset to fseek(). The return code of fseek() is also not checked.
> 
> Reported-by: Phil Sutter 
> Signed-off-by: Hangbin Liu 
> ---
>  ip/iproute.c | 11 +--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/ip/iproute.c b/ip/iproute.c
> index 3da23af..ba877dc 100644
> --- a/ip/iproute.c
> +++ b/ip/iproute.c
> @@ -1859,7 +1859,11 @@ static int iproute_restore(void)
>   if (route_dump_check_magic())
>   exit(-1);
> 
> - pos = ftell(stdin);
> + if ((pos = ftell(stdin)) == -1) {

Don't put assignments in conditionals.

> + perror("Failed to restore: ftell");
> + exit(errno);

errno is not a valid argument to exit().

...

Actually WTF is this code trying to do.
stdin is very likely to be a pipe, so expecting to seek on it
seems very likely to fail.

David





Re: [PATCH v3 net-next 1/1] net_sched: Introduce skbmod action

2016-09-06 Thread Jamal Hadi Salim

On 16-08-30 08:35 AM, Eric Dumazet wrote:


synchronize_rcu() might bee to expensive if you plan to change actions
hundred of times per second.

You could instead add a 'struct rcu_head rcu;'  field in struct
tcf_skbmod_params  (but make sure this is not exported to user space)

Then :

if (ovr)
 spin_unlock_bh(>tcf_lock);
 kfree_rcu(p_old, rcu);



Ok, working on this variant. Will post today or tommorow.

cheers,
jamal




Re: [v11, 7/8] base: soc: introduce soc_device_match() interface

2016-09-06 Thread Arnd Bergmann
On Tuesday, September 6, 2016 1:44:23 PM CEST Ulf Hansson wrote:
> On 6 September 2016 at 10:28, Yangbo Lu  wrote:
> > We keep running into cases where device drivers want to know the exact
> > version of the a SoC they are currently running on. In the past, this has
> > usually been done through a vendor specific API that can be called by a
> > driver, or by directly accessing some kind of version register that is
> > not part of the device itself but that belongs to a global register area
> > of the chip.

Please add "From: Arnd Bergmann " as the first line, to
preserve authorship. If you use "git send-email" or "git format-patch",
that should happen automatically if the author field is set right
(if not, use 'git commit --amend --author="Arnd Bergmann "'
to fix it).

> > +
> > +/*
> > + * soc_device_match - identify the SoC in the machine
> > + * @matches: zero-terminated array of possible matches
> 
> Perhaps also express the constraint on the matching entries. As you
> need at least one of the ->machine(), ->family(), ->revision() or
> ->soc_id() callbacks implemented, right!?

They are not callbacks, just strings. Having an empty entry indicates
the end of the array, and this is not called.

> > + *
> > + * returns the first matching entry of the argument array, or NULL
> > + * if none of them match.
> > + *
> > + * This function is meant as a helper in place of of_match_node()
> > + * in cases where either no device tree is available or the information
> > + * in a device node is insufficient to identify a particular variant
> > + * by its compatible strings or other properties. For new devices,
> > + * the DT binding should always provide unique compatible strings
> > + * that allow the use of of_match_node() instead.
> > + *
> > + * The calling function can use the .data entry of the
> > + * soc_device_attribute to pass a structure or function pointer for
> > + * each entry.
> 
> I don't get the use case behind this, could you elaborate?
> 
> Perhaps we should postpone adding the .data entry until we actually
> see a need for it?

I think the interface is rather useless without a way to figure
out which entry you got. Almost all users of of_match_node()
actually use the returned ->data field, and I expect this to
be the same here.

> > + */
> > +const struct soc_device_attribute *soc_device_match(
> > +   const struct soc_device_attribute *matches)
> > +{
> > +   struct device *dev;
> > +   int ret;
> > +
> > +   for (ret = 0; ret == 0; matches++) {
> 
> This loop looks a bit weird and unsafe.

Ah, and I thought I was being clever ;-)

> 1) Perhaps using a while loop makes this more readable?
> 2) As this is an exported API, I guess validation of the ->matches
> pointer needs to be done before accessing it.

Sounds fine.

> > +   if (!(matches->machine || matches->family ||
> > + matches->revision || matches->soc_id))
> > +   return NULL;
> > +   dev = NULL;
> 
> There's no need to use a struct device just to assign it to NULL.
> Instead just provide the function below with NULL.
>
> > +   ret = bus_for_each_dev(_bus_type, dev, (void *)matches,
> > +  soc_device_match_one);


I don't remember what led to this, I think you are right, we should
just pass NULL as most other callers.

Thanks for the review.

ARnd



[PATCH] rxrpc: remove duplicate 'error' variable

2016-09-06 Thread Arnd Bergmann
The rxrpc_process_call function has debug code to print a failure code,
but instead of printing the code from the rxrpc_call structure, it
prints an uninitialized variable:

net/rxrpc/call_event.c: In function 'rxrpc_process_call':
net/rxrpc/call_event.c:879:58: error: 'error' may be used uninitialized in this 
function [-Werror=maybe-uninitialized]

This removes the extraneous variable and prints the correct
code instead.

Signed-off-by: Arnd Bergmann 
Fixes: f5c17aaeb2ae ("rxrpc: Calls should only have one terminal state")
---
 net/rxrpc/call_event.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
index de72de662044..4754c7fb6242 100644
--- a/net/rxrpc/call_event.c
+++ b/net/rxrpc/call_event.c
@@ -868,7 +868,6 @@ skip_msg_init:
/* deal with events of a final nature */
if (test_bit(RXRPC_CALL_EV_RCVD_ERROR, >events)) {
enum rxrpc_skb_mark mark;
-   int error;
 
clear_bit(RXRPC_CALL_EV_CONN_ABORT, >events);
clear_bit(RXRPC_CALL_EV_REJECT_BUSY, >events);
@@ -876,10 +875,10 @@ skip_msg_init:
 
if (call->completion == RXRPC_CALL_NETWORK_ERROR) {
mark = RXRPC_SKB_MARK_NET_ERROR;
-   _debug("post net error %d", error);
+   _debug("post net error %d", call->error);
} else {
mark = RXRPC_SKB_MARK_LOCAL_ERROR;
-   _debug("post net local error %d", error);
+   _debug("post net local error %d", call->error);
}
 
if (rxrpc_post_message(call, mark, call->error, true) < 0)
-- 
2.9.0



Re: [PATCH] rxrpc: remove duplicate 'error' variable

2016-09-06 Thread David Howells
Arnd Bergmann  wrote:

> The rxrpc_process_call function has debug code to print a failure code,
> but instead of printing the code from the rxrpc_call structure, it
> prints an uninitialized variable:
> 
> net/rxrpc/call_event.c: In function 'rxrpc_process_call':
> net/rxrpc/call_event.c:879:58: error: 'error' may be used uninitialized in 
> this function [-Werror=maybe-uninitialized]
> 
> This removes the extraneous variable and prints the correct
> code instead.
> 
> Signed-off-by: Arnd Bergmann 
> Fixes: f5c17aaeb2ae ("rxrpc: Calls should only have one terminal state")

I've already posted a fix and it's waiting on DaveM.

https://patchwork.ozlabs.org/patch/665550/

http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/commit/?h=rxrpc-rewrite=00b5407e427ac2588a2496b92035a94602b3cd1b

David


Re: [RFC Patch net-next 1/6] net_sched: use RCU for action hash table

2016-09-06 Thread Jamal Hadi Salim

On 16-09-02 01:57 AM, Cong Wang wrote:

We already free tc actions in a RCU callback, so here
we just need to convert the hash table operations to
RCU API's.

Cc: Jamal Hadi Salim 
Signed-off-by: Cong Wang 


This one stands on its own merit, no?
So:
Acked-by: Jamal Hadi Salim 


cheers,
jamal


Re: Centralizing support for TCAM?

2016-09-06 Thread Jamal Hadi Salim

On 16-09-06 09:31 AM, Andrew Lunn wrote:


So if i'm reading this right, you are talking about big switches, top
of racks, etc. And you don't see much use for the TCAM.

Florian and I are interested in the other end of the scale. Little
5-10 port switches in SoHo, STB, WiFi Access points etc. At the
moment, firewalling in such devices is done by the CPU. If we can
offload some of the firewall rules to the TCAM, we would be happy.



As with all discussions on netdev, that was a distraction;->
Use tc as mentioned by Jiri. Please please no ethtool.

cheers,
jamal



[PATCH 0/3] ath10k: a little bit clean-up of ATH10K driver

2016-09-06 Thread Masahiro Yamada

Clean-up code with devm_clk_get() and devm_reset_control_get().

I know devm_reset_control_get() should be replaced with
either devm_reset_control_get_exclusive() or
devm_reset_control_get_shared().

My best guess is devm_reset_control_get_shared() for this case,
but I am not 100% sure, so I am leaving it to other developers.



Masahiro Yamada (3):
  ath10k: use devm_clk_get() instead of clk_get()
  ath10k: use devm_reset_control_get() instead of reset_control_get()
  ath10k: do not check if reset is NULL

 drivers/net/wireless/ath/ath10k/ahb.c | 105 +++---
 1 file changed, 21 insertions(+), 84 deletions(-)

-- 
1.9.1



[PATCH v4 net-next 1/1] net_sched: Introduce skbmod action

2016-09-06 Thread Jamal Hadi Salim
From: Jamal Hadi Salim 

This action is intended to be an upgrade from a usability perspective
from pedit (as well as operational debugability).
Compare this:

sudo tc filter add dev $ETH parent 1: protocol ip prio 10 \
u32 match ip protocol 1 0xff flowid 1:2 \
action pedit munge offset -14 u8 set 0x02 \
munge offset -13 u8 set 0x15 \
munge offset -12 u8 set 0x15 \
munge offset -11 u8 set 0x15 \
munge offset -10 u16 set 0x1515 \
pipe

to:

sudo tc filter add dev $ETH parent 1: protocol ip prio 10 \
u32 match ip protocol 1 0xff flowid 1:2 \
action skbmod dmac 02:15:15:15:15:15

Also try to do a MAC address swap with pedit or worse
try to debug a policy with destination mac, source mac and
etherype. Then make few rules out of those and you'll get my point.

In the future common use cases on pedit can be migrated to this action
(as an example different fields in ip v4/6, transports like tcp/udp/sctp
etc). For this first cut, this allows modifying basic ethernet header.

The most important ethernet use case at the moment is when redirecting or
mirroring packets to a remote machine. The dst mac address needs a re-write
so that it doesnt get dropped or confuse an interconnecting (learning) switc
or dropped by a target machine (which looks at the dst mac). And at times
when flipping back the packet a swap of the MAC addresses is needed.

Signed-off-by: Jamal Hadi Salim 
---
 include/net/tc_act/tc_skbmod.h|  30 
 include/uapi/linux/tc_act/tc_skbmod.h |  39 +
 net/sched/Kconfig |  11 ++
 net/sched/Makefile|   1 +
 net/sched/act_skbmod.c| 295 ++
 5 files changed, 376 insertions(+)
 create mode 100644 include/net/tc_act/tc_skbmod.h
 create mode 100644 include/uapi/linux/tc_act/tc_skbmod.h
 create mode 100644 net/sched/act_skbmod.c

diff --git a/include/net/tc_act/tc_skbmod.h b/include/net/tc_act/tc_skbmod.h
new file mode 100644
index 000..f34cf13
--- /dev/null
+++ b/include/net/tc_act/tc_skbmod.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016, Jamal Hadi Salim
+ *
+ * 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.
+*/
+
+#ifndef __NET_TC_SKBMOD_H
+#define __NET_TC_SKBMOD_H
+
+#include 
+#include 
+
+struct tcf_skbmod_params {
+   struct rcu_head rcu;
+   u64 flags; /*up to 64 types of operations; extend if needed */
+   u8  eth_dst[ETH_ALEN];
+   u16 eth_type;
+   u8  eth_src[ETH_ALEN];
+};
+
+struct tcf_skbmod {
+   struct tc_actioncommon;
+   struct tcf_skbmod_params  *skbmod_p;
+};
+#define to_skbmod(a) ((struct tcf_skbmod *)a)
+
+#endif /* __NET_TC_SKBMOD_H */
diff --git a/include/uapi/linux/tc_act/tc_skbmod.h 
b/include/uapi/linux/tc_act/tc_skbmod.h
new file mode 100644
index 000..10fc07d
--- /dev/null
+++ b/include/uapi/linux/tc_act/tc_skbmod.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016, Jamal Hadi Salim
+ *
+ * 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.
+*/
+
+#ifndef __LINUX_TC_SKBMOD_H
+#define __LINUX_TC_SKBMOD_H
+
+#include 
+
+#define TCA_ACT_SKBMOD 15
+
+#define SKBMOD_F_DMAC  0x1
+#define SKBMOD_F_SMAC  0x2
+#define SKBMOD_F_ETYPE 0x4
+#define SKBMOD_F_SWAPMAC 0x8
+
+struct tc_skbmod {
+   tc_gen;
+   __u64 flags;
+};
+
+enum {
+   TCA_SKBMOD_UNSPEC,
+   TCA_SKBMOD_TM,
+   TCA_SKBMOD_PARMS,
+   TCA_SKBMOD_DMAC,
+   TCA_SKBMOD_SMAC,
+   TCA_SKBMOD_ETYPE,
+   TCA_SKBMOD_PAD,
+   __TCA_SKBMOD_MAX
+};
+#define TCA_SKBMOD_MAX (__TCA_SKBMOD_MAX - 1)
+
+#endif
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index ccf931b..34b556d 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -749,6 +749,17 @@ config NET_ACT_CONNMARK
  To compile this code as a module, choose M here: the
  module will be called act_connmark.
 
+config NET_ACT_SKBMOD
+tristate "skb data modification action"
+depends on NET_CLS_ACT
+---help---
+ Say Y here to allow modification of skb data
+
+ If unsure, say N.
+
+ To compile this code as a module, choose M here: the
+ module will be called act_skbmod.
+
 config NET_ACT_IFE
 tristate "Inter-FE action based on IETF ForCES InterFE LFB"
 depends on NET_CLS_ACT
diff --git a/net/sched/Makefile b/net/sched/Makefile
index ae088a5..e82eff8 100644
--- a/net/sched/Makefile
+++ b/net/sched/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_NET_ACT_CSUM)+= act_csum.o
 obj-$(CONFIG_NET_ACT_VLAN) += act_vlan.o
 obj-$(CONFIG_NET_ACT_BPF)  += act_bpf.o
 

Re: [PATCH] vti: use right inner_mode for inbound inter address family policy checks

2016-09-06 Thread Steffen Klassert
On Sun, Sep 04, 2016 at 12:57:13PM +0200, Thomas Zeitlhofer wrote:
> In case of inter address family tunneling (IPv6 over vti4 or IPv4 over
> vti6), the inbound policy checks in vti_rcv_cb and vti6_rcv_cb are using
> the wrong address family. As a result, all inbound inter address family
> traffic is dropped.
> 
> Use the xfrm_ip2inner_mode helper (as done in xfrm_prepare_input and
> xfrm_input) to select the inner_mode that contains the right address family
> for the inbound policy checks.
> 
> Signed-off-by: Thomas Zeitlhofer 
> ---
> 
> Notes:
> The patch was developed by looking at the code, but without knowledge of
> the XFRM code in the kernel. It has been successfully tested, but it is
> more a guess that might be helpful for the maintainers to find a proper
> solution.
> 
>  net/ipv4/ip_vti.c  | 12 +++-
>  net/ipv6/ip6_vti.c | 12 +++-
>  2 files changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
> index a917903..44d5449 100644
> --- a/net/ipv4/ip_vti.c
> +++ b/net/ipv4/ip_vti.c
> @@ -88,6 +88,7 @@ static int vti_rcv_cb(struct sk_buff *skb, int err)
>   struct net_device *dev;
>   struct pcpu_sw_netstats *tstats;
>   struct xfrm_state *x;
> + struct xfrm_mode *inner_mode;
>   struct ip_tunnel *tunnel = XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4;
>   u32 orig_mark = skb->mark;
>   int ret;
> @@ -105,7 +106,16 @@ static int vti_rcv_cb(struct sk_buff *skb, int err)
>   }
>  
>   x = xfrm_input_state(skb);
> - family = x->inner_mode->afinfo->family;
> +
> + inner_mode = x->inner_mode;
> +
> + if (x->sel.family == AF_UNSPEC) {
> + inner_mode = xfrm_ip2inner_mode(x, 
> XFRM_MODE_SKB_CB(skb)->protocol);
> + if (inner_mode == NULL)
> + return -EPERM;

You better return -EINVAL instead of -EPERM here.
Also you should bump the LINUX_MIB_XFRMINSTATEMODEERROR
counter as we do in xfrm_input.

> + }
> +
> + family = inner_mode->afinfo->family;
>  
>   skb->mark = be32_to_cpu(tunnel->parms.i_key);
>   ret = xfrm_policy_check(NULL, XFRM_POLICY_IN, skb, family);
> diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
> index d90a11f..3149757 100644
> --- a/net/ipv6/ip6_vti.c
> +++ b/net/ipv6/ip6_vti.c
> @@ -340,6 +340,7 @@ static int vti6_rcv_cb(struct sk_buff *skb, int err)
>   struct net_device *dev;
>   struct pcpu_sw_netstats *tstats;
>   struct xfrm_state *x;
> + struct xfrm_mode *inner_mode;
>   struct ip6_tnl *t = XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6;
>   u32 orig_mark = skb->mark;
>   int ret;
> @@ -357,7 +358,16 @@ static int vti6_rcv_cb(struct sk_buff *skb, int err)
>   }
>  
>   x = xfrm_input_state(skb);
> - family = x->inner_mode->afinfo->family;
> +
> + inner_mode = x->inner_mode;
> +
> + if (x->sel.family == AF_UNSPEC) {
> + inner_mode = xfrm_ip2inner_mode(x, 
> XFRM_MODE_SKB_CB(skb)->protocol);
> + if (inner_mode == NULL)
> + return -EPERM;

Same here.

Other that that it looks ok to me.



Re: [ovs-dev] [PATCH net-next v21 3/4] openvswitch: 802.1AD Flow handling, actions, vlan parsing, netlink attributes

2016-09-06 Thread Eric Garver
On Sun, Sep 04, 2016 at 01:05:46PM +0200, Jiri Benc wrote:
> On Sat, 3 Sep 2016 13:30:12 -0400, Eric Garver wrote:
> > Would a BUG_ON(!(encap && in_encap)) be better?
> 
> Please don't crash the kernel for something that could very well
> continue without problems. Use WARN_ON at most.

Thanks Jiri. WARN_ON_ONCE() is more appropriate for what I was looking
for.

> And if you go that way, WARN_ON_ONCE or rate limiting seems to be even
> more appropriate, because if this triggers, it's quite possible it will
> trigger repeatedly and the resulting log flood would practically make
> the machine useless anyway.
> 
> Thanks,
> 
>  Jiri


[PATCH 1/3] ath10k: use devm_clk_get() instead of clk_get()

2016-09-06 Thread Masahiro Yamada
Use the managed variant of clk_get() to simplify the failure path
and the .remove callback.

Signed-off-by: Masahiro Yamada 
---

 drivers/net/wireless/ath/ath10k/ahb.c | 34 ++
 1 file changed, 6 insertions(+), 28 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/ahb.c 
b/drivers/net/wireless/ath/ath10k/ahb.c
index acec16b..8a55c0c 100644
--- a/drivers/net/wireless/ath/ath10k/ahb.c
+++ b/drivers/net/wireless/ath/ath10k/ahb.c
@@ -91,59 +91,37 @@ static int ath10k_ahb_clock_init(struct ath10k *ar)
 {
struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
struct device *dev;
-   int ret;
 
dev = _ahb->pdev->dev;
 
-   ar_ahb->cmd_clk = clk_get(dev, "wifi_wcss_cmd");
+   ar_ahb->cmd_clk = devm_clk_get(dev, "wifi_wcss_cmd");
if (IS_ERR_OR_NULL(ar_ahb->cmd_clk)) {
ath10k_err(ar, "failed to get cmd clk: %ld\n",
   PTR_ERR(ar_ahb->cmd_clk));
-   ret = ar_ahb->cmd_clk ? PTR_ERR(ar_ahb->cmd_clk) : -ENODEV;
-   goto out;
+   return ar_ahb->cmd_clk ? PTR_ERR(ar_ahb->cmd_clk) : -ENODEV;
}
 
-   ar_ahb->ref_clk = clk_get(dev, "wifi_wcss_ref");
+   ar_ahb->ref_clk = devm_clk_get(dev, "wifi_wcss_ref");
if (IS_ERR_OR_NULL(ar_ahb->ref_clk)) {
ath10k_err(ar, "failed to get ref clk: %ld\n",
   PTR_ERR(ar_ahb->ref_clk));
-   ret = ar_ahb->ref_clk ? PTR_ERR(ar_ahb->ref_clk) : -ENODEV;
-   goto err_cmd_clk_put;
+   return ar_ahb->ref_clk ? PTR_ERR(ar_ahb->ref_clk) : -ENODEV;
}
 
-   ar_ahb->rtc_clk = clk_get(dev, "wifi_wcss_rtc");
+   ar_ahb->rtc_clk = devm_clk_get(dev, "wifi_wcss_rtc");
if (IS_ERR_OR_NULL(ar_ahb->rtc_clk)) {
ath10k_err(ar, "failed to get rtc clk: %ld\n",
   PTR_ERR(ar_ahb->rtc_clk));
-   ret = ar_ahb->rtc_clk ? PTR_ERR(ar_ahb->rtc_clk) : -ENODEV;
-   goto err_ref_clk_put;
+   return ar_ahb->rtc_clk ? PTR_ERR(ar_ahb->rtc_clk) : -ENODEV;
}
 
return 0;
-
-err_ref_clk_put:
-   clk_put(ar_ahb->ref_clk);
-
-err_cmd_clk_put:
-   clk_put(ar_ahb->cmd_clk);
-
-out:
-   return ret;
 }
 
 static void ath10k_ahb_clock_deinit(struct ath10k *ar)
 {
struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
 
-   if (!IS_ERR_OR_NULL(ar_ahb->cmd_clk))
-   clk_put(ar_ahb->cmd_clk);
-
-   if (!IS_ERR_OR_NULL(ar_ahb->ref_clk))
-   clk_put(ar_ahb->ref_clk);
-
-   if (!IS_ERR_OR_NULL(ar_ahb->rtc_clk))
-   clk_put(ar_ahb->rtc_clk);
-
ar_ahb->cmd_clk = NULL;
ar_ahb->ref_clk = NULL;
ar_ahb->rtc_clk = NULL;
-- 
1.9.1



Re: [RFC Patch net-next 2/6] net_sched: introduce tcf_hash_replace()

2016-09-06 Thread Jamal Hadi Salim

On 16-09-02 01:57 AM, Cong Wang wrote:


Cc: Jamal Hadi Salim 
Signed-off-by: Cong Wang 
---
 include/net/act_api.h |  2 ++
 net/sched/act_api.c   | 20 
 2 files changed, 22 insertions(+)

diff --git a/include/net/act_api.h b/include/net/act_api.h
index 82f3c91..a374bab 100644
--- a/include/net/act_api.h




+void tcf_hash_replace(struct tc_action_net *tn, struct tc_action **old,
+ struct tc_action *new, int bind)
+{
+   struct tcf_hashinfo *hinfo = tn->hinfo;
+   unsigned int h = tcf_hash(new->tcfa_index, hinfo->hmask);
+


WWhy do you need to recreate the index?
Old index was fine since this is just a replacement..

The rest of the patches seem fine - will let Eric comment on the
mirred.

Note: I am going to still push forward with skbmod action and I think
so should the new tunnel action code i.e we make them independent.
I'd like to switch to this when we think it is stable.

cheers,
jamal


[PATCH v4 1/6] bpf: add new prog type for cgroup socket filtering

2016-09-06 Thread Daniel Mack
For now, this program type is equivalent to BPF_PROG_TYPE_SOCKET_FILTER in
terms of checks during the verification process. It may access the skb as
well.

Programs of this type will be attached to cgroups for network filtering
and accounting.

Signed-off-by: Daniel Mack 
---
 include/uapi/linux/bpf.h | 9 +
 kernel/bpf/verifier.c| 1 +
 net/core/filter.c| 6 ++
 3 files changed, 16 insertions(+)

diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index f896dfa..55f815e 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -96,8 +96,17 @@ enum bpf_prog_type {
BPF_PROG_TYPE_TRACEPOINT,
BPF_PROG_TYPE_XDP,
BPF_PROG_TYPE_PERF_EVENT,
+   BPF_PROG_TYPE_CGROUP_SOCKET,
 };
 
+enum bpf_attach_type {
+   BPF_CGROUP_INET_INGRESS,
+   BPF_CGROUP_INET_EGRESS,
+   __MAX_BPF_ATTACH_TYPE
+};
+
+#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
+
 #define BPF_PSEUDO_MAP_FD  1
 
 /* flags for BPF_MAP_UPDATE_ELEM command */
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 48c2705..1b8a871 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1805,6 +1805,7 @@ static bool may_access_skb(enum bpf_prog_type type)
case BPF_PROG_TYPE_SOCKET_FILTER:
case BPF_PROG_TYPE_SCHED_CLS:
case BPF_PROG_TYPE_SCHED_ACT:
+   case BPF_PROG_TYPE_CGROUP_SOCKET:
return true;
default:
return false;
diff --git a/net/core/filter.c b/net/core/filter.c
index a83766b..176b6f2 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2848,12 +2848,18 @@ static struct bpf_prog_type_list xdp_type __read_mostly 
= {
.type   = BPF_PROG_TYPE_XDP,
 };
 
+static struct bpf_prog_type_list cg_sk_type __read_mostly = {
+   .ops= _filter_ops,
+   .type   = BPF_PROG_TYPE_CGROUP_SOCKET,
+};
+
 static int __init register_sk_filter_ops(void)
 {
bpf_register_prog_type(_filter_type);
bpf_register_prog_type(_cls_type);
bpf_register_prog_type(_act_type);
bpf_register_prog_type(_type);
+   bpf_register_prog_type(_sk_type);
 
return 0;
 }
-- 
2.5.5



[PATCH v4 4/6] net: filter: run cgroup eBPF ingress programs

2016-09-06 Thread Daniel Mack
If the cgroup associated with the receiving socket has an eBPF
programs installed, run them from sk_filter_trim_cap().

eBPF programs used in this context are expected to either return 1 to
let the packet pass, or != 1 to drop them. The programs have access to
the full skb, including the MAC headers.

Note that cgroup_bpf_run_filter() is stubbed out as static inline nop
for !CONFIG_CGROUP_BPF, and is otherwise guarded by a static key if
the feature is unused.

Signed-off-by: Daniel Mack 
---
 net/core/filter.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index 176b6f2..3662c1a 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -78,6 +78,10 @@ int sk_filter_trim_cap(struct sock *sk, struct sk_buff *skb, 
unsigned int cap)
if (skb_pfmemalloc(skb) && !sock_flag(sk, SOCK_MEMALLOC))
return -ENOMEM;
 
+   err = cgroup_bpf_run_filter(sk, skb, BPF_CGROUP_INET_INGRESS);
+   if (err)
+   return err;
+
err = security_sock_rcv_skb(sk, skb);
if (err)
return err;
-- 
2.5.5



Re: [PATCH net-next V5 4/4] net/sched: Introduce act_tunnel_key

2016-09-06 Thread Eric Dumazet
On Sun, 2016-09-04 at 13:55 +0300, Hadar Hen Zion wrote:
> From: Amir Vadai 

...

> +struct tcf_tunnel_key_params {
> + struct rcu_head rcu;
> + int tcft_action;
> + int action;
> + struct metadata_dst *tcft_enc_metadata;
> +};
> +
> +struct tcf_tunnel_key {
> + struct tc_action  common;
> + struct tcf_tunnel_key_params *params;

In order to please sparse you must add __rcu qualifier, as in :

struct tcf_tunnel_key_params __rcu *params;

> +};
> +

Thanks.





Re: [PATCH v3 net-next 1/1] net_sched: Introduce skbmod action

2016-09-06 Thread Eric Dumazet
On Tue, 2016-09-06 at 08:08 -0400, Jamal Hadi Salim wrote:
> ng
> On 16-08-30 08:44 AM, Eric Dumazet wrote:
> > On Tue, 2016-08-30 at 07:57 -0400, Jamal Hadi Salim wrote:
> >> if (flags & SKBMOD_F_SWAPMAC) {
> >> u8 tmpaddr[ETH_ALEN];
> >> /*XXX: I am sure we can come up with something more 
> >> efficient */
> >> ether_addr_copy(tmpaddr, eth_hdr(skb)->h_dest);
> >> ether_addr_copy(eth_hdr(skb)->h_dest, 
> >> eth_hdr(skb)->h_source);
> >> ether_addr_copy(eth_hdr(skb)->h_source, tmpaddr);
> >> }
> >
> > While ether_addr_copy() is accepting u8 pointers, data must be aligned to 
> > u16 at least.
> >
> > (See comments in include/linux/etherdevice.h)
> >
> > Some arches/compilers might do things here that would generate a trap
> > if tmpaddr is not aligned.
> >
> 
> Hrm. How do you suggest dealing with this?

Just use u16 in the array ?

u16 tmpaddr[ETH_ALEN / 2]; /* ether_addr_copy() requirement */

ether_addr_copy((u8 *)tmpaddr, eth_hdr(skb)->h_dest);
...






Re: [patch net-next v7 1/3] netdevice: Add offload statistics ndo

2016-09-06 Thread Roopa Prabhu
On 9/5/16, 10:18 AM, Jiri Pirko wrote:
> From: Nogah Frankel 
>
> Add a new ndo to return statistics for offloaded operation.
> Since there can be many different offloaded operation with many
> stats types, the ndo gets an attribute id by which it knows which
> stats are wanted. The ndo also gets a void pointer to be cast according
> to the attribute id.
>
> Signed-off-by: Nogah Frankel 
> Signed-off-by: Jiri Pirko 
> ---
>  include/linux/netdevice.h | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 67bb978..2d2c09b 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -924,6 +924,14 @@ struct netdev_xdp {
>   *   3. Update dev->stats asynchronously and atomically, and define
>   *  neither operation.
>   *
> + * bool (*ndo_has_offload_stats)(int attr_id)
> + *   Return true if this device supports offload stats of this attr_id.
> + *
> + * int (*ndo_get_offload_stats)(int attr_id, const struct net_device *dev,
> + *   void *attr_data)
> + *   Get statistics for offload operations by attr_id. Write it into the
> + *   attr_data pointer.
> + *

this could have been a single ndo_get_offload_stats like the others.
and possibly new ndo_get_offload_stats_size.
Ideally the driver could do the nest.
But, this can be changed if needed in the future.

>   * int (*ndo_vlan_rx_add_vid)(struct net_device *dev, __be16 proto, u16 vid);
>   *   If device supports VLAN filtering this function is called when a
>   *   VLAN id is registered.
> @@ -1155,6 +1163,10 @@ struct net_device_ops {
>  
>   struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev,
>struct rtnl_link_stats64 
> *storage);
> + bool(*ndo_has_offload_stats)(int attr_id);
> + int (*ndo_get_offload_stats)(int attr_id,
> +  const struct 
> net_device *dev,
> +  void *attr_data);
>   struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
>  
>   int (*ndo_vlan_rx_add_vid)(struct net_device *dev,



Re: [patch net-next v7 2/3] net: core: Add offload stats to if_stats_msg

2016-09-06 Thread Roopa Prabhu
On 9/5/16, 10:18 AM, Jiri Pirko wrote:
> From: Nogah Frankel 
>
> Add a nested attribute of offload stats to if_stats_msg
> named IFLA_STATS_LINK_OFFLOAD_XSTATS.
> Under it, add SW stats, meaning stats only per packets that went via
> slowpath to the cpu, named IFLA_OFFLOAD_XSTATS_CPU_HIT.
>
> Signed-off-by: Nogah Frankel 
> Signed-off-by: Jiri Pirko 
> ---
>  include/uapi/linux/if_link.h | 10 +
>  net/core/rtnetlink.c | 88 
> ++--
>  2 files changed, 94 insertions(+), 4 deletions(-)
>
> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
> index 9bf3aec..4aaa2a1 100644
> --- a/include/uapi/linux/if_link.h
> +++ b/include/uapi/linux/if_link.h
> @@ -826,6 +826,7 @@ enum {
>   IFLA_STATS_LINK_64,
>   IFLA_STATS_LINK_XSTATS,
>   IFLA_STATS_LINK_XSTATS_SLAVE,
> + IFLA_STATS_LINK_OFFLOAD_XSTATS,
>   __IFLA_STATS_MAX,
>  };
>  
> @@ -845,6 +846,15 @@ enum {
>  };
>  #define LINK_XSTATS_TYPE_MAX (__LINK_XSTATS_TYPE_MAX - 1)
>  
> +/* These are stats embedded into IFLA_STATS_LINK_OFFLOAD_XSTATS */
> +enum {
> + IFLA_OFFLOAD_XSTATS_UNSPEC,
> + IFLA_OFFLOAD_XSTATS_CPU_HIT, /* struct rtnl_link_stats64 */
> + __IFLA_OFFLOAD_XSTATS_MAX
> +};
> +#define IFLA_OFFLOAD_XSTATS_MAX (__IFLA_OFFLOAD_XSTATS_MAX - 1)
> +#define IFLA_OFFLOAD_XSTATS_FIRST (IFLA_OFFLOAD_XSTATS_UNSPEC + 1)

not sure why we need a first in the uapi.
> +
>  /* XDP section */
>  
>  enum {
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 1dfca1c..95eb131 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -3577,6 +3577,74 @@ static bool stats_attr_valid(unsigned int mask, int 
> attrid, int idxattr)
>  (!idxattr || idxattr == attrid);
>  }
>  
> +static int rtnl_get_offload_stats_attr_size(int attr_id)
> +{
> + switch (attr_id) {
> + case IFLA_OFFLOAD_XSTATS_CPU_HIT:
> + return sizeof(struct rtnl_link_stats64);
> + }
> +
> + return 0;
> +}
> +
> +static int rtnl_get_offload_stats(struct sk_buff *skb, struct net_device 
> *dev)
> +{
> + struct nlattr *attr;
> + int attr_id, size;
> + void *attr_data;
> + int err;
> +
> + if (!(dev->netdev_ops && dev->netdev_ops->ndo_has_offload_stats &&
> +   dev->netdev_ops->ndo_get_offload_stats))
> + return 0;
> +
> + for (attr_id = IFLA_OFFLOAD_XSTATS_FIRST;
> +  attr_id <= IFLA_OFFLOAD_XSTATS_MAX; attr_id++) {
> + size = rtnl_get_offload_stats_attr_size(attr_id);
> + if (!size)
> + continue;
> +
> + if (!dev->netdev_ops->ndo_has_offload_stats(attr_id))
> + continue;
> +
> + attr = nla_reserve_64bit(skb, attr_id, size,
> +  IFLA_OFFLOAD_XSTATS_UNSPEC);
> + if (!attr)
> + return -EMSGSIZE;

you need this 64bit alignment padding only for the specific nested attribute
your driver is adding ?. The code seems to add it unconditionally for every 
attribute.
But, I am guessing future attribute authors will need to adjust this somehow.

> +
> + attr_data = nla_data(attr);
> + memset(attr_data, 0, size);
> + err = dev->netdev_ops->ndo_get_offload_stats(attr_id, dev,
> +  attr_data);
> + if (err)
> + return err;
> + }
> +
> + return 0;
> +}
> +
> +static int rtnl_get_offload_stats_size(const struct net_device *dev)
> +{
> + int size = 0;
> + int attr_id;
> +
> + if (!(dev->netdev_ops && dev->netdev_ops->ndo_has_offload_stats &&
> +   dev->netdev_ops->ndo_get_offload_stats))
> + return nla_total_size(0);
> +
> + for (attr_id = IFLA_OFFLOAD_XSTATS_FIRST;
> +  attr_id <= IFLA_OFFLOAD_XSTATS_MAX; attr_id++) {
> + if (!dev->netdev_ops->ndo_has_offload_stats(attr_id))
> + continue;
> +
> + size += rtnl_get_offload_stats_attr_size(attr_id);
> + }
> +
> + size += nla_total_size(0);
> +
> + return size;
> +}
> +
>  static int rtnl_fill_statsinfo(struct sk_buff *skb, struct net_device *dev,
>  int type, u32 pid, u32 seq, u32 change,
>  unsigned int flags, unsigned int filter_mask,
> @@ -3586,6 +3654,7 @@ static int rtnl_fill_statsinfo(struct sk_buff *skb, 
> struct net_device *dev,
>   struct nlmsghdr *nlh;
>   struct nlattr *attr;
>   int s_prividx = *prividx;
> + int err;
>  
>   ASSERT_RTNL();
>  
> @@ -3614,8 +3683,6 @@ static int rtnl_fill_statsinfo(struct sk_buff *skb, 
> struct net_device *dev,
>   const struct rtnl_link_ops *ops = dev->rtnl_link_ops;
>  
>   if (ops && ops->fill_linkxstats) {
> - int err;
> -
>   

Re: [PATCH v5 nf] netfilter: seqadj: Drop the packet directly when fail to add seqadj extension to avoid dereference NULL pointer later

2016-09-06 Thread Florian Westphal
f...@ikuai8.com  wrote:
> From: Gao Feng 
> 
> When memory is exhausted, nfct_seqadj_ext_add may fail to add the seqadj
> extension. But the function nf_ct_seqadj_init doesn't check if get valid
> seqadj pointer by the nfct_seqadj.
> 
> Now drop the packet directly when fail to add seqadj extension to avoid
> dereference NULL pointer in nf_ct_seqadj_init.
> 
> Signed-off-by: Gao Feng 
> ---
>  v5: Return NF_ACCEPT instead of NF_DROP when nfct_seqadj_ext_add failed in 
> nf_nat_setup_info
>  v4: Drop the packet directly when fail to add seqadj extension;
>  v3: Remove the warning log when seqadj is null;
>  v2: Remove the unnessary seqadj check in nf_ct_seq_adjust
>  v1: Initial patch
> 
>  net/netfilter/nf_conntrack_core.c | 6 +-
>  net/netfilter/nf_nat_core.c   | 3 ++-
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/net/netfilter/nf_conntrack_core.c 
> b/net/netfilter/nf_conntrack_core.c
> index dd2c43a..dfa76ce 100644
> --- a/net/netfilter/nf_conntrack_core.c
> +++ b/net/netfilter/nf_conntrack_core.c
> @@ -1036,7 +1036,11 @@ init_conntrack(struct net *net, struct nf_conn *tmpl,
>   return (struct nf_conntrack_tuple_hash *)ct;
>  
>   if (tmpl && nfct_synproxy(tmpl)) {
> - nfct_seqadj_ext_add(ct);
> + if (!nfct_seqadj_ext_add(ct)) {
> + nf_conntrack_free(ct);
> + pr_debug("Can't add seqadj extension\n");
> + return NULL;
> + }

if (!nfct_add_synrpxy(ct, tmpl)) {
nf_conntrack_free(ct);
return NULL;
}

static bool nf_ct_add_synproxy(struct nf_conn *ct, const struct nf_conn *tmpl)
{
if (tmpl && nfct_synproxy(tmpl)) {
if (!nfct_seqadj_ext_add(ct))
return false;

if (!nfct_synproxy_ext_add(ct))
return false;
}

return true;
}

> diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
> index de31818..f8b916a 100644
> --- a/net/netfilter/nf_nat_core.c
> +++ b/net/netfilter/nf_nat_core.c
> @@ -441,7 +441,8 @@ nf_nat_setup_info(struct nf_conn *ct,
>   ct->status |= IPS_DST_NAT;
>  
>   if (nfct_help(ct))
> - nfct_seqadj_ext_add(ct);
> + if (!nfct_seqadj_ext_add(ct))
> + return NF_ACCEPT;
>   }

Hmm, why accept?

We are asked to add extension to rewrite sequence numbers, but
we cannot.  How can the connection work if we cannot munge/track
seqno rewrites?


Re: [patch net-next RFC 1/2] fib: introduce fib notification infrastructure

2016-09-06 Thread David Ahern
On 9/6/16 8:44 AM, Jiri Pirko wrote:
> Tue, Sep 06, 2016 at 04:32:12PM CEST, d...@cumulusnetworks.com wrote:
>> On 9/6/16 6:01 AM, Jiri Pirko wrote:
>>> From: Jiri Pirko 
>>>
>>> This allows to pass information about added/deleted fib entries to
>>> whoever is interested. This is done in a very similar way as devinet
>>> notifies address additions/removals.
>>>
>>> Signed-off-by: Jiri Pirko 
>>> ---
>>>  include/net/ip_fib.h | 19 +++
>>>  net/ipv4/fib_trie.c  | 43 +++
>>>  2 files changed, 62 insertions(+)
>>>
>>
>> The notifier infrastructure should be generalized for use with IPv4 and 
>> IPv6. While the data will be family based, the infra can be generic.
>>
> 
> Yeah, that I thought about as well. Thing is, ipv6 notifier has to be
> atomic. That is the reason we have:
> inetaddr_chain and register_inetaddr_notifier (blocking notifier)
> inet6addr_chain and register_inet6addr_notifier (atomic notifier)
> 

Why is IPv6 atomic? Looking at code paths for adding addresses seems like all 
of the locks are dropped before the notifier is called and adding and deleting 
ipv6 addresses does not show a hit with this WARN_ON:


diff --git a/net/ipv6/addrconf_core.c b/net/ipv6/addrconf_core.c
index bfa941fc1165..4f9f964d95e5 100644
--- a/net/ipv6/addrconf_core.c
+++ b/net/ipv6/addrconf_core.c
@@ -103,6 +103,7 @@ EXPORT_SYMBOL(unregister_inet6addr_notifier);

 int inet6addr_notifier_call_chain(unsigned long val, void *v)
 {
+WARN_ON(in_atomic());
return atomic_notifier_call_chain(_chain, val, v);
 }
 EXPORT_SYMBOL(inet6addr_notifier_call_chain);


[PATCH v5 nf] netfilter: seqadj: Drop the packet directly when fail to add seqadj extension to avoid dereference NULL pointer later

2016-09-06 Thread fgao
From: Gao Feng 

When memory is exhausted, nfct_seqadj_ext_add may fail to add the seqadj
extension. But the function nf_ct_seqadj_init doesn't check if get valid
seqadj pointer by the nfct_seqadj.

Now drop the packet directly when fail to add seqadj extension to avoid
dereference NULL pointer in nf_ct_seqadj_init.

Signed-off-by: Gao Feng 
---
 v5: Return NF_ACCEPT instead of NF_DROP when nfct_seqadj_ext_add failed in 
nf_nat_setup_info
 v4: Drop the packet directly when fail to add seqadj extension;
 v3: Remove the warning log when seqadj is null;
 v2: Remove the unnessary seqadj check in nf_ct_seq_adjust
 v1: Initial patch

 net/netfilter/nf_conntrack_core.c | 6 +-
 net/netfilter/nf_nat_core.c   | 3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_conntrack_core.c 
b/net/netfilter/nf_conntrack_core.c
index dd2c43a..dfa76ce 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1036,7 +1036,11 @@ init_conntrack(struct net *net, struct nf_conn *tmpl,
return (struct nf_conntrack_tuple_hash *)ct;
 
if (tmpl && nfct_synproxy(tmpl)) {
-   nfct_seqadj_ext_add(ct);
+   if (!nfct_seqadj_ext_add(ct)) {
+   nf_conntrack_free(ct);
+   pr_debug("Can't add seqadj extension\n");
+   return NULL;
+   }
nfct_synproxy_ext_add(ct);
}
 
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index de31818..f8b916a 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -441,7 +441,8 @@ nf_nat_setup_info(struct nf_conn *ct,
ct->status |= IPS_DST_NAT;
 
if (nfct_help(ct))
-   nfct_seqadj_ext_add(ct);
+   if (!nfct_seqadj_ext_add(ct))
+   return NF_ACCEPT;
}
 
if (maniptype == NF_NAT_MANIP_SRC) {
-- 
1.9.1




Re: [patch net-next RFC 1/2] fib: introduce fib notification infrastructure

2016-09-06 Thread Jiri Pirko
Tue, Sep 06, 2016 at 04:32:12PM CEST, d...@cumulusnetworks.com wrote:
>On 9/6/16 6:01 AM, Jiri Pirko wrote:
>> From: Jiri Pirko 
>> 
>> This allows to pass information about added/deleted fib entries to
>> whoever is interested. This is done in a very similar way as devinet
>> notifies address additions/removals.
>> 
>> Signed-off-by: Jiri Pirko 
>> ---
>>  include/net/ip_fib.h | 19 +++
>>  net/ipv4/fib_trie.c  | 43 +++
>>  2 files changed, 62 insertions(+)
>> 
>
>The notifier infrastructure should be generalized for use with IPv4 and IPv6. 
>While the data will be family based, the infra can be generic.
>

Yeah, that I thought about as well. Thing is, ipv6 notifier has to be
atomic. That is the reason we have:
inetaddr_chain and register_inetaddr_notifier (blocking notifier)
inet6addr_chain and register_inet6addr_notifier (atomic notifier)



Re: [patch net-next v7 0/3] return offloaded stats as default and expose original sw stats

2016-09-06 Thread Roopa Prabhu
On 9/5/16, 10:18 AM, Jiri Pirko wrote:
> From: Jiri Pirko 
>
> The problem we try to handle is about offloaded forwarded packets
> which are not seen by kernel. Let me try to draw it:
>
> port1   port2 (HW stats are counted here)
>   \  /
>\/
> \  /
>  --(A) ASIC --(B)--
> |
>(C)
> |
>CPU (SW stats are counted here)
>
>
> Now we have couple of flows for TX and RX (direction does not matter here):
>
> 1) port1->A->ASIC->C->CPU
>
>For this flow, HW and SW stats are equal.
>
> 2) port1->A->ASIC->C->CPU->C->ASIC->B->port2
>
>For this flow, HW and SW stats are equal.
>
> 3) port1->A->ASIC->B->port2
>
>For this flow, SW stats are 0.
>
> The purpose of this patchset is to provide facility for user to
> find out the difference between flows 1+2 and 3. In other words, user
> will be able to see the statistics for the slow-path (through kernel).
>
> Also note that HW stats are what someone calls "accumulated" stats.
> Every packet counted by SW is also counted by HW. Not the other way around.
>
> As a default the accumulated stats (HW) will be exposed to user
> so the userspace apps can react properly.
>
> This patchset add the SW stats (flows 1+2) under offload related stats, so
> in the future we can expose other offload related stat in a similar way.
>
> ---
>
Acked-by: Roopa Prabhu 
few questions on the two ndo's on specific patches, but, the user api LGTM.

thanks jiri and nogah.




Re: [PATCH] bonding: Prevent deletion of a bond, or the last slave from a bond, with active usage.

2016-09-06 Thread Jiri Pirko
Tue, Sep 06, 2016 at 11:34:30AM CEST, jasminder.k...@hpe.com wrote:
>From: "Kaur, Jasminder" 
>
>If a bond is in use such as with IP address configured, removing it
>can result in application disruptions. If bond is used for cluster
>communication or network file system interfaces, removing it can cause
>system down time.
>
>An additional write option “?-” is added to sysfs bond interfaces as
>below, in order to prevent accidental deletions while bond is in use.
>In the absence of any usage, the below option proceeds with bond deletion.
>“ echo "?-bondX" > /sys/class/net/bonding_masters “ .
>If usage is detected such as an IP address configured, deletion is
>prevented with appropriate message logged to syslog.
>
>In the absence of any usage, the below option proceeds with deletion of
>slaves from a bond.
>“ echo "?-enoX" > /sys/class/net/bondX/bonding/slaves “ .
>If usage is detected such as an IP address configured on bond, deletion
>is prevented if the last slave is being removed from bond.
>An appropriate message is logged to syslog.

NACK

sysfs bonding iface should die in peace, don't poke in it.

Either fix you application or fix you configuration flow. Don't do this
in kernel.




Re: [PATCH 249/249] net:ethernet:intel:igb_main.c: Add Throttling disable option in order to decrease latency usually required by RT applications.

2016-09-06 Thread Steven Rostedt
On Tue, 6 Sep 2016 13:17:04 +
Amir Yihie  wrote:

> 

I guess there's not much to do here?

-- Steve


Re: [PATCH net-next V5 4/4] net/sched: Introduce act_tunnel_key

2016-09-06 Thread Hadar Hen Zion
On Tue, Sep 6, 2016 at 5:11 PM, Eric Dumazet  wrote:
> On Sun, 2016-09-04 at 13:55 +0300, Hadar Hen Zion wrote:
>> From: Amir Vadai 
>
> ...
>
>> +struct tcf_tunnel_key_params {
>> + struct rcu_head rcu;
>> + int tcft_action;
>> + int action;
>> + struct metadata_dst *tcft_enc_metadata;
>> +};
>> +
>> +struct tcf_tunnel_key {
>> + struct tc_action  common;
>> + struct tcf_tunnel_key_params *params;
>
> In order to please sparse you must add __rcu qualifier, as in :
>
> struct tcf_tunnel_key_params __rcu *params;

Thanks!


>
>> +};
>> +
>
> Thanks.
>
>
>


  1   2   >