Browse Source

Fresh pull from upstream 17.01 branch

RISCi_ATOM 7 years ago
parent
commit
b1426a23c6
100 changed files with 3036 additions and 1886 deletions
  1. 1 1
      Makefile
  2. 12 2
      config/Config-build.in
  3. 1 1
      config/Config-devel.in
  4. 0 1
      config/Config-images.in
  5. 1 1
      config/Config-kernel.in
  6. 2 2
      include/autotools.mk
  7. 4 0
      include/cmake.mk
  8. 0 3
      include/download.mk
  9. 1 1
      include/feeds.mk
  10. 8 1
      include/host-build.mk
  11. 1 1
      include/image-commands.mk
  12. 14 2
      include/image.mk
  13. 1 1
      include/kernel-build.mk
  14. 3 3
      include/kernel-version.mk
  15. 2 0
      include/package-ipkg.mk
  16. 9 1
      include/rootfs.mk
  17. 6 5
      include/target.mk
  18. 3 2
      package/base-files/Makefile
  19. 1 1
      package/base-files/files/etc/init.d/system
  20. 18 0
      package/base-files/files/etc/iproute2/rt_protos
  21. 1 0
      package/base-files/files/etc/openwrt_release
  22. 1 1
      package/base-files/files/etc/uci-defaults/13_fix_group_user
  23. 1 1
      package/base-files/files/lib/preinit/10_sysinfo
  24. 9 3
      package/base-files/files/sbin/wifi
  25. 1 0
      package/base-files/files/usr/lib/os-release
  26. 3 3
      package/base-files/image-config.in
  27. 62 0
      package/boot/apex/Makefile
  28. 20 0
      package/boot/apex/patches/001-compile_fix.patch
  29. 23 0
      package/boot/apex/patches/100-openwrt_nslu2_armeb_config.patch
  30. 23 0
      package/boot/apex/patches/120-openwrt_nslu2_16mb_armeb_config.patch
  31. 23 0
      package/boot/apex/patches/140-openwrt_fsg3_armeb_config.patch
  32. 22 0
      package/boot/apex/patches/150-limit_ram_to_64mb.patch
  33. 20 0
      package/boot/apex/patches/160-openwrt_nas100d_armeb_config.patch
  34. 1 1
      package/boot/fconfig/Makefile
  35. 12 2
      package/boot/grub2/Makefile
  36. 8 8
      package/boot/grub2/patches/100-grub_setup_root.patch
  37. 0 26
      package/boot/grub2/patches/100-musl-compat.patch
  38. 13 0
      package/boot/grub2/patches/101-disable-gettext-check-macro-version.patch
  39. 0 14
      package/boot/grub2/patches/210-fix_serial_rtscts.patch
  40. 0 10
      package/boot/kexec-tools/Config.in
  41. 6 5
      package/boot/kexec-tools/Makefile
  42. 0 171
      package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch
  43. 0 52
      package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch
  44. 0 35
      package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch
  45. 0 30
      package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch
  46. 0 30
      package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch
  47. 20 0
      package/boot/kexec-tools/patches/100-format_string_fix.patch
  48. 11 0
      package/boot/kexec-tools/patches/110-fix-vmcore-dmsg-compilation-error.patch
  49. 46 0
      package/boot/kobs-ng/Makefile
  50. 23 0
      package/boot/kobs-ng/patches/001-compile.patch
  51. 45 0
      package/boot/kobs-ng/patches/002-add-init-size-param.patch
  52. 45 0
      package/boot/kobs-ng/patches/003-raw-mode.patch
  53. 27 0
      package/boot/kobs-ng/patches/004-fix-cal_nfc_geometry.patch
  54. 47 0
      package/boot/rbcfg/Makefile
  55. 14 0
      package/boot/rbcfg/src/Makefile
  56. 109 0
      package/boot/rbcfg/src/cyg_crc.h
  57. 172 0
      package/boot/rbcfg/src/cyg_crc32.c
  58. 791 0
      package/boot/rbcfg/src/main.c
  59. 75 0
      package/boot/rbcfg/src/rbcfg.h
  60. 3 1
      package/boot/yamonenv/Makefile
  61. 0 35
      package/kernel/avila-wdt/Makefile
  62. 0 1
      package/kernel/avila-wdt/src/Makefile
  63. 0 231
      package/kernel/avila-wdt/src/avila-wdt.c
  64. 4 4
      package/kernel/kmod-sched-cake/Makefile
  65. 1 1
      package/kernel/linux/modules/can.mk
  66. 1 1
      package/kernel/linux/modules/netfilter.mk
  67. 3 3
      package/kernel/linux/modules/netsupport.mk
  68. 32 0
      package/kernel/linux/modules/nls.mk
  69. 3 3
      package/kernel/mac80211/Makefile
  70. 1 1
      package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
  71. 1 1
      package/kernel/mac80211/files/lib/wifi/mac80211.sh
  72. 3 3
      package/kernel/mac80211/patches/002-change_allconfig.patch
  73. 0 11
      package/kernel/mac80211/patches/004-fix_duplicate_skcipher_backport.patch
  74. 28 0
      package/kernel/mac80211/patches/004-kconfig_backport_fix.patch
  75. 0 22
      package/kernel/mac80211/patches/005-backport_skb_get_hash_perturb.patch
  76. 152 0
      package/kernel/mac80211/patches/005-revert-devcoredump.patch
  77. 20 0
      package/kernel/mac80211/patches/006-revert-ktime-changes.patch
  78. 266 0
      package/kernel/mac80211/patches/007-revert-genetlink-changes.patch
  79. 20 0
      package/kernel/mac80211/patches/008-revert-ndo_stats64-cleanup.patch
  80. 338 0
      package/kernel/mac80211/patches/009-revert-mtu-changes.patch
  81. 43 0
      package/kernel/mac80211/patches/011-backport_strscpy.patch
  82. 47 0
      package/kernel/mac80211/patches/030-rt2x00_options.patch
  83. 9 0
      package/kernel/mac80211/patches/040-brcmutil_option.patch
  84. 2 2
      package/kernel/mac80211/patches/060-no_local_ssb_bcma.patch
  85. 15 0
      package/kernel/mac80211/patches/090-remove-cred.patch
  86. 208 122
      package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch
  87. 1 1
      package/kernel/mac80211/patches/110-mac80211_keep_keys_on_stop_ap.patch
  88. 1 1
      package/kernel/mac80211/patches/130-mac80211-hwsim-hrtimer-clock.patch
  89. 3 3
      package/kernel/mac80211/patches/150-disable_addr_notifier.patch
  90. 1 1
      package/kernel/mac80211/patches/210-ap_scan.patch
  91. 0 953
      package/kernel/mac80211/patches/300-ath9k-Switch-to-using-mac80211-intermediate-software.patch
  92. 0 0
      package/kernel/mac80211/patches/300-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch
  93. 27 24
      package/kernel/mac80211/patches/301-ath9k_hw-issue-external-reset-for-QCA955x.patch
  94. 0 0
      package/kernel/mac80211/patches/302-ath9k_hw-set-spectral-scan-enable-bit-on-trigger-for.patch
  95. 2 1
      package/kernel/mac80211/patches/303-ath9k-don-t-run-periodic-and-nf-calibation-at-the-sa.patch
  96. 1 1
      package/kernel/mac80211/patches/304-ath9k-force-rx_clear-when-disabling-rx.patch
  97. 7 7
      package/kernel/mac80211/patches/305-ath9k-limit-retries-for-powersave-response-frames.patch
  98. 2 2
      package/kernel/mac80211/patches/306-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch
  99. 11 11
      package/kernel/mac80211/patches/307-mac80211-add-hdrlen-to-ieee80211_tx_data.patch
  100. 18 18
      package/kernel/mac80211/patches/308-mac80211-add-NEED_ALIGNED4_SKBS-hw-flag.patch

+ 1 - 1
Makefile

@@ -14,7 +14,7 @@ export TOPDIR LC_ALL LANG TZ
 
 empty:=
 space:= $(empty) $(empty)
-$(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the libreCMC directory must not include any spaces))
+$(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the LEDE directory must not include any spaces))
 
 world:
 

+ 12 - 2
config/Config-build.in

@@ -9,7 +9,7 @@ menu "Global build settings"
 
 	config ALL_NONSHARED
 		bool "Select all target specific packages by default"
-		default ALL
+		default ALL || BUILDBOT
 
 	config ALL_KMODS
 		bool "Select all kernel module packages by default"
@@ -19,6 +19,16 @@ menu "Global build settings"
 		bool "Select all userspace packages by default"
 		default n
 
+	config BUILDBOT
+		bool "Set build defaults for automatic builds (e.g. via buildbot)"
+		default n
+		help
+		  This option changes several defaults to be more suitable for
+		  automatic builds. This includes the following changes:
+		  - Deleting build directories after compiling (to save space)
+		  - Enabling per-device rootfs support
+		  ...
+
 	config SIGNED_PACKAGES
 		bool "Cryptographically signed package lists"
 		default y
@@ -61,7 +71,7 @@ menu "Global build settings"
 		bool
 		prompt "Collect kernel debug information"
 		select KERNEL_DEBUG_INFO
-		default n
+		default BUILDBOT
 		help
 		  This collects debugging symbols from the kernel and all compiled modules.
 		  Useful for release builds, so that kernel issues can be debugged offline

+ 1 - 1
config/Config-devel.in

@@ -59,7 +59,7 @@ menuconfig DEVEL
 		bool "Use ccache" if DEVEL
 		default n
 		help
-		  Compiler cache; see http://ccache.samba.org/.
+		  Compiler cache; see https://ccache.samba.org/
 
 	config EXTERNAL_KERNEL_TREE
 		string "Use external kernel tree" if DEVEL

+ 0 - 1
config/Config-images.in

@@ -201,7 +201,6 @@ menu "Target Images"
 		int "Serial port baud rate"
 		depends on GRUB_IMAGES
 		default 38400 if TARGET_x86_generic
-		default 38400 if TARGET_x86_geode
 		default 115200
 
 	config GRUB_BOOTOPTS

+ 1 - 1
config/Config-kernel.in

@@ -26,7 +26,7 @@ config KERNEL_PRINTK
 
 config KERNEL_CRASHLOG
 	bool "Crash logging"
-	depends on !(arm || powerpc || sparc || TARGET_uml)
+	depends on !(arm || powerpc || sparc || TARGET_uml || i386 || x86_64)
 	default y
 
 config KERNEL_SWAP

+ 2 - 2
include/autotools.mk

@@ -85,11 +85,11 @@ endef
 
 define gettext_version_target
 	(cd $(PKG_BUILD_DIR) && \
-		GETTEXT_VERSION=$(shell $(STAGING_DIR)/host/bin/gettext -V | $(STAGING_DIR_HOST)/bin/sed -ne '1s/.*\([0-9]\.[0-9]\{2\}\.[0-9]\).*/\1/p' ) && \
+		GETTEXT_VERSION=$(shell $(STAGING_DIR_HOSTPKG)/bin/gettext -V | $(STAGING_DIR_HOST)/bin/sed -ne '1s/.*\([0-9]\.[0-9]\{2\}\.[0-9]\).*/\1/p' ) && \
 		$(STAGING_DIR_HOST)/bin/sed \
 			-i $(PKG_BUILD_DIR)/configure.ac \
 			-e "s/AM_GNU_GETTEXT_VERSION(.*)/AM_GNU_GETTEXT_VERSION(\[$$$$GETTEXT_VERSION\])/g" && \
-		$(STAGING_DIR)/host/bin/autopoint --force \
+		$(STAGING_DIR_HOSTPKG)/bin/autopoint --force \
 	);
 endef
 

+ 4 - 0
include/cmake.mk

@@ -107,3 +107,7 @@ define Host/Configure/Default
 		$(HOST_CMAKE_SOURCE_DIR) \
 	)
 endef
+
+MAKE_FLAGS += \
+	CMAKE_COMMAND='$$(if $$(CMAKE_DISABLE_$$@),:,$(STAGING_DIR_HOST)/bin/cmake)' \
+	CMAKE_DISABLE_cmake_check_build_system=1

+ 0 - 3
include/download.mk

@@ -94,13 +94,10 @@ endif
 
 C_md5_deprecated = Use of $(2) is deprecated, switch to $(3)
 
-# Skip MD5SUM check in feeds until OpenWrt is updated
-ifneq ($(filter $(foreach dir,package tools toolchain, $(TOPDIR)/$(dir)/%),$(CURDIR)),)
 check_md5 = \
   $(if $(filter-out x,$(1)), \
     $(call check_warn,md5_deprecated,$(1),$(2),$(3)) \
   )
-endif
 
 hash_var = $(if $(filter-out x,$(1)),MD5SUM,HASH)
 endif

+ 1 - 1
include/feeds.mk

@@ -10,7 +10,7 @@
 
 FEEDS_INSTALLED:=$(notdir $(wildcard $(TOPDIR)/package/feeds/*))
 FEEDS_AVAILABLE:=$(sort $(FEEDS_INSTALLED) $(shell $(SCRIPT_DIR)/feeds list -n))
-FEEDS_ENABLED:=$(foreach feed,$(FEEDS_INSTALLED),$(if $(CONFIG_FEED_$(feed)),$(feed)))
+FEEDS_ENABLED:=$(foreach feed,$(FEEDS_AVAILABLE),$(if $(CONFIG_FEED_$(feed)),$(feed)))
 FEEDS_DISABLED:=$(filter-out $(FEEDS_ENABLED),$(FEEDS_AVAILABLE))
 
 PACKAGE_SUBDIRS=$(PACKAGE_DIR)

+ 8 - 1
include/host-build.mk

@@ -67,6 +67,12 @@ HOST_CONFIGURE_ARGS = \
 	--localstatedir=$(HOST_BUILD_PREFIX)/var \
 	--sbindir=$(HOST_BUILD_PREFIX)/bin
 
+HOST_MAKE_VARS = \
+	CFLAGS="$(HOST_CFLAGS)" \
+	CPPFLAGS="$(HOST_CPPFLAGS)" \
+	CXXFLAGS="$(HOST_CXXFLAGS)" \
+	LDFLAGS="$(HOST_LDFLAGS)"
+
 HOST_MAKE_FLAGS =
 
 HOST_CONFIGURE_CMD = $(BASH) ./configure
@@ -89,7 +95,8 @@ define Host/Configure
 endef
 
 define Host/Compile/Default
-	+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
+	+$(HOST_MAKE_VARS) \
+	$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
 		$(HOST_MAKE_FLAGS) \
 		$(1)
 endef

+ 1 - 1
include/image-commands.mk

@@ -59,7 +59,7 @@ define Build/fit
 		-D $(DEVICE_NAME) -o $@.its -k $@ \
 		$(if $(word 2,$(1)),-d $(word 2,$(1))) -C $(word 1,$(1)) \
 		-a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
-		-A $(ARCH) -v $(LINUX_VERSION)
+		-A $(LINUX_KARCH) -v $(LINUX_VERSION)
 	PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
 	@mv $@.new $@
 endef

+ 14 - 2
include/image.mk

@@ -143,10 +143,17 @@ endef
 define Image/BuildKernel/MkFIT
 	$(TOPDIR)/scripts/mkits.sh \
 		-D $(1) -o $(KDIR)/fit-$(1).its -k $(2) $(if $(3),-d $(3)) -C $(4) -a $(5) -e $(6) \
-		-A $(ARCH) -v $(LINUX_VERSION)
+		-A $(LINUX_KARCH) -v $(LINUX_VERSION)
 	PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/fit-$(1).its $(KDIR)/fit-$(1)$(7).itb
 endef
 
+ifdef CONFIG_TARGET_IMAGES_GZIP
+  define Image/Gzip
+	rm -f $(1).gz
+	gzip -9n $(1)
+  endef
+endif
+
 # $(1) source dts file
 # $(2) target dtb file
 # $(3) extra CPP flags
@@ -445,7 +452,8 @@ define Device/Build/kernel
 endef
 
 define Device/Build/image
-  $$(_TARGET): $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))
+  GZ_SUFFIX := $(if $(filter %dtb %gz,$(2)),,$(if $(and $(findstring ext4,$(1)),$(CONFIG_TARGET_IMAGES_GZIP)),.gz))
+  $$(_TARGET): $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))$$(GZ_SUFFIX)
   $(eval $(call Device/Export,$(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2)),$(1)))
   ROOTFS/$(1)/$(3) := \
 	$(KDIR)/root.$(1)$$(strip \
@@ -462,6 +470,10 @@ define Device/Build/image
 	$$(call concat_cmd,$(if $(IMAGE/$(2)/$(1)),$(IMAGE/$(2)/$(1)),$(IMAGE/$(2))))
 
   .IGNORE: $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))
+
+  $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)).gz: $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2))
+	gzip -c -9n $$^ > $$@
+
   $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2))
 	cp $$^ $$@
 

+ 1 - 1
include/kernel-build.mk

@@ -60,7 +60,7 @@ define Download/git-kernel
   PROTO:=git
   VERSION:=$(CONFIG_KERNEL_GIT_BRANCH)
   FILE:=$(LINUX_SOURCE)
-  SUBDIR:=linux-$(KERNEL_PATCHVER)
+  SUBDIR:=linux-$(LINUX_VERSION)
   OPTS:=$(KERNEL_GIT_OPTS)
 endef
 

+ 3 - 3
include/kernel-version.mk

@@ -3,10 +3,10 @@
 LINUX_RELEASE?=1
 
 LINUX_VERSION-3.18 = .43
-LINUX_VERSION-4.4 = .40
+LINUX_VERSION-4.4 = .52
 
-LINUX_KERNEL_HASH-3.18.43 = 648a61fb3b1d09a14f50a9ced13977302d57b32e2826877950071dc70541f918
-LINUX_KERNEL_HASH-4.4.40 = a3c006893966ec9bee23edb41eebbe2cf0481efe205bf037ee0cc43ce427fc22
+LINUX_KERNEL_HASH-3.18.43 = 
+LINUX_KERNEL_HASH-4.4.52 = 0f1faafdae47da5f29e740ff655f91c2eb13c8cdfc4d039d903176bd56c2ecbb
 
 ifdef KERNEL_PATCHVER
   LINUX_VERSION:=$(KERNEL_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_PATCHVER)))

+ 2 - 0
include/package-ipkg.mk

@@ -209,11 +209,13 @@ $(_endef)
 		( \
 			echo "#!/bin/sh"; \
 			echo "[ \"\$$$${IPKG_NO_SCRIPT}\" = \"1\" ] && exit 0"; \
+			echo "[ -x "\$$$${IPKG_INSTROOT}/lib/functions.sh" ] || exit 0"; \
 			echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \
 			echo "default_postinst \$$$$0 \$$$$@"; \
 		) > postinst; \
 		( \
 			echo "#!/bin/sh"; \
+			echo "[ -x "\$$$${IPKG_INSTROOT}/lib/functions.sh" ] || exit 0"; \
 			echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \
 			echo "default_prerm \$$$$0 \$$$$@"; \
 		) > prerm; \

+ 9 - 1
include/rootfs.mk

@@ -47,6 +47,14 @@ opkg = \
 
 TARGET_DIR_ORIG := $(TARGET_ROOTFS_DIR)/root.orig-$(BOARD)
 
+ifdef CONFIG_CLEAN_IPKG
+  define clean_ipkg
+	-find $(1)/usr/lib/opkg -type f -and -not -name '*.control' | $(XARGS) rm -rf
+	-sed -i -ne '/^Require-User: /p' $(1)/usr/lib/opkg/info/*.control
+	-find $(1)/usr/lib/opkg -empty | $(XARGS) rm -rf
+  endef
+endif
+
 define prepare_rootfs
 	@if [ -d $(TOPDIR)/files ]; then \
 		$(call file_copy,$(TOPDIR)/files/.,$(1)); \
@@ -75,6 +83,6 @@ define prepare_rootfs
 	rm -f $(1)/usr/lib/opkg/lists/*
 	rm -f $(1)/usr/lib/opkg/info/*.postinst*
 	rm -f $(1)/usr/lib/opkg/info/*.prerm*
-	$(if $(CONFIG_CLEAN_IPKG),rm -rf $(1)/usr/lib/opkg)
+	$(call clean_ipkg,$(1))
 	$(call mklibs,$(1))
 endef

+ 6 - 5
include/target.mk

@@ -13,7 +13,7 @@ __target_inc=1
 DEVICE_TYPE?=router
 
 # Default packages - the really basic set
-DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch
+DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd
 # For nas targets
 DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm
 # For router targets
@@ -164,17 +164,15 @@ ifeq ($(DUMP),1)
     endif
     CPU_CFLAGS += -mno-branch-likely
     CPU_CFLAGS_mips32 = -mips32 -mtune=mips32
-    CPU_CFLAGS_mips32r2 = -mips32r2 -mtune=mips32r2
     CPU_CFLAGS_mips64 = -mips64 -mtune=mips64 -mabi=64
     CPU_CFLAGS_24kc = -mips32r2 -mtune=24kc
     CPU_CFLAGS_74kc = -mips32r2 -mtune=74kc
     CPU_CFLAGS_octeon = -march=octeon -mabi=64
   endif
   ifeq ($(ARCH),i386)
-    CPU_TYPE ?= i486
-    CPU_CFLAGS_i486 = -march=i486
+    CPU_TYPE ?= pentium
+    CPU_CFLAGS_pentium = -march=pentium-mmx
     CPU_CFLAGS_pentium4 = -march=pentium4
-    CPU_CFLAGS_geode = -march=geode -mmmx -m3dnow
   endif
   ifneq ($(findstring arm,$(ARCH)),)
     CPU_TYPE ?= xscale
@@ -259,6 +257,9 @@ ifeq ($(DUMP),1)
     ifneq ($(CONFIG_VIRTIO),)
       FEATURES += virtio
     endif
+    ifneq ($(CONFIG_CPU_MIPS32_R2),)
+      FEATURES += mips16
+    endif
     FEATURES += $(foreach v,6 7,$(if $(CONFIG_CPU_V$(v)),arm_v$(v)))
 
     # remove duplicates

+ 3 - 2
package/base-files/Makefile

@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
 include $(INCLUDE_DIR)/version.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=171
+PKG_RELEASE:=172
 PKG_FLAGS:=nonshared
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
@@ -31,7 +31,7 @@ define Package/base-files
   SECTION:=base
   CATEGORY:=Base system
   DEPENDS:=+netifd +libc +procd +jsonfilter +SIGNED_PACKAGES:usign +SIGNED_PACKAGES:lede-keyring +fstools +fwtool
-  TITLE:=Base filesystem for Lede
+  TITLE:=Base filesystem for libreCMC
   URL:=http://openwrt.org/
   VERSION:=$(PKG_RELEASE)-$(REVISION)
 endef
@@ -57,6 +57,7 @@ define Package/base-files/conffiles
 /etc/sysctl.d/local.conf
 /etc/sysctl.d/
 /etc/iproute2/rt_tables
+/etc/iproute2/rt_protos
 $(call $(TARGET)/conffiles)
 endef
 

+ 1 - 1
package/base-files/files/etc/init.d/system

@@ -7,7 +7,7 @@ USE_PROCD=1
 validate_system_section()
 {
 	uci_validate_section system system "${1}" \
-		'hostname:string:libreCMC' \
+		'hostname:string:lede' \
 		'conloglevel:uinteger' \
 		'buffersize:uinteger' \
 		'timezone:string:UTC' \

+ 18 - 0
package/base-files/files/etc/iproute2/rt_protos

@@ -0,0 +1,18 @@
+#
+# Reserved protocols.
+#
+0	unspec
+1	redirect
+2	kernel
+3	boot
+4	static
+8	gated
+9	ra
+10	mrt
+11	zebra
+12	bird
+13	dnrouted
+14	xorp
+15	ntk
+16	dhcp
+42	babel

+ 1 - 0
package/base-files/files/etc/openwrt_release

@@ -3,5 +3,6 @@ DISTRIB_RELEASE='%V'
 DISTRIB_REVISION='%R'
 DISTRIB_CODENAME='%n'
 DISTRIB_TARGET='%S'
+DISTRIB_ARCH='%A'
 DISTRIB_DESCRIPTION='%D %N %V %C'
 DISTRIB_TAINTS='%t'

+ 1 - 1
package/base-files/files/etc/uci-defaults/13_fix_group_user

@@ -2,7 +2,7 @@
 
 . /lib/functions.sh
 
-for file in `grep Require-User /usr/lib/opkg/info/*.control | cut -d: -f1`; do
+for file in `grep -sl Require-User /usr/lib/opkg/info/*.control`; do
 	file="${file##*/}"
 	file="${file%.control}"
 	add_group_and_user "${file}"

+ 1 - 1
package/base-files/files/lib/preinit/10_sysinfo

@@ -3,7 +3,7 @@ do_sysinfo_generic() {
 	mkdir -p /tmp/sysinfo
 	[ -e /tmp/sysinfo/board_name ] || \
 		echo "$(strings /proc/device-tree/compatible | head -1)" > /tmp/sysinfo/board_name
-	[ -n /tmp/sysinfo/model -a -e /proc/device-tree/model ] && \
+	[ ! -e /tmp/sysinfo/model -a -e /proc/device-tree/model ] && \
 		echo "$(cat /proc/device-tree/model)" > /tmp/sysinfo/model
 }
 

+ 9 - 3
package/base-files/files/sbin/wifi

@@ -6,8 +6,8 @@
 
 usage() {
 	cat <<EOF
-Usage: $0 [down|detect|reload|status]
-enables (default), disables or detects a wifi configuration.
+Usage: $0 [config|down|reload|status]
+enables (default), disables or configures devices not yet configured.
 EOF
 	exit 1
 }
@@ -145,6 +145,12 @@ wifi_reload() {
 	wifi_reload_legacy
 }
 
+wifi_detect_notice() {
+	>&2 echo "WARNING: Wifi detect is deprecated. Use wifi config instead"
+	>&2 echo "For more information, see commit 5f8f8a366136a07df661e31decce2458357c167a"
+	exit 1
+}
+
 wifi_config() {
 	[ ! -f /etc/config/wireless ] && touch /etc/config/wireless
 
@@ -229,7 +235,7 @@ scan_wifi
 
 case "$1" in
 	down) wifi_updown "disable" "$2";;
-	detect) ;;
+	detect) wifi_detect_notice ;;
 	config) wifi_config ;;
 	status) ubus_wifi_cmd "status" "$2";;
 	reload) wifi_reload "$2";;

+ 1 - 0
package/base-files/files/usr/lib/os-release

@@ -9,6 +9,7 @@ BUG_URL="%b"
 SUPPORT_URL="%s"
 BUILD_ID="%R"
 LEDE_BOARD="%S"
+LEDE_ARCH="%A"
 LEDE_TAINTS="%t"
 LEDE_DEVICE_MANUFACTURER="%M"
 LEDE_DEVICE_MANUFACTURER_URL="%m"

+ 3 - 3
package/base-files/image-config.in

@@ -92,7 +92,7 @@ config TARGET_PREINIT_NETMASK
 config TARGET_PREINIT_BROADCAST
 	string
 	prompt "Broadcast address for preinit network messages" if PREINITOPT
-	default "192.168.10.255"
+	default "192.168.1.255"
 	help
 		Broadcast address to which to send preinit network messages, as
 		as failsafe messages
@@ -190,7 +190,7 @@ if VERSIONOPT
 	config VERSION_REPO
 		string
 		prompt "Release repository"
-		default "http://downloads.lede-project.org/snapshots"
+		default "http://downloads.lede-project.org/releases/17.01-SNAPSHOT"
 		help
 			This is the repository address embedded in the image, it defaults
 			to the trunk snapshot repo; the url may contain the following placeholders:
@@ -286,7 +286,7 @@ menuconfig PER_FEED_REPO
 
 	config PER_FEED_REPO_ADD_COMMENTED
 		bool "Comment out not enabled feeds"
-		default y
+		default !BUILDBOT
 		depends on PER_FEED_REPO && PER_FEED_REPO_ADD_DISABLED
 		help
 		  Add not enabled feeds as commented out source lines to opkg.conf.

+ 62 - 0
package/boot/apex/Makefile

@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=apex
+PKG_VERSION:=1.6.9
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://downloads.openwrt.org/sources/
+PKG_HASH:=1d2bc04c2c6bb3d2d6c1916b6dc559cda2b1ecb045d7801fd49af6af4234abeb
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+export GCC_HONOUR_COPTS=s
+
+define Package/apex
+  SECTION:=boot
+  CATEGORY:=Boot Loaders
+  DEPENDS:=@TARGET_ixp4xx
+  DEFAULT:=y
+  TITLE:=Boot loader for NSLU2, FSG3, NAS100D and others
+  URL:=http://wiki.buici.com/wiki/Apex_Bootloader
+endef
+
+define build_apex
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		ARCH=arm \
+		$(1)_config
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		$(TARGET_CONFIGURE_OPTS) \
+		KBUILD_HAVE_NLS=no \
+		ARCH=arm \
+		clean all
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/apex.bin $(PKG_BUILD_DIR)/out/apex-$(2).bin
+endef
+
+define Build/Compile
+	$(INSTALL_DIR) $(PKG_BUILD_DIR)/out
+	$(call build_apex,slugos-nslu2-armeb,nslu2-armeb)
+	$(call build_apex,slugos-nslu2-16mb-armeb,nslu2-16mb-armeb)
+	$(call build_apex,slugos-fsg3-armeb,fsg3-armeb)
+	$(call build_apex,slugos-nas100d-armeb,nas100d-armeb)
+endef
+
+define Package/apex/install
+	$(INSTALL_DIR) $(STAGING_DIR)/apex
+	$(CP) $(PKG_BUILD_DIR)/out/*.bin $(1)/
+endef
+
+define Build/InstallDev
+	$(CP) $(PKG_BUILD_DIR)/out/*.bin $(KERNEL_BUILD_DIR)
+endef
+
+$(eval $(call BuildPackage,apex))

+ 20 - 0
package/boot/apex/patches/001-compile_fix.patch

@@ -0,0 +1,20 @@
+--- a/Makefile
++++ b/Makefile
+@@ -444,7 +444,7 @@ ifeq ($(config-targets),1)
+ include $(srctree)/src/arch-$(SRCARCH)/Makefile
+ export KBUILD_DEFCONFIG
+ 
+-config %config: scripts_basic outputmakefile FORCE
++%config: scripts_basic outputmakefile FORCE
+ 	$(Q)mkdir -p include/linux include/config
+ 	$(Q)$(MAKE) $(build)=scripts/kconfig $@
+ 
+@@ -1585,7 +1585,7 @@ endif
+ 	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+ 
+ # Modules
+-/ %/: prepare scripts FORCE
++%/: prepare scripts FORCE
+ 	$(cmd_crmodverdir)
+ 	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
+ 	$(build)=$(build-dir)

+ 23 - 0
package/boot/apex/patches/100-openwrt_nslu2_armeb_config.patch

@@ -0,0 +1,23 @@
+--- a/src/mach-ixp42x/slugos-nslu2-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-armeb_config
+@@ -19,7 +19,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS NSLU2 (bigendian)"
++CONFIG_TARGET_DESCRIPTION="OpenWrt NSLU2 (8MiB Flash)"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ # CONFIG_DRIVER_LONG_LONG_SIZE is not set
+@@ -163,9 +163,9 @@ CONFIG_ENV_REGION_KERNEL_ALT="fis://kern
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ CONFIG_ENV_DEFAULT_CMDLINE_ALT_P=y
+-CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ # CONFIG_ENV_DEFAULT_STARTUP_ALT_P is not set
+ CONFIG_USES_NOR_BOOTFLASH=y

+ 23 - 0
package/boot/apex/patches/120-openwrt_nslu2_16mb_armeb_config.patch

@@ -0,0 +1,23 @@
+--- a/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
+@@ -19,7 +19,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS NSLU2/BE (16MiB Flash)"
++CONFIG_TARGET_DESCRIPTION="OpenWrt NSLU2 (16MiB Flash)"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ # CONFIG_DRIVER_LONG_LONG_SIZE is not set
+@@ -163,9 +163,9 @@ CONFIG_ENV_REGION_KERNEL_ALT="fis://kern
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ CONFIG_ENV_DEFAULT_CMDLINE_ALT_P=y
+-CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ # CONFIG_ENV_DEFAULT_STARTUP_ALT_P is not set
+ CONFIG_USES_NOR_BOOTFLASH=y

+ 23 - 0
package/boot/apex/patches/140-openwrt_fsg3_armeb_config.patch

@@ -0,0 +1,23 @@
+--- a/src/mach-ixp42x/slugos-fsg3-armeb_config
++++ b/src/mach-ixp42x/slugos-fsg3-armeb_config
+@@ -17,7 +17,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS FSG3/BE"
++CONFIG_TARGET_DESCRIPTION="OpenWrt FSG3"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+@@ -148,9 +148,9 @@ CONFIG_ENV_REGION_KERNEL_ALT="fis://kern
+ #    Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/sda1 rootdelay=10 console=ttyS0,115200"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/sda1 rootdelay=10 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ CONFIG_ENV_DEFAULT_CMDLINE_ALT_P=y
+-CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/sda2 rootdelay=10 console=ttyS0,115200"
++CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock2 rootfstype=squashfs console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ # CONFIG_ENV_DEFAULT_STARTUP_ALT_P is not set
+ CONFIG_USES_NOR_BOOTFLASH=y

+ 22 - 0
package/boot/apex/patches/150-limit_ram_to_64mb.patch

@@ -0,0 +1,22 @@
+--- a/src/mach-ixp42x/slugos-nslu2-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-armeb_config
+@@ -137,7 +137,7 @@ CONFIG_AUTOBOOT_DELAY=10
+ CONFIG_ENV_STARTUP_KERNEL_COPY=y
+ # CONFIG_ENV_REGION_KERNEL_SWAP is not set
+ CONFIG_ENV_STARTUP_PREFIX_P=y
+-CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+256m"
++CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+64m"
+ 
+ #
+ #    Regions
+--- a/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
+@@ -137,7 +137,7 @@ CONFIG_AUTOBOOT_DELAY=10
+ CONFIG_ENV_STARTUP_KERNEL_COPY=y
+ # CONFIG_ENV_REGION_KERNEL_SWAP is not set
+ CONFIG_ENV_STARTUP_PREFIX_P=y
+-CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+256m"
++CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+64m"
+ 
+ #
+ #    Regions

+ 20 - 0
package/boot/apex/patches/160-openwrt_nas100d_armeb_config.patch

@@ -0,0 +1,20 @@
+--- a/src/mach-ixp42x/slugos-nas100d-armeb_config
++++ b/src/mach-ixp42x/slugos-nas100d-armeb_config
+@@ -19,7 +19,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS NAS100D/BE"
++CONFIG_TARGET_DESCRIPTION="OpenWrt NAS100D"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ # CONFIG_DRIVER_LONG_LONG_SIZE is not set
+@@ -158,7 +158,7 @@ CONFIG_ENV_REGION_KERNEL="fis://kernel"
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock2 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock2 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ CONFIG_USES_NOR_BOOTFLASH=y
+ CONFIG_RELOCATE_SIMPLE=y

+ 1 - 1
package/boot/fconfig/Makefile

@@ -13,7 +13,7 @@ PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://andrzejekiert.ovh.org/software/fconfig/
-PKG_MD5SUM:=dac355e9f2a0f48c414c52e2034b6346
+PKG_HASH:=4ff0e8f07e35e46b705c0dbe9d9544ede01ea092a69e3f7db03e55a3f2bb8eb7
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
 

+ 12 - 2
package/boot/grub2/Makefile

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=grub
-PKG_VERSION:=2.02~beta2
+PKG_VERSION:=2.02~rc1
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
@@ -17,13 +17,16 @@ PKG_SOURCE_URL:=http://alpha.gnu.org/gnu/grub \
 	http://gnualpha.uib.no/grub/ \
 	http://mirrors.fe.up.pt/pub/gnu-alpha/grub/ \
 	http://www.nic.funet.fi/pub/gnu/alpha/gnu/grub/
-PKG_MD5SUM:=be62932eade308a364ea4bbc91295930
+PKG_HASH:=445239e9b96d1143c194c1d37851cf4196b83701c60172e49665e9d453d80278
 
+PKG_FIXUP:=autoreconf
 HOST_BUILD_PARALLEL:=1
 PKG_BUILD_DEPENDS:=grub2/host
 
 PKG_SSP:=0
 
+PKG_FLAGS:=nonshared
+
 include $(INCLUDE_DIR)/host-build.mk
 include $(INCLUDE_DIR)/package.mk
 
@@ -50,6 +53,9 @@ endef
 
 HOST_BUILD_PREFIX := $(STAGING_DIR_HOST)
 
+CONFIGURE_VARS += \
+	grub_build_mkfont_excuse="don't want fonts"
+
 CONFIGURE_ARGS += \
 	--target=$(REAL_GNU_TARGET_NAME) \
 	--disable-werror \
@@ -58,7 +64,11 @@ CONFIGURE_ARGS += \
 	--disable-libzfs \
 	--disable-grub-mkfont
 
+HOST_CONFIGURE_VARS += \
+	grub_build_mkfont_excuse="don't want fonts"
+
 HOST_CONFIGURE_ARGS += \
+	--disable-grub-mkfont \
 	--target=$(REAL_GNU_TARGET_NAME) \
 	--sbindir="$(STAGING_DIR_HOST)/bin" \
 	--disable-werror \

+ 8 - 8
package/boot/grub2/patches/100-grub_setup_root.patch

@@ -17,7 +17,7 @@
    int  force;
    int  fs_probe;
    int allow_floppy;
-@@ -178,6 +181,13 @@ argp_parser (int key, char *arg, struct 
+@@ -178,6 +181,13 @@ argp_parser (int key, char *arg, struct argp_state *state)
          arguments->dev_map = xstrdup (arg);
          break;
  
@@ -42,7 +42,7 @@
  
 --- a/util/setup.c
 +++ b/util/setup.c
-@@ -247,13 +247,12 @@ identify_partmap (grub_disk_t disk __att
+@@ -247,13 +247,12 @@ identify_partmap (grub_disk_t disk __attribute__ ((unused)),
  void
  SETUP (const char *dir,
         const char *boot_file, const char *core_file,
@@ -69,7 +69,7 @@
      char **root_devices = grub_guess_root_devices (dir);
      char **cur;
      int found = 0;
-@@ -317,6 +319,8 @@ SETUP (const char *dir,
+@@ -320,6 +322,8 @@ SETUP (const char *dir,
  	char *drive;
  	grub_device_t try_dev;
  
@@ -80,7 +80,7 @@
  	  continue;
 --- a/include/grub/util/install.h
 +++ b/include/grub/util/install.h
-@@ -182,13 +182,13 @@ grub_install_get_image_target (const cha
+@@ -184,13 +184,13 @@ grub_install_get_image_target (const char *arg);
  void
  grub_util_bios_setup (const char *dir,
  		      const char *boot_file, const char *core_file,
@@ -98,7 +98,7 @@
  
 --- a/util/grub-install.c
 +++ b/util/grub-install.c
-@@ -1660,7 +1660,7 @@ main (int argc, char *argv[])
+@@ -1673,7 +1673,7 @@ main (int argc, char *argv[])
  	/*  Now perform the installation.  */
  	if (install_bootsector)
  	  grub_util_bios_setup (platdir, "boot.img", "core.img",
@@ -107,12 +107,12 @@
  				fs_probe, allow_floppy, add_rs_codes);
  	break;
        }
-@@ -1686,7 +1686,7 @@ main (int argc, char *argv[])
+@@ -1699,7 +1699,7 @@ main (int argc, char *argv[])
  	/*  Now perform the installation.  */
  	if (install_bootsector)
  	  grub_util_sparc_setup (platdir, "boot.img", "core.img",
--				 install_device, force,
-+				 NULL, install_device, force,
+-				 install_drive, force,
++				 NULL, install_drive, force,
  				 fs_probe, allow_floppy,
  				 0 /* unused */ );
  	break;

+ 0 - 26
package/boot/grub2/patches/100-musl-compat.patch

@@ -1,26 +0,0 @@
---- a/grub-core/osdep/unix/hostdisk.c
-+++ b/grub-core/osdep/unix/hostdisk.c
-@@ -48,11 +48,10 @@
- #ifdef __linux__
- # include <sys/ioctl.h>         /* ioctl */
- # include <sys/mount.h>
--# if !defined(__GLIBC__) || \
--        ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1)))
-+# if defined(__UCLIBC__)
- /* Maybe libc doesn't have large file support.  */
- #  include <linux/unistd.h>     /* _llseek */
--# endif /* (GLIBC < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR < 1)) */
-+# endif /* __UCLIBC__ */
- #endif /* __linux__ */
- 
- grub_uint64_t
-@@ -79,8 +78,7 @@ grub_util_get_fd_size (grub_util_fd_t fd
-   return st.st_size;
- }
- 
--#if defined(__linux__) && (!defined(__GLIBC__) || \
--        ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
-+#if defined(__linux__) && defined(__UCLIBC__)
-   /* Maybe libc doesn't have large file support.  */
- int
- grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)

+ 13 - 0
package/boot/grub2/patches/101-disable-gettext-check-macro-version.patch

@@ -0,0 +1,13 @@
+diff --git a/po/Makefile.in.in b/po/Makefile.in.in
+index 3619458..060e0db 100644
+--- a/po/Makefile.in.in
++++ b/po/Makefile.in.in
+@@ -97,7 +97,7 @@ CATALOGS = @CATALOGS@
+ 	mv t-$@ $@
+ 
+ 
+-all: check-macro-version all-@USE_NLS@
++all: all-@USE_NLS@
+ 
+ all-yes: stamp-po
+ all-no:

+ 0 - 14
package/boot/grub2/patches/210-fix_serial_rtscts.patch

@@ -1,14 +0,0 @@
---- a/grub-core/term/serial.c
-+++ b/grub-core/term/serial.c
-@@ -241,9 +241,9 @@ grub_cmd_serial (grub_extcmd_context_t c
- 
-   if (state[OPTION_RTSCTS].set)
-     {
--      if (grub_strcmp (state[OPTION_PARITY].arg, "on") == 0)
-+      if (grub_strcmp (state[OPTION_RTSCTS].arg, "on") == 0)
- 	config.rtscts = 1;
--      if (grub_strcmp (state[OPTION_PARITY].arg, "off") == 0)
-+      else if (grub_strcmp (state[OPTION_RTSCTS].arg, "off") == 0)
- 	config.rtscts = 0;
-       else
- 	return grub_error (GRUB_ERR_BAD_ARGUMENT,

+ 0 - 10
package/boot/kexec-tools/Config.in

@@ -1,16 +1,6 @@
 menu "Configuration"
 	depends on PACKAGE_kexec-tools
 
-config KEXEC_TOOLS_TARGET_NAME
-	string
-	prompt "Target name for kexec kernel"
-	default EXTRA_TARGET_ARCH_NAME	if powerpc64
-	default ARCH
-	help
-	  Defines the target type of the kernels that kexec deals
-	  with. This should be the target specification of
-	  the kernel you're booting.
-
 config KEXEC_TOOLS_kdump
 	bool
 	prompt "kdump support"

+ 6 - 5
package/boot/kexec-tools/Makefile

@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=kexec-tools
-PKG_VERSION:=2.0.9
+PKG_VERSION:=2.0.14-rc1
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec
-PKG_MD5SUM:=6681319934e22e74c532bd392ccb1bbb
+PKG_HASH:=3fc505ff8d8a2d24c68aac5e6b4783997d5a086966ff3de8b05a0ceb27e5e23b
 
 PKG_FIXUP:=autoreconf
 
@@ -24,7 +24,7 @@ include $(INCLUDE_DIR)/package.mk
 define Package/kexec-tools
   SECTION:=utils
   CATEGORY:=Utilities
-  DEPENDS:=@KERNEL_KEXEC @armeb||@arm||@i386||@powerpc64||@mipsel||@mips +KEXEC_ZLIB:zlib +KEXEC_LZMA:liblzma
+  DEPENDS:=@armeb||@arm||@i386||@x86_64||@powerpc64||@mipsel||@mips +KEXEC_ZLIB:zlib +KEXEC_LZMA:liblzma
   TITLE:=Kernel boots kernel
   URL:=http://kernel.org/pub/linux/kernel/people/horms/kexec-tools/
   MAINTAINER:=Florian Fainelli <florian@openwrt.org>
@@ -40,7 +40,7 @@ define Package/kexec-tools/config
 	source "$(SOURCE)/Config.in"
 endef
 
-KEXEC_TARGET_NAME:=$(call qstrip,$(CONFIG_KEXEC_TOOLS_TARGET_NAME))-linux-$(TARGET_SUFFIX)
+KEXEC_TARGET_NAME:=$(ARCH)-linux-$(TARGET_SUFFIX)
 
 CONFIGURE_ARGS = \
 		--target=$(KEXEC_TARGET_NAME) \
@@ -55,7 +55,8 @@ CONFIGURE_ARGS = \
 		--libexecdir=/usr/lib \
 		--sysconfdir=/etc \
 		$(if $(CONFIG_KEXEC_ZLIB),--with,--without)-zlib \
-		$(if $(CONFIG_KEXEC_LZMA),--with,--without)-lzma
+		$(if $(CONFIG_KEXEC_LZMA),--with,--without)-lzma \
+		TARGET_LD="$(TARGET_CROSS)ld"
 
 TARGET_CFLAGS += -ffunction-sections -fdata-sections
 TARGET_LDFLAGS += -Wl,--gc-sections

+ 0 - 171
package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch

@@ -1,171 +0,0 @@
-From d606837b56d46eb7f815b5d85f07fcc3f1555d00 Mon Sep 17 00:00:00 2001
-From: Yousong Zhou <yszhou4tech@gmail.com>
-Date: Sun, 1 Feb 2015 00:10:07 +0800
-Subject: [PATCH 1/5] Fix zlib/lzma decompression.
-
-Let {zlib,lzma}_decompress_file() return NULL if anything wrong happened
-to allow the other method to have a chance to run.
-
-Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
-Signed-off-by: Simon Horman <horms@verge.net.au>
----
- kexec/lzma.c |   33 ++++++++++++++++++++++-----------
- kexec/zlib.c |   57 +++++++++++++++++++++++++++++++++++----------------------
- 2 files changed, 57 insertions(+), 33 deletions(-)
-
-diff --git a/kexec/lzma.c b/kexec/lzma.c
-index 939aeb3..5bfccb7 100644
---- a/kexec/lzma.c
-+++ b/kexec/lzma.c
-@@ -162,13 +162,16 @@ char *lzma_decompress_file(const char *filename, off_t *r_size)
- 	off_t size, allocated;
- 	ssize_t result;
- 
--	if (!filename) {
--		*r_size = 0;
--		return 0;
--	}
-+	dbgprintf("Try LZMA decompression.\n");
-+
-+	*r_size = 0;
-+	if (!filename)
-+		return NULL;
-+
- 	fp = lzopen(filename, "rb");
- 	if (fp == 0) {
--		die("Cannot open `%s'\n", filename);
-+		dbgprintf("Cannot open `%s'\n", filename);
-+		return NULL;
- 	}
- 	size = 0;
- 	allocated = 65536;
-@@ -183,17 +186,25 @@ char *lzma_decompress_file(const char *filename, off_t *r_size)
- 			if ((errno == EINTR) || (errno == EAGAIN))
- 				continue;
- 
--			die ("read on %s of %ld bytes failed\n",
--				filename, (allocated - size) + 0UL);
-+			dbgprintf("%s: read on %s of %ld bytes failed\n",
-+				__func__, filename, (allocated - size) + 0UL);
-+			break;
- 		}
- 		size += result;
--	} while(result > 0);
--	result = lzclose(fp);
--	if (result != LZMA_OK) {
--		die ("Close of %s failed\n", filename);
-+	} while (result > 0);
-+
-+	if (lzclose(fp) != LZMA_OK) {
-+		dbgprintf("%s: Close of %s failed\n", __func__, filename);
-+		goto fail;
- 	}
-+	if (result < 0)
-+		goto fail;
-+
- 	*r_size =  size;
- 	return buf;
-+fail:
-+	free(buf);
-+	return NULL;
- }
- #else
- char *lzma_decompress_file(const char *UNUSED(filename), off_t *UNUSED(r_size))
-diff --git a/kexec/zlib.c b/kexec/zlib.c
-index d44df12..7170ac3 100644
---- a/kexec/zlib.c
-+++ b/kexec/zlib.c
-@@ -15,29 +15,39 @@
- #include <ctype.h>
- #include <zlib.h>
- 
-+static void _gzerror(gzFile fp, int *errnum, const char **errmsg)
-+{
-+	*errmsg = gzerror(fp, errnum);
-+	if (*errnum == Z_ERRNO) {
-+		*errmsg = strerror(*errnum);
-+	}
-+}
-+
- char *zlib_decompress_file(const char *filename, off_t *r_size)
- {
- 	gzFile fp;
- 	int errnum;
- 	const char *msg;
- 	char *buf;
--	off_t size, allocated;
-+	off_t size = 0, allocated;
- 	ssize_t result;
- 
-+	dbgprintf("Try gzip decompression.\n");
-+
-+	*r_size = 0;
- 	if (!filename) {
--		*r_size = 0;
--		return 0;
-+		return NULL;
- 	}
- 	fp = gzopen(filename, "rb");
- 	if (fp == 0) {
--		msg = gzerror(fp, &errnum);
--		if (errnum == Z_ERRNO) {
--			msg = strerror(errno);
--		}
--		fprintf(stderr, "Cannot open `%s': %s\n", filename, msg);
-+		_gzerror(fp, &errnum, &msg);
-+		dbgprintf("Cannot open `%s': %s\n", filename, msg);
-+		return NULL;
-+	}
-+	if (gzdirect(fp)) {
-+		/* It's not in gzip format */
- 		return NULL;
- 	}
--	size = 0;
- 	allocated = 65536;
- 	buf = xmalloc(allocated);
- 	do {
-@@ -49,25 +59,28 @@ char *zlib_decompress_file(const char *filename, off_t *r_size)
- 		if (result < 0) {
- 			if ((errno == EINTR) || (errno == EAGAIN))
- 				continue;
--
--			msg = gzerror(fp, &errnum);
--			if (errnum == Z_ERRNO) {
--				msg = strerror(errno);
--			}
--			die ("read on %s of %ld bytes failed: %s\n",
--				filename, (allocated - size) + 0UL, msg);
-+			_gzerror(fp, &errnum, &msg);
-+			dbgprintf("Read on %s of %ld bytes failed: %s\n",
-+					filename, (allocated - size) + 0UL, msg);
-+			size = 0;
-+			goto fail;
- 		}
- 		size += result;
- 	} while(result > 0);
-+
-+fail:
- 	result = gzclose(fp);
- 	if (result != Z_OK) {
--		msg = gzerror(fp, &errnum);
--		if (errnum == Z_ERRNO) {
--			msg = strerror(errno);
--		}
--		die ("Close of %s failed: %s\n", filename, msg);
-+		_gzerror(fp, &errnum, &msg);
-+		dbgprintf(" Close of %s failed: %s\n", filename, msg);
-+	}
-+
-+	if (size > 0) {
-+		*r_size = size;
-+	} else {
-+		free(buf);
-+		buf = NULL;
- 	}
--	*r_size =  size;
- 	return buf;
- }
- #else
--- 
-1.7.10.4
-

+ 0 - 52
package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch

@@ -1,52 +0,0 @@
-From eb20884c9bbc42bdf1ccace4444f3ce72657d7d8 Mon Sep 17 00:00:00 2001
-From: Yousong Zhou <yszhou4tech@gmail.com>
-Date: Tue, 9 Sep 2014 20:15:16 +0800
-Subject: [PATCH 2/5] configure.ac: apply necessary quotes to result of macro
- expansion.
-
-This can fix the following error when searching for lzma support and
-while at it also apply the practice to other uses of the same pattern.
-
-	checking for lzma_code in -llzma... ./configure: line 4756: ac_fn_c_try_link: command not found
-
-Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
----
- configure.ac |   12 ++++++------
- 1 file changed, 6 insertions(+), 6 deletions(-)
-
-diff --git a/configure.ac b/configure.ac
-index db93331..c410e90 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -152,22 +152,22 @@ AC_CHECK_PROG([DIRNAME],  dirname,  dirname,  "no", [$PATH])
- dnl See if I have a usable copy of zlib available
- if test "$with_zlib" = yes ; then
- 	AC_CHECK_HEADER(zlib.h,
--		AC_CHECK_LIB(z, inflateInit_, ,
--		AC_MSG_NOTICE([zlib support disabled])))
-+		[AC_CHECK_LIB(z, inflateInit_, ,
-+		AC_MSG_NOTICE([zlib support disabled]))])
- fi
- 
- dnl See if I have a usable copy of lzma available
- if test "$with_lzma" = yes ; then
- 	AC_CHECK_HEADER(lzma.h,
--		AC_CHECK_LIB(lzma, lzma_code, ,
--		AC_MSG_NOTICE([lzma support disabled])))
-+		[AC_CHECK_LIB(lzma, lzma_code, ,
-+		AC_MSG_NOTICE([lzma support disabled]))])
- fi
- 
- dnl find Xen control stack libraries
- if test "$with_xen" = yes ; then
- 	AC_CHECK_HEADER(xenctrl.h,
--		AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
--		AC_MSG_NOTICE([Xen support disabled])))
-+		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
-+		AC_MSG_NOTICE([Xen support disabled]))])
- fi
- 
- dnl ---Sanity checks
--- 
-1.7.10.4
-

+ 0 - 35
package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch

@@ -1,35 +0,0 @@
-From 89d455d785190203b1d3a8766c8babb8c1688fc3 Mon Sep 17 00:00:00 2001
-From: Yousong Zhou <yszhou4tech@gmail.com>
-Date: Mon, 9 Feb 2015 19:51:25 +0800
-Subject: [PATCH 3/5] mips: fix compiler warning on printing 64-bit integer.
-
-
-Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
----
- kexec/arch/mips/crashdump-mips.c |    3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
-index e7840e0..98c9f7c 100644
---- a/kexec/arch/mips/crashdump-mips.c
-+++ b/kexec/arch/mips/crashdump-mips.c
-@@ -22,6 +22,7 @@
- #include <stdlib.h>
- #include <errno.h>
- #include <limits.h>
-+#include <inttypes.h>
- #include <elf.h>
- #include <sys/types.h>
- #include <sys/stat.h>
-@@ -52,7 +53,7 @@ static int get_kernel_paddr(struct crash_elf_info *elf_info)
- 
- 	if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) {
- 		elf_info->kern_paddr_start = start;
--		dbgprintf("kernel load physical addr start = 0x%lx\n", start);
-+		dbgprintf("kernel load physical addr start = 0x%" PRIu64 "\n", start);
- 		return 0;
- 	}
- 
--- 
-1.7.10.4
-

+ 0 - 30
package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch

@@ -1,30 +0,0 @@
-From 904e9ae892b0592c916a013869e3be3d830e0155 Mon Sep 17 00:00:00 2001
-From: Yousong Zhou <yszhou4tech@gmail.com>
-Date: Mon, 9 Feb 2015 20:11:04 +0800
-Subject: [PATCH 4/5] mips: remove unused variable.
-
-Fixes the following compilation warning.
-
-	kexec/arch/mips/crashdump-mips.c:151:6: warning: unused variable 'i' [-Wunused-variable]
-
-Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
----
- kexec/arch/mips/crashdump-mips.c |    2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
-index 98c9f7c..dc68cb4 100644
---- a/kexec/arch/mips/crashdump-mips.c
-+++ b/kexec/arch/mips/crashdump-mips.c
-@@ -148,7 +148,7 @@ static int exclude_crash_reserve_region(int *nr_ranges)
- static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
- {
- 	const char iomem[] = "/proc/iomem";
--	int i, memory_ranges = 0;
-+	int memory_ranges = 0;
- 	char line[MAX_LINE];
- 	FILE *fp;
- 	unsigned long long start, end;
--- 
-1.7.10.4
-

+ 0 - 30
package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch

@@ -1,30 +0,0 @@
-From 00e75179b3b4b80e6e58d29a2bd948f97682fd00 Mon Sep 17 00:00:00 2001
-From: Yousong Zhou <yszhou4tech@gmail.com>
-Date: Mon, 9 Feb 2015 20:28:14 +0800
-Subject: [PATCH 5/5] mips: fix warning about implicit type conversion.
-
-Fixes the following warning.
-
-	kexec/arch/mips/kexec-elf-mips.c:161:16: warning: assignment makes integer from pointer without a cast [enabled by default]
-
-Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
----
- kexec/arch/mips/kexec-elf-mips.c |    2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
-index a27d986..8a6419a 100644
---- a/kexec/arch/mips/kexec-elf-mips.c
-+++ b/kexec/arch/mips/kexec-elf-mips.c
-@@ -158,7 +158,7 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
- 	if (info->kexec_flags & KEXEC_ON_CRASH)
- 		/* In case of crashdump segment[0] is kernel.
- 		 * Put cmdline just after it. */
--		cmdline_addr = info->segment[0].mem +
-+		cmdline_addr = (unsigned long)info->segment[0].mem +
- 				info->segment[0].memsz;
- 	else
- 		cmdline_addr = 0;
--- 
-1.7.10.4
-

+ 20 - 0
package/boot/kexec-tools/patches/100-format_string_fix.patch

@@ -0,0 +1,20 @@
+--- a/kexec/arch/i386/kexec-elf-x86.c
++++ b/kexec/arch/i386/kexec-elf-x86.c
+@@ -296,6 +296,6 @@ out:
+ 	free(command_line);
+ 	free(modified_cmdline);
+ 	if (error_msg)
+-		die(error_msg);
++		die("%s", error_msg);
+ 	return result;
+ }
+--- a/kexec/arch/x86_64/kexec-elf-x86_64.c
++++ b/kexec/arch/x86_64/kexec-elf-x86_64.c
+@@ -276,6 +276,6 @@ out:
+ 	free(command_line);
+ 	free(modified_cmdline);
+ 	if (error_msg)
+-		die(error_msg);
++		die("%s", error_msg);
+ 	return result;
+ }

+ 11 - 0
package/boot/kexec-tools/patches/110-fix-vmcore-dmsg-compilation-error.patch

@@ -0,0 +1,11 @@
+--- a/vmcore-dmesg/vmcore-dmesg.c
++++ b/vmcore-dmesg/vmcore-dmesg.c
+@@ -1,6 +1,8 @@
+ #define _XOPEN_SOURCE 600
+ #define _LARGEFILE_SOURCE 1
+ #define _FILE_OFFSET_BITS 64
++#define _GNU_SOURCE
++
+ #include <endian.h>
+ #include <byteswap.h>
+ #include <stdio.h>

+ 46 - 0
package/boot/kobs-ng/Makefile

@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2013-2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=kobs-ng
+PKG_VERSION:=5.4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=imx-kobs-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/
+PKG_HASH:=85171b46068ac47c42fedb8104167bf9afd33dd9527ed127e1ca2eb29d7a86bf
+PKG_BUILD_DIR:=$(BUILD_DIR)/imx-kobs-$(PKG_VERSION)
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=COPYING
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/kobs-ng
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=Application for writing bootstreams to NAND flash
+  DEPENDS:=@TARGET_imx6
+endef
+
+define Package/kobs-ng/description
+ The kobs-ng application writes a bootstream to NAND flash with the proper
+ FCB/DBBT headers and replicated streams.
+endef
+
+define Build/Prepare
+	$(call Build/Prepare/Default)
+	echo "const char* git_sha = \"$(PKG_VERSION)\";" > $(PKG_BUILD_DIR)/autoversion.h
+endef
+
+define Package/kobs-ng/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/kobs-ng $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,kobs-ng))

+ 23 - 0
package/boot/kobs-ng/patches/001-compile.patch

@@ -0,0 +1,23 @@
+--- a/src/mtd.c
++++ b/src/mtd.c
+@@ -28,6 +28,7 @@
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <stddef.h>
+ #include <fcntl.h>
+ #include <ctype.h>
+ #include <errno.h>
+--- a/src/mtd.h
++++ b/src/mtd.h
+@@ -25,8 +25,10 @@
+ #ifndef MTD_H
+ #define MTD_H
+ 
++#define _GNU_SOURCE
+ #include <mtd/mtd-user.h>
+ #include <endian.h>
++#include <fcntl.h>
+ 
+ #include "BootControlBlocks.h"
+ #include "rom_nand_hamming_code_ecc.h"

+ 45 - 0
package/boot/kobs-ng/patches/002-add-init-size-param.patch

@@ -0,0 +1,45 @@
+Add --chip_0_size param to override the size of the mtd partition which is
+required if the SPL does not occupy the entire partition. For Gateworks
+Ventana boards the 'uboot' partition contains both the SPL and uboot.
+--- a/src/main.c
++++ b/src/main.c
+@@ -94,6 +94,7 @@ void usage(void)
+ 	"  [KOBS] boot structures config options\n"
+ 	"    --chip_0_device_path=<path> .......... Device of boot (default /dev/mtd0)\n"
+ 	"    --chip_1_device_path=<path> .......... The second chip in case of multichip NAND\n"
++	"    --chip_0_size=<size> ................. Override size of chip_0 device\n"
+ 	"    --search_exponent=<value> ............ NCB field (default 2)\n"
+ 	"    --data_setup_time=<value> ............ NCB field (default 80)\n"
+ 	"    --data_hold_time=<value> ............. NCB field (default 60)\n"
+--- a/src/mtd.c
++++ b/src/mtd.c
+@@ -876,6 +876,11 @@ struct mtd_data *mtd_open(const struct m
+ 			goto out;
+ 		}
+ 
++		/* override MTD size */
++		if (md->cfg.chip_0_size) {
++			miu->size = md->cfg.chip_0_size;
++		}
++
+ 		/* verify it's a nand */
+ 		if (miu->type != MTD_NANDFLASH
+ 			&& miu->type != MTD_MLCNANDFLASH) {
+@@ -3385,7 +3390,7 @@ static const struct {
+ } mtd_int_args[] = {
+ 	ARG_IGNORE(chip_count),
+ 	ARG_IGNORE(chip_0_offset),
+-	ARG_IGNORE(chip_0_size),
++	ARG(chip_0_size),
+ 	ARG_IGNORE(chip_1_offset),
+ 	ARG_IGNORE(chip_1_size),
+ 	ARG(search_exponent),
+@@ -3578,7 +3583,7 @@ void mtd_cfg_dump(struct mtd_config *cfg
+ //	Pd(chip_count);
+ 	Ps(chip_0_device_path);
+ //	Pd(chip_0_offset);
+-//	Pd(chip_0_size);
++	Pd(chip_0_size);
+ 	Ps(chip_1_device_path);
+ //	Pd(chip_1_offset);
+ //	Pd(chip_1_size);

+ 45 - 0
package/boot/kobs-ng/patches/003-raw-mode.patch

@@ -0,0 +1,45 @@
+The downstream Freescale vendor kernel has a patch that allows determining
+if raw NAND flash mode is provided via a debugfs file. This is not present
+in upstream kernels, but the raw access support was added in the 3.19
+kernel, so we will check the kernel version if we can't find the file.
+--- a/src/mtd.c
++++ b/src/mtd.c
+@@ -34,6 +34,7 @@
+ #include <errno.h>
+ #include <sys/types.h>
+ #include <sys/ioctl.h>
++#include <sys/utsname.h>
+ 
+ #include "mtd.h"
+ #include "rand.h"
+@@ -808,15 +809,27 @@ struct mtd_data *mtd_open(const struct m
+ 	md->cfg = *cfg;
+ 
+ 	/* check if use new raw access mode */
++	/* by looking for debugfs from fsl patch */
++	md->raw_mode_flag = 0;
+ 	fp = fopen("/sys/kernel/debug/gpmi-nand/raw_mode", "r");
+ 	if (!fp) {
+-		md->raw_mode_flag = 0;
+-		vp(md, "mtd: use legacy raw access mode\n");
++		/* fallback to kernel version: raw access added in 3.19 */
++		struct utsname uts;
++		if (!uname(&uts)) {
++			int major = 0, minor = 0;
++			sscanf(uts.release, "%d.%d", &major, &minor);
++			vp(md, "mtd: Linux %d.%d\n", major, minor);
++			if ((major << 8 | minor) > (3 << 8 | 18))
++				md->raw_mode_flag = 1;
++		}
+ 	} else {
+ 		fclose(fp);
+ 		md->raw_mode_flag = 1;
+-		vp(md, "mtd: use new bch layout raw access mode\n");
+ 	}
++	if (md->raw_mode_flag)
++		vp(md, "mtd: use new bch layout raw access mode\n");
++	else
++		vp(md, "mtd: use legacy raw access mode\n");
+ 
+ 	if (plat_config_data->m_u32UseMultiBootArea) {
+ 

+ 27 - 0
package/boot/kobs-ng/patches/004-fix-cal_nfc_geometry.patch

@@ -0,0 +1,27 @@
+The Freescale downstream vendor kernel has a patch that exports the bch
+flash geometry via a debugfs file. This is not available in mainline linux
+kernels so the fallback method calculates the geometry based on known info
+from the mtd partition. A bug exists in this funcion where it fails to
+assume that block0 ECC is the same as the other blocks by default.
+--- a/src/mtd.c
++++ b/src/mtd.c
+@@ -610,7 +610,7 @@ static int cal_nfc_geometry(struct mtd_d
+ 	/* The two are fixed, please change them when the driver changes. */
+ 	geo->metadata_size_in_bytes = 10;
+ 	geo->gf_len = 13;
+-	geo->ecc_chunkn_size_in_bytes = 512;
++	geo->ecc_chunkn_size_in_bytes = geo->ecc_chunk0_size_in_bytes = 512;
+ 
+ 	if (mtd->oobsize > geo->ecc_chunkn_size_in_bytes) {
+ 		geo->gf_len = 14;
+@@ -700,8 +700,9 @@ int parse_nfc_geometry(struct mtd_data *
+ 	unsigned int       value;
+ 
+ 	if (!plat_config_data->m_u32UseNfcGeo) {
++		/* fsl kernel patch provides bch_geometry via debugfs */
+ 		if (!(node = fopen(dbg_geometry_node_path, "r"))) {
+-			fprintf(stderr, "Cannot open BCH geometry node: \"%s\"",
++			fprintf(stderr, "Cannot open BCH geometry node: \"%s\"\n",
+ 				dbg_geometry_node_path);
+ 			return cal_nfc_geometry(md);
+ 		}

+ 47 - 0
package/boot/rbcfg/Makefile

@@ -0,0 +1,47 @@
+#
+# Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=rbcfg
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+PKG_FLAGS:=nonshared
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/rbcfg
+  SECTION:=utils
+  CATEGORY:=Utilities
+  SUBMENU:=Boot Loaders
+  TITLE:=RouterBOOT configuration tool
+  DEPENDS:=@TARGET_ar71xx
+endef
+
+define Package/rbcfg/description
+ This package contains an utility to manipulate RouterBOOT configuration on the
+ MikroTIK RB-4XX devices.
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		CC="$(TARGET_CC)" \
+		CFLAGS="$(TARGET_CFLAGS) -Wall" \
+		LDFLAGS="$(TARGET_LDFLAGS)"
+endef
+
+define Package/rbcfg/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/rbcfg $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,rbcfg))

+ 14 - 0
package/boot/rbcfg/src/Makefile

@@ -0,0 +1,14 @@
+CC = gcc
+CFLAGS = -Wall
+OBJS = main.o cyg_crc32.o
+
+all: rbcfg
+
+%.o: %.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
+rbcfg: $(OBJS)
+	$(CC) -o $@ $(OBJS)
+
+clean:
+	rm -f rbcfg *.o

+ 109 - 0
package/boot/rbcfg/src/cyg_crc.h

@@ -0,0 +1,109 @@
+//==========================================================================
+//
+//      crc.h
+//
+//      Interface for the CRC algorithms.
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2002 Andrew Lunn
+//
+// eCos 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 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):    Andrew Lunn
+// Contributors: Andrew Lunn
+// Date:         2002-08-06
+// Purpose:
+// Description:
+//
+// This code is part of eCos (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef _SERVICES_CRC_CRC_H_
+#define _SERVICES_CRC_CRC_H_
+
+#if 0
+#include <cyg/infra/cyg_type.h>
+#else
+#include <stdint.h>
+typedef uint32_t cyg_uint32;
+typedef uint16_t cyg_uint16;
+#endif
+
+#ifndef __externC
+# ifdef __cplusplus
+#  define __externC extern "C"
+# else
+#  define __externC extern
+# endif
+#endif
+
+// Compute a CRC, using the POSIX 1003 definition
+
+__externC cyg_uint32
+cyg_posix_crc32(unsigned char *s, int len);
+
+// Gary S. Brown's 32 bit CRC
+
+__externC cyg_uint32
+cyg_crc32(unsigned char *s, int len);
+
+// Gary S. Brown's 32 bit CRC, but accumulate the result from a
+// previous CRC calculation
+
+__externC cyg_uint32
+cyg_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
+
+// Ethernet FCS Algorithm
+
+__externC cyg_uint32
+cyg_ether_crc32(unsigned char *s, int len);
+
+// Ethernet FCS algorithm, but accumulate the result from a previous
+// CRC calculation.
+
+__externC cyg_uint32
+cyg_ether_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
+
+// 16 bit CRC with polynomial x^16+x^12+x^5+1
+
+__externC cyg_uint16
+cyg_crc16(unsigned char *s, int len);
+
+#endif // _SERVICES_CRC_CRC_H_
+
+
+

+ 172 - 0
package/boot/rbcfg/src/cyg_crc32.c

@@ -0,0 +1,172 @@
+//==========================================================================
+//
+//      crc32.c
+//
+//      Gary S. Brown's 32 bit CRC
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2002 Gary Thomas
+//
+// eCos 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 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):    gthomas
+// Contributors: gthomas,asl
+// Date:         2001-01-31
+// Purpose:      
+// Description:  
+//              
+// This code is part of eCos (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#if 0
+#include <cyg/crc/crc.h>
+#else
+#include "cyg_crc.h"
+#endif
+
+  /* ====================================================================== */
+  /*  COPYRIGHT (C) 1986 Gary S. Brown.  You may use this program, or       */
+  /*  code or tables extracted from it, as desired without restriction.     */
+  /*                                                                        */
+  /*  First, the polynomial itself and its table of feedback terms.  The    */
+  /*  polynomial is                                                         */
+  /*  X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0   */
+  /*                                                                        */
+  /* ====================================================================== */
+
+static const cyg_uint32 crc32_tab[] = {
+      0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+      0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+      0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+      0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
+      0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
+      0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
+      0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
+      0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+      0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
+      0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
+      0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
+      0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
+      0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
+      0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
+      0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
+      0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+      0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
+      0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
+      0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
+      0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
+      0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
+      0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
+      0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
+      0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+      0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
+      0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
+      0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
+      0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
+      0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
+      0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
+      0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
+      0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+      0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
+      0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
+      0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
+      0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
+      0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
+      0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
+      0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
+      0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+      0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
+      0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
+      0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
+      0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
+      0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
+      0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
+      0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
+      0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+      0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
+      0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
+      0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
+      0x2d02ef8dL
+   };
+
+/* This is the standard Gary S. Brown's 32 bit CRC algorithm, but
+   accumulate the CRC into the result of a previous CRC. */
+cyg_uint32 
+cyg_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
+{
+  int i;
+
+  for (i = 0;  i < len;  i++) {
+    crc32val = crc32_tab[(crc32val ^ s[i]) & 0xff] ^ (crc32val >> 8);
+  }
+  return crc32val;
+}
+
+/* This is the standard Gary S. Brown's 32 bit CRC algorithm */
+cyg_uint32
+cyg_crc32(unsigned char *s, int len)
+{
+  return (cyg_crc32_accumulate(0,s,len));
+}
+
+/* Return a 32-bit CRC of the contents of the buffer accumulating the
+   result from a previous CRC calculation. This uses the Ethernet FCS
+   algorithm.*/
+cyg_uint32
+cyg_ether_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
+{
+  int i;
+
+  if (s == 0) return 0L;
+  
+  crc32val = crc32val ^ 0xffffffff;
+  for (i = 0;  i < len;  i++) {
+      crc32val = crc32_tab[(crc32val ^ s[i]) & 0xff] ^ (crc32val >> 8);
+  }
+  return crc32val ^ 0xffffffff;
+}
+
+/* Return a 32-bit CRC of the contents of the buffer, using the
+   Ethernet FCS algorithm. */
+cyg_uint32
+cyg_ether_crc32(unsigned char *s, int len)
+{
+  return cyg_ether_crc32_accumulate(0,s,len);
+}
+
+

+ 791 - 0
package/boot/rbcfg/src/main.c

@@ -0,0 +1,791 @@
+/*
+ *  RouterBOOT configuration utility
+ *
+ *  Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <linux/limits.h>
+
+#include "rbcfg.h"
+#include "cyg_crc.h"
+
+#define RBCFG_TMP_FILE	"/tmp/.rbcfg"
+#define RBCFG_MTD_NAME	"soft_config"
+
+#define RB_ERR_NOTFOUND		1
+#define RB_ERR_INVALID		2
+#define RB_ERR_NOMEM		3
+#define RB_ERR_IO		4
+
+#define ARRAY_SIZE(_a)	(sizeof((_a)) / sizeof((_a)[0]))
+
+struct rbcfg_ctx {
+	char		*mtd_device;
+	char		*tmp_file;
+	char		*buf;
+	unsigned	buflen;
+};
+
+struct rbcfg_value {
+	const char		*name;
+	const char		*desc;
+	union {
+		uint32_t	u32;
+		const char	*raw;
+	} val;
+};
+
+#define RBCFG_ENV_TYPE_U32	0
+
+struct rbcfg_env {
+	const char			*name;
+	int				type;
+	uint16_t			id;
+	const struct rbcfg_value	*values;
+	int				num_values;
+};
+
+#define CMD_FLAG_USES_CFG	0x01
+
+struct rbcfg_command {
+	const char	*command;
+	const char	*usage;
+	int		flags;
+	int		(*exec)(int argc, const char *argv[]);
+};
+
+static void usage(void);
+
+/* Globals */
+
+static struct rbcfg_ctx *rbcfg_ctx;
+static char *rbcfg_name;
+
+#define CFG_U32(_name, _desc, _val) { 	\
+	.name		= (_name),	\
+	.desc		= (_desc),	\
+	.val.u32	= (_val),	\
+}
+
+static const struct rbcfg_value rbcfg_boot_delay[] = {
+	CFG_U32("1", "1 second", RB_BOOT_DELAY_1SEC),
+	CFG_U32("2", "2 seconds", RB_BOOT_DELAY_2SEC),
+	CFG_U32("3", "3 seconds", RB_BOOT_DELAY_3SEC),
+	CFG_U32("4", "4 seconds", RB_BOOT_DELAY_4SEC),
+	CFG_U32("5", "5 seconds", RB_BOOT_DELAY_5SEC),
+	CFG_U32("6", "6 seconds", RB_BOOT_DELAY_6SEC),
+	CFG_U32("7", "7 seconds", RB_BOOT_DELAY_7SEC),
+	CFG_U32("8", "8 seconds", RB_BOOT_DELAY_8SEC),
+	CFG_U32("9", "9 seconds", RB_BOOT_DELAY_9SEC),
+};
+
+static const struct rbcfg_value rbcfg_boot_device[] = {
+	CFG_U32("eth", "boot over Ethernet",
+		RB_BOOT_DEVICE_ETHER),
+	CFG_U32("nandeth", "boot from NAND, if fail then Ethernet",
+		RB_BOOT_DEVICE_NANDETH),
+	CFG_U32("ethnand", "boot Ethernet once, then NAND",
+		RB_BOOT_DEVICE_ETHONCE),
+	CFG_U32("nand", "boot from NAND only",
+		RB_BOOT_DEVICE_NANDONLY),
+};
+
+static const struct rbcfg_value rbcfg_boot_key[] = {
+	CFG_U32("any", "any key", RB_BOOT_KEY_ANY),
+	CFG_U32("del", "<Delete> key only", RB_BOOT_KEY_DEL),
+};
+
+static const struct rbcfg_value rbcfg_boot_protocol[] = {
+	CFG_U32("bootp", "BOOTP protocol", RB_BOOT_PROTOCOL_BOOTP),
+	CFG_U32("dhcp", "DHCP protocol", RB_BOOT_PROTOCOL_DHCP),
+};
+
+static const struct rbcfg_value rbcfg_uart_speed[] = {
+	CFG_U32("115200", "", RB_UART_SPEED_115200),
+	CFG_U32("57600", "", RB_UART_SPEED_57600),
+	CFG_U32("38400", "", RB_UART_SPEED_38400),
+	CFG_U32("19200", "", RB_UART_SPEED_19200),
+	CFG_U32("9600", "", RB_UART_SPEED_9600),
+	CFG_U32("4800", "", RB_UART_SPEED_4800),
+	CFG_U32("2400", "", RB_UART_SPEED_2400),
+	CFG_U32("1200", "", RB_UART_SPEED_1200),
+	CFG_U32("off", "disable console output", RB_UART_SPEED_OFF),
+};
+
+static const struct rbcfg_value rbcfg_cpu_mode[] = {
+	CFG_U32("powersave", "power save", RB_CPU_MODE_POWERSAVE),
+	CFG_U32("regular", "regular (better for -0c environment)",
+		RB_CPU_MODE_REGULAR),
+};
+
+static const struct rbcfg_value rbcfg_booter[] = {
+	CFG_U32("regular", "load regular booter", RB_BOOTER_REGULAR),
+	CFG_U32("backup", "force backup-booter loading", RB_BOOTER_BACKUP),
+};
+
+static const struct rbcfg_env rbcfg_envs[] = {
+	{
+		.name		= "boot_delay",
+		.id		= RB_ID_BOOT_DELAY,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_boot_delay,
+		.num_values	= ARRAY_SIZE(rbcfg_boot_delay),
+	}, {
+		.name		= "boot_device",
+		.id		= RB_ID_BOOT_DEVICE,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_boot_device,
+		.num_values	= ARRAY_SIZE(rbcfg_boot_device),
+	}, {
+		.name		= "boot_key",
+		.id		= RB_ID_BOOT_KEY,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_boot_key,
+		.num_values	= ARRAY_SIZE(rbcfg_boot_key),
+	}, {
+		.name		= "boot_protocol",
+		.id		= RB_ID_BOOT_PROTOCOL,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_boot_protocol,
+		.num_values	= ARRAY_SIZE(rbcfg_boot_protocol),
+	}, {
+		.name		= "booter",
+		.id		= RB_ID_BOOTER,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_booter,
+		.num_values	= ARRAY_SIZE(rbcfg_booter),
+	}, {
+		.name		= "cpu_mode",
+		.id		= RB_ID_CPU_MODE,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_cpu_mode,
+		.num_values	= ARRAY_SIZE(rbcfg_cpu_mode),
+	}, {
+		.name		= "uart_speed",
+		.id		= RB_ID_UART_SPEED,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_uart_speed,
+		.num_values	= ARRAY_SIZE(rbcfg_uart_speed),
+	}
+};
+
+static inline uint16_t
+get_u16(const void *buf)
+{
+	const uint8_t *p = buf;
+
+	return ((uint16_t) p[1] + ((uint16_t) p[0] << 8));
+}
+
+static inline uint32_t
+get_u32(const void *buf)
+{
+	const uint8_t *p = buf;
+
+	return ((uint32_t) p[3] + ((uint32_t) p[2] << 8) +
+	       ((uint32_t) p[1] << 16) + ((uint32_t) p[0] << 24));
+}
+
+static inline void
+put_u32(void *buf, uint32_t val)
+{
+	uint8_t *p = buf;
+
+	p[3] = val & 0xff;
+	p[2] = (val >> 8) & 0xff;
+	p[1] = (val >> 16) & 0xff;
+	p[0] = (val >> 24) & 0xff;
+}
+
+static int
+rbcfg_find_tag(struct rbcfg_ctx *ctx, uint16_t tag_id, uint16_t *tag_len,
+	       void **tag_data)
+{
+	uint16_t id;
+	uint16_t len;
+	char *buf = ctx->buf;
+	unsigned int buflen = ctx->buflen;
+	int ret = RB_ERR_NOTFOUND;
+
+	/* skip magic and CRC value */
+	buf += 8;
+	buflen -= 8;
+
+	while (buflen > 2) {
+		len = get_u16(buf);
+		buf += 2;
+		buflen -= 2;
+
+		if (buflen < 2)
+			break;
+
+		id = get_u16(buf);
+		buf += 2;
+		buflen -= 2;
+
+		if (id == RB_ID_TERMINATOR)
+			break;
+
+		if (buflen < len)
+			break;
+
+		if (id == tag_id) {
+			*tag_len = len;
+			*tag_data = buf;
+			ret = 0;
+			break;
+		}
+
+		buf += len;
+		buflen -= len;
+	}
+
+	if (ret)
+		fprintf(stderr, "no tag found with id=%u\n", tag_id);
+
+	return ret;
+}
+
+static int
+rbcfg_get_u32(struct rbcfg_ctx *ctx, uint16_t id, uint32_t *val)
+{
+	void *tag_data;
+	uint16_t tag_len;
+	int err;
+
+	err = rbcfg_find_tag(ctx, id, &tag_len, &tag_data);
+	if (err)
+		return err;
+
+	*val = get_u32(tag_data);
+	return 0;
+}
+
+static int
+rbcfg_set_u32(struct rbcfg_ctx *ctx, uint16_t id, uint32_t val)
+{
+	void *tag_data;
+	uint16_t tag_len;
+	int err;
+
+	err = rbcfg_find_tag(ctx, id, &tag_len, &tag_data);
+	if (err)
+		return err;
+
+	put_u32(tag_data, val);
+	return 0;
+}
+
+char *rbcfg_find_mtd(const char *name, int *erase_size)
+{
+	FILE *f;
+	int mtd_num;
+	char dev[PATH_MAX];
+	char *ret = NULL;
+	struct stat s;
+	int err;
+
+	f = fopen("/proc/mtd", "r");
+	if (!f)
+		return NULL;
+
+	while (1) {
+		char *p;
+		p = fgets(dev, sizeof(dev), f);
+		if (!p)
+			break;
+
+		if (!strstr(dev, name))
+			continue;
+
+		err = sscanf(dev, "mtd%d: %08x", &mtd_num, erase_size);
+		if (err != 2)
+			break;
+
+		sprintf(dev, "/dev/mtdblock%d", mtd_num);
+		err = stat(dev, &s);
+		if (err < 0)
+			break;
+
+		if ((s.st_mode & S_IFBLK) == 0)
+			break;
+
+		ret = malloc(strlen(dev) + 1);
+		if (ret == NULL)
+			break;
+
+		strncpy(ret, dev, strlen(dev) + 1);
+		break;
+	}
+
+	fclose(f);
+	return ret;
+}
+
+static int
+rbcfg_check_tmp(struct rbcfg_ctx *ctx)
+{
+	struct stat s;
+	int err;
+
+	err = stat(ctx->tmp_file, &s);
+	if (err < 0)
+		return 0;
+
+	if ((s.st_mode & S_IFREG) == 0)
+		return 0;
+
+	if (s.st_size != ctx->buflen)
+		return 0;
+
+	return 1;
+}
+
+static int
+rbcfg_load(struct rbcfg_ctx *ctx)
+{
+	uint32_t magic;
+	uint32_t crc_orig, crc;
+	char *name;
+	int tmp;
+	int fd;
+	int err;
+
+	tmp = rbcfg_check_tmp(ctx);
+	name = (tmp) ? ctx->tmp_file : ctx->mtd_device;
+
+	fd = open(name, O_RDONLY);
+	if (fd < 0) {
+		fprintf(stderr, "unable to open %s\n", name);
+		err = RB_ERR_IO;
+		goto err;
+	}
+
+	err = read(fd, ctx->buf, ctx->buflen);
+	if (err != ctx->buflen) {
+		fprintf(stderr, "unable to read from %s\n", name);
+		err = RB_ERR_IO;
+		goto err_close;
+	}
+
+	magic = get_u32(ctx->buf);
+	if (magic != RB_MAGIC_SOFT) {
+		fprintf(stderr, "invalid configuration\n");
+		err = RB_ERR_INVALID;
+		goto err_close;
+	}
+
+	crc_orig = get_u32(ctx->buf + 4);
+	put_u32(ctx->buf + 4, 0);
+	crc = cyg_ether_crc32((unsigned char *) ctx->buf, ctx->buflen);
+	if (crc != crc_orig) {
+		fprintf(stderr, "configuration has CRC error\n");
+		err = RB_ERR_INVALID;
+		goto err_close;
+	}
+
+	err = 0;
+
+ err_close:
+	close(fd);
+ err:
+	return err;
+}
+
+static int
+rbcfg_open()
+{
+	char *mtd_device;
+	struct rbcfg_ctx *ctx;
+	int buflen;
+	int err;
+
+	mtd_device = rbcfg_find_mtd(RBCFG_MTD_NAME, &buflen);
+	if (!mtd_device) {
+		fprintf(stderr, "unable to find configuration\n");
+		return RB_ERR_NOTFOUND;
+	}
+
+	ctx = malloc(sizeof(struct rbcfg_ctx) + buflen);
+	if (ctx == NULL) {
+		err = RB_ERR_NOMEM;
+		goto err_free_mtd;
+	}
+
+	ctx->mtd_device = mtd_device;
+	ctx->tmp_file = RBCFG_TMP_FILE;
+	ctx->buflen = buflen;
+	ctx->buf = (char *) &ctx[1];
+
+	err = rbcfg_load(ctx);
+	if (err)
+		goto err_free_ctx;
+
+	rbcfg_ctx = ctx;
+	return 0;
+
+ err_free_ctx:
+	free(ctx);
+ err_free_mtd:
+	free(mtd_device);
+	return err;
+}
+
+static int
+rbcfg_update(int tmp)
+{
+	struct rbcfg_ctx *ctx = rbcfg_ctx;
+	char *name;
+	uint32_t crc;
+	int fd;
+	int err;
+
+	put_u32(ctx->buf, RB_MAGIC_SOFT);
+	put_u32(ctx->buf + 4, 0);
+	crc = cyg_ether_crc32((unsigned char *) ctx->buf, ctx->buflen);
+	put_u32(ctx->buf + 4, crc);
+
+	name = (tmp) ? ctx->tmp_file : ctx->mtd_device;
+	fd = open(name, O_WRONLY | O_CREAT);
+	if (fd < 0) {
+		fprintf(stderr, "unable to open %s for writing\n", name);
+		err = RB_ERR_IO;
+		goto out;
+	}
+
+	err = write(fd, ctx->buf, ctx->buflen);
+	if (err != ctx->buflen) {
+		err = RB_ERR_IO;
+		goto out_close;
+	}
+
+	fsync(fd);
+	err = 0;
+
+ out_close:
+	close(fd);
+ out:
+	return err;
+}
+
+static void
+rbcfg_close(void)
+{
+	struct rbcfg_ctx *ctx;
+
+	ctx = rbcfg_ctx;
+	free(ctx->mtd_device);
+	free(ctx);
+}
+
+static const struct rbcfg_value *
+rbcfg_env_find(const struct rbcfg_env *env, const char *name)
+{
+	unsigned i;
+
+	for (i = 0; i < env->num_values; i++) {
+		const struct rbcfg_value *v = &env->values[i];
+
+		if (strcmp(v->name, name) == 0)
+			return v;
+	}
+
+	return NULL;
+}
+
+static const struct rbcfg_value *
+rbcfg_env_find_u32(const struct rbcfg_env *env, uint32_t val)
+{
+	unsigned i;
+
+	for (i = 0; i < env->num_values; i++) {
+		const struct rbcfg_value *v = &env->values[i];
+
+		if (v->val.u32 == val)
+			return v;
+	}
+
+	return NULL;
+}
+
+static const char *
+rbcfg_env_get_u32(const struct rbcfg_env *env)
+{
+	const struct rbcfg_value *v;
+	uint32_t val;
+	int err;
+
+	err = rbcfg_get_u32(rbcfg_ctx, env->id, &val);
+	if (err)
+		return NULL;
+
+	v = rbcfg_env_find_u32(env, val);
+	if (v == NULL) {
+		fprintf(stderr, "unknown value %08x found for %s\n",
+			val, env->name);
+		return NULL;
+	}
+
+	return v->name;
+}
+
+static int
+rbcfg_env_set_u32(const struct rbcfg_env *env, const char *data)
+{
+	const struct rbcfg_value *v;
+	int err;
+
+	v = rbcfg_env_find(env, data);
+	if (v == NULL) {
+		fprintf(stderr, "invalid value '%s'\n", data);
+		return RB_ERR_INVALID;
+	}
+
+	err = rbcfg_set_u32(rbcfg_ctx, env->id, v->val.u32);
+	return err;
+}
+
+static const char *
+rbcfg_env_get(const struct rbcfg_env *env)
+{
+	const char *ret = NULL;
+
+	switch (env->type) {
+	case RBCFG_ENV_TYPE_U32:
+		ret = rbcfg_env_get_u32(env);
+		break;
+	}
+
+	return ret;
+}
+
+static int
+rbcfg_env_set(const struct rbcfg_env *env, const char *data)
+{
+	int ret = 0;
+
+	switch (env->type) {
+	case RBCFG_ENV_TYPE_U32:
+		ret = rbcfg_env_set_u32(env, data);
+		break;
+	}
+
+	return ret;
+}
+
+static int
+rbcfg_cmd_apply(int argc, const char *argv[])
+{
+	return rbcfg_update(0);
+}
+
+static int
+rbcfg_cmd_help(int argc, const char *argv[])
+{
+	usage();
+	return 0;
+}
+
+static int
+rbcfg_cmd_get(int argc, const char *argv[])
+{
+	int err = RB_ERR_NOTFOUND;
+	int i;
+
+	if (argc != 1) {
+		usage();
+		return RB_ERR_INVALID;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+		const struct rbcfg_env *env = &rbcfg_envs[i];
+		const char *value;
+
+		if (strcmp(env->name, argv[0]))
+			continue;
+
+		value = rbcfg_env_get(env);
+		if (value) {
+			fprintf(stdout, "%s\n", value);
+			err = 0;
+		}
+		break;
+	}
+
+	return err;
+}
+
+static int
+rbcfg_cmd_set(int argc, const char *argv[])
+{
+	int err = RB_ERR_INVALID;
+	int i;
+
+	if (argc != 2) {
+		/* not enough parameters */
+		usage();
+		return RB_ERR_INVALID;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+		const struct rbcfg_env *env = &rbcfg_envs[i];
+
+		if (strcmp(env->name, argv[0]))
+			continue;
+
+		err = rbcfg_env_set(env, argv[1]);
+		if (err == 0)
+			err = rbcfg_update(1);
+		break;
+	}
+
+	return err;
+}
+
+static int
+rbcfg_cmd_show(int argc, const char *argv[])
+{
+	int i;
+
+	if (argc != 0) {
+		usage();
+		return RB_ERR_INVALID;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+		const struct rbcfg_env *env = &rbcfg_envs[i];
+		const char *value;
+
+		value = rbcfg_env_get(env);
+		if (value)
+			fprintf(stdout, "%s=%s\n", env->name, value);
+	}
+
+	return 0;
+}
+
+static const struct rbcfg_command rbcfg_commands[] = {
+	{
+		.command	= "apply",
+		.usage		= "apply\n"
+				  "\t- write configuration to the mtd device",
+		.flags		= CMD_FLAG_USES_CFG,
+		.exec		= rbcfg_cmd_apply,
+	}, {
+		.command	= "help",
+		.usage		= "help\n"
+				  "\t- show this screen",
+		.exec		= rbcfg_cmd_help,
+	}, {
+		.command	= "get",
+		.usage		= "get <name>\n"
+				  "\t- get value of the configuration option <name>",
+		.flags		= CMD_FLAG_USES_CFG,
+		.exec		= rbcfg_cmd_get,
+	}, {
+		.command	= "set",
+		.usage		= "set <name> <value>\n"
+				  "\t- set value of the configuration option <name> to <value>",
+		.flags		= CMD_FLAG_USES_CFG,
+		.exec		= rbcfg_cmd_set,
+	}, {
+		.command	= "show",
+		.usage		= "show\n"
+				  "\t- show value of all configuration options",
+		.flags		= CMD_FLAG_USES_CFG,
+		.exec		= rbcfg_cmd_show,
+	}
+};
+
+static void
+usage(void)
+{
+	char buf[255];
+	int len;
+	int i;
+
+	fprintf(stderr, "Usage: %s <command>\n", rbcfg_name);
+
+	fprintf(stderr, "\nCommands:\n");
+	for (i = 0; i < ARRAY_SIZE(rbcfg_commands); i++) {
+		const struct rbcfg_command *cmd;
+		cmd = &rbcfg_commands[i];
+
+		len = snprintf(buf, sizeof(buf), "%s", cmd->usage);
+		buf[len] = '\0';
+		fprintf(stderr, "%s\n", buf);
+	}
+
+	fprintf(stderr, "\nConfiguration options:\n");
+	for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+		const struct rbcfg_env *env;
+		int j;
+
+		env = &rbcfg_envs[i];
+		fprintf(stderr, "\n%s:\n", env->name);
+		for (j = 0; j < env->num_values; j++) {
+			const struct rbcfg_value *v = &env->values[j];
+			fprintf(stderr, "\t%-12s %s\n", v->name, v->desc);
+		}
+	}
+	fprintf(stderr, "\n");
+}
+
+int main(int argc, const char *argv[])
+{
+	const struct rbcfg_command *cmd = NULL;
+	int ret;
+	int i;
+
+	rbcfg_name = (char *) argv[0];
+
+	if (argc < 2) {
+		usage();
+		return EXIT_FAILURE;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(rbcfg_commands); i++) {
+		if (strcmp(rbcfg_commands[i].command, argv[1]) == 0) {
+			cmd = &rbcfg_commands[i];
+			break;
+		}
+	}
+
+	if (cmd == NULL) {
+		fprintf(stderr, "unknown command '%s'\n", argv[1]);
+		usage();
+		return EXIT_FAILURE;
+	}
+
+	argc -= 2;
+	argv += 2;
+
+	if (cmd->flags & CMD_FLAG_USES_CFG) {
+		ret = rbcfg_open();
+		if (ret)
+			return EXIT_FAILURE;
+	}
+
+	ret = cmd->exec(argc, argv);
+
+	if (cmd->flags & CMD_FLAG_USES_CFG)
+		rbcfg_close();
+
+	if (ret)
+		return EXIT_FAILURE;
+
+	return EXIT_SUCCESS;
+}

+ 75 - 0
package/boot/rbcfg/src/rbcfg.h

@@ -0,0 +1,75 @@
+/*
+ *  Mikrotik's RouterBOOT configuration defines
+ *
+ *  Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ *
+ */
+
+#ifndef _RBCFG_H
+#define _RBCFG_H
+
+/*
+ * Magic numbers
+ */
+#define RB_MAGIC_SOFT	0x74666f53 /* 'Soft' */
+
+/*
+ * ID values for Software settings
+ */
+#define RB_ID_TERMINATOR	0
+#define RB_ID_UART_SPEED	1
+#define RB_ID_BOOT_DELAY	2
+#define RB_ID_BOOT_DEVICE	3
+#define RB_ID_BOOT_KEY		4
+#define RB_ID_CPU_MODE		5
+#define RB_ID_FW_VERSION	6
+#define RB_ID_SOFT_07		7
+#define RB_ID_SOFT_08		8
+#define RB_ID_BOOT_PROTOCOL	9
+#define RB_ID_SOFT_10		10
+#define RB_ID_SOFT_11		11
+#define RB_ID_BOOTER		13
+
+#define RB_UART_SPEED_115200	0
+#define RB_UART_SPEED_57600	1
+#define RB_UART_SPEED_38400	2
+#define RB_UART_SPEED_19200	3
+#define RB_UART_SPEED_9600	4
+#define RB_UART_SPEED_4800	5
+#define RB_UART_SPEED_2400	6
+#define RB_UART_SPEED_1200	7
+#define RB_UART_SPEED_OFF	8
+
+#define RB_BOOT_DELAY_1SEC	1
+#define RB_BOOT_DELAY_2SEC	2
+#define RB_BOOT_DELAY_3SEC	3
+#define RB_BOOT_DELAY_4SEC	4
+#define RB_BOOT_DELAY_5SEC	5
+#define RB_BOOT_DELAY_6SEC	6
+#define RB_BOOT_DELAY_7SEC	7
+#define RB_BOOT_DELAY_8SEC	8
+#define RB_BOOT_DELAY_9SEC	9
+
+#define RB_BOOT_DEVICE_ETHER	0
+#define RB_BOOT_DEVICE_NANDETH	1
+#define RB_BOOT_DEVICE_CFCARD	2
+#define RB_BOOT_DEVICE_ETHONCE	3
+#define RB_BOOT_DEVICE_NANDONLY	5
+
+#define RB_BOOT_KEY_ANY		0
+#define RB_BOOT_KEY_DEL		1
+
+#define RB_CPU_MODE_POWERSAVE	0
+#define RB_CPU_MODE_REGULAR	1
+
+#define RB_BOOT_PROTOCOL_BOOTP	0
+#define RB_BOOT_PROTOCOL_DHCP	1
+
+#define RB_BOOTER_REGULAR	0
+#define RB_BOOTER_BACKUP	1
+
+#endif /* _RBCFG_H */

+ 3 - 1
package/boot/yamonenv/Makefile

@@ -13,10 +13,12 @@ PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)_gruen.4g__$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://downloads.openwrt.org/sources/
-PKG_MD5SUM:=a3e4f24155aa3ba5aa502bc63fdaa6ad
+PKG_HASH:=466eca9cdad2c15e957fb9ce7d0b6927ecd17d85c4cc2dff37e97a3e6b209c67
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
 
+PKG_FLAGS:=nonshared
+
 include $(INCLUDE_DIR)/package.mk
 
 define Package/yamonenv

+ 0 - 35
package/kernel/avila-wdt/Makefile

@@ -1,35 +0,0 @@
-#
-# Copyright (C) 2008 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-include $(INCLUDE_DIR)/kernel.mk
-
-PKG_NAME:=avila-wdt
-PKG_RELEASE:=1
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/avila-wdt
-  SUBMENU:=Other modules
-  TITLE:=GPIO hardware watchdog driver for modified Avila boards
-  DEPENDS:=@GPIO_SUPPORT @TARGET_ixp4xx
-  FILES:=$(PKG_BUILD_DIR)/avila-wdt.ko
-  AUTOLOAD:=$(call AutoLoad,10,avila-wdt)
-endef
-
-MAKE_OPTS:= \
-	ARCH="$(LINUX_KARCH)" \
-	CROSS_COMPILE="$(TARGET_CROSS)" \
-	SUBDIRS="$(PKG_BUILD_DIR)"
-
-define Build/Compile
-	$(MAKE) -C "$(LINUX_DIR)" \
-		$(MAKE_OPTS) \
-		modules
-endef
-
-$(eval $(call KernelPackage,avila-wdt))

+ 0 - 1
package/kernel/avila-wdt/src/Makefile

@@ -1 +0,0 @@
-obj-m := avila-wdt.o

+ 0 - 231
package/kernel/avila-wdt/src/avila-wdt.c

@@ -1,231 +0,0 @@
-/*
- * avila-wdt.c 
- * Copyright (C) 2009 Felix Fietkau <nbd@nbd.name>
- *
- * based on:
- * drivers/char/watchdog/ixp4xx_wdt.c
- *
- * Watchdog driver for Intel IXP4xx network processors
- *
- * Author: Deepak Saxena <dsaxena@plexity.net>
- *
- * Copyright 2004 (c) MontaVista, Software, Inc.
- * Based on sa1100 driver, Copyright (C) 2000 Oleg Drokin <green@crimea.edu>
- *
- * This file is licensed under  the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/jiffies.h>
-#include <linux/timer.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/watchdog.h>
-#include <linux/init.h>
-#include <linux/bitops.h>
-#include <linux/uaccess.h>
-#include <mach/hardware.h>
-
-static int nowayout = WATCHDOG_NOWAYOUT;
-static int heartbeat = 20;	/* (secs) Default is 20 seconds */
-static unsigned long wdt_status;
-static atomic_t wdt_counter;
-struct timer_list wdt_timer;
-
-#define	WDT_IN_USE		0
-#define	WDT_OK_TO_CLOSE		1
-#define WDT_RUNNING		2
-
-static void wdt_refresh(unsigned long data)
-{
-	if (test_bit(WDT_RUNNING, &wdt_status)) {
-		if (atomic_dec_and_test(&wdt_counter)) {
-			printk(KERN_WARNING "Avila watchdog expired, expect a reboot soon!\n");
-			clear_bit(WDT_RUNNING, &wdt_status);
-			return;
-		}
-	}
-
-	/* strobe to the watchdog */
-	gpio_line_set(14, IXP4XX_GPIO_HIGH);
-	gpio_line_set(14, IXP4XX_GPIO_LOW);
-
-	mod_timer(&wdt_timer, jiffies + msecs_to_jiffies(500));
-}
-
-static void wdt_enable(void)
-{
-	atomic_set(&wdt_counter, heartbeat * 2);
-
-	/* Disable clock generator output on GPIO 14/15 */
-	*IXP4XX_GPIO_GPCLKR &= ~(1 << 8);
-
-	/* activate GPIO 14 out */
-	gpio_line_config(14, IXP4XX_GPIO_OUT);
-	gpio_line_set(14, IXP4XX_GPIO_LOW);
-
-	if (!test_bit(WDT_RUNNING, &wdt_status))
-		wdt_refresh(0);
-	set_bit(WDT_RUNNING, &wdt_status);
-}
-
-static void wdt_disable(void)
-{
-	/* Re-enable clock generator output on GPIO 14/15 */
-	*IXP4XX_GPIO_GPCLKR |= (1 << 8);
-}
-
-static int avila_wdt_open(struct inode *inode, struct file *file)
-{
-	if (test_and_set_bit(WDT_IN_USE, &wdt_status))
-		return -EBUSY;
-
-	clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
-	wdt_enable();
-	return nonseekable_open(inode, file);
-}
-
-static ssize_t
-avila_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
-{
-	if (len) {
-		if (!nowayout) {
-			size_t i;
-
-			clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
-
-			for (i = 0; i != len; i++) {
-				char c;
-
-				if (get_user(c, data + i))
-					return -EFAULT;
-				if (c == 'V')
-					set_bit(WDT_OK_TO_CLOSE, &wdt_status);
-			}
-		}
-		wdt_enable();
-	}
-	return len;
-}
-
-static struct watchdog_info ident = {
-	.options	= WDIOF_CARDRESET | WDIOF_MAGICCLOSE |
-			  WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
-	.identity	= "Avila Watchdog",
-};
-
-
-static long avila_wdt_ioctl(struct file *file, unsigned int cmd,
-							unsigned long arg)
-{
-	int ret = -ENOTTY;
-	int time;
-
-	switch (cmd) {
-	case WDIOC_GETSUPPORT:
-		ret = copy_to_user((struct watchdog_info *)arg, &ident,
-				   sizeof(ident)) ? -EFAULT : 0;
-		break;
-
-	case WDIOC_GETSTATUS:
-		ret = put_user(0, (int *)arg);
-		break;
-
-	case WDIOC_KEEPALIVE:
-		wdt_enable();
-		ret = 0;
-		break;
-
-	case WDIOC_SETTIMEOUT:
-		ret = get_user(time, (int *)arg);
-		if (ret)
-			break;
-
-		if (time <= 0 || time > 60) {
-			ret = -EINVAL;
-			break;
-		}
-
-		heartbeat = time;
-		wdt_enable();
-		/* Fall through */
-
-	case WDIOC_GETTIMEOUT:
-		ret = put_user(heartbeat, (int *)arg);
-		break;
-	}
-	return ret;
-}
-
-static int avila_wdt_release(struct inode *inode, struct file *file)
-{
-	if (test_bit(WDT_OK_TO_CLOSE, &wdt_status))
-		wdt_disable();
-	else
-		printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - "
-					"timer will not stop\n");
-	clear_bit(WDT_IN_USE, &wdt_status);
-	clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
-
-	return 0;
-}
-
-
-static const struct file_operations avila_wdt_fops = {
-	.owner		= THIS_MODULE,
-	.llseek		= no_llseek,
-	.write		= avila_wdt_write,
-	.unlocked_ioctl	= avila_wdt_ioctl,
-	.open		= avila_wdt_open,
-	.release	= avila_wdt_release,
-};
-
-static struct miscdevice avila_wdt_miscdev = {
-	.minor		= WATCHDOG_MINOR + 1,
-	.name		= "avila_watchdog",
-	.fops		= &avila_wdt_fops,
-};
-
-static int __init avila_wdt_init(void)
-{
-	int ret;
-
-	init_timer(&wdt_timer);
-	wdt_timer.expires = 0;
-	wdt_timer.data = 0;
-	wdt_timer.function = wdt_refresh;
-	ret = misc_register(&avila_wdt_miscdev);
-	if (ret == 0)
-		printk(KERN_INFO "Avila Watchdog Timer: heartbeat %d sec\n",
-			heartbeat);
-	return ret;
-}
-
-static void __exit avila_wdt_exit(void)
-{
-	misc_deregister(&avila_wdt_miscdev);
-	del_timer(&wdt_timer);
-	wdt_disable();
-}
-
-
-module_init(avila_wdt_init);
-module_exit(avila_wdt_exit);
-
-MODULE_AUTHOR("Felix Fietkau <nbd@nbd.name>");
-MODULE_DESCRIPTION("Gateworks Avila Hardware Watchdog");
-
-module_param(heartbeat, int, 0);
-MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds (default 20s)");
-
-module_param(nowayout, int, 0);
-MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
-
-MODULE_LICENSE("GPL");
-MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
-

+ 4 - 4
package/kernel/kmod-sched-cake/Makefile

@@ -12,10 +12,10 @@ PKG_NAME:=sched-cake
 PKG_RELEASE:=1
 
 PKG_SOURCE_PROTO:=git
-PKG_SOURCE_URL:=https://github.com/kdarbyshirebryant/sch_cake.git
-PKG_SOURCE_DATE:=2016-12-19
-PKG_SOURCE_VERSION:=70c8eb766d5afcf3cf187594b7cd776da92bee3c
-PKG_MIRROR_HASH:=16174db5dad0a5b5ba522d4cfc058cff9851ed013a3a05166b04eb127bb12a24
+PKG_SOURCE_URL:=https://github.com/dtaht/sch_cake.git
+PKG_SOURCE_DATE:=2017-01-28
+PKG_SOURCE_VERSION:=9789742cfc596d48583ba4cdbc8f38d026121fa6
+PKG_MIRROR_HASH:=2a5afc45722c28ca8778eb50452eb305306e7898b32d7d6d73d3e77edf3cce99
 PKG_MAINTAINER:=Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
 
 include $(INCLUDE_DIR)/package.mk

+ 1 - 1
package/kernel/linux/modules/can.mk

@@ -241,7 +241,7 @@ $(eval $(call KernelPackage,can-c-can))
 define KernelPackage/can-c-can-platform
   TITLE:=Platform Bus based BOSCH C_CAN/D_CAN driver
   KCONFIG:=CONFIG_CAN_C_CAN_PLATFORM
-  DEPENDS:=kmod-can-c-can +LINUX_4_1:kmod-regmap
+  DEPENDS:=kmod-can-c-can +!LINUX_3_18:kmod-regmap
   FILES:=$(LINUX_DIR)/drivers/net/can/c_can/c_can_platform.ko
   AUTOLOAD:=$(call AutoProbe,c_can_platform)
   $(call AddDepends/can)

+ 1 - 1
package/kernel/linux/modules/netfilter.mk

@@ -495,7 +495,7 @@ $(eval $(call KernelPackage,ipt-tproxy))
 
 define KernelPackage/ipt-tee
   TITLE:=TEE support
-  DEPENDS:=+kmod-ipt-conntrack @!LINUX_4_4
+  DEPENDS:=+kmod-ipt-conntrack
   KCONFIG:= \
   	CONFIG_NETFILTER_XT_TARGET_TEE
   FILES:= \

+ 3 - 3
package/kernel/linux/modules/netsupport.mk

@@ -736,7 +736,7 @@ $(eval $(call KernelPackage,mppe))
 
 
 SCHED_MODULES = $(patsubst $(LINUX_DIR)/net/sched/%.ko,%,$(wildcard $(LINUX_DIR)/net/sched/*.ko))
-SCHED_MODULES_CORE = sch_ingress sch_fq_codel sch_hfsc cls_fw cls_route cls_flow cls_tcindex cls_u32 em_u32 act_mirred act_skbedit
+SCHED_MODULES_CORE = sch_ingress sch_fq_codel sch_hfsc sch_htb sch_tbf cls_fw cls_route cls_flow cls_tcindex cls_u32 em_u32 act_mirred act_skbedit
 SCHED_MODULES_FILTER = $(SCHED_MODULES_CORE) act_connmark sch_netem
 SCHED_MODULES_EXTRA = $(filter-out $(SCHED_MODULES_FILTER),$(SCHED_MODULES))
 SCHED_FILES = $(patsubst %,$(LINUX_DIR)/net/sched/%.ko,$(filter $(SCHED_MODULES_CORE),$(SCHED_MODULES)))
@@ -748,6 +748,8 @@ define KernelPackage/sched-core
   KCONFIG:= \
 	CONFIG_NET_SCHED=y \
 	CONFIG_NET_SCH_HFSC \
+	CONFIG_NET_SCH_HTB \
+	CONFIG_NET_SCH_TBF \
 	CONFIG_NET_SCH_INGRESS \
 	CONFIG_NET_SCH_FQ_CODEL \
 	CONFIG_NET_CLS=y \
@@ -789,12 +791,10 @@ define KernelPackage/sched
   KCONFIG:= \
 	CONFIG_NET_SCH_CODEL \
 	CONFIG_NET_SCH_DSMARK \
-	CONFIG_NET_SCH_HTB \
 	CONFIG_NET_SCH_FIFO \
 	CONFIG_NET_SCH_GRED \
 	CONFIG_NET_SCH_PRIO \
 	CONFIG_NET_SCH_RED \
-	CONFIG_NET_SCH_TBF \
 	CONFIG_NET_SCH_SFQ \
 	CONFIG_NET_SCH_TEQL \
 	CONFIG_NET_SCH_FQ \

+ 32 - 0
package/kernel/linux/modules/nls.mk

@@ -147,6 +147,38 @@ endef
 $(eval $(call KernelPackage,nls-cp932))
 
 
+define KernelPackage/nls-cp936
+  SUBMENU:=Native Language Support
+  TITLE:=Codepage 936 (Simplified Chinese)
+  KCONFIG:=CONFIG_NLS_CODEPAGE_936
+  FILES:=$(LINUX_DIR)/fs/nls/nls_cp936.ko
+  AUTOLOAD:=$(call AutoLoad,25,nls_cp936)
+  $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp936/description
+  Kernel module for NLS Codepage 936 (Simplified Chinese)
+endef
+
+$(eval $(call KernelPackage,nls-cp936))
+
+
+define KernelPackage/nls-cp950
+  SUBMENU:=Native Language Support
+  TITLE:=Codepage 950 (Traditional Chinese)
+  KCONFIG:=CONFIG_NLS_CODEPAGE_950
+  FILES:=$(LINUX_DIR)/fs/nls/nls_cp950.ko
+  AUTOLOAD:=$(call AutoLoad,25,nls_cp950)
+  $(call AddDepends/nls)
+endef
+
+define KernelPackage/nls-cp950/description
+  Kernel module for NLS Codepage 950 (Traditional Chinese)
+endef
+
+$(eval $(call KernelPackage,nls-cp950))
+
+
 define KernelPackage/nls-cp1250
   SUBMENU:=Native Language Support
   TITLE:=Codepage 1250 (Eastern Europe)

+ 3 - 3
package/kernel/mac80211/Makefile

@@ -10,13 +10,13 @@ include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=mac80211
 
-PKG_VERSION:=2016-10-08
+PKG_VERSION:=2017-01-31
 PKG_RELEASE:=1
 PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
 PKG_BACKPORT_VERSION:=
-PKG_HASH:=4f6350e3b75815060bfdf47ef266ad613c7bfea5b7b1dc4552dee69e1bebe4fb
+PKG_HASH:=75e6d39e34cf156212a2509172a4a62b673b69eb4a1d9aaa565f7fa719fa2317
 
-PKG_SOURCE:=compat-wireless-$(PKG_VERSION)$(PKG_BACKPORT_VERSION).tar.bz2
+PKG_SOURCE:=compat-wireless-$(PKG_VERSION)$(PKG_BACKPORT_VERSION).tar.xz
 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/compat-wireless-$(PKG_VERSION)
 PKG_BUILD_PARALLEL:=1
 

+ 1 - 1
package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh

@@ -756,7 +756,7 @@ drv_mac80211_setup() {
 	for_each_interface "ap" mac80211_prepare_vif
 
 	[ -n "$hostapd_ctrl" ] && {
-		/usr/sbin/hostapd -P /var/run/wifi-$phy.pid -B "$hostapd_conf_file"
+		/usr/sbin/hostapd -s -P /var/run/wifi-$phy.pid -B "$hostapd_conf_file"
 		ret="$?"
 		wireless_add_process "$(cat /var/run/wifi-$phy.pid)" "/usr/sbin/hostapd" 1
 		[ "$ret" != 0 ] && {

+ 1 - 1
package/kernel/mac80211/files/lib/wifi/mac80211.sh

@@ -122,7 +122,7 @@ detect_mac80211() {
 			set wireless.default_radio${devidx}.device=radio${devidx}
 			set wireless.default_radio${devidx}.network=lan
 			set wireless.default_radio${devidx}.mode=ap
-			set wireless.default_radio${devidx}.ssid=LEDE
+			set wireless.default_radio${devidx}.ssid=libreCMC
 			set wireless.default_radio${devidx}.encryption=none
 EOF
 		uci -q commit wireless

+ 3 - 3
package/kernel/mac80211/patches/002-change_allconfig.patch

@@ -1,6 +1,6 @@
 --- a/kconf/conf.c
 +++ b/kconf/conf.c
-@@ -593,40 +593,12 @@ int main(int ac, char **av)
+@@ -594,40 +594,12 @@ int main(int ac, char **av)
  	case oldconfig:
  	case listnewconfig:
  	case olddefconfig:
@@ -44,7 +44,7 @@
  		break;
 --- a/kconf/confdata.c
 +++ b/kconf/confdata.c
-@@ -1169,6 +1169,8 @@ bool conf_set_all_new_symbols(enum conf_
+@@ -1170,6 +1170,8 @@ bool conf_set_all_new_symbols(enum conf_
  	}
  	bool has_changed = false;
  
@@ -53,7 +53,7 @@
  	for_all_symbols(i, sym) {
  		if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID))
  			continue;
-@@ -1212,8 +1214,6 @@ bool conf_set_all_new_symbols(enum conf_
+@@ -1213,8 +1215,6 @@ bool conf_set_all_new_symbols(enum conf_
  
  	}
  

+ 0 - 11
package/kernel/mac80211/patches/004-fix_duplicate_skcipher_backport.patch

@@ -1,11 +0,0 @@
---- a/compat/Makefile
-+++ b/compat/Makefile
-@@ -35,8 +35,6 @@ compat-$(CPTCFG_KERNEL_4_6) += backport-
- 
- compat-$(CPTCFG_BPAUTO_BUILD_CRYPTO_CCM) += crypto-ccm.o
- compat-$(CPTCFG_BPAUTO_CRYPTO_SKCIPHER) += crypto-skcipher.o
--skcipher-objs += crypto-skcipher.o
--obj-$(CPTCFG_BPAUTO_CRYPTO_SKCIPHER) += skcipher.o
- compat-$(CPTCFG_BPAUTO_BUILD_WANT_DEV_COREDUMP) += drivers-base-devcoredump.o
- compat-$(CPTCFG_BPAUTO_RHASHTABLE) += lib-rhashtable.o
- cordic-objs += lib-cordic.o

+ 28 - 0
package/kernel/mac80211/patches/004-kconfig_backport_fix.patch

@@ -0,0 +1,28 @@
+--- a/backport-include/linux/kconfig.h
++++ b/backport-include/linux/kconfig.h
+@@ -5,6 +5,8 @@
+ #include_next <linux/kconfig.h>
+ #endif
+ 
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
++
+ #ifndef __ARG_PLACEHOLDER_1
+ #define __ARG_PLACEHOLDER_1 0,
+ #define config_enabled(cfg) _config_enabled(cfg)
+@@ -16,6 +18,7 @@
+  * 3.1 - 3.3 had a broken version of this, so undef
+  * (they didn't have __ARG_PLACEHOLDER_1)
+  */
++
+ #undef IS_ENABLED
+ #define IS_ENABLED(option) \
+         (config_enabled(option) || config_enabled(option##_MODULE))
+@@ -24,6 +27,8 @@
+ #undef IS_BUILTIN
+ #define IS_BUILTIN(option) config_enabled(option)
+ 
++#endif
++
+ #ifndef IS_REACHABLE
+ /*
+  * IS_REACHABLE(CONFIG_FOO) evaluates to 1 if the currently compiled

+ 0 - 22
package/kernel/mac80211/patches/005-backport_skb_get_hash_perturb.patch

@@ -1,22 +0,0 @@
---- a/backport-include/linux/skbuff.h
-+++ b/backport-include/linux/skbuff.h
-@@ -305,6 +305,19 @@ static inline void skb_free_frag(void *d
- {
- 	put_page(virt_to_head_page(data));
- }
-+
-+#include <net/flow_keys.h>
-+#include <linux/jhash.h>
-+
-+static inline u32 skb_get_hash_perturb(struct sk_buff *skb, u32 key)
-+{
-+	struct flow_keys keys;
-+
-+	skb_flow_dissect(skb, &keys);
-+	return jhash_3words((__force u32)keys.dst,
-+			    (__force u32)keys.src ^ keys.ip_proto,
-+			    (__force u32)keys.ports, key);
-+}
- #endif
- 
- #endif /* __BACKPORT_SKBUFF_H */

+ 152 - 0
package/kernel/mac80211/patches/005-revert-devcoredump.patch

@@ -0,0 +1,152 @@
+--- a/compat/Makefile
++++ b/compat/Makefile
+@@ -35,8 +35,6 @@ compat-$(CPTCFG_KERNEL_4_6) += backport-
+ 
+ compat-$(CPTCFG_BPAUTO_BUILD_CRYPTO_CCM) += crypto-ccm.o
+ compat-$(CPTCFG_BPAUTO_CRYPTO_SKCIPHER) += crypto-skcipher.o
+-skcipher-objs += crypto-skcipher.o
+-obj-$(CPTCFG_BPAUTO_CRYPTO_SKCIPHER) += skcipher.o
+ compat-$(CPTCFG_BPAUTO_BUILD_WANT_DEV_COREDUMP) += drivers-base-devcoredump.o
+ compat-$(CPTCFG_BPAUTO_RHASHTABLE) += lib-rhashtable.o
+ cordic-objs += lib-cordic.o
+--- a/compat/drivers-base-devcoredump.c
++++ b/compat/drivers-base-devcoredump.c
+@@ -31,6 +31,7 @@
+ #include <linux/slab.h>
+ #include <linux/fs.h>
+ #include <linux/workqueue.h>
++#include "backports.h"
+ 
+ static struct class devcd_class;
+ 
+@@ -40,6 +41,10 @@ static bool devcd_disabled;
+ /* if data isn't read by userspace after 5 minutes then delete it */
+ #define DEVCD_TIMEOUT	(HZ * 60 * 5)
+ 
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
++static struct bin_attribute devcd_attr_data;
++#endif
++
+ struct devcd_entry {
+ 	struct device devcd_dev;
+ 	void *data;
+@@ -69,8 +74,7 @@ static void devcd_dev_release(struct dev
+ 	 * a struct device to know when it goes away?
+ 	 */
+ 	if (devcd->failing_dev->kobj.sd)
+-		sysfs_delete_link(&devcd->failing_dev->kobj, &dev->kobj,
+-				  "devcoredump");
++		sysfs_remove_link(&devcd->failing_dev->kobj, "devcoredump");
+ 
+ 	put_device(devcd->failing_dev);
+ 	kfree(devcd);
+@@ -82,6 +86,9 @@ static void devcd_del(struct work_struct
+ 
+ 	devcd = container_of(wk, struct devcd_entry, del_wk.work);
+ 
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
++	device_remove_bin_file(&devcd->devcd_dev, &devcd_attr_data);
++#endif
+ 	device_del(&devcd->devcd_dev);
+ 	put_device(&devcd->devcd_dev);
+ }
+@@ -115,6 +122,7 @@ static struct bin_attribute devcd_attr_d
+ 	.write = devcd_data_write,
+ };
+ 
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+ static struct bin_attribute *devcd_dev_bin_attrs[] = {
+ 	&devcd_attr_data, NULL,
+ };
+@@ -126,6 +134,7 @@ static const struct attribute_group devc
+ static const struct attribute_group *devcd_dev_groups[] = {
+ 	&devcd_dev_group, NULL,
+ };
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0) */
+ 
+ static int devcd_free(struct device *dev, void *data)
+ {
+@@ -160,18 +169,11 @@ static ssize_t disabled_store(struct cla
+ 
+ 	return count;
+ }
+-static CLASS_ATTR_RW(disabled);
+ 
+-static struct attribute *devcd_class_attrs[] = {
+-	&class_attr_disabled.attr,
+-	NULL,
++static struct class_attribute devcd_class_attrs[] = {
++	__ATTR_RW(disabled),
++	__ATTR_NULL
+ };
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+-ATTRIBUTE_GROUPS(devcd_class);
+-#else
+-#define BP_ATTR_GRP_STRUCT device_attribute
+-ATTRIBUTE_GROUPS_BACKPORT(devcd_class);
+-#endif
+ 
+ static struct class devcd_class = {
+ 	.name		= "devcoredump",
+@@ -179,10 +181,8 @@ static struct class devcd_class = {
+ 	.dev_release	= devcd_dev_release,
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+ 	.dev_groups	= devcd_dev_groups,
+-#else
+-	.dev_attrs = devcd_class_dev_attrs,
+ #endif
+-	.class_groups	= devcd_class_groups,
++	.class_attrs	= devcd_class_attrs,
+ };
+ 
+ static ssize_t devcd_readv(char *buffer, loff_t offset, size_t count,
+@@ -325,6 +325,11 @@ void dev_coredumpm(struct device *dev, s
+ 	if (device_add(&devcd->devcd_dev))
+ 		goto put_device;
+ 
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
++	if (device_create_bin_file(&devcd->devcd_dev, &devcd_attr_data))
++		goto put_device;
++#endif
++
+ 	if (sysfs_create_link(&devcd->devcd_dev.kobj, &dev->kobj,
+ 			      "failing_device"))
+ 		/* nothing - symlink will be missing */;
+@@ -367,16 +372,13 @@ void dev_coredumpsg(struct device *dev,
+ }
+ EXPORT_SYMBOL_GPL(dev_coredumpsg);
+ 
+-static int __init devcoredump_init(void)
++int __init devcoredump_init(void)
+ {
+-	init_devcd_class_attrs();
+ 	return class_register(&devcd_class);
+ }
+-__initcall(devcoredump_init);
+ 
+-static void __exit devcoredump_exit(void)
++void __exit devcoredump_exit(void)
+ {
+ 	class_for_each_device(&devcd_class, NULL, NULL, devcd_free);
+ 	class_unregister(&devcd_class);
+ }
+-__exitcall(devcoredump_exit);
+--- a/include/linux/backport-devcoredump.h
++++ b/include/linux/backport-devcoredump.h
+@@ -66,7 +66,7 @@ static inline void _devcd_free_sgtable(s
+ }
+ 
+ 
+-#ifdef CONFIG_DEV_COREDUMP
++#ifdef CPTCFG_BPAUTO_WANT_DEV_COREDUMP
+ void dev_coredumpv(struct device *dev, void *data, size_t datalen,
+ 		   gfp_t gfp);
+ 
+@@ -100,6 +100,6 @@ static inline void dev_coredumpsg(struct
+ {
+ 	_devcd_free_sgtable(table);
+ }
+-#endif /* CONFIG_DEV_COREDUMP */
++#endif /* CPTCFG_BPAUTO_WANT_DEV_COREDUMP */
+ 
+ #endif /* __DEVCOREDUMP_H */

+ 20 - 0
package/kernel/mac80211/patches/006-revert-ktime-changes.patch

@@ -0,0 +1,20 @@
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c
+@@ -177,7 +177,7 @@ static bool rt2800usb_tx_sta_fifo_read_c
+ 	if (rt2800usb_txstatus_pending(rt2x00dev)) {
+ 		/* Read register after 1 ms */
+ 		hrtimer_start(&rt2x00dev->txstatus_timer,
+-			      TXSTATUS_READ_INTERVAL,
++			      ktime_set(0, TXSTATUS_READ_INTERVAL),
+ 			      HRTIMER_MODE_REL);
+ 		return false;
+ 	}
+@@ -204,7 +204,7 @@ static void rt2800usb_async_read_tx_stat
+ 
+ 	/* Read TX_STA_FIFO register after 2 ms */
+ 	hrtimer_start(&rt2x00dev->txstatus_timer,
+-		      2 * TXSTATUS_READ_INTERVAL,
++		      ktime_set(0, 2*TXSTATUS_READ_INTERVAL),
+ 		      HRTIMER_MODE_REL);
+ }
+ 

+ 266 - 0
package/kernel/mac80211/patches/007-revert-genetlink-changes.patch

@@ -0,0 +1,266 @@
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -32,8 +32,22 @@ static int nl80211_crypto_settings(struc
+ 				   struct cfg80211_crypto_settings *settings,
+ 				   int cipher_limit);
+ 
++static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb,
++			    struct genl_info *info);
++static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb,
++			      struct genl_info *info);
++
+ /* the netlink family */
+-static struct genl_family nl80211_fam;
++static struct genl_family nl80211_fam = {
++	.id = GENL_ID_GENERATE,		/* don't bother with a hardcoded ID */
++	.name = NL80211_GENL_NAME,	/* have users key off the name instead */
++	.hdrsize = 0,			/* no private header */
++	.version = 1,			/* no particular meaning now */
++	.maxattr = NL80211_ATTR_MAX,
++	.netnsok = true,
++	.pre_doit = nl80211_pre_doit,
++	.post_doit = nl80211_post_doit,
++};
+ 
+ /* multicast groups */
+ enum nl80211_multicast_groups {
+@@ -549,14 +563,13 @@ static int nl80211_prepare_wdev_dump(str
+ 
+ 	if (!cb->args[0]) {
+ 		err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
+-				  genl_family_attrbuf(&nl80211_fam),
+-				  nl80211_fam.maxattr, nl80211_policy);
++				  nl80211_fam.attrbuf, nl80211_fam.maxattr,
++				  nl80211_policy);
+ 		if (err)
+ 			goto out_unlock;
+ 
+-		*wdev = __cfg80211_wdev_from_attrs(
+-					sock_net(skb->sk),
+-					genl_family_attrbuf(&nl80211_fam));
++		*wdev = __cfg80211_wdev_from_attrs(sock_net(skb->sk),
++						   nl80211_fam.attrbuf);
+ 		if (IS_ERR(*wdev)) {
+ 			err = PTR_ERR(*wdev);
+ 			goto out_unlock;
+@@ -1903,7 +1916,7 @@ static int nl80211_dump_wiphy_parse(stru
+ 				    struct netlink_callback *cb,
+ 				    struct nl80211_dump_wiphy_state *state)
+ {
+-	struct nlattr **tb = genl_family_attrbuf(&nl80211_fam);
++	struct nlattr **tb = nl80211_fam.attrbuf;
+ 	int ret = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
+ 			      tb, nl80211_fam.maxattr, nl80211_policy);
+ 	/* ignore parse errors for backward compatibility */
+@@ -7733,7 +7746,6 @@ static int nl80211_send_survey(struct sk
+ 
+ static int nl80211_dump_survey(struct sk_buff *skb, struct netlink_callback *cb)
+ {
+-	struct nlattr **attrbuf = genl_family_attrbuf(&nl80211_fam);
+ 	struct survey_info survey;
+ 	struct cfg80211_registered_device *rdev;
+ 	struct wireless_dev *wdev;
+@@ -7746,7 +7758,7 @@ static int nl80211_dump_survey(struct sk
+ 		return res;
+ 
+ 	/* prepare_wdev_dump parsed the attributes */
+-	radio_stats = attrbuf[NL80211_ATTR_SURVEY_RADIO_STATS];
++	radio_stats = nl80211_fam.attrbuf[NL80211_ATTR_SURVEY_RADIO_STATS];
+ 
+ 	if (!wdev->netdev) {
+ 		res = -EINVAL;
+@@ -8594,14 +8606,14 @@ static int nl80211_testmode_dump(struct
+ 		 */
+ 		phy_idx = cb->args[0] - 1;
+ 	} else {
+-		struct nlattr **attrbuf = genl_family_attrbuf(&nl80211_fam);
+-
+ 		err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
+-				  attrbuf, nl80211_fam.maxattr, nl80211_policy);
++				  nl80211_fam.attrbuf, nl80211_fam.maxattr,
++				  nl80211_policy);
+ 		if (err)
+ 			goto out_err;
+ 
+-		rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk), attrbuf);
++		rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk),
++						  nl80211_fam.attrbuf);
+ 		if (IS_ERR(rdev)) {
+ 			err = PTR_ERR(rdev);
+ 			goto out_err;
+@@ -8609,8 +8621,9 @@ static int nl80211_testmode_dump(struct
+ 		phy_idx = rdev->wiphy_idx;
+ 		rdev = NULL;
+ 
+-		if (attrbuf[NL80211_ATTR_TESTDATA])
+-			cb->args[1] = (long)attrbuf[NL80211_ATTR_TESTDATA];
++		if (nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA])
++			cb->args[1] =
++				(long)nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA];
+ 	}
+ 
+ 	if (cb->args[1]) {
+@@ -10814,7 +10827,8 @@ static int handle_nan_filter(struct nlat
+ 
+ 	i = 0;
+ 	nla_for_each_nested(attr, attr_filter, rem) {
+-		filter[i].filter = nla_memdup(attr, GFP_KERNEL);
++		filter[i].filter = kmemdup(nla_data(attr), nla_len(attr),
++					   GFP_KERNEL);
+ 		filter[i].len = nla_len(attr);
+ 		i++;
+ 	}
+@@ -11450,7 +11464,6 @@ static int nl80211_prepare_vendor_dump(s
+ 				       struct cfg80211_registered_device **rdev,
+ 				       struct wireless_dev **wdev)
+ {
+-	struct nlattr **attrbuf = genl_family_attrbuf(&nl80211_fam);
+ 	u32 vid, subcmd;
+ 	unsigned int i;
+ 	int vcmd_idx = -1;
+@@ -11486,28 +11499,31 @@ static int nl80211_prepare_vendor_dump(s
+ 	}
+ 
+ 	err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
+-			  attrbuf, nl80211_fam.maxattr, nl80211_policy);
++			  nl80211_fam.attrbuf, nl80211_fam.maxattr,
++			  nl80211_policy);
+ 	if (err)
+ 		goto out_unlock;
+ 
+-	if (!attrbuf[NL80211_ATTR_VENDOR_ID] ||
+-	    !attrbuf[NL80211_ATTR_VENDOR_SUBCMD]) {
++	if (!nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_ID] ||
++	    !nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_SUBCMD]) {
+ 		err = -EINVAL;
+ 		goto out_unlock;
+ 	}
+ 
+-	*wdev = __cfg80211_wdev_from_attrs(sock_net(skb->sk), attrbuf);
++	*wdev = __cfg80211_wdev_from_attrs(sock_net(skb->sk),
++					   nl80211_fam.attrbuf);
+ 	if (IS_ERR(*wdev))
+ 		*wdev = NULL;
+ 
+-	*rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk), attrbuf);
++	*rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk),
++					   nl80211_fam.attrbuf);
+ 	if (IS_ERR(*rdev)) {
+ 		err = PTR_ERR(*rdev);
+ 		goto out_unlock;
+ 	}
+ 
+-	vid = nla_get_u32(attrbuf[NL80211_ATTR_VENDOR_ID]);
+-	subcmd = nla_get_u32(attrbuf[NL80211_ATTR_VENDOR_SUBCMD]);
++	vid = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_ID]);
++	subcmd = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_SUBCMD]);
+ 
+ 	for (i = 0; i < (*rdev)->wiphy.n_vendor_commands; i++) {
+ 		const struct wiphy_vendor_command *vcmd;
+@@ -11531,9 +11547,9 @@ static int nl80211_prepare_vendor_dump(s
+ 		goto out_unlock;
+ 	}
+ 
+-	if (attrbuf[NL80211_ATTR_VENDOR_DATA]) {
+-		data = nla_data(attrbuf[NL80211_ATTR_VENDOR_DATA]);
+-		data_len = nla_len(attrbuf[NL80211_ATTR_VENDOR_DATA]);
++	if (nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_DATA]) {
++		data = nla_data(nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_DATA]);
++		data_len = nla_len(nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_DATA]);
+ 	}
+ 
+ 	/* 0 is the first index - add 1 to parse only once */
+@@ -12795,21 +12811,6 @@ static __genl_const struct genl_ops nl80
+ 	},
+ };
+ 
+-static struct genl_family nl80211_fam __ro_after_init = {
+-	.name = NL80211_GENL_NAME,	/* have users key off the name instead */
+-	.hdrsize = 0,			/* no private header */
+-	.version = 1,			/* no particular meaning now */
+-	.maxattr = NL80211_ATTR_MAX,
+-	.netnsok = true,
+-	.pre_doit = nl80211_pre_doit,
+-	.post_doit = nl80211_post_doit,
+-	.module = THIS_MODULE,
+-	.ops = nl80211_ops,
+-	.n_ops = ARRAY_SIZE(nl80211_ops),
+-	.mcgrps = nl80211_mcgrps,
+-	.n_mcgrps = ARRAY_SIZE(nl80211_mcgrps),
+-};
+-
+ /* notification functions */
+ 
+ void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev,
+@@ -14759,11 +14760,12 @@ void nl80211_send_ap_stopped(struct wire
+ 
+ /* initialisation/exit functions */
+ 
+-int __init nl80211_init(void)
++int nl80211_init(void)
+ {
+ 	int err;
+ 
+-	err = genl_register_family(&nl80211_fam);
++	err = genl_register_family_with_ops_groups(&nl80211_fam, nl80211_ops,
++						   nl80211_mcgrps);
+ 	if (err)
+ 		return err;
+ 
+--- a/drivers/net/wireless/mac80211_hwsim.c
++++ b/drivers/net/wireless/mac80211_hwsim.c
+@@ -587,8 +587,15 @@ struct hwsim_radiotap_ack_hdr {
+ 	__le16 rt_chbitmask;
+ } __packed;
+ 
+-/* MAC80211_HWSIM netlink family */
+-static struct genl_family hwsim_genl_family;
++/* MAC80211_HWSIM netlinf family */
++static struct genl_family hwsim_genl_family = {
++	.id = GENL_ID_GENERATE,
++	.hdrsize = 0,
++	.name = "MAC80211_HWSIM",
++	.version = 1,
++	.maxattr = HWSIM_ATTR_MAX,
++	.netnsok = true,
++};
+ 
+ enum hwsim_multicast_groups {
+ 	HWSIM_MCGRP_CONFIG,
+@@ -3250,18 +3257,6 @@ static __genl_const struct genl_ops hwsi
+ 	},
+ };
+ 
+-static struct genl_family hwsim_genl_family __ro_after_init = {
+-	.name = "MAC80211_HWSIM",
+-	.version = 1,
+-	.maxattr = HWSIM_ATTR_MAX,
+-	.netnsok = true,
+-	.module = THIS_MODULE,
+-	.ops = hwsim_ops,
+-	.n_ops = ARRAY_SIZE(hwsim_ops),
+-	.mcgrps = hwsim_mcgrps,
+-	.n_mcgrps = ARRAY_SIZE(hwsim_mcgrps),
+-};
+-
+ static void destroy_radio(struct work_struct *work)
+ {
+ 	struct mac80211_hwsim_data *data =
+@@ -3309,13 +3304,15 @@ static struct notifier_block hwsim_netli
+ 	.notifier_call = mac80211_hwsim_netlink_notify,
+ };
+ 
+-static int __init hwsim_init_netlink(void)
++static int hwsim_init_netlink(void)
+ {
+ 	int rc;
+ 
+ 	printk(KERN_INFO "mac80211_hwsim: initializing netlink\n");
+ 
+-	rc = genl_register_family(&hwsim_genl_family);
++	rc = genl_register_family_with_ops_groups(&hwsim_genl_family,
++						  hwsim_ops,
++						  hwsim_mcgrps);
+ 	if (rc)
+ 		goto failure;
+ 

+ 20 - 0
package/kernel/mac80211/patches/008-revert-ndo_stats64-cleanup.patch

@@ -0,0 +1,20 @@
+--- a/net/mac80211/iface.c
++++ b/net/mac80211/iface.c
+@@ -1133,7 +1133,7 @@ static u16 ieee80211_netdev_select_queue
+ 	return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb);
+ }
+ 
+-static void
++static struct rtnl_link_stats64 *
+ ieee80211_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
+ {
+ 	int i;
+@@ -1158,6 +1158,8 @@ ieee80211_get_stats64(struct net_device
+ 		stats->rx_bytes   += rx_bytes;
+ 		stats->tx_bytes   += tx_bytes;
+ 	}
++
++	return stats;
+ }
+ 
+ static const struct net_device_ops ieee80211_dataif_ops = {

+ 338 - 0
package/kernel/mac80211/patches/009-revert-mtu-changes.patch

@@ -0,0 +1,338 @@
+--- a/net/mac80211/iface.c
++++ b/net/mac80211/iface.c
+@@ -151,6 +151,15 @@ void ieee80211_recalc_idle(struct ieee80
+ 		ieee80211_hw_config(local, change);
+ }
+ 
++static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
++{
++	if (new_mtu < 256 || new_mtu > IEEE80211_MAX_DATA_LEN)
++		return -EINVAL;
++
++	dev->mtu = new_mtu;
++	return 0;
++}
++
+ static int ieee80211_verify_mac(struct ieee80211_sub_if_data *sdata, u8 *addr,
+ 				bool check_dup)
+ {
+@@ -1168,6 +1177,7 @@ static const struct net_device_ops ieee8
+ 	.ndo_uninit		= ieee80211_uninit,
+ 	.ndo_start_xmit		= ieee80211_subif_start_xmit,
+ 	.ndo_set_rx_mode	= ieee80211_set_multicast_list,
++	.ndo_change_mtu 	= ieee80211_change_mtu,
+ 	.ndo_set_mac_address 	= ieee80211_change_mac,
+ 	.ndo_select_queue	= ieee80211_netdev_select_queue,
+ 	.ndo_get_stats64	= ieee80211_get_stats64,
+@@ -1211,6 +1221,7 @@ static const struct net_device_ops ieee8
+ 	.ndo_uninit		= ieee80211_uninit,
+ 	.ndo_start_xmit		= ieee80211_monitor_start_xmit,
+ 	.ndo_set_rx_mode	= ieee80211_set_multicast_list,
++	.ndo_change_mtu 	= ieee80211_change_mtu,
+ 	.ndo_set_mac_address 	= ieee80211_change_mac,
+ 	.ndo_select_queue	= ieee80211_monitor_select_queue,
+ 	.ndo_get_stats64	= ieee80211_get_stats64,
+@@ -1919,10 +1930,6 @@ int ieee80211_if_add(struct ieee80211_lo
+ 
+ 		netdev_set_default_ethtool_ops(ndev, &ieee80211_ethtool_ops);
+ 
+-		/* MTU range: 256 - 2304 */
+-		ndev->min_mtu = 256;
+-		ndev->max_mtu = IEEE80211_MAX_DATA_LEN;
+-
+ 		ret = register_netdevice(ndev);
+ 		if (ret) {
+ 			ieee80211_if_free(ndev);
+--- a/drivers/net/wireless/ath/wil6210/netdev.c
++++ b/drivers/net/wireless/ath/wil6210/netdev.c
+@@ -42,6 +42,21 @@ static int wil_stop(struct net_device *n
+ 	return wil_down(wil);
+ }
+ 
++static int wil_change_mtu(struct net_device *ndev, int new_mtu)
++{
++	struct wil6210_priv *wil = ndev_to_wil(ndev);
++
++	if (new_mtu < 68 || new_mtu > mtu_max) {
++		wil_err(wil, "invalid MTU %d\n", new_mtu);
++		return -EINVAL;
++	}
++
++	wil_dbg_misc(wil, "change MTU %d -> %d\n", ndev->mtu, new_mtu);
++	ndev->mtu = new_mtu;
++
++	return 0;
++}
++
+ static int wil_do_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd)
+ {
+ 	struct wil6210_priv *wil = ndev_to_wil(ndev);
+@@ -55,6 +70,7 @@ static const struct net_device_ops wil_n
+ 	.ndo_start_xmit		= wil_start_xmit,
+ 	.ndo_set_mac_address	= eth_mac_addr,
+ 	.ndo_validate_addr	= eth_validate_addr,
++	.ndo_change_mtu		= wil_change_mtu,
+ 	.ndo_do_ioctl		= wil_do_ioctl,
+ };
+ 
+@@ -111,7 +127,6 @@ static int wil6210_netdev_poll_tx(struct
+ static void wil_dev_setup(struct net_device *dev)
+ {
+ 	ether_setup(dev);
+-	dev->max_mtu = mtu_max;
+ 	dev->tx_queue_len = WIL_TX_Q_LEN_DEFAULT;
+ }
+ 
+--- a/drivers/net/wireless/atmel/atmel.c
++++ b/drivers/net/wireless/atmel/atmel.c
+@@ -1295,6 +1295,14 @@ static struct iw_statistics *atmel_get_w
+ 	return &priv->wstats;
+ }
+ 
++static int atmel_change_mtu(struct net_device *dev, int new_mtu)
++{
++	if ((new_mtu < 68) || (new_mtu > 2312))
++		return -EINVAL;
++	dev->mtu = new_mtu;
++	return 0;
++}
++
+ static int atmel_set_mac_address(struct net_device *dev, void *p)
+ {
+ 	struct sockaddr *addr = p;
+@@ -1498,6 +1506,7 @@ static const struct file_operations atme
+ static const struct net_device_ops atmel_netdev_ops = {
+ 	.ndo_open 		= atmel_open,
+ 	.ndo_stop		= atmel_close,
++	.ndo_change_mtu 	= atmel_change_mtu,
+ 	.ndo_set_mac_address 	= atmel_set_mac_address,
+ 	.ndo_start_xmit 	= start_tx,
+ 	.ndo_do_ioctl 		= atmel_ioctl,
+@@ -1591,10 +1600,6 @@ struct net_device *init_atmel_card(unsig
+ 	dev->irq = irq;
+ 	dev->base_addr = port;
+ 
+-	/* MTU range: 68 - 2312 */
+-	dev->min_mtu = 68;
+-	dev->max_mtu = MAX_WIRELESS_BODY - ETH_FCS_LEN;
+-
+ 	SET_NETDEV_DEV(dev, sys_dev);
+ 
+ 	if ((rc = request_irq(dev->irq, service_interrupt, IRQF_SHARED, dev->name, dev))) {
+--- a/drivers/net/wireless/cisco/airo.c
++++ b/drivers/net/wireless/cisco/airo.c
+@@ -2329,6 +2329,14 @@ static int airo_set_mac_address(struct n
+ 	return 0;
+ }
+ 
++static int airo_change_mtu(struct net_device *dev, int new_mtu)
++{
++	if ((new_mtu < 68) || (new_mtu > 2400))
++		return -EINVAL;
++	dev->mtu = new_mtu;
++	return 0;
++}
++
+ static LIST_HEAD(airo_devices);
+ 
+ static void add_airo_dev(struct airo_info *ai)
+@@ -2648,6 +2656,7 @@ static const struct net_device_ops airo1
+ 	.ndo_get_stats 		= airo_get_stats,
+ 	.ndo_set_mac_address	= airo_set_mac_address,
+ 	.ndo_do_ioctl		= airo_ioctl,
++	.ndo_change_mtu		= airo_change_mtu,
+ };
+ 
+ static void wifi_setup(struct net_device *dev)
+@@ -2659,8 +2668,6 @@ static void wifi_setup(struct net_device
+ 	dev->type               = ARPHRD_IEEE80211;
+ 	dev->hard_header_len    = ETH_HLEN;
+ 	dev->mtu                = AIRO_DEF_MTU;
+-	dev->min_mtu            = 68;
+-	dev->max_mtu            = MIC_MSGLEN_MAX;
+ 	dev->addr_len           = ETH_ALEN;
+ 	dev->tx_queue_len       = 100; 
+ 
+@@ -2747,6 +2754,7 @@ static const struct net_device_ops airo_
+ 	.ndo_set_rx_mode	= airo_set_multicast_list,
+ 	.ndo_set_mac_address	= airo_set_mac_address,
+ 	.ndo_do_ioctl		= airo_ioctl,
++	.ndo_change_mtu		= airo_change_mtu,
+ 	.ndo_validate_addr	= eth_validate_addr,
+ };
+ 
+@@ -2758,6 +2766,7 @@ static const struct net_device_ops mpi_n
+ 	.ndo_set_rx_mode	= airo_set_multicast_list,
+ 	.ndo_set_mac_address	= airo_set_mac_address,
+ 	.ndo_do_ioctl		= airo_ioctl,
++	.ndo_change_mtu		= airo_change_mtu,
+ 	.ndo_validate_addr	= eth_validate_addr,
+ };
+ 
+@@ -2813,7 +2822,6 @@ static struct net_device *_init_airo_car
+ 	dev->irq = irq;
+ 	dev->base_addr = port;
+ 	dev->priv_flags &= ~IFF_TX_SKB_SHARING;
+-	dev->max_mtu = MIC_MSGLEN_MAX;
+ 
+ 	SET_NETDEV_DEV(dev, dmdev);
+ 
+--- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c
++++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
+@@ -6039,6 +6039,7 @@ static const struct net_device_ops ipw21
+ 	.ndo_open		= ipw2100_open,
+ 	.ndo_stop		= ipw2100_close,
+ 	.ndo_start_xmit		= libipw_xmit,
++	.ndo_change_mtu		= libipw_change_mtu,
+ 	.ndo_tx_timeout		= ipw2100_tx_timeout,
+ 	.ndo_set_mac_address	= ipw2100_set_address,
+ 	.ndo_validate_addr	= eth_validate_addr,
+@@ -6074,8 +6075,6 @@ static struct net_device *ipw2100_alloc_
+ 	dev->wireless_data = &priv->wireless_data;
+ 	dev->watchdog_timeo = 3 * HZ;
+ 	dev->irq = 0;
+-	dev->min_mtu = 68;
+-	dev->max_mtu = LIBIPW_DATA_LEN;
+ 
+ 	/* NOTE: We don't use the wireless_handlers hook
+ 	 * in dev as the system will start throwing WX requests
+--- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c
++++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
+@@ -11561,6 +11561,7 @@ static const struct net_device_ops ipw_p
+ 	.ndo_open 		= ipw_prom_open,
+ 	.ndo_stop		= ipw_prom_stop,
+ 	.ndo_start_xmit		= ipw_prom_hard_start_xmit,
++	.ndo_change_mtu		= libipw_change_mtu,
+ 	.ndo_set_mac_address 	= eth_mac_addr,
+ 	.ndo_validate_addr	= eth_validate_addr,
+ };
+@@ -11586,9 +11587,6 @@ static int ipw_prom_alloc(struct ipw_pri
+ 	priv->prom_net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
+ 	priv->prom_net_dev->netdev_ops = &ipw_prom_netdev_ops;
+ 
+-	priv->prom_net_dev->min_mtu = 68;
+-	priv->prom_net_dev->max_mtu = LIBIPW_DATA_LEN;
+-
+ 	priv->prom_priv->ieee->iw_mode = IW_MODE_MONITOR;
+ 	SET_NETDEV_DEV(priv->prom_net_dev, &priv->pci_dev->dev);
+ 
+@@ -11621,6 +11619,7 @@ static const struct net_device_ops ipw_n
+ 	.ndo_set_rx_mode	= ipw_net_set_multicast_list,
+ 	.ndo_set_mac_address	= ipw_net_set_mac_address,
+ 	.ndo_start_xmit		= libipw_xmit,
++	.ndo_change_mtu		= libipw_change_mtu,
+ 	.ndo_validate_addr	= eth_validate_addr,
+ };
+ 
+@@ -11730,9 +11729,6 @@ static int ipw_pci_probe(struct pci_dev
+ 	net_dev->wireless_handlers = &ipw_wx_handler_def;
+ 	net_dev->ethtool_ops = &ipw_ethtool_ops;
+ 
+-	net_dev->min_mtu = 68;
+-	net_dev->max_mtu = LIBIPW_DATA_LEN;
+-
+ 	err = sysfs_create_group(&pdev->dev.kobj, &ipw_attribute_group);
+ 	if (err) {
+ 		IPW_ERROR("failed to create sysfs device attributes\n");
+--- a/drivers/net/wireless/intel/ipw2x00/libipw.h
++++ b/drivers/net/wireless/intel/ipw2x00/libipw.h
+@@ -948,6 +948,7 @@ static inline int libipw_is_cck_rate(u8
+ /* libipw.c */
+ void free_libipw(struct net_device *dev, int monitor);
+ struct net_device *alloc_libipw(int sizeof_priv, int monitor);
++int libipw_change_mtu(struct net_device *dev, int new_mtu);
+ 
+ void libipw_networks_age(struct libipw_device *ieee, unsigned long age_secs);
+ 
+--- a/drivers/net/wireless/intel/ipw2x00/libipw_module.c
++++ b/drivers/net/wireless/intel/ipw2x00/libipw_module.c
+@@ -118,6 +118,15 @@ static void libipw_networks_initialize(s
+ 			      &ieee->network_free_list);
+ }
+ 
++int libipw_change_mtu(struct net_device *dev, int new_mtu)
++{
++	if ((new_mtu < 68) || (new_mtu > LIBIPW_DATA_LEN))
++		return -EINVAL;
++	dev->mtu = new_mtu;
++	return 0;
++}
++EXPORT_SYMBOL(libipw_change_mtu);
++
+ struct net_device *alloc_libipw(int sizeof_priv, int monitor)
+ {
+ 	struct libipw_device *ieee;
+--- a/drivers/net/wireless/intersil/hostap/hostap_main.c
++++ b/drivers/net/wireless/intersil/hostap/hostap_main.c
+@@ -765,6 +765,16 @@ static void hostap_set_multicast_list(st
+ }
+ 
+ 
++static int prism2_change_mtu(struct net_device *dev, int new_mtu)
++{
++	if (new_mtu < PRISM2_MIN_MTU || new_mtu > PRISM2_MAX_MTU)
++		return -EINVAL;
++
++	dev->mtu = new_mtu;
++	return 0;
++}
++
++
+ static void prism2_tx_timeout(struct net_device *dev)
+ {
+ 	struct hostap_interface *iface;
+@@ -803,6 +813,7 @@ static const struct net_device_ops hosta
+ 	.ndo_do_ioctl		= hostap_ioctl,
+ 	.ndo_set_mac_address	= prism2_set_mac_address,
+ 	.ndo_set_rx_mode	= hostap_set_multicast_list,
++	.ndo_change_mtu 	= prism2_change_mtu,
+ 	.ndo_tx_timeout 	= prism2_tx_timeout,
+ 	.ndo_validate_addr	= eth_validate_addr,
+ };
+@@ -815,6 +826,7 @@ static const struct net_device_ops hosta
+ 	.ndo_do_ioctl		= hostap_ioctl,
+ 	.ndo_set_mac_address	= prism2_set_mac_address,
+ 	.ndo_set_rx_mode	= hostap_set_multicast_list,
++	.ndo_change_mtu 	= prism2_change_mtu,
+ 	.ndo_tx_timeout 	= prism2_tx_timeout,
+ 	.ndo_validate_addr	= eth_validate_addr,
+ };
+@@ -827,6 +839,7 @@ static const struct net_device_ops hosta
+ 	.ndo_do_ioctl		= hostap_ioctl,
+ 	.ndo_set_mac_address	= prism2_set_mac_address,
+ 	.ndo_set_rx_mode	= hostap_set_multicast_list,
++	.ndo_change_mtu 	= prism2_change_mtu,
+ 	.ndo_tx_timeout 	= prism2_tx_timeout,
+ 	.ndo_validate_addr	= eth_validate_addr,
+ };
+@@ -838,8 +851,6 @@ void hostap_setup_dev(struct net_device
+ 
+ 	iface = netdev_priv(dev);
+ 	ether_setup(dev);
+-	dev->min_mtu = PRISM2_MIN_MTU;
+-	dev->max_mtu = PRISM2_MAX_MTU;
+ 	dev->priv_flags &= ~IFF_TX_SKB_SHARING;
+ 
+ 	/* kernel callbacks */
+--- a/drivers/net/wireless/intersil/orinoco/main.c
++++ b/drivers/net/wireless/intersil/orinoco/main.c
+@@ -322,6 +322,9 @@ int orinoco_change_mtu(struct net_device
+ {
+ 	struct orinoco_private *priv = ndev_priv(dev);
+ 
++	if ((new_mtu < ORINOCO_MIN_MTU) || (new_mtu > ORINOCO_MAX_MTU))
++		return -EINVAL;
++
+ 	/* MTU + encapsulation + header length */
+ 	if ((new_mtu + ENCAPS_OVERHEAD + sizeof(struct ieee80211_hdr)) >
+ 	     (priv->nicbuf_size - ETH_HLEN))
+@@ -2285,9 +2288,6 @@ int orinoco_if_add(struct orinoco_privat
+ 	dev->base_addr = base_addr;
+ 	dev->irq = irq;
+ 
+-	dev->min_mtu = ORINOCO_MIN_MTU;
+-	dev->max_mtu = ORINOCO_MAX_MTU;
+-
+ 	SET_NETDEV_DEV(dev, priv->dev);
+ 	ret = register_netdev(dev);
+ 	if (ret)

+ 43 - 0
package/kernel/mac80211/patches/011-backport_strscpy.patch

@@ -0,0 +1,43 @@
+--- a/backport-include/linux/string.h
++++ b/backport-include/linux/string.h
+@@ -25,4 +25,8 @@ extern void *memdup_user_nul(const void
+ void memzero_explicit(void *s, size_t count);
+ #endif
+ 
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0))
++ssize_t strscpy(char *dest, const char *src, size_t count);
++#endif
++
+ #endif /* __BACKPORT_LINUX_STRING_H */
+--- a/compat/backport-4.3.c
++++ b/compat/backport-4.3.c
+@@ -57,3 +57,29 @@ void seq_hex_dump(struct seq_file *m, co
+ 	}
+ }
+ EXPORT_SYMBOL_GPL(seq_hex_dump);
++
++ssize_t strscpy(char *dest, const char *src, size_t count)
++{
++	long res = 0;
++
++	if (count == 0)
++		return -E2BIG;
++
++	while (count) {
++		char c;
++
++		c = src[res];
++		dest[res] = c;
++		if (!c)
++			return res;
++		res++;
++		count--;
++	}
++
++	/* Hit buffer length without finding a NUL; force NUL-termination. */
++	if (res)
++		dest[res-1] = '\0';
++
++	return -E2BIG;
++}
++EXPORT_SYMBOL_GPL(strscpy);

+ 47 - 0
package/kernel/mac80211/patches/030-rt2x00_options.patch

@@ -0,0 +1,47 @@
+--- a/drivers/net/wireless/ralink/rt2x00/Kconfig
++++ b/drivers/net/wireless/ralink/rt2x00/Kconfig
+@@ -225,36 +225,37 @@ config RT2800SOC
+ 
+ 
+ config RT2800_LIB
+-	tristate
++	tristate "RT2800 USB/PCI support"
+ 	depends on m
+ 
+ config RT2800_LIB_MMIO
+-	tristate
++	tristate "RT2800 MMIO support"
+ 	depends on m
+ 	select RT2X00_LIB_MMIO
+ 	select RT2800_LIB
+ 
+ config RT2X00_LIB_MMIO
+-	tristate
++	tristate "RT2x00 MMIO support"
+ 	depends on m
+ 
+ config RT2X00_LIB_PCI
+-	tristate
++	tristate "RT2x00 PCI support"
+ 	depends on m
+ 	select RT2X00_LIB
+ 
+ config RT2X00_LIB_SOC
+-	tristate
++	tristate "RT2x00 SoC support"
++	depends on SOC_RT288X || SOC_RT305X
+ 	depends on m
+ 	select RT2X00_LIB
+ 
+ config RT2X00_LIB_USB
+-	tristate
++	tristate "RT2x00 USB support"
+ 	depends on m
+ 	select RT2X00_LIB
+ 
+ config RT2X00_LIB
+-	tristate
++	tristate "RT2x00 support"
+ 	depends on m
+ 
+ config RT2X00_LIB_FIRMWARE

+ 9 - 0
package/kernel/mac80211/patches/040-brcmutil_option.patch

@@ -0,0 +1,9 @@
+--- a/drivers/net/wireless/broadcom/brcm80211/Kconfig
++++ b/drivers/net/wireless/broadcom/brcm80211/Kconfig
+@@ -1,5 +1,5 @@
+ config BRCMUTIL
+-	tristate
++	tristate "Broadcom 802.11 driver utility functions"
+ 	depends on m
+ 
+ config BRCMSMAC

+ 2 - 2
package/kernel/mac80211/patches/060-no_local_ssb_bcma.patch

@@ -1,6 +1,6 @@
 --- a/.local-symbols
 +++ b/.local-symbols
-@@ -477,45 +477,6 @@ USB_IPHETH=
+@@ -482,45 +482,6 @@ USB_IPHETH=
  USB_SIERRA_NET=
  USB_VL600=
  USB_NET_CH9200=
@@ -88,7 +88,7 @@
  	gpiodev = bus->chipco.dev ? : pcidev;
 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/Makefile
 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/Makefile
-@@ -43,6 +43,6 @@ brcmsmac-y := \
+@@ -42,6 +42,6 @@ brcmsmac-y := \
  	brcms_trace_events.o \
  	debug.o
  

+ 15 - 0
package/kernel/mac80211/patches/090-remove-cred.patch

@@ -0,0 +1,15 @@
+This is only needed for kernel < 2.6.29 and conflicts with kernel 4.4.42
+
+--- a/backport-include/linux/cred.h
++++ /dev/null
+@@ -1,10 +0,0 @@
+-#ifndef __BACKPORT_LINUX_CRED_H
+-#define __BACKPORT_LINUX_CRED_H
+-#include_next <linux/cred.h>
+-#include <linux/version.h>
+-
+-#ifndef current_user_ns
+-#define current_user_ns()	(current->nsproxy->user_ns)
+-#endif
+-
+-#endif /* __BACKPORT_LINUX_CRED_H */

+ 208 - 122
package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch

@@ -18,12 +18,12 @@
 -	aes_gcm.o \
  	aes_cmac.o \
 -	aes_gmac.o \
+ 	fils_aead.o \
  	cfg.o \
  	ethtool.o \
- 	rx.o \
 --- a/net/mac80211/aes_ccm.c
 +++ b/net/mac80211/aes_ccm.c
-@@ -13,89 +13,132 @@
+@@ -13,103 +13,132 @@
  #include <linux/types.h>
  #include <linux/err.h>
  #include <crypto/aead.h>
@@ -33,14 +33,39 @@
  #include "key.h"
  #include "aes_ccm.h"
  
--void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
+-int ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
+-			      u8 *data, size_t data_len, u8 *mic,
+-			      size_t mic_len)
 +static void aes_ccm_prepare(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, u8 *s_0,
 +			    u8 *a, u8 *b)
-+{
+ {
+-	struct scatterlist sg[3];
+-	struct aead_request *aead_req;
+-	int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm);
+-	u8 *__aad;
+-
+-	aead_req = kzalloc(reqsize + CCM_AAD_LEN, GFP_ATOMIC);
+-	if (!aead_req)
+-		return -ENOMEM;
+-
+-	__aad = (u8 *)aead_req + reqsize;
+-	memcpy(__aad, aad, CCM_AAD_LEN);
+-
+-	sg_init_table(sg, 3);
+-	sg_set_buf(&sg[0], &__aad[2], be16_to_cpup((__be16 *)__aad));
+-	sg_set_buf(&sg[1], data, data_len);
+-	sg_set_buf(&sg[2], mic, mic_len);
+-
+-	aead_request_set_tfm(aead_req, tfm);
+-	aead_request_set_crypt(aead_req, sg, sg, data_len, b_0);
+-	aead_request_set_ad(aead_req, sg[0].length);
 +	int i;
-+
+ 
+-	crypto_aead_encrypt(aead_req);
+-	kzfree(aead_req);
 +	crypto_cipher_encrypt_one(tfm, b, b_0);
-+
+ 
+-	return 0;
 +	/* Extra Authenticate-only data (always two AES blocks) */
 +	for (i = 0; i < AES_BLOCK_SIZE; i++)
 +		aad[i] ^= b[i];
@@ -63,52 +88,38 @@
 +
 +
 +void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad,
- 			       u8 *data, size_t data_len, u8 *mic,
- 			       size_t mic_len)
- {
--	struct scatterlist sg[3];
++			       u8 *data, size_t data_len, u8 *mic,
++			       size_t mic_len)
++{
 +	int i, j, last_len, num_blocks;
 +	u8 b[AES_BLOCK_SIZE];
 +	u8 s_0[AES_BLOCK_SIZE];
 +	u8 e[AES_BLOCK_SIZE];
 +	u8 *pos, *cpos;
- 
--	char aead_req_data[sizeof(struct aead_request) +
--			   crypto_aead_reqsize(tfm)]
--		__aligned(__alignof__(struct aead_request));
--	struct aead_request *aead_req = (void *) aead_req_data;
++
 +	num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_SIZE);
 +	last_len = data_len % AES_BLOCK_SIZE;
 +	aes_ccm_prepare(tfm, b_0, aad, s_0, b, b);
- 
--	memset(aead_req, 0, sizeof(aead_req_data));
++
 +	/* Process payload blocks */
 +	pos = data;
 +	cpos = data;
 +	for (j = 1; j <= num_blocks; j++) {
 +		int blen = (j == num_blocks && last_len) ?
 +			last_len : AES_BLOCK_SIZE;
- 
--	sg_init_table(sg, 3);
--	sg_set_buf(&sg[0], &aad[2], be16_to_cpup((__be16 *)aad));
--	sg_set_buf(&sg[1], data, data_len);
--	sg_set_buf(&sg[2], mic, mic_len);
++
 +		/* Authentication followed by encryption */
 +		for (i = 0; i < blen; i++)
 +			b[i] ^= pos[i];
 +		crypto_cipher_encrypt_one(tfm, b, b);
- 
--	aead_request_set_tfm(aead_req, tfm);
--	aead_request_set_crypt(aead_req, sg, sg, data_len, b_0);
--	aead_request_set_ad(aead_req, sg[0].length);
++
 +		b_0[14] = (j >> 8) & 0xff;
 +		b_0[15] = j & 0xff;
 +		crypto_cipher_encrypt_one(tfm, e, b_0);
 +		for (i = 0; i < blen; i++)
 +			*cpos++ = *pos++ ^ e[i];
 +	}
- 
--	crypto_aead_encrypt(aead_req);
++
 +	for (i = 0; i < mic_len; i++)
 +		mic[i] = b[i] ^ s_0[i];
  }
@@ -119,34 +130,46 @@
  			      size_t mic_len)
  {
 -	struct scatterlist sg[3];
--	char aead_req_data[sizeof(struct aead_request) +
--			   crypto_aead_reqsize(tfm)]
--		__aligned(__alignof__(struct aead_request));
--	struct aead_request *aead_req = (void *) aead_req_data;
+-	struct aead_request *aead_req;
+-	int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm);
+-	u8 *__aad;
+-	int err;
+-
+-	if (data_len == 0)
+-		return -EINVAL;
+-
+-	aead_req = kzalloc(reqsize + CCM_AAD_LEN, GFP_ATOMIC);
+-	if (!aead_req)
+-		return -ENOMEM;
+-
+-	__aad = (u8 *)aead_req + reqsize;
+-	memcpy(__aad, aad, CCM_AAD_LEN);
+-
+-	sg_init_table(sg, 3);
+-	sg_set_buf(&sg[0], &__aad[2], be16_to_cpup((__be16 *)__aad));
+-	sg_set_buf(&sg[1], data, data_len);
+-	sg_set_buf(&sg[2], mic, mic_len);
+-
+-	aead_request_set_tfm(aead_req, tfm);
+-	aead_request_set_crypt(aead_req, sg, sg, data_len + mic_len, b_0);
+-	aead_request_set_ad(aead_req, sg[0].length);
 +	int i, j, last_len, num_blocks;
 +	u8 *pos, *cpos;
 +	u8 a[AES_BLOCK_SIZE];
 +	u8 b[AES_BLOCK_SIZE];
 +	u8 s_0[AES_BLOCK_SIZE];
- 
--	if (data_len == 0)
--		return -EINVAL;
++
 +	num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_SIZE);
 +	last_len = data_len % AES_BLOCK_SIZE;
 +	aes_ccm_prepare(tfm, b_0, aad, s_0, a, b);
- 
--	memset(aead_req, 0, sizeof(aead_req_data));
++
 +	/* Process payload blocks */
 +	cpos = data;
 +	pos = data;
 +	for (j = 1; j <= num_blocks; j++) {
 +		int blen = (j == num_blocks && last_len) ?
 +			last_len : AES_BLOCK_SIZE;
- 
--	sg_init_table(sg, 3);
--	sg_set_buf(&sg[0], &aad[2], be16_to_cpup((__be16 *)aad));
--	sg_set_buf(&sg[1], data, data_len);
--	sg_set_buf(&sg[2], mic, mic_len);
++
 +		/* Decryption followed by authentication */
 +		b_0[14] = (j >> 8) & 0xff;
 +		b_0[15] = j & 0xff;
@@ -157,16 +180,16 @@
 +		}
 +		crypto_cipher_encrypt_one(tfm, a, a);
 +	}
- 
--	aead_request_set_tfm(aead_req, tfm);
--	aead_request_set_crypt(aead_req, sg, sg, data_len + mic_len, b_0);
--	aead_request_set_ad(aead_req, sg[0].length);
++
 +	for (i = 0; i < mic_len; i++) {
 +		if ((mic[i] ^ s_0[i]) != a[i])
 +			return -1;
 +	}
  
--	return crypto_aead_decrypt(aead_req);
+-	err = crypto_aead_decrypt(aead_req);
+-	kzfree(aead_req);
+-
+-	return err;
 +	return 0;
  }
  
@@ -179,12 +202,12 @@
  {
 -	struct crypto_aead *tfm;
 -	int err;
--
++	struct crypto_cipher *tfm;
+ 
 -	tfm = crypto_alloc_aead("ccm(aes)", 0, CRYPTO_ALG_ASYNC);
 -	if (IS_ERR(tfm))
 -		return tfm;
-+	struct crypto_cipher *tfm;
- 
+-
 -	err = crypto_aead_setkey(tfm, key, key_len);
 -	if (err)
 -		goto free_aead;
@@ -209,73 +232,11 @@
 -	crypto_free_aead(tfm);
 +	crypto_free_cipher(tfm);
  }
---- a/net/mac80211/aes_ccm.h
-+++ b/net/mac80211/aes_ccm.h
-@@ -12,15 +12,15 @@
- 
- #include <linux/crypto.h>
- 
--struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[],
--						    size_t key_len,
--						    size_t mic_len);
--void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
-+struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[],
-+						      size_t key_len,
-+						      size_t mic_len);
-+void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad,
- 			       u8 *data, size_t data_len, u8 *mic,
- 			       size_t mic_len);
--int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
-+int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad,
- 			      u8 *data, size_t data_len, u8 *mic,
- 			      size_t mic_len);
--void ieee80211_aes_key_free(struct crypto_aead *tfm);
-+void ieee80211_aes_key_free(struct crypto_cipher *tfm);
- 
- #endif /* AES_CCM_H */
---- a/net/mac80211/aes_gcm.h
-+++ b/net/mac80211/aes_gcm.h
-@@ -11,12 +11,28 @@
- 
- #include <linux/crypto.h>
- 
--void ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
--			       u8 *data, size_t data_len, u8 *mic);
--int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
--			      u8 *data, size_t data_len, u8 *mic);
--struct crypto_aead *ieee80211_aes_gcm_key_setup_encrypt(const u8 key[],
--							size_t key_len);
--void ieee80211_aes_gcm_key_free(struct crypto_aead *tfm);
-+static inline void
-+ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
-+			  u8 *data, size_t data_len, u8 *mic)
-+{
-+}
-+
-+static inline int
-+ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
-+			  u8 *data, size_t data_len, u8 *mic)
-+{
-+    return -EOPNOTSUPP;
-+}
-+
-+static inline struct crypto_aead *
-+ieee80211_aes_gcm_key_setup_encrypt(const u8 key[], size_t key_len)
-+{
-+    return NULL;
-+}
-+
-+static inline void
-+ieee80211_aes_gcm_key_free(struct crypto_aead *tfm)
-+{
-+}
- 
- #endif /* AES_GCM_H */
 --- a/net/mac80211/aes_gmac.h
 +++ b/net/mac80211/aes_gmac.h
-@@ -11,10 +11,22 @@
- 
- #include <linux/crypto.h>
+@@ -15,10 +15,22 @@
+ #define GMAC_MIC_LEN	16
+ #define GMAC_NONCE_LEN	12
  
 -struct crypto_aead *ieee80211_aes_gmac_key_setup(const u8 key[],
 -						 size_t key_len);
@@ -314,7 +275,7 @@
  		struct {
 --- a/net/mac80211/wpa.c
 +++ b/net/mac80211/wpa.c
-@@ -304,7 +304,8 @@ ieee80211_crypto_tkip_decrypt(struct iee
+@@ -305,7 +305,8 @@ ieee80211_crypto_tkip_decrypt(struct iee
  }
  
  
@@ -324,7 +285,7 @@
  {
  	__le16 mask_fc;
  	int a4_included, mgmt;
-@@ -334,14 +335,8 @@ static void ccmp_special_blocks(struct s
+@@ -335,14 +336,8 @@ static void ccmp_special_blocks(struct s
  	else
  		qos_tid = 0;
  
@@ -341,7 +302,7 @@
  
  	/* Nonce: Nonce Flags | A2 | PN
  	 * Nonce Flags: Priority (b0..b3) | Management (b4) | Reserved (b5..b7)
-@@ -349,6 +344,8 @@ static void ccmp_special_blocks(struct s
+@@ -350,6 +345,8 @@ static void ccmp_special_blocks(struct s
  	b_0[1] = qos_tid | (mgmt << 4);
  	memcpy(&b_0[2], hdr->addr2, ETH_ALEN);
  	memcpy(&b_0[8], pn, IEEE80211_CCMP_PN_LEN);
@@ -350,16 +311,31 @@
  
  	/* AAD (extra authenticate-only data) / masked 802.11 header
  	 * FC | A1 | A2 | A3 | SC | [A4] | [QC] */
-@@ -460,7 +457,7 @@ static int ccmp_encrypt_skb(struct ieee8
+@@ -406,7 +403,7 @@ static int ccmp_encrypt_skb(struct ieee8
+ 	u8 *pos;
+ 	u8 pn[6];
+ 	u64 pn64;
+-	u8 aad[CCM_AAD_LEN];
++	u8 aad[2 * AES_BLOCK_SIZE];
+ 	u8 b_0[AES_BLOCK_SIZE];
+ 
+ 	if (info->control.hw_key &&
+@@ -461,9 +458,11 @@ static int ccmp_encrypt_skb(struct ieee8
  		return 0;
  
  	pos += IEEE80211_CCMP_HDR_LEN;
 -	ccmp_special_blocks(skb, pn, b_0, aad);
+-	return ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len,
+-					 skb_put(skb, mic_len), mic_len);
 +	ccmp_special_blocks(skb, pn, b_0, aad, len);
- 	ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len,
- 				  skb_put(skb, mic_len), mic_len);
++	ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len,
++				  skb_put(skb, mic_len), mic_len);
++
++	return 0;
+ }
+ 
  
-@@ -537,7 +534,7 @@ ieee80211_crypto_ccmp_decrypt(struct iee
+@@ -536,7 +535,7 @@ ieee80211_crypto_ccmp_decrypt(struct iee
  			u8 aad[2 * AES_BLOCK_SIZE];
  			u8 b_0[AES_BLOCK_SIZE];
  			/* hardware didn't decrypt/verify MIC */
@@ -368,3 +344,113 @@
  
  			if (ieee80211_aes_ccm_decrypt(
  				    key->u.ccmp.tfm, b_0, aad,
+@@ -638,7 +637,7 @@ static int gcmp_encrypt_skb(struct ieee8
+ 	u8 *pos;
+ 	u8 pn[6];
+ 	u64 pn64;
+-	u8 aad[GCM_AAD_LEN];
++	u8 aad[2 * AES_BLOCK_SIZE];
+ 	u8 j_0[AES_BLOCK_SIZE];
+ 
+ 	if (info->control.hw_key &&
+@@ -695,8 +694,10 @@ static int gcmp_encrypt_skb(struct ieee8
+ 
+ 	pos += IEEE80211_GCMP_HDR_LEN;
+ 	gcmp_special_blocks(skb, pn, j_0, aad);
+-	return ieee80211_aes_gcm_encrypt(key->u.gcmp.tfm, j_0, aad, pos, len,
+-					 skb_put(skb, IEEE80211_GCMP_MIC_LEN));
++	ieee80211_aes_gcm_encrypt(key->u.gcmp.tfm, j_0, aad, pos, len,
++				  skb_put(skb, IEEE80211_GCMP_MIC_LEN));
++
++	return 0;
+ }
+ 
+ ieee80211_tx_result
+@@ -1120,9 +1121,9 @@ ieee80211_crypto_aes_gmac_encrypt(struct
+ 	struct ieee80211_key *key = tx->key;
+ 	struct ieee80211_mmie_16 *mmie;
+ 	struct ieee80211_hdr *hdr;
+-	u8 aad[GMAC_AAD_LEN];
++	u8 aad[20];
+ 	u64 pn64;
+-	u8 nonce[GMAC_NONCE_LEN];
++	u8 nonce[12];
+ 
+ 	if (WARN_ON(skb_queue_len(&tx->skbs) != 1))
+ 		return TX_DROP;
+@@ -1168,7 +1169,7 @@ ieee80211_crypto_aes_gmac_decrypt(struct
+ 	struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
+ 	struct ieee80211_key *key = rx->key;
+ 	struct ieee80211_mmie_16 *mmie;
+-	u8 aad[GMAC_AAD_LEN], mic[GMAC_MIC_LEN], ipn[6], nonce[GMAC_NONCE_LEN];
++	u8 aad[20], mic[16], ipn[6], nonce[12];
+ 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+ 
+ 	if (!ieee80211_is_mgmt(hdr->frame_control))
+--- a/net/mac80211/aes_ccm.h
++++ b/net/mac80211/aes_ccm.h
+@@ -12,17 +12,15 @@
+ 
+ #include <linux/crypto.h>
+ 
+-#define CCM_AAD_LEN	32
+-
+-struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[],
+-						    size_t key_len,
+-						    size_t mic_len);
+-int ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
+-			      u8 *data, size_t data_len, u8 *mic,
+-			      size_t mic_len);
+-int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
++struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[],
++						      size_t key_len,
++						      size_t mic_len);
++void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad,
++			       u8 *data, size_t data_len, u8 *mic,
++			       size_t mic_len);
++int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad,
+ 			      u8 *data, size_t data_len, u8 *mic,
+ 			      size_t mic_len);
+-void ieee80211_aes_key_free(struct crypto_aead *tfm);
++void ieee80211_aes_key_free(struct crypto_cipher *tfm);
+ 
+ #endif /* AES_CCM_H */
+--- a/net/mac80211/aes_gcm.h
++++ b/net/mac80211/aes_gcm.h
+@@ -11,14 +11,28 @@
+ 
+ #include <linux/crypto.h>
+ 
+-#define GCM_AAD_LEN	32
++static inline void
++ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
++			  u8 *data, size_t data_len, u8 *mic)
++{
++}
+ 
+-int ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
+-			      u8 *data, size_t data_len, u8 *mic);
+-int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
+-			      u8 *data, size_t data_len, u8 *mic);
+-struct crypto_aead *ieee80211_aes_gcm_key_setup_encrypt(const u8 key[],
+-							size_t key_len);
+-void ieee80211_aes_gcm_key_free(struct crypto_aead *tfm);
++static inline int
++ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
++			  u8 *data, size_t data_len, u8 *mic)
++{
++    return -EOPNOTSUPP;
++}
++
++static inline struct crypto_aead *
++ieee80211_aes_gcm_key_setup_encrypt(const u8 key[], size_t key_len)
++{
++    return NULL;
++}
++
++static inline void
++ieee80211_aes_gcm_key_free(struct crypto_aead *tfm)
++{
++}
+ 
+ #endif /* AES_GCM_H */

+ 1 - 1
package/kernel/mac80211/patches/110-mac80211_keep_keys_on_stop_ap.patch

@@ -2,7 +2,7 @@ Used for AP+STA support in OpenWrt - preserve AP mode keys across STA reconnects
 
 --- a/net/mac80211/cfg.c
 +++ b/net/mac80211/cfg.c
-@@ -1016,7 +1016,6 @@ static int ieee80211_stop_ap(struct wiph
+@@ -1014,7 +1014,6 @@ static int ieee80211_stop_ap(struct wiph
  	sdata->u.ap.driver_smps_mode = IEEE80211_SMPS_OFF;
  
  	__sta_info_flush(sdata, true);

+ 1 - 1
package/kernel/mac80211/patches/130-mac80211-hwsim-hrtimer-clock.patch

@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/mac80211_hwsim.c
 +++ b/drivers/net/wireless/mac80211_hwsim.c
-@@ -2662,7 +2662,7 @@ static int mac80211_hwsim_new_radio(stru
+@@ -2678,7 +2678,7 @@ static int mac80211_hwsim_new_radio(stru
  
  	tasklet_hrtimer_init(&data->beacon_timer,
  			     mac80211_hwsim_beacon,

+ 3 - 3
package/kernel/mac80211/patches/150-disable_addr_notifier.patch

@@ -18,7 +18,7 @@
  static int ieee80211_ifa6_changed(struct notifier_block *nb,
  				  unsigned long data, void *arg)
  {
-@@ -1101,14 +1101,14 @@ int ieee80211_register_hw(struct ieee802
+@@ -1111,14 +1111,14 @@ int ieee80211_register_hw(struct ieee802
  	if (result)
  		goto fail_flows;
  
@@ -35,7 +35,7 @@
  	local->ifa6_notifier.notifier_call = ieee80211_ifa6_changed;
  	result = register_inet6addr_notifier(&local->ifa6_notifier);
  	if (result)
-@@ -1117,13 +1117,13 @@ int ieee80211_register_hw(struct ieee802
+@@ -1127,13 +1127,13 @@ int ieee80211_register_hw(struct ieee802
  
  	return 0;
  
@@ -52,7 +52,7 @@
   fail_ifa:
  #endif
  	ieee80211_txq_teardown_flows(local);
-@@ -1153,10 +1153,10 @@ void ieee80211_unregister_hw(struct ieee
+@@ -1163,10 +1163,10 @@ void ieee80211_unregister_hw(struct ieee
  	tasklet_kill(&local->tx_pending_tasklet);
  	tasklet_kill(&local->tasklet);
  

+ 1 - 1
package/kernel/mac80211/patches/210-ap_scan.patch

@@ -1,6 +1,6 @@
 --- a/net/mac80211/cfg.c
 +++ b/net/mac80211/cfg.c
-@@ -2175,7 +2175,7 @@ static int ieee80211_scan(struct wiphy *
+@@ -2165,7 +2165,7 @@ static int ieee80211_scan(struct wiphy *
  		 * the  frames sent while scanning on other channel will be
  		 * lost)
  		 */

+ 0 - 953
package/kernel/mac80211/patches/300-ath9k-Switch-to-using-mac80211-intermediate-software.patch

@@ -1,953 +0,0 @@
-From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk>
-Date: Fri, 2 Sep 2016 16:00:30 +0200
-Subject: [PATCH] ath9k: Switch to using mac80211 intermediate software
- queues.
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This switches ath9k over to using the mac80211 intermediate software
-queueing mechanism for data packets. It removes the queueing inside the
-driver, except for the retry queue, and instead pulls from mac80211 when
-a packet is needed. The retry queue is used to store a packet that was
-pulled but can't be sent immediately.
-
-The old code path in ath_tx_start that would queue packets has been
-removed completely, as has the qlen limit tunables (since there's no
-longer a queue in the driver to limit).
-
-Based on Tim's original patch set, but reworked quite thoroughly.
-
-Cc: Tim Shepard <shep@alum.mit.edu>
-Cc: Felix Fietkau <nbd@nbd.name>
-Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
----
-
---- a/drivers/net/wireless/ath/ath9k/ath9k.h
-+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -91,7 +91,6 @@ int ath_descdma_setup(struct ath_softc *
- #define ATH_RXBUF               512
- #define ATH_TXBUF               512
- #define ATH_TXBUF_RESERVE       5
--#define ATH_MAX_QDEPTH          (ATH_TXBUF / 4 - ATH_TXBUF_RESERVE)
- #define ATH_TXMAXTRY            13
- #define ATH_MAX_SW_RETRIES      30
- 
-@@ -145,7 +144,7 @@ int ath_descdma_setup(struct ath_softc *
- #define BAW_WITHIN(_start, _bawsz, _seqno) \
- 	((((_seqno) - (_start)) & 4095) < (_bawsz))
- 
--#define ATH_AN_2_TID(_an, _tidno)  (&(_an)->tid[(_tidno)])
-+#define ATH_AN_2_TID(_an, _tidno) ath_node_to_tid(_an, _tidno)
- 
- #define IS_HT_RATE(rate)   (rate & 0x80)
- #define IS_CCK_RATE(rate)  ((rate >= 0x18) && (rate <= 0x1e))
-@@ -164,7 +163,6 @@ struct ath_txq {
- 	spinlock_t axq_lock;
- 	u32 axq_depth;
- 	u32 axq_ampdu_depth;
--	bool stopped;
- 	bool axq_tx_inprogress;
- 	struct list_head txq_fifo[ATH_TXFIFO_DEPTH];
- 	u8 txq_headidx;
-@@ -232,7 +230,6 @@ struct ath_buf {
- 
- struct ath_atx_tid {
- 	struct list_head list;
--	struct sk_buff_head buf_q;
- 	struct sk_buff_head retry_q;
- 	struct ath_node *an;
- 	struct ath_txq *txq;
-@@ -247,13 +244,13 @@ struct ath_atx_tid {
- 	s8 bar_index;
- 	bool active;
- 	bool clear_ps_filter;
-+	bool has_queued;
- };
- 
- struct ath_node {
- 	struct ath_softc *sc;
- 	struct ieee80211_sta *sta; /* station struct we're part of */
- 	struct ieee80211_vif *vif; /* interface with which we're associated */
--	struct ath_atx_tid tid[IEEE80211_NUM_TIDS];
- 
- 	u16 maxampdu;
- 	u8 mpdudensity;
-@@ -276,7 +273,6 @@ struct ath_tx_control {
- 	struct ath_node *an;
- 	struct ieee80211_sta *sta;
- 	u8 paprd;
--	bool force_channel;
- };
- 
- 
-@@ -293,7 +289,6 @@ struct ath_tx {
- 	struct ath_descdma txdma;
- 	struct ath_txq *txq_map[IEEE80211_NUM_ACS];
- 	struct ath_txq *uapsdq;
--	u32 txq_max_pending[IEEE80211_NUM_ACS];
- 	u16 max_aggr_framelen[IEEE80211_NUM_ACS][4][32];
- };
- 
-@@ -421,6 +416,22 @@ struct ath_offchannel {
- 	int duration;
- };
- 
-+static inline struct ath_atx_tid *
-+ath_node_to_tid(struct ath_node *an, u8 tidno)
-+{
-+	struct ieee80211_sta *sta = an->sta;
-+	struct ieee80211_vif *vif = an->vif;
-+	struct ieee80211_txq *txq;
-+
-+	BUG_ON(!vif);
-+	if (sta)
-+		txq = sta->txq[tidno % ARRAY_SIZE(sta->txq)];
-+	else
-+		txq = vif->txq;
-+
-+	return (struct ath_atx_tid *) txq->drv_priv;
-+}
-+
- #define case_rtn_string(val) case val: return #val
- 
- #define ath_for_each_chanctx(_sc, _ctx)                             \
-@@ -575,7 +586,6 @@ void ath_tx_edma_tasklet(struct ath_soft
- int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
- 		      u16 tid, u16 *ssn);
- void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
--void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
- 
- void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an);
- void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc,
-@@ -585,6 +595,7 @@ void ath9k_release_buffered_frames(struc
- 				   u16 tids, int nframes,
- 				   enum ieee80211_frame_release_type reason,
- 				   bool more_data);
-+void ath9k_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *queue);
- 
- /********/
- /* VIFs */
---- a/drivers/net/wireless/ath/ath9k/channel.c
-+++ b/drivers/net/wireless/ath/ath9k/channel.c
-@@ -1010,7 +1010,6 @@ static void ath_scan_send_probe(struct a
- 		goto error;
- 
- 	txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
--	txctl.force_channel = true;
- 	if (ath_tx_start(sc->hw, skb, &txctl))
- 		goto error;
- 
-@@ -1133,7 +1132,6 @@ ath_chanctx_send_vif_ps_frame(struct ath
- 	memset(&txctl, 0, sizeof(txctl));
- 	txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
- 	txctl.sta = sta;
--	txctl.force_channel = true;
- 	if (ath_tx_start(sc->hw, skb, &txctl)) {
- 		ieee80211_free_txskb(sc->hw, skb);
- 		return false;
---- a/drivers/net/wireless/ath/ath9k/debug.c
-+++ b/drivers/net/wireless/ath/ath9k/debug.c
-@@ -600,7 +600,6 @@ static int read_file_xmit(struct seq_fil
- 	PR("MPDUs XRetried:  ", xretries);
- 	PR("Aggregates:      ", a_aggr);
- 	PR("AMPDUs Queued HW:", a_queued_hw);
--	PR("AMPDUs Queued SW:", a_queued_sw);
- 	PR("AMPDUs Completed:", a_completed);
- 	PR("AMPDUs Retried:  ", a_retries);
- 	PR("AMPDUs XRetried: ", a_xretries);
-@@ -629,8 +628,7 @@ static void print_queue(struct ath_softc
- 	seq_printf(file, "%s: %d ", "qnum", txq->axq_qnum);
- 	seq_printf(file, "%s: %2d ", "qdepth", txq->axq_depth);
- 	seq_printf(file, "%s: %2d ", "ampdu-depth", txq->axq_ampdu_depth);
--	seq_printf(file, "%s: %3d ", "pending", txq->pending_frames);
--	seq_printf(file, "%s: %d\n", "stopped", txq->stopped);
-+	seq_printf(file, "%s: %3d\n", "pending", txq->pending_frames);
- 
- 	ath_txq_unlock(sc, txq);
- }
-@@ -1208,7 +1206,6 @@ static const char ath9k_gstrings_stats[]
- 	AMKSTR(d_tx_mpdu_xretries),
- 	AMKSTR(d_tx_aggregates),
- 	AMKSTR(d_tx_ampdus_queued_hw),
--	AMKSTR(d_tx_ampdus_queued_sw),
- 	AMKSTR(d_tx_ampdus_completed),
- 	AMKSTR(d_tx_ampdu_retries),
- 	AMKSTR(d_tx_ampdu_xretries),
-@@ -1288,7 +1285,6 @@ void ath9k_get_et_stats(struct ieee80211
- 	AWDATA(xretries);
- 	AWDATA(a_aggr);
- 	AWDATA(a_queued_hw);
--	AWDATA(a_queued_sw);
- 	AWDATA(a_completed);
- 	AWDATA(a_retries);
- 	AWDATA(a_xretries);
-@@ -1346,14 +1342,6 @@ int ath9k_init_debug(struct ath_hw *ah)
- 				    read_file_xmit);
- 	debugfs_create_devm_seqfile(sc->dev, "queues", sc->debug.debugfs_phy,
- 				    read_file_queues);
--	debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
--			   &sc->tx.txq_max_pending[IEEE80211_AC_BK]);
--	debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
--			   &sc->tx.txq_max_pending[IEEE80211_AC_BE]);
--	debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
--			   &sc->tx.txq_max_pending[IEEE80211_AC_VI]);
--	debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
--			   &sc->tx.txq_max_pending[IEEE80211_AC_VO]);
- 	debugfs_create_devm_seqfile(sc->dev, "misc", sc->debug.debugfs_phy,
- 				    read_file_misc);
- 	debugfs_create_devm_seqfile(sc->dev, "reset", sc->debug.debugfs_phy,
---- a/drivers/net/wireless/ath/ath9k/debug.h
-+++ b/drivers/net/wireless/ath/ath9k/debug.h
-@@ -147,7 +147,6 @@ struct ath_interrupt_stats {
-  * @completed: Total MPDUs (non-aggr) completed
-  * @a_aggr: Total no. of aggregates queued
-  * @a_queued_hw: Total AMPDUs queued to hardware
-- * @a_queued_sw: Total AMPDUs queued to software queues
-  * @a_completed: Total AMPDUs completed
-  * @a_retries: No. of AMPDUs retried (SW)
-  * @a_xretries: No. of AMPDUs dropped due to xretries
-@@ -174,7 +173,6 @@ struct ath_tx_stats {
- 	u32 xretries;
- 	u32 a_aggr;
- 	u32 a_queued_hw;
--	u32 a_queued_sw;
- 	u32 a_completed;
- 	u32 a_retries;
- 	u32 a_xretries;
---- a/drivers/net/wireless/ath/ath9k/debug_sta.c
-+++ b/drivers/net/wireless/ath/ath9k/debug_sta.c
-@@ -52,8 +52,8 @@ static ssize_t read_file_node_aggr(struc
- 			 "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE",
- 			 "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED");
- 
--	for (tidno = 0, tid = &an->tid[tidno];
--	     tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
-+	for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
-+		tid = ath_node_to_tid(an, tidno);
- 		txq = tid->txq;
- 		ath_txq_lock(sc, txq);
- 		if (tid->active) {
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -358,7 +358,6 @@ static int ath9k_init_queues(struct ath_
- 	for (i = 0; i < IEEE80211_NUM_ACS; i++) {
- 		sc->tx.txq_map[i] = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, i);
- 		sc->tx.txq_map[i]->mac80211_qnum = i;
--		sc->tx.txq_max_pending[i] = ATH_MAX_QDEPTH;
- 	}
- 	return 0;
- }
-@@ -877,6 +876,7 @@ static void ath9k_set_hw_capab(struct at
- 	hw->max_rate_tries = 10;
- 	hw->sta_data_size = sizeof(struct ath_node);
- 	hw->vif_data_size = sizeof(struct ath_vif);
-+	hw->txq_data_size = sizeof(struct ath_atx_tid);
- 	hw->extra_tx_headroom = 4;
- 
- 	hw->wiphy->available_antennas_rx = BIT(ah->caps.max_rxchains) - 1;
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1902,9 +1902,11 @@ static int ath9k_ampdu_action(struct iee
- 	bool flush = false;
- 	int ret = 0;
- 	struct ieee80211_sta *sta = params->sta;
-+	struct ath_node *an = (struct ath_node *)sta->drv_priv;
- 	enum ieee80211_ampdu_mlme_action action = params->action;
- 	u16 tid = params->tid;
- 	u16 *ssn = &params->ssn;
-+	struct ath_atx_tid *atid;
- 
- 	mutex_lock(&sc->mutex);
- 
-@@ -1937,9 +1939,9 @@ static int ath9k_ampdu_action(struct iee
- 		ath9k_ps_restore(sc);
- 		break;
- 	case IEEE80211_AMPDU_TX_OPERATIONAL:
--		ath9k_ps_wakeup(sc);
--		ath_tx_aggr_resume(sc, sta, tid);
--		ath9k_ps_restore(sc);
-+		atid = ath_node_to_tid(an, tid);
-+		atid->baw_size = IEEE80211_MIN_AMPDU_BUF <<
-+			        sta->ht_cap.ampdu_factor;
- 		break;
- 	default:
- 		ath_err(ath9k_hw_common(sc->sc_ah), "Unknown AMPDU action\n");
-@@ -2701,4 +2703,5 @@ struct ieee80211_ops ath9k_ops = {
- 	.sw_scan_start	    = ath9k_sw_scan_start,
- 	.sw_scan_complete   = ath9k_sw_scan_complete,
- 	.get_txpower        = ath9k_get_txpower,
-+	.wake_tx_queue      = ath9k_wake_tx_queue,
- };
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -67,6 +67,8 @@ static struct ath_buf *ath_tx_setup_buff
- 					   struct ath_txq *txq,
- 					   struct ath_atx_tid *tid,
- 					   struct sk_buff *skb);
-+static int ath_tx_prepare(struct ieee80211_hw *hw, struct sk_buff *skb,
-+			  struct ath_tx_control *txctl);
- 
- enum {
- 	MCS_HT20,
-@@ -137,6 +139,26 @@ static void ath_tx_queue_tid(struct ath_
- 		list_add_tail(&tid->list, list);
- }
- 
-+void ath9k_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *queue)
-+{
-+	struct ath_softc *sc = hw->priv;
-+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-+	struct ath_atx_tid *tid = (struct ath_atx_tid *) queue->drv_priv;
-+	struct ath_txq *txq = tid->txq;
-+
-+	ath_dbg(common, QUEUE, "Waking TX queue: %pM (%d)\n",
-+		queue->sta ? queue->sta->addr : queue->vif->addr,
-+		tid->tidno);
-+
-+	ath_txq_lock(sc, txq);
-+
-+	tid->has_queued = true;
-+	ath_tx_queue_tid(sc, txq, tid);
-+	ath_txq_schedule(sc, txq);
-+
-+	ath_txq_unlock(sc, txq);
-+}
-+
- static struct ath_frame_info *get_frame_info(struct sk_buff *skb)
- {
- 	struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
-@@ -164,7 +186,6 @@ static void ath_set_rates(struct ieee802
- static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
- 			     struct sk_buff *skb)
- {
--	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
- 	struct ath_frame_info *fi = get_frame_info(skb);
- 	int q = fi->txq;
- 
-@@ -175,14 +196,6 @@ static void ath_txq_skb_done(struct ath_
- 	if (WARN_ON(--txq->pending_frames < 0))
- 		txq->pending_frames = 0;
- 
--	if (txq->stopped &&
--	    txq->pending_frames < sc->tx.txq_max_pending[q]) {
--		if (ath9k_is_chanctx_enabled())
--			ieee80211_wake_queue(sc->hw, info->hw_queue);
--		else
--			ieee80211_wake_queue(sc->hw, q);
--		txq->stopped = false;
--	}
- }
- 
- static struct ath_atx_tid *
-@@ -192,9 +205,48 @@ ath_get_skb_tid(struct ath_softc *sc, st
- 	return ATH_AN_2_TID(an, tidno);
- }
- 
-+static struct sk_buff *
-+ath_tid_pull(struct ath_atx_tid *tid)
-+{
-+	struct ieee80211_txq *txq = container_of((void*)tid, struct ieee80211_txq, drv_priv);
-+	struct ath_softc *sc = tid->an->sc;
-+	struct ieee80211_hw *hw = sc->hw;
-+	struct ath_tx_control txctl = {
-+		.txq = tid->txq,
-+		.sta = tid->an->sta,
-+	};
-+	struct sk_buff *skb;
-+	struct ath_frame_info *fi;
-+	int q;
-+
-+	if (!tid->has_queued)
-+		return NULL;
-+
-+	skb = ieee80211_tx_dequeue(hw, txq);
-+	if (!skb) {
-+		tid->has_queued = false;
-+		return NULL;
-+	}
-+
-+	if (ath_tx_prepare(hw, skb, &txctl)) {
-+		ieee80211_free_txskb(hw, skb);
-+		return NULL;
-+	}
-+
-+	q = skb_get_queue_mapping(skb);
-+	if (tid->txq == sc->tx.txq_map[q]) {
-+		fi = get_frame_info(skb);
-+		fi->txq = q;
-+		++tid->txq->pending_frames;
-+	}
-+
-+	return skb;
-+ }
-+
-+
- static bool ath_tid_has_buffered(struct ath_atx_tid *tid)
- {
--	return !skb_queue_empty(&tid->buf_q) || !skb_queue_empty(&tid->retry_q);
-+	return !skb_queue_empty(&tid->retry_q) || tid->has_queued;
- }
- 
- static struct sk_buff *ath_tid_dequeue(struct ath_atx_tid *tid)
-@@ -203,46 +255,11 @@ static struct sk_buff *ath_tid_dequeue(s
- 
- 	skb = __skb_dequeue(&tid->retry_q);
- 	if (!skb)
--		skb = __skb_dequeue(&tid->buf_q);
-+		skb = ath_tid_pull(tid);
- 
- 	return skb;
- }
- 
--/*
-- * ath_tx_tid_change_state:
-- * - clears a-mpdu flag of previous session
-- * - force sequence number allocation to fix next BlockAck Window
-- */
--static void
--ath_tx_tid_change_state(struct ath_softc *sc, struct ath_atx_tid *tid)
--{
--	struct ath_txq *txq = tid->txq;
--	struct ieee80211_tx_info *tx_info;
--	struct sk_buff *skb, *tskb;
--	struct ath_buf *bf;
--	struct ath_frame_info *fi;
--
--	skb_queue_walk_safe(&tid->buf_q, skb, tskb) {
--		fi = get_frame_info(skb);
--		bf = fi->bf;
--
--		tx_info = IEEE80211_SKB_CB(skb);
--		tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
--
--		if (bf)
--			continue;
--
--		bf = ath_tx_setup_buffer(sc, txq, tid, skb);
--		if (!bf) {
--			__skb_unlink(skb, &tid->buf_q);
--			ath_txq_skb_done(sc, txq, skb);
--			ieee80211_free_txskb(sc->hw, skb);
--			continue;
--		}
--	}
--
--}
--
- static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
- {
- 	struct ath_txq *txq = tid->txq;
-@@ -883,20 +900,16 @@ static int ath_compute_num_delims(struct
- 
- static struct ath_buf *
- ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,
--			struct ath_atx_tid *tid, struct sk_buff_head **q)
-+			struct ath_atx_tid *tid)
- {
- 	struct ieee80211_tx_info *tx_info;
- 	struct ath_frame_info *fi;
--	struct sk_buff *skb;
-+	struct sk_buff *skb, *first_skb = NULL;
- 	struct ath_buf *bf;
- 	u16 seqno;
- 
- 	while (1) {
--		*q = &tid->retry_q;
--		if (skb_queue_empty(*q))
--			*q = &tid->buf_q;
--
--		skb = skb_peek(*q);
-+		skb = ath_tid_dequeue(tid);
- 		if (!skb)
- 			break;
- 
-@@ -908,7 +921,6 @@ ath_tx_get_tid_subframe(struct ath_softc
- 			bf->bf_state.stale = false;
- 
- 		if (!bf) {
--			__skb_unlink(skb, *q);
- 			ath_txq_skb_done(sc, txq, skb);
- 			ieee80211_free_txskb(sc->hw, skb);
- 			continue;
-@@ -937,8 +949,20 @@ ath_tx_get_tid_subframe(struct ath_softc
- 		seqno = bf->bf_state.seqno;
- 
- 		/* do not step over block-ack window */
--		if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno))
-+		if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) {
-+			__skb_queue_tail(&tid->retry_q, skb);
-+
-+			/* If there are other skbs in the retry q, they are
-+			 * probably within the BAW, so loop immediately to get
-+			 * one of them. Otherwise the queue can get stuck. */
-+			if (!skb_queue_is_first(&tid->retry_q, skb) &&
-+			    !WARN_ON(skb == first_skb)) {
-+				if(!first_skb) /* infinite loop prevention */
-+					first_skb = skb;
-+				continue;
-+			}
- 			break;
-+		}
- 
- 		if (tid->bar_index > ATH_BA_INDEX(tid->seq_start, seqno)) {
- 			struct ath_tx_status ts = {};
-@@ -946,7 +970,6 @@ ath_tx_get_tid_subframe(struct ath_softc
- 
- 			INIT_LIST_HEAD(&bf_head);
- 			list_add(&bf->list, &bf_head);
--			__skb_unlink(skb, *q);
- 			ath_tx_update_baw(sc, tid, seqno);
- 			ath_tx_complete_buf(sc, bf, txq, &bf_head, NULL, &ts, 0);
- 			continue;
-@@ -958,11 +981,10 @@ ath_tx_get_tid_subframe(struct ath_softc
- 	return NULL;
- }
- 
--static bool
-+static int
- ath_tx_form_aggr(struct ath_softc *sc, struct ath_txq *txq,
- 		 struct ath_atx_tid *tid, struct list_head *bf_q,
--		 struct ath_buf *bf_first, struct sk_buff_head *tid_q,
--		 int *aggr_len)
-+		 struct ath_buf *bf_first)
- {
- #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4)
- 	struct ath_buf *bf = bf_first, *bf_prev = NULL;
-@@ -972,12 +994,13 @@ ath_tx_form_aggr(struct ath_softc *sc, s
- 	struct ieee80211_tx_info *tx_info;
- 	struct ath_frame_info *fi;
- 	struct sk_buff *skb;
--	bool closed = false;
-+
- 
- 	bf = bf_first;
- 	aggr_limit = ath_lookup_rate(sc, bf, tid);
- 
--	do {
-+	while (bf)
-+	{
- 		skb = bf->bf_mpdu;
- 		fi = get_frame_info(skb);
- 
-@@ -986,12 +1009,12 @@ ath_tx_form_aggr(struct ath_softc *sc, s
- 		if (nframes) {
- 			if (aggr_limit < al + bpad + al_delta ||
- 			    ath_lookup_legacy(bf) || nframes >= h_baw)
--				break;
-+				goto stop;
- 
- 			tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
- 			if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) ||
- 			    !(tx_info->flags & IEEE80211_TX_CTL_AMPDU))
--				break;
-+				goto stop;
- 		}
- 
- 		/* add padding for previous frame to aggregation length */
-@@ -1013,20 +1036,18 @@ ath_tx_form_aggr(struct ath_softc *sc, s
- 			ath_tx_addto_baw(sc, tid, bf);
- 		bf->bf_state.ndelim = ndelim;
- 
--		__skb_unlink(skb, tid_q);
- 		list_add_tail(&bf->list, bf_q);
- 		if (bf_prev)
- 			bf_prev->bf_next = bf;
- 
- 		bf_prev = bf;
- 
--		bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
--		if (!bf) {
--			closed = true;
--			break;
--		}
--	} while (ath_tid_has_buffered(tid));
--
-+		bf = ath_tx_get_tid_subframe(sc, txq, tid);
-+	}
-+	goto finish;
-+stop:
-+	__skb_queue_tail(&tid->retry_q, bf->bf_mpdu);
-+finish:
- 	bf = bf_first;
- 	bf->bf_lastbf = bf_prev;
- 
-@@ -1037,9 +1058,7 @@ ath_tx_form_aggr(struct ath_softc *sc, s
- 		TX_STAT_INC(txq->axq_qnum, a_aggr);
- 	}
- 
--	*aggr_len = al;
--
--	return closed;
-+	return al;
- #undef PADBYTES
- }
- 
-@@ -1416,18 +1435,15 @@ static void ath_tx_fill_desc(struct ath_
- static void
- ath_tx_form_burst(struct ath_softc *sc, struct ath_txq *txq,
- 		  struct ath_atx_tid *tid, struct list_head *bf_q,
--		  struct ath_buf *bf_first, struct sk_buff_head *tid_q)
-+		  struct ath_buf *bf_first)
- {
- 	struct ath_buf *bf = bf_first, *bf_prev = NULL;
--	struct sk_buff *skb;
- 	int nframes = 0;
- 
- 	do {
- 		struct ieee80211_tx_info *tx_info;
--		skb = bf->bf_mpdu;
- 
- 		nframes++;
--		__skb_unlink(skb, tid_q);
- 		list_add_tail(&bf->list, bf_q);
- 		if (bf_prev)
- 			bf_prev->bf_next = bf;
-@@ -1436,13 +1452,15 @@ ath_tx_form_burst(struct ath_softc *sc,
- 		if (nframes >= 2)
- 			break;
- 
--		bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
-+		bf = ath_tx_get_tid_subframe(sc, txq, tid);
- 		if (!bf)
- 			break;
- 
- 		tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
--		if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
-+		if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
-+			__skb_queue_tail(&tid->retry_q, bf->bf_mpdu);
- 			break;
-+		}
- 
- 		ath_set_rates(tid->an->vif, tid->an->sta, bf);
- 	} while (1);
-@@ -1453,34 +1471,33 @@ static bool ath_tx_sched_aggr(struct ath
- {
- 	struct ath_buf *bf;
- 	struct ieee80211_tx_info *tx_info;
--	struct sk_buff_head *tid_q;
- 	struct list_head bf_q;
- 	int aggr_len = 0;
--	bool aggr, last = true;
-+	bool aggr;
- 
- 	if (!ath_tid_has_buffered(tid))
- 		return false;
- 
- 	INIT_LIST_HEAD(&bf_q);
- 
--	bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
-+	bf = ath_tx_get_tid_subframe(sc, txq, tid);
- 	if (!bf)
- 		return false;
- 
- 	tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
- 	aggr = !!(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
- 	if ((aggr && txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) ||
--		(!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) {
-+	    (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) {
-+		__skb_queue_tail(&tid->retry_q, bf->bf_mpdu);
- 		*stop = true;
- 		return false;
- 	}
- 
- 	ath_set_rates(tid->an->vif, tid->an->sta, bf);
- 	if (aggr)
--		last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf,
--					tid_q, &aggr_len);
-+		aggr_len = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf);
- 	else
--		ath_tx_form_burst(sc, txq, tid, &bf_q, bf, tid_q);
-+		ath_tx_form_burst(sc, txq, tid, &bf_q, bf);
- 
- 	if (list_empty(&bf_q))
- 		return false;
-@@ -1523,9 +1540,6 @@ int ath_tx_aggr_start(struct ath_softc *
- 		an->mpdudensity = density;
- 	}
- 
--	/* force sequence number allocation for pending frames */
--	ath_tx_tid_change_state(sc, txtid);
--
- 	txtid->active = true;
- 	*ssn = txtid->seq_start = txtid->seq_next;
- 	txtid->bar_index = -1;
-@@ -1550,7 +1564,6 @@ void ath_tx_aggr_stop(struct ath_softc *
- 	ath_txq_lock(sc, txq);
- 	txtid->active = false;
- 	ath_tx_flush_tid(sc, txtid);
--	ath_tx_tid_change_state(sc, txtid);
- 	ath_txq_unlock_complete(sc, txq);
- }
- 
-@@ -1560,14 +1573,12 @@ void ath_tx_aggr_sleep(struct ieee80211_
- 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
- 	struct ath_atx_tid *tid;
- 	struct ath_txq *txq;
--	bool buffered;
- 	int tidno;
- 
- 	ath_dbg(common, XMIT, "%s called\n", __func__);
- 
--	for (tidno = 0, tid = &an->tid[tidno];
--	     tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
--
-+	for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
-+		tid = ath_node_to_tid(an, tidno);
- 		txq = tid->txq;
- 
- 		ath_txq_lock(sc, txq);
-@@ -1577,13 +1588,12 @@ void ath_tx_aggr_sleep(struct ieee80211_
- 			continue;
- 		}
- 
--		buffered = ath_tid_has_buffered(tid);
-+		if (!skb_queue_empty(&tid->retry_q))
-+			ieee80211_sta_set_buffered(sta, tid->tidno, true);
- 
- 		list_del_init(&tid->list);
- 
- 		ath_txq_unlock(sc, txq);
--
--		ieee80211_sta_set_buffered(sta, tidno, buffered);
- 	}
- }
- 
-@@ -1596,49 +1606,20 @@ void ath_tx_aggr_wakeup(struct ath_softc
- 
- 	ath_dbg(common, XMIT, "%s called\n", __func__);
- 
--	for (tidno = 0, tid = &an->tid[tidno];
--	     tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
--
-+	for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
-+		tid = ath_node_to_tid(an, tidno);
- 		txq = tid->txq;
- 
- 		ath_txq_lock(sc, txq);
- 		tid->clear_ps_filter = true;
--
- 		if (ath_tid_has_buffered(tid)) {
- 			ath_tx_queue_tid(sc, txq, tid);
- 			ath_txq_schedule(sc, txq);
- 		}
--
- 		ath_txq_unlock_complete(sc, txq);
- 	}
- }
- 
--void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta,
--			u16 tidno)
--{
--	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
--	struct ath_atx_tid *tid;
--	struct ath_node *an;
--	struct ath_txq *txq;
--
--	ath_dbg(common, XMIT, "%s called\n", __func__);
--
--	an = (struct ath_node *)sta->drv_priv;
--	tid = ATH_AN_2_TID(an, tidno);
--	txq = tid->txq;
--
--	ath_txq_lock(sc, txq);
--
--	tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor;
--
--	if (ath_tid_has_buffered(tid)) {
--		ath_tx_queue_tid(sc, txq, tid);
--		ath_txq_schedule(sc, txq);
--	}
--
--	ath_txq_unlock_complete(sc, txq);
--}
--
- void ath9k_release_buffered_frames(struct ieee80211_hw *hw,
- 				   struct ieee80211_sta *sta,
- 				   u16 tids, int nframes,
-@@ -1651,7 +1632,6 @@ void ath9k_release_buffered_frames(struc
- 	struct ieee80211_tx_info *info;
- 	struct list_head bf_q;
- 	struct ath_buf *bf_tail = NULL, *bf;
--	struct sk_buff_head *tid_q;
- 	int sent = 0;
- 	int i;
- 
-@@ -1666,11 +1646,10 @@ void ath9k_release_buffered_frames(struc
- 
- 		ath_txq_lock(sc, tid->txq);
- 		while (nframes > 0) {
--			bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid, &tid_q);
-+			bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid);
- 			if (!bf)
- 				break;
- 
--			__skb_unlink(bf->bf_mpdu, tid_q);
- 			list_add_tail(&bf->list, &bf_q);
- 			ath_set_rates(tid->an->vif, tid->an->sta, bf);
- 			if (bf_isampdu(bf)) {
-@@ -1685,7 +1664,7 @@ void ath9k_release_buffered_frames(struc
- 			sent++;
- 			TX_STAT_INC(txq->axq_qnum, a_queued_hw);
- 
--			if (an->sta && !ath_tid_has_buffered(tid))
-+			if (an->sta && skb_queue_empty(&tid->retry_q))
- 				ieee80211_sta_set_buffered(an->sta, i, false);
- 		}
- 		ath_txq_unlock_complete(sc, tid->txq);
-@@ -1914,13 +1893,7 @@ bool ath_drain_all_txq(struct ath_softc
- 		if (!ATH_TXQ_SETUP(sc, i))
- 			continue;
- 
--		/*
--		 * The caller will resume queues with ieee80211_wake_queues.
--		 * Mark the queue as not stopped to prevent ath_tx_complete
--		 * from waking the queue too early.
--		 */
- 		txq = &sc->tx.txq[i];
--		txq->stopped = false;
- 		ath_draintxq(sc, txq);
- 	}
- 
-@@ -2319,16 +2292,14 @@ int ath_tx_start(struct ieee80211_hw *hw
- 	struct ath_softc *sc = hw->priv;
- 	struct ath_txq *txq = txctl->txq;
- 	struct ath_atx_tid *tid = NULL;
-+	struct ath_node *an = NULL;
- 	struct ath_buf *bf;
--	bool queue, skip_uapsd = false, ps_resp;
-+	bool ps_resp;
- 	int q, ret;
- 
- 	if (vif)
- 		avp = (void *)vif->drv_priv;
- 
--	if (info->flags & IEEE80211_TX_CTL_TX_OFFCHAN)
--		txctl->force_channel = true;
--
- 	ps_resp = !!(info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE);
- 
- 	ret = ath_tx_prepare(hw, skb, txctl);
-@@ -2343,63 +2314,18 @@ int ath_tx_start(struct ieee80211_hw *hw
- 
- 	q = skb_get_queue_mapping(skb);
- 
--	ath_txq_lock(sc, txq);
--	if (txq == sc->tx.txq_map[q]) {
--		fi->txq = q;
--		if (++txq->pending_frames > sc->tx.txq_max_pending[q] &&
--		    !txq->stopped) {
--			if (ath9k_is_chanctx_enabled())
--				ieee80211_stop_queue(sc->hw, info->hw_queue);
--			else
--				ieee80211_stop_queue(sc->hw, q);
--			txq->stopped = true;
--		}
--	}
--
--	queue = ieee80211_is_data_present(hdr->frame_control);
--
--	/* If chanctx, queue all null frames while NOA could be there */
--	if (ath9k_is_chanctx_enabled() &&
--	    ieee80211_is_nullfunc(hdr->frame_control) &&
--	    !txctl->force_channel)
--		queue = true;
--
--	/* Force queueing of all frames that belong to a virtual interface on
--	 * a different channel context, to ensure that they are sent on the
--	 * correct channel.
--	 */
--	if (((avp && avp->chanctx != sc->cur_chan) ||
--	     sc->cur_chan->stopped) && !txctl->force_channel) {
--		if (!txctl->an)
--			txctl->an = &avp->mcast_node;
--		queue = true;
--		skip_uapsd = true;
--	}
--
--	if (txctl->an && queue)
--		tid = ath_get_skb_tid(sc, txctl->an, skb);
--
--	if (!skip_uapsd && ps_resp) {
--		ath_txq_unlock(sc, txq);
-+	if (ps_resp)
- 		txq = sc->tx.uapsdq;
--		ath_txq_lock(sc, txq);
--	} else if (txctl->an && queue) {
--		WARN_ON(tid->txq != txctl->txq);
--
--		if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
--			tid->clear_ps_filter = true;
- 
--		/*
--		 * Add this frame to software queue for scheduling later
--		 * for aggregation.
--		 */
--		TX_STAT_INC(txq->axq_qnum, a_queued_sw);
--		__skb_queue_tail(&tid->buf_q, skb);
--		if (!txctl->an->sleeping)
--			ath_tx_queue_tid(sc, txq, tid);
-+	if (txctl->sta) {
-+		an = (struct ath_node *) sta->drv_priv;
-+		tid = ath_get_skb_tid(sc, an, skb);
-+	}
- 
--		ath_txq_schedule(sc, txq);
--		goto out;
-+	ath_txq_lock(sc, txq);
-+	if (txq == sc->tx.txq_map[q]) {
-+		fi->txq = q;
-+		++txq->pending_frames;
- 	}
- 
- 	bf = ath_tx_setup_buffer(sc, txq, tid, skb);
-@@ -2892,9 +2818,8 @@ void ath_tx_node_init(struct ath_softc *
- 	struct ath_atx_tid *tid;
- 	int tidno, acno;
- 
--	for (tidno = 0, tid = &an->tid[tidno];
--	     tidno < IEEE80211_NUM_TIDS;
--	     tidno++, tid++) {
-+	for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
-+		tid = ath_node_to_tid(an, tidno);
- 		tid->an        = an;
- 		tid->tidno     = tidno;
- 		tid->seq_start = tid->seq_next = 0;
-@@ -2902,11 +2827,14 @@ void ath_tx_node_init(struct ath_softc *
- 		tid->baw_head  = tid->baw_tail = 0;
- 		tid->active	   = false;
- 		tid->clear_ps_filter = true;
--		__skb_queue_head_init(&tid->buf_q);
-+		tid->has_queued  = false;
- 		__skb_queue_head_init(&tid->retry_q);
- 		INIT_LIST_HEAD(&tid->list);
- 		acno = TID_TO_WME_AC(tidno);
- 		tid->txq = sc->tx.txq_map[acno];
-+
-+		if (!an->sta)
-+			break; /* just one multicast ath_atx_tid */
- 	}
- }
- 
-@@ -2916,9 +2844,8 @@ void ath_tx_node_cleanup(struct ath_soft
- 	struct ath_txq *txq;
- 	int tidno;
- 
--	for (tidno = 0, tid = &an->tid[tidno];
--	     tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
--
-+	for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
-+		tid = ath_node_to_tid(an, tidno);
- 		txq = tid->txq;
- 
- 		ath_txq_lock(sc, txq);
-@@ -2930,6 +2857,9 @@ void ath_tx_node_cleanup(struct ath_soft
- 		tid->active = false;
- 
- 		ath_txq_unlock(sc, txq);
-+
-+		if (!an->sta)
-+			break; /* just one multicast ath_atx_tid */
- 	}
- }
- 

+ 0 - 0
package/kernel/mac80211/patches/314-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch → package/kernel/mac80211/patches/300-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch


+ 27 - 24
package/kernel/mac80211/patches/315-ath9k_hw-issue-external-reset-for-QCA955x.patch → package/kernel/mac80211/patches/301-ath9k_hw-issue-external-reset-for-QCA955x.patch

@@ -29,6 +29,21 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 -		npend = ath9k_hw_numtxpending(ah, i);
 -		if (npend)
 -			break;
+-	}
+-
+-	if (ah->external_reset &&
+-	    (npend || type == ATH9K_RESET_COLD)) {
+-		int reset_err = 0;
+-
+-		ath_dbg(ath9k_hw_common(ah), RESET,
+-			"reset MAC via external reset\n");
+-
+-		reset_err = ah->external_reset();
+-		if (reset_err) {
+-			ath_err(ath9k_hw_common(ah),
+-				"External reset failed, err=%d\n",
+-				reset_err);
+-			return false;
 +	if (type == ATH9K_RESET_COLD)
 +		return true;
 +
@@ -44,47 +59,35 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 +		for (i = 0; i < AR_NUM_QCU; i++) {
 +			if (ath9k_hw_numtxpending(ah, i))
 +				return true;
-+		}
- 	}
- 
--	if (ah->external_reset &&
--	    (npend || type == ATH9K_RESET_COLD)) {
--		int reset_err = 0;
+ 		}
++	}
++
 +	return false;
 +}
- 
--		ath_dbg(ath9k_hw_common(ah), RESET,
--			"reset MAC via external reset\n");
++
 +static bool ath9k_hw_external_reset(struct ath_hw *ah, int type)
 +{
 +	int err;
- 
--		reset_err = ah->external_reset();
--		if (reset_err) {
--			ath_err(ath9k_hw_common(ah),
--				"External reset failed, err=%d\n",
--				reset_err);
--			return false;
--		}
++
 +	if (!ah->external_reset || !ath9k_hw_need_external_reset(ah, type))
 +		return true;
- 
--		REG_WRITE(ah, AR_RTC_RESET, 1);
++
 +	ath_dbg(ath9k_hw_common(ah), RESET,
 +		"reset MAC via external reset\n");
-+
+ 
+-		REG_WRITE(ah, AR_RTC_RESET, 1);
 +	err = ah->external_reset();
 +	if (err) {
 +		ath_err(ath9k_hw_common(ah),
 +			"External reset failed, err=%d\n", err);
 +		return false;
-+	}
-+
+ 	}
+ 
 +	if (AR_SREV_9550(ah)) {
 +		REG_WRITE(ah, AR_RTC_RESET, 0);
 +		udelay(10);
- 	}
- 
++	}
++
 +	REG_WRITE(ah, AR_RTC_RESET, 1);
 +	udelay(10);
 +

+ 0 - 0
package/kernel/mac80211/patches/316-ath9k_hw-set-spectral-scan-enable-bit-on-trigger-for.patch → package/kernel/mac80211/patches/302-ath9k_hw-set-spectral-scan-enable-bit-on-trigger-for.patch


+ 2 - 1
package/kernel/mac80211/patches/347-ath9k-don-t-run-periodic-and-nf-calibation-at-the-sa.patch → package/kernel/mac80211/patches/303-ath9k-don-t-run-periodic-and-nf-calibation-at-the-sa.patch

@@ -1,6 +1,7 @@
 From: Felix Fietkau <nbd@nbd.name>
 Date: Tue, 27 Dec 2016 23:16:23 +0100
-Subject: [PATCH] ath9k: don't run periodic and nf calibation at the same time
+Subject: [PATCH] ath9k: don't run periodic and nf calibation at the same
+ time
 
 The checks already prevents periodic cal from being started while noise
 floor calibration runs. It is missing checks for the other way around.

+ 1 - 1
package/kernel/mac80211/patches/301-ath9k-force-rx_clear-when-disabling-rx.patch → package/kernel/mac80211/patches/304-ath9k-force-rx_clear-when-disabling-rx.patch

@@ -27,7 +27,7 @@ Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
 -	REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_ABORT | AR_DIAG_RX_DIS);
 +	u32 reg = AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT;
 +
-+	if (!config_enabled(CPTCFG_ATH9K_TX99))
++	if (!IS_ENABLED(CPTCFG_ATH9K_TX99))
 +		reg |= AR_DIAG_FORCE_RX_CLEAR;
 +	REG_SET_BIT(ah, AR_DIAG_SW, reg);
  

+ 7 - 7
package/kernel/mac80211/patches/302-ath9k-limit-retries-for-powersave-response-frames.patch → package/kernel/mac80211/patches/305-ath9k-limit-retries-for-powersave-response-frames.patch

@@ -13,7 +13,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
 
 --- a/drivers/net/wireless/ath/ath9k/xmit.c
 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -177,10 +177,25 @@ static void ath_send_bar(struct ath_atx_
+@@ -188,10 +188,25 @@ static void ath_send_bar(struct ath_atx_
  }
  
  static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
@@ -40,7 +40,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
  }
  
  static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
-@@ -1462,7 +1477,7 @@ ath_tx_form_burst(struct ath_softc *sc,
+@@ -1522,7 +1537,7 @@ ath_tx_form_burst(struct ath_softc *sc,
  			break;
  		}
  
@@ -49,7 +49,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
  	} while (1);
  }
  
-@@ -1493,7 +1508,7 @@ static bool ath_tx_sched_aggr(struct ath
+@@ -1552,7 +1567,7 @@ static bool ath_tx_sched_aggr(struct ath
  		return false;
  	}
  
@@ -58,7 +58,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
  	if (aggr)
  		aggr_len = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf);
  	else
-@@ -1651,7 +1666,7 @@ void ath9k_release_buffered_frames(struc
+@@ -1710,7 +1725,7 @@ void ath9k_release_buffered_frames(struc
  				break;
  
  			list_add_tail(&bf->list, &bf_q);
@@ -67,7 +67,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
  			if (bf_isampdu(bf)) {
  				ath_tx_addto_baw(sc, tid, bf);
  				bf->bf_state.bf_type &= ~BUF_AGGR;
-@@ -2343,7 +2358,7 @@ int ath_tx_start(struct ieee80211_hw *hw
+@@ -2410,7 +2425,7 @@ int ath_tx_start(struct ieee80211_hw *hw
  	if (txctl->paprd)
  		bf->bf_state.bfs_paprd_timestamp = jiffies;
  
@@ -76,7 +76,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
  	ath_tx_send_normal(sc, txq, tid, skb);
  
  out:
-@@ -2382,7 +2397,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw
+@@ -2449,7 +2464,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw
  			break;
  
  		bf->bf_lastbf = bf;
@@ -85,7 +85,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
  		ath_buf_set_rate(sc, bf, &info, fi->framelen, false);
  		duration += info.rates[0].PktDuration;
  		if (bf_tail)
-@@ -2898,7 +2913,7 @@ int ath9k_tx99_send(struct ath_softc *sc
+@@ -2968,7 +2983,7 @@ int ath9k_tx99_send(struct ath_softc *sc
  		return -EINVAL;
  	}
  

+ 2 - 2
package/kernel/mac80211/patches/303-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch → package/kernel/mac80211/patches/306-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch

@@ -8,7 +8,7 @@ This reverts commit 71f5137bf010c6faffab50c0ec15374c59c4a411.
 
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -2910,7 +2910,8 @@ void ath9k_hw_apply_txpower(struct ath_h
+@@ -2931,7 +2931,8 @@ void ath9k_hw_apply_txpower(struct ath_h
  {
  	struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
  	struct ieee80211_channel *channel;
@@ -18,7 +18,7 @@ This reverts commit 71f5137bf010c6faffab50c0ec15374c59c4a411.
  
  	if (!chan)
  		return;
-@@ -2918,10 +2919,15 @@ void ath9k_hw_apply_txpower(struct ath_h
+@@ -2939,10 +2940,15 @@ void ath9k_hw_apply_txpower(struct ath_h
  	channel = chan->chan;
  	chan_pwr = min_t(int, channel->max_power * 2, MAX_RATE_POWER);
  	new_pwr = min_t(int, chan_pwr, reg->power_limit);

+ 11 - 11
package/kernel/mac80211/patches/304-mac80211-add-hdrlen-to-ieee80211_tx_data.patch → package/kernel/mac80211/patches/307-mac80211-add-hdrlen-to-ieee80211_tx_data.patch

@@ -11,7 +11,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
 
 --- a/net/mac80211/ieee80211_i.h
 +++ b/net/mac80211/ieee80211_i.h
-@@ -175,6 +175,7 @@ struct ieee80211_tx_data {
+@@ -177,6 +177,7 @@ struct ieee80211_tx_data {
  	struct ieee80211_tx_rate rate;
  
  	unsigned int flags;
@@ -21,7 +21,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  
 --- a/net/mac80211/tx.c
 +++ b/net/mac80211/tx.c
-@@ -955,7 +955,7 @@ ieee80211_tx_h_fragment(struct ieee80211
+@@ -925,7 +925,7 @@ ieee80211_tx_h_fragment(struct ieee80211
  	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  	struct ieee80211_hdr *hdr = (void *)skb->data;
  	int frag_threshold = tx->local->hw.wiphy->frag_threshold;
@@ -30,7 +30,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  	int fragnum;
  
  	/* no matter what happens, tx->skb moves to tx->skbs */
-@@ -976,8 +976,6 @@ ieee80211_tx_h_fragment(struct ieee80211
+@@ -946,8 +946,6 @@ ieee80211_tx_h_fragment(struct ieee80211
  	if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU))
  		return TX_DROP;
  
@@ -39,7 +39,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  	/* internal error, why isn't DONTFRAG set? */
  	if (WARN_ON(skb->len + FCS_LEN <= frag_threshold))
  		return TX_DROP;
-@@ -1209,6 +1207,8 @@ ieee80211_tx_prepare(struct ieee80211_su
+@@ -1179,6 +1177,8 @@ ieee80211_tx_prepare(struct ieee80211_su
  
  	hdr = (struct ieee80211_hdr *) skb->data;
  
@@ -48,7 +48,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  	if (likely(sta)) {
  		if (!IS_ERR(sta))
  			tx->sta = sta;
-@@ -3414,6 +3414,7 @@ begin:
+@@ -3437,6 +3437,7 @@ begin:
  	tx.local = local;
  	tx.skb = skb;
  	tx.sdata = vif_to_sdata(info->control.vif);
@@ -56,7 +56,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  
  	if (txq->sta)
  		tx.sta = container_of(txq->sta, struct sta_info, sta);
-@@ -3584,6 +3585,7 @@ ieee80211_build_data_template(struct iee
+@@ -3731,6 +3732,7 @@ ieee80211_build_data_template(struct iee
  	hdr = (void *)skb->data;
  	tx.sta = sta_info_get(sdata, hdr->addr1);
  	tx.skb = skb;
@@ -126,7 +126,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  	if (!iv)
  		return -1;
  
-@@ -306,13 +306,14 @@ static int wep_encrypt_skb(struct ieee80
+@@ -307,13 +307,14 @@ static int wep_encrypt_skb(struct ieee80
  	struct ieee80211_key_conf *hw_key = info->control.hw_key;
  
  	if (!hw_key) {
@@ -181,7 +181,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  	len = skb->len - hdrlen;
  
  	if (info->control.hw_key)
-@@ -418,7 +417,7 @@ static int ccmp_encrypt_skb(struct ieee8
+@@ -419,7 +418,7 @@ static int ccmp_encrypt_skb(struct ieee8
  		return 0;
  	}
  
@@ -190,7 +190,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  	len = skb->len - hdrlen;
  
  	if (info->control.hw_key)
-@@ -651,7 +650,7 @@ static int gcmp_encrypt_skb(struct ieee8
+@@ -652,7 +651,7 @@ static int gcmp_encrypt_skb(struct ieee8
  		return 0;
  	}
  
@@ -199,7 +199,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  	len = skb->len - hdrlen;
  
  	if (info->control.hw_key)
-@@ -791,7 +790,6 @@ static ieee80211_tx_result
+@@ -792,7 +791,6 @@ static ieee80211_tx_result
  ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx,
  			    struct sk_buff *skb)
  {
@@ -207,7 +207,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  	struct ieee80211_key *key = tx->key;
  	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  	int hdrlen;
-@@ -807,8 +805,7 @@ ieee80211_crypto_cs_encrypt(struct ieee8
+@@ -808,8 +806,7 @@ ieee80211_crypto_cs_encrypt(struct ieee8
  		     pskb_expand_head(skb, iv_len, 0, GFP_ATOMIC)))
  		return TX_DROP;
  

+ 18 - 18
package/kernel/mac80211/patches/305-mac80211-add-NEED_ALIGNED4_SKBS-hw-flag.patch → package/kernel/mac80211/patches/308-mac80211-add-NEED_ALIGNED4_SKBS-hw-flag.patch

@@ -23,9 +23,9 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
 
 --- a/include/net/mac80211.h
 +++ b/include/net/mac80211.h
-@@ -2025,6 +2025,9 @@ struct ieee80211_txq {
-  *	drivers, mac80211 packet loss mechanism will not be triggered and driver
-  *	is completely depending on firmware event for station kickout.
+@@ -2043,6 +2043,9 @@ struct ieee80211_txq {
+  *	The stack will not do fragmentation.
+  *	The callback for @set_frag_threshold should be set as well.
   *
 + * @IEEE80211_HW_NEEDS_ALIGNED4_SKBS: Driver need aligned skbs to four-byte.
 + *	Padding will be added after ieee80211_hdr, before IV/LLC.
@@ -33,28 +33,28 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
   * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
   */
  enum ieee80211_hw_flags {
-@@ -2066,6 +2069,7 @@ enum ieee80211_hw_flags {
- 	IEEE80211_HW_TX_AMSDU,
+@@ -2085,6 +2088,7 @@ enum ieee80211_hw_flags {
  	IEEE80211_HW_TX_FRAG_LIST,
  	IEEE80211_HW_REPORTS_LOW_ACK,
+ 	IEEE80211_HW_SUPPORTS_TX_FRAG,
 +	IEEE80211_HW_NEEDS_ALIGNED4_SKBS,
  
  	/* keep last, obviously */
  	NUM_IEEE80211_HW_FLAGS
 --- a/net/mac80211/debugfs.c
 +++ b/net/mac80211/debugfs.c
-@@ -210,6 +210,7 @@ static const char *hw_flag_names[] = {
- 	FLAG(TX_AMSDU),
+@@ -211,6 +211,7 @@ static const char *hw_flag_names[] = {
  	FLAG(TX_FRAG_LIST),
  	FLAG(REPORTS_LOW_ACK),
+ 	FLAG(SUPPORTS_TX_FRAG),
 +	FLAG(NEEDS_ALIGNED4_SKBS),
  #undef FLAG
  };
  
 --- a/net/mac80211/ieee80211_i.h
 +++ b/net/mac80211/ieee80211_i.h
-@@ -1529,6 +1529,29 @@ ieee80211_have_rx_timestamp(struct ieee8
- 	return false;
+@@ -1553,6 +1553,29 @@ ieee80211_vif_get_num_mcast_if(struct ie
+ 	return -1;
  }
  
 +static inline unsigned int
@@ -96,7 +96,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  	struct rcu_head rcu_head;
 --- a/net/mac80211/status.c
 +++ b/net/mac80211/status.c
-@@ -689,9 +689,22 @@ void ieee80211_tx_monitor(struct ieee802
+@@ -693,9 +693,22 @@ void ieee80211_tx_monitor(struct ieee802
  	struct sk_buff *skb2;
  	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  	struct ieee80211_sub_if_data *sdata;
@@ -137,7 +137,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  
 --- a/net/mac80211/tx.c
 +++ b/net/mac80211/tx.c
-@@ -1206,8 +1206,7 @@ ieee80211_tx_prepare(struct ieee80211_su
+@@ -1176,8 +1176,7 @@ ieee80211_tx_prepare(struct ieee80211_su
  	info->flags &= ~IEEE80211_TX_INTFL_NEED_TXPROCESSING;
  
  	hdr = (struct ieee80211_hdr *) skb->data;
@@ -147,7 +147,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  
  	if (likely(sta)) {
  		if (!IS_ERR(sta))
-@@ -2158,7 +2157,7 @@ netdev_tx_t ieee80211_monitor_start_xmit
+@@ -2152,7 +2151,7 @@ netdev_tx_t ieee80211_monitor_start_xmit
  		goto fail;
  
  	hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr);
@@ -156,7 +156,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  
  	if (skb->len < len_rthdr + hdrlen)
  		goto fail;
-@@ -2376,7 +2375,7 @@ static struct sk_buff *ieee80211_build_h
+@@ -2370,7 +2369,7 @@ static struct sk_buff *ieee80211_build_h
  	struct ieee80211_chanctx_conf *chanctx_conf;
  	struct ieee80211_sub_if_data *ap_sdata;
  	enum nl80211_band band;
@@ -165,7 +165,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  
  	if (IS_ERR(sta))
  		sta = NULL;
-@@ -2596,6 +2595,9 @@ static struct sk_buff *ieee80211_build_h
+@@ -2590,6 +2589,9 @@ static struct sk_buff *ieee80211_build_h
  		hdrlen += 2;
  	}
  
@@ -175,7 +175,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  	/*
  	 * Drop unicast frames to unauthorised stations unless they are
  	 * EAPOL frames from the local station.
-@@ -2676,6 +2678,7 @@ static struct sk_buff *ieee80211_build_h
+@@ -2670,6 +2672,7 @@ static struct sk_buff *ieee80211_build_h
  
  	skb_pull(skb, skip_header_bytes);
  	head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb);
@@ -183,7 +183,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  
  	/*
  	 * So we need to modify the skb header and hence need a copy of
-@@ -2708,6 +2711,9 @@ static struct sk_buff *ieee80211_build_h
+@@ -2702,6 +2705,9 @@ static struct sk_buff *ieee80211_build_h
  		memcpy(skb_push(skb, meshhdrlen), &mesh_hdr, meshhdrlen);
  #endif
  
@@ -193,7 +193,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  	if (ieee80211_is_data_qos(fc)) {
  		__le16 *qos_control;
  
-@@ -2883,6 +2889,9 @@ void ieee80211_check_fast_xmit(struct st
+@@ -2877,6 +2883,9 @@ void ieee80211_check_fast_xmit(struct st
  		fc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA);
  	}
  
@@ -203,7 +203,7 @@ Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
  	/* We store the key here so there's no point in using rcu_dereference()
  	 * but that's fine because the code that changes the pointers will call
  	 * this function after doing so. For a single CPU that would be enough,
-@@ -3436,7 +3445,7 @@ begin:
+@@ -3464,7 +3473,7 @@ begin:
  
  		if (tx.key &&
  		    (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))

Some files were not shown because too many files changed in this diff