diff -ruw linux-4.2.6/arch/arm/boot/dts/kirkwood.dtsi linux-4.2.6-fbx/arch/arm/boot/dts/kirkwood.dtsi
--- linux-4.2.6/arch/arm/boot/dts/kirkwood.dtsi	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/boot/dts/kirkwood.dtsi	2015-11-18 18:24:28.592139352 +0100
@@ -99,11 +99,28 @@
 				marvell,function = "spi";
 			};
 
+			pmx_tdm_spi: pmx-tdm-spi {
+				marvell,pins = "mpp24", "mpp25", "mpp26",
+					"mpp27";
+				marvell,function = "tdm";
+			};
+
+			pmx_alt_tdm_spi: pmx-alt-tdm-spi {
+				marvell,pins = "mpp39", "mpp40", "mpp41",
+					"mpp42";
+				marvell,function = "tdm";
+			};
+
 			pmx_twsi0: pmx-twsi0 {
 				marvell,pins = "mpp8", "mpp9";
 				marvell,function = "twsi0";
 			};
 
+			pmx_twsi1: pmx-twsi1 {
+				marvell,pins = "mpp36", "mpp37";
+				marvell,function = "twsi1";
+			};
+
 			/*
 			 * Default UART pinctrl setting without RTS/CTS,
 			 * overwrite marvell,pins on board level if required.
@@ -138,6 +155,18 @@
 			status = "disabled";
 		};
 
+		tdm_spi0: tdm_spi@d0000 {
+			compatible = "marvell,orion-tdm-spi";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0xd0000 65536>;
+			clocks = <&gate_clk 20>;
+			pinctrl-0 = <&pmx_tdm_spi>;
+			pinctrl-names = "default";
+			fbx,cs-gpios = <(-1) (-1) >;
+			status = "disabled";
+		};
+
 		gpio0: gpio@10100 {
 			compatible = "marvell,orion-gpio";
 			#gpio-cells = <2>;
@@ -175,6 +204,19 @@
 			status = "disabled";
 		};
 
+		i2c1: i2c@11100 {
+			compatible = "marvell,mv64xxx-i2c";
+			reg = <0x11000 0x20>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			interrupts = <32>;
+			clock-frequency = <100000>;
+			clocks = <&gate_clk 7>;
+			pinctrl-0 = <&pmx_twsi1>;
+			pinctrl-names = "default";
+			status = "disabled";
+		};
+
 		uart0: serial@12000 {
 			compatible = "ns16550a";
 			reg = <0x12000 0x100>;
@@ -307,6 +349,7 @@
 			reg = <0x72000 0x4000>;
 			clocks = <&gate_clk 0>;
 			marvell,tx-checksum-limit = <1600>;
+			marvell,unit = <0>;
 			status = "disabled";
 
 			eth0port: ethernet0-port@0 {
@@ -338,6 +381,7 @@
 			reg = <0x76000 0x4000>;
 			clocks = <&gate_clk 19>;
 			marvell,tx-checksum-limit = <1600>;
+			marvell,unit = <1>;
 			pinctrl-0 = <&pmx_ge1>;
 			pinctrl-names = "default";
 			status = "disabled";
diff -ruw linux-4.2.6/arch/arm/boot/dts/Makefile linux-4.2.6-fbx/arch/arm/boot/dts/Makefile
--- linux-4.2.6/arch/arm/boot/dts/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/boot/dts/Makefile	2015-11-18 18:24:28.524138818 +0100
@@ -209,7 +209,9 @@
 	kirkwood-ts219-6281.dtb \
 	kirkwood-ts219-6282.dtb \
 	kirkwood-ts419-6281.dtb \
-	kirkwood-ts419-6282.dtb
+	kirkwood-ts419-6282.dtb \
+	fbxgw1r.dtb \
+	fbxgw2r.dtb
 dtb-$(CONFIG_ARCH_LPC18XX) += \
 	lpc4350-hitex-eval.dtb \
 	lpc4357-ea4357-devkit.dtb
diff -ruw linux-4.2.6/arch/arm/include/asm/mach/arch.h linux-4.2.6-fbx/arch/arm/include/asm/mach/arch.h
--- linux-4.2.6/arch/arm/include/asm/mach/arch.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/include/asm/mach/arch.h	2015-11-18 18:24:28.660139886 +0100
@@ -65,6 +65,12 @@
 	void			(*restart)(enum reboot_mode, const char *);
 };
 
+struct fdt_desc {
+	unsigned int	nr;
+	void		*fdt_start;
+	void		*fdt_end;
+};
+
 /*
  * Current machine - only accessible during boot.
  */
@@ -98,4 +104,19 @@
 	.nr		= ~0,				\
 	.name		= _namestr,
 
+#ifdef CONFIG_MACHTYPE_FDT
+#define FDT_DESC(_type)					\
+extern u8 __fdt_start_##_type;				\
+extern u8 __fdt_end_##_type;				\
+static const struct fdt_desc __fdt_desc_##_type		\
+__used							\
+__attribute__((__section__(".arch.fdt.init"))) = {	\
+	.nr		= MACH_TYPE_##_type,		\
+	.fdt_start	= &__fdt_start_##_type,		\
+	.fdt_end	= &__fdt_end_##_type,		\
+}
+#else
+#define FDT_DESC(_type)
+#endif
+
 #endif
diff -ruw linux-4.2.6/arch/arm/include/asm/prom.h linux-4.2.6-fbx/arch/arm/include/asm/prom.h
--- linux-4.2.6/arch/arm/include/asm/prom.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/include/asm/prom.h	2015-11-18 18:24:28.660139886 +0100
@@ -14,6 +14,9 @@
 #ifdef CONFIG_OF
 
 extern const struct machine_desc *setup_machine_fdt(unsigned int dt_phys);
+extern unsigned int setup_fdt_machtype(unsigned int machtype,
+				       unsigned int atags_pointer);
+
 extern void __init arm_dt_init_cpu_maps(void);
 
 #else /* CONFIG_OF */
@@ -22,6 +25,10 @@
 {
 	return NULL;
 }
+static inline phys_addr_t setup_fdt_machtype(unsigned int machtype,
+					     unsigned int atags_pointer) {
+	return atags_pointer;
+}
 
 static inline void arm_dt_init_cpu_maps(void) { }
 
diff -ruw linux-4.2.6/arch/arm/include/uapi/asm/setup.h linux-4.2.6-fbx/arch/arm/include/uapi/asm/setup.h
--- linux-4.2.6/arch/arm/include/uapi/asm/setup.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/include/uapi/asm/setup.h	2015-11-18 18:24:28.664139919 +0100
@@ -143,6 +143,37 @@
 	__u32 fmemclk;
 };
 
+/*
+ * bootloader version
+ */
+#define ATAG_LOADER_VERSION	0x41000045
+struct tag_loader_version {
+	char version[1];
+};
+
+/*
+ * freebox serial info
+ */
+#include <linux/fbxserial.h>
+#define ATAG_FBXSERIAL          0x41000044
+struct tag_fbxserial {
+        struct fbx_serial serial;
+};
+
+/*
+ * boot_info tag, used by bank0 in conjuction with fbxhwinfo to
+ * sortout whether:
+ *
+ * - user forced a bank0 boot
+ * - user forced a bank0 boot _and_ asked for nvram to be erased.
+ */
+#define ATAG_BOOT_INFO		0x41000046
+struct tag_boot_info {
+	u32 erase_nvram;		/* == 1 if user selected nvram erase */
+	u32 bank0_forced;		/* == 1 if bank0 boot was
+					   forced by user*/
+};
+
 struct tag {
 	struct tag_header hdr;
 	union {
@@ -165,6 +196,12 @@
 		 * DC21285 specific
 		 */
 		struct tag_memclk	memclk;
+		/*
+		 * Freebox specific
+		 */
+		struct tag_loader_version loader_version;
+		struct tag_fbxserial	fbxserial;
+		struct tag_boot_info	boot_info;
 	} u;
 };
 
diff -ruw linux-4.2.6/arch/arm/Kconfig linux-4.2.6-fbx/arch/arm/Kconfig
--- linux-4.2.6/arch/arm/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/Kconfig	2015-12-01 18:46:10.823631389 +0100
@@ -1843,6 +1843,14 @@
 	  to remove ATAGS support from your kernel binary.  If unsure,
 	  leave this to y.
 
+config MACHTYPE_FDT
+	bool "Select FDT to use depending on machine type"
+	select USE_OF
+	help
+	  With this option set, FDTs are embedded into the kernel for
+	  the selected machines. The machtype given by the bootloader
+	  is used to select the fdt to use.
+
 config DEPRECATED_PARAM_STRUCT
 	bool "Provide old way to pass kernel parameters"
 	depends on ATAGS
diff -ruw linux-4.2.6/arch/arm/Kconfig.debug linux-4.2.6-fbx/arch/arm/Kconfig.debug
--- linux-4.2.6/arch/arm/Kconfig.debug	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/Kconfig.debug	2015-11-18 18:24:28.520138777 +0100
@@ -488,6 +488,10 @@
 
 		  Please adjust DEBUG_UART_PHYS and DEBUG_UART_BASE configuration
 		  options based on your needs.
+	config DEBUG_FBXGWR_UART
+		bool "Kernel low-level debugging message via FBXGW1R/FBXGW2R UART"
+		depends on MACH_FBXGW2R || MACH_FBXGW1R
+		select DEBUG_UART_8250
 
 	config DEBUG_MVEBU_UART0
 		bool "Kernel low-level debugging messages via MVEBU UART0 (old bootloaders)"
@@ -1423,6 +1427,7 @@
 	default 0xc8000000 if ARCH_IXP4XX && !CPU_BIG_ENDIAN
 	default 0xc8000003 if ARCH_IXP4XX && CPU_BIG_ENDIAN
 	default 0xd0000000 if ARCH_SPEAR3XX || ARCH_SPEAR6XX
+	default 0xfec12100 if DEBUG_FBXGWR_UART
 	default 0xd0012000 if DEBUG_MVEBU_UART0
 	default 0xc81004c0 if DEBUG_MESON_UARTAO
 	default 0xd4017000 if DEBUG_MMP_UART2
@@ -1441,6 +1446,7 @@
 	default 0xf1012100 if DEBUG_MVEBU_UART1_ALTERNATE
 	default 0xf1012000 if ARCH_DOVE || ARCH_MV78XX0 || \
 				ARCH_ORION5X
+	default 0xf1012100 if DEBUG_FBXGWR_UART
 	default 0xf7fc9000 if DEBUG_BERLIN_UART
 	default 0xf8b00000 if DEBUG_HIX5HD2_UART
 	default 0xf991e000 if DEBUG_QCOM_UARTDM
diff -ruw linux-4.2.6/arch/arm/kernel/atags.h linux-4.2.6-fbx/arch/arm/kernel/atags.h
--- linux-4.2.6/arch/arm/kernel/atags.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/kernel/atags.h	2015-11-18 18:24:28.668139960 +0100
@@ -9,6 +9,7 @@
 #ifdef CONFIG_ATAGS
 const struct machine_desc *setup_machine_tags(phys_addr_t __atags_pointer,
 	unsigned int machine_nr);
+void freebox_atags_wa(unsigned int);
 #else
 static inline const struct machine_desc *
 setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
@@ -17,4 +18,5 @@
 	while (true);
 	unreachable();
 }
+static inline void freebox_atags_wa(unsigned int) {}
 #endif
diff -ruw linux-4.2.6/arch/arm/kernel/atags_parse.c linux-4.2.6-fbx/arch/arm/kernel/atags_parse.c
--- linux-4.2.6/arch/arm/kernel/atags_parse.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/kernel/atags_parse.c	2015-11-18 18:24:28.668139960 +0100
@@ -236,3 +236,22 @@
 
 	return mdesc;
 }
+
+/*
+ * parse only freebox tags.
+ */
+void freebox_atags_wa(unsigned int atags_pointer)
+{
+	const struct tag *t = phys_to_virt(atags_pointer);
+
+	if (t->hdr.tag != ATAG_CORE)
+		return ;
+
+	for (; t->hdr.size; t = tag_next(t))
+		if (t->hdr.tag == ATAG_FBXSERIAL ||
+		    t->hdr.tag == ATAG_LOADER_VERSION ||
+		    t->hdr.tag == ATAG_INITRD2 ||
+		    t->hdr.tag == ATAG_BOOT_INFO) {
+			parse_tag(t);
+		}
+}
diff -ruw linux-4.2.6/arch/arm/kernel/bios32.c linux-4.2.6-fbx/arch/arm/kernel/bios32.c
--- linux-4.2.6/arch/arm/kernel/bios32.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/kernel/bios32.c	2015-11-18 18:24:28.668139960 +0100
@@ -645,3 +645,21 @@
 	pci_io_desc.pfn = pfn;
 	iotable_init(&pci_io_desc, 1);
 }
+
+/*
+ *	pci hotplug won't map the irq for new devices, so use a fixup
+ *	to work around this.
+ */
+void pci_fixup_hotplug_irq(struct pci_dev *dev)
+{
+	int irq;
+
+	printk("pci_fixup_hotplug_irq.\n");
+
+	irq = pcibios_map_irq(dev, PCI_SLOT(dev->devfn), dev->pin);
+	if (irq == -1)
+		irq = 0;
+	dev->irq = irq;
+	pcibios_update_irq(dev, dev->irq);
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_hotplug_irq);
diff -ruw linux-4.2.6/arch/arm/kernel/devtree.c linux-4.2.6-fbx/arch/arm/kernel/devtree.c
--- linux-4.2.6/arch/arm/kernel/devtree.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/kernel/devtree.c	2015-11-18 18:24:28.668139960 +0100
@@ -248,3 +248,24 @@
 
 	return mdesc;
 }
+
+/*
+ * find an ftd_desc suitable for the provided machtype. if one is
+ * found return the physical address of the matching in-kernel fdt. if
+ * none is found return the provided atags pointer.
+ */
+unsigned int setup_fdt_machtype(unsigned int machtype,
+				unsigned int atags_pointer)
+{
+	struct fdt_desc *fdesc;
+	extern struct fdt_desc __fdt_info_begin, __fdt_info_end;
+
+	for (fdesc = &__fdt_info_begin; fdesc < &__fdt_info_end; ++fdesc) {
+		if (fdesc->nr == machtype) {
+			printk("returning FDT available at %08x\n",
+			       virt_to_phys(fdesc->fdt_start));
+			return virt_to_phys(fdesc->fdt_start);
+		}
+	}
+	return atags_pointer;
+}
diff -ruw linux-4.2.6/arch/arm/kernel/setup.c linux-4.2.6-fbx/arch/arm/kernel/setup.c
--- linux-4.2.6/arch/arm/kernel/setup.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/kernel/setup.c	2015-11-18 18:24:28.676140014 +0100
@@ -935,6 +935,14 @@
 	const struct machine_desc *mdesc;
 
 	setup_processor();
+
+	/*
+	 * parse freebox tags before potentially overriding the
+	 * __atags_pointer with the in-kernel FDT.
+	 */
+	freebox_atags_wa(__atags_pointer);
+	__atags_pointer = setup_fdt_machtype(__machine_arch_type,
+					     __atags_pointer);
 	mdesc = setup_machine_fdt(__atags_pointer);
 	if (!mdesc)
 		mdesc = setup_machine_tags(__atags_pointer, __machine_arch_type);
diff -ruw linux-4.2.6/arch/arm/kernel/vmlinux.lds.S linux-4.2.6-fbx/arch/arm/kernel/vmlinux.lds.S
--- linux-4.2.6/arch/arm/kernel/vmlinux.lds.S	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/kernel/vmlinux.lds.S	2015-11-18 18:24:28.676140014 +0100
@@ -190,6 +190,12 @@
 		*(.arch.info.init)
 		__arch_info_end = .;
 	}
+	.init.fdt.info : {
+		. = ALIGN(4);
+		__fdt_info_begin = .;
+		*(.arch.fdt.init)
+		__fdt_info_end = .;
+ 	}
 	.init.tagtable : {
 		__tagtable_begin = .;
 		*(.taglist.init)
diff -ruw linux-4.2.6/arch/arm/mach-mvebu/board.h linux-4.2.6-fbx/arch/arm/mach-mvebu/board.h
--- linux-4.2.6/arch/arm/mach-mvebu/board.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/board.h	2015-11-18 18:24:28.732140467 +0100
@@ -18,4 +18,17 @@
 #else
 static inline void netxbig_init(void) {};
 #endif
+
+#ifdef CONFIG_MACH_FBXGW1R
+void fbxgw1r_init(void);
+#else
+static inline void fbxgw1r_init(void) {};
+#endif
+
+#ifdef CONFIG_MACH_FBXGW2R
+void fbxgw2r_init(void);
+#else
+static inline void fbxgw2r_init(void) {};
+#endif
+
 #endif
diff -ruw linux-4.2.6/arch/arm/mach-mvebu/Kconfig linux-4.2.6-fbx/arch/arm/mach-mvebu/Kconfig
--- linux-4.2.6/arch/arm/mach-mvebu/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/Kconfig	2015-11-18 18:24:28.732140467 +0100
@@ -123,4 +123,29 @@
 	  Say 'Y' here if you want your kernel to support the
 	  LaCie 2Big and 5Big Network v2
 
+config FBXGW_COMMON
+	bool
+
+config MACH_FBXGW2R
+	bool "Freebox FBXGW2R"
+	select FBXSERIAL
+	select FBXGW_COMMON
+
+config MACH_FBXGW1R
+	bool "Freebox FBXGW1R"
+	select FBXSERIAL
+	select FBXGW_COMMON
+
+if FBXGW_COMMON
+
+config FBXGW_COMMON_PARTS_WRITE_ALL
+	bool "make all mtd partitions writeable"
+
+config FBXGW_COMMON_NAND_SAFE_READ_TIMINGS
+	bool "use very conservative timings for nand read"
+
+config FBXGW_COMMON_NAND_SAFE_WRITE_TIMINGS
+	bool "use very conservative timings for nand write"
+endif
+
 endif
diff -ruw linux-4.2.6/arch/arm/mach-mvebu/kirkwood.c linux-4.2.6-fbx/arch/arm/mach-mvebu/kirkwood.c
--- linux-4.2.6/arch/arm/mach-mvebu/kirkwood.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/kirkwood.c	2015-11-18 18:24:28.740140521 +0100
@@ -19,14 +19,19 @@
 #include <linux/of_net.h>
 #include <linux/of_platform.h>
 #include <linux/slab.h>
+#include <linux/dma-mapping.h>
 #include <asm/hardware/cache-feroceon-l2.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
+#include <asm/mach-types.h>
+#include "mvebu-soc-id.h"
 #include "kirkwood.h"
 #include "kirkwood-pm.h"
 #include "common.h"
 #include "board.h"
 
+#include "fbxgw-common.h"
+
 static struct resource kirkwood_cpufreq_resources[] = {
 	[0] = {
 		.start  = CPU_CONTROL_PHYS,
@@ -67,6 +72,32 @@
 	platform_device_register(&kirkwood_cpuidle);
 }
 
+static struct resource kirkwood_coretemp_resources[] = {
+	[0] = {
+		.start  = TEMP_PHYS_BASE,
+		.end    = TEMP_PHYS_BASE + sizeof (u32) - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+};
+struct platform_device kirkwood_coretemp_device = {
+	.name	    = "kirkwood-coretemp",
+	.id	    = -1,
+	.num_resources = ARRAY_SIZE(kirkwood_coretemp_resources),
+	.resource = kirkwood_coretemp_resources,
+};
+
+static void __init kirkwood_coretemp_init(void)
+{
+	u32 dev, rev;
+
+	if (mvebu_get_soc_id(&dev, &rev) < 0)
+		return;
+	if (dev != 0x6282)
+		return;
+
+	platform_device_register(&kirkwood_coretemp_device);
+}
+
 #define MV643XX_ETH_MAC_ADDR_LOW	0x0414
 #define MV643XX_ETH_MAC_ADDR_HIGH	0x0418
 
@@ -159,15 +190,70 @@
 	writel(readl(cpu_config) & ~CPU_CONFIG_ERROR_PROP, cpu_config);
 }
 
+/*
+ * See errata. Without this work around:
+ *    "The risk is that the PCIe will not work properly."
+ */
+static void kirkwood_fe_misc_120(void)
+{
+	u32 dev, rev;
+	void __iomem *reg;
+
+	if (mvebu_get_soc_id(&dev, &rev)) {
+		pr_warn("unable to get soc id when trying to apply "
+			"FE-MISC-120\n");
+		return ;
+	}
+
+	if (dev != 0x6282)
+		/* not applicable on this device */
+		return ;
+
+	reg = ioremap(FE_MISC_120_REG, 4);
+	if (!reg) {
+		pr_warn("unable to ioremap %08x when trying to apply "
+			"FE-MISC-120.\n", FE_MISC_120_REG);
+		return ;
+	}
+
+	writel(readl(reg) | (3 << 25), reg);
+	iounmap(reg);
+}
+
+/*
+ * map the IMMR space using iotable_init, like in the old times ...
+ * As it is going to be mapped using a single 1M section, this can't
+ * be bad wrt TLB pressure.
+ */
+static struct map_desc __initdata kirkwood_io_desc[] = {
+	{
+		.virtual	= 0xfec00000,
+		.pfn		= __phys_to_pfn(0xf1000000),
+		.length		= SZ_1M,
+		.type		= MT_DEVICE,
+	},
+};
+static void __init kirkwood_map_io(void)
+{
+	iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
+}
+
 static struct of_dev_auxdata auxdata[] __initdata = {
 	OF_DEV_AUXDATA("marvell,kirkwood-audio", 0xf10a0000,
 		       "mvebu-audio", NULL),
 	{ /* sentinel */ }
 };
 
+static void __init kirkwood_init_early(void)
+{
+	init_dma_coherent_pool_size(SZ_1M);
+}
+
 static void __init kirkwood_dt_init(void)
 {
 	kirkwood_disable_mbus_error_propagation();
+	kirkwood_fe_misc_120();
+	kirkwood_coretemp_init();
 
 	BUG_ON(mvebu_mbus_dt_init(false));
 
@@ -184,6 +270,30 @@
 		netxbig_init();
 
 	of_platform_populate(NULL, of_default_bus_match_table, auxdata, NULL);
+
+
+#ifdef CONFIG_FBXGW_COMMON
+	/*
+	 * run pinctrl and mvebu driver init there to control
+	 * order. we need both pinctrl and gpio controllers up and
+	 * running for fbxgw1r/fbxgw2r_init() functions.
+	 *
+	 * I'm not proud of this.
+	 */
+	{
+		extern int kirkwood_pinctrl_driver_init(void);
+		extern int mvebu_gpio_driver_init(void);
+
+		kirkwood_pinctrl_driver_init();
+		mvebu_gpio_driver_init();
+	}
+
+	if (of_machine_is_compatible("freebox,fbxgw1r"))
+		fbxgw1r_init();
+
+	if (of_machine_is_compatible("freebox,fbxgw2r"))
+		fbxgw2r_init();
+#endif
 }
 
 static const char * const kirkwood_dt_board_compat[] __initconst = {
@@ -197,3 +307,43 @@
 	.restart	= mvebu_restart,
 	.dt_compat	= kirkwood_dt_board_compat,
 MACHINE_END
+
+#ifdef CONFIG_MACH_FBXGW1R
+static const char * const fbxgw1r_dt_board_compat[] = {
+	"freebox,fbxgw1r",
+	NULL,
+};
+
+MACHINE_START(FBXGW1R, "Freebox FBXGW1R (In-kernel Flattened Device Tree)")
+	.init_machine	= kirkwood_dt_init,
+	.restart = mvebu_restart,
+	.init_early = kirkwood_init_early,
+#ifdef CONFIG_PSTORE_RAM
+	.reserve = fbxgw_reserve_crash_zone,
+#endif
+	.map_io = kirkwood_map_io,
+	.dt_compat = fbxgw1r_dt_board_compat,
+MACHINE_END
+
+FDT_DESC(FBXGW1R);
+#endif
+
+#ifdef CONFIG_MACH_FBXGW2R
+static const char * const fbxgw2r_dt_board_compat[] = {
+	"freebox,fbxgw2r",
+	NULL,
+};
+
+MACHINE_START(FBXGW2R, "Freebox FBXGW2R (In-kernel Flattened Device Tree)")
+	.init_machine	= kirkwood_dt_init,
+	.restart	= mvebu_restart,
+	.init_early = kirkwood_init_early,
+#ifdef CONFIG_PSTORE_RAM
+	.reserve	= fbxgw_reserve_crash_zone,
+#endif
+	.map_io		= kirkwood_map_io,
+	.dt_compat	= fbxgw2r_dt_board_compat,
+MACHINE_END
+
+FDT_DESC(FBXGW2R);
+#endif
diff -ruw linux-4.2.6/arch/arm/mach-mvebu/kirkwood.h linux-4.2.6-fbx/arch/arm/mach-mvebu/kirkwood.h
--- linux-4.2.6/arch/arm/mach-mvebu/kirkwood.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/kirkwood.h	2015-11-18 18:24:28.740140521 +0100
@@ -20,3 +20,7 @@
 
 #define CPU_CONTROL_PHYS	(BRIDGE_PHYS_BASE + 0x0104)
 #define MEMORY_PM_CTRL_PHYS	(BRIDGE_PHYS_BASE + 0x0118)
+
+#define FE_MISC_120_REG		(KIRKWOOD_REGS_PHYS_BASE + 0x100e4)
+
+#define TEMP_PHYS_BASE		(KIRKWOOD_REGS_PHYS_BASE + 0x10078)
diff -ruw linux-4.2.6/arch/arm/mach-mvebu/Makefile linux-4.2.6-fbx/arch/arm/mach-mvebu/Makefile
--- linux-4.2.6/arch/arm/mach-mvebu/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/Makefile	2015-11-18 18:24:28.732140467 +0100
@@ -14,3 +14,26 @@
 obj-$(CONFIG_MACH_DOVE)		 += dove.o
 obj-$(CONFIG_MACH_KIRKWOOD)	 += kirkwood.o kirkwood-pm.o
 obj-$(CONFIG_MACH_NETXBIG)	 += netxbig.o
+
+obj-$(CONFIG_FBXGW_COMMON)	 += fbxgw-common.o fbxgw-switch.o \
+				 kirkwood_nand.o fbxgw-pcie.o
+obj-$(CONFIG_MACH_FBXGW2R)	 += fbxgw2r-setup.o
+obj-$(CONFIG_MACH_FBXGW1R)	 += fbxgw1r-setup.o
+
+ifdef CONFIG_MACHTYPE_FDT
+
+quiet_cmd_GENFDTS      = GEN     $@
+      cmd_GENFDTS      = arch/arm/tools/gen-fdt-s $2 > $@ || rm -f $@
+
+define add-fdt
+obj-$$(CONFIG_MACH_$2)		 += fdt-$1.o
+arch/arm/mach-mvebu/fdt-$1.S: arch/arm/boot/dts/$1.dtb
+	$$(call cmd,GENFDTS,$2)
+arch/arm/boot/dts/$1.dtb: arch/arm/boot/dts/$1.dts
+	$$(call cmd,dtc)
+endef
+
+$(eval $(call add-fdt,fbxgw1r,FBXGW1R))
+$(eval $(call add-fdt,fbxgw2r,FBXGW2R))
+
+endif
diff -ruw linux-4.2.6/arch/arm/mm/dma-mapping.c linux-4.2.6-fbx/arch/arm/mm/dma-mapping.c
--- linux-4.2.6/arch/arm/mm/dma-mapping.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/mm/dma-mapping.c	2015-11-18 18:24:28.828141229 +0100
@@ -872,6 +872,11 @@
 	phys_addr_t paddr = page_to_phys(page) + off;
 
 	/* FIXME: non-speculating: not required */
+#ifdef CONFIG_MACH_KIRKWOOD
+	if (dir == DMA_FROM_DEVICE)
+		return;
+#endif
+
 	/* in any case, don't bother invalidating if DMA to device */
 	if (dir != DMA_TO_DEVICE) {
 		outer_inv_range(paddr, paddr + size);
diff -ruw linux-4.2.6/arch/arm/net/bpf_jit_32.c linux-4.2.6-fbx/arch/arm/net/bpf_jit_32.c
--- linux-4.2.6/arch/arm/net/bpf_jit_32.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/net/bpf_jit_32.c	2015-11-18 18:24:28.832141256 +0100
@@ -857,7 +857,9 @@
 			emit(ARM_LDR_I(r_A, r_scratch, off), ctx);
 			break;
 		case BPF_ANC | SKF_AD_IFINDEX:
+		case BPF_ANC | SKF_AD_HATYPE:
 			/* A = skb->dev->ifindex */
+			/* A = skb->dev->type */
 			ctx->seen |= SEEN_SKB;
 			off = offsetof(struct sk_buff, dev);
 			emit(ARM_LDR_I(r_scratch, r_skb, off), ctx);
@@ -867,8 +869,24 @@
 
 			BUILD_BUG_ON(FIELD_SIZEOF(struct net_device,
 						  ifindex) != 4);
+			BUILD_BUG_ON(FIELD_SIZEOF(struct net_device,
+						  type) != 2);
+
+			if (code == (BPF_ANC | SKF_AD_IFINDEX)) {
 			off = offsetof(struct net_device, ifindex);
 			emit(ARM_LDR_I(r_A, r_scratch, off), ctx);
+			} else {
+				/*
+				 * offset of field "type" in "struct
+				 * net_device" is above what can be
+				 * used in the ldrh rd, [rn, #imm]
+				 * instruction, so load the offset in
+				 * a register and use ldrh rd, [rn, rm]
+				 */
+				off = offsetof(struct net_device, type);
+				emit_mov_i(ARM_R3, off, ctx);
+				emit(ARM_LDRH_R(r_A, r_scratch, ARM_R3), ctx);
+			}
 			break;
 		case BPF_ANC | SKF_AD_MARK:
 			ctx->seen |= SEEN_SKB;
@@ -895,6 +913,17 @@
 				OP_IMM3(ARM_AND, r_A, r_A, 0x1, ctx);
 			}
 			break;
+		case BPF_ANC | SKF_AD_PKTTYPE:
+			ctx->seen |= SEEN_SKB;
+			BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,
+						  __pkt_type_offset[0]) != 1);
+			off = PKT_TYPE_OFFSET();
+			emit(ARM_LDRB_I(r_A, r_skb, off), ctx);
+			emit(ARM_AND_I(r_A, r_A, PKT_TYPE_MAX), ctx);
+#ifdef __BIG_ENDIAN_BITFIELD
+			emit(ARM_LSR_I(r_A, r_A, 5), ctx);
+#endif
+			break;
 		case BPF_ANC | SKF_AD_QUEUE:
 			ctx->seen |= SEEN_SKB;
 			BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,
@@ -904,6 +933,14 @@
 			off = offsetof(struct sk_buff, queue_mapping);
 			emit(ARM_LDRH_I(r_A, r_skb, off), ctx);
 			break;
+		case BPF_ANC | SKF_AD_PAY_OFFSET:
+			ctx->seen |= SEEN_SKB | SEEN_CALL;
+
+			emit(ARM_MOV_R(ARM_R0, r_skb), ctx);
+			emit_mov_i(ARM_R3, (unsigned int)skb_get_poff, ctx);
+			emit_blx_r(ARM_R3, ctx);
+			emit(ARM_MOV_R(r_A, ARM_R0), ctx);
+			break;
 		case BPF_LDX | BPF_W | BPF_ABS:
 			/*
 			 * load a 32bit word from struct seccomp_data.
diff -ruw linux-4.2.6/arch/arm/net/bpf_jit_32.h linux-4.2.6-fbx/arch/arm/net/bpf_jit_32.h
--- linux-4.2.6/arch/arm/net/bpf_jit_32.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/net/bpf_jit_32.h	2015-11-18 18:24:28.832141256 +0100
@@ -74,6 +74,7 @@
 #define ARM_INST_LDRB_I		0x05d00000
 #define ARM_INST_LDRB_R		0x07d00000
 #define ARM_INST_LDRH_I		0x01d000b0
+#define ARM_INST_LDRH_R		0x019000b0
 #define ARM_INST_LDR_I		0x05900000
 
 #define ARM_INST_LDM		0x08900000
@@ -160,6 +161,8 @@
 				 | (rm))
 #define ARM_LDRH_I(rt, rn, off)	(ARM_INST_LDRH_I | (rt) << 12 | (rn) << 16 \
 				 | (((off) & 0xf0) << 4) | ((off) & 0xf))
+#define ARM_LDRH_R(rt, rn, rm)	(ARM_INST_LDRH_R | (rt) << 12 | (rn) << 16 \
+				 | (rm))
 
 #define ARM_LDM(rn, regs)	(ARM_INST_LDM | (rn) << 16 | (regs))
 
diff -ruw linux-4.2.6/arch/arm/tools/mach-types linux-4.2.6-fbx/arch/arm/tools/mach-types
--- linux-4.2.6/arch/arm/tools/mach-types	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/arch/arm/tools/mach-types	2015-11-18 18:24:28.844141356 +0100
@@ -692,7 +692,7 @@
 linkstation_lsql	MACH_LINKSTATION_LSQL	LINKSTATION_LSQL	4238
 am3703gateway		MACH_AM3703GATEWAY	AM3703GATEWAY		4239
 accipiter		MACH_ACCIPITER		ACCIPITER		4240
-magnidug		MACH_MAGNIDUG		MAGNIDUG		4242
+# magnidug		MACH_MAGNIDUG		MAGNIDUG		4242
 hydra			MACH_HYDRA		HYDRA			4243
 sun3i			MACH_SUN3I		SUN3I			4244
 stm_b2078		MACH_STM_B2078		STM_B2078		4245
@@ -1006,3 +1006,7 @@
 eukrea_cpuimx28sd	MACH_EUKREA_CPUIMX28SD	EUKREA_CPUIMX28SD	4573
 domotab			MACH_DOMOTAB		DOMOTAB			4574
 pfla03			MACH_PFLA03		PFLA03			4575
+
+# FBX
+fbxgw1r			MACH_FBXGW1R		FBXGW1R			527
+fbxgw2r			MACH_FBXGW2R		FBXGW2R			4242
diff -ruw linux-4.2.6/block/blk-core.c linux-4.2.6-fbx/block/blk-core.c
--- linux-4.2.6/block/blk-core.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/block/blk-core.c	2015-11-18 18:24:29.548146940 +0100
@@ -2175,7 +2175,7 @@
 	}
 }
 
-void blk_account_io_done(struct request *req)
+void blk_account_io_done(struct request *req, int error)
 {
 	/*
 	 * Account IO completion.  flush_rq isn't accounted as a
@@ -2191,6 +2191,8 @@
 		cpu = part_stat_lock();
 		part = req->part;
 
+		if (error < 0)
+			part_stat_inc(cpu, part, io_errors[rw]);
 		part_stat_inc(cpu, part, ios[rw]);
 		part_stat_add(cpu, part, ticks[rw], duration);
 		part_round_stats(cpu, part);
@@ -2634,7 +2636,7 @@
 	if (req->cmd_flags & REQ_DONTPREP)
 		blk_unprep_request(req);
 
-	blk_account_io_done(req);
+	blk_account_io_done(req, error);
 
 	if (req->end_io)
 		req->end_io(req, error);
diff -ruw linux-4.2.6/block/blk.h linux-4.2.6-fbx/block/blk.h
--- linux-4.2.6/block/blk.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/block/blk.h	2015-11-18 18:24:29.552146966 +0100
@@ -89,7 +89,7 @@
 
 void blk_account_io_start(struct request *req, bool new_io);
 void blk_account_io_completion(struct request *req, unsigned int bytes);
-void blk_account_io_done(struct request *req);
+void blk_account_io_done(struct request *req, int error);
 
 /*
  * Internal atomic flags for request handling
diff -ruw linux-4.2.6/block/blk-mq.c linux-4.2.6-fbx/block/blk-mq.c
--- linux-4.2.6/block/blk-mq.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/block/blk-mq.c	2015-11-18 18:24:29.552146966 +0100
@@ -322,7 +322,7 @@
 
 inline void __blk_mq_end_request(struct request *rq, int error)
 {
-	blk_account_io_done(rq);
+	blk_account_io_done(rq, error);
 
 	if (rq->end_io) {
 		rq->end_io(rq, error);
diff -ruw linux-4.2.6/block/partition-generic.c linux-4.2.6-fbx/block/partition-generic.c
--- linux-4.2.6/block/partition-generic.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/block/partition-generic.c	2015-11-18 18:24:29.556146993 +0100
@@ -120,7 +120,7 @@
 	return sprintf(buf,
 		"%8lu %8lu %8llu %8u "
 		"%8lu %8lu %8llu %8u "
-		"%8u %8u %8u"
+		"%8u %8u %8u %8lu %lu"
 		"\n",
 		part_stat_read(p, ios[READ]),
 		part_stat_read(p, merges[READ]),
@@ -132,7 +132,9 @@
 		jiffies_to_msecs(part_stat_read(p, ticks[WRITE])),
 		part_in_flight(p),
 		jiffies_to_msecs(part_stat_read(p, io_ticks)),
-		jiffies_to_msecs(part_stat_read(p, time_in_queue)));
+		jiffies_to_msecs(part_stat_read(p, time_in_queue)),
+		part_stat_read(p, io_errors[READ]),
+		part_stat_read(p, io_errors[WRITE]));
 }
 
 ssize_t part_inflight_show(struct device *dev,
diff -ruw linux-4.2.6/crypto/algboss.c linux-4.2.6-fbx/crypto/algboss.c
--- linux-4.2.6/crypto/algboss.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/crypto/algboss.c	2015-11-02 19:00:16.152978579 +0100
@@ -221,7 +221,9 @@
 	if (type & CRYPTO_ALG_TESTED)
 		goto skiptest;
 
+#ifdef CONFIG_CRYPTO_BUILTIN_TEST
 	err = alg_test(param->driver, param->alg, type, CRYPTO_ALG_TESTED);
+#endif
 
 skiptest:
 	crypto_alg_tested(param->driver, err);
diff -ruw linux-4.2.6/crypto/Kconfig linux-4.2.6-fbx/crypto/Kconfig
--- linux-4.2.6/crypto/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/crypto/Kconfig	2015-11-18 18:24:29.560147025 +0100
@@ -108,6 +108,10 @@
 	help
 	  Generic implementation of the RSA public key algorithm.
 
+config CRYPTO_BUILTIN_TEST
+	bool "Include builtin tests"
+	default y
+
 config CRYPTO_MANAGER
 	tristate "Cryptographic algorithm manager"
 	select CRYPTO_MANAGER2
diff -ruw linux-4.2.6/crypto/Makefile linux-4.2.6-fbx/crypto/Makefile
--- linux-4.2.6/crypto/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/crypto/Makefile	2015-11-18 18:24:29.560147025 +0100
@@ -38,7 +38,10 @@
 rsa_generic-y += rsa_helper.o
 obj-$(CONFIG_CRYPTO_RSA) += rsa_generic.o
 
-cryptomgr-y := algboss.o testmgr.o
+cryptomgr-y := algboss.o
+ifeq ($(CONFIG_CRYPTO_BUILTIN_TEST),y)
+cryptomgr-y += testmgr.o
+endif
 
 obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
 obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
diff -ruw linux-4.2.6/drivers/ata/libata-core.c linux-4.2.6-fbx/drivers/ata/libata-core.c
--- linux-4.2.6/drivers/ata/libata-core.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/ata/libata-core.c	2015-11-18 18:24:29.648147728 +0100
@@ -4180,6 +4180,8 @@
 	/* https://bugzilla.kernel.org/show_bug.cgi?id=15573 */
 	{ "C300-CTFDDAC128MAG",	"0001",		ATA_HORKAGE_NONCQ, },
 
+	{ "Boot ROM", 		NULL,		ATA_HORKAGE_NODMA  },
+
 	/* devices which puke on READ_NATIVE_MAX */
 	{ "HDS724040KLSA80",	"KFAOA20N",	ATA_HORKAGE_BROKEN_HPA, },
 	{ "WDC WD3200JD-00KLB0", "WD-WCAMR1130137", ATA_HORKAGE_BROKEN_HPA },
diff -ruw linux-4.2.6/drivers/ata/libata-scsi.c linux-4.2.6-fbx/drivers/ata/libata-scsi.c
--- linux-4.2.6/drivers/ata/libata-scsi.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/ata/libata-scsi.c	2015-11-18 18:24:29.648147728 +0100
@@ -3693,7 +3693,7 @@
 			goto err_add;
 
 		rc = scsi_add_host_with_dma(ap->scsi_host,
-						&ap->tdev, ap->host->dev);
+					    host->dev, host->dev);
 		if (rc)
 			goto err_add;
 	}
diff -ruw linux-4.2.6/drivers/base/firmware_class.c linux-4.2.6-fbx/drivers/base/firmware_class.c
--- linux-4.2.6/drivers/base/firmware_class.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/base/firmware_class.c	2015-11-18 18:24:29.680147982 +0100
@@ -280,7 +280,8 @@
 	"/lib/firmware/updates/" UTS_RELEASE,
 	"/lib/firmware/updates",
 	"/lib/firmware/" UTS_RELEASE,
-	"/lib/firmware"
+	"/lib/firmware",
+	"/usr/lib/hotplug/firmware"
 };
 
 /*
diff -ruw linux-4.2.6/drivers/char/Kconfig linux-4.2.6-fbx/drivers/char/Kconfig
--- linux-4.2.6/drivers/char/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/char/Kconfig	2015-11-18 18:24:29.728148360 +0100
@@ -24,6 +24,15 @@
 	  kind of kernel debugging operations.
 	  When in doubt, say "N".
 
+config DEVPHYSMEM
+	bool "/dev/physmem virtual device support"
+	default n
+	help
+	  Say Y here if you want to support the /dev/physmem device. The
+	  /dev/physmem device allows unprivileged access to physical memory
+	  unused by the kernel.
+	  When in doubt, say "N".
+
 config SGI_SNSC
 	bool "SGI Altix system controller communication support"
 	depends on (IA64_SGI_SN2 || IA64_GENERIC)
diff -ruw linux-4.2.6/drivers/char/mem.c linux-4.2.6-fbx/drivers/char/mem.c
--- linux-4.2.6/drivers/char/mem.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/char/mem.c	2015-11-18 18:24:29.740148464 +0100
@@ -27,6 +27,7 @@
 #include <linux/export.h>
 #include <linux/io.h>
 #include <linux/uio.h>
+#include <linux/bootmem.h>
 
 #include <linux/uaccess.h>
 
@@ -373,6 +374,14 @@
 	return mmap_mem(file, vma);
 }
 
+static int mmap_physmem(struct file * file, struct vm_area_struct * vma)
+{
+	if (vma->vm_pgoff < max_pfn && !capable(CAP_SYS_RAWIO))
+		return -EPERM;
+
+	return mmap_mem(file, vma);
+}
+
 /*
  * This function reads the *virtual* memory as seen by the kernel.
  */
@@ -715,6 +724,11 @@
 	return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
 }
 
+static int open_physmem(struct inode * inode, struct file * filp)
+{
+	return 0;
+}
+
 #define zero_lseek	null_lseek
 #define full_lseek      null_lseek
 #define write_zero	write_null
@@ -779,6 +793,14 @@
 	.write		= write_full,
 };
 
+static const struct file_operations __maybe_unused physmem_fops = {
+	.mmap		= mmap_physmem,
+	.open		= open_physmem,
+#ifndef CONFIG_MMU
+	.get_unmapped_area = get_unmapped_area_mem,
+#endif
+};
+
 static const struct memdev {
 	const char *name;
 	umode_t mode;
@@ -802,6 +824,9 @@
 #ifdef CONFIG_PRINTK
 	[11] = { "kmsg", 0644, &kmsg_fops, 0 },
 #endif
+#ifdef CONFIG_DEVPHYSMEM
+	[16] = { "physmem", 0, &physmem_fops, FMODE_UNSIGNED_OFFSET },
+#endif
 };
 
 static int memory_open(struct inode *inode, struct file *filp)
diff -ruw linux-4.2.6/drivers/gpio/gpio-mvebu.c linux-4.2.6-fbx/drivers/gpio/gpio-mvebu.c
--- linux-4.2.6/drivers/gpio/gpio-mvebu.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/gpio/gpio-mvebu.c	2015-11-18 18:24:29.904149759 +0100
@@ -83,6 +83,7 @@
 	int		   irqbase;
 	struct irq_domain *domain;
 	int		   soc_variant;
+	int		   broken_mpp33_dir_wa;
 
 	/* Used to preserve GPIO registers across suspend/resume */
 	u32                out_reg;
@@ -259,11 +260,20 @@
 	if (ret)
 		return ret;
 
+	if (pin == 1 && mvchip->broken_mpp33_dir_wa) {
+		/*
+		 * See comment in mvebu_gpio_direction_output().
+		 */
+		u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip) - 0x40);
+		u |= ~(1 << 1);
+		writel_relaxed(u, mvebu_gpioreg_io_conf(mvchip) - 0x40);
+	} else {
 	spin_lock_irqsave(&mvchip->lock, flags);
 	u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip));
 	u |= 1 << pin;
 	writel_relaxed(u, mvebu_gpioreg_io_conf(mvchip));
 	spin_unlock_irqrestore(&mvchip->lock, flags);
+	}
 
 	return 0;
 }
@@ -286,11 +296,22 @@
 	mvebu_gpio_blink(chip, pin, 0);
 	mvebu_gpio_set(chip, pin, value);
 
+	if (pin == 1 && mvchip->broken_mpp33_dir_wa) {
+		/*
+		 * gpio33 direction bit is not controlled from the
+		 * gpio block 0, but from gpio block 1 instead. NOTE:
+		 * Screw locking.
+		 */
+		u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip) - 0x40);
+		u &= ~(1 << 1);
+		writel_relaxed(u, mvebu_gpioreg_io_conf(mvchip) - 0x40);
+	} else {
 	spin_lock_irqsave(&mvchip->lock, flags);
 	u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip));
 	u &= ~(1 << pin);
 	writel_relaxed(u, mvebu_gpioreg_io_conf(mvchip));
 	spin_unlock_irqrestore(&mvchip->lock, flags);
+	} 
 
 	return 0;
 }
@@ -675,6 +696,7 @@
 	unsigned int ngpios;
 	int soc_variant;
 	int i, cpu, id;
+	uint32_t broken_mpp33_dir = 0;
 	int err;
 
 	match = of_match_device(mvebu_gpio_of_match, &pdev->dev);
@@ -695,6 +717,12 @@
 		return -ENODEV;
 	}
 
+	of_property_read_u32(pdev->dev.of_node, "marvell,broken-mpp33-dir",
+			     &broken_mpp33_dir);
+	if (broken_mpp33_dir)
+		dev_notice(&pdev->dev, "using direction set work around for "
+			   "MPP 33.\n");
+
 	id = of_alias_get_id(pdev->dev.of_node, "gpio");
 	if (id < 0) {
 		dev_err(&pdev->dev, "Couldn't get OF id\n");
@@ -706,6 +734,7 @@
 	if (!IS_ERR(clk))
 		clk_prepare_enable(clk);
 
+	mvchip->broken_mpp33_dir_wa = broken_mpp33_dir;
 	mvchip->soc_variant = soc_variant;
 	mvchip->chip.label = dev_name(&pdev->dev);
 	mvchip->chip.dev = &pdev->dev;
@@ -860,4 +889,13 @@
 	.suspend        = mvebu_gpio_suspend,
 	.resume         = mvebu_gpio_resume,
 };
+
+#ifdef CONFIG_FBXGW_COMMON
+int mvebu_gpio_driver_init(void)
+{
+	return platform_driver_register(&mvebu_gpio_driver);
+}
+EXPORT_SYMBOL(mvebu_gpio_driver_init);
+#else
 module_platform_driver(mvebu_gpio_driver);
+#endif
diff -ruw linux-4.2.6/drivers/hid/hid-core.c linux-4.2.6-fbx/drivers/hid/hid-core.c
--- linux-4.2.6/drivers/hid/hid-core.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/hid/hid-core.c	2015-11-18 18:24:30.252152524 +0100
@@ -2025,6 +2025,7 @@
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE2) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_RAZER, USB_DEVICE_ID_RAZER_BLADE_14) },
+	{ HID_BLUETOOTH_DEVICE(0x10eb, 0x0023) },
 	{ }
 };
 
diff -ruw linux-4.2.6/drivers/hid/Kconfig linux-4.2.6-fbx/drivers/hid/Kconfig
--- linux-4.2.6/drivers/hid/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/hid/Kconfig	2015-11-18 18:24:30.252152524 +0100
@@ -316,6 +316,10 @@
 	---help---
 	Support for Waltop tablets.
 
+config HID_FBX_REMOTE_AUDIO
+	tristate "Freebox BLE remote audio driver"
+	depends on HID && SND_PCM
+
 config HID_GYRATION
 	tristate "Gyration remote control"
 	depends on HID
diff -ruw linux-4.2.6/drivers/hid/Makefile linux-4.2.6-fbx/drivers/hid/Makefile
--- linux-4.2.6/drivers/hid/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/hid/Makefile	2015-11-18 18:24:30.252152524 +0100
@@ -37,6 +37,7 @@
 obj-$(CONFIG_HID_ELO)		+= hid-elo.o
 obj-$(CONFIG_HID_EZKEY)		+= hid-ezkey.o
 obj-$(CONFIG_HID_GT683R)	+= hid-gt683r.o
+obj-$(CONFIG_HID_FBX_REMOTE_AUDIO)	+= hid-fbx-remote-audio.o
 obj-$(CONFIG_HID_GYRATION)	+= hid-gyration.o
 obj-$(CONFIG_HID_HOLTEK)	+= hid-holtek-kbd.o
 obj-$(CONFIG_HID_HOLTEK)	+= hid-holtek-mouse.o
diff -ruw linux-4.2.6/drivers/hwmon/adt7475.c linux-4.2.6-fbx/drivers/hwmon/adt7475.c
--- linux-4.2.6/drivers/hwmon/adt7475.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/hwmon/adt7475.c	2015-11-18 18:24:30.280152736 +0100
@@ -124,7 +124,19 @@
 
 /* Macro to read the registers */
 
-#define adt7475_read(reg) i2c_smbus_read_byte_data(client, (reg))
+static inline s32 __adt7475_read(const struct i2c_client *client, u8 cmd)
+{
+	s32 ret;
+
+	ret = i2c_smbus_read_byte_data(client, cmd);
+	if (ret < 0) {
+		printk("__adt7475_read error: %d\n", ret);
+		return 0;
+	}
+	return ret;
+}
+
+#define adt7475_read(reg) __adt7475_read(client, (reg))
 
 /* Macros to easily index the registers */
 
@@ -278,6 +290,9 @@
 {
 	u16 val;
 
+	if (need_resched())
+		yield();
+
 	val = i2c_smbus_read_byte_data(client, reg);
 	val |= (i2c_smbus_read_byte_data(client, reg + 1) << 8);
 
@@ -846,7 +861,7 @@
 
 	data->range[sattr->index] =
 		adt7475_read(TEMP_TRANGE_REG(sattr->index));
-	data->range[sattr->index] &= ~7;
+	data->range[sattr->index] &= ~0xf;
 	data->range[sattr->index] |= out;
 
 	i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index),
diff -ruw linux-4.2.6/drivers/hwmon/Kconfig linux-4.2.6-fbx/drivers/hwmon/Kconfig
--- linux-4.2.6/drivers/hwmon/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/hwmon/Kconfig	2015-11-18 18:24:30.272152677 +0100
@@ -1736,6 +1736,10 @@
 	  This driver provides support for the Ultra45 workstation environmental
 	  sensors.
 
+config SENSORS_KIRKWOOD_CORETEMP
+	tristate "Kirkwood core temperature censor"
+	depends on MACH_KIRKWOOD
+
 if ACPI
 
 comment "ACPI drivers"
diff -ruw linux-4.2.6/drivers/hwmon/lm85.c linux-4.2.6-fbx/drivers/hwmon/lm85.c
--- linux-4.2.6/drivers/hwmon/lm85.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/hwmon/lm85.c	2015-11-18 18:24:30.292152832 +0100
@@ -196,13 +196,13 @@
 #define RANGE_FROM_REG(val)	lm85_range_map[(val) & 0x0f]
 
 /* These are the PWM frequency encodings */
-static const int lm85_freq_map[8] = { /* 1 Hz */
-	10, 15, 23, 30, 38, 47, 61, 94
+static const int lm85_freq_map[11] = { /* 1 Hz */
+	10, 15, 23, 30, 38, 47, 61, 94, 94, 94, 94
 };
-static const int adm1027_freq_map[8] = { /* 1 Hz */
-	11, 15, 22, 29, 35, 44, 59, 88
+static const int adm1027_freq_map[11] = { /* 1 Hz */
+	11, 15, 22, 29, 35, 44, 59, 88, 88, 88, 25000
 };
-#define FREQ_MAP_LEN	8
+#define FREQ_MAP_LEN	11
 
 static int FREQ_TO_REG(const int *map,
 		       unsigned int map_size, unsigned long freq)
@@ -212,7 +212,7 @@
 
 static int FREQ_FROM_REG(const int *map, u8 reg)
 {
-	return map[reg & 0x07];
+	return map[reg & 0x0f];
 }
 
 /*
@@ -512,7 +512,7 @@
 			data->autofan[i].config =
 			    lm85_read_value(client, LM85_REG_AFAN_CONFIG(i));
 			val = lm85_read_value(client, LM85_REG_AFAN_RANGE(i));
-			data->pwm_freq[i] = val & 0x07;
+			data->pwm_freq[i] = val & 0x0f;
 			data->zone[i].range = val >> 4;
 			data->autofan[i].min_pwm =
 			    lm85_read_value(client, LM85_REG_AFAN_MINPWM(i));
@@ -1194,7 +1194,7 @@
 		TEMP_FROM_REG(data->zone[nr].limit));
 	lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
 		((data->zone[nr].range & 0x0f) << 4)
-		| (data->pwm_freq[nr] & 0x07));
+		| (data->pwm_freq[nr] & 0x0f));
 
 	mutex_unlock(&data->update_lock);
 	return count;
@@ -1230,7 +1230,7 @@
 		val - min);
 	lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
 		((data->zone[nr].range & 0x0f) << 4)
-		| (data->pwm_freq[nr] & 0x07));
+		| (data->pwm_freq[nr] & 0x0f));
 	mutex_unlock(&data->update_lock);
 	return count;
 }
@@ -1419,10 +1419,28 @@
 	.attrs = lm85_attributes_in567,
 };
 
-static void lm85_init_client(struct i2c_client *client)
+static void lm85_init_client(struct i2c_client *client, struct lm85_data *data)
 {
 	int value;
 
+	/* workaround for emc2300 (emc6d103s), when auto temp min is
+	 * the default value, pwm can never be controlled manually, so
+	 * change this */
+	if (data->type == emc6d103s) {
+		int nr;
+
+		for (nr = 0; nr < 3; nr++) {
+			data->zone[nr].limit = TEMP_TO_REG(-127000);
+			lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr),
+					 data->zone[nr].limit);
+
+			/* also force high frequency */
+			data->pwm_freq[nr] = 0xa;
+			lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
+					 data->pwm_freq[nr]);
+		}
+	}
+
 	/* Start monitoring if needed */
 	value = lm85_read_value(client, LM85_REG_CONFIG);
 	if (!(value & 0x01)) {
@@ -1573,7 +1591,7 @@
 	data->vrm = vid_which_vrm();
 
 	/* Initialize the LM85 chip */
-	lm85_init_client(client);
+	lm85_init_client(client, data);
 
 	/* sysfs hooks */
 	data->groups[idx++] = &lm85_group;
diff -ruw linux-4.2.6/drivers/hwmon/Makefile linux-4.2.6-fbx/drivers/hwmon/Makefile
--- linux-4.2.6/drivers/hwmon/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/hwmon/Makefile	2015-11-18 18:24:30.276152704 +0100
@@ -158,6 +158,7 @@
 obj-$(CONFIG_SENSORS_W83L786NG)	+= w83l786ng.o
 obj-$(CONFIG_SENSORS_WM831X)	+= wm831x-hwmon.o
 obj-$(CONFIG_SENSORS_WM8350)	+= wm8350-hwmon.o
+obj-$(CONFIG_SENSORS_KIRKWOOD_CORETEMP)+= kirkwood-coretemp.o
 
 obj-$(CONFIG_PMBUS)		+= pmbus/
 
diff -ruw linux-4.2.6/drivers/i2c/busses/i2c-mv64xxx.c linux-4.2.6-fbx/drivers/i2c/busses/i2c-mv64xxx.c
--- linux-4.2.6/drivers/i2c/busses/i2c-mv64xxx.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/i2c/busses/i2c-mv64xxx.c	2015-11-18 18:24:30.328153119 +0100
@@ -311,6 +311,11 @@
 	case MV64XXX_I2C_STATUS_MAST_WR_NO_ACK: /* 30 */
 	case MV64XXX_I2C_STATUS_MAST_RD_ADDR_NO_ACK: /* 48 */
 		/* Doesn't seem to be a device at other end */
+		dev_dbg(&drv_data->adapter.dev,
+			"mv64xxx_i2c_fsm: got no ack -- state: 0x%x, "
+			"status: 0x%x, addr: 0x%x, flags: 0x%x\n",
+			 drv_data->state, status, drv_data->msg->addr,
+			 drv_data->msg->flags);
 		drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP;
 		drv_data->state = MV64XXX_I2C_STATE_IDLE;
 		drv_data->rc = -ENXIO;
@@ -572,6 +577,34 @@
 				int is_last)
 {
 	unsigned long	flags;
+	int limit;
+
+	/*
+	 * wait for (re)start/stop condition to clear from last
+	 * transfer if any
+	 */
+	limit = 1000;
+	do {
+		u32 val;
+
+		val = readl(drv_data->reg_base + drv_data->reg_offsets.control);
+		if (!(val & (MV64XXX_I2C_REG_CONTROL_STOP |
+			     MV64XXX_I2C_REG_CONTROL_STOP)))
+			break;
+
+		udelay(1);
+	} while (limit-- > 0);
+
+	if (limit < 0) {
+		dev_err(&drv_data->adapter.dev,
+			"mv64xxx: start/stop bit won't clear\n");
+	}
+
+	/* according to datasheet, controller is buggy when you do
+	 * register polling and it says to always wait for an IRQ
+	 * (clock domain related), since we busywait for START/STOP
+	 * clear, add a small delay */
+	udelay(5);
 
 	spin_lock_irqsave(&drv_data->lock, flags);
 
@@ -579,6 +612,7 @@
 
 	drv_data->send_stop = is_last;
 	drv_data->block = 1;
+
 	mv64xxx_i2c_send_start(drv_data);
 	spin_unlock_irqrestore(&drv_data->lock, flags);
 
diff -ruw linux-4.2.6/drivers/i2c/busses/Kconfig linux-4.2.6-fbx/drivers/i2c/busses/Kconfig
--- linux-4.2.6/drivers/i2c/busses/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/i2c/busses/Kconfig	2015-11-18 18:24:30.316153032 +0100
@@ -1139,6 +1139,10 @@
 	  to SLIMpro (On chip coprocessor) mailbox mechanism.
 	  If unsure, say N.
 
+config I2C_WP3
+	tristate "Wintegra WP3 I2C controll"
+	depends on WINTEGRA_WINPATH3
+
 config SCx200_ACB
 	tristate "Geode ACCESS.bus support"
 	depends on X86_32 && PCI
diff -ruw linux-4.2.6/drivers/i2c/busses/Makefile linux-4.2.6-fbx/drivers/i2c/busses/Makefile
--- linux-4.2.6/drivers/i2c/busses/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/i2c/busses/Makefile	2015-11-18 18:24:30.316153032 +0100
@@ -92,6 +92,7 @@
 obj-$(CONFIG_I2C_XLR)		+= i2c-xlr.o
 obj-$(CONFIG_I2C_XLP9XX)	+= i2c-xlp9xx.o
 obj-$(CONFIG_I2C_RCAR)		+= i2c-rcar.o
+obj-$(CONFIG_I2C_WP3)		+= i2c-wp3.o
 
 # External I2C/SMBus adapter drivers
 obj-$(CONFIG_I2C_DIOLAN_U2C)	+= i2c-diolan-u2c.o
diff -ruw linux-4.2.6/drivers/ide/Kconfig linux-4.2.6-fbx/drivers/ide/Kconfig
--- linux-4.2.6/drivers/ide/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/ide/Kconfig	2015-11-18 18:24:30.340153211 +0100
@@ -684,6 +684,11 @@
        depends on BLK_DEV_IDE_AU1XXX
 endchoice
 
+config BLK_DEV_IDE_TANGO2
+	tristate "IDE for Tango2"
+	depends on TANGO2
+	select BLK_DEV_IDEDMA_SFF
+
 config BLK_DEV_IDE_TX4938
 	tristate "TX4938 internal IDE support"
 	depends on SOC_TX4938
diff -ruw linux-4.2.6/drivers/ide/Makefile linux-4.2.6-fbx/drivers/ide/Makefile
--- linux-4.2.6/drivers/ide/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/ide/Makefile	2015-11-18 18:24:30.340153211 +0100
@@ -113,3 +113,4 @@
 
 obj-$(CONFIG_BLK_DEV_IDE_TX4938)	+= tx4938ide.o
 obj-$(CONFIG_BLK_DEV_IDE_TX4939)	+= tx4939ide.o
+obj-$(CONFIG_BLK_DEV_IDE_TANGO2)	+= tango2ide.o
diff -ruw linux-4.2.6/drivers/input/misc/Kconfig linux-4.2.6-fbx/drivers/input/misc/Kconfig
--- linux-4.2.6/drivers/input/misc/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/input/misc/Kconfig	2015-11-18 18:24:30.452154100 +0100
@@ -807,4 +807,9 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called drv2667-haptics.
 
+config INPUT_SMSC_CAP1066
+	tristate "SMSC CAP1066 capacitive sensor driver"
+	select I2C
+	select INPUT_POLLDEV
+
 endif
diff -ruw linux-4.2.6/drivers/input/misc/Makefile linux-4.2.6-fbx/drivers/input/misc/Makefile
--- linux-4.2.6/drivers/input/misc/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/input/misc/Makefile	2015-11-18 18:24:30.452154100 +0100
@@ -76,3 +76,4 @@
 obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND)	+= xen-kbdfront.o
 obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
 obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR)	+= ideapad_slidebar.o
+obj-$(CONFIG_INPUT_SMSC_CAP1066)	+= smsc_cap1066.o
diff -ruw linux-4.2.6/drivers/Kconfig linux-4.2.6-fbx/drivers/Kconfig
--- linux-4.2.6/drivers/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/Kconfig	2015-11-18 18:24:29.592147281 +0100
@@ -8,8 +8,12 @@
 
 source "drivers/connector/Kconfig"
 
+source "drivers/fbxprocfs/Kconfig"
+
 source "drivers/mtd/Kconfig"
 
+source "drivers/fbxmtd/Kconfig"
+
 source "drivers/of/Kconfig"
 
 source "drivers/parport/Kconfig"
@@ -64,6 +68,10 @@
 
 source "drivers/gpio/Kconfig"
 
+source "drivers/fbxgpio/Kconfig"
+
+source "drivers/fbxjtag/Kconfig"
+
 source "drivers/w1/Kconfig"
 
 source "drivers/power/Kconfig"
@@ -72,6 +80,8 @@
 
 source "drivers/thermal/Kconfig"
 
+source "drivers/fbxwatchdog/Kconfig"
+
 source "drivers/watchdog/Kconfig"
 
 source "drivers/ssb/Kconfig"
diff -ruw linux-4.2.6/drivers/Makefile linux-4.2.6-fbx/drivers/Makefile
--- linux-4.2.6/drivers/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/Makefile	2015-11-20 17:03:49.275642231 +0100
@@ -14,6 +14,8 @@
 obj-y				+= pinctrl/
 obj-y				+= gpio/
 obj-y				+= pwm/
+obj-$(CONFIG_FREEBOX_GPIO)	+= fbxgpio/
+obj-$(CONFIG_FREEBOX_JTAG)	+= fbxjtag/
 obj-$(CONFIG_PCI)		+= pci/
 obj-$(CONFIG_PARISC)		+= parisc/
 obj-$(CONFIG_RAPIDIO)		+= rapidio/
@@ -84,6 +86,8 @@
 obj-$(CONFIG_VFIO)		+= vfio/
 obj-y				+= cdrom/
 obj-y				+= auxdisplay/
+
+obj-$(CONFIG_FREEBOX_MTD)	+= fbxmtd/
 obj-$(CONFIG_PCCARD)		+= pcmcia/
 obj-$(CONFIG_DIO)		+= dio/
 obj-$(CONFIG_SBUS)		+= sbus/
@@ -107,6 +111,7 @@
 obj-$(CONFIG_POWER_SUPPLY)	+= power/
 obj-$(CONFIG_HWMON)		+= hwmon/
 obj-$(CONFIG_THERMAL)		+= thermal/
+obj-$(CONFIG_FREEBOX_WATCHDOG)	+= fbxwatchdog/
 obj-$(CONFIG_WATCHDOG)		+= watchdog/
 obj-$(CONFIG_MD)		+= md/
 obj-$(CONFIG_BT)		+= bluetooth/
@@ -165,3 +170,5 @@
 obj-$(CONFIG_THUNDERBOLT)	+= thunderbolt/
 obj-$(CONFIG_CORESIGHT)		+= hwtracing/coresight/
 obj-$(CONFIG_ANDROID)		+= android/
+
+obj-$(CONFIG_FREEBOX_PROCFS)	+= fbxprocfs/
diff -ruw linux-4.2.6/drivers/media/dvb-core/dvb_frontend.c linux-4.2.6-fbx/drivers/media/dvb-core/dvb_frontend.c
--- linux-4.2.6/drivers/media/dvb-core/dvb_frontend.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/media/dvb-core/dvb_frontend.c	2015-11-18 18:24:30.572155061 +0100
@@ -875,6 +875,7 @@
 	if (fe->exit != DVB_FE_DEVICE_REMOVED)
 		fe->exit = DVB_FE_NORMAL_EXIT;
 	mb();
+	wake_up_all(&fepriv->events.wait_queue);
 
 	if (!fepriv->thread)
 		return;
@@ -2537,6 +2538,9 @@
 
 	poll_wait (file, &fepriv->events.wait_queue, wait);
 
+	if (fe->exit)
+		return POLLERR | POLLHUP;
+
 	if (fepriv->events.eventw != fepriv->events.eventr)
 		return (POLLIN | POLLRDNORM | POLLPRI);
 
diff -ruw linux-4.2.6/drivers/media/dvb-core/dvb-usb-ids.h linux-4.2.6-fbx/drivers/media/dvb-core/dvb-usb-ids.h
--- linux-4.2.6/drivers/media/dvb-core/dvb-usb-ids.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/media/dvb-core/dvb-usb-ids.h	2015-11-18 18:24:30.572155061 +0100
@@ -105,6 +105,7 @@
 #define USB_PID_DELOCK_USB2_DVBT			0xb803
 #define USB_PID_DIBCOM_HOOK_DEFAULT			0x0064
 #define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM		0x0065
+#define USB_PID_DIBCOM_HOOK_DEFAULT_STK7770P		0x0066
 #define USB_PID_DIBCOM_MOD3000_COLD			0x0bb8
 #define USB_PID_DIBCOM_MOD3000_WARM			0x0bb9
 #define USB_PID_DIBCOM_MOD3001_COLD			0x0bc6
diff -ruw linux-4.2.6/drivers/media/dvb-frontends/af9033.c linux-4.2.6-fbx/drivers/media/dvb-frontends/af9033.c
--- linux-4.2.6/drivers/media/dvb-frontends/af9033.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/media/dvb-frontends/af9033.c	2015-11-18 18:24:30.576155087 +0100
@@ -272,6 +272,22 @@
 		{ 0x800045, dev->cfg.adc_multiplier, 0xff },
 	};
 
+	/* power up tuner - for performance */
+	switch (dev->cfg.tuner) {
+	case AF9033_TUNER_IT9135_38:
+	case AF9033_TUNER_IT9135_51:
+	case AF9033_TUNER_IT9135_52:
+	case AF9033_TUNER_IT9135_60:
+	case AF9033_TUNER_IT9135_61:
+	case AF9033_TUNER_IT9135_62:
+		ret = af9033_wr_reg(dev, 0x80ec40, 0x1);
+		ret |= af9033_wr_reg(dev, 0x80fba8, 0x0);
+		ret |= af9033_wr_reg(dev, 0x80ec57, 0x0);
+		ret |= af9033_wr_reg(dev, 0x80ec58, 0x0);
+		if (ret < 0)
+			goto err;
+	}
+
 	/* program clock control */
 	clock_cw = af9033_div(dev, dev->cfg.clock, 1000000ul, 19ul);
 	buf[0] = (clock_cw >>  0) & 0xff;
@@ -450,6 +466,8 @@
 	case AF9033_TUNER_IT9135_61:
 	case AF9033_TUNER_IT9135_62:
 		ret = af9033_wr_reg(dev, 0x800000, 0x01);
+		ret |= af9033_wr_reg(dev, 0x00d827, 0x00);
+		ret |= af9033_wr_reg(dev, 0x00d829, 0x00);
 		if (ret < 0)
 			goto err;
 	}
diff -ruw linux-4.2.6/drivers/media/platform/Kconfig linux-4.2.6-fbx/drivers/media/platform/Kconfig
--- linux-4.2.6/drivers/media/platform/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/media/platform/Kconfig	2015-11-18 18:24:30.688155977 +0100
@@ -119,6 +119,7 @@
 source "drivers/media/platform/s5p-tv/Kconfig"
 source "drivers/media/platform/am437x/Kconfig"
 source "drivers/media/platform/xilinx/Kconfig"
+source "drivers/media/platform/tango2/Kconfig"
 
 endif # V4L_PLATFORM_DRIVERS
 
diff -ruw linux-4.2.6/drivers/media/platform/Makefile linux-4.2.6-fbx/drivers/media/platform/Makefile
--- linux-4.2.6/drivers/media/platform/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/media/platform/Makefile	2015-11-18 18:24:30.688155977 +0100
@@ -49,6 +49,7 @@
 obj-y	+= omap/
 
 obj-$(CONFIG_VIDEO_AM437X_VPFE)		+= am437x/
+obj-$(CONFIG_DVB_TANGO2)		+= tango2/
 
 obj-$(CONFIG_VIDEO_XILINX)		+= xilinx/
 
diff -ruw linux-4.2.6/drivers/media/rc/keymaps/Makefile linux-4.2.6-fbx/drivers/media/rc/keymaps/Makefile
--- linux-4.2.6/drivers/media/rc/keymaps/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/media/rc/keymaps/Makefile	2015-11-18 18:24:30.748156458 +0100
@@ -79,6 +79,7 @@
 			rc-pv951.o \
 			rc-hauppauge.o \
 			rc-rc6-mce.o \
+			rc-rc6-freebox.o \
 			rc-real-audio-220-32-keys.o \
 			rc-reddo.o \
 			rc-snapstream-firefly.o \
diff -ruw linux-4.2.6/drivers/media/tuners/it913x.c linux-4.2.6-fbx/drivers/media/tuners/it913x.c
--- linux-4.2.6/drivers/media/tuners/it913x.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/media/tuners/it913x.c	2015-11-18 18:24:30.756156511 +0100
@@ -136,18 +136,6 @@
 	if (ret)
 		goto err;
 
-	ret = regmap_write(dev->regmap, 0x80ec57, 0x00);
-	if (ret)
-		goto err;
-
-	ret = regmap_write(dev->regmap, 0x80ec58, 0x00);
-	if (ret)
-		goto err;
-
-	ret = regmap_write(dev->regmap, 0x80ec40, 0x01);
-	if (ret)
-		goto err;
-
 	dev->active = true;
 
 	return 0;
diff -ruw linux-4.2.6/drivers/media/usb/dvb-usb/dib0700_devices.c linux-4.2.6-fbx/drivers/media/usb/dvb-usb/dib0700_devices.c
--- linux-4.2.6/drivers/media/usb/dvb-usb/dib0700_devices.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/media/usb/dvb-usb/dib0700_devices.c	2015-11-18 18:24:30.784156739 +0100
@@ -3794,6 +3794,7 @@
 /* 80 */{ USB_DEVICE(USB_VID_ELGATO,	USB_PID_ELGATO_EYETV_DTT_2) },
 	{ USB_DEVICE(USB_VID_PCTV,      USB_PID_PCTV_2002E) },
 	{ USB_DEVICE(USB_VID_PCTV,      USB_PID_PCTV_2002E_SE) },
+	{ USB_DEVICE(USB_VID_DIBCOM,	USB_PID_DIBCOM_HOOK_DEFAULT_STK7770P) },
 	{ 0 }		/* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -4521,6 +4522,35 @@
 			.change_protocol  = dib0700_change_protocol,
 		},
 	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
+
+		.num_adapters = 1,
+		.adapter = {
+			{
+			.num_frontends = 1,
+			.fe = {{
+				.caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
+				.pid_filter_count = 32,
+				.pid_filter       = stk70x0p_pid_filter,
+				.pid_filter_ctrl  = stk70x0p_pid_filter_ctrl,
+				.frontend_attach  = stk7770p_frontend_attach,
+				.tuner_attach     = dib7770p_tuner_attach,
+
+				DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
+			}},
+				.size_of_priv =
+					sizeof(struct dib0700_adapter_state),
+			},
+		},
+
+		.num_device_descs = 1,
+		.devices = {
+			{   "DiBcom STK7770P reference design no IR",
+				{ &dib0700_usb_id_table[83], NULL },
+				{ NULL },
+			},
+		},
+
+	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
 		.num_adapters = 1,
 		.adapter = {
 			{
diff -ruw linux-4.2.6/drivers/media/usb/dvb-usb/dvb-usb.h linux-4.2.6-fbx/drivers/media/usb/dvb-usb/dvb-usb.h
--- linux-4.2.6/drivers/media/usb/dvb-usb/dvb-usb.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/media/usb/dvb-usb/dvb-usb.h	2015-11-02 19:00:28.105072805 +0100
@@ -294,7 +294,7 @@
 	int generic_bulk_ctrl_endpoint_response;
 
 	int num_device_descs;
-	struct dvb_usb_device_description devices[12];
+	struct dvb_usb_device_description devices[32];
 };
 
 /**
diff -ruw linux-4.2.6/drivers/media/usb/dvb-usb-v2/af9035.c linux-4.2.6-fbx/drivers/media/usb/dvb-usb-v2/af9035.c
--- linux-4.2.6/drivers/media/usb/dvb-usb-v2/af9035.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/media/usb/dvb-usb-v2/af9035.c	2015-11-18 18:24:30.776156671 +0100
@@ -739,6 +739,8 @@
 	if (ret < 0)
 		goto err;
 
+	msleep(30);
+
 	/* firmware loaded, request boot */
 	req.cmd = CMD_FW_BOOT;
 	ret = af9035_ctrl_msg(d, &req);
@@ -758,6 +760,15 @@
 		goto err;
 	}
 
+	/* tuner RF initial */
+	if (state->chip_type == 0x9135) {
+		ret = af9035_wr_reg(d, 0x80ec4c, 0x68);
+		if (ret < 0)
+			goto err;
+
+		msleep(30);
+	}
+
 	dev_info(&d->udev->dev, "%s: firmware version=%d.%d.%d.%d",
 			KBUILD_MODNAME, rbuf[0], rbuf[1], rbuf[2], rbuf[3]);
 
diff -ruw linux-4.2.6/drivers/misc/eeprom/at24.c linux-4.2.6-fbx/drivers/misc/eeprom/at24.c
--- linux-4.2.6/drivers/misc/eeprom/at24.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/misc/eeprom/at24.c	2015-11-18 18:24:30.868157399 +0100
@@ -260,8 +260,9 @@
 		if (status == count)
 			return count;
 
-		/* REVISIT: at HZ=100, this is sloooow */
-		msleep(1);
+		if (need_resched())
+			schedule();
+
 	} while (time_before(read_time, timeout));
 
 	return -ETIMEDOUT;
@@ -391,8 +392,9 @@
 		if (status == count)
 			return count;
 
-		/* REVISIT: at HZ=100, this is sloooow */
-		msleep(1);
+		if (need_resched())
+			schedule();
+
 	} while (time_before(write_time, timeout));
 
 	return -ETIMEDOUT;
diff -ruw linux-4.2.6/drivers/misc/Kconfig linux-4.2.6-fbx/drivers/misc/Kconfig
--- linux-4.2.6/drivers/misc/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/misc/Kconfig	2015-11-18 18:24:30.864157371 +0100
@@ -4,6 +4,9 @@
 
 menu "Misc devices"
 
+config WINTEGRA_MMAP
+	bool "wintegra mmap driver"
+
 config SENSORS_LIS3LV02D
 	tristate
 	depends on INPUT
@@ -418,6 +421,18 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called vmw_balloon.
 
+config INTELCE_PIC16PMU
+	tristate "PIC16 PMU, LED, hwmon support"
+	select INPUT_POLLDEV
+	select NEW_LEDS
+	select I2C
+	select HWMON
+	select ARCH_REQUIRE_GPIOLIB
+	---help---
+	  Freebox v6 HD PIC16 PMU interface support, enables
+	  control of the on-board LEDs and reports the power status,
+	  reset status and button status.
+
 config ARM_CHARLCD
 	bool "ARM Ltd. Character LCD Driver"
 	depends on PLAT_VERSATILE
@@ -527,4 +542,6 @@
 source "drivers/misc/genwqe/Kconfig"
 source "drivers/misc/echo/Kconfig"
 source "drivers/misc/cxl/Kconfig"
+source "drivers/misc/remoti/Kconfig"
+source "drivers/misc/hdmi-cec/Kconfig"
 endmenu
diff -ruw linux-4.2.6/drivers/misc/Makefile linux-4.2.6-fbx/drivers/misc/Makefile
--- linux-4.2.6/drivers/misc/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/misc/Makefile	2015-11-18 18:24:30.864157371 +0100
@@ -2,6 +2,7 @@
 # Makefile for misc devices that really don't fit anywhere else.
 #
 
+obj-$(CONFIG_WINTEGRA_MMAP)	+= wintegra_mmap.o
 obj-$(CONFIG_IBM_ASM)		+= ibmasm/
 obj-$(CONFIG_AD525X_DPOT)	+= ad525x_dpot.o
 obj-$(CONFIG_AD525X_DPOT_I2C)	+= ad525x_dpot-i2c.o
@@ -25,6 +26,7 @@
 obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o
 obj-$(CONFIG_KGDB_TESTS)	+= kgdbts.o
 obj-$(CONFIG_SGI_XP)		+= sgi-xp/
+obj-$(CONFIG_INTELCE_PIC16PMU)	+= pic16-pmu.o
 obj-$(CONFIG_SGI_GRU)		+= sgi-gru/
 obj-$(CONFIG_CS5535_MFGPT)	+= cs5535-mfgpt.o
 obj-$(CONFIG_HP_ILO)		+= hpilo.o
@@ -55,3 +57,5 @@
 obj-$(CONFIG_ECHO)		+= echo/
 obj-$(CONFIG_VEXPRESS_SYSCFG)	+= vexpress-syscfg.o
 obj-$(CONFIG_CXL_BASE)		+= cxl/
+obj-y				+= remoti/
+obj-y				+= hdmi-cec/
diff -ruw linux-4.2.6/drivers/mtd/devices/m25p80.c linux-4.2.6-fbx/drivers/mtd/devices/m25p80.c
--- linux-4.2.6/drivers/mtd/devices/m25p80.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/mtd/devices/m25p80.c	2015-11-18 18:24:30.916157781 +0100
@@ -48,6 +48,34 @@
 	return ret;
 }
 
+static int m25p80_read_alt_id(struct spi_nor *nor, u8 cmd, u8 *val, int len)
+{
+	struct m25p *flash = nor->priv;
+	struct spi_device *spi = flash->spi;
+	u8 cmdbuf[4] = { cmd, 0, 0, 0 };
+	int ret;
+
+	ret = spi_write_then_read(spi, cmdbuf, sizeof (cmdbuf), val, len);
+	if (ret < 0)
+		dev_err(&spi->dev, "error %d reading alt id %x\n", ret, cmd);
+
+	return ret;
+}
+
+static int m25p80_read_atmel_id(struct spi_nor *nor, u8 cmd, u8 *val, int len)
+{
+	struct m25p *flash = nor->priv;
+	struct spi_device *spi = flash->spi;
+	int ret;
+
+	printk("m25p80_read_atmel_id: 0x%x\n", cmd);
+	ret = spi_write_then_read(spi, &cmd, 1, val, len);
+	if (ret < 0)
+		dev_err(&spi->dev, "error %d reading ATMEL id %x\n", ret, cmd);
+
+	return ret;
+}
+
 static void m25p_addr2cmd(struct spi_nor *nor, unsigned int addr, u8 *cmd)
 {
 	/* opcode is in cmd[0] */
@@ -199,6 +227,8 @@
 	nor->erase = m25p80_erase;
 	nor->write_reg = m25p80_write_reg;
 	nor->read_reg = m25p80_read_reg;
+	nor->read_alt_id = m25p80_read_alt_id;
+	nor->read_atmel_id = m25p80_read_atmel_id;
 
 	nor->dev = &spi->dev;
 	nor->mtd = &flash->mtd;
diff -ruw linux-4.2.6/drivers/mtd/Kconfig linux-4.2.6-fbx/drivers/mtd/Kconfig
--- linux-4.2.6/drivers/mtd/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/mtd/Kconfig	2015-11-18 18:24:30.912157754 +0100
@@ -23,6 +23,9 @@
 	  WARNING: some of the tests will ERASE entire MTD device which they
 	  test. Do not use these tests unless you really know what you do.
 
+config MTD_ERASE_PRINTK
+	bool "write to kernel log when a block is erased"
+
 config MTD_REDBOOT_PARTS
 	tristate "RedBoot partition table parsing"
 	---help---
@@ -155,6 +158,17 @@
 	  This provides partitions parser for devices based on BCM47xx
 	  boards.
 
+config MTD_FBX6HD_PARTS
+	tristate "Freebox V6 HD partitioning support"
+	help
+	  Freebox V6 HD partitioning support
+
+config MTD_FBX6HD_PARTS_WRITE_ALL
+	bool "make all partitions writeable"
+	depends on MTD_FBX6HD_PARTS
+	help
+	  Freebox V6 HD partitions support
+
 comment "User Modules And Translation Layers"
 
 #
diff -ruw linux-4.2.6/drivers/mtd/Makefile linux-4.2.6-fbx/drivers/mtd/Makefile
--- linux-4.2.6/drivers/mtd/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/mtd/Makefile	2015-11-18 18:24:30.912157754 +0100
@@ -13,6 +13,7 @@
 obj-$(CONFIG_MTD_AR7_PARTS)	+= ar7part.o
 obj-$(CONFIG_MTD_BCM63XX_PARTS)	+= bcm63xxpart.o
 obj-$(CONFIG_MTD_BCM47XX_PARTS)	+= bcm47xxpart.o
+obj-$(CONFIG_MTD_FBX6HD_PARTS)	+= fbx6hd-mtdparts.o
 
 # 'Users' - code which presents functionality to userspace.
 obj-$(CONFIG_MTD_BLKDEVS)	+= mtd_blkdevs.o
diff -ruw linux-4.2.6/drivers/mtd/mtdchar.c linux-4.2.6-fbx/drivers/mtd/mtdchar.c
--- linux-4.2.6/drivers/mtd/mtdchar.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/mtd/mtdchar.c	2015-11-18 18:24:30.924157854 +0100
@@ -186,6 +186,7 @@
 		{
 			struct mtd_oob_ops ops;
 
+			memset(&ops, 0, sizeof (ops));
 			ops.mode = MTD_OPS_RAW;
 			ops.datbuf = kbuf;
 			ops.oobbuf = NULL;
@@ -280,6 +281,7 @@
 		{
 			struct mtd_oob_ops ops;
 
+			memset(&ops, 0, sizeof (ops));
 			ops.mode = MTD_OPS_RAW;
 			ops.datbuf = kbuf;
 			ops.oobbuf = NULL;
@@ -692,6 +694,10 @@
 			erase->callback = mtdchar_erase_callback;
 			erase->priv = (unsigned long)&waitq;
 
+#ifdef CONFIG_MTD_ERASE_PRINTK
+			printk(KERN_DEBUG "mtd: %s: ERASE offset=@%08llx\n",
+			       mtd->name, erase->addr);
+#endif
 			/*
 			  FIXME: Allow INTERRUPTIBLE. Which means
 			  not having the wait_queue head on the stack.
diff -ruw linux-4.2.6/drivers/mtd/mtdcore.c linux-4.2.6-fbx/drivers/mtd/mtdcore.c
--- linux-4.2.6/drivers/mtd/mtdcore.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/mtd/mtdcore.c	2015-11-18 18:24:30.924157854 +0100
@@ -318,6 +318,24 @@
 }
 static DEVICE_ATTR(bbt_blocks, S_IRUGO, mtd_bbtblocks_show, NULL);
 
+static ssize_t mtd_nand_type_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct mtd_info *mtd = dev_get_drvdata(dev);
+
+	return snprintf(buf, PAGE_SIZE, "%s\n", mtd->nand_type);
+}
+static DEVICE_ATTR(nand_type, S_IRUGO, mtd_nand_type_show, NULL);
+
+static ssize_t mtd_nand_manufacturer_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct mtd_info *mtd = dev_get_drvdata(dev);
+
+	return snprintf(buf, PAGE_SIZE, "%s\n", mtd->nand_manufacturer);
+}
+static DEVICE_ATTR(nand_manufacturer, S_IRUGO, mtd_nand_manufacturer_show, NULL);
+
 static struct attribute *mtd_attrs[] = {
 	&dev_attr_type.attr,
 	&dev_attr_flags.attr,
@@ -335,6 +353,8 @@
 	&dev_attr_bad_blocks.attr,
 	&dev_attr_bbt_blocks.attr,
 	&dev_attr_bitflip_threshold.attr,
+	&dev_attr_nand_type.attr,
+	&dev_attr_nand_manufacturer.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(mtd);
diff -ruw linux-4.2.6/drivers/mtd/mtdpart.c linux-4.2.6-fbx/drivers/mtd/mtdpart.c
--- linux-4.2.6/drivers/mtd/mtdpart.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/mtd/mtdpart.c	2015-11-18 18:24:30.924157854 +0100
@@ -376,6 +376,8 @@
 	slave->mtd.oobsize = master->oobsize;
 	slave->mtd.oobavail = master->oobavail;
 	slave->mtd.subpage_sft = master->subpage_sft;
+	slave->mtd.nand_type = master->nand_type;
+	slave->mtd.nand_manufacturer = master->nand_manufacturer;
 
 	slave->mtd.name = name;
 	slave->mtd.owner = master->owner;
diff -ruw linux-4.2.6/drivers/mtd/nand/Kconfig linux-4.2.6-fbx/drivers/mtd/nand/Kconfig
--- linux-4.2.6/drivers/mtd/nand/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/mtd/nand/Kconfig	2015-11-18 18:24:30.924157854 +0100
@@ -41,6 +41,15 @@
 	tristate
 	default n
 
+config MTD_FORCE_BAD_BLOCK_ERASE
+	bool "Force erase on bad blocks (useful for bootloader parts)"
+	depends on MTD_NAND
+	default n
+	help
+	  Enable this option only when you need to force an erase on
+	  blocks being marked as "bad" by Linux (i.e: other ECC/bad block
+	  marker layout).
+
 config MTD_NAND_DENALI
         tristate "Support Denali NAND controller"
         depends on HAS_DMA
@@ -538,4 +547,9 @@
 	help
 	  Enables support for NAND controller on Hisilicon SoC Hip04.
 
+config MTD_NAND_DENALI_FBX
+	tristate "NAND Denali controller support"
+	depends on MTD_NAND && PCI
+	default n
+
 endif # MTD_NAND
diff -ruw linux-4.2.6/drivers/mtd/nand/Makefile linux-4.2.6-fbx/drivers/mtd/nand/Makefile
--- linux-4.2.6/drivers/mtd/nand/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/mtd/nand/Makefile	2015-11-18 18:24:30.924157854 +0100
@@ -53,5 +53,6 @@
 obj-$(CONFIG_MTD_NAND_SUNXI)		+= sunxi_nand.o
 obj-$(CONFIG_MTD_NAND_HISI504)	        += hisi504_nand.o
 obj-$(CONFIG_MTD_NAND_BRCMNAND)		+= brcmnand/
+obj-$(CONFIG_MTD_NAND_DENALI_FBX)	+= denali_nand.o
 
 nand-objs := nand_base.o nand_bbt.o nand_timings.o
diff -ruw linux-4.2.6/drivers/mtd/nand/nand_base.c linux-4.2.6-fbx/drivers/mtd/nand/nand_base.c
--- linux-4.2.6/drivers/mtd/nand/nand_base.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/mtd/nand/nand_base.c	2015-11-18 18:24:30.936157940 +0100
@@ -2771,6 +2771,7 @@
 
 	while (len) {
 		/* Check if we have a bad block, we do not erase bad blocks! */
+#ifndef CONFIG_MTD_FORCE_BAD_BLOCK_ERASE
 		if (nand_block_checkbad(mtd, ((loff_t) page) <<
 					chip->page_shift, 0, allowbbt)) {
 			pr_warn("%s: attempt to erase a bad block at page 0x%08x\n",
@@ -2778,6 +2779,7 @@
 			instr->state = MTD_ERASE_FAILED;
 			goto erase_exit;
 		}
+#endif
 
 		/*
 		 * Invalidate the page cache, if we erase the block which
@@ -3641,6 +3643,7 @@
 	int busw;
 	int i, maf_idx;
 	u8 id_data[8];
+	int ret;
 
 	/* Select the device */
 	chip->select_chip(mtd, 0);
@@ -3775,6 +3778,17 @@
 	if (mtd->writesize > 512 && chip->cmdfunc == nand_command)
 		chip->cmdfunc = nand_command_lp;
 
+	mtd->nand_type = kstrdup(type->name, GFP_KERNEL);
+	if (!mtd->nand_type)
+		return ERR_PTR(-ENOMEM);
+
+	mtd->nand_manufacturer = kstrdup(nand_manuf_ids[maf_idx].name,
+					 GFP_KERNEL);
+	if (!mtd->nand_manufacturer) {
+		ret = -ENOMEM;
+		goto out_nand_type;
+	}
+
 	pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n",
 		*maf_id, *dev_id);
 
@@ -3792,6 +3806,11 @@
 		(int)(chip->chipsize >> 20), nand_is_slc(chip) ? "SLC" : "MLC",
 		mtd->erasesize >> 10, mtd->writesize, mtd->oobsize);
 	return type;
+
+out_nand_type:
+	kfree(mtd->nand_type);
+
+	return ERR_PTR(ret);
 }
 
 static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip,
@@ -3844,6 +3863,7 @@
 	int i, nand_maf_id, nand_dev_id;
 	struct nand_chip *chip = mtd->priv;
 	struct nand_flash_dev *type;
+	int err;
 	int ret;
 
 	if (chip->dn) {
@@ -3863,7 +3883,8 @@
 		if (!(chip->options & NAND_SCAN_SILENT_NODEV))
 			pr_warn("No NAND device found\n");
 		chip->select_chip(mtd, -1);
-		return PTR_ERR(type);
+		err = PTR_ERR(type);
+		goto out_error;
 	}
 
 	chip->select_chip(mtd, -1);
@@ -3891,6 +3912,14 @@
 	mtd->size = i * chip->chipsize;
 
 	return 0;
+
+out_error:
+	if (mtd->nand_type)
+		kfree(mtd->nand_type);
+	if (mtd->nand_manufacturer)
+		kfree(mtd->nand_manufacturer);
+
+	return err;
 }
 EXPORT_SYMBOL(nand_scan_ident);
 
@@ -4066,9 +4095,13 @@
 		ecc->read_page = nand_read_page_swecc;
 		ecc->read_subpage = nand_read_subpage;
 		ecc->write_page = nand_write_page_swecc;
+		if (!ecc->read_page_raw)
 		ecc->read_page_raw = nand_read_page_raw;
+		if (!ecc->write_page_raw)
 		ecc->write_page_raw = nand_write_page_raw;
+		if (!ecc->read_oob)
 		ecc->read_oob = nand_read_oob_std;
+		if (!ecc->write_oob)
 		ecc->write_oob = nand_write_oob_std;
 		if (!ecc->size)
 			ecc->size = 256;
@@ -4101,6 +4134,7 @@
 		}
 
 		/* See nand_bch_init() for details. */
+		if (!ecc->bytes)
 		ecc->bytes = DIV_ROUND_UP(
 				ecc->strength * fls(8 * ecc->size), 8);
 		ecc->priv = nand_bch_init(mtd, ecc->size, ecc->bytes,
@@ -4186,7 +4220,7 @@
 	switch (ecc->mode) {
 	case NAND_ECC_SOFT:
 	case NAND_ECC_SOFT_BCH:
-		if (chip->page_shift > 9)
+		if (chip->page_shift > 9 && !(chip->options & NAND_NO_RNDOUT))
 			chip->options |= NAND_SUBPAGE_READ;
 		break;
 
diff -ruw linux-4.2.6/drivers/mtd/nand/orion_nand.c linux-4.2.6-fbx/drivers/mtd/nand/orion_nand.c
--- linux-4.2.6/drivers/mtd/nand/orion_nand.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/mtd/nand/orion_nand.c	2015-11-18 18:24:30.940157981 +0100
@@ -130,7 +130,12 @@
 	nc->IO_ADDR_R = nc->IO_ADDR_W = io_base;
 	nc->cmd_ctrl = orion_nand_cmd_ctrl;
 	nc->read_buf = orion_nand_read_buf;
-	nc->ecc.mode = NAND_ECC_SOFT;
+	nc->ecc.mode = board->ecc;
+	if (board->ecc == NAND_ECC_SOFT_BCH) {
+		printk("orion_nand_probe: ECC is SOFT_BCH.\n");
+		nc->ecc.size = board->bch_ecc_size;
+		nc->ecc.bytes = board->bch_ecc_bytes;
+	}
 
 	if (board->chip_delay)
 		nc->chip_delay = board->chip_delay;
diff -ruw linux-4.2.6/drivers/mtd/spi-nor/spi-nor.c linux-4.2.6-fbx/drivers/mtd/spi-nor/spi-nor.c
--- linux-4.2.6/drivers/mtd/spi-nor/spi-nor.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/mtd/spi-nor/spi-nor.c	2015-11-18 18:24:30.944158008 +0100
@@ -29,6 +29,9 @@
 #define SPI_NOR_MAX_ID_LEN	6
 
 struct flash_info {
+
+	uint32_t ext_id;
+
 	/*
 	 * This array stores the ID bytes.
 	 * The first three bytes are the JEDIC ID.
@@ -55,6 +58,8 @@
 #define	SPI_NOR_DUAL_READ	0x20    /* Flash supports Dual Read */
 #define	SPI_NOR_QUAD_READ	0x40    /* Flash supports Quad Read */
 #define	USE_FSR			0x80	/* use flag status register */
+#define ALT_PROBE		0x100	/* only match during alt_probe */
+#define ALT_PROBE_ATMEL		0x200	/* only match during alt_probe_atmel */
 };
 
 #define JEDEC_MFR(info)	((info)->id[0])
@@ -470,6 +475,7 @@
 /* Used when the "_ext_id" is two bytes at most */
 #define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)	\
 	((kernel_ulong_t)&(struct flash_info) {				\
+		.ext_id = (_ext_id),                                    \
 		.id = {							\
 			((_jedec_id) >> 16) & 0xff,			\
 			((_jedec_id) >> 8) & 0xff,			\
@@ -486,6 +492,7 @@
 
 #define INFO6(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)	\
 	((kernel_ulong_t)&(struct flash_info) {				\
+		.ext_id = (_ext_id),                                    \
 		.id = {							\
 			((_jedec_id) >> 16) & 0xff,			\
 			((_jedec_id) >> 8) & 0xff,			\
@@ -699,6 +706,22 @@
 	{ "cat25c09", CAT25_INFO( 128, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
 	{ "cat25c17", CAT25_INFO( 256, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
 	{ "cat25128", CAT25_INFO(2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
+
+	/* Used on Freebox Gateways ... */
+
+	/* Atmel */
+	{ "at25f512b",  INFO(0x1f6500, 0x1f65, 32 * 1024, 2,
+			     ALT_PROBE_ATMEL) },
+	/* Macronix */
+	{ "mx25l512", INFO(0xc20500, 0xc205, 64 * 1024, 1,
+			   ALT_PROBE | SECT_4K) },
+	/* SST */
+	{ "sst25vf512a", INFO(0xbf4800, 0xbf48, 32 * 1024, 2, ALT_PROBE) },
+
+	/* EON */
+	{ "en25f05", INFO(0x1c0500, 0x1c05, 64 * 1024, 1,
+			  ALT_PROBE | SECT_4K) },
+
 	{ },
 };
 
@@ -726,6 +749,58 @@
 	return ERR_PTR(-ENODEV);
 }
 
+static const struct spi_device_id *spi_nor_alt_read_id(struct spi_nor *nor)
+{
+	u8			data[2];
+	u16			id;
+	int			err, tmp;
+	struct flash_info	*info;
+
+	err = nor->read_alt_id(nor, SPINOR_OP_RDID_ALT, data, sizeof (data));
+	if (err) {
+		dev_dbg(nor->dev, "error %d reading ALT ID.\n", err);
+		return ERR_PTR(err);
+	}
+	id = (data[1] << 8) | data[0];
+
+	for (tmp = 0; tmp < ARRAY_SIZE(spi_nor_ids) - 1; tmp++) {
+
+		info = (void *)spi_nor_ids[tmp].driver_data;
+		if ((info->flags & ALT_PROBE) && (info->ext_id == id))
+			return &spi_nor_ids[tmp];
+	}
+
+	dev_err(nor->dev, "unrecognized ALT id %04x\n", id);
+	return ERR_PTR(-ENODEV);
+}
+
+static const struct spi_device_id *spi_nor_atmel_id(struct spi_nor *nor)
+{
+	u8			data[2];
+	u16			id;
+	int			err, tmp;
+	struct flash_info	*info;
+
+	err = nor->read_atmel_id(nor, 0x15, data, sizeof (data));
+	if (err) {
+		dev_dbg(nor->dev, "error %d reading ATMEL ID.\n", err);
+		return ERR_PTR(err);
+	}
+	id = (data[1] << 8) | data[0];
+
+	for (tmp = 0; tmp < ARRAY_SIZE(spi_nor_ids) - 1; tmp++) {
+
+		info = (void *)spi_nor_ids[tmp].driver_data;
+		if ((info->flags & ALT_PROBE_ATMEL) && (info->ext_id == id))
+			return &spi_nor_ids[tmp];
+	}
+
+	dev_err(nor->dev, "unrecognized ATMEL id %04x\n", id);
+	return ERR_PTR(-ENODEV);
+}
+
+
+
 static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
 			size_t *retlen, u_char *buf)
 {
@@ -1001,6 +1076,13 @@
 	return 0;
 }
 
+static void sst_write_enable(struct spi_nor *nor)
+{
+	write_enable(nor);
+	nor->write_reg(nor, SPINOR_OP_EWRSR, NULL, 0, 0);
+	write_sr(nor, 0);
+}
+
 int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 {
 	const struct spi_device_id	*id = NULL;
@@ -1032,6 +1114,12 @@
 	if (name && info->id_len) {
 		const struct spi_device_id *jid;
 
+		jid = spi_nor_alt_read_id(nor);
+		if (IS_ERR(jid))
+			/* try ATMEL */
+			jid = spi_nor_atmel_id(nor);
+		if (IS_ERR(jid))
+			/* try JEDEC */
 		jid = spi_nor_read_id(nor);
 		if (IS_ERR(jid)) {
 			return PTR_ERR(jid);
@@ -1064,6 +1152,9 @@
 		write_sr(nor, 0);
 	}
 
+	if (info->ext_id == 0xbf48)
+		sst_write_enable(nor);
+
 	if (!mtd->name)
 		mtd->name = dev_name(dev);
 	mtd->type = MTD_NORFLASH;
diff -ruw linux-4.2.6/drivers/net/ethernet/Kconfig linux-4.2.6-fbx/drivers/net/ethernet/Kconfig
--- linux-4.2.6/drivers/net/ethernet/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/ethernet/Kconfig	2015-11-18 18:24:30.984158320 +0100
@@ -160,6 +160,7 @@
 source "drivers/net/ethernet/rocker/Kconfig"
 source "drivers/net/ethernet/samsung/Kconfig"
 source "drivers/net/ethernet/seeq/Kconfig"
+source "drivers/net/ethernet/sigma/Kconfig"
 source "drivers/net/ethernet/silan/Kconfig"
 source "drivers/net/ethernet/sis/Kconfig"
 source "drivers/net/ethernet/sfc/Kconfig"
@@ -174,6 +175,7 @@
 source "drivers/net/ethernet/tundra/Kconfig"
 source "drivers/net/ethernet/via/Kconfig"
 source "drivers/net/ethernet/wiznet/Kconfig"
+source "drivers/net/ethernet/wintegra/Kconfig"
 source "drivers/net/ethernet/xilinx/Kconfig"
 source "drivers/net/ethernet/xircom/Kconfig"
 
diff -ruw linux-4.2.6/drivers/net/ethernet/Makefile linux-4.2.6-fbx/drivers/net/ethernet/Makefile
--- linux-4.2.6/drivers/net/ethernet/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/ethernet/Makefile	2015-11-18 18:24:30.984158320 +0100
@@ -71,6 +71,7 @@
 obj-$(CONFIG_NET_VENDOR_SAMSUNG) += samsung/
 obj-$(CONFIG_NET_VENDOR_SEEQ) += seeq/
 obj-$(CONFIG_NET_VENDOR_SILAN) += silan/
+obj-$(CONFIG_NET_VENDOR_SIGMA) += sigma/
 obj-$(CONFIG_NET_VENDOR_SIS) += sis/
 obj-$(CONFIG_SFC) += sfc/
 obj-$(CONFIG_NET_VENDOR_SGI) += sgi/
@@ -84,5 +85,6 @@
 obj-$(CONFIG_NET_VENDOR_TUNDRA) += tundra/
 obj-$(CONFIG_NET_VENDOR_VIA) += via/
 obj-$(CONFIG_NET_VENDOR_WIZNET) += wiznet/
+obj-$(CONFIG_NET_VENDOR_WINTEGRA) += wintegra/
 obj-$(CONFIG_NET_VENDOR_XILINX) += xilinx/
 obj-$(CONFIG_NET_VENDOR_XIRCOM) += xircom/
diff -ruw linux-4.2.6/drivers/net/ethernet/marvell/Kconfig linux-4.2.6-fbx/drivers/net/ethernet/marvell/Kconfig
--- linux-4.2.6/drivers/net/ethernet/marvell/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/ethernet/marvell/Kconfig	2015-11-18 18:24:31.232160292 +0100
@@ -21,6 +21,7 @@
 	depends on (MV64X60 || PPC32 || PLAT_ORION) && INET
 	select PHYLIB
 	select MVMDIO
+	select MII
 	---help---
 	  This driver supports the gigabit ethernet MACs in the
 	  Marvell Discovery PPC/MIPS chipset family (MV643XX) and
@@ -29,6 +30,10 @@
 	  Some boards that use the Discovery chipset are the Momenco
 	  Ocelot C and Jaguar ATX and Pegasos II.
 
+config MV643XX_ETH_FBX_FF
+	bool "fast forward mode for fbxgwrx"
+	depends on (MV643XX_ETH && IP_FFN && IPV6_FFN && IPV6_SIT_6RD)
+
 config MVMDIO
 	tristate "Marvell MDIO interface support"
 	depends on HAS_IOMEM
diff -ruw linux-4.2.6/drivers/net/ethernet/marvell/mv643xx_eth.c linux-4.2.6-fbx/drivers/net/ethernet/marvell/mv643xx_eth.c
--- linux-4.2.6/drivers/net/ethernet/marvell/mv643xx_eth.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/ethernet/marvell/mv643xx_eth.c	2015-11-18 18:24:31.232160292 +0100
@@ -43,6 +43,7 @@
 #include <linux/in.h>
 #include <linux/ip.h>
 #include <net/tso.h>
+#include <net/arp.h>
 #include <linux/tcp.h>
 #include <linux/udp.h>
 #include <linux/etherdevice.h>
@@ -64,6 +65,18 @@
 #include <linux/of_irq.h>
 #include <linux/of_net.h>
 #include <linux/of_mdio.h>
+#include <linux/if_vlan.h>
+#include <linux/sort.h>
+#include <linux/fbxbridge.h>
+#include "../../../net/bridge/br_private.h"
+
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+#include <net/ip_ffn.h>
+#include <net/ip_tunnels.h>
+#include <net/ip6_ffn.h>
+#include <net/ip6_route.h>
+#include <net/ip6_tunnel.h>
+#endif
 
 static char mv643xx_eth_driver_name[] = "mv643xx_eth";
 static char mv643xx_eth_driver_version[] = "1.4";
@@ -107,6 +120,7 @@
 #define  DISABLE_AUTO_NEG_FOR_DUPLEX	0x00000004
 #define  FORCE_LINK_PASS		0x00000002
 #define  SERIAL_PORT_ENABLE		0x00000001
+#define PORT_VPT2P			0x0040
 #define PORT_STATUS			0x0044
 #define  TX_FIFO_EMPTY			0x00000400
 #define  TX_IN_PROGRESS			0x00000080
@@ -133,6 +147,7 @@
 #define INT_CAUSE_EXT			0x0064
 #define  INT_EXT_LINK_PHY		0x00110000
 #define  INT_EXT_TX			0x000000ff
+#define   INT_EXT_TX_0			0x00000001
 #define INT_MASK			0x0068
 #define INT_MASK_EXT			0x006c
 #define TX_FIFO_URGENT_THRESHOLD	0x0074
@@ -181,9 +196,9 @@
  */
 #define DEFAULT_RX_QUEUE_SIZE	128
 #define DEFAULT_TX_QUEUE_SIZE	512
-#define SKB_DMA_REALIGN		((PAGE_SIZE - NET_SKB_PAD) % SMP_CACHE_BYTES)
-
+#define RX_OFFSET		ALIGN(NET_SKB_PAD, SMP_CACHE_BYTES)
 #define TSO_HEADER_SIZE		128
+#define COPY_BREAK_SIZE		128
 
 /* Max number of allowed TCP segments for software TSO */
 #define MV643XX_MAX_TSO_SEGS 100
@@ -206,6 +221,8 @@
 	u32 cmd_sts;		/* Descriptor command status		*/
 	u32 next_desc_ptr;	/* Next descriptor pointer		*/
 	u32 buf_ptr;		/* Descriptor buffer pointer		*/
+	u32 cookie;
+	u32 pad[3];
 };
 
 struct tx_desc {
@@ -214,6 +231,9 @@
 	u32 cmd_sts;		/* Command/status field			*/
 	u32 next_desc_ptr;	/* Pointer to next descriptor		*/
 	u32 buf_ptr;		/* pointer to buffer for this descriptor*/
+	u32 cookie;
+	u32 cookie_size;
+	u32 pad[2];
 };
 #elif defined(__LITTLE_ENDIAN)
 struct rx_desc {
@@ -222,6 +242,8 @@
 	u16 byte_cnt;		/* Descriptor buffer byte count		*/
 	u32 buf_ptr;		/* Descriptor buffer pointer		*/
 	u32 next_desc_ptr;	/* Next descriptor pointer		*/
+	u32 cookie;
+	u32 pad[3];
 };
 
 struct tx_desc {
@@ -230,6 +252,9 @@
 	u16 byte_cnt;		/* buffer byte count			*/
 	u32 buf_ptr;		/* pointer to buffer for this descriptor*/
 	u32 next_desc_ptr;	/* Pointer to next descriptor		*/
+	u32 cookie;
+	u32 cookie_size;
+	u32 pad[2];
 };
 #else
 #error One of __BIG_ENDIAN or __LITTLE_ENDIAN must be defined
@@ -240,6 +265,11 @@
 
 /* RX & TX descriptor status */
 #define ERROR_SUMMARY			0x00000001
+#define ERROR_CODE_RX_CRC		(0x0 << 1)
+#define ERROR_CODE_RX_OVERRUN		(0x1 << 1)
+#define ERROR_CODE_RX_MAX_LENGTH	(0x2 << 1)
+#define ERROR_CODE_RX_RESOURCE		(0x3 << 1)
+#define ERROR_CODE_MASK			(0x3 << 1)
 
 /* RX descriptor status */
 #define LAYER_4_CHECKSUM_OK		0x40000000
@@ -251,6 +281,7 @@
 #define RX_PKT_IS_ETHERNETV2		0x00800000
 #define RX_PKT_LAYER4_TYPE_MASK		0x00600000
 #define RX_PKT_LAYER4_TYPE_TCP_IPV4	0x00000000
+#define RX_PKT_LAYER4_TYPE_UDP_IPV4	0x00200000
 #define RX_PKT_IS_VLAN_TAGGED		0x00080000
 
 /* TX descriptor command */
@@ -287,6 +318,7 @@
 	int extended_rx_coal_limit;
 	int tx_bw_control;
 	int tx_csum_limit;
+	int unit;
 	struct clk *clk;
 };
 
@@ -297,6 +329,10 @@
 static int mv643xx_eth_open(struct net_device *dev);
 static int mv643xx_eth_stop(struct net_device *dev);
 
+static int mii_bus_read(struct net_device *dev, int mii_id, int regnum);
+static void mii_bus_write(struct net_device *dev, int mii_id, int regnum,
+			  int value);
+
 
 /* per-port *****************************************************************/
 struct mib_counters {
@@ -333,23 +369,29 @@
 	/* Non MIB hardware counters */
 	u32 rx_discard;
 	u32 rx_overrun;
+	/* Non MIB software counters */
+	u32 rx_packets_q[8];
+	u32 tx_packets_q[8];
 };
 
 struct rx_queue {
 	int index;
 
-	int rx_ring_size;
-
-	int rx_desc_count;
-	int rx_curr_desc;
-	int rx_used_desc;
+	unsigned int rx_ring_size;
+	unsigned int rx_curr_desc;
+	unsigned int rx_packets;
 
 	struct rx_desc *rx_desc_area;
 	dma_addr_t rx_desc_dma;
 	int rx_desc_area_size;
-	struct sk_buff **rx_skb;
 };
 
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+#define NAPI_TX_OFFSET	1
+#else
+#define NAPI_TX_OFFSET	0
+#endif
+
 struct tx_queue {
 	int index;
 
@@ -394,14 +436,13 @@
 
 	struct napi_struct napi;
 	u32 int_mask;
-	u8 oom;
 	u8 work_link;
 	u8 work_tx;
 	u8 work_tx_end;
 	u8 work_rx;
-	u8 work_rx_refill;
 
-	int skb_size;
+	unsigned int pkt_size;
+	unsigned int frag_size;
 
 	/*
 	 * RX state.
@@ -410,7 +451,6 @@
 	unsigned long rx_desc_sram_addr;
 	int rx_desc_sram_size;
 	int rxq_count;
-	struct timer_list rx_oom;
 	struct rx_queue rxq[8];
 
 	/*
@@ -427,8 +467,19 @@
 	 */
 	struct clk *clk;
 	unsigned int t_clk;
+
+	/*
+	 * mii bus for MII ioctls & low level early switch config.
+	 */
+	struct mii_bus *mii_bus;
+
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	struct tx_queue *ff_txq;
+	struct notifier_block ff_notifier;
+#endif
 };
 
+static struct mv643xx_eth_private *mp_by_unit[4];
 
 /* port register accessors **************************************************/
 static inline u32 rdl(struct mv643xx_eth_private *mp, int offset)
@@ -508,7 +559,12 @@
 static void txq_maybe_wake(struct tx_queue *txq)
 {
 	struct mv643xx_eth_private *mp = txq_to_mp(txq);
-	struct netdev_queue *nq = netdev_get_tx_queue(mp->dev, txq->index);
+	struct netdev_queue *nq;
+
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	WARN_ON(txq->index == 0);
+#endif
+	nq = netdev_get_tx_queue(mp->dev, txq->index - NAPI_TX_OFFSET);
 
 	if (netif_tx_queue_stopped(nq)) {
 		__netif_tx_lock(nq, smp_processor_id());
@@ -518,77 +574,1899 @@
 	}
 }
 
-static int rxq_process(struct rx_queue *rxq, int budget)
+static void *mv643xx_eth_frag_alloc(const struct mv643xx_eth_private *mp)
 {
-	struct mv643xx_eth_private *mp = rxq_to_mp(rxq);
-	struct net_device_stats *stats = &mp->dev->stats;
-	int rx;
+	if (likely(mp->frag_size <= PAGE_SIZE))
+		return napi_alloc_frag(mp->frag_size);
+	else
+		return kmalloc(mp->frag_size, GFP_ATOMIC);
+}
 
-	rx = 0;
-	while (rx < budget && rxq->rx_desc_count) {
-		struct rx_desc *rx_desc;
-		unsigned int cmd_sts;
-		struct sk_buff *skb;
-		u16 byte_cnt;
+static void mv643xx_eth_frag_free(const struct mv643xx_eth_private *mp,
+				  void *data)
+{
+	if (likely(mp->frag_size <= PAGE_SIZE))
+		skb_free_frag(data);
+	else
+		kfree(data);
+}
 
-		rx_desc = &rxq->rx_desc_area[rxq->rx_curr_desc];
+static inline bool pkt_is_ipv4(u32 cmd_sts)
+{
+	return (cmd_sts & RX_PKT_IS_IPV4) == RX_PKT_IS_IPV4;
+}
 
-		cmd_sts = rx_desc->cmd_sts;
-		if (cmd_sts & BUFFER_OWNED_BY_DMA)
-			break;
-		rmb();
+static inline bool pkt_is_vlan(u32 cmd_sts)
+{
+	return (cmd_sts & RX_PKT_IS_VLAN_TAGGED) == RX_PKT_IS_VLAN_TAGGED;
+}
 
-		skb = rxq->rx_skb[rxq->rx_curr_desc];
-		rxq->rx_skb[rxq->rx_curr_desc] = NULL;
+static inline bool pkt_is_tcp4(u32 cmd_sts)
+{
+	return (cmd_sts & RX_PKT_LAYER4_TYPE_MASK) ==
+		RX_PKT_LAYER4_TYPE_TCP_IPV4;
+}
 
-		rxq->rx_curr_desc++;
-		if (rxq->rx_curr_desc == rxq->rx_ring_size)
-			rxq->rx_curr_desc = 0;
+static inline bool pkt_is_udp4(u32 cmd_sts)
+{
+	return (cmd_sts & RX_PKT_LAYER4_TYPE_MASK) ==
+		RX_PKT_LAYER4_TYPE_UDP_IPV4;
+}
 
-		dma_unmap_single(mp->dev->dev.parent, rx_desc->buf_ptr,
-				 rx_desc->buf_size, DMA_FROM_DEVICE);
-		rxq->rx_desc_count--;
-		rx++;
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
 
-		mp->work_rx_refill |= 1 << rxq->index;
+static bool ff_enabled;
+static unsigned int ff_mode;
+
+static bool ff_tx_queue_can_reclaim(struct tx_queue *txq)
+{
+	struct tx_desc *desc;
+	int tx_index;
+
+	if (!txq || !txq->tx_desc_count)
+		return false;
+
+	tx_index = txq->tx_used_desc;
+	desc = &txq->tx_desc_area[tx_index];
+
+	if ((desc->cmd_sts & BUFFER_OWNED_BY_DMA))
+		return false;
+
+	return true;
+}
 
-		byte_cnt = rx_desc->byte_cnt;
 
 		/*
-		 * Update statistics.
+ * size on which we invalidate data when we reclaim fast-forwarded
+ * buffer
 		 *
-		 * Note that the descriptor byte count includes 2 dummy
-		 * bytes automatically inserted by the hardware at the
-		 * start of the packet (which we don't count), and a 4
-		 * byte CRC at the end of the packet (which we do count).
+ * worst case read lookup by rx path from RX_OFFSET is (VLAN + ip6 +
+ * iph + tcphdr)
 		 */
-		stats->rx_packets++;
-		stats->rx_bytes += byte_cnt - 2;
+#define FF_MAP_SIZE	(sizeof (struct vlan_ethhdr) + \
+			 sizeof (struct ipv6hdr) + \
+			 sizeof (struct iphdr) + \
+			 sizeof (struct tcphdr))
+
+static void *ff_tx_queue_frag_reclaim(struct mv643xx_eth_private *mp,
+				      unsigned int needed_frag_size)
+{
+	struct tx_queue *txq = mp->ff_txq;
+	struct tx_desc *desc;
+	void *frag;
+	unsigned int frag_size;
+	int tx_index;
+
+	if (!txq || !txq->tx_desc_count)
+		return NULL;
+
+	tx_index = txq->tx_used_desc;
+	desc = &txq->tx_desc_area[tx_index];
+
+	if ((desc->cmd_sts & BUFFER_OWNED_BY_DMA))
+		return NULL;
+
+	txq->tx_used_desc = tx_index + 1;
+	if (txq->tx_used_desc == txq->tx_ring_size)
+		txq->tx_used_desc = 0;
+
+	txq->tx_desc_count--;
+
+	frag = (void *)desc->cookie;
+	frag_size = desc->cookie_size;
+
+	if (frag_size != needed_frag_size) {
+		skb_free_frag(frag);
+		return NULL;
+	}
+
+	return frag;
+}
+#endif
+
+static int rx_desc_refill(struct mv643xx_eth_private *mp,
+			  struct rx_desc *rx_desc, bool unmap)
+{
+	unsigned int map_size = mp->pkt_size;
+	void *frag;
+
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	if (ff_enabled) {
+		struct mv643xx_eth_private *omp;
 
 		/*
-		 * In case we received a packet without first / last bits
-		 * on, or the error summary bit is set, the packet needs
-		 * to be dropped.
+		 * try to reclaim from "opposite" fast forward dedicated tx
+		 * queue
 		 */
-		if ((cmd_sts & (RX_FIRST_DESC | RX_LAST_DESC | ERROR_SUMMARY))
-			!= (RX_FIRST_DESC | RX_LAST_DESC))
-			goto err;
+		if (ff_mode == 1)
+			omp = mp_by_unit[1 - mp->shared->unit];
+		else
+			omp = mp;
+
+		if (omp)
+			frag = ff_tx_queue_frag_reclaim(omp, mp->pkt_size);
+		else
+			frag = NULL;
+
+		if (!frag)
+			frag = mv643xx_eth_frag_alloc(mp);
+		else
+			map_size = FF_MAP_SIZE;
+	} else
+#endif
+		frag = mv643xx_eth_frag_alloc(mp);
+
+	if (!frag)
+		return -ENOMEM;
+
+	if (unmap)
+		dma_unmap_single(mp->dev->dev.parent, rx_desc->buf_ptr,
+				 mp->pkt_size, DMA_FROM_DEVICE);
+
+	rx_desc->buf_ptr = dma_map_single(mp->dev->dev.parent,
+					  frag + RX_OFFSET,
+					  map_size,
+					  DMA_FROM_DEVICE);
+	rx_desc->buf_size = mp->pkt_size;
+	rx_desc->cookie = (u32)frag;
+	wmb();
+	rx_desc->cmd_sts = BUFFER_OWNED_BY_DMA | RX_ENABLE_INTERRUPT;
+	wmb();
+	return 0;
+}
+
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+
+static struct {
+	struct net_device	*wan_dev;
+	struct net_device	*lan_dev;
+	unsigned long		jiffies;
+
+	struct net_device	*tun_dev;
+	u8			tun_ready:1;
+	u16			tun_mtu;
+
+	/* sit parameters */
+	union ff_tun_params {
+		struct {
+			u32		src;
+			u32		s6rd_prefix;
+			u32		s6rd_pmask;
+			u8		s6rd_plen;
+		} sit;
+
+		struct {
+			/* map parameters */
+			u32		ipv4_prefix;
+			u32		ipv4_pmask;
+			u8		ipv4_plen;
+			u8		ipv6_plen;
+			struct in6_addr	src;
+			struct in6_addr	br;
+
+			u64		ipv6_prefix;
+			u32		ea_addr_mask;
+			u16		ea_port_mask;
+			u8		psid_len;
+			u8		ea_lshift;
+		} map;
+	} u;
+
+	char			tun_dev_name[IFNAMSIZ];
+} ff;
+
+static LIST_HEAD(ff_devs);
+
+struct ff_dev {
+	const char		*desc;
+	unsigned int		unit;
+	bool			bridge_member;
+	unsigned int		vlan;
+	struct net_device	**pvirt_dev;
+
+	bool			active;
+	struct net_bridge_port	*br_port;
+	bool			dev_up;
+	struct list_head	next;
+};
+
+static inline bool is_bridge_dev(struct net_device *dev)
+{
+        return dev->priv_flags & IFF_EBRIDGE;
+}
+
+static u32 gen_netmask(u8 len)
+{
+	return htonl(~((1 << (32 - len)) - 1));
+}
+
+static void __ff_tun_set_params(bool ready,
+				unsigned int mtu,
+				const union ff_tun_params *tp)
+{
+	if (!ready) {
+		if (!ff.tun_ready)
+			return;
+
+		printk(KERN_DEBUG "ff: tunnel now NOT ready\n");
+		ff.tun_ready = 0;
+		return;
+	}
+
+	if (ff.tun_ready) {
+		if (ff.tun_mtu == mtu && !memcmp(tp, &ff.u, sizeof (*tp)))
+			return;
+	}
+
+	ff.tun_mtu = mtu;
+	memcpy(&ff.u, tp, sizeof (*tp));
+
+	if (!ff.tun_ready)
+		printk(KERN_DEBUG "ff: tunnel now ready\n");
+	else
+		printk(KERN_DEBUG "ff: tunnel params updated\n");
+
+	ff.tun_ready = true;
+}
+
+static void __ff_tun_read_params(void)
+{
+	union ff_tun_params tp;
+
+	if (!ff.tun_dev)
+		return;
+
+	if (!ff.wan_dev) {
+		__ff_tun_set_params(false, 0, NULL);
+		return;
+	}
+
+	memset(&tp, 0, sizeof (tp));
+
+	if (ff.tun_dev->type == ARPHRD_SIT) {
+		const struct ip_tunnel *tun = netdev_priv(ff.tun_dev);
+		const struct ip_tunnel_6rd_parm *ip6rd = &tun->ip6rd;
+
+		if (!ip6rd->prefixlen || ip6rd->prefixlen > 32) {
+			printk(KERN_DEBUG "ff: unsupported 6rd plen\n");
+			__ff_tun_set_params(false, 0, NULL);
+			return;
+		}
+
+		if (ff.tun_dev->mtu + sizeof (struct iphdr) >
+		    ff.wan_dev->mtu) {
+			printk(KERN_DEBUG "ff: WAN mtu too "
+			       "small for tunnel (%u => %u)\n",
+			       ff.tun_dev->mtu, ff.wan_dev->mtu);
+			__ff_tun_set_params(false, 0, NULL);
+			return;
+		}
+
+		tp.sit.src = tun->parms.iph.saddr;
+		tp.sit.s6rd_prefix = ip6rd->prefix.s6_addr32[0];
+		tp.sit.s6rd_pmask = gen_netmask(ip6rd->prefixlen);
+		tp.sit.s6rd_plen = ip6rd->prefixlen;
+		__ff_tun_set_params(true, ff.tun_dev->mtu, &tp);
+		return;
+	}
+
+	if (ff.tun_dev->type == ARPHRD_TUNNEL6) {
+		const struct ip6_tnl *t = netdev_priv(ff.tun_dev);
+		const struct __ip6_tnl_parm *prm = &t->parms;
+		const struct __ip6_tnl_fmr *fmr;
+
+		if (ff.tun_dev->mtu + sizeof (struct ipv6hdr) >
+		    ff.wan_dev->mtu) {
+			printk(KERN_DEBUG "ff: WAN mtu too "
+			       "small for tunnel (%u => %u)\n",
+			       ff.tun_dev->mtu, ff.wan_dev->mtu);
+			__ff_tun_set_params(false, 0, NULL);
+			return;
+		}
+
+		tp.map.src = prm->laddr;
+		tp.map.br = prm->raddr;
+
+		fmr = prm->fmrs;
+		if (!fmr) {
+			tp.map.ipv4_prefix = 0;
+			__ff_tun_set_params(true, ff.tun_dev->mtu, &tp);
+			return;
+		}
+
+		if (fmr->ip6_prefix_len < 32 ||
+		    (fmr->ip6_prefix_len + 32 - fmr->ip4_prefix_len > 64)) {
+			printk(KERN_DEBUG "ff: unsupp MAP-E: eabits "
+			       "span 32 bits\n");
+			__ff_tun_set_params(false, 0, NULL);
+			return;
+		}
+
+		if (fmr->offset) {
+			printk(KERN_DEBUG "ff: unsupp MAP-E: non zero "
+			       "PSID offset\n");
+			__ff_tun_set_params(false, 0, NULL);
+			return;
+		}
+
+		tp.map.ipv4_prefix = fmr->ip4_prefix.s_addr;
+		tp.map.ipv4_pmask = gen_netmask(fmr->ip4_prefix_len);
+		tp.map.ipv4_plen = fmr->ip4_prefix_len;
+		tp.map.ipv6_plen = fmr->ip6_prefix_len;
+		memcpy(&tp.map.ipv6_prefix, &fmr->ip6_prefix, 8);
+
+		tp.map.ea_addr_mask = ~gen_netmask(fmr->ip4_prefix_len);
+		if (fmr->ea_len <= 32 - fmr->ip4_prefix_len) {
+			/* v4 prefix or full IP */
+			u32 addr_bits;
+
+			addr_bits = fmr->ip4_prefix_len + fmr->ea_len;
+			if (addr_bits != 32)
+				tp.map.ea_addr_mask &= gen_netmask(addr_bits);
+			tp.map.psid_len = 0;
+		} else {
+			u8 psid_len;
+
+			psid_len = fmr->ea_len - (32 - fmr->ip4_prefix_len);
+			tp.map.psid_len = psid_len;
+			tp.map.ea_port_mask = gen_netmask(psid_len);
+		}
+
+		tp.map.ea_lshift = 32 - (fmr->ip6_prefix_len - 32) -
+			fmr->ea_len;
+
+		__ff_tun_set_params(true, ff.tun_dev->mtu, &tp);
+		return;
+	}
+}
+
+static void ff_tun_capture(void)
+{
+	struct net_device *dev;
+
+	local_bh_disable();
+	if (ff.tun_dev) {
+		local_bh_enable();
+		printk(KERN_ERR "ff: error: tun already registered\n");
+		return;
+	}
+
+	dev = dev_get_by_name(&init_net, ff.tun_dev_name);
+	if (!dev) {
+		local_bh_enable();
+		return;
+	}
+
+	if (dev->type != ARPHRD_SIT && dev->type != ARPHRD_TUNNEL6) {
+		local_bh_enable();
+		return;
+	}
+
+	if (!(dev->flags & IFF_UP)) {
+		dev_put(ff.tun_dev);
+		local_bh_enable();
+		return;
+	}
+
+	ff.tun_dev = dev;
+	__ff_tun_read_params();
+	local_bh_enable();
+	printk(KERN_INFO "ff: tun dev grabbed\n");
+}
+
+static void ff_tun_release(void)
+{
+	local_bh_disable();
+	dev_put(ff.tun_dev);
+	ff.tun_dev = NULL;
+	local_bh_enable();
+	printk(KERN_INFO "ff: tun dev released\n");
+}
+
+static int ff_device_event(struct notifier_block *this,
+			   unsigned long event, void *ptr)
+{
+	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+	struct mv643xx_eth_private *mp;
+	struct ff_dev *ff_dev;
+
+	if (!net_eq(dev_net(dev), &init_net))
+		return 0;
+
+	if (!strcmp(dev->name, ff.tun_dev_name)) {
+		local_bh_disable();
+
+		switch (event) {
+		case NETDEV_UP:
+			if (!ff.tun_dev)
+				ff_tun_capture();
+			break;
+
+		case NETDEV_CHANGE:
+		case NETDEV_CHANGEMTU:
+			if (ff.tun_dev == dev)
+				__ff_tun_read_params();
+			break;
+
+		case NETDEV_GOING_DOWN:
+		case NETDEV_DOWN:
+		case NETDEV_UNREGISTER:
+			if (ff.tun_dev == dev)
+				ff_tun_release();
+			break;
+		}
+
+		local_bh_enable();
+		return 0;
+	}
+
+	list_for_each_entry(ff_dev, &ff_devs, next) {
+		mp = container_of(this, typeof(*mp), ff_notifier);
+		if (mp->shared->unit != ff_dev->unit)
+			continue;
+
+		if (ff_dev->vlan) {
+			if (!is_vlan_dev(dev))
+				continue;
+
+			switch (event) {
+			case NETDEV_UP:
+				if (vlan_dev_upper_dev(dev) != mp->dev ||
+				    vlan_dev_vlan_id(dev) != ff_dev->vlan)
+					continue;
+
+				if (ff_dev->active)
+					continue;
+
+				dev_hold(dev);
+
+				local_bh_disable();
+				*(ff_dev->pvirt_dev) = dev;
+
+				if (ff_dev->pvirt_dev == &ff.wan_dev)
+					__ff_tun_read_params();
+				local_bh_enable();
+
+				ff_dev->active = true;
+				printk(KERN_INFO "ff: ff_dev %s: active "
+				       "for %s\n", ff_dev->desc,
+				       dev->name);
+				break;
+
+			case NETDEV_GOING_DOWN:
+			case NETDEV_DOWN:
+			case NETDEV_UNREGISTER:
+				if (!ff_dev->active)
+					continue;
+
+				if (vlan_dev_upper_dev(dev) != mp->dev ||
+				    vlan_dev_vlan_id(dev) != ff_dev->vlan)
+					continue;
+
+				local_bh_disable();
+				*(ff_dev->pvirt_dev) = NULL;
+				local_bh_enable();
+				dev_put(dev);
+				ff_dev->active = false;
+
+				printk(KERN_INFO "ff: ff_dev %s: now "
+				       "inactive\n", ff_dev->desc);
+				break;
+
+			default:
+				break;
+			}
+		}
+
+		if (ff_dev->bridge_member) {
+			struct net_bridge *br;
+			bool ok;
+
+			switch (event) {
+			case NETDEV_UP:
+				if (dev == mp->dev)
+					ff_dev->dev_up = true;
+				break;
+
+			case NETDEV_GOING_DOWN:
+			case NETDEV_DOWN:
+			case NETDEV_UNREGISTER:
+				if (dev == mp->dev)
+					ff_dev->dev_up = false;
+				break;
+
+			case NETDEV_CHANGEUPPER:
+				if (dev == mp->dev) {
+					if ((dev->priv_flags &
+					     IFF_BRIDGE_PORT) &&
+					    netdev_master_upper_dev_get(dev))
+						ff_dev->br_port = br_port_get_rcu(dev);
+					else
+						ff_dev->br_port = NULL;
+				}
+				break;
+
+			default:
+				break;
+			}
+
+			ok = false;
+			if (ff_dev->dev_up && ff_dev->br_port) {
+				br = ff_dev->br_port->br;
+				if (br->dev->flags & IFF_UP)
+					ok = true;
+			}
+
+			if (!(ok ^ ff_dev->active))
+				continue;
+
+			if (ok) {
+				dev_hold(br->dev);
+				local_bh_disable();
+				*(ff_dev->pvirt_dev) = br->dev;
+				local_bh_enable();
+				ff_dev->active = true;
+
+				printk(KERN_INFO "ff: ff_dev %s: active "
+				       "for %s\n", ff_dev->desc,
+				       br->dev->name);
+
+
+			} else {
+				dev = *(ff_dev->pvirt_dev);
+				local_bh_disable();
+				*(ff_dev->pvirt_dev) = NULL;
+				local_bh_enable();
+				dev_put(dev);
+				ff_dev->active = false;
+				printk(KERN_INFO "ff: ff_dev %s: "
+				       "now inactive\n", ff_dev->desc);
+			}
+		}
+	}
+
+	return 0;
+}
+
+enum ff_xmit_mode {
+	FF_XMIT_IPV4,
+	FF_XMIT_IPV6,
+	FF_XMIT_IPV6_IN_IPV4,
+	FF_XMIT_IPV4_IN_IPV6,
+};
 
 		/*
-		 * The -4 is for the CRC in the trailer of the
-		 * received packet
+ *
 		 */
-		skb_put(skb, byte_cnt - 2 - 4);
+static bool ff_send(struct tx_queue *txq,
+		    u32 dma_buf_addr,
+		    void *frag,
+		    u32 frag_size,
+		    unsigned int send_len,
+		    unsigned int clean_len,
+		    bool hw_l3_checksum,
+		    bool hw_l4_checksum,
+		    bool is_tcp,
+		    bool is_vlan)
+{
+	struct tx_desc *tx_desc;
+	unsigned int tx_index;
+	u32 cmd_sts;
+
+	if (WARN_ON(txq->tx_desc_count == txq->tx_ring_size))
+		return 1;
+
+	dma_sync_single_for_device(NULL, dma_buf_addr,
+				   clean_len, DMA_TO_DEVICE);
+
+	tx_index = txq->tx_curr_desc++;
+	if (txq->tx_curr_desc == txq->tx_ring_size)
+		txq->tx_curr_desc = 0;
+
+	txq->tx_desc_count++;
+	txq->tx_desc_mapping[tx_index] = DESC_DMA_MAP_SINGLE;
+
+	tx_desc = &txq->tx_desc_area[tx_index];
+	tx_desc->byte_cnt = send_len;
+	tx_desc->buf_ptr = dma_buf_addr;
+	tx_desc->cookie = (u32)frag;
+	tx_desc->cookie_size = (u32)frag_size;
+
+	cmd_sts = TX_FIRST_DESC |
+		TX_LAST_DESC |
+		GEN_CRC |
+		BUFFER_OWNED_BY_DMA |
+		ZERO_PADDING;
+
+	if (hw_l3_checksum) {
+		cmd_sts |= (GEN_IP_V4_CHECKSUM |
+			    (5 << TX_IHL_SHIFT));
+
+		if (is_vlan)
+			cmd_sts |= MAC_HDR_EXTRA_4_BYTES;
+	}
+
+	if (hw_l4_checksum) {
+		cmd_sts |= (GEN_TCP_UDP_CHECKSUM |
+			    GEN_TCP_UDP_CHK_FULL);
+
+		if (!is_tcp)
+			cmd_sts |= UDP_FRAME;
+	}
+
+	tx_desc->cmd_sts = cmd_sts;
+	txq_enable(txq);
+
+	txq->tx_bytes += send_len;
+	txq->tx_packets++;
+
+	return 0;
+}
+
+/*
+ * IP_FFN private data
+ */
+struct ffn_priv {
+	struct in6_addr		tun_dest_ip6;
+	struct dst_entry	*tun_dst;
+};
+
+static void ffn_priv_release(struct ffn_priv *priv)
+{
+	dst_release(priv->tun_dst);
+}
+
+static void ffn_priv_destructor_cb(void *data)
+{
+	struct ffn_priv *priv = (struct ffn_priv *)data;
+	ffn_priv_release(priv);
+}
+
+static struct ffn_priv *ffn_get_ro_priv(struct ffn_lookup_entry *e)
+{
+	if (e->manip.priv_destructor != ffn_priv_destructor_cb)
+		return NULL;
+
+	return (struct ffn_priv *)e->manip.ffn_priv_area;
+}
+
+static struct ffn_priv *ffn_get_rw_priv(struct ffn_lookup_entry *e)
+{
+	BUILD_BUG_ON(sizeof (e->manip.ffn_priv_area) <
+		     sizeof (struct ffn_priv));
+
+	if (e->manip.priv_destructor &&
+	    e->manip.priv_destructor != ffn_priv_destructor_cb)
+		return NULL;
+
+	return (struct ffn_priv *)e->manip.ffn_priv_area;
+}
+
+/*
+ * IPV6_FFN private data
+ */
+struct ffn6_priv {
+	u32			tun_dest_ip;
+	struct dst_entry	*tun_dst;
+};
+
+static void ffn6_priv_release(struct ffn6_priv *priv)
+{
+	dst_release(priv->tun_dst);
+}
+
+static void ffn6_priv_destructor_cb(void *data)
+{
+	struct ffn6_priv *priv = (struct ffn6_priv *)data;
+	ffn6_priv_release(priv);
+}
+
+static struct ffn6_priv *ffn6_get_ro_priv(struct ffn6_lookup_entry *e6)
+{
+	if (e6->manip.priv_destructor != ffn6_priv_destructor_cb)
+		return NULL;
+
+	return (struct ffn6_priv *)e6->manip.ffn_priv_area;
+}
+
+static struct ffn6_priv *ffn6_get_rw_priv(struct ffn6_lookup_entry *e6)
+{
+	BUILD_BUG_ON(sizeof (e6->manip.ffn_priv_area) <
+		     sizeof (struct ffn6_priv));
+
+	if (e6->manip.priv_destructor &&
+	    e6->manip.priv_destructor != ffn6_priv_destructor_cb)
+		return NULL;
+
+	return (struct ffn6_priv *)e6->manip.ffn_priv_area;
+}
+
+/*
+ *
+ */
+static u32 ff_tun_extract_6rd_addr(const struct in6_addr *d)
+{
+	u32 a1, a2;
+
+	a1 = ntohl(d->s6_addr32[0] & ~ff.u.sit.s6rd_pmask);
+	a1 <<= ff.u.sit.s6rd_plen;
+
+	a2 = ntohl(d->s6_addr32[1] & ff.u.sit.s6rd_pmask);
+	a2 >>= (32 - ff.u.sit.s6rd_plen);
+	return htonl(a1 | a2);
+}
+
+/*
+ *
+ */
+static void ff_tun_gen_mape_addr(u32 addr, u16 port, struct in6_addr *dest)
+{
+	u32 eabits;
+	u16 psid;
+
+	eabits = ntohl(addr & ff.u.map.ea_addr_mask) << ff.u.map.psid_len;
+	psid = 0;
+	if (ff.u.map.psid_len) {
+		psid = ntohs(port & ff.u.map.ea_port_mask) >>
+			(16 - ff.u.map.psid_len);
+		eabits |= psid;
+	}
+
+	memcpy(dest, &ff.u.map.ipv6_prefix, 8);
+	dest->s6_addr32[1] |= htonl(eabits << ff.u.map.ea_lshift);
+
+	dest->s6_addr32[2] = htonl(ntohl(addr) >> 16);
+	dest->s6_addr32[3] = htonl((ntohl(addr) << 16) | psid);
+}
+
+/*
+ *
+ */
+static bool ff_forward(struct mv643xx_eth_private *rx_mp,
+		       struct mv643xx_eth_private *tx_mp,
+		       struct net_device *rx_dev,
+		       struct net_device *tx_dev,
+		       unsigned int rx_vlan,
+		       unsigned int tx_vlan,
+		       struct rx_desc *rx_desc,
+		       unsigned int cmd_sts,
+		       void *frag,
+		       size_t offset, size_t eth_len)
+{
+	struct net_device_stats *rx_hw_stats;
+	struct net_device_stats *tx_hw_stats;
+	struct ffn_lookup_entry *e;
+	struct ffn6_lookup_entry *e6;
+	struct tx_queue *txq;
+	struct neighbour *neigh;
+	struct nf_conn *ct;
+	struct ethhdr *eth;
+	enum ff_xmit_mode xmit_mode;
+	u32 buf_addr;
+	unsigned int timeout;
+	void *l3_hdr, *l4_hdr;
+	bool l3_is_ipv4, l4_is_tcp;
+	unsigned int l3_plen;
+	unsigned int clean_len;
+	u32 tun_v4_dest;
+	const struct in6_addr *tun_v6_pdest;
+	u16 proto;
+
+	/* make sure we have headroom for the worst case scenario */
+	BUILD_BUG_ON(CONFIG_NETSKBPAD <
+		     (sizeof (struct ipv6hdr) + VLAN_HLEN));
+
+	if (!tx_mp || !rx_dev || !tx_dev)
+		return false;
+
+	/* hardware skip 2 bytes to align IP header */
+	eth = (struct ethhdr *)((uint8_t *)frag + offset + 2);
+	eth_len -= 2;
+
+	/*
+	 * filter only IPv4 & IPv6 packets
+	 */
+	if (rx_vlan) {
+		struct vlan_ethhdr *vhdr;
+
+		if (!pkt_is_vlan(cmd_sts))
+			return false;
+
+		vhdr = (struct vlan_ethhdr *)eth;
+		if (vhdr->h_vlan_TCI != htons(rx_vlan))
+			return false;
+
+		if (!pkt_is_ipv4(cmd_sts)) {
+			if (vhdr->h_vlan_encapsulated_proto !=
+			    htons(ETH_P_IPV6))
+				return false;
+		}
+
+		l3_hdr = vhdr + 1;
+		l3_plen = eth_len - VLAN_ETH_HLEN;
+	} else {
+		if (pkt_is_vlan(cmd_sts))
+			return false;
+
+		if (!pkt_is_ipv4(cmd_sts)) {
+			if (eth->h_proto != htons(ETH_P_IPV6))
+				return false;
+		}
+
+		l3_hdr = eth + 1;
+		l3_plen = eth_len - ETH_HLEN;
+	}
+
+	/* make sure packet is for our mac address */
+	if (memcmp(eth->h_dest, rx_mp->dev->dev_addr, 6)) {
+		return false;
+	}
+
+	l3_is_ipv4 = pkt_is_ipv4(cmd_sts);
+	if (l3_is_ipv4) {
+		struct iphdr *iph;
+		u16 sport, dport;
+		u8 ip_proto;
+
+handle_ipv4:
+		iph = (struct iphdr *)l3_hdr;
+
+		/* lookup IP ffn entry */
+		if (iph->ihl > 5 || (iph->frag_off & htons(IP_MF | IP_OFFSET)))
+			return false;
+
+		if (iph->ttl <= 1)
+			return false;
+
+		ip_proto = iph->protocol;
+		if (ip_proto == IPPROTO_TCP) {
+			struct tcphdr *tcph;
+
+			if (l3_plen < sizeof (*iph) + sizeof (*tcph))
+				return false;
+
+			tcph = (struct tcphdr *)((u8 *)iph + 20);
+			if (tcph->fin ||
+			    tcph->syn ||
+			    tcph->rst ||
+			    !tcph->ack) {
+				return false;
+			}
+
+			sport = tcph->source;
+			dport = tcph->dest;
+			l4_hdr = tcph;
+			l4_is_tcp = true;
+
+		} else if (ip_proto == IPPROTO_UDP) {
+			struct udphdr *udph;
+
+			if (l3_plen < sizeof (*iph) + sizeof (*udph))
+				return false;
+
+			udph = (struct udphdr *)((u8 *)iph + 20);
+			sport = udph->source;
+			dport = udph->dest;
+			l4_hdr = udph;
+			l4_is_tcp = false;
+
+		} else if (ip_proto == IPPROTO_IPV6) {
+			struct ipv6hdr *ip6hdr;
+			u32 ip6rd_daddr;
+
+			if (!ff.tun_ready)
+				return false;
+
+			/* must be for us */
+			if (iph->daddr != ff.u.sit.src)
+				return false;
+
+			/* check len */
+			if (l3_plen < sizeof (struct iphdr) +
+			    sizeof (struct ipv6hdr))
+				return false;
+
+			ip6hdr = (struct ipv6hdr *)(iph + 1);
+
+			/* must belong to 6rd prefix */
+			if ((ip6hdr->daddr.s6_addr32[0] &
+			     ff.u.sit.s6rd_pmask) != ff.u.sit.s6rd_prefix)
+				return false;
+
+			/* 6rd address */
+			ip6rd_daddr = ff_tun_extract_6rd_addr(&ip6hdr->daddr);
+			if (ip6rd_daddr != ff.u.sit.src)
+				return false;
+
+			/* TODO: should check for spoofing here */
+			l3_hdr = ip6hdr;
+			l3_plen -= 20;
+			l3_is_ipv4 = false;
+			goto handle_ipv6;
+
+		} else
+			return false;
+
+		e = __ffn_get(iph->saddr, iph->daddr,
+			      sport, dport, l4_is_tcp);
+		if (!e)
+			return false;
+
+		if (e->manip.dst->obsolete > 0)
+			return false;
+
+		ct = e->manip.ct;
+
+		/* only fast forward TCP connections in established state */
+		if (l4_is_tcp &&
+		    ct->proto.tcp.state != TCP_CONNTRACK_ESTABLISHED)
+			return false;
+
+		/* find out if the packet is to be sent as-is or
+		 * tunneled */
+		if (ff.tun_dev && e->manip.dst->dev == ff.tun_dev) {
+			struct ffn_priv *ffn_priv;
+			struct dst_entry *v6_dst;
+			struct in6_addr *pdest, *nexthop, dest;
+			struct rt6_info *rt6;
+
+			/* IPv4 tunneled into MAP-E device */
+			if (!ff.tun_ready) {
+				return false;
+			}
+
+			if (l3_plen > ff.tun_mtu)
+				return false;
+
+			/* lookup ipv6 route cache */
+			ffn_priv = ffn_get_ro_priv(e);
+			if (ffn_priv) {
+				if (ffn_priv->tun_dst->obsolete < 0) {
+					/* valid route found */
+					v6_dst = ffn_priv->tun_dst;
+					pdest = &ffn_priv->tun_dest_ip6;
+					goto cached_ipv6_route;
+				}
+
+				ffn_priv_release(ffn_priv);
+				e->manip.priv_destructor = NULL;
+			}
+
+			/* cache miss, compute IPv6 destination */
+			if ((iph->daddr & ff.u.map.ipv4_pmask) ==
+			    ff.u.map.ipv4_prefix) {
+				/* compute dest using FMR */
+				ff_tun_gen_mape_addr(iph->daddr, dport, &dest);
+				pdest = &dest;
+			} else {
+				/* next hop is BR */
+				pdest = &ff.u.map.br;
+			}
+
+			/* v6 route lookup */
+			rt6 = rt6_lookup(&init_net, pdest, NULL, 0, 0);
+			if (!rt6)
+				return false;
+
+			ffn_priv = ffn_get_rw_priv(e);
+			if (!ffn_priv)
+				return false;
+
+			/* cache this inside FFN private area */
+			ffn_priv->tun_dst = (struct dst_entry *)rt6;
+			memcpy(&ffn_priv->tun_dest_ip6, pdest, 16);
+			e->manip.priv_destructor = ffn_priv_destructor_cb;
+
+			v6_dst = (struct dst_entry *)rt6;
+
+cached_ipv6_route:
+			if (v6_dst->dev != tx_dev) {
+				return false;
+			}
+
+			/* is the neighboor ready ? */
+			rt6 = (struct rt6_info *)v6_dst;
+			nexthop = rt6_nexthop(rt6, pdest);
+			if (!nexthop) {
+				return false;
+			}
+
+			neigh = __ipv6_neigh_lookup_noref(tx_dev, nexthop);
+			if (!neigh) {
+				return false;
+			}
+
+			xmit_mode = FF_XMIT_IPV4_IN_IPV6;
+			tun_v6_pdest = &ffn_priv->tun_dest_ip6;
+
+		} else if (e->manip.dst->dev == tx_dev) {
+			const struct rtable *rt;
+			u32 nexthop;
+
+			/* is the neighboor ready ? */
+			rt = (const struct rtable *)e->manip.dst;
+
+			nexthop = (__force u32)rt_nexthop(rt, e->manip.new_dip);
+			neigh = __ipv4_neigh_lookup_noref(tx_dev, nexthop);
+			if (!neigh) {
+				return false;
+			}
+
+			xmit_mode = FF_XMIT_IPV4;
+		} else
+			return false;
+
+	} else {
+		struct ipv6hdr *ip6hdr;
+		u16 sport, dport;
+		u8 ip_proto;
+
+handle_ipv6:
+		ip6hdr = (struct ipv6hdr *)l3_hdr;
+
+		if (ip6hdr->hop_limit <= 1 || !ip6hdr->payload_len)
+			return false;
+
+		if (ntohs(ip6hdr->payload_len) > l3_plen)
+			return false;
+
+		ip_proto = ip6hdr->nexthdr;
+
+		if (ip_proto == IPPROTO_TCP) {
+			struct tcphdr *tcph;
+
+			if (l3_plen < sizeof (*ip6hdr) + sizeof (*tcph))
+				return false;
+
+			tcph = (struct tcphdr *)((u8 *)ip6hdr +
+						 sizeof (*ip6hdr));
+
+			if (tcph->fin ||
+			    tcph->syn ||
+			    tcph->rst ||
+			    !tcph->ack) {
+				return false;
+			}
+
+			sport = tcph->source;
+			dport = tcph->dest;
+			l4_hdr = tcph;
+			l4_is_tcp = true;
+
+		} else if (ip_proto == IPPROTO_UDP) {
+			struct udphdr *udph;
+
+			if (l3_plen < sizeof (*ip6hdr) + sizeof (*udph))
+				return false;
+
+			udph = (struct udphdr *)((u8 *)ip6hdr +
+						 sizeof (*ip6hdr));
+			sport = udph->source;
+			dport = udph->dest;
+			l4_hdr = udph;
+			l4_is_tcp = false;
+
+		} else if (ip_proto == IPPROTO_IPIP) {
+			struct iphdr *iph;
+
+			if (!ff.tun_ready)
+				return false;
+
+			/* must be for us */
+			if (memcmp(&ip6hdr->daddr, &ff.u.map.src, 16))
+				return false;
+
+			/* check len */
+			if (l3_plen < sizeof (struct iphdr) +
+			    sizeof (struct ipv6hdr))
+				return false;
+
+			iph = (struct iphdr *)(ip6hdr + 1);
+
+			/* does it come from BR ? */
+			if (memcmp(&ip6hdr->saddr, &ff.u.map.br, 16)) {
+				struct in6_addr exp_src_addr;
+
+				/* no, check FMR for spoofing */
+				if (!ff.u.map.ipv4_prefix)
+					return false;
+
+				/* check up to PSID to reduce lookup
+				 * depth */
+				ff_tun_gen_mape_addr(iph->saddr, 0,
+						     &exp_src_addr);
+				if (!ipv6_prefix_equal(&ip6hdr->saddr,
+						       &exp_src_addr,
+						       ff.u.map.ipv6_plen +
+						       ff.u.map.ipv4_plen))
+					return false;
+			}
+
+			l3_hdr = iph;
+			l3_plen -= sizeof (*ip6hdr);
+			l3_is_ipv4 = true;
+			goto handle_ipv4;
+
+		} else
+			return false;
+
+		e6 = __ffn6_get(ip6hdr->saddr.s6_addr32,
+				ip6hdr->daddr.s6_addr32,
+				sport, dport, l4_is_tcp);
+
+		if (!e6) {
+			return false;
+		}
+
+		if (e6->manip.dst->obsolete > 0) {
+			return false;
+		}
+
+		ct = e6->manip.ct;
+
+		/* only fast forward TCP connections in established state */
+		if (l4_is_tcp &&
+		    ct->proto.tcp.state != TCP_CONNTRACK_ESTABLISHED) {
+			return false;
+		}
+
+		/* find out if the packet is to be sent as-is or
+		 * tunneled */
+		if (ff.tun_dev && e6->manip.dst->dev == ff.tun_dev) {
+			struct ffn6_priv *ffn6_priv;
+			struct dst_entry *v4_dst;
+			struct flowi4 fl4;
+			struct rtable *rt;
+			u32 dest, nexthop;
+
+			/* IPv6 tunneled into SIT device using 6rd */
+			if (!ff.tun_ready) {
+				return false;
+			}
+
+			if (l3_plen > ff.tun_mtu)
+				return false;
+
+			/* lookup ipv4 route cache */
+			ffn6_priv = ffn6_get_ro_priv(e6);
+			if (ffn6_priv) {
+				if (!ffn6_priv->tun_dst->obsolete) {
+					/* valid route found */
+					v4_dst = ffn6_priv->tun_dst;
+					dest = ffn6_priv->tun_dest_ip;
+					goto cached_ipv4_route;
+				}
+
+				ffn6_priv_release(ffn6_priv);
+				e6->manip.priv_destructor = NULL;
+			}
+
+			/* cache miss, compute IPv4 destination */
+			if ((ip6hdr->daddr.s6_addr32[0] &
+			     ff.u.sit.s6rd_pmask) == ff.u.sit.s6rd_prefix) {
+				/* next hop via prefix */
+				dest = ff_tun_extract_6rd_addr(&ip6hdr->daddr);
+			} else {
+				struct in6_addr *nh6;
+				struct rt6_info *rt6;
+
+				/* next hop via route */
+				rt6 = (struct rt6_info *)e6->manip.dst;
+				nh6 = rt6_nexthop(rt6,
+				      (struct in6_addr *)e6->manip.new_dip);
+				if (!nh6) {
+					return false;
+				}
+
+				/* should be a v4 mapped */
+				if (nh6->s6_addr32[0] != 0 ||
+				    nh6->s6_addr32[1] != 0 ||
+				    nh6->s6_addr32[2] != 0) {
+					return false;
+				}
+
+				dest = nh6->s6_addr32[3];
+			}
+
+			/* v4 route lookup */
+			rt = ip_route_output_ports(&init_net, &fl4, NULL,
+						   dest, ff.u.sit.src,
+						   0, 0,
+						   IPPROTO_IPV6, 0,
+						   0);
+			if (IS_ERR(rt) ||
+			    rt->rt_type != RTN_UNICAST)
+				return false;
+
+			ffn6_priv = ffn6_get_rw_priv(e6);
+			if (!ffn6_priv)
+				return false;
+
+			/* cache this inside FFN private area */
+			ffn6_priv->tun_dst = (struct dst_entry *)rt;
+			ffn6_priv->tun_dest_ip = dest;
+			e6->manip.priv_destructor = ffn6_priv_destructor_cb;
+
+			v4_dst = (struct dst_entry *)rt;
+
+cached_ipv4_route:
+			if (v4_dst->dev != tx_dev) {
+				return false;
+			}
+
+			/* is the neighboor ready ? */
+			rt = (struct rtable *)v4_dst;
+			nexthop = (__force u32)rt_nexthop(rt, dest);
+			neigh = __ipv4_neigh_lookup_noref(tx_dev, nexthop);
+			if (!neigh) {
+				return false;
+			}
+
+			tun_v4_dest = dest;
+			xmit_mode = FF_XMIT_IPV6_IN_IPV4;
+
+		} else if (e6->manip.dst->dev == tx_dev) {
+			struct in6_addr *nexthop;
+			struct rt6_info *rt6;
+
+			/* is the neighboor ready ? */
+			rt6 = (struct rt6_info *)e6->manip.dst;
+
+			nexthop = rt6_nexthop(rt6,
+				      (struct in6_addr *)e6->manip.new_dip);
+			if (!nexthop)
+				return false;
+
+			neigh = __ipv6_neigh_lookup_noref(tx_dev, nexthop);
+			if (!neigh) {
+				return false;
+			}
+
+			xmit_mode = FF_XMIT_IPV6;
+		} else
+			return false;
+	}
+
+	if (!(neigh->nud_state & NUD_VALID)) {
+		return false;
+	}
+
+	/* is destination on correct tx bridge port ? */
+	if (is_bridge_dev(tx_dev)) {
+		struct net_bridge_port *p = br_port_get_rcu(tx_mp->dev);
+		struct net_bridge_fdb_entry *fdb;
+
+		fdb = br_fdb_find(p->br, neigh->ha, 0);
+		if (!fdb)
+			return false;
+
+		if (fdb->dst != p)
+			return false;
+	}
+
+	txq = tx_mp->ff_txq;
+	if (is_bridge_dev(rx_dev)) {
+		struct net_bridge *br = netdev_priv(rx_dev);
+		struct net_bridge_port *p;
+		struct pcpu_sw_netstats *stats;
+
+		/* if packet comes from a bridge, make sure we are
+		 * allowed to ingress it */
+		p = br_port_get_rcu(rx_mp->dev);
+		if (p->state != BR_STATE_FORWARDING) {
+			return false;
+		}
+
+		/* refresh FDB entry for this source */
+		if (!br_fdb_update_only(br, p, eth->h_source)) {
+			return false;
+		}
+
+		stats = this_cpu_ptr(br->stats);
+		stats->rx_packets++;
+		stats->rx_bytes += eth_len;
+
+	} else if (rx_vlan) {
+		struct vlan_dev_priv *vlan = vlan_dev_priv(rx_dev);
+		struct vlan_pcpu_stats *stats;
+		stats = this_cpu_ptr(vlan->vlan_pcpu_stats);
+		stats->rx_packets++;
+		stats->rx_bytes += eth_len;
+	} else {
+		rx_dev->stats.rx_packets++;
+		rx_dev->stats.rx_bytes += eth_len;
+	}
+
+	rx_hw_stats = &rx_mp->dev->stats;
+	rx_hw_stats->rx_bytes += eth_len;
+	rx_hw_stats->rx_packets++;
+
+	/* do we have room in the tx queue ? */
+	if (txq->tx_desc_count == txq->tx_ring_size &&
+	    !ff_tx_queue_can_reclaim(txq)) {
+		/* just rearm descriptor and fake success */
+		rx_desc->cmd_sts = BUFFER_OWNED_BY_DMA | TX_ENABLE_INTERRUPT;
+		txq_enable(txq);
+		return true;
+	}
+
+	/* remember RX desc hw address before we reload it and point
+	 * if back to frag hw address */
+	buf_addr = rx_desc->buf_ptr;
+	buf_addr -= offset;
+
+	/* can we allocate a new fragment to replace the descriptor we
+	 * are about to use ? */
+	if (rx_desc_refill(rx_mp, rx_desc, true)) {
+		/* just rearm descriptor and fake success */
+		rx_desc->cmd_sts = BUFFER_OWNED_BY_DMA | RX_ENABLE_INTERRUPT;
+		return true;
+	}
+
+	if (l4_is_tcp) {
+		/* don't try to track window anymore on this
+		 * connection */
+		ct->proto.tcp.no_window_track = 1;
+	}
+
+	/* alter l3 & l4 content if needed */
+	if (l3_is_ipv4) {
+		struct iphdr *iph = (struct iphdr *)l3_hdr;
+
+		if (e->manip.alter) {
+			if (l4_is_tcp) {
+				struct tcphdr *tcph = (struct tcphdr *)l4_hdr;
+				tcph->source = e->manip.new_sport;
+				tcph->dest = e->manip.new_dport;
+				tcph->check = csum16_sub(tcph->check,
+						 e->manip.l4_adjustment);
+			} else {
+				struct udphdr *udph = (struct udphdr *)l4_hdr;
+				udph->source = e->manip.new_sport;
+				udph->dest = e->manip.new_dport;
+				if (udph->check) {
+					u16 tcheck;
+
+					tcheck = csum16_sub(udph->check,
+						    e->manip.l4_adjustment);
+					udph->check = tcheck ? tcheck : 0xffff;
+				}
+			}
+
+			iph->saddr = e->manip.new_sip;
+			iph->daddr = e->manip.new_dip;
+		}
+
+		iph->ttl--;
+		iph->check = csum16_sub(iph->check,
+					e->manip.ip_adjustment);
+
+	} else {
+		struct ipv6hdr *ip6hdr = (struct ipv6hdr *)l3_hdr;
+
+		if (e6->manip.alter) {
+			if (l4_is_tcp) {
+				struct tcphdr *tcph = (struct tcphdr *)l4_hdr;
+				tcph->source = e6->manip.new_sport;
+				tcph->dest = e6->manip.new_dport;
+				tcph->check = csum16_sub(tcph->check,
+							 e6->manip.adjustment);
+			} else {
+				struct udphdr *udph = (struct udphdr *)l4_hdr;
+				udph->source = e6->manip.new_sport;
+				udph->dest = e6->manip.new_dport;
+
+				if (udph->check) {
+					u16 tcheck;
+
+					tcheck = csum16_sub(udph->check,
+						    e6->manip.adjustment);
+					udph->check = tcheck ? tcheck : 0xffff;
+				}
+			}
+
+			memcpy(ip6hdr->saddr.s6_addr32, e6->manip.new_sip, 16);
+			memcpy(ip6hdr->daddr.s6_addr32, e6->manip.new_dip, 16);
+		}
+
+		ip6hdr->hop_limit--;
+	}
+
+	/* packet is ready to xmit */
+	switch (xmit_mode) {
+	case FF_XMIT_IPV4:
+		clean_len = sizeof (struct iphdr);
+		proto = ETH_P_IP;
+		break;
+
+	case FF_XMIT_IPV6:
+		clean_len = sizeof (struct ipv6hdr);
+		proto = ETH_P_IPV6;
+		break;
+
+	case FF_XMIT_IPV6_IN_IPV4:
+	{
+		struct iphdr *tun_hdr;
+		/* prepend IPv4 */
+		tun_hdr = (struct iphdr *)((u8 *)l3_hdr - sizeof (*tun_hdr));
+		tun_hdr->ihl = 5;
+		tun_hdr->version = 4;
+		tun_hdr->tos = 0;
+		tun_hdr->tot_len = htons(l3_plen + sizeof (*tun_hdr));
+		tun_hdr->id = 0;
+		tun_hdr->frag_off = 0;
+		tun_hdr->ttl = 64;
+		tun_hdr->protocol = IPPROTO_IPV6;
+		tun_hdr->saddr = ff.u.sit.src;
+		tun_hdr->daddr = tun_v4_dest;
+
+		l3_hdr = (u8 *)tun_hdr;
+		l3_plen += sizeof (*tun_hdr);
+
+		clean_len = sizeof (struct iphdr) + sizeof (struct ipv6hdr);
+		proto = ETH_P_IP;
+		break;
+	}
+
+	case FF_XMIT_IPV4_IN_IPV6:
+	{
+		struct ipv6hdr *tun_6hdr;
+
+		/* prepend IPv6 */
+		tun_6hdr = (struct ipv6hdr *)((u8 *)l3_hdr - sizeof (*tun_6hdr));
+		tun_6hdr->version = 6;
+		tun_6hdr->priority = 0;
+		memset(tun_6hdr->flow_lbl, 0, sizeof (tun_6hdr->flow_lbl));
+		tun_6hdr->payload_len = htons(l3_plen);
+		tun_6hdr->nexthdr = IPPROTO_IPIP;
+		tun_6hdr->hop_limit = 64;
+		tun_6hdr->saddr = ff.u.map.src;
+		tun_6hdr->daddr = *tun_v6_pdest;
+
+		l3_hdr = (u8 *)tun_6hdr;
+		l3_plen += sizeof (*tun_6hdr);
+
+		clean_len = sizeof (struct ipv6hdr) + sizeof (struct iphdr);
+		proto = ETH_P_IPV6;
+		break;
+	}
+	}
+
+	if (l4_is_tcp)
+		clean_len += sizeof (struct tcphdr);
+	else
+		clean_len += sizeof (struct udphdr);
+
+	/* add ethernet header */
+	if (tx_vlan) {
+		struct vlan_ethhdr *vhdr;
+
+		vhdr = (struct vlan_ethhdr *)((u8 *)l3_hdr - VLAN_ETH_HLEN);
+		memcpy(vhdr->h_dest, neigh->ha, 6);
+		memcpy(vhdr->h_source, rx_mp->dev->dev_addr, 6);
+		vhdr->h_vlan_proto = htons(ETH_P_8021Q);
+		vhdr->h_vlan_TCI = htons(836);
+		vhdr->h_vlan_encapsulated_proto = htons(proto);
+
+		eth = (struct ethhdr *)vhdr;
+		eth_len = l3_plen + VLAN_ETH_HLEN;
+		clean_len += VLAN_ETH_HLEN;
+	} else {
+		eth = (struct ethhdr *)((u8 *)l3_hdr - ETH_HLEN);
+		memcpy(eth->h_dest, neigh->ha, 6);
+		memcpy(eth->h_source, rx_mp->dev->dev_addr, 6);
+		eth->h_proto = htons(proto);
+		eth_len = l3_plen + ETH_HLEN;
+		clean_len += ETH_HLEN;
+	}
+
+	if (ff_send(txq,
+		    buf_addr + (void *)eth - frag,
+		    frag, rx_mp->pkt_size,
+		    eth_len,
+		    clean_len,
+		    (proto == ETH_P_IP),
+		    (xmit_mode == FF_XMIT_IPV4),
+		    l4_is_tcp,
+		    tx_vlan)) {
+		skb_free_frag(frag);
+		return true;
+	}
+
+	if (is_bridge_dev(tx_dev)) {
+		struct net_bridge *br = netdev_priv(tx_dev);
+		struct pcpu_sw_netstats *stats;
+		stats = this_cpu_ptr(br->stats);
+		stats->tx_packets++;
+		stats->tx_bytes += eth_len;
+	} else if (tx_vlan) {
+		struct vlan_dev_priv *vlan = vlan_dev_priv(tx_dev);
+		struct vlan_pcpu_stats *stats;
+		stats = this_cpu_ptr(vlan->vlan_pcpu_stats);
+		stats->tx_packets++;
+		stats->tx_bytes += eth_len;
+	} else {
+		tx_dev->stats.tx_packets++;
+		tx_dev->stats.tx_bytes += eth_len;
+	}
+
+	tx_hw_stats = &tx_mp->dev->stats;
+	tx_hw_stats->tx_bytes += eth_len;
+	tx_hw_stats->tx_packets++;
+
+	/* refresh conntrack */
+	if (l4_is_tcp)
+		timeout = HZ * 3600 * 24 * 5;
+	else
+		timeout = HZ * 180;
+
+	if (ct->timeout.expires - ff.jiffies < timeout - 10 * HZ) {
+		unsigned long newtime = ff.jiffies + timeout;
+		mod_timer_pending(&ct->timeout, newtime);
+	}
+
+	return true;
+}
+
+/*
+ *
+ */
+static bool ff_receive(struct mv643xx_eth_private *mp,
+		       struct rx_desc *rx_desc,
+		       unsigned int cmd_sts,
+		       void *frag,
+		       size_t offset, size_t dlen)
+{
+#ifdef CONFIG_FBXBRIDGE
+	if (mp->dev->fbx_bridge_maybe_port)
+		return false;
+#endif
+
+	if (!ff_enabled)
+		return false;
+
+	/*
+	 * GWv1
+	 */
+	if (ff_mode == 1) {
+		/*
+		 * LAN => WAN
+		 * [eth0 (untagged)] => [br0] => IPV4 => [eth1.836]
+		 *
+		 * WAN => LAN
+		 * [eth1.836] => IPV4 => [br0] => [eth0]
+		 */
+		if (mp->shared->unit == 0)
+			return ff_forward(mp, mp_by_unit[1],
+					  ff.lan_dev,
+					  ff.wan_dev,
+					  0, 836,
+					  rx_desc,
+					  cmd_sts,
+					  frag, offset, dlen);
+
+		if (mp->shared->unit == 1)
+			return ff_forward(mp, mp_by_unit[0],
+					  ff.wan_dev,
+					  ff.lan_dev,
+					  836, 0,
+					  rx_desc,
+					  cmd_sts,
+					  frag, offset, dlen);
+	}
+
+	/*
+	 * GWv2
+	 */
+	if (ff_mode == 2) {
+		/*
+		 * LAN => WAN
+		 * [eth0 (untagged)] => [br0] => IPV4 => [eth0.836]
+		 *
+		 * WAN => LAN
+		 * [eth0.836] => IPV4 => [br0] => [eth0]
+		 */
+		if (mp->shared->unit != 0)
+			return false;
+
+		if (!pkt_is_vlan(cmd_sts))
+			return ff_forward(mp, mp,
+					  ff.lan_dev,
+					  ff.wan_dev,
+					  0, 836,
+					  rx_desc,
+					  cmd_sts,
+					  frag, offset, dlen);
+		else
+			return ff_forward(mp, mp,
+					  ff.wan_dev,
+					  ff.lan_dev,
+					  836, 0,
+					  rx_desc,
+					  cmd_sts,
+					  frag, offset, dlen);
+	}
+
+	return false;
+}
+
+/*
+ *
+ */
+static ssize_t ff_show_enabled(struct device *dev,
+			       struct device_attribute *attr,
+			       char *buf)
+{
+	return sprintf(buf, "%u\n", ff_enabled);
+}
+
+static ssize_t ff_store_enabled(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t len)
+{
+	unsigned long val;
+
+	if (kstrtoul(buf, 10, &val))
+		return -EINVAL;
+
+	if (ff_enabled == val)
+		return len;
+
+	printk(KERN_NOTICE "ff: fastpath now %s\n",
+	       val ? "enabled" : "disabled");
+	ff_enabled = val;
+	return len;
+}
+
+static struct device_attribute dev_attr_ff = {
+	.attr = { .name = "ff_enabled", .mode = (S_IRUGO | S_IWUSR) },
+	.show = ff_show_enabled,
+	.store = ff_store_enabled,
+};
+
+/*
+ *
+ */
+static ssize_t ff_show_tun_dev(struct device *dev,
+			       struct device_attribute *attr,
+			       char *buf)
+{
+	return sprintf(buf, "%u\n", ff_enabled);
+}
+
+static ssize_t ff_store_tun_dev(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t len)
+{
+	if (!len || buf[0] == '\n') {
+		ff.tun_dev_name[0] = 0;
+		ff_tun_release();
+		printk(KERN_NOTICE "ff: tun dev unset\n");
+		return len;
+	}
+
+	strncpy(ff.tun_dev_name, buf, len);
+	strim(ff.tun_dev_name);
+	printk(KERN_NOTICE "ff: tun dev set to %s\n", ff.tun_dev_name);
+	ff_tun_capture();
+	return len;
+}
+
+static struct device_attribute dev_attr_tun = {
+	.attr = { .name = "ff_tun_dev", .mode = (S_IRUGO | S_IWUSR) },
+	.show = ff_show_tun_dev,
+	.store = ff_store_tun_dev,
+};
+
+static struct ff_dev gw_lan = {
+	.desc			= "lan",
+	.unit			= 0,
+	.bridge_member		= true,
+	.pvirt_dev		= &ff.lan_dev,
+};
+
+static struct ff_dev gwv1_wan = {
+	.desc			= "wan",
+	.unit			= 1,
+	.vlan			= 836,
+	.pvirt_dev		= &ff.wan_dev,
+};
+
+static struct ff_dev gwv2_wan = {
+	.desc			= "wan",
+	.unit			= 0,
+	.vlan			= 836,
+	.pvirt_dev		= &ff.wan_dev,
+};
+
+static void ff_init(struct device *dev)
+{
+	static bool done;
+
+	if (done)
+		return;
+
+	device_create_file(dev, &dev_attr_ff);
+	device_create_file(dev, &dev_attr_tun);
+
+	printk(KERN_DEBUG "ff_init: mode %u\n", ff_mode);
+	switch (ff_mode) {
+	case 1:
+		list_add(&gw_lan.next, &ff_devs);
+		list_add(&gwv1_wan.next, &ff_devs);
+		break;
+
+	case 2:
+		list_add(&gw_lan.next, &ff_devs);
+		list_add(&gwv2_wan.next, &ff_devs);
+		break;
+	}
+
+	done = true;
+}
+#endif
+
+static void rxq_receive_packet(struct mv643xx_eth_private *mp,
+			       struct rx_queue *rxq,
+			       unsigned int cmd_sts,
+			       struct sk_buff *skb)
+{
+	struct net_device_stats *stats = &mp->dev->stats;
+
+	if (cmd_sts & LAYER_4_CHECKSUM_OK)
+		skb->ip_summed = CHECKSUM_UNNECESSARY;
+
+	rxq->rx_packets++;
+	stats->rx_packets++;
+	stats->rx_bytes += skb->len + ETH_FCS_LEN;
+
+#ifdef CONFIG_FBXBRIDGE
+	if (mp->dev->fbx_bridge_maybe_port &&
+	    pkt_is_vlan(cmd_sts) &&
+	    pkt_is_ipv4(cmd_sts)) {
+
+		if (pkt_is_tcp4(cmd_sts)) {
+			if (__fbxbridge_fp_in_vlan_tcp4(mp->dev, skb))
+				return;
+		} else if (pkt_is_udp4(cmd_sts)) {
+			if (__fbxbridge_fp_in_vlan_udp4(mp->dev, skb))
+				return;
+		}
+	}
+#endif
+
+	skb->protocol = eth_type_trans(skb, mp->dev);
+
+	if (pkt_is_ipv4(cmd_sts) &&
+	    (pkt_is_udp4(cmd_sts) || pkt_is_tcp4(cmd_sts)))
+		napi_gro_receive(&mp->napi, skb);
+	else
+		netif_receive_skb(skb);
+}
+
+static int rxq_process(struct rx_queue *rxq, int budget)
+{
+	struct mv643xx_eth_private *mp = rxq_to_mp(rxq);
+	struct net_device_stats *stats = &mp->dev->stats;
+	int rx_done;
+
+	rx_done = 0;
+	while (rx_done < budget) {
+		struct rx_desc *rx_desc;
+		struct sk_buff *skb;
+		unsigned int cmd_sts;
+		void *frag;
+		u16 byte_cnt;
+		int ret;
+
+		rx_desc = &rxq->rx_desc_area[rxq->rx_curr_desc];
+
+		cmd_sts = rx_desc->cmd_sts;
+		if (cmd_sts & BUFFER_OWNED_BY_DMA)
+			break;
+
+		rx_done++;
+		rxq->rx_curr_desc++;
+		if (rxq->rx_curr_desc == rxq->rx_ring_size)
+			rxq->rx_curr_desc = 0;
+
+		/*
+		 * In case we received a packet without first / last bits
+		 * on, or the error summary bit is set, the packet needs
+		 * to be dropped.
+		 */
+		if ((cmd_sts & (RX_FIRST_DESC | RX_LAST_DESC | ERROR_SUMMARY))
+		    != (RX_FIRST_DESC | RX_LAST_DESC))
+			goto err_rearm;
+
+		rmb();
+		frag = (void *)rx_desc->cookie;
+		byte_cnt = rx_desc->byte_cnt;
+
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+		if (ff_receive(mp, rx_desc, cmd_sts,
+			       frag, RX_OFFSET,
+			       byte_cnt - ETH_FCS_LEN)) {
+			rxq->rx_packets++;
+			continue;
+		}
+#endif
+
+		if (byte_cnt <= COPY_BREAK_SIZE) {
+			/* better copy a small frame and not unmap the
+			 * DMA region */
+			skb = netdev_alloc_skb_ip_align(mp->dev, byte_cnt);
+			if (unlikely(!skb))
+				goto err_rearm;
+
+			dma_sync_single_range_for_cpu(mp->dev->dev.parent,
+						      rx_desc->buf_ptr,
+						      0,
+						      byte_cnt,
+						      DMA_FROM_DEVICE);
+
+			memcpy(skb_put(skb, byte_cnt - 2 - ETH_FCS_LEN),
+			       frag + RX_OFFSET + 2,
+			       byte_cnt - 2 - ETH_FCS_LEN);
+
+			dma_sync_single_range_for_device(mp->dev->dev.parent,
+							 rx_desc->buf_ptr,
+							 0,
+							 byte_cnt,
+							 DMA_FROM_DEVICE);
+
+			/* rearm descriptor */
+			rx_desc->cmd_sts = BUFFER_OWNED_BY_DMA |
+				RX_ENABLE_INTERRUPT;
+
+			rxq_receive_packet(mp, rxq, cmd_sts, skb);
+			continue;
+		}
+
+                ret = rx_desc_refill(mp, rx_desc, true);
+		if (ret) {
+			netdev_err(mp->dev, "oom while refill\n");
+			goto err_rearm;
+		}
 
-		if (cmd_sts & LAYER_4_CHECKSUM_OK)
-			skb->ip_summed = CHECKSUM_UNNECESSARY;
-		skb->protocol = eth_type_trans(skb, mp->dev);
+		/* descriptor is re-armed now */
+
+		skb = build_skb(frag, mp->frag_size > PAGE_SIZE ?
+				0 : mp->frag_size);
+		if (!skb) {
+			mv643xx_eth_frag_free(mp, frag);
+			stats->rx_dropped++;
+			continue;
+		}
 
-		napi_gro_receive(&mp->napi, skb);
+		/* add NET_SKB_PAD + skip 2 bytes of hardware align */
+		skb_reserve(skb, RX_OFFSET + 2);
+		skb_put(skb, byte_cnt - 2 - ETH_FCS_LEN);
 
+		rxq_receive_packet(mp, rxq, cmd_sts, skb);
 		continue;
 
-err:
+err_rearm:
 		stats->rx_dropped++;
 
 		if ((cmd_sts & (RX_FIRST_DESC | RX_LAST_DESC)) !=
@@ -598,72 +2476,31 @@
 					   "received packet spanning multiple descriptors\n");
 		}
 
-		if (cmd_sts & ERROR_SUMMARY)
+		if (cmd_sts & ERROR_SUMMARY) {
 			stats->rx_errors++;
-
-		dev_kfree_skb(skb);
+			if (cmd_sts & RX_FIRST_DESC) {
+				switch (cmd_sts & ERROR_CODE_MASK) {
+				case ERROR_CODE_RX_MAX_LENGTH:
+					stats->rx_length_errors++;
+					break;
+				case ERROR_CODE_RX_CRC:
+					stats->rx_crc_errors++;
+					break;
+				case ERROR_CODE_RX_OVERRUN:
+					stats->rx_fifo_errors++;
+					break;
 	}
-
-	if (rx < budget)
-		mp->work_rx &= ~(1 << rxq->index);
-
-	return rx;
 }
-
-static int rxq_refill(struct rx_queue *rxq, int budget)
-{
-	struct mv643xx_eth_private *mp = rxq_to_mp(rxq);
-	int refilled;
-
-	refilled = 0;
-	while (refilled < budget && rxq->rx_desc_count < rxq->rx_ring_size) {
-		struct sk_buff *skb;
-		int rx;
-		struct rx_desc *rx_desc;
-		int size;
-
-		skb = netdev_alloc_skb(mp->dev, mp->skb_size);
-
-		if (skb == NULL) {
-			mp->oom = 1;
-			goto oom;
 		}
 
-		if (SKB_DMA_REALIGN)
-			skb_reserve(skb, SKB_DMA_REALIGN);
-
-		refilled++;
-		rxq->rx_desc_count++;
-
-		rx = rxq->rx_used_desc++;
-		if (rxq->rx_used_desc == rxq->rx_ring_size)
-			rxq->rx_used_desc = 0;
-
-		rx_desc = rxq->rx_desc_area + rx;
-
-		size = skb_end_pointer(skb) - skb->data;
-		rx_desc->buf_ptr = dma_map_single(mp->dev->dev.parent,
-						  skb->data, size,
-						  DMA_FROM_DEVICE);
-		rx_desc->buf_size = size;
-		rxq->rx_skb[rx] = skb;
-		wmb();
+		/* rearm descriptor */
 		rx_desc->cmd_sts = BUFFER_OWNED_BY_DMA | RX_ENABLE_INTERRUPT;
-		wmb();
-
-		/*
-		 * The hardware automatically prepends 2 bytes of
-		 * dummy data to each received packet, so that the
-		 * IP header ends up 16-byte aligned.
-		 */
-		skb_reserve(skb, 2);
 	}
 
-	if (refilled < budget)
-		mp->work_rx_refill &= ~(1 << rxq->index);
+	if (rx_done < budget)
+		mp->work_rx &= ~(1 << rxq->index);
 
-oom:
-	return refilled;
+	return rx_done;
 }
 
 
@@ -759,12 +2596,24 @@
 
 	desc->l4i_chk = 0;
 	desc->byte_cnt = length;
+
+	if (length <= 8 && (uintptr_t)data & 0x7) {
+		/* Copy unaligned small data fragment to TSO header data area */
+		memcpy(txq->tso_hdrs + txq->tx_curr_desc * TSO_HEADER_SIZE,
+		       data, length);
+		desc->buf_ptr = txq->tso_hdrs_dma
+			+ txq->tx_curr_desc * TSO_HEADER_SIZE;
+	} else {
+		/* Alignment is okay, map buffer and hand off to hardware */
+		txq->tx_desc_mapping[tx_index] = DESC_DMA_MAP_SINGLE;
 	desc->buf_ptr = dma_map_single(dev->dev.parent, data,
 				       length, DMA_TO_DEVICE);
-	if (unlikely(dma_mapping_error(dev->dev.parent, desc->buf_ptr))) {
+		if (unlikely(dma_mapping_error(dev->dev.parent,
+					       desc->buf_ptr))) {
 		WARN(1, "dma_map_single failed!\n");
 		return -ENOMEM;
 	}
+	}
 
 	cmd_sts = BUFFER_OWNED_BY_DMA;
 	if (last_tcp) {
@@ -779,7 +2628,8 @@
 }
 
 static inline void
-txq_put_hdr_tso(struct sk_buff *skb, struct tx_queue *txq, int length)
+txq_put_hdr_tso(struct sk_buff *skb, struct tx_queue *txq, int length,
+		struct tx_desc **ret_desc)
 {
 	struct mv643xx_eth_private *mp = txq_to_mp(txq);
 	int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
@@ -803,8 +2653,8 @@
 	desc->byte_cnt = hdr_len;
 	desc->buf_ptr = txq->tso_hdrs_dma +
 			txq->tx_curr_desc * TSO_HEADER_SIZE;
-	desc->cmd_sts = cmd_csum | BUFFER_OWNED_BY_DMA  | TX_FIRST_DESC |
-				   GEN_CRC;
+	desc->cmd_sts = cmd_csum | TX_FIRST_DESC | GEN_CRC;
+	*ret_desc = desc;
 
 	txq->tx_curr_desc++;
 	if (txq->tx_curr_desc == txq->tx_ring_size)
@@ -831,6 +2681,7 @@
 
 	total_len = skb->len - hdr_len;
 	while (total_len > 0) {
+		struct tx_desc *first_desc;
 		char *hdr;
 
 		data_left = min_t(int, skb_shinfo(skb)->gso_size, total_len);
@@ -840,7 +2691,7 @@
 		/* prepare packet headers: MAC + IP + TCP */
 		hdr = txq->tso_hdrs + txq->tx_curr_desc * TSO_HEADER_SIZE;
 		tso_build_hdr(skb, hdr, &tso, data_left, total_len == 0);
-		txq_put_hdr_tso(skb, txq, data_left);
+		txq_put_hdr_tso(skb, txq, data_left, &first_desc);
 
 		while (data_left > 0) {
 			int size;
@@ -855,6 +2706,9 @@
 			data_left -= size;
 			tso_build_data(skb, &tso, size);
 		}
+
+		wmb();
+		first_desc->cmd_sts |= BUFFER_OWNED_BY_DMA;
 	}
 
 	__skb_queue_tail(&txq->tx_skb, skb);
@@ -863,8 +2717,6 @@
 	/* clear TX_END status */
 	mp->work_tx_end &= ~(1 << txq->index);
 
-	/* ensure all descriptors are written before poking hardware */
-	wmb();
 	txq_enable(txq);
 	txq->tx_desc_count += desc_count;
 	return 0;
@@ -922,7 +2774,7 @@
 	struct tx_desc *desc;
 	u32 cmd_sts;
 	u16 l4i_chk;
-	int length, ret;
+	int maplen, length, ret;
 
 	cmd_sts = 0;
 	l4i_chk = 0;
@@ -952,10 +2804,16 @@
 		length = skb->len;
 	}
 
+	maplen = length;
+#ifdef CONFIG_FBXBRIDGE
+	if (skb->fbxbridge_state == 2 && maplen > COPY_BREAK_SIZE)
+		maplen = COPY_BREAK_SIZE;
+#endif
+
 	desc->l4i_chk = l4i_chk;
 	desc->byte_cnt = length;
 	desc->buf_ptr = dma_map_single(mp->dev->dev.parent, skb->data,
-				       length, DMA_TO_DEVICE);
+				       maplen, DMA_TO_DEVICE);
 
 	__skb_queue_tail(&txq->tx_skb, skb);
 
@@ -985,7 +2843,7 @@
 	struct netdev_queue *nq;
 
 	queue = skb_get_queue_mapping(skb);
-	txq = mp->txq + queue;
+	txq = mp->txq + queue + NAPI_TX_OFFSET;
 	nq = netdev_get_tx_queue(dev, queue);
 
 	if (has_tiny_unaligned_frags(skb) && __skb_linearize(skb)) {
@@ -1019,10 +2877,14 @@
 static void txq_kick(struct tx_queue *txq)
 {
 	struct mv643xx_eth_private *mp = txq_to_mp(txq);
-	struct netdev_queue *nq = netdev_get_tx_queue(mp->dev, txq->index);
+	struct netdev_queue *nq;
 	u32 hw_desc_ptr;
 	u32 expected_ptr;
 
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	WARN_ON(txq->index == 0);
+#endif
+	nq = netdev_get_tx_queue(mp->dev, txq->index - NAPI_TX_OFFSET);
 	__netif_tx_lock(nq, smp_processor_id());
 
 	if (rdlp(mp, TXQ_COMMAND) & (1 << txq->index))
@@ -1044,9 +2906,16 @@
 static int txq_reclaim(struct tx_queue *txq, int budget, int force)
 {
 	struct mv643xx_eth_private *mp = txq_to_mp(txq);
-	struct netdev_queue *nq = netdev_get_tx_queue(mp->dev, txq->index);
+	struct netdev_queue *nq;
 	int reclaimed;
 
+	nq = NULL;
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	if (txq->index != 0)
+#endif
+		nq = netdev_get_tx_queue(mp->dev, txq->index - NAPI_TX_OFFSET);
+
+	if (nq)
 	__netif_tx_lock_bh(nq);
 
 	reclaimed = 0;
@@ -1103,6 +2972,7 @@
 
 	}
 
+	if (nq)
 	__netif_tx_unlock_bh(nq);
 
 	if (reclaimed < budget)
@@ -1280,6 +3150,7 @@
 static void mib_counters_update(struct mv643xx_eth_private *mp)
 {
 	struct mib_counters *p = &mp->mib_counters;
+	unsigned int i;
 
 	spin_lock_bh(&mp->mib_counters_lock);
 	p->good_octets_received += mib_read(mp, 0x00);
@@ -1315,6 +3186,12 @@
 	/* Non MIB hardware counters */
 	p->rx_discard += rdlp(mp, RX_DISCARD_FRAME_CNT);
 	p->rx_overrun += rdlp(mp, RX_OVERRUN_FRAME_CNT);
+	/* Non MIB software counters */
+	for (i = 0; i < ARRAY_SIZE(mp->rxq); i++)
+		p->rx_packets_q[i] = mp->rxq[i].rx_packets;
+	for (i = 0; i < ARRAY_SIZE(mp->txq); i++)
+		p->tx_packets_q[i] = mp->txq[i].tx_packets;
+
 	spin_unlock_bh(&mp->mib_counters_lock);
 }
 
@@ -1462,6 +3339,22 @@
 	MIBSTAT(late_collision),
 	MIBSTAT(rx_discard),
 	MIBSTAT(rx_overrun),
+	MIBSTAT(rx_packets_q[0]),
+	MIBSTAT(rx_packets_q[1]),
+	MIBSTAT(rx_packets_q[2]),
+	MIBSTAT(rx_packets_q[3]),
+	MIBSTAT(rx_packets_q[4]),
+	MIBSTAT(rx_packets_q[5]),
+	MIBSTAT(rx_packets_q[6]),
+	MIBSTAT(rx_packets_q[7]),
+	MIBSTAT(tx_packets_q[0]),
+	MIBSTAT(tx_packets_q[1]),
+	MIBSTAT(tx_packets_q[2]),
+	MIBSTAT(tx_packets_q[3]),
+	MIBSTAT(tx_packets_q[4]),
+	MIBSTAT(tx_packets_q[5]),
+	MIBSTAT(tx_packets_q[6]),
+	MIBSTAT(tx_packets_q[7]),
 };
 
 static int
@@ -1660,6 +3553,244 @@
 	return 0;
 }
 
+static void
+mv643xx_eth_get_channels(struct net_device *dev, struct ethtool_channels *c)
+{
+	struct mv643xx_eth_private *mp = netdev_priv(dev);
+
+	c->max_rx = 8;
+	c->max_tx = 8;
+	c->max_other = 0;
+	c->max_combined = c->max_rx + c->max_tx;
+	c->rx_count = mp->rxq_count;
+	c->tx_count = mp->txq_count;
+}
+
+static int
+mv643xx_eth_set_channels(struct net_device *dev, struct ethtool_channels *c)
+{
+	struct mv643xx_eth_private *mp = netdev_priv(dev);
+	bool was_runnning;
+
+	if (c->rx_count > 8 || c->tx_count > 8 - NAPI_TX_OFFSET ||
+	    c->max_other)
+		return -EINVAL;
+
+	was_runnning = netif_running(dev);
+	if (was_runnning)
+		mv643xx_eth_stop(dev);
+
+	mp->rxq_count = c->rx_count;
+	mp->txq_count = c->tx_count + NAPI_TX_OFFSET;
+
+	netif_set_real_num_rx_queues(dev, mp->rxq_count);
+	netif_set_real_num_tx_queues(dev, mp->txq_count - NAPI_TX_OFFSET);
+
+	if (was_runnning && mv643xx_eth_open(dev)) {
+		netdev_err(dev,
+			   "fatal error on re-opening device after channels change\n");
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
+struct vprio_queue {
+	int	prio;
+	int	queue;
+};
+
+static int cmp_queue_inv(const void *a, const void *b)
+{
+	const struct vprio_queue *pa = a, *pb = b;
+	if (pb->queue != pa->queue)
+		return pb->queue - pa->queue;
+	return pa->prio - pb->prio;
+}
+
+static void dump_vlan_rules(struct mv643xx_eth_private *mp,
+			    struct vprio_queue *vprio_to_queue)
+{
+	unsigned int i;
+	u32 val;
+
+	val = rdlp(mp, PORT_VPT2P);
+	for (i = 0; i < 8; i++) {
+		unsigned int queue;
+
+		queue = (val & (0x7 << i * 3)) >> (i * 3);
+		vprio_to_queue[i].prio = i;
+		vprio_to_queue[i].queue = queue;
+	}
+
+	/* sort with higher tx queue first */
+	sort(vprio_to_queue, 8, sizeof (vprio_to_queue[0]),
+	     cmp_queue_inv, NULL);
+}
+
+static unsigned int find_vlan_rule(struct mv643xx_eth_private *mp,
+				   unsigned int prio)
+{
+	struct vprio_queue vprio_to_queue[8];
+	unsigned int i;
+
+	/* check if we already have a rule for this vlan */
+	dump_vlan_rules(mp, vprio_to_queue);
+	for (i = 0; i < ARRAY_SIZE(vprio_to_queue); i++) {
+		if (vprio_to_queue[i].prio != prio)
+			continue;
+		return i;
+	}
+	/* never reached */
+	return 0;
+}
+
+static int
+mv643xx_eth_get_rxnfc(struct net_device *dev,
+		      struct ethtool_rxnfc *info, u32 *rule_locs)
+{
+	struct mv643xx_eth_private *mp = netdev_priv(dev);
+
+	switch (info->cmd) {
+	case ETHTOOL_GRXFH:
+		return -ENOTSUPP;
+	case ETHTOOL_GRXRINGS:
+		info->data = mp->rxq_count;
+		break;
+
+	case ETHTOOL_GRXCLSRLCNT:
+		info->rule_cnt = 8;
+		info->data = RX_CLS_LOC_SPECIAL;
+		break;
+
+	case ETHTOOL_GRXCLSRLALL:
+	{
+		unsigned int i;
+
+		if (info->rule_cnt < 8)
+			return -EINVAL;
+
+		info->data = 8;
+		info->rule_cnt = 8;
+
+		for (i = 0; i < 8; i++)
+			rule_locs[i] = i;
+
+		break;
+	}
+
+	case ETHTOOL_GRXCLSRULE:
+	{
+		struct vprio_queue vprio_to_queue[8], *r;
+		struct ethtool_flow_ext *h_ext, *m_ext;
+		unsigned int loc;
+
+		loc = info->fs.location;
+		if (loc >= ARRAY_SIZE(vprio_to_queue))
+			return -EINVAL;
+
+		dump_vlan_rules(mp, vprio_to_queue);
+		r = &vprio_to_queue[loc];
+
+		memset(&info->fs, 0, sizeof (info->fs));
+		info->fs.flow_type = ETHER_FLOW | FLOW_EXT;
+		info->fs.ring_cookie = r->queue;
+		info->fs.location = loc;
+
+		m_ext = &info->fs.m_ext;
+		m_ext->vlan_tci |= VLAN_PRIO_MASK;
+
+		h_ext = &info->fs.h_ext;
+		h_ext->vlan_tci |= r->prio << VLAN_PRIO_SHIFT;
+
+		break;
+	}
+	}
+	return 0;
+}
+
+static int
+mv643xx_eth_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info)
+{
+	struct mv643xx_eth_private *mp = netdev_priv(dev);
+
+	switch (info->cmd) {
+	case ETHTOOL_SRXFH:
+		return -ENOTSUPP;
+
+	case ETHTOOL_SRXCLSRLINS:
+	{
+		struct ethhdr *m, z;
+		struct ethtool_flow_ext *h_ext, *m_ext;
+		unsigned int prio;
+		unsigned int rule_nr;
+		u32 val;
+
+		if ((info->fs.flow_type & (FLOW_MAC_EXT | FLOW_EXT)) !=
+		    FLOW_EXT)
+			return -EINVAL;
+
+		info->fs.flow_type &= ~FLOW_EXT;
+		if (info->fs.flow_type != ETHER_FLOW)
+			return -EINVAL;
+
+		if (info->fs.ring_cookie >= mp->rxq_count)
+			return -EINVAL;
+
+		if (info->fs.location != RX_CLS_LOC_ANY)
+			return -EINVAL;
+
+		/* no mask should be set on ethernet */
+		m = &info->fs.m_u.ether_spec;
+		memset(&z, 0, sizeof (z));
+		if (memcmp(m, &z, sizeof (*m)))
+			return -EINVAL;
+
+		/* no mask should be set on ext besides vlan prio */
+		m_ext = &info->fs.m_ext;
+		if (m_ext->vlan_etype ||
+		    m_ext->data[0] ||
+		    m_ext->data[1] ||
+		    ntohs(m_ext->vlan_tci) != VLAN_PRIO_MASK)
+			return -EINVAL;
+
+		/* ok, extract vlan prio */
+		h_ext = &info->fs.h_ext;
+		prio = (ntohs(h_ext->vlan_tci) & VLAN_PRIO_MASK) >>
+			VLAN_PRIO_SHIFT;
+
+		/* update vlan priority table for new rule */
+		rule_nr = find_vlan_rule(mp, prio);
+
+		val = rdlp(mp, PORT_VPT2P);
+		val |= info->fs.ring_cookie << (prio * 3);
+		wrlp(mp, PORT_VPT2P, val);
+
+		info->fs.location = rule_nr;
+		break;
+	}
+
+	case ETHTOOL_SRXCLSRLDEL:
+	{
+		struct vprio_queue vprio_to_queue[8], *r;
+		u32 val;
+
+		if (info->fs.location >= ARRAY_SIZE(vprio_to_queue))
+			return -EINVAL;
+
+		dump_vlan_rules(mp, vprio_to_queue);
+		r = &vprio_to_queue[info->fs.location];
+
+		/* update vlan priority table */
+		val = rdlp(mp, PORT_VPT2P);
+		val &= ~(0x7 << (r->prio * 3));
+		wrlp(mp, PORT_VPT2P, val);
+		break;
+	}
+	}
+
+	return 0;
+}
 
 static int
 mv643xx_eth_set_features(struct net_device *dev, netdev_features_t features)
@@ -1736,6 +3867,10 @@
 	.get_ts_info		= ethtool_op_get_ts_info,
 	.get_wol                = mv643xx_eth_get_wol,
 	.set_wol                = mv643xx_eth_set_wol,
+	.get_channels		= mv643xx_eth_get_channels,
+	.set_channels		= mv643xx_eth_set_channels,
+	.get_rxnfc		= mv643xx_eth_get_rxnfc,
+	.set_rxnfc		= mv643xx_eth_set_rxnfc,
 };
 
 
@@ -1913,7 +4048,6 @@
 	return 0;
 }
 
-
 /* rx/tx queue initialisation ***********************************************/
 static int rxq_init(struct mv643xx_eth_private *mp, int index)
 {
@@ -1925,10 +4059,7 @@
 	rxq->index = index;
 
 	rxq->rx_ring_size = mp->rx_ring_size;
-
-	rxq->rx_desc_count = 0;
 	rxq->rx_curr_desc = 0;
-	rxq->rx_used_desc = 0;
 
 	size = rxq->rx_ring_size * sizeof(struct rx_desc);
 
@@ -1950,14 +4081,14 @@
 	memset(rxq->rx_desc_area, 0, size);
 
 	rxq->rx_desc_area_size = size;
-	rxq->rx_skb = kcalloc(rxq->rx_ring_size, sizeof(*rxq->rx_skb),
-				    GFP_KERNEL);
-	if (rxq->rx_skb == NULL)
-		goto out_free;
 
 	rx_desc = rxq->rx_desc_area;
 	for (i = 0; i < rxq->rx_ring_size; i++) {
-		int nexti;
+		int ret, nexti;
+
+                ret = rx_desc_refill(mp, &rx_desc[i], false);
+		if (ret)
+			goto out_free;
 
 		nexti = i + 1;
 		if (nexti == rxq->rx_ring_size)
@@ -1971,6 +4102,12 @@
 
 
 out_free:
+	for (i = 0; i < rxq->rx_ring_size; i++) {
+		if (!rx_desc[i].cookie)
+			break;
+		mv643xx_eth_frag_free(mp, (void *)rx_desc[i].cookie);
+	}
+
 	if (index == 0 && size <= mp->rx_desc_sram_size)
 		iounmap(rxq->rx_desc_area);
 	else
@@ -1989,17 +4126,8 @@
 
 	rxq_disable(rxq);
 
-	for (i = 0; i < rxq->rx_ring_size; i++) {
-		if (rxq->rx_skb[i]) {
-			dev_kfree_skb(rxq->rx_skb[i]);
-			rxq->rx_desc_count--;
-		}
-	}
-
-	if (rxq->rx_desc_count) {
-		netdev_err(mp->dev, "error freeing rx ring -- %d skbs stuck\n",
-			   rxq->rx_desc_count);
-	}
+	for (i = 0; i < rxq->rx_ring_size; i++)
+		mv643xx_eth_frag_free(mp, (void *)rxq->rx_desc_area[i].cookie);
 
 	if (rxq->index == 0 &&
 	    rxq->rx_desc_area_size <= mp->rx_desc_sram_size)
@@ -2007,8 +4135,6 @@
 	else
 		dma_free_coherent(mp->dev->dev.parent, rxq->rx_desc_area_size,
 				  rxq->rx_desc_area, rxq->rx_desc_dma);
-
-	kfree(rxq->rx_skb);
 }
 
 static int txq_init(struct mv643xx_eth_private *mp, int index)
@@ -2020,7 +4146,6 @@
 	int i;
 
 	txq->index = index;
-
 	txq->tx_ring_size = mp->tx_ring_size;
 
 	/* A queue must always have room for at least one skb.
@@ -2143,6 +4268,9 @@
 		wrlp(mp, INT_CAUSE, ~int_cause);
 		mp->work_tx_end |= ((int_cause & INT_TX_END) >> 19) &
 				~(rdlp(mp, TXQ_COMMAND) & 0xff);
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+		mp->work_tx_end &= ~INT_TX_END_0;
+#endif
 		mp->work_rx |= (int_cause & INT_RX) >> 2;
 	}
 
@@ -2152,6 +4280,9 @@
 		if (int_cause_ext & INT_EXT_LINK_PHY)
 			mp->work_link = 1;
 		mp->work_tx |= int_cause_ext & INT_EXT_TX;
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+		mp->work_tx &= ~INT_EXT_TX_0;
+#endif
 	}
 
 	return 1;
@@ -2227,12 +4358,11 @@
 	struct mv643xx_eth_private *mp;
 	int work_done;
 
-	mp = container_of(napi, struct mv643xx_eth_private, napi);
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	ff.jiffies = jiffies;
+#endif
 
-	if (unlikely(mp->oom)) {
-		mp->oom = 0;
-		del_timer(&mp->rx_oom);
-	}
+	mp = container_of(napi, struct mv643xx_eth_private, napi);
 
 	work_done = 0;
 	while (work_done < budget) {
@@ -2248,8 +4378,6 @@
 		}
 
 		queue_mask = mp->work_tx | mp->work_tx_end | mp->work_rx;
-		if (likely(!mp->oom))
-			queue_mask |= mp->work_rx_refill;
 
 		if (!queue_mask) {
 			if (mv643xx_eth_collect_events(mp))
@@ -2271,16 +4399,12 @@
 			txq_maybe_wake(mp->txq + queue);
 		} else if (mp->work_rx & queue_mask) {
 			work_done += rxq_process(mp->rxq + queue, work_tbd);
-		} else if (!mp->oom && (mp->work_rx_refill & queue_mask)) {
-			work_done += rxq_refill(mp->rxq + queue, work_tbd);
 		} else {
 			BUG();
 		}
 	}
 
 	if (work_done < budget) {
-		if (mp->oom)
-			mod_timer(&mp->rx_oom, jiffies + (HZ / 10));
 		napi_complete(napi);
 		wrlp(mp, INT_MASK, mp->int_mask);
 	}
@@ -2288,13 +4412,6 @@
 	return work_done;
 }
 
-static inline void oom_timer_wrapper(unsigned long data)
-{
-	struct mv643xx_eth_private *mp = (void *)data;
-
-	napi_schedule(&mp->napi);
-}
-
 static void port_start(struct mv643xx_eth_private *mp)
 {
 	u32 pscr;
@@ -2369,32 +4486,34 @@
 	}
 }
 
-static void mv643xx_eth_recalc_skb_size(struct mv643xx_eth_private *mp)
+static void mv643xx_eth_recalc_frag_size(struct mv643xx_eth_private *mp)
 {
-	int skb_size;
-
 	/*
 	 * Reserve 2+14 bytes for an ethernet header (the hardware
 	 * automatically prepends 2 bytes of dummy data to each
 	 * received packet), 16 bytes for up to four VLAN tags, and
 	 * 4 bytes for the trailing FCS -- 36 bytes total.
 	 */
-	skb_size = mp->dev->mtu + 36;
+	mp->pkt_size = mp->dev->mtu + 36;
 
 	/*
-	 * Make sure that the skb size is a multiple of 8 bytes, as
+	 * Make sure that the buffer size is a multiple of 8 bytes, as
 	 * the lower three bits of the receive descriptor's buffer
 	 * size field are ignored by the hardware.
 	 */
-	mp->skb_size = (skb_size + 7) & ~7;
+	BUILD_BUG_ON(SMP_CACHE_BYTES < 8);
+
+	/*
+	 * add NET_SKB_PAD per build_skb() requirement, make sure we
+	 * have room to align data to cache size after reserving
+	 */
+	mp->frag_size = mp->pkt_size + RX_OFFSET;
 
 	/*
-	 * If NET_SKB_PAD is smaller than a cache line,
-	 * netdev_alloc_skb() will cause skb->data to be misaligned
-	 * to a cache line boundary.  If this is the case, include
-	 * some extra space to allow re-aligning the data area.
+	 * per build_skb() requirement
 	 */
-	mp->skb_size += SKB_DMA_REALIGN;
+	mp->frag_size = (SKB_DATA_ALIGN(mp->frag_size) +
+			 SKB_DATA_ALIGN(sizeof (struct skb_shared_info)));
 }
 
 static int mv643xx_eth_open(struct net_device *dev)
@@ -2414,7 +4533,7 @@
 		return -EAGAIN;
 	}
 
-	mv643xx_eth_recalc_skb_size(mp);
+	mv643xx_eth_recalc_frag_size(mp);
 
 	napi_enable(&mp->napi);
 
@@ -2428,15 +4547,9 @@
 			goto out;
 		}
 
-		rxq_refill(mp->rxq + i, INT_MAX);
 		mp->int_mask |= INT_RX_0 << i;
 	}
 
-	if (mp->oom) {
-		mp->rx_oom.expires = jiffies + (HZ / 10);
-		add_timer(&mp->rx_oom);
-	}
-
 	for (i = 0; i < mp->txq_count; i++) {
 		err = txq_init(mp, i);
 		if (err) {
@@ -2444,15 +4557,26 @@
 				txq_deinit(mp->txq + i);
 			goto out_free;
 		}
+
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+		if (i != 0)
 		mp->int_mask |= INT_TX_END_0 << i;
+#else
+		mp->int_mask |= INT_TX_END_0 << i;
+#endif
 	}
 
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	mp->ff_txq = &mp->txq[0];
+#endif
+
 	add_timer(&mp->mib_counters_timer);
 	port_start(mp);
 
 	wrlp(mp, INT_MASK_EXT, INT_EXT_LINK_PHY | INT_EXT_TX);
 	wrlp(mp, INT_MASK, mp->int_mask);
 
+	mp_by_unit[mp->shared->unit] = mp;
 	return 0;
 
 
@@ -2496,14 +4620,14 @@
 	struct mv643xx_eth_private *mp = netdev_priv(dev);
 	int i;
 
+	mp_by_unit[mp->shared->unit] = NULL;
+
 	wrlp(mp, INT_MASK_EXT, 0x00000000);
 	wrlp(mp, INT_MASK, 0x00000000);
 	rdlp(mp, INT_MASK);
 
 	napi_disable(&mp->napi);
 
-	del_timer_sync(&mp->rx_oom);
-
 	netif_carrier_off(dev);
 	if (mp->phy)
 		phy_stop(mp->phy);
@@ -2514,6 +4638,10 @@
 	mib_counters_update(mp);
 	del_timer_sync(&mp->mib_counters_timer);
 
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	mp->ff_txq = NULL;
+#endif
+
 	for (i = 0; i < mp->rxq_count; i++)
 		rxq_deinit(mp->rxq + i);
 	for (i = 0; i < mp->txq_count; i++)
@@ -2527,13 +4655,22 @@
 	struct mv643xx_eth_private *mp = netdev_priv(dev);
 	int ret;
 
-	if (mp->phy == NULL)
-		return -ENOTSUPP;
-
+	if (mp->phy != NULL) {
 	ret = phy_mii_ioctl(mp->phy, ifr, cmd);
 	if (!ret)
 		mv643xx_eth_adjust_link(dev);
-	return ret;
+	} else {
+		struct mii_if_info mii;
+
+		mii.dev = dev;
+		mii.mdio_read = mii_bus_read;
+		mii.mdio_write = mii_bus_write;
+		mii.phy_id = 0;
+		mii.phy_id_mask = 0x3f;
+		mii.reg_num_mask = 0x1f;
+		return generic_mii_ioctl(&mii, if_mii(ifr), cmd, NULL);
+	}
+	return -ENOTSUPP;
 }
 
 static int mv643xx_eth_change_mtu(struct net_device *dev, int new_mtu)
@@ -2544,7 +4681,7 @@
 		return -EINVAL;
 
 	dev->mtu = new_mtu;
-	mv643xx_eth_recalc_skb_size(mp);
+	mv643xx_eth_recalc_frag_size(mp);
 	tx_set_rate(mp, 1000000000, 16777216);
 
 	if (!netif_running(dev))
@@ -2785,6 +4922,12 @@
 	pdev->dev.platform_data = pd;
 
 	mv643xx_eth_property(np, "tx-checksum-limit", pd->tx_csum_limit);
+	mv643xx_eth_property(np, "unit", pd->unit);
+
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	if (!of_property_read_u32(np, "fbx,ff-model", &ff_mode))
+		ff_init(&pdev->dev);
+#endif
 
 	for_each_available_child_of_node(np, pnp) {
 		ret = mv643xx_eth_shared_of_add_port(pdev, pnp);
@@ -2856,6 +4999,7 @@
 		return ret;
 	pd = dev_get_platdata(&pdev->dev);
 
+	msp->unit = (pd ? pd->unit : 0);
 	msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ?
 					pd->tx_csum_limit : 9 * 1024;
 	infer_hw_params(msp);
@@ -2935,6 +5079,7 @@
 	mp->tx_desc_sram_size = pd->tx_sram_size;
 
 	mp->txq_count = pd->tx_queue_count ? : 1;
+	mp->txq_count += NAPI_TX_OFFSET;
 }
 
 static struct phy_device *phy_scan(struct mv643xx_eth_private *mp,
@@ -2991,6 +5136,45 @@
 	phy_start_aneg(phy);
 }
 
+static int mii_bus_read(struct net_device *dev, int mii_id, int regnum)
+{
+	struct mv643xx_eth_private *mp = netdev_priv(dev);
+	if (!mp->mii_bus)
+		return 0xffff;
+	return mp->mii_bus->read(mp->mii_bus, mii_id, regnum);
+}
+
+static void mii_bus_write(struct net_device *dev, int mii_id, int regnum,
+			 int value)
+{
+	struct mv643xx_eth_private *mp = netdev_priv(dev);
+	if (!mp->mii_bus)
+		return ;
+	mp->mii_bus->write(mp->mii_bus, mii_id, regnum, value);
+}
+
+static int mii_bus_init(struct net_device *dev,
+			struct platform_device *pdev,
+			struct mv643xx_eth_platform_data *pd)
+{
+	struct mv643xx_eth_private *mp = netdev_priv(dev);
+	extern void fbxgw_common_switch_init(struct net_device *dev,
+			     typeof(mii_bus_read), typeof(mii_bus_write));
+
+
+
+	mp->mii_bus = mdio_find_bus("f1072004.mdio-bu");
+	if (!mp->mii_bus) {
+		dev_err(&pdev->dev, "unable to find mdio bus f1072004.mdio-bu");
+		return -ENODEV;
+	}
+
+#ifdef CONFIG_FBXGW_COMMON
+	fbxgw_common_switch_init(dev, mii_bus_read, mii_bus_write);
+#endif
+	return 0;
+}
+
 static void init_pscr(struct mv643xx_eth_private *mp, int speed, int duplex)
 {
 	u32 pscr;
@@ -3055,7 +5239,9 @@
 		return -ENODEV;
 	}
 
-	dev = alloc_etherdev_mq(sizeof(struct mv643xx_eth_private), 8);
+	dev = alloc_etherdev_mqs(sizeof(struct mv643xx_eth_private),
+				 pd->tx_queue_count ? : 1,
+				 pd->rx_queue_count ? : 1);
 	if (!dev)
 		return -ENOMEM;
 
@@ -3091,7 +5277,7 @@
 	}
 
 	set_params(mp, pd);
-	netif_set_real_num_tx_queues(dev, mp->txq_count);
+	netif_set_real_num_tx_queues(dev, mp->txq_count - NAPI_TX_OFFSET);
 	netif_set_real_num_rx_queues(dev, mp->rxq_count);
 
 	err = 0;
@@ -3110,6 +5296,8 @@
 			err = PTR_ERR(mp->phy);
 		else
 			phy_init(mp, pd->speed, pd->duplex);
+	} else {
+		mii_bus_init(dev, pdev, pd);
 	}
 	if (err == -ENODEV) {
 		err = -EPROBE_DEFER;
@@ -3135,8 +5323,6 @@
 
 	netif_napi_add(dev, &mp->napi, mv643xx_eth_poll, NAPI_POLL_WEIGHT);
 
-	setup_timer(&mp->rx_oom, oom_timer_wrapper, (unsigned long)mp);
-
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	BUG_ON(!res);
@@ -3178,6 +5364,11 @@
 	if (mp->tx_desc_sram_size > 0)
 		netdev_notice(dev, "configured with sram\n");
 
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	mp->ff_notifier.notifier_call = ff_device_event;
+	register_netdevice_notifier(&mp->ff_notifier);
+#endif
+
 	return 0;
 
 out:
@@ -3192,6 +5383,10 @@
 {
 	struct mv643xx_eth_private *mp = platform_get_drvdata(pdev);
 
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	unregister_netdevice_notifier(&mp->ff_notifier);
+#endif
+
 	unregister_netdev(mp->dev);
 	if (mp->phy != NULL)
 		phy_disconnect(mp->phy);
diff -ruw linux-4.2.6/drivers/net/ethernet/marvell/sky2.c linux-4.2.6-fbx/drivers/net/ethernet/marvell/sky2.c
--- linux-4.2.6/drivers/net/ethernet/marvell/sky2.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/ethernet/marvell/sky2.c	2015-11-18 18:24:31.236160319 +0100
@@ -3051,6 +3051,16 @@
 	int work_done = 0;
 	u16 idx;
 
+	if (status == 0xffffffff) {
+		/*
+		 * this may happen if hardware is removed without
+		 * being properly disabled.
+		 */
+		printk("sky2: serious hardware error.\n");
+		napi_complete(napi);
+		return 0;
+	}
+
 	if (unlikely(status & Y2_IS_ERROR))
 		sky2_err_intr(hw, status);
 
diff -ruw linux-4.2.6/drivers/net/Kconfig linux-4.2.6-fbx/drivers/net/Kconfig
--- linux-4.2.6/drivers/net/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/Kconfig	2015-11-18 18:24:30.952158067 +0100
@@ -409,4 +409,14 @@
 
 source "drivers/net/hyperv/Kconfig"
 
+config TANGO2_ENET
+	tristate "SMP863x Builtin Ethernet support"
+	depends on NET_ETHERNET && TANGO2
+	select MII
+	select CRC32
+	help
+	 This option adds support for the SMP863x integrated Ethernet
+	 controller.  This driver uses NAPI and generic Linux MII
+	 support.
+
 endif # NETDEVICES
diff -ruw linux-4.2.6/drivers/net/Makefile linux-4.2.6-fbx/drivers/net/Makefile
--- linux-4.2.6/drivers/net/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/Makefile	2015-11-18 18:24:30.952158067 +0100
@@ -67,3 +67,4 @@
 
 obj-$(CONFIG_HYPERV_NET) += hyperv/
 obj-$(CONFIG_NTB_NETDEV) += ntb_netdev.o
+
diff -ruw linux-4.2.6/drivers/net/phy/mdio_bus.c linux-4.2.6-fbx/drivers/net/phy/mdio_bus.c
--- linux-4.2.6/drivers/net/phy/mdio_bus.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/phy/mdio_bus.c	2015-11-18 18:24:31.368161366 +0100
@@ -625,3 +625,16 @@
 	class_unregister(&mdio_bus_class);
 	bus_unregister(&mdio_bus_type);
 }
+
+static int match_mdio_bus(struct device *dev, const void *ptr)
+{
+	return !strcmp(dev->kobj.name, ptr);
+}
+
+struct mii_bus *mdio_find_bus(const char *name)
+{
+	struct device *d = class_find_device(&mdio_bus_class, NULL,
+					     name, match_mdio_bus);
+
+	return d ? to_mii_bus(d) : NULL;
+}
diff -ruw linux-4.2.6/drivers/net/ppp/ppp_generic.c linux-4.2.6-fbx/drivers/net/ppp/ppp_generic.c
--- linux-4.2.6/drivers/net/ppp/ppp_generic.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/ppp/ppp_generic.c	2015-11-18 18:24:31.372161407 +0100
@@ -174,6 +174,7 @@
 	struct ppp	*ppp;		/* ppp unit we're connected to */
 	struct net	*chan_net;	/* the net channel belongs to */
 	struct list_head clist;		/* link in list of channels per unit */
+	int		stopped;	/* channel is stopped */
 	rwlock_t	upl;		/* protects `ppp' */
 #ifdef CONFIG_PPP_MULTILINK
 	u8		avail;		/* flag used in multilink stuff */
@@ -1137,7 +1138,7 @@
 	dev->tx_queue_len = 3;
 	dev->type = ARPHRD_PPP;
 	dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
-	dev->features |= NETIF_F_NETNS_LOCAL;
+//	dev->features |= NETIF_F_NETNS_LOCAL;
 	netif_keep_dst(dev);
 }
 
@@ -1162,11 +1163,29 @@
 			ppp_send_frame(ppp, skb);
 		/* If there's no work left to do, tell the core net
 		   code that we can accept some more. */
-		if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq))
+		if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq)) {
+			/* only  enable  net  queue  if at  least  one
+			 * channel is not stopped */
+			struct list_head *list;
+			struct channel *pch;
+			bool need_wake;
+
+			list = &ppp->channels;
+			need_wake = false;
+			while ((list = list->next) != &ppp->channels) {
+				pch = list_entry(list, struct channel, clist);
+				if (!pch->stopped) {
+					need_wake = true;
+					break;
+				}
+			}
+
+			if (need_wake)
 			netif_wake_queue(ppp->dev);
 		else
 			netif_stop_queue(ppp->dev);
 	}
+	}
 	ppp_xmit_unlock(ppp);
 }
 
@@ -2394,10 +2413,24 @@
 
 	if (!pch)
 		return;
+	pch->stopped = 0;
 	ppp_channel_push(pch);
 }
 
 /*
+ * Callback from a channel when it want to prevent further transmit on it
+ */
+void
+ppp_output_stop(struct ppp_channel *chan)
+{
+	struct channel *pch = chan->ppp;
+
+	if (pch == 0)
+		return;
+	pch->stopped = 1;
+}
+
+/*
  * Compression control.
  */
 
@@ -3038,6 +3071,7 @@
 EXPORT_SYMBOL(ppp_input);
 EXPORT_SYMBOL(ppp_input_error);
 EXPORT_SYMBOL(ppp_output_wakeup);
+EXPORT_SYMBOL(ppp_output_stop);
 EXPORT_SYMBOL(ppp_register_compressor);
 EXPORT_SYMBOL(ppp_unregister_compressor);
 MODULE_LICENSE("GPL");
diff -ruw linux-4.2.6/drivers/net/wireless/ath/ath10k/mac.c linux-4.2.6-fbx/drivers/net/wireless/ath/ath10k/mac.c
--- linux-4.2.6/drivers/net/wireless/ath/ath10k/mac.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/wireless/ath/ath10k/mac.c	2015-11-18 18:24:31.408161686 +0100
@@ -6993,12 +6993,14 @@
 		goto err_free;
 	}
 
+#ifndef CONFIG_ATH_REG_IGNORE
 	if (!ath_is_world_regd(&ar->ath_common.regulatory)) {
 		ret = regulatory_hint(ar->hw->wiphy,
 				      ar->ath_common.regulatory.alpha2);
 		if (ret)
 			goto err_unregister;
 	}
+#endif
 
 	return 0;
 
diff -ruw linux-4.2.6/drivers/net/wireless/ath/ath10k/pci.c linux-4.2.6-fbx/drivers/net/wireless/ath/ath10k/pci.c
--- linux-4.2.6/drivers/net/wireless/ath/ath10k/pci.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/wireless/ath/ath10k/pci.c	2015-11-18 18:24:31.408161686 +0100
@@ -536,7 +536,8 @@
 	/* Check if the shared legacy irq is for us */
 	cause = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS +
 				  PCIE_INTR_CAUSE_ADDRESS);
-	if (cause & (PCIE_INTR_FIRMWARE_MASK | PCIE_INTR_CE_MASK_ALL))
+	if (cause & (PCIE_INTR_FIRMWARE_MASK | PCIE_INTR_CE_MASK_ALL) &&
+	    cause != 0xdeadbeef)
 		return true;
 
 	return false;
diff -ruw linux-4.2.6/drivers/net/wireless/ath/Kconfig linux-4.2.6-fbx/drivers/net/wireless/ath/Kconfig
--- linux-4.2.6/drivers/net/wireless/ath/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/wireless/ath/Kconfig	2015-11-18 18:24:31.400161620 +0100
@@ -33,6 +33,9 @@
          This option enables tracepoints for atheros wireless drivers.
 	 Currently, ath9k makes use of this facility.
 
+config ATH_REG_IGNORE
+	bool "ignore all eeprom regulation"
+
 config ATH_REG_DYNAMIC_USER_REG_HINTS
 	bool "Atheros dynamic user regulatory hints"
 	depends on CFG80211_CERTIFICATION_ONUS
diff -ruw linux-4.2.6/drivers/net/wireless/ath/regd.c linux-4.2.6-fbx/drivers/net/wireless/ath/regd.c
--- linux-4.2.6/drivers/net/wireless/ath/regd.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/wireless/ath/regd.c	2015-11-18 18:24:31.456162067 +0100
@@ -341,6 +341,10 @@
 	struct ieee80211_channel *ch;
 	unsigned int i;
 
+#ifdef CONFIG_ATH_REG_IGNORE
+	return;
+#endif
+
 	for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
 		if (!wiphy->bands[band])
 			continue;
@@ -374,6 +378,10 @@
 {
 	struct ieee80211_supported_band *sband;
 
+#ifdef CONFIG_ATH_REG_IGNORE
+	return;
+#endif
+
 	sband = wiphy->bands[IEEE80211_BAND_2GHZ];
 	if (!sband)
 		return;
@@ -402,6 +410,10 @@
 	struct ieee80211_channel *ch;
 	unsigned int i;
 
+#ifdef CONFIG_ATH_REG_IGNORE
+	return;
+#endif
+
 	if (!wiphy->bands[IEEE80211_BAND_5GHZ])
 		return;
 
@@ -633,6 +645,11 @@
 	const struct ieee80211_regdomain *regd;
 
 	wiphy->reg_notifier = reg_notifier;
+
+#ifdef CONFIG_ATH_REG_IGNORE
+	return 0;
+#endif
+
 	wiphy->regulatory_flags |= REGULATORY_STRICT_REG |
 				   REGULATORY_CUSTOM_REG;
 
@@ -697,7 +714,7 @@
 	    regdmn == CTRY_DEFAULT) {
 		printk(KERN_DEBUG "ath: EEPROM indicates default "
 		       "country code should be used\n");
-		reg->country_code = CTRY_UNITED_STATES;
+		reg->country_code = CTRY_FRANCE;
 	}
 
 	if (reg->country_code == CTRY_DEFAULT) {
diff -ruw linux-4.2.6/drivers/net/wireless/mwl8k.c linux-4.2.6-fbx/drivers/net/wireless/mwl8k.c
--- linux-4.2.6/drivers/net/wireless/mwl8k.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/wireless/mwl8k.c	2015-11-18 18:24:31.572162983 +0100
@@ -24,6 +24,7 @@
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
 #include <linux/workqueue.h>
+#include <linux/crc32.h>
 
 #define MWL8K_DESC	"Marvell TOPDOG(R) 802.11 Wireless Network Driver"
 #define MWL8K_NAME	KBUILD_MODNAME
@@ -35,6 +36,12 @@
 MODULE_PARM_DESC(ap_mode_default,
 		 "Set to 1 to make ap mode the default instead of sta mode");
 
+static u8 ap_base_mac_addr[18] = "00:00:00:00:00:00";
+module_param_string(base_mac_addr, ap_base_mac_addr, 18, 0);
+MODULE_PARM_DESC(ap_base_mac_addr,
+		  "Override EEPROM defined base mac address in AP mode");
+
+
 /* Register definitions */
 #define MWL8K_HIU_GEN_PTR			0x00000c10
 #define  MWL8K_MODE_STA				 0x0000005a
@@ -300,6 +307,9 @@
 	struct ieee80211_channel *acs_chan;
 	unsigned long channel_time;
 	struct survey_info survey[MWL8K_NUM_CHANS];
+
+	unsigned int last_short_preamble;
+	unsigned int last_basic_rates;
 };
 
 #define MAX_WEP_KEY_LEN         13
@@ -327,6 +337,9 @@
 
 	/* A flag to indicate is HW crypto is enabled for this bssid */
 	bool is_hw_crypto_enabled;
+
+	u32 last_beacon_crc;
+	unsigned int last_beacon_int;
 };
 #define MWL8K_VIF(_vif) ((struct mwl8k_vif *)&((_vif)->drv_priv))
 #define IEEE80211_KEY_CONF(_u8) ((struct ieee80211_key_conf *)(_u8))
@@ -793,6 +806,11 @@
 	return loops ? 0 : -ETIMEDOUT;
 }
 
+static bool disable_5g = 0;
+module_param(disable_5g, bool, 0);
+MODULE_PARM_DESC(disable_5g,
+		 "Set to 1 to disable 5G band usage");
+
 
 /* DMA header used by firmware and hardware.  */
 struct mwl8k_dma_data {
@@ -1009,6 +1027,9 @@
 		}
 	}
 
+	if (le16_to_cpu(rxd->htsig2) & (1 << 7))
+		status->flag |= RX_FLAG_SHORT_GI;
+
 	if (rxd->channel > 14) {
 		status->band = IEEE80211_BAND_5GHZ;
 		if (!(status->flag & RX_FLAG_HT))
@@ -1651,6 +1672,8 @@
  */
 
 #define RI_FORMAT(a)		  (a & 0x0001)
+#define RI_SHORT_GI(a)		 (a & 0x0002)
+#define RI_40MHZ(a)		 (a & 0x0004)
 #define RI_RATE_ID_MCS(a)	 ((a & 0x01f8) >> 3)
 
 static int
@@ -1708,6 +1731,8 @@
 		tx_desc->pkt_len = 0;
 
 		info = IEEE80211_SKB_CB(skb);
+		rate_info = le16_to_cpu(tx_desc->rate_info);
+
 		if (ieee80211_is_data(wh->frame_control)) {
 			rcu_read_lock();
 			sta = ieee80211_find_sta_by_ifaddr(hw, wh->addr1,
@@ -1715,7 +1740,6 @@
 			if (sta) {
 				sta_info = MWL8K_STA(sta);
 				BUG_ON(sta_info == NULL);
-				rate_info = le16_to_cpu(tx_desc->rate_info);
 				/* If rate is < 6.5 Mpbs for an ht station
 				 * do not form an ampdu. If the station is a
 				 * legacy station (format = 0), do not form an
@@ -1729,18 +1753,25 @@
 				}
 			}
 			rcu_read_unlock();
-		}
 
-		ieee80211_tx_info_clear_status(info);
-
-		/* Rate control is happening in the firmware.
-		 * Ensure no tx rate is being reported.
-		 */
+			info->status.rates[0].idx = RI_RATE_ID_MCS(rate_info);
+			info->status.rates[0].flags = 0;
+			if (RI_FORMAT(rate_info))
+				info->status.rates[0].flags |= IEEE80211_TX_RC_MCS;
+			if (RI_SHORT_GI(rate_info))
+				info->status.rates[0].flags |= IEEE80211_TX_RC_SHORT_GI;
+			if (RI_40MHZ(rate_info))
+				info->status.rates[0].flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
+			info->status.rates[1].idx = -1;
+		} else
 		info->status.rates[0].idx = -1;
-		info->status.rates[0].count = 1;
+
+		ieee80211_tx_info_clear_status(info);
 
 		if (MWL8K_TXD_SUCCESS(status))
 			info->flags |= IEEE80211_TX_STAT_ACK;
+		if (index >= MWL8K_TX_WMM_QUEUES)
+			info->flags |= IEEE80211_TX_STAT_AMPDU;
 
 		ieee80211_tx_status_irqsafe(hw, skb);
 
@@ -2429,7 +2460,7 @@
 			mwl8k_set_ht_caps(hw, &priv->band_24, caps);
 	}
 
-	if (caps & MWL8K_CAP_5GHZ) {
+	if (!disable_5g && (caps & MWL8K_CAP_5GHZ)) {
 		mwl8k_setup_5ghz_band(hw);
 		if (caps & MWL8K_CAP_MIMO)
 			mwl8k_set_ht_caps(hw, &priv->band_50, caps);
@@ -2524,6 +2555,7 @@
 
 	if (!rc) {
 		int off;
+		u8 ap_base_mac[ETH_ALEN];
 
 		api_version = le32_to_cpu(cmd->fw_api_version);
 		if (priv->device_info->fw_api_ap != api_version) {
@@ -2535,7 +2567,13 @@
 			rc = -EINVAL;
 			goto done;
 		}
+
+		if (mac_pton(ap_base_mac_addr, ap_base_mac) &&
+		    !is_zero_ether_addr(ap_base_mac))
+			SET_IEEE80211_PERM_ADDR(hw, ap_base_mac);
+		else
 		SET_IEEE80211_PERM_ADDR(hw, cmd->perm_addr);
+
 		priv->num_mcaddrs = le16_to_cpu(cmd->num_mcaddrs);
 		priv->fw_rev = le32_to_cpu(cmd->fw_rev);
 		priv->hw_rev = cmd->hw_rev;
@@ -4699,10 +4737,6 @@
 	}
 	priv->irq = priv->pdev->irq;
 
-	/* Enable TX reclaim and RX tasklets.  */
-	tasklet_enable(&priv->poll_tx_task);
-	tasklet_enable(&priv->poll_rx_task);
-
 	/* Enable interrupts */
 	iowrite32(MWL8K_A2H_EVENTS, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
 	iowrite32(MWL8K_A2H_EVENTS,
@@ -4737,12 +4771,15 @@
 		iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
 		free_irq(priv->pdev->irq, hw);
 		priv->irq = -1;
-		tasklet_disable(&priv->poll_tx_task);
-		tasklet_disable(&priv->poll_rx_task);
+		tasklet_kill(&priv->poll_tx_task);
+		tasklet_kill(&priv->poll_rx_task);
 	} else {
 		ieee80211_wake_queues(hw);
 	}
 
+	priv->last_short_preamble = ~0;
+	priv->last_basic_rates = ~0;
+
 	return rc;
 }
 
@@ -4770,8 +4807,8 @@
 		dev_kfree_skb(priv->beacon_skb);
 
 	/* Stop TX reclaim and RX tasklets.  */
-	tasklet_disable(&priv->poll_tx_task);
-	tasklet_disable(&priv->poll_rx_task);
+	tasklet_kill(&priv->poll_tx_task);
+	tasklet_kill(&priv->poll_rx_task);
 
 	/* Return all skbs to mac80211 */
 	for (i = 0; i < mwl8k_tx_queues(priv); i++)
@@ -4846,6 +4883,8 @@
 	mwl8k_vif->seqno = 0;
 	memcpy(mwl8k_vif->bssid, vif->addr, ETH_ALEN);
 	mwl8k_vif->is_hw_crypto_enabled = false;
+	mwl8k_vif->last_beacon_crc = ~0;
+	mwl8k_vif->last_beacon_int = ~0;
 
 	/* Set the mac address.  */
 	mwl8k_cmd_set_mac_addr(hw, vif, vif->addr);
@@ -5090,19 +5129,27 @@
 mwl8k_bss_info_changed_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 			  struct ieee80211_bss_conf *info, u32 changed)
 {
+	struct mwl8k_priv *priv = hw->priv;
+	struct mwl8k_vif *mwl8k_vif = MWL8K_VIF(vif);
+	struct sk_buff *skb;
+	bool update_beacon;
+	u32 crc;
 	int rc;
 
 	if (mwl8k_fw_lock(hw))
 		return;
 
-	if (changed & BSS_CHANGED_ERP_PREAMBLE) {
+	if ((changed & BSS_CHANGED_ERP_PREAMBLE) &&
+	    priv->last_short_preamble != vif->bss_conf.use_short_preamble) {
 		rc = mwl8k_set_radio_preamble(hw,
 				vif->bss_conf.use_short_preamble);
 		if (rc)
 			goto out;
+		priv->last_short_preamble = vif->bss_conf.use_short_preamble;
 	}
 
-	if (changed & BSS_CHANGED_BASIC_RATES) {
+	if ((changed & BSS_CHANGED_BASIC_RATES) &&
+	    priv->last_basic_rates != vif->bss_conf.basic_rates) {
 		int idx;
 		int rate;
 
@@ -5121,18 +5168,33 @@
 			rate = mwl8k_rates_50[idx].hw_value;
 
 		mwl8k_cmd_use_fixed_rate_ap(hw, rate, rate);
+		priv->last_basic_rates = vif->bss_conf.basic_rates;
 	}
 
-	if (changed & (BSS_CHANGED_BEACON_INT | BSS_CHANGED_BEACON)) {
-		struct sk_buff *skb;
+	update_beacon = false;
+
+	if ((changed & BSS_CHANGED_BEACON_INT) &&
+	    mwl8k_vif->last_beacon_int != vif->bss_conf.beacon_int)
+		update_beacon = true;
 
 		skb = ieee80211_beacon_get(hw, vif);
-		if (skb != NULL) {
-			mwl8k_cmd_set_beacon(hw, vif, skb->data, skb->len);
-			kfree_skb(skb);
+	crc = 0;
+
+	if (changed & BSS_CHANGED_BEACON) {
+		if (skb) {
+			crc = crc32_le(~0, skb->data, skb->len);
+			if (crc != mwl8k_vif->last_beacon_crc)
+				update_beacon = true;
 		}
 	}
 
+	if (skb && update_beacon) {
+		mwl8k_cmd_set_beacon(hw, vif, skb->data, skb->len);
+		mwl8k_vif->last_beacon_crc = crc;
+		mwl8k_vif->last_beacon_int = vif->bss_conf.beacon_int;
+	}
+	kfree_skb(skb);
+
 	if (changed & BSS_CHANGED_BEACON_ENABLED)
 		mwl8k_cmd_bss_start(hw, vif, info->enable_beacon);
 
@@ -6105,9 +6167,7 @@
 
 	/* TX reclaim and RX tasklets.  */
 	tasklet_init(&priv->poll_tx_task, mwl8k_tx_poll, (unsigned long)hw);
-	tasklet_disable(&priv->poll_tx_task);
 	tasklet_init(&priv->poll_rx_task, mwl8k_rx_poll, (unsigned long)hw);
-	tasklet_disable(&priv->poll_rx_task);
 
 	/* Power management cookie */
 	priv->cookie = pci_alloc_consistent(priv->pdev, 4, &priv->cookie_dma);
diff -ruw linux-4.2.6/drivers/of/of_net.c linux-4.2.6-fbx/drivers/of/of_net.c
--- linux-4.2.6/drivers/of/of_net.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/of/of_net.c	2015-11-18 18:24:31.676163818 +0100
@@ -10,6 +10,7 @@
 #include <linux/of_net.h>
 #include <linux/phy.h>
 #include <linux/export.h>
+#include <linux/fbxserial.h>
 
 /**
  * of_get_phy_mode - Get phy mode for given device_node
@@ -68,6 +69,13 @@
 const void *of_get_mac_address(struct device_node *np)
 {
 	const void *addr;
+#ifdef CONFIG_FBXSERIAL
+	struct property *pp;
+
+	pp = of_find_property(np, "fbxserial-mac-address", NULL);
+	if (pp && pp->length == 4)
+		return fbxserialinfo_get_mac_addr(be32_to_cpu(*(u32*)pp->value));
+#endif
 
 	addr = of_get_mac_addr(np, "mac-address");
 	if (addr)
diff -ruw linux-4.2.6/drivers/of/platform.c linux-4.2.6-fbx/drivers/of/platform.c
--- linux-4.2.6/drivers/of/platform.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/of/platform.c	2015-11-18 18:24:31.676163818 +0100
@@ -74,6 +74,13 @@
 	struct device_node *node = dev->of_node;
 	const __be32 *reg;
 	u64 addr;
+	const char *legacy_name = NULL;
+
+	if (of_property_read_string(node, "fbx,legacy-device-name",
+				    &legacy_name) == 0) {
+		dev_set_name(dev, "%s", legacy_name);
+		return ;
+	}
 
 	/* Construct the name, using parent nodes if necessary to ensure uniqueness */
 	while (node->parent) {
diff -ruw linux-4.2.6/drivers/pci/host/pci-mvebu.c linux-4.2.6-fbx/drivers/pci/host/pci-mvebu.c
--- linux-4.2.6/drivers/pci/host/pci-mvebu.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/pci/host/pci-mvebu.c	2015-11-18 18:24:31.684163872 +0100
@@ -781,6 +781,11 @@
 		return start;
 }
 
+static void __init mvebu_pcie_preinit(void)
+{
+	pci_clear_flags(PCI_REASSIGN_ALL_RSRC);
+}
+
 static void mvebu_pcie_enable(struct mvebu_pcie *pcie)
 {
 	struct hw_pci hw;
@@ -797,6 +802,7 @@
 	hw.map_irq        = of_irq_parse_and_map_pci;
 	hw.ops            = &mvebu_pcie_ops;
 	hw.align_resource = mvebu_pcie_align_resource;
+	hw.preinit	  = mvebu_pcie_preinit,
 
 	pci_common_init_dev(&pcie->pdev->dev, &hw);
 }
diff -ruw linux-4.2.6/drivers/pci/pcie/aer/aerdrv_core.c linux-4.2.6-fbx/drivers/pci/pcie/aer/aerdrv_core.c
--- linux-4.2.6/drivers/pci/pcie/aer/aerdrv_core.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/pci/pcie/aer/aerdrv_core.c	2015-11-18 18:24:31.700164000 +0100
@@ -425,7 +425,8 @@
 
 	if (driver && driver->reset_link) {
 		status = driver->reset_link(udev);
-	} else if (udev->has_secondary_link) {
+	} else if (pci_pcie_type(udev) == PCI_EXP_TYPE_DOWNSTREAM ||
+		pci_pcie_type(udev) == PCI_EXP_TYPE_ROOT_PORT) {
 		status = default_reset_link(udev);
 	} else {
 		dev_printk(KERN_DEBUG, &dev->dev,
diff -ruw linux-4.2.6/drivers/pci/probe.c linux-4.2.6-fbx/drivers/pci/probe.c
--- linux-4.2.6/drivers/pci/probe.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/pci/probe.c	2015-11-18 18:24:31.704164033 +0100
@@ -1652,7 +1652,7 @@
 		return 0;
 	if (pci_pcie_type(parent) == PCI_EXP_TYPE_ROOT_PORT)
 		return 1;
-	if (parent->has_secondary_link &&
+	if (pci_pcie_type(parent) == PCI_EXP_TYPE_DOWNSTREAM &&
 	    !pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS))
 		return 1;
 	return 0;
diff -ruw linux-4.2.6/drivers/pci/quirks.c linux-4.2.6-fbx/drivers/pci/quirks.c
--- linux-4.2.6/drivers/pci/quirks.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/pci/quirks.c	2015-11-18 18:24:31.708164073 +0100
@@ -2727,6 +2727,8 @@
 }
 
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_HINT, 0x0020, quirk_hotplug_bridge);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PERICOM, PCI_DEVICE_ID_PI7C9X20303SL,
+			 quirk_hotplug_bridge);
 
 /*
  * This is a quirk for the Ricoh MMC controller found as a part of
diff -ruw linux-4.2.6/drivers/pci/vc.c linux-4.2.6-fbx/drivers/pci/vc.c
--- linux-4.2.6/drivers/pci/vc.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/pci/vc.c	2015-11-18 18:24:31.708164073 +0100
@@ -108,7 +108,8 @@
 	struct pci_dev *link = NULL;
 
 	/* Enable VCs from the downstream device */
-	if (!dev->has_secondary_link)
+	if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
+	    pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM)
 		return;
 
 	ctrl_pos = pos + PCI_VC_RES_CTRL + (res * PCI_CAP_VC_PER_VC_SIZEOF);
diff -ruw linux-4.2.6/drivers/pinctrl/mvebu/pinctrl-kirkwood.c linux-4.2.6-fbx/drivers/pinctrl/mvebu/pinctrl-kirkwood.c
--- linux-4.2.6/drivers/pinctrl/mvebu/pinctrl-kirkwood.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/pinctrl/mvebu/pinctrl-kirkwood.c	2015-11-18 18:24:31.736164286 +0100
@@ -495,7 +495,15 @@
 	.remove = kirkwood_pinctrl_remove,
 };
 
+#ifdef CONFIG_FBXGW_COMMON
+int kirkwood_pinctrl_driver_init(void)
+{
+	return platform_driver_register(&kirkwood_pinctrl_driver);
+}
+EXPORT_SYMBOL(kirkwood_pinctrl_driver_init);
+#else
 module_platform_driver(kirkwood_pinctrl_driver);
+#endif
 
 MODULE_AUTHOR("Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>");
 MODULE_DESCRIPTION("Marvell Kirkwood pinctrl driver");
diff -ruw linux-4.2.6/drivers/platform/Kconfig linux-4.2.6-fbx/drivers/platform/Kconfig
--- linux-4.2.6/drivers/platform/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/platform/Kconfig	2015-11-18 18:24:31.772164580 +0100
@@ -9,3 +9,11 @@
 endif
 
 source "drivers/platform/chrome/Kconfig"
+
+if X86_INTEL_CE
+source "drivers/platform/intelce/Kconfig"
+endif
+
+if TANGO2
+source "drivers/platform/tango2/Kconfig"
+endif
diff -ruw linux-4.2.6/drivers/platform/Makefile linux-4.2.6-fbx/drivers/platform/Makefile
--- linux-4.2.6/drivers/platform/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/platform/Makefile	2015-11-18 18:24:31.772164580 +0100
@@ -7,3 +7,5 @@
 obj-$(CONFIG_OLPC)		+= olpc/
 obj-$(CONFIG_GOLDFISH)		+= goldfish/
 obj-$(CONFIG_CHROME_PLATFORMS)	+= chrome/
+obj-$(CONFIG_X86_INTEL_CE)	+= intelce/
+obj-$(CONFIG_TANGO2)		+= tango2/
diff -ruw linux-4.2.6/drivers/spi/Kconfig linux-4.2.6-fbx/drivers/spi/Kconfig
--- linux-4.2.6/drivers/spi/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/spi/Kconfig	2015-11-18 18:24:32.080167023 +0100
@@ -399,6 +399,12 @@
 	def_bool y
 	depends on SPI_PXA2XX
 
+config SPI_TDM_ORION
+	tristate "Orion TDM SPI master"
+	depends on PLAT_ORION
+	help
+	  This enables using the TDM SPI master controller on the Orion chips.
+
 config SPI_PXA2XX
 	tristate "PXA2xx SSP SPI master"
 	depends on (ARCH_PXA || PCI || ACPI)
diff -ruw linux-4.2.6/drivers/spi/Makefile linux-4.2.6-fbx/drivers/spi/Makefile
--- linux-4.2.6/drivers/spi/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/spi/Makefile	2015-11-18 18:24:32.080167023 +0100
@@ -57,6 +57,7 @@
 obj-$(CONFIG_SPI_OMAP24XX)		+= spi-omap2-mcspi.o
 obj-$(CONFIG_SPI_TI_QSPI)		+= spi-ti-qspi.o
 obj-$(CONFIG_SPI_ORION)			+= spi-orion.o
+obj-$(CONFIG_SPI_TDM_ORION)		+= orion_tdm_spi.o
 obj-$(CONFIG_SPI_PL022)			+= spi-pl022.o
 obj-$(CONFIG_SPI_PPC4xx)		+= spi-ppc4xx.o
 spi-pxa2xx-platform-objs		:= spi-pxa2xx.o
diff -ruw linux-4.2.6/drivers/tty/serial/8250/8250_core.c linux-4.2.6-fbx/drivers/tty/serial/8250/8250_core.c
--- linux-4.2.6/drivers/tty/serial/8250/8250_core.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/tty/serial/8250/8250_core.c	2015-11-18 18:24:32.456169996 +0100
@@ -42,6 +42,12 @@
 #include <linux/sunserialcore.h>
 #endif
 
+#ifdef CONFIG_TANGO2
+#include <asm/mach-tango2/tango2_gbus.h>
+
+extern unsigned long em8xxx_sys_frequency;
+#endif
+
 #include <asm/io.h>
 #include <asm/irq.h>
 
@@ -336,20 +342,30 @@
 	},
 };
 
+
 /* Uart divisor latch read */
 static int default_serial_dl_read(struct uart_8250_port *up)
 {
+#ifndef CONFIG_TANGO2
 	return serial_in(up, UART_DLL) | serial_in(up, UART_DLM) << 8;
+#else
+	BUG();
+	return 0;
+#endif
 }
 
 /* Uart divisor latch write */
 static void default_serial_dl_write(struct uart_8250_port *up, int value)
 {
+#ifndef CONFIG_TANGO2
 	serial_out(up, UART_DLL, value & 0xff);
 	serial_out(up, UART_DLM, value >> 8 & 0xff);
+#else
+	BUG();
+#endif
 }
 
-#if defined(CONFIG_MIPS_ALCHEMY) || defined(CONFIG_SERIAL_8250_RT288X)
+#if defined(CONFIG_MIPS_ALCHEMY) || defined(CONFIG_SERIAL_8250_RT288X) || defined(CONFIG_WINTEGRA_WINPATH3)
 
 /* Au1x00/RT288x UART hardware has a weird register layout */
 static const s8 au_io_in_map[8] = {
@@ -423,14 +439,44 @@
 
 static unsigned int mem_serial_in(struct uart_port *p, int offset)
 {
+#ifdef CONFIG_TANGO2
+	unsigned long v;
+
+	/* no EFR on tango2 */
+	if (offset == UART_EFR)
+		v = 0;
+	else
+		v = gbus_readl((unsigned long)p->membase +
+			       (offset << p->regshift));
+	return v;
+#else
 	offset = offset << p->regshift;
 	return readb(p->membase + offset);
+#endif
 }
 
 static void mem_serial_out(struct uart_port *p, int offset, int value)
 {
+#ifdef CONFIG_TANGO2
+	/*
+	 * we add a special case for UART_DL register, since
+	 * register content has a different meaning for us.
+	 */
+	if (offset == UART_DL) {
+		/* select right clock source */
+		value = (em8xxx_sys_frequency / p->uartclk);
+	}
+
+	/* no EFR on tango2 */
+	if (offset != UART_EFR) {
+		offset = offset << p->regshift;
+		gbus_writel((unsigned long)p->membase + offset,
+			    value);
+	}
+#else
 	offset = offset << p->regshift;
 	writeb(value, p->membase + offset);
+#endif
 }
 
 static void mem32_serial_out(struct uart_port *p, int offset, int value)
@@ -500,7 +546,7 @@
 		p->serial_out = mem32be_serial_out;
 		break;
 
-#if defined(CONFIG_MIPS_ALCHEMY) || defined(CONFIG_SERIAL_8250_RT288X)
+#if defined(CONFIG_MIPS_ALCHEMY) || defined(CONFIG_SERIAL_8250_RT288X) || defined(CONFIG_WINTEGRA_WINPATH3)
 	case UPIO_AU:
 		p->serial_in = au_serial_in;
 		p->serial_out = au_serial_out;
@@ -742,7 +788,11 @@
 static int size_fifo(struct uart_8250_port *up)
 {
 	unsigned char old_fcr, old_mcr, old_lcr;
+#ifdef CONFIG_TANGO2
+	unsigned short old_dll, old_dlm;
+#else
 	unsigned short old_dl;
+#endif
 	int count;
 
 	old_lcr = serial_in(up, UART_LCR);
@@ -753,8 +803,14 @@
 		    UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT);
 	serial_out(up, UART_MCR, UART_MCR_LOOP);
 	serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
+#ifdef CONFIG_TANGO2
+	old_dll = serial_in(up, UART_DL) & 0xff;
+	old_dlm = serial_in(up, UART_DL) >> 8;
+	serial_out(up, UART_DL, 0x01);
+#else
 	old_dl = serial_dl_read(up);
 	serial_dl_write(up, 0x0001);
+#endif
 	serial_out(up, UART_LCR, 0x03);
 	for (count = 0; count < 256; count++)
 		serial_out(up, UART_TX, count);
@@ -765,7 +821,11 @@
 	serial_out(up, UART_FCR, old_fcr);
 	serial_out(up, UART_MCR, old_mcr);
 	serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
+#ifdef CONFIG_TANGO2
+	serial_out(up, UART_DL, (old_dlm << 8) | old_dll);
+#else
 	serial_dl_write(up, old_dl);
+#endif
 	serial_out(up, UART_LCR, old_lcr);
 
 	return count;
@@ -784,6 +844,16 @@
 	old_lcr = serial_in(p, UART_LCR);
 	serial_out(p, UART_LCR, UART_LCR_CONF_MODE_A);
 
+#ifdef CONFIG_TANGO2
+	old_dll = serial_in(p, UART_DL) & 0xff;
+	old_dlm = serial_in(p, UART_DL) >> 8;
+
+	serial_out(p, UART_DL, 0);
+
+	id = serial_in(p, UART_DL);
+
+	serial_out(p, UART_DL, (old_dlm << 8) | old_dll);
+#else
 	old_dll = serial_in(p, UART_DLL);
 	old_dlm = serial_in(p, UART_DLM);
 
@@ -794,6 +864,7 @@
 
 	serial_out(p, UART_DLL, old_dll);
 	serial_out(p, UART_DLM, old_dlm);
+#endif
 	serial_out(p, UART_LCR, old_lcr);
 
 	return id;
@@ -1026,11 +1097,19 @@
 
 			serial_out(up, UART_LCR, 0xE0);
 
+#ifdef CONFIG_TANGO2
+			quot = serial_in(up, UART_DL);
+#else
 			quot = serial_dl_read(up);
+#endif
 			quot <<= 3;
 
 			if (ns16550a_goto_highspeed(up))
+#ifdef CONFIG_TANGO2
+				serial_out(up, UART_DL, quot);
+#else
 				serial_dl_write(up, quot);
+#endif
 
 			serial_out(up, UART_LCR, 0);
 
@@ -2539,7 +2618,11 @@
 	else
 		serial_port_out(port, UART_LCR, up->lcr | UART_LCR_DLAB);
 
+#ifdef CONFIG_TANGO2
+	serial_out(up, UART_DL, quot);
+#else
 	serial_dl_write(up, quot);
+#endif
 
 	/* XR17V35x UARTs have an extra fractional divisor register (DLD) */
 	if (up->port.type == PORT_XR17V35X)
@@ -2661,6 +2744,11 @@
 	}
 
 	serial8250_set_divisor(port, baud, quot, frac);
+#ifdef CONFIG_TANGO2
+	serial_out(up, UART_DL, quot);
+#else
+	serial_dl_write(up, quot);
+#endif
 
 	/*
 	 * LCR DLAB must be set to enable 64-byte FIFO mode. If the FCR
@@ -3435,8 +3523,13 @@
 
 	lcr = serial_port_in(port, UART_LCR);
 	serial_port_out(port, UART_LCR, lcr | UART_LCR_DLAB);
+#ifdef CONFIG_TANGO2
+	dll = serial_port_in(port, UART_DL) & 0xff;
+	dlm = serial_port_in(port, UART_DL) >> 8;
+#else
 	dll = serial_port_in(port, UART_DLL);
 	dlm = serial_port_in(port, UART_DLM);
+#endif
 	serial_port_out(port, UART_LCR, lcr);
 
 	quot = (dlm << 8) | dll;
diff -ruw linux-4.2.6/drivers/tty/serial/8250/8250_early.c linux-4.2.6-fbx/drivers/tty/serial/8250/8250_early.c
--- linux-4.2.6/drivers/tty/serial/8250/8250_early.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/tty/serial/8250/8250_early.c	2015-11-18 18:24:32.456169996 +0100
@@ -126,8 +126,12 @@
 	divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud);
 	c = serial8250_early_in(port, UART_LCR);
 	serial8250_early_out(port, UART_LCR, c | UART_LCR_DLAB);
+#ifdef CONFIG_TANGO2
+	serial8250_early_out(port, UART_DL, divisor & 0xffff);
+#else
 	serial8250_early_out(port, UART_DLL, divisor & 0xff);
 	serial8250_early_out(port, UART_DLM, (divisor >> 8) & 0xff);
+#endif
 	serial8250_early_out(port, UART_LCR, c & ~UART_LCR_DLAB);
 }
 
diff -ruw linux-4.2.6/drivers/usb/host/ehci-hcd.c linux-4.2.6-fbx/drivers/usb/host/ehci-hcd.c
--- linux-4.2.6/drivers/usb/host/ehci-hcd.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/usb/host/ehci-hcd.c	2015-11-18 18:24:32.568170885 +0100
@@ -1296,6 +1296,11 @@
 #define	PLATFORM_DRIVER		ehci_hcd_sead3_driver
 #endif
 
+#ifdef CONFIG_TANGO2
+#include "ehci-tango2.c"
+#define	PLATFORM_DRIVER		ehci_hcd_tango2_driver
+#endif
+
 static int __init ehci_hcd_init(void)
 {
 	int retval = 0;
diff -ruw linux-4.2.6/drivers/usb/storage/usb.c linux-4.2.6-fbx/drivers/usb/storage/usb.c
--- linux-4.2.6/drivers/usb/storage/usb.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/usb/storage/usb.c	2015-11-18 18:24:32.636171424 +0100
@@ -83,7 +83,7 @@
 MODULE_DESCRIPTION("USB Mass Storage driver for Linux");
 MODULE_LICENSE("GPL");
 
-static unsigned int delay_use = 1;
+static unsigned int delay_use = 5;
 module_param(delay_use, uint, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device");
 
diff -ruw linux-4.2.6/drivers/video/Kconfig linux-4.2.6-fbx/drivers/video/Kconfig
--- linux-4.2.6/drivers/video/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/video/Kconfig	2015-11-18 18:24:32.652171550 +0100
@@ -52,4 +52,15 @@
 endif
 
 
+config FB_SSD1327
+	tristate "SSD1327 OLED driver"
+	depends on FB
+	select FB_SYS_FILLRECT
+	select FB_SYS_COPYAREA
+	select FB_SYS_IMAGEBLIT
+	select FB_SYS_FOPS
+	select FB_BACKLIGHT
+	select SPI
+	default n
+
 endmenu
diff -ruw linux-4.2.6/drivers/video/Makefile linux-4.2.6-fbx/drivers/video/Makefile
--- linux-4.2.6/drivers/video/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/drivers/video/Makefile	2015-11-18 18:24:32.652171550 +0100
@@ -11,3 +11,5 @@
 ifeq ($(CONFIG_OF),y)
 obj-$(CONFIG_VIDEOMODE_HELPERS) += of_display_timing.o of_videomode.o
 endif
+
+obj-$(CONFIG_FB_SSD1327)          += ssd1327.o
diff -ruw linux-4.2.6/firmware/Makefile linux-4.2.6-fbx/firmware/Makefile
--- linux-4.2.6/firmware/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/firmware/Makefile	2015-11-18 18:24:32.852173142 +0100
@@ -136,6 +136,10 @@
 fw-shipped-$(CONFIG_VIDEO_CPIA2) += cpia2/stv0672_vp4.bin
 fw-shipped-$(CONFIG_YAM) += yam/1200.bin yam/9600.bin
 
+fw-shipped-$(CONFIG_MWL8K) += mwl8k/helper_8366.fw mwl8k/fmimage_8764_ap-1.fw \
+                               mwl8k/fmimage_8366_ap-3.fw
+
+
 fw-shipped-all := $(fw-shipped-y) $(fw-shipped-m) $(fw-shipped-)
 
 quiet_cmd_ihex  = IHEX    $@
@@ -235,3 +239,10 @@
 obj- := dummy
 
 hostprogs-y := ihex2fw
+
+# hack for 'make mrproper' and mwl8k .fw files being removed.
+quiet_cmd_shipped = SHIPPED $@
+cmd_shipped = cat $< > $@
+
+%.fw: %.fw_shipped
+	$(call cmd,shipped)
diff -ruw linux-4.2.6/fs/exec.c linux-4.2.6-fbx/fs/exec.c
--- linux-4.2.6/fs/exec.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/fs/exec.c	2015-11-18 18:24:32.956173961 +0100
@@ -1490,6 +1490,23 @@
 		return PTR_ERR(filename);
 
 	/*
+	 * handle current->exec_mode:
+	 * - if unlimited, then nothing to do.
+	 * - if once, then set it to denied and continue (next execve
+	 *   after this one will fail).
+	 * - if denied, then effectively fail the execve call with EPERM.
+	 */
+	switch (current->exec_mode) {
+	case EXEC_MODE_UNLIMITED:
+		break;
+	case EXEC_MODE_ONCE:
+		current->exec_mode = EXEC_MODE_DENIED;
+		break;
+	case EXEC_MODE_DENIED:
+		return -EPERM;
+	}
+
+	/*
 	 * We move the actual failure in case of RLIMIT_NPROC excess from
 	 * set*uid() to execve() because too many poorly written programs
 	 * don't check setuid() return code.  Here we additionally recheck
diff -ruw linux-4.2.6/fs/Kconfig linux-4.2.6-fbx/fs/Kconfig
--- linux-4.2.6/fs/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/fs/Kconfig	2015-11-18 18:24:32.860173202 +0100
@@ -99,6 +99,7 @@
 
 source "fs/fat/Kconfig"
 source "fs/ntfs/Kconfig"
+source "fs/exfat/Kconfig"
 
 endmenu
 endif # BLOCK
diff -ruw linux-4.2.6/fs/Makefile linux-4.2.6-fbx/fs/Makefile
--- linux-4.2.6/fs/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/fs/Makefile	2015-11-18 18:24:32.860173202 +0100
@@ -126,3 +126,4 @@
 obj-$(CONFIG_CEPH_FS)		+= ceph/
 obj-$(CONFIG_PSTORE)		+= pstore/
 obj-$(CONFIG_EFIVAR_FS)		+= efivarfs/
+obj-$(CONFIG_EXFAT_FS)		+= exfat/
diff -ruw linux-4.2.6/fs/proc/array.c linux-4.2.6-fbx/fs/proc/array.c
--- linux-4.2.6/fs/proc/array.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/fs/proc/array.c	2015-11-18 18:24:33.132175359 +0100
@@ -139,6 +139,21 @@
 	return task_state_array[fls(state)];
 }
 
+static const char *const task_exec_mode_array[] = {
+	"0 (Denied)",
+	"1 (Once)",
+	"2 (Unlimited)",
+};
+
+static inline const char *get_task_exec_mode(struct task_struct *tsk)
+{
+	unsigned int exec_mode = tsk->exec_mode;
+
+	if (exec_mode > EXEC_MODE_UNLIMITED)
+		return "? (Invalid)";
+	return task_exec_mode_array[exec_mode];
+}
+
 static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
 				struct pid *pid, struct task_struct *p)
 {
@@ -340,6 +355,12 @@
 			p->nivcsw);
 }
 
+static inline void task_exec_mode(struct seq_file *m,
+				  struct task_struct *p)
+{
+	seq_printf(m, "Exec mode: %s\n", get_task_exec_mode(p));
+}
+
 static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
 {
 	seq_printf(m, "Cpus_allowed:\t%*pb\n",
@@ -366,6 +387,7 @@
 	task_cpus_allowed(m, task);
 	cpuset_task_status_allowed(m, task);
 	task_context_switch_counts(m, task);
+	task_exec_mode(m, task);
 	return 0;
 }
 
diff -ruw linux-4.2.6/fs/pstore/ram.c linux-4.2.6-fbx/fs/pstore/ram.c
--- linux-4.2.6/fs/pstore/ram.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/fs/pstore/ram.c	2015-11-18 18:24:33.136175399 +0100
@@ -319,6 +319,8 @@
 
 	prz = cxt->przs[cxt->dump_write_cnt];
 
+	persistent_ram_zap(prz);
+
 	hlen = ramoops_write_kmsg_hdr(prz, compressed);
 	if (size + hlen > prz->buffer_size)
 		size = prz->buffer_size - hlen;
diff -ruw linux-4.2.6/fs/xfs/xfs_buf.c linux-4.2.6-fbx/fs/xfs/xfs_buf.c
--- linux-4.2.6/fs/xfs/xfs_buf.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/fs/xfs/xfs_buf.c	2015-11-18 18:24:33.188175806 +0100
@@ -377,6 +377,37 @@
 	return error;
 }
 
+#ifdef CONFIG_MIPS
+static void cache_flush_buf_page(xfs_buf_t *bp, int page_id)
+{
+	struct page *page;
+	void *vmaddr, *addr;
+
+	if (!xfs_buf_is_vmapped(bp))
+		return;
+
+	page = bp->b_pages[page_id];
+	vmaddr = bp->b_addr - bp->b_offset + (page_id * PAGE_CACHE_SIZE);
+	addr = page_address(page);
+
+	if (pages_do_alias((unsigned long)addr, (unsigned long)vmaddr)) {
+		local_flush_data_cache_page(vmaddr);
+		local_flush_data_cache_page(addr);
+	}
+}
+
+static void cache_flush_buf(xfs_buf_t *bp)
+{
+	unsigned int i;
+
+	for (i = 0; i < bp->b_page_count; i++)
+		cache_flush_buf_page(bp, i);
+}
+#else
+static inline void cache_flush_buf_page(xfs_buf_t *bp, int page_id) { }
+static inline void cache_flush_buf(xfs_buf_t *bp) { }
+#endif
+
 /*
  *	Map buffer into kernel address-space if necessary.
  */
@@ -416,6 +447,7 @@
 		if (!bp->b_addr)
 			return -ENOMEM;
 		bp->b_addr += bp->b_offset;
+		cache_flush_buf(bp);
 	}
 
 	return 0;
@@ -1173,6 +1205,7 @@
 		if (nbytes > size)
 			nbytes = size;
 
+		cache_flush_buf_page(bp, page_index);
 		rbytes = bio_add_page(bio, bp->b_pages[page_index], nbytes,
 				      offset);
 		if (rbytes < nbytes)
diff -ruw linux-4.2.6/include/linux/genhd.h linux-4.2.6-fbx/include/linux/genhd.h
--- linux-4.2.6/include/linux/genhd.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/genhd.h	2015-11-18 18:24:33.264176415 +0100
@@ -85,6 +85,7 @@
 	unsigned long ticks[2];
 	unsigned long io_ticks;
 	unsigned long time_in_queue;
+	unsigned long io_errors[2];
 };
 
 #define PARTITION_META_INFO_VOLNAMELTH	64
diff -ruw linux-4.2.6/include/linux/if_vlan.h linux-4.2.6-fbx/include/linux/if_vlan.h
--- linux-4.2.6/include/linux/if_vlan.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/if_vlan.h	2015-11-18 18:24:33.272176469 +0100
@@ -17,6 +17,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/bug.h>
 #include <uapi/linux/if_vlan.h>
+#include <uapi/linux/pkt_sched.h>
 
 #define VLAN_HLEN	4		/* The additional bytes required by VLAN
 					 * (in addition to the Ethernet header)
@@ -109,6 +110,7 @@
 extern struct net_device *__vlan_find_dev_deep_rcu(struct net_device *real_dev,
 					       __be16 vlan_proto, u16 vlan_id);
 extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
+extern struct net_device *vlan_dev_upper_dev(const struct net_device *dev);
 extern u16 vlan_dev_vlan_id(const struct net_device *dev);
 extern __be16 vlan_dev_vlan_proto(const struct net_device *dev);
 
@@ -176,7 +178,7 @@
 
 	mp = vlan_dev_priv(dev)->egress_priority_map[(skprio & 0xF)];
 	while (mp) {
-		if (mp->priority == skprio) {
+		if (mp->priority == (skprio & TC_H_MIN_MASK)) {
 			return mp->vlan_qos; /* This should already be shifted
 					      * to mask correctly with the
 					      * VLAN's TCI */
@@ -215,6 +217,12 @@
 {
 	BUG();
 	return NULL;
+}
+
+static inline struct net_device *vlan_dev_upper_dev(const struct net_device *dev)
+{
+	BUG();
+	return NULL;
 }
 
 static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
diff -ruw linux-4.2.6/include/linux/in.h linux-4.2.6-fbx/include/linux/in.h
--- linux-4.2.6/include/linux/in.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/in.h	2015-11-02 19:00:31.881102571 +0100
@@ -34,6 +34,9 @@
 		return 0;
 	case IPPROTO_AH:	/* SPI */
 		return 4;
+	case IPPROTO_IPV6:
+		/* third byte of ipv6 destination address */
+		return 36;
 	default:
 		return -EINVAL;
 	}
diff -ruw linux-4.2.6/include/linux/init_task.h linux-4.2.6-fbx/include/linux/init_task.h
--- linux-4.2.6/include/linux/init_task.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/init_task.h	2015-11-18 18:24:33.276176501 +0100
@@ -191,6 +191,7 @@
 	.stack		= &init_thread_info,				\
 	.usage		= ATOMIC_INIT(2),				\
 	.flags		= PF_KTHREAD,					\
+	.exec_mode	= EXEC_MODE_UNLIMITED,				\
 	.prio		= MAX_PRIO-20,					\
 	.static_prio	= MAX_PRIO-20,					\
 	.normal_prio	= MAX_PRIO-20,					\
diff -ruw linux-4.2.6/include/linux/mtd/mtd.h linux-4.2.6-fbx/include/linux/mtd/mtd.h
--- linux-4.2.6/include/linux/mtd/mtd.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/mtd/mtd.h	2015-11-18 18:24:33.312176795 +0100
@@ -163,6 +163,10 @@
 	 */
 	unsigned int bitflip_threshold;
 
+	/* NAND related attributes */
+	const char *nand_type;
+	const char *nand_manufacturer;
+
 	// Kernel-only stuff starts here.
 	const char *name;
 	int index;
diff -ruw linux-4.2.6/include/linux/mtd/nand.h linux-4.2.6-fbx/include/linux/mtd/nand.h
--- linux-4.2.6/include/linux/mtd/nand.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/mtd/nand.h	2015-11-18 18:24:33.312176795 +0100
@@ -190,6 +190,9 @@
  */
 #define NAND_USE_BOUNCE_BUFFER	0x00100000
 
+/* NAND controller does not want RNDOUT commands, even in NAND_ECC_SOFT */
+#define NAND_NO_RNDOUT		0x00800000
+
 /* Options set by nand scan */
 /* Nand scan has allocated controller struct */
 #define NAND_CONTROLLER_ALLOC	0x80000000
diff -ruw linux-4.2.6/include/linux/mtd/spi-nor.h linux-4.2.6-fbx/include/linux/mtd/spi-nor.h
--- linux-4.2.6/include/linux/mtd/spi-nor.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/mtd/spi-nor.h	2015-11-18 18:24:33.312176795 +0100
@@ -29,9 +29,11 @@
 #define SPINOR_OP_PP		0x02	/* Page program (up to 256 bytes) */
 #define SPINOR_OP_BE_4K		0x20	/* Erase 4KiB block */
 #define SPINOR_OP_BE_4K_PMC	0xd7	/* Erase 4KiB block on PMC chips */
+#define SPINOR_OP_EWRSR		0x50	/* SST: Enable write to status reg */
 #define SPINOR_OP_BE_32K	0x52	/* Erase 32KiB block */
 #define SPINOR_OP_CHIP_ERASE	0xc7	/* Erase whole flash chip */
 #define SPINOR_OP_SE		0xd8	/* Sector erase (usually 64KiB) */
+#define	SPINOR_OP_RDID_ALT	0x90	/* Read ID (alt) */
 #define SPINOR_OP_RDID		0x9f	/* Read JEDEC ID */
 #define SPINOR_OP_RDCR		0x35	/* Read configuration register */
 #define SPINOR_OP_RDFSR		0x70	/* Read flag status register */
@@ -190,6 +192,8 @@
 	void (*write)(struct spi_nor *nor, loff_t to,
 			size_t len, size_t *retlen, const u_char *write_buf);
 	int (*erase)(struct spi_nor *nor, loff_t offs);
+	int (*read_alt_id)(struct spi_nor *nor, u8 cmd, u8 *val, int len);
+	int (*read_atmel_id)(struct spi_nor *nor, u8 cmd, u8 *val, int len);
 
 	int (*flash_lock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
 	int (*flash_unlock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
diff -ruw linux-4.2.6/include/linux/mv643xx_eth.h linux-4.2.6-fbx/include/linux/mv643xx_eth.h
--- linux-4.2.6/include/linux/mv643xx_eth.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/mv643xx_eth.h	2015-11-18 18:24:33.312176795 +0100
@@ -25,6 +25,7 @@
 	 * limit of 9KiB will be used.
 	 */
 	int			tx_csum_limit;
+	unsigned int		unit;
 };
 
 #define MV643XX_ETH_PHY_ADDR_DEFAULT	0
diff -ruw linux-4.2.6/include/linux/netdevice.h linux-4.2.6-fbx/include/linux/netdevice.h
--- linux-4.2.6/include/linux/netdevice.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/netdevice.h	2015-11-18 18:24:33.312176795 +0100
@@ -61,6 +61,20 @@
 struct wpan_dev;
 struct mpls_dev;
 
+#ifdef CONFIG_NETRXTHREAD
+
+#define RXTHREAD_MAX_PKTS       512
+struct krxd {
+	struct sk_buff_head	pkt_queue;
+	unsigned int		stats_pkts;
+	unsigned int		stats_dropped;
+	wait_queue_head_t	wq;
+	struct task_struct	*task;
+};
+
+extern struct krxd gkrxd[CONFIG_NETRXTHREAD_RX_QUEUE];
+#endif
+
 void netdev_set_default_ethtool_ops(struct net_device *dev,
 				    const struct ethtool_ops *ops);
 
@@ -1735,6 +1749,12 @@
 	struct garp_port __rcu	*garp_port;
 	struct mrp_port __rcu	*mrp_port;
 
+#ifdef CONFIG_FBXBRIDGE
+	struct fbxbridge	*fbx_bridge;
+	struct fbxbridge	*fbx_bridge_port;
+	int			fbx_bridge_maybe_port;
+#endif
+
 	struct device	dev;
 	const struct attribute_group *sysfs_groups[4];
 	const struct attribute_group *sysfs_rx_queue_group;
diff -ruw linux-4.2.6/include/linux/netfilter/nf_conntrack_ftp.h linux-4.2.6-fbx/include/linux/netfilter/nf_conntrack_ftp.h
--- linux-4.2.6/include/linux/netfilter/nf_conntrack_ftp.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/netfilter/nf_conntrack_ftp.h	2015-11-02 18:59:25.284577582 +0100
@@ -17,6 +17,11 @@
 	u_int16_t seq_aft_nl_num[IP_CT_DIR_MAX];
 	/* pickup sequence tracking, useful for conntrackd */
 	u_int16_t flags[IP_CT_DIR_MAX];
+#if defined(CONFIG_FREEBOX_BRIDGE) || defined(CONFIG_FREEBOX_BRIDGE_MODULE)
+	unsigned int is_fbxbridge;
+	unsigned long fbxbridge_remote;
+	unsigned long fbxbridge_wan;
+#endif
 };
 
 struct nf_conntrack_expect;
diff -ruw linux-4.2.6/include/linux/netfilter/nf_conntrack_tcp.h linux-4.2.6-fbx/include/linux/netfilter/nf_conntrack_tcp.h
--- linux-4.2.6/include/linux/netfilter/nf_conntrack_tcp.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/netfilter/nf_conntrack_tcp.h	2015-11-18 18:24:33.316176822 +0100
@@ -27,6 +27,7 @@
 	/* For SYN packets while we may be out-of-sync */
 	u_int8_t	last_wscale;	/* Last window scaling factor seen */
 	u_int8_t	last_flags;	/* Last flags set */
+	u_int32_t	no_window_track;
 };
 
 #endif /* _NF_CONNTRACK_TCP_H */
diff -ruw linux-4.2.6/include/linux/pci_ids.h linux-4.2.6-fbx/include/linux/pci_ids.h
--- linux-4.2.6/include/linux/pci_ids.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/pci_ids.h	2015-11-18 18:24:33.324176881 +0100
@@ -2995,4 +2995,7 @@
 
 #define PCI_VENDOR_ID_OCZ		0x1b85
 
+#define PCI_VENDOR_ID_PERICOM		0x12d8
+#define PCI_DEVICE_ID_PI7C9X20303SL	0xa303
+
 #endif /* _LINUX_PCI_IDS_H */
diff -ruw linux-4.2.6/include/linux/phy.h linux-4.2.6-fbx/include/linux/phy.h
--- linux-4.2.6/include/linux/phy.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/phy.h	2015-11-18 18:24:33.324176881 +0100
@@ -211,7 +211,7 @@
 struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
 int mdiobus_read(struct mii_bus *bus, int addr, u32 regnum);
 int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val);
-
+struct mii_bus *mdio_find_bus(const char *name);
 
 #define PHY_INTERRUPT_DISABLED	0x0
 #define PHY_INTERRUPT_ENABLED	0x80000000
diff -ruw linux-4.2.6/include/linux/platform_data/mtd-orion_nand.h linux-4.2.6-fbx/include/linux/platform_data/mtd-orion_nand.h
--- linux-4.2.6/include/linux/platform_data/mtd-orion_nand.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/platform_data/mtd-orion_nand.h	2015-11-18 18:24:33.332176949 +0100
@@ -18,6 +18,9 @@
 	u8 cle;		/* address line number connected to CLE */
 	u8 width;	/* buswidth */
 	u8 chip_delay;
+	u8 ecc;
+	u16 bch_ecc_size;
+	u8 bch_ecc_bytes;
 };
 
 
diff -ruw linux-4.2.6/include/linux/ppp_channel.h linux-4.2.6-fbx/include/linux/ppp_channel.h
--- linux-4.2.6/include/linux/ppp_channel.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/ppp_channel.h	2015-11-02 18:59:34.536650518 +0100
@@ -49,6 +49,9 @@
 /* Called by the channel when it can send some more data. */
 extern void ppp_output_wakeup(struct ppp_channel *);
 
+/* Called by the channel when it want to prevent further transmit on it */
+extern void ppp_output_stop(struct ppp_channel *);
+
 /* Called by the channel to process a received PPP packet.
    The packet should have just the 2-byte PPP protocol header. */
 extern void ppp_input(struct ppp_channel *, struct sk_buff *);
diff -ruw linux-4.2.6/include/linux/sched.h linux-4.2.6-fbx/include/linux/sched.h
--- linux-4.2.6/include/linux/sched.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/sched.h	2015-11-18 18:24:33.348177075 +0100
@@ -1353,6 +1353,12 @@
 	perf_nr_task_contexts,
 };
 
+enum task_exec_mode {
+	EXEC_MODE_DENIED,
+	EXEC_MODE_ONCE,
+	EXEC_MODE_UNLIMITED,
+};
+
 struct task_struct {
 	volatile long state;	/* -1 unrunnable, 0 runnable, >0 stopped */
 	void *stack;
@@ -1360,6 +1366,8 @@
 	unsigned int flags;	/* per process flags, defined below */
 	unsigned int ptrace;
 
+	enum task_exec_mode exec_mode;
+
 #ifdef CONFIG_SMP
 	struct llist_node wake_entry;
 	int on_cpu;
diff -ruw linux-4.2.6/include/linux/skbuff.h linux-4.2.6-fbx/include/linux/skbuff.h
--- linux-4.2.6/include/linux/skbuff.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/skbuff.h	2015-11-18 18:24:33.352177102 +0100
@@ -456,6 +456,13 @@
 }
 
 
+enum {
+	FFN_STATE_INIT = 0,
+	FFN_STATE_FORWARDABLE,
+	FFN_STATE_FAST_FORWARDED,
+	FFN_STATE_INCOMPATIBLE,
+};
+
 /** 
  *	struct sk_buff - socket buffer
  *	@next: Next buffer in list
@@ -557,14 +564,27 @@
 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
 	struct nf_conntrack	*nfct;
 #endif
+#ifdef CONFIG_IP_FFN
+	int			ffn_state;
+	int			ffn_orig_tos;
+#endif
 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
 	struct nf_bridge_info	*nf_bridge;
 #endif
+
+#ifdef CONFIG_FBXBRIDGE
+	int			fbxbridge_state;
+#endif
+
 	unsigned int		len,
 				data_len;
 	__u16			mac_len,
 				hdr_len;
 
+#ifdef CONFIG_NETRXTHREAD
+	int			rxthread_prio;
+#endif
+
 	/* Following fields are _not_ copied in __copy_skb_header()
 	 * Note that queue_mapping is here mostly to fill a hole.
 	 */
@@ -2038,6 +2058,10 @@
  * get_rps_cpus() for example only access one 64 bytes aligned block :
  * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
  */
+#ifdef CONFIG_NETSKBPAD
+#define NET_SKB_PAD	CONFIG_NETSKBPAD
+#endif
+
 #ifndef NET_SKB_PAD
 #define NET_SKB_PAD	max(32, L1_CACHE_BYTES)
 #endif
diff -ruw linux-4.2.6/include/net/ip6_tunnel.h linux-4.2.6-fbx/include/net/ip6_tunnel.h
--- linux-4.2.6/include/net/ip6_tunnel.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/net/ip6_tunnel.h	2015-11-18 18:24:33.396177455 +0100
@@ -15,6 +15,18 @@
 /* determine capability on a per-packet basis */
 #define IP6_TNL_F_CAP_PER_PACKET 0x40000
 
+/* IPv6 tunnel FMR */
+struct __ip6_tnl_fmr {
+	struct __ip6_tnl_fmr *next; /* next fmr in list */
+	struct in6_addr ip6_prefix;
+	struct in_addr ip4_prefix;
+
+	__u8 ip6_prefix_len;
+	__u8 ip4_prefix_len;
+	__u8 ea_len;
+	__u8 offset;
+};
+
 struct __ip6_tnl_parm {
 	char name[IFNAMSIZ];	/* name of tunnel device */
 	int link;		/* ifindex of underlying L2 interface */
@@ -25,6 +37,7 @@
 	__u32 flags;		/* tunnel flags */
 	struct in6_addr laddr;	/* local tunnel end-point address */
 	struct in6_addr raddr;	/* remote tunnel end-point address */
+	struct __ip6_tnl_fmr *fmrs;	/* FMRs */
 
 	__be16			i_flags;
 	__be16			o_flags;
diff -ruw linux-4.2.6/include/net/ip.h linux-4.2.6-fbx/include/net/ip.h
--- linux-4.2.6/include/net/ip.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/net/ip.h	2015-11-18 18:24:33.392177430 +0100
@@ -518,6 +518,20 @@
 int ip_frag_mem(struct net *net);
 
 /*
+ *     Functions provided by ip_ffn.c
+ */
+
+enum {
+	IP_FFN_FINISH_OUT,
+	IP_FFN_LOCAL_IN,
+};
+
+extern void ip_ffn_init(void);
+extern int ip_ffn_process(struct sk_buff *skb);
+extern void ip_ffn_add(struct sk_buff *skb, int when);
+extern void ip_ffn_flush_all(void);
+
+/*
  *	Functions provided by ip_forward.c
  */
  
diff -ruw linux-4.2.6/include/net/ipv6.h linux-4.2.6-fbx/include/net/ipv6.h
--- linux-4.2.6/include/net/ipv6.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/net/ipv6.h	2015-11-18 18:24:33.396177455 +0100
@@ -847,6 +847,7 @@
 int ip6_output(struct sock *sk, struct sk_buff *skb);
 int ip6_forward(struct sk_buff *skb);
 int ip6_input(struct sk_buff *skb);
+int ip6_input_finish(struct sock *sk, struct sk_buff *skb);
 int ip6_mc_input(struct sk_buff *skb);
 
 int __ip6_local_out(struct sk_buff *skb);
@@ -969,4 +970,19 @@
 		      const struct in6_addr *addr);
 int ipv6_sock_mc_drop(struct sock *sk, int ifindex,
 		      const struct in6_addr *addr);
+
+/*
+ *     Functions provided by ipv6_ffn.c
+ */
+
+enum {
+	IPV6_FFN_FINISH_OUT,
+	IPV6_FFN_LOCAL_IN,
+};
+
+extern void ipv6_ffn_init(void);
+extern int ipv6_ffn_process(struct sk_buff *skb);
+extern void ipv6_ffn_add(struct sk_buff *skb, int when);
+extern void ipv6_ffn_flush_all(void);
+
 #endif /* _NET_IPV6_H */
diff -ruw linux-4.2.6/include/net/sock.h linux-4.2.6-fbx/include/net/sock.h
--- linux-4.2.6/include/net/sock.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/net/sock.h	2015-11-18 18:24:33.412177584 +0100
@@ -185,6 +185,7 @@
 	unsigned char		skc_reuseport:1;
 	unsigned char		skc_ipv6only:1;
 	unsigned char		skc_net_refcnt:1;
+	unsigned char		skc_reuse_conflict;
 	int			skc_bound_dev_if;
 	union {
 		struct hlist_node	skc_bind_node;
@@ -324,6 +325,7 @@
 #define sk_reuseport		__sk_common.skc_reuseport
 #define sk_ipv6only		__sk_common.skc_ipv6only
 #define sk_net_refcnt		__sk_common.skc_net_refcnt
+#define sk_reuse_conflict	__sk_common.skc_reuse_conflict
 #define sk_bound_dev_if		__sk_common.skc_bound_dev_if
 #define sk_bind_node		__sk_common.skc_bind_node
 #define sk_prot			__sk_common.skc_prot
@@ -720,6 +722,7 @@
 		     */
 	SOCK_FILTER_LOCKED, /* Filter cannot be changed anymore */
 	SOCK_SELECT_ERR_QUEUE, /* Wake select on error queue */
+	SOCK_UDP_DUP_UNICAST,
 };
 
 static inline void sock_copy_flags(struct sock *nsk, struct sock *osk)
diff -ruw linux-4.2.6/include/uapi/asm-generic/socket.h linux-4.2.6-fbx/include/uapi/asm-generic/socket.h
--- linux-4.2.6/include/uapi/asm-generic/socket.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/uapi/asm-generic/socket.h	2015-11-18 18:24:33.440177811 +0100
@@ -87,4 +87,6 @@
 #define SO_ATTACH_BPF		50
 #define SO_DETACH_BPF		SO_DETACH_FILTER
 
+#define SO_UDP_DUP_UNICAST	51
+
 #endif /* __ASM_GENERIC_SOCKET_H */
diff -ruw linux-4.2.6/include/uapi/linux/if_tunnel.h linux-4.2.6-fbx/include/uapi/linux/if_tunnel.h
--- linux-4.2.6/include/uapi/linux/if_tunnel.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/uapi/linux/if_tunnel.h	2015-11-18 18:24:33.452177896 +0100
@@ -57,10 +57,23 @@
 	IFLA_IPTUN_ENCAP_FLAGS,
 	IFLA_IPTUN_ENCAP_SPORT,
 	IFLA_IPTUN_ENCAP_DPORT,
+	IFLA_IPTUN_FMRS,
 	__IFLA_IPTUN_MAX,
 };
 #define IFLA_IPTUN_MAX	(__IFLA_IPTUN_MAX - 1)
 
+enum {
+	IFLA_IPTUN_FMR_UNSPEC,
+	IFLA_IPTUN_FMR_IP6_PREFIX,
+	IFLA_IPTUN_FMR_IP4_PREFIX,
+	IFLA_IPTUN_FMR_IP6_PREFIX_LEN,
+	IFLA_IPTUN_FMR_IP4_PREFIX_LEN,
+	IFLA_IPTUN_FMR_EA_LEN,
+	IFLA_IPTUN_FMR_OFFSET,
+	__IFLA_IPTUN_FMR_MAX,
+};
+#define IFLA_IPTUN_FMR_MAX (__IFLA_IPTUN_FMR_MAX - 1)
+
 enum tunnel_encap_types {
 	TUNNEL_ENCAP_NONE,
 	TUNNEL_ENCAP_FOU,
diff -ruw linux-4.2.6/include/uapi/linux/Kbuild linux-4.2.6-fbx/include/uapi/linux/Kbuild
--- linux-4.2.6/include/uapi/linux/Kbuild	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/uapi/linux/Kbuild	2015-11-18 18:24:33.444177837 +0100
@@ -115,11 +115,14 @@
 header-y += errqueue.h
 header-y += ethtool.h
 header-y += eventpoll.h
+header-y += exfat_user.h
 header-y += fadvise.h
 header-y += falloc.h
 header-y += fanotify.h
 header-y += fb.h
 header-y += fcntl.h
+header-y += fbxatm.h
+header-y += fbxmtd_map_ioctl.h
 header-y += fd.h
 header-y += fdreg.h
 header-y += fib_rules.h
@@ -332,6 +335,7 @@
 header-y += ppp-ioctl.h
 header-y += pps.h
 header-y += prctl.h
+header-y += prctl-private.h
 header-y += psci.h
 header-y += ptp_clock.h
 header-y += ptrace.h
@@ -455,3 +459,10 @@
 header-y += xilinx-v4l2-controls.h
 header-y += zorro.h
 header-y += zorro_ids.h
+
+header-y += fbxatm.h
+header-y += fbxbridge.h
+header-y += fbxjtag.h
+
+header-y += remoti/
+header-y += hdmi-cec/
diff -ruw linux-4.2.6/include/uapi/linux/libc-compat.h linux-4.2.6-fbx/include/uapi/linux/libc-compat.h
--- linux-4.2.6/include/uapi/linux/libc-compat.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/uapi/linux/libc-compat.h	2015-11-18 18:24:33.456177937 +0100
@@ -48,13 +48,13 @@
 #ifndef _UAPI_LIBC_COMPAT_H
 #define _UAPI_LIBC_COMPAT_H
 
-/* We have included glibc headers... */
-#if defined(__GLIBC__)
+/* We have included libc headers... */
+#if !defined(__KERNEL__)
 
-/* Coordinate with glibc netinet/in.h header. */
+/* Coordinate with libc netinet/in.h header. */
 #if defined(_NETINET_IN_H)
 
-/* GLIBC headers included first so don't define anything
+/* LIBC headers included first so don't define anything
  * that would already be defined. */
 #define __UAPI_DEF_IN_ADDR		0
 #define __UAPI_DEF_IN_IPPROTO		0
@@ -68,7 +68,7 @@
  * if the glibc code didn't define them. This guard matches
  * the guard in glibc/inet/netinet/in.h which defines the
  * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
-#if defined(__USE_MISC) || defined (__USE_GNU)
+#if !defined(__GLIBC__) || defined(__USE_MISC) || defined (__USE_GNU)
 #define __UAPI_DEF_IN6_ADDR_ALT		0
 #else
 #define __UAPI_DEF_IN6_ADDR_ALT		1
@@ -83,7 +83,7 @@
 #else
 
 /* Linux headers included first, and we must define everything
- * we need. The expectation is that glibc will check the
+ * we need. The expectation is that the libc will check the
  * __UAPI_DEF_* defines and adjust appropriately. */
 #define __UAPI_DEF_IN_ADDR		1
 #define __UAPI_DEF_IN_IPPROTO		1
@@ -93,7 +93,7 @@
 #define __UAPI_DEF_IN_CLASS		1
 
 #define __UAPI_DEF_IN6_ADDR		1
-/* We unconditionally define the in6_addr macros and glibc must
+/* We unconditionally define the in6_addr macros and the libc must
  * coordinate. */
 #define __UAPI_DEF_IN6_ADDR_ALT		1
 #define __UAPI_DEF_SOCKADDR_IN6		1
@@ -115,7 +115,7 @@
 /* If we did not see any headers from any supported C libraries,
  * or we are being included in the kernel, then define everything
  * that we need. */
-#else /* !defined(__GLIBC__) */
+#else /* defined(__KERNEL__) */
 
 /* Definitions for in.h */
 #define __UAPI_DEF_IN_ADDR		1
@@ -138,6 +138,6 @@
 /* Definitions for xattr.h */
 #define __UAPI_DEF_XATTR		1
 
-#endif /* __GLIBC__ */
+#endif /* __KERNEL__ */
 
 #endif /* _UAPI_LIBC_COMPAT_H */
diff -ruw linux-4.2.6/include/uapi/linux/netlink.h linux-4.2.6-fbx/include/uapi/linux/netlink.h
--- linux-4.2.6/include/uapi/linux/netlink.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/uapi/linux/netlink.h	2015-11-18 18:24:33.460177964 +0100
@@ -1,7 +1,7 @@
 #ifndef _UAPI__LINUX_NETLINK_H
 #define _UAPI__LINUX_NETLINK_H
 
-#include <linux/kernel.h>
+//#include <linux/kernel.h>
 #include <linux/socket.h> /* for __kernel_sa_family_t */
 #include <linux/types.h>
 
diff -ruw linux-4.2.6/include/uapi/linux/serial_reg.h linux-4.2.6-fbx/include/uapi/linux/serial_reg.h
--- linux-4.2.6/include/uapi/linux/serial_reg.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/uapi/linux/serial_reg.h	2015-11-18 18:24:33.464177991 +0100
@@ -18,9 +18,18 @@
  * DLAB=0
  */
 #define UART_RX		0	/* In:  Receive buffer */
+#ifdef CONFIG_TANGO2
+#define UART_TX		1	/* Out: Transmit buffer */
+#else
 #define UART_TX		0	/* Out: Transmit buffer */
+#endif
 
+#ifdef CONFIG_TANGO2
+#define UART_IER	2	/* Out: Interrupt Enable Register */
+#else
 #define UART_IER	1	/* Out: Interrupt Enable Register */
+#endif
+
 #define UART_IER_MSI		0x08 /* Enable Modem status interrupt */
 #define UART_IER_RLSI		0x04 /* Enable receiver line status interrupt */
 #define UART_IER_THRI		0x02 /* Enable Transmitter holding register int. */
@@ -30,7 +39,12 @@
  */
 #define UART_IERX_SLEEP		0x10 /* Enable sleep mode */
 
+#ifdef CONFIG_TANGO2
+#define UART_IIR	3	/* In:  Interrupt ID Register */
+#else
 #define UART_IIR	2	/* In:  Interrupt ID Register */
+#endif
+
 #define UART_IIR_NO_INT		0x01 /* No interrupts pending */
 #define UART_IIR_ID		0x0e /* Mask for the interrupt ID */
 #define UART_IIR_MSI		0x00 /* Modem status interrupt */
@@ -44,7 +58,12 @@
 #define UART_IIR_XOFF		0x10 /* OMAP XOFF/Special Character */
 #define UART_IIR_CTS_RTS_DSR	0x20 /* OMAP CTS/RTS/DSR Change */
 
+#ifdef CONFIG_TANGO2
+#define UART_FCR	4	/* Out: FIFO Control Register */
+#else
 #define UART_FCR	2	/* Out: FIFO Control Register */
+#endif
+
 #define UART_FCR_ENABLE_FIFO	0x01 /* Enable the FIFO */
 #define UART_FCR_CLEAR_RCVR	0x02 /* Clear the RCVR FIFO */
 #define UART_FCR_CLEAR_XMIT	0x04 /* Clear the XMIT FIFO */
@@ -94,7 +113,12 @@
 	(((x) & UART_FCR_TRIGGER_MASK) >> UART_FCR_R_TRIG_SHIFT)
 #define UART_FCR_R_TRIG_MAX_STATE	4
 
+#ifdef CONFIG_TANGO2
+#define UART_LCR	5	/* Out: Line Control Register */
+#else
 #define UART_LCR	3	/* Out: Line Control Register */
+#endif
+
 /*
  * Note: if the word length is 5 bits (UART_LCR_WLEN5), then setting 
  * UART_LCR_STOP will select 1.5 stop bits, not 2 stop bits.
@@ -117,7 +141,11 @@
 #define UART_LCR_CONF_MODE_A	UART_LCR_DLAB	/* Configutation mode A */
 #define UART_LCR_CONF_MODE_B	0xBF		/* Configutation mode B */
 
+#ifdef CONFIG_TANGO2
+#define UART_MCR	6	/* Out: Modem Control Register */
+#else
 #define UART_MCR	4	/* Out: Modem Control Register */
+#endif
 #define UART_MCR_CLKSEL		0x80 /* Divide clock by 4 (TI16C752, EFR[4]=1) */
 #define UART_MCR_TCRTLR		0x40 /* Access TCR/TLR (TI16C752, EFR[4]=1) */
 #define UART_MCR_XONANY		0x20 /* Enable Xon Any (TI16C752, EFR[4]=1) */
@@ -128,8 +156,14 @@
 #define UART_MCR_RTS		0x02 /* RTS complement */
 #define UART_MCR_DTR		0x01 /* DTR complement */
 
+#ifdef CONFIG_TANGO2
+#define UART_LSR	7	/* In:  Line Status Register */
+#else
 #define UART_LSR	5	/* In:  Line Status Register */
+#endif
+
 #define UART_LSR_FIFOE		0x80 /* Fifo error */
+
 #define UART_LSR_TEMT		0x40 /* Transmitter empty */
 #define UART_LSR_THRE		0x20 /* Transmit-hold-register empty */
 #define UART_LSR_BI		0x10 /* Break interrupt indicator */
@@ -139,7 +173,11 @@
 #define UART_LSR_DR		0x01 /* Receiver data ready */
 #define UART_LSR_BRK_ERROR_BITS	0x1E /* BI, FE, PE, OE bits */
 
+#ifdef CONFIG_TANGO2
+#define UART_MSR	8	/* In:  Modem Status Register */
+#else
 #define UART_MSR	6	/* In:  Modem Status Register */
+#endif
 #define UART_MSR_DCD		0x80 /* Data Carrier Detect */
 #define UART_MSR_RI		0x40 /* Ring Indicator */
 #define UART_MSR_DSR		0x20 /* Data Set Ready */
@@ -150,18 +188,37 @@
 #define UART_MSR_DCTS		0x01 /* Delta CTS */
 #define UART_MSR_ANY_DELTA	0x0F /* Any of the delta bits! */
 
+#ifdef CONFIG_TANGO2
+#define UART_SCR	9	/* I/O: Scratch Register */
+#else
 #define UART_SCR	7	/* I/O: Scratch Register */
+#endif
 
 /*
  * DLAB=1
  */
+#ifdef CONFIG_TANGO2
+/*
+ * smp863x has DLM and DLM in one register
+ */
+#define UART_DL		10
+#define UART_CLKSEL     11      /* Clock selection */
+#else
 #define UART_DLL	0	/* Out: Divisor Latch Low */
 #define UART_DLM	1	/* Out: Divisor Latch High */
+#endif
 
 /*
  * LCR=0xBF (or DLAB=1 for 16C660)
  */
+#ifdef CONFIG_TANGO2
+/* EFR does not exist on TANGO2, we use a magic to catch accesses and
+ * make them nop */
+#define UART_EFR	42
+#else
 #define UART_EFR	2	/* I/O: Extended Features Register */
+#endif
+
 #define UART_XR_EFR	9	/* I/O: Extended Features Register (XR17D15x) */
 #define UART_EFR_CTS		0x80 /* CTS flow control */
 #define UART_EFR_RTS		0x40 /* RTS flow control */
diff -ruw linux-4.2.6/include/uapi/linux/sockios.h linux-4.2.6-fbx/include/uapi/linux/sockios.h
--- linux-4.2.6/include/uapi/linux/sockios.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/uapi/linux/sockios.h	2015-11-18 18:24:33.468178023 +0100
@@ -128,6 +128,14 @@
 #define SIOCSHWTSTAMP	0x89b0		/* set and get config		*/
 #define SIOCGHWTSTAMP	0x89b1		/* get config			*/
 
+/* fbxdiverter call */
+#define SIOCGFBXDIVERT  0x89c0		/* fbxdiverter support          */
+#define SIOCSFBXDIVERT  0x89c1		/* Set fbxdiverter options      */
+
+/* fbxbridge call */
+#define SIOCGFBXBRIDGE	0x89b2		/* fbxbridge support          */
+#define SIOCSFBXBRIDGE	0x89b3		/* Set fbxbridge options      */
+
 /* Device private ioctl calls */
 
 /*
diff -ruw linux-4.2.6/include/uapi/linux/tty.h linux-4.2.6-fbx/include/uapi/linux/tty.h
--- linux-4.2.6/include/uapi/linux/tty.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/include/uapi/linux/tty.h	2015-11-18 18:24:33.468178023 +0100
@@ -35,5 +35,6 @@
 #define N_TRACESINK	23	/* Trace data routing for MIPI P1149.7 */
 #define N_TRACEROUTER	24	/* Trace data routing for MIPI P1149.7 */
 #define N_NCI		25	/* NFC NCI UART */
+#define N_REMOTI	26	/* RemoTI over UART */
 
 #endif /* _UAPI_LINUX_TTY_H */
diff -ruw linux-4.2.6/init/initramfs.c linux-4.2.6-fbx/init/initramfs.c
--- linux-4.2.6/init/initramfs.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/init/initramfs.c	2015-11-18 18:24:33.480178118 +0100
@@ -628,7 +628,18 @@
 		fd = sys_open("/initrd.image",
 			      O_WRONLY|O_CREAT, 0700);
 		if (fd >= 0) {
-			ssize_t written = xwrite(fd, (char *)initrd_start,
+			ssize_t written;
+#ifdef CONFIG_FBX_DECRYPT_INITRD
+			int err;
+			extern int fbx_decrypt_initrd(char *start,
+						      u32 size);
+
+			err = fbx_decrypt_initrd((char*)initrd_start,
+						 initrd_end - initrd_start);
+			if (err)
+				printk(KERN_ERR "Decrypt failed: %i\n", err);
+#endif
+			written = xwrite(fd, (char *)initrd_start,
 						initrd_end - initrd_start);
 
 			if (written != initrd_end - initrd_start)
diff -ruw linux-4.2.6/init/Kconfig linux-4.2.6-fbx/init/Kconfig
--- linux-4.2.6/init/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/init/Kconfig	2015-11-18 18:24:33.480178118 +0100
@@ -874,6 +874,15 @@
 		     13 =>   8 KB for each CPU
 		     12 =>   4 KB for each CPU
 
+config FBX_DECRYPT_INITRD
+	bool "Decrypt initrd at boot"
+	depends on BLK_DEV_RAM
+	default n
+
+config FBX_DECRYPT_INITRD_KEY
+	string "Decryption key"
+	depends on FBX_DECRYPT_INITRD
+
 #
 # Architectures with an unreliable sched_clock() should select this:
 #
@@ -1338,7 +1347,6 @@
 menuconfig EXPERT
 	bool "Configure standard kernel features (expert users)"
 	# Unhide debug options, to make the on-by-default options visible
-	select DEBUG_KERNEL
 	help
 	  This option allows certain base kernel options and settings
           to be disabled or tweaked. This is for specialized
diff -ruw linux-4.2.6/init/Makefile linux-4.2.6-fbx/init/Makefile
--- linux-4.2.6/init/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/init/Makefile	2015-11-02 19:00:04.836889379 +0100
@@ -13,6 +13,7 @@
 ifneq ($(CONFIG_ARCH_INIT_TASK),y)
 obj-y                          += init_task.o
 endif
+obj-$(CONFIG_FBX_DECRYPT_INITRD)+= fbx_decrypt_initrd.o rc4.o
 
 mounts-y			:= do_mounts.o
 mounts-$(CONFIG_BLK_DEV_RAM)	+= do_mounts_rd.o
diff -ruw linux-4.2.6/kernel/fork.c linux-4.2.6-fbx/kernel/fork.c
--- linux-4.2.6/kernel/fork.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/kernel/fork.c	2015-11-18 18:24:33.508178344 +0100
@@ -382,6 +382,11 @@
 
 	account_kernel_stack(ti, 1);
 
+	/*
+	 * inherit parent exec_mode.
+	 */
+	tsk->exec_mode = orig->exec_mode;
+
 	return tsk;
 
 free_ti:
diff -ruw linux-4.2.6/kernel/pid.c linux-4.2.6-fbx/kernel/pid.c
--- linux-4.2.6/kernel/pid.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/kernel/pid.c	2015-11-18 18:24:33.524178469 +0100
@@ -84,7 +84,7 @@
 	.ns.ops = &pidns_operations,
 #endif
 };
-EXPORT_SYMBOL_GPL(init_pid_ns);
+EXPORT_SYMBOL(init_pid_ns);
 
 /*
  * Note: disable interrupts while the pidmap_lock is held as an
diff -ruw linux-4.2.6/kernel/printk/printk.c linux-4.2.6-fbx/kernel/printk/printk.c
--- linux-4.2.6/kernel/printk/printk.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/kernel/printk/printk.c	2015-11-18 18:24:33.528178500 +0100
@@ -55,6 +55,10 @@
 #include "console_cmdline.h"
 #include "braille.h"
 
+#ifdef CONFIG_DEBUG_LL
+extern void printascii(char *);
+#endif
+
 int console_printk[4] = {
 	CONSOLE_LOGLEVEL_DEFAULT,	/* console_loglevel */
 	MESSAGE_LOGLEVEL_DEFAULT,	/* default_message_loglevel */
@@ -1720,6 +1724,10 @@
 	 */
 	text_len = vscnprintf(text, sizeof(textbuf), fmt, args);
 
+#ifdef CONFIG_DEBUG_LL
+	printascii(text);
+#endif
+
 	/* mark and strip a trailing newline */
 	if (text_len && text[text_len-1] == '\n') {
 		text_len--;
diff -ruw linux-4.2.6/kernel/resource.c linux-4.2.6-fbx/kernel/resource.c
--- linux-4.2.6/kernel/resource.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/kernel/resource.c	2015-11-18 18:24:33.532178532 +0100
@@ -358,15 +358,14 @@
 	read_lock(&resource_lock);
 
 	for (p = iomem_resource.child; p; p = next_resource(p, sibling_only)) {
-		if (p->flags != res->flags)
-			continue;
-		if (name && strcmp(p->name, name))
-			continue;
 		if (p->start > end) {
 			p = NULL;
 			break;
 		}
-		if ((p->end >= start) && (p->start < end))
+		if (p->flags != res->flags)
+			continue;
+		if ((p->end >= start) && (p->start < end) &&
+		    (name == NULL || !strcmp(p->name, name)))
 			break;
 	}
 
diff -ruw linux-4.2.6/kernel/sys.c linux-4.2.6-fbx/kernel/sys.c
--- linux-4.2.6/kernel/sys.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/kernel/sys.c	2015-11-18 18:24:33.544178625 +0100
@@ -10,6 +10,7 @@
 #include <linux/mman.h>
 #include <linux/reboot.h>
 #include <linux/prctl.h>
+#include <linux/prctl-private.h>
 #include <linux/highuid.h>
 #include <linux/fs.h>
 #include <linux/kmod.h>
@@ -2267,6 +2268,18 @@
 	case PR_GET_FP_MODE:
 		error = GET_FP_MODE(me);
 		break;
+	case PR_SET_EXEC_MODE:
+		if (arg2 != EXEC_MODE_UNLIMITED &&
+		    arg2 != EXEC_MODE_ONCE &&
+		    arg2 != EXEC_MODE_DENIED)
+			return -EINVAL;
+
+		if (arg2 > current->exec_mode)
+			return -EPERM;
+		current->exec_mode = arg2;
+		return 0;
+	case PR_GET_EXEC_MODE:
+		return current->exec_mode;
 	default:
 		error = -EINVAL;
 		break;
diff -ruw linux-4.2.6/lib/Kconfig linux-4.2.6-fbx/lib/Kconfig
--- linux-4.2.6/lib/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/lib/Kconfig	2015-11-18 18:24:33.564178786 +0100
@@ -531,4 +531,8 @@
 config ARCH_HAS_PMEM_API
 	bool
 
+config FBXSERIAL
+	bool
+	select CRC32
+
 endmenu
diff -ruw linux-4.2.6/lib/Makefile linux-4.2.6-fbx/lib/Makefile
--- linux-4.2.6/lib/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/lib/Makefile	2015-11-18 18:24:33.564178786 +0100
@@ -205,3 +205,6 @@
 clean-files	+= oid_registry_data.c
 
 obj-$(CONFIG_UCS2_STRING) += ucs2_string.o
+
+obj-$(CONFIG_FBXSERIAL) += fbxserial.o
+
diff -ruw linux-4.2.6/net/8021q/vlan.c linux-4.2.6-fbx/net/8021q/vlan.c
--- linux-4.2.6/net/8021q/vlan.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/8021q/vlan.c	2015-11-18 18:24:33.620179233 +0100
@@ -208,7 +208,7 @@
 /*  Attach a VLAN device to a mac address (ie Ethernet Card).
  *  Returns 0 if the device was created or a negative error code otherwise.
  */
-static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
+int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
 {
 	struct net_device *new_dev;
 	struct vlan_dev_priv *vlan;
diff -ruw linux-4.2.6/net/8021q/vlan_core.c linux-4.2.6-fbx/net/8021q/vlan_core.c
--- linux-4.2.6/net/8021q/vlan_core.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/8021q/vlan_core.c	2015-11-18 18:24:33.620179233 +0100
@@ -89,6 +89,12 @@
 }
 EXPORT_SYMBOL(__vlan_find_dev_deep_rcu);
 
+struct net_device *vlan_dev_upper_dev(const struct net_device *dev)
+{
+	return vlan_dev_priv(dev)->real_dev;
+}
+EXPORT_SYMBOL(vlan_dev_upper_dev);
+
 struct net_device *vlan_dev_real_dev(const struct net_device *dev)
 {
 	struct net_device *ret = vlan_dev_priv(dev)->real_dev;
diff -ruw linux-4.2.6/net/bridge/br_fdb.c linux-4.2.6-fbx/net/bridge/br_fdb.c
--- linux-4.2.6/net/bridge/br_fdb.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/bridge/br_fdb.c	2015-11-18 18:24:33.648179459 +0100
@@ -472,6 +472,14 @@
 	return NULL;
 }
 
+struct net_bridge_fdb_entry *br_fdb_find(struct net_bridge *br,
+					 const unsigned char *addr,
+					 __u16 vid)
+{
+        struct hlist_head *head = &br->hash[br_mac_hash(addr, vid)];
+	return fdb_find(head, addr, vid);
+}
+
 static struct net_bridge_fdb_entry *fdb_find_rcu(struct hlist_head *head,
 						 const unsigned char *addr,
 						 __u16 vid)
@@ -552,6 +560,21 @@
 	return ret;
 }
 
+bool br_fdb_update_only(struct net_bridge *br,
+			struct net_bridge_port *source,
+			const unsigned char *addr)
+{
+	struct net_bridge_fdb_entry *fdb;
+	struct hlist_head *head = &br->hash[br_mac_hash(addr, 0)];
+
+	fdb = fdb_find(head, addr, 0);
+	if (!fdb)
+		return false;
+
+	fdb->updated = jiffies;
+	return true;
+}
+
 void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
 		   const unsigned char *addr, u16 vid, bool added_by_user)
 {
diff -ruw linux-4.2.6/net/bridge/br_private.h linux-4.2.6-fbx/net/bridge/br_private.h
--- linux-4.2.6/net/bridge/br_private.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/bridge/br_private.h	2015-11-18 18:24:33.652179485 +0100
@@ -395,6 +395,12 @@
 		   unsigned long off);
 int br_fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
 		  const unsigned char *addr, u16 vid);
+struct net_bridge_fdb_entry *br_fdb_find(struct net_bridge *br,
+					 const unsigned char *addr,
+					 __u16 vid);
+bool br_fdb_update_only(struct net_bridge *br,
+			struct net_bridge_port *source,
+			const unsigned char *addr);
 void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
 		   const unsigned char *addr, u16 vid, bool added_by_user);
 
diff -ruw linux-4.2.6/net/core/dev.c linux-4.2.6-fbx/net/core/dev.c
--- linux-4.2.6/net/core/dev.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/core/dev.c	2015-11-18 18:24:33.664179588 +0100
@@ -136,6 +136,7 @@
 #include <linux/errqueue.h>
 #include <linux/hrtimer.h>
 #include <linux/netfilter_ingress.h>
+#include <linux/kthread.h>
 
 #include "net-sysfs.h"
 
@@ -156,6 +157,10 @@
 					 struct net_device *dev,
 					 struct netdev_notifier_info *info);
 
+#ifdef CONFIG_NETRXTHREAD
+struct krxd gkrxd[CONFIG_NETRXTHREAD_RX_QUEUE];
+#endif
+
 /*
  * The @dev_base_head list is protected by @dev_base_lock and the rtnl
  * semaphore.
@@ -3515,6 +3520,23 @@
 	return ret;
 }
 
+/* Start Freebox added code */
+#if defined(CONFIG_FREEBOX_DIVERTER) || defined(CONFIG_FREEBOX_DIVERTER_MODULE)
+int (*fbxdiverter_hook)(struct sk_buff *);
+
+static int handle_fbxdiverter(struct sk_buff *skb)
+{
+	/* try_module_get is missing here, so there is a race on
+	 * fbxdiverter module deletion */
+	if (!fbxdiverter_hook)
+		return 0;
+	return fbxdiverter_hook(skb);
+}
+
+EXPORT_SYMBOL(fbxdiverter_hook);
+#endif
+
+
 /**
  *	netif_rx	-	post buffer to the network code
  *	@skb: buffer to post
@@ -3623,6 +3645,36 @@
 EXPORT_SYMBOL_GPL(br_fdb_test_addr_hook);
 #endif
 
+#ifdef CONFIG_FBXBRIDGE
+struct sk_buff *(*fbxbridge_handle_frame_hook)(struct fbxbridge *p, struct sk_buff *skb);
+
+struct fbxbridge;
+
+static inline struct sk_buff *handle_fbxbridge(struct sk_buff *skb,
+					       struct packet_type **pt_prev, int *ret,
+					       struct net_device *orig_dev)
+{
+	struct fbxbridge *fbxbr;
+
+	if (skb->pkt_type == PACKET_LOOPBACK ||
+	    (fbxbr = skb->dev->fbx_bridge_port) == NULL)
+		return skb;
+
+	if (skb->protocol != __constant_htons(ETH_P_IP) &&
+	    skb->protocol != __constant_htons(ETH_P_ARP))
+		return skb;
+
+	if (*pt_prev) {
+		*ret = deliver_skb(skb, *pt_prev, orig_dev);
+		*pt_prev = NULL;
+	}
+
+	return fbxbridge_handle_frame_hook(fbxbr, skb);
+}
+#else
+#define handle_fbxbridge(skb, pt_prev, ret, orig_dev)   (skb)
+#endif
+
 static inline struct sk_buff *handle_ing(struct sk_buff *skb,
 					 struct packet_type **pt_prev,
 					 int *ret, struct net_device *orig_dev)
@@ -3761,17 +3813,7 @@
 	int ret = NET_RX_DROP;
 	__be16 type;
 
-	net_timestamp_check(!netdev_tstamp_prequeue, skb);
-
-	trace_netif_receive_skb(skb);
-
 	orig_dev = skb->dev;
-
-	skb_reset_network_header(skb);
-	if (!skb_transport_header_was_set(skb))
-		skb_reset_transport_header(skb);
-	skb_reset_mac_len(skb);
-
 	pt_prev = NULL;
 
 another_round:
@@ -3809,6 +3851,9 @@
 	}
 
 skip_taps:
+	skb = handle_fbxbridge(skb, &pt_prev, &ret, orig_dev);
+	if (!skb)
+		goto out;
 #ifdef CONFIG_NET_INGRESS
 	if (static_key_false(&ingress_needed)) {
 		skb = handle_ing(skb, &pt_prev, &ret, orig_dev);
@@ -3904,7 +3949,9 @@
 	return ret;
 }
 
-static int __netif_receive_skb(struct sk_buff *skb)
+static int __netif_receive_skb(struct sk_buff *skb);
+
+static int __netif_receive_skb_end(struct sk_buff *skb)
 {
 	int ret;
 
@@ -3957,6 +4004,88 @@
 	return ret;
 }
 
+#ifdef CONFIG_NETRXTHREAD
+
+static int krxd_action(void *data)
+{
+	struct krxd *krxd = (struct krxd *)data;
+	unsigned int queue = krxd - gkrxd;
+	struct sk_buff *skb;
+
+	set_user_nice(current, queue > 0 ? -10 : -5);
+	current->flags |= PF_NOFREEZE;
+	__set_current_state(TASK_RUNNING);
+
+	local_bh_disable();
+	while (1) {
+		skb = skb_dequeue(&krxd->pkt_queue);
+		if (!skb) {
+			local_bh_enable();
+			wait_event_interruptible(krxd->wq,
+					 skb_queue_len(&krxd->pkt_queue));
+			set_current_state(TASK_RUNNING);
+			local_bh_disable();
+			continue;
+		}
+
+		__netif_receive_skb_end(skb);
+
+		/* only schedule when working on lowest prio queue */
+		if (queue == 0) {
+			if (need_resched()) {
+				local_bh_enable();
+				schedule();
+				local_bh_disable();
+			}
+		}
+	}
+	return 0;
+}
+#endif /* RXTHREAD */
+
+static int __netif_receive_skb(struct sk_buff *skb)
+{
+#ifdef CONFIG_NETRXTHREAD
+	unsigned int len;
+	struct krxd *krxd;
+#endif
+	net_timestamp_check(!netdev_tstamp_prequeue, skb);
+
+	trace_netif_receive_skb(skb);
+
+	skb_reset_network_header(skb);
+	if (!skb_transport_header_was_set(skb))
+		skb_reset_transport_header(skb);
+	skb_reset_mac_len(skb);
+
+#if defined(CONFIG_FREEBOX_DIVERTER) || defined(CONFIG_FREEBOX_DIVERTER_MODULE)
+	if (handle_fbxdiverter(skb))
+		return NET_RX_SUCCESS;
+#endif
+
+#ifndef CONFIG_NETRXTHREAD
+	return __netif_receive_skb_end(skb);
+#else
+	BUILD_BUG_ON(ARRAY_SIZE(gkrxd) < 2);
+	krxd = &gkrxd[skb->rxthread_prio & 1];
+
+	/* queue the packet to the rx thread */
+	local_bh_disable();
+	len = skb_queue_len(&krxd->pkt_queue);
+	if (len < RXTHREAD_MAX_PKTS) {
+		__skb_queue_tail(&krxd->pkt_queue, skb);
+		krxd->stats_pkts++;
+		if (!len)
+			wake_up(&krxd->wq);
+	} else {
+		krxd->stats_dropped++;
+		dev_kfree_skb(skb);
+	}
+	local_bh_enable();
+	return NET_RX_SUCCESS;
+#endif
+}
+
 /**
  *	netif_receive_skb - process receive buffer from network
  *	@skb: buffer to process
@@ -6706,7 +6835,7 @@
 			rebroadcast_time = jiffies;
 		}
 
-		msleep(250);
+		msleep(1);
 
 		refcnt = netdev_refcnt_read(dev);
 
@@ -7638,6 +7767,23 @@
 	open_softirq(NET_TX_SOFTIRQ, net_tx_action);
 	open_softirq(NET_RX_SOFTIRQ, net_rx_action);
 
+#ifdef CONFIG_NETRXTHREAD
+	for (i = 0; i < CONFIG_NETRXTHREAD_RX_QUEUE; i++) {
+		struct krxd *krxd = &gkrxd[i];
+		struct task_struct *task;
+
+		skb_queue_head_init(&krxd->pkt_queue);
+		init_waitqueue_head(&krxd->wq);
+		task = kthread_create(krxd_action, krxd, "krxthread_%u", i);
+		if (IS_ERR(task)) {
+			printk(KERN_ERR "unable to create krxd\n");
+			return -ENOMEM;
+		}
+		krxd->task = task;
+		wake_up_process(task);
+	}
+#endif
+
 	hotcpu_notifier(dev_cpu_callback, 0);
 	dst_init();
 	rc = 0;
@@ -7646,3 +7792,7 @@
 }
 
 subsys_initcall(net_dev_init);
+
+#if defined(CONFIG_FBXBRIDGE_MODULE)
+EXPORT_SYMBOL(fbxbridge_handle_frame_hook);
+#endif
diff -ruw linux-4.2.6/net/core/net-procfs.c linux-4.2.6-fbx/net/core/net-procfs.c
--- linux-4.2.6/net/core/net-procfs.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/core/net-procfs.c	2015-11-18 18:24:33.672179640 +0100
@@ -311,6 +311,83 @@
 	.release = seq_release_net,
 };
 
+#ifdef CONFIG_NETRXTHREAD
+/*
+ *	This is invoked by the /proc filesystem handler to display a device
+ *	in detail.
+ */
+static void *krxthread_seq_start(struct seq_file *seq, loff_t *pos)
+{
+	int *queue;
+
+	if (*pos > CONFIG_NETRXTHREAD_RX_QUEUE)
+		return NULL;
+
+	queue = kmalloc(sizeof(*queue), GFP_KERNEL);
+	if (!queue)
+		return NULL;
+	*queue = ((int)*pos - 1);
+
+	return queue;
+}
+
+static void *krxthread_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+	int *queue = v;
+
+	if (*pos == CONFIG_NETRXTHREAD_RX_QUEUE)
+		return NULL;
+
+	++*queue;
+	*pos = *queue + 1;
+	return queue;
+}
+
+static void krxthread_seq_stop(struct seq_file *seq, void *v)
+{
+	kfree(v);
+}
+
+static void krxthread_seq_printf_stats(struct seq_file *seq, int queue)
+{
+	seq_printf(seq, "%8u %12u %12u\n",
+		   queue,
+		   gkrxd[queue].stats_pkts,
+		   gkrxd[queue].stats_dropped);
+}
+
+static int krxthread_seq_show(struct seq_file *seq, void *v)
+{
+	int *queue = v;
+
+	if (*queue == -1)
+		seq_printf(seq, "%8s %12s %12s\n",
+			   "queue", "packets", "drops");
+	else
+		krxthread_seq_printf_stats(seq, *queue);
+	return 0;
+}
+
+static const struct seq_operations krxthread_seq_ops = {
+	.start = krxthread_seq_start,
+	.next  = krxthread_seq_next,
+	.stop  = krxthread_seq_stop,
+	.show  = krxthread_seq_show,
+};
+
+static int krxthread_seq_open(struct inode *inode, struct file *file)
+{
+	return seq_open(file, &krxthread_seq_ops);
+}
+
+static const struct file_operations krxthread_seq_fops = {
+	.owner	 = THIS_MODULE,
+	.open    = krxthread_seq_open,
+	.read    = seq_read,
+	.llseek  = seq_lseek,
+	.release = seq_release,
+};
+#endif /* KRXTHREAD */
 
 static int __net_init dev_proc_net_init(struct net *net)
 {
@@ -323,9 +400,13 @@
 		goto out_dev;
 	if (!proc_create("ptype", S_IRUGO, net->proc_net, &ptype_seq_fops))
 		goto out_softnet;
-
 	if (wext_proc_init(net))
 		goto out_ptype;
+#ifdef CONFIG_NETRXTHREAD
+	if (!proc_create("krxthread", S_IRUGO, net->proc_net,
+			 &krxthread_seq_fops))
+		goto out_ptype;
+#endif
 	rc = 0;
 out:
 	return rc;
diff -ruw linux-4.2.6/net/core/skbuff.c linux-4.2.6-fbx/net/core/skbuff.c
--- linux-4.2.6/net/core/skbuff.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/core/skbuff.c	2015-11-18 18:24:33.676179674 +0100
@@ -774,6 +774,10 @@
 	memcpy(&new->headers_start, &old->headers_start,
 	       offsetof(struct sk_buff, headers_end) -
 	       offsetof(struct sk_buff, headers_start));
+
+#ifdef CONFIG_IP_FFN
+	new->ffn_state		= FFN_STATE_INIT;
+#endif
 	CHECK_SKB_FIELD(protocol);
 	CHECK_SKB_FIELD(csum);
 	CHECK_SKB_FIELD(hash);
@@ -824,6 +828,9 @@
 	C(mac_len);
 	n->hdr_len = skb->nohdr ? skb_headroom(skb) : skb->hdr_len;
 	n->cloned = 1;
+#ifdef CONFIG_FBXBRIDGE
+	n->fbxbridge_state = 0;
+#endif
 	n->nohdr = 0;
 	n->destructor = NULL;
 	C(tail);
@@ -1181,6 +1188,9 @@
 	skb->cloned   = 0;
 	skb->hdr_len  = 0;
 	skb->nohdr    = 0;
+#ifdef CONFIG_FBXBRIDGE
+	skb->fbxbridge_state = 0;
+#endif
 	atomic_set(&skb_shinfo(skb)->dataref, 1);
 	return 0;
 
@@ -1636,6 +1646,10 @@
 	skb->tail     += delta;
 	skb->data_len -= delta;
 
+#ifdef CONFIG_FBXBRIDGE
+	skb->fbxbridge_state = 0;
+#endif
+
 	return skb_tail_pointer(skb);
 }
 EXPORT_SYMBOL(__pskb_pull_tail);
diff -ruw linux-4.2.6/net/core/sock.c linux-4.2.6-fbx/net/core/sock.c
--- linux-4.2.6/net/core/sock.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/core/sock.c	2015-11-18 18:24:33.676179674 +0100
@@ -988,6 +988,10 @@
 					 sk->sk_max_pacing_rate);
 		break;
 
+	case SO_UDP_DUP_UNICAST:
+		sock_valbool_flag(sk, SOCK_UDP_DUP_UNICAST, valbool);
+		break;
+
 	default:
 		ret = -ENOPROTOOPT;
 		break;
@@ -1248,6 +1252,10 @@
 		v.val = sk->sk_incoming_cpu;
 		break;
 
+	case SO_UDP_DUP_UNICAST:
+		v.val = sock_flag(sk, SOCK_UDP_DUP_UNICAST);
+		break;
+
 	default:
 		/* We implement the SO_SNDLOWAT etc to not be settable
 		 * (1003.1g 7).
diff -ruw linux-4.2.6/net/ipv4/ipconfig.c linux-4.2.6-fbx/net/ipv4/ipconfig.c
--- linux-4.2.6/net/ipv4/ipconfig.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv4/ipconfig.c	2015-11-18 18:24:33.708179927 +0100
@@ -189,15 +189,61 @@
 static struct ic_device *ic_first_dev __initdata;	/* List of open device */
 static struct net_device *ic_dev __initdata;		/* Selected device */
 
-static bool __init ic_is_init_dev(struct net_device *dev)
+static bool __init ic_is_init_dev(struct net_device *dev, bool partial)
 {
+	char *p = NULL;
+	bool ret;
+
 	if (dev->flags & IFF_LOOPBACK)
 		return false;
-	return user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
+
+	if (partial) {
+		p = strchr(user_dev_name, '.');
+		if (p)
+			*p = 0;
+	}
+
+	ret = false;
+	if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
 	    (!(dev->flags & IFF_LOOPBACK) &&
 	     (dev->flags & (IFF_POINTOPOINT|IFF_BROADCAST)) &&
-	     strncmp(dev->name, "dummy", 5));
+	     strncmp(dev->name, "dummy", 5)))
+		ret = true;
+	if (p)
+		*p = '.';
+	return ret;
+}
+
+#ifdef CONFIG_VLAN_8021Q
+int register_vlan_device(struct net_device *real_dev, u16 vlan_id);
+
+static void __init prepare_vlan(void)
+{
+	unsigned short oflags;
+	struct net_device *dev;
+	char *p;
+	u16 vid;
+
+	if (!strchr(user_dev_name, '.'))
+		return;
+
+	p = strchr(user_dev_name, '.');
+	*p = 0;
+	vid = simple_strtoul(p + 1, NULL, 10);
+	dev = __dev_get_by_name(&init_net, user_dev_name);
+	if (!dev)
+		goto fail;
+
+	oflags = dev->flags;
+	if (dev_change_flags(dev, oflags | IFF_UP) < 0)
+		goto fail;
+
+	register_vlan_device(dev, vid);
+
+fail:
+	*p = '.';
 }
+#endif
 
 static int __init ic_open_devs(void)
 {
@@ -217,8 +263,13 @@
 			pr_err("IP-Config: Failed to open %s\n", dev->name);
 	}
 
+#ifdef CONFIG_VLAN_8021Q
+	/* register vlan device if needed */
+	prepare_vlan();
+#endif
+
 	for_each_netdev(&init_net, dev) {
-		if (ic_is_init_dev(dev)) {
+		if (ic_is_init_dev(dev, false)) {
 			int able = 0;
 			if (dev->mtu >= 364)
 				able |= IC_BOOTP;
@@ -267,7 +318,7 @@
 		int wait, elapsed;
 
 		for_each_netdev(&init_net, dev)
-			if (ic_is_init_dev(dev) && netif_carrier_ok(dev))
+			if (ic_is_init_dev(dev, false) && netif_carrier_ok(dev))
 				goto have_carrier;
 
 		msleep(1);
@@ -720,8 +771,10 @@
 			e += len;
 		}
 		if (*vendor_class_identifier) {
+#ifdef IPCONFIG_DEBUG
 			pr_info("DHCP: sending class identifier \"%s\"\n",
 				vendor_class_identifier);
+#endif
 			*e++ = 60;	/* Class-identifier */
 			len = strlen(vendor_class_identifier);
 			*e++ = len;
@@ -1379,7 +1432,7 @@
 
 		rtnl_lock();
 		for_each_netdev(&init_net, dev) {
-			if (ic_is_init_dev(dev)) {
+			if (ic_is_init_dev(dev, true)) {
 				found = 1;
 				break;
 			}
diff -ruw linux-4.2.6/net/ipv4/ip_input.c linux-4.2.6-fbx/net/ipv4/ip_input.c
--- linux-4.2.6/net/ipv4/ip_input.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv4/ip_input.c	2015-11-18 18:24:33.704179894 +0100
@@ -187,10 +187,15 @@
 	return false;
 }
 
-static int ip_local_deliver_finish(struct sock *sk, struct sk_buff *skb)
+int ip_local_deliver_finish(struct sock *sk, struct sk_buff *skb)
 {
 	struct net *net = dev_net(skb->dev);
 
+#ifdef CONFIG_IP_FFN
+	if (skb->ffn_state == FFN_STATE_FORWARDABLE)
+		ip_ffn_add(skb, IP_FFN_LOCAL_IN);
+#endif
+
 	__skb_pull(skb, skb_network_header_len(skb));
 
 	rcu_read_lock();
@@ -452,6 +457,11 @@
 	/* Must drop socket now because of tproxy. */
 	skb_orphan(skb);
 
+#ifdef CONFIG_IP_FFN
+	if (!ip_ffn_process(skb))
+		return NET_RX_SUCCESS;
+#endif
+
 	return NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, NULL, skb,
 		       dev, NULL,
 		       ip_rcv_finish);
diff -ruw linux-4.2.6/net/ipv4/ip_output.c linux-4.2.6-fbx/net/ipv4/ip_output.c
--- linux-4.2.6/net/ipv4/ip_output.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv4/ip_output.c	2015-11-18 18:24:33.704179894 +0100
@@ -201,6 +201,11 @@
 		skb = skb2;
 	}
 
+#ifdef CONFIG_IP_FFN
+	if (skb->ffn_state == FFN_STATE_FORWARDABLE)
+		ip_ffn_add(skb, IP_FFN_FINISH_OUT);
+#endif
+
 	rcu_read_lock_bh();
 	nexthop = (__force u32) rt_nexthop(rt, ip_hdr(skb)->daddr);
 	neigh = __ipv4_neigh_lookup_noref(dev, nexthop);
@@ -208,7 +213,6 @@
 		neigh = __neigh_create(&arp_tbl, &nexthop, dev, false);
 	if (!IS_ERR(neigh)) {
 		int res = dst_neigh_output(dst, neigh, skb);
-
 		rcu_read_unlock_bh();
 		return res;
 	}
@@ -353,6 +357,11 @@
 	skb->dev = dev;
 	skb->protocol = htons(ETH_P_IP);
 
+#ifdef CONFIG_IP_FFN
+	if (skb->ffn_state == FFN_STATE_FAST_FORWARDED)
+		return ip_finish_output(sk, skb);
+#endif
+
 	return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, sk, skb,
 			    NULL, dev,
 			    ip_finish_output,
@@ -1606,4 +1615,7 @@
 #if defined(CONFIG_IP_MULTICAST)
 	igmp_mc_init();
 #endif
+#ifdef CONFIG_IP_FFN
+	ip_ffn_init();
+#endif
 }
diff -ruw linux-4.2.6/net/ipv4/ip_tunnel_core.c linux-4.2.6-fbx/net/ipv4/ip_tunnel_core.c
--- linux-4.2.6/net/ipv4/ip_tunnel_core.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv4/ip_tunnel_core.c	2015-11-18 18:24:33.704179894 +0100
@@ -45,6 +45,9 @@
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
 #include <net/rtnetlink.h>
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+#include <net/netfilter/nf_conntrack.h>
+#endif
 
 int iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
 		  __be32 src, __be32 dst, __u8 proto,
@@ -57,6 +60,13 @@
 	skb_scrub_packet(skb, xnet);
 
 	skb_clear_hash(skb);
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+	if (proto == IPPROTO_IPV6) {
+		skb->nfct = &nf_ct_untracked_get()->ct_general;
+		skb->nfctinfo = IP_CT_NEW;
+		nf_conntrack_get(skb->nfct);
+	}
+#endif
 	skb_dst_set(skb, &rt->dst);
 	memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
 
diff -ruw linux-4.2.6/net/ipv4/Kconfig linux-4.2.6-fbx/net/ipv4/Kconfig
--- linux-4.2.6/net/ipv4/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv4/Kconfig	2015-11-18 18:24:33.692179801 +0100
@@ -391,6 +391,11 @@
 	tristate
 	default n
 
+config INET_XFRM_GC_THRESH
+	int "IP: xfrm garbage collect threshold"
+	depends on XFRM
+	default 32768
+
 config INET_XFRM_MODE_TRANSPORT
 	tristate "IP: IPsec transport mode"
 	default y
diff -ruw linux-4.2.6/net/ipv4/Makefile linux-4.2.6-fbx/net/ipv4/Makefile
--- linux-4.2.6/net/ipv4/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv4/Makefile	2015-11-18 18:24:33.692179801 +0100
@@ -15,6 +15,8 @@
 
 obj-$(CONFIG_NET_IP_TUNNEL) += ip_tunnel.o
 obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o
+
+obj-$(CONFIG_IP_FFN) += ip_ffn.o
 obj-$(CONFIG_PROC_FS) += proc.o
 obj-$(CONFIG_IP_MULTIPLE_TABLES) += fib_rules.o
 obj-$(CONFIG_IP_MROUTE) += ipmr.o
diff -ruw linux-4.2.6/net/ipv4/netfilter/ip_tables.c linux-4.2.6-fbx/net/ipv4/netfilter/ip_tables.c
--- linux-4.2.6/net/ipv4/netfilter/ip_tables.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv4/netfilter/ip_tables.c	2015-11-18 18:24:33.708179927 +0100
@@ -30,6 +30,9 @@
 #include <linux/netfilter_ipv4/ip_tables.h>
 #include <net/netfilter/nf_log.h>
 #include "../../netfilter/xt_repldata.h"
+#ifdef CONFIG_FBXBRIDGE
+#include <linux/fbxbridge.h>
+#endif
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
@@ -1287,6 +1290,14 @@
 			   tmp.num_counters, tmp.counters);
 	if (ret)
 		goto free_newinfo_untrans;
+
+#ifdef CONFIG_IP_FFN
+	ip_ffn_flush_all();
+#endif
+
+#if defined(CONFIG_FBXBRIDGE) || defined(CONFIG_FBXBRIDGE_MODULE)
+	fbxbridge_fp_flush_all();
+#endif
 	return 0;
 
  free_newinfo_untrans:
diff -ruw linux-4.2.6/net/ipv4/netfilter/Kconfig linux-4.2.6-fbx/net/ipv4/netfilter/Kconfig
--- linux-4.2.6/net/ipv4/netfilter/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv4/netfilter/Kconfig	2015-11-18 18:24:33.708179927 +0100
@@ -5,6 +5,13 @@
 menu "IP: Netfilter Configuration"
 	depends on INET && NETFILTER
 
+config IP_FFN
+	bool "IP: Fast forwarding and NAT"
+
+config IP_FFN_PROCFS
+	bool "IP: Fast forwarding and NAT /proc/net entries"
+	depends on IP_FFN
+
 config NF_DEFRAG_IPV4
 	tristate
 	default n
diff -ruw linux-4.2.6/net/ipv4/udp.c linux-4.2.6-fbx/net/ipv4/udp.c
--- linux-4.2.6/net/ipv4/udp.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv4/udp.c	2015-11-18 18:24:33.724180055 +0100
@@ -211,6 +211,8 @@
 				       const struct sock *sk2),
 		     unsigned int hash2_nulladdr)
 {
+	struct sock *sk2;
+	struct hlist_nulls_node *node;
 	struct udp_hslot *hslot, *hslot2;
 	struct udp_table *udptable = sk->sk_prot->h.udp_table;
 	int    error = 1;
@@ -290,6 +292,48 @@
 	inet_sk(sk)->inet_num = snum;
 	udp_sk(sk)->udp_port_hash = snum;
 	udp_sk(sk)->udp_portaddr_hash ^= snum;
+
+	/* resolve udp reuse conflict */
+	if (sk->sk_reuse) {
+		bool found;
+
+		found = false;
+		sk_nulls_for_each(sk2, node, &hslot->head) {
+			if (!net_eq(sock_net(sk2), net) ||
+			    sk2 == sk ||
+			    (udp_sk(sk2)->udp_port_hash != snum))
+				continue;
+
+			if (sk2->sk_bound_dev_if &&
+			    sk->sk_bound_dev_if &&
+			    sk2->sk_bound_dev_if != sk->sk_bound_dev_if)
+				continue;
+
+			if (!(*saddr_comp)(sk, sk2))
+				continue;
+
+			found = true;
+			break;
+		}
+
+		sk_nulls_for_each(sk2, node, &hslot->head) {
+			if (!net_eq(sock_net(sk2), net) ||
+			    sk2 == sk ||
+			    (udp_sk(sk2)->udp_port_hash != snum))
+				continue;
+
+			if (sk2->sk_bound_dev_if &&
+			    sk->sk_bound_dev_if &&
+			    sk2->sk_bound_dev_if != sk->sk_bound_dev_if)
+				continue;
+
+			if (!(*saddr_comp)(sk, sk2))
+				continue;
+
+			sk->sk_reuse_conflict = found;
+		}
+	}
+
 	if (sk_unhashed(sk)) {
 		sk_nulls_add_node_rcu(sk, &hslot->head);
 		hslot->count++;
@@ -1712,6 +1756,56 @@
 	return 0;
 }
 
+/*
+ *	Unicast goes to one listener and all sockets with dup flag
+ *
+ *	Note: called only from the BH handler context.
+ */
+static int __udp4_lib_uc_conflict_deliver(struct net *net, struct sk_buff *skb,
+					  struct udphdr  *uh,
+					  __be32 saddr, __be32 daddr,
+					  struct udp_table *udptable)
+{
+	struct sock *sk, *stack[256 / sizeof(struct sock *)];
+	struct udp_hslot *hslot = udp_hashslot(udptable, net, ntohs(uh->dest));
+	struct hlist_nulls_node *node;
+	int dif;
+	unsigned int count = 0, non_dup_count = 0;
+
+	spin_lock(&hslot->lock);
+	sk = sk_nulls_head(&hslot->head);
+	dif = skb->dev->ifindex;
+	sk_nulls_for_each(sk, node, &hslot->head) {
+		if (!sock_flag(sk, SOCK_UDP_DUP_UNICAST)) {
+			if (!non_dup_count) {
+				stack[count++] = sk;
+				sock_hold(sk);
+			}
+			non_dup_count = 1;
+		} else {
+			stack[count++] = sk;
+			sock_hold(sk);
+		}
+
+		if (unlikely(count == ARRAY_SIZE(stack))) {
+			flush_stack(stack, count, skb, ~0);
+			count = 0;
+		}
+	}
+
+	spin_unlock(&hslot->lock);
+
+	/*
+	 * do the slow work with no lock held
+	 */
+	if (count) {
+		flush_stack(stack, count, skb, count - 1);
+	} else {
+		kfree_skb(skb);
+	}
+	return 0;
+}
+
 /* Initialize UDP checksum. If exited with zero value (success),
  * CHECKSUM_UNNECESSARY means, that no more checks are required.
  * Otherwise, csum completion requires chacksumming packet body,
@@ -1781,6 +1875,13 @@
 		if (unlikely(sk->sk_rx_dst != dst))
 			udp_sk_rx_dst_set(sk, dst);
 
+		if (sk->sk_reuse_conflict) {
+			sock_put(sk);
+			return __udp4_lib_uc_conflict_deliver(net, skb, uh,
+							      saddr, daddr,
+							      udptable);
+		}
+
 		ret = udp_queue_rcv_skb(sk, skb);
 		sock_put(sk);
 		/* a return value > 0 means to resubmit the input, but
diff -ruw linux-4.2.6/net/ipv4/xfrm4_policy.c linux-4.2.6-fbx/net/ipv4/xfrm4_policy.c
--- linux-4.2.6/net/ipv4/xfrm4_policy.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv4/xfrm4_policy.c	2015-11-18 18:24:33.728180095 +0100
@@ -239,7 +239,7 @@
 	.destroy =		xfrm4_dst_destroy,
 	.ifdown =		xfrm4_dst_ifdown,
 	.local_out =		__ip_local_out,
-	.gc_thresh =		32768,
+	.gc_thresh =		CONFIG_INET_XFRM_GC_THRESH,
 };
 
 static struct xfrm_policy_afinfo xfrm4_policy_afinfo = {
diff -ruw linux-4.2.6/net/ipv6/af_inet6.c linux-4.2.6-fbx/net/ipv6/af_inet6.c
--- linux-4.2.6/net/ipv6/af_inet6.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv6/af_inet6.c	2015-11-18 18:24:33.732180119 +0100
@@ -940,6 +940,10 @@
 	if (err)
 		goto udpv6_fail;
 
+#ifdef CONFIG_IPV6_FFN
+	ipv6_ffn_init();
+#endif
+
 	err = udplitev6_init();
 	if (err)
 		goto udplitev6_fail;
diff -ruw linux-4.2.6/net/ipv6/ip6_input.c linux-4.2.6-fbx/net/ipv6/ip6_input.c
--- linux-4.2.6/net/ipv6/ip6_input.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv6/ip6_input.c	2015-11-18 18:24:33.736180147 +0100
@@ -182,6 +182,11 @@
 	/* Must drop socket now because of tproxy. */
 	skb_orphan(skb);
 
+#ifdef CONFIG_IPV6_FFN
+	if (!ipv6_ffn_process(skb))
+		return NET_RX_SUCCESS;
+#endif
+
 	return NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, NULL, skb,
 		       dev, NULL,
 		       ip6_rcv_finish);
@@ -198,7 +203,7 @@
  */
 
 
-static int ip6_input_finish(struct sock *sk, struct sk_buff *skb)
+int ip6_input_finish(struct sock *sk, struct sk_buff *skb)
 {
 	struct net *net = dev_net(skb_dst(skb)->dev);
 	const struct inet6_protocol *ipprot;
@@ -207,6 +212,11 @@
 	int nexthdr;
 	bool raw;
 
+#ifdef CONFIG_IPV6_FFN
+	if (skb->ffn_state == FFN_STATE_FORWARDABLE)
+		ipv6_ffn_add(skb, IPV6_FFN_LOCAL_IN);
+#endif
+
 	/*
 	 *	Parse extension headers
 	 */
diff -ruw linux-4.2.6/net/ipv6/ip6_output.c linux-4.2.6-fbx/net/ipv6/ip6_output.c
--- linux-4.2.6/net/ipv6/ip6_output.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv6/ip6_output.c	2015-11-18 18:24:33.736180147 +0100
@@ -54,6 +54,7 @@
 #include <net/icmp.h>
 #include <net/xfrm.h>
 #include <net/checksum.h>
+#include <net/dsfield.h>
 #include <linux/mroute6.h>
 
 static int ip6_finish_output2(struct sock *sk, struct sk_buff *skb)
@@ -104,6 +105,11 @@
 		}
 	}
 
+#ifdef CONFIG_IPV6_FFN
+	if (skb->ffn_state == FFN_STATE_FORWARDABLE)
+		ipv6_ffn_add(skb, IPV6_FFN_FINISH_OUT);
+#endif
+
 	rcu_read_lock_bh();
 	nexthop = rt6_nexthop((struct rt6_info *)dst, &ipv6_hdr(skb)->daddr);
 	neigh = __ipv6_neigh_lookup_noref(dst->dev, nexthop);
@@ -143,6 +149,11 @@
 		return 0;
 	}
 
+#ifdef CONFIG_IP_FFN
+	if (skb->ffn_state == FFN_STATE_FAST_FORWARDED)
+		return ip6_finish_output(sk, skb);
+#endif
+
 	return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING, sk, skb,
 			    NULL, dev,
 			    ip6_finish_output,
@@ -510,6 +521,8 @@
 
 	hdr->hop_limit--;
 
+	skb->priority = rt_tos2priority(ipv6_get_dsfield(hdr));
+
 	IP6_INC_STATS_BH(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS);
 	IP6_ADD_STATS_BH(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len);
 	return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, NULL, skb,
diff -ruw linux-4.2.6/net/ipv6/ip6_tunnel.c linux-4.2.6-fbx/net/ipv6/ip6_tunnel.c
--- linux-4.2.6/net/ipv6/ip6_tunnel.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv6/ip6_tunnel.c	2015-11-18 18:24:33.736180147 +0100
@@ -16,6 +16,8 @@
  *      as published by the Free Software Foundation; either version
  *      2 of the License, or (at your option) any later version.
  *
+ *	Changes:
+ * Steven Barth <cyrus@openwrt.org>:		MAP-E FMR support
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -71,11 +73,9 @@
 module_param(log_ecn_error, bool, 0644);
 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
 
-static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
+static u32 HASH(const struct in6_addr *addr)
 {
-	u32 hash = ipv6_addr_hash(addr1) ^ ipv6_addr_hash(addr2);
-
-	return hash_32(hash, HASH_SIZE_SHIFT);
+	return hash_32(ipv6_addr_hash(addr), HASH_SIZE_SHIFT);
 }
 
 static int ip6_tnl_dev_init(struct net_device *dev);
@@ -174,27 +174,36 @@
 static struct ip6_tnl *
 ip6_tnl_lookup(struct net *net, const struct in6_addr *remote, const struct in6_addr *local)
 {
-	unsigned int hash = HASH(remote, local);
+	unsigned int hash = HASH(local);
 	struct ip6_tnl *t;
 	struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
 	struct in6_addr any;
+	struct __ip6_tnl_fmr *fmr;
 
 	for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
-		if (ipv6_addr_equal(local, &t->parms.laddr) &&
-		    ipv6_addr_equal(remote, &t->parms.raddr) &&
-		    (t->dev->flags & IFF_UP))
+		if (!ipv6_addr_equal(local, &t->parms.laddr) ||
+				!(t->dev->flags & IFF_UP))
+			continue;
+
+		if (ipv6_addr_equal(remote, &t->parms.raddr))
+			return t;
+
+		for (fmr = t->parms.fmrs; fmr; fmr = fmr->next) {
+			if (ipv6_prefix_equal(remote, &fmr->ip6_prefix,
+					fmr->ip6_prefix_len))
 			return t;
 	}
+	}
 
 	memset(&any, 0, sizeof(any));
-	hash = HASH(&any, local);
+	hash = HASH(local);
 	for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
 		if (ipv6_addr_equal(local, &t->parms.laddr) &&
 		    (t->dev->flags & IFF_UP))
 			return t;
 	}
 
-	hash = HASH(remote, &any);
+	hash = HASH(&any);
 	for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
 		if (ipv6_addr_equal(remote, &t->parms.raddr) &&
 		    (t->dev->flags & IFF_UP))
@@ -229,7 +238,7 @@
 
 	if (!ipv6_addr_any(remote) || !ipv6_addr_any(local)) {
 		prio = 1;
-		h = HASH(remote, local);
+		h = HASH(local);
 	}
 	return &ip6n->tnls[prio][h];
 }
@@ -399,6 +408,12 @@
 	struct net *net = t->net;
 	struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
 
+	while (t->parms.fmrs) {
+		struct __ip6_tnl_fmr *next = t->parms.fmrs->next;
+		kfree(t->parms.fmrs);
+		t->parms.fmrs = next;
+	}
+
 	if (dev == ip6n->fb_tnl_dev)
 		RCU_INIT_POINTER(ip6n->tnls_wc[0], NULL);
 	else
@@ -785,6 +800,108 @@
 }
 EXPORT_SYMBOL_GPL(ip6_tnl_rcv_ctl);
 
+
+/**
+ * ip4ip6_fmr_calc - calculate target / source IPv6-address based on FMR
+ *   @dest: destination IPv6 address buffer
+ *   @skb: received socket buffer
+ *   @fmr: MAP FMR
+ *   @xmit: Calculate for xmit or rcv
+ **/
+static void ip4ip6_fmr_calc(struct in6_addr *dest,
+		const struct iphdr *iph, const uint8_t *end,
+		const struct __ip6_tnl_fmr *fmr, bool xmit)
+{
+	int psidlen = fmr->ea_len - (32 - fmr->ip4_prefix_len);
+	u8 *portp = NULL;
+	bool use_dest_addr;
+	const struct iphdr *dsth = iph;
+
+	if ((u8*)dsth >= end)
+		return;
+
+	/* find significant IP header */
+	if (iph->protocol == IPPROTO_ICMP) {
+		struct icmphdr *ih = (struct icmphdr*)(((u8*)dsth) + dsth->ihl * 4);
+		if (ih && ((u8*)&ih[1]) <= end && (
+			ih->type == ICMP_DEST_UNREACH ||
+			ih->type == ICMP_SOURCE_QUENCH ||
+			ih->type == ICMP_TIME_EXCEEDED ||
+			ih->type == ICMP_PARAMETERPROB ||
+			ih->type == ICMP_REDIRECT))
+				dsth = (const struct iphdr*)&ih[1];
+	}
+
+	/* in xmit-path use dest port by default and source port only if
+		this is an ICMP reply to something else; vice versa in rcv-path */
+	use_dest_addr = (xmit && dsth == iph) || (!xmit && dsth != iph);
+
+	/* get dst port */
+	if (((u8*)&dsth[1]) <= end && (
+		dsth->protocol == IPPROTO_UDP ||
+		dsth->protocol == IPPROTO_TCP ||
+		dsth->protocol == IPPROTO_SCTP ||
+		dsth->protocol == IPPROTO_DCCP)) {
+			/* for UDP, TCP, SCTP and DCCP source and dest port
+			follow IPv4 header directly */
+			portp = ((u8*)dsth) + dsth->ihl * 4;
+
+			if (use_dest_addr)
+				portp += sizeof(u16);
+	} else if (iph->protocol == IPPROTO_ICMP) {
+		struct icmphdr *ih = (struct icmphdr*)(((u8*)dsth) + dsth->ihl * 4);
+
+		/* use icmp identifier as port */
+		if (((u8*)&ih) <= end && (
+		    (use_dest_addr && (
+		    ih->type == ICMP_ECHOREPLY ||
+			ih->type == ICMP_TIMESTAMPREPLY ||
+			ih->type == ICMP_INFO_REPLY ||
+			ih->type == ICMP_ADDRESSREPLY)) ||
+			(!use_dest_addr && (
+			ih->type == ICMP_ECHO ||
+			ih->type == ICMP_TIMESTAMP ||
+			ih->type == ICMP_INFO_REQUEST ||
+			ih->type == ICMP_ADDRESS)
+			)))
+				portp = (u8*)&ih->un.echo.id;
+	}
+
+	if ((portp && &portp[2] <= end) || psidlen == 0) {
+		int frombyte = fmr->ip6_prefix_len / 8;
+		int fromrem = fmr->ip6_prefix_len % 8;
+		int bytes = sizeof(struct in6_addr) - frombyte;
+		const u32 *addr = (use_dest_addr) ? &iph->daddr : &iph->saddr;
+		u64 eabits = ((u64)ntohl(*addr)) << (32 + fmr->ip4_prefix_len);
+		u64 t = 0;
+
+		/* extract PSID from port and add it to eabits */
+		u16 psidbits = 0;
+		if (psidlen > 0) {
+			psidbits = ((u16)portp[0]) << 8 | ((u16)portp[1]);
+			psidbits >>= 16 - psidlen - fmr->offset;
+			psidbits = (u16)(psidbits << (16 - psidlen));
+			eabits |= ((u64)psidbits) << (48 - (fmr->ea_len - psidlen));
+		}
+
+		/* rewrite destination address */
+		*dest = fmr->ip6_prefix;
+		memcpy(&dest->s6_addr[10], addr, sizeof(*addr));
+		dest->s6_addr16[7] = htons(psidbits >> (16 - psidlen));
+
+		if (bytes > sizeof(u64))
+			bytes = sizeof(u64);
+
+		/* insert eabits */
+		memcpy(&t, &dest->s6_addr[frombyte], bytes);
+		t = be64_to_cpu(t) & ~(((((u64)1) << fmr->ea_len) - 1)
+			<< (64 - fmr->ea_len - fromrem));
+		t = cpu_to_be64(t | (eabits >> fromrem));
+		memcpy(&dest->s6_addr[frombyte], &t, bytes);
+	}
+}
+
+
 /**
  * ip6_tnl_rcv - decapsulate IPv6 packet and retransmit it locally
  *   @skb: received socket buffer
@@ -830,6 +947,26 @@
 		skb_reset_network_header(skb);
 		skb->protocol = htons(protocol);
 		memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
+		if (protocol == ETH_P_IP &&
+			!ipv6_addr_equal(&ipv6h->saddr, &t->parms.raddr)) {
+				/* Packet didn't come from BR, so lookup FMR */
+				struct __ip6_tnl_fmr *fmr;
+				struct in6_addr expected = t->parms.raddr;
+				for (fmr = t->parms.fmrs; fmr; fmr = fmr->next)
+					if (ipv6_prefix_equal(&ipv6h->saddr,
+						&fmr->ip6_prefix, fmr->ip6_prefix_len))
+							break;
+
+				/* Check that IPv6 matches IPv4 source to prevent spoofing */
+				if (fmr)
+					ip4ip6_fmr_calc(&expected, ip_hdr(skb),
+							skb_tail_pointer(skb), fmr, false);
+
+				if (!ipv6_addr_equal(&ipv6h->saddr, &expected)) {
+					rcu_read_unlock();
+					goto discard;
+				}
+		}
 
 		__skb_tunnel_rx(skb, t->dev, t->net);
 
@@ -1123,6 +1260,7 @@
 	__u32 mtu;
 	u8 tproto;
 	int err;
+	struct __ip6_tnl_fmr *fmr;
 
 	tproto = ACCESS_ONCE(t->parms.proto);
 	if (tproto != IPPROTO_IPIP && tproto != 0)
@@ -1142,6 +1280,18 @@
 	if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
 		fl6.flowi6_mark = skb->mark;
 
+	/* try to find matching FMR */
+	for (fmr = t->parms.fmrs; fmr; fmr = fmr->next) {
+		unsigned mshift = 32 - fmr->ip4_prefix_len;
+		if (ntohl(fmr->ip4_prefix.s_addr) >> mshift ==
+				ntohl(iph->daddr) >> mshift)
+			break;
+	}
+
+	/* change dstaddr according to FMR */
+	if (fmr)
+		ip4ip6_fmr_calc(&fl6.daddr, iph, skb_tail_pointer(skb), fmr, true);
+
 	err = ip6_tnl_xmit2(skb, dev, dsfield, &fl6, encap_limit, &mtu);
 	if (err != 0) {
 		/* XXX: send ICMP error even if DF is not set. */
@@ -1310,6 +1460,14 @@
 	t->parms.flowinfo = p->flowinfo;
 	t->parms.link = p->link;
 	t->parms.proto = p->proto;
+
+	while (t->parms.fmrs) {
+		struct __ip6_tnl_fmr *next = t->parms.fmrs->next;
+		kfree(t->parms.fmrs);
+		t->parms.fmrs = next;
+	}
+	t->parms.fmrs = p->fmrs;
+
 	ip6_tnl_dst_reset(t);
 	ip6_tnl_link_config(t);
 	return 0;
@@ -1348,6 +1506,7 @@
 	p->flowinfo = u->flowinfo;
 	p->link = u->link;
 	p->proto = u->proto;
+	p->fmrs = NULL;
 	memcpy(p->name, u->name, sizeof(u->name));
 }
 
@@ -1634,6 +1793,15 @@
 	return 0;
 }
 
+static const struct nla_policy ip6_tnl_fmr_policy[IFLA_IPTUN_FMR_MAX + 1] = {
+	[IFLA_IPTUN_FMR_IP6_PREFIX] = { .len = sizeof(struct in6_addr) },
+	[IFLA_IPTUN_FMR_IP4_PREFIX] = { .len = sizeof(struct in_addr) },
+	[IFLA_IPTUN_FMR_IP6_PREFIX_LEN] = { .type = NLA_U8 },
+	[IFLA_IPTUN_FMR_IP4_PREFIX_LEN] = { .type = NLA_U8 },
+	[IFLA_IPTUN_FMR_EA_LEN] = { .type = NLA_U8 },
+	[IFLA_IPTUN_FMR_OFFSET] = { .type = NLA_U8 }
+};
+
 static void ip6_tnl_netlink_parms(struct nlattr *data[],
 				  struct __ip6_tnl_parm *parms)
 {
@@ -1665,6 +1833,46 @@
 
 	if (data[IFLA_IPTUN_PROTO])
 		parms->proto = nla_get_u8(data[IFLA_IPTUN_PROTO]);
+
+	if (data[IFLA_IPTUN_FMRS]) {
+		unsigned rem;
+		struct nlattr *fmr;
+		nla_for_each_nested(fmr, data[IFLA_IPTUN_FMRS], rem) {
+			struct nlattr *fmrd[IFLA_IPTUN_FMR_MAX + 1], *c;
+			struct __ip6_tnl_fmr *nfmr;
+
+			nla_parse_nested(fmrd, IFLA_IPTUN_FMR_MAX,
+				fmr, ip6_tnl_fmr_policy);
+
+			if (!(nfmr = kzalloc(sizeof(*nfmr), GFP_KERNEL)))
+				continue;
+
+			nfmr->offset = 6;
+
+			if ((c = fmrd[IFLA_IPTUN_FMR_IP6_PREFIX]))
+				nla_memcpy(&nfmr->ip6_prefix, fmrd[IFLA_IPTUN_FMR_IP6_PREFIX],
+					sizeof(nfmr->ip6_prefix));
+
+			if ((c = fmrd[IFLA_IPTUN_FMR_IP4_PREFIX]))
+				nla_memcpy(&nfmr->ip4_prefix, fmrd[IFLA_IPTUN_FMR_IP4_PREFIX],
+					sizeof(nfmr->ip4_prefix));
+
+			if ((c = fmrd[IFLA_IPTUN_FMR_IP6_PREFIX_LEN]))
+				nfmr->ip6_prefix_len = nla_get_u8(c);
+
+			if ((c = fmrd[IFLA_IPTUN_FMR_IP4_PREFIX_LEN]))
+				nfmr->ip4_prefix_len = nla_get_u8(c);
+
+			if ((c = fmrd[IFLA_IPTUN_FMR_EA_LEN]))
+				nfmr->ea_len = nla_get_u8(c);
+
+			if ((c = fmrd[IFLA_IPTUN_FMR_OFFSET]))
+				nfmr->offset = nla_get_u8(c);
+
+			nfmr->next = parms->fmrs;
+			parms->fmrs = nfmr;
+		}
+	}
 }
 
 static int ip6_tnl_newlink(struct net *src_net, struct net_device *dev,
@@ -1717,6 +1925,12 @@
 
 static size_t ip6_tnl_get_size(const struct net_device *dev)
 {
+	const struct ip6_tnl *t = netdev_priv(dev);
+	struct __ip6_tnl_fmr *c;
+	int fmrs = 0;
+	for (c = t->parms.fmrs; c; c = c->next)
+		++fmrs;
+
 	return
 		/* IFLA_IPTUN_LINK */
 		nla_total_size(4) +
@@ -1734,6 +1948,24 @@
 		nla_total_size(4) +
 		/* IFLA_IPTUN_PROTO */
 		nla_total_size(1) +
+		/* IFLA_IPTUN_FMRS */
+		nla_total_size(0) +
+		(
+			/* nest */
+			nla_total_size(0) +
+			/* IFLA_IPTUN_FMR_IP6_PREFIX */
+			nla_total_size(sizeof(struct in6_addr)) +
+			/* IFLA_IPTUN_FMR_IP4_PREFIX */
+			nla_total_size(sizeof(struct in_addr)) +
+			/* IFLA_IPTUN_FMR_EA_LEN */
+			nla_total_size(1) +
+			/* IFLA_IPTUN_FMR_IP6_PREFIX_LEN */
+			nla_total_size(1) +
+			/* IFLA_IPTUN_FMR_IP4_PREFIX_LEN */
+			nla_total_size(1) +
+			/* IFLA_IPTUN_FMR_OFFSET */
+			nla_total_size(1)
+		) * fmrs +
 		0;
 }
 
@@ -1741,6 +1973,9 @@
 {
 	struct ip6_tnl *tunnel = netdev_priv(dev);
 	struct __ip6_tnl_parm *parm = &tunnel->parms;
+	struct __ip6_tnl_fmr *c;
+	int fmrcnt = 0;
+	struct nlattr *fmrs;
 
 	if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
 	    nla_put_in6_addr(skb, IFLA_IPTUN_LOCAL, &parm->laddr) ||
@@ -1749,8 +1984,27 @@
 	    nla_put_u8(skb, IFLA_IPTUN_ENCAP_LIMIT, parm->encap_limit) ||
 	    nla_put_be32(skb, IFLA_IPTUN_FLOWINFO, parm->flowinfo) ||
 	    nla_put_u32(skb, IFLA_IPTUN_FLAGS, parm->flags) ||
-	    nla_put_u8(skb, IFLA_IPTUN_PROTO, parm->proto))
+	    nla_put_u8(skb, IFLA_IPTUN_PROTO, parm->proto) ||
+	    !(fmrs = nla_nest_start(skb, IFLA_IPTUN_FMRS)))
+		goto nla_put_failure;
+
+	for (c = parm->fmrs; c; c = c->next) {
+		struct nlattr *fmr = nla_nest_start(skb, ++fmrcnt);
+		if (!fmr ||
+			nla_put(skb, IFLA_IPTUN_FMR_IP6_PREFIX,
+				sizeof(c->ip6_prefix), &c->ip6_prefix) ||
+			nla_put(skb, IFLA_IPTUN_FMR_IP4_PREFIX,
+				sizeof(c->ip4_prefix), &c->ip4_prefix) ||
+			nla_put_u8(skb, IFLA_IPTUN_FMR_IP6_PREFIX_LEN, c->ip6_prefix_len) ||
+			nla_put_u8(skb, IFLA_IPTUN_FMR_IP4_PREFIX_LEN, c->ip4_prefix_len) ||
+			nla_put_u8(skb, IFLA_IPTUN_FMR_EA_LEN, c->ea_len) ||
+			nla_put_u8(skb, IFLA_IPTUN_FMR_OFFSET, c->offset))
 		goto nla_put_failure;
+
+		nla_nest_end(skb, fmr);
+	}
+	nla_nest_end(skb, fmrs);
+
 	return 0;
 
 nla_put_failure:
@@ -1774,6 +2028,7 @@
 	[IFLA_IPTUN_FLOWINFO]		= { .type = NLA_U32 },
 	[IFLA_IPTUN_FLAGS]		= { .type = NLA_U32 },
 	[IFLA_IPTUN_PROTO]		= { .type = NLA_U8 },
+	[IFLA_IPTUN_FMRS]		= { .type = NLA_NESTED },
 };
 
 static struct rtnl_link_ops ip6_link_ops __read_mostly = {
diff -ruw linux-4.2.6/net/ipv6/Makefile linux-4.2.6-fbx/net/ipv6/Makefile
--- linux-4.2.6/net/ipv6/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv6/Makefile	2015-11-18 18:24:33.728180095 +0100
@@ -13,6 +13,7 @@
 ipv6-offload :=	ip6_offload.o tcpv6_offload.o udp_offload.o exthdrs_offload.o
 
 ipv6-$(CONFIG_SYSCTL) = sysctl_net_ipv6.o
+ipv6-$(CONFIG_IPV6_FFN) += ip6_ffn.o
 ipv6-$(CONFIG_IPV6_MROUTE) += ip6mr.o
 
 ipv6-$(CONFIG_XFRM) += xfrm6_policy.o xfrm6_state.o xfrm6_input.o \
diff -ruw linux-4.2.6/net/ipv6/netfilter/Kconfig linux-4.2.6-fbx/net/ipv6/netfilter/Kconfig
--- linux-4.2.6/net/ipv6/netfilter/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv6/netfilter/Kconfig	2015-11-18 18:24:33.740180180 +0100
@@ -5,6 +5,13 @@
 menu "IPv6: Netfilter Configuration"
 	depends on INET && IPV6 && NETFILTER
 
+config IPV6_FFN
+	bool "IPv6: Fast forwarding and NAT"
+
+config IPV6_FFN_PROCFS
+	bool "IPv6: Fast forwarding and NAT /proc/net entries"
+	depends on IPV6_FFN
+
 config NF_DEFRAG_IPV6
 	tristate
 	default n
diff -ruw linux-4.2.6/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c linux-4.2.6-fbx/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
--- linux-4.2.6/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c	2015-11-18 18:24:33.744180222 +0100
@@ -81,6 +81,8 @@
 				  enum nf_nat_manip_type maniptype)
 {
 	struct ipv6hdr *ipv6h;
+	const __be32 *to;
+	__be32 *from;
 	__be16 frag_off;
 	int hdroff;
 	u8 nexthdr;
@@ -100,11 +102,24 @@
 				target, maniptype))
 		return false;
 manip_addr:
-	if (maniptype == NF_NAT_MANIP_SRC)
-		ipv6h->saddr = target->src.u3.in6;
-	else
-		ipv6h->daddr = target->dst.u3.in6;
+	if (maniptype == NF_NAT_MANIP_SRC) {
+		from = ipv6h->saddr.s6_addr32;
+		to = target->src.u3.in6.s6_addr32;
+	} else {
+		from = ipv6h->daddr.s6_addr32;
+		to = target->dst.u3.in6.s6_addr32;
+	}
+
+	if (skb->ip_summed == CHECKSUM_COMPLETE) {
+		__be32 diff[] = {
+			~from[0], ~from[1], ~from[2], ~from[3],
+			to[0], to[1], to[2], to[3],
+		};
+
+		skb->csum = ~csum_partial(diff, sizeof(diff), ~skb->csum);
+	}
 
+	memcpy(from, to, sizeof (struct in6_addr));
 	return true;
 }
 
diff -ruw linux-4.2.6/net/ipv6/udp.c linux-4.2.6-fbx/net/ipv6/udp.c
--- linux-4.2.6/net/ipv6/udp.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/ipv6/udp.c	2015-11-18 18:24:33.748180250 +0100
@@ -841,6 +841,52 @@
 	return 0;
 }
 
+/*
+ * Note: called only from the BH handler context,
+ * so we don't need to lock the hashes.
+ */
+static int __udp6_lib_uc_conflict_deliver(struct net *net, struct sk_buff *skb,
+		const struct in6_addr *saddr, const struct in6_addr *daddr,
+		struct udp_table *udptable)
+{
+	struct sock *sk, *stack[256 / sizeof(struct sock *)];
+	const struct udphdr *uh = udp_hdr(skb);
+	struct udp_hslot *hslot = udp_hashslot(udptable, net, ntohs(uh->dest));
+	struct hlist_nulls_node *node;
+	int dif;
+	unsigned int count = 0, non_dup_count = 0;
+
+	spin_lock(&hslot->lock);
+	sk = sk_nulls_head(&hslot->head);
+	dif = inet6_iif(skb);
+	sk_nulls_for_each (sk, node, &hslot->head) {
+		if (!sock_flag(sk, SOCK_UDP_DUP_UNICAST)) {
+			if (!non_dup_count) {
+				stack[count++] = sk;
+				sock_hold(sk);
+			}
+			non_dup_count = 1;
+		} else {
+			stack[count++] = sk;
+			sock_hold(sk);
+		}
+
+		if (unlikely(count == ARRAY_SIZE(stack))) {
+			flush_stack(stack, count, skb, ~0);
+			count = 0;
+		}
+	}
+
+	spin_unlock(&hslot->lock);
+
+	if (count) {
+		flush_stack(stack, count, skb, count - 1);
+	} else {
+		kfree_skb(skb);
+	}
+	return 0;
+}
+
 int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 		   int proto)
 {
@@ -909,6 +955,12 @@
 		if (inet_get_convert_csum(sk) && uh->check && !IS_UDPLITE(sk))
 			skb_checksum_try_convert(skb, IPPROTO_UDP, uh->check,
 						 ip6_compute_pseudo);
+		if (sk->sk_reuse_conflict) {
+			sock_put(sk);
+			return __udp6_lib_uc_conflict_deliver(net, skb,
+							      saddr, daddr,
+							      udptable);
+		}
 
 		ret = udpv6_queue_rcv_skb(sk, skb);
 		sock_put(sk);
diff -ruw linux-4.2.6/net/Kconfig linux-4.2.6-fbx/net/Kconfig
--- linux-4.2.6/net/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/Kconfig	2015-11-18 18:24:33.620179233 +0100
@@ -50,6 +50,18 @@
 
 menu "Networking options"
 
+config NETSKBPAD
+	int "Size reserved by dev_alloc_skb"
+	default 16
+
+config NETRXTHREAD
+	bool "Do rx network processing in kernel thread"
+
+config NETRXTHREAD_RX_QUEUE
+	int "Number of rx queues"
+	default 1
+	depends on NETRXTHREAD
+
 source "net/packet/Kconfig"
 source "net/unix/Kconfig"
 source "net/xfrm/Kconfig"
@@ -208,6 +220,8 @@
 source "net/tipc/Kconfig"
 source "net/atm/Kconfig"
 source "net/l2tp/Kconfig"
+source "net/fbxatm/Kconfig"
+source "net/fbxbridge/Kconfig"
 source "net/802/Kconfig"
 source "net/bridge/Kconfig"
 source "net/dsa/Kconfig"
diff -ruw linux-4.2.6/net/Makefile linux-4.2.6-fbx/net/Makefile
--- linux-4.2.6/net/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/Makefile	2015-11-18 18:24:33.620179233 +0100
@@ -36,6 +36,12 @@
 obj-$(CONFIG_AF_RXRPC)		+= rxrpc/
 obj-$(CONFIG_ATM)		+= atm/
 obj-$(CONFIG_L2TP)		+= l2tp/
+ifneq ($(CONFIG_FBXATM),)
+obj-y				+= fbxatm/
+endif
+ifneq ($(CONFIG_FBXBRIDGE),)
+obj-y				+= fbxbridge/
+endif
 obj-$(CONFIG_DECNET)		+= decnet/
 obj-$(CONFIG_PHONET)		+= phonet/
 ifneq ($(CONFIG_VLAN_8021Q),)
diff -ruw linux-4.2.6/net/netfilter/core.c linux-4.2.6-fbx/net/netfilter/core.c
--- linux-4.2.6/net/netfilter/core.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/netfilter/core.c	2015-11-18 18:24:33.784180531 +0100
@@ -183,7 +183,7 @@
 	}
 	return NF_ACCEPT;
 }
-
+EXPORT_SYMBOL(nf_iterate);
 
 /* Returns 1 if okfn() needs to be executed by the caller,
  * -EPERM for NF_DROP, 0 otherwise. */
diff -ruw linux-4.2.6/net/netfilter/nf_conntrack_core.c linux-4.2.6-fbx/net/netfilter/nf_conntrack_core.c
--- linux-4.2.6/net/netfilter/nf_conntrack_core.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/netfilter/nf_conntrack_core.c	2015-11-18 18:24:33.796180635 +0100
@@ -328,6 +328,14 @@
 }
 EXPORT_SYMBOL_GPL(nf_ct_tmpl_free);
 
+#ifdef CONFIG_IP_FFN
+extern void ip_ffn_ct_destroy(struct nf_conn *ct);
+#endif
+
+#ifdef CONFIG_IPV6_FFN
+extern void ipv6_ffn_ct_destroy(struct nf_conn *ct);
+#endif
+
 static void
 destroy_conntrack(struct nf_conntrack *nfct)
 {
@@ -339,6 +347,15 @@
 	NF_CT_ASSERT(atomic_read(&nfct->use) == 0);
 	NF_CT_ASSERT(!timer_pending(&ct->timeout));
 
+#ifdef CONFIG_IP_FFN
+	if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num == AF_INET)
+		ip_ffn_ct_destroy(ct);
+#endif
+#ifdef CONFIG_IPV6_FFN
+	if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num == AF_INET6)
+		ipv6_ffn_ct_destroy(ct);
+#endif
+
 	if (unlikely(nf_ct_is_template(ct))) {
 		nf_ct_tmpl_free(ct);
 		return;
diff -ruw linux-4.2.6/net/netfilter/nf_conntrack_ftp.c linux-4.2.6-fbx/net/netfilter/nf_conntrack_ftp.c
--- linux-4.2.6/net/netfilter/nf_conntrack_ftp.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/netfilter/nf_conntrack_ftp.c	2015-11-18 18:24:33.796180635 +0100
@@ -27,6 +27,11 @@
 #include <net/netfilter/nf_conntrack_helper.h>
 #include <linux/netfilter/nf_conntrack_ftp.h>
 
+#if defined(CONFIG_FREEBOX_BRIDGE) || defined(CONFIG_FREEBOX_BRIDGE_MODULE)
+#include <net/netfilter/nf_nat_helper.h>
+#include <fbxbridge.h>
+#endif
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
 MODULE_DESCRIPTION("ftp connection tracking helper");
@@ -410,6 +415,17 @@
 		return NF_ACCEPT;
 	}
 
+#if defined(CONFIG_FREEBOX_BRIDGE) || defined(CONFIG_FREEBOX_BRIDGE_MODULE)
+	if (!ct_ftp_info->is_fbxbridge && skb->dev->fbx_bridge) {
+		struct fbxbridge *fbxbr;
+
+		fbxbr = skb->dev->fbx_bridge;
+		ct_ftp_info->is_fbxbridge = 1;
+		ct_ftp_info->fbxbridge_remote = ntohl(fbxbr->br_remote_ipaddr);
+		ct_ftp_info->fbxbridge_wan = fbxbr->wan_ipaddr;
+	}
+#endif
+
 	th = skb_header_pointer(skb, protoff, sizeof(_tcph), &_tcph);
 	if (th == NULL)
 		return NF_ACCEPT;
@@ -496,6 +512,50 @@
 	 * Doesn't matter unless NAT is happening.  */
 	daddr = &ct->tuplehash[!dir].tuple.dst.u3;
 
+#if defined(CONFIG_FREEBOX_BRIDGE) || defined(CONFIG_FREEBOX_BRIDGE_MODULE)
+	if (ct_ftp_info->is_fbxbridge &&
+	    search[dir][i].ftptype == NF_CT_FTP_PORT) {
+		unsigned long orig_ip_addr;
+		unsigned short orig_port;
+		char buffer[sizeof("nnn,nnn,nnn,nnn,nnn,nnn")];
+		unsigned int len;
+		__be32 addr;
+
+		/* kludge: if  we are here,  then this is a  local pkt
+		 * that has  gone through internal  fbxbridge snat.
+		 *
+		 * If we see a port  command, then we mangle packet to
+		 * change  ip  address  given  to  the  remote  bridge
+		 * address */
+
+		/* check  address  is  packet  is  the  one  fbxbridge
+		 * changed */
+		orig_ip_addr = cmd.u3.ip;
+		if (orig_ip_addr != ct_ftp_info->fbxbridge_wan)
+			goto donttouch;
+
+		/* now mangle the remote address */
+		orig_port = cmd.u.tcp.port;
+		addr = ct_ftp_info->fbxbridge_remote;
+		len = sprintf(buffer, "%u,%u,%u,%u,%u,%u",
+			      ((unsigned char *)&addr)[0],
+			      ((unsigned char *)&addr)[1],
+			      ((unsigned char *)&addr)[2],
+			      ((unsigned char *)&addr)[3],
+			      orig_port >> 8 , orig_port & 0xFF);
+
+		nf_nat_mangle_tcp_packet(skb, ct, ctinfo, matchoff,
+					 matchlen, buffer, len);
+
+		/* then adjust as if nothing happened */
+		matchlen = len;
+		cmd.u3.ip = ct_ftp_info->fbxbridge_remote;
+	}
+donttouch:
+
+#endif
+
+
 	/* Update the ftp info */
 	if ((cmd.l3num == nf_ct_l3num(ct)) &&
 	    memcmp(&cmd.u3.all, &ct->tuplehash[dir].tuple.src.u3.all,
diff -ruw linux-4.2.6/net/netfilter/nf_conntrack_proto_tcp.c linux-4.2.6-fbx/net/netfilter/nf_conntrack_proto_tcp.c
--- linux-4.2.6/net/netfilter/nf_conntrack_proto_tcp.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/netfilter/nf_conntrack_proto_tcp.c	2015-11-18 18:24:33.800180659 +0100
@@ -1033,7 +1033,8 @@
 		break;
 	}
 
-	if (!tcp_in_window(ct, &ct->proto.tcp, dir, index,
+	if (!ct->proto.tcp.no_window_track &&
+	    !tcp_in_window(ct, &ct->proto.tcp, dir, index,
 			   skb, dataoff, th, pf)) {
 		spin_unlock_bh(&ct->lock);
 		return -NF_ACCEPT;
@@ -1099,6 +1100,29 @@
 	return NF_ACCEPT;
 }
 
+#ifdef CONFIG_IP_FFN
+int external_tcpv4_packet(struct nf_conn *ct,
+			  const struct sk_buff *skb,
+			  unsigned int dataoff,
+			  enum ip_conntrack_info ctinfo)
+{
+	return tcp_packet(ct, skb, dataoff, ctinfo, AF_INET, 0,
+			  tcp_get_timeouts(nf_ct_net(ct)));
+}
+#endif
+
+#ifdef CONFIG_IPV6_FFN
+int external_tcpv6_packet(struct nf_conn *ct,
+			  const struct sk_buff *skb,
+			  unsigned int dataoff,
+			  enum ip_conntrack_info ctinfo)
+{
+	return tcp_packet(ct, skb, dataoff, ctinfo, AF_INET6, 0,
+			  tcp_get_timeouts(nf_ct_net(ct)));
+}
+#endif
+
+
 /* Called when a new connection for this protocol found. */
 static bool tcp_new(struct nf_conn *ct, const struct sk_buff *skb,
 		    unsigned int dataoff, unsigned int *timeouts)
diff -ruw linux-4.2.6/net/netfilter/nf_conntrack_proto_udp.c linux-4.2.6-fbx/net/netfilter/nf_conntrack_proto_udp.c
--- linux-4.2.6/net/netfilter/nf_conntrack_proto_udp.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/netfilter/nf_conntrack_proto_udp.c	2015-11-18 18:24:33.800180659 +0100
@@ -100,6 +100,28 @@
 	return NF_ACCEPT;
 }
 
+#ifdef CONFIG_IP_FFN
+int external_udpv4_packet(struct nf_conn *ct,
+			  const struct sk_buff *skb,
+			  unsigned int dataoff,
+			  enum ip_conntrack_info ctinfo)
+{
+	return udp_packet(ct, skb, dataoff, ctinfo, AF_INET, 0,
+			  udp_get_timeouts(nf_ct_net(ct)));
+}
+#endif
+
+#ifdef CONFIG_IPV6_FFN
+int external_udpv6_packet(struct nf_conn *ct,
+			  const struct sk_buff *skb,
+			  unsigned int dataoff,
+			  enum ip_conntrack_info ctinfo)
+{
+	return udp_packet(ct, skb, dataoff, ctinfo, AF_INET, 0,
+			  udp_get_timeouts(nf_ct_net(ct)));
+}
+#endif
+
 /* Called when a new connection for this protocol found. */
 static bool udp_new(struct nf_conn *ct, const struct sk_buff *skb,
 		    unsigned int dataoff, unsigned int *timeouts)
diff -ruw linux-4.2.6/net/netfilter/xt_owner.c linux-4.2.6-fbx/net/netfilter/xt_owner.c
--- linux-4.2.6/net/netfilter/xt_owner.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/netfilter/xt_owner.c	2015-11-18 18:24:33.812180761 +0100
@@ -28,6 +28,61 @@
 	return 0;
 }
 
+static int __owner_match_simple_gid(kgid_t gid, kgid_t gid_min, kgid_t gid_max)
+{
+	return gid_gte(gid, gid_min) && gid_lte(gid, gid_max);
+}
+
+/*
+ * see kernel/groups.c:groups_to_user() function, which inspired the
+ * content of this function.
+ */
+static int __owner_match_gid_groupinfo(const struct group_info *group_info,
+				       kgid_t gid_min, kgid_t gid_max)
+{
+	unsigned int count = group_info->ngroups;
+	unsigned int block;
+
+	for (block = 0; block < group_info->nblocks; ++block) {
+		unsigned int cp_count = min(NGROUPS_PER_BLOCK, count);
+		unsigned int i;
+
+		for (i = 0; i < cp_count; ++i) {
+			if (__owner_match_simple_gid(
+					     group_info->blocks[block][i],
+					     gid_min, gid_max)) {
+				return 1;
+			}
+			count -= cp_count;
+		}
+	}
+	return 0;
+}
+
+static int owner_match_gid(const struct file *filp,
+			   const struct xt_owner_match_info *info)
+{
+	kgid_t gid_min = make_kgid(&init_user_ns, info->gid_min);
+	kgid_t gid_max = make_kgid(&init_user_ns, info->gid_max);
+
+	/*
+	 * direct match, this is the simple and only case handled by
+	 * the old code, file fsgid matches info gid range.
+	 */
+	if (__owner_match_simple_gid(filp->f_cred->fsgid, gid_min, gid_max))
+		return 1;
+
+	/*
+	 * otherwise we need to have a look to the group list available
+	 * in f_cred->group_info.
+	 */
+	if (__owner_match_gid_groupinfo(filp->f_cred->group_info,
+					gid_min, gid_max))
+		return 1;
+
+	return 0;
+}
+
 static bool
 owner_mt(const struct sk_buff *skb, struct xt_action_param *par)
 {
@@ -58,10 +113,7 @@
 	}
 
 	if (info->match & XT_OWNER_GID) {
-		kgid_t gid_min = make_kgid(&init_user_ns, info->gid_min);
-		kgid_t gid_max = make_kgid(&init_user_ns, info->gid_max);
-		if ((gid_gte(filp->f_cred->fsgid, gid_min) &&
-		     gid_lte(filp->f_cred->fsgid, gid_max)) ^
+		if (owner_match_gid(filp, info) ^
 		    !(info->invert & XT_OWNER_GID))
 			return false;
 	}
diff -ruw linux-4.2.6/net/sched/sch_drr.c linux-4.2.6-fbx/net/sched/sch_drr.c
--- linux-4.2.6/net/sched/sch_drr.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/sched/sch_drr.c	2015-11-18 18:24:33.844181004 +0100
@@ -347,7 +347,9 @@
 			cl = drr_find_class(sch, res.classid);
 		return cl;
 	}
-	return NULL;
+
+	/* default to first minor if it exists, or drop */
+	return drr_find_class(sch, TC_H_MAKE(TC_H_MAJ(sch->handle), 1));
 }
 
 static int drr_enqueue(struct sk_buff *skb, struct Qdisc *sch)
diff -ruw linux-4.2.6/net/socket.c linux-4.2.6-fbx/net/socket.c
--- linux-4.2.6/net/socket.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/socket.c	2015-11-18 18:24:33.860181133 +0100
@@ -877,6 +877,31 @@
 	return err;
 }
 
+static DEFINE_MUTEX(fbxdiverter_ioctl_mutex);
+static int (*fbxdiverter_ioctl_hook) (struct net *, unsigned int cmd, void __user *arg) = NULL;
+
+void fbxdiverter_ioctl_set(int (*hook) (struct net *, unsigned int,
+					void __user *))
+{
+	mutex_lock(&fbxdiverter_ioctl_mutex);
+	fbxdiverter_ioctl_hook = hook;
+	mutex_unlock(&fbxdiverter_ioctl_mutex);
+}
+
+EXPORT_SYMBOL(fbxdiverter_ioctl_set);
+
+static DEFINE_MUTEX(fbxbridge_ioctl_mutex);
+static int (*fbxbridge_ioctl_hook)(struct net *, unsigned int cmd, void __user *arg) = NULL;
+
+void fbxbridge_set(int (*hook)(struct net *, unsigned int, void __user *))
+{
+	mutex_lock(&fbxbridge_ioctl_mutex);
+	fbxbridge_ioctl_hook = hook;
+	mutex_unlock(&fbxbridge_ioctl_mutex);
+}
+
+EXPORT_SYMBOL(fbxbridge_set);
+
 /*
  *	With an ioctl, arg may well be a user mode pointer, but we don't know
  *	what to do with it - that's up to the protocol still.
@@ -950,6 +975,28 @@
 				err = dlci_ioctl_hook(cmd, argp);
 			mutex_unlock(&dlci_ioctl_mutex);
 			break;
+		case SIOCGFBXDIVERT:
+		case SIOCSFBXDIVERT:
+			err = -ENOPKG;
+			if (!fbxdiverter_ioctl_hook)
+				request_module("fbxdiverter");
+
+			mutex_lock(&fbxdiverter_ioctl_mutex);
+			if (fbxdiverter_ioctl_hook)
+				err = fbxdiverter_ioctl_hook(net, cmd, argp);
+			mutex_unlock(&fbxdiverter_ioctl_mutex);
+			break;
+		case SIOCGFBXBRIDGE:
+		case SIOCSFBXBRIDGE:
+			err = -ENOPKG;
+			if (!fbxbridge_ioctl_hook)
+				request_module("fbxbridge");
+
+			mutex_lock(&fbxbridge_ioctl_mutex);
+			if (fbxbridge_ioctl_hook)
+				err = fbxbridge_ioctl_hook(net, cmd, argp);
+			mutex_unlock(&fbxbridge_ioctl_mutex);
+			break;
 		default:
 			err = sock_do_ioctl(net, sock, cmd, arg);
 			break;
diff -ruw linux-4.2.6/net/unix/af_unix.c linux-4.2.6-fbx/net/unix/af_unix.c
--- linux-4.2.6/net/unix/af_unix.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/unix/af_unix.c	2015-11-18 18:24:33.880181299 +0100
@@ -279,8 +279,10 @@
 	sk_for_each(s, &unix_socket_table[hash ^ type]) {
 		struct unix_sock *u = unix_sk(s);
 
+#ifdef UNIX_ABSTRACT_IGNORE_NETNS
 		if (!net_eq(sock_net(s), net))
 			continue;
+#endif
 
 		if (u->addr->len == len &&
 		    !memcmp(u->addr->name, sunname, len))
diff -ruw linux-4.2.6/net/unix/Kconfig linux-4.2.6-fbx/net/unix/Kconfig
--- linux-4.2.6/net/unix/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/unix/Kconfig	2015-11-02 19:00:43.393193318 +0100
@@ -19,6 +19,9 @@
 
 	  Say Y unless you know what you are doing.
 
+config UNIX_ABSTRACT_IGNORE_NETNS
+	bool "make abstract namespace global to all network namespaces"
+
 config UNIX_DIAG
 	tristate "UNIX: socket monitoring interface"
 	depends on UNIX
diff -ruw linux-4.2.6/net/wireless/db.txt linux-4.2.6-fbx/net/wireless/db.txt
--- linux-4.2.6/net/wireless/db.txt	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/net/wireless/db.txt	2015-11-18 18:24:33.884181327 +0100
@@ -1,17 +1,1252 @@
+# This is the world regulatory domain
+country 00:
+	(2402 - 2472 @ 40), (20)
+	# Channel 12 - 13.
+	(2457 - 2482 @ 40), (20), NO-IR
+	# Channel 14. Only JP enables this and for 802.11b only
+	(2474 - 2494 @ 20), (20), NO-IR, NO-OFDM
+	# Channel 36 - 48
+	(5170 - 5250 @ 80), (20), NO-IR, AUTO-BW
+	# Channel 52 - 64
+	(5250 - 5330 @ 80), (20), NO-IR, DFS, AUTO-BW
+	# Channel 100 - 144
+	(5490 - 5730 @ 160), (20), NO-IR, DFS
+	# Channel 149 - 165
+	(5735 - 5835 @ 80), (20), NO-IR
+	# IEEE 802.11ad (60GHz), channels 1..3
+	(57240 - 63720 @ 2160), (0)
+
+
+country AD:
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20)
+	(5250 - 5330 @ 80), (20), DFS
+	(5490 - 5710 @ 80), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country AE: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country AF: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+# Source:
+# http://pucanguilla.org/Downloads/January2005-Anguilla%20Table%20of%20Allocations.pdf
+country AI: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country AL: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20.00), AUTO-BW
+	(5250 - 5330 @ 80), (20.00), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27.00), DFS
+
+country AM: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 20), (18)
+	(5250 - 5330 @ 20), (18), DFS
+
+country AN: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country AR: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country AS: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country AT: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country AU: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country AW: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country AZ: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (18), AUTO-BW
+	(5250 - 5330 @ 80), (18), DFS, AUTO-BW
+
+country BA: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country BB: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (23), AUTO-BW
+	(5250 - 5330 @ 80), (23), DFS, AUTO-BW
+	(5735 - 5835 @ 80), (30)
+
+country BD: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5735 - 5835 @ 80), (30)
+
+country BE: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country BF: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country BG: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 5 gHz Short Range Devices, ref:
+	# Etsi EN 300 440-1
+	# Etsi EN 300 440-2
+	# http://crc.bg/files/_bg/Spisak_2015.pdf
+	# http://crc.bg/files/_bg/Pravila_2015_resh24.pdf
+	(5725 - 5875 @ 80), (14)
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country BH: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 20), (20)
+	(5250 - 5330 @ 20), (20), DFS
+	(5735 - 5835 @ 20), (20)
+
+country BL: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country BM: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country BN: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5735 - 5835 @ 80), (20)
+
+country BO: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5250 - 5330 @ 80), (30), DFS
+	(5735 - 5835 @ 80), (30)
+
+country BR: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country BS: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+# Source:
+# http://www.bicma.gov.bt/paper/publication/nrrpart4.pdf
+country BT: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country BY: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country BZ: DFS-JP
+	(2402 - 2482 @ 40), (30)
+	(5735 - 5835 @ 80), (30)
+
+country CA: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5600 @ 80), (24), DFS
+	(5650 - 5730 @ 80), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+# Source:
+# http://www.art-rca.org
+country CF: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 40), (17)
+	(5250 - 5330 @ 40), (24), DFS
+	(5490 - 5730 @ 40), (24), DFS
+	(5735 - 5835 @ 40), (30)
+
+country CH: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country CI: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country CL: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5735 - 5835 @ 80), (20)
+
+country CN: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (23), AUTO-BW
+	(5250 - 5330 @ 80), (23), DFS, AUTO-BW
+	(5735 - 5835 @ 80), (30)
+	# 60 gHz band channels 1,4: 28dBm, channels 2,3: 44dBm
+	# ref: http://www.miit.gov.cn/n11293472/n11505629/n11506593/n11960250/n11960606/n11960700/n12330791.files/n12330790.pdf
+	(57240 - 59400 @ 2160), (28)
+	(59400 - 63720 @ 2160), (44)
+	(63720 - 65880 @ 2160), (28)
+
+country CO: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country CR: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 20), (17)
+	(5250 - 5330 @ 20), (24), DFS
+	(5490 - 5730 @ 20), (24), DFS
+	(5735 - 5835 @ 20), (30)
+
+country CX: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country CY: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+# Data from http://www.ctu.eu/164/download/VOR/VOR-12-08-2005-34.pdf
+# and http://www.ctu.eu/164/download/VOR/VOR-12-05-2007-6-AN.pdf
+# Power at 5250 - 5350 MHz and 5470 - 5725 MHz can be doubled if TPC is
+# implemented.
+country CZ: DFS-ETSI
+	(2400 - 2483.5 @ 40), (100 mW)
+	(5150 - 5250 @ 80), (200 mW), NO-OUTDOOR, AUTO-BW
+	(5250 - 5350 @ 80), (100 mW), NO-OUTDOOR, DFS, AUTO-BW
+	(5470 - 5725 @ 160), (500 mW), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+# Data from "Frequenznutzungsplan" (as published in April 2008), downloaded from
+# http://www.bundesnetzagentur.de/cae/servlet/contentblob/38448/publicationFile/2659/Frequenznutzungsplan2008_Id17448pdf.pdf
+# For the 5GHz range also see
+# http://www.bundesnetzagentur.de/cae/servlet/contentblob/38216/publicationFile/6579/WLAN5GHzVfg7_2010_28042010pdf.pdf
+# The values have been reduced by a factor of 2 (3db) for non TPC devices
+# (in other words: devices with TPC can use twice the tx power of this table).
+# Note that the docs do not require TPC for 5150--5250; the reduction to
+# 100mW thus is not strictly required -- however the conservative 100mW
+# limit is used here as the non-interference with radar and satellite
+# apps relies on the attenuation by the building walls only in the
+# absence of DFS; the neighbour countries have 100mW limit here as well.
+
+country DE: DFS-ETSI
+	# entries 279004 and 280006
+	(2400 - 2483.5 @ 40), (100 mW)
+	# entry 303005
+	(5150 - 5250 @ 80), (100 mW), NO-OUTDOOR, AUTO-BW
+	# entries 304002 and 305002
+	(5250 - 5350 @ 80), (100 mW), NO-OUTDOOR, DFS, AUTO-BW
+	# entries 308002, 309001 and 310003
+	(5470 - 5725 @ 160), (500 mW), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country DK: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+# Source:
+# http://www.ntrcdom.org/index.php?option=com_content&view=category&layout=blog&id=10&Itemid=55
+country DM: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (23), DFS, AUTO-BW
+	(5735 - 5835 @ 80), (30)
+
+country DO: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (23), DFS, AUTO-BW
+	(5735 - 5835 @ 80), (30)
+
+country DZ: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5170.000 - 5250.000 @ 80.000), (23.00), AUTO-BW
+	(5250.000 - 5330.000 @ 80.000), (23.00), DFS, AUTO-BW
+	(5490.000 - 5670.000 @ 160.000), (23.00), DFS
+
+country EC: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 20), (17)
+	(5250 - 5330 @ 20), (24), DFS
+	(5490 - 5730 @ 20), (24), DFS
+	(5735 - 5835 @ 20), (30)
+
+country EE: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country EG: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 40), (20)
+	(5250 - 5330 @ 40), (20), DFS
+
+# Orden IET/787/2013, de 25 de abril, por la que se aprueba
+# el cuadro nacional de atribución de frecuencias.
+# http://www.boe.es/diario_boe/txt.php?id=BOE-A-2013-4845
 #
-# This file is a placeholder to prevent accidental build breakage if someone
-# enables CONFIG_CFG80211_INTERNAL_REGDB.  Almost no one actually needs to
-# enable that build option.
-#
-# You should be using CRDA instead.  It is even better if you use the CRDA
-# package provided by your distribution, since they will probably keep it
-# up-to-date on your behalf.
-#
-# If you _really_ intend to use CONFIG_CFG80211_INTERNAL_REGDB then you will
-# need to replace this file with one containing appropriately formatted
-# regulatory rules that cover the regulatory domains you will be using.  Your
-# best option is to extract the db.txt file from the wireless-regdb git
-# repository:
-#
-#   git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-regdb.git
-#
+# more info at "Cuadro nacional de atribución de frecuencias (CNAF)":
+# http://www.minetur.gob.es/telecomunicaciones/espectro/paginas/cnaf.aspx
+
+country ES: DFS-ETSI
+	(2400 - 2483.5 @ 40), (100 mW)
+	(5150 - 5250 @ 80), (200 mW), NO-OUTDOOR, AUTO-BW
+	(5250 - 5350 @ 80), (100 mW), NO-OUTDOOR, DFS, AUTO-BW
+	(5470 - 5725 @ 160), (500 mW), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country ET: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country FI: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country FM: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country FR: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country GB: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country GD: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country GE: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (18), AUTO-BW
+	(5250 - 5330 @ 80), (18), DFS, AUTO-BW
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country GF: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country GH: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country GL: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20)
+	(5250 - 5330 @ 80), (20), DFS
+	(5490 - 5710 @ 80), (27), DFS
+
+country GP: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country GR: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country GT: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (23), DFS, AUTO-BW
+	(5735 - 5835 @ 80), (30)
+
+country GU: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 20), (17)
+	(5250 - 5330 @ 20), (24), DFS
+	(5490 - 5730 @ 20), (24), DFS
+	(5735 - 5835 @ 20), (30)
+
+country GY:
+	(2402 - 2482 @ 40), (30)
+	(5735 - 5835 @ 80), (30)
+
+country HK: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country HN: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country HR: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country HT: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country HU: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country ID: DFS-JP
+	# ref: http://www.postel.go.id/content/ID/regulasi/standardisasi/kepdir/bwa%205,8%20ghz.pdf
+	(2402 - 2482 @ 20), (20)
+	(5735 - 5815 @ 20), (23)
+
+country IE: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country IL: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5150 - 5250 @ 80), (200 mW), NO-OUTDOOR, AUTO-BW
+	(5250 - 5350 @ 80), (200 mW), NO-OUTDOOR, DFS, AUTO-BW
+
+country IN: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5735 - 5835 @ 80), (20)
+
+country IR: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5735 - 5835 @ 80), (30)
+
+country IS: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country IT: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country JM: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country JO: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (23)
+	(5735 - 5835 @ 80), (23)
+
+country JP: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(2474 - 2494 @ 20), (20), NO-OFDM
+	(4910 - 4990 @ 40), (23)
+	(5030 - 5090 @ 40), (23)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (23), DFS
+	# 60 GHz band channels 2-4 at 10mW,
+	# ref: http://www.arib.or.jp/english/html/overview/doc/1-STD-T74v1_1.pdf
+	(59000 - 66000 @ 2160), (10 mW)
+
+country KE: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (23)
+	(5490 - 5570 @ 80), (30), DFS
+	(5735 - 5775 @ 40), (23)
+
+country KH: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+# Source
+# http://ntrc.kn/?page_id=7
+country KN: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (30), DFS
+	(5735 - 5815 @ 80), (30)
+
+country KP: DFS-JP
+	(2402 - 2482 @ 20), (20)
+	(5170 - 5250 @ 20), (20)
+	(5250 - 5330 @ 20), (20), DFS
+	(5490 - 5630 @ 20), (30), DFS
+	(5735 - 5815 @ 20), (30)
+
+country KR: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (30), DFS
+	(5735 - 5835 @ 80), (30)
+
+country KW: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+
+country KY: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country KZ:
+	(2402 - 2482 @ 40), (20)
+
+country LB: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+# Source:
+# http://www.ntrc.org.lc/operational_structures.htm
+country LC: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (30), DFS
+	(5735 - 5815 @ 80), (30)
+
+country LI: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country LK: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 20), (17)
+	(5250 - 5330 @ 20), (24), DFS
+	(5490 - 5730 @ 20), (24), DFS
+	(5735 - 5835 @ 20), (30)
+
+# Source:
+# http://lca.org.ls/images/documents/lesotho_national_frequency_allocation_plan.pdf
+country LS: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country LT: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country LU: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country LV: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country MA: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+
+country MC: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+# Source:
+# http://www.cnfr.md/index.php?pag=sec&id=117&l=en
+country MD: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+# Source:
+# http://www.cept.org/files/1050/Tools%20and%20Services/EFIS%20-%20ECO%20Frequency%20Information%20System/National%20frequency%20tables/Montenegro%20NAFT%20-%202010.pdf
+country ME: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country MF: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country MH: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country MK: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country MN: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country MO: DFS-FCC
+	(2402 - 2482 @ 40), (23)
+	(5170 - 5250 @ 80), (23), AUTO-BW
+	(5250 - 5330 @ 80), (23), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (30), DFS
+	(5735 - 5835 @ 80), (30)
+
+country MP: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country MQ: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+# Source:
+# http://www.are.mr/pdfs/telec_freq_TNAbf_2010.pdf
+country MR: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country MT: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country MU: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+# Source:
+# http://www.cam.gov.mv/docs/tech_standards/TAM-TS-100-2004-WLAN.pdf
+country MV: DFS-ETSI
+	(2400 - 2483.5 @ 40), (100 mW)
+	(5150 - 5250 @ 80), (200 mW), AUTO-BW
+	(5250 - 5350 @ 80), (100 mW), DFS, AUTO-BW
+	(5725 - 5850 @ 80), (100 mW)
+
+country MW: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country MX: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country MY: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (23), DFS, AUTO-BW
+	(5735 - 5835 @ 80), (30)
+
+country NG: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5250 - 5330 @ 80), (30), DFS
+	(5735 - 5835 @ 80), (30)
+
+country NI: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country NL: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), NO-OUTDOOR, AUTO-BW
+	(5250 - 5330 @ 80), (20), NO-OUTDOOR, DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+# Data from http://www.lovdata.no/dokument/SF/forskrift/2012-01-19-77
+# Power at 5250 - 5350 MHz, 5470 - 5725 MHz and 5815 – 5850 MHz can
+# be doubled if TPC is implemented.
+# Up to 2W (or 4W with TPC) is allowed in the 5725 – 5795 MHz band
+# which has been merged with 5470 - 5725 MHz to allow wide channels
+country NO: DFS-ETSI
+	(2400 - 2483.5 @ 40), (100 mW)
+	(5150 - 5250 @ 80), (200 mW), AUTO-BW
+	(5250 - 5350 @ 80), (100 mW), DFS, AUTO-BW
+	(5470 - 5795 @ 160), (500 mW), DFS
+	(5815 - 5850 @ 35), (2000 mW), DFS
+	(17100 - 17300 @ 200), (100 mW)
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country NP: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5735 - 5835 @ 80), (20)
+
+country NZ: DFS-ETSI
+	(2402 - 2482 @ 40), (30)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country OM: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country PA: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (23), DFS, AUTO-BW
+	(5735 - 5835 @ 80), (30)
+
+country PE: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country PF: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country PG: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country PH: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country PK: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5735 - 5835 @ 80), (30)
+
+country PL: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country PM: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country PR: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country PT: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country PW: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country PY: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country QA: DFS-JP
+	(2402 - 2482 @ 40), (20)
+	(5735 - 5835 @ 80), (30)
+
+country RE: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country RO: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+
+# Source:
+# http://www.ratel.rs/upload/documents/Plan_namene/Plan_namene-sl_glasnik.pdf
+country RS: DFS-ETSI
+	(2400 - 2483.5 @ 40), (100 mW)
+	(5150 - 5350 @ 40), (200 mW), NO-OUTDOOR
+	(5470 - 5725 @ 20), (1000 mW), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country RU: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 40), (20)
+	(5250 - 5330 @ 40), (20), DFS
+	(5650 - 5730 @ 40), (30), DFS
+	(5735 - 5835 @ 40), (30)
+	# 60 GHz band channels 1-4, ref: Changes to NLA 124_Order №129_22042015.pdf
+	(57000 - 66000 @ 2160), (40)
+
+country RW: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country SA: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country SE: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country SG: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country SI: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country SK: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+# Source:
+# Regulation N° 2004-005 ART/DG/DRC/D.Rég
+country SN: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country SR: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country SV: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 20), (17)
+	(5250 - 5330 @ 20), (23), DFS
+	(5735 - 5835 @ 20), (30)
+
+country SY:
+	(2402 - 2482 @ 40), (20)
+
+# Source:
+# http://www.telecommission.tc/Spectrum-plan20110324-101210.html
+country TC: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country TD: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country TG: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 40), (20)
+	(5250 - 5330 @ 40), (20), DFS
+	(5490 - 5710 @ 40), (27), DFS
+
+country TH: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country TN: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+
+country TR: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country TT: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country TW: DFS-JP
+	(2402 - 2472 @ 40), (30)
+	(5270 - 5330 @ 40), (17), DFS
+	(5490 - 5590 @ 80), (30), DFS
+	(5650 - 5710 @ 40), (30), DFS
+	(5735 - 5835 @ 80), (30)
+ 
+country TZ:
+	(2402 - 2482 @ 40), (20)
+	(5735 - 5835 @ 80), (30)
+
+# Source:
+# #914 / 06 Sep 2007: http://www.ucrf.gov.ua/uk/doc/nkrz/1196068874
+# #1174 / 23 Oct 2008: http://www.nkrz.gov.ua/uk/activities/ruling/1225269361
+# (appendix 8)
+# Listed 5GHz range is a lowest common denominator for all related
+# rules in the referenced laws. Such a range is used because of
+# disputable definitions there.
+country UA: DFS-ETSI
+	(2400 - 2483.5 @ 40), (20), NO-OUTDOOR
+	(5150 - 5350 @ 40), (20), NO-OUTDOOR
+	(5490 - 5670 @ 80), (20), DFS
+	(5735 - 5835 @ 80), (20)
+	# 60 gHz band channels 1-4, ref: Etsi En 302 567
+	(57000 - 66000 @ 2160), (40)
+
+country UG: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country US: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (23), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (23), DFS
+	(5735 - 5835 @ 80), (30)
+	# 60g band
+	# reference: http://cfr.regstoday.com/47cfr15.aspx#47_CFR_15p255
+	# channels 1,2,3, EIRP=40dBm(43dBm peak)
+	(57240 - 63720 @ 2160), (40)
+
+country UY: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+# Source:
+# http://cemc.uz/article/1976/
+country UZ: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+
+# Source:
+# http://www.ntrc.vc/regulations/Jun_2006_Spectrum_Managment_Regulations.pdf
+country VC: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+# Source:
+# Official Gazette (Gaceta Oficial) concerning Unlicensed transmitter use
+# (10 June 2013)
+# http://www.conatel.gob.ve/
+country VE: DFS-FCC
+	(2402 - 2482 @ 40), (30)
+	(5170 - 5250 @ 80), (23), AUTO-BW
+	(5250 - 5330 @ 80), (23), DFS, AUTO-BW
+	(5735 - 5835 @ 80), (30)
+
+country VI: DFS-FCC
+	(2402 - 2472 @ 40), (30)
+	(5170 - 5250 @ 80), (24), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country VN: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17)
+	(5250 - 5330 @ 80), (24), DFS
+	(5490 - 5730 @ 80), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+# Source:
+# http://www.trr.vu/attachments/category/130/GURL_for_Short-range_Radiocommunication_Devices2.pdf
+country VU: DFS-FCC
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (17), AUTO-BW
+	(5250 - 5330 @ 80), (24), DFS, AUTO-BW
+	(5490 - 5730 @ 160), (24), DFS
+	(5735 - 5835 @ 80), (30)
+
+country WF: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country WS: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 40), (20)
+	(5250 - 5330 @ 40), (20), DFS
+	(5490 - 5710 @ 40), (27), DFS
+
+country YE:
+	(2402 - 2482 @ 40), (20)
+
+country YT: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country ZA: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
+country ZW: DFS-ETSI
+	(2402 - 2482 @ 40), (20)
+	(5170 - 5250 @ 80), (20), AUTO-BW
+	(5250 - 5330 @ 80), (20), DFS, AUTO-BW
+	(5490 - 5710 @ 160), (27), DFS
+
diff -ruw linux-4.2.6/sound/soc/codecs/cs42l52.c linux-4.2.6-fbx/sound/soc/codecs/cs42l52.c
--- linux-4.2.6/sound/soc/codecs/cs42l52.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/sound/soc/codecs/cs42l52.c	2015-11-18 18:24:34.084182904 +0100
@@ -182,19 +182,25 @@
 	}
 }
 
-static DECLARE_TLV_DB_SCALE(hl_tlv, -10200, 50, 0);
+static DECLARE_TLV_DB_SCALE(bass_gain_tlv, -1050, 150, 0);
 
-static DECLARE_TLV_DB_SCALE(hpd_tlv, -9600, 50, 1);
+static DECLARE_TLV_DB_SCALE(mst_tlv, -6000, 50, 0);
+
+static DECLARE_TLV_DB_SCALE(hpd_tlv, -9600, 50, 0);
 
 static DECLARE_TLV_DB_SCALE(ipd_tlv, -9600, 100, 0);
 
 static DECLARE_TLV_DB_SCALE(mic_tlv, 1600, 100, 0);
 
+static DECLARE_TLV_DB_SCALE(adc_mix_tlv, -5150, 50, 0);
+
 static DECLARE_TLV_DB_SCALE(pga_tlv, -600, 50, 0);
 
-static DECLARE_TLV_DB_SCALE(mix_tlv, -50, 50, 0);
+static DECLARE_TLV_DB_SCALE(mix_tlv, -5150, 50, 0);
 
-static DECLARE_TLV_DB_SCALE(beep_tlv, -56, 200, 0);
+static DECLARE_TLV_DB_SCALE(bypass_tlv, -6000, 50, 0);
+
+static DECLARE_TLV_DB_SCALE(beep_tlv, -5600, 200, 0);
 
 static const unsigned int limiter_tlv[] = {
 	TLV_DB_RANGE_HEAD(2),
@@ -396,18 +402,18 @@
 static const struct snd_kcontrol_new cs42l52_snd_controls[] = {
 
 	SOC_DOUBLE_R_SX_TLV("Master Volume", CS42L52_MASTERA_VOL,
-			      CS42L52_MASTERB_VOL, 0, 0x34, 0xE4, hl_tlv),
+			      CS42L52_MASTERB_VOL, 0, 0x88, 0x90, mst_tlv),
 
 	SOC_DOUBLE_R_SX_TLV("Headphone Volume", CS42L52_HPA_VOL,
-			      CS42L52_HPB_VOL, 0, 0x34, 0xC0, hpd_tlv),
+			      CS42L52_HPB_VOL, 0, 0x40, 0xc0, hpd_tlv),
 
 	SOC_ENUM("Headphone Analog Gain", hp_gain_enum),
 
 	SOC_DOUBLE_R_SX_TLV("Speaker Volume", CS42L52_SPKA_VOL,
-			      CS42L52_SPKB_VOL, 0, 0x40, 0xC0, hl_tlv),
+			    CS42L52_SPKB_VOL, 0, 0x40, 0xc0, hpd_tlv),
 
 	SOC_DOUBLE_R_SX_TLV("Bypass Volume", CS42L52_PASSTHRUA_VOL,
-			      CS42L52_PASSTHRUB_VOL, 0, 0x88, 0x90, pga_tlv),
+			      CS42L52_PASSTHRUB_VOL, 0, 0x88, 0x90, bypass_tlv),
 
 	SOC_DOUBLE("Bypass Mute", CS42L52_MISC_CTL, 4, 5, 1, 0),
 
@@ -420,7 +426,7 @@
 			      CS42L52_ADCB_VOL, 0, 0xA0, 0x78, ipd_tlv),
 	SOC_DOUBLE_R_SX_TLV("ADC Mixer Volume",
 			     CS42L52_ADCA_MIXER_VOL, CS42L52_ADCB_MIXER_VOL,
-				0, 0x19, 0x7F, ipd_tlv),
+				0, 0x19, 0x7F, adc_mix_tlv),
 
 	SOC_DOUBLE("ADC Switch", CS42L52_ADC_MISC_CTL, 0, 1, 1, 0),
 
@@ -428,7 +434,7 @@
 		     CS42L52_ADCB_MIXER_VOL, 7, 1, 1),
 
 	SOC_DOUBLE_R_SX_TLV("PGA Volume", CS42L52_PGAA_CTL,
-			    CS42L52_PGAB_CTL, 0, 0x28, 0x24, pga_tlv),
+			    CS42L52_PGAB_CTL, 0, 0xF4, 0x24, pga_tlv),
 
 	SOC_DOUBLE_R_SX_TLV("PCM Mixer Volume",
 			    CS42L52_PCMA_MIXER_VOL, CS42L52_PCMB_MIXER_VOL,
@@ -448,15 +454,15 @@
 
 	SOC_SINGLE("Tone Control Switch", CS42L52_BEEP_TONE_CTL, 0, 1, 1),
 	SOC_SINGLE_TLV("Treble Gain Volume",
-			    CS42L52_TONE_CTL, 4, 15, 1, hl_tlv),
+			    CS42L52_TONE_CTL, 4, 0xf, 1, bass_gain_tlv),
 	SOC_SINGLE_TLV("Bass Gain Volume",
-			    CS42L52_TONE_CTL, 0, 15, 1, hl_tlv),
+			    CS42L52_TONE_CTL, 0, 0xf, 1, bass_gain_tlv),
 
 	/* Limiter */
 	SOC_SINGLE_TLV("Limiter Max Threshold Volume",
-		       CS42L52_LIMITER_CTL1, 5, 7, 0, limiter_tlv),
+		       CS42L52_LIMITER_CTL1, 5, 7, 1, limiter_tlv),
 	SOC_SINGLE_TLV("Limiter Cushion Threshold Volume",
-		       CS42L52_LIMITER_CTL1, 2, 7, 0, limiter_tlv),
+		       CS42L52_LIMITER_CTL1, 2, 7, 1, limiter_tlv),
 	SOC_SINGLE_TLV("Limiter Release Rate Volume",
 		       CS42L52_LIMITER_CTL2, 0, 63, 0, limiter_tlv),
 	SOC_SINGLE_TLV("Limiter Attack Rate Volume",
@@ -898,14 +904,12 @@
 		break;
 	case SND_SOC_BIAS_STANDBY:
 		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
-			regcache_cache_only(cs42l52->regmap, false);
 			regcache_sync(cs42l52->regmap);
 		}
 		snd_soc_write(codec, CS42L52_PWRCTL1, CS42L52_PWRCTL1_PDN_ALL);
 		break;
 	case SND_SOC_BIAS_OFF:
 		snd_soc_write(codec, CS42L52_PWRCTL1, CS42L52_PWRCTL1_PDN_ALL);
-		regcache_cache_only(cs42l52->regmap, true);
 		break;
 	}
 
@@ -1083,8 +1087,6 @@
 {
 	struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec);
 
-	regcache_cache_only(cs42l52->regmap, true);
-
 	cs42l52_add_mic_controls(codec);
 
 	cs42l52_init_beep(codec);
@@ -1197,7 +1199,7 @@
 		cs42l52->pdata = *pdata;
 	}
 
-	if (cs42l52->pdata.reset_gpio) {
+	if ((int)cs42l52->pdata.reset_gpio >= 0) {
 		ret = devm_gpio_request_one(&i2c_client->dev,
 					    cs42l52->pdata.reset_gpio,
 					    GPIOF_OUT_INIT_HIGH,
diff -ruw linux-4.2.6/sound/soc/kirkwood/Kconfig linux-4.2.6-fbx/sound/soc/kirkwood/Kconfig
--- linux-4.2.6/sound/soc/kirkwood/Kconfig	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/sound/soc/kirkwood/Kconfig	2015-11-18 18:24:34.140183355 +0100
@@ -15,3 +15,8 @@
 	  Say Y if you want to add support for SoC audio on
 	  the Armada 370 Development Board.
 
+config SND_KIRKWOOD_SOC_FBXGW2R
+	tristate "Soc Audio support for fbxgw2r"
+	depends on SND_KIRKWOOD_SOC && MACH_FBXGW2R && I2C
+	select SND_KIRKWOOD_SOC_I2S
+	select SND_SOC_CS42L52
diff -ruw linux-4.2.6/sound/soc/kirkwood/kirkwood-dma.c linux-4.2.6-fbx/sound/soc/kirkwood/kirkwood-dma.c
--- linux-4.2.6/sound/soc/kirkwood/kirkwood-dma.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/sound/soc/kirkwood/kirkwood-dma.c	2015-11-18 18:24:34.144183382 +0100
@@ -202,22 +202,29 @@
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct kirkwood_dma_data *priv = kirkwood_priv(substream);
 	unsigned long size, count;
+	unsigned long val;
 
 	/* compute buffer size in term of "words" as requested in specs */
 	size = frames_to_bytes(runtime, runtime->buffer_size);
 	size = (size>>2)-1;
 	count = snd_pcm_lib_period_bytes(substream);
 
+	val = readl(priv->io + KIRKWOOD_SCNTR_CTL);
+
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 		writel(count, priv->io + KIRKWOOD_PLAY_BYTE_INT_COUNT);
 		writel(runtime->dma_addr, priv->io + KIRKWOOD_PLAY_BUF_ADDR);
 		writel(size, priv->io + KIRKWOOD_PLAY_BUF_SIZE);
+		val |= KIRKWOOD_SCNTR_CTL_PLAY_CLEAR |
+			KIRKWOOD_SCNTR_CTL_PLAY_EN;
 	} else {
 		writel(count, priv->io + KIRKWOOD_REC_BYTE_INT_COUNT);
 		writel(runtime->dma_addr, priv->io + KIRKWOOD_REC_BUF_ADDR);
 		writel(size, priv->io + KIRKWOOD_REC_BUF_SIZE);
+		val |= KIRKWOOD_SCNTR_CTL_REC_CLEAR |
+			KIRKWOOD_SCNTR_CTL_REC_EN;
 	}
-
+	writel(val, priv->io + KIRKWOOD_SCNTR_CTL);
 
 	return 0;
 }
@@ -238,6 +245,35 @@
 	return count;
 }
 
+static snd_pcm_sframes_t kirkwood_dma_delay(struct snd_pcm_substream *substream,
+					    struct snd_soc_dai *codec_dai)
+{
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
+	struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
+	struct kirkwood_dma_data *priv;
+	snd_pcm_sframes_t cur_pointer;
+	u32 real;
+
+	priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
+
+	/* it sucks that we have to call pointer again, would be
+	 * better if current one was given */
+	cur_pointer = kirkwood_dma_pointer(substream);
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		real = readl(priv->io + KIRKWOOD_PLAY_SCNTR);
+	else
+		real = readl(priv->io + KIRKWOOD_REC_SCNTR);
+
+	real %= runtime->buffer_size;
+
+	if (cur_pointer >= real)
+		return cur_pointer - real;
+	return runtime->buffer_size - real + cur_pointer - 1;
+
+}
+
 static struct snd_pcm_ops kirkwood_dma_ops = {
 	.open =		kirkwood_dma_open,
 	.close =        kirkwood_dma_close,
@@ -316,6 +352,7 @@
 
 struct snd_soc_platform_driver kirkwood_soc_platform = {
 	.ops		= &kirkwood_dma_ops,
+	.delay		= kirkwood_dma_delay,
 	.pcm_new	= kirkwood_dma_new,
 	.pcm_free	= kirkwood_dma_free_dma_buffers,
 };
diff -ruw linux-4.2.6/sound/soc/kirkwood/kirkwood.h linux-4.2.6-fbx/sound/soc/kirkwood/kirkwood.h
--- linux-4.2.6/sound/soc/kirkwood/kirkwood.h	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/sound/soc/kirkwood/kirkwood.h	2015-11-18 18:24:34.144183382 +0100
@@ -80,6 +80,15 @@
 #define KIRKWOOD_DCO_CTL_FREQ_12		(1<<0)
 #define KIRKWOOD_DCO_CTL_FREQ_24		(2<<0)
 
+#define KIRKWOOD_SCNTR_CTL			0x1220
+#define KIRKWOOD_SCNTR_CTL_REC_EN		(1 << 0)
+#define KIRKWOOD_SCNTR_CTL_PLAY_EN		(1 << 1)
+#define KIRKWOOD_SCNTR_CTL_REC_CLEAR		(1 << 8)
+#define KIRKWOOD_SCNTR_CTL_PLAY_CLEAR		(1 << 9)
+
+#define KIRKWOOD_PLAY_SCNTR			0x1224
+#define KIRKWOOD_REC_SCNTR			0x1228
+
 #define KIRKWOOD_DCO_SPCR_STATUS		0x120c
 #define KIRKWOOD_DCO_SPCR_STATUS_DCO_LOCK	(1<<16)
 
diff -ruw linux-4.2.6/sound/soc/kirkwood/Makefile linux-4.2.6-fbx/sound/soc/kirkwood/Makefile
--- linux-4.2.6/sound/soc/kirkwood/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/sound/soc/kirkwood/Makefile	2015-11-18 18:24:34.140183355 +0100
@@ -5,3 +5,6 @@
 snd-soc-armada-370-db-objs := armada-370-db.o
 
 obj-$(CONFIG_SND_KIRKWOOD_SOC_ARMADA370_DB) += snd-soc-armada-370-db.o
+
+snd-soc-fbxgw2r-objs := kirkwood-fbxgw2r.o
+obj-$(CONFIG_SND_KIRKWOOD_SOC_FBXGW2R) += snd-soc-fbxgw2r.o
diff -ruw linux-4.2.6/sound/soc/soc-ops.c linux-4.2.6-fbx/sound/soc/soc-ops.c
--- linux-4.2.6/sound/soc/soc-ops.c	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/sound/soc/soc-ops.c	2015-11-18 18:24:34.164183541 +0100
@@ -201,7 +201,7 @@
 
 	uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1;
 	uinfo->value.integer.min = 0;
-	uinfo->value.integer.max = platform_max - mc->min;
+	uinfo->value.integer.max = platform_max;
 	return 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
diff -ruw linux-4.2.6/usr/Makefile linux-4.2.6-fbx/usr/Makefile
--- linux-4.2.6/usr/Makefile	2015-11-09 23:37:56.000000000 +0100
+++ linux-4.2.6-fbx/usr/Makefile	2015-11-18 18:24:34.280184466 +0100
@@ -49,8 +49,10 @@
 # in initramfs and to detect if any files are added/removed.
 # Removed files are identified by directory timestamp being updated
 # The dependency list is generated by gen_initramfs.sh -l
-ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
-	include $(obj)/.initramfs_data.cpio.d
+ifneq ($(wildcard $(obj)/.initramfs_data.cpio$(suffix_y).d),)
+	include $(obj)/.initramfs_data.cpio$(suffix_y).d
+else
+	deps_initramfs := FORCE
 endif
 
 quiet_cmd_initfs = GEN     $@
@@ -70,5 +72,5 @@
 # 3) If gen_init_cpio are newer than initramfs_data.cpio
 # 4) arguments to gen_initramfs.sh changes
 $(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
-	$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
+	$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio$(suffix_y).d
 	$(call if_changed,initfs)
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/boot/dts/fbxgw1r.dts	2015-11-18 18:24:28.560139098 +0100
@@ -0,0 +1,109 @@
+/dts-v1/;
+
+#include "kirkwood.dtsi"
+#include "kirkwood-6281.dtsi"
+
+/ {
+	model = "Freebox Gateway V1";
+	compatible = "freebox,fbxgw1r";
+
+	chosen {
+		stdout-path = &uart1;
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x20000000>; /* 512 MB */
+	};
+
+	ocp@f1000000 {
+		fbxwdt: fbxwatchdog-timer@20300 {
+			compatible = "marvell,orion-fbxwdt";
+			reg = <0x20300 0x28>, <0x20108 0x4>;
+			clocks = <&gate_clk 7>;
+			fbx,legacy-device-name = "orion_fbxwdt";
+			status = "okay";
+		};
+	};
+
+	aliases {
+		spi0 = &tdm_spi0;
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
+&uart1 {
+	status = "okay";
+};
+
+&pmx_uart1 {
+	marvell,pins = "mpp15", "mpp16";
+	marvell,function = "uart1";
+};
+
+&pmx_uart0 {
+	/* only mpp11 here (uart rx) as mpp10 is used as a gpio */
+	marvell,pins = "mpp11";
+	marvell,function = "uart0";
+};
+
+
+&usb0 {
+	status = "okay";
+	fbx,legacy-device-name = "orion-ehci.0";
+};
+
+&eth0 {
+	status = "okay";
+	fbx,ff-model = <1>;
+};
+&eth0port {
+	fbxserial-mac-address = <0>;
+	speed = <1000>;
+	duplex = <1>;
+};
+
+&eth1 {
+	status = "okay";
+};
+&eth1port {
+	fbxserial-mac-address = <0>;
+	speed = <1000>;
+	duplex = <1>;
+};
+
+&mdio {
+	status = "okay";
+};
+
+&i2c0 {
+	status = "okay";
+	clock-frequency = <25000>;
+	fbx,legacy-device-name = "mv64xxx_i2c.0";
+
+	adt7475@2e {
+		compatible = "adi,adt7475";
+		reg = <0x2e>;
+	};
+};
+
+&tdm_spi0 {
+	fbx,cs-gpios = <(-1) 36>;
+	status = "okay";
+	pinctrl-0 = <&pmx_alt_tdm_spi>;
+};
+
+&sata {
+	status = "okay";
+	nr-ports = <2>;
+	fbx,legacy-device-name = "sata_mv.0";
+};
+
+&pciec {
+	status = "okay";
+};
+&pcie0 {
+	status = "okay";
+};
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/boot/dts/fbxgw2r.dts	2015-11-18 18:24:28.560139098 +0100
@@ -0,0 +1,119 @@
+/dts-v1/;
+
+#include "kirkwood.dtsi"
+#include "kirkwood-6282.dtsi"
+
+/ {
+	model = "Freebox Gateway V2";
+	compatible = "freebox,fbxgw2r";
+
+	chosen {
+		stdout-path = &uart1;
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x40000000>; /* 1024 MB */
+	};
+
+	ocp@f1000000 {
+		fbxwdt: fbxwatchdog-timer@20300 {
+			compatible = "marvell,orion-fbxwdt";
+			reg = <0x20300 0x28>, <0x20108 0x4>;
+			clocks = <&gate_clk 7>;
+			fbx,legacy-device-name = "orion_fbxwdt";
+			status = "okay";
+		};
+	};
+
+	aliases {
+		spi0 = &tdm_spi0;
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
+&uart1 {
+	status = "okay";
+};
+
+&pmx_uart1 {
+	marvell,pins = "mpp15", "mpp16";
+	marvell,function = "uart1";
+};
+
+&nand {
+	status = "foutu";
+};
+&usb0 {
+	status = "okay";
+	fbx,legacy-device-name = "orion-ehci.0";
+};
+
+&eth0 {
+	status = "okay";
+	fbx,ff-model = <2>;
+};
+
+&eth0port {
+	fbxserial-mac-address = <0>;
+	speed = <1000>;
+	duplex = <1>;
+};
+
+&mdio {
+	status = "okay";
+};
+
+&i2c0 {
+	status = "okay";
+	clock-frequency = <25000>;
+	fbx,legacy-device-name = "mv64xxx_i2c.0";
+
+	adt7475@2e {
+		compatible = "adi,adt7475";
+		reg = <0x2e>;
+	};
+};
+
+&i2c1 {
+	status = "okay";
+	clock-frequency = <25000>;
+	fbx,legacy-device-name = "mv64xxx_i2c.1";
+
+	codec@4a {
+		compatible = "cirrus,cs42l52";
+		// cirrus,reset-gpio = <0>;
+		reg = <0x4a>;
+	};
+};
+
+&audio0 {
+	status = "okay";
+};
+
+&gpio1 {
+       marvell,broken-mpp33-dir = <1>;
+};
+
+&tdm_spi0 {
+	fbx,cs-gpios = <(-1) 34>;
+	status = "okay";
+};
+
+&sata {
+	status = "okay";
+	nr-ports = <2>;
+	fbx,legacy-device-name = "sata_mv.0";
+};
+
+&pciec {
+	status = "okay";
+};
+&pcie0 {
+	status = "okay";
+};
+&pcie1 {
+	status = "okay";
+};
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/fbxgw1r-setup.c	2015-11-18 18:24:28.740140521 +0100
@@ -0,0 +1,509 @@
+/*
+ * Freebox GW01r
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/kernel.h>
+#include <linux/gpio.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/fbxgpio_core.h>
+#include <linux/smsc_cap1066.h>
+#include <linux/platform_data/at24.h>
+#include <linux/i2c.h>
+#include <linux/input.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/flash.h>
+#include <linux/spi/ssd1327.h>
+
+#include <mach/board_fbxgw1r.h>
+
+#define PFX	"fbxgw1r: "
+
+#include "fbxgw-switch.h"
+#include "fbxgw-common.h"
+#include "fbxgw-pcie.h"
+
+/*
+ * set shift registers output to given value
+ */
+static void set_shift_register(u8 val)
+{
+	int i;
+
+	gpio_set_value(GPIO_SR_CLK, 0);
+	gpio_set_value(GPIO_SR_LOAD, 0);
+
+	udelay(1);
+
+	for (i = 7; i >= 0; i--) {
+		gpio_set_value(GPIO_SR_DIN, (val & (1 << i)) ? 1 : 0);
+		udelay(100);
+		gpio_set_value(GPIO_SR_CLK, 1);
+		udelay(100);
+		gpio_set_value(GPIO_SR_CLK, 0);
+	}
+
+	udelay(1);
+	gpio_set_value(GPIO_SR_LOAD, 1);
+	udelay(1);
+}
+
+/*
+ * reset values can not be read back from shift registers, we have to
+ * keep them
+ */
+static DEFINE_SPINLOCK(sr_lock);
+static unsigned long sr_value;
+
+/*
+ * clear or set sr bit
+ */
+static void sr_set_bit(int bit, int value)
+{
+	unsigned long flags;
+
+	value = !!value;
+	spin_lock_irqsave(&sr_lock, flags);
+	sr_value &= ~(1 << bit);
+	sr_value |= (value << bit);
+	set_shift_register((u8)sr_value);
+	spin_unlock_irqrestore(&sr_lock, flags);
+}
+
+/*
+ * return cached bit value
+ */
+static int sr_get_bit(int bit)
+{
+	return test_bit(bit, &sr_value);
+}
+
+/*
+ * control PCIe bus reset
+ */
+static void fbxgw1r_pcie_reset(int value)
+{
+	sr_set_bit(SROUT_PCIE_RST, value);
+}
+
+/*
+ * control marvell swith reset
+ */
+static void fbxgw1r_marvell_switch_reset(int value)
+{
+	gpio_set_value(GPIO_SW_RESET, value);
+}
+
+static int fbxgw1r_do_vlan(void)
+{
+	return 1;
+}
+
+#define NFS_VLAN_ID 41
+
+int marvell_6161_config(struct net_device *dev, int probe,
+			int (*mii_read)(struct net_device *dev,
+					int phy_id, int reg),
+			void (*mii_write)(struct net_device *dev,
+					  int phy_id, int reg, int val))
+{
+	u16 val;
+	struct mii_struct mii = {
+		.dev = dev,
+		.read = mii_read,
+		.write = mii_write,
+	};
+
+	if (!probe)
+		return 0;
+
+	/* switch needs more than 1 second (!) to go out of reset */
+	fbxgw1r_marvell_switch_reset(0);
+	mdelay(1);
+	fbxgw1r_marvell_switch_reset(1);
+	msleep(2000);
+
+	/* probe */
+	val = mii.read(mii.dev, SWPORT(0), PORTREG_SWITCH_IDENTIFIER);
+	if (PRODUCT_NUM(val) != 0x161) {
+		printk(KERN_ERR PFX "unknown switch id: 0x%08x\n",
+		       PRODUCT_NUM(val));
+		return 1;
+	}
+	mii.dev_id = PRODUCT_NUM(val);
+	mii.indirect_phy_access = false;
+
+	fbxgw_sw_config_cpu_port(&mii, SWPORT(5));
+	fbxgw_sw_config_phy_port(&mii, PHYPORT(1));
+
+
+	if (fbxgw1r_do_vlan()) {
+		const u8 config[6] = {
+			PDATA_NOT_MEMBER,
+			PDATA_MEMBER_UNTAGGED,
+			PDATA_NOT_MEMBER,
+			PDATA_NOT_MEMBER,
+			PDATA_NOT_MEMBER,
+			PDATA_MEMBER_TAGGED,
+		};
+
+		fbxgw_sw_vtu_load(&mii, NFS_VLAN_ID, config, sizeof (config));
+
+		fbxgw_sw_port_default_vid(&mii, SWPORT(1), NFS_VLAN_ID);
+		fbxgw_sw_port_dot1q_secure(&mii, SWPORT(1));
+		fbxgw_sw_port_dot1q_secure(&mii, SWPORT(5));
+	}
+
+	fbxgw_sw_port_forward_enable(&mii, SWPORT(1));
+	fbxgw_sw_port_forward_enable(&mii, SWPORT(5));
+
+	printk(KERN_INFO PFX "marvell 6161 initialized\n");
+	return 0;
+}
+
+static const struct flash_platform_data	flash_info = {
+	.name		= "bcmflash",
+};
+
+static const struct ssd1327_platform_data ssd1327_pd = {
+	.data_select_gpio	= GPIO_OLED_DATA_SELECT,
+	.width			= 128,
+	.height			= 128,
+	.rotate			= 270,
+	.watchdog		= 300,
+};
+
+static struct spi_board_info spi_board_info[] __initdata = {
+
+	{
+		.modalias       = "ssd1327",
+		.platform_data	= &ssd1327_pd,
+		.mode		= SPI_MODE_0,
+		.max_speed_hz	= 10 * 1000 * 1000,
+		.bus_num	= 0,
+		.chip_select    = 0,
+	},
+
+	{
+		.modalias       = "m25p80",
+		.platform_data	= &flash_info,
+		.mode		= SPI_MODE_0,
+		.max_speed_hz	= 4 * 1000 * 1000,
+		.bus_num	= 0,
+		.chip_select    = 1,
+	},
+};
+
+/*
+ * fbxgpio
+ */
+static struct fbxgpio_operations fbxgw1r_gpio_ops = {
+	/* cast only for signed/unsigned */
+	.get_datain = (int (*)(int))gpio_get_value,
+	.get_dataout = (int (*)(int))gpio_get_value,
+	.set_dataout = (void (*)(int, int))gpio_set_value,
+};
+
+static struct fbxgpio_operations fbxgw1r_sr_ops = {
+	.get_dataout = sr_get_bit,
+	.set_dataout = sr_set_bit,
+};
+
+static struct fbxgpio_pin fbxgw1r_gpio_pins[] = {
+	/* marvell gpios */
+	{
+		.pin_name	 = "oled-data-select",
+		.direction	= GPIO_DIR_OUT,
+		.pin_num	= GPIO_OLED_DATA_SELECT,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "test-mode",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_TEST_MODE,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "sfp-txdis",
+		.direction	= GPIO_DIR_OUT,
+		.pin_num	= GPIO_SFP_TXDIS,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "sw-reset",
+		.direction	= GPIO_DIR_OUT,
+		.pin_num	= GPIO_SW_RESET,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "sw-int",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_SW_INT,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "sfp-pwrgood",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_SFP_PWRGOOD,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "sfp-txfault",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_SFP_TXFAULT,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "sfp-presence",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_SFP_PRESENCE,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "sfp-rxloss",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_SFP_RXLOSS,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "exp-rst",
+		.direction	= GPIO_DIR_OUT,
+		.pin_num	= GPIO_EXP_RST,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "pos-sense",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_POS_SENSE,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "exp-pwrgood",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_EXP_PWRGOOD,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "exp-presence",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_EXP_PRESENCE,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "kp-int",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_KP_INT,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "board-id-0",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_BOARD_ID_0,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+	{
+		.pin_name	= "board-id-1",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_BOARD_ID_1,
+		.ops		= &fbxgw1r_gpio_ops,
+	},
+
+	/* shift registers resets */
+	{
+		.pin_name       = "sfp-pwren",
+		.direction      = GPIO_DIR_OUT,
+		.pin_num	= SROUT_SFP_PWREN,
+		.ops		= &fbxgw1r_sr_ops,
+	},
+	{
+		.pin_name       = "usb-rst",
+		.direction      = GPIO_DIR_OUT,
+		.pin_num	= SROUT_USB_RST,
+		.ops		= &fbxgw1r_sr_ops,
+	},
+	{
+		.pin_name       = "audio-rst",
+		.direction      = GPIO_DIR_OUT,
+		.pin_num	= SROUT_AUDIO_RST,
+		.ops		= &fbxgw1r_sr_ops,
+	},
+	{
+		.pin_name       = "exp-pwren",
+		.direction      = GPIO_DIR_OUT,
+		.pin_num	= SROUT_EXP_PWREN,
+		.ops		= &fbxgw1r_sr_ops,
+	},
+	{
+		.pin_name       = "bcm-rst",
+		.direction      = GPIO_DIR_OUT,
+		.pin_num	= SROUT_BCM_RST,
+		.ops		= &fbxgw1r_sr_ops,
+	},
+	{
+		.pin_name       = "pcie-rst",
+		.direction      = GPIO_DIR_OUT,
+		.pin_num	= SROUT_PCIE_RST,
+		.ops		= &fbxgw1r_sr_ops,
+	},
+	{
+		.pin_name       = "keypad-oled-rst",
+		.direction      = GPIO_DIR_OUT,
+		.pin_num	= SROUT_KEYPAD_OLED_RST,
+		.ops		= &fbxgw1r_sr_ops,
+	},
+	{
+		.pin_name       = "keypad-pwren",
+		.direction      = GPIO_DIR_OUT,
+		.pin_num	= SROUT_OLED_PWREN,
+		.ops		= &fbxgw1r_sr_ops,
+	},
+
+
+	{  },
+};
+
+static struct platform_device fbxgw1r_gpio_device = {
+	.name   = "fbxgpio",
+	.id     = -1,
+	.dev    = {
+		.platform_data = &fbxgw1r_gpio_pins,
+	},
+};
+
+/*
+ * i2c midplane eeprom.
+ */
+static struct at24_platform_data midplane_eeprom_data = {
+	.byte_len	= 4096,
+	.page_size	= 8,
+	.flags		= AT24_FLAG_ADDR16,
+};
+
+/*
+ * expansion board eeprom.
+ */
+static struct at24_platform_data expansion_eeprom_data = {
+	.byte_len	= 32768,
+	.page_size	= 64,
+	.flags		= AT24_FLAG_ADDR16,
+};
+
+/*
+ * i2c smsc
+ */
+static struct smsc_cap1066_pdata cap1066_pdata = {
+	.key_map = {
+		KEY_DOWN,
+		KEY_LEFT,
+		KEY_UP,
+		0,
+		KEY_ENTER,
+		KEY_RIGHT,
+	},
+
+	.has_irq_gpio = true,
+	.irq_gpio = GPIO_KP_INT,
+};
+
+static struct i2c_board_info fbxgw1r_i2c_devs[] = {
+	{
+		.type		= "cap1066",
+		.addr		= 0x28,
+		.platform_data	= &cap1066_pdata,
+	},
+	{
+		.type		= "24c32",
+		.addr		= 0x57,
+		.platform_data	= &midplane_eeprom_data,
+	},
+	{
+		.type		= "24c256",
+		.addr		= 0x53,
+		.platform_data	= &expansion_eeprom_data,
+	},
+};
+
+void __init fbxgw1r_init(void)
+{
+	struct fbxgw_pcie_priv *pex_priv;
+
+	printk("fbxgw1r-init.\n");
+	panic_timeout = 10;
+	panic_on_oops = 1;
+
+	fbxgw_common_fixup_i2c(0);
+
+	gpio_request(GPIO_OLED_DATA_SELECT, "oled-data-select");
+	gpio_request(GPIO_SR_CLK, "sr-clk");
+	gpio_request(GPIO_SR_DIN, "sr-din");
+	gpio_request(GPIO_TEST_MODE, "test-mode");
+	gpio_request(GPIO_SFP_TXDIS, "sfp-txdis");
+	gpio_request(GPIO_SR_LOAD, "sr-load");
+	gpio_request(GPIO_SW_RESET, "sw-reset");
+	gpio_request(GPIO_SW_INT, "sw-int");
+	gpio_request(GPIO_SFP_PWRGOOD, "sfp-pwrgood");
+	gpio_request(GPIO_SFP_TXFAULT, "sfp-txfault");
+	gpio_request(GPIO_SPI_CS_BCM, "spi-cs-bcm");
+	gpio_request(GPIO_SFP_PRESENCE, "sfp-presence");
+	gpio_request(GPIO_SFP_RXLOSS, "sfp-rxloss");
+	gpio_request(GPIO_EXP_RST, "exp-rst");
+	gpio_request(GPIO_POS_SENSE, "pos-sense");
+	gpio_request(GPIO_EXP_PWRGOOD, "exp-pwrgood");
+	gpio_request(GPIO_EXP_PRESENCE, "exp-presence");
+	gpio_request(GPIO_KP_INT, "kp-int");
+	gpio_request(GPIO_BOARD_ID_0, "board-id-0");
+	gpio_request(GPIO_BOARD_ID_1, "board-id-1");
+
+	gpio_direction_output(GPIO_OLED_DATA_SELECT, 0);
+	gpio_direction_output(GPIO_SR_CLK, 0);
+	gpio_direction_output(GPIO_SR_DIN, 0);
+	gpio_direction_input(GPIO_TEST_MODE);
+	gpio_direction_output(GPIO_SFP_TXDIS, 1);
+	gpio_direction_output(GPIO_SR_LOAD, 0);
+	gpio_direction_output(GPIO_SW_RESET, 1);
+	gpio_direction_input(GPIO_SW_INT);
+	gpio_direction_input(GPIO_SFP_PWRGOOD);
+	gpio_direction_input(GPIO_SFP_TXFAULT);
+	gpio_direction_output(GPIO_SPI_CS_BCM, 1);
+	gpio_direction_input(GPIO_SFP_PRESENCE);
+	gpio_direction_input(GPIO_SFP_RXLOSS);
+	gpio_direction_output(GPIO_EXP_RST, 0);
+	gpio_direction_input(GPIO_POS_SENSE);
+	gpio_direction_input(GPIO_EXP_PWRGOOD);
+	gpio_direction_input(GPIO_EXP_PRESENCE);
+	gpio_direction_input(GPIO_KP_INT);
+	gpio_direction_input(GPIO_BOARD_ID_0);
+	gpio_direction_input(GPIO_BOARD_ID_1);
+
+	/* set shift register default value */
+	sr_value = (0 << SROUT_PCIE_RST) |
+		(0 << SROUT_BCM_RST) |
+		(1 << SROUT_KEYPAD_OLED_RST) |
+		(0 << SROUT_SFP_PWREN) |
+		(1 << SROUT_USB_RST) |
+		(1 << SROUT_AUDIO_RST) |
+		(0 << SROUT_EXP_PWREN) |
+		(1 << SROUT_OLED_PWREN);
+	set_shift_register((u8)sr_value);
+
+	i2c_register_board_info(0, fbxgw1r_i2c_devs,
+				ARRAY_SIZE(fbxgw1r_i2c_devs));
+	spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
+	fbxgw_common_nand_init();
+
+	if (fbxgw_pcie_preinit(&pex_priv) == 0) {
+		fbxgw1r_pcie_reset(0);
+		mdelay(100);
+		fbxgw1r_pcie_reset(1);
+		mdelay(100);
+		fbxgw_pcie_retrain_link(pex_priv);
+		fbxgw_pcie_preexit(pex_priv);
+	}
+
+	fbxgw_fbxatm_init();
+	platform_device_register(&fbxgw1r_gpio_device);
+}
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/fbxgw2r-setup.c	2015-11-18 18:24:28.740140521 +0100
@@ -0,0 +1,433 @@
+/*
+ * fbxgw2r-setup.c for fbxgw2r
+ * Created by <nschichan@freebox.fr> on Thu Jan 22 14:27:03 2015
+ */
+
+#include <linux/kernel.h>
+#include <linux/gpio.h>
+#include <linux/fbxgpio_core.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/platform_data/at24.h>
+#include <linux/smsc_cap1066.h>
+#include <linux/input.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/flash.h>
+#include <linux/spi/ssd1327.h>
+
+#include <mach/board_fbxgw2r.h>
+
+#include "board.h"
+#include "fbxgw-common.h"
+#include "fbxgw-switch.h"
+#include "fbxgw-pcie.h"
+
+#define PFX	"fbxgw2r: "
+
+/*
+ * reset whatever is behind the (inactive) mini-PCIe connector
+ */
+static void fbxgw2r_pcie_reset(int value)
+{
+	gpio_set_value(GPIO_PCIE_RST, value);
+}
+
+/*
+ * reset onboard WLAN chip.
+ */
+static void fbxgw2r_wlan_rst(int value)
+{
+	gpio_set_value(GPIO_WLAN_RST, value);
+}
+
+/*
+ * reset onboard audio codec
+ */
+static void fbxgw2r_audio_rst(int value)
+{
+	gpio_set_value(GPIO_AUDIO_RST, value);
+}
+
+static void fbxgw2r_marvell_switch_reset(int value)
+{
+	gpio_set_value(GPIO_SW_RESET, value);
+}
+
+static int fbxgw2r_do_vlan(void)
+{
+	/* hardcode to 1 for now. */
+	return 1;
+}
+
+#define NFS_VLAN_ID			41
+
+int marvell_6176_config(struct net_device *dev, int probe,
+			int (*mii_read)(struct net_device *dev,
+					int phy_id, int reg),
+			void (*mii_write)(struct net_device *dev,
+					  int phy_id, int reg, int val))
+{
+	u16 val;
+	struct mii_struct mii = {
+		.dev_id = 0,
+		.dev = dev,
+		.read = mii_read,
+		.write = mii_write,
+	};
+
+	if (!probe)
+		return 0;
+
+	fbxgw2r_marvell_switch_reset(0);
+	msleep(1);
+	fbxgw2r_marvell_switch_reset(1);
+	msleep(2000);
+
+	/* probe */
+	val = mii_read(dev, SWPORT(0), PORTREG_SWITCH_IDENTIFIER);
+	if (PRODUCT_NUM(val) != 0x176) {
+		printk(KERN_ERR PFX "unknown switch id: 0x%08x\n",
+		       PRODUCT_NUM(val));
+		return 1;
+	}
+	mii.dev_id = PRODUCT_NUM(val);
+	mii.indirect_phy_access = true;
+
+	fbxgw_sw_config_cpu_port(&mii, SWPORT(5));
+	fbxgw_sw_config_phy_port(&mii, PHYPORT(0));
+
+	mii.write(dev, SWPORT(0), 0x16, 0x8011);
+	mii.write(dev, SWPORT(1), 0x16, 0x8011);
+	mii.write(dev, SWPORT(2), 0x16, 0x8011);
+	mii.write(dev, SWPORT(3), 0x16, 0x8011);
+
+	if (fbxgw2r_do_vlan()) {
+		const u8 config[7] = {
+			PDATA_MEMBER_UNTAGGED,
+			PDATA_NOT_MEMBER,
+			PDATA_NOT_MEMBER,
+			PDATA_NOT_MEMBER,
+			PDATA_NOT_MEMBER,
+			PDATA_MEMBER_TAGGED,
+			PDATA_NOT_MEMBER,
+		};
+
+		fbxgw_sw_vtu_stu_init(&mii, PCR_PORTSTATE_FORWARDING,
+				      sizeof (config));
+		fbxgw_sw_vtu_load(&mii, NFS_VLAN_ID, config, sizeof (config));
+
+		fbxgw_sw_port_default_vid(&mii, SWPORT(0), NFS_VLAN_ID);
+		fbxgw_sw_port_dot1q_secure(&mii, SWPORT(0));
+		fbxgw_sw_port_dot1q_secure(&mii, SWPORT(5));
+	}
+
+	fbxgw_sw_port_forward_enable(&mii, SWPORT(5));
+	fbxgw_sw_port_forward_enable(&mii, SWPORT(0));
+
+	printk(KERN_INFO PFX "marvell 6176 initialized\n");
+
+	return 0;
+}
+
+static const struct flash_platform_data	flash_info = {
+	.name		= "bcmflash",
+};
+
+static const struct ssd1327_platform_data ssd1327_pd = {
+	.data_select_gpio	= GPIO_OLED_DATA_SELECT,
+	.width			= 128,
+	.height			= 128,
+	.rotate			= 270,
+	.watchdog		= 300,
+};
+
+static struct spi_board_info spi_board_info[] __initdata = {
+	{
+		.modalias       = "ssd1327",
+		.platform_data	= &ssd1327_pd,
+		.mode		= SPI_MODE_0,
+		.max_speed_hz	= 10 * 1000 * 1000,
+		.bus_num	= 0,
+		.chip_select    = 0,
+	},
+	{
+		.modalias       = "m25p80",
+		.platform_data	= &flash_info,
+		.mode		= SPI_MODE_0,
+		.max_speed_hz	= 1 * 1000 * 1000,
+		.bus_num	= 0,
+		.chip_select    = 1,
+	},
+};
+
+/*
+ * fbxgpio
+ */
+static struct fbxgpio_operations fbxgw2r_gpio_ops = {
+	/* cast only for signed/unsigned */
+	.get_datain = (int (*)(int))gpio_get_value,
+	.get_dataout = (int (*)(int))gpio_get_value,
+	.set_dataout = (void (*)(int, int))gpio_set_value,
+};
+
+static struct fbxgpio_pin fbxgw2r_gpio_pins[] = {
+	/* marvell gpios */
+	{
+		.pin_name	= "bcm-rst",
+		.direction	= GPIO_DIR_OUT,
+		.pin_num	= GPIO_BCM_RST,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "pcie-rst",
+		.direction	= GPIO_DIR_OUT,
+		.pin_num	= GPIO_PCIE_RST,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "sw-int",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_SW_INT,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "test-mode",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_TEST_MODE,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "sfp-pwren",
+		.direction	= GPIO_DIR_OUT,
+		.pin_num	= GPIO_SFP_PWREN,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "sfp-txdis",
+		.direction	= GPIO_DIR_OUT,
+		.pin_num	= GPIO_SFP_TXDIS,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "sfp-pwrgood",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_SFP_PWRGOOD,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "sfp-presence",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_SFP_PRESENCE,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "sfp-rxloss",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_SFP_RXLOSS,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "sfp-txfault",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_SFP_TXFAULT,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "audio-rst",
+		.direction	= GPIO_DIR_OUT,
+		.pin_num	= GPIO_AUDIO_RST,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "pos-sense",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_POS_SENSE,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "exp-presence",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_EXP_PRESENCE,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "exp-pwrgood",
+		.direction	= GPIO_DIR_IN,
+		.pin_num	= GPIO_EXP_PWRGOOD,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "exp-pwren",
+		.direction	= GPIO_DIR_OUT,
+		.pin_num	= GPIO_EXP_PWREN,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "exp-rst",
+		.direction	= GPIO_DIR_OUT,
+		.pin_num	= GPIO_EXP_RST,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+	{
+		.pin_name	= "sw-reset",
+		.direction	= GPIO_DIR_OUT,
+		.pin_num	= GPIO_SW_RESET,
+		.ops		= &fbxgw2r_gpio_ops,
+	},
+
+	{ },
+};
+
+static struct platform_device fbxgw2r_gpio_device = {
+	.name   = "fbxgpio",
+	.id     = -1,
+	.dev    = {
+		.platform_data = &fbxgw2r_gpio_pins,
+	},
+};
+
+/*
+ * i2c midplane eeprom.
+ */
+static struct at24_platform_data midplane_eeprom_data = {
+	.byte_len	= 4096,
+	.page_size	= 8,
+	.flags		= AT24_FLAG_ADDR16,
+};
+
+/*
+ * expansion board eeprom.
+ */
+static struct at24_platform_data expansion_eeprom_data = {
+	.byte_len	= 32768,
+	.page_size	= 64,
+	.flags		= AT24_FLAG_ADDR16,
+};
+
+/*
+ * i2c smsc
+ */
+static struct smsc_cap1066_pdata cap1066_pdata = {
+	.key_map = {
+		KEY_DOWN,
+		KEY_LEFT,
+		KEY_UP,
+		0,
+		KEY_ENTER,
+		KEY_RIGHT,
+	},
+
+	.has_irq_gpio = true,
+	.irq_gpio = GPIO_KP_INT,
+};
+
+static struct i2c_board_info fbxgw2r_i2c0_devs[] = {
+	{
+		.type		= "cap1066",
+		.addr		= 0x28,
+		.platform_data	= &cap1066_pdata,
+	},
+	{
+		.type		= "24c32",
+		.addr		= 0x57,
+		.platform_data	= &midplane_eeprom_data,
+	},
+	{
+		.type		= "24c256",
+		.addr		= 0x53,
+		.platform_data	= &expansion_eeprom_data,
+	},
+};
+
+struct platform_device fbxgw2r_audio = {
+	.name = "fbxgw2r-audio",
+	.id = -1,
+};
+
+void __init fbxgw2r_init(void)
+{
+	extern int panic_timeout;
+	struct fbxgw_pcie_priv *pex_priv;
+
+	printk("fbxgw2r-init.\n");
+
+	panic_timeout = 10;
+	panic_on_oops = 1;
+
+	fbxgw_common_fixup_i2c(0);
+	fbxgw_common_fixup_i2c(1);
+
+	gpio_request(GPIO_OLED_DATA_SELECT, "oled-data-select");
+	gpio_request(GPIO_WLAN_RST, "wlan-rst");
+	gpio_request(GPIO_PCIE_RST, "pcie-rst");
+	gpio_request(GPIO_SW_RESET, "sw-reset");
+	gpio_request(GPIO_SW_INT, "sw-int");
+	gpio_request(GPIO_TEST_MODE, "test-mode");
+	gpio_request(GPIO_SPI_CS_BCM, "spi-cs-bcm");
+	gpio_request(GPIO_BCM_RST, "bcm-rst");
+	gpio_request(GPIO_SFP_TXDIS, "sfp-txdis");
+	gpio_request(GPIO_SFP_PRESENCE, "sfp-presence");
+	gpio_request(GPIO_SFP_PWRGOOD, "sfp-pwrgood");
+	gpio_request(GPIO_SFP_TXFAULT, "sfp-txfault");
+	gpio_request(GPIO_SFP_RXLOSS, "sfp-rxloss");
+	gpio_request(GPIO_KP_INT, "kp-int");
+	gpio_request(GPIO_SFP_PWREN, "sfp-pwren");
+	gpio_request(GPIO_POS_SENSE, "pos-sense");
+	gpio_request(GPIO_AUDIO_RST, "audio-rst");
+
+	gpio_request(GPIO_EXP_PWREN, "exp-pwren");
+	gpio_request(GPIO_EXP_PWRGOOD, "exp-pwrgood");
+	gpio_request(GPIO_EXP_PRESENCE, "exp-presence");
+	gpio_request(GPIO_EXP_RST, "exp-rst");
+
+	gpio_direction_output(GPIO_OLED_DATA_SELECT, 0);
+	gpio_direction_output(GPIO_WLAN_RST, 0);
+	gpio_direction_input(GPIO_TEST_MODE);
+	gpio_direction_output(GPIO_PCIE_RST, 0);
+	gpio_direction_output(GPIO_SW_RESET, 0);
+	gpio_direction_input(GPIO_SW_INT);
+	gpio_direction_output(GPIO_SPI_CS_BCM, 1);
+	gpio_direction_output(GPIO_BCM_RST, 0);
+	gpio_direction_output(GPIO_AUDIO_RST, 0);
+	gpio_direction_input(GPIO_POS_SENSE);
+
+	gpio_direction_output(GPIO_SFP_PWREN, 0);
+	gpio_direction_output(GPIO_SFP_TXDIS, 1);
+	gpio_direction_input(GPIO_SFP_PRESENCE);
+	gpio_direction_input(GPIO_SFP_PWRGOOD);
+	gpio_direction_input(GPIO_SFP_TXFAULT);
+	gpio_direction_input(GPIO_SFP_RXLOSS);
+
+	gpio_direction_output(GPIO_EXP_PWREN, 0);
+	gpio_direction_output(GPIO_EXP_RST, 0);
+	gpio_direction_input(GPIO_EXP_PRESENCE);
+	gpio_direction_input(GPIO_EXP_PWRGOOD);
+
+	i2c_register_board_info(0, fbxgw2r_i2c0_devs,
+				ARRAY_SIZE(fbxgw2r_i2c0_devs));
+
+	spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
+
+	fbxgw_common_nand_init();
+
+	if (fbxgw_pcie_preinit(&pex_priv) == 0) {
+		fbxgw2r_pcie_reset(0);
+		fbxgw2r_wlan_rst(0);
+		mdelay(100);
+		fbxgw2r_pcie_reset(1);
+		fbxgw2r_wlan_rst(1);
+		mdelay(100);
+		fbxgw_pcie_retrain_link(pex_priv);
+		fbxgw_pcie_preexit(pex_priv);
+	}
+
+	/* reset audio codec */
+	fbxgw2r_audio_rst(0);
+	mdelay(100);
+	fbxgw2r_audio_rst(1);
+
+	fbxgw_fbxatm_init();
+	platform_device_register(&fbxgw2r_gpio_device);
+	platform_device_register(&fbxgw2r_audio);
+}
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/fbxgw-common.c	2015-11-18 18:24:28.736140494 +0100
@@ -0,0 +1,459 @@
+/*
+ * fbxgw-common.c for fbxgw
+ * Created by <nschichan@freebox.fr> on Wed Jan 21 16:10:06 2015
+ */
+
+#include <linux/kernel.h>
+#include <linux/random.h>
+#include <linux/netdevice.h>
+#include <linux/gpio.h>
+#include <linux/memblock.h>
+#include <linux/pstore_ram.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/physmap.h>
+#include <linux/mtd/nand.h>
+#include <linux/fbxatm_remote.h>
+
+#include <asm/mach-types.h>
+#include <asm/setup.h>
+
+#include "mach/kirkwood_nand.h"
+
+#include "fbxgw-switch.h"
+
+#define PFX "fbxgw: "
+
+/*
+ * code that can be shared between fbxgw1r & fbxgw2r:
+ * - crash zone init
+ * - fbxserial stuff.
+ * - nand timings & nand partitions
+ * - ATAG_LOADER_VERSION and ATAG_BOOT_INFO entries in
+ *   tagged list.
+ */
+
+/*
+ * top of RAM - 32k, just below bootloader page table
+ */
+#define CRASH_ZONE_ADDR_FBXGW1R       0x1fff8000
+#define CRASH_ZONE_ADDR_FBXGW2R       0x3fff8000
+
+static phys_addr_t __init crash_zone_addr(void)
+{
+	if (machine_is_fbxgw1r())
+		return CRASH_ZONE_ADDR_FBXGW1R;
+	if (machine_is_fbxgw2r())
+		return CRASH_ZONE_ADDR_FBXGW2R;
+
+	return 0;
+}
+
+void __init fbxgw_reserve_crash_zone(void)
+{
+	phys_addr_t addr = crash_zone_addr();
+
+	if (!addr) {
+		pr_warn(PFX "invalid crash_zone_addr.\n");
+		return ;
+	}
+
+	memblock_reserve(addr, SZ_16K);
+}
+
+static struct ramoops_platform_data ramoops_data = {
+        .mem_size		= SZ_16K,
+        .mem_address		= ~0 /* changed at runtime */,
+        .record_size		= SZ_16K,
+        .dump_oops		= 0,
+        .ecc_info		= {
+		.ecc_size = 16,
+		.block_size = 0,
+	},
+};
+
+static struct platform_device ramoops_dev = {
+        .name = "ramoops",
+        .dev = {
+                .platform_data = &ramoops_data,
+        },
+};
+
+static int __init fbxgw_setup_crash_zone(void)
+{
+	phys_addr_t addr = crash_zone_addr();
+
+	if (!addr) {
+		pr_warn(PFX "invalid crash_zone_addr.\n");
+		return -EINVAL;
+	}
+
+	ramoops_data.mem_address = addr;
+	return platform_device_register(&ramoops_dev);
+}
+
+arch_initcall(fbxgw_setup_crash_zone);
+
+/*
+ * NAND flash
+ */
+static struct mtd_partition fbxgw1r_nand_parts[] = {
+	{
+		.name = "all",
+		.offset = 0,
+		.size = MTDPART_SIZ_FULL,
+		.mask_flags = MTD_WRITEABLE,
+	}, {
+		.name = "u-boot",
+		.offset = 0,
+		.size = SZ_1M,
+		.mask_flags = MTD_WRITEABLE,
+	}, {
+		.name = "serial",
+		.offset = SZ_1M,
+		.size = SZ_1M,
+		.mask_flags = MTD_WRITEABLE,
+	}, {
+		.name = "calibration",
+		.offset = SZ_1M * 2,
+		.size = SZ_1M,
+		.mask_flags = MTD_WRITEABLE,
+	}, {
+		.name = "bank0",
+		.offset = SZ_1M * 3,
+		.size = SZ_1M * 18,
+		.mask_flags = MTD_WRITEABLE,
+	}, {
+		.name = "nvram",
+		.offset = SZ_1M * 21,
+		.size = SZ_1M * 3,
+	}, {
+		.name = "bank1",
+		.offset = SZ_1M * 24,
+		.size = SZ_1M * 62,
+	}, {
+		.name = "femto",
+		.offset = SZ_1M * 86,
+		.size = SZ_1M * 16,
+	}, {
+		.name = "config",
+		.offset = SZ_1M * 120,
+		.size = SZ_1M * 8,
+	}, {
+		.name = "new_bank0",
+		.offset = SZ_1M * 102,
+		.size = SZ_1M * 18,
+	},
+};
+
+/*
+ * Hardcoded timings for two known NAND parts:
+ * - NUMONYX NAND01GW3B2CZA6F
+ * - TOSHIBA TC58NVG0S3EBAI4
+ *
+ * Kirkwood to ONFI mapping (from Marvell)
+ * =======================================
+ * TurnOff => tRHW
+ * Acc2First => tCEA
+ * Acc2Next => tRC
+ * NFOEnW => tREH
+ * CEn2WEn => tCS – tWP
+ * WrLow => tWP
+ * WrHigh => tWH
+ *
+ * = Numonyx
+ * tRHW = 100ns | 20 Turnoff cycles (regvalue = 16)
+ * tCEA = 25ns | 5 Acc2first cycles (regvalue = 9)
+ * tRC = 25ns | 5 Acc2next cycles (regvalue = 5)
+ * tREH = 10ns | 2 NOFEnW cycles (regvalue = 1)
+ * tCS - tWP = 20ns - 12ns = 8ns | 2 CEn2WEn cycles (regvalue = 6)
+ * tWp = 12ns | 3 WrLow cycles (regvalue = 3)
+ * tWh = 10ns | 2 WrHigh cycles (regvalue = 2)
+ * command delay: 25ns
+ *
+ * = Toshiba
+ * tRHW = 30ns | 6 Turnoff cycles (regvalue 2)
+ * tCEA = 25ns | 5 Acc2first cycles (regvalue 9)
+ * tRC = 25ns | 5 Acc2next cycles (regvalue 5)
+ * tREH = 10ns | 5 NOFEnW cycles (regvalue 2)
+ * tCS - tWP = 20ns - 12ns = 8ns | 2 CEn2WEn cycles (regvalue = 6)
+ * tWp = 12ns | 3 WrLow cycles (regvalue = 3)
+ * tWh = 10ns | 2 WrHigh cycles (regvalue = 2)
+ * command delay: 30ns
+ *
+ * all values are the same besides Turnoff
+ * add one cycle for all values
+ *
+ * BEWARE: Acc2next & NFOEnW ARE LINKED ! Any additional cycles given
+ * to NOFEnW must be accounted for in Acc2next
+ */
+#define NAND_COMMAND_DELAY	35
+
+static void __init set_nand_timings(void)
+{
+	u32 val;
+	u32 turnoff, acc2first, acc2next, nofenw, cen2wen, wrlow, wrhigh;
+	void __iomem *nand_regs;
+
+#ifdef CONFIG_FBXGW_COMMON_NAND_SAFE_READ_TIMINGS
+	turnoff = 0x1f;
+	acc2first = 0x1f;
+	acc2next = 0x1f;
+	nofenw = 0xc;
+#else
+	turnoff = 0x11;
+	acc2first = 0xa;
+	acc2next = 0x7;
+	nofenw = 0x2;
+#endif
+
+#ifdef CONFIG_FBXGW_COMMON_NAND_SAFE_WRITE_TIMINGS
+	cen2wen = 0xf;
+	wrlow = 0xf;
+	wrhigh = 0xf;
+#else
+	cen2wen = 0x7;
+	wrlow = 0x4;
+	wrhigh = 0x3;
+#endif
+
+	nand_regs = ioremap(NAND_PHYS_BASE, 0x100);
+	if (!nand_regs) {
+		/*
+		 * FIXME: does this warrant a panic() ?
+		 */
+		pr_crit("unable to remap NAND registers to configure "
+			"timings.\n");
+		return ;
+	}
+
+
+	val = readl(nand_regs + NAND_RD_PARAM_OFF);
+	/* turnoff */
+	val &= ~(0x1f << 0);
+	val |= (turnoff << 0);
+	/* acc2first */
+	val &= ~(0x1f << 6);
+	val |= (acc2first << 6);
+	/* acc2next */
+	val &= ~(0x1f << 17);
+	val |= (acc2next << 17);
+	writel(val, nand_regs + NAND_RD_PARAM_OFF);
+
+	val = readl(nand_regs + NAND_FLASH_CTL_OFF);
+	/* nfoenw */
+	val &= ~(0x1f << 9);
+	val |= (nofenw << 9);
+	writel(val, nand_regs + NAND_FLASH_CTL_OFF);
+
+	val = readl(nand_regs + NAND_WR_PARAM_OFF);
+	/* CEn2WEn */
+	val &= ~(0xf << 0);
+	val |= (cen2wen << 0);
+	/* WrLow */
+	val &= ~(0xf << 8);
+	val |= (wrlow << 8);
+	/* WrHigh */
+	val &= ~(0xf << 16);
+	val |= (wrhigh << 16);
+	writel(val, nand_regs + NAND_WR_PARAM_OFF);
+
+	iounmap(nand_regs);
+}
+
+#ifdef CONFIG_FBXGW_COMMON_PARTS_WRITE_ALL
+static void __init set_parts_writeable(struct mtd_partition *parts, int count)
+{
+	int i;
+
+	for (i = 0; i < count; ++i) {
+		parts[i].mask_flags &= ~MTD_WRITEABLE;
+	}
+}
+#endif
+
+
+void __init fbxgw_common_nand_init(void)
+{
+	struct kirkwood_nand_ecc ecc;
+
+	set_nand_timings();
+#ifdef CONFIG_FBXGW_COMMON_PARTS_WRITE_ALL
+	set_parts_writeable(fbxgw1r_nand_parts, ARRAY_SIZE(fbxgw1r_nand_parts));
+#endif
+
+	if (machine_is_fbxgw1r())
+		ecc.ecc = NAND_ECC_SOFT;
+
+	if (machine_is_fbxgw2r()) {
+		ecc.ecc = NAND_ECC_SOFT_BCH;
+		/* default to 4 bits error correction per 512 bytes for now */
+		ecc.bch_ecc_size = 512;
+		ecc.bch_ecc_bytes = 7;
+	}
+
+	kirkwood_nand_init_ecc(fbxgw1r_nand_parts,
+			       ARRAY_SIZE(fbxgw1r_nand_parts),
+			       NAND_COMMAND_DELAY, &ecc);
+}
+
+/*
+ * fbxhwinfo fields, retrieved from ATAG list.
+ */
+char loader_version_str[128];
+int loader_erase_nvram = 0;
+int loader_bank0_forced = 0;
+EXPORT_SYMBOL(loader_version_str);
+EXPORT_SYMBOL(loader_erase_nvram);
+EXPORT_SYMBOL(loader_bank0_forced);
+
+static int parse_tag_loader_version(const struct tag *tag)
+{
+	const char *version;
+
+	version = tag->u.loader_version.version;
+	if (strncmp(version, "u-boot-", 7) ||
+	    strlen(version) > sizeof (loader_version_str) - 1) {
+		pr_info(PFX "invalid loader version.\n");
+		return 0;
+	}
+
+	strcpy(loader_version_str, version);
+	pr_info(PFX "loader version is '%s'\n", loader_version_str);
+	return 0;
+}
+__tagtable(ATAG_LOADER_VERSION, parse_tag_loader_version);
+
+static int __init fbxgw_parse_boot_info(const struct tag *tag)
+{
+	if (tag->u.boot_info.erase_nvram) {
+		printk(KERN_INFO PFX "loader asked for nvram erase.\n");
+		loader_erase_nvram = 1;
+	}
+	if (tag->u.boot_info.bank0_forced) {
+		printk(KERN_INFO PFX "loader user forced a bank0 boot.\n");
+		loader_bank0_forced = 1;
+	}
+	return 0;
+}
+__tagtable(ATAG_BOOT_INFO, fbxgw_parse_boot_info);
+
+/*
+ * fbxserialinfo stuff.
+ */
+struct fbx_serial serial;
+static int got_serial;
+
+const struct fbx_serial *arch_get_fbxserial(void)
+{
+	if (got_serial)
+		 return &serial;
+	return NULL;
+}
+EXPORT_SYMBOL(arch_get_fbxserial);
+
+static int __init parse_fbxserial_tag(const struct tag *tag)
+{
+	memcpy(&serial, &tag->u.fbxserial, sizeof (serial));
+	add_device_randomness(&serial, sizeof (serial));
+	got_serial = 1;
+	return 0;
+}
+__tagtable(ATAG_FBXSERIAL, parse_fbxserial_tag);
+
+/*
+ * board name for fbxhwinfo
+ */
+char fbxhwinfo_model[32];
+EXPORT_SYMBOL(fbxhwinfo_model);
+static int __init fbxgw_setup_model(void)
+{
+	if (machine_is_fbxgw1r())
+		sprintf(fbxhwinfo_model, "fbxgw1r");
+	if (machine_is_fbxgw2r())
+		sprintf(fbxhwinfo_model, "fbxgw2r");
+	return 0;
+}
+arch_initcall(fbxgw_setup_model);
+
+void fbxgw_common_switch_init(struct net_device *dev,
+			      int (*mii_read)(struct net_device *dev,
+					      int phy_id, int reg),
+			      void (*mii_write)(struct net_device *dev,
+						int phy_id, int reg, int val))
+{
+	if (machine_is_fbxgw2r())
+		marvell_6176_config(dev, 1, mii_read, mii_write);
+	if (machine_is_fbxgw1r())
+		marvell_6161_config(dev, 1, mii_read, mii_write);
+}
+
+void __init fbxgw_common_fixup_i2c(int bus_nr)
+{
+	int gpio_scl, gpio_sda;
+
+	if (bus_nr == 0) {
+		/*
+		 * BUS0: use MPP 8 and 9
+		 */
+		gpio_sda = 8;
+		gpio_scl = 9;
+	} else if (bus_nr == 1) {
+		/*
+		 * BUS1: use MPP 36 and 37
+		 */
+		gpio_sda = 36;
+		gpio_scl = 37;
+	} else
+		return;
+
+	/*
+	 * gpio_request will invoke pinctrl to put the MPPs in the
+	 * correct function.
+	 */
+
+	gpio_request(gpio_sda, "sda");
+	gpio_request(gpio_scl, "scl");
+	gpio_direction_input(gpio_scl);
+	gpio_direction_input(gpio_sda);
+
+	if (!gpio_get_value(gpio_sda)) {
+		size_t i;
+
+		for (i = 0; i < 32; i++) {
+			gpio_direction_output(gpio_scl, 0);
+			udelay(100);
+			gpio_direction_input(gpio_scl);
+			udelay(100);
+		}
+
+		if (!gpio_get_value(gpio_sda))
+			printk(KERN_ERR "i2c%d seems locked\n", bus_nr);
+		else
+			printk(KERN_ERR "i2c%d unlocked manually\n", bus_nr);
+	}
+
+	gpio_free(gpio_sda);
+	gpio_free(gpio_scl);
+}
+
+/*
+ * broadcom 6358 remote atm device
+ */
+static struct fbxatm_remote_pdata bcm6358_remote_pdata = {
+	.remote_mac	= "\x00\x07\xcb\x00\x00\xfe",
+	.netdev_name	= "eth0.43",
+	.remote_name	= "bcm63xx_fbxxtm0",
+};
+
+static struct platform_device fbxatm_remote_device = {
+	.name	= "fbxatm_remote",
+	.id	= -1,
+	.dev	= {
+		.platform_data = &bcm6358_remote_pdata,
+	},
+};
+
+void __init fbxgw_fbxatm_init(void)
+{
+	platform_device_register(&fbxatm_remote_device);
+}
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/fbxgw-common.h	2015-11-18 18:24:28.736140494 +0100
@@ -0,0 +1,14 @@
+/*
+ * fbxgw-common.h for fbxgw
+ * Created by <nschichan@freebox.fr> on Mon Jan 26 12:43:05 2015
+ */
+
+#ifndef __FBXGW_COMMON_H
+# define __FBXGW_COMMON_H
+
+void fbxgw_reserve_crash_zone(void);
+void fbxgw_common_nand_init(void);
+void fbxgw_common_fixup_i2c(int bus_nr);
+void fbxgw_fbxatm_init(void);
+
+#endif /* !__FBXGW_COMMON_H */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/fbxgw-pcie.c	2015-11-18 18:24:28.736140494 +0100
@@ -0,0 +1,202 @@
+/*
+ * fbxgw-pcie.c for fbxgw
+ * Created by <nschichan@freebox.fr> on Tue Jan 27 15:04:56 2015
+ */
+
+#include <linux/kernel.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+
+#include <asm/mach-types.h>
+
+#define PFX	"fbxgw-pcie: "
+
+# define PCIE0_PHYS	0xf1040000
+# define PCIE1_PHYS	0xf1044000
+# define CPUCFG_PHYS	0xf1020100
+
+struct fbxgw_pcie_priv {
+	void __iomem *cpuc_base; /* incl. CPU_CONTROL & CPU_CGC */
+	void __iomem *pcie0_base;
+	void __iomem *pcie1_base;
+};
+
+#define CPU_CONTROL		0x04
+# define PCIE0_ENABLE		0x00000001
+# define CPU_RESET		0x00000002
+# define PCIE1_ENABLE		0x00000010
+
+#define CLOCK_GATING_CTRL	0x1c
+# define CGC_PEX0		(1 << 2)
+# define CGC_PEX1		(1 << 18)
+
+/*
+ * PCIe unit register offsets.
+ */
+#define PCIE_DEV_ID_OFF		0x0000
+#define PCIE_CMD_OFF		0x0004
+#define PCIE_DEV_REV_OFF	0x0008
+#define PCIE_BAR_LO_OFF(n)	(0x0010 + ((n) << 3))
+#define PCIE_BAR_HI_OFF(n)	(0x0014 + ((n) << 3))
+#define PCIE_LINK_CTRL_OFF	0x0070
+#define  PCIE_LINK_CTRL_LINK_DIS	(1 << 4)
+#define  PCIE_LINK_CTRL_RETR_LINK	(1 << 5)
+#define  PCIE_LINK_CTRL_LINK_TRAINING	(1 << 27)
+#define PCIE_HEADER_LOG_4_OFF	0x0128
+#define PCIE_BAR_CTRL_OFF(n)	(0x1804 + ((n - 1) * 4))
+#define PCIE_WIN04_CTRL_OFF(n)	(0x1820 + ((n) << 4))
+#define PCIE_WIN04_BASE_OFF(n)	(0x1824 + ((n) << 4))
+#define PCIE_WIN04_REMAP_OFF(n)	(0x182c + ((n) << 4))
+#define PCIE_WIN5_CTRL_OFF	0x1880
+#define PCIE_WIN5_BASE_OFF	0x1884
+#define PCIE_WIN5_REMAP_OFF	0x188c
+#define PCIE_CONF_ADDR_OFF	0x18f8
+#define  PCIE_CONF_ADDR_EN		0x80000000
+#define  PCIE_CONF_REG(r)		((((r) & 0xf00) << 16) | ((r) & 0xfc))
+#define  PCIE_CONF_BUS(b)		(((b) & 0xff) << 16)
+#define  PCIE_CONF_DEV(d)		(((d) & 0x1f) << 11)
+#define  PCIE_CONF_FUNC(f)		(((f) & 0x7) << 8)
+#define PCIE_CONF_DATA_OFF	0x18fc
+#define PCIE_MASK_OFF		0x1910
+#define PCIE_CTRL_OFF		0x1a00
+#define  PCIE_CTRL_X1_MODE		0x0001
+#define PCIE_STAT_OFF		0x1a04
+#define  PCIE_STAT_DEV_OFFS		20
+#define  PCIE_STAT_DEV_MASK		0x1f
+#define  PCIE_STAT_BUS_OFFS		8
+#define  PCIE_STAT_BUS_MASK		0xff
+#define  PCIE_STAT_LINK_DOWN		1
+#define PCIE_DEBUG_CTRL         0x1a60
+#define  PCIE_DEBUG_SOFT_RESET		(1<<20)
+
+static int __init pcie_link_up(void __iomem *base)
+{
+	return !(readl(base + PCIE_STAT_OFF) & PCIE_STAT_LINK_DOWN);
+}
+
+static void __init pcie_set_link_disable(void __iomem *base, int v)
+{
+	u32 val;
+
+	val = readl(base + PCIE_LINK_CTRL_OFF);
+	if (v)
+		val |= PCIE_LINK_CTRL_LINK_DIS;
+	else
+		val &= ~PCIE_LINK_CTRL_LINK_DIS;
+	writel(val, base + PCIE_LINK_CTRL_OFF);
+}
+
+static void __init pcie_set_retrain_link(void __iomem *base, int v)
+{
+	u32 val;
+
+	val = readl(base + PCIE_LINK_CTRL_OFF);
+	if (v)
+		val |= PCIE_LINK_CTRL_RETR_LINK;
+	else
+		val &= ~PCIE_LINK_CTRL_RETR_LINK;
+	writel(val, base + PCIE_LINK_CTRL_OFF);
+}
+
+static void __init __fbxgw_pcie_preinit(int index, void __iomem *base,
+					struct fbxgw_pcie_priv *priv)
+{
+	u32 val;
+	u32 pcie_enable_mask = index == 0 ? PCIE0_ENABLE : PCIE1_ENABLE;
+
+	/* we will reset PCIe bus, make sure it's correctly disabled
+	 * first */
+	val = readl(priv->cpuc_base + CPU_CONTROL);
+	if (!(val & pcie_enable_mask)) {
+		val |= pcie_enable_mask;
+		writel(val, priv->cpuc_base + CPU_CONTROL);
+		return;
+	}
+
+	if (!pcie_link_up(base))
+		return;
+
+	pcie_set_link_disable(base, 1);
+	mdelay(100);
+	pcie_set_link_disable(base, 0);
+}
+
+int __init fbxgw_pcie_preinit(struct fbxgw_pcie_priv **out_priv)
+{
+	struct fbxgw_pcie_priv *priv;
+	int err = -ENOMEM;
+	priv = kzalloc(sizeof (*priv), GFP_KERNEL);
+
+	if (!priv)
+		return err;
+
+	priv->cpuc_base = ioremap(CPUCFG_PHYS, 0x100);
+	priv->pcie0_base = ioremap(PCIE0_PHYS, 0x4000);
+	priv->pcie1_base = ioremap(PCIE1_PHYS, 0x4000);
+
+	if (!priv->cpuc_base || !priv->pcie0_base || !priv->pcie1_base) {
+		goto err_iounmap;
+	}
+
+	*out_priv = priv;
+
+	__fbxgw_pcie_preinit(0, priv->pcie0_base, priv);
+	if (machine_is_fbxgw2r())
+		__fbxgw_pcie_preinit(1, priv->pcie1_base, priv);
+
+	return 0;
+
+err_iounmap:
+	if (priv->cpuc_base)
+		iounmap(priv->cpuc_base);
+	if (priv->pcie0_base)
+		iounmap(priv->pcie0_base);
+	if (priv->pcie1_base)
+		iounmap(priv->pcie1_base);
+	return err;
+}
+
+static void __init __fbxgw_pcie_retrain_link(int index, void __iomem *base,
+					     struct fbxgw_pcie_priv *priv)
+{
+	u32 cgc;
+
+	/*
+	 * be sure to enable corresponding PCIe clock. CGC_PEX0 might
+	 * already be set due to previous call to kirkwood_pcie_id()
+	 * though.
+	 */
+	cgc = readl(priv->cpuc_base + CLOCK_GATING_CTRL);
+	switch (index) {
+	case 0:
+		cgc |= CGC_PEX0;
+		break;
+	case 1:
+		cgc |= CGC_PEX1;
+		break;
+	}
+	writel(cgc, priv->cpuc_base + CLOCK_GATING_CTRL);
+
+	mdelay(100);
+	pcie_set_retrain_link(base, 1);
+	mdelay(1);
+	/* check link, should be up */
+	if (!pcie_link_up(base))
+		pr_err(PFX "PCIe%d link is down\n", index);
+
+}
+
+void __init fbxgw_pcie_retrain_link(struct fbxgw_pcie_priv *priv)
+{
+	__fbxgw_pcie_retrain_link(0, priv->pcie0_base, priv);
+	if (machine_is_fbxgw2r())
+		__fbxgw_pcie_retrain_link(1, priv->pcie1_base, priv);
+}
+
+void __init fbxgw_pcie_preexit(struct fbxgw_pcie_priv *priv)
+{
+	iounmap(priv->pcie0_base);
+	iounmap(priv->pcie1_base);
+	iounmap(priv->cpuc_base);
+}
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/fbxgw-pcie.h	2015-11-18 18:24:28.736140494 +0100
@@ -0,0 +1,15 @@
+/*
+ * fbxgw-pcie.h for fbxgw
+ * Created by <nschichan@freebox.fr> on Tue Jan 27 15:39:48 2015
+ */
+
+#ifndef __FBXGW_PCIE_H
+# define __FBXGW_PCIE_H
+
+struct fbxgw_pcie_priv;
+
+int fbxgw_pcie_preinit(struct fbxgw_pcie_priv **p);
+int fbxgw_pcie_retrain_link(struct fbxgw_pcie_priv *p);
+int fbxgw_pcie_preexit(struct fbxgw_pcie_priv *p);
+
+#endif /* !__FBXGW_PCIE_H */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/fbxgw-switch.c	2015-11-18 18:24:28.736140494 +0100
@@ -0,0 +1,309 @@
+/*
+ * fbxgw-switch.c for fbxgw-switch
+ * Created by <nschichan@freebox.fr> on Tue Jun  5 20:46:17 2012
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+
+#include "fbxgw-switch.h"
+
+#define PFX "fbxgw-switch: "
+
+
+#define MARVELL_PHYPORT0		0x00
+
+#define MARVELL_SWPORT0			0x10
+#define MARVELL_SWPORT4			0x14
+#define MARVELL_SWPORT5			0x15
+
+#define PORTREG_PCS			0x1
+
+#define PCS_RGMII_RX_DELAY		(1 << 15)
+#define PCS_RGMII_TX_DELAY		(1 << 14)
+#define PCS_FORCELINK_UP		(1 << 5)
+#define PCS_FORCELINK			(1 << 4)
+#define PCS_FORCEDUPLEX_FULL		(1 << 3)
+#define PCS_FORCEDUPLEX			(1 << 2)
+#define PCS_FORCESPEED_10		0x0
+#define PCS_FORCESPEED_100		0x1
+#define PCS_FORCESPEED_1000		0x2
+#define PCS_FORCESPEED_AUTO		0x3
+
+#define PORTREG_PCR			0x4
+#define PCR_PORTSTATE_DISABLED		0x0
+/* #define PCR_PORTSTATE_FORWARDING	0x3 */
+
+#define PORTREG_VLANID			0x7
+
+#define PORTREG_PCR2			0x8
+#define PCR2_MODE_SHIFT			10
+#define PCR2_MODE_SECURE		3
+
+#define MARVELL_GLOBAL1			0x1b
+#define MARVELL_GLOBAL2			0x1c
+
+#define GLOBREG_VTUFID			0x2
+#define GLOBREG_VTUSID			0x3
+
+#define GLOBREG_GCR			0x4
+#define GCR_PPUEN			(1 << 14)
+
+#define GLOBREG_VTUOP			0x5
+#define VTUOP_BUSY			(1 << 15)
+#define VTUOP_OP_LOAD			(0x3 << 12)
+#define VTUOP_OP_STU_LOAD		(0x5 << 12)
+#define VTUOP_OP_GETNEXT		(0x4 << 12)
+
+#define GLOBREG_VTUVID			0x6
+#define VTUVID_VALID			(1 << 12)
+
+#define GLOBREG_VTU_P03_DATA		0x7
+#define GLOBREG_VTU_P46_DATA		0x8
+
+#define GLOBREG_VTU_DATA		0x9
+
+#define GLOBREG_SMI_CMD			0x18
+# define SMI_CMD_BUSY			(1 << 15)
+# define SMI_CLAUSE_22			(1 << 12)
+# define SMI_CMD_READ			(2 << 10)
+# define SMI_CMD_WRITE			(1 << 10)
+# define SMI_DEVADDR(DevAddr)	(DevAddr << 5)
+# define SMI_REGADDR(RegAddr)	(RegAddr)
+#define GLOBREG_SMI_DATA		0x19
+
+#define GLOBREG_GSR			0x0
+# define GSR_PPU_POLLING		(1 << 15)
+
+
+/*
+ * voodo register content. P4_RGMII_FORCE is effective on revision A2
+ * of mv6161 chip. see revision A2 release notes for details.
+ */
+#define P4_RGMII_DELAY			0x03
+#define P5_RGMII_DELAY			0x18
+
+
+
+static int __mii_indirect_wait(struct mii_struct *mii, int tries)
+{
+	while (tries) {
+		u16 val = mii->read(mii->dev, MARVELL_GLOBAL2, GLOBREG_SMI_CMD);
+		if ((val & SMI_CMD_BUSY) == 0)
+			return 0;
+		udelay(1000);
+		--tries;
+	}
+	return -ETIMEDOUT;
+}
+
+static int __mii_indirect_read(struct mii_struct *mii, int phy_id, int reg)
+{
+	u16 smi_cmd = SMI_CMD_BUSY | SMI_CLAUSE_22 | SMI_CMD_READ |
+		SMI_DEVADDR(phy_id) | SMI_REGADDR(reg);
+
+	mii->write(mii->dev, MARVELL_GLOBAL2, GLOBREG_SMI_CMD, smi_cmd);
+	if (__mii_indirect_wait(mii, 1000) < 0) {
+		printk(KERN_WARNING PFX "indirect phy read did not "
+		       "complete.\n");
+		return 0xffff;
+	}
+	return mii->read(mii->dev, MARVELL_GLOBAL2, GLOBREG_SMI_DATA);
+}
+
+static int mii_phy_read(struct mii_struct *mii, int phy_id, int reg)
+{
+	if (mii->indirect_phy_access == false)
+		return mii->read(mii->dev, phy_id, reg);
+	else
+		return __mii_indirect_read(mii, phy_id, reg);
+}
+
+static void __mii_indirect_write(struct mii_struct *mii, int phy_id, int reg,
+				int val)
+{
+	u16 smi_cmd = SMI_CMD_BUSY | SMI_CLAUSE_22 | SMI_CMD_WRITE |
+		SMI_DEVADDR(phy_id) | SMI_REGADDR(reg);
+
+	mii->write(mii->dev, MARVELL_GLOBAL2, GLOBREG_SMI_DATA, val);
+	mii->write(mii->dev, MARVELL_GLOBAL2, GLOBREG_SMI_CMD, smi_cmd);
+	if (__mii_indirect_wait(mii, 1000) < 0) {
+		printk(KERN_WARNING PFX "indirect phy write did not "
+		       "complete.\n");
+	}
+}
+
+static void mii_phy_write(struct mii_struct *mii, int phy_id, int reg, int val)
+{
+
+	if (mii->indirect_phy_access == false)
+		return mii->write(mii->dev, phy_id, reg, val);
+	else
+		return __mii_indirect_write(mii, phy_id, reg, val);
+}
+
+static void __vtu_wait(struct mii_struct *mii)
+{
+	for (;;) {
+		u16 val = mii->read(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTUOP);
+		if ((val & (1 << 15)) == 0)
+			break;
+		msleep(10);
+	}
+}
+
+void fbxgw_sw_vtu_stu_init(struct mii_struct *mii, int port_state,
+			   size_t nr_ports)
+{
+	u16 vtu_op = VTUOP_OP_STU_LOAD;
+	u16 regs[2] = { 0 , 0 };
+	int i;
+
+	mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTUOP, vtu_op);
+
+	mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTUSID, 0);
+	mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTUVID, VTUVID_VALID);
+
+
+	for (i = 0; i < nr_ports; ++i) {
+		int off;
+		int shift;
+
+		off = i / 4;
+		shift = 4 * (i % 4) +  2;
+
+		regs[off] |= port_state << shift;
+	}
+
+	mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTU_P03_DATA, regs[0]);
+	mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTU_P46_DATA, regs[1]);
+
+	vtu_op |= VTUOP_BUSY;
+	mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTUOP, vtu_op);
+	__vtu_wait(mii);
+}
+
+void fbxgw_sw_vtu_load(struct mii_struct *mii, u16 vid, const u8 *ports,
+		       size_t nr_ports)
+{
+	u16 vtu_op;
+	u16 regs[2] = { 0, 0 };
+	int i;
+
+	vtu_op = VTUOP_OP_LOAD;
+	mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTUOP, vtu_op);
+
+	mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTUFID, 1);
+	mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTUSID, 0);
+
+	mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTUVID,
+		   vid | VTUVID_VALID);
+
+	for (i = 0; i < nr_ports; ++i) {
+		int off;
+		int shift;
+
+		off = (i / 4);
+		shift = (i % 4) * 4;
+
+		regs[off] |= ports[i] << shift;
+	}
+
+	mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTU_P03_DATA, regs[0]);
+	mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTU_P46_DATA, regs[1]);
+
+	vtu_op |= VTUOP_BUSY;
+	mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_VTUOP, vtu_op);
+
+	__vtu_wait(mii);
+}
+
+void fbxgw_sw_config_cpu_port(struct mii_struct *mii, int swport)
+{
+	u16 pcs = PCS_FORCEDUPLEX_FULL | PCS_FORCEDUPLEX |
+		PCS_FORCESPEED_1000 |
+		PCS_FORCELINK | PCS_FORCELINK_UP;
+
+	if (mii->dev_id == 0x176)
+		pcs |= PCS_RGMII_TX_DELAY | PCS_RGMII_RX_DELAY;
+	else {
+		static u16 delay;
+		/*
+		 * set rgmii delay for cpu port (5) and ftth port (4), also
+		 * force ftth port in RGMII mode
+		 */
+		if (swport == 5)
+			delay = P5_RGMII_DELAY;
+		else
+			delay = P4_RGMII_DELAY;
+		mii->write(mii->dev, MARVELL_SWPORT4, 0x1a, 0x81e7);
+		(void)mii->read(mii->dev, MARVELL_SWPORT5, 0x1a);
+		mii->write(mii->dev, MARVELL_SWPORT5, 0x1a, P5_RGMII_DELAY);
+		mii->write(mii->dev, MARVELL_SWPORT4, 0x1a, 0xc1e7);
+	}
+
+	mii->write(mii->dev, swport, PORTREG_PCS, pcs);
+}
+
+void fbxgw_sw_config_phy_port(struct mii_struct *mii, int phy_port)
+{
+	u16 val;
+
+	if (mii->indirect_phy_access == false) {
+		val = mii->read(mii->dev, MARVELL_GLOBAL1, GLOBREG_GCR);
+		val &= ~GCR_PPUEN;
+		mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_GCR, val);
+	}
+
+
+	/* power up phy for eth port 0 */
+	val = mii_phy_read(mii, phy_port, 0x00);
+	val &= ~0x0800;
+	mii_phy_write(mii, phy_port, 0x00, val);
+
+
+	/* restart autoneg */
+	val = mii_phy_read(mii, phy_port, 0x00);
+	val |= 0x0200;
+	mii_phy_write(mii, phy_port, 0x00, val);
+
+	mii_phy_write(mii, phy_port, 20, 0);
+
+	if (mii->indirect_phy_access == false) {
+		val = mii->read(mii->dev, MARVELL_GLOBAL1, GLOBREG_GCR);
+		val |= GCR_PPUEN;
+		mii->write(mii->dev, MARVELL_GLOBAL1, GLOBREG_GCR, val);
+	}
+}
+
+void fbxgw_sw_port_default_vid(struct mii_struct *mii, int swport, u16 vid)
+{
+	u16 val;
+
+	val = mii->read(mii->dev, swport, PORTREG_VLANID);
+	val &= ~0xfff;
+	val |= vid;
+	mii->write(mii->dev, swport, PORTREG_VLANID, val);
+}
+
+void fbxgw_sw_port_dot1q_secure(struct mii_struct *mii, int swport)
+{
+	u16 val;
+
+	val = mii->read(mii->dev, swport, PORTREG_PCR2);
+	val &= ~(3 << PCR2_MODE_SHIFT);
+	val |= (PCR2_MODE_SECURE << PCR2_MODE_SHIFT);
+	mii->write(mii->dev, swport, PORTREG_PCR2, val);
+}
+
+void fbxgw_sw_port_forward_enable(struct mii_struct *mii, int swport)
+{
+	u16 val;
+
+	/* enable forwarding */
+	val = mii->read(mii->dev, swport, PORTREG_PCR);
+	val |= PCR_PORTSTATE_FORWARDING;
+	mii->write(mii->dev, swport, PORTREG_PCR, val);
+}
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/fbxgw-switch.h	2015-11-18 18:24:28.736140494 +0100
@@ -0,0 +1,60 @@
+/*
+ * fbxgw-switch.h for fbxgw-switch.h
+ * Created by <nschichan@freebox.fr> on Tue Jun  5 20:46:37 2012
+ */
+
+#ifndef __FBXGW_SWITCH_H
+# define __FBXGW_SWITCH_H
+
+struct mii_struct {
+	u16 dev_id;
+	bool indirect_phy_access;
+	struct net_device *dev;
+	int (*read)(struct net_device *dev, int phy_id, int reg);
+	void (*write)(struct net_device *dev, int phy_id, int reg, int val);
+};
+
+void fbxgw_sw_vtu_stu_init(struct mii_struct *mii, int port_state,
+			   size_t nr_ports);
+
+void fbxgw_sw_vtu_load(struct mii_struct *mii, u16 vid, const u8 *ports,
+		       size_t nr_ports);
+
+void fbxgw_sw_config_cpu_port(struct mii_struct *mii, int swport);
+
+void fbxgw_sw_config_phy_port(struct mii_struct *mii, int phy_port);
+
+void fbxgw_sw_port_default_vid(struct mii_struct *mii, int swport, u16 vid);
+
+void fbxgw_sw_port_dot1q_secure(struct mii_struct *mii, int swport);
+
+void fbxgw_sw_port_forward_enable(struct mii_struct *mii, int swport);
+
+#define SWPORT(X)	((X) + 0x10)
+#define PHYPORT(X)	(X)
+
+
+#define PORTREG_SWITCH_IDENTIFIER	0x3
+#define PRODUCT_NUM(x)			(((x) >> 4) & 0xfff)
+
+
+#define PDATA_MEMBER_UNMODIFIED		0
+#define PDATA_MEMBER_UNTAGGED		1
+#define PDATA_MEMBER_TAGGED		2
+#define PDATA_NOT_MEMBER		3
+
+#define PCR_PORTSTATE_FORWARDING	3
+
+int marvell_6176_config(struct net_device *dev, int probe,
+			int (*mii_read)(struct net_device *dev,
+					int phy_id, int reg),
+			void (*mii_write)(struct net_device *dev,
+					  int phy_id, int reg, int val));
+int marvell_6161_config(struct net_device *dev, int probe,
+			int (*mii_read)(struct net_device *dev,
+					int phy_id, int reg),
+			void (*mii_write)(struct net_device *dev,
+					  int phy_id, int reg, int val));
+
+
+#endif /* !__FBXGW_SWITCH_H */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/fdt-fbxgw1r.S	2015-12-01 18:48:22.128673390 +0100
@@ -0,0 +1,7 @@
+	.section .rodata.fdt, "a"
+	.global __fdt_start_FBXGW1R
+	.global __fdt_end_FBXGW1R
+	.align 4
+__fdt_start_FBXGW1R:
+	.incbin "arch/arm/boot/dts/fbxgw1r.dtb"
+__fdt_end_FBXGW1R:
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/fdt-fbxgw2r.S	2015-12-01 18:48:22.132673418 +0100
@@ -0,0 +1,7 @@
+	.section .rodata.fdt, "a"
+	.global __fdt_start_FBXGW2R
+	.global __fdt_end_FBXGW2R
+	.align 4
+__fdt_start_FBXGW2R:
+	.incbin "arch/arm/boot/dts/fbxgw2r.dtb"
+__fdt_end_FBXGW2R:
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/include/mach/board_fbxgw1r.h	2015-11-18 18:24:28.740140521 +0100
@@ -0,0 +1,41 @@
+#ifndef BOARD_FBXGW1R_H_
+#define BOARD_FBXGW1R_H_
+
+/*
+ * board gpios
+ */
+#define GPIO_OLED_DATA_SELECT	7
+#define GPIO_SR_CLK		10
+#define GPIO_BCM_DOWN		11
+#define GPIO_SR_DIN		12
+#define GPIO_TEST_MODE		13
+#define GPIO_SFP_TXDIS		14
+#define GPIO_SR_LOAD		17
+#define GPIO_SW_RESET		28
+#define GPIO_SW_INT		29
+#define GPIO_SFP_PWRGOOD	34
+#define GPIO_SFP_TXFAULT	35
+#define GPIO_SPI_CS_BCM		36
+#define GPIO_SFP_PRESENCE	37
+#define GPIO_SFP_RXLOSS		38
+#define GPIO_BOARD_ID_0		43
+#define GPIO_EXP_RST		44
+#define GPIO_POS_SENSE		45
+#define GPIO_EXP_PWRGOOD	46
+#define GPIO_EXP_PRESENCE	47
+#define GPIO_KP_INT		48
+#define GPIO_BOARD_ID_1		49
+
+/*
+ * shift register outputs
+ */
+#define SROUT_SFP_PWREN		0
+#define SROUT_USB_RST		1
+#define SROUT_AUDIO_RST		2
+#define SROUT_EXP_PWREN		3
+#define SROUT_BCM_RST		4
+#define SROUT_PCIE_RST		5
+#define SROUT_KEYPAD_OLED_RST	6
+#define SROUT_OLED_PWREN	7
+
+#endif /* !BOARD_FBXGW1R_H_ */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/include/mach/board_fbxgw2r.h	2015-11-18 18:24:28.740140521 +0100
@@ -0,0 +1,31 @@
+/*
+ * board_fbxgw2r.h for fbxgw2r
+ * Created by <nschichan@freebox.fr> on Wed May 30 18:35:25 2012
+ */
+
+#ifndef __BOARD_FBXGW2R_H
+# define __BOARD_FBXGW2R_H
+
+#define GPIO_OLED_DATA_SELECT	7
+#define GPIO_SFP_TXDIS		12
+#define GPIO_TEST_MODE		13
+#define GPIO_WLAN_RST		14
+#define GPIO_PCIE_RST		17
+#define GPIO_EXP_PWREN		22
+#define GPIO_SW_RESET		28
+#define GPIO_SW_INT		29
+#define GPIO_BCM_RST		30
+#define GPIO_SFP_PRESENCE	31
+#define GPIO_SFP_PWRGOOD	32
+#define GPIO_SFP_TXFAULT	35
+#define GPIO_AUDIO_RST		33
+#define GPIO_SPI_CS_BCM		34
+#define GPIO_SFP_RXLOSS		38
+#define GPIO_EXP_RST		44
+#define GPIO_POS_SENSE		45
+#define GPIO_EXP_PWRGOOD	46
+#define GPIO_EXP_PRESENCE	47
+#define GPIO_KP_INT		48
+#define GPIO_SFP_PWREN		49
+
+#endif /* __BOARD_FBXGW2R_H */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/include/mach/kirkwood_nand.h	2015-11-18 18:24:28.740140521 +0100
@@ -0,0 +1,26 @@
+/*
+ * orion_nand.h for fbxgw
+ * Created by <nschichan@freebox.fr> on Mon Jan 26 16:56:29 2015
+ */
+
+#ifndef __MACH_ORION_NAND_H
+# define __MACH_ORION_NAND_H
+
+# define KIRKWOOD_NAND_MEM_PHYS_BASE	0xf4000000
+# define KIRKWOOD_NAND_MEM_SIZE		SZ_1K
+
+# define  NAND_PHYS_BASE		(0xf1010400)
+# define   NAND_RD_PARAM_OFF		0x0018
+# define   NAND_WR_PARAM_OFF		0x001C
+# define   NAND_FLASH_CTL_OFF		0x0070
+
+struct kirkwood_nand_ecc {
+	u8 ecc;
+	u16 bch_ecc_size;
+	u16 bch_ecc_bytes;
+};
+
+void kirkwood_nand_init_ecc(struct mtd_partition *parts, int nr_parts,
+			    int delay, struct kirkwood_nand_ecc *ecc);
+
+#endif /*! __MACH_ORION_NAND_H */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/mach-mvebu/kirkwood_nand.c	2015-11-18 18:24:28.740140521 +0100
@@ -0,0 +1,52 @@
+/*
+ * kirkwood_nand.c for fbxgw
+ * Created by <nschichan@freebox.fr> on Mon Jan 26 17:08:40 2015
+ */
+
+#include <linux/kernel.h>
+#include <linux/mtd/nand.h>
+#include <linux/platform_device.h>
+#include <linux/platform_data/mtd-orion_nand.h>
+
+#include "mach/kirkwood_nand.h"
+
+static struct resource kirkwood_nand_resource = {
+	.flags		= IORESOURCE_MEM,
+	.start		= KIRKWOOD_NAND_MEM_PHYS_BASE,
+	.end		= KIRKWOOD_NAND_MEM_PHYS_BASE +
+				KIRKWOOD_NAND_MEM_SIZE - 1,
+};
+
+static struct orion_nand_data kirkwood_nand_data = {
+	.cle		= 0,
+	.ale		= 1,
+	.width		= 8,
+};
+
+static struct platform_device kirkwood_nand_flash = {
+	.name		= "orion_nand",
+	.id		= -1,
+	.dev		= {
+		.platform_data	= &kirkwood_nand_data,
+	},
+	.resource	= &kirkwood_nand_resource,
+	.num_resources	= 1,
+};
+
+void __init kirkwood_nand_init_ecc(struct mtd_partition *parts, int nr_parts,
+				  int chip_delay, struct kirkwood_nand_ecc *ecc)
+{
+	if (!ecc) {
+		kirkwood_nand_data.ecc = NAND_ECC_SOFT;
+		kirkwood_nand_data.bch_ecc_size =
+			kirkwood_nand_data.bch_ecc_bytes = 0;
+	} else {
+		kirkwood_nand_data.ecc = ecc->ecc;
+		kirkwood_nand_data.bch_ecc_bytes = ecc->bch_ecc_bytes;
+		kirkwood_nand_data.bch_ecc_size = ecc->bch_ecc_size;
+	}
+	kirkwood_nand_data.parts = parts;
+	kirkwood_nand_data.nr_parts = nr_parts;
+	kirkwood_nand_data.chip_delay = chip_delay;
+	platform_device_register(&kirkwood_nand_flash);
+}
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/arch/arm/tools/gen-fdt-s	2015-11-18 18:24:28.844141356 +0100
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+machtype_up=$1
+machtype_low=$(echo $machtype_up | tr '[:upper:]' '[:lower:]')
+
+cat <<EOF
+	.section .rodata.fdt, "a"
+	.global __fdt_start_$machtype_up
+	.global __fdt_end_$machtype_up
+	.align 4
+__fdt_start_$machtype_up:
+	.incbin "arch/arm/boot/dts/$machtype_low.dtb"
+__fdt_end_$machtype_up:
+EOF
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/config	2015-12-01 18:48:53.996926254 +0100
@@ -0,0 +1,3584 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# Linux/arm 4.2.6 Kernel Configuration
+#
+CONFIG_ARM=y
+CONFIG_ARM_HAS_SG_CHAIN=y
+CONFIG_MIGHT_HAVE_PCI=y
+CONFIG_SYS_SUPPORTS_APM_EMULATION=y
+CONFIG_HAVE_PROC_CPU=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_NEED_DMA_MAP_STATE=y
+CONFIG_ARCH_SUPPORTS_UPROBES=y
+CONFIG_VECTORS_BASE=0xffff0000
+CONFIG_ARM_PATCH_PHYS_VIRT=y
+CONFIG_GENERIC_BUG=y
+CONFIG_PGTABLE_LEVELS=2
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_IRQ_WORK=y
+CONFIG_BUILDTIME_EXTABLE_SORT=y
+
+#
+# General setup
+#
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_CROSS_COMPILE="/opt/toolchains/armeabi-musl-1.1.3.4-gcc-4.8.3-binutils-2.24-gdb-7.7/bin/arm-fbx-linux-muslgnueabi-"
+# CONFIG_COMPILE_TEST is not set
+CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_LZMA=y
+CONFIG_HAVE_KERNEL_XZ=y
+CONFIG_HAVE_KERNEL_LZO=y
+CONFIG_HAVE_KERNEL_LZ4=y
+CONFIG_KERNEL_GZIP=y
+# CONFIG_KERNEL_LZMA is not set
+# CONFIG_KERNEL_XZ is not set
+# CONFIG_KERNEL_LZO is not set
+# CONFIG_KERNEL_LZ4 is not set
+CONFIG_DEFAULT_HOSTNAME="(none)"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_CROSS_MEMORY_ATTACH is not set
+# CONFIG_FHANDLE is not set
+# CONFIG_USELIB is not set
+CONFIG_AUDIT=y
+CONFIG_HAVE_ARCH_AUDITSYSCALL=y
+CONFIG_AUDITSYSCALL=y
+CONFIG_AUDIT_WATCH=y
+CONFIG_AUDIT_TREE=y
+
+#
+# IRQ subsystem
+#
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_IRQ_SHOW=y
+CONFIG_GENERIC_IRQ_SHOW_LEVEL=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_GENERIC_IRQ_CHIP=y
+CONFIG_IRQ_DOMAIN=y
+CONFIG_HANDLE_DOMAIN_IRQ=y
+# CONFIG_IRQ_DOMAIN_DEBUG is not set
+CONFIG_IRQ_FORCED_THREADING=y
+CONFIG_SPARSE_IRQ=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+
+#
+# Timers subsystem
+#
+CONFIG_TICK_ONESHOT=y
+CONFIG_HZ_PERIODIC=y
+# CONFIG_NO_HZ_IDLE is not set
+# CONFIG_NO_HZ is not set
+CONFIG_HIGH_RES_TIMERS=y
+
+#
+# CPU/Task time and stats accounting
+#
+CONFIG_TICK_CPU_ACCOUNTING=y
+# CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set
+# CONFIG_IRQ_TIME_ACCOUNTING is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_TASKSTATS is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TINY_RCU=y
+# CONFIG_RCU_EXPERT is not set
+CONFIG_SRCU=y
+# CONFIG_TASKS_RCU is not set
+# CONFIG_RCU_STALL_COMMON is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_RCU_EXPEDITE_BOOT is not set
+# CONFIG_BUILD_BIN2C is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_LOG_BUF_SHIFT=15
+# CONFIG_FBX_DECRYPT_INITRD is not set
+CONFIG_GENERIC_SCHED_CLOCK=y
+CONFIG_CGROUPS=y
+# CONFIG_CGROUP_DEBUG is not set
+# CONFIG_CGROUP_FREEZER is not set
+# CONFIG_CGROUP_DEVICE is not set
+# CONFIG_CPUSETS is not set
+# CONFIG_CGROUP_CPUACCT is not set
+# CONFIG_MEMCG is not set
+# CONFIG_CGROUP_SCHED is not set
+# CONFIG_BLK_CGROUP is not set
+# CONFIG_CHECKPOINT_RESTORE is not set
+CONFIG_NAMESPACES=y
+# CONFIG_UTS_NS is not set
+# CONFIG_IPC_NS is not set
+# CONFIG_USER_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_NET_NS=y
+# CONFIG_SCHED_AUTOGROUP is not set
+# CONFIG_SYSFS_DEPRECATED is not set
+# CONFIG_RELAY is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_RD_GZIP is not set
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+# CONFIG_RD_XZ is not set
+# CONFIG_RD_LZO is not set
+# CONFIG_RD_LZ4 is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
+CONFIG_HAVE_UID16=y
+CONFIG_BPF=y
+CONFIG_EXPERT=y
+CONFIG_UID16=y
+CONFIG_MULTIUSER=y
+# CONFIG_SGETMASK_SYSCALL is not set
+# CONFIG_SYSFS_SYSCALL is not set
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+# CONFIG_BPF_SYSCALL is not set
+CONFIG_SHMEM=y
+CONFIG_AIO=y
+CONFIG_ADVISE_SYSCALLS=y
+CONFIG_PCI_QUIRKS=y
+CONFIG_EMBEDDED=y
+CONFIG_HAVE_PERF_EVENTS=y
+CONFIG_PERF_USE_VMALLOC=y
+
+#
+# Kernel Performance Events And Counters
+#
+# CONFIG_PERF_EVENTS is not set
+CONFIG_VM_EVENT_COUNTERS=y
+# CONFIG_SLUB_DEBUG is not set
+CONFIG_COMPAT_BRK=y
+# CONFIG_SLAB is not set
+CONFIG_SLUB=y
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_KPROBES is not set
+# CONFIG_JUMP_LABEL is not set
+# CONFIG_UPROBES is not set
+# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
+CONFIG_ARCH_USE_BUILTIN_BSWAP=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_OPTPROBES=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+CONFIG_HAVE_DMA_ATTRS=y
+CONFIG_HAVE_DMA_CONTIGUOUS=y
+CONFIG_GENERIC_SMP_IDLE_THREAD=y
+CONFIG_GENERIC_IDLE_POLL_SETUP=y
+CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
+CONFIG_HAVE_CLK=y
+CONFIG_HAVE_DMA_API_DEBUG=y
+CONFIG_HAVE_PERF_REGS=y
+CONFIG_HAVE_PERF_USER_STACK_DUMP=y
+CONFIG_HAVE_ARCH_JUMP_LABEL=y
+CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
+CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
+CONFIG_SECCOMP_FILTER=y
+CONFIG_HAVE_CC_STACKPROTECTOR=y
+# CONFIG_CC_STACKPROTECTOR is not set
+CONFIG_CC_STACKPROTECTOR_NONE=y
+# CONFIG_CC_STACKPROTECTOR_REGULAR is not set
+# CONFIG_CC_STACKPROTECTOR_STRONG is not set
+CONFIG_HAVE_CONTEXT_TRACKING=y
+CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
+CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
+CONFIG_HAVE_MOD_ARCH_SPECIFIC=y
+CONFIG_MODULES_USE_ELF_REL=y
+CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
+CONFIG_CLONE_BACKWARDS=y
+CONFIG_OLD_SIGSUSPEND3=y
+CONFIG_OLD_SIGACTION=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+# CONFIG_MODULE_SIG is not set
+# CONFIG_MODULE_COMPRESS is not set
+CONFIG_BLOCK=y
+CONFIG_LBDAF=y
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_BSGLIB is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+# CONFIG_BLK_CMDLINE_PARSER is not set
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+# CONFIG_AIX_PARTITION is not set
+# CONFIG_OSF_PARTITION is not set
+# CONFIG_AMIGA_PARTITION is not set
+# CONFIG_ATARI_PARTITION is not set
+# CONFIG_MAC_PARTITION is not set
+CONFIG_MSDOS_PARTITION=y
+# CONFIG_BSD_DISKLABEL is not set
+# CONFIG_MINIX_SUBPARTITION is not set
+# CONFIG_SOLARIS_X86_PARTITION is not set
+# CONFIG_UNIXWARE_DISKLABEL is not set
+# CONFIG_LDM_PARTITION is not set
+# CONFIG_SGI_PARTITION is not set
+# CONFIG_ULTRIX_PARTITION is not set
+# CONFIG_SUN_PARTITION is not set
+# CONFIG_KARMA_PARTITION is not set
+CONFIG_EFI_PARTITION=y
+# CONFIG_SYSV68_PARTITION is not set
+# CONFIG_CMDLINE_PARTITION is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
+CONFIG_INLINE_READ_UNLOCK=y
+CONFIG_INLINE_READ_UNLOCK_IRQ=y
+CONFIG_INLINE_WRITE_UNLOCK=y
+CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
+CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
+# CONFIG_FREEZER is not set
+
+#
+# System Type
+#
+CONFIG_MMU=y
+CONFIG_ARCH_MULTIPLATFORM=y
+# CONFIG_ARCH_REALVIEW is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_CLPS711X is not set
+# CONFIG_ARCH_GEMINI is not set
+# CONFIG_ARCH_EBSA110 is not set
+# CONFIG_ARCH_EP93XX is not set
+# CONFIG_ARCH_FOOTBRIDGE is not set
+# CONFIG_ARCH_NETX is not set
+# CONFIG_ARCH_IOP13XX is not set
+# CONFIG_ARCH_IOP32X is not set
+# CONFIG_ARCH_IOP33X is not set
+# CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_DOVE is not set
+# CONFIG_ARCH_MV78XX0 is not set
+# CONFIG_ARCH_ORION5X is not set
+# CONFIG_ARCH_MMP is not set
+# CONFIG_ARCH_KS8695 is not set
+# CONFIG_ARCH_W90X900 is not set
+# CONFIG_ARCH_LPC32XX is not set
+# CONFIG_ARCH_PXA is not set
+# CONFIG_ARCH_SHMOBILE_LEGACY is not set
+# CONFIG_ARCH_RPC is not set
+# CONFIG_ARCH_SA1100 is not set
+# CONFIG_ARCH_S3C24XX is not set
+# CONFIG_ARCH_S3C64XX is not set
+# CONFIG_ARCH_DAVINCI is not set
+# CONFIG_ARCH_OMAP1 is not set
+
+#
+# Multiple platform selection
+#
+
+#
+# CPU Core family selection
+#
+# CONFIG_ARCH_MULTI_V4 is not set
+# CONFIG_ARCH_MULTI_V4T is not set
+CONFIG_ARCH_MULTI_V5=y
+CONFIG_ARCH_MULTI_V4_V5=y
+# CONFIG_ARCH_MULTI_V6 is not set
+# CONFIG_ARCH_MULTI_V7 is not set
+CONFIG_ARCH_MULTI_CPU_AUTO=y
+CONFIG_ARCH_MVEBU=y
+CONFIG_MACH_MVEBU_ANY=y
+CONFIG_MACH_KIRKWOOD=y
+# CONFIG_MACH_NETXBIG is not set
+CONFIG_FBXGW_COMMON=y
+CONFIG_MACH_FBXGW2R=y
+CONFIG_MACH_FBXGW1R=y
+CONFIG_FBXGW_COMMON_PARTS_WRITE_ALL=y
+# CONFIG_FBXGW_COMMON_NAND_SAFE_READ_TIMINGS is not set
+# CONFIG_FBXGW_COMMON_NAND_SAFE_WRITE_TIMINGS is not set
+# CONFIG_MACH_ASM9260 is not set
+# CONFIG_ARCH_AT91 is not set
+# CONFIG_ARCH_INTEGRATOR is not set
+# CONFIG_ARCH_MXC is not set
+# CONFIG_ARCH_MXS is not set
+# CONFIG_ARCH_NOMADIK is not set
+# CONFIG_ARCH_NSPIRE is not set
+# CONFIG_PLAT_SPEAR is not set
+# CONFIG_ARCH_U300 is not set
+# CONFIG_ARCH_WM8505 is not set
+CONFIG_PLAT_ORION=y
+
+#
+# Processor Type
+#
+CONFIG_CPU_FEROCEON=y
+# CONFIG_CPU_FEROCEON_OLD_ID is not set
+CONFIG_CPU_32v5=y
+CONFIG_CPU_ABRT_EV5T=y
+CONFIG_CPU_PABRT_LEGACY=y
+CONFIG_CPU_CACHE_VIVT=y
+CONFIG_CPU_COPY_FEROCEON=y
+CONFIG_CPU_TLB_FEROCEON=y
+CONFIG_CPU_CP15=y
+CONFIG_CPU_CP15_MMU=y
+CONFIG_CPU_USE_DOMAINS=y
+
+#
+# Processor Features
+#
+# CONFIG_ARCH_PHYS_ADDR_T_64BIT is not set
+# CONFIG_ARM_THUMB is not set
+# CONFIG_CPU_BIG_ENDIAN is not set
+# CONFIG_CPU_ICACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_DISABLE is not set
+CONFIG_NEED_KUSER_HELPERS=y
+CONFIG_KUSER_HELPERS=y
+CONFIG_OUTER_CACHE=y
+CONFIG_CACHE_FEROCEON_L2=y
+# CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH is not set
+# CONFIG_CACHE_L2X0 is not set
+CONFIG_ARM_L1_CACHE_SHIFT=5
+CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
+CONFIG_ARM_KERNMEM_PERMS=y
+CONFIG_DEBUG_RODATA=y
+CONFIG_MULTI_IRQ_HANDLER=y
+
+#
+# Bus support
+#
+CONFIG_PCI=y
+# CONFIG_PCI_DOMAINS_GENERIC is not set
+CONFIG_PCI_SYSCALL=y
+# CONFIG_PCI_MSI is not set
+# CONFIG_PCI_DEBUG is not set
+# CONFIG_PCI_REALLOC_ENABLE_AUTO is not set
+# CONFIG_PCI_STUB is not set
+# CONFIG_PCI_IOV is not set
+# CONFIG_PCI_PRI is not set
+# CONFIG_PCI_PASID is not set
+
+#
+# PCI host controller drivers
+#
+CONFIG_PCI_MVEBU=y
+# CONFIG_PCI_HOST_GENERIC is not set
+# CONFIG_PCI_LAYERSCAPE is not set
+# CONFIG_PCIE_IPROC is not set
+CONFIG_PCIEPORTBUS=y
+CONFIG_PCIEAER=y
+# CONFIG_PCIE_ECRC is not set
+# CONFIG_PCIEAER_INJECT is not set
+# CONFIG_PCIEASPM is not set
+# CONFIG_PCCARD is not set
+
+#
+# Kernel Features
+#
+# CONFIG_VMSPLIT_3G is not set
+CONFIG_VMSPLIT_2G=y
+# CONFIG_VMSPLIT_1G is not set
+CONFIG_PAGE_OFFSET=0x80000000
+CONFIG_ARCH_NR_GPIO=0
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+CONFIG_PREEMPT_COUNT=y
+CONFIG_HZ_FIXED=0
+CONFIG_HZ_100=y
+# CONFIG_HZ_200 is not set
+# CONFIG_HZ_250 is not set
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_500 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=100
+CONFIG_SCHED_HRTICK=y
+CONFIG_AEABI=y
+# CONFIG_OABI_COMPAT is not set
+# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
+# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
+CONFIG_HAVE_ARCH_PFN_VALID=y
+# CONFIG_HIGHMEM is not set
+CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
+# CONFIG_ARM_MODULE_PLTS is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_HAVE_MEMBLOCK=y
+CONFIG_NO_BOOTMEM=y
+# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=999999
+# CONFIG_COMPACTION is not set
+# CONFIG_PHYS_ADDR_T_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=0
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_NEED_PER_CPU_KM=y
+# CONFIG_CLEANCACHE is not set
+# CONFIG_FRONTSWAP is not set
+# CONFIG_CMA is not set
+# CONFIG_ZPOOL is not set
+# CONFIG_ZBUD is not set
+# CONFIG_ZSMALLOC is not set
+CONFIG_FORCE_MAX_ZONEORDER=11
+CONFIG_ALIGNMENT_TRAP=y
+# CONFIG_UACCESS_WITH_MEMCPY is not set
+CONFIG_SECCOMP=y
+CONFIG_SWIOTLB=y
+CONFIG_IOMMU_HELPER=y
+
+#
+# Boot options
+#
+CONFIG_USE_OF=y
+CONFIG_ATAGS=y
+CONFIG_MACHTYPE_FDT=y
+# CONFIG_DEPRECATED_PARAM_STRUCT is not set
+CONFIG_ZBOOT_ROM_TEXT=0x0
+CONFIG_ZBOOT_ROM_BSS=0x0
+# CONFIG_ARM_APPENDED_DTB is not set
+CONFIG_CMDLINE="root=/dev/nfs ro ip=:::::eth0.41:dhcp console=ttyS1,115200 user_debug=28 dhcpclass=linux-fbxgw2r"
+# CONFIG_CMDLINE_FROM_BOOTLOADER is not set
+# CONFIG_CMDLINE_EXTEND is not set
+CONFIG_CMDLINE_FORCE=y
+# CONFIG_KEXEC is not set
+# CONFIG_CRASH_DUMP is not set
+CONFIG_AUTO_ZRELADDR=y
+
+#
+# CPU Power Management
+#
+
+#
+# CPU Frequency scaling
+#
+# CONFIG_CPU_FREQ is not set
+
+#
+# CPU Idle
+#
+# CONFIG_CPU_IDLE is not set
+# CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED is not set
+
+#
+# Floating point emulation
+#
+
+#
+# At least one emulation must be selected
+#
+# CONFIG_VFP is not set
+
+#
+# Userspace binary formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_BINFMT_SCRIPT=y
+# CONFIG_HAVE_AOUT is not set
+# CONFIG_BINFMT_MISC is not set
+CONFIG_COREDUMP=y
+
+#
+# Power management options
+#
+# CONFIG_SUSPEND is not set
+# CONFIG_HIBERNATION is not set
+# CONFIG_PM is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+# CONFIG_ARM_CPU_SUSPEND is not set
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_NET=y
+CONFIG_NET_INGRESS=y
+
+#
+# Networking options
+#
+CONFIG_NETSKBPAD=64
+CONFIG_NETRXTHREAD=y
+CONFIG_NETRXTHREAD_RX_QUEUE=2
+CONFIG_PACKET=y
+# CONFIG_PACKET_DIAG is not set
+CONFIG_UNIX=y
+CONFIG_UNIX_ABSTRACT_IGNORE_NETNS=y
+# CONFIG_UNIX_DIAG is not set
+CONFIG_XFRM=y
+CONFIG_XFRM_ALGO=y
+CONFIG_XFRM_USER=y
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
+CONFIG_NET_KEY=y
+# CONFIG_NET_KEY_MIGRATE is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+# CONFIG_IP_FIB_TRIE_STATS is not set
+CONFIG_IP_MULTIPLE_TABLES=y
+# CONFIG_IP_ROUTE_MULTIPATH is not set
+# CONFIG_IP_ROUTE_VERBOSE is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+CONFIG_NET_IPGRE_DEMUX=y
+CONFIG_NET_IP_TUNNEL=y
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_NET_IPVTI is not set
+# CONFIG_NET_UDP_TUNNEL is not set
+# CONFIG_NET_FOU is not set
+# CONFIG_NET_FOU_IP_TUNNELS is not set
+# CONFIG_GENEVE_CORE is not set
+CONFIG_INET_AH=y
+CONFIG_INET_ESP=y
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+CONFIG_INET_TUNNEL=y
+CONFIG_INET_XFRM_GC_THRESH=1024
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+# CONFIG_INET_XFRM_MODE_BEET is not set
+CONFIG_INET_LRO=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_INET_UDP_DIAG is not set
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IPV6=y
+# CONFIG_IPV6_ROUTER_PREF is not set
+# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+# CONFIG_INET6_AH is not set
+# CONFIG_INET6_ESP is not set
+# CONFIG_INET6_IPCOMP is not set
+# CONFIG_IPV6_MIP6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+CONFIG_INET6_TUNNEL=y
+# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET6_XFRM_MODE_BEET is not set
+# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
+CONFIG_IPV6_SIT=y
+CONFIG_IPV6_SIT_6RD=y
+CONFIG_IPV6_NDISC_NODETYPE=y
+CONFIG_IPV6_TUNNEL=y
+# CONFIG_IPV6_GRE is not set
+# CONFIG_IPV6_MULTIPLE_TABLES is not set
+# CONFIG_IPV6_MROUTE is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NET_PTP_CLASSIFY is not set
+# CONFIG_NETWORK_PHY_TIMESTAMPING is not set
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_NETFILTER_ADVANCED=y
+# CONFIG_BRIDGE_NETFILTER is not set
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_INGRESS=y
+# CONFIG_NETFILTER_NETLINK_ACCT is not set
+# CONFIG_NETFILTER_NETLINK_QUEUE is not set
+# CONFIG_NETFILTER_NETLINK_LOG is not set
+CONFIG_NF_CONNTRACK=y
+# CONFIG_NF_CONNTRACK_MARK is not set
+CONFIG_NF_CONNTRACK_PROCFS=y
+# CONFIG_NF_CONNTRACK_EVENTS is not set
+# CONFIG_NF_CONNTRACK_TIMEOUT is not set
+# CONFIG_NF_CONNTRACK_TIMESTAMP is not set
+CONFIG_NF_CT_PROTO_DCCP=y
+CONFIG_NF_CT_PROTO_GRE=m
+CONFIG_NF_CT_PROTO_SCTP=y
+# CONFIG_NF_CT_PROTO_UDPLITE is not set
+# CONFIG_NF_CONNTRACK_AMANDA is not set
+CONFIG_NF_CONNTRACK_FTP=y
+CONFIG_NF_CONNTRACK_H323=m
+CONFIG_NF_CONNTRACK_IRC=m
+# CONFIG_NF_CONNTRACK_NETBIOS_NS is not set
+# CONFIG_NF_CONNTRACK_SNMP is not set
+CONFIG_NF_CONNTRACK_PPTP=m
+# CONFIG_NF_CONNTRACK_SANE is not set
+CONFIG_NF_CONNTRACK_SIP=m
+CONFIG_NF_CONNTRACK_TFTP=y
+# CONFIG_NF_CT_NETLINK is not set
+# CONFIG_NF_CT_NETLINK_TIMEOUT is not set
+CONFIG_NF_NAT=y
+CONFIG_NF_NAT_NEEDED=y
+CONFIG_NF_NAT_PROTO_DCCP=y
+CONFIG_NF_NAT_PROTO_SCTP=y
+# CONFIG_NF_NAT_AMANDA is not set
+CONFIG_NF_NAT_FTP=y
+CONFIG_NF_NAT_IRC=m
+CONFIG_NF_NAT_SIP=m
+CONFIG_NF_NAT_TFTP=y
+CONFIG_NF_NAT_REDIRECT=y
+# CONFIG_NF_TABLES is not set
+CONFIG_NETFILTER_XTABLES=y
+
+#
+# Xtables combined modules
+#
+CONFIG_NETFILTER_XT_MARK=y
+# CONFIG_NETFILTER_XT_CONNMARK is not set
+
+#
+# Xtables targets
+#
+# CONFIG_NETFILTER_XT_TARGET_AUDIT is not set
+# CONFIG_NETFILTER_XT_TARGET_CHECKSUM is not set
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=y
+# CONFIG_NETFILTER_XT_TARGET_CONNMARK is not set
+CONFIG_NETFILTER_XT_TARGET_DSCP=y
+# CONFIG_NETFILTER_XT_TARGET_HL is not set
+# CONFIG_NETFILTER_XT_TARGET_HMARK is not set
+# CONFIG_NETFILTER_XT_TARGET_IDLETIMER is not set
+# CONFIG_NETFILTER_XT_TARGET_LED is not set
+# CONFIG_NETFILTER_XT_TARGET_LOG is not set
+CONFIG_NETFILTER_XT_TARGET_MARK=y
+CONFIG_NETFILTER_XT_NAT=y
+# CONFIG_NETFILTER_XT_TARGET_NETMAP is not set
+# CONFIG_NETFILTER_XT_TARGET_NFLOG is not set
+# CONFIG_NETFILTER_XT_TARGET_NFQUEUE is not set
+# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set
+CONFIG_NETFILTER_XT_TARGET_REDIRECT=y
+# CONFIG_NETFILTER_XT_TARGET_TEE is not set
+CONFIG_NETFILTER_XT_TARGET_TPROXY=y
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=y
+# CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP is not set
+
+#
+# Xtables matches
+#
+# CONFIG_NETFILTER_XT_MATCH_ADDRTYPE is not set
+# CONFIG_NETFILTER_XT_MATCH_BPF is not set
+# CONFIG_NETFILTER_XT_MATCH_CGROUP is not set
+# CONFIG_NETFILTER_XT_MATCH_CLUSTER is not set
+# CONFIG_NETFILTER_XT_MATCH_COMMENT is not set
+# CONFIG_NETFILTER_XT_MATCH_CONNBYTES is not set
+# CONFIG_NETFILTER_XT_MATCH_CONNLABEL is not set
+# CONFIG_NETFILTER_XT_MATCH_CONNLIMIT is not set
+# CONFIG_NETFILTER_XT_MATCH_CONNMARK is not set
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
+# CONFIG_NETFILTER_XT_MATCH_CPU is not set
+CONFIG_NETFILTER_XT_MATCH_DCCP=y
+# CONFIG_NETFILTER_XT_MATCH_DEVGROUP is not set
+CONFIG_NETFILTER_XT_MATCH_DSCP=y
+# CONFIG_NETFILTER_XT_MATCH_ECN is not set
+# CONFIG_NETFILTER_XT_MATCH_ESP is not set
+# CONFIG_NETFILTER_XT_MATCH_HASHLIMIT is not set
+# CONFIG_NETFILTER_XT_MATCH_HELPER is not set
+# CONFIG_NETFILTER_XT_MATCH_HL is not set
+# CONFIG_NETFILTER_XT_MATCH_IPCOMP is not set
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=y
+# CONFIG_NETFILTER_XT_MATCH_L2TP is not set
+# CONFIG_NETFILTER_XT_MATCH_LENGTH is not set
+CONFIG_NETFILTER_XT_MATCH_LIMIT=y
+CONFIG_NETFILTER_XT_MATCH_MAC=y
+CONFIG_NETFILTER_XT_MATCH_MARK=y
+# CONFIG_NETFILTER_XT_MATCH_MULTIPORT is not set
+# CONFIG_NETFILTER_XT_MATCH_NFACCT is not set
+CONFIG_NETFILTER_XT_MATCH_OWNER=y
+# CONFIG_NETFILTER_XT_MATCH_POLICY is not set
+# CONFIG_NETFILTER_XT_MATCH_PKTTYPE is not set
+# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set
+# CONFIG_NETFILTER_XT_MATCH_RATEEST is not set
+# CONFIG_NETFILTER_XT_MATCH_REALM is not set
+# CONFIG_NETFILTER_XT_MATCH_RECENT is not set
+CONFIG_NETFILTER_XT_MATCH_SCTP=y
+# CONFIG_NETFILTER_XT_MATCH_SOCKET is not set
+CONFIG_NETFILTER_XT_MATCH_STATE=y
+# CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set
+# CONFIG_NETFILTER_XT_MATCH_STRING is not set
+# CONFIG_NETFILTER_XT_MATCH_TCPMSS is not set
+# CONFIG_NETFILTER_XT_MATCH_TIME is not set
+# CONFIG_NETFILTER_XT_MATCH_U32 is not set
+# CONFIG_IP_SET is not set
+# CONFIG_IP_VS is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_FFN=y
+# CONFIG_IP_FFN_PROCFS is not set
+CONFIG_NF_DEFRAG_IPV4=y
+CONFIG_NF_CONNTRACK_IPV4=y
+CONFIG_NF_CONNTRACK_PROC_COMPAT=y
+# CONFIG_NF_LOG_ARP is not set
+# CONFIG_NF_LOG_IPV4 is not set
+CONFIG_NF_REJECT_IPV4=y
+CONFIG_NF_NAT_IPV4=y
+CONFIG_NF_NAT_MASQUERADE_IPV4=y
+CONFIG_NF_NAT_PROTO_GRE=m
+CONFIG_NF_NAT_PPTP=m
+CONFIG_NF_NAT_H323=m
+CONFIG_IP_NF_IPTABLES=y
+# CONFIG_IP_NF_MATCH_AH is not set
+# CONFIG_IP_NF_MATCH_ECN is not set
+# CONFIG_IP_NF_MATCH_RPFILTER is not set
+# CONFIG_IP_NF_MATCH_TTL is not set
+CONFIG_IP_NF_FILTER=y
+CONFIG_IP_NF_TARGET_REJECT=y
+# CONFIG_IP_NF_TARGET_SYNPROXY is not set
+CONFIG_IP_NF_NAT=y
+CONFIG_IP_NF_TARGET_MASQUERADE=y
+# CONFIG_IP_NF_TARGET_NETMAP is not set
+CONFIG_IP_NF_TARGET_REDIRECT=y
+CONFIG_IP_NF_MANGLE=y
+# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
+# CONFIG_IP_NF_TARGET_ECN is not set
+# CONFIG_IP_NF_TARGET_TTL is not set
+# CONFIG_IP_NF_RAW is not set
+# CONFIG_IP_NF_ARPTABLES is not set
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IPV6_FFN=y
+# CONFIG_IPV6_FFN_PROCFS is not set
+CONFIG_NF_DEFRAG_IPV6=y
+CONFIG_NF_CONNTRACK_IPV6=y
+CONFIG_NF_REJECT_IPV6=y
+# CONFIG_NF_LOG_IPV6 is not set
+CONFIG_NF_NAT_IPV6=y
+CONFIG_NF_NAT_MASQUERADE_IPV6=y
+CONFIG_IP6_NF_IPTABLES=y
+# CONFIG_IP6_NF_MATCH_AH is not set
+# CONFIG_IP6_NF_MATCH_EUI64 is not set
+# CONFIG_IP6_NF_MATCH_FRAG is not set
+# CONFIG_IP6_NF_MATCH_OPTS is not set
+# CONFIG_IP6_NF_MATCH_HL is not set
+# CONFIG_IP6_NF_MATCH_IPV6HEADER is not set
+# CONFIG_IP6_NF_MATCH_MH is not set
+# CONFIG_IP6_NF_MATCH_RPFILTER is not set
+# CONFIG_IP6_NF_MATCH_RT is not set
+# CONFIG_IP6_NF_TARGET_HL is not set
+CONFIG_IP6_NF_FILTER=y
+CONFIG_IP6_NF_TARGET_REJECT=y
+# CONFIG_IP6_NF_TARGET_SYNPROXY is not set
+CONFIG_IP6_NF_MANGLE=y
+# CONFIG_IP6_NF_RAW is not set
+CONFIG_IP6_NF_NAT=y
+CONFIG_IP6_NF_TARGET_MASQUERADE=y
+# CONFIG_IP6_NF_TARGET_NPT is not set
+# CONFIG_BRIDGE_NF_EBTABLES is not set
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_L2TP is not set
+CONFIG_FBXATM=y
+CONFIG_FBXATM_REMOTE=y
+CONFIG_FBXATM_STACK=y
+# CONFIG_FBXATM_REMOTE_STUB is not set
+CONFIG_FBXATM_REMOTE_DRIVER=y
+CONFIG_FBXBRIDGE=y
+CONFIG_STP=y
+CONFIG_BRIDGE=y
+# CONFIG_BRIDGE_IGMP_SNOOPING is not set
+# CONFIG_BRIDGE_VLAN_FILTERING is not set
+CONFIG_HAVE_NET_DSA=y
+CONFIG_VLAN_8021Q=y
+# CONFIG_VLAN_8021Q_GVRP is not set
+# CONFIG_VLAN_8021Q_MVRP is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=y
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_PHONET is not set
+# CONFIG_6LOWPAN is not set
+# CONFIG_IEEE802154 is not set
+CONFIG_NET_SCHED=y
+
+#
+# Queueing/Scheduling
+#
+# CONFIG_NET_SCH_CBQ is not set
+# CONFIG_NET_SCH_HTB is not set
+# CONFIG_NET_SCH_HFSC is not set
+CONFIG_NET_SCH_PRIO=y
+CONFIG_NET_SCH_MULTIQ=y
+# CONFIG_NET_SCH_RED is not set
+# CONFIG_NET_SCH_SFB is not set
+CONFIG_NET_SCH_SFQ=y
+# CONFIG_NET_SCH_TEQL is not set
+# CONFIG_NET_SCH_TBF is not set
+# CONFIG_NET_SCH_GRED is not set
+# CONFIG_NET_SCH_DSMARK is not set
+# CONFIG_NET_SCH_NETEM is not set
+CONFIG_NET_SCH_DRR=y
+# CONFIG_NET_SCH_MQPRIO is not set
+# CONFIG_NET_SCH_CHOKE is not set
+# CONFIG_NET_SCH_QFQ is not set
+# CONFIG_NET_SCH_CODEL is not set
+CONFIG_NET_SCH_FQ_CODEL=y
+# CONFIG_NET_SCH_FQ is not set
+# CONFIG_NET_SCH_HHF is not set
+# CONFIG_NET_SCH_PIE is not set
+CONFIG_NET_SCH_INGRESS=y
+# CONFIG_NET_SCH_PLUG is not set
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+# CONFIG_NET_CLS_BASIC is not set
+# CONFIG_NET_CLS_TCINDEX is not set
+# CONFIG_NET_CLS_ROUTE4 is not set
+# CONFIG_NET_CLS_FW is not set
+CONFIG_NET_CLS_U32=y
+# CONFIG_CLS_U32_PERF is not set
+CONFIG_CLS_U32_MARK=y
+# CONFIG_NET_CLS_RSVP is not set
+# CONFIG_NET_CLS_RSVP6 is not set
+# CONFIG_NET_CLS_FLOW is not set
+# CONFIG_NET_CLS_CGROUP is not set
+# CONFIG_NET_CLS_BPF is not set
+# CONFIG_NET_CLS_FLOWER is not set
+# CONFIG_NET_EMATCH is not set
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=y
+# CONFIG_NET_ACT_GACT is not set
+# CONFIG_NET_ACT_MIRRED is not set
+# CONFIG_NET_ACT_IPT is not set
+# CONFIG_NET_ACT_NAT is not set
+# CONFIG_NET_ACT_PEDIT is not set
+# CONFIG_NET_ACT_SIMP is not set
+CONFIG_NET_ACT_SKBEDIT=y
+# CONFIG_NET_ACT_CSUM is not set
+# CONFIG_NET_ACT_VLAN is not set
+# CONFIG_NET_ACT_BPF is not set
+# CONFIG_NET_CLS_IND is not set
+CONFIG_NET_SCH_FIFO=y
+# CONFIG_DCB is not set
+# CONFIG_BATMAN_ADV is not set
+# CONFIG_OPENVSWITCH is not set
+# CONFIG_VSOCKETS is not set
+# CONFIG_NETLINK_MMAP is not set
+# CONFIG_NETLINK_DIAG is not set
+# CONFIG_MPLS is not set
+# CONFIG_HSR is not set
+# CONFIG_NET_SWITCHDEV is not set
+# CONFIG_CGROUP_NET_PRIO is not set
+# CONFIG_CGROUP_NET_CLASSID is not set
+CONFIG_NET_RX_BUSY_POLL=y
+CONFIG_BQL=y
+CONFIG_BPF_JIT=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+CONFIG_BT=y
+CONFIG_BT_BREDR=y
+# CONFIG_BT_RFCOMM is not set
+CONFIG_BT_BNEP=y
+# CONFIG_BT_BNEP_MC_FILTER is not set
+# CONFIG_BT_BNEP_PROTO_FILTER is not set
+# CONFIG_BT_HIDP is not set
+# CONFIG_BT_LE is not set
+# CONFIG_BT_SELFTEST is not set
+# CONFIG_BT_DEBUGFS is not set
+
+#
+# Bluetooth device drivers
+#
+CONFIG_BT_INTEL=y
+CONFIG_BT_HCIBTUSB=y
+# CONFIG_BT_HCIBTUSB_BCM is not set
+# CONFIG_BT_HCIBTUSB_RTL is not set
+# CONFIG_BT_HCIUART is not set
+CONFIG_BT_HCIBCM203X=y
+# CONFIG_BT_HCIBPA10X is not set
+# CONFIG_BT_HCIBFUSB is not set
+# CONFIG_BT_HCIVHCI is not set
+CONFIG_BT_MRVL=y
+CONFIG_BT_ATH3K=y
+# CONFIG_AF_RXRPC is not set
+CONFIG_FIB_RULES=y
+CONFIG_WIRELESS=y
+CONFIG_CFG80211=y
+# CONFIG_NL80211_TESTMODE is not set
+# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set
+# CONFIG_CFG80211_REG_DEBUG is not set
+CONFIG_CFG80211_CERTIFICATION_ONUS=y
+# CONFIG_CFG80211_REG_CELLULAR_HINTS is not set
+# CONFIG_CFG80211_REG_RELAX_NO_IR is not set
+CONFIG_CFG80211_DEFAULT_PS=y
+# CONFIG_CFG80211_DEBUGFS is not set
+CONFIG_CFG80211_INTERNAL_REGDB=y
+# CONFIG_CFG80211_WEXT is not set
+# CONFIG_LIB80211 is not set
+CONFIG_MAC80211=y
+CONFIG_MAC80211_HAS_RC=y
+CONFIG_MAC80211_RC_MINSTREL=y
+CONFIG_MAC80211_RC_MINSTREL_HT=y
+# CONFIG_MAC80211_RC_MINSTREL_VHT is not set
+CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y
+CONFIG_MAC80211_RC_DEFAULT="minstrel_ht"
+# CONFIG_MAC80211_MESH is not set
+CONFIG_MAC80211_LEDS=y
+# CONFIG_MAC80211_DEBUGFS is not set
+# CONFIG_MAC80211_MESSAGE_TRACING is not set
+# CONFIG_MAC80211_DEBUG_MENU is not set
+CONFIG_MAC80211_STA_HASH_MAX_SIZE=0
+# CONFIG_WIMAX is not set
+# CONFIG_RFKILL is not set
+# CONFIG_NET_9P is not set
+# CONFIG_CAIF is not set
+# CONFIG_CEPH_LIB is not set
+# CONFIG_NFC is not set
+CONFIG_HAVE_BPF_JIT=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+# CONFIG_UEVENT_HELPER is not set
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+# CONFIG_FIRMWARE_IN_KERNEL is not set
+CONFIG_EXTRA_FIRMWARE=""
+CONFIG_FW_LOADER_USER_HELPER=y
+CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
+# CONFIG_ALLOW_DEV_COREDUMP is not set
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_GENERIC_CPU_DEVICES is not set
+CONFIG_SOC_BUS=y
+CONFIG_REGMAP=y
+CONFIG_REGMAP_I2C=y
+CONFIG_REGMAP_SPI=y
+# CONFIG_DMA_SHARED_BUFFER is not set
+
+#
+# Bus devices
+#
+# CONFIG_BRCMSTB_GISB_ARB is not set
+CONFIG_MVEBU_MBUS=y
+# CONFIG_VEXPRESS_CONFIG is not set
+# CONFIG_CONNECTOR is not set
+CONFIG_FREEBOX_PROCFS=y
+CONFIG_MTD=y
+# CONFIG_MTD_TESTS is not set
+CONFIG_MTD_ERASE_PRINTK=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AFS_PARTS is not set
+# CONFIG_MTD_OF_PARTS is not set
+# CONFIG_MTD_AR7_PARTS is not set
+# CONFIG_MTD_FBX6HD_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_SM_FTL is not set
+# CONFIG_MTD_OOPS is not set
+# CONFIG_MTD_SWAP is not set
+# CONFIG_MTD_PARTITIONED_MASTER is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+# CONFIG_MTD_CFI is not set
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_INTEL_VR_NOR is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_DATAFLASH is not set
+CONFIG_MTD_M25P80=y
+# CONFIG_MTD_SST25L is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOCG3 is not set
+CONFIG_MTD_NAND_ECC=y
+# CONFIG_MTD_NAND_ECC_SMC is not set
+CONFIG_MTD_NAND=y
+CONFIG_MTD_NAND_BCH=y
+CONFIG_MTD_NAND_ECC_BCH=y
+# CONFIG_MTD_SM_COMMON is not set
+# CONFIG_MTD_FORCE_BAD_BLOCK_ERASE is not set
+# CONFIG_MTD_NAND_DENALI is not set
+# CONFIG_MTD_NAND_GPIO is not set
+# CONFIG_MTD_NAND_OMAP_BCH_BUILD is not set
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_NAND_RICOH is not set
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+# CONFIG_MTD_NAND_DOCG4 is not set
+# CONFIG_MTD_NAND_CAFE is not set
+# CONFIG_MTD_NAND_PXA3xx is not set
+# CONFIG_MTD_NAND_NANDSIM is not set
+# CONFIG_MTD_NAND_BRCMNAND is not set
+# CONFIG_MTD_NAND_PLATFORM is not set
+CONFIG_MTD_NAND_ORION=y
+# CONFIG_MTD_NAND_HISI504 is not set
+# CONFIG_MTD_NAND_DENALI_FBX is not set
+# CONFIG_MTD_ONENAND is not set
+
+#
+# LPDDR & LPDDR2 PCM memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+# CONFIG_MTD_LPDDR2_NVM is not set
+CONFIG_MTD_SPI_NOR=y
+# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTD_UBI_BEB_LIMIT=20
+# CONFIG_MTD_UBI_FASTMAP is not set
+# CONFIG_MTD_UBI_GLUEBI is not set
+# CONFIG_MTD_UBI_BLOCK is not set
+# CONFIG_FREEBOX_MTD is not set
+CONFIG_DTC=y
+CONFIG_OF=y
+# CONFIG_OF_UNITTEST is not set
+CONFIG_OF_FLATTREE=y
+CONFIG_OF_EARLY_FLATTREE=y
+CONFIG_OF_ADDRESS=y
+CONFIG_OF_ADDRESS_PCI=y
+CONFIG_OF_IRQ=y
+CONFIG_OF_NET=y
+CONFIG_OF_MDIO=y
+CONFIG_OF_PCI=y
+CONFIG_OF_PCI_IRQ=y
+CONFIG_OF_MTD=y
+CONFIG_OF_RESERVED_MEM=y
+# CONFIG_OF_OVERLAY is not set
+CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
+# CONFIG_PARPORT is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_DEV_NULL_BLK is not set
+# CONFIG_BLK_DEV_PCIESSD_MTIP32XX is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+# CONFIG_BLK_DEV_DRBD is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_NVME is not set
+# CONFIG_BLK_DEV_SX8 is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=1
+CONFIG_BLK_DEV_RAM_SIZE=16384
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_MG_DISK is not set
+# CONFIG_BLK_DEV_RBD is not set
+# CONFIG_BLK_DEV_RSXX is not set
+
+#
+# Misc devices
+#
+# CONFIG_WINTEGRA_MMAP is not set
+# CONFIG_SENSORS_LIS3LV02D is not set
+# CONFIG_AD525X_DPOT is not set
+# CONFIG_DUMMY_IRQ is not set
+# CONFIG_PHANTOM is not set
+# CONFIG_SGI_IOC4 is not set
+# CONFIG_TIFM_CORE is not set
+# CONFIG_ICS932S401 is not set
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_HP_ILO is not set
+# CONFIG_APDS9802ALS is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_ISL29020 is not set
+# CONFIG_SENSORS_TSL2550 is not set
+# CONFIG_SENSORS_BH1780 is not set
+# CONFIG_SENSORS_BH1770 is not set
+# CONFIG_SENSORS_APDS990X is not set
+# CONFIG_HMC6352 is not set
+# CONFIG_DS1682 is not set
+# CONFIG_TI_DAC7512 is not set
+# CONFIG_INTELCE_PIC16PMU is not set
+# CONFIG_BMP085_I2C is not set
+# CONFIG_BMP085_SPI is not set
+# CONFIG_USB_SWITCH_FSA9480 is not set
+# CONFIG_LATTICE_ECP3_CONFIG is not set
+# CONFIG_SRAM is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+CONFIG_EEPROM_AT24=m
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
+# CONFIG_EEPROM_93XX46 is not set
+# CONFIG_CB710_CORE is not set
+
+#
+# Texas Instruments shared transport line discipline
+#
+# CONFIG_TI_ST is not set
+# CONFIG_SENSORS_LIS3_SPI is not set
+# CONFIG_SENSORS_LIS3_I2C is not set
+
+#
+# Altera FPGA firmware download module
+#
+# CONFIG_ALTERA_STAPL is not set
+
+#
+# Intel MIC Bus Driver
+#
+
+#
+# SCIF Bus Driver
+#
+
+#
+# Intel MIC Host Driver
+#
+
+#
+# Intel MIC Card Driver
+#
+
+#
+# SCIF Driver
+#
+# CONFIG_ECHO is not set
+# CONFIG_CXL_BASE is not set
+# CONFIG_CXL_KERNEL_API is not set
+
+#
+# RemoTI support
+#
+
+#
+# HDMI CEC support
+#
+# CONFIG_HDMI_CEC is not set
+CONFIG_HAVE_IDE=y
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI_MOD=y
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=y
+CONFIG_SCSI_DMA=y
+# CONFIG_SCSI_NETLINK is not set
+# CONFIG_SCSI_MQ_DEFAULT is not set
+# CONFIG_SCSI_PROC_FS is not set
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+CONFIG_CHR_DEV_SG=y
+# CONFIG_CHR_DEV_SCH is not set
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+CONFIG_SCSI_SCAN_ASYNC=y
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+# CONFIG_SCSI_SRP_ATTRS is not set
+# CONFIG_SCSI_LOWLEVEL is not set
+# CONFIG_SCSI_DH is not set
+# CONFIG_SCSI_OSD_INITIATOR is not set
+CONFIG_ATA=y
+# CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_VERBOSE_ERROR=y
+CONFIG_SATA_PMP=y
+
+#
+# Controllers with non-SFF native interface
+#
+# CONFIG_SATA_AHCI is not set
+# CONFIG_SATA_AHCI_PLATFORM is not set
+# CONFIG_AHCI_CEVA is not set
+# CONFIG_AHCI_MVEBU is not set
+# CONFIG_SATA_INIC162X is not set
+# CONFIG_SATA_ACARD_AHCI is not set
+# CONFIG_SATA_SIL24 is not set
+CONFIG_ATA_SFF=y
+
+#
+# SFF controllers with custom DMA interface
+#
+# CONFIG_PDC_ADMA is not set
+# CONFIG_SATA_QSTOR is not set
+# CONFIG_SATA_SX4 is not set
+CONFIG_ATA_BMDMA=y
+
+#
+# SATA SFF controllers with BMDMA
+#
+# CONFIG_ATA_PIIX is not set
+CONFIG_SATA_MV=m
+# CONFIG_SATA_NV is not set
+# CONFIG_SATA_PROMISE is not set
+# CONFIG_SATA_SIL is not set
+# CONFIG_SATA_SIS is not set
+# CONFIG_SATA_SVW is not set
+# CONFIG_SATA_ULI is not set
+# CONFIG_SATA_VIA is not set
+# CONFIG_SATA_VITESSE is not set
+
+#
+# PATA SFF controllers with BMDMA
+#
+# CONFIG_PATA_ALI is not set
+# CONFIG_PATA_AMD is not set
+# CONFIG_PATA_ARTOP is not set
+# CONFIG_PATA_ATIIXP is not set
+# CONFIG_PATA_ATP867X is not set
+# CONFIG_PATA_CMD64X is not set
+# CONFIG_PATA_CYPRESS is not set
+# CONFIG_PATA_EFAR is not set
+# CONFIG_PATA_HPT366 is not set
+# CONFIG_PATA_HPT37X is not set
+# CONFIG_PATA_HPT3X2N is not set
+# CONFIG_PATA_HPT3X3 is not set
+# CONFIG_PATA_IT8213 is not set
+# CONFIG_PATA_IT821X is not set
+# CONFIG_PATA_JMICRON is not set
+# CONFIG_PATA_MARVELL is not set
+# CONFIG_PATA_NETCELL is not set
+# CONFIG_PATA_NINJA32 is not set
+# CONFIG_PATA_NS87415 is not set
+# CONFIG_PATA_OLDPIIX is not set
+# CONFIG_PATA_OPTIDMA is not set
+# CONFIG_PATA_PDC2027X is not set
+# CONFIG_PATA_PDC_OLD is not set
+# CONFIG_PATA_RADISYS is not set
+# CONFIG_PATA_RDC is not set
+# CONFIG_PATA_SCH is not set
+# CONFIG_PATA_SERVERWORKS is not set
+# CONFIG_PATA_SIL680 is not set
+# CONFIG_PATA_SIS is not set
+# CONFIG_PATA_TOSHIBA is not set
+# CONFIG_PATA_TRIFLEX is not set
+# CONFIG_PATA_VIA is not set
+# CONFIG_PATA_WINBOND is not set
+
+#
+# PIO-only SFF controllers
+#
+# CONFIG_PATA_CMD640_PCI is not set
+# CONFIG_PATA_MPIIX is not set
+# CONFIG_PATA_NS87410 is not set
+# CONFIG_PATA_OPTI is not set
+# CONFIG_PATA_PLATFORM is not set
+# CONFIG_PATA_RZ1000 is not set
+
+#
+# Generic fallback / legacy drivers
+#
+# CONFIG_ATA_GENERIC is not set
+# CONFIG_PATA_LEGACY is not set
+CONFIG_MD=y
+# CONFIG_BLK_DEV_MD is not set
+# CONFIG_BCACHE is not set
+CONFIG_BLK_DEV_DM_BUILTIN=y
+CONFIG_BLK_DEV_DM=y
+# CONFIG_DM_MQ_DEFAULT is not set
+# CONFIG_DM_DEBUG is not set
+CONFIG_DM_CRYPT=y
+# CONFIG_DM_SNAPSHOT is not set
+# CONFIG_DM_THIN_PROVISIONING is not set
+# CONFIG_DM_CACHE is not set
+# CONFIG_DM_ERA is not set
+# CONFIG_DM_MIRROR is not set
+# CONFIG_DM_RAID is not set
+# CONFIG_DM_ZERO is not set
+# CONFIG_DM_MULTIPATH is not set
+# CONFIG_DM_DELAY is not set
+# CONFIG_DM_UEVENT is not set
+# CONFIG_DM_FLAKEY is not set
+# CONFIG_DM_VERITY is not set
+# CONFIG_DM_SWITCH is not set
+# CONFIG_DM_LOG_WRITES is not set
+# CONFIG_TARGET_CORE is not set
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_FIREWIRE is not set
+# CONFIG_FIREWIRE_NOSY is not set
+CONFIG_NETDEVICES=y
+CONFIG_MII=y
+CONFIG_NET_CORE=y
+# CONFIG_BONDING is not set
+CONFIG_DUMMY=y
+# CONFIG_EQUALIZER is not set
+# CONFIG_NET_FC is not set
+# CONFIG_IFB is not set
+# CONFIG_NET_TEAM is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_IPVLAN is not set
+# CONFIG_VXLAN is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+CONFIG_TUN=y
+# CONFIG_TUN_VNET_CROSS_LE is not set
+# CONFIG_VETH is not set
+# CONFIG_NLMON is not set
+# CONFIG_ARCNET is not set
+
+#
+# CAIF transport drivers
+#
+
+#
+# Distributed Switch Architecture drivers
+#
+# CONFIG_NET_DSA_MV88E6XXX is not set
+# CONFIG_NET_DSA_MV88E6XXX_NEED_PPU is not set
+CONFIG_ETHERNET=y
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_NET_VENDOR_ADAPTEC is not set
+# CONFIG_NET_VENDOR_AGERE is not set
+# CONFIG_NET_VENDOR_ALTEON is not set
+# CONFIG_ALTERA_TSE is not set
+# CONFIG_NET_VENDOR_AMD is not set
+# CONFIG_NET_VENDOR_ARC is not set
+# CONFIG_NET_VENDOR_ATHEROS is not set
+# CONFIG_NET_CADENCE is not set
+CONFIG_NET_VENDOR_BROADCOM=y
+# CONFIG_B44 is not set
+# CONFIG_BCMGENET is not set
+# CONFIG_BNX2 is not set
+# CONFIG_CNIC is not set
+# CONFIG_TIGON3 is not set
+# CONFIG_BNX2X is not set
+# CONFIG_SYSTEMPORT is not set
+# CONFIG_NET_VENDOR_BROCADE is not set
+# CONFIG_NET_VENDOR_CAVIUM is not set
+# CONFIG_NET_VENDOR_CHELSIO is not set
+# CONFIG_NET_VENDOR_CIRRUS is not set
+# CONFIG_NET_VENDOR_CISCO is not set
+# CONFIG_DM9000 is not set
+# CONFIG_DNET is not set
+# CONFIG_NET_VENDOR_DEC is not set
+# CONFIG_NET_VENDOR_DLINK is not set
+# CONFIG_NET_VENDOR_EMULEX is not set
+# CONFIG_NET_VENDOR_EZCHIP is not set
+# CONFIG_NET_VENDOR_EXAR is not set
+# CONFIG_NET_VENDOR_FARADAY is not set
+# CONFIG_NET_VENDOR_HISILICON is not set
+# CONFIG_NET_VENDOR_HP is not set
+# CONFIG_NET_VENDOR_INTEL is not set
+# CONFIG_IP1000 is not set
+# CONFIG_JME is not set
+CONFIG_NET_VENDOR_MARVELL=y
+CONFIG_MV643XX_ETH=y
+CONFIG_MV643XX_ETH_FBX_FF=y
+CONFIG_MVMDIO=y
+# CONFIG_MVNETA is not set
+# CONFIG_SKGE is not set
+CONFIG_SKY2=m
+# CONFIG_SKY2_DEBUG is not set
+# CONFIG_NET_VENDOR_MELLANOX is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_MICROCHIP is not set
+# CONFIG_NET_VENDOR_MYRI is not set
+# CONFIG_FEALNX is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_NVIDIA is not set
+# CONFIG_NET_VENDOR_OKI is not set
+# CONFIG_ETHOC is not set
+# CONFIG_NET_PACKET_ENGINE is not set
+# CONFIG_NET_VENDOR_QLOGIC is not set
+# CONFIG_NET_VENDOR_QUALCOMM is not set
+# CONFIG_NET_VENDOR_REALTEK is not set
+# CONFIG_NET_VENDOR_RENESAS is not set
+# CONFIG_NET_VENDOR_RDC is not set
+# CONFIG_NET_VENDOR_ROCKER is not set
+# CONFIG_NET_VENDOR_SAMSUNG is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_SILAN is not set
+# CONFIG_NET_VENDOR_SIS is not set
+# CONFIG_SFC is not set
+# CONFIG_NET_VENDOR_SMSC is not set
+# CONFIG_NET_VENDOR_STMICRO is not set
+# CONFIG_NET_VENDOR_SUN is not set
+# CONFIG_NET_VENDOR_TEHUTI is not set
+# CONFIG_NET_VENDOR_TI is not set
+# CONFIG_NET_VENDOR_VIA is not set
+# CONFIG_NET_VENDOR_WIZNET is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+CONFIG_PHYLIB=y
+
+#
+# MII PHY device drivers
+#
+# CONFIG_AT803X_PHY is not set
+# CONFIG_AMD_PHY is not set
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_CICADA_PHY is not set
+# CONFIG_VITESSE_PHY is not set
+# CONFIG_SMSC_PHY is not set
+# CONFIG_BROADCOM_PHY is not set
+# CONFIG_BCM7XXX_PHY is not set
+# CONFIG_BCM87XX_PHY is not set
+# CONFIG_ICPLUS_PHY is not set
+# CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
+# CONFIG_MICREL_PHY is not set
+# CONFIG_DP83867_PHY is not set
+# CONFIG_FIXED_PHY is not set
+# CONFIG_MDIO_BITBANG is not set
+# CONFIG_MDIO_BUS_MUX_GPIO is not set
+# CONFIG_MDIO_BUS_MUX_MMIOREG is not set
+# CONFIG_MDIO_BCM_UNIMAC is not set
+# CONFIG_MICREL_KS8995MA is not set
+CONFIG_PPP=y
+# CONFIG_PPP_BSDCOMP is not set
+# CONFIG_PPP_DEFLATE is not set
+# CONFIG_PPP_FILTER is not set
+CONFIG_PPP_MPPE=y
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPPOE=y
+CONFIG_PPTP=y
+# CONFIG_PPP_ASYNC is not set
+# CONFIG_PPP_SYNC_TTY is not set
+# CONFIG_SLIP is not set
+CONFIG_SLHC=y
+# CONFIG_USB_NET_DRIVERS is not set
+CONFIG_WLAN=y
+# CONFIG_LIBERTAS_THINFIRM is not set
+# CONFIG_ATMEL is not set
+# CONFIG_AT76C50X_USB is not set
+# CONFIG_PRISM54 is not set
+# CONFIG_USB_ZD1201 is not set
+# CONFIG_USB_NET_RNDIS_WLAN is not set
+# CONFIG_RTL8180 is not set
+# CONFIG_RTL8187 is not set
+# CONFIG_ADM8211 is not set
+# CONFIG_MAC80211_HWSIM is not set
+CONFIG_MWL8K=m
+CONFIG_ATH_COMMON=y
+CONFIG_ATH_CARDS=y
+# CONFIG_ATH_DEBUG is not set
+CONFIG_ATH_REG_IGNORE=y
+# CONFIG_ATH_REG_DYNAMIC_USER_REG_HINTS is not set
+# CONFIG_ATH5K is not set
+# CONFIG_ATH5K_PCI is not set
+# CONFIG_ATH9K is not set
+# CONFIG_ATH9K_HTC is not set
+# CONFIG_CARL9170 is not set
+# CONFIG_ATH6KL is not set
+# CONFIG_AR5523 is not set
+# CONFIG_WIL6210 is not set
+CONFIG_ATH10K=y
+CONFIG_ATH10K_PCI=m
+# CONFIG_ATH10K_DEBUG is not set
+# CONFIG_ATH10K_DEBUGFS is not set
+CONFIG_ATH10K_DFS_CERTIFIED=y
+# CONFIG_WCN36XX is not set
+# CONFIG_B43 is not set
+# CONFIG_B43LEGACY is not set
+# CONFIG_BRCMSMAC is not set
+# CONFIG_BRCMFMAC is not set
+# CONFIG_HOSTAP is not set
+# CONFIG_IPW2100 is not set
+# CONFIG_IPW2200 is not set
+# CONFIG_IWLWIFI is not set
+# CONFIG_IWL4965 is not set
+# CONFIG_IWL3945 is not set
+# CONFIG_LIBERTAS is not set
+# CONFIG_HERMES is not set
+# CONFIG_P54_COMMON is not set
+# CONFIG_RT2X00 is not set
+# CONFIG_WL_MEDIATEK is not set
+# CONFIG_RTL_CARDS is not set
+# CONFIG_WL_TI is not set
+# CONFIG_ZD1211RW is not set
+# CONFIG_MWIFIEX is not set
+# CONFIG_CW1200 is not set
+# CONFIG_RSI_91X is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+# CONFIG_WAN is not set
+# CONFIG_VMXNET3 is not set
+# CONFIG_ISDN is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+# CONFIG_INPUT_LEDS is not set
+# CONFIG_INPUT_FF_MEMLESS is not set
+CONFIG_INPUT_POLLDEV=y
+# CONFIG_INPUT_SPARSEKMAP is not set
+# CONFIG_INPUT_MATRIXKMAP is not set
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TABLET is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+CONFIG_INPUT_MISC=y
+# CONFIG_INPUT_AD714X is not set
+# CONFIG_INPUT_BMA150 is not set
+# CONFIG_INPUT_E3X0_BUTTON is not set
+# CONFIG_INPUT_MMA8450 is not set
+# CONFIG_INPUT_MPU3050 is not set
+# CONFIG_INPUT_GP2A is not set
+# CONFIG_INPUT_GPIO_BEEPER is not set
+# CONFIG_INPUT_GPIO_TILT_POLLED is not set
+# CONFIG_INPUT_ATI_REMOTE2 is not set
+# CONFIG_INPUT_KEYSPAN_REMOTE is not set
+# CONFIG_INPUT_KXTJ9 is not set
+# CONFIG_INPUT_POWERMATE is not set
+# CONFIG_INPUT_YEALINK is not set
+# CONFIG_INPUT_CM109 is not set
+# CONFIG_INPUT_UINPUT is not set
+# CONFIG_INPUT_PCF8574 is not set
+# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set
+# CONFIG_INPUT_ADXL34X is not set
+# CONFIG_INPUT_IMS_PCU is not set
+# CONFIG_INPUT_CMA3000 is not set
+# CONFIG_INPUT_DRV260X_HAPTICS is not set
+# CONFIG_INPUT_DRV2665_HAPTICS is not set
+# CONFIG_INPUT_DRV2667_HAPTICS is not set
+CONFIG_INPUT_SMSC_CAP1066=m
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_TTY=y
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=16
+# CONFIG_SERIAL_NONSTANDARD is not set
+# CONFIG_NOZOMI is not set
+# CONFIG_N_GSM is not set
+# CONFIG_TRACE_SINK is not set
+# CONFIG_DEVMEM is not set
+# CONFIG_DEVKMEM is not set
+# CONFIG_DEVPHYSMEM is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_EARLYCON=y
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_DEPRECATED_OPTIONS=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_PCI=y
+CONFIG_SERIAL_8250_NR_UARTS=4
+CONFIG_SERIAL_8250_RUNTIME_UARTS=2
+# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250_DW is not set
+# CONFIG_SERIAL_8250_EM is not set
+# CONFIG_SERIAL_8250_INGENIC is not set
+
+#
+# Non-8250 serial port support
+#
+# CONFIG_SERIAL_EARLYCON_ARM_SEMIHOST is not set
+# CONFIG_SERIAL_MAX3100 is not set
+# CONFIG_SERIAL_MAX310X is not set
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_JSM is not set
+CONFIG_SERIAL_OF_PLATFORM=y
+# CONFIG_SERIAL_SCCNXP is not set
+# CONFIG_SERIAL_SC16IS7XX is not set
+# CONFIG_SERIAL_BCM63XX is not set
+# CONFIG_SERIAL_ALTERA_JTAGUART is not set
+# CONFIG_SERIAL_ALTERA_UART is not set
+# CONFIG_SERIAL_IFX6X60 is not set
+# CONFIG_SERIAL_XILINX_PS_UART is not set
+# CONFIG_SERIAL_ARC is not set
+# CONFIG_SERIAL_RP2 is not set
+# CONFIG_SERIAL_FSL_LPUART is not set
+# CONFIG_SERIAL_CONEXANT_DIGICOLOR is not set
+# CONFIG_SERIAL_ST_ASC is not set
+# CONFIG_SERIAL_STM32 is not set
+# CONFIG_TTY_PRINTK is not set
+# CONFIG_HVC_DCC is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+CONFIG_DEVPORT=y
+# CONFIG_XILLYBUS is not set
+
+#
+# I2C support
+#
+CONFIG_I2C=y
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
+CONFIG_I2C_CHARDEV=y
+# CONFIG_I2C_MUX is not set
+CONFIG_I2C_HELPER_AUTO=y
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# PC SMBus host controller drivers
+#
+# CONFIG_I2C_ALI1535 is not set
+# CONFIG_I2C_ALI1563 is not set
+# CONFIG_I2C_ALI15X3 is not set
+# CONFIG_I2C_AMD756 is not set
+# CONFIG_I2C_AMD8111 is not set
+# CONFIG_I2C_I801 is not set
+# CONFIG_I2C_ISCH is not set
+# CONFIG_I2C_PIIX4 is not set
+# CONFIG_I2C_NFORCE2 is not set
+# CONFIG_I2C_SIS5595 is not set
+# CONFIG_I2C_SIS630 is not set
+# CONFIG_I2C_SIS96X is not set
+# CONFIG_I2C_VIA is not set
+# CONFIG_I2C_VIAPRO is not set
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+# CONFIG_I2C_CBUS_GPIO is not set
+# CONFIG_I2C_DESIGNWARE_PLATFORM is not set
+# CONFIG_I2C_DESIGNWARE_PCI is not set
+# CONFIG_I2C_GPIO is not set
+CONFIG_I2C_MV64XXX=y
+# CONFIG_I2C_OCORES is not set
+# CONFIG_I2C_PCA_PLATFORM is not set
+# CONFIG_I2C_PXA_PCI is not set
+# CONFIG_I2C_RK3X is not set
+# CONFIG_I2C_SIMTEC is not set
+# CONFIG_I2C_XILINX is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+# CONFIG_I2C_DIOLAN_U2C is not set
+# CONFIG_I2C_PARPORT_LIGHT is not set
+# CONFIG_I2C_ROBOTFUZZ_OSIF is not set
+# CONFIG_I2C_TAOS_EVM is not set
+# CONFIG_I2C_TINY_USB is not set
+
+#
+# Other I2C/SMBus bus drivers
+#
+# CONFIG_I2C_STUB is not set
+# CONFIG_I2C_SLAVE is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+CONFIG_SPI=y
+CONFIG_SPI_DEBUG=y
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+# CONFIG_SPI_ALTERA is not set
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_CADENCE is not set
+# CONFIG_SPI_GPIO is not set
+# CONFIG_SPI_FSL_SPI is not set
+# CONFIG_SPI_OC_TINY is not set
+CONFIG_SPI_ORION=y
+CONFIG_SPI_TDM_ORION=y
+# CONFIG_SPI_PXA2XX is not set
+# CONFIG_SPI_PXA2XX_PCI is not set
+# CONFIG_SPI_ROCKCHIP is not set
+# CONFIG_SPI_SC18IS602 is not set
+# CONFIG_SPI_XCOMM is not set
+# CONFIG_SPI_XILINX is not set
+# CONFIG_SPI_ZYNQMP_GQSPI is not set
+# CONFIG_SPI_DESIGNWARE is not set
+
+#
+# SPI Protocol Masters
+#
+# CONFIG_SPI_SPIDEV is not set
+# CONFIG_SPI_TLE62X0 is not set
+# CONFIG_SPMI is not set
+# CONFIG_HSI is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
+
+#
+# PPS generators support
+#
+
+#
+# PTP clock support
+#
+# CONFIG_PTP_1588_CLOCK is not set
+
+#
+# Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks.
+#
+CONFIG_PINCTRL=y
+
+#
+# Pin controllers
+#
+CONFIG_PINMUX=y
+CONFIG_PINCONF=y
+# CONFIG_DEBUG_PINCTRL is not set
+# CONFIG_PINCTRL_AMD is not set
+# CONFIG_PINCTRL_SINGLE is not set
+CONFIG_PINCTRL_MVEBU=y
+CONFIG_PINCTRL_KIRKWOOD=y
+CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y
+CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_DEVRES=y
+CONFIG_OF_GPIO=y
+# CONFIG_DEBUG_GPIO is not set
+# CONFIG_GPIO_SYSFS is not set
+CONFIG_GPIO_GENERIC=y
+
+#
+# Memory mapped GPIO drivers
+#
+# CONFIG_GPIO_74XX_MMIO is not set
+# CONFIG_GPIO_ALTERA is not set
+# CONFIG_GPIO_DWAPB is not set
+# CONFIG_GPIO_EM is not set
+# CONFIG_GPIO_GENERIC_PLATFORM is not set
+# CONFIG_GPIO_GRGPIO is not set
+CONFIG_GPIO_MVEBU=y
+# CONFIG_GPIO_SCH311X is not set
+# CONFIG_GPIO_VX855 is not set
+# CONFIG_GPIO_ZEVIO is not set
+
+#
+# I2C GPIO expanders
+#
+# CONFIG_GPIO_ADP5588 is not set
+# CONFIG_GPIO_ADNP is not set
+# CONFIG_GPIO_MAX7300 is not set
+# CONFIG_GPIO_MAX732X is not set
+# CONFIG_GPIO_PCA953X is not set
+# CONFIG_GPIO_PCF857X is not set
+# CONFIG_GPIO_SX150X is not set
+
+#
+# MFD GPIO expanders
+#
+
+#
+# PCI GPIO expanders
+#
+# CONFIG_GPIO_AMD8111 is not set
+# CONFIG_GPIO_BT8XX is not set
+# CONFIG_GPIO_ML_IOH is not set
+# CONFIG_GPIO_RDC321X is not set
+
+#
+# SPI GPIO expanders
+#
+# CONFIG_GPIO_74X164 is not set
+# CONFIG_GPIO_MAX7301 is not set
+# CONFIG_GPIO_MCP23S08 is not set
+# CONFIG_GPIO_MC33880 is not set
+
+#
+# USB GPIO expanders
+#
+CONFIG_FREEBOX_GPIO=y
+# CONFIG_FREEBOX_JTAG is not set
+# CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
+# CONFIG_POWER_AVS is not set
+CONFIG_HWMON=y
+CONFIG_HWMON_VID=y
+# CONFIG_HWMON_DEBUG_CHIP is not set
+
+#
+# Native drivers
+#
+# CONFIG_SENSORS_AD7314 is not set
+# CONFIG_SENSORS_AD7414 is not set
+# CONFIG_SENSORS_AD7418 is not set
+# CONFIG_SENSORS_ADM1021 is not set
+# CONFIG_SENSORS_ADM1025 is not set
+# CONFIG_SENSORS_ADM1026 is not set
+# CONFIG_SENSORS_ADM1029 is not set
+# CONFIG_SENSORS_ADM1031 is not set
+# CONFIG_SENSORS_ADM9240 is not set
+# CONFIG_SENSORS_ADT7310 is not set
+# CONFIG_SENSORS_ADT7410 is not set
+# CONFIG_SENSORS_ADT7411 is not set
+# CONFIG_SENSORS_ADT7462 is not set
+# CONFIG_SENSORS_ADT7470 is not set
+CONFIG_SENSORS_ADT7475=y
+# CONFIG_SENSORS_ASC7621 is not set
+# CONFIG_SENSORS_ATXP1 is not set
+# CONFIG_SENSORS_DS620 is not set
+# CONFIG_SENSORS_DS1621 is not set
+# CONFIG_SENSORS_I5K_AMB is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_F71882FG is not set
+# CONFIG_SENSORS_F75375S is not set
+# CONFIG_SENSORS_GL518SM is not set
+# CONFIG_SENSORS_GL520SM is not set
+# CONFIG_SENSORS_G760A is not set
+# CONFIG_SENSORS_G762 is not set
+# CONFIG_SENSORS_GPIO_FAN is not set
+# CONFIG_SENSORS_HIH6130 is not set
+# CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_JC42 is not set
+# CONFIG_SENSORS_POWR1220 is not set
+# CONFIG_SENSORS_LINEAGE is not set
+# CONFIG_SENSORS_LTC2945 is not set
+# CONFIG_SENSORS_LTC4151 is not set
+# CONFIG_SENSORS_LTC4215 is not set
+# CONFIG_SENSORS_LTC4222 is not set
+# CONFIG_SENSORS_LTC4245 is not set
+# CONFIG_SENSORS_LTC4260 is not set
+# CONFIG_SENSORS_LTC4261 is not set
+# CONFIG_SENSORS_MAX1111 is not set
+# CONFIG_SENSORS_MAX16065 is not set
+# CONFIG_SENSORS_MAX1619 is not set
+# CONFIG_SENSORS_MAX1668 is not set
+# CONFIG_SENSORS_MAX197 is not set
+# CONFIG_SENSORS_MAX6639 is not set
+# CONFIG_SENSORS_MAX6642 is not set
+# CONFIG_SENSORS_MAX6650 is not set
+# CONFIG_SENSORS_MAX6697 is not set
+# CONFIG_SENSORS_HTU21 is not set
+# CONFIG_SENSORS_MCP3021 is not set
+# CONFIG_SENSORS_ADCXX is not set
+# CONFIG_SENSORS_LM63 is not set
+# CONFIG_SENSORS_LM70 is not set
+# CONFIG_SENSORS_LM73 is not set
+# CONFIG_SENSORS_LM75 is not set
+# CONFIG_SENSORS_LM77 is not set
+# CONFIG_SENSORS_LM78 is not set
+# CONFIG_SENSORS_LM80 is not set
+# CONFIG_SENSORS_LM83 is not set
+CONFIG_SENSORS_LM85=y
+# CONFIG_SENSORS_LM87 is not set
+# CONFIG_SENSORS_LM90 is not set
+# CONFIG_SENSORS_LM92 is not set
+# CONFIG_SENSORS_LM93 is not set
+# CONFIG_SENSORS_LM95234 is not set
+# CONFIG_SENSORS_LM95241 is not set
+# CONFIG_SENSORS_LM95245 is not set
+# CONFIG_SENSORS_PC87360 is not set
+# CONFIG_SENSORS_PC87427 is not set
+# CONFIG_SENSORS_NTC_THERMISTOR is not set
+# CONFIG_SENSORS_NCT6683 is not set
+# CONFIG_SENSORS_NCT6775 is not set
+# CONFIG_SENSORS_NCT7802 is not set
+# CONFIG_SENSORS_NCT7904 is not set
+# CONFIG_SENSORS_PCF8591 is not set
+# CONFIG_PMBUS is not set
+# CONFIG_SENSORS_SHT15 is not set
+# CONFIG_SENSORS_SHT21 is not set
+# CONFIG_SENSORS_SHTC1 is not set
+# CONFIG_SENSORS_SIS5595 is not set
+# CONFIG_SENSORS_DME1737 is not set
+# CONFIG_SENSORS_EMC1403 is not set
+# CONFIG_SENSORS_EMC2103 is not set
+# CONFIG_SENSORS_EMC6W201 is not set
+# CONFIG_SENSORS_SMSC47M1 is not set
+# CONFIG_SENSORS_SMSC47M192 is not set
+# CONFIG_SENSORS_SMSC47B397 is not set
+# CONFIG_SENSORS_SCH56XX_COMMON is not set
+# CONFIG_SENSORS_SMM665 is not set
+# CONFIG_SENSORS_ADC128D818 is not set
+# CONFIG_SENSORS_ADS1015 is not set
+# CONFIG_SENSORS_ADS7828 is not set
+# CONFIG_SENSORS_ADS7871 is not set
+# CONFIG_SENSORS_AMC6821 is not set
+# CONFIG_SENSORS_INA209 is not set
+# CONFIG_SENSORS_INA2XX is not set
+# CONFIG_SENSORS_TC74 is not set
+# CONFIG_SENSORS_THMC50 is not set
+# CONFIG_SENSORS_TMP102 is not set
+# CONFIG_SENSORS_TMP103 is not set
+# CONFIG_SENSORS_TMP401 is not set
+# CONFIG_SENSORS_TMP421 is not set
+# CONFIG_SENSORS_VIA686A is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_SENSORS_VT8231 is not set
+# CONFIG_SENSORS_W83781D is not set
+# CONFIG_SENSORS_W83791D is not set
+# CONFIG_SENSORS_W83792D is not set
+# CONFIG_SENSORS_W83793 is not set
+# CONFIG_SENSORS_W83795 is not set
+# CONFIG_SENSORS_W83L785TS is not set
+# CONFIG_SENSORS_W83L786NG is not set
+# CONFIG_SENSORS_W83627HF is not set
+# CONFIG_SENSORS_W83627EHF is not set
+CONFIG_SENSORS_KIRKWOOD_CORETEMP=m
+# CONFIG_THERMAL is not set
+CONFIG_FREEBOX_WATCHDOG=y
+CONFIG_FREEBOX_WATCHDOG_CHAR=y
+CONFIG_FREEBOX_WATCHDOG_ORION=y
+# CONFIG_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
+CONFIG_BCMA_POSSIBLE=y
+
+#
+# Broadcom specific AMBA
+#
+# CONFIG_BCMA is not set
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+# CONFIG_MFD_AS3711 is not set
+# CONFIG_MFD_AS3722 is not set
+# CONFIG_PMIC_ADP5520 is not set
+# CONFIG_MFD_AAT2870_CORE is not set
+# CONFIG_MFD_ATMEL_HLCDC is not set
+# CONFIG_MFD_BCM590XX is not set
+# CONFIG_MFD_AXP20X is not set
+# CONFIG_MFD_CROS_EC is not set
+# CONFIG_MFD_ASIC3 is not set
+# CONFIG_PMIC_DA903X is not set
+# CONFIG_MFD_DA9052_SPI is not set
+# CONFIG_MFD_DA9052_I2C is not set
+# CONFIG_MFD_DA9055 is not set
+# CONFIG_MFD_DA9063 is not set
+# CONFIG_MFD_DA9150 is not set
+# CONFIG_MFD_DLN2 is not set
+# CONFIG_MFD_MC13XXX_SPI is not set
+# CONFIG_MFD_MC13XXX_I2C is not set
+# CONFIG_MFD_HI6421_PMIC is not set
+# CONFIG_HTC_EGPIO is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_HTC_I2CPLD is not set
+# CONFIG_LPC_ICH is not set
+# CONFIG_LPC_SCH is not set
+# CONFIG_INTEL_SOC_PMIC is not set
+# CONFIG_MFD_JANZ_CMODIO is not set
+# CONFIG_MFD_KEMPLD is not set
+# CONFIG_MFD_88PM800 is not set
+# CONFIG_MFD_88PM805 is not set
+# CONFIG_MFD_88PM860X is not set
+# CONFIG_MFD_MAX14577 is not set
+# CONFIG_MFD_MAX77686 is not set
+# CONFIG_MFD_MAX77693 is not set
+# CONFIG_MFD_MAX77843 is not set
+# CONFIG_MFD_MAX8907 is not set
+# CONFIG_MFD_MAX8925 is not set
+# CONFIG_MFD_MAX8997 is not set
+# CONFIG_MFD_MAX8998 is not set
+# CONFIG_MFD_MT6397 is not set
+# CONFIG_MFD_MENF21BMC is not set
+# CONFIG_EZX_PCAP is not set
+# CONFIG_MFD_VIPERBOARD is not set
+# CONFIG_MFD_RETU is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_MFD_PM8921_CORE is not set
+# CONFIG_MFD_RDC321X is not set
+# CONFIG_MFD_RTSX_PCI is not set
+# CONFIG_MFD_RT5033 is not set
+# CONFIG_MFD_RTSX_USB is not set
+# CONFIG_MFD_RC5T583 is not set
+# CONFIG_MFD_RK808 is not set
+# CONFIG_MFD_RN5T618 is not set
+# CONFIG_MFD_SEC_CORE is not set
+# CONFIG_MFD_SI476X_CORE is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_MFD_SKY81452 is not set
+# CONFIG_MFD_SMSC is not set
+# CONFIG_ABX500_CORE is not set
+# CONFIG_MFD_STMPE is not set
+# CONFIG_MFD_SYSCON is not set
+# CONFIG_MFD_TI_AM335X_TSCADC is not set
+# CONFIG_MFD_LP3943 is not set
+# CONFIG_MFD_LP8788 is not set
+# CONFIG_MFD_PALMAS is not set
+# CONFIG_TPS6105X is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_TPS6507X is not set
+# CONFIG_MFD_TPS65090 is not set
+# CONFIG_MFD_TPS65217 is not set
+# CONFIG_MFD_TPS65218 is not set
+# CONFIG_MFD_TPS6586X is not set
+# CONFIG_MFD_TPS65910 is not set
+# CONFIG_MFD_TPS65912 is not set
+# CONFIG_MFD_TPS65912_I2C is not set
+# CONFIG_MFD_TPS65912_SPI is not set
+# CONFIG_MFD_TPS80031 is not set
+# CONFIG_TWL4030_CORE is not set
+# CONFIG_TWL6040_CORE is not set
+# CONFIG_MFD_WL1273_CORE is not set
+# CONFIG_MFD_LM3533 is not set
+# CONFIG_MFD_TC3589X is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_MFD_T7L66XB is not set
+# CONFIG_MFD_TC6387XB is not set
+# CONFIG_MFD_TC6393XB is not set
+# CONFIG_MFD_VX855 is not set
+# CONFIG_MFD_ARIZONA_I2C is not set
+# CONFIG_MFD_ARIZONA_SPI is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X_I2C is not set
+# CONFIG_MFD_WM831X_SPI is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_WM8994 is not set
+# CONFIG_REGULATOR is not set
+CONFIG_MEDIA_SUPPORT=y
+
+#
+# Multimedia core support
+#
+# CONFIG_MEDIA_CAMERA_SUPPORT is not set
+# CONFIG_MEDIA_ANALOG_TV_SUPPORT is not set
+CONFIG_MEDIA_DIGITAL_TV_SUPPORT=y
+# CONFIG_MEDIA_RADIO_SUPPORT is not set
+# CONFIG_MEDIA_SDR_SUPPORT is not set
+CONFIG_MEDIA_RC_SUPPORT=y
+# CONFIG_MEDIA_CONTROLLER is not set
+# CONFIG_VIDEO_ADV_DEBUG is not set
+# CONFIG_VIDEO_FIXED_MINOR_RANGES is not set
+CONFIG_DVB_CORE=y
+# CONFIG_DVB_NET is not set
+# CONFIG_TTPCI_EEPROM is not set
+CONFIG_DVB_MAX_ADAPTERS=8
+# CONFIG_DVB_DYNAMIC_MINORS is not set
+
+#
+# Media drivers
+#
+CONFIG_RC_CORE=y
+# CONFIG_RC_MAP is not set
+# CONFIG_RC_DECODERS is not set
+# CONFIG_RC_DEVICES is not set
+CONFIG_MEDIA_USB_SUPPORT=y
+
+#
+# Analog/digital TV USB devices
+#
+# CONFIG_VIDEO_AU0828 is not set
+
+#
+# Digital TV USB devices
+#
+CONFIG_DVB_USB=y
+# CONFIG_DVB_USB_DEBUG is not set
+# CONFIG_DVB_USB_A800 is not set
+# CONFIG_DVB_USB_DIBUSB_MB is not set
+# CONFIG_DVB_USB_DIBUSB_MC is not set
+CONFIG_DVB_USB_DIB0700=m
+# CONFIG_DVB_USB_UMT_010 is not set
+# CONFIG_DVB_USB_CXUSB is not set
+# CONFIG_DVB_USB_M920X is not set
+# CONFIG_DVB_USB_DIGITV is not set
+# CONFIG_DVB_USB_VP7045 is not set
+# CONFIG_DVB_USB_VP702X is not set
+# CONFIG_DVB_USB_GP8PSK is not set
+# CONFIG_DVB_USB_NOVA_T_USB2 is not set
+# CONFIG_DVB_USB_TTUSB2 is not set
+# CONFIG_DVB_USB_DTT200U is not set
+# CONFIG_DVB_USB_OPERA1 is not set
+# CONFIG_DVB_USB_AF9005 is not set
+# CONFIG_DVB_USB_PCTV452E is not set
+# CONFIG_DVB_USB_DW2102 is not set
+# CONFIG_DVB_USB_CINERGY_T2 is not set
+# CONFIG_DVB_USB_DTV5100 is not set
+# CONFIG_DVB_USB_FRIIO is not set
+# CONFIG_DVB_USB_AZ6027 is not set
+# CONFIG_DVB_USB_TECHNISAT_USB2 is not set
+CONFIG_DVB_USB_V2=y
+# CONFIG_DVB_USB_AF9015 is not set
+CONFIG_DVB_USB_AF9035=m
+# CONFIG_DVB_USB_ANYSEE is not set
+# CONFIG_DVB_USB_AU6610 is not set
+# CONFIG_DVB_USB_AZ6007 is not set
+# CONFIG_DVB_USB_CE6230 is not set
+# CONFIG_DVB_USB_EC168 is not set
+# CONFIG_DVB_USB_GL861 is not set
+# CONFIG_DVB_USB_LME2510 is not set
+# CONFIG_DVB_USB_MXL111SF is not set
+# CONFIG_DVB_USB_DVBSKY is not set
+# CONFIG_DVB_TTUSB_BUDGET is not set
+# CONFIG_DVB_TTUSB_DEC is not set
+# CONFIG_SMS_USB_DRV is not set
+# CONFIG_DVB_B2C2_FLEXCOP_USB is not set
+# CONFIG_DVB_AS102 is not set
+
+#
+# Webcam, TV (analog/digital) USB devices
+#
+# CONFIG_MEDIA_PCI_SUPPORT is not set
+
+#
+# Supported MMC/SDIO adapters
+#
+# CONFIG_CYPRESS_FIRMWARE is not set
+
+#
+# Media ancillary drivers (tuners, sensors, i2c, frontends)
+#
+# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
+CONFIG_MEDIA_ATTACH=y
+CONFIG_MEDIA_TUNER=y
+
+#
+# Customize TV tuners
+#
+# CONFIG_MEDIA_TUNER_SIMPLE is not set
+# CONFIG_MEDIA_TUNER_TDA8290 is not set
+# CONFIG_MEDIA_TUNER_TDA827X is not set
+# CONFIG_MEDIA_TUNER_TDA18271 is not set
+# CONFIG_MEDIA_TUNER_TDA9887 is not set
+# CONFIG_MEDIA_TUNER_TEA5761 is not set
+# CONFIG_MEDIA_TUNER_TEA5767 is not set
+# CONFIG_MEDIA_TUNER_MT20XX is not set
+# CONFIG_MEDIA_TUNER_MT2060 is not set
+# CONFIG_MEDIA_TUNER_MT2063 is not set
+# CONFIG_MEDIA_TUNER_MT2266 is not set
+# CONFIG_MEDIA_TUNER_MT2131 is not set
+# CONFIG_MEDIA_TUNER_QT1010 is not set
+# CONFIG_MEDIA_TUNER_XC2028 is not set
+# CONFIG_MEDIA_TUNER_XC5000 is not set
+# CONFIG_MEDIA_TUNER_XC4000 is not set
+# CONFIG_MEDIA_TUNER_MXL5005S is not set
+# CONFIG_MEDIA_TUNER_MXL5007T is not set
+# CONFIG_MEDIA_TUNER_MC44S803 is not set
+# CONFIG_MEDIA_TUNER_MAX2165 is not set
+# CONFIG_MEDIA_TUNER_TDA18218 is not set
+# CONFIG_MEDIA_TUNER_FC0011 is not set
+# CONFIG_MEDIA_TUNER_FC0012 is not set
+# CONFIG_MEDIA_TUNER_FC0013 is not set
+# CONFIG_MEDIA_TUNER_TDA18212 is not set
+# CONFIG_MEDIA_TUNER_E4000 is not set
+# CONFIG_MEDIA_TUNER_FC2580 is not set
+# CONFIG_MEDIA_TUNER_M88RS6000T is not set
+# CONFIG_MEDIA_TUNER_TUA9001 is not set
+# CONFIG_MEDIA_TUNER_SI2157 is not set
+CONFIG_MEDIA_TUNER_IT913X=m
+# CONFIG_MEDIA_TUNER_R820T is not set
+# CONFIG_MEDIA_TUNER_MXL301RF is not set
+# CONFIG_MEDIA_TUNER_QM1D1C0042 is not set
+
+#
+# Customise DVB Frontends
+#
+
+#
+# Multistandard (satellite) frontends
+#
+# CONFIG_DVB_STB0899 is not set
+# CONFIG_DVB_STB6100 is not set
+# CONFIG_DVB_STV090x is not set
+# CONFIG_DVB_STV6110x is not set
+
+#
+# Multistandard (cable + terrestrial) frontends
+#
+# CONFIG_DVB_DRXK is not set
+# CONFIG_DVB_TDA18271C2DD is not set
+# CONFIG_DVB_SI2165 is not set
+
+#
+# DVB-S (satellite) frontends
+#
+# CONFIG_DVB_CX24110 is not set
+# CONFIG_DVB_CX24123 is not set
+# CONFIG_DVB_MT312 is not set
+# CONFIG_DVB_ZL10036 is not set
+# CONFIG_DVB_ZL10039 is not set
+# CONFIG_DVB_S5H1420 is not set
+# CONFIG_DVB_STV0288 is not set
+# CONFIG_DVB_STB6000 is not set
+# CONFIG_DVB_STV0299 is not set
+# CONFIG_DVB_STV6110 is not set
+# CONFIG_DVB_STV0900 is not set
+# CONFIG_DVB_TDA8083 is not set
+# CONFIG_DVB_TDA10086 is not set
+# CONFIG_DVB_TDA8261 is not set
+# CONFIG_DVB_VES1X93 is not set
+# CONFIG_DVB_TUNER_ITD1000 is not set
+# CONFIG_DVB_TUNER_CX24113 is not set
+# CONFIG_DVB_TDA826X is not set
+# CONFIG_DVB_TUA6100 is not set
+# CONFIG_DVB_CX24116 is not set
+# CONFIG_DVB_CX24117 is not set
+# CONFIG_DVB_CX24120 is not set
+# CONFIG_DVB_SI21XX is not set
+# CONFIG_DVB_TS2020 is not set
+# CONFIG_DVB_DS3000 is not set
+# CONFIG_DVB_MB86A16 is not set
+# CONFIG_DVB_TDA10071 is not set
+
+#
+# DVB-T (terrestrial) frontends
+#
+# CONFIG_DVB_SP8870 is not set
+# CONFIG_DVB_SP887X is not set
+# CONFIG_DVB_CX22700 is not set
+# CONFIG_DVB_CX22702 is not set
+# CONFIG_DVB_S5H1432 is not set
+# CONFIG_DVB_DRXD is not set
+# CONFIG_DVB_L64781 is not set
+# CONFIG_DVB_TDA1004X is not set
+# CONFIG_DVB_NXT6000 is not set
+# CONFIG_DVB_MT352 is not set
+# CONFIG_DVB_ZL10353 is not set
+# CONFIG_DVB_DIB3000MB is not set
+# CONFIG_DVB_DIB3000MC is not set
+CONFIG_DVB_DIB7000M=m
+CONFIG_DVB_DIB7000P=m
+# CONFIG_DVB_DIB9000 is not set
+# CONFIG_DVB_TDA10048 is not set
+# CONFIG_DVB_AF9013 is not set
+# CONFIG_DVB_EC100 is not set
+# CONFIG_DVB_HD29L2 is not set
+# CONFIG_DVB_STV0367 is not set
+# CONFIG_DVB_CXD2820R is not set
+# CONFIG_DVB_AS102_FE is not set
+
+#
+# DVB-C (cable) frontends
+#
+# CONFIG_DVB_VES1820 is not set
+# CONFIG_DVB_TDA10021 is not set
+# CONFIG_DVB_TDA10023 is not set
+# CONFIG_DVB_STV0297 is not set
+
+#
+# ATSC (North American/Korean Terrestrial/Cable DTV) frontends
+#
+# CONFIG_DVB_NXT200X is not set
+# CONFIG_DVB_OR51211 is not set
+# CONFIG_DVB_OR51132 is not set
+# CONFIG_DVB_BCM3510 is not set
+# CONFIG_DVB_LGDT330X is not set
+# CONFIG_DVB_LGDT3305 is not set
+# CONFIG_DVB_LGDT3306A is not set
+# CONFIG_DVB_LG2160 is not set
+# CONFIG_DVB_S5H1409 is not set
+# CONFIG_DVB_AU8522_DTV is not set
+# CONFIG_DVB_S5H1411 is not set
+
+#
+# ISDB-T (terrestrial) frontends
+#
+# CONFIG_DVB_S921 is not set
+# CONFIG_DVB_DIB8000 is not set
+# CONFIG_DVB_MB86A20S is not set
+
+#
+# ISDB-S (satellite) & ISDB-T (terrestrial) frontends
+#
+# CONFIG_DVB_TC90522 is not set
+
+#
+# Digital terrestrial only tuners/PLL
+#
+# CONFIG_DVB_PLL is not set
+CONFIG_DVB_TUNER_DIB0070=m
+# CONFIG_DVB_TUNER_DIB0090 is not set
+
+#
+# SEC control devices for DVB-S
+#
+# CONFIG_DVB_DRX39XYJ is not set
+# CONFIG_DVB_LNBP21 is not set
+# CONFIG_DVB_LNBP22 is not set
+# CONFIG_DVB_ISL6405 is not set
+# CONFIG_DVB_ISL6421 is not set
+# CONFIG_DVB_ISL6423 is not set
+# CONFIG_DVB_A8293 is not set
+# CONFIG_DVB_SP2 is not set
+# CONFIG_DVB_LGS8GL5 is not set
+# CONFIG_DVB_LGS8GXX is not set
+# CONFIG_DVB_ATBM8830 is not set
+# CONFIG_DVB_TDA665x is not set
+# CONFIG_DVB_IX2505V is not set
+# CONFIG_DVB_M88RS2000 is not set
+CONFIG_DVB_AF9033=m
+
+#
+# Tools to develop new frontends
+#
+# CONFIG_DVB_DUMMY_FE is not set
+
+#
+# Graphics support
+#
+# CONFIG_VGA_ARB is not set
+
+#
+# Direct Rendering Manager
+#
+# CONFIG_DRM is not set
+
+#
+# Frame buffer Devices
+#
+CONFIG_FB=y
+# CONFIG_FIRMWARE_EDID is not set
+CONFIG_FB_CMDLINE=y
+# CONFIG_FB_DDC is not set
+# CONFIG_FB_BOOT_VESA_SUPPORT is not set
+# CONFIG_FB_CFB_FILLRECT is not set
+# CONFIG_FB_CFB_COPYAREA is not set
+# CONFIG_FB_CFB_IMAGEBLIT is not set
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+CONFIG_FB_SYS_FILLRECT=y
+CONFIG_FB_SYS_COPYAREA=y
+CONFIG_FB_SYS_IMAGEBLIT=y
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+CONFIG_FB_SYS_FOPS=y
+# CONFIG_FB_SVGALIB is not set
+# CONFIG_FB_MACMODES is not set
+CONFIG_FB_BACKLIGHT=y
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_TILEBLITTING is not set
+
+#
+# Frame buffer hardware drivers
+#
+# CONFIG_FB_CIRRUS is not set
+# CONFIG_FB_PM2 is not set
+# CONFIG_FB_CYBER2000 is not set
+# CONFIG_FB_ASILIANT is not set
+# CONFIG_FB_IMSTT is not set
+# CONFIG_FB_OPENCORES is not set
+# CONFIG_FB_S1D13XXX is not set
+# CONFIG_FB_NVIDIA is not set
+# CONFIG_FB_RIVA is not set
+# CONFIG_FB_I740 is not set
+# CONFIG_FB_MATROX is not set
+# CONFIG_FB_RADEON is not set
+# CONFIG_FB_ATY128 is not set
+# CONFIG_FB_ATY is not set
+# CONFIG_FB_S3 is not set
+# CONFIG_FB_SAVAGE is not set
+# CONFIG_FB_SIS is not set
+# CONFIG_FB_NEOMAGIC is not set
+# CONFIG_FB_KYRO is not set
+# CONFIG_FB_3DFX is not set
+# CONFIG_FB_VOODOO1 is not set
+# CONFIG_FB_VT8623 is not set
+# CONFIG_FB_TRIDENT is not set
+# CONFIG_FB_ARK is not set
+# CONFIG_FB_PM3 is not set
+# CONFIG_FB_CARMINE is not set
+# CONFIG_FB_SMSCUFX is not set
+# CONFIG_FB_UDL is not set
+# CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB_METRONOME is not set
+# CONFIG_FB_MB862XX is not set
+# CONFIG_FB_BROADSHEET is not set
+# CONFIG_FB_AUO_K190X is not set
+# CONFIG_FB_SIMPLE is not set
+# CONFIG_FB_SSD1307 is not set
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+# CONFIG_LCD_CLASS_DEVICE is not set
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+# CONFIG_BACKLIGHT_GENERIC is not set
+# CONFIG_BACKLIGHT_ADP8860 is not set
+# CONFIG_BACKLIGHT_ADP8870 is not set
+# CONFIG_BACKLIGHT_LM3639 is not set
+# CONFIG_BACKLIGHT_GPIO is not set
+# CONFIG_BACKLIGHT_LV5207LP is not set
+# CONFIG_BACKLIGHT_BD6107 is not set
+# CONFIG_VGASTATE is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE is not set
+# CONFIG_LOGO is not set
+CONFIG_FB_SSD1327=y
+CONFIG_SOUND=y
+# CONFIG_SOUND_OSS_CORE is not set
+CONFIG_SND=y
+CONFIG_SND_TIMER=y
+CONFIG_SND_PCM=y
+CONFIG_SND_HWDEP=y
+CONFIG_SND_RAWMIDI=y
+CONFIG_SND_COMPRESS_OFFLOAD=y
+CONFIG_SND_JACK=y
+# CONFIG_SND_SEQUENCER is not set
+# CONFIG_SND_MIXER_OSS is not set
+# CONFIG_SND_PCM_OSS is not set
+# CONFIG_SND_HRTIMER is not set
+# CONFIG_SND_DYNAMIC_MINORS is not set
+# CONFIG_SND_SUPPORT_OLD_API is not set
+# CONFIG_SND_PROC_FS is not set
+CONFIG_SND_VERBOSE_PRINTK=y
+# CONFIG_SND_DEBUG is not set
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
+# CONFIG_SND_DRIVERS is not set
+# CONFIG_SND_PCI is not set
+
+#
+# HD-Audio
+#
+CONFIG_SND_HDA_PREALLOC_SIZE=64
+# CONFIG_SND_ARM is not set
+# CONFIG_SND_SPI is not set
+CONFIG_SND_USB=y
+CONFIG_SND_USB_AUDIO=y
+# CONFIG_SND_USB_UA101 is not set
+# CONFIG_SND_USB_CAIAQ is not set
+# CONFIG_SND_USB_6FIRE is not set
+# CONFIG_SND_USB_HIFACE is not set
+# CONFIG_SND_BCD2000 is not set
+# CONFIG_SND_USB_POD is not set
+# CONFIG_SND_USB_PODHD is not set
+# CONFIG_SND_USB_TONEPORT is not set
+# CONFIG_SND_USB_VARIAX is not set
+CONFIG_SND_SOC=y
+# CONFIG_SND_ATMEL_SOC is not set
+# CONFIG_SND_DESIGNWARE_I2S is not set
+
+#
+# SoC Audio for Freescale CPUs
+#
+
+#
+# Common SoC Audio options for Freescale CPUs:
+#
+# CONFIG_SND_SOC_FSL_ASRC is not set
+# CONFIG_SND_SOC_FSL_SAI is not set
+# CONFIG_SND_SOC_FSL_SSI is not set
+# CONFIG_SND_SOC_FSL_SPDIF is not set
+# CONFIG_SND_SOC_FSL_ESAI is not set
+# CONFIG_SND_SOC_IMX_AUDMUX is not set
+CONFIG_SND_KIRKWOOD_SOC=m
+# CONFIG_SND_KIRKWOOD_SOC_ARMADA370_DB is not set
+CONFIG_SND_KIRKWOOD_SOC_FBXGW2R=m
+# CONFIG_SND_SOC_QCOM is not set
+# CONFIG_SND_SOC_XTFPGA_I2S is not set
+CONFIG_SND_SOC_I2C_AND_SPI=y
+
+#
+# CODEC drivers
+#
+# CONFIG_SND_SOC_AC97_CODEC is not set
+# CONFIG_SND_SOC_ADAU1701 is not set
+# CONFIG_SND_SOC_AK4104 is not set
+# CONFIG_SND_SOC_AK4554 is not set
+# CONFIG_SND_SOC_AK4642 is not set
+# CONFIG_SND_SOC_AK5386 is not set
+# CONFIG_SND_SOC_ALC5623 is not set
+# CONFIG_SND_SOC_CS35L32 is not set
+# CONFIG_SND_SOC_CS42L51_I2C is not set
+CONFIG_SND_SOC_CS42L52=m
+# CONFIG_SND_SOC_CS42L56 is not set
+# CONFIG_SND_SOC_CS42L73 is not set
+# CONFIG_SND_SOC_CS4265 is not set
+# CONFIG_SND_SOC_CS4270 is not set
+# CONFIG_SND_SOC_CS4271_I2C is not set
+# CONFIG_SND_SOC_CS4271_SPI is not set
+# CONFIG_SND_SOC_CS42XX8_I2C is not set
+# CONFIG_SND_SOC_HDMI_CODEC is not set
+# CONFIG_SND_SOC_ES8328 is not set
+# CONFIG_SND_SOC_PCM1681 is not set
+# CONFIG_SND_SOC_PCM1792A is not set
+# CONFIG_SND_SOC_PCM512x_I2C is not set
+# CONFIG_SND_SOC_PCM512x_SPI is not set
+# CONFIG_SND_SOC_RT5631 is not set
+# CONFIG_SND_SOC_RT5677_SPI is not set
+# CONFIG_SND_SOC_SGTL5000 is not set
+# CONFIG_SND_SOC_SIRF_AUDIO_CODEC is not set
+# CONFIG_SND_SOC_SPDIF is not set
+# CONFIG_SND_SOC_SSM2602_SPI is not set
+# CONFIG_SND_SOC_SSM2602_I2C is not set
+# CONFIG_SND_SOC_SSM4567 is not set
+# CONFIG_SND_SOC_STA32X is not set
+# CONFIG_SND_SOC_STA350 is not set
+# CONFIG_SND_SOC_TAS2552 is not set
+# CONFIG_SND_SOC_TAS5086 is not set
+# CONFIG_SND_SOC_TAS571X is not set
+# CONFIG_SND_SOC_TFA9879 is not set
+# CONFIG_SND_SOC_TLV320AIC23_I2C is not set
+# CONFIG_SND_SOC_TLV320AIC23_SPI is not set
+# CONFIG_SND_SOC_TLV320AIC31XX is not set
+# CONFIG_SND_SOC_TLV320AIC3X is not set
+# CONFIG_SND_SOC_TS3A227E is not set
+# CONFIG_SND_SOC_WM8510 is not set
+# CONFIG_SND_SOC_WM8523 is not set
+# CONFIG_SND_SOC_WM8580 is not set
+# CONFIG_SND_SOC_WM8711 is not set
+# CONFIG_SND_SOC_WM8728 is not set
+# CONFIG_SND_SOC_WM8731 is not set
+# CONFIG_SND_SOC_WM8737 is not set
+# CONFIG_SND_SOC_WM8741 is not set
+# CONFIG_SND_SOC_WM8750 is not set
+# CONFIG_SND_SOC_WM8753 is not set
+# CONFIG_SND_SOC_WM8770 is not set
+# CONFIG_SND_SOC_WM8776 is not set
+# CONFIG_SND_SOC_WM8804_I2C is not set
+# CONFIG_SND_SOC_WM8804_SPI is not set
+# CONFIG_SND_SOC_WM8903 is not set
+# CONFIG_SND_SOC_WM8962 is not set
+# CONFIG_SND_SOC_WM8978 is not set
+# CONFIG_SND_SOC_TPA6130A2 is not set
+# CONFIG_SND_SIMPLE_CARD is not set
+# CONFIG_SOUND_PRIME is not set
+
+#
+# HID support
+#
+CONFIG_HID=y
+# CONFIG_HID_BATTERY_STRENGTH is not set
+# CONFIG_HIDRAW is not set
+# CONFIG_UHID is not set
+# CONFIG_HID_GENERIC is not set
+
+#
+# Special HID drivers
+#
+# CONFIG_HID_A4TECH is not set
+# CONFIG_HID_ACRUX is not set
+# CONFIG_HID_APPLE is not set
+# CONFIG_HID_AUREAL is not set
+# CONFIG_HID_BELKIN is not set
+# CONFIG_HID_CHERRY is not set
+# CONFIG_HID_CHICONY is not set
+# CONFIG_HID_PRODIKEYS is not set
+# CONFIG_HID_CYPRESS is not set
+# CONFIG_HID_DRAGONRISE is not set
+# CONFIG_HID_EMS_FF is not set
+# CONFIG_HID_ELECOM is not set
+# CONFIG_HID_EZKEY is not set
+# CONFIG_HID_KEYTOUCH is not set
+# CONFIG_HID_KYE is not set
+# CONFIG_HID_WALTOP is not set
+# CONFIG_HID_FBX_REMOTE_AUDIO is not set
+# CONFIG_HID_GYRATION is not set
+# CONFIG_HID_ICADE is not set
+# CONFIG_HID_TWINHAN is not set
+# CONFIG_HID_KENSINGTON is not set
+# CONFIG_HID_LCPOWER is not set
+# CONFIG_HID_LENOVO is not set
+# CONFIG_HID_LOGITECH is not set
+# CONFIG_HID_MAGICMOUSE is not set
+# CONFIG_HID_MICROSOFT is not set
+# CONFIG_HID_MONTEREY is not set
+# CONFIG_HID_MULTITOUCH is not set
+# CONFIG_HID_ORTEK is not set
+# CONFIG_HID_PANTHERLORD is not set
+# CONFIG_HID_PETALYNX is not set
+# CONFIG_HID_PICOLCD is not set
+# CONFIG_HID_PLANTRONICS is not set
+# CONFIG_HID_PRIMAX is not set
+# CONFIG_HID_SAITEK is not set
+# CONFIG_HID_SAMSUNG is not set
+# CONFIG_HID_SPEEDLINK is not set
+# CONFIG_HID_STEELSERIES is not set
+# CONFIG_HID_SUNPLUS is not set
+# CONFIG_HID_RMI is not set
+# CONFIG_HID_GREENASIA is not set
+# CONFIG_HID_SMARTJOYPLUS is not set
+# CONFIG_HID_TIVO is not set
+# CONFIG_HID_TOPSEED is not set
+# CONFIG_HID_THINGM is not set
+# CONFIG_HID_THRUSTMASTER is not set
+# CONFIG_HID_WACOM is not set
+# CONFIG_HID_WIIMOTE is not set
+# CONFIG_HID_XINMO is not set
+# CONFIG_HID_ZEROPLUS is not set
+# CONFIG_HID_ZYDACRON is not set
+# CONFIG_HID_SENSOR_HUB is not set
+
+#
+# USB HID support
+#
+# CONFIG_USB_HID is not set
+# CONFIG_HID_PID is not set
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
+
+#
+# I2C HID support
+#
+# CONFIG_I2C_HID is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_COMMON=y
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB=y
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEFAULT_PERSIST=y
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+# CONFIG_USB_OTG_FSM is not set
+# CONFIG_USB_ULPI_BUS is not set
+# CONFIG_USB_MON is not set
+# CONFIG_USB_WUSB_CBAF is not set
+
+#
+# USB Host Controller Drivers
+#
+# CONFIG_USB_C67X00_HCD is not set
+# CONFIG_USB_XHCI_HCD is not set
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+# CONFIG_USB_EHCI_TT_NEWSCHED is not set
+CONFIG_USB_EHCI_PCI=m
+CONFIG_USB_EHCI_HCD_ORION=m
+# CONFIG_USB_EHCI_HCD_PLATFORM is not set
+# CONFIG_USB_OXU210HP_HCD is not set
+# CONFIG_USB_ISP116X_HCD is not set
+# CONFIG_USB_ISP1362_HCD is not set
+# CONFIG_USB_FUSBH200_HCD is not set
+# CONFIG_USB_FOTG210_HCD is not set
+# CONFIG_USB_MAX3421_HCD is not set
+# CONFIG_USB_OHCI_HCD is not set
+# CONFIG_USB_UHCI_HCD is not set
+# CONFIG_USB_SL811_HCD is not set
+# CONFIG_USB_R8A66597_HCD is not set
+# CONFIG_USB_HCD_TEST_MODE is not set
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=y
+CONFIG_USB_PRINTER=y
+# CONFIG_USB_WDM is not set
+# CONFIG_USB_TMC is not set
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
+#
+
+#
+# also be needed; see USB_STORAGE Help for more info
+#
+CONFIG_USB_STORAGE=y
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_REALTEK is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_ISD200 is not set
+# CONFIG_USB_STORAGE_USBAT is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_STORAGE_SDDR55 is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_ALAUDA is not set
+# CONFIG_USB_STORAGE_ONETOUCH is not set
+# CONFIG_USB_STORAGE_KARMA is not set
+# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
+# CONFIG_USB_STORAGE_ENE_UB6250 is not set
+# CONFIG_USB_UAS is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USBIP_CORE is not set
+# CONFIG_USB_MUSB_HDRC is not set
+# CONFIG_USB_DWC3 is not set
+# CONFIG_USB_DWC2 is not set
+# CONFIG_USB_CHIPIDEA is not set
+# CONFIG_USB_ISP1760 is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_SERIAL is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_ADUTUX is not set
+# CONFIG_USB_SEVSEG is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_FTDI_ELAN is not set
+# CONFIG_USB_APPLEDISPLAY is not set
+# CONFIG_USB_SISUSBVGA is not set
+# CONFIG_USB_LD is not set
+# CONFIG_USB_TRANCEVIBRATOR is not set
+# CONFIG_USB_IOWARRIOR is not set
+# CONFIG_USB_TEST is not set
+# CONFIG_USB_EHSET_TEST_FIXTURE is not set
+# CONFIG_USB_ISIGHTFW is not set
+# CONFIG_USB_YUREX is not set
+# CONFIG_USB_EZUSB_FX2 is not set
+# CONFIG_USB_HSIC_USB3503 is not set
+# CONFIG_USB_LINK_LAYER_TEST is not set
+
+#
+# USB Physical Layer drivers
+#
+# CONFIG_USB_PHY is not set
+# CONFIG_NOP_USB_XCEIV is not set
+# CONFIG_AM335X_PHY_USB is not set
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_USB_ISP1301 is not set
+# CONFIG_USB_ULPI is not set
+# CONFIG_USB_GADGET is not set
+# CONFIG_USB_LED_TRIG is not set
+# CONFIG_UWB is not set
+# CONFIG_MMC is not set
+# CONFIG_MEMSTICK is not set
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+# CONFIG_LEDS_CLASS_FLASH is not set
+
+#
+# LED drivers
+#
+# CONFIG_LEDS_BCM6328 is not set
+# CONFIG_LEDS_BCM6358 is not set
+# CONFIG_LEDS_LM3530 is not set
+# CONFIG_LEDS_LM3642 is not set
+# CONFIG_LEDS_PCA9532 is not set
+# CONFIG_LEDS_GPIO is not set
+# CONFIG_LEDS_LP3944 is not set
+# CONFIG_LEDS_LP5521 is not set
+# CONFIG_LEDS_LP5523 is not set
+# CONFIG_LEDS_LP5562 is not set
+# CONFIG_LEDS_LP8501 is not set
+# CONFIG_LEDS_LP8860 is not set
+# CONFIG_LEDS_PCA955X is not set
+# CONFIG_LEDS_PCA963X is not set
+# CONFIG_LEDS_DAC124S085 is not set
+# CONFIG_LEDS_BD2802 is not set
+# CONFIG_LEDS_LT3593 is not set
+# CONFIG_LEDS_NS2 is not set
+# CONFIG_LEDS_NETXBIG is not set
+# CONFIG_LEDS_TCA6507 is not set
+# CONFIG_LEDS_TLC591XX is not set
+# CONFIG_LEDS_LM355x is not set
+
+#
+# LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)
+#
+# CONFIG_LEDS_BLINKM is not set
+# CONFIG_LEDS_PM8941_WLED is not set
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+# CONFIG_LEDS_TRIGGER_TIMER is not set
+# CONFIG_LEDS_TRIGGER_ONESHOT is not set
+# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set
+# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
+# CONFIG_LEDS_TRIGGER_CPU is not set
+# CONFIG_LEDS_TRIGGER_GPIO is not set
+# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
+
+#
+# iptables trigger is under Netfilter config (LED target)
+#
+# CONFIG_LEDS_TRIGGER_TRANSIENT is not set
+# CONFIG_LEDS_TRIGGER_CAMERA is not set
+# CONFIG_ACCESSIBILITY is not set
+# CONFIG_INFINIBAND is not set
+CONFIG_EDAC_ATOMIC_SCRUB=y
+CONFIG_EDAC_SUPPORT=y
+# CONFIG_EDAC is not set
+CONFIG_RTC_LIB=y
+# CONFIG_RTC_CLASS is not set
+# CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+# CONFIG_VIRT_DRIVERS is not set
+
+#
+# Virtio drivers
+#
+# CONFIG_VIRTIO_PCI is not set
+# CONFIG_VIRTIO_MMIO is not set
+
+#
+# Microsoft Hyper-V guest support
+#
+# CONFIG_STAGING is not set
+# CONFIG_CHROME_PLATFORMS is not set
+CONFIG_CLKDEV_LOOKUP=y
+CONFIG_HAVE_CLK_PREPARE=y
+CONFIG_COMMON_CLK=y
+
+#
+# Common Clock Framework
+#
+# CONFIG_COMMON_CLK_SI5351 is not set
+# CONFIG_COMMON_CLK_SI570 is not set
+# CONFIG_COMMON_CLK_CDCE925 is not set
+# CONFIG_CLK_QORIQ is not set
+# CONFIG_COMMON_CLK_PXA is not set
+# CONFIG_COMMON_CLK_CDCE706 is not set
+CONFIG_MVEBU_CLK_COMMON=y
+CONFIG_KIRKWOOD_CLK=y
+
+#
+# Hardware Spinlock drivers
+#
+
+#
+# Clock Source drivers
+#
+CONFIG_CLKSRC_OF=y
+CONFIG_CLKSRC_MMIO=y
+CONFIG_ORION_TIMER=y
+# CONFIG_ARM_TIMER_SP804 is not set
+# CONFIG_ATMEL_PIT is not set
+# CONFIG_SH_TIMER_CMT is not set
+# CONFIG_SH_TIMER_MTU2 is not set
+# CONFIG_SH_TIMER_TMU is not set
+# CONFIG_EM_TIMER_STI is not set
+# CONFIG_MAILBOX is not set
+# CONFIG_IOMMU_SUPPORT is not set
+
+#
+# Remoteproc drivers
+#
+# CONFIG_STE_MODEM_RPROC is not set
+
+#
+# Rpmsg drivers
+#
+
+#
+# SOC (System On Chip) specific Drivers
+#
+# CONFIG_SUNXI_SRAM is not set
+# CONFIG_SOC_TI is not set
+# CONFIG_PM_DEVFREQ is not set
+# CONFIG_EXTCON is not set
+# CONFIG_MEMORY is not set
+# CONFIG_IIO is not set
+# CONFIG_NTB is not set
+# CONFIG_VME_BUS is not set
+# CONFIG_PWM is not set
+CONFIG_IRQCHIP=y
+CONFIG_ORION_IRQCHIP=y
+# CONFIG_IPACK_BUS is not set
+# CONFIG_RESET_CONTROLLER is not set
+# CONFIG_FMC is not set
+
+#
+# PHY Subsystem
+#
+CONFIG_GENERIC_PHY=y
+# CONFIG_PHY_PXA_28NM_HSIC is not set
+# CONFIG_PHY_PXA_28NM_USB2 is not set
+CONFIG_PHY_MVEBU_SATA=y
+# CONFIG_BCM_KONA_USB2_PHY is not set
+# CONFIG_POWERCAP is not set
+# CONFIG_MCB is not set
+CONFIG_RAS=y
+# CONFIG_THUNDERBOLT is not set
+
+#
+# Android
+#
+# CONFIG_ANDROID is not set
+
+#
+# Firmware Drivers
+#
+# CONFIG_FIRMWARE_MEMMAP is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_EXT4_FS=y
+# CONFIG_EXT4_FS_POSIX_ACL is not set
+# CONFIG_EXT4_FS_SECURITY is not set
+# CONFIG_EXT4_ENCRYPTION is not set
+# CONFIG_EXT4_DEBUG is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=y
+# CONFIG_JBD2_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+CONFIG_XFS_FS=y
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_POSIX_ACL is not set
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_WARN is not set
+# CONFIG_XFS_DEBUG is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+# CONFIG_F2FS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_EXPORTFS=y
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_FANOTIFY=y
+# CONFIG_QUOTA is not set
+# CONFIG_QUOTACTL is not set
+# CONFIG_AUTOFS4_FS is not set
+CONFIG_FUSE_FS=y
+# CONFIG_CUSE is not set
+# CONFIG_OVERLAY_FS is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=850
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+CONFIG_NTFS_FS=y
+# CONFIG_NTFS_DEBUG is not set
+# CONFIG_NTFS_RW is not set
+CONFIG_EXFAT_FS=y
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
+# CONFIG_PROC_CHILDREN is not set
+CONFIG_KERNFS=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_TMPFS_XATTR is not set
+# CONFIG_HUGETLB_PAGE is not set
+# CONFIG_CONFIGFS_FS is not set
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+CONFIG_HFS_FS=y
+CONFIG_HFSPLUS_FS=y
+# CONFIG_HFSPLUS_FS_POSIX_ACL is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS2_FS is not set
+CONFIG_UBIFS_FS=y
+CONFIG_UBIFS_FS_ADVANCED_COMPR=y
+CONFIG_UBIFS_FS_LZO=y
+CONFIG_UBIFS_FS_ZLIB=y
+# CONFIG_LOGFS is not set
+CONFIG_CRAMFS=y
+CONFIG_SQUASHFS=y
+CONFIG_SQUASHFS_FILE_CACHE=y
+# CONFIG_SQUASHFS_FILE_DIRECT is not set
+CONFIG_SQUASHFS_DECOMP_SINGLE=y
+# CONFIG_SQUASHFS_DECOMP_MULTI is not set
+# CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU is not set
+# CONFIG_SQUASHFS_XATTR is not set
+CONFIG_SQUASHFS_ZLIB=y
+# CONFIG_SQUASHFS_LZ4 is not set
+# CONFIG_SQUASHFS_LZO is not set
+# CONFIG_SQUASHFS_XZ is not set
+# CONFIG_SQUASHFS_4K_DEVBLK_SIZE is not set
+# CONFIG_SQUASHFS_EMBEDDED is not set
+CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
+# CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_QNX6FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_PSTORE=y
+# CONFIG_PSTORE_CONSOLE is not set
+# CONFIG_PSTORE_PMSG is not set
+CONFIG_PSTORE_RAM=y
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V2=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFS_SWAP is not set
+CONFIG_ROOT_NFS=y
+CONFIG_NFSD=y
+CONFIG_NFSD_V3=y
+# CONFIG_NFSD_V3_ACL is not set
+CONFIG_NFSD_V4=y
+# CONFIG_NFSD_PNFS is not set
+# CONFIG_NFSD_FAULT_INJECTION is not set
+CONFIG_GRACE_PERIOD=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+# CONFIG_SUNRPC_DEBUG is not set
+# CONFIG_CEPH_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+CONFIG_NLS_CODEPAGE_850=y
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=y
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_MAC_ROMAN is not set
+# CONFIG_NLS_MAC_CELTIC is not set
+# CONFIG_NLS_MAC_CENTEURO is not set
+# CONFIG_NLS_MAC_CROATIAN is not set
+# CONFIG_NLS_MAC_CYRILLIC is not set
+# CONFIG_NLS_MAC_GAELIC is not set
+# CONFIG_NLS_MAC_GREEK is not set
+# CONFIG_NLS_MAC_ICELAND is not set
+# CONFIG_NLS_MAC_INUIT is not set
+# CONFIG_NLS_MAC_ROMANIAN is not set
+# CONFIG_NLS_MAC_TURKISH is not set
+CONFIG_NLS_UTF8=y
+
+#
+# Kernel hacking
+#
+
+#
+# printk and dmesg options
+#
+CONFIG_PRINTK_TIME=y
+CONFIG_MESSAGE_LOGLEVEL_DEFAULT=4
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+
+#
+# Compile-time checks and compiler options
+#
+# CONFIG_DEBUG_INFO is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+# CONFIG_STRIP_ASM_SYMS is not set
+# CONFIG_READABLE_ASM is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+# CONFIG_PAGE_OWNER is not set
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+# CONFIG_DEBUG_SECTION_MISMATCH is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1
+CONFIG_DEBUG_KERNEL=y
+
+#
+# Memory Debugging
+#
+# CONFIG_PAGE_EXTENSION is not set
+# CONFIG_DEBUG_PAGEALLOC is not set
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_SLUB_STATS is not set
+CONFIG_HAVE_DEBUG_KMEMLEAK=y
+# CONFIG_DEBUG_KMEMLEAK is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_DEBUG_VM is not set
+CONFIG_DEBUG_MEMORY_INIT=y
+# CONFIG_DEBUG_SHIRQ is not set
+
+#
+# Debug Lockups and Hangs
+#
+# CONFIG_LOCKUP_DETECTOR is not set
+CONFIG_DETECT_HUNG_TASK=y
+CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=1
+# CONFIG_PANIC_ON_OOPS is not set
+CONFIG_PANIC_ON_OOPS_VALUE=0
+CONFIG_PANIC_TIMEOUT=10
+# CONFIG_SCHED_DEBUG is not set
+# CONFIG_SCHED_INFO is not set
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_SCHED_STACK_END_CHECK is not set
+# CONFIG_DEBUG_TIMEKEEPING is not set
+# CONFIG_TIMER_STATS is not set
+
+#
+# Lock Debugging (spinlocks, mutexes, etc...)
+#
+CONFIG_DEBUG_RT_MUTEXES=y
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_WW_MUTEX_SLOWPATH is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+CONFIG_DEBUG_ATOMIC_SLEEP=y
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_LOCK_TORTURE_TEST is not set
+CONFIG_STACKTRACE=y
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+CONFIG_DEBUG_LIST=y
+CONFIG_DEBUG_PI_LIST=y
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
+
+#
+# RCU Debugging
+#
+# CONFIG_PROVE_RCU is not set
+# CONFIG_SPARSE_RCU_POINTER is not set
+# CONFIG_TORTURE_TEST is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_TRACE is not set
+# CONFIG_RCU_EQS_DEBUG is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_NOTIFIER_ERROR_INJECTION is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_LATENCYTOP is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
+CONFIG_HAVE_C_RECORDMCOUNT=y
+CONFIG_TRACING_SUPPORT=y
+# CONFIG_FTRACE is not set
+
+#
+# Runtime Testing
+#
+# CONFIG_LKDTM is not set
+# CONFIG_TEST_LIST_SORT is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_RBTREE_TEST is not set
+# CONFIG_INTERVAL_TREE_TEST is not set
+# CONFIG_PERCPU_TEST is not set
+# CONFIG_ATOMIC64_SELFTEST is not set
+# CONFIG_TEST_HEXDUMP is not set
+# CONFIG_TEST_STRING_HELPERS is not set
+# CONFIG_TEST_KSTRTOX is not set
+# CONFIG_TEST_RHASHTABLE is not set
+# CONFIG_DMA_API_DEBUG is not set
+# CONFIG_TEST_LKM is not set
+# CONFIG_TEST_USER_COPY is not set
+# CONFIG_TEST_BPF is not set
+# CONFIG_TEST_FIRMWARE is not set
+# CONFIG_TEST_UDELAY is not set
+# CONFIG_MEMTEST is not set
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+# CONFIG_ARM_PTDUMP is not set
+# CONFIG_STRICT_DEVMEM is not set
+CONFIG_ARM_UNWIND=y
+CONFIG_DEBUG_USER=y
+# CONFIG_DEBUG_LL is not set
+CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S"
+# CONFIG_DEBUG_UART_8250 is not set
+# CONFIG_DEBUG_UART_BCM63XX is not set
+CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h"
+CONFIG_DEBUG_SET_MODULE_RONX=y
+# CONFIG_CORESIGHT is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY_DMESG_RESTRICT is not set
+# CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
+CONFIG_DEFAULT_SECURITY_DAC=y
+CONFIG_DEFAULT_SECURITY=""
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
+CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_BLKCIPHER2=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_RNG_DEFAULT=y
+CONFIG_CRYPTO_PCOMP2=y
+CONFIG_CRYPTO_AKCIPHER2=y
+# CONFIG_CRYPTO_RSA is not set
+# CONFIG_CRYPTO_BUILTIN_TEST is not set
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+# CONFIG_CRYPTO_USER is not set
+CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y
+CONFIG_CRYPTO_GF128MUL=y
+CONFIG_CRYPTO_NULL=y
+CONFIG_CRYPTO_WORKQUEUE=y
+# CONFIG_CRYPTO_CRYPTD is not set
+# CONFIG_CRYPTO_MCRYPTD is not set
+CONFIG_CRYPTO_AUTHENC=y
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+CONFIG_CRYPTO_CCM=y
+CONFIG_CRYPTO_GCM=y
+# CONFIG_CRYPTO_CHACHA20POLY1305 is not set
+CONFIG_CRYPTO_SEQIV=y
+CONFIG_CRYPTO_ECHAINIV=y
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=y
+CONFIG_CRYPTO_CTR=y
+# CONFIG_CRYPTO_CTS is not set
+CONFIG_CRYPTO_ECB=y
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
+CONFIG_CRYPTO_CMAC=y
+CONFIG_CRYPTO_HMAC=y
+# CONFIG_CRYPTO_XCBC is not set
+# CONFIG_CRYPTO_VMAC is not set
+
+#
+# Digest
+#
+CONFIG_CRYPTO_CRC32C=y
+# CONFIG_CRYPTO_CRC32 is not set
+# CONFIG_CRYPTO_CRCT10DIF is not set
+CONFIG_CRYPTO_GHASH=y
+# CONFIG_CRYPTO_POLY1305 is not set
+# CONFIG_CRYPTO_MD4 is not set
+CONFIG_CRYPTO_MD5=y
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
+CONFIG_CRYPTO_SHA1=y
+CONFIG_CRYPTO_SHA256=y
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_AES=y
+# CONFIG_CRYPTO_ANUBIS is not set
+CONFIG_CRYPTO_ARC4=y
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_CHACHA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
+CONFIG_CRYPTO_DEFLATE=y
+# CONFIG_CRYPTO_ZLIB is not set
+CONFIG_CRYPTO_LZO=y
+# CONFIG_CRYPTO_842 is not set
+# CONFIG_CRYPTO_LZ4 is not set
+# CONFIG_CRYPTO_LZ4HC is not set
+
+#
+# Random Number Generation
+#
+# CONFIG_CRYPTO_ANSI_CPRNG is not set
+CONFIG_CRYPTO_DRBG_MENU=y
+CONFIG_CRYPTO_DRBG_HMAC=y
+# CONFIG_CRYPTO_DRBG_HASH is not set
+# CONFIG_CRYPTO_DRBG_CTR is not set
+CONFIG_CRYPTO_DRBG=y
+CONFIG_CRYPTO_JITTERENTROPY=y
+# CONFIG_CRYPTO_USER_API_HASH is not set
+# CONFIG_CRYPTO_USER_API_SKCIPHER is not set
+# CONFIG_CRYPTO_USER_API_RNG is not set
+# CONFIG_CRYPTO_USER_API_AEAD is not set
+# CONFIG_CRYPTO_HW is not set
+# CONFIG_ARM_CRYPTO is not set
+# CONFIG_BINARY_PRINTF is not set
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+# CONFIG_HAVE_ARCH_BITREVERSE is not set
+CONFIG_RATIONAL=y
+CONFIG_GENERIC_STRNCPY_FROM_USER=y
+CONFIG_GENERIC_STRNLEN_USER=y
+CONFIG_GENERIC_NET_UTILS=y
+CONFIG_GENERIC_PCI_IOMAP=y
+CONFIG_GENERIC_IO=y
+CONFIG_PERCPU_RWSEM=y
+CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y
+CONFIG_CRC_CCITT=y
+CONFIG_CRC16=y
+# CONFIG_CRC_T10DIF is not set
+# CONFIG_CRC_ITU_T is not set
+CONFIG_CRC32=y
+# CONFIG_CRC32_SELFTEST is not set
+CONFIG_CRC32_SLICEBY8=y
+# CONFIG_CRC32_SLICEBY4 is not set
+# CONFIG_CRC32_SARWATE is not set
+# CONFIG_CRC32_BIT is not set
+# CONFIG_CRC7 is not set
+CONFIG_LIBCRC32C=y
+# CONFIG_CRC8 is not set
+CONFIG_AUDIT_GENERIC=y
+# CONFIG_AUDIT_ARCH_COMPAT_GENERIC is not set
+# CONFIG_RANDOM32_SELFTEST is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_LZO_COMPRESS=y
+CONFIG_LZO_DECOMPRESS=y
+# CONFIG_XZ_DEC is not set
+# CONFIG_XZ_DEC_BCJ is not set
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_REED_SOLOMON=y
+CONFIG_REED_SOLOMON_ENC8=y
+CONFIG_REED_SOLOMON_DEC8=y
+CONFIG_BCH=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT_MAP=y
+CONFIG_HAS_DMA=y
+CONFIG_DQL=y
+CONFIG_GLOB=y
+# CONFIG_GLOB_SELFTEST is not set
+CONFIG_NLATTR=y
+CONFIG_GENERIC_ATOMIC64=y
+CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
+CONFIG_AVERAGE=y
+# CONFIG_CORDIC is not set
+# CONFIG_DDR is not set
+CONFIG_LIBFDT=y
+CONFIG_OID_REGISTRY=y
+CONFIG_ARCH_HAS_SG_CHAIN=y
+CONFIG_FBXSERIAL=y
+# CONFIG_VIRTUALIZATION is not set
diff -Nruw linux-4.2.6-fbx/drivers/fbxgpio./fbxgpio_core.c linux-4.2.6-fbx/drivers/fbxgpio/fbxgpio_core.c
--- linux-4.2.6-fbx/drivers/fbxgpio./fbxgpio_core.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxgpio/fbxgpio_core.c	2015-11-02 18:59:09.344451921 +0100
@@ -0,0 +1,312 @@
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/fbxgpio_core.h>
+
+#define PFX	"fbxgpio_core: "
+
+/* #define DEBUG */
+#ifdef DEBUG
+#define dprint(Fmt, Arg...)	printk(PFX Fmt, Arg)
+#else
+#define dprint(Fmt, Arg...)	do { } while (0)
+#endif
+
+static struct class *fbxgpio_class;
+
+/*
+ * show direction in for gpio associated with class_device dev.
+ */
+static ssize_t show_direction(struct device *dev,
+			      struct device_attribute *attr, char *buf)
+{
+	struct fbxgpio_pin *p;
+	int dir, ret = 0;
+
+	p = dev_get_drvdata(dev);
+
+	if (p->ops->get_direction)
+		dir = p->ops->get_direction(p->pin_num);
+	else
+		dir = p->direction;
+
+	switch (dir) {
+	case GPIO_DIR_IN:
+		ret += sprintf(buf, "input\n");
+		break;
+	case GPIO_DIR_OUT:
+		ret += sprintf(buf, "output\n");
+		break;
+	default:
+		ret += sprintf(buf, "unknown\n");
+		break;
+	}
+	return ret;
+}
+
+/*
+ * store direction. return -EINVAL if direction string is bad. return
+ * -EPERM if flag FBXGPIO_PIN_DIR_RW is set in flags.
+ */
+static ssize_t store_direction(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t size)
+{
+	int dir;
+	struct fbxgpio_pin *p;
+	int match_len = 0;
+	int i;
+	static const char *word_match[] = {
+		[GPIO_DIR_IN] = "input",
+		[GPIO_DIR_OUT] = "output",
+	};
+
+	if (*buf == ' ' || *buf == '\t' || *buf == '\r' || *buf == '\n')
+		/* silently eat any spaces/tab/linefeed/carriagereturn */
+		return 1;
+
+	p = dev_get_drvdata(dev);
+	if (!(p->flags & FBXGPIO_PIN_DIR_RW)) {
+		dprint("pin %s direction is read only.\n", p->pin_name);
+		return -EPERM;
+	}
+	dir = 0;
+	for (i = 0; i < 2; ++i) {
+		if (size >= strlen(word_match[i]) &&
+		    !strncmp(buf, word_match[i], strlen(word_match[i]))) {
+			dir = i;
+			match_len = strlen(word_match[i]);
+			break ;
+		}
+	}
+	if (i == 2)
+		return -EINVAL;
+
+	p->ops->set_direction(p->pin_num, dir);
+	return match_len;
+}
+
+/*
+ * show input data for input gpio pins.
+ */
+static ssize_t show_datain(struct device *dev,
+			   struct device_attribute *attr, char *buf)
+{
+	int val;
+	struct fbxgpio_pin *p;
+
+	p = dev_get_drvdata(dev);
+	if (p->direction == GPIO_DIR_OUT)
+		return -EINVAL;
+	val = p->ops->get_datain(p->pin_num);
+
+	if (p->flags & FBXGPIO_PIN_REVERSE_POL)
+		val = 1 - val;
+	return sprintf(buf, "%i\n", val);
+}
+
+/*
+ * show output data for output gpio pins.
+ */
+static ssize_t show_dataout(struct device *dev,
+			    struct device_attribute *attr, char *buf)
+{
+	int val;
+	struct fbxgpio_pin *p;
+
+	p = dev_get_drvdata(dev);
+	if (p->direction == GPIO_DIR_IN)
+		return -EINVAL;
+	if (p->ops->get_dataout)
+		val = p->ops->get_dataout(p->pin_num);
+	else
+		val = p->cur_dataout;
+
+	if (p->flags & FBXGPIO_PIN_REVERSE_POL)
+		val = 1 - val;
+	return sprintf(buf, "%i\n", val);
+}
+
+/*
+ * store new dataout value for output gpio pins.
+ */
+static ssize_t store_dataout(struct device *dev,
+	    struct device_attribute *attr, const char *buf, size_t size)
+{
+	int val;
+	struct fbxgpio_pin *p;
+
+	if (*buf == ' ' || *buf == '\t' || *buf == '\r' || *buf == '\n')
+		/* silently eat any spaces/tab/linefeed/carriagereturn */
+		return 1;
+
+	p = dev_get_drvdata(dev);
+
+	if (p->direction != GPIO_DIR_OUT)
+		return -EINVAL;
+
+	switch (*buf) {
+	case '0':
+		val = 0;
+		break ;
+	case '1':
+		val = 1;
+		break ;
+	default:
+		return -EINVAL;
+	}
+
+	p->cur_dataout = val;
+
+	if (p->flags & FBXGPIO_PIN_REVERSE_POL)
+		val = 1 - val;
+	p->ops->set_dataout(p->pin_num, val);
+	return 1;
+}
+
+/*
+ * show pin number associated with gpio pin.
+ */
+static ssize_t show_pinnum(struct device *dev,
+			   struct device_attribute *attr, char *buf)
+{
+	struct fbxgpio_pin *p;
+
+	p = dev_get_drvdata(dev);
+	return sprintf(buf, "%i\n", p->pin_num);
+}
+
+/*
+ * attribute list associated with each class device.
+ */
+static struct device_attribute gpio_attributes[] = {
+	__ATTR(direction, 0600, show_direction, store_direction),
+	__ATTR(data_in,   0400, show_datain, NULL),
+	__ATTR(data_out,  0600, show_dataout, store_dataout),
+	__ATTR(pin_num,   0400, show_pinnum, NULL),
+};
+
+static int fbxgpio_register_pin(struct platform_device *ppdev,
+				struct fbxgpio_pin *pin)
+{
+	struct device *dev;
+	int i, ret;
+
+	dprint("registering pin %s\n", pin->pin_name);
+
+	/* ensure ops is valid */
+	if (!pin->ops) {
+		printk(KERN_ERR PFX "no operation set for pin %s\n",
+		       pin->pin_name);
+		return -EINVAL;
+	}
+
+	dev = device_create(fbxgpio_class, &ppdev->dev, 0, pin,
+			    "%s", pin->pin_name);
+	if (IS_ERR(dev))
+		return PTR_ERR(dev);
+
+	for (i = 0; i < ARRAY_SIZE(gpio_attributes); i++) {
+		ret = device_create_file(dev, &gpio_attributes[i]);
+		if (ret)
+			goto err_out;
+	}
+
+	/* ensure pin direction matches hardware state */
+	if (pin->ops->get_direction &&
+	    pin->direction != pin->ops->get_direction(pin->pin_num)) {
+		printk(KERN_WARNING PFX "pin %s default direction does not "
+		       "match current hardware state, fixing.\n",
+		       pin->pin_name);
+		pin->ops->set_direction(pin->pin_num, pin->direction);
+	}
+	pin->dev = dev;
+	return 0;
+
+err_out:
+	for (; i >= 0; i--)
+		device_remove_file(dev, &gpio_attributes[i]);
+	device_unregister(dev);
+	return ret;
+}
+
+static void fbxgpio_unregister_pin(struct fbxgpio_pin *pin)
+{
+	struct device *dev;
+	int i;
+
+	dprint("unregistering pin %s\n", pin->pin_name);
+	dev = pin->dev;
+	pin->dev = NULL;
+
+	for (i = 0; i < ARRAY_SIZE(gpio_attributes); i++)
+		device_remove_file(dev, &gpio_attributes[i]);
+	device_unregister(dev);
+}
+
+static int fbxgpio_platform_probe(struct platform_device *pdev)
+{
+	struct fbxgpio_pin *p;
+	int err = 0;
+
+	p = pdev->dev.platform_data;
+	while (p->pin_name) {
+		err = fbxgpio_register_pin(pdev, p);
+		if (err)
+			return err;
+		++p;
+	}
+	return 0;
+}
+
+static int fbxgpio_platform_remove(struct platform_device *pdev)
+{
+	struct fbxgpio_pin *p;
+
+	p = pdev->dev.platform_data;
+	while (p->pin_name) {
+		fbxgpio_unregister_pin(p);
+		++p;
+	}
+	return 0;
+}
+
+static struct platform_driver fbxgpio_platform_driver =
+{
+	.probe	= fbxgpio_platform_probe,
+	.remove	= fbxgpio_platform_remove,
+	.driver	= {
+		.name	= "fbxgpio",
+	}
+};
+
+static int __init fbxgpio_init(void)
+{
+	int ret;
+
+	fbxgpio_class = class_create(THIS_MODULE, "fbxgpio");
+	if (IS_ERR(fbxgpio_class))
+		return PTR_ERR(fbxgpio_class);
+
+	ret = platform_driver_register(&fbxgpio_platform_driver);
+	if (ret) {
+		printk(KERN_ERR PFX "unable to register fbxgpio driver.\n");
+		class_destroy(fbxgpio_class);
+		return ret;
+	}
+	return 0;
+}
+
+static void __exit fbxgpio_exit(void)
+{
+	platform_driver_unregister(&fbxgpio_platform_driver);
+	class_destroy(fbxgpio_class);
+}
+
+subsys_initcall(fbxgpio_init);
+module_exit(fbxgpio_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Nicolas Schichan <nicolas.schichan@freebox.fr>");
diff -Nruw linux-4.2.6-fbx/drivers/fbxgpio./Kconfig linux-4.2.6-fbx/drivers/fbxgpio/Kconfig
--- linux-4.2.6-fbx/drivers/fbxgpio./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxgpio/Kconfig	2015-11-02 18:59:09.344451921 +0100
@@ -0,0 +1,3 @@
+config FREEBOX_GPIO
+	tristate "Freebox GPIO control interface"
+	default n
diff -Nruw linux-4.2.6-fbx/drivers/fbxgpio./Makefile linux-4.2.6-fbx/drivers/fbxgpio/Makefile
--- linux-4.2.6-fbx/drivers/fbxgpio./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxgpio/Makefile	2015-11-02 18:59:09.344451921 +0100
@@ -0,0 +1 @@
+obj-$(CONFIG_FREEBOX_GPIO)	+= fbxgpio_core.o
diff -Nruw linux-4.2.6-fbx/drivers/fbxjtag./Kconfig linux-4.2.6-fbx/drivers/fbxjtag/Kconfig
--- linux-4.2.6-fbx/drivers/fbxjtag./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxjtag/Kconfig	2015-11-02 18:59:33.144639544 +0100
@@ -0,0 +1,3 @@
+config FREEBOX_JTAG
+	tristate "Freebox JTAG control interface"
+	default n
diff -Nruw linux-4.2.6-fbx/drivers/fbxjtag./Makefile linux-4.2.6-fbx/drivers/fbxjtag/Makefile
--- linux-4.2.6-fbx/drivers/fbxjtag./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxjtag/Makefile	2015-11-02 18:59:33.144639544 +0100
@@ -0,0 +1 @@
+obj-$(CONFIG_FREEBOX_JTAG)	+= fbxjtag.o
diff -Nruw linux-4.2.6-fbx/drivers/fbxmtd./Kconfig linux-4.2.6-fbx/drivers/fbxmtd/Kconfig
--- linux-4.2.6-fbx/drivers/fbxmtd./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxmtd/Kconfig	2015-11-02 19:00:47.129222768 +0100
@@ -0,0 +1,41 @@
+menuconfig FREEBOX_MTD
+	tristate "Freebox Memory Technology Devices (FBXMTD) support"
+
+if FREEBOX_MTD
+
+config FREEBOX_MTD_BACKEND_AMD
+	bool "Support for AMD compatible flash"
+
+config FREEBOX_MTD_BACKEND_INTEL
+	bool "Support for Intel Strataflash"
+
+config FREEBOX_MTD_BLK
+	tristate "Block device access to fbxmtd"
+	depends on BLOCK
+
+config FREEBOX_MTD_CHAR
+	tristate "Character device access to fbxmtd"
+
+
+comment "Mapping drivers"
+
+#
+# Generic mapping driver.
+#
+config FREEBOX_MTD_MAP_DRV_FBX
+	tristate "Freebox mapping Driver."
+	select CRC32
+
+config FREEBOX_MTD_MAP_DRV_BCM963XX
+	tristate "Broadcom 963xx flash format"
+	select CRC32
+
+#
+# Freebox MTD Map Control interface
+#
+config FREEBOX_MTD_MAP_IOCTL
+	tristate "IOCTL control interface"
+	depends on FREEBOX_MTD_MAP_DRV_FBX
+
+endif
+
diff -Nruw linux-4.2.6-fbx/drivers/fbxmtd./Makefile linux-4.2.6-fbx/drivers/fbxmtd/Makefile
--- linux-4.2.6-fbx/drivers/fbxmtd./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxmtd/Makefile	2015-11-02 19:00:47.129222768 +0100
@@ -0,0 +1,24 @@
+
+# core support
+obj-$(CONFIG_FREEBOX_MTD) += fbxmtd.o
+
+fbxmtd-objs += fbxmtd_core.o fbxmtd_core_io.o
+ifeq ($(CONFIG_FREEBOX_MTD_BACKEND_AMD),y)
+fbxmtd-objs += fbxmtd_core_amd.o
+endif
+
+ifeq ($(CONFIG_FREEBOX_MTD_BACKEND_INTEL),y)
+fbxmtd-objs += fbxmtd_core_intel.o
+endif
+
+# generic character device access support (r/w with read erase modify write)
+obj-$(CONFIG_FREEBOX_MTD_CHAR) += fbxmtd_char.o
+fbxmtd_char-objs += fbxmtd_char_dev.o
+
+# generic r/o block device access support
+obj-$(CONFIG_FREEBOX_MTD_BLK) += fbxmtd_blk.o
+fbxmtd_blk-objs += fbxmtd_blk_dev.o
+
+obj-$(CONFIG_FREEBOX_MTD_MAP_DRV_FBX) += fbxmtd_map_drv_fbx.o
+obj-$(CONFIG_FREEBOX_MTD_MAP_DRV_BCM963XX) += fbxmtd_map_drv_bcm963xx.o
+obj-$(CONFIG_FREEBOX_MTD_MAP_IOCTL) += fbxmtd_map_ioctl.o
diff -Nruw linux-4.2.6-fbx/drivers/fbxprocfs./fbxprocfs.c linux-4.2.6-fbx/drivers/fbxprocfs/fbxprocfs.c
--- linux-4.2.6-fbx/drivers/fbxprocfs./fbxprocfs.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxprocfs/fbxprocfs.c	2015-11-02 18:59:07.048433820 +0100
@@ -0,0 +1,299 @@
+/*
+ * Freebox ProcFs interface
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/seq_file.h>
+#include <linux/uaccess.h>
+#include <linux/sizes.h>
+
+#include <linux/fbxprocfs.h>
+
+#define PFX	"fbxprocfs: "
+
+
+static struct list_head clients;
+static struct mutex clients_mutex;
+
+static struct proc_dir_entry *root;
+
+/*
+ * register  a  fbxprocfs client  with  given  dirname, caller  should
+ * consider returned struct opaque
+ */
+struct fbxprocfs_client *fbxprocfs_add_client(const char *dirname,
+					      struct module *owner)
+{
+	struct fbxprocfs_client *ret, *p;
+
+	ret = NULL;
+	mutex_lock(&clients_mutex);
+
+	/* check for duplicate */
+	list_for_each_entry(p, &clients, list) {
+		if (!strcmp(dirname, p->dirname))
+			goto out;
+	}
+
+	if (!(ret = kmalloc(sizeof (*ret), GFP_KERNEL))) {
+		printk(KERN_ERR PFX "kmalloc failed\n");
+		goto out;
+	}
+
+	/* try to create client directory */
+	if (!(ret->dir = proc_mkdir(dirname, root))) {
+		printk(KERN_ERR PFX "can't create %s dir\n", dirname);
+		kfree(ret);
+		ret = NULL;
+		goto out;
+	}
+
+	atomic_set(&ret->refcount, 1);
+	ret->dirname = dirname;
+	list_add(&ret->list, &clients);
+
+out:
+	mutex_unlock(&clients_mutex);
+	return ret;
+}
+
+/*
+ * unregister  a  fbxprocfs client, make sure usage count is zero
+ */
+int fbxprocfs_remove_client(struct fbxprocfs_client *client)
+{
+	int ret;
+
+	mutex_lock(&clients_mutex);
+
+	ret = 0;
+	if (atomic_read(&client->refcount) > 1) {
+		ret = -EBUSY;
+		goto out;
+	}
+
+	remove_proc_entry(client->dirname, root);
+	list_del(&client->list);
+	kfree(client);
+
+out:
+	mutex_unlock(&clients_mutex);
+	return ret;
+}
+
+/*
+ * remove given entries from client directory
+ */
+static int
+__remove_entries(struct fbxprocfs_client *client,
+		 const struct fbxprocfs_desc *ro_desc,
+		 const struct fbxprocfs_desc *rw_desc)
+{
+	int i;
+
+	for (i = 0; ro_desc && ro_desc[i].name; i++) {
+		remove_proc_entry(ro_desc[i].name, client->dir);
+		atomic_dec(&client->refcount);
+	}
+
+	for (i = 0; rw_desc && rw_desc[i].name; i++) {
+		remove_proc_entry(rw_desc[i].name, client->dir);
+		atomic_dec(&client->refcount);
+	}
+
+	return 0;
+}
+
+/*
+ * replacement for NULL rfunc.
+ */
+static int bad_rfunc(struct seq_file *m, void *ptr)
+{
+	return -EACCES;
+}
+
+/*
+ * fbxprocfs write path is now handled by seq_file code. this
+ * simplifies client code greatly.
+ */
+static int fbxprocfs_open(struct inode *inode, struct file *file)
+{
+	const struct fbxprocfs_desc *desc = PDE_DATA(inode);
+
+	return single_open(file, desc->rfunc ? desc->rfunc : bad_rfunc,
+			   (void*)desc->id);
+}
+
+/*
+ * no particular help from kernel in the write path, fetch user buffer
+ * in a kernel buffer and call write func.
+ */
+static int fbxprocfs_write(struct file *file, const char __user *ubuf,
+			   size_t len, loff_t *off)
+{
+	/*
+	 * get fbxprocfs desc via the proc_dir_entry in file inode
+	 */
+	struct fbxprocfs_desc *d = PDE_DATA(file_inode(file));
+	char *kbuf;
+	int ret;
+
+	/*
+	 * must have a wfunc callback.
+	 */
+	if (!d->wfunc)
+		return -EACCES;
+
+	/*
+	 * allow up to SZ_4K bytes to be written.
+	 */
+	if (len > SZ_4K)
+		return -EOVERFLOW;
+
+	/*
+	 * alloc and fetch kernel buffer containing user data.
+	 */
+	kbuf = kmalloc(SZ_4K, GFP_KERNEL);
+	if (!kbuf)
+		return -ENOMEM;
+
+	ret = -EFAULT;
+	if (copy_from_user(kbuf, ubuf, len))
+		goto kfree;
+
+	ret = d->wfunc(file, kbuf, len, (void*)d->id);
+
+kfree:
+	kfree(kbuf);
+	return ret;
+}
+
+/*
+ * fbxprocfs file operations, read stuff is handled by seq_file code.
+ */
+static const struct file_operations fbxprocfs_fops = {
+	.open		= fbxprocfs_open,
+	.llseek		= seq_lseek,
+	.read		= seq_read,
+	.release	= seq_release,
+	.write		= fbxprocfs_write,
+};
+
+/*
+ * replaces create_proc_read_entry removed in latest kernels.
+ */
+static struct proc_dir_entry *__create_proc_read_entry(
+				       const struct fbxprocfs_desc *desc,
+				       struct proc_dir_entry *base)
+{
+	return proc_create_data(desc->name, 0, base, &fbxprocfs_fops,
+				(void*)desc);
+}
+
+/*
+ * replaces create_proc_entry removed in latest kernels.
+ */
+static struct proc_dir_entry *__create_proc_entry(
+					const struct fbxprocfs_desc *desc,
+					struct proc_dir_entry *base)
+{
+	return proc_create_data(desc->name, S_IFREG | S_IWUSR | S_IRUGO,
+				base, &fbxprocfs_fops, (void*)desc);
+}
+
+/*
+ * create given entries in client directory
+ */
+static int
+__create_entries(struct fbxprocfs_client *client,
+		 const struct fbxprocfs_desc *ro_desc,
+		 const struct fbxprocfs_desc *rw_desc)
+{
+	struct proc_dir_entry	*proc;
+	int			i;
+
+	for (i = 0; ro_desc && ro_desc[i].name; i++) {
+		if (!(proc = __create_proc_read_entry(&ro_desc[i],
+						      client->dir))) {
+			printk(KERN_ERR PFX "can't create %s/%s entry\n",
+			       client->dirname, ro_desc[i].name);
+			goto err;
+		}
+		atomic_inc(&client->refcount);
+	}
+
+	for (i = 0; rw_desc && rw_desc[i].name; i++) {
+		if (!(proc = __create_proc_entry(&rw_desc[i], client->dir))) {
+			printk(KERN_ERR PFX "can't create %s/%s entry\n",
+			       client->dirname, ro_desc[i].name);
+			goto err;
+		}
+		atomic_inc(&client->refcount);
+	}
+
+	return 0;
+
+err:
+	__remove_entries(client, ro_desc, rw_desc);
+	return -1;
+}
+
+int
+fbxprocfs_create_entries(struct fbxprocfs_client *client,
+			 const struct fbxprocfs_desc *ro_desc,
+			 const struct fbxprocfs_desc *rw_desc)
+{
+	int	ret;
+
+	ret = __create_entries(client, ro_desc, rw_desc);
+	return ret;
+}
+
+int
+fbxprocfs_remove_entries(struct fbxprocfs_client *client,
+			 const struct fbxprocfs_desc *ro_desc,
+			 const struct fbxprocfs_desc *rw_desc)
+{
+	int	ret;
+
+	ret = __remove_entries(client, ro_desc, rw_desc);
+	return ret;
+}
+
+
+static int __init
+fbxprocfs_init(void)
+{
+	INIT_LIST_HEAD(&clients);
+	mutex_init(&clients_mutex);
+
+	/* create freebox directory */
+	if (!(root = proc_mkdir("freebox", NULL))) {
+		printk(KERN_ERR PFX "can't create freebox/ dir\n");
+		return -EIO;
+	}
+	return 0;
+}
+
+static void __exit
+fbxprocfs_exit(void)
+{
+	remove_proc_entry("freebox", NULL);
+}
+
+module_init(fbxprocfs_init);
+module_exit(fbxprocfs_exit);
+
+EXPORT_SYMBOL(fbxprocfs_create_entries);
+EXPORT_SYMBOL(fbxprocfs_remove_entries);
+EXPORT_SYMBOL(fbxprocfs_add_client);
+EXPORT_SYMBOL(fbxprocfs_remove_client);
+
+MODULE_LICENSE("GPL");
+MODULE_VERSION("1.0");
+MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
+
diff -Nruw linux-4.2.6-fbx/drivers/fbxprocfs./Kconfig linux-4.2.6-fbx/drivers/fbxprocfs/Kconfig
--- linux-4.2.6-fbx/drivers/fbxprocfs./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxprocfs/Kconfig	2015-11-02 18:59:06.816431990 +0100
@@ -0,0 +1,2 @@
+config FREEBOX_PROCFS
+	tristate "Freebox procfs interface"
diff -Nruw linux-4.2.6-fbx/drivers/fbxprocfs./Makefile linux-4.2.6-fbx/drivers/fbxprocfs/Makefile
--- linux-4.2.6-fbx/drivers/fbxprocfs./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxprocfs/Makefile	2015-11-02 18:59:06.816431990 +0100
@@ -0,0 +1 @@
+obj-$(CONFIG_FREEBOX_PROCFS) += fbxprocfs.o
diff -Nruw linux-4.2.6-fbx/drivers/fbxwatchdog./fbxwatchdog_char.c linux-4.2.6-fbx/drivers/fbxwatchdog/fbxwatchdog_char.c
--- linux-4.2.6-fbx/drivers/fbxwatchdog./fbxwatchdog_char.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxwatchdog/fbxwatchdog_char.c	2015-11-02 18:59:16.988512183 +0100
@@ -0,0 +1,218 @@
+/*
+ * add standard char device interface for fbxwatchdog.
+ */
+
+/*
+ * XXX: results are undefined if attemps are made to access watchdog
+ * from char device interface and sysfs at the same time.
+ */
+
+#define PFX "fbxwatchdog_char: "
+
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/module.h>
+#include <linux/timer.h>
+#include <linux/miscdevice.h>
+#include <linux/watchdog.h>
+#include "fbxwatchdog.h"
+
+#include <asm/uaccess.h>
+
+static struct fbxwatchdog *chardev_wdt;
+static unsigned long chardev_users;
+static unsigned long default_countdown = 60 * 1000;
+static int expect_close;
+
+/*
+ * we support the WDIOF_MAGICCLOSE: is the user writes 'V' to the device,
+ * the release method will stop the watchdog.
+ */
+static int
+wdt_write(struct file *file, const char *__user buf, size_t len, loff_t *ppos)
+{
+	int i;
+
+	if (!len)
+		return 0;
+
+	for (i = 0; i < len; ++i) {
+		char c;
+
+		if (get_user(c, buf + i))
+			return -EFAULT;
+		if (c == 'V')
+			expect_close = 1;
+	}
+	if (len)
+		chardev_wdt->countdown = default_countdown;
+	return len;
+}
+
+static long
+wdt_ioctl(struct file *file,
+	  unsigned int cmd, unsigned long arg)
+{
+	static const struct watchdog_info winfo = {
+		.options		= WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE |
+					  WDIOF_KEEPALIVEPING,
+		.firmware_version	= 0x42,
+		.identity		= "fbxwatchdog",
+	};
+	int tmp;
+
+	switch (cmd) {
+	case WDIOC_GETSUPPORT:
+		/*
+		 * return watchdog information structure to userland.
+		 */
+		return copy_to_user((struct watchdog_info __user *)arg,
+				    &winfo, sizeof (winfo)) ? -EFAULT: 0;
+
+	case WDIOC_SETTIMEOUT:
+		/*
+		 * set watchdog timeout: if current countdown is
+		 * higher than timeout, set countdown to timeout
+		 * value.
+		 */
+		if (copy_from_user(&tmp, (void __user *) arg,
+				   sizeof (tmp))) {
+			return -EFAULT;
+		}
+		if (1000 * tmp < 0)
+			return -EINVAL;
+		default_countdown = 1000 * tmp;
+		if (chardev_wdt->countdown > default_countdown)
+			chardev_wdt->countdown = default_countdown;
+		return 0;
+
+	case WDIOC_GETTIMEOUT:
+		/*
+		 * get current timeout value.
+		 */
+		tmp = default_countdown / 1000;
+		return copy_to_user((void __user *)arg, &tmp,
+				    sizeof (tmp)) ? -EFAULT : 0;
+
+	case WDIOC_KEEPALIVE:
+		/*
+		 * ping watchdog.
+		 */
+		chardev_wdt->countdown = default_countdown;
+		return 0;
+
+	case WDIOC_GETTIMELEFT:
+		/*
+		 * return current countdown value to userland.
+		 */
+		tmp = chardev_wdt->countdown / 1000;
+		return copy_to_user((void __user *)arg, &tmp, sizeof (tmp)) ?
+		  -EFAULT : 0;
+
+	default:
+		return -ENOIOCTLCMD;
+	}
+}
+
+/*
+ * called when remote process calls close(2) on watchdog fd or
+ * exit(2).
+ */
+static int
+wdt_release(struct inode *inode, struct file *file)
+{
+	unsigned long flags;
+
+	if (expect_close && chardev_wdt->enabled) {
+		spin_lock_irqsave(&chardev_wdt->lock, flags);
+		chardev_wdt->enabled = 0;
+		chardev_wdt->wdt_stop(chardev_wdt);
+		spin_unlock_irqrestore(&chardev_wdt->lock, flags);
+	} else
+		printk(KERN_CRIT PFX "unexpected close: not stopping "
+		       "watchdog.\n");
+	chardev_users = 0;
+	return 0;
+}
+
+/*
+ * open watchdog device file: the test_and_set_bit enforces the fact
+ * that only one process opens the watchdog device file as long as it
+ * does not try to fork(2). dup(2)/dup2(2) might be problematic
+ * too. thus, we assume that watchdogd will do "The right thing" and
+ * won't try to do anything too fancy with the fd opened to
+ * /dev/watchdog.
+ */
+static int wdt_open(struct inode *inode, struct file *file)
+{
+	unsigned long flags;
+
+	if (test_and_set_bit(1, &chardev_users))
+		return -EBUSY;
+
+	expect_close = 0;
+
+	/*
+	 * watchdog is to be enabled when opened.
+	 */
+	if (!chardev_wdt->enabled) {
+		spin_lock_irqsave(&chardev_wdt->lock, flags);
+		chardev_wdt->enabled = 1;
+		chardev_wdt->countdown = default_countdown;
+		chardev_wdt->wdt_start(chardev_wdt);
+		chardev_wdt->countdown_min = INT_MAX;
+		spin_unlock_irqrestore(&chardev_wdt->lock, flags);
+	}
+	return 0;
+}
+
+static struct file_operations wdt_fops = {
+	.owner		= THIS_MODULE,
+	.open		= wdt_open,
+	.write		= wdt_write,
+	.unlocked_ioctl	= wdt_ioctl,
+	.release	= wdt_release,
+};
+
+static struct miscdevice wdt_miscdev = {
+	.minor		= WATCHDOG_MINOR,
+	.name		= "watchdog",
+	.fops		= &wdt_fops,
+};
+
+/*
+ * add watchdog to the char interface. if we are already bound to a
+ * watchdog, return 0, this is not a major no-no.
+ */
+int
+fbxwatchdog_char_add(struct fbxwatchdog *wdt)
+{
+	int err;
+
+	err = misc_register(&wdt_miscdev);
+	if (err) {
+		printk("unable to register misc device.\n");
+		if (err == -EEXIST)
+			return 0;
+		return err;
+	}
+	chardev_wdt = wdt;
+	return 0;
+}
+
+/*
+ * if the watchdog is bound to the char device interface, unregister
+ * the misc device and tell that we are no more bound to a
+ * watchdog. otherwise, do nothing.
+ */
+void
+fbxwatchdog_char_remove(struct fbxwatchdog *wdt)
+{
+	if (wdt != chardev_wdt)
+		return ;
+	misc_deregister(&wdt_miscdev);
+	chardev_wdt = NULL;
+}
+
+EXPORT_SYMBOL(fbxwatchdog_char_add);
+EXPORT_SYMBOL(fbxwatchdog_char_remove);
diff -Nruw linux-4.2.6-fbx/drivers/fbxwatchdog./fbxwatchdog_core.c linux-4.2.6-fbx/drivers/fbxwatchdog/fbxwatchdog_core.c
--- linux-4.2.6-fbx/drivers/fbxwatchdog./fbxwatchdog_core.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxwatchdog/fbxwatchdog_core.c	2015-11-02 18:59:16.988512183 +0100
@@ -0,0 +1,301 @@
+#include <linux/kernel.h>
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/reboot.h>
+#include <linux/timer.h>
+#include <linux/jiffies.h>
+#include <linux/slab.h>
+
+#include "fbxwatchdog.h"
+
+#define SOFTTIMER_FREQ	(HZ / 10)
+
+#define PFX "fbxwatchdog: "
+
+static struct class *fbxwatchdog_class;
+
+static ssize_t
+show_enabled(struct device *dev,
+	     struct device_attribute *attr, char *buf)
+{
+	struct fbxwatchdog *wdt;
+
+	wdt = dev_get_drvdata(dev);
+	if (!wdt) {
+		printk(KERN_DEBUG "ignoring request to dead watchdog.\n");
+		return -ENODEV;
+	}
+
+	return snprintf(buf, PAGE_SIZE, "%i\n", wdt->enabled);
+}
+
+/*
+ * start/stop watchdog depending on the value of the first character
+ * of buf. set countdown_min to a sane value.
+ */
+static ssize_t
+store_enabled(struct device *dev,
+	      struct device_attribute *attr, const char *buf, size_t size)
+{
+	struct fbxwatchdog *wdt;
+	unsigned long flags;
+
+	wdt = dev_get_drvdata(dev);
+	if (!wdt) {
+		printk(KERN_DEBUG "ignoring request to dead watchdog.\n");
+		return -ENODEV;
+	}
+
+	if (size == 0)
+		return 0;
+
+
+	spin_lock_irqsave(&wdt->lock, flags);
+	switch (*buf) {
+	case '0':
+		if (wdt->enabled) {
+			wdt->enabled = 0;
+			wdt->wdt_stop(wdt);
+		}
+		break;
+
+	case '1':
+		if (!wdt->enabled) {
+			wdt->enabled = 1;
+			wdt->wdt_start(wdt);
+			wdt->countdown_min = INT_MAX;
+		}
+		break;
+
+	default:
+		break;
+	}
+	spin_unlock_irqrestore(&wdt->lock, flags);
+
+	return size;
+}
+
+static ssize_t
+show_countdown(struct device *dev,
+	       struct device_attribute *attr, char *buf)
+{
+	struct fbxwatchdog *wdt;
+
+	wdt = dev_get_drvdata(dev);
+	if (!wdt) {
+		printk(KERN_DEBUG "ignoring request to dead watchdog.\n");
+		return -ENODEV;
+	}
+
+	return snprintf(buf, PAGE_SIZE, "%i\n", wdt->countdown);
+}
+
+/*
+ * update watchdog countdown with the userland value given in buf.
+ */
+static ssize_t
+store_countdown(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t size)
+{
+	struct fbxwatchdog *wdt;
+	int countdown;
+	char *ptr;
+
+	wdt = dev_get_drvdata(dev);
+	if (!wdt) {
+		printk(KERN_DEBUG "ignoring request to dead watchdog.\n");
+		return -ENODEV;
+	}
+
+	if (size == 0)
+		return 0;
+
+	ptr = kzalloc(size + 1, GFP_KERNEL);
+	if (!ptr)
+		return -ENOMEM;
+	strlcpy(ptr, buf, size + 1);
+
+	countdown = simple_strtoul(ptr, NULL, 10);
+	wdt->countdown = countdown;
+	kfree(ptr);
+
+	return size;
+}
+
+static ssize_t
+show_countdown_min(struct device *dev,
+		   struct device_attribute *attr, char *buf)
+{
+	struct fbxwatchdog *wdt;
+
+	wdt = dev_get_drvdata(dev);
+	if (!wdt) {
+		printk(KERN_DEBUG "ignoring request to dead watchdog.\n");
+		return -ENODEV;
+	}
+
+	return snprintf(buf, PAGE_SIZE, "%i\n", wdt->countdown_min);
+}
+
+static struct device_attribute wdt_attributes[] = {
+	__ATTR(enabled, 0600, show_enabled, store_enabled),
+	__ATTR(countdown, 0600, show_countdown, store_countdown),
+	__ATTR(countdown_min, 0400, show_countdown_min, NULL),
+};
+
+/*
+ * software timer callback: decrement countdown and update
+ * countdown_min if needed. this is called 10 times per second.
+ */
+static void fbxwatchdog_timer_cb(unsigned long data)
+{
+	struct fbxwatchdog *wdt;
+
+	wdt = (struct fbxwatchdog *)data;
+
+	if (wdt->enabled) {
+		wdt->countdown -= jiffies_to_msecs(SOFTTIMER_FREQ);
+		if (wdt->countdown < wdt->countdown_min)
+			wdt->countdown_min = wdt->countdown;
+	}
+
+	wdt->timer.expires = jiffies + SOFTTIMER_FREQ;
+	add_timer(&wdt->timer);
+}
+
+/*
+ * called from half life interrupt handler, panic if countdown is too
+ * low (ie if userland has not reset countdown to before it reached
+ * 0).
+ */
+static void fbxwatchdog_halflife_cb(struct fbxwatchdog *wdt)
+{
+	if (wdt->countdown <= 0) {
+		wdt->wdt_stop(wdt);
+		panic("software fbxwatchdog triggered");
+	}
+}
+
+/*
+ * register a new watchdog device.
+ */
+int fbxwatchdog_register(struct fbxwatchdog *wdt)
+{
+	struct device *dev;
+	int i = 0, err = 0;
+
+	if (wdt == NULL)
+		return -EFAULT;
+
+	printk(KERN_INFO PFX "registering watchdog %s\n", wdt->name);
+
+	dev = device_create(fbxwatchdog_class, NULL, 0, wdt, "%s", wdt->name);
+	if (IS_ERR(dev)) {
+		printk(KERN_ERR PFX "unable to allocate device.\n");
+		err = PTR_ERR(dev);
+		goto out_error;
+	}
+	wdt->dev = dev;
+
+	for (i = 0; i < ARRAY_SIZE(wdt_attributes); i++) {
+		err = device_create_file(dev, &wdt_attributes[i]);
+		if (err)
+			goto out_error;
+	}
+
+	/* start countdown soft timer */
+	init_timer(&wdt->timer);
+	wdt->timer.function = fbxwatchdog_timer_cb;
+	wdt->timer.data = (unsigned long)wdt;
+	wdt->timer.expires = jiffies + SOFTTIMER_FREQ;
+	add_timer(&wdt->timer);
+
+	spin_lock_init(&wdt->lock);
+
+	wdt->cb = fbxwatchdog_halflife_cb;
+	err = wdt->wdt_init(wdt);
+	if (err) {
+		printk(KERN_ERR PFX "unable to do low level init of "
+		       "watchdog %s.\n", wdt->name);
+		goto out_del_timer;
+	}
+
+#ifdef CONFIG_FREEBOX_WATCHDOG_CHAR
+	err = fbxwatchdog_char_add(wdt);
+	if (err) {
+		printk(KERN_ERR PFX "unable to add %s to the fbxwatchdog char "
+		       "device interface.\n", wdt->name);
+		goto out_wdt_cleanup;
+	}
+#endif
+
+	return 0;
+
+#ifdef CONFIG_FREEBOX_WATCHDOG_CHAR
+out_wdt_cleanup:
+	wdt->wdt_cleanup(wdt);
+#endif
+
+out_del_timer:
+	del_timer_sync(&wdt->timer);
+out_error:
+	if (wdt->dev) {
+		for (; i >= 0; i--)
+			device_remove_file(dev, &wdt_attributes[i]);
+		device_unregister(dev);
+	}
+	return err;
+}
+
+int fbxwatchdog_unregister(struct fbxwatchdog *wdt)
+{
+	int i;
+
+	printk(KERN_INFO PFX "registering watchdog %s\n", wdt->name);
+
+	if (wdt->enabled) {
+		unsigned long flags;
+
+		printk(KERN_WARNING "removing enabled watchdog.\n");
+		spin_lock_irqsave(&wdt->lock, flags);
+		wdt->wdt_stop(wdt);
+		spin_unlock_irqrestore(&wdt->lock, flags);
+	}
+
+#ifdef CONFIG_FREEBOX_WATCHDOG_CHAR
+	fbxwatchdog_char_remove(wdt);
+#endif
+	wdt->wdt_cleanup(wdt);
+	del_timer_sync(&wdt->timer);
+	for (i = 0; i < ARRAY_SIZE(wdt_attributes); i++)
+		device_remove_file(wdt->dev, &wdt_attributes[i]);
+	device_unregister(wdt->dev);
+	wdt->dev = NULL;
+	return 0;
+}
+
+static int __init fbxwatchdog_init(void)
+{
+	printk(KERN_INFO PFX "2007, Freebox SA.\n");
+	fbxwatchdog_class = class_create(THIS_MODULE, "fbxwatchdog");
+	if (IS_ERR(fbxwatchdog_class))
+		return PTR_ERR(fbxwatchdog_class);
+	return 0;
+}
+
+static void __exit fbxwatchdog_exit(void)
+{
+	class_destroy(fbxwatchdog_class);
+}
+
+
+EXPORT_SYMBOL_GPL(fbxwatchdog_register);
+EXPORT_SYMBOL_GPL(fbxwatchdog_unregister);
+
+module_init(fbxwatchdog_init);
+module_exit(fbxwatchdog_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Nicolas Schichan <nschichan@freebox.fr>");
+MODULE_DESCRIPTION("Freebox Watchdog Core - www.freebox.fr");
diff -Nruw linux-4.2.6-fbx/drivers/fbxwatchdog./fbxwatchdog.h linux-4.2.6-fbx/drivers/fbxwatchdog/fbxwatchdog.h
--- linux-4.2.6-fbx/drivers/fbxwatchdog./fbxwatchdog.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxwatchdog/fbxwatchdog.h	2015-11-02 18:59:16.988512183 +0100
@@ -0,0 +1,47 @@
+#ifndef FBXWATCHDOG_H
+# define FBXWATCHDOG_H
+
+struct fbxwatchdog {
+	const char *name;
+	void *priv;
+
+	int enabled;
+	int countdown;
+	int countdown_min;
+
+	int (*wdt_init)(struct fbxwatchdog *wdt);
+	int (*wdt_cleanup)(struct fbxwatchdog *wdt);
+
+	/*
+	 * wdt_start and wdt_stop are called with wdt->lock held and irq
+	 * disabled.
+	 */
+	int (*wdt_start)(struct fbxwatchdog *wdt);
+	int (*wdt_stop)(struct fbxwatchdog *wdt);
+
+	/*
+	 * cb is called from interrupt/softirq context (depends on the
+	 * underlying driver/hardware).
+	 */
+	void (*cb)(struct fbxwatchdog *wdt);
+
+	struct timer_list timer;
+
+	struct device *dev;
+
+	/*
+	 * protect interrupt handlers & start/stop methods running in
+	 * thead context.
+	 */
+	spinlock_t	lock;
+};
+
+int fbxwatchdog_register(struct fbxwatchdog *wdt);
+int fbxwatchdog_unregister(struct fbxwatchdog *wdt);
+
+#ifdef CONFIG_FREEBOX_WATCHDOG_CHAR
+int fbxwatchdog_char_add(struct fbxwatchdog *wdt);
+void fbxwatchdog_char_remove(struct fbxwatchdog *wdt);
+#endif
+
+#endif /* !FBXWATCHDOG_H */
diff -Nruw linux-4.2.6-fbx/drivers/fbxwatchdog./fbxwatchdog_orion.c linux-4.2.6-fbx/drivers/fbxwatchdog/fbxwatchdog_orion.c
--- linux-4.2.6-fbx/drivers/fbxwatchdog./fbxwatchdog_orion.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxwatchdog/fbxwatchdog_orion.c	2015-11-18 18:24:29.888149630 +0100
@@ -0,0 +1,303 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/timer.h>
+#include <linux/jiffies.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/clk.h>
+
+#include "fbxwatchdog.h"
+
+struct fbxwatchdog_orion_priv {
+	struct clk		*clk;
+	unsigned int		tclk;
+	void __iomem		*wdt_base;
+	void __iomem		*rstout_base;
+	struct timer_list	half_life_timer;
+};
+
+/*
+ * Watchdog timer block registers.
+ */
+#define RSTOUTn_MASK		(0x0108)
+#define TIMER_CTRL		(0x0000)
+#define  WDT_EN			0x0010
+#define WDT_COUNTER		(0x0024)
+
+#define WDT_MAX_CYCLE_COUNT	0xffffffff
+#define WDT_IN_USE		0
+#define WDT_OK_TO_CLOSE		1
+
+#define WDT_RESET_OUT_EN	BIT(1)
+
+static u32 read_rstout_mask(struct fbxwatchdog_orion_priv *priv)
+{
+	return readl(priv->rstout_base);
+}
+
+static void write_rstout_mask(struct fbxwatchdog_orion_priv *priv, u32 val)
+{
+	writel(val, priv->rstout_base);
+}
+
+static u32 read_wdt_timer_ctrl(struct fbxwatchdog_orion_priv *priv)
+{
+	return readl(priv->wdt_base + TIMER_CTRL);
+}
+
+static void write_wdt_timer_ctrl(struct fbxwatchdog_orion_priv *priv, u32 val)
+{
+	writel(val, priv->wdt_base + TIMER_CTRL);
+}
+
+static void write_wdt_counter(struct fbxwatchdog_orion_priv *priv, u32 val)
+{
+	writel(val, priv->wdt_base + WDT_COUNTER);
+}
+
+/*
+ * orion does not trigger interrupts each times the watchdog reaches
+ * the half of it's count down. we emulate this behaviour using a
+ * linux timer that fires every 500 msec.
+ */
+static void
+half_life_timer_cb(unsigned long data)
+{
+	struct fbxwatchdog *wdt;
+	struct fbxwatchdog_orion_priv *priv;
+	unsigned long flags;
+
+	wdt = (struct fbxwatchdog *)data;
+	priv = wdt->priv;
+
+	spin_lock_irqsave(&wdt->lock, flags);
+
+	/* reload counter */
+	write_wdt_counter(priv, priv->tclk * 10);
+
+	if (wdt->cb)
+		wdt->cb(wdt);
+
+	priv->half_life_timer.expires = jiffies + HZ / 2;
+	add_timer(&priv->half_life_timer);
+
+	spin_unlock_irqrestore(&wdt->lock, flags);
+}
+
+/*
+ * setup half life timer.
+ */
+static int orion_wdt_init(struct fbxwatchdog *wdt)
+{
+	struct fbxwatchdog_orion_priv *priv;
+
+	priv = wdt->priv;
+	init_timer(&priv->half_life_timer);
+	priv->half_life_timer.function = half_life_timer_cb;
+	priv->half_life_timer.data = (unsigned long)wdt;
+	return 0;
+}
+
+static int orion_wdt_cleanup(struct fbxwatchdog *wdt)
+{
+	return 0;
+}
+
+static int orion_wdt_start(struct fbxwatchdog *wdt)
+{
+	struct fbxwatchdog_orion_priv *priv;
+	uint32_t val;
+
+	dev_info(wdt->dev, "starting watchdog ...\n");
+
+	priv = wdt->priv;
+	val = read_wdt_timer_ctrl(priv);
+	if (val & WDT_EN) {
+		dev_warn(wdt->dev, "watchdog has been enabled by "
+			 "bootloader.!\n");
+		/* disable it */
+		val &= ~WDT_EN;
+		write_wdt_timer_ctrl(priv, val);
+	}
+
+	/* watchdog will blow up after 10 seconds if not refreshed */
+	write_wdt_counter(priv, priv->tclk * 10);
+
+	/* enable it */
+	val = read_wdt_timer_ctrl(priv);
+	val |= WDT_EN;
+	write_wdt_timer_ctrl(priv, val);
+
+	/* enable reset on watchdog */
+	val = read_rstout_mask(priv);
+	val |= WDT_RESET_OUT_EN;
+	write_rstout_mask(priv, val);
+
+	/* will fire every 500 ms */
+	priv->half_life_timer.expires = jiffies + HZ / 2;
+	add_timer(&priv->half_life_timer);
+
+	return 0;
+}
+
+int orion_wdt_stop(struct fbxwatchdog *wdt)
+{
+	struct fbxwatchdog_orion_priv *priv;
+	uint32_t val;
+
+	dev_info(wdt->dev, "stopping watchdog ...\n");
+
+	priv = wdt->priv;
+	del_timer_sync(&priv->half_life_timer);
+
+	/* disable it */
+	val = read_wdt_timer_ctrl(priv);
+	val &= ~WDT_EN;
+	write_wdt_timer_ctrl(priv, val);
+
+	/* disable reset on watchdog */
+	val = read_rstout_mask(priv);
+	val |= WDT_RESET_OUT_EN;
+	write_rstout_mask(priv, val);
+
+	return 0;
+}
+
+static int fbxwatchdog_platform_probe(struct platform_device *pdev)
+{
+	struct fbxwatchdog_orion_priv *priv = NULL;
+	struct fbxwatchdog *wdt;
+	struct clk *clk;
+	struct resource *r_wdt, *r_rstout;
+	int err = 0;
+
+	clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(clk)) {
+		dev_err(&pdev->dev, "Orion Watchdog missing clock\n");
+		return -ENODEV;
+	}
+	clk_prepare_enable(clk);
+
+	r_wdt = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	r_rstout = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+
+	if (!r_rstout || !r_wdt) {
+		dev_err(&pdev->dev, "Orion Watchdog missing resource.\n");
+		return -ENODEV;
+
+	}
+
+	wdt = devm_kzalloc(&pdev->dev, sizeof (*wdt), GFP_KERNEL);
+	if (!wdt) {
+		dev_err(&pdev->dev, "unable allocate memory for watchdog.\n");
+		err = -ENOMEM;
+		goto out_error;
+	}
+
+	priv = devm_kzalloc(&pdev->dev, sizeof (*priv), GFP_KERNEL);
+	if (!priv) {
+		dev_err(&pdev->dev, "unable to allocate memory for private "
+		       "structure.\n");
+		err = -ENOMEM;
+		goto out_error;
+	}
+
+	wdt->priv = priv;
+	wdt->name = pdev->name;
+
+	wdt->wdt_init = orion_wdt_init;
+	wdt->wdt_cleanup = orion_wdt_cleanup;
+	wdt->wdt_start = orion_wdt_start;
+	wdt->wdt_stop = orion_wdt_stop;
+
+	priv->wdt_base = devm_ioremap_resource(&pdev->dev, r_wdt);
+	if (!priv->wdt_base) {
+		dev_err(&pdev->dev, "unable to ioremap watchdog registers.");
+		err = -ENOMEM;
+		goto out_error;
+	}
+
+	priv->rstout_base = devm_ioremap_resource(&pdev->dev, r_rstout);
+	if (!priv->rstout_base) {
+		dev_err(&pdev->dev, "unable to ioremap rstou mask register.");
+		err = -ENOMEM;
+		goto out_error;
+	}
+
+	priv->tclk = clk_get_rate(clk);
+	priv->clk = clk;
+	dev_notice(&pdev->dev, "TCLK rate is %d Mhz.\n", priv->tclk / 1000000);
+
+
+	err = fbxwatchdog_register(wdt);
+	if (err) {
+		dev_err(&pdev->dev, "unable to register watchdog %s\n",
+			wdt->name);
+		goto out_error;
+	}
+
+	platform_set_drvdata(pdev, wdt);
+
+	return 0;
+
+ out_error:
+	clk_disable_unprepare(clk);
+	return err;
+}
+
+/*
+ * unregister and free memory allocated by the probe function.
+ */
+static int
+fbxwatchdog_platform_remove(struct platform_device *pdev)
+{
+	struct fbxwatchdog *wdt;
+	struct fbxwatchdog_orion_priv *priv;
+
+	wdt = platform_get_drvdata(pdev);
+	if (!wdt) {
+		BUG();
+		return -ENODEV;
+	}
+
+	fbxwatchdog_unregister(wdt);
+
+	priv = wdt->priv;
+	clk_disable_unprepare(priv->clk);
+
+	return 0;
+}
+
+static const struct of_device_id orion_fbxwdt_match_table[] = {
+	{ .compatible = "marvell,orion-fbxwdt" },
+	{},
+};
+
+struct platform_driver fbxwatchdog_platform_driver = {
+	.probe	= fbxwatchdog_platform_probe,
+	.remove	= fbxwatchdog_platform_remove,
+	.driver	= {
+		.name	= "orion_fbxwdt",
+		.of_match_table = orion_fbxwdt_match_table,
+	}
+};
+
+static int __init fbxwatchdog_orion_init(void)
+{
+	platform_driver_register(&fbxwatchdog_platform_driver);
+	return 0;
+}
+
+static void __exit fbxwatchdog_orion_exit(void)
+{
+	platform_driver_unregister(&fbxwatchdog_platform_driver);
+}
+
+module_init(fbxwatchdog_orion_init);
+module_exit(fbxwatchdog_orion_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Nicolas Schichan <nschichan@freebox.fr>");
+MODULE_DESCRIPTION("Freebox Watchdog, orion specific bits");
+
diff -Nruw linux-4.2.6-fbx/drivers/fbxwatchdog./Kconfig linux-4.2.6-fbx/drivers/fbxwatchdog/Kconfig
--- linux-4.2.6-fbx/drivers/fbxwatchdog./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxwatchdog/Kconfig	2015-11-02 18:59:53.192797586 +0100
@@ -0,0 +1,20 @@
+menuconfig FREEBOX_WATCHDOG
+	tristate "Freebox Watchdog"
+	default n
+
+if FREEBOX_WATCHDOG
+
+config FREEBOX_WATCHDOG_CHAR
+	bool "Freebox Watchdog char device interface."
+	default n
+
+config FREEBOX_WATCHDOG_ORION
+	tristate "Marvell Orion support"
+	depends on PLAT_ORION
+
+config FREEBOX_WATCHDOG_BCM63XX
+	tristate "Broadcom 63xx Freebox Watchdog support"
+	depends on BCM63XX
+	default n
+
+endif
diff -Nruw linux-4.2.6-fbx/drivers/fbxwatchdog./Makefile linux-4.2.6-fbx/drivers/fbxwatchdog/Makefile
--- linux-4.2.6-fbx/drivers/fbxwatchdog./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/fbxwatchdog/Makefile	2015-11-02 18:59:53.192797586 +0100
@@ -0,0 +1,9 @@
+obj-$(CONFIG_FREEBOX_WATCHDOG) += fbxwatchdog.o
+
+fbxwatchdog-objs = fbxwatchdog_core.o
+ifeq ($(CONFIG_FREEBOX_WATCHDOG_CHAR),y)
+fbxwatchdog-objs += fbxwatchdog_char.o
+endif
+
+obj-$(CONFIG_FREEBOX_WATCHDOG_ORION)	+= fbxwatchdog_orion.o
+obj-$(CONFIG_FREEBOX_WATCHDOG_BCM63XX)	+= fbxwatchdog_bcm63xx.o
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/drivers/hwmon/kirkwood-coretemp.c	2015-11-02 19:00:37.889149931 +0100
@@ -0,0 +1,168 @@
+/*
+ * kirkwood-coretemp.c for kirkwood-coretemp
+ * Created by <nschichan@freebox.fr> on Wed Jul 11 19:59:27 2012
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+
+#define PFX "kirkwood-coretemp: "
+
+struct kirkwood_coretemp_priv {
+	void __iomem *reg;
+	struct device *hwmon_dev;
+	struct attribute_group attrs;
+};
+
+static int show_kirkwood_coretemp(struct device *dev,
+				  struct device_attribute *devattr,
+				  char *buf)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct kirkwood_coretemp_priv *priv = platform_get_drvdata(pdev);
+	u32 reg;
+	u32 raw_temp;
+	s32 temp_out;
+
+	reg = readl(priv->reg);
+
+	/*
+	 * TermTValid shall be set.
+	 */
+	if ((reg & (1 << 9)) == 0)
+		return -EIO;
+
+	raw_temp = (reg >> 10) & 0x1ff;
+
+	/*
+	 * out temperature = (322 - raw) / 1.3625
+	 *
+	 * can't use float here, so be creative.
+	 *
+	 * we also have to avoid 32bit integer overflow (hence the
+	 * 1000000 / 1363 division instead of 10000000 / 13625)
+	 */
+	temp_out = (322 - raw_temp);
+	temp_out = (temp_out * 1000000) / 1363;
+
+	return sprintf(buf, "%i\n", temp_out);
+}
+
+static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_kirkwood_coretemp,
+			  NULL, 0);
+
+static int show_name(struct device *dev, struct device_attribute *devattr,
+		     char *buf)
+{
+	return sprintf(buf, "%s\n", kobject_name(&dev->kobj));
+}
+
+static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
+
+static struct attribute *kirkwood_coretemp_attr[] = {
+	&sensor_dev_attr_temp1_input.dev_attr.attr,
+	&dev_attr_name.attr,
+	NULL,
+};
+
+static int kirkwood_coretemp_probe(struct platform_device *pdev)
+{
+	struct kirkwood_coretemp_priv *priv;
+	struct resource *resource;
+	int err = 0;
+
+	dev_dbg(&pdev->dev, "probe.\n");
+
+	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!resource)
+		return -ENXIO;
+
+	priv = kzalloc(sizeof (*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->reg = ioremap(resource->start, resource_size(resource));
+	if (!priv->reg) {
+		dev_err(&pdev->dev, "unable to ioremap registers.\n");
+		err = -ENOMEM;
+		goto err_free_priv;
+	}
+
+	priv->attrs.attrs = kirkwood_coretemp_attr;
+	err = sysfs_create_group(&pdev->dev.kobj, &priv->attrs);
+	if (err) {
+		dev_err(&pdev->dev, "unable to greate sysfs group.\n");
+		goto err_iounmap;
+	}
+
+	platform_set_drvdata(pdev, priv);
+
+	priv->hwmon_dev = hwmon_device_register(&pdev->dev);
+	if (IS_ERR(priv->hwmon_dev)) {
+		dev_err(&pdev->dev, "unable to register hwmon device.\n");
+		err = PTR_ERR(priv->hwmon_dev);
+		goto err_sysfs_remove_group;
+	}
+
+
+	return 0;
+
+err_sysfs_remove_group:
+	sysfs_remove_group(&pdev->dev.kobj, &priv->attrs);
+err_iounmap:
+	iounmap(priv->reg);
+err_free_priv:
+	kfree(priv);
+	return err;
+}
+
+static int kirkwood_coretemp_remove(struct platform_device *pdev)
+{
+	struct kirkwood_coretemp_priv *priv = platform_get_drvdata(pdev);
+
+	dev_dbg(&pdev->dev, "remove.\n");
+	hwmon_device_unregister(priv->hwmon_dev);
+	sysfs_remove_group(&pdev->dev.kobj, &priv->attrs);
+	iounmap(priv->reg);
+	kfree(priv);
+
+	return 0;
+}
+
+static struct platform_driver kirkwood_coretemp_driver = {
+	.probe		= kirkwood_coretemp_probe,
+	.remove		= kirkwood_coretemp_remove,
+	.driver		= {
+		.name	= "kirkwood-coretemp",
+	}
+};
+
+static int __init kirkwood_coretemp_init(void)
+{
+	int err;
+
+	err = platform_driver_register(&kirkwood_coretemp_driver);
+	if (err) {
+		printk(KERN_ERR PFX "unable to register platform driver.\n");
+		return err;
+	}
+
+	return 0;
+}
+
+static void __exit kirkwood_coretemp_exit(void)
+{
+	platform_driver_unregister(&kirkwood_coretemp_driver);
+}
+
+module_init(kirkwood_coretemp_init);
+module_exit(kirkwood_coretemp_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Nicolas Schichan <nschichan@freebox.fr>");
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/drivers/input/misc/smsc_cap1066.c	2015-11-02 19:00:39.405161875 +0100
@@ -0,0 +1,1075 @@
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/input-polldev.h>
+#include <linux/smsc_cap1066.h>
+#include <linux/slab.h>
+#include <linux/gpio.h>
+
+#define PFX		"cap1066: "
+
+/*
+ * list of registers
+ */
+#define SMSC_REG_MAIN_CTRL		0x00
+#define SMSC_REG_BTN_STATUS1		0x03
+#define SMSC_REG_DATA_SENSITIVITY	0x1f
+#define SMSC_REG_CFG			0x20
+#define SMSC_REG_SENS_CFG		0x22
+#define SMSC_REG_MTOUCH_CFG_REG		0x2a
+#define SMSC_REG_CFG2			0x44
+#define SMSC_REG_LED_OUT_TYPE		0x71
+#define SMSC_REG_LED_LINK		0x72
+#define SMSC_REG_LED_OUTPUT_CTL		0x74
+#define SMSC_REG_LED_BEHAVIOUR1		0x81
+#define SMSC_REG_LED_BEHAVIOUR2		0x82
+#define SMSC_REG_LED_DIRECT_DCYCLE	0x93
+#define SMSC_REG_LED_DIRECT_RAMP_RATE	0x94
+#define SMSC_REG_LED_OFF_DELAY		0x95
+#define SMSC_REG_DID			0xfd
+#define SMSC_REG_VID			0xfe
+
+/*
+ * used in cap1066_init_hw and during priv initialization.
+ */
+#define DEFAULT_DUTY_CYCLE_MIN		0x4
+#define DEFAULT_DUTY_CYCLE_MAX		0xf
+#define DEFAULT_RAMP_TIME_FALL		0x1
+#define DEFAULT_RAMP_TIME_RISE		0x2
+
+/*
+ * vendor id / device id
+ */
+#define SMSC_CAP1066_VID	0x5d
+#define SMSC_CAP1066_DID	0x41
+#define SMSC_CAP1166_DID	0x51
+
+static const unsigned short normal_i2c[] = { 0x28, I2C_CLIENT_END };
+
+static const struct i2c_device_id cap1066_id[] = {
+	{ "cap1066", 0 },
+	{ }
+};
+
+/*
+ * private context
+ */
+static unsigned short default_map[CAP1066_MAX_BTNS] = {
+	BTN_0,
+	BTN_1,
+	BTN_2,
+	BTN_3,
+	BTN_4,
+	BTN_5,
+};
+
+struct led_btn_name
+{
+	int code;
+	const char *name;
+};
+
+/*
+ * whenever possible symlinks will be created from led_btn_X to
+ * led_key_y, depending on user provided keymap. add entries here as
+ * you see fit.
+ */
+static const struct led_btn_name led_btn_names[] = {
+	{ KEY_UP, "led_key_up", },
+	{ KEY_DOWN, "led_key_down", },
+	{ KEY_LEFT, "led_key_left", },
+	{ KEY_RIGHT, "led_key_right", },
+	{ KEY_ENTER, "led_key_enter", },
+};
+
+enum {
+	E_SMSC_CAP1066_LED_MODE_AUTO,
+	E_SMSC_CAP1066_LED_MODE_ON,
+	E_SMSC_CAP1066_LED_MODE_OFF,
+};
+
+struct cap1066_led_dev
+{
+	struct cap1066_priv	*parent_priv;
+	struct device		dev;
+	int			led_mode;
+	int			led_index;
+	const char		*btn_link;
+};
+
+struct cap1066_priv {
+	struct input_polled_dev *poll_dev;
+	struct i2c_client	*client;
+	unsigned short		keymap[CAP1066_MAX_BTNS];
+	struct cap1066_led_dev	*led_devices[CAP1066_MAX_BTNS];
+
+	u8			duty_cycle_min;
+	u8			duty_cycle_max;
+	u8			raw_ramp_time_fall;
+	u8			raw_ramp_time_rise;
+
+	bool			has_irq_gpio;
+	unsigned int		irq_gpio;
+};
+
+static const char *get_keycode_btn_name(int key_code)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(led_btn_names); ++i) {
+		if (key_code == led_btn_names[i].code)
+			return led_btn_names[i].name;
+	}
+	return NULL;
+}
+
+/*
+ * single register read
+ */
+static int cap1066_read_reg(struct i2c_client *client, u8 reg, u8 *val)
+{
+	int ret;
+
+	ret = i2c_smbus_read_byte_data(client, reg);
+	if (ret < 0) {
+		printk(KERN_ERR PFX "read failed: %d\n", ret);
+		return ret;
+	}
+
+	*val = (u8)ret;
+	return 0;
+}
+
+/*
+ * single register write
+ */
+static int cap1066_write_reg(struct i2c_client *client, u8 reg, u8 val)
+{
+	int ret;
+
+	ret = i2c_smbus_write_byte_data(client, reg, val);
+	if (ret < 0) {
+		printk(KERN_ERR PFX "write failed: %d\n", ret);
+		return ret;
+	}
+	return 0;
+}
+
+/*
+ * called when an smbus device is detected, make sure it's a cap1066
+ */
+static int cap1066_detect(struct i2c_client *client,
+			  struct i2c_board_info *info)
+
+{
+	int ret;
+	u8 vid, did;
+	const char *name = NULL;
+
+	ret = cap1066_read_reg(client, SMSC_REG_VID, &vid);
+	if (ret)
+		return ret;
+
+	ret = cap1066_read_reg(client, SMSC_REG_DID, &did);
+	if (ret)
+		return ret;
+
+	if (vid != SMSC_CAP1066_VID)
+		goto no_dev;
+
+	switch (did) {
+	case SMSC_CAP1066_DID:
+		name = "cap1066";
+		break;
+	case SMSC_CAP1166_DID:
+		name = "cap1166";
+		break;
+	default:
+		goto no_dev;
+	}
+
+	printk(KERN_INFO PFX "detected SMSC %s chip\n", name);
+	if (info)
+		strlcpy(info->type, name, I2C_NAME_SIZE);
+	return 0;
+
+no_dev:
+	printk(KERN_ERR PFX "bad vid/did: 0x%04x/0x%04x\n", vid, did);
+	return -ENODEV;
+}
+
+/*
+ * reset registers value
+ */
+static int cap1066_init_hw(struct i2c_client *client)
+{
+	unsigned int i;
+	u8 did;
+	int ret;
+
+	static const u8 init_regs[] = {
+		/* power on */
+		SMSC_REG_MAIN_CTRL, 0x0,
+
+		/* default sensitivity */
+		SMSC_REG_DATA_SENSITIVITY, 0x2f,
+
+		/* max duration */
+		SMSC_REG_SENS_CFG, 0xf4,
+
+		/* default configuration */
+		SMSC_REG_CFG, 0x38,
+
+		/* open drain output on all gpios */
+		SMSC_REG_LED_OUT_TYPE, 0x00,
+
+		/* link leds with sensors */
+		SMSC_REG_LED_LINK, 0x3f,
+
+		/* setup direct mode */
+		SMSC_REG_LED_BEHAVIOUR1, 0x00,
+		SMSC_REG_LED_BEHAVIOUR2, 0x00,
+
+		/* set led duty cycle min/max to 10% => 100% */
+		SMSC_REG_LED_DIRECT_DCYCLE,
+			(DEFAULT_DUTY_CYCLE_MAX << 4) |
+			(DEFAULT_DUTY_CYCLE_MIN),
+
+		/* set ramp rate time to 500ms/250ms */
+		SMSC_REG_LED_DIRECT_RAMP_RATE,
+			(DEFAULT_RAMP_TIME_RISE << 3) |
+			(DEFAULT_RAMP_TIME_FALL),
+	};
+
+	static const u8 init_cap11_regs[] = {
+		/* default configuration2 */
+		SMSC_REG_CFG2, 0x44,
+	};
+
+	for (i = 0; i < ARRAY_SIZE(init_regs); i += 2) {
+		int ret;
+
+		ret = cap1066_write_reg(client,
+					init_regs[i], init_regs[i + 1]);
+		if (ret)
+			return ret;
+	}
+
+	ret = cap1066_read_reg(client, SMSC_REG_DID, &did);
+	if (ret)
+		return ret;
+
+	if (did != SMSC_CAP1166_DID)
+		return 0;
+
+	for (i = 0; i < ARRAY_SIZE(init_cap11_regs); i += 2) {
+		int ret;
+
+		ret = cap1066_write_reg(client,
+					init_cap11_regs[i],
+					init_cap11_regs[i + 1]);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+/*
+ * input core poll callback
+ */
+static void cap1066_input_poll(struct input_polled_dev *dev)
+{
+	struct cap1066_priv *priv = dev->private;
+	struct input_dev *input = dev->input;
+	unsigned int i;
+	int ret;
+	u8 stat;
+
+	if (priv->has_irq_gpio) {
+		if (gpio_get_value(priv->irq_gpio))
+			return;
+	}
+
+	/* clear interrupt flag */
+	cap1066_write_reg(priv->client, SMSC_REG_MAIN_CTRL, 0);
+
+	ret = cap1066_read_reg(priv->client, SMSC_REG_BTN_STATUS1, &stat);
+	if (ret) {
+		printk(KERN_ERR PFX "unable to read status\n");
+		return;
+	}
+
+	for (i = 0; i < CAP1066_MAX_BTNS; i++)
+		input_report_key(input, priv->keymap[i],
+				 (stat & (1 << i)) ? 1 : 0);
+	input_sync(input);
+}
+
+#define to_cap1066_led_dev(Dev)	container_of(Dev, struct cap1066_led_dev, dev)
+
+/*
+ * called when all sysfs references to the cap1066_led_dev are gone.
+ */
+static void cap1066_led_dev_release(struct device *dev)
+{
+	struct cap1066_led_dev *led_dev;
+
+	led_dev = to_cap1066_led_dev(dev);
+	kfree(led_dev);
+}
+
+static int is_white(int c)
+{
+	return c == '\0' || c == ' ' || c == '\t' || c == '\n' || c == '\r';
+}
+
+/*
+ * store a new control value for a given cap1066_led_dev:
+ * - auto means that the led is linked to the capacitive keys
+ * - on means that the led is always on
+ * - off means that the led is always off
+ */
+static ssize_t store_control(struct device *dev,
+			     struct device_attribute *attr,
+			     const char *buf, size_t count)
+{
+	struct cap1066_led_dev *led_dev;
+	int new_mode;
+	int read_len = 0;
+	const char *end;
+	int key;
+	u8 reg;
+	struct i2c_client *client;
+	static const char *valid_keys[] = {
+		[E_SMSC_CAP1066_LED_MODE_AUTO] = "auto",
+		[E_SMSC_CAP1066_LED_MODE_ON] = "on",
+		[E_SMSC_CAP1066_LED_MODE_OFF] = "off",
+	};
+
+
+	led_dev = to_cap1066_led_dev(dev);
+	client = led_dev->parent_priv->client;
+
+	if (is_white(*buf))
+		/*
+		 * eat white spaces silently, upper layer will call us
+		 * again.
+		 */
+		return 1;
+
+	for (key = 0; key < ARRAY_SIZE(valid_keys); ++key) {
+		if (count < strlen(valid_keys[key]))
+			continue ;
+		if (!strncmp(buf, valid_keys[key], strlen(valid_keys[key]))) {
+			break;
+		}
+	}
+
+	if (key == ARRAY_SIZE(valid_keys)) {
+		/*
+		 * end of valid_keys array reached and nothing valid
+		 * was recognized.
+		 */
+		printk(KERN_ERR PFX "invalid control value.\n");
+		return -EINVAL;
+	}
+	new_mode = key;
+	read_len = strlen(valid_keys[key]);
+
+	/*
+	 * check that no garbage is present at end of input.
+	 */
+	end = buf + read_len;
+	if (end < buf + count && !is_white(*end)) {
+		/*
+		 * garbage at end of input.
+		 */
+		printk(KERN_ERR PFX "garbage at end of value for led "
+		       "control.\n");
+		return -EINVAL;
+	}
+
+	if (new_mode == led_dev->led_mode)
+		return read_len;
+
+	if (new_mode == E_SMSC_CAP1066_LED_MODE_AUTO) {
+		cap1066_read_reg(client, SMSC_REG_LED_LINK, &reg);
+		reg |= (1 << led_dev->led_index);
+		cap1066_write_reg(client, SMSC_REG_LED_LINK, reg);
+	} else {
+		cap1066_read_reg(client, SMSC_REG_LED_LINK, &reg);
+		reg &= ~(1 << led_dev->led_index);
+		cap1066_write_reg(client, SMSC_REG_LED_LINK, reg);
+
+		cap1066_read_reg(client, SMSC_REG_LED_OUTPUT_CTL, &reg);
+		if (new_mode == E_SMSC_CAP1066_LED_MODE_ON)
+			reg |= (1 << led_dev->led_index);
+		else
+			reg &= ~(1 << led_dev->led_index);
+		cap1066_write_reg(client, SMSC_REG_LED_OUTPUT_CTL, reg);
+	}
+	led_dev->led_mode = new_mode;
+
+	return read_len;
+}
+
+static ssize_t show_control(struct device *dev,
+			    struct device_attribute *attr, char *buf)
+{
+	struct cap1066_led_dev *led_dev;
+	const char *str;
+
+	led_dev = to_cap1066_led_dev(dev);
+	switch (led_dev->led_mode) {
+	case E_SMSC_CAP1066_LED_MODE_AUTO:
+		str = "auto";
+		break;
+
+	case E_SMSC_CAP1066_LED_MODE_ON:
+		str = "on";
+		break;
+
+	case E_SMSC_CAP1066_LED_MODE_OFF:
+		str = "off";
+		break;
+
+	default:
+		str = "invalid";
+		break;
+	}
+
+	return sprintf(buf, "%s\n", str);
+}
+
+static DEVICE_ATTR(control, S_IWUSR | S_IRUSR, show_control, store_control);
+
+static struct device_attribute *cap1066_led_dev_attrs[] = {
+	&dev_attr_control,
+};
+
+/*
+ * helper used to create all attributes given in the attr array.
+ *
+ * if something goes wrong during creation, remove attributes that
+ * have already been created.
+ */
+static int create_sysfs_files(struct device *dev,
+			      struct device_attribute **attrs,
+			      size_t count)
+{
+	int created;
+	int error = 0;
+
+	for (created = 0; created < count; ++created) {
+		error = device_create_file(dev, attrs[created]);
+		if (error)
+			break;
+	}
+
+	if (!error)
+		/*
+		 * no errors, can return.
+		 */
+		return 0;
+
+	/*
+	 * errors during creation, remove already created
+	 * files.
+	 */
+	while (--created >= 0)
+		device_remove_file(dev, attrs[created]);
+
+	return error;
+}
+
+/*
+ * create a led device. This will create a new directory in the sysfs
+ * base of the parent. a symlink will be created if a button name is
+ * found via get_keycode_btn_name().
+ */
+static struct cap1066_led_dev *cap1066_create_led_dev(struct device *parent,
+						      struct cap1066_priv *priv,
+						      int index, int key_code)
+{
+	struct cap1066_led_dev *dev;
+	int error = 0;
+
+	dev = kzalloc(sizeof (*dev), GFP_KERNEL);
+	if (!dev)
+		return NULL;
+
+	dev->led_index = index;
+	dev->parent_priv = priv;
+	dev_set_name(&dev->dev, "led_btn_%i", index);
+	dev->dev.release = cap1066_led_dev_release;
+	dev->dev.parent = parent;
+	if (device_register(&dev->dev) < 0) {
+		kfree(dev);
+		return NULL;
+	}
+
+	/*
+	 * create sysfs attributes.
+	 */
+	error = create_sysfs_files(&dev->dev, cap1066_led_dev_attrs,
+				   ARRAY_SIZE(cap1066_led_dev_attrs));
+	if (error) {
+		device_unregister(&dev->dev);
+		return NULL;
+	}
+
+	/*
+	 * create sysfs symlinks to friendly names, wherever possible.
+	 */
+	dev->btn_link = get_keycode_btn_name(key_code);
+	if (dev->btn_link) {
+		error = sysfs_create_link(&parent->kobj, &dev->dev.kobj,
+					  dev->btn_link);
+		if (error)
+			dev->btn_link = NULL;
+	}
+	return dev;
+}
+
+static void cap1066_remove_led_dev(struct cap1066_led_dev *dev)
+{
+	int i;
+
+	if (dev->btn_link)
+		sysfs_remove_link(&dev->dev.parent->kobj, dev->btn_link);
+
+	for (i = 0; i < ARRAY_SIZE(cap1066_led_dev_attrs); ++i)
+		device_remove_file(&dev->dev, cap1066_led_dev_attrs[i]);
+	device_unregister(&dev->dev);
+
+	/*
+	 * dev->release() kfree the cap1066_led_dev struct
+	 */
+}
+
+/*
+ * helper to exctract an unsigned long from the buffer given in
+ * parameter.
+ *
+ * first store buf in a zero terminated string and strtoul() it.
+ */
+static int get_ulong(const char *buf, size_t count, unsigned long *ret)
+{
+	char local_buf[32];
+	unsigned long val;
+	const char *end;
+
+	strncpy(local_buf, buf, min(count , sizeof (local_buf)));
+	local_buf[min(count, sizeof (local_buf) - 1)] = 0;
+
+	val = simple_strtoul(local_buf, (char**)&end, 0);
+	if (!is_white(*end))
+		/*
+		 * garbage after end of input.
+		 */
+		return -EINVAL;
+
+	*ret = val;
+
+	return 0;
+}
+
+/*
+ * duty cycle sysfs callbacks: things may not work as expected if
+ * duty_cycle_min is >= duty_cycle_max.
+ *
+ * values that can be written in duty_cycle_max/duty_cycle_min
+ * attributes can be on the range [0, 16 [.
+ *
+ * 0 means the lowest possible pwm duty cycle.
+ * 1 means the highest possible pwm duty cycle.
+ */
+
+static ssize_t store_duty_cycle_min(struct device *dev,
+				    struct device_attribute *attr,
+				    const char *buf, size_t count)
+{
+	unsigned long val;
+	struct i2c_client *client;
+	struct cap1066_priv *priv;
+	int error;
+	u8 reg;
+
+	client = to_i2c_client(dev);
+	priv = i2c_get_clientdata(client);
+
+	if (is_white(*buf))
+		return 1;
+
+	error = get_ulong(buf, count, &val);
+	if (error)
+		return error;
+
+	if (val > 0xf)
+		return -ERANGE;
+
+	cap1066_read_reg(client, SMSC_REG_LED_DIRECT_DCYCLE, &reg);
+	reg &= ~0xf;
+	reg |= val;
+	cap1066_write_reg(client, SMSC_REG_LED_DIRECT_DCYCLE, reg);
+
+	priv->duty_cycle_min = val;
+
+	pr_debug(PFX "store_duty_cycle_min: reg = 0x%02x\n", reg);
+	return count;
+}
+
+static ssize_t show_duty_cycle_min(struct device *dev,
+				   struct device_attribute *attr,
+				   char *buf)
+{
+	struct i2c_client *client;
+	struct cap1066_priv *priv;
+
+	client = to_i2c_client(dev);
+	priv = i2c_get_clientdata(client);
+
+	return sprintf(buf, "%u\n", priv->duty_cycle_min);
+}
+
+static ssize_t store_duty_cycle_max(struct device *dev,
+				    struct device_attribute *attr,
+				    const char *buf, size_t count)
+{
+	unsigned long val;
+	struct i2c_client *client;
+	struct cap1066_priv *priv;
+	int error;
+	u8 reg;
+
+	client = to_i2c_client(dev);
+	priv = i2c_get_clientdata(client);
+
+	if (is_white(*buf))
+		return 1;
+
+	error = get_ulong(buf, count, &val);
+	if (error)
+		return error;
+
+	if (val > 0xf)
+		return -ERANGE;
+
+	cap1066_read_reg(client, SMSC_REG_LED_DIRECT_DCYCLE, &reg);
+	reg &= ~0xf0;
+	reg |= val << 4;
+	cap1066_write_reg(client, SMSC_REG_LED_DIRECT_DCYCLE, reg);
+
+	priv->duty_cycle_max = val;
+
+	pr_debug(PFX "store_duty_cycle_max: reg = 0x%02x\n", reg);
+	return count;
+}
+
+static ssize_t show_duty_cycle_max(struct device *dev,
+				   struct device_attribute *attr,
+				   char *buf)
+{
+	struct i2c_client *client;
+	struct cap1066_priv *priv;
+
+	client = to_i2c_client(dev);
+	priv = i2c_get_clientdata(client);
+
+	return sprintf(buf, "%u\n", priv->duty_cycle_max);
+}
+
+/*
+ * convert millisecond value to a "raw" value ready to be written to
+ * the register.
+ */
+static u8 msec_to_raw_ramp_time(unsigned long msec)
+{
+	u8 ret;
+
+	if (msec <= 1500)
+		/*
+		 * register handles 250 msec increments if below 1500
+		 * msec.
+		 */
+		ret = msec / 250;
+	else
+		/*
+		 * there is no 1750 msec step, and 2000 msec is
+		 * encoded as 0x7.
+		 */
+		ret = 0x7;
+
+	return ret;
+}
+
+/*
+ * convert raw register value to a millisecond value.
+ */
+static unsigned long raw_ramp_time_to_msec(u8 raw)
+{
+	unsigned long ret;
+
+	if (raw < 7)
+		ret = 250 * raw;
+	else
+		ret = 2000;
+
+	return ret;
+}
+
+/*
+ * ramp time sysfs callbacks. delays are not reliable if programmed
+ * want time is higher than 1000 msec.
+ *
+ * values that can be written are on the range [0, 2000] and are given
+ * in milliseconds. Values higher than 2000 are clamped to 2000. shown
+ * values are rounded up to the next value supported by the hardware.
+ */
+
+static ssize_t store_ramp_time_rise(struct device *dev,
+				    struct device_attribute *attr,
+				    const char *buf, size_t count)
+{
+	unsigned long val;
+	u8 raw_val;
+	struct i2c_client *client;
+	struct cap1066_priv *priv;
+	int error;
+	u8 reg;
+
+	client = to_i2c_client(dev);
+	priv = i2c_get_clientdata(client);
+
+	if (is_white(*buf))
+		return 1;
+
+	error = get_ulong(buf, count, &val);
+	if (error)
+		return error;
+
+	raw_val = msec_to_raw_ramp_time(val);
+
+	cap1066_read_reg(client, SMSC_REG_LED_DIRECT_RAMP_RATE, &reg);
+	reg &= ~(0x7 << 3);
+	reg |= raw_val << 3;
+	cap1066_write_reg(client, SMSC_REG_LED_DIRECT_RAMP_RATE, reg);
+
+	priv->raw_ramp_time_rise = raw_val;
+
+	pr_debug(PFX "store_ramp_time_rise: reg = %02x\n", reg);
+	return count;
+}
+
+static ssize_t show_ramp_time_rise(struct device *dev,
+				   struct device_attribute *attr,
+				   char *buf)
+{
+	struct i2c_client *client;
+	struct cap1066_priv *priv;
+	unsigned long msec;
+
+	client = to_i2c_client(dev);
+	priv = i2c_get_clientdata(client);
+
+	msec = raw_ramp_time_to_msec(priv->raw_ramp_time_rise);
+
+	return sprintf(buf, "%lu\n", msec);
+}
+
+static ssize_t store_ramp_time_fall(struct device *dev,
+				    struct device_attribute *attr,
+				    const char *buf, size_t count)
+{
+	unsigned long val;
+	u8 raw_val;
+	struct i2c_client *client;
+	struct cap1066_priv *priv;
+	int error;
+	u8 reg;
+
+	client = to_i2c_client(dev);
+	priv = i2c_get_clientdata(client);
+
+	if (is_white(*buf))
+		return 1;
+
+	error = get_ulong(buf, count, &val);
+	if (error)
+		return error;
+
+	raw_val = msec_to_raw_ramp_time(val);
+
+	cap1066_read_reg(client, SMSC_REG_LED_DIRECT_RAMP_RATE, &reg);
+	reg &= ~0x7;
+	reg |= raw_val;
+	cap1066_write_reg(client, SMSC_REG_LED_DIRECT_RAMP_RATE, reg);
+
+	priv->raw_ramp_time_fall = raw_val;
+
+	pr_debug(PFX "store_ramp_time_rise: reg = %02x\n", reg);
+	return count;
+}
+
+static ssize_t show_ramp_time_fall(struct device *dev,
+				   struct device_attribute *attr,
+				   char *buf)
+{
+	struct i2c_client *client;
+	struct cap1066_priv *priv;
+	unsigned long msec;
+
+	client = to_i2c_client(dev);
+	priv = i2c_get_clientdata(client);
+
+	msec = raw_ramp_time_to_msec(priv->raw_ramp_time_fall);
+
+	return sprintf(buf, "%lu\n", msec);
+}
+
+#define MTOUCH_ENABLE		(1 << 7)
+#define MTOUCH_COUNT_MASK	(3 << 2)
+#define MTOUCH_COUNT_SHIFT	(2)
+
+/*
+ * touch limit handling: the hardware can report at most 1 to 4 key
+ * press event or no limit at all.
+ *
+ * Accepted values in touch_limit attribte:
+ * 0 -> no limit
+ * [1, 4] -> limit to the indicated count
+ * [4, +inf [ -> invalid
+ */
+static ssize_t store_touch_limit(struct device *dev,
+				 struct device_attribute *attr, const char *buf,
+				 size_t count)
+{
+	struct i2c_client *client;
+	unsigned long limit;
+	int err;
+	u8 mtouch_reg;
+
+	client = to_i2c_client(dev);
+
+	if (is_white(*buf))
+		return 1;
+
+	err = get_ulong(buf, count, &limit);
+	if (err)
+		return err;
+
+	if (limit > 4)
+		return -EINVAL;
+
+	if (limit == 0) {
+		mtouch_reg = 0;
+	} else {
+		mtouch_reg = MTOUCH_ENABLE |
+			((limit - 1) << MTOUCH_COUNT_SHIFT);
+	}
+	cap1066_write_reg(client, SMSC_REG_MTOUCH_CFG_REG, mtouch_reg);
+
+	return count;
+}
+
+static ssize_t show_touch_limit(struct device *dev,
+				struct device_attribute *attr,
+				char *buf)
+{
+	struct i2c_client *client;
+	u8 mtouch_reg;
+
+	client = to_i2c_client(dev);
+
+	cap1066_read_reg(client, SMSC_REG_MTOUCH_CFG_REG, &mtouch_reg);
+
+	if (mtouch_reg & MTOUCH_ENABLE) {
+		u8 count = (mtouch_reg & MTOUCH_COUNT_MASK) >>
+			MTOUCH_COUNT_SHIFT;
+		return sprintf(buf, "%d\n", count + 1);
+	} else {
+		return sprintf(buf, "0\n");
+	}
+}
+
+static DEVICE_ATTR(duty_cycle_min, S_IRUSR | S_IWUSR, show_duty_cycle_min,
+		   store_duty_cycle_min);
+
+static DEVICE_ATTR(duty_cycle_max, S_IRUSR | S_IWUSR, show_duty_cycle_max,
+		   store_duty_cycle_max);
+
+static DEVICE_ATTR(ramp_time_rise, S_IRUSR | S_IWUSR, show_ramp_time_rise,
+		   store_ramp_time_rise);
+
+static DEVICE_ATTR(ramp_time_fall, S_IRUSR | S_IWUSR, show_ramp_time_fall,
+		   store_ramp_time_fall);
+
+static DEVICE_ATTR(touch_limit, S_IWUSR | S_IRUSR, show_touch_limit,
+		   store_touch_limit);
+
+static struct device_attribute *cap1066_base_attributes[] = {
+	&dev_attr_duty_cycle_min,
+	&dev_attr_duty_cycle_max,
+	&dev_attr_ramp_time_rise,
+	&dev_attr_ramp_time_fall,
+	&dev_attr_touch_limit,
+};
+
+
+/*
+ * i2c core probe callback, called after sucessful detect
+ */
+static int cap1066_probe(struct i2c_client *client,
+			 const struct i2c_device_id *id)
+{
+	struct input_polled_dev *poll_dev;
+	struct input_dev *input;
+	struct cap1066_priv *priv;
+	int ret, i;
+
+	ret = cap1066_detect(client, NULL);
+	if (ret)
+		dev_warn(&client->dev, "unknown cap1x66 device.\n");
+
+	/* initialize controller */
+	ret = cap1066_init_hw(client);
+	if (ret)
+		return ret;
+
+	/* allocate context */
+	priv = kzalloc(sizeof (*priv), GFP_KERNEL);
+	poll_dev = input_allocate_polled_device();
+	if (!priv || !poll_dev) {
+		ret = -ENOMEM;
+		goto out_fail;
+	}
+
+	/*
+	 * must match what has been setup in cap1066_init_hw().
+	 */
+	priv->duty_cycle_min = DEFAULT_DUTY_CYCLE_MIN;
+	priv->duty_cycle_max = DEFAULT_DUTY_CYCLE_MAX;
+	priv->raw_ramp_time_rise = DEFAULT_RAMP_TIME_RISE;
+	priv->raw_ramp_time_fall = DEFAULT_RAMP_TIME_FALL;
+
+	if (client->dev.platform_data) {
+		struct smsc_cap1066_pdata *pdata;
+
+		pdata = client->dev.platform_data;
+		memcpy(priv->keymap, pdata->key_map, sizeof (pdata->key_map));
+		priv->has_irq_gpio = pdata->has_irq_gpio;
+		priv->irq_gpio = pdata->irq_gpio;
+	} else
+		memcpy(priv->keymap, default_map, sizeof (default_map));
+
+	if (priv->has_irq_gpio)
+		gpio_direction_input(priv->irq_gpio);
+
+	priv->poll_dev = poll_dev;
+	priv->client = client;
+
+	poll_dev->private = priv;
+	poll_dev->poll = cap1066_input_poll;
+	poll_dev->poll_interval = 50 /* ms */;
+
+	input = poll_dev->input;
+	input->name = "smsc_cap1066";
+	input->phys = "smsc_cap1066/input0";
+	input->id.bustype = BUS_I2C;
+	input->dev.parent = &client->dev;
+
+	input->keycode = priv->keymap;
+	input->keycodemax = ARRAY_SIZE(priv->keymap);
+	input->keycodesize = sizeof (unsigned short);
+
+	set_bit(EV_REP, input->evbit);
+	set_bit(EV_KEY, input->evbit);
+	for (i = 0; i < ARRAY_SIZE(priv->keymap); i++)
+		set_bit(priv->keymap[i], input->keybit);
+
+	i2c_set_clientdata(client, priv);
+
+	ret = input_register_polled_device(poll_dev);
+	if (ret)
+		goto out_fail;
+
+	for (i = 0; i < ARRAY_SIZE(priv->keymap); ++i) {
+		if (!priv->keymap[i])
+			continue;
+		priv->led_devices[i] =
+			cap1066_create_led_dev(&client->dev,
+					       priv, i, priv->keymap[i]);
+	}
+
+	if (create_sysfs_files(&client->dev, cap1066_base_attributes,
+			       ARRAY_SIZE(cap1066_base_attributes)) < 0)
+		goto out_free_led_devs;
+
+	return 0;
+
+out_free_led_devs:
+	for (i = 0; i < ARRAY_SIZE(priv->keymap); ++i)
+		if (priv->led_devices[i])
+			cap1066_remove_led_dev(priv->led_devices[i]);
+out_fail:
+	input_free_polled_device(poll_dev);
+	kfree(priv);
+	i2c_set_clientdata(client, NULL);
+	return ret;
+}
+
+/*
+ * i2c core remove callback
+ */
+static int cap1066_remove(struct i2c_client *client)
+{
+	int i;
+	struct cap1066_priv *priv = i2c_get_clientdata(client);
+
+	for (i = 0; i < ARRAY_SIZE(cap1066_base_attributes); ++i)
+		device_remove_file(&client->dev, cap1066_base_attributes[i]);
+
+	for (i = 0; i < ARRAY_SIZE(priv->keymap); ++i) {
+		if (priv->led_devices[i])
+			cap1066_remove_led_dev(priv->led_devices[i]);
+	}
+
+	input_unregister_polled_device(priv->poll_dev);
+	input_free_polled_device(priv->poll_dev);
+	kfree(priv);
+
+	return 0;
+}
+
+static struct i2c_driver cap1066_driver = {
+	.driver = {
+		.name	= "cap1066",
+	},
+	.probe		= cap1066_probe,
+	.remove		= cap1066_remove,
+	.id_table	= cap1066_id,
+
+	.detect		= cap1066_detect,
+	.class		= I2C_CLASS_HWMON,
+	.address_list	= normal_i2c,
+};
+
+static int __init cap1066_init(void)
+{
+	return i2c_add_driver(&cap1066_driver);
+}
+
+static void __exit cap1066_exit(void)
+{
+	i2c_del_driver(&cap1066_driver);
+}
+
+
+MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
+MODULE_DESCRIPTION("SMSC CAP1066 driver");
+MODULE_LICENSE("GPL");
+
+module_init(cap1066_init);
+module_exit(cap1066_exit);
diff -Nruw linux-4.2.6-fbx/drivers/media/platform/tango2./Kconfig linux-4.2.6-fbx/drivers/media/platform/tango2/Kconfig
--- linux-4.2.6-fbx/drivers/media/platform/tango2./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/media/platform/tango2/Kconfig	2015-11-02 19:00:34.261121325 +0100
@@ -0,0 +1,11 @@
+config DVB_TANGO2
+	tristate "Tango2 DVB adapter"
+	depends on ARCH_FBX5_B
+	select I2C
+	select I2C_ALGOBIT
+	select DVB_TDA1004X
+	select DVB_PLL
+
+config DVB_TANGO2_TESTBED
+	bool "extended testing and useful error codes"
+	depends on DVB_TANGO2
diff -Nruw linux-4.2.6-fbx/drivers/media/platform/tango2./Makefile linux-4.2.6-fbx/drivers/media/platform/tango2/Makefile
--- linux-4.2.6-fbx/drivers/media/platform/tango2./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/media/platform/tango2/Makefile	2015-11-02 19:00:34.261121325 +0100
@@ -0,0 +1,5 @@
+obj-$(CONFIG_DVB_TANGO2) = tango2_dvb.o
+
+tango2_dvb-objs := tango2.o
+
+EXTRA_CFLAGS = -Idrivers/media/dvb-core/ -Idrivers/media/dvb-frontends/
diff -Nruw linux-4.2.6-fbx/drivers/misc/hdmi-cec./Kconfig linux-4.2.6-fbx/drivers/misc/hdmi-cec/Kconfig
--- linux-4.2.6-fbx/drivers/misc/hdmi-cec./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/misc/hdmi-cec/Kconfig	2015-11-02 19:00:25.385051364 +0100
@@ -0,0 +1,15 @@
+menu "HDMI CEC support"
+
+config HDMI_CEC
+	tristate "HDMI CEC (Consumer Electronics Control) support"
+	---help---
+	   HDMI Consumer Electronics Control support.
+
+config HDMI_CEC_REMOTI
+	tristate "RemoTI CEC driver"
+	depends on HDMI_CEC
+	select REMOTI
+	---help---
+	   HDMI CEC driver using RemoTI IPCs.
+
+endmenu
diff -Nruw linux-4.2.6-fbx/drivers/misc/hdmi-cec./Makefile linux-4.2.6-fbx/drivers/misc/hdmi-cec/Makefile
--- linux-4.2.6-fbx/drivers/misc/hdmi-cec./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/misc/hdmi-cec/Makefile	2015-11-02 19:00:25.385051364 +0100
@@ -0,0 +1,6 @@
+obj-$(CONFIG_HDMI_CEC)		+= hdmi-cec.o
+hdmi-cec-objs			+= core.o dev.o
+
+# drivers
+obj-$(CONFIG_HDMI_CEC_REMOTI)	+= remoti-cec.o
+remoti-cec-objs			:= remoti.o
diff -Nruw linux-4.2.6-fbx/drivers/misc/remoti./Kconfig linux-4.2.6-fbx/drivers/misc/remoti/Kconfig
--- linux-4.2.6-fbx/drivers/misc/remoti./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/misc/remoti/Kconfig	2015-11-02 19:00:24.929047769 +0100
@@ -0,0 +1,26 @@
+menu "RemoTI support"
+
+config REMOTI
+	tristate "RemoTI support"
+	depends on FBX6HD
+	---help---
+	  Texas Instruments RemoTI stack.
+
+config REMOTI_LEDS
+	tristate "RemoTI LEDS support"
+	depends on REMOTI
+	depends on LEDS_CLASS
+	---help---
+	  RemoTI LEDS class driver support.
+
+config REMOTI_GPIO
+	tristate "RemoTI gpio support"
+	depends on REMOTI
+	---help---
+	  gpiochip driver for the RemoTI RNP
+
+config REMOTI_USER
+	tristate "RemoTI userspace access"
+	depends on REMOTI
+
+endmenu
diff -Nruw linux-4.2.6-fbx/drivers/misc/remoti./Makefile linux-4.2.6-fbx/drivers/misc/remoti/Makefile
--- linux-4.2.6-fbx/drivers/misc/remoti./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/misc/remoti/Makefile	2015-11-02 19:00:24.929047769 +0100
@@ -0,0 +1,9 @@
+obj-$(CONFIG_REMOTI)		+= remoti.o
+obj-$(CONFIG_REMOTI_GPIO)	+= remoti-gpio.o
+obj-$(CONFIG_REMOTI_LEDS)	+= remoti-leds.o
+obj-$(CONFIG_REMOTI_USER)	+= remoti-user.o
+
+remoti-objs			:= core.o core-sysfs.o
+remoti-gpio-objs		:= gpio.o
+remoti-leds-objs		:= leds.o
+remoti-user-objs		:= user.o
diff -Nruw linux-4.2.6-fbx/drivers/net/ethernet/sigma./Kconfig linux-4.2.6-fbx/drivers/net/ethernet/sigma/Kconfig
--- linux-4.2.6-fbx/drivers/net/ethernet/sigma./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/ethernet/sigma/Kconfig	2015-11-18 18:24:31.308160900 +0100
@@ -0,0 +1,21 @@
+#
+# Marvell device configuration
+#
+
+config NET_VENDOR_SIGMA
+	bool "Sigma Design devices"
+	default y
+	depends on TANGO2
+
+if NET_VENDOR_SIGMA
+
+config TANGO2_ENET
+	tristate "SMP863x Builtin Ethernet support"
+	select MII
+	select CRC32
+	help
+	 This option adds support for the SMP863x integrated Ethernet
+	 controller.  This driver uses NAPI and generic Linux MII
+	 support.
+
+endif # NET_VENDOR_SIGMA
diff -Nruw linux-4.2.6-fbx/drivers/net/ethernet/sigma./Makefile linux-4.2.6-fbx/drivers/net/ethernet/sigma/Makefile
--- linux-4.2.6-fbx/drivers/net/ethernet/sigma./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/ethernet/sigma/Makefile	2015-11-18 18:24:31.308160900 +0100
@@ -0,0 +1 @@
+obj-$(CONFIG_TANGO2_ENET) += tango2_enet/tango2_enet.o
diff -Nruw linux-4.2.6-fbx/drivers/net/ethernet/wintegra./Kconfig linux-4.2.6-fbx/drivers/net/ethernet/wintegra/Kconfig
--- linux-4.2.6-fbx/drivers/net/ethernet/wintegra./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/ethernet/wintegra/Kconfig	2015-11-02 19:00:36.241136940 +0100
@@ -0,0 +1,10 @@
+config NET_VENDOR_WINTEGRA
+	bool
+
+config WINTEGRA_WINPATH3_ETH
+	tristate "Wintegra Winpath3 internal mac support"
+	depends on WINTEGRA_WINPATH3
+	select NET_VENDOR_WINTEGRA
+	select NET_CORE
+	select MII
+	select PHYLIB
diff -Nruw linux-4.2.6-fbx/drivers/net/ethernet/wintegra./Makefile linux-4.2.6-fbx/drivers/net/ethernet/wintegra/Makefile
--- linux-4.2.6-fbx/drivers/net/ethernet/wintegra./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/net/ethernet/wintegra/Makefile	2015-11-02 19:00:36.241136940 +0100
@@ -0,0 +1 @@
+obj-$(CONFIG_WINTEGRA_WINPATH3_ETH) += wp3_eth.o
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/drivers/net/wireless/mwl8k_max_hostif.h	2015-04-14 01:43:56.747528585 +0200
@@ -0,0 +1,53 @@
+#ifndef HOSTIF_H_
+#define HOSTIF_H_
+
+#ifndef __KERNEL__
+/*
+ * map to linux kernel types for easier sharing
+ */
+#include "linux_types.h"
+#endif
+
+/*
+ * device => host IRQ
+ */
+#define IRQ_D2H_VUART	(1 << 0)
+
+/*
+ * IX ZONE
+ */
+#define IXZONE_MAGIC	0x2cc4189b
+
+enum {
+	IXZONE_VUART,
+};
+
+struct ixzone_root {
+	__le32		magic;
+	__le32		node_count;
+};
+
+struct ixzone_node {
+	__le32		type;
+
+	/* relative to root */
+	__le32		off;
+};
+
+struct vuart_ixzone {
+	__le32		buf_offset;
+	__le32		buf_size;
+
+	/*
+	 * 'fw' & 'host' are relative (0 < val < buf_size)
+	 *
+	 * firmware increments 'fw', host increments 'host',
+	 *
+	 * (fw == host) => buffer is empty
+	 * (fw == host - 1) => buffer is full
+	 */
+	__le32		fw;
+	__le32		host;
+};
+
+#endif /* ! HOSTIF_H_ */
diff -Nruw linux-4.2.6-fbx/drivers/platform/intelce./Kconfig linux-4.2.6-fbx/drivers/platform/intelce/Kconfig
--- linux-4.2.6-fbx/drivers/platform/intelce./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/platform/intelce/Kconfig	2015-11-02 19:00:19.825007528 +0100
@@ -0,0 +1,18 @@
+#
+# IntelCE devices configuration
+#
+
+menu "IntelCE devices"
+
+config INTELCE_GPIO
+	tristate "GPIO support"
+	select ARCH_REQUIRE_GPIOLIB
+	---help---
+	  IntelCE 3100/4100 GPIO support.
+
+config INTELCE_DFX
+	tristate "DFX reporting support"
+	---help---
+	  IntelCE 3100/4100 DFX fuse reporting support.
+
+endmenu
diff -Nruw linux-4.2.6-fbx/drivers/platform/intelce./Makefile linux-4.2.6-fbx/drivers/platform/intelce/Makefile
--- linux-4.2.6-fbx/drivers/platform/intelce./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/platform/intelce/Makefile	2015-11-02 19:00:19.829007553 +0100
@@ -0,0 +1,2 @@
+obj-$(CONFIG_INTELCE_GPIO)	+= gpio-intelce.o
+obj-$(CONFIG_INTELCE_DFX)	+= dfx.o
diff -Nruw linux-4.2.6-fbx/drivers/platform/tango2./Kconfig linux-4.2.6-fbx/drivers/platform/tango2/Kconfig
--- linux-4.2.6-fbx/drivers/platform/tango2./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/platform/tango2/Kconfig	2015-11-02 19:00:32.817109939 +0100
@@ -0,0 +1,30 @@
+#
+# TANGO2 devices configuration
+#
+
+menu "Tango2 devices"
+	depends on TANGO2
+
+config TANGO2_FIP
+	tristate "Front panel support"
+	select INPUT
+	---help---
+	  Tango2 FIP front panel support.
+
+config TANGO2_GPIO
+	tristate "GPIO sysfs support"
+	---help---
+	  Export GPIO attributes in sysfs.
+
+config TANGO2_IR
+	tristate "IR support"
+	---help---
+	  Tango2 IR (NEC/RC5/RC6) support.
+
+config TANGO2_FB
+	tristate "Framebuffer support"
+	depends on FB
+	---help---
+	  Tango2 framebuffer support.
+
+endmenu
diff -Nruw linux-4.2.6-fbx/drivers/platform/tango2./Makefile linux-4.2.6-fbx/drivers/platform/tango2/Makefile
--- linux-4.2.6-fbx/drivers/platform/tango2./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/drivers/platform/tango2/Makefile	2015-11-02 19:00:32.817109939 +0100
@@ -0,0 +1,6 @@
+# Makefile for the TANGO2 device drivers
+
+obj-$(CONFIG_TANGO2_FIP) += fip.o
+obj-$(CONFIG_TANGO2_GPIO) += gpio.o
+obj-$(CONFIG_TANGO2_IR) += ir.o
+obj-$(CONFIG_TANGO2_FB) += fb.o
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/drivers/spi/orion_tdm_spi.c	2015-11-18 18:24:32.080167023 +0100
@@ -0,0 +1,613 @@
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/orion_tdm_spi.h>
+#include <linux/gpio.h>
+#include <linux/clk.h>
+#include <asm/unaligned.h>
+
+#define DRIVER_NAME			"orion_tdm_spi"
+
+/*
+ * registers
+ */
+#define PCM_CTRL_REG			0x0000
+#define PCM_DAA_CSS_CTRL_MASK		(1 << 15)
+
+#define SPI_CLK_PRESCALE_REG		0x3100
+#define SCLOCK_LOW_SHIFT		0
+#define SCLOCK_LOW_MASK			(0xff << SCLOCK_LOW_SHIFT)
+#define SCLOCK_HIGH_SHIFT		8
+#define SCLOCK_HIGH_MASK		(0xff << SCLOCK_HIGH_SHIFT)
+
+#define SPI_GLOBAL_CTRL_REG		0x3104
+#define CODEC_ENABLE_MASK		(1 << 0)
+
+#define SPI_CTRL_REG			0x3108
+#define SPI_STAT_MASK			(1 << 10)
+
+#define SPI_CODEC_ACCESS_L_REG		0x3130
+#define ACCESS_BYTE0_SHIFT		0
+#define ACCESS_BYTE1_SHIFT		8
+
+#define SPI_CODEC_ACCESS_H_REG		0x3134
+#define ACCESS_BYTE2_SHIFT		0
+#define ACCESS_BYTE3_SHIFT		8
+
+#define SPI_REG_ACCESS_CTRL_REG		0x3138
+#define BYTES_TO_XFER_MASK		0x3
+#define SPI_LSB_MSB_MASK		(1 << 2)
+#define SPI_RD_WR_MASK			(1 << 3)
+#define SPI_BYTES_TO_READ_SHIFT		4
+#define SPI_LO_SPEED_CLK_MASK		(1 << 5)
+#define SPI_READ_CS_HOLD_SHIFT		6
+
+#define SPI_READ_DATA_REG		0x313c
+
+#define SPI_REG_ACCESS_CTRL1_REG	0x3140
+#define SPI_WRITE_CS_HOLD_SHIFT		0
+
+#define SPI_OUT_EN_CTRL_REG		0x4000
+#define SPI_OUT_EN_DISABLE_MASK		(1 << 0)
+
+
+struct orion_tdm_spi {
+	struct spi_master		*master;
+	void __iomem			*base;
+
+	unsigned int			max_speed;
+	unsigned int			min_speed;
+
+	/* current configured speed/divs for each CS, drivers uses "low"
+	 * for CS0 and "high" for CS1 */
+	unsigned int			speeds[2];
+	u32				divs[2];
+
+	unsigned int			current_cs;
+	struct orion_tdm_spi_info	*spi_info;
+	struct clk			*clk;
+};
+
+MODULE_ALIAS("platform:" DRIVER_NAME);
+
+static inline u32 spi_readl(struct orion_tdm_spi *priv, u32 reg)
+{
+	u32 val;
+
+	val = readl(priv->base + reg);
+/* 	printk("spi_readl: readl at %08x => 0x%08x\n", */
+/* 	       priv->base + reg, val); */
+	return val;
+}
+
+static inline void spi_writel(struct orion_tdm_spi *priv, u32 val, u32 reg)
+{
+/* 	printk("spi_writl: writl at %08x <= 0x%08x\n", */
+/* 	       priv->base + reg, val); */
+	writel(val, priv->base + reg);
+}
+
+static int spi_baudrate_set(struct orion_tdm_spi *priv,
+			    unsigned int cs, unsigned int speed)
+{
+	u32 tclk_hz;
+	u32 div, val;
+
+	if (priv->speeds[cs] == speed)
+		return 0;
+
+	tclk_hz = clk_get_rate(priv->clk);
+
+	/* find divider, the supported values are: 2...254 (even only) */
+	div = DIV_ROUND_UP(tclk_hz, speed);
+	div = roundup(div, 2);
+
+	if (div > 254)
+		return 1;
+
+	if (div < 2)
+		div = 2;
+
+	/* don't reprogram div if not needed */
+	if (priv->divs[cs] == div) {
+		priv->speeds[cs] = speed;
+		return 0;
+	}
+
+	/* Convert the rate to SPI clock divisor value.	*/
+	val = spi_readl(priv, SPI_CLK_PRESCALE_REG);
+	if (cs) {
+		val &= ~SCLOCK_HIGH_MASK;
+		val |= div << SCLOCK_HIGH_SHIFT;
+	} else {
+		val &= ~SCLOCK_LOW_MASK;
+		val |= div << SCLOCK_LOW_SHIFT;
+	}
+	spi_writel(priv, val, SPI_CLK_PRESCALE_REG);
+
+	priv->speeds[cs] = speed;
+	priv->divs[cs] = div;
+	return 0;
+}
+
+static void spi_set_cs(struct orion_tdm_spi *priv, struct spi_device *spi,
+		       int active)
+{
+	struct orion_tdm_spi_info *spi_info;
+	int gpio;
+
+	spi_info = priv->spi_info;
+
+	/* set correct cs in hardware */
+	if (spi->chip_select != priv->current_cs) {
+		u32 val;
+
+		val = spi_readl(priv, PCM_CTRL_REG);
+		if (spi->chip_select)
+			val |= PCM_DAA_CSS_CTRL_MASK;
+		else
+			val &= ~PCM_DAA_CSS_CTRL_MASK;
+		spi_writel(priv, val, PCM_CTRL_REG);
+		priv->current_cs = spi->chip_select;
+	}
+
+	/* if not using gpio, hardware moves cs for us */
+	gpio = spi_info->cs_use_gpio[priv->current_cs];
+	if (gpio == -1)
+		return;
+
+	gpio_set_value(gpio, 1 - active);
+}
+
+static int do_spi_poll(struct orion_tdm_spi *priv)
+{
+	unsigned int loop;
+	u32 val;
+
+	for (loop = 0; loop < 1000; loop++) {
+		val = spi_readl(priv, SPI_CTRL_REG);
+		if (!(val & SPI_STAT_MASK))
+			return 0;
+	}
+	return 1;
+}
+
+static int do_write_read(struct orion_tdm_spi *priv, struct spi_device *spi,
+			 const u8 *tx, unsigned int tx_len,
+			 u8 *rx, unsigned int rx_len)
+{
+	u32 val;
+
+	if (do_spi_poll(priv)) {
+		dev_err(&spi->dev, "spi_poll timed out\n");
+		return 1;
+	}
+
+	val = tx[0];
+	if (tx_len > 1)
+		val |= tx[1] << 8;
+	spi_writel(priv, val, SPI_CODEC_ACCESS_L_REG);
+
+	if (tx_len > 2) {
+		val = tx[2];
+		if (tx_len > 3)
+			val |= tx[3] << 8;
+		spi_writel(priv, val, SPI_CODEC_ACCESS_H_REG);
+	}
+
+
+	val = tx_len - 1;
+	if (rx_len)
+		val |= SPI_RD_WR_MASK;
+	if (rx_len > 1)
+		val |= (1 << SPI_BYTES_TO_READ_SHIFT);
+	if (spi->chip_select) {
+		/* note: bit set to 1 => use high speed */
+		val |= SPI_LO_SPEED_CLK_MASK;
+	}
+	spi_writel(priv, val, SPI_REG_ACCESS_CTRL_REG);
+
+	val = spi_readl(priv, SPI_CTRL_REG);
+	val |= SPI_STAT_MASK;
+	spi_writel(priv, val, SPI_CTRL_REG);
+
+	if (do_spi_poll(priv)) {
+		dev_err(&spi->dev, "spi_poll timed out\n");
+		return 1;
+	}
+
+	if (rx_len) {
+		val = spi_readl(priv, SPI_READ_DATA_REG);
+		rx[0] = val & 0xff;
+		if (rx_len > 1)
+			rx[1] = (val >> 8) & 0xff;
+	}
+
+	return 0;
+}
+
+static int orion_tdm_spi_setup(struct spi_device *spi)
+{
+	struct orion_tdm_spi *priv;
+
+	priv = spi_master_get_devdata(spi->master);
+
+	if (spi->bits_per_word == 0)
+		spi->bits_per_word = 8;
+
+	if (spi->bits_per_word != 8) {
+		dev_err(&spi->dev, "setup: unsupported transfer width %u\n",
+			spi->bits_per_word);
+		return -EINVAL;
+	}
+
+	if ((spi->max_speed_hz == 0) ||
+	    (spi->max_speed_hz > priv->max_speed))
+		spi->max_speed_hz = priv->max_speed;
+
+	if (spi->max_speed_hz < priv->min_speed) {
+		dev_err(&spi->dev, "setup: requested speed too low %d Hz\n",
+			spi->max_speed_hz);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int orion_tdm_spi_transfer(struct spi_device *spi,
+				  struct spi_message *m)
+{
+	struct orion_tdm_spi *priv;
+	struct spi_transfer *t;
+	int want_write, cs_active;
+
+	m->actual_length = 0;
+	m->status = 0;
+
+/* 	printk("orion_tdm_spi_transfer for device speed %u\n", */
+/* 		spi->max_speed_hz); */
+
+	/* reject invalid messages and transfers */
+	if (list_empty(&m->transfers) || !m->complete)
+		return -EINVAL;
+
+	priv = spi_master_get_devdata(spi->master);
+
+	/*
+	 * first pass for sanity check
+	 *
+	 * hardware  is  dumb,  and   can't  read/write  at  the  same
+	 * time. Worst, you have to write at least one byte to be able
+	 * to read, and you can't not read more than two bytes.
+	 */
+	want_write = 0;
+
+	list_for_each_entry(t, &m->transfers, transfer_list) {
+
+		if (!t->len)
+			continue;
+
+		if (t->tx_buf && t->rx_buf) {
+			dev_err(&spi->dev,
+				"message rejected : "
+				"full duplex transfer not supported\n");
+			m->status = -ENOTSUPP;
+			goto msg_done;
+		}
+
+		if (!t->tx_buf && !t->rx_buf && t->len) {
+			dev_err(&spi->dev,
+				"message rejected : "
+				"invalid transfer data buffers\n");
+			m->status = -EINVAL;
+			goto msg_done;
+		}
+
+		/* check if forced transfer width is valid */
+		if (t->bits_per_word && t->bits_per_word != 8) {
+			dev_err(&spi->dev,
+				"message rejected : "
+				"invalid transfer bits_per_word (%d bits)\n",
+				t->bits_per_word);
+			m->status = -EINVAL;
+			goto msg_done;
+		}
+
+		/* check if forced transfer speed if ok */
+		if (t->speed_hz && t->speed_hz < priv->min_speed) {
+			dev_err(&spi->dev,
+				"message rejected : "
+				"device min speed (%d Hz) exceeds "
+				"required transfer speed (%d Hz)\n",
+				priv->min_speed, t->speed_hz);
+			m->status = -EINVAL;
+			goto msg_done;
+		}
+
+		if (t->tx_buf)
+			want_write += t->len;
+		if (t->rx_buf) {
+			if (t->len > 2) {
+				dev_err(&spi->dev,
+					"message rejected : "
+					"marvell dumb spi can't read "
+					"more than 2 bytes\n");
+				m->status = -EINVAL;
+				goto msg_done;
+
+			}
+
+			if (want_write)
+				want_write = 0;
+			else {
+				dev_err(&spi->dev,
+					"message rejected : "
+					"marvell dumb spi can't read "
+					"without write first\n");
+				m->status = -EINVAL;
+				goto msg_done;
+			}
+		}
+	}
+
+/* 	printk("SPI CS\n"); */
+	spi_set_cs(priv, spi, 0);
+	cs_active = 0;
+
+	/* do the actual transfer, we need to coalesce write and read
+	 * transfer */
+	list_for_each_entry(t, &m->transfers, transfer_list) {
+		unsigned int i, speed;
+
+		if (!t->len)
+			continue;
+
+		/* get and configure speed for this transfer */
+		if (t->speed_hz)
+			speed = t->speed_hz;
+		else
+			speed = spi->max_speed_hz;
+
+		if (spi_baudrate_set(priv, spi->chip_select, speed)) {
+			m->status = -EINVAL;
+			goto msg_done;
+		}
+
+		/* write always one byte, if this is the last byte to
+		 * transfer, lookahead next transfer and read if
+		 * needed */
+		BUG_ON(!t->tx_buf);
+
+		for (i = 0; i < t->len;) {
+			struct spi_transfer *nt;
+			u8 *rx;
+			const u8 *tx;
+			unsigned int rx_len, tx_remain;
+
+			rx = NULL;
+			nt = NULL;
+			rx_len = 0;
+
+			tx_remain = t->len - i;
+			if (tx_remain == 1) {
+				struct list_head *e;
+
+				/* last byte to write, check if next
+				 * transfer is a read and coalesce */
+				e = t->transfer_list.next;
+				if (e != &m->transfers) {
+					nt = list_entry(e, struct spi_transfer,
+							transfer_list);
+					if (nt->rx_buf) {
+						rx = nt->rx_buf;
+						rx_len = nt->len;
+					} else
+						nt = NULL;
+				}
+			}
+
+			/* we can write 4 bytes at a time if not
+			 * reading */
+			if (tx_remain > 4)
+				tx_remain = 4;
+			else {
+				/* make sure we leave at least one
+				 * byte in case we need to coalesce
+				 * with next read */
+				if (tx_remain > 1)
+					tx_remain--;
+			}
+			tx = t->tx_buf + i;
+
+			if (!cs_active) {
+				spi_set_cs(priv, spi, 1);
+				cs_active = 1;
+			}
+
+			if (do_write_read(priv, spi, tx, tx_remain,
+					  rx, rx_len)) {
+				m->status = -EIO;
+				goto msg_done;
+			}
+
+			if (t->cs_change) {
+				spi_set_cs(priv, spi, 0);
+				cs_active = 0;
+			}
+
+			m->actual_length += tx_remain + rx_len;
+
+			/* skip next transfer if we coalesced it */
+			if (nt) {
+				t = nt;
+				break;
+			}
+
+			i += tx_remain;
+		}
+
+		if (t->delay_usecs)
+			udelay(t->delay_usecs);
+	}
+
+	if (cs_active)
+		spi_set_cs(priv, spi, 0);
+
+msg_done:
+	if (m->complete)
+		m->complete(m->context);
+	return m->status;
+}
+
+static int orion_tdm_spi_info_from_of(struct device *dev,
+				      struct orion_tdm_spi_info **out)
+{
+	int err;
+	uint32_t arr[2];
+
+	err = of_property_read_u32_array(dev->of_node, "fbx,cs-gpios", arr,
+					 ARRAY_SIZE(arr));
+	if (err)
+		return err;
+
+	*out = devm_kzalloc(dev, sizeof (**out), GFP_KERNEL);
+	if (!*out)
+		return -ENOMEM;
+
+	(*out)->cs_use_gpio[0] = arr[0];
+	(*out)->cs_use_gpio[1] = arr[1];
+
+	dev_dbg(dev, "cs gpio[0] = %d\n", (*out)->cs_use_gpio[0]);
+	dev_dbg(dev, "cs gpio[1] = %d\n", (*out)->cs_use_gpio[1]);
+	return 0;
+}
+
+static int __init orion_tdm_spi_probe(struct platform_device *pdev)
+{
+	struct spi_master *master;
+	struct orion_tdm_spi *priv;
+	struct resource *r;
+	struct orion_tdm_spi_info *spi_info;
+	unsigned int tclk_hz;
+	int status = 0;
+	u32 val;
+
+	spi_info = pdev->dev.platform_data;
+
+	if (!spi_info && !pdev->dev.of_node)
+		return -ENODEV;
+
+	if (!spi_info) {
+		int err = orion_tdm_spi_info_from_of(&pdev->dev, &spi_info);
+
+		if (err)
+			return err;
+	}
+
+	master = spi_alloc_master(&pdev->dev, sizeof (*priv));
+	if (master == NULL) {
+		dev_dbg(&pdev->dev, "master allocation failed\n");
+		return -ENOMEM;
+	}
+
+	if (pdev->id != -1)
+		master->bus_num = pdev->id;
+
+	master->setup = orion_tdm_spi_setup;
+	master->transfer = orion_tdm_spi_transfer;
+	master->num_chipselect = 2;
+	master->mode_bits = 0;
+
+	dev_set_drvdata(&pdev->dev, master);
+
+	priv = spi_master_get_devdata(master);
+	priv->master = master;
+	priv->spi_info = spi_info;
+
+	priv->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(priv->clk)) {
+		dev_err(&pdev->dev, "no associated clk\n");
+		status = PTR_ERR(priv->clk);
+		goto out;
+	}
+
+	clk_prepare_enable(priv->clk);
+	tclk_hz = clk_get_rate(priv->clk);
+	priv->max_speed = DIV_ROUND_UP(tclk_hz, 4);
+	priv->min_speed = DIV_ROUND_UP(tclk_hz, 254);
+	priv->current_cs = ~0;
+
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (r == NULL) {
+		status = -ENODEV;
+		goto out_clk;
+	}
+	priv->base = devm_ioremap_resource(&pdev->dev, r);
+	if (!priv->base) {
+		status = -ENOMEM;
+		goto out_clk;
+	}
+
+	/* configure TDM SPI */
+	val = spi_readl(priv, SPI_OUT_EN_CTRL_REG);
+	val &= ~SPI_OUT_EN_DISABLE_MASK;
+	spi_writel(priv, val, SPI_OUT_EN_CTRL_REG);
+
+	val = spi_readl(priv, SPI_GLOBAL_CTRL_REG);
+	val |= CODEC_ENABLE_MASK;
+	spi_writel(priv, val, SPI_GLOBAL_CTRL_REG);
+
+	master->dev.of_node = pdev->dev.of_node;
+	status = spi_register_master(master);
+	if (status < 0)
+		goto out_clk;
+
+	return status;
+
+out_clk:
+	clk_disable_unprepare(priv->clk);
+
+out:
+	spi_master_put(master);
+	return status;
+}
+
+static int __exit orion_tdm_spi_remove(struct platform_device *pdev)
+{
+	struct spi_master *master;
+	struct orion_tdm_spi *priv;
+
+	master = dev_get_drvdata(&pdev->dev);
+	priv = spi_master_get_devdata(master);
+
+	clk_disable_unprepare(priv->clk);
+	spi_unregister_master(master);
+
+	return 0;
+}
+
+static const struct of_device_id orion_tdm_spi_match_table[] = {
+	{ .compatible = "marvell,orion-tdm-spi", .data = NULL },
+	{},
+};
+
+static struct platform_driver orion_tdm_spi_driver = {
+	.driver = {
+		.name	= DRIVER_NAME,
+		.owner	= THIS_MODULE,
+		.of_match_table = orion_tdm_spi_match_table,
+	},
+	.remove		= __exit_p(orion_tdm_spi_remove),
+	.probe		= orion_tdm_spi_probe,
+};
+
+module_platform_driver(orion_tdm_spi_driver);
+
+MODULE_DESCRIPTION("Orion TDM SPI driver");
+MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
+MODULE_LICENSE("GPL");
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/drivers/video/ssd1327.c	2015-11-02 18:59:43.188718730 +0100
@@ -0,0 +1,700 @@
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/sched.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/ssd1327.h>
+#include <linux/workqueue.h>
+#include <linux/gpio.h>
+#include <linux/fb.h>
+#include <linux/platform_device.h>
+#include <linux/uaccess.h>
+#include <linux/vmalloc.h>
+#include <linux/backlight.h>
+
+/*
+ * commands
+ */
+#define OPCODE_CONTRAST		0x81
+
+#define OPCODE_SET_COLUMN	0x15
+#define OPCODE_SET_ROW		0x75
+#define OPCODE_SET_REMAP	0xa0
+#define OPCODE_DISPLAY_NORMAL	0xa4
+#define OPCODE_DISPLAY_ALL_ON	0xa5
+#define OPCODE_DISPLAY_ALL_OFF	0xa6
+
+#define OPCODE_DISPLAY_OFF	0xae
+#define OPCODE_DISPLAY_ON	0xaf
+
+#define OPCODE_DEF_GRAY		0xb9
+
+#define SSD1327_MAX_BRIGHTNESS		0x81
+#define SSD1327_NOMINAL_BRIGHTNESS	0x64
+
+/*
+ * fbinfo
+ */
+static struct fb_fix_screeninfo ssd1327_fb_fix = {
+	.id		= "ssd1327",
+	.type		= FB_TYPE_PACKED_PIXELS,
+	.visual		= FB_VISUAL_STATIC_PSEUDOCOLOR,
+	.xpanstep	= 0,
+	.ypanstep	= 1,
+	.ywrapstep	= 0,
+	.accel		= FB_ACCEL_NONE,
+};
+
+static struct fb_var_screeninfo ssd1327_fb_var = {
+	.bits_per_pixel	= 8,
+	.grayscale	= 1,
+	.nonstd		= 1,
+	.red.length	= 8,
+	.green.length	= 8,
+	.blue.length	= 8,
+};
+
+/*
+ * private data
+ */
+#define SSD1327_COLS		64
+#define SSD1327_ROWS		128
+#define GDDRAM_SIZE		SSD1327_COLS * SSD1327_ROWS
+
+struct ssd1327 {
+	struct mutex			mutex;
+
+	/* image of display ram */
+	u8				gddram[GDDRAM_SIZE];
+	u8				old_gddram[GDDRAM_SIZE];
+
+	/* data ram, 8 bits per pixel */
+	u8				*vmem;
+	unsigned int			vmem_size;
+
+	struct fb_info			*fb;
+	struct ssd1327_platform_data	*data;
+	struct spi_device		*spi;
+
+	struct backlight_device		*backlight;
+	unsigned int			brightness;
+
+	/* watchog timer */
+	struct delayed_work		wtd_work;
+	unsigned int			wtd_max;
+	atomic_t			wtd_count;
+};
+
+/*
+ * send command to device
+ */
+static int send_cmd(struct ssd1327 *priv, u8 cmd)
+{
+	struct ssd1327_platform_data *data;
+	int ret;
+
+	data = priv->spi->dev.platform_data;
+
+	mutex_lock(&priv->mutex);
+	gpio_set_value(data->data_select_gpio, 0);
+	ret = spi_write_then_read(priv->spi, &cmd, 1, NULL, 0);
+	mutex_unlock(&priv->mutex);
+	return ret;
+}
+
+/*
+ * send command list to device
+ */
+static int send_cmds(struct ssd1327 *priv, const u8 *cmd, unsigned int len)
+{
+	unsigned int i;
+	int ret;
+
+	for (i = 0; i < len; i++) {
+		ret = send_cmd(priv, cmd[i]);
+		if (ret < 0)
+			return ret;
+	}
+	return 0;
+}
+
+/*
+ * write given data into device gddram
+ */
+static int write_data(struct ssd1327 *priv, u8 *tx, unsigned int size)
+{
+	struct ssd1327_platform_data *data;
+	int ret;
+
+	data = priv->spi->dev.platform_data;
+
+	mutex_lock(&priv->mutex);
+	gpio_set_value(data->data_select_gpio, 1);
+	ret = spi_write(priv->spi, tx, size);
+	mutex_unlock(&priv->mutex);
+	return ret;
+}
+
+/*
+ * soft reset & initialize ssd1327
+ */
+static int ssd1327_init(struct ssd1327 *priv)
+{
+	const u8 init_cmds[] = { OPCODE_DISPLAY_ON,
+
+				 /* set even/odd splitting */
+				 OPCODE_SET_REMAP, (1 << 6),
+				 OPCODE_CONTRAST, SSD1327_NOMINAL_BRIGHTNESS,
+				 OPCODE_DEF_GRAY,
+				 OPCODE_DISPLAY_NORMAL,
+	};
+	int ret;
+
+	/* zero ram */
+	ret = write_data(priv, priv->gddram, GDDRAM_SIZE);
+	if (ret)
+		return ret;
+
+	return send_cmds(priv, init_cmds, sizeof (init_cmds));
+}
+
+/*
+ * update area
+ */
+static int ssd1327_fb_update(struct ssd1327 *priv)
+{
+	unsigned int col, row, w, h, i, count;
+	unsigned char *vmem;
+	u8 *start;
+	u8 ccmds[3] = { OPCODE_SET_COLUMN, 0, 0x3f };
+	u8 rcmds[3] = { OPCODE_SET_ROW, 0, 0x7f };
+	int toggle, last_toggle_pos, moved;
+
+	w = priv->data->width;
+	h = priv->data->height;
+
+	/* backup previous gddram */
+	memcpy(priv->old_gddram, priv->gddram, GDDRAM_SIZE);
+
+	vmem = priv->vmem + w * priv->fb->var.yoffset;
+
+	for (row = 0; row < SSD1327_ROWS; row++) {
+
+		if (row >= h)
+			break;
+
+		for (col = 0; col < SSD1327_COLS; col++) {
+			unsigned int nibble;
+			u8 val;
+
+			val = 0;
+			for (nibble = 0; nibble < 2; nibble++) {
+				unsigned int off, x;
+				u8 vval;
+
+				x = col * 2 + nibble;
+				if (x >= w)
+					break;
+
+				switch (priv->fb->var.rotate) {
+				case 0:
+				default:
+					off = row * w + x;
+					break;
+
+				case 180:
+					off = w * h - (row * w + x) - 1;
+					break;
+
+				case 90:
+					off = (w - x - 1) * w + row;
+					break;
+
+				case 270:
+					off = x * w + (h - row - 1);
+					break;
+				}
+
+				vval = vmem[off] >> 4;
+				val |= vval << (nibble * 4);
+			}
+
+			priv->gddram[row * SSD1327_COLS + col] = val;
+		}
+	}
+
+	/* count consecutive toggled bytes, each column/row address
+	 * change adds 6 bytes to send  */
+	moved = toggle = 0;
+	last_toggle_pos = -INT_MAX;
+	count = 0;
+	for (i = 0; i < GDDRAM_SIZE; i++) {
+		if (priv->gddram[i] ^ priv->old_gddram[i]) {
+			/* if crossing column boundary and first
+			 * address is not 0, we must send column
+			 * command */
+			if (moved && ((i % SSD1327_COLS) == 0)) {
+				count += 3;
+				moved = 0;
+			}
+
+			if (!toggle) {
+				if (i - last_toggle_pos < 6) {
+					unsigned int j;
+
+					/* fake last columns as dirty,
+					 * cheaper than repositionning
+					 * cursor */
+					for (j = last_toggle_pos; j < i; j++)
+						priv->old_gddram[j] =
+							~priv->gddram[j];
+
+					count += i - last_toggle_pos - 1;
+				} else {
+					/* send command to change
+					 * address & column */
+					count += 6;
+
+					/* if we changed first column address
+					 * to non 0, remember it */
+					if ((i % SSD1327_COLS))
+						moved = 1;
+					else
+						moved = 0;
+				}
+			}
+
+			toggle = 1;
+			count++;
+
+		} else {
+			if (toggle)
+				last_toggle_pos = i - 1;
+			toggle = 0;
+		}
+	}
+
+	/* force full gddram update if we would send more bytes
+	 * using clever update */
+	if (count > GDDRAM_SIZE)
+		return write_data(priv, priv->gddram, GDDRAM_SIZE);
+
+	moved = toggle = 0;
+	count = 0;
+	start = NULL;
+	for (i = 0; i < GDDRAM_SIZE; i++) {
+
+		if (priv->gddram[i] ^ priv->old_gddram[i]) {
+			/* if crossed column boundary and first
+			 * address is not 0, we must send command to
+			 * reset column*/
+			if (moved && ((i % SSD1327_COLS) == 0)) {
+				write_data(priv, start, count);
+				start += count;
+				count = 0;
+				ccmds[1] = 0;
+				send_cmds(priv, ccmds, 3);
+				moved = 0;
+			}
+
+			if (!toggle) {
+				ccmds[1] = i % SSD1327_COLS;
+				rcmds[1] = i / SSD1327_COLS;
+				send_cmds(priv, ccmds, 3);
+				send_cmds(priv, rcmds, 3);
+
+				/* if we changed first column address
+				 * to non 0, remember it */
+				if ((i % SSD1327_COLS))
+					moved = 1;
+				else
+					moved = 0;
+				start = &priv->gddram[i];
+			}
+
+			count++;
+			toggle = 1;
+
+		} else {
+			if (count) {
+				write_data(priv, start, count);
+				count = 0;
+			}
+			toggle = 0;
+		}
+	}
+
+	if (count)
+		write_data(priv, start, count);
+
+	/* reset position */
+	ccmds[1] = 0;
+	send_cmds(priv, ccmds, 3);
+	rcmds[1] = 0;
+	send_cmds(priv, rcmds, 3);
+	return 0;
+}
+
+/*
+ * frame buffer fill rect callback
+ */
+static void ssd1327_fb_fillrect(struct fb_info *info,
+				const struct fb_fillrect *rect)
+{
+	struct ssd1327 *priv = info->par;
+	sys_fillrect(info, rect);
+	atomic_set(&priv->wtd_count, priv->wtd_max);
+	ssd1327_fb_update(priv);
+}
+
+/*
+ * frame buffer copy area callback
+ */
+static void ssd1327_fb_copyarea(struct fb_info *info,
+				const struct fb_copyarea *area)
+{
+	struct ssd1327 *priv = info->par;
+	sys_copyarea(info, area);
+	atomic_set(&priv->wtd_count, priv->wtd_max);
+	ssd1327_fb_update(priv);
+}
+
+/*
+ * frame buffer image blit
+ */
+static void ssd1327_fb_imageblit(struct fb_info *info,
+				 const struct fb_image *image)
+{
+	struct ssd1327 *priv = info->par;
+	sys_imageblit(info, image);
+	atomic_set(&priv->wtd_count, priv->wtd_max);
+	ssd1327_fb_update(priv);
+}
+
+/*
+ * frame buffer pan callback
+ */
+static int ssd1327_fb_pan(struct fb_var_screeninfo *var, struct fb_info *info)
+{
+	struct ssd1327 *priv = info->par;
+	priv->fb->var.xoffset = var->xoffset;
+	priv->fb->var.yoffset = var->yoffset;
+	atomic_set(&priv->wtd_count, priv->wtd_max);
+	ssd1327_fb_update(priv);
+	return 0;
+}
+
+/*
+ * fram buffer set_par callback, set videomode
+ */
+static int ssd1327_fb_set_par(struct fb_info *info)
+{
+	struct ssd1327 *priv = info->par;
+	/* called after rotate update */
+	atomic_set(&priv->wtd_count, priv->wtd_max);
+	ssd1327_fb_update(priv);
+	return 0;
+}
+
+static int ssd1327_fb_check_var(struct fb_var_screeninfo *var,
+				struct fb_info *info)
+{
+	unsigned int rotate;
+
+	rotate = var->rotate;
+	if (rotate != 0 && rotate != 90 && rotate != 180 && rotate != 270)
+		rotate = 0;
+	*var = info->var;
+	var->rotate = rotate;
+	return 0;
+}
+
+/*
+ * frame buffer blank callback
+ */
+static int ssd1327_fb_blank(int blank, struct fb_info *info)
+{
+	return 0;
+}
+
+/*
+ * frame buffer write from userspace
+ */
+static ssize_t ssd1327_fb_write(struct fb_info *info, const char __user *buf,
+				size_t count, loff_t *ppos)
+{
+	struct ssd1327 *priv = info->par;
+	unsigned long p = *ppos;
+	void *dst;
+	int err = 0;
+	unsigned long total_size;
+
+	if (info->state != FBINFO_STATE_RUNNING)
+		return -EPERM;
+
+	total_size = info->fix.smem_len;
+
+	if (p > total_size)
+		return -EFBIG;
+
+	if (count > total_size) {
+		err = -EFBIG;
+		count = total_size;
+	}
+
+	if (count + p > total_size) {
+		if (!err)
+			err = -ENOSPC;
+
+		count = total_size - p;
+	}
+
+	dst = (void __force *)(info->screen_base + p);
+
+	if (copy_from_user(dst, buf, count))
+		err = -EFAULT;
+
+	if  (!err)
+		*ppos += count;
+
+	atomic_set(&priv->wtd_count, priv->wtd_max);
+	ssd1327_fb_update(priv);
+
+	return (err) ? err : count;
+}
+
+static struct fb_ops ssd1327_fb_ops = {
+	.owner		= THIS_MODULE,
+	.fb_write	= ssd1327_fb_write,
+	.fb_fillrect	= ssd1327_fb_fillrect,
+	.fb_copyarea	= ssd1327_fb_copyarea,
+	.fb_imageblit	= ssd1327_fb_imageblit,
+	.fb_pan_display	= ssd1327_fb_pan,
+	.fb_blank	= ssd1327_fb_blank,
+	.fb_check_var	= ssd1327_fb_check_var,
+	.fb_set_par	= ssd1327_fb_set_par,
+};
+
+/*
+ * watchdog timer
+ */
+static void wtd_work_cb(struct work_struct *t)
+{
+	struct ssd1327 *priv;
+	struct delayed_work *dwork;
+
+	dwork = container_of(t, struct delayed_work, work);
+	priv = container_of(dwork, struct ssd1327, wtd_work);
+
+	if (atomic_dec_and_test(&priv->wtd_count)) {
+		dev_err(&priv->spi->dev, "watchdog triggered\n");
+		memset(priv->vmem, 0, priv->vmem_size);
+		ssd1327_fb_update(priv);
+	}
+
+	schedule_delayed_work(&priv->wtd_work, HZ);
+}
+
+/*
+ * backlight control
+ */
+static int ssd1327_bl_update_status(struct backlight_device *bl)
+{
+	struct ssd1327 *priv;
+	u8 bl_cmds[2];
+	int ret;
+
+	priv = bl_get_data(bl);
+
+	bl_cmds[0] = OPCODE_CONTRAST;
+	bl_cmds[1] = bl->props.brightness;
+
+	ret = send_cmds(priv, bl_cmds, sizeof (bl_cmds));
+	if (ret < 0)
+		return ret;
+	priv->brightness = bl->props.brightness;
+	return 0;
+}
+
+static int ssd1327_bl_get_brightness(struct backlight_device *bl)
+{
+	struct ssd1327 *priv;
+	priv = bl_get_data(bl);
+	return priv->brightness;
+}
+
+static struct backlight_ops ssd1327_bl_ops = {
+	.update_status		= ssd1327_bl_update_status,
+	.get_brightness		= ssd1327_bl_get_brightness,
+};
+
+static const struct backlight_properties ssd1327_bl_props = {
+	.power		= FB_BLANK_UNBLANK,
+	.fb_blank	= FB_BLANK_UNBLANK,
+	.max_brightness	= SSD1327_MAX_BRIGHTNESS,
+	.type		= BACKLIGHT_RAW,
+};
+
+static int init_backlight(struct ssd1327 *priv)
+{
+	struct backlight_device *bl;
+
+	bl = backlight_device_register("ssd1327", &priv->spi->dev,
+				       priv, &ssd1327_bl_ops,
+				       &ssd1327_bl_props);
+	if (IS_ERR(bl)) {
+		dev_err(&priv->spi->dev, "error %ld on backlight register\n",
+			PTR_ERR(bl));
+		return PTR_ERR(bl);
+	}
+	priv->backlight = bl;
+	bl->props.brightness = priv->brightness;
+	return 0;
+}
+
+/*
+ * platform device probe callback
+ */
+static int ssd1327_probe(struct spi_device *spi)
+{
+	struct ssd1327 *priv;
+	struct ssd1327_platform_data *data;
+	struct fb_info *fb;
+	int ret;
+
+	data = spi->dev.platform_data;
+	if (!data) {
+		dev_err(&spi->dev, "no screen description\n");
+		return -ENODEV;
+	}
+
+	/* sanity check on screen size */
+	if (data->width > SSD1327_COLS * 2 ||
+	    data->height > SSD1327_ROWS) {
+		dev_err(&spi->dev, "unsupported screen dimension\n");
+		return -ENODEV;
+	}
+
+	fb = framebuffer_alloc(sizeof (*priv), &spi->dev);
+	if (!fb)
+		return -ENOMEM;
+	priv = fb->par;
+	mutex_init(&priv->mutex);
+	priv->spi = spi;
+	priv->data = data;
+	priv->fb = fb;
+	priv->brightness = SSD1327_NOMINAL_BRIGHTNESS;
+	priv->wtd_max = data->watchdog;
+
+	/* setup framebuffer */
+	fb->fbops = &ssd1327_fb_ops;
+	fb->flags = FBINFO_FLAG_DEFAULT | FBINFO_HWACCEL_YPAN;
+	fb->var = ssd1327_fb_var;
+	fb->fix = ssd1327_fb_fix;
+
+	fb->var.xres = data->width;
+	fb->var.yres = data->height;
+	fb->var.xres_virtual = data->width;
+	fb->var.yres_virtual = data->height * 2;
+
+	/* twice lcd size so we can pan in one direction */
+	fb->fix.smem_len = (data->width * data->height) * 2;
+	fb->fix.line_length = data->width;
+	fb->var.rotate = data->rotate;
+
+	/* allocate video memory */
+	priv->vmem_size = PAGE_ALIGN(fb->fix.smem_len);
+	priv->vmem = vmalloc(priv->vmem_size);
+	if (!priv->vmem) {
+		ret = -ENOMEM;
+		goto fail;
+	}
+	memset(priv->vmem, 0, priv->vmem_size);
+	fb->screen_base = (char __iomem *)priv->vmem;
+
+	ret = ssd1327_init(priv);
+	if (ret)
+		goto fail;
+
+	if (init_backlight(priv))
+		goto fail;
+
+	/* register frame buffer */
+	ret = register_framebuffer(fb);
+	if (ret < 0)
+		goto fail;
+
+	INIT_DELAYED_WORK(&priv->wtd_work, wtd_work_cb);
+
+	if (priv->wtd_max) {
+		atomic_set(&priv->wtd_count, priv->wtd_max);
+		schedule_delayed_work(&priv->wtd_work, HZ);
+	}
+
+	dev_info(&spi->dev,
+		 "fb%d: SSD1327 frame buffer device (%ux%u screen)\n",
+		 fb->node, data->width, data->height);
+
+	dev_set_drvdata(&spi->dev, priv);
+	return 0;
+
+fail:
+	if (priv->vmem)
+		vfree(priv->vmem);
+	if (priv->backlight)
+		backlight_device_unregister(priv->backlight);
+	framebuffer_release(fb);
+	return ret;
+}
+
+/*
+ * platform device remove callback
+ */
+static int ssd1327_remove(struct spi_device *spi)
+{
+	struct ssd1327 *priv;
+	unsigned int i;
+
+	priv = dev_get_drvdata(&spi->dev);
+	cancel_delayed_work_sync(&priv->wtd_work);
+	unregister_framebuffer(priv->fb);
+	for (i = 0; i < priv->vmem_size; i += PAGE_SIZE) {
+		struct page *page;
+		page = vmalloc_to_page(priv->vmem + i);
+		page->mapping = NULL;
+	}
+	vfree(priv->vmem);
+	backlight_device_unregister(priv->backlight);
+	framebuffer_release(priv->fb);
+	return 0;
+}
+
+static struct spi_driver ssd1327_driver = {
+	.driver = {
+		.name		= "ssd1327",
+		.owner		= THIS_MODULE,
+	},
+	.probe		= ssd1327_probe,
+	.remove		= ssd1327_remove,
+};
+
+static int __init ssd1327_module_init(void)
+{
+	return spi_register_driver(&ssd1327_driver);
+}
+
+static void __exit ssd1327_module_exit(void)
+{
+	spi_unregister_driver(&ssd1327_driver);
+}
+
+module_init(ssd1327_module_init);
+module_exit(ssd1327_module_exit);
+
+MODULE_DESCRIPTION("SSD1327 driver");
+MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
+MODULE_LICENSE("GPL");
diff -Nruw linux-4.2.6-fbx/fs/exfat./bitmap.c linux-4.2.6-fbx/fs/exfat/bitmap.c
--- linux-4.2.6-fbx/fs/exfat./bitmap.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/bitmap.c	2015-11-02 19:00:12.748951755 +0100
@@ -0,0 +1,600 @@
+/*
+ * bitmap.c for exfat
+ * Created by <nschichan@freebox.fr> on Thu Aug  8 19:21:05 2013
+ */
+
+#include <linux/buffer_head.h>
+#include <linux/fs.h>
+
+#include "exfat.h"
+#include "exfat_fs.h"
+
+
+static inline sector_t exfat_bitmap_sector(struct exfat_sb_info *sbi,
+					   u32 cluster)
+{
+	return sbi->first_bitmap_sector + ((cluster / 8) >> sbi->sectorbits);
+}
+
+static inline u32 exfat_bitmap_off(struct exfat_sb_info *sbi,
+				   u32 cluster)
+{
+	return (cluster / 8) & sbi->sectormask;
+}
+
+static inline u32 exfat_bitmap_shift(u32 cluster)
+{
+	return cluster & 7;
+}
+
+static int __find_get_free_cluster(struct inode *inode, u32 *out_cluster)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+
+	while (1) {
+		sector_t sect = exfat_bitmap_sector(sbi,
+						    sbi->cur_bitmap_cluster);
+		u32 off = exfat_bitmap_off(sbi, sbi->cur_bitmap_cluster);
+		u32 shift = exfat_bitmap_shift(sbi->cur_bitmap_cluster);
+
+		/* disk is full */
+		if (!sbi->free_clusters)
+			break;
+
+		if (!sbi->cur_bitmap_bh ||
+		    sect != sbi->cur_bitmap_sector) {
+			if (sbi->cur_bitmap_bh)
+				brelse(sbi->cur_bitmap_bh);
+			sbi->cur_bitmap_bh = sb_bread(inode->i_sb, sect);
+			sbi->cur_bitmap_sector = sect;
+			if (!sbi->cur_bitmap_bh) {
+				exfat_msg(inode->i_sb, KERN_ERR,
+					  "unable to read bitmap sector "
+					  "at %llu", sect);
+				return -EIO;
+			}
+		}
+
+		if (!(sbi->cur_bitmap_bh->b_data[off] & (1 << shift))) {
+			sbi->cur_bitmap_bh->b_data[off] |= (1 << shift);
+			*out_cluster = sbi->cur_bitmap_cluster;
+			goto found;
+		}
+
+		++sbi->cur_bitmap_cluster;
+		if (sbi->cur_bitmap_cluster == sbi->cluster_count)
+			sbi->cur_bitmap_cluster = 0;
+	}
+	return -ENOSPC;
+
+found:
+	sbi->prev_free_cluster = *out_cluster;
+	--sbi->free_clusters;
+	mark_buffer_dirty(sbi->cur_bitmap_bh);
+	return 0;
+}
+
+static int __put_cluster(struct inode *inode, u32 cluster)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+	sector_t sect = exfat_bitmap_sector(sbi, cluster);
+	u32 off = exfat_bitmap_off(sbi, cluster);
+	u32 shift = exfat_bitmap_shift(cluster);
+
+
+	if (!sbi->cur_bitmap_bh || sect != sbi->cur_bitmap_sector) {
+		if (sbi->cur_bitmap_bh)
+			brelse(sbi->cur_bitmap_bh);
+		sbi->cur_bitmap_bh = sb_bread(inode->i_sb, sect);
+		if (!sbi->cur_bitmap_bh) {
+			exfat_msg(inode->i_sb, KERN_ERR,
+				  "unable to read bitmap sector at %llu", sect);
+			return -EIO;
+		}
+		sbi->cur_bitmap_sector = sect;
+		sbi->cur_bitmap_cluster = cluster;
+	}
+	if ((sbi->cur_bitmap_bh->b_data[off] & (1 << shift)) == 0) {
+		exfat_fs_error(inode->i_sb, "put_cluster: cluster %u "
+			  "already free.", cluster);
+		return -EIO;
+	}
+
+	++sbi->free_clusters;
+	sbi->cur_bitmap_bh->b_data[off] &= ~(1 << shift);
+	sbi->prev_free_cluster = cluster;
+	mark_buffer_dirty(sbi->cur_bitmap_bh);
+	/* sync_dirty_buffer(sbi->cur_bitmap_bh); */
+	return 0;
+}
+
+/*
+ * setup search to start at given cluster.
+ */
+static void __exfat_reset_bitmap(struct exfat_sb_info *sbi, u32 cluster)
+{
+	sector_t sect;
+
+	if (cluster >= sbi->cluster_count)
+		cluster = 0;
+
+	sect = exfat_bitmap_sector(sbi, cluster);
+	if (sbi->cur_bitmap_sector != sect) {
+		sbi->cur_bitmap_sector = sect;
+		if (sbi->cur_bitmap_bh) {
+			brelse(sbi->cur_bitmap_bh);
+			sbi->cur_bitmap_bh = NULL;
+		}
+	}
+	sbi->cur_bitmap_cluster = cluster;
+}
+
+static bool all_contiguous(u32 *clusters, u32 nr)
+{
+	u32 i;
+
+	for (i = 0; i < nr - 1; ++i) {
+		if (clusters[i] != clusters[i + 1] - 1)
+			return false;
+	}
+	return true;
+}
+
+/*
+ * hint must be the immediately after the last allocated cluster of
+ * the inode.
+ */
+int exfat_alloc_clusters(struct inode *inode, u32 hint, u32 *clusters, u32 nr)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+	struct exfat_inode_info *info = EXFAT_I(inode);
+	u32 i;
+
+	mutex_lock(&sbi->bitmap_mutex);
+	__exfat_reset_bitmap(sbi, hint - 2);
+	for (i = 0; i < nr; ++i) {
+		u32 new;
+		int error;
+
+		error = __find_get_free_cluster(inode, &new);
+		if (error) {
+			mutex_unlock(&sbi->bitmap_mutex);
+			return error;
+		}
+
+		clusters[i] = new + 2;
+	}
+	mutex_unlock(&sbi->bitmap_mutex);
+
+	/*
+	 * all clusters found: now see if we need to update/create a
+	 * fat chain.
+	 */
+	if (info->first_cluster == 0) {
+		info->first_cluster = clusters[0];
+		if (all_contiguous(clusters, nr)) {
+			/*
+			 * first cluster alloc on inode and all
+			 * clusters are contiguous.
+			 */
+			info->flags |= EXFAT_I_FAT_INVALID;
+		} else {
+			/*
+			 * first alloc and already fragmented.
+			 */
+			return exfat_write_fat(inode, 0, clusters, nr);
+		}
+	} else {
+		int error;
+		if ((info->flags & EXFAT_I_FAT_INVALID) &&
+		    (clusters[0] != hint || !all_contiguous(clusters, nr))) {
+			/*
+			 * must now use fat chain instead of bitmap.
+			 */
+			info->flags &= ~(EXFAT_I_FAT_INVALID);
+
+			/*
+			 * write the contiguous chain that would
+			 * previously be accessed without the FAT
+			 * chain.
+			 */
+			error = exfat_write_fat_contiguous(inode,
+						  info->first_cluster,
+						  hint - info->first_cluster);
+			if (error)
+				return error;
+		}
+
+		if ((info->flags & EXFAT_I_FAT_INVALID) == 0) {
+			/*
+			 * link the allocated clusters after hint.
+			 */
+			error = exfat_write_fat(inode, hint - 1, clusters, nr);
+			if (error)
+				return  error;
+		}
+
+	}
+
+	/*
+	 * update i_blocks.
+	 */
+	inode->i_blocks += nr << (sbi->clusterbits - 9);
+	info->allocated_clusters += nr;
+
+	/*
+	 * caller must call mark_inode_dirty so that inode
+	 * first_cluster and inode flags get written to the disk.
+	 * caller must update inode size (directory and regular file
+	 * have different rules).
+	 */
+	return 0;
+}
+
+
+static int exfat_free_clusters_contiguous(struct inode *inode,
+					  u32 start, u32 nr)
+{
+	u32 cluster;
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+	int error = 0;
+
+	mutex_lock(&sbi->bitmap_mutex);
+	for (cluster = start; cluster < start + nr; ++cluster) {
+		error = __put_cluster(inode, cluster - 2);
+		if (error)
+			break;
+	}
+	mutex_unlock(&sbi->bitmap_mutex);
+	return error;
+}
+
+static int exfat_free_clusters_fat(struct inode *inode,
+				   u32 fcluster_start, u32 nr)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+	u32 fcluster;
+	int error = 0;
+
+	mutex_lock(&sbi->bitmap_mutex);
+	for (fcluster = fcluster_start; fcluster < fcluster_start + nr;
+	     ++fcluster) {
+		u32 dcluster;
+		int error;
+
+		error = exfat_get_fat_cluster(inode, fcluster, &dcluster);
+		if (error)
+			break;
+
+		error = __put_cluster(inode, dcluster - 2);
+		if (error)
+			break;
+	}
+	mutex_unlock(&sbi->bitmap_mutex);
+
+	/*
+	 * per-inode file cluster to disk cluster translation cache
+	 * mostly now holds entries to the zone we just truncated, so
+	 * they must not be kept (this could lead to FS corruption).
+	 */
+	exfat_inode_cache_drop(inode);
+
+	return error;
+}
+
+int exfat_free_clusters_inode(struct inode *inode, u32 fcluster_start)
+{
+	struct exfat_inode_info *info = EXFAT_I(inode);
+	int error;
+	u32 nr_to_free = info->allocated_clusters - fcluster_start;
+
+	if (info->first_cluster == 0 || nr_to_free == 0)
+		/*
+		 * no clusters allocated, or nothing to do
+		 */
+		return 0;
+
+	if (info->flags & EXFAT_I_FAT_INVALID)
+		error = exfat_free_clusters_contiguous(inode,
+				       info->first_cluster + fcluster_start,
+				       nr_to_free);
+	else
+		error = exfat_free_clusters_fat(inode, fcluster_start,
+					nr_to_free);
+	if (error)
+		return error;
+
+	info->allocated_clusters -= nr_to_free;
+	inode->i_blocks = EXFAT_I(inode)->allocated_clusters <<
+		(EXFAT_SB(inode->i_sb)->clusterbits - 9);
+
+	/*
+	 * update inode info, caller must call mark_inode_dirty and
+	 * update inode->i_size.
+	 */
+	if (fcluster_start == 0) {
+		info->first_cluster = 0;
+		info->flags &= ~(EXFAT_I_FAT_INVALID);
+	}
+	return 0;
+}
+
+static u32 count_clusters_bh(struct buffer_head *bh, u32 count)
+{
+	u8 *ptr = bh->b_data;
+	u32 ret = 0;
+	u8 val;
+
+	while (count >= sizeof (u64) * 8) {
+		u64 val = *(u64*)ptr;
+
+		ret += hweight64(~val);
+		count -= sizeof (u64) * 8;
+		ptr += sizeof (u64);
+	}
+	if (count >= sizeof (u32) * 8) {
+		u32 val = *(u32*)ptr;
+
+		ret += hweight32(~val);
+		count -= sizeof (u32) * 8;
+		ptr += sizeof (u32);
+	}
+	if (count >= sizeof (u16) * 8) {
+		u16 val = *(u16*)ptr;
+
+		ret += hweight16(~val);
+		count -= sizeof (u16) * 8;
+		ptr += sizeof (u16);
+	}
+	while (count >= sizeof (u8) * 8) {
+		u8 val = *ptr;
+
+		ret += hweight8(~val);
+		count -= sizeof (u8) * 8;
+		ptr += sizeof (u8);
+	}
+	val = *ptr;
+	while (count) {
+		ret += (~val & 1);
+		val >>= 1;
+		--count;
+	}
+	return ret;
+}
+
+/*
+ * only called during mount, so taking sbi->bitmap_mutex should not be
+ * needed.
+ */
+static int exfat_get_free_cluster_count(struct super_block *sb, u32 *out_count)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	u32 clusters_per_sector = 8 * sbi->sectorsize;
+	u32 cluster;
+
+	*out_count = 0;
+	for (cluster = 0; cluster < sbi->cluster_count;
+	     cluster += clusters_per_sector) {
+		sector_t sect = exfat_bitmap_sector(sbi, cluster);
+		struct buffer_head *bh;
+		u32 count = clusters_per_sector;
+
+		if (cluster + clusters_per_sector > sbi->cluster_count)
+			count = sbi->cluster_count - cluster;
+
+		bh = sb_bread(sb, sect);
+		if (!bh) {
+			exfat_msg(sb, KERN_ERR,
+				  "unable to read bitmap sector at %llu", sect);
+			return -EIO;
+		}
+		*out_count += count_clusters_bh(bh, count);
+		brelse(bh);
+	}
+	return 0;
+}
+
+/*
+ * setup a bitmap context, preload a bh from the requested starting
+ * cluster.
+ */
+int exfat_init_bitmap_context(struct super_block *sb,
+			      struct exfat_bitmap_ctx *ctx,
+			      u32 cluster)
+{
+	memset(ctx, 0, sizeof (*ctx));
+	ctx->sb = sb;
+
+	cluster -= 2;
+	if (cluster >= EXFAT_SB(sb)->cluster_count)
+		return -ENOSPC;
+
+	ctx->cur_sector = exfat_bitmap_sector(EXFAT_SB(sb), cluster);
+	ctx->bh = sb_bread(ctx->sb, ctx->cur_sector);
+
+	if (!ctx->bh) {
+		exfat_msg(sb, KERN_ERR, "unable to read bitmap sector at %llu",
+			  ctx->cur_sector);
+		return -EIO;
+	}
+	return 0;
+}
+
+/*
+ * release bh in an already setup bitmap context.
+ */
+void exfat_exit_bitmap_context(struct exfat_bitmap_ctx *ctx)
+{
+	if (ctx->bh)
+		brelse(ctx->bh);
+}
+
+/*
+ * test a specific cluster usage in the bitmap. reuse the bh in the
+ * exfat_bitmap_ctx or read a new one if starting cluster is outside
+ * the current one.
+ */
+static int exfat_test_bitmap_cluster(struct exfat_bitmap_ctx *ctx,
+				     uint32_t cluster, bool *cluster_in_use)
+{
+	sector_t sect;
+	uint32_t off = exfat_bitmap_off(EXFAT_SB(ctx->sb), cluster);
+	int shift = exfat_bitmap_shift(cluster);
+
+	sect = exfat_bitmap_sector(EXFAT_SB(ctx->sb), cluster);
+	if (sect != ctx->cur_sector) {
+		ctx->cur_sector = sect;
+		ctx->bh = sb_bread(ctx->sb, ctx->cur_sector);
+		if (!ctx->bh) {
+			exfat_msg(ctx->sb, KERN_ERR,
+				  "unable to read bitmap sector at %llu", sect);
+			return -EIO;
+		}
+	}
+
+	*cluster_in_use = !!(ctx->bh->b_data[off] & (1 << shift));
+	return 0;
+}
+
+/*
+ * update first_in_use and nr_in_use with the first zone of used
+ * clusters starting from start_cluster.
+ */
+int exfat_test_bitmap(struct exfat_bitmap_ctx *ctx, uint32_t start_cluster,
+		      uint32_t *first_in_use, uint32_t *nr_in_use)
+{
+	bool in_use = false;
+	int error = 0;
+	struct exfat_sb_info *sbi = EXFAT_SB(ctx->sb);
+
+	start_cluster -= 2;
+
+	/*
+	 * scan bitmap until we find a cluster that is in use.
+	 */
+	while (1) {
+		if (start_cluster == sbi->cluster_count) {
+			/*
+			 * readched end of disk: no more in use
+			 * cluster found.
+			 */
+			*first_in_use = sbi->cluster_count;
+			*nr_in_use = 0;
+			return 0;
+		}
+		error = exfat_test_bitmap_cluster(ctx, start_cluster, &in_use);
+		if (error)
+			return error;
+		if (in_use)
+			break;
+		++start_cluster;
+	}
+
+
+	/*
+	 * update first_in_use, and scan until a free cluster is
+	 * found.
+	 */
+	*first_in_use = start_cluster + 2;
+	*nr_in_use = 0;
+	while (1) {
+		error = exfat_test_bitmap_cluster(ctx, start_cluster, &in_use);
+		if (error)
+			return error;
+		if (!in_use)
+			break;
+		++(*nr_in_use);
+		++start_cluster;
+	}
+	return 0;
+}
+
+int exfat_init_bitmap(struct inode *root)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(root->i_sb);
+	struct exfat_bitmap_entry *be;
+	struct exfat_dir_ctx dctx;
+	u32 first_bitmap_cluster;
+	u32 last_bitmap_cluster;
+
+	int error;
+
+	mutex_init(&sbi->bitmap_mutex);
+
+	error = exfat_init_dir_ctx(root, &dctx, 0);
+	if (error)
+		return error;
+
+try_bitmap:
+	error = -ENOENT;
+	be = __exfat_dentry_next(&dctx, E_EXFAT_BITMAP, 0xff, true, NULL);
+	if (!be) {
+		exfat_msg(root->i_sb, KERN_ERR, "root directory does not "
+			  "have a bitmap entry.");
+		goto fail;
+	}
+
+	if (exfat_bitmap_nr(be->flags) != 0)
+		/*
+		 * not expected to find a second bitmap entry here
+		 * since we checked during superblock fill that we
+		 * were not on a texFAT volume ...
+		 */
+		goto try_bitmap;
+
+
+	error = -EINVAL;
+	if (__le64_to_cpu(be->length) * 8 < sbi->cluster_count) {
+		exfat_msg(root->i_sb, KERN_INFO, "bitmap does not cover "
+			  "the whole cluster heap.");
+		goto fail;
+	}
+
+	first_bitmap_cluster = __le32_to_cpu(be->cluster_addr);
+	last_bitmap_cluster = first_bitmap_cluster +
+		(__le32_to_cpu(be->length) >> sbi->clusterbits);
+
+	/*
+	 * check that bitmap start and end clusters are inside the
+	 * disk.
+	 */
+	error = -ERANGE;
+	if (first_bitmap_cluster < 2 &&
+	    first_bitmap_cluster >= sbi->cluster_count) {
+		exfat_msg(root->i_sb, KERN_ERR, "bitmap start cluster is "
+			  "outside disk limits.");
+		goto fail;
+	}
+	if (last_bitmap_cluster < 2 &&
+	    last_bitmap_cluster >= sbi->cluster_count) {
+		exfat_msg(root->i_sb, KERN_ERR, "bitmap last cluster is "
+			  "outside disk limits.");
+		goto fail;
+	}
+
+	sbi->bitmap_length = __le32_to_cpu(be->length);
+	sbi->first_bitmap_sector = exfat_cluster_sector(sbi,
+					__le32_to_cpu(be->cluster_addr));
+	sbi->last_bitmap_sector = sbi->first_bitmap_sector +
+		DIV_ROUND_UP(sbi->bitmap_length, sbi->sectorsize);
+
+	error = exfat_get_free_cluster_count(root->i_sb, &sbi->free_clusters);
+	if (error)
+		goto fail;
+
+	sbi->prev_free_cluster = 0;
+
+	exfat_cleanup_dir_ctx(&dctx);
+	return 0;
+fail:
+	exfat_cleanup_dir_ctx(&dctx);
+	return error;
+}
+
+void exfat_exit_bitmap(struct super_block *sb)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+
+	if (sbi->cur_bitmap_bh)
+		brelse(sbi->cur_bitmap_bh);
+}
diff -Nruw linux-4.2.6-fbx/fs/exfat./dir.c linux-4.2.6-fbx/fs/exfat/dir.c
--- linux-4.2.6-fbx/fs/exfat./dir.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/dir.c	2015-11-02 19:00:10.348932830 +0100
@@ -0,0 +1,400 @@
+/*
+ * dir.c for exfat
+ * Created by <nschichan@freebox.fr> on Tue Aug 20 11:42:46 2013
+ */
+
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/buffer_head.h>
+#include <linux/slab.h>
+#include <linux/nls.h>
+
+#include "exfat.h"
+#include "exfat_fs.h"
+
+/*
+ * setup an exfat_dir_ctx structure so that __exfat_dentry_next can
+ * work with it.
+ */
+int exfat_init_dir_ctx(struct inode *inode, struct exfat_dir_ctx *ctx,
+		       off_t start)
+{
+	u32 cluster = EXFAT_I(inode)->first_cluster;
+
+	memset(ctx, 0, sizeof (*ctx));
+
+	if (cluster == 0) {
+		ctx->empty = true;
+		ctx->sb = inode->i_sb;
+		return 0;
+	}
+
+	if (cluster < EXFAT_CLUSTER_FIRSTVALID ||
+	    cluster > EXFAT_CLUSTER_LASTVALID) {
+		exfat_msg(inode->i_sb, KERN_ERR, "exfat_init_dir_ctx: invalid "
+			  "cluster %u", cluster);
+		return -EINVAL;
+	}
+
+	start &= ~(0x20 - 1);
+	if (start == 0)
+		ctx->off = -1;
+	else
+		ctx->off = start - 0x20;
+
+	ctx->sb = inode->i_sb;
+	ctx->inode = inode;
+
+	return 0;
+}
+
+void exfat_cleanup_dir_ctx(struct exfat_dir_ctx *dctx)
+{
+	if (dctx->bh)
+		brelse(dctx->bh);
+}
+
+/*
+ * calculate the checksum for the current direntry. fields containing
+ * the checksum for the first entry is not part of the checksum
+ * calculation.
+ */
+u16 exfat_direntry_checksum(void *data, u16 checksum, bool first)
+{
+	u8 *ptr = data;
+	int i;
+
+	for (i = 0; i < 0x20; ++i) {
+		if (first && (i == 2 || i == 3))
+			continue ;
+		checksum = ((checksum << 15) | (checksum >> 1)) + (u16)ptr[i];
+	}
+	return checksum;
+}
+
+u32 exfat_dctx_fpos(struct exfat_dir_ctx *dctx)
+{
+	return dctx->off;
+}
+
+u64 exfat_dctx_dpos(struct exfat_dir_ctx *dctx)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(dctx->sb);
+
+	return (dctx->sector << sbi->sectorbits) +
+		(dctx->off & sbi->sectormask);
+}
+
+static int exfat_get_dctx_disk_cluster(struct exfat_dir_ctx *dctx,
+				       u32 file_cluster, u32 *disk_cluster)
+{
+	struct exfat_inode_info *info = EXFAT_I(dctx->inode);
+
+	if (info->flags & EXFAT_I_FAT_INVALID) {
+		*disk_cluster = info->first_cluster + file_cluster;
+		return 0;
+	} else {
+		return exfat_get_fat_cluster(dctx->inode, file_cluster,
+					     disk_cluster);
+	}
+}
+
+/*
+ * get the next typed dentry in the exfat_dir_ctx structure. can_skip
+ * indicates whether the entry must be immediately there in the entry
+ * stream. *end indicates whether end of directory entry stream is
+ * reached or not.
+ *
+ * only one buffer_head is kept at a time. subsequent calls to
+ * __exfat_dentry_next can invalidate pointers from previous calls due
+ * to that.
+ */
+void *__exfat_dentry_next(struct exfat_dir_ctx *dctx, int type, int mask,
+			  bool can_skip, bool *end)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(dctx->sb);
+
+	if (dctx->empty) {
+		if (end)
+			*end = true;
+		return NULL;
+	}
+
+	if (end)
+		*end = false;
+
+	if (dctx->off == -1)
+		dctx->off = 0;
+	else
+		dctx->off += 0x20;
+
+	for (;;) {
+		sector_t wanted_sector;
+		u32 file_cluster = dctx->off >> sbi->clusterbits;
+		u32 disk_cluster;
+		int error;
+		int sector_offset;
+		sector_t sector_in_cluster;
+
+		if (dctx->off >= dctx->inode->i_size) {
+			*end = true;
+			return NULL;
+		}
+
+
+		error = exfat_get_dctx_disk_cluster(dctx, file_cluster,
+						    &disk_cluster);
+		if (error)
+			return NULL;
+
+		sector_in_cluster = (dctx->off >> sbi->sectorbits) %
+			sbi->sectors_per_cluster;
+
+		wanted_sector = exfat_cluster_sector(sbi, disk_cluster) +
+			sector_in_cluster;
+		if (wanted_sector != dctx->sector || !dctx->bh) {
+			/*
+			 * need to fetch a new sector from the current
+			 * cluster.
+			 */
+			dctx->sector = wanted_sector;
+			if (dctx->bh)
+				brelse(dctx->bh);
+			dctx->bh = sb_bread(dctx->sb, dctx->sector);
+			if (!dctx->bh)
+				return NULL;
+		}
+
+		sector_offset = dctx->off & sbi->sectormask;
+		if ((dctx->bh->b_data[sector_offset] & mask) == (type & mask))
+			/*
+			 * return pointer to entry if type matches the
+			 * one given.
+			 */
+			return dctx->bh->b_data + sector_offset;
+
+		if (dctx->bh->b_data[sector_offset] == 0 && end)
+			/*
+			 * set end if no more entries in this directory.
+			 */
+			*end = true;
+
+		if (dctx->bh->b_data[sector_offset] == 0 || !can_skip)
+			/*
+			 * handle can_skip / end of directory.
+			 */
+			return NULL;
+
+		/*
+		 * move to next entry.
+		 */
+		dctx->off += 0x20;
+	}
+	return NULL;
+}
+
+/*
+ * helper around __exfat_dentry_next that copies the content of the
+ * found entry in a user supplied buffer.
+ */
+int exfat_dentry_next(void *out, struct exfat_dir_ctx *dctx,
+			     int type, bool can_skip)
+{
+	bool end;
+
+	void *ptr = __exfat_dentry_next(dctx, type, 0xff, can_skip, &end);
+
+	if (!ptr) {
+		if (end)
+			return -ENOENT;
+		else {
+			exfat_msg(dctx->sb, KERN_INFO, "no ptr and "
+				  "end not reached: "
+				  "type %02x, can_skip %s\n", type,
+				  can_skip ? "true" : "false");
+			return -EIO;
+		}
+	}
+	memcpy(out, ptr, 0x20);
+	return 0;
+}
+
+/*
+ * extract name by parsing consecutive E_EXFAT_FILENAME entries in a
+ * caller provided buffer. also update the checksum on the fly.
+ *
+ * no utf16 to utf8 conversion is performed.
+ */
+int __exfat_get_name(struct exfat_dir_ctx *dctx, u32 name_length,
+			    __le16 *name, u16 *calc_checksum,
+			    struct exfat_iloc *iloc)
+{
+	__le16 *ptr;
+	int error;
+	int nr;
+
+	ptr = name;
+
+	error = -EIO;
+	nr = 0;
+	while (name_length) {
+		struct exfat_filename_entry *e;
+		u32 len = 15;
+
+		e = __exfat_dentry_next(dctx, E_EXFAT_FILENAME, 0xff,
+					false, NULL);
+		if (!e)
+			goto fail;
+		*calc_checksum = exfat_direntry_checksum(e, *calc_checksum,
+							 false);
+
+		if (iloc)
+			iloc->disk_offs[nr + 2] = exfat_dctx_dpos(dctx);
+		if (name_length < 15)
+			len = name_length;
+
+		memcpy(ptr, e->name_frag, len * sizeof (__le16));
+		name_length -= len;
+		ptr += len;
+		nr++;
+	}
+	return 0;
+
+fail:
+	return error;
+}
+
+/*
+ * walk the directory and invoke filldir on all found entries.
+ */
+static int __exfat_iterate(struct exfat_dir_ctx *dctx, struct file *file,
+			   struct dir_context *ctx)
+{
+	int error;
+	char *name = __getname();
+	__le16 *utf16name = __getname();
+
+	if (!name)
+		return -ENOMEM;
+	if (!utf16name) {
+		__putname(name);
+		return -ENOMEM;
+	}
+
+	for (;;) {
+		struct exfat_filedir_entry *efd;
+		struct exfat_stream_extension_entry *esx;
+		int dtype = DT_REG;
+		int name_length;
+		bool end;
+		u16 calc_checksum;
+		u16 expect_checksum;
+
+		/*
+		 * get the next filedir entry, we are allowed to skip
+		 * entries for that.
+		 */
+		error = -EIO;
+		efd = __exfat_dentry_next(dctx, E_EXFAT_FILEDIR, 0xff,
+					  true, &end);
+		if (!efd) {
+			if (end)
+				break;
+			else
+				goto fail;
+		}
+		expect_checksum = __le16_to_cpu(efd->set_checksum);
+		calc_checksum = exfat_direntry_checksum(efd, 0, true);
+
+		if (__le16_to_cpu(efd->attributes & E_EXFAT_ATTR_DIRECTORY))
+			dtype = DT_DIR;
+
+		/*
+		 * get immediate stream extension entry.
+		 */
+		esx = __exfat_dentry_next(dctx, E_EXFAT_STREAM_EXT, 0xff, false,
+					  NULL);
+		if (!esx)
+			goto fail;
+		calc_checksum = exfat_direntry_checksum(esx, calc_checksum,
+							false);
+
+		/*
+		 * get immediate name.
+		 */
+		error = __exfat_get_name(dctx, esx->name_length, utf16name,
+					 &calc_checksum, NULL);
+		if (error) {
+			exfat_msg(dctx->sb, KERN_INFO, "__exfat_get_name "
+				  "has failed with %i", error);
+			goto fail;
+		}
+
+		if (calc_checksum != expect_checksum) {
+			exfat_msg(dctx->sb, KERN_INFO, "checksum: "
+				  "calculated %04x, expect %04x",
+				  calc_checksum, expect_checksum);
+			error = -EIO;
+			goto fail;
+		}
+
+		/*
+		 * convert utf16 to utf8 for kernel filldir callback.
+		 */
+		name_length = utf16s_to_utf8s(utf16name, esx->name_length,
+						   UTF16_LITTLE_ENDIAN,
+						   name, NAME_MAX + 2);
+		if (name_length < 0) {
+			error = name_length;
+			goto fail;
+		}
+		if (name_length > 255) {
+			error = -ENAMETOOLONG;
+			goto fail;
+		}
+
+		/*
+		 * tell the kernel we have an entry by calling
+		 * dir_emit
+		 */
+		if (dir_emit(ctx, name, name_length, 1, dtype))
+			ctx->pos = 2 + exfat_dctx_fpos(dctx);
+		else
+			goto fail;
+	}
+	__putname(name);
+	__putname(utf16name);
+	ctx->pos = file_inode(file)->i_size + 2;
+	return 0;
+fail:
+	__putname(name);
+	__putname(utf16name);
+	return error;
+}
+
+/*
+ * readdir callback for VFS. fill "." and "..", then invoke
+ * __exfat_iterate.
+ */
+int exfat_iterate(struct file *file, struct dir_context *ctx)
+{
+	struct exfat_dir_ctx dctx;
+	int error;
+	struct inode *inode = file_inode(file);
+
+	switch (ctx->pos) {
+	case 0:
+		return dir_emit_dots(file, ctx);
+	default:
+		if (ctx->pos >= inode->i_size + 2)
+			return 0;
+		error = exfat_init_dir_ctx(inode, &dctx, ctx->pos - 2);
+		if (error)
+			return error;
+		exfat_lock_super(inode->i_sb);
+		error = __exfat_iterate(&dctx, file, ctx);
+		exfat_unlock_super(inode->i_sb);
+		exfat_cleanup_dir_ctx(&dctx);
+		return error;
+	}
+}
diff -Nruw linux-4.2.6-fbx/fs/exfat./exfat_fs.h linux-4.2.6-fbx/fs/exfat/exfat_fs.h
--- linux-4.2.6-fbx/fs/exfat./exfat_fs.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/exfat_fs.h	2015-11-02 19:00:10.348932830 +0100
@@ -0,0 +1,200 @@
+/*
+ * exfat_fs.h for exfat
+ * Created by <nschichan@freebox.fr> on Mon Jul 29 15:06:38 2013
+ */
+
+#ifndef __EXFAT_FS_H
+# define __EXFAT_FS_H
+
+/*
+ * exfat on disk structures and constants
+ */
+
+#include <linux/types.h>
+
+struct exfat_vbr {
+	u8	jump[3];
+	u8	fsname[8];
+	u8	reserved1[53];
+
+	__le64	partition_offset;
+	__le64	volume_length;
+
+	__le32	fat_offset;
+	__le32	fat_length;
+
+	__le32	cluster_heap_offset;
+	__le32	cluster_count;
+	__le32	cluster_root_dir;
+
+	__le32	serial_number;
+
+	__le16	fs_rev;
+	__le16	volume_flags;
+
+	u8	bytes_per_sector;
+	u8	sectors_per_cluster;
+
+	u8	fat_num;
+	u8	drive_select;
+	u8	heap_use_percent;
+
+	u8	reserved2[7];
+	u8	boot_code[390];
+
+	u8	boot_sig[2];
+};
+
+enum {
+	EXFAT_CLUSTER_FIRSTVALID	= 0x00000002,
+	EXFAT_CLUSTER_LASTVALID		= 0xfffffff6,
+	EXFAT_CLUSTER_BADBLK		= 0xfffffff7,
+	EXFAT_CLUSTER_MEDIATYPE		= 0xfffffff8,
+	EXFAT_CLUSTER_EOF		= 0xffffffff,
+};
+
+enum {
+	EXFAT_ACTIVEFAT_MASK = (1 << 0),
+	EXFAT_FLAG_DIRTY = (1 << 1),
+	EXFAT_FLAG_MEDIA_FAILURE = (1 << 2),
+};
+
+static inline int exfat_active_fat(u16 flags)
+{
+	return flags & EXFAT_ACTIVEFAT_MASK;
+}
+
+#define EXFAT_CHECKSUM_SECTORS	11
+
+enum {
+	EXFAT_I_ALLOC_POSSIBLE = (1 << 0),
+	EXFAT_I_FAT_INVALID = (1 << 1),
+};
+
+/*
+ * directory cluster content
+ */
+
+/*
+ * entry types
+ */
+enum {
+	E_EXFAT_EOD		= 0x00,
+	E_EXFAT_VOLUME_LABEL	= 0x83,
+	E_EXFAT_BITMAP		= 0x81,
+	E_EXFAT_UPCASE_TABLE	= 0x82,
+	E_EXFAT_GUID		= 0xa0,
+	E_EXFAT_PADDING		= 0xa1,
+	E_EXFAT_ACL		= 0xe2,
+	E_EXFAT_FILEDIR		= 0x85,
+	E_EXFAT_STREAM_EXT	= 0xc0,
+	E_EXFAT_FILENAME	= 0xc1,
+};
+
+/*
+ * file attributes in exfat_filedir_entry
+ */
+enum {
+	E_EXFAT_ATTR_RO		= (1 << 0),
+	E_EXFAT_ATTR_HIDDEN	= (1 << 1),
+	E_EXFAT_ATTR_SYSTEM	= (1 << 2),
+	/* bit 3 reserved */
+	E_EXFAT_ATTR_DIRECTORY	= (1 << 4),
+	E_EXFAT_ATTR_ARCHIVE	= (1 << 5),
+	/* bits 6-15 reserved */
+};
+
+/* type 0x83 */
+struct exfat_volume_label_entry {
+	u8 type;
+	u8 charcount;
+	__u16 label[11];
+	u8 reserved1[8];
+};
+
+static inline int exfat_bitmap_nr(u8 flags)
+{
+	return flags & 1;
+}
+
+/* type 0x81 */
+struct exfat_bitmap_entry {
+	u8 type;
+	u8 flags;
+	u8 reserved1[18];
+	__le32 cluster_addr;
+	__le64 length;
+};
+
+/* type 0x82 */
+struct exfat_upcase_entry {
+	u8 type;
+	u8 reserved1[3];
+	__le32 checksum;
+	u8 reserved2[12];
+	__le32 cluster_addr;
+	__le64 length;
+};
+
+/* type 0xa0 */
+struct exfat_guid_entry {
+	u8 type;
+	u8 secondary_count;
+	__le16 set_checksum;
+	__le16 flags;
+	u8 guid[16];
+	u8 reserved1[10];
+};
+
+/* type 0xa1 */
+struct exfat_padding_entry {
+	u8 type;
+	u8 reserved1[31];
+};
+
+/* type 0xe2 */
+struct exfat_acl_entry {
+	u8 type;
+	u8 reserved1[31];
+};
+
+/* type 0x85 */
+struct exfat_filedir_entry {
+	u8 type;
+	u8 secondary_count;
+	__le16 set_checksum;
+	__le16 attributes;
+	u8 reserved1[2];
+	__le32 create;
+	__le32 modified;
+	__le32 accessed;
+	u8 create_10ms;
+	u8 modified_10ms;
+	s8 create_tz_offset;
+	s8 modified_tz_offset;
+	s8 accessed_tz_offset;
+	u8 reserved2[7];
+};
+
+/* 0xc0 */
+struct exfat_stream_extension_entry {
+	u8 type;
+	u8 flags;
+	u8 reserved1;
+	u8 name_length;
+	__le16 name_hash;
+	u8 reserved2[2];
+	__le64 valid_data_length;
+	u8 reserved3[4];
+	__le32 first_cluster;
+	__le64 data_length;
+};
+
+/* 0xc1 */
+struct exfat_filename_entry {
+	u8 type;
+	u8 flags;
+	__le16 name_frag[15];
+};
+
+#endif /*! __EXFAT_FS_H */
diff -Nruw linux-4.2.6-fbx/fs/exfat./exfat.h linux-4.2.6-fbx/fs/exfat/exfat.h
--- linux-4.2.6-fbx/fs/exfat./exfat.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/exfat.h	2015-11-02 19:00:12.956953394 +0100
@@ -0,0 +1,325 @@
+/*
+ * exfat.h for exfat
+ * Created by <nschichan@freebox.fr> on Tue Jul 23 12:37:12 2013
+ */
+
+#ifndef __EXFAT_H
+# define __EXFAT_H
+
+#define EXFAT_HASH_BITS	(8)
+#define EXFAT_HASH_SIZE	(1 << EXFAT_HASH_BITS)
+
+/*
+ * special inode number for root directory.
+ */
+#define EXFAT_ROOT_INO	1
+
+enum {
+	EXFAT_ERROR_ACTION_CONTINUE,
+	EXFAT_ERROR_ACTION_REMOUNT_RO,
+	EXFAT_ERROR_ACTION_PANIC,
+};
+
+struct exfat_sb_options {
+	kuid_t	uid;
+	kgid_t	gid;
+	mode_t	dmask;
+	mode_t	fmask;
+	int	time_offset;
+	int	time_offset_set;
+	int	error_action;
+};
+
+struct exfat_sb_info {
+	struct exfat_sb_options options;
+
+	struct buffer_head *sb_bh;
+	struct exfat_vbr *vbr;
+	bool dirty;
+
+	u32 sectorsize; /* in bytes*/
+	u32 clustersize; /* in bytes */
+	u32 sectors_per_cluster;
+	int sectorbits;
+	int clusterbits;
+	u32 sectormask;
+	u32 clustermask;
+
+	u32 fat_offset;
+	u32 fat_length;
+
+	u32 root_dir_cluster;
+	u32 cluster_heap_offset;
+	u32 cluster_count;
+
+	__le16	*upcase_table;
+	u32	upcase_len;
+
+	/*
+	 * bitmap fields
+	 */
+	struct mutex		bitmap_mutex;
+	u32			bitmap_length;
+	sector_t		first_bitmap_sector;
+	sector_t		last_bitmap_sector;
+	sector_t		cur_bitmap_sector;
+	u32			cur_bitmap_cluster;
+	struct buffer_head	*cur_bitmap_bh;
+	u32			free_clusters;
+	u32			prev_free_cluster;
+
+	/*
+	 * inode hash fields
+	 */
+	spinlock_t		inode_hash_lock;
+	struct hlist_head	inode_hash[EXFAT_HASH_SIZE];
+
+	struct mutex		sb_mutex;
+};
+
+struct exfat_cache_entry {
+	struct list_head list;
+	u32 file_cluster;
+	u32 disk_cluster;
+	u32 nr_contig;
+};
+
+struct exfat_cache {
+	struct mutex		mutex;
+	struct list_head	entries;
+	u32			nr_entries;
+};
+
+struct exfat_iloc {
+	u8 nr_secondary;
+	u32 file_off;
+	u64 disk_offs[19];
+};
+
+struct exfat_inode_info {
+	u8			flags;
+	u16			attributes;
+	u32			first_cluster;
+	u32			allocated_clusters;
+	loff_t			mmu_private;
+	struct exfat_iloc	iloc;
+	struct hlist_node	hash_list;
+
+	struct exfat_cache	exfat_cache;
+	struct inode		vfs_inode;
+};
+
+static inline struct exfat_sb_info *EXFAT_SB(struct super_block *sb)
+{
+	return sb->s_fs_info;
+}
+
+static inline struct exfat_inode_info *EXFAT_I(struct inode *inode)
+{
+	return container_of(inode, struct exfat_inode_info, vfs_inode);
+}
+
+loff_t exfat_dir_links(struct inode *inode);
+
+int exfat_write_fat_contiguous(struct inode *inode, u32 first_cluster,
+			       u32 nr_clusters);
+int exfat_write_fat(struct inode *inode, u32 prev_cluster, u32 *clusters,
+		    u32 nr_clusters);
+
+__printf(3, 4) void exfat_msg(struct super_block *sb, const char *level,
+			      const char *fmt, ...);
+__printf(2, 3) void exfat_fs_error(struct super_block *sb,
+				   const char *fmt, ...);
+int exfat_get_fat_cluster(struct inode *inode, u32 fcluster, u32 *dcluster);
+int __exfat_get_fat_cluster(struct inode *inode, u32 fcluster, u32 *dcluster,
+			    bool eof_is_fatal);
+
+void exfat_inode_cache_init(struct inode *inode);
+void exfat_inode_cache_drop(struct inode *inode);
+
+int exfat_init_fat(struct super_block *sb);
+
+int exfat_init_bitmap(struct inode *root);
+void exfat_exit_bitmap(struct super_block *sb);
+int exfat_alloc_clusters(struct inode *inode, u32 hint_cluster,
+			 u32 *cluster, u32 nr);
+int exfat_free_clusters_inode(struct inode *inode, u32 start);
+
+
+/*
+ * read only bitmap accessors: used by EXFAT_IOCGETBITMAP ioctl.
+ */
+struct exfat_bitmap_ctx {
+	struct super_block *sb;
+	struct buffer_head *bh;
+	sector_t cur_sector;
+};
+
+int exfat_init_bitmap_context(struct super_block *sb,
+			      struct exfat_bitmap_ctx *ctx, u32 cluster);
+void exfat_exit_bitmap_context(struct exfat_bitmap_ctx *ctx);
+int exfat_test_bitmap(struct exfat_bitmap_ctx *ctx, uint32_t start_cluster,
+		      uint32_t *first_in_use, uint32_t *nr_in_use);
+
+
+/*
+ * return the physical sector address for a given cluster.
+ */
+static inline sector_t exfat_cluster_sector(struct exfat_sb_info *sbi,
+					    u32 cluster)
+{
+	return (sector_t)sbi->cluster_heap_offset + (cluster - 2) *
+		(sector_t)sbi->sectors_per_cluster;
+}
+
+/*
+ * in dir.c
+ */
+struct exfat_dir_ctx {
+	struct super_block	*sb;
+	struct inode		*inode;
+	struct buffer_head	*bh;
+
+	off_t			off; /* from beginning of directory */
+	sector_t		sector;
+	bool empty;
+};
+
+int exfat_init_dir_ctx(struct inode *inode, struct exfat_dir_ctx *ctx,
+		       off_t off);
+void exfat_cleanup_dir_ctx(struct exfat_dir_ctx *dctx);
+int exfat_get_cluster_hint(struct inode *inode, u32 *out_hint);
+int exfat_dentry_next(void *, struct exfat_dir_ctx *, int, bool);
+void *__exfat_dentry_next(struct exfat_dir_ctx *dctx, int type, int mask,
+			  bool can_skip, bool *end);
+u16 exfat_direntry_checksum(void *data, u16 checksum, bool first);
+u32 exfat_dctx_fpos(struct exfat_dir_ctx *dctx);
+u64 exfat_dctx_dpos(struct exfat_dir_ctx *dctx);
+int __exfat_get_name(struct exfat_dir_ctx *dctx, u32 name_length, __le16 *name,
+		     u16 *calc_checksum, struct exfat_iloc *iloc);
+
+/*
+ * in namei.c
+ */
+
+/*
+ * hold a pointer to an exfat dir entry, with the corresponding bh.
+ */
+struct dir_entry_buffer {
+	struct buffer_head *bh;
+	u32 off; /* in bytes, inside the buffer_head b_data array */
+	void *start;
+};
+
+int exfat_get_dir_entry_buffers(struct inode *dir, struct exfat_iloc *iloc,
+				struct dir_entry_buffer *entries,
+				size_t nr_entries);
+u16 exfat_dir_entries_checksum(struct dir_entry_buffer *entries, u32 nr);
+void exfat_dirty_dir_entries(struct dir_entry_buffer *entries,
+			     size_t nr_entries, bool sync);
+void exfat_write_time(struct exfat_sb_info *sbi, struct timespec *ts,
+		      __le32 *datetime, u8 *time_cs, u8 *tz_offset);
+
+/*
+ * in inode.c
+ */
+
+int exfat_init_inodes(void);
+void exfat_exit_inodes(void);
+
+struct inode *exfat_iget(struct super_block *sb, loff_t disk_pos);
+void exfat_insert_inode_hash(struct inode *inode);
+void exfat_remove_inode_hash(struct inode *inode);
+int __exfat_write_inode(struct inode *inode, bool sync);
+
+/*
+ * in upcase.c
+ */
+int exfat_upcase_init(struct inode *root);
+static inline __le16 exfat_upcase_convert(struct super_block *sb, __le16 _c)
+{
+	u16 c = __le16_to_cpu(_c);
+
+	if (c >= EXFAT_SB(sb)->upcase_len)
+		return _c;
+	return EXFAT_SB(sb)->upcase_table[c];
+}
+
+/*
+ * superblock operations
+ */
+struct inode *exfat_alloc_inode(struct super_block *sb);
+void exfat_destroy_inode(struct inode *_inode);
+int exfat_drop_inode(struct inode *inode);
+void exfat_evict_inode(struct inode *inode);
+
+/*
+ * file operations
+ */
+int exfat_iterate(struct file *f, struct dir_context *ctx);
+long exfat_ioctl(struct file *, unsigned int, unsigned long);
+int exfat_truncate_blocks(struct inode *inode, loff_t newsize);
+
+/*
+ * inode operations
+ */
+struct dentry *exfat_inode_lookup(struct inode *, struct dentry *,
+				  unsigned int);
+int exfat_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode,
+		       bool excl);
+int exfat_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
+
+mode_t exfat_make_mode(struct exfat_sb_info *sbi, mode_t mode, u16 attrs);
+
+int exfat_write_inode(struct inode *inode, struct writeback_control *wbc);
+
+int exfat_inode_unlink(struct inode *inode, struct dentry *dentry);
+
+int exfat_inode_rmdir(struct inode *inode, struct dentry *dentry);
+
+int exfat_getattr(struct vfsmount *, struct dentry *, struct kstat *);
+int exfat_setattr(struct dentry *, struct iattr *);
+int exfat_rename(struct inode *, struct dentry *,
+		 struct inode *, struct dentry *);
+
+/*
+ * address space operations
+ */
+int exfat_readpage(struct file *file, struct page *page);
+int exfat_readpages(struct file *file, struct address_space *mapping,
+		    struct list_head *pages, unsigned nr_pages);
+int exfat_write_begin(struct file *file, struct address_space *mapping,
+		      loff_t pos, unsigned len, unsigned flags,
+		      struct page **pagep, void **fsdata);
+int exfat_write_end(struct file *file, struct address_space *mapping,
+		    loff_t pos, unsigned len, unsigned copied,
+		    struct page *page, void *fsdata);
+int exfat_writepage(struct page *page, struct writeback_control *wbc);
+int exfat_writepages(struct address_space *, struct writeback_control *);
+
+
+extern const struct inode_operations exfat_dir_inode_operations;
+extern const struct inode_operations exfat_file_inode_operations;
+extern const struct file_operations exfat_dir_operations;
+extern const struct file_operations exfat_file_operations;
+extern const struct address_space_operations exfat_address_space_operations;
+
+/*
+ * time functions
+ */
+void exfat_time_2unix(struct timespec *ts, u32 datetime, u8 time_cs,
+		      s8 tz_offset);
+void exfat_time_2exfat(struct exfat_sb_info *sbi, struct timespec *ts,
+		       u32 *datetime, u8 *time_cs, s8 *tz_offset);
+
+static inline void exfat_lock_super(struct super_block *sb)
+{
+	mutex_lock(&EXFAT_SB(sb)->sb_mutex);
+}
+
+static inline void exfat_unlock_super(struct super_block *sb)
+{
+	mutex_unlock(&EXFAT_SB(sb)->sb_mutex);
+}
+
+#endif /*! __EXFAT_H */
diff -Nruw linux-4.2.6-fbx/fs/exfat./fat.c linux-4.2.6-fbx/fs/exfat/fat.c
--- linux-4.2.6-fbx/fs/exfat./fat.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/fat.c	2015-11-02 19:00:12.956953394 +0100
@@ -0,0 +1,424 @@
+/*
+ * fat.c for exfat
+ * Created by <nschichan@freebox.fr> on Mon Jul 29 19:43:38 2013
+ */
+
+#include <linux/fs.h>
+#include <linux/buffer_head.h>
+#include <linux/slab.h>
+
+#include "exfat.h"
+#include "exfat_fs.h"
+
+#define MAX_CACHED_FAT	16
+
+/*
+ * helpers for exfat_next_fat_cluster.
+ */
+
+/*
+ * get the sector number in the fat where the next requested cluster
+ * number is to be found.
+ */
+static inline sector_t cluster_sector(struct exfat_sb_info *sbi, u32 cluster)
+{
+	return sbi->fat_offset + (((u64)cluster * sizeof (u32)) >> sbi->sectorbits);
+}
+
+/*
+ * get the offset in the fat sector where the next requested cluster
+ * number is to be found.
+ */
+static inline off_t cluster_offset(struct exfat_sb_info *sbi, u32 cluster)
+{
+	return (cluster * sizeof (u32)) & sbi->sectormask;
+}
+
+/*
+ * walk one step in the fat chain.
+ */
+static int exfat_next_fat_cluster(struct super_block *sb, u32 *cluster)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	sector_t sect = cluster_sector(sbi, *cluster);
+	off_t off = cluster_offset(sbi, *cluster);
+	struct buffer_head *bh;
+
+	bh = sb_bread(sb, sect);
+	if (!bh) {
+		exfat_msg(sb, KERN_ERR, "unable to read FAT sector at %llu",
+			  sect);
+		return -EIO;
+	}
+
+	*cluster = __le32_to_cpu(*(u32*)&bh->b_data[off]);
+	brelse(bh);
+	return 0;
+}
+
+/*
+ * setup inode cache
+ */
+void exfat_inode_cache_init(struct inode *inode)
+{
+	mutex_init(&EXFAT_I(inode)->exfat_cache.mutex);
+	EXFAT_I(inode)->exfat_cache.nr_entries = 0;
+	INIT_LIST_HEAD(&EXFAT_I(inode)->exfat_cache.entries);
+}
+
+/*
+ * drop inode cache content
+ */
+void exfat_inode_cache_drop(struct inode *inode)
+{
+	struct exfat_cache *cache = &EXFAT_I(inode)->exfat_cache;
+	struct exfat_cache_entry *e, *tmp;
+
+	mutex_lock(&cache->mutex);
+	list_for_each_entry_safe (e, tmp, &cache->entries, list) {
+		kfree(e);
+	}
+	INIT_LIST_HEAD(&cache->entries);
+	cache->nr_entries = 0;
+	mutex_unlock(&cache->mutex);
+}
+
+/*
+ * move the entry to the head of the list, this will make it less
+ * likely to be the victim in when caching new entries.
+ *
+ * caller must hold cache->mutex.
+ */
+static void __exfat_fat_lru(struct exfat_cache *cache,
+			  struct exfat_cache_entry *e)
+{
+	if (cache->entries.next != &e->list)
+		list_move(&e->list, &cache->entries);
+}
+
+/*
+ * find a cache entry that is close to the wanted fcluster (ideally
+ * spanning over the requested file cluster).
+ *
+ * caller must hold cache->mutex.
+ */
+static struct exfat_cache_entry *__exfat_cache_lookup(struct exfat_cache *cache,
+						      u32 fcluster)
+{
+	struct exfat_cache_entry *e;
+	struct exfat_cache_entry *best = NULL;
+
+	list_for_each_entry (e, &cache->entries, list) {
+		if (e->file_cluster <= fcluster &&
+		    e->file_cluster + e->nr_contig >= fcluster)
+			return e;
+
+		if (!best && e->file_cluster < fcluster)
+			best = e;
+		if (best && best->file_cluster < e->file_cluster &&
+		    e->file_cluster < fcluster)
+			best = e;
+	}
+	return best;
+}
+
+/*
+ * caller must hold cache->mutex.
+ */
+static int __exfat_cache_cluster(struct exfat_cache *cache,
+			       struct exfat_cache_entry *nearest,
+			       u32 fcluster, u32 dcluster)
+{
+	struct exfat_cache_entry *e;
+
+	/*
+	 * see if we can merge with the nearest entry. in the ideal
+	 * case, all cluster in the chain are contiguous, and only
+	 * one entry is needed for a single file.
+	 */
+	if (nearest &&
+	    nearest->file_cluster + nearest->nr_contig + 1 == fcluster &&
+	    nearest->disk_cluster + nearest->nr_contig + 1 == dcluster) {
+		list_move(&nearest->list, &cache->entries);
+		nearest->nr_contig++;
+		return 0;
+	}
+
+	/*
+	 * allocate a new entry or reuse an existing one if the number
+	 * of cached entries is too hihc.
+	 */
+	if (cache->nr_entries < MAX_CACHED_FAT) {
+		e = kmalloc(sizeof (*e), GFP_NOFS);
+		list_add(&e->list, &cache->entries);
+		++cache->nr_entries;
+	} else {
+		e = list_entry(cache->entries.prev, struct exfat_cache_entry,
+			       list);
+		list_move(&e->list, &cache->entries);
+	}
+
+	if (!e)
+		return -ENOMEM;
+
+	e->file_cluster = fcluster;
+	e->disk_cluster = dcluster;
+	e->nr_contig = 0;
+
+	return 0;
+}
+
+int __exfat_get_fat_cluster(struct inode *inode, u32 fcluster, u32 *dcluster,
+			    bool eof_is_fatal)
+{
+	struct exfat_inode_info *info = EXFAT_I(inode);
+	struct exfat_cache *cache = &info->exfat_cache;
+	int error;
+	struct exfat_cache_entry *e;
+	u32 fcluster_start;
+
+	/*
+	 * intial translation: first file cluster is found in the
+	 * inode info.
+	 */
+	if (fcluster == 0) {
+		*dcluster = info->first_cluster;
+		return 0;
+	}
+
+	mutex_lock(&cache->mutex);
+	/*
+	 * try to find a cached entry either covering the file cluster
+	 * we want or at least close to the file cluster.
+	 */
+	e = __exfat_cache_lookup(cache, fcluster);
+	if (e && e->file_cluster <= fcluster &&
+	    e->file_cluster + e->nr_contig >= fcluster) {
+		/*
+		 * perfect match, entry zone covers the requested file
+		 * cluster.
+		 */
+		__exfat_fat_lru(cache, e);
+		*dcluster = e->disk_cluster + (fcluster - e->file_cluster);
+		mutex_unlock(&cache->mutex);
+		return 0;
+	}
+
+	if (e) {
+		/*
+		 * we have an entry, hopefully close enough, setup
+		 * cluster walk from there.
+		 */
+		*dcluster = e->disk_cluster + e->nr_contig;
+		fcluster_start = e->file_cluster + e->nr_contig;
+	} else {
+		/*
+		 * no entry, walk the FAT chain from the start of the
+		 * file.
+		 */
+		fcluster_start = 0;
+		*dcluster = info->first_cluster;
+	}
+
+	/*
+	 * walk fhe FAT chain the number of time required to get the
+	 * disk cluster corresponding to the file cluster.
+	 */
+	while (fcluster_start != fcluster) {
+		error = exfat_next_fat_cluster(inode->i_sb, dcluster);
+		if (error) {
+			mutex_unlock(&cache->mutex);
+			return error;
+		}
+		if (*dcluster == EXFAT_CLUSTER_EOF) {
+			if (eof_is_fatal)
+				/*
+				 * exfat_fill_root uses
+				 * __exfat_get_fat_cluster with
+				 * eof_is_fatal set to false, as the
+				 * root inode does not have a size
+				 * field and thus requires a complete
+				 * FAT walk to compute the size.
+				 */
+				exfat_fs_error(inode->i_sb, "premature EOF in FAT "
+					       "chain. file cluster %u out "
+					       "of %u\n", fcluster_start,
+					       fcluster);
+			mutex_unlock(&cache->mutex);
+			return -EIO;
+		}
+		if (*dcluster < EXFAT_CLUSTER_FIRSTVALID) {
+			exfat_fs_error(inode->i_sb, "invalid cluster %u found "
+				       "in fat chain.", *dcluster);
+			mutex_unlock(&cache->mutex);
+			return -EIO;
+		}
+		++fcluster_start;
+	}
+
+	/*
+	 * cache the result.
+	 */
+	__exfat_cache_cluster(cache, e, fcluster, *dcluster);
+	mutex_unlock(&cache->mutex);
+	return 0;
+}
+
+int exfat_get_fat_cluster(struct inode *inode, u32 fcluster, u32 *dcluster)
+{
+	return __exfat_get_fat_cluster(inode, fcluster, dcluster, true);
+}
+
+int exfat_init_fat(struct super_block *sb)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	struct buffer_head *bh;
+	int error = 0;
+	u32 first, second;
+
+	bh = sb_bread(sb, sbi->fat_offset);
+	if (!bh) {
+		exfat_msg(sb, KERN_ERR, "unable to read FAT sector at %u",
+			  sbi->fat_offset);
+		return -EIO;
+	}
+
+	first = __le32_to_cpu(*(__le32*)(bh->b_data + 0));
+	second = __le32_to_cpu(*(__le32*)(bh->b_data + sizeof (__le32)));
+
+	if (first != 0xf8ffffff && second != 0xffffffff) {
+		exfat_msg(sb, KERN_INFO, "invalid FAT start: %08x, %08x",
+			  first, second);
+		error = -ENXIO;
+	}
+
+	brelse(bh);
+	return error;
+}
+
+/*
+ * fat write context, store the current buffer_head and current
+ * cluster to avoid having sb_bread all the time when the clusters are
+ * contiguous or at least not too far apart.
+ */
+struct fat_write_ctx {
+	struct super_block *sb;
+	struct buffer_head *bh;
+	u32 cur_cluster;
+};
+
+static void fat_init_write_ctx(struct fat_write_ctx *fwctx,
+				struct super_block *sb)
+{
+	memset(fwctx, 0, sizeof (*fwctx));
+	fwctx->sb = sb;
+}
+
+static void fat_exit_write_ctx(struct fat_write_ctx *fwctx)
+{
+	if (fwctx->bh)
+		brelse(fwctx->bh);
+}
+
+static int __fat_write_entry(struct fat_write_ctx *fwctx,
+			       u32 cluster, u32 next)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(fwctx->sb);
+	sector_t current_sector = cluster_sector(sbi, fwctx->cur_cluster);
+	sector_t wanted_sector = cluster_sector(sbi, cluster);
+	off_t off = cluster_offset(sbi, cluster);
+
+	/*
+	 * first see if we need a different buffer head from the
+	 * current one in the fat_write_ctx.
+	 */
+	if (current_sector != wanted_sector || !fwctx->bh) {
+		if (fwctx->bh)
+			brelse(fwctx->bh);
+		fwctx->bh = sb_bread(fwctx->sb, wanted_sector);
+		if (!fwctx->bh) {
+			exfat_msg(fwctx->sb, KERN_ERR,
+				  "unable to read FAT sector at %llu",
+				  wanted_sector);
+			return -EIO;
+		}
+	}
+
+	/*
+	 * set fat cluster to point to the next cluster, and mark bh
+	 * dirty so that the change hits the storage device.
+	 */
+	fwctx->cur_cluster = cluster;
+	*(__le32*)(fwctx->bh->b_data + off) = __cpu_to_le32(next);
+	mark_buffer_dirty(fwctx->bh);
+	return 0;
+}
+
+/*
+ * write nr_clusters contiguous clusters starting at first_cluster.
+ */
+int exfat_write_fat_contiguous(struct inode *inode, u32 first_cluster,
+			       u32 nr_clusters)
+{
+	u32 cluster;
+	struct fat_write_ctx fwctx;
+	int error = 0;
+
+	fat_init_write_ctx(&fwctx, inode->i_sb);
+	for (cluster = first_cluster;
+	     cluster < first_cluster + nr_clusters - 1;
+	     ++cluster) {
+		error = __fat_write_entry(&fwctx, cluster, cluster + 1);
+		if (error)
+			goto end;
+	}
+
+	/*
+	 * set EOF
+	 */
+	error = __fat_write_entry(&fwctx, cluster, EXFAT_CLUSTER_EOF);
+end:
+	fat_exit_write_ctx(&fwctx);
+	return error;
+
+}
+
+/*
+ * write cluster nr_clusters stored in clusters array, link with prev_cluster.
+ */
+int exfat_write_fat(struct inode *inode, u32 prev_cluster, u32 *clusters,
+		    u32 nr_clusters)
+{
+	u32 i;
+	struct fat_write_ctx fwctx;
+	int error;
+
+	if (!nr_clusters)
+		/* ??! */
+		return 0;
+
+	fat_init_write_ctx(&fwctx, inode->i_sb);
+
+	if (prev_cluster) {
+		/*
+		 * link with previous cluster if applicable.
+		 */
+		error = __fat_write_entry(&fwctx, prev_cluster, clusters[0]);
+		if (error)
+			goto end;
+	}
+	for (i = 0; i < nr_clusters - 1; ++i) {
+		error = __fat_write_entry(&fwctx, clusters[i], clusters[i + 1]);
+		if (error)
+			goto end;
+	}
+
+	/*
+	 * set EOF.
+	 */
+	error = __fat_write_entry(&fwctx, clusters[i], EXFAT_CLUSTER_EOF);
+
+ end:
+	fat_exit_write_ctx(&fwctx);
+	return error;
+}
diff -Nruw linux-4.2.6-fbx/fs/exfat./file.c linux-4.2.6-fbx/fs/exfat/file.c
--- linux-4.2.6-fbx/fs/exfat./file.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/file.c	2015-11-18 18:24:32.956173961 +0100
@@ -0,0 +1,427 @@
+/*
+ * file.c for exfat
+ * Created by <nschichan@freebox.fr> on Tue Aug 20 14:39:41 2013
+ */
+
+#include <linux/buffer_head.h>
+#include <linux/fs.h>
+#include <linux/exfat_user.h>
+
+#include "exfat.h"
+#include "exfat_fs.h"
+
+static int append_fragment(struct exfat_fragment __user *ufrag,
+			   struct exfat_fragment *kfrag)
+{
+	if (copy_to_user(ufrag, kfrag, sizeof (*kfrag)))
+		return -EFAULT;
+	return 0;
+}
+
+static void setup_fragment(struct exfat_sb_info *sbi,
+			  struct exfat_fragment *fragment, uint32_t fcluster,
+			  uint32_t dcluster)
+{
+	fragment->fcluster_start = fcluster;
+	fragment->dcluster_start = dcluster;
+	fragment->sector_start = exfat_cluster_sector(sbi, dcluster);
+	fragment->nr_clusters = 1;
+}
+
+static int exfat_ioctl_get_fragments(struct inode *inode,
+				     struct exfat_fragment_head __user *uhead)
+{
+	struct exfat_fragment_head head;
+	struct exfat_fragment fragment;
+	u32 fcluster;
+	u32 prev_dcluster;
+	u32 cur_fragment;
+	struct exfat_inode_info *info = EXFAT_I(inode);
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+	int error;
+
+	memset(&fragment, 0, sizeof (fragment));
+
+	if (copy_from_user(&head, uhead, sizeof (head)))
+		return -EFAULT;
+
+
+	if (put_user(sbi->sectorsize, &uhead->sector_size) ||
+	    put_user(sbi->clustersize, &uhead->cluster_size))
+		return -EFAULT;
+
+	if (!head.nr_fragments) {
+		/*
+		 * user did not provide space for fragments after
+		 * header.
+		 */
+		return 0;
+	}
+
+	if (head.fcluster_start >= info->allocated_clusters) {
+		/*
+		 * requested start cluster is after file EOF
+		 */
+		if (put_user(0, &uhead->nr_fragments))
+			return -EFAULT;
+		return 0;
+	}
+
+	if (info->flags & EXFAT_I_FAT_INVALID) {
+		/*
+		 * not FAT chain, this file has only one fragment.
+		 */
+		fragment.fcluster_start = head.fcluster_start;
+		fragment.dcluster_start =
+			info->first_cluster + head.fcluster_start;
+		fragment.nr_clusters = info->allocated_clusters -
+			head.fcluster_start;
+		fragment.sector_start =
+			exfat_cluster_sector(sbi, fragment.dcluster_start);
+
+		if (copy_to_user(&uhead->fragments[0], &fragment,
+				 sizeof (fragment)))
+			return -EFAULT;
+		if (put_user(1, &uhead->nr_fragments))
+			return -EFAULT;
+		if (put_user(info->first_cluster + info->allocated_clusters,
+			     &uhead->fcluster_start))
+			return -EFAULT;
+		return 0;
+	}
+
+	fcluster = head.fcluster_start;
+	cur_fragment = 0;
+
+	/*
+	 * initial fragment setup
+	 */
+	error = exfat_get_fat_cluster(inode, fcluster,
+				      &prev_dcluster);
+	if (error)
+		return error;
+	setup_fragment(sbi, &fragment, fcluster, prev_dcluster);
+	++fcluster;
+	while (fcluster < info->allocated_clusters) {
+		int error;
+		u32 dcluster;
+
+		/*
+		 * walk one step in the FAT.
+		 */
+		error = exfat_get_fat_cluster(inode, fcluster, &dcluster);
+		if (error)
+			return error;
+
+		if (prev_dcluster == dcluster - 1) {
+			/*
+			 * dcluster and prev_dcluster are contiguous.
+			 */
+			++fragment.nr_clusters;
+		} else {
+			/*
+			 * put this cluster in the user array
+			 */
+			error = append_fragment(&uhead->fragments[cur_fragment],
+						&fragment);
+			if (error)
+				return error;
+
+			++cur_fragment;
+			if (cur_fragment == head.nr_fragments)
+				break;
+
+			/*
+			 * setup a new fragment.
+			 */
+			setup_fragment(sbi, &fragment, fcluster, dcluster);
+		}
+		++fcluster;
+		prev_dcluster = dcluster;
+	}
+
+	if (cur_fragment < head.nr_fragments) {
+		append_fragment(&uhead->fragments[cur_fragment], &fragment);
+		++cur_fragment;
+	}
+
+	/*
+	 * update nr_fragments in user supplied head.
+	 */
+	if (cur_fragment != head.nr_fragments &&
+	    put_user(cur_fragment, &uhead->nr_fragments))
+		return -EFAULT;
+
+	/*
+	 * update fcluster_start in user supplied head.
+	 */
+	if (put_user(fcluster, &uhead->fcluster_start))
+		return -EFAULT;
+
+
+	return 0;
+}
+
+static int exfat_ioctl_get_bitmap(struct super_block *sb,
+				  struct exfat_bitmap_head __user *uhead)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	struct exfat_bitmap_head head;
+	uint32_t i;
+	int error;
+	struct exfat_bitmap_ctx ctx;
+	uint32_t start_cluster;
+
+	if (copy_from_user(&head, uhead, sizeof (head)))
+		return -EFAULT;
+
+	start_cluster = head.start_cluster;
+	if (start_cluster < 2)
+		return -EINVAL;
+
+
+	error = exfat_init_bitmap_context(sb, &ctx, head.start_cluster);
+	if (error)
+		return error;
+	for (i = 0; i < head.nr_entries; ++i) {
+		uint32_t first_in_use;
+		uint32_t nr_in_use;
+		int error;
+
+		error = exfat_test_bitmap(&ctx, start_cluster, &first_in_use,
+					  &nr_in_use);
+		if (error)
+			goto out_error;
+
+		if (first_in_use == sbi->cluster_count)
+			break;
+		if (put_user(first_in_use, &uhead->entries[i].start_cluster))
+			goto out_efault;
+		if (put_user(nr_in_use, &uhead->entries[i].nr_clusters))
+			goto out_efault;
+		if (put_user(exfat_cluster_sector(sbi, first_in_use),
+			     &uhead->entries[i].sector_start))
+			goto out_efault;
+		if (put_user((u64)nr_in_use * sbi->sectors_per_cluster,
+			     &uhead->entries[i].nr_sectors))
+			goto out_efault;
+		start_cluster = first_in_use + nr_in_use + 1;
+	}
+
+	exfat_exit_bitmap_context(&ctx);
+	if (put_user(i, &uhead->nr_entries))
+		return -EFAULT;
+	if (put_user(start_cluster, &uhead->start_cluster))
+		return -EFAULT;
+
+	return 0;
+
+out_efault:
+	error = -EFAULT;
+out_error:
+	exfat_exit_bitmap_context(&ctx);
+	return error;
+}
+
+static int exfat_ioctl_get_dirents(struct inode *inode,
+				   struct exfat_dirent_head __user *uhead)
+{
+	struct exfat_dir_ctx dctx;
+	struct exfat_dirent_head head;
+	int error;
+	uint32_t i;
+
+	if (!S_ISDIR(inode->i_mode))
+		return -ENOTDIR;
+
+	if (copy_from_user(&head, uhead, sizeof (head)))
+		return -EFAULT;
+
+	/* make sure we're aligned on an entry boundary */
+	head.offset &= ~0x1f;
+
+	error = exfat_init_dir_ctx(inode, &dctx, head.offset);
+	if (error < 0)
+		return error;
+
+	error = 0;
+	for (i = 0; i < head.nr_entries; ++i) {
+		bool end;
+		u8 *entry = __exfat_dentry_next(&dctx, 0, 0, false, &end);
+		u8 type;
+
+		if (!entry && end)
+			/* genuine end of file */
+			break;
+		if (!entry) {
+			/* something went wrong */
+			error = -EIO;
+			goto out;
+		}
+		type = *entry;
+
+		if (put_user(type, &uhead->entries[i])) {
+			error = -EFAULT;
+			goto out;
+		}
+	}
+
+	/*
+	 * update head nr_entries and offset.
+	 */
+	if (put_user(i, &uhead->nr_entries))  {
+		error = -EFAULT;
+		goto out;
+	}
+	if (put_user(head.offset + 0x20 * i, &uhead->offset)) {
+		error = -EFAULT;
+		goto out;
+	}
+
+ out:
+	exfat_cleanup_dir_ctx(&dctx);
+	return error;
+}
+
+long exfat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+	case EXFAT_IOCGETFRAGMENTS:
+		return exfat_ioctl_get_fragments(file_inode(file),
+						 (void __user*)arg);
+	case EXFAT_IOCGETBITMAP:
+		return exfat_ioctl_get_bitmap(file_inode(file)->i_sb,
+					      (void __user*)arg);
+	case EXFAT_IOCGETDIRENTS:
+		return exfat_ioctl_get_dirents(file_inode(file),
+					       (void __user*)arg);
+	default:
+		return -ENOTTY;
+	}
+}
+
+static int exfat_cont_expand(struct inode *inode, loff_t newsize)
+{
+	int error;
+
+	error = generic_cont_expand_simple(inode, newsize);
+	if (error)
+		return error;
+
+	inode->i_mtime = CURRENT_TIME_SEC;
+	mark_inode_dirty(inode);
+
+	if (IS_SYNC(inode))
+		exfat_msg(inode->i_sb, KERN_ERR, "TODO: cont_expand with "
+			  "sync mode.");
+	return 0;
+}
+
+int exfat_truncate_blocks(struct inode *inode, loff_t newsize)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+	u32 fcluster = (newsize + sbi->clustersize - 1) >> sbi->clusterbits;
+	int error;
+
+	if (EXFAT_I(inode)->mmu_private > newsize)
+		EXFAT_I(inode)->mmu_private = newsize;
+
+	error = exfat_free_clusters_inode(inode, fcluster);
+	if (error) {
+		exfat_msg(inode->i_sb, KERN_INFO, "exfat_free_clusters_inode: "
+			  "%i", error);
+		return error;
+	}
+
+	return 0;
+}
+
+int exfat_getattr(struct vfsmount *mnt, struct dentry *dentry,
+		  struct kstat *stat)
+{
+	struct inode *inode = dentry->d_inode;
+	generic_fillattr(inode, stat);
+	stat->blksize = EXFAT_SB(inode->i_sb)->clustersize;
+	return 0;
+}
+
+#define EXFAT_VALID_MODE       (S_IFREG | S_IFDIR | S_IRWXUGO)
+
+static int exfat_mode_fixup(struct inode *inode, mode_t *mode)
+{
+	mode_t mask, perm;
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+
+	if (S_ISDIR(*mode))
+		mask = sbi->options.dmask;
+	else
+		mask = sbi->options.fmask;
+
+	perm = *mode & ~(S_IFMT | mask);
+
+	/*
+	 * we want 'r' and 'x' bits when mask allows for it.
+	 */
+	if ((perm & (S_IRUGO | S_IXUGO)) !=
+	    (inode->i_mode & ~mask & (S_IRUGO | S_IXUGO))) {
+		return -EPERM;
+	}
+
+	/*
+	 * we want all 'w' bits or none, depending on mask.
+	 */
+	if ((perm & S_IWUGO) && (perm & S_IWUGO) != (~mask & S_IWUGO))
+		return -EPERM;
+	*mode &= ~mask;
+	return 0;
+}
+
+int exfat_setattr(struct dentry *dentry, struct iattr *attrs)
+{
+	struct inode *inode = dentry->d_inode;
+	int error;
+
+	/*
+	 * can set uid/gid, only if it the same as the current one in
+	 * the inode.
+	 */
+	if (attrs->ia_valid & ATTR_UID &&
+	    !uid_eq(inode->i_uid, attrs->ia_uid))
+		return -EPERM;
+
+	if (attrs->ia_valid & ATTR_GID &&
+	    !gid_eq(inode->i_gid, attrs->ia_gid))
+		return -EPERM;
+
+	if (attrs->ia_valid & ATTR_MODE &&
+	    (attrs->ia_mode & ~EXFAT_VALID_MODE ||
+	     exfat_mode_fixup(inode, &attrs->ia_mode) < 0)) {
+		/*
+		 * silently ignore mode change if we're not OK with
+		 * it (same behavior as vfat).
+		 */
+		attrs->ia_valid &= ~ATTR_MODE;
+	}
+
+	if (attrs->ia_valid & ATTR_SIZE) {
+		inode_dio_wait(inode);
+		if (attrs->ia_size > inode->i_size) {
+			/*
+			 * expand file
+			 */
+			error = exfat_cont_expand(inode, attrs->ia_size);
+			if (error)
+				return error;
+		} else {
+			/*
+			 * shrink file
+			 */
+			truncate_setsize(inode, attrs->ia_size);
+			exfat_truncate_blocks(inode, attrs->ia_size);
+		}
+	}
+
+	setattr_copy(inode, attrs);
+	mark_inode_dirty(inode);
+	return 0;
+}
diff -Nruw linux-4.2.6-fbx/fs/exfat./inode.c linux-4.2.6-fbx/fs/exfat/inode.c
--- linux-4.2.6-fbx/fs/exfat./inode.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/inode.c	2015-11-02 19:00:11.664943203 +0100
@@ -0,0 +1,278 @@
+/*
+ * inode.c<2> for exfat
+ * Created by <nschichan@freebox.fr> on Wed Jul 24 16:15:52 2013
+ */
+
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/slab.h>
+#include <linux/buffer_head.h>
+#include <linux/writeback.h>
+#include <linux/hash.h>
+
+#include "exfat_fs.h"
+#include "exfat.h"
+
+static struct kmem_cache *exfat_inodes_cachep;
+
+/*
+ * inode callbacks.
+ */
+struct inode *exfat_alloc_inode(struct super_block *sb)
+{
+	struct exfat_inode_info *ei = kmem_cache_alloc(exfat_inodes_cachep,
+						       GFP_NOFS);
+
+	if (!ei)
+		return NULL;
+
+	return &ei->vfs_inode;
+}
+
+static void exfat_i_callback(struct rcu_head *head)
+{
+	struct inode *inode = container_of(head, struct inode, i_rcu);
+
+	kmem_cache_free(exfat_inodes_cachep, EXFAT_I(inode));
+}
+
+void exfat_destroy_inode(struct inode *_inode)
+{
+	struct exfat_inode_info *inode = EXFAT_I(_inode);
+
+	call_rcu(&inode->vfs_inode.i_rcu, exfat_i_callback);
+}
+
+static void exfat_inode_init_once(void *ptr)
+{
+	struct exfat_inode_info *info = ptr;
+
+	INIT_HLIST_NODE(&info->hash_list);
+	exfat_inode_cache_init(&info->vfs_inode);
+	inode_init_once(&info->vfs_inode);
+}
+
+/*
+ * inode cache create/destroy.
+ */
+int exfat_init_inodes(void)
+{
+	exfat_inodes_cachep = kmem_cache_create("exfat-inodes",
+				       sizeof (struct exfat_inode_info), 0,
+				       SLAB_RECLAIM_ACCOUNT |SLAB_MEM_SPREAD,
+				       exfat_inode_init_once);
+	if (!exfat_inodes_cachep)
+		return -ENOMEM;
+	return 0;
+}
+
+void exfat_exit_inodes(void)
+{
+	kmem_cache_destroy(exfat_inodes_cachep);
+}
+
+int exfat_drop_inode(struct inode *inode)
+{
+	return generic_drop_inode(inode);
+}
+
+void exfat_evict_inode(struct inode *inode)
+{
+	if (inode->i_data.nrpages)
+		truncate_inode_pages(&inode->i_data, 0);
+	if (!inode->i_nlink) {
+		inode->i_size = 0;
+		exfat_free_clusters_inode(inode, 0);
+	}
+	invalidate_inode_buffers(inode);
+	clear_inode(inode);
+	exfat_remove_inode_hash(inode);
+	exfat_inode_cache_drop(inode);
+}
+
+static u32 exfat_hash(loff_t disk_pos)
+{
+	return hash_32(disk_pos, EXFAT_HASH_BITS);
+}
+
+struct inode *exfat_iget(struct super_block *sb, loff_t disk_pos)
+{
+	struct exfat_inode_info *info;
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	struct hlist_head *head = sbi->inode_hash + exfat_hash(disk_pos);
+	struct inode *ret = NULL;
+
+
+	spin_lock(&sbi->inode_hash_lock);
+	hlist_for_each_entry (info, head, hash_list) {
+		if (info->iloc.disk_offs[0] != disk_pos)
+			continue ;
+		ret = igrab(&info->vfs_inode);
+		if (ret)
+			break;
+	}
+	spin_unlock(&sbi->inode_hash_lock);
+	return ret;
+}
+
+void exfat_insert_inode_hash(struct inode *inode)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+	struct exfat_inode_info *info = EXFAT_I(inode);
+	struct hlist_head *head = sbi->inode_hash +
+		exfat_hash(info->iloc.disk_offs[0]);
+
+	spin_lock(&sbi->inode_hash_lock);
+	hlist_add_head(&info->hash_list, head);
+	spin_unlock(&sbi->inode_hash_lock);
+}
+
+void exfat_remove_inode_hash(struct inode *inode)
+{
+	struct exfat_inode_info *info = EXFAT_I(inode);
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+
+	spin_lock(&sbi->inode_hash_lock);
+	info->iloc.disk_offs[0] = 0;
+	hlist_del_init(&info->hash_list);
+	spin_unlock(&sbi->inode_hash_lock);
+}
+
+/*
+ * calculate the number of links in a directory. this is the number of
+ * EXFAT_FILEDIR_ENTRY typed elements in the directory stream. This
+ * does not include the '.' and '..' entries.
+ */
+loff_t exfat_dir_links(struct inode *inode)
+{
+	size_t ret = 0;
+	struct exfat_dir_ctx dctx;
+	int error;
+	bool end;
+
+	error = exfat_init_dir_ctx(inode, &dctx, 0);
+	if (error)
+		return error;
+
+	error = -EIO;
+	for (;;) {
+		struct exfat_filedir_entry *e =
+			__exfat_dentry_next(&dctx, E_EXFAT_FILEDIR, 0xff,
+					    true, &end);
+		if (!e) {
+			if (end)
+				error = 0;
+			goto out;
+		}
+		++ret;
+	}
+out:
+	exfat_cleanup_dir_ctx(&dctx);
+	if (error)
+		return error;
+	return ret;
+}
+
+int exfat_get_cluster_hint(struct inode *inode, u32 *out_hint)
+{
+	struct exfat_inode_info *info = EXFAT_I(inode);
+	int error;
+	u32 first_cluster = info->first_cluster;
+
+
+	if (!first_cluster) {
+		/*
+		 * empty file, return a cluster likely to be free.
+		 */
+		*out_hint = EXFAT_SB(inode->i_sb)->prev_free_cluster + 2;
+		return 0;
+	}
+
+	if (info->flags & EXFAT_I_FAT_INVALID) {
+		/*
+		 * not fat run, all clusters are contiguous, set hint
+		 * to next last file cluster.
+		 */
+		*out_hint = first_cluster + info->allocated_clusters;
+		return 0;
+	}
+
+	/*
+	 * fat run available, walk it to get the last physical cluster
+	 * address and set hint to the immediate next physical
+	 * cluster.
+	 */
+	error = exfat_get_fat_cluster(inode, info->allocated_clusters - 1,
+				      out_hint);
+	if (error)
+		return error;
+	(*out_hint)++;
+	return 0;
+}
+
+int __exfat_write_inode(struct inode *inode, bool sync)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+	struct exfat_inode_info *info = EXFAT_I(inode);
+	struct dir_entry_buffer entries[info->iloc.nr_secondary];
+	int error;
+	struct exfat_filedir_entry *efd;
+	struct exfat_stream_extension_entry *esx;
+	u16 checksum;
+
+	if (inode->i_ino == EXFAT_ROOT_INO)
+		return 0;
+
+	if (info->iloc.disk_offs[0] == 0) {
+		/*
+		 * write_inode() to unlinked inode: don't corrupt
+		 * superblock.
+		 */
+		return 0;
+	}
+
+	error = exfat_get_dir_entry_buffers(inode, &info->iloc,
+					    entries, info->iloc.nr_secondary);
+	if (error)
+		return error;
+
+	if (inode->i_mode & S_IWUGO)
+		info->attributes &= ~E_EXFAT_ATTR_RO;
+	else
+		info->attributes |= E_EXFAT_ATTR_RO;
+
+	efd = entries[0].start;
+	esx = entries[1].start;
+
+	efd->attributes = __cpu_to_le16(info->attributes);
+	esx->data_length = __cpu_to_le64(inode->i_size);
+	esx->valid_data_length = esx->data_length =
+		__cpu_to_le64(inode->i_size);
+	esx->flags = info->flags;
+	esx->first_cluster = __cpu_to_le32(info->first_cluster);
+
+	exfat_write_time(sbi, &inode->i_ctime, &efd->create, &efd->create_10ms,
+			 &efd->create_tz_offset);
+	exfat_write_time(sbi, &inode->i_mtime, &efd->modified,
+			 &efd->modified_10ms, &efd->modified_tz_offset);
+	exfat_write_time(sbi, &inode->i_atime, &efd->accessed, NULL,
+			 &efd->accessed_tz_offset);
+
+	checksum = exfat_dir_entries_checksum(entries, info->iloc.nr_secondary);
+	efd->set_checksum = __cpu_to_le16(checksum);
+
+	exfat_dirty_dir_entries(entries, info->iloc.nr_secondary, sync);
+
+
+	return 0;
+}
+
+int exfat_write_inode(struct inode *inode, struct writeback_control *wbc)
+{
+	int ret;
+
+	exfat_lock_super(inode->i_sb);
+	ret = __exfat_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL);
+	exfat_unlock_super(inode->i_sb);
+	return ret;
+}
diff -Nruw linux-4.2.6-fbx/fs/exfat./Kconfig linux-4.2.6-fbx/fs/exfat/Kconfig
--- linux-4.2.6-fbx/fs/exfat./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/Kconfig	2015-11-02 19:00:10.348932830 +0100
@@ -0,0 +1,3 @@
+
+config EXFAT_FS
+	tristate "exFAT fs support"
diff -Nruw linux-4.2.6-fbx/fs/exfat./Makefile linux-4.2.6-fbx/fs/exfat/Makefile
--- linux-4.2.6-fbx/fs/exfat./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/Makefile	2015-11-02 19:00:10.348932830 +0100
@@ -0,0 +1,13 @@
+
+obj-$(CONFIG_EXFAT_FS)	+= exfat.o
+
+exfat-y	= super.o				\
+	inode.o					\
+	fat.o					\
+	read-write.o				\
+	upcase.o				\
+	bitmap.o				\
+	time.o					\
+	dir.o					\
+	namei.o					\
+	file.o
diff -Nruw linux-4.2.6-fbx/fs/exfat./namei.c linux-4.2.6-fbx/fs/exfat/namei.c
--- linux-4.2.6-fbx/fs/exfat./namei.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/namei.c	2015-11-02 19:00:12.312948311 +0100
@@ -0,0 +1,924 @@
+/*
+ * namei.c for exfat
+ * Created by <nschichan@freebox.fr> on Tue Aug 20 12:00:27 2013
+ */
+
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/buffer_head.h>
+#include <linux/nls.h>
+
+#include "exfat.h"
+#include "exfat_fs.h"
+
+static u16 exfat_filename_hash_cont(struct super_block *sb,
+				    const __le16 *name, u16 hash, size_t len);
+
+
+void exfat_write_time(struct exfat_sb_info *sbi, struct timespec *ts,
+		      __le32 *datetime, u8 *time_cs, u8 *tz_offset)
+{
+	u32 cpu_datetime;
+
+	exfat_time_2exfat(sbi, ts, &cpu_datetime, time_cs, tz_offset);
+	*datetime = __cpu_to_le32(cpu_datetime);
+}
+
+static void exfat_read_time(struct timespec *ts, __le32 datetime, u8 time_cs,
+			    u8 tz_offset)
+{
+	u32 cpu_datetime = __le32_to_cpu(datetime);
+	exfat_time_2unix(ts, cpu_datetime, time_cs, tz_offset);
+}
+
+static int exfat_zero_cluster(struct super_block *sb, u32 cluster, bool sync)
+{
+	sector_t start = exfat_cluster_sector(EXFAT_SB(sb), cluster);
+	sector_t end = start + EXFAT_SB(sb)->sectors_per_cluster;
+	sector_t sect;
+
+	for (sect = start; sect < end; ++sect) {
+		struct buffer_head *bh = sb_bread(sb, sect);
+		if (!bh) {
+			exfat_msg(sb, KERN_WARNING,
+				  "unable to read sector %llu for zeroing.",
+				  sect);
+			return -EIO;
+		}
+		memset(bh->b_data, 0, bh->b_size);
+		mark_buffer_dirty(bh);
+		if (sync)
+			sync_dirty_buffer(bh);
+		brelse(bh);
+	}
+	return 0;
+}
+
+/*
+ * use per superblock fmask or dmaks, depending on provided entry
+ * attribute to restrict the provided mode even more.
+ */
+mode_t exfat_make_mode(struct exfat_sb_info *sbi, mode_t mode, u16 attrs)
+{
+	if (attrs & E_EXFAT_ATTR_DIRECTORY)
+		mode = (mode & ~sbi->options.dmask) | S_IFDIR;
+	else
+		mode = (mode & ~sbi->options.fmask) | S_IFREG;
+	if (attrs & E_EXFAT_ATTR_RO)
+		mode &= ~S_IWUGO;
+	return mode;
+}
+
+/*
+ * populate inode fields.
+ */
+static struct inode *exfat_populate_inode(struct super_block *sb,
+			  const struct exfat_filedir_entry *efd,
+			  const struct exfat_stream_extension_entry *esx,
+			  const struct exfat_iloc *iloc)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	struct inode *inode;
+
+	inode = exfat_iget(sb, iloc->disk_offs[0]);
+	if (inode)
+		return inode;
+
+	inode = new_inode(sb);
+	if (!inode)
+		return NULL;
+
+	inode->i_ino = iunique(sb, EXFAT_ROOT_INO);
+	EXFAT_I(inode)->first_cluster = __le32_to_cpu(esx->first_cluster);
+	EXFAT_I(inode)->flags = esx->flags;
+	EXFAT_I(inode)->iloc = *iloc;
+	EXFAT_I(inode)->attributes = __le16_to_cpu(efd->attributes);
+
+	inode->i_size = __le64_to_cpu(esx->data_length);
+	EXFAT_I(inode)->allocated_clusters = inode->i_size >> sbi->clusterbits;
+	if (inode->i_size & sbi->clustermask)
+		EXFAT_I(inode)->allocated_clusters++;
+	inode->i_blocks = EXFAT_I(inode)->allocated_clusters <<
+		(sbi->clusterbits - 9);
+	EXFAT_I(inode)->mmu_private = inode->i_size;
+
+	inode->i_uid = sbi->options.uid;
+	inode->i_gid = sbi->options.gid;
+	inode->i_mode = exfat_make_mode(sbi, S_IRWXUGO,
+					EXFAT_I(inode)->attributes);
+
+	if (EXFAT_I(inode)->attributes & E_EXFAT_ATTR_DIRECTORY) {
+		loff_t nlinks = exfat_dir_links(inode);
+		if (nlinks < 0)
+			goto iput;
+		set_nlink(inode, nlinks + 2);
+	} else
+		set_nlink(inode, 1);
+
+	if (esx->data_length != esx->valid_data_length)
+		exfat_msg(sb, KERN_WARNING, "data length (%llu) != valid data "
+			  "length (%llu)", __le64_to_cpu(esx->data_length),
+			  __le64_to_cpu(esx->valid_data_length));
+
+	if (S_ISDIR(inode->i_mode)) {
+		inode->i_fop = &exfat_dir_operations;
+		inode->i_op = &exfat_dir_inode_operations;
+	} else {
+		/* until we support write */
+		inode->i_fop = &exfat_file_operations;
+		inode->i_op = &exfat_file_inode_operations;
+		inode->i_data.a_ops = &exfat_address_space_operations;
+	}
+
+
+	exfat_read_time(&inode->i_ctime, efd->create, efd->create_10ms,
+			efd->create_tz_offset);
+	exfat_read_time(&inode->i_mtime, efd->modified, efd->modified_10ms,
+			efd->modified_tz_offset);
+	exfat_read_time(&inode->i_atime, efd->accessed, 0,
+			efd->accessed_tz_offset);
+
+	exfat_insert_inode_hash(inode);
+	insert_inode_hash(inode);
+	return inode;
+iput:
+	iput(inode);
+	return NULL;
+}
+
+/*
+ * lookup an inode.
+ */
+struct dentry *exfat_inode_lookup(struct inode *parent, struct dentry *dentry,
+				  unsigned int flags)
+{
+	struct super_block *sb = dentry->d_sb;
+	struct exfat_dir_ctx dctx;
+	int error;
+	struct exfat_filedir_entry efd;
+	struct exfat_stream_extension_entry esx;
+	__le16 *name = __getname();
+	__le16 *utf16_name = __getname();
+	unsigned int utf16_name_length;
+	__le16 name_hash;
+
+	exfat_lock_super(parent->i_sb);
+
+	if (!name || !utf16_name) {
+		error = -ENOMEM;
+		goto putnames;
+	}
+
+	utf16_name_length = utf8s_to_utf16s(dentry->d_name.name,
+					    dentry->d_name.len,
+					    UTF16_LITTLE_ENDIAN,
+					    utf16_name, 255 + 2);
+	if (utf16_name_length > 255) {
+		error = -ENAMETOOLONG;
+		goto putnames;
+	}
+
+	/*
+	 * get the name hash of the wanted inode early so that we can
+	 * skip entries with only an efd and an esx entry.
+	 */
+	name_hash = __cpu_to_le16(exfat_filename_hash_cont(sb, utf16_name, 0,
+							   utf16_name_length));
+
+	/*
+	 * create a dir ctx from the parent so that we can iterate on
+	 * it.
+	 */
+	error = exfat_init_dir_ctx(parent, &dctx, 0);
+	if (error)
+		goto putnames;
+
+	for (;;) {
+		u32 name_length;
+		struct inode *inode;
+		u16 calc_checksum;
+		u16 expect_checksum;
+		struct exfat_iloc iloc;
+
+		memset(&iloc, 0, sizeof (iloc));
+		/*
+		 * get filedir and stream extension entries.
+		 */
+		error = exfat_dentry_next(&efd, &dctx, E_EXFAT_FILEDIR, true);
+		if (error < 0)
+			/* end of directory reached, or other error */
+			goto cleanup;
+
+		error = -EINVAL;
+		if (efd.secondary_count > 18)
+			goto cleanup;
+
+		iloc.file_off = exfat_dctx_fpos(&dctx);
+		iloc.disk_offs[0] = exfat_dctx_dpos(&dctx);
+		iloc.nr_secondary = efd.secondary_count + 1;
+
+		error = exfat_dentry_next(&esx, &dctx, E_EXFAT_STREAM_EXT,
+					  false);
+		if (error)
+			goto cleanup;
+
+		if (esx.name_hash != name_hash)
+			/*
+			 * stored name hash is not the same as the
+			 * wanted hash: no point in processing the
+			 * remaining entries for the current efd/esx
+			 * any further.
+			 */
+			continue ;
+
+		/*
+		 * now that the hash matches it is ok to update the
+		 * checksum for the efd and esx entries.
+		 */
+		expect_checksum = __le16_to_cpu(efd.set_checksum);
+		calc_checksum = exfat_direntry_checksum(&efd, 0, true);
+
+		calc_checksum = exfat_direntry_checksum(&esx,
+							calc_checksum, false);
+		iloc.disk_offs[1] = exfat_dctx_dpos(&dctx);
+
+		/*
+		 * fetch name.
+		 */
+		name_length = esx.name_length;
+		error = __exfat_get_name(&dctx, name_length, name,
+					 &calc_checksum, &iloc);
+		if (error)
+			goto cleanup;
+
+		if (calc_checksum != expect_checksum) {
+			exfat_msg(dctx.sb, KERN_INFO, "checksum: "
+				  "calculated %04x, expect %04x",
+				  calc_checksum, expect_checksum);
+			error = -EIO;
+			goto cleanup;
+		}
+
+
+		if (utf16_name_length != name_length)
+			continue ;
+
+		if (memcmp(utf16_name, name, name_length * sizeof (__le16)))
+			continue ;
+
+		inode = exfat_populate_inode(sb, &efd, &esx, &iloc);
+		if (inode) {
+			d_add(dentry, inode);
+			error = 0;
+		} else
+			error = -EIO;
+		goto cleanup;
+	}
+
+cleanup:
+	exfat_cleanup_dir_ctx(&dctx);
+putnames:
+	if (name)
+		__putname(name);
+	if (utf16_name)
+		__putname(utf16_name);
+	exfat_unlock_super(parent->i_sb);
+	if (error && error != -ENOENT)
+		return ERR_PTR(error);
+	return NULL;
+}
+
+/*
+ * find nr unused directory entries (type & 0x80 == 0).
+ */
+static int exfat_find_dir_iloc(struct inode *inode, int nr,
+			       struct exfat_iloc *iloc)
+{
+	struct exfat_dir_ctx dctx;
+	bool end = false;
+	int error;
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+	u32 nr_new_clusters, i;
+	u32 new_clusters[2];
+	u32 hint_cluster;
+
+retry:
+	memset(iloc, 0, sizeof (*iloc));
+	iloc->nr_secondary = nr;
+
+	error = exfat_init_dir_ctx(inode, &dctx, 0);
+	if (error)
+		return error;
+
+	while (1) {
+		int nr_free;
+		void *ent;
+
+		ent = __exfat_dentry_next(&dctx, 0x00, 0x80, true, &end);
+		if (end)
+			break;
+		if (!ent) {
+			exfat_cleanup_dir_ctx(&dctx);
+			return -EIO;
+		}
+
+		nr_free = 1;
+		iloc->file_off = exfat_dctx_fpos(&dctx);
+		iloc->disk_offs[0] = exfat_dctx_dpos(&dctx);
+		while (__exfat_dentry_next(&dctx, 0x00, 0x80, false, &end)
+		       != NULL && nr_free < nr) {
+			iloc->disk_offs[nr_free] = exfat_dctx_dpos(&dctx);
+			++nr_free;
+		}
+		if (nr_free == nr) {
+			/*
+			 * we found enough consecutive free entries.
+			 */
+			exfat_cleanup_dir_ctx(&dctx);
+			return 0;
+		}
+
+	}
+
+	/*
+	 * not enough consecutive free entries found, kick the cluster
+	 * allocator and retry.
+	 */
+	exfat_cleanup_dir_ctx(&dctx);
+
+	/*
+	 * with the smallest cluster size, a file can take more than
+	 * two clusters. allocate two in that case reardless of what
+	 * is needed to make code simplier.
+	 */
+	switch (sbi->clustersize) {
+	case 512:
+		nr_new_clusters = 2;
+		break;
+	default:
+		nr_new_clusters = 1;
+		break;
+	}
+
+	/*
+	 * get a hint cluster for the cluster allocator.
+	 */
+	error = exfat_get_cluster_hint(inode, &hint_cluster);
+	if (error)
+		return error;
+
+	/*
+	 * peform the allocation.
+	 */
+	error = exfat_alloc_clusters(inode, hint_cluster, new_clusters,
+				     nr_new_clusters);
+	if (error)
+		return error;
+
+	/*
+	 * fill new cluster(s) with zero.
+	 */
+	for (i = 0; i < nr_new_clusters; ++i)
+		exfat_zero_cluster(inode->i_sb, new_clusters[i], false);
+
+	/*
+	 * update size and mark inode as dirty so that write_inode()
+	 * can update it's size, and the other fields updated by
+	 * exfat_alloc_clusters.
+	 */
+	inode->i_size += nr_new_clusters << sbi->clusterbits;
+	mark_inode_dirty(inode);
+
+	/*
+	 * kick the whole place search again, this time with the newly
+	 * allocated clusters.
+	 */
+	goto retry;
+}
+
+/*
+ * setup dir_entry_buffers starting at using iloc.
+ */
+int exfat_get_dir_entry_buffers(struct inode *dir, struct exfat_iloc *iloc,
+				struct dir_entry_buffer *entries,
+				size_t nr_entries)
+{
+	size_t i;
+	int error;
+	struct exfat_sb_info *sbi = EXFAT_SB(dir->i_sb);
+
+	BUG_ON(iloc->nr_secondary != nr_entries);
+
+	memset(entries, 0, sizeof (*entries) * nr_entries);
+	for (i = 0; i < nr_entries; ++i) {
+		sector_t sector = iloc->disk_offs[i] >> sbi->sectorbits;
+
+		entries[i].off = iloc->disk_offs[i] & sbi->sectormask;
+		entries[i].bh = sb_bread(dir->i_sb, sector);
+		if (!entries[i].bh) {
+			error = -EIO;
+			goto fail;
+		}
+		entries[i].start = entries[i].bh->b_data + entries[i].off;
+	}
+	return 0;
+
+fail:
+	for (i = 0; i < nr_entries; ++i)
+		if (entries[i].bh)
+			brelse(entries[i].bh);
+	return error;
+}
+
+static u16 exfat_filename_hash_cont(struct super_block *sb,
+				    const __le16 *name, u16 hash, size_t len)
+{
+	while (len) {
+		u16 c = __le16_to_cpu(exfat_upcase_convert(sb, *name));
+
+		hash = ((hash << 15) | (hash >> 1)) + (c & 0xff);
+		hash = ((hash << 15) | (hash >> 1)) + (c >> 8);
+		--len;
+		++name;
+	}
+	return hash;
+}
+
+u16 exfat_dir_entries_checksum(struct dir_entry_buffer *entries, u32 nr)
+{
+	u32 checksum = 0;
+
+	if (nr) {
+		checksum = exfat_direntry_checksum(entries->start,
+						   checksum, true);
+		--nr;
+		++entries;
+	}
+	while (nr) {
+		checksum = exfat_direntry_checksum(entries->start,
+						   checksum, false);
+		--nr;
+		++entries;
+	}
+	return checksum;
+}
+
+/*
+ * setup exfat_filedir_entry and exfat_stream_extension_entry for a
+ * new entry, with attribute attrs, and named name.
+ */
+static void exfat_fill_dir_entries(struct super_block *sb,
+				  struct dir_entry_buffer *entries,
+				  size_t nr_entries, u8 attrs,
+				  __le16 *name, int name_length)
+{
+	struct exfat_filedir_entry *efd;
+	struct exfat_stream_extension_entry *esx;
+	int i;
+	u16 name_hash;
+	u16 checksum;
+	struct timespec ts = CURRENT_TIME_SEC;
+
+	efd = entries[0].start;
+	esx = entries[1].start;
+
+	/*
+	 * fill exfat filedir entry
+	 */
+	memset(efd, 0, sizeof (*efd));
+	efd->type = E_EXFAT_FILEDIR;
+	efd->secondary_count = nr_entries - 1;
+	efd->set_checksum = 0;
+	efd->attributes = __cpu_to_le16(attrs);
+
+	/*
+	 * update file directory entry times
+	 */
+	efd = entries[0].start;
+	exfat_write_time(EXFAT_SB(sb), &ts, &efd->create, &efd->create_10ms,
+			 &efd->create_tz_offset);
+	efd->modified = efd->accessed = efd->create;
+	efd->modified_10ms = efd->create_10ms;
+	efd->accessed_tz_offset = efd->modified_tz_offset =
+		efd->create_tz_offset;
+
+	/*
+	 * fill exfat stream extension entry
+	 */
+	memset(esx, 0, sizeof (*esx));
+	esx->type = E_EXFAT_STREAM_EXT;
+	esx->flags = EXFAT_I_ALLOC_POSSIBLE;
+	esx->first_cluster = __cpu_to_le32(0);
+	esx->data_length = __cpu_to_le64(0);
+	esx->valid_data_length = __cpu_to_le64(0);
+	esx->name_length = name_length;
+
+	/*
+	 * fill name fragments.
+	 */
+	name_hash = 0;
+	for (i = 0; i < nr_entries - 2; ++i, name_length -= 15) {
+		struct exfat_filename_entry *efn = entries[i + 2].start;
+		int len = 15;
+
+		if (name_length < 15)
+			len = name_length;
+
+		memset(efn, 0, sizeof (*efn));
+		efn->type = E_EXFAT_FILENAME;
+		memcpy(efn->name_frag, name + i * 15, len * sizeof (__le16));
+		name_hash = exfat_filename_hash_cont(sb, efn->name_frag,
+						     name_hash, len);
+	}
+	esx->name_hash = __cpu_to_le16(name_hash);
+
+	checksum = exfat_dir_entries_checksum(entries, nr_entries);
+	efd->set_checksum = __cpu_to_le16(checksum);
+}
+
+/*
+ * mark all buffer heads in the entries array as dirty. optionally
+ * sync them if required.
+ */
+void exfat_dirty_dir_entries(struct dir_entry_buffer *entries,
+			     size_t nr_entries, bool sync)
+{
+	size_t i;
+
+	for (i = 0; i < nr_entries; ++i) {
+		mark_buffer_dirty(entries[i].bh);
+		if (sync)
+			sync_dirty_buffer(entries[i].bh);
+		brelse(entries[i].bh);
+	}
+}
+
+/*
+ * cleanup all buffer heads in entries.
+ */
+static void exfat_cleanup_dir_entries(struct dir_entry_buffer *entries,
+				     size_t nr_entries)
+{
+	size_t i;
+
+	for (i = 0; i < nr_entries; ++i)
+		brelse(entries[i].bh);
+}
+
+/*
+ * create an inode
+ */
+static int __exfat_inode_create(struct inode *dir, struct dentry *dentry,
+				umode_t mode, bool is_dir)
+{
+	int nr_entries;
+	struct dir_entry_buffer entries[19];
+	struct inode *new;
+	struct exfat_iloc iloc;
+	int error;
+	u8 attr = 0;
+	__le16 *utf16_name;
+	int utf16_name_length;
+
+	if (is_dir)
+		attr |= E_EXFAT_ATTR_DIRECTORY;
+
+	exfat_lock_super(dir->i_sb);
+
+	utf16_name = __getname();
+	if (!utf16_name) {
+		error = -ENOMEM;
+		goto unlock_super;
+	}
+
+	utf16_name_length = utf8s_to_utf16s(dentry->d_name.name,
+					    dentry->d_name.len,
+					    UTF16_LITTLE_ENDIAN, utf16_name,
+					    255 + 2);
+	if (utf16_name_length < 0) {
+		error = utf16_name_length;
+		goto putname;
+	}
+	if (utf16_name_length > 255) {
+		error = -ENAMETOOLONG;
+		goto putname;
+	}
+
+
+	nr_entries = 2 + DIV_ROUND_UP(utf16_name_length, 15);
+	if (nr_entries > 19) {
+		error = -ENAMETOOLONG;
+		goto putname;
+	}
+
+	error = exfat_find_dir_iloc(dir, nr_entries, &iloc);
+	if (error < 0)
+		goto putname;
+
+	error = exfat_get_dir_entry_buffers(dir, &iloc, entries, nr_entries);
+	if (error)
+		goto putname;
+	exfat_fill_dir_entries(dir->i_sb, entries, nr_entries, attr,
+				       utf16_name, utf16_name_length);
+
+	/*
+	 * create an inode with it.
+	 */
+	error = -ENOMEM;
+	new = exfat_populate_inode(dir->i_sb, entries[0].start,
+				   entries[1].start, &iloc);
+	if (!new)
+		goto cleanup;
+	inc_nlink(dir);
+	d_instantiate(dentry, new);
+
+	/*
+	 * update directory atime / ctime.
+	 */
+	dir->i_atime = dir->i_mtime = CURRENT_TIME_SEC;
+	if (IS_DIRSYNC(dir))
+		__exfat_write_inode(dir, true);
+	else
+		mark_inode_dirty(dir);
+
+	/*
+	 * write to disk
+	 */
+	exfat_dirty_dir_entries(entries, nr_entries, false);
+	__putname(utf16_name);
+	exfat_unlock_super(dir->i_sb);
+	return 0;
+
+cleanup:
+	exfat_cleanup_dir_entries(entries, nr_entries);
+putname:
+	__putname(utf16_name);
+unlock_super:
+	exfat_unlock_super(dir->i_sb);
+	return error;
+}
+
+int exfat_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode,
+		       bool excl)
+{
+	return __exfat_inode_create(dir, dentry, mode, false);
+}
+
+int exfat_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
+{
+	return __exfat_inode_create(dir, dentry, mode, true);
+}
+
+/*
+ * inode unlink: find all direntry buffers and clear seventh bit of
+ * the entry type to mark the as unused.
+ */
+static int __exfat_inode_unlink(struct inode *dir, struct dentry *dentry)
+{
+	struct inode *inode = dentry->d_inode;
+	struct exfat_inode_info *info = EXFAT_I(inode);
+	struct dir_entry_buffer entries[info->iloc.nr_secondary];
+	int error;
+	u32 i;
+
+	error = exfat_get_dir_entry_buffers(inode, &info->iloc,
+					    entries, info->iloc.nr_secondary);
+	if (error)
+		return error;
+
+	for (i = 0; i < info->iloc.nr_secondary; ++i) {
+		u8 *type = entries[i].start;
+
+		*type &= 0x7f;
+	}
+
+	drop_nlink(dir);
+	clear_nlink(inode);
+	inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
+
+	/*
+	 * update atime & mtime for parent directory.
+	 */
+	dir->i_mtime = dir->i_atime = CURRENT_TIME_SEC;
+	if (IS_DIRSYNC(dir))
+		__exfat_write_inode(dir, true);
+	else
+		mark_inode_dirty(dir);
+
+	exfat_dirty_dir_entries(entries, info->iloc.nr_secondary, false);
+	exfat_remove_inode_hash(inode);
+	return 0;
+}
+
+int exfat_inode_unlink(struct inode *dir, struct dentry *dentry)
+{
+	int ret;
+
+	exfat_lock_super(dir->i_sb);
+	ret = __exfat_inode_unlink(dir, dentry);
+	exfat_unlock_super(dir->i_sb);
+	return ret;
+}
+
+/*
+ * inode rmdir: check that links is not greater than 2 (meaning that
+ * the directory is empty) and invoke unlink.
+ */
+static int __exfat_inode_rmdir(struct inode *dir, struct dentry *dentry)
+{
+	struct inode *inode = dentry->d_inode;
+
+	if (inode->i_nlink > 2)
+		return -ENOTEMPTY;
+
+	return __exfat_inode_unlink(dir, dentry);
+}
+
+int exfat_inode_rmdir(struct inode *dir, struct dentry *dentry)
+{
+	int ret;
+
+	exfat_lock_super(dir->i_sb);
+	ret = __exfat_inode_rmdir(dir, dentry);
+	exfat_unlock_super(dir->i_sb);
+	return ret;
+}
+
+int exfat_rename(struct inode *old_dir, struct dentry *old_dentry,
+		 struct inode *new_dir, struct dentry *new_dentry)
+{
+	struct inode *old_inode = old_dentry->d_inode;
+	struct inode *new_inode = new_dentry->d_inode;
+	int new_nr_entries;
+	int error = 0;
+	struct exfat_iloc new_iloc;
+	struct exfat_inode_info *old_info = EXFAT_I(old_inode);
+	struct dir_entry_buffer old_buffers[old_info->iloc.nr_secondary];
+	struct dir_entry_buffer new_buffers[19];
+	struct exfat_filedir_entry *efd;
+	struct exfat_stream_extension_entry *esx;
+	int name_length;
+	__le16 *name;
+	u16 name_hash;
+	int i;
+
+	exfat_lock_super(new_dir->i_sb);
+
+	/*
+	 * convert new name to utf16
+	 */
+	name = __getname();
+	if (!name) {
+		error = -ENOMEM;
+		goto unlock_super;
+	}
+	name_length = utf8s_to_utf16s(new_dentry->d_name.name,
+				      new_dentry->d_name.len,
+				      UTF16_LITTLE_ENDIAN, name, 255 + 2);
+
+	if (name_length > 255) {
+		error = -ENAMETOOLONG;
+		goto err_putname;
+	}
+	if (name_length < 0) {
+		error = name_length;
+		goto err_putname;
+	}
+
+	new_nr_entries = 2 + DIV_ROUND_UP(name_length, 15);
+
+	/*
+	 * find space for new entry
+	 */
+	error = exfat_find_dir_iloc(new_dir, new_nr_entries, &new_iloc);
+	if (error < 0)
+		goto err_putname;
+
+	/*
+	 * get buffers for old and new entries.
+	 */
+	error = exfat_get_dir_entry_buffers(old_dir, &old_info->iloc,
+				    old_buffers, old_info->iloc.nr_secondary);
+	if (error < 0)
+		goto err_putname;
+
+	error = exfat_get_dir_entry_buffers(new_dir, &new_iloc, new_buffers,
+					    new_nr_entries);
+	if (error < 0)
+		goto err_cleanup_old_buffers;
+
+
+	/*
+	 * remove new inode, if it exists.
+	 */
+	if (new_inode) {
+		if (S_ISDIR(new_inode->i_mode))
+			error = __exfat_inode_rmdir(new_dir, new_dentry);
+		else
+			error = __exfat_inode_unlink(new_dir, new_dentry);
+		if (error < 0)
+			goto err_cleanup_new_buffers;
+	}
+
+	/*
+	 * move old esd to new esd (and ditto for esx).
+	 */
+	efd = new_buffers[0].start;
+	esx = new_buffers[1].start;
+	memcpy(efd, old_buffers[0].start, sizeof (*efd));
+	memcpy(esx, old_buffers[1].start, sizeof (*esx));
+
+	efd->secondary_count = new_nr_entries - 1;
+
+	/*
+	 * patch new name after that.
+	 */
+	esx->name_length = __cpu_to_le16(name_length);
+
+	/*
+	 * fill name fragments.
+	 */
+	name_hash = 0;
+	for (i = 0; i < new_nr_entries - 2; ++i, name_length -= 15) {
+		struct exfat_filename_entry *efn = new_buffers[i + 2].start;
+		int len = 15;
+
+		if (name_length < 15)
+			len = name_length;
+
+		memset(efn, 0, sizeof (*efn));
+		efn->type = E_EXFAT_FILENAME;
+		memcpy(efn->name_frag, name + i * 15, len * sizeof (__le16));
+		name_hash = exfat_filename_hash_cont(new_dir->i_sb,
+						     efn->name_frag,
+						     name_hash, len);
+	}
+	__putname(name);
+	esx->name_hash = __cpu_to_le16(name_hash);
+	efd->set_checksum = exfat_dir_entries_checksum(new_buffers,
+						       new_nr_entries);
+	efd->set_checksum = __cpu_to_le16(efd->set_checksum);
+
+	/*
+	 * mark old buffer entries as unused.
+	 */
+	for (i = 0; i < old_info->iloc.nr_secondary; ++i)
+		*((u8*)old_buffers[i].start) &= 0x7f;
+
+	/*
+	 * dirty old & new entries buffers.
+	 */
+	exfat_dirty_dir_entries(new_buffers, new_nr_entries, false);
+	exfat_dirty_dir_entries(old_buffers, old_info->iloc.nr_secondary,
+				false);
+
+	/*
+	 * update links if new_dir and old_dir are differents.
+	 */
+	if (new_dir != old_dir) {
+		drop_nlink(old_dir);
+		inc_nlink(new_dir);
+	}
+
+	/*
+	 * make old inode use the new iloc, and update sb inode hash.
+	 */
+	exfat_remove_inode_hash(old_inode);
+	old_info->iloc = new_iloc;
+	exfat_insert_inode_hash(old_inode);
+
+	/*
+	 * update new dir & old dir mtime/atime
+	 */
+	if (new_dir == old_dir) {
+		new_dir->i_mtime = new_dir->i_atime = CURRENT_TIME_SEC;
+		if (IS_DIRSYNC(new_dir))
+			__exfat_write_inode(new_dir, true);
+		else
+			mark_inode_dirty(new_dir);
+	} else {
+		new_dir->i_mtime = new_dir->i_atime =
+			old_dir->i_mtime = old_dir->i_atime = CURRENT_TIME_SEC;
+		if (IS_DIRSYNC(new_dir)) {
+			__exfat_write_inode(new_dir, true);
+			__exfat_write_inode(old_dir, true);
+		} else {
+			mark_inode_dirty(new_dir);
+			mark_inode_dirty(old_dir);
+		}
+	}
+
+	exfat_unlock_super(new_dir->i_sb);
+	return 0;
+
+err_cleanup_new_buffers:
+	exfat_cleanup_dir_entries(new_buffers, new_nr_entries);
+err_cleanup_old_buffers:
+	exfat_cleanup_dir_entries(old_buffers, old_info->iloc.nr_secondary);
+err_putname:
+	__putname(name);
+unlock_super:
+	exfat_unlock_super(new_dir->i_sb);
+	return error;
+}
diff -Nruw linux-4.2.6-fbx/fs/exfat./read-write.c linux-4.2.6-fbx/fs/exfat/read-write.c
--- linux-4.2.6-fbx/fs/exfat./read-write.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/read-write.c	2015-11-18 18:24:32.956173961 +0100
@@ -0,0 +1,150 @@
+/*
+ * read-write.c for exfat
+ * Created by <nschichan@freebox.fr> on Wed Jul 31 16:37:51 2013
+ */
+
+#include <linux/slab.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/mpage.h>
+#include <linux/buffer_head.h>
+
+#include "exfat.h"
+#include "exfat_fs.h"
+
+/*
+ * map file sector to disk sector.
+ */
+static int exfat_bmap(struct inode *inode, sector_t fsect, sector_t *dsect)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+	struct exfat_inode_info *info = EXFAT_I(inode);
+	u32 cluster_nr = fsect >> (sbi->clusterbits - sbi->sectorbits);
+	u32 cluster;
+	unsigned int offset = fsect & (sbi->sectors_per_cluster - 1);
+
+	if (info->flags & EXFAT_I_FAT_INVALID)
+		cluster = info->first_cluster + cluster_nr;
+	else {
+		int error;
+
+		error = exfat_get_fat_cluster(inode, cluster_nr, &cluster);
+		if (error)
+			return error;
+	}
+
+	*dsect = exfat_cluster_sector(sbi, cluster) + offset;
+	return 0;
+}
+
+static int exfat_get_block(struct inode *inode, sector_t block,
+			   struct buffer_head *bh, int create)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
+	struct exfat_inode_info *info = EXFAT_I(inode);
+	sector_t last_block;
+	unsigned int offset;
+	sector_t dblock;
+	int error;
+
+	last_block = (i_size_read(inode) + sbi->sectorsize - 1) >>
+		sbi->sectorbits;
+	offset = block & (sbi->sectors_per_cluster - 1);
+
+	if (!create && block >= last_block)
+		return 0;
+
+	if (create && block >= last_block && offset == 0) {
+		u32 hint, cluster;
+
+		/*
+		 * request for first sector in a cluster immediate to
+		 * the last allocated cluster of the file: must
+		 * allocate a new clluster.
+		 */
+		error = exfat_get_cluster_hint(inode, &hint);
+		if (error)
+			return error;
+
+		error = exfat_alloc_clusters(inode, hint, &cluster, 1);
+		if (error)
+			return error;
+	}
+
+	error = exfat_bmap(inode, block, &dblock);
+	if (error)
+		return error;
+
+	if (create && block >= last_block) {
+		/*
+		 * currently in create mode: we need to update
+		 * mmu_private.
+		 */
+		info->mmu_private += sbi->sectorsize;
+		set_buffer_new(bh);
+	}
+	map_bh(bh, inode->i_sb, dblock);
+	return 0;
+}
+
+int exfat_readpage(struct file *file, struct page *page)
+{
+	return mpage_readpage(page, exfat_get_block);
+}
+
+int exfat_readpages(struct file *file, struct address_space *mapping,
+		    struct list_head *pages, unsigned nr_pages)
+{
+	return mpage_readpages(mapping, pages, nr_pages, exfat_get_block);
+}
+
+static int exfat_write_error(struct inode *inode, loff_t to)
+{
+	if (to > inode->i_size) {
+		truncate_pagecache(inode, to);
+		exfat_truncate_blocks(inode, inode->i_size);
+	}
+	return 0;
+}
+
+int exfat_write_begin(struct file *file, struct address_space *mapping,
+		      loff_t pos, unsigned len, unsigned flags,
+		      struct page **pagep, void **fsdata)
+{
+	struct inode *inode = mapping->host;
+	int error;
+
+	*pagep = NULL;
+	error = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+				 exfat_get_block, &EXFAT_I(inode)->mmu_private);
+
+	if (error)
+		exfat_write_error(inode, pos + len);
+	return error;
+}
+
+int exfat_write_end(struct file *file, struct address_space *mapping,
+		    loff_t pos, unsigned len, unsigned copied,
+		    struct page *page, void *fsdata)
+{
+	struct inode *inode = mapping->host;
+	int error;
+
+	error = generic_write_end(file, mapping, pos, len, copied, page,
+				  fsdata);
+
+	if (error < len)
+		exfat_write_error(inode, pos + len);
+	return error;
+}
+
+int exfat_writepage(struct page *page, struct writeback_control *wbc)
+{
+	return block_write_full_page(page, exfat_get_block, wbc);
+}
+
+int exfat_writepages(struct address_space *mapping,
+		     struct writeback_control *wbc)
+{
+	return mpage_writepages(mapping, wbc, exfat_get_block);
+}
diff -Nruw linux-4.2.6-fbx/fs/exfat./super.c linux-4.2.6-fbx/fs/exfat/super.c
--- linux-4.2.6-fbx/fs/exfat./super.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/super.c	2015-11-18 18:24:32.956173961 +0100
@@ -0,0 +1,735 @@
+/*
+ * super.c<2> for exfat
+ * Created by <nschichan@freebox.fr> on Tue Jul 23 12:33:53 2013
+ */
+
+#include <linux/kernel.h>
+#include <linux/bug.h>
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/slab.h>
+#include <linux/buffer_head.h>
+#include <linux/statfs.h>
+#include <linux/parser.h>
+#include <linux/seq_file.h>
+#include <linux/sched.h>
+#include <linux/cred.h>
+
+#include "exfat_fs.h"
+#include "exfat.h"
+
+
+#define PFX	"exFAT: "
+
+static void exfat_put_super(struct super_block *sb);
+static int exfat_statfs(struct dentry *dentry, struct kstatfs *kstat);
+static int exfat_show_options(struct seq_file *m, struct dentry *root);
+static int exfat_remount(struct super_block *sb, int *flags, char *opts);
+
+static const struct super_operations exfat_super_ops = {
+	.alloc_inode	= exfat_alloc_inode,
+	.destroy_inode	= exfat_destroy_inode,
+	.drop_inode	= exfat_drop_inode,
+	.evict_inode	= exfat_evict_inode,
+	.write_inode	= exfat_write_inode,
+	.statfs         = exfat_statfs,
+	.put_super      = exfat_put_super,
+	.show_options	= exfat_show_options,
+	.remount_fs	= exfat_remount,
+};
+
+const struct file_operations exfat_dir_operations = {
+	.llseek = generic_file_llseek,
+	.read = generic_read_dir,
+	.iterate = exfat_iterate,
+	.unlocked_ioctl	= exfat_ioctl,
+};
+
+const struct file_operations exfat_file_operations = {
+	.llseek		= generic_file_llseek,
+	.read_iter	= generic_file_read_iter,
+	.write_iter	= generic_file_write_iter,
+	.mmap		= generic_file_mmap,
+	.splice_read	= generic_file_splice_read,
+	.unlocked_ioctl	= exfat_ioctl,
+	.fsync		= generic_file_fsync,
+};
+
+const struct inode_operations exfat_dir_inode_operations =
+{
+	.create = exfat_inode_create,
+	.mkdir	= exfat_inode_mkdir,
+	.lookup = exfat_inode_lookup,
+	.rmdir	= exfat_inode_rmdir,
+	.unlink	= exfat_inode_unlink,
+	.rename	= exfat_rename,
+	.setattr = exfat_setattr,
+	.getattr = exfat_getattr,
+};
+
+const struct inode_operations exfat_file_inode_operations = {
+	.setattr = exfat_setattr,
+	.getattr = exfat_getattr,
+};
+
+const struct address_space_operations exfat_address_space_operations = {
+	.readpage	= exfat_readpage,
+	.readpages	= exfat_readpages,
+	.write_begin	= exfat_write_begin,
+	.write_end	= exfat_write_end,
+	.writepage	= exfat_writepage,
+	.writepages	= exfat_writepages,
+};
+
+void exfat_msg(struct super_block *sb, const char *prefix,
+		const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+	printk("%sexFAT-fs (%s): %pV\n", prefix, sb->s_id, &vaf);
+	va_end(args);
+}
+
+void exfat_fs_error(struct super_block *sb, const char *fmt, ...)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+	exfat_msg(sb, KERN_ERR, "error: %pV", &vaf);
+	va_end(args);
+
+	if (sbi->options.error_action == EXFAT_ERROR_ACTION_REMOUNT_RO &&
+	    !(sb->s_flags & MS_RDONLY)) {
+		sb->s_flags |= MS_RDONLY;
+		exfat_msg(sb, KERN_ERR, "remounted read-only due to fs error.");
+	} else if (sbi->options.error_action == EXFAT_ERROR_ACTION_PANIC)
+		panic("exFAT-fs (%s): panic due fs error.\n", sb->s_id);
+}
+
+/*
+ * process checksum on buffer head. first indicates if the special
+ * treatment of the first sector needs to be done or not.
+ *
+ * first sector can be changed (volume flags, and heap use percent),
+ * those fields are excluded from the checksum to allow updating
+ * without recalculating the checksum.
+ */
+static u32 exfat_sb_checksum_process(struct buffer_head *bh, u32 checksum,
+				     unsigned int size,
+				     bool first)
+{
+	unsigned int i;
+
+	for (i = 0; i < size; ++i) {
+		if (first && (i == 106 || i == 107 || i == 112))
+			continue ;
+		checksum = ((checksum << 31) | (checksum >> 1)) +
+			(unsigned char)bh->b_data[i];
+	}
+	return checksum;
+}
+
+static int exfat_check_sb_checksum(struct super_block *sb)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	u32 checksum;
+	int i;
+	int err;
+	struct buffer_head *bh[EXFAT_CHECKSUM_SECTORS + 1];
+
+	/*
+	 * fetch needed sectors, reuse first sector from sbi.
+	 */
+	err = -ENOMEM;
+	memset(bh, 0, sizeof (struct buffer_head*) *
+	       (EXFAT_CHECKSUM_SECTORS + 1));
+	bh[0] = sbi->sb_bh;
+	for (i = 1; i < EXFAT_CHECKSUM_SECTORS + 1; ++i) {
+		bh[i] = sb_bread(sb, i);
+		if (!bh[i])
+			goto out;
+	}
+
+	/*
+	 * calculate checksum.
+	 */
+	checksum = exfat_sb_checksum_process(bh[0], 0, sbi->sectorsize, true);
+	for (i = 1; i < EXFAT_CHECKSUM_SECTORS; ++i) {
+		checksum = exfat_sb_checksum_process(bh[i], checksum,
+						     sbi->sectorsize, false);
+	}
+
+	/*
+	 * compare with the checksum sector.
+	 */
+	err = -EINVAL;
+	for (i = 0; i < sbi->sectorsize; i += sizeof (u32)) {
+		__le32 val = *(u32*)(bh[EXFAT_CHECKSUM_SECTORS]->b_data + i);
+
+		if (__le32_to_cpu(val) != checksum) {
+			exfat_msg(sb, KERN_INFO, "at offset %i, checksum "
+				  "%08x != %08x", i, __le32_to_cpu(val), checksum);
+			goto out;
+		}
+	}
+	err = 0;
+
+out:
+	for (i = 1; i < EXFAT_CHECKSUM_SECTORS; ++i)
+		if (bh[i])
+			brelse(bh[i]);
+	return err;
+}
+
+static int exfat_check_sb(struct super_block *sb)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	struct exfat_vbr *vbr = sbi->vbr;
+	u16 fs_rev;
+	u16 flags;
+	int active_fat;
+	u16 num_fats;
+
+	if (memcmp(vbr->jump, "\xeb\x76\x90", sizeof (vbr->jump))) {
+		exfat_msg(sb, KERN_INFO, "invalid jump field in vbr.");
+		return -EINVAL;
+	}
+
+	if (memcmp(vbr->fsname, "EXFAT   ", 8)) {
+		exfat_msg(sb, KERN_INFO, "invalid fsname field in vbr: %s.",
+			  vbr->fsname);
+		return -EINVAL;
+	}
+
+	fs_rev = __le16_to_cpu(vbr->fs_rev);
+	if (fs_rev != 0x0100) {
+		exfat_msg(sb, KERN_INFO, "filesystem version invalid: "
+			  "have 0x%04x, need 0x0100", fs_rev);
+		return -EINVAL;
+	}
+
+	flags = __le16_to_cpu(vbr->volume_flags);
+	active_fat = exfat_active_fat(flags);
+	if (active_fat != 0) {
+		exfat_msg(sb, KERN_INFO, "filesystems with active fat > 0 are "
+			  "not supported.");
+		return -EINVAL;
+	}
+
+	if (flags & EXFAT_FLAG_MEDIA_FAILURE)
+		exfat_msg(sb, KERN_WARNING, "filesystem had media failure(s)");
+
+	/*
+	 * bytes per sectors are on the range 2^9 - 2^12 (512 - 4096)
+	 */
+	if (vbr->bytes_per_sector < 9 || vbr->bytes_per_sector > 12) {
+		exfat_msg(sb, KERN_ERR, "invalid byte per sectors: %u",
+			  (1 << vbr->bytes_per_sector));
+		return -EINVAL;
+	}
+
+	/*
+	 * sectors per cluster can be as low as 0, and must not result
+	 * in a cluster size higher than 32MB (byte_per_sector +
+	 * sectors_per_cluster must not be creater than 25)
+	 */
+	if (vbr->bytes_per_sector + vbr->sectors_per_cluster > 25) {
+		exfat_msg(sb, KERN_ERR, "invalid cluster size: %u",
+		  1 << (vbr->bytes_per_sector + vbr->sectors_per_cluster));
+		return -EINVAL;
+	}
+
+	num_fats = __le16_to_cpu(vbr->fat_num);
+	if (num_fats == 0) {
+		exfat_msg(sb, KERN_ERR, "superblock reports no FAT.");
+		return -EINVAL;
+	}
+	if (num_fats > 1) {
+		exfat_msg(sb, KERN_ERR, "TexFAT is not supported.");
+		return -EINVAL;
+	}
+
+	if (memcmp(vbr->boot_sig, "\x55\xaa", 2)) {
+		exfat_msg(sb, KERN_ERR, "invalid end boot signature: %02x%02x.",
+			  vbr->boot_sig[0], vbr->boot_sig[1]);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int exfat_fill_root(struct super_block *sb, struct inode *root)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	u32 nclust;
+	u32 dummy;
+	loff_t links;
+
+	root->i_ino = EXFAT_ROOT_INO;
+	root->i_version = 1;
+	EXFAT_I(root)->first_cluster =
+		__le32_to_cpu(sbi->root_dir_cluster);
+	EXFAT_I(root)->attributes = E_EXFAT_ATTR_DIRECTORY;
+
+	root->i_uid = sbi->options.uid;
+	root->i_gid = sbi->options.gid;
+
+	root->i_mode = exfat_make_mode(sbi, S_IRWXUGO, E_EXFAT_ATTR_DIRECTORY);
+	root->i_version++;
+	root->i_generation = 0;
+
+	root->i_op = &exfat_dir_inode_operations;
+	root->i_fop = &exfat_dir_operations;
+
+	/*
+	 * root inode cannot use bitmap.
+	 */
+	EXFAT_I(root)->flags = EXFAT_I_ALLOC_POSSIBLE;
+
+	/*
+	 * set i_size
+	 */
+	nclust = 0;
+	while (__exfat_get_fat_cluster(root, nclust, &dummy, false) == 0)
+		++nclust;
+	root->i_size = nclust << sbi->clusterbits;
+	root->i_blocks = nclust << (sbi->clusterbits - 9);
+	EXFAT_I(root)->allocated_clusters = nclust;
+
+	/*
+	 * +2 to account for '.' and '..'
+	 */
+	links = exfat_dir_links(root);
+	if (links < 0)
+		return links;
+	set_nlink(root, links + 2);
+
+	root->i_mtime = root->i_atime = root->i_ctime = CURRENT_TIME_SEC;
+
+	return 0;
+}
+
+static loff_t exfat_file_max_byte(struct exfat_sb_info *sbi)
+{
+	u32 max_clusters = EXFAT_CLUSTER_LASTVALID -
+		EXFAT_CLUSTER_FIRSTVALID + 1;
+
+	return (loff_t)max_clusters << sbi->clusterbits;
+}
+
+static int exfat_show_options(struct seq_file *m, struct dentry *root)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(root->d_inode->i_sb);
+
+	if (!uid_eq(sbi->options.uid, GLOBAL_ROOT_UID))
+		seq_printf(m, ",uid=%u",
+			   from_kuid_munged(&init_user_ns, sbi->options.uid));
+	if (!gid_eq(sbi->options.gid, GLOBAL_ROOT_GID))
+		seq_printf(m, ",gid=%u",
+			   from_kgid_munged(&init_user_ns, sbi->options.gid));
+
+	seq_printf(m, ",fmask=%04o", sbi->options.fmask);
+	seq_printf(m, ",dmask=%04o", sbi->options.dmask);
+
+	if (sbi->options.time_offset_set)
+		seq_printf(m, ",time_offset=%d", sbi->options.time_offset);
+
+	switch (sbi->options.error_action) {
+	case EXFAT_ERROR_ACTION_PANIC:
+		seq_printf(m, ",errors=panic");
+		break;
+	case EXFAT_ERROR_ACTION_REMOUNT_RO:
+		seq_printf(m, ",errors=remount-ro");
+		break;
+	default:
+		seq_printf(m, ",errors=continue");
+		break;
+	}
+
+	return 0;
+}
+
+enum {
+	Opt_exfat_uid,
+	Opt_exfat_gid,
+	Opt_exfat_dmask,
+	Opt_exfat_fmask,
+	Opt_exfat_time_offset,
+	Opt_exfat_error_continue,
+	Opt_exfat_error_remount_ro,
+	Opt_exfat_error_panic,
+	Opt_exfat_err,
+};
+
+static const match_table_t exfat_tokens = {
+	{ Opt_exfat_uid, "uid=%u", },
+	{ Opt_exfat_gid, "gid=%u", },
+	{ Opt_exfat_dmask, "dmask=%04o", },
+	{ Opt_exfat_fmask, "fmask=%04o", },
+	{ Opt_exfat_time_offset, "time_offset=%d", },
+	{ Opt_exfat_error_continue, "errors=continue", },
+	{ Opt_exfat_error_remount_ro, "errors=remount-ro", },
+	{ Opt_exfat_error_panic, "errors=panic", },
+	{ Opt_exfat_err, NULL },
+};
+
+static int exfat_parse_options(struct super_block *sb, char *opts, int silent)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	char *p;
+
+	sbi->options.uid = current_uid();
+	sbi->options.gid = current_gid();
+
+	sbi->options.dmask = current_umask();
+	sbi->options.fmask = current_umask();
+	sbi->options.time_offset_set = 0;
+	sbi->options.error_action = EXFAT_ERROR_ACTION_CONTINUE;
+
+	while (1) {
+		int token;
+		substring_t args[MAX_OPT_ARGS];
+		unsigned int optval;
+
+		p = strsep(&opts, ",");
+		if (!p)
+			break;
+		token = match_token(p, exfat_tokens, args);
+
+		switch (token) {
+		case Opt_exfat_uid:
+			if (match_int(&args[0], &optval))
+				return -EINVAL;
+			sbi->options.uid = make_kuid(current_user_ns(), optval);
+			break;
+
+		case Opt_exfat_gid:
+			if (match_int(&args[0], &optval))
+				return -EINVAL;
+			sbi->options.gid = make_kgid(current_user_ns(), optval);
+			break;
+
+		case Opt_exfat_dmask:
+			if (match_octal(&args[0], &optval))
+				return -EINVAL;
+			sbi->options.dmask = optval;
+			break;
+
+		case Opt_exfat_fmask:
+			if (match_octal(&args[0], &optval))
+				return -EINVAL;
+			sbi->options.fmask = optval;
+			break;
+
+		case Opt_exfat_time_offset:
+			if (match_int(&args[0], &optval))
+				return -EINVAL;
+			if (optval < -12 * 60 && optval > 12 * 60) {
+				if (!silent)
+					exfat_msg(sb, KERN_INFO, "invalid "
+						  "time_offset value %d: "
+						  "should be between %d and %d",
+						  optval, -12 * 60, 12 * 60);
+				return -EINVAL;
+			}
+			sbi->options.time_offset = optval;
+			sbi->options.time_offset_set = 1;
+			break;
+
+		case Opt_exfat_error_continue:
+			sbi->options.error_action = EXFAT_ERROR_ACTION_CONTINUE;
+			break;
+
+		case Opt_exfat_error_remount_ro:
+			sbi->options.error_action =
+				EXFAT_ERROR_ACTION_REMOUNT_RO;
+			break;
+
+		case Opt_exfat_error_panic:
+			sbi->options.error_action = EXFAT_ERROR_ACTION_PANIC;
+			break;
+
+		default:
+			if (!silent)
+				exfat_msg(sb, KERN_INFO, "Unrecognized mount "
+					  "option %s or missing parameter.\n",
+					  p);
+			return -EINVAL;
+		}
+	}
+	return 0;
+}
+
+static void exfat_set_sb_dirty(struct super_block *sb, bool set, bool force)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	u16 flags;
+
+	/*
+	 * do not change anything if mounted read only and not
+	 * forced. the force case would happen during remount.
+	 */
+	if ((sb->s_flags & MS_RDONLY) && !force)
+		return ;
+
+	if (sbi->dirty) {
+		if (set)
+			exfat_msg(sb, KERN_WARNING, "Volume was not cleanly "
+				  "umounted. fsck should probably be needed.");
+		return ;
+	}
+
+	flags = __le16_to_cpu(sbi->vbr->volume_flags);
+	if (set)
+		flags |= EXFAT_FLAG_DIRTY;
+	else
+		flags &= ~EXFAT_FLAG_DIRTY;
+	sbi->vbr->volume_flags = __cpu_to_le16(flags);
+
+	mark_buffer_dirty(sbi->sb_bh);
+	sync_dirty_buffer(sbi->sb_bh);
+}
+
+static int exfat_remount(struct super_block *sb, int *flags, char *opts)
+{
+	int new_rdonly = *flags & MS_RDONLY;
+
+	if (new_rdonly != (sb->s_flags & MS_RDONLY)) {
+		if (new_rdonly)
+			exfat_set_sb_dirty(sb, false, false);
+		else
+			/*
+			 * sb->s_flag still has MS_RDONLY, so we need
+			 * to force the dirty state
+			 */
+			exfat_set_sb_dirty(sb, true, true);
+	}
+	return 0;
+}
+
+static int exfat_fill_super(struct super_block *sb, void *data, int silent)
+{
+	struct exfat_sb_info *sbi = NULL;
+	int ret = -ENOMEM;
+	struct inode *root = NULL;
+	int i;
+
+	sbi = kzalloc(sizeof (*sbi), GFP_KERNEL);
+	if (!sbi)
+		return -ENOMEM;
+
+	sb->s_fs_info = sbi;
+	if (exfat_parse_options(sb, data, silent) < 0)
+		return -EINVAL;
+
+	mutex_init(&sbi->sb_mutex);
+	spin_lock_init(&sbi->inode_hash_lock);
+
+	/*
+	 * first block, before we know sector size.
+	 */
+	sbi->sb_bh = sb_bread(sb, 0);
+	if (!sbi->sb_bh)
+		goto fail;
+
+	sbi->vbr = (struct exfat_vbr*)sbi->sb_bh->b_data;
+	sb->s_op = &exfat_super_ops;
+
+
+	ret = exfat_check_sb(sb);
+	if (ret)
+		goto fail;
+
+	/*
+	 * vbr seems sane, fill sbi.
+	 */
+	sbi->sectorsize = (1 << sbi->vbr->bytes_per_sector);
+	sbi->clustersize = sbi->sectorsize *
+		(1 << sbi->vbr->sectors_per_cluster);
+
+	sbi->sectors_per_cluster = sbi->clustersize / sbi->sectorsize;
+
+	sbi->sectorbits = sbi->vbr->bytes_per_sector;
+	sbi->clusterbits = sbi->vbr->sectors_per_cluster + sbi->sectorbits;
+	sbi->sectormask = sbi->sectorsize - 1;
+	sbi->clustermask = sbi->clustersize - 1;
+
+
+	sbi->fat_offset = __le32_to_cpu(sbi->vbr->fat_offset);
+	sbi->fat_length = __le32_to_cpu(sbi->vbr->fat_length);
+
+	sbi->root_dir_cluster = __le32_to_cpu(sbi->vbr->cluster_root_dir);
+
+	sbi->cluster_heap_offset = __le32_to_cpu(sbi->vbr->cluster_heap_offset);
+	sbi->cluster_count = __le32_to_cpu(sbi->vbr->cluster_count);
+
+	sbi->dirty = !!(__le16_to_cpu(sbi->vbr->volume_flags) &
+			EXFAT_FLAG_DIRTY);
+
+	/*
+	 * now that we know sector size, reread superblock with
+	 * correct sector size.
+	 */
+	ret = -EIO;
+	if (sb->s_blocksize != sbi->sectorsize) {
+		if (!sb_set_blocksize(sb, sbi->sectorsize)) {
+			exfat_msg(sb, KERN_INFO, "bad block size %d.",
+				  sbi->sectorsize);
+			goto fail;
+		}
+
+		brelse(sbi->sb_bh);
+		sbi->vbr = NULL;
+
+		sbi->sb_bh = sb_bread(sb, 0);
+		if (!sbi->sb_bh)
+			goto fail;
+		sbi->vbr = (struct exfat_vbr*)sbi->sb_bh->b_data;
+		sb->s_fs_info = sbi;
+	}
+
+	ret = exfat_check_sb_checksum(sb);
+	if (ret)
+		goto fail;
+
+	sb->s_maxbytes = exfat_file_max_byte(sbi);
+
+	ret = exfat_init_fat(sb);
+	if (ret)
+		goto fail;
+
+	for (i = 0 ; i < EXFAT_HASH_SIZE; ++i) {
+		INIT_HLIST_HEAD(&sbi->inode_hash[i]);
+	}
+
+	/*
+	 * create root inode.
+	 */
+	root = new_inode(sb);
+	if (!root)
+		goto fail;
+
+	exfat_fill_root(sb, root);
+
+	ret = exfat_upcase_init(root);
+	if (ret)
+		goto fail_iput;
+
+	ret = exfat_init_bitmap(root);
+	if (ret)
+		goto fail_iput;
+
+
+	sb->s_root = d_make_root(root);
+	if (!sb->s_root)
+		goto fail_iput;
+
+	exfat_set_sb_dirty(sb, true, false);
+	return 0;
+
+fail_iput:
+	iput(root);
+
+fail:
+	if (sbi->sb_bh)
+		brelse(sbi->sb_bh);
+	if (sbi)
+		kfree(sbi);
+	return ret;
+}
+
+static struct dentry *exfat_mount(struct file_system_type *fstype,
+				  int flags, const char *dev_name, void *data)
+{
+	return mount_bdev(fstype, flags, dev_name, data, exfat_fill_super);
+}
+
+static void exfat_put_super(struct super_block *sb)
+{
+	struct exfat_sb_info *sbi;
+
+	sbi = EXFAT_SB(sb);
+	if (sbi) {
+		exfat_set_sb_dirty(sb, false, false);
+		exfat_exit_bitmap(sb);
+		brelse(sbi->sb_bh);
+		kfree(sbi->upcase_table);
+		kfree(sbi);
+	}
+}
+
+static int exfat_statfs(struct dentry *dentry, struct kstatfs *kstat)
+{
+	struct super_block *sb = dentry->d_inode->i_sb;
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
+
+	memset(kstat, 0, sizeof (*kstat));
+
+
+	kstat->f_bsize = sbi->clustersize;
+	kstat->f_blocks = sbi->cluster_count;
+	kstat->f_bfree = sbi->free_clusters;
+	kstat->f_bavail = sbi->free_clusters;
+	kstat->f_namelen = 255;
+	kstat->f_fsid.val[0] = (u32)id;
+	kstat->f_fsid.val[1] = (u32)(id >> 32);
+
+	return 0;
+}
+
+static struct file_system_type exfat_fs_type = {
+	.owner		= THIS_MODULE,
+	.name		= "exfat",
+	.mount		= exfat_mount,
+	.kill_sb	= kill_block_super,
+	.fs_flags	= FS_REQUIRES_DEV,
+};
+
+static int __init exfat_init(void)
+{
+	int error;
+
+	/* some sanity check on internal structure sizes */
+	BUILD_BUG_ON(sizeof (struct exfat_vbr) != 512);
+
+	BUILD_BUG_ON(sizeof (struct exfat_volume_label_entry) != 0x20);
+	BUILD_BUG_ON(sizeof (struct exfat_bitmap_entry) != 0x20);
+	BUILD_BUG_ON(sizeof (struct exfat_upcase_entry) != 0x20);
+	BUILD_BUG_ON(sizeof (struct exfat_guid_entry) != 0x20);
+	BUILD_BUG_ON(sizeof (struct exfat_padding_entry) != 0x20);
+	BUILD_BUG_ON(sizeof (struct exfat_acl_entry) != 0x20);
+	BUILD_BUG_ON(sizeof (struct exfat_filedir_entry) != 0x20);
+	BUILD_BUG_ON(sizeof (struct exfat_stream_extension_entry) != 0x20);
+	BUILD_BUG_ON(sizeof (struct exfat_filename_entry) != 0x20);
+
+	error = exfat_init_inodes();
+	if (error)
+		return error;
+
+
+	error = register_filesystem(&exfat_fs_type);
+	if (error)
+		exfat_exit_inodes();
+	return error;
+}
+
+static void __exit exfat_exit(void)
+{
+	unregister_filesystem(&exfat_fs_type);
+	exfat_exit_inodes();
+}
+
+module_init(exfat_init);
+module_exit(exfat_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Nicolas Schichan <nschichan@freebox.fr>");
diff -Nruw linux-4.2.6-fbx/fs/exfat./time.c linux-4.2.6-fbx/fs/exfat/time.c
--- linux-4.2.6-fbx/fs/exfat./time.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/time.c	2015-11-02 19:00:10.348932830 +0100
@@ -0,0 +1,126 @@
+
+#include <linux/kernel.h>
+#include <linux/fs.h>
+
+#include "exfat.h"
+#include "exfat_fs.h"
+
+
+
+extern struct timezone sys_tz;
+
+/*
+ * The epoch of FAT timestamp is 1980.
+ *     :  bits :     value
+ * date:  0 -  4: day	(1 -  31)
+ * date:  5 -  8: month	(1 -  12)
+ * date:  9 - 15: year	(0 - 127) from 1980
+ * time:  0 -  4: sec	(0 -  29) 2sec counts
+ * time:  5 - 10: min	(0 -  59)
+ * time: 11 - 15: hour	(0 -  23)
+ */
+#define SECS_PER_MIN	60
+#define SECS_PER_HOUR	(60 * 60)
+#define SECS_PER_DAY	(SECS_PER_HOUR * 24)
+/* days between 1.1.70 and 1.1.80 (2 leap days) */
+#define DAYS_DELTA	(365 * 10 + 2)
+/* 120 (2100 - 1980) isn't leap year */
+#define YEAR_2100	120
+#define IS_LEAP_YEAR(y)	(!((y) & 3) && (y) != YEAR_2100)
+
+/* Linear day numbers of the respective 1sts in non-leap years. */
+static time_t days_in_year[] = {
+	/* Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec */
+	0,   0,  31,  59,  90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0,
+};
+
+/* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */
+void exfat_time_2unix(struct timespec *ts, u32 datetime, u8 time_cs,
+		      s8 tz_offset)
+{
+	u16 date = (datetime >> 16);
+	u16 time = (datetime & 0xffff);
+	time_t second, day, leap_day, month, year;
+
+	year  = date >> 9;
+	month = max(1, (date >> 5) & 0xf);
+	day   = max(1, date & 0x1f) - 1;
+
+	if (((tz_offset & (1 << 6)) == 0))
+		tz_offset &= ~(1 << 7);
+
+	leap_day = (year + 3) / 4;
+	if (year > YEAR_2100)		/* 2100 isn't leap year */
+		leap_day--;
+	if (IS_LEAP_YEAR(year) && month > 2)
+		leap_day++;
+
+	second =  (time & 0x1f) << 1;
+	second += ((time >> 5) & 0x3f) * SECS_PER_MIN;
+	second += (time >> 11) * SECS_PER_HOUR;
+	second += (year * 365 + leap_day
+		   + days_in_year[month] + day
+		   + DAYS_DELTA) * SECS_PER_DAY;
+
+	second -= tz_offset * 15 * SECS_PER_MIN;
+
+	if (time_cs) {
+		ts->tv_sec = second + (time_cs / 100);
+		ts->tv_nsec = (time_cs % 100) * 10000000;
+	} else {
+		ts->tv_sec = second;
+		ts->tv_nsec = 0;
+	}
+}
+
+/* Convert linear UNIX date to a FAT time/date pair. */
+void exfat_time_2exfat(struct exfat_sb_info *sbi, struct timespec *ts,
+		       u32 *datetime, u8 *time_cs, s8 *tz_offset)
+{
+	struct tm tm;
+	u16 time;
+	u16 date;
+	int offset;
+
+	if (sbi->options.time_offset_set) {
+		offset = -sbi->options.time_offset;
+	} else
+		offset = sys_tz.tz_minuteswest;
+
+	time_to_tm(ts->tv_sec, -offset * SECS_PER_MIN, &tm);
+
+	/*  FAT can only support year between 1980 to 2107 */
+	if (tm.tm_year < 1980 - 1900) {
+		time = 0;
+		date = cpu_to_le16((0 << 9) | (1 << 5) | 1);
+		if (time_cs)
+			*time_cs = 0;
+		*tz_offset = 0;
+		return;
+	}
+	if (tm.tm_year > 2107 - 1900) {
+		time = cpu_to_le16((23 << 11) | (59 << 5) | 29);
+		date = cpu_to_le16((127 << 9) | (12 << 5) | 31);
+		if (time_cs)
+			*time_cs = 199;
+		*tz_offset = 0;
+		return;
+	}
+
+	/* from 1900 -> from 1980 */
+	tm.tm_year -= 80;
+	/* 0~11 -> 1~12 */
+	tm.tm_mon++;
+	/* 0~59 -> 0~29(2sec counts) */
+	tm.tm_sec >>= 1;
+
+	time = cpu_to_le16(tm.tm_hour << 11 | tm.tm_min << 5 | tm.tm_sec);
+	date = cpu_to_le16(tm.tm_year << 9 | tm.tm_mon << 5 | tm.tm_mday);
+
+	*datetime = (date << 16) | time;
+
+	if (time_cs)
+		*time_cs = (ts->tv_sec & 1) * 100 + ts->tv_nsec / 10000000;
+	*tz_offset = -offset / 15;
+	*tz_offset |= (1 << 7);
+}
diff -Nruw linux-4.2.6-fbx/fs/exfat./upcase.c linux-4.2.6-fbx/fs/exfat/upcase.c
--- linux-4.2.6-fbx/fs/exfat./upcase.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/fs/exfat/upcase.c	2015-11-02 19:00:10.348932830 +0100
@@ -0,0 +1,136 @@
+/*
+ * upcase.c for exfat
+ * Created by <nschichan@freebox.fr> on Wed Aug  7 11:51:37 2013
+ */
+
+#include <linux/buffer_head.h>
+#include <linux/slab.h>
+#include <linux/fs.h>
+
+#include "exfat.h"
+#include "exfat_fs.h"
+
+static u32 exfat_calc_upcase_checksum(const u8 *data, u32 checksum,
+				      size_t count)
+{
+	while (count) {
+		checksum = ((checksum << 31) | (checksum >> 1)) + *data;
+		--count;
+		++data;
+	}
+	return checksum;
+}
+
+static int exfat_load_upcase_table(struct super_block *sb, u32 disk_cluster,
+				   u32 *out_checksum)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	struct buffer_head *bh;
+	sector_t start, sect, end;
+	u32 off = 0;
+	u32 byte_len = sbi->upcase_len * sizeof (__le16);
+	u32 checksum = 0;
+
+	/*
+	 * up-case table are not fragmented, so sequential cluster
+	 * read will do here.
+	 */
+	start = exfat_cluster_sector(sbi, disk_cluster);
+	end = start + DIV_ROUND_UP(byte_len,
+			   sbi->sectorsize);
+	for (sect = start; sect < end; ++sect) {
+		u32 len = sbi->sectorsize;
+
+		if (sect == end - 1)
+			len = byte_len & sbi->sectormask;
+
+		bh = sb_bread(sb, sect);
+		if (!bh) {
+			exfat_msg(sb, KERN_ERR,
+				  "unable to read upcase sector %llu", sect);
+			return -EIO;
+		}
+		memcpy((u8*)sbi->upcase_table + off, bh->b_data,
+		       len);
+
+		checksum = exfat_calc_upcase_checksum(bh->b_data, checksum,
+						      len);
+
+		off += len;
+		brelse(bh);
+	}
+
+	BUG_ON(off != byte_len);
+	*out_checksum = checksum;
+	return 0;
+}
+
+int exfat_upcase_init(struct inode *root)
+{
+	struct exfat_sb_info *sbi = EXFAT_SB(root->i_sb);
+	struct exfat_upcase_entry *upcase;
+	struct exfat_dir_ctx dctx;
+	int error;
+	u64 upcase_length;
+	u32 checksum;
+
+	/*
+	 * configure directory context and look for an upcase table
+	 * entry.
+	 */
+	if (exfat_init_dir_ctx(root, &dctx, 0) < 0)
+		return -EIO;
+
+	error = -EIO;
+	upcase = __exfat_dentry_next(&dctx, E_EXFAT_UPCASE_TABLE, 0xff,
+				     true, NULL);
+	if (!upcase)
+		goto fail;
+
+	/*
+	 * check upcase table length. we need it to be non-zero,
+	 * ending on a __le16 boundary and provide at most a
+	 * conversion for the whole __le16 space.
+	 */
+	upcase_length = __le64_to_cpu(upcase->length);
+	if (upcase_length == 0 ||
+	    upcase_length & (sizeof (__le16) - 1) ||
+	    upcase_length > 0xffff * sizeof (__le16)) {
+		exfat_msg(root->i_sb, KERN_ERR, "invalid upcase length %llu",
+			  upcase_length);
+		goto fail;
+	}
+
+	/*
+	 * load complete upcase table in memory.
+	 */
+	error = -ENOMEM;
+	sbi->upcase_len = upcase_length / sizeof (__le16);
+	sbi->upcase_table = kmalloc(upcase_length, GFP_NOFS);
+	if (!sbi->upcase_table)
+		goto fail;
+
+	error = exfat_load_upcase_table(root->i_sb,
+					__le32_to_cpu(upcase->cluster_addr),
+					&checksum);
+	if (error)
+		goto fail;
+
+	if (checksum != __le32_to_cpu(upcase->checksum)) {
+		exfat_msg(root->i_sb, KERN_INFO,
+			  "upcase table checksum mismatch: have %08x, "
+			  "expect %08x", checksum,
+			  __le32_to_cpu(upcase->checksum));
+		error = -EINVAL;
+		goto fail;
+	}
+
+	exfat_cleanup_dir_ctx(&dctx);
+	return 0;
+
+fail:
+	if (sbi->upcase_table)
+		kfree(sbi->upcase_table);
+	exfat_cleanup_dir_ctx(&dctx);
+	return error;
+}
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/linux/fbxatm_dev.h	2015-11-02 18:59:21.464547475 +0100
@@ -0,0 +1,434 @@
+#ifndef LINUX_FBXATM_DEV_H_
+#define LINUX_FBXATM_DEV_H_
+
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/err.h>
+#include <linux/wait.h>
+#include <linux/workqueue.h>
+#include <linux/skbuff.h>
+#include <linux/mutex.h>
+#include <linux/fbxatm.h>
+#include <linux/device.h>
+#include <asm/atomic.h>
+#include <linux/if_vlan.h>
+#include <linux/fbxatm_remote.h>
+
+/*
+ * atm cell helper
+ */
+#define ATM_CELL_HDR_SIZE	5
+
+#define ATM_GET_GFC(h)		(((h)[0] & 0xf0) >> 4)
+#define ATM_SET_GFC(h,v)	do {					\
+					(h)[0] &= ~0xf0;		\
+					(h)[0] |= (v) << 4;		\
+				} while (0)
+
+#define ATM_GET_VPI(h)		((((h)[0] & 0x0f) << 4) |		\
+				 (((h)[1] & 0xf0) >> 4))
+#define ATM_SET_VPI(h,v)	do {					\
+					(h)[0] &= ~0xf;			\
+					(h)[1] &= ~0xf0;		\
+					(h)[0] |= (v) >> 4;		\
+					(h)[1] |= ((v) & 0xf) << 4;	\
+				} while (0)
+
+#define ATM_GET_VCI(h)		((((h)[1] & 0x0f) << 12) |		\
+				 ((h)[2] << 4) |			\
+				 ((((h)[3] & 0xf0) >> 4)))
+#define ATM_SET_VCI(h,v)	do {					\
+					(h)[1] &= ~0xf;			\
+					(h)[3] &= ~0xf0;		\
+					(h)[1] |= (v) >> 12;		\
+					(h)[2] = ((v) & 0xff0) >> 4;	\
+					(h)[3] |= ((v) & 0xf) << 4;	\
+				} while (0)
+
+
+#define ATM_GET_PT(h)		(((h)[3] & 0x0e) >> 1)
+#define ATM_SET_PT(h,v)		do {					\
+					(h)[3] &= ~0xe;			\
+					(h)[3] |= (v) << 1;		\
+				} while (0)
+
+#define ATM_GET_CLP(h)		(((h)[3] & 0x01))
+#define ATM_SET_CLP(h,v)	do {					\
+					(h)[3] &= ~1;			\
+					(h)[3] |= (v);			\
+				} while (0)
+
+#define ATM_GET_HEC(h)		((h)[4])
+#define ATM_SET_HEC(h,v)	do {					\
+					(h)[4] = (v);			\
+				} while (0)
+
+
+/*
+ * OAM definition
+ */
+#define OAM_VCI_SEG_F4			3
+#define OAM_VCI_END2END_F4		4
+
+#define OAM_PTI_SEG_F5			0x4
+#define OAM_PTI_END2END_F5		0x5
+
+#define OAM_TYPE_SHIFT			4
+#define OAM_TYPE_MASK			(0xf << OAM_TYPE_SHIFT)
+#define OAM_TYPE_FAULT_MANAGEMENT	0x1
+#define OAM_TYPE_PERF_MANAGEMENT	0x2
+#define OAM_TYPE_ACTIVATION		0x8
+
+#define FUNC_TYPE_SHIFT			0
+#define FUNC_TYPE_MASK			(0xf << FUNC_TYPE_SHIFT)
+#define FUNC_TYPE_AIS			0x0
+#define FUNC_TYPE_FERF			0x1
+#define FUNC_TYPE_CONT_CHECK		0x4
+#define FUNC_TYPE_OAM_LOOPBACK		0x8
+
+struct fbxatm_oam_cell_payload {
+	u8			cell_hdr[5];
+	u8			cell_type;
+	u8			loopback_indication;
+	u8			correlation_tag[4];
+	u8			loopback_id[16];
+	u8			source_id[16];
+	u8			reserved[8];
+	u8			crc10[2];
+};
+
+struct fbxatm_oam_cell {
+	struct fbxatm_oam_cell_payload	payload;
+	struct list_head		next;
+};
+
+struct fbxatm_oam_ping {
+	struct fbxatm_oam_ping_req	req;
+	u32				correlation_id;
+	int				replied;
+	wait_queue_head_t		wq;
+	struct list_head		next;
+};
+
+/*
+ * vcc/device stats
+ */
+struct fbxatm_vcc_stats {
+	unsigned long			rx_bytes;
+	unsigned long			tx_bytes;
+	unsigned long			rx_aal5;
+	unsigned long			tx_aal5;
+};
+
+struct fbxatm_dev_stats {
+	unsigned long			rx_bytes;
+	unsigned long			tx_bytes;
+	unsigned long			rx_aal5;
+	unsigned long			tx_aal5;
+	unsigned long			rx_f4_oam;
+	unsigned long			tx_f4_oam;
+	unsigned long			rx_f5_oam;
+	unsigned long			tx_f5_oam;
+	unsigned long			rx_bad_oam;
+	unsigned long			rx_bad_llid_oam;
+	unsigned long			rx_other_oam;
+	unsigned long			rx_dropped;
+	unsigned long			tx_drop_nolink;
+};
+
+/*
+ * vcc user ops
+ */
+struct fbxatm_vcc_uops {
+	void	(*link_change)(void *cb_data, int link,
+			       unsigned int rx_cell_rate,
+			       unsigned int tx_cell_rate);
+	void	(*rx_pkt)(struct sk_buff *skb, void *cb_data);
+	void	(*tx_done)(void *cb_data);
+};
+
+/*
+ * vcc status flags
+ */
+enum {
+	FBXATM_VCC_F_FULL		= (1 << 0),
+
+	FBXATM_VCC_F_LINK_UP		= (1 << 1),
+};
+
+
+/*
+ * vcc definition
+ */
+struct fbxatm_dev;
+
+struct fbxatm_vcc {
+	unsigned int			vpi;
+	unsigned int			vci;
+
+	struct fbxatm_vcc_qos		qos;
+
+	struct fbxatm_vcc_stats		stats;
+
+	enum fbxatm_vcc_user		user;
+	void				*user_priv;
+
+	struct fbxatm_dev		*adev;
+	void				*dev_priv;
+
+	spinlock_t			user_ops_lock;
+	const struct fbxatm_vcc_uops	*user_ops;
+	void				*user_cb_data;
+
+	unsigned int			to_drop_pkt;
+
+	spinlock_t			tx_lock;
+	unsigned long			vcc_flags;
+
+	struct list_head		next;
+};
+
+/*
+ * fbxatm device operation
+ */
+struct fbxatm_dev_ops {
+	int (*open)(struct fbxatm_vcc *vcc);
+
+	void (*close)(struct fbxatm_vcc *vcc);
+
+	int (*ioctl)(struct fbxatm_dev *adev,
+		     unsigned int cmd, void __user *arg);
+
+	int (*send)(struct fbxatm_vcc *vcc, struct sk_buff *skb);
+
+	int (*send_oam)(struct fbxatm_dev *adev,
+			struct fbxatm_oam_cell *cell);
+
+	int (*init_procfs)(struct fbxatm_dev *adev);
+	void (*release_procfs)(struct fbxatm_dev *adev);
+
+	struct module			*owner;
+};
+
+/*
+ * device flags
+ */
+enum {
+	FBXATM_DEV_F_LINK_UP		= (1 << 0),
+};
+
+/*
+ * fbxatm device definition
+ */
+struct fbxatm_dev {
+	int				ifindex;
+	unsigned long			dev_flags;
+
+	unsigned int			max_vcc;
+	unsigned int			vci_mask;
+	unsigned int			vpi_mask;
+	unsigned int			max_priority;
+	unsigned int			max_rx_priority;
+	unsigned int			tx_headroom;
+
+	char				*name;
+
+	/* unit: b/s */
+	unsigned int			link_rate_ds;
+	unsigned int			link_rate_us;
+
+	unsigned int			link_cell_rate_ds;
+	unsigned int			link_cell_rate_us;
+
+	const struct fbxatm_dev_ops	*ops;
+
+	spinlock_t			stats_lock;
+	struct fbxatm_dev_stats		stats;
+
+	struct list_head		vcc_list;
+
+	struct device			dev;
+
+	spinlock_t			oam_lock;
+	struct list_head		rx_oam_cells;
+	unsigned int			rx_oam_cells_count;
+	struct work_struct		oam_work;
+
+	struct list_head		oam_pending_ping;
+	u32				oam_correlation_id;
+
+	struct proc_dir_entry		*dev_proc_entry;
+	void				*priv;
+	struct list_head		next;
+};
+
+/*
+ * API for device drivers
+ */
+struct fbxatm_dev *fbxatm_alloc_device(int sizeof_priv);
+
+int fbxatm_register_device(struct fbxatm_dev *adev,
+			   const char *base_name,
+			   const struct fbxatm_dev_ops *ops);
+
+void fbxatm_free_device(struct fbxatm_dev *adev);
+
+void fbxatm_dev_set_link_up(struct fbxatm_dev *adev);
+
+void fbxatm_dev_set_link_down(struct fbxatm_dev *adev);
+
+int fbxatm_unregister_device(struct fbxatm_dev *adev);
+
+void fbxatm_netifrx_oam(struct fbxatm_dev *adev,
+			struct fbxatm_oam_cell *cell);
+
+
+static inline int fbxatm_vcc_link_is_up(struct fbxatm_vcc *vcc)
+{
+	return test_bit(FBXATM_VCC_F_LINK_UP, &vcc->vcc_flags);
+}
+
+#define	FBXATMDEV_ALIGN		4
+
+static inline void *fbxatm_dev_priv(struct fbxatm_dev *adev)
+{
+	return (u8 *)adev + ((sizeof(struct fbxatm_dev)
+			      + (FBXATMDEV_ALIGN - 1))
+			     & ~(FBXATMDEV_ALIGN - 1));
+}
+
+/*
+ * API for FBXATM stack user
+ */
+struct fbxatm_ioctl {
+	int (*handler)(struct socket *sock,
+		       unsigned int cmd, void __user *useraddr);
+
+	void (*release)(struct socket *sock);
+
+	struct module		*owner;
+	struct list_head	next;
+};
+
+void fbxatm_set_uops(struct fbxatm_vcc *vcc,
+		     const struct fbxatm_vcc_uops *user_ops,
+		     void *user_cb_data);
+
+struct fbxatm_vcc *
+fbxatm_bind_to_vcc(const struct fbxatm_vcc_id *id,
+		   enum fbxatm_vcc_user user);
+
+void fbxatm_unbind_vcc(struct fbxatm_vcc *vcc);
+
+
+static inline int fbxatm_vcc_queue_full(struct fbxatm_vcc *vcc)
+{
+	return test_bit(FBXATM_VCC_F_FULL, &vcc->vcc_flags);
+}
+
+#ifdef CONFIG_FBXATM_STACK
+/*
+ * stack user callback to send data on given vcc
+ */
+static inline int fbxatm_send(struct fbxatm_vcc *vcc, struct sk_buff *skb)
+{
+	int ret;
+	unsigned int len;
+
+	len = skb->len;
+
+	spin_lock_bh(&vcc->tx_lock);
+	if (!test_bit(FBXATM_VCC_F_LINK_UP, &vcc->vcc_flags)) {
+		spin_unlock_bh(&vcc->tx_lock);
+		dev_kfree_skb(skb);
+		spin_lock(&vcc->adev->stats_lock);
+		vcc->adev->stats.tx_drop_nolink++;
+		spin_unlock(&vcc->adev->stats_lock);
+		return 0;
+	}
+
+	ret = vcc->adev->ops->send(vcc, skb);
+	if (!ret) {
+		vcc->stats.tx_bytes += len;
+		vcc->stats.tx_aal5++;
+	}
+	spin_unlock_bh(&vcc->tx_lock);
+
+	if (!ret) {
+		spin_lock_bh(&vcc->adev->stats_lock);
+		vcc->adev->stats.tx_bytes += len;
+		vcc->adev->stats.tx_aal5++;
+		spin_unlock_bh(&vcc->adev->stats_lock);
+	}
+	return ret;
+}
+
+/*
+ * device callback when packet comes in
+ */
+static inline void fbxatm_netifrx(struct fbxatm_vcc *vcc, struct sk_buff *skb)
+{
+	unsigned int len;
+
+	len = skb->len;
+
+	spin_lock_bh(&vcc->user_ops_lock);
+	if (!vcc->user_ops) {
+		spin_unlock_bh(&vcc->user_ops_lock);
+		dev_kfree_skb(skb);
+		return;
+	}
+
+	if (vcc->to_drop_pkt) {
+		vcc->to_drop_pkt--;
+		spin_unlock_bh(&vcc->user_ops_lock);
+		dev_kfree_skb(skb);
+		return;
+	}
+
+	vcc->stats.rx_bytes += len;
+	vcc->stats.rx_aal5++;
+
+	vcc->user_ops->rx_pkt(skb, vcc->user_cb_data);
+	spin_unlock_bh(&vcc->user_ops_lock);
+
+	spin_lock_bh(&vcc->adev->stats_lock);
+	vcc->adev->stats.rx_bytes += len;
+	vcc->adev->stats.rx_aal5++;
+	spin_unlock_bh(&vcc->adev->stats_lock);
+}
+
+/*
+ * device callback when tx is done on vcc
+ */
+static inline void fbxatm_tx_done(struct fbxatm_vcc *vcc)
+{
+	spin_lock_bh(&vcc->user_ops_lock);
+	if (vcc->user_ops)
+		vcc->user_ops->tx_done(vcc->user_cb_data);
+	spin_unlock_bh(&vcc->user_ops_lock);
+}
+#else
+int fbxatm_send(struct fbxatm_vcc *vcc, struct sk_buff *skb);
+void fbxatm_netifrx(struct fbxatm_vcc *vcc, struct sk_buff *skb);
+void fbxatm_tx_done(struct fbxatm_vcc *vcc);
+#endif
+
+static inline unsigned int fbxatm_rx_reserve(void)
+{
+#ifdef CONFIG_FBXATM_STACK
+	/* normal stack, no headroom needed */
+	return 0;
+#else
+	/* remote stub, we need to send rx skb to another location,
+	 * adding the fbxatm_remote header, an ethernet header (with
+	 * possible vlan) */
+	return ALIGN(sizeof (struct fbxatm_remote_hdr) + VLAN_ETH_HLEN, 4);
+#endif
+}
+
+void fbxatm_register_ioctl(struct fbxatm_ioctl *ioctl);
+
+void fbxatm_unregister_ioctl(struct fbxatm_ioctl *ioctl);
+
+#endif /* !LINUX_FBXATM_DEV_H_ */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/linux/fbxatm_remote.h	2015-11-02 18:59:21.464547475 +0100
@@ -0,0 +1,216 @@
+#ifndef FBXATM_REMOTE_H_
+#define FBXATM_REMOTE_H_
+
+#include <linux/types.h>
+#include <linux/if_ether.h>
+#include <linux/netdevice.h>
+
+/*
+ * fbxatm remote protocol messages
+ */
+#define ETH_P_FBXATM_REMOTE	0x8844
+#define FBXATM_REMOTE_MAGIC	0xd76f8d2f
+
+enum fbxatm_remote_flags {
+	FBXATM_RFLAGS_ACK = (1 << 0),
+};
+
+enum fbxatm_remote_mtype {
+	/* driver => stub */
+	FBXATM_RMT_CONNECT = 0,
+
+	/* stub => driver */
+	FBXATM_RMT_DEV_LINK,
+	FBXATM_RMT_DEV_RX_OAM,
+
+	/* driver => stub */
+	FBXATM_RMT_KEEPALIVE,
+	FBXATM_RMT_DEV_SEND_OAM,
+	FBXATM_RMT_VCC_ACTION,
+
+	/* driver => stub */
+	FBXATM_RMT_VCC_SEND,
+
+	/* stub => driver */
+	FBXATM_RMT_VCC_QEMPTY,
+	FBXATM_RMT_VCC_RX,
+};
+
+struct fbxatm_remote_hdr {
+	u32	magic;
+	u8	flags;
+	u8	seq;
+	u16	len;
+	u16	sport;
+	u16	dport;
+
+	u32	session_id;
+	u32	mtype;
+};
+
+/*
+ * sent to destination port 0
+ */
+struct fbxatm_remote_connect {
+	u8	name[32];
+
+	u16	dev_link_port;
+	u16	dev_rx_oam_port;
+};
+
+struct fbxatm_remote_connect_ack {
+	u16	vcc_action_port;
+	u16	dev_send_oam_port;
+	u16	keepalive_port;
+	u16	pad;
+
+	u32	max_vcc;
+	u32	vci_mask;
+	u32	vpi_mask;
+	u32	max_priority;
+	u32	max_rx_priority;
+
+	u32	link;
+	u32	link_rate_ds;
+	u32	link_rate_us;
+	u32	link_cell_rate_ds;
+	u32	link_cell_rate_us;
+};
+
+/*
+ * sent on dev_link port
+ */
+struct fbxatm_remote_dev_link {
+	u32	link;
+	u32	link_rate_ds;
+	u32	link_rate_us;
+	u32	link_cell_rate_ds;
+	u32	link_cell_rate_us;
+};
+
+/*
+ * sent on vcc_action port
+ */
+struct fbxatm_remote_vcc_action {
+	/* 1: open - 0: close */
+	u32	action;
+
+	/*
+	 * open args
+	 */
+	u16	vcc_rx_port;
+	u16	vcc_qempty_port;
+
+	/* from vcc id struct */
+	u32	vpi;
+	u32	vci;
+
+	/* from qos struct */
+	u32	traffic_class;
+	u32	max_sdu;
+	u32	max_buffered_pkt;
+	u32	priority;
+	u32	rx_priority;
+
+	/*
+	 * close args
+	 */
+	u32	vcc_remote_id;
+};
+
+struct fbxatm_remote_vcc_action_ack {
+	u32	ret;
+
+	/* open args ack */
+	u32	vcc_remote_id;
+	u16	vcc_send_port;
+	u16	pad;
+};
+
+/*
+ * sent on vcc_send port
+ */
+struct fbxatm_remote_vcc_send_ack {
+	u32	full;
+};
+
+/*
+ * pseudo socket layer
+ */
+struct fbxatm_remote_sock;
+struct fbxatm_remote_ctx;
+
+struct fbxatm_remote_sockaddr {
+	u16		lport;
+	u16		dport;
+	u32		mtype;
+	int		infinite_retry;
+	int		(*deliver)(void *priv, struct sk_buff *skb,
+				   struct sk_buff **ack);
+	void		(*response)(void *priv, struct sk_buff *skb);
+	void		*priv;
+};
+
+struct sk_buff *fbxatm_remote_alloc_skb(struct fbxatm_remote_ctx *ctx,
+					unsigned int size);
+
+unsigned int fbxatm_remote_headroom(struct fbxatm_remote_ctx *ctx);
+
+void fbxatm_remote_sock_getaddr(struct fbxatm_remote_sock *sock,
+				struct fbxatm_remote_sockaddr *addr);
+
+void fbxatm_remote_sock_purge(struct fbxatm_remote_sock *sock);
+
+int fbxatm_remote_sock_pending(struct fbxatm_remote_sock *sock);
+
+struct fbxatm_remote_ctx *fbxatm_remote_alloc_ctx(struct net_device *netdev,
+						  u8 *remote_mac,
+						  u32 session_id,
+						  void (*timeout)(void *priv),
+						  void *priv);
+
+struct fbxatm_remote_sock *
+fbxatm_remote_sock_bind(struct fbxatm_remote_ctx *ctx,
+			struct fbxatm_remote_sockaddr *addr,
+			int send_ack);
+
+struct fbxatm_remote_sock *
+fbxatm_remote_sock_connect(struct fbxatm_remote_ctx *ctx,
+			   struct fbxatm_remote_sockaddr *addr,
+			   int need_ack);
+
+int fbxatm_remote_sock_send(struct fbxatm_remote_sock *sock,
+			    struct sk_buff *skb);
+
+int fbxatm_remote_sock_send_ack(struct fbxatm_remote_sock *sock,
+				struct sk_buff *skb);
+
+int fbxatm_remote_sock_send_raw_ack(struct fbxatm_remote_ctx *ctx,
+				    struct net_device *dev,
+				    u8 *remote_mac,
+				    struct fbxatm_remote_hdr *hdr,
+				    struct sk_buff *ack);
+
+void fbxatm_remote_sock_close(struct fbxatm_remote_sock *sock);
+
+void fbxatm_remote_set_unknown_cb(void (*cb)(struct net_device *,
+					     struct sk_buff *));
+
+void fbxatm_remote_free_ctx(struct fbxatm_remote_ctx *ctx);
+
+void fbxatm_remote_ctx_set_dead(struct fbxatm_remote_ctx *ctx);
+
+int fbxatm_remote_init(void);
+
+void fbxatm_remote_exit(void);
+
+/*
+ * platform data for fbxatm_remote driver
+ */
+struct fbxatm_remote_pdata {
+	u8	remote_mac[ETH_ALEN];
+	char	netdev_name[IFNAMSIZ];
+	char	remote_name[32];
+};
+
+#endif /* !FBXATM_REMOTE_H_ */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/linux/fbxbridge.h	2015-11-02 18:59:48.664761888 +0100
@@ -0,0 +1,242 @@
+#ifndef _FBXBRIDGE_H
+# define _FBXBRIDGE_H
+
+#include <linux/if.h>
+#include <linux/if_ether.h>
+
+#define MAX_ALIASES		3
+
+#define FBXBRIDGE_PFX		"fbxbridge: "
+
+#define FBXBRIDGE_LAN_TO_WAN	1
+#define FBXBRIDGE_WAN_TO_LAN	2
+
+#define FBXBRIDGE_FLAGS_FILTER			(1 << 0)
+#define FBXBRIDGE_FLAGS_DHCPD			(1 << 1)
+#define FBXBRIDGE_FLAGS_NETFILTER		(1 << 2)
+
+/*
+ * ioctl command
+ */
+
+enum fbxbridge_ioctl_cmd
+{
+	E_CMD_BR_CHG = 0,
+	E_CMD_BR_DEV_CHG,
+	E_CMD_BR_PARAMS,
+};
+
+struct fbxbridge_ioctl_chg
+{
+	char	brname[IFNAMSIZ];
+	int	action;
+};
+
+struct fbxbridge_ioctl_dev_chg
+{
+	char	brname[IFNAMSIZ];
+	char	devname[IFNAMSIZ];
+	int	wan;
+	int	action;
+};
+
+struct fbxbridge_port_info
+{
+	char	name[IFNAMSIZ];
+	int	present;
+};
+
+struct fbxbridge_ioctl_params
+{
+	int				action;
+	char				brname[IFNAMSIZ];
+	struct fbxbridge_port_info	wan_dev;
+	struct fbxbridge_port_info	lan_dev;
+	unsigned int			flags;
+	unsigned char			lan_hwaddr[ETH_ALEN];
+	unsigned char			have_hw_addr;
+	unsigned int			dns1_addr;
+	unsigned int			dns2_addr;
+	unsigned long			ip_aliases[MAX_ALIASES];
+
+	unsigned long			dhcpd_renew_time;
+	unsigned long			dhcpd_rebind_time;
+	unsigned long			dhcpd_lease_time;
+	unsigned int			inputmark;
+};
+
+struct fbxbridge_ioctl_req
+{
+	enum fbxbridge_ioctl_cmd	cmd;
+	unsigned long			arg;
+};
+
+#ifdef __KERNEL__
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/netdevice.h>
+#include <linux/if_arp.h>
+
+#define ARP_RATE_LIMIT		(HZ)
+#define ARP_ETHER_SIZE		(8 + ETH_ALEN * 2 + 4 * 2)
+
+#define FBXBR_PORT_WAN		0
+#define FBXBR_PORT_LAN		1
+
+#define FBXBR_CACHE_SIZE	128
+#define FBXBR_MAX_RULES		256
+
+struct fbxbridge_port;
+
+struct fbxbridge_fp_rule {
+	u32			sip;
+	u32			dip;
+	u16			sport;
+	u16			dport;
+
+	u8			dest_hwaddr[6];
+	struct fbxbridge_port	*oport;
+
+	struct hlist_node	hnext;
+	struct list_head	next;
+};
+
+struct fbxbridge_fp {
+	struct hlist_head	hrules[FBXBR_CACHE_SIZE];
+	struct list_head	rules;
+	unsigned int		count;
+};
+
+struct fbxbridge_port {
+	struct net_device	*dev;
+	struct net_device	*master_dev;
+	u16			vlan1;
+	u16			vlan2;
+	struct fbxbridge_fp	tcp_fp;
+	struct fbxbridge_fp	udp_fp;
+};
+
+struct fbxbridge {
+	struct fbxbridge	*next;
+	unsigned int		refcount;
+
+	char			name[IFNAMSIZ];
+	struct net_device	*dev;
+
+	/* local and remote (fbx) ip address */
+	unsigned long		br_ipaddr;
+	unsigned long		br_remote_ipaddr;
+
+	/* list of ip we consider to be local */
+	unsigned long		ip_aliases[MAX_ALIASES];
+
+	/* wan side inet info */
+	unsigned long		wan_ipaddr;
+	unsigned long		wan_netmask;
+	unsigned long		lan_netmask;
+	/* this is the _client_ gw */
+	unsigned long		wan_gw;
+
+	char			wan_dev_name[IFNAMSIZ];
+	char			lan_dev_name[IFNAMSIZ];
+	int			fast_path_enabled;
+	struct fbxbridge_port	ports[2];
+
+	unsigned char		lan_hwaddr[ETH_ALEN];
+	unsigned char		have_hw_addr;
+
+	unsigned int		flags;
+	unsigned int		inputmark;
+
+	unsigned int		dns1_ipaddr;
+	unsigned int		dns2_ipaddr;
+
+	unsigned long		last_arp_send;
+
+	unsigned long		dhcpd_renew_time;
+	unsigned long		dhcpd_rebind_time;
+	unsigned long		dhcpd_lease_time;
+};
+
+extern struct fbxbridge *fbxbridge_list;
+
+/* fbxbridge_dev.c */
+void __fbxbridge_keep_hw_addr(struct fbxbridge *br, unsigned char *hwaddr);
+
+/* fbxbridge_dhcp.c */
+void fbxbridge_dhcpd(struct fbxbridge *br, struct sk_buff *skb);
+
+
+/* fbxbridge_forward.c */
+struct sk_buff *fbxbridge_handle_frame(struct fbxbridge *br,
+				       struct sk_buff *skb);
+
+
+/* fbxbridge_filter.c */
+int
+fbxbridge_filter_lan_to_wan_packet(struct fbxbridge *br, struct sk_buff *skb);
+
+int
+fbxbridge_filter_wan_to_lan_packet(struct fbxbridge *br, struct sk_buff *skb);
+
+int fbxbridge_nf_hook(struct fbxbridge *br, uint8_t pf, unsigned int hook,
+		      struct sk_buff *skb, struct net_device *in,
+		      struct net_device *out);
+
+/* fbxbridge_local.c */
+void
+handle_local_input_lan_frame(struct fbxbridge *br, struct sk_buff *skb);
+
+int
+handle_local_output_frame(struct fbxbridge *br, struct sk_buff *skb);
+
+
+/* fbxbridge_output.c */
+void output_arp_frame(struct fbxbridge *br, struct net_device *dev,
+		      unsigned short type,
+		      unsigned long src_ip, unsigned char *src_hw,
+		      unsigned long target_ip, unsigned char *target_hw);
+
+void output_lan_frame(struct fbxbridge *br, struct sk_buff *skb);
+
+void output_lan_mcast_frame(struct fbxbridge *br, struct sk_buff *skb);
+
+void output_wan_frame(struct fbxbridge *br, struct sk_buff *skb);
+
+
+/* fbxbridge_utils.c */
+void fbxbridge_snat_packet(struct sk_buff *skb, unsigned long new_addr);
+
+void fbxbridge_dnat_packet(struct sk_buff *skb, unsigned long new_addr);
+
+int fbxbridge_check_ip_packet(struct sk_buff *skb);
+
+int fbxbridge_check_udp_tcp_packet(struct sk_buff *skb);
+
+/* fbxbridge_fastpath.c */
+int __fbxbridge_fp_in_vlan_tcp4(struct net_device *idev, struct sk_buff *skb);
+
+int __fbxbridge_fp_in_vlan_udp4(struct net_device *idev, struct sk_buff *skb);
+
+int __fbxbridge_fp_add_wan_to_lan(struct fbxbridge *br,
+				  const struct sk_buff *skb,
+				  const uint8_t *new_dest_hw_addr);
+
+int __fbxbridge_fp_add_lan_to_wan(struct fbxbridge *br,
+				  const struct sk_buff *skb,
+				  const uint8_t *new_dest_hw_addr);
+
+void __fbxbridge_fp_flush_by_dip(struct fbxbridge_port *bport, uint32_t dip);
+
+void __fbxbridge_fp_flush(struct fbxbridge *br);
+
+void fbxbridge_fp_flush_all(void);
+
+void fbxbridge_fp_init(struct fbxbridge *br);
+
+void __fbxbridge_fp_check(struct fbxbridge *br);
+
+#endif /* ! __KERNEL__ */
+
+#endif
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/linux/fbxgpio_core.h	2015-11-02 18:59:09.344451921 +0100
@@ -0,0 +1,39 @@
+/*
+ * fbxgpio.h for linux-freebox
+ * Created by <nschichan@freebox.fr> on Wed Feb 21 22:09:46 2007
+ * Freebox SA
+ */
+
+#ifndef FBXGPIO_H
+# define FBXGPIO_H
+
+# include <linux/types.h>
+
+/* can change pin direction */
+#define FBXGPIO_PIN_DIR_RW	(1 << 0)
+#define FBXGPIO_PIN_REVERSE_POL	(1 << 1)
+
+struct fbxgpio_operations {
+	int  (*get_datain)(int gpio);
+	void (*set_dataout)(int gpio, int val);
+	int  (*get_dataout)(int gpio);
+	void (*set_direction)(int gpio, int dir);
+	int  (*get_direction)(int gpio);
+};
+
+
+struct fbxgpio_pin {
+	const struct fbxgpio_operations	*ops;
+	const char			*pin_name;
+	uint32_t			flags;
+	int				direction;
+	int				pin_num;
+	unsigned int			cur_dataout;
+	struct device			*dev;
+};
+
+
+#define GPIO_DIR_IN	0x1
+#define GPIO_DIR_OUT	0x0
+
+#endif /* !FBXGPIO_H */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/linux/fbxjtag.h	2015-11-02 18:59:33.144639544 +0100
@@ -0,0 +1,88 @@
+#ifndef FBXJTAG_H_
+# define FBXJTAG_H_
+
+#ifdef __KERNEL__
+# include <linux/types.h>
+#endif
+
+# define JTAG_RESET_STEPS	16
+# define JTAG_DATA_READ_SIZE	128
+# define JTAG_INST_READ_SIZE	128
+# define JTAG_DEF_CLOCK_DELAY	500
+# define JTAG_DEF_WAIT_TMS	0
+
+enum jtag_main_state {
+	JTAG_STATE_TEST_MASK	=	0x10,
+	JTAG_STATE_RUN_MASK	=	0x20,
+	JTAG_STATE_DR_MASK	=	0x40,
+	JTAG_STATE_IR_MASK	=	0x80,
+};
+#define JTAG_STATE_MASK			0xF0
+
+enum jtag_sub_state {
+	JTAG_SUB_STATE_SELECT	=	0x0,
+	JTAG_SUB_STATE_CAPTURE	=	0x1,
+	JTAG_SUB_STATE_SHIFT	=	0x2,
+	JTAG_SUB_STATE_EXIT1	=	0x3,
+	JTAG_SUB_STATE_PAUSE	=	0x4,
+	JTAG_SUB_STATE_EXIT2	=	0x5,
+	JTAG_SUB_STATE_UPDATE	=	0x6,
+};
+#define JTAG_SUB_STATE_MASK		0xF
+
+enum jtag_state {
+	JTAG_STATE_UNDEF	= 0,
+	JTAG_STATE_TEST_LOGIC_RESET	= JTAG_STATE_TEST_MASK,
+	JTAG_STATE_RUN_TEST_IDLE	= JTAG_STATE_RUN_MASK,
+
+	JTAG_STATE_SELECT_DR	= JTAG_STATE_DR_MASK | JTAG_SUB_STATE_SELECT,
+	JTAG_STATE_CAPTURE_DR	= JTAG_STATE_DR_MASK | JTAG_SUB_STATE_CAPTURE,
+	JTAG_STATE_SHIFT_DR	= JTAG_STATE_DR_MASK | JTAG_SUB_STATE_SHIFT,
+	JTAG_STATE_EXIT1_DR	= JTAG_STATE_DR_MASK | JTAG_SUB_STATE_EXIT1,
+	JTAG_STATE_PAUSE_DR	= JTAG_STATE_DR_MASK | JTAG_SUB_STATE_PAUSE,
+	JTAG_STATE_EXIT2_DR	= JTAG_STATE_DR_MASK | JTAG_SUB_STATE_EXIT2,
+	JTAG_STATE_UPDATE_DR	= JTAG_STATE_DR_MASK | JTAG_SUB_STATE_UPDATE,
+
+	JTAG_STATE_SELECT_IR	= JTAG_STATE_IR_MASK | JTAG_SUB_STATE_SELECT,
+	JTAG_STATE_CAPTURE_IR	= JTAG_STATE_IR_MASK | JTAG_SUB_STATE_CAPTURE,
+	JTAG_STATE_SHIFT_IR	= JTAG_STATE_IR_MASK | JTAG_SUB_STATE_SHIFT,
+	JTAG_STATE_EXIT1_IR	= JTAG_STATE_IR_MASK | JTAG_SUB_STATE_EXIT1,
+	JTAG_STATE_PAUSE_IR	= JTAG_STATE_IR_MASK | JTAG_SUB_STATE_PAUSE,
+	JTAG_STATE_EXIT2_IR	= JTAG_STATE_IR_MASK | JTAG_SUB_STATE_EXIT2,
+	JTAG_STATE_UPDATE_IR	= JTAG_STATE_IR_MASK | JTAG_SUB_STATE_UPDATE,
+
+	JTAG_STATE_MAX
+};
+
+#define JTAG_STATE_IN_DR(state)	((state) & JTAG_STATE_DR_MASK)
+#define JTAG_STATE_IN_IR(state)	((state) & JTAG_STATE_IR_MASK)
+
+#ifdef __KERNEL__
+
+#define JTAG_BUF_SIZE	2048
+
+struct fbxjtag_data {
+	const char	*name;
+	struct {
+		struct fbxgpio_pin	*tck;
+		struct fbxgpio_pin	*tms;
+		struct fbxgpio_pin	*tdi;
+		struct fbxgpio_pin	*tdo;
+	}		gpios;
+	unsigned long	clock_delay;
+	unsigned long	wait_tms;
+	unsigned long	data_read_size;
+	unsigned long	instruction_read_size;
+	struct device	*dev;
+	enum jtag_state state;
+	char		nb_reset;
+	char		dr_buf[JTAG_BUF_SIZE];
+	unsigned 	dr_w;
+	unsigned 	dr_r;
+	char		ir_buf[JTAG_BUF_SIZE];
+	unsigned 	ir_r;
+	unsigned 	ir_w;
+};
+#endif
+
+#endif /* !FBXJTAG_H_ */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/linux/fbxmtd_map_ioctl.h	2015-11-02 19:00:47.133222796 +0100
@@ -0,0 +1,52 @@
+/*
+ * fbxmtd_map_ioctl.h for linux-freebox
+ * Created by <nschichan@freebox.fr> on Thu Feb  8 20:37:28 2007
+ * Freebox SA
+ */
+
+#ifndef FBXMTD_MAP_IOCTL_H
+# define FBXMTD_MAP_IOCTL_H
+
+/*
+ * IOCTL interface
+ */
+#define FBXMTD_MINOR	242
+
+#define FBXMTD_MAP_IOCTL_MAX_DEV	2
+#define FBXMTD_MAP_IOCTL_MAX_PART	16
+
+struct fbxmtd_map_ioctl_part
+{
+	char		name[32];
+	uint32_t	offset;
+	uint32_t	size;
+	uint32_t	flags;
+};
+
+struct fbxmtd_map_ioctl_dev
+{
+	char				name[32];
+	uint32_t			base_phys;
+	int				bus_width;
+	uint32_t			size;
+	uint32_t			status;
+	struct fbxmtd_map_ioctl_part	parts[FBXMTD_MAP_IOCTL_MAX_PART];
+	int				num_parts;
+};
+
+#define FBXMTD_MAP_IOCTL_NR	0x42
+
+struct fbxmtd_map_ioctl_query
+{
+	uint32_t	cmd;
+	uint32_t	param;
+	int		result;
+	void __user	*user_buf;
+	uint32_t	user_buf_size;
+};
+
+#define FBXMTDCTL_CMD_GET_DEVICES	0x1
+#define FBXMTDCTL_CMD_ADD_DEVICE	0x2
+#define FBXMTDCTL_CMD_DEL_DEVICE	0x3
+
+#endif /* !FBXMTD_MAP_IOCTL_H */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/linux/fbxprocfs.h	2015-11-02 18:59:07.284435689 +0100
@@ -0,0 +1,40 @@
+#ifndef FBXPROCFS_H_
+#define FBXPROCFS_H_
+
+#include <linux/proc_fs.h>
+#include <asm/atomic.h>
+#include <linux/seq_file.h>
+
+struct fbxprocfs_client
+{
+	const char *dirname;
+	struct module *owner;
+	struct proc_dir_entry *dir;
+	atomic_t refcount;
+	struct list_head list;
+};
+
+struct fbxprocfs_desc {
+	char		*name;
+	unsigned long	id;
+	int	(*rfunc)(struct seq_file *, void *);
+	int	(*wfunc)(struct file *, const char *, unsigned long, void *);
+};
+
+struct fbxprocfs_client *fbxprocfs_add_client(const char *dirname,
+					      struct module *owner);
+
+int fbxprocfs_remove_client(struct fbxprocfs_client *client);
+
+
+int
+fbxprocfs_create_entries(struct fbxprocfs_client *client,
+			 const struct fbxprocfs_desc *ro_desc,
+			 const struct fbxprocfs_desc *rw_desc);
+
+int
+fbxprocfs_remove_entries(struct fbxprocfs_client *client,
+			 const struct fbxprocfs_desc *ro_desc,
+			 const struct fbxprocfs_desc *rw_desc);
+
+#endif /* FBXPROCFS_H_ */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/linux/fbxserial.h	2015-11-18 18:24:33.260176374 +0100
@@ -0,0 +1,122 @@
+#ifndef FBXSERIAL_H_
+#define FBXSERIAL_H_
+
+#include <linux/kernel.h>
+#include <linux/string.h>
+
+/*
+ * some part of serial may vary, we use abstract struct to store this,
+ * data content depends on type.
+ */
+#define EXTINFO_SIZE		128
+#define EXTINFO_MAX_COUNT	16
+
+/*
+ * extdev desc
+ */
+#define EXTINFO_TYPE_EXTDEV	1
+
+#define EXTDEV_TYPE_BUNDLE	1
+#define EXTDEV_TYPE_MAX		2
+
+struct fbx_serial_extinfo {
+	u32			type;
+
+	union {
+		/* extdev */
+		struct {
+			u32	type;
+			u32	model;
+			char	serial[64];
+		} extdev;
+
+		/* raw access */
+		unsigned char	data[EXTINFO_SIZE];
+	} u;
+}  __attribute__ ((packed));;
+
+
+/*
+ * master serial structure
+ */
+
+#define FBXSERIAL_VERSION	1
+
+#define FBXSERIAL_MAGIC		0x2d9521ab
+
+#define MAC_ADDR_SIZE		6
+#define RANDOM_DATA_SIZE	32
+
+/*
+ * this  is the  maximum size  we accept  to check  crc32  against, so
+ * structure may no grow larger than this
+ */
+#define FBXSERIAL_MAX_SIZE	8192
+
+struct fbx_serial {
+	u32	crc32;
+	u32	magic;
+	u32	struct_version;
+	u32	len;
+
+	/* board serial */
+	u16	type;
+	u8	version;
+	u8	manufacturer;
+	u16	year;
+	u8	week;
+	u32	number;
+	u32	flags;
+
+	/* mac address base */
+	u8	mac_addr_base[MAC_ADDR_SIZE];
+
+	/* mac address count */
+	u8	mac_count;
+
+	/* random data */
+	u8	random_data[RANDOM_DATA_SIZE];
+
+	/* last update of data (seconds since epoch) */
+	u32	last_modified;
+
+	/* count of following extinfo tag */
+	u32	extinfo_count;
+
+	/* beginning of extended info */
+	struct fbx_serial_extinfo	extinfos[EXTINFO_MAX_COUNT];
+
+} __attribute__ ((packed));
+
+
+/*
+ * default value to use in case magic is wrong (no cksum in that case)
+ */
+static inline void fbxserial_set_default(struct fbx_serial *s)
+{
+	memset(s, 0, sizeof (*s));
+	s->magic = FBXSERIAL_MAGIC;
+	s->struct_version = FBXSERIAL_VERSION;
+	s->len = sizeof (*s);
+	s->manufacturer = '_';
+	memcpy(s->mac_addr_base, "\x00\x07\xCB\x00\x00\xFD", 6);
+	s->mac_count = 1;
+}
+
+void
+fbxserialinfo_get_random(unsigned char *data, unsigned int len);
+
+const void *
+fbxserialinfo_get_mac_addr(unsigned int index);
+
+int
+fbxserialinfo_read(void *data, struct fbx_serial *out);
+
+struct fbx_serial *fbxserialinfo_get(void);
+
+/*
+ * implemented in board specific code
+ */
+const struct fbx_serial *arch_get_fbxserial(void);
+
+#endif /* FBXSERIAL_H_ */
diff -Nruw linux-4.2.6-fbx/include/linux/hdmi-cec./dev.h linux-4.2.6-fbx/include/linux/hdmi-cec/dev.h
--- linux-4.2.6-fbx/include/linux/hdmi-cec./dev.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/include/linux/hdmi-cec/dev.h	2015-11-02 19:00:25.385051364 +0100
@@ -0,0 +1,30 @@
+#ifndef __HDMI_CEC_DEV_H
+#define __HDMI_CEC_DEV_H
+
+#include <linux/ioctl.h>
+#include <linux/hdmi-cec/hdmi-cec.h>
+
+#define CEC_IOCTL_BASE	'C'
+
+#define CEC_SET_LOGICAL_ADDRESS	_IOW(CEC_IOCTL_BASE, 0, int)
+#define CEC_RESET_DEVICE	_IOW(CEC_IOCTL_BASE, 3, int)
+#define CEC_GET_COUNTERS	_IOR(CEC_IOCTL_BASE, 4, struct cec_counters)
+#define CEC_SET_RX_MODE		_IOW(CEC_IOCTL_BASE, 5, enum cec_rx_mode)
+#define CEC_GET_TX_STATUS	_IOW(CEC_IOCTL_BASE, 6, struct cec_tx_status)
+#define CEC_SET_DETACHED_CONFIG	_IOW(CEC_IOCTL_BASE, 7, struct cec_detached_config)
+
+#define CEC_MAX_DEVS	(10)
+
+#ifdef __KERNEL__
+
+struct cec_adapter;
+
+int __init cec_cdev_init(void);
+void __exit cec_cdev_exit(void);
+
+int cec_create_adapter_node(struct cec_adapter *);
+void cec_remove_adapter_node(struct cec_adapter *);
+
+#endif /* __KERNEL__ */
+
+#endif /* __HDMI_CEC_DEV_H */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/linux/smsc_cap1066.h	2015-11-02 18:59:13.136481816 +0100
@@ -0,0 +1,12 @@
+#ifndef SMSC_CAP1066_H_
+#define SMSC_CAP1066_H_
+
+#define CAP1066_MAX_BTNS	6
+
+struct smsc_cap1066_pdata {
+	unsigned short	key_map[CAP1066_MAX_BTNS];
+	unsigned int	irq_gpio;
+	bool		has_irq_gpio;
+};
+
+#endif /* ! SMSC_CAP1066_H_ */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/linux/spi/orion_tdm_spi.h	2015-11-02 18:59:13.560485163 +0100
@@ -0,0 +1,8 @@
+#ifndef __LINUX_SPI_ORION_TDM_SPI_H
+#define __LINUX_SPI_ORION_TDM_SPI_H
+
+struct orion_tdm_spi_info {
+	int	cs_use_gpio[2];
+};
+
+#endif
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/linux/spi/ssd1327.h	2015-11-02 18:59:13.796487031 +0100
@@ -0,0 +1,20 @@
+#ifndef __LINUX_SPI_SSD1327_H
+#define __LINUX_SPI_SSD1327_H
+
+struct ssd1327_platform_data {
+	/* attached screen info */
+	unsigned int		width;
+	unsigned int		height;
+
+	int			rotate;
+
+	/* gpio used to select command/data */
+	int			data_select_gpio;
+
+	/* watchdog (second), enabled if non zero, screen is blanked
+	 * if nothing is written for this number of seconds */
+	unsigned int		watchdog;
+};
+
+#endif /* ! __LINUX_SPI_SSD1327_H */
+
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/net/ip6_ffn.h	2015-11-18 18:24:33.392177430 +0100
@@ -0,0 +1,53 @@
+#ifndef IP6_FFN_H_
+#define IP6_FFN_H_
+
+#include <linux/types.h>
+#include <linux/net.h>
+#include <net/route.h>
+#include <net/netfilter/nf_conntrack.h>
+
+struct ffn6_data {
+	u32 new_sip[4];
+	u32 new_dip[4];
+
+	u16 new_sport;
+	u16 new_dport;
+	__sum16 adjustment;
+	u8 new_tos;
+	u32 new_skb_prio;
+	u32 new_mark;
+
+	u32 force_skb_prio : 1;
+	u32 alter : 1;
+	u32 tos_change : 1;
+	struct dst_entry *dst;
+	struct nf_conn *ct;
+	enum ip_conntrack_info ctinfo;
+
+	void (*priv_destructor)(void *);
+	u32 ffn_priv_area[8];
+};
+
+struct ffn6_lookup_entry {
+	u32 sip[4];
+	u32 dip[4];
+	u16 sport;
+	u16 dport;
+	u8 protocol;
+	u8 added_when;
+#ifdef CONFIG_IPV6_FFN_PROCFS
+	uint64_t forwarded_bytes;
+	uint32_t forwarded_packets;
+#endif
+	struct list_head next;
+	struct ffn6_data manip;
+	struct list_head all_next;
+};
+
+extern spinlock_t ffn6_lock;
+struct ffn6_lookup_entry *__ffn6_get(const u32 *sip,
+				     const u32 *dip,
+				     u16 sport, u16 dport,
+				     int is_tcp);
+
+#endif /* ! IP6_FFN_H_*/
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/net/ip_ffn.h	2015-11-18 18:24:33.396177455 +0100
@@ -0,0 +1,51 @@
+#ifndef IP_FFN_H_
+#define IP_FFN_H_
+
+#include <linux/types.h>
+#include <linux/net.h>
+#include <net/route.h>
+#include <net/netfilter/nf_conntrack.h>
+
+struct ffn_data {
+	u32 new_sip;
+	u32 new_dip;
+	u16 new_sport;
+	u16 new_dport;
+	u8 new_tos;
+	u8 force_skb_prio : 1;
+	u8 alter : 1;
+	u8 tos_change : 1;
+	__sum16 ip_adjustment;
+	__sum16 l4_adjustment;
+	unsigned int new_skb_prio;
+	u32 new_mark;
+	struct dst_entry *dst;
+	struct nf_conn *ct;
+	enum ip_conntrack_info ctinfo;
+
+	void (*priv_destructor)(void *);
+	u32 ffn_priv_area[8];
+};
+
+struct ffn_lookup_entry {
+	int added_when;
+	u32 sip;
+	u32 dip;
+	u16 sport;
+	u16 dport;
+	u8 protocol;
+#ifdef CONFIG_IP_FFN_PROCFS
+	uint64_t forwarded_bytes;
+	uint32_t forwarded_packets;
+#endif
+	struct list_head next;
+	struct ffn_data manip;
+	struct list_head all_next;
+};
+
+extern spinlock_t ffn_lock;
+struct ffn_lookup_entry *__ffn_get(u32 sip, u32 dip,
+				   u16 sport, u16 dport,
+				   int is_tcp);
+
+#endif /* ! IP_FFN_H_*/
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/uapi/linux/exfat_user.h	2015-11-02 19:00:10.348932830 +0100
@@ -0,0 +1,47 @@
+/*
+ * exfat_user.h for exfat
+ * Created by <nschichan@freebox.fr> on Fri Aug 23 15:31:08 2013
+ */
+
+#ifndef __EXFAT_USER_H
+# define __EXFAT_USER_H
+
+struct exfat_fragment {
+	uint32_t	fcluster_start;
+	uint32_t	dcluster_start;
+	uint32_t	nr_clusters;
+	uint64_t	sector_start;
+};
+
+struct exfat_fragment_head {
+	uint32_t		fcluster_start;
+	uint32_t		nr_fragments;
+	uint32_t		sector_size;
+	uint32_t		cluster_size;
+	struct exfat_fragment	fragments[0];
+};
+
+struct exfat_bitmap_data {
+	uint32_t		start_cluster;
+	uint32_t		nr_clusters;
+	uint64_t		sector_start;
+	uint64_t		nr_sectors;
+};
+
+struct exfat_bitmap_head {
+	uint32_t			start_cluster;
+	uint32_t			nr_entries;
+	struct exfat_bitmap_data	entries[0];
+};
+
+struct exfat_dirent_head {
+	uint32_t offset;
+	uint32_t nr_entries;
+	uint8_t entries[0];
+};
+
+#define EXFAT_IOCGETFRAGMENTS	_IOR('X', 0x01, struct exfat_fragment_head)
+#define EXFAT_IOCGETBITMAP	_IOR('X', 0x02, struct exfat_bitmap_head)
+#define EXFAT_IOCGETDIRENTS	_IOR('X', 0x03, struct exfat_dirent_head)
+
+#endif /* !__EXFAT_USER_H */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/uapi/linux/fbxatm.h	2015-11-18 18:24:33.448177864 +0100
@@ -0,0 +1,158 @@
+/*
+ * Generic fbxatm definition, exported to userspace
+ */
+#ifndef LINUX_FBXATM_H_
+#define LINUX_FBXATM_H_
+
+#include <linux/types.h>
+#include <linux/if.h>
+
+#define FBXATM_IOCTL_MAGIC		0xd3
+
+/* allow userspace usage without up to date kernel headers */
+#ifndef PF_FBXATM
+#define PF_FBXATM			32
+#define AF_FBXATM			PF_FBXATM
+#endif
+
+struct fbxatm_vcc_id {
+	int				dev_idx;
+	__u32				vpi;
+	__u32				vci;
+};
+
+enum fbxatm_vcc_user {
+	FBXATM_VCC_USER_NONE = 0,
+	FBXATM_VCC_USER_2684,
+	FBXATM_VCC_USER_PPPOA,
+};
+
+enum fbxatm_vcc_traffic_class {
+	FBXATM_VCC_TC_UBR_NO_PCR = 0,
+	FBXATM_VCC_TC_UBR,
+};
+
+struct fbxatm_vcc_qos {
+	__u32				traffic_class;
+	__u32				max_sdu;
+	__u32				max_buffered_pkt;
+	__u32				priority;
+	__u32				rx_priority;
+};
+
+
+/*
+ * VCC related
+ */
+struct fbxatm_vcc_params {
+	/* ADD/DEL/GET */
+	struct fbxatm_vcc_id		id;
+
+	/* ADD/GET */
+	struct fbxatm_vcc_qos		qos;
+
+	/* GET */
+	enum fbxatm_vcc_user		user;
+};
+
+#define FBXATM_IOCADD		_IOW(FBXATM_IOCTL_MAGIC,	1,	\
+					struct fbxatm_vcc_params)
+
+#define FBXATM_IOCDEL		_IOR(FBXATM_IOCTL_MAGIC,	2,	\
+					struct fbxatm_vcc_params)
+
+#define FBXATM_IOCGET		_IOWR(FBXATM_IOCTL_MAGIC,	3,	\
+					struct fbxatm_vcc_params)
+
+
+struct fbxatm_vcc_drop_params {
+	struct fbxatm_vcc_id		id;
+	unsigned int			drop_count;
+};
+
+#define FBXATM_IOCDROP		_IOWR(FBXATM_IOCTL_MAGIC,	5,	\
+					struct fbxatm_vcc_drop_params)
+
+/*
+ * OAM related
+ */
+enum fbxatm_oam_ping_type {
+	FBXATM_OAM_PING_SEG_F4	= 0,
+	FBXATM_OAM_PING_SEG_F5,
+	FBXATM_OAM_PING_E2E_F4,
+	FBXATM_OAM_PING_E2E_F5,
+};
+
+struct fbxatm_oam_ping_req {
+	/* only dev_idx for F4 */
+	struct fbxatm_vcc_id		id;
+
+	__u8				llid[16];
+	enum fbxatm_oam_ping_type	type;
+};
+
+#define FBXATM_IOCOAMPING	_IOWR(FBXATM_IOCTL_MAGIC,	10,	\
+				      struct fbxatm_oam_ping_req)
+
+
+/*
+ * PPPOA related
+ */
+enum fbxatm_pppoa_encap {
+	FBXATM_EPPPOA_AUTODETECT = 0,
+	FBXATM_EPPPOA_VCMUX,
+	FBXATM_EPPPOA_LLC,
+};
+
+struct fbxatm_pppoa_vcc_params {
+	struct fbxatm_vcc_id		id;
+	__u32				encap;
+	__u32				cur_encap;
+};
+
+#define FBXATM_PPPOA_IOCADD	_IOW(FBXATM_IOCTL_MAGIC,	20,	\
+					struct fbxatm_pppoa_vcc_params)
+
+#define FBXATM_PPPOA_IOCDEL	_IOW(FBXATM_IOCTL_MAGIC,	21,	\
+					struct fbxatm_pppoa_vcc_params)
+
+#define FBXATM_PPPOA_IOCGET	_IOWR(FBXATM_IOCTL_MAGIC,	22,	\
+					struct fbxatm_pppoa_vcc_params)
+
+
+
+/*
+ * 2684 related
+ */
+enum fbxatm_2684_encap {
+	FBXATM_E2684_VCMUX = 0,
+	FBXATM_E2684_LLC,
+};
+
+enum fbxatm_2684_payload {
+	FBXATM_P2684_BRIDGE = 0,
+	FBXATM_P2684_ROUTED,
+};
+
+#define FBXATM_2684_MAX_VCC		8
+
+struct fbxatm_2684_vcc_params {
+	struct fbxatm_vcc_id		id_list[FBXATM_2684_MAX_VCC];
+	size_t				id_count;
+
+	__u32				encap;
+	__u32				payload;
+	char				dev_name[IFNAMSIZ];
+};
+
+
+#define FBXATM_2684_IOCADD	_IOW(FBXATM_IOCTL_MAGIC,	30,	\
+					struct fbxatm_2684_vcc_params)
+
+#define FBXATM_2684_IOCDEL	_IOW(FBXATM_IOCTL_MAGIC,	31,	\
+					struct fbxatm_2684_vcc_params)
+
+#define FBXATM_2684_IOCGET	_IOWR(FBXATM_IOCTL_MAGIC,	32,	\
+					struct fbxatm_2684_vcc_params)
+
+#endif /* LINUX_FBXATM_H_ */
diff -Nruw linux-4.2.6-fbx/include/uapi/linux/hdmi-cec./hdmi-cec.h linux-4.2.6-fbx/include/uapi/linux/hdmi-cec/hdmi-cec.h
--- linux-4.2.6-fbx/include/uapi/linux/hdmi-cec./hdmi-cec.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/include/uapi/linux/hdmi-cec/hdmi-cec.h	2015-11-02 19:00:25.385051364 +0100
@@ -0,0 +1,153 @@
+#ifndef __UAPI_HDMI_CEC_H
+#define __UAPI_HDMI_CEC_H
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+
+/* Common defines for HDMI CEC */
+#define CEC_BCAST_ADDR		(0x0f)
+#define CEC_ADDR_MAX		CEC_BCAST_ADDR
+
+#define CEC_MAX_MSG_LEN		(16)	/* 16 blocks */
+
+enum cec_rx_msg_flags {
+	/*
+	 * an ACK was received for this message
+	 */
+	CEC_RX_F_ACKED			= (1 << 0),
+
+	/*
+	 * message was fully received
+	 */
+	CEC_RX_F_COMPLETE		= (1 << 1),
+};
+
+/**
+ * struct cec_rx_msg - user-space exposed cec message cookie
+ * @data:	cec message payload
+ * @len:	cec message length
+ * @valid:	0 for invalid message
+ * @flags:	flag field (cec_rx_msg_flags)
+ */
+struct cec_rx_msg {
+	__u8	data[CEC_MAX_MSG_LEN];
+	__u8	len;
+	__u8	valid;
+	__u8	flags;
+
+} __attribute__((packed));
+
+enum cec_tx_status_flags {
+	/*
+	 * message was nacked at some point
+	 */
+	CEC_TX_F_NACK			= (1 << 0),
+
+	/*
+	 * abort sending because total time to send was elapsed
+	 */
+	CEC_TX_F_TIMEOUT		= (1 << 1),
+
+	/*
+	 * abort sending because maximum number of retry has passed
+	 */
+	CEC_TX_F_MAX_RETRIES		= (1 << 2),
+
+	/*
+	 * abort sending because of arbitration loss
+	 */
+	CEC_TX_F_ARBITRATION_LOST	= (1 << 3),
+
+	/*
+	 * message failed for other reason
+	 */
+	CEC_TX_F_UNKNOWN_ERROR		= (1 << 7),
+};
+
+/**
+ * struct cec_tx_msg - user-space exposed cec message cookie
+ * @expire_ms:	how long we try to send message (milliseconds)
+ * @data:	cec message payload
+ * @len:	cec message length
+ * @success:	0 => message was sent, else => failed to send message
+ * @flags:	flag field (cec_tx_msg_flags)
+ * @tries:	number of try done to send message
+ */
+struct cec_tx_msg {
+	__u16	expire_ms;
+	__u8	data[CEC_MAX_MSG_LEN];
+	__u8	len;
+	__u8	success;
+	__u8	flags;
+	__u8	tries;
+} __attribute__((packed));
+
+struct cec_tx_status {
+	__u8	sent;
+	__u8	success;
+	__u8	flags;
+	__u8	tries;
+} __attribute__((packed));
+
+#define DETACH_CFG_F_WAKEUP		(1 << 0)
+
+struct cec_detached_config {
+	__u8	phys_addr_valid;
+	__u8	phys_addr[2];
+	__u8	flags;
+} __attribute__((packed));
+
+/* Counters */
+
+/**
+ * struct cec_rx_counters - cec adpater RX counters
+ */
+struct cec_rx_counters {
+	__u8	pkts;
+	__u8	filtered_pkts;
+	__u8	valid_pkts;
+	__u8	rx_queue_full;
+	__u8	late_ack;
+	__u8	error;
+	__u8	rx_timeout_abort;
+	__u8	rx_throttled;
+};
+
+/**
+ * struct cec_tx_counters - cec adapter TX counters
+ */
+struct cec_tx_counters {
+	__u8	done;
+	__u8	fail;
+	__u8	timeout;
+	__u8	arb_loss;
+	__u8	bad_ack_timings;
+	__u8	tx_miss_early;
+	__u8	tx_miss_late;
+};
+
+/**
+ * struct cec_counters - tx and rx cec counters
+ * @rx:	struct cec_rx_counters
+ * @tx: struct cec_tx_counters
+ */
+struct cec_counters {
+	struct cec_rx_counters	rx;
+	struct cec_tx_counters	tx;
+};
+
+/**
+ * enum cec_rx_mode - cec adapter rx mode
+ * @CEC_RX_MODE_DISABLED:	RX path is disabled (default)
+ * @CEC_RX_MODE_DEFAULT:	accept only unicast traffic
+ * @CEC_RX_MODE_ACCEPT_ALL:	accept all incoming RX traffic (sniffing mode)
+ * @CEC_RX_MODE_MAX:		sentinel
+ */
+enum cec_rx_mode {
+	CEC_RX_MODE_DISABLED = 0,
+	CEC_RX_MODE_DEFAULT,
+	CEC_RX_MODE_ACCEPT_ALL,
+	CEC_RX_MODE_MAX
+};
+
+#endif /* __UAPI_HDMI_CEC_H */
diff -Nruw linux-4.2.6-fbx/include/uapi/linux/hdmi-cec./Kbuild linux-4.2.6-fbx/include/uapi/linux/hdmi-cec/Kbuild
--- linux-4.2.6-fbx/include/uapi/linux/hdmi-cec./Kbuild	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/include/uapi/linux/hdmi-cec/Kbuild	2015-11-02 19:00:25.385051364 +0100
@@ -0,0 +1 @@
+header-y	+= hdmi-cec.h dev.h
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/include/uapi/linux/prctl-private.h	2015-11-18 18:24:33.464177991 +0100
@@ -0,0 +1,10 @@
+#ifndef _LINUX_PRCTL_PRIVATE_H
+#define _LINUX_PRCTL_PRIVATE_H
+
+/*
+ * Freebox addition: set/get exec mode.
+ */
+#define PR_SET_EXEC_MODE	54
+#define PR_GET_EXEC_MODE	55
+
+#endif /* ! _LINUX_PRCTL_PRIVATE_H */
diff -Nruw linux-4.2.6-fbx/include/uapi/linux/remoti./Kbuild linux-4.2.6-fbx/include/uapi/linux/remoti/Kbuild
--- linux-4.2.6-fbx/include/uapi/linux/remoti./Kbuild	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/include/uapi/linux/remoti/Kbuild	2015-11-02 19:00:24.929047769 +0100
@@ -0,0 +1 @@
+header-y	+= remoti.h
diff -Nruw linux-4.2.6-fbx/include/uapi/linux/remoti./remoti.h linux-4.2.6-fbx/include/uapi/linux/remoti/remoti.h
--- linux-4.2.6-fbx/include/uapi/linux/remoti./remoti.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/include/uapi/linux/remoti/remoti.h	2015-11-02 19:00:24.929047769 +0100
@@ -0,0 +1,137 @@
+#ifndef _UAPI_REMOTI_H
+#define _UAPI_REMOTI_H
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+/*
+ * subsystem definitions
+ */
+#define NPI_SYS_RES0		0
+#define NPI_SYS_SYS		1
+#define NPI_SYS_MAC		2
+#define NPI_SYS_NWK		3
+#define NPI_SYS_AF		4
+#define NPI_SYS_ZDO		5
+#define NPI_SYS_SAPI		6
+#define NPI_SYS_UTIL		7
+#define NPI_SYS_DBG		8
+#define NPI_SYS_APP		9
+#define NPI_SYS_RCAF		10
+#define NPI_SYS_RCN		11
+#define NPI_SYS_RCN_CLI		12
+#define NPI_SYS_BOOT		13
+#define NPI_SYS_MAX		14
+#define NPI_SYS_MASK		0x1F
+
+/*
+ * type definitions
+ */
+#define NPI_POLL		0
+#define NPI_SREQ		1
+#define NPI_AREQ		2
+#define NPI_SRSP		3
+#define NPI_TYPE_MAX		4
+#define NPI_TYPE_MASK		3
+#define NPI_TYPE_SHIFT		5
+
+
+/* common error codes (see RemoTI API) */
+#define RTI_SUCCESS		0x00
+
+/*
+ * rti user message
+ */
+#define NPI_MAX_DATA_LEN	123
+
+struct rti_msg {
+	__u8	type;
+	__u8	subsys;
+	__u8	cmd;
+
+	__u8	data_len;
+	__u8	data[NPI_MAX_DATA_LEN];
+
+	__u8	custom_reply_cmd;
+	__u8	reply_cmd;
+	__u8	reply_len;
+	__u8	reply[NPI_MAX_DATA_LEN];
+};
+
+/*
+ * socket addr family on "user" device
+ */
+#ifndef PF_REMOTI
+#define PF_REMOTI			37
+#define AF_REMOTI			PF_REMOTI
+#endif
+
+struct sockaddr_rti {
+	__u32	device_id;
+};
+
+#define SOL_REMOTI			280
+#define REMOTI_REGISTER_CB		0
+
+struct rti_callback {
+	__u8	subsys;
+	__u8	cmd;
+};
+
+/*
+ * ioctl on uart device
+ */
+enum rti_dev_state {
+	RTI_DEV_S_STOPPED = 0,
+	RTI_DEV_S_BOOTING,
+	RTI_DEV_S_BOOT_FAILED,
+	RTI_DEV_S_OPERATIONAL,
+	RTI_DEV_S_STOPPING,
+	RTI_DEV_S_DEAD,
+};
+
+struct rti_dev_status {
+	__u32	dev_state;
+	__u32	fw_version;
+};
+
+struct rti_dev_stats {
+	__u64	tx_bytes;
+	__u64	tx_packets;
+
+	__u64	tx_boot_packets;
+	__u64	tx_rcaf_packets;
+	__u64	tx_util_packets;
+	__u64	tx_other_packets;
+
+
+	__u64	rx_bytes;
+	__u64	rx_packets;
+	__u64	rx_bad_sof;
+	__u64	rx_len_errors;
+	__u64	rx_fcs_errors;
+	__u64	rx_tty_errors;
+	__u64	rx_full_errors;
+	__u64	rx_subsys_errors;
+	__u64	rx_type_errors;
+	__u64	rx_no_callback;
+
+	__u64	rx_boot_packets;
+	__u64	rx_rcaf_packets;
+	__u64	rx_util_packets;
+	__u64	rx_other_packets;
+};
+
+enum {
+	RTI_BOOT_FLAGS_FORCE_UPDATE	= (1 << 0),
+};
+
+#define RTI_IOCTL_MAGIC		0xd4
+#define RTI_ATTACH_DEVICE	_IOR(RTI_IOCTL_MAGIC, 1, __u32)
+#define RTI_GET_STATUS		_IOW(RTI_IOCTL_MAGIC, 2, struct rti_dev_status)
+#define RTI_GET_STATS		_IOW(RTI_IOCTL_MAGIC, 3, struct rti_dev_stats)
+
+#define RTI_START_DEVICE	_IOR(RTI_IOCTL_MAGIC, 8, __u32)
+#define RTI_STOP_DEVICE		_IO(RTI_IOCTL_MAGIC, 9)
+
+#endif /* _UAPI_REMOTI_H */
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/lib/fbxserial.c	2015-11-18 18:24:33.572178850 +0100
@@ -0,0 +1,174 @@
+#include <linux/compiler.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/vmalloc.h>
+#include <linux/crc32.h>
+#include <linux/slab.h>
+
+#include <asm/io.h>
+
+#include <linux/fbxserial.h>
+
+#define PFX "builtin-fbxserial: "
+
+static void __init
+fbxserialinfo_use_default(struct fbx_serial *serial)
+{
+	printk(KERN_WARNING PFX "warning: using default serial infos\n");
+	fbxserial_set_default(serial);
+}
+
+/*
+ * add trailing 0 for bundle string here.
+ */
+static void __init
+bundle_fixup(struct fbx_serial *serial)
+{
+	struct fbx_serial_extinfo *p;
+	int i;
+
+	for (i = 0; i < be32_to_cpu(serial->extinfo_count); i++) {
+
+		if (i >= EXTINFO_MAX_COUNT)
+			break;
+
+		p = &serial->extinfos[i];
+		if (be32_to_cpu(p->type) == EXTINFO_TYPE_EXTDEV &&
+		    be32_to_cpu(p->u.extdev.type) == EXTDEV_TYPE_BUNDLE) {
+			int size;
+
+			size = sizeof (p->u.extdev.serial);
+			p->u.extdev.serial[size - 1] = 0;
+		}
+	}
+}
+
+/*
+ * called from  arch code early  in the boot sequence.   This function
+ * returns 1  in case serial infos are  invalid/unreadable and default
+ * values have been used.
+ */
+int __init
+fbxserialinfo_read(void *data, struct fbx_serial *out)
+{
+	uint32_t sum;
+
+	/*
+	 * get partial serial data from flash/whatever.
+	 */
+	memcpy(out, data, sizeof (*out));
+
+	/* check magic first */
+	if (be32_to_cpu(out->magic) != FBXSERIAL_MAGIC) {
+		printk(KERN_NOTICE PFX "invalid magic (%08x, expected %08x), "
+			"using defaults !\n", be32_to_cpu(out->magic),
+		       FBXSERIAL_MAGIC);
+		goto out_default;
+	}
+
+	/* fetch size for which we have to check CRC */
+	if (be32_to_cpu(out->len) > FBXSERIAL_MAX_SIZE) {
+		printk(KERN_NOTICE PFX "structure size too big (%d), "
+		       "using defaults !\n", be32_to_cpu(out->len));
+		goto out_default;
+	}
+
+	/* compute and check checksum */
+	sum = crc32(0, data + 4, be32_to_cpu(out->len) - 4);
+
+	if (be32_to_cpu(out->crc32) != sum) {
+		printk(KERN_NOTICE PFX "invalid checksum (%08x, "
+		       "expected %08x), using defaults !\n", sum,
+		       be32_to_cpu(out->crc32));
+		goto out_default;
+	}
+
+	printk(KERN_INFO PFX "Found valid serial infos !\n");
+	bundle_fixup(out);
+	return 0;
+
+ out_default:
+	fbxserialinfo_use_default(out);
+	bundle_fixup(out);
+	return 1;
+}
+
+void
+fbxserialinfo_get_random(unsigned char *data, unsigned int len)
+{
+	const struct fbx_serial *s;
+
+	s = arch_get_fbxserial();
+
+	if (len > sizeof (s->random_data))
+		len = sizeof (s->random_data);
+
+	memcpy(data, s->random_data, len);
+}
+EXPORT_SYMBOL(fbxserialinfo_get_random);
+
+static u8 *mac_table;
+
+static void inc_mac(u8 *mac, int count)
+{
+	int index = 5;
+	int overflow;
+
+	do {
+		unsigned int val = mac[index] + count;
+
+		overflow = val >> 8;
+		mac[index] = val;
+		count = (count + 255) >> 8;
+		--index;
+	} while (index >= 0 && overflow);
+}
+
+static int gen_mac_table(const struct fbx_serial *s)
+{
+	int i;
+
+	mac_table = kmalloc(6 * s->mac_count, GFP_KERNEL);
+	if (!mac_table)
+		return -ENOMEM;
+
+	for (i = 0; i < s->mac_count; ++i) {
+		u8 *mac = &mac_table[6 * i];
+
+		memcpy(mac, s->mac_addr_base, 6);
+		inc_mac(mac, i);
+	}
+	return 0;
+}
+
+const void *
+fbxserialinfo_get_mac_addr(unsigned int index)
+{
+	const struct fbx_serial *s;
+
+	s = arch_get_fbxserial();
+	if (!s) {
+		pr_warn(PFX "no serial available: using default.\n");
+		goto default_mac;
+	}
+
+	if (index >= s->mac_count) {
+		pr_warn(PFX "mac index %d too high: using default.\n",
+			index);
+		goto default_mac;
+	}
+
+	if (!mac_table) {
+		int error = gen_mac_table(s);
+		if (error) {
+			pr_err(PFX "gen_mac_table() failed: using default.\n");
+			goto default_mac;
+		}
+	}
+
+	return &mac_table[6 * index];
+
+default_mac:
+	 return "\x00\x07\xcb\x00\x00\xfd";
+}
+EXPORT_SYMBOL(fbxserialinfo_get_mac_addr);
diff -Nruw linux-4.2.6-fbx/net/fbxatm./crc10.c linux-4.2.6-fbx/net/fbxatm/crc10.c
--- linux-4.2.6-fbx/net/fbxatm./crc10.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxatm/crc10.c	2015-11-02 18:59:21.464547475 +0100
@@ -0,0 +1,48 @@
+#include <linux/types.h>
+
+static const u16 crc10_table[256] = {
+	0x0000, 0x0233, 0x0255, 0x0066, 0x0299, 0x00aa, 0x00cc, 0x02ff,
+	0x0301, 0x0132, 0x0154, 0x0367, 0x0198, 0x03ab, 0x03cd, 0x01fe,
+	0x0031, 0x0202, 0x0264, 0x0057, 0x02a8, 0x009b, 0x00fd, 0x02ce,
+	0x0330, 0x0103, 0x0165, 0x0356, 0x01a9, 0x039a, 0x03fc, 0x01cf,
+	0x0062, 0x0251, 0x0237, 0x0004, 0x02fb, 0x00c8, 0x00ae, 0x029d,
+	0x0363, 0x0150, 0x0136, 0x0305, 0x01fa, 0x03c9, 0x03af, 0x019c,
+	0x0053, 0x0260, 0x0206, 0x0035, 0x02ca, 0x00f9, 0x009f, 0x02ac,
+	0x0352, 0x0161, 0x0107, 0x0334, 0x01cb, 0x03f8, 0x039e, 0x01ad,
+	0x00c4, 0x02f7, 0x0291, 0x00a2, 0x025d, 0x006e, 0x0008, 0x023b,
+	0x03c5, 0x01f6, 0x0190, 0x03a3, 0x015c, 0x036f, 0x0309, 0x013a,
+	0x00f5, 0x02c6, 0x02a0, 0x0093, 0x026c, 0x005f, 0x0039, 0x020a,
+	0x03f4, 0x01c7, 0x01a1, 0x0392, 0x016d, 0x035e, 0x0338, 0x010b,
+	0x00a6, 0x0295, 0x02f3, 0x00c0, 0x023f, 0x000c, 0x006a, 0x0259,
+	0x03a7, 0x0194, 0x01f2, 0x03c1, 0x013e, 0x030d, 0x036b, 0x0158,
+	0x0097, 0x02a4, 0x02c2, 0x00f1, 0x020e, 0x003d, 0x005b, 0x0268,
+	0x0396, 0x01a5, 0x01c3, 0x03f0, 0x010f, 0x033c, 0x035a, 0x0169,
+	0x0188, 0x03bb, 0x03dd, 0x01ee, 0x0311, 0x0122, 0x0144, 0x0377,
+	0x0289, 0x00ba, 0x00dc, 0x02ef, 0x0010, 0x0223, 0x0245, 0x0076,
+	0x01b9, 0x038a, 0x03ec, 0x01df, 0x0320, 0x0113, 0x0175, 0x0346,
+	0x02b8, 0x008b, 0x00ed, 0x02de, 0x0021, 0x0212, 0x0274, 0x0047,
+	0x01ea, 0x03d9, 0x03bf, 0x018c, 0x0373, 0x0140, 0x0126, 0x0315,
+	0x02eb, 0x00d8, 0x00be, 0x028d, 0x0072, 0x0241, 0x0227, 0x0014,
+	0x01db, 0x03e8, 0x038e, 0x01bd, 0x0342, 0x0171, 0x0117, 0x0324,
+	0x02da, 0x00e9, 0x008f, 0x02bc, 0x0043, 0x0270, 0x0216, 0x0025,
+	0x014c, 0x037f, 0x0319, 0x012a, 0x03d5, 0x01e6, 0x0180, 0x03b3,
+	0x024d, 0x007e, 0x0018, 0x022b, 0x00d4, 0x02e7, 0x0281, 0x00b2,
+	0x017d, 0x034e, 0x0328, 0x011b, 0x03e4, 0x01d7, 0x01b1, 0x0382,
+	0x027c, 0x004f, 0x0029, 0x021a, 0x00e5, 0x02d6, 0x02b0, 0x0083,
+	0x012e, 0x031d, 0x037b, 0x0148, 0x03b7, 0x0184, 0x01e2, 0x03d1,
+	0x022f, 0x001c, 0x007a, 0x0249, 0x00b6, 0x0285, 0x02e3, 0x00d0,
+	0x011f, 0x032c, 0x034a, 0x0179, 0x0386, 0x01b5, 0x01d3, 0x03e0,
+	0x021e, 0x002d, 0x004b, 0x0278, 0x0087, 0x02b4, 0x02d2, 0x00e1,
+};
+
+static u16 crc10_byte(u16 crc, const u8 c)
+{
+	return ((crc << 8) & 0x3ff) ^ crc10_table[(crc >> 2) & 0xff] ^ c;
+}
+
+u16 crc10(u16 crc, const u8 *buffer, size_t len)
+{
+	while (len--)
+		crc = crc10_byte(crc, *buffer++);
+	return crc;
+}
diff -Nruw linux-4.2.6-fbx/net/fbxatm./fbxatm_2684.c linux-4.2.6-fbx/net/fbxatm/fbxatm_2684.c
--- linux-4.2.6-fbx/net/fbxatm./fbxatm_2684.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxatm/fbxatm_2684.c	2015-11-18 18:24:33.688179768 +0100
@@ -0,0 +1,840 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/if_arp.h>
+#include <linux/rtnetlink.h>
+#include <linux/pkt_sched.h>
+#include <linux/net.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/udp.h>
+#include <linux/icmp.h>
+#include <linux/proc_fs.h>
+#include <net/ip.h>
+#include <net/route.h>
+#include <linux/fbxatm_dev.h>
+
+#include "fbxatm_priv.h"
+
+#define PFX	"fbxatm_2684: "
+
+static LIST_HEAD(fbxatm_2684_dev_list);
+static DEFINE_MUTEX(fbxatm_2684_mutex);
+
+#define LLC_NEEDED_HEADROOM		10
+#define VCMUX_BRIDGED_NEEDED_HEADROOM	2
+
+#define LLC			0xaa, 0xaa, 0x03
+#define SNAP_BRIDGED		0x00, 0x80, 0xc2
+#define SNAP_ROUTED		0x00, 0x00, 0x00
+#define PID_ETHERNET_NOFCS	0x00, 0x07
+
+static u8 llc_bridged_802d3_pad[] = { LLC, SNAP_BRIDGED, PID_ETHERNET_NOFCS,
+				      0, 0 };
+static u8 llc_snap_routed[] = { LLC, SNAP_ROUTED };
+
+/*
+ * private data for 2684 vcc
+ */
+struct fbxatm_2684_vcc;
+
+struct fbxatm_2684_queue {
+	struct fbxatm_vcc		*vcc;
+	unsigned int			queue_idx;
+	struct fbxatm_2684_vcc		*priv;
+};
+
+struct fbxatm_2684_vcc {
+	struct fbxatm_2684_queue	queues[FBXATM_2684_MAX_VCC];
+	size_t				queue_count;
+
+	struct net_device		*dev;
+	struct fbxatm_2684_vcc_params	params;
+
+	spinlock_t			tx_lock;
+
+	struct rtnl_link_stats64	stats;
+
+	struct list_head		next;
+};
+
+static uint32_t tel_last_ip;
+
+static void warn_if_tel(struct fbxatm_2684_vcc *vcc, struct sk_buff *skb)
+{
+	struct iphdr *iph;
+	struct udphdr *udph = NULL;
+
+	iph = (struct iphdr *)skb->data;
+
+	if (iph->protocol != IPPROTO_UDP)
+		return;
+
+	if (skb_headlen(skb) < (iph->ihl * 4) + sizeof (struct udphdr))
+		return;
+
+	udph = (struct udphdr *)((unsigned char *)iph + (iph->ihl * 4));
+	if (ntohs(udph->dest) >= 5004 && ntohs(udph->dest) <= 5020) {
+		static u32 last_ip;
+		static unsigned long last_time;
+		unsigned long now;
+
+		now = jiffies;
+		if ((last_ip == iph->saddr &&
+		     (!last_time || time_before(now, last_time + 2 * HZ)))) {
+			static unsigned int consecutive;
+			consecutive++;
+			if (consecutive > 5) {
+				tel_last_ip = iph->saddr;
+				consecutive = 0;
+			}
+		}
+
+		last_time = now;
+		last_ip = iph->saddr;
+	}
+}
+
+/*
+ * procfs read callback
+ */
+static int tel_proc_show(struct seq_file *m, void *v)
+{
+	seq_printf(m, "%pI4\n", &tel_last_ip);
+	return 0;
+}
+
+static int tel_proc_write(struct file *file, const char __user *ubuf,
+			  size_t len, loff_t *off)
+{
+	tel_last_ip = 0;
+	return len;
+}
+
+static int tel_proc_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, tel_proc_show, PDE_DATA(inode));
+}
+
+static const struct file_operations tel_proc_fops = {
+	.owner          = THIS_MODULE,
+	.open           = tel_proc_open,
+	.read           = seq_read,
+	.write		= tel_proc_write,
+	.llseek         = seq_lseek,
+	.release        = single_release,
+};
+
+/*
+ * fbxatm stack receive callback, called from softirq
+ */
+static void vcc_rx_callback(struct sk_buff *skb, void *data)
+{
+	struct fbxatm_2684_queue *queue;
+	struct fbxatm_2684_vcc *priv;
+
+	queue = (struct fbxatm_2684_queue *)data;
+	priv = queue->priv;
+
+	switch (priv->params.encap) {
+	case FBXATM_E2684_VCMUX:
+		switch (priv->params.payload) {
+		case FBXATM_P2684_BRIDGE:
+			/* assume 802.3, need to remove 2 bytes zero
+			 * padding */
+			if (skb->len < 2 || memcmp(skb->data, "\0\0", 2))
+				goto drop;
+			skb_pull(skb, 2);
+			skb->protocol = eth_type_trans(skb, priv->dev);
+			memset(skb->data, 0, 2);
+			break;
+
+		case FBXATM_P2684_ROUTED:
+			/* assume ipv4 */
+			skb->protocol = htons(ETH_P_IP);
+			break;
+		}
+		break;
+
+	case FBXATM_E2684_LLC:
+		switch (priv->params.payload) {
+		case FBXATM_P2684_BRIDGE:
+		{
+			/* recognize only 802.3 */
+			if (skb->len < sizeof(llc_bridged_802d3_pad))
+				goto drop;
+
+			if (memcmp(skb->data, llc_bridged_802d3_pad, 7))
+				goto drop;
+
+			/* don't check the last bytes of pid, it can
+			 * be 1 or 7 depending on the presence of
+			 * FCS */
+			skb_pull(skb, sizeof(llc_bridged_802d3_pad));
+			skb->protocol = eth_type_trans(skb, priv->dev);
+			break;
+		}
+
+		case FBXATM_P2684_ROUTED:
+		{
+			u16 proto;
+			unsigned int offset;
+
+			if (skb->len < sizeof(llc_snap_routed) + 2)
+				goto drop;
+
+			offset = sizeof (llc_snap_routed);
+			proto = skb->data[offset] << 8;
+			proto |= skb->data[offset + 1];
+
+			skb->protocol = proto;
+			skb_pull(skb, sizeof(llc_snap_routed) + 2);
+			break;
+		}
+		}
+		break;
+	}
+
+	skb->dev = priv->dev;
+	skb->pkt_type = PACKET_HOST;
+	priv->stats.rx_bytes += skb->len;
+	priv->stats.rx_packets++;
+
+	if (priv->params.encap == FBXATM_E2684_VCMUX &&
+	    priv->params.payload == FBXATM_P2684_ROUTED &&
+	    queue->vcc->vpi == 8 && queue->vcc->vci == 35)
+		warn_if_tel(priv, skb);
+
+	netif_rx(skb);
+	return;
+
+drop:
+	priv->stats.rx_errors++;
+	dev_kfree_skb(skb);
+}
+
+/*
+ * fbxatm stack tx done callback, called from softirq
+ */
+static void vcc_tx_done_callback(void *data)
+{
+	struct fbxatm_2684_queue *queue;
+	struct fbxatm_2684_vcc *priv;
+
+	queue = (struct fbxatm_2684_queue *)data;
+	priv = queue->priv;
+
+	spin_lock(&priv->tx_lock);
+	if (__netif_subqueue_stopped(priv->dev, queue->queue_idx))
+		netif_wake_subqueue(priv->dev, queue->queue_idx);
+	spin_unlock(&priv->tx_lock);
+}
+
+/*
+ * fbxatm stack callback when vcc link changes
+ */
+static void vcc_link_change(void *data, int link,
+			    unsigned int rx_cell_rate,
+			    unsigned int tx_cell_rate)
+{
+	struct fbxatm_2684_queue *queue;
+	struct fbxatm_2684_vcc *priv;
+
+	queue = (struct fbxatm_2684_queue *)data;
+	priv = queue->priv;
+
+	if (link)
+		netif_carrier_on(priv->dev);
+	else
+		netif_carrier_off(priv->dev);
+}
+
+/*
+ * vcc user ops, callback from fbxatm stack
+ */
+static const struct fbxatm_vcc_uops fbxatm_2684_uops = {
+	.link_change	= vcc_link_change,
+	.rx_pkt		= vcc_rx_callback,
+	.tx_done	= vcc_tx_done_callback,
+};
+
+/*
+ * netdevice ->ndo_select_queue() callback
+ */
+static u16 fbxatm_2684_netdev_select_queue(struct net_device *dev,
+					   struct sk_buff *skb,
+					   void *accel_priv,
+					   select_queue_fallback_t fallback)
+{
+	/* force lower band to avoid kernel doing round robin */
+	return 0;
+}
+
+/*
+ * netdevice xmit callback
+ */
+static int fbxatm_2684_netdev_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct fbxatm_2684_vcc *priv;
+	int ret, queue_idx;
+	unsigned int needed_headroom;
+	struct fbxatm_2684_queue *queue;
+
+	priv = netdev_priv(dev);
+	queue_idx = skb_get_queue_mapping(skb);
+	queue = &priv->queues[queue_idx];
+
+	/*
+	 * check if we have to expand skb head
+	 */
+	needed_headroom = 0;
+	if (priv->params.encap == FBXATM_E2684_VCMUX) {
+		if (priv->params.payload == FBXATM_P2684_BRIDGE)
+			needed_headroom = VCMUX_BRIDGED_NEEDED_HEADROOM;
+	} else
+		needed_headroom = LLC_NEEDED_HEADROOM;
+
+	if (skb_headroom(skb) < needed_headroom) {
+		struct sk_buff *nskb;
+		unsigned int new_head;
+
+		new_head = skb_headroom(skb) + needed_headroom;
+		nskb = skb_realloc_headroom(skb, new_head);
+		dev_kfree_skb(skb);
+		if (!nskb)
+			goto dropped;
+		skb = nskb;
+	}
+
+	switch (priv->params.encap) {
+	case FBXATM_E2684_VCMUX:
+		switch (priv->params.payload) {
+		case FBXATM_P2684_BRIDGE:
+			skb_push(skb, 2);
+			memset(skb->data, 0, 2);
+			break;
+		case FBXATM_P2684_ROUTED:
+			/* nothing to do */
+			break;
+		}
+		break;
+
+	case FBXATM_E2684_LLC:
+		switch (priv->params.payload) {
+		case FBXATM_P2684_BRIDGE:
+			skb_push(skb, sizeof(llc_bridged_802d3_pad));
+			memcpy(skb->data, llc_bridged_802d3_pad,
+			       sizeof(llc_bridged_802d3_pad));
+			break;
+
+		case FBXATM_P2684_ROUTED:
+		{
+			unsigned int offset;
+
+			skb_push(skb, sizeof(llc_snap_routed));
+			memcpy(skb->data, llc_snap_routed,
+			       sizeof(llc_snap_routed));
+
+			offset = sizeof (llc_snap_routed);
+			skb->data[offset] = (skb->protocol >> 8) & 0xff;
+			skb->data[offset + 1] = skb->protocol & 0xff;
+			break;
+		}
+		}
+		break;
+	}
+
+	spin_lock(&priv->tx_lock);
+
+	ret = fbxatm_send(queue->vcc, skb);
+	if (ret) {
+		/* packet was not sent, queue is full */
+		netif_stop_subqueue(dev, queue_idx);
+		spin_unlock(&priv->tx_lock);
+		return NETDEV_TX_BUSY;
+	}
+
+	/* check if queue is full */
+	priv->stats.tx_bytes += skb->len;
+	priv->stats.tx_packets++;
+
+	if (fbxatm_vcc_queue_full(queue->vcc))
+		netif_stop_subqueue(dev, queue_idx);
+	spin_unlock(&priv->tx_lock);
+
+	return NETDEV_TX_OK;
+
+dropped:
+	priv->stats.tx_errors++;
+	return NETDEV_TX_OK;
+}
+
+/*
+ * netdevice get_stats callback
+ */
+static struct rtnl_link_stats64 *
+fbxatm_2684_netdev_get_stats64(struct net_device *dev,
+			       struct rtnl_link_stats64 *stats)
+{
+	struct fbxatm_2684_vcc *priv;
+	priv = netdev_priv(dev);
+	memcpy(stats, &priv->stats, sizeof (*stats));
+	return stats;
+}
+
+/*
+ * netdevice setup callback for bridge encap
+ */
+static void setup_bridged(struct net_device *dev)
+{
+	ether_setup(dev);
+}
+
+/*
+ * netdevice setup callback for routed encap
+ */
+static void setup_routed(struct net_device *dev)
+{
+	dev->type		= ARPHRD_PPP;
+	dev->hard_header_len	= 0;
+	dev->mtu		= 1500;
+	dev->addr_len		= 0;
+	dev->tx_queue_len	= 128;
+	dev->flags		= IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
+}
+
+static const struct net_device_ops fbxatm_2684_ops = {
+	.ndo_start_xmit		= fbxatm_2684_netdev_xmit,
+	.ndo_get_stats64	= fbxatm_2684_netdev_get_stats64,
+	.ndo_select_queue	= fbxatm_2684_netdev_select_queue,
+};
+
+/*
+ * sysfs callback, show encapsulation
+ */
+static ssize_t show_encap(struct device *d,
+			  struct device_attribute *attr, char *buf)
+{
+	struct fbxatm_2684_vcc *priv = netdev_priv(to_net_dev(d));
+
+	switch (priv->params.encap) {
+	case FBXATM_E2684_LLC:
+		return sprintf(buf, "llc\n");
+	case FBXATM_E2684_VCMUX:
+	default:
+		return sprintf(buf, "vcmux\n");
+	}
+}
+
+static DEVICE_ATTR(encap, S_IRUGO, show_encap, NULL);
+
+/*
+ * sysfs callback, show payload
+ */
+static ssize_t show_payload(struct device *d,
+			    struct device_attribute *attr, char *buf)
+{
+	struct fbxatm_2684_vcc *priv = netdev_priv(to_net_dev(d));
+
+	switch (priv->params.payload) {
+	case FBXATM_P2684_BRIDGE:
+		return sprintf(buf, "bridge\n");
+	case FBXATM_P2684_ROUTED:
+	default:
+		return sprintf(buf, "routed\n");
+	}
+}
+
+static DEVICE_ATTR(payload, S_IRUGO, show_payload, NULL);
+
+/*
+ * sysfs callback, show vcc id
+ */
+static ssize_t show_vcc(struct device *d,
+			struct device_attribute *attr, char *buf)
+{
+	struct fbxatm_2684_vcc *priv = netdev_priv(to_net_dev(d));
+
+	return sprintf(buf, "%u.%u.%u\n",
+		       priv->queues[0].vcc->adev->ifindex,
+		       priv->queues[0].vcc->vpi, priv->queues[0].vcc->vci);
+}
+
+static DEVICE_ATTR(vcc, S_IRUGO, show_vcc, NULL);
+
+static struct attribute *fbxatm2684_attrs[] = {
+	&dev_attr_encap.attr,
+	&dev_attr_payload.attr,
+	&dev_attr_vcc.attr,
+	NULL
+};
+
+static struct attribute_group fbxatm2684_group = {
+	.name = "fbxatm2684",
+	.attrs = fbxatm2684_attrs,
+};
+
+/*
+ * create sysfs files for 2684 device
+ */
+static int vcc2684_sysfs_register(struct fbxatm_2684_vcc *priv,
+				  struct net_device *dev)
+{
+	int ret;
+
+	ret = sysfs_create_group(&dev->dev.kobj, &fbxatm2684_group);
+	if (ret)
+		goto out1;
+
+	ret = sysfs_create_link(&dev->dev.kobj,
+				&priv->queues[0].vcc->adev->dev.kobj,
+				"fbxatm_dev");
+	if (ret)
+		goto out2;
+
+	return 0;
+
+out2:
+	sysfs_remove_group(&dev->dev.kobj, &fbxatm2684_group);
+out1:
+	return ret;
+}
+
+/*
+ * remove sysfs files for 2684 device
+ */
+static void vcc2684_sysfs_unregister(struct fbxatm_2684_vcc *priv,
+				     struct net_device *dev)
+{
+	sysfs_remove_group(&dev->dev.kobj, &fbxatm2684_group);
+	sysfs_remove_link(&dev->dev.kobj, "fbxatm_dev");
+}
+
+/*
+ * register netdevice & sysfs attribute
+ */
+static int register_2684_netdev(struct fbxatm_2684_vcc *priv,
+				struct net_device *dev)
+{
+	int ret;
+
+	/* hold rtnl while registering netdevice and creating sysfs
+	 * files to avoid race */
+	rtnl_lock();
+
+	if (strchr(dev->name, '%')) {
+		ret = dev_alloc_name(dev, dev->name);
+		if (ret < 0)
+			goto out;
+	}
+
+	ret = register_netdevice(dev);
+	if (ret)
+		goto out;
+
+	ret = vcc2684_sysfs_register(priv, dev);
+	if (ret)
+		goto out_unregister;
+
+	rtnl_unlock();
+	return 0;
+
+out_unregister:
+	unregister_netdevice(dev);
+
+out:
+	rtnl_unlock();
+	return ret;
+}
+
+/*
+ * create a RFC2684 encapsulation on given vcc
+ */
+static int __create_2684_vcc(const struct fbxatm_2684_vcc_params *params)
+{
+	struct fbxatm_2684_vcc *priv;
+	struct fbxatm_vcc *vccs[FBXATM_2684_MAX_VCC];
+	struct net_device *dev = NULL;
+	void (*netdev_setup_cb)(struct net_device *dev);
+	unsigned int headroom;
+	size_t i;
+	int ret;
+
+	/* sanity check */
+	switch (params->encap) {
+	case FBXATM_E2684_VCMUX:
+	case FBXATM_E2684_LLC:
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	switch (params->payload) {
+	case FBXATM_P2684_BRIDGE:
+		netdev_setup_cb = setup_bridged;
+		break;
+	case FBXATM_P2684_ROUTED:
+		netdev_setup_cb = setup_routed;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (!params->dev_name[0])
+		return -EINVAL;
+
+	/* bind to vcc */
+	memset(vccs, 0, sizeof (vccs));
+	for (i = 0; i < params->id_count; i++) {
+		struct fbxatm_vcc *vcc;
+
+		vcc = fbxatm_bind_to_vcc(&params->id_list[i],
+					 FBXATM_VCC_USER_2684);
+		if (IS_ERR(vcc)) {
+			ret = PTR_ERR(vcc);
+			goto fail;
+		}
+		vccs[i] = vcc;
+	}
+
+	/* create netdevice */
+	dev = alloc_netdev_mqs(sizeof(*priv), params->dev_name,
+			       NET_NAME_UNKNOWN, netdev_setup_cb,
+			       params->id_count, 1);
+	if (!dev) {
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	netif_set_real_num_tx_queues(dev, params->id_count);
+	netif_set_real_num_rx_queues(dev, 1);
+
+	priv = netdev_priv(dev);
+	memset(priv, 0, sizeof (priv));
+	memcpy(&priv->params, params, sizeof (*params));
+	memcpy(dev->name, priv->params.dev_name, IFNAMSIZ);
+
+	spin_lock_init(&priv->tx_lock);
+	priv->dev = dev;
+	for (i = 0; i < params->id_count; i++) {
+		priv->queues[i].vcc = vccs[i];
+		priv->queues[i].queue_idx = i;
+		priv->queues[i].priv = priv;
+	}
+	priv->queue_count = params->id_count;
+
+	dev->netdev_ops = &fbxatm_2684_ops;
+
+	/* make sure kernel generated packet have correct headroom for
+	 * encapsulation/payload */
+	headroom = 0;
+	for (i = 0; i < params->id_count; i++)
+		headroom = max_t(int, headroom, vccs[i]->adev->tx_headroom);
+	dev->hard_header_len += headroom;
+
+	switch (params->encap) {
+	case FBXATM_E2684_VCMUX:
+	default:
+		if (params->payload == FBXATM_P2684_BRIDGE)
+			dev->hard_header_len += VCMUX_BRIDGED_NEEDED_HEADROOM;
+		break;
+	case FBXATM_E2684_LLC:
+		dev->hard_header_len += LLC_NEEDED_HEADROOM;
+		break;
+	}
+
+	ret = register_2684_netdev(priv, dev);
+	if (ret)
+		goto fail;
+
+	if (fbxatm_vcc_link_is_up(vccs[0])) {
+		netif_carrier_on(dev);
+		netif_tx_start_all_queues(dev);
+	} else
+		netif_carrier_off(dev);
+	list_add_tail(&priv->next, &fbxatm_2684_dev_list);
+
+	for (i = 0; i < params->id_count; i++)
+		fbxatm_set_uops(vccs[i], &fbxatm_2684_uops, &priv->queues[i]);
+
+	return 0;
+
+fail:
+	for (i = 0; i < ARRAY_SIZE(vccs); i++) {
+		if (vccs[i])
+			fbxatm_unbind_vcc(vccs[i]);
+	}
+	if (dev)
+		free_netdev(dev);
+	return ret;
+}
+
+/*
+ * find 2684 vcc from id list
+ */
+static struct fbxatm_2684_vcc *__find_2684_vcc(const struct fbxatm_vcc_id *id,
+					       size_t count)
+{
+	struct fbxatm_2684_vcc *priv;
+	size_t i;
+
+	/* find it */
+	list_for_each_entry(priv, &fbxatm_2684_dev_list, next) {
+		for (i = 0; i < priv->queue_count; i++) {
+			struct fbxatm_2684_queue *q;
+			size_t j;
+
+			q = &priv->queues[i];
+
+			for (j = 0; j < count; j++) {
+				if (q->vcc->adev->ifindex == id[j].dev_idx &&
+				    q->vcc->vpi == id[0].vpi &&
+				    q->vcc->vci == id[0].vci)
+					return priv;
+			}
+		}
+	}
+	return NULL;
+}
+
+/*
+ * create a RFC2684 encapsulation on given vcc
+ */
+static int create_2684_vcc(const struct fbxatm_2684_vcc_params *params)
+{
+	int ret;
+
+	mutex_lock(&fbxatm_2684_mutex);
+	ret = __create_2684_vcc(params);
+	mutex_unlock(&fbxatm_2684_mutex);
+	return ret;
+}
+
+/*
+ * remove RFC2684 encapsulation from given vcc
+ */
+static int __remove_2684_vcc(const struct fbxatm_2684_vcc_params *params)
+{
+	struct fbxatm_2684_vcc *priv;
+	size_t i;
+
+	priv = __find_2684_vcc(params->id_list, params->id_count);
+	if (!priv)
+		return -ENOENT;
+
+	/* close netdevice, fbxatm_2684_netdev_xmit cannot be called
+	 * again */
+	rtnl_lock();
+	dev_close(priv->dev);
+	rtnl_unlock();
+
+	for (i = 0; i < priv->queue_count; i++)
+		fbxatm_unbind_vcc(priv->queues[i].vcc);
+	vcc2684_sysfs_unregister(priv, priv->dev);
+	unregister_netdev(priv->dev);
+	list_del(&priv->next);
+	free_netdev(priv->dev);
+	return 0;
+}
+
+/*
+ * remove RFC2684 encapsulation from given vcc
+ */
+static int remove_2684_vcc(const struct fbxatm_2684_vcc_params *params)
+{
+	int ret;
+
+	mutex_lock(&fbxatm_2684_mutex);
+	ret = __remove_2684_vcc(params);
+	mutex_unlock(&fbxatm_2684_mutex);
+	return ret;
+}
+
+/*
+ * 2684 related ioctl handler
+ */
+static int fbxatm_2684_ioctl(struct socket *sock,
+			     unsigned int cmd, void __user *useraddr)
+{
+	int ret;
+
+	ret = 0;
+
+	switch (cmd) {
+	case FBXATM_2684_IOCADD:
+	case FBXATM_2684_IOCDEL:
+	{
+		struct fbxatm_2684_vcc_params params;
+
+		if (copy_from_user(&params, useraddr, sizeof(params)))
+			return -EFAULT;
+
+		if (cmd == FBXATM_2684_IOCADD)
+			ret = create_2684_vcc(&params);
+		else
+			ret = remove_2684_vcc(&params);
+		break;
+	}
+
+	case FBXATM_2684_IOCGET:
+	{
+		struct fbxatm_2684_vcc_params params;
+		struct fbxatm_2684_vcc *priv;
+
+		if (copy_from_user(&params, useraddr, sizeof(params)))
+			return -EFAULT;
+
+		mutex_lock(&fbxatm_2684_mutex);
+		priv = __find_2684_vcc(params.id_list, params.id_count);
+		if (!priv)
+			ret = -ENOENT;
+		else {
+			memcpy(&params, &priv->params, sizeof (params));
+			memcpy(params.dev_name, priv->dev->name, IFNAMSIZ);
+		}
+		mutex_unlock(&fbxatm_2684_mutex);
+
+		if (ret)
+			return ret;
+
+		if (copy_to_user(useraddr, &params, sizeof(params)))
+			return -EFAULT;
+		break;
+	}
+
+	default:
+		return -ENOIOCTLCMD;
+	}
+
+	return ret;
+}
+
+static struct fbxatm_ioctl fbxatm_2684_ioctl_ops = {
+	.handler	= fbxatm_2684_ioctl,
+	.owner		= THIS_MODULE,
+};
+
+int __init fbxatm_2684_init(void)
+{
+	struct proc_dir_entry *root, *proc;
+
+	root = fbxatm_proc_misc_register("tel");
+	if (!root)
+		return -ENOMEM;
+
+	/* tel debug crap */
+	proc = proc_create_data("bad_ip", 0666, root, &tel_proc_fops, NULL);
+	if (!proc)
+		return -ENOMEM;
+
+	fbxatm_register_ioctl(&fbxatm_2684_ioctl_ops);
+	return 0;
+}
+
+void fbxatm_2684_exit(void)
+{
+	fbxatm_unregister_ioctl(&fbxatm_2684_ioctl_ops);
+}
diff -Nruw linux-4.2.6-fbx/net/fbxatm./fbxatm_core.c linux-4.2.6-fbx/net/fbxatm/fbxatm_core.c
--- linux-4.2.6-fbx/net/fbxatm./fbxatm_core.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxatm/fbxatm_core.c	2015-11-18 18:24:33.688179768 +0100
@@ -0,0 +1,207 @@
+#include <linux/init.h>
+#include <linux/net.h>
+#include <linux/socket.h>
+#include <linux/fbxatm.h>
+#include <linux/fbxatm_dev.h>
+#include <linux/module.h>
+#include <net/sock.h>
+#include "fbxatm_priv.h"
+
+static DEFINE_MUTEX(ioctl_mutex);
+static LIST_HEAD(ioctl_list);
+
+void fbxatm_register_ioctl(struct fbxatm_ioctl *ioctl)
+{
+	mutex_lock(&ioctl_mutex);
+	list_add_tail(&ioctl->next, &ioctl_list);
+	mutex_unlock(&ioctl_mutex);
+}
+
+void fbxatm_unregister_ioctl(struct fbxatm_ioctl *ioctl)
+{
+	mutex_lock(&ioctl_mutex);
+	list_del(&ioctl->next);
+	mutex_unlock(&ioctl_mutex);
+}
+
+static int fbxatm_sock_ioctl(struct socket *sock, unsigned int cmd,
+			     unsigned long arg)
+{
+	struct fbxatm_ioctl *ioctl;
+	void __user *useraddr;
+	int ret;
+
+	/* sanity check */
+	useraddr = (void __user *)arg;
+
+	if (!capable(CAP_NET_ADMIN))
+		return -EPERM;
+
+	ret = -ENOIOCTLCMD;
+	mutex_lock(&ioctl_mutex);
+
+	list_for_each_entry(ioctl, &ioctl_list, next) {
+		if (!ioctl->handler)
+			continue;
+
+		if (!try_module_get(ioctl->owner))
+			continue;
+
+		ret = ioctl->handler(sock, cmd, useraddr);
+		module_put(ioctl->owner);
+		if (ret != -ENOIOCTLCMD)
+			break;
+	}
+	mutex_unlock(&ioctl_mutex);
+
+	return ret;
+}
+
+static int fbxatm_sock_release(struct socket *sock)
+{
+	struct fbxatm_ioctl *ioctl;
+	struct sock *sk = sock->sk;
+
+	mutex_lock(&ioctl_mutex);
+
+	list_for_each_entry(ioctl, &ioctl_list, next) {
+		if (!ioctl->release)
+			continue;
+
+		if (!try_module_get(ioctl->owner))
+			continue;
+
+		ioctl->release(sock);
+		module_put(ioctl->owner);
+	}
+	mutex_unlock(&ioctl_mutex);
+
+	if (sk)
+		sock_put(sk);
+
+	return 0;
+}
+
+static const struct proto_ops fbxatm_proto_ops = {
+	.family		= PF_FBXATM,
+
+	.release =	fbxatm_sock_release,
+	.ioctl =	fbxatm_sock_ioctl,
+
+	.bind =		sock_no_bind,
+	.connect =	sock_no_connect,
+	.socketpair =	sock_no_socketpair,
+	.accept =	sock_no_accept,
+	.getname =	sock_no_getname,
+	.poll =		sock_no_poll,
+	.listen =	sock_no_listen,
+	.shutdown =	sock_no_shutdown,
+	.setsockopt =	sock_no_setsockopt,
+	.getsockopt =	sock_no_getsockopt,
+	.sendmsg =	sock_no_sendmsg,
+	.recvmsg =	sock_no_recvmsg,
+	.mmap =		sock_no_mmap,
+	.sendpage =	sock_no_sendpage,
+	.owner		= THIS_MODULE,
+};
+
+static struct proto fbxatm_proto = {
+        .name           = "fbxatm",
+        .owner          =  THIS_MODULE,
+        .obj_size       = sizeof (struct sock),
+};
+
+static int fbxatm_sock_create(struct net *net, struct socket *sock,
+			      int protocol, int kern)
+{
+	struct sock *sk;
+
+        sk = sk_alloc(net, PF_FBXATM, GFP_KERNEL, &fbxatm_proto, kern);
+	if (!sk)
+		return -ENOMEM;
+
+        sock_init_data(sock, sk);
+        sock->state = SS_UNCONNECTED;
+        sock->ops = &fbxatm_proto_ops;
+	return 0;
+}
+
+static struct net_proto_family fbxatm_family_ops = {
+	.family = PF_FBXATM,
+	.create = fbxatm_sock_create,
+	.owner = THIS_MODULE,
+};
+
+
+static int __init fbxatm_init(void)
+{
+	int ret;
+
+	printk(KERN_INFO "Freebox ATM stack\n");
+	ret = fbxatm_sysfs_init();
+	if (ret)
+		return ret;
+
+	ret = fbxatm_procfs_init();
+	if (ret)
+		goto fail_sysfs;
+
+	ret = fbxatm_vcc_init();
+	if (ret)
+		goto fail_procfs;
+
+	ret = fbxatm_2684_init();
+	if (ret)
+		goto fail_vcc;
+
+	ret = fbxatm_pppoa_init();
+	if (ret)
+		goto fail_2684;
+
+	ret = proto_register(&fbxatm_proto, 0);
+	if (ret)
+		goto fail_pppoa;
+
+	ret = sock_register(&fbxatm_family_ops);
+	if (ret)
+		goto fail_proto;
+
+	return 0;
+
+fail_proto:
+	proto_unregister(&fbxatm_proto);
+
+fail_pppoa:
+	fbxatm_pppoa_exit();
+
+fail_2684:
+	fbxatm_2684_exit();
+
+fail_vcc:
+	fbxatm_vcc_exit();
+
+fail_procfs:
+	fbxatm_procfs_exit();
+
+fail_sysfs:
+	fbxatm_sysfs_exit();
+	printk(KERN_ERR "failed to initialize Freebox ATM stack\n");
+	return ret;
+}
+
+static void __exit fbxatm_exit(void)
+{
+	sock_unregister(PF_FBXATM);
+	proto_unregister(&fbxatm_proto);
+	fbxatm_pppoa_exit();
+	fbxatm_2684_exit();
+	fbxatm_vcc_exit();
+	fbxatm_procfs_exit();
+	fbxatm_sysfs_exit();
+}
+
+subsys_initcall(fbxatm_init);
+module_exit(fbxatm_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_ALIAS_NETPROTO(PF_FBXATM);
diff -Nruw linux-4.2.6-fbx/net/fbxatm./fbxatm_dev.c linux-4.2.6-fbx/net/fbxatm/fbxatm_dev.c
--- linux-4.2.6-fbx/net/fbxatm./fbxatm_dev.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxatm/fbxatm_dev.c	2015-11-02 18:59:22.140552799 +0100
@@ -0,0 +1,957 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/sched.h>
+#include <linux/mutex.h>
+#include <linux/bitops.h>
+#include <linux/fbxatm_dev.h>
+#include "fbxatm_priv.h"
+
+/*
+ * list of registered device & lock
+ */
+LIST_HEAD(fbxatm_dev_list);
+
+/*
+ * big "rtnl" lock
+ */
+DEFINE_MUTEX(fbxatm_mutex);
+static int fbxatm_ifindex = -1;
+
+/*
+ * find device by index
+ */
+static struct fbxatm_dev *__fbxatm_dev_get_by_index(int ifindex)
+{
+	struct fbxatm_dev *pdev;
+
+	list_for_each_entry(pdev, &fbxatm_dev_list, next) {
+		if (pdev->ifindex == ifindex)
+			return pdev;
+	}
+	return NULL;
+}
+
+/*
+ * find vcc by id
+ */
+static struct fbxatm_vcc *
+__fbxatm_vcc_get_by_id(const struct fbxatm_vcc_id *id)
+{
+	struct fbxatm_dev *adev;
+	struct fbxatm_vcc *vcc;
+	int found;
+
+	adev = __fbxatm_dev_get_by_index(id->dev_idx);
+	if (!adev)
+		return ERR_PTR(-ENODEV);
+
+	found = 0;
+	list_for_each_entry(vcc, &adev->vcc_list, next) {
+		if (vcc->vpi != id->vpi || vcc->vci != id->vci)
+			continue;
+		found = 1;
+		break;
+	}
+
+	if (found)
+		return vcc;
+	return ERR_PTR(-ENOENT);
+}
+
+/*
+ * allocate device
+ */
+struct fbxatm_dev *fbxatm_alloc_device(int sizeof_priv)
+{
+	unsigned int size;
+
+	size = sizeof(struct fbxatm_dev) + sizeof_priv + FBXATMDEV_ALIGN;
+	return kzalloc(size, GFP_KERNEL);
+}
+
+EXPORT_SYMBOL(fbxatm_alloc_device);
+
+/*
+ * calculate crc10 of oam cell
+ */
+static void compute_oam_crc10(struct fbxatm_oam_cell_payload *cell)
+{
+	u8 *pdu;
+	u16 crc;
+
+	/* crc10 does not cover header */
+	pdu = (u8 *)&cell->cell_type;
+	memset(cell->crc10, 0, 2);
+
+	crc = crc10(0, pdu, sizeof (*cell) - sizeof (cell->cell_hdr));
+	cell->crc10[0] = crc >> 8;
+	cell->crc10[1] = crc & 0xff;
+}
+
+/*
+ * check crc10 of oam cell
+ */
+static int check_oam_crc10(struct fbxatm_oam_cell_payload *cell)
+{
+	u8 *pdu;
+	u16 crc;
+
+	pdu = (u8 *)&cell->cell_type;
+
+	crc = (cell->crc10[0] << 8) | cell->crc10[1];
+	memset(cell->crc10, 0, 2);
+
+	if (crc != crc10(0, pdu, sizeof (*cell) - sizeof (cell->cell_hdr)))
+		return 1;
+
+	return 0;
+}
+
+/*
+ * send an oam ping and wait for answer
+ */
+static int do_oam_ping(struct fbxatm_oam_ping *ping)
+{
+	struct fbxatm_dev *adev;
+	struct fbxatm_oam_cell *oam_cell;
+	struct fbxatm_oam_cell_payload *cell;
+	u8 *hdr;
+	int ret;
+
+	switch (ping->req.type) {
+	case FBXATM_OAM_PING_SEG_F4:
+	case FBXATM_OAM_PING_E2E_F4:
+		return -ENOTSUPP;
+	case FBXATM_OAM_PING_SEG_F5:
+	case FBXATM_OAM_PING_E2E_F5:
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	/* find device */
+	mutex_lock(&fbxatm_mutex);
+	adev = __fbxatm_dev_get_by_index(ping->req.id.dev_idx);
+	if (!adev) {
+		ret = -ENODEV;
+		goto out_unlock;
+	}
+
+	if (!test_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags)) {
+		ret = -ENETDOWN;
+		goto out_unlock;
+	}
+
+	/* if f5, vcc need to be opened */
+	switch (ping->req.type) {
+	case FBXATM_OAM_PING_SEG_F5:
+	case FBXATM_OAM_PING_E2E_F5:
+	{
+		struct fbxatm_vcc *vcc;
+
+		vcc = __fbxatm_vcc_get_by_id(&ping->req.id);
+		if (IS_ERR(vcc)) {
+			ret = -ENETDOWN;
+			goto out_unlock;
+		}
+		break;
+	}
+
+	default:
+		break;
+	}
+
+	ping->correlation_id = ++adev->oam_correlation_id;
+
+	/* prepare atm oam cell and send it */
+	oam_cell = kmalloc(sizeof (*oam_cell), GFP_KERNEL);
+	if (!oam_cell) {
+		ret = -ENOMEM;
+		goto out_unlock;
+	}
+	cell = &oam_cell->payload;
+
+	hdr = cell->cell_hdr;
+	ATM_SET_GFC(hdr, 0);
+
+	ATM_SET_VPI(hdr, ping->req.id.vpi);
+	ATM_SET_VCI(hdr, ping->req.id.vci);
+	if (ping->req.type == FBXATM_OAM_PING_E2E_F5)
+		ATM_SET_PT(hdr, OAM_PTI_END2END_F5);
+	else
+		ATM_SET_PT(hdr, OAM_PTI_SEG_F5);
+	ATM_SET_CLP(hdr, 0);
+	ATM_SET_HEC(hdr, 0);
+
+	cell->cell_type = (OAM_TYPE_FAULT_MANAGEMENT << OAM_TYPE_SHIFT) |
+		(FUNC_TYPE_OAM_LOOPBACK << FUNC_TYPE_SHIFT);
+	cell->loopback_indication = 1;
+
+	memcpy(cell->correlation_tag, &ping->correlation_id,
+	       sizeof (cell->correlation_tag));
+	memcpy(cell->loopback_id, ping->req.llid, sizeof (ping->req.llid));
+	memset(cell->source_id, 0x6a, sizeof (cell->source_id));
+	memset(cell->reserved, 0x6a, sizeof (cell->reserved));
+
+	compute_oam_crc10(cell);
+
+	ret = adev->ops->send_oam(adev, oam_cell);
+	if (ret)
+		goto out_unlock;
+
+	/* wait for an answer */
+	list_add(&ping->next, &adev->oam_pending_ping);
+	ping->replied = 0;
+	init_waitqueue_head(&ping->wq);
+	mutex_unlock(&fbxatm_mutex);
+
+	ret = wait_event_interruptible_timeout(ping->wq, ping->replied,
+					       HZ * 5);
+	list_del(&ping->next);
+
+	if (ret == -ERESTARTSYS)
+		return ret;
+
+	if (ping->replied < 0) {
+		/* ping failed */
+		return ping->replied;
+	}
+
+	if (!ping->replied) {
+		/* timeout */
+		return -ETIME;
+	}
+
+	return 0;
+
+
+out_unlock:
+	mutex_unlock(&fbxatm_mutex);
+	return ret;
+}
+
+/*
+ * special llid values
+ */
+static const u8 llid_all1[16] = { 0xff, 0xff, 0xff, 0xff,
+				  0xff, 0xff, 0xff, 0xff,
+				  0xff, 0xff, 0xff, 0xff,
+				  0xff, 0xff, 0xff, 0xff };
+
+static const u8 llid_all0[16] = { 0 };
+
+/*
+ * handle incoming oam cell
+ */
+static void handle_oam_cell(struct fbxatm_dev *adev,
+			    struct fbxatm_oam_cell *oam_cell)
+{
+	struct fbxatm_oam_cell_payload *cell;
+	u16 vci;
+	u8 *hdr, pt, oam, func;
+
+	/* check CRC10 */
+	cell = &oam_cell->payload;
+	if (check_oam_crc10(cell)) {
+		adev->stats.rx_bad_oam++;
+		goto out;
+	}
+
+	/* drop f4 cells */
+	hdr = cell->cell_hdr;
+	vci = ATM_GET_VCI(hdr);
+
+	if (vci == OAM_VCI_SEG_F4 || vci == OAM_VCI_END2END_F4) {
+		adev->stats.rx_f4_oam++;
+		goto out;
+	}
+
+	/* keep f5 cells only */
+	pt = ATM_GET_PT(hdr);
+	if (pt != OAM_PTI_SEG_F5 && pt != OAM_PTI_END2END_F5) {
+		adev->stats.rx_other_oam++;
+		goto out;
+	}
+
+	adev->stats.rx_f5_oam++;
+
+	/* keep oam loopback type only */
+	oam = (cell->cell_type & OAM_TYPE_MASK) >> OAM_TYPE_SHIFT;
+	func = (cell->cell_type & FUNC_TYPE_MASK) >> FUNC_TYPE_SHIFT;
+
+	if (oam != OAM_TYPE_FAULT_MANAGEMENT ||
+	    func != FUNC_TYPE_OAM_LOOPBACK) {
+		adev->stats.rx_other_oam++;
+		goto out;
+	}
+
+	if (cell->loopback_indication & 1) {
+		int match, ret;
+
+		/* request, check for llid match */
+		match = 0;
+		switch (pt) {
+		case OAM_PTI_SEG_F5:
+			/* 0x0 or 0xffffffff */
+			if (!memcmp(cell->loopback_id, llid_all0,
+				    sizeof (llid_all0)))
+				match = 1;
+			/* fallthrough */
+
+		case OAM_PTI_END2END_F5:
+			/* 0xffffffff only */
+			if (!memcmp(cell->loopback_id, llid_all1,
+				    sizeof (llid_all1)))
+				match = 1;
+			break;
+		}
+
+		if (!match) {
+			adev->stats.rx_bad_llid_oam++;
+			goto out;
+		}
+
+		/* ok, update llid and answer */
+		cell->loopback_indication = 0;
+		memcpy(cell->loopback_id, llid_all1, sizeof (llid_all1));
+		compute_oam_crc10(cell);
+
+		mutex_lock(&fbxatm_mutex);
+		ret = adev->ops->send_oam(adev, oam_cell);
+		mutex_unlock(&fbxatm_mutex);
+
+		if (!ret) {
+			/* send successful, don't free cell */
+			return;
+		}
+
+	} else {
+		struct fbxatm_oam_ping *ping;
+
+		/* reply, find a matching sender */
+		mutex_lock(&fbxatm_mutex);
+		list_for_each_entry(ping, &adev->oam_pending_ping, next) {
+
+			/* compare correlation id */
+			if (memcmp(&ping->correlation_id,
+				   cell->correlation_tag,
+				   sizeof (cell->correlation_tag)))
+				continue;
+
+			/* compare ping type */
+			switch (ping->req.type) {
+			case FBXATM_OAM_PING_SEG_F5:
+				if (pt != OAM_PTI_SEG_F5)
+					continue;
+				break;
+			case FBXATM_OAM_PING_E2E_F5:
+				if (pt != OAM_PTI_END2END_F5)
+					continue;
+				break;
+			default:
+				break;
+			}
+
+			/* seems we have a match */
+			ping->replied = 1;
+			wake_up(&ping->wq);
+		}
+		mutex_unlock(&fbxatm_mutex);
+	}
+
+out:
+	kfree(oam_cell);
+}
+
+/*
+ * oam rx processing workqueue
+ */
+static void fbxatm_oam_work(struct work_struct *work)
+{
+	struct fbxatm_dev *adev;
+	struct fbxatm_oam_cell *cell;
+
+	adev = container_of(work, struct fbxatm_dev, oam_work);
+
+	do {
+		cell = NULL;
+		spin_lock_bh(&adev->oam_lock);
+		if (!list_empty(&adev->rx_oam_cells)) {
+			cell = list_first_entry(&adev->rx_oam_cells,
+						struct fbxatm_oam_cell, next);
+			list_del(&cell->next);
+			adev->rx_oam_cells_count--;
+		}
+		spin_unlock_bh(&adev->oam_lock);
+
+		if (cell)
+			handle_oam_cell(adev, cell);
+
+	} while (cell);
+}
+
+/*
+ * register given device
+ */
+static int __fbxatm_register_device(struct fbxatm_dev *adev,
+				    const char *base_name,
+				    const struct fbxatm_dev_ops *ops)
+{
+	struct fbxatm_dev *pdev;
+	int name_len, count, ret;
+	long *inuse;
+
+	adev->ops = ops;
+	INIT_LIST_HEAD(&adev->vcc_list);
+	INIT_LIST_HEAD(&adev->next);
+	spin_lock_init(&adev->stats_lock);
+	spin_lock_init(&adev->oam_lock);
+	INIT_LIST_HEAD(&adev->rx_oam_cells);
+	INIT_WORK(&adev->oam_work, fbxatm_oam_work);
+	INIT_LIST_HEAD(&adev->oam_pending_ping);
+	get_random_bytes(&adev->oam_correlation_id, 4);
+
+	name_len = strlen(base_name);
+	adev->name = kmalloc(name_len + 10, GFP_KERNEL);
+	if (!adev->name) {
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	/* allocate ifindex */
+	while (1) {
+		if (++fbxatm_ifindex < 0)
+			fbxatm_ifindex = 0;
+		if (__fbxatm_dev_get_by_index(fbxatm_ifindex))
+			continue;
+		adev->ifindex = fbxatm_ifindex;
+		break;
+	}
+
+	/* allocate device name */
+	inuse = (long *)get_zeroed_page(GFP_ATOMIC);
+	if (!inuse) {
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	list_for_each_entry(pdev, &fbxatm_dev_list, next) {
+		unsigned long val;
+		char *end;
+
+		/* look for common prefix */
+		if (strncmp(base_name, pdev->name, name_len))
+			continue;
+
+		/* make sure name is the same, not just a prefix */
+		val = simple_strtoul(pdev->name + name_len, &end, 10);
+		if (!*end)
+			continue;
+
+		set_bit(val, inuse);
+	}
+
+	count = find_first_zero_bit(inuse, PAGE_SIZE * 8);
+	free_page((unsigned long)inuse);
+
+	snprintf(adev->name, name_len + 10, "%s%d", base_name, count);
+	list_add_tail(&adev->next, &fbxatm_dev_list);
+
+	/* create procfs entries */
+	ret = fbxatm_proc_dev_register(adev);
+	if (ret)
+		goto fail;
+
+	/* call device procfs init if any */
+	if (adev->ops->init_procfs) {
+		ret = adev->ops->init_procfs(adev);
+		if (ret)
+			goto fail_procfs;
+	}
+
+	/* create sysfs entries */
+	ret = fbxatm_register_dev_sysfs(adev);
+	if (ret)
+		goto fail_procfs;
+
+	return 0;
+
+fail_procfs:
+	fbxatm_proc_dev_deregister(adev);
+
+fail:
+	list_del(&adev->next);
+	kfree(adev->name);
+	return ret;
+}
+
+/*
+ * take lock and register device
+ */
+int fbxatm_register_device(struct fbxatm_dev *adev,
+			   const char *base_name,
+			   const struct fbxatm_dev_ops *ops)
+{
+	int ret;
+
+	mutex_lock(&fbxatm_mutex);
+	ret = __fbxatm_register_device(adev, base_name, ops);
+	mutex_unlock(&fbxatm_mutex);
+	return ret;
+}
+
+EXPORT_SYMBOL(fbxatm_register_device);
+
+/*
+ * change device "link" state
+ */
+static void fbxatm_dev_set_link(struct fbxatm_dev *adev, int link)
+{
+	struct fbxatm_vcc *vcc;
+
+	/* prevent new vcc creation and oam ping */
+	mutex_lock(&fbxatm_mutex);
+
+	if (link) {
+		memset(&adev->stats, 0, sizeof (adev->stats));
+		list_for_each_entry(vcc, &adev->vcc_list, next)
+			memset(&vcc->stats, 0, sizeof (vcc->stats));
+		wmb();
+		set_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags);
+		list_for_each_entry(vcc, &adev->vcc_list, next) {
+			set_bit(FBXATM_VCC_F_LINK_UP, &vcc->vcc_flags);
+			if (!vcc->user_ops || !vcc->user_ops->link_change)
+				continue;
+			vcc->user_ops->link_change(vcc->user_cb_data, 1,
+						   adev->link_cell_rate_ds,
+						   adev->link_cell_rate_us);
+		}
+	} else {
+		/* prevent further oam cells input */
+		spin_lock_bh(&adev->oam_lock);
+		clear_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags);
+		spin_unlock_bh(&adev->oam_lock);
+
+		/* flush rx oam work */
+		cancel_work_sync(&adev->oam_work);
+
+		/* now disable tx on all vcc */
+		list_for_each_entry(vcc, &adev->vcc_list, next) {
+			spin_lock_bh(&vcc->tx_lock);
+			clear_bit(FBXATM_VCC_F_LINK_UP, &vcc->vcc_flags);
+			spin_unlock_bh(&vcc->tx_lock);
+			if (!vcc->user_ops || !vcc->user_ops->link_change)
+				continue;
+			vcc->user_ops->link_change(vcc->user_cb_data, 0, 0, 0);
+		}
+	}
+
+	fbxatm_dev_change_sysfs(adev);
+	mutex_unlock(&fbxatm_mutex);
+}
+
+/*
+ * set device "link" to up, allowing vcc/device send ops to be called,
+ * this function sleeps
+ */
+void fbxatm_dev_set_link_up(struct fbxatm_dev *adev)
+{
+	if (!test_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags))
+		printk(KERN_INFO "%s: link UP - "
+		       "down: %u kbit/s - up: %u kbit/s\n", adev->name,
+		       adev->link_rate_ds / 1000, adev->link_rate_us / 1000);
+	return fbxatm_dev_set_link(adev, 1);
+}
+
+EXPORT_SYMBOL(fbxatm_dev_set_link_up);
+
+/*
+ * set device link to down, disallowing any vcc/device send ops to be
+ * called, this function sleeps
+ */
+void fbxatm_dev_set_link_down(struct fbxatm_dev *adev)
+{
+	if (test_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags))
+		printk(KERN_INFO "%s: link DOWN\n", adev->name);
+	return fbxatm_dev_set_link(adev, 0);
+}
+
+EXPORT_SYMBOL(fbxatm_dev_set_link_down);
+
+/*
+ * take lock and unregister device
+ */
+int fbxatm_unregister_device(struct fbxatm_dev *adev)
+{
+	int ret;
+
+	ret = 0;
+	mutex_lock(&fbxatm_mutex);
+
+	if (!list_empty(&adev->vcc_list)) {
+		ret = -EBUSY;
+		goto out;
+	}
+
+	list_del(&adev->next);
+
+	if (adev->ops->release_procfs)
+		adev->ops->release_procfs(adev);
+	fbxatm_proc_dev_deregister(adev);
+
+	fbxatm_unregister_dev_sysfs(adev);
+out:
+	mutex_unlock(&fbxatm_mutex);
+	return ret;
+}
+
+EXPORT_SYMBOL(fbxatm_unregister_device);
+
+/*
+ * actually free device memory
+ */
+void __fbxatm_free_device(struct fbxatm_dev *adev)
+{
+	kfree(adev->name);
+	kfree(adev);
+}
+
+/*
+ * free device memory
+ */
+void fbxatm_free_device(struct fbxatm_dev *adev)
+{
+	/* actual free is done in sysfs release */
+//	class_device_put(&adev->class_dev);
+}
+
+EXPORT_SYMBOL(fbxatm_free_device);
+
+/*
+ * device callback when oam cell comes in
+ */
+void fbxatm_netifrx_oam(struct fbxatm_dev *adev, struct fbxatm_oam_cell *cell)
+{
+	spin_lock_bh(&adev->oam_lock);
+	if (!test_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags) ||
+	    adev->rx_oam_cells_count > 8) {
+		kfree(cell);
+		spin_unlock_bh(&adev->oam_lock);
+		return;
+	}
+	adev->rx_oam_cells_count++;
+	list_add_tail(&cell->next, &adev->rx_oam_cells);
+	spin_unlock_bh(&adev->oam_lock);
+	schedule_work(&adev->oam_work);
+}
+
+EXPORT_SYMBOL(fbxatm_netifrx_oam);
+
+/*
+ * set user ops on vcc
+ */
+void fbxatm_set_uops(struct fbxatm_vcc *vcc,
+		     const struct fbxatm_vcc_uops *user_ops,
+		     void *user_cb_data)
+{
+	spin_lock_bh(&vcc->user_ops_lock);
+	vcc->user_ops = user_ops;
+	vcc->user_cb_data = user_cb_data;
+	spin_unlock_bh(&vcc->user_ops_lock);
+}
+
+/*
+ * bind to given vcc
+ */
+static struct fbxatm_vcc *
+__fbxatm_bind_to_vcc(const struct fbxatm_vcc_id *id,
+		     enum fbxatm_vcc_user user)
+{
+	struct fbxatm_vcc *vcc;
+
+	vcc = __fbxatm_vcc_get_by_id(id);
+	if (IS_ERR(vcc))
+		return vcc;
+
+	if (vcc->user != FBXATM_VCC_USER_NONE)
+		return ERR_PTR(-EBUSY);
+
+	vcc->user = user;
+	return vcc;
+}
+
+/*
+ * bind to given vcc
+ */
+struct fbxatm_vcc *
+fbxatm_bind_to_vcc(const struct fbxatm_vcc_id *id,
+		   enum fbxatm_vcc_user user)
+{
+	struct fbxatm_vcc *vcc;
+
+	mutex_lock(&fbxatm_mutex);
+	vcc = __fbxatm_bind_to_vcc(id, user);
+	mutex_unlock(&fbxatm_mutex);
+	return vcc;
+}
+
+/*
+ * unbind from given vcc
+ */
+void fbxatm_unbind_vcc(struct fbxatm_vcc *vcc)
+{
+	spin_lock_bh(&vcc->user_ops_lock);
+	vcc->user_ops = NULL;
+	vcc->user_cb_data = NULL;
+	vcc->user = FBXATM_VCC_USER_NONE;
+	spin_unlock_bh(&vcc->user_ops_lock);
+}
+
+/*
+ * open vcc on given device
+ */
+static int __fbxatm_dev_open_vcc(const struct fbxatm_vcc_id *id,
+				 const struct fbxatm_vcc_qos *qos)
+{
+	struct fbxatm_vcc *vcc;
+	struct fbxatm_dev *adev;
+	int ret, count;
+
+	/* check vpi/vci unicity  */
+	vcc = __fbxatm_vcc_get_by_id(id);
+	if (!IS_ERR(vcc))
+		return -EBUSY;
+
+	/* sanity check */
+	switch (qos->traffic_class) {
+	case FBXATM_VCC_TC_UBR_NO_PCR:
+	case FBXATM_VCC_TC_UBR:
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (qos->max_sdu > 4096)
+		return -EINVAL;
+
+	if (!qos->max_buffered_pkt || qos->max_buffered_pkt > 128)
+		return -EINVAL;
+
+	adev = __fbxatm_dev_get_by_index(id->dev_idx);
+	if (!adev)
+		return -ENODEV;
+
+	/* make sure device accept requested priorities */
+	if (qos->priority > adev->max_priority)
+		return -EINVAL;
+
+	if (qos->rx_priority > adev->max_rx_priority)
+		return -EINVAL;
+
+	/* don't open more vcc than device can handle */
+	count = 0;
+	list_for_each_entry(vcc, &adev->vcc_list, next)
+		count++;
+	if (count + 1 > adev->max_vcc)
+		return -ENOSPC;
+
+	/* make sure vpi/vci is valid for this device */
+	if ((~adev->vpi_mask & id->vpi) || (~adev->vci_mask & id->vci))
+		return -EINVAL;
+
+	if (!try_module_get(adev->ops->owner))
+		return -ENODEV;
+
+	/* ok, create vcc */
+	vcc = kzalloc(sizeof (*vcc), GFP_KERNEL);
+	if (!vcc)
+		return -ENOMEM;
+
+	spin_lock_init(&vcc->user_ops_lock);
+	spin_lock_init(&vcc->tx_lock);
+	vcc->vpi = id->vpi;
+	vcc->vci = id->vci;
+	vcc->adev = adev;
+	vcc->to_drop_pkt = 0;
+	memcpy(&vcc->qos, qos, sizeof (*qos));
+
+	ret = adev->ops->open(vcc);
+	if (ret) {
+		kfree(vcc);
+		return ret;
+	}
+
+	/* inherit vcc link state from device */
+	if (test_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags))
+		set_bit(FBXATM_VCC_F_LINK_UP, &vcc->vcc_flags);
+
+	list_add_tail(&vcc->next, &adev->vcc_list);
+	return ret;
+}
+
+/*
+ * find device & open vcc on it
+ */
+static int fbxatm_dev_open_vcc(const struct fbxatm_vcc_id *id,
+			       const struct fbxatm_vcc_qos *qos)
+{
+	int ret;
+
+	mutex_lock(&fbxatm_mutex);
+	ret = __fbxatm_dev_open_vcc(id, qos);
+	mutex_unlock(&fbxatm_mutex);
+	return ret;
+}
+
+/*
+ * close vcc on device
+ */
+static int __fbxatm_dev_close_vcc(struct fbxatm_vcc *vcc)
+{
+	struct fbxatm_dev *adev;
+
+	if (vcc->user != FBXATM_VCC_USER_NONE)
+		return -EBUSY;
+	adev = vcc->adev;
+	module_put(adev->ops->owner);
+	adev->ops->close(vcc);
+	list_del(&vcc->next);
+	kfree(vcc);
+	return 0;
+}
+
+/*
+ * find device & vcc and close it
+ */
+static int fbxatm_dev_close_vcc(const struct fbxatm_vcc_id *id)
+{
+	struct fbxatm_vcc *vcc;
+	int ret;
+
+	mutex_lock(&fbxatm_mutex);
+	vcc = __fbxatm_vcc_get_by_id(id);
+	if (IS_ERR(vcc))
+		ret = PTR_ERR(vcc);
+	else
+		ret = __fbxatm_dev_close_vcc(vcc);
+	mutex_unlock(&fbxatm_mutex);
+	return ret;
+}
+
+/*
+ * ioctl handler
+ */
+static int fbxatm_vcc_ioctl(struct socket *sock,
+			    unsigned int cmd, void __user *useraddr)
+{
+	int ret;
+
+	ret = 0;
+
+	switch (cmd) {
+	case FBXATM_IOCADD:
+	case FBXATM_IOCDEL:
+	{
+		struct fbxatm_vcc_params params;
+
+		if (copy_from_user(&params, useraddr, sizeof(params)))
+			return -EFAULT;
+
+		if (cmd == FBXATM_IOCADD)
+			ret = fbxatm_dev_open_vcc(&params.id, &params.qos);
+		else
+			ret = fbxatm_dev_close_vcc(&params.id);
+		break;
+	}
+
+	case FBXATM_IOCGET:
+	{
+		struct fbxatm_vcc_params params;
+		struct fbxatm_vcc *vcc;
+
+		if (copy_from_user(&params, useraddr, sizeof(params)))
+			return -EFAULT;
+
+		mutex_lock(&fbxatm_mutex);
+		vcc = __fbxatm_vcc_get_by_id(&params.id);
+		if (IS_ERR(vcc))
+			ret = PTR_ERR(vcc);
+		else {
+			memcpy(&params.qos, &vcc->qos, sizeof (vcc->qos));
+			params.user = vcc->user;
+		}
+		mutex_unlock(&fbxatm_mutex);
+
+		if (ret)
+			return ret;
+
+		if (copy_to_user(useraddr, &params, sizeof(params)))
+			return -EFAULT;
+		break;
+	}
+
+	case FBXATM_IOCOAMPING:
+	{
+		struct fbxatm_oam_ping ping;
+
+		if (copy_from_user(&ping.req, useraddr, sizeof(ping.req)))
+			return -EFAULT;
+
+		ret = do_oam_ping(&ping);
+		if (ret)
+			return ret;
+
+		if (copy_to_user(useraddr, &ping.req, sizeof(ping.req)))
+			return -EFAULT;
+		break;
+	}
+
+	case FBXATM_IOCDROP:
+	{
+		struct fbxatm_vcc_drop_params params;
+		struct fbxatm_vcc *vcc;
+
+		if (copy_from_user(&params, useraddr, sizeof(params)))
+			return -EFAULT;
+
+		mutex_lock(&fbxatm_mutex);
+		vcc = __fbxatm_vcc_get_by_id(&params.id);
+		if (IS_ERR(vcc))
+			ret = PTR_ERR(vcc);
+		else {
+			spin_lock_bh(&vcc->user_ops_lock);
+			vcc->to_drop_pkt += params.drop_count;
+			spin_unlock_bh(&vcc->user_ops_lock);
+			ret = 0;
+		}
+		mutex_unlock(&fbxatm_mutex);
+
+		if (ret)
+			return ret;
+		break;
+	}
+
+	default:
+		return -ENOIOCTLCMD;
+	}
+
+	return ret;
+}
+
+static struct fbxatm_ioctl fbxatm_vcc_ioctl_ops = {
+	.handler	= fbxatm_vcc_ioctl,
+	.owner		= THIS_MODULE,
+};
+
+int __init fbxatm_vcc_init(void)
+{
+	fbxatm_register_ioctl(&fbxatm_vcc_ioctl_ops);
+	return 0;
+}
+
+void fbxatm_vcc_exit(void)
+{
+	fbxatm_unregister_ioctl(&fbxatm_vcc_ioctl_ops);
+}
diff -Nruw linux-4.2.6-fbx/net/fbxatm./fbxatm_pppoa.c linux-4.2.6-fbx/net/fbxatm/fbxatm_pppoa.c
--- linux-4.2.6-fbx/net/fbxatm./fbxatm_pppoa.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxatm/fbxatm_pppoa.c	2015-11-02 18:59:21.464547475 +0100
@@ -0,0 +1,485 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/netdevice.h>
+#include <linux/if_pppox.h>
+#include <linux/ppp_channel.h>
+#include <linux/ppp_defs.h>
+#include <linux/if_ppp.h>
+#include <linux/fbxatm.h>
+#include <linux/fbxatm_dev.h>
+#include "fbxatm_priv.h"
+
+#define PFX	"fbxatm_pppoa: "
+
+static LIST_HEAD(fbxatm_pppoa_vcc_list);
+static DEFINE_MUTEX(fbxatm_pppoa_mutex);
+
+/*
+ * private data for pppoa vcc
+ */
+struct fbxatm_pppoa_vcc {
+	struct fbxatm_vcc		*vcc;
+	struct fbxatm_pppoa_vcc_params	params;
+	enum fbxatm_pppoa_encap		cur_encap;
+
+	/* used by ppp */
+	int				flags;
+	struct ppp_channel		chan;
+
+	struct socket			*sock;
+	struct list_head		next;
+};
+
+
+#define __LLC_HDR		0xfe, 0xfe, 0x03
+#define __NLPID_PPP		0xcf
+#define __PPP_LCP		0xc0, 0x21
+
+static const u8 llc_ppp[]	= { __LLC_HDR, __NLPID_PPP };
+static const u8 llc_ppp_lcp[]	= { __LLC_HDR, __NLPID_PPP, __PPP_LCP };
+static const u8 lcp[]		= { __PPP_LCP };
+
+
+/*
+ * fbxatm stack receive callback, called from softirq
+ */
+static void vcc_rx_callback(struct sk_buff *skb, void *data)
+{
+	struct fbxatm_pppoa_vcc *priv;
+
+	priv = (struct fbxatm_pppoa_vcc *)data;
+
+	if (priv->chan.ppp == NULL) {
+		dev_kfree_skb(skb);
+		return;
+	}
+
+	switch (priv->cur_encap) {
+	case FBXATM_EPPPOA_VCMUX:
+		/* nothing to do */
+		break;
+
+	case FBXATM_EPPPOA_LLC:
+		/* make sure llc header is present and remove */
+		if (skb->len < sizeof(llc_ppp) ||
+		    memcmp(skb->data, llc_ppp, sizeof(llc_ppp)))
+			goto error;
+		skb_pull(skb, sizeof(llc_ppp));
+		break;
+
+	case FBXATM_EPPPOA_AUTODETECT:
+		/* look for lcp, with an llc header or not */
+		if (skb->len >= sizeof(llc_ppp_lcp) &&
+		    !memcmp(skb->data, llc_ppp_lcp, sizeof(llc_ppp_lcp))) {
+			priv->cur_encap = FBXATM_EPPPOA_LLC;
+			skb_pull(skb, sizeof(llc_ppp));
+			break;
+		}
+
+		if (skb->len >= sizeof(lcp) &&
+		    !memcmp(skb->data, lcp, sizeof (lcp))) {
+			priv->cur_encap = FBXATM_EPPPOA_VCMUX;
+			break;
+		}
+
+		/* no match */
+		goto error;
+	}
+
+	ppp_input(&priv->chan, skb);
+	return;
+
+error:
+	dev_kfree_skb(skb);
+	ppp_input_error(&priv->chan, 0);
+}
+
+/*
+ * fbxatm stack tx done callback, called from softirq
+ */
+static void vcc_tx_done_callback(void *data)
+{
+	struct fbxatm_pppoa_vcc *priv;
+	priv = (struct fbxatm_pppoa_vcc *)data;
+	ppp_output_wakeup(&priv->chan);
+}
+
+/*
+ * vcc user ops, callback from fbxatm stack
+ */
+static const struct fbxatm_vcc_uops fbxatm_pppoa_vcc_uops = {
+	.rx_pkt		= vcc_rx_callback,
+	.tx_done	= vcc_tx_done_callback,
+};
+
+/*
+ * ppp xmit callback
+ */
+static int ppp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
+{
+	struct fbxatm_pppoa_vcc *priv;
+	struct sk_buff *to_send_skb, *nskb;
+	int ret;
+
+	priv = (struct fbxatm_pppoa_vcc *)chan->private;
+
+	/* MAYBE FIXME: handle protocol compression ? */
+
+	to_send_skb = skb;
+	nskb = NULL;
+
+	/* send using vcmux encap if not yet known */
+	switch (priv->cur_encap) {
+	case FBXATM_EPPPOA_AUTODETECT:
+	case FBXATM_EPPPOA_VCMUX:
+		break;
+
+	case FBXATM_EPPPOA_LLC:
+	{
+		unsigned int headroom;
+
+		headroom = skb_headroom(skb);
+
+		if (headroom < sizeof(llc_ppp)) {
+			headroom += sizeof(llc_ppp);
+			nskb = skb_realloc_headroom(skb, headroom);
+			if (!nskb) {
+				dev_kfree_skb(skb);
+				return 1;
+			}
+			to_send_skb = nskb;
+		}
+
+		skb_push(to_send_skb, sizeof(llc_ppp));
+		memcpy(to_send_skb->data, llc_ppp, sizeof(llc_ppp));
+		break;
+	}
+	}
+
+	ret = fbxatm_send(priv->vcc, to_send_skb);
+	if (ret) {
+		/* packet was not sent, queue is full, free any newly
+		 * created skb */
+		if (nskb)
+			dev_kfree_skb(nskb);
+		else {
+			/* restore original skb if we altered it */
+			if (priv->cur_encap == FBXATM_EPPPOA_LLC)
+				skb_pull(skb, sizeof(llc_ppp));
+		}
+
+		/* suspend ppp output, will be woken up by
+		 * ppp_output_wakeup, we're called under ppp lock so
+		 * we can't race with tx done */
+		return 0;
+	}
+
+	/* packet was sent, if we sent a copy free the original */
+	if (nskb)
+		dev_kfree_skb(skb);
+
+	if (fbxatm_vcc_queue_full(priv->vcc))
+		ppp_output_stop(chan);
+
+	return 1;
+}
+
+static int ppp_ioctl(struct ppp_channel *chan, unsigned int cmd,
+		     unsigned long arg)
+{
+	struct fbxatm_pppoa_vcc *priv;
+	int ret;
+
+	priv = (struct fbxatm_pppoa_vcc *)chan->private;
+
+	switch (cmd) {
+	case PPPIOCGFLAGS:
+		ret = put_user(priv->flags, (int __user *)arg) ? -EFAULT : 0;
+		break;
+	case PPPIOCSFLAGS:
+		ret = get_user(priv->flags, (int __user *) arg) ? -EFAULT : 0;
+		break;
+	default:
+		ret = -ENOTTY;
+		break;
+	}
+	return ret;
+}
+
+static struct ppp_channel_ops fbxatm_pppoa_ppp_ops = {
+	.start_xmit = ppp_xmit,
+	.ioctl = ppp_ioctl,
+};
+
+/*
+ * find pppoa vcc from id
+ */
+static struct fbxatm_pppoa_vcc *
+__find_pppoa_vcc(const struct fbxatm_vcc_id *id)
+{
+	struct fbxatm_pppoa_vcc *priv;
+	int found;
+
+	/* find it */
+	found = 0;
+	list_for_each_entry(priv, &fbxatm_pppoa_vcc_list, next) {
+		if (priv->vcc->adev->ifindex != id->dev_idx ||
+		    priv->vcc->vpi != id->vpi ||
+		    priv->vcc->vci != id->vci)
+			continue;
+
+		found = 1;
+		break;
+	}
+
+	if (found)
+		return priv;
+	return NULL;
+}
+
+/*
+ * find pppoa vcc from socket
+ */
+static struct fbxatm_pppoa_vcc *
+__find_pppoa_vcc_from_socket(const struct socket *sock)
+{
+	struct fbxatm_pppoa_vcc *priv;
+	int found;
+
+	/* find it */
+	found = 0;
+	list_for_each_entry(priv, &fbxatm_pppoa_vcc_list, next) {
+		if (priv->sock != sock)
+			continue;
+
+		found = 1;
+		break;
+	}
+
+	if (found)
+		return priv;
+	return NULL;
+}
+
+/*
+ * bind to given vcc
+ */
+static int __bind_pppoa_vcc(const struct fbxatm_pppoa_vcc_params *params,
+			    struct socket *sock)
+{
+	struct fbxatm_pppoa_vcc *priv;
+	int ret;
+
+	/* sanity check */
+	switch (params->encap) {
+	case FBXATM_EPPPOA_AUTODETECT:
+	case FBXATM_EPPPOA_VCMUX:
+	case FBXATM_EPPPOA_LLC:
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+	memcpy(&priv->params, params, sizeof (*params));
+	priv->cur_encap = params->encap;
+
+	/* bind to vcc */
+	priv->vcc = fbxatm_bind_to_vcc(&params->id, FBXATM_VCC_USER_PPPOA);
+	if (IS_ERR(priv->vcc)) {
+		ret = PTR_ERR(priv->vcc);
+		goto fail;
+	}
+
+	fbxatm_set_uops(priv->vcc, &fbxatm_pppoa_vcc_uops, priv);
+	priv->chan.private = priv;
+	priv->chan.ops = &fbxatm_pppoa_ppp_ops;
+	priv->chan.mtu = priv->vcc->qos.max_sdu - PPP_HDRLEN;
+	priv->chan.hdrlen = 0;
+	priv->sock = sock;
+
+	if (priv->cur_encap != FBXATM_EPPPOA_VCMUX) {
+		/* assume worst case if vcmux is not forced */
+		priv->chan.mtu -= sizeof(llc_ppp);
+		priv->chan.hdrlen += sizeof(llc_ppp);
+	}
+
+	priv->chan.mtu -= priv->vcc->adev->tx_headroom;
+	priv->chan.hdrlen += priv->vcc->adev->tx_headroom;
+
+	ret = ppp_register_channel(&priv->chan);
+	if (ret)
+		goto fail_unbind;
+	list_add_tail(&priv->next, &fbxatm_pppoa_vcc_list);
+	return 0;
+
+fail_unbind:
+	fbxatm_unbind_vcc(priv->vcc);
+
+fail:
+	kfree(priv);
+	return ret;
+}
+
+/*
+ * bind to given vcc
+ */
+static int bind_pppoa_vcc(const struct fbxatm_pppoa_vcc_params *params,
+			  struct socket *sock)
+{
+	int ret;
+
+	mutex_lock(&fbxatm_pppoa_mutex);
+	ret = __bind_pppoa_vcc(params, sock);
+	mutex_unlock(&fbxatm_pppoa_mutex);
+	return ret;
+}
+
+/*
+ * unbind from given vcc
+ */
+static void __unbind_pppoa_vcc(struct fbxatm_pppoa_vcc *priv)
+{
+	ppp_unregister_channel(&priv->chan);
+	fbxatm_unbind_vcc(priv->vcc);
+	list_del(&priv->next);
+	kfree(priv);
+}
+
+/*
+ * unbind from given vcc
+ */
+static int unbind_pppoa_vcc(const struct fbxatm_pppoa_vcc_params *params)
+{
+	struct fbxatm_pppoa_vcc *priv;
+	int ret;
+
+	ret = 0;
+	mutex_lock(&fbxatm_pppoa_mutex);
+	priv = __find_pppoa_vcc(&params->id);
+	if (!priv)
+		ret = -ENOENT;
+	else
+		__unbind_pppoa_vcc(priv);
+	mutex_unlock(&fbxatm_pppoa_mutex);
+	return ret;
+}
+
+/*
+ * pppoa related ioctl handler
+ */
+static int fbxatm_pppoa_ioctl(struct socket *sock,
+			      unsigned int cmd, void __user *useraddr)
+{
+	int ret;
+
+	ret = 0;
+
+	switch (cmd) {
+	case FBXATM_PPPOA_IOCADD:
+	case FBXATM_PPPOA_IOCDEL:
+	{
+		struct fbxatm_pppoa_vcc_params params;
+
+		if (copy_from_user(&params, useraddr, sizeof(params)))
+			return -EFAULT;
+
+		if (cmd == FBXATM_PPPOA_IOCADD)
+			ret = bind_pppoa_vcc(&params, sock);
+		else
+			ret = unbind_pppoa_vcc(&params);
+		break;
+	}
+
+	case FBXATM_PPPOA_IOCGET:
+	{
+		struct fbxatm_pppoa_vcc_params params;
+		struct fbxatm_pppoa_vcc *priv;
+
+		if (copy_from_user(&params, useraddr, sizeof(params)))
+			return -EFAULT;
+
+		mutex_lock(&fbxatm_pppoa_mutex);
+		priv = __find_pppoa_vcc(&params.id);
+		if (!priv)
+			ret = -ENOENT;
+		else
+			memcpy(&params, &priv->params, sizeof (params));
+		mutex_unlock(&fbxatm_pppoa_mutex);
+
+		if (ret)
+			return ret;
+
+		if (copy_to_user(useraddr, &params, sizeof(params)))
+			return -EFAULT;
+		break;
+	}
+
+	case PPPIOCGCHAN:
+	case PPPIOCGUNIT:
+	{
+		struct fbxatm_pppoa_vcc *priv;
+		int value;
+
+		value = 0;
+
+		mutex_lock(&fbxatm_pppoa_mutex);
+		priv = __find_pppoa_vcc_from_socket(sock);
+		if (!priv)
+			ret = -ENOENT;
+		else {
+			if (cmd == PPPIOCGCHAN)
+				value = ppp_channel_index(&priv->chan);
+			else
+				value = ppp_unit_number(&priv->chan);
+		}
+		mutex_unlock(&fbxatm_pppoa_mutex);
+
+		if (ret)
+			return ret;
+
+		if (copy_to_user(useraddr, &value, sizeof(value)))
+			ret = -EFAULT;
+		break;
+	}
+
+	default:
+		return -ENOIOCTLCMD;
+	}
+
+	return ret;
+}
+
+/*
+ * pppoa related release handler
+ */
+static void fbxatm_pppoa_release(struct socket *sock)
+{
+	struct fbxatm_pppoa_vcc *priv;
+
+	mutex_lock(&fbxatm_pppoa_mutex);
+	priv = __find_pppoa_vcc_from_socket(sock);
+	if (priv)
+		__unbind_pppoa_vcc(priv);
+	mutex_unlock(&fbxatm_pppoa_mutex);
+}
+
+static struct fbxatm_ioctl fbxatm_pppoa_ioctl_ops = {
+	.handler	= fbxatm_pppoa_ioctl,
+	.release	= fbxatm_pppoa_release,
+	.owner		= THIS_MODULE,
+};
+
+int __init fbxatm_pppoa_init(void)
+{
+	fbxatm_register_ioctl(&fbxatm_pppoa_ioctl_ops);
+	return 0;
+}
+
+void fbxatm_pppoa_exit(void)
+{
+	fbxatm_unregister_ioctl(&fbxatm_pppoa_ioctl_ops);
+}
diff -Nruw linux-4.2.6-fbx/net/fbxatm./fbxatm_priv.h linux-4.2.6-fbx/net/fbxatm/fbxatm_priv.h
--- linux-4.2.6-fbx/net/fbxatm./fbxatm_priv.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxatm/fbxatm_priv.h	2015-11-02 18:59:21.464547475 +0100
@@ -0,0 +1,67 @@
+#ifndef FBXATM_PRIV_H_
+#define FBXATM_PRIV_H_
+
+#include <linux/list.h>
+#include <linux/mutex.h>
+
+extern struct list_head fbxatm_dev_list;
+extern struct mutex fbxatm_mutex;
+
+int __init fbxatm_vcc_init(void);
+
+void fbxatm_vcc_exit(void);
+
+void __fbxatm_free_device(struct fbxatm_dev *adev);
+
+int __init fbxatm_2684_init(void);
+
+void fbxatm_2684_exit(void);
+
+/*
+ * pppoa
+ */
+#ifdef CONFIG_PPP
+int __init fbxatm_pppoa_init(void);
+
+void fbxatm_pppoa_exit(void);
+#else
+static inline int fbxatm_pppoa_init(void) { return 0; };
+static inline void fbxatm_pppoa_exit(void) { };
+#endif
+
+/*
+ * procfs stuff
+ */
+int fbxatm_proc_dev_register(struct fbxatm_dev *dev);
+
+void fbxatm_proc_dev_deregister(struct fbxatm_dev *dev);
+
+struct proc_dir_entry *fbxatm_proc_misc_register(const char *path);
+
+void fbxatm_proc_misc_deregister(const char *path);
+
+int __init fbxatm_procfs_init(void);
+
+void fbxatm_procfs_exit(void);
+
+
+/*
+ * sysfs stuff
+ */
+int __init fbxatm_sysfs_init(void);
+
+void fbxatm_sysfs_exit(void);
+
+void fbxatm_dev_change_sysfs(struct fbxatm_dev *adev);
+
+int fbxatm_register_dev_sysfs(struct fbxatm_dev *adev);
+
+void fbxatm_unregister_dev_sysfs(struct fbxatm_dev *adev);
+
+
+/*
+ * crc10
+ */
+u16 crc10(u16 crc, const u8 *buffer, size_t len);
+
+#endif /* !FBXATM_PRIV_H_ */
diff -Nruw linux-4.2.6-fbx/net/fbxatm./fbxatm_procfs.c linux-4.2.6-fbx/net/fbxatm/fbxatm_procfs.c
--- linux-4.2.6-fbx/net/fbxatm./fbxatm_procfs.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxatm/fbxatm_procfs.c	2015-11-02 18:59:22.996559548 +0100
@@ -0,0 +1,340 @@
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <linux/fbxatm_dev.h>
+#include <net/net_namespace.h>
+#include "fbxatm_priv.h"
+
+static struct proc_dir_entry *fbxatm_proc_root;
+
+/*
+ * /proc/net/atm/vcc
+ */
+static int vcc_seq_show(struct seq_file *seq, void *v)
+{
+	struct fbxatm_vcc *vcc;
+
+	if (v == (void *)SEQ_START_TOKEN) {
+		seq_printf(seq, "%s",
+			   "Itf.VPI.VCI USER TC MaxSDU  RX TX  RXAAL5 "
+			   "TXAAL5\n");
+		return 0;
+	}
+
+	vcc = (struct fbxatm_vcc *)v;
+	seq_printf(seq, "%d.%u.%u %d ", vcc->adev->ifindex,
+		   vcc->vpi, vcc->vci, vcc->user);
+	seq_printf(seq, "%u %u ", vcc->qos.traffic_class, vcc->qos.max_sdu);
+	seq_printf(seq, "%lu %lu  %lu %lu\n",
+		   vcc->stats.rx_bytes,
+		   vcc->stats.tx_bytes,
+		   vcc->stats.rx_aal5,
+		   vcc->stats.tx_aal5);
+	return 0;
+}
+
+static void *vcc_seq_start(struct seq_file *seq, loff_t *pos)
+{
+	struct fbxatm_dev *adev;
+	struct fbxatm_vcc *tvcc, *vcc;
+	int count;
+
+	mutex_lock(&fbxatm_mutex);
+
+	if (!*pos)
+		return SEQ_START_TOKEN;
+
+	count = 1;
+	tvcc = NULL;
+	list_for_each_entry(adev, &fbxatm_dev_list, next) {
+		list_for_each_entry(vcc, &adev->vcc_list, next) {
+			if (count == *pos) {
+				tvcc = vcc;
+				break;
+			}
+			count++;
+		}
+	}
+
+	return tvcc;
+}
+
+static void *vcc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+	struct fbxatm_dev *adev;
+	struct fbxatm_vcc *last_vcc, *vcc, *tvcc;
+
+	if (v == (void *)SEQ_START_TOKEN) {
+		if (list_empty(&fbxatm_dev_list))
+			return NULL;
+		adev = list_entry(fbxatm_dev_list.next, struct fbxatm_dev,
+				  next);
+		last_vcc = NULL;
+	} else {
+		last_vcc = (struct fbxatm_vcc *)v;
+		adev = last_vcc->adev;
+	}
+
+	tvcc = NULL;
+	list_for_each_entry_continue(adev, &fbxatm_dev_list, next) {
+
+		if (last_vcc && last_vcc->adev == adev) {
+			vcc = last_vcc;
+			list_for_each_entry_continue(vcc, &adev->vcc_list,
+						     next) {
+				tvcc = vcc;
+				break;
+			}
+		} else {
+			list_for_each_entry(vcc, &adev->vcc_list, next) {
+				tvcc = vcc;
+				break;
+			}
+		}
+	}
+
+	if (tvcc)
+		(*pos)++;
+	return tvcc;
+}
+
+static void vcc_seq_stop(struct seq_file *seq, void *v)
+{
+	mutex_unlock(&fbxatm_mutex);
+}
+
+static const struct seq_operations vcc_seq_ops = {
+	.start		= vcc_seq_start,
+	.next		= vcc_seq_next,
+	.stop		= vcc_seq_stop,
+	.show		= vcc_seq_show,
+};
+
+static int vcc_seq_open(struct inode *inode, struct file *file)
+{
+	return seq_open(file, &vcc_seq_ops);
+}
+
+static const struct file_operations vcc_seq_fops = {
+	.open		= vcc_seq_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= seq_release,
+};
+
+/*
+ * /proc/net/atm/dev
+ */
+static int adev_seq_show(struct seq_file *seq, void *v)
+{
+	struct fbxatm_dev *adev;
+
+	if (v == (void *)SEQ_START_TOKEN) {
+		seq_printf(seq, "%s",
+			   "Itf  RX TX  RXAAL5 TXAAL5  RXF4OAM TXF4OAM  "
+			   "RXF5OAM TXF5OAM  RXBADOAM RXBADLLIDOAM "
+			   "RXOTHEROAM RXDROPPED TXDROPNOLINK\n");
+		return 0;
+	}
+
+	adev = (struct fbxatm_dev *)v;
+	seq_printf(seq, "%d  %lu %lu  %lu %lu  ",
+		   adev->ifindex,
+		   adev->stats.rx_bytes,
+		   adev->stats.tx_bytes,
+		   adev->stats.rx_aal5,
+		   adev->stats.tx_aal5);
+
+	seq_printf(seq, "%lu %lu  %lu %lu  %lu %lu %lu %lu %lu\n",
+		   adev->stats.rx_f4_oam,
+		   adev->stats.tx_f4_oam,
+
+		   adev->stats.rx_f5_oam,
+		   adev->stats.tx_f5_oam,
+
+		   adev->stats.rx_bad_oam,
+		   adev->stats.rx_bad_llid_oam,
+		   adev->stats.rx_other_oam,
+		   adev->stats.rx_dropped,
+		   adev->stats.tx_drop_nolink);
+	return 0;
+}
+
+static void *adev_seq_start(struct seq_file *seq, loff_t *pos)
+{
+	struct fbxatm_dev *adev, *tadev;
+	int count;
+
+	mutex_lock(&fbxatm_mutex);
+
+	if (!*pos)
+		return SEQ_START_TOKEN;
+
+	count = 1;
+	tadev = NULL;
+	list_for_each_entry(adev, &fbxatm_dev_list, next) {
+		if (count == *pos) {
+			tadev = adev;
+			break;
+		}
+		count++;
+	}
+
+	return tadev;
+}
+
+static void *adev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+	struct fbxatm_dev *adev, *tadev;
+
+	if (v == (void *)SEQ_START_TOKEN) {
+		if (list_empty(&fbxatm_dev_list))
+			return NULL;
+		adev = list_entry(fbxatm_dev_list.next, struct fbxatm_dev,
+				  next);
+	} else
+		adev = (struct fbxatm_dev *)v;
+
+	tadev = NULL;
+	list_for_each_entry_continue(adev, &fbxatm_dev_list, next) {
+		tadev = adev;
+		break;
+	}
+
+	if (tadev)
+		(*pos)++;
+	return tadev;
+}
+
+static void adev_seq_stop(struct seq_file *seq, void *v)
+{
+	mutex_unlock(&fbxatm_mutex);
+}
+
+static const struct seq_operations adev_seq_ops = {
+	.start		= adev_seq_start,
+	.next		= adev_seq_next,
+	.stop		= adev_seq_stop,
+	.show		= adev_seq_show,
+};
+
+static int adev_seq_open(struct inode *inode, struct file *file)
+{
+	return seq_open(file, &adev_seq_ops);
+}
+
+static const struct file_operations adev_seq_fops = {
+	.open		= adev_seq_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= seq_release,
+};
+
+
+/*
+ * create device private entry in proc
+ */
+int fbxatm_proc_dev_register(struct fbxatm_dev *adev)
+{
+	adev->dev_proc_entry = proc_mkdir(adev->name, fbxatm_proc_root);
+	if (!adev->dev_proc_entry)
+		return 1;
+	return 0;
+}
+
+
+void fbxatm_proc_dev_deregister(struct fbxatm_dev *adev)
+{
+	remove_proc_entry(adev->name, fbxatm_proc_root);
+}
+
+/*
+ * create misc private entry in proc
+ */
+struct proc_dir_entry *fbxatm_proc_misc_register(const char *path)
+{
+	return proc_mkdir(path, fbxatm_proc_root);
+}
+
+void fbxatm_proc_misc_deregister(const char *path)
+{
+	remove_proc_entry(path, fbxatm_proc_root);
+}
+
+/*
+ * list of proc entries for fbxatm
+ */
+static struct fbxatm_proc_entry {
+	char *name;
+	const struct file_operations *proc_fops;
+	struct proc_dir_entry *dirent;
+
+} fbxatm_proc_entries[] = {
+	{
+		.name = "dev",
+		.proc_fops = &adev_seq_fops,
+	},
+	{
+		.name = "vcc",
+		.proc_fops = &vcc_seq_fops,
+	},
+};
+
+static void fbxatm_remove_proc(void)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(fbxatm_proc_entries); i++) {
+		struct fbxatm_proc_entry *e;
+
+		e = &fbxatm_proc_entries[i];
+
+		if (!e->dirent)
+			continue;
+		remove_proc_entry(e->name, fbxatm_proc_root);
+		e->dirent = NULL;
+	}
+
+	remove_proc_entry("fbxatm", init_net.proc_net);
+}
+
+int __init fbxatm_procfs_init(void)
+{
+	unsigned int i;
+	int ret;
+
+	fbxatm_proc_root = proc_net_mkdir(&init_net, "fbxatm",
+					  init_net.proc_net);
+	if (!fbxatm_proc_root) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(fbxatm_proc_entries); i++) {
+		struct proc_dir_entry *dirent;
+		struct fbxatm_proc_entry *e;
+
+		e = &fbxatm_proc_entries[i];
+
+		dirent = proc_create_data(e->name, S_IRUGO, fbxatm_proc_root,
+					  e->proc_fops, NULL);
+		if (!dirent) {
+			ret = -ENOMEM;
+			goto err;
+		}
+		e->dirent = dirent;
+	}
+
+	return 0;
+
+err:
+	if (fbxatm_proc_root)
+		fbxatm_remove_proc();
+	return ret;
+}
+
+void fbxatm_procfs_exit(void)
+{
+	fbxatm_remove_proc();
+}
diff -Nruw linux-4.2.6-fbx/net/fbxatm./fbxatm_remote.c linux-4.2.6-fbx/net/fbxatm/fbxatm_remote.c
--- linux-4.2.6-fbx/net/fbxatm./fbxatm_remote.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxatm/fbxatm_remote.c	2015-11-02 18:59:24.004567494 +0100
@@ -0,0 +1,810 @@
+#include <linux/module.h>
+#include <linux/fbxatm.h>
+#include <linux/fbxatm_dev.h>
+#include <linux/fbxatm_remote.h>
+#include <asm/unaligned.h>
+
+#define PFX		"fbxatm_remote: "
+#define MAX_PORTS	64
+#define MAX_RETRANS	10
+#define RETRANS_TIMER	(HZ / 3)
+
+struct fbxatm_remote_ctx;
+
+struct fbxatm_remote_sock {
+	spinlock_t			lock;
+	struct fbxatm_remote_sockaddr	addr;
+
+	struct timer_list		retrans_timer;
+	unsigned int			retrans_count;
+
+	struct sk_buff			*pending;
+
+	/* 1 for output */
+	int				direction;
+
+	/* wait ack for output, send ack for input */
+	int				has_ack;
+
+	u8				seq;
+
+	struct fbxatm_remote_ctx	*ctx;
+	struct list_head		next;
+};
+
+struct fbxatm_remote_ctx {
+	spinlock_t			lock;
+	int				dead;
+
+	struct net_device		*netdev;
+	u8				remote_mac[ETH_ALEN];
+	u32				session_id;
+
+	struct fbxatm_remote_sock	*socks_per_lport[MAX_PORTS];
+	struct sk_buff			*pending_zero_ack;
+
+	void				(*timeout_cb)(void *priv);
+	void				*priv;
+
+	struct list_head		next;
+};
+
+static struct list_head ctx_list;
+static DEFINE_SPINLOCK(ctx_list_lock);
+static void (*unknown_cb)(struct net_device *,
+			  struct sk_buff *);
+
+unsigned int fbxatm_remote_headroom(struct fbxatm_remote_ctx *ctx)
+{
+	return sizeof (struct fbxatm_remote_hdr) +
+		ctx->netdev->hard_header_len + ctx->netdev->needed_headroom;
+}
+
+EXPORT_SYMBOL(fbxatm_remote_headroom);
+
+/*
+ * allocate skb with enough headroom for header
+ */
+struct sk_buff *fbxatm_remote_alloc_skb(struct fbxatm_remote_ctx *ctx,
+					unsigned int size)
+{
+	struct sk_buff *skb;
+	unsigned int hroom_size;
+
+	hroom_size = fbxatm_remote_headroom(ctx);
+	skb = dev_alloc_skb(hroom_size + size);
+	if (!skb)
+		return NULL;
+	skb_reserve(skb, hroom_size);
+	return skb;
+}
+
+EXPORT_SYMBOL(fbxatm_remote_alloc_skb);
+
+/*
+ * return sock addr
+ */
+void fbxatm_remote_sock_getaddr(struct fbxatm_remote_sock *sock,
+				struct fbxatm_remote_sockaddr *addr)
+{
+	memcpy(addr, &sock->addr, sizeof (*addr));
+}
+
+EXPORT_SYMBOL(fbxatm_remote_sock_getaddr);
+
+/*
+ * socket retrans timer callback
+ */
+static void sock_timer(unsigned long data)
+{
+	struct fbxatm_remote_sock *sock;
+	struct sk_buff *skb;
+
+	sock = (struct fbxatm_remote_sock *)data;
+
+	spin_lock_bh(&sock->ctx->lock);
+	spin_lock(&sock->lock);
+
+	if (!sock->addr.infinite_retry && sock->retrans_count >= MAX_RETRANS) {
+		printk(KERN_ERR PFX "retrans max reached\n");
+		sock->ctx->dead = 1;
+		dev_kfree_skb(sock->pending);
+		sock->pending = NULL;
+		if (sock->ctx->timeout_cb)
+			sock->ctx->timeout_cb(sock->ctx->priv);
+		spin_unlock(&sock->lock);
+		spin_unlock_bh(&sock->ctx->lock);
+		return;
+	}
+
+	sock->retrans_count++;
+	sock->retrans_timer.expires = jiffies + RETRANS_TIMER;
+
+	skb = skb_clone(sock->pending, GFP_ATOMIC);
+	if (skb)
+		dev_queue_xmit(skb);
+	add_timer(&sock->retrans_timer);
+
+	spin_unlock(&sock->lock);
+	spin_unlock_bh(&sock->ctx->lock);
+}
+
+/*
+ * append header for given socket
+ */
+static int append_tx_header(struct fbxatm_remote_sock *sock,
+			    struct sk_buff *skb)
+{
+	struct fbxatm_remote_hdr *hdr;
+	unsigned int needed;
+
+	needed = skb->dev->hard_header_len + skb->dev->needed_headroom +
+		sizeof (*hdr);
+
+	if (unlikely(skb_headroom(skb) < needed)) {
+		if (net_ratelimit())
+			printk(KERN_WARNING PFX "headroom too small %d < %d\n",
+			       skb_headroom(skb), needed);
+	}
+
+	if (skb_cow_head(skb, needed))
+		return 1;
+
+	hdr = (struct fbxatm_remote_hdr *)skb_push(skb, sizeof (*hdr));
+	skb_set_network_header(skb, 0);
+
+	put_unaligned(htonl(FBXATM_REMOTE_MAGIC), &hdr->magic);
+	if (sock->direction == 1) {
+		/* output */
+		hdr->flags = 0;
+	} else {
+		/* input */
+		hdr->flags = FBXATM_RFLAGS_ACK;
+	}
+	hdr->seq = sock->seq;
+	put_unaligned(htons(skb->len), &hdr->len);
+	put_unaligned(sock->addr.lport, &hdr->sport);
+	put_unaligned(sock->addr.dport, &hdr->dport);
+
+	put_unaligned(sock->addr.mtype, &hdr->mtype);
+	put_unaligned(sock->ctx->session_id, &hdr->session_id);
+
+	skb->protocol = htons(ETH_P_FBXATM_REMOTE);
+	if (dev_hard_header(skb, skb->dev, ETH_P_FBXATM_REMOTE,
+			    sock->ctx->remote_mac, NULL, skb->len) < 0)
+		return 1;
+
+	return 0;
+}
+
+/*
+ * purge socket send queue, advance next sequence
+ */
+void fbxatm_remote_sock_purge(struct fbxatm_remote_sock *sock)
+{
+	spin_lock_bh(&sock->lock);
+	if (sock->pending) {
+		del_timer_sync(&sock->retrans_timer);
+		dev_kfree_skb(sock->pending);
+		sock->pending = NULL;
+		sock->seq++;
+	}
+	spin_unlock_bh(&sock->lock);
+}
+
+EXPORT_SYMBOL(fbxatm_remote_sock_purge);
+
+/*
+ * check if tx is pending on socket
+ */
+int fbxatm_remote_sock_pending(struct fbxatm_remote_sock *sock)
+{
+	int ret;
+
+	spin_lock_bh(&sock->lock);
+	ret = sock->pending ? 1 : 0;
+	spin_unlock_bh(&sock->lock);
+	return ret;
+}
+
+EXPORT_SYMBOL(fbxatm_remote_sock_pending);
+
+/*
+ * send skb on socket
+ */
+int fbxatm_remote_sock_send(struct fbxatm_remote_sock *sock,
+			    struct sk_buff *skb)
+{
+	BUG_ON(sock->direction == 0);
+
+	spin_lock_bh(&sock->lock);
+	skb->dev = sock->ctx->netdev;
+
+	if (append_tx_header(sock, skb)) {
+		spin_unlock_bh(&sock->lock);
+		dev_kfree_skb(skb);
+		return 1;
+	}
+
+	if (unlikely(sock->ctx->dead)) {
+		spin_unlock_bh(&sock->lock);
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	/* start retrans timer if needed */
+	if (sock->has_ack) {
+		if (sock->pending) {
+			printk(KERN_ERR PFX "sock already has tx pending\n");
+			spin_unlock_bh(&sock->lock);
+			dev_kfree_skb(skb);
+			return 1;
+		}
+
+		sock->pending = skb_clone(skb, GFP_ATOMIC);
+		if (sock->pending) {
+			sock->retrans_count = 0;
+			sock->retrans_timer.expires = jiffies + RETRANS_TIMER;
+			add_timer(&sock->retrans_timer);
+		}
+	}
+
+	spin_unlock_bh(&sock->lock);
+	dev_queue_xmit(skb);
+
+	return 0;
+}
+
+EXPORT_SYMBOL(fbxatm_remote_sock_send);
+
+/*
+ * send ack skb on socket
+ */
+int fbxatm_remote_sock_send_ack(struct fbxatm_remote_sock *sock,
+				struct sk_buff *skb)
+{
+	BUG_ON(sock->direction == 1);
+
+	spin_lock_bh(&sock->lock);
+
+	skb->dev = sock->ctx->netdev;
+
+	if (append_tx_header(sock, skb)) {
+		spin_unlock_bh(&sock->lock);
+		dev_kfree_skb(skb);
+		return 1;
+	}
+
+	if (unlikely(sock->ctx->dead)) {
+		spin_unlock_bh(&sock->lock);
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	skb->dev = sock->ctx->netdev;
+	sock->pending = skb_clone(skb, GFP_ATOMIC);
+	spin_unlock_bh(&sock->lock);
+	dev_queue_xmit(skb);
+
+	return 0;
+}
+
+EXPORT_SYMBOL(fbxatm_remote_sock_send_ack);
+
+/*
+ * send raw ack
+ */
+int fbxatm_remote_sock_send_raw_ack(struct fbxatm_remote_ctx *ctx,
+				    struct net_device *dev,
+				    u8 *remote_mac,
+				    struct fbxatm_remote_hdr *hdr,
+				    struct sk_buff *ack)
+{
+	struct fbxatm_remote_hdr *ack_hdr;
+
+	if (skb_cow_head(ack, sizeof (*ack_hdr))) {
+		dev_kfree_skb(ack);
+		return 1;
+	}
+
+	ack_hdr = (struct fbxatm_remote_hdr *)skb_push(ack, sizeof (*hdr));
+	skb_set_network_header(ack, 0);
+
+	put_unaligned(htonl(FBXATM_REMOTE_MAGIC), &ack_hdr->magic);
+	ack_hdr->flags = FBXATM_RFLAGS_ACK;
+	ack_hdr->seq = hdr->seq;
+
+	put_unaligned(htons(ack->len), &ack_hdr->len);
+	put_unaligned(hdr->dport, &ack_hdr->sport);
+	put_unaligned(hdr->sport, &ack_hdr->dport);
+	put_unaligned(hdr->mtype, &ack_hdr->mtype);
+	put_unaligned(hdr->session_id, &ack_hdr->session_id);
+
+	ack->dev = dev;
+
+	if (dev_hard_header(ack, dev, ETH_P_FBXATM_REMOTE,
+			    remote_mac, NULL, ack->len) < 0) {
+		dev_kfree_skb(ack);
+		return 1;
+	}
+
+	if (hdr->dport == 0) {
+		kfree(ctx->pending_zero_ack);
+		ctx->pending_zero_ack = skb_clone(ack, GFP_ATOMIC);
+	}
+
+	if (dev_queue_xmit(ack))
+		return 1;
+
+	return 0;
+}
+
+EXPORT_SYMBOL(fbxatm_remote_sock_send_raw_ack);
+
+/*
+ * handle input data on 'in' direction socket
+ */
+static void __in_sock_rcv(struct fbxatm_remote_sock *sock,
+			  struct sk_buff *skb,
+			  struct fbxatm_remote_hdr *hdr)
+{
+	struct sk_buff *ack;
+	int ret;
+
+	spin_lock(&sock->lock);
+
+	if (sock->has_ack) {
+		u8 expected_seq;
+
+		/* check for duplicate seq  */
+		if (hdr->seq == sock->seq) {
+
+			/* got last packet again, ack has been
+			 * lost, send it again if we have it */
+			if (sock->pending) {
+				ack = skb_clone(sock->pending, GFP_ATOMIC);
+				if (ack)
+					dev_queue_xmit(ack);
+			}
+
+			spin_unlock(&sock->lock);
+			dev_kfree_skb(skb);
+			return;
+		}
+
+		expected_seq = sock->seq + 1;
+		if (hdr->seq != expected_seq) {
+			/* lost sync */
+			spin_unlock(&sock->lock);
+			dev_kfree_skb(skb);
+			return;
+		}
+
+		/* about to accept new packet, free any pending ack */
+		dev_kfree_skb(sock->pending);
+		sock->pending = NULL;
+
+		sock->seq = hdr->seq;
+
+		/* set sock dport to last receive packet to send
+		 * correct ack */
+		sock->addr.dport = hdr->sport;
+	}
+
+	/* deliver packet to socket */
+	ret = sock->addr.deliver(sock->addr.priv, skb, &ack);
+
+	if (!sock->has_ack || !ret) {
+		/* don't send ack now */
+		spin_unlock(&sock->lock);
+		return;
+	}
+
+	if (!ack) {
+		/* generate empty ack */
+		ack = fbxatm_remote_alloc_skb(sock->ctx, 0);
+		if (!ack) {
+			spin_unlock(&sock->lock);
+			return;
+		}
+	}
+
+	ack->dev = sock->ctx->netdev;
+
+	if (append_tx_header(sock, ack)) {
+		spin_unlock(&sock->lock);
+		dev_kfree_skb(ack);
+		return;
+	}
+
+	sock->pending = ack;
+
+	/* send ack now */
+	ack = skb_clone(sock->pending, GFP_ATOMIC);
+	spin_unlock(&sock->lock);
+
+	if (ack)
+		dev_queue_xmit(ack);
+}
+
+/*
+ * handle data on 'out' direction socket
+ */
+static void __out_sock_rcv(struct fbxatm_remote_sock *sock,
+			   struct sk_buff *skb,
+			   struct fbxatm_remote_hdr *hdr)
+{
+	if (!sock->has_ack) {
+		dev_kfree_skb(skb);
+		printk(KERN_ERR PFX "ack for non ack sock\n");
+		return;
+	}
+
+	spin_lock(&sock->lock);
+
+	/* check if ack if for last sent seq */
+	if (hdr->seq != sock->seq) {
+		spin_unlock(&sock->lock);
+		dev_kfree_skb(skb);
+		return;
+	}
+
+	/* make sure we're expecting it */
+	if (!sock->pending) {
+		spin_unlock(&sock->lock);
+		dev_kfree_skb(skb);
+		return;
+	}
+
+	del_timer_sync(&sock->retrans_timer);
+	dev_kfree_skb(sock->pending);
+	sock->pending = NULL;
+	sock->seq++;
+
+	if (sock->addr.response)
+		sock->addr.response(sock->addr.priv, skb);
+	else
+		dev_kfree_skb(skb);
+
+	spin_unlock(&sock->lock);
+}
+
+/*
+ * fbxatm ethertype rx callback
+ */
+static int fbxatm_rcv(struct sk_buff *skb, struct net_device *dev,
+		      struct packet_type *pt, struct net_device *orig_dev)
+{
+	struct fbxatm_remote_hdr *hdr;
+	struct fbxatm_remote_ctx *ctx;
+	int found;
+	unsigned int len;
+	u16 port;
+
+	if (!netif_running(dev)) {
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	skb = skb_unshare(skb, GFP_ATOMIC);
+	if (!skb)
+		return 0;
+
+	/* decode fbxatm ethertype */
+	if (!pskb_may_pull(skb, sizeof (*hdr))) {
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	hdr = (struct fbxatm_remote_hdr *)skb_network_header(skb);
+	if (ntohl(hdr->magic) != FBXATM_REMOTE_MAGIC) {
+		if (net_ratelimit())
+			printk(KERN_ERR PFX "bad fbxatm remote magic: %08x\n",
+			       ntohl(hdr->magic));
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	/* check len */
+	len = ntohs(hdr->len);
+	if (skb->len < len) {
+		if (net_ratelimit())
+			printk(KERN_ERR PFX "short packet\n");
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	/* trim skb to correct size */
+	if (pskb_trim(skb, len)) {
+		dev_kfree_skb(skb);
+		return 0;
+	}
+
+	port = ntohs(hdr->dport);
+	if (port >= MAX_PORTS) {
+		dev_kfree_skb(skb);
+		printk(KERN_ERR PFX "bad port %u\n", port);
+		return 0;
+	}
+
+	/* remove header */
+	skb_set_network_header(skb, 0);
+	__skb_pull(skb, sizeof (*hdr));
+	skb_set_transport_header(skb, 0);
+
+	/* find context by mac/session id */
+	found = 0;
+	spin_lock_bh(&ctx_list_lock);
+	list_for_each_entry(ctx, &ctx_list, next) {
+		struct ethhdr *eth;
+		struct fbxatm_remote_sock *sock;
+		int is_ack;
+
+		eth = eth_hdr(skb);
+		if (memcmp(eth->h_source, ctx->remote_mac, ETH_ALEN))
+			continue;
+
+		if (hdr->session_id != ctx->session_id)
+			continue;
+
+		spin_lock(&ctx->lock);
+
+		if (unlikely(ctx->dead)) {
+			spin_unlock(&ctx->lock);
+			continue;
+		}
+
+		/* found context, find socket by port */
+		found = 1;
+
+		/* special case for port 0, in case ack is lost */
+		if (port == 0 && ctx->pending_zero_ack) {
+			struct sk_buff *ack;
+			ack = skb_clone(ctx->pending_zero_ack, GFP_ATOMIC);
+			if (ack)
+				dev_queue_xmit(ack);
+			spin_unlock(&ctx->lock);
+			break;
+		}
+
+		sock = ctx->socks_per_lport[port];
+		if (!sock) {
+			printk(KERN_ERR PFX "context but no socket for "
+			       "port: %u\n", port);
+			spin_unlock(&ctx->lock);
+			break;
+		}
+
+		if (hdr->mtype != sock->addr.mtype) {
+			printk(KERN_ERR PFX "incorrect mtype for sock\n");
+			spin_unlock(&ctx->lock);
+			break;
+		}
+
+		/* check direction, we should only get ack for output
+		 * socket */
+		is_ack = (hdr->flags & FBXATM_RFLAGS_ACK) ? 1 : 0;
+		if (sock->direction ^ is_ack) {
+			printk(KERN_ERR PFX "incorrect ack value for sock\n");
+			spin_unlock(&ctx->lock);
+			break;
+		}
+
+		/* ok deliver */
+		if (sock->direction)
+			__out_sock_rcv(sock, skb, hdr);
+		else
+			__in_sock_rcv(sock, skb, hdr);
+
+		spin_unlock(&ctx->lock);
+		spin_unlock_bh(&ctx_list_lock);
+		return 0;
+	}
+
+	spin_unlock_bh(&ctx_list_lock);
+
+	if (!found && unknown_cb)
+		unknown_cb(dev, skb);
+	else
+		dev_kfree_skb(skb);
+
+	return 0;
+}
+
+void fbxatm_remote_set_unknown_cb(void (*cb)(struct net_device *,
+					     struct sk_buff *))
+{
+	unknown_cb = cb;
+}
+
+EXPORT_SYMBOL(fbxatm_remote_set_unknown_cb);
+
+/*
+ * allocate local port for socket
+ */
+static int __alloc_lport(struct fbxatm_remote_ctx *ctx,
+			 struct fbxatm_remote_sock *sock)
+{
+	int i;
+
+	for (i = 1; i < ARRAY_SIZE(ctx->socks_per_lport); i++) {
+		if (ctx->socks_per_lport[i])
+			continue;
+		sock->addr.lport = htons(i);
+		ctx->socks_per_lport[i] = sock;
+		return 0;
+	}
+	return -EADDRINUSE;
+}
+
+static struct fbxatm_remote_sock *sock_new(struct fbxatm_remote_sockaddr *addr)
+{
+	struct fbxatm_remote_sock *sock;
+
+	sock = kzalloc(sizeof (*sock), GFP_KERNEL);
+	if (!sock)
+		return NULL;
+	memcpy(&sock->addr, addr, sizeof (*addr));
+	init_timer(&sock->retrans_timer);
+	spin_lock_init(&sock->lock);
+	sock->retrans_timer.data = (unsigned long)sock;
+	sock->retrans_timer.function = sock_timer;
+	return sock;
+}
+
+struct fbxatm_remote_sock *
+fbxatm_remote_sock_connect(struct fbxatm_remote_ctx *ctx,
+			   struct fbxatm_remote_sockaddr *addr,
+			   int need_ack)
+{
+	struct fbxatm_remote_sock *sock;
+
+	sock = sock_new(addr);
+	if (!sock)
+		return NULL;
+
+	spin_lock_bh(&ctx->lock);
+	sock->ctx = ctx;
+	if (__alloc_lport(ctx, sock)) {
+		spin_unlock_bh(&ctx->lock);
+		kfree(sock);
+		return NULL;
+	}
+
+	sock->direction = 1;
+	sock->seq = 0;
+	sock->has_ack = need_ack;
+	spin_unlock_bh(&ctx->lock);
+
+	return sock;
+}
+
+EXPORT_SYMBOL(fbxatm_remote_sock_connect);
+
+struct fbxatm_remote_sock *
+fbxatm_remote_sock_bind(struct fbxatm_remote_ctx *ctx,
+			struct fbxatm_remote_sockaddr *addr,
+			int send_ack)
+{
+	struct fbxatm_remote_sock *sock;
+
+	sock = sock_new(addr);
+	if (!sock)
+		return NULL;
+
+	spin_lock_bh(&ctx->lock);
+	sock->ctx = ctx;
+	if (__alloc_lport(ctx, sock)) {
+		spin_unlock_bh(&ctx->lock);
+		kfree(sock);
+		return NULL;
+	}
+
+	sock->direction = 0;
+	sock->seq = ~0;
+	sock->has_ack = send_ack;
+	spin_unlock_bh(&ctx->lock);
+
+	return sock;
+}
+
+EXPORT_SYMBOL(fbxatm_remote_sock_bind);
+
+void fbxatm_remote_sock_close(struct fbxatm_remote_sock *sock)
+{
+	spin_lock_bh(&sock->ctx->lock);
+	if (sock->addr.lport)
+		sock->ctx->socks_per_lport[ntohs(sock->addr.lport)] = NULL;
+
+	spin_lock(&sock->lock);
+	del_timer_sync(&sock->retrans_timer);
+	dev_kfree_skb(sock->pending);
+	spin_unlock(&sock->lock);
+	spin_unlock_bh(&sock->ctx->lock);
+	kfree(sock);
+}
+
+EXPORT_SYMBOL(fbxatm_remote_sock_close);
+
+struct fbxatm_remote_ctx *fbxatm_remote_alloc_ctx(struct net_device *netdev,
+						  u8 *remote_mac,
+						  u32 session_id,
+						  void (*timeout)(void *priv),
+						  void *priv)
+{
+	struct fbxatm_remote_ctx *ctx;
+
+	ctx = kzalloc(sizeof (*ctx), GFP_KERNEL);
+	if (!ctx)
+		return NULL;
+	ctx->netdev = netdev;
+	spin_lock_init(&ctx->lock);
+	memcpy(ctx->remote_mac, remote_mac, ETH_ALEN);
+	ctx->session_id = session_id;
+	ctx->timeout_cb = timeout;
+	ctx->priv = priv;
+
+	spin_lock_bh(&ctx_list_lock);
+	list_add_tail(&ctx->next, &ctx_list);
+	spin_unlock_bh(&ctx_list_lock);
+
+	return ctx;
+}
+
+EXPORT_SYMBOL(fbxatm_remote_alloc_ctx);
+
+void fbxatm_remote_ctx_set_dead(struct fbxatm_remote_ctx *ctx)
+{
+	spin_lock_bh(&ctx->lock);
+	ctx->dead = 1;
+	spin_unlock_bh(&ctx->lock);
+}
+
+EXPORT_SYMBOL(fbxatm_remote_ctx_set_dead);
+
+void fbxatm_remote_free_ctx(struct fbxatm_remote_ctx *ctx)
+{
+	int i;
+
+	spin_lock_bh(&ctx_list_lock);
+	spin_lock(&ctx->lock);
+
+	for (i = 1; i < ARRAY_SIZE(ctx->socks_per_lport); i++) {
+		if (!ctx->socks_per_lport[i])
+			continue;
+		printk(KERN_ERR PFX "socket count is not 0\n");
+		spin_unlock(&ctx->lock);
+		spin_unlock_bh(&ctx_list_lock);
+		return;
+	}
+
+	kfree(ctx->pending_zero_ack);
+	list_del(&ctx->next);
+	spin_unlock(&ctx->lock);
+	spin_unlock_bh(&ctx_list_lock);
+	kfree(ctx);
+}
+
+EXPORT_SYMBOL(fbxatm_remote_free_ctx);
+
+static struct packet_type fbxatm_packet_type = {
+	.type	= __constant_htons(ETH_P_FBXATM_REMOTE),
+	.func	= fbxatm_rcv,
+};
+
+int fbxatm_remote_init(void)
+{
+	spin_lock_init(&ctx_list_lock);
+	INIT_LIST_HEAD(&ctx_list);
+	dev_add_pack(&fbxatm_packet_type);
+	return 0;
+}
+
+EXPORT_SYMBOL(fbxatm_remote_init);
+
+void fbxatm_remote_exit(void)
+{
+	dev_remove_pack(&fbxatm_packet_type);
+}
+
+EXPORT_SYMBOL(fbxatm_remote_exit);
diff -Nruw linux-4.2.6-fbx/net/fbxatm./fbxatm_remote_driver.c linux-4.2.6-fbx/net/fbxatm/fbxatm_remote_driver.c
--- linux-4.2.6-fbx/net/fbxatm./fbxatm_remote_driver.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxatm/fbxatm_remote_driver.c	2015-11-02 18:59:24.004567494 +0100
@@ -0,0 +1,1123 @@
+/*
+ * "remote" driver for fbxatm, "connect" to a remote fbxatm stack in
+ * net stub mode and control its PHYs
+ *
+ * Copyright (C) 2009 Maxime Bizon <mbizon@freebox.fr>
+ */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/sched.h>
+
+#include "fbxatm_remote_driver.h"
+
+#define PFX	"fbxatm_remote_driver: "
+
+static struct list_head remote_dev_list;
+static DEFINE_SPINLOCK(remote_lock);
+
+/*
+ * request moving to dead state and schedule
+ */
+static void set_dying(struct driver_remote *priv)
+{
+	priv->want_die = 1;
+	schedule_delayed_work(&priv->fsm_work, 0);
+}
+
+/*
+ * socket deliver callback for vcc_rx socket
+ */
+static int vcc_rx_deliver(void *data, struct sk_buff *skb,
+			  struct sk_buff **ack)
+{
+	struct driver_remote_vcc *pvcc;
+
+	pvcc = (struct driver_remote_vcc *)data;
+	fbxatm_netifrx(pvcc->vcc, skb);
+	return 0;
+}
+
+/*
+ * socket deliver callback for vcc_qempty socket
+ */
+static int vcc_qempty_deliver(void *data, struct sk_buff *skb,
+			      struct sk_buff **ack)
+{
+	struct driver_remote_vcc *pvcc;
+	struct driver_remote *priv;
+
+	pvcc = (struct driver_remote_vcc *)data;
+	priv = pvcc->priv;
+
+	spin_lock(&priv->tx_lock);
+
+	if (pvcc->tx_pending) {
+		/* wait until we get tx ack */
+		pvcc->tx_got_qempty = 1;
+		goto send_ack;
+	}
+
+	/* report tx done event */
+	clear_bit(FBXATM_VCC_F_FULL, &pvcc->vcc->vcc_flags);
+	fbxatm_tx_done(pvcc->vcc);
+
+send_ack:
+	dev_kfree_skb(skb);
+	*ack = NULL;
+	spin_unlock(&priv->tx_lock);
+	/* send ack now */
+	return 1;
+}
+
+/*
+ * socket response callback for vcc_send socket, called with bh
+ * disabled
+ */
+static void vcc_send_response(void *data, struct sk_buff *skb)
+{
+	struct fbxatm_remote_vcc_send_ack *pkt_ack;
+	struct driver_remote_vcc *pvcc;
+	struct driver_remote *priv;
+
+	pvcc = (struct driver_remote_vcc *)data;
+	priv = pvcc->priv;
+
+	spin_lock(&priv->tx_lock);
+
+	if (unlikely(!pvcc->tx_pending)) {
+		printk(KERN_ERR PFX "send response while no tx pending\n");
+		goto out;
+	}
+
+	if (!pskb_may_pull(skb, sizeof (*pkt_ack))) {
+		printk(KERN_ERR PFX "bad vcc send ack\n");
+		goto out;
+	}
+
+	pvcc->tx_pending = 0;
+
+	pkt_ack = (struct fbxatm_remote_vcc_send_ack *)skb->data;
+	if (pkt_ack->full) {
+		/* qempty will wake us up later, but maybe we got it
+		 * already ? */
+		if (!pvcc->tx_got_qempty)
+			goto out;
+	}
+
+	/* wake up queue */
+	clear_bit(FBXATM_VCC_F_FULL, &pvcc->vcc->vcc_flags);
+	fbxatm_tx_done(pvcc->vcc);
+
+out:
+	spin_unlock(&priv->tx_lock);
+	dev_kfree_skb(skb);
+}
+
+/*
+ * fbxatm request to send aal5 on given vcc, called with bh disabled
+ */
+static int remote_send(struct fbxatm_vcc *vcc, struct sk_buff *skb)
+{
+	struct driver_remote_vcc *pvcc;
+	struct driver_remote *priv;
+
+	pvcc = vcc->dev_priv;
+	priv = pvcc->priv;
+
+	spin_lock(&priv->tx_lock);
+	if (priv->state != RSTATE_S_ACTIVE)
+		goto drop;
+
+	if (test_bit(FBXATM_VCC_F_FULL, &vcc->vcc_flags)) {
+		spin_unlock(&priv->tx_lock);
+		/* return queue full */
+		return 1;
+	}
+
+	if (fbxatm_remote_sock_send(pvcc->vcc_send_sock, skb)) {
+		/* packet has been dropped */
+		spin_unlock(&priv->tx_lock);
+		return 0;
+	}
+
+	set_bit(FBXATM_VCC_F_FULL, &vcc->vcc_flags);
+	pvcc->tx_pending = 1;
+	pvcc->tx_got_qempty = 0;
+
+	spin_unlock(&priv->tx_lock);
+	return 0;
+
+drop:
+	spin_unlock(&priv->tx_lock);
+	dev_kfree_skb(skb);
+	return 0;
+}
+
+/*
+ * sleep until we get an ack for sockets using wq
+ */
+static int __wait_ack(struct driver_remote *priv)
+{
+	wait_event(priv->wq, priv->wq_res != 0 ||
+		   priv->state != RSTATE_S_ACTIVE);
+
+	if (priv->wq_res == 2 || priv->state != RSTATE_S_ACTIVE) {
+		/* timeout or device will die soon */
+		return -EIO;
+	}
+
+	return 0;
+}
+
+/*
+ * fbxatm callback to send oam cell
+ */
+static int remote_send_oam(struct fbxatm_dev *adev,
+			   struct fbxatm_oam_cell *cell)
+{
+	struct driver_remote *priv;
+	struct sk_buff *skb;
+	int ret;
+
+	priv = fbxatm_dev_priv(adev);
+	mutex_lock(&priv->mutex);
+
+	if (priv->state != RSTATE_S_ACTIVE) {
+		mutex_unlock(&priv->mutex);
+		return -ENODEV;
+	}
+
+	/* prepare outgoing packet */
+	skb = fbxatm_remote_alloc_skb(priv->remote_ctx,
+				      sizeof (cell->payload));
+	if (!skb) {
+		mutex_unlock(&priv->mutex);
+		kfree(cell);
+		return -ENOMEM;
+	}
+
+	memcpy(skb_put(skb, sizeof (cell->payload)), &cell->payload,
+	       sizeof (cell->payload));
+	kfree(cell);
+
+	/* send & wait for ack */
+	skb_queue_purge(&priv->wq_acks);
+	priv->wq_res = 0;
+
+	if (fbxatm_remote_sock_send(priv->dev_send_oam_sock, skb))
+		return -ENOMEM;
+
+	ret = __wait_ack(priv);
+	mutex_unlock(&priv->mutex);
+
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ * fbxatm callback to open given vcc
+ */
+static int remote_vcc_open(struct fbxatm_vcc *vcc)
+{
+	struct fbxatm_remote_vcc_action *pkt;
+	struct fbxatm_remote_vcc_action_ack *pkt_ack;
+	struct sk_buff *skb, *ack;
+	struct fbxatm_remote_sockaddr addr;
+	struct driver_remote_vcc *pvcc;
+	struct driver_remote *priv;
+	int ret;
+
+	priv = fbxatm_dev_priv(vcc->adev);
+	mutex_lock(&priv->mutex);
+
+	if (priv->state != RSTATE_S_ACTIVE) {
+		mutex_unlock(&priv->mutex);
+		return -EIO;
+	}
+
+	/* allocate private vcc context */
+	pvcc = kzalloc(sizeof (*pvcc), GFP_KERNEL);
+	if (!pvcc) {
+		mutex_unlock(&priv->mutex);
+		return -ENOMEM;
+	}
+
+	pvcc->priv = priv;
+	pvcc->vcc = vcc;
+	vcc->dev_priv = pvcc;
+
+	/* open input sockets */
+	memset(&addr, 0, sizeof (addr));
+	addr.mtype = htonl(FBXATM_RMT_VCC_RX);
+	addr.priv = pvcc;
+	addr.deliver = vcc_rx_deliver;
+	pvcc->vcc_rx_sock = fbxatm_remote_sock_bind(priv->remote_ctx,
+						    &addr, 0);
+	if (!pvcc->vcc_rx_sock) {
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	memset(&addr, 0, sizeof (addr));
+	addr.mtype = htonl(FBXATM_RMT_VCC_QEMPTY);
+	addr.priv = pvcc;
+	addr.deliver = vcc_qempty_deliver;
+	pvcc->vcc_qempty_sock = fbxatm_remote_sock_bind(priv->remote_ctx,
+							&addr, 1);
+	if (!pvcc->vcc_qempty_sock) {
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	/* prepare outgoing packet */
+	skb = fbxatm_remote_alloc_skb(priv->remote_ctx,
+				      sizeof (*pkt));
+	if (!skb) {
+		ret = -ENOMEM;
+		goto fail;
+	}
+	pkt = (struct fbxatm_remote_vcc_action *)skb_put(skb, sizeof (*pkt));
+	pkt->action = htonl(1);
+
+	fbxatm_remote_sock_getaddr(pvcc->vcc_rx_sock, &addr);
+	pkt->vcc_rx_port = addr.lport;
+
+	fbxatm_remote_sock_getaddr(pvcc->vcc_qempty_sock, &addr);
+	pkt->vcc_qempty_port = addr.lport;
+
+	pkt->vpi = htonl(vcc->vpi);
+	pkt->vci = htonl(vcc->vci);
+	pkt->traffic_class = htonl(vcc->qos.traffic_class);
+	pkt->max_sdu = htonl(vcc->qos.max_sdu);
+	pkt->max_buffered_pkt = htonl(vcc->qos.max_buffered_pkt);
+	pkt->priority = htonl(vcc->qos.priority);
+	pkt->rx_priority = htonl(vcc->qos.rx_priority);
+
+	/* send & wait for ack */
+	skb_queue_purge(&priv->wq_acks);
+	priv->wq_res = 0;
+
+	if (fbxatm_remote_sock_send(priv->vcc_action_sock, skb)) {
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	ret = __wait_ack(priv);
+
+	if (ret) {
+		/* timeout, device will die soon */
+		goto fail;
+	}
+
+	/* check ack */
+	ack = skb_dequeue(&priv->wq_acks);
+	if (!pskb_may_pull(ack, sizeof (*pkt_ack))) {
+		printk(KERN_ERR PFX "bad vcc action ack\n");
+		dev_kfree_skb(ack);
+		set_dying(priv);
+		ret = -EIO;
+		goto fail;
+	}
+
+	pkt_ack = (struct fbxatm_remote_vcc_action_ack *)ack->data;
+	if (pkt_ack->ret) {
+		printk(KERN_ERR PFX "remote vcc open failed\n");
+		dev_kfree_skb(ack);
+		set_dying(priv);
+		ret = -EIO;
+		goto fail;
+	}
+
+	pvcc->remote_id = pkt_ack->vcc_remote_id;
+
+	memset(&addr, 0, sizeof (addr));
+	addr.mtype = htonl(FBXATM_RMT_VCC_SEND);
+	addr.priv = pvcc;
+	addr.dport = pkt_ack->vcc_send_port;
+	addr.response = vcc_send_response;
+	pvcc->vcc_send_sock = fbxatm_remote_sock_connect(priv->remote_ctx,
+							 &addr, 1);
+	if (!pvcc->vcc_send_sock) {
+		dev_kfree_skb(ack);
+		set_dying(priv);
+		ret = -EIO;
+		goto fail;
+	}
+
+	dev_kfree_skb(ack);
+	list_add(&pvcc->next, &priv->pvcc_list);
+	mutex_unlock(&priv->mutex);
+	return 0;
+
+fail:
+	if (pvcc->vcc_qempty_sock)
+		fbxatm_remote_sock_close(pvcc->vcc_qempty_sock);
+	if (pvcc->vcc_rx_sock)
+		fbxatm_remote_sock_close(pvcc->vcc_rx_sock);
+	kfree(pvcc);
+	mutex_unlock(&priv->mutex);
+	return ret;
+}
+
+/*
+ * fbxatm callback to close & flush given vcc
+ */
+static void remote_vcc_close(struct fbxatm_vcc *vcc)
+{
+	struct driver_remote *priv;
+	struct driver_remote_vcc *pvcc;
+	struct sk_buff *skb, *ack;
+	struct fbxatm_remote_vcc_action *pkt;
+	struct fbxatm_remote_vcc_action_ack *pkt_ack;
+	int ret;
+
+	priv = fbxatm_dev_priv(vcc->adev);
+	mutex_lock(&priv->mutex);
+
+	pvcc = vcc->dev_priv;
+
+	if (priv->state != RSTATE_S_ACTIVE) {
+		/* just close vcc, don't tell remote */
+		list_del(&pvcc->next);
+		kfree(pvcc);
+
+		/* warn fsm so it can restart */
+		schedule_delayed_work(&priv->fsm_work, 0);
+		goto out_unlock;
+	}
+
+	/* prepare outgoing packet */
+	skb = fbxatm_remote_alloc_skb(priv->remote_ctx,
+				      sizeof (*pkt));
+	if (!skb) {
+		set_dying(priv);
+		goto out_unlock;
+	}
+
+	pkt = (struct fbxatm_remote_vcc_action *)skb_put(skb, sizeof (*pkt));
+	pkt->action = htonl(0);
+	pkt->vcc_remote_id = pvcc->remote_id;
+
+	/* free vcc now, failure will trigger dead state */
+	fbxatm_remote_sock_close(pvcc->vcc_send_sock);
+	fbxatm_remote_sock_close(pvcc->vcc_rx_sock);
+	fbxatm_remote_sock_close(pvcc->vcc_qempty_sock);
+	list_del(&pvcc->next);
+	kfree(pvcc);
+
+	/* send & wait for ack */
+	skb_queue_purge(&priv->wq_acks);
+	priv->wq_res = 0;
+
+	if (fbxatm_remote_sock_send(priv->vcc_action_sock, skb)) {
+		set_dying(priv);
+		goto out_unlock;
+	}
+
+	ret = __wait_ack(priv);
+
+	if (ret) {
+		/* timeout, device will die soon */
+		mutex_unlock(&priv->mutex);
+		return;
+	}
+
+	/* check ack */
+	ack = skb_dequeue(&priv->wq_acks);
+	if (!pskb_may_pull(ack, sizeof (*pkt_ack))) {
+		printk(KERN_ERR PFX "bad vcc action close ack\n");
+		dev_kfree_skb(ack);
+		set_dying(priv);
+		goto out_unlock;
+	}
+
+	pkt_ack = (struct fbxatm_remote_vcc_action_ack *)ack->data;
+	if (pkt_ack->ret) {
+		printk(KERN_ERR PFX "remote vcc close failed\n");
+		dev_kfree_skb(ack);
+		set_dying(priv);
+		goto out_unlock;
+	}
+
+out_unlock:
+	mutex_unlock(&priv->mutex);
+}
+
+/*
+ * common response for vcc action & send oam socket
+ */
+static void common_response(void *data, struct sk_buff *skb)
+{
+	struct driver_remote *priv;
+
+	priv = (struct driver_remote *)data;
+	skb_queue_tail(&priv->wq_acks, skb);
+	priv->wq_res = 1;
+	wake_up(&priv->wq);
+}
+
+/*
+ * create device procfs entries
+ */
+static int remote_init_procfs(struct fbxatm_dev *adev)
+{
+	return 0;
+}
+
+/*
+ * release device procfs entries
+ */
+static void remote_release_procfs(struct fbxatm_dev *adev)
+{
+}
+
+/*
+ * local fake fbxatm device callbacks
+ */
+static const struct fbxatm_dev_ops remote_fbxatm_ops = {
+	.open		= remote_vcc_open,
+	.close		= remote_vcc_close,
+	.send		= remote_send,
+	.send_oam	= remote_send_oam,
+	.init_procfs	= remote_init_procfs,
+	.release_procfs	= remote_release_procfs,
+	.owner		= THIS_MODULE,
+};
+
+/*
+ * dev_rx_oam socket rx callback
+ */
+static int dev_rx_oam_deliver(void *data, struct sk_buff *skb,
+			      struct sk_buff **ack)
+{
+	struct driver_remote *priv;
+
+	priv = (struct driver_remote *)data;
+	skb_queue_tail(&priv->dev_oam_reqs, skb);
+	schedule_delayed_work(&priv->fsm_work, 0);
+
+	return 0;
+}
+
+/*
+ * dev_link socket rx callback
+ */
+static int dev_link_deliver(void *data, struct sk_buff *skb,
+			    struct sk_buff **ack)
+{
+	struct driver_remote *priv;
+
+	priv = (struct driver_remote *)data;
+	skb_queue_tail(&priv->dev_link_reqs, skb);
+	schedule_delayed_work(&priv->fsm_work, 0);
+
+	/* send ack later */
+	return 0;
+}
+
+/*
+ * dev_connect socket tx ack callback
+ */
+static void dev_connect_response(void *data, struct sk_buff *skb)
+{
+	struct driver_remote *priv;
+
+	priv = (struct driver_remote *)data;
+	skb_queue_tail(&priv->connect_acks, skb);
+	schedule_delayed_work(&priv->fsm_work, 0);
+}
+
+/*
+ * handle link change queue
+ */
+static void handle_dev_link_queue(struct driver_remote *priv)
+{
+	struct sk_buff *skb;
+
+	do {
+		struct fbxatm_remote_dev_link *pkt;
+		struct fbxatm_dev *adev;
+		struct sk_buff *ack;
+
+		skb = skb_dequeue(&priv->dev_link_reqs);
+		if (!skb)
+			break;
+
+		if (!pskb_may_pull(skb, sizeof (*pkt))) {
+			printk(KERN_ERR PFX "bad rx dev link\n");
+			dev_kfree_skb(skb);
+			continue;
+		}
+
+		pkt = (struct fbxatm_remote_dev_link *)skb->data;
+
+		adev = priv->fbxatm_dev;
+		adev->link_rate_ds = ntohl(pkt->link_rate_ds);
+		adev->link_rate_us = ntohl(pkt->link_rate_us);
+		adev->link_cell_rate_ds = ntohl(pkt->link_cell_rate_ds);
+		adev->link_cell_rate_us = ntohl(pkt->link_cell_rate_us);
+
+		if (pkt->link)
+			fbxatm_dev_set_link_up(adev);
+		else
+			fbxatm_dev_set_link_down(adev);
+
+		/* send ack */
+		ack = fbxatm_remote_alloc_skb(priv->remote_ctx, 0);
+		if (!ack)
+			continue;
+		fbxatm_remote_sock_send_ack(priv->dev_link_sock, ack);
+
+	} while (1);
+}
+
+/*
+ * handle oam rx queue
+ */
+static void handle_oam_rx_queue(struct driver_remote *priv)
+{
+	struct fbxatm_oam_cell *cell;
+	struct sk_buff *skb;
+
+	do {
+		skb = skb_dequeue(&priv->dev_oam_reqs);
+		if (!skb)
+			break;
+
+		cell = kmalloc(sizeof (*cell), GFP_KERNEL);
+		if (!cell) {
+			dev_kfree_skb(skb);
+			continue;
+		}
+
+		if (!pskb_may_pull(skb, sizeof (cell->payload))) {
+			printk(KERN_ERR PFX "bad rx oam\n");
+			kfree(cell);
+			dev_kfree_skb(skb);
+			continue;
+		}
+
+		memcpy(&cell->payload, skb->data, sizeof (cell->payload));
+		dev_kfree_skb(skb);
+		fbxatm_netifrx_oam(priv->fbxatm_dev, cell);
+
+	} while (1);
+}
+
+/*
+ * free all and set to dead state
+ */
+static void remote_free(struct driver_remote *priv)
+{
+	struct driver_remote_vcc *pvcc;
+
+	if (priv->state == RSTATE_S_DEAD)
+		return;
+
+	priv->want_die = 0;
+
+	/* make sure remote_send device operation doesn't use sockets
+	 * any more */
+	spin_lock_bh(&priv->tx_lock);
+	priv->state = RSTATE_S_DEAD;
+	spin_unlock_bh(&priv->tx_lock);
+
+	/* same goes for open_vcc, close_vcc and send_oam ops,
+	 * RSTATE_S_DEAD will prevent function from being entered, and
+	 * any sleeper will be woken up */
+	wake_up(&priv->wq);
+
+	mutex_lock(&priv->mutex);
+
+	/* no vcc can be created, close all vcc sockets */
+	list_for_each_entry(pvcc, &priv->pvcc_list, next) {
+
+		if (pvcc->vcc_send_sock) {
+			fbxatm_remote_sock_close(pvcc->vcc_send_sock);
+			pvcc->vcc_send_sock = NULL;
+		}
+
+		if (pvcc->vcc_rx_sock) {
+			fbxatm_remote_sock_close(pvcc->vcc_rx_sock);
+			pvcc->vcc_rx_sock = NULL;
+		}
+
+		if (pvcc->vcc_qempty_sock) {
+			fbxatm_remote_sock_close(pvcc->vcc_qempty_sock);
+			pvcc->vcc_qempty_sock = NULL;
+		}
+	}
+	mutex_unlock(&priv->mutex);
+
+	/* no external callback from fbxatm can use sockets now */
+
+	/* close all sockets */
+	if (priv->dev_connect_sock) {
+		fbxatm_remote_sock_close(priv->dev_connect_sock);
+		priv->dev_connect_sock = NULL;
+	}
+
+	if (priv->keepalive_sock) {
+		fbxatm_remote_sock_close(priv->keepalive_sock);
+		priv->keepalive_sock = NULL;
+	}
+
+	if (priv->dev_link_sock) {
+		fbxatm_remote_sock_close(priv->dev_link_sock);
+		priv->dev_link_sock = NULL;
+	}
+
+	if (priv->dev_rx_oam_sock) {
+		fbxatm_remote_sock_close(priv->dev_rx_oam_sock);
+		priv->dev_rx_oam_sock = NULL;
+	}
+
+	if (priv->vcc_action_sock) {
+		fbxatm_remote_sock_close(priv->vcc_action_sock);
+		priv->vcc_action_sock = NULL;
+	}
+
+	if (priv->dev_send_oam_sock) {
+		fbxatm_remote_sock_close(priv->dev_send_oam_sock);
+		priv->dev_send_oam_sock = NULL;
+	}
+
+	if (priv->netdev) {
+		dev_put(priv->netdev);
+		priv->netdev = NULL;
+	}
+
+	if (priv->remote_ctx) {
+		fbxatm_remote_free_ctx(priv->remote_ctx);
+		priv->remote_ctx = NULL;
+	}
+
+	skb_queue_purge(&priv->connect_acks);
+	skb_queue_purge(&priv->dev_link_reqs);
+	skb_queue_purge(&priv->dev_oam_reqs);
+	skb_queue_purge(&priv->wq_acks);
+
+	if (priv->fbxatm_dev_registered) {
+		fbxatm_dev_set_link_down(priv->fbxatm_dev);
+		printk(KERN_WARNING "%s: marking dead\n",
+		       priv->fbxatm_dev->name);
+	}
+}
+
+/*
+ * remote context timeout on any socket
+ */
+static void remote_sock_timeout(void *data)
+{
+	set_dying((struct driver_remote *)data);
+}
+
+/*
+ * main workqueue to handle device fsm
+ */
+static void remote_fsm(struct work_struct *t)
+{
+	struct delayed_work *dwork;
+	struct driver_remote *priv;
+	struct net_device *netdev;
+	struct fbxatm_remote_sockaddr addr;
+
+	dwork = container_of(t, struct delayed_work, work);
+	priv = container_of(dwork, struct driver_remote, fsm_work);
+
+	if (priv->want_die) {
+		remote_free(priv);
+		/* let FSM restart if needed */
+	}
+
+	switch (priv->state) {
+	case RSTATE_S_WAIT_NETDEV:
+	{
+		struct fbxatm_remote_connect *pkt;
+		struct fbxatm_remote_ctx *ctx;
+		struct sk_buff *skb;
+		u32 session_id;
+
+		netdev = dev_get_by_name(&init_net, priv->pd->netdev_name);
+		if (!netdev) {
+			/* netdev notifier will reschedule */
+			return;
+		}
+		priv->netdev = netdev;
+
+		/* got netdev, open remote context */
+		get_random_bytes(&session_id, sizeof (session_id));
+		ctx = fbxatm_remote_alloc_ctx(netdev, priv->pd->remote_mac,
+					      session_id,
+					      remote_sock_timeout,
+					      priv);
+		if (!ctx) {
+			printk(KERN_ERR PFX "unable to allocate remote ctx\n");
+			remote_free(priv);
+			return;
+		}
+		priv->remote_ctx = ctx;
+
+		/* open rx sockets */
+		memset(&addr, 0, sizeof (addr));
+		addr.mtype = htonl(FBXATM_RMT_DEV_LINK);
+		addr.deliver = dev_link_deliver;
+		addr.priv = priv;
+		priv->dev_link_sock = fbxatm_remote_sock_bind(ctx, &addr, 1);
+		if (!priv->dev_link_sock) {
+			remote_free(priv);
+			return;
+		}
+
+		memset(&addr, 0, sizeof (addr));
+		addr.mtype = htonl(FBXATM_RMT_DEV_RX_OAM);
+		addr.deliver = dev_rx_oam_deliver;
+		addr.priv = priv;
+		priv->dev_rx_oam_sock = fbxatm_remote_sock_bind(ctx, &addr, 0);
+		if (!priv->dev_rx_oam_sock) {
+			remote_free(priv);
+			return;
+		}
+
+		/* create socket for initial connexion */
+		memset(&addr, 0, sizeof (addr));
+		addr.mtype = htonl(FBXATM_RMT_CONNECT);
+		addr.response = dev_connect_response;
+		addr.priv = priv;
+		addr.infinite_retry = 1;
+		priv->dev_connect_sock = fbxatm_remote_sock_connect(ctx,
+								    &addr, 1);
+		if (!priv->dev_connect_sock) {
+			remote_free(priv);
+			return;
+		}
+
+		/* send the connect packet */
+		skb = fbxatm_remote_alloc_skb(priv->remote_ctx,
+					      sizeof (*pkt));
+		if (!skb) {
+			remote_free(priv);
+			return;
+		}
+
+		pkt = (struct fbxatm_remote_connect *)
+			skb_put(skb, sizeof (*pkt));
+
+		memcpy(pkt->name, priv->pd->remote_name, sizeof (pkt->name));
+
+		fbxatm_remote_sock_getaddr(priv->dev_link_sock, &addr);
+		pkt->dev_link_port = addr.lport;
+
+		fbxatm_remote_sock_getaddr(priv->dev_rx_oam_sock, &addr);
+		pkt->dev_rx_oam_port = addr.lport;
+
+		if (fbxatm_remote_sock_send(priv->dev_connect_sock, skb)) {
+			dev_kfree_skb(skb);
+			remote_free(priv);
+			return;
+		}
+
+		/* wait for connect ack... */
+		priv->state = RSTATE_S_WAIT_REMOTE;
+		break;
+	}
+
+	case RSTATE_S_WAIT_REMOTE:
+	{
+		struct fbxatm_remote_connect_ack *pkt_ack;
+		struct fbxatm_remote_ctx *ctx;
+		struct fbxatm_dev *adev;
+		struct sk_buff *skb;
+		int ret;
+
+		skb = skb_dequeue(&priv->connect_acks);
+		if (!skb)
+			return;
+
+		if (!pskb_may_pull(skb, sizeof (*pkt_ack))) {
+			printk(KERN_ERR PFX "bad connect ack\n");
+			dev_kfree_skb(skb);
+			return;
+		}
+
+		pkt_ack = (struct fbxatm_remote_connect_ack *)skb->data;
+		ctx = priv->remote_ctx;
+
+		/* open sockets */
+		memset(&addr, 0, sizeof (addr));
+		addr.mtype = htonl(FBXATM_RMT_VCC_ACTION);
+		addr.response = common_response;
+		addr.dport = pkt_ack->vcc_action_port;
+		addr.priv = priv;
+		priv->vcc_action_sock = fbxatm_remote_sock_connect(ctx,
+								   &addr, 1);
+		if (!priv->vcc_action_sock) {
+			remote_free(priv);
+			return;
+		}
+
+		memset(&addr, 0, sizeof (addr));
+		addr.mtype = htonl(FBXATM_RMT_DEV_SEND_OAM);
+		addr.response = common_response;
+		addr.dport = pkt_ack->dev_send_oam_port;
+		addr.priv = priv;
+		priv->dev_send_oam_sock = fbxatm_remote_sock_connect(ctx,
+								     &addr, 1);
+		if (!priv->dev_send_oam_sock) {
+			remote_free(priv);
+			return;
+		}
+
+		memset(&addr, 0, sizeof (addr));
+		addr.mtype = htonl(FBXATM_RMT_KEEPALIVE);
+		addr.priv = priv;
+		addr.dport = pkt_ack->keepalive_port;
+		priv->keepalive_sock = fbxatm_remote_sock_connect(ctx,
+								  &addr, 1);
+		if (!priv->keepalive_sock) {
+			remote_free(priv);
+			return;
+		}
+
+		/* all set, register fbxatm device */
+		adev = priv->fbxatm_dev;
+		adev->max_vcc = ntohl(pkt_ack->max_vcc);
+		adev->vci_mask = ntohl(pkt_ack->vci_mask);
+		adev->vpi_mask = ntohl(pkt_ack->vpi_mask);
+		adev->max_priority = ntohl(pkt_ack->max_priority);
+		adev->max_rx_priority = ntohl(pkt_ack->max_rx_priority);
+		adev->link_rate_ds = ntohl(pkt_ack->link_rate_ds);
+		adev->link_rate_us = ntohl(pkt_ack->link_rate_us);
+		adev->link_cell_rate_ds = ntohl(pkt_ack->link_cell_rate_ds);
+		adev->link_cell_rate_us = ntohl(pkt_ack->link_cell_rate_us);
+		adev->tx_headroom = fbxatm_remote_headroom(ctx);
+
+		/* register atm device */
+		priv->state = RSTATE_S_ACTIVE;
+
+		if (!priv->fbxatm_dev_registered) {
+			ret = fbxatm_register_device(adev, "remote_fbxatm",
+						     &remote_fbxatm_ops);
+			if (ret) {
+				remote_free(priv);
+				return;
+			}
+		}
+
+		priv->fbxatm_dev_registered = 1;
+		printk(KERN_INFO "%s: connected to %s - %pM6/%s\n",
+		       adev->name, priv->pd->remote_name,
+		       priv->pd->remote_mac, priv->netdev->name);
+
+		if (pkt_ack->link)
+			fbxatm_dev_set_link_up(adev);
+		else
+			fbxatm_dev_set_link_down(adev);
+
+		schedule_delayed_work(&priv->fsm_work, HZ);
+		break;
+	}
+
+	case RSTATE_S_ACTIVE:
+	{
+		/* process link change event if any */
+		handle_dev_link_queue(priv);
+
+		/* process rx oam if any */
+		handle_oam_rx_queue(priv);
+
+		/* send keepalive */
+		if (!fbxatm_remote_sock_pending(priv->keepalive_sock)) {
+			struct sk_buff *skb;
+
+			skb = fbxatm_remote_alloc_skb(priv->remote_ctx, 0);
+			if (skb)
+				fbxatm_remote_sock_send(priv->keepalive_sock,
+							skb);
+		}
+
+		schedule_delayed_work(&priv->fsm_work, HZ);
+		break;
+	}
+
+	case RSTATE_S_DEAD:
+		/* wait until open vcc list is empty */
+		if (!list_empty(&priv->pvcc_list))
+			break;
+
+		priv->state = RSTATE_S_WAIT_NETDEV;
+		if (priv->fbxatm_dev_registered)
+			printk(KERN_INFO "%s: reconnecting\n",
+			       priv->fbxatm_dev->name);
+		schedule_delayed_work(&priv->fsm_work, HZ);
+		break;
+	}
+}
+
+/*
+ * netdevice notifier callback
+ */
+static int remote_device_event(struct notifier_block *this,
+			       unsigned long event, void *ptr)
+{
+	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+	struct driver_remote *priv;
+
+	spin_lock_bh(&remote_lock);
+
+	/* go through remote list to check if device matches one */
+	list_for_each_entry(priv, &remote_dev_list, next) {
+
+		switch (event) {
+		case NETDEV_REGISTER:
+			if (strcmp(dev->name, priv->pd->netdev_name))
+				continue;
+			break;
+
+		case NETDEV_UNREGISTER:
+			if (dev != priv->netdev)
+				continue;
+			priv->want_die = 1;
+			break;
+
+		default:
+			continue;
+		}
+		schedule_delayed_work(&priv->fsm_work, 0);
+	}
+
+	spin_unlock_bh(&remote_lock);
+
+	return 0;
+}
+
+static struct notifier_block remote_notifier = {
+	.notifier_call = remote_device_event,
+};
+
+/*
+ * platform data probe callback
+ */
+static int remote_probe(struct platform_device *pdev)
+{
+	struct fbxatm_remote_pdata *pd;
+	struct driver_remote *priv;
+	struct fbxatm_dev *adev;
+
+	pd = pdev->dev.platform_data;
+	if (!pd || !pd->netdev_name[0])
+		return -EINVAL;
+
+	/* allocate fbxatm device */
+	adev = fbxatm_alloc_device(sizeof (*priv));
+	if (!adev)
+		return -ENOMEM;
+
+	priv = fbxatm_dev_priv(adev);
+
+	priv->fbxatm_dev = adev;
+	INIT_LIST_HEAD(&priv->pvcc_list);
+	spin_lock_init(&priv->tx_lock);
+	mutex_init(&priv->mutex);
+
+	priv->state = RSTATE_S_WAIT_NETDEV;
+	INIT_DELAYED_WORK(&priv->fsm_work, remote_fsm);
+
+	skb_queue_head_init(&priv->connect_acks);
+	skb_queue_head_init(&priv->dev_link_reqs);
+	skb_queue_head_init(&priv->dev_oam_reqs);
+	init_waitqueue_head(&priv->wq);
+	skb_queue_head_init(&priv->wq_acks);
+	priv->pd = pd;
+
+	spin_lock_bh(&remote_lock);
+	list_add_tail(&priv->next, &remote_dev_list);
+	spin_unlock_bh(&remote_lock);
+
+	platform_set_drvdata(pdev, priv);
+
+	printk(KERN_INFO PFX "connecting to %s - %pM6/%s\n",
+	       priv->pd->remote_name,
+	       priv->pd->remote_mac,
+	       priv->pd->netdev_name);
+
+	/* kick fsm  */
+	schedule_delayed_work(&priv->fsm_work, 0);
+	return 0;
+}
+
+static int remote_remove(struct platform_device *pdev)
+{
+	struct driver_remote *priv;
+	struct fbxatm_dev *adev;
+
+	priv = platform_get_drvdata(pdev);
+	adev = priv->fbxatm_dev;
+
+	/* remove from global list so network notifier can't find us */
+	spin_lock_bh(&remote_lock);
+	list_del(&priv->next);
+	spin_unlock_bh(&remote_lock);
+
+	/* cancel any pending fsm */
+	cancel_delayed_work_sync(&priv->fsm_work);
+
+	/* force dead state */
+	remote_free(priv);
+
+	if (priv->fbxatm_dev_registered)
+		fbxatm_unregister_device(adev);
+	fbxatm_free_device(adev);
+	return 0;
+}
+
+struct platform_driver fbxatm_remote_driver = {
+	.probe	= remote_probe,
+	.remove	= remote_remove,
+	.driver	= {
+		.name	= "fbxatm_remote",
+		.owner  = THIS_MODULE,
+	},
+};
+
+static int __init fbxatm_remote_driver_init(void)
+{
+	int ret;
+
+	INIT_LIST_HEAD(&remote_dev_list);
+	ret = fbxatm_remote_init();
+	if (ret)
+		goto fail;
+	ret = register_netdevice_notifier(&remote_notifier);
+	if (ret)
+		goto fail_remote;
+	ret = platform_driver_register(&fbxatm_remote_driver);
+	if (ret)
+		goto fail_notifier;
+	return 0;
+
+fail_notifier:
+	unregister_netdevice_notifier(&remote_notifier);
+fail_remote:
+	fbxatm_remote_exit();
+fail:
+	return ret;
+}
+
+static void __exit fbxatm_remote_driver_exit(void)
+{
+	fbxatm_remote_exit();
+	unregister_netdevice_notifier(&remote_notifier);
+	platform_driver_unregister(&fbxatm_remote_driver);
+}
+
+module_init(fbxatm_remote_driver_init);
+module_exit(fbxatm_remote_driver_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_VERSION("1.0");
+MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
diff -Nruw linux-4.2.6-fbx/net/fbxatm./fbxatm_remote_driver.h linux-4.2.6-fbx/net/fbxatm/fbxatm_remote_driver.h
--- linux-4.2.6-fbx/net/fbxatm./fbxatm_remote_driver.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxatm/fbxatm_remote_driver.h	2015-11-02 18:59:21.464547475 +0100
@@ -0,0 +1,79 @@
+#ifndef FBXATM_REMOTE_DRIVER_H_
+#define FBXATM_REMOTE_DRIVER_H_
+
+#include <linux/spinlock.h>
+#include <linux/workqueue.h>
+#include <linux/fbxatm.h>
+#include <linux/fbxatm_dev.h>
+#include <linux/fbxatm_remote.h>
+
+enum remote_state {
+	RSTATE_S_WAIT_NETDEV = 0,
+	RSTATE_S_WAIT_REMOTE,
+	RSTATE_S_ACTIVE,
+	RSTATE_S_DEAD,
+};
+
+struct driver_remote;
+
+struct driver_remote_vcc {
+
+	struct fbxatm_vcc		*vcc;
+	struct driver_remote		*priv;
+
+	unsigned int			remote_id;
+
+	int				tx_pending;
+	int				tx_got_qempty;
+
+	/* output */
+	struct fbxatm_remote_sock	*vcc_send_sock;
+
+	/* input */
+	struct fbxatm_remote_sock	*vcc_rx_sock;
+	struct fbxatm_remote_sock	*vcc_qempty_sock;
+
+	struct list_head		next;
+};
+
+struct driver_remote {
+	struct fbxatm_dev		*fbxatm_dev;
+	int				fbxatm_dev_registered;
+
+	struct list_head		pvcc_list;
+
+	spinlock_t			tx_lock;
+	struct mutex			mutex;
+
+	struct fbxatm_remote_ctx	*remote_ctx;
+	struct net_device		*netdev;
+
+	enum remote_state		state;
+	struct delayed_work		fsm_work;
+	int				want_die;
+
+	/* output */
+	struct fbxatm_remote_sock	*dev_connect_sock;
+	struct sk_buff_head		connect_acks;
+
+	struct fbxatm_remote_sock	*keepalive_sock;
+
+	/* input */
+	struct fbxatm_remote_sock	*dev_link_sock;
+	struct sk_buff_head		dev_link_reqs;
+
+	struct fbxatm_remote_sock	*dev_rx_oam_sock;
+	struct sk_buff_head		dev_oam_reqs;
+
+	/* used to wait for send_oam & vcc_action */
+	struct fbxatm_remote_sock	*vcc_action_sock;
+	struct fbxatm_remote_sock	*dev_send_oam_sock;
+	wait_queue_head_t		wq;
+	int				wq_res;
+	struct sk_buff_head		wq_acks;
+
+	struct fbxatm_remote_pdata	*pd;
+	struct list_head		next;
+};
+
+#endif /* ! FBXATM_REMOTE_DRIVER_H_ */
diff -Nruw linux-4.2.6-fbx/net/fbxatm./fbxatm_sysfs.c linux-4.2.6-fbx/net/fbxatm/fbxatm_sysfs.c
--- linux-4.2.6-fbx/net/fbxatm./fbxatm_sysfs.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxatm/fbxatm_sysfs.c	2015-11-02 18:59:21.464547475 +0100
@@ -0,0 +1,154 @@
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/kobject.h>
+#include <linux/stat.h>
+#include <linux/fbxatm_dev.h>
+#include "fbxatm_priv.h"
+
+#define to_fbxatm_dev(cldev) container_of(cldev, struct fbxatm_dev, dev)
+
+static ssize_t show_ifindex(struct device *dev,
+			  struct device_attribute *attr, char *buf)
+{
+	struct fbxatm_dev *adev = to_fbxatm_dev(dev);
+	return sprintf(buf, "%d\n", adev->ifindex);
+}
+
+static ssize_t show_link_state(struct device *dev,
+			       struct device_attribute *attr, char *buf)
+{
+	struct fbxatm_dev *adev = to_fbxatm_dev(dev);
+	return sprintf(buf, "%d\n",
+		       test_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags) ?
+		       1 : 0);
+}
+
+static ssize_t show_link_rate_us(struct device *dev,
+				 struct device_attribute *attr, char *buf)
+{
+	struct fbxatm_dev *adev = to_fbxatm_dev(dev);
+	return sprintf(buf, "%d\n", adev->link_rate_us);
+}
+
+static ssize_t show_link_rate_ds(struct device *dev,
+				 struct device_attribute *attr, char *buf)
+{
+	struct fbxatm_dev *adev = to_fbxatm_dev(dev);
+	return sprintf(buf, "%d\n", adev->link_rate_ds);
+}
+
+static ssize_t show_max_priority(struct device *dev,
+				 struct device_attribute *attr, char *buf)
+{
+	struct fbxatm_dev *adev = to_fbxatm_dev(dev);
+	return sprintf(buf, "%d\n", adev->max_priority);
+}
+
+static ssize_t show_max_rx_priority(struct device *dev,
+				    struct device_attribute *attr, char *buf)
+{
+	struct fbxatm_dev *adev = to_fbxatm_dev(dev);
+	return sprintf(buf, "%d\n", adev->max_rx_priority);
+}
+
+static DEVICE_ATTR(ifindex, S_IRUGO, show_ifindex, NULL);
+static DEVICE_ATTR(link_state, S_IRUGO, show_link_state, NULL);
+static DEVICE_ATTR(link_rate_us, S_IRUGO, show_link_rate_us, NULL);
+static DEVICE_ATTR(link_rate_ds, S_IRUGO, show_link_rate_ds, NULL);
+static DEVICE_ATTR(max_priority, S_IRUGO, show_max_priority, NULL);
+static DEVICE_ATTR(max_rx_priority, S_IRUGO, show_max_rx_priority, NULL);
+
+static struct device_attribute *fbxatm_attrs[] = {
+	&dev_attr_ifindex,
+	&dev_attr_link_state,
+	&dev_attr_link_rate_us,
+	&dev_attr_link_rate_ds,
+	&dev_attr_max_priority,
+	&dev_attr_max_rx_priority,
+};
+
+static int fbxatm_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+	struct fbxatm_dev *adev;
+
+	if (!dev)
+		return -ENODEV;
+
+	adev = to_fbxatm_dev(dev);
+	if (!adev)
+		return -ENODEV;
+
+	if (add_uevent_var(env, "NAME=%s", adev->name))
+		return -ENOMEM;
+
+	if (add_uevent_var(env, "IFINDEX=%u", adev->ifindex))
+		return -ENOMEM;
+
+	if (add_uevent_var(env, "LINK=%u",
+			   test_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags) ?
+			   1 : 0))
+		return -ENOMEM;
+
+	return 0;
+}
+
+static void fbxatm_release(struct device *dev)
+{
+	struct fbxatm_dev *adev = to_fbxatm_dev(dev);
+	__fbxatm_free_device(adev);
+}
+
+static struct class fbxatm_class = {
+	.name		= "fbxatm",
+	.dev_release	= fbxatm_release,
+	.dev_uevent	= fbxatm_uevent,
+};
+
+void fbxatm_dev_change_sysfs(struct fbxatm_dev *adev)
+{
+	struct device *dev = &adev->dev;
+
+	kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, NULL);
+}
+
+int fbxatm_register_dev_sysfs(struct fbxatm_dev *adev)
+{
+	struct device *dev = &adev->dev;
+	int i, j, ret;
+
+	dev->class = &fbxatm_class;
+	dev_set_name(dev, "%s", adev->name);
+	ret = device_register(dev);
+	if (ret < 0)
+		return ret;
+
+	for (i = 0; i < ARRAY_SIZE(fbxatm_attrs); i++) {
+		ret = device_create_file(dev, fbxatm_attrs[i]);
+		if (ret)
+			goto err;
+	}
+	return 0;
+
+err:
+	for (j = 0; j < i; j++)
+		device_remove_file(dev, fbxatm_attrs[j]);
+	device_del(dev);
+	return ret;
+}
+
+void fbxatm_unregister_dev_sysfs(struct fbxatm_dev *adev)
+{
+	struct device *dev = &adev->dev;
+	device_del(dev);
+}
+
+int __init fbxatm_sysfs_init(void)
+{
+	return class_register(&fbxatm_class);
+}
+
+void fbxatm_sysfs_exit(void)
+{
+	class_unregister(&fbxatm_class);
+}
diff -Nruw linux-4.2.6-fbx/net/fbxatm./Kconfig linux-4.2.6-fbx/net/fbxatm/Kconfig
--- linux-4.2.6-fbx/net/fbxatm./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxatm/Kconfig	2015-11-02 18:59:21.464547475 +0100
@@ -0,0 +1,28 @@
+menuconfig FBXATM
+	tristate "Freebox Asynchronous Transfer Mode (ATM)"
+
+if FBXATM
+
+config FBXATM_REMOTE
+	bool
+
+choice
+	prompt "mode"
+	default FBXATM_STACK
+
+config FBXATM_STACK
+	bool "standard"
+
+config FBXATM_REMOTE_STUB
+	bool "remote stub"
+	select FBXATM_REMOTE
+
+endchoice
+
+config FBXATM_REMOTE_DRIVER
+	tristate "remote fbxatm driver"
+	depends on FBXATM_STACK
+	select FBXATM_REMOTE
+	default n
+
+endif
diff -Nruw linux-4.2.6-fbx/net/fbxatm./Makefile linux-4.2.6-fbx/net/fbxatm/Makefile
--- linux-4.2.6-fbx/net/fbxatm./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxatm/Makefile	2015-11-02 18:59:21.464547475 +0100
@@ -0,0 +1,18 @@
+obj-$(CONFIG_FBXATM) += fbxatm.o
+obj-$(CONFIG_FBXATM_REMOTE) += fbxatm_remote.o
+
+fbxatm-y := fbxatm_procfs.o fbxatm_sysfs.o
+
+ifeq ($(CONFIG_FBXATM_STACK),y)
+fbxatm-y += 	fbxatm_core.o	\
+		fbxatm_2684.o	\
+		fbxatm_dev.o	\
+		crc10.o
+fbxatm-$(CONFIG_PPP) += fbxatm_pppoa.o
+endif
+
+ifeq ($(CONFIG_FBXATM_REMOTE_STUB),y)
+fbxatm-y += fbxatm_remote_stub.o
+endif
+
+obj-$(CONFIG_FBXATM_REMOTE_DRIVER) += fbxatm_remote_driver.o
diff -Nruw linux-4.2.6-fbx/net/fbxbridge./fbxbridge_dev.c linux-4.2.6-fbx/net/fbxbridge/fbxbridge_dev.c
--- linux-4.2.6-fbx/net/fbxbridge./fbxbridge_dev.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxbridge/fbxbridge_dev.c	2015-11-18 19:11:39.106579329 +0100
@@ -0,0 +1,855 @@
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/sockios.h>
+
+#include <linux/notifier.h>
+#include <linux/if_arp.h>
+#include <linux/inetdevice.h>
+#include <asm/uaccess.h>
+
+#include <linux/fbxbridge.h>
+#include <linux/if_vlan.h>
+#include <net/neighbour.h>
+#include <net/netevent.h>
+
+struct fbxbridge *fbxbridge_list = NULL;
+extern struct sk_buff *(*fbxbridge_handle_frame_hook)(struct fbxbridge *br,
+						      struct sk_buff *skb);
+extern void fbxbridge_set(int (*hook)(struct net *net,
+				      unsigned int, void __user *));
+
+/*
+ * bridge network function
+ */
+static int bridge_net_open(struct net_device *dev)
+{
+	return 0;
+}
+
+static int bridge_net_stop(struct net_device *dev)
+{
+	return 0;
+}
+
+
+#define	DEFAULT_RENEWAL_TIME	60
+#define	DEFAULT_REBIND_TIME	300
+#define	DEFAULT_LEASE_TIME	600
+
+
+static int bridge_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct fbxbridge *br = (struct fbxbridge *)netdev_priv(dev);
+
+	br->dev->stats.tx_packets++;
+	br->dev->stats.tx_bytes += skb->len;
+
+	if (handle_local_output_frame(br, skb))
+		br->dev->stats.tx_dropped++;
+
+	return 0;
+}
+
+static const struct net_device_ops fbxbridge_net_ops = {
+	.ndo_open		= bridge_net_open,
+	.ndo_stop		= bridge_net_stop,
+	.ndo_start_xmit		= bridge_net_start_xmit,
+};
+
+static void bridge_net_setup(struct net_device *dev)
+{
+	dev->netdev_ops = &fbxbridge_net_ops;
+	dev->flags = IFF_NOARP;
+	dev->tx_queue_len = 0;	/* we use bridge devices queues */
+	dev->type = ARPHRD_PPP;
+	dev->mtu = 1500;
+	dev->features = 0;
+	dev->hard_header_len = 16;
+}
+
+/*
+ * helper to access the bridge list
+ */
+static void add_to_bridge_list(struct fbxbridge *br)
+{
+	br->next = fbxbridge_list;
+	fbxbridge_list = br;
+}
+
+static void remove_from_bridge_list(struct fbxbridge *br)
+{
+	struct fbxbridge *p, *pprev;
+
+	pprev = p = fbxbridge_list;
+	while (p) {
+		if (p == br)
+			break;
+		pprev = p;
+	}
+
+	if (p) {
+		if (p == fbxbridge_list)
+			fbxbridge_list = fbxbridge_list->next;
+		else
+			pprev->next = br->next;
+	}
+}
+
+static struct fbxbridge *get_bridge_by_name(const char *name)
+{
+	struct fbxbridge *p;
+
+	p = fbxbridge_list;
+	while (p) {
+		if (!strcmp(name, p->name))
+			return p;
+		p = p->next;
+	}
+
+	return NULL;
+}
+
+static struct fbxbridge *alloc_bridge(const char *name)
+{
+	struct net_device *dev;
+	struct fbxbridge *br;
+
+	dev = alloc_netdev(sizeof(*br), name, NET_NAME_UNKNOWN,
+			   bridge_net_setup);
+	if (!dev)
+		return NULL;
+	br = netdev_priv(dev);
+
+	memset(br, 0, sizeof (*br));
+	strncpy(br->name, name, IFNAMSIZ);
+	br->refcount = 1;
+	br->last_arp_send = jiffies;
+	br->dev = dev;
+
+	br->dhcpd_renew_time = DEFAULT_RENEWAL_TIME;
+	br->dhcpd_rebind_time = DEFAULT_REBIND_TIME;
+	br->dhcpd_lease_time = DEFAULT_LEASE_TIME;
+
+	fbxbridge_fp_init(br);
+
+	return br;
+}
+
+static struct net_device *get_vlan_master(struct net_device *dev,
+					  u16 *id, u16 *id2)
+{
+	struct net_device *sub_dev, *sub2_dev;
+
+	if (!is_vlan_dev(dev)) {
+		*id = 0;
+		*id2 = 0;
+		return dev;
+
+	}
+
+	sub_dev = vlan_dev_upper_dev(dev);
+	if (!is_vlan_dev(sub_dev)) {
+		*id = vlan_dev_vlan_id(dev);
+		*id2 = 0;
+		return sub_dev;
+	}
+
+	/* subdevice is a vlan too */
+	sub2_dev = vlan_dev_upper_dev(sub_dev);
+	*id = vlan_dev_vlan_id(sub_dev);
+	*id2 = vlan_dev_vlan_id(dev);
+
+	return sub2_dev;
+}
+
+static void
+__grab_bridge_device(struct fbxbridge *br,
+		     struct net_device *dev,
+		     bool is_wan)
+{
+	struct fbxbridge_port *bport;
+	u16 id, id2;
+
+	bport = &br->ports[is_wan ? FBXBR_PORT_WAN : FBXBR_PORT_LAN];
+	if (bport->dev)
+		return;
+
+	dev_hold(dev);
+	dev->fbx_bridge_port = br;
+	bport->dev = dev;
+	bport->master_dev = get_vlan_master(dev, &id, &id2);
+	bport->master_dev->fbx_bridge_maybe_port++;
+	bport->vlan1 = id;
+	bport->vlan2 = id2;
+
+	printk(KERN_INFO "%s: %s device %s grabbed - master %s\n",
+	       br->name, is_wan ? "wan" : "lan", dev->name,
+	       bport->master_dev->name);
+
+	__fbxbridge_fp_check(br);
+}
+
+static void
+__ungrab_bridge_device(struct fbxbridge *br, bool is_wan)
+{
+	struct net_device *dev;
+	struct fbxbridge_port *bport;
+
+	bport = &br->ports[is_wan ? FBXBR_PORT_WAN : FBXBR_PORT_LAN];
+	if (!bport->dev)
+		return;
+
+	dev = bport->dev;
+	bport->dev = NULL;
+	bport->master_dev->fbx_bridge_maybe_port--;
+	bport->master_dev = NULL;
+
+	if (!is_wan)
+		br->have_hw_addr = 0;
+
+	dev->fbx_bridge_port = NULL;
+	dev_put(dev);
+
+	printk(KERN_INFO "%s: %s device %s released\n",
+	       br->name, is_wan ? "wan" : "lan", dev->name);
+
+	__fbxbridge_fp_check(br);
+}
+
+static int release_bridge(struct fbxbridge *br)
+{
+	if (--br->refcount > 0)
+		return 0;
+
+	/*
+	 * allow removal of bridge even if there are devices present
+	 * in it.
+	 */
+	if (br->ports[FBXBR_PORT_WAN].dev)
+		__ungrab_bridge_device(br, true);
+	if (br->ports[FBXBR_PORT_LAN].dev)
+		__ungrab_bridge_device(br, false);
+
+	printk(KERN_INFO FBXBRIDGE_PFX "unregistering bridge %s\n", br->name);
+
+	br->dev->fbx_bridge = NULL;
+	wmb();
+	unregister_netdev(br->dev);
+	remove_from_bridge_list(br);
+	free_netdev(br->dev);
+
+	module_put(THIS_MODULE);
+
+	return 0;
+}
+
+static int remove_bridge(const char *name)
+{
+	struct fbxbridge *br;
+
+	if (!(br = get_bridge_by_name(name)))
+		return -ENODEV;
+
+	return release_bridge(br);
+}
+
+static int create_bridge(const char *name)
+{
+	struct fbxbridge *br;
+
+	if (get_bridge_by_name(name))
+		return -EEXIST;
+
+	/* allocate this bridge */
+	if (!(br = alloc_bridge(name)))
+		return -ENOMEM;
+
+	if (register_netdev(br->dev)) {
+		free_netdev(br->dev);
+		return -ENODEV;
+	}
+
+	br->dev->fbx_bridge = br;
+	add_to_bridge_list(br);
+
+	/* can not fail, the ioctl hook is protected by a mutex */
+	try_module_get(THIS_MODULE);
+
+	printk(KERN_INFO FBXBRIDGE_PFX "registered bridge %s\n", name);
+
+	return 0;
+}
+
+static int set_bridge_info(const char *name, unsigned int flags,
+			   unsigned int dns1, unsigned int dns2,
+			   unsigned long *ip_aliases,
+			   unsigned long dhcpd_renew_time,
+			   unsigned long dhcpd_rebind_time,
+			   unsigned long dhcpd_lease_time,
+			   unsigned int inputmark)
+{
+	struct fbxbridge *br;
+
+	if (!(br = get_bridge_by_name(name)))
+		return -ENODEV;
+
+	local_bh_disable();
+	br->flags = flags;
+	br->dns1_ipaddr = dns1;
+	br->dns2_ipaddr = dns2;
+	memcpy(br->ip_aliases, ip_aliases, sizeof (br->ip_aliases));
+	br->dhcpd_renew_time = dhcpd_renew_time;
+	br->dhcpd_rebind_time = dhcpd_rebind_time;
+	br->dhcpd_lease_time = dhcpd_lease_time;
+	br->inputmark = inputmark;
+	local_bh_enable();
+
+	return 0;
+}
+
+
+
+static int find_bridge_interface(const char *dev_name, struct fbxbridge **br)
+{
+	struct fbxbridge *p;
+
+	p = fbxbridge_list;
+	while (p) {
+
+		if (strcmp(p->name, dev_name)) {
+			p = p->next;
+			continue;
+		}
+
+		if (br)
+			*br = p;
+		return 1;
+	}
+
+	return 0;
+}
+
+static int find_bridge_device(const char *dev_name, struct fbxbridge **br,
+			      bool *is_wan)
+{
+	struct fbxbridge *p;
+
+	p = fbxbridge_list;
+	while (p) {
+		if (!strcmp(p->lan_dev_name, dev_name)) {
+			if (br)
+				*br = p;
+			if (is_wan)
+				*is_wan = 0;
+			return 1;
+		}
+		if (!strcmp(p->wan_dev_name, dev_name)) {
+			if (br)
+				*br = p;
+			if (is_wan)
+				*is_wan = 1;
+			return 1;
+		}
+		p = p->next;
+	}
+
+	return 0;
+}
+
+static inline __be32 gen_wan_gw(__be32 be_ipaddr, __be32 be_netmask)
+{
+	u32 ipaddr, netmask;
+	u32 gw, mask;
+
+	ipaddr = __be32_to_cpu(be_ipaddr);
+	netmask = __be32_to_cpu(be_netmask);
+
+	gw = ipaddr & netmask;
+	mask = ~netmask;
+
+	gw |= (mask - 1);
+	if (gw == ipaddr) {
+		/*
+		 * that's unfortunate, but when in PPP mode, the
+		 * computed gateway can be the public ip address of
+		 * the customer. nevermind, pick the .253 address,
+		 * gateway ip is just a polite jocke in PPP anyway.
+		 */
+		gw &= netmask;
+		gw |= mask - 2;
+	}
+	return __cpu_to_be32(gw);
+}
+
+/*
+ * assume it is running with bh disabled
+ */
+static void __fetch_wan_addr(struct fbxbridge *br, struct in_ifaddr *ifa)
+{
+	struct net_device *dev;
+	int changed;
+
+	if (ifa) {
+		changed = 0;
+		dev = ifa->ifa_dev->dev;
+
+		if (br->wan_ipaddr != ifa->ifa_local ||
+		    br->wan_netmask != ifa->ifa_mask)
+			changed = 1;
+
+		br->wan_ipaddr = ifa->ifa_local;
+		br->wan_netmask = ifa->ifa_mask;
+		if (br->wan_netmask != 0xffffffff) {
+			br->wan_gw = gen_wan_gw(br->wan_ipaddr, br->wan_netmask);
+			br->lan_netmask = br->wan_netmask;
+		} else {
+			u32 gw;
+
+			gw = ntohl(br->wan_ipaddr) & 0xffffff00;
+			if ((gw | 0xfe) == ntohl(br->wan_ipaddr))
+				gw |= 0xfd;
+			else
+				gw |= 0xfe;
+
+			br->wan_gw = htonl(gw);
+			br->lan_netmask = htonl(0xffffff00);
+		}
+
+		if (changed) {
+			printk(KERN_NOTICE "%s: wan inet device %s address "
+			       "changed to [%pI4]\n", br->name,
+ 			       dev->name, &br->wan_ipaddr);
+			printk("%s: %s: wan netmask: %pI4\n",
+			       br->name, dev->name, &br->wan_netmask);
+			printk("%s: %s: wan gw: %pI4\n",
+			       br->name, dev->name, &br->wan_gw);
+			__fbxbridge_fp_check(br);
+		}
+	}
+}
+
+void __fbxbridge_keep_hw_addr(struct fbxbridge *br, unsigned char *hwaddr)
+{
+	if (br->have_hw_addr && !memcmp(br->lan_hwaddr, hwaddr, ETH_ALEN))
+		return;
+
+	if (br->have_hw_addr)
+		__fbxbridge_fp_flush(br);
+
+	memcpy(br->lan_hwaddr, hwaddr, ETH_ALEN);
+	br->have_hw_addr = 1;
+	printk(KERN_NOTICE "%s: new lan hw address is now %pM\n",
+	       br->name, hwaddr);
+	__fbxbridge_fp_check(br);
+}
+
+static int add_bridge_device(const char *bridge_name, const char *dev_name,
+			     bool is_wan)
+{
+	struct net_device *dev;
+	struct fbxbridge *br;
+
+	/* check no bridge already use this device */
+	if (find_bridge_device(dev_name, NULL, NULL))
+		return -EEXIST;
+
+	if (!(br = get_bridge_by_name(bridge_name)))
+		return -ENODEV;
+
+	/* any room for a new device */
+	if (is_wan) {
+		if (br->wan_dev_name[0])
+			return -EBUSY;
+
+		strcpy(br->wan_dev_name, dev_name);
+	} else {
+		if (br->lan_dev_name[0])
+			return -EBUSY;
+
+		strcpy(br->lan_dev_name, dev_name);
+	}
+
+	/* try to resolve device */
+	if (!(dev = dev_get_by_name(&init_net, dev_name))) {
+		/* device does  not exists  yet, will wait  for device
+		 * events */
+		return 0;
+	}
+
+	local_bh_disable();
+	__grab_bridge_device(br, dev, is_wan);
+	if (is_wan) {
+		struct in_device *in_dev;
+
+		rcu_read_lock();
+
+		in_dev = __in_dev_get_rcu(dev);
+		if (in_dev)
+			__fetch_wan_addr(br, in_dev->ifa_list);
+
+		rcu_read_unlock();
+	}
+	local_bh_enable();
+	dev_put(dev);
+
+	return 0;
+}
+
+static int remove_bridge_device(const char *bridge_name, const char *dev_name)
+{
+	struct fbxbridge *br;
+	bool is_wan;
+
+	/* check bridge use this device */
+	if (!find_bridge_device(dev_name, &br, &is_wan))
+		return -ENODEV;
+
+	/* is this the one ? */
+	if (strcmp(bridge_name, br->name))
+		return -ENODEV;
+
+	local_bh_disable();
+	__ungrab_bridge_device(br, is_wan);
+	if (is_wan)
+		br->wan_dev_name[0] = 0;
+	else
+		br->lan_dev_name[0] = 0;
+	local_bh_enable();
+
+	return 0;
+}
+
+
+
+static int bridge_device_event(struct notifier_block *this,
+			       unsigned long event, void *ptr)
+{
+	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+	struct fbxbridge *br;
+	bool is_wan;
+
+	/* only interested by device that belong to a bridge */
+	if (!find_bridge_device(dev->name, &br, &is_wan))
+		return NOTIFY_DONE;
+
+	local_bh_disable();
+
+	switch (event) {
+	case NETDEV_UP:
+		__grab_bridge_device(br, dev, is_wan);
+		break;
+
+	case NETDEV_GOING_DOWN:
+	case NETDEV_DOWN:
+	case NETDEV_UNREGISTER:
+		__ungrab_bridge_device(br, is_wan);
+		break;
+
+	default:
+		break;
+	};
+
+	local_bh_enable();
+
+	return NOTIFY_DONE;
+}
+
+/*
+ * handle inet configuration event on bridge interface (fbxbr%d)
+ */
+static void bridge_inet_interface_event(struct fbxbridge *br,
+					unsigned long event,
+					struct in_ifaddr *ifa)
+{
+	int changed = 0;
+
+	switch (event) {
+	case NETDEV_UP:
+		local_bh_disable();
+		if (ifa->ifa_address && ifa->ifa_local != ifa->ifa_address) {
+			br->br_ipaddr = ifa->ifa_local;
+			br->br_remote_ipaddr = ifa->ifa_address;
+			changed = 1;
+			__fbxbridge_fp_check(br);
+		}
+		local_bh_enable();
+		break;
+
+	case NETDEV_DOWN:
+		local_bh_disable();
+		if (br->br_ipaddr) {
+			br->br_ipaddr = br->br_remote_ipaddr = 0;
+			changed = 1;
+			__fbxbridge_fp_check(br);
+		}
+		local_bh_enable();
+		break;
+
+	default:
+		return;
+	}
+
+	if (!changed)
+		return;
+
+	if (br->br_ipaddr) {
+		printk(KERN_INFO "%s: bridge interface configured: "
+		       "[%pI4 -> %pI4]\n", br->name,
+		       &br->br_ipaddr, &br->br_remote_ipaddr);
+	} else {
+		printk(KERN_INFO "%s: bridge interface unconfigured\n",
+		       br->name);
+	}
+}
+
+/*
+ * handle inet configuration event on bridge wan device
+ */
+static void bridge_inet_device_event(struct fbxbridge *br, unsigned long event,
+				     struct in_ifaddr *ifa)
+{
+	switch (event) {
+	case NETDEV_UP:
+		local_bh_disable();
+		__fetch_wan_addr(br, ifa);
+		local_bh_enable();
+		break;
+
+	case NETDEV_DOWN:
+		/* we never  clear wan address, so we  can continue to
+		 * use the bridge on lan side even if wan is down */
+		break;
+
+	default:
+		break;
+	}
+}
+
+
+static int bridge_inet_event(struct notifier_block *this,
+			     unsigned long event, void *ptr)
+{
+	struct in_ifaddr *ifa = (struct in_ifaddr *)ptr;
+	struct net_device *dev = ifa->ifa_dev->dev;
+	struct fbxbridge *br;
+
+	/* is it a bridge or a wan device that belong to a bridge ? */
+	if (find_bridge_interface(dev->name, &br))
+		bridge_inet_interface_event(br, event, ifa);
+	else {
+		bool is_wan;
+
+		if (find_bridge_device(dev->name, &br, &is_wan) && is_wan)
+			bridge_inet_device_event(br, event, ifa);
+	}
+
+	return NOTIFY_DONE;
+}
+
+
+static struct notifier_block fbxbridge_notifier = {
+	notifier_call: bridge_device_event,
+};
+
+static struct notifier_block fbxbridge_inet_notifier = {
+	notifier_call: bridge_inet_event,
+};
+
+
+/* ioctl handling */
+static int fbxbridge_ioctl(struct net *net, unsigned int ign, void __user *arg)
+{
+	struct fbxbridge_ioctl_req	req;
+	struct fbxbridge_ioctl_chg	chg;
+	struct fbxbridge_ioctl_dev_chg	dev_chg;
+	struct fbxbridge_ioctl_params	params;
+	struct fbxbridge		*br;
+	int				ret;
+
+	/* fetch ioctl request */
+	if (access_ok(VERIFY_READ, arg, sizeof(req)) != 1)
+		return -EFAULT;
+
+	if (copy_from_user(&req, arg, sizeof (req)))
+		return -EFAULT;
+
+	switch (req.cmd) {
+	case E_CMD_BR_CHG:
+		if (access_ok(VERIFY_READ, (void *)req.arg, sizeof(chg)) != 1)
+			return -EFAULT;
+
+		if (copy_from_user(&chg, (void *)req.arg, sizeof (chg)))
+			return -EFAULT;
+
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
+
+		if (!chg.action)
+			return create_bridge(chg.brname);
+		return remove_bridge(chg.brname);
+
+	case E_CMD_BR_DEV_CHG:
+		if (access_ok(VERIFY_READ, (void *)req.arg,
+			      sizeof(dev_chg)) != 1)
+			return -EFAULT;
+
+		if (copy_from_user(&dev_chg, (void *)req.arg,
+				   sizeof (dev_chg)))
+			return -EFAULT;
+
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
+
+		if (!dev_chg.action)
+			return add_bridge_device(dev_chg.brname,
+						 dev_chg.devname,
+						 dev_chg.wan ? 1 : 0);
+
+		return remove_bridge_device(dev_chg.brname, dev_chg.devname);
+
+	case E_CMD_BR_PARAMS:
+		if (access_ok(VERIFY_READ, (void *)req.arg,
+			      sizeof(params)) != 1)
+			return -EFAULT;
+
+		if (copy_from_user(&params, (void *)req.arg, sizeof (params)))
+			return -EFAULT;
+
+		if (!params.action) {
+			/* this is a get */
+			if (!(br = get_bridge_by_name(params.brname)))
+				return -ENODEV;
+
+			local_bh_disable();
+
+			params.flags = br->flags;
+			params.dns1_addr = br->dns1_ipaddr;
+			params.dns2_addr = br->dns2_ipaddr;
+			params.have_hw_addr = br->have_hw_addr;
+			memcpy(params.ip_aliases, br->ip_aliases,
+			       sizeof (br->ip_aliases));
+			memcpy(params.lan_hwaddr, br->lan_hwaddr, ETH_ALEN);
+
+			memcpy(params.wan_dev.name, br->wan_dev_name,
+			       IFNAMSIZ);
+			if (br->ports[FBXBR_PORT_WAN].dev)
+				params.wan_dev.present = 1;
+
+			memcpy(params.lan_dev.name, br->lan_dev_name,
+			       IFNAMSIZ);
+			if (br->ports[FBXBR_PORT_LAN].dev)
+				params.lan_dev.present = 1;
+
+			params.dhcpd_renew_time = br->dhcpd_renew_time;
+			params.dhcpd_rebind_time = br->dhcpd_rebind_time;
+			params.dhcpd_lease_time = br->dhcpd_lease_time;
+			params.inputmark = br->inputmark;
+			local_bh_enable();
+
+			if (access_ok(VERIFY_WRITE, (void *)req.arg,
+				      sizeof(params)) != 1)
+				return -EFAULT;
+
+			if (copy_to_user((void *)req.arg, &params,
+					 sizeof (params)))
+				return -EFAULT;
+			return 0;
+		}
+
+		/* this is a set */
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
+
+		local_bh_disable();
+		ret = set_bridge_info(params.brname, params.flags,
+				      params.dns1_addr, params.dns2_addr,
+				      params.ip_aliases,
+				      params.dhcpd_renew_time,
+				      params.dhcpd_rebind_time,
+				      params.dhcpd_lease_time,
+				      params.inputmark);
+		local_bh_enable();
+
+		return ret;
+
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int fbxbridge_netevent_callback(struct notifier_block *nb,
+				       unsigned long event,
+				       void *data)
+{
+	struct neighbour *n;
+	struct fbxbridge *p;
+	u32 dip;
+
+	if (event != NETEVENT_NEIGH_UPDATE)
+		return 0;
+
+	n = (struct neighbour *)data;
+	if (n->nud_state & NUD_VALID)
+		return 0;
+
+	if (n->tbl->family != AF_INET)
+		return 0;
+
+	memcpy(&dip, n->primary_key, 4);
+
+	local_bh_disable();
+	p = fbxbridge_list;
+	while (p) {
+		unsigned int i;
+
+		for (i = 0; i < ARRAY_SIZE(p->ports); i++) {
+			if (p->ports[i].dev != n->dev)
+				continue;
+
+			__fbxbridge_fp_flush_by_dip(&p->ports[i], dip);
+			goto found;
+		}
+
+		p = p->next;
+	}
+
+found:
+	local_bh_enable();
+	return 0;
+}
+
+static struct notifier_block fbxbridge_netevent_nb = {
+        .notifier_call = fbxbridge_netevent_callback,
+};
+
+static int __init fbxbridge_init_module(void)
+{
+	register_netdevice_notifier(&fbxbridge_notifier);
+	register_inetaddr_notifier(&fbxbridge_inet_notifier);
+	register_netevent_notifier(&fbxbridge_netevent_nb);
+	fbxbridge_handle_frame_hook = fbxbridge_handle_frame;
+	fbxbridge_set(fbxbridge_ioctl);
+
+	return 0;
+}
+
+static void __exit fbxbridge_exit_module(void)
+{
+	unregister_netdevice_notifier(&fbxbridge_notifier);
+	unregister_netevent_notifier(&fbxbridge_netevent_nb);
+	unregister_inetaddr_notifier(&fbxbridge_inet_notifier);
+	fbxbridge_set(NULL);
+	fbxbridge_handle_frame_hook = NULL;
+}
+
+module_init(fbxbridge_init_module);
+module_exit(fbxbridge_exit_module);
+
+MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
+MODULE_DESCRIPTION("Freebox Network Bridge - www.freebox.fr");
+MODULE_LICENSE("GPL");
diff -Nruw linux-4.2.6-fbx/net/fbxbridge./fbxbridge_dhcp.c linux-4.2.6-fbx/net/fbxbridge/fbxbridge_dhcp.c
--- linux-4.2.6-fbx/net/fbxbridge./fbxbridge_dhcp.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxbridge/fbxbridge_dhcp.c	2015-11-02 18:59:31.552626997 +0100
@@ -0,0 +1,461 @@
+/*
+ * fbxbridge_dhcp.c
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+
+#include <linux/netdevice.h>
+#include <linux/udp.h>
+#include <linux/netfilter.h>
+#include <net/ip.h>
+#include <asm/checksum.h>
+
+#include <linux/fbxbridge.h>
+#include <linux/fbxserial.h>
+
+#define BOOTP_REQUEST   1
+#define BOOTP_REPLY     2
+
+struct bootp_pkt {              /* BOOTP packet format */
+	struct iphdr iph;       /* IP header */
+	struct udphdr udph;     /* UDP header */
+	u8 op;                  /* 1=request, 2=reply */
+	u8 htype;               /* HW address type */
+	u8 hlen;                /* HW address length */
+	u8 hops;                /* Used only by gateways */
+	u32 xid;                /* Transaction ID */
+	u16 secs;               /* Seconds since we started */
+	u16 flags;              /* Just what it says */
+	u32 client_ip;          /* Client's IP address if known */
+	u32 your_ip;            /* Assigned IP address */
+	u32 server_ip;          /* (Next, e.g. NFS) Server's IP address */
+	u32 relay_ip;           /* IP address of BOOTP relay */
+	u8 hw_addr[16];         /* Client's HW address */
+	u8 serv_name[64];       /* Server host name */
+	u8 boot_file[128];      /* Name of boot file */
+	u8 exten[312];          /* DHCP options / BOOTP vendor extensions */
+};
+
+
+#define DHCPDISCOVER	1
+#define DHCPOFFER	2
+#define DHCPREQUEST	3
+#define DHCPDECLINE	4
+#define DHCPACK		5
+#define DHCPNACK	6
+#define DHCPRELEASE	7
+#define DHCPINFORM	8
+
+#define BROADCAST_FLAG	0x8000 /* "I need broadcast replies" */
+
+static const char *dhcp_to_name[] = {
+	"NONE",
+	"DHCPDISCOVER",
+	"DHCPOFFER",
+	"DHCPREQUEST",
+	"DHCPDECLINE",
+	"DHCPACK",
+	"DHCPNACK",
+	"DHCPRELEASE",
+	"DHCPINFORM",
+};
+
+
+#define PARAM_SUBMASK	(1 << 0)
+#define PARAM_ROUTER	(1 << 1)
+#define PARAM_DNS	(1 << 2)
+#define PARAM_BROADCAST	(1 << 3)
+
+struct dhcp_options
+{
+	u8	msg_type;
+	u32	t1;		/* renewal timeout */
+	u32	t2;		/* rebinding timemout */
+	u32	lease_time;	/* lease time */
+	u32	server_id;	/* server identifier */
+	u32	request_param;	/* requested config params (bitfield) */
+
+	u32	netmask;	/* netmask assigne to client */
+	u32	router;
+	u32	bcast;
+	u32	dns1;
+	u32	dns2;
+	u32	requested_ip;
+
+	bool	need_bcast;
+};
+
+
+static const unsigned char dhcp_magic_cookie[] = { 0x63, 0x82, 0x53, 0x63 };
+
+/* parse the dhcp options string to a struct */
+static void parse_dhcp_opts(const u8			*opts_str,
+			    int				maxlen,
+			    struct dhcp_options		*opts)
+{
+	const u8 *p, *end;
+
+	memset(opts, 0, sizeof(*opts));
+
+	/* check magic cookie */
+	if (memcmp(opts_str, dhcp_magic_cookie, sizeof(dhcp_magic_cookie)))
+		return;
+
+	/* now go for options */
+	p = opts_str + 4;
+	end = opts_str + maxlen;
+
+	while (p < end && *p != 0xff) {
+		const u8 *option;
+		size_t len, i;
+
+		option = p++;
+
+                if (*option == 0)
+                        continue;
+
+		/* jump of 'len' + 1 bytes */
+		len = *p;
+		p += len + 1;
+		if (p >= end)
+			break;
+
+		/* search for known parameter */
+		switch (*option) {
+		case 53: /* msg_type */
+			if (len)
+				opts->msg_type = option[2];
+			break;
+
+		case 55: /* param request */
+			for (i = 0; i < len; i++) {
+				switch (option[2 + i]) {
+				case 1: /* subnet */
+					opts->request_param |= PARAM_SUBMASK;
+					break;
+
+				case 3: /* router */
+					opts->request_param |= PARAM_ROUTER;
+					break;
+
+				case 6: /* dns */
+					opts->request_param |= PARAM_DNS;
+					break;
+
+				case 28: /* broadcast */
+					opts->request_param |= PARAM_BROADCAST;
+					break;
+				}
+			}
+			break;
+
+		case 50: /* requested_ip */
+			if (len >= 4)
+				memcpy(&opts->requested_ip, option + 2, 4);
+			break;
+
+		case 54: /* server_id */
+			if (len >= 4)
+				memcpy(&opts->server_id, option + 2, 4);
+			break;
+}
+	}
+}
+
+static void dump_dhcp_message(struct fbxbridge *br, struct sk_buff *skb,
+			      struct bootp_pkt *bpkt, const char *action,
+			      const char *dest)
+
+{
+	struct dhcp_options opts;
+
+	parse_dhcp_opts(bpkt->exten, skb->len - (sizeof(*bpkt) - 312),
+			&opts);
+
+	if (opts.msg_type < 9) {
+		struct iphdr *iph;
+
+		iph = ip_hdr(skb);
+		printk(KERN_DEBUG "%s: %s dhcp %s %s "
+		       "(%pI4 -> %pI4) "
+		       "(caddr: %pI4 - yaddr: %pI4 - "
+		       "saddr: %pI4 - req_addr: %pI4)\n",
+		       br->name,
+		       action,
+		       dhcp_to_name[opts.msg_type],
+		       dest,
+		       &iph->saddr,
+		       &iph->daddr,
+		       &bpkt->client_ip,
+		       &bpkt->your_ip,
+		       &bpkt->server_ip,
+		       &opts.requested_ip);
+	} else {
+		printk(KERN_DEBUG "%s: %s unknown dhcp message %s\n",
+		       br->name, action, dest);
+	}
+}
+
+/* write a the dhcp options string from a struct */
+static void make_dhcp_opts(u8				*opts_str,
+			   const struct dhcp_options	*opts,
+			   int				type)
+{
+	int len = 0;
+
+	memcpy(opts_str, dhcp_magic_cookie, sizeof(dhcp_magic_cookie));
+	len += sizeof(dhcp_magic_cookie);
+
+	/* msg type (REPLY or OFFER) */
+	opts_str[len++] = 53;
+	opts_str[len++] = 1;
+	opts_str[len++] = opts->msg_type;
+
+	/* server id */
+	opts_str[len++] = 54;
+	opts_str[len++] = 4;
+	memcpy(opts_str + len, &opts->server_id, 4);
+	len += 4;
+
+	/* t1 */
+	if (opts->t1) {
+		opts_str[len++] = 58;
+		opts_str[len++] = 4;
+		memcpy(opts_str + len, &opts->t1, 4);
+		len += 4;
+	}
+
+	/* t2 */
+	if (opts->t2) {
+		opts_str[len++] = 59;
+		opts_str[len++] = 4;
+		memcpy(opts_str + len, &opts->t2, 4);
+		len += 4;
+	}
+
+	/* lease time */
+	if (opts->lease_time) {
+		opts_str[len++] = 51;
+		opts_str[len++] = 4;
+		memcpy(opts_str + len, &opts->lease_time, 4);
+		len += 4;
+	}
+
+	/* add requested_param */
+	if (opts->request_param & PARAM_SUBMASK) {
+		opts_str[len++] = 1;
+		opts_str[len++] = 4;
+		memcpy(opts_str + len, &opts->netmask, 4);
+		len += 4;
+	}
+
+	if (opts->request_param & PARAM_ROUTER) {
+		opts_str[len++] = 3;
+		opts_str[len++] = 4;
+		memcpy(opts_str + len, &opts->router, 4);
+		len += 4;
+	}
+
+	if (opts->request_param & PARAM_BROADCAST) {
+		opts_str[len++] = 28;
+		opts_str[len++] = 4;
+		memcpy(opts_str + len, &opts->bcast, 4);
+		len += 4;
+	}
+
+	if (opts->request_param & PARAM_DNS) {
+		opts_str[len++] = 6;
+		opts_str[len++] = (opts->dns2 ? 8 : 4);
+		memcpy(opts_str + len, &opts->dns1, 4);
+		if (opts->dns2)
+			memcpy(opts_str + len + 4, &opts->dns2, 4);
+		len += (opts->dns2 ? 8 : 4);
+	}
+
+	opts_str[len++] = 255;
+}
+
+/* dhcp server */
+static void send_dhcp_reply(struct fbxbridge *br, int type,
+			    const struct bootp_pkt *src_packet,
+			    const struct dhcp_options *src_opts)
+{
+	struct sk_buff		*skb;
+	struct iphdr		*h;
+	struct bootp_pkt	*b;
+	struct dhcp_options	dhcp_opts;
+
+	/* Allocate packet */
+	skb = dev_alloc_skb(sizeof (struct bootp_pkt) + 32);
+	if (!skb)
+		return;
+
+	skb_reserve(skb, 16);
+	b = (struct bootp_pkt *)skb_put(skb, sizeof(struct bootp_pkt));
+	memset(b, 0, sizeof(struct bootp_pkt));
+
+	/* Construct IP header */
+	skb_reset_network_header(skb);
+	h = &b->iph;
+	h->version = 4;
+	h->ihl = 5;
+	h->tot_len = htons(sizeof(struct bootp_pkt));
+	h->frag_off = __constant_htons(IP_DF);
+	h->ttl = 64;
+	h->protocol = IPPROTO_UDP;
+	h->saddr = br->wan_gw;
+
+	switch (type) {
+	case DHCPOFFER:
+	case DHCPACK:
+		if (src_packet->client_ip)
+			h->daddr = src_packet->client_ip;
+                else if (src_opts->need_bcast)
+                        h->daddr = INADDR_BROADCAST;
+		else
+			h->daddr = br->wan_ipaddr;
+		break;
+
+	case DHCPNACK:
+		/* always broadcast NAK */
+		h->daddr = INADDR_BROADCAST;
+		break;
+	}
+
+	h->check = ip_fast_csum((unsigned char *) h, h->ihl);
+
+	/* Construct UDP header */
+	b->udph.source = __constant_htons(67);
+	b->udph.dest = __constant_htons(68);
+	b->udph.len = htons(sizeof(struct bootp_pkt) - sizeof(struct iphdr));
+
+	/* Construct DHCP header */
+	b->op = BOOTP_REPLY;
+	b->htype = ARPHRD_ETHER;
+	b->hlen = ETH_ALEN;
+	b->secs = 0;
+	b->xid = src_packet->xid;
+
+	switch (type) {
+	case DHCPOFFER:
+		b->server_ip = br->wan_gw;
+		b->your_ip = br->wan_ipaddr;
+		break;
+
+	case DHCPACK:
+		b->client_ip = src_packet->client_ip;
+		b->server_ip = br->wan_gw;
+		b->your_ip = br->wan_ipaddr;
+		break;
+
+	case DHCPNACK:
+		break;
+	}
+
+	b->relay_ip = src_packet->relay_ip;
+	memcpy(b->hw_addr, src_packet->hw_addr, sizeof(src_packet->hw_addr));
+
+	/* Construct DHCP options */
+	memset(&dhcp_opts, 0, sizeof (dhcp_opts));
+	dhcp_opts.msg_type = type;
+	dhcp_opts.server_id = br->wan_gw;
+
+	switch (type) {
+	case DHCPOFFER:
+	case DHCPACK:
+		dhcp_opts.t1 = htonl(br->dhcpd_renew_time);
+		dhcp_opts.t2 = htonl(br->dhcpd_rebind_time);
+		dhcp_opts.lease_time = htonl(br->dhcpd_lease_time);
+		dhcp_opts.netmask = br->lan_netmask;
+		dhcp_opts.bcast = (br->lan_netmask & br->wan_gw) |
+			~br->lan_netmask;
+		dhcp_opts.dns1 = br->dns1_ipaddr;
+		dhcp_opts.dns2 = br->dns2_ipaddr ? br->dns2_ipaddr : 0;
+		dhcp_opts.router = br->wan_gw;
+		dhcp_opts.request_param = src_opts->request_param;
+		break;
+	}
+
+	make_dhcp_opts(b->exten, &dhcp_opts, type);
+	dump_dhcp_message(br, skb, b, "sending", "to lan");
+
+	output_lan_frame(br, skb);
+}
+
+void fbxbridge_dhcpd(struct fbxbridge *br, struct sk_buff *skb)
+{
+	struct bootp_pkt *bpkt;
+	struct dhcp_options opts;
+
+	/* code assumes linear skb */
+	if (skb_linearize(skb) < 0)
+		return;
+
+	/* reject short packet */
+	if (skb->len < (sizeof(*bpkt) - 312))
+		return;
+
+	bpkt = (struct bootp_pkt *)skb->data;
+
+	/* select only valid BOOTP Request/Discover */
+	if (bpkt->op != BOOTP_REQUEST || bpkt->hlen != ETH_ALEN)
+		return;
+
+	parse_dhcp_opts(bpkt->exten, skb->len - (sizeof(*bpkt) - 312), &opts);
+        if (ntohs(bpkt->flags) & BROADCAST_FLAG)
+		opts.need_bcast = true;
+
+	dump_dhcp_message(br, skb, bpkt, "received", "from lan");
+
+	/* select DHCPDISCOVER to send a DHCPOFFER */
+	if (opts.msg_type == DHCPDISCOVER) {
+		__fbxbridge_keep_hw_addr(br, bpkt->hw_addr);
+
+		send_dhcp_reply(br, DHCPOFFER, bpkt, &opts);
+
+	} else if (opts.msg_type == DHCPREQUEST) {
+
+		__fbxbridge_keep_hw_addr(br, bpkt->hw_addr);
+
+		/* send ACK or NACK */
+		if (!opts.requested_ip) {
+			/* RENEWING/REBINDING */
+			if (!bpkt->client_ip) {
+				/* invalid packet; ignore */
+				return;
+			}
+
+			if (bpkt->client_ip != br->wan_ipaddr)
+				send_dhcp_reply(br, DHCPNACK, bpkt, &opts);
+			else
+				send_dhcp_reply(br, DHCPACK, bpkt, &opts);
+			return;
+
+		}
+
+		/* INIT-REBOOT or SELECTING */
+		if (bpkt->client_ip) {
+			/* invalid packet; ignore */
+			return;
+		}
+
+		if (!opts.server_id) {
+			/* INIT-REBOOT */
+			if (opts.requested_ip != br->wan_ipaddr)
+				send_dhcp_reply(br, DHCPNACK, bpkt, &opts);
+			else
+				send_dhcp_reply(br, DHCPACK, bpkt, &opts);
+			return;
+		}
+
+		/* SELECTING */
+		if (opts.server_id == br->wan_gw) {
+			/* client selected us */
+			send_dhcp_reply(br, DHCPACK, bpkt, &opts);
+		} else {
+			/* ignore */
+		}
+	}
+}
diff -Nruw linux-4.2.6-fbx/net/fbxbridge./fbxbridge_fastpath.c linux-4.2.6-fbx/net/fbxbridge/fbxbridge_fastpath.c
--- linux-4.2.6-fbx/net/fbxbridge./fbxbridge_fastpath.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxbridge/fbxbridge_fastpath.c	2015-11-18 18:24:33.688179768 +0100
@@ -0,0 +1,319 @@
+#include <linux/tcp.h>
+#include <linux/udp.h>
+#include <linux/jhash.h>
+#include <linux/if_vlan.h>
+#include <net/ip.h>
+
+#include <linux/fbxbridge.h>
+
+static inline u32 rule_hash(u32 sip, u32 dip, u16 sport, u16 dport)
+{
+	return jhash_3words(sip, dip, sport | dport << 16, 0);
+}
+
+static struct fbxbridge_fp_rule *
+lookup_rule(const struct fbxbridge_fp *fp, u32 hash,
+	    u32 sip, u32 dip, u16 sport, u16 dport)
+{
+	struct fbxbridge_fp_rule *r;
+
+	hlist_for_each_entry(r, &fp->hrules[hash % FBXBR_CACHE_SIZE], hnext) {
+		/* compare entry */
+		if (r->sip == sip && r->dip == dip &&
+		    r->sport == sport && r->dport == dport)
+			return r;
+	}
+	return NULL;
+}
+
+static struct fbxbridge_port *get_iport_svlan(struct net_device *idev,
+					      u16 vlan)
+{
+	struct fbxbridge *br;
+
+	br = fbxbridge_list;
+	do {
+		struct fbxbridge_port *iport;
+
+		if (!br->fast_path_enabled) {
+			br = br->next;
+			continue;
+		}
+
+		iport = &br->ports[FBXBR_PORT_WAN];
+		if (iport->master_dev == idev &&
+		    iport->vlan1 == vlan &&
+		    iport->vlan2 == 0)
+			return iport;
+
+		iport = &br->ports[FBXBR_PORT_LAN];
+		if (iport->master_dev == idev &&
+		    iport->vlan1 == vlan &&
+		    iport->vlan2 == 0)
+			return iport;
+
+		br = br->next;
+
+	} while (br);
+
+	return NULL;
+}
+
+static int __fp_in_ether_vlan(struct net_device *idev,
+			      struct sk_buff *skb,
+			      bool is_tcp)
+{
+	struct fbxbridge_fp_rule *rule;
+	struct fbxbridge_port *iport;
+	struct iphdr *iph;
+	struct vlan_hdr *vhdr;
+	struct fbxbridge_fp *fp;
+	u16 sport, dport;
+	u32 hash;
+
+	vhdr = (struct vlan_hdr *)(skb->data + ETH_HLEN);
+	iport = get_iport_svlan(idev, ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK);
+	if (!iport)
+		return 0;
+
+	skb_set_network_header(skb, VLAN_ETH_HLEN);
+	iph = ip_hdr(skb);
+	if (is_tcp) {
+		struct tcphdr *tcph;
+		tcph = (struct tcphdr *)((void *)iph + iph->ihl * 4);
+		sport = tcph->source;
+		dport = tcph->dest;
+		fp = &iport->tcp_fp;
+	} else {
+		struct udphdr *udph;
+		udph = (struct udphdr *)((void *)iph + iph->ihl * 4);
+		sport = udph->source;
+		dport = udph->dest;
+		fp = &iport->udp_fp;
+	}
+
+	hash = rule_hash(iph->saddr, iph->daddr, sport, dport);
+	rule = lookup_rule(fp, hash,
+			   iph->saddr, iph->daddr, sport, dport);
+	if (!rule)
+		return 0;
+
+	skb->fbxbridge_state = 2;
+	skb->protocol = htons(ETH_P_8021Q);
+	skb->dev = rule->oport->master_dev;
+
+	memcpy(skb->data, rule->dest_hwaddr, 6);
+	memcpy(skb->data + 6, skb->dev->dev_addr, 6);
+	vhdr->h_vlan_TCI = htons(rule->oport->vlan1);
+	dev_queue_xmit(skb);
+	return 1;
+}
+
+int __fbxbridge_fp_in_vlan_tcp4(struct net_device *idev, struct sk_buff *skb)
+{
+	return __fp_in_ether_vlan(idev, skb, true);
+}
+
+int __fbxbridge_fp_in_vlan_udp4(struct net_device *idev, struct sk_buff *skb)
+{
+	return __fp_in_ether_vlan(idev, skb, false);
+}
+
+static int __fbxbridge_fp_add(struct fbxbridge *br,
+			      const struct sk_buff *skb,
+			      const uint8_t *new_dest_hw_addr,
+			      struct fbxbridge_port *iport,
+			      struct fbxbridge_port *oport)
+{
+	struct fbxbridge_fp_rule *rule;
+	const struct iphdr *iph;
+	struct fbxbridge_fp *fp;
+	u32 hash;
+	u16 sport, dport;
+
+	if (!br->fast_path_enabled)
+		return 0;
+
+	iph = ip_hdr(skb);
+	switch (iph->protocol) {
+	case IPPROTO_UDP:
+	{
+		struct udphdr *udph;
+
+		udph = (struct udphdr *)skb_transport_header(skb);
+		sport = udph->source;
+		dport = udph->dest;
+		fp = &iport->udp_fp;
+		break;
+	}
+
+	case IPPROTO_TCP:
+	{
+		struct tcphdr *tcph;
+
+		tcph = (struct tcphdr *)skb_transport_header(skb);
+		/* ignore unless SYN */
+		if (!tcph->syn)
+			return 0;
+		sport = tcph->source;
+		dport = tcph->dest;
+		fp = &iport->tcp_fp;
+		break;
+	}
+
+	default:
+		return 0;
+	}
+
+	hash = rule_hash(iph->saddr, iph->daddr, sport, dport);
+	rule = lookup_rule(fp, hash, iph->saddr, iph->daddr, sport, dport);
+	if (rule)
+		return 0;
+
+	/* add new entry */
+	if (fp->count < FBXBR_MAX_RULES) {
+		rule = kmalloc(sizeof (*rule), GFP_ATOMIC);
+		if (!rule)
+			return 1;
+		fp->count++;
+	} else {
+		rule = list_first_entry(&fp->rules, struct fbxbridge_fp_rule,
+					next);
+		hlist_del(&rule->hnext);
+		list_del(&rule->next);
+	}
+
+	rule->sip = iph->saddr;
+	rule->dip = iph->daddr;
+	rule->sport = sport;
+	rule->dport = dport;
+	if (new_dest_hw_addr)
+		memcpy(rule->dest_hwaddr, new_dest_hw_addr, 6);
+	rule->oport = oport;
+	hlist_add_head(&rule->hnext, &fp->hrules[hash % FBXBR_CACHE_SIZE]);
+	list_add_tail(&rule->next, &fp->rules);
+
+	return 0;
+}
+
+int __fbxbridge_fp_add_wan_to_lan(struct fbxbridge *br,
+				  const struct sk_buff *skb,
+				  const uint8_t *new_dest_hw_addr)
+{
+	return __fbxbridge_fp_add(br, skb, new_dest_hw_addr,
+				  &br->ports[FBXBR_PORT_WAN],
+				  &br->ports[FBXBR_PORT_LAN]);
+}
+
+int __fbxbridge_fp_add_lan_to_wan(struct fbxbridge *br,
+				  const struct sk_buff *skb,
+				  const uint8_t *new_dest_hw_addr)
+{
+	return __fbxbridge_fp_add(br, skb, new_dest_hw_addr,
+				  &br->ports[FBXBR_PORT_LAN],
+				  &br->ports[FBXBR_PORT_WAN]);
+}
+
+void fbxbridge_fp_init(struct fbxbridge *br)
+{
+	size_t i;
+
+	for (i = 0; i < ARRAY_SIZE(br->ports); i++) {
+		struct fbxbridge_port *bport = &br->ports[i];
+		size_t j;
+
+		INIT_LIST_HEAD(&bport->tcp_fp.rules);
+		for (j = 0; j < FBXBR_CACHE_SIZE; j++)
+			INIT_HLIST_HEAD(&bport->tcp_fp.hrules[j]);
+		bport->tcp_fp.count = 0;
+		INIT_LIST_HEAD(&bport->udp_fp.rules);
+		for (j = 0; j < FBXBR_CACHE_SIZE; j++)
+			INIT_HLIST_HEAD(&bport->udp_fp.hrules[j]);
+		bport->udp_fp.count = 0;
+	}
+}
+
+static void __flush_by_dip(struct fbxbridge_fp *fp, uint32_t dip)
+{
+	struct fbxbridge_fp_rule *rule, *tmp;
+
+	list_for_each_entry_safe(rule, tmp, &fp->rules, next) {
+		if (rule->dip != dip)
+			continue;
+
+		hlist_del(&rule->hnext);
+		list_del(&rule->next);
+		kfree(rule);
+		fp->count--;
+	}
+}
+
+void __fbxbridge_fp_flush_by_dip(struct fbxbridge_port *bport, uint32_t dip)
+{
+	__flush_by_dip(&bport->tcp_fp, dip);
+	__flush_by_dip(&bport->udp_fp, dip);
+}
+
+void __fbxbridge_fp_flush(struct fbxbridge *br)
+{
+	size_t i;
+
+	for (i = 0; i < ARRAY_SIZE(br->ports); i++) {
+		struct fbxbridge_port *bport = &br->ports[i];
+		struct fbxbridge_fp_rule *rule, *tmp;
+		struct fbxbridge_fp *fp;
+
+		fp = &bport->tcp_fp;
+		list_for_each_entry_safe(rule, tmp, &fp->rules, next)
+			kfree(rule);
+
+		fp = &bport->udp_fp;
+		list_for_each_entry_safe(rule, tmp, &fp->rules, next)
+			kfree(rule);
+	}
+	fbxbridge_fp_init(br);
+}
+
+void fbxbridge_fp_flush_all(void)
+{
+	struct fbxbridge *br;
+
+	local_bh_disable();
+	br = fbxbridge_list;
+	while (br) {
+		if (br->fast_path_enabled)
+			__fbxbridge_fp_flush(br);
+		br = br->next;
+	}
+	local_bh_enable();
+}
+
+void __fbxbridge_fp_check(struct fbxbridge *br)
+{
+	struct fbxbridge_port *lport, *wport;
+	bool enabled;
+
+	lport = &br->ports[FBXBR_PORT_LAN];
+	wport = &br->ports[FBXBR_PORT_WAN];
+
+	enabled = (lport->dev && wport->dev &&
+		   lport->dev->type == wport->dev->type &&
+		   !(!!lport->vlan1 ^ !!wport->vlan1) &&
+		   !(!!lport->vlan2 ^ !!wport->vlan2) &&
+		   br->have_hw_addr &&
+		   br->br_ipaddr &&
+		   br->wan_ipaddr);
+
+	if (!(enabled ^ br->fast_path_enabled)) {
+		if (br->fast_path_enabled)
+			__fbxbridge_fp_flush(br);
+		return;
+	}
+
+	br->fast_path_enabled = enabled;
+	printk(KERN_INFO "%s: fastpath is now %s\n",
+	       br->name,
+	       enabled ? "enabled" : "disabled");
+	if (!br->fast_path_enabled)
+		__fbxbridge_fp_flush(br);
+}
diff -Nruw linux-4.2.6-fbx/net/fbxbridge./fbxbridge_filter.c linux-4.2.6-fbx/net/fbxbridge/fbxbridge_filter.c
--- linux-4.2.6-fbx/net/fbxbridge./fbxbridge_filter.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxbridge/fbxbridge_filter.c	2015-11-18 18:24:33.688179768 +0100
@@ -0,0 +1,203 @@
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+
+#include <linux/ip.h>
+#include <linux/tcp.h>
+#include <net/ip.h>
+#include <net/ipv6.h>
+#include <linux/netfilter.h>
+#include <net/netfilter/nf_conntrack.h>
+#include <linux/fbxbridge.h>
+
+#ifdef CONFIG_NETFILTER
+/*
+ * not available in any public header inside include/ :(
+ */
+unsigned int nf_iterate(struct list_head *head,
+			struct sk_buff *skb,
+			struct nf_hook_state *state,
+			struct nf_hook_ops **elemp);
+
+static int lolfn(struct sock *sk, struct sk_buff *skb)
+{
+	return 0;
+}
+
+/*
+ * We can't use NF_HOOK directly here as it will kfree_skb() if it is
+ * to be dropped.
+ */
+int fbxbridge_nf_hook(struct fbxbridge *br, uint8_t pf, unsigned int hook,
+		      struct sk_buff *skb, struct net_device *in,
+		      struct net_device *out)
+{
+	struct nf_hook_ops *elem;
+	int verdict;
+	struct nf_hook_state state;
+
+	nf_hook_state_init(&state, &nf_hooks[pf][hook], hook,
+			   INT_MIN, pf, in, out, skb->sk, lolfn);
+	elem = list_entry_rcu(state.hook_list, struct nf_hook_ops, list);
+
+	rcu_read_lock();
+	verdict = nf_iterate(state.hook_list, skb, &state, &elem);
+	rcu_read_unlock();
+	return verdict;
+}
+
+/*
+ * invoke netfilter FORWARD table for finer grained control
+ */
+static int
+netfilter_lan_to_wan_packet(struct fbxbridge *br, struct sk_buff *skb)
+{
+	if (!br->ports[FBXBR_PORT_WAN].dev || !br->ports[FBXBR_PORT_LAN].dev)
+		return NF_DROP;
+
+	skb->nfct = &nf_ct_untracked_get()->ct_general;
+	skb->nfctinfo = IP_CT_NEW;
+	nf_conntrack_get(skb->nfct);
+
+	return fbxbridge_nf_hook(br, NFPROTO_IPV4,
+				 NF_INET_FORWARD, skb,
+				 br->dev,
+				 br->ports[FBXBR_PORT_WAN].dev);
+}
+
+/*
+ * invoke netfilter FORWARD table for finer grained control
+ */
+static int
+netfilter_wan_to_lan_packet(struct fbxbridge *br, struct sk_buff *skb)
+{
+	if (!br->ports[FBXBR_PORT_WAN].dev || !br->ports[FBXBR_PORT_LAN].dev)
+		return NF_DROP;
+
+	skb->nfct = &nf_ct_untracked_get()->ct_general;
+	skb->nfctinfo = IP_CT_NEW;
+	nf_conntrack_get(skb->nfct);
+
+	return fbxbridge_nf_hook(br, NFPROTO_IPV4,
+				 NF_INET_FORWARD, skb,
+				 br->ports[FBXBR_PORT_WAN].dev,
+				 br->dev);
+}
+
+#else
+static inline int
+netfilter_lan_to_wan_packet(struct fbxbridge *br, struct sk_buff *skb)
+{ return NF_ACCEPT; }
+
+static inline int
+netfilter_wan_to_lan_packet(struct fbxbridge *br, struct sk_buff *skb)
+{ return NF_ACCEPT; }
+#endif
+
+
+static int
+filter_lan_to_wan_packet(struct fbxbridge *br, struct sk_buff *skb)
+{
+	struct iphdr *ip = ip_hdr(skb);
+
+	/* disallow source spoofing */
+	if (ip->saddr != br->wan_ipaddr)
+		return NF_DROP;
+
+	/* disallow all private net destination */
+	if ((ntohl(ip->daddr) & 0xff000000) == 0x0a000000)
+		return NF_DROP;
+
+	if ((ntohl(ip->daddr) & 0xfff00000) == 0xac100000)
+		return NF_DROP;
+
+	if ((ntohl(ip->daddr) & 0xffff0000) == 0xc0a80000)
+		return NF_DROP;
+
+	/* no multicast please */
+	if (IN_MULTICAST(ntohl(ip->daddr)))
+		return NF_DROP;
+
+	/* Don't let IP broadcast go through us */
+	if (ip->daddr == INADDR_ANY)
+		return NF_DROP;
+
+	if (ip->daddr == INADDR_BROADCAST)
+		return NF_DROP;
+
+	return NF_ACCEPT;
+}
+
+/*
+ * note: caller assured that ip header is valid
+ */
+int
+fbxbridge_filter_lan_to_wan_packet(struct fbxbridge *br, struct sk_buff *skb)
+{
+	int ret = NF_ACCEPT;
+
+	if ((br->flags & (FBXBRIDGE_FLAGS_FILTER))) {
+		ret = filter_lan_to_wan_packet(br, skb);
+		if (ret != NF_ACCEPT)
+			return ret;
+	}
+
+	if ((br->flags & FBXBRIDGE_FLAGS_NETFILTER))
+		ret = netfilter_lan_to_wan_packet(br, skb);
+
+	return ret;
+}
+
+static int filter_wan_to_lan_packet(struct fbxbridge *br, struct sk_buff *skb)
+{
+	struct iphdr *ip = ip_hdr(skb);
+
+	/* discard packet with obvious bad source */
+	if (IN_LOOPBACK(ntohl(ip->saddr)))
+		return NF_DROP;
+
+	/* give ipv6 in ip private to freebox back to the
+	 * kernel */
+	if (ip->protocol == IPPROTO_IPV6) {
+		struct ipv6hdr *iph6;
+		unsigned int hlen;
+
+		/* sanity check on header value */
+		hlen = ip->ihl * 4;
+		if (skb->len < hlen + sizeof(struct ipv6hdr))
+			return NF_DROP;
+
+		iph6 = (struct ipv6hdr *)((unsigned char *)ip + hlen);
+		if ((iph6->daddr.s6_addr32[0] & htonl(0xfffffff0)) ==
+		    htonl(0x2a010e30))
+			return NF_STOP;
+	}
+
+	/* keep ETHER_IP packets */
+	if (ip->protocol == 97)
+		return NF_STOP;
+
+	return NF_ACCEPT;
+}
+
+/*
+ * note: caller assured that ip header is valid
+ */
+int
+fbxbridge_filter_wan_to_lan_packet(struct fbxbridge *br, struct sk_buff *skb)
+{
+	int ret = NF_ACCEPT;
+
+	if ((br->flags & (FBXBRIDGE_FLAGS_FILTER))) {
+		ret = filter_wan_to_lan_packet(br, skb);
+		if (ret != NF_ACCEPT) {
+			return ret;
+		}
+	}
+
+	if ((br->flags & FBXBRIDGE_FLAGS_NETFILTER))
+		ret = netfilter_wan_to_lan_packet(br, skb);
+
+	return ret;
+}
diff -Nruw linux-4.2.6-fbx/net/fbxbridge./fbxbridge_forward.c linux-4.2.6-fbx/net/fbxbridge/fbxbridge_forward.c
--- linux-4.2.6-fbx/net/fbxbridge./fbxbridge_forward.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxbridge/fbxbridge_forward.c	2015-12-01 14:32:07.404030518 +0100
@@ -0,0 +1,362 @@
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/udp.h>
+#include <net/arp.h>
+
+#include <linux/pkt_sched.h>
+#include <linux/ip.h>
+#include <linux/netfilter.h>
+#include <net/ip.h>
+#include <net/sock.h>
+#include <net/route.h>
+
+#include <linux/fbxbridge.h>
+
+#ifdef CONFIG_NET_SCH_INGRESS
+#include <net/pkt_sched.h>
+#endif
+
+#ifdef CONFIG_NET_CLS_ACT
+static struct sk_buff *ing_filter(struct sk_buff *skb)
+{
+	struct tcf_proto *cl = rcu_dereference_bh(skb->dev->ingress_cl_list);
+	struct tcf_result cl_res;
+
+	/* If there's at least one ingress present somewhere (so
+	 * we get here via enabled static key), remaining devices
+	 * that are not configured with an ingress qdisc will bail
+	 * out here.
+	 */
+	if (!cl)
+		return skb;
+
+	qdisc_skb_cb(skb)->pkt_len = skb->len;
+	skb->tc_verd = SET_TC_AT(skb->tc_verd, AT_INGRESS);
+	qdisc_bstats_update_cpu(cl->q, skb);
+
+
+	switch (tc_classify(skb, cl, &cl_res)) {
+	case TC_ACT_OK:
+	case TC_ACT_RECLASSIFY:
+		skb->tc_index = TC_H_MIN(cl_res.classid);
+		break;
+	case TC_ACT_SHOT:
+		qdisc_qstats_drop_cpu(cl->q);
+	case TC_ACT_STOLEN:
+	case TC_ACT_QUEUED:
+		kfree_skb(skb);
+		return NULL;
+	default:
+		break;
+	}
+
+	return skb;
+}
+#endif
+
+#ifdef CONFIG_NETFILTER
+static int fbxbridge_skb_set_inputmark(struct fbxbridge *br, struct sk_buff *skb)
+{
+	if (skb->mark & br->inputmark) {
+		if (net_ratelimit()) {
+			printk(KERN_WARNING "fbxbridge: %s: input mark "
+			       "already set on skb %p\n", br->name, skb);
+		}
+		return 0;
+	}
+	skb->mark |= br->inputmark;
+	return 1;
+}
+
+static inline void fbxbridge_skb_clear_inputmark(struct fbxbridge *br,
+						 struct sk_buff *skb)
+{
+	skb->mark &= ~br->inputmark;
+}
+#endif
+
+static int handle_wan_frame(struct fbxbridge *br, struct sk_buff *skb)
+{
+	struct iphdr *iph;
+	int ret;
+	int verdict;
+
+	/*
+	 * filter only valid ip packet;
+	 */
+	if (skb->protocol != __constant_htons(ETH_P_IP))
+		return NF_STOP;
+
+	if (fbxbridge_check_ip_packet(skb)) {
+		kfree_skb(skb);
+		return NF_DROP;
+	}
+
+	iph = ip_hdr(skb);
+	if (iph->frag_off & htons(IP_OFFSET)) {
+		/* don't filter frags */
+		goto done;
+	}
+
+	if (fbxbridge_check_udp_tcp_packet(skb)) {
+		kfree_skb(skb);
+		return NF_DROP;
+	}
+
+#ifdef CONFIG_NETFILTER
+	if (br->flags & FBXBRIDGE_FLAGS_NETFILTER) {
+		int changed = fbxbridge_skb_set_inputmark(br, skb);
+
+
+		verdict = fbxbridge_nf_hook(br, NFPROTO_IPV4, NF_INET_LOCAL_IN,
+					    skb, skb->dev, NULL);
+		if (changed)
+			fbxbridge_skb_clear_inputmark(br, skb);
+
+		if (verdict == NF_ACCEPT || verdict == NF_STOP) {
+			/*
+			 * let it enter via the WAN interface.
+			 */
+			return NF_STOP;
+		}
+	}
+#endif
+
+	ret = fbxbridge_filter_wan_to_lan_packet(br, skb);
+	if (ret != NF_ACCEPT) {
+		if (ret == NF_DROP)
+			kfree_skb(skb);
+		return ret;
+	}
+	skb->fbxbridge_state = 1;
+
+	/* don't handle packet unless wan is up */
+	if (!br->wan_ipaddr) {
+		kfree_skb(skb);
+		return NF_DROP;
+	}
+
+done:
+#ifdef CONFIG_NET_CLS_ACT
+	/* pass it in ingress policer if frame is to be bridged */
+	skb = ing_filter(skb);
+	if (!skb)
+		return NF_DROP;
+	skb->tc_verd = 0;
+#endif
+
+	output_lan_frame(br, skb);
+	return ret;
+}
+
+static void handle_arp_frame(struct fbxbridge *br, struct sk_buff *skb)
+{
+	unsigned int sender_ipaddr, target_ipaddr;
+	unsigned char *sender_hwaddr, *req;
+	struct arphdr *arp;
+
+	/* sanity check on packet */
+	if (skb->len < ARP_ETHER_SIZE)
+		return;
+
+	arp = (struct arphdr *)skb->data;
+
+	if (arp->ar_hrd != __constant_htons(ARPHRD_ETHER) &&
+	    arp->ar_hrd != __constant_htons(ARPHRD_IEEE802))
+		return;
+
+	if (arp->ar_pro != __constant_htons(ETH_P_IP))
+		return;
+
+	if (arp->ar_hln != ETH_ALEN)
+		return;
+
+	if (arp->ar_pln != 4)
+		return;
+
+	if (arp->ar_op != __constant_htons(ARPOP_REQUEST) &&
+	    arp->ar_op != __constant_htons(ARPOP_REPLY))
+		return;
+
+	/* fetch subfields */
+	req = (unsigned char *)(arp + 1);
+
+	sender_hwaddr = req;
+	req += ETH_ALEN;
+
+	memcpy(&sender_ipaddr, req, 4);
+	req += 4;
+
+	/* skip target_hwaddr */
+	req += ETH_ALEN;
+
+	memcpy(&target_ipaddr, req, 4);
+
+	/* ignore gratuitous ARP */
+	if (!sender_ipaddr)
+		return;
+
+	if (arp->ar_op == __constant_htons(ARPOP_REQUEST)) {
+
+		/* client is sending an arp request */
+		if (!br->wan_ipaddr) {
+			/* wan is down, our address is not known,
+			 * answer to every arp requests */
+
+			/* ignore what looks like gratuitous ARP */
+			if (sender_ipaddr == target_ipaddr)
+				return;
+
+		} else {
+			/* wan is up, filter our arp reply to match
+			 * WAN */
+
+			/* accept only arp from remote client */
+			if (sender_ipaddr != br->wan_ipaddr)
+				return;
+
+			/* accept only arp request for wan network */
+			if ((target_ipaddr & br->lan_netmask) !=
+			    (br->wan_ipaddr & br->lan_netmask))
+				return;
+
+			/* request is for the client's address, keep quiet */
+			if (target_ipaddr == br->wan_ipaddr)
+				return;
+		}
+
+		/* ok I can answer */
+		output_arp_frame(br, skb->dev, ARPOP_REPLY,
+				 target_ipaddr,
+				 skb->dev->dev_addr,
+				 br->wan_ipaddr,
+				 sender_hwaddr);
+
+		/* keep the client address */
+		__fbxbridge_keep_hw_addr(br, sender_hwaddr);
+
+	} else {
+
+		/* accept only arp from remote client */
+		if (sender_ipaddr != br->wan_ipaddr)
+			return;
+
+		/* we received  an arp reply,  if it was  addressed to
+		 * us, then keep the client mac address  */
+		if (target_ipaddr != br->wan_gw)
+			return;
+
+		__fbxbridge_keep_hw_addr(br, sender_hwaddr);
+	}
+}
+
+static inline int is_local_ip(struct fbxbridge *br, unsigned long ipaddr)
+{
+	int i;
+
+	if (ipaddr == br->br_ipaddr || ipv4_is_multicast(ipaddr))
+		return 1;
+
+	for (i = 0; i < MAX_ALIASES; i++) {
+		if (br->ip_aliases[i] && br->ip_aliases[i] == ipaddr)
+			return 1;
+	}
+
+	return 0;
+}
+
+static int handle_lan_frame(struct fbxbridge *br, struct sk_buff *skb)
+{
+	struct iphdr *iph;
+	int ret;
+
+	/* handle non ip frame (arp) now */
+	if (skb->protocol == __constant_htons(ETH_P_ARP)) {
+		handle_arp_frame(br, skb);
+		kfree_skb(skb);
+		return NF_DROP;
+	}
+
+	/*
+	 * filter only valid ip packet;
+	 */
+	if (skb->protocol != __constant_htons(ETH_P_IP))
+		return NF_STOP;
+
+	if (fbxbridge_check_ip_packet(skb)) {
+		kfree_skb(skb);
+		return NF_DROP;
+	}
+
+	iph = ip_hdr(skb);
+
+	/* look  the destination  address, if  talking to  our private
+	 * address or alias, then frame is local */
+	if (is_local_ip(br, iph->daddr)) {
+		handle_local_input_lan_frame(br, skb);
+		return NF_ACCEPT;
+	}
+
+	/* don't handle packet unless wan is up */
+	if (!br->wan_ipaddr) {
+		kfree_skb(skb);
+		return NF_DROP;
+	}
+
+	if (iph->frag_off & htons(IP_OFFSET)) {
+		/* don't filter frags */
+		goto done;
+	}
+
+	if (fbxbridge_check_udp_tcp_packet(skb)) {
+		kfree_skb(skb);
+		return NF_DROP;
+	}
+	iph = ip_hdr(skb);
+
+	if ((br->flags & FBXBRIDGE_FLAGS_DHCPD) &&
+	    iph->protocol == IPPROTO_UDP) {
+		struct udphdr *udp;
+
+		udp = (struct udphdr *)skb_transport_header(skb);
+		if (udp->dest == htons(67)) {
+			fbxbridge_dhcpd(br, skb);
+			kfree_skb(skb);
+			return NF_DROP;
+		}
+	}
+
+	ret = fbxbridge_filter_lan_to_wan_packet(br, skb);
+	if (ret != NF_ACCEPT) {
+		if (ret == NF_DROP)
+			kfree_skb(skb);
+		return ret;
+	}
+	skb->fbxbridge_state = 1;
+
+done:
+	output_wan_frame(br, skb);
+	return ret;
+}
+
+struct sk_buff *fbxbridge_handle_frame(struct fbxbridge *br,
+				       struct sk_buff *skb)
+{
+	int ret;
+
+	/* if bridge interface is down, do nothing */
+	if (!(br->dev->flags & IFF_UP))
+		return skb;
+
+	/* check if frame is coming from lan or wan */
+	if (skb->dev == br->ports[FBXBR_PORT_WAN].dev)
+		ret = handle_wan_frame(br, skb);
+	else
+		ret = handle_lan_frame(br, skb);
+
+	/* tell kernel if the packet has been consumed or not */
+	return (ret != NF_STOP ? NULL : skb);
+}
diff -Nruw linux-4.2.6-fbx/net/fbxbridge./fbxbridge_local.c linux-4.2.6-fbx/net/fbxbridge/fbxbridge_local.c
--- linux-4.2.6-fbx/net/fbxbridge./fbxbridge_local.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxbridge/fbxbridge_local.c	2015-11-02 18:59:29.820613347 +0100
@@ -0,0 +1,65 @@
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/pkt_sched.h>
+
+#include <linux/ip.h>
+
+#include <linux/fbxbridge.h>
+
+void handle_local_input_lan_frame(struct fbxbridge *br, struct sk_buff *skb)
+{
+	if (!br->br_remote_ipaddr) {
+		kfree_skb(skb);
+		return;
+	}
+
+	/* packet comes from lan, snat it and make it local */
+	fbxbridge_snat_packet(skb, br->br_remote_ipaddr);
+	skb->dev = br->dev;
+	skb->pkt_type = PACKET_HOST;
+	br->dev->stats.rx_packets++;
+	br->dev->stats.rx_bytes += skb->len;
+	netif_rx(skb);
+}
+
+int handle_local_output_frame(struct fbxbridge *br, struct sk_buff *skb)
+{
+	struct iphdr *ip;
+
+	/* if no wan addr, we can't do anything */
+	if (!br->wan_ipaddr) {
+		kfree_skb(skb);
+		return 1;
+	}
+
+	/*
+	 * filter only valid packets
+	 */
+	if (skb->protocol != __constant_htons(ETH_P_IP)) {
+		kfree_skb(skb);
+		return 1;
+	}
+
+        if (fbxbridge_check_ip_packet(skb)) {
+                kfree_skb(skb);
+                return 1;
+	}
+	ip = ip_hdr(skb);
+
+	if (ipv4_is_multicast(ip->daddr)) {
+		output_lan_mcast_frame(br, skb);
+		return 0;
+	}
+
+	if (ip->daddr != br->br_remote_ipaddr) {
+		kfree_skb(skb);
+		return 1;
+	}
+
+	fbxbridge_dnat_packet(skb, br->wan_ipaddr);
+	output_lan_frame(br, skb);
+	return 0;
+}
diff -Nruw linux-4.2.6-fbx/net/fbxbridge./fbxbridge_output.c linux-4.2.6-fbx/net/fbxbridge/fbxbridge_output.c
--- linux-4.2.6-fbx/net/fbxbridge./fbxbridge_output.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxbridge/fbxbridge_output.c	2015-12-01 14:31:57.595953634 +0100
@@ -0,0 +1,217 @@
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/init.h>
+
+#include <linux/timer.h>
+#include <linux/ip.h>
+#include <linux/if_arp.h>
+#include <net/ip.h>
+#include <net/arp.h>
+
+#include <linux/fbxbridge.h>
+
+static unsigned char hw_bcast[ETH_ALEN] = { 0xff, 0xff, 0xff,
+					    0xff, 0xff, 0xff };
+
+static unsigned char hw_zero[ETH_ALEN] = { 0 };
+
+void output_arp_frame(struct fbxbridge *br, struct net_device *dev,
+		      unsigned short type,
+		      unsigned long src_ip, unsigned char *src_hw,
+		      unsigned long target_ip, unsigned char *target_hw)
+{
+	struct arphdr *arp;
+	struct sk_buff *skb;
+	unsigned char *arp_ptr;
+
+	/* prepare arp packet */
+	skb = dev_alloc_skb(ARP_ETHER_SIZE + dev->hard_header_len + 15);
+	if (unlikely (!skb))
+		return;
+
+	skb_reserve(skb, (dev->hard_header_len + 15) & ~15);
+	skb_reset_network_header(skb);
+	arp = (struct arphdr *)skb_network_header(skb);
+	skb_put(skb, ARP_ETHER_SIZE);
+
+	skb->dev = dev;
+	skb->protocol = htons(ETH_P_ARP);
+
+	arp->ar_hrd = htons(dev->type);
+	arp->ar_pro = htons(ETH_P_IP);
+	arp->ar_hln = dev->addr_len;
+	arp->ar_pln = 4;
+	arp->ar_op = htons(type);
+
+	arp_ptr = (unsigned char *)(arp + 1);
+
+	memcpy(arp_ptr, src_hw, dev->addr_len);
+	arp_ptr += dev->addr_len;
+	memcpy(arp_ptr, &src_ip, 4);
+	arp_ptr += 4;
+	memcpy(arp_ptr, target_hw, dev->addr_len);
+	arp_ptr += dev->addr_len;
+	memcpy(arp_ptr, &target_ip, 4);
+
+	/* handle promiscous mode on bridge */
+	if (unlikely(br->dev->flags & IFF_PROMISC)) {
+		struct sk_buff *skb2;
+
+		if ((skb2 = skb_clone(skb, GFP_ATOMIC))) {
+			skb2->dev = br->dev;
+			skb2->pkt_type = PACKET_HOST;
+			netif_rx(skb2);
+		}
+	}
+
+	if (dev_hard_header(skb, dev, ETH_P_ARP,
+			    target_hw == hw_zero ? hw_bcast : target_hw,
+			    src_hw, skb->len) < 0) {
+		dev_kfree_skb(skb);
+		return;
+	}
+
+	dev_queue_xmit(skb);
+}
+
+void output_lan_mcast_frame(struct fbxbridge *br, struct sk_buff *skb)
+{
+	struct iphdr *ip;
+	char mcast_hwaddr[6];
+	uint32_t daddr;
+
+	/* only send mcast if we have an active device */
+	if (!br->ports[FBXBR_PORT_LAN].dev) {
+		kfree(skb);
+		return;
+	}
+
+	ip = ip_hdr(skb);
+
+	/* compute mcast hwaddr */
+	mcast_hwaddr[0] = 0x1;
+	mcast_hwaddr[1] = 0x0;
+	mcast_hwaddr[2] = 0x5e;
+	daddr = ntohl(ip->daddr);
+	mcast_hwaddr[3] = (daddr & 0x7f0000) >> 16;
+	mcast_hwaddr[4] = (daddr & 0xff00) >> 8;
+	mcast_hwaddr[5] = (daddr & 0xff);
+
+	skb->dev = br->ports[FBXBR_PORT_LAN].dev;
+	dev_hard_header(skb, skb->dev, ETH_P_802_3,
+			mcast_hwaddr, skb->dev->dev_addr, ETH_P_IP);
+
+	dev_queue_xmit(skb);
+}
+
+void output_lan_frame(struct fbxbridge *br, struct sk_buff *skb)
+{
+	struct iphdr *iph;
+
+	if (!br->ports[FBXBR_PORT_LAN].dev) {
+		kfree_skb(skb);
+		return;
+	}
+
+	iph = ip_hdr(skb);
+
+	if ((!br->have_hw_addr && iph->daddr != INADDR_BROADCAST)) {
+
+		/* (fixme: try to queue instead of dropping ?) */
+		kfree_skb(skb);
+
+		/* rate limit arp sending to ARP_RATE_LIMIT  */
+		if (time_before(jiffies, br->last_arp_send + ARP_RATE_LIMIT))
+			return;
+		br->last_arp_send = jiffies;
+
+		output_arp_frame(br, br->ports[FBXBR_PORT_LAN].dev,
+				 ARPOP_REQUEST,
+				 br->wan_gw,
+				 br->ports[FBXBR_PORT_LAN].dev->dev_addr,
+				 br->wan_ipaddr,
+				 hw_zero);
+		return;
+	}
+
+	/* we have  an active device, send  to the hw addr  if we have
+	 * it, or to  the bcast hw addr if we don't  or the packet is
+	 * an ip broadcast */
+	skb->dev = br->ports[FBXBR_PORT_LAN].dev;
+	dev_hard_header(skb, skb->dev, ETH_P_802_3,
+			(br->have_hw_addr &&
+			 iph->daddr != INADDR_BROADCAST) ?
+			br->lan_hwaddr : hw_bcast,
+			skb->dev->dev_addr, ETH_P_IP);
+
+	if (skb->fbxbridge_state == 1)
+		__fbxbridge_fp_add_wan_to_lan(br, skb, br->lan_hwaddr);
+
+	dev_queue_xmit(skb);
+}
+
+/*
+ * queue the packet on the wan device
+ */
+void output_wan_frame(struct fbxbridge *br, struct sk_buff *skb)
+{
+	if (!br->ports[FBXBR_PORT_WAN].dev) {
+		kfree_skb(skb);
+		return;
+	}
+
+	skb->dev = br->ports[FBXBR_PORT_WAN].dev;
+	if (skb->dev->type == ARPHRD_ETHER) {
+		struct neighbour *n;
+		struct iphdr *iph;
+		__be32 nexthop;
+
+		/*
+		 * on FTTH (wan dev->type == ARPHRD_ETHER is our cue
+		 * in this case) get nexthop address, if nexthop is
+		 * outside local wan, it is the wan_gw.
+		 */
+		iph = ip_hdr(skb);
+		nexthop = iph->daddr;
+		if ((nexthop & br->wan_netmask) !=
+		    (br->wan_ipaddr & br->wan_netmask))
+				nexthop = br->wan_gw;
+
+		/*
+		 * get a neighbour, possibly creating it.
+		 */
+		n = __neigh_lookup(&arp_tbl, &nexthop, skb->dev, 1);
+		if (!n)
+			return ;
+
+		if ((n->nud_state & NUD_VALID) == 0) {
+			/*
+			 * no MAC address for this neighbour (yet),
+			 * trigger ARP state machine via
+			 * neigh_event_send() and drop skb.
+			 */
+
+			if (net_ratelimit())
+				printk("%pI4 is invalid (state 0x%x).\n",
+				       &nexthop, n->nud_state);
+			neigh_event_send(n, NULL);
+			neigh_release(n);
+			kfree_skb(skb);
+			return ;
+		} else
+			neigh_event_send(n, NULL);
+
+		if (skb->fbxbridge_state == 1)
+			__fbxbridge_fp_add_lan_to_wan(br, skb, n->ha);
+
+		dev_hard_header(skb, skb->dev, ETH_P_802_3, n->ha,
+				skb->dev->dev_addr, ETH_P_IP);
+		neigh_release(n);
+	} else {
+		if (skb->fbxbridge_state == 1)
+			__fbxbridge_fp_add_lan_to_wan(br, skb, NULL);
+	}
+	dev_queue_xmit(skb);
+}
diff -Nruw linux-4.2.6-fbx/net/fbxbridge./fbxbridge_utils.c linux-4.2.6-fbx/net/fbxbridge/fbxbridge_utils.c
--- linux-4.2.6-fbx/net/fbxbridge./fbxbridge_utils.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxbridge/fbxbridge_utils.c	2015-11-02 18:59:28.484602822 +0100
@@ -0,0 +1,142 @@
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/init.h>
+
+#include <linux/ip.h>
+#include <linux/udp.h>
+#include <linux/tcp.h>
+#include <linux/netfilter_ipv4.h>
+#include <net/ip.h>
+#include <net/tcp.h>
+#include <asm/checksum.h>
+
+#include <linux/fbxbridge.h>
+
+int fbxbridge_check_ip_packet(struct sk_buff *skb)
+{
+	const struct iphdr *iph;
+
+	if (!pskb_may_pull(skb, sizeof (*iph)))
+		return 1;
+
+	iph = (struct iphdr *)skb->data;
+
+	if (iph->ihl < 5 || iph->version != 4)
+		return 1;
+
+	if (!pskb_may_pull(skb, iph->ihl * 4))
+		return 1;
+
+	iph = (struct iphdr *)skb->data;
+
+	if (ntohs(iph->tot_len) > skb->len)
+		return 1;
+
+	skb_reset_network_header(skb);
+	skb->transport_header = skb->network_header + iph->ihl * 4;
+
+	return 0;
+}
+
+int fbxbridge_check_udp_tcp_packet(struct sk_buff *skb)
+{
+	const struct iphdr *iph;
+
+	iph = ip_hdr(skb);
+
+	switch (iph->protocol) {
+	case IPPROTO_UDP:
+		if (!pskb_may_pull(skb, skb_transport_offset(skb) +
+				   sizeof (struct udphdr)))
+			return 1;
+		break;
+	case IPPROTO_TCP:
+		if (!pskb_may_pull(skb, skb_transport_offset(skb) +
+				   sizeof (struct tcphdr)))
+			return 1;
+		break;
+	}
+	return 0;
+}
+
+/*
+ * do source or destination nat
+ */
+static void recalculate_checksum(struct sk_buff *skb, u32 osaddr, u32 odaddr)
+{
+	struct iphdr *iph;
+	u16 check;
+
+	iph = ip_hdr(skb);
+	if (iph->frag_off & htons(IP_OFFSET)) {
+		printk("frag => no checksum\n");
+		return;
+	}
+
+	if (fbxbridge_check_udp_tcp_packet(skb))
+		return;
+
+	iph = ip_hdr(skb);
+
+	switch (iph->protocol) {
+	case IPPROTO_TCP:
+	{
+		struct tcphdr *tcph;
+
+		tcph = (struct tcphdr *)skb_transport_header(skb);
+		check = tcph->check;
+		if (skb->ip_summed != CHECKSUM_COMPLETE)
+			check = ~check;
+		check = csum_tcpudp_magic(iph->saddr, iph->daddr, 0, 0, check);
+		check = csum_tcpudp_magic(~osaddr, ~odaddr, 0, 0, ~check);
+		if (skb->ip_summed == CHECKSUM_COMPLETE)
+			check = ~check;
+		tcph->check = check;
+		break;
+	}
+
+	case IPPROTO_UDP:
+	{
+		struct udphdr *udph;
+
+		udph = (struct udphdr *)skb_transport_header(skb);
+		check = udph->check;
+		if (check != 0) {
+			check = csum_tcpudp_magic(iph->saddr, iph->daddr,
+						  0, 0, ~check);
+			check = csum_tcpudp_magic(~osaddr, ~odaddr, 0, 0,
+						  ~check);
+			udph->check = check ? : 0xFFFF;
+		}
+		break;
+	}
+	}
+}
+
+void fbxbridge_snat_packet(struct sk_buff *skb, unsigned long new_addr)
+{
+	struct iphdr	*ip;
+	unsigned long	oaddr;
+
+	ip = ip_hdr(skb);
+	oaddr = ip->saddr;
+	ip->saddr = new_addr;
+	ip->check = 0;
+	ip->check = ip_fast_csum((unsigned char *) ip, ip->ihl);
+	recalculate_checksum(skb, oaddr, ip->daddr);
+}
+
+void fbxbridge_dnat_packet(struct sk_buff *skb, unsigned long new_addr)
+{
+	struct iphdr	*ip;
+	unsigned long	oaddr;
+
+	ip = ip_hdr(skb);
+	oaddr = ip->daddr;
+	ip->daddr = new_addr;
+	ip->check = 0;
+	ip->check = ip_fast_csum((unsigned char *) ip, ip->ihl);
+	recalculate_checksum(skb, ip->saddr, oaddr);
+}
diff -Nruw linux-4.2.6-fbx/net/fbxbridge./Kconfig linux-4.2.6-fbx/net/fbxbridge/Kconfig
--- linux-4.2.6-fbx/net/fbxbridge./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxbridge/Kconfig	2015-11-02 18:59:49.136765613 +0100
@@ -0,0 +1,6 @@
+
+#
+# Freebox bridge
+#
+config FBXBRIDGE
+	bool "Freebox Bridge"
diff -Nruw linux-4.2.6-fbx/net/fbxbridge./Makefile linux-4.2.6-fbx/net/fbxbridge/Makefile
--- linux-4.2.6-fbx/net/fbxbridge./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/net/fbxbridge/Makefile	2015-11-02 18:59:48.668761921 +0100
@@ -0,0 +1,8 @@
+
+obj-$(CONFIG_FBXBRIDGE)	+= fbxbridge.o
+
+fbxbridge-objs := 	fbxbridge_dev.o fbxbridge_forward.o	\
+			fbxbridge_local.o fbxbridge_output.o	\
+			fbxbridge_utils.o fbxbridge_filter.o	\
+			fbxbridge_dhcp.o fbxbridge_fastpath.o
+
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/net/ipv4/ip_ffn.c	2015-11-18 18:24:33.704179894 +0100
@@ -0,0 +1,701 @@
+/*
+ * IP fast forwarding and NAT
+ *
+ * Very restrictive code, that only cope non fragmented UDP and TCP
+ * packets, that are routed and NATed with no other modification.
+ *
+ * Provide a fast path for established conntrack entries so that
+ * packets go out ASAP.
+ */
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/net.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
+#include <linux/jhash.h>
+#include <linux/proc_fs.h>
+#include <net/ip.h>
+#include <net/route.h>
+#include <net/netfilter/nf_conntrack.h>
+#include <net/netfilter/nf_conntrack_helper.h>
+
+#include <net/ip_ffn.h>
+
+#define FFN_CACHE_SIZE		256
+#define MAX_FFN_ENTRY		2048
+
+DEFINE_SPINLOCK(ffn_lock);
+static struct list_head ffn_cache[FFN_CACHE_SIZE];
+static struct list_head ffn_all;
+static unsigned int ffn_entry_count;
+
+/*
+ * hash on five parameter
+ */
+static inline unsigned int ffn_hash(u32 sip, u32 dip, u16 sport, u16 dport,
+				    int is_tcp)
+{
+	return jhash_3words(sip, is_tcp ? dip : ~dip, sport | dport << 16, 0);
+}
+
+/*
+ * attempt to find entry with given value in cache
+ */
+static struct ffn_lookup_entry *__ffn_find(u32 sip, u32 dip,
+					   u16 sport, u16 dport,
+					   u8 protocol,
+					   unsigned int hash)
+{
+	struct ffn_lookup_entry *tmp;
+
+	list_for_each_entry(tmp, &ffn_cache[hash % FFN_CACHE_SIZE], next) {
+
+		/* compare entry */
+		if (tmp->sip == sip && tmp->dip == dip &&
+		    tmp->sport == sport && tmp->dport == dport &&
+		    tmp->protocol == protocol)
+			return tmp;
+	}
+	return NULL;
+}
+
+struct ffn_lookup_entry *__ffn_get(u32 sip, u32 dip,
+				   u16 sport, u16 dport,
+				   int is_tcp)
+{
+	unsigned int hash;
+	u8 protocol;
+
+	/* lookup entry in cache */
+	protocol = (is_tcp) ? IPPROTO_TCP : IPPROTO_UDP;
+	hash = ffn_hash(sip, dip, sport, dport, is_tcp);
+	return __ffn_find(sip, dip, sport, dport, protocol, hash);
+}
+
+static void __ffn_remove_entry(struct ffn_lookup_entry *e)
+{
+	if (e->manip.priv_destructor)
+		e->manip.priv_destructor((void *)e->manip.ffn_priv_area);
+	list_del(&e->next);
+	list_del(&e->all_next);
+	ffn_entry_count--;
+	dst_release(e->manip.dst);
+	kfree(e);
+}
+
+static int __ffn_add_entry(struct ffn_lookup_entry *e,
+			   u8 proto, unsigned int hash)
+{
+	/* make sure it's not present */
+	if (__ffn_find(e->sip, e->dip, e->sport, e->dport, proto, hash))
+		return 1;
+
+	if (ffn_entry_count >= MAX_FFN_ENTRY)
+		return 1;
+
+	/* add new entry */
+	list_add_tail(&e->next, &ffn_cache[hash % FFN_CACHE_SIZE]);
+	list_add_tail(&e->all_next, &ffn_all);
+	ffn_entry_count++;
+	return 0;
+}
+
+/*
+ *
+ */
+static inline __sum16 checksum_adjust(u32 osip,
+				      u32 nsip,
+				      u32 odip,
+				      u32 ndip,
+				      u16 osport,
+				      u16 nsport,
+				      u16 odport,
+				      u16 ndport)
+{
+	const u32 old[] = { osip, odip, osport, odport };
+	const u32 new[] = { nsip, ndip, nsport, ndport };
+	__wsum osum, nsum;
+
+	osum = csum_partial(old, sizeof (old), 0);
+	nsum = csum_partial(new, sizeof (new), 0);
+
+	return ~csum_fold(csum_sub(nsum, osum));
+}
+
+/*
+ *
+ */
+static inline __sum16 checksum_adjust_ip(u32 osip,
+					 u32 nsip,
+					 u32 odip,
+					 u32 ndip)
+{
+	const u32 old[] = { osip, odip };
+	const u32 new[] = { nsip, ndip };
+	__wsum osum, nsum;
+
+	osum = csum_partial(old, sizeof (old), 0);
+	nsum = csum_partial(new, sizeof (new), 0);
+
+	/* -1 for TTL decrease */
+	return ~csum_fold(csum_sub(csum_sub(nsum, osum), 1));
+}
+
+/*
+ * two hooks into netfilter code
+ */
+extern int external_tcpv4_packet(struct nf_conn *ct,
+				 const struct sk_buff *skb,
+				 unsigned int dataoff,
+				 enum ip_conntrack_info ctinfo);
+
+extern int external_udpv4_packet(struct nf_conn *ct,
+				 const struct sk_buff *skb,
+				 unsigned int dataoff,
+				 enum ip_conntrack_info ctinfo);
+
+extern int ip_local_deliver_finish(struct sock *sk, struct sk_buff *skb);
+
+/*
+ * check if packet is in ffn cache, or mark it if it can be added
+ * later
+ */
+int ip_ffn_process(struct sk_buff *skb)
+{
+	struct ffn_lookup_entry *e;
+	struct nf_conntrack *nfct;
+	struct iphdr *iph;
+	struct tcphdr *tcph = NULL;
+	struct udphdr *udph = NULL;
+	bool remove_me;
+	u16 tcheck;
+	u8 proto;
+	int res, added_when;
+
+	if (!net_eq(dev_net(skb->dev), &init_net))
+		goto not_ffnable;
+
+	iph = ip_hdr(skb);
+
+	/* refuse fragmented IP packet, or packets with IP options */
+	if (iph->ihl > 5 || (iph->frag_off & htons(IP_MF | IP_OFFSET)))
+		goto not_ffnable;
+
+	/* check encapsulated protocol is udp or tcp */
+	if (iph->protocol != IPPROTO_TCP && iph->protocol != IPPROTO_UDP)
+		goto not_ffnable;
+
+	if (iph->ttl <= 1)
+		goto not_ffnable;
+
+	proto = iph->protocol;
+	if (proto == IPPROTO_TCP) {
+		if (skb_headlen(skb) < sizeof (*iph) + sizeof (struct tcphdr))
+			goto not_ffnable;
+
+		tcph = (struct tcphdr *)((unsigned char *)iph + sizeof (*iph));
+
+		if (tcph->doff * 4 < sizeof (struct tcphdr))
+			goto not_ffnable;
+
+		if (skb_headlen(skb) < sizeof (*iph) + tcph->doff * 4)
+			goto not_ffnable;
+
+		spin_lock_bh(&ffn_lock);
+		e = __ffn_get(iph->saddr, iph->daddr, tcph->source,
+			      tcph->dest, 1);
+	} else {
+		if (skb_headlen(skb) < sizeof (*iph) + sizeof (struct udphdr))
+			goto not_ffnable;
+
+		udph = (struct udphdr *)((unsigned char *)iph + sizeof (*iph));
+		spin_lock_bh(&ffn_lock);
+		e = __ffn_get(iph->saddr, iph->daddr, udph->source,
+			      udph->dest, 0);
+	}
+
+	if (!e) {
+		spin_unlock_bh(&ffn_lock);
+		goto ffnable;
+	}
+
+	if (e->manip.dst->obsolete > 0) {
+		__ffn_remove_entry(e);
+		spin_unlock_bh(&ffn_lock);
+		goto ffnable;
+	}
+
+	nfct = &e->manip.ct->ct_general;
+	nf_conntrack_get(nfct);
+
+	remove_me = false;
+	if (proto == IPPROTO_TCP) {
+		/* do sequence number checking and update
+		 * conntrack info */
+		res = external_tcpv4_packet(e->manip.ct, skb, sizeof (*iph),
+					    e->manip.ctinfo);
+		if (e->manip.ct->proto.tcp.state != TCP_ESTABLISHED)
+			remove_me = true;
+		tcheck = tcph->check;
+
+	} else {
+		res = external_udpv4_packet(e->manip.ct, skb, sizeof (*iph),
+					    e->manip.ctinfo);
+		tcheck = udph->check;
+	}
+
+	if (unlikely(res != NF_ACCEPT)) {
+		/* packet rejected by conntrack, unless asked to drop,
+		 * send it back into kernel */
+		if (remove_me)
+			__ffn_remove_entry(e);
+
+		spin_unlock_bh(&ffn_lock);
+		nf_conntrack_put(nfct);
+
+		if (res == NF_DROP) {
+			dev_kfree_skb(skb);
+			return 0;
+		}
+
+		goto ffnable;
+	}
+
+	if (!e->manip.alter)
+		goto fix_ip_hdr;
+
+	if (skb->ip_summed != CHECKSUM_PARTIAL) {
+		/* fix ports & transport protocol checksum */
+		if (proto == IPPROTO_TCP) {
+			tcph->source = e->manip.new_sport;
+			tcph->dest = e->manip.new_dport;
+			tcph->check = csum16_sub(tcph->check,
+						 e->manip.l4_adjustment);
+		} else {
+			udph->source = e->manip.new_sport;
+			udph->dest = e->manip.new_dport;
+			if (udph->check) {
+				u16 tcheck;
+
+				tcheck = csum16_sub(udph->check,
+						    e->manip.l4_adjustment);
+				udph->check = tcheck ? tcheck : 0xffff;
+			}
+		}
+	} else {
+		unsigned int len;
+
+		/*
+		 * assume tcph->check only covers ip pseudo header, so
+		 * don't update checksum wrt port change
+		 *
+		 * we might check skb->csum_offset to confirm that
+		 * this is a valid assertion
+		 */
+		if (proto == IPPROTO_TCP) {
+			len = skb->len - ((void *)tcph - (void *)iph);
+			tcheck = ~csum_tcpudp_magic(e->manip.new_sip,
+						    e->manip.new_dip,
+						    len, IPPROTO_TCP, 0);
+			tcph->check = tcheck;
+			tcph->source = e->manip.new_sport;
+			tcph->dest = e->manip.new_dport;
+		} else {
+			len = skb->len - ((void *)udph - (void *)iph);
+			if (udph->check) {
+				tcheck = ~csum_tcpudp_magic(e->manip.new_sip,
+							    e->manip.new_dip,
+							    len,
+							    IPPROTO_UDP, 0);
+				udph->check = tcheck ? tcheck : 0xffff;
+			}
+			udph->source = e->manip.new_sport;
+			udph->dest = e->manip.new_dport;
+		}
+	}
+
+	/* update IP header field */
+	iph->saddr = e->manip.new_sip;
+	iph->daddr = e->manip.new_dip;
+
+fix_ip_hdr:
+	iph->ttl--;
+
+	if (e->manip.tos_change) {
+		iph->tos = e->manip.new_tos;
+		iph->check = 0;
+		iph->check = ip_fast_csum((u8 *)iph, 5);
+	} else {
+		iph->check = csum16_sub(iph->check,
+					e->manip.ip_adjustment);
+	}
+
+	/* forward skb */
+	if (e->manip.force_skb_prio)
+		skb->priority = e->manip.new_skb_prio;
+	else
+		skb->priority = rt_tos2priority(iph->tos);
+
+	skb->mark = e->manip.new_mark;
+
+#ifdef CONFIG_IP_FFN_PROCFS
+	e->forwarded_packets++;
+	e->forwarded_bytes += skb->len;
+#endif
+
+	skb_dst_set(skb, dst_clone(e->manip.dst));
+
+	if (nfct == skb->nfct) {
+		/*
+		 * skbs to/from localhost will have the conntrack
+		 * already set, don't leak references here.
+		 */
+		nf_conntrack_put(nfct);
+	} else {
+		if (unlikely(skb->nfct != NULL)) {
+			/*
+			 * conntrack is not NULL here and it is not
+			 * the same as the one we have in the
+			 * ffn_entry, this shoud not happen, warn once
+			 * and switch to slow path.
+			 */
+			WARN_ONCE(skb->nfct != NULL,
+				  "weird skb->nfct %p, NULL was expected\n",
+				  skb->nfct);
+			printk_once(KERN_WARNING "ffn entry:\n"
+				    " added_when: %i\n"
+				    " sip: %pI4 -> %pI4\n"
+				    " dip: %pI4 -> %pI4\n"
+				    " sport: %u -> %u\n"
+				    " dport: %u -> %u\n",
+				    e->added_when,
+				    &e->sip, &e->manip.new_sip,
+				    &e->dip, &e->manip.new_dip,
+				    htons(e->sport), htons(e->manip.new_sport),
+				    htons(e->dport), htons(e->manip.new_dport));
+			goto not_ffnable;
+		}
+		skb->nfct = nfct;
+		skb->nfctinfo = e->manip.ctinfo;
+	}
+
+	added_when = e->added_when;
+	if (remove_me)
+		__ffn_remove_entry(e);
+	spin_unlock_bh(&ffn_lock);
+
+	skb->ffn_state = FFN_STATE_FAST_FORWARDED;
+
+	if (added_when == IP_FFN_FINISH_OUT)
+		dst_output(skb);
+	else
+		ip_local_deliver_finish(skb->sk, skb);
+
+	return 0;
+
+ffnable:
+	skb->ffn_state = FFN_STATE_FORWARDABLE;
+	skb->ffn_orig_tos = iph->tos;
+	return 1;
+
+not_ffnable:
+	skb->ffn_state = FFN_STATE_INCOMPATIBLE;
+	return 1;
+}
+
+/*
+ * check if skb is candidate for ffn, and if so add it to ffn cache
+ *
+ * called after post routing
+ */
+void ip_ffn_add(struct sk_buff *skb, int when)
+{
+	struct nf_conn *ct;
+	struct nf_conntrack_tuple *tuple, *rtuple;
+	enum ip_conntrack_info ctinfo;
+	struct ffn_lookup_entry *e;
+	struct iphdr *iph;
+	unsigned int hash;
+	int dir;
+	u8 proto;
+
+	if (!net_eq(dev_net(skb->dev), &init_net))
+		return;
+
+	if (ffn_entry_count >= MAX_FFN_ENTRY)
+		return;
+
+	iph = ip_hdr(skb);
+
+	if (!skb->nfct)
+		return;
+
+	if (skb_dst(skb)->output != ip_output && when == IP_FFN_FINISH_OUT)
+		return;
+
+	if (skb->nfct == &nf_ct_untracked_get()->ct_general)
+		return;
+
+	ct = nf_ct_get(skb, &ctinfo);
+	if ((ctinfo != IP_CT_ESTABLISHED) &&
+	    (ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY)) {
+		return;
+	}
+
+	if (nfct_help(ct))
+		return;
+
+	dir = (ctinfo == IP_CT_ESTABLISHED) ?
+		IP_CT_DIR_ORIGINAL : IP_CT_DIR_REPLY;
+	tuple = &ct->tuplehash[dir].tuple;
+
+	if (tuple->dst.protonum != IPPROTO_TCP &&
+	    tuple->dst.protonum != IPPROTO_UDP)
+		return;
+
+	if (tuple->dst.protonum == IPPROTO_TCP &&
+	    ct->proto.tcp.state != TCP_CONNTRACK_ESTABLISHED)
+		return;
+
+	rtuple = &ct->tuplehash[1 - dir].tuple;
+
+	e = kmalloc(sizeof (*e), GFP_ATOMIC);
+	if (!e)
+		return;
+
+	e->added_when = when;
+	e->sip = tuple->src.u3.ip;
+	e->dip = tuple->dst.u3.ip;
+	e->sport = tuple->src.u.all;
+	e->dport = tuple->dst.u.all;
+	e->protocol = tuple->dst.protonum;
+
+#ifdef CONFIG_IP_FFN_PROCFS
+	e->forwarded_packets = 0;
+	e->forwarded_bytes = 0;
+#endif
+
+	e->manip.new_sip = rtuple->dst.u3.ip;
+	e->manip.new_dip = rtuple->src.u3.ip;
+	e->manip.new_sport = rtuple->dst.u.all;
+	e->manip.new_dport = rtuple->src.u.all;
+
+	if (e->manip.new_sip == e->sip &&
+	    e->manip.new_dip == e->dip &&
+	    e->manip.new_sport == e->sport &&
+	    e->manip.new_dport == e->dport)
+		e->manip.alter = 0;
+	else
+		e->manip.alter = 1;
+
+	if (e->manip.alter) {
+		/* compute checksum adjustement */
+		e->manip.l4_adjustment = checksum_adjust(e->sip,
+							 e->manip.new_sip,
+							 e->dip,
+							 e->manip.new_dip,
+							 e->sport,
+							 e->manip.new_sport,
+							 e->dport,
+							 e->manip.new_dport);
+
+		e->manip.ip_adjustment = checksum_adjust_ip(e->sip,
+							    e->manip.new_sip,
+							    e->dip,
+							    e->manip.new_dip);
+	}
+
+	if (skb->ffn_orig_tos != iph->tos) {
+		e->manip.tos_change = 1;
+		e->manip.new_tos = iph->tos;
+	} else
+		e->manip.tos_change = 0;
+
+	if (skb->priority != rt_tos2priority(iph->tos)) {
+		e->manip.force_skb_prio = 1;
+		e->manip.new_skb_prio = skb->priority;
+	} else
+		e->manip.force_skb_prio = 0;
+
+	e->manip.new_mark = skb->mark;
+	e->manip.priv_destructor = NULL;
+	e->manip.dst = skb_dst(skb);
+	dst_hold(e->manip.dst);
+	e->manip.ct = ct;
+	e->manip.ctinfo = ctinfo;
+
+	hash = ffn_hash(e->sip, e->dip, e->sport, e->dport,
+			e->protocol == IPPROTO_TCP);
+	proto = (e->protocol == IPPROTO_TCP) ? IPPROTO_TCP : IPPROTO_UDP;
+
+	spin_lock_bh(&ffn_lock);
+	if (__ffn_add_entry(e, proto, hash)) {
+		spin_unlock_bh(&ffn_lock);
+		dst_release(e->manip.dst);
+		kfree(e);
+		return;
+	}
+	spin_unlock_bh(&ffn_lock);
+}
+
+/*
+ * netfilter callback when conntrack is about to be destroyed
+ */
+void ip_ffn_ct_destroy(struct nf_conn *ct)
+{
+	struct nf_conntrack_tuple *tuple;
+	struct ffn_lookup_entry *e;
+	int dir;
+
+	/* locate all entry that use this conntrack */
+	for (dir = 0; dir < 2; dir++) {
+		tuple = &ct->tuplehash[dir].tuple;
+
+		if (tuple->dst.protonum != IPPROTO_TCP &&
+		    tuple->dst.protonum != IPPROTO_UDP)
+			return;
+
+		spin_lock_bh(&ffn_lock);
+		e = __ffn_get(tuple->src.u3.ip, tuple->dst.u3.ip,
+			      tuple->src.u.all, tuple->dst.u.all,
+			      tuple->dst.protonum == IPPROTO_TCP);
+		if (e)
+			__ffn_remove_entry(e);
+		spin_unlock_bh(&ffn_lock);
+	}
+}
+
+/*
+ * initialize ffn cache data
+ */
+static void __ip_ffn_init_cache(void)
+{
+	int i;
+
+	for (i = 0; i < FFN_CACHE_SIZE; i++)
+		INIT_LIST_HEAD(&ffn_cache[i]);
+	INIT_LIST_HEAD(&ffn_all);
+	ffn_entry_count = 0;
+}
+
+/*
+ * flush all ffn cache
+ */
+void ip_ffn_flush_all(void)
+{
+	struct ffn_lookup_entry *e, *tmp;
+
+	spin_lock_bh(&ffn_lock);
+	list_for_each_entry_safe(e, tmp, &ffn_all, all_next)
+		__ffn_remove_entry(e);
+	__ip_ffn_init_cache();
+	spin_unlock_bh(&ffn_lock);
+}
+
+#ifdef CONFIG_IP_FFN_PROCFS
+struct proc_dir_entry *proc_net_ip_ffn;
+
+static int ip_ffn_entries_show(struct seq_file *m, void *v)
+{
+	int i;
+
+	spin_lock_bh(&ffn_lock);
+
+	for (i = 0; i < FFN_CACHE_SIZE; ++i) {
+		struct ffn_lookup_entry *e;
+
+		if (list_empty(&ffn_cache[i]))
+			continue;
+
+		seq_printf(m, "Bucket %i:\n", i);
+		list_for_each_entry (e, &ffn_cache[i], next) {
+			seq_printf(m, " Protocol: ");
+			switch (e->protocol) {
+			case IPPROTO_TCP:
+				seq_printf(m, "TCPv4\n");
+				break;
+			case IPPROTO_UDP:
+				seq_printf(m, "UDPv4\n");
+				break;
+			default:
+				seq_printf(m, "ipproto_%i\n", e->protocol);
+				break;
+			}
+			seq_printf(m, " Original flow: %pI4:%u -> %pI4:%u\n",
+				   &e->sip,
+				   ntohs(e->sport),
+				   &e->dip,
+				   ntohs(e->dport));
+
+			if (e->sip != e->manip.new_sip ||
+			    e->dip != e->manip.new_dip ||
+			    e->sport != e->manip.new_sport ||
+			    e->dport != e->manip.new_dport) {
+				seq_printf(m,
+					   " Modified flow: %pI4:%u -> "
+					   "%pI4:%u\n",
+					   &e->manip.new_sip,
+					   ntohs(e->manip.new_sport),
+					   &e->manip.new_dip,
+					   ntohs(e->manip.new_dport));
+			}
+
+			seq_printf(m, "  Forwarded packets: %u\n",
+				   e->forwarded_packets);
+			seq_printf(m, "  Forwarded bytes: %llu\n",
+				   e->forwarded_bytes);
+			seq_printf(m, "\n");
+		}
+	}
+
+	spin_unlock_bh(&ffn_lock);
+	return 0;
+}
+
+static int ip_ffn_entries_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, ip_ffn_entries_show, NULL);
+}
+
+static const struct file_operations ip_ffn_entries_fops = {
+	.owner = THIS_MODULE,
+	.open	= ip_ffn_entries_open,
+	.release = single_release,
+	.read = seq_read,
+	.llseek = seq_lseek,
+};
+
+
+static int __init __ip_ffn_init_procfs(void)
+{
+	proc_net_ip_ffn = proc_net_mkdir(&init_net, "ip_ffn",
+					 init_net.proc_net);
+	if (!proc_net_ip_ffn) {
+		printk(KERN_ERR "proc_mkdir() has failed for 'net/ip_ffn'.\n");
+		return -1;
+	}
+
+	if (proc_create("entries", 0400, proc_net_ip_ffn,
+			&ip_ffn_entries_fops) == NULL) {
+		printk(KERN_ERR "proc_create() has failed for "
+		       "'net/ip_ffn/entries'.\n");
+		return -1;
+	}
+	return 0;
+}
+#endif
+
+/*
+ * initialize ffn
+ */
+void __init ip_ffn_init(void)
+{
+	printk("IP Fast Forward and NAT enabled\n");
+	__ip_ffn_init_cache();
+
+#ifdef CONFIG_IP_FFN_PROCFS
+	if (__ip_ffn_init_procfs() < 0)
+		printk(KERN_WARNING "IP FFN: unable to create proc entries.\n");
+#endif
+}
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/net/ipv6/ip6_ffn.c	2015-11-18 18:24:33.732180119 +0100
@@ -0,0 +1,631 @@
+/*
+ * IPv6 fast forwarding and NAT
+ *
+ * Very restrictive code, that only cope non fragmented UDP and TCP
+ * packets, that are routed and NATed with no other modification.
+ *
+ * Provide a fast path for established conntrack entries so that
+ * packets go out ASAP.
+ */
+
+#include <linux/tcp.h>
+#include <linux/udp.h>
+#include <linux/jhash.h>
+#include <linux/proc_fs.h>
+#include <net/netfilter/nf_conntrack.h>
+#include <net/netfilter/nf_conntrack_helper.h>
+
+#include <net/ip6_ffn.h>
+#include <net/dsfield.h>
+
+#define FFN6_CACHE_SIZE		256
+#define MAX_FFN6_ENTRY		2048
+
+DEFINE_SPINLOCK(ffn6_lock);
+static struct list_head ffn6_cache[FFN6_CACHE_SIZE];
+static struct list_head ffn6_all;
+static unsigned int ffn6_entry_count;
+
+static void __ffn6_remove_entry(struct ffn6_lookup_entry *e)
+{
+	if (e->manip.priv_destructor)
+		e->manip.priv_destructor((void *)e->manip.ffn_priv_area);
+	list_del(&e->next);
+	list_del(&e->all_next);
+	ffn6_entry_count--;
+	dst_release(e->manip.dst);
+	kfree(e);
+}
+
+/*
+ * hash on five parameter
+ */
+static inline unsigned int ffn6_hash(const u32 *sip, const u32 *dip,
+				     u16 sport, u16 dport,
+				     int is_tcp)
+{
+	return jhash_3words(sip[3], is_tcp ? dip[3] : ~dip[3],
+			    sport | dport << 16, 0);
+}
+
+/*
+ * attempt to find entry with given value in cache
+ */
+static struct ffn6_lookup_entry *__ffn6_find(const u32 *sip, const u32 *dip,
+					     u16 sport, u16 dport,
+					     u8 protocol,
+					     unsigned int hash)
+{
+	struct ffn6_lookup_entry *tmp;
+
+	list_for_each_entry(tmp, &ffn6_cache[hash % FFN6_CACHE_SIZE], next) {
+
+		/* compare entry */
+		if (!memcmp(tmp->sip, sip, 16) &&
+		    !memcmp(tmp->dip, dip, 16) &&
+		    tmp->sport == sport && tmp->dport == dport &&
+		    tmp->protocol == protocol)
+			return tmp;
+	}
+	return NULL;
+}
+
+struct ffn6_lookup_entry *__ffn6_get(const u32 *sip, const u32 *dip,
+				     u16 sport, u16 dport,
+				     int is_tcp)
+{
+	unsigned int hash;
+	u8 protocol;
+
+	/* lookup entry in cache */
+	protocol = (is_tcp) ? IPPROTO_TCP : IPPROTO_UDP;
+	hash = ffn6_hash(sip, dip, sport, dport, is_tcp);
+	return __ffn6_find(sip, dip, sport, dport, protocol, hash);
+}
+
+static int __ffn6_add_entry(struct ffn6_lookup_entry *e,
+			    u8 proto, unsigned int hash)
+{
+	/* make sure it's not present */
+	if (__ffn6_find(e->sip, e->dip, e->sport, e->dport, proto, hash))
+		return 1;
+
+	if (ffn6_entry_count >= MAX_FFN6_ENTRY)
+		return 1;
+
+	/* add new entry */
+	list_add_tail(&e->next, &ffn6_cache[hash % FFN6_CACHE_SIZE]);
+	list_add_tail(&e->all_next, &ffn6_all);
+	ffn6_entry_count++;
+	return 0;
+}
+
+/*
+ * two hooks into netfilter code
+ */
+extern int external_tcpv6_packet(struct nf_conn *ct,
+				 const struct sk_buff *skb,
+				 unsigned int dataoff,
+				 enum ip_conntrack_info ctinfo);
+
+extern int external_udpv6_packet(struct nf_conn *ct,
+				 const struct sk_buff *skb,
+				 unsigned int dataoff,
+				 enum ip_conntrack_info ctinfo);
+
+/*
+ * check if packet is in ffn cache, or mark it if it can be added
+ * later
+ */
+int ipv6_ffn_process(struct sk_buff *skb)
+{
+	struct ffn6_lookup_entry *e;
+	struct nf_conntrack *nfct;
+	struct ipv6hdr *iph;
+	struct tcphdr *tcph = NULL;
+	struct udphdr *udph = NULL;
+	bool remove_me;
+	int added_when;
+	u8 proto;
+	int res;
+
+	if (!net_eq(dev_net(skb->dev), &init_net))
+		goto not_ffnable;
+
+	iph = ipv6_hdr(skb);
+
+	/* check encapsulated protocol is udp or tcp */
+	proto = iph->nexthdr;
+	if (proto != IPPROTO_TCP && proto != IPPROTO_UDP)
+		goto not_ffnable;
+
+	if (iph->hop_limit <= 1 || !iph->payload_len)
+		goto not_ffnable;
+
+	/* TODO: implement this later, no hardware to test for now */
+	if (skb->ip_summed == CHECKSUM_PARTIAL)
+		goto not_ffnable;
+
+	proto = iph->nexthdr;
+	if (proto == IPPROTO_TCP) {
+		if (skb_headlen(skb) < sizeof (*iph) + sizeof (struct tcphdr))
+			goto not_ffnable;
+
+		tcph = (struct tcphdr *)((unsigned char *)iph + sizeof (*iph));
+
+		spin_lock_bh(&ffn6_lock);
+		e = __ffn6_get(iph->saddr.s6_addr32, iph->daddr.s6_addr32,
+			       tcph->source, tcph->dest, 1);
+	} else {
+
+		if (skb_headlen(skb) < sizeof (*iph) + sizeof (struct udphdr))
+			goto not_ffnable;
+
+		udph = (struct udphdr *)((unsigned char *)iph + sizeof (*iph));
+
+		spin_lock_bh(&ffn6_lock);
+		e = __ffn6_get(iph->saddr.s6_addr32, iph->daddr.s6_addr32,
+			       udph->source, udph->dest, 0);
+	}
+
+	if (!e) {
+		spin_unlock_bh(&ffn6_lock);
+		goto ffnable;
+	}
+
+	if (e->manip.dst->obsolete > 0) {
+		__ffn6_remove_entry(e);
+		spin_unlock_bh(&ffn6_lock);
+		goto ffnable;
+	}
+
+	nfct = &e->manip.ct->ct_general;
+	nf_conntrack_get(nfct);
+
+	remove_me = false;
+	if (proto == IPPROTO_TCP) {
+		/* do sequence number checking and update
+		 * conntrack info */
+		res = external_tcpv6_packet(e->manip.ct, skb, sizeof (*iph),
+					    e->manip.ctinfo);
+		if (e->manip.ct->proto.tcp.state != TCP_ESTABLISHED)
+			remove_me = true;
+	} else {
+		res = external_udpv6_packet(e->manip.ct, skb, sizeof (*iph),
+					    e->manip.ctinfo);
+	}
+
+	if (unlikely(res != NF_ACCEPT)) {
+		/* packet rejected by conntrack, unless asked to drop,
+		 * send it back into kernel */
+		if (remove_me)
+			__ffn6_remove_entry(e);
+
+		spin_unlock_bh(&ffn6_lock);
+		nf_conntrack_put(nfct);
+
+		if (res == NF_DROP) {
+			dev_kfree_skb(skb);
+			return 0;
+		}
+
+		goto ffnable;
+	}
+
+	if (!e->manip.alter)
+		goto fix_ip_hdr;
+
+	/* fix ports & transport protocol checksum */
+	if (proto == IPPROTO_TCP) {
+		tcph->source = e->manip.new_sport;
+		tcph->dest = e->manip.new_dport;
+		tcph->check = csum16_sub(tcph->check, e->manip.adjustment);
+	} else {
+		udph->source = e->manip.new_sport;
+		udph->dest = e->manip.new_dport;
+		if (udph->check) {
+			u16 tcheck;
+
+			tcheck = csum16_sub(udph->check, e->manip.adjustment);
+			udph->check = tcheck ? tcheck : 0xffff;
+		}
+	}
+
+	memcpy(iph->saddr.s6_addr32, e->manip.new_sip, 16);
+	memcpy(iph->daddr.s6_addr32, e->manip.new_dip, 16);
+
+fix_ip_hdr:
+	/* update IP header field */
+	iph->hop_limit--;
+	if (e->manip.tos_change)
+		ipv6_change_dsfield(iph, 0, e->manip.new_tos);
+
+	if (e->manip.force_skb_prio)
+		skb->priority = e->manip.new_skb_prio;
+	else
+		skb->priority = rt_tos2priority(ipv6_get_dsfield(iph));
+
+	skb->mark = e->manip.new_mark;
+
+#ifdef CONFIG_IPV6_FFN_PROCFS
+	e->forwarded_packets++;
+	e->forwarded_bytes += skb->len;
+#endif
+
+	skb_dst_set(skb, dst_clone(e->manip.dst));
+
+	if (nfct == skb->nfct) {
+		/*
+		 * skbs to/from localhost will have the conntrack
+		 * already set, don't leak references here.
+		 */
+		nf_conntrack_put(nfct);
+	} else {
+		if (unlikely(skb->nfct != NULL)) {
+			/*
+			 * conntrack is not NULL here and it is not
+			 * the same as the one we have in the
+			 * ffn_entry, this shoud not happen, warn once
+			 * and switch to slow path.
+			 */
+			WARN_ONCE(skb->nfct != NULL,
+				  "weird skb->nfct %p, NULL was expected\n",
+				  skb->nfct);
+			printk_once(KERN_WARNING "ffn entry:\n"
+				    " added_when: %i\n"
+				    " sip: %pI6 -> %pI6\n"
+				    " dip: %pI6 -> %pI6\n"
+				    " sport: %u -> %u\n"
+				    " dport: %u -> %u\n",
+				    e->added_when,
+				    e->sip, e->manip.new_sip,
+				    e->dip, e->manip.new_dip,
+				    htons(e->sport), htons(e->manip.new_sport),
+				    htons(e->dport), htons(e->manip.new_dport));
+			goto not_ffnable;
+		}
+		skb->nfct = nfct;
+		skb->nfctinfo = e->manip.ctinfo;
+	}
+
+	added_when = e->added_when;
+	if (remove_me)
+		__ffn6_remove_entry(e);
+	spin_unlock_bh(&ffn6_lock);
+
+	skb->ffn_state = FFN_STATE_FAST_FORWARDED;
+
+	if (added_when == IPV6_FFN_FINISH_OUT)
+		dst_output(skb);
+	else
+		ip6_input_finish(skb->sk, skb);
+
+	return 0;
+
+ffnable:
+	skb->ffn_state = FFN_STATE_FORWARDABLE;
+	skb->ffn_orig_tos = ipv6_get_dsfield(iph);
+	return 1;
+
+not_ffnable:
+	skb->ffn_state = FFN_STATE_INCOMPATIBLE;
+	return 1;
+}
+
+/*
+ *
+ */
+static inline __sum16 checksum_adjust(const u32 *osip,
+				      const u32 *nsip,
+				      const u32 *odip,
+				      const u32 *ndip,
+				      u16 osport,
+				      u16 nsport,
+				      u16 odport,
+				      u16 ndport)
+{
+	const u32 oports[] = { osport, odport };
+	const u32 nports[] = { nsport, ndport };
+	__wsum osum, nsum;
+
+	osum = csum_partial(osip, 16, 0);
+	osum = csum_partial(odip, 16, osum);
+	osum = csum_partial(oports, 8, osum);
+
+	nsum = csum_partial(nsip, 16, 0);
+	nsum = csum_partial(ndip, 16, nsum);
+	nsum = csum_partial(nports, 8, nsum);
+
+	return ~csum_fold(csum_sub(nsum, osum));
+}
+
+/*
+ * check if skb is candidate for ffn, and if so add it to ffn cache
+ *
+ * called after post routing
+ */
+void ipv6_ffn_add(struct sk_buff *skb, int when)
+{
+	struct nf_conn *ct;
+	struct nf_conntrack_tuple *tuple, *rtuple;
+	enum ip_conntrack_info ctinfo;
+	struct ffn6_lookup_entry *e;
+	struct ipv6hdr *iph;
+	unsigned int hash;
+	int dir;
+	u8 proto, tos;
+
+	if (!net_eq(dev_net(skb->dev), &init_net))
+		return;
+
+	if (ffn6_entry_count >= MAX_FFN6_ENTRY)
+		return;
+
+	iph = ipv6_hdr(skb);
+
+	if (!skb->nfct || (when == IPV6_FFN_FINISH_OUT &&
+			   skb_dst(skb)->output != ip6_output))
+		return;
+
+	if (skb->nfct == &nf_ct_untracked_get()->ct_general)
+		return;
+
+	ct = nf_ct_get(skb, &ctinfo);
+	if ((ctinfo != IP_CT_ESTABLISHED) &&
+	    (ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY))
+		return;
+
+	if (nfct_help(ct))
+		return;
+
+	dir = (ctinfo == IP_CT_ESTABLISHED) ?
+		IP_CT_DIR_ORIGINAL : IP_CT_DIR_REPLY;
+	tuple = &ct->tuplehash[dir].tuple;
+
+	if (tuple->dst.protonum != IPPROTO_TCP &&
+	    tuple->dst.protonum != IPPROTO_UDP)
+		return;
+
+	if (tuple->dst.protonum == IPPROTO_TCP &&
+	    ct->proto.tcp.state != TCP_CONNTRACK_ESTABLISHED)
+		return;
+
+	rtuple = &ct->tuplehash[1 - dir].tuple;
+
+	e = kmalloc(sizeof (*e), GFP_ATOMIC);
+	if (!e)
+		return;
+
+	e->added_when = when;
+	memcpy(e->sip, tuple->src.u3.ip6, 16);
+	memcpy(e->dip, tuple->dst.u3.ip6, 16);
+	e->sport = tuple->src.u.all;
+	e->dport = tuple->dst.u.all;
+	e->protocol = tuple->dst.protonum;
+
+#ifdef CONFIG_IPV6_FFN_PROCFS
+	e->forwarded_packets = 0;
+	e->forwarded_bytes = 0;
+#endif
+
+	memcpy(e->manip.new_sip, rtuple->dst.u3.ip6, 16);
+	memcpy(e->manip.new_dip, rtuple->src.u3.ip6, 16);
+	e->manip.new_sport = rtuple->dst.u.all;
+	e->manip.new_dport = rtuple->src.u.all;
+
+	if (!memcmp(e->manip.new_sip, e->sip, 16) &&
+	    !memcmp(e->manip.new_dip, e->dip, 16) &&
+	    e->manip.new_sport == e->sport &&
+	    e->manip.new_dport == e->dport)
+		e->manip.alter = 0;
+	else
+		e->manip.alter = 1;
+
+	if (e->manip.alter) {
+		/* compute checksum adjustement */
+		e->manip.adjustment = checksum_adjust(e->sip,
+						      e->manip.new_sip,
+						      e->dip,
+						      e->manip.new_dip,
+						      e->sport,
+						      e->manip.new_sport,
+						      e->dport,
+						      e->manip.new_dport);
+	}
+
+	tos = ipv6_get_dsfield(iph);
+	if (skb->ffn_orig_tos != tos) {
+		e->manip.tos_change = 1;
+		e->manip.new_tos = tos;
+	} else
+		e->manip.tos_change = 0;
+
+	if (skb->priority != rt_tos2priority(tos)) {
+		e->manip.force_skb_prio = 1;
+		e->manip.new_skb_prio = skb->priority;
+	} else
+		e->manip.force_skb_prio = 0;
+
+	e->manip.new_mark = skb->mark;
+	e->manip.dst = skb_dst(skb);
+	e->manip.priv_destructor = NULL;
+	dst_hold(e->manip.dst);
+	e->manip.ct = ct;
+	e->manip.ctinfo = ctinfo;
+
+	hash = ffn6_hash(e->sip, e->dip, e->sport, e->dport,
+			 e->protocol == IPPROTO_TCP);
+	proto = (e->protocol == IPPROTO_TCP) ? IPPROTO_TCP : IPPROTO_UDP;
+
+	spin_lock_bh(&ffn6_lock);
+	if (__ffn6_add_entry(e, proto, hash)) {
+		spin_unlock_bh(&ffn6_lock);
+		dst_release(e->manip.dst);
+		kfree(e);
+		return;
+	}
+	spin_unlock_bh(&ffn6_lock);
+}
+
+/*
+ * netfilter callback when conntrack is about to be destroyed
+ */
+void ipv6_ffn_ct_destroy(struct nf_conn *ct)
+{
+	struct nf_conntrack_tuple *tuple;
+	struct ffn6_lookup_entry *e;
+	int dir;
+
+	/* locate all entry that use this conntrack */
+	for (dir = 0; dir < 2; dir++) {
+		tuple = &ct->tuplehash[dir].tuple;
+
+		if (tuple->dst.protonum != IPPROTO_TCP &&
+		    tuple->dst.protonum != IPPROTO_UDP)
+			return;
+
+		spin_lock_bh(&ffn6_lock);
+		e = __ffn6_get(tuple->src.u3.ip6, tuple->dst.u3.ip6,
+			       tuple->src.u.all, tuple->dst.u.all,
+			       tuple->dst.protonum == IPPROTO_TCP);
+		if (e)
+			__ffn6_remove_entry(e);
+		spin_unlock_bh(&ffn6_lock);
+	}
+}
+
+/*
+ * initialize ffn cache data
+ */
+static void __ipv6_ffn_init_cache(void)
+{
+	int i;
+
+	for (i = 0; i < FFN6_CACHE_SIZE; i++)
+		INIT_LIST_HEAD(&ffn6_cache[i]);
+	INIT_LIST_HEAD(&ffn6_all);
+	ffn6_entry_count = 0;
+}
+
+/*
+ * flush all ffn cache
+ */
+void ipv6_ffn_flush_all(void)
+{
+	struct ffn6_lookup_entry *e, *tmp;
+
+	spin_lock_bh(&ffn6_lock);
+	list_for_each_entry_safe(e, tmp, &ffn6_all, all_next)
+		__ffn6_remove_entry(e);
+	__ipv6_ffn_init_cache();
+	spin_unlock_bh(&ffn6_lock);
+}
+
+#ifdef CONFIG_IPV6_FFN_PROCFS
+struct proc_dir_entry *proc_net_ipv6_ffn;
+
+static int ipv6_ffn_entries_show(struct seq_file *m, void *v)
+{
+	int i;
+
+	spin_lock_bh(&ffn6_lock);
+
+	for (i = 0; i < FFN6_CACHE_SIZE; ++i) {
+		struct ffn6_lookup_entry *e;
+
+		if (list_empty(&ffn6_cache[i]))
+			continue;
+
+		seq_printf(m, "Bucket %i:\n", i);
+		list_for_each_entry (e, &ffn6_cache[i], next) {
+			seq_printf(m, " Protocol: ");
+			switch (e->protocol) {
+			case IPPROTO_TCP:
+				seq_printf(m, "TCPv6\n");
+				break;
+			case IPPROTO_UDP:
+				seq_printf(m, "UDPv6\n");
+				break;
+			default:
+				seq_printf(m, "ipproto_%i\n", e->protocol);
+				break;
+			}
+
+			seq_printf(m, " Original flow: %pI6:%u -> %pI6:%u\n",
+				   e->sip,
+				   ntohs(e->sport),
+				   e->dip,
+				   ntohs(e->dport));
+
+			if (memcmp(e->sip, e->manip.new_sip, 16) ||
+			    memcmp(e->dip, e->manip.new_dip, 16) ||
+			    e->sport != e->manip.new_sport ||
+			    e->dport != e->manip.new_dport) {
+				seq_printf(m,
+					   " Modified flow: %pI6:%u -> "
+					   "%pI6:%u\n",
+					   e->manip.new_sip,
+					   ntohs(e->manip.new_sport),
+					   e->manip.new_dip,
+					   ntohs(e->manip.new_dport));
+			}
+
+			seq_printf(m, "  Forwarded packets: %u\n",
+				   e->forwarded_packets);
+			seq_printf(m, "  Forwarded bytes: %llu\n",
+				   e->forwarded_bytes);
+			seq_printf(m, "\n");
+		}
+	}
+
+	spin_unlock_bh(&ffn6_lock);
+	return 0;
+}
+
+static int ipv6_ffn_entries_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, ipv6_ffn_entries_show, NULL);
+}
+
+static const struct file_operations ipv6_ffn_entries_fops = {
+	.owner = THIS_MODULE,
+	.open	= ipv6_ffn_entries_open,
+	.release = single_release,
+	.read = seq_read,
+	.llseek = seq_lseek,
+};
+
+
+static int __init __ipv6_ffn_init_procfs(void)
+{
+	proc_net_ipv6_ffn = proc_net_mkdir(&init_net, "ipv6_ffn",
+					 init_net.proc_net);
+	if (!proc_net_ipv6_ffn) {
+		printk(KERN_ERR "proc_mkdir() has failed "
+		       "for 'net/ipv6_ffn'.\n");
+		return -1;
+	}
+
+	if (proc_create("entries", 0400, proc_net_ipv6_ffn,
+			&ipv6_ffn_entries_fops) == NULL) {
+		printk(KERN_ERR "proc_create() has failed for "
+		       "'net/ipv6_ffn/entries'.\n");
+		return -1;
+	}
+	return 0;
+}
+#endif
+
+/*
+ * initialize ffn
+ */
+void __init ipv6_ffn_init(void)
+{
+	printk("IPv6 Fast Forward and NAT enabled\n");
+	__ipv6_ffn_init_cache();
+
+#ifdef CONFIG_IPV6_FFN_PROCFS
+	if (__ipv6_ffn_init_procfs() < 0)
+		printk(KERN_WARNING "IPv6 FFN: unable to create proc entries.\n");
+#endif
+}
--- /dev/null	2014-07-28 16:39:28.978429694 +0200
+++ linux-4.2.6-fbx/sound/soc/kirkwood/kirkwood-fbxgw2r.c	2015-11-18 18:24:34.144183382 +0100
@@ -0,0 +1,247 @@
+/*
+ * kirkwood-fbxgw2r.c
+ *
+ * Modified-from: kirkwood-rd88f6282a.c, which was before
+ * Modified-from: kirkwood-openrd.c
+ * Which is:
+ * (c) 2010 Arnaud Patard <apatard@mandriva.com>
+ * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
+ *
+ *  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 <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <sound/soc.h>
+#include <asm/mach-types.h>
+#include "../codecs/cs42l52.h"
+
+#if 0
+static void dump_registers(struct snd_soc_codec *codec)
+{
+	int i;
+
+	for (i = 0; i < 0x40; ++i) {
+		int val = snd_soc_read(codec, i);
+		if (val < 0)
+			printk("%02x: <unreadable (you're drunk)>\n", i);
+		else
+			printk("%02x: %02x\n", i, val);
+	}
+}
+#endif
+
+static int fbxgw2r_dai_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_codec *codec = rtd->codec;
+	u8 reg;
+
+#if 0
+	printk("Default register configuration:\n");
+	dump_registers(codec);
+#endif
+
+	/*
+	 * make sure we correctly transition from speaker to headphone
+	 * and vice&versa.
+	 */
+	snd_soc_write(codec, 0x4, 0x05);
+
+	/*
+	 * select input4a/input4b for capture
+	 */
+	reg = snd_soc_read(codec, 0x8);
+	reg &= ~(7 << 5);
+	reg |= (3 << 5);
+	snd_soc_write(codec, 0x8, reg);
+
+	reg = snd_soc_read(codec, 0x9);
+	reg &= ~(7 << 5);
+	reg |= (3 << 5);
+	snd_soc_write(codec, 0x9, reg);
+
+	/*
+	 * set headphone analog gain to 1.000
+	 */
+	reg = snd_soc_read(codec, 0x0d);
+	reg &= ~0xe0;
+	reg |= 0xc0;
+	snd_soc_write(codec, 0x0d, reg);
+
+	return 0;
+}
+
+static int fbxgw2r_hw_params(struct snd_pcm_substream *substream,
+		struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	int ret;
+	unsigned int fmt;
+	int freq = 0;
+
+	fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS;
+	ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
+	if (ret < 0)
+		return ret;
+	ret = snd_soc_dai_set_fmt(codec_dai, fmt);
+	if (ret < 0)
+		return ret;
+
+
+	switch (params_rate(params)) {
+	default:
+	case 44100:
+		freq = 11289600;
+		break;
+	case 96000:
+	case 48000:
+		freq = 12288000;
+		break;
+	}
+
+	return snd_soc_dai_set_sysclk(codec_dai, 0, freq, SND_SOC_CLOCK_IN);
+}
+
+static int fbxgw2r_startup(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_codec *codec = rtd->codec_dai->codec;
+
+	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+		u8 reg;
+
+		/*
+		 * power up ADC A & B
+		 */
+		reg = snd_soc_read(codec, 0x2);
+		reg &= ~(3 << 1);
+		snd_soc_write(codec, 0x2, reg);
+
+		/*
+		 * unmute ADC A mixer volume
+		 */
+		reg = snd_soc_read(codec, 0x18);
+		reg &= ~(1 << 7);
+		snd_soc_write(codec, 0x18, reg);
+
+		/*
+		 * unmute ADC B mixer volume
+		 */
+		reg = snd_soc_read(codec, 0x19);
+		reg &= ~(1 << 7);
+		snd_soc_write(codec, 0x19, reg);
+	}
+
+#if 0
+	dump_registers(codec);
+#endif
+	return 0;
+}
+
+static void fbxgw2r_shutdown(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_codec *codec = rtd->codec_dai->codec;
+
+	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+		u8 reg;
+
+		/*
+		 * power down ADC A & B
+		 */
+		reg = snd_soc_read(codec, 0x2);
+		reg |= (3 << 1);
+		snd_soc_write(codec, 0x2, reg);
+
+		/*
+		 * mute ADC A mixer volume
+		 */
+		reg = snd_soc_read(codec, 0x18);
+		reg |= (1 << 7);
+		snd_soc_write(codec, 0x18, reg);
+
+		/*
+		 * mute ADC B mixer volume
+		 */
+		reg = snd_soc_read(codec, 0x19);
+		reg |= (1 << 7);
+		snd_soc_write(codec, 0x19, reg);
+	}
+}
+
+static struct snd_soc_ops fbxgw2r_ops = {
+	.hw_params = fbxgw2r_hw_params,
+	.startup = fbxgw2r_startup,
+	.shutdown = fbxgw2r_shutdown,
+};
+
+static struct snd_soc_dai_link fbxgw2r_dai[] = {
+	{
+		.name = "CS42L52",
+		.stream_name = "CS42L52 HiFi",
+		.cpu_name = "mvebu-audio",
+		.cpu_dai_name = "i2s",
+		.platform_name = "mvebu-audio",
+		.codec_dai_name = "cs42l52",
+		.codec_name = "cs42l52.1-004a",
+		.ops = &fbxgw2r_ops,
+		.init = fbxgw2r_dai_init,
+	},
+};
+
+
+static struct snd_soc_card fbxgw2r = {
+	.name = "FBXGW2R",
+	.dai_link = fbxgw2r_dai,
+	.num_links = ARRAY_SIZE(fbxgw2r_dai),
+};
+
+static int fbxgw2r_probe(struct platform_device *pdev)
+{
+	struct snd_soc_card *card = &fbxgw2r;
+
+	card->dev = &pdev->dev;
+	return snd_soc_register_card(card);
+}
+
+static int fbxgw2r_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+
+	return snd_soc_unregister_card(card);
+}
+
+struct platform_driver fbxgw2r_driver = {
+	.driver = {
+		.name = "fbxgw2r-audio",
+		.owner = THIS_MODULE,
+	},
+	.probe = fbxgw2r_probe,
+	.remove = fbxgw2r_remove,
+};
+
+static int __init fbxgw2r_init(void)
+{
+	return platform_driver_register(&fbxgw2r_driver);
+}
+
+static void __exit fbxgw2r_exit(void)
+{
+	platform_driver_unregister(&fbxgw2r_driver);
+}
+
+module_init(fbxgw2r_init);
+module_exit(fbxgw2r_exit);
+
+/* Module information */
+MODULE_DESCRIPTION("ALSA SoC FBXGW2R Client");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:soc-audio");
diff -Nruw linux-4.2.6-fbx/tools/lguest/include./linux/virtio_types.h linux-4.2.6-fbx/tools/lguest/include/linux/virtio_types.h
--- linux-4.2.6-fbx/tools/lguest/include./linux/virtio_types.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-4.2.6-fbx/tools/lguest/include/linux/virtio_types.h	2015-11-18 18:24:33.472178064 +0100
@@ -0,0 +1,46 @@
+#ifndef _UAPI_LINUX_VIRTIO_TYPES_H
+#define _UAPI_LINUX_VIRTIO_TYPES_H
+/* Type definitions for virtio implementations.
+ *
+ * This header is BSD licensed so anyone can use the definitions to implement
+ * compatible drivers/servers.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of IBM nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Copyright (C) 2014 Red Hat, Inc.
+ * Author: Michael S. Tsirkin <mst@redhat.com>
+ */
+#include <linux/types.h>
+
+/*
+ * __virtio{16,32,64} have the following meaning:
+ * - __u{16,32,64} for virtio devices in legacy mode, accessed in native endian
+ * - __le{16,32,64} for standard-compliant virtio devices
+ */
+
+typedef __u16 __bitwise__ __virtio16;
+typedef __u32 __bitwise__ __virtio32;
+typedef __u64 __bitwise__ __virtio64;
+
+#endif /* _UAPI_LINUX_VIRTIO_TYPES_H */
