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

2016-10-27 Thread Y.B. Lu
> -Original Message-
> From: Y.B. Lu
> Sent: Friday, October 28, 2016 2:00 PM
> To: 'Scott Wood'; linux-...@vger.kernel.org; ulf.hans...@linaro.org; Arnd
> Bergmann
> Cc: linuxppc-...@lists.ozlabs.org; devicet...@vger.kernel.org; linux-arm-
> ker...@lists.infradead.org; linux-ker...@vger.kernel.org; linux-
> c...@vger.kernel.org; linux-...@vger.kernel.org; iommu@lists.linux-
> foundation.org; netdev@vger.kernel.org; Greg Kroah-Hartman; Mark Rutland;
> Rob Herring; Russell King; Jochen Friedrich; Joerg Roedel; Claudiu Manoil;
> Bhupesh Sharma; Qiang Zhao; Kumar Gala; Santosh Shilimkar; Leo Li; X.B.
> Xie; M.H. Lian
> Subject: RE: [v13, 5/8] soc: fsl: add GUTS driver for QorIQ platforms
> 
> 
> 
> > -Original Message-
> > From: linux-mmc-ow...@vger.kernel.org [mailto:linux-mmc-
> > ow...@vger.kernel.org] On Behalf Of Scott Wood
> > Sent: Friday, October 28, 2016 12:46 PM
> > To: Y.B. Lu; linux-...@vger.kernel.org; ulf.hans...@linaro.org; Arnd
> > Bergmann
> > Cc: linuxppc-...@lists.ozlabs.org; devicet...@vger.kernel.org;
> > linux-arm- ker...@lists.infradead.org; linux-ker...@vger.kernel.org;
> > linux- c...@vger.kernel.org; linux-...@vger.kernel.org;
> > iommu@lists.linux- foundation.org; netdev@vger.kernel.org; Greg
> > Kroah-Hartman; Mark Rutland; Rob Herring; Russell King; Jochen
> > Friedrich; Joerg Roedel; Claudiu Manoil; Bhupesh Sharma; Qiang Zhao;
> Kumar Gala; Santosh Shilimkar; Leo Li; X.B.
> > Xie; M.H. Lian
> > Subject: Re: [v13, 5/8] soc: fsl: add GUTS driver for QorIQ platforms
> >
> > On Fri, 2016-10-28 at 11:32 +0800, Yangbo Lu wrote:
> > > + guts->regs = of_iomap(np, 0);
> > > + if (!guts->regs)
> > > + return -ENOMEM;
> > > +
> > > + /* Register soc device */
> > > + machine = of_flat_dt_get_machine_name();
> > > + if (machine)
> > > + soc_dev_attr.machine = devm_kstrdup(dev, machine,
> > > GFP_KERNEL);
> > > +
> > > + svr = fsl_guts_get_svr();
> > > + soc_die = fsl_soc_die_match(svr, fsl_soc_die);
> > > + if (soc_die) {
> > > + soc_dev_attr.family = devm_kasprintf(dev, GFP_KERNEL,
> > > +  "QorIQ %s", soc_die-
> > > >die);
> > > + } else {
> > > + soc_dev_attr.family = devm_kasprintf(dev, GFP_KERNEL,
> > > "QorIQ");
> > > + }
> > > + soc_dev_attr.soc_id = devm_kasprintf(dev, GFP_KERNEL,
> > > +  "svr:0x%08x", svr);
> > > + soc_dev_attr.revision = devm_kasprintf(dev, GFP_KERNEL, "%d.%d",
> > > +    SVR_MAJ(svr), SVR_MIN(svr));
> > > +
> > > + soc_dev = soc_device_register(&soc_dev_attr);
> > > + if (IS_ERR(soc_dev))
> > > + return PTR_ERR(soc_dev);
> >
> > ioremap leaks on this error path.  Use devm_ioremap_resource().
> >
> 
> [Lu Yangbo-B47093] Ok. I have fixed it in v14. Thanks :)

[Lu Yangbo-B47093] Sorry, used the wrong error code... Will resent it

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


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

2016-10-27 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
Changes for v12:
- None
Changes for v13:
- None
Changes for v14:
- 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



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

2016-10-27 Thread Yangbo Lu
From: Arnd Bergmann 

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 
Acked-by: Greg Kroah-Hartman 
---
Changes for v11:
- Added this patch for soc match
Changes for v12:
- Corrected the author
- Rewrited soc_device_match with while loop
Changes for v13:
- Added ack from Greg
Changes for v14:
- None
---
 drivers/base/Kconfig|  1 +
 drivers/base/soc.c  | 66 +
 include/linux/sys_soc.h |  3 +++
 3 files changed, 70 insertions(+)

diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index fdf44ca..991b21e 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -235,6 +235,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 b63f23e..0c5cf87 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static DEFINE_IDA(soc_ida);
 
@@ -159,3 +160,68 @@ static int __init soc_bus_register(void)
return bus_register(&soc_bus_type);
 }
 core_initcall(soc_bus_register);
+
+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)
+{
+   int ret = 0;
+
+   if (!matches)
+   return NULL;
+
+   while (!ret) {
+   if (!(matches->machine || matches->family ||
+ matches->revision || matches->soc_id))
+   break;
+   ret = bus_for_each_dev(&soc_bus_type, NULL, (void *)matches,
+  soc_device_match_one);
+   if (!ret)
+   matches++;
+   else
+   return matches;
+   }
+   return NULL;
+}
+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

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

2016-10-27 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 
---
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
Changes for v12:
- Removed "signed-off-by: Scott"
- Defined fsl_soc_die_attr struct array instead of
  soc_device_attribute
- Re-designed soc_device_attribute for QorIQ SoC
- Other minor fixes
Changes for v13:
- Rebased
- Removed text after 'bool' in Kconfig
- Removed ARCH ifdefs
- Added more bits for ls1021a mask
- Used devm
Changes for v14:
- Used devm_ioremap_resource
---
 drivers/soc/Kconfig  |   3 +-
 drivers/soc/fsl/Kconfig  |  18 
 drivers/soc/fsl/Makefile |   1 +
 drivers/soc/fsl/guts.c   | 237 +++
 include/linux/fsl/guts.h | 125 +++--
 5 files changed, 334 insertions(+), 50 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 e6e90e8..f31bceb 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -1,8 +1,7 @@
 menu "SOC (System On Chip) specific Drivers"
 
 source "drivers/soc/bcm/Kconfig"
-source "drivers/soc/fsl/qbman/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..7a9fb9b
--- /dev/null
+++ b/drivers/soc/fsl/Kconfig
@@ -0,0 +1,18 @@
+#
+# Freescale SOC drivers
+#
+
+source "drivers/soc/fsl/qbman/Kconfig"
+source "drivers/soc/fsl/qe/Kconfig"
+
+config FSL_GUTS
+   bool
+   select SOC_BUS
+   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.
diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
index 75e1f53..44b3beb 100644
--- a/drivers/soc/fsl/Makefile
+++ b/drivers/soc/fsl/Makefile
@@ -5,3 +5,4 @@
 obj-$(CONFIG_FSL_DPAA) += qbman/
 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..16d9744
--- /dev/null
+++ b/drivers/soc/fsl/guts.c
@@ -0,0 +1,237 @@
+/*
+ * 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 
+
+struct guts {
+   struct ccsr_guts __iomem *regs;
+   bool little_endian;
+};
+
+struct fsl_soc_die_attr {
+   char*die;
+   u32 svr;
+   u32 mask;
+};
+
+static struct guts *guts;
+static struct soc_device_attribute soc_dev_attr;
+static struct soc_device *soc_dev;
+
+
+/* SoC die attribute definition for QorIQ platform */
+static const struct fsl_soc_die_attr fsl_soc_die[] = {
+   /*
+* Power Architecture-based SoCs T Series

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

2016-10-27 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
Changes for v12:
- None
Changes for v13:
- None
Changes for v14:
- None
---
 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 d3a5974..cb0efea 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 20b1055..dc778e8 100644
--- a/drivers/clk/clk-qoriq.c
+++ b/drivers/clk/clk-qoriq.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1153,8 +1154,6 @@ static struct clk *clockgen_clk_get(struct 
of_phandle_args *clkspec, void *data)
 }
 
 #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 565a49a..e791c51 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 4b4f5bc..55be5ce 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



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

2016-10-27 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
Changes for v12:
- Matched soc through .family field instead of .soc_id
Changes for v13:
- None
Changes for v14:
- None
---
 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..57bdb9e 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 = &sdhci_esdhc_le_ops,
 };
 
+static struct soc_device_attribute soc_incorrect_hostver[] = {
+   { .family = "QorIQ T4240", .revision = "1.0", },
+   { .family = "QorIQ 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



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

2016-10-27 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
Changes for v12:
- None
Changes for v13:
- None
Changes for v14:
- None
---
 MAINTAINERS | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index c72fa18..cf3aaee 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5037,9 +5037,18 @@ S:   Maintained
 F: drivers/net/ethernet/freescale/fman
 F: Documentation/devicetree/bindings/powerpc/fsl/fman.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



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

2016-10-27 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
Changes for v12:
- None
Changes for v13:
- None
Changes for v14:
- 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 337da90..c03b099 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi
@@ -215,6 +215,12 @@
clocks = <&sysclk>;
};
 
+   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



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

2016-10-27 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 of Yangbo are to add the GUTS driver. This is used to
register a soc device which contain soc version and revision information.
The other two patches introduce the soc_device_match method in soc driver
and apply it on esdhc driver to fix this bug.

Arnd Bergmann (1):
  base: soc: introduce soc_device_match() interface

Yangbo Lu (7):
  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
  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 |  66 ++
 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|   3 +-
 drivers/soc/fsl/Kconfig|  18 ++
 drivers/soc/fsl/Makefile   |   1 +
 drivers/soc/fsl/guts.c | 238 +
 include/linux/fsl/guts.h   | 125 ++-
 .../asm/mpc85xx.h => include/linux/fsl/svr.h   |   4 +-
 include/linux/sys_soc.h|   3 +
 21 files changed, 458 insertions(+), 62 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



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

2016-10-27 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
Changes for v12:
- None
Changes for v13:
- None
Changes for v14:
- None
---
 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



Re: [PATCH v2] ip6_tunnel: Clear IP6CB in ip6_tnl_xmit() after encapsulation

2016-10-27 Thread Eli Cooper
On 2016/10/28 10:17, Tom Herbert wrote:
> On Thu, Oct 27, 2016 at 6:52 PM, Eli Cooper  wrote:
>> > skb->cb may contain data from previous layers. In the observed scenario,
>> > the garbage data were misinterpreted as IP6CB(skb)->frag_max_size, so
>> > that small packets sent through the tunnel are mistakenly fragmented.
>> >
>> > This patch clears the control buffer for the next layer, after an IPv6
>> > header is installed.
>> >
> Nice catch, but can you rectify this with what udp_tunnel6_xmit_skb is
> doing. udp_tunnel6_xmit_skb calls ip6tunnel_xmit directly. Looks like
> we do
>
> memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
> IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED
> | IPSKB_REROUTED);
>
> Is this what we should be doing in ip6_tnl_xmit also, or is
> udp_tunnel6_xmit_skb broken because it doesn't zero all the cb?

udp_tunnel6_xmit_skb() is also broken, I can confirm. Actually I found
it pretty easy to reproduce by having a netns or router forwarding
between two tunnels established with another two namespaces or hosts.
The router sends out packets with IPv6 Fragment headers, even when the
packet is too small to really get fragmented.

The control buffer, by definition, is private to the layer having the
skb queued at the moment. As David has pointed out in v1 of this patch,
cb is either interpreted as IPCB or as IP6CB, and in this case, it will
be IP6CB after ip6tunnel_xmit(). So I think it is best that all the
IP6CB gets cleared before it is pushed to the next layer. Maybe we
should clear IP6CB in ip6tunnel_xmit(), rather than in every tunnel's codes?

By the way, I don't see any point in setting IPCB(skb)->flags in
udp_tunnel6_xmit_skb(). It will not be interpreted as IPCB any further
past ip6tunnel_xmit(), even if it were not cleared. Plus, nothing seems
to use these flags anyway.

Thanks,
Eli


Did You Get My Message This Time?

2016-10-27 Thread Friedrich Mayrhofer



This is the second time i am sending you this mail.I, Friedrich Mayrhofer 
Donate $ 1,000,000.00 to You, Email  Me personally for more details.

Regards.
Friedrich Mayrhofer


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

2016-10-27 Thread Scott Wood
On Fri, 2016-10-28 at 11:32 +0800, Yangbo Lu wrote:
> + guts->regs = of_iomap(np, 0);
> + if (!guts->regs)
> + return -ENOMEM;
> +
> + /* Register soc device */
> + machine = of_flat_dt_get_machine_name();
> + if (machine)
> + soc_dev_attr.machine = devm_kstrdup(dev, machine,
> GFP_KERNEL);
> +
> + svr = fsl_guts_get_svr();
> + soc_die = fsl_soc_die_match(svr, fsl_soc_die);
> + if (soc_die) {
> + soc_dev_attr.family = devm_kasprintf(dev, GFP_KERNEL,
> +  "QorIQ %s", soc_die-
> >die);
> + } else {
> + soc_dev_attr.family = devm_kasprintf(dev, GFP_KERNEL,
> "QorIQ");
> + }
> + soc_dev_attr.soc_id = devm_kasprintf(dev, GFP_KERNEL,
> +  "svr:0x%08x", svr);
> + soc_dev_attr.revision = devm_kasprintf(dev, GFP_KERNEL, "%d.%d",
> +    SVR_MAJ(svr), SVR_MIN(svr));
> +
> + soc_dev = soc_device_register(&soc_dev_attr);
> + if (IS_ERR(soc_dev))
> + return PTR_ERR(soc_dev);

ioremap leaks on this error path.  Use devm_ioremap_resource().

-Scott



Hope you received my message

2016-10-27 Thread Friedrich Mayrhofer


-- 
This is the second time i am sending you this mail.
I, Friedrich Mayrhofer Donate $ 1,000,000.00 to You, Email  Me personally for 
more details.
Regards.Friedrich Mayrhofer


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

2016-10-27 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
Changes for v12:
- Matched soc through .family field instead of .soc_id
Changes for v13:
- None
---
 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..57bdb9e 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 = &sdhci_esdhc_le_ops,
 };
 
+static struct soc_device_attribute soc_incorrect_hostver[] = {
+   { .family = "QorIQ T4240", .revision = "1.0", },
+   { .family = "QorIQ 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



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

2016-10-27 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
Changes for v12:
- None
Changes for v13:
- None
---
 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 d3a5974..cb0efea 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 20b1055..dc778e8 100644
--- a/drivers/clk/clk-qoriq.c
+++ b/drivers/clk/clk-qoriq.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1153,8 +1154,6 @@ static struct clk *clockgen_clk_get(struct 
of_phandle_args *clkspec, void *data)
 }
 
 #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 565a49a..e791c51 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 4b4f5bc..55be5ce 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



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

2016-10-27 Thread Yangbo Lu
From: Arnd Bergmann 

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 
Acked-by: Greg Kroah-Hartman 
---
Changes for v11:
- Added this patch for soc match
Changes for v12:
- Corrected the author
- Rewrited soc_device_match with while loop
Changes for v13:
- Added ack from Greg
---
 drivers/base/Kconfig|  1 +
 drivers/base/soc.c  | 66 +
 include/linux/sys_soc.h |  3 +++
 3 files changed, 70 insertions(+)

diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index fdf44ca..991b21e 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -235,6 +235,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 b63f23e..0c5cf87 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static DEFINE_IDA(soc_ida);
 
@@ -159,3 +160,68 @@ static int __init soc_bus_register(void)
return bus_register(&soc_bus_type);
 }
 core_initcall(soc_bus_register);
+
+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)
+{
+   int ret = 0;
+
+   if (!matches)
+   return NULL;
+
+   while (!ret) {
+   if (!(matches->machine || matches->family ||
+ matches->revision || matches->soc_id))
+   break;
+   ret = bus_for_each_dev(&soc_bus_type, NULL, (void *)matches,
+  soc_device_match_one);
+   if (!ret)
+   matches++;
+   else
+   return matches;
+   }
+   return NULL;
+}
+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

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

2016-10-27 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
Changes for v12:
- None
Changes for v13:
- 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



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

2016-10-27 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 
---
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
Changes for v12:
- Removed "signed-off-by: Scott"
- Defined fsl_soc_die_attr struct array instead of
  soc_device_attribute
- Re-designed soc_device_attribute for QorIQ SoC
- Other minor fixes
Changes for v13:
- Rebased
- Removed text after 'bool' in Kconfig
- Removed ARCH ifdefs
- Added more bits for ls1021a mask
- Used devm
---
 drivers/soc/Kconfig  |   3 +-
 drivers/soc/fsl/Kconfig  |  18 
 drivers/soc/fsl/Makefile |   1 +
 drivers/soc/fsl/guts.c   | 236 +++
 include/linux/fsl/guts.h | 125 +++--
 5 files changed, 333 insertions(+), 50 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 e6e90e8..f31bceb 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -1,8 +1,7 @@
 menu "SOC (System On Chip) specific Drivers"
 
 source "drivers/soc/bcm/Kconfig"
-source "drivers/soc/fsl/qbman/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..7a9fb9b
--- /dev/null
+++ b/drivers/soc/fsl/Kconfig
@@ -0,0 +1,18 @@
+#
+# Freescale SOC drivers
+#
+
+source "drivers/soc/fsl/qbman/Kconfig"
+source "drivers/soc/fsl/qe/Kconfig"
+
+config FSL_GUTS
+   bool
+   select SOC_BUS
+   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.
diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
index 75e1f53..44b3beb 100644
--- a/drivers/soc/fsl/Makefile
+++ b/drivers/soc/fsl/Makefile
@@ -5,3 +5,4 @@
 obj-$(CONFIG_FSL_DPAA) += qbman/
 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..1f356ed
--- /dev/null
+++ b/drivers/soc/fsl/guts.c
@@ -0,0 +1,236 @@
+/*
+ * 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 
+
+struct guts {
+   struct ccsr_guts __iomem *regs;
+   bool little_endian;
+};
+
+struct fsl_soc_die_attr {
+   char*die;
+   u32 svr;
+   u32 mask;
+};
+
+static struct guts *guts;
+static struct soc_device_attribute soc_dev_attr;
+static struct soc_device *soc_dev;
+
+
+/* SoC die attribute definition for QorIQ platform */
+static const struct fsl_soc_die_attr fsl_soc_die[] = {
+   /*
+* Power Architecture-based SoCs T Series
+*/
+
+   /* Die: T4240, SoC: T4240/T4160

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

2016-10-27 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 of Yangbo are to add the GUTS driver. This is used to
register a soc device which contain soc version and revision information.
The other two patches introduce the soc_device_match method in soc driver
and apply it on esdhc driver to fix this bug.

Arnd Bergmann (1):
  base: soc: introduce soc_device_match() interface

Yangbo Lu (7):
  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
  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 |  66 ++
 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|   3 +-
 drivers/soc/fsl/Kconfig|  18 ++
 drivers/soc/fsl/Makefile   |   1 +
 drivers/soc/fsl/guts.c | 236 +
 include/linux/fsl/guts.h   | 125 ++-
 .../asm/mpc85xx.h => include/linux/fsl/svr.h   |   4 +-
 include/linux/sys_soc.h|   3 +
 21 files changed, 456 insertions(+), 62 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



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

2016-10-27 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
Changes for v12:
- None
Changes for v13:
- None
---
 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



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

2016-10-27 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
Changes for v12:
- None
Changes for v13:
- 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 337da90..c03b099 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi
@@ -215,6 +215,12 @@
clocks = <&sysclk>;
};
 
+   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 v2 2/9] ipv6: sr: add code base for control plane support of SR-IPv6

2016-10-27 Thread Tom Herbert
On Wed, Oct 26, 2016 at 8:54 AM, David Lebrun  wrote:
> This patch adds the necessary hooks and structures to provide support
> for SR-IPv6 control plane, essentially the Generic Netlink commands
> that will be used for userspace control over the Segment Routing
> kernel structures.
>
> The genetlink commands provide control over two different structures:
> tunnel source and HMAC data. The tunnel source is the source address
> that will be used by default when encapsulating packets into an
> outer IPv6 header + SRH. If the tunnel source is set to :: then an
> address of the outgoing interface will be selected as the source.
>
> The HMAC commands currently just return ENOTSUPP and will be implemented
> in a future patch.
>
> Signed-off-by: David Lebrun 
> ---
>  include/linux/seg6_genl.h  |   6 ++
>  include/net/netns/ipv6.h   |   1 +
>  include/net/seg6.h |  30 ++
>  include/uapi/linux/seg6_genl.h |  32 ++
>  net/ipv6/Makefile  |   2 +-
>  net/ipv6/seg6.c| 214 
> +
>  6 files changed, 284 insertions(+), 1 deletion(-)
>  create mode 100644 include/linux/seg6_genl.h
>  create mode 100644 include/net/seg6.h
>  create mode 100644 include/uapi/linux/seg6_genl.h
>  create mode 100644 net/ipv6/seg6.c
>
> diff --git a/include/linux/seg6_genl.h b/include/linux/seg6_genl.h
> new file mode 100644
> index 000..d6c3fb4f
> --- /dev/null
> +++ b/include/linux/seg6_genl.h
> @@ -0,0 +1,6 @@
> +#ifndef _LINUX_SEG6_GENL_H
> +#define _LINUX_SEG6_GENL_H
> +
> +#include 
> +
> +#endif
> diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
> index 10d0848..de7745e 100644
> --- a/include/net/netns/ipv6.h
> +++ b/include/net/netns/ipv6.h
> @@ -85,6 +85,7 @@ struct netns_ipv6 {
>  #endif
> atomic_tdev_addr_genid;
> atomic_tfib6_sernum;
> +   struct seg6_pernet_data *seg6_data;
>  };
>
>  #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
> diff --git a/include/net/seg6.h b/include/net/seg6.h
> new file mode 100644
> index 000..a9d9a9b
> --- /dev/null
> +++ b/include/net/seg6.h
> @@ -0,0 +1,30 @@
> +/*
> + *  SR-IPv6 implementation
> + *
> + *  Author:
> + *  David Lebrun 
> + *
> + *
> + *  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_SEG6_H
> +#define _NET_SEG6_H
> +
> +#include 
> +#include 
> +
> +struct seg6_pernet_data {
> +   struct mutex lock;
> +   struct in6_addr __rcu *tun_src;
> +};
> +
> +static inline struct seg6_pernet_data *seg6_pernet(struct net *net)
> +{
> +   return net->ipv6.seg6_data;
> +}
> +
> +#endif
> diff --git a/include/uapi/linux/seg6_genl.h b/include/uapi/linux/seg6_genl.h
> new file mode 100644
> index 000..fcf1c60
> --- /dev/null
> +++ b/include/uapi/linux/seg6_genl.h
> @@ -0,0 +1,32 @@
> +#ifndef _UAPI_LINUX_SEG6_GENL_H
> +#define _UAPI_LINUX_SEG6_GENL_H
> +
> +#define SEG6_GENL_NAME "SEG6"
> +#define SEG6_GENL_VERSION  0x1
> +
> +enum {
> +   SEG6_ATTR_UNSPEC,
> +   SEG6_ATTR_DST,
> +   SEG6_ATTR_DSTLEN,
> +   SEG6_ATTR_HMACKEYID,
> +   SEG6_ATTR_SECRET,
> +   SEG6_ATTR_SECRETLEN,
> +   SEG6_ATTR_ALGID,
> +   SEG6_ATTR_HMACINFO,
> +   __SEG6_ATTR_MAX,
> +};
> +
> +#define SEG6_ATTR_MAX (__SEG6_ATTR_MAX - 1)
> +
> +enum {
> +   SEG6_CMD_UNSPEC,
> +   SEG6_CMD_SETHMAC,
> +   SEG6_CMD_DUMPHMAC,
> +   SEG6_CMD_SET_TUNSRC,
> +   SEG6_CMD_GET_TUNSRC,
> +   __SEG6_CMD_MAX,
> +};
> +
> +#define SEG6_CMD_MAX (__SEG6_CMD_MAX - 1)
> +
> +#endif
> diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile
> index c174ccb..29a77d3 100644
> --- a/net/ipv6/Makefile
> +++ b/net/ipv6/Makefile
> @@ -45,7 +45,7 @@ obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o
>  obj-$(CONFIG_IPV6_GRE) += ip6_gre.o
>  obj-$(CONFIG_IPV6_FOU) += fou6.o
>
> -obj-y += addrconf_core.o exthdrs_core.o ip6_checksum.o ip6_icmp.o
> +obj-y += addrconf_core.o exthdrs_core.o ip6_checksum.o ip6_icmp.o seg6.o
>  obj-$(CONFIG_INET) += output_core.o protocol.o $(ipv6-offload)
>
>  obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o
> diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c
> new file mode 100644
> index 000..24111662
> --- /dev/null
> +++ b/net/ipv6/seg6.c
> @@ -0,0 +1,214 @@
> +/*
> + *  SR-IPv6 implementation
> + *
> + *  Author:
> + *  David Lebrun 
> + *
> + *
> + *  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 
> +

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

2016-10-27 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
Changes for v12:
- None
Changes for v13:
- None
---
 MAINTAINERS | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index c72fa18..cf3aaee 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5037,9 +5037,18 @@ S:   Maintained
 F: drivers/net/ethernet/freescale/fman
 F: Documentation/devicetree/bindings/powerpc/fsl/fman.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 v2 1/5] kconfig: introduce the "imply" keyword

2016-10-27 Thread Nicolas Pitre
On Fri, 28 Oct 2016, Paul Bolle wrote:

> On Tue, 2016-10-25 at 22:28 -0400, Nicolas Pitre wrote:
> > The "imply" keyword is a weak version of "select" where the target
> > config symbol can still be turned off, avoiding those pitfalls that come
> > with the "select" keyword.
> > 
> > This is useful e.g. with multiple drivers that want to indicate their
> > ability to hook into a given subsystem
> 
> "hook into a [...] subsystem" is rather vague.

You could say: benefit from, contribute to, register with, or any 
combination of those. At some point there is no good way to remain 
generic. At least none came to my mind.

> >  while still being able to configure that subsystem out
> 
> s/being able to/allowing the user to/, correct? 

Correct.

> > and keep those drivers selected.
> 
> Perhaps replace that with: "without also having to unset these
> drivers"?

Sure. I currently have:

  This is useful e.g. with multiple drivers that want to indicate their
  ability to hook into an important secondary subsystem while allowing
  the user to configure that subsystem out without also having to unset
  these drivers.

> > +- weak reverse dependencies: "imply"  ["if" ]
> 
> You probably got "["if" ]" for free by copying what's there for
> select. But this series doesn't use it, so perhaps it would be better
> to not document it yet. But that is rather sneaky. Dunno.

If it is not documented then the chance that someone uses it are slim. 
And since it comes "for free" I don't see the point of making the tool 
less flexible. And not having this flexibility could make some 
transitions from "select" to "imply" needlessly difficult.

> > +  This is similar to "select" as it enforces a lower limit on another
> > +  symbol except that the "implied" config symbol's value may still be
> > +  set to n from a direct dependency or with a visible prompt.
> 
> This is seriously hard to parse. But it's late here, so it might just
> be me.

I tried to follow the existing style. I removed the word "config" from 
that paragraph as it looked redundant. Other than that, any improvements 
from someone more inspired than myself is welcome.

> > +  Given the following example:
> > +
> > +  config FOO
> > +   tristate
> > +   imply BAZ
> > +
> > +  config BAZ
> > +   tristate
> > +   depends on BAR
> > +
> > +  The following values are possible:
> > +
> > +   FOO BAR BAZ's default   choice for BAZ
> > +   --- --- -   --
> > +   n   y   n   N/m/y
> > +   m   y   m   M/y/n
> > +   y   y   y   Y/n
> 
> Also
>   n   n   *   N
>   m   n   *   N
> 
> Is that right?

Right.  Is it clearer if I list all combinations, or maybe:

*   n   *   N

> > +   y   n   *   N
> 
> But what does '*' mean?

It's a wildcard meaning either of n, m, or y.

> What happens when a tristate symbol is implied by a symbol set to 'y'
> and by a symbol set to 'm'?

That's respectively the third and second rows in the table above.

> And in your example BAR is bool, right? Does the above get more
> complicated if BAR would be tristate?

If BAR=m then implying BAZ from FOO=y will force BAZ to y or n, 
bypassing the restriction provided by BAR like "select" does.  This is 
somewhat questionable for "select" to do that, and the code emits a 
warning when "select" bypasses a direct dependency set to n, but not 
when set to m. For now "imply" simply tries to be consistent with 
the "select" behavior.

> How does setting a direct default for BAZ interfere with the implied
> values?

It doesn't. An implied symbol may be promoted to a higher value than the 
default, not a lower value. So if the direct default is higher than the 
implied value then the default wins.

> >    b) Match dependency semantics:
> >     b1) Swap all "select FOO" to "depends on FOO" or,
> >     b2) Swap all "depends on FOO" to "select FOO"
> > +  c) Consider the use of "imply" instead of "select"
> 
> If memory serves me right this text was added after a long discussion
> with Luis Rodriguez. Luis might want to have a look at any 

The "imply" statement doesn't create the kind of dependency conflicts as 
"select" does. So I think it is worth mentioning as a possibility here.

> Haven't looked at the code yet, sorry. I'm still trying to see whether
> I can wrap my mind around this. It looks like just setting a default on
> another symbol, but there could be a twist I missed.

Setting a default was the purpose of my "suggest" patch. The "imply" 
statement still imposes a restriction similar to "select" where the 
implied symbol cannot be m if implied with y.

Some people didn't like the fact that you could turn a driver from m to
y and silently lose some features if they w

Re: [PATCH v2 4/9] ipv6: sr: add core files for SR HMAC support

2016-10-27 Thread Tom Herbert
On Wed, Oct 26, 2016 at 8:54 AM, David Lebrun  wrote:
> This patch adds the necessary functions to compute and check the HMAC 
> signature
> of an SR-enabled packet. Two HMAC algorithms are supported: hmac(sha1) and
> hmac(sha256).
>
> In order to avoid dynamic memory allocation for each HMAC computation,
> a per-cpu ring buffer is allocated for this purpose.
>
> Signed-off-by: David Lebrun 
> ---
>  include/linux/seg6_hmac.h  |   6 +
>  include/net/seg6_hmac.h|  61 ++
>  include/uapi/linux/seg6_hmac.h |  20 ++
>  net/ipv6/Kconfig   |  12 ++
>  net/ipv6/seg6_hmac.c   | 432 
> +
>  5 files changed, 531 insertions(+)
>  create mode 100644 include/linux/seg6_hmac.h
>  create mode 100644 include/net/seg6_hmac.h
>  create mode 100644 include/uapi/linux/seg6_hmac.h
>  create mode 100644 net/ipv6/seg6_hmac.c
>
> diff --git a/include/linux/seg6_hmac.h b/include/linux/seg6_hmac.h
> new file mode 100644
> index 000..da437eb
> --- /dev/null
> +++ b/include/linux/seg6_hmac.h
> @@ -0,0 +1,6 @@
> +#ifndef _LINUX_SEG6_HMAC_H
> +#define _LINUX_SEG6_HMAC_H
> +
> +#include 
> +
> +#endif
> diff --git a/include/net/seg6_hmac.h b/include/net/seg6_hmac.h
> new file mode 100644
> index 000..6e5ee6a
> --- /dev/null
> +++ b/include/net/seg6_hmac.h
> @@ -0,0 +1,61 @@
> +/*
> + *  SR-IPv6 implementation
> + *
> + *  Author:
> + *  David Lebrun 
> + *
> + *
> + *  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_SEG6_HMAC_H
> +#define _NET_SEG6_HMAC_H
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define SEG6_HMAC_MAX_DIGESTSIZE   160
> +#define SEG6_HMAC_RING_SIZE256
> +
> +struct seg6_hmac_info {
> +   struct list_head list;
> +
> +   u32 hmackeyid;
> +   char secret[SEG6_HMAC_SECRET_LEN];
> +   u8 slen;
> +   u8 alg_id;
> +};
> +
> +struct seg6_hmac_algo {
> +   u8 alg_id;
> +   char name[64];
> +   struct crypto_shash * __percpu *tfms;
> +   struct shash_desc * __percpu *shashs;
> +};
> +
> +extern int seg6_hmac_compute(struct seg6_hmac_info *hinfo,
> +struct ipv6_sr_hdr *hdr, struct in6_addr *saddr,
> +u8 *output);
> +extern struct seg6_hmac_info *seg6_hmac_info_lookup(struct net *net, u32 
> key);
> +extern int seg6_hmac_info_add(struct net *net, u32 key,
> + struct seg6_hmac_info *hinfo);
> +extern int seg6_hmac_info_del(struct net *net, u32 key,
> + struct seg6_hmac_info *hinfo);
> +extern int seg6_push_hmac(struct net *net, struct in6_addr *saddr,
> + struct ipv6_sr_hdr *srh);
> +extern bool seg6_hmac_validate_skb(struct sk_buff *skb);
> +extern int seg6_hmac_init(void);
> +extern void seg6_hmac_exit(void);
> +extern int seg6_hmac_net_init(struct net *net);
> +extern void seg6_hmac_net_exit(struct net *net);
> +
> +#endif
> diff --git a/include/uapi/linux/seg6_hmac.h b/include/uapi/linux/seg6_hmac.h
> new file mode 100644
> index 000..0b5eda7
> --- /dev/null
> +++ b/include/uapi/linux/seg6_hmac.h
> @@ -0,0 +1,20 @@
> +#ifndef _UAPI_LINUX_SEG6_HMAC_H
> +#define _UAPI_LINUX_SEG6_HMAC_H
> +
> +#define SEG6_HMAC_SECRET_LEN   64
> +#define SEG6_HMAC_FIELD_LEN32
> +
> +struct sr6_tlv_hmac {
> +   __u8 type;
> +   __u8 len;
> +   __u16 reserved;
Maybe add a common definition for SR TLV.

> +   __be32 hmackeyid;
> +   __u8 hmac[SEG6_HMAC_FIELD_LEN];
> +} __attribute__((packed));
> +
> +enum {
> +   SEG6_HMAC_ALGO_SHA1 = 1,
> +   SEG6_HMAC_ALGO_SHA256 = 2,
> +};
> +
> +#endif
> diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
> index 2343e4f..c647712 100644
> --- a/net/ipv6/Kconfig
> +++ b/net/ipv6/Kconfig
> @@ -289,4 +289,16 @@ config IPV6_PIMSM_V2
>   Support for IPv6 PIM multicast routing protocol PIM-SMv2.
>   If unsure, say N.
>
> +config IPV6_SEG6_HMAC
> +   bool "IPv6: Segment Routing HMAC support"
> +   depends on IPV6
> +   select CRYPTO_HMAC
> +   select CRYPTO_SHA1
> +   select CRYPTO_SHA256
> +   ---help---
> + Support for HMAC signature generation and verification
> + of SR-enabled packets.
> +
> + If unsure, say N.
> +
>  endif # IPV6
> diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c
> new file mode 100644
> index 000..65ebc0c
> --- /dev/null
> +++ b/net/ipv6/seg6_hmac.c
> @@ -0,0 +1,432 @@
> +/*
> + *  SR-IPv6 implementation -- HMAC functions
> + *
> + *  Author:
> + *  David Lebrun 
> + *
> + *
> + *  This program is free software; you can redistribute it and/or
> + *  modify it under the terms of the GNU General Public L

Re: [PATCH v2 3/9] ipv6: sr: add support for SRH encapsulation and injection with lwtunnels

2016-10-27 Thread Tom Herbert
On Wed, Oct 26, 2016 at 8:54 AM, David Lebrun  wrote:
> This patch creates a new type of interfaceless lightweight tunnel (SEG6),
> enabling the encapsulation and injection of SRH within locally emitted
> packets and forwarded packets.
>
> From a configuration viewpoint, a seg6 tunnel would be configured as follows:
>
>   ip -6 ro ad fc00::1/128 encap seg6 mode encap segs fc42::1,fc42::2,fc42::3 
> dev eth0
>
> Any packet whose destination address is fc00::1 would thus be encapsulated
> within an outer IPv6 header containing the SRH with three segments, and would
> actually be routed to the first segment of the list. If `mode inline' was
> specified instead of `mode encap', then the SRH would be directly inserted
> after the IPv6 header without outer encapsulation.
>
> Signed-off-by: David Lebrun 
> ---
>  include/linux/seg6_iptunnel.h  |   6 +
>  include/net/seg6.h |   1 +
>  include/uapi/linux/lwtunnel.h  |   1 +
>  include/uapi/linux/seg6_iptunnel.h |  41 
>  net/core/lwtunnel.c|   2 +
>  net/ipv6/Makefile  |   2 +-
>  net/ipv6/seg6_iptunnel.c   | 370 
> +
>  7 files changed, 422 insertions(+), 1 deletion(-)
>  create mode 100644 include/linux/seg6_iptunnel.h
>  create mode 100644 include/uapi/linux/seg6_iptunnel.h
>  create mode 100644 net/ipv6/seg6_iptunnel.c
>
> diff --git a/include/linux/seg6_iptunnel.h b/include/linux/seg6_iptunnel.h
> new file mode 100644
> index 000..5377cf6
> --- /dev/null
> +++ b/include/linux/seg6_iptunnel.h
> @@ -0,0 +1,6 @@
> +#ifndef _LINUX_SEG6_IPTUNNEL_H
> +#define _LINUX_SEG6_IPTUNNEL_H
> +
> +#include 
> +
> +#endif
> diff --git a/include/net/seg6.h b/include/net/seg6.h
> index a9d9a9b..53d3bdb 100644
> --- a/include/net/seg6.h
> +++ b/include/net/seg6.h
> @@ -16,6 +16,7 @@
>
>  #include 
>  #include 
> +#include 
>
>  struct seg6_pernet_data {
> struct mutex lock;
> diff --git a/include/uapi/linux/lwtunnel.h b/include/uapi/linux/lwtunnel.h
> index a478fe8..453cc62 100644
> --- a/include/uapi/linux/lwtunnel.h
> +++ b/include/uapi/linux/lwtunnel.h
> @@ -9,6 +9,7 @@ enum lwtunnel_encap_types {
> LWTUNNEL_ENCAP_IP,
> LWTUNNEL_ENCAP_ILA,
> LWTUNNEL_ENCAP_IP6,
> +   LWTUNNEL_ENCAP_SEG6,
> __LWTUNNEL_ENCAP_MAX,
>  };
>
> diff --git a/include/uapi/linux/seg6_iptunnel.h 
> b/include/uapi/linux/seg6_iptunnel.h
> new file mode 100644
> index 000..da5524a
> --- /dev/null
> +++ b/include/uapi/linux/seg6_iptunnel.h
> @@ -0,0 +1,41 @@
> +/*
> + *  SR-IPv6 implementation
> + *
> + *  Author:
> + *  David Lebrun 
> + *
> + *
> + *  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 _UAPI_LINUX_SEG6_IPTUNNEL_H
> +#define _UAPI_LINUX_SEG6_IPTUNNEL_H
> +
> +enum {
> +   SEG6_IPTUNNEL_UNSPEC,
> +   SEG6_IPTUNNEL_SRH,
> +   __SEG6_IPTUNNEL_MAX,
> +};
> +#define SEG6_IPTUNNEL_MAX (__SEG6_IPTUNNEL_MAX - 1)
> +
> +struct seg6_iptunnel_encap {
> +   int flags;
> +   struct ipv6_sr_hdr srh[0];
> +};
> +
> +#define SEG6_IPTUN_ENCAP_SIZE(x) ((sizeof(*x)) + (((x)->srh->hdrlen + 1) << 
> 3))
> +
> +#define SEG6_IPTUN_FLAG_ENCAP   0x1
> +
> +static inline size_t seg6_lwt_headroom(struct seg6_iptunnel_encap *tuninfo)
> +{
> +   int encap = !!(tuninfo->flags & SEG6_IPTUN_FLAG_ENCAP);
> +
> +   return ((tuninfo->srh->hdrlen + 1) << 3) +
> +  (encap * sizeof(struct ipv6hdr));
> +}
> +
> +#endif
> diff --git a/net/core/lwtunnel.c b/net/core/lwtunnel.c
> index 88fd642..03976e9 100644
> --- a/net/core/lwtunnel.c
> +++ b/net/core/lwtunnel.c
> @@ -39,6 +39,8 @@ static const char *lwtunnel_encap_str(enum 
> lwtunnel_encap_types encap_type)
> return "MPLS";
> case LWTUNNEL_ENCAP_ILA:
> return "ILA";
> +   case LWTUNNEL_ENCAP_SEG6:
> +   return "SEG6";
> case LWTUNNEL_ENCAP_IP6:
> case LWTUNNEL_ENCAP_IP:
> case LWTUNNEL_ENCAP_NONE:
> diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile
> index 29a77d3..4bd1e73 100644
> --- a/net/ipv6/Makefile
> +++ b/net/ipv6/Makefile
> @@ -45,7 +45,7 @@ obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o
>  obj-$(CONFIG_IPV6_GRE) += ip6_gre.o
>  obj-$(CONFIG_IPV6_FOU) += fou6.o
>
> -obj-y += addrconf_core.o exthdrs_core.o ip6_checksum.o ip6_icmp.o seg6.o
> +obj-y += addrconf_core.o exthdrs_core.o ip6_checksum.o ip6_icmp.o seg6.o 
> seg6_iptunnel.o
>  obj-$(CONFIG_INET) += output_core.o protocol.o $(ipv6-offload)
>
>  obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o
> diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
> new file mode 100644
> index 000..caae8ab
> --- /dev/null
> +++ b/net/ipv6/seg6_iptunnel.c
> @@ -0,0 +1,370 @@
> +/*
> + *  SR-IPv6 implemen

RE: [PATCH] e1000e: x86: e1000 driver trying to free already-free irq.

2016-10-27 Thread Brown, Aaron F
> From: netdev-ow...@vger.kernel.org [mailto:netdev-
> ow...@vger.kernel.org] On Behalf Of David Singleton
> Sent: Monday, October 17, 2016 9:51 AM
> To: Kirsher, Jeffrey T 
> Cc: khalidm ; intel-wired-...@lists.osuosl.org;
> netdev@vger.kernel.org; linux-ker...@vger.kernel.org
> Subject: [PATCH] e1000e: x86: e1000 driver trying to free already-free irq.
> 
> From: khalidm 
> 
> During systemd reboot sequence network driver interface is shutdown
> by e1000_close. The PCI driver interface is shut by e1000_shutdown.
> The e1000_shutdown checks for netif_running status, if still up it
> brings down driver. But it disables msi outside of this if statement,
> regardless of netif status. All this is OK when e1000_close happens
> after shutdown. However, by default, everything in systemd is done
> in parallel. This creates a conditions where e1000_shutdown is called
> after e1000_close, therefore hitting BUG_ON assert in free_msi_irqs.
> 
> Cc-Id: xe-ker...@external.cisco.com
> Signed-off-by: khalidm 
> Signed-off-by: David Singleton 
> ---
>  drivers/net/ethernet/intel/e1000e/netdev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Tested-by: Aaron Brown 


Re: [PATCH v2 1/9] ipv6: implement dataplane support for rthdr type 4 (Segment Routing Header)

2016-10-27 Thread Tom Herbert
On Wed, Oct 26, 2016 at 8:54 AM, David Lebrun  wrote:
> Implement minimal support for processing of SR-enabled packets
> as described in
> https://tools.ietf.org/html/draft-ietf-6man-segment-routing-header-02.
>
> This patch implements the following operations:
> - Intermediate segment endpoint: incrementation of active segment and 
> rerouting.
> - Egress for SR-encapsulated packets: decapsulation of outer IPv6 header + SRH
>   and routing of inner packet.
> - Cleanup flag support for SR-inlined packets: removal of SRH if we are the
>   penultimate segment endpoint.
>
> A per-interface sysctl seg6_enabled is provided, to accept/deny SR-enabled
> packets. Default is deny.
>
> This patch does not provide support for HMAC-signed packets.
>
> Signed-off-by: David Lebrun 
> ---
>  include/linux/ipv6.h  |   1 +
>  include/linux/seg6.h  |   6 ++
>  include/uapi/linux/ipv6.h |   2 +
>  include/uapi/linux/seg6.h |  48 
>  net/ipv6/addrconf.c   |  10 +++
>  net/ipv6/exthdrs.c| 183 
> ++
>  6 files changed, 250 insertions(+)
>  create mode 100644 include/linux/seg6.h
>  create mode 100644 include/uapi/linux/seg6.h
>
> diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
> index 7e9a789..76830e6 100644
> --- a/include/linux/ipv6.h
> +++ b/include/linux/ipv6.h
> @@ -64,6 +64,7 @@ struct ipv6_devconf {
> } stable_secret;
> __s32   use_oif_addrs_only;
> __s32   keep_addr_on_down;
> +   __s32   seg6_enabled;
>
> struct ctl_table_header *sysctl_header;
>  };
> diff --git a/include/linux/seg6.h b/include/linux/seg6.h
> new file mode 100644
> index 000..7a66d2b
> --- /dev/null
> +++ b/include/linux/seg6.h
> @@ -0,0 +1,6 @@
> +#ifndef _LINUX_SEG6_H
> +#define _LINUX_SEG6_H
> +
> +#include 
> +
> +#endif
> diff --git a/include/uapi/linux/ipv6.h b/include/uapi/linux/ipv6.h
> index 8c27723..7ff1d65 100644
> --- a/include/uapi/linux/ipv6.h
> +++ b/include/uapi/linux/ipv6.h
> @@ -39,6 +39,7 @@ struct in6_ifreq {
>  #define IPV6_SRCRT_STRICT  0x01/* Deprecated; will be removed */
>  #define IPV6_SRCRT_TYPE_0  0   /* Deprecated; will be removed */
>  #define IPV6_SRCRT_TYPE_2  2   /* IPv6 type 2 Routing Header   */
> +#define IPV6_SRCRT_TYPE_4  4   /* Segment Routing with IPv6 */
>
>  /*
>   * routing header
> @@ -178,6 +179,7 @@ enum {
> DEVCONF_DROP_UNSOLICITED_NA,
> DEVCONF_KEEP_ADDR_ON_DOWN,
> DEVCONF_RTR_SOLICIT_MAX_INTERVAL,
> +   DEVCONF_SEG6_ENABLED,
> DEVCONF_MAX
>  };
>
> diff --git a/include/uapi/linux/seg6.h b/include/uapi/linux/seg6.h
> new file mode 100644
> index 000..7630e7d
> --- /dev/null
> +++ b/include/uapi/linux/seg6.h
> @@ -0,0 +1,48 @@
> +/*
> + *  SR-IPv6 implementation
> + *
> + *  Author:
> + *  David Lebrun 
> + *
> + *
> + *  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 _UAPI_LINUX_SEG6_H
> +#define _UAPI_LINUX_SEG6_H
> +
> +/*
> + * SRH
> + */
> +struct ipv6_sr_hdr {
> +   __u8nexthdr;
> +   __u8hdrlen;
> +   __u8type;
> +   __u8segments_left;
> +   __u8first_segment;
> +   __u8flag_1;
> +   __u8flag_2;
> +   __u8reserved;
> +
> +   struct in6_addr segments[0];
> +};
> +
> +#define SR6_FLAG1_CLEANUP  (1 << 7)
> +#define SR6_FLAG1_PROTECTED(1 << 6)
> +#define SR6_FLAG1_OAM  (1 << 5)
> +#define SR6_FLAG1_ALERT(1 << 4)
> +#define SR6_FLAG1_HMAC (1 << 3)
> +
> +#define SR6_TLV_INGRESS1
> +#define SR6_TLV_EGRESS 2
> +#define SR6_TLV_OPAQUE 3
> +#define SR6_TLV_PADDING4
> +#define SR6_TLV_HMAC   5
> +
> +#define sr_has_cleanup(srh) ((srh)->flag_1 & SR6_FLAG1_CLEANUP)
> +#define sr_has_hmac(srh) ((srh)->flag_1 & SR6_FLAG1_HMAC)
> +
> +#endif
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index d8983e1..8d068ee 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -239,6 +239,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
> .use_oif_addrs_only = 0,
> .ignore_routes_with_linkdown = 0,
> .keep_addr_on_down  = 0,
> +   .seg6_enabled   = 0,
>  };
>
>  static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
> @@ -285,6 +286,7 @@ static struct ipv6_devconf ipv6_devconf_dflt 
> __read_mostly = {
> .use_oif_addrs_only = 0,
> .ignore_routes_with_linkdown = 0,
> .keep_addr_on_down  = 0,
> +   .seg6_enabled   = 0,
>  };
>
>  /* Check if a valid qdisc is available */
> @@ -4965,6 +4967,7 @@ static inline void ipv6_store_devconf(struct 
> ipv6_devconf *cnf,
> 

Re: [net-next PATCH 3/3] net: Add support for XPS with QoS via traffic classes

2016-10-27 Thread Tom Herbert
On Thu, Oct 27, 2016 at 8:40 AM, Alexander Duyck
 wrote:
> This patch adds support for setting and using XPS when QoS via traffic
> classes is enabled.  With this change we will factor in the priority and
> traffic class mapping of the packet and use that information to correctly
> select the queue.
>
> This allows us to define a set of queues for a given traffic class via
> mqprio and then configure the XPS mapping for those queues so that the
> traffic flows can avoid head-of-line blocking between the individual CPUs
> if so desired.
>
Does this change the sys API for XPS? Is it up the user to know which
are priority queues in sys?

Thanks,
Tom

> Signed-off-by: Alexander Duyck 
> ---
>  include/linux/netdevice.h |5 +-
>  net/core/dev.c|  136 
> +
>  net/core/net-sysfs.c  |   31 +++---
>  3 files changed, 122 insertions(+), 50 deletions(-)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index d045432..56f90f7 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -732,8 +732,8 @@ struct xps_dev_maps {
> struct rcu_head rcu;
> struct xps_map __rcu *cpu_map[0];
>  };
> -#define XPS_DEV_MAPS_SIZE (sizeof(struct xps_dev_maps) +   \
> -(nr_cpu_ids * sizeof(struct xps_map *)))
> +#define XPS_DEV_MAPS_SIZE(_tcs) (sizeof(struct xps_dev_maps) + \
> +   (nr_cpu_ids * (_tcs) * sizeof(struct xps_map *)))
>  #endif /* CONFIG_XPS */
>
>  #define TC_MAX_QUEUE   16
> @@ -1920,6 +1920,7 @@ int netdev_set_prio_tc_map(struct net_device *dev, u8 
> prio, u8 tc)
> return 0;
>  }
>
> +int netdev_txq_to_tc(struct net_device *dev, unsigned int txq);
>  void netdev_reset_tc(struct net_device *dev);
>  int netdev_set_tc_queue(struct net_device *dev, u8 tc, u16 count, u16 
> offset);
>  int netdev_set_num_tc(struct net_device *dev, u8 num_tc);
> diff --git a/net/core/dev.c b/net/core/dev.c
> index d124081..37c1096 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -1948,6 +1948,23 @@ static void netif_setup_tc(struct net_device *dev, 
> unsigned int txq)
> }
>  }
>
> +int netdev_txq_to_tc(struct net_device *dev, unsigned int txq)
> +{
> +   if (dev->num_tc) {
> +   struct netdev_tc_txq *tc = &dev->tc_to_txq[0];
> +   int i;
> +
> +   for (i = 0; i < TC_MAX_QUEUE; i++, tc++) {
> +   if ((txq - tc->offset) < tc->count)
> +   return i;
> +   }
> +
> +   return -1;
> +   }
> +
> +   return 0;
> +}
> +
>  #ifdef CONFIG_XPS
>  static DEFINE_MUTEX(xps_map_mutex);
>  #define xmap_dereference(P)\
> @@ -1985,18 +2002,22 @@ static bool remove_xps_queue_cpu(struct net_device 
> *dev,
>  struct xps_dev_maps *dev_maps,
>  int cpu, u16 offset, u16 count)
>  {
> +   int tc = dev->num_tc ? : 1;
> bool active = false;
> -   int i;
> +   int tci;
>
> count += offset;
> -   i = count;
>
> -   do {
> -   if (i-- == offset) {
> -   active = true;
> -   break;
> -   }
> -   } while (remove_xps_queue(dev_maps, cpu, i));
> +   for (tci = cpu * tc; tc--; tci++) {
> +   int i = count;
> +
> +   do {
> +   if (i-- == offset) {
> +   active = true;
> +   break;
> +   }
> +   } while (remove_xps_queue(dev_maps, tci, i));
> +   }
>
> return active;
>  }
> @@ -2075,20 +2096,28 @@ int netif_set_xps_queue(struct net_device *dev, const 
> struct cpumask *mask,
> u16 index)
>  {
> struct xps_dev_maps *dev_maps, *new_dev_maps = NULL;
> +   int i, cpu, tci, numa_node_id = -2;
> +   int maps_sz, num_tc = 1, tc = 0;
> struct xps_map *map, *new_map;
> -   int maps_sz = max_t(unsigned int, XPS_DEV_MAPS_SIZE, L1_CACHE_BYTES);
> -   int cpu, numa_node_id = -2;
> bool active = false;
>
> +   if (dev->num_tc) {
> +   num_tc = dev->num_tc;
> +   tc = netdev_txq_to_tc(dev, index);
> +   if (tc < 0)
> +   return -EINVAL;
> +   }
> +
> +   maps_sz = XPS_DEV_MAPS_SIZE(num_tc);
> +   if (maps_sz < L1_CACHE_BYTES)
> +   maps_sz = L1_CACHE_BYTES;
> +
> mutex_lock(&xps_map_mutex);
>
> dev_maps = xmap_dereference(dev->xps_maps);
>
> /* allocate memory for queue storage */
> -   for_each_online_cpu(cpu) {
> -   if (!cpumask_test_cpu(cpu, mask))
> -   continue;
> -
> +   for_each_cpu_and(cpu, cpu_online_mask, mask) {
> if (!new_dev_maps)
> new_dev_maps = kzalloc(maps_sz, GFP_KERNEL);
> if (!new_dev_maps)

Re: [net-next PATCH 2/3] net: Refactor removal of queues from XPS map and apply on num_tc changes

2016-10-27 Thread Tom Herbert
On Thu, Oct 27, 2016 at 8:40 AM, Alexander Duyck
 wrote:
> This patch updates the code for removing queues from the XPS map and makes
> it so that we can apply the code any time we change either the number of
> traffic classes or the mapping of a given block of queues.  This way we
> avoid having queues pulling traffic from a foreign traffic class.
>
> Signed-off-by: Alexander Duyck 
> ---
>  net/core/dev.c |   79 
> 
>  1 file changed, 56 insertions(+), 23 deletions(-)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index d4d45bf..d124081 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -1953,32 +1953,56 @@ static void netif_setup_tc(struct net_device *dev, 
> unsigned int txq)
>  #define xmap_dereference(P)\
> rcu_dereference_protected((P), lockdep_is_held(&xps_map_mutex))
>
> -static struct xps_map *remove_xps_queue(struct xps_dev_maps *dev_maps,
> -   int cpu, u16 index)
> +static bool remove_xps_queue(struct xps_dev_maps *dev_maps,
> +int tci, u16 index)
>  {
> struct xps_map *map = NULL;
> int pos;
>
> if (dev_maps)
> -   map = xmap_dereference(dev_maps->cpu_map[cpu]);
> +   map = xmap_dereference(dev_maps->cpu_map[tci]);
> +   if (!map)
> +   return false;
>
> -   for (pos = 0; map && pos < map->len; pos++) {
> -   if (map->queues[pos] == index) {
> -   if (map->len > 1) {
> -   map->queues[pos] = map->queues[--map->len];
> -   } else {
> -   RCU_INIT_POINTER(dev_maps->cpu_map[cpu], 
> NULL);
> -   kfree_rcu(map, rcu);
> -   map = NULL;
> -   }
> +   for (pos = map->len; pos--;) {
> +   if (map->queues[pos] != index)
> +   continue;
> +
> +   if (map->len > 1) {
> +   map->queues[pos] = map->queues[--map->len];
> break;
> }
> +
> +   RCU_INIT_POINTER(dev_maps->cpu_map[tci], NULL);
> +   kfree_rcu(map, rcu);
> +   return false;
> }
>
> -   return map;
> +   return true;
>  }
>
> -static void netif_reset_xps_queues_gt(struct net_device *dev, u16 index)
> +static bool remove_xps_queue_cpu(struct net_device *dev,
> +struct xps_dev_maps *dev_maps,
> +int cpu, u16 offset, u16 count)
> +{
> +   bool active = false;
> +   int i;
> +
> +   count += offset;
> +   i = count;
> +
> +   do {
> +   if (i-- == offset) {
> +   active = true;
> +   break;
> +   }
> +   } while (remove_xps_queue(dev_maps, cpu, i));
> +
IMO do/while's are hard to read. Does something like this work:

static bool remove_xps_queue_cpu(struct net_device *dev,
struct xps_dev_maps *dev_maps,
int cpu, u16 offset, u16 count)
{
 int i;

 for (i = count + offset; i > offset; i--)
  if (!remove_xps_queue(dev_maps, cpu, i - 1))
  break;

 return (i == offset);
}

> +   return active;
> +}
> +
> +static void netif_reset_xps_queues(struct net_device *dev, u16 offset,
> +  u16 count)
>  {
> struct xps_dev_maps *dev_maps;
> int cpu, i;
> @@ -1990,21 +2014,16 @@ static void netif_reset_xps_queues_gt(struct 
> net_device *dev, u16 index)
> if (!dev_maps)
> goto out_no_maps;
>
> -   for_each_possible_cpu(cpu) {
> -   for (i = index; i < dev->num_tx_queues; i++) {
> -   if (!remove_xps_queue(dev_maps, cpu, i))
> -   break;
> -   }
> -   if (i == dev->num_tx_queues)
> -   active = true;
> -   }
> +   for_each_possible_cpu(cpu)
> +   active |= remove_xps_queue_cpu(dev, dev_maps, cpu, offset,
> +  count);

Maybe just do dumb "if (remove_xps...) active = true;"

>
> if (!active) {
> RCU_INIT_POINTER(dev->xps_maps, NULL);
> kfree_rcu(dev_maps, rcu);
> }
>
> -   for (i = index; i < dev->num_tx_queues; i++)
> +   for (i = offset + (count - 1); count--; i--)
> netdev_queue_numa_node_write(netdev_get_tx_queue(dev, i),
>  NUMA_NO_NODE);
>
> @@ -2012,6 +2031,11 @@ static void netif_reset_xps_queues_gt(struct 
> net_device *dev, u16 index)
> mutex_unlock(&xps_map_mutex);
>  }
>
> +static void netif_reset_xps_queues_gt(struct net_device *dev, u16 index)
> +{
> +   netif_reset_xps_queues(dev, index, de

Re: [PATCH v2] ip6_tunnel: Clear IP6CB in ip6_tnl_xmit() after encapsulation

2016-10-27 Thread Tom Herbert
On Thu, Oct 27, 2016 at 6:52 PM, Eli Cooper  wrote:
> skb->cb may contain data from previous layers. In the observed scenario,
> the garbage data were misinterpreted as IP6CB(skb)->frag_max_size, so
> that small packets sent through the tunnel are mistakenly fragmented.
>
> This patch clears the control buffer for the next layer, after an IPv6
> header is installed.
>
Nice catch, but can you rectify this with what udp_tunnel6_xmit_skb is
doing. udp_tunnel6_xmit_skb calls ip6tunnel_xmit directly. Looks like
we do

memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED
| IPSKB_REROUTED);

Is this what we should be doing in ip6_tnl_xmit also, or is
udp_tunnel6_xmit_skb broken because it doesn't zero all the cb?

Thanks,
Tom

> Signed-off-by: Eli Cooper 
> ---
> v2: clears the whole IP6CB altogether and does it after encapsulation
>
>  net/ipv6/ip6_tunnel.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
> index 202d16a..1487e17 100644
> --- a/net/ipv6/ip6_tunnel.c
> +++ b/net/ipv6/ip6_tunnel.c
> @@ -1174,6 +1174,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device 
> *dev, __u8 dsfield,
>
> skb_push(skb, sizeof(struct ipv6hdr));
> skb_reset_network_header(skb);
> +   memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
> ipv6h = ipv6_hdr(skb);
> ip6_flow_hdr(ipv6h, INET_ECN_encapsulate(0, dsfield),
>  ip6_make_flowlabel(net, skb, fl6->flowlabel, true, fl6));
> --
> 2.10.1
>


Re: [PATCH net-next RFC WIP] Patch for XDP support for virtio_net

2016-10-27 Thread David Miller
From: Alexander Duyck 
Date: Thu, 27 Oct 2016 18:43:59 -0700

> On Thu, Oct 27, 2016 at 6:35 PM, David Miller  wrote:
>> From: "Michael S. Tsirkin" 
>> Date: Fri, 28 Oct 2016 01:25:48 +0300
>>
>>> On Thu, Oct 27, 2016 at 05:42:18PM -0400, David Miller wrote:
 From: "Michael S. Tsirkin" 
 Date: Fri, 28 Oct 2016 00:30:35 +0300

 > Something I'd like to understand is how does XDP address the
 > problem that 100Byte packets are consuming 4K of memory now.

 Via page pools.  We're going to make a generic one, but right now
 each and every driver implements a quick list of pages to allocate
 from (and thus avoid the DMA man/unmap overhead, etc.)
>>>
>>> So to clarify, ATM virtio doesn't attempt to avoid dma map/unmap
>>> so there should be no issue with that even when using sub/page
>>> regions, assuming DMA APIs support sub-page map/unmap correctly.
>>
>> That's not what I said.
>>
>> The page pools are meant to address the performance degradation from
>> going to having one packet per page for the sake of XDP's
>> requirements.
>>
>> You still need to have one packet per page for correct XDP operation
>> whether you do page pools or not, and whether you have DMA mapping
>> (or it's equivalent virutalization operation) or not.
> 
> Maybe I am missing something here, but why do you need to limit things
> to one packet per page for correct XDP operation?  Most of the drivers
> out there now are usually storing something closer to at least 2
> packets per page, and with the DMA API fixes I am working on there
> should be no issue with changing the contents inside those pages since
> we won't invalidate or overwrite the data after the DMA buffer has
> been synchronized for use by the CPU.

Because with SKB's you can share the page with other packets.

With XDP you simply cannot.

It's software semantics that are the issue.  SKB frag list pages
are read only, XDP packets are writable.

This has nothing to do with "writability" of the pages wrt. DMA
mapping or cpu mappings.


[PATCH v2] ip6_tunnel: Clear IP6CB in ip6_tnl_xmit() after encapsulation

2016-10-27 Thread Eli Cooper
skb->cb may contain data from previous layers. In the observed scenario,
the garbage data were misinterpreted as IP6CB(skb)->frag_max_size, so
that small packets sent through the tunnel are mistakenly fragmented.

This patch clears the control buffer for the next layer, after an IPv6
header is installed.

Signed-off-by: Eli Cooper 
---
v2: clears the whole IP6CB altogether and does it after encapsulation

 net/ipv6/ip6_tunnel.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 202d16a..1487e17 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1174,6 +1174,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device 
*dev, __u8 dsfield,
 
skb_push(skb, sizeof(struct ipv6hdr));
skb_reset_network_header(skb);
+   memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
ipv6h = ipv6_hdr(skb);
ip6_flow_hdr(ipv6h, INET_ECN_encapsulate(0, dsfield),
 ip6_make_flowlabel(net, skb, fl6->flowlabel, true, fl6));
-- 
2.10.1



Re: [PATCH net-next RFC WIP] Patch for XDP support for virtio_net

2016-10-27 Thread Alexander Duyck
On Thu, Oct 27, 2016 at 6:35 PM, David Miller  wrote:
> From: "Michael S. Tsirkin" 
> Date: Fri, 28 Oct 2016 01:25:48 +0300
>
>> On Thu, Oct 27, 2016 at 05:42:18PM -0400, David Miller wrote:
>>> From: "Michael S. Tsirkin" 
>>> Date: Fri, 28 Oct 2016 00:30:35 +0300
>>>
>>> > Something I'd like to understand is how does XDP address the
>>> > problem that 100Byte packets are consuming 4K of memory now.
>>>
>>> Via page pools.  We're going to make a generic one, but right now
>>> each and every driver implements a quick list of pages to allocate
>>> from (and thus avoid the DMA man/unmap overhead, etc.)
>>
>> So to clarify, ATM virtio doesn't attempt to avoid dma map/unmap
>> so there should be no issue with that even when using sub/page
>> regions, assuming DMA APIs support sub-page map/unmap correctly.
>
> That's not what I said.
>
> The page pools are meant to address the performance degradation from
> going to having one packet per page for the sake of XDP's
> requirements.
>
> You still need to have one packet per page for correct XDP operation
> whether you do page pools or not, and whether you have DMA mapping
> (or it's equivalent virutalization operation) or not.

Maybe I am missing something here, but why do you need to limit things
to one packet per page for correct XDP operation?  Most of the drivers
out there now are usually storing something closer to at least 2
packets per page, and with the DMA API fixes I am working on there
should be no issue with changing the contents inside those pages since
we won't invalidate or overwrite the data after the DMA buffer has
been synchronized for use by the CPU.


Re: [PATCH net-next RFC WIP] Patch for XDP support for virtio_net

2016-10-27 Thread David Miller
From: "Michael S. Tsirkin" 
Date: Fri, 28 Oct 2016 01:25:48 +0300

> On Thu, Oct 27, 2016 at 05:42:18PM -0400, David Miller wrote:
>> From: "Michael S. Tsirkin" 
>> Date: Fri, 28 Oct 2016 00:30:35 +0300
>> 
>> > Something I'd like to understand is how does XDP address the
>> > problem that 100Byte packets are consuming 4K of memory now.
>> 
>> Via page pools.  We're going to make a generic one, but right now
>> each and every driver implements a quick list of pages to allocate
>> from (and thus avoid the DMA man/unmap overhead, etc.)
> 
> So to clarify, ATM virtio doesn't attempt to avoid dma map/unmap
> so there should be no issue with that even when using sub/page
> regions, assuming DMA APIs support sub-page map/unmap correctly.

That's not what I said.

The page pools are meant to address the performance degradation from
going to having one packet per page for the sake of XDP's
requirements.

You still need to have one packet per page for correct XDP operation
whether you do page pools or not, and whether you have DMA mapping
(or it's equivalent virutalization operation) or not.


Re: [PATCH net-next 2/2] net/mlx4_en: Refactor the XDP forwarding rings scheme

2016-10-27 Thread Alexei Starovoitov
On Thu, Oct 27, 2016 at 05:52:04PM +0300, Tariq Toukan wrote:
> Separately manage the two types of TX rings: regular ones, and XDP.
> Upon an XDP set, do not borrow regular TX rings and convert them
> into XDP ones, but allocate new ones, unless we hit the max number
> of rings.
> Which means that in systems with smaller #cores we will not consume
> the current TX rings for XDP, while we are still in the num TX limit.

The commit log is too scarce for details...
So questions:
- Did you test with changing the number of channels after xdp prog is loaded?
That was the recent bug that Brenden fixed.
- does it still have 256 tx queue limit or xdp tx rings can go over?
- Any performance implications ?

Brenden, could you please review this patch?



RE: [PATCH net-next RFC WIP] Patch for XDP support for virtio_net

2016-10-27 Thread Shrijeet Mukherjee
> -Original Message-
> From: Shrijeet Mukherjee [mailto:s...@cumulusnetworks.com]
> Sent: Thursday, October 27, 2016 5:02 PM
> To: John Fastabend ; Jesper Dangaard Brouer
> ; David Miller 
> Cc: m...@redhat.com; shrij...@gmail.com; t...@herbertland.com;
> netdev@vger.kernel.org; Roopa Prabhu ;
> Nikolay Aleksandrov 
> Subject: RE: [PATCH net-next RFC WIP] Patch for XDP support for virtio_net
>
> > >
> > > Looking at the virtio_net.c code, the function call receive_big()
> > >might actually be okay for XDP, unless the incoming packet is larger
> > >than PAGE_SIZE and thus uses several pages (via a linked list in
> > >page- private).
> > >
> > > The receive_mergeable() does not look compatible with XDP.
> > >
> >
> > Looks to me the correct conditions can be met by getting the correct
> > feature negotiation to happen, specifically no
> VIRTIO_NET_F_MRG_RXBUF
> > and one of the TSO/ECN/GSO feature bits set the big_packets flag as
> Jesper
> > notes.
> >
> > Srijeet, are you going to give this a try? I'm trying to get the
> > device
> side
> > working by the way on the vhost interface.
> >
>
> Yup, I did try it .. but it looked like the device gets to make that call
> (Unless
> someone tells me I did something wrong) If I turned that feature off in
> the
> driver it crashed (did not chase too far down that hole) but let me try
> that
> again.

Nevermind, I must have had some other issue. This does seem to work using
TSO as the function. Will spin something up to have the device export an XDP
capability which would block MERGEABLE for now and we can sort out alternate
plans later ?

>
> Wanted to consider a path, which looks like has been considered and
> discarded, but for the mergable buffers case, if we disallow edit's (no
> writes) would that be an acceptable answer ? sorry in advance for the
> repeat question, but the benefit of mergeable seems like it can be real
> for
> all packets that are not being XDP'ed .. so maybe apps can make a choice
> of
> doing a copy into a local buffer and XDP_TX from there ?


Re: [PATCH v2 1/5] kconfig: introduce the "imply" keyword

2016-10-27 Thread Paul Bolle
On Tue, 2016-10-25 at 22:28 -0400, Nicolas Pitre wrote:
> The "imply" keyword is a weak version of "select" where the target
> config symbol can still be turned off, avoiding those pitfalls that come
> with the "select" keyword.
> 
> This is useful e.g. with multiple drivers that want to indicate their
> ability to hook into a given subsystem

"hook into a [...] subsystem" is rather vague.

>  while still being able to configure that subsystem out

s/being able to/allowing the user to/, correct? 

> and keep those drivers selected.

Perhaps replace that with: "without also having to unset these
drivers"?

> Currently, the same effect can almost be achieved with:
> 
> config DRIVER_A
>   tristate
> 
> config DRIVER_B
>   tristate
> 
> config DRIVER_C
>   tristate
> 
> config DRIVER_D
>   tristate
> 
> [...]
> 
> config SUBSYSTEM_X
>   tristate
>   default DRIVER_A || DRIVER_B || DRIVER_C || DRIVER_D || [...]
> 
> This is unwieldly

unwieldy

> to maintain especially with a large number of drivers.
> Furthermore, there is no easy way to restrict the choice for SUBSYSTEM_X
> to y or n, excluding m, when some drivers are built-in. The "select"
> keyword allows for excluding m, but it excludes n as well. Hence
> this "imply" keyword.  The above becomes:
> 
> config DRIVER_A
>   tristate
>   imply SUBSYSTEM_X
> 
> config DRIVER_B
>   tristate
>   imply SUBSYSTEM_X
> 
> [...]
> 
> config SUBSYSTEM_X
>   tristate
> 
> This is much cleaner, and way more flexible than "select". SUBSYSTEM_X
> can still be configured out, and it can be set as a module when none of
> the drivers are selected or all of them are also modular.

[I already commented on this sentence in a previous message.]

> --- a/Documentation/kbuild/kconfig-language.txt
> +++ b/Documentation/kbuild/kconfig-language.txt

>   That will limit the usefulness but on the other hand avoid
>   the illegal configurations all over.
>  
> +- weak reverse dependencies: "imply"  ["if" ]

You probably got "["if" ]" for free by copying what's there for
select. But this series doesn't use it, so perhaps it would be better
to not document it yet. But that is rather sneaky. Dunno.

> +  This is similar to "select" as it enforces a lower limit on another
> +  symbol except that the "implied" config symbol's value may still be
> +  set to n from a direct dependency or with a visible prompt.

This is seriously hard to parse. But it's late here, so it might just
be me.

> +  Given the following example:
> +
> +  config FOO
> + tristate
> + imply BAZ
> +
> +  config BAZ
> + tristate
> + depends on BAR
> +
> +  The following values are possible:
> +
> + FOO BAR BAZ's default   choice for BAZ
> + --- --- -   --
> + n   y   n   N/m/y
> + m   y   m   M/y/n
> + y   y   y   Y/n

Also
n   n   *   N
m   n   *   N

Is that right?

> + y   n   *   N

But what does '*' mean?

What happens when a tristate symbol is implied by a symbol set to 'y'
and by a symbol set to 'm'?

And in your example BAR is bool, right? Does the above get more
complicated if BAR would be tristate?

How does setting a direct default for BAZ interfere with the implied
values?

> +  This is useful e.g. with multiple drivers that want to indicate their
> +  ability to hook into a given subsystem while still being able to
> +  configure that subsystem out and keep those drivers selected.

See my comments above.

>    b) Match dependency semantics:
>   b1) Swap all "select FOO" to "depends on FOO" or,
>   b2) Swap all "depends on FOO" to "select FOO"
> +  c) Consider the use of "imply" instead of "select"

If memory serves me right this text was added after a long discussion
with Luis Rodriguez. Luis might want to have a look at any 

Haven't looked at the code yet, sorry. I'm still trying to see whether
I can wrap my mind around this. It looks like just setting a default on
another symbol, but there could be a twist I missed.


Paul Bolle


RE: [PATCH net-next RFC WIP] Patch for XDP support for virtio_net

2016-10-27 Thread Shrijeet Mukherjee
> >
> > Looking at the virtio_net.c code, the function call receive_big()
> > might actually be okay for XDP, unless the incoming packet is larger
> > than PAGE_SIZE and thus uses several pages (via a linked list in page-
> >private).
> >
> > The receive_mergeable() does not look compatible with XDP.
> >
>
> Looks to me the correct conditions can be met by getting the correct
> feature negotiation to happen, specifically no VIRTIO_NET_F_MRG_RXBUF
> and one of the TSO/ECN/GSO feature bits set the big_packets flag as
Jesper
> notes.
>
> Srijeet, are you going to give this a try? I'm trying to get the device
side
> working by the way on the vhost interface.
>

Yup, I did try it .. but it looked like the device gets to make that call
(Unless someone tells me I did something wrong) If I turned that feature
off in the driver it crashed (did not chase too far down that hole) but
let me try that again.

Wanted to consider a path, which looks like has been considered and
discarded, but for the mergable buffers case, if we disallow edit's (no
writes) would that be an acceptable answer ? sorry in advance for the
repeat question, but the benefit of mergeable seems like it can be real
for all packets that are not being XDP'ed .. so maybe apps can make a
choice of doing a copy into a local buffer and XDP_TX from there ?


[PATCH net] enic: fix rq disable

2016-10-27 Thread Govindarajulu Varadarajan
When MTU is changed from 9000 to 1500 while there is burst of inbound 9000
bytes packets, adaptor sometimes delivers 9000 bytes packets to 1500 bytes
buffers. This causes memory corruption and sometimes crash.

This is because of a race condition in adaptor between "RQ disable"
clearing descriptor mini-cache and mini-cache valid bit being set by
completion of descriptor fetch. This can result in stale RQ desc being
cached and used when packets arrive. In this case, the stale descriptor
have old MTU value.

Solution is to write RQ->disable twice. The first write will stop any
further desc fetches, allowing the second disable to clear the mini-cache
valid bit without danger of a race.

Also, the check for rq->running becoming 0 after writing rq->enable to 0
is not done properly. When incoming packets are flooding the interface,
rq->running will pulse high for each dropped packet. Since the driver was
waiting for 10us between each poll, it is possible to see rq->running = 1
1000 times in a row, even though it is not actually stuck running.
This results in false failure of vnic_rq_disable(). Fix is to try more
than 1000 time without delay between polls to ensure we do not miss when
running goes low.

In old adaptors rq->enable needs to be re-written to 0 when posted_index
is reset in vnic_rq_clean() in order to keep rq->prefetch_index in sync.

Signed-off-by: Govindarajulu Varadarajan <_gov...@gmx.com>
---
 drivers/net/ethernet/cisco/enic/vnic_rq.c | 32 ++-
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/cisco/enic/vnic_rq.c 
b/drivers/net/ethernet/cisco/enic/vnic_rq.c
index e572a52..36bc2c7 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_rq.c
+++ b/drivers/net/ethernet/cisco/enic/vnic_rq.c
@@ -169,19 +169,28 @@ int vnic_rq_disable(struct vnic_rq *rq)
 {
unsigned int wait;
struct vnic_dev *vdev = rq->vdev;
+   int i;
 
-   iowrite32(0, &rq->ctrl->enable);
+   /* Due to a race condition with clearing RQ "mini-cache" in hw, we need
+* to disable the RQ twice to guarantee that stale descriptors are not
+* used when this RQ is re-enabled.
+*/
+   for (i = 0; i < 2; i++) {
+   iowrite32(0, &rq->ctrl->enable);
 
-   /* Wait for HW to ACK disable request */
-   for (wait = 0; wait < 1000; wait++) {
-   if (!(ioread32(&rq->ctrl->running)))
-   return 0;
-   udelay(10);
-   }
+   /* Wait for HW to ACK disable request */
+   for (wait = 2; wait > 0; wait--)
+   if (!ioread32(&rq->ctrl->running))
+   break;
+   if (!wait) {
+   vdev_neterr(vdev, "Failed to disable RQ[%d]\n",
+   rq->index);
 
-   vdev_neterr(vdev, "Failed to disable RQ[%d]\n", rq->index);
+   return -ETIMEDOUT;
+   }
+   }
 
-   return -ETIMEDOUT;
+   return 0;
 }
 
 void vnic_rq_clean(struct vnic_rq *rq,
@@ -212,6 +221,11 @@ void vnic_rq_clean(struct vnic_rq *rq,
[fetch_index % VNIC_RQ_BUF_BLK_ENTRIES(count)];
iowrite32(fetch_index, &rq->ctrl->posted_index);
 
+   /* Anytime we write fetch_index, we need to re-write 0 to rq->enable
+* to re-sync internal VIC state.
+*/
+   iowrite32(0, &rq->ctrl->enable);
+
vnic_dev_clear_desc_ring(&rq->ring);
 }
 
-- 
2.10.1



Re: [PATCH net 1/2] vxlan: avoid using stale vxlan socket.

2016-10-27 Thread Stephen Hemminger
On Thu, 27 Oct 2016 11:51:55 -0700
Pravin B Shelar  wrote:

> - vxlan->vn4_sock = NULL;
> + rcu_assign_pointer(vxlan->vn4_sock, NULL);
>  #if IS_ENABLED(CONFIG_IPV6)
> - vxlan->vn6_sock = NULL;
> + rcu_assign_pointer(vxlan->vn6_sock, NULL);
>   if (ipv6 || metadata)

User RCU_INIT_POINTER when setting pointer to NULL.
It avoids unnecessary barrier.


[PATCH net 1/1] tipc: fix broadcast link synchronization problem

2016-10-27 Thread Jon Maloy
In commit 2d18ac4ba745 ("tipc: extend broadcast link initialization
criteria") we tried to fix a problem with the initial synchronization
of broadcast link acknowledge values. Unfortunately that solution is
not sufficient to solve the issue.

We have seen it happen that LINK_PROTOCOL/STATE packets with a valid
non-zero unicast acknowledge number may bypass BCAST_PROTOCOL
initialization, NAME_DISTRIBUTOR and other STATE packets with invalid
broadcast acknowledge numbers, leading to premature opening of the
broadcast link. When the bypassed packets finally arrive, they are
inadvertently accepted, and the already correctly initialized
acknowledge number in the broadcast receive link is overwritten by
the invalid (zero) value of the said packets. After this the broadcast
link goes stale.

We now fix this by marking the packets where we know the acknowledge
value is or may be invalid, and then ignoring the acks from those.

To this purpose, we claim an unused bit in the header to indicate that
the value is invalid. We set the bit to 1 in the initial BCAST_PROTOCOL
synchronization packet and all initial ("bulk") NAME_DISTRIBUTOR
packets, plus those LINK_PROTOCOL packets sent out before the broadcast
links are fully synchronized.

This minor protocol update is fully backwards compatible.

Reported-by: John Thompson 
Tested-by: John Thompson 
Signed-off-by: Jon Maloy 
---
 net/tipc/bcast.c  | 14 ++
 net/tipc/bcast.h  |  3 ++-
 net/tipc/link.c   |  2 ++
 net/tipc/msg.h| 17 +
 net/tipc/name_distr.c |  1 +
 net/tipc/node.c   |  2 +-
 6 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 753f774..aa1babb 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -247,11 +247,17 @@ int tipc_bcast_rcv(struct net *net, struct tipc_link *l, 
struct sk_buff *skb)
  *
  * RCU is locked, no other locks set
  */
-void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l, u32 acked)
+void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l,
+   struct tipc_msg *hdr)
 {
struct sk_buff_head *inputq = &tipc_bc_base(net)->inputq;
+   u16 acked = msg_bcast_ack(hdr);
struct sk_buff_head xmitq;
 
+   /* Ignore bc acks sent by peer before bcast synch point was received */
+   if (msg_bc_ack_invalid(hdr))
+   return;
+
__skb_queue_head_init(&xmitq);
 
tipc_bcast_lock(net);
@@ -279,11 +285,11 @@ int tipc_bcast_sync_rcv(struct net *net, struct tipc_link 
*l,
__skb_queue_head_init(&xmitq);
 
tipc_bcast_lock(net);
-   if (msg_type(hdr) == STATE_MSG) {
+   if (msg_type(hdr) != STATE_MSG) {
+   tipc_link_bc_init_rcv(l, hdr);
+   } else if (!msg_bc_ack_invalid(hdr)) {
tipc_link_bc_ack_rcv(l, msg_bcast_ack(hdr), &xmitq);
rc = tipc_link_bc_sync_rcv(l, hdr, &xmitq);
-   } else {
-   tipc_link_bc_init_rcv(l, hdr);
}
tipc_bcast_unlock(net);
 
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h
index 5ffe344..855d53c 100644
--- a/net/tipc/bcast.h
+++ b/net/tipc/bcast.h
@@ -55,7 +55,8 @@ void tipc_bcast_dec_bearer_dst_cnt(struct net *net, int 
bearer_id);
 int  tipc_bcast_get_mtu(struct net *net);
 int tipc_bcast_xmit(struct net *net, struct sk_buff_head *list);
 int tipc_bcast_rcv(struct net *net, struct tipc_link *l, struct sk_buff *skb);
-void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l, u32 acked);
+void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l,
+   struct tipc_msg *hdr);
 int tipc_bcast_sync_rcv(struct net *net, struct tipc_link *l,
struct tipc_msg *hdr);
 int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg);
diff --git a/net/tipc/link.c b/net/tipc/link.c
index b36e16c..1055164 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1312,6 +1312,7 @@ static void tipc_link_build_proto_msg(struct tipc_link 
*l, int mtyp, bool probe,
msg_set_next_sent(hdr, l->snd_nxt);
msg_set_ack(hdr, l->rcv_nxt - 1);
msg_set_bcast_ack(hdr, bcl->rcv_nxt - 1);
+   msg_set_bc_ack_invalid(hdr, !node_up);
msg_set_last_bcast(hdr, l->bc_sndlink->snd_nxt - 1);
msg_set_link_tolerance(hdr, tolerance);
msg_set_linkprio(hdr, priority);
@@ -1574,6 +1575,7 @@ static void tipc_link_build_bc_init_msg(struct tipc_link 
*l,
__skb_queue_head_init(&list);
if (!tipc_link_build_bc_proto_msg(l->bc_rcvlink, false, 0, &list))
return;
+   msg_set_bc_ack_invalid(buf_msg(skb_peek(&list)), true);
tipc_link_xmit(l, &list, xmitq);
 }
 
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index c3832cd..50a7398 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -714,6 +714,23 @@ static inline void msg_set_peer_stopping(struct tipc_msg 
*m, u32 s)
msg_set_bits(m, 5, 13, 0x1, s);
 }
 
+static inline bool msg_bc_ack_invalid(struct tipc_msg 

Re: AW: Redundancy support through HSR and PRP

2016-10-27 Thread Murali Karicheri
On 10/25/2016 09:24 AM, HEISE, Peter P wrote:
> Hi Murali, hi Arvid,
> 
> also no work on PRP from my side.
> 
> Should be pretty straight forward to get PRP support from the existing HSR 
> code.

Thanks Arvid and Peter!

Basically I have following to be done w.r.t HSR/PRP.

1. Add PRP support
2. Add h/w offload some of the rx/tx redundancy and L2 forward handling to 
firmware.

If you have any thoughts on 2, please let me know. Our hardware is a switch
with HSR/PRP support. So I believe I need to have L2 offload done using the DSA
and run the hsr/prp driver on top of that. The MIB handling is done in the
firmware. So that has to be offloaded as well. My work has just begun and I hope
to come up with an RFC patch for HSR offload first followed by PRP support.

>From high level, it appears to be a straight forward to add the PRP support.
I might have to rename the net/hsr to something like net/hsr-prp ??

Also restructure the code a bit to support PRP

I have brought up HSR driver on my platform (HSRv0 and HSRv1) and it seems to 
work.
So I might be able to regress the existing once I add my change.

Peter,

Do you think you could help me do some testing in the future when patches become
available?

Murali

> 
> 
> -Ursprüngliche Nachricht-
> Von: Arvid Brodin [mailto:arvid.bro...@alten.se] 
> Gesendet: Dienstag, 25. Oktober 2016 15:04
> An: Murali Karicheri
> Cc: open list:TI NETCP ETHERNET DRIVER; David Miller; HEISE, Peter P
> Betreff: Re: Redundancy support through HSR and PRP
> 
> On 2016-10-24 18:35, Murali Karicheri wrote:
>>> On 10/10/2016 02:34 PM, Murali Karicheri wrote:
 All,

 Wondering if there plan to add PRP driver support, like HSR in 
 Linux? AFAIK, PRP adds trailor to Ethernet frame and is used for 
 Redundancy management like HSR.
 So wondering why this is not supported.

 Thanks

>>> I need to work on a prp driver for Linux. So if there is already 
>>> someone working on this, I would like to join and contribute. Either 
>>> way please respond so that I can work to add this support.
>>>
>> + Arvid
>>
>> Didn't copy HSR owner in my original email. Copying now.
>>
> 
> Hi Murali,
> 
> I'm not aware of anyone working on PRP support.
> 
> I will have very little time, if any, to help out with this (or even test 
> changes).
> In fact, if you want to send a patch for the MAINTAINERS file to take over 
> maintainership of the HSR/PRP driver, that would probably be a good thing.
> 
> (I'm CC'ing also Peter Heise to this conversation, since he's done some 
> recent work on the HSR driver, and might want to keep updated.)
> 
> 


-- 
Murali Karicheri
Linux Kernel, Keystone


Re: [PATCH 1/5] net: phy: broadcom: Add BCM54810 phy entry

2016-10-27 Thread Jon Mason
On Thu, Oct 27, 2016 at 11:15:05AM +0200, Andrew Lunn wrote:
> On Wed, Oct 26, 2016 at 03:35:57PM -0400, Jon Mason wrote:
> > From: Vikas Soni 
> > 
> > Add BCM54810 phy entry
> 
> Hi Jon, Vikis
> 
> The subject line is a bit misleading. It does more than add a PHY ID
> entry.

All of the parts are related to adding the BCM54810 Phy, but I agree it
could be more verbose about what is happening.

> > Signed-off-by: Vikas Soni 
> > Signed-off-by: Jon Mason 
> > ---
> >  drivers/net/phy/Kconfig|  2 +-
> >  drivers/net/phy/broadcom.c | 65 
> > ++
> >  include/linux/brcmphy.h|  7 +
> >  3 files changed, 73 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> > index 45f68ea..31967ca 100644
> > --- a/drivers/net/phy/Kconfig
> > +++ b/drivers/net/phy/Kconfig
> > @@ -217,7 +217,7 @@ config BROADCOM_PHY
> > select BCM_NET_PHYLIB
> > ---help---
> >   Currently supports the BCM5411, BCM5421, BCM5461, BCM54616S, BCM5464,
> > - BCM5481 and BCM5482 PHYs.
> > + BCM5481, BCM54810 and BCM5482 PHYs.
> >  
> >  config CICADA_PHY
> > tristate "Cicada PHYs"
> > diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
> > index 870327e..cdce761 100644
> > --- a/drivers/net/phy/broadcom.c
> > +++ b/drivers/net/phy/broadcom.c
> > @@ -35,6 +35,35 @@ static int bcm54xx_auxctl_write(struct phy_device 
> > *phydev, u16 regnum, u16 val)
> > return phy_write(phydev, MII_BCM54XX_AUX_CTL, regnum | val);
> >  }
> >  
> > +static int bcm54810_config(struct phy_device *phydev)
> > +{
> > +   int rc;
> > +
> > +   /* Disable BroadR-Reach */
> > +   rc = bcm_phy_write_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL, 0);
> > +   if (rc < 0)
> > +   return rc;
> > +
> > +   /* SKEW DISABLE */
> > +   rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
> > + 0xF0E0);
> > +   if (rc < 0)
> > +   return rc;
> > +
> > +   /* DELAY DISABLE */
> > +   rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
> > + 0x7000);
> 
> This driver mostly uses symbolic names, not #defines. Please can you
> use #defines here and else were in this patch.

Will do.  After looking at this, this appears to be setup for a read
that doesn't follow.  I'll audit this, clean it up and resend.

 
> > +   if (rc < 0)
> > +   return rc;
> > +
> > +   /* DELAY DISABLE */
> > +   rc = bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, 0);
> > +   if (rc < 0)
> > +   return rc;
> 
> Twice the same comment?
>
> > +
> > +   return 0;
> > +}
> > +
> >  /* Needs SMDSP clock enabled via bcm54xx_phydsp_config() */
> >  static int bcm50610_a0_workaround(struct phy_device *phydev)
> >  {
> > @@ -207,6 +236,20 @@ static int bcm54xx_config_init(struct phy_device 
> > *phydev)
> > (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
> > bcm54xx_adjust_rxrefclk(phydev);
> >  
> > +   if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810) {
> > +   err = bcm54810_config(phydev);
> > +   if (err)
> > +   return err;
> > +
> > +   reg = phy_read(phydev, MII_BMCR);
> > +   if (reg < 0)
> > +   return reg;
> > +
> > +   err = phy_write(phydev, MII_BMCR, reg & ~BMCR_PDOWN);
> > +   if (err)
> > +   return err;
> 
> This seems a bit odd. I would expect the PHY core correctly handles
> the PHY being powered down. Can you explain this a bit more, why it is
> needed.

I believe it was needed in earlier versions of the code, but doesn't
seem to be needed anymore.  Removing.

> 
>   Thanks
>   Andrew


Re: [PATCH] net: phy: at803x: the Atheros 8031 supports pause frames

2016-10-27 Thread Florian Fainelli
On 10/27/2016 03:24 PM, Timur Tabi wrote:
> Florian Fainelli wrote:
> 
>> Hu? In my experience that should not come from supporting Pause frames
>> or not, but rather properly configuring a (RG)MII delay, but your
>> mileage may vary.
> 
> I can assure you, I'm more confused than you.  I've been working in this
> for almost two weeks, and not only does this patch align with other phy
> drivers, but it does fix my bug.  Without this patch, phylib does not
> set the pause frame bits (10 and 11) in MII_ADVERTISE.

And that's expected, but if your MAC does not act upon phydev->pause and
phydev->asym_pause, then chances are that you can indeed lose packets
every once in a while.

The part that is totally crappy about Pause frames and PHYLIB is that we
need some information about whether this should be supported or not,
such that we can change MII_ADVERTISE accordingly to reflect that, and
what best way to do this than use one of these SUPPORTED_* bits to set
that, except, that unlike speed (which is both a MAC and PHY property),
Pause is exclusively MAC, yet, it transpires in PHYLIB.

MACs that I work with for instance need to be told to ignore pause
frames, or not ignore them, it all depends on what you want to
advertise/support.

> 
>> It does not, support for Pause frames is a MAC-level feature, yet,
>> PHYLIB (and that's been on my todo for a while now) insists on reporting
>> the confusing phydev->pause and phydev->asym_pause, which really is what
>> has been determined from auto-negotiating with your partner, as opposed
>> to being a supported thing or not. The PHY has absolutely not business
>> in that.
> 
> But there are pause frame bits in the MII_ADVERTISE register, and this
> setting directly impacts whether those bits are set.  I don't see how
> this is a MAC-level feature.

This is a MAC level feature, that needs to be auto-negotiated with your
link partner, which is why there is room for this in MII_ADVERTISE, but
the PHY absolutely does not participate in Pause frames, other than
passing them through the MAC, like normal frames. Whether your MAC acts
upon that or not is a MAC dependent feature.

> 
>> Your change should probably be in the Ethernet MAC driver, when you have
>> successfully connected to the PHY, update phydev->supported to include
>> SUPPORTED_Pause | SUPPORTED_Asym_pause.
> 
> The phylib documentation (networking/phy.txt) says:
> 
>  Now just make sure that phydev->supported and phydev->advertising have any
>  values pruned from them which don't make sense for your controller (a
> 10/100
>  controller may be connected to a gigabit capable PHY, so you would need to
>  mask off SUPPORTED_1000baseT*).  See include/linux/ethtool.h for
> definitions
>  for these bitfields.
> 
> and then it says:
> 
>> Note that you should not SET any bits, or the PHY may
>>  get put into an unsupported state.
> 
> So are you sure I'm supposed to set those bits?

Yes I am sure you should set these bits, the documentation is not
necessarily the authoritative source here (although it should). What
this probably meant to be written is something like: don't set any bits
that are not defined in ethtool.h, i.e: do not use this to store
persistent states.
-- 
Florian


Re: [PATCH net-next 5/5] ipv6: Compute multipath hash for forwarded ICMP errors from offending packet

2016-10-27 Thread Tom Herbert
On Mon, Oct 24, 2016 at 2:28 AM, Jakub Sitnicki  wrote:
> Same as for the transmit path, let's do our best to ensure that received
> ICMP errors that may be subject to forwarding will be routed the same
> path as flow that triggered the error, if it was going in the opposite
> direction.
>
Unfortunately our ability to do this is generally quite limited. This
patch will select the route for multipath, but I don't believe sets
the same link in LAG and definitely can't help switches doing ECMP to
route the ICMP packet in the same way as the flow would be. Did you
see a problem that warrants solving this case?

Tom


> Signed-off-by: Jakub Sitnicki 
> ---
>  net/ipv6/route.c | 26 ++
>  1 file changed, 26 insertions(+)
>
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 1184c2b..c0f38ea 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1150,6 +1150,30 @@ struct dst_entry *ip6_route_input_lookup(struct net 
> *net,
>  }
>  EXPORT_SYMBOL_GPL(ip6_route_input_lookup);
>
> +static u32 ip6_multipath_icmp_hash(const struct sk_buff *skb)
> +{
> +   const struct icmp6hdr *icmph = icmp6_hdr(skb);
> +   const struct ipv6hdr *inner_iph;
> +   struct ipv6hdr _inner_iph;
> +
> +   if (icmph->icmp6_type != ICMPV6_DEST_UNREACH &&
> +   icmph->icmp6_type != ICMPV6_PKT_TOOBIG &&
> +   icmph->icmp6_type != ICMPV6_TIME_EXCEED &&
> +   icmph->icmp6_type != ICMPV6_PARAMPROB)
> +   goto standard_hash;
> +
> +   inner_iph = skb_header_pointer(
> +   skb, skb_transport_offset(skb) + sizeof(*icmph),
> +   sizeof(_inner_iph), &_inner_iph);
> +   if (!inner_iph)
> +   goto standard_hash;
> +
> +   return icmpv6_multipath_hash(inner_iph);
> +
> +standard_hash:
> +   return 0; /* compute it later, if needed */
> +}
> +
>  void ip6_route_input(struct sk_buff *skb)
>  {
> const struct ipv6hdr *iph = ipv6_hdr(skb);
> @@ -1168,6 +1192,8 @@ void ip6_route_input(struct sk_buff *skb)
> tun_info = skb_tunnel_info(skb);
> if (tun_info && !(tun_info->mode & IP_TUNNEL_INFO_TX))
> fl6.flowi6_tun_key.tun_id = tun_info->key.tun_id;
> +   if (unlikely(fl6.flowi6_proto == IPPROTO_ICMPV6))
> +   fl6.mp_hash = ip6_multipath_icmp_hash(skb);

I will point out that this is only
> skb_dst_drop(skb);
> skb_dst_set(skb, ip6_route_input_lookup(net, skb->dev, &fl6, flags));
>  }
> --
> 2.7.4
>


Re: [PATCH 4/5] net: ethernet: bgmac: add NS2 support

2016-10-27 Thread Ray Jui


On 10/27/2016 3:21 PM, Ray Jui wrote:
> 
> 
> On 10/27/2016 1:51 PM, Jon Mason wrote:
>> On Wed, Oct 26, 2016 at 02:50:39PM -0700, Florian Fainelli wrote:
>>> On 10/26/2016 12:36 PM, Jon Mason wrote:
 Add support for the variant of amac hardware present in the Broadcom
 Northstar2 based SoCs.  Northstar2 requires an additional register to be
 configured with the port speed/duplexity (NICPM).  This can be added to
 the link callback to hide it from the instances that do not use this.
 Also, the bgmac_chip_reset() was intentionally removed to prevent the
 resetting of the chip to the default values on open.  Finally, clearing
 of the pending interrupts on init is required due to observed issues on
 some platforms.

 Signed-off-by: Jon Mason 
 ---
>>>
 +static void bgmac_nicpm_speed_set(struct net_device *net_dev)
 +{
 +  struct bgmac *bgmac = netdev_priv(net_dev);
 +  u32 val;
 +
 +  if (!bgmac->plat.nicpm_base)
 +  return;
 +
 +  val = NICPM_IOMUX_CTRL_INIT_VAL;
 +  switch (bgmac->net_dev->phydev->speed) {
 +  default:
 +  pr_err("Unsupported speed.  Defaulting to 1000Mb\n");
 +  case SPEED_1000:
 +  val |= NICPM_IOMUX_CTRL_SPD_1000M << NICPM_IOMUX_CTRL_SPD_SHIFT;
 +  break;
 +  case SPEED_100:
 +  val |= NICPM_IOMUX_CTRL_SPD_100M << NICPM_IOMUX_CTRL_SPD_SHIFT;
 +  break;
 +  case SPEED_10:
 +  val |= NICPM_IOMUX_CTRL_SPD_10M << NICPM_IOMUX_CTRL_SPD_SHIFT;
 +  break;
 +  }
 +
 +  writel(val, bgmac->plat.nicpm_base + NICPM_IOMUX_CTRL);
 +
 +  usleep_range(10, 100);
>>>
>>> Does not seem like a good idea, do you need that sleep?
>>
>> Oops, that's not supposed to be there.  Removed.
>>
>>
 +
 +  bgmac_adjust_link(bgmac->net_dev);
 +}
 +
  static int platform_phy_connect(struct bgmac *bgmac)
  {
struct phy_device *phy_dev;
  
 -  phy_dev = of_phy_get_and_connect(bgmac->net_dev, bgmac->dev->of_node,
 -   bgmac_adjust_link);
 +  if (bgmac->plat.nicpm_base)
 +  phy_dev = of_phy_get_and_connect(bgmac->net_dev,
 +   bgmac->dev->of_node,
 +   bgmac_nicpm_speed_set);
 +  else
 +  phy_dev = of_phy_get_and_connect(bgmac->net_dev,
 +   bgmac->dev->of_node,
 +   bgmac_adjust_link);
if (!phy_dev) {
dev_err(bgmac->dev, "Phy connect failed\n");
return -ENODEV;
}
  
 +  if (bgmac->feature_flags & BGMAC_FEAT_LANE_SWAP)
 +  phy_dev->dev_flags |= PHY_BRCM_EXP_LANE_SWAP;
 +
return 0;
  }
  
 @@ -140,6 +188,9 @@ static int bgmac_probe(struct platform_device *pdev)
  
platform_set_drvdata(pdev, bgmac);
  
 +  if (of_property_read_bool(np, "brcm,enet-phy-lane-swap"))
 +  bgmac->feature_flags |= BGMAC_FEAT_LANE_SWAP;
 +
/* Set the features of the 4707 family */
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
 @@ -182,6 +233,14 @@ static int bgmac_probe(struct platform_device *pdev)
if (IS_ERR(bgmac->plat.idm_base))
return PTR_ERR(bgmac->plat.idm_base);
  
 +  regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nicpm_base");
 +  if (regs) {
 +  bgmac->plat.nicpm_base = devm_ioremap_resource(&pdev->dev,
 + regs);
 +  if (IS_ERR(bgmac->plat.nicpm_base))
 +  return PTR_ERR(bgmac->plat.nicpm_base);
 +  }
 +
bgmac->read = platform_bgmac_read;
bgmac->write = platform_bgmac_write;
bgmac->idm_read = platform_bgmac_idm_read;
 @@ -213,6 +272,7 @@ static int bgmac_remove(struct platform_device *pdev)
  static const struct of_device_id bgmac_of_enet_match[] = {
{.compatible = "brcm,amac",},
{.compatible = "brcm,nsp-amac",},
 +  {.compatible = "brcm,ns2-amac",},
{},
  };
  
 diff --git a/drivers/net/ethernet/broadcom/bgmac.c 
 b/drivers/net/ethernet/broadcom/bgmac.c
 index 38876ec..1796208 100644
 --- a/drivers/net/ethernet/broadcom/bgmac.c
 +++ b/drivers/net/ethernet/broadcom/bgmac.c
 @@ -1082,6 +1082,9 @@ static void bgmac_enable(struct bgmac *bgmac)
  /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */
  static void bgmac_chip_init(struct bgmac *bgmac)
  {
 +  /* Clear any erroneously pending interrupts */
 +  bgmac_write(bgmac, BGMAC_INT_STATUS, ~0);
 +
/* 1 interrupt per received frame */
bgmac_write(bgmac, BGMAC_INT_RECV_LAZY, 1 << BGMAC_IRL_FC_SHIFT);
  
 @@ -

Re: [PATCH net-next RFC WIP] Patch for XDP support for virtio_net

2016-10-27 Thread Michael S. Tsirkin
On Thu, Oct 27, 2016 at 05:42:18PM -0400, David Miller wrote:
> From: "Michael S. Tsirkin" 
> Date: Fri, 28 Oct 2016 00:30:35 +0300
> 
> > Something I'd like to understand is how does XDP address the
> > problem that 100Byte packets are consuming 4K of memory now.
> 
> Via page pools.  We're going to make a generic one, but right now
> each and every driver implements a quick list of pages to allocate
> from (and thus avoid the DMA man/unmap overhead, etc.)

So to clarify, ATM virtio doesn't attempt to avoid dma map/unmap
so there should be no issue with that even when using sub/page
regions, assuming DMA APIs support sub-page map/unmap correctly.

The only reason virtio attempts to use sub-page fragments is to conserve
memory so that truesize for a 100byte packets won't be 4K. Are you
saying pools will somehow mean we won't need to worry about that so
effectively truesize=100byte even though the rest of the 4k page goes
unused? If so we'll happily go back to allocate memory in 4K chunks like
we used to before 2613af0ed18a, and remove a bunch of complexity.

-- 
MST


Re: [PATCH] net: phy: at803x: the Atheros 8031 supports pause frames

2016-10-27 Thread Timur Tabi

Florian Fainelli wrote:


Hu? In my experience that should not come from supporting Pause frames
or not, but rather properly configuring a (RG)MII delay, but your
mileage may vary.


I can assure you, I'm more confused than you.  I've been working in this 
for almost two weeks, and not only does this patch align with other phy 
drivers, but it does fix my bug.  Without this patch, phylib does not 
set the pause frame bits (10 and 11) in MII_ADVERTISE.



It does not, support for Pause frames is a MAC-level feature, yet,
PHYLIB (and that's been on my todo for a while now) insists on reporting
the confusing phydev->pause and phydev->asym_pause, which really is what
has been determined from auto-negotiating with your partner, as opposed
to being a supported thing or not. The PHY has absolutely not business
in that.


But there are pause frame bits in the MII_ADVERTISE register, and this 
setting directly impacts whether those bits are set.  I don't see how 
this is a MAC-level feature.



Your change should probably be in the Ethernet MAC driver, when you have
successfully connected to the PHY, update phydev->supported to include
SUPPORTED_Pause | SUPPORTED_Asym_pause.


The phylib documentation (networking/phy.txt) says:

 Now just make sure that phydev->supported and phydev->advertising have any
 values pruned from them which don't make sense for your controller (a 
10/100

 controller may be connected to a gigabit capable PHY, so you would need to
 mask off SUPPORTED_1000baseT*).  See include/linux/ethtool.h for 
definitions

 for these bitfields.

and then it says:


Note that you should not SET any bits, or the PHY may
 get put into an unsupported state.


So are you sure I'm supposed to set those bits?

--
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.


Re: [PATCH 4/5] net: ethernet: bgmac: add NS2 support

2016-10-27 Thread Ray Jui


On 10/27/2016 1:51 PM, Jon Mason wrote:
> On Wed, Oct 26, 2016 at 02:50:39PM -0700, Florian Fainelli wrote:
>> On 10/26/2016 12:36 PM, Jon Mason wrote:
>>> Add support for the variant of amac hardware present in the Broadcom
>>> Northstar2 based SoCs.  Northstar2 requires an additional register to be
>>> configured with the port speed/duplexity (NICPM).  This can be added to
>>> the link callback to hide it from the instances that do not use this.
>>> Also, the bgmac_chip_reset() was intentionally removed to prevent the
>>> resetting of the chip to the default values on open.  Finally, clearing
>>> of the pending interrupts on init is required due to observed issues on
>>> some platforms.
>>>
>>> Signed-off-by: Jon Mason 
>>> ---
>>
>>> +static void bgmac_nicpm_speed_set(struct net_device *net_dev)
>>> +{
>>> +   struct bgmac *bgmac = netdev_priv(net_dev);
>>> +   u32 val;
>>> +
>>> +   if (!bgmac->plat.nicpm_base)
>>> +   return;
>>> +
>>> +   val = NICPM_IOMUX_CTRL_INIT_VAL;
>>> +   switch (bgmac->net_dev->phydev->speed) {
>>> +   default:
>>> +   pr_err("Unsupported speed.  Defaulting to 1000Mb\n");
>>> +   case SPEED_1000:
>>> +   val |= NICPM_IOMUX_CTRL_SPD_1000M << NICPM_IOMUX_CTRL_SPD_SHIFT;
>>> +   break;
>>> +   case SPEED_100:
>>> +   val |= NICPM_IOMUX_CTRL_SPD_100M << NICPM_IOMUX_CTRL_SPD_SHIFT;
>>> +   break;
>>> +   case SPEED_10:
>>> +   val |= NICPM_IOMUX_CTRL_SPD_10M << NICPM_IOMUX_CTRL_SPD_SHIFT;
>>> +   break;
>>> +   }
>>> +
>>> +   writel(val, bgmac->plat.nicpm_base + NICPM_IOMUX_CTRL);
>>> +
>>> +   usleep_range(10, 100);
>>
>> Does not seem like a good idea, do you need that sleep?
> 
> Oops, that's not supposed to be there.  Removed.
> 
> 
>>> +
>>> +   bgmac_adjust_link(bgmac->net_dev);
>>> +}
>>> +
>>>  static int platform_phy_connect(struct bgmac *bgmac)
>>>  {
>>> struct phy_device *phy_dev;
>>>  
>>> -   phy_dev = of_phy_get_and_connect(bgmac->net_dev, bgmac->dev->of_node,
>>> -bgmac_adjust_link);
>>> +   if (bgmac->plat.nicpm_base)
>>> +   phy_dev = of_phy_get_and_connect(bgmac->net_dev,
>>> +bgmac->dev->of_node,
>>> +bgmac_nicpm_speed_set);
>>> +   else
>>> +   phy_dev = of_phy_get_and_connect(bgmac->net_dev,
>>> +bgmac->dev->of_node,
>>> +bgmac_adjust_link);
>>> if (!phy_dev) {
>>> dev_err(bgmac->dev, "Phy connect failed\n");
>>> return -ENODEV;
>>> }
>>>  
>>> +   if (bgmac->feature_flags & BGMAC_FEAT_LANE_SWAP)
>>> +   phy_dev->dev_flags |= PHY_BRCM_EXP_LANE_SWAP;
>>> +
>>> return 0;
>>>  }
>>>  
>>> @@ -140,6 +188,9 @@ static int bgmac_probe(struct platform_device *pdev)
>>>  
>>> platform_set_drvdata(pdev, bgmac);
>>>  
>>> +   if (of_property_read_bool(np, "brcm,enet-phy-lane-swap"))
>>> +   bgmac->feature_flags |= BGMAC_FEAT_LANE_SWAP;
>>> +
>>> /* Set the features of the 4707 family */
>>> bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
>>> bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
>>> @@ -182,6 +233,14 @@ static int bgmac_probe(struct platform_device *pdev)
>>> if (IS_ERR(bgmac->plat.idm_base))
>>> return PTR_ERR(bgmac->plat.idm_base);
>>>  
>>> +   regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nicpm_base");
>>> +   if (regs) {
>>> +   bgmac->plat.nicpm_base = devm_ioremap_resource(&pdev->dev,
>>> +  regs);
>>> +   if (IS_ERR(bgmac->plat.nicpm_base))
>>> +   return PTR_ERR(bgmac->plat.nicpm_base);
>>> +   }
>>> +
>>> bgmac->read = platform_bgmac_read;
>>> bgmac->write = platform_bgmac_write;
>>> bgmac->idm_read = platform_bgmac_idm_read;
>>> @@ -213,6 +272,7 @@ static int bgmac_remove(struct platform_device *pdev)
>>>  static const struct of_device_id bgmac_of_enet_match[] = {
>>> {.compatible = "brcm,amac",},
>>> {.compatible = "brcm,nsp-amac",},
>>> +   {.compatible = "brcm,ns2-amac",},
>>> {},
>>>  };
>>>  
>>> diff --git a/drivers/net/ethernet/broadcom/bgmac.c 
>>> b/drivers/net/ethernet/broadcom/bgmac.c
>>> index 38876ec..1796208 100644
>>> --- a/drivers/net/ethernet/broadcom/bgmac.c
>>> +++ b/drivers/net/ethernet/broadcom/bgmac.c
>>> @@ -1082,6 +1082,9 @@ static void bgmac_enable(struct bgmac *bgmac)
>>>  /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */
>>>  static void bgmac_chip_init(struct bgmac *bgmac)
>>>  {
>>> +   /* Clear any erroneously pending interrupts */
>>> +   bgmac_write(bgmac, BGMAC_INT_STATUS, ~0);
>>> +
>>> /* 1 interrupt per received frame */
>>> bgmac_write(bgmac, BGMAC_INT_RECV_LAZY, 1 << BGMAC_IRL_FC_SHIFT);
>>>  
>>> @@ -1158,8 +1161,6 @@ static int bgmac_open(struct net_device *net_dev)
>>> struct bgmac *bgmac = netd

Re: [PATCH net-next v3 3/9] ipv6: sr: add support for SRH encapsulation and injection with lwtunnels

2016-10-27 Thread kbuild test robot
Hi David,

[auto build test ERROR on net-next/master]

url:
https://github.com/0day-ci/linux/commits/David-Lebrun/ipv6-implement-dataplane-support-for-rthdr-type-4-Segment-Routing-Header/20161027-233201
config: arm-iop13xx_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   net/built-in.o: In function `seg6_output':
>> sysctl_net.c:(.text+0xdfc8c): undefined reference to `dst_cache_get'
>> sysctl_net.c:(.text+0xdfd78): undefined reference to `dst_cache_set_ip6'

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


.config.gz
Description: application/gzip


Re: [PATCH] net: phy: at803x: the Atheros 8031 supports pause frames

2016-10-27 Thread Florian Fainelli
On 10/27/2016 03:05 PM, Timur Tabi wrote:
> The Atheros 8031 PHY supports the 802.3 extension for symmetric and
> asymmetric pause frames, so set that to the list of features supported
> by the phy.
> 
> Signed-off-by: Timur Tabi 
> ---
> 
> Without this patch, my NIC (the Qualcomm EMAC) receives a lot of frame
> check sequence (aka CRC) errors, resulting in about 10% packet loss.

Hu? In my experience that should not come from supporting Pause frames
or not, but rather properly configuring a (RG)MII delay, but your
mileage may vary.

> Can someone help me understand why?  Because of this patch, I can't use
> the generic phy driver in phylib.  Why would a MAC controller require
> its PHY to support pause frames?

It does not, support for Pause frames is a MAC-level feature, yet,
PHYLIB (and that's been on my todo for a while now) insists on reporting
the confusing phydev->pause and phydev->asym_pause, which really is what
has been determined from auto-negotiating with your partner, as opposed
to being a supported thing or not. The PHY has absolutely not business
in that.

Your change should probably be in the Ethernet MAC driver, when you have
successfully connected to the PHY, update phydev->supported to include
SUPPORTED_Pause | SUPPORTED_Asym_pause.

> 
>  drivers/net/phy/at803x.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index a52b560..fb80413 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
> @@ -440,7 +440,8 @@ static struct phy_driver at803x_driver[] = {
>   .get_wol= at803x_get_wol,
>   .suspend= at803x_suspend,
>   .resume = at803x_resume,
> - .features   = PHY_GBIT_FEATURES,
> + .features   = PHY_GBIT_FEATURES |
> +   SUPPORTED_Pause | SUPPORTED_Asym_Pause,
>   .flags  = PHY_HAS_INTERRUPT,
>   .config_aneg= genphy_config_aneg,
>   .read_status= genphy_read_status,
> 


-- 
Florian


Re: [net 4/4] i40e: fix call of ndo_dflt_bridge_getlink()

2016-10-27 Thread Greg
On Thu, 2016-10-27 at 14:27 -0700, Jeff Kirsher wrote:
> From: Huaibin Wang 
> 
> Order of arguments is wrong.
> The wrong code has been introduced by commit 7d4f8d871ab1, but is compiled
> only since commit 9df70b66418e.
> 
> Note that this may break netlink dumps.
> 
> Fixes: 9df70b66418e ("i40e: Remove incorrect #ifdef's")
> Fixes: 7d4f8d871ab1 ("switchdev; add VLAN support for port's bridge_getlink")
> CC: Carolyn Wyborny 
> Signed-off-by: Huaibin Wang 
> Signed-off-by: Nicolas Dichtel 
> Tested-by: Andrew Bowers 
> Signed-off-by: Jeff Kirsher 
> ---
>  drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
> b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index 6abc130..31c97e3 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
> @@ -9034,7 +9034,7 @@ static int i40e_ndo_bridge_getlink(struct sk_buff *skb, 
> u32 pid, u32 seq,
>   return 0;
>  
>   return ndo_dflt_bridge_getlink(skb, pid, seq, dev, veb->bridge_mode,
> -nlflags, 0, 0, filter_mask, NULL);
> +0, 0, nlflags, filter_mask, NULL);

Yikes!  And NDO function with 10 parameters?  No wonder they get mixed
up.

- Greg

>  }
>  
>  /* Hardware supports L4 tunnel length of 128B (=2^7) which includes




Re: [PATCH net-next 5/5] ipv6: Compute multipath hash for forwarded ICMP errors from offending packet

2016-10-27 Thread Jakub Sitnicki
On Thu, Oct 27, 2016 at 03:25 PM GMT, David Miller wrote:
> From: Jakub Sitnicki 
> Date: Mon, 24 Oct 2016 11:28:52 +0200
>
>> +inner_iph = skb_header_pointer(
>> +skb, skb_transport_offset(skb) + sizeof(*icmph),
>> +sizeof(_inner_iph), &_inner_iph);
>
> Please do not style this call like this, put as many arguments as
> you can on the first line.
>
>   inner_iph = skb_header_pointer(skb,
>  skb_transport_offset(skb) + 
> sizeof(*icmph),
>  sizeof(_inner_iph), &_inner_iph);
>
> And on the second and subsequent lines, indent to the first column after
> the openning parenthesis of the first line.

FWIW, I had it styled like that and then changed it. Will change back.

In my defense - checkpatch.pl made me do it, Your Honor! (line too long)


[PATCH] net: phy: at803x: the Atheros 8031 supports pause frames

2016-10-27 Thread Timur Tabi
The Atheros 8031 PHY supports the 802.3 extension for symmetric and
asymmetric pause frames, so set that to the list of features supported
by the phy.

Signed-off-by: Timur Tabi 
---

Without this patch, my NIC (the Qualcomm EMAC) receives a lot of frame
check sequence (aka CRC) errors, resulting in about 10% packet loss.
Can someone help me understand why?  Because of this patch, I can't use
the generic phy driver in phylib.  Why would a MAC controller require
its PHY to support pause frames?

 drivers/net/phy/at803x.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index a52b560..fb80413 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -440,7 +440,8 @@ static struct phy_driver at803x_driver[] = {
.get_wol= at803x_get_wol,
.suspend= at803x_suspend,
.resume = at803x_resume,
-   .features   = PHY_GBIT_FEATURES,
+   .features   = PHY_GBIT_FEATURES |
+ SUPPORTED_Pause | SUPPORTED_Asym_Pause,
.flags  = PHY_HAS_INTERRUPT,
.config_aneg= genphy_config_aneg,
.read_status= genphy_read_status,
-- 
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.



Re: [PATCH net-next 4/5] ipv6: Compute multipath hash for sent ICMP errors from offending packet

2016-10-27 Thread Jakub Sitnicki
On Thu, Oct 27, 2016 at 03:24 PM GMT, David Miller wrote:
> From: Jakub Sitnicki 
> Date: Mon, 24 Oct 2016 11:28:51 +0200
>
>> diff --git a/include/linux/icmpv6.h b/include/linux/icmpv6.h
>> index 57086e9..6282e03 100644
>> --- a/include/linux/icmpv6.h
>> +++ b/include/linux/icmpv6.h
>> @@ -45,4 +45,6 @@ extern void
>> icmpv6_flow_init(struct sock *sk,
>>   const struct in6_addr 
>> *saddr,
>>   const struct in6_addr 
>> *daddr,
>>   int oif);
>> +struct ipv6hdr;
>> +extern u32  icmpv6_multipath_hash(const struct 
>> ipv6hdr *iph);
>>  #endif
>
> We do not use "extern" in external function declarations in header file any 
> more.

My mistake, will remote it.


Re: [PATCH net-next 0/5] Route ICMPv6 errors with the flow when ECMP in use

2016-10-27 Thread Hannes Frederic Sowa
Hi,

On 27.10.2016 17:23, David Miller wrote:
> From: Jakub Sitnicki 
> Date: Mon, 24 Oct 2016 11:28:47 +0200
> 
>> However, for it to work IPv6 flow labels have to be same in both
>> directions (i.e. reflected) or need to be chosen in a manner that
>> ensures that the flow going in the opposite direction would actually
>> be routed to a given path.
> 
> My understanding is that this is not really guaranteed, and that
> entities are nearly encouraged to set the flow label in whatever
> manner makes sense for their use case.

In general this is true.

> I think we really cannot have any kind of hard dependency on how
> flow labels are set and used by the internet.

Probably/Hopefully ECMP setups are set up by the same entity that also
operates the servers, thus they can easily control the reflection of
flow labels on those servers. This might be especially important for
anycast services hosted behind ECMP services.

If the flow labels don't match, these patches are just best effort and
don't improve nor worsen the situation (lot's of traffic afaik still
carries 0 as flow label which indeed does help).

Bye,
Hannes



Re: [PATCH net-next RFC WIP] Patch for XDP support for virtio_net

2016-10-27 Thread David Miller
From: "Michael S. Tsirkin" 
Date: Fri, 28 Oct 2016 00:30:35 +0300

> Something I'd like to understand is how does XDP address the
> problem that 100Byte packets are consuming 4K of memory now.

Via page pools.  We're going to make a generic one, but right now
each and every driver implements a quick list of pages to allocate
from (and thus avoid the DMA man/unmap overhead, etc.)


[net-next PATCH 3/3] net: Add support for XPS with QoS via traffic classes

2016-10-27 Thread Alexander Duyck
This patch adds support for setting and using XPS when QoS via traffic
classes is enabled.  With this change we will factor in the priority and
traffic class mapping of the packet and use that information to correctly
select the queue.

This allows us to define a set of queues for a given traffic class via
mqprio and then configure the XPS mapping for those queues so that the
traffic flows can avoid head-of-line blocking between the individual CPUs
if so desired.

Signed-off-by: Alexander Duyck 
---
 include/linux/netdevice.h |5 +-
 net/core/dev.c|  136 +
 net/core/net-sysfs.c  |   31 +++---
 3 files changed, 122 insertions(+), 50 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d045432..56f90f7 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -732,8 +732,8 @@ struct xps_dev_maps {
struct rcu_head rcu;
struct xps_map __rcu *cpu_map[0];
 };
-#define XPS_DEV_MAPS_SIZE (sizeof(struct xps_dev_maps) +   \
-(nr_cpu_ids * sizeof(struct xps_map *)))
+#define XPS_DEV_MAPS_SIZE(_tcs) (sizeof(struct xps_dev_maps) + \
+   (nr_cpu_ids * (_tcs) * sizeof(struct xps_map *)))
 #endif /* CONFIG_XPS */
 
 #define TC_MAX_QUEUE   16
@@ -1920,6 +1920,7 @@ int netdev_set_prio_tc_map(struct net_device *dev, u8 
prio, u8 tc)
return 0;
 }
 
+int netdev_txq_to_tc(struct net_device *dev, unsigned int txq);
 void netdev_reset_tc(struct net_device *dev);
 int netdev_set_tc_queue(struct net_device *dev, u8 tc, u16 count, u16 offset);
 int netdev_set_num_tc(struct net_device *dev, u8 num_tc);
diff --git a/net/core/dev.c b/net/core/dev.c
index d124081..37c1096 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1948,6 +1948,23 @@ static void netif_setup_tc(struct net_device *dev, 
unsigned int txq)
}
 }
 
+int netdev_txq_to_tc(struct net_device *dev, unsigned int txq)
+{
+   if (dev->num_tc) {
+   struct netdev_tc_txq *tc = &dev->tc_to_txq[0];
+   int i;
+
+   for (i = 0; i < TC_MAX_QUEUE; i++, tc++) {
+   if ((txq - tc->offset) < tc->count)
+   return i;
+   }
+
+   return -1;
+   }
+
+   return 0;
+}
+
 #ifdef CONFIG_XPS
 static DEFINE_MUTEX(xps_map_mutex);
 #define xmap_dereference(P)\
@@ -1985,18 +2002,22 @@ static bool remove_xps_queue_cpu(struct net_device *dev,
 struct xps_dev_maps *dev_maps,
 int cpu, u16 offset, u16 count)
 {
+   int tc = dev->num_tc ? : 1;
bool active = false;
-   int i;
+   int tci;
 
count += offset;
-   i = count;
 
-   do {
-   if (i-- == offset) {
-   active = true;
-   break;
-   }
-   } while (remove_xps_queue(dev_maps, cpu, i));
+   for (tci = cpu * tc; tc--; tci++) {
+   int i = count;
+
+   do {
+   if (i-- == offset) {
+   active = true;
+   break;
+   }
+   } while (remove_xps_queue(dev_maps, tci, i));
+   }
 
return active;
 }
@@ -2075,20 +2096,28 @@ int netif_set_xps_queue(struct net_device *dev, const 
struct cpumask *mask,
u16 index)
 {
struct xps_dev_maps *dev_maps, *new_dev_maps = NULL;
+   int i, cpu, tci, numa_node_id = -2;
+   int maps_sz, num_tc = 1, tc = 0;
struct xps_map *map, *new_map;
-   int maps_sz = max_t(unsigned int, XPS_DEV_MAPS_SIZE, L1_CACHE_BYTES);
-   int cpu, numa_node_id = -2;
bool active = false;
 
+   if (dev->num_tc) {
+   num_tc = dev->num_tc;
+   tc = netdev_txq_to_tc(dev, index);
+   if (tc < 0)
+   return -EINVAL;
+   }
+
+   maps_sz = XPS_DEV_MAPS_SIZE(num_tc);
+   if (maps_sz < L1_CACHE_BYTES)
+   maps_sz = L1_CACHE_BYTES;
+
mutex_lock(&xps_map_mutex);
 
dev_maps = xmap_dereference(dev->xps_maps);
 
/* allocate memory for queue storage */
-   for_each_online_cpu(cpu) {
-   if (!cpumask_test_cpu(cpu, mask))
-   continue;
-
+   for_each_cpu_and(cpu, cpu_online_mask, mask) {
if (!new_dev_maps)
new_dev_maps = kzalloc(maps_sz, GFP_KERNEL);
if (!new_dev_maps) {
@@ -2096,25 +2125,35 @@ int netif_set_xps_queue(struct net_device *dev, const 
struct cpumask *mask,
return -ENOMEM;
}
 
-   map = dev_maps ? xmap_dereference(dev_maps->cpu_map[cpu]) :
+   tci = cpu * num_tc + tc;
+   map = dev_maps ? xmap_dereference(dev_maps->cpu_map[tci]) :
 NULL;
 
map = expand_xps_

[net-next PATCH 0/3] Add support for XPS when using DCB

2016-10-27 Thread Alexander Duyck
This patch series enables proper isolation between traffic classes when
using XPS while DCB is enabled.  Previously enabling XPS would cause the
traffic to be potentially pulled from one traffic class into another on
egress.  This change essentially multiplies the XPS map by the number of
traffic classes and allows us to do a lookup per traffic class for a given
CPU.

To guarantee the isolation I invalidate the XPS map for any queues that are
moved from one traffic class to another, or if we change the number of
traffic classes.

---

Alexander Duyck (3):
  net: Move functions for configuring traffic classes out of inline headers
  net: Refactor removal of queues from XPS map and apply on num_tc changes
  net: Add support for XPS with QoS via traffic classes


 include/linux/netdevice.h |   36 +--
 net/core/dev.c|  228 +++--
 net/core/net-sysfs.c  |   31 --
 3 files changed, 202 insertions(+), 93 deletions(-)

--


[net-next PATCH 2/3] net: Refactor removal of queues from XPS map and apply on num_tc changes

2016-10-27 Thread Alexander Duyck
This patch updates the code for removing queues from the XPS map and makes
it so that we can apply the code any time we change either the number of
traffic classes or the mapping of a given block of queues.  This way we
avoid having queues pulling traffic from a foreign traffic class.

Signed-off-by: Alexander Duyck 
---
 net/core/dev.c |   79 
 1 file changed, 56 insertions(+), 23 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index d4d45bf..d124081 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1953,32 +1953,56 @@ static void netif_setup_tc(struct net_device *dev, 
unsigned int txq)
 #define xmap_dereference(P)\
rcu_dereference_protected((P), lockdep_is_held(&xps_map_mutex))
 
-static struct xps_map *remove_xps_queue(struct xps_dev_maps *dev_maps,
-   int cpu, u16 index)
+static bool remove_xps_queue(struct xps_dev_maps *dev_maps,
+int tci, u16 index)
 {
struct xps_map *map = NULL;
int pos;
 
if (dev_maps)
-   map = xmap_dereference(dev_maps->cpu_map[cpu]);
+   map = xmap_dereference(dev_maps->cpu_map[tci]);
+   if (!map)
+   return false;
 
-   for (pos = 0; map && pos < map->len; pos++) {
-   if (map->queues[pos] == index) {
-   if (map->len > 1) {
-   map->queues[pos] = map->queues[--map->len];
-   } else {
-   RCU_INIT_POINTER(dev_maps->cpu_map[cpu], NULL);
-   kfree_rcu(map, rcu);
-   map = NULL;
-   }
+   for (pos = map->len; pos--;) {
+   if (map->queues[pos] != index)
+   continue;
+
+   if (map->len > 1) {
+   map->queues[pos] = map->queues[--map->len];
break;
}
+
+   RCU_INIT_POINTER(dev_maps->cpu_map[tci], NULL);
+   kfree_rcu(map, rcu);
+   return false;
}
 
-   return map;
+   return true;
 }
 
-static void netif_reset_xps_queues_gt(struct net_device *dev, u16 index)
+static bool remove_xps_queue_cpu(struct net_device *dev,
+struct xps_dev_maps *dev_maps,
+int cpu, u16 offset, u16 count)
+{
+   bool active = false;
+   int i;
+
+   count += offset;
+   i = count;
+
+   do {
+   if (i-- == offset) {
+   active = true;
+   break;
+   }
+   } while (remove_xps_queue(dev_maps, cpu, i));
+
+   return active;
+}
+
+static void netif_reset_xps_queues(struct net_device *dev, u16 offset,
+  u16 count)
 {
struct xps_dev_maps *dev_maps;
int cpu, i;
@@ -1990,21 +2014,16 @@ static void netif_reset_xps_queues_gt(struct net_device 
*dev, u16 index)
if (!dev_maps)
goto out_no_maps;
 
-   for_each_possible_cpu(cpu) {
-   for (i = index; i < dev->num_tx_queues; i++) {
-   if (!remove_xps_queue(dev_maps, cpu, i))
-   break;
-   }
-   if (i == dev->num_tx_queues)
-   active = true;
-   }
+   for_each_possible_cpu(cpu)
+   active |= remove_xps_queue_cpu(dev, dev_maps, cpu, offset,
+  count);
 
if (!active) {
RCU_INIT_POINTER(dev->xps_maps, NULL);
kfree_rcu(dev_maps, rcu);
}
 
-   for (i = index; i < dev->num_tx_queues; i++)
+   for (i = offset + (count - 1); count--; i--)
netdev_queue_numa_node_write(netdev_get_tx_queue(dev, i),
 NUMA_NO_NODE);
 
@@ -2012,6 +2031,11 @@ static void netif_reset_xps_queues_gt(struct net_device 
*dev, u16 index)
mutex_unlock(&xps_map_mutex);
 }
 
+static void netif_reset_xps_queues_gt(struct net_device *dev, u16 index)
+{
+   netif_reset_xps_queues(dev, index, dev->num_tx_queues - index);
+}
+
 static struct xps_map *expand_xps_map(struct xps_map *map,
  int cpu, u16 index)
 {
@@ -2175,6 +2199,9 @@ int netif_set_xps_queue(struct net_device *dev, const 
struct cpumask *mask,
 #endif
 void netdev_reset_tc(struct net_device *dev)
 {
+#ifdef CONFIG_XPS
+   netif_reset_xps_queues_gt(dev, 0);
+#endif
dev->num_tc = 0;
memset(dev->tc_to_txq, 0, sizeof(dev->tc_to_txq));
memset(dev->prio_tc_map, 0, sizeof(dev->prio_tc_map));
@@ -2186,6 +2213,9 @@ int netdev_set_tc_queue(struct net_device *dev, u8 tc, 
u16 count, u16 offset)
if (tc >= dev->num_tc)
return -EINVAL;
 
+#ifdef CONFIG_XPS
+   netif_reset_xps_queues(dev, offset, cou

[net-next PATCH 1/3] net: Move functions for configuring traffic classes out of inline headers

2016-10-27 Thread Alexander Duyck
The functions for configuring the traffic class to queue mappings have
other effects that need to be addressed.  Instead of trying to export a
bunch of new functions just relocate the functions so that we can
instrument them directly with the functionality they will need.

Signed-off-by: Alexander Duyck 
---
 include/linux/netdevice.h |   31 +++
 net/core/dev.c|   29 +
 2 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 458c876..d045432 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1920,34 +1920,9 @@ int netdev_set_prio_tc_map(struct net_device *dev, u8 
prio, u8 tc)
return 0;
 }
 
-static inline
-void netdev_reset_tc(struct net_device *dev)
-{
-   dev->num_tc = 0;
-   memset(dev->tc_to_txq, 0, sizeof(dev->tc_to_txq));
-   memset(dev->prio_tc_map, 0, sizeof(dev->prio_tc_map));
-}
-
-static inline
-int netdev_set_tc_queue(struct net_device *dev, u8 tc, u16 count, u16 offset)
-{
-   if (tc >= dev->num_tc)
-   return -EINVAL;
-
-   dev->tc_to_txq[tc].count = count;
-   dev->tc_to_txq[tc].offset = offset;
-   return 0;
-}
-
-static inline
-int netdev_set_num_tc(struct net_device *dev, u8 num_tc)
-{
-   if (num_tc > TC_MAX_QUEUE)
-   return -EINVAL;
-
-   dev->num_tc = num_tc;
-   return 0;
-}
+void netdev_reset_tc(struct net_device *dev);
+int netdev_set_tc_queue(struct net_device *dev, u8 tc, u16 count, u16 offset);
+int netdev_set_num_tc(struct net_device *dev, u8 num_tc);
 
 static inline
 int netdev_get_num_tc(struct net_device *dev)
diff --git a/net/core/dev.c b/net/core/dev.c
index f55fb45..d4d45bf 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2173,6 +2173,35 @@ int netif_set_xps_queue(struct net_device *dev, const 
struct cpumask *mask,
 EXPORT_SYMBOL(netif_set_xps_queue);
 
 #endif
+void netdev_reset_tc(struct net_device *dev)
+{
+   dev->num_tc = 0;
+   memset(dev->tc_to_txq, 0, sizeof(dev->tc_to_txq));
+   memset(dev->prio_tc_map, 0, sizeof(dev->prio_tc_map));
+}
+EXPORT_SYMBOL(netdev_reset_tc);
+
+int netdev_set_tc_queue(struct net_device *dev, u8 tc, u16 count, u16 offset)
+{
+   if (tc >= dev->num_tc)
+   return -EINVAL;
+
+   dev->tc_to_txq[tc].count = count;
+   dev->tc_to_txq[tc].offset = offset;
+   return 0;
+}
+EXPORT_SYMBOL(netdev_set_tc_queue);
+
+int netdev_set_num_tc(struct net_device *dev, u8 num_tc)
+{
+   if (num_tc > TC_MAX_QUEUE)
+   return -EINVAL;
+
+   dev->num_tc = num_tc;
+   return 0;
+}
+EXPORT_SYMBOL(netdev_set_num_tc);
+
 /*
  * Routine to help set real_num_tx_queues. To avoid skbs mapped to queues
  * greater then real_num_tx_queues stale skbs on the qdisc must be flushed.



Re: [PATCH net-next RFC WIP] Patch for XDP support for virtio_net

2016-10-27 Thread Michael S. Tsirkin
On Thu, Oct 27, 2016 at 02:09:08PM -0700, John Fastabend wrote:
> On 16-10-27 01:55 AM, Jesper Dangaard Brouer wrote:
> > On Wed, 26 Oct 2016 13:11:22 -0400 (EDT)
> > David Miller  wrote:
> > 
> >> From: "Michael S. Tsirkin" 
> >> Date: Wed, 26 Oct 2016 20:07:19 +0300
> >>
> >>> On Wed, Oct 26, 2016 at 12:52:45PM -0400, David Miller wrote:  
>  From: "Michael S. Tsirkin" 
>  Date: Wed, 26 Oct 2016 19:36:45 +0300
>    
> > On Wed, Oct 26, 2016 at 03:52:02PM +0200, Jesper Dangaard Brouer wrote: 
> >  
> >> On Sat, 22 Oct 2016 04:07:23 +
> >> Shrijeet Mukherjee  wrote:
> >>   
> >>> This patch adds support for xdp ndo and also inserts the xdp program
> >>> call into the merged RX buffers and big buffers paths  
> >>
> >> I really appreciate you are doing this for virtio_net.
> >>
> >> My first question is: Is the (packet) page data writable?
> >> (MST might be able to answer?)
> >>
> >> As this is currently an XDP requirement[1].
> >
> > I'm not sure I understand what does writable mean.
> > Could you explain a bit more pls?
> > We do copy data into skb ATM but I plan to change that.  
> 
>  The packet data area must be writable,  
> >>>
> >>> This is the part I don't fully understand.
> >>> It's in RAM so of course it's writeable.  
> >>
> >> Pages in SKB frag lists are not usually writable, because they share
> >> space with data from other packets the way drivers usually carve up
> >> pages to receive packets into.
> >>
> >> It is therefore illegal for the networking code to write into SKB frag
> >> pages.
> >>
> >> Pages used for XDP processed packets must not have this restriction.
> >>
> >>> We share pages between arbitrary multiple packets. I think that's
> >>> OK  
> >>
> >> That's exactly what is not allowed with XDP.
> >>
> >> Each packet must be the sole user of a page, otherwise the semantics
> >> required by XDP are not met.
> > 
> > Looking at the virtio_net.c code, the function call receive_big() might
> > actually be okay for XDP, unless the incoming packet is larger than
> > PAGE_SIZE and thus uses several pages (via a linked list in page->private).
> > 
> > The receive_mergeable() does not look compatible with XDP.
> > 
> 
> Looks to me the correct conditions can be met by getting the correct
> feature negotiation to happen, specifically no VIRTIO_NET_F_MRG_RXBUF
> and one of the TSO/ECN/GSO feature bits set the big_packets flag as
> Jesper notes.
> 
> Srijeet, are you going to give this a try? I'm trying to get the device
> side working by the way on the vhost interface.
> 
> Thanks,
> John

Something I'd like to understand is how does XDP address the
problem that 100Byte packets are consuming 4K of memory now.

-- 
MST


[net 0/4][pull request] Intel Wired LAN Driver Updates 2016-10-27

2016-10-27 Thread Jeff Kirsher
This series contains fixes to ixgbe and i40e.

Emil fixes a NULL pointer dereference when a macvlan interface is brought
up while the PF is still down.

David root caused the original panic that was fixed by commit id
(a036244c068612 "i40e: Fix kernel panic on enable/disable LLDP") and the
fix was not quite correct, so removed the get_default_tc() and replaced
it with a #define since there is only one TC supported as a default.

Guilherme Piccoli fixes an issue where if we modprobe the driver module
without enough MSI-X interrupts, then unload the module and reload it
again, the kernel would crash.  So if we fail to allocate enough MSI-X
interrupts, we should disable them since they were previously enabled.

Huaibin Wang found that the order of the arguments for
ndo_dflt_bridge_getlink() were in the correct order, so fix the order.

The following are changes since commit d5d32e4b76687f4df9ad3ba8d3702b7347f51fa6:
  net: ipv6: Do not consider link state for nexthop validation
and are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-queue 40GbE

David Ertman (1):
  i40e: Fix configure TCs after initial DCB disable

Emil Tantilov (1):
  ixgbe: fix panic when using macvlan with l2-fwd-offload enabled

Guilherme G Piccoli (1):
  i40e: disable MSI-X interrupts if we cannot reserve enough vectors

Huaibin Wang (1):
  i40e: fix call of ndo_dflt_bridge_getlink()

 drivers/net/ethernet/intel/i40e/i40e.h|  1 +
 drivers/net/ethernet/intel/i40e/i40e_main.c   | 34 +--
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 12 ++
 3 files changed, 15 insertions(+), 32 deletions(-)

-- 
2.7.4



[net 3/4] i40e: disable MSI-X interrupts if we cannot reserve enough vectors

2016-10-27 Thread Jeff Kirsher
From: Guilherme G Piccoli 

If we fail on allocating enough MSI-X interrupts, we should disable
them since they were previously enabled in this point of code.

Not disabling them can lead to WARN_ON() being triggered and subsequent
failure in enabling MSI as a fallback; the below message was shown without
this patch while we played with interrupt allocation in i40e driver:

[ 21.461346] sysfs: cannot create duplicate filename 
'/devices/pci0007:00/0007:00:00.0/0007:01:00.3/msi_irqs'
[ 21.461459] [ cut here ]
[ 21.461514] WARNING: CPU: 64 PID: 1155 at fs/sysfs/dir.c:31 
sysfs_warn_dup+0x88/0xc0

Also, we noticed that without this patch, if we modprobe the module without
enough MSI-X interrupts (triggering the above warning), unload the module
and re-load it again, we got a crash on the system.

Signed-off-by: Guilherme G Piccoli 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 050d005..6abc130 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -7684,6 +7684,7 @@ static int i40e_init_msix(struct i40e_pf *pf)
pf->flags &= ~I40E_FLAG_MSIX_ENABLED;
kfree(pf->msix_entries);
pf->msix_entries = NULL;
+   pci_disable_msix(pf->pdev);
return -ENODEV;
 
} else if (v_actual == I40E_MIN_MSIX) {
-- 
2.7.4



[net 2/4] i40e: Fix configure TCs after initial DCB disable

2016-10-27 Thread Jeff Kirsher
From: David Ertman 

in commit a036244c068612a43fa8c0f33a0eb4daa4d8dba0 a fix
was put into place to avoid a kernel panic when a non-
supported traffic class configuration was put into place
and then lldp was enabled/disabled on the link partner
switch.  This fix caused it to be necessary to
unload/reload the driver to reenable DCB once a supported
TC config was in place.

The root cause of the original panic was that the function
i40e_pf_get_default_tc was allowing for a default TC other
than TC 0, and only TC 0 is supported as a default.

This patch removes the get_default_tc function and replaces
it with a #define since there is only one TC supported as
a default.

Change-Id: I448371974e946386d0a7718d73668b450b7c72ef
Signed-off-by: Dave Ertman 
Tested-by: Ronald Bynoe 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e.h  |  1 +
 drivers/net/ethernet/intel/i40e/i40e_main.c | 31 -
 2 files changed, 5 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e.h 
b/drivers/net/ethernet/intel/i40e/i40e.h
index 2030d7c..6d61e44 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -92,6 +92,7 @@
 #define I40E_AQ_LEN256
 #define I40E_AQ_WORK_LIMIT 66 /* max number of VFs + a little */
 #define I40E_MAX_USER_PRIORITY 8
+#define I40E_DEFAULT_TRAFFIC_CLASS BIT(0)
 #define I40E_DEFAULT_MSG_ENABLE4
 #define I40E_QUEUE_WAIT_RETRY_LIMIT10
 #define I40E_INT_NAME_STR_LEN  (IFNAMSIZ + 16)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
b/drivers/net/ethernet/intel/i40e/i40e_main.c
index ac1faee..050d005 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -4641,29 +4641,6 @@ static u8 i40e_pf_get_num_tc(struct i40e_pf *pf)
 }
 
 /**
- * i40e_pf_get_default_tc - Get bitmap for first enabled TC
- * @pf: PF being queried
- *
- * Return a bitmap for first enabled traffic class for this PF.
- **/
-static u8 i40e_pf_get_default_tc(struct i40e_pf *pf)
-{
-   u8 enabled_tc = pf->hw.func_caps.enabled_tcmap;
-   u8 i = 0;
-
-   if (!enabled_tc)
-   return 0x1; /* TC0 */
-
-   /* Find the first enabled TC */
-   for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
-   if (enabled_tc & BIT(i))
-   break;
-   }
-
-   return BIT(i);
-}
-
-/**
  * i40e_pf_get_pf_tc_map - Get bitmap for enabled traffic classes
  * @pf: PF being queried
  *
@@ -4673,7 +4650,7 @@ static u8 i40e_pf_get_tc_map(struct i40e_pf *pf)
 {
/* If DCB is not enabled for this PF then just return default TC */
if (!(pf->flags & I40E_FLAG_DCB_ENABLED))
-   return i40e_pf_get_default_tc(pf);
+   return I40E_DEFAULT_TRAFFIC_CLASS;
 
/* SFP mode we want PF to be enabled for all TCs */
if (!(pf->flags & I40E_FLAG_MFP_ENABLED))
@@ -4683,7 +4660,7 @@ static u8 i40e_pf_get_tc_map(struct i40e_pf *pf)
if (pf->hw.func_caps.iscsi)
return i40e_get_iscsi_tc_map(pf);
else
-   return i40e_pf_get_default_tc(pf);
+   return I40E_DEFAULT_TRAFFIC_CLASS;
 }
 
 /**
@@ -5029,7 +5006,7 @@ static void i40e_dcb_reconfigure(struct i40e_pf *pf)
if (v == pf->lan_vsi)
tc_map = i40e_pf_get_tc_map(pf);
else
-   tc_map = i40e_pf_get_default_tc(pf);
+   tc_map = I40E_DEFAULT_TRAFFIC_CLASS;
 #ifdef I40E_FCOE
if (pf->vsi[v]->type == I40E_VSI_FCOE)
tc_map = i40e_get_fcoe_tc_map(pf);
@@ -5717,7 +5694,7 @@ static int i40e_handle_lldp_event(struct i40e_pf *pf,
u8 type;
 
/* Not DCB capable or capability disabled */
-   if (!(pf->flags & I40E_FLAG_DCB_ENABLED))
+   if (!(pf->flags & I40E_FLAG_DCB_CAPABLE))
return ret;
 
/* Ignore if event is not for Nearest Bridge */
-- 
2.7.4



[net 4/4] i40e: fix call of ndo_dflt_bridge_getlink()

2016-10-27 Thread Jeff Kirsher
From: Huaibin Wang 

Order of arguments is wrong.
The wrong code has been introduced by commit 7d4f8d871ab1, but is compiled
only since commit 9df70b66418e.

Note that this may break netlink dumps.

Fixes: 9df70b66418e ("i40e: Remove incorrect #ifdef's")
Fixes: 7d4f8d871ab1 ("switchdev; add VLAN support for port's bridge_getlink")
CC: Carolyn Wyborny 
Signed-off-by: Huaibin Wang 
Signed-off-by: Nicolas Dichtel 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 6abc130..31c97e3 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -9034,7 +9034,7 @@ static int i40e_ndo_bridge_getlink(struct sk_buff *skb, 
u32 pid, u32 seq,
return 0;
 
return ndo_dflt_bridge_getlink(skb, pid, seq, dev, veb->bridge_mode,
-  nlflags, 0, 0, filter_mask, NULL);
+  0, 0, nlflags, filter_mask, NULL);
 }
 
 /* Hardware supports L4 tunnel length of 128B (=2^7) which includes
-- 
2.7.4



[net 1/4] ixgbe: fix panic when using macvlan with l2-fwd-offload enabled

2016-10-27 Thread Jeff Kirsher
From: Emil Tantilov 

Fix NULL pointer dereference in the case where a macvlan interface is
brought up while the PF is still down:

BUG: unable to handle kernel NULL pointer dereference at 0010
IP: [] ixgbe_alloc_rx_buffers+0x42/0x1a0 [ixgbe]

Call Trace:
[] ixgbe_configure_rx_ring+0x2eb/0x3d0 [ixgbe]
[] ixgbe_fwd_ring_up+0xd1/0x380 [ixgbe]
[] ixgbe_fwd_add+0x149/0x230 [ixgbe]
[] macvlan_open+0x260/0x2b0 [macvlan]

Reported-by: Matthew Garrett 
Signed-off-by: Emil Tantilov 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index a244d9a..bd93d82 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -9135,10 +9135,14 @@ static void *ixgbe_fwd_add(struct net_device *pdev, 
struct net_device *vdev)
goto fwd_add_err;
fwd_adapter->pool = pool;
fwd_adapter->real_adapter = adapter;
-   err = ixgbe_fwd_ring_up(vdev, fwd_adapter);
-   if (err)
-   goto fwd_add_err;
-   netif_tx_start_all_queues(vdev);
+
+   if (netif_running(pdev)) {
+   err = ixgbe_fwd_ring_up(vdev, fwd_adapter);
+   if (err)
+   goto fwd_add_err;
+   netif_tx_start_all_queues(vdev);
+   }
+
return fwd_adapter;
 fwd_add_err:
/* unwind counter and free adapter struct */
-- 
2.7.4



Re: [PATCH 2/5] Documentation: devicetree: net: add NS2 bindings to amac

2016-10-27 Thread Florian Fainelli
On 10/27/2016 02:21 PM, Jon Mason wrote:
> On Thu, Oct 27, 2016 at 11:17:57AM +0200, Andrew Lunn wrote:
>> On Wed, Oct 26, 2016 at 03:35:58PM -0400, Jon Mason wrote:
>>> Signed-off-by: Jon Mason 
>>> ---
>>>  Documentation/devicetree/bindings/net/brcm,amac.txt | 7 +--
>>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/Documentation/devicetree/bindings/net/brcm,amac.txt 
>>> b/Documentation/devicetree/bindings/net/brcm,amac.txt
>>> index ba5ecc1..f92caee 100644
>>> --- a/Documentation/devicetree/bindings/net/brcm,amac.txt
>>> +++ b/Documentation/devicetree/bindings/net/brcm,amac.txt
>>> @@ -2,15 +2,18 @@ Broadcom AMAC Ethernet Controller Device Tree Bindings
>>>  -
>>>  
>>>  Required properties:
>>> - - compatible: "brcm,amac" or "brcm,nsp-amac"
>>> + - compatible: "brcm,amac", "brcm,nsp-amac", or "brcm,ns2-amac"
>>>   - reg:Address and length of the GMAC registers,
>>> Address and length of the GMAC IDM registers
>>> +   Address and length of the NIC Port Manager registers (optional)
>>>   - reg-names:  Names of the registers.  Must have both "amac_base" and
>>> -   "idm_base"
>>> +   "idm_base". "nicpm_base" is optional (required for NS2)
>>>   - interrupts: Interrupt number
>>>  
>>>  Optional properties:
>>>  - mac-address: See ethernet.txt file in the same directory
>>> +- brcm,enet-phy-lane-swap:
>>> +   boolean; Swap the PHY lanes (needed on some SKUs of NS2)
>>
>> Maybe i'm missing something here, but the patch to the PHY swapped the
>> lanes. This seems to be a PHY property, not a MAC property. And it
>> swapped them unconditionally
> 
> It swapped them based on (from patch 1/5)
>if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 &&
>phydev->dev_flags & PHY_BRCM_EXP_LANE_SWAP)
> 
> That flag is being set in the driver based on whether the lanes need
> to be swapped (which depends on the SKU of NS2).  The only SKU of NS2
> we have upstream right now has it swapped, but one that should be
> pushed out in the next few weeks will not have this flag present.
> There is no way to detect it, and having a separate compat string
> seemed overkill.

Andrew has a point thought that this is a property that is associated
with the PHY, and not with the Ethernet MAC per se, as such, you can put
it in the Ethernet PHY node, and look up the proper from
drivers/net/phy/broadcom.c, and come up with a Broadcom Ethernet PHY
binding document (sorry).

There is no need to have a specific compatible string allocated, using
the (mostly) generic Ethernet PHY binding, plus this property documented
would be good enough.
-- 
Florian


Re: [PATCH 2/5] Documentation: devicetree: net: add NS2 bindings to amac

2016-10-27 Thread Jon Mason
On Thu, Oct 27, 2016 at 11:17:57AM +0200, Andrew Lunn wrote:
> On Wed, Oct 26, 2016 at 03:35:58PM -0400, Jon Mason wrote:
> > Signed-off-by: Jon Mason 
> > ---
> >  Documentation/devicetree/bindings/net/brcm,amac.txt | 7 +--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/net/brcm,amac.txt 
> > b/Documentation/devicetree/bindings/net/brcm,amac.txt
> > index ba5ecc1..f92caee 100644
> > --- a/Documentation/devicetree/bindings/net/brcm,amac.txt
> > +++ b/Documentation/devicetree/bindings/net/brcm,amac.txt
> > @@ -2,15 +2,18 @@ Broadcom AMAC Ethernet Controller Device Tree Bindings
> >  -
> >  
> >  Required properties:
> > - - compatible: "brcm,amac" or "brcm,nsp-amac"
> > + - compatible: "brcm,amac", "brcm,nsp-amac", or "brcm,ns2-amac"
> >   - reg:Address and length of the GMAC registers,
> > Address and length of the GMAC IDM registers
> > +   Address and length of the NIC Port Manager registers (optional)
> >   - reg-names:  Names of the registers.  Must have both "amac_base" and
> > -   "idm_base"
> > +   "idm_base". "nicpm_base" is optional (required for NS2)
> >   - interrupts: Interrupt number
> >  
> >  Optional properties:
> >  - mac-address: See ethernet.txt file in the same directory
> > +- brcm,enet-phy-lane-swap:
> > +   boolean; Swap the PHY lanes (needed on some SKUs of NS2)
> 
> Maybe i'm missing something here, but the patch to the PHY swapped the
> lanes. This seems to be a PHY property, not a MAC property. And it
> swapped them unconditionally

It swapped them based on (from patch 1/5)
   if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 &&
   phydev->dev_flags & PHY_BRCM_EXP_LANE_SWAP)

That flag is being set in the driver based on whether the lanes need
to be swapped (which depends on the SKU of NS2).  The only SKU of NS2
we have upstream right now has it swapped, but one that should be
pushed out in the next few weeks will not have this flag present.
There is no way to detect it, and having a separate compat string
seemed overkill.

Thanks,
Jon

> 
>   Andrew


Re: [PATCH v2] net: skip genenerating uevents for network namespaces that are exiting

2016-10-27 Thread David Miller
From: Andrei Vagin 
Date: Mon, 24 Oct 2016 19:09:53 -0700

> No one can see these events, because a network namespace can not be
> destroyed, if it has sockets.
> 
> Unlike other devices, uevent-s for network devices are generated
> only inside their network namespaces. They are filtered in
> kobj_bcast_filter()
> 
> My experiments shows that net namespaces are destroyed more 30% faster
> with this optimization.
> 
> Here is a perf output for destroying network namespaces without this
> patch.
 ...
> It's very critical to optimize the exit path for network namespaces,
> because they are destroyed under net_mutex and many namespaces can be
> destroyed for one iteration.
> 
> v2: use dev_set_uevent_suppress()
> 
> Cc: Cong Wang 
> Cc: "David S. Miller" 
> Cc: Eric W. Biederman 
> Signed-off-by: Andrei Vagin 

Applied to net-next, thanks.


Re: Pure polling mode for netdevices

2016-10-27 Thread Zach Brown
On Fri, Oct 21, 2016 at 11:41:46AM -0700, Eric Dumazet wrote:
> On Fri, 2016-10-21 at 13:03 -0500, Zach Brown wrote:
> > Is there a way to get NAPI to poll all the time?
> > Or just any way to get netdevices to use only polling and no interrupts?
> > 
> > We have some rt targets where the jitter can be improved by disabling
> > interrupts and using just polling. In these cases we're okay with the
> > performance downsides that come with polling.
> > 
> > In particular we already have an implementation for the cadence macb driver
> > that does only polling mode and have verified that it improves the
> > jitter.
> > 
> > We're hoping for a more general existing solution or at the very least a
> > solution that would be accepted upstream. Any thoughts?
> 
> This is not yet done, although you could use busy poll infrastructure to
> get this without a kernel change.
> 
> Open as many TCP flows are necessary to traverse all the queues you care
> about, then loop on recvmsg() to trigger NAPI polling.
> 
> 

I looked into the busy poll infrastructure and I don't think it meets our
needs. We're not interested in minimizing the latency of the ethernet device,
but rather diminishing if not eliminating the system jitter cause by ethernet
interrupts. Not to mention that some interfaces like macb don't provide a lot
of the config options to make busy polling really work well. For example,
interrupt coalescing configuration. 

I was thinking more along the lines of an extenstion to the NAPI interface that
drivers can opt into that allows them to enter NAPI polling mode and never
leave when configured to do so.  



Re: [PATCH v2 net 1/1] net sched filters: fix notification of filter delete with proper handle

2016-10-27 Thread David Miller
From: Jamal Hadi Salim 
Date: Mon, 24 Oct 2016 20:18:27 -0400

> From: Jamal Hadi Salim 
> 
> Daniel says:
> 
> While trying out [1][2], I noticed that tc monitor doesn't show the
> correct handle on delete:
> 
> $ tc monitor
> qdisc clsact : dev eno1 parent :fff1
> filter dev eno1 ingress protocol all pref 49152 bpf handle 0x2a [...]
> deleted filter dev eno1 ingress protocol all pref 49152 bpf handle 0xf3be0c80
> 
> some context to explain the above:
> The user identity of any tc filter is represented by a 32-bit
> identifier encoded in tcm->tcm_handle. Example 0x2a in the bpf filter
> above. A user wishing to delete, get or even modify a specific filter
> uses this handle to reference it.
> Every classifier is free to provide its own semantics for the 32 bit handle.
> Example: classifiers like u32 use schemes like 800:1:801 to describe
> the semantics of their filters represented as hash table, bucket and
> node ids etc.
> Classifiers also have internal per-filter representation which is different
> from this externally visible identity. Most classifiers set this
> internal representation to be a pointer address (which allows fast retrieval
> of said filters in their implementations). This internal representation
> is referenced with the "fh" variable in the kernel control code.
> 
> When a user successfuly deletes a specific filter, by specifying the correct
> tcm->tcm_handle, an event is generated to user space which indicates
> which specific filter was deleted.
> 
> Before this patch, the "fh" value was sent to user space as the identity.
> As an example what is shown in the sample bpf filter delete event above
> is 0xf3be0c80. This is infact a 32-bit truncation of 0x8807f3be0c80
> which happens to be a 64-bit memory address of the internal filter
> representation (address of the corresponding filter's struct cls_bpf_prog);
> 
> After this patch the appropriate user identifiable handle as encoded
> in the originating request tcm->tcm_handle is generated in the event.
> One of the cardinal rules of netlink rules is to be able to take an
> event (such as a delete in this case) and reflect it back to the
> kernel and successfully delete the filter. This patch achieves that.
> 
> Note, this issue has existed since the original TC action
> infrastructure code patch back in 2004 as found in:
> https://git.kernel.org/cgit/linux/kernel/git/history/history.git/commit/
> 
> [1] http://patchwork.ozlabs.org/patch/682828/
> [2] http://patchwork.ozlabs.org/patch/682829/
> 
> Fixes: 4e54c4816bfe ("[NET]: Add tc extensions infrastructure.")
> Reported-by: Daniel Borkmann 
> Acked-by: Cong Wang 
> Signed-off-by: Jamal Hadi Salim 

Applied and queued up for -stable, thanks Jamal.


Re: [PATCH net-next RFC WIP] Patch for XDP support for virtio_net

2016-10-27 Thread John Fastabend
On 16-10-27 01:55 AM, Jesper Dangaard Brouer wrote:
> On Wed, 26 Oct 2016 13:11:22 -0400 (EDT)
> David Miller  wrote:
> 
>> From: "Michael S. Tsirkin" 
>> Date: Wed, 26 Oct 2016 20:07:19 +0300
>>
>>> On Wed, Oct 26, 2016 at 12:52:45PM -0400, David Miller wrote:  
 From: "Michael S. Tsirkin" 
 Date: Wed, 26 Oct 2016 19:36:45 +0300
   
> On Wed, Oct 26, 2016 at 03:52:02PM +0200, Jesper Dangaard Brouer wrote:  
>> On Sat, 22 Oct 2016 04:07:23 +
>> Shrijeet Mukherjee  wrote:
>>   
>>> This patch adds support for xdp ndo and also inserts the xdp program
>>> call into the merged RX buffers and big buffers paths  
>>
>> I really appreciate you are doing this for virtio_net.
>>
>> My first question is: Is the (packet) page data writable?
>> (MST might be able to answer?)
>>
>> As this is currently an XDP requirement[1].
>
> I'm not sure I understand what does writable mean.
> Could you explain a bit more pls?
> We do copy data into skb ATM but I plan to change that.  

 The packet data area must be writable,  
>>>
>>> This is the part I don't fully understand.
>>> It's in RAM so of course it's writeable.  
>>
>> Pages in SKB frag lists are not usually writable, because they share
>> space with data from other packets the way drivers usually carve up
>> pages to receive packets into.
>>
>> It is therefore illegal for the networking code to write into SKB frag
>> pages.
>>
>> Pages used for XDP processed packets must not have this restriction.
>>
>>> We share pages between arbitrary multiple packets. I think that's
>>> OK  
>>
>> That's exactly what is not allowed with XDP.
>>
>> Each packet must be the sole user of a page, otherwise the semantics
>> required by XDP are not met.
> 
> Looking at the virtio_net.c code, the function call receive_big() might
> actually be okay for XDP, unless the incoming packet is larger than
> PAGE_SIZE and thus uses several pages (via a linked list in page->private).
> 
> The receive_mergeable() does not look compatible with XDP.
> 

Looks to me the correct conditions can be met by getting the correct
feature negotiation to happen, specifically no VIRTIO_NET_F_MRG_RXBUF
and one of the TSO/ECN/GSO feature bits set the big_packets flag as
Jesper notes.

Srijeet, are you going to give this a try? I'm trying to get the device
side working by the way on the vhost interface.

Thanks,
John



Re: [PATCH 4/5] net: ethernet: bgmac: add NS2 support

2016-10-27 Thread Jon Mason
On Wed, Oct 26, 2016 at 02:50:39PM -0700, Florian Fainelli wrote:
> On 10/26/2016 12:36 PM, Jon Mason wrote:
> > Add support for the variant of amac hardware present in the Broadcom
> > Northstar2 based SoCs.  Northstar2 requires an additional register to be
> > configured with the port speed/duplexity (NICPM).  This can be added to
> > the link callback to hide it from the instances that do not use this.
> > Also, the bgmac_chip_reset() was intentionally removed to prevent the
> > resetting of the chip to the default values on open.  Finally, clearing
> > of the pending interrupts on init is required due to observed issues on
> > some platforms.
> > 
> > Signed-off-by: Jon Mason 
> > ---
> 
> > +static void bgmac_nicpm_speed_set(struct net_device *net_dev)
> > +{
> > +   struct bgmac *bgmac = netdev_priv(net_dev);
> > +   u32 val;
> > +
> > +   if (!bgmac->plat.nicpm_base)
> > +   return;
> > +
> > +   val = NICPM_IOMUX_CTRL_INIT_VAL;
> > +   switch (bgmac->net_dev->phydev->speed) {
> > +   default:
> > +   pr_err("Unsupported speed.  Defaulting to 1000Mb\n");
> > +   case SPEED_1000:
> > +   val |= NICPM_IOMUX_CTRL_SPD_1000M << NICPM_IOMUX_CTRL_SPD_SHIFT;
> > +   break;
> > +   case SPEED_100:
> > +   val |= NICPM_IOMUX_CTRL_SPD_100M << NICPM_IOMUX_CTRL_SPD_SHIFT;
> > +   break;
> > +   case SPEED_10:
> > +   val |= NICPM_IOMUX_CTRL_SPD_10M << NICPM_IOMUX_CTRL_SPD_SHIFT;
> > +   break;
> > +   }
> > +
> > +   writel(val, bgmac->plat.nicpm_base + NICPM_IOMUX_CTRL);
> > +
> > +   usleep_range(10, 100);
> 
> Does not seem like a good idea, do you need that sleep?

Oops, that's not supposed to be there.  Removed.


> > +
> > +   bgmac_adjust_link(bgmac->net_dev);
> > +}
> > +
> >  static int platform_phy_connect(struct bgmac *bgmac)
> >  {
> > struct phy_device *phy_dev;
> >  
> > -   phy_dev = of_phy_get_and_connect(bgmac->net_dev, bgmac->dev->of_node,
> > -bgmac_adjust_link);
> > +   if (bgmac->plat.nicpm_base)
> > +   phy_dev = of_phy_get_and_connect(bgmac->net_dev,
> > +bgmac->dev->of_node,
> > +bgmac_nicpm_speed_set);
> > +   else
> > +   phy_dev = of_phy_get_and_connect(bgmac->net_dev,
> > +bgmac->dev->of_node,
> > +bgmac_adjust_link);
> > if (!phy_dev) {
> > dev_err(bgmac->dev, "Phy connect failed\n");
> > return -ENODEV;
> > }
> >  
> > +   if (bgmac->feature_flags & BGMAC_FEAT_LANE_SWAP)
> > +   phy_dev->dev_flags |= PHY_BRCM_EXP_LANE_SWAP;
> > +
> > return 0;
> >  }
> >  
> > @@ -140,6 +188,9 @@ static int bgmac_probe(struct platform_device *pdev)
> >  
> > platform_set_drvdata(pdev, bgmac);
> >  
> > +   if (of_property_read_bool(np, "brcm,enet-phy-lane-swap"))
> > +   bgmac->feature_flags |= BGMAC_FEAT_LANE_SWAP;
> > +
> > /* Set the features of the 4707 family */
> > bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
> > bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
> > @@ -182,6 +233,14 @@ static int bgmac_probe(struct platform_device *pdev)
> > if (IS_ERR(bgmac->plat.idm_base))
> > return PTR_ERR(bgmac->plat.idm_base);
> >  
> > +   regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nicpm_base");
> > +   if (regs) {
> > +   bgmac->plat.nicpm_base = devm_ioremap_resource(&pdev->dev,
> > +  regs);
> > +   if (IS_ERR(bgmac->plat.nicpm_base))
> > +   return PTR_ERR(bgmac->plat.nicpm_base);
> > +   }
> > +
> > bgmac->read = platform_bgmac_read;
> > bgmac->write = platform_bgmac_write;
> > bgmac->idm_read = platform_bgmac_idm_read;
> > @@ -213,6 +272,7 @@ static int bgmac_remove(struct platform_device *pdev)
> >  static const struct of_device_id bgmac_of_enet_match[] = {
> > {.compatible = "brcm,amac",},
> > {.compatible = "brcm,nsp-amac",},
> > +   {.compatible = "brcm,ns2-amac",},
> > {},
> >  };
> >  
> > diff --git a/drivers/net/ethernet/broadcom/bgmac.c 
> > b/drivers/net/ethernet/broadcom/bgmac.c
> > index 38876ec..1796208 100644
> > --- a/drivers/net/ethernet/broadcom/bgmac.c
> > +++ b/drivers/net/ethernet/broadcom/bgmac.c
> > @@ -1082,6 +1082,9 @@ static void bgmac_enable(struct bgmac *bgmac)
> >  /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */
> >  static void bgmac_chip_init(struct bgmac *bgmac)
> >  {
> > +   /* Clear any erroneously pending interrupts */
> > +   bgmac_write(bgmac, BGMAC_INT_STATUS, ~0);
> > +
> > /* 1 interrupt per received frame */
> > bgmac_write(bgmac, BGMAC_INT_RECV_LAZY, 1 << BGMAC_IRL_FC_SHIFT);
> >  
> > @@ -1158,8 +1161,6 @@ static int bgmac_open(struct net_device *net_dev)
> > struct bgmac *bgmac = netdev_priv(net_dev);
> > int err = 0;
> >  
> > -   

Re: [PATCH] net: bgmac: fix spelling mistake: "connecton" -> "connection"

2016-10-27 Thread David Miller
From: Colin King 
Date: Mon, 24 Oct 2016 23:46:18 +0100

> From: Colin Ian King 
> 
> trivial fix to spelling mistake in dev_err message
> 
> Signed-off-by: Colin Ian King 

Applied.


Re: [PATCH v3 net] flow_dissector: fix vlan tag handling

2016-10-27 Thread David Miller
From: Arnd Bergmann 
Date: Mon, 24 Oct 2016 23:40:30 +0200

> gcc warns about an uninitialized pointer dereference in the vlan
> priority handling:
> 
> net/core/flow_dissector.c: In function '__skb_flow_dissect':
> net/core/flow_dissector.c:281:61: error: 'vlan' may be used uninitialized in 
> this function [-Werror=maybe-uninitialized]
> 
> As pointed out by Jiri Pirko, the variable is never actually used
> without being initialized first as the only way it end up uninitialized
> is with skb_vlan_tag_present(skb)==true, and that means it does not
> get accessed.
> 
> However, the warning hints at some related issues that I'm addressing
> here:
> 
> - the second check for the vlan tag is different from the first one
>   that tests the skb for being NULL first, causing both the warning
>   and a possible NULL pointer dereference that was not entirely fixed.
> - The same patch that introduced the NULL pointer check dropped an
>   earlier optimization that skipped the repeated check of the
>   protocol type
> - The local '_vlan' variable is referenced through the 'vlan' pointer
>   but the variable has gone out of scope by the time that it is
>   accessed, causing undefined behavior
> 
> Caching the result of the 'skb && skb_vlan_tag_present(skb)' check
> in a local variable allows the compiler to further optimize the
> later check. With those changes, the warning also disappears.
> 
> Fixes: 3805a938a6c2 ("flow_dissector: Check skb for VLAN only if skb 
> specified.")
> Fixes: d5709f7ab776 ("flow_dissector: For stripped vlan, get vlan info from 
> skb->vlan_tci")
> Signed-off-by: Arnd Bergmann 

Applied, thanks Arnd.


Re: [PATCH] net: ipv6: Do not consider link state for nexthop validation

2016-10-27 Thread David Miller
From: David Ahern 
Date: Mon, 24 Oct 2016 12:27:23 -0700

> Similar to IPv4, do not consider link state when validating next hops.
> 
> Currently, if the link is down default routes can fail to insert:
>  $ ip -6 ro add vrf blue default via 2100:2::64 dev eth2
>  RTNETLINK answers: No route to host
> 
> With this patch the command succeeds.
> 
> Fixes: 8c14586fc320 ("net: ipv6: Use passed in table for nexthop lookups")
> Signed-off-by: David Ahern 

Applied and queued up for -stable.


[patch net-next v2] rocker: set physical device for port netdevice

2016-10-27 Thread Jiri Pirko
From: Jiri Pirko 

Do this so the sysfs has "device" link correctly set.

Signed-off-by: Jiri Pirko 
---
v1->v2:
 - make pdev non-const as pointerd out by kbuild test robot
---
 drivers/net/ethernet/rocker/rocker_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index 2e81b70..55b2ab9 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -2534,7 +2534,7 @@ static void rocker_port_dev_addr_init(struct rocker_port 
*rocker_port)
 #define ROCKER_PORT_MAX_MTU9000
 static int rocker_probe_port(struct rocker *rocker, unsigned int port_number)
 {
-   const struct pci_dev *pdev = rocker->pdev;
+   struct pci_dev *pdev = rocker->pdev;
struct rocker_port *rocker_port;
struct net_device *dev;
int err;
@@ -2542,6 +2542,7 @@ static int rocker_probe_port(struct rocker *rocker, 
unsigned int port_number)
dev = alloc_etherdev(sizeof(struct rocker_port));
if (!dev)
return -ENOMEM;
+   SET_NETDEV_DEV(dev, &pdev->dev);
rocker_port = netdev_priv(dev);
rocker_port->dev = dev;
rocker_port->rocker = rocker;
-- 
2.5.5



Re: [PATCH v2] net: ipv6: Fix processing of RAs in presence of VRF

2016-10-27 Thread David Miller
From: David Ahern 
Date: Mon, 24 Oct 2016 10:52:35 -0700

> rt6_add_route_info and rt6_add_dflt_router were updated to pull the FIB
> table from the device index, but the corresponding rt6_get_route_info
> and rt6_get_dflt_router functions were not leading to the failure to
> process RA's:
> 
> ICMPv6: RA: ndisc_router_discovery failed to add default route
> 
> Fix the 'get' functions by using the table id associated with the
> device when applicable.
> 
> Also, now that default routes can be added to tables other than the
> default table, rt6_purge_dflt_routers needs to be updated as well to
> look at all tables. To handle that efficiently, add a flag to the table
> denoting if it is has a default route via RA.
> 
> Fixes: ca254490c8dfd ("net: Add VRF support to IPv6 stack")
> Signed-off-by: David Ahern 

Applied and queued up for -stable, thanks.


Re: [PATCH] kalmia: avoid potential uninitialized variable use

2016-10-27 Thread David Miller
From: Arnd Bergmann 
Date: Mon, 24 Oct 2016 17:54:18 +0200

> The kalmia_send_init_packet() returns zero or a negative return
> code, but gcc has no way of knowing that there cannot be a
> positive return code, so it determines that copying the ethernet
> address at the end of kalmia_bind() will access uninitialized
> data:
> 
> drivers/net/usb/kalmia.c: In function ‘kalmia_bind’:
> arch/x86/include/asm/string_32.h:78:22: error: ‘*((void *)ðernet_addr+4)’ 
> may be used uninitialized in this function [-Werror=maybe-uninitialized]
>*((short *)to + 2) = *((short *)from + 2);
>   ^
> drivers/net/usb/kalmia.c:138:5: note: ‘*((void *)ðernet_addr+4)’ was 
> declared here
> 
> This warning is harmless, but for consistency, we should make
> the check for the return code match what the driver does everywhere
> else and just progate it, which then gets rid of the warning.
> 
> Signed-off-by: Arnd Bergmann 

Applied, thanks.


Re: [patch net-next] rocker: set physical device for port netdevice

2016-10-27 Thread Jiri Pirko
Thu, Oct 27, 2016 at 10:03:46PM CEST, l...@intel.com wrote:
>Hi Jiri,
>
>[auto build test WARNING on net-next/master]
>
>url:
>https://github.com/0day-ci/linux/commits/Jiri-Pirko/rocker-set-physical-device-for-port-netdevice/20161028-030044
>config: tile-allmodconfig (attached as .config)
>compiler: tilegx-linux-gcc (GCC) 4.6.2
>reproduce:
>wget 
> https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
>  -O ~/bin/make.cross
>chmod +x ~/bin/make.cross
># save the attached .config to linux build tree
>make.cross ARCH=tile 
>
>All warnings (new ones prefixed by >>):
>
>   drivers/net/ethernet/rocker/rocker_main.c: In function 'rocker_probe_port':
>>> drivers/net/ethernet/rocker/rocker_main.c:2545:2: warning: assignment 
>>> discards 'const' qualifier from pointer target type [enabled by default]
>

Sigh, sending v2. 


Re: [PATCH] ip6_tunnel: Clear IP6CB(skb)->frag_max_size in ip4ip6_tnl_xmit()

2016-10-27 Thread David Miller
From: Eli Cooper 
Date: Mon, 24 Oct 2016 23:07:12 +0800

> diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
> index 202d16a..4110562 100644
> --- a/net/ipv6/ip6_tunnel.c
> +++ b/net/ipv6/ip6_tunnel.c
> @@ -1205,6 +1205,7 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device 
> *dev)
>   int err;
>  
>   memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
> + IP6CB(skb)->frag_max_size = 0;
>  
>   tproto = ACCESS_ONCE(t->parms.proto);
>   if (tproto != IPPROTO_IPIP && tproto != 0)

This doesn't look right at all.

Either skb->cb is interpreted as IPCB() past this point, or
it is interpreted as IP6CB().

So pick which structure is used, and simply clear that specific
structure.


Re: [PATCH v2 net] macsec: Fix header length if SCI is added if explicitly disabled

2016-10-27 Thread David Miller
From: Tobias Brunner 
Date: Mon, 24 Oct 2016 15:44:26 +0200

> Even if sending SCIs is explicitly disabled, the code that creates the
> Security Tag might still decide to add it (e.g. if multiple RX SCs are
> defined on the MACsec interface).
> But because the header length so far only depended on the configuration
> option the SCI overwrote the original frame's contents (EtherType and
> e.g. the beginning of the IP header) and if encrypted did not visibly
> end up in the packet, while the SC flag in the TCI field of the Security
> Tag was still set, resulting in invalid MACsec frames.
> 
> Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
> Signed-off-by: Tobias Brunner 

Applied and queued up for -stable.


Re: [PATCH net-next] ethernet: fix min/max MTU typos

2016-10-27 Thread David Miller
From: Stefan Richter 
Date: Mon, 24 Oct 2016 14:42:26 +0200

> Fixes: d894be57ca92('ethernet: use net core MTU range checking in more 
> drivers')
> CC: Jarod Wilson 
> CC: Thomas Falcon 
> Signed-off-by: Stefan Richter 

Applied.


Re: [PATCH 0/5] genetlink improvements

2016-10-27 Thread David Miller
From: Johannes Berg 
Date: Mon, 24 Oct 2016 14:40:00 +0200

> This series contains some generic netlink improvements, making
> the API safer to use, and making the function pointers in the
> family struct safer by allowing it to be __ro_after_init.

Looks great, series applied, thanks!


Re: [PATCH v4] skbedit: allow the user to specify bitmask for mark

2016-10-27 Thread David Miller
From: Antonio Quartulli 
Date: Mon, 24 Oct 2016 20:32:57 +0800

> The user may want to use only some bits of the skb mark in
> his skbedit rules because the remaining part might be used by
> something else.
> 
> Introduce the "mask" parameter to the skbedit actor in order
> to implement such functionality.
> 
> When the mask is specified, only those bits selected by the
> latter are altered really changed by the actor, while the
> rest is left untouched.
> 
> Signed-off-by: Antonio Quartulli 
> Signed-off-by: Jamal Hadi Salim 

Applied, thanks.


Re: [PATCH 1/2] Revert "at803x: fix suspend/resume for SGMII link"

2016-10-27 Thread David Miller
From: Zefir Kurtisi 
Date: Mon, 24 Oct 2016 12:40:53 +0200

> This reverts commit 98267311fe3b334ae7c107fa0e2413adcf3ba735.
> 
> Suspending the SGMII alongside the copper side
> made the at803x inaccessable while powered down,
> e.g. it can't be re-probed after suspend.
> 
> Signed-off-by: Zefir Kurtisi 

Applied.


Re: [PATCH 2/2] at803x: double check SGMII side autoneg

2016-10-27 Thread David Miller
From: Zefir Kurtisi 
Date: Mon, 24 Oct 2016 12:40:54 +0200

> In SGMII mode, we observed an autonegotiation issue
> after power-down-up cycles where the copper side
> reports successful link establishment but the
> SGMII side's link is down.
> 
> This happened in a setup where the at8031 is
> connected over SGMII to a eTSEC (fsl gianfar),
> but so far could not be reproduced with other
> Ethernet device / driver combinations.
> 
> This commit adds a wrapper function for at8031
> that in case of operating in SGMII mode double
> checks SGMII link state when generic aneg_done()
> succeeds. It prints a warning on failure but
> intentionally does not try to recover from this
> state. As a result, if you ever see a warning
> '803x_aneg_done: SGMII link is not ok' you will
> end up having an Ethernet link up but won't get
> any data through. This should not happen, if it
> does, please contact the module maintainer.
> 
> Signed-off-by: Zefir Kurtisi 

Applied.


Re: [patch net-next] rocker: set physical device for port netdevice

2016-10-27 Thread kbuild test robot
Hi Jiri,

[auto build test WARNING on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Jiri-Pirko/rocker-set-physical-device-for-port-netdevice/20161028-030044
config: tile-allmodconfig (attached as .config)
compiler: tilegx-linux-gcc (GCC) 4.6.2
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=tile 

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/rocker/rocker_main.c: In function 'rocker_probe_port':
>> drivers/net/ethernet/rocker/rocker_main.c:2545:2: warning: assignment 
>> discards 'const' qualifier from pointer target type [enabled by default]

vim +/const +2545 drivers/net/ethernet/rocker/rocker_main.c

  2529  eth_hw_addr_random(rocker_port->dev);
  2530  }
  2531  }
  2532  
  2533  #define ROCKER_PORT_MIN_MTU ETH_MIN_MTU
  2534  #define ROCKER_PORT_MAX_MTU 9000
  2535  static int rocker_probe_port(struct rocker *rocker, unsigned int 
port_number)
  2536  {
  2537  const struct pci_dev *pdev = rocker->pdev;
  2538  struct rocker_port *rocker_port;
  2539  struct net_device *dev;
  2540  int err;
  2541  
  2542  dev = alloc_etherdev(sizeof(struct rocker_port));
  2543  if (!dev)
  2544  return -ENOMEM;
> 2545  SET_NETDEV_DEV(dev, &pdev->dev);
  2546  rocker_port = netdev_priv(dev);
  2547  rocker_port->dev = dev;
  2548  rocker_port->rocker = rocker;
  2549  rocker_port->port_number = port_number;
  2550  rocker_port->pport = port_number + 1;
  2551  
  2552  err = rocker_world_check_init(rocker_port);
  2553  if (err) {

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


.config.gz
Description: application/gzip


Re: [patch net-next] rocker: set physical device for port netdevice

2016-10-27 Thread kbuild test robot
Hi Jiri,

[auto build test WARNING on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Jiri-Pirko/rocker-set-physical-device-for-port-netdevice/20161028-030044
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   In file included from drivers/net/ethernet/rocker/rocker_main.c:21:0:
   drivers/net/ethernet/rocker/rocker_main.c: In function 'rocker_probe_port':
>> include/linux/netdevice.h:2062:54: warning: assignment discards 'const' 
>> qualifier from pointer target type
#define SET_NETDEV_DEV(net, pdev) ((net)->dev.parent = (pdev))
 ^
>> drivers/net/ethernet/rocker/rocker_main.c:2545:2: note: in expansion of 
>> macro 'SET_NETDEV_DEV'
 SET_NETDEV_DEV(dev, &pdev->dev);
 ^

vim +/SET_NETDEV_DEV +2545 drivers/net/ethernet/rocker/rocker_main.c

  2529  eth_hw_addr_random(rocker_port->dev);
  2530  }
  2531  }
  2532  
  2533  #define ROCKER_PORT_MIN_MTU ETH_MIN_MTU
  2534  #define ROCKER_PORT_MAX_MTU 9000
  2535  static int rocker_probe_port(struct rocker *rocker, unsigned int 
port_number)
  2536  {
  2537  const struct pci_dev *pdev = rocker->pdev;
  2538  struct rocker_port *rocker_port;
  2539  struct net_device *dev;
  2540  int err;
  2541  
  2542  dev = alloc_etherdev(sizeof(struct rocker_port));
  2543  if (!dev)
  2544  return -ENOMEM;
> 2545  SET_NETDEV_DEV(dev, &pdev->dev);
  2546  rocker_port = netdev_priv(dev);
  2547  rocker_port->dev = dev;
  2548  rocker_port->rocker = rocker;
  2549  rocker_port->port_number = port_number;
  2550  rocker_port->pport = port_number + 1;
  2551  
  2552  err = rocker_world_check_init(rocker_port);
  2553  if (err) {

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


.config.gz
Description: application/gzip


Re: [PATCH net-next 1/3] net: core: Add a UID field to struct sock.

2016-10-27 Thread David Miller
From: Eric Dumazet 
Date: Thu, 27 Oct 2016 10:36:26 -0700

> On Fri, 2016-10-28 at 02:20 +0900, Lorenzo Colitti wrote:
> 
>> diff --git a/net/core/sock.c b/net/core/sock.c
>> index d8e4532e..831e4e8 100644
>> --- a/net/core/sock.c
>> +++ b/net/core/sock.c
>> @@ -1570,6 +1570,7 @@ struct sock *sk_clone_lock(const struct sock *sk, 
>> const gfp_t priority)
>>   */
>>  sk_refcnt_debug_inc(newsk);
>>  sk_set_socket(newsk, NULL);
>> +newsk->sk_uid = sk->sk_uid;
> 
> Not sure why this is needed ?
> 
> sk_clone_lock() already copies sk to newsk, using sock_copy(newsk, sk);

Agreed.


Re: [PATCH net-next 1/3] net: core: Add a UID field to struct sock.

2016-10-27 Thread kbuild test robot
Hi Lorenzo,

[auto build test WARNING on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Lorenzo-Colitti/net-core-Add-a-UID-field-to-struct-sock/20161028-020552
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   include/linux/skbuff.h:947: warning: No description found for parameter 'sk'
   include/net/sock.h:450: warning: No description found for parameter 
'sk_padding'
>> include/net/sock.h:450: warning: No description found for parameter 'sk_uid'
   include/net/sock.h:450: warning: No description found for parameter 'sk_rcu'
   include/linux/netdevice.h:1902: warning: No description found for parameter 
'prio_tc_map[TC_BITMASK + 1]'

vim +/sk_uid +450 include/net/sock.h

ef64a54f6 Pavel Emelyanov 2012-02-21  434   __s32   
sk_peek_off;
^1da177e4 Linus Torvalds  2005-04-16  435   int 
sk_write_pending;
d5f642384 Alexey Dobriyan 2008-11-04  436  #ifdef CONFIG_SECURITY
^1da177e4 Linus Torvalds  2005-04-16  437   void
*sk_security;
d5f642384 Alexey Dobriyan 2008-11-04  438  #endif
2a56a1fec Tejun Heo   2015-12-07  439   struct sock_cgroup_data 
sk_cgrp_data;
baac50bbc Johannes Weiner 2016-01-14  440   struct mem_cgroup   
*sk_memcg;
^1da177e4 Linus Torvalds  2005-04-16  441   void
(*sk_state_change)(struct sock *sk);
676d23690 David S. Miller 2014-04-11  442   void
(*sk_data_ready)(struct sock *sk);
^1da177e4 Linus Torvalds  2005-04-16  443   void
(*sk_write_space)(struct sock *sk);
^1da177e4 Linus Torvalds  2005-04-16  444   void
(*sk_error_report)(struct sock *sk);
^1da177e4 Linus Torvalds  2005-04-16  445   int 
(*sk_backlog_rcv)(struct sock *sk,
^1da177e4 Linus Torvalds  2005-04-16  446   
  struct sk_buff *skb);
^1da177e4 Linus Torvalds  2005-04-16  447   void
(*sk_destruct)(struct sock *sk);
ef456144d Craig Gallek2016-01-04  448   struct sock_reuseport __rcu 
*sk_reuseport_cb;
a4298e452 Eric Dumazet2016-04-01  449   struct rcu_head sk_rcu;
^1da177e4 Linus Torvalds  2005-04-16 @450  };
^1da177e4 Linus Torvalds  2005-04-16  451  
559835ea7 Pravin B Shelar 2013-09-24  452  #define __sk_user_data(sk) ((*((void 
__rcu **)&(sk)->sk_user_data)))
559835ea7 Pravin B Shelar 2013-09-24  453  
559835ea7 Pravin B Shelar 2013-09-24  454  #define 
rcu_dereference_sk_user_data(sk) rcu_dereference(__sk_user_data((sk)))
559835ea7 Pravin B Shelar 2013-09-24  455  #define rcu_assign_sk_user_data(sk, 
ptr) rcu_assign_pointer(__sk_user_data((sk)), ptr)
559835ea7 Pravin B Shelar 2013-09-24  456  
4a17fd522 Pavel Emelyanov 2012-04-19  457  /*
4a17fd522 Pavel Emelyanov 2012-04-19  458   * SK_CAN_REUSE and SK_NO_REUSE on a 
socket mean that the socket is OK

:: The code at line 450 was first introduced by commit
:: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:: TO: Linus Torvalds 
:: CC: Linus Torvalds 

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


.config.gz
Description: application/gzip


[PATCH 11/17] batman-adv: Allow selecting BATMAN V if CFG80211 is not built

2016-10-27 Thread Simon Wunderlich
From: Linus Lüssing 

With the new stub for cfg80211_get_station(), we can now build the
BATMAN V protocol even with a kernel that was built without any
wireless support.

Signed-off-by: Linus Lüssing 
Signed-off-by: Sven Eckelmann 
Signed-off-by: Simon Wunderlich 
---
 net/batman-adv/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/Kconfig b/net/batman-adv/Kconfig
index f20742c..b73b96a 100644
--- a/net/batman-adv/Kconfig
+++ b/net/batman-adv/Kconfig
@@ -17,7 +17,7 @@ config BATMAN_ADV
 
 config BATMAN_ADV_BATMAN_V
bool "B.A.T.M.A.N. V protocol (experimental)"
-   depends on BATMAN_ADV && CFG80211=y || (CFG80211=m && BATMAN_ADV=m)
+   depends on BATMAN_ADV && !(CFG80211=m && BATMAN_ADV=y)
default n
help
  This option enables the B.A.T.M.A.N. V protocol, the successor
-- 
2.10.1



[PATCH 07/17] batman-adv: Move batadv_sum_counter to soft-interface.c

2016-10-27 Thread Simon Wunderlich
From: Sven Eckelmann 

The function batadv_sum_counter is only used in soft-interface.c and has no
special relevance for main.h.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Simon Wunderlich 
---
 net/batman-adv/main.h   | 21 -
 net/batman-adv/soft-interface.c | 21 +
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 8b0979b..6a2328d 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -185,7 +185,6 @@ enum batadv_uev_type {
 
 #include  /* for packet.h */
 #include 
-#include 
 #include 
 #include  /* for packet.h */
 #include 
@@ -284,26 +283,6 @@ static inline void batadv_add_counter(struct batadv_priv 
*bat_priv, size_t idx,
 
 #define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1)
 
-/**
- * batadv_sum_counter - Sum the cpu-local counters for index 'idx'
- * @bat_priv: the bat priv with all the soft interface information
- * @idx: index of counter to sum up
- *
- * Return: sum of all cpu-local counters
- */
-static inline u64 batadv_sum_counter(struct batadv_priv *bat_priv,  size_t idx)
-{
-   u64 *counters, sum = 0;
-   int cpu;
-
-   for_each_possible_cpu(cpu) {
-   counters = per_cpu_ptr(bat_priv->bat_counters, cpu);
-   sum += counters[idx];
-   }
-
-   return sum;
-}
-
 /* Define a macro to reach the control buffer of the skb. The members of the
  * control buffer are defined in struct batadv_skb_cb in types.h.
  * The macro is inspired by the similar macro TCP_SKB_CB() in tcp.h.
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 49e16b6..f37c1c7 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -116,6 +117,26 @@ static int batadv_interface_release(struct net_device *dev)
return 0;
 }
 
+/**
+ * batadv_sum_counter - Sum the cpu-local counters for index 'idx'
+ * @bat_priv: the bat priv with all the soft interface information
+ * @idx: index of counter to sum up
+ *
+ * Return: sum of all cpu-local counters
+ */
+static u64 batadv_sum_counter(struct batadv_priv *bat_priv,  size_t idx)
+{
+   u64 *counters, sum = 0;
+   int cpu;
+
+   for_each_possible_cpu(cpu) {
+   counters = per_cpu_ptr(bat_priv->bat_counters, cpu);
+   sum += counters[idx];
+   }
+
+   return sum;
+}
+
 static struct net_device_stats *batadv_interface_stats(struct net_device *dev)
 {
struct batadv_priv *bat_priv = netdev_priv(dev);
-- 
2.10.1



[PATCH 03/17] batman-adv: Add network_coding and mcast sysfs files to README

2016-10-27 Thread Simon Wunderlich
From: Sven Eckelmann 

Signed-off-by: Sven Eckelmann 
Signed-off-by: Simon Wunderlich 
---
 Documentation/networking/batman-adv.txt | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Documentation/networking/batman-adv.txt 
b/Documentation/networking/batman-adv.txt
index d414e60..8afa991 100644
--- a/Documentation/networking/batman-adv.txt
+++ b/Documentation/networking/batman-adv.txt
@@ -71,10 +71,11 @@ All  mesh  wide  settings  can be found in batman's own 
interface
 folder:
 
 # ls /sys/class/net/bat0/mesh/
-#aggregated_ogmsdistributed_arp_table  gw_sel_classorig_interval
-#ap_isolation   fragmentation  hop_penalty routing_algo
-#bondinggw_bandwidth   isolation_mark  vlan0
-#bridge_loop_avoidance  gw_modelog_level
+# aggregated_ogmsfragmentation  isolation_mark  routing_algo
+# ap_isolation   gw_bandwidth   log_level   vlan0
+# bondinggw_modemulticast_mode
+# bridge_loop_avoidance  gw_sel_class   network_coding
+# distributed_arp_table  hop_penaltyorig_interval
 
 There is a special folder for debugging information:
 
-- 
2.10.1



[PATCH 14/17] batman-adv: Use proper name for fragments list head

2016-10-27 Thread Simon Wunderlich
From: Sven Eckelmann 

The batman-adv codebase is using "list" for the list node (prev/next) and
+"_list" for the head of a list. Not using this
naming scheme can up in confusions because list_head is used for both the
head of the list and the list node (prev/next) in each item of the list.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Simon Wunderlich 
---
 net/batman-adv/fragmentation.c | 14 +++---
 net/batman-adv/fragmentation.h |  2 +-
 net/batman-adv/originator.c|  2 +-
 net/batman-adv/types.h |  6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index 1b2f5b9..2b967a3 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -73,7 +73,7 @@ void batadv_frag_purge_orig(struct batadv_orig_node 
*orig_node,
spin_lock_bh(&chain->lock);
 
if (!check_cb || check_cb(chain)) {
-   batadv_frag_clear_chain(&chain->head);
+   batadv_frag_clear_chain(&chain->fragment_list);
chain->size = 0;
}
 
@@ -117,8 +117,8 @@ static bool batadv_frag_init_chain(struct 
batadv_frag_table_entry *chain,
if (chain->seqno == seqno)
return false;
 
-   if (!hlist_empty(&chain->head))
-   batadv_frag_clear_chain(&chain->head);
+   if (!hlist_empty(&chain->fragment_list))
+   batadv_frag_clear_chain(&chain->fragment_list);
 
chain->size = 0;
chain->seqno = seqno;
@@ -176,7 +176,7 @@ static bool batadv_frag_insert_packet(struct 
batadv_orig_node *orig_node,
chain = &orig_node->fragments[bucket];
spin_lock_bh(&chain->lock);
if (batadv_frag_init_chain(chain, seqno)) {
-   hlist_add_head(&frag_entry_new->list, &chain->head);
+   hlist_add_head(&frag_entry_new->list, &chain->fragment_list);
chain->size = skb->len - hdr_size;
chain->timestamp = jiffies;
chain->total_size = ntohs(frag_packet->total_size);
@@ -185,7 +185,7 @@ static bool batadv_frag_insert_packet(struct 
batadv_orig_node *orig_node,
}
 
/* Find the position for the new fragment. */
-   hlist_for_each_entry(frag_entry_curr, &chain->head, list) {
+   hlist_for_each_entry(frag_entry_curr, &chain->fragment_list, list) {
/* Drop packet if fragment already exists. */
if (frag_entry_curr->no == frag_entry_new->no)
goto err_unlock;
@@ -220,11 +220,11 @@ static bool batadv_frag_insert_packet(struct 
batadv_orig_node *orig_node,
 * exceeds the maximum size of one merged packet. Don't allow
 * packets to have different total_size.
 */
-   batadv_frag_clear_chain(&chain->head);
+   batadv_frag_clear_chain(&chain->fragment_list);
chain->size = 0;
} else if (ntohs(frag_packet->total_size) == chain->size) {
/* All fragments received. Hand over chain to caller. */
-   hlist_move_list(&chain->head, chain_out);
+   hlist_move_list(&chain->fragment_list, chain_out);
chain->size = 0;
}
 
diff --git a/net/batman-adv/fragmentation.h b/net/batman-adv/fragmentation.h
index 3202fe3..b95f619 100644
--- a/net/batman-adv/fragmentation.h
+++ b/net/batman-adv/fragmentation.h
@@ -47,7 +47,7 @@ int batadv_frag_send_packet(struct sk_buff *skb,
 static inline bool
 batadv_frag_check_entry(struct batadv_frag_table_entry *frags_entry)
 {
-   if (!hlist_empty(&frags_entry->head) &&
+   if (!hlist_empty(&frags_entry->fragment_list) &&
batadv_has_timed_out(frags_entry->timestamp, BATADV_FRAG_TIMEOUT))
return true;
return false;
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 6af87c9..518b1ed 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -1021,7 +1021,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct 
batadv_priv *bat_priv,
batadv_orig_node_vlan_put(vlan);
 
for (i = 0; i < BATADV_FRAG_BUFFER_COUNT; i++) {
-   INIT_HLIST_HEAD(&orig_node->fragments[i].head);
+   INIT_HLIST_HEAD(&orig_node->fragments[i].fragment_list);
spin_lock_init(&orig_node->fragments[i].lock);
orig_node->fragments[i].size = 0;
}
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 97336ec..d31e7ec 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -184,7 +184,7 @@ struct batadv_orig_ifinfo {
 
 /**
  * struct batadv_frag_table_entry - head in the fragment buffer table
- * @head: head of list with fragments
+ * @fragment_list: head of list with fragments
  * @lock: lock to protect the list of fragments
  * @timestamp: time (jiffie) of last received fragment
  * @seqno: sequence numbe

[PATCH 02/17] batman-adv: Add B.A.T.M.A.N. V sysfs files to README

2016-10-27 Thread Simon Wunderlich
From: Sven Eckelmann 

Signed-off-by: Sven Eckelmann 
Signed-off-by: Simon Wunderlich 
---
 Documentation/networking/batman-adv.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/networking/batman-adv.txt 
b/Documentation/networking/batman-adv.txt
index 8a8d3d9..d414e60 100644
--- a/Documentation/networking/batman-adv.txt
+++ b/Documentation/networking/batman-adv.txt
@@ -32,7 +32,7 @@ compatible interfaces. Once found, it will create  subfolders 
 in
 the /sys directories of each supported interface, e.g.
 
 # ls /sys/class/net/eth0/batman_adv/
-# iface_status  mesh_iface
+# elp_interval  iface_status  mesh_iface  throughput_override
 
 If an interface does not have the "batman_adv" subfolder it prob-
 ably is not supported. Not supported  interfaces  are:  loopback,
-- 
2.10.1



[PATCH 05/17] batman-adv: Document new nc, mcast and tpmeter log levels

2016-10-27 Thread Simon Wunderlich
From: Sven Eckelmann 

Signed-off-by: Sven Eckelmann 
Signed-off-by: Simon Wunderlich 
---
 Documentation/networking/batman-adv.txt | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/Documentation/networking/batman-adv.txt 
b/Documentation/networking/batman-adv.txt
index a918131..ccf9467 100644
--- a/Documentation/networking/batman-adv.txt
+++ b/Documentation/networking/batman-adv.txt
@@ -161,13 +161,16 @@ file in debugfs
 The additional debug output is by default disabled. It can be en-
 abled  during run time. Following log_levels are defined:
 
-0 - All  debug  output  disabled
-1 - Enable messages related to routing / flooding / broadcasting
-2 - Enable messages related to route added / changed / deleted
-4 - Enable messages related to translation table operations
-8 - Enable messages related to bridge loop avoidance
-16 - Enable messaged related to DAT, ARP snooping and parsing
-31 - Enable all messages
+  0 - All  debug  output  disabled
+  1 - Enable messages related to routing / flooding / broadcasting
+  2 - Enable messages related to route added / changed / deleted
+  4 - Enable messages related to translation table operations
+  8 - Enable messages related to bridge loop avoidance
+ 16 - Enable messages related to DAT, ARP snooping and parsing
+ 32 - Enable messages related to network coding
+ 64 - Enable messages related to multicast
+128 - Enable messages related to throughput meter
+255 - Enable all messages
 
 The debug output can be changed at runtime  using  the  file
 /sys/class/net/bat0/mesh/log_level. e.g.
-- 
2.10.1



  1   2   3   >