diff -ruw linux-5.4.60/arch/arm/boot/dts/kirkwood-6282.dtsi linux-5.4.60-fbx/arch/arm/boot/dts/kirkwood-6282.dtsi
--- linux-5.4.60/arch/arm/boot/dts/kirkwood-6282.dtsi	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/boot/dts/kirkwood-6282.dtsi	2021-03-04 13:20:56.844172180 +0100
@@ -80,6 +80,11 @@
 				marvell,function = "twsi1";
 			};
 
+			pmx_twsi1_gpio: pmx-twsi1-gpio {
+				marvell,pins = "mpp36", "mpp37";
+				marvell,function = "gpio";
+			};
+
 			pmx_sdio: pmx-sdio {
 				marvell,pins = "mpp12", "mpp13", "mpp14",
 					       "mpp15", "mpp16", "mpp17";
@@ -109,7 +114,10 @@
 			clock-frequency = <100000>;
 			clocks = <&gate_clk 7>;
 			pinctrl-0 = <&pmx_twsi1>;
-			pinctrl-names = "default";
+			pinctrl-1 = <&pmx_twsi1_gpio>;
+			pinctrl-names = "default", "gpio";
+			sda-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
+			scl-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
 			status = "disabled";
 		};
 
diff -ruw linux-5.4.60/arch/arm/boot/dts/kirkwood.dtsi linux-5.4.60-fbx/arch/arm/boot/dts/kirkwood.dtsi
--- linux-5.4.60/arch/arm/boot/dts/kirkwood.dtsi	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/boot/dts/kirkwood.dtsi	2021-03-04 13:20:56.847505513 +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_twsi0_gpio: pmx-twsi0-gpio {
+				marvell,pins = "mpp8", "mpp9";
+				marvell,function = "gpio";
+			};
+
 			/*
 			 * Default UART pinctrl setting without RTS/CTS,
 			 * overwrite marvell,pins on board level if required.
@@ -138,6 +155,17 @@
 			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";
+			status = "disabled";
+		};
+
 		gpio0: gpio@10100 {
 			compatible = "marvell,orion-gpio";
 			#gpio-cells = <2>;
@@ -171,7 +199,10 @@
 			clock-frequency = <100000>;
 			clocks = <&gate_clk 7>;
 			pinctrl-0 = <&pmx_twsi0>;
-			pinctrl-names = "default";
+			pinctrl-1 = <&pmx_twsi0_gpio>;
+			pinctrl-names = "default", "gpio";
+			sda-gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
+			scl-gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
 			status = "disabled";
 		};
 
@@ -319,6 +350,7 @@
 			clocks = <&gate_clk 0>;
 			marvell,tx-checksum-limit = <1600>;
 			status = "disabled";
+			mdio-bus = <&mdio>;
 
 			eth0port: ethernet0-port@0 {
 				compatible = "marvell,kirkwood-eth-port";
diff -ruw linux-5.4.60/arch/arm/boot/dts/Makefile linux-5.4.60-fbx/arch/arm/boot/dts/Makefile
--- linux-5.4.60/arch/arm/boot/dts/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/boot/dts/Makefile	2021-03-04 13:20:56.790838844 +0100
@@ -128,7 +128,9 @@
 	bcm47189-tenda-ac9.dtb \
 	bcm947189acdbmr.dtb
 dtb-$(CONFIG_ARCH_BCM_63XX) += \
-	bcm963138dvt.dtb
+	bcm963138dvt.dtb \
+	bcm963138ref-rnc.dtb \
+	fbxgw7a.dtb
 dtb-$(CONFIG_ARCH_BCM_CYGNUS) += \
 	bcm911360_entphn.dtb \
 	bcm911360k.dtb \
@@ -238,7 +240,7 @@
 	keystone-k2e-evm.dtb \
 	keystone-k2g-evm.dtb \
 	keystone-k2g-ice.dtb
-dtb-$(CONFIG_MACH_KIRKWOOD) += \
+dtb-$(CONFIG_MACH_KIRKWOOD_DTB) += \
 	kirkwood-b3.dtb \
 	kirkwood-blackarmor-nas220.dtb \
 	kirkwood-cloudbox.dtb \
@@ -315,6 +317,8 @@
 	kirkwood-ts219-6282.dtb \
 	kirkwood-ts419-6281.dtb \
 	kirkwood-ts419-6282.dtb
+dtb-$(CONFIG_FBXGW_COMMON) += \
+	fbxgwr_exp_stb.dtb
 dtb-$(CONFIG_ARCH_LPC18XX) += \
 	lpc4337-ciaa.dtb \
 	lpc4350-hitex-eval.dtb \
@@ -1303,3 +1307,17 @@
 	aspeed-bmc-opp-zaius.dtb \
 	aspeed-bmc-portwell-neptune.dtb \
 	aspeed-bmc-quanta-q71l.dtb
+
+$(foreach file, $(subst $\",,$(CONFIG_OF_DTB_BUILTIN_LIST)), \
+		$(eval dtb-y += $(file).dtb))
+
+$(foreach file, $(subst $\",,$(CONFIG_OF_DTB_BUILTIN_LIST)), \
+		$(eval obj-y += $(file).dtb.o))
+
+dtstree		:= $(srctree)/$(src)
+dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts))
+
+DTC_FLAGS	+= -@
+always		:= $(dtb-y)
+clean-files	:= *.dtb *.dtb.S
+obj-		+= dummy
diff -ruw linux-5.4.60/arch/arm/include/uapi/asm/setup.h linux-5.4.60-fbx/arch/arm/include/uapi/asm/setup.h
--- linux-5.4.60/arch/arm/include/uapi/asm/setup.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/include/uapi/asm/setup.h	2021-03-04 13:20:56.907505517 +0100
@@ -144,6 +144,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 {
@@ -166,6 +197,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-5.4.60/arch/arm/Kconfig linux-5.4.60-fbx/arch/arm/Kconfig
--- linux-5.4.60/arch/arm/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/Kconfig	2021-03-30 15:36:01.931685377 +0200
@@ -1724,6 +1724,10 @@
 	help
 	  Include support for flattened device tree machine descriptions.
 
+config DT_OVERRIDE_BUILTIN
+	bool "override given DTB with built-in DTB if compat matches"
+	depends on OF
+
 config ATAGS
 	bool "Support for the traditional ATAGS boot data passing" if USE_OF
 	default y
@@ -1741,6 +1745,10 @@
 	  This was deprecated in 2001 and announced to live on for 5 years.
 	  Some old boot loaders still use this way.
 
+config DT_FROM_MACHTYPE
+	bool "lookup kernel built-in DTB from ATAGS machtype"
+	depends on OF && ATAGS
+
 # Compressed boot loader in ROM.  Yes, we really want to ask about
 # TEXT and BSS so we preserve their values in the config files.
 config ZBOOT_ROM_TEXT
diff -ruw linux-5.4.60/arch/arm/kernel/atags_parse.c linux-5.4.60-fbx/arch/arm/kernel/atags_parse.c
--- linux-5.4.60/arch/arm/kernel/atags_parse.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/kernel/atags_parse.c	2021-03-04 13:20:56.907505517 +0100
@@ -22,11 +22,13 @@
 #include <linux/screen_info.h>
 #include <linux/memblock.h>
 #include <uapi/linux/mount.h>
+#include <linux/of_fdt.h>
 
 #include <asm/setup.h>
 #include <asm/system_info.h>
 #include <asm/page.h>
 #include <asm/mach/arch.h>
+#include <asm/prom.h>
 
 #include "atags.h"
 
@@ -175,15 +177,70 @@
 			tag->hdr.tag = ATAG_NONE;
 }
 
+/*
+ * lookup into built-in list of machine DT to find machine with the
+ * given machtype
+ */
+static int
+find_matching_builtin_dt(unsigned int machtype,
+			 phys_addr_t *dt_pointer)
+{
+#ifdef CONFIG_DT_FROM_MACHTYPE
+	char compat_string[32];
+	const void *blob;
+
+	sprintf(compat_string, "arm-machtype,%u", machtype);
+	blob = of_fdt_find_compatible_dtb(compat_string);
+	if (blob) {
+		*dt_pointer = virt_to_phys(blob);
+		return 0;
+	}
+#endif
+	return 1;
+}
+
 const struct machine_desc * __init
 setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
 {
 	struct tag *tags = (struct tag *)&default_tags;
 	const struct machine_desc *mdesc = NULL, *p;
 	char *from = default_command_line;
+	phys_addr_t builtin_dt;
 
 	default_tags.mem.start = PHYS_OFFSET;
 
+	if (!find_matching_builtin_dt(machine_nr, &builtin_dt)) {
+		if (__atags_pointer) {
+			tags = phys_to_virt(__atags_pointer);
+
+			if (tags->hdr.tag == ATAG_CORE) {
+				struct tag *tag;
+
+				/* remove all tags that we expect DT to
+				 * override */
+				for (; tag->hdr.size; tag = tag_next(tag)) {
+					switch (tag->hdr.tag) {
+					case ATAG_MEM:
+					case ATAG_CORE:
+					case ATAG_SERIAL:
+					case ATAG_REVISION:
+					case ATAG_CMDLINE:
+						tag->hdr.tag = ATAG_NONE;
+						break;
+
+					default:
+						break;
+					}
+				}
+
+				save_atags(tags);
+				parse_tags(tags);
+			}
+		}
+
+		return setup_machine_fdt(builtin_dt);
+	}
+
 	/*
 	 * locate machine in the list of supported machines.
 	 */
diff -ruw linux-5.4.60/arch/arm/kernel/devtree.c linux-5.4.60-fbx/arch/arm/kernel/devtree.c
--- linux-5.4.60/arch/arm/kernel/devtree.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/kernel/devtree.c	2021-03-04 13:20:56.907505517 +0100
@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/memblock.h>
+#include <linux/libfdt.h>
 #include <linux/of.h>
 #include <linux/of_fdt.h>
 #include <linux/of_irq.h>
@@ -201,6 +202,37 @@
 	return m;
 }
 
+/*
+ * lookup into built-in list of DTB to find one with the same compat
+ * string as the given blob
+ */
+static const void *find_matching_builtin_dt(const void *blob)
+{
+	const char *cp;
+	int cplen;
+
+	cp = fdt_getprop(blob, 0, "compatible", &cplen);
+	if (cp == NULL)
+		return NULL;
+
+	while (cplen > 0) {
+		const void *builtin_blob;
+		unsigned long l;
+
+		builtin_blob = of_fdt_find_compatible_dtb(cp);
+		if (builtin_blob) {
+			pr_notice("overriding given DTB with "
+				  "builtin one => '%s'", cp);
+			return builtin_blob;
+		}
+
+		l = strlen(cp) + 1;
+		cp += l;
+		cplen -= l;
+	}
+	return NULL;
+}
+
 /**
  * setup_machine_fdt - Machine setup when an dtb was passed to the kernel
  * @dt_phys: physical address of dt blob
@@ -224,6 +256,14 @@
 	if (!dt_phys || !early_init_dt_verify(phys_to_virt(dt_phys)))
 		return NULL;
 
+	if (IS_ENABLED(CONFIG_DT_OVERRIDE_BUILTIN)) {
+		const void *builtin_blob;
+
+		builtin_blob = find_matching_builtin_dt(phys_to_virt(dt_phys));
+		if (builtin_blob)
+			early_init_dt_verify((void *)builtin_blob);
+	}
+
 	mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach);
 
 	if (!mdesc) {
diff -ruw linux-5.4.60/arch/arm/mach-bcm/Kconfig linux-5.4.60-fbx/arch/arm/mach-bcm/Kconfig
--- linux-5.4.60/arch/arm/mach-bcm/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/mach-bcm/Kconfig	2021-03-04 13:20:56.917505516 +0100
@@ -200,6 +200,7 @@
 	select HAVE_ARM_TWD if SMP
 	select HAVE_ARM_SCU if SMP
 	select HAVE_SMP
+	select PINCTRL
 	help
 	  This enables support for systems based on Broadcom DSL SoCs.
 	  It currently supports the 'BCM63XX' ARM-based family, which includes
diff -ruw linux-5.4.60/arch/arm/mach-bcm/Makefile linux-5.4.60-fbx/arch/arm/mach-bcm/Makefile
--- linux-5.4.60/arch/arm/mach-bcm/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/mach-bcm/Makefile	2021-03-04 13:20:56.917505516 +0100
@@ -58,7 +58,7 @@
 # BCM63XXx
 ifeq ($(CONFIG_ARCH_BCM_63XX),y)
 obj-y				+= bcm63xx.o
-obj-$(CONFIG_SMP)		+= bcm63xx_smp.o bcm63xx_pmb.o
+obj-$(CONFIG_SMP)		+= bcm63xx_smp.o
 endif
 
 ifeq ($(CONFIG_ARCH_BRCMSTB),y)
diff -ruw linux-5.4.60/arch/arm/mach-mvebu/Kconfig linux-5.4.60-fbx/arch/arm/mach-mvebu/Kconfig
--- linux-5.4.60/arch/arm/mach-mvebu/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/mach-mvebu/Kconfig	2021-03-04 13:20:56.937505517 +0100
@@ -132,4 +132,35 @@
 	  Say 'Y' here if you want your kernel to support boards based
 	  on the Marvell Kirkwood device tree.
 
+config MACH_KIRKWOOD_DTB
+	bool "build kirkwood DTB"
+
+config FBXGW_COMMON
+	bool
+	select ARCH_HAS_FBXSERIAL
+	select RESET_CONTROLLER
+
+config MACH_FBXGW2R
+	bool "Freebox FBXGW2R"
+	select FBXSERIAL
+	select FBXGW_COMMON
+
+config MACH_FBXGW1R
+	bool "Freebox FBXGW1R"
+	select FBXSERIAL
+	select FBXGW_COMMON
+	select GPIOLIB
+
+if FBXGW_COMMON
+
+config FBXGW_COMMON_ETHSW
+	bool "initialize ethernet switch"
+
+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-5.4.60/arch/arm/mach-mvebu/kirkwood.c linux-5.4.60-fbx/arch/arm/mach-mvebu/kirkwood.c
--- linux-5.4.60/arch/arm/mach-mvebu/kirkwood.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/mach-mvebu/kirkwood.c	2021-03-04 13:20:56.937505517 +0100
@@ -22,6 +22,7 @@
 #include <asm/hardware/cache-feroceon-l2.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
+#include "mvebu-soc-id.h"
 #include "kirkwood.h"
 #include "kirkwood-pm.h"
 #include "common.h"
@@ -156,15 +157,67 @@
 	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 */ }
 };
 
+extern void fbxgw1r_init(void);
+extern void fbxgw2r_init(void);
+
 static void __init kirkwood_dt_init(void)
 {
 	kirkwood_disable_mbus_error_propagation();
+	kirkwood_fe_misc_120();
 
 	BUG_ON(mvebu_mbus_dt_init(false));
 
@@ -178,9 +231,25 @@
 	kirkwood_dt_eth_fixup();
 
 	of_platform_default_populate(NULL, auxdata, NULL);
+
+#ifdef CONFIG_MACH_FBXGW1R
+	if (of_machine_is_compatible("freebox,fbxgw1r"))
+		fbxgw1r_init();
+#endif
+
+#ifdef CONFIG_MACH_FBXGW2R
+	if (of_machine_is_compatible("freebox,fbxgw2r"))
+		fbxgw2r_init();
+#endif
 }
 
 static const char * const kirkwood_dt_board_compat[] __initconst = {
+#ifdef CONFIG_MACH_FBXGW1R
+	"freebox,fbxgw1r",
+#endif
+#ifdef CONFIG_MACH_FBXGW2R
+	"freebox,fbxgw2r",
+#endif
 	"marvell,kirkwood",
 	NULL
 };
@@ -190,4 +259,5 @@
 	.init_machine	= kirkwood_dt_init,
 	.restart	= mvebu_restart,
 	.dt_compat	= kirkwood_dt_board_compat,
+	.map_io		= kirkwood_map_io,
 MACHINE_END
diff -ruw linux-5.4.60/arch/arm/mach-mvebu/kirkwood.h linux-5.4.60-fbx/arch/arm/mach-mvebu/kirkwood.h
--- linux-5.4.60/arch/arm/mach-mvebu/kirkwood.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/mach-mvebu/kirkwood.h	2021-03-04 13:20:56.937505517 +0100
@@ -20,3 +20,5 @@
 
 #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)
diff -ruw linux-5.4.60/arch/arm/mach-mvebu/Makefile linux-5.4.60-fbx/arch/arm/mach-mvebu/Makefile
--- linux-5.4.60/arch/arm/mach-mvebu/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/mach-mvebu/Makefile	2021-03-04 13:20:56.937505517 +0100
@@ -18,4 +18,7 @@
 ifeq ($(CONFIG_MACH_KIRKWOOD),y)
 obj-y				 += kirkwood.o
 obj-$(CONFIG_PM)		 += kirkwood-pm.o
+obj-$(CONFIG_FBXGW_COMMON)	 += fbxgw-common.o fbxgw-rst.o
+obj-$(CONFIG_FBXGW_COMMON_ETHSW) += fbxgw-switch.o
+obj-$(CONFIG_MACH_FBXGW1R)	 += fbxgw1r-gpio-sr.o
 endif
diff -ruw linux-5.4.60/arch/arm/Makefile linux-5.4.60-fbx/arch/arm/Makefile
--- linux-5.4.60/arch/arm/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/Makefile	2021-03-04 13:20:56.790838844 +0100
@@ -318,6 +318,11 @@
 	$(eval GCC_PLUGINS_CFLAGS += $(SSP_PLUGIN_CFLAGS))
 endif
 
+ifeq ($(CONFIG_USE_OF),y)
+# add builtin-dtb into kernel binary
+core-y			 	+= arch/arm/boot/dts/
+endif
+
 all:	$(notdir $(KBUILD_IMAGE))
 
 
diff -ruw linux-5.4.60/arch/arm/mm/dma-mapping.c linux-5.4.60-fbx/arch/arm/mm/dma-mapping.c
--- linux-5.4.60/arch/arm/mm/dma-mapping.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/arch/arm/mm/dma-mapping.c	2021-03-04 13:20:56.987505520 +0100
@@ -522,6 +522,7 @@
 
 		*ret_page = phys_to_page(phys);
 		ptr = (void *)val;
+		memset(ptr, 0, size);
 	}
 
 	return ptr;
@@ -959,6 +960,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-5.4.60/block/blk-core.c linux-5.4.60-fbx/block/blk-core.c
--- linux-5.4.60/block/blk-core.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/block/blk-core.c	2021-03-04 13:20:57.497505542 +0100
@@ -1319,7 +1319,7 @@
 	}
 }
 
-void blk_account_io_done(struct request *req, u64 now)
+void blk_account_io_done(struct request *req, u64 now, blk_status_t error)
 {
 	/*
 	 * Account IO completion.  flush_rq isn't accounted as a
@@ -1333,6 +1333,10 @@
 		part_stat_lock();
 		part = req->part;
 
+		if (error) {
+			int rw = rq_data_dir(req);
+			part_stat_inc(part, io_errors[rw]);
+		}
 		update_io_ticks(part, jiffies);
 		part_stat_inc(part, ios[sgrp]);
 		part_stat_add(part, nsecs[sgrp], now - req->start_time_ns);
diff -ruw linux-5.4.60/block/blk-flush.c linux-5.4.60-fbx/block/blk-flush.c
--- linux-5.4.60/block/blk-flush.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/block/blk-flush.c	2021-03-04 13:20:57.497505542 +0100
@@ -165,10 +165,21 @@
 	rq->flush.seq |= seq;
 	cmd_flags = rq->cmd_flags;
 
-	if (likely(!error))
+	if (likely(!error)) {
 		seq = blk_flush_cur_seq(rq);
-	else
+	} else {
 		seq = REQ_FSEQ_DONE;
+		printk_once(KERN_ERR "%s: flush failed: data integrity problem\n",
+				   rq->rq_disk ? rq->rq_disk->disk_name : "?");
+		/*
+		 * returning an error to the FS is wrong: the data is all
+		 * there, it just might not be written out in the expected
+		 * order and thus have a window where the integrity is suspect
+		 * in a crash.  Given the small likelihood of actually
+		 * crashing, we should just log a warning here.
+		 */
+		error = 0;
+	}
 
 	switch (seq) {
 	case REQ_FSEQ_PREFLUSH:
diff -ruw linux-5.4.60/block/blk.h linux-5.4.60-fbx/block/blk.h
--- linux-5.4.60/block/blk.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/block/blk.h	2021-03-04 13:20:57.500838876 +0100
@@ -187,7 +187,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, u64 now);
+void blk_account_io_done(struct request *req, u64 now, blk_status_t error);
 
 /*
  * Internal elevator interface
diff -ruw linux-5.4.60/block/blk-mq.c linux-5.4.60-fbx/block/blk-mq.c
--- linux-5.4.60/block/blk-mq.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/block/blk-mq.c	2021-03-04 13:20:57.497505542 +0100
@@ -552,7 +552,7 @@
 	if (rq->internal_tag != -1)
 		blk_mq_sched_completed_request(rq, now);
 
-	blk_account_io_done(rq, now);
+	blk_account_io_done(rq, now, error);
 
 	if (rq->end_io) {
 		rq_qos_done(rq->q, rq);
diff -ruw linux-5.4.60/block/partition-generic.c linux-5.4.60-fbx/block/partition-generic.c
--- linux-5.4.60/block/partition-generic.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/block/partition-generic.c	2021-03-04 13:20:57.500838876 +0100
@@ -128,6 +128,7 @@
 		"%8lu %8lu %8llu %8u "
 		"%8u %8u %8u "
 		"%8lu %8lu %8llu %8u"
+		"%8lu %lu"
 		"\n",
 		part_stat_read(p, ios[STAT_READ]),
 		part_stat_read(p, merges[STAT_READ]),
@@ -143,7 +144,9 @@
 		part_stat_read(p, ios[STAT_DISCARD]),
 		part_stat_read(p, merges[STAT_DISCARD]),
 		(unsigned long long)part_stat_read(p, sectors[STAT_DISCARD]),
-		(unsigned int)part_stat_read_msecs(p, STAT_DISCARD));
+		(unsigned int)part_stat_read_msecs(p, STAT_DISCARD),
+		part_stat_read(p, io_errors[READ]),
+		part_stat_read(p, io_errors[WRITE]));
 }
 
 ssize_t part_inflight_show(struct device *dev, struct device_attribute *attr,
@@ -345,7 +348,7 @@
 		queue_limit_discard_alignment(&disk->queue->limits, start);
 	p->nr_sects = len;
 	p->partno = partno;
-	p->policy = get_disk_ro(disk);
+	p->policy = get_disk_ro(disk) || (flags & ADDPART_FLAG_RO);
 
 	if (info) {
 		struct partition_meta_info *pinfo = alloc_part_info(disk);
diff -ruw linux-5.4.60/block/partitions/check.c linux-5.4.60-fbx/block/partitions/check.c
--- linux-5.4.60/block/partitions/check.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/block/partitions/check.c	2021-03-04 13:20:57.500838876 +0100
@@ -24,6 +24,7 @@
 #include "acorn.h"
 #include "amiga.h"
 #include "atari.h"
+#include "dt.h"
 #include "ldm.h"
 #include "mac.h"
 #include "msdos.h"
@@ -40,6 +41,10 @@
 int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
 
 static int (*check_part[])(struct parsed_partitions *) = {
+#ifdef CONFIG_OF_PARTITION
+	dt_partition,
+#endif
+
 	/*
 	 * Probe partition formats with tables at disk address 0
 	 * that also have an ADFS boot block at 0xdc0.
diff -ruw linux-5.4.60/block/partitions/Kconfig linux-5.4.60-fbx/block/partitions/Kconfig
--- linux-5.4.60/block/partitions/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/block/partitions/Kconfig	2021-03-04 13:20:57.500838876 +0100
@@ -268,3 +268,11 @@
 	help
 	  Say Y here if you want to read the partition table from bootargs.
 	  The format for the command line is just like mtdparts.
+
+config OF_PARTITION
+	bool "Device tree partition support" if PARTITION_ADVANCED
+	depends on OF
+
+config OF_PARTITION_IGNORE_RO
+	bool "ignore read-only flag"
+	depends on OF_PARTITION
diff -ruw linux-5.4.60/block/partitions/Makefile linux-5.4.60-fbx/block/partitions/Makefile
--- linux-5.4.60/block/partitions/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/block/partitions/Makefile	2021-03-04 13:20:57.500838876 +0100
@@ -21,3 +21,4 @@
 obj-$(CONFIG_EFI_PARTITION) += efi.o
 obj-$(CONFIG_KARMA_PARTITION) += karma.o
 obj-$(CONFIG_SYSV68_PARTITION) += sysv68.o
+obj-$(CONFIG_OF_PARTITION) += dt.o
diff -ruw linux-5.4.60/drivers/ata/libata-core.c linux-5.4.60-fbx/drivers/ata/libata-core.c
--- linux-5.4.60/drivers/ata/libata-core.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/ata/libata-core.c	2021-03-04 13:20:57.567505546 +0100
@@ -4478,6 +4478,8 @@
 	   SD7SN6S256G and SD8SN8U256G */
 	{ "SanDisk SD[78]SN*G",	NULL,		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-5.4.60/drivers/ata/libata-scsi.c linux-5.4.60-fbx/drivers/ata/libata-scsi.c
--- linux-5.4.60/drivers/ata/libata-scsi.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/ata/libata-scsi.c	2021-03-04 13:20:57.570838879 +0100
@@ -4556,7 +4556,8 @@
 		 */
 		shost->max_host_blocked = 1;
 
-		rc = scsi_add_host_with_dma(shost, &ap->tdev, ap->host->dev);
+		rc = scsi_add_host_with_dma(shost,
+					    host->dev, host->dev);
 		if (rc)
 			goto err_alloc;
 	}
diff -ruw linux-5.4.60/drivers/base/property.c linux-5.4.60-fbx/drivers/base/property.c
--- linux-5.4.60/drivers/base/property.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/base/property.c	2021-03-04 13:20:57.590838880 +0100
@@ -17,6 +17,7 @@
 #include <linux/property.h>
 #include <linux/etherdevice.h>
 #include <linux/phy.h>
+#include <linux/fbxserial.h>
 
 struct fwnode_handle *dev_fwnode(struct device *dev)
 {
@@ -838,6 +839,21 @@
 {
 	char *res;
 
+#ifdef CONFIG_FBXSERIAL
+	u32 index;
+	int ret;
+
+	ret = fwnode_property_read_u32(fwnode, "fbxserial-mac-address",
+				       &index);
+	if (ret == 0) {
+		res = (void *)fbxserialinfo_get_mac_addr(index);
+		if (res) {
+			memcpy(addr, res, alen);
+			return res;
+		}
+	}
+#endif
+
 	res = fwnode_get_mac_addr(fwnode, "mac-address", addr, alen);
 	if (res)
 		return res;
diff -ruw linux-5.4.60/drivers/base/regmap/internal.h linux-5.4.60-fbx/drivers/base/regmap/internal.h
--- linux-5.4.60/drivers/base/regmap/internal.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/base/regmap/internal.h	2021-03-04 13:20:57.590838880 +0100
@@ -294,4 +294,6 @@
 	return reg >> map->reg_stride_order;
 }
 
+void *regmap_mmio_ctx_get_base(const void *priv);
+
 #endif
diff -ruw linux-5.4.60/drivers/base/regmap/regmap.c linux-5.4.60-fbx/drivers/base/regmap/regmap.c
--- linux-5.4.60/drivers/base/regmap/regmap.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/base/regmap/regmap.c	2021-03-04 13:20:57.590838880 +0100
@@ -3110,6 +3110,15 @@
 }
 EXPORT_SYMBOL_GPL(regmap_parse_val);
 
+#ifdef CONFIG_REGMAP_MMIO
+void *regmap_get_mmio_base_address(struct regmap *map)
+{
+	return regmap_mmio_ctx_get_base(map->bus_context);
+}
+
+EXPORT_SYMBOL_GPL(regmap_get_mmio_base_address);
+#endif
+
 static int __init regmap_initcall(void)
 {
 	regmap_debugfs_initcall();
diff -ruw linux-5.4.60/drivers/base/regmap/regmap-mmio.c linux-5.4.60-fbx/drivers/base/regmap/regmap-mmio.c
--- linux-5.4.60/drivers/base/regmap/regmap-mmio.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/base/regmap/regmap-mmio.c	2021-03-04 13:20:57.590838880 +0100
@@ -376,4 +376,10 @@
 }
 EXPORT_SYMBOL_GPL(regmap_mmio_detach_clk);
 
+void *regmap_mmio_ctx_get_base(const void *priv)
+{
+	struct regmap_mmio_context *ctx = (struct regmap_mmio_context *)priv;
+	return ctx->regs;
+}
+
 MODULE_LICENSE("GPL v2");
diff -ruw linux-5.4.60/drivers/bluetooth/btrtl.h linux-5.4.60-fbx/drivers/bluetooth/btrtl.h
--- linux-5.4.60/drivers/bluetooth/btrtl.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/bluetooth/btrtl.h	2021-03-04 13:20:57.610838881 +0100
@@ -14,6 +14,11 @@
 
 struct btrtl_device_info;
 
+struct rtl_chip_type_evt {
+	__u8 status;
+	__u8 type;
+} __packed;
+
 struct rtl_download_cmd {
 	__u8 index;
 	__u8 data[RTL_FRAG_LEN];
@@ -60,7 +65,10 @@
 			    struct btrtl_device_info *btrtl_dev,
 			    unsigned int *controller_baudrate,
 			    u32 *device_baudrate, bool *flow_control);
+void btrtl_apply_quirks(struct hci_dev *hdev,
+			struct btrtl_device_info *btrtl_dev);
 
+void btrtl_show_version(struct hci_dev *hdev);
 #else
 
 static inline struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
@@ -98,4 +106,9 @@
 	return -ENOENT;
 }
 
+static inline void btrtl_apply_quirks(struct hci_dev *hdev,
+			struct btrtl_device_info *btrtl_dev)
+{
+}
+
 #endif
diff -ruw linux-5.4.60/drivers/bluetooth/Kconfig linux-5.4.60-fbx/drivers/bluetooth/Kconfig
--- linux-5.4.60/drivers/bluetooth/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/bluetooth/Kconfig	2021-03-04 13:20:57.607505547 +0100
@@ -211,7 +211,6 @@
 	depends on BT_HCIUART
 	depends on BT_HCIUART_SERDEV
 	depends on GPIOLIB
-	depends on ACPI
 	select BT_HCIUART_3WIRE
 	select BT_RTL
 	help
diff -ruw linux-5.4.60/drivers/char/hw_random/Kconfig linux-5.4.60-fbx/drivers/char/hw_random/Kconfig
--- linux-5.4.60/drivers/char/hw_random/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/char/hw_random/Kconfig	2021-03-04 13:20:57.620838881 +0100
@@ -88,6 +88,11 @@
 
 	  If unsure, say Y.
 
+config HW_RANDOM_BCM63XX
+	tristate "Broadcom BCM63xx Random Number Generator support"
+	depends on ARCH_BCM_63XX || BCM63XX
+	default HW_RANDOM
+
 config HW_RANDOM_IPROC_RNG200
 	tristate "Broadcom iProc/STB RNG200 support"
 	depends on ARCH_BCM_IPROC || ARCH_BRCMSTB
diff -ruw linux-5.4.60/drivers/char/hw_random/Makefile linux-5.4.60-fbx/drivers/char/hw_random/Makefile
--- linux-5.4.60/drivers/char/hw_random/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/char/hw_random/Makefile	2021-03-04 13:20:57.620838881 +0100
@@ -28,6 +28,7 @@
 obj-$(CONFIG_HW_RANDOM_POWERNV) += powernv-rng.o
 obj-$(CONFIG_HW_RANDOM_HISI)	+= hisi-rng.o
 obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o
+obj-$(CONFIG_HW_RANDOM_BCM63XX) += bcm63xx-rng.o
 obj-$(CONFIG_HW_RANDOM_IPROC_RNG200) += iproc-rng200.o
 obj-$(CONFIG_HW_RANDOM_ST) += st-rng.o
 obj-$(CONFIG_HW_RANDOM_XGENE) += xgene-rng.o
diff -ruw linux-5.4.60/drivers/char/Kconfig linux-5.4.60-fbx/drivers/char/Kconfig
--- linux-5.4.60/drivers/char/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/char/Kconfig	2021-03-04 13:20:57.617505548 +0100
@@ -26,6 +26,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".
+
 source "drivers/tty/serial/Kconfig"
 source "drivers/tty/serdev/Kconfig"
 
diff -ruw linux-5.4.60/drivers/char/mem.c linux-5.4.60-fbx/drivers/char/mem.c
--- linux-5.4.60/drivers/char/mem.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/char/mem.c	2021-03-04 13:20:57.624172215 +0100
@@ -29,6 +29,8 @@
 #include <linux/export.h>
 #include <linux/io.h>
 #include <linux/uio.h>
+#include <linux/memblock.h>
+
 #include <linux/uaccess.h>
 #include <linux/security.h>
 #include <linux/pseudo_fs.h>
@@ -434,6 +436,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.
  */
@@ -870,6 +880,11 @@
 	return 0;
 }
 
+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
@@ -935,6 +950,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;
@@ -958,6 +981,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-5.4.60/drivers/cpufreq/Kconfig linux-5.4.60-fbx/drivers/cpufreq/Kconfig
--- linux-5.4.60/drivers/cpufreq/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/cpufreq/Kconfig	2021-03-04 13:20:57.690838885 +0100
@@ -327,5 +327,10 @@
 	  This adds the CPUFreq driver support for Freescale QorIQ SoCs
 	  which are capable of changing the CPU's frequency dynamically.
 
+config BCM63158_CPUFREQ
+	tristate "CPU frequency scaling driver for BCM63158 SoC"
+	depends on ARCH_BCM63XX
+
 endif
+
 endmenu
diff -ruw linux-5.4.60/drivers/cpufreq/Makefile linux-5.4.60-fbx/drivers/cpufreq/Makefile
--- linux-5.4.60/drivers/cpufreq/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/cpufreq/Makefile	2021-03-04 13:20:57.690838885 +0100
@@ -111,3 +111,5 @@
 obj-$(CONFIG_SPARC_US2E_CPUFREQ)	+= sparc-us2e-cpufreq.o
 obj-$(CONFIG_SPARC_US3_CPUFREQ)		+= sparc-us3-cpufreq.o
 obj-$(CONFIG_UNICORE32)			+= unicore2-cpufreq.o
+
+obj-$(CONFIG_BCM63158_CPUFREQ)		+= bcm63158-cpufreq.o
diff -ruw linux-5.4.60/drivers/gpio/gpio-mvebu.c linux-5.4.60-fbx/drivers/gpio/gpio-mvebu.c
--- linux-5.4.60/drivers/gpio/gpio-mvebu.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/gpio/gpio-mvebu.c	2021-03-04 13:20:57.777505555 +0100
@@ -66,6 +66,11 @@
 #define GPIO_LEVEL_MASK_OFF		0x001c
 #define GPIO_BLINK_CNT_SELECT_OFF	0x0020
 
+#define GPIO_CONTROL_SET_OFF		0x0028
+#define GPIO_CONTROL_CLR_OFF		0x002c
+#define GPIO_DATAOUT_SET_OFF		0x0030
+#define GPIO_DATAOUT_CLR_OFF		0x0034
+
 /*
  * PWM register offsets.
  */
@@ -110,11 +115,13 @@
 struct mvebu_gpio_chip {
 	struct gpio_chip   chip;
 	struct regmap     *regs;
+	void __iomem      *base;
 	u32		   offset;
 	struct regmap     *percpu_regs;
 	int		   irqbase;
 	struct irq_domain *domain;
 	int		   soc_variant;
+	int		   broken_mpp33_dir_wa;
 
 	/* Used for PWM support */
 	struct clk	  *clk;
@@ -300,6 +307,18 @@
 {
 	struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip);
 
+	if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_A8K) {
+		unsigned int off;
+
+		if (value)
+			off = GPIO_DATAOUT_SET_OFF;
+		else
+			off = GPIO_DATAOUT_CLR_OFF;
+
+		writel(BIT(pin), mvchip->base + off + mvchip->offset);
+		return;
+	}
+
 	regmap_update_bits(mvchip->regs, GPIO_OUT_OFF + mvchip->offset,
 			   BIT(pin), value ? BIT(pin) : 0);
 }
@@ -338,7 +357,7 @@
 static int mvebu_gpio_direction_input(struct gpio_chip *chip, unsigned int pin)
 {
 	struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip);
-	int ret;
+	int offset, ret;
 
 	/*
 	 * Check with the pinctrl driver whether this pin is usable as
@@ -348,7 +367,16 @@
 	if (ret)
 		return ret;
 
-	regmap_update_bits(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset,
+	offset = 0;
+	if (pin == 1 && mvchip->broken_mpp33_dir_wa) {
+		/*
+		 * See comment in mvebu_gpio_direction_output().
+		 */
+		offset = -0x40;
+	}
+
+	regmap_update_bits(mvchip->regs,
+			   GPIO_IO_CONF_OFF + mvchip->offset + offset,
 			   BIT(pin), BIT(pin));
 
 	return 0;
@@ -358,7 +386,7 @@
 				       int value)
 {
 	struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip);
-	int ret;
+	int offset, ret;
 
 	/*
 	 * Check with the pinctrl driver whether this pin is usable as
@@ -371,7 +399,17 @@
 	mvebu_gpio_blink(chip, pin, 0);
 	mvebu_gpio_set(chip, pin, value);
 
-	regmap_update_bits(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset,
+	offset = 0;
+	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
+		 */
+		offset = -0x40;
+	}
+
+	regmap_update_bits(mvchip->regs,
+			   GPIO_IO_CONF_OFF + mvchip->offset + offset,
 			   BIT(pin), 0);
 
 	return 0;
@@ -380,9 +418,18 @@
 static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
 {
 	struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip);
+	int offset;
 	u32 u;
 
-	regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u);
+	offset = 0;
+	if (pin == 1 && mvchip->broken_mpp33_dir_wa) {
+		/*
+		 * See comment in mvebu_gpio_direction_output().
+		 */
+		offset = -0x40;
+	}
+
+	regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset + offset, &u);
 
 	return !!(u & BIT(pin));
 }
@@ -1046,6 +1093,8 @@
 	if (IS_ERR(mvchip->regs))
 		return PTR_ERR(mvchip->regs);
 
+	mvchip->base = base;
+
 	/*
 	 * For the legacy SoCs, the regmap directly maps to the GPIO
 	 * registers, so no offset is needed.
@@ -1078,6 +1127,8 @@
 	if (IS_ERR(mvchip->regs))
 		return PTR_ERR(mvchip->regs);
 
+	mvchip->base = regmap_get_mmio_base_address(mvchip->regs);
+
 	if (of_property_read_u32(pdev->dev.of_node, "offset", &mvchip->offset))
 		return -EINVAL;
 
@@ -1095,6 +1146,7 @@
 	bool have_irqs;
 	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);
@@ -1118,6 +1170,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");
@@ -1129,6 +1187,7 @@
 	if (!IS_ERR(mvchip->clk))
 		clk_prepare_enable(mvchip->clk);
 
+	mvchip->broken_mpp33_dir_wa = broken_mpp33_dir;
 	mvchip->soc_variant = soc_variant;
 	mvchip->chip.label = dev_name(&pdev->dev);
 	mvchip->chip.parent = &pdev->dev;
diff -ruw linux-5.4.60/drivers/hid/hid-quirks.c linux-5.4.60-fbx/drivers/hid/hid-quirks.c
--- linux-5.4.60/drivers/hid/hid-quirks.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/hid/hid-quirks.c	2021-03-04 13:20:58.437505585 +0100
@@ -684,6 +684,7 @@
 #if IS_ENABLED(CONFIG_HID_ZYDACRON)
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) },
 #endif
+	{ HID_BLUETOOTH_DEVICE(0x10eb, 0x0023) },
 	{ }
 };
 
diff -ruw linux-5.4.60/drivers/hid/Kconfig linux-5.4.60-fbx/drivers/hid/Kconfig
--- linux-5.4.60/drivers/hid/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/hid/Kconfig	2021-03-04 13:20:58.430838917 +0100
@@ -439,6 +439,11 @@
 	help
 	  Support for ViewSonic/Signotec PD1011 signature pad.
 
+config HID_FBX_REMOTE_AUDIO
+	tristate "Freebox BLE remote audio driver"
+	depends on HID && SND
+	select SND_PCM
+
 config HID_GYRATION
 	tristate "Gyration remote control"
 	depends on HID
diff -ruw linux-5.4.60/drivers/hid/Makefile linux-5.4.60-fbx/drivers/hid/Makefile
--- linux-5.4.60/drivers/hid/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/hid/Makefile	2021-03-04 13:20:58.430838917 +0100
@@ -50,6 +50,7 @@
 obj-$(CONFIG_HID_GFRM)		+= hid-gfrm.o
 obj-$(CONFIG_HID_GOOGLE_HAMMER)	+= hid-google-hammer.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-5.4.60/drivers/hwmon/adt7475.c linux-5.4.60-fbx/drivers/hwmon/adt7475.c
--- linux-5.4.60/drivers/hwmon/adt7475.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/hwmon/adt7475.c	2021-03-04 13:20:58.450838918 +0100
@@ -128,7 +128,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 */
 
diff -ruw linux-5.4.60/drivers/hwmon/Kconfig linux-5.4.60-fbx/drivers/hwmon/Kconfig
--- linux-5.4.60/drivers/hwmon/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/hwmon/Kconfig	2021-03-04 13:20:58.447505585 +0100
@@ -1922,6 +1922,17 @@
 	  If you say yes here you get support for the temperature
 	  and power sensors for APM X-Gene SoC.
 
+config SENSORS_KIRKWOOD_CORETEMP
+	tristate "Kirkwood core temperature censor"
+	depends on MACH_KIRKWOOD
+
+config SENSORS_LD6710_FBX
+	tristate "LD6710 hardware monitoring driver (as seen on Freebox hardware)"
+	depends on I2C
+
+config SENSORS_AP806
+	tristate "Marvell AP806/CP110 hardware monitoring driver"
+
 if ACPI
 
 comment "ACPI drivers"
diff -ruw linux-5.4.60/drivers/hwmon/lm85.c linux-5.4.60-fbx/drivers/hwmon/lm85.c
--- linux-5.4.60/drivers/hwmon/lm85.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/hwmon/lm85.c	2021-03-04 13:20:58.457505585 +0100
@@ -194,7 +194,7 @@
 };
 
 static const int adm1027_freq_map[] = { /* 1 Hz */
-	11, 15, 22, 29, 35, 44, 59, 88
+	11, 15, 22, 29, 35, 44, 59, 88, 88, 88, 25000
 };
 
 static int FREQ_TO_REG(const int *map,
@@ -1424,10 +1424,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)) {
@@ -1587,7 +1605,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-5.4.60/drivers/hwmon/Makefile linux-5.4.60-fbx/drivers/hwmon/Makefile
--- linux-5.4.60/drivers/hwmon/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/hwmon/Makefile	2021-03-04 13:20:58.447505585 +0100
@@ -87,6 +87,7 @@
 obj-$(CONFIG_SENSORS_JC42)	+= jc42.o
 obj-$(CONFIG_SENSORS_K8TEMP)	+= k8temp.o
 obj-$(CONFIG_SENSORS_K10TEMP)	+= k10temp.o
+obj-$(CONFIG_SENSORS_LD6710_FBX) += ld6710-fbx.o
 obj-$(CONFIG_SENSORS_LINEAGE)	+= lineage-pem.o
 obj-$(CONFIG_SENSORS_LOCHNAGAR)	+= lochnagar-hwmon.o
 obj-$(CONFIG_SENSORS_LM63)	+= lm63.o
@@ -177,6 +178,8 @@
 obj-$(CONFIG_SENSORS_WM831X)	+= wm831x-hwmon.o
 obj-$(CONFIG_SENSORS_WM8350)	+= wm8350-hwmon.o
 obj-$(CONFIG_SENSORS_XGENE)	+= xgene-hwmon.o
+obj-$(CONFIG_SENSORS_KIRKWOOD_CORETEMP)+= kirkwood-coretemp.o
+obj-$(CONFIG_SENSORS_AP806)	+= ap806-hwmon.o
 
 obj-$(CONFIG_SENSORS_OCC)	+= occ/
 obj-$(CONFIG_PMBUS)		+= pmbus/
diff -ruw linux-5.4.60/drivers/i2c/busses/i2c-mv64xxx.c linux-5.4.60-fbx/drivers/i2c/busses/i2c-mv64xxx.c
--- linux-5.4.60/drivers/i2c/busses/i2c-mv64xxx.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/i2c/busses/i2c-mv64xxx.c	2021-03-04 13:20:58.480838920 +0100
@@ -22,6 +22,8 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/of_irq.h>
+#include <linux/of_gpio.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/delay.h>
@@ -147,6 +149,10 @@
 	bool			irq_clear_inverted;
 	/* Clk div is 2 to the power n, not 2 to the power n + 1 */
 	bool			clk_n_base_0;
+	struct i2c_bus_recovery_info rinfo;
+	struct pinctrl		*pinctrl;
+	struct pinctrl_state	*pinctrl_pins_default;
+	struct pinctrl_state	*pinctrl_pins_gpio;
 };
 
 static struct mv64xxx_i2c_regs mv64xxx_i2c_regs_mv64xxx = {
@@ -312,6 +318,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;
@@ -562,6 +573,8 @@
 				"mv64xxx: I2C bus locked, block: %d, "
 				"time_left: %d\n", drv_data->block,
 				(int)time_left);
+			if (drv_data->adapter.bus_recovery_info)
+				i2c_recover_bus(&drv_data->adapter);
 			mv64xxx_i2c_hw_init(drv_data);
 		}
 	} else
@@ -573,6 +586,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);
 
@@ -580,6 +621,7 @@
 
 	drv_data->send_stop = is_last;
 	drv_data->block = 1;
+
 	mv64xxx_i2c_send_start(drv_data);
 	spin_unlock_irqrestore(&drv_data->lock, flags);
 
@@ -863,6 +905,61 @@
 out:
 	return rc;
 }
+
+static void mv64xxx_prepare_recovery(struct i2c_adapter *adap)
+{
+	struct mv64xxx_i2c_data *drv_data = i2c_get_adapdata(adap);
+	pinctrl_select_state(drv_data->pinctrl, drv_data->pinctrl_pins_gpio);
+}
+
+static void mv64xxx_unprepare_recovery(struct i2c_adapter *adap)
+{
+	struct mv64xxx_i2c_data *drv_data = i2c_get_adapdata(adap);
+	pinctrl_select_state(drv_data->pinctrl, drv_data->pinctrl_pins_default);
+}
+
+static int mv64xxx_init_recovery_info(struct mv64xxx_i2c_data *drv_data,
+				      struct platform_device *pdev)
+{
+	struct i2c_bus_recovery_info *rinfo = &drv_data->rinfo;
+
+	drv_data->pinctrl = devm_pinctrl_get(&pdev->dev);
+	if (!drv_data->pinctrl || IS_ERR(drv_data->pinctrl)) {
+		if (PTR_ERR(drv_data->pinctrl) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n");
+		return 0;
+	}
+
+	drv_data->pinctrl_pins_default = pinctrl_lookup_state(drv_data->pinctrl,
+			PINCTRL_STATE_DEFAULT);
+	drv_data->pinctrl_pins_gpio = pinctrl_lookup_state(drv_data->pinctrl,
+			"gpio");
+
+	rinfo->sda_gpiod = devm_gpiod_get(&pdev->dev, "sda",
+					  GPIOD_IN);
+	rinfo->scl_gpiod = devm_gpiod_get(&pdev->dev, "scl",
+					  GPIOD_OUT_HIGH_OPEN_DRAIN);
+
+	if (PTR_ERR(rinfo->sda_gpiod) == -EPROBE_DEFER ||
+	    PTR_ERR(rinfo->scl_gpiod) == -EPROBE_DEFER) {
+		return -EPROBE_DEFER;
+	} else if (IS_ERR(rinfo->sda_gpiod) ||
+		   IS_ERR(rinfo->scl_gpiod) ||
+		   IS_ERR(drv_data->pinctrl_pins_default) ||
+		   IS_ERR(drv_data->pinctrl_pins_gpio)) {
+		dev_info(&pdev->dev, "recovery information incomplete\n");
+		return 0;
+	}
+
+	rinfo->prepare_recovery = mv64xxx_prepare_recovery;
+	rinfo->unprepare_recovery = mv64xxx_unprepare_recovery;
+	rinfo->recover_bus = i2c_generic_scl_recovery;
+	drv_data->adapter.bus_recovery_info = rinfo;
+
+	return 0;
+}
+
 #else /* CONFIG_OF */
 static int
 mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
@@ -870,8 +967,15 @@
 {
 	return -ENODEV;
 }
+
+static int mv64xxx_init_recovery_info(struct mv64xxx_i2c_data *drv_data,
+				      struct platform_device *pdev)
+{
+	return 0;
+}
 #endif /* CONFIG_OF */
 
+
 static int
 mv64xxx_i2c_probe(struct platform_device *pd)
 {
@@ -899,6 +1003,10 @@
 	init_waitqueue_head(&drv_data->waitq);
 	spin_lock_init(&drv_data->lock);
 
+	rc = mv64xxx_init_recovery_info(drv_data, pd);
+	if (rc)
+		return rc;
+
 	/* Not all platforms have clocks */
 	drv_data->clk = devm_clk_get(&pd->dev, NULL);
 	if (IS_ERR(drv_data->clk) && PTR_ERR(drv_data->clk) == -EPROBE_DEFER)
@@ -934,7 +1042,7 @@
 	drv_data->adapter.dev.parent = &pd->dev;
 	drv_data->adapter.algo = &mv64xxx_i2c_algo;
 	drv_data->adapter.owner = THIS_MODULE;
-	drv_data->adapter.class = I2C_CLASS_DEPRECATED;
+	drv_data->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
 	drv_data->adapter.nr = pd->id;
 	drv_data->adapter.dev.of_node = pd->dev.of_node;
 	platform_set_drvdata(pd, drv_data);
diff -ruw linux-5.4.60/drivers/i2c/busses/Kconfig linux-5.4.60-fbx/drivers/i2c/busses/Kconfig
--- linux-5.4.60/drivers/i2c/busses/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/i2c/busses/Kconfig	2021-03-04 13:20:58.474172253 +0100
@@ -473,7 +473,7 @@
 config I2C_BRCMSTB
 	tristate "BRCM Settop/DSL I2C controller"
 	depends on ARCH_BRCMSTB || BMIPS_GENERIC || ARCH_BCM_63XX || \
-		   COMPILE_TEST
+		   ARCH_BCM63XX || COMPILE_TEST
 	default y
 	help
 	  If you say yes to this option, support will be included for the
@@ -1376,6 +1376,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-5.4.60/drivers/i2c/busses/Makefile linux-5.4.60-fbx/drivers/i2c/busses/Makefile
--- linux-5.4.60/drivers/i2c/busses/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/i2c/busses/Makefile	2021-03-04 13:20:58.474172253 +0100
@@ -123,6 +123,7 @@
 obj-$(CONFIG_I2C_XLP9XX)	+= i2c-xlp9xx.o
 obj-$(CONFIG_I2C_RCAR)		+= i2c-rcar.o
 obj-$(CONFIG_I2C_ZX2967)	+= i2c-zx2967.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-5.4.60/drivers/i2c/i2c-core-base.c linux-5.4.60-fbx/drivers/i2c/i2c-core-base.c
--- linux-5.4.60/drivers/i2c/i2c-core-base.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/i2c/i2c-core-base.c	2021-03-04 13:20:58.487505587 +0100
@@ -223,12 +223,14 @@
 			bri->set_sda(adap, scl);
 		ndelay(RECOVERY_NDELAY / 2);
 
+		if (0) {
 		if (scl) {
 			ret = i2c_generic_bus_free(adap);
 			if (ret == 0)
 				break;
 		}
 	}
+	}
 
 	/* If we can't check bus status, assume recovery worked */
 	if (ret == -EOPNOTSUPP)
diff -ruw linux-5.4.60/drivers/input/misc/Kconfig linux-5.4.60-fbx/drivers/input/misc/Kconfig
--- linux-5.4.60/drivers/input/misc/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/input/misc/Kconfig	2021-03-04 13:20:58.604172259 +0100
@@ -894,4 +894,9 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called stpmic1_onkey.
 
+config INPUT_SMSC_CAP1066
+	tristate "SMSC CAP1066 capacitive sensor driver"
+	select I2C
+	select INPUT_POLLDEV
+
 endif
diff -ruw linux-5.4.60/drivers/input/misc/Makefile linux-5.4.60-fbx/drivers/input/misc/Makefile
--- linux-5.4.60/drivers/input/misc/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/input/misc/Makefile	2021-03-04 13:20:58.604172259 +0100
@@ -85,4 +85,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-5.4.60/drivers/Kconfig linux-5.4.60-fbx/drivers/Kconfig
--- linux-5.4.60/drivers/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/Kconfig	2021-03-04 13:20:57.530838878 +0100
@@ -18,6 +18,8 @@
 
 source "drivers/gnss/Kconfig"
 
+source "drivers/fbxprocfs/Kconfig"
+
 source "drivers/mtd/Kconfig"
 
 source "drivers/of/Kconfig"
@@ -78,6 +80,10 @@
 
 source "drivers/gpio/Kconfig"
 
+source "drivers/fbxgpio/Kconfig"
+
+source "drivers/fbxjtag/Kconfig"
+
 source "drivers/w1/Kconfig"
 
 source "drivers/power/Kconfig"
@@ -86,6 +92,8 @@
 
 source "drivers/thermal/Kconfig"
 
+source "drivers/fbxwatchdog/Kconfig"
+
 source "drivers/watchdog/Kconfig"
 
 source "drivers/ssb/Kconfig"
diff -ruw linux-5.4.60/drivers/leds/Kconfig linux-5.4.60-fbx/drivers/leds/Kconfig
--- linux-5.4.60/drivers/leds/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/leds/Kconfig	2021-03-04 13:20:58.647505594 +0100
@@ -823,6 +823,16 @@
 	  Say Y to enable the LM36274 LED driver for TI LMU devices.
 	  This supports the LED device LM36274.
 
+config LEDS_LED1202
+	tristate "LED support for STMicroElectronics LED1202"
+	depends on LEDS_CLASS && I2C && OF
+	help
+	  This option enables support for the LED1202 12-channel
+	  LED driver.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called leds-led1202.
+
 comment "LED Triggers"
 source "drivers/leds/trigger/Kconfig"
 
diff -ruw linux-5.4.60/drivers/leds/Makefile linux-5.4.60-fbx/drivers/leds/Makefile
--- linux-5.4.60/drivers/leds/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/leds/Makefile	2021-03-04 13:20:58.647505594 +0100
@@ -85,6 +85,7 @@
 obj-$(CONFIG_LEDS_TI_LMU_COMMON)	+= leds-ti-lmu-common.o
 obj-$(CONFIG_LEDS_LM3697)		+= leds-lm3697.o
 obj-$(CONFIG_LEDS_LM36274)		+= leds-lm36274.o
+obj-$(CONFIG_LEDS_LED1202)		+= leds-led1202.o
 
 # LED SPI Drivers
 obj-$(CONFIG_LEDS_CR0014114)		+= leds-cr0014114.o
diff -ruw linux-5.4.60/drivers/Makefile linux-5.4.60-fbx/drivers/Makefile
--- linux-5.4.60/drivers/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/Makefile	2021-03-04 13:20:57.530838878 +0100
@@ -16,7 +16,9 @@
 obj-$(CONFIG_GPIOLIB)		+= gpio/
 obj-y				+= pwm/
 
+obj-$(CONFIG_FREEBOX_GPIO)	+= fbxgpio/
 obj-y				+= pci/
+obj-$(CONFIG_FREEBOX_JTAG)	+= fbxjtag/
 
 obj-$(CONFIG_PARISC)		+= parisc/
 obj-$(CONFIG_RAPIDIO)		+= rapidio/
@@ -117,6 +119,7 @@
 obj-y				+= 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/
@@ -186,3 +189,5 @@
 obj-$(CONFIG_GNSS)		+= gnss/
 obj-$(CONFIG_INTERCONNECT)	+= interconnect/
 obj-$(CONFIG_COUNTER)		+= counter/
+
+obj-$(CONFIG_FREEBOX_PROCFS)	+= fbxprocfs/
diff -ruw linux-5.4.60/drivers/media/dvb-core/dvb_frontend.c linux-5.4.60-fbx/drivers/media/dvb-core/dvb_frontend.c
--- linux-5.4.60/drivers/media/dvb-core/dvb_frontend.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/media/dvb-core/dvb_frontend.c	2021-03-04 13:20:58.687505596 +0100
@@ -807,6 +807,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;
@@ -2715,6 +2716,9 @@
 
 	poll_wait(file, &fepriv->events.wait_queue, wait);
 
+	if (fe->exit)
+		return POLLERR | POLLHUP;
+
 	if (fepriv->events.eventw != fepriv->events.eventr)
 		return (EPOLLIN | EPOLLRDNORM | EPOLLPRI);
 
diff -ruw linux-5.4.60/drivers/media/rc/keymaps/Makefile linux-5.4.60-fbx/drivers/media/rc/keymaps/Makefile
--- linux-5.4.60/drivers/media/rc/keymaps/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/media/rc/keymaps/Makefile	2021-03-04 13:20:58.817505601 +0100
@@ -91,6 +91,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-5.4.60/drivers/media/usb/dvb-usb/dib0700_devices.c linux-5.4.60-fbx/drivers/media/usb/dvb-usb/dib0700_devices.c
--- linux-5.4.60/drivers/media/usb/dvb-usb/dib0700_devices.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/media/usb/dvb-usb/dib0700_devices.c	2021-03-04 13:20:58.840838936 +0100
@@ -3912,6 +3912,7 @@
 	{ USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK8096PVR) },
 /* 85 */{ USB_DEVICE(USB_VID_HAMA,	USB_PID_HAMA_DVBT_HYBRID) },
 	{ USB_DEVICE(USB_VID_MICROSOFT,	USB_PID_XBOX_ONE_TUNER) },
+	{ USB_DEVICE(USB_VID_DIBCOM,	USB_PID_DIBCOM_HOOK_DEFAULT_STK7770P) },
 	{ 0 }		/* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -5154,6 +5155,30 @@
 				{ NULL },
 			},
 		},
+	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
+		.num_adapters = 1,
+		.adapter = {
+			{
+			DIB0700_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),
+			}},
+			},
+		},
+		.num_device_descs = 1,
+		.devices = {
+			{   "DiBcom STK7770P reference design no IR",
+				{ &dib0700_usb_id_table[87], NULL },
+				{ NULL },
+			},
+		},
 	},
 };
 
diff -ruw linux-5.4.60/drivers/mfd/Kconfig linux-5.4.60-fbx/drivers/mfd/Kconfig
--- linux-5.4.60/drivers/mfd/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mfd/Kconfig	2021-03-04 13:20:58.880838938 +0100
@@ -1967,6 +1967,16 @@
 	  This driver provides common support for accessing the device,
 	  additional drivers must be enabled in order to use the functionality
 	  of the device.
+config MFD_FBXGW7R_PANEL
+	tristate "Freebox fbxgw7r panel support"
+	depends on FB
+	depends on SPI_MASTER
+	depends on OF
+	select FB_SYS_FOPS
+	select FB_SYS_FILLRECT
+	select FB_SYS_COPYAREA
+	select FB_SYS_IMAGEBLIT
+	select FB_DEFERRED_IO
 
 menu "Multimedia Capabilities Port drivers"
 	depends on ARCH_SA1100
diff -ruw linux-5.4.60/drivers/mfd/Makefile linux-5.4.60-fbx/drivers/mfd/Makefile
--- linux-5.4.60/drivers/mfd/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mfd/Makefile	2021-03-04 13:20:58.880838938 +0100
@@ -255,4 +255,5 @@
 obj-$(CONFIG_MFD_ROHM_BD70528)	+= rohm-bd70528.o
 obj-$(CONFIG_MFD_ROHM_BD718XX)	+= rohm-bd718x7.o
 obj-$(CONFIG_MFD_STMFX) 	+= stmfx.o
+obj-$(CONFIG_MFD_FBXGW7R_PANEL)	+= fbxgw7r-panel.o
 
diff -ruw linux-5.4.60/drivers/misc/eeprom/at24.c linux-5.4.60-fbx/drivers/misc/eeprom/at24.c
--- linux-5.4.60/drivers/misc/eeprom/at24.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/misc/eeprom/at24.c	2021-03-04 13:20:58.904172272 +0100
@@ -566,7 +566,6 @@
 	struct at24_data *at24;
 	struct regmap *regmap;
 	bool writable;
-	u8 test_byte;
 	int err;
 
 	i2c_fn_i2c = i2c_check_functionality(client->adapter, I2C_FUNC_I2C);
@@ -587,8 +586,10 @@
 		page_size = 1;
 
 	flags = cdata->flags;
+#ifndef CONFIG_NVMEM_IGNORE_RO
 	if (device_property_present(dev, "read-only"))
 		flags |= AT24_FLAG_READONLY;
+#endif
 	if (device_property_present(dev, "no-read-rollover"))
 		flags |= AT24_FLAG_NO_RDROL;
 
@@ -705,17 +706,6 @@
 	pm_runtime_set_active(dev);
 	pm_runtime_enable(dev);
 
-	/*
-	 * Perform a one-byte test read to verify that the
-	 * chip is functional.
-	 */
-	err = at24_read(at24, 0, &test_byte, 1);
-	pm_runtime_idle(dev);
-	if (err) {
-		pm_runtime_disable(dev);
-		return -ENODEV;
-	}
-
 	dev_info(dev, "%u byte %s EEPROM, %s, %u bytes/write\n",
 		 byte_len, client->name,
 		 writable ? "writable" : "read-only", at24->write_max);
diff -ruw linux-5.4.60/drivers/misc/eeprom/Kconfig linux-5.4.60-fbx/drivers/misc/eeprom/Kconfig
--- linux-5.4.60/drivers/misc/eeprom/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/misc/eeprom/Kconfig	2021-03-04 13:20:58.904172272 +0100
@@ -129,4 +129,8 @@
 	  This driver can also be built as a module.  If so, the module
 	  will be called ee1004.
 
+config EEPROM_EE1004_RAW
+	tristate "SPD EEPROMs on DDR4 memory modules (non smbus)"
+	depends on I2C && SYSFS
+
 endmenu
diff -ruw linux-5.4.60/drivers/misc/eeprom/Makefile linux-5.4.60-fbx/drivers/misc/eeprom/Makefile
--- linux-5.4.60/drivers/misc/eeprom/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/misc/eeprom/Makefile	2021-03-04 13:20:58.904172272 +0100
@@ -8,3 +8,4 @@
 obj-$(CONFIG_EEPROM_DIGSY_MTC_CFG) += digsy_mtc_eeprom.o
 obj-$(CONFIG_EEPROM_IDT_89HPESX) += idt_89hpesx.o
 obj-$(CONFIG_EEPROM_EE1004)	+= ee1004.o
+obj-$(CONFIG_EEPROM_EE1004_RAW)	+= ee1004_raw.o
diff -ruw linux-5.4.60/drivers/misc/Kconfig linux-5.4.60-fbx/drivers/misc/Kconfig
--- linux-5.4.60/drivers/misc/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/misc/Kconfig	2021-03-04 13:20:58.900838939 +0100
@@ -5,6 +5,9 @@
 
 menu "Misc devices"
 
+config WINTEGRA_MMAP
+	bool "wintegra mmap driver"
+
 config SENSORS_LIS3LV02D
 	tristate
 	depends on INPUT
@@ -379,6 +382,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 PCH_PHUB
 	tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) PHUB"
 	select GENERIC_NET_UTILS
@@ -400,6 +415,15 @@
 	  To compile this driver as a module, choose M here: the module will
 	  be called pch_phub.
 
+config FBXSERIAL_OF
+	bool "read fbxserial through DT chosen node"
+	depends on OF
+	select ARCH_HAS_FBXSERIAL
+
+config RANDOM_OF
+	bool "get Linux PRNG random through dt chosen node."
+	depends on OF
+
 config LATTICE_ECP3_CONFIG
 	tristate "Lattice ECP3 FPGA bitstream configuration via SPI"
 	depends on SPI && SYSFS
@@ -481,4 +505,6 @@
 source "drivers/misc/ocxl/Kconfig"
 source "drivers/misc/cardreader/Kconfig"
 source "drivers/misc/habanalabs/Kconfig"
+source "drivers/misc/remoti/Kconfig"
+source "drivers/misc/hdmi-cec/Kconfig"
 endmenu
diff -ruw linux-5.4.60/drivers/misc/Makefile linux-5.4.60-fbx/drivers/misc/Makefile
--- linux-5.4.60/drivers/misc/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/misc/Makefile	2021-03-04 13:20:58.900838939 +0100
@@ -3,6 +3,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_IBMVMC)		+= ibmvmc.o
 obj-$(CONFIG_AD525X_DPOT)	+= ad525x_dpot.o
@@ -23,7 +24,10 @@
 obj-$(CONFIG_SENSORS_APDS990X)	+= apds990x.o
 obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o
 obj-$(CONFIG_KGDB_TESTS)	+= kgdbts.o
+obj-$(CONFIG_FBXSERIAL_OF)	+= fbxserial_of.o
+obj-$(CONFIG_RANDOM_OF)		+= random_of.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
@@ -38,6 +42,7 @@
 obj-y				+= cb710/
 obj-$(CONFIG_VMWARE_BALLOON)	+= vmw_balloon.o
 obj-$(CONFIG_PCH_PHUB)		+= pch_phub.o
+obj-y				+= hdmi-cec/
 obj-y				+= ti-st/
 obj-y				+= lis3lv02d/
 obj-$(CONFIG_ALTERA_STAPL)	+=altera-stapl/
@@ -57,3 +62,4 @@
 obj-$(CONFIG_PVPANIC)   	+= pvpanic.o
 obj-$(CONFIG_HABANA_AI)		+= habanalabs/
 obj-$(CONFIG_XILINX_SDFEC)	+= xilinx_sdfec.o
+obj-y				+= remoti/
diff -ruw linux-5.4.60/drivers/mmc/host/Kconfig linux-5.4.60-fbx/drivers/mmc/host/Kconfig
--- linux-5.4.60/drivers/mmc/host/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mmc/host/Kconfig	2021-03-04 13:20:58.934172273 +0100
@@ -976,7 +976,7 @@
 
 config MMC_SDHCI_BRCMSTB
 	tristate "Broadcom SDIO/SD/MMC support"
-	depends on ARCH_BRCMSTB || BMIPS_GENERIC
+	depends on ARCH_BRCMSTB || BMIPS_GENERIC || ARCH_BCM63XX
 	depends on MMC_SDHCI_PLTFM
 	default y
 	help
diff -ruw linux-5.4.60/drivers/mtd/Kconfig linux-5.4.60-fbx/drivers/mtd/Kconfig
--- linux-5.4.60/drivers/mtd/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mtd/Kconfig	2021-03-04 13:20:58.947505608 +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"
+
 menu "Partition parsers"
 source "drivers/mtd/parsers/Kconfig"
 endmenu
diff -ruw linux-5.4.60/drivers/mtd/mtdchar.c linux-5.4.60-fbx/drivers/mtd/mtdchar.c
--- linux-5.4.60/drivers/mtd/mtdchar.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mtd/mtdchar.c	2021-03-04 13:20:58.954172274 +0100
@@ -176,6 +176,7 @@
 		{
 			struct mtd_oob_ops ops;
 
+			memset(&ops, 0, sizeof (ops));
 			ops.mode = MTD_OPS_RAW;
 			ops.datbuf = kbuf;
 			ops.oobbuf = NULL;
@@ -270,6 +271,7 @@
 		{
 			struct mtd_oob_ops ops;
 
+			memset(&ops, 0, sizeof (ops));
 			ops.mode = MTD_OPS_RAW;
 			ops.datbuf = kbuf;
 			ops.oobbuf = NULL;
@@ -753,6 +755,11 @@
 				erase->len = einfo32.length;
 			}
 
+#ifdef CONFIG_MTD_ERASE_PRINTK
+			printk(KERN_DEBUG "mtd: %s: ERASE offset=@%08llx\n",
+			       mtd->name, erase->addr);
+#endif
+
 			ret = mtd_erase(mtd, erase);
 			kfree(erase);
 		}
diff -ruw linux-5.4.60/drivers/mtd/mtdcore.c linux-5.4.60-fbx/drivers/mtd/mtdcore.c
--- linux-5.4.60/drivers/mtd/mtdcore.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mtd/mtdcore.c	2021-03-04 13:20:58.954172274 +0100
@@ -307,6 +307,43 @@
 }
 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 ssize_t mtd_nand_onfi_ecc_bits_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct mtd_info *mtd = dev_get_drvdata(dev);
+
+	return snprintf(buf, PAGE_SIZE, "%d\n", mtd->onfi_ecc_bits);
+}
+static DEVICE_ATTR(onfi_ecc_bits, S_IRUGO, mtd_nand_onfi_ecc_bits_show, NULL);
+
+static ssize_t mtd_nand_onfi_model_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->onfi_model ? mtd->onfi_model : "unknown");
+}
+static DEVICE_ATTR(onfi_model, S_IRUGO, mtd_nand_onfi_model_show, NULL);
+
 static struct attribute *mtd_attrs[] = {
 	&dev_attr_type.attr,
 	&dev_attr_flags.attr,
@@ -325,6 +362,10 @@
 	&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,
+	&dev_attr_onfi_ecc_bits.attr,
+	&dev_attr_onfi_model.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(mtd);
diff -ruw linux-5.4.60/drivers/mtd/mtdpart.c linux-5.4.60-fbx/drivers/mtd/mtdpart.c
--- linux-5.4.60/drivers/mtd/mtdpart.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mtd/mtdpart.c	2021-03-04 13:20:58.954172274 +0100
@@ -350,6 +350,10 @@
 	slave->mtd.oobavail = parent->oobavail;
 	slave->mtd.subpage_sft = parent->subpage_sft;
 	slave->mtd.pairing = parent->pairing;
+	slave->mtd.nand_type = parent->nand_type;
+	slave->mtd.nand_manufacturer = parent->nand_manufacturer;
+	slave->mtd.onfi_ecc_bits = parent->onfi_ecc_bits;
+	slave->mtd.onfi_model = parent->onfi_model;
 
 	slave->mtd.name = name;
 	slave->mtd.owner = parent->owner;
diff -ruw linux-5.4.60/drivers/mtd/nand/raw/Kconfig linux-5.4.60-fbx/drivers/mtd/nand/raw/Kconfig
--- linux-5.4.60/drivers/mtd/nand/raw/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mtd/nand/raw/Kconfig	2021-03-04 13:20:58.957505608 +0100
@@ -34,6 +34,14 @@
 
 comment "Raw/parallel NAND flash controllers"
 
+config MTD_FORCE_BAD_BLOCK_ERASE
+	bool "Force erase on bad blocks (useful for bootloader parts)"
+	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
 
@@ -53,6 +61,10 @@
 	  Enable the driver for NAND flash on platforms using a Denali NAND
 	  controller as a DT device.
 
+config MTD_NAND_DENALI_FBX
+	tristate "NAND Denali controller support"
+	depends on PCI
+
 config MTD_NAND_AMS_DELTA
 	tristate "Amstrad E3 NAND controller"
 	depends on MACH_AMS_DELTA || COMPILE_TEST
diff -ruw linux-5.4.60/drivers/mtd/nand/raw/Makefile linux-5.4.60-fbx/drivers/mtd/nand/raw/Makefile
--- linux-5.4.60/drivers/mtd/nand/raw/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mtd/nand/raw/Makefile	2021-03-04 13:20:58.957505608 +0100
@@ -10,6 +10,7 @@
 obj-$(CONFIG_MTD_NAND_DENALI)		+= denali.o
 obj-$(CONFIG_MTD_NAND_DENALI_PCI)	+= denali_pci.o
 obj-$(CONFIG_MTD_NAND_DENALI_DT)	+= denali_dt.o
+obj-$(CONFIG_MTD_NAND_DENALI_FBX)	+= denali_nand.o
 obj-$(CONFIG_MTD_NAND_AU1550)		+= au1550nd.o
 obj-$(CONFIG_MTD_NAND_S3C2410)		+= s3c2410.o
 obj-$(CONFIG_MTD_NAND_TANGO)		+= tango_nand.o
diff -ruw linux-5.4.60/drivers/mtd/nand/raw/nand_base.c linux-5.4.60-fbx/drivers/mtd/nand/raw/nand_base.c
--- linux-5.4.60/drivers/mtd/nand/raw/nand_base.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mtd/nand/raw/nand_base.c	2021-03-04 13:20:58.964172275 +0100
@@ -4211,6 +4211,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(chip, ((loff_t) page) <<
 					chip->page_shift, allowbbt)) {
 			pr_warn("%s: attempt to erase a bad block at page 0x%08x\n",
@@ -4218,6 +4219,7 @@
 			ret = -EIO;
 			goto erase_exit;
 		}
+#endif
 
 		/*
 		 * Invalidate the page cache, if we erase the block which
@@ -4830,6 +4832,14 @@
 	pr_info("%d MiB, %s, erase size: %d KiB, page size: %d, OOB size: %d\n",
 		(int)(targetsize >> 20), nand_is_slc(chip) ? "SLC" : "MLC",
 		mtd->erasesize >> 10, mtd->writesize, mtd->oobsize);
+
+	mtd->nand_type = chip->parameters.model;
+	mtd->nand_manufacturer = nand_manufacturer_name(manufacturer);
+	if (chip->parameters.onfi) {
+		mtd->onfi_ecc_bits = chip->base.eccreq.strength;
+		mtd->onfi_model = chip->parameters.model;
+	}
+
 	return 0;
 
 free_detect_allocation:
@@ -5100,9 +5110,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;
@@ -5123,9 +5137,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;
 
 		/*
@@ -5768,7 +5786,7 @@
 	/* Large page NAND with SOFT_ECC should support subpage reads */
 	switch (ecc->mode) {
 	case NAND_ECC_SOFT:
-		if (chip->page_shift > 9)
+		if (chip->page_shift > 9 && !(chip->options & NAND_NO_RNDOUT))
 			chip->options |= NAND_SUBPAGE_READ;
 		break;
 
diff -ruw linux-5.4.60/drivers/mtd/nand/raw/nand_bch.c linux-5.4.60-fbx/drivers/mtd/nand/raw/nand_bch.c
--- linux-5.4.60/drivers/mtd/nand/raw/nand_bch.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mtd/nand/raw/nand_bch.c	2021-03-04 13:20:58.964172275 +0100
@@ -80,6 +80,7 @@
 					errloc[i]);
 		}
 	} else if (count < 0) {
+		if (printk_ratelimit())
 		pr_err("ecc unrecoverable error\n");
 		count = -EBADMSG;
 	}
diff -ruw linux-5.4.60/drivers/mtd/nand/raw/nand_ecc.c linux-5.4.60-fbx/drivers/mtd/nand/raw/nand_ecc.c
--- linux-5.4.60/drivers/mtd/nand/raw/nand_ecc.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mtd/nand/raw/nand_ecc.c	2021-03-04 13:20:58.964172275 +0100
@@ -455,6 +455,7 @@
 	if ((bitsperbyte[b0] + bitsperbyte[b1] + bitsperbyte[b2]) == 1)
 		return 1;	/* error in ECC data; no action needed */
 
+	if (printk_ratelimit())
 	pr_err("%s: uncorrectable ECC error\n", __func__);
 	return -EBADMSG;
 }
diff -ruw linux-5.4.60/drivers/mtd/parsers/Kconfig linux-5.4.60-fbx/drivers/mtd/parsers/Kconfig
--- linux-5.4.60/drivers/mtd/parsers/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mtd/parsers/Kconfig	2021-03-04 13:20:58.967505609 +0100
@@ -67,6 +67,10 @@
 	  flash memory node, as described in
 	  Documentation/devicetree/bindings/mtd/partition.txt.
 
+config MTD_OF_PARTS_IGNORE_RO
+	bool "ignore read-only flag"
+	depends on MTD_OF_PARTS
+
 config MTD_PARSER_IMAGETAG
 	tristate "Parser for BCM963XX Image Tag format partitions"
 	depends on BCM63XX || BMIPS_GENERIC || COMPILE_TEST
@@ -160,3 +164,14 @@
 	  'FIS directory' images, enable this option.
 
 endif # MTD_REDBOOT_PARTS
+
+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
diff -ruw linux-5.4.60/drivers/mtd/parsers/Makefile linux-5.4.60-fbx/drivers/mtd/parsers/Makefile
--- linux-5.4.60/drivers/mtd/parsers/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mtd/parsers/Makefile	2021-03-04 13:20:58.967505609 +0100
@@ -9,3 +9,4 @@
 obj-$(CONFIG_MTD_PARSER_TRX)		+= parser_trx.o
 obj-$(CONFIG_MTD_SHARPSL_PARTS)		+= sharpslpart.o
 obj-$(CONFIG_MTD_REDBOOT_PARTS)		+= redboot.o
+obj-$(CONFIG_MTD_FBX6HD_PARTS)	+= fbx6hd-mtdparts.o
diff -ruw linux-5.4.60/drivers/mtd/parsers/ofpart.c linux-5.4.60-fbx/drivers/mtd/parsers/ofpart.c
--- linux-5.4.60/drivers/mtd/parsers/ofpart.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mtd/parsers/ofpart.c	2021-03-04 13:20:58.967505609 +0100
@@ -111,8 +111,10 @@
 			partname = of_get_property(pp, "name", &len);
 		parts[i].name = partname;
 
+#ifndef CONFIG_MTD_OF_PARTS_IGNORE_RO
 		if (of_get_property(pp, "read-only", &len))
 			parts[i].mask_flags |= MTD_WRITEABLE;
+#endif
 
 		if (of_get_property(pp, "lock", &len))
 			parts[i].mask_flags |= MTD_POWERUP_LOCK;
diff -ruw linux-5.4.60/drivers/mtd/spi-nor/spi-nor.c linux-5.4.60-fbx/drivers/mtd/spi-nor/spi-nor.c
--- linux-5.4.60/drivers/mtd/spi-nor/spi-nor.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/mtd/spi-nor/spi-nor.c	2021-03-04 13:20:58.970838942 +0100
@@ -178,6 +178,7 @@
 
 struct flash_info {
 	char		*name;
+	uint32_t	ext_id;
 
 	/*
 	 * This array stores the ID bytes.
@@ -196,7 +197,8 @@
 	u16		page_size;
 	u16		addr_width;
 
-	u16		flags;
+	u32		flags;
+
 #define SECT_4K			BIT(0)	/* SPINOR_OP_BE_4K works uniformly */
 #define SPI_NOR_NO_ERASE	BIT(1)	/* No erase command needed */
 #define SST_WRITE		BIT(2)	/* use SST byte programming */
@@ -234,6 +236,9 @@
 #define USE_CLSR		BIT(14)	/* use CLSR command */
 #define SPI_NOR_OCTAL_READ	BIT(15)	/* Flash supports Octal Read */
 
+#define ALT_PROBE		BIT(16)	/* only match during alt_probe */
+#define ALT_PROBE_ATMEL		BIT(17)	/* only match during alt_probe_atmel */
+
 	/* Part specific fixup hooks. */
 	const struct spi_nor_fixups *fixups;
 };
@@ -2033,6 +2038,7 @@
 
 /* Used when the "_ext_id" is two bytes at most */
 #define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)	\
+		.ext_id = (_ext_id),					\
 		.id = {							\
 			((_jedec_id) >> 16) & 0xff,			\
 			((_jedec_id) >> 8) & 0xff,			\
@@ -2047,6 +2053,7 @@
 		.flags = (_flags),
 
 #define INFO6(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)	\
+		.ext_id = (_ext_id),					\
 		.id = {							\
 			((_jedec_id) >> 16) & 0xff,			\
 			((_jedec_id) >> 8) & 0xff,			\
@@ -2503,6 +2510,22 @@
 	/* XMC (Wuhan Xinxin Semiconductor Manufacturing Corp.) */
 	{ "XM25QH64A", INFO(0x207017, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 	{ "XM25QH128A", INFO(0x207018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
+
+	/* 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) },
+
 	{ },
 };
 
@@ -2541,6 +2564,69 @@
 	return ERR_PTR(-ENODEV);
 }
 
+static const struct flash_info *spi_nor_alt_read_id(struct spi_nor *nor)
+{
+	u8 data[2];
+	u16 id;
+	int err, tmp;
+	const struct flash_info	*info;
+	struct spi_mem_op op =
+		SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDID_ALT, 1),
+			   SPI_MEM_OP_ADDR(3, 0, 1),
+			   SPI_MEM_OP_NO_DUMMY,
+			   SPI_MEM_OP_DATA_IN(sizeof (data), data, 1));
+
+	BUG_ON(!nor->spimem);
+
+	err = spi_mem_exec_op(nor->spimem, &op);
+	if (err < 0) {
+		dev_err(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 = &spi_nor_ids[tmp];
+		if ((info->flags & ALT_PROBE) && (info->ext_id == id))
+			return info;
+	}
+
+	dev_err(nor->dev, "unrecognized ALT id %04x\n", id);
+	return ERR_PTR(-ENODEV);
+}
+
+static const struct flash_info *spi_nor_atmel_id(struct spi_nor *nor)
+{
+	u8 data[2];
+	u16 id;
+	int err, tmp;
+	const struct flash_info	*info;
+	struct spi_mem_op op =
+		SPI_MEM_OP(SPI_MEM_OP_CMD(0x15, 1),
+			   SPI_MEM_OP_NO_ADDR,
+			   SPI_MEM_OP_NO_DUMMY,
+			   SPI_MEM_OP_DATA_IN(sizeof (data), data, 1));
+
+	BUG_ON(!nor->spimem);
+
+	err = spi_mem_exec_op(nor->spimem, &op);
+	if (err < 0) {
+		dev_err(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 = &spi_nor_ids[tmp];
+		if ((info->flags & ALT_PROBE_ATMEL) && (info->ext_id == id))
+			return info;
+	}
+
+	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)
 {
@@ -4746,6 +4832,19 @@
 	return NULL;
 }
 
+static void sst_write_enable(struct spi_nor *nor)
+{
+	struct spi_mem_op op =
+		SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_EWRSR, 1),
+			   SPI_MEM_OP_NO_ADDR,
+			   SPI_MEM_OP_NO_DUMMY,
+			   SPI_MEM_OP_NO_DATA);
+	write_enable(nor);
+	BUG_ON(!nor->spimem);
+	spi_mem_exec_op(nor->spimem, &op);
+	write_sr(nor, 0);
+}
+
 static int spi_nor_set_addr_width(struct spi_nor *nor)
 {
 	if (nor->addr_width) {
@@ -4803,6 +4902,12 @@
 	if (name && info->id_len) {
 		const struct flash_info *jinfo;
 
+		jinfo = spi_nor_alt_read_id(nor);
+		if (IS_ERR(jinfo))
+			/* try ATMEL */
+			jinfo = spi_nor_atmel_id(nor);
+		if (IS_ERR(jinfo))
+			/* try JEDEC */
 		jinfo = spi_nor_read_id(nor);
 		if (IS_ERR(jinfo)) {
 			return jinfo;
@@ -4891,6 +4996,9 @@
 	/* Init flash parameters based on flash_info struct and SFDP */
 	spi_nor_init_params(nor);
 
+	if (info->ext_id == 0xbf48)
+		sst_write_enable(nor);
+
 	if (!mtd->name)
 		mtd->name = dev_name(dev);
 	mtd->priv = nor;
diff -ruw linux-5.4.60/drivers/net/ethernet/broadcom/Kconfig linux-5.4.60-fbx/drivers/net/ethernet/broadcom/Kconfig
--- linux-5.4.60/drivers/net/ethernet/broadcom/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/ethernet/broadcom/Kconfig	2021-03-04 13:20:59.017505610 +0100
@@ -60,6 +60,45 @@
 	  This driver supports the ethernet MACs in the Broadcom 63xx
 	  MIPS chipset family (BCM63XX).
 
+config BCM63XX_ENET_RUNNER
+	tristate "Broadcom 63xx (63138) runner ethernet support"
+	select MII
+	select FIXED_PHY
+	select PHYLIB
+	select BCM7XXX_PHY
+	select BROADCOM_PHY
+	select SOC_BCM63XX_RDP
+
+config BCM63158_SF2
+	tristate "Broadcom 63158 SF2 support"
+	select MII
+	select PHYLINK
+	select BCM7XXX_PHY
+	select BROADCOM_PHY
+	select NET_DSA
+	select NET_DSA_TAG_BRCM_FBX
+
+config BCM63158_SYSTEMPORT
+	tristate "Broadcom 63158 SYSTEMPORT internal MAC support"
+	depends on OF
+	select MII
+	select PHYLINK
+
+config BCM63158_ENET_RUNNER
+	tristate "Broadcom 63158 runner ethernet support"
+	select MII
+	select PHYLINK
+	select SOC_BCM63XX_XRDP
+
+config BCM63158_ENET_RUNNER_FF
+	bool "fastpath support for freebox boards"
+	depends on BCM63158_ENET_RUNNER
+	select IP_FFN
+	select IPV6_FFN
+	select IPV6_SIT_6RD
+	select BRIDGE
+	select FBXBRIDGE
+
 config BCMGENET
 	tristate "Broadcom GENET internal MAC support"
 	depends on HAS_IOMEM
diff -ruw linux-5.4.60/drivers/net/ethernet/broadcom/Makefile linux-5.4.60-fbx/drivers/net/ethernet/broadcom/Makefile
--- linux-5.4.60/drivers/net/ethernet/broadcom/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/ethernet/broadcom/Makefile	2021-03-04 13:20:59.017505610 +0100
@@ -16,3 +16,5 @@
 obj-$(CONFIG_BGMAC_PLATFORM) += bgmac-platform.o
 obj-$(CONFIG_SYSTEMPORT) += bcmsysport.o
 obj-$(CONFIG_BNXT) += bnxt/
+obj-$(CONFIG_BCM63XX_ENET_RUNNER) += bcm63xx_enet_runner/
+obj-y += bcm63158/
diff -ruw linux-5.4.60/drivers/net/ethernet/Kconfig linux-5.4.60-fbx/drivers/net/ethernet/Kconfig
--- linux-5.4.60/drivers/net/ethernet/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/ethernet/Kconfig	2021-03-04 13:20:58.997505609 +0100
@@ -180,6 +180,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-5.4.60/drivers/net/ethernet/Makefile linux-5.4.60-fbx/drivers/net/ethernet/Makefile
--- linux-5.4.60/drivers/net/ethernet/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/ethernet/Makefile	2021-03-04 13:20:58.997505609 +0100
@@ -92,6 +92,7 @@
 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/
 obj-$(CONFIG_NET_VENDOR_SYNOPSYS) += synopsys/
diff -ruw linux-5.4.60/drivers/net/ethernet/marvell/Kconfig linux-5.4.60-fbx/drivers/net/ethernet/marvell/Kconfig
--- linux-5.4.60/drivers/net/ethernet/marvell/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/ethernet/marvell/Kconfig	2021-03-04 13:20:59.164172284 +0100
@@ -23,6 +23,7 @@
 	depends on 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
@@ -31,6 +32,15 @@
 	  Some boards that use the Discovery chipset are the Momenco
 	  Ocelot C and Jaguar ATX and Pegasos II.
 
+config MV643XX_ETH_FBX_FF
+	bool "fastpath support for freebox boards"
+	depends on MV643XX_ETH
+	select IP_FFN
+	select IPV6_FFN
+	select IPV6_SIT_6RD
+	select BRIDGE
+	select FBXBRIDGE
+
 config MVMDIO
 	tristate "Marvell MDIO interface support"
 	depends on HAS_IOMEM
@@ -86,10 +96,20 @@
 	depends on ARCH_MVEBU || COMPILE_TEST
 	select MVMDIO
 	select PHYLINK
+	select MII
 	---help---
 	  This driver supports the network interface units in the
 	  Marvell ARMADA 375, 7K and 8K SoCs.
 
+config MVPP2_FBX_FF
+	bool "fastpath support for freebox boards"
+	depends on MVPP2
+	select IP_FFN
+	select IPV6_FFN
+	select IPV6_SIT_6RD
+	select BRIDGE
+	select FBXBRIDGE
+
 config PXA168_ETH
 	tristate "Marvell pxa168 ethernet support"
 	depends on HAS_IOMEM
diff -ruw linux-5.4.60/drivers/net/ethernet/marvell/mv643xx_eth.c linux-5.4.60-fbx/drivers/net/ethernet/marvell/mv643xx_eth.c
--- linux-5.4.60/drivers/net/ethernet/marvell/mv643xx_eth.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/ethernet/marvell/mv643xx_eth.c	2021-03-04 13:20:59.164172284 +0100
@@ -52,6 +52,20 @@
 #include <linux/of_irq.h>
 #include <linux/of_net.h>
 #include <linux/of_mdio.h>
+#include <linux/if_vlan.h>
+#include <linux/sort.h>
+
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+#include <net/arp.h>
+#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>
+
+#include "../../../net/bridge/br_private.h"
+#include "../../../net/fbxbridge/fbxbr_private.h"
+#endif
 
 static char mv643xx_eth_driver_name[] = "mv643xx_eth";
 static char mv643xx_eth_driver_version[] = "1.4";
@@ -95,6 +109,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
@@ -121,6 +136,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
@@ -169,7 +185,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
@@ -192,6 +210,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 {
@@ -200,6 +220,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 {
@@ -208,6 +231,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 {
@@ -216,6 +241,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
@@ -226,6 +254,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
@@ -237,6 +270,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 */
@@ -273,7 +307,9 @@
 	int extended_rx_coal_limit;
 	int tx_bw_control;
 	int tx_csum_limit;
+	int unit;
 	struct clk *clk;
+	struct mii_bus *mii_bus;
 };
 
 #define TX_BW_CONTROL_ABSENT		0
@@ -319,23 +355,30 @@
 	/* 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;
+	unsigned int *rx_desc_map_sizes;
 };
 
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+#define NAPI_TX_OFFSET	1
+#else
+#define NAPI_TX_OFFSET	0
+#endif
+
 struct tx_queue {
 	int index;
 
@@ -378,14 +421,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.
@@ -394,7 +436,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];
 
 	/*
@@ -411,8 +452,19 @@
 	 */
 	struct clk *clk;
 	unsigned int t_clk;
+
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	struct tx_queue *ff_txq;
+	struct notifier_block ff_notifier;
+#endif
+
+	u32 ftth_tx_shaper_rate;
+	u32 ftth_tx_shaper_burst;
 };
 
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+static struct mv643xx_eth_private *mp_by_unit[4];
+#endif
 
 /* port register accessors **************************************************/
 static inline u32 rdl(struct mv643xx_eth_private *mp, int offset)
@@ -492,7 +544,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());
@@ -502,152 +559,2128 @@
 	}
 }
 
-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];
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
 
-		cmd_sts = rx_desc->cmd_sts;
-		if (cmd_sts & BUFFER_OWNED_BY_DMA)
-			break;
-		rmb();
+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;
 
-		skb = rxq->rx_skb[rxq->rx_curr_desc];
-		rxq->rx_skb[rxq->rx_curr_desc] = NULL;
+	if (!txq || !txq->tx_desc_count)
+		return false;
 
-		rxq->rx_curr_desc++;
-		if (rxq->rx_curr_desc == rxq->rx_ring_size)
-			rxq->rx_curr_desc = 0;
+	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;
+}
+
+
+/*
+ * size on which we invalidate data when we reclaim fast-forwarded
+ * buffer
+ *
+ * worst case read lookup by rx path from RX_OFFSET is (VLAN + ip6 +
+ * iph + tcphdr)
+ */
+#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,
+			  unsigned int *pmap_size,
+			  bool unmap)
+{
+	unsigned int map_size = mp->pkt_size;
+	void *frag;
+	bool frag_allocated = true;
+
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	if (ff_enabled) {
+		struct mv643xx_eth_private *omp;
+
+		/*
+		 * try to reclaim from "opposite" fast forward dedicated tx
+		 * queue
+		 */
+		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;
+			frag_allocated = false;
+		}
+	} 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,
-				 rx_desc->buf_size, DMA_FROM_DEVICE);
-		rxq->rx_desc_count--;
-		rx++;
+				 *pmap_size, DMA_FROM_DEVICE);
 
-		mp->work_rx_refill |= 1 << rxq->index;
+	*pmap_size = map_size;
+	rx_desc->buf_ptr = dma_map_single(mp->dev->dev.parent,
+					  frag + RX_OFFSET,
+					  map_size,
+					  DMA_FROM_DEVICE);
+	if (unlikely(dma_mapping_error(mp->dev->dev.parent,
+				       rx_desc->buf_ptr))) {
+		WARN(1, "dma_map_single failed!\n");
+		if (frag_allocated)
+			mv643xx_eth_frag_free(frag, mp);
+		return -ENOMEM;
+	}
 
-		byte_cnt = rx_desc->byte_cnt;
+	rx_desc->buf_size = mp->pkt_size;
+	rx_desc->cookie = (u32)frag;
+	wmb();
+	rx_desc->cmd_sts = BUFFER_OWNED_BY_DMA | RX_ENABLE_INTERRUPT;
+	return 0;
+}
+
+static inline bool pkt_is_ipv4(u32 cmd_sts)
+{
+	return (cmd_sts & RX_PKT_IS_IPV4) == RX_PKT_IS_IPV4;
+}
+
+static inline bool pkt_is_tcp4(u32 cmd_sts)
+{
+	return (cmd_sts & RX_PKT_LAYER4_TYPE_MASK) ==
+		RX_PKT_LAYER4_TYPE_TCP_IPV4;
+}
+
+static inline bool pkt_is_udp4(u32 cmd_sts)
+{
+	return (cmd_sts & RX_PKT_LAYER4_TYPE_MASK) ==
+		RX_PKT_LAYER4_TYPE_UDP_IPV4;
+}
+
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+
+static inline bool pkt_is_vlan(u32 cmd_sts)
+{
+	return (cmd_sts & RX_PKT_IS_VLAN_TAGGED) == RX_PKT_IS_VLAN_TAGGED;
+}
+
+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;
+	struct fbxbr_port	*fbxbr_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 inline bool is_fbxbridge_port(struct net_device *dev)
+{
+        return dev->priv_flags & IFF_FBXBRIDGE_PORT;
+}
+
+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)
+{
+	int was_on = 0;
+
+	local_bh_disable();
+	if (ff.tun_dev) {
+		dev_put(ff.tun_dev);
+		ff.tun_dev = NULL;
+		was_on = 1;
+	}
+	local_bh_enable();
+	if (was_on)
+		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;
+			struct fbxbr *fbxbr;
+			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) {
+					rcu_read_lock();
+					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;
+
+					if ((dev->priv_flags &
+					     IFF_FBXBRIDGE_PORT) &&
+					    netdev_master_upper_dev_get(dev))
+						ff_dev->fbxbr_port = fbxbr_port_get_rcu(dev);
+					else
+						ff_dev->fbxbr_port = NULL;
+					rcu_read_unlock();
+				}
+				break;
+
+			default:
+				break;
+			}
+
+			ok = false;
+			br = NULL;
+			fbxbr = NULL;
+			if (ff_dev->dev_up && ff_dev->br_port) {
+				br = ff_dev->br_port->br;
+				if (br->dev->flags & IFF_UP)
+					ok = true;
+			}
+
+			if (ff_dev->dev_up && ff_dev->fbxbr_port) {
+				fbxbr = ff_dev->fbxbr_port->br;
+				if (fbxbr->dev->flags & IFF_UP)
+					ok = true;
+			}
+
+			if (!(ok ^ ff_dev->active))
+				continue;
+
+			if (ok) {
+				struct net_device *br_dev;
+				struct net_device *true_dev;
+
+				if (br) {
+					br_dev = br->dev;
+					true_dev = br->dev;
+				} else {
+					br_dev = fbxbr->dev;
+					true_dev = mp->dev;
+				}
+
+				dev_hold(true_dev);
+				local_bh_disable();
+				*(ff_dev->pvirt_dev) = true_dev;
+				local_bh_enable();
+				ff_dev->active = true;
+
+				printk(KERN_INFO "ff: ff_dev %s: active "
+				       "for %s\n", ff_dev->desc,
+				       true_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,
+};
 
 		/*
-		 * Update statistics.
 		 *
-		 * 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).
 		 */
-		stats->rx_packets++;
-		stats->rx_bytes += byte_cnt - 2;
+static bool ff_send(struct mv643xx_eth_private *mp,
+		    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 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(mp->dev->dev.parent, 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;
+	}
+
+	tx_desc->cmd_sts = cmd_sts;
+	txq_enable(txq);
+
+	txq->tx_bytes += send_len;
+	txq->tx_packets++;
+
+	return 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.
+ * ipv4 forward cache private data
 		 */
-		if ((cmd_sts & (RX_FIRST_DESC | RX_LAST_DESC | ERROR_SUMMARY))
-			!= (RX_FIRST_DESC | RX_LAST_DESC))
-			goto err;
+struct ff_priv {
+	struct in6_addr		tun_dest_ip6;
+	struct dst_entry	*tun_dst;
+};
+
+static void ff_priv_release(const struct ff_priv *priv)
+{
+	dst_release(priv->tun_dst);
+}
+
+static void ff_priv_destructor_cb(void *data)
+{
+	const struct ff_priv *priv = (const struct ff_priv *)data;
+	ff_priv_release(priv);
+}
+
+static const struct ff_priv *ffn_get_ro_priv(const struct ffn_lookup_entry *e)
+{
+	if (e->manip.priv_destructor != ff_priv_destructor_cb)
+		return NULL;
+
+	return (const struct ff_priv *)e->manip.ffn_priv_area;
+}
+
+static struct ff_priv *ffn_get_rw_priv(struct ffn_lookup_entry *e)
+{
+	BUILD_BUG_ON(sizeof (e->manip.ffn_priv_area) <
+		     sizeof (struct ff_priv));
+
+	if (e->manip.priv_destructor &&
+	    e->manip.priv_destructor != ff_priv_destructor_cb)
+		return NULL;
+
+	return (struct ff_priv *)e->manip.ffn_priv_area;
+}
+
+static const struct ff_priv *fwc_get_ro_priv(const struct fbxbr_fwcache *fwc)
+{
+	if (fwc->priv_destructor != ff_priv_destructor_cb)
+		return NULL;
+
+	return (const struct ff_priv *)fwc->priv_area;
+}
+
+static struct ff_priv *fwc_get_rw_priv(const struct fbxbr_fwcache *fwc)
+{
+	BUILD_BUG_ON(sizeof (fwc->priv_area) < sizeof (struct ff_priv));
+
+	if (fwc->priv_destructor &&
+	    fwc->priv_destructor != ff_priv_destructor_cb)
+		return NULL;
+
+	return (struct ff_priv *)fwc->priv_area;
+}
 
 		/*
-		 * The -4 is for the CRC in the trailer of the
-		 * received packet
+ * ipv6 forward cache private data
 		 */
-		skb_put(skb, byte_cnt - 2 - 4);
+struct ff6_priv {
+	u32			tun_dest_ip;
+	struct dst_entry	*tun_dst;
+};
 
-		if (cmd_sts & LAYER_4_CHECKSUM_OK)
-			skb->ip_summed = CHECKSUM_UNNECESSARY;
-		skb->protocol = eth_type_trans(skb, mp->dev);
+static void ff6_priv_release(const struct ff6_priv *priv)
+{
+	dst_release(priv->tun_dst);
+}
 
-		napi_gro_receive(&mp->napi, skb);
+static void ff6_priv_destructor_cb(void *data)
+{
+	const struct ff6_priv *priv = (const struct ff6_priv *)data;
+	ff6_priv_release(priv);
+}
 
-		continue;
+static const struct ff6_priv *ffn6_get_ro_priv(const struct ffn6_lookup_entry *e6)
+{
+	if (e6->manip.priv_destructor != ff6_priv_destructor_cb)
+		return NULL;
 
-err:
-		stats->rx_dropped++;
+	return (const struct ff6_priv *)e6->manip.ffn_priv_area;
+}
 
-		if ((cmd_sts & (RX_FIRST_DESC | RX_LAST_DESC)) !=
-			(RX_FIRST_DESC | RX_LAST_DESC)) {
-			if (net_ratelimit())
-				netdev_err(mp->dev,
-					   "received packet spanning multiple descriptors\n");
+static struct ff6_priv *ffn6_get_rw_priv(struct ffn6_lookup_entry *e6)
+{
+	BUILD_BUG_ON(sizeof (e6->manip.ffn_priv_area) <
+		     sizeof (struct ff6_priv));
+
+	if (e6->manip.priv_destructor &&
+	    e6->manip.priv_destructor != ff6_priv_destructor_cb)
+		return NULL;
+
+	return (struct ff6_priv *)e6->manip.ffn_priv_area;
 		}
 
-		if (cmd_sts & ERROR_SUMMARY)
-			stats->rx_errors++;
+/*
+ *
+ */
+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;
 
-		dev_kfree_skb(skb);
+	a2 = ntohl(d->s6_addr32[1] & ff.u.sit.s6rd_pmask);
+	a2 >>= (32 - ff.u.sit.s6rd_plen);
+	return htonl(a1 | a2);
 	}
 
-	if (rx < budget)
-		mp->work_rx &= ~(1 << rxq->index);
+/*
+ *
+ */
+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,
+		       bool wan_to_lan,
+		       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 *pmap_size,
+		       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 net_device *last_rx_dev, *next_tx_dev;
+	struct ffn_lookup_entry *e;
+	struct ffn6_lookup_entry *e6;
+	struct tx_queue *txq;
+	struct nf_conn *ct = NULL;
+	struct ethhdr *eth;
+	enum ff_xmit_mode xmit_mode;
+	u8 dest_hw[6];
+	u32 buf_addr;
+	unsigned int timeout;
+	void *l2_hdr, *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;
+	struct net_device *soft_tx_dev;
+
+	/* make sure we have headroom for the worst case scenario */
+	BUILD_BUG_ON(NET_SKB_PAD <
+		     (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;
+	}
+
+	last_rx_dev = rx_dev;
+	l3_is_ipv4 = pkt_is_ipv4(cmd_sts);
+
+	if (l3_is_ipv4) {
+		struct iphdr *iph;
+		struct fbxbr_fwcache *fwc;
+		struct fbxbr *fbxbr;
+		struct fbxbr_port *fbxbr_fwd_port;
+		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;
+
+		if (is_fbxbridge_port(last_rx_dev)) {
+			struct fbxbr_fwcache_key k;
+			struct fbxbr_port *p;
+			u32 hash;
+
+			p = fbxbr_port_get_rcu(last_rx_dev);
+			fbxbr = p->br;
+
+			if (wan_to_lan) {
+				WARN_ON(!p->is_wan);
+				k.wan_ip = iph->saddr;
+				k.lan_ip = iph->daddr;
+				k.wan_port = sport;
+				k.lan_port = dport;
+				fbxbr_fwd_port = fbxbr->lan_port;
+			} else {
+				WARN_ON(p->is_wan);
+				k.lan_ip = iph->saddr;
+				k.wan_ip = iph->daddr;
+				k.lan_port = sport;
+				k.wan_port = dport;
+				fbxbr_fwd_port = fbxbr->wan_port;
+			}
+			k.is_tcp = l4_is_tcp;
+
+			if (!unlikely(fbxbr_fwd_port))
+				return false;
+
+			hash = fbxbr_fwcache_hash(&k);
+			fwc = __fbxbr_fwcache_lookup(p->br, hash, &k);
+			if (!fwc)
+				return false;
+
+			next_tx_dev = fbxbr_fwd_port->dev;
+			e = NULL;
+		} else {
+			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;
+
+			next_tx_dev = e->manip.dst->dev;
+			fwc = NULL;
+		}
+
+		/* find out if the packet is to be sent as-is or
+		 * tunneled */
+		if (ff.tun_dev && next_tx_dev == ff.tun_dev) {
+			const struct ff_priv *ff_priv;
+			struct ff_priv *ff_wpriv;
+			struct dst_entry *v6_dst;
+			const struct in6_addr *pdest, *nexthop;
+			struct in6_addr dest;
+			struct rt6_info *rt6;
+			struct neighbour *neigh;
+
+			/* IPv4 tunneled into MAP-E device */
+			if (!ff.tun_ready) {
+				return false;
+			}
+
+			if (l3_plen > ff.tun_mtu)
+				return false;
+
+			/* lookup ipv6 route cache */
+			if (e)
+				ff_priv = ffn_get_ro_priv(e);
+			else
+				ff_priv = fwc_get_ro_priv(fwc);
+
+			if (ff_priv) {
+				if (ff_priv->tun_dst->obsolete < 0) {
+					/* valid route found */
+ 					v6_dst = ff_priv->tun_dst;
+					pdest = &ff_priv->tun_dest_ip6;
+					goto cached_ipv6_route;
+				}
+
+				ff_priv_release(ff_priv);
+				if (e)
+					e->manip.priv_destructor = NULL;
+				else
+					fwc->priv_destructor = NULL;
+			}
+
+			/* cache miss, compute IPv6 destination */
+			if (ff.u.map.ipv4_prefix &&
+			    (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, NULL, 0);
+			if (!rt6)
+				return false;
+
+			if (e)
+				ff_wpriv = ffn_get_rw_priv(e);
+			else
+				ff_wpriv = fwc_get_rw_priv(fwc);
+			if (!ff_wpriv)
+				return false;
+
+			/* cache this inside FFN private area */
+			ff_wpriv->tun_dst = (struct dst_entry *)rt6;
+			memcpy(&ff_wpriv->tun_dest_ip6, pdest, 16);
+			if (e)
+				e->manip.priv_destructor = ff_priv_destructor_cb;
+			else
+				fwc->priv_destructor = ff_priv_destructor_cb;
+			ff_priv = ff_wpriv;
+
+			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, (struct in6_addr *)pdest);
+			if (!nexthop) {
+				return false;
+			}
+
+			neigh = __ipv6_neigh_lookup_noref(tx_dev, nexthop);
+			if (!neigh || !(neigh->nud_state & NUD_VALID))
+				return false;
+			memcpy(dest_hw, neigh->ha, 6);
+
+			xmit_mode = FF_XMIT_IPV4_IN_IPV6;
+			tun_v6_pdest = &ff_priv->tun_dest_ip6;
+
+		} else if (next_tx_dev == tx_dev) {
+			struct neighbour *neigh;
+			const struct rtable *rt;
+
+			/* is the neighboor ready ? */
+			if (e) {
+				u32 nexthop;
+
+				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 || !(neigh->nud_state & NUD_VALID))
+					return false;
+
+				memcpy(dest_hw, neigh->ha, 6);
+			} else {
+				if (!fbxbr_fwd_port->is_wan) {
+					if (!fbxbr->have_hw_addr)
+						return false;
+					memcpy(dest_hw, fbxbr->lan_hwaddr, 6);
+				} else {
+					__be32 nh;
+
+					nh = iph->daddr;
+					if ((nh & fbxbr->wan_netmask) !=
+					    (fbxbr->wan_ipaddr &
+					     fbxbr->wan_netmask)) {
+						rt = fbxbr_fwd_port->rt;
+						if (!rt ||
+						    rt->dst.obsolete > 0)
+							return false;
+
+						nh = rt_nexthop(rt, nh);
+					}
+
+					neigh = __ipv4_neigh_lookup_noref(
+						tx_dev, nh);
+					if (!neigh ||
+					    !(neigh->nud_state & NUD_VALID))
+						return false;
+
+					memcpy(dest_hw, neigh->ha, 6);
+				}
+			}
+
+			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;
+			}
+
+			if (!ff.tun_dev)
+				return false;
+
+			last_rx_dev = ff.tun_dev;
+			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) {
+			const struct ff6_priv *ff6_priv;
+			struct ff6_priv *ff6_wpriv;
+			struct dst_entry *v4_dst;
+			struct flowi4 fl4;
+			struct rtable *rt;
+			struct neighbour *neigh;
+			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 */
+			ff6_priv = ffn6_get_ro_priv(e6);
+			if (ff6_priv) {
+				if (!ff6_priv->tun_dst->obsolete) {
+					/* valid route found */
+					v4_dst = ff6_priv->tun_dst;
+					dest = ff6_priv->tun_dest_ip;
+					goto cached_ipv4_route;
+				}
+
+				ff6_priv_release(ff6_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 {
+				const 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;
+
+			ff6_wpriv = ffn6_get_rw_priv(e6);
+			if (!ff6_wpriv)
+				return false;
+
+			/* cache this inside FFN private area */
+			ff6_wpriv->tun_dst = (struct dst_entry *)rt;
+			ff6_wpriv->tun_dest_ip = dest;
+			e6->manip.priv_destructor = ff6_priv_destructor_cb;
+
+			v4_dst = (struct dst_entry *)rt;
+			ff6_priv = ff6_wpriv;
+
+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 || !(neigh->nud_state & NUD_VALID))
+				return false;
+			memcpy(dest_hw, neigh->ha, 6);
+
+			tun_v4_dest = dest;
+			xmit_mode = FF_XMIT_IPV6_IN_IPV4;
+
+		} else if (e6->manip.dst->dev == tx_dev) {
+			const struct in6_addr *nexthop;
+			const struct rt6_info *rt6;
+			struct neighbour *neigh;
+
+			/* is the neighboor ready ? */
+			rt6 = (const 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 || !(neigh->nud_state & NUD_VALID))
+				return false;
+			memcpy(dest_hw, neigh->ha, 6);
+
+			xmit_mode = FF_XMIT_IPV6;
+		} else
+			return false;
+	}
+
+	/* is destination on correct tx bridge port ? */
+	soft_tx_dev = NULL;
+	if (is_bridge_dev(tx_dev)) {
+		struct net_bridge_port *p = br_port_get_rcu(tx_mp->dev);
+		struct net_bridge_fdb_entry *fdb;
 
-	return rx;
+		fdb = br_fdb_find_rcu(p->br, dest_hw, 0);
+		if (!fdb)
+			return false;
+
+		if (fdb->dst != p)
+			soft_tx_dev = fdb->dst->dev;
+	}
+
+	if (!soft_tx_dev)
+		txq = tx_mp->ff_txq;
+	else
+		txq = NULL;
+
+	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 &&
+	    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 | RX_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, pmap_size, true)) {
+		/* just rearm descriptor and fake success */
+		rx_desc->cmd_sts = BUFFER_OWNED_BY_DMA | RX_ENABLE_INTERRUPT;
+		return true;
+	}
+
+	if (ct && 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 (routing only) */
+	if (l3_is_ipv4 && e) {
+		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 if (!l3_is_ipv4 && e6) {
+		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--;
 }
 
-static int rxq_refill(struct rx_queue *rxq, int budget)
+	/* 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 mv643xx_eth_private *mp = rxq_to_mp(rxq);
-	int refilled;
+		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 (e || e6) {
+		if (l4_is_tcp)
+			clean_len += sizeof (struct tcphdr);
+		else
+			clean_len += sizeof (struct udphdr);
+	}
 
-	refilled = 0;
-	while (refilled < budget && rxq->rx_desc_count < rxq->rx_ring_size) {
+	/* add ethernet header */
+	l2_hdr = l3_hdr;
+	if (tx_vlan) {
+		struct vlan_ethhdr *vhdr;
+
+		l2_hdr -= VLAN_ETH_HLEN;
+		vhdr = (struct vlan_ethhdr *)l2_hdr;
+		memcpy(vhdr->h_dest, dest_hw, 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 {
+		l2_hdr -= ETH_HLEN;
+		eth = (struct ethhdr *)l2_hdr;
+		memcpy(eth->h_dest, dest_hw, 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 (txq) {
+		if (ff_send(tx_mp,
+			    txq,
+			    buf_addr + (void *)eth - frag,
+			    frag, rx_mp->pkt_size,
+			    eth_len,
+			    clean_len,
+			    (proto == ETH_P_IP),
+			    tx_vlan)) {
+			skb_free_frag(frag);
+			return true;
+		}
+	} else {
 		struct sk_buff *skb;
-		int rx;
-		struct rx_desc *rx_desc;
-		int size;
 
-		skb = netdev_alloc_skb(mp->dev, mp->skb_size);
+		skb = build_skb(frag, rx_mp->frag_size);
+		if (!skb) {
+			skb_free_frag(frag);
+			return true;
+		}
+
+		skb_reserve(skb, (void *)eth - frag);
+		skb_put(skb, eth_len);
+		skb->protocol = eth->h_proto;
+		skb_set_network_header(skb, l3_hdr - l2_hdr);
+		skb->dev = soft_tx_dev;
+		dev_queue_xmit(skb);
+	}
+
+	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;
+	}
 
-		if (skb == NULL) {
-			mp->oom = 1;
-			goto oom;
+	if (txq) {
+		tx_hw_stats = &tx_mp->dev->stats;
+		tx_hw_stats->tx_bytes += eth_len;
+		tx_hw_stats->tx_packets++;
 		}
 
-		if (SKB_DMA_REALIGN)
-			skb_reserve(skb, SKB_DMA_REALIGN);
+	/* refresh conntrack */
+	if (ct) {
+		if (l4_is_tcp)
+			timeout = HZ * 3600 * 24 * 5;
+		else
+			timeout = HZ * 180;
 
-		refilled++;
-		rxq->rx_desc_count++;
+		if (ct->timeout - ff.jiffies < timeout - 10 * HZ) {
+			unsigned long newtime = ff.jiffies + timeout;
+			ct->timeout = newtime;
+		}
+	}
 
-		rx = rxq->rx_used_desc++;
-		if (rxq->rx_used_desc == rxq->rx_ring_size)
-			rxq->rx_used_desc = 0;
+	return true;
+}
 
-		rx_desc = rxq->rx_desc_area + rx;
+/*
+ *
+ */
+static bool ff_receive(struct mv643xx_eth_private *mp,
+		       struct rx_desc *rx_desc,
+		       unsigned int *pmap_size,
+		       unsigned int cmd_sts,
+		       void *frag,
+		       size_t offset, size_t dlen)
+{
+	if (!ff_enabled)
+		return false;
 
-		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();
-		rx_desc->cmd_sts = BUFFER_OWNED_BY_DMA | RX_ENABLE_INTERRUPT;
-		wmb();
+	/*
+	 * 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],
+					  false,
+					  ff.lan_dev,
+					  ff.wan_dev,
+					  0, 836,
+					  rx_desc,
+					  pmap_size,
+					  cmd_sts,
+					  frag, offset, dlen);
+
+		if (mp->shared->unit == 1)
+			return ff_forward(mp, mp_by_unit[0],
+					  true,
+					  ff.wan_dev,
+					  ff.lan_dev,
+					  836, 0,
+					  rx_desc,
+					  pmap_size,
+					  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,
+					  false,
+					  ff.lan_dev,
+					  ff.wan_dev,
+					  0, 836,
+					  rx_desc,
+					  pmap_size,
+					  cmd_sts,
+					  frag, offset, dlen);
+		else
+			return ff_forward(mp, mp,
+					  true,
+					  ff.wan_dev,
+					  ff.lan_dev,
+					  836, 0,
+					  rx_desc,
+					  pmap_size,
+					  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,
+};
 
 		/*
-		 * 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);
+static ssize_t ff_show_tun_dev(struct device *dev,
+			       struct device_attribute *attr,
+			       char *buf)
+{
+	return sprintf(buf, "%s\n", ff.tun_dev_name);
 	}
 
-	if (refilled < budget)
-		mp->work_rx_refill &= ~(1 << rxq->index);
+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;
+	}
 
-oom:
-	return refilled;
+	ff_tun_release();
+	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;
+
+	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, rx_desc_idx;
+		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++;
+		rx_desc_idx = rxq->rx_curr_desc;
+		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,
+			       &rxq->rx_desc_map_sizes[rx_desc_idx],
+			       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,
+				     &rxq->rx_desc_map_sizes[rx_desc_idx],
+				     true);
+		if (ret) {
+			netdev_err(mp->dev, "oom while refill\n");
+			goto err_rearm;
+		}
+
+		/* 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;
+		}
+
+		/* 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_rearm:
+		stats->rx_dropped++;
+
+		if ((cmd_sts & (RX_FIRST_DESC | RX_LAST_DESC)) !=
+			(RX_FIRST_DESC | RX_LAST_DESC)) {
+			if (net_ratelimit())
+				netdev_err(mp->dev,
+					   "received packet spanning multiple descriptors\n");
+		}
+
+		if (cmd_sts & ERROR_SUMMARY) {
+			stats->rx_errors++;
+			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;
+				}
+			}
+		}
+
+		/* rearm descriptor */
+		rx_desc->cmd_sts = BUFFER_OWNED_BY_DMA | RX_ENABLE_INTERRUPT;
+	}
+
+	if (rx_done < budget)
+		mp->work_rx &= ~(1 << rxq->index);
+
+	return rx_done;
 }
 
 
@@ -671,8 +2704,36 @@
 	return (__force __be16)sum;
 }
 
+static u32 fill_desc_for_checksum(unsigned int vlan_hdr_len,
+				  unsigned int ihl,
+				  unsigned int ip_proto)
+{
+	u32 cmd = 0;
+
+	if (vlan_hdr_len & 4)
+		cmd |= MAC_HDR_EXTRA_4_BYTES;
+	if (vlan_hdr_len & 8)
+		cmd |= MAC_HDR_EXTRA_8_BYTES;
+
+	cmd |= GEN_TCP_UDP_CHECKSUM |
+		GEN_TCP_UDP_CHK_FULL |
+		GEN_IP_V4_CHECKSUM |
+		ihl << TX_IHL_SHIFT;
+
+	switch (ip_proto) {
+	case IPPROTO_UDP:
+		cmd |= UDP_FRAME;
+		break;
+	case IPPROTO_TCP:
+		break;
+	default:
+		WARN(1, "protocol not supported");
+	}
+	return cmd;
+}
+
 static int skb_tx_csum(struct mv643xx_eth_private *mp, struct sk_buff *skb,
-		       u16 *l4i_chk, u32 *command, int length)
+		       u32 *command, int length)
 {
 	int ret;
 	u32 cmd = 0;
@@ -695,28 +2756,9 @@
 			return ret;
 		}
 
-		if (tag_bytes & 4)
-			cmd |= MAC_HDR_EXTRA_4_BYTES;
-		if (tag_bytes & 8)
-			cmd |= MAC_HDR_EXTRA_8_BYTES;
-
-		cmd |= GEN_TCP_UDP_CHECKSUM | GEN_TCP_UDP_CHK_FULL |
-			   GEN_IP_V4_CHECKSUM   |
-			   ip_hdr(skb)->ihl << TX_IHL_SHIFT;
-
-		/* TODO: Revisit this. With the usage of GEN_TCP_UDP_CHK_FULL
-		 * it seems we don't need to pass the initial checksum. */
-		switch (ip_hdr(skb)->protocol) {
-		case IPPROTO_UDP:
-			cmd |= UDP_FRAME;
-			*l4i_chk = 0;
-			break;
-		case IPPROTO_TCP:
-			*l4i_chk = 0;
-			break;
-		default:
-			WARN(1, "protocol not supported");
-		}
+		cmd |= fill_desc_for_checksum(tag_bytes,
+					      ip_hdr(skb)->ihl,
+					      ip_hdr(skb)->protocol);
 	} else {
 no_csum:
 		/* Errata BTS #50, IHL must be 5 if no HW checksum */
@@ -775,32 +2817,27 @@
 }
 
 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,
 		u32 *first_cmd_sts, bool first_desc)
 {
-	struct mv643xx_eth_private *mp = txq_to_mp(txq);
 	int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
 	int tx_index;
 	struct tx_desc *desc;
-	int ret;
-	u32 cmd_csum = 0;
-	u16 l4i_chk = 0;
+	u32 cmd_csum;
 	u32 cmd_sts;
 
 	tx_index = txq->tx_curr_desc;
 	desc = &txq->tx_desc_area[tx_index];
 
-	ret = skb_tx_csum(mp, skb, &l4i_chk, &cmd_csum, length);
-	if (ret)
-		WARN(1, "failed to prepare checksum!");
-
-	/* Should we set this? Can't use the value from skb_tx_csum()
-	 * as it's not the correct initial L4 checksum to use. */
 	desc->l4i_chk = 0;
-
 	desc->byte_cnt = hdr_len;
 	desc->buf_ptr = txq->tso_hdrs_dma +
 			txq->tx_curr_desc * TSO_HEADER_SIZE;
+
+	cmd_csum = fill_desc_for_checksum(skb_network_offset(skb) - ETH_HLEN,
+					  ip_hdr(skb)->ihl,
+					  IPPROTO_TCP);
+
 	cmd_sts = cmd_csum | BUFFER_OWNED_BY_DMA  | TX_FIRST_DESC |
 				   GEN_CRC;
 
@@ -851,8 +2888,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, &first_cmd_sts,
-				first_desc);
+		txq_put_hdr_tso(skb, txq, &first_cmd_sts, first_desc);
 
 		while (data_left > 0) {
 			int size;
@@ -891,7 +2927,7 @@
 	return ret;
 }
 
-static void txq_submit_frag_skb(struct tx_queue *txq, struct sk_buff *skb)
+static int txq_submit_frag_skb(struct tx_queue *txq, struct sk_buff *skb)
 {
 	struct mv643xx_eth_private *mp = txq_to_mp(txq);
 	int nr_frags = skb_shinfo(skb)->nr_frags;
@@ -926,22 +2962,26 @@
 		desc->buf_ptr = skb_frag_dma_map(mp->dev->dev.parent,
 						 this_frag, 0, desc->byte_cnt,
 						 DMA_TO_DEVICE);
+		if (unlikely(dma_mapping_error(mp->dev->dev.parent,
+					       desc->buf_ptr))) {
+			WARN(1, "skb_frag_dma_map failed!\n");
+			return -ENOMEM;
+		}
 	}
+	return 0;
 }
 
 static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb,
 			  struct net_device *dev)
 {
 	struct mv643xx_eth_private *mp = txq_to_mp(txq);
-	int nr_frags = skb_shinfo(skb)->nr_frags;
+	int nr_frags;
 	int tx_index;
 	struct tx_desc *desc;
 	u32 cmd_sts;
-	u16 l4i_chk;
 	int length, ret;
 
 	cmd_sts = 0;
-	l4i_chk = 0;
 
 	if (txq->tx_ring_size - txq->tx_desc_count < MAX_SKB_FRAGS + 1) {
 		if (net_ratelimit())
@@ -949,7 +2989,7 @@
 		return -EBUSY;
 	}
 
-	ret = skb_tx_csum(mp, skb, &l4i_chk, &cmd_sts, skb->len);
+	ret = skb_tx_csum(mp, skb, &cmd_sts, skb->len);
 	if (ret)
 		return ret;
 	cmd_sts |= TX_FIRST_DESC | GEN_CRC | BUFFER_OWNED_BY_DMA;
@@ -960,18 +3000,31 @@
 	desc = &txq->tx_desc_area[tx_index];
 	txq->tx_desc_mapping[tx_index] = DESC_DMA_MAP_SINGLE;
 
+	nr_frags = skb_shinfo(skb)->nr_frags;
 	if (nr_frags) {
-		txq_submit_frag_skb(txq, skb);
+		ret = txq_submit_frag_skb(txq, skb);
+		if (ret) {
+			/* restore txq pointer */
+			txq->tx_curr_desc = tx_index;
+			return ret;
+		}
 		length = skb_headlen(skb);
 	} else {
 		cmd_sts |= ZERO_PADDING | TX_LAST_DESC | TX_ENABLE_INTERRUPT;
 		length = skb->len;
 	}
 
-	desc->l4i_chk = l4i_chk;
+	desc->l4i_chk = 0;
 	desc->byte_cnt = length;
 	desc->buf_ptr = dma_map_single(mp->dev->dev.parent, skb->data,
 				       length, DMA_TO_DEVICE);
+	if (unlikely(dma_mapping_error(mp->dev->dev.parent,
+				       desc->buf_ptr))) {
+		/* restore txq pointer */
+		txq->tx_curr_desc = tx_index;
+		WARN(1, "dma_map_single failed!\n");
+		return -ENOMEM;
+	}
 
 	__skb_queue_tail(&txq->tx_skb, skb);
 
@@ -993,6 +3046,34 @@
 	return 0;
 }
 
+static int mv643xx_eth_gso_too_big(struct tx_queue *txq,
+				   struct sk_buff *skb,
+				   struct net_device *dev)
+{
+	struct sk_buff *segs, *nskb;
+	int ret;
+
+	segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO);
+	if (IS_ERR(segs) || !segs)
+		return -ENOMEM;
+
+	ret = 0;
+	do {
+		nskb = segs;
+		segs = segs->next;
+		nskb->next = NULL;
+
+		if (!ret)
+			ret = txq_submit_skb(txq, nskb, dev);
+
+		if (ret)
+			dev_consume_skb_any(nskb);
+	} while (segs);
+
+	dev_consume_skb_any(skb);
+	return 0;
+}
+
 static netdev_tx_t mv643xx_eth_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct mv643xx_eth_private *mp = netdev_priv(dev);
@@ -1001,10 +3082,11 @@
 	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)) {
+		if (net_ratelimit())
 		netdev_printk(KERN_DEBUG, dev,
 			      "failed to linearize skb with tiny unaligned fragment\n");
 		return NETDEV_TX_BUSY;
@@ -1012,9 +3094,12 @@
 
 	length = skb->len;
 
-	if (skb_is_gso(skb))
-		ret = txq_submit_tso(txq, skb, dev);
+	if (skb_is_gso(skb)) {
+		if (skb_shinfo(skb)->gso_size > mp->shared->tx_csum_limit)
+			ret = mv643xx_eth_gso_too_big(txq, skb, dev);
 	else
+			ret = txq_submit_tso(txq, skb, dev);
+	} else
 		ret = txq_submit_skb(txq, skb, dev);
 	if (!ret) {
 		txq->tx_bytes += length;
@@ -1035,10 +3120,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))
@@ -1057,13 +3146,22 @@
 	mp->work_tx_end &= ~(1 << txq->index);
 }
 
-static int txq_reclaim(struct tx_queue *txq, int budget, int force)
+static int txq_reclaim(struct tx_queue *txq, int budget,
+		       bool force, bool lock)
 {
 	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 && lock) {
 	__netif_tx_lock_bh(nq);
+	}
 
 	reclaimed = 0;
 	while (reclaimed < budget && txq->tx_desc_count > 0) {
@@ -1119,6 +3217,7 @@
 
 	}
 
+	if (nq && lock)
 	__netif_tx_unlock_bh(nq);
 
 	if (reclaimed < budget)
@@ -1133,11 +3232,13 @@
  * Set total maximum TX rate (shared by all TX queues for this port)
  * to 'rate' bits per second, with a maximum burst of 'burst' bytes.
  */
-static void tx_set_rate(struct mv643xx_eth_private *mp, int rate, int burst)
+static void tx_set_rate(struct mv643xx_eth_private *mp)
 {
 	int token_rate;
 	int mtu;
 	int bucket_size;
+	u32 rate = mp->ftth_tx_shaper_rate;
+	u32 burst = mp->ftth_tx_shaper_burst;
 
 	token_rate = ((rate / 1000) * 64) / (mp->t_clk / 1000);
 	if (token_rate > 1023)
@@ -1151,6 +3252,9 @@
 	if (bucket_size > 65535)
 		bucket_size = 65535;
 
+	if (bucket_size < mtu)
+		bucket_size = mtu;
+
 	switch (mp->shared->tx_bw_control) {
 	case TX_BW_CONTROL_OLD_LAYOUT:
 		wrlp(mp, TX_BW_RATE, token_rate);
@@ -1296,6 +3400,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);
@@ -1331,6 +3436,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);
 }
 
@@ -1480,6 +3591,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
@@ -1676,14 +3803,257 @@
 	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)
 {
 	struct mv643xx_eth_private *mp = netdev_priv(dev);
 	bool rx_csum = features & NETIF_F_RXCSUM;
+	u32 port_config;
 
-	wrlp(mp, PORT_CONFIG, rx_csum ? 0x02000000 : 0x00000000);
+	port_config = rdlp(mp, PORT_CONFIG);
+	if (rx_csum)
+		port_config |= 0x02000000;
+	else
+		port_config &= ~0x02000000;
+	wrlp(mp, PORT_CONFIG, port_config);
 
 	return 0;
 }
@@ -1752,6 +4122,10 @@
 	.set_wol                = mv643xx_eth_set_wol,
 	.get_link_ksettings	= mv643xx_eth_get_link_ksettings,
 	.set_link_ksettings	= mv643xx_eth_set_link_ksettings,
+	.get_channels		= mv643xx_eth_get_channels,
+	.set_channels		= mv643xx_eth_set_channels,
+	.get_rxnfc		= mv643xx_eth_get_rxnfc,
+	.set_rxnfc		= mv643xx_eth_set_rxnfc,
 };
 
 
@@ -1927,7 +4301,6 @@
 	return 0;
 }
 
-
 /* rx/tx queue initialisation ***********************************************/
 static int rxq_init(struct mv643xx_eth_private *mp, int index)
 {
@@ -1939,10 +4312,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);
 
@@ -1964,14 +4334,22 @@
 	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)
+
+	rxq->rx_desc_map_sizes = kcalloc(rxq->rx_ring_size,
+					 sizeof (*rxq->rx_desc_map_sizes),
+					 GFP_ATOMIC);
+	if (!rxq->rx_desc_map_sizes)
 		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],
+				     &rxq->rx_desc_map_sizes[i],
+				     false);
+		if (ret)
+			goto out_free;
 
 		nexti = i + 1;
 		if (nexti == rxq->rx_ring_size)
@@ -1985,6 +4363,16 @@
 
 
 out_free:
+	for (i = 0; i < rxq->rx_ring_size; i++) {
+		if (!rx_desc[i].cookie)
+			break;
+		dma_unmap_single(mp->dev->dev.parent,
+				 rx_desc[i].buf_ptr,
+				 rxq->rx_desc_map_sizes[i],
+				 DMA_FROM_DEVICE);
+		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
@@ -1992,6 +4380,7 @@
 				  rxq->rx_desc_area,
 				  rxq->rx_desc_dma);
 
+	kfree(rxq->rx_desc_map_sizes);
 out:
 	return -ENOMEM;
 }
@@ -2004,15 +4393,11 @@
 	rxq_disable(rxq);
 
 	for (i = 0; i < rxq->rx_ring_size; i++) {
-		if (rxq->rx_skb[i]) {
-			dev_consume_skb_any(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);
+		dma_unmap_single(mp->dev->dev.parent,
+				 rxq->rx_desc_area[i].buf_ptr,
+				 rxq->rx_desc_map_sizes[i],
+				 DMA_FROM_DEVICE);
+		mv643xx_eth_frag_free(mp, (void *)rxq->rx_desc_area[i].cookie);
 	}
 
 	if (rxq->index == 0 &&
@@ -2022,7 +4407,7 @@
 		dma_free_coherent(mp->dev->dev.parent, rxq->rx_desc_area_size,
 				  rxq->rx_desc_area, rxq->rx_desc_dma);
 
-	kfree(rxq->rx_skb);
+	kfree(rxq->rx_desc_map_sizes);
 }
 
 static int txq_init(struct mv643xx_eth_private *mp, int index)
@@ -2118,7 +4503,7 @@
 	struct mv643xx_eth_private *mp = txq_to_mp(txq);
 
 	txq_disable(txq);
-	txq_reclaim(txq, txq->tx_ring_size, 1);
+	txq_reclaim(txq, txq->tx_ring_size, true, false);
 
 	BUG_ON(txq->tx_used_desc != txq->tx_curr_desc);
 
@@ -2157,6 +4542,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;
 	}
 
@@ -2166,6 +4554,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;
@@ -2205,7 +4596,8 @@
 			for (i = 0; i < mp->txq_count; i++) {
 				struct tx_queue *txq = mp->txq + i;
 
-				txq_reclaim(txq, txq->tx_ring_size, 1);
+				txq_reclaim(txq, txq->tx_ring_size,
+					    true, true);
 				txq_reset_hw_ptr(txq);
 			}
 		}
@@ -2241,12 +4633,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) {
@@ -2262,8 +4653,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))
@@ -2281,20 +4670,17 @@
 		if (mp->work_tx_end & queue_mask) {
 			txq_kick(mp->txq + queue);
 		} else if (mp->work_tx & queue_mask) {
-			work_done += txq_reclaim(mp->txq + queue, work_tbd, 0);
+			work_done += txq_reclaim(mp->txq + queue, work_tbd,
+						 false, true);
 			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_done(napi, work_done);
 		wrlp(mp, INT_MASK, mp->int_mask);
 	}
@@ -2302,13 +4688,6 @@
 	return work_done;
 }
 
-static inline void oom_timer_wrapper(struct timer_list *t)
-{
-	struct mv643xx_eth_private *mp = from_timer(mp, t, rx_oom);
-
-	napi_schedule(&mp->napi);
-}
-
 static void port_start(struct mv643xx_eth_private *mp)
 {
 	struct net_device *dev = mp->dev;
@@ -2344,7 +4723,7 @@
 	/*
 	 * Configure TX path and queues.
 	 */
-	tx_set_rate(mp, 1000000000, 16777216);
+	tx_set_rate(mp);
 	for (i = 0; i < mp->txq_count; i++) {
 		struct tx_queue *txq = mp->txq + i;
 
@@ -2358,6 +4737,7 @@
 	 * frames to RX queue #0, and include the pseudo-header when
 	 * calculating receive checksums.
 	 */
+	wrlp(mp, PORT_CONFIG, 0x00000000);
 	mv643xx_eth_set_features(mp->dev, mp->dev->features);
 
 	/*
@@ -2385,32 +4765,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);
 
 	/*
-	 * 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.
+	 * add NET_SKB_PAD per build_skb() requirement, make sure we
+	 * have room to align data to cache size after reserving
 	 */
-	mp->skb_size += SKB_DMA_REALIGN;
+	mp->frag_size = mp->pkt_size + RX_OFFSET;
+
+	/*
+	 * per build_skb() requirement
+	 */
+	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)
@@ -2430,7 +4812,7 @@
 		return -EAGAIN;
 	}
 
-	mv643xx_eth_recalc_skb_size(mp);
+	mv643xx_eth_recalc_frag_size(mp);
 
 	napi_enable(&mp->napi);
 
@@ -2444,15 +4826,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) {
@@ -2460,15 +4836,28 @@
 				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);
 
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	WARN_ON(mp_by_unit[mp->shared->unit] != NULL);
+	mp_by_unit[mp->shared->unit] = mp;
+#endif
 	return 0;
 
 
@@ -2512,14 +4901,16 @@
 	struct mv643xx_eth_private *mp = netdev_priv(dev);
 	int i;
 
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	mp_by_unit[mp->shared->unit] = NULL;
+#endif
+
 	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 (dev->phydev)
 		phy_stop(dev->phydev);
@@ -2530,6 +4921,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++)
@@ -2538,13 +4933,39 @@
 	return 0;
 }
 
+static int mii_bus_read(struct net_device *dev, int mii_id, int regnum)
+{
+	struct mv643xx_eth_private *mp = netdev_priv(dev);
+	return mp->shared->mii_bus->read(mp->shared->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);
+	mp->shared->mii_bus->write(mp->shared->mii_bus, mii_id, regnum, value);
+}
+
 static int mv643xx_eth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
 	int ret;
 
-	if (!dev->phydev)
+	if (!dev->phydev) {
+		struct mv643xx_eth_private *mp = netdev_priv(dev);
+		struct mii_if_info mii;
+
+		if (!mp->shared->mii_bus)
 		return -ENOTSUPP;
 
+		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);
+	}
+
 	ret = phy_mii_ioctl(dev->phydev, ifr, cmd);
 	if (!ret)
 		mv643xx_eth_adjust_link(dev);
@@ -2556,8 +4977,8 @@
 	struct mv643xx_eth_private *mp = netdev_priv(dev);
 
 	dev->mtu = new_mtu;
-	mv643xx_eth_recalc_skb_size(mp);
-	tx_set_rate(mp, 1000000000, 16777216);
+	mv643xx_eth_recalc_frag_size(mp);
+	tx_set_rate(mp);
 
 	if (!netif_running(dev))
 		return 0;
@@ -2797,6 +5218,9 @@
 	pdev->dev.platform_data = pd;
 
 	mv643xx_eth_property(np, "tx-checksum-limit", pd->tx_csum_limit);
+	mv643xx_eth_property(np, "unit", pd->unit);
+
+	pd->mdio_node = of_parse_phandle(np, "mdio-bus", 0);
 
 	for_each_available_child_of_node(np, pnp) {
 		ret = mv643xx_eth_shared_of_add_port(pdev, pnp);
@@ -2870,10 +5294,32 @@
 		goto err_put_clk;
 	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;
+
+#ifdef CONFIG_OF
+	if (pd->mdio_node) {
+		msp->mii_bus = of_mdio_find_bus(pd->mdio_node);
+		if (!msp->mii_bus)
+			return -EPROBE_DEFER;
+	}
+#endif
+
 	infer_hw_params(msp);
 
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	if (of_machine_is_compatible("freebox,fbxgw1r"))
+		ff_mode = 1;
+	else if (of_machine_is_compatible("freebox,fbxgw2r"))
+		ff_mode = 2;
+	else
+		WARN(1, "ff_mode not set");
+
+	if (ff_mode)
+		ff_init(&pdev->dev);
+#endif
+
 	return 0;
 
 err_put_clk:
@@ -2954,6 +5400,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 int get_phy_mode(struct mv643xx_eth_private *mp)
@@ -3095,7 +5542,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;
 
@@ -3109,6 +5558,30 @@
 
 	mp->dev = dev;
 
+	/*
+	 * tx shaper bandwidth & burst.
+	 *
+	 * bandwidth is in Mb/s, burst in is bytes.
+	 */
+	if (of_property_read_u32(pdev->dev.of_node, "fbx,tx-shaper-rate",
+				 &mp->ftth_tx_shaper_rate))
+		/*
+		 * default to 1Gb/s
+		 */
+		mp->ftth_tx_shaper_rate = 1000000000;
+	else
+		mp->ftth_tx_shaper_rate *= 1000000;
+
+	if (of_property_read_u32(pdev->dev.of_node, "fbx,tx-shaper-burst",
+				 &mp->ftth_tx_shaper_burst))
+		/*
+		 * default to 16M
+		 */
+		mp->ftth_tx_shaper_burst = 16777216;
+
+	dev_info(&pdev->dev, "shaper rate: %u, burst: %u\n",
+		 mp->ftth_tx_shaper_rate, mp->ftth_tx_shaper_burst);
+
 	/* Kirkwood resets some registers on gated clocks. Especially
 	 * CLK125_BYPASS_EN must be cleared but is not available on
 	 * all other SoCs/System Controllers using this driver.
@@ -3132,7 +5605,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;
@@ -3175,8 +5648,6 @@
 
 	netif_napi_add(dev, &mp->napi, mv643xx_eth_poll, NAPI_POLL_WEIGHT);
 
-	timer_setup(&mp->rx_oom, oom_timer_wrapper, 0);
-
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	BUG_ON(!res);
@@ -3220,6 +5691,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:
@@ -3235,6 +5711,10 @@
 	struct mv643xx_eth_private *mp = platform_get_drvdata(pdev);
 	struct net_device *dev = mp->dev;
 
+#ifdef CONFIG_MV643XX_ETH_FBX_FF
+	unregister_netdevice_notifier(&mp->ff_notifier);
+#endif
+
 	unregister_netdev(mp->dev);
 	if (dev->phydev)
 		phy_disconnect(dev->phydev);
diff -ruw linux-5.4.60/drivers/net/ethernet/marvell/sky2.c linux-5.4.60-fbx/drivers/net/ethernet/marvell/sky2.c
--- linux-5.4.60/drivers/net/ethernet/marvell/sky2.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/ethernet/marvell/sky2.c	2021-03-04 13:20:59.170838951 +0100
@@ -3024,6 +3024,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-5.4.60/drivers/net/phy/mdio_bus.c linux-5.4.60-fbx/drivers/net/phy/mdio_bus.c
--- linux-5.4.60/drivers/net/phy/mdio_bus.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/phy/mdio_bus.c	2021-03-04 13:20:59.290838956 +0100
@@ -404,8 +404,16 @@
 		bus->reset_gpiod = gpiod;
 
 		gpiod_set_value_cansleep(gpiod, 1);
+		if (bus->reset_delay_us < 1000)
 		udelay(bus->reset_delay_us);
+		else
+			mdelay(bus->reset_delay_us / 1000);
+
 		gpiod_set_value_cansleep(gpiod, 0);
+		if (bus->reset_delay_us < 1000)
+			udelay(bus->reset_delay_us);
+		else
+			mdelay(bus->reset_delay_us / 1000);
 	}
 
 	if (bus->reset)
diff -ruw linux-5.4.60/drivers/net/phy/phy.c linux-5.4.60-fbx/drivers/net/phy/phy.c
--- linux-5.4.60/drivers/net/phy/phy.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/phy/phy.c	2021-03-04 13:20:59.290838956 +0100
@@ -29,7 +29,7 @@
 #include <linux/uaccess.h>
 #include <linux/atomic.h>
 
-#define PHY_STATE_TIME	HZ
+#define PHY_STATE_TIME	(HZ / 2)
 
 #define PHY_STATE_STR(_state)			\
 	case PHY_##_state:			\
diff -ruw linux-5.4.60/drivers/net/phy/phy-core.c linux-5.4.60-fbx/drivers/net/phy/phy-core.c
--- linux-5.4.60/drivers/net/phy/phy-core.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/phy/phy-core.c	2021-03-04 13:20:59.290838956 +0100
@@ -8,7 +8,7 @@
 
 const char *phy_speed_to_str(int speed)
 {
-	BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS != 69,
+	BUILD_BUG_ON_MSG(__ETHTOOL_LINK_MODE_MASK_NBITS != 75,
 		"Enum ethtool_link_mode_bit_indices and phylib are out of sync. "
 		"If a speed or mode has been added please update phy_speed_to_str "
 		"and the PHY settings array.\n");
@@ -113,6 +113,10 @@
 	PHY_SETTING(  20000, FULL,  20000baseKR2_Full		),
 	PHY_SETTING(  20000, FULL,  20000baseMLD2_Full		),
 	/* 10G */
+	PHY_SETTING(  10000, FULL,  10000_1000basePRX_D_Full	),
+	PHY_SETTING(  10000, FULL,  10000_1000basePRX_U_Full	),
+	PHY_SETTING(  10000, FULL,  10000basePR_D_Full		),
+	PHY_SETTING(  10000, FULL,  10000basePR_U_Full		),
 	PHY_SETTING(  10000, FULL,  10000baseCR_Full		),
 	PHY_SETTING(  10000, FULL,  10000baseER_Full		),
 	PHY_SETTING(  10000, FULL,  10000baseKR_Full		),
@@ -128,6 +132,8 @@
 	PHY_SETTING(   2500, FULL,   2500baseT_Full		),
 	PHY_SETTING(   2500, FULL,   2500baseX_Full		),
 	/* 1G */
+	PHY_SETTING(   1000, FULL,   1000basePX_D_Full		),
+	PHY_SETTING(   1000, FULL,   1000basePX_U_Full		),
 	PHY_SETTING(   1000, FULL,   1000baseKX_Full		),
 	PHY_SETTING(   1000, FULL,   1000baseT_Full		),
 	PHY_SETTING(   1000, HALF,   1000baseT_Half		),
diff -ruw linux-5.4.60/drivers/net/phy/phy_device.c linux-5.4.60-fbx/drivers/net/phy/phy_device.c
--- linux-5.4.60/drivers/net/phy/phy_device.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/phy/phy_device.c	2021-03-04 13:20:59.290838956 +0100
@@ -1767,7 +1767,7 @@
 	 * drops can be detected. Do not double-read the status
 	 * in polling mode to detect such short link drops.
 	 */
-	if (!phy_polling_mode(phydev)) {
+	if (!phy_polling_mode(phydev) || !phydev->link) {
 		status = phy_read(phydev, MII_BMSR);
 		if (status < 0)
 			return status;
diff -ruw linux-5.4.60/drivers/net/phy/swphy.c linux-5.4.60-fbx/drivers/net/phy/swphy.c
--- linux-5.4.60/drivers/net/phy/swphy.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/phy/swphy.c	2021-03-04 13:20:59.294172289 +0100
@@ -29,6 +29,7 @@
 	SWMII_SPEED_10 = 0,
 	SWMII_SPEED_100,
 	SWMII_SPEED_1000,
+	SWMII_SPEED_2500,
 	SWMII_DUPLEX_HALF = 0,
 	SWMII_DUPLEX_FULL,
 };
@@ -51,6 +52,10 @@
 		.lpagb = LPA_1000FULL | LPA_1000HALF,
 		.estat = ESTATUS_1000_TFULL | ESTATUS_1000_THALF,
 	},
+	[SWMII_SPEED_2500] = {
+		.bmsr  = BMSR_ESTATEN,
+		.lpagb = LPA_1000FULL | LPA_1000HALF,
+	},
 };
 
 static const struct swmii_regs duplex[] = {
@@ -71,6 +76,8 @@
 static int swphy_decode_speed(int speed)
 {
 	switch (speed) {
+	case 2500:
+		return SWMII_SPEED_2500;
 	case 1000:
 		return SWMII_SPEED_1000;
 	case 100:
diff -ruw linux-5.4.60/drivers/net/ppp/ppp_generic.c linux-5.4.60-fbx/drivers/net/ppp/ppp_generic.c
--- linux-5.4.60/drivers/net/ppp/ppp_generic.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/ppp/ppp_generic.c	2021-03-04 13:20:59.294172289 +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 */
@@ -1409,10 +1410,28 @@
 			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);
+		}
 	} else {
 		kfree_skb(skb);
 	}
@@ -2725,10 +2744,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.
  */
 
@@ -3325,6 +3358,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-5.4.60/drivers/net/ppp/pptp.c linux-5.4.60-fbx/drivers/net/ppp/pptp.c
--- linux-5.4.60/drivers/net/ppp/pptp.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/ppp/pptp.c	2021-03-04 13:20:59.294172289 +0100
@@ -358,6 +358,7 @@
 	po = lookup_chan(htons(header->call_id), iph->saddr);
 	if (po) {
 		skb_dst_drop(skb);
+		skb->mark = 0;
 		nf_reset_ct(skb);
 		return sk_receive_skb(sk_pppox(po), skb, 0);
 	}
diff -ruw linux-5.4.60/drivers/net/tun.c linux-5.4.60-fbx/drivers/net/tun.c
--- linux-5.4.60/drivers/net/tun.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/tun.c	2021-03-04 13:20:59.297505623 +0100
@@ -68,6 +68,10 @@
 #include <linux/bpf.h>
 #include <linux/bpf_trace.h>
 #include <linux/mutex.h>
+#include <linux/ip.h>
+#include <linux/udp.h>
+#include <linux/tcp.h>
+#include <net/ip.h>
 
 #include <linux/uaccess.h>
 #include <linux/proc_fs.h>
@@ -194,6 +198,31 @@
 	unsigned long updated ____cacheline_aligned_in_smp;
 };
 
+/*
+ * smalltun definitions
+ */
+#define SMALLTUN_MAGIC			0x6660
+#define SMALLTUN_VERSION		0x1
+
+#define TYPE_MASK			0xf
+#define TYPE_CLT			(1 << 3)
+
+#define TYPE_TRIGGER			0x0
+#define TYPE_CHALLENGE			0x1
+#define TYPE_CLIENT_HELLO		0x2
+#define TYPE_SERVER_HELLO		0x3
+
+#define TYPE_CLT_DATA			(TYPE_CLT | 0x0)
+#define TYPE_CLT_GET_PARAMS		(TYPE_CLT | 0x1)
+#define TYPE_CLT_PARAMS			(TYPE_CLT | 0x2)
+
+struct smalltun_pkt_hdr {
+	u16		magic;
+	u8		version;
+	u8		flag_type;
+	u8		data[0];
+};
+
 #define TUN_NUM_FLOW_ENTRIES 1024
 #define TUN_MASK_FLOW_ENTRIES (TUN_NUM_FLOW_ENTRIES - 1)
 
@@ -213,6 +242,11 @@
 	kuid_t			owner;
 	kgid_t			group;
 
+	struct smalltun_fp	smalltun_fps[4];
+	unsigned int		smalltun_valid_count;
+	unsigned int		smalltun_valid[4];
+	struct rtable		*smalltun_rt_cache[4];
+
 	struct net_device	*dev;
 	netdev_features_t	set_features;
 #define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
@@ -1027,6 +1061,184 @@
 	return 0;
 }
 
+static int smalltun_is_fastpath(struct tun_struct *tun,
+				struct sk_buff *skb)
+{
+	struct iphdr *iph;
+	const struct smalltun_fp *fp;
+	struct rtable **prt_cache, *rt_cache;
+	struct flowi4 fl;
+	bool match;
+	size_t i;
+
+	if (!tun->smalltun_valid_count)
+		return 0;
+
+	if (skb->protocol != htons(ETH_P_IP))
+		return 0;
+
+	if (!pskb_may_pull(skb, sizeof(struct iphdr)))
+		return 0;
+
+	iph = ip_hdr(skb);
+
+	/* lookup smalltun fastpath */
+	fp = NULL;
+	rt_cache = NULL;
+	for (i = 0; i < ARRAY_SIZE(tun->smalltun_fps); i++) {
+		if (!tun->smalltun_valid[i])
+			continue;
+
+		if (iph->daddr == tun->smalltun_fps[i].inner_dst) {
+			fp = &tun->smalltun_fps[i];
+			prt_cache = &tun->smalltun_rt_cache[i];
+			break;
+		}
+	}
+
+	if (!fp)
+		return 0;
+
+	if (fp->af != AF_INET) {
+		/* FIXME: implement IPv6 transport */
+		return 0;
+	}
+
+	if (!pskb_may_pull(skb, iph->ihl * 4))
+		return 0;
+
+	match = false;
+	for (i = 0; i < fp->rule_count; i++) {
+		const struct smalltun_rule *r = &fp->rules[i];
+		unsigned int sport, dport;
+
+		if (iph->protocol != r->proto)
+			continue;
+
+		switch (iph->protocol) {
+		case IPPROTO_UDP:
+		{
+			const struct udphdr *udp;
+			udp = (struct udphdr *)((u8 *)iph + (iph->ihl << 2));
+			sport = ntohs(udp->source);
+	                dport = ntohs(udp->dest);
+			break;
+		}
+		case IPPROTO_TCP:
+		{
+			const struct tcphdr *tcp;
+			tcp = (struct tcphdr *)((u8 *)iph + (iph->ihl << 2));
+			sport = ntohs(tcp->source);
+			dport = ntohs(tcp->dest);
+			break;
+		}
+		default:
+			match = true;
+			break;
+		}
+
+		if (match)
+			break;
+
+		if (r->src_port_start && r->src_port_end) {
+			if (sport < ntohs(r->src_port_start) ||
+			    sport > ntohs(r->src_port_end))
+				continue;
+		}
+
+		if (r->dst_port_start && r->dst_port_end) {
+			if (dport < ntohs(r->dst_port_start) ||
+			    dport > ntohs(r->dst_port_end))
+				continue;
+		}
+		match = true;
+	}
+
+	if (!match)
+		return 0;
+
+	if (fp->af == AF_INET) {
+		struct iphdr *oiph;
+		struct udphdr *oudph;
+		struct smalltun_pkt_hdr *pkt;
+		unsigned int payload_len;
+
+		payload_len = skb->len;
+
+		if (skb_cow_head(skb,
+				 sizeof (struct iphdr) +
+				 sizeof (struct udphdr) +
+				 sizeof (struct smalltun_pkt_hdr)))
+			return 0;
+
+		pkt = skb_push(skb, sizeof (struct smalltun_pkt_hdr));
+		oudph = skb_push(skb, sizeof (struct udphdr));
+		skb_reset_transport_header(skb);
+		oiph = skb_push(skb, sizeof (struct iphdr));
+		skb_reset_network_header(skb);
+
+		/* ip */
+		oiph->version = 4;
+		oiph->tos = 0;
+		oiph->id = 0;
+		oiph->ihl = 5;
+		oiph->frag_off = 0;
+		oiph->ttl = 64;
+		oiph->protocol = IPPROTO_UDP;
+		memcpy(&oiph->saddr, fp->outer_src, 4);
+		memcpy(&oiph->daddr, fp->outer_dst, 4);
+
+		/* udp */
+		oudph->source = fp->outer_src_port;
+		oudph->dest = fp->outer_dst_port;
+		oudph->len = htons(payload_len + sizeof (*oudph) +
+				   sizeof (*pkt));
+		oudph->check = 0;
+
+		/* smalltun */
+		pkt->magic = htons(SMALLTUN_MAGIC);
+		pkt->version = SMALLTUN_VERSION;
+		pkt->flag_type = TYPE_CLT_DATA;
+
+		memset(&fl, 0x00, sizeof (fl));
+		memcpy(&fl.saddr, fp->outer_src, 4);
+		memcpy(&fl.daddr, fp->outer_dst, 4);
+
+		if (*prt_cache && (*prt_cache)->dst.obsolete > 0) {
+			rt_cache = *prt_cache;
+			*prt_cache = NULL;
+			ip_rt_put(rt_cache);
+		}
+
+		rt_cache = *prt_cache;
+		if (!rt_cache) {
+			rt_cache = ip_route_output_key(&init_net, &fl);
+			if (IS_ERR(rt_cache)) {
+				pr_err("ip_route_output_key(%pI4): %li\n",
+				       &fl.daddr, PTR_ERR(rt_cache));
+				return 0;
+			}
+
+			if (!rt_cache->dst.dev) {
+				pr_err("ip_route_output_key(%pI4): no dev\n",
+				       &fl.daddr);
+				return 0;
+			}
+
+			*prt_cache = rt_cache;
+		}
+
+		skb_dst_set(skb, dst_clone(&rt_cache->dst));
+		skb->dev = skb_dst(skb)->dev;
+		ip_local_out(&init_net, NULL, skb);
+		return 1;
+	}
+
+	/* find route */
+
+	return 0;
+}
+
 /* Net device start xmit */
 static void tun_automq_xmit(struct tun_struct *tun, struct sk_buff *skb)
 {
@@ -1104,6 +1316,11 @@
 	 */
 	skb_orphan(skb);
 
+	if (smalltun_is_fastpath(tun, skb)) {
+		rcu_read_unlock();
+		return NETDEV_TX_OK;
+	}
+
 	nf_reset_ct(skb);
 
 	if (ptr_ring_produce(&tfile->tx_ring, skb))
@@ -3347,6 +3564,100 @@
 		ret = open_related_ns(&net->ns, get_net_ns);
 		break;
 
+	case TUNSMALLTUNSETFP:
+	{
+		struct smalltun_fp fp;
+		unsigned int i;
+		int free_idx;
+
+		ret = -EFAULT;
+		if (copy_from_user(&fp, argp, sizeof(fp)))
+			break;
+
+		/* look for duplicate */
+		ret = 0;
+		free_idx = -1;
+		for (i = 0; i < ARRAY_SIZE(tun->smalltun_fps); i++) {
+			if (!tun->smalltun_valid[i]) {
+				if (free_idx == -1)
+					free_idx = i;
+				continue;
+			}
+
+			if (fp.inner_src == tun->smalltun_fps[i].inner_src &&
+			    fp.inner_dst == tun->smalltun_fps[i].inner_dst) {
+				ret = -EEXIST;
+				break;
+			}
+		}
+
+		if (ret)
+			break;
+
+		if (free_idx == -1) {
+			ret = -ENOSPC;
+			break;
+		}
+
+		memcpy(&tun->smalltun_fps[free_idx], &fp, sizeof (fp));
+		tun->smalltun_valid[free_idx] = 1;
+		tun->smalltun_valid_count++;
+		tun_debug(KERN_INFO, tun, "new fp rule for %pI4 <=> %pI4 (%u rules)\n",
+			  &fp.inner_src,
+			  &fp.inner_dst,
+			  fp.rule_count);
+
+		if (fp.af == AF_INET) {
+			tun_debug(KERN_INFO, tun, "outer %pI4:%u <=> %pI4:%u\n",
+				  fp.outer_src,
+				  ntohs(fp.outer_src_port),
+				  fp.outer_dst,
+				  ntohs(fp.outer_dst_port));
+		} else {
+			tun_debug(KERN_INFO, tun, "outer %pI6:%u <=> %pI6:%u\n",
+				  fp.outer_src,
+				  ntohs(fp.outer_src_port),
+				  fp.outer_dst,
+				  ntohs(fp.outer_dst_port));
+		}
+		break;
+	}
+
+	case TUNSMALLTUNDELFP:
+	{
+		struct smalltun_fp fp;
+		unsigned int i;
+
+		ret = -EFAULT;
+		if (copy_from_user(&fp, argp, sizeof(fp)))
+			break;
+
+		/* lookup */
+		ret = -ENOENT;
+		for (i = 0; i < ARRAY_SIZE(tun->smalltun_fps); i++) {
+			if (fp.inner_src == tun->smalltun_fps[i].inner_src &&
+			    fp.inner_dst == tun->smalltun_fps[i].inner_dst) {
+				ret = 0;
+				break;
+			}
+		}
+
+		if (ret)
+			break;
+
+		tun->smalltun_valid[i] = 0;
+		tun->smalltun_valid_count--;
+		if (tun->smalltun_rt_cache[i]) {
+			ip_rt_put(tun->smalltun_rt_cache[i]);
+			tun->smalltun_rt_cache[i] = NULL;
+		}
+
+		tun_debug(KERN_INFO, tun, "removed fp rule for %pI4 <=> %pI4\n",
+			  &fp.inner_src,
+			  &fp.inner_dst);
+		break;
+	}
+
 	default:
 		ret = -EINVAL;
 		break;
diff -ruw linux-5.4.60/drivers/net/wireless/ath/ath10k/core.c linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/core.c
--- linux-5.4.60/drivers/net/wireless/ath/ath10k/core.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/core.c	2021-03-04 13:20:59.314172291 +0100
@@ -88,6 +88,7 @@
 		.rri_on_ddr = false,
 		.hw_filter_reset_required = true,
 		.fw_diag_ce_download = false,
+		.uart_pin_workaround = true,
 		.tx_stats_over_pktlog = true,
 	},
 	{
@@ -1090,6 +1091,7 @@
 static int ath10k_fetch_cal_file(struct ath10k *ar)
 {
 	char filename[100];
+	unsigned int i;
 
 	/* pre-cal-<bus>-<id>.bin */
 	scnprintf(filename, sizeof(filename), "pre-cal-%s-%s.bin",
@@ -1103,6 +1105,11 @@
 	scnprintf(filename, sizeof(filename), "cal-%s-%s.bin",
 		  ath10k_bus_str(ar->hif.bus), dev_name(ar->dev));
 
+	for (i = 0; filename[i]; i++) {
+		if (filename[i] == ':')
+			filename[i] = '_';
+	}
+
 	ar->cal_file = ath10k_fetch_fw_file(ar, ATH10K_FW_DIR, filename);
 	if (IS_ERR(ar->cal_file))
 		/* calibration file is optional, don't print any warnings */
@@ -2221,6 +2228,7 @@
 
 	switch (ar->state) {
 	case ATH10K_STATE_ON:
+	case ATH10K_STATE_PRE_ON:
 		ar->state = ATH10K_STATE_RESTARTING;
 		ath10k_halt(ar);
 		ath10k_scan_finish(ar);
diff -ruw linux-5.4.60/drivers/net/wireless/ath/ath10k/core.h linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/core.h
--- linux-5.4.60/drivers/net/wireless/ath/ath10k/core.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/core.h	2021-03-04 13:20:59.314172291 +0100
@@ -646,10 +646,12 @@
 	void *cal_data;
 	u32 enable_extd_tx_stats;
 	u8 fw_dbglog_mode;
+	u32 burst_dur[4];
 };
 
 enum ath10k_state {
 	ATH10K_STATE_OFF = 0,
+	ATH10K_STATE_PRE_ON,
 	ATH10K_STATE_ON,
 
 	/* When doing firmware recovery the device is first powered down.
@@ -946,6 +948,7 @@
 	struct ieee80211_ops *ops;
 	struct device *dev;
 	u8 mac_addr[ETH_ALEN];
+	const char *fem_name;
 
 	enum ath10k_hw_rev hw_rev;
 	u16 dev_id;
@@ -1120,6 +1123,8 @@
 
 	struct work_struct register_work;
 	struct work_struct restart_work;
+	struct work_struct powerup_work;
+	bool powerup_pending;
 
 	/* cycle count is reported twice for each visited channel during scan.
 	 * access protected by data_lock
diff -ruw linux-5.4.60/drivers/net/wireless/ath/ath10k/debug.c linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/debug.c
--- linux-5.4.60/drivers/net/wireless/ath/ath10k/debug.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/debug.c	2021-03-04 13:20:59.314172291 +0100
@@ -2510,6 +2510,79 @@
 	.llseek = default_llseek,
 };
 
+static ssize_t ath10k_write_burst_dur(struct file *file, const char __user *user_buf,
+				      size_t count, loff_t *ppos)
+{
+
+        struct ath10k *ar = file->private_data;
+        u32 dur[4];
+        int ret;
+	int ac;
+	char buf[128];
+
+	simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
+
+	/* make sure that buf is null terminated */
+	buf[sizeof(buf) - 1] = 0;
+
+	ret = sscanf(buf, "%u %u %u %u", &dur[0], &dur[1], &dur[2], &dur[3]);
+
+	if (!ret)
+		return -EINVAL;
+
+	mutex_lock(&ar->conf_mutex);
+
+	if (ar->state != ATH10K_STATE_ON &&
+	    ar->state != ATH10K_STATE_RESTARTED) {
+		ret = -ENETDOWN;
+		goto exit;
+	}
+
+	for (ac = 0; ac < 4; ac++) {
+		if (dur[ac] < MIN_BURST_DUR || dur[ac] > MAX_BURST_DUR) {
+			ret = -EINVAL;
+			goto exit;
+		}
+
+		ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->aggr_burst,
+						(SM(ac, ATH10K_AGGR_BURST_AC) |
+						SM(dur[ac], ATH10K_AGGR_BURST_DUR)));
+		if (ret) {
+			ath10k_warn(ar, "failed to set aggr burst duration for ac %d: %d\n", ac, ret);
+			goto exit;
+		}
+		ar->debug.burst_dur[ac] = dur[ac];
+	}
+
+        ret = count;
+
+exit:
+        mutex_unlock(&ar->conf_mutex);
+        return ret;
+}
+
+static ssize_t ath10k_read_burst_dur(struct file *file, char __user *user_buf,
+				     size_t count, loff_t *ppos)
+{
+	struct ath10k *ar = file->private_data;
+	int len = 0;
+	char buf[128];
+
+	len = scnprintf(buf, sizeof(buf) - len, "%u %u %u %u\n",
+			ar->debug.burst_dur[0], ar->debug.burst_dur[1],
+			ar->debug.burst_dur[2], ar->debug.burst_dur[3]);
+
+	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static const struct file_operations fops_burst_dur = {
+        .read = ath10k_read_burst_dur,
+        .write = ath10k_write_burst_dur,
+        .open = simple_open,
+        .owner = THIS_MODULE,
+        .llseek = default_llseek,
+};
+
 int ath10k_debug_create(struct ath10k *ar)
 {
 	ar->debug.cal_data = vzalloc(ATH10K_DEBUG_CAL_DATA_LEN);
@@ -2596,6 +2669,9 @@
 	debugfs_create_file("ani_enable", 0600, ar->debug.debugfs_phy, ar,
 			    &fops_ani_enable);
 
+	debugfs_create_file("burst_dur", S_IRUSR | S_IWUSR,
+			    ar->debug.debugfs_phy, ar, &fops_burst_dur);
+
 	if (IS_ENABLED(CONFIG_ATH10K_DFS_CERTIFIED)) {
 		debugfs_create_file("dfs_simulate_radar", 0200, ar->debug.debugfs_phy,
 				    ar, &fops_simulate_radar);
diff -ruw linux-5.4.60/drivers/net/wireless/ath/ath10k/debug.h linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/debug.h
--- linux-5.4.60/drivers/net/wireless/ath/ath10k/debug.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/debug.h	2021-03-04 13:20:59.314172291 +0100
@@ -80,6 +80,15 @@
 __printf(2, 3) void ath10k_err(struct ath10k *ar, const char *fmt, ...);
 __printf(2, 3) void ath10k_warn(struct ath10k *ar, const char *fmt, ...);
 
+#define ATH10K_AGGR_BURST_AC_MASK  0xff000000
+#define ATH10K_AGGR_BURST_AC_LSB   24
+#define ATH10K_AGGR_BURST_DUR_MASK 0x00ffffff
+#define ATH10K_AGGR_BURST_DUR_LSB  0
+
+/* burst duration in usec */
+#define MIN_BURST_DUR 0
+#define MAX_BURST_DUR 8000
+
 void ath10k_debug_print_hwfw_info(struct ath10k *ar);
 void ath10k_debug_print_board_info(struct ath10k *ar);
 void ath10k_debug_print_boot_info(struct ath10k *ar);
diff -ruw linux-5.4.60/drivers/net/wireless/ath/ath10k/htt.h linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/htt.h
--- linux-5.4.60/drivers/net/wireless/ath/ath10k/htt.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/htt.h	2021-03-04 13:20:59.314172291 +0100
@@ -2225,7 +2225,7 @@
  * Should be: sizeof(struct htt_host_rx_desc) + max rx MSDU size,
  * rounded up to a cache line size.
  */
-#define HTT_RX_BUF_SIZE 1920
+#define HTT_RX_BUF_SIZE 2048
 #define HTT_RX_MSDU_SIZE (HTT_RX_BUF_SIZE - (int)sizeof(struct htt_rx_desc))
 
 /* Refill a bunch of RX buffers for each refill round so that FW/HW can handle
diff -ruw linux-5.4.60/drivers/net/wireless/ath/ath10k/mac.c linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/mac.c
--- linux-5.4.60/drivers/net/wireless/ath/ath10k/mac.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/mac.c	2021-03-04 13:20:59.317505624 +0100
@@ -2515,7 +2515,7 @@
 	const u16 *vht_mcs_mask;
 	u8 ampdu_factor;
 	u8 max_nss, vht_mcs;
-	int i;
+	int i, nss160;
 
 	if (WARN_ON(ath10k_mac_vif_chan(vif, &def)))
 		return;
@@ -2575,23 +2575,45 @@
 		__le16_to_cpu(vht_cap->vht_mcs.tx_highest);
 	arg->peer_vht_rates.tx_mcs_set = ath10k_peer_assoc_h_vht_limit(
 		__le16_to_cpu(vht_cap->vht_mcs.tx_mcs_map), vht_mcs_mask);
+	arg->peer_bw_rxnss_override = 0;
+	nss160 = 1; /* 1x1 default config for VHT160 */
+
+	/* only local 4x4 configuration do support 2x2 for VHT160,
+	 * everything else must use 1x1 
+	 */
+
+	if (ar->cfg_rx_chainmask == 15)
+		nss160 = arg->peer_num_spatial_streams < 2 ? 1 : 2;
+
+	/* if peer provides 1x1 nss160 information using max rate
+	 * vht information, we reduce local nss160 to 1x1.
+	 * consider that it has been observed that some client
+	 * devices provide zero here, no matter which transmission
+	 * rate is possible. in that case the local nss configuration 
+	 * will be used at maxmimum configuration possible. (see above)
+	 */
 
-	ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vht peer %pM max_mpdu %d flags 0x%x\n",
-		   sta->addr, arg->peer_max_mpdu, arg->peer_flags);
+	if (arg->peer_vht_rates.rx_max_rate == 780)
+		nss160 = 1;
 
-	if (arg->peer_vht_rates.rx_max_rate &&
-	    (sta->vht_cap.cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK)) {
-		switch (arg->peer_vht_rates.rx_max_rate) {
-		case 1560:
-			/* Must be 2x2 at 160Mhz is all it can do. */
-			arg->peer_bw_rxnss_override = 2;
-			break;
-		case 780:
-			/* Can only do 1x1 at 160Mhz (Long Guard Interval) */
-			arg->peer_bw_rxnss_override = 1;
+	/* in case if peer is connected with vht160 or vht80+80,
+         * we need to properly adjust rxnss parameters otherwise 
+	 * firmware will raise a assert 
+	 */
+	switch (arg->peer_phymode) {
+	case MODE_11AC_VHT80_80:
+		arg->peer_bw_rxnss_override = BW_NSS_FWCONF_80_80(nss160);
+	/* fall through */
+	case MODE_11AC_VHT160:
+		arg->peer_bw_rxnss_override |= BW_NSS_FWCONF_160(nss160);
+		break;
+	default:
 			break;
 		}
-	}
+
+	ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vht peer %pM max_mpdu %d flags 0x%x peer_bw_rxnss_override 0x%x\n",
+		   sta->addr, arg->peer_max_mpdu, arg->peer_flags, 
+		   arg->peer_bw_rxnss_override);
 }
 
 static void ath10k_peer_assoc_h_qos(struct ath10k *ar,
@@ -2743,9 +2765,9 @@
 	ath10k_peer_assoc_h_crypto(ar, vif, sta, arg);
 	ath10k_peer_assoc_h_rates(ar, vif, sta, arg);
 	ath10k_peer_assoc_h_ht(ar, vif, sta, arg);
+	ath10k_peer_assoc_h_phymode(ar, vif, sta, arg);
 	ath10k_peer_assoc_h_vht(ar, vif, sta, arg);
 	ath10k_peer_assoc_h_qos(ar, vif, sta, arg);
-	ath10k_peer_assoc_h_phymode(ar, vif, sta, arg);
 
 	return 0;
 }
@@ -4556,13 +4578,6 @@
 		vht_cap.cap |= val;
 	}
 
-	/* Currently the firmware seems to be buggy, don't enable 80+80
-	 * mode until that's resolved.
-	 */
-	if ((ar->vht_cap_info & IEEE80211_VHT_CAP_SHORT_GI_160) &&
-	    (ar->vht_cap_info & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK) == 0)
-		vht_cap.cap |= IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
-
 	mcs_map = 0;
 	for (i = 0; i < 8; i++) {
 		if ((i < ar->num_rf_chains) && (ar->cfg_tx_chainmask & BIT(i)))
@@ -4734,13 +4749,18 @@
 	const char *fem_name;
 	int ret;
 
+	if (ar->fem_name)
+		fem_name = ar->fem_name;
+	else {
 	node = ar->dev->of_node;
 	if (!node)
 		return -ENOENT;
 
-	ret = of_property_read_string_index(node, "ext-fem-name", 0, &fem_name);
+		ret = of_property_read_string_index(node, "ext-fem-name",
+						    0, &fem_name);
 	if (ret)
 		return -ENOENT;
+	}
 
 	/*
 	 * If external Front End module used in hardware, then default base band timing
@@ -4759,12 +4779,83 @@
 	return 0;
 }
 
+static int ath10k_get_powered(struct ieee80211_hw *hw, bool *up, bool *busy)
+{
+	struct ath10k *ar = hw->priv;
+	*up = (ar->state == ATH10K_STATE_ON ||
+	       ar->state == ATH10K_STATE_PRE_ON);
+	*busy = ar->powerup_pending;
+	return 0;
+}
+
+static int ath10k_set_powered(struct ieee80211_hw *hw)
+{
+	struct ath10k *ar = hw->priv;
+
+	switch (ar->state) {
+	case ATH10K_STATE_OFF:
+	case ATH10K_STATE_PRE_ON:
+		break;
+	default:
+		return 0;
+	}
+
+	if (ar->powerup_pending)
+		return 0;
+
+	queue_work(ar->workqueue, &ar->powerup_work);
+	ar->powerup_pending = true;
+	return 0;
+}
+
+static void ath10k_powerup_work(struct work_struct *work)
+{
+	struct ath10k *ar = container_of(work, struct ath10k, powerup_work);
+	int ret;
+
+	mutex_lock(&ar->conf_mutex);
+
+	if (ar->state != ATH10K_STATE_OFF) {
+		mutex_unlock(&ar->conf_mutex);
+		return;
+	}
+
+	ret = ath10k_hif_power_up(ar, ATH10K_FIRMWARE_MODE_NORMAL);
+	if (ret) {
+		ath10k_err(ar, "Could not init hif: %d\n", ret);
+		goto err_off;
+	}
+
+	ret = ath10k_core_start(ar, ATH10K_FIRMWARE_MODE_NORMAL,
+				&ar->normal_mode_fw);
+	if (ret) {
+		ath10k_err(ar, "Could not init core: %d\n", ret);
+		goto err_power_down;
+	}
+
+	ar->state = ATH10K_STATE_PRE_ON;
+	ar->powerup_pending = false;
+	mutex_unlock(&ar->conf_mutex);
+	return;
+
+err_power_down:
+	ath10k_hif_power_down(ar);
+
+err_off:
+	ar->state = ATH10K_STATE_OFF;
+
+	ar->powerup_pending = false;
+	mutex_unlock(&ar->conf_mutex);
+	return;
+}
+
 static int ath10k_start(struct ieee80211_hw *hw)
 {
 	struct ath10k *ar = hw->priv;
 	u32 param;
 	int ret = 0;
 	struct wmi_bb_timing_cfg_arg bb_timing = {0};
+	bool skip_core_start = false;
 
 	/*
 	 * This makes sense only when restarting hw. It is harmless to call
@@ -4779,6 +4870,10 @@
 	case ATH10K_STATE_OFF:
 		ar->state = ATH10K_STATE_ON;
 		break;
+	case ATH10K_STATE_PRE_ON:
+		skip_core_start = true;
+		ar->state = ATH10K_STATE_ON;
+		break;
 	case ATH10K_STATE_RESTARTING:
 		ar->state = ATH10K_STATE_RESTARTED;
 		break;
@@ -4793,6 +4888,7 @@
 		goto err;
 	}
 
+	if (!skip_core_start) {
 	ret = ath10k_hif_power_up(ar, ATH10K_FIRMWARE_MODE_NORMAL);
 	if (ret) {
 		ath10k_err(ar, "Could not init hif: %d\n", ret);
@@ -4805,6 +4901,7 @@
 		ath10k_err(ar, "Could not init core: %d\n", ret);
 		goto err_power_down;
 	}
+	}
 
 	param = ar->wmi.pdev_param->pmf_qos;
 	ret = ath10k_wmi_pdev_set_param(ar, param, 1);
@@ -4963,6 +5060,9 @@
 
 	ath10k_drain_tx(ar);
 
+	cancel_work_sync(&ar->powerup_work);
+	ar->powerup_pending = false;
+
 	mutex_lock(&ar->conf_mutex);
 	if (ar->state != ATH10K_STATE_OFF) {
 		ath10k_halt(ar);
@@ -7131,7 +7231,7 @@
 				  struct ieee80211_channel *channel)
 {
 	int ret;
-	enum wmi_bss_survey_req_type type = WMI_BSS_SURVEY_REQ_TYPE_READ_CLEAR;
+	enum wmi_bss_survey_req_type type = WMI_BSS_SURVEY_REQ_TYPE_READ;
 
 	lockdep_assert_held(&ar->conf_mutex);
 
@@ -8187,6 +8287,8 @@
 static const struct ieee80211_ops ath10k_ops = {
 	.tx				= ath10k_mac_op_tx,
 	.wake_tx_queue			= ath10k_mac_op_wake_tx_queue,
+	.get_powered			= ath10k_get_powered,
+	.set_powered			= ath10k_set_powered,
 	.start				= ath10k_start,
 	.stop				= ath10k_stop,
 	.config				= ath10k_config,
@@ -8397,6 +8499,7 @@
 		.radar_detect_widths =	BIT(NL80211_CHAN_WIDTH_20_NOHT) |
 					BIT(NL80211_CHAN_WIDTH_20) |
 					BIT(NL80211_CHAN_WIDTH_40) |
+					BIT(NL80211_CHAN_WIDTH_160) |
 					BIT(NL80211_CHAN_WIDTH_80),
 #endif
 	},
@@ -8521,6 +8624,7 @@
 		.radar_detect_widths =	BIT(NL80211_CHAN_WIDTH_20_NOHT) |
 					BIT(NL80211_CHAN_WIDTH_20) |
 					BIT(NL80211_CHAN_WIDTH_40) |
+					BIT(NL80211_CHAN_WIDTH_160) |
 					BIT(NL80211_CHAN_WIDTH_80),
 #endif
 	},
@@ -8539,6 +8643,7 @@
 		.radar_detect_widths =  BIT(NL80211_CHAN_WIDTH_20_NOHT) |
 					BIT(NL80211_CHAN_WIDTH_20) |
 					BIT(NL80211_CHAN_WIDTH_40) |
+					BIT(NL80211_CHAN_WIDTH_160) |
 					BIT(NL80211_CHAN_WIDTH_80),
 #endif
 	},
@@ -8578,6 +8683,8 @@
 #define WRD_METHOD "WRDD"
 #define WRDD_WIFI  (0x07)
 
+#define ATH10K_DFS_PULSE_VALID_DIFF_TS 100
+
 static u32 ath10k_mac_wrdd_get_mcc(struct ath10k *ar, union acpi_object *wrdd)
 {
 	union acpi_object *mcc_pkg;
@@ -8791,6 +8898,7 @@
 	ieee80211_hw_set(ar->hw, SUPPORT_FAST_XMIT);
 	ieee80211_hw_set(ar->hw, CONNECTION_MONITOR);
 	ieee80211_hw_set(ar->hw, SUPPORTS_PER_STA_GTK);
+	ieee80211_hw_set(ar->hw, APVLAN_NEED_MCAST_TO_UCAST);
 	ieee80211_hw_set(ar->hw, WANT_MONITOR_VIF);
 	ieee80211_hw_set(ar->hw, CHANCTX_STA_CSA);
 	ieee80211_hw_set(ar->hw, QUEUE_CONTROL);
@@ -8955,6 +9063,8 @@
 	if (IS_ENABLED(CONFIG_ATH10K_DFS_CERTIFIED)) {
 		/* Init ath dfs pattern detector */
 		ar->ath_common.debug_mask = ATH_DBG_DFS;
+		ar->ath_common.dfs_pulse_valid_diff_ts =
+					ATH10K_DFS_PULSE_VALID_DIFF_TS;
 		ar->dfs_detector = dfs_pattern_detector_init(&ar->ath_common,
 							     NL80211_DFS_UNSET);
 
@@ -8972,6 +9082,15 @@
 	if (!ar->hw_params.hw_ops->set_coverage_class)
 		ar->ops->set_coverage_class = NULL;
 
+	/* Current wake_tx_queue implementation imposes a significant
+	 * performance penalty in some setups. The tx scheduling code needs
+	 * more work anyway so disable the wake_tx_queue unless firmware
+	 * supports the pull-push mechanism.
+	 */
+	if (!test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL,
+		      ar->running_fw->fw_file.fw_features))
+		ar->ops->wake_tx_queue = NULL;
+
 	ret = ath_regd_init(&ar->ath_common.regulatory, ar->hw->wiphy,
 			    ath10k_reg_notifier);
 	if (ret) {
@@ -9002,6 +9121,9 @@
 
 	ar->hw->weight_multiplier = ATH10K_AIRTIME_WEIGHT_MULTIPLIER;
 
+	INIT_WORK(&ar->powerup_work, ath10k_powerup_work);
+	ar->powerup_pending = false;
+
 	ret = ieee80211_register_hw(ar->hw);
 	if (ret) {
 		ath10k_err(ar, "failed to register ieee80211: %d\n", ret);
@@ -9013,16 +9135,20 @@
 		ar->hw->wiphy->software_iftypes |= BIT(NL80211_IFTYPE_AP_VLAN);
 	}
 
+#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;
 
+#ifndef CONFIG_ATH_REG_IGNORE
 err_unregister:
+#endif
 	ieee80211_unregister_hw(ar->hw);
 
 err_dfs_detector_exit:
@@ -9040,6 +9166,7 @@
 void ath10k_mac_unregister(struct ath10k *ar)
 {
 	ieee80211_unregister_hw(ar->hw);
+	cancel_work_sync(&ar->powerup_work);
 
 	if (IS_ENABLED(CONFIG_ATH10K_DFS_CERTIFIED) && ar->dfs_detector)
 		ar->dfs_detector->exit(ar->dfs_detector);
diff -ruw linux-5.4.60/drivers/net/wireless/ath/ath10k/pci.c linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/pci.c
--- linux-5.4.60/drivers/net/wireless/ath/ath10k/pci.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/pci.c	2021-03-04 13:20:59.317505624 +0100
@@ -9,6 +9,7 @@
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/bitops.h>
+#include <linux/delay.h>
 
 #include "core.h"
 #include "debug.h"
@@ -30,6 +31,7 @@
 
 static unsigned int ath10k_pci_irq_mode = ATH10K_PCI_IRQ_AUTO;
 static unsigned int ath10k_pci_reset_mode = ATH10K_PCI_RESET_AUTO;
+static char *fem_name;
 
 module_param_named(irq_mode, ath10k_pci_irq_mode, uint, 0644);
 MODULE_PARM_DESC(irq_mode, "0: auto, 1: legacy, 2: msi (default: 0)");
@@ -37,6 +39,9 @@
 module_param_named(reset_mode, ath10k_pci_reset_mode, uint, 0644);
 MODULE_PARM_DESC(reset_mode, "0: auto, 1: warm only (default: 0)");
 
+module_param(fem_name, charp, 0660);
+MODULE_PARM_DESC(fem_name, "force FEM type");
+
 /* how long wait to wait for target to initialise, in ms */
 #define ATH10K_PCI_TARGET_WAIT 3000
 #define ATH10K_PCI_NUM_WARM_RESET_ATTEMPTS 3
@@ -714,7 +719,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;
@@ -2652,12 +2658,6 @@
 	return 0;
 }
 
-static int ath10k_pci_qca99x0_soft_chip_reset(struct ath10k *ar)
-{
-	ath10k_pci_irq_disable(ar);
-	return ath10k_pci_qca99x0_chip_reset(ar);
-}
-
 static int ath10k_pci_safe_chip_reset(struct ath10k *ar)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
@@ -3498,7 +3498,7 @@
 	.get_num_banks	= ath10k_pci_get_num_banks,
 };
 
-static int ath10k_pci_probe(struct pci_dev *pdev,
+static int __ath10k_pci_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *pci_dev)
 {
 	int ret = 0;
@@ -3539,21 +3539,21 @@
 	case QCA99X0_2_0_DEVICE_ID:
 		hw_rev = ATH10K_HW_QCA99X0;
 		pci_ps = false;
-		pci_soft_reset = ath10k_pci_qca99x0_soft_chip_reset;
+		pci_soft_reset = NULL;;
 		pci_hard_reset = ath10k_pci_qca99x0_chip_reset;
 		targ_cpu_to_ce_addr = ath10k_pci_qca99x0_targ_cpu_to_ce_addr;
 		break;
 	case QCA9984_1_0_DEVICE_ID:
 		hw_rev = ATH10K_HW_QCA9984;
 		pci_ps = false;
-		pci_soft_reset = ath10k_pci_qca99x0_soft_chip_reset;
+		pci_soft_reset = NULL;;
 		pci_hard_reset = ath10k_pci_qca99x0_chip_reset;
 		targ_cpu_to_ce_addr = ath10k_pci_qca99x0_targ_cpu_to_ce_addr;
 		break;
 	case QCA9888_2_0_DEVICE_ID:
 		hw_rev = ATH10K_HW_QCA9888;
 		pci_ps = false;
-		pci_soft_reset = ath10k_pci_qca99x0_soft_chip_reset;
+		pci_soft_reset = NULL;;
 		pci_hard_reset = ath10k_pci_qca99x0_chip_reset;
 		targ_cpu_to_ce_addr = ath10k_pci_qca99x0_targ_cpu_to_ce_addr;
 		break;
@@ -3592,6 +3592,7 @@
 	ar_pci->targ_cpu_to_ce_addr = targ_cpu_to_ce_addr;
 	ar->ce_priv = &ar_pci->ce;
 
+	ar->fem_name = fem_name;
 	ar->id.vendor = pdev->vendor;
 	ar->id.device = pdev->device;
 	ar->id.subsystem_vendor = pdev->subsystem_vendor;
@@ -3751,6 +3752,23 @@
 			 ath10k_pci_pm_suspend,
 			 ath10k_pci_pm_resume);
 
+static int ath10k_pci_probe(struct pci_dev *pdev,
+			    const struct pci_device_id *pci_dev)
+{
+	int cnt = 0;
+	int rv;
+	do {
+		rv = __ath10k_pci_probe(pdev, pci_dev);
+		if (rv == 0)
+			return rv;
+
+		pr_err("ath10k: failed to probe PCI : %d, retry-count: %d\n", rv, cnt);
+		mdelay(10); /* let the ath10k firmware gerbil take a small break */
+	} while (cnt++ < 3);
+
+	return rv;
+}
+
 static struct pci_driver ath10k_pci_driver = {
 	.name = "ath10k_pci",
 	.id_table = ath10k_pci_id_table,
diff -ruw linux-5.4.60/drivers/net/wireless/ath/ath10k/wmi.c linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/wmi.c
--- linux-5.4.60/drivers/net/wireless/ath/ath10k/wmi.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/wmi.c	2021-03-04 13:20:59.320838957 +0100
@@ -1681,10 +1681,11 @@
 	.bw160 = WMI_10_2_PEER_160MHZ,
 };
 
-void ath10k_wmi_put_wmi_channel(struct wmi_channel *ch,
+void ath10k_wmi_put_wmi_channel(struct ath10k *ar, struct wmi_channel *ch,
 				const struct wmi_channel_arg *arg)
 {
 	u32 flags = 0;
+	struct ieee80211_channel *chan = NULL;
 
 	memset(ch, 0, sizeof(*ch));
 
@@ -1700,13 +1701,35 @@
 		flags |= WMI_CHAN_FLAG_HT40_PLUS;
 	if (arg->chan_radar)
 		flags |= WMI_CHAN_FLAG_DFS;
-
+	ch->band_center_freq2 = 0;
 	ch->mhz = __cpu_to_le32(arg->freq);
 	ch->band_center_freq1 = __cpu_to_le32(arg->band_center_freq1);
-	if (arg->mode == MODE_11AC_VHT80_80)
+	if (arg->mode == MODE_11AC_VHT80_80) {
 		ch->band_center_freq2 = __cpu_to_le32(arg->band_center_freq2);
-	else
-		ch->band_center_freq2 = 0;
+		chan = ieee80211_get_channel(ar->hw->wiphy,
+						arg->band_center_freq2 - 10);
+	}
+	if (arg->mode == MODE_11AC_VHT160)  {
+		if (arg->freq > arg->band_center_freq1) {
+			ch->band_center_freq1 =
+				__cpu_to_le32(arg->band_center_freq1 + 40);
+			/* Minus 40 to get secondary segment's center frequency
+			 * And minus 10 to get a defined 5G channel frequency.
+			 */
+			chan = ieee80211_get_channel(ar->hw->wiphy,
+					arg->band_center_freq1 - 40 - 10);
+		} else {
+			ch->band_center_freq1 =
+				__cpu_to_le32(arg->band_center_freq1 - 40);
+			chan = ieee80211_get_channel(ar->hw->wiphy,
+					arg->band_center_freq1 + 40 - 10);
+		}
+		ch->band_center_freq2 = __cpu_to_le32(arg->band_center_freq1);
+	}
+
+	if (chan && chan->flags & IEEE80211_CHAN_RADAR)
+		flags |= WMI_CHAN_FLAG_DFS_CFREQ2;
+
 	ch->min_power = arg->min_power;
 	ch->max_power = arg->max_power;
 	ch->reg_power = arg->max_reg_power;
@@ -7089,7 +7112,7 @@
 		memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
 	}
 
-	ath10k_wmi_put_wmi_channel(&cmd->chan, &arg->channel);
+	ath10k_wmi_put_wmi_channel(ar, &cmd->chan, &arg->channel);
 
 	ath10k_dbg(ar, ATH10K_DBG_WMI,
 		   "wmi vdev %s id 0x%x flags: 0x%0X, freq %d, mode %d, ch_flags: 0x%0X, max_power: %d\n",
@@ -7461,7 +7484,7 @@
 		ch = &arg->channels[i];
 		ci = &cmd->chan_info[i];
 
-		ath10k_wmi_put_wmi_channel(ci, ch);
+		ath10k_wmi_put_wmi_channel(ar, ci, ch);
 	}
 
 	return skb;
@@ -7552,12 +7575,7 @@
 	struct wmi_10_4_peer_assoc_complete_cmd *cmd = buf;
 
 	ath10k_wmi_peer_assoc_fill_10_2(ar, buf, arg);
-	if (arg->peer_bw_rxnss_override)
-		cmd->peer_bw_rxnss_override =
-			__cpu_to_le32((arg->peer_bw_rxnss_override - 1) |
-				      BIT(PEER_BW_RXNSS_OVERRIDE_OFFSET));
-	else
-		cmd->peer_bw_rxnss_override = 0;
+	cmd->peer_bw_rxnss_override = __cpu_to_le32(arg->peer_bw_rxnss_override);
 }
 
 static int
@@ -8869,7 +8887,7 @@
 
 	for (i = 0; i < cap->peer_chan_len; i++) {
 		chan = (struct wmi_channel *)&peer_cap->peer_chan_list[i];
-		ath10k_wmi_put_wmi_channel(chan, &chan_arg[i]);
+		ath10k_wmi_put_wmi_channel(ar, chan, &chan_arg[i]);
 	}
 
 	ath10k_dbg(ar, ATH10K_DBG_WMI,
diff -ruw linux-5.4.60/drivers/net/wireless/ath/ath10k/wmi.h linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/wmi.h
--- linux-5.4.60/drivers/net/wireless/ath/ath10k/wmi.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/wmi.h	2021-03-04 13:20:59.320838957 +0100
@@ -2085,6 +2085,8 @@
 
 /* Indicate reason for channel switch */
 #define WMI_CHANNEL_CHANGE_CAUSE_CSA (1 << 13)
+/* DFS required on channel for 2nd segment of VHT160 and VHT80+80*/
+#define WMI_CHAN_FLAG_DFS_CFREQ2  (1 << 15)
 
 #define WMI_MAX_SPATIAL_STREAM        3 /* default max ss */
 
@@ -6478,7 +6480,19 @@
 	__le32 info0; /* WMI_PEER_ASSOC_INFO0_ */
 } __packed;
 
-#define PEER_BW_RXNSS_OVERRIDE_OFFSET  31
+#define BW_NSS_FWCONF_MAP_ENABLE	BIT(31)
+#define BW_NSS_FWCONF_MAP_160MHZ_LSB	(0)
+#define BW_NSS_FWCONF_MAP_160MHZ_MASK	(0x00000007)
+#define BW_NSS_FWCONF_MAP_80_80MHZ_LSB	(3)
+#define BW_NSS_FWCONF_MAP_80_80MHZ_MASK (0x00000038)
+#define BW_NSS_FWCONF_MAP_MASK		(0x0000003F)
+
+#define GET_BW_NSS_FWCONF_160(x)	(MS(x, BW_NSS_FWCONF_MAP_160MHZ) + 1)
+#define GET_BW_NSS_FWCONF_80_80(x)	(MS(x, BW_NSS_FWCONF_MAP_80_80MHZ) + 1)
+
+/* Values defined to set 160 MHz Bandwidth NSS Mapping into FW*/
+#define BW_NSS_FWCONF_160(x)		(BW_NSS_FWCONF_MAP_ENABLE | SM(x - 1, BW_NSS_FWCONF_MAP_160MHZ))
+#define BW_NSS_FWCONF_80_80(x)		(BW_NSS_FWCONF_MAP_ENABLE | SM(x - 1, BW_NSS_FWCONF_MAP_80_80MHZ))
 
 struct wmi_10_4_peer_assoc_complete_cmd {
 	struct wmi_10_2_peer_assoc_complete_cmd cmd;
@@ -7312,7 +7326,7 @@
 				      const struct wmi_start_scan_arg *arg);
 void ath10k_wmi_set_wmm_param(struct wmi_wmm_params *params,
 			      const struct wmi_wmm_params_arg *arg);
-void ath10k_wmi_put_wmi_channel(struct wmi_channel *ch,
+void ath10k_wmi_put_wmi_channel(struct ath10k *ar, struct wmi_channel *ch,
 				const struct wmi_channel_arg *arg);
 int ath10k_wmi_start_scan_verify(const struct wmi_start_scan_arg *arg);
 
diff -ruw linux-5.4.60/drivers/net/wireless/ath/ath10k/wmi-tlv.c linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/wmi-tlv.c
--- linux-5.4.60/drivers/net/wireless/ath/ath10k/wmi-tlv.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/ath10k/wmi-tlv.c	2021-03-04 13:20:59.320838957 +0100
@@ -2063,7 +2063,7 @@
 	tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
 	tlv->len = __cpu_to_le16(sizeof(*ch));
 	ch = (void *)tlv->value;
-	ath10k_wmi_put_wmi_channel(ch, &arg->channel);
+	ath10k_wmi_put_wmi_channel(ar, ch, &arg->channel);
 
 	ptr += sizeof(*tlv);
 	ptr += sizeof(*ch);
@@ -2703,7 +2703,7 @@
 		tlv->len = __cpu_to_le16(sizeof(*ci));
 		ci = (void *)tlv->value;
 
-		ath10k_wmi_put_wmi_channel(ci, ch);
+		ath10k_wmi_put_wmi_channel(ar, ci, ch);
 
 		chans += sizeof(*tlv);
 		chans += sizeof(*ci);
@@ -3404,7 +3404,7 @@
 		tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
 		tlv->len = __cpu_to_le16(sizeof(*chan));
 		chan = (void *)tlv->value;
-		ath10k_wmi_put_wmi_channel(chan, &chan_arg[i]);
+		ath10k_wmi_put_wmi_channel(ar, chan, &chan_arg[i]);
 
 		ptr += sizeof(*tlv);
 		ptr += sizeof(*chan);
diff -ruw linux-5.4.60/drivers/net/wireless/ath/ath.h linux-5.4.60-fbx/drivers/net/wireless/ath/ath.h
--- linux-5.4.60/drivers/net/wireless/ath/ath.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/ath.h	2021-03-04 13:20:59.314172291 +0100
@@ -184,6 +184,8 @@
 
 	int last_rssi;
 	struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
+
+	int dfs_pulse_valid_diff_ts;
 };
 
 static inline const struct ath_ps_ops *ath_ps_ops(struct ath_common *common)
diff -ruw linux-5.4.60/drivers/net/wireless/ath/dfs_pattern_detector.c linux-5.4.60-fbx/drivers/net/wireless/ath/dfs_pattern_detector.c
--- linux-5.4.60/drivers/net/wireless/ath/dfs_pattern_detector.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/dfs_pattern_detector.c	2021-03-04 13:20:59.344172292 +0100
@@ -273,6 +273,7 @@
 {
 	u32 i;
 	struct channel_detector *cd;
+	int diff_ts;
 
 	/*
 	 * pulses received for a non-supported or un-initialized
@@ -285,8 +286,9 @@
 	if (cd == NULL)
 		return false;
 
+	diff_ts = event->ts - dpd->last_pulse_ts;
 	/* reset detector on time stamp wraparound, caused by TSF reset */
-	if (event->ts < dpd->last_pulse_ts)
+	if (diff_ts < dpd->common->dfs_pulse_valid_diff_ts)
 		dpd_reset(dpd);
 	dpd->last_pulse_ts = event->ts;
 
diff -ruw linux-5.4.60/drivers/net/wireless/ath/dfs_pattern_detector.h linux-5.4.60-fbx/drivers/net/wireless/ath/dfs_pattern_detector.h
--- linux-5.4.60/drivers/net/wireless/ath/dfs_pattern_detector.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/dfs_pattern_detector.h	2021-03-04 13:20:59.344172292 +0100
@@ -24,7 +24,7 @@
 /* tolerated deviation of radar time stamp in usecs on both sides
  * TODO: this might need to be HW-dependent
  */
-#define PRI_TOLERANCE	16
+#define PRI_TOLERANCE	6
 
 /**
  * struct ath_dfs_pool_stats - DFS Statistics for global pools
diff -ruw linux-5.4.60/drivers/net/wireless/ath/Kconfig linux-5.4.60-fbx/drivers/net/wireless/ath/Kconfig
--- linux-5.4.60/drivers/net/wireless/ath/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/Kconfig	2021-03-04 13:20:59.310838957 +0100
@@ -37,6 +37,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-5.4.60/drivers/net/wireless/ath/key.c linux-5.4.60-fbx/drivers/net/wireless/ath/key.c
--- linux-5.4.60/drivers/net/wireless/ath/key.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/key.c	2021-03-04 13:20:59.344172292 +0100
@@ -524,7 +524,7 @@
 			idx = ath_reserve_key_cache_slot(common, key->cipher);
 			break;
 		default:
-			idx = key->keyidx;
+			idx = ath_reserve_key_cache_slot(common, key->cipher);
 			break;
 		}
 	} else if (key->keyidx) {
diff -ruw linux-5.4.60/drivers/net/wireless/ath/regd.c linux-5.4.60-fbx/drivers/net/wireless/ath/regd.c
--- linux-5.4.60/drivers/net/wireless/ath/regd.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/ath/regd.c	2021-03-04 13:20:59.344172292 +0100
@@ -345,6 +345,10 @@
 	struct ieee80211_channel *ch;
 	unsigned int i;
 
+#ifdef CONFIG_ATH_REG_IGNORE
+	return;
+#endif
+
 	for (band = 0; band < NUM_NL80211_BANDS; band++) {
 		if (!wiphy->bands[band])
 			continue;
@@ -378,6 +382,10 @@
 {
 	struct ieee80211_supported_band *sband;
 
+#ifdef CONFIG_ATH_REG_IGNORE
+	return;
+#endif
+
 	sband = wiphy->bands[NL80211_BAND_2GHZ];
 	if (!sband)
 		return;
@@ -407,6 +415,9 @@
 	struct ieee80211_channel *ch;
 	unsigned int i;
 
+#ifdef CONFIG_ATH_REG_IGNORE
+	return;
+#endif
 	if (!wiphy->bands[NL80211_BAND_5GHZ])
 		return;
 
@@ -639,6 +650,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;
 
@@ -703,7 +719,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-5.4.60/drivers/net/wireless/mac80211_hwsim.c linux-5.4.60-fbx/drivers/net/wireless/mac80211_hwsim.c
--- linux-5.4.60/drivers/net/wireless/mac80211_hwsim.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/mac80211_hwsim.c	2021-03-04 13:20:59.414172295 +0100
@@ -619,6 +619,7 @@
 	[HWSIM_ATTR_PERM_ADDR] = { .type = NLA_UNSPEC, .len = ETH_ALEN },
 	[HWSIM_ATTR_IFTYPE_SUPPORT] = { .type = NLA_U32 },
 	[HWSIM_ATTR_CIPHER_SUPPORT] = { .type = NLA_BINARY },
+	[HWSIM_ATTR_BANDS] = { .type = NLA_U8 },
 };
 
 static void mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
@@ -2393,6 +2394,7 @@
 	u32 iftypes;
 	u32 *ciphers;
 	u8 n_ciphers;
+	u8 bands;
 };
 
 static void hwsim_mcast_config_msg(struct sk_buff *mcast_skb,
@@ -2934,6 +2936,9 @@
 
 		sband->band = band;
 
+		if (!(BIT(band) & param->bands))
+			continue;
+
 		switch (band) {
 		case NL80211_BAND_2GHZ:
 			sband->channels = data->channels_2ghz;
@@ -3474,10 +3479,14 @@
 	param.channels = channels;
 	param.destroy_on_close =
 		info->attrs[HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE];
+	param.bands = BIT(NL80211_BAND_2GHZ) | BIT(NL80211_BAND_5GHZ);
 
 	if (info->attrs[HWSIM_ATTR_CHANNELS])
 		param.channels = nla_get_u32(info->attrs[HWSIM_ATTR_CHANNELS]);
 
+	if (info->attrs[HWSIM_ATTR_BANDS])
+		param.bands = nla_get_u8(info->attrs[HWSIM_ATTR_BANDS]);
+
 	if (param.channels < 1) {
 		GENL_SET_ERR_MSG(info, "must have at least one channel");
 		return -EINVAL;
@@ -3585,7 +3594,8 @@
 
 	ret = mac80211_hwsim_new_radio(info, &param);
 	kfree(hwname);
-	return ret;
+
+	return (ret < 0) ? ret : 0;
 }
 
 static int hwsim_del_radio_nl(struct sk_buff *msg, struct genl_info *info)
diff -ruw linux-5.4.60/drivers/net/wireless/mac80211_hwsim.h linux-5.4.60-fbx/drivers/net/wireless/mac80211_hwsim.h
--- linux-5.4.60/drivers/net/wireless/mac80211_hwsim.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/mac80211_hwsim.h	2021-03-04 13:20:59.414172295 +0100
@@ -161,6 +161,7 @@
 	HWSIM_ATTR_PERM_ADDR,
 	HWSIM_ATTR_IFTYPE_SUPPORT,
 	HWSIM_ATTR_CIPHER_SUPPORT,
+	HWSIM_ATTR_BANDS,
 	__HWSIM_ATTR_MAX,
 };
 #define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1)
diff -ruw linux-5.4.60/drivers/net/wireless/marvell/Kconfig linux-5.4.60-fbx/drivers/net/wireless/marvell/Kconfig
--- linux-5.4.60/drivers/net/wireless/marvell/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/Kconfig	2021-03-04 13:20:59.414172295 +0100
@@ -25,4 +25,8 @@
 	  To compile this driver as a module, choose M here: the module
 	  will be called mwl8k.  If unsure, say N.
 
+config MWL8K_NEW
+	tristate "Marvell 88W8xxx PCI/PCIe NEW"
+	depends on MAC80211 && PCI
+
 endif # WLAN_VENDOR_MARVELL
diff -ruw linux-5.4.60/drivers/net/wireless/marvell/Makefile linux-5.4.60-fbx/drivers/net/wireless/marvell/Makefile
--- linux-5.4.60/drivers/net/wireless/marvell/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/Makefile	2021-03-04 13:20:59.414172295 +0100
@@ -5,3 +5,4 @@
 obj-$(CONFIG_MWIFIEX)	+= mwifiex/
 
 obj-$(CONFIG_MWL8K)	+= mwl8k.o
+obj-$(CONFIG_MWL8K_NEW)	+= mwl8k_new/
diff -ruw linux-5.4.60/drivers/net/wireless/marvell/mwl8k.c linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k.c
--- linux-5.4.60/drivers/net/wireless/marvell/mwl8k.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k.c	2021-03-04 13:20:59.424172295 +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,17 @@
 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");
+
+static int mac_addr_count = -1;
+module_param(mac_addr_count, int, 0);
+MODULE_PARM_DESC(ap_base_mac_addr,
+		  "Override EEPROM defined mac address count");
+
+
 /* Register definitions */
 #define MWL8K_HIU_GEN_PTR			0x00000c10
 #define  MWL8K_MODE_STA				 0x0000005a
@@ -181,6 +193,7 @@
 struct mwl8k_priv {
 	struct ieee80211_hw *hw;
 	struct pci_dev *pdev;
+	struct mac_address addresses[8];
 	int irq;
 
 	struct mwl8k_device_info *device_info;
@@ -300,6 +313,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 +343,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))
@@ -801,6 +820,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 {
@@ -1017,6 +1041,9 @@
 		}
 	}
 
+	if (le16_to_cpu(rxd->htsig2) & (1 << 7))
+		status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
+
 	if (rxd->channel > 14) {
 		status->band = NL80211_BAND_5GHZ;
 		if (!(status->encoding == RX_ENC_HT) &&
@@ -1661,6 +1688,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
@@ -1718,6 +1747,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,
@@ -1725,7 +1756,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
@@ -1739,18 +1769,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);
 
@@ -2442,7 +2479,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);
@@ -2516,6 +2553,20 @@
 	__le32 wcbbase_ampdu[MWL8K_MAX_AMPDU_QUEUES];
 } __packed;
 
+static void inc_mac(u8 *base, unsigned int count)
+{
+        unsigned int i;
+
+        for (i = 0; i < count; i++) {
+                int j;
+
+                for (j = 5; j >= 0; j--) {
+                        if (++base[j] != 0)
+                                break;
+                }
+        }
+}
+
 static int mwl8k_cmd_get_hw_spec_ap(struct ieee80211_hw *hw)
 {
 	struct mwl8k_priv *priv = hw->priv;
@@ -2537,6 +2588,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) {
@@ -2548,7 +2600,27 @@
 			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);
+
+		if (mac_addr_count > 0) {
+			unsigned int i;
+
+			for (i = 0; i < mac_addr_count &&
+				     i < ARRAY_SIZE(priv->addresses); i++) {
+				memcpy(&priv->addresses[i],
+				       hw->wiphy->perm_addr, 6);
+				inc_mac(priv->addresses[i].addr, i);
+			}
+
+			hw->wiphy->addresses = priv->addresses;
+			hw->wiphy->n_addresses = i;
+		}
+
 		priv->num_mcaddrs = le16_to_cpu(cmd->num_mcaddrs);
 		priv->fw_rev = le32_to_cpu(cmd->fw_rev);
 		priv->hw_rev = cmd->hw_rev;
@@ -4712,10 +4784,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,
@@ -4750,12 +4818,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;
 }
 
@@ -4783,8 +4854,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++)
@@ -4859,6 +4930,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);
@@ -5104,19 +5177,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;
 
@@ -5135,18 +5216,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);
 
@@ -6099,8 +6195,10 @@
 	 * Ask mac80211 to not to trigger PS mode
 	 * based on PM bit of incoming frames.
 	 */
-	if (priv->ap_fw)
+	if (priv->ap_fw) {
 		ieee80211_hw_set(hw, AP_LINK_PS);
+		ieee80211_hw_set(hw, APVLAN_NEED_MCAST_TO_UCAST);
+	}
 
 	hw->vif_data_size = sizeof(struct mwl8k_vif);
 	hw->sta_data_size = sizeof(struct mwl8k_sta);
@@ -6121,9 +6219,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-5.4.60/drivers/nvmem/core.c linux-5.4.60-fbx/drivers/nvmem/core.c
--- linux-5.4.60/drivers/nvmem/core.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/nvmem/core.c	2021-03-04 13:20:59.504172299 +0100
@@ -396,8 +396,10 @@
 			     config->name ? config->id : nvmem->id);
 	}
 
+#ifndef CONFIG_NVMEM_IGNORE_RO
 	nvmem->read_only = device_property_present(config->dev, "read-only") ||
 			   config->read_only || !nvmem->reg_write;
+#endif
 
 	nvmem->dev.groups = nvmem_sysfs_get_groups(nvmem, config);
 
diff -ruw linux-5.4.60/drivers/nvmem/Kconfig linux-5.4.60-fbx/drivers/nvmem/Kconfig
--- linux-5.4.60/drivers/nvmem/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/nvmem/Kconfig	2021-03-04 13:20:59.504172299 +0100
@@ -24,6 +24,9 @@
 	 This interface is mostly used by userspace applications to
 	 read/write directly into nvmem.
 
+config NVMEM_IGNORE_RO
+	bool "ignore read-only flags"
+
 config NVMEM_IMX_IIM
 	tristate "i.MX IC Identification Module support"
 	depends on ARCH_MXC || COMPILE_TEST
diff -ruw linux-5.4.60/drivers/of/fdt.c linux-5.4.60-fbx/drivers/of/fdt.c
--- linux-5.4.60/drivers/of/fdt.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/of/fdt.c	2021-03-04 13:20:59.507505632 +0100
@@ -28,6 +28,7 @@
 
 #include <asm/setup.h>  /* for COMMAND_LINE_SIZE */
 #include <asm/page.h>
+#include <asm-generic/vmlinux.lds.h>
 
 #include "of_private.h"
 
@@ -745,6 +746,39 @@
 	return 0;
 }
 
+/*
+ * iterate list of built-in dtb to find a compatible match
+ */
+const void __init *of_fdt_find_compatible_dtb(const char *name)
+{
+	struct fdt_header {
+		__be32 magic;
+		__be32 totalsize;
+	};
+	const struct fdt_header *blob, *best;
+	unsigned int best_score = ~0;
+
+	best = NULL;
+	blob = (const struct fdt_header *)__dtb_start;
+	while ((void *)blob < (void *)__dtb_end &&
+	       (be32_to_cpu(blob->magic) == OF_DT_HEADER)) {
+		unsigned int score;
+		u32 size;
+
+		score = of_fdt_is_compatible(blob, 0, name);
+		if (score > 0 && score < best_score) {
+			best = blob;
+			best_score = score;
+		}
+
+		size = be32_to_cpu(blob->totalsize);
+		blob = (const struct fdt_header *)
+			PTR_ALIGN((void *)blob + size, STRUCT_ALIGNMENT);
+	}
+
+	return best;
+}
+
 /**
  * of_flat_dt_is_compatible - Return true if given node has compat in compatible list
  * @node: node to test
@@ -1040,6 +1074,40 @@
 	return 0;
 }
 
+#ifdef CONFIG_RANDOM_OF
+/*
+ * get random seed area from device tree, and reserve it early enough
+ * so that it remains untouched until we can properly add it to the
+ * entropy pool.
+ */
+extern u64 random_seed_start;
+extern u64 random_seed_size;
+
+static void __init early_init_dt_handle_random_seed(unsigned long node)
+{
+	const __be32 *prop;
+	int len;
+
+	prop = of_get_flat_dt_prop(node, "fbx,random-seed", &len);
+	if (!prop)
+		return;
+
+	if (len != 16) {
+		pr_err("bad fbx,random-seed size %d vs %d!\n", 16, len);
+		return ;
+	}
+
+	random_seed_start = dt_mem_next_cell(2, &prop);
+	random_seed_size = dt_mem_next_cell(2, &prop);
+
+	memblock_reserve(random_seed_start, random_seed_size);
+}
+#else
+static inline void early_init_dt_handle_random_seed(unsigned long node)
+{
+}
+#endif
+
 int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
 				     int depth, void *data)
 {
@@ -1092,6 +1160,8 @@
 				fdt_totalsize(initial_boot_params));
 	}
 
+	early_init_dt_handle_random_seed(node);
+
 	/* break now */
 	return 1;
 }
diff -ruw linux-5.4.60/drivers/of/Kconfig linux-5.4.60-fbx/drivers/of/Kconfig
--- linux-5.4.60/drivers/of/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/of/Kconfig	2021-03-04 13:20:59.504172299 +0100
@@ -35,6 +35,11 @@
 
 	  If unsure, say N here, but this option is safe to enable.
 
+config OF_DTB_BUILTIN_LIST
+	string "Link given list of DTB files into kernel"
+	help
+	  Specify filename without .dtb extension
+
 config OF_FLATTREE
 	bool
 	select DTC
@@ -103,6 +108,13 @@
 config OF_NUMA
 	bool
 
+config OF_CONFIGFS
+	bool "Device Tree Overlay ConfigFS interface"
+	select CONFIGFS_FS
+	select OF_OVERLAY
+	help
+	  Enable a simple user-space driven DT overlay interface.
+
 config OF_DMA_DEFAULT_COHERENT
 	# arches should select this if DMA is coherent by default for OF devices
 	bool
diff -ruw linux-5.4.60/drivers/of/Makefile linux-5.4.60-fbx/drivers/of/Makefile
--- linux-5.4.60/drivers/of/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/of/Makefile	2021-03-04 13:20:59.504172299 +0100
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-y = base.o device.o platform.o property.o
 obj-$(CONFIG_OF_KOBJ) += kobj.o
+obj-$(CONFIG_OF_CONFIGFS) += configfs.o
 obj-$(CONFIG_OF_DYNAMIC) += dynamic.o
 obj-$(CONFIG_OF_FLATTREE) += fdt.o
 obj-$(CONFIG_OF_EARLY_FLATTREE) += fdt_address.o
diff -ruw linux-5.4.60/drivers/of/of_net.c linux-5.4.60-fbx/drivers/of/of_net.c
--- linux-5.4.60/drivers/of/of_net.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/of/of_net.c	2021-03-04 13:20:59.507505632 +0100
@@ -11,6 +11,7 @@
 #include <linux/phy.h>
 #include <linux/export.h>
 #include <linux/device.h>
+#include <linux/fbxserial.h>
 
 /**
  * of_get_phy_mode - Get phy mode for given device_node
@@ -97,6 +98,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-5.4.60/drivers/of/overlay.c linux-5.4.60-fbx/drivers/of/overlay.c
--- linux-5.4.60/drivers/of/overlay.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/of/overlay.c	2021-03-04 13:20:59.507505632 +0100
@@ -362,7 +362,7 @@
 	}
 
 	if (!of_node_check_flag(target->np, OF_OVERLAY))
-		pr_err("WARNING: memory leak will occur if overlay removed, property: %pOF/%s\n",
+		pr_debug("WARNING: memory leak will occur if overlay removed, property: %pOF/%s\n",
 		       target->np, new_prop->name);
 
 	if (ret) {
diff -ruw linux-5.4.60/drivers/pci/controller/Kconfig linux-5.4.60-fbx/drivers/pci/controller/Kconfig
--- linux-5.4.60/drivers/pci/controller/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/pci/controller/Kconfig	2021-03-04 13:20:59.514172300 +0100
@@ -265,6 +265,11 @@
 	  This can lead to data corruption if drivers perform concurrent
 	  config and MMIO accesses.
 
+config PCIE_BCM63XX
+	tristate "BCM63XX SoCs PCIe endpoint driver."
+	depends on ARCH_BCM63XX || COMPILE_TEST
+	depends on OF
+
 config VMD
 	depends on PCI_MSI && X86_64 && SRCU
 	select X86_DEV_DMA_OPS
diff -ruw linux-5.4.60/drivers/pci/controller/Makefile linux-5.4.60-fbx/drivers/pci/controller/Makefile
--- linux-5.4.60/drivers/pci/controller/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/pci/controller/Makefile	2021-03-04 13:20:59.514172300 +0100
@@ -29,6 +29,7 @@
 obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o
 obj-$(CONFIG_PCIE_MOBIVEIL) += pcie-mobiveil.o
 obj-$(CONFIG_PCIE_TANGO_SMP8759) += pcie-tango.o
+obj-$(CONFIG_PCIE_BCM63XX) += pcie-bcm63xx.o
 obj-$(CONFIG_VMD) += vmd.o
 # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW
 obj-y				+= dwc/
diff -ruw linux-5.4.60/drivers/pci/controller/pci-mvebu.c linux-5.4.60-fbx/drivers/pci/controller/pci-mvebu.c
--- linux-5.4.60/drivers/pci/controller/pci-mvebu.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/pci/controller/pci-mvebu.c	2021-03-04 13:20:59.517505633 +0100
@@ -72,6 +72,7 @@
 	struct mvebu_pcie_port *ports;
 	struct msi_controller *msi;
 	struct list_head resources;
+	struct gpio_descs *reset_gpios;
 	struct resource io;
 	struct resource realio;
 	struct resource mem;
@@ -97,8 +98,6 @@
 	unsigned int io_target;
 	unsigned int io_attr;
 	struct clk *clk;
-	struct gpio_desc *reset_gpio;
-	char *reset_name;
 	struct pci_bridge_emul bridge;
 	struct device_node *dn;
 	struct mvebu_pcie *pcie;
@@ -809,8 +808,7 @@
 	struct mvebu_pcie_port *port, struct device_node *child)
 {
 	struct device *dev = &pcie->pdev->dev;
-	enum of_gpio_flags flags;
-	int reset_gpio, ret;
+	int ret;
 
 	port->pcie = pcie;
 
@@ -850,42 +848,6 @@
 		port->io_attr = -1;
 	}
 
-	reset_gpio = of_get_named_gpio_flags(child, "reset-gpios", 0, &flags);
-	if (reset_gpio == -EPROBE_DEFER) {
-		ret = reset_gpio;
-		goto err;
-	}
-
-	if (gpio_is_valid(reset_gpio)) {
-		unsigned long gpio_flags;
-
-		port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset",
-						  port->name);
-		if (!port->reset_name) {
-			ret = -ENOMEM;
-			goto err;
-		}
-
-		if (flags & OF_GPIO_ACTIVE_LOW) {
-			dev_info(dev, "%pOF: reset gpio is active low\n",
-				 child);
-			gpio_flags = GPIOF_ACTIVE_LOW |
-				     GPIOF_OUT_INIT_LOW;
-		} else {
-			gpio_flags = GPIOF_OUT_INIT_HIGH;
-		}
-
-		ret = devm_gpio_request_one(dev, reset_gpio, gpio_flags,
-					    port->reset_name);
-		if (ret) {
-			if (ret == -EPROBE_DEFER)
-				goto err;
-			goto skip;
-		}
-
-		port->reset_gpio = gpio_to_desc(reset_gpio);
-	}
-
 	port->clk = of_clk_get_by_name(child, NULL);
 	if (IS_ERR(port->clk)) {
 		dev_err(dev, "%s: cannot get clock\n", port->name);
@@ -904,8 +866,6 @@
 	ret = 0;
 
 	/* In the case of skipping, we need to free these */
-	devm_kfree(dev, port->reset_name);
-	port->reset_name = NULL;
 	devm_kfree(dev, port->name);
 	port->name = NULL;
 
@@ -914,41 +874,11 @@
 }
 
 /*
- * Power up a PCIe port.  PCIe requires the refclk to be stable for 100µs
- * prior to releasing PERST.  See table 2-4 in section 2.6.2 AC Specifications
- * of the PCI Express Card Electromechanical Specification, 1.1.
- */
-static int mvebu_pcie_powerup(struct mvebu_pcie_port *port)
-{
-	int ret;
-
-	ret = clk_prepare_enable(port->clk);
-	if (ret < 0)
-		return ret;
-
-	if (port->reset_gpio) {
-		u32 reset_udelay = PCI_PM_D3COLD_WAIT * 1000;
-
-		of_property_read_u32(port->dn, "reset-delay-us",
-				     &reset_udelay);
-
-		udelay(100);
-
-		gpiod_set_value_cansleep(port->reset_gpio, 0);
-		msleep(reset_udelay / 1000);
-	}
-
-	return 0;
-}
-
-/*
  * Power down a PCIe port.  Strictly, PCIe requires us to place the card
  * in D3hot state before asserting PERST#.
  */
 static void mvebu_pcie_powerdown(struct mvebu_pcie_port *port)
 {
-	gpiod_set_value_cansleep(port->reset_gpio, 1);
-
 	clk_disable_unprepare(port->clk);
 }
 
@@ -1069,6 +999,16 @@
 	if (ret)
 		return ret;
 
+	/* get reset gpios */
+	pcie->reset_gpios = devm_gpiod_get_array_optional(dev,
+							  "reset",
+							  GPIOD_OUT_HIGH);
+	if (IS_ERR(pcie->reset_gpios)) {
+		ret = PTR_ERR(pcie->reset_gpios);
+		dev_err(dev, "failed to parse reset-gpios property: %d\n", ret);
+		return ret;
+	}
+
 	num = of_get_available_child_count(np);
 
 	pcie->ports = devm_kcalloc(dev, num, sizeof(*pcie->ports), GFP_KERNEL);
@@ -1099,8 +1039,37 @@
 		if (!child)
 			continue;
 
-		ret = mvebu_pcie_powerup(port);
+		ret = clk_prepare_enable(port->clk);
 		if (ret < 0)
+			return ret;
+	}
+
+	/*
+	 * Power up a PCIe port.  PCIe requires the refclk to be stable for 100µs
+	 * prior to releasing PERST.  See table 2-4 in section 2.6.2 AC Specifications
+	 * of the PCI Express Card Electromechanical Specification, 1.1.
+	 */
+	if (pcie->reset_gpios) {
+		struct gpio_descs *reset_gpios = pcie->reset_gpios;
+		u32 reset_udelay = PCI_PM_D3COLD_WAIT * 1000;
+		unsigned int i;
+
+		udelay(100);
+
+		dev_info(dev, "using %u gpio(s) to reset bus",
+			 reset_gpios->ndescs);
+
+		for (i = 0; i < reset_gpios->ndescs; i++)
+			gpiod_set_value(reset_gpios->desc[i], 0);
+
+		msleep(reset_udelay / 1000);
+	}
+
+	for (i = 0; i < pcie->nports; i++) {
+		struct mvebu_pcie_port *port = &pcie->ports[i];
+
+		child = port->dn;
+		if (!child)
 			continue;
 
 		port->base = mvebu_pcie_map_registers(pdev, child, port);
@@ -1111,6 +1080,13 @@
 			continue;
 		}
 
+		if (!mvebu_pcie_link_up(port))
+			dev_warn(&port->pcie->pdev->dev,
+				 "%s: PCIe link is DOWN", port->name);
+		else
+			dev_info(&port->pcie->pdev->dev,
+				 "%s: PCIe link is UP", port->name);
+
 		mvebu_pcie_setup_hw(port);
 		mvebu_pcie_set_local_dev_nr(port, 1);
 		mvebu_pci_bridge_emul_init(port);
diff -ruw linux-5.4.60/drivers/pci/quirks.c linux-5.4.60-fbx/drivers/pci/quirks.c
--- linux-5.4.60/drivers/pci/quirks.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/pci/quirks.c	2021-03-04 13:20:59.527505633 +0100
@@ -3083,6 +3083,8 @@
 	dev->is_hotplug_bridge = 1;
 }
 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 some
diff -ruw linux-5.4.60/drivers/phy/broadcom/Kconfig linux-5.4.60-fbx/drivers/phy/broadcom/Kconfig
--- linux-5.4.60/drivers/phy/broadcom/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/phy/broadcom/Kconfig	2021-03-04 13:20:59.537505634 +0100
@@ -29,6 +29,11 @@
 	help
 	  Enable this to support the Broadcom Kona USB 2.0 PHY.
 
+config PHY_BRCM_USB_63138
+	tristate "Broadcom 63138 USB 2.0/3.0 PHY Driver"
+	depends on ARCH_BCM_63XX || COMPILE_TEST
+	select GENERIC_PHY
+
 config PHY_BCM_NS_USB2
 	tristate "Broadcom Northstar USB 2.0 PHY Driver"
 	depends on ARCH_BCM_IPROC || COMPILE_TEST
diff -ruw linux-5.4.60/drivers/phy/broadcom/Makefile linux-5.4.60-fbx/drivers/phy/broadcom/Makefile
--- linux-5.4.60/drivers/phy/broadcom/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/phy/broadcom/Makefile	2021-03-04 13:20:59.537505634 +0100
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_PHY_CYGNUS_PCIE)		+= phy-bcm-cygnus-pcie.o
+obj-$(CONFIG_PHY_BRCM_USB_63138)	+= phy-brcm-usb-63138.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB2)		+= phy-bcm-ns-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB3)		+= phy-bcm-ns-usb3.o
diff -ruw linux-5.4.60/drivers/phy/Kconfig linux-5.4.60-fbx/drivers/phy/Kconfig
--- linux-5.4.60/drivers/phy/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/phy/Kconfig	2021-03-04 13:20:59.537505634 +0100
@@ -49,6 +49,10 @@
 	help
 	  This option enables support for APM X-Gene SoC multi-purpose PHY.
 
+config XDSL_PHY_API
+	tristate "xDSL PHY API"
+	select GENERIC_PHY
+
 source "drivers/phy/allwinner/Kconfig"
 source "drivers/phy/amlogic/Kconfig"
 source "drivers/phy/broadcom/Kconfig"
diff -ruw linux-5.4.60/drivers/phy/Makefile linux-5.4.60-fbx/drivers/phy/Makefile
--- linux-5.4.60/drivers/phy/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/phy/Makefile	2021-03-04 13:20:59.537505634 +0100
@@ -8,6 +8,8 @@
 obj-$(CONFIG_PHY_LPC18XX_USB_OTG)	+= phy-lpc18xx-usb-otg.o
 obj-$(CONFIG_PHY_XGENE)			+= phy-xgene.o
 obj-$(CONFIG_PHY_PISTACHIO_USB)		+= phy-pistachio-usb.o
+obj-$(CONFIG_XDSL_PHY_API)		+= xdsl_phy_api.o
+
 obj-$(CONFIG_ARCH_SUNXI)		+= allwinner/
 obj-$(CONFIG_ARCH_MESON)		+= amlogic/
 obj-$(CONFIG_ARCH_MEDIATEK)		+= mediatek/
diff -ruw linux-5.4.60/drivers/phy/marvell/Kconfig linux-5.4.60-fbx/drivers/phy/marvell/Kconfig
--- linux-5.4.60/drivers/phy/marvell/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/phy/marvell/Kconfig	2021-03-04 13:20:59.540838967 +0100
@@ -103,3 +103,11 @@
 	  The PHY driver will be used by Marvell udc/ehci/otg driver.
 
 	  To compile this driver as a module, choose M here.
+
+config PHY_UTMI_CP110
+	bool "Marvell CP110 UTMI PHY Driver"
+	depends on ARCH_MVEBU
+	depends on OF
+	help
+	  Enable this to support Marvell USB2.0 PHY driver for Marvell
+	  CP110-based SoCs (A7K and A8K).
diff -ruw linux-5.4.60/drivers/phy/marvell/Makefile linux-5.4.60-fbx/drivers/phy/marvell/Makefile
--- linux-5.4.60/drivers/phy/marvell/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/phy/marvell/Makefile	2021-03-04 13:20:59.540838967 +0100
@@ -10,3 +10,4 @@
 obj-$(CONFIG_PHY_PXA_28NM_HSIC)		+= phy-pxa-28nm-hsic.o
 obj-$(CONFIG_PHY_PXA_28NM_USB2)		+= phy-pxa-28nm-usb2.o
 obj-$(CONFIG_PHY_PXA_USB)		+= phy-pxa-usb.o
+obj-$(CONFIG_PHY_UTMI_CP110)		+= phy-utmi-cp110.o
diff -ruw linux-5.4.60/drivers/pinctrl/bcm/Kconfig linux-5.4.60-fbx/drivers/pinctrl/bcm/Kconfig
--- linux-5.4.60/drivers/pinctrl/bcm/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/pinctrl/bcm/Kconfig	2021-03-04 13:20:59.547505634 +0100
@@ -28,6 +28,15 @@
 	help
 	   Say Y here to enable the Broadcom BCM2835 GPIO driver.
 
+config PINCTRL_BCM63138
+	bool "Broadcom 63138 pinmux driver"
+	depends on OF && (ARCH_BCM_63XX || ARCH_BCM63XX || COMPILE_TEST)
+	default ARCH_BCM_63XX
+	select PINMUX
+	select PINCONF
+	select GENERIC_PINCONF
+	select GPIOLIB
+
 config PINCTRL_IPROC_GPIO
 	bool "Broadcom iProc GPIO (with PINCONF) driver"
 	depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST)
diff -ruw linux-5.4.60/drivers/pinctrl/bcm/Makefile linux-5.4.60-fbx/drivers/pinctrl/bcm/Makefile
--- linux-5.4.60/drivers/pinctrl/bcm/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/pinctrl/bcm/Makefile	2021-03-04 13:20:59.547505634 +0100
@@ -3,6 +3,7 @@
 
 obj-$(CONFIG_PINCTRL_BCM281XX)		+= pinctrl-bcm281xx.o
 obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
+obj-$(CONFIG_PINCTRL_BCM63138)		+= pinctrl-bcm63138.o
 obj-$(CONFIG_PINCTRL_IPROC_GPIO)	+= pinctrl-iproc-gpio.o
 obj-$(CONFIG_PINCTRL_CYGNUS_MUX)	+= pinctrl-cygnus-mux.o
 obj-$(CONFIG_PINCTRL_NS)		+= pinctrl-ns.o
diff -ruw linux-5.4.60/drivers/platform/Kconfig linux-5.4.60-fbx/drivers/platform/Kconfig
--- linux-5.4.60/drivers/platform/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/platform/Kconfig	2021-03-04 13:20:59.597505636 +0100
@@ -13,3 +13,9 @@
 source "drivers/platform/mellanox/Kconfig"
 
 source "drivers/platform/olpc/Kconfig"
+
+if X86_INTEL_CE
+source "drivers/platform/intelce/Kconfig"
+endif
+
+source "drivers/platform/fbxgw7r/Kconfig"
diff -ruw linux-5.4.60/drivers/platform/Makefile linux-5.4.60-fbx/drivers/platform/Makefile
--- linux-5.4.60/drivers/platform/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/platform/Makefile	2021-03-04 13:20:59.597505636 +0100
@@ -9,3 +9,5 @@
 obj-$(CONFIG_OLPC_EC)		+= olpc/
 obj-$(CONFIG_GOLDFISH)		+= goldfish/
 obj-$(CONFIG_CHROME_PLATFORMS)	+= chrome/
+obj-$(CONFIG_X86_INTEL_CE)	+= intelce/
+obj-$(CONFIG_FBXGW7R_PLATFORM)	+= fbxgw7r/
diff -ruw linux-5.4.60/drivers/soc/bcm/Kconfig linux-5.4.60-fbx/drivers/soc/bcm/Kconfig
--- linux-5.4.60/drivers/soc/bcm/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/soc/bcm/Kconfig	2021-03-04 13:20:59.834172314 +0100
@@ -34,5 +34,6 @@
 	  If unsure, say N.
 
 source "drivers/soc/bcm/brcmstb/Kconfig"
+source "drivers/soc/bcm/bcm63xx/Kconfig"
 
 endmenu
diff -ruw linux-5.4.60/drivers/soc/bcm/Makefile linux-5.4.60-fbx/drivers/soc/bcm/Makefile
--- linux-5.4.60/drivers/soc/bcm/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/soc/bcm/Makefile	2021-03-04 13:20:59.834172314 +0100
@@ -2,3 +2,4 @@
 obj-$(CONFIG_BCM2835_POWER)	+= bcm2835-power.o
 obj-$(CONFIG_RASPBERRYPI_POWER)	+= raspberrypi-power.o
 obj-$(CONFIG_SOC_BRCMSTB)	+= brcmstb/
+obj-$(CONFIG_SOC_BCM63XX)	+= bcm63xx/
diff -ruw linux-5.4.60/drivers/spi/Kconfig linux-5.4.60-fbx/drivers/spi/Kconfig
--- linux-5.4.60/drivers/spi/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/spi/Kconfig	2021-03-04 13:20:59.847505647 +0100
@@ -147,7 +147,7 @@
 
 config SPI_BCM63XX_HSSPI
 	tristate "Broadcom BCM63XX HS SPI controller driver"
-	depends on BCM63XX || ARCH_BCM_63XX || COMPILE_TEST
+	depends on BCM63XX || ARCH_BCM63XX || ARCH_BCM_63XX || COMPILE_TEST
 	help
 	  This enables support for the High Speed SPI controller present on
 	  newer Broadcom BCM63XX SoCs.
@@ -539,6 +539,12 @@
 	help
 	  This selects a driver for the PPC4xx SPI Controller.
 
+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 || ARCH_MMP || PCI || ACPI)
diff -ruw linux-5.4.60/drivers/spi/Makefile linux-5.4.60-fbx/drivers/spi/Makefile
--- linux-5.4.60/drivers/spi/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/spi/Makefile	2021-03-04 13:20:59.847505647 +0100
@@ -76,6 +76,7 @@
 obj-$(CONFIG_SPI_ORION)			+= spi-orion.o
 obj-$(CONFIG_SPI_PIC32)			+= spi-pic32.o
 obj-$(CONFIG_SPI_PIC32_SQI)		+= spi-pic32-sqi.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 spi-pxa2xx-dma.o
diff -ruw linux-5.4.60/drivers/spi/spi-orion.c linux-5.4.60-fbx/drivers/spi/spi-orion.c
--- linux-5.4.60/drivers/spi/spi-orion.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/spi/spi-orion.c	2021-03-04 13:20:59.854172315 +0100
@@ -48,6 +48,9 @@
 /* Register for the "Direct Mode" */
 #define SPI_DIRECT_WRITE_CONFIG_REG	0x20
 
+/* per-CS register parameters */
+#define SPI_CSN_TIMING_PARM_REGS(n)	(0x30 + 4 * (n))
+
 #define ORION_SPI_TMISO_SAMPLE_MASK	(0x3 << 6)
 #define ORION_SPI_TMISO_SAMPLE_1	(1 << 6)
 #define ORION_SPI_TMISO_SAMPLE_2	(2 << 6)
@@ -683,6 +686,25 @@
 		goto out_rel_axi_clk;
 	}
 
+	/*
+	 * on A8K (using a380 compatible) and A380, there are per-CS
+	 * timing parameters registers, which may be used and left
+	 * active by the bootloader.
+	 *
+	 * This drivers uses the global timing parameter register(s)
+	 * and interface configuration register, and could silently
+	 * fallback to previously configured per-CS timing parameters,
+	 * unless those registers are cleared beforehand.
+	 */
+	if (of_device_is_compatible(pdev->dev.of_node, 
+				    "marvell,armada-380-spi")) {
+		int cs;
+
+		for (cs = 0; cs < 8; ++cs)
+			writel(0x0, spi->base + SPI_CSN_TIMING_PARM_REGS(cs));
+
+	}
+
 	for_each_available_child_of_node(pdev->dev.of_node, np) {
 		struct orion_direct_acc *dir_acc;
 		u32 cs;
diff -ruw linux-5.4.60/drivers/tty/serial/8250/8250_pci.c linux-5.4.60-fbx/drivers/tty/serial/8250/8250_pci.c
--- linux-5.4.60/drivers/tty/serial/8250/8250_pci.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/tty/serial/8250/8250_pci.c	2021-03-04 13:21:00.027505655 +0100
@@ -1871,6 +1871,11 @@
 #define PCIE_DEVICE_ID_WCH_CH384_4S	0x3470
 #define PCIE_DEVICE_ID_WCH_CH382_2S	0x3253
 
+#define PCI_DEVICE_ID_PERICOM_PI7C9X7951	0x7951
+#define PCI_DEVICE_ID_PERICOM_PI7C9X7952	0x7952
+#define PCI_DEVICE_ID_PERICOM_PI7C9X7954	0x7954
+#define PCI_DEVICE_ID_PERICOM_PI7C9X7958	0x7958
+
 #define PCI_VENDOR_ID_ACCESIO			0x494f
 #define PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SDB	0x1051
 #define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2S	0x1053
diff -ruw linux-5.4.60/drivers/tty/serial/Kconfig linux-5.4.60-fbx/drivers/tty/serial/Kconfig
--- linux-5.4.60/drivers/tty/serial/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/tty/serial/Kconfig	2021-03-04 13:21:00.027505655 +0100
@@ -1134,6 +1134,11 @@
 	    BCM68xx (PON)
 	    BCM7xxx (STB) - DOCSIS console
 
+config SERIAL_BCM63XX_HS
+	tristate "Broadcom BCM63xx HS UART support"
+	select SERIAL_CORE
+	depends on ARCH_BCM63XX || COMPILE_TEST
+
 config SERIAL_BCM63XX_CONSOLE
 	bool "Console on BCM63xx serial port"
 	depends on SERIAL_BCM63XX=y
diff -ruw linux-5.4.60/drivers/tty/serial/Makefile linux-5.4.60-fbx/drivers/tty/serial/Makefile
--- linux-5.4.60/drivers/tty/serial/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/tty/serial/Makefile	2021-03-04 13:21:00.027505655 +0100
@@ -30,6 +30,7 @@
 obj-$(CONFIG_SERIAL_PNX8XXX) += pnx8xxx_uart.o
 obj-$(CONFIG_SERIAL_SA1100) += sa1100.o
 obj-$(CONFIG_SERIAL_BCM63XX) += bcm63xx_uart.o
+obj-$(CONFIG_SERIAL_BCM63XX_HS) += bcm63xx-hs-uart.o
 obj-$(CONFIG_SERIAL_SAMSUNG) += samsung.o
 obj-$(CONFIG_SERIAL_MAX3100) += max3100.o
 obj-$(CONFIG_SERIAL_MAX310X) += max310x.o
diff -ruw linux-5.4.60/drivers/usb/host/ehci-orion.c linux-5.4.60-fbx/drivers/usb/host/ehci-orion.c
--- linux-5.4.60/drivers/usb/host/ehci-orion.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/usb/host/ehci-orion.c	2021-03-04 13:21:00.080838992 +0100
@@ -19,6 +19,7 @@
 #include <linux/usb/hcd.h>
 #include <linux/io.h>
 #include <linux/dma-mapping.h>
+#include <linux/reset.h>
 
 #include "ehci.h"
 
@@ -57,11 +58,13 @@
 			     | USB_SBUSCFG_AHBBRST_INCR16)
 
 #define DRIVER_DESC "EHCI orion driver"
+#define EHCI_MAX_RSTS 4
 
 #define hcd_to_orion_priv(h) ((struct orion_ehci_hcd *)hcd_to_ehci(h)->priv)
 
 struct orion_ehci_hcd {
 	struct clk *clk;
+	struct reset_control *rsts[EHCI_MAX_RSTS];
 	struct phy *phy;
 };
 
@@ -212,7 +215,7 @@
 	struct usb_hcd *hcd;
 	struct ehci_hcd *ehci;
 	void __iomem *regs;
-	int irq, err;
+	int irq, err, rst;
 	enum orion_ehci_phy_ver phy_version;
 	struct orion_ehci_hcd *priv;
 
@@ -267,6 +270,22 @@
 	if (!IS_ERR(priv->clk))
 		clk_prepare_enable(priv->clk);
 
+	for (rst = 0; rst < EHCI_MAX_RSTS; rst++) {
+		priv->rsts[rst] = devm_reset_control_get_shared_by_index(
+					&pdev->dev, rst);
+		if (IS_ERR(priv->rsts[rst])) {
+			err = PTR_ERR(priv->rsts[rst]);
+			if (err == -EPROBE_DEFER)
+				goto err;
+			priv->rsts[rst] = NULL;
+			break;
+		}
+
+		err = reset_control_deassert(priv->rsts[rst]);
+		if (err)
+			goto err;
+	}
+
 	priv->phy = devm_phy_optional_get(&pdev->dev, "usb");
 	if (IS_ERR(priv->phy)) {
 		err = PTR_ERR(priv->phy);
@@ -313,6 +332,7 @@
 		clk_disable_unprepare(priv->clk);
 	usb_put_hcd(hcd);
 err:
+	if (err != -EPROBE_DEFER)
 	dev_err(&pdev->dev, "init %s fail, %d\n",
 		dev_name(&pdev->dev), err);
 
diff -ruw linux-5.4.60/drivers/usb/host/Kconfig linux-5.4.60-fbx/drivers/usb/host/Kconfig
--- linux-5.4.60/drivers/usb/host/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/usb/host/Kconfig	2021-03-04 13:21:00.080838992 +0100
@@ -70,13 +70,13 @@
 	  If unsure, say N.
 
 config USB_XHCI_MVEBU
-	tristate "xHCI support for Marvell Armada 375/38x/37xx"
+	tristate "xHCI support for Marvell Armada 375/38x/37xx/70x0/80x0"
 	select USB_XHCI_PLATFORM
 	depends on HAS_IOMEM
 	depends on ARCH_MVEBU || COMPILE_TEST
 	---help---
 	  Say 'Y' to enable the support for the xHCI host controller
-	  found in Marvell Armada 375/38x/37xx ARM SOCs.
+	  found in Marvell Armada 375/38x/37xx/70x0/80x0 ARM SOCs.
 
 config USB_XHCI_RCAR
 	tristate "xHCI support for Renesas R-Car SoCs"
@@ -734,6 +734,10 @@
 
 	  If unsure, say N.
 
+config USB_BCM63158
+	tristate "Broadcom BCM63158 SoC USB host driver"
+	depends on ARCH_BCM63XX || COMPILE_TEST
+
 config USB_HCD_SSB
 	tristate "SSB usb host driver"
 	depends on SSB
diff -ruw linux-5.4.60/drivers/usb/host/Makefile linux-5.4.60-fbx/drivers/usb/host/Makefile
--- linux-5.4.60/drivers/usb/host/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/usb/host/Makefile	2021-03-04 13:21:00.080838992 +0100
@@ -88,3 +88,4 @@
 obj-$(CONFIG_USB_HCD_SSB)	+= ssb-hcd.o
 obj-$(CONFIG_USB_FOTG210_HCD)	+= fotg210-hcd.o
 obj-$(CONFIG_USB_MAX3421_HCD)	+= max3421-hcd.o
+obj-$(CONFIG_USB_BCM63158)	+= usb-bcm63158.o
diff -ruw linux-5.4.60/drivers/usb/storage/usb.c linux-5.4.60-fbx/drivers/usb/storage/usb.c
--- linux-5.4.60/drivers/usb/storage/usb.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/usb/storage/usb.c	2021-03-04 13:21:00.120838993 +0100
@@ -67,7 +67,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-5.4.60/drivers/video/fbdev/Kconfig linux-5.4.60-fbx/drivers/video/fbdev/Kconfig
--- linux-5.4.60/drivers/video/fbdev/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/video/fbdev/Kconfig	2021-03-04 13:21:00.130838993 +0100
@@ -2263,6 +2263,24 @@
 	  called sm712fb. If you want to compile it as a module, say M
 	  here and read <file:Documentation/kbuild/modules.rst>.
 
+config FB_SSD1320
+	tristate "SSD1320 OLED driver"
+	depends on FB && SPI
+	select FB_SYS_FILLRECT
+	select FB_SYS_COPYAREA
+	select FB_SYS_IMAGEBLIT
+	select FB_SYS_FOPS
+	select FB_BACKLIGHT
+
+config FB_SSD1327
+	tristate "SSD1327 OLED driver"
+	depends on FB && SPI
+	select FB_SYS_FILLRECT
+	select FB_SYS_COPYAREA
+	select FB_SYS_IMAGEBLIT
+	select FB_SYS_FOPS
+	select FB_BACKLIGHT
+
 source "drivers/video/fbdev/omap/Kconfig"
 source "drivers/video/fbdev/omap2/Kconfig"
 source "drivers/video/fbdev/mmp/Kconfig"
diff -ruw linux-5.4.60/drivers/video/fbdev/Makefile linux-5.4.60-fbx/drivers/video/fbdev/Makefile
--- linux-5.4.60/drivers/video/fbdev/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/video/fbdev/Makefile	2021-03-04 13:21:00.130838993 +0100
@@ -131,6 +131,8 @@
 obj-$(CONFIG_FB_DA8XX)		  += da8xx-fb.o
 obj-$(CONFIG_FB_SSD1307)	  += ssd1307fb.o
 obj-$(CONFIG_FB_SIMPLE)           += simplefb.o
+obj-$(CONFIG_FB_SSD1327)          += ssd1327.o
+obj-$(CONFIG_FB_SSD1320)          += ssd1320.o
 
 # the test framebuffer is last
 obj-$(CONFIG_FB_VIRTUAL)          += vfb.o
diff -ruw linux-5.4.60/drivers/video/Kconfig linux-5.4.60-fbx/drivers/video/Kconfig
--- linux-5.4.60/drivers/video/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/drivers/video/Kconfig	2021-03-04 13:21:00.127505660 +0100
@@ -46,5 +46,4 @@
 
 endif
 
-
 endmenu
diff -ruw linux-5.4.60/fs/exec.c linux-5.4.60-fbx/fs/exec.c
--- linux-5.4.60/fs/exec.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/fs/exec.c	2021-03-04 13:21:00.760839022 +0100
@@ -1729,6 +1729,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-5.4.60/fs/Kconfig linux-5.4.60-fbx/fs/Kconfig
--- linux-5.4.60/fs/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/fs/Kconfig	2021-03-30 15:23:23.571651105 +0200
@@ -143,6 +143,7 @@
 
 source "fs/fat/Kconfig"
 source "fs/ntfs/Kconfig"
+source "fs/exfat/Kconfig"
 
 endmenu
 endif # BLOCK
diff -ruw linux-5.4.60/fs/Makefile linux-5.4.60-fbx/fs/Makefile
--- linux-5.4.60/fs/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/fs/Makefile	2021-03-30 15:23:23.571651105 +0200
@@ -132,3 +132,4 @@
 obj-$(CONFIG_PSTORE)		+= pstore/
 obj-$(CONFIG_EFIVAR_FS)		+= efivarfs/
 obj-$(CONFIG_EROFS_FS)		+= erofs/
+obj-$(CONFIG_EXFAT_FS_FBX)	+= exfat/
diff -ruw linux-5.4.60/fs/proc/array.c linux-5.4.60-fbx/fs/proc/array.c
--- linux-5.4.60/fs/proc/array.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/fs/proc/array.c	2021-03-04 13:21:00.864172360 +0100
@@ -149,6 +149,21 @@
 	return task_state_array[task_state_index(tsk)];
 }
 
+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)
 {
@@ -378,6 +393,12 @@
 	seq_putc(m, '\n');
 }
 
+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",
@@ -424,6 +445,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-5.4.60/fs/pstore/ram.c linux-5.4.60-fbx/fs/pstore/ram.c
--- linux-5.4.60/fs/pstore/ram.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/fs/pstore/ram.c	2021-03-30 15:23:23.571651105 +0200
@@ -516,7 +516,7 @@
 static int ramoops_init_przs(const char *name,
 			     struct device *dev, struct ramoops_context *cxt,
 			     struct persistent_ram_zone ***przs,
-			     phys_addr_t *paddr, size_t mem_sz,
+			     phys_addr_t *paddr, void *vaddr, size_t mem_sz,
 			     ssize_t record_size,
 			     unsigned int *cnt, u32 sig, u32 flags)
 {
@@ -580,7 +580,7 @@
 		else
 			label = kasprintf(GFP_KERNEL, "ramoops:%s(%d/%d)",
 					  name, i, *cnt - 1);
-		prz_ar[i] = persistent_ram_new(*paddr, zone_sz, sig,
+		prz_ar[i] = persistent_ram_new(*paddr, vaddr, zone_sz, sig,
 					       &cxt->ecc_info,
 					       cxt->memtype, flags, label);
 		kfree(label);
@@ -612,7 +612,7 @@
 static int ramoops_init_prz(const char *name,
 			    struct device *dev, struct ramoops_context *cxt,
 			    struct persistent_ram_zone **prz,
-			    phys_addr_t *paddr, size_t sz, u32 sig)
+			    phys_addr_t *paddr, void *vaddr, size_t sz, u32 sig)
 {
 	char *label;
 
@@ -627,7 +627,7 @@
 	}
 
 	label = kasprintf(GFP_KERNEL, "ramoops:%s", name);
-	*prz = persistent_ram_new(*paddr, sz, sig, &cxt->ecc_info,
+	*prz = persistent_ram_new(*paddr, vaddr, sz, sig, &cxt->ecc_info,
 				  cxt->memtype, PRZ_FLAG_ZAP_OLD, label);
 	kfree(label);
 	if (IS_ERR(*prz)) {
@@ -794,12 +794,14 @@
 	dump_mem_sz = cxt->size - cxt->console_size - cxt->ftrace_size
 			- cxt->pmsg_size;
 	err = ramoops_init_przs("dmesg", dev, cxt, &cxt->dprzs, &paddr,
+				pdata->mem_ptr,
 				dump_mem_sz, cxt->record_size,
 				&cxt->max_dump_cnt, 0, 0);
 	if (err)
 		goto fail_out;
 
 	err = ramoops_init_prz("console", dev, cxt, &cxt->cprz, &paddr,
+			       pdata->mem_ptr,
 			       cxt->console_size, 0);
 	if (err)
 		goto fail_init_cprz;
@@ -808,6 +810,7 @@
 				? nr_cpu_ids
 				: 1;
 	err = ramoops_init_przs("ftrace", dev, cxt, &cxt->fprzs, &paddr,
+				pdata->mem_ptr,
 				cxt->ftrace_size, -1,
 				&cxt->max_ftrace_cnt, LINUX_VERSION_CODE,
 				(cxt->flags & RAMOOPS_FLAG_FTRACE_PER_CPU)
@@ -816,6 +819,7 @@
 		goto fail_init_fprz;
 
 	err = ramoops_init_prz("pmsg", dev, cxt, &cxt->mprz, &paddr,
+			       pdata->mem_ptr,
 				cxt->pmsg_size, 0);
 	if (err)
 		goto fail_init_mprz;
diff -ruw linux-5.4.60/fs/pstore/ram_core.c linux-5.4.60-fbx/fs/pstore/ram_core.c
--- linux-5.4.60/fs/pstore/ram_core.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/fs/pstore/ram_core.c	2021-03-30 15:23:23.571651105 +0200
@@ -463,13 +463,16 @@
 	return va;
 }
 
-static int persistent_ram_buffer_map(phys_addr_t start, phys_addr_t size,
+static int persistent_ram_buffer_map(phys_addr_t start, void *vaddr,
+				     phys_addr_t size,
 		struct persistent_ram_zone *prz, int memtype)
 {
 	prz->paddr = start;
 	prz->size = size;
 
-	if (pfn_valid(start >> PAGE_SHIFT))
+	if (vaddr)
+		prz->vaddr = vaddr;
+	else if (pfn_valid(start >> PAGE_SHIFT))
 		prz->vaddr = persistent_ram_vmap(start, size, memtype);
 	else
 		prz->vaddr = persistent_ram_iomap(start, size, memtype,
@@ -558,7 +561,8 @@
 	kfree(prz);
 }
 
-struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
+struct persistent_ram_zone *persistent_ram_new(phys_addr_t start,
+					       void *vaddr, size_t size,
 			u32 sig, struct persistent_ram_ecc_info *ecc_info,
 			unsigned int memtype, u32 flags, char *label)
 {
@@ -576,7 +580,7 @@
 	prz->flags = flags;
 	prz->label = kstrdup(label, GFP_KERNEL);
 
-	ret = persistent_ram_buffer_map(start, size, prz, memtype);
+	ret = persistent_ram_buffer_map(start, vaddr, size, prz, memtype);
 	if (ret)
 		goto err;
 
diff -ruw linux-5.4.60/include/asm-generic/vmlinux.lds.h linux-5.4.60-fbx/include/asm-generic/vmlinux.lds.h
--- linux-5.4.60/include/asm-generic/vmlinux.lds.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/asm-generic/vmlinux.lds.h	2021-03-04 13:21:00.920839029 +0100
@@ -264,7 +264,7 @@
 #define KERNEL_DTB()							\
 	STRUCT_ALIGN();							\
 	__dtb_start = .;						\
-	KEEP(*(.dtb.init.rodata))					\
+	KEEP(*(.dtb.rodata))						\
 	__dtb_end = .;
 
 /*
@@ -354,6 +354,7 @@
 	. = ALIGN((align));						\
 	.rodata           : AT(ADDR(.rodata) - LOAD_OFFSET) {		\
 		__start_rodata = .;					\
+		KERNEL_DTB()						\
 		*(.rodata) *(.rodata.*)					\
 		RO_AFTER_INIT_DATA	/* Read only after init */	\
 		. = ALIGN(8);						\
@@ -644,7 +645,6 @@
 	TIMER_OF_TABLES()						\
 	CPU_METHOD_OF_TABLES()						\
 	CPUIDLE_METHOD_OF_TABLES()					\
-	KERNEL_DTB()							\
 	IRQCHIP_OF_MATCH_TABLE()					\
 	ACPI_PROBE_TABLE(irqchip)					\
 	ACPI_PROBE_TABLE(timer)						\
diff -ruw linux-5.4.60/include/linux/ethtool.h linux-5.4.60-fbx/include/linux/ethtool.h
--- linux-5.4.60/include/linux/ethtool.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/ethtool.h	2021-03-04 13:21:00.967505698 +0100
@@ -404,6 +404,14 @@
 				      struct ethtool_fecparam *);
 	void	(*get_ethtool_phy_stats)(struct net_device *,
 					 struct ethtool_stats *, u64 *);
+	int	(*get_epon_param)(struct net_device *,
+				  struct ethtool_epon_param *);
+	int	(*set_epon_param)(struct net_device *,
+				  const struct ethtool_epon_param *);
+	int	(*set_shaper_param)(struct net_device *,
+				    const struct ethtool_shaper_params *);
+	int	(*get_shaper_param)(struct net_device *,
+				    struct ethtool_shaper_params *);
 };
 
 struct ethtool_rx_flow_rule {
diff -ruw linux-5.4.60/include/linux/genhd.h linux-5.4.60-fbx/include/linux/genhd.h
--- linux-5.4.60/include/linux/genhd.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/genhd.h	2021-03-04 13:21:00.970839031 +0100
@@ -91,6 +91,7 @@
 	unsigned long io_ticks;
 	unsigned long time_in_queue;
 	local_t in_flight[2];
+	unsigned long io_errors[2];
 };
 
 #define PARTITION_META_INFO_VOLNAMELTH	64
@@ -614,6 +615,7 @@
 #define ADDPART_FLAG_NONE	0
 #define ADDPART_FLAG_RAID	1
 #define ADDPART_FLAG_WHOLEDISK	2
+#define ADDPART_FLAG_RO		4
 
 extern int blk_alloc_devt(struct hd_struct *part, dev_t *devt);
 extern void blk_free_devt(dev_t devt);
diff -ruw linux-5.4.60/include/linux/if_vlan.h linux-5.4.60-fbx/include/linux/if_vlan.h
--- linux-5.4.60/include/linux/if_vlan.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/if_vlan.h	2021-03-04 13:21:00.977505698 +0100
@@ -12,6 +12,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)
@@ -134,6 +135,7 @@
 			 int (*action)(struct net_device *dev, int vid,
 				       void *arg), void *arg);
 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);
 
@@ -200,7 +202,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 */
@@ -242,6 +244,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-5.4.60/include/linux/in.h linux-5.4.60-fbx/include/linux/in.h
--- linux-5.4.60/include/linux/in.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/in.h	2021-03-04 13:21:00.980839031 +0100
@@ -30,6 +30,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-5.4.60/include/linux/miscdevice.h linux-5.4.60-fbx/include/linux/miscdevice.h
--- linux-5.4.60/include/linux/miscdevice.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/miscdevice.h	2021-03-04 13:21:01.004172366 +0100
@@ -21,6 +21,7 @@
 #define APOLLO_MOUSE_MINOR	7	/* unused */
 #define PC110PAD_MINOR		9	/* unused */
 /*#define ADB_MOUSE_MINOR	10	FIXME OBSOLETE */
+#define TALDEV_MINOR		74	/* Marvell TAL device */
 #define WATCHDOG_MINOR		130	/* Watchdog timer     */
 #define TEMP_MINOR		131	/* Temperature Sensor */
 #define APM_MINOR_DEV		134
diff -ruw linux-5.4.60/include/linux/mtd/mtd.h linux-5.4.60-fbx/include/linux/mtd/mtd.h
--- linux-5.4.60/include/linux/mtd/mtd.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/mtd/mtd.h	2021-03-04 13:21:01.010839033 +0100
@@ -247,6 +247,12 @@
 	 */
 	unsigned int bitflip_threshold;
 
+	/* NAND related attributes */
+	const char *nand_type;
+	const char *nand_manufacturer;
+	const char *onfi_model;
+	uint8_t onfi_ecc_bits;
+
 	/* Kernel-only stuff starts here. */
 	const char *name;
 	int index;
diff -ruw linux-5.4.60/include/linux/mtd/rawnand.h linux-5.4.60-fbx/include/linux/mtd/rawnand.h
--- linux-5.4.60/include/linux/mtd/rawnand.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/mtd/rawnand.h	2021-03-04 13:21:01.010839033 +0100
@@ -222,6 +222,9 @@
  */
 #define NAND_KEEP_TIMINGS	0x00800000
 
+/* NAND controller does not want RNDOUT commands, even in NAND_ECC_SOFT */
+#define NAND_NO_RNDOUT		0x01000000
+
 /* Cell info constants */
 #define NAND_CI_CHIPNR_MSK	0x03
 #define NAND_CI_CELLTYPE_MSK	0x0C
diff -ruw linux-5.4.60/include/linux/mtd/spi-nor.h linux-5.4.60-fbx/include/linux/mtd/spi-nor.h
--- linux-5.4.60/include/linux/mtd/spi-nor.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/mtd/spi-nor.h	2021-03-04 13:21:01.010839033 +0100
@@ -56,9 +56,11 @@
 #define SPINOR_OP_PP_1_8_8	0xc2	/* Octal page program */
 #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_RDSFDP	0x5a	/* Read SFDP */
 #define SPINOR_OP_RDCR		0x35	/* Read configuration register */
@@ -598,6 +600,8 @@
 	ssize_t (*write)(struct spi_nor *nor, loff_t to,
 			size_t len, 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 (*clear_sr_bp)(struct spi_nor *nor);
 	struct spi_nor_flash_parameter params;
diff -ruw linux-5.4.60/include/linux/mv643xx_eth.h linux-5.4.60-fbx/include/linux/mv643xx_eth.h
--- linux-5.4.60/include/linux/mv643xx_eth.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/mv643xx_eth.h	2021-03-04 13:21:01.010839033 +0100
@@ -26,6 +26,9 @@
 	 * limit of 9KiB will be used.
 	 */
 	int			tx_csum_limit;
+	int			unit;
+
+	struct device_node	*mdio_node;
 };
 
 #define MV643XX_ETH_PHY_ADDR_DEFAULT	0
diff -ruw linux-5.4.60/include/linux/netdevice.h linux-5.4.60-fbx/include/linux/netdevice.h
--- linux-5.4.60/include/linux/netdevice.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/netdevice.h	2021-03-04 13:21:01.014172366 +0100
@@ -65,6 +65,20 @@
 struct bpf_prog;
 struct xdp_buff;
 
+#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);
 
@@ -1522,6 +1536,8 @@
 	IFF_FAILOVER_SLAVE		= 1<<28,
 	IFF_L3MDEV_RX_HANDLER		= 1<<29,
 	IFF_LIVE_RENAME_OK		= 1<<30,
+	IFF_FBXBRIDGE			= 1ULL<<31,
+	IFF_FBXBRIDGE_PORT		= 1ULL<<32,
 };
 
 #define IFF_802_1Q_VLAN			IFF_802_1Q_VLAN
@@ -1554,6 +1570,8 @@
 #define IFF_FAILOVER_SLAVE		IFF_FAILOVER_SLAVE
 #define IFF_L3MDEV_RX_HANDLER		IFF_L3MDEV_RX_HANDLER
 #define IFF_LIVE_RENAME_OK		IFF_LIVE_RENAME_OK
+#define IFF_FBXBRIDGE			IFF_FBXBRIDGE
+#define IFF_FBXBRIDGE_PORT		IFF_FBXBRIDGE_PORT
 
 /**
  *	struct net_device - The DEVICE structure.
@@ -1858,7 +1876,7 @@
 	const struct header_ops *header_ops;
 
 	unsigned int		flags;
-	unsigned int		priv_flags;
+	u64			priv_flags;
 
 	unsigned short		gflags;
 	unsigned short		padded;
@@ -4616,6 +4634,16 @@
 	return dev->priv_flags & IFF_BRIDGE_PORT;
 }
 
+static inline bool netif_is_fbxbridge_master(const struct net_device *dev)
+{
+	return dev->priv_flags & IFF_FBXBRIDGE;
+}
+
+static inline bool netif_is_fbxbridge_port(const struct net_device *dev)
+{
+	return dev->priv_flags & IFF_FBXBRIDGE_PORT;
+}
+
 static inline bool netif_is_ovs_master(const struct net_device *dev)
 {
 	return dev->priv_flags & IFF_OPENVSWITCH;
diff -ruw linux-5.4.60/include/linux/netfilter/nf_conntrack_ftp.h linux-5.4.60-fbx/include/linux/netfilter/nf_conntrack_ftp.h
--- linux-5.4.60/include/linux/netfilter/nf_conntrack_ftp.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/netfilter/nf_conntrack_ftp.h	2021-03-04 13:21:01.014172366 +0100
@@ -22,6 +22,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
 };
 
 /* For NAT to hook in when we find a packet which describes what other
diff -ruw linux-5.4.60/include/linux/netfilter/nf_conntrack_sip.h linux-5.4.60-fbx/include/linux/netfilter/nf_conntrack_sip.h
--- linux-5.4.60/include/linux/netfilter/nf_conntrack_sip.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/netfilter/nf_conntrack_sip.h	2021-03-04 13:21:01.014172366 +0100
@@ -5,6 +5,7 @@
 #include <linux/skbuff.h>
 #include <linux/types.h>
 #include <net/netfilter/nf_conntrack_expect.h>
+#include <crypto/sha.h>
 
 #define SIP_PORT	5060
 #define SIP_TIMEOUT	3600
@@ -30,6 +31,10 @@
 	enum sip_expectation_classes	class;
 };
 
+struct nf_ct_sip_expect {
+	u8				cid_hash[SHA256_DIGEST_SIZE];
+};
+
 #define SDP_MEDIA_TYPE(__name, __class)					\
 {									\
 	.name	= (__name),						\
diff -ruw linux-5.4.60/include/linux/netfilter/nf_conntrack_tcp.h linux-5.4.60-fbx/include/linux/netfilter/nf_conntrack_tcp.h
--- linux-5.4.60/include/linux/netfilter/nf_conntrack_tcp.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/netfilter/nf_conntrack_tcp.h	2021-03-04 13:21:01.014172366 +0100
@@ -28,6 +28,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-5.4.60/include/linux/of_fdt.h linux-5.4.60-fbx/include/linux/of_fdt.h
--- linux-5.4.60/include/linux/of_fdt.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/of_fdt.h	2021-03-04 13:21:01.017505700 +0100
@@ -89,6 +89,7 @@
 extern void unflatten_and_copy_device_tree(void);
 extern void early_init_devtree(void *);
 extern void early_get_first_memblock_info(void *, phys_addr_t *);
+const void *of_fdt_find_compatible_dtb(const char *name);
 #else /* CONFIG_OF_EARLY_FLATTREE */
 static inline int early_init_dt_scan_chosen_stdout(void) { return -ENODEV; }
 static inline void early_init_fdt_scan_reserved_mem(void) {}
diff -ruw linux-5.4.60/include/linux/pci_ids.h linux-5.4.60-fbx/include/linux/pci_ids.h
--- linux-5.4.60/include/linux/pci_ids.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/pci_ids.h	2021-03-04 13:21:01.020839033 +0100
@@ -1838,6 +1838,7 @@
 #define PCI_DEVICE_ID_PERICOM_PI7C9X7952	0x7952
 #define PCI_DEVICE_ID_PERICOM_PI7C9X7954	0x7954
 #define PCI_DEVICE_ID_PERICOM_PI7C9X7958	0x7958
+#define PCI_DEVICE_ID_PI7C9X20303SL	0xa303
 
 #define PCI_SUBVENDOR_ID_CHASE_PCIFAST		0x12E0
 #define PCI_SUBDEVICE_ID_CHASE_PCIFAST4		0x0031
diff -ruw linux-5.4.60/include/linux/phy.h linux-5.4.60-fbx/include/linux/phy.h
--- linux-5.4.60/include/linux/phy.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/phy.h	2021-03-04 13:21:01.020839033 +0100
@@ -102,6 +102,14 @@
 	/* 10GBASE-KR, XFI, SFI - single lane 10G Serdes */
 	PHY_INTERFACE_MODE_10GKR,
 	PHY_INTERFACE_MODE_USXGMII,
+
+	PHY_INTERFACE_MODE_1000BASEPX_D,
+	PHY_INTERFACE_MODE_1000BASEPX_U,
+	PHY_INTERFACE_MODE_10000BASEPR_D,
+	PHY_INTERFACE_MODE_10000BASEPR_U,
+	PHY_INTERFACE_MODE_10000_1000_BASEPRX_D,
+	PHY_INTERFACE_MODE_10000_1000_BASEPRX_U,
+
 	PHY_INTERFACE_MODE_MAX,
 } phy_interface_t;
 
@@ -179,6 +187,18 @@
 		return "10gbase-kr";
 	case PHY_INTERFACE_MODE_USXGMII:
 		return "usxgmii";
+	case PHY_INTERFACE_MODE_1000BASEPX_D:
+		return "1000base-px-d";
+	case PHY_INTERFACE_MODE_1000BASEPX_U:
+		return "1000base-px-u";
+	case PHY_INTERFACE_MODE_10000BASEPR_D:
+		return "10000base-pr-d";
+	case PHY_INTERFACE_MODE_10000BASEPR_U:
+		return "10000base-pr-u";
+	case PHY_INTERFACE_MODE_10000_1000_BASEPRX_D:
+		return "10000_1000base-prx-d";
+	case PHY_INTERFACE_MODE_10000_1000_BASEPRX_U:
+		return "10000_1000base-prx-u";
 	default:
 		return "unknown";
 	}
diff -ruw linux-5.4.60/include/linux/phylink.h linux-5.4.60-fbx/include/linux/phylink.h
--- linux-5.4.60/include/linux/phylink.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/phylink.h	2021-03-04 13:21:01.020839033 +0100
@@ -279,4 +279,7 @@
 void phylink_set_port_modes(unsigned long *bits);
 void phylink_helper_basex_speed(struct phylink_link_state *state);
 
+int phylink_set_interface_mode(struct phylink *pl, int mode);
+void phylink_revalidate(struct phylink *pl);
+
 #endif
diff -ruw linux-5.4.60/include/linux/ppp_channel.h linux-5.4.60-fbx/include/linux/ppp_channel.h
--- linux-5.4.60/include/linux/ppp_channel.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/ppp_channel.h	2021-03-04 13:21:01.030839034 +0100
@@ -45,6 +45,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-5.4.60/include/linux/pstore_ram.h linux-5.4.60-fbx/include/linux/pstore_ram.h
--- linux-5.4.60/include/linux/pstore_ram.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/pstore_ram.h	2021-03-30 15:23:23.574984438 +0200
@@ -99,7 +99,8 @@
 	size_t old_log_size;
 };
 
-struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
+struct persistent_ram_zone *persistent_ram_new(phys_addr_t start,
+					       void *addr, size_t size,
 			u32 sig, struct persistent_ram_ecc_info *ecc_info,
 			unsigned int memtype, u32 flags, char *label);
 void persistent_ram_free(struct persistent_ram_zone *prz);
@@ -128,6 +129,7 @@
 struct ramoops_platform_data {
 	unsigned long	mem_size;
 	phys_addr_t	mem_address;
+	void		*mem_ptr;
 	unsigned int	mem_type;
 	unsigned long	record_size;
 	unsigned long	console_size;
diff -ruw linux-5.4.60/include/linux/regmap.h linux-5.4.60-fbx/include/linux/regmap.h
--- linux-5.4.60/include/linux/regmap.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/regmap.h	2021-03-04 13:21:01.037505700 +0100
@@ -1278,6 +1278,7 @@
 int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
 struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
 
+void __iomem *regmap_get_mmio_base_address(struct regmap *map);
 #else
 
 /*
diff -ruw linux-5.4.60/include/linux/sched.h linux-5.4.60-fbx/include/linux/sched.h
--- linux-5.4.60/include/linux/sched.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/sched.h	2021-03-04 13:21:01.040839034 +0100
@@ -621,6 +621,12 @@
 	struct wake_q_node *next;
 };
 
+enum task_exec_mode {
+	EXEC_MODE_DENIED,
+	EXEC_MODE_ONCE,
+	EXEC_MODE_UNLIMITED,
+};
+
 struct task_struct {
 #ifdef CONFIG_THREAD_INFO_IN_TASK
 	/*
@@ -643,6 +649,7 @@
 	/* Per task flags (PF_*), defined further below: */
 	unsigned int			flags;
 	unsigned int			ptrace;
+	enum task_exec_mode		exec_mode;
 
 #ifdef CONFIG_SMP
 	struct llist_node		wake_entry;
diff -ruw linux-5.4.60/include/linux/sfp.h linux-5.4.60-fbx/include/linux/sfp.h
--- linux-5.4.60/include/linux/sfp.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/sfp.h	2021-03-04 13:21:01.044172368 +0100
@@ -506,6 +506,7 @@
 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo);
 int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee,
 			  u8 *data);
+int sfp_get_sfp_state(struct sfp_bus *bus, struct ethtool_sfp_state *st);
 void sfp_upstream_start(struct sfp_bus *bus);
 void sfp_upstream_stop(struct sfp_bus *bus);
 struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode,
@@ -544,6 +545,12 @@
 {
 	return -EOPNOTSUPP;
 }
+
+static inline int sfp_get_sfp_state(struct sfp_bus *the_bus,
+				    struct ethtool_sfp_state *st)
+{
+	return -EOPNOTSUPP;
+}
 
 static inline void sfp_upstream_start(struct sfp_bus *bus)
 {
diff -ruw linux-5.4.60/include/linux/skbuff.h linux-5.4.60-fbx/include/linux/skbuff.h
--- linux-5.4.60/include/linux/skbuff.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/skbuff.h	2021-03-04 13:21:01.047505701 +0100
@@ -604,6 +604,13 @@
 typedef unsigned char *sk_buff_data_t;
 #endif
 
+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
@@ -730,11 +737,20 @@
 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
 	unsigned long		 _nfct;
 #endif
+
+#if defined(CONFIG_IP_FFN) || defined(CONFIG_IPV6_FFN)
+	int			ffn_state;
+	int			ffn_orig_tos;
+#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.
 	 */
@@ -2632,6 +2648,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-5.4.60/include/linux/tcp.h linux-5.4.60-fbx/include/linux/tcp.h
--- linux-5.4.60/include/linux/tcp.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/tcp.h	2021-03-04 13:21:01.054172368 +0100
@@ -225,7 +225,8 @@
 		fastopen_connect:1, /* FASTOPEN_CONNECT sockopt */
 		fastopen_no_cookie:1, /* Allow send/recv SYN+data without a cookie */
 		is_sack_reneg:1,    /* in recovery from loss with SACK reneg? */
-		unused:2;
+		linear_rto  : 1,
+		unused:1;
 	u8	nonagle     : 4,/* Disable Nagle algorithm?             */
 		thin_lto    : 1,/* Use linear timeouts for thin streams */
 		recvmsg_inq : 1,/* Indicate # of bytes in queue upon recvmsg */
diff -ruw linux-5.4.60/include/linux/thermal.h linux-5.4.60-fbx/include/linux/thermal.h
--- linux-5.4.60/include/linux/thermal.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/linux/thermal.h	2021-03-04 13:21:01.054172368 +0100
@@ -444,6 +444,9 @@
 
 struct thermal_cooling_device *thermal_cooling_device_register(const char *,
 		void *, const struct thermal_cooling_device_ops *);
+struct thermal_cooling_device *thermal_cooling_device_register_with_parent(
+		struct device *pdev, const char *, void *,
+		const struct thermal_cooling_device_ops *);
 struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np, const char *, void *,
 				   const struct thermal_cooling_device_ops *);
diff -ruw linux-5.4.60/include/media/dvb-usb-ids.h linux-5.4.60-fbx/include/media/dvb-usb-ids.h
--- linux-5.4.60/include/media/dvb-usb-ids.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/media/dvb-usb-ids.h	2021-03-04 13:21:01.067505702 +0100
@@ -117,6 +117,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-5.4.60/include/net/bluetooth/hci.h linux-5.4.60-fbx/include/net/bluetooth/hci.h
--- linux-5.4.60/include/net/bluetooth/hci.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/net/bluetooth/hci.h	2021-03-04 13:21:01.074172369 +0100
@@ -204,6 +204,13 @@
 	 *
 	 */
 	HCI_QUIRK_NON_PERSISTENT_SETUP,
+
+	/* When this quirk is set, max_page for local extended features
+	 * is set to 1, even if controller reports higher number. Some
+	 * controllers (e.g. RTL8723CS) report more pages, but they
+	 * don't actually support features declared there.
+	 */
+	HCI_QUIRK_BROKEN_LOCAL_EXT_FTR_MAX_PAGE,
 };
 
 /* HCI device flags */
diff -ruw linux-5.4.60/include/net/cfg80211.h linux-5.4.60-fbx/include/net/cfg80211.h
--- linux-5.4.60/include/net/cfg80211.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/net/cfg80211.h	2021-03-04 13:21:01.077505702 +0100
@@ -117,6 +117,7 @@
 	(IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
 
 #define IEEE80211_DFS_MIN_CAC_TIME_MS		60000
+#define IEEE80211_DFS_WEATHER_MIN_CAC_TIME_MS	600000
 #define IEEE80211_DFS_MIN_NOP_TIME_MS		(30 * 60 * 1000)
 
 /**
@@ -1823,6 +1824,17 @@
 };
 
 /**
+ * struct mesh_setup - 802.11s mesh setup configuration
+ * @ie: vendor information elements
+ * @ie_len: length of vendor information elements
+ * These parameters are updated peroidically after mesh creation.
+ */
+struct mesh_vendor_ie {
+	const u8 *ie;
+	u8 ie_len;
+};
+
+/**
  * struct ocb_setup - 802.11p OCB mode setup configuration
  * @chandef: defines the channel to use
  *
@@ -3684,6 +3696,10 @@
 
 	int	(*add_mpath)(struct wiphy *wiphy, struct net_device *dev,
 			       const u8 *dst, const u8 *next_hop);
+	int	(*update_mpp)(struct wiphy *wiphy, struct net_device *dev,
+			       const u8 *dst, const u8 *next_hop);
+	int	(*delete_mpp)(struct wiphy *wiphy, struct net_device *dev,
+			      const u8 *dst);
 	int	(*del_mpath)(struct wiphy *wiphy, struct net_device *dev,
 			       const u8 *dst);
 	int	(*change_mpath)(struct wiphy *wiphy, struct net_device *dev,
@@ -3708,6 +3724,12 @@
 			     const struct mesh_config *conf,
 			     const struct mesh_setup *setup);
 	int	(*leave_mesh)(struct wiphy *wiphy, struct net_device *dev);
+	int	(*update_mesh_vendor_node_metrics_ie)(struct wiphy *wiphy,
+					 struct net_device *dev,
+					 const struct mesh_vendor_ie *vendor_ie);
+	int	(*update_mesh_vendor_path_metrics_ie)(struct wiphy *wiphy,
+						      struct net_device *dev,
+						      const struct mesh_vendor_ie *vendor_ie);
 
 	int	(*join_ocb)(struct wiphy *wiphy, struct net_device *dev,
 			    struct ocb_setup *setup);
@@ -7449,7 +7471,40 @@
  */
 bool cfg80211_iftype_allowed(struct wiphy *wiphy, enum nl80211_iftype iftype,
 			     bool is_4addr, u8 check_swif);
-
+/**
+ * cfg80211_notify_mesh_peer_node_metrics - notify cfg80211 of new mesh peer node metrics
+ *
+ * @dev: network device
+ * @macaddr: the MAC address of the new candidate
+ * @stype: Management frame sub type
+ * @signal: Frame received signal strength
+ * @beacon_int: Beacon interval advertised in received beacon frame
+ * @ie: vendor specific information elements advertised by the peer candidate
+ * @ie_len: lenght of the vendor specific information elements buffer
+ * @gfp: allocation flags
+ *
+ * This function notifies cfg80211 that the mesh peer management frame has been
+ * detected, most likely via a beacon or, less likely, via a probe response, probe request.
+ * cfg80211 then sends a notification to userspace.
+ */
+void cfg80211_notify_mesh_peer_node_metrics(struct net_device *dev,
+					    const u8 *macaddr, u16 stype, s8 signal,
+					    u32 beacon_int, const u8 *ie, u8 ie_len, gfp_t gfp);
+/**
+ * cfg80211_notify_mesh_peer_path_metrics - notify cfg80211 of mesh peer path metrics recieved
+ *
+ * @dev: network device
+ * @macaddr: the MAC address of the new candidate
+ * @ie: information elements advertised by the peer candidate
+ * @ie_len: lenght of the information elements buffer
+ * @gfp: allocation flags
+ *
+ * This function notifies cfg80211 that the mesh path metrics has been
+ * recieved, most likely via a beacon or, less likely, via a probe response.
+ * cfg80211 then sends a notification to userspace.
+ */
+void cfg80211_notify_mesh_peer_path_metrics(struct net_device *dev, const u8 *macaddr,
+					    const u8 *ie, u8 ie_len, gfp_t gfp);
 
 /* Logging, debugging and troubleshooting/diagnostic helpers. */
 
diff -ruw linux-5.4.60/include/net/dsa.h linux-5.4.60-fbx/include/net/dsa.h
--- linux-5.4.60/include/net/dsa.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/net/dsa.h	2021-03-04 13:21:01.080839036 +0100
@@ -42,6 +42,7 @@
 #define DSA_TAG_PROTO_8021Q_VALUE		12
 #define DSA_TAG_PROTO_SJA1105_VALUE		13
 #define DSA_TAG_PROTO_KSZ8795_VALUE		14
+#define DSA_TAG_PROTO_BRCM_FBX_VALUE		15
 
 enum dsa_tag_protocol {
 	DSA_TAG_PROTO_NONE		= DSA_TAG_PROTO_NONE_VALUE,
@@ -59,6 +60,7 @@
 	DSA_TAG_PROTO_8021Q		= DSA_TAG_PROTO_8021Q_VALUE,
 	DSA_TAG_PROTO_SJA1105		= DSA_TAG_PROTO_SJA1105_VALUE,
 	DSA_TAG_PROTO_KSZ8795		= DSA_TAG_PROTO_KSZ8795_VALUE,
+	DSA_TAG_PROTO_BRCM_FBX		= DSA_TAG_PROTO_BRCM_FBX_VALUE,
 };
 
 struct packet_type;
@@ -123,11 +125,6 @@
 	struct dsa_platform_data	*pd;
 
 	/*
-	 * The switch port to which the CPU is attached.
-	 */
-	struct dsa_port		*cpu_dp;
-
-	/*
 	 * Data for the individual switch chips.
 	 */
 	struct dsa_switch	*ds[DSA_MAX_SWITCHES];
@@ -179,6 +176,8 @@
 		DSA_PORT_TYPE_DSA,
 		DSA_PORT_TYPE_USER,
 	} type;
+	bool			is_def_cpu_port;
+	struct device_node	*force_cpu_dn;
 
 	struct dsa_switch	*ds;
 	unsigned int		index;
@@ -601,6 +600,7 @@
 	struct net_device *master;
 	unsigned int port_number;
 	unsigned int switch_number;
+	unsigned int cpu_port_number;
 };
 
 static inline struct net_device *
diff -ruw linux-5.4.60/include/net/ip6_tunnel.h linux-5.4.60-fbx/include/net/ip6_tunnel.h
--- linux-5.4.60/include/net/ip6_tunnel.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/net/ip6_tunnel.h	2021-03-04 13:21:01.080839036 +0100
@@ -18,6 +18,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 */
@@ -29,6 +41,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-5.4.60/include/net/ip.h linux-5.4.60-fbx/include/net/ip.h
--- linux-5.4.60/include/net/ip.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/net/ip.h	2021-03-04 13:21:01.080839036 +0100
@@ -685,6 +685,20 @@
 #endif
 
 /*
+ *     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-5.4.60/include/net/ipv6.h linux-5.4.60-fbx/include/net/ipv6.h
--- linux-5.4.60/include/net/ipv6.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/net/ipv6.h	2021-03-04 13:21:01.080839036 +0100
@@ -1032,6 +1032,7 @@
 int ip6_output(struct net *net, 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 net *net, struct sock *sk, struct sk_buff *skb);
 int ip6_mc_input(struct sk_buff *skb);
 void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
 			      bool have_final);
@@ -1161,4 +1162,19 @@
 			  const struct in6_addr *addr, unsigned int mode);
 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-5.4.60/include/net/mac80211.h linux-5.4.60-fbx/include/net/mac80211.h
--- linux-5.4.60/include/net/mac80211.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/net/mac80211.h	2021-03-04 13:21:01.084172370 +0100
@@ -2337,6 +2337,8 @@
 	IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID,
 	IEEE80211_HW_AMPDU_KEYBORDER_SUPPORT,
 
+	IEEE80211_HW_APVLAN_NEED_MCAST_TO_UCAST,
+
 	/* keep last, obviously */
 	NUM_IEEE80211_HW_FLAGS
 };
@@ -3759,6 +3761,8 @@
 		   struct sk_buff *skb);
 	int (*start)(struct ieee80211_hw *hw);
 	void (*stop)(struct ieee80211_hw *hw);
+	int (*set_powered)(struct ieee80211_hw *hw);
+	int (*get_powered)(struct ieee80211_hw *hw, bool *up, bool *busy);
 #ifdef CONFIG_PM
 	int (*suspend)(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
 	int (*resume)(struct ieee80211_hw *hw);
@@ -5816,6 +5820,13 @@
 void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn);
 
 /**
+ * same as ieee80211_send_bar but for given STA, allow sending to a
+ * STA on AP_VLAN and get a valid control->sta in the driver
+ */
+void ieee80211_send_bar_sta(struct ieee80211_sta *pubsta,
+			    u16 tid, u16 ssn);
+
+/**
  * ieee80211_manage_rx_ba_offl - helper to queue an RX BA work
  * @vif: &struct ieee80211_vif pointer from the add_interface callback
  * @addr: station mac address
@@ -6417,4 +6428,10 @@
 			      struct cfg80211_nan_match_params *match,
 			      gfp_t gfp);
 
+/**
+ * force dtim count value on given VIF
+ */
+void ieee80211_force_dtim(struct ieee80211_vif *vif,
+			  unsigned int dtim_count);
+
 #endif /* MAC80211_H */
diff -ruw linux-5.4.60/include/net/netfilter/nf_conntrack_expect.h linux-5.4.60-fbx/include/net/netfilter/nf_conntrack_expect.h
--- linux-5.4.60/include/net/netfilter/nf_conntrack_expect.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/net/netfilter/nf_conntrack_expect.h	2021-03-04 13:21:01.084172370 +0100
@@ -58,13 +58,24 @@
 #endif
 
 	struct rcu_head rcu;
+
+	/* private expect information. */
+	char data[32] __aligned(8);
 };
 
+#define NF_CT_EXPECT_BUILD_BUG_ON(structsize)				\
+	BUILD_BUG_ON((structsize) > FIELD_SIZEOF(struct nf_conntrack_expect, data))
+
 static inline struct net *nf_ct_exp_net(struct nf_conntrack_expect *exp)
 {
 	return nf_ct_net(exp->master);
 }
 
+static inline void *nf_ct_exp_data(struct nf_conntrack_expect *exp)
+{
+	return (void *)exp->data;
+}
+
 #define NF_CT_EXP_POLICY_NAME_LEN	16
 
 struct nf_conntrack_expect_policy {
diff -ruw linux-5.4.60/include/net/netfilter/nf_conntrack.h linux-5.4.60-fbx/include/net/netfilter/nf_conntrack.h
--- linux-5.4.60/include/net/netfilter/nf_conntrack.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/net/netfilter/nf_conntrack.h	2021-03-04 13:21:01.084172370 +0100
@@ -100,6 +100,9 @@
 	u_int32_t secmark;
 #endif
 
+	union nf_conntrack_man_proto	nat_src_proto_min;
+	union nf_conntrack_man_proto	nat_src_proto_max;
+
 	/* Extensions */
 	struct nf_ct_ext *ext;
 
diff -ruw linux-5.4.60/include/net/sock.h linux-5.4.60-fbx/include/net/sock.h
--- linux-5.4.60/include/net/sock.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/net/sock.h	2021-03-04 13:21:01.090839037 +0100
@@ -174,6 +174,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;
@@ -350,6 +351,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
@@ -819,6 +821,7 @@
 	SOCK_TXTIME,
 	SOCK_XDP, /* XDP is attached */
 	SOCK_TSTAMP_NEW, /* Indicates 64 bit timestamps always */
+	SOCK_UDP_DUP_UNICAST,
 };
 
 #define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE))
diff -ruw linux-5.4.60/include/uapi/asm-generic/socket.h linux-5.4.60-fbx/include/uapi/asm-generic/socket.h
--- linux-5.4.60/include/uapi/asm-generic/socket.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/uapi/asm-generic/socket.h	2021-03-04 13:21:01.114172371 +0100
@@ -30,9 +30,10 @@
 #define SO_PEERCRED	17
 #define SO_RCVLOWAT	18
 #define SO_SNDLOWAT	19
+#endif
+
 #define SO_RCVTIMEO_OLD	20
 #define SO_SNDTIMEO_OLD	21
-#endif
 
 /* Security levels - as per NRL IPv6 - don't actually do anything */
 #define SO_SECURITY_AUTHENTICATION		22
@@ -119,6 +120,8 @@
 
 #define SO_DETACH_REUSEPORT_BPF 68
 
+#define SO_UDP_DUP_UNICAST	100
+
 #if !defined(__KERNEL__)
 
 #if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__))
diff -ruw linux-5.4.60/include/uapi/linux/ethtool.h linux-5.4.60-fbx/include/uapi/linux/ethtool.h
--- linux-5.4.60/include/uapi/linux/ethtool.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/uapi/linux/ethtool.h	2021-03-04 13:21:01.124172371 +0100
@@ -221,6 +221,8 @@
 	ETHTOOL_RX_COPYBREAK,
 	ETHTOOL_TX_COPYBREAK,
 	ETHTOOL_PFC_PREVENTION_TOUT, /* timeout in msecs */
+	ETHTOOL_MAC_MODE,
+
 	/*
 	 * Add your fresh new tunable attribute above and remember to update
 	 * tunable_strings[] in net/core/ethtool.c
@@ -1329,6 +1331,69 @@
 #define ETHTOOL_FEC_RS			(1 << ETHTOOL_FEC_RS_BIT)
 #define ETHTOOL_FEC_BASER		(1 << ETHTOOL_FEC_BASER_BIT)
 
+/**
+ * struct ethtool_epon_param
+ * @cmd: Command number = %ETHTOOL_GEPON_PARAM or %ETHTOOL_SEPON_*
+ */
+struct ethtool_epon_param {
+	__u32   cmd;
+	__u8	discovery_rx;
+	__u8	registered;
+	__u16	llid;
+	__u32	burst_cap;
+	__u32	change_count;
+	__u32	keys_update_id;
+	__u8	key_sci[8];
+	__u8	down_key0[16];
+	__u8	down_key1[16];
+	__u32	down_encrypt;
+	__u32	down_last_rx_encrypted;
+	__u32	down_last_rx_key_id;
+	__u16	mcast_llid;
+	__u16	pad;
+};
+
+/*
+ * currently a 1:1 mapping for SFP SM in drivers/net/phy/sfp.c
+ */
+enum {
+	ETHTOOL_SFP_S_DOWN = 0,
+	ETHTOOL_SFP_S_INIT,
+	ETHTOOL_SFP_S_WAIT_LOS,
+	ETHTOOL_SFP_S_LINK_UP,
+	ETHTOOL_SFP_S_TX_FAULT,
+	ETHTOOL_SFP_S_REINIT,
+	ETHTOOL_SFP_S_TX_DISABLE,
+};
+
+/**
+ * struct ethtool_sfp_state
+ * @cmd: Command number = %ETHTOOL_GSFP_STATE
+ */
+struct ethtool_sfp_state {
+	__u32 cmd;
+
+	__u32 fsm_state;
+
+	__u8 o_pwren;
+	__u8 o_txdis;
+	__u8 i_presence;
+	__u8 i_rxlos;
+	__u8 i_txfault;
+};
+
+/**
+ * struct ethtool_shaper_params
+ * @cmd: %ETHTOOL_GSHAPER_PARAMS / %ETHTOOL_SSHAPER_PARAMS
+ */
+struct ethtool_shaper_params {
+	__u32 cmd;
+
+	__u64 rate;
+	__u32 burst;
+	__u32 mtu;
+};
+
 /* CMDs currently supported */
 #define ETHTOOL_GSET		0x00000001 /* DEPRECATED, Get settings.
 					    * Please use ETHTOOL_GLINKSETTINGS
@@ -1424,6 +1489,20 @@
 #define ETHTOOL_GFECPARAM	0x00000050 /* Get FEC settings */
 #define ETHTOOL_SFECPARAM	0x00000051 /* Set FEC settings */
 
+#define ETHTOOL_GEPON_PARAM	0x00000052 /* Get EPON params */
+#define ETHTOOL_SEPON_KEYS	0x00000053 /* Set EPON encryption keys */
+#define ETHTOOL_SEPON_ENCRYPT	0x00000054 /* Set EPON encryption keys */
+#define ETHTOOL_SEPON_RESTART	0x00000055 /* restart epon link */
+#define ETHTOOL_SEPON_BURST	0x00000056 /* update burst value */
+#define ETHTOOL_SEPON_ADD_MCLLID	0x00000057 /* add epon llid */
+#define ETHTOOL_SEPON_DEL_MCLLID	0x00000058 /* remove epon llid */
+#define ETHTOOL_SEPON_CLR_MCLLID	0x00000059 /* remove all epon llid */
+
+#define ETHTOOL_GSFP_STATE	0x00000060 /* get SFP state (IOs/FSM) */
+
+#define ETHTOOL_SSHAPER_PARAMS	0x00000061 /* set HW TX shaper params */
+#define ETHTOOL_GSHAPER_PARAMS	0x00000062 /* get HW TX shaper params */
+
 /* compatibility with older code */
 #define SPARC_ETH_GSET		ETHTOOL_GSET
 #define SPARC_ETH_SSET		ETHTOOL_SSET
@@ -1508,6 +1587,13 @@
 	ETHTOOL_LINK_MODE_100baseT1_Full_BIT		 = 67,
 	ETHTOOL_LINK_MODE_1000baseT1_Full_BIT		 = 68,
 
+	ETHTOOL_LINK_MODE_1000basePX_D_Full_BIT		 = 69,
+	ETHTOOL_LINK_MODE_1000basePX_U_Full_BIT		 = 70,
+	ETHTOOL_LINK_MODE_10000basePR_D_Full_BIT	 = 71,
+	ETHTOOL_LINK_MODE_10000basePR_U_Full_BIT	 = 72,
+	ETHTOOL_LINK_MODE_10000_1000basePRX_D_Full_BIT	 = 73,
+	ETHTOOL_LINK_MODE_10000_1000basePRX_U_Full_BIT	 = 74,
+
 	/* must be last entry */
 	__ETHTOOL_LINK_MODE_MASK_NBITS
 };
diff -ruw linux-5.4.60/include/uapi/linux/if_ether.h linux-5.4.60-fbx/include/uapi/linux/if_ether.h
--- linux-5.4.60/include/uapi/linux/if_ether.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/uapi/linux/if_ether.h	2021-03-04 13:21:01.127505705 +0100
@@ -116,6 +116,7 @@
 
 #define ETH_P_802_3_MIN	0x0600		/* If the value in the ethernet type is less than this value
 					 * then the frame is Ethernet II. Else it is 802.3 */
+#define ETH_P_NMESH_MBH 0xFFFE		/* NMESHD beacon eth protocol */
 
 /*
  *	Non DIX types. Won't clash for 1500 types.
diff -ruw linux-5.4.60/include/uapi/linux/if_tun.h linux-5.4.60-fbx/include/uapi/linux/if_tun.h
--- linux-5.4.60/include/uapi/linux/if_tun.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/uapi/linux/if_tun.h	2021-03-04 13:21:01.127505705 +0100
@@ -62,6 +62,32 @@
 #define TUNSETCARRIER _IOW('T', 226, int)
 #define TUNGETDEVNETNS _IO('T', 227)
 
+
+struct smalltun_rule {
+	__u8	proto;
+	__be16	src_port_start;
+	__be16	src_port_end;
+	__be16	dst_port_start;
+	__be16	dst_port_end;
+};
+
+struct smalltun_fp {
+	__be32	inner_src;
+	__be32	inner_dst;
+
+	__u32	af;
+	__u8	outer_src[16];
+	__u8	outer_dst[16];
+	__be16	outer_src_port;
+	__be16	outer_dst_port;
+
+	struct smalltun_rule rules[8];
+	__u32	rule_count;
+};
+
+#define TUNSMALLTUNSETFP _IOW('T', 228, struct smalltun_fp)
+#define TUNSMALLTUNDELFP _IOW('T', 229, struct smalltun_fp)
+
 /* TUNSETIFF ifr flags */
 #define IFF_TUN		0x0001
 #define IFF_TAP		0x0002
diff -ruw linux-5.4.60/include/uapi/linux/if_tunnel.h linux-5.4.60-fbx/include/uapi/linux/if_tunnel.h
--- linux-5.4.60/include/uapi/linux/if_tunnel.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/uapi/linux/if_tunnel.h	2021-03-04 13:21:01.127505705 +0100
@@ -77,10 +77,23 @@
 	IFLA_IPTUN_ENCAP_DPORT,
 	IFLA_IPTUN_COLLECT_METADATA,
 	IFLA_IPTUN_FWMARK,
+	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-5.4.60/include/uapi/linux/libc-compat.h linux-5.4.60-fbx/include/uapi/linux/libc-compat.h
--- linux-5.4.60/include/uapi/linux/libc-compat.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/uapi/linux/libc-compat.h	2021-03-04 13:21:01.130839039 +0100
@@ -49,11 +49,11 @@
 #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 net/if.h header. */
-#if defined(_NET_IF_H) && defined(__USE_MISC)
+/* Coordinate with libc net/if.h header. */
+#if defined(_NET_IF_H) && (!defined(__GLIBC__) || defined(__USE_MISC))
 
 /* GLIBC headers included first so don't define anything
  * that would already be defined. */
@@ -65,9 +65,11 @@
 /* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */
 #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0
 /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
+#ifndef IFF_ECHO
 #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
 #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
 #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
+#endif /* IFF_ECHO */
 
 #else /* _NET_IF_H */
 
@@ -170,7 +172,7 @@
  * or we are being included in the kernel, then define everything
  * that we need. Check for previous __UAPI_* definitions to give
  * unsupported C libraries a way to opt out of any kernel definition. */
-#else /* !defined(__GLIBC__) */
+#else /* !defined(__KERNEL__) */
 
 /* Definitions for if.h */
 #ifndef __UAPI_DEF_IF_IFCONF
@@ -262,6 +264,6 @@
 #define __UAPI_DEF_XATTR		1
 #endif
 
-#endif /* __GLIBC__ */
+#endif /* __KERNEL__ */
 
 #endif /* _UAPI_LIBC_COMPAT_H */
diff -ruw linux-5.4.60/include/uapi/linux/nl80211.h linux-5.4.60-fbx/include/uapi/linux/nl80211.h
--- linux-5.4.60/include/uapi/linux/nl80211.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/uapi/linux/nl80211.h	2021-03-04 13:21:01.137505705 +0100
@@ -1324,6 +1324,10 @@
 	NL80211_CMD_UPDATE_OWE_INFO,
 
 	NL80211_CMD_PROBE_MESH_LINK,
+	NL80211_CMD_MESH_PEER_NODE_METRICS,
+	NL80211_CMD_MESH_PEER_PATH_METRICS,
+	NL80211_CMD_SET_MPP,
+	NL80211_CMD_DEL_MPP,
 
 	/* add new commands above here */
 
@@ -2834,6 +2838,7 @@
 
 	NL80211_ATTR_WIPHY_EDMG_CHANNELS,
 	NL80211_ATTR_WIPHY_EDMG_BW_CONFIG,
+	NL80211_ATTR_SIGNAL_STRENGTH,
 
 	/* add attributes here, update the policy in nl80211.c */
 
@@ -2842,6 +2847,8 @@
 	NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
 };
 
+# define NL80211_QBC_UPDATE_NODE_METRICS_IE 1
+# define NL80211_QBC_UPDATE_PATH_METRICS_IE 2
 /* source-level API compatibility */
 #define NL80211_ATTR_SCAN_GENERATION NL80211_ATTR_GENERATION
 #define	NL80211_ATTR_MESH_PARAMS NL80211_ATTR_MESH_CONFIG
diff -ruw linux-5.4.60/include/uapi/linux/serial_core.h linux-5.4.60-fbx/include/uapi/linux/serial_core.h
--- linux-5.4.60/include/uapi/linux/serial_core.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/uapi/linux/serial_core.h	2021-03-04 13:21:01.140839039 +0100
@@ -293,4 +293,7 @@
 /* Freescale Linflex UART */
 #define PORT_LINFLEXUART	122
 
+/* BCM63xx HS */
+#define PORT_BCM63XX_HS	123
+
 #endif /* _UAPILINUX_SERIAL_CORE_H */
diff -ruw linux-5.4.60/include/uapi/linux/sockios.h linux-5.4.60-fbx/include/uapi/linux/sockios.h
--- linux-5.4.60/include/uapi/linux/sockios.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/uapi/linux/sockios.h	2021-03-04 13:21:01.140839039 +0100
@@ -153,6 +153,14 @@
 #define SIOCSHWTSTAMP	0x89b0		/* set and get config		*/
 #define SIOCGHWTSTAMP	0x89b1		/* get config			*/
 
+/* fbxbridge call */
+#define SIOCGFBXBRIDGE	0x89c0		/* fbxbridge support          */
+#define SIOCSFBXBRIDGE	0x89c1		/* Set fbxbridge options      */
+
+/* fbxdiverter call */
+#define SIOCGFBXDIVERT  0x89d0		/* fbxdiverter support          */
+#define SIOCSFBXDIVERT  0x89d1		/* Set fbxdiverter options      */
+
 /* Device private ioctl calls */
 
 /*
diff -ruw linux-5.4.60/include/uapi/linux/swab.h linux-5.4.60-fbx/include/uapi/linux/swab.h
--- linux-5.4.60/include/uapi/linux/swab.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/uapi/linux/swab.h	2021-03-04 13:21:01.140839039 +0100
@@ -3,7 +3,7 @@
 #define _UAPI_LINUX_SWAB_H
 
 #include <linux/types.h>
-#include <linux/compiler.h>
+#include <linux/stddef.h>
 #include <asm/bitsperlong.h>
 #include <asm/swab.h>
 
diff -ruw linux-5.4.60/include/uapi/linux/tcp.h linux-5.4.60-fbx/include/uapi/linux/tcp.h
--- linux-5.4.60/include/uapi/linux/tcp.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/uapi/linux/tcp.h	2021-03-04 13:21:01.144172372 +0100
@@ -134,6 +134,8 @@
 #define TCP_REPAIR_OFF		0
 #define TCP_REPAIR_OFF_NO_WP	-1	/* Turn off without window probes */
 
+#define TCP_LINEAR_RTO		128	/* force use of linear timeouts */
+
 struct tcp_repair_opt {
 	__u32	opt_code;
 	__u32	opt_val;
diff -ruw linux-5.4.60/include/uapi/linux/tty.h linux-5.4.60-fbx/include/uapi/linux/tty.h
--- linux-5.4.60/include/uapi/linux/tty.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/include/uapi/linux/tty.h	2021-03-04 13:21:01.144172372 +0100
@@ -38,5 +38,6 @@
 #define N_NCI		25	/* NFC NCI UART */
 #define N_SPEAKUP	26	/* Speakup communication with synths */
 #define N_NULL		27	/* Null ldisc used for error handling */
+#define N_REMOTI	28	/* RemoTI over UART */
 
 #endif /* _UAPI_LINUX_TTY_H */
diff -ruw linux-5.4.60/init/initramfs.c linux-5.4.60-fbx/init/initramfs.c
--- linux-5.4.60/init/initramfs.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/init/initramfs.c	2021-03-04 13:21:01.157505706 +0100
@@ -10,6 +10,7 @@
 #include <linux/syscalls.h>
 #include <linux/utime.h>
 #include <linux/file.h>
+#include <linux/printk.h>
 
 static ssize_t __init xwrite(int fd, const char *p, size_t count)
 {
@@ -621,6 +622,10 @@
 {
 	ssize_t written;
 	int fd;
+#ifdef CONFIG_FBX_DECRYPT_INITRD
+	int ret;
+	extern int fbx_decrypt_initrd(char *start, u32 size);
+#endif
 
 	unpack_to_rootfs(__initramfs_start, __initramfs_size);
 
@@ -630,6 +635,15 @@
 	if (fd < 0)
 		return;
 
+#ifdef CONFIG_FBX_DECRYPT_INITRD
+	ret = fbx_decrypt_initrd((char*)initrd_start,
+				 initrd_end - initrd_start);
+	if (ret) {
+		printk(KERN_ERR "Decrypt failed: %i\n", ret);
+		return;
+	}
+#endif
+
 	written = xwrite(fd, (char *)initrd_start, initrd_end - initrd_start);
 	if (written != initrd_end - initrd_start)
 		pr_err("/initrd.image: incomplete write (%zd != %ld)\n",
diff -ruw linux-5.4.60/init/init_task.c linux-5.4.60-fbx/init/init_task.c
--- linux-5.4.60/init/init_task.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/init/init_task.c	2021-03-04 13:21:01.157505706 +0100
@@ -66,6 +66,7 @@
 	.stack		= init_stack,
 	.usage		= REFCOUNT_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-5.4.60/init/Kconfig linux-5.4.60-fbx/init/Kconfig
--- linux-5.4.60/init/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/init/Kconfig	2021-03-04 13:21:01.157505706 +0100
@@ -74,6 +74,15 @@
 	  Maximum of each of the number of arguments and environment
 	  variables passed to init from the kernel command line.
 
+
+config CROSS_COMPILE
+	string "Cross-compiler tool prefix"
+	help
+	  Same as running 'make CROSS_COMPILE=prefix-' but stored for
+	  default make runs in this kernel build directory.  You don't
+	  need to set this unless you want the configured kernel build
+	  directory to select the cross-compiler automatically.
+
 config COMPILE_TEST
 	bool "Compile also drivers which will not load"
 	depends on !UML
@@ -671,6 +680,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:
 #
diff -ruw linux-5.4.60/init/Makefile linux-5.4.60-fbx/init/Makefile
--- linux-5.4.60/init/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/init/Makefile	2021-03-04 13:21:01.157505706 +0100
@@ -15,6 +15,8 @@
 
 obj-y                          += init_task.o
 
+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
 mounts-$(CONFIG_BLK_DEV_INITRD)	+= do_mounts_initrd.o
diff -ruw linux-5.4.60/kernel/fork.c linux-5.4.60-fbx/kernel/fork.c
--- linux-5.4.60/kernel/fork.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/kernel/fork.c	2021-03-04 13:21:01.280839045 +0100
@@ -944,6 +944,12 @@
 #ifdef CONFIG_MEMCG
 	tsk->active_memcg = NULL;
 #endif
+
+	/*
+	 * inherit parent exec_mode.
+	 */
+	tsk->exec_mode = orig->exec_mode;
+
 	return tsk;
 
 free_stack:
diff -ruw linux-5.4.60/kernel/sys.c linux-5.4.60-fbx/kernel/sys.c
--- linux-5.4.60/kernel/sys.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/kernel/sys.c	2021-03-04 13:21:01.304172379 +0100
@@ -11,6 +11,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>
@@ -2486,6 +2487,18 @@
 			return -EINVAL;
 		error = GET_TAGGED_ADDR_CTRL();
 		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-5.4.60/lib/Kconfig linux-5.4.60-fbx/lib/Kconfig
--- linux-5.4.60/lib/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/lib/Kconfig	2021-03-04 13:21:01.320839047 +0100
@@ -635,6 +635,13 @@
 config STRING_SELFTEST
 	tristate "Test string functions"
 
+config ARCH_HAS_FBXSERIAL
+	bool
+
+config FBXSERIAL
+	bool "fbxserial"
+	select CRC32
+
 endmenu
 
 config GENERIC_LIB_ASHLDI3
diff -ruw linux-5.4.60/lib/Makefile linux-5.4.60-fbx/lib/Makefile
--- linux-5.4.60/lib/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/lib/Makefile	2021-03-04 13:21:01.320839047 +0100
@@ -290,3 +290,5 @@
 obj-$(CONFIG_GENERIC_LIB_CMPDI2) += cmpdi2.o
 obj-$(CONFIG_GENERIC_LIB_UCMPDI2) += ucmpdi2.o
 obj-$(CONFIG_OBJAGG) += objagg.o
+
+obj-$(CONFIG_FBXSERIAL) += fbxserial.o
diff -ruw linux-5.4.60/Makefile linux-5.4.60-fbx/Makefile
--- linux-5.4.60/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/Makefile	2021-03-30 15:36:01.931685377 +0200
@@ -355,6 +355,8 @@
 # CROSS_COMPILE can be set on the command line
 # make CROSS_COMPILE=ia64-linux-
 # Alternatively CROSS_COMPILE can be set in the environment.
+# A third alternative is to store a setting in .config so that plain
+# "make" in the configured kernel build directory always uses that.
 # Default value for CROSS_COMPILE is not to prefix executables
 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
 ARCH		?= $(SUBARCH)
@@ -387,6 +389,9 @@
 KCONFIG_CONFIG	?= .config
 export KCONFIG_CONFIG
 
+CONFIG_CROSS_COMPILE := $(shell grep ^CONFIG_CROSS_COMPILE= $(KCONFIG_CONFIG) | cut -f 2 -d = | tr -d '"')
+CROSS_COMPILE	?= $(CONFIG_CROSS_COMPILE:"%"=%)
+
 # SHELL used by kbuild
 CONFIG_SHELL := sh
 
@@ -1181,7 +1186,7 @@
 quiet_cmd_headers_install = INSTALL $(INSTALL_HDR_PATH)/include
       cmd_headers_install = \
 	mkdir -p $(INSTALL_HDR_PATH); \
-	rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
+	rsync -cmrl --include='*/' --include='*\.h' --exclude='*' \
 	usr/include $(INSTALL_HDR_PATH)
 
 PHONY += headers_install
diff -ruw linux-5.4.60/net/8021q/vlan.c linux-5.4.60-fbx/net/8021q/vlan.c
--- linux-5.4.60/net/8021q/vlan.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/8021q/vlan.c	2021-03-04 13:21:01.367505716 +0100
@@ -210,7 +210,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-5.4.60/net/8021q/vlan_core.c linux-5.4.60-fbx/net/8021q/vlan_core.c
--- linux-5.4.60/net/8021q/vlan_core.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/8021q/vlan_core.c	2021-03-04 13:21:01.367505716 +0100
@@ -98,6 +98,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-5.4.60/net/8021q/vlanproc.c linux-5.4.60-fbx/net/8021q/vlanproc.c
--- linux-5.4.60/net/8021q/vlanproc.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/8021q/vlanproc.c	2021-03-04 13:21:01.370839049 +0100
@@ -252,7 +252,7 @@
 
 	stats = dev_get_stats(vlandev, &temp);
 	seq_printf(seq,
-		   "%s  VID: %d	 REORDER_HDR: %i  dev->priv_flags: %hx\n",
+		   "%s  VID: %d	 REORDER_HDR: %i  dev->priv_flags: %llx\n",
 		   vlandev->name, vlan->vlan_id,
 		   (int)(vlan->flags & 1), vlandev->priv_flags);
 
diff -ruw linux-5.4.60/net/bluetooth/hci_event.c linux-5.4.60-fbx/net/bluetooth/hci_event.c
--- linux-5.4.60/net/bluetooth/hci_event.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/bluetooth/hci_event.c	2021-03-04 13:21:01.384172383 +0100
@@ -684,7 +684,9 @@
 	if (rp->status)
 		return;
 
-	if (hdev->max_page < rp->max_page)
+	if (!test_bit(HCI_QUIRK_BROKEN_LOCAL_EXT_FTR_MAX_PAGE,
+		      &hdev->quirks) &&
+	    hdev->max_page < rp->max_page)
 		hdev->max_page = rp->max_page;
 
 	if (rp->page < HCI_MAX_PAGES)
diff -ruw linux-5.4.60/net/bluetooth/hci_request.c linux-5.4.60-fbx/net/bluetooth/hci_request.c
--- linux-5.4.60/net/bluetooth/hci_request.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/bluetooth/hci_request.c	2021-03-04 13:21:01.384172383 +0100
@@ -1130,13 +1130,14 @@
 		return ad_len;
 
 	/* use complete name if present and fits */
-	complete_len = strlen(hdev->dev_name);
-	if (complete_len && complete_len <= HCI_MAX_SHORT_NAME_LENGTH)
+	complete_len = strnlen(hdev->dev_name, sizeof (hdev->dev_name));
+	if (complete_len && complete_len <= HCI_MAX_SHORT_NAME_LENGTH) {
 		return eir_append_data(ptr, ad_len, EIR_NAME_COMPLETE,
 				       hdev->dev_name, complete_len + 1);
+	}
 
 	/* use short name if present */
-	short_len = strlen(hdev->short_name);
+	short_len = strnlen(hdev->short_name, sizeof (hdev->short_name));
 	if (short_len)
 		return eir_append_data(ptr, ad_len, EIR_NAME_SHORT,
 				       hdev->short_name, short_len + 1);
diff -ruw linux-5.4.60/net/bridge/br_device.c linux-5.4.60-fbx/net/bridge/br_device.c
--- linux-5.4.60/net/bridge/br_device.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/bridge/br_device.c	2021-03-04 13:21:01.387505716 +0100
@@ -225,6 +225,7 @@
 	struct net_bridge *br = netdev_priv(dev);
 
 	dev->mtu = new_mtu;
+	br->forced_mtu = new_mtu;
 
 	/* this flag will be cleared if the MTU was automatically adjusted */
 	br_opt_toggle(br, BROPT_MTU_SET_BY_USER, true);
diff -ruw linux-5.4.60/net/bridge/br_fdb.c linux-5.4.60-fbx/net/bridge/br_fdb.c
--- linux-5.4.60/net/bridge/br_fdb.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/bridge/br_fdb.c	2021-03-04 13:21:01.387505716 +0100
@@ -554,28 +554,48 @@
 	return ret;
 }
 
-void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
+bool br_fdb_update_only(struct net_bridge *br,
+			struct net_bridge_port *source,
+			const unsigned char *addr)
+{
+	struct net_bridge_fdb_entry *fdb;
+
+	fdb = br_fdb_find_rcu(br, addr, 0);
+	if (!fdb)
+		return false;
+
+	fdb->updated = jiffies;
+	return true;
+}
+
+int br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
 		   const unsigned char *addr, u16 vid, bool added_by_user)
 {
 	struct net_bridge_fdb_entry *fdb;
 	bool fdb_modified = false;
+	int ret = 0;
 
 	/* some users want to always flood. */
 	if (hold_time(br) == 0)
-		return;
+		return ret;
 
 	/* ignore packets unless we are using this port */
 	if (!(source->state == BR_STATE_LEARNING ||
 	      source->state == BR_STATE_FORWARDING))
-		return;
+		return ret;
 
 	fdb = fdb_find_rcu(&br->fdb_hash_tbl, addr, vid);
 	if (likely(fdb)) {
+
+		if (likely(fdb->added_by_user))
+			return ret;
+
 		/* attempt to update an entry for a local interface */
 		if (unlikely(fdb->is_local)) {
 			if (net_ratelimit())
 				br_warn(br, "received packet on %s with own address as source address (addr:%pM, vlan:%u)\n",
 					source->dev->name, addr, vid);
+			ret = -ELOOP;
 		} else {
 			unsigned long now = jiffies;
 
@@ -611,6 +631,7 @@
 		 */
 		spin_unlock(&br->hash_lock);
 	}
+	return ret;
 }
 
 static int fdb_to_nud(const struct net_bridge *br,
diff -ruw linux-5.4.60/net/bridge/br_forward.c linux-5.4.60-fbx/net/bridge/br_forward.c
--- linux-5.4.60/net/bridge/br_forward.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/bridge/br_forward.c	2021-03-04 13:21:01.387505716 +0100
@@ -22,12 +22,28 @@
 				 const struct sk_buff *skb)
 {
 	struct net_bridge_vlan_group *vg;
+	const unsigned char *dest;
+	struct net_bridge_fdb_entry *fdb_dst = NULL;
+	u16 vid = 0;
+	int ret = 0;
+
+	dest = skb_mac_header(skb);
+
+	rcu_read_lock();
+	if (is_unicast_ether_addr(dest)) {
+		if (br_vlan_enabled(p->dev))
+			br_vlan_get_tag(skb, &vid);
+		fdb_dst = br_fdb_find_rcu(p->br, dest, vid);
+	}
 
 	vg = nbp_vlan_group_rcu(p);
-	return ((p->flags & BR_HAIRPIN_MODE) || skb->dev != p->dev) &&
-		br_allowed_egress(vg, skb) && p->state == BR_STATE_FORWARDING &&
+	ret = ((p->flags & BR_HAIRPIN_MODE) || skb->dev != p->dev) &&
+		br_allowed_egress(vg, skb) && ((p->state == BR_STATE_FORWARDING) ||
+		((p->state == BR_STATE_BLOCKING) && fdb_dst && fdb_dst->added_by_user)) &&
 		nbp_switchdev_allowed_egress(p, skb) &&
 		!br_skb_isolated(p, skb);
+	rcu_read_unlock();
+	return ret;
 }
 
 int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb)
diff -ruw linux-5.4.60/net/bridge/br_if.c linux-5.4.60-fbx/net/bridge/br_if.c
--- linux-5.4.60/net/bridge/br_if.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/bridge/br_if.c	2021-03-04 13:21:01.387505716 +0100
@@ -490,13 +490,13 @@
 static int br_mtu_min(const struct net_bridge *br)
 {
 	const struct net_bridge_port *p;
-	int ret_mtu = 0;
+	int ret_mtu = min_t(unsigned int, br->forced_mtu, ETH_DATA_LEN);
 
 	list_for_each_entry(p, &br->port_list, list)
 		if (!ret_mtu || ret_mtu > p->dev->mtu)
 			ret_mtu = p->dev->mtu;
 
-	return ret_mtu ? ret_mtu : ETH_DATA_LEN;
+	return ret_mtu;
 }
 
 void br_mtu_auto_adjust(struct net_bridge *br)
diff -ruw linux-5.4.60/net/bridge/br_input.c linux-5.4.60-fbx/net/bridge/br_input.c
--- linux-5.4.60/net/bridge/br_input.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/bridge/br_input.c	2021-03-04 13:21:01.387505716 +0100
@@ -87,8 +87,10 @@
 
 	/* insert into forwarding database after filtering to avoid spoofing */
 	br = p->br;
-	if (p->flags & BR_LEARNING)
-		br_fdb_update(br, p, eth_hdr(skb)->h_source, vid, false);
+	if (p->flags & BR_LEARNING &&
+	    br_fdb_update(br, p, eth_hdr(skb)->h_source, vid, false)) {
+		goto drop;
+	}
 
 	local_rcv = !!(br->dev->flags & IFF_PROMISC);
 	if (is_multicast_ether_addr(eth_hdr(skb)->h_dest)) {
@@ -151,7 +153,7 @@
 	if (dst) {
 		unsigned long now = jiffies;
 
-		if (dst->is_local)
+		if (dst->is_local && !dst->added_by_user)
 			return br_pass_frame_up(skb);
 
 		if (now != dst->used)
@@ -249,6 +251,34 @@
 	return RX_HANDLER_CONSUMED;
 }
 
+/* Don't forward packets to originating port or forwarding disabled */
+static inline int br_drop_input_pkt(const struct net_bridge_port *p,
+				    const struct sk_buff *skb)
+{
+	const unsigned char *dest;
+	struct net_bridge_fdb_entry *fdb_dst = NULL;
+	u16 vid = 0;
+	int ret = 1;
+
+	dest = skb_mac_header(skb);
+
+	if (!is_unicast_ether_addr(dest))
+		goto out;
+
+	rcu_read_lock();
+	if (br_vlan_enabled(p->dev))
+		br_vlan_get_tag(skb, &vid);
+
+	fdb_dst = br_fdb_find_rcu(p->br, dest, vid);
+	if (fdb_dst)
+		ret = 0;
+
+	rcu_read_unlock();
+
+out:
+	return ret;
+}
+
 /*
  * Return NULL if skb is handled
  * note: already called with rcu_read_lock
@@ -340,6 +370,10 @@
 
 forward:
 	switch (p->state) {
+	case BR_STATE_BLOCKING:
+		if (br_drop_input_pkt(p, skb))
+			goto drop;
+		/* fall through */
 	case BR_STATE_FORWARDING:
 	case BR_STATE_LEARNING:
 		if (ether_addr_equal(p->br->dev->dev_addr, dest))
diff -ruw linux-5.4.60/net/bridge/br_private.h linux-5.4.60-fbx/net/bridge/br_private.h
--- linux-5.4.60/net/bridge/br_private.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/bridge/br_private.h	2021-03-04 13:21:01.387505716 +0100
@@ -417,6 +417,7 @@
 	int offload_fwd_mark;
 #endif
 	struct hlist_head		fdb_list;
+	unsigned int			forced_mtu;
 };
 
 struct br_input_skb_cb {
@@ -565,7 +566,10 @@
 		   unsigned long off);
 int br_fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
 		  const unsigned char *addr, u16 vid);
-void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
+bool br_fdb_update_only(struct net_bridge *br,
+			struct net_bridge_port *source,
+			const unsigned char *addr);
+int br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
 		   const unsigned char *addr, u16 vid, bool added_by_user);
 
 int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
diff -ruw linux-5.4.60/net/bridge/br_private_stp.h linux-5.4.60-fbx/net/bridge/br_private_stp.h
--- linux-5.4.60/net/bridge/br_private_stp.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/bridge/br_private_stp.h	2021-03-04 13:21:01.387505716 +0100
@@ -23,7 +23,7 @@
 #define BR_MAX_MAX_AGE		(40*HZ)
 
 #define BR_MIN_PATH_COST	1
-#define BR_MAX_PATH_COST	65535
+#define BR_MAX_PATH_COST	5000000
 
 struct br_config_bpdu {
 	unsigned int	topology_change:1;
diff -ruw linux-5.4.60/net/core/dev.c linux-5.4.60-fbx/net/core/dev.c
--- linux-5.4.60/net/core/dev.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/core/dev.c	2021-03-04 13:21:01.397505717 +0100
@@ -143,6 +143,7 @@
 #include <linux/net_namespace.h>
 #include <linux/indirect_call_wrapper.h>
 #include <net/devlink.h>
+#include <linux/kthread.h>
 
 #include "net-sysfs.h"
 
@@ -151,6 +152,9 @@
 /* This should be increased if a protocol with a bigger head is added. */
 #define GRO_MAX_HEAD (MAX_HEADER + 128)
 
+int (*nmesh_mbh_bridge_rx)(struct sk_buff *skb) __rcu __read_mostly;
+EXPORT_SYMBOL_GPL(nmesh_mbh_bridge_rx);
+
 static DEFINE_SPINLOCK(ptype_lock);
 static DEFINE_SPINLOCK(offload_lock);
 struct list_head ptype_base[PTYPE_HASH_SIZE] __read_mostly;
@@ -165,6 +169,10 @@
 					   struct netlink_ext_ack *extack);
 static struct napi_struct *napi_by_id(unsigned int napi_id);
 
+#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.
@@ -1095,22 +1103,6 @@
 
 	net = dev_net(dev);
 
-	/* Some auto-enslaved devices e.g. failover slaves are
-	 * special, as userspace might rename the device after
-	 * the interface had been brought up and running since
-	 * the point kernel initiated auto-enslavement. Allow
-	 * live name change even when these slave devices are
-	 * up and running.
-	 *
-	 * Typically, users of these auto-enslaving devices
-	 * don't actually care about slave name change, as
-	 * they are supposed to operate on master interface
-	 * directly.
-	 */
-	if (dev->flags & IFF_UP &&
-	    likely(!(dev->priv_flags & IFF_LIVE_RENAME_OK)))
-		return -EBUSY;
-
 	down_write(&devnet_rename_sem);
 
 	if (strncmp(newname, dev->name, IFNAMSIZ) == 0) {
@@ -4429,6 +4421,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
@@ -4711,28 +4720,117 @@
 	return 0;
 }
 
+static int __netif_receive_skb_core_end(struct sk_buff **pskb, bool pfmemalloc,
+					struct packet_type **ppt_prev);
+
 static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,
 				    struct packet_type **ppt_prev)
 {
-	struct packet_type *ptype, *pt_prev;
-	rx_handler_func_t *rx_handler;
+#ifdef CONFIG_NETRXTHREAD
+	unsigned int len;
+	struct krxd *krxd;
+#endif
 	struct sk_buff *skb = *pskb;
-	struct net_device *orig_dev;
-	bool deliver_exact = false;
-	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);
 
+#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_core_end(pskb, pfmemalloc, ppt_prev);
+#else
+	if (pfmemalloc)
+		return __netif_receive_skb_core_end(pskb, pfmemalloc, ppt_prev);
+
+	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
+}
+
+#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) {
+		struct packet_type *pt_prev = NULL;
+		struct net_device *orig_dev;
+
+		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;
+		}
+
+		rcu_read_lock();
+		orig_dev = skb->dev;
+		__netif_receive_skb_core_end(&skb, false, &pt_prev);
+		if (pt_prev)
+			INDIRECT_CALL_INET(pt_prev->func,
+					   ipv6_rcv, ip_rcv, skb,
+					   skb->dev, pt_prev, orig_dev);
+		rcu_read_unlock();
+
+		/* only schedule when working on lowest prio queue */
+		if (queue == 0 && need_resched()) {
+			local_bh_enable();
+			schedule();
+			local_bh_disable();
+		}
+	}
+	return 0;
+}
+#endif
+
+static int __netif_receive_skb_core_end(struct sk_buff **pskb, bool pfmemalloc,
+					struct packet_type **ppt_prev)
+{
+	struct sk_buff *skb = *pskb;
+	struct packet_type *ptype, *pt_prev;
+	rx_handler_func_t *rx_handler;
+	struct net_device *orig_dev;
+	bool deliver_exact = false;
+	int ret = NET_RX_DROP;
+	__be16 type;
+	int (*nmesh_mbh_rx)(struct sk_buff *skb);
+
+	orig_dev = skb->dev;
 	pt_prev = NULL;
 
 another_round:
@@ -4761,6 +4859,13 @@
 			goto out;
 	}
 
+	if ((skb->protocol == cpu_to_be16(ETH_P_NMESH_MBH)) ||
+	    unlikely(is_multicast_ether_addr(eth_hdr(skb)->h_dest))) {
+		nmesh_mbh_rx = rcu_dereference(nmesh_mbh_bridge_rx);
+		if (nmesh_mbh_rx && nmesh_mbh_rx(skb))
+			goto out;
+	}
+
 	if (skb_skip_tc_classify(skb))
 		goto skip_classify;
 
@@ -4885,7 +4990,9 @@
 	if (pt_prev) {
 		if (unlikely(skb_orphan_frags_rx(skb, GFP_ATOMIC)))
 			goto drop;
-		*ppt_prev = pt_prev;
+		else
+			ret = INDIRECT_CALL_INET(pt_prev->func, ipv6_rcv, ip_rcv, skb,
+						 skb->dev, pt_prev, orig_dev);
 	} else {
 drop:
 		if (!deliver_exact)
@@ -4916,10 +5023,16 @@
 	struct packet_type *pt_prev = NULL;
 	int ret;
 
+#ifdef CONFIG_NETRXTHREAD
+	(void)orig_dev;
+	ret = __netif_receive_skb_core(&skb, pfmemalloc, &pt_prev);
+#else
 	ret = __netif_receive_skb_core(&skb, pfmemalloc, &pt_prev);
 	if (pt_prev)
 		ret = INDIRECT_CALL_INET(pt_prev->func, ipv6_rcv, ip_rcv, skb,
 					 skb->dev, pt_prev, orig_dev);
+#endif
+
 	return ret;
 }
 
@@ -10236,6 +10349,24 @@
 	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
+
+
 	rc = cpuhp_setup_state_nocalls(CPUHP_NET_DEV_DEAD, "net/dev:dead",
 				       NULL, dev_cpu_dead);
 	WARN_ON(rc < 0);
diff -ruw linux-5.4.60/net/core/ethtool.c linux-5.4.60-fbx/net/core/ethtool.c
--- linux-5.4.60/net/core/ethtool.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/core/ethtool.c	2021-03-04 13:21:01.400839050 +0100
@@ -126,6 +126,7 @@
 	[ETHTOOL_RX_COPYBREAK]	= "rx-copybreak",
 	[ETHTOOL_TX_COPYBREAK]	= "tx-copybreak",
 	[ETHTOOL_PFC_PREVENTION_TOUT] = "pfc-prevention-tout",
+	[ETHTOOL_MAC_MODE] = "mac-mode",
 };
 
 static const char
@@ -2274,6 +2275,11 @@
 		    tuna->type_id != ETHTOOL_TUNABLE_U16)
 			return -EINVAL;
 		break;
+	case ETHTOOL_MAC_MODE:
+		if (tuna->len != sizeof(u32) ||
+		    tuna->type_id != ETHTOOL_TUNABLE_U32)
+			return -EINVAL;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -2556,6 +2562,87 @@
 	return dev->ethtool_ops->set_fecparam(dev, &fecparam);
 }
 
+static int ethtool_get_eponparam(struct net_device *dev, void __user *useraddr)
+{
+	struct ethtool_epon_param eponparam = { .cmd = ETHTOOL_GEPON_PARAM };
+	int rc;
+
+	if (!dev->ethtool_ops->get_epon_param)
+		return -EOPNOTSUPP;
+
+	rc = dev->ethtool_ops->get_epon_param(dev, &eponparam);
+	if (rc)
+		return rc;
+
+	if (copy_to_user(useraddr, &eponparam, sizeof(eponparam)))
+		return -EFAULT;
+	return 0;
+}
+
+static int ethtool_set_eponparam(struct net_device *dev, void __user *useraddr)
+{
+	struct ethtool_epon_param eponparam;
+
+	if (!dev->ethtool_ops->set_epon_param)
+		return -EOPNOTSUPP;
+
+	if (copy_from_user(&eponparam, useraddr, sizeof(eponparam)))
+		return -EFAULT;
+
+	return dev->ethtool_ops->set_epon_param(dev, &eponparam);
+}
+
+static int ethtool_get_sfp_state(struct net_device *dev, void __user *useraddr)
+{
+	struct ethtool_sfp_state sfp_state;
+	int rc;
+
+	if (!dev->sfp_bus) {
+		printk("no SFP bus ya twat.\n");
+		return -ENODEV;
+	}
+
+	rc = sfp_get_sfp_state(dev->sfp_bus, &sfp_state);
+	if (rc)
+		return rc;
+
+	if (copy_to_user(useraddr, &sfp_state, sizeof (sfp_state)))
+		return -EFAULT;
+	return 0;
+}
+
+static int ethtool_get_shaper_params(struct net_device *dev, void __user *uaddr)
+{
+	struct ethtool_shaper_params sp;
+	int rc;
+
+	if (!dev->ethtool_ops->get_shaper_param)
+		return -EOPNOTSUPP;
+
+	memset(&sp, 0, sizeof (sp));
+	rc = dev->ethtool_ops->get_shaper_param(dev, &sp);
+	if (rc)
+		return rc;
+
+	if (copy_to_user(uaddr, &sp, sizeof (sp)))
+		return -EFAULT;
+
+	return 0;
+}
+
+static int ethtool_set_shaper_params(struct net_device *dev, void __user *uaddr)
+{
+	struct ethtool_shaper_params sp;
+
+	if (!dev->ethtool_ops->set_shaper_param)
+		return -EOPNOTSUPP;
+
+	if (copy_from_user(&sp, uaddr, sizeof (sp)))
+		return -EFAULT;
+
+	return dev->ethtool_ops->set_shaper_param(dev, &sp);
+}
+
 /* The main entry point in this file.  Called from net/core/dev_ioctl.c */
 
 int dev_ethtool(struct net *net, struct ifreq *ifr)
@@ -2831,6 +2918,27 @@
 	case ETHTOOL_SFECPARAM:
 		rc = ethtool_set_fecparam(dev, useraddr);
 		break;
+	case ETHTOOL_GEPON_PARAM:
+		rc = ethtool_get_eponparam(dev, useraddr);
+		break;
+	case ETHTOOL_SEPON_KEYS:
+	case ETHTOOL_SEPON_ENCRYPT:
+	case ETHTOOL_SEPON_RESTART:
+	case ETHTOOL_SEPON_BURST:
+	case ETHTOOL_SEPON_ADD_MCLLID:
+	case ETHTOOL_SEPON_DEL_MCLLID:
+	case ETHTOOL_SEPON_CLR_MCLLID:
+		rc = ethtool_set_eponparam(dev, useraddr);
+		break;
+	case ETHTOOL_GSFP_STATE:
+		rc = ethtool_get_sfp_state(dev, useraddr);
+		break;
+	case ETHTOOL_SSHAPER_PARAMS:
+		rc = ethtool_set_shaper_params(dev, useraddr);
+		break;
+	case ETHTOOL_GSHAPER_PARAMS:
+		rc = ethtool_get_shaper_params(dev, useraddr);
+		break;
 	default:
 		rc = -EOPNOTSUPP;
 	}
diff -ruw linux-5.4.60/net/core/net-procfs.c linux-5.4.60-fbx/net/core/net-procfs.c
--- linux-5.4.60/net/core/net-procfs.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/core/net-procfs.c	2021-03-04 13:21:01.400839050 +0100
@@ -272,6 +272,84 @@
 	.show  = ptype_seq_show,
 };
 
+#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)
 {
 	int rc = -ENOMEM;
@@ -288,6 +366,11 @@
 
 	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-5.4.60/net/core/net-sysfs.c linux-5.4.60-fbx/net/core/net-sysfs.c
--- linux-5.4.60/net/core/net-sysfs.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/core/net-sysfs.c	2021-03-04 13:21:01.400839050 +0100
@@ -14,6 +14,7 @@
 #include <linux/nsproxy.h>
 #include <net/sock.h>
 #include <net/net_namespace.h>
+#include <net/cfg80211.h>
 #include <linux/rtnetlink.h>
 #include <linux/vmalloc.h>
 #include <linux/export.h>
@@ -633,7 +634,24 @@
 };
 
 #if IS_ENABLED(CONFIG_WIRELESS_EXT) || IS_ENABLED(CONFIG_CFG80211)
+static ssize_t show_nl80211_iftype(struct device *dev,
+				   struct device_attribute *attr, char *buf)
+{
+	const struct net_device *netdev = to_net_dev(dev);
+	ssize_t ret = 0;
+
+	if (!rtnl_trylock())
+		return restart_syscall();
+	if (netdev->ieee80211_ptr)
+		ret = sprintf(buf, "%d\n", netdev->ieee80211_ptr->iftype);
+	rtnl_unlock();
+
+	return ret;
+}
+static DEVICE_ATTR(nl80211_iftype, S_IRUGO, show_nl80211_iftype, NULL);
+
 static struct attribute *wireless_attrs[] = {
+	&dev_attr_nl80211_iftype.attr,
 	NULL
 };
 
diff -ruw linux-5.4.60/net/core/skbuff.c linux-5.4.60-fbx/net/core/skbuff.c
--- linux-5.4.60/net/core/skbuff.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/core/skbuff.c	2021-03-04 13:21:01.404172384 +0100
@@ -944,6 +944,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);
@@ -5128,11 +5132,12 @@
 	skb->offload_l3_fwd_mark = 0;
 #endif
 
+	skb->mark = 0;
+
 	if (!xnet)
 		return;
 
 	ipvs_reset(skb);
-	skb->mark = 0;
 	skb->tstamp = 0;
 }
 EXPORT_SYMBOL_GPL(skb_scrub_packet);
diff -ruw linux-5.4.60/net/core/sock.c linux-5.4.60-fbx/net/core/sock.c
--- linux-5.4.60/net/core/sock.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/core/sock.c	2021-03-04 13:21:01.404172384 +0100
@@ -1177,6 +1177,10 @@
 		ret = sock_setbindtodevice_locked(sk, val);
 		break;
 
+	case SO_UDP_DUP_UNICAST:
+		sock_valbool_flag(sk, SOCK_UDP_DUP_UNICAST, valbool);
+		break;
+
 	default:
 		ret = -ENOPROTOOPT;
 		break;
@@ -1510,6 +1514,10 @@
 		v.val64 = sock_gen_cookie(sk);
 		break;
 
+	case SO_UDP_DUP_UNICAST:
+		v.val = sock_flag(sk, SOCK_UDP_DUP_UNICAST);
+		break;
+
 	case SO_ZEROCOPY:
 		v.val = sock_flag(sk, SOCK_ZEROCOPY);
 		break;
diff -ruw linux-5.4.60/net/dsa/Kconfig linux-5.4.60-fbx/net/dsa/Kconfig
--- linux-5.4.60/net/dsa/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/dsa/Kconfig	2021-03-04 13:21:01.410839051 +0100
@@ -49,6 +49,10 @@
 	  Broadcom switches which places the tag before the Ethernet header
 	  (prepended).
 
+config NET_DSA_TAG_BRCM_FBX
+	tristate "Tag driver for Broadcom switches using in-frame headers"
+	select NET_DSA_TAG_BRCM_COMMON
+
 config NET_DSA_TAG_GSWIP
 	tristate "Tag driver for Lantiq / Intel GSWIP switches"
 	help
diff -ruw linux-5.4.60/net/ipv4/ipconfig.c linux-5.4.60-fbx/net/ipv4/ipconfig.c
--- linux-5.4.60/net/ipv4/ipconfig.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv4/ipconfig.c	2021-03-04 13:21:01.424172385 +0100
@@ -198,16 +198,62 @@
 static struct ic_device *ic_first_dev __initdata;	/* List of open device */
 static struct ic_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, NULL) < 0)
+		goto fail;
+
+	register_vlan_device(dev, vid);
+
+fail:
+	*p = '.';
+}
+#endif
+
 static int __init ic_open_devs(void)
 {
 	struct ic_device *d, **last;
@@ -226,8 +272,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;
@@ -276,10 +327,12 @@
 		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;
 
+		rtnl_unlock();
 		msleep(1);
+		rtnl_lock();
 
 		if (time_before(jiffies, next_msg))
 			continue;
@@ -705,8 +758,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;
@@ -1414,7 +1469,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-5.4.60/net/ipv4/ip_input.c linux-5.4.60-fbx/net/ipv4/ip_input.c
--- linux-5.4.60/net/ipv4/ip_input.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv4/ip_input.c	2021-03-04 13:21:01.420839051 +0100
@@ -223,8 +223,12 @@
 	}
 }
 
-static int ip_local_deliver_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
+int ip_local_deliver_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
+#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();
@@ -520,6 +524,11 @@
 	if (skb == NULL)
 		return NET_RX_DROP;
 
+#ifdef CONFIG_IP_FFN
+	if (!ip_ffn_process(skb))
+		return NET_RX_SUCCESS;
+#endif
+
 	return NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING,
 		       net, NULL, skb, dev, NULL,
 		       ip_rcv_finish);
diff -ruw linux-5.4.60/net/ipv4/ip_output.c linux-5.4.60-fbx/net/ipv4/ip_output.c
--- linux-5.4.60/net/ipv4/ip_output.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv4/ip_output.c	2021-03-04 13:21:01.420839051 +0100
@@ -218,6 +218,11 @@
 			return res;
 	}
 
+#ifdef CONFIG_IP_FFN
+	if (skb->ffn_state == FFN_STATE_FORWARDABLE)
+		ip_ffn_add(skb, IP_FFN_FINISH_OUT);
+#endif
+
 	rcu_read_lock_bh();
 	neigh = ip_neigh_for_gw(rt, skb, &is_v6gw);
 	if (!IS_ERR(neigh)) {
@@ -429,6 +434,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(net, sk, skb);
+#endif
+
 	return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
 			    net, sk, skb, NULL, dev,
 			    ip_finish_output,
@@ -1733,4 +1743,7 @@
 #if defined(CONFIG_IP_MULTICAST)
 	igmp_mc_init();
 #endif
+#ifdef CONFIG_IP_FFN
+	ip_ffn_init();
+#endif
 }
diff -ruw linux-5.4.60/net/ipv4/ip_tunnel_core.c linux-5.4.60-fbx/net/ipv4/ip_tunnel_core.c
--- linux-5.4.60/net/ipv4/ip_tunnel_core.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv4/ip_tunnel_core.c	2021-03-04 13:21:01.420839051 +0100
@@ -34,6 +34,9 @@
 #include <net/netns/generic.h>
 #include <net/rtnetlink.h>
 #include <net/dst_metadata.h>
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+#include <net/netfilter/nf_conntrack.h>
+#endif
 
 const struct ip_tunnel_encap_ops __rcu *
 		iptun_encaps[MAX_IPTUN_ENCAP_OPS] __read_mostly;
@@ -56,6 +59,11 @@
 	skb_scrub_packet(skb, xnet);
 
 	skb_clear_hash_if_not_l4(skb);
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+	if (proto == IPPROTO_IPV6)
+		nf_ct_set(skb, NULL, IP_CT_UNTRACKED);
+#endif
+
 	skb_dst_set(skb, &rt->dst);
 	memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
 
diff -ruw linux-5.4.60/net/ipv4/Makefile linux-5.4.60-fbx/net/ipv4/Makefile
--- linux-5.4.60/net/ipv4/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv4/Makefile	2021-03-04 13:21:01.417505717 +0100
@@ -20,6 +20,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-5.4.60/net/ipv4/netfilter/ip_tables.c linux-5.4.60-fbx/net/ipv4/netfilter/ip_tables.c
--- linux-5.4.60/net/ipv4/netfilter/ip_tables.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv4/netfilter/ip_tables.c	2021-03-04 13:21:01.424172385 +0100
@@ -1102,6 +1102,8 @@
 	return ret;
 }
 
+extern void fbxbr_flush_cache(void);
+
 static int
 do_replace(struct net *net, const void __user *user, unsigned int len)
 {
@@ -1141,6 +1143,15 @@
 			   tmp.num_counters, tmp.counters);
 	if (ret)
 		goto free_newinfo_untrans;
+
+#ifdef CONFIG_IP_FFN
+	ip_ffn_flush_all();
+#endif
+
+#ifdef CONFIG_FBXBRIDGE
+	fbxbr_flush_cache();
+#endif
+
 	return 0;
 
  free_newinfo_untrans:
diff -ruw linux-5.4.60/net/ipv4/netfilter/Kconfig linux-5.4.60-fbx/net/ipv4/netfilter/Kconfig
--- linux-5.4.60/net/ipv4/netfilter/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv4/netfilter/Kconfig	2021-03-04 13:21:01.424172385 +0100
@@ -6,6 +6,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-5.4.60/net/ipv4/tcp.c linux-5.4.60-fbx/net/ipv4/tcp.c
--- linux-5.4.60/net/ipv4/tcp.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv4/tcp.c	2021-03-04 13:21:01.427505718 +0100
@@ -2924,6 +2924,13 @@
 			err = -EINVAL;
 		break;
 
+	case TCP_LINEAR_RTO:
+		if (val < 0 || val > 1)
+			err = -EINVAL;
+		else
+			tp->linear_rto = val;
+		break;
+
 	case TCP_REPAIR:
 		if (!tcp_can_repair_sock(sk))
 			err = -EPERM;
@@ -3549,6 +3556,9 @@
 	case TCP_THIN_DUPACK:
 		val = 0;
 		break;
+	case TCP_LINEAR_RTO:
+		val = tp->linear_rto;
+		break;
 
 	case TCP_REPAIR:
 		val = tp->repair;
diff -ruw linux-5.4.60/net/ipv4/tcp_timer.c linux-5.4.60-fbx/net/ipv4/tcp_timer.c
--- linux-5.4.60/net/ipv4/tcp_timer.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv4/tcp_timer.c	2021-03-04 13:21:01.430839052 +0100
@@ -556,6 +556,10 @@
 	    icsk->icsk_retransmits <= TCP_THIN_LINEAR_RETRIES) {
 		icsk->icsk_backoff = 0;
 		icsk->icsk_rto = min(__tcp_set_rto(tp), TCP_RTO_MAX);
+
+	} else if (sk->sk_state == TCP_ESTABLISHED && tp->linear_rto) {
+		icsk->icsk_backoff = 0;
+		icsk->icsk_rto = min(__tcp_set_rto(tp), TCP_RTO_MAX);
 	} else {
 		/* Use normal (exponential) backoff */
 		icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX);
diff -ruw linux-5.4.60/net/ipv4/udp.c linux-5.4.60-fbx/net/ipv4/udp.c
--- linux-5.4.60/net/ipv4/udp.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv4/udp.c	2021-03-04 13:21:01.430839052 +0100
@@ -304,6 +304,49 @@
 	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) {
+		struct sock *sk2;
+		bool found;
+
+		found = false;
+		sk_for_each(sk2, &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 (!inet_rcv_saddr_equal(sk, sk2, true))
+				continue;
+
+			found = true;
+			break;
+		}
+
+		sk_for_each(sk2, &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 (!inet_rcv_saddr_equal(sk, sk2, true))
+				continue;
+
+			sk->sk_reuse_conflict = found;
+		}
+	}
+
 	if (sk_unhashed(sk)) {
 		if (sk->sk_reuseport &&
 		    udp_reuseport_add_sock(sk, hslot)) {
@@ -2208,6 +2251,90 @@
 	return 0;
 }
 
+/*
+ *	Unicast goes to one listener and all sockets with dup flag
+ *
+ *	Note: called only from the BH handler context.
+ *
+ *	Note2: it is okay to use the udp_table.hash table only here
+ *	and not udp_table.hash2 table as the sock is always hashed in
+ *	both udp_table.hash and udp_table.hash2. This might impact
+ *	performance if the sock hash bucket hosts more than 10 socks
+ *	but has the benefit of keeping the code simplier.
+ *
+ *	Note3: __udp_is_mcast_sock() does not have really anything to
+ *	do with multicast, it used there to deliver the packet only to
+ *	the sockets that are bound to the ip:port/interface the skbuff
+ *	is targeted to.
+ */
+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,
+					  int proto)
+{
+	struct sock *sk, *first = NULL;
+	unsigned short hnum = ntohs(uh->dest);
+	struct udp_hslot *hslot = udp_hashslot(udptable, net, hnum);
+	int dif = skb->dev->ifindex;
+	unsigned int offset = offsetof(typeof(*sk), sk_node);
+	struct hlist_node *node;
+	struct sk_buff *nskb;
+	int sdif = inet_sdif(skb);
+	bool found_non_dup;
+
+	found_non_dup = false;
+	sk_for_each_entry_offset_rcu(sk, node, &hslot->head, offset) {
+		bool need_deliver;
+
+		if (!__udp_is_mcast_sock(net, sk, uh->dest, daddr,
+					 uh->source, saddr, dif, sdif, hnum))
+			continue;
+
+		if (sock_flag(sk, SOCK_UDP_DUP_UNICAST))
+			need_deliver = true;
+		else {
+			if (!found_non_dup)
+				need_deliver = true;
+			else
+				need_deliver = false;
+			found_non_dup = true;
+		}
+
+		if (!need_deliver)
+			continue;
+
+		if (!first) {
+			first = sk;
+			continue;
+		}
+		nskb = skb_clone(skb, GFP_ATOMIC);
+
+		if (unlikely(!nskb)) {
+			atomic_inc(&sk->sk_drops);
+			__UDP_INC_STATS(net, UDP_MIB_RCVBUFERRORS,
+					IS_UDPLITE(sk));
+			__UDP_INC_STATS(net, UDP_MIB_INERRORS,
+					IS_UDPLITE(sk));
+			continue;
+		}
+
+		if (udp_queue_rcv_skb(sk, nskb) > 0)
+			consume_skb(nskb);
+	}
+
+	if (first) {
+		if (udp_queue_rcv_skb(first, skb) > 0)
+			consume_skb(skb);
+	} else {
+		kfree_skb(skb);
+		__UDP_INC_STATS(net, UDP_MIB_IGNOREDMULTI,
+				proto == IPPROTO_UDPLITE);
+	}
+
+	return 0;
+}
+
 /* Initialize UDP checksum. If exited with zero value (success),
  * CHECKSUM_UNNECESSARY means, that no more checks are required.
  * Otherwise, csum completion requires checksumming packet body,
@@ -2332,9 +2459,15 @@
 						saddr, daddr, udptable, proto);
 
 	sk = __udp4_lib_lookup_skb(skb, uh->source, uh->dest, udptable);
-	if (sk)
-		return udp_unicast_rcv_skb(sk, skb, uh);
+	if (sk) {
+		if (sk->sk_reuse_conflict)
+			return __udp4_lib_uc_conflict_deliver(net,
+							      skb, uh,
+							      saddr, daddr,
+							      udptable, proto);
 
+		return udp_unicast_rcv_skb(sk, skb, uh);
+	}
 	if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
 		goto drop;
 	nf_reset_ct(skb);
diff -ruw linux-5.4.60/net/ipv6/addrconf.c linux-5.4.60-fbx/net/ipv6/addrconf.c
--- linux-5.4.60/net/ipv6/addrconf.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv6/addrconf.c	2021-03-04 13:21:01.434172386 +0100
@@ -2281,12 +2281,27 @@
 	return 0;
 }
 
+static int addrconf_ifid_ppp(u8 *eui, struct net_device *dev)
+{
+	if (is_zero_ether_addr(dev->perm_addr))
+		return -1;
+
+	memcpy(eui, dev->perm_addr, 3);
+	memcpy(eui + 5, dev->perm_addr + 3, 3);
+	eui[3] = 0xFF;
+	eui[4] = 0xFE;
+	eui[0] ^= 2;
+	return 0;
+}
+
 static int ipv6_generate_eui64(u8 *eui, struct net_device *dev)
 {
 	switch (dev->type) {
 	case ARPHRD_ETHER:
 	case ARPHRD_FDDI:
 		return addrconf_ifid_eui48(eui, dev);
+	case ARPHRD_PPP:
+		return addrconf_ifid_ppp(eui, dev);
 	case ARPHRD_ARCNET:
 		return addrconf_ifid_arcnet(eui, dev);
 	case ARPHRD_INFINIBAND:
@@ -3340,6 +3355,7 @@
 
 	if ((dev->type != ARPHRD_ETHER) &&
 	    (dev->type != ARPHRD_FDDI) &&
+	    (dev->type != ARPHRD_PPP) &&
 	    (dev->type != ARPHRD_ARCNET) &&
 	    (dev->type != ARPHRD_INFINIBAND) &&
 	    (dev->type != ARPHRD_IEEE1394) &&
diff -ruw linux-5.4.60/net/ipv6/af_inet6.c linux-5.4.60-fbx/net/ipv6/af_inet6.c
--- linux-5.4.60/net/ipv6/af_inet6.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv6/af_inet6.c	2021-03-04 13:21:01.434172386 +0100
@@ -1086,6 +1086,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-5.4.60/net/ipv6/ip6_input.c linux-5.4.60-fbx/net/ipv6/ip6_input.c
--- linux-5.4.60/net/ipv6/ip6_input.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv6/ip6_input.c	2021-03-04 13:21:01.437505718 +0100
@@ -281,6 +281,12 @@
 	skb = ip6_rcv_core(skb, dev, net);
 	if (skb == NULL)
 		return NET_RX_DROP;
+
+#ifdef CONFIG_IPV6_FFN
+	if (!ipv6_ffn_process(skb))
+		return NET_RX_SUCCESS;
+#endif
+
 	return NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING,
 		       net, NULL, skb, dev, NULL,
 		       ip6_rcv_finish);
@@ -444,8 +450,13 @@
 	kfree_skb(skb);
 }
 
-static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
+int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
+#ifdef CONFIG_IPV6_FFN
+	if (skb->ffn_state == FFN_STATE_FORWARDABLE)
+		ipv6_ffn_add(skb, IPV6_FFN_LOCAL_IN);
+#endif
+
 	rcu_read_lock();
 	ip6_protocol_deliver_rcu(net, skb, 0, false);
 	rcu_read_unlock();
diff -ruw linux-5.4.60/net/ipv6/ip6_output.c linux-5.4.60-fbx/net/ipv6/ip6_output.c
--- linux-5.4.60/net/ipv6/ip6_output.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv6/ip6_output.c	2021-03-04 13:21:01.437505718 +0100
@@ -51,6 +51,7 @@
 #include <net/icmp.h>
 #include <net/xfrm.h>
 #include <net/checksum.h>
+#include <net/dsfield.h>
 #include <linux/mroute6.h>
 #include <net/l3mdev.h>
 #include <net/lwtunnel.h>
@@ -106,6 +107,11 @@
 			return res;
 	}
 
+#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);
@@ -172,6 +178,11 @@
 		return 0;
 	}
 
+#ifdef CONFIG_IP_FFN
+	if (skb->ffn_state == FFN_STATE_FAST_FORWARDED)
+		return ip6_finish_output(net, sk, skb);
+#endif
+
 	return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING,
 			    net, sk, skb, NULL, dev,
 			    ip6_finish_output,
@@ -565,6 +576,8 @@
 
 	hdr->hop_limit--;
 
+	skb->priority = rt_tos2priority(ipv6_get_dsfield(hdr));
+
 	return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD,
 		       net, NULL, skb, skb->dev, dst->dev,
 		       ip6_forward_finish);
diff -ruw linux-5.4.60/net/ipv6/ip6_tunnel.c linux-5.4.60-fbx/net/ipv6/ip6_tunnel.c
--- linux-5.4.60/net/ipv6/ip6_tunnel.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv6/ip6_tunnel.c	2021-03-04 13:21:01.437505718 +0100
@@ -67,9 +67,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);
+	u32 hash = ipv6_addr_hash(addr);
 
 	return hash_32(hash, IP6_TUNNEL_HASH_SIZE_SHIFT);
 }
@@ -136,20 +136,29 @@
 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) &&
 		    ipv6_addr_any(&t->parms.raddr) &&
@@ -157,7 +166,7 @@
 			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) &&
 		    ipv6_addr_any(&t->parms.laddr) &&
@@ -197,7 +206,7 @@
 
 	if (!ipv6_addr_any(remote) || !ipv6_addr_any(local)) {
 		prio = 1;
-		h = HASH(remote, local);
+		h = HASH(local);
 	}
 	return &ip6n->tnls[prio][h];
 }
@@ -378,6 +387,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
@@ -767,6 +782,107 @@
 }
 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);
+	}
+}
+
+
 static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 			 const struct tnl_ptk_info *tpi,
 			 struct metadata_dst *tun_dst,
@@ -819,6 +935,27 @@
 	skb_reset_network_header(skb);
 	memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
 
+	if (tpi->proto == htons(ETH_P_IP) &&
+		!ipv6_addr_equal(&ipv6h->saddr, &tunnel->parms.raddr)) {
+			/* Packet didn't come from BR, so lookup FMR */
+			struct __ip6_tnl_fmr *fmr;
+			struct in6_addr expected = tunnel->parms.raddr;
+			for (fmr = tunnel->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 drop;
+			}
+	}
+
 	__skb_tunnel_rx(skb, tunnel->dev, tunnel->net);
 
 	err = dscp_ecn_decapsulate(tunnel, ipv6h, skb);
@@ -951,6 +1088,7 @@
 	opt->ops.opt_nflen = 8;
 }
 
+
 /**
  * ip6_tnl_addr_conflict - compare packet addresses to tunnel's own
  *   @t: the outgoing tunnel device
@@ -1232,6 +1370,7 @@
 	struct ip6_tnl *t = netdev_priv(dev);
 	const struct iphdr  *iph;
 	int encap_limit = -1;
+	struct __ip6_tnl_fmr *fmr;
 	struct flowi6 fl6;
 	__u8 dsfield;
 	__u32 mtu;
@@ -1280,6 +1419,18 @@
 	fl6.flowi6_uid = sock_net_uid(dev_net(dev), NULL);
 	dsfield = INET_ECN_encapsulate(dsfield, ipv4_get_dsfield(iph));
 
+	/* 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(ip_hdr(skb)->daddr) >> mshift)
+			break;
+	}
+
+	/* change dstaddr according to FMR */
+	if (fmr)
+		ip4ip6_fmr_calc(&fl6.daddr, ip_hdr(skb), skb_tail_pointer(skb), fmr, true);
+
 	if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6))
 		return -1;
 
@@ -1497,6 +1648,14 @@
 	t->parms.link = p->link;
 	t->parms.proto = p->proto;
 	t->parms.fwmark = p->fwmark;
+
+	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;
+
 	dst_cache_reset(&t->dst_cache);
 	ip6_tnl_link_config(t);
 	return 0;
@@ -1535,6 +1694,7 @@
 	p->flowinfo = u->flowinfo;
 	p->link = u->link;
 	p->proto = u->proto;
+	p->fmrs = NULL;
 	memcpy(p->name, u->name, sizeof(u->name));
 }
 
@@ -1919,13 +2079,22 @@
 	return 0;
 }
 
-static void ip6_tnl_netlink_parms(struct nlattr *data[],
+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 int ip6_tnl_netlink_parms(struct nlattr *data[],
 				  struct __ip6_tnl_parm *parms)
 {
 	memset(parms, 0, sizeof(*parms));
 
 	if (!data)
-		return;
+		return 0;
 
 	if (data[IFLA_IPTUN_LINK])
 		parms->link = nla_get_u32(data[IFLA_IPTUN_LINK]);
@@ -1956,6 +2125,52 @@
 
 	if (data[IFLA_IPTUN_FWMARK])
 		parms->fwmark = nla_get_u32(data[IFLA_IPTUN_FWMARK]);
+
+	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;
+			int err;
+
+			err = nla_parse_nested_deprecated(fmrd, IFLA_IPTUN_FMR_MAX,
+					       fmr, ip6_tnl_fmr_policy, NULL);
+			if (err)
+				return err;
+
+			if (!(nfmr = kzalloc(sizeof(*nfmr), GFP_KERNEL)))
+				return -ENOMEM;
+
+			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;
+		}
+	}
+
+	return 0;
 }
 
 static bool ip6_tnl_netlink_encap_parms(struct nlattr *data[],
@@ -2009,7 +2224,9 @@
 			return err;
 	}
 
-	ip6_tnl_netlink_parms(data, &nt->parms);
+	err = ip6_tnl_netlink_parms(data, &nt->parms);
+	if (err)
+		return err;
 
 	if (nt->parms.collect_md) {
 		if (rtnl_dereference(ip6n->collect_md_tun))
@@ -2036,6 +2253,7 @@
 	struct net *net = t->net;
 	struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
 	struct ip_tunnel_encap ipencap;
+	int err;
 
 	if (dev == ip6n->fb_tnl_dev)
 		return -EINVAL;
@@ -2046,7 +2264,10 @@
 		if (err < 0)
 			return err;
 	}
-	ip6_tnl_netlink_parms(data, &p);
+	err = ip6_tnl_netlink_parms(data, &p);
+	if (err)
+		return err;
+
 	if (p.collect_md)
 		return -EINVAL;
 
@@ -2071,6 +2292,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) +
@@ -2100,6 +2327,24 @@
 		nla_total_size(0) +
 		/* IFLA_IPTUN_FWMARK */
 		nla_total_size(4) +
+		/* 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;
 }
 
@@ -2107,6 +2352,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) ||
@@ -2116,9 +2364,27 @@
 	    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_u32(skb, IFLA_IPTUN_FWMARK, parm->fwmark))
+	    nla_put_u32(skb, IFLA_IPTUN_FWMARK, parm->fwmark) ||
+	    !(fmrs = nla_nest_start_noflag(skb, IFLA_IPTUN_FMRS)))
 		goto nla_put_failure;
 
+	for (c = parm->fmrs; c; c = c->next) {
+		struct nlattr *fmr = nla_nest_start_noflag(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);
+
 	if (nla_put_u16(skb, IFLA_IPTUN_ENCAP_TYPE, tunnel->encap.type) ||
 	    nla_put_be16(skb, IFLA_IPTUN_ENCAP_SPORT, tunnel->encap.sport) ||
 	    nla_put_be16(skb, IFLA_IPTUN_ENCAP_DPORT, tunnel->encap.dport) ||
@@ -2158,6 +2424,7 @@
 	[IFLA_IPTUN_ENCAP_DPORT]	= { .type = NLA_U16 },
 	[IFLA_IPTUN_COLLECT_METADATA]	= { .type = NLA_FLAG },
 	[IFLA_IPTUN_FWMARK]		= { .type = NLA_U32 },
+	[IFLA_IPTUN_FMRS]		= { .type = NLA_NESTED },
 };
 
 static struct rtnl_link_ops ip6_link_ops __read_mostly = {
diff -ruw linux-5.4.60/net/ipv6/Makefile linux-5.4.60-fbx/net/ipv6/Makefile
--- linux-5.4.60/net/ipv6/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv6/Makefile	2021-03-04 13:21:01.434172386 +0100
@@ -15,6 +15,7 @@
 ipv6-offload :=	ip6_offload.o tcpv6_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-5.4.60/net/ipv6/netfilter/ip6_tables.c linux-5.4.60-fbx/net/ipv6/netfilter/ip6_tables.c
--- linux-5.4.60/net/ipv6/netfilter/ip6_tables.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv6/netfilter/ip6_tables.c	2021-03-04 13:21:01.440839052 +0100
@@ -1158,6 +1158,10 @@
 			   tmp.num_counters, tmp.counters);
 	if (ret)
 		goto free_newinfo_untrans;
+
+#ifdef CONFIG_IPV6_FFN
+	ipv6_ffn_flush_all();
+#endif
 	return 0;
 
  free_newinfo_untrans:
diff -ruw linux-5.4.60/net/ipv6/netfilter/Kconfig linux-5.4.60-fbx/net/ipv6/netfilter/Kconfig
--- linux-5.4.60/net/ipv6/netfilter/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv6/netfilter/Kconfig	2021-03-04 13:21:01.440839052 +0100
@@ -6,6 +6,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_SOCKET_IPV6
 	tristate "IPv6 socket lookup support"
 	help
diff -ruw linux-5.4.60/net/ipv6/udp.c linux-5.4.60-fbx/net/ipv6/udp.c
--- linux-5.4.60/net/ipv6/udp.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/ipv6/udp.c	2021-03-04 13:21:01.444172385 +0100
@@ -743,6 +743,82 @@
  * 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, int proto)
+{
+	struct sock *sk, *first = NULL;
+	const struct udphdr *uh = udp_hdr(skb);
+	unsigned short hnum = ntohs(uh->dest);
+	struct udp_hslot *hslot = udp_hashslot(udptable, net, hnum);
+	unsigned int offset = offsetof(typeof(*sk), sk_node);
+	int dif = inet6_iif(skb);
+	int sdif = inet6_sdif(skb);
+	struct hlist_node *node;
+	struct sk_buff *nskb;
+	bool found_non_dup;
+
+	found_non_dup = false;
+	sk_for_each_entry_offset_rcu(sk, node, &hslot->head, offset) {
+		bool need_deliver;
+
+		if (!__udp_v6_is_mcast_sock(net, sk, uh->dest, daddr,
+					    uh->source, saddr, dif, sdif, hnum))
+
+			continue;
+
+		/* If zero checksum and no_check is not on for
+		 * the socket then skip it.
+		 */
+		if (!uh->check && !udp_sk(sk)->no_check6_rx)
+			continue;
+
+		if (sock_flag(sk, SOCK_UDP_DUP_UNICAST))
+			need_deliver = true;
+		else {
+			if (!found_non_dup)
+				need_deliver = true;
+			else
+				need_deliver = false;
+			found_non_dup = true;
+		}
+
+		if (!need_deliver)
+			continue;
+
+		if (!first) {
+			first = sk;
+			continue;
+		}
+		nskb = skb_clone(skb, GFP_ATOMIC);
+		if (unlikely(!nskb)) {
+			atomic_inc(&sk->sk_drops);
+			__UDP6_INC_STATS(net, UDP_MIB_RCVBUFERRORS,
+					 IS_UDPLITE(sk));
+			__UDP6_INC_STATS(net, UDP_MIB_INERRORS,
+					 IS_UDPLITE(sk));
+			continue;
+		}
+
+		if (udpv6_queue_rcv_skb(sk, nskb) > 0)
+			consume_skb(nskb);
+	}
+
+	if (first) {
+		if (udpv6_queue_rcv_skb(first, skb) > 0)
+			consume_skb(skb);
+	} else {
+		kfree_skb(skb);
+		__UDP6_INC_STATS(net, UDP_MIB_IGNOREDMULTI,
+				 proto == IPPROTO_UDPLITE);
+	}
+	return 0;
+}
+
+/*
+ * Note: called only from the BH handler context,
+ * so we don't need to lock the hashes.
+ */
 static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
 		const struct in6_addr *saddr, const struct in6_addr *daddr,
 		struct udp_table *udptable, int proto)
@@ -913,6 +989,12 @@
 	if (sk) {
 		if (!uh->check && !udp_sk(sk)->no_check6_rx)
 			goto report_csum_error;
+
+		if (sk->sk_reuse_conflict)
+			return __udp6_lib_uc_conflict_deliver(net, skb,
+						      saddr, daddr,
+						      udptable, proto);
+
 		return udp6_unicast_rcv_skb(sk, skb, uh);
 	}
 
diff -ruw linux-5.4.60/net/Kconfig linux-5.4.60-fbx/net/Kconfig
--- linux-5.4.60/net/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/Kconfig	2021-03-04 13:21:01.370839049 +0100
@@ -60,6 +60,20 @@
 
 menu "Networking options"
 
+config NETSKBPAD
+	int "Size reserved by dev_alloc_skb"
+	default 32
+
+config NETRXTHREAD
+	bool "Do rx network processing in kernel thread"
+	depends on BROKEN_ON_SMP
+
+config NETRXTHREAD_RX_QUEUE
+	int "Number of rx queues"
+	default 1
+	depends on NETRXTHREAD
+
+source "net/nmesh-mbh/Kconfig"
 source "net/packet/Kconfig"
 source "net/unix/Kconfig"
 source "net/tls/Kconfig"
@@ -216,6 +230,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-5.4.60/net/mac80211/agg-tx.c linux-5.4.60-fbx/net/mac80211/agg-tx.c
--- linux-5.4.60/net/mac80211/agg-tx.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/agg-tx.c	2021-03-04 13:21:01.447505719 +0100
@@ -139,6 +139,14 @@
 }
 EXPORT_SYMBOL(ieee80211_send_bar);
 
+void ieee80211_send_bar_sta(struct ieee80211_sta *pubsta,
+			    u16 tid, u16 ssn)
+{
+	struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
+	ieee80211_send_bar(&sta->sdata->vif, pubsta->addr, tid, ssn);
+}
+EXPORT_SYMBOL(ieee80211_send_bar_sta);
+
 void ieee80211_assign_tid_tx(struct sta_info *sta, int tid,
 			     struct tid_ampdu_tx *tid_tx)
 {
@@ -290,7 +298,6 @@
 	ieee80211_assign_tid_tx(sta, tid, NULL);
 
 	ieee80211_agg_splice_finish(sta->sdata, tid);
-	ieee80211_agg_start_txq(sta, tid, false);
 
 	kfree_rcu(tid_tx, rcu_head);
 }
@@ -860,6 +867,7 @@
 {
 	struct ieee80211_sub_if_data *sdata = sta->sdata;
 	bool send_delba = false;
+	bool stop_txq = false;
 
 	ht_dbg(sdata, "Stopping Tx BA session for %pM tid %d\n",
 	       sta->sta.addr, tid);
@@ -877,9 +885,12 @@
 		send_delba = true;
 
 	ieee80211_remove_tid_tx(sta, tid);
+	stop_txq = true;
 
  unlock_sta:
 	spin_unlock_bh(&sta->lock);
+	if (stop_txq)
+		ieee80211_agg_start_txq(sta, tid, false);
 
 	if (send_delba)
 		ieee80211_send_delba(sdata, sta->sta.addr, tid,
diff -ruw linux-5.4.60/net/mac80211/cfg.c linux-5.4.60-fbx/net/mac80211/cfg.c
--- linux-5.4.60/net/mac80211/cfg.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/cfg.c	2021-03-04 13:21:01.450839053 +0100
@@ -1926,6 +1926,59 @@
 	return 0;
 }
 
+static int ieee80211_update_mpp(struct wiphy *wiphy, struct net_device *dev,
+			       const u8 *dst, const u8 *next_hop)
+{
+	struct ieee80211_sub_if_data *sdata;
+	int ret = 0;
+	struct mesh_path *mppath;
+
+	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+	rcu_read_lock();
+
+	mppath = mpp_path_lookup(sdata, dst);
+	if (!mppath) {
+		ret = mpp_path_add(sdata, dst, next_hop);
+		if (!ret) {
+			mppath = mpp_path_lookup(sdata, dst);
+			spin_lock_bh(&mppath->state_lock);
+			mppath->flags |= MESH_PATH_FIXED;
+			spin_unlock_bh(&mppath->state_lock);
+		}
+	} else {
+		spin_lock_bh(&mppath->state_lock);
+		if (!ether_addr_equal(mppath->mpp, next_hop))
+			memcpy(mppath->mpp, next_hop, ETH_ALEN);
+		mppath->exp_time = jiffies;
+		mppath->flags |= MESH_PATH_FIXED;
+		spin_unlock_bh(&mppath->state_lock);
+	}
+	rcu_read_unlock();
+	return ret;
+}
+
+static int ieee80211_delete_mpp(struct wiphy *wiphy, struct net_device *dev,
+			       const u8 *dst)
+{
+	struct ieee80211_sub_if_data *sdata;
+	int ret = 0;
+	struct mesh_path *mppath;
+
+	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+	rcu_read_lock();
+	mppath = mpp_path_lookup(sdata, dst);
+	if (mppath) {
+		spin_lock_bh(&mppath->state_lock);
+		mppath->flags &= ~MESH_PATH_FIXED;
+		spin_unlock_bh(&mppath->state_lock);
+	} else {
+		ret = -ENOENT;
+	}
+	rcu_read_unlock();
+	return ret;
+}
+
 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
 				struct net_device *dev,
 				struct mesh_config *conf)
@@ -2104,6 +2157,36 @@
 	return 0;
 }
 
+static int ieee80211_update_mesh_vendor_node_metrics_ie(struct wiphy *wiphy,
+							struct net_device *dev,
+							const struct mesh_vendor_ie *vendor_ie)
+{
+	struct ieee80211_sub_if_data *sdata;
+	struct ieee80211_if_mesh *ifmsh;
+
+	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+	ifmsh = &sdata->u.mesh;
+	memcpy(ifmsh->node_vendor_ie, vendor_ie->ie, vendor_ie->ie_len);
+	ifmsh->node_vendor_ie_len = vendor_ie->ie_len;
+	ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
+	return 0;
+}
+
+static int ieee80211_update_mesh_vendor_path_metrics_ie(struct wiphy *wiphy,
+							struct net_device *dev,
+							const struct mesh_vendor_ie *vendor_ie)
+{
+	struct ieee80211_sub_if_data *sdata;
+	struct ieee80211_if_mesh *ifmsh;
+
+	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+	ifmsh = &sdata->u.mesh;
+	memcpy(ifmsh->mpm_vendor_ie, vendor_ie->ie, vendor_ie->ie_len);
+	ifmsh->mpm_vendor_ie_len = vendor_ie->ie_len;
+	ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
+	return 0;
+}
+
 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
 			       const struct mesh_config *conf,
 			       const struct mesh_setup *setup)
@@ -2127,8 +2210,10 @@
 	err = ieee80211_vif_use_channel(sdata, &setup->chandef,
 					IEEE80211_CHANCTX_SHARED);
 	mutex_unlock(&sdata->local->mtx);
-	if (err)
+	if (err) {
+		kfree(ifmsh->ie);
 		return err;
+	}
 
 	return ieee80211_start_mesh(sdata);
 }
@@ -3993,10 +4078,14 @@
 	.dump_mpath = ieee80211_dump_mpath,
 	.get_mpp = ieee80211_get_mpp,
 	.dump_mpp = ieee80211_dump_mpp,
+	.update_mpp = ieee80211_update_mpp,
+	.delete_mpp = ieee80211_delete_mpp,
 	.update_mesh_config = ieee80211_update_mesh_config,
 	.get_mesh_config = ieee80211_get_mesh_config,
 	.join_mesh = ieee80211_join_mesh,
 	.leave_mesh = ieee80211_leave_mesh,
+	.update_mesh_vendor_node_metrics_ie = ieee80211_update_mesh_vendor_node_metrics_ie,
+	.update_mesh_vendor_path_metrics_ie = ieee80211_update_mesh_vendor_path_metrics_ie,
 #endif
 	.join_ocb = ieee80211_join_ocb,
 	.leave_ocb = ieee80211_leave_ocb,
diff -ruw linux-5.4.60/net/mac80211/debugfs.c linux-5.4.60-fbx/net/mac80211/debugfs.c
--- linux-5.4.60/net/mac80211/debugfs.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/debugfs.c	2021-03-04 13:21:01.450839053 +0100
@@ -272,6 +272,7 @@
 	FLAG(SUPPORTS_MULTI_BSSID),
 	FLAG(SUPPORTS_ONLY_HE_MULTI_BSSID),
 	FLAG(AMPDU_KEYBORDER_SUPPORT),
+	FLAG(APVLAN_NEED_MCAST_TO_UCAST),
 #undef FLAG
 };
 
diff -ruw linux-5.4.60/net/mac80211/driver-ops.c linux-5.4.60-fbx/net/mac80211/driver-ops.c
--- linux-5.4.60/net/mac80211/driver-ops.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/driver-ops.c	2021-03-04 13:21:01.450839053 +0100
@@ -49,6 +49,30 @@
 	local->started = false;
 }
 
+int drv_get_powered(struct ieee80211_local *local, bool *up, bool *busy)
+{
+	int ret = -EOPNOTSUPP;
+
+	might_sleep();
+
+	if (local->ops->get_powered)
+		ret = local->ops->get_powered(&local->hw, up, busy);
+
+	return ret;
+}
+
+int drv_set_powered(struct ieee80211_local *local)
+{
+	int ret = -EOPNOTSUPP;
+
+	might_sleep();
+
+	if (local->ops->set_powered)
+		ret = local->ops->set_powered(&local->hw);
+
+	return ret;
+}
+
 int drv_add_interface(struct ieee80211_local *local,
 		      struct ieee80211_sub_if_data *sdata)
 {
diff -ruw linux-5.4.60/net/mac80211/driver-ops.h linux-5.4.60-fbx/net/mac80211/driver-ops.h
--- linux-5.4.60/net/mac80211/driver-ops.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/driver-ops.h	2021-03-04 13:21:01.450839053 +0100
@@ -85,6 +85,8 @@
 
 int drv_start(struct ieee80211_local *local);
 void drv_stop(struct ieee80211_local *local);
+int drv_get_powered(struct ieee80211_local *local, bool *up, bool *busy);
+int drv_set_powered(struct ieee80211_local *local);
 
 #ifdef CONFIG_PM
 static inline int drv_suspend(struct ieee80211_local *local,
diff -ruw linux-5.4.60/net/mac80211/ethtool.c linux-5.4.60-fbx/net/mac80211/ethtool.c
--- linux-5.4.60/net/mac80211/ethtool.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/ethtool.c	2021-03-04 13:21:01.450839053 +0100
@@ -46,6 +46,22 @@
 };
 #define STA_STATS_LEN	ARRAY_SIZE(ieee80211_gstrings_sta_stats)
 
+struct ethtool_priv_flags_strings {
+	const char string[ETH_GSTRING_LEN];
+};
+
+enum {
+	POWERED_SUPPORTED	= (1 << 0),
+	POWERED_STATUS		= (1 << 1),
+	POWERED_CHANGE_BUSY	= (1 << 2),
+};
+
+static const struct ethtool_priv_flags_strings ieee80211_pflags_strings[] = {
+	{ .string = "powered-supported" },
+	{ .string = "powered-status" },
+	{ .string = "powered-change-busy", },
+};
+
 static int ieee80211_get_sset_count(struct net_device *dev, int sset)
 {
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
@@ -56,6 +72,9 @@
 
 	rv += drv_get_et_sset_count(sdata, sset);
 
+	if (sset == ETH_SS_PRIV_FLAGS)
+		rv += ARRAY_SIZE(ieee80211_pflags_strings);
+
 	if (rv == 0)
 		return -EOPNOTSUPP;
 	return rv;
@@ -212,6 +231,9 @@
 		memcpy(data, ieee80211_gstrings_sta_stats, sz_sta_stats);
 	}
 	drv_get_et_strings(sdata, sset, &(data[sz_sta_stats]));
+	if (sset == ETH_SS_PRIV_FLAGS)
+		memcpy(data, ieee80211_pflags_strings,
+		       sizeof (ieee80211_pflags_strings));
 }
 
 static int ieee80211_get_regs_len(struct net_device *dev)
@@ -229,6 +251,35 @@
 	regs->len = 0;
 }
 
+static u32 ieee80211_get_priv_flags(struct net_device *dev)
+{
+	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+	struct ieee80211_local *local = sdata->local;
+	bool powered, powered_busy;
+	u32 ret;
+
+	ret = 0;
+	if (!drv_get_powered(local, &powered, &powered_busy)) {
+		ret |= POWERED_SUPPORTED;
+		if (powered)
+			ret |= POWERED_STATUS;
+		if (powered_busy)
+			ret |= POWERED_CHANGE_BUSY;
+	}
+	return ret;
+}
+
+static int ieee80211_set_priv_flags(struct net_device *dev, u32 flags)
+{
+	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+	struct ieee80211_local *local = sdata->local;
+
+	if (flags & (POWERED_STATUS))
+		return drv_set_powered(local);
+
+	return 0;
+}
+
 const struct ethtool_ops ieee80211_ethtool_ops = {
 	.get_drvinfo = cfg80211_get_drvinfo,
 	.get_regs_len = ieee80211_get_regs_len,
@@ -239,4 +290,6 @@
 	.get_strings = ieee80211_get_strings,
 	.get_ethtool_stats = ieee80211_get_stats,
 	.get_sset_count = ieee80211_get_sset_count,
+	.set_priv_flags	= ieee80211_set_priv_flags,
+	.get_priv_flags	= ieee80211_get_priv_flags,
 };
diff -ruw linux-5.4.60/net/mac80211/ieee80211_i.h linux-5.4.60-fbx/net/mac80211/ieee80211_i.h
--- linux-5.4.60/net/mac80211/ieee80211_i.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/ieee80211_i.h	2021-03-04 13:21:01.450839053 +0100
@@ -721,6 +721,13 @@
 	struct mesh_table *mpp_paths; /* Store paths for MPP&MAP */
 	int mesh_paths_generation;
 	int mpp_paths_generation;
+
+	/* Store Vendor specific node metrics IE */
+	u8 node_vendor_ie[260];
+	u8 node_vendor_ie_len;
+	/* Store Vendor specific mesh path metrics IE */
+	u8 mpm_vendor_ie[260];
+	u8 mpm_vendor_ie_len;
 };
 
 #ifdef CONFIG_MAC80211_MESH
@@ -1532,6 +1539,13 @@
 	bool parse_error;
 };
 
+struct ieee802_11_mesh_vendor_specific_elems {
+	const u8 *ie_start;
+	u8 ie_len;
+	/* whether a parse error occurred while retrieving these elements */
+	bool parse_error;
+};
+
 static inline struct ieee80211_local *hw_to_local(
 	struct ieee80211_hw *hw)
 {
@@ -1983,6 +1997,9 @@
 			       struct ieee802_11_elems *elems,
 			       u64 filter, u32 crc, u8 *transmitter_bssid,
 			       u8 *bss_bssid);
+u32 ieee802_11_parse_mesh_vendor_elems(const u8 *start, size_t len, bool action,
+				       struct ieee802_11_mesh_vendor_specific_elems *elems,
+				       u64 filter, u32 crc, u8 type);
 static inline void ieee802_11_parse_elems(const u8 *start, size_t len,
 					  bool action,
 					  struct ieee802_11_elems *elems,
diff -ruw linux-5.4.60/net/mac80211/key.c linux-5.4.60-fbx/net/mac80211/key.c
--- linux-5.4.60/net/mac80211/key.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/key.c	2021-03-04 13:21:01.450839053 +0100
@@ -172,6 +172,12 @@
 		 * Hence, don't send GTKs for VLAN interfaces to the driver.
 		 */
 		if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
+			if (ieee80211_hw_check(&key->local->hw,
+					       APVLAN_NEED_MCAST_TO_UCAST)) {
+				/* no need to fail, this key will
+				 * never be used */
+				return 0;
+			}
 			ret = 1;
 			goto out_unsupported;
 		}
diff -ruw linux-5.4.60/net/mac80211/mesh.c linux-5.4.60-fbx/net/mac80211/mesh.c
--- linux-5.4.60/net/mac80211/mesh.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/mesh.c	2021-03-30 15:23:23.574984438 +0200
@@ -338,20 +338,31 @@
 	u8 offset, len;
 	const u8 *data;
 
-	if (!ifmsh->ie || !ifmsh->ie_len)
-		return 0;
 
 	/* fast-forward to vendor IEs */
-	offset = ieee80211_ie_split_vendor(ifmsh->ie, ifmsh->ie_len, 0);
+	if (ifmsh->node_vendor_ie_len) {
+		offset = ieee80211_ie_split_vendor(ifmsh->node_vendor_ie, ifmsh->node_vendor_ie_len, 0);
 
-	if (offset < ifmsh->ie_len) {
-		len = ifmsh->ie_len - offset;
-		data = ifmsh->ie + offset;
+		if (offset < ifmsh->node_vendor_ie_len) {
+			len = ifmsh->node_vendor_ie_len - offset;
+			data = ifmsh->node_vendor_ie + offset;
 		if (skb_tailroom(skb) < len)
 			return -ENOMEM;
 		skb_put_data(skb, data, len);
 	}
+	}
 
+	if (ifmsh->mpm_vendor_ie_len) {
+		offset = ieee80211_ie_split_vendor(ifmsh->mpm_vendor_ie, ifmsh->mpm_vendor_ie_len, 0);
+
+		if (offset < ifmsh->mpm_vendor_ie_len) {
+			len = ifmsh->mpm_vendor_ie_len - offset;
+			data = ifmsh->mpm_vendor_ie + offset;
+			if (skb_tailroom(skb) < len)
+				return -ENOMEM;
+			skb_put_data(skb, data, len);
+		}
+	}
 	return 0;
 }
 
@@ -766,7 +777,9 @@
 		   2 + sizeof(struct ieee80211_vht_operation) +
 		   ie_len_he_cap +
 		   2 + 1 + sizeof(struct ieee80211_he_operation) +
-		   ifmsh->ie_len;
+		   ifmsh->ie_len +
+		   ifmsh->node_vendor_ie_len +
+		   ifmsh->mpm_vendor_ie_len;
 
 	bcn = kzalloc(sizeof(*bcn) + head_len + tail_len, GFP_KERNEL);
 	/* need an skb for IE builders to operate on */
@@ -1220,12 +1233,17 @@
 	size_t baselen;
 	int freq;
 	enum nl80211_band band = rx_status->band;
+	struct ieee802_11_mesh_vendor_specific_elems velems;
+	u32 beacon_int;
 
 	/* ignore ProbeResp to foreign address */
 	if (stype == IEEE80211_STYPE_PROBE_RESP &&
 	    !ether_addr_equal(mgmt->da, sdata->vif.addr))
 		return;
 
+	if (stype == IEEE80211_STYPE_BEACON)
+		beacon_int = mgmt->u.beacon.beacon_int;
+
 	baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
 	if (baselen > len)
 		return;
@@ -1252,6 +1270,36 @@
 	if (mesh_matches_local(sdata, &elems)) {
 		mpl_dbg(sdata, "rssi_threshold=%d,rx_status->signal=%d\n",
 			sdata->u.mesh.mshcfg.rssi_threshold, rx_status->signal);
+		if (mesh_neighbour_connection_established(sdata, mgmt->sa, &elems, rx_status)) {
+			ieee802_11_parse_mesh_vendor_elems(mgmt->u.probe_resp.variable,
+							   len - baselen,
+							   false, &velems, 0, 0,
+							   NL80211_QBC_UPDATE_NODE_METRICS_IE);
+
+			if (velems.parse_error	== false) {
+				cfg80211_notify_mesh_peer_node_metrics(sdata->dev, mgmt->sa, stype,
+								       rx_status->signal,
+								       beacon_int,
+								       velems.ie_start,
+								       velems.ie_len,
+								       GFP_KERNEL);
+				elems.total_len -= (velems.ie_len + 2);
+			}
+
+			ieee802_11_parse_mesh_vendor_elems(mgmt->u.probe_resp.variable,
+							   len - baselen,
+							   false, &velems, 0, 0,
+							   NL80211_QBC_UPDATE_PATH_METRICS_IE);
+
+			if (velems.parse_error	== false) {
+				cfg80211_notify_mesh_peer_path_metrics(sdata->dev, mgmt->sa,
+								       velems.ie_start,
+								       velems.ie_len,
+								       GFP_KERNEL);
+				elems.total_len -= (velems.ie_len + 2);
+			}
+		}
+
 		if (!sdata->u.mesh.user_mpm ||
 		    sdata->u.mesh.mshcfg.rssi_threshold == 0 ||
 		    sdata->u.mesh.mshcfg.rssi_threshold < rx_status->signal)
@@ -1362,11 +1410,20 @@
 	bool fwd_csa = true;
 	size_t baselen;
 	u8 *pos;
+	struct sta_info *sta = NULL;
 
 	if (mgmt->u.action.u.measurement.action_code !=
 	    WLAN_ACTION_SPCT_CHL_SWITCH)
 		return;
 
+	/* Process action frames received from connected mesh nodes */
+	rcu_read_lock();
+	sta = sta_info_get(sdata, mgmt->bssid);
+	if (!sta) {
+		rcu_read_unlock();
+		return;
+	}
+	rcu_read_unlock();
 	pos = mgmt->u.action.u.chan_switch.variable;
 	baselen = offsetof(struct ieee80211_mgmt,
 			   u.action.u.chan_switch.variable);
diff -ruw linux-5.4.60/net/mac80211/mesh.h linux-5.4.60-fbx/net/mac80211/mesh.h
--- linux-5.4.60/net/mac80211/mesh.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/mesh.h	2021-03-30 15:23:23.578317771 +0200
@@ -297,7 +297,10 @@
 			 struct ieee80211_mgmt *mgmt, size_t len,
 			 struct ieee80211_rx_status *rx_status);
 void mesh_sta_cleanup(struct sta_info *sta);
-
+bool mesh_neighbour_connection_established(struct ieee80211_sub_if_data *sdata,
+					   u8 *hw_addr,
+					   struct ieee802_11_elems *elems,
+					   struct ieee80211_rx_status *rx_status);
 /* Private interfaces */
 /* Mesh paths */
 int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
diff -ruw linux-5.4.60/net/mac80211/mesh_plink.c linux-5.4.60-fbx/net/mac80211/mesh_plink.c
--- linux-5.4.60/net/mac80211/mesh_plink.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/mesh_plink.c	2021-03-30 15:23:23.578317771 +0200
@@ -1226,3 +1226,32 @@
 			       mgmt->bssid, NULL);
 	mesh_process_plink_frame(sdata, mgmt, &elems, rx_status);
 }
+
+/*
+ * mesh_neighbour_connection_established - return if connection has been established with  neighbor.
+ *
+ * @sdata: local meshif
+ * @addr: peer's address
+ * @elems: IEs from beacon or mesh peering frame
+ *
+ *
+ */
+bool mesh_neighbour_connection_established(struct ieee80211_sub_if_data *sdata,
+					   u8 *hw_addr,
+					   struct ieee802_11_elems *elems,
+					   struct ieee80211_rx_status *rx_status)
+{
+	struct sta_info *sta;
+	bool ret = false;
+
+	sta = mesh_sta_info_get(sdata, hw_addr, elems, rx_status);
+	if (!sta)
+		goto out;
+
+	if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
+		ret = true;
+
+out:
+	rcu_read_unlock();
+	return ret;
+}
diff -ruw linux-5.4.60/net/mac80211/rx.c linux-5.4.60-fbx/net/mac80211/rx.c
--- linux-5.4.60/net/mac80211/rx.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/rx.c	2021-03-04 13:21:01.454172386 +0100
@@ -2756,9 +2756,11 @@
 			mpp_path_add(sdata, proxied_addr, mpp_addr);
 		} else {
 			spin_lock_bh(&mppath->state_lock);
-			if (!ether_addr_equal(mppath->mpp, mpp_addr))
+			if (!ether_addr_equal(mppath->mpp, mpp_addr) &&
+			    !(mppath->flags & MESH_PATH_FIXED)) {
 				memcpy(mppath->mpp, mpp_addr, ETH_ALEN);
 			mppath->exp_time = jiffies;
+			}
 			spin_unlock_bh(&mppath->state_lock);
 		}
 		rcu_read_unlock();
@@ -2823,6 +2825,7 @@
 	}
 
 	IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, fwded_frames);
+	fwd_skb->dev = sdata->dev;
 	ieee80211_add_pending_skb(local, fwd_skb);
  out:
 	if (is_multicast_ether_addr(hdr->addr1))
@@ -4577,7 +4580,7 @@
 	 * The same happens when we're not even started,
 	 * but that's worth a warning.
 	 */
-	if (WARN_ON(!local->started))
+	if (!local->started)
 		goto drop;
 
 	if (likely(!(status->flag & RX_FLAG_FAILED_PLCP_CRC))) {
diff -ruw linux-5.4.60/net/mac80211/sta_info.c linux-5.4.60-fbx/net/mac80211/sta_info.c
--- linux-5.4.60/net/mac80211/sta_info.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/sta_info.c	2021-03-04 13:21:01.454172386 +0100
@@ -277,9 +277,10 @@
 		return;
 
 	local_bh_disable();
-	if (!test_sta_flag(sta, WLAN_STA_PS_STA))
+	if (!test_sta_flag(sta, WLAN_STA_PS_STA)) {
+		if (test_sta_flag(sta, WLAN_STA_PS_DELIVER))
 		ieee80211_sta_ps_deliver_wakeup(sta);
-	else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL))
+	} else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL))
 		ieee80211_sta_ps_deliver_poll_response(sta);
 	else if (test_and_clear_sta_flag(sta, WLAN_STA_UAPSD))
 		ieee80211_sta_ps_deliver_uapsd(sta);
diff -ruw linux-5.4.60/net/mac80211/status.c linux-5.4.60-fbx/net/mac80211/status.c
--- linux-5.4.60/net/mac80211/status.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/status.c	2021-03-04 13:21:01.457505719 +0100
@@ -876,13 +876,15 @@
 	struct ieee80211_bar *bar;
 	int shift = 0;
 	int tid = IEEE80211_NUM_TIDS;
+	bool ack_requested;
 
 	rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
 
+	ack_requested = !(info->flags & IEEE80211_TX_CTL_NO_ACK);
 	sband = local->hw.wiphy->bands[info->band];
 	fc = hdr->frame_control;
 
-	if (status->sta) {
+	if (status->sta && ack_requested) {
 		sta = container_of(status->sta, struct sta_info, sta);
 		shift = ieee80211_vif_get_shift(&sta->sdata->vif);
 
@@ -1101,6 +1103,7 @@
 	struct ieee80211_supported_band *sband;
 	int retry_count;
 	bool acked, noack_success;
+	bool ack_requested;
 
 	if (status->skb)
 		return __ieee80211_tx_status(hw, status);
@@ -1112,10 +1115,11 @@
 
 	sband = hw->wiphy->bands[info->band];
 
+	ack_requested = !(info->flags & IEEE80211_TX_CTL_NO_ACK);
 	acked = !!(info->flags & IEEE80211_TX_STAT_ACK);
 	noack_success = !!(info->flags & IEEE80211_TX_STAT_NOACK_TRANSMITTED);
 
-	if (pubsta) {
+	if (pubsta && ack_requested) {
 		struct sta_info *sta;
 
 		sta = container_of(pubsta, struct sta_info, sta);
diff -ruw linux-5.4.60/net/mac80211/tx.c linux-5.4.60-fbx/net/mac80211/tx.c
--- linux-5.4.60/net/mac80211/tx.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/tx.c	2021-03-04 13:21:01.457505719 +0100
@@ -1256,6 +1256,9 @@
 	    (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE))
 		return NULL;
 
+	if (unlikely(ieee80211_is_ctl(hdr->frame_control)))
+		return NULL;
+
 	if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) {
 		if ((!ieee80211_is_mgmt(hdr->frame_control) ||
 		     ieee80211_is_bufferable_mmpdu(hdr->frame_control) ||
@@ -3961,6 +3964,9 @@
 			return false;
 		if (sdata->wdev.use_4addr)
 			return false;
+		if (ieee80211_hw_check(&sdata->local->hw,
+				       APVLAN_NEED_MCAST_TO_UCAST))
+			break;
 		/* fall through */
 	case NL80211_IFTYPE_AP:
 		/* check runtime toggle for this bss */
diff -ruw linux-5.4.60/net/mac80211/util.c linux-5.4.60-fbx/net/mac80211/util.c
--- linux-5.4.60/net/mac80211/util.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/mac80211/util.c	2021-03-04 13:21:01.457505719 +0100
@@ -250,7 +250,8 @@
 	local_bh_disable();
 	spin_lock(&fq->lock);
 
-	if (sdata->vif.type == NL80211_IFTYPE_AP)
+	if ((sdata->vif.type == NL80211_IFTYPE_AP) &&
+	    ieee80211_sdata_running(sdata))
 		ps = &sdata->bss->ps;
 
 	sdata->vif.txqs_stopped[ac] = false;
@@ -891,6 +892,63 @@
 }
 EXPORT_SYMBOL(ieee80211_queue_delayed_work);
 
+u32 ieee802_11_parse_mesh_vendor_elems(const u8 *start, size_t len, bool action,
+			       struct ieee802_11_mesh_vendor_specific_elems *elems,
+			       u64 filter, u32 crc, u8 type)
+{
+	size_t left = len;
+	const u8 *pos = start;
+	bool calc_crc = filter != 0;
+
+	memset(elems, 0, sizeof(*elems));
+	elems->parse_error = true;
+
+	while (left >= 2) {
+		u8 id, elen;
+
+		id = *pos++;
+		elen = *pos++;
+		left -= 2;
+
+		if (elen > left) {
+			break;
+		}
+
+		if (calc_crc && id < 64 && (filter & (1ULL << id)))
+			crc = crc32_be(crc, pos - 2, elen + 2);
+
+
+		switch (id) {
+		case WLAN_EID_VENDOR_SPECIFIC:
+			if (elen >= 4 && pos[0] == 0xC0 && pos[1] == 0xFF &&
+			    pos[2] == 0xEE && pos[3] == type) {
+				/* Qubercomm OUI (C0:FF:EE) */
+
+				if (calc_crc)
+					crc = crc32_be(crc, pos - 2, elen + 2);
+
+				elems->ie_start = pos;
+				elems->ie_len = elen;
+				elems->parse_error = false;
+
+			}
+			break;
+		default:
+			break;
+		}
+
+		if (elems->parse_error == false)
+			break;
+
+		left -= elen;
+		pos += elen;
+	}
+
+	return crc;
+
+}
+EXPORT_SYMBOL(ieee802_11_parse_mesh_vendor_elems);
+
 static u32
 _ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
 			    struct ieee802_11_elems *elems,
@@ -3808,6 +3866,32 @@
 	ps->dtim_count = dtim_count;
 }
 
+void ieee80211_force_dtim(struct ieee80211_vif *vif,
+			  unsigned int dtim_count)
+{
+	struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
+	u8 dtim_period = sdata->vif.bss_conf.dtim_period;
+	struct ps_data *ps;
+
+	if (sdata->vif.type == NL80211_IFTYPE_AP ||
+	    sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
+		if (!sdata->bss)
+			return;
+
+		ps = &sdata->bss->ps;
+	} else if (ieee80211_vif_is_mesh(&sdata->vif)) {
+		ps = &sdata->u.mesh.ps;
+	} else {
+		return;
+	}
+
+	if (WARN_ON_ONCE(dtim_count >= dtim_period))
+		return;
+
+	ps->dtim_count = dtim_count;
+}
+EXPORT_SYMBOL(ieee80211_force_dtim);
+
 static u8 ieee80211_chanctx_radar_detect(struct ieee80211_local *local,
 					 struct ieee80211_chanctx *ctx)
 {
diff -ruw linux-5.4.60/net/Makefile linux-5.4.60-fbx/net/Makefile
--- linux-5.4.60/net/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/Makefile	2021-03-04 13:21:01.370839049 +0100
@@ -39,6 +39,12 @@
 obj-$(CONFIG_STREAM_PARSER)	+= strparser/
 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),)
@@ -87,3 +93,4 @@
 obj-$(CONFIG_QRTR)		+= qrtr/
 obj-$(CONFIG_NET_NCSI)		+= ncsi/
 obj-$(CONFIG_XDP_SOCKETS)	+= xdp/
+obj-$(CONFIG_NET_NMESH_MBH)	+= nmesh-mbh/
diff -ruw linux-5.4.60/net/netfilter/Kconfig linux-5.4.60-fbx/net/netfilter/Kconfig
--- linux-5.4.60/net/netfilter/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/netfilter/Kconfig	2021-03-04 13:21:01.460839053 +0100
@@ -333,6 +333,7 @@
 config NF_CONNTRACK_SIP
 	tristate "SIP protocol support"
 	default m if NETFILTER_ADVANCED=n
+	select CRYPTO_LIB_SHA256
 	help
 	  SIP is an application-layer control protocol that can establish,
 	  modify, and terminate multimedia sessions (conferences) such as
diff -ruw linux-5.4.60/net/netfilter/nf_conntrack_core.c linux-5.4.60-fbx/net/netfilter/nf_conntrack_core.c
--- linux-5.4.60/net/netfilter/nf_conntrack_core.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/netfilter/nf_conntrack_core.c	2021-03-04 13:21:01.467505720 +0100
@@ -592,6 +592,14 @@
 #endif
 }
 
+#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)
 {
@@ -600,6 +608,15 @@
 	pr_debug("destroy_conntrack(%p)\n", ct);
 	WARN_ON(atomic_read(&nfct->use) != 0);
 
+#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-5.4.60/net/netfilter/nf_conntrack_ftp.c linux-5.4.60-fbx/net/netfilter/nf_conntrack_ftp.c
--- linux-5.4.60/net/netfilter/nf_conntrack_ftp.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/netfilter/nf_conntrack_ftp.c	2021-03-04 13:21:01.467505720 +0100
@@ -27,6 +27,10 @@
 #include <linux/netfilter/nf_conntrack_ftp.h>
 
 #define HELPER_NAME "ftp"
+#if defined(CONFIG_FREEBOX_BRIDGE) || defined(CONFIG_FREEBOX_BRIDGE_MODULE)
+#include <net/netfilter/nf_nat_helper.h>
+#include <net/fbxbridge.h>
+#endif
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
@@ -398,6 +402,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;
@@ -484,6 +499,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-5.4.60/net/netfilter/nf_conntrack_helper.c linux-5.4.60-fbx/net/netfilter/nf_conntrack_helper.c
--- linux-5.4.60/net/netfilter/nf_conntrack_helper.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/netfilter/nf_conntrack_helper.c	2021-03-04 13:21:01.467505720 +0100
@@ -35,7 +35,7 @@
 EXPORT_SYMBOL_GPL(nf_ct_helper_hsize);
 static unsigned int nf_ct_helper_count __read_mostly;
 
-static bool nf_ct_auto_assign_helper __read_mostly = false;
+static bool nf_ct_auto_assign_helper __read_mostly = true;
 module_param_named(nf_conntrack_helper, nf_ct_auto_assign_helper, bool, 0644);
 MODULE_PARM_DESC(nf_conntrack_helper,
 		 "Enable automatic conntrack helper assignment (default 0)");
diff -ruw linux-5.4.60/net/netfilter/nf_conntrack_proto_tcp.c linux-5.4.60-fbx/net/netfilter/nf_conntrack_proto_tcp.c
--- linux-5.4.60/net/netfilter/nf_conntrack_proto_tcp.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/netfilter/nf_conntrack_proto_tcp.c	2021-03-04 13:21:01.467505720 +0100
@@ -1088,7 +1088,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)) {
 		spin_unlock_bh(&ct->lock);
 		return -NF_ACCEPT;
@@ -1163,6 +1164,38 @@
 	return NF_ACCEPT;
 }
 
+#ifdef CONFIG_IP_FFN
+int external_tcpv4_packet(struct nf_conn *ct,
+			  struct sk_buff *skb,
+			  unsigned int dataoff,
+			  enum ip_conntrack_info ctinfo)
+{
+	/* fixme: is is always PRE_ROUTING ?*/
+	struct nf_hook_state state = {
+		.hook = NF_INET_PRE_ROUTING,
+		.pf = AF_INET,
+		.net = nf_ct_net(ct),
+	};
+	return nf_conntrack_tcp_packet(ct, skb, dataoff, ctinfo, &state);
+}
+#endif
+
+#ifdef CONFIG_IPV6_FFN
+int external_tcpv6_packet(struct nf_conn *ct,
+			  struct sk_buff *skb,
+			  unsigned int dataoff,
+			  enum ip_conntrack_info ctinfo)
+{
+	/* fixme: is is always PRE_ROUTING ?*/
+	struct nf_hook_state state = {
+		.hook = NF_INET_PRE_ROUTING,
+		.pf = AF_INET6,
+		.net = nf_ct_net(ct),
+	};
+	return nf_conntrack_tcp_packet(ct, skb, dataoff, ctinfo, &state);
+}
+#endif
+
 static bool tcp_can_early_drop(const struct nf_conn *ct)
 {
 	switch (ct->proto.tcp.state) {
diff -ruw linux-5.4.60/net/netfilter/nf_conntrack_proto_udp.c linux-5.4.60-fbx/net/netfilter/nf_conntrack_proto_udp.c
--- linux-5.4.60/net/netfilter/nf_conntrack_proto_udp.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/netfilter/nf_conntrack_proto_udp.c	2021-03-04 13:21:01.467505720 +0100
@@ -122,6 +122,38 @@
 	return NF_ACCEPT;
 }
 
+#ifdef CONFIG_IP_FFN
+int external_udpv4_packet(struct nf_conn *ct,
+			  struct sk_buff *skb,
+			  unsigned int dataoff,
+			  enum ip_conntrack_info ctinfo)
+{
+	/* fixme: is is always PRE_ROUTING ?*/
+	struct nf_hook_state state = {
+		.hook = NF_INET_PRE_ROUTING,
+		.pf = AF_INET,
+		.net = nf_ct_net(ct),
+	};
+	return nf_conntrack_udp_packet(ct, skb, dataoff, ctinfo, &state);
+}
+#endif
+
+#ifdef CONFIG_IPV6_FFN
+int external_udpv6_packet(struct nf_conn *ct,
+			  struct sk_buff *skb,
+			  unsigned int dataoff,
+			  enum ip_conntrack_info ctinfo)
+{
+	/* fixme: is is always PRE_ROUTING ?*/
+	struct nf_hook_state state = {
+		.hook = NF_INET_PRE_ROUTING,
+		.pf = AF_INET6,
+		.net = nf_ct_net(ct),
+	};
+	return nf_conntrack_udp_packet(ct, skb, dataoff, ctinfo, &state);
+}
+#endif
+
 #ifdef CONFIG_NF_CT_PROTO_UDPLITE
 static void udplite_error_log(const struct sk_buff *skb,
 			      const struct nf_hook_state *state,
diff -ruw linux-5.4.60/net/netfilter/nf_conntrack_sip.c linux-5.4.60-fbx/net/netfilter/nf_conntrack_sip.c
--- linux-5.4.60/net/netfilter/nf_conntrack_sip.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/netfilter/nf_conntrack_sip.c	2021-03-04 13:21:01.467505720 +0100
@@ -35,6 +35,8 @@
 MODULE_ALIAS("ip_conntrack_sip");
 MODULE_ALIAS_NFCT_HELPER(HELPER_NAME);
 
+#define MAX_CALLS	8
+
 #define MAX_PORTS	8
 static unsigned short ports[MAX_PORTS];
 static unsigned int ports_c;
@@ -825,7 +827,8 @@
 	return found;
 }
 
-static void flush_expectations(struct nf_conn *ct, bool media)
+static void __flush_expectations(struct nf_conn *ct, bool media,
+				 const u8 *cid_hash)
 {
 	struct nf_conn_help *help = nfct_help(ct);
 	struct nf_conntrack_expect *exp;
@@ -835,6 +838,15 @@
 	hlist_for_each_entry_safe(exp, next, &help->expectations, lnode) {
 		if ((exp->class != SIP_EXPECT_SIGNALLING) ^ media)
 			continue;
+		if (media && cid_hash) {
+			const struct nf_ct_sip_expect *exp_sip_info;
+			exp_sip_info = nf_ct_exp_data(exp);
+
+			if (memcmp(exp_sip_info->cid_hash, cid_hash,
+				   sizeof (exp_sip_info->cid_hash)))
+				continue;
+		}
+
 		if (!nf_ct_remove_expect(exp))
 			continue;
 		if (!media)
@@ -843,12 +855,36 @@
 	spin_unlock_bh(&nf_conntrack_expect_lock);
 }
 
+static void flush_sig_expectations(struct nf_conn *ct)
+{
+	return __flush_expectations(ct, false, NULL);
+}
+
+static void flush_media_expectations(struct nf_conn *ct,
+				     const char *msg_data,
+				     unsigned int msg_len)
+{
+	unsigned int matchoff, matchlen;
+	u8 cid_hash[SHA256_DIGEST_SIZE];
+	struct sha256_state s;
+
+	sha256_init(&s);
+	if (ct_sip_get_header(ct, msg_data, 0, msg_len,
+			      SIP_HDR_CALL_ID,
+			      &matchoff, &matchlen) > 0)
+		sha256_update(&s, msg_data + matchoff, matchlen);
+	sha256_final(&s, cid_hash);
+
+	__flush_expectations(ct, true, cid_hash);
+}
+
 static int set_expected_rtp_rtcp(struct sk_buff *skb, unsigned int protoff,
 				 unsigned int dataoff,
 				 const char **dptr, unsigned int *datalen,
 				 union nf_inet_addr *daddr, __be16 port,
 				 enum sip_expectation_classes class,
-				 unsigned int mediaoff, unsigned int medialen)
+				 unsigned int mediaoff, unsigned int medialen,
+				 const u8 *cid_hash)
 {
 	struct nf_conntrack_expect *exp, *rtp_exp, *rtcp_exp;
 	enum ip_conntrack_info ctinfo;
@@ -861,6 +897,7 @@
 	u_int16_t base_port;
 	__be16 rtp_port, rtcp_port;
 	const struct nf_nat_sip_hooks *hooks;
+	struct nf_ct_sip_expect *exp_sip_info;
 
 	saddr = NULL;
 	if (sip_direct_media) {
@@ -953,18 +990,29 @@
 			goto err1;
 	}
 
-	if (skip_expect)
+	if (skip_expect) {
+		exp_sip_info = nf_ct_exp_data(exp);
+		memcpy(exp_sip_info->cid_hash, cid_hash,
+		       sizeof (exp_sip_info->cid_hash));
 		return NF_ACCEPT;
+	}
 
 	rtp_exp = nf_ct_expect_alloc(ct);
 	if (rtp_exp == NULL)
 		goto err1;
+	exp_sip_info = nf_ct_exp_data(rtp_exp);
+	memcpy(exp_sip_info->cid_hash, cid_hash,
+	       sizeof (exp_sip_info->cid_hash));
 	nf_ct_expect_init(rtp_exp, class, nf_ct_l3num(ct), saddr, daddr,
 			  IPPROTO_UDP, NULL, &rtp_port);
 
+
 	rtcp_exp = nf_ct_expect_alloc(ct);
 	if (rtcp_exp == NULL)
 		goto err2;
+	exp_sip_info = nf_ct_exp_data(rtcp_exp);
+	memcpy(exp_sip_info->cid_hash, cid_hash,
+	       sizeof (exp_sip_info->cid_hash));
 	nf_ct_expect_init(rtcp_exp, class, nf_ct_l3num(ct), saddr, daddr,
 			  IPPROTO_UDP, NULL, &rtcp_port);
 
@@ -1039,10 +1087,20 @@
 	const struct nf_nat_sip_hooks *hooks;
 	unsigned int port;
 	const struct sdp_media_type *t;
+	struct sha256_state s;
+	u8 cid_hash[SHA256_DIGEST_SIZE];
 	int ret = NF_ACCEPT;
 
 	hooks = rcu_dereference(nf_nat_sip_hooks);
 
+	/* extract caller id if any */
+	sha256_init(&s);
+	if (ct_sip_get_header(ct, *dptr, 0, *datalen,
+			      SIP_HDR_CALL_ID,
+			      &matchoff, &matchlen) > 0)
+		sha256_update(&s, *dptr + matchoff, matchlen);
+	sha256_final(&s, cid_hash);
+
 	/* Find beginning of session description */
 	if (ct_sip_get_sdp_header(ct, *dptr, 0, *datalen,
 				  SDP_HDR_VERSION, SDP_HDR_UNSPEC,
@@ -1101,7 +1159,7 @@
 		ret = set_expected_rtp_rtcp(skb, protoff, dataoff,
 					    dptr, datalen,
 					    &rtp_addr, htons(port), t->class,
-					    mediaoff, medialen);
+					    mediaoff, medialen, cid_hash);
 		if (ret != NF_ACCEPT) {
 			nf_ct_helper_log(skb, ct,
 					 "cannot add expectation for voice");
@@ -1145,7 +1203,7 @@
 	    (code >= 200 && code <= 299))
 		return process_sdp(skb, protoff, dataoff, dptr, datalen, cseq);
 	else if (ct_sip_info->invite_cseq == cseq)
-		flush_expectations(ct, true);
+		flush_media_expectations(ct, *dptr, *datalen);
 	return NF_ACCEPT;
 }
 
@@ -1162,7 +1220,7 @@
 	    (code >= 200 && code <= 299))
 		return process_sdp(skb, protoff, dataoff, dptr, datalen, cseq);
 	else if (ct_sip_info->invite_cseq == cseq)
-		flush_expectations(ct, true);
+		flush_media_expectations(ct, *dptr, *datalen);
 	return NF_ACCEPT;
 }
 
@@ -1179,7 +1237,7 @@
 	    (code >= 200 && code <= 299))
 		return process_sdp(skb, protoff, dataoff, dptr, datalen, cseq);
 	else if (ct_sip_info->invite_cseq == cseq)
-		flush_expectations(ct, true);
+		flush_media_expectations(ct, *dptr, *datalen);
 	return NF_ACCEPT;
 }
 
@@ -1193,7 +1251,7 @@
 	struct nf_ct_sip_master *ct_sip_info = nfct_help_data(ct);
 	unsigned int ret;
 
-	flush_expectations(ct, true);
+	flush_media_expectations(ct, *dptr, *datalen);
 	ret = process_sdp(skb, protoff, dataoff, dptr, datalen, cseq);
 	if (ret == NF_ACCEPT)
 		ct_sip_info->invite_cseq = cseq;
@@ -1208,7 +1266,7 @@
 	enum ip_conntrack_info ctinfo;
 	struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
 
-	flush_expectations(ct, true);
+	flush_media_expectations(ct, *dptr, *datalen);
 	return NF_ACCEPT;
 }
 
@@ -1387,7 +1445,7 @@
 	}
 
 flush:
-	flush_expectations(ct, false);
+	flush_sig_expectations(ct);
 	return NF_ACCEPT;
 }
 
@@ -1642,17 +1700,17 @@
 	},
 	[SIP_EXPECT_AUDIO] = {
 		.name		= "audio",
-		.max_expected	= 2 * IP_CT_DIR_MAX,
+		.max_expected	= MAX_CALLS * 2 * IP_CT_DIR_MAX,
 		.timeout	= 3 * 60,
 	},
 	[SIP_EXPECT_VIDEO] = {
 		.name		= "video",
-		.max_expected	= 2 * IP_CT_DIR_MAX,
+		.max_expected	= MAX_CALLS * 2 * IP_CT_DIR_MAX,
 		.timeout	= 3 * 60,
 	},
 	[SIP_EXPECT_IMAGE] = {
 		.name		= "image",
-		.max_expected	= IP_CT_DIR_MAX,
+		.max_expected	= MAX_CALLS * IP_CT_DIR_MAX,
 		.timeout	= 3 * 60,
 	},
 };
@@ -1667,6 +1725,7 @@
 	int i, ret;
 
 	NF_CT_HELPER_BUILD_BUG_ON(sizeof(struct nf_ct_sip_master));
+	NF_CT_EXPECT_BUILD_BUG_ON(sizeof(struct nf_ct_sip_expect));
 
 	if (ports_c == 0)
 		ports[ports_c++] = SIP_PORT;
diff -ruw linux-5.4.60/net/netfilter/nf_nat_core.c linux-5.4.60-fbx/net/netfilter/nf_nat_core.c
--- linux-5.4.60/net/netfilter/nf_nat_core.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/netfilter/nf_nat_core.c	2021-03-04 13:21:01.470839054 +0100
@@ -661,6 +661,11 @@
 	else
 		ct->status |= IPS_SRC_NAT_DONE;
 
+	if (maniptype == NF_NAT_MANIP_SRC) {
+		ct->nat_src_proto_min = range->min_proto;
+		ct->nat_src_proto_max = range->max_proto;
+	}
+
 	return NF_ACCEPT;
 }
 EXPORT_SYMBOL(nf_nat_setup_info);
diff -ruw linux-5.4.60/net/netfilter/nf_nat_ftp.c linux-5.4.60-fbx/net/netfilter/nf_nat_ftp.c
--- linux-5.4.60/net/netfilter/nf_nat_ftp.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/netfilter/nf_nat_ftp.c	2021-03-04 13:21:01.470839054 +0100
@@ -69,7 +69,8 @@
 			       struct nf_conntrack_expect *exp)
 {
 	union nf_inet_addr newaddr;
-	u_int16_t port;
+	u_int16_t port, sport, eport;
+	unsigned int i;
 	int dir = CTINFO2DIR(ctinfo);
 	struct nf_conn *ct = exp->master;
 	char buffer[sizeof("|1||65535|") + INET6_ADDRSTRLEN];
@@ -86,8 +87,26 @@
 	 * this one. */
 	exp->expectfn = nf_nat_follow_master;
 
+	if (dir == IP_CT_DIR_ORIGINAL &&
+	    (ct->status & IPS_SRC_NAT) &&
+	    ct->nat_src_proto_min.all &&
+	    ct->nat_src_proto_max.all) {
+		sport = ntohs(ct->nat_src_proto_min.all);
+		eport = ntohs(ct->nat_src_proto_max.all);
+	} else {
+		sport = 1024;
+		eport = 65535;
+	}
+
+	port = ntohs(exp->saved_proto.tcp.port);
+	if (port < sport || port > eport) {
+		get_random_bytes(&port, sizeof (port));
+		port %= eport - sport;
+		port += sport;
+	}
+
 	/* Try to get same port: if not, try to change it. */
-	for (port = ntohs(exp->saved_proto.tcp.port); port != 0; port++) {
+	for (i = 0; i < eport - sport + 1; i++) {
 		int ret;
 
 		exp->tuple.dst.u.tcp.port = htons(port);
@@ -98,6 +117,10 @@
 			port = 0;
 			break;
 		}
+
+		port++;
+		if (port > eport)
+			port = sport;
 	}
 
 	if (port == 0) {
diff -ruw linux-5.4.60/net/netfilter/nf_nat_helper.c linux-5.4.60-fbx/net/netfilter/nf_nat_helper.c
--- linux-5.4.60/net/netfilter/nf_nat_helper.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/netfilter/nf_nat_helper.c	2021-03-04 13:21:01.470839054 +0100
@@ -188,6 +188,14 @@
 	range.flags = NF_NAT_RANGE_MAP_IPS;
 	range.min_addr = range.max_addr
 		= ct->master->tuplehash[!exp->dir].tuple.dst.u3;
+
+	if (ct->master->nat_src_proto_min.all &&
+	    ct->master->nat_src_proto_max.all) {
+		range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
+		range.min_proto = ct->master->nat_src_proto_min;
+		range.max_proto = ct->master->nat_src_proto_max;
+	}
+
 	nf_nat_setup_info(ct, &range, NF_NAT_MANIP_SRC);
 
 	/* For DST manip, map port here to where it's expected. */
diff -ruw linux-5.4.60/net/netfilter/nf_nat_proto.c linux-5.4.60-fbx/net/netfilter/nf_nat_proto.c
--- linux-5.4.60/net/netfilter/nf_nat_proto.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/netfilter/nf_nat_proto.c	2021-03-04 13:21:01.470839054 +0100
@@ -385,6 +385,8 @@
 {
 #if IS_ENABLED(CONFIG_IPV6)
 	struct ipv6hdr *ipv6h;
+	const __be32 *to;
+	__be32 *from;
 	__be16 frag_off;
 	int hdroff;
 	u8 nexthdr;
@@ -407,10 +409,24 @@
 	ipv6h = (void *)skb->data + iphdroff;
 
 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));
 
 #endif
 	return true;
diff -ruw linux-5.4.60/net/netfilter/nf_nat_sip.c linux-5.4.60-fbx/net/netfilter/nf_nat_sip.c
--- linux-5.4.60/net/netfilter/nf_nat_sip.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/netfilter/nf_nat_sip.c	2021-03-04 13:21:01.470839054 +0100
@@ -365,6 +365,15 @@
 		range_set_for_snat = 1;
 	}
 
+	if (range_set_for_snat) {
+		if (ct->master->nat_src_proto_min.all &&
+		    ct->master->nat_src_proto_max.all) {
+			range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
+			range.min_proto = ct->master->nat_src_proto_min;
+			range.max_proto = ct->master->nat_src_proto_max;
+		}
+	}
+
 	/* Perform SRC manip. */
 	if (range_set_for_snat)
 		nf_nat_setup_info(ct, &range, NF_NAT_MANIP_SRC);
@@ -382,10 +391,11 @@
 	enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
 	struct nf_ct_sip_master *ct_sip_info = nfct_help_data(ct);
 	union nf_inet_addr newaddr;
-	u_int16_t port;
+	u_int16_t port, sport, eport;
 	__be16 srcport;
 	char buffer[INET6_ADDRSTRLEN + sizeof("[]:nnnnn")];
 	unsigned int buflen;
+	unsigned int i;
 
 	/* Connection will come from reply */
 	if (nf_inet_addr_cmp(&ct->tuplehash[dir].tuple.src.u3,
@@ -410,7 +420,24 @@
 	exp->dir = !dir;
 	exp->expectfn = nf_nat_sip_expected;
 
-	for (; port != 0; port++) {
+	if (dir == IP_CT_DIR_ORIGINAL &&
+	    (ct->status & IPS_SRC_NAT) &&
+	    ct->nat_src_proto_min.all &&
+	    ct->nat_src_proto_max.all) {
+		sport = ntohs(ct->nat_src_proto_min.all);
+		eport = ntohs(ct->nat_src_proto_max.all);
+	} else {
+		sport = 1024;
+		eport = 65535;
+	}
+
+	if (port < sport || port > eport) {
+		get_random_bytes(&port, sizeof (port));
+		port %= eport - sport;
+		port += sport;
+	}
+
+	for (i = 0; i < eport - sport + 1; i++) {
 		int ret;
 
 		exp->tuple.dst.u.udp.port = htons(port);
@@ -421,6 +448,10 @@
 			port = 0;
 			break;
 		}
+
+		port++;
+		if (port > eport)
+			port = sport;
 	}
 
 	if (port == 0) {
@@ -580,7 +611,8 @@
 	enum ip_conntrack_info ctinfo;
 	struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
 	enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
-	u_int16_t port;
+	u_int16_t port, sport, eport;
+	unsigned int i;
 
 	/* Connection will come from reply */
 	if (nf_inet_addr_cmp(&ct->tuplehash[dir].tuple.src.u3,
@@ -601,17 +633,37 @@
 	rtcp_exp->dir = !dir;
 	rtcp_exp->expectfn = nf_nat_sip_expected;
 
+	if (dir == IP_CT_DIR_ORIGINAL &&
+	    (ct->status & IPS_SRC_NAT) &&
+	    ct->nat_src_proto_min.all &&
+	    ct->nat_src_proto_max.all) {
+		sport = ntohs(ct->nat_src_proto_min.all);
+		eport = ntohs(ct->nat_src_proto_max.all);
+	} else {
+		sport = 1024;
+		eport = 65535;
+	}
+
+	port = ntohs(rtp_exp->tuple.dst.u.udp.port);
+	if (port < sport || port > eport - 1) {
+		get_random_bytes(&port, sizeof (port));
+		port %= eport - sport;
+		port += sport;
+	}
+
 	/* Try to get same pair of ports: if not, try to change them. */
-	for (port = ntohs(rtp_exp->tuple.dst.u.udp.port);
-	     port != 0; port += 2) {
+	for (i = 0; i < eport - sport + 1; i += 2) {
 		int ret;
 
 		rtp_exp->tuple.dst.u.udp.port = htons(port);
 		ret = nf_ct_expect_related(rtp_exp,
 					   NF_CT_EXP_F_SKIP_MASTER);
-		if (ret == -EBUSY)
+		if (ret == -EBUSY) {
+			port += 2;
+			if (port > eport)
+				port = sport;
 			continue;
-		else if (ret < 0) {
+		} else if (ret < 0) {
 			port = 0;
 			break;
 		}
@@ -622,12 +674,19 @@
 			break;
 		else if (ret == -EBUSY) {
 			nf_ct_unexpect_related(rtp_exp);
+			port += 2;
+			if (port > eport)
+				port = sport;
 			continue;
 		} else if (ret < 0) {
 			nf_ct_unexpect_related(rtp_exp);
 			port = 0;
 			break;
 		}
+
+		port += 2;
+		if (port > eport)
+			port = sport;
 	}
 
 	if (port == 0) {
diff -ruw linux-5.4.60/net/sched/sch_drr.c linux-5.4.60-fbx/net/sched/sch_drr.c
--- linux-5.4.60/net/sched/sch_drr.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/sched/sch_drr.c	2021-03-04 13:21:01.500839054 +0100
@@ -334,7 +334,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-5.4.60/net/socket.c linux-5.4.60-fbx/net/socket.c
--- linux-5.4.60/net/socket.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/socket.c	2021-03-04 13:21:01.514172389 +0100
@@ -1066,6 +1066,29 @@
 	return err;
 }
 
+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);
+}
+
+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);
+
 /*
  *	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.
@@ -1165,6 +1188,17 @@
 
 			err = open_related_ns(&net->ns, get_net_ns);
 			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 SIOCGSTAMP_OLD:
 		case SIOCGSTAMPNS_OLD:
 			if (!sock->ops->gettstamp) {
@@ -1185,6 +1219,17 @@
 						   cmd == SIOCGSTAMP_NEW,
 						   false);
 			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-5.4.60/net/unix/af_unix.c linux-5.4.60-fbx/net/unix/af_unix.c
--- linux-5.4.60/net/unix/af_unix.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/unix/af_unix.c	2021-03-04 13:21:01.524172389 +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-5.4.60/net/unix/Kconfig linux-5.4.60-fbx/net/unix/Kconfig
--- linux-5.4.60/net/unix/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/unix/Kconfig	2021-03-04 13:21:01.524172389 +0100
@@ -25,6 +25,9 @@
 	depends on UNIX
 	default y
 
+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-5.4.60/net/wireless/core.h linux-5.4.60-fbx/net/wireless/core.h
--- linux-5.4.60/net/wireless/core.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/wireless/core.h	2021-03-04 13:21:01.527505723 +0100
@@ -331,6 +331,12 @@
 			 struct net_device *dev,
 			 struct mesh_setup *setup,
 			 const struct mesh_config *conf);
+int cfg80211_update_mesh_vendor_node_metrics_ie(struct cfg80211_registered_device *rdev,
+						struct net_device *dev,
+						struct mesh_vendor_ie *vendor_ie);
+int cfg80211_update_mesh_vendor_path_metrics_ie(struct cfg80211_registered_device *rdev,
+                                   struct net_device *dev,
+                                   struct mesh_vendor_ie *vendor_ie);
 int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev,
 			  struct net_device *dev);
 int cfg80211_leave_mesh(struct cfg80211_registered_device *rdev,
diff -ruw linux-5.4.60/net/wireless/mesh.c linux-5.4.60-fbx/net/wireless/mesh.c
--- linux-5.4.60/net/wireless/mesh.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/wireless/mesh.c	2021-03-04 13:21:01.527505723 +0100
@@ -217,6 +217,34 @@
 	return err;
 }
 
+int cfg80211_update_mesh_vendor_node_metrics_ie(struct cfg80211_registered_device *rdev,
+				   struct net_device *dev,
+				   struct mesh_vendor_ie *vendor_ie)
+{
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+	int err;
+
+	wdev_lock(wdev);
+	err = rdev_update_mesh_vendor_node_metrics_ie(rdev, dev, vendor_ie);
+	wdev_unlock(wdev);
+
+	return err;
+}
+
+int cfg80211_update_mesh_vendor_path_metrics_ie(struct cfg80211_registered_device *rdev,
+						struct net_device *dev,
+						struct mesh_vendor_ie *vendor_ie)
+{
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+	int err;
+
+	wdev_lock(wdev);
+	err = rdev_update_mesh_vendor_path_metrics_ie(rdev, dev, vendor_ie);
+	wdev_unlock(wdev);
+
+	return err;
+}
+
 int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev,
 			      struct wireless_dev *wdev,
 			      struct cfg80211_chan_def *chandef)
diff -ruw linux-5.4.60/net/wireless/nl80211.c linux-5.4.60-fbx/net/wireless/nl80211.c
--- linux-5.4.60/net/wireless/nl80211.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/wireless/nl80211.c	2021-03-04 13:21:01.530839056 +0100
@@ -6407,6 +6407,51 @@
 	return err;
 }
 
+static int nl80211_set_mpp(struct sk_buff *skb, struct genl_info *info)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct net_device *dev = info->user_ptr[1];
+	u8 *dst = NULL;
+	u8 *next_hop = NULL;
+
+	if (!info->attrs[NL80211_ATTR_MAC])
+		return -EINVAL;
+
+	if (!info->attrs[NL80211_ATTR_MPATH_NEXT_HOP])
+		return -EINVAL;
+
+	dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
+	next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]);
+
+	if (!rdev->ops->update_mpp)
+		return -EOPNOTSUPP;
+
+	if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT)
+		return -EOPNOTSUPP;
+
+	return rdev_update_mpp(rdev, dev, dst, next_hop);
+}
+
+static int nl80211_del_mpp(struct sk_buff *skb, struct genl_info *info)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct net_device *dev = info->user_ptr[1];
+	u8 *dst;
+
+	if (!info->attrs[NL80211_ATTR_MAC])
+		return -EINVAL;
+
+	if (!rdev->ops->delete_mpp)
+		return -EOPNOTSUPP;
+
+	if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT)
+		return -EOPNOTSUPP;
+
+	dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
+
+	return rdev_delete_mpp(rdev, dev, dst);
+}
+
 static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
 {
 	struct cfg80211_registered_device *rdev = info->user_ptr[0];
@@ -12906,8 +12951,30 @@
 	struct cfg80211_registered_device *rdev = info->user_ptr[0];
 	struct wireless_dev *wdev =
 		__cfg80211_wdev_from_attrs(genl_info_net(info), info->attrs);
-	int i, err;
+	int i, err = 0;
 	u32 vid, subcmd;
+	struct net_device *dev = wdev->netdev;
+	struct mesh_vendor_ie mv_ie;
+	struct nlattr *ieattr;
+	u8 type;
+
+
+	if (wdev->iftype == NL80211_IFTYPE_MESH_POINT) {
+		if (info->attrs[NL80211_ATTR_VENDOR_DATA] &&
+			info->attrs[NL80211_ATTR_VENDOR_SUBCMD]) {
+			if (!info->attrs[NL80211_ATTR_VENDOR_DATA])
+				return -EINVAL;
+			ieattr = info->attrs[NL80211_ATTR_VENDOR_DATA];
+			mv_ie.ie = nla_data(ieattr);
+			mv_ie.ie_len = nla_len(ieattr);
+			type = nla_get_u32(info->attrs[NL80211_ATTR_VENDOR_SUBCMD]);
+			if (type == NL80211_QBC_UPDATE_NODE_METRICS_IE)
+				err = cfg80211_update_mesh_vendor_node_metrics_ie(rdev, dev, &mv_ie);
+			else if (type == NL80211_QBC_UPDATE_PATH_METRICS_IE)
+				err = cfg80211_update_mesh_vendor_path_metrics_ie(rdev, dev, &mv_ie);
+			return err;
+		}
+	}
 
 	if (!rdev->wiphy.vendor_commands)
 		return -EOPNOTSUPP;
@@ -14085,6 +14152,20 @@
 				  NL80211_FLAG_NEED_RTNL,
 	},
 	{
+		.cmd = NL80211_CMD_SET_MPP,
+		.doit = nl80211_set_mpp,
+		.flags = GENL_UNS_ADMIN_PERM,
+		.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
+				  NL80211_FLAG_NEED_RTNL,
+	},
+	{
+		.cmd = NL80211_CMD_DEL_MPP,
+		.doit = nl80211_del_mpp,
+		.flags = GENL_UNS_ADMIN_PERM,
+		.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
+				  NL80211_FLAG_NEED_RTNL,
+	},
+	{
 		.cmd = NL80211_CMD_SET_BSS,
 		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 		.doit = nl80211_set_bss,
@@ -15473,6 +15554,94 @@
 }
 EXPORT_SYMBOL(cfg80211_notify_new_peer_candidate);
 
+void cfg80211_notify_mesh_peer_path_metrics(struct net_device *dev, const u8 *macaddr,
+				       const u8 *ie, u8 ie_len, gfp_t gfp)
+{
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
+	struct sk_buff *msg;
+	void *hdr;
+
+	if (WARN_ON(wdev->iftype != NL80211_IFTYPE_MESH_POINT))
+		return;
+
+	msg = nlmsg_new(100 + ie_len, gfp);
+	if (!msg)
+		return;
+
+	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_MESH_PEER_PATH_METRICS);
+	if (!hdr) {
+		nlmsg_free(msg);
+		return;
+	}
+
+	if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+	    nla_put_string(msg, NL80211_ATTR_IFNAME, dev->name) ||
+	    nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
+	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, macaddr) ||
+	    (ie_len && ie &&
+	     nla_put(msg, NL80211_ATTR_IE, ie_len , ie)))
+		goto nla_put_failure;
+
+	genlmsg_end(msg, hdr);
+
+	genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
+				NL80211_MCGRP_MLME, gfp);
+	return;
+
+ nla_put_failure:
+	genlmsg_cancel(msg, hdr);
+	nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_notify_mesh_peer_path_metrics);
+
+
+void cfg80211_notify_mesh_peer_node_metrics(struct net_device *dev,
+                                      const u8 *macaddr, u16 stype, s8 signal,
+                                      u32 beacon_int, const u8 *ie, u8 ie_len, gfp_t gfp)
+{
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
+	struct sk_buff *msg;
+	void *hdr;
+
+	if (WARN_ON(wdev->iftype != NL80211_IFTYPE_MESH_POINT))
+		return;
+
+	msg = nlmsg_new(100 + ie_len, gfp);
+	if (!msg)
+		return;
+
+	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_MESH_PEER_NODE_METRICS);
+	if (!hdr) {
+		nlmsg_free(msg);
+		return;
+	}
+
+	if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+	    nla_put_string(msg, NL80211_ATTR_IFNAME, dev->name) ||
+	    nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
+	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, macaddr) ||
+	    nla_put_u16(msg, NL80211_ATTR_FRAME_TYPE, stype) ||
+	    nla_put_s8(msg, NL80211_ATTR_SIGNAL_STRENGTH, signal) ||
+	    nla_put_u32(msg, NL80211_ATTR_BEACON_INTERVAL, beacon_int) ||
+	    (ie_len && ie &&
+	     nla_put(msg, NL80211_ATTR_IE, ie_len , ie)))
+		goto nla_put_failure;
+
+	genlmsg_end(msg, hdr);
+
+	genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
+				NL80211_MCGRP_MLME, gfp);
+	return;
+
+ nla_put_failure:
+	genlmsg_cancel(msg, hdr);
+	nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_notify_mesh_peer_node_metrics);
+
+
 void nl80211_michael_mic_failure(struct cfg80211_registered_device *rdev,
 				 struct net_device *netdev, const u8 *addr,
 				 enum nl80211_key_type key_type, int key_id,
diff -ruw linux-5.4.60/net/wireless/rdev-ops.h linux-5.4.60-fbx/net/wireless/rdev-ops.h
--- linux-5.4.60/net/wireless/rdev-ops.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/wireless/rdev-ops.h	2021-03-04 13:21:01.530839056 +0100
@@ -278,6 +278,28 @@
 	return ret;
 }
 
+static inline int rdev_update_mpp(struct cfg80211_registered_device *rdev,
+				 struct net_device *dev, u8 *dst, u8 *next_hop)
+{
+	int ret;
+
+	trace_rdev_update_mpp(&rdev->wiphy, dev, dst, next_hop);
+	ret = rdev->ops->update_mpp(&rdev->wiphy, dev, dst, next_hop);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+	return ret;
+}
+
+static inline int rdev_delete_mpp(struct cfg80211_registered_device *rdev,
+				 struct net_device *dev, u8 *dst)
+{
+	int ret;
+
+	trace_rdev_delete_mpp(&rdev->wiphy, dev, dst);
+	ret = rdev->ops->delete_mpp(&rdev->wiphy, dev, dst);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+	return ret;
+}
+
 static inline int rdev_dump_mpath(struct cfg80211_registered_device *rdev,
 				  struct net_device *dev, int idx, u8 *dst,
 				  u8 *next_hop, struct mpath_info *pinfo)
@@ -339,6 +361,23 @@
 	return ret;
 }
 
+static inline int rdev_update_mesh_vendor_node_metrics_ie(struct cfg80211_registered_device *rdev,
+							  struct net_device *dev,
+							  struct mesh_vendor_ie *ie)
+{
+	int ret;
+	ret = rdev->ops->update_mesh_vendor_node_metrics_ie(&rdev->wiphy, dev, ie);
+	return ret;
+}
+
+static inline int rdev_update_mesh_vendor_path_metrics_ie(struct cfg80211_registered_device *rdev,
+							  struct net_device *dev,
+							  struct mesh_vendor_ie *ie)
+{
+	int ret;
+	ret = rdev->ops->update_mesh_vendor_path_metrics_ie(&rdev->wiphy, dev, ie);
+	return ret;
+}
 
 static inline int rdev_leave_mesh(struct cfg80211_registered_device *rdev,
 				  struct net_device *dev)
diff -ruw linux-5.4.60/net/wireless/reg.c linux-5.4.60-fbx/net/wireless/reg.c
--- linux-5.4.60/net/wireless/reg.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/wireless/reg.c	2021-03-04 13:21:01.530839056 +0100
@@ -1761,6 +1761,9 @@
 
 		if (chan->flags & IEEE80211_CHAN_RADAR) {
 			chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS;
+			if (chan->center_freq >= 5600 &&
+			    chan->center_freq <= 5650)
+				chan->dfs_cac_ms = IEEE80211_DFS_WEATHER_MIN_CAC_TIME_MS;
 			if (reg_rule->dfs_cac_ms)
 				chan->dfs_cac_ms = reg_rule->dfs_cac_ms;
 		}
@@ -1781,9 +1784,14 @@
 	if (chan->flags & IEEE80211_CHAN_RADAR) {
 		if (reg_rule->dfs_cac_ms)
 			chan->dfs_cac_ms = reg_rule->dfs_cac_ms;
+		else {
+			if (chan->center_freq >= 5600 &&
+			    chan->center_freq <= 5650)
+				chan->dfs_cac_ms = IEEE80211_DFS_WEATHER_MIN_CAC_TIME_MS;
 		else
 			chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS;
 	}
+	}
 
 	if (chan->orig_mpwr) {
 		/*
diff -ruw linux-5.4.60/net/wireless/trace.h linux-5.4.60-fbx/net/wireless/trace.h
--- linux-5.4.60/net/wireless/trace.h	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/net/wireless/trace.h	2021-03-04 13:21:01.534172390 +0100
@@ -813,6 +813,11 @@
 	TP_ARGS(wiphy, netdev, mac)
 );
 
+DEFINE_EVENT(wiphy_netdev_mac_evt, rdev_delete_mpp,
+	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac),
+	TP_ARGS(wiphy, netdev, mac)
+);
+
 TRACE_EVENT(rdev_dump_station,
 	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int _idx,
 		 u8 *mac),
@@ -888,6 +893,12 @@
 	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst,
 		 u8 *next_hop),
 	TP_ARGS(wiphy, netdev, dst, next_hop)
+);
+
+DEFINE_EVENT(mpath_evt, rdev_update_mpp,
+	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst,
+		 u8 *next_hop),
+	TP_ARGS(wiphy, netdev, dst, next_hop)
 );
 
 TRACE_EVENT(rdev_dump_mpath,
diff -ruw linux-5.4.60/scripts/dtc/include-prefixes/arm/kirkwood-6282.dtsi linux-5.4.60-fbx/scripts/dtc/include-prefixes/arm/kirkwood-6282.dtsi
--- linux-5.4.60/scripts/dtc/include-prefixes/arm/kirkwood-6282.dtsi	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/scripts/dtc/include-prefixes/arm/kirkwood-6282.dtsi	2021-03-04 13:20:56.844172180 +0100
@@ -80,6 +80,11 @@
 				marvell,function = "twsi1";
 			};
 
+			pmx_twsi1_gpio: pmx-twsi1-gpio {
+				marvell,pins = "mpp36", "mpp37";
+				marvell,function = "gpio";
+			};
+
 			pmx_sdio: pmx-sdio {
 				marvell,pins = "mpp12", "mpp13", "mpp14",
 					       "mpp15", "mpp16", "mpp17";
@@ -109,7 +114,10 @@
 			clock-frequency = <100000>;
 			clocks = <&gate_clk 7>;
 			pinctrl-0 = <&pmx_twsi1>;
-			pinctrl-names = "default";
+			pinctrl-1 = <&pmx_twsi1_gpio>;
+			pinctrl-names = "default", "gpio";
+			sda-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
+			scl-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
 			status = "disabled";
 		};
 
diff -ruw linux-5.4.60/scripts/dtc/include-prefixes/arm/kirkwood.dtsi linux-5.4.60-fbx/scripts/dtc/include-prefixes/arm/kirkwood.dtsi
--- linux-5.4.60/scripts/dtc/include-prefixes/arm/kirkwood.dtsi	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/scripts/dtc/include-prefixes/arm/kirkwood.dtsi	2021-03-04 13:20:56.847505513 +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_twsi0_gpio: pmx-twsi0-gpio {
+				marvell,pins = "mpp8", "mpp9";
+				marvell,function = "gpio";
+			};
+
 			/*
 			 * Default UART pinctrl setting without RTS/CTS,
 			 * overwrite marvell,pins on board level if required.
@@ -138,6 +155,17 @@
 			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";
+			status = "disabled";
+		};
+
 		gpio0: gpio@10100 {
 			compatible = "marvell,orion-gpio";
 			#gpio-cells = <2>;
@@ -171,7 +199,10 @@
 			clock-frequency = <100000>;
 			clocks = <&gate_clk 7>;
 			pinctrl-0 = <&pmx_twsi0>;
-			pinctrl-names = "default";
+			pinctrl-1 = <&pmx_twsi0_gpio>;
+			pinctrl-names = "default", "gpio";
+			sda-gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
+			scl-gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
 			status = "disabled";
 		};
 
@@ -319,6 +350,7 @@
 			clocks = <&gate_clk 0>;
 			marvell,tx-checksum-limit = <1600>;
 			status = "disabled";
+			mdio-bus = <&mdio>;
 
 			eth0port: ethernet0-port@0 {
 				compatible = "marvell,kirkwood-eth-port";
diff -ruw linux-5.4.60/scripts/dtc/include-prefixes/arm/Makefile linux-5.4.60-fbx/scripts/dtc/include-prefixes/arm/Makefile
--- linux-5.4.60/scripts/dtc/include-prefixes/arm/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/scripts/dtc/include-prefixes/arm/Makefile	2021-03-04 13:20:56.790838844 +0100
@@ -128,7 +128,9 @@
 	bcm47189-tenda-ac9.dtb \
 	bcm947189acdbmr.dtb
 dtb-$(CONFIG_ARCH_BCM_63XX) += \
-	bcm963138dvt.dtb
+	bcm963138dvt.dtb \
+	bcm963138ref-rnc.dtb \
+	fbxgw7a.dtb
 dtb-$(CONFIG_ARCH_BCM_CYGNUS) += \
 	bcm911360_entphn.dtb \
 	bcm911360k.dtb \
@@ -238,7 +240,7 @@
 	keystone-k2e-evm.dtb \
 	keystone-k2g-evm.dtb \
 	keystone-k2g-ice.dtb
-dtb-$(CONFIG_MACH_KIRKWOOD) += \
+dtb-$(CONFIG_MACH_KIRKWOOD_DTB) += \
 	kirkwood-b3.dtb \
 	kirkwood-blackarmor-nas220.dtb \
 	kirkwood-cloudbox.dtb \
@@ -315,6 +317,8 @@
 	kirkwood-ts219-6282.dtb \
 	kirkwood-ts419-6281.dtb \
 	kirkwood-ts419-6282.dtb
+dtb-$(CONFIG_FBXGW_COMMON) += \
+	fbxgwr_exp_stb.dtb
 dtb-$(CONFIG_ARCH_LPC18XX) += \
 	lpc4337-ciaa.dtb \
 	lpc4350-hitex-eval.dtb \
@@ -1303,3 +1307,17 @@
 	aspeed-bmc-opp-zaius.dtb \
 	aspeed-bmc-portwell-neptune.dtb \
 	aspeed-bmc-quanta-q71l.dtb
+
+$(foreach file, $(subst $\",,$(CONFIG_OF_DTB_BUILTIN_LIST)), \
+		$(eval dtb-y += $(file).dtb))
+
+$(foreach file, $(subst $\",,$(CONFIG_OF_DTB_BUILTIN_LIST)), \
+		$(eval obj-y += $(file).dtb.o))
+
+dtstree		:= $(srctree)/$(src)
+dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts))
+
+DTC_FLAGS	+= -@
+always		:= $(dtb-y)
+clean-files	:= *.dtb *.dtb.S
+obj-		+= dummy
diff -ruw linux-5.4.60/scripts/Makefile.build linux-5.4.60-fbx/scripts/Makefile.build
--- linux-5.4.60/scripts/Makefile.build	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/scripts/Makefile.build	2021-03-04 13:21:01.547505724 +0100
@@ -431,7 +431,7 @@
 # module is turned into a multi object module, $^ will contain header file
 # dependencies recorded in the .*.cmd file.
 quiet_cmd_link_multi-m = LD [M]  $@
-      cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^)
+      cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o %.a,$^)
 
 $(multi-used-m): FORCE
 	$(call if_changed,link_multi-m)
diff -ruw linux-5.4.60/scripts/Makefile.lib linux-5.4.60-fbx/scripts/Makefile.lib
--- linux-5.4.60/scripts/Makefile.lib	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/scripts/Makefile.lib	2021-03-04 13:21:01.547505724 +0100
@@ -256,11 +256,11 @@
 DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
 
 # Generate an assembly file to wrap the output of the device tree compiler
-quiet_cmd_dt_S_dtb= DTB     $@
+quiet_cmd_dt_S_dtb= DTB_bin $@
 cmd_dt_S_dtb=						\
 {							\
 	echo '\#include <asm-generic/vmlinux.lds.h>'; 	\
-	echo '.section .dtb.init.rodata,"a"';		\
+	echo '.section .dtb.rodata,"a"';		\
 	echo '.balign STRUCT_ALIGNMENT';		\
 	echo '.global __dtb_$(subst -,_,$(*F))_begin';	\
 	echo '__dtb_$(subst -,_,$(*F))_begin:';		\
@@ -273,6 +273,8 @@
 $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
 	$(call if_changed,dt_S_dtb)
 
+.PRECIOUS: $(src)/%.dtb.S
+
 quiet_cmd_dtc = DTC     $@
 cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
 	$(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
diff -ruw linux-5.4.60/sound/soc/codecs/cs42l52.c linux-5.4.60-fbx/sound/soc/codecs/cs42l52.c
--- linux-5.4.60/sound/soc/codecs/cs42l52.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/sound/soc/codecs/cs42l52.c	2021-03-04 13:21:01.664172395 +0100
@@ -127,19 +127,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 DECLARE_TLV_DB_RANGE(limiter_tlv,
 	0, 2, TLV_DB_SCALE_ITEM(-3000, 600, 0),
@@ -340,18 +346,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),
 
@@ -364,7 +370,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),
 
@@ -372,7 +378,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,
@@ -392,15 +398,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",
@@ -571,8 +577,8 @@
 	{"ADC Left", NULL, "Charge Pump"},
 	{"ADC Right", NULL, "Charge Pump"},
 
-	{"Charge Pump", NULL, "ADC Left Mux"},
-	{"Charge Pump", NULL, "ADC Right Mux"},
+	{"ADC Left Mux", NULL, "Charge Pump"},
+	{"ADC Right Mux", NULL, "Charge Pump"},
 
 	{"ADC Left Mux", "Input1A", "AIN1L"},
 	{"ADC Right Mux", "Input1B", "AIN1R"},
@@ -585,19 +591,19 @@
 	{"ADC Left Mux", "PGA Input Left", "PGA Left"},
 	{"ADC Right Mux", "PGA Input Right" , "PGA Right"},
 
-	{"PGA Left", "Switch", "AIN1L"},
-	{"PGA Right", "Switch", "AIN1R"},
-	{"PGA Left", "Switch", "AIN2L"},
-	{"PGA Right", "Switch", "AIN2R"},
-	{"PGA Left", "Switch", "AIN3L"},
-	{"PGA Right", "Switch", "AIN3R"},
-	{"PGA Left", "Switch", "AIN4L"},
-	{"PGA Right", "Switch", "AIN4R"},
+	{"PGA Left", NULL, "AIN1L"},
+	{"PGA Right", NULL, "AIN1R"},
+	{"PGA Left", NULL, "AIN2L"},
+	{"PGA Right", NULL, "AIN2R"},
+	{"PGA Left", NULL, "AIN3L"},
+	{"PGA Right", NULL, "AIN3R"},
+	{"PGA Left", NULL, "AIN4L"},
+	{"PGA Right", NULL, "AIN4R"},
 
-	{"PGA Left", "Switch", "PGA MICA"},
+	{"PGA Left", NULL, "PGA MICA"},
 	{"PGA MICA", NULL, "MICA"},
 
-	{"PGA Right", "Switch", "PGA MICB"},
+	{"PGA Right", NULL, "PGA MICB"},
 	{"PGA MICB", NULL, "MICB"},
 
 	{"HPOUTA", NULL, "HP Left Amp"},
@@ -842,14 +848,12 @@
 		break;
 	case SND_SOC_BIAS_STANDBY:
 		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
-			regcache_cache_only(cs42l52->regmap, false);
 			regcache_sync(cs42l52->regmap);
 		}
 		snd_soc_component_write(component, CS42L52_PWRCTL1, CS42L52_PWRCTL1_PDN_ALL);
 		break;
 	case SND_SOC_BIAS_OFF:
 		snd_soc_component_write(component, CS42L52_PWRCTL1, CS42L52_PWRCTL1_PDN_ALL);
-		regcache_cache_only(cs42l52->regmap, true);
 		break;
 	}
 
@@ -1027,8 +1031,6 @@
 {
 	struct cs42l52_private *cs42l52 = snd_soc_component_get_drvdata(component);
 
-	regcache_cache_only(cs42l52->regmap, true);
-
 	cs42l52_add_mic_controls(component);
 
 	cs42l52_init_beep(component);
@@ -1090,6 +1092,7 @@
 {
 	struct cs42l52_private *cs42l52;
 	struct cs42l52_platform_data *pdata = dev_get_platdata(&i2c_client->dev);
+	struct gpio_desc *reset;
 	int ret;
 	unsigned int devid = 0;
 	unsigned int reg;
@@ -1130,26 +1133,26 @@
 			if (of_property_read_u32(i2c_client->dev.of_node,
 				"cirrus,chgfreq-divisor", &val32) >= 0)
 				pdata->chgfreq = val32;
-
-			pdata->reset_gpio =
-				of_get_named_gpio(i2c_client->dev.of_node,
-						"cirrus,reset-gpio", 0);
 		}
 		cs42l52->pdata = *pdata;
 	}
 
-	if (cs42l52->pdata.reset_gpio) {
-		ret = devm_gpio_request_one(&i2c_client->dev,
-					    cs42l52->pdata.reset_gpio,
-					    GPIOF_OUT_INIT_HIGH,
-					    "CS42L52 /RST");
-		if (ret < 0) {
-			dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n",
-				cs42l52->pdata.reset_gpio, ret);
+	reset = devm_gpiod_get_optional(&i2c_client->dev,
+					"reset",
+					GPIOD_OUT_HIGH);
+	if (reset) {
+		if (IS_ERR(reset)) {
+			ret = PTR_ERR(reset);
+			if (ret != -EPROBE_DEFER)
+				dev_err(&i2c_client->dev,
+                                        "failed to get reset gpio :%d",
+					ret);
 			return ret;
 		}
-		gpio_set_value_cansleep(cs42l52->pdata.reset_gpio, 0);
-		gpio_set_value_cansleep(cs42l52->pdata.reset_gpio, 1);
+
+		msleep(100);
+		gpiod_set_value_cansleep(reset, 0);
+		msleep(100);
 	}
 
 	i2c_set_clientdata(i2c_client, cs42l52);
diff -ruw linux-5.4.60/sound/soc/kirkwood/Kconfig linux-5.4.60-fbx/sound/soc/kirkwood/Kconfig
--- linux-5.4.60/sound/soc/kirkwood/Kconfig	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/sound/soc/kirkwood/Kconfig	2021-03-04 13:21:01.724172398 +0100
@@ -16,3 +16,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-5.4.60/sound/soc/kirkwood/Makefile linux-5.4.60-fbx/sound/soc/kirkwood/Makefile
--- linux-5.4.60/sound/soc/kirkwood/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/sound/soc/kirkwood/Makefile	2021-03-04 13:21:01.724172398 +0100
@@ -6,3 +6,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-5.4.60/sound/soc/soc-ops.c linux-5.4.60-fbx/sound/soc/soc-ops.c
--- linux-5.4.60/sound/soc/soc-ops.c	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/sound/soc/soc-ops.c	2021-03-04 13:21:01.737505732 +0100
@@ -196,7 +196,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-5.4.60/usr/Makefile linux-5.4.60-fbx/usr/Makefile
--- linux-5.4.60/usr/Makefile	2020-08-21 13:05:39.000000000 +0200
+++ linux-5.4.60-fbx/usr/Makefile	2021-03-04 13:21:01.924172407 +0100
@@ -27,7 +27,7 @@
 # Generate the initramfs cpio archive
 
 hostprogs-y := gen_init_cpio
-initramfs   := $(CONFIG_SHELL) $(srctree)/$(src)/gen_initramfs_list.sh
+initramfs   := $(BASH) $(srctree)/$(src)/gen_initramfs_list.sh
 ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
 			$(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
 ramfs-args  := \
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/arch/arm/boot/dts/fbxgw1r.dts	2021-03-04 13:20:56.817505512 +0100
@@ -0,0 +1,360 @@
+/dts-v1/;
+
+#include <dt-bindings/input/linux-event-codes.h>
+
+#include "kirkwood.dtsi"
+#include "kirkwood-6281.dtsi"
+#include "fbxgw.dtsi"
+
+/ {
+	model = "Freebox Gateway V1";
+	compatible = "freebox,fbxgw1r", "arm-machtype,527";
+
+	chosen {
+		stdout-path = &uart1;
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x20000000>; /* 512 MB */
+	};
+
+	reserved-memory {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		ramoops@1fff8000 {
+			compatible = "ramoops";
+			/* RAM top - 32k, just below bootloader page table */
+			reg = <0x1fff8000 (16 * 1024)>;
+			record-size = <(16 * 1024)>;
+			ecc-size = <16>;
+			no-dump-oops;
+		};
+        };
+
+	gpio_sr: gpio-sr@0 {
+		compatible = "freebox,fbxgw1r-gpio-sr";
+		#gpio-cells = <2>;
+		gpio-controller;
+		ngpios = <8>;
+
+		gpio-line-names = "sfp-pwren", /* 0 */
+				"usb-rst", /* 1 */
+				"audio-rst", /* 2 */
+				"exp-pwren", /* 3 */
+				"bcm-rst", /* 4 */
+				"pcie-rst", /* 5 */
+				"keypad-oled-rst", /* 6 */
+				"oled-vcc"; /* 7 */
+
+		/* presumed bootloader state */
+		sr,init-value = <((1 << 1) | (1 << 6) | (1 << 7))>;
+		sr,gpio-din = <&gpio0 12 0>;
+		sr,gpio-load = <&gpio0 17 0>;
+		sr,gpio-clk = <&gpio0 10 0>;
+	};
+
+	fbxgw1r_rst: fbxgw1r-rst@0 {
+		compatible = "freebox,fbxgw1r-rst";
+		#reset-cells = <1>;
+
+		usb-gpio = <&gpio_sr 1 GPIO_ACTIVE_LOW>;
+		audio-gpio = <&gpio_sr 2 GPIO_ACTIVE_LOW>;
+		keypad-oled-gpio = <&gpio_sr 6 GPIO_ACTIVE_LOW>;
+	};
+
+	fbxgpio@0 {
+		compatible = "fbx,fbxgpio";
+
+		/* claimed for userspace */
+		pos-sense {
+			name = "pos-sense";
+			gpio = <&gpio1 13 0>;
+			input;
+		};
+
+		board-id-0 {
+			name = "board-id-0";
+			gpio = <&gpio1 11 0>;
+			input;
+		};
+
+		board-id-1 {
+			name = "board-id-1";
+			gpio = <&gpio1 17 0>;
+			input;
+		};
+
+		test-mode {
+			name = "test-mode";
+			gpio = <&gpio0 13 0>;
+			input;
+		};
+
+		sw-reset {
+			name = "sw-reset";
+			gpio = <&gpio0 28 0>;
+			output-high;
+			no-claim;
+		};
+
+		sw-int {
+			name = "sw-int";
+			gpio = <&gpio0 29 0>;
+			input;
+		};
+
+		sfp-txdis {
+			name = "sfp-txdis";
+			gpio = <&gpio0 14 0>;
+			output-high;
+		};
+
+		sfp-pwrgood {
+			name = "sfp-pwrgood";
+			gpio = <&gpio1 2 0>;
+			input;
+		};
+
+		sfp-txfault {
+			name = "sfp-txfault";
+			gpio = <&gpio1 3 0>;
+			input;
+		};
+
+		sfp-presence {
+			name = "sfp-presence";
+			gpio = <&gpio1 5 0>;
+			input;
+		};
+
+		sfp-rxloss {
+			name = "sfp-rxloss";
+			gpio = <&gpio1 6 0>;
+			input;
+		};
+
+		sfp-pwren {
+			name = "sfp-pwren";
+			gpio = <&gpio_sr 0 0>;
+			output-low;
+		};
+
+		exp-rst {
+			name = "exp-rst";
+			gpio = <&gpio1 12 0>;
+			output-low;
+		};
+
+		exp-pwrgood {
+			name = "exp-pwrgood";
+			gpio = <&gpio1 14 0>;
+			input;
+		};
+
+		exp-presence {
+			name = "exp-presence";
+			gpio = <&gpio1 15 0>;
+			input;
+		};
+
+		exp-pwren {
+			name = "exp-pwren";
+			gpio = <&gpio_sr 3 0>;
+			output-low;
+		};
+
+		bcm-rst {
+			name = "bcm-rst";
+			gpio = <&gpio_sr 4 0>;
+			output-low;
+		};
+
+
+		/* unclaimed, exported for debug only */
+		oled-data-select {
+			name = "oled-data-select";
+			gpio = <&gpio0 7 0>;
+			output-low;
+			no-claim;
+		};
+
+		kp-int {
+			name = "kp-int";
+			gpio = <&gpio1 16 0>;
+			input;
+			no-claim;
+		};
+
+		usb-rst {
+			name = "usb-rst";
+			gpio = <&gpio_sr 1 0>;
+			output-low;
+			no-claim;
+		};
+
+		audio-rst {
+			name = "audio-rst";
+			gpio = <&gpio_sr 2 0>;
+			output-low;
+			no-claim;
+		};
+
+		pcie-rst {
+			name = "pcie-rst";
+			gpio = <&gpio_sr 5 0>;
+			output-low;
+			no-claim;
+		};
+
+		keypad-oled-rst {
+			name = "keypad-oled-rst";
+			gpio = <&gpio_sr 6 0>;
+			output-low;
+			no-claim;
+		};
+
+		oled-vcc {
+			name = "oled-vcc";
+			gpio = <&gpio_sr 7 0>;
+			output-low;
+			no-claim;
+		};
+	};
+};
+
+&gpio0 {
+	gpio-line-names = "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "oled-data-select", /* 7 */
+			  "",
+			  "",
+			  "sr-clk", /* 10 */
+			  "bcm-down", /* 11 */
+			  "sr-din", /* 12 */
+			  "test-mode", /* 13 */
+			  "sfp-txdis", /* 14 */
+			  "",
+			  "",
+			  "sr-load", /* 17 */
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "sw-reset", /* 28 */
+			  "sw-int", /* 29 */
+			  "",
+			  "";
+};
+
+&gpio1 {
+	gpio-line-names = "",
+			  "",
+			  "sfp-pwrgood", /* 2 */
+			  "sfp-txfault", /* 3 */
+			  "spi-cs-bcm", /* 4 */
+			  "sfp-presence", /* 5 */
+			  "sfp-rxloss", /* 6*/
+			  "", /* 7 */
+			  "", /* 8 */
+			  "", /* 9 */
+			  "", /* 10 */
+			  "board-id-0", /* 11 */
+			  "exp-rst", /* 12 */
+			  "pos-sense", /* 13 */
+			  "exp-pwrgood", /* 14 */
+			  "exp-presence", /* 15 */
+			  "kp-int", /* 16 */
+			  "board-id-1"; /* 17 */
+};
+
+&usb0 {
+	resets = <&fbxgw1r_rst 0>,
+	       <&fbxgw1r_rst 1>;
+};
+
+&mdio {
+	status = "okay";
+
+	mv6161: mv6161@0 {
+		compatible = "freebox,fbxgw-mv6161";
+		reg = <0>;
+		gpio-reset = <&gpio0 28 0>;
+	};
+};
+
+&eth0 {
+	status = "okay";
+};
+
+&eth0port {
+	fbxserial-mac-address = <0>;
+	speed = <1000>;
+	duplex = <1>;
+};
+
+&i2c0 {
+        cap1066@28 {
+		resets = <&fbxgw1r_rst 2>;
+		irq-gpio = <&gpio1 16 0>;
+	};
+};
+
+&tdm_spi0 {
+	pinctrl-0 = <&pmx_alt_tdm_spi>;
+	cs-gpios = <0>, <&gpio1 4 GPIO_ACTIVE_HIGH>;
+
+	ssd1327@0 {
+		ssd1327,data-select-gpio = <&gpio0 7 GPIO_ACTIVE_HIGH>;
+		ssd1327,vcc-gpio = <&gpio_sr 7 GPIO_ACTIVE_HIGH>;
+		resets = <&fbxgw1r_rst 2>;
+	};
+};
+
+&sata {
+	status = "okay";
+	nr-ports = <2>;
+};
+
+&pciec {
+	status = "okay";
+	reset-gpios = <&gpio_sr 5 GPIO_ACTIVE_LOW>;
+};
+
+&pcie0 {
+	status = "okay";
+};
+
+&nand {
+	nand-ecc-mode = "soft";
+	nand-ecc-algo = "hamming";
+};
+
+&eth1 {
+	status = "okay";
+};
+
+&eth1port {
+	fbxserial-mac-address = <0>;
+	speed = <1000>;
+	duplex = <1>;
+};
+
+&pmx_uart0 {
+	/* only mpp11 here (uart rx) as mpp10 is used as a gpio */
+	marvell,pins = "mpp11";
+	marvell,function = "uart0";
+};
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/arch/arm/boot/dts/fbxgw2r.dts	2021-03-04 13:20:56.817505512 +0100
@@ -0,0 +1,351 @@
+/dts-v1/;
+
+#include <dt-bindings/input/linux-event-codes.h>
+
+#include "kirkwood.dtsi"
+#include "kirkwood-6282.dtsi"
+#include "fbxgw.dtsi"
+
+/ {
+	model = "Freebox Gateway V2";
+	compatible = "freebox,fbxgw2r", "arm-machtype,4242";
+
+	chosen {
+		stdout-path = &uart1;
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x40000000>; /* 1024M */
+	};
+
+	reserved-memory {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		ramoops@3fff8000 {
+			compatible = "ramoops";
+			/* RAM top - 32k, just below bootloader page table */
+			reg = <0x3fff8000 (16 * 1024)>;
+			record-size = <(16 * 1024)>;
+			ecc-size = <16>;
+			no-dump-oops;
+		};
+        };
+
+	fbxgw2r_rst: fbxgw2r-rst@0 {
+		compatible = "freebox,fbxgw2r-rst";
+		#reset-cells = <1>;
+
+		usb-gpio = <&gpio0 23 GPIO_ACTIVE_LOW>;
+		keypad-oled-gpio = <&gpio0 21 GPIO_ACTIVE_LOW>;
+	};
+
+	fbxgw2r-audio@0 {
+		compatible = "freebox,fbxgw2r-audio";
+	};
+
+	ocp@f1000000 {
+		kirkwood-coretemp@10078 {
+			compatible = "marvell,kirkwood-coretemp";
+			reg = <0x10078 0x4>;
+			status = "okay";
+		};
+
+		thermal: thermal@10078 {
+			status = "disabled";
+		};
+	};
+
+	fbxgpio@0 {
+		compatible = "fbx,fbxgpio";
+
+		/* claimed for userspace */
+		pos-sense {
+			name = "pos-sense";
+			gpio = <&gpio1 13 0>;
+			input;
+		};
+
+		test-mode {
+			name = "test-mode";
+			gpio = <&gpio0 13 0>;
+			input;
+		};
+
+		sw-reset {
+			name = "sw-reset";
+			gpio = <&gpio0 28 0>;
+			output-high;
+			no-claim;
+		};
+
+		sw-int {
+			name = "sw-int";
+			gpio = <&gpio0 29 0>;
+			input;
+		};
+
+		sfp-txdis {
+			name = "sfp-txdis";
+			gpio = <&gpio0 12 0>;
+			output-high;
+		};
+
+		sfp-pwrgood {
+			name = "sfp-pwrgood";
+			gpio = <&gpio1 0 0>;
+			input;
+		};
+
+		sfp-txfault {
+			name = "sfp-txfault";
+			gpio = <&gpio1 3 0>;
+			input;
+		};
+
+		sfp-presence {
+			name = "sfp-presence";
+			gpio = <&gpio0 31 0>;
+			input;
+		};
+
+		sfp-rxloss {
+			name = "sfp-rxloss";
+			gpio = <&gpio1 6 0>;
+			input;
+		};
+
+		sfp-pwren {
+			name = "sfp-pwren";
+			gpio = <&gpio1 17 0>;
+			output-low;
+		};
+
+		exp-rst {
+			name = "exp-rst";
+			gpio = <&gpio1 12 0>;
+			output-low;
+		};
+
+		exp-pwrgood {
+			name = "exp-pwrgood";
+			gpio = <&gpio1 14 0>;
+			input;
+		};
+
+		exp-presence {
+			name = "exp-presence";
+			gpio = <&gpio1 15 0>;
+			input;
+		};
+
+		exp-pwren {
+			name = "exp-pwren";
+			gpio = <&gpio0 22 0>;
+			output-low;
+		};
+
+		bcm-rst {
+			name = "bcm-rst";
+			gpio = <&gpio0 30 0>;
+			output-low;
+		};
+
+
+		/* unclaimed, exported for debug only */
+		oled-data-select {
+			name = "oled-data-select";
+			gpio = <&gpio0 7 0>;
+			output-low;
+			no-claim;
+		};
+
+		kp-int {
+			name = "kp-int";
+			gpio = <&gpio1 16 0>;
+			input;
+			no-claim;
+		};
+
+		usb-rst {
+			name = "usb-rst";
+			gpio = <&gpio0 23 0>;
+			output-low;
+			no-claim;
+		};
+
+		audio-rst {
+			name = "audio-rst";
+			gpio = <&gpio1 1 0>;
+			output-low;
+			no-claim;
+		};
+
+		pcie-rst {
+			name = "pcie-rst";
+			gpio = <&gpio0 17 0>;
+			output-low;
+			no-claim;
+		};
+
+		keypad-oled-rst {
+			name = "keypad-oled-rst";
+			gpio = <&gpio0 21 0>;
+			output-low;
+			no-claim;
+		};
+
+		oled-vcc {
+			name = "oled-vcc";
+			gpio = <&gpio0 20 0>;
+			output-low;
+			no-claim;
+		};
+	};
+};
+
+&gpio0 {
+	gpio-line-names = "", /* 0 */
+			  "", /* 1 */
+			  "", /* 2 */
+			  "", /* 3 */
+			  "", /* 4 */
+			  "", /* 5 */
+			  "", /* 6 */
+			  "oled-data-select", /* 7 */
+			  "", /* 8 */
+			  "", /* 9 */
+			  "", /* 10 */
+			  "", /* 11 */
+			  "sfp-txdis", /* 12 */
+			  "test-mode", /* 13 */
+			  "wlan-rst", /* 14 */
+			  "", /* 15 */
+			  "", /* 16 */
+			  "pcie-rst", /* 17 */
+			  "", /* 18 */
+			  "", /* 19 */
+			  "oled-vcc", /* 20 */
+			  "keypad-oled-rst", /* 21 */
+			  "exp-pwren", /* 22 */
+			  "usb-rst", /* 23 */
+			  "", /* 24 */
+			  "", /* 25 */
+			  "", /* 26 */
+			  "", /* 27 */
+			  "sw-reset", /* 28 */
+			  "sw-int", /* 29 */
+			  "bcm-rst", /* 30 */
+			  "sfp-presence"; /* 31 */
+};
+
+&gpio1 {
+	gpio-line-names = "sfp-pwrgood", /* 0 */
+			  "audio-rst", /* 1 */
+			  "spi-cs-bcm", /* 2 */
+			  "sfp-txfault", /* 3 */
+			  "", /* 4 */
+			  "", /* 5 */
+			  "sfp-rxloss", /* 6*/
+			  "", /* 7 */
+			  "", /* 8 */
+			  "", /* 9 */
+			  "", /* 10 */
+			  "", /* 11 */
+			  "exp-rst", /* 12 */
+			  "pos-sense", /* 13 */
+			  "exp-pwrgood", /* 14 */
+			  "exp-presence", /* 15 */
+			  "kp-int", /* 16 */
+			  "sfp-pwren"; /* 17 */
+};
+
+&usb0 {
+	status = "okay";
+	resets = <&fbxgw2r_rst 0>;
+};
+
+&mdio {
+	status = "okay";
+
+	mv6176: mv6176@0 {
+		compatible = "freebox,fbxgw-mv6176";
+		reg = <0>;
+		gpio-reset = <&gpio0 28 0>;
+	};
+};
+
+&eth0 {
+	status = "okay";
+};
+
+&eth0port {
+	fbxserial-mac-address = <0>;
+	speed = <1000>;
+	duplex = <1>;
+};
+
+&i2c0 {
+        cap1066@28 {
+		resets = <&fbxgw2r_rst 2>;
+		irq-gpio = <&gpio1 16 0>;
+	};
+};
+
+&tdm_spi0 {
+	cs-gpios = <0>, <&gpio1 2 GPIO_ACTIVE_HIGH>;
+
+	ssd1327@0 {
+		ssd1327,data-select-gpio = <&gpio0 7 GPIO_ACTIVE_HIGH>;
+		ssd1327,vcc-gpio = <&gpio0 20 GPIO_ACTIVE_HIGH>;
+		resets = <&fbxgw2r_rst 2>;
+	};
+};
+
+&sata {
+	status = "okay";
+	nr-ports = <2>;
+};
+
+&pciec {
+	status = "okay";
+	reset-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>,
+		      <&gpio0 14 GPIO_ACTIVE_LOW>;
+};
+
+&pcie0 {
+	status = "okay";
+};
+
+&nand {
+	nand-ecc-mode = "soft";
+	nand-ecc-algo = "bch";
+	/* this will make ecc_bytes == 7 */
+	nand-ecc-strength = <4>;
+	nand-ecc-step-size = <512>;
+};
+
+&gpio1 {
+	marvell,broken-mpp33-dir = <1>;
+};
+
+&audio0 {
+	status = "okay";
+};
+
+&i2c1 {
+	status = "okay";
+	clock-frequency = <25000>;
+
+	codec@4a {
+		compatible = "cirrus,cs42l52";
+		reset-gpio = <&gpio1 1 GPIO_ACTIVE_LOW>;
+		reg = <0x4a>;
+	};
+};
+
+&pcie1 {
+        status = "okay";
+};
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/arch/arm/boot/dts/fbxgw.dtsi	2021-03-04 13:20:56.817505512 +0100
@@ -0,0 +1,156 @@
+/ {
+	ocp@f1000000 {
+		fbxwdt: fbxwatchdog-timer@20300 {
+			compatible = "marvell,orion-fbxwdt";
+			reg = <0x20300 0x28>, <0x20108 0x4>;
+			clocks = <&gate_clk 7>;
+			status = "okay";
+		};
+	};
+};
+
+&i2c0 {
+	status = "okay";
+	clock-frequency = <25000>;
+
+        cap1066@28 {
+		/* SMSC cap1066 */
+		compatible = "smsc,smsc_cap1066";
+		reg = <0x28>;
+		keymap = <KEY_DOWN
+		       	  KEY_LEFT
+			  KEY_UP
+			  0
+			  KEY_ENTER
+			  KEY_RIGHT>;
+	};
+
+        eeprom@53 {
+		/* expansion eeprom */
+		compatible = "atmel,24c256";
+		read-only;
+		reg = <0x53>;
+	};
+
+        eeprom@57 {
+		/* midlane eeprom */
+		compatible = "atmel,24c32";
+		read-only;
+		reg = <0x57>;
+		pagesize = <8>;
+	};
+};
+
+&tdm_spi0 {
+	status = "okay";
+	num-cs = <1>;
+
+	ssd1327@0 {
+		compatible = "solomon,ssd1327";
+		reg = <0>;
+		spi-max-frequency = <(9 * 1000 * 1000)>;
+		ssd1327,width = <128>;
+		ssd1327,height = <128>;
+		ssd1327,rotate = <270>;
+		ssd1327,watchdog = <300>;
+	};
+
+	bcm-flash@1 {
+		compatible = "m25p80";
+		reg = <1>;
+		spi-max-frequency = <(1 * 1000 * 1000)>;
+		label = "bcmflash";
+	};
+};
+
+&nand {
+	status = "okay";
+	chip-delay = <35>;
+
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		all@0 {
+			label = "all";
+			/* MTDPART_SIZ_FULL=0 */
+			reg = <0x0 0>;
+			read-only;
+		};
+
+		u-boot@0 {
+			label = "u-boot";
+			reg = <0x0 (1 * 1024 * 1024)>;
+			read-only;
+		};
+
+		serial@ {
+			label = "serial";
+			reg = <(1 * 1024 * 1024) (1 * 1024 * 1024)>;
+			read-only;
+		};
+
+		calibration@0 {
+			label = "calibration";
+			reg = <(2 * 1024 * 1024) (1 * 1024 * 1024)>;
+			read-only;
+		};
+
+		bank0@0 {
+			label = "bank0";
+			reg = <(3 * 1024 * 1024) (18 * 1024 * 1024)>;
+			read-only;
+		};
+
+		nvram@0 {
+			label = "nvram";
+			reg = <(21 * 1024 * 1024) (3 * 1024 * 1024)>;
+		};
+
+		bank1@0 {
+			label = "bank1";
+			reg = <(24 * 1024 * 1024) (62 * 1024 * 1024)>;
+		};
+
+		femto@0 {
+			label = "femto";
+			reg = <(86 * 1024 * 1024) (16 * 1024 * 1024)>;
+		};
+
+		config@0 {
+			label = "config";
+			reg = <(120 * 1024 * 1024) (8 * 1024 * 1024)>;
+		};
+
+		partition@0 {
+			label = "new_bank0";
+			reg = <(102 * 1024 * 1024) (18 * 1024 * 1024)>;
+		};
+	};
+};
+
+&eth0 {
+	marvell,unit = <0>;
+};
+
+&eth1 {
+	marvell,unit = <1>;
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&uart1 {
+	status = "okay";
+};
+
+&pmx_uart1 {
+	marvell,pins = "mpp15", "mpp16";
+	marvell,function = "uart1";
+};
+
+&usb0 {
+	status = "okay";
+};
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/arch/arm/boot/dts/fbxgwr_exp_stb.dts	2021-03-04 13:20:56.817505512 +0100
@@ -0,0 +1,55 @@
+#include <dt-bindings/gpio/gpio.h>
+
+/dts-v1/;
+/plugin/;
+
+/ {
+    compatible = "freebox,fbxgw1r", "freebox,fbxgw2r";
+
+    fragment@0 {
+	target = <&i2c0>;
+        __overlay__ {
+		#address-cells = <0x1>;
+		#size-cells = <0x0>;
+
+		// IO expander
+		exp_gpio_extender: exp@41 {
+			compatible = "ti,pca9536";
+			reg = <0x41>;
+			gpio-controller;
+			ngpios = <4>;
+			#gpio-cells = <2>;
+			gpio-line-names = "bank0-mode", /* 0 */
+				"stb-rear-button-feedback", /* 1 */
+				"test-mode", /* 2 */
+				"stb-test-mode-feedback"; /* 3 */
+		};
+        };
+    };
+
+     fragment@1 {
+	target-path="/";
+        __overlay__ {
+		exp-fbxgpio {
+			compatible = "fbx,fbxgpio";
+			exp-bank0-mode {
+				gpio = <&exp_gpio_extender 0 GPIO_ACTIVE_LOW>;
+				output-low;
+			};
+			exp-stb-rear-button-feedback {
+				gpio = <&exp_gpio_extender 1 GPIO_ACTIVE_LOW>;
+				input;
+			};
+			exp-test-mode {
+				gpio = <&exp_gpio_extender 2 GPIO_ACTIVE_HIGH>;
+				output-low;
+			};
+			exp-stb-test-mode-feedback {
+				gpio = <&exp_gpio_extender 3 GPIO_ACTIVE_HIGH>;
+				input;
+			};
+		};
+        };
+    };
+
+};
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/arch/arm/mach-mvebu/fbxgw1r-gpio-sr.c	2021-03-04 13:20:56.937505517 +0100
@@ -0,0 +1,204 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/spinlock.h>
+#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
+
+/*
+ * priv
+ */
+struct gpio_sr_priv {
+	int			gpio_din;
+	int			gpio_clk;
+	int			gpio_load;
+
+	struct gpio_chip	gc;
+	spinlock_t		lock;
+
+	/*
+	 * reset values can not be read back from shift registers, we
+	 * have to keep them
+	 */
+	unsigned long		cache_value;
+};
+
+/*
+ * set shift registers output to given value
+ */
+static void __set_shift_register(struct gpio_sr_priv *priv, u8 val)
+{
+	int i;
+
+	gpio_set_value(priv->gpio_clk, 0);
+	gpio_set_value(priv->gpio_load, 0);
+
+	udelay(1);
+
+	for (i = 7; i >= 0; i--) {
+		gpio_set_value(priv->gpio_din, (val & (1 << i)) ? 1 : 0);
+		udelay(100);
+		gpio_set_value(priv->gpio_clk, 1);
+		udelay(100);
+		gpio_set_value(priv->gpio_clk, 0);
+	}
+
+	udelay(1);
+	gpio_set_value(priv->gpio_load, 1);
+	udelay(1);
+}
+
+/*
+ * clear or set sr bit
+ */
+static void sr_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
+{
+	struct gpio_sr_priv *priv = gpiochip_get_data(chip);
+	unsigned long flags;
+
+	if (!(test_bit(offset, &priv->cache_value) ^ value))
+		return;
+
+	spin_lock_irqsave(&priv->lock, flags);
+	if (value)
+		__set_bit(offset, &priv->cache_value);
+	else
+		__clear_bit(offset, &priv->cache_value);
+	__set_shift_register(priv, (u8)priv->cache_value);
+	spin_unlock_irqrestore(&priv->lock, flags);
+}
+
+/*
+ * return cached bit value
+ */
+static int sr_gpio_get(struct gpio_chip *chip, unsigned int offset)
+{
+	struct gpio_sr_priv *priv = gpiochip_get_data(chip);
+	return test_bit(offset, &priv->cache_value);
+}
+
+/*
+ * fixed direction
+ */
+static int sr_gpio_direction_output(struct gpio_chip *chip,
+				    unsigned int offset,
+				    int value)
+{
+	sr_gpio_set(chip, offset, value);
+	return 0;
+}
+
+/*
+ * fixed direction
+ */
+static int sr_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
+{
+	return 0;
+}
+
+static int fbxgw1r_gpio_sr_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct gpio_sr_priv *priv;
+	struct gpio_chip *gc;
+	unsigned int flags;
+	u32 init_val, ngpios;
+	int ret;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof (*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	spin_lock_init(&priv->lock);
+
+        if (of_property_read_u32(np, "ngpios", &ngpios)) {
+                dev_err(&pdev->dev, "Missing ngpios OF property\n");
+                return -ENODEV;
+        }
+
+	if (ngpios > 8) {
+                dev_err(&pdev->dev, "invalid number of gpios\n");
+                return -ENODEV;
+        }
+
+	/* get all GPIOs */
+	priv->gpio_din = of_get_named_gpio_flags(np, "sr,gpio-din", 0, &flags);
+        if (priv->gpio_din < 0)
+                return priv->gpio_din;
+
+	priv->gpio_clk = of_get_named_gpio_flags(np, "sr,gpio-clk", 0, &flags);
+        if (priv->gpio_clk < 0)
+                return priv->gpio_clk;
+
+	priv->gpio_load = of_get_named_gpio_flags(np, "sr,gpio-load", 0, &flags);
+        if (priv->gpio_load < 0)
+                return priv->gpio_load;
+
+	ret = of_property_read_u32(np, "sr,init-value", &init_val);
+        if (ret) {
+                dev_err(&pdev->dev, "missing <sr,init-value>\n");
+                return ret;
+        }
+
+	ret = devm_gpio_request(&pdev->dev, priv->gpio_din,
+				"sr-gpio-din");
+	if (ret < 0) {
+                dev_err(&pdev->dev, "failed to request gpio din");
+                return ret;
+        }
+
+	ret = devm_gpio_request(&pdev->dev, priv->gpio_load,
+				"sr-gpio-load");
+	if (ret < 0) {
+                dev_err(&pdev->dev, "failed to request gpio load");
+                return ret;
+        }
+
+	ret = devm_gpio_request(&pdev->dev, priv->gpio_clk,
+				"sr-gpio-clk");
+	if (ret < 0) {
+                dev_err(&pdev->dev, "failed to request gpio clk");
+                return ret;
+        }
+
+	priv->cache_value = init_val;
+	__set_shift_register(priv, (u8)priv->cache_value);
+
+	/* register gpiochip */
+	gc = &priv->gc;
+	gc->base = -1;
+	gc->label = "fbxgw1r-gpio-sr";
+	gc->get = sr_gpio_get;
+        gc->set = sr_gpio_set;
+        gc->get_direction = sr_gpio_get_direction;
+        gc->direction_output = sr_gpio_direction_output;
+	gc->ngpio = 8;
+        gc->of_node = np;
+        gc->parent = &pdev->dev;
+
+	ret = gpiochip_add_data(&priv->gc, priv);
+	if (ret) {
+		dev_err(&pdev->dev,
+			"cannot add fbxgw1r GPIO SR chip, error=%d", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static const struct of_device_id fbxgw1r_gpio_sr_ids[] = {
+	{ .compatible = "freebox,fbxgw1r-gpio-sr" },
+	{ }
+};
+
+static struct platform_driver fbxgw1r_gpio_sr_driver = {
+	.driver = {
+		.name           = "fbxgw1r-gpio-sr",
+		.of_match_table = of_match_ptr(fbxgw1r_gpio_sr_ids),
+	},
+	.probe  = fbxgw1r_gpio_sr_probe,
+};
+
+builtin_platform_driver(fbxgw1r_gpio_sr_driver);
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/arch/arm/mach-mvebu/fbxgw-common.c	2021-03-04 13:20:56.937505517 +0100
@@ -0,0 +1,281 @@
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/physmap.h>
+#include <linux/mtd/rawnand.h>
+#include <linux/fbxatm_remote.h>
+
+#include <asm/setup.h>
+
+#include "kirkwood.h"
+
+#define PFX "fbxgw: "
+
+#define CPU_CONTROL_PEX0EN	(1 << 0)
+#define CPU_CONTROL_PEX1EN	(1 << 4)
+
+#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
+
+static inline bool machine_is_fbxgw1r(void)
+{
+	return of_machine_is_compatible("freebox,fbxgw1r");
+}
+
+static inline bool machine_is_fbxgw2r(void)
+{
+	return of_machine_is_compatible("freebox,fbxgw2r");
+}
+
+/*
+ * 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);
+}
+
+/*
+ * 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);
+
+/*
+ * broadcom 6358 remote atm device
+ */
+static struct fbxatm_remote_pdata bcm6358_remote_pdata = {
+	.remote_mac	= "\x00\x07\xcb\x00\x00\xfe",
+	.netdev_name	= "bcmfbxatm0",
+	.remote_name	= "bcm63xx_fbxxtm0",
+};
+
+static struct platform_device fbxatm_remote_device = {
+	.name	= "fbxatm_remote",
+	.id	= -1,
+	.dev	= {
+		.platform_data = &bcm6358_remote_pdata,
+	},
+};
+
+/*
+ * mainline pci-mvebu driver does not make sure PCIe is enabled at SOC
+ * level
+ */
+static void __init pcie_ensure_enabled(void)
+{
+	void __iomem *cpu_control;
+	u32 val;
+
+	cpu_control = ioremap(CPU_CONTROL_PHYS, 4);
+	val = readl(cpu_control);
+
+	if (!(val & CPU_CONTROL_PEX0EN))
+		printk(KERN_INFO PFX "enabling PCIe0 hw\n");
+	val |= CPU_CONTROL_PEX0EN;
+
+	if (machine_is_fbxgw2r()) {
+		if (!(val & CPU_CONTROL_PEX1EN))
+			printk(KERN_INFO PFX "enabling PCIe1 hw\n");
+		val |= CPU_CONTROL_PEX1EN;
+	}
+
+	writel(val, cpu_control);
+	iounmap(cpu_control);
+}
+
+/*
+ * called from machine_init() (arch_initcall)
+ */
+static void __init fbxgw_init(void)
+{
+	panic_timeout = 10;
+	panic_on_oops = 1;
+
+	pcie_ensure_enabled();
+	set_nand_timings();
+	platform_device_register(&fbxatm_remote_device);
+}
+
+void __init fbxgw1r_init(void)
+{
+	printk("fbxgw1r-init.\n");
+	fbxgw_init();
+}
+
+/*
+ * called from machine_init() (arch_initcall)
+ */
+void __init fbxgw2r_init(void)
+{
+	printk("fbxgw2r-init.\n");
+	fbxgw_init();
+}
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/arch/arm/mach-mvebu/fbxgw-rst.c	2021-03-04 13:20:56.937505517 +0100
@@ -0,0 +1,164 @@
+#include <linux/kernel.h>
+#include <linux/mutex.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/of_gpio.h>
+#include <linux/reset-controller.h>
+
+struct rst_desc {
+	const char		*name;
+	bool			shared;
+};
+
+static const struct rst_desc descs[]= {
+	{ "usb", false },
+	{ "audio", false },
+	{ "keypad-oled", true },
+};
+
+struct rst_control_priv {
+	struct gpio_desc		*gpio;
+	const struct rst_desc		*desc;
+};
+
+struct rst_priv {
+	struct rst_control_priv		controls[ARRAY_SIZE(descs)];
+	struct reset_controller_dev	rcdev;
+};
+
+/*
+ *
+ */
+static int op_assert(struct reset_controller_dev *rcdev, unsigned long id)
+{
+	struct rst_priv *priv = container_of((rcdev), struct rst_priv, rcdev);
+	struct rst_control_priv *rcp = &priv->controls[id];
+
+	if (WARN_ON(!rcp->gpio))
+		return 0;
+
+	if (gpiod_get_value(rcp->gpio))
+		return 0;
+
+	if (rcp->desc->shared)
+		return -EBUSY;
+
+	gpiod_set_value(rcp->gpio, 1);
+	return 0;
+}
+
+/*
+ *
+ */
+static int op_deassert(struct reset_controller_dev *rcdev, unsigned long id)
+{
+	struct rst_priv *priv = container_of((rcdev), struct rst_priv, rcdev);
+	struct rst_control_priv *rcp = &priv->controls[id];
+
+	if (WARN_ON(!rcp->gpio))
+		return 0;
+
+	gpiod_set_value(rcp->gpio, 0);
+	return 0;
+}
+
+/*
+ *
+ */
+static int op_status(struct reset_controller_dev *rcdev, unsigned long id)
+{
+	struct rst_priv *priv = container_of((rcdev), struct rst_priv, rcdev);
+	struct rst_control_priv *rcp = &priv->controls[id];
+
+	if (WARN_ON(!rcp->gpio))
+		return 0;
+
+	return gpiod_get_value(rcp->gpio);
+}
+
+static const struct reset_control_ops fbxgw_rst_ops = {
+	.assert		= op_assert,
+	.deassert	= op_deassert,
+	.status		= op_status,
+};
+
+/*
+ *
+ */
+static int fbxgw_rst_probe(struct platform_device *pdev)
+{
+	struct reset_controller_dev *rcdev;
+	struct rst_priv *priv;
+	unsigned int i;
+	int ret;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof (*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	/* get all GPIOs */
+	for (i = 0; i < ARRAY_SIZE(priv->controls); i++) {
+		struct rst_control_priv *rcp = &priv->controls[i];
+		int ret;
+
+		rcp->gpio = devm_gpiod_get_optional(&pdev->dev, descs[i].name,
+						    GPIOD_ASIS);
+		if (!rcp->gpio)
+			continue;
+
+		if (IS_ERR(rcp->gpio)) {
+			ret = PTR_ERR(rcp->gpio);
+
+			if (ret != -EPROBE_DEFER)
+				dev_err(&pdev->dev,
+					"failed to get %s gpio :%d",
+					descs[i].name, ret);
+			return ret;
+		}
+
+		ret = gpiod_get_direction(rcp->gpio);
+		WARN_ON(ret < 0);
+
+		if (ret != GPIOF_DIR_OUT) {
+			dev_warn(&pdev->dev,
+				 "reset gpio for %s was not previously "
+				 "configured, forcing assert", descs[i].name);
+			gpiod_direction_output(rcp->gpio, 1);
+		}
+
+		rcp->desc = &descs[i];
+	}
+
+	/* register controller */
+        rcdev = &priv->rcdev;
+        rcdev->ops = &fbxgw_rst_ops;
+        rcdev->of_node = pdev->dev.of_node;
+        rcdev->of_reset_n_cells = 1;
+        rcdev->nr_resets = ARRAY_SIZE(priv->controls);
+
+        ret = devm_reset_controller_register(&pdev->dev, rcdev);
+        if (ret) {
+                dev_err(&pdev->dev,
+			"failed to register reset controller: %d", ret);
+                return ret;
+        }
+
+	return 0;
+}
+
+static const struct of_device_id fbxgw_rst_ids[] = {
+	{ .compatible = "freebox,fbxgw1r-rst" },
+	{ .compatible = "freebox,fbxgw2r-rst" },
+	{ }
+};
+
+static struct platform_driver fbxgw_rst_driver = {
+	.driver = {
+		.name           = "fbxgw-rst",
+		.of_match_table = of_match_ptr(fbxgw_rst_ids),
+	},
+	.probe  = fbxgw_rst_probe,
+};
+
+builtin_platform_driver(fbxgw_rst_driver);
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/arch/arm/mach-mvebu/fbxgw-switch.c	2021-03-04 13:20:56.937505517 +0100
@@ -0,0 +1,502 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/mdio.h>
+#include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/of_device.h>
+
+#define PFX "fbxgw-switch: "
+
+#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 NFS_VLAN_ID			41
+
+#define SWPORT(X)			((X) + 0x10)
+#define PHYPORT(X)			(X)
+#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
+
+/*
+ *
+ */
+struct sw_priv {
+	int			dev_id;
+	bool			indirect_phy_access;
+	struct mdio_device	*mdiodev;
+};
+
+/*
+ * hardcoded for now
+ */
+static inline bool do_vlan(void)
+{
+	return true;
+}
+
+static int __sw_read(struct sw_priv *priv, int addr, u32 regnum)
+{
+	return mdiobus_read(priv->mdiodev->bus, addr, regnum);
+}
+
+static int __sw_write(struct sw_priv *priv, int addr, u32 regnum, u16 val)
+{
+	return mdiobus_write(priv->mdiodev->bus, addr, regnum, val);
+}
+
+static int __sw_indirect_wait(struct sw_priv *priv, int tries)
+{
+	while (tries) {
+		u16 val = __sw_read(priv, MARVELL_GLOBAL2, GLOBREG_SMI_CMD);
+		if ((val & SMI_CMD_BUSY) == 0)
+			return 0;
+		udelay(1000);
+		--tries;
+	}
+	return -ETIMEDOUT;
+}
+
+static int __sw_indirect_read(struct sw_priv *priv, int phy_id, int reg)
+{
+	u16 smi_cmd = SMI_CMD_BUSY | SMI_CLAUSE_22 | SMI_CMD_READ |
+		SMI_DEVADDR(phy_id) | SMI_REGADDR(reg);
+
+	__sw_write(priv, MARVELL_GLOBAL2, GLOBREG_SMI_CMD, smi_cmd);
+	if (__sw_indirect_wait(priv, 1000) < 0) {
+		printk(KERN_WARNING PFX "indirect phy read did not "
+		       "complete.\n");
+		return 0xffff;
+	}
+	return __sw_read(priv, MARVELL_GLOBAL2, GLOBREG_SMI_DATA);
+}
+
+static int sw_phy_read(struct sw_priv *priv, int phy_id, int reg)
+{
+	if (priv->indirect_phy_access == false)
+		return __sw_read(priv, phy_id, reg);
+	else
+		return __sw_indirect_read(priv, phy_id, reg);
+}
+
+static void __sw_indirect_write(struct sw_priv *priv, 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);
+
+	__sw_write(priv, MARVELL_GLOBAL2, GLOBREG_SMI_DATA, val);
+	__sw_write(priv, MARVELL_GLOBAL2, GLOBREG_SMI_CMD, smi_cmd);
+	if (__sw_indirect_wait(priv, 1000) < 0) {
+		printk(KERN_WARNING PFX "indirect phy write did not "
+		       "complete.\n");
+	}
+}
+
+static void sw_phy_write(struct sw_priv *priv, int phy_id, int reg, int val)
+{
+
+	if (priv->indirect_phy_access == false)
+		__sw_write(priv, phy_id, reg, val);
+	else
+		__sw_indirect_write(priv, phy_id, reg, val);
+}
+
+static void __vtu_wait(struct sw_priv *priv)
+{
+	for (;;) {
+		u16 val = __sw_read(priv, MARVELL_GLOBAL1, GLOBREG_VTUOP);
+		if ((val & (1 << 15)) == 0)
+			break;
+		msleep(10);
+	}
+}
+
+static void fbxgw_sw_vtu_stu_init(struct sw_priv *priv, int port_state,
+				  size_t nr_ports)
+{
+	u16 vtu_op = VTUOP_OP_STU_LOAD;
+	u16 regs[2] = { 0 , 0 };
+	int i;
+
+	__sw_write(priv, MARVELL_GLOBAL1, GLOBREG_VTUOP, vtu_op);
+
+	__sw_write(priv, MARVELL_GLOBAL1, GLOBREG_VTUSID, 0);
+	__sw_write(priv, 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;
+	}
+
+	__sw_write(priv, MARVELL_GLOBAL1, GLOBREG_VTU_P03_DATA, regs[0]);
+	__sw_write(priv, MARVELL_GLOBAL1, GLOBREG_VTU_P46_DATA, regs[1]);
+
+	vtu_op |= VTUOP_BUSY;
+	__sw_write(priv, MARVELL_GLOBAL1, GLOBREG_VTUOP, vtu_op);
+	__vtu_wait(priv);
+}
+
+static void fbxgw_sw_vtu_load(struct sw_priv *priv, u16 vid, const u8 *ports,
+			      size_t nr_ports)
+{
+	u16 vtu_op;
+	u16 regs[2] = { 0, 0 };
+	int i;
+
+	vtu_op = VTUOP_OP_LOAD;
+	__sw_write(priv, MARVELL_GLOBAL1, GLOBREG_VTUOP, vtu_op);
+
+	__sw_write(priv, MARVELL_GLOBAL1, GLOBREG_VTUFID, 1);
+	__sw_write(priv, MARVELL_GLOBAL1, GLOBREG_VTUSID, 0);
+
+	__sw_write(priv, 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;
+	}
+
+	__sw_write(priv, MARVELL_GLOBAL1, GLOBREG_VTU_P03_DATA, regs[0]);
+	__sw_write(priv, MARVELL_GLOBAL1, GLOBREG_VTU_P46_DATA, regs[1]);
+
+	vtu_op |= VTUOP_BUSY;
+	__sw_write(priv, MARVELL_GLOBAL1, GLOBREG_VTUOP, vtu_op);
+
+	__vtu_wait(priv);
+}
+
+static void fbxgw_sw_config_cpu_port(struct sw_priv *priv, int swport)
+{
+	u16 pcs = PCS_FORCEDUPLEX_FULL | PCS_FORCEDUPLEX |
+		PCS_FORCESPEED_1000 |
+		PCS_FORCELINK | PCS_FORCELINK_UP;
+
+	if (priv->dev_id == 0x6176)
+		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;
+		__sw_write(priv, MARVELL_SWPORT4, 0x1a, 0x81e7);
+		(void)__sw_read(priv, MARVELL_SWPORT5, 0x1a);
+		__sw_write(priv, MARVELL_SWPORT5, 0x1a, P5_RGMII_DELAY);
+		__sw_write(priv, MARVELL_SWPORT4, 0x1a, 0xc1e7);
+	}
+
+	__sw_write(priv, swport, PORTREG_PCS, pcs);
+}
+
+static void fbxgw_sw_config_phy_port(struct sw_priv *priv, int phy_port)
+{
+	u16 val;
+
+	if (priv->indirect_phy_access == false) {
+		val = __sw_read(priv, MARVELL_GLOBAL1, GLOBREG_GCR);
+		val &= ~GCR_PPUEN;
+		__sw_write(priv, MARVELL_GLOBAL1, GLOBREG_GCR, val);
+	}
+
+
+	/* power up phy for eth port 0 */
+	val = sw_phy_read(priv, phy_port, 0x00);
+	val &= ~0x0800;
+	sw_phy_write(priv, phy_port, 0x00, val);
+
+
+	/* restart autoneg */
+	val = sw_phy_read(priv, phy_port, 0x00);
+	val |= 0x0200;
+	sw_phy_write(priv, phy_port, 0x00, val);
+
+	sw_phy_write(priv, phy_port, 20, 0);
+
+	if (priv->indirect_phy_access == false) {
+		val = __sw_read(priv, MARVELL_GLOBAL1, GLOBREG_GCR);
+		val |= GCR_PPUEN;
+		__sw_write(priv, MARVELL_GLOBAL1, GLOBREG_GCR, val);
+	}
+}
+
+static void fbxgw_sw_port_default_vid(struct sw_priv *priv,
+				      int swport, u16 vid)
+{
+	u16 val;
+
+	val = __sw_read(priv, swport, PORTREG_VLANID);
+	val &= ~0xfff;
+	val |= vid;
+	__sw_write(priv, swport, PORTREG_VLANID, val);
+}
+
+static void fbxgw_sw_port_dot1q_secure(struct sw_priv *priv, int swport)
+{
+	u16 val;
+
+	val = __sw_read(priv, swport, PORTREG_PCR2);
+	val &= ~(3 << PCR2_MODE_SHIFT);
+	val |= (PCR2_MODE_SECURE << PCR2_MODE_SHIFT);
+	__sw_write(priv, swport, PORTREG_PCR2, val);
+}
+
+static void fbxgw_sw_port_forward_enable(struct sw_priv *priv, int swport)
+{
+	u16 val;
+
+	/* enable forwarding */
+	val = __sw_read(priv, swport, PORTREG_PCR);
+	val |= PCR_PORTSTATE_FORWARDING;
+	__sw_write(priv, swport, PORTREG_PCR, val);
+}
+
+static int mv6161_config(struct sw_priv *priv)
+{
+	struct device *dev = &priv->mdiodev->dev;
+	u16 val;
+
+	/* probe */
+	val = __sw_read(priv, 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;
+	}
+
+	priv->dev_id = 0x6161;
+	priv->indirect_phy_access = false;
+
+	fbxgw_sw_config_cpu_port(priv, SWPORT(5));
+	fbxgw_sw_config_phy_port(priv, PHYPORT(1));
+
+	if (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(priv, NFS_VLAN_ID, config, sizeof (config));
+
+		fbxgw_sw_port_default_vid(priv, SWPORT(1), NFS_VLAN_ID);
+		fbxgw_sw_port_dot1q_secure(priv, SWPORT(1));
+		fbxgw_sw_port_dot1q_secure(priv, SWPORT(5));
+	}
+
+	fbxgw_sw_port_forward_enable(priv, SWPORT(1));
+	fbxgw_sw_port_forward_enable(priv, SWPORT(5));
+
+	dev_info(dev, "marvell 6161 initialized\n");
+	return 0;
+}
+
+static int mv6176_config(struct sw_priv *priv)
+{
+	struct device *dev = &priv->mdiodev->dev;
+	u16 val;
+
+	/* probe */
+	val = __sw_read(priv, 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;
+	}
+
+	priv->dev_id = 0x6176;
+	priv->indirect_phy_access = true;
+
+	fbxgw_sw_config_cpu_port(priv, SWPORT(5));
+	fbxgw_sw_config_phy_port(priv, PHYPORT(0));
+
+	__sw_write(priv, SWPORT(0), 0x16, 0x8011);
+	__sw_write(priv, SWPORT(1), 0x16, 0x8011);
+	__sw_write(priv, SWPORT(2), 0x16, 0x8011);
+	__sw_write(priv, SWPORT(3), 0x16, 0x8011);
+
+	if (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(priv, PCR_PORTSTATE_FORWARDING,
+				      sizeof (config));
+		fbxgw_sw_vtu_load(priv, NFS_VLAN_ID, config, sizeof (config));
+
+		fbxgw_sw_port_default_vid(priv, SWPORT(0), NFS_VLAN_ID);
+		fbxgw_sw_port_dot1q_secure(priv, SWPORT(0));
+		fbxgw_sw_port_dot1q_secure(priv, SWPORT(5));
+	}
+
+	fbxgw_sw_port_forward_enable(priv, SWPORT(5));
+	fbxgw_sw_port_forward_enable(priv, SWPORT(0));
+
+	dev_info(dev, "marvell 6176 initialized\n");
+	return 0;
+}
+
+static int fbxgw_mv61xx_probe(struct mdio_device *mdiodev)
+{
+	struct device *dev = &mdiodev->dev;
+	struct sw_priv *priv;
+	int reset_gpio;
+	unsigned int flags;
+	u32 id;
+
+	reset_gpio = of_get_named_gpio_flags(dev->of_node,
+					     "gpio-reset", 0, &flags);
+        if (reset_gpio < 0)
+                return reset_gpio;
+
+	priv = devm_kzalloc(dev, sizeof (*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->mdiodev = mdiodev;
+	dev_info(dev, "resetting switch\n");
+
+	gpio_direction_output(reset_gpio, 0);
+	msleep(1);
+	gpio_set_value(reset_gpio, 1);
+	msleep(2000);
+
+	id = (u32)of_device_get_match_data(dev);
+	switch (id) {
+	case 0x6161:
+		return mv6161_config(priv);
+
+	case 0x6176:
+		return mv6176_config(priv);
+
+	default:
+		dev_err(dev, "unsupported model\n");
+		return -ENODEV;
+	}
+
+	mdiodev->flags = MDIO_DEVICE_FLAG_PHY;
+	return 0;
+}
+
+static const struct of_device_id fbxgw_mv61xx_of_match[] = {
+        {
+                .compatible = "freebox,fbxgw-mv6161",
+                .data = (void *)0x6161,
+        },
+        {
+		.compatible = "freebox,fbxgw-mv6176",
+                .data = (void *)0x6176,
+        },
+        { /* sentinel */ },
+};
+
+static struct mdio_driver fbxgw_mv61xx_driver = {
+	.probe  = fbxgw_mv61xx_probe,
+        .mdiodrv.driver = {
+                .name = "fbxgw-mv61xx",
+                .of_match_table = of_match_ptr(fbxgw_mv61xx_of_match),
+        },
+};
+
+mdio_module_driver(fbxgw_mv61xx_driver);
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/block/partitions/dt.h	2021-03-04 13:20:57.500838876 +0100
@@ -0,0 +1 @@
+int dt_partition(struct parsed_partitions *);
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/config	2021-03-30 15:41:00.541698876 +0200
@@ -0,0 +1,4293 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# Linux/arm 5.4.60 Kernel Configuration
+#
+
+#
+# Compiler: arm-linux-muslgnueabi-gcc (freebox) 8.3.0
+#
+CONFIG_CC_IS_GCC=y
+CONFIG_GCC_VERSION=80300
+CONFIG_CLANG_VERSION=0
+CONFIG_CC_CAN_LINK=y
+CONFIG_CC_HAS_ASM_GOTO=y
+CONFIG_CC_HAS_ASM_INLINE=y
+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.21-gcc-8.3.0-binutils-2.32-gdb-7.12.1-2/bin/arm-linux-muslgnueabi-"
+# CONFIG_COMPILE_TEST is not set
+CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
+CONFIG_BUILD_SALT=""
+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_USELIB is not set
+CONFIG_AUDIT=y
+CONFIG_HAVE_ARCH_AUDITSYSCALL=y
+CONFIG_AUDITSYSCALL=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_FORCED_THREADING=y
+CONFIG_SPARSE_IRQ=y
+# CONFIG_GENERIC_IRQ_DEBUGFS is not set
+# end of IRQ subsystem
+
+CONFIG_GENERIC_IRQ_MULTI_HANDLER=y
+CONFIG_ARCH_CLOCKSOURCE_DATA=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
+# end of Timers subsystem
+
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+CONFIG_PREEMPT_COUNT=y
+
+#
+# CPU/Task time and stats accounting
+#
+CONFIG_TICK_CPU_ACCOUNTING=y
+# CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set
+CONFIG_IRQ_TIME_ACCOUNTING=y
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_PSI is not set
+# end of CPU/Task time and stats accounting
+
+#
+# RCU Subsystem
+#
+CONFIG_TINY_RCU=y
+# CONFIG_RCU_EXPERT is not set
+CONFIG_SRCU=y
+CONFIG_TINY_SRCU=y
+# end of RCU Subsystem
+
+# CONFIG_IKCONFIG is not set
+# CONFIG_IKHEADERS is not set
+CONFIG_LOG_BUF_SHIFT=16
+CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=13
+# CONFIG_FBX_DECRYPT_INITRD is not set
+CONFIG_GENERIC_SCHED_CLOCK=y
+
+#
+# Scheduler features
+#
+# end of Scheduler features
+
+CONFIG_CGROUPS=y
+# CONFIG_MEMCG is not set
+# CONFIG_BLK_CGROUP is not set
+# CONFIG_CGROUP_SCHED is not set
+# CONFIG_CGROUP_PIDS is not set
+# CONFIG_CGROUP_RDMA is not set
+# CONFIG_CGROUP_FREEZER is not set
+# CONFIG_CGROUP_DEVICE is not set
+# CONFIG_CGROUP_CPUACCT is not set
+# CONFIG_CGROUP_DEBUG is not set
+CONFIG_NAMESPACES=y
+CONFIG_UTS_NS=y
+CONFIG_IPC_NS=y
+# CONFIG_USER_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_NET_NS=y
+# CONFIG_CHECKPOINT_RESTORE is not set
+# 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_INITRAMFS_FORCE is not set
+# 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_PERFORMANCE is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=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_FHANDLE is not set
+CONFIG_POSIX_TIMERS=y
+CONFIG_PRINTK=y
+CONFIG_PRINTK_NMI=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_FUTEX_PI=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_AIO=y
+# CONFIG_IO_URING is not set
+CONFIG_ADVISE_SYSCALLS=y
+CONFIG_MEMBARRIER=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+CONFIG_KALLSYMS_BASE_RELATIVE=y
+# CONFIG_BPF_SYSCALL is not set
+# CONFIG_USERFAULTFD is not set
+CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE=y
+# CONFIG_RSEQ is not set
+CONFIG_EMBEDDED=y
+CONFIG_HAVE_PERF_EVENTS=y
+CONFIG_PERF_USE_VMALLOC=y
+# CONFIG_PC104 is not set
+
+#
+# Kernel Performance Events And Counters
+#
+# CONFIG_PERF_EVENTS is not set
+# end of Kernel Performance Events And Counters
+
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_SLUB_DEBUG=y
+CONFIG_COMPAT_BRK=y
+# CONFIG_SLAB is not set
+CONFIG_SLUB=y
+# CONFIG_SLOB is not set
+CONFIG_SLAB_MERGE_DEFAULT=y
+# CONFIG_SLAB_FREELIST_RANDOM is not set
+# CONFIG_SLAB_FREELIST_HARDENED is not set
+# CONFIG_SHUFFLE_PAGE_ALLOCATOR is not set
+# CONFIG_PROFILING is not set
+# end of General setup
+
+CONFIG_ARM=y
+CONFIG_ARM_HAS_SG_CHAIN=y
+CONFIG_SYS_SUPPORTS_APM_EMULATION=y
+CONFIG_HAVE_PROC_CPU=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_FIX_EARLYCON_MEM=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_ARCH_SUPPORTS_UPROBES=y
+CONFIG_ARM_PATCH_PHYS_VIRT=y
+CONFIG_GENERIC_BUG=y
+CONFIG_PGTABLE_LEVELS=2
+
+#
+# System Type
+#
+CONFIG_MMU=y
+CONFIG_ARCH_MMAP_RND_BITS_MIN=8
+CONFIG_ARCH_MMAP_RND_BITS_MAX=15
+CONFIG_ARCH_MULTIPLATFORM=y
+# CONFIG_ARCH_EBSA110 is not set
+# CONFIG_ARCH_EP93XX is not set
+# CONFIG_ARCH_FOOTBRIDGE is not set
+# CONFIG_ARCH_IOP32X is not set
+# CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_DOVE is not set
+# CONFIG_ARCH_PXA is not set
+# CONFIG_ARCH_RPC is not set
+# CONFIG_ARCH_SA1100 is not set
+# CONFIG_ARCH_S3C24XX 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
+# end of Multiple platform selection
+
+# CONFIG_MACH_ASM9260 is not set
+# CONFIG_ARCH_ASPEED is not set
+# CONFIG_ARCH_AT91 is not set
+# CONFIG_ARCH_DAVINCI is not set
+# CONFIG_ARCH_MXC is not set
+# CONFIG_ARCH_INTEGRATOR is not set
+# CONFIG_ARCH_LPC32XX is not set
+# CONFIG_ARCH_MMP is not set
+# CONFIG_ARCH_MV78XX0 is not set
+CONFIG_ARCH_MVEBU=y
+CONFIG_MACH_MVEBU_ANY=y
+CONFIG_MACH_KIRKWOOD=y
+# CONFIG_MACH_KIRKWOOD_DTB is not set
+CONFIG_FBXGW_COMMON=y
+CONFIG_MACH_FBXGW2R=y
+CONFIG_MACH_FBXGW1R=y
+CONFIG_FBXGW_COMMON_ETHSW=y
+# CONFIG_FBXGW_COMMON_NAND_SAFE_READ_TIMINGS is not set
+# CONFIG_FBXGW_COMMON_NAND_SAFE_WRITE_TIMINGS is not set
+# CONFIG_ARCH_MXS is not set
+# CONFIG_ARCH_NOMADIK is not set
+# CONFIG_ARCH_NSPIRE is not set
+# CONFIG_ARCH_ORION5X is not set
+# CONFIG_ARCH_OXNAS is not set
+# CONFIG_ARCH_REALVIEW is not set
+# CONFIG_PLAT_SPEAR is not set
+# CONFIG_ARCH_SUNXI is not set
+# CONFIG_ARCH_U300 is not set
+# CONFIG_ARCH_VERSATILE 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_THUMB_CAPABLE=y
+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_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_ARM_L1_CACHE_SHIFT=5
+CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
+CONFIG_DEBUG_ALIGN_RODATA=y
+# end of System Type
+
+#
+# Bus support
+#
+# end of Bus support
+
+#
+# Kernel Features
+#
+# CONFIG_VMSPLIT_3G is not set
+# CONFIG_VMSPLIT_3G_OPT is not set
+CONFIG_VMSPLIT_2G=y
+# CONFIG_VMSPLIT_1G is not set
+CONFIG_PAGE_OFFSET=0x80000000
+CONFIG_ARCH_NR_GPIO=0
+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_HAVE_ARCH_PFN_VALID=y
+# CONFIG_HIGHMEM is not set
+# CONFIG_CPU_SW_DOMAIN_PAN is not set
+CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
+# CONFIG_ARM_MODULE_PLTS is not set
+CONFIG_FORCE_MAX_ZONEORDER=11
+CONFIG_ALIGNMENT_TRAP=y
+# CONFIG_UACCESS_WITH_MEMCPY is not set
+CONFIG_SECCOMP=y
+# CONFIG_PARAVIRT is not set
+# CONFIG_PARAVIRT_TIME_ACCOUNTING is not set
+# end of Kernel Features
+
+#
+# Boot options
+#
+CONFIG_USE_OF=y
+# CONFIG_DT_OVERRIDE_BUILTIN is not set
+CONFIG_ATAGS=y
+# CONFIG_DEPRECATED_PARAM_STRUCT is not set
+CONFIG_DT_FROM_MACHTYPE=y
+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 coherent_pool=1M"
+# 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
+# CONFIG_EFI is not set
+# end of Boot options
+
+#
+# CPU Power Management
+#
+
+#
+# CPU Frequency scaling
+#
+# CONFIG_CPU_FREQ is not set
+# end of CPU Frequency scaling
+
+#
+# CPU Idle
+#
+# CONFIG_CPU_IDLE is not set
+# end of CPU Idle
+# end of CPU Power Management
+
+#
+# Floating point emulation
+#
+
+#
+# At least one emulation must be selected
+#
+# CONFIG_VFP is not set
+# end of Floating point emulation
+
+#
+# Power management options
+#
+# CONFIG_SUSPEND is not set
+# CONFIG_HIBERNATION is not set
+# CONFIG_PM is not set
+# CONFIG_APM_EMULATION is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+# end of Power management options
+
+#
+# Firmware Drivers
+#
+# CONFIG_FIRMWARE_MEMMAP is not set
+# CONFIG_FW_CFG_SYSFS is not set
+# CONFIG_GOOGLE_FIRMWARE is not set
+
+#
+# Tegra firmware driver
+#
+# end of Tegra firmware driver
+# end of Firmware Drivers
+
+# CONFIG_ARM_CRYPTO is not set
+# CONFIG_VIRTUALIZATION is not set
+
+#
+# General architecture-dependent options
+#
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_KPROBES is not set
+# CONFIG_JUMP_LABEL is not set
+CONFIG_ARCH_USE_BUILTIN_BSWAP=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_OPTPROBES=y
+CONFIG_HAVE_NMI=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+CONFIG_HAVE_DMA_CONTIGUOUS=y
+CONFIG_GENERIC_SMP_IDLE_THREAD=y
+CONFIG_GENERIC_IDLE_POLL_SETUP=y
+CONFIG_ARCH_HAS_FORTIFY_SOURCE=y
+CONFIG_ARCH_HAS_KEEPINITRD=y
+CONFIG_ARCH_HAS_SET_MEMORY=y
+CONFIG_HAVE_ARCH_THREAD_STRUCT_WHITELIST=y
+CONFIG_ARCH_32BIT_OFF_T=y
+CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
+CONFIG_HAVE_RSEQ=y
+CONFIG_HAVE_CLK=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_STACKPROTECTOR=y
+CONFIG_CC_HAS_STACKPROTECTOR_NONE=y
+# CONFIG_STACKPROTECTOR 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_HAVE_ARCH_MMAP_RND_BITS=y
+CONFIG_HAVE_EXIT_THREAD=y
+CONFIG_ARCH_MMAP_RND_BITS=8
+CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT=y
+CONFIG_HAVE_COPY_THREAD_TLS=y
+CONFIG_CLONE_BACKWARDS=y
+CONFIG_OLD_SIGSUSPEND3=y
+CONFIG_OLD_SIGACTION=y
+CONFIG_64BIT_TIME=y
+CONFIG_COMPAT_32BIT_TIME=y
+CONFIG_ARCH_OPTIONAL_KERNEL_RWX=y
+CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y
+CONFIG_STRICT_KERNEL_RWX=y
+CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y
+CONFIG_STRICT_MODULE_RWX=y
+CONFIG_ARCH_HAS_PHYS_TO_DMA=y
+CONFIG_REFCOUNT_FULL=y
+# CONFIG_LOCK_EVENT_COUNTS is not set
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
+# end of GCOV-based kernel profiling
+
+CONFIG_PLUGIN_HOSTCC="g++"
+CONFIG_HAVE_GCC_PLUGINS=y
+CONFIG_GCC_PLUGINS=y
+# CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
+# CONFIG_GCC_PLUGIN_LATENT_ENTROPY is not set
+# CONFIG_GCC_PLUGIN_RANDSTRUCT is not set
+# end of General architecture-dependent options
+
+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_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+# CONFIG_TRIM_UNUSED_KSYMS is not set
+CONFIG_BLOCK=y
+CONFIG_BLK_SCSI_REQUEST=y
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_BSGLIB is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+# CONFIG_BLK_DEV_ZONED is not set
+# CONFIG_BLK_CMDLINE_PARSER is not set
+# CONFIG_BLK_WBT is not set
+CONFIG_BLK_DEBUG_FS=y
+# CONFIG_BLK_SED_OPAL 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
+# CONFIG_OF_PARTITION is not set
+# end of Partition Types
+
+CONFIG_BLK_MQ_PCI=y
+
+#
+# IO Schedulers
+#
+CONFIG_MQ_IOSCHED_DEADLINE=y
+CONFIG_MQ_IOSCHED_KYBER=y
+# CONFIG_IOSCHED_BFQ is not set
+# end of IO Schedulers
+
+CONFIG_UNINLINE_SPIN_UNLOCK=y
+CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_ELF_FDPIC is not set
+CONFIG_ELFCORE=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_BINFMT_SCRIPT=y
+CONFIG_ARCH_HAS_BINFMT_FLAT=y
+# CONFIG_BINFMT_FLAT is not set
+CONFIG_BINFMT_FLAT_ARGVP_ENVP_ON_STACK=y
+# CONFIG_BINFMT_MISC is not set
+CONFIG_COREDUMP=y
+# end of Executable file formats
+
+#
+# Memory Management options
+#
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_ARCH_KEEP_MEMBLOCK=y
+CONFIG_SPLIT_PTLOCK_CPUS=999999
+# CONFIG_COMPACTION is not set
+# 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_GENERIC_EARLY_IOREMAP=y
+# CONFIG_IDLE_PAGE_TRACKING is not set
+# CONFIG_PERCPU_STATS is not set
+# CONFIG_GUP_BENCHMARK is not set
+# end of Memory Management options
+
+CONFIG_NET=y
+CONFIG_NET_INGRESS=y
+CONFIG_NET_EGRESS=y
+CONFIG_SKB_EXTENSIONS=y
+
+#
+# Networking options
+#
+CONFIG_NETSKBPAD=64
+CONFIG_NETRXTHREAD=y
+CONFIG_NETRXTHREAD_RX_QUEUE=2
+CONFIG_NET_NMESH_MBH=y
+CONFIG_PACKET=y
+# CONFIG_PACKET_DIAG is not set
+CONFIG_UNIX=y
+CONFIG_UNIX_SCM=y
+CONFIG_UNIX_ABSTRACT_IGNORE_NETNS=y
+# CONFIG_UNIX_DIAG is not set
+# CONFIG_TLS is not set
+CONFIG_XFRM=y
+CONFIG_XFRM_OFFLOAD=y
+CONFIG_XFRM_ALGO=y
+CONFIG_XFRM_USER=y
+CONFIG_XFRM_INTERFACE=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_FOU is not set
+# CONFIG_NET_FOU_IP_TUNNELS is not set
+CONFIG_INET_AH=y
+CONFIG_INET_ESP=y
+# CONFIG_INET_ESP_OFFLOAD is not set
+# CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TUNNEL=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_INET_UDP_DIAG is not set
+# CONFIG_INET_RAW_DIAG is not set
+# CONFIG_INET_DIAG_DESTROY 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=y
+CONFIG_INET6_ESP=y
+CONFIG_INET6_ESP_OFFLOAD=y
+# CONFIG_INET6_IPCOMP is not set
+# CONFIG_IPV6_MIP6 is not set
+# CONFIG_IPV6_ILA is not set
+CONFIG_INET6_TUNNEL=y
+# CONFIG_IPV6_VTI 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=y
+CONFIG_IPV6_SUBTREES=y
+# CONFIG_IPV6_MROUTE is not set
+# CONFIG_IPV6_SEG6_LWTUNNEL is not set
+# CONFIG_IPV6_SEG6_HMAC is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETWORK_PHY_TIMESTAMPING is not set
+CONFIG_NETFILTER=y
+CONFIG_NETFILTER_ADVANCED=y
+# CONFIG_BRIDGE_NETFILTER is not set
+
+#
+# Core Netfilter Configuration
+#
+# CONFIG_NETFILTER_INGRESS is not set
+# CONFIG_NETFILTER_NETLINK_ACCT is not set
+# CONFIG_NETFILTER_NETLINK_QUEUE is not set
+# CONFIG_NETFILTER_NETLINK_LOG is not set
+# CONFIG_NETFILTER_NETLINK_OSF is not set
+CONFIG_NF_CONNTRACK=y
+# CONFIG_NF_LOG_NETDEV is not set
+# CONFIG_NF_CONNTRACK_MARK is not set
+# CONFIG_NF_CONNTRACK_ZONES 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_CONNTRACK_LABELS is not set
+CONFIG_NF_CT_PROTO_DCCP=y
+CONFIG_NF_CT_PROTO_GRE=y
+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_NAT=y
+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_NAT_MASQUERADE=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_MASQUERADE=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_OSF 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
+# end of Core Netfilter Configuration
+
+# CONFIG_IP_SET is not set
+# CONFIG_IP_VS is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_FFN=y
+CONFIG_IP_FFN_PROCFS=y
+CONFIG_NF_DEFRAG_IPV4=y
+# CONFIG_NF_SOCKET_IPV4 is not set
+CONFIG_NF_TPROXY_IPV4=y
+# CONFIG_NF_DUP_IPV4 is not set
+# CONFIG_NF_LOG_ARP is not set
+# CONFIG_NF_LOG_IPV4 is not set
+CONFIG_NF_REJECT_IPV4=y
+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
+# end of IP: Netfilter Configuration
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IPV6_FFN=y
+CONFIG_IPV6_FFN_PROCFS=y
+# CONFIG_NF_SOCKET_IPV6 is not set
+CONFIG_NF_TPROXY_IPV6=y
+# CONFIG_NF_DUP_IPV6 is not set
+CONFIG_NF_REJECT_IPV6=y
+# CONFIG_NF_LOG_IPV6 is not set
+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_MATCH_SRH 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
+# end of IPv6: Netfilter Configuration
+
+CONFIG_NF_DEFRAG_IPV6=y
+# CONFIG_NF_CONNTRACK_BRIDGE is not set
+# CONFIG_BRIDGE_NF_EBTABLES is not set
+# CONFIG_BPFILTER 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_NET_DSA is not set
+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_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_CBS is not set
+# CONFIG_NET_SCH_ETF is not set
+# CONFIG_NET_SCH_TAPRIO 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_SKBPRIO 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_CAKE is not set
+# 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
+# CONFIG_NET_SCH_DEFAULT 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_CLS_MATCHALL 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_SAMPLE 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_MPLS is not set
+# CONFIG_NET_ACT_VLAN is not set
+# CONFIG_NET_ACT_BPF is not set
+# CONFIG_NET_ACT_SKBMOD is not set
+# CONFIG_NET_ACT_IFE is not set
+# CONFIG_NET_ACT_TUNNEL_KEY is not set
+# CONFIG_NET_ACT_CT is not set
+# CONFIG_NET_TC_SKB_EXT 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_DIAG is not set
+# CONFIG_MPLS is not set
+# CONFIG_NET_NSH is not set
+# CONFIG_HSR is not set
+# CONFIG_NET_SWITCHDEV is not set
+# CONFIG_NET_L3_MASTER_DEV is not set
+# CONFIG_NET_NCSI 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
+# end of Network testing
+# end of Networking options
+
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN 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_HS=y
+# CONFIG_BT_LE is not set
+# CONFIG_BT_LEDS 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_AUTOSUSPEND is not set
+# CONFIG_BT_HCIBTUSB_BCM is not set
+# CONFIG_BT_HCIBTUSB_MTK 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
+# end of Bluetooth device drivers
+
+# CONFIG_AF_RXRPC is not set
+# CONFIG_AF_KCM is not set
+CONFIG_FIB_RULES=y
+CONFIG_WIRELESS=y
+CONFIG_CFG80211=y
+CONFIG_NL80211_TESTMODE=y
+# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set
+CONFIG_CFG80211_CERTIFICATION_ONUS=y
+# CONFIG_CFG80211_REQUIRE_SIGNED_REGDB is not set
+# 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_CRDA_SUPPORT=y
+# CONFIG_CFG80211_WEXT is not set
+CONFIG_MAC80211=y
+CONFIG_MAC80211_HAS_RC=y
+CONFIG_MAC80211_RC_MINSTREL=y
+CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y
+CONFIG_MAC80211_RC_DEFAULT="minstrel_ht"
+CONFIG_MAC80211_MESH=y
+CONFIG_MAC80211_LEDS=y
+CONFIG_MAC80211_DEBUGFS=y
+# 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_PSAMPLE is not set
+# CONFIG_NET_IFE is not set
+# CONFIG_LWTUNNEL is not set
+CONFIG_DST_CACHE=y
+CONFIG_GRO_CELLS=y
+# CONFIG_FAILOVER is not set
+CONFIG_HAVE_EBPF_JIT=y
+
+#
+# Device Drivers
+#
+CONFIG_HAVE_PCI=y
+CONFIG_FORCE_PCI=y
+CONFIG_PCI=y
+CONFIG_PCI_DOMAINS=y
+CONFIG_PCI_DOMAINS_GENERIC=y
+CONFIG_PCI_SYSCALL=y
+CONFIG_PCIEPORTBUS=y
+CONFIG_PCIEAER=y
+# CONFIG_PCIEAER_INJECT is not set
+# CONFIG_PCIE_ECRC is not set
+# CONFIG_PCIEASPM is not set
+# CONFIG_PCIE_DPC is not set
+# CONFIG_PCIE_PTM is not set
+# CONFIG_PCIE_BW is not set
+# CONFIG_PCI_MSI is not set
+CONFIG_PCI_QUIRKS=y
+# CONFIG_PCI_DEBUG is not set
+# CONFIG_PCI_STUB is not set
+CONFIG_PCI_BRIDGE_EMUL=y
+# CONFIG_PCI_IOV is not set
+# CONFIG_PCI_PRI is not set
+# CONFIG_PCI_PASID is not set
+# CONFIG_HOTPLUG_PCI is not set
+
+#
+# PCI controller drivers
+#
+CONFIG_PCI_MVEBU=y
+
+#
+# Cadence PCIe controllers support
+#
+# CONFIG_PCIE_CADENCE_HOST is not set
+# end of Cadence PCIe controllers support
+
+# CONFIG_PCI_FTPCI100 is not set
+# CONFIG_PCI_HOST_GENERIC is not set
+# CONFIG_PCIE_XILINX is not set
+# CONFIG_PCI_V3_SEMI is not set
+# CONFIG_PCIE_ALTERA is not set
+
+#
+# DesignWare PCI Core Support
+#
+# end of DesignWare PCI Core Support
+# end of PCI controller drivers
+
+#
+# PCI Endpoint
+#
+# CONFIG_PCI_ENDPOINT is not set
+# end of PCI Endpoint
+
+#
+# PCI switch controller drivers
+#
+# CONFIG_PCI_SW_SWITCHTEC is not set
+# end of PCI switch controller drivers
+
+# CONFIG_PCCARD is not set
+# CONFIG_RAPIDIO is not set
+
+#
+# Generic Driver Options
+#
+# CONFIG_UEVENT_HELPER is not set
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+
+#
+# Firmware loader
+#
+CONFIG_FW_LOADER=y
+CONFIG_FW_LOADER_PAGED_BUF=y
+CONFIG_EXTRA_FIRMWARE=""
+CONFIG_FW_LOADER_USER_HELPER=y
+CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
+# CONFIG_FW_LOADER_COMPRESS is not set
+# end of Firmware loader
+
+CONFIG_WANT_DEV_COREDUMP=y
+# CONFIG_ALLOW_DEV_COREDUMP is not set
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_DEBUG_TEST_DRIVER_REMOVE is not set
+# CONFIG_TEST_ASYNC_DRIVER_PROBE is not set
+CONFIG_GENERIC_CPU_AUTOPROBE=y
+CONFIG_SOC_BUS=y
+CONFIG_REGMAP=y
+CONFIG_REGMAP_I2C=y
+CONFIG_REGMAP_SPI=y
+CONFIG_REGMAP_MMIO=y
+# end of Generic Driver Options
+
+#
+# Bus devices
+#
+# CONFIG_BRCMSTB_GISB_ARB is not set
+# CONFIG_MOXTET is not set
+CONFIG_MVEBU_MBUS=y
+# CONFIG_VEXPRESS_CONFIG is not set
+# end of Bus devices
+
+# CONFIG_CONNECTOR is not set
+# CONFIG_GNSS is not set
+CONFIG_FREEBOX_PROCFS=y
+CONFIG_MTD=y
+# CONFIG_MTD_TESTS is not set
+CONFIG_MTD_ERASE_PRINTK=y
+
+#
+# Partition parsers
+#
+# CONFIG_MTD_AR7_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+CONFIG_MTD_OF_PARTS=y
+# CONFIG_MTD_OF_PARTS_IGNORE_RO is not set
+# CONFIG_MTD_AFS_PARTS is not set
+# CONFIG_MTD_REDBOOT_PARTS is not set
+# CONFIG_MTD_FBX6HD_PARTS is not set
+# end of Partition parsers
+
+#
+# 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_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+# end of RAM/ROM/Flash chip drivers
+
+#
+# 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
+# end of Mapping drivers for chip access
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_MCHP23K256 is not set
+# 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
+# end of Self-contained MTD device drivers
+
+CONFIG_MTD_NAND_CORE=y
+# CONFIG_MTD_ONENAND is not set
+CONFIG_MTD_NAND_ECC_SW_HAMMING=y
+# CONFIG_MTD_NAND_ECC_SW_HAMMING_SMC is not set
+CONFIG_MTD_RAW_NAND=y
+CONFIG_MTD_NAND_ECC_SW_BCH=y
+
+#
+# Raw/parallel NAND flash controllers
+#
+# CONFIG_MTD_FORCE_BAD_BLOCK_ERASE is not set
+# CONFIG_MTD_NAND_DENALI_PCI is not set
+# CONFIG_MTD_NAND_DENALI_DT is not set
+# CONFIG_MTD_NAND_DENALI_FBX is not set
+# CONFIG_MTD_NAND_CAFE is not set
+CONFIG_MTD_NAND_ORION=y
+# CONFIG_MTD_NAND_MARVELL is not set
+# CONFIG_MTD_NAND_BRCMNAND is not set
+# CONFIG_MTD_NAND_MXIC is not set
+# CONFIG_MTD_NAND_GPIO is not set
+# CONFIG_MTD_NAND_PLATFORM is not set
+
+#
+# Misc
+#
+# CONFIG_MTD_NAND_NANDSIM is not set
+# CONFIG_MTD_NAND_RICOH is not set
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+# CONFIG_MTD_SPI_NAND is not set
+
+#
+# LPDDR & LPDDR2 PCM memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+# CONFIG_MTD_LPDDR2_NVM is not set
+# end of LPDDR & LPDDR2 PCM memory drivers
+
+CONFIG_MTD_SPI_NOR=y
+# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
+# CONFIG_SPI_CADENCE_QUADSPI is not set
+# CONFIG_SPI_MTK_QUADSPI 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_MTD_HYPERBUS is not set
+CONFIG_DTC=y
+CONFIG_OF=y
+# CONFIG_OF_UNITTEST is not set
+CONFIG_OF_DTB_BUILTIN_LIST="fbxgw1r fbxgw2r"
+CONFIG_OF_FLATTREE=y
+CONFIG_OF_EARLY_FLATTREE=y
+CONFIG_OF_KOBJ=y
+CONFIG_OF_DYNAMIC=y
+CONFIG_OF_ADDRESS=y
+CONFIG_OF_IRQ=y
+CONFIG_OF_NET=y
+CONFIG_OF_MDIO=y
+CONFIG_OF_RESERVED_MEM=y
+CONFIG_OF_RESOLVE=y
+CONFIG_OF_OVERLAY=y
+CONFIG_OF_CONFIGFS=y
+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_DEV_UMEM 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_SX8 is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=1
+CONFIG_BLK_DEV_RAM_SIZE=65536
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_BLK_DEV_RBD is not set
+# CONFIG_BLK_DEV_RSXX is not set
+
+#
+# NVME Support
+#
+# CONFIG_BLK_DEV_NVME is not set
+# CONFIG_NVME_FC is not set
+# CONFIG_NVME_TARGET is not set
+# end of NVME Support
+
+#
+# Misc devices
+#
+# CONFIG_WINTEGRA_MMAP is not set
+# CONFIG_AD525X_DPOT is not set
+# CONFIG_DUMMY_IRQ is not set
+# CONFIG_PHANTOM 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_BH1770 is not set
+# CONFIG_SENSORS_APDS990X is not set
+# CONFIG_HMC6352 is not set
+# CONFIG_DS1682 is not set
+# CONFIG_INTELCE_PIC16PMU is not set
+# CONFIG_FBXSERIAL_OF is not set
+# CONFIG_RANDOM_OF is not set
+# CONFIG_LATTICE_ECP3_CONFIG is not set
+# CONFIG_SRAM is not set
+# CONFIG_PCI_ENDPOINT_TEST is not set
+# CONFIG_XILINX_SDFEC is not set
+# CONFIG_PVPANIC 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_EEPROM_IDT_89HPESX is not set
+# CONFIG_EEPROM_EE1004 is not set
+# CONFIG_EEPROM_EE1004_RAW is not set
+# end of EEPROM support
+
+# CONFIG_CB710_CORE is not set
+
+#
+# Texas Instruments shared transport line discipline
+#
+# CONFIG_TI_ST is not set
+# end of Texas Instruments shared transport line discipline
+
+# CONFIG_SENSORS_LIS3_SPI is not set
+# CONFIG_SENSORS_LIS3_I2C is not set
+# CONFIG_ALTERA_STAPL is not set
+
+#
+# Intel MIC & related support
+#
+
+#
+# Intel MIC Bus Driver
+#
+
+#
+# SCIF Bus Driver
+#
+
+#
+# VOP Bus Driver
+#
+# CONFIG_VOP_BUS is not set
+
+#
+# Intel MIC Host Driver
+#
+
+#
+# Intel MIC Card Driver
+#
+
+#
+# SCIF Driver
+#
+
+#
+# Intel MIC Coprocessor State Management (COSM) Drivers
+#
+
+#
+# VOP Driver
+#
+# end of Intel MIC & related support
+
+# CONFIG_ECHO is not set
+# CONFIG_MISC_ALCOR_PCI is not set
+# CONFIG_MISC_RTSX_PCI is not set
+# CONFIG_MISC_RTSX_USB is not set
+# CONFIG_HABANA_AI is not set
+
+#
+# RemoTI support
+#
+# end of RemoTI support
+
+#
+# HDMI CEC support
+#
+# CONFIG_HDMI_CEC is not set
+# end of HDMI CEC support
+# end of Misc devices
+
+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_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_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
+# end of SCSI Transports
+
+# CONFIG_SCSI_LOWLEVEL is not set
+# CONFIG_SCSI_DH is not set
+# end of SCSI device support
+
+CONFIG_ATA=y
+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_AHCI_QORIQ 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_DEBUG is not set
+# CONFIG_DM_UNSTRIPED 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_WRITECACHE is not set
+# CONFIG_DM_ERA is not set
+# CONFIG_DM_CLONE 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_DUST is not set
+# CONFIG_DM_INIT 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_DM_INTEGRITY 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
+# end of IEEE 1394 (FireWire) support
+
+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_GENEVE is not set
+# CONFIG_GTP is not set
+# CONFIG_MACSEC is not set
+# CONFIG_NETCONSOLE is not set
+CONFIG_TUN=y
+# CONFIG_TUN_VNET_CROSS_LE is not set
+CONFIG_VETH=y
+# CONFIG_NLMON is not set
+# CONFIG_ARCNET is not set
+
+#
+# CAIF transport drivers
+#
+
+#
+# Distributed Switch Architecture drivers
+#
+# end of Distributed Switch Architecture drivers
+
+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_ALACRITECH is not set
+# CONFIG_NET_VENDOR_ALTEON is not set
+# CONFIG_ALTERA_TSE is not set
+# CONFIG_NET_VENDOR_AMAZON is not set
+# CONFIG_NET_VENDOR_AMD is not set
+# CONFIG_NET_VENDOR_AQUANTIA is not set
+# CONFIG_NET_VENDOR_ARC is not set
+CONFIG_NET_VENDOR_ATHEROS=y
+# CONFIG_ATL2 is not set
+# CONFIG_ATL1 is not set
+# CONFIG_ATL1E is not set
+CONFIG_ATL1C=m
+# CONFIG_ALX is not set
+# CONFIG_NET_VENDOR_AURORA is not set
+# CONFIG_NET_VENDOR_BROADCOM is not set
+# CONFIG_NET_VENDOR_BROCADE is not set
+# CONFIG_NET_VENDOR_CADENCE 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_NET_VENDOR_CORTINA 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_FARADAY is not set
+# CONFIG_NET_VENDOR_GOOGLE is not set
+# CONFIG_NET_VENDOR_HISILICON is not set
+# CONFIG_NET_VENDOR_HP is not set
+# CONFIG_NET_VENDOR_HUAWEI is not set
+# CONFIG_NET_VENDOR_INTEL 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_MVPP2 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_MICROSEMI 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_NETERION is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
+# CONFIG_NET_VENDOR_NI is not set
+# CONFIG_NET_VENDOR_NVIDIA is not set
+# CONFIG_NET_VENDOR_OKI is not set
+# CONFIG_ETHOC is not set
+# CONFIG_NET_VENDOR_PACKET_ENGINES is not set
+# CONFIG_NET_VENDOR_PENSANDO is not set
+# CONFIG_NET_VENDOR_QLOGIC is not set
+# CONFIG_NET_VENDOR_QUALCOMM is not set
+# CONFIG_NET_VENDOR_RDC is not set
+# CONFIG_NET_VENDOR_REALTEK is not set
+# CONFIG_NET_VENDOR_RENESAS 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_SOLARFLARE is not set
+# CONFIG_NET_VENDOR_SILAN is not set
+# CONFIG_NET_VENDOR_SIS is not set
+# CONFIG_NET_VENDOR_SMSC is not set
+# CONFIG_NET_VENDOR_SOCIONEXT is not set
+# CONFIG_NET_VENDOR_STMICRO is not set
+# CONFIG_NET_VENDOR_SUN is not set
+# CONFIG_NET_VENDOR_SYNOPSYS 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_NET_VENDOR_XILINX is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+CONFIG_MDIO_DEVICE=y
+CONFIG_MDIO_BUS=y
+# CONFIG_MDIO_BCM_UNIMAC 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_BUS_MUX_MULTIPLEXER is not set
+# CONFIG_MDIO_HISI_FEMAC is not set
+# CONFIG_MDIO_MSCC_MIIM is not set
+CONFIG_PHYLIB=y
+CONFIG_SWPHY=y
+# CONFIG_LED_TRIGGER_PHY is not set
+
+#
+# MII PHY device drivers
+#
+# CONFIG_ADIN_PHY is not set
+# CONFIG_AMD_PHY is not set
+# CONFIG_AQUANTIA_PHY is not set
+# CONFIG_AX88796B_PHY is not set
+# CONFIG_AT803X_PHY is not set
+# CONFIG_BCM7XXX_PHY is not set
+# CONFIG_BCM87XX_PHY is not set
+# CONFIG_BROADCOM_PHY is not set
+# CONFIG_CICADA_PHY is not set
+# CONFIG_CORTINA_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_DP83822_PHY is not set
+# CONFIG_DP83TC811_PHY is not set
+# CONFIG_DP83848_PHY is not set
+# CONFIG_DP83867_PHY is not set
+CONFIG_FIXED_PHY=y
+# CONFIG_ICPLUS_PHY is not set
+# CONFIG_INTEL_XWAY_PHY is not set
+# CONFIG_LSI_ET1011C_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_MARVELL_10G_PHY is not set
+# CONFIG_MICREL_PHY is not set
+# CONFIG_MICROCHIP_PHY is not set
+# CONFIG_MICROCHIP_T1_PHY is not set
+# CONFIG_MICROSEMI_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_NXP_TJA11XX_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_REALTEK_PHY is not set
+# CONFIG_RENESAS_PHY is not set
+# CONFIG_ROCKCHIP_PHY is not set
+# CONFIG_SMSC_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_TERANETICS_PHY is not set
+# CONFIG_VITESSE_PHY is not set
+# CONFIG_XILINX_GMII2RGMII 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_WIRELESS_WDS is not set
+# CONFIG_WLAN_VENDOR_ADMTEK is not set
+CONFIG_ATH_COMMON=y
+CONFIG_WLAN_VENDOR_ATH=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_CE=y
+CONFIG_ATH10K_PCI=m
+# CONFIG_ATH10K_AHB is not set
+# CONFIG_ATH10K_USB is not set
+# CONFIG_ATH10K_DEBUG is not set
+# CONFIG_ATH10K_DEBUGFS is not set
+CONFIG_ATH10K_DFS_CERTIFIED=y
+# CONFIG_WCN36XX is not set
+# CONFIG_WLAN_VENDOR_ATMEL is not set
+# CONFIG_WLAN_VENDOR_BROADCOM is not set
+# CONFIG_WLAN_VENDOR_CISCO is not set
+# CONFIG_WLAN_VENDOR_INTEL is not set
+# CONFIG_WLAN_VENDOR_INTERSIL is not set
+CONFIG_WLAN_VENDOR_MARVELL=y
+# CONFIG_LIBERTAS is not set
+# CONFIG_LIBERTAS_THINFIRM is not set
+# CONFIG_MWIFIEX is not set
+CONFIG_MWL8K=m
+CONFIG_MWL8K_NEW=m
+# CONFIG_WLAN_VENDOR_MEDIATEK is not set
+# CONFIG_WLAN_VENDOR_RALINK is not set
+# CONFIG_WLAN_VENDOR_REALTEK is not set
+# CONFIG_WLAN_VENDOR_RSI is not set
+# CONFIG_WLAN_VENDOR_ST is not set
+# CONFIG_WLAN_VENDOR_TI is not set
+# CONFIG_WLAN_VENDOR_ZYDAS is not set
+# CONFIG_WLAN_VENDOR_QUANTENNA is not set
+CONFIG_MAC80211_HWSIM=m
+# CONFIG_USB_NET_RNDIS_WLAN is not set
+# CONFIG_VIRT_WIFI is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+# CONFIG_WAN is not set
+# CONFIG_VMXNET3 is not set
+# CONFIG_NETDEVSIM is not set
+# CONFIG_NET_FAILOVER is not set
+# CONFIG_ISDN is not set
+# CONFIG_NVM 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_ATMEL_CAPTOUCH is not set
+# CONFIG_INPUT_BMA150 is not set
+# CONFIG_INPUT_E3X0_BUTTON is not set
+# CONFIG_INPUT_MSM_VIBRATOR is not set
+# CONFIG_INPUT_MMA8450 is not set
+# CONFIG_INPUT_GP2A is not set
+# CONFIG_INPUT_GPIO_BEEPER is not set
+# CONFIG_INPUT_GPIO_DECODER is not set
+# CONFIG_INPUT_GPIO_VIBRA 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
+# CONFIG_RMI4_CORE is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+# end of Hardware I/O ports
+# end of Input device support
+
+#
+# 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_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_NULL_TTY is not set
+# CONFIG_LDISC_AUTOLOAD 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_FINTEK is not set
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_PCI=y
+# CONFIG_SERIAL_8250_EXAR is not set
+CONFIG_SERIAL_8250_NR_UARTS=4
+CONFIG_SERIAL_8250_RUNTIME_UARTS=2
+# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250_ASPEED_VUART is not set
+CONFIG_SERIAL_8250_FSL=y
+# CONFIG_SERIAL_8250_DW is not set
+# CONFIG_SERIAL_8250_EM is not set
+# CONFIG_SERIAL_8250_RT288X is not set
+CONFIG_SERIAL_OF_PLATFORM=y
+
+#
+# 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_UARTLITE is not set
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_JSM is not set
+# CONFIG_SERIAL_SIFIVE is not set
+# 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_FSL_LINFLEXUART is not set
+# CONFIG_SERIAL_CONEXANT_DIGICOLOR is not set
+# CONFIG_SERIAL_ST_ASC is not set
+# CONFIG_SERIAL_MVEBU_UART is not set
+# end of Serial drivers
+
+CONFIG_SERIAL_MCTRL_GPIO=y
+# CONFIG_SERIAL_DEV_BUS 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_APPLICOM is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+CONFIG_DEVPORT=y
+# CONFIG_XILLYBUS is not set
+# end of Character devices
+
+# CONFIG_RANDOM_TRUST_BOOTLOADER 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_NVIDIA_GPU 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_EMEV2 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 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
+#
+# end of I2C Hardware Bus support
+
+# 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
+# end of I2C support
+
+# CONFIG_I3C is not set
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+CONFIG_SPI_MEM=y
+
+#
+# SPI Master Controller Drivers
+#
+# CONFIG_SPI_ALTERA is not set
+# CONFIG_SPI_ARMADA_3700 is not set
+# CONFIG_SPI_AXI_SPI_ENGINE is not set
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_CADENCE is not set
+# CONFIG_SPI_DESIGNWARE is not set
+# CONFIG_SPI_NXP_FLEXSPI 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_ROCKCHIP is not set
+# CONFIG_SPI_SC18IS602 is not set
+# CONFIG_SPI_SIFIVE is not set
+# CONFIG_SPI_MXIC is not set
+# CONFIG_SPI_XCOMM is not set
+# CONFIG_SPI_XILINX is not set
+# CONFIG_SPI_ZYNQMP_GQSPI is not set
+
+#
+# SPI Protocol Masters
+#
+# CONFIG_SPI_SPIDEV is not set
+# CONFIG_SPI_LOOPBACK_TEST is not set
+# CONFIG_SPI_TLE62X0 is not set
+# CONFIG_SPI_SLAVE is not set
+# CONFIG_SPMI is not set
+# CONFIG_HSI is not set
+# CONFIG_PPS is not set
+
+#
+# PTP clock support
+#
+# CONFIG_PTP_1588_CLOCK is not set
+
+#
+# Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks.
+#
+# end of PTP clock support
+
+CONFIG_PINCTRL=y
+CONFIG_PINMUX=y
+CONFIG_PINCONF=y
+# CONFIG_DEBUG_PINCTRL is not set
+# CONFIG_PINCTRL_AMD is not set
+# CONFIG_PINCTRL_MCP23S08 is not set
+# CONFIG_PINCTRL_SINGLE is not set
+# CONFIG_PINCTRL_SX150X is not set
+# CONFIG_PINCTRL_STMFX is not set
+# CONFIG_PINCTRL_OCELOT is not set
+CONFIG_PINCTRL_MVEBU=y
+CONFIG_PINCTRL_KIRKWOOD=y
+CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIOLIB_FASTPATH_LIMIT=512
+CONFIG_OF_GPIO=y
+# CONFIG_DEBUG_GPIO is not set
+CONFIG_GPIO_SYSFS=y
+
+#
+# Memory mapped GPIO drivers
+#
+# CONFIG_GPIO_74XX_MMIO is not set
+# CONFIG_GPIO_ALTERA is not set
+# CONFIG_GPIO_CADENCE is not set
+# CONFIG_GPIO_DWAPB is not set
+# CONFIG_GPIO_FTGPIO010 is not set
+# CONFIG_GPIO_GENERIC_PLATFORM is not set
+# CONFIG_GPIO_GRGPIO is not set
+# CONFIG_GPIO_HLWD is not set
+# CONFIG_GPIO_MB86S7X is not set
+# CONFIG_GPIO_MPC8XXX is not set
+CONFIG_GPIO_MVEBU=y
+# CONFIG_GPIO_XILINX is not set
+# CONFIG_GPIO_ZEVIO is not set
+# CONFIG_GPIO_AMD_FCH is not set
+# end of Memory mapped GPIO drivers
+
+#
+# I2C GPIO expanders
+#
+# CONFIG_GPIO_ADP5588 is not set
+# CONFIG_GPIO_ADNP is not set
+# CONFIG_GPIO_GW_PLD is not set
+# CONFIG_GPIO_MAX7300 is not set
+# CONFIG_GPIO_MAX732X is not set
+CONFIG_GPIO_PCA953X=y
+# CONFIG_GPIO_PCA953X_IRQ is not set
+# CONFIG_GPIO_PCF857X is not set
+# CONFIG_GPIO_TPIC2810 is not set
+# end of I2C GPIO expanders
+
+#
+# MFD GPIO expanders
+#
+# CONFIG_HTC_EGPIO is not set
+# end of MFD GPIO expanders
+
+#
+# PCI GPIO expanders
+#
+# CONFIG_GPIO_BT8XX is not set
+# CONFIG_GPIO_PCI_IDIO_16 is not set
+# CONFIG_GPIO_PCIE_IDIO_24 is not set
+# CONFIG_GPIO_RDC321X is not set
+# end of PCI GPIO expanders
+
+#
+# SPI GPIO expanders
+#
+# CONFIG_GPIO_74X164 is not set
+# CONFIG_GPIO_MAX3191X is not set
+# CONFIG_GPIO_MAX7301 is not set
+# CONFIG_GPIO_MC33880 is not set
+# CONFIG_GPIO_PISOSR is not set
+# CONFIG_GPIO_XRA1403 is not set
+# end of SPI GPIO expanders
+
+#
+# USB GPIO expanders
+#
+# end of USB GPIO expanders
+
+# CONFIG_GPIO_MOCKUP is not set
+CONFIG_FREEBOX_GPIO=y
+CONFIG_FREEBOX_GPIO_DT=y
+# CONFIG_FREEBOX_JTAG is not set
+# CONFIG_W1 is not set
+# CONFIG_POWER_AVS is not set
+# CONFIG_POWER_RESET is not set
+# CONFIG_POWER_SUPPLY 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_AS370 is not set
+# CONFIG_SENSORS_ASC7621 is not set
+# CONFIG_SENSORS_ASPEED 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_LTC2990 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_MAX31722 is not set
+# CONFIG_SENSORS_MAX6621 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_MAX31790 is not set
+# CONFIG_SENSORS_MCP3021 is not set
+# CONFIG_SENSORS_TC654 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_NPCM7XX is not set
+# CONFIG_SENSORS_NSA320 is not set
+# CONFIG_SENSORS_OCC_P8_I2C 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_SHT3x 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_STTS751 is not set
+# CONFIG_SENSORS_SMM665 is not set
+# CONFIG_SENSORS_ADC128D818 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_INA3221 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_TMP108 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_W83773G 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_SENSORS_LD6710_FBX is not set
+# CONFIG_SENSORS_AP806 is not set
+# CONFIG_THERMAL is not set
+CONFIG_FREEBOX_WATCHDOG=y
+CONFIG_FREEBOX_WATCHDOG_CHAR=y
+CONFIG_FREEBOX_WATCHDOG_ORION=y
+# CONFIG_FREEBOX_WATCHDOG_BCM63XX_OF is not set
+# CONFIG_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+# CONFIG_SSB is not set
+CONFIG_BCMA_POSSIBLE=y
+# CONFIG_BCMA is not set
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_ACT8945A 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_FLEXCOM is not set
+# CONFIG_MFD_ATMEL_HLCDC is not set
+# CONFIG_MFD_BCM590XX is not set
+# CONFIG_MFD_BD9571MWV is not set
+# CONFIG_MFD_AXP20X_I2C is not set
+# CONFIG_MFD_MADERA 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_DA9062 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_PASIC3 is not set
+# CONFIG_HTC_I2CPLD is not set
+# CONFIG_LPC_ICH is not set
+# CONFIG_LPC_SCH 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_MAX77620 is not set
+# CONFIG_MFD_MAX77650 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_CPCAP is not set
+# CONFIG_MFD_VIPERBOARD is not set
+# CONFIG_MFD_RETU is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_MFD_PM8XXX is not set
+# CONFIG_MFD_RDC321X is not set
+# CONFIG_MFD_RT5033 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_TI_LMU 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_TPS65086 is not set
+# CONFIG_MFD_TPS65090 is not set
+# CONFIG_MFD_TPS65217 is not set
+# CONFIG_MFD_TI_LP873X is not set
+# CONFIG_MFD_TI_LP87565 is not set
+# CONFIG_MFD_TPS65218 is not set
+# CONFIG_MFD_TPS6586X is not set
+# CONFIG_MFD_TPS65910 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_T7L66XB is not set
+# CONFIG_MFD_TC6387XB is not set
+# CONFIG_MFD_TC6393XB is not set
+# CONFIG_MFD_TQMX86 is not set
+# CONFIG_MFD_VX855 is not set
+# CONFIG_MFD_LOCHNAGAR 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_MFD_ROHM_BD718XX is not set
+# CONFIG_MFD_ROHM_BD70528 is not set
+# CONFIG_MFD_STPMIC1 is not set
+# CONFIG_MFD_STMFX is not set
+# CONFIG_MFD_FBXGW7R_PANEL is not set
+# end of Multifunction device drivers
+
+# CONFIG_REGULATOR is not set
+CONFIG_RC_CORE=y
+# CONFIG_RC_MAP is not set
+# CONFIG_LIRC is not set
+# CONFIG_RC_DECODERS is not set
+# CONFIG_RC_DEVICES 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_CEC_SUPPORT is not set
+# 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_DVB_MAX_ADAPTERS=8
+# CONFIG_DVB_DYNAMIC_MINORS is not set
+# CONFIG_DVB_DEMUX_SECTION_LOSS_LOG is not set
+# CONFIG_DVB_ULE_DEBUG is not set
+
+#
+# Media drivers
+#
+CONFIG_MEDIA_USB_SUPPORT=y
+
+#
+# Analog/digital TV USB devices
+#
+
+#
+# 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_AZ6027 is not set
+# CONFIG_DVB_USB_TECHNISAT_USB2 is not set
+CONFIG_DVB_USB_V2=y
+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_USB_ZD1301 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
+# CONFIG_DVB_PLATFORM_DRIVERS is not set
+
+#
+# Supported MMC/SDIO adapters
+#
+# CONFIG_CYPRESS_FIRMWARE is not set
+
+#
+# Media ancillary drivers (tuners, sensors, i2c, spi, frontends)
+#
+# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
+CONFIG_MEDIA_ATTACH=y
+
+#
+# Media SPI Adapters
+#
+# CONFIG_CXD2880_SPI_DRV is not set
+# end of Media SPI Adapters
+
+CONFIG_MEDIA_TUNER=y
+
+#
+# Customize TV tuners
+#
+# CONFIG_MEDIA_TUNER_SIMPLE is not set
+# CONFIG_MEDIA_TUNER_TDA18250 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
+# CONFIG_MEDIA_TUNER_QM1D1B0004 is not set
+# end of Customize TV tuners
+
+#
+# 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_STV0910 is not set
+# CONFIG_DVB_STV6110x is not set
+# CONFIG_DVB_STV6111 is not set
+# CONFIG_DVB_MXL5XX 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
+# CONFIG_DVB_MN88472 is not set
+# CONFIG_DVB_MN88473 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_EC100 is not set
+# CONFIG_DVB_STV0367 is not set
+# CONFIG_DVB_CXD2820R is not set
+# CONFIG_DVB_CXD2841ER is not set
+# CONFIG_DVB_ZD1301_DEMOD is not set
+# CONFIG_DVB_CXD2880 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_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
+# CONFIG_DVB_MN88443X 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_LNBH25 is not set
+# CONFIG_DVB_LNBH29 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_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
+# CONFIG_DVB_HORUS3A is not set
+# CONFIG_DVB_ASCOT2E is not set
+# CONFIG_DVB_HELENE is not set
+
+#
+# Common Interface (EN50221) controller drivers
+#
+# CONFIG_DVB_CXD2099 is not set
+# CONFIG_DVB_SP2 is not set
+
+#
+# Tools to develop new frontends
+#
+# CONFIG_DVB_DUMMY_FE is not set
+# end of Customise DVB Frontends
+
+#
+# Graphics support
+#
+# CONFIG_VGA_ARB is not set
+# CONFIG_IMX_IPUV3_CORE is not set
+# CONFIG_DRM is not set
+# CONFIG_DRM_DP_CEC is not set
+
+#
+# ARM devices
+#
+# end of ARM devices
+
+#
+# ACP (Audio CoProcessor) Configuration
+#
+# end of ACP (Audio CoProcessor) Configuration
+
+#
+# Frame buffer Devices
+#
+CONFIG_FB_CMDLINE=y
+CONFIG_FB_NOTIFY=y
+CONFIG_FB=y
+# CONFIG_FIRMWARE_EDID 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_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_IBM_GXT4500 is not set
+# CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB_METRONOME is not set
+# CONFIG_FB_MB862XX is not set
+# CONFIG_FB_SIMPLE is not set
+# CONFIG_FB_SSD1307 is not set
+# CONFIG_FB_SM712 is not set
+# CONFIG_FB_SSD1320 is not set
+CONFIG_FB_SSD1327=y
+# end of Frame buffer Devices
+
+#
+# Backlight & LCD device support
+#
+# CONFIG_LCD_CLASS_DEVICE is not set
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+# CONFIG_BACKLIGHT_GENERIC is not set
+# CONFIG_BACKLIGHT_PM8941_WLED 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_BACKLIGHT_ARCXCNN is not set
+# end of Backlight & LCD device support
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE is not set
+# end of Console display driver support
+
+# CONFIG_LOGO is not set
+# end of Graphics support
+
+CONFIG_SOUND=y
+CONFIG_SND=y
+CONFIG_SND_TIMER=y
+CONFIG_SND_PCM=y
+CONFIG_SND_HWDEP=y
+CONFIG_SND_RAWMIDI=y
+CONFIG_SND_JACK=y
+CONFIG_SND_JACK_INPUT_DEV=y
+# CONFIG_SND_OSSEMUL is not set
+CONFIG_SND_PCM_TIMER=y
+# 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_SEQUENCER is not set
+# CONFIG_SND_DRIVERS is not set
+# CONFIG_SND_PCI is not set
+
+#
+# HD-Audio
+#
+# end of 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_SOC_AMD_ACP is not set
+# 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_AUDMIX 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_FSL_MICFIL is not set
+# CONFIG_SND_SOC_IMX_AUDMUX is not set
+# end of SoC Audio for Freescale CPUs
+
+# CONFIG_SND_I2S_HI6210_I2S 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_IMG is not set
+# CONFIG_SND_SOC_MTK_BTCVSD is not set
+# CONFIG_SND_SOC_SOF_TOPLEVEL is not set
+
+#
+# STMicroelectronics STM32 SOC audio support
+#
+# end of STMicroelectronics STM32 SOC audio support
+
+# CONFIG_SND_SOC_XILINX_I2S is not set
+# CONFIG_SND_SOC_XILINX_AUDIO_FORMATTER is not set
+# CONFIG_SND_SOC_XILINX_SPDIF is not set
+# CONFIG_SND_SOC_XTFPGA_I2S is not set
+# CONFIG_ZX_TDM 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_ADAU1761_I2C is not set
+# CONFIG_SND_SOC_ADAU1761_SPI is not set
+# CONFIG_SND_SOC_ADAU7002 is not set
+# CONFIG_SND_SOC_AK4104 is not set
+# CONFIG_SND_SOC_AK4118 is not set
+# CONFIG_SND_SOC_AK4458 is not set
+# CONFIG_SND_SOC_AK4554 is not set
+# CONFIG_SND_SOC_AK4613 is not set
+# CONFIG_SND_SOC_AK4642 is not set
+# CONFIG_SND_SOC_AK5386 is not set
+# CONFIG_SND_SOC_AK5558 is not set
+# CONFIG_SND_SOC_ALC5623 is not set
+# CONFIG_SND_SOC_BD28623 is not set
+# CONFIG_SND_SOC_BT_SCO is not set
+# CONFIG_SND_SOC_CS35L32 is not set
+# CONFIG_SND_SOC_CS35L33 is not set
+# CONFIG_SND_SOC_CS35L34 is not set
+# CONFIG_SND_SOC_CS35L35 is not set
+# CONFIG_SND_SOC_CS35L36 is not set
+# CONFIG_SND_SOC_CS42L42 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_CS43130 is not set
+# CONFIG_SND_SOC_CS4341 is not set
+# CONFIG_SND_SOC_CS4349 is not set
+# CONFIG_SND_SOC_CS53L30 is not set
+# CONFIG_SND_SOC_CX2072X is not set
+# CONFIG_SND_SOC_DMIC is not set
+# CONFIG_SND_SOC_ES7134 is not set
+# CONFIG_SND_SOC_ES7241 is not set
+# CONFIG_SND_SOC_ES8316 is not set
+# CONFIG_SND_SOC_ES8328_I2C is not set
+# CONFIG_SND_SOC_ES8328_SPI is not set
+# CONFIG_SND_SOC_GTM601 is not set
+# CONFIG_SND_SOC_INNO_RK3036 is not set
+# CONFIG_SND_SOC_MAX98088 is not set
+# CONFIG_SND_SOC_MAX98357A is not set
+# CONFIG_SND_SOC_MAX98504 is not set
+# CONFIG_SND_SOC_MAX9867 is not set
+# CONFIG_SND_SOC_MAX98927 is not set
+# CONFIG_SND_SOC_MAX98373 is not set
+# CONFIG_SND_SOC_MAX9860 is not set
+# CONFIG_SND_SOC_MSM8916_WCD_DIGITAL is not set
+# CONFIG_SND_SOC_PCM1681 is not set
+# CONFIG_SND_SOC_PCM1789_I2C is not set
+# CONFIG_SND_SOC_PCM179X_I2C is not set
+# CONFIG_SND_SOC_PCM179X_SPI is not set
+# CONFIG_SND_SOC_PCM186X_I2C is not set
+# CONFIG_SND_SOC_PCM186X_SPI is not set
+# CONFIG_SND_SOC_PCM3060_I2C is not set
+# CONFIG_SND_SOC_PCM3060_SPI is not set
+# CONFIG_SND_SOC_PCM3168A_I2C is not set
+# CONFIG_SND_SOC_PCM3168A_SPI is not set
+# CONFIG_SND_SOC_PCM512x_I2C is not set
+# CONFIG_SND_SOC_PCM512x_SPI is not set
+# CONFIG_SND_SOC_RK3328 is not set
+# CONFIG_SND_SOC_RT5616 is not set
+# CONFIG_SND_SOC_RT5631 is not set
+# CONFIG_SND_SOC_SGTL5000 is not set
+# CONFIG_SND_SOC_SIMPLE_AMPLIFIER is not set
+# CONFIG_SND_SOC_SIRF_AUDIO_CODEC is not set
+# CONFIG_SND_SOC_SPDIF is not set
+# CONFIG_SND_SOC_SSM2305 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_STI_SAS 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_TAS5720 is not set
+# CONFIG_SND_SOC_TAS6424 is not set
+# CONFIG_SND_SOC_TDA7419 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_TLV320AIC32X4_I2C is not set
+# CONFIG_SND_SOC_TLV320AIC32X4_SPI is not set
+# CONFIG_SND_SOC_TLV320AIC3X is not set
+# CONFIG_SND_SOC_TS3A227E is not set
+# CONFIG_SND_SOC_TSCS42XX is not set
+# CONFIG_SND_SOC_TSCS454 is not set
+# CONFIG_SND_SOC_UDA1334 is not set
+# CONFIG_SND_SOC_WM8510 is not set
+# CONFIG_SND_SOC_WM8523 is not set
+# CONFIG_SND_SOC_WM8524 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_WM8782 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_WM8904 is not set
+# CONFIG_SND_SOC_WM8960 is not set
+# CONFIG_SND_SOC_WM8962 is not set
+# CONFIG_SND_SOC_WM8974 is not set
+# CONFIG_SND_SOC_WM8978 is not set
+# CONFIG_SND_SOC_WM8985 is not set
+# CONFIG_SND_SOC_ZX_AUD96P22 is not set
+# CONFIG_SND_SOC_MAX9759 is not set
+# CONFIG_SND_SOC_MT6351 is not set
+# CONFIG_SND_SOC_MT6358 is not set
+# CONFIG_SND_SOC_NAU8540 is not set
+# CONFIG_SND_SOC_NAU8810 is not set
+# CONFIG_SND_SOC_NAU8822 is not set
+# CONFIG_SND_SOC_NAU8824 is not set
+# CONFIG_SND_SOC_TPA6130A2 is not set
+# end of CODEC drivers
+
+# CONFIG_SND_SIMPLE_CARD is not set
+# CONFIG_SND_AUDIO_GRAPH_CARD 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_ASUS 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_CORSAIR is not set
+# CONFIG_HID_COUGAR is not set
+# CONFIG_HID_MACALLY is not set
+# CONFIG_HID_PRODIKEYS is not set
+# CONFIG_HID_CMEDIA 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_GEMBIRD is not set
+# CONFIG_HID_GFRM is not set
+# CONFIG_HID_KEYTOUCH is not set
+# CONFIG_HID_KYE is not set
+# CONFIG_HID_WALTOP is not set
+# CONFIG_HID_VIEWSONIC 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_ITE is not set
+# CONFIG_HID_JABRA is not set
+# CONFIG_HID_TWINHAN is not set
+# CONFIG_HID_KENSINGTON is not set
+# CONFIG_HID_LCPOWER is not set
+# CONFIG_HID_LED is not set
+# CONFIG_HID_LENOVO is not set
+# CONFIG_HID_LOGITECH is not set
+# CONFIG_HID_MAGICMOUSE is not set
+# CONFIG_HID_MALTRON is not set
+# CONFIG_HID_MAYFLASH is not set
+# CONFIG_HID_REDRAGON is not set
+# CONFIG_HID_MICROSOFT is not set
+# CONFIG_HID_MONTEREY is not set
+# CONFIG_HID_MULTITOUCH is not set
+# CONFIG_HID_NTI 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_STEAM 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_UDRAW_PS3 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
+# CONFIG_HID_ALPS is not set
+# end of Special HID drivers
+
+#
+# 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
+# end of USB HID Boot Protocol drivers
+# end of USB HID support
+
+#
+# I2C HID support
+#
+# CONFIG_I2C_HID is not set
+# end of I2C HID support
+# end of HID support
+
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_COMMON=y
+# CONFIG_USB_LED_TRIG is not set
+# CONFIG_USB_ULPI_BUS is not set
+# CONFIG_USB_CONN_GPIO is not set
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB=y
+# CONFIG_USB_PCI is not set
+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_LEDS_TRIGGER_USBPORT is not set
+CONFIG_USB_AUTOSUSPEND_DELAY=2
+# CONFIG_USB_MON 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_FSL is not set
+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_FOTG210_HCD is not set
+# CONFIG_USB_MAX3421_HCD is not set
+# CONFIG_USB_OHCI_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_CDNS3 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_LEGOTOWER is not set
+# CONFIG_USB_LCD 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_HUB_USB251XB is not set
+# CONFIG_USB_HSIC_USB3503 is not set
+# CONFIG_USB_HSIC_USB4604 is not set
+# CONFIG_USB_LINK_LAYER_TEST is not set
+
+#
+# USB Physical Layer drivers
+#
+# CONFIG_NOP_USB_XCEIV is not set
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_USB_ISP1301 is not set
+# CONFIG_USB_ULPI is not set
+# end of USB Physical Layer drivers
+
+# CONFIG_USB_GADGET is not set
+# CONFIG_TYPEC is not set
+# CONFIG_USB_ROLE_SWITCH 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
+# CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set
+
+#
+# LED drivers
+#
+# CONFIG_LEDS_AN30259A is not set
+# CONFIG_LEDS_BCM6328 is not set
+# CONFIG_LEDS_BCM6358 is not set
+# CONFIG_LEDS_CR0014114 is not set
+# CONFIG_LEDS_LM3530 is not set
+# CONFIG_LEDS_LM3532 is not set
+# CONFIG_LEDS_LM3642 is not set
+# CONFIG_LEDS_LM3692X is not set
+# CONFIG_LEDS_PCA9532 is not set
+# CONFIG_LEDS_GPIO is not set
+# CONFIG_LEDS_LP3944 is not set
+# CONFIG_LEDS_LP3952 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
+# CONFIG_LEDS_IS31FL319X is not set
+# CONFIG_LEDS_IS31FL32XX 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_MLXREG is not set
+# CONFIG_LEDS_USER is not set
+# CONFIG_LEDS_SPI_BYTE is not set
+# CONFIG_LEDS_TI_LMU_COMMON is not set
+# CONFIG_LEDS_LED1202 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_DISK is not set
+# CONFIG_LEDS_TRIGGER_MTD 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_ACTIVITY 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_LEDS_TRIGGER_PANIC is not set
+# CONFIG_LEDS_TRIGGER_NETDEV is not set
+# CONFIG_LEDS_TRIGGER_PATTERN is not set
+# CONFIG_LEDS_TRIGGER_AUDIO 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
+
+#
+# DMABUF options
+#
+# CONFIG_SYNC_FILE is not set
+# end of DMABUF options
+
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+# CONFIG_VIRT_DRIVERS is not set
+# CONFIG_VIRTIO_MENU is not set
+
+#
+# Microsoft Hyper-V guest support
+#
+# end of Microsoft Hyper-V guest support
+
+# CONFIG_GREYBUS is not set
+# CONFIG_STAGING is not set
+# CONFIG_GOLDFISH is not set
+# CONFIG_MFD_CROS_EC is not set
+# CONFIG_CHROME_PLATFORMS is not set
+# CONFIG_MELLANOX_PLATFORM is not set
+# CONFIG_FBXGW7R_PLATFORM is not set
+CONFIG_CLKDEV_LOOKUP=y
+CONFIG_HAVE_CLK_PREPARE=y
+CONFIG_COMMON_CLK=y
+
+#
+# Common Clock Framework
+#
+# CONFIG_CLK_HSDK is not set
+# CONFIG_COMMON_CLK_MAX9485 is not set
+# CONFIG_COMMON_CLK_SI5341 is not set
+# CONFIG_COMMON_CLK_SI5351 is not set
+# CONFIG_COMMON_CLK_SI514 is not set
+# CONFIG_COMMON_CLK_SI544 is not set
+# CONFIG_COMMON_CLK_SI570 is not set
+# CONFIG_COMMON_CLK_CDCE706 is not set
+# CONFIG_COMMON_CLK_CDCE925 is not set
+# CONFIG_COMMON_CLK_CS2000_CP is not set
+# CONFIG_CLK_QORIQ is not set
+# CONFIG_COMMON_CLK_VC5 is not set
+# CONFIG_COMMON_CLK_FIXED_MMIO is not set
+CONFIG_MVEBU_CLK_COMMON=y
+CONFIG_KIRKWOOD_CLK=y
+# end of Common Clock Framework
+
+# CONFIG_HWSPINLOCK is not set
+
+#
+# Clock Source drivers
+#
+CONFIG_TIMER_OF=y
+CONFIG_TIMER_PROBE=y
+CONFIG_CLKSRC_MMIO=y
+CONFIG_ORION_TIMER=y
+# end of Clock Source drivers
+
+# CONFIG_MAILBOX is not set
+# CONFIG_IOMMU_SUPPORT is not set
+
+#
+# Remoteproc drivers
+#
+# CONFIG_REMOTEPROC is not set
+# end of Remoteproc drivers
+
+#
+# Rpmsg drivers
+#
+# CONFIG_RPMSG_VIRTIO is not set
+# end of Rpmsg drivers
+
+# CONFIG_SOUNDWIRE is not set
+
+#
+# SOC (System On Chip) specific Drivers
+#
+
+#
+# Amlogic SoC drivers
+#
+# end of Amlogic SoC drivers
+
+#
+# Aspeed SoC drivers
+#
+# end of Aspeed SoC drivers
+
+#
+# Broadcom SoC drivers
+#
+# CONFIG_SOC_BRCMSTB is not set
+# end of Broadcom SoC drivers
+
+#
+# NXP/Freescale QorIQ SoC drivers
+#
+# end of NXP/Freescale QorIQ SoC drivers
+
+#
+# i.MX SoC drivers
+#
+# end of i.MX SoC drivers
+
+#
+# Qualcomm SoC drivers
+#
+# end of Qualcomm SoC drivers
+
+# CONFIG_SOC_TI is not set
+
+#
+# Xilinx SoC drivers
+#
+# CONFIG_XILINX_VCU is not set
+# end of Xilinx SoC drivers
+# end of SOC (System On Chip) specific Drivers
+
+# 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
+
+#
+# IRQ chip support
+#
+CONFIG_IRQCHIP=y
+# CONFIG_AL_FIC is not set
+CONFIG_ORION_IRQCHIP=y
+# end of IRQ chip support
+
+# CONFIG_IPACK_BUS is not set
+CONFIG_RESET_CONTROLLER=y
+# CONFIG_RESET_TI_SYSCON is not set
+
+#
+# PHY Subsystem
+#
+CONFIG_GENERIC_PHY=y
+# CONFIG_XDSL_PHY_API is not set
+# CONFIG_BCM_KONA_USB2_PHY is not set
+# CONFIG_PHY_CADENCE_DP is not set
+# CONFIG_PHY_CADENCE_DPHY is not set
+# CONFIG_PHY_CADENCE_SIERRA is not set
+# CONFIG_PHY_FSL_IMX8MQ_USB is not set
+# CONFIG_PHY_MIXEL_MIPI_DPHY is not set
+# CONFIG_PHY_MVEBU_A3700_UTMI is not set
+# CONFIG_PHY_MVEBU_A38X_COMPHY is not set
+CONFIG_PHY_MVEBU_SATA=y
+# CONFIG_PHY_PXA_28NM_HSIC is not set
+# CONFIG_PHY_PXA_28NM_USB2 is not set
+# CONFIG_PHY_UTMI_CP110 is not set
+# CONFIG_PHY_MAPPHONE_MDM6600 is not set
+# end of PHY Subsystem
+
+# CONFIG_POWERCAP is not set
+# CONFIG_MCB is not set
+CONFIG_RAS=y
+
+#
+# Android
+#
+# CONFIG_ANDROID is not set
+# end of Android
+
+CONFIG_DAX=y
+CONFIG_NVMEM=y
+CONFIG_NVMEM_SYSFS=y
+# CONFIG_NVMEM_IGNORE_RO is not set
+
+#
+# HW tracing support
+#
+# CONFIG_STM is not set
+# CONFIG_INTEL_TH is not set
+# end of HW tracing support
+
+# CONFIG_FPGA is not set
+# CONFIG_FSI is not set
+# CONFIG_SIOX is not set
+# CONFIG_SLIMBUS is not set
+# CONFIG_INTERCONNECT is not set
+# CONFIG_COUNTER is not set
+# end of Device Drivers
+
+#
+# File systems
+#
+# CONFIG_VALIDATE_FS_PARSER is not set
+CONFIG_FS_IOMAP=y
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_POSIX_ACL is not set
+# CONFIG_EXT3_FS_SECURITY is not set
+CONFIG_EXT4_FS=y
+# CONFIG_EXT4_FS_POSIX_ACL is not set
+# CONFIG_EXT4_FS_SECURITY is not set
+# CONFIG_EXT4_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_ONLINE_SCRUB is not set
+# CONFIG_XFS_WARN is not set
+# CONFIG_XFS_DEBUG is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_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_EXPORTFS_BLOCK_OPS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_MANDATORY_FILE_LOCKING=y
+# CONFIG_FS_ENCRYPTION is not set
+# CONFIG_FS_VERITY is not set
+CONFIG_FSNOTIFY=y
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_FANOTIFY=y
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_AUTOFS_FS is not set
+CONFIG_FUSE_FS=y
+# CONFIG_CUSE is not set
+# CONFIG_VIRTIO_FS is not set
+# CONFIG_OVERLAY_FS is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+# end of Caches
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+# end of CD-ROM/DVD Filesystems
+
+#
+# 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_FAT_DEFAULT_UTF8 is not set
+CONFIG_NTFS_FS=y
+# CONFIG_NTFS_DEBUG is not set
+# CONFIG_NTFS_RW is not set
+CONFIG_EXFAT_FS_FBX=y
+# end of DOS/FAT/NT Filesystems
+
+#
+# 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_MEMFD_CREATE=y
+CONFIG_CONFIGFS_FS=y
+# end of Pseudo filesystems
+
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ORANGEFS_FS is not set
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+CONFIG_HFS_FS=y
+CONFIG_HFSPLUS_FS=y
+# 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_UBIFS_FS_ZSTD is not set
+# CONFIG_UBIFS_ATIME_SUPPORT is not set
+# CONFIG_UBIFS_FS_XATTR is not set
+# CONFIG_UBIFS_FS_AUTHENTICATION is not set
+CONFIG_CRAMFS=y
+CONFIG_CRAMFS_BLOCKDEV=y
+CONFIG_CRAMFS_MTD=y
+CONFIG_SQUASHFS=y
+# CONFIG_SQUASHFS_FILE_CACHE is not set
+CONFIG_SQUASHFS_FILE_DIRECT=y
+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 is not set
+# CONFIG_SQUASHFS_LZ4 is not set
+# CONFIG_SQUASHFS_LZO is not set
+CONFIG_SQUASHFS_XZ=y
+# CONFIG_SQUASHFS_ZSTD 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_DEFLATE_COMPRESS is not set
+# CONFIG_PSTORE_LZO_COMPRESS is not set
+# CONFIG_PSTORE_LZ4_COMPRESS is not set
+# CONFIG_PSTORE_LZ4HC_COMPRESS is not set
+# CONFIG_PSTORE_842_COMPRESS is not set
+# CONFIG_PSTORE_ZSTD_COMPRESS is not set
+# 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_EROFS_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_BLOCKLAYOUT is not set
+# CONFIG_NFSD_SCSILAYOUT is not set
+# CONFIG_NFSD_FLEXFILELAYOUT 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_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
+# CONFIG_DLM is not set
+# CONFIG_UNICODE is not set
+# end of File systems
+
+#
+# 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_HAVE_HARDENED_USERCOPY_ALLOCATOR=y
+# CONFIG_HARDENED_USERCOPY is not set
+# CONFIG_FORTIFY_SOURCE is not set
+# CONFIG_STATIC_USERMODEHELPER is not set
+CONFIG_DEFAULT_SECURITY_DAC=y
+CONFIG_LSM="yama,loadpin,safesetid,integrity"
+
+#
+# Kernel hardening options
+#
+
+#
+# Memory initialization
+#
+CONFIG_INIT_STACK_NONE=y
+# CONFIG_GCC_PLUGIN_STRUCTLEAK_USER is not set
+# CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF is not set
+# CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL is not set
+# CONFIG_INIT_ON_ALLOC_DEFAULT_ON is not set
+# CONFIG_INIT_ON_FREE_DEFAULT_ON is not set
+# end of Memory initialization
+# end of Kernel hardening options
+# end of Security options
+
+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_AKCIPHER2=y
+CONFIG_CRYPTO_KPP2=y
+CONFIG_CRYPTO_KPP=y
+CONFIG_CRYPTO_ACOMP2=y
+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_NULL2=y
+# CONFIG_CRYPTO_CRYPTD is not set
+CONFIG_CRYPTO_AUTHENC=y
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Public-key cryptography
+#
+# CONFIG_CRYPTO_RSA is not set
+# CONFIG_CRYPTO_DH is not set
+CONFIG_CRYPTO_ECC=y
+CONFIG_CRYPTO_ECDH=y
+# CONFIG_CRYPTO_ECRDSA is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+CONFIG_CRYPTO_CCM=y
+CONFIG_CRYPTO_GCM=y
+CONFIG_CRYPTO_CHACHA20POLY1305=y
+# CONFIG_CRYPTO_AEGIS128 is not set
+CONFIG_CRYPTO_SEQIV=y
+CONFIG_CRYPTO_ECHAINIV=y
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=y
+# CONFIG_CRYPTO_CFB is not set
+CONFIG_CRYPTO_CTR=y
+# CONFIG_CRYPTO_CTS is not set
+CONFIG_CRYPTO_ECB=y
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_OFB is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+# CONFIG_CRYPTO_KEYWRAP is not set
+# CONFIG_CRYPTO_ADIANTUM is not set
+CONFIG_CRYPTO_ESSIV=y
+
+#
+# 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_XXHASH is not set
+# CONFIG_CRYPTO_CRCT10DIF is not set
+CONFIG_CRYPTO_GHASH=y
+CONFIG_CRYPTO_POLY1305=y
+# 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_LIB_SHA256=y
+CONFIG_CRYPTO_SHA256=y
+CONFIG_CRYPTO_SHA512=y
+CONFIG_CRYPTO_SHA3=y
+# CONFIG_CRYPTO_SM3 is not set
+# CONFIG_CRYPTO_STREEBOG is not set
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_LIB_AES=y
+CONFIG_CRYPTO_AES=y
+# CONFIG_CRYPTO_AES_TI is not set
+# CONFIG_CRYPTO_ANUBIS is not set
+CONFIG_CRYPTO_LIB_ARC4=y
+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_LIB_DES=y
+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=y
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_SM4 is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
+CONFIG_CRYPTO_DEFLATE=y
+CONFIG_CRYPTO_LZO=y
+# CONFIG_CRYPTO_842 is not set
+# CONFIG_CRYPTO_LZ4 is not set
+# CONFIG_CRYPTO_LZ4HC is not set
+# CONFIG_CRYPTO_ZSTD 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_HASH_INFO=y
+# CONFIG_CRYPTO_HW is not set
+
+#
+# Certificates for signature checking
+#
+# end of Certificates for signature checking
+
+#
+# Library routines
+#
+# CONFIG_PACKING is not set
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_STRNCPY_FROM_USER=y
+CONFIG_GENERIC_STRNLEN_USER=y
+CONFIG_GENERIC_NET_UTILS=y
+# CONFIG_CORDIC is not set
+CONFIG_RATIONAL=y
+CONFIG_GENERIC_PCI_IOMAP=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_CRC64 is not set
+# CONFIG_CRC4 is not set
+# CONFIG_CRC7 is not set
+CONFIG_LIBCRC32C=y
+# CONFIG_CRC8 is not set
+CONFIG_AUDIT_GENERIC=y
+# 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=y
+# CONFIG_XZ_DEC_X86 is not set
+# CONFIG_XZ_DEC_POWERPC is not set
+# CONFIG_XZ_DEC_IA64 is not set
+CONFIG_XZ_DEC_ARM=y
+# CONFIG_XZ_DEC_ARMTHUMB is not set
+# CONFIG_XZ_DEC_SPARC is not set
+CONFIG_XZ_DEC_BCJ=y
+# CONFIG_XZ_DEC_TEST 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_NEED_DMA_MAP_STATE=y
+CONFIG_ARCH_HAS_DMA_WRITE_COMBINE=y
+CONFIG_DMA_DECLARE_COHERENT=y
+CONFIG_ARCH_HAS_SETUP_DMA_OPS=y
+CONFIG_ARCH_HAS_TEARDOWN_DMA_OPS=y
+CONFIG_DMA_REMAP=y
+# CONFIG_DMA_API_DEBUG is not set
+CONFIG_SGL_ALLOC=y
+CONFIG_DQL=y
+CONFIG_GLOB=y
+# CONFIG_GLOB_SELFTEST is not set
+CONFIG_NLATTR=y
+CONFIG_GENERIC_ATOMIC64=y
+# CONFIG_IRQ_POLL is not set
+CONFIG_LIBFDT=y
+CONFIG_OID_REGISTRY=y
+CONFIG_SG_POOL=y
+CONFIG_SBITMAP=y
+# CONFIG_STRING_SELFTEST is not set
+CONFIG_ARCH_HAS_FBXSERIAL=y
+CONFIG_FBXSERIAL=y
+# end of Library routines
+
+#
+# Kernel hacking
+#
+
+#
+# printk and dmesg options
+#
+CONFIG_PRINTK_TIME=y
+# CONFIG_PRINTK_CALLER is not set
+CONFIG_CONSOLE_LOGLEVEL_DEFAULT=7
+CONFIG_CONSOLE_LOGLEVEL_QUIET=4
+CONFIG_MESSAGE_LOGLEVEL_DEFAULT=4
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+# end of printk and dmesg options
+
+#
+# Compile-time checks and compiler options
+#
+# CONFIG_DEBUG_INFO is not set
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+# CONFIG_STRIP_ASM_SYMS is not set
+CONFIG_READABLE_ASM=y
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_INSTALL is not set
+CONFIG_OPTIMIZE_INLINING=y
+# CONFIG_DEBUG_SECTION_MISMATCH is not set
+CONFIG_SECTION_MISMATCH_WARN_ONLY=y
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
+# end of Compile-time checks and compiler options
+
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1
+CONFIG_MAGIC_SYSRQ_SERIAL=y
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_MISC is not set
+
+#
+# Memory Debugging
+#
+# CONFIG_PAGE_EXTENSION is not set
+# CONFIG_DEBUG_PAGEALLOC is not set
+# CONFIG_PAGE_OWNER is not set
+CONFIG_PAGE_POISONING=y
+# CONFIG_PAGE_POISONING_NO_SANITY is not set
+# CONFIG_PAGE_POISONING_ZERO is not set
+# CONFIG_DEBUG_RODATA_TEST is not set
+CONFIG_DEBUG_OBJECTS=y
+# CONFIG_DEBUG_OBJECTS_SELFTEST is not set
+# CONFIG_DEBUG_OBJECTS_FREE is not set
+CONFIG_DEBUG_OBJECTS_TIMERS=y
+CONFIG_DEBUG_OBJECTS_WORK=y
+CONFIG_DEBUG_OBJECTS_RCU_HEAD=y
+# CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER is not set
+CONFIG_DEBUG_OBJECTS_ENABLE_DEFAULT=1
+# CONFIG_SLUB_DEBUG_ON 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_ARCH_HAS_DEBUG_VIRTUAL=y
+# CONFIG_DEBUG_VIRTUAL is not set
+CONFIG_DEBUG_MEMORY_INIT=y
+CONFIG_CC_HAS_KASAN_GENERIC=y
+CONFIG_KASAN_STACK=1
+# end of Memory Debugging
+
+CONFIG_ARCH_HAS_KCOV=y
+CONFIG_CC_HAS_SANCOV_TRACE_PC=y
+# CONFIG_KCOV is not set
+# CONFIG_DEBUG_SHIRQ is not set
+
+#
+# Debug Lockups and Hangs
+#
+# CONFIG_SOFTLOCKUP_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_WQ_WATCHDOG is not set
+# end of Debug Lockups and Hangs
+
+CONFIG_PANIC_ON_OOPS=y
+CONFIG_PANIC_ON_OOPS_VALUE=1
+CONFIG_PANIC_TIMEOUT=10
+# CONFIG_SCHED_DEBUG is not set
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_SCHED_STACK_END_CHECK is not set
+# CONFIG_DEBUG_TIMEKEEPING is not set
+
+#
+# Lock Debugging (spinlocks, mutexes, etc...)
+#
+CONFIG_LOCK_DEBUGGING_SUPPORT=y
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+CONFIG_DEBUG_RT_MUTEXES=y
+CONFIG_DEBUG_SPINLOCK=y
+CONFIG_DEBUG_MUTEXES=y
+# CONFIG_DEBUG_WW_MUTEX_SLOWPATH is not set
+# CONFIG_DEBUG_RWSEMS is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+CONFIG_DEBUG_ATOMIC_SLEEP=y
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_LOCK_TORTURE_TEST is not set
+# CONFIG_WW_MUTEX_SELFTEST is not set
+# end of Lock Debugging (spinlocks, mutexes, etc...)
+
+CONFIG_STACKTRACE=y
+# CONFIG_WARN_ALL_UNSEEDED_RANDOM is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_KOBJECT_RELEASE is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+CONFIG_DEBUG_LIST=y
+# CONFIG_DEBUG_PLIST is not set
+CONFIG_DEBUG_SG=y
+CONFIG_DEBUG_NOTIFIERS=y
+# CONFIG_DEBUG_CREDENTIALS is not set
+
+#
+# RCU Debugging
+#
+# CONFIG_RCU_PERF_TEST is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_TRACE is not set
+# CONFIG_RCU_EQS_DEBUG is not set
+# end of RCU Debugging
+
+# CONFIG_DEBUG_WQ_FORCE_RR_CPU 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_DYNAMIC_FTRACE_WITH_REGS=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
+# CONFIG_RUNTIME_TESTING_MENU is not set
+# CONFIG_MEMTEST is not set
+# CONFIG_BUG_ON_DATA_CORRUPTION is not set
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+# CONFIG_UBSAN is not set
+CONFIG_UBSAN_ALIGNMENT=y
+CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y
+# CONFIG_ARM_PTDUMP_DEBUGFS is not set
+# CONFIG_DEBUG_WX is not set
+# CONFIG_UNWINDER_FRAME_POINTER is not set
+CONFIG_UNWINDER_ARM=y
+CONFIG_ARM_UNWIND=y
+CONFIG_DEBUG_USER=y
+# CONFIG_DEBUG_LL is not set
+CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S"
+CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h"
+# CONFIG_CORESIGHT is not set
+# end of Kernel hacking
diff -Nruw linux-5.4.60-fbx/drivers/fbxgpio./fbxgpio_core.c linux-5.4.60-fbx/drivers/fbxgpio/fbxgpio_core.c
--- linux-5.4.60-fbx/drivers/fbxgpio./fbxgpio_core.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxgpio/fbxgpio_core.c	2021-03-04 13:20:57.760838887 +0100
@@ -0,0 +1,361 @@
+#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>
+#include <linux/of.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;
+
+/*
+ * retrieval of a struct fbxgpio_pin from a phandle in the device
+ * tree.
+ */
+struct fbxgpio_of_mach_data {
+	struct fbxgpio_pin *match;
+	struct device_node *np;
+};
+
+static int match_fbxgpio_of_node(struct device *dev, void *data)
+{
+	struct fbxgpio_of_mach_data *md = data;
+	struct fbxgpio_pin *pin = dev_get_drvdata(dev);
+
+	if (pin->of_node == md->np) {
+		md->match = pin;
+		return 1;
+	}
+	return 0;
+}
+
+struct fbxgpio_pin *fbxgpio_of_get(struct device_node *np, const char *propname,
+				   int index)
+{
+	struct fbxgpio_of_mach_data md;
+
+	/*
+	 * get the pin device_node.
+	 */
+	md.match = NULL;
+	md.np = of_parse_phandle(np, propname, index);
+	if (!md.np)
+		return ERR_PTR(-ENOENT);
+
+	/*
+	 * find the struct fbxgpio_pin behind that device_node.
+	 */
+	class_for_each_device(fbxgpio_class, NULL, &md,
+			      match_fbxgpio_of_node);
+
+	return md.match ? md.match : ERR_PTR(-ENOENT);
+}
+EXPORT_SYMBOL(fbxgpio_of_get);
+
+/*
+ * 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, ret;
+	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;
+
+	ret = p->ops->set_direction(p->pin_num, dir);
+	if (ret)
+		return ret;
+	p->direction = 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-5.4.60-fbx/drivers/fbxgpio./fbxgpio_dt.c linux-5.4.60-fbx/drivers/fbxgpio/fbxgpio_dt.c
--- linux-5.4.60-fbx/drivers/fbxgpio./fbxgpio_dt.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxgpio/fbxgpio_dt.c	2021-03-04 13:20:57.760838887 +0100
@@ -0,0 +1,264 @@
+/*
+ * fbxgpio_dt.c for fbxgpio
+ * Created by <nschichan@freebox.fr> on Tue Aug  1 14:01:01 2017
+ */
+
+#include <linux/kernel.h>
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
+#include <linux/platform_device.h>
+#include <linux/fbxgpio_core.h>
+#include <linux/module.h>
+#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
+#include <linux/of_gpio.h>
+
+static atomic_t last_id = ATOMIC_INIT(0);
+
+/*
+ * fbxgpio driver fetching gpios names and configuration from
+ * device-tree.
+ */
+
+struct fbxgpio_dt_priv {
+	struct fbxgpio_pin *pins;
+	unsigned int npins;
+
+	/* dynamically created platform_device for fbxgpio_core */
+	struct platform_device *top_pdev;
+};
+
+
+/*
+ * small shim layer for gpiolib <-> fbxgpio_operations.
+ *
+ * gpio direction change is unsupported, does userspace really need
+ * it?
+ */
+static int fbxgpio_dt_get_data(int gpio)
+{
+	return gpio_get_value_cansleep(gpio);
+}
+
+static void fbxgpio_dt_set_dataout(int gpio, int value)
+{
+	gpio_set_value_cansleep(gpio, value);
+}
+
+static int fbxgpio_dt_set_direction(int gpio, int dir)
+{
+	if (dir == GPIO_DIR_OUT)
+		return gpio_direction_output(gpio, 0);
+	else
+		return gpio_direction_input(gpio);
+}
+
+static const struct fbxgpio_operations fbxgpio_dt_ops = {
+	.get_datain = fbxgpio_dt_get_data,
+	.get_dataout = fbxgpio_dt_get_data,
+	.set_dataout = fbxgpio_dt_set_dataout,
+	.set_direction = fbxgpio_dt_set_direction,
+};
+
+/*
+ * fill an fbxgpio_pin with the configuration found in a device tree
+ * node.
+ *
+ * required properties are:
+ * - gpio: a phandle to a standard linux gpio.
+ *
+ * - the name of the node: the name of the gpio as it will appear under
+ *   /sys/class/fbxgpio/
+ *
+ * - <input>/<output-high>/<output-low>: how to declare gpio and
+ *   actually setup it unless no-claim is given
+ *
+ * - <no-claim>: just declare gpio, but don't request & setup it
+ */
+static int fbxgpio_dt_fill_gpio(struct platform_device *pdev,
+				struct device_node *np,
+				struct fbxgpio_pin *pin)
+{
+	enum of_gpio_flags flags;
+	int error;
+
+	error = of_property_read_string(np, "name", &pin->pin_name);
+	if (error) {
+		dev_err(&pdev->dev, "gpio has no name.\n");
+		return error;
+	}
+
+	pin->pin_num = of_get_named_gpio_flags(np, "gpio", 0, &flags);
+	if (pin->pin_num < 0) {
+		if (pin->pin_num != -EPROBE_DEFER)
+			dev_err(&pdev->dev,
+				"unable to get gpio desc for %s: %d.\n",
+				pin->pin_name, pin->pin_num);
+		return pin->pin_num;
+	}
+
+	if (of_property_read_bool(np, "input")) {
+		pin->direction = GPIO_DIR_IN;
+	} else if (of_property_read_bool(np, "output-low")) {
+		pin->direction = GPIO_DIR_OUT;
+		pin->cur_dataout = 0;
+	} else if (of_property_read_bool(np, "output-high")) {
+		pin->direction = GPIO_DIR_OUT;
+		pin->cur_dataout = 1;
+	} else {
+		dev_err(&pdev->dev,
+			"no state specified for %s\n",
+			pin->pin_name);
+		return -EINVAL;
+	}
+
+	if (flags & OF_GPIO_ACTIVE_LOW) {
+		pin->flags |= FBXGPIO_PIN_REVERSE_POL;
+		if (pin->direction == GPIO_DIR_OUT)
+			pin->cur_dataout = 1 - pin->cur_dataout;
+	}
+
+	if (!of_property_read_bool(np, "no-claim")) {
+		error = gpio_request(pin->pin_num, "fbxgpio-dt");
+		if (error) {
+			dev_err(&pdev->dev, "unable to request gpio%d (%s): %d\n",
+				pin->pin_num, pin->pin_name, error);
+			return error;
+		}
+		pin->claimed = true;
+
+		if (pin->direction == GPIO_DIR_OUT)
+			gpio_direction_output(pin->pin_num, pin->cur_dataout);
+		else
+			gpio_direction_input(pin->pin_num);
+	}
+
+	if (of_property_read_bool(np, "bidir"))
+		pin->flags = FBXGPIO_PIN_DIR_RW;
+
+	pin->of_node = np;
+	pin->ops = &fbxgpio_dt_ops;
+	return 0;
+}
+
+static int fbxgpio_dt_probe(struct platform_device *pdev)
+{
+	struct fbxgpio_dt_priv *priv;
+	struct device_node *fbxgpio_node;
+	u32 cur_gpio;
+	int error = 0;
+	size_t priv_alloc_size;
+	int i;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof (*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	dev_set_drvdata(&pdev->dev, priv);
+
+	/*
+	 * first pass to get the number of struct fbxgpio_pin to
+	 * allocate.
+	 */
+	for_each_available_child_of_node(pdev->dev.of_node, fbxgpio_node) {
+		++priv->npins;
+	}
+
+	/*
+	 * allocate pins: use npins + 1 for zeroed end sentinel.
+	 */
+	priv_alloc_size = (priv->npins + 1) * sizeof (struct fbxgpio_pin);
+	priv->pins = devm_kzalloc(&pdev->dev, priv_alloc_size, GFP_KERNEL);
+	if (!priv->pins)
+		return -ENOMEM;
+
+	/*
+	 * second pass to fill the priv->pins array.
+	 */
+	cur_gpio = 0;
+	for_each_available_child_of_node(pdev->dev.of_node, fbxgpio_node) {
+		error = fbxgpio_dt_fill_gpio(pdev, fbxgpio_node,
+					     &priv->pins[cur_gpio]);
+		if (error)
+			goto out_free_gpios;
+		++cur_gpio;
+	}
+
+	dev_info(&pdev->dev, "%u gpios.\n", priv->npins);
+
+	/*
+	 * create and register a platform device for fbxgpio_core.
+	 */
+	priv->top_pdev = platform_device_register_data(&pdev->dev,
+						       "fbxgpio",
+						       atomic_inc_return(&last_id),
+						       priv->pins,
+						       priv_alloc_size);
+
+	if (IS_ERR(priv->top_pdev)) {
+		dev_err(&pdev->dev, "unable to register fbxgpio platform "
+			"device: %ld\n", PTR_ERR(priv->top_pdev));
+		return PTR_ERR(priv->top_pdev);
+	}
+
+	for (i = 0; i < priv->npins; i++) {
+		struct fbxgpio_pin *pin = &priv->pins[i];
+
+		if (pin->direction == GPIO_DIR_OUT)
+			dev_dbg(&pdev->dev,
+				"%sgpio %d (%s) is output, default %d\n",
+				pin->claimed ? "unclaimed " : "",
+				pin->pin_num, pin->pin_name, pin->cur_dataout);
+		else
+			dev_dbg(&pdev->dev,
+				"%sgpio %d (%s) is input\n",
+				pin->claimed ? "unclaimed " : "",
+				pin->pin_num, pin->pin_name);
+	}
+
+	return 0;
+
+out_free_gpios:
+	while (cur_gpio) {
+		--cur_gpio;
+		if (priv->pins[cur_gpio].claimed)
+			gpio_free(priv->pins[cur_gpio].pin_num);
+	}
+	return error;
+}
+
+static int fbxgpio_dt_remove(struct platform_device *pdev)
+{
+	struct fbxgpio_dt_priv *priv = dev_get_drvdata(&pdev->dev);
+	unsigned int i;
+
+	platform_device_unregister(priv->top_pdev);
+
+	for (i = 0; i < priv->npins; ++i) {
+		if (priv->pins[i].claimed)
+			gpio_free(priv->pins[i].pin_num);
+	}
+
+	return 0;
+}
+
+static const struct of_device_id fbxgpio_dt_of_match_table[] = {
+	{ .compatible = "fbx,fbxgpio" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, fbxgpio_dt_of_match_table);
+
+static struct platform_driver fbxgpio_dt_platform_driver = {
+	.probe		= fbxgpio_dt_probe,
+	.remove		= fbxgpio_dt_remove,
+	.driver		= {
+		.name		= "fbxgpio-dt",
+		.of_match_table	= fbxgpio_dt_of_match_table,
+	},
+};
+
+module_platform_driver(fbxgpio_dt_platform_driver);
+
+MODULE_AUTHOR("Nicolas Schichan <nschichan@freebox.fr>");
+MODULE_DESCRIPTION("DT Freebox GPIO Driver");
+MODULE_LICENSE("GPL v2");
diff -Nruw linux-5.4.60-fbx/drivers/fbxgpio./Kconfig linux-5.4.60-fbx/drivers/fbxgpio/Kconfig
--- linux-5.4.60-fbx/drivers/fbxgpio./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxgpio/Kconfig	2021-03-04 13:20:57.760838887 +0100
@@ -0,0 +1,7 @@
+config FREEBOX_GPIO
+	tristate "Freebox GPIO control interface"
+	default n
+
+config FREEBOX_GPIO_DT
+	tristate "Freebox GPIO DT binding."
+	default n
diff -Nruw linux-5.4.60-fbx/drivers/fbxgpio./Makefile linux-5.4.60-fbx/drivers/fbxgpio/Makefile
--- linux-5.4.60-fbx/drivers/fbxgpio./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxgpio/Makefile	2021-03-04 13:20:57.760838887 +0100
@@ -0,0 +1,2 @@
+obj-$(CONFIG_FREEBOX_GPIO)	+= fbxgpio_core.o
+obj-$(CONFIG_FREEBOX_GPIO_DT)	+= fbxgpio_dt.o
diff -Nruw linux-5.4.60-fbx/drivers/fbxjtag./Kconfig linux-5.4.60-fbx/drivers/fbxjtag/Kconfig
--- linux-5.4.60-fbx/drivers/fbxjtag./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxjtag/Kconfig	2021-03-04 13:20:57.760838887 +0100
@@ -0,0 +1,3 @@
+config FREEBOX_JTAG
+	tristate "Freebox JTAG control interface"
+	default n
diff -Nruw linux-5.4.60-fbx/drivers/fbxjtag./Makefile linux-5.4.60-fbx/drivers/fbxjtag/Makefile
--- linux-5.4.60-fbx/drivers/fbxjtag./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxjtag/Makefile	2021-03-04 13:20:57.760838887 +0100
@@ -0,0 +1 @@
+obj-$(CONFIG_FREEBOX_JTAG)	+= fbxjtag.o
diff -Nruw linux-5.4.60-fbx/drivers/fbxprocfs./fbxprocfs.c linux-5.4.60-fbx/drivers/fbxprocfs/fbxprocfs.c
--- linux-5.4.60-fbx/drivers/fbxprocfs./fbxprocfs.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxprocfs/fbxprocfs.c	2021-03-04 13:20:57.760838887 +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 ssize_t 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	= single_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-5.4.60-fbx/drivers/fbxprocfs./Kconfig linux-5.4.60-fbx/drivers/fbxprocfs/Kconfig
--- linux-5.4.60-fbx/drivers/fbxprocfs./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxprocfs/Kconfig	2021-03-04 13:20:57.760838887 +0100
@@ -0,0 +1,2 @@
+config FREEBOX_PROCFS
+	tristate "Freebox procfs interface"
diff -Nruw linux-5.4.60-fbx/drivers/fbxprocfs./Makefile linux-5.4.60-fbx/drivers/fbxprocfs/Makefile
--- linux-5.4.60-fbx/drivers/fbxprocfs./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxprocfs/Makefile	2021-03-04 13:20:57.760838887 +0100
@@ -0,0 +1 @@
+obj-$(CONFIG_FREEBOX_PROCFS) += fbxprocfs.o
diff -Nruw linux-5.4.60-fbx/drivers/fbxwatchdog./fbxwatchdog_char.c linux-5.4.60-fbx/drivers/fbxwatchdog/fbxwatchdog_char.c
--- linux-5.4.60-fbx/drivers/fbxwatchdog./fbxwatchdog_char.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxwatchdog/fbxwatchdog_char.c	2021-03-04 13:20:57.760838887 +0100
@@ -0,0 +1,219 @@
+/*
+ * 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 <linux/uaccess.h>
+#include "fbxwatchdog.h"
+
+#include <linux/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-5.4.60-fbx/drivers/fbxwatchdog./fbxwatchdog_core.c linux-5.4.60-fbx/drivers/fbxwatchdog/fbxwatchdog_core.c
--- linux-5.4.60-fbx/drivers/fbxwatchdog./fbxwatchdog_core.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxwatchdog/fbxwatchdog_core.c	2021-03-04 13:20:57.760838887 +0100
@@ -0,0 +1,297 @@
+#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(struct timer_list *t)
+{
+	struct fbxwatchdog *wdt = from_timer(wdt, t, timer);
+
+	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 */
+	timer_setup(&wdt->timer, fbxwatchdog_timer_cb, 0);
+	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-5.4.60-fbx/drivers/fbxwatchdog./fbxwatchdog.h linux-5.4.60-fbx/drivers/fbxwatchdog/fbxwatchdog.h
--- linux-5.4.60-fbx/drivers/fbxwatchdog./fbxwatchdog.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxwatchdog/fbxwatchdog.h	2021-03-04 13:20:57.760838887 +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-5.4.60-fbx/drivers/fbxwatchdog./fbxwatchdog_orion.c linux-5.4.60-fbx/drivers/fbxwatchdog/fbxwatchdog_orion.c
--- linux-5.4.60-fbx/drivers/fbxwatchdog./fbxwatchdog_orion.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxwatchdog/fbxwatchdog_orion.c	2021-03-04 13:20:57.760838887 +0100
@@ -0,0 +1,301 @@
+#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 <linux/of.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;
+	struct fbxwatchdog	*wdt;
+};
+
+/*
+ * 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(struct timer_list *t)
+{
+	struct fbxwatchdog_orion_priv *priv = from_timer(priv, t, half_life_timer);
+	struct fbxwatchdog *wdt = priv->wdt;
+	unsigned long flags;
+
+	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;
+	timer_setup(&priv->half_life_timer, half_life_timer_cb, 0);
+	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;
+	}
+
+	priv->wdt = wdt;
+	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-5.4.60-fbx/drivers/fbxwatchdog./Kconfig linux-5.4.60-fbx/drivers/fbxwatchdog/Kconfig
--- linux-5.4.60-fbx/drivers/fbxwatchdog./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxwatchdog/Kconfig	2021-03-04 13:20:57.760838887 +0100
@@ -0,0 +1,24 @@
+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
+
+config FREEBOX_WATCHDOG_BCM63XX_OF
+	tristate "Broadcom 63xx Freebox Watchdog support (generic)"
+	depends on OF && !FREEBOX_WATCHDOG_BCM63XX
+
+endif
diff -Nruw linux-5.4.60-fbx/drivers/fbxwatchdog./Makefile linux-5.4.60-fbx/drivers/fbxwatchdog/Makefile
--- linux-5.4.60-fbx/drivers/fbxwatchdog./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/fbxwatchdog/Makefile	2021-03-04 13:20:57.760838887 +0100
@@ -0,0 +1,10 @@
+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
+obj-$(CONFIG_FREEBOX_WATCHDOG_BCM63XX_OF)	+= fbxwatchdog_bcm63xx_of.o
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/drivers/hwmon/kirkwood-coretemp.c	2021-03-04 13:20:58.457505585 +0100
@@ -0,0 +1,119 @@
+/*
+ * 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>
+#include <linux/of.h>
+
+#define PFX "kirkwood-coretemp: "
+
+struct kirkwood_coretemp_priv {
+	void __iomem *reg;
+};
+
+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 struct attribute *kirkwood_coretemp_attrs[] = {
+	&sensor_dev_attr_temp1_input.dev_attr.attr,
+	NULL,
+};
+
+ATTRIBUTE_GROUPS(kirkwood_coretemp);
+
+static int kirkwood_coretemp_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct kirkwood_coretemp_priv *priv;
+	struct resource *res;
+	struct device *hwmon_dev;
+	void __iomem *regs;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENOENT;
+
+	regs = devm_ioremap_resource(dev, res);
+	if (IS_ERR(regs))
+		return PTR_ERR(regs);
+
+	priv = devm_kzalloc(dev, sizeof (*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->reg = regs;
+	platform_set_drvdata(pdev, priv);
+
+	hwmon_dev = devm_hwmon_device_register_with_groups(dev,
+							   "kirkwood_coretemp",
+							   priv,
+							   kirkwood_coretemp_groups);
+	return PTR_ERR_OR_ZERO(hwmon_dev);
+}
+
+static int kirkwood_coretemp_remove(struct platform_device *pdev)
+{
+	return 0;
+}
+
+
+static const struct of_device_id kirkwood_coretemp_match[] = {
+	{ .compatible	= "marvell,kirkwood-coretemp" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, kirkwood_coretemp_match);
+
+static struct platform_driver kirkwood_coretemp_driver = {
+	.probe		= kirkwood_coretemp_probe,
+	.remove		= kirkwood_coretemp_remove,
+	.driver		= {
+		.name	= "kirkwood-coretemp",
+		.of_match_table	= kirkwood_coretemp_match,
+	},
+};
+
+module_platform_driver(kirkwood_coretemp_driver);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Nicolas Schichan <nschichan@freebox.fr>");
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/drivers/input/misc/smsc_cap1066.c	2021-03-04 13:20:58.607505592 +0100
@@ -0,0 +1,1117 @@
+#include <linux/kernel.h>
+#include <linux/delay.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/consumer.h>
+#include <linux/of_gpio.h>
+#include <linux/reset.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 u32 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;
+	u32			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;
+
+	struct gpio_desc	*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->irq_gpio && gpiod_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 device_node *np = client->dev.of_node;
+	struct input_polled_dev *poll_dev;
+	struct input_dev *input;
+	struct cap1066_priv *priv;
+	struct reset_control *reset;
+	int ret, i;
+
+	priv = devm_kzalloc(&client->dev, sizeof (*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->irq_gpio = devm_gpiod_get_optional(&client->dev,
+						 "irq",
+						 GPIOD_IN);
+	if (IS_ERR(priv->irq_gpio)) {
+		ret = PTR_ERR(priv->irq_gpio);
+		if (ret != -EPROBE_DEFER)
+			dev_err(&client->dev,
+				"failed to get irq gpio :%d", ret);
+		return ret;
+	}
+
+	if (np) {
+		ret = of_property_read_u32_array(np,
+						 "keymap",
+						 priv->keymap,
+						 ARRAY_SIZE(priv->keymap));
+		if (ret < 0) {
+			dev_err(&client->dev,
+				"bad/missing keymap property: %d", ret);
+			return ret;
+		}
+	} else
+		memcpy(priv->keymap, default_map, sizeof (priv->keymap));
+
+	/* un-reset if needed */
+	reset = devm_reset_control_get_shared_by_index(&client->dev, 0);
+	if (IS_ERR(reset)) {
+		ret = PTR_ERR(reset);
+		if (ret == -ENOENT)
+			reset = NULL;
+		else if (ret != -EPROBE_DEFER){
+			dev_err(&client->dev, "failed to get reset: %d\n",
+				ret);
+			return ret;
+		}
+	}
+
+	if (reset && reset_control_status(reset)) {
+		reset_control_deassert(reset);
+		msleep(10);
+	}
+
+	ret = cap1066_detect(client, NULL);
+	if (ret) {
+		if (ret != -ENODEV)
+			return ret;
+
+		dev_warn(&client->dev, "unknown cap1x66 device, try anyway.\n");
+	}
+
+	/* initialize controller */
+	ret = cap1066_init_hw(client);
+	if (ret)
+		return ret;
+
+	/* allocate context */
+	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;
+
+	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);
+	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);
+
+	return 0;
+}
+
+static const struct of_device_id cap1066_of_table[] = {
+	{ .compatible = "smsc,smsc_cap1066" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, cap1066_of_table);
+
+static struct i2c_driver cap1066_driver = {
+	.driver = {
+		.name	= "cap1066",
+		.of_match_table	= of_match_ptr(cap1066_of_table),
+	},
+	.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-5.4.60-fbx/drivers/misc/hdmi-cec./Kconfig linux-5.4.60-fbx/drivers/misc/hdmi-cec/Kconfig
--- linux-5.4.60-fbx/drivers/misc/hdmi-cec./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/misc/hdmi-cec/Kconfig	2021-03-04 13:20:58.914172272 +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-5.4.60-fbx/drivers/misc/hdmi-cec./Makefile linux-5.4.60-fbx/drivers/misc/hdmi-cec/Makefile
--- linux-5.4.60-fbx/drivers/misc/hdmi-cec./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/misc/hdmi-cec/Makefile	2021-03-04 13:20:58.914172272 +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-5.4.60-fbx/drivers/misc/remoti./Kconfig linux-5.4.60-fbx/drivers/misc/remoti/Kconfig
--- linux-5.4.60-fbx/drivers/misc/remoti./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/misc/remoti/Kconfig	2021-03-04 13:20:58.924172273 +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-5.4.60-fbx/drivers/misc/remoti./Makefile linux-5.4.60-fbx/drivers/misc/remoti/Makefile
--- linux-5.4.60-fbx/drivers/misc/remoti./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/misc/remoti/Makefile	2021-03-04 13:20:58.924172273 +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-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63158./enet/Makefile linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63158/enet/Makefile
--- linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63158./enet/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63158/enet/Makefile	2021-03-04 13:20:59.017505610 +0100
@@ -0,0 +1,11 @@
+obj-$(CONFIG_BCM63158_ENET_RUNNER) 	+= bcm63158_enet_runner.o
+
+bcm63158_enet_runner-y	:= \
+	ethtool.o \
+	main.o \
+	port_unimac.o \
+	port_xport.o \
+	port_xport_serdes.o \
+	port_xport_epon.o \
+	port_xport_epon_dbg.o \
+	port_xport_xlmac.o
diff -Nruw linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63158./Makefile linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63158/Makefile
--- linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63158./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63158/Makefile	2021-03-04 13:20:59.017505610 +0100
@@ -0,0 +1,3 @@
+obj-$(CONFIG_BCM63158_SYSTEMPORT) 	+= bcmsysport_63158.o
+obj-$(CONFIG_BCM63158_ENET_RUNNER) 	+= enet/
+obj-$(CONFIG_BCM63158_SF2) 		+= sf2/
diff -Nruw linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63158./sf2/Makefile linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63158/sf2/Makefile
--- linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63158./sf2/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63158/sf2/Makefile	2021-03-04 13:20:59.020838944 +0100
@@ -0,0 +1,4 @@
+obj-$(CONFIG_BCM63158_SF2) 		+= bcm63158_sf2.o
+
+bcm63158_sf2-y 				+= sf2_main.o sf2_fdb.o
+bcm63158_sf2-$(CONFIG_DEBUG_FS) 	+= sf2_debug.o
diff -Nruw linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63xx_enet_runner./Makefile linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63xx_enet_runner/Makefile
--- linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63xx_enet_runner./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/ethernet/broadcom/bcm63xx_enet_runner/Makefile	2021-03-04 13:20:59.020838944 +0100
@@ -0,0 +1,5 @@
+obj-$(CONFIG_BCM63XX_ENET_RUNNER) 	+= bcm63xx_enet_runner_mod.o
+obj-$(CONFIG_BCM63XX_ENET_RUNNER) 	+= bcm63xx_sf2.o
+
+bcm63xx_enet_runner_mod-y 			+= bcm63xx_enet_runner.o
+bcm63xx_enet_runner_mod-$(CONFIG_DEBUG_FS) 	+= bcm63xx_enet_runner_debug.o
diff -Nruw linux-5.4.60-fbx/drivers/net/ethernet/wintegra./Kconfig linux-5.4.60-fbx/drivers/net/ethernet/wintegra/Kconfig
--- linux-5.4.60-fbx/drivers/net/ethernet/wintegra./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/ethernet/wintegra/Kconfig	2021-03-04 13:20:59.274172288 +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-5.4.60-fbx/drivers/net/ethernet/wintegra./Makefile linux-5.4.60-fbx/drivers/net/ethernet/wintegra/Makefile
--- linux-5.4.60-fbx/drivers/net/ethernet/wintegra./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/ethernet/wintegra/Makefile	2021-03-04 13:20:59.274172288 +0100
@@ -0,0 +1 @@
+obj-$(CONFIG_WINTEGRA_WINPATH3_ETH) += wp3_eth.o
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./d11_defs.h linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/d11_defs.h
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./d11_defs.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/d11_defs.h	2021-03-04 13:20:59.424172295 +0100
@@ -0,0 +1,59 @@
+#ifndef D11_DEFS_H_
+#define D11_DEFS_H_
+
+/*
+ *
+ */
+static const u16 bits_per_symbol[][2] = {
+	/* 20MHz 40MHz */
+	{    26,   54 },     /*  0: BPSK */
+	{    52,  108 },     /*  1: QPSK 1/2 */
+	{    78,  162 },     /*  2: QPSK 3/4 */
+	{   104,  216 },     /*  3: 16-QAM 1/2 */
+	{   156,  324 },     /*  4: 16-QAM 3/4 */
+	{   208,  432 },     /*  5: 64-QAM 2/3 */
+	{   234,  486 },     /*  6: 64-QAM 3/4 */
+	{   260,  540 },     /*  7: 64-QAM 5/6 */
+};
+
+#define IEEE80211_SEQ_SEQ_SHIFT    4
+#define IEEE80211_SEQ_MAX          4096
+
+#define IEEE80211_AGGR_MAX_MPDU    64
+
+#define AMPDU_DELIM_SZ          4
+#define BITS_PER_BYTE           8
+#define OFDM_PLCP_BITS          22
+#define HT_RC_2_STREAMS(_rc)    ((((_rc) & 0x78) >> 3) + 1)
+#define L_STF                   8
+#define L_LTF                   8
+#define L_SIG                   4
+#define HT_SIG                  8
+#define HT_STF                  4
+#define HT_LTF(_ns)             (4 * (_ns))
+#define SYMBOL_TIME(_ns)        ((_ns) << 2) /* ns * 4 us */
+#define SYMBOL_TIME_HALFGI(_ns) (((_ns) * 18 + 4) / 5)  /* ns * 3.6 us */
+#define TIME_SYMBOLS(t)         ((t) >> 2)
+#define TIME_SYMBOLS_HALFGI(t)  (((t) * 5 - 4) / 18)
+#define NUM_SYMBOLS_PER_USEC(_usec) (_usec >> 2)
+#define NUM_SYMBOLS_PER_USEC_HALFGI(_usec) (((_usec*5)-4)/18)
+
+#define TID_TO_WME_AC(_tid)				\
+	((((_tid) == 0) || ((_tid) == 3)) ? IEEE80211_AC_BE :	\
+	 (((_tid) == 1) || ((_tid) == 2)) ? IEEE80211_AC_BK :	\
+	 (((_tid) == 4) || ((_tid) == 5)) ? IEEE80211_AC_VI :	\
+	 IEEE80211_AC_VO)
+
+
+/* compressed blockack bitmap size (in bits) */
+#define D11_BA_BMP_SIZE			64
+
+/* return block-ack bitmap index given sequence and starting sequence */
+#define D11_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_MAX - 1))
+
+/* return whether a bit at index _n in bitmap _bm is set
+ * _sz is the size of the bitmap  */
+#define D11_BA_ISSET(_bm, _n)  (((_n) < (D11_BA_BMP_SIZE)) &&		\
+				((_bm)[(_n) >> 3] & (1 << ((_n) & 7))))
+
+#endif /* !D11_DEFS_H_ */
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./debugfs.c linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/debugfs.c
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./debugfs.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/debugfs.c	2021-03-04 13:20:59.424172295 +0100
@@ -0,0 +1,81 @@
+#include "mwl8k_priv.h"
+
+static struct dentry *dbg_dir;
+
+/*
+ *
+ */
+static int mwl8k_debugfs_show_test(void *data, u64 *val)
+{
+	struct mwl8k_priv *priv = data;
+	size_t i;
+
+	printk("test\n");
+	for (i = 0; i < 1000 * 1000; i++) {
+		(void)ioread32(priv->sram);
+		(void)iowrite32(0x0, priv->sram);
+		if (i % 10000 == 0)
+			msleep(1);
+		if (signal_pending(current))
+			break;
+	}
+
+	*val = 0;
+	return 0;
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(mwl8k_debugfs_test, mwl8k_debugfs_show_test,
+			 NULL, "%lld\n");
+
+/*
+ * This function creates the debug FS directory structure and the files.
+ */
+void mwl8k_debugfs_dev_init(struct mwl8k_priv *priv)
+{
+	if (!dbg_dir)
+		return;
+
+	/* export regs */
+	priv->blob_regs.data = priv->regs;
+	priv->blob_regs.size = 64 * 1024;
+	priv->blob_sram.data = priv->sram;
+	priv->blob_sram.size = 64 * 1024;
+
+	priv->dbg_regs = debugfs_create_blob("regs", 0644, dbg_dir,
+					     &priv->blob_regs);
+	priv->dbg_sram = debugfs_create_blob("sram", 0644, dbg_dir,
+					     &priv->blob_sram);
+	priv->dbg_test = debugfs_create_file("test", 0644, dbg_dir,
+					     priv, &mwl8k_debugfs_test);
+}
+
+/*
+ * This function removes the debug FS directory structure and the files.
+ */
+void mwl8k_debugfs_dev_remove(struct mwl8k_priv *priv)
+{
+	if (priv->dbg_regs)
+		debugfs_remove(priv->dbg_regs);
+	if (priv->dbg_sram)
+		debugfs_remove(priv->dbg_sram);
+	if (priv->dbg_test)
+		debugfs_remove(priv->dbg_test);
+}
+
+/*
+ * This function creates the top level proc directory.
+ */
+void mwl8k_debugfs_init(void)
+{
+	dbg_dir = debugfs_create_dir("mwl8k_new", NULL);
+	if (!dbg_dir)
+		printk(KERN_ERR "failed to create debugfs dir\n");
+}
+
+/*
+ * This function removes the top level proc directory.
+ */
+void mwl8k_debugfs_remove(void)
+{
+	debugfs_remove(dbg_dir);
+}
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./fw.c linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/fw.c
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./fw.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/fw.c	2021-03-04 13:20:59.424172295 +0100
@@ -0,0 +1,290 @@
+#include "mwl8k_priv.h"
+
+/*
+ * LEGACY INTERFACE, used to exchange with helper
+ */
+struct mwl8k_cmd_pkt {
+	__le16	code;
+	__le16	length;
+	__u8	seq_num;
+	__u8	macid;
+	__le16	result;
+	char	payload[0];
+} __packed;
+
+#define MWL8K_HIU_GEN_PTR			0x00000c10
+#define MWL8K_HIU_INT_CODE			0x00000c14
+#define  MWL8K_INT_CODE_CMD_FINISHED		 0x00000005
+#define MWL8K_HIU_H2A_INTERRUPT_STATUS		0x00000c1c
+#define MWL8K_HIU_SCRATCH			0x00000c40
+
+#define  MWL8K_H2A_INT_DUMMY			 (1 << 20)
+#define  MWL8K_H2A_INT_RESET			 (1 << 15)
+#define  MWL8K_H2A_INT_DOORBELL			 (1 << 1)
+
+#define MWL8K_CMD_CODE_DNLD		0x0001
+
+/*
+ * end LEGACY INTERFACE
+ */
+
+
+/*
+ *
+ */
+static int mwl8k_send_fw_load_cmd(struct mwl8k_priv *priv, void *data, int length)
+{
+	void __iomem *regs = priv->regs;
+	dma_addr_t dma_addr;
+	int loops;
+
+	dma_addr = pci_map_single(priv->pdev, data, length, PCI_DMA_TODEVICE);
+	if (pci_dma_mapping_error(priv->pdev, dma_addr))
+		return -ENOMEM;
+
+	iowrite32(dma_addr, regs + MWL8K_HIU_GEN_PTR);
+	iowrite32(0, regs + MWL8K_HIU_INT_CODE);
+	iowrite32(MWL8K_H2A_INT_DOORBELL,
+		regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS);
+	iowrite32(MWL8K_H2A_INT_DUMMY,
+		regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS);
+
+	loops = 10000;
+	do {
+		if (priv->info->helper_image) {
+			u32 int_code = ioread32(regs + MWL8K_HIU_INT_CODE);
+			//printk("int code: %08x\n", int_code);
+			if (int_code == MWL8K_INT_CODE_CMD_FINISHED) {
+				iowrite32(0, regs + MWL8K_HIU_INT_CODE);
+				break;
+			}
+		} else {
+			u32 int_code;
+
+			int_code = ioread32(regs +
+					    MWL8K_HIU_H2A_INTERRUPT_STATUS);
+			//printk("int code: %08x\n", int_code);
+			if (int_code == 0)
+				break;
+		}
+
+		cond_resched();
+		udelay(1);
+	} while (--loops);
+
+	pci_unmap_single(priv->pdev, dma_addr, length, PCI_DMA_TODEVICE);
+
+	if (!loops) {
+		dev_dbg(&priv->pdev->dev,
+			"mwl8k_send_fw_load_cmd %u timeout\n",
+			length);
+	}
+
+	return loops ? 0 : -ETIMEDOUT;
+}
+
+/*
+ * firmware loading for 8366, bootrom interface
+ */
+static int mwl8k_load_fw_image(struct mwl8k_priv *priv,
+				const u8 *data, size_t length)
+{
+	struct mwl8k_cmd_pkt *cmd;
+	int done;
+	int rc = 0;
+
+	//printk("mwl8k_load_fw_image len:%u\n", length);
+
+	cmd = kmalloc(sizeof(*cmd) + 256, GFP_KERNEL);
+	if (cmd == NULL)
+		return -ENOMEM;
+
+	cmd->code = cpu_to_le16(MWL8K_CMD_CODE_DNLD);
+	cmd->seq_num = 0;
+	cmd->macid = 0;
+	cmd->result = 0;
+
+	done = 0;
+	while (length) {
+		int block_size = length > 256 ? 256 : length;
+
+		memcpy(cmd->payload, data + done, block_size);
+		cmd->length = cpu_to_le16(block_size);
+
+		//printk("load size: %u\n", block_size);
+		rc = mwl8k_send_fw_load_cmd(priv, cmd,
+						sizeof(*cmd) + block_size);
+		if (rc)
+			break;
+
+		done += block_size;
+		length -= block_size;
+
+		msleep(1);
+	}
+
+	if (!rc) {
+		//printk("final block\n");
+		cmd->length = 0;
+		rc = mwl8k_send_fw_load_cmd(priv, cmd, sizeof(*cmd));
+	}
+
+	kfree(cmd);
+
+	return rc;
+}
+
+/*
+ * firmware loading for 8366 helper & 8764 bootrom
+ */
+static int mwl8k_feed_fw_image(struct mwl8k_priv *priv,
+				const u8 *data, size_t length)
+{
+	unsigned char *buffer;
+	int may_continue, rc = 0;
+	u32 done, prev_block_size;
+
+	//printk("mwl8k_feed_fw_image: len:%u\n", length);
+
+	buffer = kmalloc(1024, GFP_KERNEL);
+	if (buffer == NULL) {
+		return -ENOMEM;
+	}
+
+	done = 0;
+	prev_block_size = 0;
+	may_continue = 1000;
+	while (may_continue > 0) {
+		u32 block_size;
+
+		block_size = ioread32(priv->regs + MWL8K_HIU_SCRATCH);
+		if (block_size & 1) {
+			//printk("BLOCK SIZE : %x\n", block_size);
+			rc = -EREMOTEIO;
+			break;
+		} else {
+			done += prev_block_size;
+			length -= prev_block_size;
+			//printk("total done: %u\n", done);
+		}
+
+		if (block_size > 1024 || block_size > length) {
+			rc = -EOVERFLOW;
+			//printk("OVERFLOW\n");
+			break;
+		}
+
+		if (length == 0) {
+			//printk("length finished\n");
+			rc = 0;
+			break;
+		}
+
+		if (block_size == 0) {
+			//printk("block_size == 0\n");
+			rc = -EPROTO;
+			may_continue--;
+			udelay(1);
+			continue;
+		}
+
+		//printk("block_size == %d\n", block_size);
+		prev_block_size = block_size;
+		memcpy(buffer, data + done, block_size);
+
+		rc = mwl8k_send_fw_load_cmd(priv, buffer, block_size);
+		if (rc) {
+			printk("send_fw_load_cmd failed\n");
+			break;
+		}
+	}
+
+	if (!rc && length != 0) {
+		rc = -EREMOTEIO;
+	}
+
+	kfree(buffer);
+
+	return rc;
+}
+
+/*
+ *
+ */
+int mwl8k_fw_upload(struct mwl8k_priv *priv)
+{
+	const struct firmware *fw = priv->fw_ucode;
+	const struct firmware *helper = priv->fw_helper;
+	int rc;
+
+	if (helper) {
+		rc = mwl8k_load_fw_image(priv, helper->data, helper->size);
+		if (rc) {
+			dev_err(&priv->pdev->dev,
+				"unable to load firmware helper image\n");
+			return rc;
+		}
+
+		/* give time for helper to load */
+		msleep(10);
+	}
+
+	rc = mwl8k_feed_fw_image(priv, fw->data, fw->size);
+	if (rc) {
+		dev_err(&priv->pdev->dev,
+			"unable to load firmware image\n");
+		return rc;
+	}
+
+	return 0;
+}
+
+/*
+ *
+ */
+int mwl8k_fw_request(struct mwl8k_priv *priv)
+{
+	int ret;
+
+	if (priv->info->helper_image) {
+		ret = request_firmware(&priv->fw_helper,
+				       priv->info->helper_image,
+				       &priv->pdev->dev);
+		if (ret) {
+			dev_err(&priv->pdev->dev,
+				"error requesting helper fw\n");
+			return ret;
+		}
+	}
+
+	ret = request_firmware(&priv->fw_ucode,
+			       priv->info->fw_image,
+			       &priv->pdev->dev);
+	if (ret) {
+		dev_err(&priv->pdev->dev,
+			"error requesting fw image\n");
+		return ret;
+	}
+
+	return 0;
+}
+
+/*
+ *
+ */
+static void fw_free(const struct firmware **fw)
+{
+	if (*fw == NULL)
+		return;
+	release_firmware(*fw);
+	*fw = NULL;
+}
+
+/*
+ *
+ */
+void mwl8k_fw_release(struct mwl8k_priv *priv)
+{
+	fw_free(&priv->fw_ucode);
+	fw_free(&priv->fw_helper);
+}
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./hostif_dmatest.h linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/hostif_dmatest.h
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./hostif_dmatest.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/hostif_dmatest.h	2021-03-04 13:20:59.424172295 +0100
@@ -0,0 +1,32 @@
+#ifndef HOSTIF_DMATEST_H_
+#define HOSTIF_DMATEST_H_
+
+#ifndef __KERNEL__
+/*
+ * map to linux kernel types for easier sharing
+ */
+#include <arch/mv8xxx/linux_types.h>
+#endif
+
+#ifndef __packed
+#define __packed __attribute__((packed))
+#endif
+
+/*
+ * DMA test service
+ */
+#define SVC_DMATEST_UUID	0x3bdb253c
+
+struct ixzone_svc_dma_test {
+
+	struct {
+		/*
+		 * single area used by firmware for doing read/write
+		 * test transfers to host RAM
+		 */
+		__le32		fw_req_size;
+		__le32		host_dma_address;
+	} test;
+} __packed;
+
+#endif /* HOSTIF_DMATEST_H_ */
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./hostif.h linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/hostif.h
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./hostif.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/hostif.h	2021-03-04 13:20:59.424172295 +0100
@@ -0,0 +1,83 @@
+#ifndef HOSTIF_H_
+#define HOSTIF_H_
+
+#ifndef __KERNEL__
+/*
+ * map to linux kernel types for easier sharing
+ */
+#include <arch/mv8xxx/linux_types.h>
+#endif
+
+#ifndef __packed
+#define __packed __attribute__((packed))
+#endif
+
+/*
+ * generic exchange ring buffer
+ */
+struct ixzone_ring_buf {
+	__le32			buf_offset;
+	__le32			buf_size;
+
+	/*
+	 * 'producer' & 'consumer' are relative (0 < val < buf_size)
+	 *
+	 * (consumer == producer) => buffer is empty
+	 * (producer == consumer - 1) => buffer is full
+	 */
+	__le32			producer;
+	__le32			consumer;
+} __packed;
+
+/*
+ * CONSOLE service
+ */
+#define SVC_CONSOLE_UUID	0x00010001
+
+struct ixzone_svc_console {
+	/*
+	 * producer == FW
+	 * consumer == HOST
+	 */
+	struct ixzone_ring_buf	rb;
+	__le32			irq_mask;
+} __packed;
+
+/*
+ * TTY service
+ */
+#define SVC_TTY_UUID		0x00010002
+
+struct ixzone_svc_tty {
+	/* producer is FW */
+	struct ixzone_ring_buf	f2h_rb;
+	__le32			f2h_irq_mask;
+
+	/* producer is host */
+	struct ixzone_ring_buf	h2f_rb;
+	__le32			h2f_irq_mask;
+} __packed;
+
+/*
+ * BOOT_AREA headers
+ */
+#define BOOTAREA_MAGIC		0x2cc4189b
+
+struct bootarea_root {
+	__le32			magic;
+	__u8			early_svc_count;
+	__u8			boot_done;
+	__le16			svc_count;
+} __packed;
+
+#define BOOTAREA_SVC_FLAG_SYNCH	(1 << 0)
+
+struct bootarea_svc {
+	__le32			svc_uuid;
+	__le32			svc_flags;
+
+	/* relative to root */
+	__le32			off;
+} __packed;
+
+#endif
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./hostif_wifi.h linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/hostif_wifi.h
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./hostif_wifi.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/hostif_wifi.h	2021-03-04 13:20:59.424172295 +0100
@@ -0,0 +1,612 @@
+#ifndef HOSTIF_WIFI_H_
+#define HOSTIF_WIFI_H_
+
+#ifndef __KERNEL__
+/*
+ * map to linux kernel types for easier sharing
+ */
+#include <arch/mv8xxx/linux_types.h>
+#endif
+
+#ifndef __packed
+#define __packed __attribute__((packed))
+#endif
+
+/*
+ * wifi service
+ */
+#define SVC_WIFI_UUID		0x43b2cab9
+
+#define WIFI_API_VERSION	1
+#define WIFI_MAX_TX_QUEUES	16
+
+enum wifi_cmd_id {
+	/* global commands */
+	WIFI_CMD_ADD_VIF,
+	WIFI_CMD_API_VERSION,
+	WIFI_CMD_DRAIN_QUEUE_SCHED,
+	WIFI_CMD_FW_VERSION,
+	WIFI_CMD_GET_MAC_ADDRESS,
+	WIFI_CMD_RADIO_CONTROL,
+	WIFI_CMD_GET_CHAN_SURVEY,
+	WIFI_CMD_RELEASE_VIF,
+	WIFI_CMD_SET_RX_FILTER,
+	WIFI_CMD_START,
+	WIFI_CMD_STOP,
+
+	/*  PER VIF commands */
+	WIFI_CMD_VIF_ADD_STA,
+	WIFI_CMD_VIF_DEL_STA,
+	WIFI_CMD_VIF_ADD_KEY,
+	WIFI_CMD_VIF_DEL_KEY,
+	WIFI_CMD_VIF_ENABLE_BEACON,
+	WIFI_CMD_VIF_GET_DTIM_COUNT,
+	WIFI_CMD_VIF_SET_BEACON_PARAMS,
+	WIFI_CMD_VIF_SET_BSS_PARAMS,
+	WIFI_CMD_VIF_SET_EDCA_PARAMS,
+	WIFI_CMD_VIF_SET_SHORT_SLOT,
+	WIFI_CMD_VIF_START,
+	WIFI_CMD_VIF_STOP,
+	WIFI_CMD_VIF_UPDATE_BEACON,
+
+	WIFI_CMD_LAST,
+};
+
+enum wifi_chan_bw {
+	WIFI_CHAN_BW_10MHZ,
+	WIFI_CHAN_BW_20MHZ,
+	WIFI_CHAN_BW_40MHZ_ABOVE,
+	WIFI_CHAN_BW_40MHZ_BELOW,
+	WIFI_CHAN_BW_5MHZ,
+};
+
+enum wifi_vif_type {
+	WIFI_VIF_TYPE_STA,
+	WIFI_VIF_TYPE_AP,
+};
+
+struct wifi_cmd_radio_control_req {
+	__u8		channel;
+	__u8		bw; /* enum wifi_chan_bw */
+} __packed;
+
+struct wifi_cmd_start_req {
+	struct {
+		__le32		dma_addr;
+		__le32		len;
+	} rx;
+
+	struct {
+		/* set len to 0 when not used */
+		__le32		dma_addr;
+		__le32		len;
+	} tx[WIFI_MAX_TX_QUEUES];
+
+} __packed;
+
+enum {
+	/* disable FCS fail filter */
+	WIFI_FILTER_FCS_FAIL		= (1 << 0),
+
+	/* disable all filters (include ftype filters) */
+	WIFI_FILTER_PROMISC		= (1 << 1),
+
+	/* disable multicast filter */
+	WIFI_FILTER_ALL_MULTI		= (1 << 2),
+
+	/* disable BSSID filter */
+	WIFI_FILTER_ALL_BSSID		= (1 << 3),
+
+	/* various per-ftype filter */
+	WIFI_FILTER_FTYPE_CONTROL	= (1 << 4),
+	WIFI_FILTER_FTYPE_PS_POLL	= (1 << 5),
+	WIFI_FILTER_FTYPE_PROBE_REQ	= (1 << 6),
+};
+
+enum wifi_ac {
+	WIFI_AC_BK = 0,
+	WIFI_AC_BE,
+	WIFI_AC_VI,
+	WIFI_AC_VO,
+};
+
+#define WIFI_AC_COUNT	4
+
+enum {
+	WIFI_CMD_CHAN_ASYNC,
+	WIFI_CMD_CHAN_ATOMIC,
+
+	WIFI_CMD_CHAN_LAST,
+};
+
+enum wifi_cmd_result {
+	WIFI_RESULT_OK,
+	WIFI_RESULT_INVAL,
+	WIFI_RESULT_UNKNOWN_CMD,
+	WIFI_RESULT_IO_ERROR,
+	WIFI_RESULT_NOSPC,
+	WIFI_RESULT_NOENT,
+	WIFI_RESULT_BUSY,
+	WIFI_RESULT_EAGAIN,
+	WIFI_RESULT_EXISTS,
+};
+
+#define WIFI_INVALID_VIF_HWID	0xffff
+#define WIFI_INVALID_STA_HWID	0xffff
+#define WIFI_INVALID_KEY_HWID	0xff
+#define WIFI_INVALID_TBTT_IDX	0xff
+
+struct wifi_cmd_set_rx_filter_req {
+	__le32		filter;
+} __packed;
+
+struct wifi_cmd_add_vif_req {
+	__u8			type; /* enum wifi_vif_type */
+	__u8			mac_addr[6];
+} __packed;
+
+struct wifi_cmd_get_chan_survey_resp {
+	__s8		avg_nf;
+	__u64		chan_time;
+	__u64		chan_busy;
+	__u64		chan_rx;
+	__u64		chan_tx;
+} __packed;
+
+struct wifi_cmd_add_vif_resp {
+	__le16		vif_hwid;
+	__u8		tbtt_idx;
+	__u8		ac_to_qid[WIFI_AC_COUNT];
+	__u8		cab_qid;
+} __packed;
+
+struct wifi_cmd_release_vif_req {
+	__le16		vif_hwid;
+} __packed;
+
+struct wifi_cmd_vif_start_req {
+	__le16		vif_hwid;
+} __packed;
+
+struct wifi_cmd_vif_stop_req {
+	__le16		vif_hwid;
+} __packed;
+
+struct wifi_cmd_vif_set_bss_params_req {
+	__le16		vif_hwid;
+	__u8		bssid[6];
+} __packed;
+
+struct wifi_cmd_vif_add_sta_req {
+	__le16		vif_hwid;
+	__u8		mac[6];
+} __packed;
+
+struct wifi_cmd_vif_add_sta_resp {
+	__le16		sta_hwid;
+} __packed;
+
+struct wifi_cmd_vif_del_sta_req {
+	__le16		vif_hwid;
+	__le16		sta_hwid;
+} __packed;
+
+struct wifi_cmd_vif_add_key_req {
+	__le16		vif_hwid;
+	__le16		sta_hwid;
+	__u8		key[16];
+	__u8		key_idx;
+} __packed;
+
+struct wifi_cmd_vif_add_key_resp {
+	__u8		key_hwid;
+} __packed;
+
+struct wifi_cmd_vif_del_key_req {
+	__le16		vif_hwid;
+	__le16		sta_hwid;
+	__u8		key_hwid;
+} __packed;
+
+struct wifi_cmd_vif_set_edca_params_req {
+	__le16		vif_hwid;
+	__u8		txq_idx;
+	__le16		aifsn;
+	__le16		cw_min;
+	__le16		cw_max;
+	__le16		txop;
+} __packed;
+
+struct wifi_cmd_vif_set_beacon_params_req {
+	__le16		vif_hwid;
+
+	/*
+	 * those parameters cannot be changed while beaconing is
+	 * enabled
+	 */
+	__u8		rate_idx;
+	__le16		beacon_interval;
+	__u8		dtim_period;
+
+} __packed;
+
+struct wifi_cmd_vif_enable_beacon_req {
+	__le16		vif_hwid;
+	__u8		enabled;
+} __packed;
+
+struct wifi_cmd_vif_set_short_slot_req {
+	__le16		vif_hwid;
+	__u8		is_short;
+} __packed;
+
+struct wifi_cmd_drain_queue_sched_req {
+	__u8		qid;
+} __packed;
+
+struct wifi_cmd_vif_get_dtim_count_req {
+	__le16		vif_hwid;
+} __packed;
+
+struct wifi_cmd_vif_update_beacon_req {
+	__le16		vif_hwid;
+	__le32		bcn_host_addr;
+	__le16		bcn_size;
+} __packed;
+
+
+struct wifi_cmd_api_version_resp {
+	__le32		version;
+} __packed;
+
+struct wifi_cmd_fw_version_resp {
+	__le16		major;
+	__le16		minor;
+} __packed;
+
+struct wifi_cmd_get_mac_address_resp {
+	__u8		mac_addr[6];
+	__le16		mac_addr_count;
+} __packed;
+
+struct wifi_cmd_vif_get_dtim_count_resp {
+	__u8		dtim_count;
+};
+
+struct wifi_cmd_hdr {
+	__le32		id;
+	__le32		size;
+} __packed;
+
+struct wifi_cmd_req {
+	union {
+		/* async command */
+		struct wifi_cmd_radio_control_req	radio_control;
+		struct wifi_cmd_start_req		start;
+		struct wifi_cmd_set_rx_filter_req	set_rx_filter;
+		struct wifi_cmd_add_vif_req		add_vif;
+		struct wifi_cmd_release_vif_req		release_vif;
+
+		struct wifi_cmd_vif_start_req		vif_start;
+		struct wifi_cmd_vif_stop_req		vif_stop;
+		struct wifi_cmd_vif_set_bss_params_req	vif_set_bss_params;
+		struct wifi_cmd_vif_set_short_slot_req	vif_set_short_slot;
+		struct wifi_cmd_vif_set_beacon_params_req	vif_set_beacon_params;
+		struct wifi_cmd_vif_enable_beacon_req	vif_enable_beacon;
+		struct wifi_cmd_vif_set_edca_params_req	vif_set_edca_params;
+		struct wifi_cmd_vif_add_sta_req		vif_add_sta;
+		struct wifi_cmd_vif_del_sta_req		vif_del_sta;
+		struct wifi_cmd_vif_add_key_req		vif_add_key;
+		struct wifi_cmd_vif_del_key_req		vif_del_key;
+
+		/* atomic commands */
+		struct wifi_cmd_drain_queue_sched_req	drain_queue_sched;
+		struct wifi_cmd_vif_get_dtim_count_req	vif_get_dtim_count;
+		struct wifi_cmd_vif_update_beacon_req	vif_update_beacon;
+	};
+} __packed;
+
+struct wifi_cmd_resp {
+	__le32		result;
+	union {
+		/* async commands */
+		struct wifi_cmd_api_version_resp	api_version;
+		struct wifi_cmd_fw_version_resp		fw_version;
+		struct wifi_cmd_get_mac_address_resp	get_mac_address;
+		struct wifi_cmd_get_chan_survey_resp	get_chan_survey;
+		struct wifi_cmd_add_vif_resp		add_vif;
+		struct wifi_cmd_vif_add_sta_resp	vif_add_sta;
+		struct wifi_cmd_vif_add_key_resp	vif_add_key;
+
+		/* atomic command */
+		struct wifi_cmd_vif_get_dtim_count_resp	vif_get_dtim_count;
+	};
+} __packed;
+
+#define WIFI_HDR_SIZE		(sizeof (struct wifi_cmd_hdr))
+#define WIFI_MAX_REQ_SIZE	(sizeof (struct wifi_cmd_req))
+#define WIFI_MAX_REPLY_SIZE	(sizeof (struct wifi_cmd_resp))
+#define WIFI_MAX_CMD_SIZE				\
+	(WIFI_HDR_SIZE +				\
+	((WIFI_MAX_REQ_SIZE > WIFI_MAX_REPLY_SIZE) ?	\
+	 WIFI_MAX_REQ_SIZE : WIFI_MAX_REPLY_SIZE))
+
+
+/*
+ * rx descriptors
+ */
+enum {
+	/* set if FCS is valid */
+	RXD_F_FCS_VALID		= (1 << 0),
+
+	/* set if frame was received with cck modulation */
+	RXD_F_CCK		= (1 << 1),
+
+	/* set if frame was received with short preamble */
+	RXD_F_SHORT_PREAMBLE	= (1 << 2),
+
+	/* set if frame was received using short GI */
+	RXD_F_SHORT_GI		= (1 << 3),
+
+	/* set if frame was received using HT */
+	RXD_F_HT		= (1 << 4),
+
+	/* set if frame was received inside AMPDU */
+	RXD_F_AMPDU		= (1 << 5),
+
+	/* set if frame was received using 40Mhz mod */
+	RXD_F_40MHZ		= (1 << 6),
+
+	/* set if frame was decrypted by hardware */
+	RXD_F_DECRYPTED		= (1 << 7),
+
+	/* set if firmware owns the buffer */
+	RXD_F_FW_OWNED		= (1 << 15),
+};
+
+struct wifi_rxd {
+	/* keep status at the beginning */
+	__le16		status;
+	__u8		pad[2];
+
+	__le32		buf_addr;
+
+	/* rssi per chain */
+	__s8		rssi_per_chain[4];
+
+	/* received rate, either MCS or hw index depending on HT flag
+	 * (status) */
+	__u8		rate;
+
+	/* global rssi */
+	__s8		rssi;
+
+	/* noise floor */
+	__s8		noise_floor;
+
+	/* received channel */
+	__s8		channel;
+
+	/* TSF value at rx */
+	__le32		tsf;
+
+	/* buf size must be > 128, updated by hardware */
+	__le16		buf_size;
+
+	__u8		pad2[10];
+};
+
+#ifndef __KERNEL__
+STATIC_ASSERT(sz_rxd, sizeof (struct wifi_rxd) == 32);
+#endif
+
+/*
+ * tx descriptors
+ */
+enum {
+	TXD_RF_SHORT_PRE	= (1 << 0),
+	TXD_RF_RTS_CTS		= (1 << 1),
+	TXD_RF_CTS_PROTECT	= (1 << 2),
+	TXD_RF_HT		= (1 << 3),
+	TXD_RF_SHORT_GI		= (1 << 4),
+	TXD_RF_40MHZ		= (1 << 5),
+	TXD_RF_VALID		= (1 << 7),
+};
+
+/*
+ * rate information, hardware has 4 fallback rates
+ *
+ * only first rate is used on A-MPDU
+ */
+struct wifi_txd_rinfo {
+	__u8		flags;
+	__u8		rate;
+	__u8		count:4;
+	__u8		antenna_mask:4;
+};
+
+/*
+ * status field
+ */
+enum {
+	/*
+	 * host to fw
+	 */
+
+	/* no-ack policy */
+	TXD_F_TX_NO_ACK		= (1 << 0),
+
+	/* clear STA PS filter for this frame */
+	TXD_F_TX_CLEAR_PS	= (1 << 1),
+
+	/* bypass STA PS filter for this frame */
+	TXD_F_TX_BYPASS_PS	= (1 << 2),
+
+	/* only 1 supported at MCS <= 7 (Nsts=2 && Nss=1) */
+	TXD_F_TX_STBC		= (1 << 3),
+
+	/* this is the first MPDU of an A-MPDU aggregate, all further
+	 * MPDUs to include in this aggregate must have AMPDU_MORE or
+	 * AMPDU_LAST flag, status reporting (BlockACK) will be done
+	 * only in last MPDU */
+	TXD_F_TX_AMPDU_START	= (1 << 4),
+
+	/* set on all MPDUs to include in current AMPDU besides
+	 * first & last */
+	TXD_F_TX_AMPDU_MORE	= (1 << 5),
+
+	/* set on last MPDUs to include in current AMPDU */
+	TXD_F_TX_AMPDU_LAST	= (1 << 6),
+
+	/* has to set on BAR to ensure fw will report BlockAck status,
+	 * tid field and sta are also mandatory */
+	TXD_F_TX_BAR		= (1 << 7),
+
+
+	/*
+	 * fw to host
+	 */
+
+	/* set by firmware if frame was sent successfully (unless
+	 * NO_ACK, this means that ACK or BlockACK was received) */
+	TXD_F_TX_SUCCESS	= (1 << 8),
+
+	/* set by firmware if frame was filtered because of STA ps
+	 * status, tx_success will not be set */
+	TXD_F_TX_PS_FILTERED	= (1 << 9),
+
+	/* set by firmware if frame was too big, tx success will not
+	 * be set */
+	TXD_F_TX_TOO_BIG	= (1 << 10),
+
+	/* set if firmware owns the buffer */
+	TXD_F_FW_OWNED		= (1 << 15),
+};
+
+#define WIFI_TXD_MAX_RATES	4
+
+struct wifi_txd {
+	/* keep status at beginning */
+	__le16			status;
+	__u8			pad[2];
+
+	__le32			buf_addr;
+
+	union {
+		/* filled by SW before transmit */
+		struct wifi_txd_rinfo	rinfo[WIFI_TXD_MAX_RATES];
+
+		/* filled by FW when tx is done, on last AMPDU
+		 * frame or BAR frames */
+		struct {
+			__u8		bitmap[8];
+			/* start sn only has the seqno part (12 bits) */
+			__le16		start_seq;
+		} ba;
+	};
+
+	/* filled by FW, number of total tries the hardware did */
+	__u8			tries_done:4;
+
+	/* can be 2, 3 or 4, implies corresponding header len without
+	 * QOS control field (16, 24, 30) */
+	__u8			addr_count:4;
+
+	/* offset in buf_addr where data starts (after header and qos
+	 * control if present) */
+	__u8			data_offset:7;
+	__u8			has_qos_control:1;
+
+	/* qos control field value if frame has one */
+	__le16			qos_control;
+
+	/* MSDU size (data size excluding header len) */
+	__le16			data_size;
+
+	/* index from 0 to 7 (from HT spec), only valid for first
+	 * packet of AMPDU */
+	__le16			ampdu_density:4;
+
+	/* host side current BA window start, needs to be filled when
+	 * sending an AMPDU, for the first packet */
+	__le16			ampdu_baw_ssn:12;
+
+	/*
+	 * VIF and STA (can be WIFI_INVALID_STA/VIF_HWID for none)
+	 *
+	 * needed by firmware to apply correct powersave policy for
+	 * the station, no PS update will be done if not set
+	 *
+	 * set neither of them for raw frame injection
+	 * set only vif_hwid for broadcast/multicast frames
+	 */
+	__le16			vif_hwid;
+	__le16			sta_hwid;
+
+	/*
+	 * CCMP PN, only used if key hwid if valid
+	 */
+	__u8			ccmp_pn[8];
+
+	/*
+	 * Key hwid (or WIFI_INVALID_KEY_HWID)
+	 *
+	 * if sta_hwid is set, this is a sta key index, otherwise it's
+	 * a vif key index (so vif_hwid has to bet set)
+	 */
+	__u8			key_hwid;
+
+	/*
+	 * TID must be set on last packet of AMDPU and on BAR frames
+	 * (in addition to the TXD_F_BAR)
+	 */
+	__u8			tid;
+
+	__u8			pad2[22];
+};
+
+#ifndef __KERNEL__
+STATIC_ASSERT(sz_txd, sizeof (struct wifi_txd) == 64);
+#endif
+
+struct ixzone_svc_wifi_cmd_chan {
+	__le32		buf_offset;
+	__le32		buf_size;
+	__le32		host_ctr;
+	__le32		fw_ctr;
+	__le32		h2f_irq_mask;
+	__le32		f2h_irq_mask;
+} __packed;
+
+struct ixzone_svc_wifi {
+	struct ixzone_svc_wifi_cmd_chan cmd_chans[WIFI_CMD_CHAN_LAST];
+
+	struct {
+		__le32	chain_count;
+	} radio;
+
+	struct {
+		__le32	f2h_irq_mask;
+	} rx;
+
+	struct {
+		__le32	f2h_irq_mask;
+		__le32	h2f_irq_mask;
+		__le16	txq_count;
+		__le16	max_ampdu_chain;
+	} tx;
+
+	struct {
+		__u8	max_sta_vif;
+		__u8	max_ap_vif;
+		__le16	bcn_interval_gcd;
+		__le32	tbtt_f2h_irq_mask;
+	} vif;
+
+} __packed;
+
+#ifndef __KERNEL__
+STATIC_ASSERT(sz_wifi, (sizeof (struct ixzone_svc_wifi) % 4) == 0);
+#endif
+
+#endif /* HOSTIF_WIFI_H_ */
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./main.c linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/main.c
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./main.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/main.c	2021-03-04 13:20:59.424172295 +0100
@@ -0,0 +1,648 @@
+#include <linux/init.h>
+#include <linux/kernel.h>
+
+#include "mwl8k_priv.h"
+
+static const struct dbg_svc_ops *dbg_services_ops[8];
+static size_t dbg_services_ops_count;
+
+/*
+ *
+ */
+static u32 dbg_services_process(struct mwl8k_priv *priv,
+				bool sync,
+				u32 mask)
+{
+	struct dbg_svc_priv *dsp;
+	struct list_head *head;
+	u32 remain = 0;
+
+	head = sync ? &priv->dbg_sync_services : &priv->dbg_services;
+	list_for_each_entry(dsp, head, next) {
+		u32 svc_mask;
+
+		if (unlikely(!dsp->ops->svc_process))
+			continue;
+
+		svc_mask = dsp->poll_mask & mask;
+		if (svc_mask)
+			remain |= dsp->ops->svc_process(dsp->svc_priv,
+							svc_mask);
+	}
+	return remain;
+}
+
+/*
+ *
+ */
+static u32 dbg_services_process_synch(struct mwl8k_priv *priv, u32 mask)
+{
+	return dbg_services_process(priv, true, mask);
+}
+
+/*
+ *
+ */
+static u32 dbg_services_process_normal(struct mwl8k_priv *priv,
+					 u32 mask)
+{
+	return dbg_services_process(priv, false, mask);
+}
+
+/*
+ *
+ */
+static void dbg_services_exit(struct list_head *head)
+{
+	struct dbg_svc_priv *dsp, *tmp;
+
+	list_for_each_entry_safe(dsp, tmp, head, next) {
+		if (!dsp->ops->svc_exit)
+			continue;
+		dsp->ops->svc_exit(dsp->svc_priv);
+	}
+}
+
+/*
+ *
+ */
+static void dbg_services_exit_all(struct mwl8k_priv *priv)
+{
+	dbg_services_exit(&priv->dbg_services);
+	dbg_services_exit(&priv->dbg_sync_services);
+}
+
+/*
+ *
+ */
+static void dbg_services_free(struct list_head *head)
+{
+	struct dbg_svc_priv *dsp, *tmp;
+
+	list_for_each_entry_safe(dsp, tmp, head, next) {
+		dsp->ops->svc_free(dsp->svc_priv);
+		kfree(dsp);
+	}
+}
+
+/*
+ *
+ */
+static void dbg_services_free_all(struct mwl8k_priv *priv)
+{
+	dbg_services_free(&priv->dbg_services);
+	dbg_services_free(&priv->dbg_sync_services);
+}
+
+/*
+ *
+ */
+static int dbg_services_add(struct mwl8k_priv *priv,
+			    u32 uuid,
+			    u16 flags,
+			    u32 poll_mask,
+			    const struct dbg_svc_ops *ops,
+			    void *svc_priv)
+{
+	struct dbg_svc_priv *dsp;
+	struct list_head *head;
+
+	dsp = kzalloc(sizeof (*dsp), GFP_KERNEL);
+	if (!dsp)
+		return -ENOMEM;
+
+	if (flags & BOOTAREA_SVC_FLAG_SYNCH) {
+		head = &priv->dbg_sync_services;
+		priv->dbg_sync_services_poll_mask |= poll_mask;
+	} else {
+		head = &priv->dbg_services;
+		priv->dbg_services_poll_mask |= poll_mask;
+	}
+
+	dsp->ops = ops;
+	dsp->poll_mask = poll_mask;
+	dsp->svc_uuid = uuid;
+	dsp->svc_priv = svc_priv;
+	list_add_tail(&dsp->next, head);
+	return 0;
+}
+
+/*
+ * Host work handling
+ */
+static void mwl8k_poll(unsigned long data)
+{
+	struct mwl8k_priv *priv = (struct mwl8k_priv *)data;
+	unsigned long flags;
+	u32 status, normal_status, sync_status, remain = 0;
+
+	/* don't rearm tasklet if we are stopping */
+	if (priv->poll_stop)
+		return;
+
+	/*
+	 * "dequeue" work to todo
+	 */
+	spin_lock_irqsave(&priv->poll_lock, flags);
+	normal_status = priv->poll_todo;
+	priv->poll_todo = 0;
+	spin_unlock_irqrestore(&priv->poll_lock, flags);
+
+	if (normal_status)
+		remain = dbg_services_process_normal(priv, normal_status);
+
+	/*
+	 * check for additionnal work
+	 */
+	spin_lock_irqsave(&priv->poll_lock, flags);
+	status = ioread32(priv->regs + MWL8K_HIU_A2H_INTERRUPT_STATUS);
+
+	/* because of read side effect, if we dequeue some sync
+	 * services interrupt, we have to process them and make sure
+	 * they are unmasked */
+	sync_status = status & priv->dbg_sync_services_poll_mask;
+	if (unlikely(sync_status)) {
+		spin_lock(&priv->dbg_sync_services_lock);
+		dbg_services_process_synch(priv, sync_status);
+		spin_unlock(&priv->dbg_sync_services_lock);
+		iowrite32(~sync_status, priv->regs +
+			  MWL8K_HIU_A2H_INTERRUPT_STATUS);
+	}
+
+	normal_status = status & priv->dbg_services_poll_mask;
+	priv->poll_todo |= normal_status | remain;
+
+	if (priv->poll_todo) {
+		/* printk(KERN_DEBUG "poll: todo: %08x\n", priv->poll_todo); */
+		tasklet_schedule(&priv->poll_task);
+	} else {
+		/* ack all possible interrupts, will reset the hidden
+		 * internal IRQ mask */
+		/* printk(KERN_DEBUG "poll: no-todo\n"); */
+		iowrite32(~priv->poll_mask, priv->regs +
+			  MWL8K_HIU_A2H_INTERRUPT_STATUS);
+		/* printk(KERN_DEBUG "poll: out\n"); */
+
+		/* unmask all IRQ */
+		iowrite32(priv->poll_mask,
+			  priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
+	}
+	spin_unlock_irqrestore(&priv->poll_lock, flags);
+}
+
+/*
+ * Interrupt handling.
+ */
+static irqreturn_t mwl8k_interrupt(int irq, void *dev_id)
+{
+	struct mwl8k_priv *priv = dev_id;
+	u32 status, normal_status, sync_status;
+
+	status = ioread32(priv->regs + MWL8K_HIU_A2H_INTERRUPT_STATUS);
+	if (!status)
+		return IRQ_NONE;
+
+	status &= priv->poll_mask;
+	if (!status)
+		return IRQ_HANDLED;
+
+	sync_status = status & priv->dbg_sync_services_poll_mask;
+	if (unlikely(sync_status)) {
+		spin_lock(&priv->dbg_sync_services_lock);
+		dbg_services_process_synch(priv, sync_status);
+		spin_unlock(&priv->dbg_sync_services_lock);
+
+		/* ack interrupt for sync services otherwise they are
+		 * internaly masked */
+		iowrite32(~sync_status, priv->regs +
+			  MWL8K_HIU_A2H_INTERRUPT_STATUS);
+	}
+
+	normal_status = status & priv->dbg_services_poll_mask;
+	if (likely(normal_status)) {
+		spin_lock(&priv->poll_lock);
+		priv->poll_todo |= normal_status;
+		spin_unlock(&priv->poll_lock);
+		tasklet_schedule(&priv->poll_task);
+
+		/* mask any further host interrupts for non sync
+		 * services */
+		iowrite32(priv->dbg_sync_services_poll_mask,
+			  priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
+
+		/* this write seems posted and we can re-enter IRQ
+		 * even after clearing mask, so make sure it's
+		 * actually disabled */
+		(void)ioread32(priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
+	}
+
+	return IRQ_HANDLED;
+}
+
+/*
+ *
+ */
+static int init_svc(struct mwl8k_priv *priv,
+		    struct __iomem bootarea_svc *svc)
+{
+	const struct dbg_svc_ops *ops;
+	u32 uuid = le32_to_cpu(svc->svc_uuid);
+	u32 flags = le32_to_cpu(svc->svc_flags);
+	u32 off = le32_to_cpu(svc->off);
+	u32 poll_mask;
+	void __iomem *vdesc;
+	void *data;
+	int ret;
+	size_t i;
+
+	ops = NULL;
+	for (i = 0; i < dbg_services_ops_count; i++) {
+		const struct dbg_svc_ops *tops = dbg_services_ops[i];
+
+		if (tops->uuid == uuid) {
+			ops = tops;
+			break;
+		}
+	}
+
+	if (!ops) {
+		dev_dbg(&priv->pdev->dev,
+			"unsupported service uuid %x\n", uuid);
+		return 0;
+	}
+
+	if (check_bound(SRAM_SIZE, off, ops->desc_size)) {
+		dev_err(&priv->pdev->dev,
+			"dbg node %s has bad offsets: %x\n",
+			ops->name, off);
+		return 0;
+	}
+
+	vdesc = priv->sram + off;
+	data = ops->svc_alloc(priv, vdesc, &poll_mask);
+	if (!data)
+		return -ENOMEM;
+
+	ret = dbg_services_add(priv, uuid, flags, poll_mask, ops, data);
+	if (ret) {
+		ops->svc_free(data);
+		return ret;
+	}
+
+	priv->poll_mask |= poll_mask;
+	dev_info(&priv->pdev->dev, "%s service detected\n", ops->name);
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int mwl8k_init(struct mwl8k_priv *priv)
+{
+	struct __iomem bootarea_root *root;
+	struct __iomem bootarea_svc *svc;
+	unsigned long timeout;
+	u32 i, early_svc_count, svc_count;
+	bool booted;
+	int ret;
+
+	/*
+	 * wait for magic data to appear in sram
+	 */
+	msleep(1);
+
+	booted = false;
+	root = (struct __iomem bootarea_root *)priv->sram;
+	for (i = 0; i < 100; i++) {
+		u32 magic = le32_to_cpu(ioread32(&root->magic));
+
+		if (magic == BOOTAREA_MAGIC) {
+			booted = true;
+			break;
+		}
+
+		msleep(1);
+	}
+
+	if (!booted) {
+		dev_err(&priv->pdev->dev,
+			"firmware did not boot\n");
+		return -EIO;
+	}
+
+	/*
+	 * parse bootarea, register early debug services
+	 */
+	early_svc_count = root->early_svc_count;
+	for (i = 0; i < early_svc_count; i++) {
+		svc = (struct __iomem bootarea_svc *)(root + 1) + i;
+
+		ret = init_svc(priv, svc);
+		if (ret)
+			return ret;
+	}
+
+	/* wait for boot to finish */
+	timeout = jiffies + HZ * 5;
+	booted = false;
+
+	while (jiffies < timeout) {
+		if (ioread8(&root->boot_done)) {
+			booted = true;
+			break;
+		}
+
+		/* process synchronous services in case firmware spins
+		 * on it */
+		dbg_services_process_synch(priv, ~0);
+		cpu_relax();
+
+		if (need_resched())
+			yield();
+	}
+
+	if (!booted) {
+		dev_err(&priv->pdev->dev,
+			"firmware did not complete boot\n");
+		return -EIO;
+	}
+
+	svc_count = le32_to_cpu(root->svc_count);
+	for (i = early_svc_count; i < early_svc_count + svc_count; i++) {
+		svc = (struct __iomem bootarea_svc *)(root + 1) + i;
+
+		ret = init_svc(priv, svc);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int mwl8k_init_post(struct mwl8k_priv *priv)
+{
+	struct dbg_svc_priv *dsp;
+	int ret = 0;
+
+	list_for_each_entry(dsp, &priv->dbg_sync_services, next) {
+		if (!dsp->ops->svc_init)
+			continue;
+
+		ret = dsp->ops->svc_init(dsp->svc_priv);
+		if (ret)
+			break;
+	}
+
+	list_for_each_entry(dsp, &priv->dbg_services, next) {
+		if (!dsp->ops->svc_init)
+			continue;
+
+		ret = dsp->ops->svc_init(dsp->svc_priv);
+		if (ret)
+			break;
+	}
+
+	return ret;
+}
+
+/*
+ *
+ */
+static void mwl8k_release(struct mwl8k_priv *priv)
+{
+	dbg_services_free_all(priv);
+	mwl8k_fw_release(priv);
+	mwl8k_debugfs_dev_remove(priv);
+}
+
+enum {
+	MWL8366 = 0,
+	MWL8764,
+};
+
+static const struct mwl8k_device_info mwl8k_info_tbl[] = {
+	[MWL8366] = {
+		.part_name	= "88w8366",
+		.helper_image	= "mwl8k_new/helper_8366.fw",
+		.fw_image	= "mwl8k_new/8366.fw",
+		.dma_mask	= DMA_BIT_MASK(31),
+	},
+	[MWL8764] = {
+		.part_name	= "88w8764",
+		.fw_image	= "mwl8k_new/8764.fw",
+		.dma_mask	= DMA_BIT_MASK(32),
+	},
+};
+
+/*
+ * PCI probe function
+ */
+static int mwl8k_probe(struct pci_dev *pdev,
+		       const struct pci_device_id *id)
+{
+	struct mwl8k_priv *priv;
+	int rc;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	INIT_LIST_HEAD(&priv->dbg_services);
+	INIT_LIST_HEAD(&priv->dbg_sync_services);
+	spin_lock_init(&priv->dbg_sync_services_lock);
+	tasklet_init(&priv->poll_task, mwl8k_poll, (unsigned long)priv);
+	spin_lock_init(&priv->poll_lock);
+
+	rc = pcim_enable_device(pdev);
+	if (rc) {
+		dev_err(&pdev->dev,
+			"Cannot enable new PCI device\n");
+		return rc;
+	}
+
+	rc = pcim_iomap_regions(pdev, 0x5, MWL8K_NAME);
+	if (rc) {
+		dev_err(&pdev->dev,
+			"cannot obtain PCI resources\n");
+		return rc;
+	}
+
+	pci_set_master(pdev);
+	pci_set_drvdata(pdev, priv);
+	priv->pdev = pdev;
+	priv->info = &mwl8k_info_tbl[id->driver_data];
+	priv->sram = pcim_iomap_table(pdev)[0];
+	priv->regs = pcim_iomap_table(pdev)[2];
+
+	rc = pci_set_consistent_dma_mask(pdev, priv->info->dma_mask);
+	if (rc) {
+		dev_err(&pdev->dev, "failed to set consistent dma mask\n");
+		return rc;
+	}
+
+	rc = pci_set_dma_mask(pdev, priv->info->dma_mask);
+	if (rc) {
+		dev_err(&pdev->dev, "failed to set dma mask\n");
+		return rc;
+	}
+
+	rc = mwl8k_fw_request(priv);
+	if (rc)
+		return rc;
+
+	/* switch interrupt mode to clear on read */
+	iowrite32(0xffffffff, priv->regs + MWL8K_HIU_A2H_INTERRUPT_CLEAR_SEL);
+	/* clear all interrupts & reset internal mask */
+	(void)ioread32(priv->regs + MWL8K_HIU_A2H_INTERRUPT_STATUS);
+	iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_STATUS);
+
+	/* don't use interrupt event mask, make it passthrough */
+	iowrite32(0xffffffff,
+		  priv->regs + MWL8K_HIU_A2H_INTERRUPT_STATUS_MASK);
+
+	/* mask all IRQ for now */
+	iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
+
+	/* Load firmware into hardware */
+	rc = mwl8k_fw_upload(priv);
+	if (rc)
+		goto err_release;
+
+	rc = mwl8k_init(priv);
+	if (rc) {
+		dev_err(&pdev->dev,
+			"failed to init chip\n");
+		goto err_release;
+	}
+
+	rc = request_irq(priv->pdev->irq, mwl8k_interrupt,
+			 IRQF_SHARED, MWL8K_NAME, priv);
+	if (rc) {
+		dev_err(&pdev->dev,
+			"failed to register IRQ handler\n");
+		goto err_release;
+	}
+
+	/* unmask IRQ */
+	iowrite32(priv->poll_mask, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
+
+	rc = mwl8k_init_post(priv);
+	if (rc) {
+		dev_err(&pdev->dev, "post init failed\n");
+		goto err_irq;
+	}
+
+#ifdef CONFIG_DEBUG_FS
+	mwl8k_debugfs_dev_init(priv);
+#endif
+	return 0;
+
+err_irq:
+	dbg_services_exit_all(priv);
+	free_irq(pdev->irq, priv);
+
+err_release:
+	mwl8k_release(priv);
+
+	return rc;
+}
+
+static void mwl8k_remove(struct pci_dev *pdev)
+{
+	struct mwl8k_priv *priv = pci_get_drvdata(pdev);
+
+#ifdef CONFIG_DEBUG_FS
+	mwl8k_debugfs_dev_remove(priv);
+#endif
+
+	dbg_services_exit_all(priv);
+
+	/* disable IRQ & kill tasklet */
+	iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
+	priv->poll_stop = 1;
+	tasklet_kill(&priv->poll_task);
+
+	mwl8k_release(priv);
+	free_irq(pdev->irq, priv);
+}
+
+MODULE_FIRMWARE("mwl8k/helper_8366.fw");
+MODULE_FIRMWARE("mwl8k/8366.fw");
+MODULE_FIRMWARE("mwl8k/8764.fw");
+
+static const struct pci_device_id mwl8k_pci_id_table[] = {
+	{ PCI_VDEVICE(MARVELL, 0x2a40), .driver_data = MWL8366, },
+	{ PCI_VDEVICE(MARVELL, 0x2a41), .driver_data = MWL8366, },
+	{ PCI_VDEVICE(MARVELL, 0x2a42), .driver_data = MWL8366, },
+	{ PCI_VDEVICE(MARVELL, 0x2a43), .driver_data = MWL8366, },
+	{ PCI_VDEVICE(MARVELL, 0x2b36), .driver_data = MWL8764, },
+	{ },
+};
+
+MODULE_DEVICE_TABLE(pci, mwl8k_pci_id_table);
+
+static struct pci_driver mwl8k_new_driver = {
+	.name		= MWL8K_NAME,
+	.id_table	= mwl8k_pci_id_table,
+	.probe		= mwl8k_probe,
+	.remove		= mwl8k_remove,
+};
+
+/*
+ *
+ */
+static void __init register_dbg_service_ops(const struct dbg_svc_ops *ops)
+{
+	if (WARN_ON(dbg_services_ops_count >= ARRAY_SIZE(dbg_services_ops)))
+		return;
+	dbg_services_ops[dbg_services_ops_count] = ops;
+	dbg_services_ops_count++;
+	if (ops->init)
+		ops->init();
+}
+
+/*
+ *
+ */
+static int __init mwl8k_new_init(void)
+{
+#ifdef CONFIG_DEBUG_FS
+	mwl8k_debugfs_init();
+#endif
+	register_dbg_service_ops(&console_dbg_svc_ops);
+	register_dbg_service_ops(&vtty_dbg_svc_ops);
+	register_dbg_service_ops(&dma_test_dbg_svc_ops);
+	register_dbg_service_ops(&wifi_svc_ops);
+
+	return pci_register_driver(&mwl8k_new_driver);
+}
+
+/*
+ *
+ */
+static void __exit mwl8k_new_exit(void)
+{
+	size_t i;
+
+	pci_unregister_driver(&mwl8k_new_driver);
+#ifdef CONFIG_DEBUG_FS
+	mwl8k_debugfs_remove();
+#endif
+	for (i = 0; i < dbg_services_ops_count; i++) {
+		const struct dbg_svc_ops *ops = dbg_services_ops[i];
+		if (ops->exit)
+			ops->exit();
+	}
+}
+
+module_init(mwl8k_new_init);
+module_exit(mwl8k_new_exit);
+
+MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
+MODULE_DESCRIPTION("Marvel mwl8k new driver");
+MODULE_VERSION("1.0");
+MODULE_LICENSE("GPL");
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./Makefile linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/Makefile
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/Makefile	2021-03-04 13:20:59.424172295 +0100
@@ -0,0 +1,12 @@
+mwl8k_new-$(CONFIG_DEBUG_FS) += debugfs.o
+mwl8k_new-y += fw.o
+mwl8k_new-y += main.o
+mwl8k_new-y += utils.o
+
+mwl8k_new-y += svc_console.o
+mwl8k_new-y += svc_dma_test.o
+mwl8k_new-y += svc_vtty.o
+
+mwl8k_new-y += wifi_core.o
+
+obj-$(CONFIG_MWL8K_NEW)	+= mwl8k_new.o
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./mwl8k_priv.h linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/mwl8k_priv.h
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./mwl8k_priv.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/mwl8k_priv.h	2021-03-04 13:20:59.424172295 +0100
@@ -0,0 +1,199 @@
+#ifndef MWL8K_PRIV_H_
+#define MWL8K_PRIV_H_
+
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/spinlock.h>
+#include <linux/list.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <linux/completion.h>
+#include <linux/etherdevice.h>
+#include <linux/slab.h>
+#include <net/mac80211.h>
+#include <linux/moduleparam.h>
+#include <linux/firmware.h>
+#include <linux/workqueue.h>
+#include <linux/crc32.h>
+
+#include "hostif.h"
+
+#define MWL8K_NAME	"mwl8k_new"
+#define MWL8K_PFX	MWL8K_NAME ": "
+
+/*
+ * registers
+ */
+
+/* Host->device communications */
+#define MWL8K_HIU_H2A_INTERRUPT_EVENTS		0x00000c18
+#define MWL8K_HIU_H2A_INTERRUPT_STATUS		0x00000c1c
+#define MWL8K_HIU_H2A_INTERRUPT_MASK		0x00000c20
+#define MWL8K_HIU_H2A_INTERRUPT_CLEAR_SEL	0x00000c24
+#define MWL8K_HIU_H2A_INTERRUPT_STATUS_MASK	0x00000c28
+
+/* Device->host communications */
+#define MWL8K_HIU_A2H_INTERRUPT_EVENTS		0x00000c2c
+#define MWL8K_HIU_A2H_INTERRUPT_STATUS		0x00000c30
+#define MWL8K_HIU_A2H_INTERRUPT_MASK		0x00000c34
+#define MWL8K_HIU_A2H_INTERRUPT_CLEAR_SEL	0x00000c38
+#define MWL8K_HIU_A2H_INTERRUPT_STATUS_MASK	0x00000c3c
+
+#define SRAM_SIZE			(64 * 1024)
+
+/*
+ *
+ */
+struct mwl8k_ring_buf {
+	u8 __iomem		*start;
+	u32			size;
+	u32 __iomem		*fw_ptr;
+	u32 __iomem		*host_ptr;
+	u32			host_off;
+};
+
+/*
+ *
+ */
+struct mwl8k_priv;
+
+struct dbg_svc_ops {
+	const char	*name;
+	u32		uuid;
+	size_t		desc_size;
+	void		*(*svc_alloc)(struct mwl8k_priv *priv,
+				      void __iomem *vdesc,
+				      u32 *poll_mask);
+	int		(*svc_init)(void *data);
+	u32		(*svc_process)(void *data, u32 irq_status);
+	void		(*svc_exit)(void *data);
+	void		(*svc_free)(void *data);
+
+	void		(*init)(void);
+	void		(*exit)(void);
+};
+
+/*
+ *
+ */
+struct dbg_svc_priv {
+	u32			svc_uuid;
+	void			*svc_priv;
+	u32			poll_mask;
+	const struct dbg_svc_ops	*ops;
+	struct list_head	next;
+};
+
+/*
+ *
+ */
+struct mwl8k_device_info {
+	const char *part_name;
+	const char *helper_image;
+	const char *fw_image;
+	u64 dma_mask;
+};
+
+/*
+ * main per-device private data
+ */
+struct mwl8k_priv {
+	struct ieee80211_hw	*hw;
+	struct pci_dev		*pdev;
+
+	void __iomem		*sram;
+	void __iomem		*regs;
+
+	const struct mwl8k_device_info *info;
+	const struct firmware	*fw_helper;
+	const struct firmware	*fw_ucode;
+
+	spinlock_t		poll_lock;
+	bool			poll_stop;
+	u32			poll_todo;
+	u32			poll_mask;
+	struct tasklet_struct	poll_task;
+
+	spinlock_t		dbg_sync_services_lock;
+	u32			dbg_sync_services_poll_mask;
+	u32			dbg_services_poll_mask;
+	struct list_head	dbg_sync_services;
+	struct list_head	dbg_services;
+
+	unsigned int		vtty_count;
+
+#ifdef CONFIG_DEBUG_FS
+	struct dentry		*dbg_regs;
+	struct dentry		*dbg_sram;
+	struct dentry		*dbg_test;
+	struct debugfs_blob_wrapper blob_regs, blob_sram;
+#endif
+};
+
+/*
+ *
+ */
+static inline int check_bound(u32 bsize, u32 off, u32 size)
+{
+	if (off >= bsize)
+		return 1;
+
+	if (off + size < off)
+		return 1;
+
+	if (off + size >= bsize)
+		return 1;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static inline void mwl8k_raise_fw_irq(struct mwl8k_priv *priv, u32 mask)
+{
+	iowrite32(mask, priv->regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS);
+}
+
+/*
+ * debugfs.c
+ */
+void mwl8k_debugfs_dev_init(struct mwl8k_priv *priv);
+void mwl8k_debugfs_dev_remove(struct mwl8k_priv *priv);
+void mwl8k_debugfs_init(void);
+void mwl8k_debugfs_remove(void);
+
+/*
+ * fw.c
+ */
+int mwl8k_fw_upload(struct mwl8k_priv *priv);
+int mwl8k_fw_request(struct mwl8k_priv *priv);
+void mwl8k_fw_release(struct mwl8k_priv *priv);
+
+/*
+ * utils.c
+ */
+void memcpy_fromio_iovec(u8 *kdata, struct iovec *iov, int len);
+
+size_t rb_gen_iov(struct mwl8k_ring_buf *rb,
+		  struct iovec iov[2],
+		  u32 fw_off,
+		  u32 max_size);
+
+int rb_init(const char *name,
+	    unsigned int off,
+	    struct  __iomem ixzone_ring_buf *rb_io,
+	    struct mwl8k_ring_buf *rb,
+	    bool host_is_consumer);
+
+/*
+ * debug services
+ */
+extern const struct dbg_svc_ops console_dbg_svc_ops;
+extern const struct dbg_svc_ops vtty_dbg_svc_ops;
+extern const struct dbg_svc_ops dma_test_dbg_svc_ops;
+extern const struct dbg_svc_ops wifi_svc_ops;
+
+#endif
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./svc_console.c linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/svc_console.c
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./svc_console.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/svc_console.c	2021-03-04 13:20:59.424172295 +0100
@@ -0,0 +1,151 @@
+#include "mwl8k_priv.h"
+#include "hostif.h"
+
+struct mwl8k_console_priv {
+	char			line_buf[256];
+	size_t			char_count;
+	struct mwl8k_ring_buf	rb;
+	u32			irq_mask;
+	bool			enabled;
+	struct mwl8k_priv	*priv;
+};
+
+/*
+ *
+ */
+static void console_print_lines(struct mwl8k_console_priv *cp)
+{
+	size_t i, start;
+
+	for (start = i = 0; i < cp->char_count; i++) {
+		if (cp->line_buf[i] != '\n')
+			continue;
+
+		/* end of line */
+		if (i - start) {
+			dev_info(&cp->priv->pdev->dev,
+				 "fw: %.*s\n",
+				 (int)(i - start),
+				 cp->line_buf + start);
+		}
+
+		start = i + 1;
+	}
+
+	if (start < cp->char_count)
+		memmove(cp->line_buf,
+			cp->line_buf + start,
+			cp->char_count - start);
+
+	cp->char_count -= start;
+}
+
+/*
+ *
+ */
+static void console_read_data(struct mwl8k_console_priv *cp)
+{
+	struct mwl8k_ring_buf *rb = &cp->rb;
+	u32 fw_off;
+
+	if (!cp->enabled)
+		return;
+
+	fw_off = le32_to_cpu(ioread32(rb->fw_ptr));
+	if (fw_off >= rb->size) {
+		dev_err(&cp->priv->pdev->dev,
+			"console fw off OOB: %08x\n", fw_off);
+		/* hard firmware crash, panic to get log */
+//		panic("mwl8k firmware crashed");
+		cp->enabled = false;
+		return;
+	}
+
+	do {
+		struct iovec iov[2];
+		size_t local_remain;
+		size_t len;
+
+		local_remain = sizeof (cp->line_buf) - cp->char_count;
+		if (!local_remain) {
+			cp->char_count = 0;
+			local_remain = sizeof (cp->line_buf);
+		}
+
+		len = rb_gen_iov(rb, iov, fw_off, local_remain);
+		if (!len)
+			break;
+
+		memcpy_fromio_iovec(cp->line_buf + cp->char_count, iov, len);
+		cp->char_count += len;
+
+		rb->host_off += len;
+		if (rb->host_off >= rb->size)
+			rb->host_off -= rb->size;
+
+		console_print_lines(cp);
+
+	} while (rb->host_off != fw_off);
+
+	iowrite32(rb->host_off, rb->host_ptr);
+}
+
+/*
+ *
+ */
+static u32 console_process(void *data, u32 irq_status)
+{
+	struct mwl8k_console_priv *cp = (struct mwl8k_console_priv *)data;
+	console_read_data(cp);
+	return 0;
+}
+
+/*
+ *
+ */
+static void *console_alloc(struct mwl8k_priv *priv, void __iomem *vdesc,
+			   u32 *poll_mask)
+{
+	struct __iomem ixzone_svc_console *desc = vdesc;
+	struct mwl8k_console_priv *cp;
+	unsigned int off;
+
+	if (!desc->irq_mask) {
+		dev_err(&priv->pdev->dev,
+			"console has no irq mask\n");
+		return NULL;
+	}
+
+	cp = kzalloc(sizeof (*cp), GFP_KERNEL);
+	if (!cp)
+		return NULL;
+
+	off = (void *)&desc->rb - (void *)priv->sram;
+	if (rb_init("console", off, &desc->rb, &cp->rb, true)) {
+		kfree(cp);
+		return NULL;
+	}
+
+	*poll_mask = le32_to_cpu(desc->irq_mask);
+	cp->priv = priv;
+	cp->enabled = true;
+	return cp;
+}
+
+/*
+ *
+ */
+static void console_free(void *data)
+{
+	struct mwl8k_console_priv *cp = (struct mwl8k_console_priv *)data;
+	kfree(cp);
+}
+
+const struct dbg_svc_ops console_dbg_svc_ops = {
+	.name		= "console",
+	.uuid		= SVC_CONSOLE_UUID,
+	.desc_size	= sizeof (struct ixzone_svc_console),
+	.svc_alloc	= console_alloc,
+	.svc_process	= console_process,
+	.svc_free	= console_free,
+};
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./svc_dma_test.c linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/svc_dma_test.c
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./svc_dma_test.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/svc_dma_test.c	2021-03-04 13:20:59.424172295 +0100
@@ -0,0 +1,72 @@
+#include "mwl8k_priv.h"
+#include "hostif_dmatest.h"
+
+struct dma_test_priv {
+	uint8_t			*area;
+	unsigned int		area_size;
+	dma_addr_t		area_dma;
+	struct mwl8k_priv	*priv;
+};
+
+/*
+ *
+ */
+static u32 dma_test_process(void *data, u32 irq_status)
+{
+	return 0;
+}
+
+/*
+ *
+ */
+static void *
+dma_test_alloc(struct mwl8k_priv *priv, void __iomem *vdesc,
+	       u32 *poll_mask)
+{
+	struct __iomem ixzone_svc_dma_test *desc = vdesc;
+	struct dma_test_priv *ds;
+	unsigned int i;
+
+	ds = kzalloc(sizeof (*ds), GFP_KERNEL);
+	if (!ds)
+		return NULL;
+
+	ds->area_size = le32_to_cpu(ioread32(&desc->test.fw_req_size));
+	ds->area = pci_alloc_consistent(priv->pdev, ds->area_size,
+					&ds->area_dma);
+	if (!ds->area) {
+		dev_err(&priv->pdev->dev,
+			"failed to alloc DMA server %u bytes\n",
+			ds->area_size);
+		kfree(ds);
+		return NULL;
+	}
+
+	for (i = 0; i < ds->area_size; i++)
+		ds->area[i] = i;
+
+	ds->priv = priv;
+	iowrite32(cpu_to_le32(ds->area_dma), &desc->test.host_dma_address);
+
+	return ds;
+}
+
+/*
+ *
+ */
+static void dma_test_free(void *data)
+{
+	struct dma_test_priv *ds = (struct dma_test_priv *)data;
+	pci_free_consistent(ds->priv->pdev, ds->area_size,
+			    ds->area, ds->area_dma);
+	kfree(ds);
+}
+
+const struct dbg_svc_ops dma_test_dbg_svc_ops = {
+	.name		= "dma_test",
+	.uuid		= SVC_DMATEST_UUID,
+	.desc_size	= sizeof (struct ixzone_svc_dma_test),
+	.svc_alloc	= dma_test_alloc,
+	.svc_process	= dma_test_process,
+	.svc_free	= dma_test_free,
+};
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./svc_vtty.c linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/svc_vtty.c
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./svc_vtty.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/svc_vtty.c	2021-03-04 13:20:59.424172295 +0100
@@ -0,0 +1,496 @@
+#include <linux/serial.h>
+#include <linux/serial_core.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+
+#include "mwl8k_priv.h"
+#include "hostif.h"
+
+struct mwl8k_vtty_priv {
+	/* rx from firmware */
+	struct mwl8k_ring_buf	f2h_rb;
+	u32			f2h_irq_mask;
+
+	/* tx to firmware */
+	struct mwl8k_ring_buf	h2f_rb;
+	u32			h2f_irq_mask;
+
+	/* uart emulation */
+	struct uart_port	port;
+	bool			uart_started;
+	struct tasklet_struct	tx_task;
+
+	bool			enabled;
+	struct mwl8k_priv	*priv;
+};
+
+/*
+ *
+ */
+static struct uart_driver mwl8k_vtty_driver = {
+	.owner		= THIS_MODULE,
+	.driver_name	= "mwl8k_vtty",
+	.dev_name	= "mwl8k_vtty",
+	/* experimental major number */
+	.major		= 240,
+	.minor		= 0,
+	.nr		= 4,
+};
+
+/*
+ *
+ */
+static inline struct mwl8k_vtty_priv *to_vtty(struct uart_port *port)
+{
+	return container_of(port, struct mwl8k_vtty_priv, port);
+}
+
+/*
+ * serial core request to check if uart tx fifo is empty
+ */
+static unsigned int vtty_uart_tx_empty(struct uart_port *port)
+{
+	struct mwl8k_vtty_priv *vp = to_vtty(port);
+	struct mwl8k_ring_buf *rb = &vp->h2f_rb;
+	u32 fw_off;
+
+	printk("%s\n", __FUNCTION__);
+	fw_off = le32_to_cpu(ioread32(rb->fw_ptr));
+	if (fw_off == rb->host_off)
+		return 1;
+	return 0;
+}
+
+/*
+ * serial core request to return RI, CTS, DCD and DSR pin state
+ */
+static unsigned int vtty_uart_get_mctrl(struct uart_port *port)
+{
+	/* printk("%s\n", __FUNCTION__); */
+	return TIOCM_CTS | TIOCM_CD;
+}
+
+/*
+ * serial core request to set RTS and DTR pin state and loopback mode
+ */
+static void vtty_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+	/* struct mwl8k_vtty_priv *vp = to_vtty(port); */
+	/* printk("%s\n", __FUNCTION__); */
+}
+
+/*
+ * serial core request to start tx ASAP (used for flow control)
+ */
+static void vtty_uart_stop_tx(struct uart_port *port)
+{
+	/* printk("%s\n", __FUNCTION__); */
+}
+
+/*
+ * serial core request to (re)enable tx
+ */
+static void vtty_uart_start_tx(struct uart_port *port)
+{
+	struct mwl8k_vtty_priv *vp = to_vtty(port);
+	/* printk("%s\n", __FUNCTION__); */
+	tasklet_schedule(&vp->tx_task);
+}
+
+/*
+ * serial core request to stop rx, called before port shutdown
+ */
+static void vtty_uart_stop_rx(struct uart_port *port)
+{
+	struct mwl8k_vtty_priv *vp = to_vtty(port);
+
+	/* printk("%s\n", __FUNCTION__); */
+	/* irq are disabled */
+	vp->uart_started = false;
+}
+
+/*
+ * serial core request to enable modem status interrupt reporting
+ */
+static void vtty_uart_enable_ms(struct uart_port *port)
+{
+	/* printk("%s\n", __FUNCTION__); */
+}
+
+/*
+ * serial core request to start/stop emitting break char
+ */
+static void vtty_uart_break_ctl(struct uart_port *port, int ctl)
+{
+	/* printk("%s\n", __FUNCTION__); */
+}
+
+/*
+ * return port type in string format
+ */
+static const char *vtty_uart_type(struct uart_port *port)
+{
+	return "mwl8k_vtty";
+}
+
+/*
+ * serial core request to initialize uart and start rx operation
+ */
+static int vtty_uart_startup(struct uart_port *port)
+{
+	struct mwl8k_vtty_priv *vp = to_vtty(port);
+	unsigned long flags;
+
+	/* printk("%s\n", __FUNCTION__); */
+	spin_lock_irqsave(&port->lock, flags);
+	vp->uart_started = true;
+	spin_unlock_irqrestore(&port->lock, flags);
+	dev_info(&vp->priv->pdev->dev, "vtty line %d enabled\n", port->line);
+	return 0;
+}
+
+/*
+ * serial core request to flush & disable uart
+ */
+static void vtty_uart_shutdown(struct uart_port *port)
+{
+	struct mwl8k_vtty_priv *vp = to_vtty(port);
+	/* printk("%s\n", __FUNCTION__); */
+	dev_info(&vp->priv->pdev->dev, "vtty line %d disabled\n", port->line);
+}
+
+/*
+ * serial core request to change current uart setting
+ */
+static void vtty_uart_set_termios(struct uart_port *port,
+				  struct ktermios *new,
+				  struct ktermios *old)
+{
+	/* printk("%s\n", __FUNCTION__); */
+}
+
+/*
+ * serial core request to claim uart iomem
+ */
+static int vtty_uart_request_port(struct uart_port *port)
+{
+	/* printk("%s\n", __FUNCTION__); */
+	return 0;
+}
+
+/*
+ * serial core request to release uart iomem
+ */
+static void vtty_uart_release_port(struct uart_port *port)
+{
+	/* printk("%s\n", __FUNCTION__); */
+}
+
+/*
+ * serial core request to do any port required autoconfiguration
+ */
+static void vtty_uart_config_port(struct uart_port *port, int flags)
+{
+	/* printk("%s\n", __FUNCTION__); */
+	port->type = 1;
+}
+
+/*
+ * serial core request to check that port information in serinfo are
+ * suitable
+ */
+static int vtty_uart_verify_port(struct uart_port *port,
+				struct serial_struct *serinfo)
+{
+	printk("%s\n", __FUNCTION__);
+	/* if (port->type != PORT_BCM63XX) */
+	/* 	return -EINVAL; */
+	return 0;
+}
+
+/*
+ * serial core callbacks
+ */
+static const struct uart_ops vtty_uart_ops = {
+	.tx_empty	= vtty_uart_tx_empty,
+	.get_mctrl	= vtty_uart_get_mctrl,
+	.set_mctrl	= vtty_uart_set_mctrl,
+	.start_tx	= vtty_uart_start_tx,
+	.stop_tx	= vtty_uart_stop_tx,
+	.stop_rx	= vtty_uart_stop_rx,
+	.enable_ms	= vtty_uart_enable_ms,
+	.break_ctl	= vtty_uart_break_ctl,
+	.type		= vtty_uart_type,
+	.startup	= vtty_uart_startup,
+	.shutdown	= vtty_uart_shutdown,
+	.set_termios	= vtty_uart_set_termios,
+	.release_port	= vtty_uart_release_port,
+	.request_port	= vtty_uart_request_port,
+	.config_port	= vtty_uart_config_port,
+	.verify_port	= vtty_uart_verify_port,
+};
+
+/*
+ *
+ */
+static void vtty_read_data(struct mwl8k_vtty_priv *vp)
+{
+	struct mwl8k_ring_buf *rb = &vp->f2h_rb;
+	struct uart_port *port = &vp->port;
+	unsigned long flags;
+	unsigned int count;
+	u32 fw_off;
+
+	if (!vp->enabled)
+		return;
+
+	fw_off = le32_to_cpu(ioread32(rb->fw_ptr));
+	if (fw_off >= rb->size) {
+		dev_err(&vp->priv->pdev->dev,
+			"vtty f2h fw off OOB: %08x\n", fw_off);
+		vp->enabled = false;
+		return;
+	}
+
+	count = 0;
+	do {
+		u8 c;
+
+		if (rb->host_off == fw_off)
+			break;
+
+		c = ioread8(rb->start + rb->host_off);
+
+		spin_lock_irqsave(&port->lock, flags);
+		if (vp->uart_started) {
+			vp->port.icount.rx++;
+			uart_insert_char(&vp->port, 0, 0, c, TTY_NORMAL);
+		}
+		spin_unlock_irqrestore(&port->lock, flags);
+
+		count++;
+		rb->host_off++;
+		if (rb->host_off >= rb->size)
+			rb->host_off -= rb->size;
+
+	} while (rb->host_off != fw_off);
+
+	if (count) {
+		iowrite32(rb->host_off, rb->host_ptr);
+		mwl8k_raise_fw_irq(vp->priv, vp->h2f_irq_mask);
+	}
+
+	spin_lock_irqsave(&port->lock, flags);
+	if (vp->uart_started)
+		tty_flip_buffer_push(&vp->port.state->port);
+	spin_unlock_irqrestore(&port->lock, flags);
+}
+
+/*
+ *
+ */
+static void vtty_write_task(unsigned long data)
+{
+	struct mwl8k_vtty_priv *vp = (struct mwl8k_vtty_priv *)data;
+	struct mwl8k_ring_buf *rb = &vp->h2f_rb;
+	struct uart_port *port = &vp->port;
+	struct circ_buf *xmit;
+	unsigned long flags;
+	u32 fw_off, xmit_done;
+
+	if (!vp->enabled)
+		return;
+
+	spin_lock_irqsave(&port->lock, flags);
+
+	if (!vp->uart_started || uart_tx_stopped(port))
+		goto out_unlock;
+
+	fw_off = le32_to_cpu(ioread32(rb->fw_ptr));
+	if (fw_off >= rb->size) {
+		dev_err(&vp->priv->pdev->dev,
+			"vtty h2f fw off OOB: %08x\n", fw_off);
+		vp->enabled = false;
+		goto out_unlock;
+	}
+
+	xmit = &port->state->xmit;
+	xmit_done = 0;
+	while (1) {
+		u32 next;
+		u8 c;
+
+		/* do we have data to send ? */
+		if (uart_circ_empty(xmit))
+			break;
+
+		next = rb->host_off + 1;
+		if (next >= rb->size)
+			next -= rb->size;
+
+		/* is tx fifo full ? */
+		if (next == fw_off) {
+			dev_warn(&vp->priv->pdev->dev, "vtty tx fifo full\n");
+			break;
+		}
+
+		/* queue this char */
+		c = xmit->buf[xmit->tail];
+		iowrite8(c, rb->start + rb->host_off);
+		rb->host_off = next;
+		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+		port->icount.tx++;
+		xmit_done++;
+	}
+
+	if (xmit_done) {
+		iowrite32(rb->host_off, rb->host_ptr);
+		mwl8k_raise_fw_irq(vp->priv, vp->h2f_irq_mask);
+	}
+
+	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+		uart_write_wakeup(port);
+
+out_unlock:
+	spin_unlock_irqrestore(&port->lock, flags);
+}
+
+
+/*
+ *
+ */
+static u32 vtty_process(void *data, u32 irq_status)
+{
+	struct mwl8k_vtty_priv *vp = (struct mwl8k_vtty_priv *)data;
+	vtty_read_data(vp);
+	tasklet_schedule(&vp->tx_task);
+	return 0;
+}
+
+/*
+ *
+ */
+static bool uart_driver_registered;
+
+static int vtty_register_uart_driver(struct mwl8k_priv *priv)
+{
+	int ret;
+
+	if (uart_driver_registered)
+		return 0;
+
+	ret = uart_register_driver(&mwl8k_vtty_driver);
+	if (ret) {
+		dev_err(&priv->pdev->dev,
+			"failed to register uart driver: %d\n", ret);
+		return ret;
+	}
+
+	uart_driver_registered = true;
+	return 0;
+}
+
+/*
+ *
+ */
+static void vtty_unregister_uart_driver(void)
+{
+	if (uart_driver_registered) {
+		uart_unregister_driver(&mwl8k_vtty_driver);
+		uart_driver_registered = false;
+	}
+}
+
+/*
+ *
+ */
+static void *vtty_alloc(struct mwl8k_priv *priv, void __iomem *vdesc,
+			u32 *poll_mask)
+{
+	struct __iomem ixzone_svc_tty *desc = vdesc;
+	struct mwl8k_vtty_priv *vp;
+	struct uart_port *port;
+	unsigned int off;
+	int ret;
+
+	if (vtty_register_uart_driver(priv))
+		return NULL;
+
+	if (!desc->f2h_irq_mask || !desc->h2f_irq_mask) {
+		dev_err(&priv->pdev->dev,
+			"vtty has no irq mask\n");
+		return NULL;
+	}
+
+	vp = kzalloc(sizeof (*vp), GFP_KERNEL);
+	if (!vp)
+		return NULL;
+
+	off = (void *)&desc->f2h_rb - (void *)priv->sram;
+	if (rb_init("vtty_f2h", off, &desc->f2h_rb, &vp->f2h_rb, true)) {
+		kfree(vp);
+		return NULL;
+	}
+
+	off = (void *)&desc->h2f_rb - (void *)priv->sram;
+	if (rb_init("vtty_h2f", off, &desc->h2f_rb, &vp->h2f_rb, false)) {
+		kfree(vp);
+		return NULL;
+	}
+
+	tasklet_init(&vp->tx_task, vtty_write_task, (unsigned long)vp);
+	port = &vp->port;
+	port->ops = &vtty_uart_ops;
+	port->dev = &priv->pdev->dev;
+	port->line = priv->vtty_count;
+	port->membase = (void *)vp->f2h_rb.host_ptr;
+	port->iotype = SERIAL_IO_MEM;
+	port->flags = UPF_BOOT_AUTOCONF;
+	port->type = 1;
+
+	ret = uart_add_one_port(&mwl8k_vtty_driver, port);
+	if (ret) {
+		dev_err(&priv->pdev->dev,
+			"failed to add uart port: %d\n", ret);
+		kfree(vp);
+		return NULL;
+	}
+
+	vp->f2h_irq_mask = le32_to_cpu(desc->f2h_irq_mask);
+	*poll_mask = vp->f2h_irq_mask;
+	vp->h2f_irq_mask = le32_to_cpu(desc->h2f_irq_mask);
+	vp->priv = priv;
+	vp->enabled = true;
+	priv->vtty_count++;
+	return vp;
+}
+
+/*
+ *
+ */
+static void vtty_free(void *data)
+{
+	struct mwl8k_vtty_priv *vp = (struct mwl8k_vtty_priv *)data;
+	uart_remove_one_port(&mwl8k_vtty_driver, &vp->port);
+	vp->enabled = false;
+	tasklet_kill(&vp->tx_task);
+	kfree(vp);
+}
+
+/*
+ *
+ */
+static void __exit vtty_exit(void)
+{
+	vtty_unregister_uart_driver();
+}
+
+const struct dbg_svc_ops vtty_dbg_svc_ops = {
+	.name		= "vtty",
+	.uuid		= SVC_TTY_UUID,
+	.desc_size	= sizeof (struct ixzone_svc_tty),
+	.svc_alloc	= vtty_alloc,
+	.svc_process	= vtty_process,
+	.svc_free	= vtty_free,
+	.exit		= vtty_exit,
+};
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./utils.c linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/utils.c
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./utils.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/utils.c	2021-03-04 13:20:59.424172295 +0100
@@ -0,0 +1,113 @@
+#include "mwl8k_priv.h"
+
+/*
+ *
+ */
+void memcpy_fromio_iovec(u8 *kdata, struct iovec *iov, int len)
+{
+	while (len > 0) {
+		if (iov->iov_len) {
+			int copy = min_t(unsigned int, len, iov->iov_len);
+			memcpy_fromio(kdata, iov->iov_base, copy);
+			len -= copy;
+			kdata += copy;
+			iov->iov_base += copy;
+			iov->iov_len -= copy;
+		}
+		iov++;
+	}
+}
+
+/*
+ * Reduce an iovec's length in-place.  Return the resulting number of segments
+ */
+static unsigned long iov_shorten(struct iovec *iov,
+				 unsigned long nr_segs, size_t to)
+{
+	unsigned long seg = 0;
+	size_t len = 0;
+
+	while (seg < nr_segs) {
+		seg++;
+		if (len + iov->iov_len >= to) {
+			iov->iov_len = to - len;
+			break;
+		}
+		len += iov->iov_len;
+		iov++;
+	}
+	return seg;
+}
+
+/*
+ *
+ */
+size_t rb_gen_iov(struct mwl8k_ring_buf *rb,
+		  struct iovec iov[2],
+		  u32 fw_off,
+		  u32 max_size)
+{
+	size_t iov_count;
+
+	if (fw_off >= rb->host_off) {
+		iov[0].iov_base = rb->start +  rb->host_off;
+		iov[0].iov_len = fw_off - rb->host_off;
+		iov[1].iov_base = NULL;
+		iov[1].iov_len = 0;
+	} else {
+		iov[0].iov_base = rb->start + rb->host_off;
+		iov[0].iov_len = rb->size - rb->host_off;
+		iov[1].iov_base = rb->start;
+		iov[1].iov_len = fw_off;
+	}
+
+	if (max_size)
+		iov_count = iov_shorten(iov, 2, max_size);
+	else
+		iov_count = 2;
+
+	return iov_length(iov, iov_count);
+}
+
+/*
+ *
+ */
+int rb_init(const char *name,
+	    unsigned int off,
+	    struct  __iomem ixzone_ring_buf *rb_io,
+	    struct mwl8k_ring_buf *rb,
+	    bool host_is_consumer)
+{
+	u32 boff, bsize;
+
+	boff = le32_to_cpu(rb_io->buf_offset);
+	bsize = le32_to_cpu(rb_io->buf_size);
+
+	if (check_bound(SRAM_SIZE, off + boff, bsize)) {
+		printk(KERN_ERR MWL8K_PFX
+		       "%s ring buf has bad buf offsets\n", name);
+		return 1;
+	}
+
+	rb->start = (void *)rb_io + boff;
+	rb->size = bsize;
+
+	if (host_is_consumer) {
+		rb->fw_ptr = &rb_io->producer;
+		rb->host_ptr = &rb_io->consumer;
+		rb->host_off = le32_to_cpu(rb_io->consumer);
+	} else {
+		rb->fw_ptr = &rb_io->consumer;
+		rb->host_ptr = &rb_io->producer;
+		rb->host_off = le32_to_cpu(rb_io->producer);
+	}
+
+	if (rb->host_off >= rb->size) {
+		printk(KERN_ERR MWL8K_PFX
+		       "%s ring buf has bad idx offsets\n", name);
+		return 1;
+	}
+
+	return 0;
+}
+
diff -Nruw linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./wifi_core.c linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/wifi_core.c
--- linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new./wifi_core.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/net/wireless/marvell/mwl8k_new/wifi_core.c	2021-03-04 13:20:59.427505629 +0100
@@ -0,0 +1,6034 @@
+#include <linux/mutex.h>
+#include <net/mac80211.h>
+
+#include "mwl8k_priv.h"
+#include "hostif_wifi.h"
+#include "d11_defs.h"
+
+static u8 base_mac_addr[18] = "00:00:00:00:00:00";
+module_param_string(base_mac_addr, base_mac_addr, 18, 0);
+MODULE_PARM_DESC(base_mac_addr,
+		  "Override EEPROM defined base mac address in AP mode");
+
+static int mac_addr_count = -1;
+module_param(mac_addr_count, int, 0);
+MODULE_PARM_DESC(mac_addr_count,
+		  "Override EEPROM defined mac address count");
+
+#undef TX_DBG_PRINT
+
+#ifdef TX_DBG_PRINT
+#define txdbg(...)	printk(__VA_ARGS__)
+#define psdbg(...)	printk(__VA_ARGS__)
+#define badbg(...)	printk(__VA_ARGS__)
+#define aggdbg(...)	printk(__VA_ARGS__)
+#else
+#define txdbg(...)
+#define psdbg(...)
+#define badbg(...)
+#define aggdbg(...)
+#endif
+
+#define RND_DROP_PPK	0
+
+#define WIFI_MAX_AP_VIFS	8
+#define WIFI_STA_MAGIC		0x12345678
+
+/*
+ * number of rx descriptors
+ */
+#define WIFI_RX_DESCS		256
+
+/*
+ * maximum number of descriptors we are allowed to use from the
+ * .wake_tx_queue interface
+ *
+ * we will be pushing at best two full aggregates (could be for two
+ * different TID), and/or 8 non aggregates.
+ *
+ * if not using aggregation, even the fastest packet takes no less
+ * than 100us to transmit (including ACK), so with about 8 of those,
+ * we can push 1ms of data into FIFO and make sure we don't starve
+ */
+#define WIFI_TX_MAX_AGGR	2
+#define WIFI_TX_MAX_NON_AGGR	8
+
+#define WIFI_TX_DESCS_WAKE	(WIFI_TX_MAX_AGGR * IEEE80211_AGGR_MAX_MPDU + \
+				 WIFI_TX_MAX_NON_AGGR)
+
+/*
+ * number of tx descriptors to allocate, we reserve some for drv_tx()
+ * callback which can only push control frames or ps response frames
+ */
+#define WIFI_TX_DESCS		(WIFI_TX_DESCS_WAKE + 8)
+
+
+/*
+ * rx buffer size, big enough to receive the minimum size AMSDU,
+ * mandatory for 802.11n
+ */
+#define WIFI_RX_BUF_SIZE	3839
+
+/*
+ * maximum number of time we will software retry a single mpdu from
+ * aggregate
+ */
+#define WIFI_MAX_SW_TRIES	20
+
+/* since hardware does not do multi rate retry on AMPDU, if we cannot
+ * build a large chain, better send them as individual packets, this
+ * is the minimum number of packets to send as AMPDU */
+#define WIFI_MIN_AGGR_COUNT	4
+
+/*
+ * rx queue (interface between host & firmware)
+ */
+struct wifi_rxq {
+	u32		count;
+	u32		refill_off;
+	u32		fw_off;
+
+	struct wifi_rxd	*descs;
+	dma_addr_t	descs_dma;
+
+	struct {
+		struct sk_buff *skb;
+		DEFINE_DMA_UNMAP_ADDR(dma);
+	} *bufs;
+};
+
+/*
+ * we will be doing some internal queing inside the driver to handle
+ * aggregation and software retransmit, the skb->cb leftover after
+ * mac80211 took its share is not big enough to contain all the extra
+ * data we need, so for each skb we track in tx path, there is an
+ * associated wifi_tx_skb struct
+ */
+enum wifi_tx_skb_type {
+	WIFI_TXSKB_QOS_DATA,
+	WIFI_TXSKB_BAR,
+	WIFI_TXSKB_OTHER,
+};
+
+struct wifi_tx_skb {
+	/* frame to transmit */
+	struct sk_buff		*skb;
+	DEFINE_DMA_UNMAP_ADDR(skb_dma);
+	DEFINE_DMA_UNMAP_LEN(skb_len);
+
+	/* txq it belongs to */
+	struct wifi_txq		*txq;
+
+	/* for packets aggregated, we will be doing software retries
+	 * of single failed mpdu, this is the total try count */
+	u8			sw_tries_done;
+
+	/*
+	 * whether the frame was sent has a valid tid field, it means
+	 * it got transmitted to a known STA, and that the frame will
+	 * be accounted in wifi_tid tx_pending
+	 */
+	bool			has_tid:1;
+
+	/* type of frame (valid if has_tid == true) */
+	enum wifi_tx_skb_type	type:2;
+
+	/*
+	 * if the frame has a known TID, this is the corresponding STA
+	 * version when it's created
+	 */
+	u32			sta_version;
+
+	/* tid of frame, used after tx completion to find back the
+	 * correct wifi_tid, only valid when has_tid is true */
+	u8			tid;
+
+	/*
+	 * when type is WIFI_TXSKB_BAR, this is the tid for which the
+	 * BAR request was sent (not the TID the frame was sent on)
+	 */
+	u8			bar_tid;
+
+	/* true size of frame that will be transmitted in the air,
+	 * including encryption and FCS, filled when we create this
+	 * wrapper */
+	u16			frame_len;
+
+	/* sequence number of frame, only valid for QOS data frames
+	 * (type == WIFI_TXSKB_QOS_DATA), extracted from header when
+	 * we create the wrapper */
+	u16			seq_no;
+
+	/* most invariant fields of tx descriptor are pre-computed
+	 * here, others like ampdu flags are updated just before
+	 * queuing to hardware */
+	struct wifi_txd		txdesc;
+
+	/* used when queing frame into hardware, aggr_member will be
+	 * true if frame is part of AMPDU, aggr_list will be non empty
+	 * for the last MPDU of the aggregate */
+	bool			aggr_member;
+	struct list_head	aggr_list;
+
+	struct list_head	next;
+};
+
+/*
+ * tx queue (interface between host & firmware)
+ */
+struct wifi_txq {
+	spinlock_t		lock;
+	u16			idx;
+	u16			ac;
+
+	/* DMA queue offsets */
+	u32			head_off;
+	u32			reclaim_off;
+
+	/* count of total descriptors we pushed in queue  */
+	u32			count;
+
+	/* count of aggregates & non-aggregate packets we pushed via
+	 * the wake_tx_queue interface */
+	u32			aggr_count;
+	u32			non_aggr_count;
+
+	/* pre-allocated list of wifi_tx_skb, same size as total
+	 * number of descriptors */
+	struct list_head	wifi_tx_skbs_pool;
+
+	/* tx hardware descriptors queue */
+	struct wifi_txd		*descs;
+	dma_addr_t		descs_dma;
+
+	/* pending packets */
+	struct wifi_tx_skb	**pending_wskb;
+
+	/* pre-computed aggregate maximum size for each; chan-width,
+	 * per-guard-interval, per mcs */
+	u16			max_aggr_framelen[2][2][32];
+};
+
+enum wifi_ps_action {
+	WIFI_PS_ACTION_NONE,
+	WIFI_PS_ACTION_SLEEP,
+	WIFI_PS_ACTION_TXDONE,
+	WIFI_PS_ACTION_WAKEUP,
+};
+
+enum wifi_ps_state {
+	WIFI_PS_AWAKE,
+	WIFI_PS_ENTER_SLEEP,
+	WIFI_PS_SLEEP,
+};
+
+struct wifi_sta {
+	/*
+	 * there is a race in mac80211, .sta_notify callback can be
+	 * called before .sta_add has completed, which result in a
+	 * crash because struct wifi_sta is initialized in .sta_add
+	 *
+	 * workaround this with a magic init done marker value
+	 */
+	u32			magic;
+
+	/*
+	 * STA is looked up on tx completion by its mac address, but
+	 * since we don't wait for tx queue to drain when removing a
+	 * STA, it's possible for the STA to deauth and re-auth while
+	 * packet are still pending in tx queue, which will mess up
+	 * with the BAW tracking
+	 *
+	 * fix this by having an additional "version" counter
+	 */
+	u32			version;
+
+	/*
+	 * hardware id allocated by the firmware
+	 */
+	__le16			hw_id;
+
+
+	/* this makes tid invisible to tx done handler, used to
+	 * prevent TID rescheduling when flushing aggregation state
+	 * (see ampdu_action) */
+	bool			dead;
+
+	/*
+	 * reflect current PS state of station, updated via notify
+	 * callback from mac80211, this goes like this
+	 *
+	 * 1) STA is initially in PS_AWAKE state.
+	 *
+	 * 2) If/when stack receives a packet with the PS bit set, it
+	 * will call our .sta_notify callback
+	 *
+	 * 3) if there is no packet pending (in TX DMA queue) for this
+	 * STA, we will switch to SLEEP state (see 5)
+
+	 * 4) Otherwise, we get into ENTER_SLEEP state, and call
+	 * ieee80211_sta_block_awake() so that mac80211 will leave the
+	 * STA internal state to sleep if it wakes up.f Each time we
+	 * get tx completion for a packet, we decrement the pending
+	 * counter for the associated STA. When it reaches 0, we will
+	 * unblock mac80211 and switch to SLEEP state.
+	 *
+	 * 5) when entering SLEEP state, we tell mac80211 whether of
+	 * not we have buffered packets in the driver for each STA/TID
+	 * using ieee80211_sta_set_buffered(). This is re-evaluated
+	 * each time we dequeue a packet from the TID retry queue and
+	 * the retry queue becomes empty. Note that there is an
+	 * additional sub state in each TID, ps_sleep_has_buf tracks
+	 * whether we have reported that we still have buffered data
+	 * or not for this TID
+	 *
+	 * when PS state is AWAKE, packets for a tid should flow only
+	 * from the itxq (tid_schedule)
+	 *
+	 * when PS state is ENTER_SLEEP, there should be no tx at all.
+	 *
+	 * when PS state is SLEEP && ps_sleep_has_buf == true for any
+	 * TID, data packets should be sent only as a respond to
+	 * PS-Poll (service period), and done only through
+	 * .release_buffered_frames interface
+	 *
+	 * when PS state is SLEEP && ps_sleep_has_buf == false for all
+	 * TIDs, same as previously, but we will also get packets
+	 * buffered inside mac80211 through drv_tx() interface
+	 */
+	enum wifi_ps_state	ps_state;
+
+	/* number of packets currently sitting in hw queue waiting for
+	 * tx completion for this STA, only packets sent on a valid
+	 * tid are accounted */
+	unsigned int		tx_pending;
+
+	/*
+	 * this lock protect the PS state
+	 */
+	spinlock_t		lock;
+
+	/*
+	 * HW has a persistent filter for STA in powersave, and will
+	 * return all frames as filtered until it's cleared.
+	 *
+	 * usually that's racy because STA PS status gets updated by
+	 * rx path, while we get filtered frame by tx completion.
+	 *
+	 * since we use ieee80211_sta_block_awake() in the driver,
+	 * there can not be any sleep => awake => sleep STA transition
+	 * without the STA pending traffic being drained. The
+	 * clear_ps_filter flag will be set only after we leave the
+	 * SLEEP state, all packets sent during service period are
+	 * flags to bypass that filter.
+	 */
+	atomic_t		clear_ps_filter;
+};
+
+#define WIFI_STA(_sta) ((struct wifi_sta *)&((_sta)->drv_priv))
+
+
+/*
+ * private per mac80211 intermediate txq info (called it a TID to
+ * avoid confusion with other txq)
+ */
+enum wifi_aggr_state {
+	WIFI_AGGR_STOPPED,
+	WIFI_AGGR_ACTIVE,
+	WIFI_AGGR_STOPPING,
+};
+
+enum wifi_bar_state {
+	WIFI_BAR_NONE,
+	WIFI_BAR_NEEDED,
+	WIFI_BAR_SENT,
+	WIFI_BAR_WAIT_RETRY,
+};
+
+enum wifi_tid_type {
+	/* for itxq associated to VIF, used for multicast traffic, no
+	 * associated STA */
+	WIFI_TID_MCAST,
+
+	/* for special itxq with id 16 (IEEE80211_NUM_TIDS), we get
+	 * bufferable management frames on it */
+	WIFI_TID_STA_MMPDU,
+
+	/* for itxq with TID 0 and non WME STA, we get data frame only
+	 * on those, but the sequence number will not be monotonic */
+	WIFI_TID_STA_DATA,
+
+	/* for itxq with TID 0 to 15 and WME STA, we only get QOS data
+	 * on those */
+	WIFI_TID_STA_QOS_DATA,
+
+};
+
+struct wifi_tid {
+	/* see enum definition */
+	enum wifi_tid_type	type;
+
+	/*
+	 * see explanation regarding ps_state in wifi_sta
+	 */
+	bool			ps_sleep_has_buf;
+
+	/*
+	 * internal list of packets that needs to be retried, this is
+	 * used only if tid type is WIFI_TID_STA_QOS_DATA, whether
+	 * aggregation is active or not.
+	 *
+	 * filtered frames (STA is in powersave) for are requeued here
+	 * and not given back to mac80211
+	 *
+	 * when aggregation is active, frames that we dequeued from
+	 * mac80211 itxq and were not sent (max aggregate len reached)
+	 * or sent but got no ACK are sitting here, waiting to be
+	 * (re)transmitted.
+	 *
+	 * order of packets inside does not matter, the rule is that
+	 * whatever sits here should be part of current BAW.
+	 */
+	struct list_head	retry_q;
+
+	/* current block ack session state for this tid */
+	enum wifi_aggr_state	aggr_state;
+
+	/* maximum total number of bytes allowed by remote STA in an
+	 * ampdu, updated when aggregation is started */
+	u16			ampdu_max_bytes;
+
+	/* minimum ampdu density requested by remote STA, index from 0
+	 * to 7 */
+	u8			ampdu_density;
+
+	/*
+	 * This is the BlockAck window (BAW) maximum size (number of
+	 * packets), defaults to hardware max, updated to remote STA
+	 * maximum supported value (if lower) when aggr session state
+	 * switches to operational.
+	 *
+	 * It's used even when aggregation is disabled. All PS
+	 * filtered frames will be retried by the driver itself, so
+	 * until a frame is ACKed, it's considered as inflight. When
+	 * aggregation wants to start, we have to return a starting
+	 * SSN, which must include those inflight packets (otherwise
+	 * if we could send packets with a SSN lower than what we
+	 * returned in AddBA). Instead of an alternative inflight
+	 * counters, we re-use the BAW to implement this, baw_size is
+	 * set to an artificial limit.
+	 */
+	u16			baw_max_size;
+
+	/*
+	 * After AddBA exchange, chosen BAW size may be lower than
+	 * what remote is using, because mac80211 send a fixed 64
+	 * value to remote, which may be higher than what our hardware
+	 * support, we remember the remote BAW size, and use it for
+	 * BAR scheduling
+	 */
+	u16			remote_baw_max_size;
+
+	/*
+	 * this is the sequence number that correspond the the start
+	 * of our BAW (BlockAck window)
+	 */
+	u16			seq_start;
+
+	/*
+	 * scoreboard tracks the blockack window state.
+	 *
+	 * (scb == scoreboard)
+	 *
+	 * scb_inflight bitmap tracks whether given frames is in-flight
+	 * (not yet acked, not yet failed), scb_acked is bitmap of
+	 * positively acknowledged frames
+	 *
+	 * scb_inflight_count is the number of frames in scb_inflight
+	 * bitmap
+	 *
+	 * scb_head is the bit index inside scoreboard corresponding
+	 * to the status of packet with <seq_start>
+	 *
+	 * scb_tail is the bit index inside scoreboard corresponding
+	 * to the next available space in the scoreboard. (scb_tail -
+	 * scb_head) is the number of in-flight packets (from the
+	 * received POV)
+	 *
+	 * bitmap range validity is  [ <scb_head>, <scb_tail> - 1 ]
+	 *
+	 * NB: scoreboards size needs to be 1 element more because of
+	 * ring buffer structure (scb_head == scb_tail is empty,
+	 * scb_head + 1 == scb_tail is full)
+	 */
+#define WIFI_SCB_MAX		(IEEE80211_AGGR_MAX_MPDU + 1)
+
+	unsigned long		scb_acked[BITS_TO_LONGS(WIFI_SCB_MAX)];
+	unsigned long		scb_inflight[BITS_TO_LONGS(WIFI_SCB_MAX)];
+	unsigned int		scb_inflight_count;
+	unsigned int		scb_head;
+	unsigned int		scb_tail;
+
+	/*
+	 * After a failed MPDU (too many retransmits), there is a
+	 * "hole" in the BAW. If failed MPDU has seq_no N, and
+	 * receiver has successfuly received MPDUs N+1 and N+2, those
+	 * won't be delivered to the higher level until a very large
+	 * timeout.
+	 *
+	 * To make the receiver aware we won't retry the failed MPDU,
+	 * we can send a "BlocAck Request" (BAR) frame, with a field
+	 * Starting Sequence Number (SSN) equal to N+3, which will
+	 * cause it to "flush" all MPDU stored with seq_no < N+3
+	 *
+	 * Note that it's not mandatory, the receiver side BAW will
+	 * still advance when receiving packets outside the BAW range
+	 * (as long as sequence lies withing 2^11 of current one), so
+	 * if we keep sending MPDU and reach seq_no N+64, then MPDU N
+	 * will be flushed anyway.
+	 *
+	 * So we use a timer, each time we know that a BAR has to be
+	 * sent, we arm the timer and remember the SSN, if after the
+	 * timer the hole is not past SSN+64 we will send the BAR.
+	 *
+	 * Only one BAR will be sent at a time, and we won't send a
+	 * new one unless the previous one has been sent (tx
+	 * completion).
+	 *
+	 * mac80211 has a logic to retry failed BAR, but that causes
+	 * re-entering the tx path from tx completion path
+	 * (ieee80211_tx_status_ext() => drv_tx()), which requires
+	 * careful locking, to avoid this complexity we don't report
+	 * BAR tx failure to mac80211 and schedule bar retry ourselves
+	 *
+	 * BAR can also be sent immediately from the tx path if it's
+	 * pending and we dequeued everything on the TID.
+	 *
+	 * When BAR state is set to BAR_NEEDED, timer will be armed,
+	 * bar_req_limit tracks the maximum SN inside BAW for which
+	 * the BAR is useful, if BAW head goes past this value, then
+	 * BAR is canceled.
+	 *
+	 * When BAR tx fails, state switch to BAR_WAIT_RETRY, timer is not
+	 * armed. In that state, if any MPDU is acked, timer will be
+	 * armed to minimum value.
+	 */
+	spinlock_t		bar_lock;
+	enum wifi_bar_state	bar_state;
+	bool			bar_inflight;
+	int			bar_retry_count;
+	struct timer_list	bar_timer;
+	int			bar_req_limit;
+
+	/* associated hardware tx queue */
+	struct wifi_txq		*txq;
+};
+
+#define WIFI_TID(_txqi) ((struct wifi_tid *)&((_txqi)->drv_priv))
+
+#define TID2ITXQ(_tid)	container_of((void *)wifi_tid,		\
+				     struct ieee80211_txq,	\
+				     drv_priv)
+
+/*
+ * private per-vif info
+ */
+struct wifi_vif {
+	__le16			hw_id;
+	unsigned int		tbtt_idx;
+};
+
+#define WIFI_VIF(_vif) ((struct wifi_vif *)&((_vif)->drv_priv))
+
+/*
+ * command channel
+ */
+struct wifi_cmd_chan {
+	u8 __iomem		*buf_start;
+	u32			buf_size;
+	u32			f2h_irq_mask;
+	u32			h2f_irq_mask;
+	u32 __iomem		*fw_count_ptr;
+	u32 __iomem		*host_count_ptr;
+	u32 __iomem		host_count;
+	struct mutex		lock;
+	spinlock_t		complete_lock;
+	struct completion	completion;
+	bool			pending;
+};
+
+/*
+ *
+ */
+struct wifi_priv {
+	/*
+	 * cmd offset
+	 */
+	struct wifi_cmd_chan	cmd_chans[WIFI_CMD_CHAN_LAST];
+
+	/*
+	 * rx related
+	 */
+	u32			rx_f2h_irq_mask;
+	struct wifi_rxq		rxq;
+
+	/*
+	 * tx related
+	 */
+	struct wifi_txq		*txqs;
+	size_t			txq_count;
+	u32			tx_f2h_irq_mask;
+	u32			tx_f2h_irq_shift;
+	u32			tx_h2f_irq_mask;
+	u32			tx_h2f_irq_shift;
+
+	/*
+	 * vif related
+	 */
+	u32			tbtt_f2h_irq_mask;
+	u32			tbtt_f2h_irq_shift;
+
+	/*
+	 * misc
+	 */
+	u16			fw_major;
+	u16			fw_minor;
+	struct mac_address	addresses[8];
+	size_t			addresses_count;
+
+	/*
+	 * hardware limits
+	 */
+	int			hw_max_ampdu_chain;
+	int			hw_max_ap_vif;
+	int			hw_max_sta_vif;
+	int			hw_radio_chains;
+	int			hw_bcn_interval_gcd;
+
+	struct ieee80211_supported_band gband;
+	struct ieee80211_iface_limit if_limits[2];
+	struct ieee80211_iface_combination if_comb;
+
+	u32			sta_next_version;
+	struct survey_info	survey[13];
+	int			cur_chan_idx;
+
+	spinlock_t		vifs_by_tbtt_lock;
+	struct ieee80211_vif	*vifs_by_tbtt_idx[WIFI_MAX_AP_VIFS];
+
+	struct ieee80211_hw	*hw;
+	bool			hw_registered;
+	struct pci_dev		*pdev;
+	struct device		*dev;
+	struct mwl8k_priv	*priv;
+};
+
+/*
+ * supported band
+ */
+#define CHAN2G(_idx, _freq)  {	   \
+	.band = NL80211_BAND_2GHZ, \
+	.center_freq = (_freq), \
+	.hw_value = (_idx), \
+	.max_power = 20, \
+}
+
+static struct ieee80211_channel gchannels[] = {
+	CHAN2G(1, 2412),
+	CHAN2G(2, 2417),
+	CHAN2G(3, 2422),
+	CHAN2G(4, 2427),
+	CHAN2G(5, 2432),
+	CHAN2G(6, 2437),
+	CHAN2G(7, 2442),
+	CHAN2G(8, 2447),
+	CHAN2G(9, 2452),
+	CHAN2G(10, 2457),
+	CHAN2G(11, 2462),
+	CHAN2G(12, 2467),
+	CHAN2G(13, 2472),
+};
+
+static struct ieee80211_rate mwl8k_rates[] = {
+	{
+		.bitrate = 10,
+		.hw_value = 0,
+	},
+	{
+		.bitrate = 20,
+		.flags = IEEE80211_RATE_SHORT_PREAMBLE,
+		.hw_value = 1,
+	},
+	{
+		.bitrate = 55,
+		.flags = IEEE80211_RATE_SHORT_PREAMBLE,
+		.hw_value = 2,
+	},
+	{
+		.bitrate = 110,
+		.flags = IEEE80211_RATE_SHORT_PREAMBLE,
+		.hw_value = 3,
+	},
+	{
+		.bitrate = 60,
+		.hw_value = 5,
+	},
+	{
+		.bitrate = 90,
+		.hw_value = 6,
+	},
+	{
+		.bitrate = 120,
+		.hw_value = 7,
+	},
+	{
+		.bitrate = 180,
+		.hw_value = 8,
+	},
+	{
+		.bitrate = 240,
+		.hw_value = 9,
+	},
+	{
+		.bitrate = 360,
+		.hw_value = 10,
+	},
+	{
+		.bitrate = 480,
+		.hw_value = 11,
+	},
+	{
+		.bitrate = 540,
+		.hw_value = 12,
+	}
+};
+
+
+static int wifi_rxd_rate_to_rate(uint8_t val, bool is_cck)
+{
+	switch (val) {
+	case 8: return 10;
+	case 9: return 8;
+	case 10: return is_cck ? 0 : 6;
+	case 11: return 4;
+	case 12: return 11;
+	case 13: return 9;
+	case 14: return 7;
+	case 15: return 5;
+	case 20: return 1;
+	case 55: return 2;
+	case 110: return 3;
+	default: return 0;
+	}
+}
+
+/*
+ *
+ */
+static const char * const wifi_cmd_errors[] = {
+	[WIFI_RESULT_OK]		= "OK",
+	[WIFI_RESULT_INVAL]		= "INVAL",
+	[WIFI_RESULT_UNKNOWN_CMD]	= "UNKNOWN_CMD",
+	[WIFI_RESULT_IO_ERROR]		= "IO_ERROR",
+	[WIFI_RESULT_NOSPC]		= "NOSPC",
+	[WIFI_RESULT_NOENT]		= "NOENT",
+	[WIFI_RESULT_BUSY]		= "BUSY",
+	[WIFI_RESULT_EAGAIN]		= "EAGAIN",
+	[WIFI_RESULT_EXISTS]		= "EXISTS",
+};
+
+static const char *wifi_cmd_strerror(int ret)
+{
+	if (ret < 0 || ret >= ARRAY_SIZE(wifi_cmd_errors))
+		return "UNKNOWN";
+	return wifi_cmd_errors[ret];
+}
+
+/*
+ *
+ */
+static int __cmd_submit(struct wifi_priv *wp,
+			u32 chan_id,
+			u32 cmd_id,
+			const void *req_buf,
+			size_t req_buf_size,
+			u32 *presult,
+			void *resp_buf,
+			size_t *resp_buf_size,
+			bool strict_resp_size)
+{
+	struct wifi_cmd_chan *chan = &wp->cmd_chans[chan_id];
+	struct wifi_cmd_hdr __iomem *hdr_io;
+	struct wifi_cmd_resp __iomem *resp_io;
+	bool is_atomic = (chan_id == WIFI_CMD_CHAN_ATOMIC);
+	size_t len;
+	u32 fw_count, fw_resp_size, result;
+	int ret;
+
+	len = req_buf_size + WIFI_HDR_SIZE;
+	if (len > chan->buf_size) {
+		dev_err(wp->dev, "total cmd size too big for buf\n");
+		return -EINVAL;
+	}
+
+	if (!is_atomic)
+		mutex_lock(&chan->lock);
+
+	/* extra sanity check */
+	fw_count = le32_to_cpu(ioread32(chan->fw_count_ptr));
+	if (fw_count != chan->host_count) {
+		dev_err(wp->dev, "unexpected fw cmd ptr:%x host:%x\n",
+			fw_count, chan->host_count);
+		ret = -EIO;
+		goto fail;
+	}
+
+	/* write command header */
+	hdr_io = (struct wifi_cmd_hdr *)chan->buf_start;
+	iowrite32(cpu_to_le32(cmd_id), &hdr_io->id);
+	iowrite32(cpu_to_le32(req_buf_size), &hdr_io->size);
+
+	/* write request data */
+	memcpy_toio(hdr_io + 1, req_buf, req_buf_size);
+
+	/* increment queue pointer */
+	if (!is_atomic)
+		init_completion(&chan->completion);
+
+	spin_lock_bh(&chan->complete_lock);
+	chan->host_count++;
+	chan->pending = true;
+	iowrite32(cpu_to_le32(chan->host_count), chan->host_count_ptr);
+	spin_unlock_bh(&chan->complete_lock);
+
+	mwl8k_raise_fw_irq(wp->priv, chan->h2f_irq_mask);
+
+	ret = 0;
+	if (!is_atomic) {
+		/* wait for irq */
+		if (!wait_for_completion_timeout(&chan->completion, 10 * HZ))
+			ret = 1;
+	} else {
+		size_t i;
+
+		for (i = 0; i < 100000; i++) {
+			u32 fw_off = le32_to_cpu(ioread32(chan->fw_count_ptr));
+
+			if (fw_off == chan->host_count)
+				break;
+
+			udelay(5);
+		}
+
+		if (i > 10000) {
+			printk("long atomic command: %zu\n", i);
+		}
+
+		if (i == 100000)
+			ret = 1;
+	}
+
+	if (ret) {
+		dev_err(wp->dev, "%scommand %u timeout, host:%x fw:%x\n",
+			is_atomic ? "atomic " : "",
+			cmd_id,
+			ioread32(chan->fw_count_ptr),
+			ioread32(chan->host_count_ptr));
+		ret = -ETIMEDOUT;
+		goto fail;
+	}
+
+	/* extract result */
+	fw_resp_size = cpu_to_le32(ioread32(&hdr_io->size));
+	if (fw_resp_size < sizeof (resp_io->result)) {
+		dev_err(wp->dev, "command %u resp too small: %u\n",
+			cmd_id,
+			fw_resp_size);
+		ret = -EIO;
+		goto fail;
+	}
+
+	resp_io = (struct wifi_cmd_resp *)(hdr_io + 1);
+	result = le32_to_cpu(ioread32(&resp_io->result));
+	if (presult)
+		*presult = result;
+	fw_resp_size -= sizeof (resp_io->result);
+
+	if (resp_buf && fw_resp_size > *resp_buf_size) {
+		dev_err(wp->dev, "command %u resp too big: %u (buf %zu)\n",
+			cmd_id,
+			fw_resp_size, *resp_buf_size);
+		ret = -EIO;
+		goto fail;
+	}
+
+	if (result) {
+		dev_err(wp->dev, "command %u resp failed with "
+			"result %u (%s)\n",
+			cmd_id, result, wifi_cmd_strerror(result));
+		ret = -EIO;
+		goto fail;
+	}
+
+	if (resp_buf_size && strict_resp_size &&
+	    fw_resp_size != *resp_buf_size) {
+		dev_err(wp->dev, "command %u resp size invalid:%u exp:%zu\n",
+			cmd_id,
+			fw_resp_size,
+			*resp_buf_size);
+		ret = -EIO;
+		goto fail;
+	}
+
+	ret = 0;
+	if (resp_buf)
+		memcpy_fromio(resp_buf,
+			      (void *)&resp_io->result + 4,
+			      fw_resp_size);
+
+fail:
+	if (!is_atomic)
+		mutex_unlock(&chan->lock);
+	return ret;
+}
+
+/*
+ *
+ */
+static int cmd_submit_check(struct wifi_priv *wp,
+			    u32 chan_id,
+			    u32 cmd_id,
+			    const void *req_buf,
+			    size_t req_buf_size,
+			    void *resp_buf,
+			    size_t *resp_buf_size)
+{
+	return __cmd_submit(wp, chan_id, cmd_id, req_buf, req_buf_size,
+			    NULL, resp_buf, resp_buf_size, true);
+}
+
+/*
+ *
+ */
+static int cmd_submit_check_no_req(struct wifi_priv *wp,
+				   u32 chan_id,
+				   u32 cmd_id,
+				   void *resp_buf,
+				   size_t *resp_buf_size)
+{
+	return __cmd_submit(wp, chan_id, cmd_id, NULL, 0,
+			    NULL, resp_buf, resp_buf_size, true);
+}
+
+/*
+ *
+ */
+static int cmd_submit_check_no_resp(struct wifi_priv *wp,
+				    u32 chan_id,
+				    u32 cmd_id,
+				    const void *req_buf,
+				    size_t req_buf_size)
+{
+	return __cmd_submit(wp, chan_id, cmd_id, req_buf, req_buf_size,
+			    NULL, NULL, 0, false);
+}
+
+
+/*
+ *
+ */
+static int cmd_submit_check_no_req_no_resp(struct wifi_priv *wp,
+					   u32 chan_id,
+					   u32 cmd_id)
+{
+	return __cmd_submit(wp, chan_id, cmd_id, NULL, 0,
+			    NULL, NULL, 0, true);
+}
+
+/*
+ *
+ */
+static void cmd_chan_async_handle_irq(struct wifi_priv *wp)
+{
+	struct wifi_cmd_chan *chan = &wp->cmd_chans[WIFI_CMD_CHAN_ASYNC];
+
+	spin_lock(&chan->complete_lock);
+	if (chan->pending) {
+		__le32 fw_count = ioread32(chan->fw_count_ptr);
+		if (le32_to_cpu(fw_count) == chan->host_count)
+			complete(&chan->completion);
+	}
+	spin_unlock(&chan->complete_lock);
+}
+
+/*
+ *
+ */
+static int cmd_get_api_version(struct wifi_priv *wp,
+			       u32 *api_version)
+{
+	struct wifi_cmd_api_version_resp resp;
+	size_t resp_size = sizeof (resp);
+	int ret;
+
+	ret = cmd_submit_check_no_req(wp,
+				      WIFI_CMD_CHAN_ASYNC,
+				      WIFI_CMD_API_VERSION,
+				      &resp, &resp_size);
+	if (ret)
+		return ret;
+
+	*api_version = le32_to_cpu(resp.version);
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_get_fw_version(struct wifi_priv *wp,
+			      u16 *major,
+			      u16 *minor)
+{
+	struct wifi_cmd_fw_version_resp resp;
+	size_t resp_size = sizeof (resp);
+	int ret;
+
+	ret = cmd_submit_check_no_req(wp, WIFI_CMD_CHAN_ASYNC,
+				      WIFI_CMD_FW_VERSION,
+				      &resp, &resp_size);
+	if (ret)
+		return ret;
+
+	*major = le16_to_cpu(resp.major);
+	*minor = le16_to_cpu(resp.minor);
+	return 0;
+}
+
+/*
+ *
+ */
+static void inc_mac(u8 *base, unsigned int count)
+{
+        unsigned int i;
+
+        for (i = 0; i < count; i++) {
+                int j;
+
+                for (j = 5; j >= 0; j--) {
+                        if (++base[j] != 0)
+                                break;
+                }
+        }
+}
+
+/*
+ *
+ */
+static int cmd_get_mac_address(struct wifi_priv *wp,
+			       struct mac_address *addresses, size_t *count)
+{
+	struct wifi_cmd_get_mac_address_resp resp;
+	size_t resp_size = sizeof (resp);
+	size_t i, hw_count;
+	int ret;
+
+	if (!*count)
+		return -EINVAL;
+
+	ret = cmd_submit_check_no_req(wp, WIFI_CMD_CHAN_ASYNC,
+				      WIFI_CMD_GET_MAC_ADDRESS,
+				      &resp, &resp_size);
+	if (ret)
+		return ret;
+
+	hw_count = le16_to_cpu(resp.mac_addr_count);
+	for (i = 0; i < *count && i < hw_count; i++) {
+		memcpy(addresses[i].addr, resp.mac_addr, 6);
+		inc_mac(addresses[i].addr, i);
+	}
+
+	*count = i;
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_get_chan_survey(struct wifi_priv *wp,
+			       s8 *nf,
+			       u64 *chan_time,
+			       u64 *chan_busy,
+			       u64 *chan_rx,
+			       u64 *chan_tx)
+{
+	struct wifi_cmd_get_chan_survey_resp resp;
+	size_t resp_size = sizeof (resp);
+	int ret;
+
+	ret = cmd_submit_check_no_req(wp, WIFI_CMD_CHAN_ASYNC,
+				      WIFI_CMD_GET_CHAN_SURVEY,
+				      &resp, &resp_size);
+	if (ret)
+		return ret;
+
+	*nf = resp.avg_nf;
+	*chan_time = div_u64(le64_to_cpu(resp.chan_time), 1000);
+	*chan_busy = div_u64(le64_to_cpu(resp.chan_busy), 1000);
+	*chan_rx = div_u64(le64_to_cpu(resp.chan_rx), 1000);
+	*chan_tx = div_u64(le64_to_cpu(resp.chan_tx), 1000);
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_start(struct wifi_priv *wp)
+{
+	struct wifi_cmd_start_req req;
+	size_t i;
+	int ret;
+
+	memset(&req, 0, sizeof (req));
+	req.rx.dma_addr = cpu_to_le32(wp->rxq.descs_dma);
+	req.rx.len = cpu_to_le32(WIFI_RX_DESCS);
+
+	for (i = 0; i < wp->txq_count; i++) {
+		req.tx[i].dma_addr = cpu_to_le32(wp->txqs[i].descs_dma);
+		req.tx[i].len = cpu_to_le32(WIFI_TX_DESCS);
+	}
+
+	ret = cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+				       WIFI_CMD_START,
+				       &req, sizeof (req));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_stop(struct wifi_priv *wp)
+{
+	int ret;
+
+	ret = cmd_submit_check_no_req_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+					      WIFI_CMD_STOP);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_set_rx_filter(struct wifi_priv *wp, u32 filter)
+{
+	struct wifi_cmd_set_rx_filter_req req = {
+		.filter = le32_to_cpu(filter),
+	};
+	int ret;
+
+	ret = cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+				       WIFI_CMD_SET_RX_FILTER,
+				       &req, sizeof (req));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_add_vif(struct wifi_priv *wp,
+		       enum wifi_vif_type type,
+		       const u8 *mac_addr,
+		       __le16 *vif_hwid,
+		       unsigned int *tbtt_idx,
+		       unsigned int ac_mapping[IEEE80211_NUM_ACS],
+		       unsigned int *cab_qid)
+{
+	struct wifi_cmd_add_vif_req req;
+	struct wifi_cmd_add_vif_resp resp;
+	size_t resp_size = sizeof (resp);
+	int ret;
+
+	req.type = type;
+	memcpy(req.mac_addr, mac_addr, sizeof (req.mac_addr));
+
+	ret = cmd_submit_check(wp, WIFI_CMD_CHAN_ASYNC,
+			       WIFI_CMD_ADD_VIF,
+			       &req, sizeof (req),
+			       &resp, &resp_size);
+	if (ret)
+		return ret;
+
+	*vif_hwid = resp.vif_hwid;
+	*tbtt_idx = resp.tbtt_idx;
+	ac_mapping[IEEE80211_AC_BK] = resp.ac_to_qid[WIFI_AC_BK];
+	ac_mapping[IEEE80211_AC_BE] = resp.ac_to_qid[WIFI_AC_BE];
+	ac_mapping[IEEE80211_AC_VO] = resp.ac_to_qid[WIFI_AC_VO];
+	ac_mapping[IEEE80211_AC_VI] = resp.ac_to_qid[WIFI_AC_VI];
+	*cab_qid = resp.cab_qid;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_release_vif(struct wifi_priv *wp,
+			   __le16 vif_hwid)
+{
+	struct wifi_cmd_release_vif_req req = {
+		.vif_hwid = vif_hwid,
+	};
+	int ret;
+
+	ret = cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+				       WIFI_CMD_RELEASE_VIF,
+				       &req, sizeof (req));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_vif_start(struct wifi_priv *wp,
+			 __le16 vif_hwid)
+{
+	struct wifi_cmd_vif_start_req req = {
+		.vif_hwid = vif_hwid,
+	};
+	int ret;
+
+	ret = cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+				       WIFI_CMD_VIF_START,
+				       &req, sizeof (req));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_vif_stop(struct wifi_priv *wp,
+			__le16 vif_hwid)
+{
+	struct wifi_cmd_vif_stop_req req = {
+		.vif_hwid = vif_hwid,
+	};
+	int ret;
+
+	ret = cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+				       WIFI_CMD_VIF_STOP,
+				       &req, sizeof (req));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_vif_set_bss_params(struct wifi_priv *wp,
+				  __le16 vif_hwid,
+				  const uint8_t *bssid)
+{
+	struct wifi_cmd_vif_set_bss_params_req req;
+	int ret;
+
+	req.vif_hwid = vif_hwid;
+	memcpy(req.bssid, bssid, sizeof (req.bssid));
+
+	ret = cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+				       WIFI_CMD_VIF_SET_BSS_PARAMS,
+				       &req, sizeof (req));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_vif_set_short_slot(struct wifi_priv *wp,
+				  __le16 vif_hwid,
+				  bool is_short)
+{
+	struct wifi_cmd_vif_set_short_slot_req req;
+	int ret;
+
+	req.vif_hwid = vif_hwid;
+	req.is_short = is_short;
+
+	ret = cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+				       WIFI_CMD_VIF_SET_SHORT_SLOT,
+				       &req, sizeof (req));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_vif_set_edca_params(struct wifi_priv *wp,
+				   __le16 vif_hwid,
+				   unsigned int txq_idx,
+				   unsigned int cw_min,
+				   unsigned int cw_max,
+				   unsigned int aifsn,
+				   unsigned int txop)
+{
+	struct wifi_cmd_vif_set_edca_params_req req;
+	int ret;
+
+	req.vif_hwid = vif_hwid;
+	req.txq_idx = txq_idx;
+	req.cw_min = le16_to_cpu(cw_min);
+	req.cw_max = le16_to_cpu(cw_max);
+	req.aifsn = le16_to_cpu(aifsn);
+	req.txop = le16_to_cpu(txop);
+
+	ret = cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+				       WIFI_CMD_VIF_SET_EDCA_PARAMS,
+				       &req, sizeof (req));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_vif_set_beacon_params(struct wifi_priv *wp,
+				     __le16 vif_hwid,
+				     unsigned int rate_idx,
+				     unsigned int beacon_int,
+				     unsigned int dtim_period)
+{
+	struct wifi_cmd_vif_set_beacon_params_req req;
+	int ret;
+
+	req.vif_hwid = vif_hwid;
+	req.rate_idx = rate_idx;
+	req.beacon_interval = le16_to_cpu(beacon_int);
+	req.dtim_period = dtim_period;
+
+	ret = cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+				       WIFI_CMD_VIF_SET_BEACON_PARAMS,
+				       &req, sizeof (req));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_vif_enable_beacon(struct wifi_priv *wp,
+				 __le16 vif_hwid,
+				 bool enabled)
+{
+	struct wifi_cmd_vif_enable_beacon_req req;
+	int ret;
+
+	req.vif_hwid = vif_hwid;
+	req.enabled = enabled;
+
+	ret = cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+				       WIFI_CMD_VIF_ENABLE_BEACON,
+				       &req, sizeof (req));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_vif_add_sta(struct wifi_priv *wp,
+			   __le16 vif_hwid,
+			   const u8 *addr,
+			   __le16 *hw_id)
+{
+	struct wifi_cmd_vif_add_sta_req req;
+	struct wifi_cmd_vif_add_sta_resp resp;
+	size_t resp_size = sizeof (resp);
+	int ret;
+
+	req.vif_hwid = vif_hwid;
+	memcpy(req.mac, addr, ETH_ALEN);
+
+	ret = cmd_submit_check(wp, WIFI_CMD_CHAN_ASYNC,
+			       WIFI_CMD_VIF_ADD_STA,
+			       &req, sizeof (req),
+			       &resp, &resp_size);
+	if (ret)
+		return ret;
+
+	*hw_id = resp.sta_hwid;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_vif_del_sta(struct wifi_priv *wp,
+			   __le16 vif_hwid,
+			   unsigned int sta_idx)
+{
+	struct wifi_cmd_vif_del_sta_req req;
+	int ret;
+
+	req.vif_hwid = vif_hwid;
+	req.sta_hwid = cpu_to_le16(sta_idx);
+
+	ret = cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+				       WIFI_CMD_VIF_DEL_STA,
+				       &req, sizeof (req));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_vif_get_dtim_count_atomic(struct wifi_priv *wp,
+					 __le16 vif_hwid,
+					 unsigned int *dtim_count)
+{
+	struct wifi_cmd_vif_get_dtim_count_req req;
+	struct wifi_cmd_vif_get_dtim_count_resp resp;
+	size_t resp_size = sizeof (resp);
+	int ret;
+
+	req.vif_hwid = vif_hwid;
+
+	ret = cmd_submit_check(wp, WIFI_CMD_CHAN_ATOMIC,
+			       WIFI_CMD_VIF_GET_DTIM_COUNT,
+			       &req, sizeof (req),
+			       &resp, &resp_size);
+	if (ret)
+		return ret;
+
+	*dtim_count = resp.dtim_count;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_vif_update_beacon_atomic(struct wifi_priv *wp,
+					__le16 vif_hwid,
+					unsigned int bcn_dma_addr,
+					unsigned int bcn_size)
+{
+	struct wifi_cmd_vif_update_beacon_req req;
+
+	req.vif_hwid = vif_hwid;
+	req.bcn_host_addr = cpu_to_le32(bcn_dma_addr);
+	req.bcn_size = cpu_to_le16(bcn_size);
+
+	return cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ATOMIC,
+					WIFI_CMD_VIF_UPDATE_BEACON,
+					&req, sizeof (req));
+}
+
+/*
+ *
+ */
+static int cmd_vif_add_key(struct wifi_priv *wp,
+			   __le16 vif_hwid,
+			   __le16 sta_hwid,
+			   unsigned int key_idx,
+			   const u8 *key,
+			   u8 *hw_id)
+{
+	struct wifi_cmd_vif_add_key_req req;
+	struct wifi_cmd_vif_add_key_resp resp;
+	size_t resp_size = sizeof (resp);
+	int ret;
+
+	req.vif_hwid = vif_hwid;
+	req.sta_hwid = sta_hwid;
+	req.key_idx = key_idx;
+	memcpy(req.key, key, sizeof (req.key));
+
+	ret = cmd_submit_check(wp, WIFI_CMD_CHAN_ASYNC,
+			       WIFI_CMD_VIF_ADD_KEY,
+			       &req, sizeof (req),
+			       &resp, &resp_size);
+	if (ret)
+		return ret;
+
+	*hw_id = resp.key_hwid;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int cmd_vif_del_key(struct wifi_priv *wp,
+			   __le16 vif_hwid,
+			   __le16 sta_hwid,
+			   u8 hw_id)
+{
+	struct wifi_cmd_vif_del_key_req req;
+	int ret;
+
+	req.vif_hwid = vif_hwid;
+	req.sta_hwid = sta_hwid;
+	req.key_hwid = hw_id;
+
+	ret = cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+				       WIFI_CMD_VIF_DEL_KEY,
+				       &req, sizeof (req));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ *
+ */
+static int freq_to_idx(struct ieee80211_hw *hw, int freq)
+{
+	struct ieee80211_supported_band *sband;
+	int band, ch, idx = 0;
+
+	for (band = NL80211_BAND_2GHZ; band < NUM_NL80211_BANDS; band++) {
+		sband = hw->wiphy->bands[band];
+		if (!sband)
+			continue;
+
+		for (ch = 0; ch < sband->n_channels; ch++, idx++)
+			if (sband->channels[ch].center_freq == freq)
+				goto exit;
+	}
+
+exit:
+	return idx;
+}
+
+/*
+ *
+ */
+static int wifi_set_channel(struct wifi_priv *wp)
+{
+	struct ieee80211_hw *hw = wp->hw;
+	const struct cfg80211_chan_def *chandef = &hw->conf.chandef;
+	const struct ieee80211_channel *channel = chandef->chan;
+        enum nl80211_chan_width width = chandef->width;
+	struct wifi_cmd_radio_control_req req;
+	int ret;
+
+	req.channel = channel->hw_value;
+
+	switch (width) {
+	case NL80211_CHAN_WIDTH_20_NOHT:
+        case NL80211_CHAN_WIDTH_20:
+		req.bw = WIFI_CHAN_BW_20MHZ;
+		break;
+        case NL80211_CHAN_WIDTH_40:
+		req.bw = 40;
+		if (channel->center_freq > chandef->center_freq1)
+			req.bw = WIFI_CHAN_BW_40MHZ_BELOW;
+		else
+			req.bw = WIFI_CHAN_BW_40MHZ_ABOVE;
+		break;
+	default:
+		return -ENOTSUPP;
+	}
+
+	ret = cmd_submit_check_no_resp(wp, WIFI_CMD_CHAN_ASYNC,
+				       WIFI_CMD_RADIO_CONTROL,
+				       &req, sizeof (req));
+	if (ret)
+		return ret;
+
+	wp->cur_chan_idx = freq_to_idx(hw, channel->center_freq);
+	return 0;
+}
+
+/*
+ *
+ */
+static int wifi_rxq_refill(struct wifi_priv *wp, int limit)
+{
+	struct wifi_rxq *rxq = &wp->rxq;
+	int refilled;
+
+	refilled = 0;
+	while (rxq->count < WIFI_RX_DESCS && limit--) {
+		struct sk_buff *skb;
+		struct wifi_rxd *rxd;
+		dma_addr_t addr;
+		u32 cur;
+
+		skb = dev_alloc_skb(WIFI_RX_BUF_SIZE);
+		if (skb == NULL)
+			break;
+
+		addr = pci_map_single(wp->pdev, skb->data,
+				      WIFI_RX_BUF_SIZE, DMA_FROM_DEVICE);
+
+		if (pci_dma_mapping_error(wp->pdev, addr)) {
+			dev_kfree_skb(skb);
+			break;
+		}
+
+		cur = rxq->refill_off;
+
+		rxq->bufs[cur].skb = skb;
+		dma_unmap_addr_set(&rxq->bufs[cur], dma, addr);
+
+		rxd = &rxq->descs[cur];
+		rxd->buf_addr = cpu_to_le32(addr);
+		rxd->buf_size = cpu_to_le16(WIFI_RX_BUF_SIZE);
+		wmb();
+		rxd->status = cpu_to_le16(RXD_F_FW_OWNED);
+
+		rxq->refill_off++;
+		if (rxq->refill_off == WIFI_RX_DESCS)
+			rxq->refill_off = 0;
+
+		rxq->count++;
+		refilled++;
+	}
+
+	return refilled;
+}
+
+/*
+ *
+ */
+static int wifi_process_rx(struct wifi_priv *wp, int limit)
+{
+	struct wifi_rxq *rxq = &wp->rxq;
+	int processed;
+
+	processed = 0;
+	while (rxq->count && limit--) {
+		struct sk_buff *skb;
+		struct wifi_rxd *rxd;
+		struct ieee80211_rx_status *rx_stat;
+		unsigned int len;
+		u16 rxd_status;
+		u32 cur;
+
+		cur = rxq->fw_off;
+		rxd = &rxq->descs[cur];
+		rmb();
+
+		rxd_status = le16_to_cpu(rxd->status);
+		if (rxd_status & RXD_F_FW_OWNED)
+			break;
+
+		pci_unmap_single(wp->pdev,
+				 dma_unmap_addr(&rxq->bufs[cur], dma),
+				 WIFI_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
+		dma_unmap_addr_set(&rxq->bufs[cur], dma, 0);
+
+		skb = rxq->bufs[cur].skb;
+		BUG_ON(!skb);
+		rxq->bufs[cur].skb = NULL;
+
+		len = le16_to_cpu(rxd->buf_size);
+		if (!len || len > WIFI_RX_BUF_SIZE) {
+			dev_err(wp->dev, "bad desc RX len: %u\n", len);
+			dev_kfree_skb(skb);
+			goto skip;
+		}
+
+		skb_put(skb, len);
+
+		/* fill rx status */
+		rx_stat = IEEE80211_SKB_RXCB(skb);
+		if (rxd_status & RXD_F_HT) {
+			rx_stat->rate_idx = rxd->rate;
+			rx_stat->encoding = RX_ENC_HT;
+		} else {
+			bool is_cck = rxd_status & RXD_F_CCK;
+			rx_stat->rate_idx = wifi_rxd_rate_to_rate(rxd->rate,
+								  is_cck);
+			rx_stat->encoding = RX_ENC_LEGACY;
+		}
+
+		if (!(rxd_status & RXD_F_FCS_VALID))
+			rx_stat->flag |= RX_FLAG_FAILED_FCS_CRC;
+
+		if (rxd_status & RXD_F_SHORT_PREAMBLE)
+			rx_stat->enc_flags |= RX_ENC_FLAG_SHORTPRE;
+
+		if (rxd_status & RXD_F_SHORT_GI)
+			rx_stat->enc_flags |= RX_ENC_FLAG_SHORT_GI;
+
+		if (rxd_status & RXD_F_DECRYPTED)
+			rx_stat->flag |= RX_FLAG_DECRYPTED;
+
+		rx_stat->band = 0;
+		rx_stat->freq =
+			ieee80211_channel_to_frequency(rxd->channel,
+						       NL80211_BAND_2GHZ);
+		rx_stat->signal = rxd->rssi;
+		rx_stat->chains = (1 << wp->hw_radio_chains) - 1;
+		BUILD_BUG_ON(sizeof (rx_stat->chain_signal) !=
+			     sizeof (rxd->rssi_per_chain));
+		memcpy(rx_stat->chain_signal, rxd->rssi_per_chain,
+		       sizeof (rx_stat->chain_signal));
+
+		ieee80211_rx(wp->hw, skb);
+
+	skip:
+		processed++;
+		rxq->count--;
+		rxq->fw_off++;
+		if (rxq->fw_off == WIFI_RX_DESCS)
+			rxq->fw_off = 0;
+	}
+
+	return processed;
+}
+
+/*
+ * release wifi_skb wrapper fields (not the wrapper itself) and return
+ * it to the pool
+ */
+static void __wifi_tx_skb_release(struct wifi_priv *wp,
+				  struct wifi_tx_skb *wskb,
+				  bool tx_failed,
+				  bool skip_skb_free)
+{
+	txdbg("wifi_tx_skb_release wskb:%ps seq:%u failed:%d skip_free:%d\n",
+	      wskb, wskb->seq_no, tx_failed, skip_skb_free);
+
+	pci_unmap_single(wp->pdev,
+			 dma_unmap_addr(wskb, skb_dma),
+			 dma_unmap_len(wskb, skb_len),
+			 PCI_DMA_TODEVICE);
+	dma_unmap_addr_set(wskb, skb_dma, 0);
+	list_add(&wskb->next, &wskb->txq->wifi_tx_skbs_pool);
+	if (!skip_skb_free) {
+		if (tx_failed)
+			ieee80211_free_txskb(wp->hw, wskb->skb);
+		else
+			dev_kfree_skb(wskb->skb);
+	}
+}
+
+static void wifi_tx_skb_release_txfail(struct wifi_priv *wp,
+				       struct wifi_tx_skb *wskb)
+{
+	__wifi_tx_skb_release(wp, wskb, true, false);
+}
+
+static void wifi_tx_skb_release_keep_skb(struct wifi_priv *wp,
+					 struct wifi_tx_skb *wskb)
+{
+	__wifi_tx_skb_release(wp, wskb, true, true);
+}
+
+/*
+ *
+ */
+static int fill_hw_offsets(const struct ieee80211_hdr *d11, struct wifi_txd *txd)
+{
+	__le16 fc = d11->frame_control;
+
+	if (ieee80211_is_data(fc)) {
+		unsigned int hdr_size;
+
+		bool has_qos = ieee80211_is_data_qos(fc);
+
+		if (ieee80211_has_a4(fc)) {
+			hdr_size = 30;
+			txd->addr_count = 4;
+		} else {
+			hdr_size = 24;
+			txd->addr_count = 3;
+		}
+
+		txd->has_qos_control = has_qos;
+		if (has_qos)
+			memcpy(&txd->qos_control, (u8 *)d11 + hdr_size,
+			       IEEE80211_QOS_CTL_LEN);
+
+		txd->data_offset = !has_qos ? hdr_size : hdr_size +
+			IEEE80211_QOS_CTL_LEN;
+		return 0;
+	}
+
+	if (ieee80211_is_mgmt(fc)) {
+		txd->addr_count = 3;
+		txd->data_offset = 24;
+		txd->has_qos_control = 0;
+		return 0;
+	}
+
+	if (ieee80211_is_ctl(fc)) {
+		if ((fc & cpu_to_le16(0x00E0)) == cpu_to_le16(0x00C0)) {
+			/* cannot send one address type */
+			return 1;
+		}
+
+		txd->addr_count = 2;
+		txd->data_offset = 16;
+		txd->has_qos_control = 0;
+		return 0;
+	}
+
+	return 1;
+}
+
+/*
+ * allocate (from fixed pool) and fill skb wrapper we use inside tx
+ * path
+ */
+static struct wifi_tx_skb *wifi_tx_skb_wrap(struct wifi_priv *wp,
+					    struct wifi_txq *txq,
+					    struct sk_buff *skb,
+					    struct ieee80211_sta *sta,
+					    int tid)
+{
+	const struct ieee80211_hdr *d11;
+	struct wifi_tx_skb *wskb;
+	struct ieee80211_tx_info *info;
+	struct ieee80211_key_conf *hw_key;
+	struct wifi_vif *wifi_vif;
+	struct wifi_sta *wifi_sta;
+	struct wifi_txd *txdesc;
+	dma_addr_t dma;
+	u16 frame_len;
+
+	txdbg("wifi_tx_skb_wrap: skb:%pS len:%u sta:%pM\n",
+	      skb, skb->len, sta ? sta->addr : NULL);
+
+	/* we should always have something in the pool, it is pre
+	 * allocated with the same size as txq, and we make sure to
+	 * stop sending before queue becomes full */
+	if (WARN_ON(list_empty(&txq->wifi_tx_skbs_pool)))
+		return NULL;
+
+	info = IEEE80211_SKB_CB(skb);
+	hw_key = info->control.hw_key;
+
+	wskb = list_first_entry(&txq->wifi_tx_skbs_pool,
+				struct wifi_tx_skb,
+				next);
+	wskb->sw_tries_done = 0;
+	wskb->txq = txq;
+
+	frame_len = skb->len + FCS_LEN;
+	if (hw_key)
+		frame_len += hw_key->icv_len;
+	wskb->frame_len = frame_len;
+
+	/* lookup sta & vif, we need to write their hw id inside descriptor */
+	wifi_sta = NULL;
+	if (sta) {
+		wifi_sta = WIFI_STA(sta);
+		wskb->sta_version = wifi_sta->version;
+	}
+
+	wifi_vif = NULL;
+	if (info->control.vif)
+		wifi_vif = WIFI_VIF(info->control.vif);
+
+	/*
+	 * precompute invariant tx descriptor fields
+	 */
+	d11 = (const struct ieee80211_hdr *)skb->data;
+	txdesc = &wskb->txdesc;
+
+	if (fill_hw_offsets(d11, txdesc)) {
+		/* should not happen unless raw frame injection */
+		wiphy_err(wp->hw->wiphy, "hardware cannot send such frame\n");
+		return NULL;
+	}
+
+	if (WARN_ON(skb->len < txdesc->data_offset)) {
+		/* catch strange packets */
+		return NULL;
+	}
+
+	txdesc->data_size = cpu_to_le16(skb->len - txdesc->data_offset);
+	txdesc->sta_hwid = wifi_sta ? wifi_sta->hw_id : WIFI_INVALID_STA_HWID;
+	txdesc->vif_hwid = wifi_vif ? wifi_vif->hw_id : WIFI_INVALID_VIF_HWID;
+	txdesc->key_hwid = hw_key ? hw_key->hw_key_idx : WIFI_INVALID_KEY_HWID;
+
+	if (hw_key) {
+		u64 pn64 = atomic64_inc_return(&hw_key->tx_pn);
+		memcpy(&txdesc->ccmp_pn, &pn64, 8);
+	}
+
+	txdesc->status = TXD_F_FW_OWNED;
+
+	if (is_multicast_ether_addr(d11->addr1) ||
+	    (info->flags & IEEE80211_TX_CTL_NO_ACK))
+		txdesc->status |= TXD_F_TX_NO_ACK;
+
+	if (info->flags & IEEE80211_TX_CTL_STBC)
+		txdesc->status |= TXD_F_TX_STBC;
+
+	/* tid is used to find back wifi_tid at tx completion and do
+	 * proper STA tx accounting */
+	if (tid == -1) {
+		wskb->has_tid = false;
+		wskb->tid = 0;
+	} else {
+		if (WARN_ON(!sta))
+			return NULL;
+
+		wskb->has_tid = true;
+		wskb->tid = tid;
+
+		/* is_data_present is needed to exclude null func
+		 * frames, which have no valid sequence number and are
+		 * sent on another TID */
+		if (ieee80211_is_data_present(d11->frame_control) &&
+		    ieee80211_is_data_qos(d11->frame_control)) {
+
+			if (info->flags & IEEE80211_TX_INTFL_RETRANSMISSION) {
+				WARN(1, "QOS data frame restranmisted by stack\n");
+				return NULL;
+			}
+
+
+			wskb->type = WIFI_TXSKB_QOS_DATA;
+			wskb->seq_no =
+				(le16_to_cpu(d11->seq_ctrl) &
+				 IEEE80211_SCTL_SEQ) >>
+				IEEE80211_SEQ_SEQ_SHIFT;
+			txdesc->tid = wskb->tid;
+			WARN_ON(tid == IEEE80211_NUM_TIDS);
+
+		} else if (ieee80211_is_back_req(d11->frame_control)) {
+			const struct ieee80211_bar *bar;
+			u16 bar_tid;
+
+			/* BAR frames must be tagged */
+			bar = (const struct ieee80211_bar *)skb->data;
+			bar_tid = le16_to_cpu(bar->control) >>
+				IEEE80211_BAR_CTRL_TID_INFO_SHIFT;
+			wskb->type = WIFI_TXSKB_BAR;
+			wskb->bar_tid = bar_tid;
+
+			txdesc->status |= TXD_F_TX_BAR;
+			txdesc->tid = wskb->bar_tid;
+		} else
+			wskb->type = WIFI_TXSKB_OTHER;
+	}
+
+	/* map skb */
+	dma = pci_map_single(wp->pdev, skb->data, skb->len, PCI_DMA_TODEVICE);
+	if (pci_dma_mapping_error(wp->pdev, dma)) {
+		wiphy_err(wp->hw->wiphy, "failed to dma map skb\n");
+		return NULL;
+	}
+
+	wskb->skb = skb;
+	dma_unmap_addr_set(wskb, skb_dma, dma);
+	dma_unmap_len_set(wskb, skb_len, skb->len);
+	txdesc->buf_addr = cpu_to_le32(dma);
+
+	/* remove from pool list */
+	list_del(&wskb->next);
+	txdbg("wifi_tx_skb_wrap: returned %ps, has_tid:%d tid:%d type:%u seq:%u\n",
+	      wskb, wskb->has_tid, wskb->tid, wskb->type, wskb->seq_no);
+	return wskb;
+}
+
+/*
+ *
+ */
+static void wifi_tx_skb_inc_sw_tries(struct wifi_priv *wp,
+				     struct wifi_tx_skb *wskb)
+{
+	struct ieee80211_hdr *hdr;
+
+	++wskb->sw_tries_done;
+	if (wskb->sw_tries_done == 1 || wskb->sw_tries_done > 2)
+		return;
+
+	/* set the retry bit and header, update cache */
+	hdr = (struct ieee80211_hdr *)wskb->skb->data;
+	hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_RETRY);
+	pci_dma_sync_single_for_device(wp->pdev,
+				       dma_unmap_addr(wskb, skb_dma),
+				       sizeof (*hdr), DMA_TO_DEVICE);
+}
+
+/*
+ *
+ */
+static void wifi_tx_skb_set_more_data(struct wifi_priv *wp,
+				      struct wifi_tx_skb *wskb,
+				      bool more_data)
+{
+	struct ieee80211_hdr *hdr;
+
+	hdr = (struct ieee80211_hdr *)wskb->skb->data;
+	hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA);
+	pci_dma_sync_single_for_device(wp->pdev,
+				       dma_unmap_addr(wskb, skb_dma),
+				       sizeof (*hdr), DMA_TO_DEVICE);
+}
+
+/*
+ *
+ */
+static void wifi_tx_skb_fill_rates(struct wifi_tx_skb *wskb,
+				   struct ieee80211_vif *vif,
+				   struct ieee80211_sta *sta)
+{
+	struct ieee80211_tx_info *info;
+	struct wifi_txd *txdesc;
+	size_t i;
+
+	txdbg("wifi_tx_skb_fill_rates: wskp:%ps sta:%ps\n", wskb, sta);
+	/* we use tx_info to store rates */
+	info = IEEE80211_SKB_CB(wskb->skb);
+	ieee80211_get_tx_rates(vif,
+			       sta,
+			       wskb->skb,
+			       info->control.rates,
+			       ARRAY_SIZE(info->control.rates));
+
+	WARN_ON_ONCE(info->control.rates[0].idx < 0);
+
+	txdesc = &wskb->txdesc;
+	for (i = 0; i < WIFI_TXD_MAX_RATES; i++) {
+		const struct ieee80211_tx_rate *r = &info->control.rates[i];
+		struct wifi_txd_rinfo *txr = &txdesc->rinfo[i];
+
+		if (r->idx == -1) {
+			/* make sure to clear to mark end of list,
+			 * since this can be called multiple times on
+			 * same wskb */
+			txr->flags = 0;
+			break;
+		}
+
+		txdbg("fill rate[%zu]: idx:%u ht:%d count:%d\n",
+		       i,
+		       r->idx, !!(r->flags & IEEE80211_TX_RC_MCS), r->count);
+
+		txr->flags = TXD_RF_VALID;
+
+		if (r->flags & IEEE80211_TX_RC_USE_RTS_CTS)
+			txr->flags |= TXD_RF_RTS_CTS;
+		else if (r->flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
+			txr->flags |= TXD_RF_CTS_PROTECT;
+
+		if ((r->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE))
+			txr->flags |= TXD_RF_SHORT_PRE;
+
+		if (!(r->flags & IEEE80211_TX_RC_MCS))
+			txr->rate = mwl8k_rates[r->idx].hw_value;
+		else {
+			txr->rate = r->idx;
+			txr->flags |= TXD_RF_HT;
+			if ((r->flags & IEEE80211_TX_RC_SHORT_GI))
+				txr->flags |= TXD_RF_SHORT_GI;
+			if ((r->flags & IEEE80211_TX_RC_40_MHZ_WIDTH))
+				txr->flags |= TXD_RF_40MHZ;
+		}
+
+		txr->count = r->count;
+		txr->antenna_mask = 0;
+	}
+}
+
+/*
+ * queue a chain of packets into the hardware tx queue, chain is not
+ * valid after call if packets have been successfully queued
+ *
+ * for A-MPDU, first tx desc must have the following fields:
+ *   - ampdu_density
+ *   - ampdu_baw_ssn
+ *
+ * caller must hold the txq lock and sta lock
+ */
+static int wifi_tx_send_chain(struct wifi_priv *wp,
+			      struct list_head *chain,
+			      size_t chain_count,
+			      bool form_aggr,
+			      struct ieee80211_sta *sta,
+			      bool bypass_ps)
+{
+	struct wifi_tx_skb *wskb;
+	struct wifi_txq *wifi_txq;
+	struct wifi_txd *first_txdesc;
+	__le32 first_desc_status;
+	bool clear_ps;
+	/* int tid = -1; */
+
+	/* if (chain_count > 1) { */
+	/* 	printk("SEND CHAIN count:%d\n", chain_count); */
+
+	/* 	list_for_each_entry(wskb, chain, next) { */
+	/* 		printk(" - member: frame_len:%u " */
+	/* 		       "addr_count:%u data_size:%u data_offset:%u has_qos:%d\n", */
+	/* 		       wskb->skb->len, */
+	/* 		       wskb->txdesc.addr_count, */
+	/* 		       wskb->txdesc.data_size, */
+	/* 		       wskb->txdesc.data_offset, */
+	/* 		       wskb->txdesc.has_qos_control); */
+	/* 	} */
+	/* } */
+
+	if (WARN_ON(!chain_count))
+		return 1;
+
+	wskb = list_first_entry(chain, struct wifi_tx_skb, next);
+
+	wifi_txq = wskb->txq;
+	WARN_ON(wifi_txq->idx == 6);
+	lockdep_assert_held(&wifi_txq->lock);
+
+	txdbg("wifi_tx_send_chain: chain_count:%zu aggr:%d sta:%pM "
+	      "bypass_ps:%d txq_count:%d\n",
+	      chain_count, form_aggr, sta ? sta->addr : NULL, bypass_ps,
+	      wifi_txq->count);
+
+	if (WARN_ON(wifi_txq->count + chain_count > WIFI_TX_DESCS))
+		return 1;
+
+	/*
+	 * if traffic if for a STA, and is not sent during the service
+	 * period, we will clear the hardware PS filter if needed
+	 */
+	clear_ps = false;
+	if (sta && !bypass_ps)
+		clear_ps = atomic_dec_and_test(&WIFI_STA(sta)->clear_ps_filter);
+
+	if (clear_ps) {
+		/* printk("wifi_tx_send_chain: sta %pM will clear ps\n", */
+		/*       sta->addr); */
+	}
+
+	/*
+	 * tx pending accounting for this tid
+	 */
+	if (sta && wskb->has_tid) {
+		struct wifi_sta *wifi_sta = WIFI_STA(sta);
+
+		lockdep_assert_held(&wifi_sta->lock);
+
+		wifi_sta->tx_pending += chain_count;
+		txdbg("wifi_tx_send_chain: sta %pM tx pending now %d\n",
+		      sta->addr, wifi_sta->tx_pending);
+		/* tid = wskb->tid; */
+	}
+
+	first_txdesc = NULL;
+	list_for_each_entry(wskb, chain, next) {
+		struct wifi_txd *txdesc;
+		u32 cur_off;
+
+		txdbg("wifi_tx_send_chain: wskb:%ps has_tid:%d tid:%d type:%d seq:%u\n",
+		      wskb, wskb->has_tid, wskb->tid, wskb->type, wskb->seq_no);
+
+		/* raise number of total tries for this skb, it will
+		 * update the retry bit in 802.11 header if needed */
+		wifi_tx_skb_inc_sw_tries(wp, wskb);
+
+		/*
+		 * most tx desc fields have been pre-computed, clear
+		 * any previous transient flags in case we resend that
+		 * frame
+		*/
+		wskb->txdesc.status &= ~(TXD_F_TX_AMPDU_START |
+					 TXD_F_TX_AMPDU_MORE |
+					 TXD_F_TX_AMPDU_LAST |
+					 TXD_F_TX_CLEAR_PS |
+					 TXD_F_TX_BYPASS_PS);
+
+		/*
+		 * setup powersave & AMPDU flags in tx desc
+		 */
+		if (clear_ps) {
+			wskb->txdesc.status |= TXD_F_TX_CLEAR_PS;
+			clear_ps = false;
+		}
+
+		if (bypass_ps)
+			wskb->txdesc.status |= TXD_F_TX_BYPASS_PS;
+
+		if (form_aggr) {
+			u32 ampdu_flags = 0;
+
+			if (list_is_first(&wskb->next, chain)) {
+				ampdu_flags |= TXD_F_TX_AMPDU_START;
+				wifi_txq->aggr_count++;
+			}
+			if (list_is_last(&wskb->next, chain)) {
+				ampdu_flags |= TXD_F_TX_AMPDU_LAST;
+			}
+			if (!ampdu_flags)
+				ampdu_flags |= TXD_F_TX_AMPDU_MORE;
+
+			wskb->txdesc.status |= ampdu_flags;
+			wskb->aggr_member = true;
+			INIT_LIST_HEAD(&wskb->aggr_list);
+		} else {
+			wskb->aggr_member = false;
+			wifi_txq->non_aggr_count++;
+		}
+
+		/* update memory-mapped descriptor */
+		cur_off = wifi_txq->head_off;
+		txdesc = &wifi_txq->descs[cur_off];
+
+		if (!first_txdesc) {
+			/* first descriptor of list, memcpy all but
+			 * status field status field so transmission
+			 * does not start now */
+			BUILD_BUG_ON(offsetof(struct wifi_txd, status));
+			memcpy((void *)txdesc + sizeof (txdesc->status),
+			       (void *)&wskb->txdesc + sizeof (txdesc->status),
+			       sizeof (*txdesc) - sizeof (txdesc->status));
+
+			/* remember status */
+			first_txdesc = txdesc;
+			first_desc_status = wskb->txdesc.status;
+			BUG_ON(first_txdesc->status & TXD_F_FW_OWNED);
+		} else
+			memcpy(txdesc, &wskb->txdesc, sizeof (*txdesc));
+
+		wifi_txq->pending_wskb[cur_off] = wskb;
+		cur_off++;
+		if (cur_off >= WIFI_TX_DESCS)
+			cur_off = 0;
+
+		wifi_txq->head_off = cur_off;
+		wifi_txq->count++;
+	}
+
+	if (form_aggr) {
+		struct wifi_tx_skb *last_wskb;
+
+		/* transfer whole chain in last entry */
+		last_wskb = list_last_entry(chain, struct wifi_tx_skb, next);
+		list_splice(chain, &last_wskb->aggr_list);
+	}
+
+	/* if (sta && tid != -1) { */
+	/* 	struct wifi_tid *wifi_tid = WIFI_TID(sta->txq[tid]); */
+
+	/* 	printk("tx: agg:%u cnt:%d (pnd now aggr:%d nagg:%d) seq:%d\n", */
+	/* 	       form_aggr, chain_count, */
+	/* 	       wifi_txq->aggr_count, */
+	/* 	       wifi_txq->non_aggr_count, */
+	/* 	       wifi_tid->seq_start); */
+	/* } */
+
+	/* all set, start tx */
+	wmb();
+	first_txdesc->status = first_desc_status;
+	mwl8k_raise_fw_irq(wp->priv, 1 << (wifi_txq->idx + wp->tx_h2f_irq_shift));
+
+	return 0;
+}
+
+/*
+ * return actually used size in BAW, ie number of in-flight packets
+ * seen from the receiver
+ */
+static inline size_t
+wifi_tid_baw_tracked_size(const struct wifi_tid *wifi_tid)
+{
+	if (wifi_tid->scb_tail >= wifi_tid->scb_head)
+		return wifi_tid->scb_tail - wifi_tid->scb_head;
+
+	return WIFI_SCB_MAX - wifi_tid->scb_head + wifi_tid->scb_tail;
+}
+
+/*
+ * return available space BAW
+ */
+static inline size_t
+wifi_tid_baw_space(const struct wifi_tid *wifi_tid)
+{
+	size_t tracked;
+
+	tracked = wifi_tid_baw_tracked_size(wifi_tid);
+	if (tracked > wifi_tid->baw_max_size) {
+		/* this is allowed if the BAW max size is shrinked,
+		 * can happen when enabling aggregation */
+		return 0;
+	}
+
+	return wifi_tid->baw_max_size - tracked;
+}
+
+/*
+ * check if sequence is being tracked by block ack window
+ */
+static inline bool
+wifi_tid_baw_tracks_seqno(const struct wifi_tid *wifi_tid,
+			  unsigned int seq_no)
+{
+	unsigned int delta;
+
+	delta = (seq_no - wifi_tid->seq_start) & 0xfff;
+	return delta < wifi_tid_baw_tracked_size(wifi_tid);
+}
+
+/*
+ * return next sequence number just after last one being tracked by
+ * block ack window
+ */
+static inline u16
+wifi_tid_baw_next_seqno(const struct wifi_tid *wifi_tid)
+{
+	size_t count = wifi_tid_baw_tracked_size(wifi_tid);
+	u16 last;
+
+	last = wifi_tid->seq_start + count;
+	last &= 0xfff;
+	return last;
+}
+
+/*
+ * return true if there are packet being tracked by BAW currently
+ * being transmitted
+ */
+static inline bool
+wifi_tid_baw_has_inflight_packets(const struct wifi_tid *wifi_tid)
+{
+	return (wifi_tid->scb_inflight_count > 0);
+}
+
+/*
+ * called after any change that could affect "global" ps state
+ *
+ * must be called holding STA lock
+ */
+static void wifi_sta_ps_transition(struct ieee80211_hw *hw,
+				   struct ieee80211_sta *sta,
+				   enum wifi_ps_action action)
+{
+	struct wifi_sta *wifi_sta;
+	struct wifi_tid *wifi_tid;
+	size_t tidno;
+
+	wifi_sta = WIFI_STA(sta);
+	lockdep_assert_held(&wifi_sta->lock);
+
+	psdbg("wifi_sta_ps_transition: %pM cur_state:%d action:%d\n",
+	      sta->addr, wifi_sta->ps_state, action);
+
+again:
+	switch (wifi_sta->ps_state) {
+	case WIFI_PS_AWAKE:
+		if (WARN_ON(action && action != WIFI_PS_ACTION_SLEEP))
+			break;
+
+		wifi_sta->ps_state = WIFI_PS_ENTER_SLEEP;
+		action = WIFI_PS_ACTION_NONE;
+		ieee80211_sta_block_awake(hw, sta, true);
+		goto again;
+
+	case WIFI_PS_ENTER_SLEEP:
+		if (WARN_ON(action &&
+			    (action != WIFI_PS_ACTION_TXDONE &&
+			     action != WIFI_PS_ACTION_SLEEP))) {
+			psdbg("wifi_sta_ps_transition: wtf, "
+			      "state is enter sleep, action is :%d\n",
+			      action);
+			break;
+		}
+
+		/* wait until all TID has no more data packets in
+		 * flight */
+		if (wifi_sta->tx_pending) {
+			psdbg("wifi_sta_ps_transition: tx "
+			      "still pending (%u packets)\n",
+			      wifi_sta->tx_pending);
+			break;
+		}
+
+		if (action == WIFI_PS_ACTION_SLEEP)
+			break;
+
+		for (tidno = 0; tidno < IEEE80211_NUM_TIDS + 1; tidno++) {
+			wifi_tid = WIFI_TID(sta->txq[tidno]);
+			if (wifi_tid_baw_has_inflight_packets(wifi_tid)) {
+				ieee80211_sta_set_buffered(sta, tidno, true);
+				psdbg("entering ps with has_buf (%d)\n",
+				      wifi_tid->scb_inflight_count);
+				wifi_tid->ps_sleep_has_buf = true;
+			} else
+				wifi_tid->ps_sleep_has_buf = false;
+		}
+
+		/* done */
+		wifi_sta->ps_state = WIFI_PS_SLEEP;
+		psdbg("=> now asleep\n");
+		ieee80211_sta_block_awake(hw, sta, false);
+		break;
+
+	case WIFI_PS_SLEEP:
+		if (action == WIFI_PS_ACTION_SLEEP) {
+			/*
+			 * this can happen:
+			 *
+			 * sta_ps_start()
+			 * sta_notify(SLEEP)
+			 * driver calls ieee80211_sta_block_awake(true)
+			 * sta_ps_end()
+			 * WLAN_STA_PS_DRIVER is set, just clear PS_STA
+			 * driver calls ieee80211_sta_block_awake(false)
+			 * schedule deliver work queue
+			 * sta_ps_start()
+			 * sta_notify(SLEEP) again
+			 */
+			break;
+		}
+
+		if (WARN_ON(action && action != WIFI_PS_ACTION_WAKEUP))
+			break;
+
+		/* make sure mac80211 will resched all STA itxq */
+		atomic_set(&wifi_sta->clear_ps_filter, 1);
+		for (tidno = 0; tidno < IEEE80211_NUM_TIDS + 1; tidno++) {
+			wifi_tid = WIFI_TID(sta->txq[tidno]);
+			if (wifi_tid_baw_has_inflight_packets(wifi_tid))
+				ieee80211_schedule_txq(hw, TID2ITXQ(wifi_tid));
+		}
+
+		wifi_sta->ps_state = WIFI_PS_AWAKE;
+		psdbg("=> now awake\n");
+		break;
+	}
+
+	/* printk("wifi_sta_ps_transition: new_state:%d\n", wifi_sta->ps_state); */
+}
+
+/*
+ * called when TID has no more inflight packet
+ */
+static void wifi_tid_ps_has_no_more_buffer(struct wifi_tid *wifi_tid)
+{
+	struct ieee80211_txq *itxq = TID2ITXQ(wifi_tid);
+	struct wifi_sta *wifi_sta = WIFI_STA(itxq->sta);
+
+	if (!wifi_tid->ps_sleep_has_buf)
+		return;
+
+	if (wifi_sta->ps_state != WIFI_PS_SLEEP)
+		return;
+
+	psdbg("wifi_tid_ps_recheck: sta:%pM no more bufferd\n",
+	      itxq->sta->addr);
+	ieee80211_sta_set_buffered(itxq->sta, itxq->tid, false);
+	wifi_tid->ps_sleep_has_buf = false;
+}
+
+/*
+ * dump BAW (debug)
+ */
+static void wifi_tid_baw_print(struct wifi_tid *wifi_tid)
+{
+	u32 end = wifi_tid->seq_start + wifi_tid_baw_tracked_size(wifi_tid);
+	end &= 0xfff;
+
+	badbg("baw: max_size:%u tracked:%zu seq_start:%u => %u head:%u tail:%u inflight:%u\n",
+	      wifi_tid->baw_max_size,
+	      wifi_tid_baw_tracked_size(wifi_tid),
+	      wifi_tid->seq_start,
+	      end,
+	      wifi_tid->scb_head,
+	      wifi_tid->scb_tail,
+	      wifi_tid->scb_inflight_count);
+}
+
+static void wifi_tid_baw_print_nodebug(struct wifi_tid *wifi_tid)
+{
+	u32 end = wifi_tid->seq_start + wifi_tid_baw_tracked_size(wifi_tid);
+	end &= 0xfff;
+
+	printk("baw: max_size:%u tracked:%zu seq_start:%u => %u head:%u tail:%u inflight:%u\n",
+	       wifi_tid->baw_max_size,
+	       wifi_tid_baw_tracked_size(wifi_tid),
+	       wifi_tid->seq_start,
+	       end,
+	       wifi_tid->scb_head,
+	       wifi_tid->scb_tail,
+	       wifi_tid->scb_inflight_count);
+}
+
+/*
+ * actually send the BAR
+ */
+static void wifi_tid_send_bar(struct wifi_tid *wifi_tid, int seq_no)
+{
+	struct ieee80211_txq *itxq = TID2ITXQ(wifi_tid);
+
+	badbg("wifi_tid_send_bar: seq_no:%d\n", seq_no);
+
+	/* NB: this re-enter driver via drv_tx_queue() */
+	ieee80211_send_bar_sta(itxq->sta,
+			       itxq->tid,
+			       seq_no << IEEE80211_SEQ_SEQ_SHIFT);
+}
+
+/*
+ * schedule or reschedule BAR timer
+ */
+static void __wifi_tid_baw_bar_resched_timer(struct wifi_tid *wifi_tid)
+{
+	badbg("__wifi_tid_baw_bar_resched_timer\n");
+	mod_timer(&wifi_tid->bar_timer, jiffies + HZ / 100);
+}
+
+static void __wifi_tid_baw_bar_trigger_timer(struct wifi_tid *wifi_tid)
+{
+	badbg("__wifi_tid_baw_bar_trigger_timer\n");
+	mod_timer(&wifi_tid->bar_timer,  jiffies);
+}
+
+static void __wifi_tid_baw_bar_may_trigger_timer(struct wifi_tid *wifi_tid)
+{
+	if (timer_pending(&wifi_tid->bar_timer))
+		return;
+	__wifi_tid_baw_bar_trigger_timer(wifi_tid);
+}
+
+/*
+ * BAR timer callback, send BAR unless request was canceled
+ */
+static void wifi_tid_baw_bar_timer(struct timer_list *t)
+{
+	struct wifi_tid *wifi_tid = from_timer(wifi_tid, t, bar_timer);
+	bool send_bar;
+
+	spin_lock(&wifi_tid->bar_lock);
+
+	badbg("wifi_tid_baw_bar_timer: bar_state:%d bar_req_limit:%d seq_start:%d inflight:%d\n",
+	      wifi_tid->bar_state,
+	      wifi_tid->bar_req_limit,
+	      wifi_tid->seq_start,
+	      wifi_tid->bar_inflight);
+
+	send_bar = false;
+	switch (wifi_tid->bar_state) {
+	case WIFI_BAR_NONE:
+	case WIFI_BAR_SENT:
+	case WIFI_BAR_WAIT_RETRY:
+		/* request canceled, we don't use del_timer() so it
+		 * might happen */
+		break;
+
+	case WIFI_BAR_NEEDED:
+		if (wifi_tid->bar_inflight) {
+			/* previous BAR still being transmited, txdone
+			 * will update state */
+			break;
+		}
+
+		wifi_tid->bar_state = WIFI_BAR_SENT;
+		wifi_tid->bar_inflight = true;
+		send_bar = true;
+		break;
+	}
+	spin_unlock(&wifi_tid->bar_lock);
+
+	if (send_bar)
+		wifi_tid_send_bar(wifi_tid, wifi_tid->seq_start);
+}
+
+/*
+ * if BAR send request is pending, reset timer so it's sent ASAP
+ */
+static void wifi_tid_baw_bar_flush_any(struct wifi_tid *wifi_tid)
+{
+	spin_lock(&wifi_tid->bar_lock);
+
+	switch (wifi_tid->bar_state) {
+	case WIFI_BAR_NONE:
+	case WIFI_BAR_SENT:
+	case WIFI_BAR_WAIT_RETRY:
+		break;
+
+	case WIFI_BAR_NEEDED:
+		__wifi_tid_baw_bar_trigger_timer(wifi_tid);
+		break;
+	}
+
+	spin_unlock(&wifi_tid->bar_lock);
+}
+
+/*
+ * schedule a BAR for given seq_no, arm a timer to do it later
+ */
+static void __wifi_tid_baw_bar_schedule(struct wifi_tid *wifi_tid,
+					unsigned int seq_no)
+{
+	switch (wifi_tid->bar_state) {
+	case WIFI_BAR_NEEDED:
+	case WIFI_BAR_WAIT_RETRY:
+		/* BAR request already pending, update bar range */
+		wifi_tid->bar_req_limit =
+			(seq_no + wifi_tid->remote_baw_max_size) & 0xfff;
+		badbg("wifi_tid_baw_bar_schedule: <pending>, new seq_no:%d "
+		      "=> extend limit_sn: %d\n",
+		      seq_no,
+		      wifi_tid->bar_req_limit);
+		break;
+
+	case WIFI_BAR_NONE:
+	case WIFI_BAR_SENT:
+		wifi_tid->bar_state = WIFI_BAR_NEEDED;
+		wifi_tid->bar_req_limit =
+			(seq_no + wifi_tid->remote_baw_max_size) & 0xfff;
+
+		badbg("wifi_tid_baw_bar_schedule: <none>, seq_no:%d "
+		      "=> limit_sn:%d\n",
+		      seq_no,
+		      wifi_tid->bar_req_limit);
+		__wifi_tid_baw_bar_resched_timer(wifi_tid);
+		break;
+	}
+}
+
+/*
+ * this is called after any MPDU on this TID is positively
+ * acknowledged, it will schedule BAR retransmit if BAR was pending
+ */
+static void wifi_tid_baw_bar_may_retry(struct wifi_tid *wifi_tid)
+{
+	spin_lock(&wifi_tid->bar_lock);
+
+	switch (wifi_tid->bar_state) {
+	case WIFI_BAR_NONE:
+	case WIFI_BAR_SENT:
+	case WIFI_BAR_NEEDED:
+		break;
+	case WIFI_BAR_WAIT_RETRY:
+		if (wifi_tid->bar_retry_count >= 10) {
+			wifi_tid->bar_state = WIFI_BAR_NONE;
+			break;
+		}
+
+		++wifi_tid->bar_retry_count;
+		badbg("wifi_tid_baw_bar_may_retry => will retry ASAP\n");
+		wifi_tid->bar_state = WIFI_BAR_NEEDED;
+		__wifi_tid_baw_bar_trigger_timer(wifi_tid);
+		break;
+	}
+	spin_unlock(&wifi_tid->bar_lock);
+}
+
+/*
+ * this is called after BAR transmit completion
+ */
+static void wifi_tid_baw_bar_handle_txdone(struct wifi_tid *wifi_tid,
+					   bool txok)
+{
+	spin_lock(&wifi_tid->bar_lock);
+	badbg("wifi_tid_baw_bar_handle_txdone: BAR txdone (txok:%d)\n",
+	      txok);
+
+	WARN_ON(!wifi_tid->bar_inflight);
+	wifi_tid->bar_inflight = false;
+
+	switch (wifi_tid->bar_state) {
+	case WIFI_BAR_NONE:
+		break;
+	case WIFI_BAR_SENT:
+		if (!txok) {
+			/* retry previous request */
+			wifi_tid->bar_state = WIFI_BAR_WAIT_RETRY;
+			wifi_tid->bar_retry_count = 0;
+		}
+		break;
+	case WIFI_BAR_NEEDED:
+		/* more recent BAR request present, so we don't care
+		 * if previous BAR could be sent or not, make sure
+		 * timer is running (in case timer has already expired) */
+		__wifi_tid_baw_bar_may_trigger_timer(wifi_tid);
+		break;
+	case WIFI_BAR_WAIT_RETRY:
+		WARN(1, "bad BAR state");
+		break;
+	}
+
+	spin_unlock(&wifi_tid->bar_lock);
+}
+
+/*
+ * update BAW after packet transmit success of failure, this will move
+ * BAW head forward when possible and update the BAR pending state
+ *
+ * return true if baw head has moved
+ */
+static bool
+wifi_tid_baw_update(struct wifi_tid *wifi_tid,
+		    struct wifi_tx_skb *wskb,
+		    bool txok)
+{
+	unsigned int seq_scb_idx;
+	int bar_seqno;
+
+	txdbg("wifi_tid_baw_update: seq_no:%u txok:%u\n", wskb->seq_no, txok);
+	if (WARN_ON(!wifi_tid_baw_tracks_seqno(wifi_tid, wskb->seq_no))) {
+		/* we are not supposed to reduce the BAW while packets
+		 * tracked inside it are in-flight */
+		printk("wifi_tid_baw_update: seq_no:%u txok:%u\n", wskb->seq_no, txok);
+		wifi_tid_baw_print_nodebug(wifi_tid);
+		return false;
+	}
+
+	/* compute index in scoreboard for this seqno */
+	seq_scb_idx = wifi_tid->scb_head;
+	seq_scb_idx += (wskb->seq_no - wifi_tid->seq_start) & 0xfff;
+	if (seq_scb_idx >= WIFI_SCB_MAX)
+		seq_scb_idx -= WIFI_SCB_MAX;
+
+	/* additional sanity check */
+	if (WARN_ON(!test_bit(seq_scb_idx, wifi_tid->scb_inflight)))
+		return false;
+
+	/* record positive acknowledgement and tx failure */
+	if (txok)
+		__set_bit(seq_scb_idx, wifi_tid->scb_acked);
+
+	__clear_bit(seq_scb_idx, wifi_tid->scb_inflight);
+	wifi_tid->scb_inflight_count--;
+
+	/* if number of packets in flight reaches 0 and the STA was
+	 * marked as sleeping, we can tell stack that we have no more
+	 * packets buffered for this TID */
+	if (!wifi_tid->scb_inflight_count)
+		wifi_tid_ps_has_no_more_buffer(wifi_tid);
+
+	/* if this packet was not at head of window, head cannot move */
+	if (wskb->seq_no != wifi_tid->seq_start) {
+		txdbg("wifi_tid_baw_update: not head (seq_start:%d)\n",
+		      wifi_tid->seq_start);
+		wifi_tid_baw_print(wifi_tid);
+		return false;
+	}
+
+	/*
+	 * seqno was at the head of the window, we can now move it
+	 * forward
+	 *
+	 * if we find any failed frame, then a BAR will be needed
+	 */
+	bar_seqno = -1;
+
+	spin_lock(&wifi_tid->bar_lock);
+	do {
+		if (!test_bit(wifi_tid->scb_head, wifi_tid->scb_acked))
+			bar_seqno = wifi_tid->seq_start;
+
+		/* move head */
+		wifi_tid->seq_start++;
+		wifi_tid->seq_start &= 0xfff;
+
+		/* we have moved head, cancel existing bar request if
+		 * we step over its SN validity limit */
+		switch (wifi_tid->bar_state) {
+		case WIFI_BAR_NONE:
+		case WIFI_BAR_SENT:
+			break;
+		case WIFI_BAR_NEEDED:
+		case WIFI_BAR_WAIT_RETRY:
+			if (wifi_tid->seq_start == wifi_tid->bar_req_limit) {
+				badbg("wifi_tid_baw_update "
+				       "=> cancel bar_seqno:%d head_seq_no:%d\n",
+				       wifi_tid->bar_req_limit,
+				       wifi_tid->seq_start);
+				wifi_tid->bar_state = WIFI_BAR_NONE;
+			}
+			break;
+		}
+
+		wifi_tid->scb_head++;
+		if (wifi_tid->scb_head >= WIFI_SCB_MAX)
+			wifi_tid->scb_head -= WIFI_SCB_MAX;
+
+		badbg("wifi_tid_baw_update: moved head to seq_no %u\n",
+		      wifi_tid->seq_start);
+
+		/* stop when we reach an in-flight frame */
+		if (test_bit(wifi_tid->scb_head, wifi_tid->scb_inflight))
+			break;
+
+	} while (wifi_tid->scb_head != wifi_tid->scb_tail);
+
+	/* schedule or unschedule BAR */
+	switch (wifi_tid->aggr_state) {
+	case WIFI_AGGR_STOPPED:
+		break;
+	case WIFI_AGGR_ACTIVE:
+	case WIFI_AGGR_STOPPING:
+		if (bar_seqno != -1)
+			__wifi_tid_baw_bar_schedule(wifi_tid, bar_seqno);
+		break;
+	}
+
+	spin_unlock(&wifi_tid->bar_lock);
+
+	wifi_tid_baw_print(wifi_tid);
+	return true;
+}
+
+/*
+ * mark packet as tracked by BAW
+ *
+ * this will enforce its seq_no to be the next seqno after BAW end
+ */
+static void
+wifi_tid_baw_addto(struct wifi_tid *wifi_tid, struct wifi_tx_skb *wskb)
+{
+	unsigned int seq_scb_idx;
+
+	WARN_ON(wskb->type != WIFI_TXSKB_QOS_DATA);
+	if (WARN_ON(wifi_tid_baw_tracked_size(wifi_tid) >=
+		    wifi_tid->baw_max_size))
+		return;
+
+	badbg("wifi_tid_baw_addto: seq_no:%u\n", wskb->seq_no);
+
+	if (WARN_ON(wifi_tid_baw_next_seqno(wifi_tid) != wskb->seq_no)) {
+		printk("wifi_tid_baw_addto: NEXT SEQ SHOULD BE:%u, but is %u\n",
+		       wifi_tid_baw_next_seqno(wifi_tid),
+		       wskb->seq_no);
+		return;
+	}
+
+	wifi_tid->scb_tail++;
+	if (wifi_tid->scb_tail >= WIFI_SCB_MAX)
+		wifi_tid->scb_tail -= WIFI_SCB_MAX;
+
+	/* compute index in scoreboard for this seqno */
+	seq_scb_idx = wifi_tid->scb_head;
+	seq_scb_idx += (wskb->seq_no - wifi_tid->seq_start) & 0xfff;
+	if (seq_scb_idx >= WIFI_SCB_MAX)
+		seq_scb_idx -= WIFI_SCB_MAX;
+
+	__clear_bit(seq_scb_idx, wifi_tid->scb_acked);
+	__set_bit(seq_scb_idx, wifi_tid->scb_inflight);
+	wifi_tid->scb_inflight_count++;
+
+	badbg("wifi_tid_baw_addto: inflight count now: %u\n",
+	      wifi_tid->scb_inflight_count);
+	wifi_tid_baw_print(wifi_tid);
+}
+
+/*
+ *
+ */
+static void wifi_tid_init(struct wifi_tid *wifi_tid,
+			  struct wifi_txq *wifi_txq,
+			  enum wifi_tid_type type)
+{
+	memset(wifi_tid, 0, sizeof (*wifi_tid));
+	INIT_LIST_HEAD(&wifi_tid->retry_q);
+	spin_lock_init(&wifi_tid->bar_lock);
+	timer_setup(&wifi_tid->bar_timer, wifi_tid_baw_bar_timer, 0);
+	wifi_tid->txq = wifi_txq;
+	wifi_tid->baw_max_size = WIFI_TX_MAX_NON_AGGR;
+	wifi_tid->type = type;
+}
+
+/*
+ *
+ */
+static void wifi_tid_drain(struct wifi_priv *wp,
+			   struct wifi_tid *wifi_tid)
+{
+	struct wifi_tx_skb *wskb, *tmp;
+
+	list_for_each_entry_safe(wskb, tmp, &wifi_tid->retry_q, next)
+		wifi_tx_skb_release_txfail(wp, wskb);
+	INIT_LIST_HEAD(&wifi_tid->retry_q);
+}
+
+/*
+ *
+ */
+static void wifi_tid_release(struct wifi_priv *wp,
+			     struct wifi_tid *wifi_tid)
+{
+	/* ampdu action callback should have stopped any tx ba
+	 * session before removing STA */
+	WARN_ON(wifi_tid->aggr_state != WIFI_AGGR_STOPPED);
+
+	/* tx completion for tx filtered frame can queue frames to
+	 * retry as long as STA struct is visible, we have to drain
+	 * here */
+	wifi_tid_drain(wp, wifi_tid);
+
+	del_timer_sync(&wifi_tid->bar_timer);
+}
+
+/*
+ *
+ */
+static void wifi_tid_requeue(struct wifi_tid *wifi_tid,
+			     struct wifi_tx_skb *wskb)
+{
+	txdbg("wifi_tid_requeue: requeing wskb:%ps seq:%u\n",
+	       wskb, wskb->seq_no);
+	list_add(&wskb->next, &wifi_tid->retry_q);
+}
+
+/*
+ *
+ */
+static void wifi_tid_requeue_chain(struct wifi_tid *wifi_tid,
+				   struct list_head *chain,
+				   size_t max_count)
+{
+	struct wifi_tx_skb *wskb, *tmp;
+
+	list_for_each_entry_safe_reverse(wskb, tmp, chain, next){
+		if (!max_count)
+			break;
+		wifi_tid_requeue(wifi_tid, wskb);
+		max_count--;
+	}
+}
+
+/*
+ *
+ */
+static struct wifi_tx_skb *
+wifi_tid_dequeue(struct wifi_priv *wp, struct ieee80211_txq *itxq,
+		 bool do_retry, bool do_mac80211, bool *is_retry)
+{
+	struct wifi_tid *wifi_tid = WIFI_TID(itxq);
+	struct wifi_tx_skb *wskb;
+	struct sk_buff *skb;
+	int tid;
+
+	/* dequeue from retry queue first, it's guaranted to
+	 * be already in BAW */
+	if (do_retry && !list_empty(&wifi_tid->retry_q)) {
+		wskb = list_first_entry(&wifi_tid->retry_q,
+					struct wifi_tx_skb, next);
+		list_del(&wskb->next);
+		txdbg("wifi_tid_dequeue wskb:%ps seq:%u (from retry %u)\n",
+		      wskb, wskb->seq_no, wskb->sw_tries_done);
+		if (is_retry)
+			*is_retry = true;
+		return wskb;
+	}
+
+	if (!do_mac80211)
+		return NULL;
+
+	skb = ieee80211_tx_dequeue(wp->hw, itxq);
+	if (!skb)
+		return NULL;
+
+	switch (wifi_tid->type) {
+	case WIFI_TID_MCAST:
+		tid = -1;
+		break;
+	default:
+		tid = itxq->tid;
+		break;
+	}
+
+	wskb = wifi_tx_skb_wrap(wp, wifi_tid->txq, skb, itxq->sta, tid);
+	if (!wskb) {
+		ieee80211_free_txskb(wp->hw, skb);
+		return NULL;
+	}
+
+	txdbg("wifi_tid_dequeue wskb:%ps has_tid:%d tid:%d seq:%u\n",
+	      wskb, wskb->has_tid, wskb->tid, wskb->seq_no);
+	if (is_retry)
+		*is_retry = false;
+	return wskb;
+}
+
+static struct wifi_tx_skb *
+wifi_tid_dequeue_any(struct wifi_priv *wp, struct ieee80211_txq *itxq,
+		     bool *is_retry)
+{
+	txdbg("wifi_tid_dequeue_any\n");
+	return wifi_tid_dequeue(wp, itxq, true, true, is_retry);
+}
+
+static struct wifi_tx_skb *
+wifi_tid_dequeue_only_mac80211(struct wifi_priv *wp, struct ieee80211_txq *itxq)
+{
+	txdbg("wifi_tid_dequeue_mac80211\n");
+	return wifi_tid_dequeue(wp, itxq, false, true, NULL);
+}
+
+static struct wifi_tx_skb *
+wifi_tid_dequeue_only_retry(struct wifi_priv *wp, struct ieee80211_txq *itxq)
+{
+	txdbg("wifi_tid_dequeue_only_retry\n");
+	return wifi_tid_dequeue(wp, itxq, true, false, NULL);
+}
+
+/*
+ * dequeue from retry queue first, then mac80211 if BAW allows it, add
+ * frame to BAW
+ */
+static struct wifi_tx_skb *
+wifi_tid_dequeue_within_baw_limit(struct wifi_priv *wp,
+				  struct ieee80211_txq *itxq)
+{
+	struct wifi_tid *wifi_tid = WIFI_TID(itxq);
+	struct wifi_tx_skb *wskb;
+	size_t space;
+
+	space = wifi_tid_baw_space(wifi_tid);
+
+	txdbg("wifi_tid_dequeue_within_space: baw space:%zu\n", space);
+	if (space > 0) {
+		bool from_retry;
+
+		wskb = wifi_tid_dequeue_any(wp, itxq, &from_retry);
+		if (wskb && !from_retry)
+			wifi_tid_baw_addto(wifi_tid, wskb);
+	} else
+		wskb = wifi_tid_dequeue_only_retry(wp, itxq);
+
+	return wskb;
+}
+
+/*
+ *
+ */
+static u16 compute_max_ampdu_bytes(const struct wifi_txq *wifi_txq,
+				   const struct ieee80211_tx_rate *rates)
+{
+	u32 max_frmlen;
+	u16 aggr_limit;
+	bool legacy;
+	size_t i;
+
+	legacy = false;
+	max_frmlen = 0;
+
+	for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
+		const struct ieee80211_tx_rate *r = &rates[i];
+		int short_gi, bw_40;
+
+		if (r->idx < 0)
+			break;
+
+		if (!r->count)
+			continue;
+
+		if (!(r->flags & IEEE80211_TX_RC_MCS)) {
+			legacy = true;
+			break;
+		}
+
+		bw_40 = !!(rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH);
+		short_gi = !!(rates[i].flags & IEEE80211_TX_RC_SHORT_GI);
+		max_frmlen = wifi_txq->max_aggr_framelen[bw_40][short_gi][r->idx];
+		break;
+	}
+
+	if (legacy)
+		return 0;
+
+	aggr_limit = min(max_frmlen, (u32)(64 * 1024 - 1));
+	return aggr_limit;
+}
+
+/*
+ *
+ */
+static bool has_legacy_rate(const struct ieee80211_tx_rate *rates)
+{
+	bool legacy;
+	size_t i;
+
+	legacy = false;
+	for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
+		const struct ieee80211_tx_rate *r = &rates[i];
+
+		if (r->idx < 0)
+			break;
+
+		if (!r->count)
+			continue;
+
+		if (!(r->flags & IEEE80211_TX_RC_MCS))
+			return true;
+	}
+	return false;
+}
+
+/*
+ * Returns the size in bytes of delimiters that need to added to meet
+ * the minimum required mpdudensity.
+ */
+static int compute_delims_size(const struct ieee80211_tx_rate *r,
+			       u16 frmlen, u8 density_idx)
+{
+	unsigned int width, streams, density_us;
+	u32 nsymbits, nsymbols;
+	u16 minlen;
+	u8 mcs;
+	bool half_gi;
+	bool bw_40;
+
+	switch (density_idx) {
+	case 0:
+	default:
+		return 0;
+	case 1:
+	case 2:
+	case 3:
+		density_us = 1;
+		break;
+	case 4:
+		density_us = 2;
+		break;
+	case 5:
+		density_us = 4;
+		break;
+	case 6:
+		density_us = 8;
+		break;
+	case 7:
+		density_us = 16;
+		break;
+	}
+
+	mcs = r->idx;
+	bw_40 = !!(r->flags & IEEE80211_TX_RC_40_MHZ_WIDTH);
+	half_gi = !!(r->flags & IEEE80211_TX_RC_SHORT_GI);
+
+	if (half_gi)
+		nsymbols = NUM_SYMBOLS_PER_USEC_HALFGI(density_us);
+	else
+		nsymbols = NUM_SYMBOLS_PER_USEC(density_us);
+
+	if (nsymbols == 0)
+		nsymbols = 1;
+
+	streams = mcs / 8 + 1;
+	nsymbits = bits_per_symbol[mcs % 8][width] * streams;
+	minlen = (nsymbols * nsymbits) / BITS_PER_BYTE;
+
+	if (frmlen >= minlen)
+		return 0;
+
+	return ALIGN(minlen - frmlen, AMPDU_DELIM_SZ);
+}
+
+/*
+ * build a chain of packets to send as an aggregate, return chain size
+ */
+static size_t wifi_tid_build_aggr(struct wifi_priv *wp,
+				  struct ieee80211_txq *itxq,
+				  struct list_head *chain,
+				  bool *aggr)
+{
+	struct wifi_tid *wifi_tid = WIFI_TID(itxq);
+	struct wifi_tx_skb *first_wskb;
+	struct ieee80211_tx_info *tx_info;
+	u16 max_aggr_bytes, mpdu_bytes, aggr_bytes;
+	ssize_t count;
+
+	/*
+	 * check how many "fresh" packets (from mac80211) we can send
+	 * until being limited by the BAW, if BAW is full only try to
+	 * dequeue from retry queue
+	 */
+	first_wskb = wifi_tid_dequeue_within_baw_limit(wp, itxq);
+	if (!first_wskb)
+		return 0;
+
+	INIT_LIST_HEAD(chain);
+	list_add(&first_wskb->next, chain);
+	count = 1;
+
+	/* fill rates for the first packet */
+	tx_info = IEEE80211_SKB_CB(first_wskb->skb);
+	wifi_tx_skb_fill_rates(first_wskb, itxq->vif, itxq->sta);
+
+	/* if rate is a probe rate or if packet is not supposed to be
+	 * aggregated, stop here */
+	if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) ||
+	    !(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
+		txdbg("wifi_build_aggr: first has probe rate / non ampdu\n");
+		/* printk("bd probe 1\n"); */
+		*aggr = false;
+		return count;
+	}
+
+	/* find out the maximum allowed aggregate len at this rate
+	 * without going over the 4 milliseconds limit */
+	max_aggr_bytes = compute_max_ampdu_bytes(wifi_tid->txq,
+						 tx_info->control.rates);
+	/* cap to maximum value supported by remote STA */
+	if (wifi_tid->ampdu_max_bytes)
+		max_aggr_bytes = min(max_aggr_bytes,
+				     wifi_tid->ampdu_max_bytes);
+
+	if (!max_aggr_bytes) {
+		/* packet has legacy rate, don't aggregate */
+		*aggr = false;
+		/* printk("bd leg 1\n"); */
+		return count;
+	}
+
+	/* will build an aggregate, fill mandatory txdesc info */
+	first_wskb->txdesc.ampdu_density = wifi_tid->ampdu_density;
+	first_wskb->txdesc.ampdu_baw_ssn = wifi_tid->seq_start;
+
+	/* dequeue as many frames as we can */
+	mpdu_bytes = first_wskb->frame_len;
+	mpdu_bytes += compute_delims_size(tx_info->control.rates, mpdu_bytes,
+					  wifi_tid->ampdu_density);
+	mpdu_bytes += AMPDU_DELIM_SZ;
+	mpdu_bytes = ALIGN(mpdu_bytes, 4);
+	aggr_bytes = mpdu_bytes;
+
+	while (1) {
+		struct wifi_tx_skb *wskb;
+
+		/* send at most half the maximum baw size per ampdu,
+		 * in best cast we will have two ampdu inflight with
+		 * full window */
+		if (count >= wifi_tid->baw_max_size / 2) {
+			txdbg("wifi_build_aggr: reached baw size\n");
+			/* printk("bd baw 1\n"); */
+			break;
+		}
+
+		wskb = wifi_tid_dequeue_within_baw_limit(wp, itxq);
+		if (!wskb) {
+			txdbg("wifi_build_aggr: nothing more to dequeue\n");
+			/* printk("bd deq spc:%u\n", */
+			/*        wifi_tid_baw_space(wifi_tid)); */
+			break;
+		}
+
+		/* stop if next skb is a probe rate, or not supposed
+		 * to be aggregated */
+		tx_info = IEEE80211_SKB_CB(wskb->skb);
+		if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) ||
+		    !(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
+			txdbg("wifi_build_aggr: next probe or !ampdu\n");
+			wifi_tid_requeue(wifi_tid, wskb);
+			/* printk("bd probe 2\n"); */
+			break;
+		}
+
+		if (has_legacy_rate(tx_info->control.rates)) {
+			txdbg("wifi_build_aggr: next has legacy rate\n");
+			wifi_tid_requeue(wifi_tid, wskb);
+			/* printk("bd leg 2\n"); */
+			break;
+		}
+
+		/* compute aggregrated frame len of this packet, and
+		 * check we don't go past limit */
+		mpdu_bytes = wskb->frame_len;
+		mpdu_bytes += compute_delims_size(tx_info->control.rates,
+						  mpdu_bytes,
+						  wifi_tid->ampdu_density);
+		mpdu_bytes += AMPDU_DELIM_SZ;
+		mpdu_bytes = ALIGN(mpdu_bytes, 4);
+
+		if (aggr_bytes + mpdu_bytes > max_aggr_bytes) {
+			txdbg("wifi_build_aggr: too many bytes add %u > %u\n",
+			      aggr_bytes + mpdu_bytes, max_aggr_bytes);
+			wifi_tid_requeue(wifi_tid, wskb);
+			/* printk("bd maxb %u\n", max_aggr_bytes); */
+			break;
+		}
+
+		aggr_bytes += mpdu_bytes;
+		list_add_tail(&wskb->next, chain);
+		count++;
+	}
+
+	txdbg("final aggr size is %u / %u\n", aggr_bytes, max_aggr_bytes);
+	*aggr = true;
+	return count;
+}
+
+/*
+ *
+ */
+static void wifi_tid_schedule_aggr_active(struct ieee80211_hw *hw,
+					  struct ieee80211_txq *itxq)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct wifi_tid *wifi_tid = WIFI_TID(itxq);
+	struct list_head chain;
+	bool do_aggr;
+	size_t count;
+
+	WARN_ON(wifi_tid->type != WIFI_TID_STA_QOS_DATA);
+
+	/*
+	 * try to build a chain of packet to aggregate, it may end up
+	 * being a single packet that we have to send without
+	 * aggregation
+	 */
+	count = wifi_tid_build_aggr(wp, itxq, &chain, &do_aggr);
+	if (count)
+		txdbg("wifi_tid_schedule_aggr_active: built an %saggregate of count:%zu\n",
+		      do_aggr ? "" : "NOT ", count);
+	else
+		txdbg("wifi_tid_schedule_aggr_active: nothing to send\n");
+
+	if (!count) {
+		if (!wifi_tid_baw_has_inflight_packets(wifi_tid)) {
+			/* no new packet to send, nothing in flight,
+			 * if the BAR delay timer is running, we can
+			 * send the BAR immediately instead of
+			 * waiting */
+			wifi_tid_baw_bar_flush_any(wifi_tid);
+		}
+		return;
+	}
+
+	if (count < WIFI_MIN_AGGR_COUNT) {
+		struct wifi_tx_skb *wskb;
+
+		/* since hardware does not do multi rate retry on
+		 * AMPDU, if we cannot build a large chain, better
+		 * send them as individual packets */
+		wskb = list_first_entry(&chain, struct wifi_tx_skb, next);
+		wifi_tid_requeue_chain(wifi_tid, &chain, count - 1);
+		INIT_LIST_HEAD(&chain);
+		list_add(&wskb->next, &chain);
+		count = 1;
+		do_aggr = false;
+	}
+
+	/* if we end up finally sending it as non aggregated, clear
+	 * the AMPDU tx info flag, otherwise rate control won't be
+	 * updated at tx done */
+	if (!do_aggr) {
+		struct wifi_tx_skb *wskb;
+		struct ieee80211_tx_info *tx_info;
+		wskb = list_first_entry(&chain, struct wifi_tx_skb, next);
+		tx_info = IEEE80211_SKB_CB(wskb->skb);
+		tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
+	}
+
+	/* { */
+	/* 	struct wifi_tx_skb *wskb; */
+	/* 	wskb = list_first_entry(&chain, struct wifi_tx_skb, next); */
+	/* 	txdbg("send chain count:%u (BAW:%d), seq:%d\n", count, */
+	/* 	      wifi_tid_baw_tracked_size(wifi_tid), */
+	/* 	      wskb->seq_no); */
+	/* } */
+
+	/* cannot fail since caller made sure not to push too much*/
+	WARN_ON(wifi_tx_send_chain(wp, &chain, count, do_aggr,
+				   itxq->sta, false));
+}
+
+/*
+ *
+ */
+static void wifi_tid_schedule_aggr_stopping(struct ieee80211_hw *hw,
+					    struct ieee80211_txq *itxq)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct ieee80211_tx_info *tx_info;
+	struct list_head chain;
+	struct wifi_tx_skb *wskb;
+	struct wifi_tid *wifi_tid = WIFI_TID(itxq);
+
+	WARN_ON(wifi_tid->type != WIFI_TID_STA_QOS_DATA);
+
+	wskb = wifi_tid_dequeue_only_retry(wp, itxq);
+	if (!wskb)
+		return;
+
+	txdbg("wifi_tid_schedule_aggr_stopping: will *NOT* aggr starting from "
+	      "wskb:%ps seq:%u\n", wskb, wskb->seq_no);
+
+	wifi_tx_skb_fill_rates(wskb, itxq->vif, itxq->sta);
+
+	/* when aggregation state is stopping, frames will still be
+	 * marked as to be aggregated, make sure to clear this */
+	tx_info = IEEE80211_SKB_CB(wskb->skb);
+	tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
+
+	INIT_LIST_HEAD(&chain);
+	list_add(&wskb->next, &chain);
+
+	/* cannot fail since caller made sure not to push too much*/
+	WARN_ON(wifi_tx_send_chain(wp, &chain, 1, false, itxq->sta, false));
+}
+
+/*
+ *
+ */
+static void wifi_tid_schedule_non_aggr(struct ieee80211_hw *hw,
+				       struct ieee80211_txq *itxq)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct ieee80211_tx_info *tx_info;
+	struct list_head chain;
+	struct wifi_tx_skb *wskb;
+	struct wifi_tid *wifi_tid = WIFI_TID(itxq);
+
+	wskb = NULL;
+	switch (wifi_tid->type) {
+	case WIFI_TID_MCAST:
+	case WIFI_TID_STA_MMPDU:
+	case WIFI_TID_STA_DATA:
+		wskb = wifi_tid_dequeue_only_mac80211(wp, itxq);
+		break;
+	case WIFI_TID_STA_QOS_DATA:
+		wskb = wifi_tid_dequeue_within_baw_limit(wp, itxq);
+		break;
+	}
+
+	if (!wskb)
+		return;
+
+	txdbg("wifi_tid_schedule_non_aggr: will *NOT* aggr starting from "
+	      "wskb:%ps seq:%u\n", wskb, wskb->seq_no);
+
+	wifi_tx_skb_fill_rates(wskb, itxq->vif, itxq->sta);
+
+	tx_info = IEEE80211_SKB_CB(wskb->skb);
+	WARN_ON(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
+
+	INIT_LIST_HEAD(&chain);
+	list_add(&wskb->next, &chain);
+
+	/* cannot fail since caller made sure not to push too much*/
+	WARN_ON(wifi_tx_send_chain(wp, &chain, 1, false, itxq->sta, false));
+}
+
+/*
+ * schedule some packets from this tid
+ *
+ * return false if we don't want to be rescheduled (tx completion will
+ * do this), otherwise we want to be called again to schedule more
+ * packets that we buffer internally
+ */
+static bool wifi_tid_schedule(struct ieee80211_hw *hw,
+			      struct ieee80211_txq *itxq)
+{
+	struct wifi_tid *wifi_tid = WIFI_TID(itxq);
+	struct wifi_sta *wifi_sta;
+	bool ret;
+
+	wifi_sta = NULL;
+	if (itxq->sta) {
+		wifi_sta = WIFI_STA(itxq->sta);
+		spin_lock(&wifi_sta->lock);
+
+		if (wifi_sta->ps_state != WIFI_PS_AWAKE) {
+			/*
+			 * we take care to stop scheduling a tid when STA is
+			 * sleeping, but this can happen:
+			 * - ieee80211_tx_stop_ba_cb_irqsafe
+			 * - ieee80211_ba_session_work
+			 * - ieee80211_agg_start_txq
+			 * - wifi_tid_schedule
+			 */
+			spin_unlock(&wifi_sta->lock);
+			return false;
+		}
+	}
+
+	switch (wifi_tid->aggr_state) {
+	case WIFI_AGGR_STOPPED:
+		txdbg("wifi_tid_schedule: enter aggr stopped (ac:%d/tid:%d)\n",
+		      itxq->ac, itxq->tid);
+
+		wifi_tid_schedule_non_aggr(hw, itxq);
+		break;
+
+	case WIFI_AGGR_STOPPING:
+		txdbg("wifi_tid_schedule: enter aggr stopping (ac:%d/tid:%d)\n",
+		      itxq->ac, itxq->tid);
+
+		wifi_tid_schedule_aggr_stopping(hw, itxq);
+
+		/* switch to stopped state when we have completed
+		 * everything that was inflight in BAW */
+		if (!wifi_tid_baw_has_inflight_packets(wifi_tid)) {
+			WARN_ON(!list_empty(&wifi_tid->retry_q));
+			wifi_tid->aggr_state = WIFI_AGGR_STOPPED;
+			ieee80211_stop_tx_ba_cb_irqsafe(itxq->vif,
+							itxq->sta->addr,
+							itxq->tid);
+		}
+		break;
+
+	case WIFI_AGGR_ACTIVE:
+		txdbg("wifi_tid_schedule: enter aggr active (ac:%d/tid:%d)\n",
+		      itxq->ac, itxq->tid);
+		wifi_tid_schedule_aggr_active(hw, itxq);
+		break;
+	}
+
+	/* force resched if we have more packets in the retry queue
+	 * ready to be sent */
+	if (list_empty(&wifi_tid->retry_q))
+		txdbg("wifi_tid_schedule: => don't force resched\n");
+	else
+		txdbg("wifi_tid_schedule: => force resched\n");
+
+	ret = list_empty(&wifi_tid->retry_q) ? false : true;
+	if (wifi_sta)
+		spin_unlock(&wifi_sta->lock);
+	return ret;
+}
+
+/*
+ *
+ */
+static bool wifi_txq_has_enough_buffered_data(struct wifi_txq *wifi_txq)
+{
+	if (wifi_txq->count >= WIFI_TX_DESCS_WAKE)
+		return true;
+	if (wifi_txq->aggr_count >= WIFI_TX_MAX_AGGR)
+		return true;
+	if (wifi_txq->non_aggr_count >= WIFI_TX_MAX_NON_AGGR)
+		return true;
+	return false;
+}
+
+/*
+ * must be called with txq lock held
+ */
+static void wifi_txq_schedule(struct ieee80211_hw *hw,
+			      struct wifi_txq *wifi_txq)
+{
+	struct ieee80211_txq *itxq;
+
+	WARN_ON(!in_atomic());
+	txdbg("wifi_txq_schedule: txq:%ps ac:%d\n",
+	       wifi_txq, wifi_txq->ac);
+
+	/* don't push too much data */
+	if (wifi_txq_has_enough_buffered_data(wifi_txq)) {
+		txdbg("wifi_txq_schedule: enough data\n");
+		return;
+	}
+
+	/* iterate over STA/TID to schedule */
+	ieee80211_txq_schedule_start(hw, wifi_txq->ac);
+
+	rcu_read_lock();
+	while ((itxq = ieee80211_next_txq(hw, wifi_txq->ac))) {
+		bool force_resched = wifi_tid_schedule(hw, itxq);
+		ieee80211_return_txq(hw, itxq, force_resched);
+
+		/* if txq is "full", we can stop scheduling here */
+		if (wifi_txq_has_enough_buffered_data(wifi_txq))
+			break;
+	}
+	rcu_read_unlock();
+	ieee80211_txq_schedule_end(hw, wifi_txq->ac);
+	txdbg("wifi_txq_schedule: schedule end\n");
+}
+
+/*
+ * note: hardware only fills tx status for the last descriptor, which
+ * is the one passed
+ */
+static void tx_done_process_aggr_chain(struct wifi_priv *wp,
+				       struct list_head *chain,
+				       const struct wifi_txd *txdesc,
+				       struct ieee80211_sta *sta,
+				       struct wifi_tid *wifi_tid)
+{
+	struct list_head retry_chain, report_chain;
+	struct wifi_tx_skb *wskb, *wtmp, *wskb_first, *wskb_report;
+	struct wifi_sta *wifi_sta;
+	bool wskb_report_txok;
+	struct ieee80211_tx_info static_info;
+	struct ieee80211_tx_status tx_status;
+	u32 desc_status;
+	bool ba_received, filtered;
+	size_t i, count, count_bad, tries_done;
+	u8 bitmap[8];
+	u16 ssn;
+
+	if (sta)
+		wifi_sta = WIFI_STA(sta);
+
+	if (wifi_tid)
+		WARN_ON(wifi_tid->type != WIFI_TID_STA_QOS_DATA);
+
+	/*
+	 * For aggregated frames and rate control update, reporting tx
+	 * status to mac80211 is not done on a frame-by-frame
+	 * basis. Instead, a single report is done with a field
+	 * containing the total number of frames that were aggregated,
+	 * and the total number of frames from this aggregate that
+	 * were acknowledged. Other frames transmitted in this mpdu
+	 * must still be reported, but without the AMPDU_STAT flags.
+	 *
+	 * All unacknowledged frames will be software retried (unless
+	 * they reach a maximum retry count), we build a chain of
+	 * those
+	 */
+	wskb_first = list_first_entry(chain, struct wifi_tx_skb, next);
+	txdbg("process_aggr_chain_done "
+	       "wifi_tid:%ps wskb_first:%ps first_seq:%u\n",
+	       wifi_tid, wskb_first, wskb_first->seq_no);
+	desc_status = le32_to_cpu(txdesc->status);
+	ba_received = !!(desc_status & TXD_F_TX_SUCCESS);
+	filtered = !!(desc_status & TXD_F_TX_PS_FILTERED);
+
+	if (ba_received) {
+		memcpy(bitmap, txdesc->ba.bitmap, sizeof (bitmap));
+		ssn = le16_to_cpu(txdesc->ba.start_seq);
+	}
+
+	/*
+	 * RANDOM DROP for testing
+	 */
+#if RND_DROP_PPK > 0
+	{
+		static unsigned int total = 1000 / RND_DROP_PPK;
+		size_t to_drop = 0, skip;
+
+		count = 0;
+		list_for_each_entry(wskb, chain, next)
+			count++;
+
+		if (!total--) {
+			total = 1000 / RND_DROP_PPK;
+			to_drop = count / 3;
+		}
+
+		skip = 2;
+		list_for_each_entry(wskb, chain, next) {
+			if (ba_received) {
+				unsigned int ba_index;
+				ba_index = D11_BA_INDEX(ssn, wskb->seq_no);
+				if (ba_index < D11_BA_BMP_SIZE &&
+				    D11_BA_ISSET(bitmap, ba_index)) {
+					if (!to_drop)
+						continue;
+
+					if (skip--)
+						continue;
+
+					bitmap[ba_index / 8] &= ~(1 << (ba_index % 8));
+					to_drop--;
+					printk("rnd drop seq:%d\n", wskb->seq_no);
+					skip = 2;
+				}
+			}
+		}
+	}
+#endif
+
+	INIT_LIST_HEAD(&retry_chain);
+	INIT_LIST_HEAD(&report_chain);
+	wskb_report = NULL;
+	count_bad = count = 0;
+
+	list_for_each_entry_safe(wskb, wtmp, chain, next) {
+		struct ieee80211_tx_info *info;
+		unsigned int ba_index;
+		bool acked;
+
+		acked = false;
+		if (ba_received) {
+			/* compute the bitmap index for this frame
+			 * sequence number according to the sequence
+			 * start of the bitmap */
+			ba_index = D11_BA_INDEX(ssn, wskb->seq_no);
+			if (ba_index < D11_BA_BMP_SIZE &&
+			    D11_BA_ISSET(bitmap, ba_index))
+				acked = true;
+		}
+
+		if (wifi_tid &&
+		    (filtered ||
+		     (!acked && wifi_sta->ps_state != WIFI_PS_AWAKE))) {
+			/* filtered frames, or frame that failed while
+			 * sta was asleep are requeued for software
+			 * retransmit */
+			wskb->sw_tries_done--;
+			txdbg("process_ampdu_mpdu_done: filtered, "
+			      "will requeue\n");
+			list_add_tail(&wskb->next, &retry_chain);
+			continue;
+		}
+
+		/* actual tx was attempted for this frame */
+		count++;
+
+		if (!wifi_tid) {
+			/* STA went away */
+			info = IEEE80211_SKB_CB(wskb->skb);
+			ieee80211_tx_info_clear_status(info);
+			list_add_tail(&wskb->next, &report_chain);
+			continue;
+		}
+
+		txdbg("process_aggr_chain_done: "
+		       "wskb:%ps seq:%u ba_received:%d ba_ssn:%u acked:%u\n",
+		       wskb, wskb->seq_no, ba_received, ssn, acked);
+
+		if (acked) {
+			wifi_tid_baw_update(wifi_tid, wskb, true);
+
+			if (!wskb_report) {
+				/* use this skb for mac80211 report */
+				wskb_report = wskb;
+				wskb_report_txok = true;
+				continue;
+			}
+
+			/* we don't need this frame anymore, update tx
+			 * info to reflect transmit success */
+			info = IEEE80211_SKB_CB(wskb->skb);
+			ieee80211_tx_info_clear_status(info);
+			info->flags |= IEEE80211_TX_STAT_ACK;
+			list_add_tail(&wskb->next, &report_chain);
+			continue;
+		}
+
+		/* !acked */
+		count_bad++;
+
+		/* are we going to retry this frame ? */
+		if (wskb->sw_tries_done < WIFI_MAX_SW_TRIES) {
+			txdbg("process_aggr_chain_done: "
+			      "will retry wskb:%ps seq:%u (try %u / %u)\n",
+			      wskb,
+			      wskb->seq_no,
+			      wskb->sw_tries_done, WIFI_MAX_SW_TRIES);
+			list_add_tail(&wskb->next, &retry_chain);
+			continue;
+		}
+
+		wifi_tid_baw_update(wifi_tid, wskb, false);
+		txdbg("process_aggr_chain_done: "
+		       "too many retries for wskb:%ps seq:%u\n",
+		       wskb, wskb->seq_no);
+
+		/* we don't need this frame anymore, update tx info to
+		 * reflect transmit failure */
+		if (!wskb_report) {
+			/* use this skb for mac80211 report */
+			wskb_report = wskb;
+			wskb_report_txok = false;
+			continue;
+		}
+
+		info = IEEE80211_SKB_CB(wskb->skb);
+		ieee80211_tx_info_clear_status(info);
+		list_add_tail(&wskb->next, &report_chain);
+	}
+
+	/*
+	 * any frames to retry goes into the retry chain, if those
+	 * frames have no associated tid (STA removed), just release
+	 * them
+	 */
+	if (wifi_tid) {
+		wifi_tid_requeue_chain(wifi_tid, &retry_chain, ~0);
+
+		/* if we got at least one positive ACK, we may retry
+		 * to send BAR */
+		if (count && count != count_bad)
+			wifi_tid_baw_bar_may_retry(wifi_tid);
+
+		/*
+		 * since we are may be pushing back frames in retry
+		 * queue, make sure itxq is scheduled
+		 *
+		 * also, some aggr state management and BAR flush
+		 * decision is done as schedule time, so we always
+		 * reschedule tid
+		 */
+		if (wifi_sta->ps_state == WIFI_PS_AWAKE)
+			ieee80211_schedule_txq(wp->hw, TID2ITXQ(wifi_tid));
+	} else
+		list_splice_tail(&retry_chain, &report_chain);
+
+	/*
+	 * if no transmit was even attempted (everything filtered),
+	 * stop here
+	 */
+	if (!count)
+		return;
+
+	/*
+	 * report status to mac80211 of the AMPDU, either with or
+	 * without an associated skb so that rate table is always
+	 * updated
+	 */
+	tx_status.sta = sta;
+	tx_status.rate = NULL;
+
+	txdbg("process_aggr_chain_done: wskb_report:%ps\n",
+	       wskb_report);
+	if (wskb_report) {
+		struct ieee80211_tx_info *info_report;
+
+		info_report = IEEE80211_SKB_CB(wskb_report->skb);
+
+		/* whatever AMPDU we choose to report was transmitted
+		 * using rate from the *first* MPDU of the chain, make
+		 * sure to report the correct one */
+		if (wskb_report != wskb_first) {
+			struct ieee80211_tx_info *info_first;
+
+			info_first = IEEE80211_SKB_CB(wskb_report->skb);
+			memcpy(info_report->status.rates,
+			       info_first->status.rates,
+			       sizeof (info_report->status.rates));
+		}
+
+		tx_status.info = info_report;
+		tx_status.skb = wskb_report->skb;
+	} else {
+		tx_status.skb = NULL;
+		tx_status.info = &static_info;
+		memcpy(&static_info,
+		       IEEE80211_SKB_CB(wskb_first->skb),
+		       sizeof (static_info));
+	}
+
+	/* update rate table, hardware only did 1 try, update rate
+	 * table to reflect this */
+	ieee80211_tx_info_clear_status(tx_status.info);
+	tries_done = 1;
+
+	for (i = 0; i < WIFI_TXD_MAX_RATES; i++) {
+		struct ieee80211_tx_rate *r = &tx_status.info->status.rates[i];
+
+		if (r->idx == -1)
+			break;
+
+		if (tries_done) {
+			r->count = tries_done;
+			tries_done = 0;
+		} else
+			r->idx = -1;
+	}
+
+	txdbg("process_aggr_chain_done: will report rate:%u count:%zu ack_len:%zu\n",
+	       tx_status.info->status.rates[0].idx,
+	       count, count - count_bad);
+
+	tx_status.info->flags = IEEE80211_TX_STAT_AMPDU;
+	if (wskb_report_txok)
+		tx_status.info->flags |= IEEE80211_TX_STAT_ACK;
+	tx_status.info->status.ampdu_len = count;
+	tx_status.info->status.ampdu_ack_len = count - count_bad;
+
+	if (wskb_report) {
+		/* note: this consumes the skb if any */
+		ieee80211_tx_status_ext(wp->hw, &tx_status);
+		wifi_tx_skb_release_keep_skb(wp, wskb_report);
+	} else if (sta) {
+		/* we only want to update rate control here with the
+		 * failed try, don't use ieee80211_tx_status_ext()
+		 * otherwise it will consider it a failed frame */
+		ieee80211_tx_rate_update(wp->hw, sta, tx_status.info);
+	}
+
+	/* now report all other frames to mac80211 as usual, rate
+	 * control will ignore them since they don't have the
+	 * TX_STAT_AMPDU flag */
+	list_for_each_entry_safe(wskb, wtmp, &report_chain, next) {
+		tx_status.sta = sta;
+		tx_status.rate = NULL;
+		tx_status.info = IEEE80211_SKB_CB(wskb->skb);
+		tx_status.skb = wskb->skb;
+
+		txdbg("process_aggr_chain_done: tx complete rem wskb:%p\n",
+			wskb);
+
+		ieee80211_tx_status_ext(wp->hw, &tx_status);
+		wifi_tx_skb_release_keep_skb(wp, wskb);
+	}
+
+	txdbg("process_aggr_chain_done out\n");
+}
+
+/*
+ *
+ */
+static void tx_done_process_single_mpdu(struct wifi_priv *wp,
+					struct wifi_tx_skb *wskb,
+					const struct wifi_txd *txdesc,
+					struct ieee80211_sta *sta,
+					struct wifi_tid *wifi_tid)
+{
+	struct ieee80211_tx_info *info;
+	struct ieee80211_tx_status tx_status;
+	u8 rcounts[IEEE80211_TX_MAX_RATES], tries_done;
+	u32 desc_status;
+	bool txok, filtered, ps_resp;
+	size_t i;
+
+	txdbg("process_single_mpdu_done: wskb:%pS has_tid:%d tid:%d type:%d seqno:%u\n",
+	      wskb, wskb->has_tid, wskb->tid, wskb->type, wskb->seq_no);
+
+	desc_status = le32_to_cpu(txdesc->status);
+	info = IEEE80211_SKB_CB(wskb->skb);
+
+	/* prepare tx status reporting */
+	tx_status.skb = wskb->skb;
+	tx_status.info = info;
+	tx_status.sta = sta;
+	tx_status.rate = NULL;
+
+	txok = !!(desc_status & TXD_F_TX_SUCCESS);
+	filtered = !!(desc_status & TXD_F_TX_PS_FILTERED);
+	ps_resp = (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER);
+
+	if (!sta || !wifi_tid) {
+		txdbg("process_single_mpdu_done: no STA/TID found\n");
+		goto report;
+	}
+
+	txdbg("process_single_mpdu_done: STA found %pM, tid:%d\n",
+	      sta->addr, wskb->tid);
+
+	if (wskb->type == WIFI_TXSKB_QOS_DATA) {
+		struct wifi_sta *wifi_sta = WIFI_STA(sta);
+
+		WARN_ON(wifi_tid->type != WIFI_TID_STA_QOS_DATA);
+
+		/* filtered data frames and failed frames while STA is
+		 * in PS mode are requeued for software retransmit */
+		if (filtered ||
+		    (!txok && !ps_resp &&
+		     wifi_sta->ps_state != WIFI_PS_AWAKE)) {
+			wskb->sw_tries_done--;
+			txdbg("process_single_mpdu_done: filtered, "
+			      "will requeue\n");
+			wifi_tid_requeue(wifi_tid, wskb);
+			return;
+		}
+
+		wifi_tid_baw_update(wifi_tid, wskb, txok);
+
+		/* if we got at least one positive ACK, we may retry
+		 * to send BAR */
+		if (txok)
+			wifi_tid_baw_bar_may_retry(wifi_tid);
+
+		/*
+		 * since we are may be pushing back frames in retry
+		 * queue, make sure itxq is scheduled
+		 *
+		 * also, some aggr state management and BAR flush
+		 * decision is done as schedule time, so we always
+		 * reschedule tid
+		 */
+		if (wifi_sta->ps_state == WIFI_PS_AWAKE)
+			ieee80211_schedule_txq(wp->hw, TID2ITXQ(wifi_tid));
+	}
+
+	/* continue trying to retransmit any pending BAR whatever aggr
+	 * state is */
+	if (wskb->type == WIFI_TXSKB_BAR) {
+		struct wifi_tid *bar_tid;
+
+		/* lookup bar tid, STA is the same, but tid is not */
+		bar_tid = WIFI_TID(sta->txq[wskb->bar_tid]);
+		WARN_ON(bar_tid->type != WIFI_TID_STA_QOS_DATA);
+
+		wifi_tid_baw_bar_handle_txdone(bar_tid, txok);
+
+		if (!txok) {
+			/* XXX: a bit of a kludge, don't report BAR tx
+			 * failure to mac80211 to avoid any BAR
+			 * retransmit coming from the stack */
+			wifi_tx_skb_release_txfail(wp, wskb);
+			return;
+		}
+	}
+
+report:
+	/* keep a copy of rate counts before calling clear_status(),
+	 * the hardware reports a total number of tries, so we need to
+	 * know the original try count per rate */
+	for (i = 0; i < ARRAY_SIZE(info->control.rates); i++) {
+		const struct ieee80211_tx_rate *r = &info->control.rates[i];
+		rcounts[i] = r->count;
+	}
+
+	ieee80211_tx_info_clear_status(info);
+
+	if (txok) {
+		if (info->flags & IEEE80211_TX_CTL_NO_ACK)
+			info->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED;
+		else
+			info->flags |= IEEE80211_TX_STAT_ACK;
+	}
+
+	if (filtered)
+		info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
+
+	tries_done = txdesc->tries_done;
+	for (i = 0; i < WIFI_TXD_MAX_RATES; i++) {
+		struct ieee80211_tx_rate *r;
+		unsigned int todo;
+
+		r = &info->control.rates[i];
+		if (r->idx == -1)
+			break;
+
+		todo = rcounts[i];
+		if (!tries_done) {
+			r->idx = -1;
+
+		} else if (tries_done > todo) {
+			tries_done -= todo;
+			r->count = todo;
+		} else {
+			r->count = tries_done;
+			tries_done = 0;
+		}
+	}
+
+#ifdef TX_DBG_PRINT
+	for (i = 0; i < 4; i++) {
+		struct ieee80211_tx_rate *r = &info->status.rates[i];
+		txdbg("process_single_mpdu_done: rate:%u tried %u times\n",
+		       r->idx, r->count);
+	}
+#endif
+
+	/* NOTE: this will consumes skb */
+	ieee80211_tx_status_ext(wp->hw, &tx_status);
+	wifi_tx_skb_release_keep_skb(wp, wskb);
+}
+
+/*
+ *
+ */
+static int wifi_process_tx_done(struct wifi_priv *wp, unsigned int qid)
+{
+	struct wifi_txq *txq;
+	u32 reclaim_off;
+	bool need_wake;
+	struct ieee80211_sta *sta;
+
+	txdbg("===== wifi_process_tx_done\n");
+
+	txq = &wp->txqs[qid];
+	spin_lock(&txq->lock);
+
+	need_wake = false;
+
+	reclaim_off = txq->reclaim_off;
+	if (txq->count == WIFI_TX_DESCS) {
+		need_wake = true;
+		/* WARN_ON(!ieee80211_queue_stopped(wp->hw, txq->idx)); */
+	}
+
+	sta = NULL;
+	while (txq->count) {
+		struct wifi_tx_skb *wskb;
+		struct wifi_txd *txdesc;
+		struct wifi_tid *wifi_tid;
+		struct wifi_sta *wifi_sta;
+		const struct ieee80211_hdr *d11;
+		bool report;
+
+		rmb();
+
+		txdesc = &txq->descs[reclaim_off];
+		if (le32_to_cpu(txdesc->status) & TXD_F_FW_OWNED)
+			break;
+
+		/* printk("tx done: desc:%p status:%08x buf:%08x\n", */
+		/*        txdesc, txdesc->status, txdesc->buf_addr); */
+		wskb = txq->pending_wskb[reclaim_off];
+		txq->pending_wskb[reclaim_off] = NULL;
+		txdbg("wifi_process_tx_done: tx done on "
+		      "wskb:%ps has_tid:%d tid:%d type:%d seq:%u\n",
+		      wskb, wskb->has_tid, wskb->tid, wskb->type, wskb->seq_no);
+
+		reclaim_off++;
+		if (reclaim_off >= WIFI_TX_DESCS)
+			reclaim_off = 0;
+
+		txq->reclaim_off = reclaim_off;
+		txq->count--;
+
+		/*
+		 * lookup STA & TID, rcu lock is held by caller, since
+		 * all AMPDU members have the same STA, optimize to do
+		 * a single lookup
+		 */
+		if (!wskb->has_tid) {
+			sta = NULL;
+		} else if (!sta) {
+			d11 = (const struct ieee80211_hdr *)wskb->skb->data;
+			sta = ieee80211_find_sta_by_ifaddr(wp->hw,
+							   d11->addr1,
+							   d11->addr2);
+		}
+
+		wifi_tid = NULL;
+		wifi_sta = NULL;
+		if (sta && wskb->has_tid) {
+			wifi_sta = WIFI_STA(sta);
+			if (wifi_sta->magic != WIFI_STA_MAGIC ||
+			    wifi_sta->version != wskb->sta_version)
+				wifi_sta = NULL;
+			else {
+				spin_lock(&wifi_sta->lock);
+				if (wifi_sta->dead) {
+					spin_unlock(&wifi_sta->lock);
+					wifi_sta = NULL;
+				} else
+					wifi_tid = WIFI_TID(sta->txq[wskb->tid]);
+			}
+		}
+
+		txdbg("wifi_process_tx_done:  sta:%pM tid:%pS\n",
+		      sta ? sta->addr : NULL, wifi_tid);
+
+		/*
+		 * we will only report single mpdu or last mpdu of
+		 * aggreagate
+		 */
+		report = !wskb->aggr_member || !list_empty(&wskb->aggr_list);
+
+		if (report) {
+			if (!wskb->aggr_member) {
+				tx_done_process_single_mpdu(wp, wskb, txdesc,
+							    sta, wifi_tid);
+				txq->non_aggr_count--;
+			} else {
+				tx_done_process_aggr_chain(wp,
+							   &wskb->aggr_list,
+							   txdesc,
+							   sta, wifi_tid);
+				txq->aggr_count--;
+			}
+		}
+
+		/*
+		 * tx pending accounting for this tid
+		 */
+		if (wifi_sta) {
+			wifi_sta->tx_pending--;
+
+			/* printk("tx pending minus alt now %d\n", */
+			/*        wifi_sta->tx_pending); */
+			if (!wifi_sta->tx_pending &&
+			    wifi_sta->ps_state == WIFI_PS_ENTER_SLEEP) {
+				txdbg("tx pending alt %d reached 0\n",
+				      wifi_sta->tx_pending);
+				wifi_sta_ps_transition(wp->hw, sta,
+						       WIFI_PS_ACTION_TXDONE);
+			}
+
+			txdbg("wifi_process_tx_done: sta %pM "
+			      "tx pending now %d\n",
+			      sta->addr,
+			      wifi_sta->tx_pending);
+
+			spin_unlock(&wifi_sta->lock);
+		}
+
+		/* lookup STA again next loop if frame was single mpdu
+		 * or last ampdu member */
+		if (report)
+			sta = NULL;
+	}
+
+	if (txq->count != WIFI_TX_DESCS && need_wake) {
+		/* printk("tx_status: ieee80211_awake %d\n", txq->idx); */
+		ieee80211_wake_queue(wp->hw, txq->idx);
+	}
+
+	if (txq->count < WIFI_TX_DESCS_WAKE)
+		wifi_txq_schedule(wp->hw, txq);
+
+	spin_unlock(&txq->lock);
+	return 0;
+}
+
+/*
+ * @tx: Handler that 802.11 module calls for each transmitted frame.
+ *	skb contains the buffer starting from the IEEE 802.11 header.
+ *	The low-level driver should send the frame out based on
+ *	configuration in the TX control data. This handler should,
+ *	preferably, never fail and stop queues appropriately.
+ *	Must be atomic.
+ *
+ */
+static void wifi_ops_tx(struct ieee80211_hw *hw,
+			struct ieee80211_tx_control *control,
+			struct sk_buff *skb)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct wifi_txq *wifi_txq;
+	const struct ieee80211_hdr *hdr;
+	struct ieee80211_tx_info *tx_info;
+	struct ieee80211_vif *vif;
+	struct wifi_tx_skb *wskb;
+	struct wifi_sta *wifi_sta;
+	struct list_head chain;
+	bool bypass_ps;
+	int tid;
+
+	WARN_ON(!in_atomic());
+
+	tx_info = IEEE80211_SKB_CB(skb);
+	/* keep VIF before we overwrite it */
+	vif = tx_info->control.vif;
+
+	if (WARN_ON(tx_info->hw_queue >= wp->txq_count))
+		return;
+
+	/* sanity check on space, should not happen since we stop que
+	 * queue when it becomes full */
+	wifi_txq = &wp->txqs[tx_info->hw_queue];
+	spin_lock(&wifi_txq->lock);
+
+	txdbg("===== wifi_ops_tx, queue:%d txq:%ps\n",
+	      tx_info->hw_queue, wifi_txq);
+
+	if (WARN_ON(wifi_txq->count == WIFI_TX_DESCS)) {
+		ieee80211_free_txskb(hw, skb);
+		spin_unlock(&wifi_txq->lock);
+		return;
+	}
+
+	/*
+	 * this is part is a bit kludgy, during powersave service
+	 * period (pspoll), mac80211 will send frames that it would
+	 * normally send through itxq via drv_tx(), thus we lose the
+	 * tid information.
+	 *
+	 * it's important to find back the correct tid to maintain the
+	 * proper tx_pending counter
+	 *
+	 * so we apply the same logic as ieee80211_get_txq() to find
+	 * which tid the frame would have been assigned
+	 */
+	tid = -1;
+	hdr = (const struct ieee80211_hdr *)skb->data;
+	if (ieee80211_is_ctl(hdr->frame_control)) {
+		WARN_ON(!ieee80211_is_back_req(hdr->frame_control));
+		tid = IEEE80211_NUM_TIDS;
+	} else if (!ieee80211_is_data_present(hdr->frame_control)) {
+		if ((!ieee80211_is_mgmt(hdr->frame_control) ||
+		     ieee80211_is_bufferable_mmpdu(hdr->frame_control) ||
+		     vif->type == NL80211_IFTYPE_STATION) &&
+		    control->sta) {
+			tid = IEEE80211_NUM_TIDS;
+		}
+	} else if (control->sta)
+		tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
+
+	wskb = wifi_tx_skb_wrap(wp, wifi_txq, skb, control->sta, tid);
+	if (!wskb) {
+		ieee80211_free_txskb(hw, skb);
+		spin_unlock(&wifi_txq->lock);
+		return;
+	}
+
+	bypass_ps = (tx_info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER);
+
+	/* data packet for an existing TID should be only sent from
+	 * drv_tx() during PS-poll, so retryq should be empty */
+	wifi_sta = NULL;
+	if (wskb->has_tid) {
+		txdbg("wifi_ops_tx is for existing TID %d (seq:%u)\n",
+		      wskb->tid, wskb->seq_no);
+
+		wifi_sta = WIFI_STA(control->sta);
+		spin_lock(&wifi_sta->lock);
+
+		if (!ieee80211_is_back_req(hdr->frame_control)) {
+			WARN_ON(!bypass_ps);
+			WARN_ON(wifi_sta->ps_state != WIFI_PS_SLEEP);
+		}
+
+		if (wskb->type == WIFI_TXSKB_QOS_DATA) {
+			struct wifi_tid *wifi_tid;
+
+			/* hopefully mac80211 won't bust the BAW
+			 * window, we are not announcing UAPSD
+			 * support, so it's only frame by frame with
+			 * PS-POLL */
+			wifi_tid = WIFI_TID(control->sta->txq[wskb->tid]);
+			WARN_ON(wifi_tid->ps_sleep_has_buf);
+			wifi_tid_baw_addto(wifi_tid, wskb);
+		}
+	}
+
+	wifi_tx_skb_fill_rates(wskb, vif, control->sta);
+	INIT_LIST_HEAD(&chain);
+	list_add(&wskb->next, &chain);
+
+	/* cannot fail since we checked for available size before */
+	WARN_ON(wifi_tx_send_chain(wp, &chain, 1, false,
+				   control->sta, bypass_ps));
+
+	if (wifi_txq->count == WIFI_TX_DESCS) {
+		/* printk("ops_tx: stop queu %d\n", wifi_txq->idx); */
+		ieee80211_stop_queue(hw, wifi_txq->idx);
+	}
+
+	if (wifi_sta)
+		spin_unlock(&wifi_sta->lock);
+
+	spin_unlock(&wifi_txq->lock);
+}
+
+/*
+ * @wake_tx_queue: Called when new packets have been added to the queue.
+ */
+static void wifi_ops_wake_tx_queue(struct ieee80211_hw *hw,
+				   struct ieee80211_txq *itxq)
+{
+	struct wifi_tid *wifi_tid = WIFI_TID(itxq);
+	struct wifi_txq *wifi_txq = wifi_tid->txq;
+
+	txdbg("===== wifi_ops_wake_tx_queue: vif:%pS sta:%pS\n",
+	       itxq->vif, itxq->sta);
+	WARN_ON(!in_atomic());
+
+	spin_lock(&wifi_txq->lock);
+	wifi_txq_schedule(hw, wifi_txq);
+	spin_unlock(&wifi_txq->lock);
+}
+
+/*
+ * @release_buffered_frames: Release buffered frames according to the given
+ *	parameters. In the case where the driver buffers some frames for
+ *	sleeping stations mac80211 will use this callback to tell the driver
+ *	to release some frames, either for PS-poll or uAPSD.
+ *	Note that if the @more_data parameter is %false the driver must check
+ *	if there are more frames on the given TIDs, and if there are more than
+ *	the frames being released then it must still set the more-data bit in
+ *	the frame. If the @more_data parameter is %true, then of course the
+ *	more-data bit must always be set.
+ *	The @tids parameter tells the driver which TIDs to release frames
+ *	from, for PS-poll it will always have only a single bit set.
+ *	In the case this is used for a PS-poll initiated release, the
+ *	@num_frames parameter will always be 1 so code can be shared. In
+ *	this case the driver must also set %IEEE80211_TX_STATUS_EOSP flag
+ *	on the TX status (and must report TX status) so that the PS-poll
+ *	period is properly ended. This is used to avoid sending multiple
+ *	responses for a retried PS-poll frame.
+ *	In the case this is used for uAPSD, the @num_frames parameter may be
+ *	bigger than one, but the driver may send fewer frames (it must send
+ *	at least one, however). In this case it is also responsible for
+ *	setting the EOSP flag in the QoS header of the frames. Also, when the
+ *	service period ends, the driver must set %IEEE80211_TX_STATUS_EOSP
+ *	on the last frame in the SP. Alternatively, it may call the function
+ *	ieee80211_sta_eosp() to inform mac80211 of the end of the SP.
+ *	This callback must be atomic.
+ */
+static void
+wifi_ops_release_buffered_frames(struct ieee80211_hw *hw,
+				 struct ieee80211_sta *sta,
+				 u16 tids, int num_frames,
+				 enum ieee80211_frame_release_type reason,
+				 bool more_data)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct wifi_sta *wifi_sta = WIFI_STA(sta);
+
+	WARN_ON(!in_atomic());
+	psdbg("wifi_ops_release_buffered_frames, sta:%pM tids:%x num_frame:%d\n",
+	      sta->addr, tids, num_frames);
+
+	/* we don't claim support for UAPSD so we will only get one
+	 * frame at a time */
+	WARN_ON(num_frames > 1 ||
+		reason != IEEE80211_FRAME_RELEASE_PSPOLL);
+
+	while (tids && num_frames) {
+		struct wifi_tid *wifi_tid;
+		struct ieee80211_txq *itxq;
+		u16 tidno = ffs(tids) - 1;
+
+		tids &= ~(1 << tidno);
+		wifi_tid = WIFI_TID(sta->txq[tidno]);
+		itxq = TID2ITXQ(wifi_tid);
+
+		spin_lock(&wifi_tid->txq->lock);
+		spin_lock(&wifi_sta->lock);
+		WARN_ON(wifi_sta->ps_state != WIFI_PS_SLEEP);
+
+		while (num_frames) {
+			struct wifi_tx_skb *wskb;
+			struct list_head chain;
+			struct ieee80211_tx_info *info;
+
+			switch (wifi_tid->type) {
+			case WIFI_TID_MCAST:
+			case WIFI_TID_STA_MMPDU:
+			case WIFI_TID_STA_DATA:
+				wskb = wifi_tid_dequeue_only_mac80211(wp,
+								      itxq);
+				break;
+			case WIFI_TID_STA_QOS_DATA:
+				wskb = wifi_tid_dequeue_within_baw_limit(wp,
+									 itxq);
+				break;
+			}
+
+			if (!wskb) {
+				/* we would not be called if there was
+				 * no frame to dequeue, but with codel
+				 * on txqueue it's actually possible
+				 * that packets sit in itxq for too
+				 * long and are dropped at dequeue
+				 * time, so we get called for
+				 * nothing
+				 *
+				 * this should be fixed to return an
+				 * error to the caller which could
+				 * then send a NULL frame
+				 */
+				break;
+			}
+
+			if (!more_data) {
+				/* this seems wrong because we don't
+				 * know if itxq became empty */
+				more_data = !list_empty(&wifi_tid->retry_q);
+			}
+
+			wifi_tx_skb_set_more_data(wp, wskb, more_data);
+
+			psdbg("wifi_ops_release_buffered_frames: "
+			      "wskb:%pS more_data:%d\n",
+			      wskb, more_data);
+
+			INIT_LIST_HEAD(&chain);
+			list_add(&wskb->next, &chain);
+
+			/* mark it so that tx complete path won't
+			 * retry it */
+			info = IEEE80211_SKB_CB(wskb->skb);
+			info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
+			num_frames--;
+
+			/* mark it so that tx complete path will
+			 * report EOSP to mac80211 */
+			if (!num_frames)
+				info->flags |= IEEE80211_TX_STATUS_EOSP |
+					IEEE80211_TX_CTL_REQ_TX_STATUS;
+
+			WARN_ON(wifi_tx_send_chain(wp, &chain, 1, false,
+						   sta, true));
+		}
+
+		spin_unlock(&wifi_sta->lock);
+		spin_unlock(&wifi_tid->txq->lock);
+	}
+}
+
+/*
+ * @sta_notify: Notifies low level driver about power state transition of an
+ *	associated station, AP,  IBSS/WDS/mesh peer etc. For a VIF operating
+ *	in AP mode, this callback will not be called when the flag
+ *	%IEEE80211_HW_AP_LINK_PS is set. Must be atomic.
+ */
+static void wifi_ops_sta_notify(struct ieee80211_hw *hw,
+				struct ieee80211_vif *vif,
+				enum sta_notify_cmd cmd,
+				struct ieee80211_sta *sta)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct wifi_sta *wifi_sta = WIFI_STA(sta);
+	size_t tidno;
+
+	WARN_ON(!in_atomic());
+
+	if (wifi_sta->magic != WIFI_STA_MAGIC)
+		return;
+
+	psdbg("wifi_ops_sta_notify: sta->addr:%pM sleeping:%d\n",
+	      sta->addr, (cmd == STA_NOTIFY_SLEEP));
+
+	spin_lock(&wifi_sta->lock);
+	wifi_sta_ps_transition(hw, sta,
+			       (cmd == STA_NOTIFY_SLEEP) ?
+			       WIFI_PS_ACTION_SLEEP :
+			       WIFI_PS_ACTION_WAKEUP);
+	spin_unlock(&wifi_sta->lock);
+
+	/* when waking up, reschedule all txq used by this STA */
+	if (cmd == STA_NOTIFY_AWAKE) {
+		size_t qid, to_sched;
+
+		to_sched = 0;
+		for (tidno = 0; tidno < IEEE80211_NUM_TIDS + 1; tidno++) {
+			struct wifi_tid *wifi_tid = WIFI_TID(sta->txq[tidno]);
+			to_sched |= (1 << wifi_tid->txq->idx);
+		}
+
+		while (to_sched) {
+			struct wifi_txq *wifi_txq;
+
+			qid = ffs(to_sched) - 1;
+			to_sched &= ~(1 << qid);
+			wifi_txq = &wp->txqs[qid];
+
+			spin_lock(&wifi_txq->lock);
+			wifi_txq_schedule(wp->hw, wifi_txq);
+			spin_unlock(&wifi_txq->lock);
+		}
+	}
+}
+
+
+/*
+ *
+ */
+static void wifi_vif_update_beacon(struct ieee80211_hw *hw,
+				   struct ieee80211_vif *vif)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct wifi_vif *wifi_vif = WIFI_VIF(vif);
+	dma_addr_t dma;
+	struct sk_buff *skb;
+
+	skb = ieee80211_beacon_get(hw, vif);
+	if (!skb) {
+		wiphy_err(hw->wiphy, "failed to get beacon skb\n");
+		return;
+	}
+
+	dma = pci_map_single(wp->pdev, skb->data, skb->len,
+			     PCI_DMA_TODEVICE);
+	if (pci_dma_mapping_error(wp->pdev, dma)) {
+		wiphy_err(hw->wiphy,
+			  "failed to dma map beacon\n");
+		dev_kfree_skb(skb);
+		return;
+	}
+
+	cmd_vif_update_beacon_atomic(wp, wifi_vif->hw_id, dma, skb->len);
+	pci_unmap_single(wp->pdev, dma, skb->len, PCI_DMA_TODEVICE);
+	dev_kfree_skb(skb);
+}
+
+/*
+² *
+ */
+static void wifi_handle_tbtt(struct wifi_priv *wp, u32 tbtt_idx)
+{
+	struct ieee80211_vif *vif;
+	unsigned int dtim_count;
+	struct wifi_txq *cab_txq;
+	struct wifi_vif *wifi_vif;
+
+	if (WARN_ON(tbtt_idx >= ARRAY_SIZE(wp->vifs_by_tbtt_idx)))
+		return;
+
+	spin_lock(&wp->vifs_by_tbtt_lock);
+	vif = wp->vifs_by_tbtt_idx[tbtt_idx];
+	if (!vif) {
+		spin_unlock(&wp->vifs_by_tbtt_lock);
+		if (net_ratelimit())
+			dev_err(wp->dev, "tbtt interrupt on unknown vif %u",
+				tbtt_idx);
+		return;
+	}
+
+	/* get current DTIM count */
+	wifi_vif = WIFI_VIF(vif);
+	if (cmd_vif_get_dtim_count_atomic(wp, wifi_vif->hw_id, &dtim_count)) {
+		spin_unlock(&wp->vifs_by_tbtt_lock);
+		return;
+	}
+
+	/* resync with hardware, we get this interrupt early before
+	 * next TBTT, dtim count we read here will change at next TBTT
+	 * interrupt */
+	ieee80211_force_dtim(vif, dtim_count);
+
+	/* this will call get_beacon, which will decrement dtim
+	 * count */
+	wifi_vif_update_beacon(wp->hw, vif);
+
+	cab_txq = &wp->txqs[vif->cab_queue];
+	spin_lock(&cab_txq->lock);
+
+	/* FIXME: limit number of packet we push here */
+	while (cab_txq->count < WIFI_TX_DESCS) {
+		struct sk_buff *skb;
+		struct wifi_tx_skb *wskb;
+		struct list_head chain;
+
+		skb = ieee80211_get_buffered_bc(wp->hw, vif);
+		if (!skb)
+			break;
+
+		wskb = wifi_tx_skb_wrap(wp, cab_txq, skb, NULL, -1);
+		if (!wskb)
+			dev_kfree_skb(skb);
+
+		wifi_tx_skb_fill_rates(wskb, vif, NULL);
+		INIT_LIST_HEAD(&chain);
+		list_add(&wskb->next, &chain);
+
+		if (wifi_tx_send_chain(wp, &chain, 1, false, NULL, false))
+			wifi_tx_skb_release_txfail(wp, wskb);
+	}
+	spin_unlock(&cab_txq->lock);
+	spin_unlock(&wp->vifs_by_tbtt_lock);
+}
+
+/*
+ *
+ */
+static u32 wifi_process(void *data, u32 irq_status)
+{
+	struct wifi_priv *wp = (struct wifi_priv *)data;
+	u32 remain = 0;
+
+	/* check for async command completion */
+	if (irq_status & wp->cmd_chans[WIFI_CMD_CHAN_ASYNC].f2h_irq_mask)
+		cmd_chan_async_handle_irq(wp);
+
+	/* check for TBTT */
+	if (irq_status & wp->tbtt_f2h_irq_mask) {
+		u32 tbtt_mask;
+
+		tbtt_mask = (irq_status & wp->tbtt_f2h_irq_mask) >>
+			wp->tbtt_f2h_irq_shift;
+		while (tbtt_mask) {
+			u32 tbtt_idx = ffs(tbtt_mask) - 1;
+			wifi_handle_tbtt(wp, tbtt_idx);
+			tbtt_mask &= ~(1 << tbtt_idx);
+		}
+	}
+
+	/* check for rx */
+	if (irq_status & wp->rx_f2h_irq_mask) {
+		int done;
+
+		done = wifi_process_rx(wp, 128);
+		wifi_rxq_refill(wp, 128);
+		if (done >= 128)
+			remain |= wp->rx_f2h_irq_mask;
+	}
+
+	/* check for tx done */
+	if (irq_status & wp->tx_f2h_irq_mask) {
+		u32 queue_mask;
+
+		queue_mask = (irq_status & wp->tx_f2h_irq_mask)	>>
+			wp->tx_f2h_irq_shift;
+
+		/* tx completion will usually lookup STA which needs
+		 * to be done under RCU lock */
+		rcu_read_lock();
+		while (queue_mask) {
+			u32 qid = ffs(queue_mask) - 1;
+			wifi_process_tx_done(wp, qid);
+			queue_mask &= ~(1 << qid);
+		}
+		rcu_read_unlock();
+	}
+
+	return remain;
+}
+
+/**
+ * @get_stats: Return low-level statistics.
+ * 	Returns zero if statistics are available.
+ *	The callback can sleep.
+ */
+static int wifi_ops_get_stats(struct ieee80211_hw *hw,
+			      struct ieee80211_low_level_stats *stats)
+{
+	printk("ops get stats\n");
+
+	/* struct wifi_priv *wp = hw->priv; */
+	/* struct wifi_txq *wifi_txq; */
+	/* wifi_txq = &wp->txqs[0]; */
+
+	return 0;
+}
+
+/**
+ * @ampdu_action:
+ * Perform a certain A-MPDU action.
+ * The RA/TID combination determines the destination and TID we want
+ * the ampdu action to be performed for. The action is defined through
+ * ieee80211_ampdu_mlme_action.
+ * When the action is set to %IEEE80211_AMPDU_TX_OPERATIONAL the driver
+ * may neither send aggregates containing more subframes than @buf_size
+ * nor send aggregates in a way that lost frames would exceed the
+ * buffer size. If just limiting the aggregate size, this would be
+ * possible with a buf_size of 8:
+ *
+ * - ``TX: 1.....7``
+ * - ``RX:  2....7`` (lost frame #1)
+ * - ``TX:        8..1...``
+ *
+ * which is invalid since #1 was now re-transmitted well past the
+ * buffer size of 8. Correct ways to retransmit #1 would be:
+ *
+ * - ``TX:        1   or``
+ * - ``TX:        18  or``
+ * - ``TX:        81``
+ *
+ * Even ``189`` would be wrong since 1 could be lost again.
+ *
+ * Returns a negative error code on failure.
+ * The callback can sleep.
+ */
+static int
+wifi_ops_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+		      struct ieee80211_ampdu_params *params)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct ieee80211_sta *sta = params->sta;
+	struct wifi_sta *wifi_sta = WIFI_STA(sta);
+	int ret;
+
+	spin_lock_bh(&wifi_sta->lock);
+
+	switch (params->action) {
+	case IEEE80211_AMPDU_RX_START:
+		aggdbg("%pM ampdu action rx start called\n", sta->addr);
+		ret = 0;
+		break;
+
+	case IEEE80211_AMPDU_RX_STOP:
+		aggdbg("%pM ampdu action rx stop called\n", sta->addr);
+		ret = 0;
+		break;
+
+	case IEEE80211_AMPDU_TX_START:
+	{
+		struct wifi_tid *wifi_tid = WIFI_TID(sta->txq[params->tid]);
+
+		WARN_ON(wifi_tid->aggr_state != WIFI_AGGR_STOPPED);
+		wifi_tid->ampdu_max_bytes =
+			(1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
+			       sta->ht_cap.ampdu_factor)) - 1;
+		wifi_tid->ampdu_density = sta->ht_cap.ampdu_density;
+		wifi_tid->aggr_state = WIFI_AGGR_ACTIVE;
+		/* start with minimal BAW size, until it's updated
+		 * when going into operational */
+		wifi_tid->baw_max_size = 1;
+		wifi_tid->remote_baw_max_size = 1;
+		/* update BA SSN with current BAW sequence start */
+		params->ssn = wifi_tid->seq_start;
+		aggdbg("%pM ampdu action tx start called, "
+		       "tid:%u ssn:%u max:%u dens:%u\n",
+		       sta->addr,
+		       params->tid,
+		       params->ssn,
+		       wifi_tid->ampdu_max_bytes,
+		       wifi_tid->ampdu_density);
+		ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, params->tid);
+		break;
+	}
+
+	case IEEE80211_AMPDU_TX_OPERATIONAL:
+	{
+		struct wifi_tid *wifi_tid = WIFI_TID(sta->txq[params->tid]);
+
+		/* don't go larger than what both our hardware and
+		 * remote can support */
+		WARN_ON(params->buf_size < 1);
+		wifi_tid->remote_baw_max_size = params->buf_size;
+		wifi_tid->baw_max_size = min(wp->hw_max_ampdu_chain,
+					 (int)wifi_tid->remote_baw_max_size);
+
+		aggdbg("%pM ampdu action tx operational called, "
+		       "tid:%u baw_max_size:%u\n",
+		       sta->addr,
+		       params->tid,
+		       wifi_tid->baw_max_size);
+		break;
+	}
+
+	case IEEE80211_AMPDU_TX_STOP_CONT:
+	{
+		struct wifi_tid *wifi_tid = WIFI_TID(sta->txq[params->tid]);
+
+		aggdbg("%pM ampdu action tx stop called\n",
+		       sta->addr);
+
+		/*
+		 * note: we could stop aggregation from here instead
+		 * of letting it drain while
+		 */
+		if (!wifi_tid_baw_has_inflight_packets(wifi_tid)) {
+			wifi_tid->aggr_state = WIFI_AGGR_STOPPED;
+			ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr,
+							params->tid);
+			aggdbg("%pM stopped aggr!\n", sta->addr);
+		} else {
+			wifi_tid->aggr_state = WIFI_AGGR_STOPPING;
+			aggdbg("%pM mark aggr as stopping...\n",
+			       sta->addr);
+		}
+		break;
+	}
+
+	case IEEE80211_AMPDU_TX_STOP_FLUSH:
+	case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
+	{
+		struct wifi_tid *wifi_tid = WIFI_TID(sta->txq[params->tid]);
+
+		aggdbg("%pM ampdu action tx stop FLUSH called\n",
+		       sta->addr);
+
+		/* this is called before STA removal, but the STA/TID
+		 * is still be visible to tx done handler, which can
+		 * requeue packets to retry_q and reschedule the
+		 * TID, this flag prevents this */
+		wifi_sta->dead = true;
+		wifi_tid_drain(wp, wifi_tid);
+		wifi_tid->aggr_state = WIFI_AGGR_STOPPED;
+		break;
+	}
+
+	default:
+		/* should not be called */
+		break;
+	}
+
+	spin_unlock_bh(&wifi_sta->lock);
+	return ret;
+}
+
+/*
+ * @can_aggregate_in_amsdu: Called in order to determine if HW supports
+ *	aggregating two specific frames in the same A-MSDU. The relation
+ *	between the skbs should be symmetric and transitive. Note that while
+ *	skb is always a real frame, head may or may not be an A-MSDU.
+ */
+static bool wifi_ops_can_aggregate_in_amsdu(struct ieee80211_hw *hw,
+					    struct sk_buff *head,
+					    struct sk_buff *skb)
+{
+	/* should be ok to do this, but requires testing, rtw88 dev
+	 * says it does not bring anything in performance for 2.4G
+	 * band, and confuses some AP */
+	return false;
+}
+
+/*
+ * @sta_add: Notifies low level driver about addition of an associated
+ *     station, AP, IBSS/WDS/mesh peer etc. This callback can sleep.
+ */
+static int wifi_ops_set_key(struct ieee80211_hw *hw,
+			    enum set_key_cmd cmd_param,
+			    struct ieee80211_vif *vif,
+			    struct ieee80211_sta *sta,
+			    struct ieee80211_key_conf *key)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct wifi_vif *wifi_vif = WIFI_VIF(vif);
+	struct wifi_sta *wifi_sta;
+	int ret;
+	__le16 sta_hwid;
+
+	switch (key->cipher) {
+	case WLAN_CIPHER_SUITE_CCMP:
+		if (vif->type == NL80211_IFTYPE_MESH_POINT &&
+		    !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
+			/* IBSS RSN group keys */
+			return -EOPNOTSUPP;
+		}
+		break;
+	default:
+		return -EOPNOTSUPP;
+	}
+
+	sta_hwid = WIFI_INVALID_STA_HWID;
+	if (sta) {
+		if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
+			return -EOPNOTSUPP;
+		wifi_sta = WIFI_STA(sta);
+		sta_hwid = wifi_sta->hw_id;
+	}
+
+	switch (cmd_param) {
+	case SET_KEY:
+		ret = cmd_vif_add_key(wp,
+				      wifi_vif->hw_id,
+				      sta_hwid,
+				      key->keyidx,
+				      key->key,
+				      &key->hw_key_idx);
+		break;
+
+	case DISABLE_KEY:
+		ret = cmd_vif_del_key(wp,
+				      wifi_vif->hw_id,
+				      sta_hwid,
+				      key->hw_key_idx);
+		break;
+
+	default:
+		ret = -EOPNOTSUPP;
+		break;
+	}
+
+	return ret;
+}
+
+/*
+ * @sta_add: Notifies low level driver about addition of an associated
+ *     station, AP, IBSS/WDS/mesh peer etc. This callback can sleep.
+ */
+static int
+wifi_ops_sta_add(struct ieee80211_hw *hw,
+		 struct ieee80211_vif *vif,
+		 struct ieee80211_sta *sta)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct wifi_vif *wifi_vif = WIFI_VIF(vif);
+	struct wifi_sta *wifi_sta = WIFI_STA(sta);
+	size_t tidno;
+	int ret;
+
+	ret = cmd_vif_add_sta(wp, wifi_vif->hw_id,
+			      sta->addr, &wifi_sta->hw_id);
+	if (ret < 0)
+		return 0;
+
+	spin_lock_init(&wifi_sta->lock);
+	wifi_sta->version = ++wp->sta_next_version;
+	wifi_sta->tx_pending = 0;
+	wifi_sta->ps_state = WIFI_PS_AWAKE;
+
+	/* initialize all itxq private data */
+	for (tidno = 0; tidno < IEEE80211_NUM_TIDS + 1; tidno++) {
+		struct wifi_tid *wifi_tid = WIFI_TID(sta->txq[tidno]);
+		unsigned int acno = TID_TO_WME_AC(tidno);
+		unsigned int qid = vif->hw_queue[acno];
+		enum wifi_tid_type type;
+
+		if (tidno == IEEE80211_NUM_TIDS)
+			type = WIFI_TID_STA_MMPDU;
+		else if (sta->wme)
+			type = WIFI_TID_STA_QOS_DATA;
+		else
+			type = WIFI_TID_STA_DATA;
+
+		wifi_tid_init(wifi_tid, &wp->txqs[qid], type);
+	}
+
+	wmb();
+	wifi_sta->magic = WIFI_STA_MAGIC;
+
+	return 0;
+}
+
+/*
+ * @sta_remove: Notifies low level driver about removal of an associated
+ *	station, AP, IBSS/WDS/mesh peer etc. Note that after the callback
+ *	returns it isn't safe to use the pointer, not even RCU protected;
+ *	no RCU grace period is guaranteed between returning here and freeing
+ *	the station. See @sta_pre_rcu_remove if needed.
+ *	This callback can sleep.
+ */
+static int wifi_ops_sta_remove(struct ieee80211_hw *hw,
+			       struct ieee80211_vif *vif,
+			       struct ieee80211_sta *sta)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct wifi_vif *wifi_vif = WIFI_VIF(vif);
+	struct wifi_sta *wifi_sta = WIFI_STA(sta);
+	size_t tidno;
+	int ret;
+
+	for (tidno = 0; tidno < IEEE80211_NUM_TIDS + 1; tidno++) {
+		struct wifi_tid *wifi_tid = WIFI_TID(sta->txq[tidno]);
+		wifi_tid_release(wp, wifi_tid);
+	}
+
+	ret = cmd_vif_del_sta(wp, wifi_vif->hw_id,
+			      wifi_sta->hw_id);
+	if (ret < 0)
+		return 0;
+
+	return 0;
+}
+
+
+/*
+ * @bss_info_changed: Handler for configuration requests related to BSS
+ *	parameters that may vary during BSS's lifespan, and may affect low
+ *	level driver (e.g. assoc/disassoc status, erp parameters).
+ *	This function should not be used if no BSS has been set, unless
+ *	for association indication. The @changed parameter indicates which
+ *	of the bss parameters has changed when a call is made. The callback
+ *	can sleep.
+ */
+static void
+wifi_ops_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+			  struct ieee80211_bss_conf *info, u32 changed)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct wifi_vif *wifi_vif = WIFI_VIF(vif);
+
+	/* printk("wifi_ops_bss_info_changed: changed:0x%08x\n", changed); */
+	if (changed & BSS_CHANGED_ERP_CTS_PROT) {
+		/* nothing to do, rate control will flag packets with
+		 * RTS/CTS as needed */
+	}
+
+	if (changed & BSS_CHANGED_ERP_PREAMBLE) {
+		/* nothing to do, rate control will flag packets with
+		 * short/long preamble as needed */
+	}
+
+	if (changed & BSS_CHANGED_ERP_SLOT)
+		cmd_vif_set_short_slot(wp, wifi_vif->hw_id,
+				       info->use_short_slot);
+
+	if (changed & BSS_CHANGED_BSSID)
+		cmd_vif_set_bss_params(wp, wifi_vif->hw_id, info->bssid);
+
+	if (changed & BSS_CHANGED_BEACON_ENABLED) {
+		if (info->enable_beacon) {
+			struct ieee80211_rate *bcn_rate;
+			struct sk_buff *skb;
+			struct ieee80211_tx_info *tx_info;
+
+			skb = ieee80211_beacon_get_template(hw, vif, NULL);
+			if (!skb)
+				return;
+
+			tx_info = IEEE80211_SKB_CB(skb);
+			bcn_rate = ieee80211_get_tx_rate(hw, tx_info);
+			cmd_vif_set_beacon_params(wp, wifi_vif->hw_id,
+						  bcn_rate->hw_value,
+						  info->beacon_int,
+						  info->dtim_period);
+			dev_kfree_skb(skb);
+		}
+
+		cmd_vif_enable_beacon(wp, wifi_vif->hw_id,
+				      info->enable_beacon);
+	}
+
+	if (changed & BSS_CHANGED_HT) {
+	}
+}
+
+/*
+ * compute number of bytes for a frames of usecs duration at given
+ * rate
+ */
+static int usec_to_framelen(int usecs, int mcs, bool ht40, bool sgi)
+{
+	int streams = (mcs / 8) + 1;
+	int symbols, bits;
+	int bytes = 0;
+
+	usecs -= L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams);
+	symbols = sgi ? TIME_SYMBOLS_HALFGI(usecs) : TIME_SYMBOLS(usecs);
+	bits = symbols * bits_per_symbol[mcs % 8][ht40] * streams;
+	bits -= OFDM_PLCP_BITS;
+	bytes = bits / 8;
+
+	/* if (mcs == 15) */
+	/* 	printk("mcs:%d ht40:%u sgi:%u => %u usecs == %u bytes\n", */
+	/* 	       mcs, ht40, sgi, usecs, bytes); */
+	if (bytes > 65532)
+		bytes = 65532;
+
+	return bytes;
+}
+
+/**
+ * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
+ *	bursting) for a hardware TX queue.
+ *	Returns a negative error code on failure.
+ *	The callback can sleep.
+ */
+static int wifi_ops_conf_tx(struct ieee80211_hw *hw,
+			    struct ieee80211_vif *vif, u16 ac,
+			    const struct ieee80211_tx_queue_params *params)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct wifi_vif *wifi_vif = WIFI_VIF(vif);
+	struct wifi_txq *wifi_txq;
+	u16 *cur_ht20, *cur_ht20_sgi, *cur_ht40, *cur_ht40_sgi;
+	int mcs;
+	u32 txop;
+
+	/* printk("conf tx called, ac:%d cw:%d/%d aifsn:%d txop:%d\n", */
+	/*        ac, */
+	/*        params->cw_min, */
+	/*        params->cw_max, */
+	/*        params->aifs, */
+	/*        params->txop); */
+
+	if (cmd_vif_set_edca_params(wp,
+				    wifi_vif->hw_id,
+				    vif->hw_queue[ac],
+				    params->cw_min,
+				    params->cw_max,
+				    params->aifs,
+				    params->txop))
+		return 1;
+
+	/* compute aggregate max len for this queue */
+	wifi_txq = &wp->txqs[vif->hw_queue[ac]];
+
+	/* 4ms is the default (and maximum) duration */
+	txop = params->txop;
+	if (!txop || txop > 4096)
+		txop = 4096;
+
+	cur_ht20 = wifi_txq->max_aggr_framelen[0][0];
+	cur_ht20_sgi = wifi_txq->max_aggr_framelen[0][1];
+	cur_ht40 = wifi_txq->max_aggr_framelen[1][0];
+	cur_ht40_sgi = wifi_txq->max_aggr_framelen[1][1];
+
+	for (mcs = 0; mcs < 32; mcs++) {
+		cur_ht20[mcs] = usec_to_framelen(txop, mcs, false, false);
+		cur_ht20_sgi[mcs] = usec_to_framelen(txop, mcs, false, true);
+		cur_ht40[mcs] = usec_to_framelen(txop, mcs, true, false);
+		cur_ht40_sgi[mcs] = usec_to_framelen(txop, mcs, true, true);
+	}
+
+	return 0;
+}
+
+
+/*
+ * @add_interface: Called when a netdevice attached to the hardware is
+ *	enabled. Because it is not called for monitor mode devices, @start
+ *	and @stop must be implemented.
+ *	The driver should perform any initialization it needs before
+ *	the device can be enabled. The initial configuration for the
+ *	interface is given in the conf parameter.
+ *	The callback may refuse to add an interface by returning a
+ *	negative error code (which will be seen in userspace.)
+ *	Must be implemented and can sleep.
+ */
+static int wifi_ops_add_interface(struct ieee80211_hw *hw,
+				  struct ieee80211_vif *vif)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct wifi_vif *wifi_vif = WIFI_VIF(vif);
+	struct wifi_tid *wifi_tid_mc = WIFI_TID(vif->txq);
+	enum wifi_vif_type vif_type;
+	unsigned int ac_mapping[IEEE80211_NUM_ACS], cab_qid;
+	size_t i;
+	int ret;
+
+	/* printk("wifi_ops_add_interface\n"); */
+
+	switch (vif->type) {
+	case NL80211_IFTYPE_STATION:
+		vif_type = WIFI_VIF_TYPE_STA;
+		break;
+	case NL80211_IFTYPE_AP:
+	case NL80211_IFTYPE_MESH_POINT:
+		vif_type = WIFI_VIF_TYPE_AP;
+		break;
+	default:
+		return -ENOTSUPP;
+	}
+
+	ret = cmd_add_vif(wp, vif_type, vif->addr,
+			  &wifi_vif->hw_id,
+			  &wifi_vif->tbtt_idx,
+			  ac_mapping, &cab_qid);
+	if (ret)
+		return ret;
+
+	if (wifi_vif->tbtt_idx != WIFI_INVALID_TBTT_IDX) {
+		if (wifi_vif->tbtt_idx >= ARRAY_SIZE(wp->vifs_by_tbtt_idx) ||
+		    wp->vifs_by_tbtt_idx[wifi_vif->tbtt_idx]) {
+			dev_err(wp->dev, "invalid VIF tbtt idx %x\n",
+				wifi_vif->tbtt_idx);
+			cmd_release_vif(wp, wifi_vif->hw_id);
+			return -EIO;
+		}
+	}
+
+	for (i = 0; i < IEEE80211_NUM_ACS; i++) {
+		vif->hw_queue[i] = ac_mapping[i];
+		/* FIXME: mac80211 limitation here */
+		wp->txqs[vif->hw_queue[i]].ac = i;
+		BUG_ON(vif->hw_queue[i] >= wp->txq_count);
+	}
+	vif->cab_queue = cab_qid;
+
+	ret = cmd_vif_start(wp, wifi_vif->hw_id);
+	if (ret) {
+		cmd_release_vif(wp, wifi_vif->hw_id);
+		return ret;
+	}
+
+	/* init the itxq used to send multicast, we will mix mcast
+	 * with BE traffic, cabq will be used instead when at least
+	 * one STA is in powersave */
+	wifi_tid_init(wifi_tid_mc,
+		      &wp->txqs[ac_mapping[IEEE80211_AC_BE]],
+		      WIFI_TID_MCAST);
+
+	if (wifi_vif->tbtt_idx != WIFI_INVALID_TBTT_IDX) {
+		spin_lock_bh(&wp->vifs_by_tbtt_lock);
+		wp->vifs_by_tbtt_idx[wifi_vif->tbtt_idx] = vif;
+		spin_unlock_bh(&wp->vifs_by_tbtt_lock);
+	}
+
+	return 0;
+}
+
+/*
+ * @remove_interface: Notifies a driver that an interface is going down.
+ *	The @stop callback is called after this if it is the last interface
+ *	and no monitor interfaces are present.
+ *	When all interfaces are removed, the MAC address in the hardware
+ *	must be cleared so the device no longer acknowledges packets,
+ *	the mac_addr member of the conf structure is, however, set to the
+ *	MAC address of the device going away.
+ *	Hence, this callback must be implemented. It can sleep.
+ */
+static void wifi_ops_remove_interface(struct ieee80211_hw *hw,
+				      struct ieee80211_vif *vif)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct wifi_vif *wifi_vif = WIFI_VIF(vif);
+	struct wifi_tid *wifi_tid_mc = WIFI_TID(vif->txq);
+	int ret;
+
+	/* printk("wifi_ops_remove_interface\n"); */
+
+	/* hide it from interrupt handler */
+	if (wifi_vif->tbtt_idx != WIFI_INVALID_TBTT_IDX) {
+		spin_lock_bh(&wp->vifs_by_tbtt_lock);
+		wp->vifs_by_tbtt_idx[wifi_vif->tbtt_idx] = NULL;
+		spin_unlock_bh(&wp->vifs_by_tbtt_lock);
+	}
+
+	wifi_tid_release(wp, wifi_tid_mc);
+
+	ret = cmd_vif_stop(wp, wifi_vif->hw_id);
+	if (ret) {
+		dev_err(wp->dev, "failed to stop wifi vif\n");
+		return;
+	}
+	cmd_release_vif(wp, wifi_vif->hw_id);
+}
+
+/*
+ *
+ */
+static int wifi_rxq_init(struct wifi_priv *wp)
+{
+	struct wifi_rxq *rxq = &wp->rxq;
+	size_t size;
+
+	rxq->count = 0;
+	rxq->refill_off = 0;
+	rxq->fw_off = 0;
+
+	size = WIFI_RX_DESCS * sizeof (*rxq->descs);
+
+	rxq->descs = pci_zalloc_consistent(wp->pdev, size, &rxq->descs_dma);
+	if (rxq->descs == NULL) {
+		dev_err(wp->dev, "failed to alloc rx descs\n");
+		return -ENOMEM;
+	}
+
+	rxq->bufs = kcalloc(WIFI_RX_DESCS, sizeof(*rxq->bufs), GFP_KERNEL);
+	if (rxq->bufs == NULL) {
+		pci_free_consistent(wp->pdev, size,
+				    rxq->descs, rxq->descs_dma);
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
+/*
+ *
+ */
+static void wifi_rxq_release(struct wifi_priv *wp)
+{
+	struct wifi_rxq *rxq = &wp->rxq;
+	int i;
+
+	if (rxq->descs == NULL)
+		return;
+
+	for (i = 0; i < WIFI_RX_DESCS; i++) {
+		if (!rxq->bufs[i].skb)
+			continue;
+
+		pci_unmap_single(wp->pdev,
+				 dma_unmap_addr(&rxq->bufs[i], dma),
+				 WIFI_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
+		dma_unmap_addr_set(&rxq->bufs[i], dma, 0);
+		kfree_skb(rxq->bufs[i].skb);
+		rxq->bufs[i].skb = NULL;
+	}
+
+	kfree(rxq->bufs);
+	rxq->bufs = NULL;
+	pci_free_consistent(wp->pdev,
+			    WIFI_RX_DESCS * sizeof (*rxq->descs),
+			    rxq->descs, rxq->descs_dma);
+	rxq->descs = NULL;
+}
+
+
+/*
+ *
+ */
+static void wifi_txq_release(struct wifi_priv *wp, struct wifi_txq *txq)
+{
+	struct wifi_tx_skb *wskb, *tmp;
+	int i;
+
+	for (i = 0; i < WIFI_TX_DESCS; i++) {
+		struct wifi_tx_skb *wskb = txq->pending_wskb[i];
+		if (wskb) {
+			wifi_tx_skb_release_txfail(wp, wskb);
+			txq->pending_wskb[i] = NULL;
+		}
+	}
+
+	list_for_each_entry_safe(wskb, tmp, &txq->wifi_tx_skbs_pool, next)
+		kfree(wskb);
+
+	kfree(txq->pending_wskb);
+	pci_free_consistent(wp->pdev,
+			    WIFI_TX_DESCS * sizeof (*txq->descs),
+			    txq->descs, txq->descs_dma);
+}
+
+/*
+ *
+ */
+static int wifi_txq_init(struct wifi_priv *wp, unsigned int idx)
+{
+	struct wifi_txq *txq = &wp->txqs[idx];
+	size_t i, size;
+
+	spin_lock_init(&txq->lock);
+	txq->idx = idx;
+	txq->head_off = 0;
+	txq->reclaim_off = 0;
+	INIT_LIST_HEAD(&txq->wifi_tx_skbs_pool);
+
+	size = WIFI_TX_DESCS * sizeof (*txq->descs);
+
+	txq->descs = pci_zalloc_consistent(wp->pdev, size, &txq->descs_dma);
+	if (txq->descs == NULL) {
+		dev_err(wp->dev, "failed to alloc tx descs\n");
+		goto free;
+	}
+
+	txq->pending_wskb = kcalloc(WIFI_TX_DESCS,
+				    sizeof(*txq->pending_wskb), GFP_KERNEL);
+	if (txq->pending_wskb == NULL)
+		goto free;
+
+	/*
+	 * prefill the wifi_tx_skb pool
+	 *
+	 * When doing tx completion for aggregate, the actual release
+	 * happen when the last packet of the aggregate is marked as
+	 * done by the hardware. So even the tx queue seems to be
+	 * almost empty, some wifi_tx_skb are not yet released. This
+	 * can be at most the maximum size of an aggregate, so we
+	 * alloc a bit more.
+	 */
+	for (i = 0; i < WIFI_TX_DESCS + IEEE80211_AGGR_MAX_MPDU; i++) {
+		struct wifi_tx_skb *wskb;
+
+		wskb = kzalloc(sizeof(*wskb), GFP_KERNEL);
+		if (!wskb)
+			goto free;
+
+		list_add_tail(&wskb->next, &txq->wifi_tx_skbs_pool);
+	}
+
+	return 0;
+
+free:
+	wifi_txq_release(wp, txq);
+	return -ENOMEM;
+}
+
+/*
+ * @start: Called before the first netdevice attached to the hardware
+ *	is enabled. This should turn on the hardware and must turn on
+ *	frame reception (for possibly enabled monitor interfaces.)
+ *	Returns negative error codes, these may be seen in userspace,
+ *	or zero.
+ *	When the device is started it should not have a MAC address
+ *	to avoid acknowledging frames before a non-monitor device
+ *	is added.
+ *	Must be implemented and can sleep.
+ */
+static int wifi_ops_start(struct ieee80211_hw *hw)
+{
+	struct wifi_priv *wp = hw->priv;
+	size_t i;
+	int ret;
+
+	/* printk("wifi_ops_start\n"); */
+
+	ret = wifi_rxq_init(wp);
+	if (ret)
+		goto fail;
+
+	if (wifi_rxq_refill(wp, INT_MAX) != WIFI_RX_DESCS) {
+		dev_err(wp->dev, "failed to refill rxq\n");
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	wp->txqs = kcalloc(wp->txq_count, sizeof (*wp->txqs), GFP_KERNEL);
+	if (!wp->txqs) {
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	for (i = 0; i < wp->txq_count; i++) {
+		ret = wifi_txq_init(wp, i);
+		if (ret)
+			goto fail;
+	}
+
+	if (cmd_start(wp)) {
+		dev_err(wp->dev, "failed to start device\n");
+		ret = -EIO;
+		goto fail;
+	}
+
+	return 0;
+
+fail:
+	if (wp->txqs) {
+		size_t i;
+		for (i = 0; i < wp->txq_count; i++)
+			wifi_txq_release(wp, &wp->txqs[i]);
+		kfree(wp->txqs);
+		wp->txqs = NULL;
+	}
+	wifi_rxq_release(wp);
+	return ret;
+}
+
+/*
+ * @stop: Called after last netdevice attached to the hardware
+ *	is disabled. This should turn off the hardware (at least
+ *	it must turn off frame reception.)
+ *	May be called right after add_interface if that rejects
+ *	an interface. If you added any work onto the mac80211 workqueue
+ *	you should ensure to cancel it on this callback.
+ *	Must be implemented and can sleep.
+ */
+static void wifi_ops_stop(struct ieee80211_hw *hw)
+{
+	struct wifi_priv *wp = hw->priv;
+	size_t i;
+
+	/* printk("wifi_ops_stop\n"); */
+
+	if (cmd_stop(wp))
+		dev_err(wp->dev, "failed to stop device\n");
+
+	for (i = 0; i < wp->txq_count; i++) {
+		wifi_txq_release(wp, &wp->txqs[i]);
+	}
+
+	kfree(wp->txqs);
+	wifi_rxq_release(wp);
+}
+
+/*
+ *
+ */
+static int update_survey(struct ieee80211_hw *hw,
+			 unsigned int chan_idx)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct survey_info *survey = &wp->survey[chan_idx];
+	int ret;
+
+	ret = cmd_get_chan_survey(wp,
+				  &survey->noise,
+				  &survey->time,
+				  &survey->time_busy,
+				  &survey->time_rx,
+				  &survey->time_tx);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ * @get_survey: Return per-channel survey information
+ */
+static int wifi_ops_get_survey(struct ieee80211_hw *hw, int idx,
+			       struct survey_info *survey)
+{
+	struct wifi_priv *wp = hw->priv;
+	struct ieee80211_supported_band *sband;
+
+	if (idx >= ARRAY_SIZE(wp->survey))
+		return -ENOENT;
+
+	if (idx == wp->cur_chan_idx) {
+		int ret = update_survey(hw, idx);
+		if (ret)
+			return ret;
+	}
+
+	memcpy(survey, &wp->survey[idx], sizeof (*survey));
+
+	sband = hw->wiphy->bands[NL80211_BAND_2GHZ];
+	survey->channel = &sband->channels[idx];
+
+	survey->filled =
+		SURVEY_INFO_NOISE_DBM |
+		SURVEY_INFO_TIME |
+		SURVEY_INFO_TIME_BUSY |
+		SURVEY_INFO_TIME_RX |
+		SURVEY_INFO_TIME_TX;
+
+	if (idx == wp->cur_chan_idx)
+		survey->filled |= SURVEY_INFO_IN_USE;
+
+	return 0;
+}
+
+/*
+ * @config: Handler for configuration requests. IEEE 802.11 code calls this
+ *	function to change hardware configuration, e.g., channel.
+ *	This function should never fail but returns a negative error code
+ *	if it does. The callback can sleep.
+ */
+static int wifi_ops_config(struct ieee80211_hw *hw, u32 changed)
+{
+	struct wifi_priv *wp = hw->priv;
+	int ret;
+
+	/* printk("wifi_ops_config: changed:%08x\n", changed); */
+
+	if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
+		if (wp->cur_chan_idx != -1)
+			update_survey(hw, wp->cur_chan_idx);
+
+		ret = wifi_set_channel(wp);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+/*
+ * @prepare_multicast: Prepare for multicast filter configuration.
+ *	This callback is optional, and its return value is passed
+ *	to configure_filter(). This callback must be atomic.
+ */
+static u64 wifi_ops_prepare_multicast(struct ieee80211_hw *hw,
+				      struct netdev_hw_addr_list *mc_list)
+{
+	/* don't try to filter multicast for now */
+	return WIFI_FILTER_ALL_MULTI;
+}
+
+/*
+ * @configure_filter: Configure the device's RX filter.
+ *	See the section "Frame filtering" for more information.
+ *	This callback must be implemented and can sleep.
+ */
+static void wifi_ops_configure_filter(struct ieee80211_hw *hw,
+				      unsigned int changed_flags,
+				      unsigned int *total_flags,
+				      u64 multicast)
+{
+	struct wifi_priv *wp = hw->priv;
+	u32 f;
+
+	/* keep only what we support */
+	*total_flags &=
+		FIF_ALLMULTI |
+		FIF_FCSFAIL |
+		FIF_BCN_PRBRESP_PROMISC |
+		FIF_CONTROL |
+		FIF_OTHER_BSS |
+		FIF_PSPOLL |
+		FIF_PROBE_REQ;
+
+	/* printk("wifi_ops_configure_filter: total_flags:%08x\n", */
+	/*        *total_flags); */
+
+	f = 0;
+	if (*total_flags & FIF_ALLMULTI)
+		f |= WIFI_FILTER_ALL_MULTI;
+	else
+		f |= multicast;
+	if (*total_flags & FIF_FCSFAIL)
+		f |= WIFI_FILTER_FCS_FAIL;
+	if (*total_flags & FIF_OTHER_BSS)
+		f |= WIFI_FILTER_PROMISC;
+	if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
+		f |= WIFI_FILTER_ALL_BSSID;
+	if (*total_flags & FIF_CONTROL)
+		f |= WIFI_FILTER_FTYPE_CONTROL;
+	if (*total_flags & FIF_PSPOLL)
+		f |= WIFI_FILTER_FTYPE_PS_POLL;
+	if (*total_flags & FIF_PROBE_REQ)
+		f |= WIFI_FILTER_FTYPE_PROBE_REQ;
+
+	cmd_set_rx_filter(wp, f);
+}
+
+/*
+ * mac80211 device ops
+ */
+static const struct ieee80211_ops wifi_mac80211_ops = {
+	.tx			= wifi_ops_tx,
+	.wake_tx_queue		= wifi_ops_wake_tx_queue,
+	.release_buffered_frames= wifi_ops_release_buffered_frames,
+	.start			= wifi_ops_start,
+	.stop			= wifi_ops_stop,
+	.add_interface		= wifi_ops_add_interface,
+	.remove_interface	= wifi_ops_remove_interface,
+	.bss_info_changed	= wifi_ops_bss_info_changed,
+	.get_survey		= wifi_ops_get_survey,
+	.config			= wifi_ops_config,
+	.configure_filter	= wifi_ops_configure_filter,
+	.sta_add		= wifi_ops_sta_add,
+	.sta_remove		= wifi_ops_sta_remove,
+	.sta_notify		= wifi_ops_sta_notify,
+	.set_key                = wifi_ops_set_key,
+	.conf_tx		= wifi_ops_conf_tx,
+	.prepare_multicast	= wifi_ops_prepare_multicast,
+	.ampdu_action		= wifi_ops_ampdu_action,
+	.can_aggregate_in_amsdu	= wifi_ops_can_aggregate_in_amsdu,
+	.get_stats		= wifi_ops_get_stats,
+};
+
+/*
+ *
+ */
+static void setup_24hz_band(struct wifi_priv *wp,
+			    struct ieee80211_supported_band *b)
+{
+	struct ieee80211_sta_ht_cap *ht = &b->ht_cap;
+	size_t i;
+
+	b->band = NL80211_BAND_2GHZ;
+	b->channels = gchannels;
+	b->n_channels = ARRAY_SIZE(gchannels);
+	b->bitrates = mwl8k_rates;
+	b->n_bitrates = ARRAY_SIZE(mwl8k_rates);
+
+	ht->ht_supported = true;
+	ht->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
+		IEEE80211_HT_CAP_SGI_20 |
+		IEEE80211_HT_CAP_SGI_40 |
+		IEEE80211_HT_CAP_TX_STBC |
+		IEEE80211_HT_CAP_RX_STBC;
+
+	ht->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;
+	ht->ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
+
+	for (i = 0; i < wp->hw_radio_chains; i++)
+		ht->mcs.rx_mask[i] = 0xff;
+	/* MCS32 */
+	ht->mcs.rx_mask[4] = 0x1;
+
+	ht->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
+}
+
+/*
+ *
+ */
+static int wifi_ieee80211_register(struct wifi_priv *wp)
+{
+	struct ieee80211_hw *hw = wp->hw;
+	size_t count;
+	int ret;
+
+	/* setup wiphy */
+	SET_IEEE80211_PERM_ADDR(hw, wp->addresses[0].addr);
+	hw->wiphy->addresses = wp->addresses;
+	hw->wiphy->n_addresses = wp->addresses_count;
+	count = wp->addresses_count;
+	if (count > 256)
+		count = 256;
+
+	hw->wiphy->interface_modes =
+		BIT(NL80211_IFTYPE_MONITOR) |
+		BIT(NL80211_IFTYPE_AP) |
+		BIT(NL80211_IFTYPE_MESH_POINT) |
+		BIT(NL80211_IFTYPE_STATION);
+
+	wp->if_limits[0].types = BIT(NL80211_IFTYPE_STATION);
+	wp->if_limits[0].max = wp->hw_max_sta_vif;
+
+	wp->if_limits[1].types = BIT(NL80211_IFTYPE_AP);
+#ifdef CONFIG_MAC80211_MESH
+	wp->if_limits[1].types |= BIT(NL80211_IFTYPE_MESH_POINT);
+#endif
+	wp->if_limits[1].max = wp->hw_max_ap_vif;
+
+	wp->if_comb.limits = wp->if_limits;
+	wp->if_comb.n_limits = ARRAY_SIZE(wp->if_limits);
+	wp->if_comb.max_interfaces = wp->hw_max_sta_vif + wp->hw_max_ap_vif;
+	wp->if_comb.num_different_channels = 1;
+	wp->if_comb.beacon_int_min_gcd = wp->hw_bcn_interval_gcd;
+
+	hw->wiphy->iface_combinations = &wp->if_comb;
+	hw->wiphy->n_iface_combinations = 1;
+
+	setup_24hz_band(wp, &wp->gband);
+	hw->wiphy->bands[0] = &wp->gband;
+
+	scnprintf(hw->wiphy->fw_version, sizeof (hw->wiphy->fw_version),
+		  "%u.%u", wp->fw_major, wp->fw_minor);
+
+	hw->wiphy->available_antennas_rx = (1 << wp->hw_radio_chains) - 1;
+	hw->wiphy->available_antennas_tx = (1 << wp->hw_radio_chains) - 1;
+
+	/* disabled until release_buffered_frames is fixed */
+	/* hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; */
+	hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
+
+	/* setup remaining hw fields */
+	ieee80211_hw_set(hw, SIGNAL_DBM);
+	ieee80211_hw_set(hw, PS_NULLFUNC_STACK);
+	ieee80211_hw_set(hw, SUPPORTS_RC_TABLE);
+	ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING);
+	ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
+	ieee80211_hw_set(hw, NO_AUTO_VIF);
+	ieee80211_hw_set(hw, QUEUE_CONTROL);
+	ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU);
+	ieee80211_hw_set(hw, SUPPORTS_CLONED_SKBS);
+	ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
+	ieee80211_hw_set(hw, AMPDU_AGGREGATION);
+	ieee80211_hw_set(hw, BUFF_MMPDU_TXQ);
+	ieee80211_hw_set(hw, STA_MMPDU_TXQ);
+	ieee80211_hw_set(hw, MFP_CAPABLE);
+
+	hw->vif_data_size = sizeof (struct wifi_vif);
+	hw->sta_data_size = sizeof (struct wifi_sta);
+	hw->txq_data_size = sizeof (struct wifi_tid);
+	hw->queues = wp->txq_count;
+	hw->max_rates = WIFI_TXD_MAX_RATES;
+	hw->max_report_rates = WIFI_TXD_MAX_RATES;
+	hw->max_rate_tries = 15;
+	hw->offchannel_tx_hw_queue = 6;
+
+	ret = ieee80211_register_hw(hw);
+	if (ret) {
+		wiphy_err(hw->wiphy, "cannot register device: %d\n", ret);
+		return ret;
+	}
+
+	wp->hw_registered = true;
+	return 0;
+}
+
+/*
+ *
+ */
+static void wifi_release(struct wifi_priv *wp)
+{
+}
+
+/*
+ *
+ */
+static int wifi_init(void *data)
+{
+	struct wifi_priv *wp = (struct wifi_priv *)data;
+	u8 force_mac[ETH_ALEN];
+	u32 api_version;
+	int ret;
+
+	if (cmd_get_api_version(wp, &api_version)) {
+		dev_err(wp->dev, "failed to get api_version\n");
+		return -EIO;
+	}
+
+	if (api_version != WIFI_API_VERSION) {
+		dev_err(wp->dev, "API version mismatch %u\n", api_version);
+		return -EIO;
+	}
+
+	if (cmd_get_fw_version(wp, &wp->fw_major, &wp->fw_minor)) {
+		dev_err(wp->dev, "failed to get fw version\n");
+		return -EIO;
+	}
+
+	dev_info(wp->dev, "wifi firmware version [%u.%u]\n",
+		 wp->fw_major,
+		 wp->fw_minor);
+
+	if (mac_pton(base_mac_addr, force_mac) &&
+	    !is_zero_ether_addr(force_mac) &&
+	    mac_addr_count > 0) {
+		unsigned int i;
+
+		dev_info(wp->dev, "using mac address from module params\n");
+
+		for (i = 0; i < mac_addr_count &&
+			     i < ARRAY_SIZE(wp->addresses); i++) {
+			memcpy(&wp->addresses[i], force_mac, 6);
+			inc_mac(wp->addresses[i].addr, i);
+		}
+
+		wp->addresses_count = mac_addr_count;
+
+	} else {
+		wp->addresses_count = ARRAY_SIZE(wp->addresses);
+		if (cmd_get_mac_address(wp, wp->addresses,
+					&wp->addresses_count)) {
+			dev_err(wp->dev, "failed to get mac address\n");
+			return -EIO;
+		}
+	}
+
+	ret = wifi_ieee80211_register(wp);
+	if (ret)
+		goto fail;
+
+	return 0;
+
+fail:
+	wifi_release(wp);
+	return ret;
+}
+
+/*
+ *
+ */
+static void wifi_exit(void *data)
+{
+	struct wifi_priv *wp = (struct wifi_priv *)data;
+
+	if (!wp->hw_registered)
+		return;
+
+	/* stop processing irq, FIXME: need spinlock for SMP  */
+	wp->rx_f2h_irq_mask = 0;
+	wp->tx_f2h_irq_mask = 0;
+	wp->tbtt_f2h_irq_mask = 0;
+
+	ieee80211_unregister_hw(wp->hw);
+	wifi_release(wp);
+}
+
+/*
+ *
+ */
+static void *
+wifi_alloc(struct mwl8k_priv *priv, void __iomem *vdesc, u32 *poll_mask)
+{
+	struct __iomem ixzone_svc_wifi *desc = vdesc;
+	struct ieee80211_hw *hw;
+	struct wifi_priv *wp;
+	size_t i;
+	u32 off;
+
+	if (!desc->radio.chain_count ||
+	    desc->radio.chain_count > 4) {
+		dev_err(&priv->pdev->dev,
+			"wifi service has invalid radio chains\n");
+		return NULL;
+	}
+
+	if (!desc->tx.max_ampdu_chain) {
+		dev_err(&priv->pdev->dev,
+			"wifi service has invalid max_ampdu_chain\n");
+		return NULL;
+	}
+
+	if (!desc->rx.f2h_irq_mask) {
+		dev_err(&priv->pdev->dev, "wifi service has no rx irq mask\n");
+		return NULL;
+	}
+
+	if (!desc->tx.f2h_irq_mask || !desc->tx.h2f_irq_mask) {
+		dev_err(&priv->pdev->dev, "wifi service has no tx irq mask\n");
+		return NULL;
+	}
+
+	if (desc->vif.max_ap_vif) {
+		if (!desc->vif.bcn_interval_gcd) {
+			dev_err(&priv->pdev->dev,
+				"wifi service has no beacon interval gcd\n");
+			return NULL;
+		}
+
+		if (!desc->vif.tbtt_f2h_irq_mask) {
+			dev_err(&priv->pdev->dev,
+				"wifi service has no tbtt irq mask\n");
+			return NULL;
+		}
+	}
+
+	off = (void *)desc - (void *)priv->sram;
+
+	for (i = 0; i < ARRAY_SIZE(desc->cmd_chans); i++) {
+		const __iomem struct ixzone_svc_wifi_cmd_chan *cdesc;
+		u32 boff, bsize;
+
+		cdesc = &desc->cmd_chans[i];
+
+		if (!cdesc->f2h_irq_mask || !cdesc->h2f_irq_mask) {
+			dev_err(&priv->pdev->dev,
+				"wifi cmd chan %zu has no irq mask\n", i);
+			return NULL;
+		}
+
+		if (cdesc->buf_offset % 4) {
+			dev_err(&priv->pdev->dev,
+				"wifi cmd chan %zu buf not aligned\n", i);
+			return NULL;
+		}
+
+		boff = le32_to_cpu(cdesc->buf_offset);
+		bsize = le32_to_cpu(cdesc->buf_size);
+
+		if (check_bound(SRAM_SIZE, off + boff, bsize)) {
+			dev_err(&priv->pdev->dev,
+				"wifi cmd chan %zu buf has bad offsets\n", i);
+			return NULL;
+		}
+	}
+
+	hw = ieee80211_alloc_hw(sizeof (*wp), &wifi_mac80211_ops);
+	if (!hw) {
+		dev_err(wp->dev, "ieee80211 alloc failed\n");
+		return NULL;
+	}
+
+	wp = hw->priv;
+	wp->hw = hw;
+	wp->priv = priv;
+	wp->cur_chan_idx = -1;
+	spin_lock_init(&wp->vifs_by_tbtt_lock);
+
+	*poll_mask = 0;
+
+	for (i = 0; i < ARRAY_SIZE(desc->cmd_chans); i++) {
+		struct __iomem ixzone_svc_wifi_cmd_chan *cdesc;
+		struct wifi_cmd_chan *chan;
+		u32 boff, bsize;
+
+		cdesc = &desc->cmd_chans[i];
+		boff = le32_to_cpu(cdesc->buf_offset);
+		bsize = le32_to_cpu(cdesc->buf_size);
+
+		chan = &wp->cmd_chans[i];
+		chan->buf_start = priv->sram + off + boff;
+		chan->buf_size = bsize;
+		chan->f2h_irq_mask = le32_to_cpu(cdesc->f2h_irq_mask);
+		chan->h2f_irq_mask = le32_to_cpu(cdesc->h2f_irq_mask);
+		chan->host_count_ptr = &cdesc->host_ctr;
+		chan->fw_count_ptr = &cdesc->fw_ctr;
+
+		mutex_init(&chan->lock);
+		spin_lock_init(&chan->complete_lock);
+
+		/* only watch irq done for async channel, we will
+		 * busy wait for completion on atomic channel */
+		if (i == WIFI_CMD_CHAN_ASYNC)
+			*poll_mask |= chan->f2h_irq_mask;
+	}
+
+	wp->rx_f2h_irq_mask = desc->rx.f2h_irq_mask;
+
+	wp->txq_count = le16_to_cpu(desc->tx.txq_count);
+	wp->hw_max_ampdu_chain = le16_to_cpu(desc->tx.max_ampdu_chain);
+	wp->tx_f2h_irq_mask = le32_to_cpu(desc->tx.f2h_irq_mask);
+	wp->tx_f2h_irq_shift = ffs(wp->tx_f2h_irq_mask) - 1;
+	wp->tx_h2f_irq_mask = le32_to_cpu(desc->tx.h2f_irq_mask);
+	wp->tx_h2f_irq_shift = ffs(wp->tx_h2f_irq_mask) - 1;
+
+	wp->tbtt_f2h_irq_mask = le32_to_cpu(desc->vif.tbtt_f2h_irq_mask);
+	wp->tbtt_f2h_irq_shift = ffs(wp->tbtt_f2h_irq_mask) - 1;
+
+	wp->hw_max_sta_vif = desc->vif.max_sta_vif;
+	wp->hw_max_ap_vif = desc->vif.max_ap_vif;
+	wp->hw_bcn_interval_gcd = desc->vif.bcn_interval_gcd;
+	if (wp->hw_max_ap_vif > WIFI_MAX_AP_VIFS)
+		wp->hw_max_ap_vif = WIFI_MAX_AP_VIFS;
+	wp->hw_radio_chains = le32_to_cpu(desc->radio.chain_count);
+
+	wp->dev = &priv->pdev->dev;
+	wp->pdev = priv->pdev;
+
+	SET_IEEE80211_DEV(hw, &priv->pdev->dev);
+
+	*poll_mask |= wp->rx_f2h_irq_mask |
+		wp->tx_f2h_irq_mask |
+		wp->tbtt_f2h_irq_mask;
+
+	return wp;
+}
+
+/*
+ *
+ */
+static void wifi_free(void *data)
+{
+	struct wifi_priv *wp = (struct wifi_priv *)data;
+	ieee80211_free_hw(wp->hw);
+}
+
+const struct dbg_svc_ops wifi_svc_ops = {
+	.name		= "wifi",
+	.uuid		= SVC_WIFI_UUID,
+	.desc_size	= sizeof (struct ixzone_svc_wifi),
+	.svc_alloc	= wifi_alloc,
+	.svc_init	= wifi_init,
+	.svc_process	= wifi_process,
+	.svc_exit	= wifi_exit,
+	.svc_free	= wifi_free,
+};
+
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/drivers/of/configfs.c	2021-03-04 13:20:59.507505632 +0100
@@ -0,0 +1,279 @@
+/*
+ * Configfs entries for device-tree
+ *
+ * Copyright (C) 2013 - Pantelis Antoniou <panto@antoniou-consulting.com>
+ *
+ * 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/ctype.h>
+#include <linux/cpu.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#include <linux/spinlock.h>
+#include <linux/slab.h>
+#include <linux/proc_fs.h>
+#include <linux/configfs.h>
+#include <linux/types.h>
+#include <linux/stat.h>
+#include <linux/limits.h>
+#include <linux/file.h>
+#include <linux/vmalloc.h>
+#include <linux/firmware.h>
+#include <linux/sizes.h>
+
+#include "of_private.h"
+
+struct cfs_overlay_item {
+	struct config_item	item;
+
+	char			path[PATH_MAX];
+
+	const struct firmware	*fw;
+	struct device_node	*overlay;
+	int			ov_id;
+
+	void			*dtbo;
+	int			dtbo_size;
+};
+
+static inline struct cfs_overlay_item *to_cfs_overlay_item(
+		struct config_item *item)
+{
+	return item ? container_of(item, struct cfs_overlay_item, item) : NULL;
+}
+
+static ssize_t cfs_overlay_item_path_show(struct config_item *item,
+		char *page)
+{
+	struct cfs_overlay_item *overlay = to_cfs_overlay_item(item);
+	return sprintf(page, "%s\n", overlay->path);
+}
+
+static ssize_t cfs_overlay_item_path_store(struct config_item *item,
+		const char *page, size_t count)
+{
+	struct cfs_overlay_item *overlay = to_cfs_overlay_item(item);
+	const char *p = page;
+	char *s;
+	int err;
+
+	/* if it's set do not allow changes */
+	if (overlay->path[0] != '\0' || overlay->dtbo_size > 0)
+		return -EPERM;
+
+	/* copy to path buffer (and make sure it's always zero terminated */
+	count = snprintf(overlay->path, sizeof(overlay->path) - 1, "%s", p);
+	overlay->path[sizeof(overlay->path) - 1] = '\0';
+
+	/* strip trailing newlines */
+	s = overlay->path + strlen(overlay->path);
+	while (s > overlay->path && *--s == '\n')
+		*s = '\0';
+
+	pr_debug("%s: path is '%s'\n", __func__, overlay->path);
+
+	err = request_firmware(&overlay->fw, overlay->path, NULL);
+	if (err != 0)
+		goto out_err;
+
+	err = of_overlay_fdt_apply((void *)overlay->fw->data,
+				   overlay->fw->size,
+				   &overlay->ov_id);
+	if (err != 0)
+		goto out_err;
+
+	return count;
+
+out_err:
+
+	release_firmware(overlay->fw);
+	overlay->fw = NULL;
+
+	overlay->path[0] = '\0';
+	return err;
+}
+
+static ssize_t cfs_overlay_item_status_show(struct config_item *item,
+		char *page)
+{
+	struct cfs_overlay_item *overlay = to_cfs_overlay_item(item);
+
+	return sprintf(page, "%s\n",
+			overlay->ov_id >= 0 ? "applied" : "unapplied");
+}
+
+CONFIGFS_ATTR(cfs_overlay_item_, path);
+CONFIGFS_ATTR_RO(cfs_overlay_item_, status);
+
+static struct configfs_attribute *cfs_overlay_attrs[] = {
+	&cfs_overlay_item_attr_path,
+	&cfs_overlay_item_attr_status,
+	NULL,
+};
+
+ssize_t cfs_overlay_item_dtbo_read(struct config_item *item,
+		void *buf, size_t max_count)
+{
+	struct cfs_overlay_item *overlay = to_cfs_overlay_item(item);
+
+	pr_debug("%s: buf=%p max_count=%zu\n", __func__,
+			buf, max_count);
+
+	if (overlay->dtbo == NULL)
+		return 0;
+
+	/* copy if buffer provided */
+	if (buf != NULL) {
+		/* the buffer must be large enough */
+		if (overlay->dtbo_size > max_count)
+			return -ENOSPC;
+
+		memcpy(buf, overlay->dtbo, overlay->dtbo_size);
+	}
+
+	return overlay->dtbo_size;
+}
+
+ssize_t cfs_overlay_item_dtbo_write(struct config_item *item,
+		const void *buf, size_t count)
+{
+	struct cfs_overlay_item *overlay = to_cfs_overlay_item(item);
+	int err;
+
+	/* if it's set do not allow changes */
+	if (overlay->path[0] != '\0' || overlay->dtbo_size > 0)
+		return -EPERM;
+
+	/* copy the contents */
+	overlay->dtbo = kmemdup(buf, count, GFP_KERNEL);
+	if (overlay->dtbo == NULL)
+		return -ENOMEM;
+
+	overlay->dtbo_size = count;
+
+	err = of_overlay_fdt_apply((void *)overlay->fw->data,
+				   overlay->dtbo_size,
+				   &overlay->ov_id);
+	if (err != 0)
+		goto out_err;
+
+	return count;
+
+out_err:
+	kfree(overlay->dtbo);
+	overlay->dtbo = NULL;
+	overlay->dtbo_size = 0;
+
+	return err;
+}
+
+CONFIGFS_BIN_ATTR(cfs_overlay_item_, dtbo, NULL, SZ_1M);
+
+static struct configfs_bin_attribute *cfs_overlay_bin_attrs[] = {
+	&cfs_overlay_item_attr_dtbo,
+	NULL,
+};
+
+static void cfs_overlay_release(struct config_item *item)
+{
+	struct cfs_overlay_item *overlay = to_cfs_overlay_item(item);
+
+	if (overlay->ov_id >= 0)
+		of_overlay_remove(&overlay->ov_id);
+	if (overlay->fw)
+		release_firmware(overlay->fw);
+	/* kfree with NULL is safe */
+	kfree(overlay->dtbo);
+	kfree(overlay);
+}
+
+static struct configfs_item_operations cfs_overlay_item_ops = {
+	.release	= cfs_overlay_release,
+};
+
+static struct config_item_type cfs_overlay_type = {
+	.ct_item_ops	= &cfs_overlay_item_ops,
+	.ct_attrs	= cfs_overlay_attrs,
+	.ct_bin_attrs	= cfs_overlay_bin_attrs,
+	.ct_owner	= THIS_MODULE,
+};
+
+static struct config_item *cfs_overlay_group_make_item(
+		struct config_group *group, const char *name)
+{
+	struct cfs_overlay_item *overlay;
+
+	overlay = kzalloc(sizeof(*overlay), GFP_KERNEL);
+	if (!overlay)
+		return ERR_PTR(-ENOMEM);
+	overlay->ov_id = -1;
+
+	config_item_init_type_name(&overlay->item, name, &cfs_overlay_type);
+	return &overlay->item;
+}
+
+static void cfs_overlay_group_drop_item(struct config_group *group,
+		struct config_item *item)
+{
+	struct cfs_overlay_item *overlay = to_cfs_overlay_item(item);
+
+	config_item_put(&overlay->item);
+}
+
+static struct configfs_group_operations overlays_ops = {
+	.make_item	= cfs_overlay_group_make_item,
+	.drop_item	= cfs_overlay_group_drop_item,
+};
+
+static struct config_item_type overlays_type = {
+	.ct_group_ops   = &overlays_ops,
+	.ct_owner       = THIS_MODULE,
+};
+
+static struct configfs_group_operations of_cfs_ops = {
+	/* empty - we don't allow anything to be created */
+};
+
+static struct config_item_type of_cfs_type = {
+	.ct_group_ops   = &of_cfs_ops,
+	.ct_owner       = THIS_MODULE,
+};
+
+struct config_group of_cfs_overlay_group;
+
+static struct configfs_subsystem of_cfs_subsys = {
+	.su_group = {
+		.cg_item = {
+			.ci_namebuf = "device-tree",
+			.ci_type = &of_cfs_type,
+		},
+	},
+	.su_mutex = __MUTEX_INITIALIZER(of_cfs_subsys.su_mutex),
+};
+
+static int __init of_cfs_init(void)
+{
+	int ret;
+
+	pr_info("%s\n", __func__);
+
+	config_group_init(&of_cfs_subsys.su_group);
+	config_group_init_type_name(&of_cfs_overlay_group, "overlays",
+			&overlays_type);
+	configfs_add_default_group(&of_cfs_overlay_group,
+			&of_cfs_subsys.su_group);
+
+	ret = configfs_register_subsystem(&of_cfs_subsys);
+	if (ret != 0) {
+		pr_err("%s: failed to register subsys\n", __func__);
+		goto out;
+	}
+	pr_info("%s: OK\n", __func__);
+out:
+	return ret;
+}
+late_initcall(of_cfs_init);
diff -Nruw linux-5.4.60-fbx/drivers/platform/fbxgw7r./Kconfig linux-5.4.60-fbx/drivers/platform/fbxgw7r/Kconfig
--- linux-5.4.60-fbx/drivers/platform/fbxgw7r./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/platform/fbxgw7r/Kconfig	2021-03-04 13:20:59.600838970 +0100
@@ -0,0 +1,6 @@
+config FBXGW7R_PLATFORM
+	bool "Freebox Gateway V7 specific drivers"
+
+config FBXGW7R_SWITCH
+	bool "Freebox Gateway V7 in kernel switch init code."
+	depends on FBXGW7R_PLATFORM
diff -Nruw linux-5.4.60-fbx/drivers/platform/fbxgw7r./Makefile linux-5.4.60-fbx/drivers/platform/fbxgw7r/Makefile
--- linux-5.4.60-fbx/drivers/platform/fbxgw7r./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/platform/fbxgw7r/Makefile	2021-03-04 13:20:59.600838970 +0100
@@ -0,0 +1 @@
+obj-$(CONFIG_FBXGW7R_SWITCH)	+= fbxgw7r-switch.o
diff -Nruw linux-5.4.60-fbx/drivers/platform/intelce./Kconfig linux-5.4.60-fbx/drivers/platform/intelce/Kconfig
--- linux-5.4.60-fbx/drivers/platform/intelce./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/platform/intelce/Kconfig	2021-03-04 13:20:59.600838970 +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-5.4.60-fbx/drivers/platform/intelce./Makefile linux-5.4.60-fbx/drivers/platform/intelce/Makefile
--- linux-5.4.60-fbx/drivers/platform/intelce./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/platform/intelce/Makefile	2021-03-04 13:20:59.600838970 +0100
@@ -0,0 +1,2 @@
+obj-$(CONFIG_INTELCE_GPIO)	+= gpio-intelce.o
+obj-$(CONFIG_INTELCE_DFX)	+= dfx.o
diff -Nruw linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx./Kconfig linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx/Kconfig
--- linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx/Kconfig	2021-03-04 13:20:59.834172314 +0100
@@ -0,0 +1,35 @@
+config SOC_BCM63XX
+	bool "Broadcom 63xx SoC drivers"
+	depends on ARCH_BCM_63XX || ARM64 || COMPILE_TEST
+	select RESET_CONTROLLER
+	help
+	  Enables drivers for the Broadcom 63XX series of chips.
+	  This option alone enables only some support code, while the drivers
+	  can be enabled individually within this menu.
+
+	  If unsure, say N.
+
+config UBUS4_BCM63158
+	bool "Broadcom 63158 UBUS4 driver"
+	depends on SOC_BCM63XX || COMPILE_TEST
+
+config PROCMON_BCM63158
+	bool "Broadcom 63158 PROCMON driver"
+	depends on SOC_BCM63XX || COMPILE_TEST
+
+config SOC_BCM63XX_RDP
+	bool "rdp subsystem"
+	depends on SOC_BCM63XX || COMPILE_TEST
+
+config SOC_BCM63XX_XRDP
+	bool "xrdp subsystem"
+	depends on SOC_BCM63XX || COMPILE_TEST
+	select UBUS4_BCM63158
+
+config SOC_BCM63XX_XRDP_IOCTL
+	bool "ioctl interface"
+	depends on SOC_BCM63XX_XRDP
+
+config SOC_MEMC_BCM63158
+	tristate "Broadcom 63158 MEMC driver"
+	depends on SOC_BCM63XX || COMPILE_TEST
diff -Nruw linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx./Makefile linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx/Makefile
--- linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx/Makefile	2021-03-04 13:20:59.834172314 +0100
@@ -0,0 +1,6 @@
+obj-y += pmc.o
+obj-$(CONFIG_SOC_BCM63XX_RDP) += rdp/
+obj-$(CONFIG_SOC_BCM63XX_XRDP) += xrdp/
+obj-$(CONFIG_UBUS4_BCM63158)	+= ubus4-bcm63158.o
+obj-$(CONFIG_PROCMON_BCM63158)	+= procmon-bcm63158.o
+obj-$(CONFIG_SOC_MEMC_BCM63158)	+= memc-bcm63158.o
diff -Nruw linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx./rdp/Makefile linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx/rdp/Makefile
--- linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx./rdp/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx/rdp/Makefile	2021-03-04 13:20:59.834172314 +0100
@@ -0,0 +1,9 @@
+obj-y += rdp_drv.o
+
+rdp_drv-y += \
+	rdp.o \
+	rdp_api.o \
+	rdp_io.o \
+	rdp_ioctl.o
+
+rdp_drv-$(CONFIG_DEBUG_FS) += rdp_debug.o
diff -Nruw linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx./xrdp/Makefile linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx/xrdp/Makefile
--- linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx./xrdp/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/drivers/soc/bcm/bcm63xx/xrdp/Makefile	2021-03-04 13:20:59.834172314 +0100
@@ -0,0 +1,8 @@
+obj-y += xrdp_drv.o
+
+xrdp_drv-y += \
+	xrdp.o \
+	xrdp_api.o
+
+xrdp_drv-$(CONFIG_SOC_BCM63XX_XRDP_IOCTL) += xrdp_ioctl.o
+xrdp_drv-$(CONFIG_DEBUG_FS) += xrdp_debug.o
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/drivers/spi/orion_tdm_spi.c	2021-03-04 13:20:59.847505647 +0100
@@ -0,0 +1,589 @@
+#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/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			hardware_cs_selected;
+	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);
+	return val;
+}
+
+static inline void spi_writel(struct orion_tdm_spi *priv, u32 val, u32 reg)
+{
+	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)
+{
+	unsigned int use_hardware_cs;
+
+	/* if not using gpio, hardware moves cs for us */
+	if (gpio_is_valid(spi->cs_gpio))
+		use_hardware_cs = 0;
+	else {
+		WARN_ON_ONCE(spi->chip_select > 0);
+		use_hardware_cs = 1;
+	}
+
+	/* toggle hardware CS usage (with small cache) */
+	if (use_hardware_cs != priv->hardware_cs_selected) {
+		u32 val;
+
+		val = spi_readl(priv, PCM_CTRL_REG);
+		if (!use_hardware_cs)
+			val |= PCM_DAA_CSS_CTRL_MASK;
+		else
+			val &= ~PCM_DAA_CSS_CTRL_MASK;
+		spi_writel(priv, val, PCM_CTRL_REG);
+		priv->hardware_cs_selected = use_hardware_cs;
+	}
+
+	/* toggle GPIO usage */
+	if (!use_hardware_cs)
+		gpio_set_value(spi->cs_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;
+	}
+
+	if (gpio_is_valid(spi->cs_gpio)) {
+		unsigned long flags;
+
+		flags = GPIOF_DIR_OUT;
+		if (spi->mode & SPI_CS_HIGH)
+			flags |= GPIOF_INIT_LOW;
+		else
+			flags |= GPIOF_INIT_HIGH;
+
+		return gpio_request_one(spi->cs_gpio, flags,
+					dev_name(&spi->dev));
+	}
+
+	return 0;
+}
+
+static void orion_tdm_spi_cleanup(struct spi_device *spi)
+{
+	if (gpio_is_valid(spi->cs_gpio)) {
+		gpio_free(spi->cs_gpio);
+	}
+}
+
+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;
+
+	/* 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;
+			}
+		}
+	}
+
+	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);
+	}
+
+msg_done:
+	if (cs_active)
+		spi_set_cs(priv, spi, 0);
+
+	if (m->complete)
+		m->complete(m->context);
+	return m->status;
+}
+
+static int orion_tdm_spi_probe(struct platform_device *pdev)
+{
+	struct spi_master *master;
+	struct orion_tdm_spi *priv;
+	struct resource *r;
+	unsigned int tclk_hz;
+	int status = 0;
+	u32 val;
+
+	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->cleanup = orion_tdm_spi_cleanup;
+	master->transfer = orion_tdm_spi_transfer;
+	master->num_chipselect = 1;
+	master->mode_bits = 0;
+
+	platform_set_drvdata(pdev, master);
+
+	priv = spi_master_get_devdata(master);
+	priv->master = master;
+
+	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;
+	}
+
+	status = clk_prepare_enable(priv->clk);
+	if (status < 0)
+		goto out;
+
+	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->hardware_cs_selected = ~0;
+
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	priv->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(priv->base)) {
+		status = PTR_ERR(priv->base);
+		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 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		= 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	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/drivers/video/fbdev/ssd1327.c	2021-03-04 13:21:00.167505662 +0100
@@ -0,0 +1,873 @@
+#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/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>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+#include <linux/reset.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_SET_MULTIPLEX_RATIO	0xa8
+#define OPCODE_SET_FUNC_A		0xab
+
+#define OPCODE_DISPLAY_OFF	0xae
+#define OPCODE_DISPLAY_ON	0xaf
+
+#define OPCODE_SET_PHASE_LENGTH		0xb1
+#define OPCODE_SET_FRONT_CLOCK_DIV	0xb3
+#define OPCODE_UNKNOWN			0xb4 // for brightness enhancement?
+#define OPCODE_SET_2ND_PRECHARGE	0xb6
+#define OPCODE_SET_GRAYSCALE_TBL	0xb8
+#define OPCODE_DEF_GRAY			0xb9
+
+#define OPCODE_SET_PRECHARGE_VOLTAGE	0xbc
+#define OPCODE_SET_VCOMM_VOLTAGE	0xbe
+
+#define OPCODE_SET_FUNC_B		0xd5
+
+#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;
+
+	/* configuration from device tree */
+	u32				width;
+	u32				height;
+	u32				rotate;
+	u32				watchdog;
+
+	/* 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 gpio_desc		*vcc_gpio;
+	struct reset_control		*reset;
+	struct gpio_desc		*reset_gpio;
+	struct gpio_desc		*data_gpio;
+	struct spi_device		*spi;
+
+	struct backlight_device		*backlight;
+	unsigned int			brightness;
+
+	/* watchog timer */
+	struct delayed_work		wtd_work;
+	atomic_t			wtd_count;
+
+	const char			*init_seq;
+};
+
+/*
+ * send command to device
+ */
+static int send_cmd(struct ssd1327 *priv, u8 cmd)
+{
+	int ret;
+
+	mutex_lock(&priv->mutex);
+	gpiod_set_value(priv->data_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)
+{
+	int ret;
+
+	mutex_lock(&priv->mutex);
+	gpiod_set_value(priv->data_gpio, 1);
+	ret = spi_write(priv->spi, tx, size);
+	mutex_unlock(&priv->mutex);
+	return ret;
+}
+
+static inline bool ssd1327_reset_needed(struct ssd1327 *priv)
+{
+	return priv->reset_gpio ||
+		(priv->reset && reset_control_status(priv->reset));
+}
+
+static inline void ssd1327_reset_assert(struct ssd1327 *priv)
+{
+	if (priv->reset)
+		reset_control_assert(priv->reset);
+	if (priv->reset_gpio)
+		gpiod_direction_output(priv->reset_gpio, 0);
+}
+
+static inline void ssd1327_reset_deassert(struct ssd1327 *priv)
+{
+	if (priv->reset)
+		reset_control_deassert(priv->reset);
+	if (priv->reset_gpio)
+		gpiod_direction_output(priv->reset_gpio, 1);
+}
+
+/*
+ * soft reset & initialize ssd1327
+ */
+static int ssd1327_init(struct ssd1327 *priv)
+{
+	/*
+	 * init sequence used in fbxgw1r/fbxgw2r (incl. FreeboxOne,
+	 * even if it should use the p32202 init sequence).
+	 */
+	const u8 init_cmds_other[] = { OPCODE_DISPLAY_ON,
+
+				 /* set even/odd splitting */
+				 OPCODE_SET_REMAP, (1 << 6),
+				 OPCODE_CONTRAST, SSD1327_NOMINAL_BRIGHTNESS,
+				 OPCODE_DEF_GRAY,
+				 OPCODE_DISPLAY_NORMAL,
+	};
+	/*
+	 * init sequence for p32202 screen, found on jbxgw7r
+	 */
+	const u8 init_cmds_p32202[] = {
+		OPCODE_DISPLAY_OFF,
+		/* set even/odd splitting */
+		OPCODE_SET_REMAP, (1 << 6),
+		OPCODE_DISPLAY_NORMAL,
+
+		OPCODE_SET_MULTIPLEX_RATIO, 0x7f,
+		OPCODE_SET_FUNC_A, 0x01,
+		OPCODE_CONTRAST, 0xa5,
+		OPCODE_SET_PHASE_LENGTH, 0x31,
+		OPCODE_SET_FRONT_CLOCK_DIV, 0xc1,
+		OPCODE_UNKNOWN, 0xb5,
+		OPCODE_SET_2ND_PRECHARGE, 0x0d,
+		OPCODE_SET_PRECHARGE_VOLTAGE, 0x04,
+		OPCODE_SET_VCOMM_VOLTAGE, 0x07,
+		OPCODE_SET_FUNC_B, 0x60,
+
+		OPCODE_DISPLAY_ON,
+	};
+	const u8 *init_cmds;
+	size_t init_cmds_size;
+	int ret;
+
+	/* check if we need to powerup */
+	if (ssd1327_reset_needed(priv)) {
+		dev_info(&priv->spi->dev, "reset held, powerup needed");
+
+		ssd1327_reset_assert(priv);
+		msleep(500);
+
+		gpiod_direction_output(priv->vcc_gpio, 0);
+		ssd1327_reset_deassert(priv);
+		msleep(10);
+		gpiod_direction_output(priv->vcc_gpio, 1);
+		msleep(100);
+	}
+
+	/* zero ram */
+	ret = write_data(priv, priv->gddram, GDDRAM_SIZE);
+	if (ret)
+		return ret;
+
+	/*
+	 * select init command depending on device tree property, use
+	 * init_cmds_other by default.
+	 */
+	if (priv->init_seq && !strcmp(priv->init_seq, "p32202")) {
+		dev_dbg(&priv->spi->dev,  "using init sequence for "
+			 "p32202 part.\n");
+		init_cmds = init_cmds_p32202;
+		init_cmds_size = sizeof (init_cmds_p32202);
+	} else {
+		init_cmds = init_cmds_other;
+		init_cmds_size = sizeof (init_cmds_other);
+	}
+
+	return send_cmds(priv, init_cmds, init_cmds_size);
+}
+
+/*
+ * 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->width;
+	h = priv->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->watchdog);
+	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->watchdog);
+	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->watchdog);
+	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->watchdog);
+	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->watchdog);
+	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->watchdog);
+	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 device_node *node = spi->dev.of_node;
+	struct ssd1327 *priv;
+	struct fb_info *fb;
+	int ret;
+
+	if (!node) {
+		dev_err(&spi->dev, "No device tree data found!\n");
+		return -EINVAL;
+	}
+
+	fb = framebuffer_alloc(sizeof (*priv), &spi->dev);
+	if (!fb)
+		return -ENOMEM;
+
+	priv = fb->par;
+	mutex_init(&priv->mutex);
+	priv->spi = spi;
+	priv->fb = fb;
+	priv->brightness = SSD1327_NOMINAL_BRIGHTNESS;
+
+	priv->reset = devm_reset_control_get_shared_by_index(&spi->dev, 0);
+	if (IS_ERR(priv->reset)) {
+		ret = PTR_ERR(priv->reset);
+		if (ret == -ENOENT)
+			priv->reset = NULL;
+		else {
+			if (ret != -EPROBE_DEFER)
+				dev_err(&spi->dev, "failed to get reset: %d\n",
+					ret);
+			goto fail;
+		}
+	}
+
+	priv->reset_gpio = devm_gpiod_get(&spi->dev, "ssd1327,reset",
+					  GPIOD_ASIS);
+	if (IS_ERR(priv->reset_gpio)) {
+		ret = PTR_ERR(priv->reset_gpio);
+		if (ret == -ENOENT)
+			priv->reset_gpio = NULL;
+		else {
+			if (ret != -EPROBE_DEFER)
+				dev_err(&spi->dev, "failed to get reset gpio: "
+					"%d\n", ret);
+			goto fail;
+		}
+	}
+
+	priv->vcc_gpio = NULL;
+	if (priv->reset_gpio || priv->reset) {
+		priv->vcc_gpio = devm_gpiod_get(&spi->dev, "ssd1327,vcc",
+						GPIOD_ASIS);
+		if (IS_ERR(priv->vcc_gpio)) {
+			ret = PTR_ERR(priv->vcc_gpio);
+			if (ret != -EPROBE_DEFER)
+				dev_err(&spi->dev,
+					"failed to get vcc gpio: %d\n", ret);
+			goto fail;
+		}
+	}
+
+	priv->data_gpio = devm_gpiod_get(&spi->dev,
+					 "ssd1327,data-select",
+					 GPIOD_OUT_LOW);
+	if (IS_ERR(priv->data_gpio)) {
+		ret = PTR_ERR(priv->data_gpio);
+		if (ret != -EPROBE_DEFER)
+			dev_err(&spi->dev, "failed to get data gpio: %d\n",
+				ret);
+		goto fail;
+	}
+
+	ret = of_property_read_u32(node, "ssd1327,width", &priv->width);
+	if (ret) {
+		dev_err(&spi->dev, "failed to get width\n");
+		goto fail;
+	}
+
+	ret = of_property_read_u32(node, "ssd1327,height", &priv->height);
+	if (ret) {
+		dev_err(&spi->dev, "failed to get height\n");
+		goto fail;
+	}
+
+	/* sanity check on screen size */
+	if (priv->width > SSD1327_COLS * 2 ||
+	    priv->height > SSD1327_ROWS) {
+		dev_err(&spi->dev, "unsupported screen dimension\n");
+		goto fail;
+	}
+
+	ret = of_property_read_u32(node, "ssd1327,rotate", &priv->rotate);
+	if (ret) {
+		dev_err(&spi->dev, "failed to get rotate\n");
+		goto fail;
+	}
+
+	ret = of_property_read_u32(node, "ssd1327,watchdog", &priv->watchdog);
+	if (ret) {
+		dev_err(&spi->dev, "failed to get watchdog\n");
+		goto fail;
+	}
+
+	priv->init_seq = NULL;
+	of_property_read_string(node, "ssd1327,init-sequence", &priv->init_seq);
+
+	/* 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 = priv->width;
+	fb->var.yres = priv->height;
+	fb->var.xres_virtual = priv->width;
+	fb->var.yres_virtual = priv->height * 2;
+
+	/* twice lcd size so we can pan in one direction */
+	fb->fix.smem_len = (priv->width * priv->height) * 2;
+	fb->fix.line_length = priv->width;
+	fb->var.rotate = priv->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->watchdog) {
+		atomic_set(&priv->wtd_count, priv->watchdog);
+		schedule_delayed_work(&priv->wtd_work, HZ);
+	}
+
+	dev_info(&spi->dev,
+		 "fb%d: SSD1327 frame buffer device (%ux%u screen)\n",
+		 fb->node, priv->width, priv->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 const struct of_device_id ssd1327_of_match[] = {
+	{
+		.compatible = "solomon,ssd1327",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, ssd1327_of_match);
+
+static struct spi_driver ssd1327_driver = {
+	.driver = {
+		.name		= "ssd1327",
+		.of_match_table	= ssd1327_of_match,
+	},
+	.probe		= ssd1327_probe,
+	.remove		= ssd1327_remove,
+};
+
+module_spi_driver(ssd1327_driver);
+
+MODULE_DESCRIPTION("SSD1327 driver");
+MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
+MODULE_LICENSE("GPL");
diff -Nruw linux-5.4.60-fbx/fs/exfat./bitmap.c linux-5.4.60-fbx/fs/exfat/bitmap.c
--- linux-5.4.60-fbx/fs/exfat./bitmap.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/bitmap.c	2021-03-04 13:21:00.760839022 +0100
@@ -0,0 +1,606 @@
+/*
+ * 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", (unsigned long long)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",
+				  (unsigned long long)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);
+	}
+	if (count >= sizeof (u8) * 8) {
+		u8 val = *ptr;
+
+		ret += hweight8(~val);
+		count -= sizeof (u8) * 8;
+		ptr += sizeof (u8);
+	}
+
+	if (count) {
+		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",
+				  (unsigned long long)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",
+			  (unsigned long long)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",
+				  (unsigned long long)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-5.4.60-fbx/fs/exfat./dir.c linux-5.4.60-fbx/fs/exfat/dir.c
--- linux-5.4.60-fbx/fs/exfat./dir.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/dir.c	2021-03-04 13:21:00.760839022 +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-5.4.60-fbx/fs/exfat./exfat_fs.h linux-5.4.60-fbx/fs/exfat/exfat_fs.h
--- linux-5.4.60-fbx/fs/exfat./exfat_fs.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/exfat_fs.h	2021-03-04 13:21:00.760839022 +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-5.4.60-fbx/fs/exfat./exfat.h linux-5.4.60-fbx/fs/exfat/exfat.h
--- linux-5.4.60-fbx/fs/exfat./exfat.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/exfat.h	2021-03-04 13:21:00.760839022 +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 timespec64 *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(const struct path *, struct kstat *, u32, unsigned int);
+int exfat_setattr(struct dentry *, struct iattr *);
+int exfat_rename(struct inode *, struct dentry *,
+		 struct inode *, struct dentry *, unsigned int);
+
+/*
+ * 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 timespec64 *ts, u32 datetime, u8 time_cs,
+		      s8 tz_offset);
+void exfat_time_2exfat(struct exfat_sb_info *sbi, struct timespec64 *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-5.4.60-fbx/fs/exfat./fat.c linux-5.4.60-fbx/fs/exfat/fat.c
--- linux-5.4.60-fbx/fs/exfat./fat.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/fat.c	2021-03-04 13:21:00.760839022 +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",
+			  (unsigned long long)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",
+				  (unsigned long long)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-5.4.60-fbx/fs/exfat./file.c linux-5.4.60-fbx/fs/exfat/file.c
--- linux-5.4.60-fbx/fs/exfat./file.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/file.c	2021-03-04 13:21:00.760839022 +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(inode);
+	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(const struct path *path, struct kstat *stat, u32 request_mask,
+		  unsigned int flags)
+{
+	struct inode *inode = d_inode(path->dentry);
+	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, umode_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-5.4.60-fbx/fs/exfat./inode.c linux-5.4.60-fbx/fs/exfat/inode.c
--- linux-5.4.60-fbx/fs/exfat./inode.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/inode.c	2021-03-04 13:21:00.760839022 +0100
@@ -0,0 +1,277 @@
+/*
+ * 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)
+{
+	truncate_inode_pages_final(&inode->i_data);
+	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-5.4.60-fbx/fs/exfat./Kconfig linux-5.4.60-fbx/fs/exfat/Kconfig
--- linux-5.4.60-fbx/fs/exfat./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/Kconfig	2021-03-04 13:21:00.760839022 +0100
@@ -0,0 +1,3 @@
+
+config EXFAT_FS_FBX
+	tristate "exFAT fs support"
diff -Nruw linux-5.4.60-fbx/fs/exfat./Makefile linux-5.4.60-fbx/fs/exfat/Makefile
--- linux-5.4.60-fbx/fs/exfat./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/Makefile	2021-03-04 13:21:00.760839022 +0100
@@ -0,0 +1,13 @@
+
+obj-$(CONFIG_EXFAT_FS_FBX)	+= 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-5.4.60-fbx/fs/exfat./namei.c linux-5.4.60-fbx/fs/exfat/namei.c
--- linux-5.4.60-fbx/fs/exfat./namei.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/namei.c	2021-03-04 13:21:00.760839022 +0100
@@ -0,0 +1,931 @@
+/*
+ * 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 timespec64 *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 timespec64 *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.",
+				  (unsigned long long)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 timespec64 ts;
+
+        ktime_get_coarse_real_ts64(&ts);
+
+	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(dir);
+	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(inode);
+
+	/*
+	 * update atime & mtime for parent directory.
+	 */
+	dir->i_mtime = dir->i_atime = current_time(dir);
+	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,
+		 unsigned int flags)
+{
+	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;
+
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
+	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(new_dir);
+		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(old_dir);
+		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-5.4.60-fbx/fs/exfat./read-write.c linux-5.4.60-fbx/fs/exfat/read-write.c
--- linux-5.4.60-fbx/fs/exfat./read-write.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/read-write.c	2021-03-04 13:21:00.760839022 +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-5.4.60-fbx/fs/exfat./super.c linux-5.4.60-fbx/fs/exfat/super.c
--- linux-5.4.60-fbx/fs/exfat./super.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/super.c	2021-03-04 13:21:00.760839022 +0100
@@ -0,0 +1,742 @@
+/*
+ * 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 <linux/iversion.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 & SB_RDONLY)) {
+		sb->s_flags |= SB_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;
+	inode_set_iversion(root, 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);
+	inode_inc_iversion(root);
+	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(root);
+
+	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 & SB_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 & SB_RDONLY;
+
+	if (new_rdonly != (sb->s_flags & SB_RDONLY)) {
+		if (new_rdonly)
+			exfat_set_sb_dirty(sb, false, false);
+		else
+			/*
+			 * sb->s_flag still has SB_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;
+
+	/*
+	 * time granularity of FS for use by current_time(inode): in
+	 * nsec so 1000000000 for 1 sec granularity.
+	 */
+	sb->s_time_gran = 1000 * 1000 * 1000;
+
+	/*
+	 * 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-5.4.60-fbx/fs/exfat./time.c linux-5.4.60-fbx/fs/exfat/time.c
--- linux-5.4.60-fbx/fs/exfat./time.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/time.c	2021-03-04 13:21:00.760839022 +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 timespec64 *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 timespec64 *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;
+
+	time64_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-5.4.60-fbx/fs/exfat./upcase.c linux-5.4.60-fbx/fs/exfat/upcase.c
--- linux-5.4.60-fbx/fs/exfat./upcase.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/fs/exfat/upcase.c	2021-03-04 13:21:00.760839022 +0100
@@ -0,0 +1,137 @@
+/*
+ * 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",
+				  (unsigned long long)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",
+			  (unsigned long long)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	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/linux/fbxatm_dev.h	2021-03-30 15:23:23.574984438 +0200
@@ -0,0 +1,436 @@
+#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 {
+	u32			rx_bytes;
+	u32			tx_bytes;
+	u32			rx_aal5;
+	u32			tx_aal5;
+};
+
+struct fbxatm_dev_stats {
+	u32			rx_bytes;
+	u32			tx_bytes;
+	u32			rx_aal5;
+	u32			tx_aal5;
+	u32			rx_f4_oam;
+	u32			tx_f4_oam;
+	u32			rx_f5_oam;
+	u32			tx_f5_oam;
+	u32			rx_bad_oam;
+	u32			rx_bad_llid_oam;
+	u32			rx_other_oam;
+	u32			rx_dropped;
+	u32			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;
+	spinlock_t			dev_link_lock;
+
+	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;
+
+	spinlock_t			vcc_list_lock;
+	struct list_head		vcc_list;
+
+	struct device			dev;
+
+	spinlock_t			oam_list_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	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/linux/fbxatm_remote.h	2021-03-04 13:21:00.967505698 +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	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/linux/fbxgpio_core.h	2021-03-04 13:21:00.967505698 +0100
@@ -0,0 +1,45 @@
+/*
+ * 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);
+	int (*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;
+	bool				claimed;
+	unsigned int			cur_dataout;
+	struct device			*dev;
+	struct device_node		*of_node;
+};
+
+
+#define GPIO_DIR_IN	0x1
+#define GPIO_DIR_OUT	0x0
+
+struct fbxgpio_pin *fbxgpio_of_get(struct device_node *np,
+				   const char *propname,
+				   int index);
+
+#endif /* !FBXGPIO_H */
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/linux/fbxprocfs.h	2021-03-04 13:21:00.967505698 +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	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/linux/fbxserial.h	2021-03-04 13:21:00.967505698 +0100
@@ -0,0 +1,129 @@
+#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(const void *data, struct fbx_serial *out);
+
+struct fbx_serial *fbxserialinfo_get(void);
+
+/*
+ * implemented in board specific code
+ */
+#ifdef CONFIG_ARCH_HAS_FBXSERIAL
+extern const struct fbx_serial *arch_get_fbxserial(void);
+#else
+static inline const struct fbx_serial *arch_get_fbxserial(void)
+{
+	return NULL;
+}
+#endif
+
+#endif /* FBXSERIAL_H_ */
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/linux/smsc_cap1066.h	2021-03-04 13:21:01.047505701 +0100
@@ -0,0 +1,12 @@
+#ifndef SMSC_CAP1066_H_
+#define SMSC_CAP1066_H_
+
+#define CAP1066_MAX_BTNS	6
+
+struct smsc_cap1066_pdata {
+	u32		key_map[CAP1066_MAX_BTNS];
+	unsigned int	irq_gpio;
+	bool		has_irq_gpio;
+};
+
+#endif /* ! SMSC_CAP1066_H_ */
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/net/ip6_ffn.h	2021-03-04 13:21:01.080839036 +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	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/net/ip_ffn.h	2021-03-04 13:21:01.080839036 +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	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/uapi/linux/bcm63xx_rdp_ioctl.h	2021-03-04 13:21:01.120839038 +0100
@@ -0,0 +1,71 @@
+#ifndef LINUX_BCM63XX_RDP_IOCTL_H_
+#define LINUX_BCM63XX_RDP_IOCTL_H_
+
+#include <linux/types.h>
+
+enum {
+	RDP_IOC_OP_GET_INFO,
+
+	RDP_IOC_OP_READ8,
+	RDP_IOC_OP_READ16,
+	RDP_IOC_OP_READ32,
+	RDP_IOC_OP_WRITE8,
+	RDP_IOC_OP_WRITE16,
+	RDP_IOC_OP_WRITE32,
+
+	RDP_IOC_OP_READ_TM_32,
+	RDP_IOC_OP_WRITE_TM_32,
+	RDP_IOC_OP_READ_MC_32,
+	RDP_IOC_OP_WRITE_MC_32,
+
+	RDP_IOC_OP_RESET,
+
+	RDP_IOC_DMA_MAP,
+	RDP_IOC_DMA_GET_INFO,
+	RDP_IOC_DMA_FLUSH_ALL,
+	RDP_IOC_DMA_READ_BUFFER,
+	RDP_IOC_DMA_WRITE_BUFFER,
+
+	RDP_IOC_OP_MAP_INTERRUPTS,
+};
+
+struct bcm_rdp_pioctl_dma_result {
+	__u32		id;
+	__u32		size;
+	__u64		virt_addr;
+	__u64		dma_addr;
+};
+
+struct bcm_rdp_pioctl_get_info_result {
+	__u64		tm_dma_addr;
+	__u64		mc_dma_addr;
+	__u32		tm_size;
+	__u32		mc_size;
+};
+
+struct bcm_rdp_pioctl {
+	union {
+		/* for get_info op */
+		struct {
+			void __user	*buf_addr;
+		} get_info;
+
+		/* for read/write op */
+		struct {
+			__u32		reg_area;
+			__u32		offset;
+			__u32		size;
+			void __user	*buf_addr;
+		} io;
+
+		/* for dma op */
+		struct {
+			__u32		id;
+			__u32		size;
+			void __user	*buf_addr;
+		} dma;
+	} u;
+};
+
+#endif /* LINUX_BCM63XX_RDP_IOCTL_H_ */
+
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/uapi/linux/exfat_user.h	2021-03-04 13:21:01.124172371 +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	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/uapi/linux/fbxatm.h	2021-03-04 13:21:01.124172371 +0100
@@ -0,0 +1,159 @@
+/*
+ * 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];
+	__u8				perm_addr[6];
+};
+
+
+#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_ */
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/uapi/linux/fbxbridge.h	2021-03-04 13:21:01.124172371 +0100
@@ -0,0 +1,72 @@
+#ifndef _UAPI_FBXBRIDGE_H
+# define _UAPI_FBXBRIDGE_H
+
+#include <linux/if.h>
+#include <linux/if_ether.h>
+
+#define MAX_ALIASES				3
+
+#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];
+	__u32	action;
+};
+
+struct fbxbridge_ioctl_dev_chg
+{
+	char	brname[IFNAMSIZ];
+	char	devname[IFNAMSIZ];
+	__u32	wan;
+	__u32	action;
+};
+
+struct fbxbridge_port_info
+{
+	char	name[IFNAMSIZ];
+	__u32	present;
+};
+
+struct fbxbridge_ioctl_params
+{
+	int				action;
+	char				brname[IFNAMSIZ];
+
+	/* config */
+	__u32				flags;
+	__be32				dns1_addr;
+	__be32				dns2_addr;
+	__be32				ip_aliases[MAX_ALIASES];
+	__u32				dhcpd_renew_time;
+	__u32				dhcpd_rebind_time;
+	__u32				dhcpd_lease_time;
+	__u32				inputmark;
+
+	/* status */
+	struct fbxbridge_port_info	wan_dev;
+	struct fbxbridge_port_info	lan_dev;
+	__u8				lan_hwaddr[ETH_ALEN];
+	__u32				have_hw_addr;
+};
+
+struct fbxbridge_ioctl_req
+{
+	enum fbxbridge_ioctl_cmd	cmd;
+	unsigned long			arg;
+};
+
+#endif /* _UAPI_FBXBRIDGE_H */
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/uapi/linux/fbxjtag.h	2021-03-04 13:21:01.124172371 +0100
@@ -0,0 +1,89 @@
+#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;
+	u32		clock_delay;
+	u32		wait_tms;
+	u32		data_read_size;
+	u32		instruction_read_size;
+	bool		last_tms_dataout;
+	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_ */
diff -Nruw linux-5.4.60-fbx/include/uapi/linux/hdmi-cec./dev.h linux-5.4.60-fbx/include/uapi/linux/hdmi-cec/dev.h
--- linux-5.4.60-fbx/include/uapi/linux/hdmi-cec./dev.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/include/uapi/linux/hdmi-cec/dev.h	2021-03-04 13:21:01.124172371 +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 */
diff -Nruw linux-5.4.60-fbx/include/uapi/linux/hdmi-cec./hdmi-cec.h linux-5.4.60-fbx/include/uapi/linux/hdmi-cec/hdmi-cec.h
--- linux-5.4.60-fbx/include/uapi/linux/hdmi-cec./hdmi-cec.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/include/uapi/linux/hdmi-cec/hdmi-cec.h	2021-03-04 13:21:01.124172371 +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 */
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/include/uapi/linux/prctl-private.h	2021-03-04 13:21:01.137505705 +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	57
+#define PR_GET_EXEC_MODE	58
+
+#endif /* ! _LINUX_PRCTL_PRIVATE_H */
diff -Nruw linux-5.4.60-fbx/include/uapi/linux/remoti./remoti.h linux-5.4.60-fbx/include/uapi/linux/remoti/remoti.h
--- linux-5.4.60-fbx/include/uapi/linux/remoti./remoti.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/include/uapi/linux/remoti/remoti.h	2021-03-04 13:21:01.140839039 +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	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/lib/fbxserial.c	2021-03-04 13:21:01.324172380 +0100
@@ -0,0 +1,178 @@
+#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(const 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;
+
+	memset(data, 0, 6);
+	s = arch_get_fbxserial();
+	if (WARN(!s, "arch_get_fbxserial returned NULL"))
+		return;
+
+	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-5.4.60-fbx/net/fbxatm./crc10.c linux-5.4.60-fbx/net/fbxatm/crc10.c
--- linux-5.4.60-fbx/net/fbxatm./crc10.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxatm/crc10.c	2021-03-04 13:21:01.410839051 +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-5.4.60-fbx/net/fbxatm./fbxatm_2684.c linux-5.4.60-fbx/net/fbxatm/fbxatm_2684.c
--- linux-5.4.60-fbx/net/fbxatm./fbxatm_2684.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxatm/fbxatm_2684.c	2021-03-04 13:21:01.410839051 +0100
@@ -0,0 +1,852 @@
+#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 ssize_t 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:
+			/* kludge to detect ipv6 or ipv4 */
+			if (skb->len && (skb->data[0] & 0xf0) == 0x60)
+				skb->protocol = htons(ETH_P_IPV6);
+			else
+				skb->protocol = htons(ETH_P_IP);
+			skb_reset_mac_header(skb);
+			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);
+			skb_reset_mac_header(skb);
+			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,
+					   struct net_device *sb_dev)
+{
+	/* 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;
+	unsigned int len;
+
+	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);
+
+	len = skb->len;
+	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);
+		WARN_ONCE(1, "fbxatm2684_xmit called with full queue");
+		priv->stats.tx_errors++;
+		dev_kfree_skb(skb);
+		return NETDEV_TX_OK;
+	}
+
+	priv->stats.tx_bytes += len;
+	priv->stats.tx_packets++;
+
+	/* check if queue is full */
+	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 void
+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));
+}
+
+/*
+ * 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;
+
+	if (!is_zero_ether_addr(params->perm_addr))
+		memcpy(dev->perm_addr, params->perm_addr, 6);
+
+	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-5.4.60-fbx/net/fbxatm./fbxatm_core.c linux-5.4.60-fbx/net/fbxatm/fbxatm_core.c
--- linux-5.4.60-fbx/net/fbxatm./fbxatm_core.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxatm/fbxatm_core.c	2021-03-04 13:21:01.410839051 +0100
@@ -0,0 +1,206 @@
+#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,
+	.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-5.4.60-fbx/net/fbxatm./fbxatm_dev.c linux-5.4.60-fbx/net/fbxatm/fbxatm_dev.c
--- linux-5.4.60-fbx/net/fbxatm./fbxatm_dev.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxatm/fbxatm_dev.c	2021-03-04 13:21:01.410839051 +0100
@@ -0,0 +1,983 @@
+#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;
+	spin_lock_bh(&adev->vcc_list_lock);
+	list_for_each_entry(vcc, &adev->vcc_list, next) {
+		if (vcc->vpi != id->vpi || vcc->vci != id->vci)
+			continue;
+		found = 1;
+		break;
+	}
+	spin_unlock_bh(&adev->vcc_list_lock);
+
+	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 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);
+
+	spin_lock_bh(&adev->dev_link_lock);
+	if (!test_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags))
+		ret = -ENETDOWN;
+	else
+		ret = adev->ops->send_oam(adev, oam_cell);
+	spin_unlock_bh(&adev->dev_link_lock);
+	if (ret)
+		goto out_unlock;
+
+	/* wait for an answer */
+	adev->stats.tx_f5_oam++;
+	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);
+
+		spin_lock_bh(&adev->dev_link_lock);
+		if (!test_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags))
+			ret = adev->ops->send_oam(adev, oam_cell);
+		else
+			ret = -ENETDOWN;
+		spin_unlock_bh(&adev->dev_link_lock);
+
+		if (!ret) {
+			/* send successful, don't free cell */
+			adev->stats.tx_f5_oam++;
+			return;
+		}
+
+	} else {
+		struct fbxatm_oam_ping *ping;
+
+		/* reply, find a matching sender */
+		spin_lock_bh(&adev->oam_list_lock);
+		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);
+		}
+		spin_unlock_bh(&adev->oam_list_lock);
+	}
+
+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_list_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_list_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);
+	spin_lock_init(&adev->vcc_list_lock);
+	INIT_LIST_HEAD(&adev->next);
+	spin_lock_init(&adev->stats_lock);
+	spin_lock_init(&adev->oam_list_lock);
+	spin_lock_init(&adev->dev_link_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;
+
+	if (link) {
+		memset(&adev->stats, 0, sizeof (adev->stats));
+		set_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags);
+
+		spin_lock_bh(&adev->vcc_list_lock);
+		list_for_each_entry(vcc, &adev->vcc_list, next) {
+			memset(&vcc->stats, 0, sizeof (vcc->stats));
+			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);
+		}
+		spin_unlock_bh(&adev->vcc_list_lock);
+	} else {
+		/* prevent further oam cells input */
+		spin_lock_bh(&adev->dev_link_lock);
+		clear_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags);
+		spin_unlock_bh(&adev->dev_link_lock);
+
+		/* flush rx oam work */
+		cancel_work_sync(&adev->oam_work);
+
+		/* now disable tx on all vcc */
+		spin_lock_bh(&adev->vcc_list_lock);
+		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);
+		}
+		spin_unlock_bh(&adev->vcc_list_lock);
+	}
+
+	fbxatm_dev_change_sysfs(adev);
+}
+
+/*
+ * 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;
+	bool empty;
+
+	ret = 0;
+	mutex_lock(&fbxatm_mutex);
+
+	spin_lock_bh(&adev->vcc_list_lock);
+	empty = list_empty(&adev->vcc_list);
+	spin_unlock_bh(&adev->vcc_list_lock);
+	if (!empty) {
+		ret = -EBUSY;
+		goto out;
+	}
+
+	if (!list_empty(&adev->oam_pending_ping)) {
+		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)
+{
+	bool link_up;
+
+	spin_lock_bh(&adev->dev_link_lock);
+	link_up = test_bit(FBXATM_DEV_F_LINK_UP, &adev->dev_flags);
+	spin_unlock_bh(&adev->dev_link_lock);
+
+	if (!link_up || adev->rx_oam_cells_count > 8) {
+		kfree(cell);
+		return;
+	}
+
+	adev->rx_oam_cells_count++;
+	spin_lock_bh(&adev->oam_list_lock);
+	list_add_tail(&cell->next, &adev->rx_oam_cells);
+	spin_unlock_bh(&adev->oam_list_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 */
+	spin_lock_bh(&adev->vcc_list_lock);
+	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);
+	spin_unlock_bh(&adev->vcc_list_lock);
+
+	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);
+	spin_lock_bh(&adev->vcc_list_lock);
+	list_del(&vcc->next);
+	spin_unlock_bh(&adev->vcc_list_lock);
+	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-5.4.60-fbx/net/fbxatm./fbxatm_pppoa.c linux-5.4.60-fbx/net/fbxatm/fbxatm_pppoa.c
--- linux-5.4.60-fbx/net/fbxatm./fbxatm_pppoa.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxatm/fbxatm_pppoa.c	2021-03-04 13:21:01.410839051 +0100
@@ -0,0 +1,500 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/interrupt.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 tasklet_struct		tx_done_tasklet;
+
+	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);
+}
+
+/*
+ * tx done tasklet callback
+ */
+static void tx_done_tasklet_func(unsigned long data)
+{
+	struct fbxatm_pppoa_vcc *priv = (struct fbxatm_pppoa_vcc *)data;
+	ppp_output_wakeup(&priv->chan);
+}
+
+/*
+ * fbxatm stack tx done callback, called from softirq
+ */
+static void vcc_tx_done_callback(void *data)
+{
+	struct fbxatm_pppoa_vcc *priv = data;
+
+	/* schedule taslket to avoid re-entering in ppp_xmit */
+	tasklet_schedule(&priv->tx_done_tasklet);
+}
+
+/*
+ * 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;
+	tasklet_init(&priv->tx_done_tasklet, tx_done_tasklet_func,
+		     (unsigned long)priv);
+
+	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);
+	tasklet_kill(&priv->tx_done_tasklet);
+	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-5.4.60-fbx/net/fbxatm./fbxatm_priv.h linux-5.4.60-fbx/net/fbxatm/fbxatm_priv.h
--- linux-5.4.60-fbx/net/fbxatm./fbxatm_priv.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxatm/fbxatm_priv.h	2021-03-04 13:21:01.410839051 +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-5.4.60-fbx/net/fbxatm./fbxatm_procfs.c linux-5.4.60-fbx/net/fbxatm/fbxatm_procfs.c
--- linux-5.4.60-fbx/net/fbxatm./fbxatm_procfs.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxatm/fbxatm_procfs.c	2021-03-30 15:23:23.574984438 +0200
@@ -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, "%u %u  %u %u\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  %u %u  %u %u  ",
+		   adev->ifindex,
+		   adev->stats.rx_bytes,
+		   adev->stats.tx_bytes,
+		   adev->stats.rx_aal5,
+		   adev->stats.tx_aal5);
+
+	seq_printf(seq, "%u %u  %u %u  %u %u %u %u %u\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-5.4.60-fbx/net/fbxatm./fbxatm_remote.c linux-5.4.60-fbx/net/fbxatm/fbxatm_remote.c
--- linux-5.4.60-fbx/net/fbxatm./fbxatm_remote.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxatm/fbxatm_remote.c	2021-03-04 13:21:01.414172385 +0100
@@ -0,0 +1,808 @@
+#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(struct timer_list *timer)
+{
+	struct fbxatm_remote_sock *sock;
+	struct sk_buff *skb;
+
+	sock = container_of(timer, struct fbxatm_remote_sock, retrans_timer);
+
+	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));
+	timer_setup(&sock->retrans_timer, sock_timer, 0);
+	spin_lock_init(&sock->lock);
+	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-5.4.60-fbx/net/fbxatm./fbxatm_remote_driver.c linux-5.4.60-fbx/net/fbxatm/fbxatm_remote_driver.c
--- linux-5.4.60-fbx/net/fbxatm./fbxatm_remote_driver.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxatm/fbxatm_remote_driver.c	2021-03-04 13:21:01.414172385 +0100
@@ -0,0 +1,1185 @@
+/*
+ * "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 <linux/of.h>
+#include <linux/of_net.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);
+
+send_ack:
+	dev_kfree_skb(skb);
+	*ack = NULL;
+	spin_unlock(&priv->tx_lock);
+	/* send ack now */
+	fbxatm_tx_done(pvcc->vcc);
+	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);
+	spin_unlock(&priv->tx_lock);
+	dev_kfree_skb(skb);
+	fbxatm_tx_done(pvcc->vcc);
+	return;
+
+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:
+		case NETDEV_CHANGENAME:
+			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,
+};
+
+/*
+ * get remote pdata through of
+ */
+static struct fbxatm_remote_pdata *
+remote_of_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct fbxatm_remote_pdata *pd;
+	const void *mac_addr;
+	const char *netdev_name;
+	const char *remote_name;
+	int len;
+
+	pd = devm_kzalloc(&pdev->dev, sizeof (*pd), GFP_KERNEL);
+	if (!pd)
+		return ERR_PTR(-ENOMEM);
+
+	mac_addr = of_get_mac_address(np);
+	if (!mac_addr) {
+		printk(KERN_ERR PFX "missing of mac-address\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	netdev_name = of_get_property(np, "netdev-name", &len);
+	if (!netdev_name || len >= sizeof (pd->netdev_name)) {
+		printk(KERN_ERR PFX "missing of netdev-name\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	remote_name = of_get_property(np, "remote-name", &len);
+	if (!remote_name || len >= sizeof (pd->remote_name)) {
+		printk(KERN_ERR PFX "missing of remote-name\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	memcpy(pd->remote_mac, mac_addr, 6);
+	strlcpy(pd->netdev_name, netdev_name, sizeof (pd->netdev_name));
+	strlcpy(pd->remote_name, remote_name, sizeof (pd->remote_name));
+
+	return pd;
+}
+
+/*
+ * 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) {
+		if (!pd->netdev_name[0])
+			return -EINVAL;
+	} else if (pdev->dev.of_node) {
+		pd = remote_of_probe(pdev);
+		if (IS_ERR(pd))
+			return PTR_ERR(pd);
+	} else
+		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;
+}
+
+static const struct of_device_id fbxatm_remote_of_table[] = {
+	{ .compatible = "freebox,fbxatm-remote" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, fbxatm_remote_of_table);
+
+struct platform_driver fbxatm_remote_driver = {
+	.probe	= remote_probe,
+	.remove	= remote_remove,
+	.driver	= {
+		.name	= "fbxatm_remote",
+		.owner  = THIS_MODULE,
+		.of_match_table	= of_match_ptr(fbxatm_remote_of_table),
+	},
+};
+
+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-5.4.60-fbx/net/fbxatm./fbxatm_remote_driver.h linux-5.4.60-fbx/net/fbxatm/fbxatm_remote_driver.h
--- linux-5.4.60-fbx/net/fbxatm./fbxatm_remote_driver.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxatm/fbxatm_remote_driver.h	2021-03-04 13:21:01.414172385 +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-5.4.60-fbx/net/fbxatm./fbxatm_sysfs.c linux-5.4.60-fbx/net/fbxatm/fbxatm_sysfs.c
--- linux-5.4.60-fbx/net/fbxatm./fbxatm_sysfs.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxatm/fbxatm_sysfs.c	2021-03-30 15:23:23.574984438 +0200
@@ -0,0 +1,182 @@
+#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 ssize_t show_rx_bytes(struct device *dev,
+			     struct device_attribute *attr, char *buf)
+{
+	struct fbxatm_dev *adev = to_fbxatm_dev(dev);
+	u32 val;
+
+	spin_lock_bh(&adev->stats_lock);
+	val = adev->stats.rx_bytes;
+	spin_unlock_bh(&adev->stats_lock);
+	return sprintf(buf, "%u\n", val);
+}
+
+static ssize_t show_tx_bytes(struct device *dev,
+			     struct device_attribute *attr, char *buf)
+{
+	struct fbxatm_dev *adev = to_fbxatm_dev(dev);
+	u32 val;
+
+	spin_lock_bh(&adev->stats_lock);
+	val = adev->stats.tx_bytes;
+	spin_unlock_bh(&adev->stats_lock);
+	return sprintf(buf, "%u\n", val);
+}
+
+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 DEVICE_ATTR(rx_bytes, S_IRUGO, show_rx_bytes, NULL);
+static DEVICE_ATTR(tx_bytes, S_IRUGO, show_tx_bytes, 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,
+	&dev_attr_rx_bytes,
+	&dev_attr_tx_bytes,
+};
+
+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-5.4.60-fbx/net/fbxatm./Kconfig linux-5.4.60-fbx/net/fbxatm/Kconfig
--- linux-5.4.60-fbx/net/fbxatm./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxatm/Kconfig	2021-03-04 13:21:01.410839051 +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
+	select OF
+
+endif
diff -Nruw linux-5.4.60-fbx/net/fbxatm./Makefile linux-5.4.60-fbx/net/fbxatm/Makefile
--- linux-5.4.60-fbx/net/fbxatm./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxatm/Makefile	2021-03-04 13:21:01.410839051 +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-5.4.60-fbx/net/fbxbridge./fbxbr_dev.c linux-5.4.60-fbx/net/fbxbridge/fbxbr_dev.c
--- linux-5.4.60-fbx/net/fbxbridge./fbxbr_dev.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxbridge/fbxbr_dev.c	2021-03-04 13:21:01.414172385 +0100
@@ -0,0 +1,734 @@
+#define pr_fmt(fmt)	"fbxbridge: " fmt
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/sockios.h>
+#include <linux/inetdevice.h>
+#include <linux/notifier.h>
+#include <linux/if_arp.h>
+#include <linux/mutex.h>
+#include <net/neighbour.h>
+#include <net/netevent.h>
+#include <net/ip.h>
+#include "fbxbr_private.h"
+
+static LIST_HEAD(fbxbr_list);
+static DEFINE_MUTEX(fbxbr_list_mutex);
+
+/*
+ * ioctl "install" func
+ */
+extern void fbxbridge_set(int (*hook)(struct net *net,
+				      unsigned int, void __user *));
+
+
+/*
+ * caller must hold rtnl lock
+ */
+struct fbxbr *__fbxbr_get_by_name(struct net *net, const char *name)
+{
+	struct net_device *dev;
+
+	dev = __dev_get_by_name(net, name);
+	if (dev == NULL)
+		return ERR_PTR(-ENODEV);
+
+	if (!(dev->priv_flags & IFF_FBXBRIDGE))
+		return ERR_PTR(-ENODEV);
+
+	return netdev_priv(dev);
+}
+
+/*
+ * compute ip address that we will pretend to be on the lan side
+ */
+static inline __be32 gen_lan_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);
+
+	/* default to last address of subnet */
+	gw = ipaddr & netmask;
+	mask = ~netmask;
+	gw |= (mask - 1);
+
+	/* if it happens to be the ip address, then take another one */
+	if (gw == ipaddr) {
+		gw &= netmask;
+		gw |= mask - 2;
+	}
+	return __cpu_to_be32(gw);
+}
+
+/*
+ * must be called with bridge write lock held
+ */
+static void __fetch_wan_parameters(struct fbxbr *br, struct in_ifaddr *ifa)
+{
+	struct net_device *wan_dev;
+
+	if (!ifa)
+		return;
+
+	if (WARN_ON(!br->wan_port))
+		return;
+
+	if (br->wan_ipaddr == ifa->ifa_local &&
+	    br->wan_netmask == ifa->ifa_mask)
+		return;
+
+	br->wan_ipaddr = ifa->ifa_local;
+	br->wan_netmask = ifa->ifa_mask;
+
+	if (br->wan_netmask != 0xffffffff) {
+		/* standard netmask */
+		br->lan_gw = gen_lan_gw(br->wan_ipaddr,	br->wan_netmask);
+		br->lan_netmask = br->wan_netmask;
+	} else {
+		u32 gw;
+
+		/* switch to /24 if wan it pointtopoint */
+		gw = ntohl(br->wan_ipaddr) & 0xffffff00;
+		if ((gw | 0xfe) == ntohl(br->wan_ipaddr))
+			gw |= 0xfd;
+		else
+			gw |= 0xfe;
+
+		br->lan_gw = htonl(gw);
+		br->lan_netmask = htonl(0xffffff00);
+	}
+
+	wan_dev = br->wan_port->dev;
+	pr_notice("%s: wan inet device %s address changed to [%pI4]\n",
+		  br->dev->name, wan_dev->name, &br->wan_ipaddr);
+
+	pr_info("%s: %s: wan netmask: %pI4\n",
+		br->dev->name, wan_dev->name, &br->wan_netmask);
+
+	pr_info("%s: %s: lan gw: %pI4\n",
+		br->dev->name, wan_dev->name, &br->lan_gw);
+}
+
+/*
+ * caller must hold rtnl lock
+ */
+int __fbxbr_add_br_port(struct net *net, const char *name,
+			const char *port_name, bool is_wan)
+{
+	struct net_device *dev;
+	struct fbxbr *br;
+	struct fbxbr_port *p;
+	int ret;
+
+	/* locate bridge */
+	br = __fbxbr_get_by_name(net, name);
+	if (IS_ERR(br))
+		return PTR_ERR(br);
+
+	/* check that we don't have a device already */
+	if ((is_wan && br->wan_port) || (!is_wan && br->lan_port))
+		return -EBUSY;
+
+	/* locate port */
+	dev = __dev_get_by_name(net, port_name);
+	if (!dev)
+		return -ENODEV;
+
+	/* make sure it's not used by us */
+	if (dev->priv_flags & (IFF_FBXBRIDGE | IFF_FBXBRIDGE_PORT))
+		return -EBUSY;
+
+	/* allocate new port */
+	p = kzalloc(sizeof (*p), GFP_KERNEL);
+	if (p == NULL)
+		return -ENOMEM;
+
+	p->br = br;
+	p->dev = dev;
+	p->is_wan = is_wan;
+
+	write_lock_bh(&br->lock);
+	if (is_wan)
+		br->wan_port = p;
+	else
+		br->lan_port = p;
+
+	if (is_wan) {
+		struct in_device *in_dev;
+
+		rcu_read_lock();
+
+		in_dev = __in_dev_get_rcu(dev);
+		if (in_dev)
+			__fetch_wan_parameters(br, in_dev->ifa_list);
+
+		rcu_read_unlock();
+	}
+
+	write_unlock_bh(&br->lock);
+
+	ret = netdev_rx_handler_register(dev, fbxbr_handle_frame, p);
+	if (ret)
+		goto err;
+
+	dev->priv_flags |= IFF_FBXBRIDGE_PORT;
+
+	ret = netdev_master_upper_dev_link(dev, br->dev, NULL, NULL, NULL);
+	if (ret)
+		goto err;
+
+	pr_info("%s: %s device %s grabbed\n",
+		br->dev->name, is_wan ? "wan" : "lan", dev->name);
+
+	return 0;
+
+err:
+	write_lock_bh(&br->lock);
+	netdev_rx_handler_unregister(dev);
+	if (is_wan)
+		br->wan_port = NULL;
+	else
+		br->lan_port = NULL;
+	dev->priv_flags &= ~IFF_FBXBRIDGE_PORT;
+	write_unlock_bh(&br->lock);
+	kfree(p);
+	return ret;
+}
+
+/*
+ * caller must hold rtnl lock
+ */
+void __fbxbr_del_br_port(struct fbxbr_port *p)
+{
+	struct fbxbr *br = p->br;
+	struct net_device *dev = p->dev;
+	bool is_wan;
+
+	netdev_upper_dev_unlink(dev, br->dev);
+	netdev_rx_handler_unregister(dev);
+	dev->priv_flags &= ~IFF_FBXBRIDGE_PORT;
+	is_wan = p->is_wan;
+
+	write_lock_bh(&br->lock);
+	if (p->is_wan)
+		br->wan_port = NULL;
+	else
+		br->lan_port = NULL;
+
+	if (p->rt)
+		ip_rt_put(p->rt);
+	write_unlock_bh(&br->lock);
+	kfree(p);
+
+	pr_info("%s: %s device %s released\n",
+		br->dev->name, is_wan ? "wan" : "lan", dev->name);
+}
+
+/*
+ * caller must hold rtnl lock
+ */
+int __fbxbr_del_br_port_by_name(struct net *net, const char *name,
+				const char *port_name)
+{
+	struct net_device *dev;
+	struct fbxbr *br;
+	struct fbxbr_port *p;
+
+	/* locate bridge */
+	br = __fbxbr_get_by_name(net, name);
+	if (IS_ERR(br))
+		return PTR_ERR(br);
+
+	/* locate port */
+	dev = __dev_get_by_name(net, port_name);
+	if (!dev)
+		return -ENODEV;
+
+	p = fbxbr_port_get_rtnl(dev);
+	if (!p || p->br != br)
+		return -EINVAL;
+
+	__fbxbr_del_br_port(p);
+	return 0;
+}
+
+/*
+ * bridge device netdevice ops
+ */
+static int fbxbr_net_open(struct net_device *dev)
+{
+	return 0;
+}
+
+static int fbxbr_net_stop(struct net_device *dev)
+{
+	return 0;
+}
+
+static int fbxbr_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct fbxbr *br = netdev_priv(dev);
+	const struct iphdr *iph;
+
+	read_lock(&br->lock);
+
+	if (skb->protocol != htons(ETH_P_IP))
+		goto drop;
+
+	if (!br->wan_ipaddr)
+		goto drop;
+
+	if (!br->lan_port)
+		goto drop;
+
+	if (!pskb_may_pull(skb, sizeof (*iph)))
+		goto drop;
+
+	iph = ip_hdr(skb);
+
+	if (ipv4_is_multicast(iph->daddr)) {
+		dev->stats.tx_packets++;
+		dev->stats.tx_bytes += skb->len;
+		fbxbr_output_lan_mcast_frame(br, skb);
+		goto done;
+	}
+
+	if (iph->daddr != br->br_remote_ipaddr)
+		goto drop;
+
+	fbxbr_dnat_packet(skb, br->wan_ipaddr);
+	dev->stats.tx_packets++;
+	dev->stats.tx_bytes += skb->len;
+	fbxbr_output_lan_frame(br, skb);
+
+done:
+	read_unlock(&br->lock);
+	return 0;
+
+drop:
+	dev->stats.tx_dropped++;
+	read_unlock(&br->lock);
+	kfree(skb);
+	return 0;
+}
+
+static const struct net_device_ops fbxbr_net_ops = {
+	.ndo_open		= fbxbr_net_open,
+	.ndo_stop		= fbxbr_net_stop,
+	.ndo_start_xmit		= fbxbr_net_start_xmit,
+};
+
+static struct device_type fbxbr_type = {
+	.name	= "fbxbridge",
+};
+
+/*
+ * fbxbridge alloc_netdev setup func
+ */
+#define COMMON_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | \
+			 NETIF_F_GSO_MASK | NETIF_F_HW_CSUM)
+
+static void fbxbr_netdev_setup(struct net_device *dev)
+{
+	struct fbxbr *br = netdev_priv(dev);
+	size_t i;
+
+	dev->flags = IFF_NOARP;
+	dev->type = ARPHRD_PPP;
+	dev->mtu = 1500;
+	dev->hard_header_len = 16;
+
+	dev->netdev_ops = &fbxbr_net_ops;
+	dev->needs_free_netdev = true;
+	SET_NETDEV_DEVTYPE(dev, &fbxbr_type);
+	dev->priv_flags = IFF_FBXBRIDGE | IFF_NO_QUEUE;
+
+	dev->features = 0;
+	dev->hw_features = 0;
+	dev->vlan_features = 0;
+
+	br->dev = dev;
+	rwlock_init(&br->lock);
+	rwlock_init(&br->lan_hwaddr_lock);
+	br->dhcpd_renew_time = DEFAULT_RENEWAL_TIME;
+	br->dhcpd_rebind_time = DEFAULT_REBIND_TIME;
+	br->dhcpd_lease_time = DEFAULT_LEASE_TIME;
+	spin_lock_init(&br->last_arp_lock);
+	br->last_arp_send = jiffies;
+
+	rwlock_init(&br->fwcache_lock);
+	INIT_LIST_HEAD(&br->fwcache_rules);
+	for (i = 0; i < ARRAY_SIZE(br->fwcache_hrules); i++)
+		INIT_HLIST_HEAD(&br->fwcache_hrules[i]);
+}
+
+/*
+ *
+ */
+int fbxbr_add_br(struct net *net, const char *name)
+{
+	struct net_device *dev;
+	struct fbxbr *br;
+	int ret;
+
+	dev = alloc_netdev(sizeof (struct fbxbr), name, NET_NAME_UNKNOWN,
+			   fbxbr_netdev_setup);
+	if (!dev)
+		return -ENOMEM;
+
+	dev_net_set(dev, net);
+
+	ret = register_netdev(dev);
+	if (ret) {
+		free_netdev(dev);
+		return ret;
+	}
+
+	br = netdev_priv(dev);
+	mutex_lock(&fbxbr_list_mutex);
+	list_add(&br->next, &fbxbr_list);
+	mutex_unlock(&fbxbr_list_mutex);
+
+	pr_notice("%s: new fbxbridge\n", dev->name);
+	return 0;
+}
+
+
+/*
+ * caller must hold rtnl lock
+ */
+int __fbxbr_del_br(struct net *net, const char *name)
+{
+	struct fbxbr *br;
+
+	br = __fbxbr_get_by_name(net, name);
+	if (IS_ERR(br))
+		return PTR_ERR(br);
+
+	mutex_lock(&fbxbr_list_mutex);
+	list_del(&br->next);
+	mutex_unlock(&fbxbr_list_mutex);
+
+	if (br->wan_port)
+		__fbxbr_del_br_port(br->wan_port);
+	if (br->lan_port)
+		__fbxbr_del_br_port(br->lan_port);
+
+	unregister_netdevice(br->dev);
+	return 0;
+}
+
+/*
+ *
+ */
+int fbxbr_get_params(struct net *net, const char *name,
+		     struct fbxbridge_ioctl_params *params)
+{
+	struct fbxbr *br;
+
+	rtnl_lock();
+
+	/* locate bridge */
+	br = __fbxbr_get_by_name(net, name);
+	if (IS_ERR(br)) {
+		rtnl_unlock();
+		return PTR_ERR(br);
+	}
+
+	/* copy current config */
+	params->flags = br->flags;
+	params->dns1_addr = br->dns1_ipaddr;
+	params->dns2_addr = br->dns2_ipaddr;
+	memcpy(params->ip_aliases, br->ip_aliases, sizeof (br->ip_aliases));
+	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;
+
+	/* current ports */
+	if (br->wan_port) {
+		memcpy(params->wan_dev.name,
+		       br->wan_port->dev->name,
+		       IFNAMSIZ);
+		params->wan_dev.present = 1;
+	} else {
+		params->wan_dev.name[0] = 0;
+		params->wan_dev.present = 0;
+	}
+
+	if (br->lan_port) {
+		memcpy(params->lan_dev.name,
+		       br->lan_port->dev->name,
+		       IFNAMSIZ);
+		params->lan_dev.present = 1;
+	} else {
+		params->lan_dev.name[0] = 0;
+		params->lan_dev.present = 0;
+	}
+
+	/* copy state */
+	read_lock_bh(&br->lan_hwaddr_lock);
+	params->have_hw_addr = br->have_hw_addr;
+	memcpy(params->lan_hwaddr, br->lan_hwaddr, ETH_ALEN);
+	read_unlock_bh(&br->lan_hwaddr_lock);
+
+	rtnl_unlock();
+
+	return 0;
+}
+
+/*
+ *
+ */
+int fbxbr_set_params(struct net *net, const char *name,
+		     const struct fbxbridge_ioctl_params *params)
+{
+	struct fbxbr *br;
+
+	rtnl_lock();
+
+	/* locate bridge */
+	br = __fbxbr_get_by_name(net, name);
+	if (IS_ERR(br)) {
+		rtnl_unlock();
+		return PTR_ERR(br);
+	}
+
+	write_lock_bh(&br->lock);
+
+	br->flags = params->flags;
+	br->dns1_ipaddr = params->dns1_addr;
+	br->dns2_ipaddr = params->dns2_addr;
+	memcpy(br->ip_aliases, params->ip_aliases, sizeof (br->ip_aliases));
+	br->dhcpd_renew_time = params->dhcpd_renew_time;
+	br->dhcpd_rebind_time = params->dhcpd_rebind_time;
+	br->dhcpd_lease_time = params->dhcpd_lease_time;
+	br->inputmark = params->inputmark;
+
+	write_unlock_bh(&br->lock);
+
+	fbxbr_fwcache_flush(br);
+
+	rtnl_unlock();
+
+	return 0;
+}
+
+/*
+ *
+ */
+void fbxbr_flush_cache(void)
+{
+	struct fbxbr *br;
+
+	mutex_lock(&fbxbr_list_mutex);
+	list_for_each_entry(br, &fbxbr_list, next)
+		fbxbr_fwcache_flush(br);
+	mutex_unlock(&fbxbr_list_mutex);
+}
+
+/*
+ * must be called with BH disabled
+ */
+void fbxbr_capture_hw_addr(struct fbxbr *br, const u8 *hwaddr)
+{
+	bool same;
+
+	read_lock(&br->lan_hwaddr_lock);
+	same = (br->have_hw_addr && !memcmp(br->lan_hwaddr, hwaddr, ETH_ALEN));
+	read_unlock(&br->lan_hwaddr_lock);
+
+	if (same)
+		return;
+
+	write_lock(&br->lan_hwaddr_lock);
+	memcpy(br->lan_hwaddr, hwaddr, ETH_ALEN);
+	br->have_hw_addr = 1;
+	write_unlock(&br->lan_hwaddr_lock);
+
+	pr_notice("%s: new lan hw address is now %pM\n",
+		  br->dev->name, hwaddr);
+}
+
+/*
+ * netdevice notifier callback, called with rtnl lock
+ */
+static int fbxbr_netdev_event_callback(struct notifier_block *this,
+				       unsigned long event, void *ptr)
+{
+	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+
+	ASSERT_RTNL();
+
+	if (!(dev->priv_flags & IFF_FBXBRIDGE_PORT))
+		return NOTIFY_DONE;
+
+	/* catch port that goes away */
+	switch (event) {
+	case NETDEV_UNREGISTER:
+		__fbxbr_del_br_port(fbxbr_port_get_rtnl(dev));
+		break;
+
+	default:
+		break;
+	};
+
+	return NOTIFY_DONE;
+}
+
+/*
+ * handle inet configuration event on port
+ */
+static void __handle_inet_port_event(struct fbxbr_port *p,
+				     unsigned long event,
+				     struct in_ifaddr *ifa)
+{
+	struct fbxbr *br;
+
+	if (!p->is_wan)
+		return;
+
+	br = p->br;
+
+	switch (event) {
+	case NETDEV_UP:
+		write_lock_bh(&br->lan_hwaddr_lock);
+		__fetch_wan_parameters(br, ifa);
+		write_unlock_bh(&br->lan_hwaddr_lock);
+		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;
+	}
+}
+
+/*
+ * handle inet configuration event on bridge interface (fbxbr%d)
+ */
+static void __handle_inet_bridge_event(struct fbxbr *br,
+				       unsigned long event,
+				       struct in_ifaddr *ifa)
+{
+	switch (event) {
+	case NETDEV_UP:
+		if (!ifa->ifa_address || ifa->ifa_local == ifa->ifa_address)
+			return;
+
+		write_lock_bh(&br->lan_hwaddr_lock);
+		br->br_ipaddr = ifa->ifa_local;
+		br->br_remote_ipaddr = ifa->ifa_address;
+		write_unlock_bh(&br->lan_hwaddr_lock);
+
+		if (br->br_ipaddr)
+			pr_info("%s: bridge local interface configured: "
+				"[%pI4 -> %pI4]\n",
+				br->dev->name,
+				&br->br_ipaddr,
+				&br->br_remote_ipaddr);
+		break;
+
+	case NETDEV_DOWN:
+		write_lock_bh(&br->lan_hwaddr_lock);
+		if (br->br_ipaddr) {
+			br->br_ipaddr = br->br_remote_ipaddr = 0;
+			pr_info("%s: bridge interface unconfigured\n",
+				br->dev->name);
+		}
+		write_unlock_bh(&br->lan_hwaddr_lock);
+		break;
+
+	default:
+		return;
+	}
+}
+
+/*
+ * kernel inet event notifier callback
+ */
+static int fbxbr_inet_event_callback(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;
+
+	ASSERT_RTNL();
+
+	/* is it a bridge ? */
+	if (dev->priv_flags & IFF_FBXBRIDGE) {
+		struct fbxbr *br = netdev_priv(dev);
+		__handle_inet_bridge_event(br, event, ifa);
+		return NOTIFY_DONE;
+	}
+
+	/* is it a bridge port */
+	if (dev->priv_flags & IFF_FBXBRIDGE_PORT) {
+		struct fbxbr_port *p = fbxbr_port_get_rtnl(dev);
+		__handle_inet_port_event(p, event, ifa);
+		return NOTIFY_DONE;
+	}
+
+	return NOTIFY_DONE;
+}
+
+
+static struct notifier_block fbxbr_netdev_notifier = {
+	notifier_call: fbxbr_netdev_event_callback,
+};
+
+static struct notifier_block fbxbr_inet_notifier = {
+	notifier_call: fbxbr_inet_event_callback,
+};
+
+/*
+ *
+ */
+static int __init fbxbr_init_module(void)
+{
+	int err;
+
+	err = register_netdevice_notifier(&fbxbr_netdev_notifier);
+	if (err) {
+		pr_err("can't register netdevice notifier\n");
+		return err;
+	}
+
+	err = register_inetaddr_notifier(&fbxbr_inet_notifier);
+	if (err) {
+		pr_err("can't register inet notifier\n");
+		goto err_netdev;
+	}
+
+	fbxbridge_set(fbxbr_ioctl);
+	return 0;
+
+err_netdev:
+	unregister_netdevice_notifier(&fbxbr_netdev_notifier);
+	return err;
+}
+
+/*
+ *
+ */
+static void __exit fbxbr_exit_module(void)
+{
+	unregister_netdevice_notifier(&fbxbr_netdev_notifier);
+	unregister_inetaddr_notifier(&fbxbr_inet_notifier);
+	fbxbridge_set(NULL);
+}
+
+module_init(fbxbr_init_module);
+module_exit(fbxbr_exit_module);
+
+MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
+MODULE_DESCRIPTION("Freebox Network Bridge - www.freebox.fr");
+MODULE_LICENSE("GPL");
diff -Nruw linux-5.4.60-fbx/net/fbxbridge./fbxbr_dhcp.c linux-5.4.60-fbx/net/fbxbridge/fbxbr_dhcp.c
--- linux-5.4.60-fbx/net/fbxbridge./fbxbr_dhcp.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxbridge/fbxbr_dhcp.c	2021-03-04 13:21:01.414172385 +0100
@@ -0,0 +1,502 @@
+#include "fbxbr_private.h"
+#include <linux/udp.h>
+#include <net/ip.h>
+#include <asm/checksum.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 FBX_OPT_VENDOR_F_IGNORE_BRIDGE	(1 << 0)
+
+struct fbx_opt_vendor {
+	u8	oui[3];
+	u32	version;
+	u32	flags;
+} __attribute__((packed));
+
+#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;
+
+	struct fbx_opt_vendor	fbx;
+	bool			fbx_valid;
+
+	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;
+
+		case 224: /* IANA reserved for freebox use */
+		{
+			if (len >= sizeof (opts->fbx)) {
+				memcpy(&opts->fbx, option + 2,
+				       sizeof (opts->fbx));
+				if (opts->fbx.oui[0] == 0x00 &&
+				    opts->fbx.oui[1] == 0x07 &&
+				    opts->fbx.oui[2] == 0xCB)
+					opts->fbx_valid = true;
+			}
+			break;
+		}
+		}
+	}
+}
+
+static void dump_dhcp_message(struct fbxbr *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->dev->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->dev->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 fbxbr *br,
+			    struct net_device *dev,
+			    const u8 *dest_hw,
+			    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;
+	int hlen = LL_RESERVED_SPACE(dev);
+	int tlen = dev->needed_tailroom;
+
+	/* Allocate packet */
+	skb = alloc_skb(sizeof (struct bootp_pkt) + hlen + tlen, GFP_ATOMIC);
+	if (!skb)
+		return;
+
+	skb->dev = dev;
+	skb_reserve(skb, hlen);
+	skb_reset_network_header(skb);
+
+	b = (struct bootp_pkt *)skb_put(skb, sizeof(struct bootp_pkt));
+	memset(b, 0, sizeof(struct bootp_pkt));
+
+	/* Construct IP header */
+	h = &b->iph;
+	h->version = 4;
+	h->ihl = 5;
+	h->tot_len = htons(sizeof(struct bootp_pkt));
+	h->frag_off = htons(IP_DF);
+	h->ttl = 64;
+	h->protocol = IPPROTO_UDP;
+	h->saddr = br->lan_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->lan_gw;
+		b->your_ip = br->wan_ipaddr;
+		break;
+
+	case DHCPACK:
+		b->client_ip = src_packet->client_ip;
+		b->server_ip = br->lan_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->lan_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->lan_gw) |
+			~br->lan_netmask;
+		dhcp_opts.dns1 = br->dns1_ipaddr;
+		dhcp_opts.dns2 = br->dns2_ipaddr ? br->dns2_ipaddr : 0;
+		dhcp_opts.router = br->lan_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");
+
+	if (dev_hard_header(skb, dev, ETH_P_IP,
+			    dest_hw, dev->dev_addr, skb->len) < 0) {
+		kfree(skb);
+		return;
+	}
+
+	dev_queue_xmit(skb);
+}
+
+/*
+ * called under bridge lock
+ *
+ * packet must be a valid IP & UDP packet with dport 67
+ *
+ * answer will be sent to skb->dev
+ */
+void fbxbr_dhcpd(struct fbxbr *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 (opts.fbx_valid &&
+	    (be32_to_cpu(opts.fbx.flags) & FBX_OPT_VENDOR_F_IGNORE_BRIDGE)) {
+		printk(KERN_DEBUG "%s: ignore DHCP message with "
+		       "freebox ignore-bridge flags set\n", br->dev->name);
+		return;
+	}
+
+        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) {
+		send_dhcp_reply(br, skb->dev, bpkt->hw_addr,
+				DHCPOFFER, bpkt, &opts);
+
+	} else if (opts.msg_type == DHCPREQUEST) {
+		/* 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, skb->dev, bpkt->hw_addr,
+						DHCPNACK, bpkt, &opts);
+			else {
+				send_dhcp_reply(br, skb->dev, bpkt->hw_addr,
+						DHCPACK, bpkt, &opts);
+				fbxbr_capture_hw_addr(br, bpkt->hw_addr);
+			}
+			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, skb->dev, bpkt->hw_addr,
+						DHCPNACK, bpkt, &opts);
+			else {
+				send_dhcp_reply(br, skb->dev, bpkt->hw_addr,
+						DHCPACK, bpkt, &opts);
+				fbxbr_capture_hw_addr(br, bpkt->hw_addr);
+			}
+			return;
+		}
+
+		/* SELECTING */
+		if (opts.server_id == br->lan_gw) {
+			/* client selected us */
+			send_dhcp_reply(br, skb->dev, bpkt->hw_addr,
+					DHCPACK, bpkt, &opts);
+			fbxbr_capture_hw_addr(br, bpkt->hw_addr);
+		} else {
+			/* ignore */
+		}
+	}
+}
diff -Nruw linux-5.4.60-fbx/net/fbxbridge./fbxbr_filter.c linux-5.4.60-fbx/net/fbxbridge/fbxbr_filter.c
--- linux-5.4.60-fbx/net/fbxbridge./fbxbr_filter.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxbridge/fbxbr_filter.c	2021-03-04 13:21:01.414172385 +0100
@@ -0,0 +1,258 @@
+#include <net/ip.h>
+#include <net/netfilter/nf_conntrack.h>
+#include <linux/netfilter.h>
+#include "fbxbr_private.h"
+
+static int lolfn(struct net *net, struct sock *sk, struct sk_buff *skb)
+{
+	return 0;
+}
+
+/*
+ * invoke netfilter table for finer grained control
+ */
+static int
+netfilter_call_hook(struct sk_buff *skb,
+		    unsigned int hook,
+		    struct net_device *in_dev,
+		    struct net_device *out_dev)
+{
+	struct iphdr *iph = ip_hdr(skb);
+	int ret;
+
+	/* don't run frags into netfilter */
+	if ((iph->frag_off & htons(IP_OFFSET)))
+		return NF_ACCEPT;
+
+	nf_ct_set(skb, NULL, IP_CT_UNTRACKED);
+
+	/* NF_HOOK will kfree_skb(), guard against this */
+	skb_get(skb);
+
+	ret = NF_HOOK(NFPROTO_IPV4,
+		      hook,
+		      &init_net,
+		      NULL,
+		      skb,
+		      in_dev,
+		      out_dev,
+		      lolfn);
+
+	if (ret < 0)
+		return NF_DROP;
+
+	skb_unref(skb);
+	return NF_ACCEPT;
+}
+
+static int
+netfilter_forward_hook(struct sk_buff *skb,
+		       struct net_device *in_dev,
+		       struct net_device *out_dev)
+{
+	return netfilter_call_hook(skb, NF_INET_FORWARD, in_dev, out_dev);
+}
+
+static int
+netfilter_input_hook(struct sk_buff *skb, struct net_device *in_dev)
+{
+	return netfilter_call_hook(skb, NF_INET_LOCAL_IN, in_dev, NULL);
+}
+
+/*
+ * set input mark bits, return true if changed
+ */
+static bool skb_set_br_inputmark(struct fbxbr *br, struct sk_buff *skb)
+{
+	if (unlikely(skb->mark & br->inputmark)) {
+		if (net_ratelimit())
+			pr_err("%s: input mark already set on skb\n",
+			       br->dev->name);
+		return false;
+	}
+
+	skb->mark |= br->inputmark;
+	return true;
+}
+
+static inline void skb_clear_br_inputmark(struct fbxbr *br,
+					  struct sk_buff *skb)
+{
+	skb->mark &= ~br->inputmark;
+}
+
+/*
+ * assume linear ip header
+ */
+static bool wan_to_lan_want_keep(struct fbxbr *br,
+				 struct sk_buff *skb)
+{
+	struct iphdr *iph = ip_hdr(skb);
+	bool changed;
+	int ret;
+
+	/* keep ETHER_IP packets */
+	if (iph->protocol == 97)
+		return true;
+
+	/* give ipv6 in ip private to freebox back to the
+	 * kernel */
+	if (iph->protocol == IPPROTO_IPV6) {
+		struct ipv6hdr *iph6;
+		unsigned int hlen;
+
+		/* capture at least all traffic from our GW
+		 * (192.88.99.101) */
+		if (iph->saddr == htonl(0xc0586365))
+			return true;
+
+		/* rest if peer-to-peer shortcut traffic, check if
+		 * this is for our IPv6 subnet, we cannot do it on
+		 * fragmented traffic thought */
+		if (iph->frag_off & htons(IP_OFFSET))
+			return false;
+
+		/* sanity check on header value */
+		hlen = iph->ihl * 4;
+		if (skb->len < hlen + sizeof(struct ipv6hdr))
+			return false;
+
+		iph6 = (struct ipv6hdr *)((unsigned char *)iph + hlen);
+		if ((iph6->daddr.s6_addr32[0] & htonl(0xfffffff0)) ==
+		    htonl(0x2a010e30))
+			return true;
+	}
+
+	if (!(br->flags & FBXBRIDGE_FLAGS_NETFILTER))
+		return false;
+
+	/* we cant filter frags with netfilter */
+	if (iph->frag_off & htons(IP_OFFSET))
+		return false;
+
+	/* check netfilter input hook */
+	changed = skb_set_br_inputmark(br, skb);
+	ret = netfilter_input_hook(skb, skb->dev);
+	if (changed)
+		skb_clear_br_inputmark(br, skb);
+
+	if (ret == NF_ACCEPT)
+		return true;
+
+	return false;
+}
+
+/*
+ * assume linear ip header
+ */
+static bool wan_to_lan_can_forward(struct fbxbr *br, struct sk_buff *skb)
+{
+	if ((br->flags & FBXBRIDGE_FLAGS_NETFILTER)) {
+		int ret;
+
+		ret = netfilter_forward_hook(skb, br->wan_port->dev, br->dev);
+		if (ret == NF_DROP)
+			return false;
+	}
+	return true;
+}
+
+/*
+ * note: caller assured that ip header is valid and holds bridge read
+ * lock
+ *
+ * use netfilter hook return type
+ */
+int
+fbxbr_filter_wan_to_lan_packet(struct fbxbr *br, struct sk_buff *skb)
+{
+	int ret;
+
+	if (wan_to_lan_want_keep(br, skb))
+		return NF_STOP;
+
+	if (!br->lan_port)
+		return NF_DROP;
+
+	ret = wan_to_lan_can_forward(br, skb);
+	if (ret != NF_ACCEPT)
+		return NF_DROP;
+
+	return NF_ACCEPT;
+}
+
+/*
+ * assume linear ip header
+ */
+static bool lan_to_wan_want_keep(struct fbxbr *br, struct sk_buff *skb)
+{
+	return false;
+}
+
+/*
+ * assume linear ip header
+ */
+static bool lan_to_wan_can_forward(struct fbxbr *br, struct sk_buff *skb)
+{
+	struct iphdr *iph = ip_hdr(skb);
+
+	/* disallow source spoofing */
+	if (iph->saddr != br->wan_ipaddr)
+		return false;
+
+	/* disallow all private net destination */
+	if (ipv4_is_loopback(iph->daddr) ||
+	    ipv4_is_private_10(iph->daddr) ||
+	    ipv4_is_private_172(iph->daddr) ||
+	    ipv4_is_private_192(iph->daddr) ||
+	    ipv4_is_linklocal_169(iph->daddr) ||
+	    ipv4_is_anycast_6to4(iph->daddr) ||
+	    ipv4_is_test_192(iph->daddr) ||
+	    ipv4_is_test_198(iph->daddr))
+		return false;
+
+	/* no multicast please */
+	if (ipv4_is_multicast(iph->daddr))
+		return false;
+
+	/* Don't let IP broadcast go through us */
+	if (ipv4_is_zeronet(iph->daddr))
+		return false;
+
+	if (ipv4_is_lbcast(iph->daddr))
+		return false;
+
+	if ((br->flags & FBXBRIDGE_FLAGS_NETFILTER)) {
+		int ret;
+
+		ret = netfilter_forward_hook(skb, br->dev, br->wan_port->dev);
+		if (ret == NF_DROP)
+			return false;
+	}
+
+	return true;
+}
+
+/*
+ * note: caller assured that ip header is valid and holds bridge read
+ * lock
+ *
+ * use netfilter hook return type
+ */
+int
+fbxbr_filter_lan_to_wan_packet(struct fbxbr *br, struct sk_buff *skb)
+{
+	int ret;
+
+	if (lan_to_wan_want_keep(br, skb))
+		return NF_STOP;
+
+	if (!br->wan_port)
+		return NF_DROP;
+
+	ret = lan_to_wan_can_forward(br, skb);
+	if (ret != NF_ACCEPT)
+		return NF_DROP;
+
+	return NF_ACCEPT;
+}
diff -Nruw linux-5.4.60-fbx/net/fbxbridge./fbxbr_fwcache.c linux-5.4.60-fbx/net/fbxbridge/fbxbr_fwcache.c
--- linux-5.4.60-fbx/net/fbxbridge./fbxbr_fwcache.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxbridge/fbxbr_fwcache.c	2021-03-04 13:21:01.414172385 +0100
@@ -0,0 +1,177 @@
+#include <linux/jhash.h>
+#include <net/ip.h>
+#include "fbxbr_private.h"
+
+/*
+ *
+ */
+u32 fbxbr_fwcache_hash(const struct fbxbr_fwcache_key *k)
+{
+	return jhash_3words(k->lan_ip,
+			    k->is_tcp ? k->wan_ip : ~k->wan_ip,
+			    k->lan_port | k->wan_port << 16, 0);
+}
+
+/*
+ * must be called with bh disabled and fwcache held
+ */
+struct fbxbr_fwcache *
+__fbxbr_fwcache_lookup(struct fbxbr *br, u32 hash,
+		       const struct fbxbr_fwcache_key *k)
+{
+	struct fbxbr_fwcache *fwc;
+
+	hlist_for_each_entry(fwc,
+			     &br->fwcache_hrules[hash % FBXBR_FWCACHE_SIZE],
+			     hnext) {
+		/* compare entry */
+		if (fwc->lan_ip == k->lan_ip &&
+		    fwc->wan_ip == k->wan_ip &&
+		    fwc->is_tcp == k->is_tcp &&
+		    fwc->lan_port == k->lan_port &&
+		    fwc->wan_port == k->wan_port)
+			return fwc;
+	}
+
+	return NULL;
+}
+
+/*
+ * return true if the flow has a chance to be in the fwcache
+ *
+ * skb must be a valid ipv4 packet
+ */
+bool fbxbr_fwcache_skb_allowable(struct sk_buff *skb,
+				 bool from_wan,
+				 struct fbxbr_fwcache_key *k,
+				 bool *can_create)
+{
+	const struct iphdr *iph;
+	__be16 psrc, pdst;
+
+	iph = ip_hdr(skb);
+
+	if (iph->frag_off & htons(IP_OFFSET))
+		return false;
+
+	if (iph->protocol != IPPROTO_UDP && iph->protocol != IPPROTO_TCP)
+		return false;
+
+	if (from_wan) {
+		k->wan_ip = iph->saddr;
+		k->lan_ip = iph->daddr;
+	} else {
+		k->lan_ip = iph->saddr;
+		k->wan_ip = iph->daddr;
+	}
+
+	if (iph->protocol == IPPROTO_UDP) {
+		struct udphdr *udph;
+
+		if (!pskb_may_pull(skb, skb_transport_offset(skb) +
+				   sizeof (struct udphdr)))
+			return false;
+
+		udph = (struct udphdr *)skb_transport_header(skb);
+		*can_create = true;
+
+		psrc = udph->source;
+		pdst = udph->dest;
+		k->is_tcp = false;
+	} else {
+		struct tcphdr *tcph;
+
+		if (!pskb_may_pull(skb, skb_transport_offset(skb) +
+				   sizeof (struct tcphdr)))
+			return false;
+
+		tcph = (struct tcphdr *)skb_transport_header(skb);
+		if (tcph->syn)
+			*can_create = true;
+		else
+			*can_create = false;
+
+		psrc = tcph->source;
+		pdst = tcph->dest;
+		k->is_tcp = true;
+	}
+
+	if (from_wan) {
+		k->wan_port = psrc;
+		k->lan_port = pdst;
+	} else {
+		k->lan_port = psrc;
+		k->wan_port = pdst;
+	}
+	return true;
+}
+
+/*
+ * must be called with bh disabled
+ */
+int fbxbr_fwcache_add(struct fbxbr *br,
+		      u32 hash, const struct fbxbr_fwcache_key *k)
+{
+	struct fbxbr_fwcache *fwc;
+
+	write_lock(&br->fwcache_lock);
+
+	if (unlikely(__fbxbr_fwcache_lookup(br, hash, k)))
+		goto done;
+
+	/* add new entry */
+	if (br->fwcache_count < FBXBR_FWCACHE_MAX_ENTRY) {
+		fwc = kmalloc(sizeof (*fwc), GFP_ATOMIC);
+		if (!fwc)
+			goto done;
+		br->fwcache_count++;
+	} else {
+		fwc = list_first_entry(&br->fwcache_rules,
+				       struct fbxbr_fwcache,
+				       next);
+		hlist_del(&fwc->hnext);
+		list_del(&fwc->next);
+		if (fwc->priv_destructor)
+			fwc->priv_destructor((void *)fwc->priv_area);
+	}
+
+	fwc->lan_ip = k->lan_ip;
+	fwc->wan_ip = k->wan_ip;
+	fwc->lan_port = k->lan_port;
+	fwc->wan_port = k->wan_port;
+	fwc->is_tcp = k->is_tcp;
+	fwc->priv_destructor = NULL;
+	memset(fwc->priv_area, 0, sizeof (fwc->priv_area));
+
+	hlist_add_head(&fwc->hnext,
+		       &br->fwcache_hrules[hash % FBXBR_FWCACHE_SIZE]);
+	list_add_tail(&fwc->next, &br->fwcache_rules);
+
+done:
+	write_unlock(&br->fwcache_lock);
+	return 0;
+}
+
+/*
+ *
+ */
+void fbxbr_fwcache_flush(struct fbxbr *br)
+{
+	struct fbxbr_fwcache *fwc, *tmp;
+	size_t i;
+
+	write_lock_bh(&br->fwcache_lock);
+
+	list_for_each_entry_safe(fwc, tmp, &br->fwcache_rules, next) {
+		if (fwc->priv_destructor)
+			fwc->priv_destructor((void *)fwc->priv_area);
+		kfree(fwc);
+	}
+
+	INIT_LIST_HEAD(&br->fwcache_rules);
+	for (i = 0; i < ARRAY_SIZE(br->fwcache_hrules); i++)
+		INIT_HLIST_HEAD(&br->fwcache_hrules[i]);
+	br->fwcache_count = 0;
+
+	write_unlock_bh(&br->fwcache_lock);
+}
diff -Nruw linux-5.4.60-fbx/net/fbxbridge./fbxbr_input.c linux-5.4.60-fbx/net/fbxbridge/fbxbr_input.c
--- linux-5.4.60-fbx/net/fbxbridge./fbxbr_input.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxbridge/fbxbr_input.c	2021-03-04 13:21:01.414172385 +0100
@@ -0,0 +1,347 @@
+#include <linux/if_arp.h>
+#include <linux/in.h>
+#include <linux/udp.h>
+#include <net/ip.h>
+#include "fbxbr_private.h"
+
+/*
+ *
+ */
+static rx_handler_result_t __handle_wan_frame(struct fbxbr_port *p,
+					      struct sk_buff *skb)
+{
+	struct fbxbr *br = p->br;
+	struct fbxbr_fwcache_key fwk;
+	bool fwc_present, fwc_can_create;
+	u32 hash = 0;
+	int ret;
+
+	/* give back non IPv4 packets */
+	if (skb->protocol != htons(ETH_P_IP))
+		return RX_HANDLER_PASS;
+
+	/* stop here if we have no idea what the wan ip address is or
+	 * was */
+	if (!br->wan_ipaddr)
+		goto drop;
+
+	if (!fbxbr_is_valid_ip_packet(skb))
+		goto drop;
+
+	/* lookup into forward cache */
+	fwc_present = false;
+	fwc_can_create = false;
+
+	if (fbxbr_fwcache_skb_allowable(skb, true, &fwk, &fwc_can_create)) {
+		hash = fbxbr_fwcache_hash(&fwk);
+		read_lock(&br->fwcache_lock);
+		fwc_present = (__fbxbr_fwcache_lookup(br, hash, &fwk) != NULL);
+		read_unlock(&br->fwcache_lock);
+	}
+
+	if (fwc_present)
+		goto output_lan;
+
+	ret = fbxbr_filter_wan_to_lan_packet(br, skb);
+	switch (ret) {
+	default:
+		WARN(1, "unsupported filter action");
+		/* fallthrough */
+
+	case NF_DROP:
+		kfree_skb(skb);
+		return RX_HANDLER_CONSUMED;
+
+	case NF_STOP:
+		nf_reset_ct(skb);
+		return RX_HANDLER_PASS;
+
+	case NF_ACCEPT:
+		break;
+	}
+
+output_lan:
+	if (!br->lan_port)
+		goto drop;
+
+	fbxbr_output_lan_frame(br, skb);
+
+	if (!fwc_present && fwc_can_create)
+		fbxbr_fwcache_add(br, hash, &fwk);
+
+	return RX_HANDLER_CONSUMED;
+
+drop:
+	kfree_skb(skb);
+	return RX_HANDLER_CONSUMED;
+}
+
+/*
+ *
+ */
+static void
+__handle_lan_arp_frame(struct fbxbr_port *p, struct sk_buff *skb)
+{
+	struct net_device *dev = p->dev;
+	struct fbxbr *br = p->br;
+	__be32 sender_ipaddr, target_ipaddr;
+	u8 *sender_hwaddr, *req;
+	struct arphdr *arp;
+
+	if (!pskb_may_pull(skb, arp_hdr_len(p->dev)))
+		goto done;
+
+	arp = arp_hdr(skb);
+	if (arp->ar_hln != dev->addr_len || arp->ar_pln != 4)
+		goto done;
+
+	if ((arp->ar_hrd != htons(ARPHRD_ETHER) &&
+	     arp->ar_hrd != htons(ARPHRD_IEEE802)) ||
+	    arp->ar_pro != htons(ETH_P_IP))
+		goto done;
+
+	if (arp->ar_op != htons(ARPOP_REQUEST) &&
+	    arp->ar_op != htons(ARPOP_REPLY))
+		goto done;
+
+	/* fetch subfields */
+	req = (unsigned char *)(arp + 1);
+
+	sender_hwaddr = req;
+	req += ETH_ALEN;
+
+	memcpy(&sender_ipaddr, req, 4);
+	req += 4;
+
+	/* skip target_hwaddr */
+	req += dev->addr_len;
+
+	memcpy(&target_ipaddr, req, 4);
+
+	/* ignore gratuitous ARP */
+	if (!sender_ipaddr)
+		goto done;
+
+	if (arp->ar_op == htons(ARPOP_REQUEST)) {
+
+		/* client is sending an arp request */
+		if (!br->wan_ipaddr) {
+			/* wan has never been up, our wan address is
+			 * not known, answer to every arp requests */
+
+			/* ignore what looks like gratuitous ARP */
+			if (sender_ipaddr == target_ipaddr)
+				goto done;
+
+			/* don't answer for special ip address */
+			if (ipv4_is_private_10(target_ipaddr) ||
+			    ipv4_is_private_172(target_ipaddr) ||
+			    ipv4_is_private_192(target_ipaddr) ||
+			    ipv4_is_linklocal_169(target_ipaddr) ||
+			    ipv4_is_anycast_6to4(target_ipaddr) ||
+			    ipv4_is_test_192(target_ipaddr) ||
+			    ipv4_is_test_198(target_ipaddr))
+				goto done;
+
+			/* ok, will reply with a zero source
+			 * address */
+		} else {
+			/* wan is up, filter our arp reply to match
+			 * WAN */
+
+			/* accept only arp from remote client */
+			if (sender_ipaddr != br->wan_ipaddr)
+				goto done;
+
+			/* accept only arp request for wan network */
+			if ((target_ipaddr & br->lan_netmask) !=
+			    (br->wan_ipaddr & br->lan_netmask))
+				goto done;
+
+			/* request is for the client's address, keep quiet */
+			if (target_ipaddr == br->wan_ipaddr)
+				goto done;
+		}
+
+		/* ok I can answer */
+		fbxbr_send_arp_frame(dev, ARPOP_REPLY, sender_hwaddr,
+				     target_ipaddr, NULL,
+				     br->wan_ipaddr, sender_hwaddr);
+
+		/* keep the client address */
+		fbxbr_capture_hw_addr(br, sender_hwaddr);
+
+	} else {
+
+		/* accept only arp from remote client */
+		if (sender_ipaddr != br->wan_ipaddr)
+			goto done;
+
+		/* we received  an arp reply,  iff it was  addressed to
+		 * us, then keep the client mac address  */
+		if (target_ipaddr != br->lan_gw)
+			goto done;
+
+		fbxbr_capture_hw_addr(br, sender_hwaddr);
+	}
+
+done:
+	kfree_skb(skb);
+}
+
+/*
+ *
+ */
+static inline bool __is_local_ip(struct fbxbr *br, __be32 ipaddr)
+{
+	int i;
+
+	if (ipaddr == br->br_ipaddr || ipv4_is_multicast(ipaddr))
+		return true;
+
+	for (i = 0; i < MAX_ALIASES; i++) {
+		if (br->ip_aliases[i] && br->ip_aliases[i] == ipaddr)
+			return true;
+	}
+
+	return false;
+}
+
+/*
+ *
+ */
+static rx_handler_result_t __handle_lan_frame(struct fbxbr_port *p,
+					      struct sk_buff *skb)
+{
+	struct fbxbr *br = p->br;
+	struct iphdr *iph;
+	struct fbxbr_fwcache_key fwk;
+	bool fwc_present, fwc_can_create, is_fragment;
+	u32 hash = 0;
+	int ret;
+
+	if (skb->protocol == htons(ETH_P_ARP)) {
+		__handle_lan_arp_frame(p, skb);
+		return RX_HANDLER_CONSUMED;
+	}
+
+	/* give back non IPv4 packets */
+	if (skb->protocol != htons(ETH_P_IP))
+		return RX_HANDLER_PASS;
+
+	if (!fbxbr_is_valid_ip_packet(skb))
+		goto 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)) {
+
+		if (!br->br_remote_ipaddr)
+			goto drop;
+
+		/* packet comes from lan, snat it and make it local */
+		fbxbr_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);
+		return RX_HANDLER_CONSUMED;
+	}
+
+	/* stop here if we have no idea what the wan ip address is or
+	 * was */
+	if (!br->wan_ipaddr)
+		goto drop;
+
+	/* lookup into forward cache */
+	fwc_present = false;
+	fwc_can_create = false;
+
+	if (fbxbr_fwcache_skb_allowable(skb, false, &fwk, &fwc_can_create)) {
+		hash = fbxbr_fwcache_hash(&fwk);
+		read_lock(&br->fwcache_lock);
+		fwc_present = (__fbxbr_fwcache_lookup(br, hash, &fwk) != NULL);
+		read_unlock(&br->fwcache_lock);
+	}
+
+	if (fwc_present)
+		goto output_wan;
+
+	/* process DHCP if enabled */
+	is_fragment = iph->frag_off & htons(IP_OFFSET);
+	if (iph->protocol == IPPROTO_UDP &&
+	    !is_fragment &&
+	    (br->flags & FBXBRIDGE_FLAGS_DHCPD)) {
+		struct udphdr *udp;
+
+		if (!fbxbr_is_valid_udp_tcp_packet(skb))
+			goto drop;
+
+		udp = udp_hdr(skb);
+		if (udp->dest == htons(67)) {
+			fbxbr_dhcpd(br, skb);
+			goto drop;
+		}
+	}
+
+	ret = fbxbr_filter_lan_to_wan_packet(br, skb);
+	switch (ret) {
+	default:
+		WARN(1, "unsupported filter action");
+		/* fallthrough */
+
+	case NF_DROP:
+		kfree_skb(skb);
+		return RX_HANDLER_CONSUMED;
+
+	case NF_STOP:
+		nf_reset_ct(skb);
+		return RX_HANDLER_PASS;
+
+	case NF_ACCEPT:
+		break;
+	}
+
+output_wan:
+	if (!br->wan_port)
+		goto drop;
+
+	fbxbr_output_wan_frame(br, skb);
+
+	if (!fwc_present && fwc_can_create)
+		fbxbr_fwcache_add(br, hash, &fwk);
+
+	return RX_HANDLER_CONSUMED;
+
+drop:
+	kfree_skb(skb);
+	return RX_HANDLER_CONSUMED;
+}
+
+/*
+ *
+ */
+rx_handler_result_t fbxbr_handle_frame(struct sk_buff **pskb)
+{
+	struct sk_buff *skb = *pskb;
+	struct fbxbr_port *p;
+	rx_handler_result_t ret;
+
+	skb = skb_share_check(skb, GFP_ATOMIC);
+	if (!skb)
+		return RX_HANDLER_CONSUMED;
+
+	p = fbxbr_port_get_rcu(skb->dev);
+
+	read_lock(&p->br->lock);
+	if (p->is_wan)
+		ret = __handle_wan_frame(p, skb);
+	else
+		ret = __handle_lan_frame(p, skb);
+	read_unlock(&p->br->lock);
+
+	return ret;
+}
diff -Nruw linux-5.4.60-fbx/net/fbxbridge./fbxbr_ioctl.c linux-5.4.60-fbx/net/fbxbridge/fbxbr_ioctl.c
--- linux-5.4.60-fbx/net/fbxbridge./fbxbr_ioctl.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxbridge/fbxbr_ioctl.c	2021-03-04 13:21:01.414172385 +0100
@@ -0,0 +1,85 @@
+#include <linux/capability.h>
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <net/net_namespace.h>
+#include <linux/uaccess.h>
+#include "fbxbr_private.h"
+
+/*
+ * ioctl handling
+ */
+int fbxbr_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;
+	int ret;
+
+	/* fetch ioctl request */
+	if (copy_from_user(&req, arg, sizeof (req)))
+		return -EFAULT;
+
+	switch (req.cmd) {
+	case E_CMD_BR_CHG:
+		if (copy_from_user(&chg, (void *)req.arg, sizeof (chg)))
+			return -EFAULT;
+
+		if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
+			return -EPERM;
+
+		if (!chg.action)
+			return fbxbr_add_br(net, chg.brname);
+
+		rtnl_lock();
+		ret = __fbxbr_del_br(net, chg.brname);
+		rtnl_unlock();
+		return ret;
+
+	case E_CMD_BR_DEV_CHG:
+		if (copy_from_user(&dev_chg, (void *)req.arg,
+				   sizeof (dev_chg)))
+			return -EFAULT;
+
+		if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
+			return -EPERM;
+
+		rtnl_lock();
+		if (!dev_chg.action)
+			ret = __fbxbr_add_br_port(net,
+						  dev_chg.brname,
+						  dev_chg.devname,
+						  dev_chg.wan);
+		else
+			ret = __fbxbr_del_br_port_by_name(net,
+							  dev_chg.brname,
+							  dev_chg.devname);
+		rtnl_unlock();
+		return ret;
+
+	case E_CMD_BR_PARAMS:
+		if (copy_from_user(&params, (void *)req.arg, sizeof (params)))
+			return -EFAULT;
+
+		if (!params.action) {
+			/* this is a get */
+			ret = fbxbr_get_params(net, params.brname, &params);
+			if (ret)
+				return ret;
+
+			return copy_to_user((void *)req.arg, &params,
+					    sizeof (params));
+		}
+
+		/* this is a set */
+		if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
+			return -EPERM;
+
+		return fbxbr_set_params(net, params.brname, &params);
+
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
diff -Nruw linux-5.4.60-fbx/net/fbxbridge./fbxbr_output.c linux-5.4.60-fbx/net/fbxbridge/fbxbr_output.c
--- linux-5.4.60-fbx/net/fbxbridge./fbxbr_output.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxbridge/fbxbr_output.c	2021-03-04 13:21:01.414172385 +0100
@@ -0,0 +1,164 @@
+#include <net/ip.h>
+#include <net/arp.h>
+#include "fbxbr_private.h"
+
+/*
+ * caller must hold bridge lock
+ *
+ * lan port must be valid
+ */
+void fbxbr_output_lan_mcast_frame(struct fbxbr *br, struct sk_buff *skb)
+{
+	struct fbxbr_port *p = br->lan_port;
+	struct net_device *dev = p->dev;
+	struct iphdr *ip;
+	u8 mcast_hwaddr[6];
+	u32 daddr;
+
+	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 = dev;
+	dev_hard_header(skb, dev, ETH_P_802_3, mcast_hwaddr, dev->dev_addr,
+			ETH_P_IP);
+	dev_queue_xmit(skb);
+}
+
+/*
+ * caller must hold bridge lock and have BH disabled
+ *
+ * lan port must be valid
+ *
+ * must be a valid ip packet
+ */
+void fbxbr_output_lan_frame(struct fbxbr *br, struct sk_buff *skb)
+{
+	struct fbxbr_port *p = br->lan_port;
+	struct net_device *dev = p->dev;
+	struct iphdr *iph;
+	const char *dest_hw;
+
+	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  */
+		spin_lock(&br->last_arp_lock);
+		if (time_before(jiffies, br->last_arp_send + ARP_RATE_LIMIT)) {
+			spin_unlock(&br->last_arp_lock);
+			return;
+		}
+
+		br->last_arp_send = jiffies;
+		spin_unlock(&br->last_arp_lock);
+
+		fbxbr_send_arp_frame(dev,
+				     ARPOP_REQUEST,
+				     NULL,
+				     br->lan_gw,
+				     NULL,
+				     br->wan_ipaddr,
+				     NULL);
+		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 = dev;
+
+	if (br->have_hw_addr && iph->daddr != INADDR_BROADCAST)
+		dest_hw = br->lan_hwaddr;
+	else
+		dest_hw = dev->broadcast;
+
+	dev_hard_header(skb, dev, ETH_P_802_3, dest_hw, dev->dev_addr,
+			ETH_P_IP);
+	dev_queue_xmit(skb);
+}
+
+/*
+ * caller must hold bridge lock and have BH disabled
+ *
+ * wan port must be valid
+ *
+ * must be a valid ip packet
+ */
+void fbxbr_output_wan_frame(struct fbxbr *br, struct sk_buff *skb)
+{
+	struct fbxbr_port *p = br->wan_port;
+	struct net_device *dev = p->dev;
+	struct iphdr *iph;
+	struct neighbour *neigh;
+	__be32 nh;
+
+	skb->dev = dev;
+
+	if (!dev->hard_header_len) {
+		dev_queue_xmit(skb);
+		return;
+	}
+
+	iph = ip_hdr(skb);
+
+	/* resolve next hop */
+	nh = iph->daddr;
+	if ((nh & br->wan_netmask) != (br->wan_ipaddr & br->wan_netmask)) {
+		struct rtable *rt;
+
+		rt = p->rt;
+		if (rt && rt->dst.obsolete > 0) {
+			ip_rt_put(rt);
+			p->rt = NULL;
+			rt = NULL;
+		}
+
+		/* need to find default gateway */
+		if (!rt) {
+			rt = ip_route_output(&init_net, nh, 0, 0,
+					     dev->ifindex);
+			if (IS_ERR(rt) || rt->rt_type != RTN_UNICAST) {
+				kfree_skb(skb);
+				return;
+			}
+
+			p->rt = rt;
+		}
+
+		nh = rt_nexthop(rt, nh);
+	}
+
+	/* resolve neighbour */
+	neigh = __ipv4_neigh_lookup_noref(dev, nh);
+        if (unlikely(!neigh))
+                neigh = __neigh_create(&arp_tbl, &nh, dev, false);
+
+	if (IS_ERR(neigh)) {
+		kfree_skb(skb);
+		return;
+	}
+
+	if (!(neigh->nud_state & NUD_VALID)) {
+		neigh_event_send(neigh, NULL);
+		kfree_skb(skb);
+		return;
+	}
+
+	neigh_event_send(neigh, NULL);
+
+	/* send */
+	dev_hard_header(skb, dev, ETH_P_802_3, neigh->ha, dev->dev_addr,
+			ETH_P_IP);
+	dev_queue_xmit(skb);
+}
diff -Nruw linux-5.4.60-fbx/net/fbxbridge./fbxbr_private.h linux-5.4.60-fbx/net/fbxbridge/fbxbr_private.h
--- linux-5.4.60-fbx/net/fbxbridge./fbxbr_private.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxbridge/fbxbr_private.h	2021-03-04 13:21:01.414172385 +0100
@@ -0,0 +1,197 @@
+#ifndef FBXBRIDGE_PRIVATE_H_
+#define FBXBRIDGE_PRIVATE_H_
+
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/fbxbridge.h>
+#include <linux/rtnetlink.h>
+#include <linux/spinlock.h>
+
+#define ARP_RATE_LIMIT			(HZ)
+#define ARP_ETHER_SIZE			(8 + ETH_ALEN * 2 + 4 * 2)
+#define	DEFAULT_RENEWAL_TIME		60
+#define	DEFAULT_REBIND_TIME		300
+#define	DEFAULT_LEASE_TIME		600
+
+#define FBXBR_FWCACHE_SIZE		256
+#define FBXBR_FWCACHE_MAX_ENTRY		2048
+
+struct fbxbr;
+
+struct fbxbr_fwcache_key {
+	__be32			lan_ip;
+	__be32			wan_ip;
+	__be16			lan_port;
+	__be16			wan_port;
+	bool			is_tcp;
+};
+
+struct fbxbr_fwcache {
+	__be32			lan_ip;
+	__be32			wan_ip;
+	__be16			lan_port;
+	__be16			wan_port;
+	u8			is_tcp;
+	struct hlist_node       hnext;
+	struct list_head        next;
+
+	void			(*priv_destructor)(void *);
+	u32			priv_area[8];
+};
+
+struct fbxbr_port {
+	struct fbxbr		*br;
+	struct net_device	*dev;
+	struct rtable		*rt;
+	bool			is_wan;
+};
+
+struct fbxbr {
+	struct net_device	*dev;
+
+	/* protect all fields but lan_hwaddr */
+	rwlock_t		lock;
+
+	/*
+	 * currently assigned lan & wan port, updated by userspace
+	 * under rtnl
+	 */
+	struct fbxbr_port	*wan_port;
+	struct fbxbr_port	*lan_port;
+
+	/*
+	 * config, updated by userspace
+	 */
+	unsigned int		flags;
+	unsigned int		inputmark;
+
+	unsigned int		dns1_ipaddr;
+	unsigned int		dns2_ipaddr;
+
+	unsigned long		dhcpd_renew_time;
+	unsigned long		dhcpd_rebind_time;
+	unsigned long		dhcpd_lease_time;
+
+	/* list of ip we consider to be local */
+	unsigned long		ip_aliases[MAX_ALIASES];
+
+	/*
+	 * runtime state
+	 */
+
+	/* local and remote (fbx) ip address, maintained using inet
+	 * notifier */
+	__be32			br_ipaddr;
+	__be32			br_remote_ipaddr;
+
+	/* wan side inet info */
+	__be32			wan_ipaddr;
+	__be32			wan_netmask;
+	__be32			lan_gw;
+	__be32			lan_netmask;
+
+	/* currently detected lan device hardware address */
+	rwlock_t		lan_hwaddr_lock;
+	bool			have_hw_addr;
+	unsigned char		lan_hwaddr[ETH_ALEN];
+
+	spinlock_t		last_arp_lock;
+	unsigned long		last_arp_send;
+
+	rwlock_t		fwcache_lock;
+        struct hlist_head       fwcache_hrules[FBXBR_FWCACHE_SIZE];
+        struct list_head        fwcache_rules;
+        unsigned int            fwcache_count;
+
+	struct list_head	next;
+};
+
+/*
+ * helpers to get bridge port from netdevice
+ */
+#define fbxbr_port_exists(dev) (dev->priv_flags & IFF_FBXBRIDGE_PORT)
+
+static inline struct fbxbr_port *
+fbxbr_port_get_rcu(const struct net_device *dev)
+{
+	return rcu_dereference(dev->rx_handler_data);
+}
+
+static inline struct fbxbr_port *
+fbxbr_port_get_rtnl(const struct net_device *dev)
+{
+	return fbxbr_port_exists(dev) ?
+		rtnl_dereference(dev->rx_handler_data) : NULL;
+}
+
+/* fbxbr_dev.c */
+int fbxbr_add_br(struct net *net, const char *name);
+
+int __fbxbr_del_br(struct net *net, const char *name);
+
+int __fbxbr_add_br_port(struct net *net, const char *name,
+			const char *port_name, bool is_wan);
+
+int __fbxbr_del_br_port_by_name(struct net *net, const char *name,
+				const char *port_name);
+
+void __fbxbr_del_br_port(struct fbxbr_port *p);
+
+int fbxbr_get_params(struct net *net, const char *name,
+		     struct fbxbridge_ioctl_params *params);
+
+int fbxbr_set_params(struct net *net, const char *name,
+		     const struct fbxbridge_ioctl_params *params);
+
+void fbxbr_capture_hw_addr(struct fbxbr *br, const u8 *hwaddr);
+
+
+/* fbxbr_dhcp.c */
+void fbxbr_dhcpd(struct fbxbr *br, struct sk_buff *skb);
+
+/* fbxbr_filter.c */
+int
+fbxbr_filter_wan_to_lan_packet(struct fbxbr *br, struct sk_buff *skb);
+int
+fbxbr_filter_lan_to_wan_packet(struct fbxbr *br, struct sk_buff *skb);
+
+/* fbxbr_fwcache.c */
+u32 fbxbr_fwcache_hash(const struct fbxbr_fwcache_key *k);
+
+struct fbxbr_fwcache *
+__fbxbr_fwcache_lookup(struct fbxbr *br, u32 hash,
+		       const struct fbxbr_fwcache_key *k);
+
+bool fbxbr_fwcache_skb_allowable(struct sk_buff *skb,
+				 bool from_wan,
+				 struct fbxbr_fwcache_key *k,
+				 bool *can_create);
+int fbxbr_fwcache_add(struct fbxbr *br,
+		      u32 hash, const struct fbxbr_fwcache_key *k);
+
+void fbxbr_fwcache_flush(struct fbxbr *br);
+
+/* fbxbr_ioctl.c */
+int fbxbr_ioctl(struct net *net, unsigned int ign, void __user *arg);
+
+/* fbxbr_input.c */
+rx_handler_result_t fbxbr_handle_frame(struct sk_buff **pskb);
+
+/* fbxbr_output.c */
+void fbxbr_output_lan_mcast_frame(struct fbxbr *br, struct sk_buff *skb);
+void fbxbr_output_lan_frame(struct fbxbr *br, struct sk_buff *skb);
+void fbxbr_output_wan_frame(struct fbxbr *br, struct sk_buff *skb);
+
+/* fbxbr_utils.c */
+int fbxbr_send_arp_frame(struct net_device *dev, u16 op,
+			 const u8 *dest_hw,
+			 __be32 src_ip, const u8 *src_hw,
+			 __be32 target_ip, const u8 *target_hw);
+
+bool fbxbr_is_valid_ip_packet(struct sk_buff *skb);
+bool fbxbr_is_valid_udp_tcp_packet(struct sk_buff *skb);
+void fbxbr_snat_packet(struct sk_buff *skb, __be32 new_addr);
+void fbxbr_dnat_packet(struct sk_buff *skb, __be32 new_addr);
+
+
+#endif /* !FBXBRIDGE_PRIVATE_H_ */
diff -Nruw linux-5.4.60-fbx/net/fbxbridge./fbxbr_utils.c linux-5.4.60-fbx/net/fbxbridge/fbxbr_utils.c
--- linux-5.4.60-fbx/net/fbxbridge./fbxbr_utils.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxbridge/fbxbr_utils.c	2021-03-04 13:21:01.414172385 +0100
@@ -0,0 +1,204 @@
+#include <linux/if_arp.h>
+#include <net/ip.h>
+#include "fbxbr_private.h"
+
+/*
+ * allocate & send ARP frame to given device
+ *
+ * src_hw can be NULL, device address is used instead
+ * dest_hw can be NULL, device broadcast address is used instead
+ * target_hw can be NULL, empty address is used instead
+ */
+int fbxbr_send_arp_frame(struct net_device *dev, u16 op,
+			 const u8 *dest_hw,
+			 __be32 src_ip, const u8 *src_hw,
+			 __be32 target_ip, const u8 *target_hw)
+{
+	struct arphdr *arp;
+	struct sk_buff *skb;
+	unsigned char *arp_ptr;
+	int hlen = LL_RESERVED_SPACE(dev);
+	int tlen = dev->needed_tailroom;
+	int ret;
+
+	/* prepare arp packet */
+	skb = alloc_skb(arp_hdr_len(dev) + hlen + tlen, GFP_ATOMIC);
+	if (!skb)
+		return -ENOMEM;
+
+	skb_reserve(skb, hlen);
+	skb_reset_network_header(skb);
+	arp = skb_put(skb, arp_hdr_len(dev));
+	skb->dev = dev;
+	skb->protocol = htons(ETH_P_ARP);
+
+	if (!src_hw)
+		src_hw = dev->dev_addr;
+	if (!dest_hw)
+		dest_hw = dev->broadcast;
+
+	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(op);
+
+	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;
+
+	if (target_hw)
+		memcpy(arp_ptr, target_hw, dev->addr_len);
+	else
+		memset(arp_ptr, 0, dev->addr_len);
+
+	arp_ptr += dev->addr_len;
+	memcpy(arp_ptr, &target_ip, 4);
+
+	ret = dev_hard_header(skb, dev, ETH_P_ARP, dest_hw, src_hw, skb->len);
+	if (ret < 0) {
+		kfree(skb);
+		return ret;
+	}
+
+	return dev_queue_xmit(skb);
+}
+
+/*
+ * validate header fields & checksum, also linearize IP header and
+ * setup transport headers
+ */
+bool fbxbr_is_valid_ip_packet(struct sk_buff *skb)
+{
+	const struct iphdr *iph;
+
+	if (!pskb_may_pull(skb, sizeof (*iph)))
+		return false;
+
+	iph = ip_hdr(skb);
+
+	if (iph->ihl < 5 || iph->version != 4)
+		return false;
+
+	if (!pskb_may_pull(skb, iph->ihl * 4))
+		return false;
+
+	iph = ip_hdr(skb);
+
+	if (ntohs(iph->tot_len) > skb->len)
+		return false;
+
+	skb->transport_header = skb->network_header + iph->ihl * 4;
+
+	return true;
+}
+
+/*
+ * make sure the udp/tcp header is present in the linear section
+ */
+bool fbxbr_is_valid_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 false;
+		break;
+	case IPPROTO_TCP:
+		if (!pskb_may_pull(skb, skb_transport_offset(skb) +
+				   sizeof (struct tcphdr)))
+			return false;
+		break;
+	}
+	return true;
+}
+
+
+/*
+ * do source or destination nat
+ */
+static void recalculate_l4_checksum(struct sk_buff *skb,
+				    __be32 osaddr, __be32 odaddr)
+{
+	struct iphdr *iph;
+	u16 check;
+
+	iph = ip_hdr(skb);
+	if (iph->frag_off & htons(IP_OFFSET))
+		return;
+
+	if (!fbxbr_is_valid_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;
+	}
+	}
+}
+
+/*
+ * packet must be valid IPv4 with header in linear section
+ */
+void fbxbr_snat_packet(struct sk_buff *skb, __be32 new_addr)
+{
+	struct iphdr *ip;
+	__be32 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_l4_checksum(skb, oaddr, ip->daddr);
+}
+
+void fbxbr_dnat_packet(struct sk_buff *skb, __be32 new_addr)
+{
+	struct iphdr *ip;
+	__be32 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_l4_checksum(skb, ip->saddr, oaddr);
+}
diff -Nruw linux-5.4.60-fbx/net/fbxbridge./Kconfig linux-5.4.60-fbx/net/fbxbridge/Kconfig
--- linux-5.4.60-fbx/net/fbxbridge./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxbridge/Kconfig	2021-03-04 13:21:01.414172385 +0100
@@ -0,0 +1,8 @@
+
+#
+# Freebox bridge
+#
+config FBXBRIDGE
+	bool "Freebox Bridge"
+	select NETFILTER
+	select NF_CONNTRACK
diff -Nruw linux-5.4.60-fbx/net/fbxbridge./Makefile linux-5.4.60-fbx/net/fbxbridge/Makefile
--- linux-5.4.60-fbx/net/fbxbridge./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/fbxbridge/Makefile	2021-03-04 13:21:01.414172385 +0100
@@ -0,0 +1,12 @@
+
+obj-$(CONFIG_FBXBRIDGE)	+= fbxbridge.o
+
+fbxbridge-objs := 		\
+	fbxbr_dev.o		\
+	fbxbr_dhcp.o		\
+	fbxbr_filter.o		\
+	fbxbr_fwcache.o		\
+	fbxbr_input.o		\
+	fbxbr_ioctl.o		\
+	fbxbr_output.o		\
+	fbxbr_utils.o
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/net/ipv4/ip_ffn.c	2021-03-04 13:21:01.420839051 +0100
@@ -0,0 +1,708 @@
+/*
+ * 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,
+				 struct sk_buff *skb,
+				 unsigned int dataoff,
+				 enum ip_conntrack_info ctinfo);
+
+extern int external_udpv4_packet(struct nf_conn *ct,
+				 struct sk_buff *skb,
+				 unsigned int dataoff,
+				 enum ip_conntrack_info ctinfo);
+
+extern int ip_local_deliver_finish(struct net *net,
+				   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_CONNTRACK_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(skb)) {
+		/*
+		 * skbs to/from localhost will have the conntrack
+		 * already set, don't leak references here.
+		 */
+		nf_conntrack_put(nfct);
+	} else {
+		if (unlikely(skb_nfct(skb) != 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(1,
+				  "weird skb->nfct %p, NULL was expected\n",
+				  skb_nfct(skb));
+			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;
+		}
+		nf_ct_set(skb, (struct nf_conn *)nfct, 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;
+	IPCB(skb)->flags |= IPSKB_FORWARDED;
+
+	if (added_when == IP_FFN_FINISH_OUT)
+		dst_output(&init_net, skb->sk, skb);
+	else
+		ip_local_deliver_finish(&init_net, 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;
+	struct net *skb_net;
+	int dir;
+	u8 proto;
+
+	skb_net = dev_net(skb->dev);
+	if (!unlikely(net_eq(skb_net, &init_net)))
+		return;
+
+	/* make sure external_tcp_packet/external_udp_packet won't
+	 * attempt to checksum packet, the ffn code does not update
+	 * skb->csum, which must stay valid if skb_checksum_complete
+	 * has been called */
+	if (unlikely(skb_net->ct.sysctl_checksum))
+		skb_net->ct.sysctl_checksum = 0;
+
+	if (ffn_entry_count >= MAX_FFN_ENTRY)
+		return;
+
+	iph = ip_hdr(skb);
+
+	if (skb_dst(skb)->output != ip_output && when == IP_FFN_FINISH_OUT)
+		return;
+
+	ct = nf_ct_get(skb, &ctinfo);
+	if (!ct || ctinfo == IP_CT_UNTRACKED)
+		return;
+
+	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	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/net/ipv6/ip6_ffn.c	2021-03-04 13:21:01.437505718 +0100
@@ -0,0 +1,646 @@
+/*
+ * 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,
+				 struct sk_buff *skb,
+				 unsigned int dataoff,
+				 enum ip_conntrack_info ctinfo);
+
+extern int external_udpv6_packet(struct nf_conn *ct,
+				 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));
+
+		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(&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_CONNTRACK_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(skb)) {
+		/*
+		 * skbs to/from localhost will have the conntrack
+		 * already set, don't leak references here.
+		 */
+		nf_conntrack_put(nfct);
+	} else {
+		if (unlikely(skb_nfct(skb) != 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(1,
+				  "weird skb->nfct %p, NULL was expected\n",
+				  skb_nfct(skb));
+			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;
+		}
+		nf_ct_set(skb, (struct nf_conn *)nfct, 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(&init_net, skb->sk, skb);
+	else
+		ip6_input_finish(&init_net, 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;
+	struct net *skb_net;
+	u8 proto, tos;
+
+	skb_net = dev_net(skb->dev);
+	if (!unlikely(net_eq(skb_net, &init_net)))
+		return;
+
+	/* make sure external_tcp_packet/external_udp_packet won't
+	 * attempt to checksum packet, the ffn code does not update
+	 * skb->csum, which must stay valid if skb_checksum_complete
+	 * has been called */
+	if (unlikely(skb_net->ct.sysctl_checksum))
+		skb_net->ct.sysctl_checksum = 0;
+
+	if (ffn6_entry_count >= MAX_FFN6_ENTRY)
+		return;
+
+	iph = ipv6_hdr(skb);
+
+	if ((when == IPV6_FFN_FINISH_OUT &&
+	     skb_dst(skb)->output != ip6_output))
+		return;
+
+	ct = nf_ct_get(skb, &ctinfo);
+	if (!ct || ctinfo == IP_CT_UNTRACKED)
+		return;
+
+	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
+}
diff -Nruw linux-5.4.60-fbx/net/nmesh-mbh./Kconfig linux-5.4.60-fbx/net/nmesh-mbh/Kconfig
--- linux-5.4.60-fbx/net/nmesh-mbh./Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/nmesh-mbh/Kconfig	2021-03-04 13:21:01.484172387 +0100
@@ -0,0 +1,4 @@
+config NET_NMESH_MBH
+        tristate "nmesh multi backhaul ethernet support"
+        help
+          This is part of qubercomm's magic to support ethernet as a backhaul
diff -Nruw linux-5.4.60-fbx/net/nmesh-mbh./Makefile linux-5.4.60-fbx/net/nmesh-mbh/Makefile
--- linux-5.4.60-fbx/net/nmesh-mbh./Makefile	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/nmesh-mbh/Makefile	2021-03-04 13:21:01.484172387 +0100
@@ -0,0 +1 @@
+obj-$(CONFIG_NET_NMESH_MBH)	   += nmesh-mbh.o
diff -Nruw linux-5.4.60-fbx/net/nmesh-mbh./nmesh-mbh.c linux-5.4.60-fbx/net/nmesh-mbh/nmesh-mbh.c
--- linux-5.4.60-fbx/net/nmesh-mbh./nmesh-mbh.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/nmesh-mbh/nmesh-mbh.c	2021-03-04 13:21:01.484172387 +0100
@@ -0,0 +1,794 @@
+/*
+ * Copyright (c) 2019 Qubercomm Technologies, Inc.
+ */
+
+#include <linux/icmpv6.h>
+#include <net/addrconf.h>
+#include <net/ip6_checksum.h>
+#include "nmesh-mbh.h"
+
+#define ICMPV6_NMESH_MBH		254
+
+static struct nmesh_mbh mbh;
+static const u8 _mbh_icmp6_mc_ebeacon_addr[] = {
+	0x33, 0x33, 0x00, 0x00, 0x00, 0x01,
+};
+static const u8 _mbh_eth_mc_ebeacon_addr[] = {
+	0x01, 0x80, 0xC2, 0xFF, 0xFF, 0xFE,
+};
+
+static struct mbh_iface *mbh_iface_find_by_name(char *name)
+{
+	struct mbh_iface *iface;
+
+	lockdep_assert_held(&mbh.iface_lock);
+
+	list_for_each_entry(iface, &mbh.ifaces, list) {
+		if (!strcmp(iface->name, name))
+			return iface;
+	}
+	return NULL;
+}
+
+static struct mbh_iface *mbh_iface_find_by_mac(unsigned char *mac)
+{
+	struct mbh_iface *iface;
+
+	lockdep_assert_held(&mbh.iface_lock);
+
+	list_for_each_entry(iface, &mbh.ifaces, list) {
+		if (ether_addr_equal(iface->mac, mac))
+			return iface;
+	}
+	return NULL;
+}
+
+static struct mbh_remote_peer *mbh_remote_peer_find_by_mac(struct mbh_iface *iface,
+							   unsigned char *mac)
+{
+	struct mbh_remote_peer *remote_peer;
+
+	lockdep_assert_held(&mbh.iface_lock);
+
+	list_for_each_entry(remote_peer, &iface->remote_peers_list, list) {
+		if (ether_addr_equal(remote_peer->mac, mac))
+			return remote_peer;
+	}
+	return NULL;
+}
+
+static char mbh_is_nmeshd_alive(void)
+{
+	struct task_struct *task;
+	struct pid *pid;
+
+	rcu_read_lock();
+
+	pid = find_pid_ns(mbh.nmeshd_pid, &init_pid_ns);
+	if (unlikely(!pid)) {
+		rcu_read_unlock();
+		return 0;
+	}
+
+	task = pid_task(pid, PIDTYPE_PID);
+
+	rcu_read_unlock();
+
+	if(unlikely(!task))
+		return 0;
+
+	return 1;
+}
+
+static inline void mbh_stop_hb_timer(void)
+{
+	if (!test_bit(MBH_HB_SCHEDULED, &mbh.flags))
+		return;
+
+	del_timer(&mbh.hb_timer);
+	clear_bit(MBH_HB_SCHEDULED, &mbh.flags);
+}
+
+/* It's not possible to cancel a timer (heart beat timer)
+ * within the same timer context. This tasklet helps in
+ * such a situation. */
+void mbh_cancel_hb_timer_tasklet(unsigned long data)
+{
+	mbh_stop_hb_timer();
+}
+
+static void mbh_iface_cleanup(void)
+{
+	struct mbh_iface *iface, *tmp;
+	struct mbh_remote_peer *remote_peer, *rtmp;
+
+	spin_lock_bh(&mbh.iface_lock);
+	list_for_each_entry_safe(iface, tmp, &mbh.ifaces, list) {
+		if (iface->hb_payload)
+			kfree(iface->hb_payload);
+
+		list_for_each_entry_safe(remote_peer, rtmp,
+					 &iface->remote_peers_list, list) {
+			list_del(&remote_peer->list);
+			kfree(remote_peer);
+		}
+
+		list_del(&iface->list);
+                kfree(iface);
+	}
+	spin_unlock_bh(&mbh.iface_lock);
+}
+
+static void mbh_send_uevent(struct mbh_event_hdr *ehdr_to_send,
+			    char *payload, int payload_size)
+{
+	struct sk_buff  *skb;
+	struct nlmsghdr *nlh;
+	struct mbh_event_hdr *ehdr;
+	int len, ret;
+
+	len = NLMSG_HDRLEN + sizeof(struct mbh_event_hdr) + payload_size;
+
+	skb = nlmsg_new(len, gfp_any());
+	if (!skb)
+		return;
+
+	nlh = nlmsg_put(skb, 0, 0, NLMSG_DONE, len - NLMSG_HDRLEN, 0);
+	if (!nlh) {
+		kfree_skb(skb);
+		return;
+	}
+
+	ehdr = nlmsg_data(nlh);
+	*ehdr = *ehdr_to_send;
+	memcpy(ehdr + 1, payload, payload_size);
+
+	/* send composed event to the user space */
+	ret = netlink_unicast(mbh.nl_soc, skb,
+			      mbh.nmeshd_pid, MSG_DONTWAIT);
+
+	if (ret == -ECONNREFUSED && !mbh_is_nmeshd_alive())
+		mbh_stop_hb_timer();
+}
+
+static int mbh_record_remote_peer_hb_time(struct net_device *dev,
+					   unsigned char *remote_peer_mac)
+{
+	struct mbh_iface *iface;
+	struct mbh_remote_peer *remote_peer;
+	int found = 0;
+
+	if (unlikely(!dev || !remote_peer_mac))
+		return found;
+
+	spin_lock_bh(&mbh.iface_lock);
+	iface = mbh_iface_find_by_name(dev->name);
+	if (!iface)
+		goto unlock;
+
+	found = 1;
+	remote_peer = mbh_remote_peer_find_by_mac(iface, remote_peer_mac);
+	if (unlikely(!remote_peer)) {
+		remote_peer = kzalloc(sizeof(*remote_peer), GFP_ATOMIC);
+		if (!remote_peer)
+			goto unlock;
+
+		ether_addr_copy(remote_peer->mac, remote_peer_mac);
+		list_add(&remote_peer->list, &iface->remote_peers_list);
+	}
+
+	remote_peer->last_hb_rx_time = jiffies;
+unlock:
+	spin_unlock_bh(&mbh.iface_lock);
+	return found;
+}
+
+static bool mbh_check_icmpv6(struct sk_buff *skb)
+{
+	struct ipv6hdr *ip6_hdr;
+	struct icmp6hdr *icmpv6_hdr;
+
+	if (skb->protocol != cpu_to_be16(ETH_P_IPV6))
+		return false;
+
+	/*
+	 * Check that packets has enough data to be icmpv6 eventually in
+	 * separate pages
+	 */
+	if (!pskb_may_pull(skb, sizeof(*ip6_hdr) + sizeof(*icmpv6_hdr)))
+		return false;
+
+	ip6_hdr = ipv6_hdr(skb);
+	if (ip6_hdr->nexthdr != IPPROTO_ICMPV6)
+		return false;
+
+	/* Check for DA ? */
+	skb_pull(skb, sizeof(*ip6_hdr));
+
+	/* Check for icmpv6 header */
+	skb_reset_transport_header(skb);
+	icmpv6_hdr = icmp6_hdr(skb);
+	if (icmpv6_hdr->icmp6_type != ICMPV6_NMESH_MBH)
+		return false;
+
+	skb_pull(skb, sizeof(*icmpv6_hdr));
+	return true;
+}
+
+int mbh_bridge_rx(struct sk_buff *skb)
+{
+	struct sk_buff *clone = skb_clone(skb, GFP_ATOMIC);
+	struct mbh_event_hdr event_hdr;
+	struct mbh_iface *iface;
+	struct mbh_hdr *mbh_hdr;
+	int ret = 0, found;
+
+	if (!clone)
+		return 0;
+
+	if ((skb->protocol != cpu_to_be16(ETH_P_NMESH_MBH)) &&
+		!mbh_check_icmpv6(clone)) {
+		goto notmbh;
+	}
+
+	if (!test_bit(MBH_HB_SCHEDULED, &mbh.flags)) {
+		/* heart beat frame tx is already stopped,
+		 * there is no point processing rx pkt */
+		goto drop;
+	}
+
+	if (!pskb_may_pull(clone, sizeof(*mbh_hdr)))
+		goto notmbh;
+
+	mbh_hdr = (struct mbh_hdr *)clone->data;
+	if (mbh_hdr->frame_type == MBH_HEART_BEAT_FRAME) {
+		/* loop back case: drop the heart beat initiated in
+		 * the same system on the another ethernet interface. */
+		spin_lock_bh(&mbh.iface_lock);
+		iface = mbh_iface_find_by_mac(eth_hdr(clone)->h_source);
+		spin_unlock_bh(&mbh.iface_lock);
+		if (iface)
+			goto drop;
+
+		found = mbh_record_remote_peer_hb_time(clone->dev,
+				eth_hdr(clone)->h_source);
+		/*
+		 * Packet was not received in nmeshd managed interface yet, let
+		 * linux stack process it again until it is received on proper
+		 * interface
+		 */
+		if (!found)
+			goto notmbh;
+
+		skb_pull(clone, sizeof(struct mbh_hdr));
+		event_hdr.type = MBH_HB_FRAME;
+		ether_addr_copy(event_hdr.h_source, eth_hdr(clone)->h_source);
+		ether_addr_copy(event_hdr.h_dest, clone->dev->dev_addr);
+
+		/* send heart beat frame to user space */
+		mbh_send_uevent(&event_hdr, clone->data, clone->len);
+	}
+drop:
+	kfree_skb(skb);
+	ret = 1;
+notmbh:
+	kfree_skb(clone);
+	return ret;
+}
+
+static void mbh_cleanup_aged_out_remote_peers(void)
+{
+	struct mbh_remote_peer *remote_peer, *rtmp;
+	struct mbh_iface *iface;
+
+	lockdep_assert_held(&mbh.iface_lock);
+
+	list_for_each_entry(iface, &mbh.ifaces, list) {
+	    list_for_each_entry_safe(remote_peer, rtmp,
+				     &iface->remote_peers_list, list) {
+		if (time_before(jiffies,
+				remote_peer->last_hb_rx_time +
+				msecs_to_jiffies(MBH_REMOTE_PEER_AGE_TIMEOUT)))
+			continue;
+
+		/* remote peer aged out */
+		list_del(&remote_peer->list);
+		kfree(remote_peer);
+	     }
+	}
+}
+
+static void mbh_send_icmp6_heart_beat_mc(struct mbh_iface *iface,
+					 struct net_device *dev)
+{
+	struct in6_addr saddr, daddr;
+	struct icmp6hdr *icmpv6_hdr;
+	struct mbh_hdr *mbh_hdr;
+	struct ipv6hdr *ip6_hdr;
+	struct ethhdr *eth_hdr;
+	struct sk_buff *skb;
+	size_t totlen;
+
+	/* Set fake SA and DA to ff02::1 */
+	ipv6_addr_set(&saddr, htonl(0xfe800000), 0, 0, htonl(0xfffe));
+	ipv6_addr_set(&daddr, htonl(0xff020000), 0, 0, htonl(1));
+
+
+	totlen = ETH_HLEN + sizeof(*ip6_hdr) + sizeof(*icmpv6_hdr) +
+		sizeof(*mbh_hdr) + iface->hb_payload_len;
+	skb = dev_alloc_skb(totlen + NET_IP_ALIGN);
+	if (!skb)
+		return;
+
+	/* Reserve space up to transport header (included) */
+	skb_reserve(skb, NET_IP_ALIGN + ETH_HLEN + sizeof(*ip6_hdr) +
+			sizeof(*icmpv6_hdr));
+
+	/* pack mbh hdr */
+	mbh_hdr = skb_put(skb, sizeof(*mbh_hdr));
+	mbh_hdr->frame_type = MBH_HEART_BEAT_FRAME;
+	/* copy user configured payload */
+	memcpy(skb_put(skb, iface->hb_payload_len),
+		       iface->hb_payload, iface->hb_payload_len);
+
+
+	/* prepare ICMPv6 Header */
+	icmpv6_hdr = skb_push(skb, sizeof(*icmpv6_hdr));
+	skb_reset_transport_header(skb);
+	*icmpv6_hdr = (struct icmp6hdr) {
+		.icmp6_type = ICMPV6_NMESH_MBH,
+	};
+	icmpv6_hdr->icmp6_cksum = csum_ipv6_magic(&saddr, &daddr, skb->len,
+						 IPPROTO_ICMPV6,
+						 csum_partial(icmpv6_hdr,
+							      skb->len, 0));
+
+	/* prepare IPv6 header */
+	ip6_hdr = skb_push(skb, sizeof(*ip6_hdr));
+	skb_reset_network_header(skb);
+	ip6_flow_hdr(ip6_hdr, 0, 0);
+	ip6_hdr->payload_len = htons(skb->len - sizeof(*ip6_hdr));
+	ip6_hdr->nexthdr = IPPROTO_ICMPV6;
+	ip6_hdr->hop_limit = 255; /* Maybe set maxhop to 1 ? */
+	ip6_hdr->saddr = saddr;
+	ip6_hdr->daddr = daddr;
+
+	/* prepare 802.3 header */
+	eth_hdr = skb_push(skb, ETH_HLEN);
+	skb_reset_mac_header(skb);
+	ether_addr_copy(eth_hdr->h_dest, _mbh_icmp6_mc_ebeacon_addr);
+	ether_addr_copy(eth_hdr->h_source, dev->dev_addr);
+	eth_hdr->h_proto = htons(ETH_P_IPV6);
+
+	skb->dev = dev;
+	skb->protocol = htons(ETH_P_IPV6);
+	skb->priority = TC_PRIO_CONTROL;
+
+	/* note: ethernet driver may add pad bytes (with zero) before tx */
+	dev_queue_xmit(skb);
+}
+
+static void mbh_send_eth_heart_beat_mc(struct mbh_iface *iface,
+				       struct net_device *dev)
+{
+	struct mbh_hdr *mbh_hdr;
+	struct ethhdr *eth_hdr;
+	struct sk_buff *skb;
+
+	skb = dev_alloc_skb(ETH_HLEN + sizeof(struct mbh_hdr) +
+			    iface->hb_payload_len + NET_IP_ALIGN);
+	if (!skb)
+		return;
+
+	skb_reserve(skb, NET_IP_ALIGN);
+
+	/* prepare .3 header */
+	eth_hdr = (struct ethhdr *) skb_put(skb, ETH_HLEN);
+	skb_reset_mac_header(skb);
+	ether_addr_copy(eth_hdr->h_source, dev->dev_addr);
+	ether_addr_copy(eth_hdr->h_dest, _mbh_eth_mc_ebeacon_addr);
+	eth_hdr->h_proto = htons(ETH_P_NMESH_MBH);
+
+	/* pack mbh hdr */
+	mbh_hdr = (struct mbh_hdr *)skb_put(skb, sizeof(struct mbh_hdr));
+	mbh_hdr->frame_type = MBH_HEART_BEAT_FRAME;
+
+	/* copy user configured payload */
+	memcpy(skb_put(skb, iface->hb_payload_len),
+		       iface->hb_payload, iface->hb_payload_len);
+	skb_reset_network_header(skb);
+
+	skb->dev = dev;
+	skb->protocol = htons(ETH_P_NMESH_MBH);
+	skb->priority = TC_PRIO_CONTROL;
+
+	dev_queue_xmit(skb);
+}
+
+static void mbh_send_heart_beat_mc(struct mbh_iface *iface,
+				   struct net_device *dev)
+{
+	mbh_send_eth_heart_beat_mc(iface, dev);
+	mbh_send_icmp6_heart_beat_mc(iface, dev);
+	iface->bcast_hb_last_tx_time = jiffies;
+}
+
+static void mbh_send_heart_beat_uc(struct mbh_iface *iface,
+				   struct net_device *dev)
+{
+	struct mbh_remote_peer *remote_peer;
+	struct sk_buff *skb, *skb_to_send;
+	struct mbh_hdr *mbh_hdr;
+	struct ethhdr *eth_hdr;
+
+	skb = dev_alloc_skb(ETH_HLEN + sizeof(struct mbh_hdr) +
+			    iface->hb_payload_len + NET_IP_ALIGN);
+	if (!skb)
+		return;
+
+	skb_reserve(skb, NET_IP_ALIGN);
+
+	/* prepare .3 header */
+	eth_hdr = (struct ethhdr *) skb_put(skb, ETH_HLEN);
+	skb_reset_mac_header(skb);
+	ether_addr_copy(eth_hdr->h_source, dev->dev_addr);
+	eth_hdr->h_proto = htons(ETH_P_NMESH_MBH);
+
+	/* pack mbh hdr */
+	mbh_hdr = (struct mbh_hdr *)skb_put(skb, sizeof(struct mbh_hdr));
+	mbh_hdr->frame_type = MBH_HEART_BEAT_FRAME;
+
+	/* copy user configured payload */
+	memcpy(skb_put(skb, iface->hb_payload_len),
+		       iface->hb_payload, iface->hb_payload_len);
+	skb_reset_network_header(skb);
+
+	skb->dev = dev;
+	skb->protocol = htons(ETH_P_NMESH_MBH);
+	skb->priority = TC_PRIO_CONTROL;
+
+	/* send unicast heart beat frame for every remote peer */
+	list_for_each_entry(remote_peer, &iface->remote_peers_list, list) {
+		if (list_is_last(&remote_peer->list, &iface->remote_peers_list)) {
+			skb_to_send = skb;
+		} else {
+			skb_to_send = skb_copy(skb, GFP_ATOMIC);
+			if (!skb_to_send)
+				skb_to_send = skb;
+		}
+
+		/* pack remote peer address in destination field */
+		eth_hdr = (struct ethhdr *) skb_mac_header(skb_to_send);
+		ether_addr_copy(eth_hdr->h_dest, remote_peer->mac);
+
+		dev_queue_xmit(skb_to_send);
+
+		if (skb == skb_to_send)
+			break;
+	}
+}
+
+static void mbh_send_heart_beat_frame(struct net_device *dev)
+{
+	struct mbh_iface *iface;
+
+	/* nmeshd alive check for the every heart beat timer expiry seems to
+	 * be overkill. hence, do this only after the certain hb interval. */
+	if (++mbh.nmeshd_alive_check_count >= MBH_HB_EXPIRE_FOR_NMESHD_ALIVE_CHECK) {
+		if (mbh_is_nmeshd_alive()) {
+			mbh.nmeshd_alive_check_count = 0;
+		} else {
+			/* nmeshd is dead, stop further heart beat tx */
+			tasklet_schedule(&mbh.cancel_hb_timer_tasklet);
+			return;
+		}
+	}
+
+	spin_lock_bh(&mbh.iface_lock);
+
+	mbh_cleanup_aged_out_remote_peers();
+
+	iface = mbh_iface_find_by_name(dev->name);
+	if (!iface || !iface->hb_payload)
+		goto unlock;
+
+	if (iface->initial_bcast_hb_tx_count < MBH_INITIAL_BCAST_HB_TX_COUNT_MAX) {
+		iface->initial_bcast_hb_tx_count++;
+		mbh_send_heart_beat_mc(iface, dev);
+	} else if (time_after(jiffies,
+			iface->bcast_hb_last_tx_time +
+			msecs_to_jiffies(MBH_PERIODIC_BCAST_HB_INTERVAL))) {
+		mbh_send_heart_beat_mc(iface, dev);
+	} else if (!list_empty(&iface->remote_peers_list)) {
+		mbh_send_heart_beat_uc(iface, dev);
+	}
+
+unlock:
+	spin_unlock_bh(&mbh.iface_lock);
+}
+
+static void mbh_heart_beat_timer(struct timer_list *t)
+{
+	struct net_device *dev;
+	struct net_bridge *br;
+	struct net_bridge_port *p;
+
+	dev = dev_get_by_name(&init_net, mbh.br_name);
+	if (!dev)
+		goto reshedule;
+
+	br = netdev_priv(dev);
+
+	/* send heart beat frame on each non wireless interfaces
+	 * linked to the bridge */
+	list_for_each_entry(p, &br->port_list, list) {
+		if (p->state == BR_STATE_DISABLED ||
+		    !p->dev || !(p->dev->flags & IFF_UP))
+			continue;
+
+		/* skip wireless interface */
+		if (p->dev->ieee80211_ptr)
+			continue;
+
+		mbh_send_heart_beat_frame(p->dev);
+	}
+	dev_put(dev);
+
+reshedule:
+	mod_timer(&mbh.hb_timer,
+		  jiffies + msecs_to_jiffies(mbh.hb_timer_interval));
+}
+
+static void mbh_set_hb_payload_cmd(struct mbh_set_hb_payload_cmd *msg)
+{
+	struct mbh_iface *iface;
+	struct net_device *dev;
+
+	if (msg->payload_len > MBH_HB_MAX_PAYLOAD) {
+		printk(KERN_ERR "mbh: hb payload len exceeding max limit (max:%d, received:%d)\n",
+		       MBH_HB_MAX_PAYLOAD, msg->payload_len);
+		return;
+	}
+
+	dev = dev_get_by_name(&init_net, msg->iface_name);
+	if (!dev) {
+		printk(KERN_ERR "mbh: device %s is not present in the system\n",
+		       msg->iface_name);
+		return;
+	}
+
+	spin_lock_bh(&mbh.iface_lock);
+
+	iface = mbh_iface_find_by_name(msg->iface_name);
+	if (!iface) {
+		iface = kzalloc(sizeof(*iface), GFP_ATOMIC);
+		if (!iface) {
+			spin_unlock_bh(&mbh.iface_lock);
+			dev_put(dev);
+			return;
+		}
+
+		snprintf(iface->name, sizeof(iface->name), msg->iface_name);
+		ether_addr_copy(iface->mac, dev->dev_addr);
+		INIT_LIST_HEAD(&iface->remote_peers_list);
+		list_add(&iface->list, &mbh.ifaces);
+	}
+
+	dev_put(dev);
+
+	if (iface->hb_payload)
+		kfree(iface->hb_payload);
+
+	if (msg->payload_len) {
+		iface->hb_payload = kmalloc(msg->payload_len, GFP_ATOMIC);
+		if (iface->hb_payload) {
+			memcpy(iface->hb_payload, &msg->payload,
+			       msg->payload_len);
+			iface->hb_payload_len = msg->payload_len;
+		}
+	} else {
+		iface->hb_payload = NULL;
+	}
+
+	spin_unlock_bh(&mbh.iface_lock);
+}
+
+static void mbh_start_cmd(u32 pid, struct mbh_start_cmd *msg)
+{
+	struct mbh_iface *iface;
+
+	mbh_stop_hb_timer();
+
+	mbh.nmeshd_pid = pid;
+
+	if (msg->hb_timer_interval)
+		mbh.hb_timer_interval = msg->hb_timer_interval;
+	else
+		mbh.hb_timer_interval = MBH_HB_TIMER_DEFAULT_INTERVAL;
+
+	memcpy(&mbh.br_name, &msg->br_name, IFNAMSIZ);
+
+	/* reset initial bcast hb counter to force each interface
+	 * to start with broadcast heart beat frame. */
+	spin_lock_bh(&mbh.iface_lock);
+	list_for_each_entry(iface, &mbh.ifaces, list)
+		iface->initial_bcast_hb_tx_count = 0;
+	spin_unlock_bh(&mbh.iface_lock);
+
+	RCU_INIT_POINTER(nmesh_mbh_bridge_rx, mbh_bridge_rx);
+
+	set_bit(MBH_HB_SCHEDULED, &mbh.flags);
+	mod_timer(&mbh.hb_timer,
+		  jiffies + msecs_to_jiffies(mbh.hb_timer_interval));
+}
+
+static void mbh_stop_cmd(void)
+{
+	mbh_stop_hb_timer();
+	RCU_INIT_POINTER(nmesh_mbh_bridge_rx, NULL);
+	rcu_barrier();
+}
+
+static void mbh_nl_soc_recv(struct sk_buff *skb)
+{
+	struct nlmsghdr *nlh;
+	struct mbh_cmd_hdr *hdr;
+	void *msg;
+
+	nlh = nlmsg_hdr(skb);
+	hdr = nlmsg_data(nlh);
+	msg = hdr + 1;
+
+	if (hdr->magic != MBH_HDR_MAGIC)
+		return;
+
+	switch (hdr->cmd) {
+	case MBH_SET_HB_PAYLOAD_CMD:
+		mbh_set_hb_payload_cmd(msg);
+		break;
+	case MBH_START_CMD:
+		mbh_start_cmd(nlh->nlmsg_pid, msg);
+		break;
+	case MBH_STOP_CMD:
+		mbh_stop_cmd();
+		break;
+	default:
+		break;
+	}
+}
+
+static ssize_t mbh_debugfs_read_status(struct file *file,
+				       char __user *user_buf,
+				       size_t count, loff_t *ppos)
+{
+	unsigned int len = 0, buf_len = 800, ago;
+	struct mbh_iface *iface;
+	struct mbh_remote_peer *remote_peer;
+	char *buf;
+	int ret_cnt;
+
+	buf = kzalloc(buf_len, GFP_KERNEL);
+        if (!buf)
+                return -ENOMEM;
+
+	len += scnprintf(buf + len, buf_len - len, "heart_beat_timer = %s\n",
+			 test_bit(MBH_HB_SCHEDULED, &mbh.flags) ? "running" : "stopped");
+	if (mbh.hb_timer_interval)
+		len += scnprintf(buf + len, buf_len - len,
+				 "heart_beat_timer_interval = %ld msec\n",
+				 mbh.hb_timer_interval);
+	if (strlen(mbh.br_name))
+		len += scnprintf(buf + len, buf_len - len,
+				 "bridge = %s\n", mbh.br_name);
+
+	spin_lock_bh(&mbh.iface_lock);
+
+	mbh_cleanup_aged_out_remote_peers();
+
+	list_for_each_entry(iface, &mbh.ifaces, list) {
+		len += scnprintf(buf + len, buf_len - len, "%s:\n", iface->name);
+		len += scnprintf(buf + len, buf_len - len,
+				 "  mac = %pM\n", iface->mac);
+		len += scnprintf(buf + len, buf_len - len,
+				 "  heart_beat = %s\n",
+				 test_bit(MBH_HB_SCHEDULED, &mbh.flags) &&
+				 iface->hb_payload ? "active" : "inactive");
+		if (iface->hb_payload) {
+			len += scnprintf(buf + len, buf_len - len,
+					 "  heart_beat_payload_len = %d bytes\n",
+					 iface->hb_payload_len);
+		}
+		len += scnprintf(buf + len, buf_len - len,
+				 "  remote_peers: %s",
+				 list_empty(&iface->remote_peers_list) ? "not found\n" : "\n");
+
+		list_for_each_entry(remote_peer, &iface->remote_peers_list, list) {
+			ago = jiffies_to_msecs(jiffies - remote_peer->last_hb_rx_time);
+			len += scnprintf(buf + len, buf_len - len,
+					 "    mac: %pM, last_seen: %u msec ago\n",
+					 remote_peer->mac, ago);
+		}
+	}
+
+	spin_unlock_bh(&mbh.iface_lock);
+
+	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+
+	kfree(buf);
+	return ret_cnt;
+}
+
+static const struct file_operations fops_debugfs_status = {
+	.read = mbh_debugfs_read_status,
+	.open = simple_open,
+	.owner = THIS_MODULE,
+	.llseek = default_llseek,
+};
+
+static int mbh_debugfs_init(void)
+{
+	struct dentry *entry;
+
+	mbh.debugfs_dir = debugfs_create_dir("nmesh-mbh", NULL);
+	if (IS_ERR_OR_NULL(mbh.debugfs_dir)) {
+		printk(KERN_ERR "mbh: nmesh-mbh debugfs directory creation failed!");
+		return -ENOMEM;
+	}
+
+	entry = debugfs_create_file("status", S_IRUSR, mbh.debugfs_dir, NULL,
+				    &fops_debugfs_status);
+	if (!entry) {
+		printk(KERN_ERR "mbh: status debugfs entry creation failed!");
+		debugfs_remove_recursive(mbh.debugfs_dir);
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
+static int __init mbh_init(void)
+{
+	struct netlink_kernel_cfg cfg = {
+		.input =  mbh_nl_soc_recv,
+	};
+	int ret;
+
+	spin_lock_init(&mbh.iface_lock);
+	INIT_LIST_HEAD(&mbh.ifaces);
+
+	mbh.nl_soc = netlink_kernel_create(&init_net,
+					   NETLINK_NMESH_MBH, &cfg);
+	if (!mbh.nl_soc) {
+		printk(KERN_ERR "mbh: unable to create netlink socket!");
+		return -ENOMEM;
+	}
+
+	timer_setup(&mbh.hb_timer, mbh_heart_beat_timer, 0);
+	tasklet_init(&mbh.cancel_hb_timer_tasklet,
+		     mbh_cancel_hb_timer_tasklet, 0);
+
+	ret = mbh_debugfs_init();
+	if (ret) {
+		netlink_kernel_release(mbh.nl_soc);
+		return ret;
+	}
+
+	return 0;
+}
+
+static void __exit mbh_exit(void)
+{
+	mbh_stop_cmd();
+
+	tasklet_kill(&mbh.cancel_hb_timer_tasklet);
+
+	mbh_stop_hb_timer();
+	mbh_iface_cleanup();
+
+	debugfs_remove_recursive(mbh.debugfs_dir);
+	netlink_kernel_release(mbh.nl_soc);
+}
+
+module_init(mbh_init);
+module_exit(mbh_exit);
+MODULE_LICENSE("GPL");
diff -Nruw linux-5.4.60-fbx/net/nmesh-mbh./nmesh-mbh.h linux-5.4.60-fbx/net/nmesh-mbh/nmesh-mbh.h
--- linux-5.4.60-fbx/net/nmesh-mbh./nmesh-mbh.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.4.60-fbx/net/nmesh-mbh/nmesh-mbh.h	2021-03-04 13:21:01.484172387 +0100
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2019 Qubercomm Technologies, Inc.
+ */
+
+#ifndef MBH_H
+#define MBH_H
+
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/if_bridge.h>
+#include <linux/etherdevice.h>
+#include <net/netlink.h>
+#include <linux/timer.h>
+#include <linux/if.h>
+#include "../bridge/br_private.h"
+#include <linux/sched.h>
+#include <linux/pid.h>
+#include <linux/debugfs.h>
+
+#define NETLINK_NMESH_MBH	31
+
+#define MBH_HB_TIMER_DEFAULT_INTERVAL	1000 	/*  in msec */
+#define MBH_HDR_MAGIC			0xBAFA
+#define MBH_HB_MAX_PAYLOAD		512
+
+#define MBH_INITIAL_BCAST_HB_TX_COUNT_MAX	5
+#define MBH_REMOTE_PEER_AGE_TIMEOUT		10000    /* in msec, 10 sec */
+#define MBH_PERIODIC_BCAST_HB_INTERVAL		300000   /* in msec, 5 min */
+
+/* check nmeshd alive status after every 3 heart beat timer expiry */
+#define MBH_HB_EXPIRE_FOR_NMESHD_ALIVE_CHECK	3
+
+enum mbh_frame_type {
+	MBH_HEART_BEAT_FRAME,
+};
+
+struct mbh_hdr {
+	char frame_type;
+} __packed;
+
+enum mbh_cmd_table {
+	MBH_SET_HB_PAYLOAD_CMD,
+	MBH_START_CMD,
+	MBH_STOP_CMD,
+};
+
+struct mbh_cmd_hdr {
+        unsigned short magic;
+        char cmd;
+};
+
+struct mbh_set_hb_payload_cmd {
+	char iface_name[IFNAMSIZ];
+	unsigned short payload_len;
+	char payload[MBH_HB_MAX_PAYLOAD];
+};
+
+struct mbh_start_cmd {
+	char br_name[IFNAMSIZ];
+	unsigned long hb_timer_interval; /* in msec */
+};
+
+enum mbh_event_type {
+	MBH_HB_FRAME,
+};
+
+struct mbh_event_hdr {
+	unsigned char type; /* Refer enum mbh_event_type  */
+	unsigned char h_source[ETH_ALEN];
+	unsigned char h_dest[ETH_ALEN];
+} __attribute__((packed));
+
+enum mbh_flags {
+	MBH_HB_SCHEDULED,
+};
+
+struct mbh_remote_peer {
+	struct list_head list;
+	unsigned char mac[ETH_ALEN];
+	unsigned long last_hb_rx_time;
+};
+
+struct mbh_iface {
+	struct list_head list;
+	struct list_head remote_peers_list; /* struct mbh_remote_peer */
+	char name[IFNAMSIZ];
+	unsigned char mac[ETH_ALEN];
+	char *hb_payload;
+	unsigned short hb_payload_len;
+	unsigned char initial_bcast_hb_tx_count;
+	unsigned long bcast_hb_last_tx_time;
+};
+
+struct nmesh_mbh {
+	struct sock *nl_soc;
+	u32 nmeshd_pid;
+	char br_name[IFNAMSIZ];
+
+	struct timer_list hb_timer;
+	unsigned long hb_timer_interval;
+	unsigned long flags; /* Refer: enum mbh_flags */
+
+	spinlock_t iface_lock;
+	struct list_head ifaces;
+
+	unsigned char nmeshd_alive_check_count;
+	struct tasklet_struct cancel_hb_timer_tasklet;
+
+	struct dentry *debugfs_dir;
+};
+
+extern int (*nmesh_mbh_bridge_rx)(struct sk_buff *skb);
+
+#endif /* MBH_H */
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/scripts/dtc/include-prefixes/arm/fbxgw1r.dts	2021-03-04 13:20:56.817505512 +0100
@@ -0,0 +1,360 @@
+/dts-v1/;
+
+#include <dt-bindings/input/linux-event-codes.h>
+
+#include "kirkwood.dtsi"
+#include "kirkwood-6281.dtsi"
+#include "fbxgw.dtsi"
+
+/ {
+	model = "Freebox Gateway V1";
+	compatible = "freebox,fbxgw1r", "arm-machtype,527";
+
+	chosen {
+		stdout-path = &uart1;
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x20000000>; /* 512 MB */
+	};
+
+	reserved-memory {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		ramoops@1fff8000 {
+			compatible = "ramoops";
+			/* RAM top - 32k, just below bootloader page table */
+			reg = <0x1fff8000 (16 * 1024)>;
+			record-size = <(16 * 1024)>;
+			ecc-size = <16>;
+			no-dump-oops;
+		};
+        };
+
+	gpio_sr: gpio-sr@0 {
+		compatible = "freebox,fbxgw1r-gpio-sr";
+		#gpio-cells = <2>;
+		gpio-controller;
+		ngpios = <8>;
+
+		gpio-line-names = "sfp-pwren", /* 0 */
+				"usb-rst", /* 1 */
+				"audio-rst", /* 2 */
+				"exp-pwren", /* 3 */
+				"bcm-rst", /* 4 */
+				"pcie-rst", /* 5 */
+				"keypad-oled-rst", /* 6 */
+				"oled-vcc"; /* 7 */
+
+		/* presumed bootloader state */
+		sr,init-value = <((1 << 1) | (1 << 6) | (1 << 7))>;
+		sr,gpio-din = <&gpio0 12 0>;
+		sr,gpio-load = <&gpio0 17 0>;
+		sr,gpio-clk = <&gpio0 10 0>;
+	};
+
+	fbxgw1r_rst: fbxgw1r-rst@0 {
+		compatible = "freebox,fbxgw1r-rst";
+		#reset-cells = <1>;
+
+		usb-gpio = <&gpio_sr 1 GPIO_ACTIVE_LOW>;
+		audio-gpio = <&gpio_sr 2 GPIO_ACTIVE_LOW>;
+		keypad-oled-gpio = <&gpio_sr 6 GPIO_ACTIVE_LOW>;
+	};
+
+	fbxgpio@0 {
+		compatible = "fbx,fbxgpio";
+
+		/* claimed for userspace */
+		pos-sense {
+			name = "pos-sense";
+			gpio = <&gpio1 13 0>;
+			input;
+		};
+
+		board-id-0 {
+			name = "board-id-0";
+			gpio = <&gpio1 11 0>;
+			input;
+		};
+
+		board-id-1 {
+			name = "board-id-1";
+			gpio = <&gpio1 17 0>;
+			input;
+		};
+
+		test-mode {
+			name = "test-mode";
+			gpio = <&gpio0 13 0>;
+			input;
+		};
+
+		sw-reset {
+			name = "sw-reset";
+			gpio = <&gpio0 28 0>;
+			output-high;
+			no-claim;
+		};
+
+		sw-int {
+			name = "sw-int";
+			gpio = <&gpio0 29 0>;
+			input;
+		};
+
+		sfp-txdis {
+			name = "sfp-txdis";
+			gpio = <&gpio0 14 0>;
+			output-high;
+		};
+
+		sfp-pwrgood {
+			name = "sfp-pwrgood";
+			gpio = <&gpio1 2 0>;
+			input;
+		};
+
+		sfp-txfault {
+			name = "sfp-txfault";
+			gpio = <&gpio1 3 0>;
+			input;
+		};
+
+		sfp-presence {
+			name = "sfp-presence";
+			gpio = <&gpio1 5 0>;
+			input;
+		};
+
+		sfp-rxloss {
+			name = "sfp-rxloss";
+			gpio = <&gpio1 6 0>;
+			input;
+		};
+
+		sfp-pwren {
+			name = "sfp-pwren";
+			gpio = <&gpio_sr 0 0>;
+			output-low;
+		};
+
+		exp-rst {
+			name = "exp-rst";
+			gpio = <&gpio1 12 0>;
+			output-low;
+		};
+
+		exp-pwrgood {
+			name = "exp-pwrgood";
+			gpio = <&gpio1 14 0>;
+			input;
+		};
+
+		exp-presence {
+			name = "exp-presence";
+			gpio = <&gpio1 15 0>;
+			input;
+		};
+
+		exp-pwren {
+			name = "exp-pwren";
+			gpio = <&gpio_sr 3 0>;
+			output-low;
+		};
+
+		bcm-rst {
+			name = "bcm-rst";
+			gpio = <&gpio_sr 4 0>;
+			output-low;
+		};
+
+
+		/* unclaimed, exported for debug only */
+		oled-data-select {
+			name = "oled-data-select";
+			gpio = <&gpio0 7 0>;
+			output-low;
+			no-claim;
+		};
+
+		kp-int {
+			name = "kp-int";
+			gpio = <&gpio1 16 0>;
+			input;
+			no-claim;
+		};
+
+		usb-rst {
+			name = "usb-rst";
+			gpio = <&gpio_sr 1 0>;
+			output-low;
+			no-claim;
+		};
+
+		audio-rst {
+			name = "audio-rst";
+			gpio = <&gpio_sr 2 0>;
+			output-low;
+			no-claim;
+		};
+
+		pcie-rst {
+			name = "pcie-rst";
+			gpio = <&gpio_sr 5 0>;
+			output-low;
+			no-claim;
+		};
+
+		keypad-oled-rst {
+			name = "keypad-oled-rst";
+			gpio = <&gpio_sr 6 0>;
+			output-low;
+			no-claim;
+		};
+
+		oled-vcc {
+			name = "oled-vcc";
+			gpio = <&gpio_sr 7 0>;
+			output-low;
+			no-claim;
+		};
+	};
+};
+
+&gpio0 {
+	gpio-line-names = "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "oled-data-select", /* 7 */
+			  "",
+			  "",
+			  "sr-clk", /* 10 */
+			  "bcm-down", /* 11 */
+			  "sr-din", /* 12 */
+			  "test-mode", /* 13 */
+			  "sfp-txdis", /* 14 */
+			  "",
+			  "",
+			  "sr-load", /* 17 */
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "",
+			  "sw-reset", /* 28 */
+			  "sw-int", /* 29 */
+			  "",
+			  "";
+};
+
+&gpio1 {
+	gpio-line-names = "",
+			  "",
+			  "sfp-pwrgood", /* 2 */
+			  "sfp-txfault", /* 3 */
+			  "spi-cs-bcm", /* 4 */
+			  "sfp-presence", /* 5 */
+			  "sfp-rxloss", /* 6*/
+			  "", /* 7 */
+			  "", /* 8 */
+			  "", /* 9 */
+			  "", /* 10 */
+			  "board-id-0", /* 11 */
+			  "exp-rst", /* 12 */
+			  "pos-sense", /* 13 */
+			  "exp-pwrgood", /* 14 */
+			  "exp-presence", /* 15 */
+			  "kp-int", /* 16 */
+			  "board-id-1"; /* 17 */
+};
+
+&usb0 {
+	resets = <&fbxgw1r_rst 0>,
+	       <&fbxgw1r_rst 1>;
+};
+
+&mdio {
+	status = "okay";
+
+	mv6161: mv6161@0 {
+		compatible = "freebox,fbxgw-mv6161";
+		reg = <0>;
+		gpio-reset = <&gpio0 28 0>;
+	};
+};
+
+&eth0 {
+	status = "okay";
+};
+
+&eth0port {
+	fbxserial-mac-address = <0>;
+	speed = <1000>;
+	duplex = <1>;
+};
+
+&i2c0 {
+        cap1066@28 {
+		resets = <&fbxgw1r_rst 2>;
+		irq-gpio = <&gpio1 16 0>;
+	};
+};
+
+&tdm_spi0 {
+	pinctrl-0 = <&pmx_alt_tdm_spi>;
+	cs-gpios = <0>, <&gpio1 4 GPIO_ACTIVE_HIGH>;
+
+	ssd1327@0 {
+		ssd1327,data-select-gpio = <&gpio0 7 GPIO_ACTIVE_HIGH>;
+		ssd1327,vcc-gpio = <&gpio_sr 7 GPIO_ACTIVE_HIGH>;
+		resets = <&fbxgw1r_rst 2>;
+	};
+};
+
+&sata {
+	status = "okay";
+	nr-ports = <2>;
+};
+
+&pciec {
+	status = "okay";
+	reset-gpios = <&gpio_sr 5 GPIO_ACTIVE_LOW>;
+};
+
+&pcie0 {
+	status = "okay";
+};
+
+&nand {
+	nand-ecc-mode = "soft";
+	nand-ecc-algo = "hamming";
+};
+
+&eth1 {
+	status = "okay";
+};
+
+&eth1port {
+	fbxserial-mac-address = <0>;
+	speed = <1000>;
+	duplex = <1>;
+};
+
+&pmx_uart0 {
+	/* only mpp11 here (uart rx) as mpp10 is used as a gpio */
+	marvell,pins = "mpp11";
+	marvell,function = "uart0";
+};
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/scripts/dtc/include-prefixes/arm/fbxgw2r.dts	2021-03-04 13:20:56.817505512 +0100
@@ -0,0 +1,351 @@
+/dts-v1/;
+
+#include <dt-bindings/input/linux-event-codes.h>
+
+#include "kirkwood.dtsi"
+#include "kirkwood-6282.dtsi"
+#include "fbxgw.dtsi"
+
+/ {
+	model = "Freebox Gateway V2";
+	compatible = "freebox,fbxgw2r", "arm-machtype,4242";
+
+	chosen {
+		stdout-path = &uart1;
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x40000000>; /* 1024M */
+	};
+
+	reserved-memory {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		ramoops@3fff8000 {
+			compatible = "ramoops";
+			/* RAM top - 32k, just below bootloader page table */
+			reg = <0x3fff8000 (16 * 1024)>;
+			record-size = <(16 * 1024)>;
+			ecc-size = <16>;
+			no-dump-oops;
+		};
+        };
+
+	fbxgw2r_rst: fbxgw2r-rst@0 {
+		compatible = "freebox,fbxgw2r-rst";
+		#reset-cells = <1>;
+
+		usb-gpio = <&gpio0 23 GPIO_ACTIVE_LOW>;
+		keypad-oled-gpio = <&gpio0 21 GPIO_ACTIVE_LOW>;
+	};
+
+	fbxgw2r-audio@0 {
+		compatible = "freebox,fbxgw2r-audio";
+	};
+
+	ocp@f1000000 {
+		kirkwood-coretemp@10078 {
+			compatible = "marvell,kirkwood-coretemp";
+			reg = <0x10078 0x4>;
+			status = "okay";
+		};
+
+		thermal: thermal@10078 {
+			status = "disabled";
+		};
+	};
+
+	fbxgpio@0 {
+		compatible = "fbx,fbxgpio";
+
+		/* claimed for userspace */
+		pos-sense {
+			name = "pos-sense";
+			gpio = <&gpio1 13 0>;
+			input;
+		};
+
+		test-mode {
+			name = "test-mode";
+			gpio = <&gpio0 13 0>;
+			input;
+		};
+
+		sw-reset {
+			name = "sw-reset";
+			gpio = <&gpio0 28 0>;
+			output-high;
+			no-claim;
+		};
+
+		sw-int {
+			name = "sw-int";
+			gpio = <&gpio0 29 0>;
+			input;
+		};
+
+		sfp-txdis {
+			name = "sfp-txdis";
+			gpio = <&gpio0 12 0>;
+			output-high;
+		};
+
+		sfp-pwrgood {
+			name = "sfp-pwrgood";
+			gpio = <&gpio1 0 0>;
+			input;
+		};
+
+		sfp-txfault {
+			name = "sfp-txfault";
+			gpio = <&gpio1 3 0>;
+			input;
+		};
+
+		sfp-presence {
+			name = "sfp-presence";
+			gpio = <&gpio0 31 0>;
+			input;
+		};
+
+		sfp-rxloss {
+			name = "sfp-rxloss";
+			gpio = <&gpio1 6 0>;
+			input;
+		};
+
+		sfp-pwren {
+			name = "sfp-pwren";
+			gpio = <&gpio1 17 0>;
+			output-low;
+		};
+
+		exp-rst {
+			name = "exp-rst";
+			gpio = <&gpio1 12 0>;
+			output-low;
+		};
+
+		exp-pwrgood {
+			name = "exp-pwrgood";
+			gpio = <&gpio1 14 0>;
+			input;
+		};
+
+		exp-presence {
+			name = "exp-presence";
+			gpio = <&gpio1 15 0>;
+			input;
+		};
+
+		exp-pwren {
+			name = "exp-pwren";
+			gpio = <&gpio0 22 0>;
+			output-low;
+		};
+
+		bcm-rst {
+			name = "bcm-rst";
+			gpio = <&gpio0 30 0>;
+			output-low;
+		};
+
+
+		/* unclaimed, exported for debug only */
+		oled-data-select {
+			name = "oled-data-select";
+			gpio = <&gpio0 7 0>;
+			output-low;
+			no-claim;
+		};
+
+		kp-int {
+			name = "kp-int";
+			gpio = <&gpio1 16 0>;
+			input;
+			no-claim;
+		};
+
+		usb-rst {
+			name = "usb-rst";
+			gpio = <&gpio0 23 0>;
+			output-low;
+			no-claim;
+		};
+
+		audio-rst {
+			name = "audio-rst";
+			gpio = <&gpio1 1 0>;
+			output-low;
+			no-claim;
+		};
+
+		pcie-rst {
+			name = "pcie-rst";
+			gpio = <&gpio0 17 0>;
+			output-low;
+			no-claim;
+		};
+
+		keypad-oled-rst {
+			name = "keypad-oled-rst";
+			gpio = <&gpio0 21 0>;
+			output-low;
+			no-claim;
+		};
+
+		oled-vcc {
+			name = "oled-vcc";
+			gpio = <&gpio0 20 0>;
+			output-low;
+			no-claim;
+		};
+	};
+};
+
+&gpio0 {
+	gpio-line-names = "", /* 0 */
+			  "", /* 1 */
+			  "", /* 2 */
+			  "", /* 3 */
+			  "", /* 4 */
+			  "", /* 5 */
+			  "", /* 6 */
+			  "oled-data-select", /* 7 */
+			  "", /* 8 */
+			  "", /* 9 */
+			  "", /* 10 */
+			  "", /* 11 */
+			  "sfp-txdis", /* 12 */
+			  "test-mode", /* 13 */
+			  "wlan-rst", /* 14 */
+			  "", /* 15 */
+			  "", /* 16 */
+			  "pcie-rst", /* 17 */
+			  "", /* 18 */
+			  "", /* 19 */
+			  "oled-vcc", /* 20 */
+			  "keypad-oled-rst", /* 21 */
+			  "exp-pwren", /* 22 */
+			  "usb-rst", /* 23 */
+			  "", /* 24 */
+			  "", /* 25 */
+			  "", /* 26 */
+			  "", /* 27 */
+			  "sw-reset", /* 28 */
+			  "sw-int", /* 29 */
+			  "bcm-rst", /* 30 */
+			  "sfp-presence"; /* 31 */
+};
+
+&gpio1 {
+	gpio-line-names = "sfp-pwrgood", /* 0 */
+			  "audio-rst", /* 1 */
+			  "spi-cs-bcm", /* 2 */
+			  "sfp-txfault", /* 3 */
+			  "", /* 4 */
+			  "", /* 5 */
+			  "sfp-rxloss", /* 6*/
+			  "", /* 7 */
+			  "", /* 8 */
+			  "", /* 9 */
+			  "", /* 10 */
+			  "", /* 11 */
+			  "exp-rst", /* 12 */
+			  "pos-sense", /* 13 */
+			  "exp-pwrgood", /* 14 */
+			  "exp-presence", /* 15 */
+			  "kp-int", /* 16 */
+			  "sfp-pwren"; /* 17 */
+};
+
+&usb0 {
+	status = "okay";
+	resets = <&fbxgw2r_rst 0>;
+};
+
+&mdio {
+	status = "okay";
+
+	mv6176: mv6176@0 {
+		compatible = "freebox,fbxgw-mv6176";
+		reg = <0>;
+		gpio-reset = <&gpio0 28 0>;
+	};
+};
+
+&eth0 {
+	status = "okay";
+};
+
+&eth0port {
+	fbxserial-mac-address = <0>;
+	speed = <1000>;
+	duplex = <1>;
+};
+
+&i2c0 {
+        cap1066@28 {
+		resets = <&fbxgw2r_rst 2>;
+		irq-gpio = <&gpio1 16 0>;
+	};
+};
+
+&tdm_spi0 {
+	cs-gpios = <0>, <&gpio1 2 GPIO_ACTIVE_HIGH>;
+
+	ssd1327@0 {
+		ssd1327,data-select-gpio = <&gpio0 7 GPIO_ACTIVE_HIGH>;
+		ssd1327,vcc-gpio = <&gpio0 20 GPIO_ACTIVE_HIGH>;
+		resets = <&fbxgw2r_rst 2>;
+	};
+};
+
+&sata {
+	status = "okay";
+	nr-ports = <2>;
+};
+
+&pciec {
+	status = "okay";
+	reset-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>,
+		      <&gpio0 14 GPIO_ACTIVE_LOW>;
+};
+
+&pcie0 {
+	status = "okay";
+};
+
+&nand {
+	nand-ecc-mode = "soft";
+	nand-ecc-algo = "bch";
+	/* this will make ecc_bytes == 7 */
+	nand-ecc-strength = <4>;
+	nand-ecc-step-size = <512>;
+};
+
+&gpio1 {
+	marvell,broken-mpp33-dir = <1>;
+};
+
+&audio0 {
+	status = "okay";
+};
+
+&i2c1 {
+	status = "okay";
+	clock-frequency = <25000>;
+
+	codec@4a {
+		compatible = "cirrus,cs42l52";
+		reset-gpio = <&gpio1 1 GPIO_ACTIVE_LOW>;
+		reg = <0x4a>;
+	};
+};
+
+&pcie1 {
+        status = "okay";
+};
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/scripts/dtc/include-prefixes/arm/fbxgw.dtsi	2021-03-04 13:20:56.817505512 +0100
@@ -0,0 +1,156 @@
+/ {
+	ocp@f1000000 {
+		fbxwdt: fbxwatchdog-timer@20300 {
+			compatible = "marvell,orion-fbxwdt";
+			reg = <0x20300 0x28>, <0x20108 0x4>;
+			clocks = <&gate_clk 7>;
+			status = "okay";
+		};
+	};
+};
+
+&i2c0 {
+	status = "okay";
+	clock-frequency = <25000>;
+
+        cap1066@28 {
+		/* SMSC cap1066 */
+		compatible = "smsc,smsc_cap1066";
+		reg = <0x28>;
+		keymap = <KEY_DOWN
+		       	  KEY_LEFT
+			  KEY_UP
+			  0
+			  KEY_ENTER
+			  KEY_RIGHT>;
+	};
+
+        eeprom@53 {
+		/* expansion eeprom */
+		compatible = "atmel,24c256";
+		read-only;
+		reg = <0x53>;
+	};
+
+        eeprom@57 {
+		/* midlane eeprom */
+		compatible = "atmel,24c32";
+		read-only;
+		reg = <0x57>;
+		pagesize = <8>;
+	};
+};
+
+&tdm_spi0 {
+	status = "okay";
+	num-cs = <1>;
+
+	ssd1327@0 {
+		compatible = "solomon,ssd1327";
+		reg = <0>;
+		spi-max-frequency = <(9 * 1000 * 1000)>;
+		ssd1327,width = <128>;
+		ssd1327,height = <128>;
+		ssd1327,rotate = <270>;
+		ssd1327,watchdog = <300>;
+	};
+
+	bcm-flash@1 {
+		compatible = "m25p80";
+		reg = <1>;
+		spi-max-frequency = <(1 * 1000 * 1000)>;
+		label = "bcmflash";
+	};
+};
+
+&nand {
+	status = "okay";
+	chip-delay = <35>;
+
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		all@0 {
+			label = "all";
+			/* MTDPART_SIZ_FULL=0 */
+			reg = <0x0 0>;
+			read-only;
+		};
+
+		u-boot@0 {
+			label = "u-boot";
+			reg = <0x0 (1 * 1024 * 1024)>;
+			read-only;
+		};
+
+		serial@ {
+			label = "serial";
+			reg = <(1 * 1024 * 1024) (1 * 1024 * 1024)>;
+			read-only;
+		};
+
+		calibration@0 {
+			label = "calibration";
+			reg = <(2 * 1024 * 1024) (1 * 1024 * 1024)>;
+			read-only;
+		};
+
+		bank0@0 {
+			label = "bank0";
+			reg = <(3 * 1024 * 1024) (18 * 1024 * 1024)>;
+			read-only;
+		};
+
+		nvram@0 {
+			label = "nvram";
+			reg = <(21 * 1024 * 1024) (3 * 1024 * 1024)>;
+		};
+
+		bank1@0 {
+			label = "bank1";
+			reg = <(24 * 1024 * 1024) (62 * 1024 * 1024)>;
+		};
+
+		femto@0 {
+			label = "femto";
+			reg = <(86 * 1024 * 1024) (16 * 1024 * 1024)>;
+		};
+
+		config@0 {
+			label = "config";
+			reg = <(120 * 1024 * 1024) (8 * 1024 * 1024)>;
+		};
+
+		partition@0 {
+			label = "new_bank0";
+			reg = <(102 * 1024 * 1024) (18 * 1024 * 1024)>;
+		};
+	};
+};
+
+&eth0 {
+	marvell,unit = <0>;
+};
+
+&eth1 {
+	marvell,unit = <1>;
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&uart1 {
+	status = "okay";
+};
+
+&pmx_uart1 {
+	marvell,pins = "mpp15", "mpp16";
+	marvell,function = "uart1";
+};
+
+&usb0 {
+	status = "okay";
+};
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/scripts/dtc/include-prefixes/arm/fbxgwr_exp_stb.dts	2021-03-04 13:20:56.817505512 +0100
@@ -0,0 +1,55 @@
+#include <dt-bindings/gpio/gpio.h>
+
+/dts-v1/;
+/plugin/;
+
+/ {
+    compatible = "freebox,fbxgw1r", "freebox,fbxgw2r";
+
+    fragment@0 {
+	target = <&i2c0>;
+        __overlay__ {
+		#address-cells = <0x1>;
+		#size-cells = <0x0>;
+
+		// IO expander
+		exp_gpio_extender: exp@41 {
+			compatible = "ti,pca9536";
+			reg = <0x41>;
+			gpio-controller;
+			ngpios = <4>;
+			#gpio-cells = <2>;
+			gpio-line-names = "bank0-mode", /* 0 */
+				"stb-rear-button-feedback", /* 1 */
+				"test-mode", /* 2 */
+				"stb-test-mode-feedback"; /* 3 */
+		};
+        };
+    };
+
+     fragment@1 {
+	target-path="/";
+        __overlay__ {
+		exp-fbxgpio {
+			compatible = "fbx,fbxgpio";
+			exp-bank0-mode {
+				gpio = <&exp_gpio_extender 0 GPIO_ACTIVE_LOW>;
+				output-low;
+			};
+			exp-stb-rear-button-feedback {
+				gpio = <&exp_gpio_extender 1 GPIO_ACTIVE_LOW>;
+				input;
+			};
+			exp-test-mode {
+				gpio = <&exp_gpio_extender 2 GPIO_ACTIVE_HIGH>;
+				output-low;
+			};
+			exp-stb-test-mode-feedback {
+				gpio = <&exp_gpio_extender 3 GPIO_ACTIVE_HIGH>;
+				input;
+			};
+		};
+        };
+    };
+
+};
--- /dev/null	2021-03-25 15:17:26.552434351 +0100
+++ linux-5.4.60-fbx/sound/soc/kirkwood/kirkwood-fbxgw2r.c	2021-03-04 13:21:01.724172398 +0100
@@ -0,0 +1,235 @@
+/*
+ * 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_component *component)
+{
+	int i;
+
+	for (i = 0; i < 0x40; ++i) {
+		int val = snd_soc_component_read32(component, 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_component *component = rtd->codec_dai->component;
+	u8 reg;
+
+#if 0
+	printk("Default register configuration:\n");
+	dump_registers(component);
+#endif
+
+	/*
+	 * make sure we correctly transition from speaker to headphone
+	 * and vice&versa.
+	 */
+	snd_soc_component_write(component, 0x4, 0x05);
+
+	/*
+	 * select input4a/input4b for capture
+	 */
+	reg = snd_soc_component_read32(component, 0x8);
+	reg &= ~(7 << 5);
+	reg |= (3 << 5);
+	snd_soc_component_write(component, 0x8, reg);
+
+	reg = snd_soc_component_read32(component, 0x9);
+	reg &= ~(7 << 5);
+	reg |= (3 << 5);
+	snd_soc_component_write(component, 0x9, reg);
+
+	/*
+	 * set headphone analog gain to 1.000
+	 */
+	reg = snd_soc_component_read32(component, 0x0d);
+	reg &= ~0xe0;
+	reg |= 0xc0;
+	snd_soc_component_write(component, 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_component *component = rtd->codec_dai->component;
+
+	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+		u8 reg;
+
+		/*
+		 * power up ADC A & B
+		 */
+		reg = snd_soc_component_read32(component, 0x2);
+		reg &= ~(3 << 1);
+		snd_soc_component_write(component, 0x2, reg);
+
+		/*
+		 * unmute ADC A mixer volume
+		 */
+		reg = snd_soc_component_read32(component, 0x18);
+		reg &= ~(1 << 7);
+		snd_soc_component_write(component, 0x18, reg);
+
+		/*
+		 * unmute ADC B mixer volume
+		 */
+		reg = snd_soc_component_read32(component, 0x19);
+		reg &= ~(1 << 7);
+		snd_soc_component_write(component, 0x19, reg);
+	}
+
+#if 0
+	dump_registers(component);
+#endif
+	return 0;
+}
+
+static void fbxgw2r_shutdown(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_component *component = rtd->codec_dai->component;
+
+	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+		u8 reg;
+
+		/*
+		 * power down ADC A & B
+		 */
+		reg = snd_soc_component_read32(component, 0x2);
+		reg |= (3 << 1);
+		snd_soc_component_write(component, 0x2, reg);
+
+		/*
+		 * mute ADC A mixer volume
+		 */
+		reg = snd_soc_component_read32(component, 0x18);
+		reg |= (1 << 7);
+		snd_soc_component_write(component, 0x18, reg);
+
+		/*
+		 * mute ADC B mixer volume
+		 */
+		reg = snd_soc_component_read32(component, 0x19);
+		reg |= (1 << 7);
+		snd_soc_component_write(component, 0x19, reg);
+	}
+}
+
+static struct snd_soc_ops fbxgw2r_ops = {
+	.hw_params = fbxgw2r_hw_params,
+	.startup = fbxgw2r_startup,
+	.shutdown = fbxgw2r_shutdown,
+};
+
+SND_SOC_DAILINK_DEFS(cpu_dsp,
+	DAILINK_COMP_ARRAY(COMP_CPU("i2s")),
+	DAILINK_COMP_ARRAY(COMP_CODEC("cs42l52.1-004a", "cs42l52")),
+	DAILINK_COMP_ARRAY(COMP_PLATFORM("mvebu-audio")));
+
+static struct snd_soc_dai_link fbxgw2r_dai[] = {
+	{
+		.name = "CS42L52",
+		.stream_name = "CS42L52 HiFi",
+		.ops = &fbxgw2r_ops,
+		.init = fbxgw2r_dai_init,
+		SND_SOC_DAILINK_REG(cpu_dsp),
+	},
+};
+
+
+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 devm_snd_soc_register_card(card->dev, card);
+}
+
+static const struct of_device_id fbxgw2r_audio_dt_ids[] = {
+	{ .compatible = "freebox,fbxgw2r-audio" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, fbxgw2r_audio_dt_ids);
+
+struct platform_driver fbxgw2r_audio_driver = {
+	.driver = {
+		.name = "fbxgw2r-audio",
+		.of_match_table = of_match_ptr(fbxgw2r_audio_dt_ids),
+		.owner = THIS_MODULE,
+	},
+	.probe = fbxgw2r_probe,
+};
+
+module_platform_driver(fbxgw2r_audio_driver);
+
+/* Module information */
+MODULE_DESCRIPTION("ALSA SoC FBXGW2R Client");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:soc-audio");
