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:
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"
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
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
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
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
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
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
$(HOST_CMAKE_SOURCE_DIR) \
)
endef
+
+MAKE_FLAGS += \
+ CMAKE_COMMAND='$$(if $$(CMAKE_DISABLE_$$@),:,$(STAGING_DIR_HOST)/bin/cmake)' \
+ CMAKE_DISABLE_cmake_check_build_system=1
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
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)
--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
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
-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
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
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 \
$$(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 $$^ $$@
PROTO:=git
VERSION:=$(CONFIG_KERNEL_GIT_BRANCH)
FILE:=$(LINUX_SOURCE)
- SUBDIR:=linux-$(KERNEL_PATCHVER)
+ SUBDIR:=linux-$(LINUX_VERSION)
OPTS:=$(KERNEL_GIT_OPTS)
endef
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)))
( \
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; \
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)); \
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
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
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
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
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/
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
/etc/sysctl.d/local.conf
/etc/sysctl.d/
/etc/iproute2/rt_tables
+/etc/iproute2/rt_protos
$(call $(TARGET)/conffiles)
endef
validate_system_section()
{
uci_validate_section system system "${1}" \
- 'hostname:string:libreCMC' \
+ 'hostname:string:lede' \
'conloglevel:uinteger' \
'buffersize:uinteger' \
'timezone:string:UTC' \
--- /dev/null
+#
+# 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
DISTRIB_REVISION='%R'
DISTRIB_CODENAME='%n'
DISTRIB_TARGET='%S'
+DISTRIB_ARCH='%A'
DISTRIB_DESCRIPTION='%D %N %V %C'
DISTRIB_TAINTS='%t'
. /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}"
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
}
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
}
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
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";;
SUPPORT_URL="%s"
BUILD_ID="%R"
LEDE_BOARD="%S"
+LEDE_ARCH="%A"
LEDE_TAINTS="%t"
LEDE_DEVICE_MANUFACTURER="%M"
LEDE_DEVICE_MANUFACTURER_URL="%m"
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
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:
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.
--- /dev/null
+#
+# 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))
--- /dev/null
+--- 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)
--- /dev/null
+--- 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
--- /dev/null
+--- 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
--- /dev/null
+--- 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
--- /dev/null
+--- 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
--- /dev/null
+--- 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
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)
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
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
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 \
--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 \
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;
--- 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,
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;
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,
--- 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",
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;
+++ /dev/null
---- 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)
--- /dev/null
+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:
+++ /dev/null
---- 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,
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"
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
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>
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) \
--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
+++ /dev/null
-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
-
+++ /dev/null
-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
-
+++ /dev/null
-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
-
+++ /dev/null
-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
-
+++ /dev/null
-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
-
--- /dev/null
+--- 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;
+ }
--- /dev/null
+--- 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>
--- /dev/null
+#
+# 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))
--- /dev/null
+--- 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"
--- /dev/null
+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);
--- /dev/null
+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) {
+
--- /dev/null
+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);
+ }
--- /dev/null
+#
+# 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))
--- /dev/null
+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
--- /dev/null
+//==========================================================================
+//
+// 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_
+
+
+
--- /dev/null
+//==========================================================================
+//
+// 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);
+}
+
+
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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 */
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
+++ /dev/null
-#
-# 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))
+++ /dev/null
-obj-m := avila-wdt.o
+++ /dev/null
-/*
- * 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);
-
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
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)
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:= \
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)))
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 \
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 \
$(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)
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
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 ] && {
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
--- 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:
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;
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_
}
+++ /dev/null
---- 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
--- /dev/null
+--- 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
+++ /dev/null
---- 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 */
--- /dev/null
+--- 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 */
--- /dev/null
+--- 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);
+ }
+
--- /dev/null
+--- 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;
+
--- /dev/null
+--- 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 = {
--- /dev/null
+--- 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)
--- /dev/null
+--- 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);
--- /dev/null
+--- 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
--- /dev/null
+--- 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
--- 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=
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
--- /dev/null
+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 */
- 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>
#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];
+
+
+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];
}
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;
+ }
+ 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;
}
{
- 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;
- 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);
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
}
{
__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;
/* 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);
/* 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 */
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 */
--- 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);
--- 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,
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;
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;
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);
--- 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)
*/
+++ /dev/null
-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 = ¶ms->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 */
- }
- }
-
--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Sat, 9 Jul 2016 15:25:24 +0200
+Subject: [PATCH] ath9k_hw: reset AHB-WMAC interface on AR91xx
+
+Should fix a few stability issues
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -1394,8 +1394,12 @@ static bool ath9k_hw_set_reset(struct at
+ if (!AR_SREV_9100(ah))
+ REG_WRITE(ah, AR_RC, 0);
+
+- if (AR_SREV_9100(ah))
++ if (AR_SREV_9100(ah)) {
++ /* Reset the AHB-WMAC interface */
++ if (ah->external_reset)
++ ah->external_reset();
+ udelay(50);
++ }
+
+ return true;
+ }
+++ /dev/null
-From: Felix Fietkau <nbd@openwrt.org>
-Date: Sun, 7 Jun 2015 13:53:35 +0200
-Subject: [PATCH] ath9k: force rx_clear when disabling rx
-
-This makes stopping Rx more reliable and should reduce the frequency of
-Rx related DMA stop warnings. Don't use rx_clear in TX99 mode.
-
-Cc: stable@vger.kernel.org
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
-Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
----
-
---- a/drivers/net/wireless/ath/ath9k/mac.c
-+++ b/drivers/net/wireless/ath/ath9k/mac.c
-@@ -677,13 +677,18 @@ void ath9k_hw_startpcureceive(struct ath
-
- ath9k_ani_reset(ah, is_scanning);
-
-- REG_CLR_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
-+ REG_CLR_BIT(ah, AR_DIAG_SW,
-+ AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT | AR_DIAG_FORCE_RX_CLEAR);
- }
- EXPORT_SYMBOL(ath9k_hw_startpcureceive);
-
- void ath9k_hw_abortpcurecv(struct ath_hw *ah)
- {
-- 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))
-+ reg |= AR_DIAG_FORCE_RX_CLEAR;
-+ REG_SET_BIT(ah, AR_DIAG_SW, reg);
-
- ath9k_hw_disable_mib_counters(ah);
- }
--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Sat, 9 Jul 2016 15:26:44 +0200
+Subject: [PATCH] ath9k_hw: issue external reset for QCA955x
+
+The RTC interface on the SoC needs to be reset along with the rest of
+the WMAC.
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -1271,39 +1271,56 @@ void ath9k_hw_get_delta_slope_vals(struc
+ *coef_exponent = coef_exp - 16;
+ }
+
+-/* AR9330 WAR:
+- * call external reset function to reset WMAC if:
+- * - doing a cold reset
+- * - we have pending frames in the TX queues.
+- */
+-static bool ath9k_hw_ar9330_reset_war(struct ath_hw *ah, int type)
++static bool ath9k_hw_need_external_reset(struct ath_hw *ah, int type)
+ {
+- int i, npend = 0;
++ int i;
+
+- for (i = 0; i < AR_NUM_QCU; i++) {
+- 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;
++
++ if (AR_SREV_9550(ah))
++ return true;
++
++ /* AR9330 WAR:
++ * call external reset function to reset WMAC if:
++ * - doing a cold reset
++ * - we have pending frames in the TX queues.
++ */
++ if (AR_SREV_9330(ah)) {
++ for (i = 0; i < AR_NUM_QCU; i++) {
++ if (ath9k_hw_numtxpending(ah, i))
++ return true;
+ }
++ }
++
++ return false;
++}
++
++static bool ath9k_hw_external_reset(struct ath_hw *ah, int type)
++{
++ int err;
++
++ if (!ah->external_reset || !ath9k_hw_need_external_reset(ah, type))
++ return true;
++
++ 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);
++
+ return true;
+ }
+
+@@ -1356,24 +1373,24 @@ static bool ath9k_hw_set_reset(struct at
+ rst_flags |= AR_RTC_RC_MAC_COLD;
+ }
+
+- if (AR_SREV_9330(ah)) {
+- if (!ath9k_hw_ar9330_reset_war(ah, type))
+- return false;
+- }
+-
+ if (ath9k_hw_mci_is_enabled(ah))
+ ar9003_mci_check_gpm_offset(ah);
+
+ /* DMA HALT added to resolve ar9300 and ar9580 bus error during
+- * RTC_RC reg read
++ * RTC_RC reg read. Also needed for AR9550 external reset
+ */
+- if (AR_SREV_9300(ah) || AR_SREV_9580(ah)) {
++ if (AR_SREV_9300(ah) || AR_SREV_9580(ah) || AR_SREV_9550(ah)) {
+ REG_SET_BIT(ah, AR_CFG, AR_CFG_HALT_REQ);
+ ath9k_hw_wait(ah, AR_CFG, AR_CFG_HALT_ACK, AR_CFG_HALT_ACK,
+ 20 * AH_WAIT_TIMEOUT);
+- REG_CLR_BIT(ah, AR_CFG, AR_CFG_HALT_REQ);
+ }
+
++ if (!AR_SREV_9100(ah))
++ ath9k_hw_external_reset(ah, type);
++
++ if (AR_SREV_9300(ah) || AR_SREV_9580(ah))
++ REG_CLR_BIT(ah, AR_CFG, AR_CFG_HALT_REQ);
++
+ REG_WRITE(ah, AR_RTC_RC, rst_flags);
+
+ REGWRITE_BUFFER_FLUSH(ah);
+++ /dev/null
-From: Felix Fietkau <nbd@openwrt.org>
-Date: Thu, 2 Jul 2015 15:20:56 +0200
-Subject: [PATCH] ath9k: limit retries for powersave response frames
-
-In some cases, the channel might be busy enough that an ath9k AP's
-response to PS-Poll frames might be too slow and the station has already
-gone to sleep. To avoid wasting too much airtime on this, limit the
-number of retries on such frames and ensure that no sample rate gets
-used.
-
-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_
- }
-
- static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
-- struct ath_buf *bf)
-+ struct ath_buf *bf, bool ps)
- {
-+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(bf->bf_mpdu);
-+
-+ if (ps) {
-+ /* Clear the first rate to avoid using a sample rate for PS frames */
-+ info->control.rates[0].idx = -1;
-+ info->control.rates[0].count = 0;
-+ }
-+
- ieee80211_get_tx_rates(vif, sta, bf->bf_mpdu, bf->rates,
- ARRAY_SIZE(bf->rates));
-+ if (!ps)
-+ return;
-+
-+ if (bf->rates[0].count > 2)
-+ bf->rates[0].count = 2;
-+
-+ bf->rates[1].idx = -1;
- }
-
- 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,
- break;
- }
-
-- ath_set_rates(tid->an->vif, tid->an->sta, bf);
-+ ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
- } while (1);
- }
-
-@@ -1493,7 +1508,7 @@ static bool ath_tx_sched_aggr(struct ath
- return false;
- }
-
-- ath_set_rates(tid->an->vif, tid->an->sta, bf);
-+ ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
- 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
- break;
-
- list_add_tail(&bf->list, &bf_q);
-- ath_set_rates(tid->an->vif, tid->an->sta, bf);
-+ ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
- 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
- if (txctl->paprd)
- bf->bf_state.bfs_paprd_timestamp = jiffies;
-
-- ath_set_rates(vif, sta, bf);
-+ ath_set_rates(vif, sta, bf, ps_resp);
- ath_tx_send_normal(sc, txq, tid, skb);
-
- out:
-@@ -2382,7 +2397,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw
- break;
-
- bf->bf_lastbf = bf;
-- ath_set_rates(vif, NULL, bf);
-+ ath_set_rates(vif, NULL, bf, false);
- 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
- return -EINVAL;
- }
-
-- ath_set_rates(sc->tx99_vif, NULL, bf);
-+ ath_set_rates(sc->tx99_vif, NULL, bf, false);
-
- ath9k_hw_set_desc_link(sc->sc_ah, bf->bf_desc, bf->bf_daddr);
- ath9k_hw_tx99_start(sc->sc_ah, txctl->txq->axq_qnum);
--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Mon, 11 Jul 2016 12:07:40 +0200
+Subject: [PATCH] ath9k_hw: set spectral scan enable bit on trigger for
+ AR9003+
+
+AR9002 code and QCA AR9003+ code do the same.
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+@@ -1800,6 +1800,8 @@ static void ar9003_hw_spectral_scan_conf
+
+ static void ar9003_hw_spectral_scan_trigger(struct ath_hw *ah)
+ {
++ REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN,
++ AR_PHY_SPECTRAL_SCAN_ENABLE);
+ /* Activate spectral scan */
+ REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN,
+ AR_PHY_SPECTRAL_SCAN_ACTIVE);
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Sat, 14 May 2016 14:51:02 +0200
-Subject: [PATCH] Revert "ath9k: interpret requested txpower in EIRP
- domain"
-
-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
- {
- struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
- struct ieee80211_channel *channel;
-- int chan_pwr, new_pwr;
-+ int chan_pwr, new_pwr, max_gain;
-+ int ant_gain, ant_reduction = 0;
-
- if (!chan)
- return;
-@@ -2918,10 +2919,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);
-+ max_gain = chan_pwr - new_pwr + channel->max_antenna_gain * 2;
-+
-+ ant_gain = get_antenna_gain(ah, chan);
-+ if (ant_gain > max_gain)
-+ ant_reduction = ant_gain - max_gain;
-
- ah->eep_ops->set_txpower(ah, chan,
- ath9k_regd_get_ctl(reg, chan),
-- get_antenna_gain(ah, chan), new_pwr, test);
-+ ant_reduction, new_pwr, test);
- }
-
- void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
--- /dev/null
+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
+
+The checks already prevents periodic cal from being started while noise
+floor calibration runs. It is missing checks for the other way around.
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
++++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
+@@ -676,10 +676,10 @@ static int ar9002_hw_calibrate(struct at
+ return 0;
+
+ ah->cal_list_curr = currCal = currCal->calNext;
+- if (currCal->calState == CAL_WAITING) {
++ if (currCal->calState == CAL_WAITING)
+ ath9k_hw_reset_calibration(ah, currCal);
+- return 0;
+- }
++
++ return 0;
+ }
+
+ /* Do NF cal only at longer intervals */
--- /dev/null
+From: Felix Fietkau <nbd@openwrt.org>
+Date: Sun, 7 Jun 2015 13:53:35 +0200
+Subject: [PATCH] ath9k: force rx_clear when disabling rx
+
+This makes stopping Rx more reliable and should reduce the frequency of
+Rx related DMA stop warnings. Don't use rx_clear in TX99 mode.
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/mac.c
++++ b/drivers/net/wireless/ath/ath9k/mac.c
+@@ -677,13 +677,18 @@ void ath9k_hw_startpcureceive(struct ath
+
+ ath9k_ani_reset(ah, is_scanning);
+
+- REG_CLR_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
++ REG_CLR_BIT(ah, AR_DIAG_SW,
++ AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT | AR_DIAG_FORCE_RX_CLEAR);
+ }
+ EXPORT_SYMBOL(ath9k_hw_startpcureceive);
+
+ void ath9k_hw_abortpcurecv(struct ath_hw *ah)
+ {
+- 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 (!IS_ENABLED(CPTCFG_ATH9K_TX99))
++ reg |= AR_DIAG_FORCE_RX_CLEAR;
++ REG_SET_BIT(ah, AR_DIAG_SW, reg);
+
+ ath9k_hw_disable_mib_counters(ah);
+ }
+++ /dev/null
-From: Janusz Dziedzic <janusz.dziedzic@tieto.com>
-Date: Fri, 19 Feb 2016 11:01:49 +0100
-Subject: [PATCH] mac80211: add hdrlen to ieee80211_tx_data
-
-Add hdrlen to ieee80211_tx_data and use this
-when wep/ccmd/tkip. This is preparation for
-aligned4 code.
-
-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 {
- struct ieee80211_tx_rate rate;
-
- unsigned int flags;
-+ unsigned int hdrlen;
- };
-
-
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -955,7 +955,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;
-- int hdrlen;
-+ int hdrlen = tx->hdrlen;
- int fragnum;
-
- /* no matter what happens, tx->skb moves to tx->skbs */
-@@ -976,8 +976,6 @@ ieee80211_tx_h_fragment(struct ieee80211
- if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU))
- return TX_DROP;
-
-- hdrlen = ieee80211_hdrlen(hdr->frame_control);
--
- /* 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
-
- hdr = (struct ieee80211_hdr *) skb->data;
-
-+ tx->hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+
- if (likely(sta)) {
- if (!IS_ERR(sta))
- tx->sta = sta;
-@@ -3414,6 +3414,7 @@ begin:
- tx.local = local;
- tx.skb = skb;
- tx.sdata = vif_to_sdata(info->control.vif);
-+ tx.hdrlen = ieee80211_padded_hdrlen(hw, hdr->frame_control);
-
- if (txq->sta)
- tx.sta = container_of(txq->sta, struct sta_info, sta);
-@@ -3584,6 +3585,7 @@ ieee80211_build_data_template(struct iee
- hdr = (void *)skb->data;
- tx.sta = sta_info_get(sdata, hdr->addr1);
- tx.skb = skb;
-+ tx.hdrlen = ieee80211_padded_hdrlen(&tx.local->hw, hdr->frame_control);
-
- if (ieee80211_tx_h_select_key(&tx) != TX_CONTINUE) {
- rcu_read_unlock();
---- a/net/mac80211/util.c
-+++ b/net/mac80211/util.c
-@@ -1227,6 +1227,7 @@ void ieee80211_send_auth(struct ieee8021
- struct ieee80211_local *local = sdata->local;
- struct sk_buff *skb;
- struct ieee80211_mgmt *mgmt;
-+ unsigned int hdrlen;
- int err;
-
- /* 24 + 6 = header + auth_algo + auth_transaction + status_code */
-@@ -1251,8 +1252,10 @@ void ieee80211_send_auth(struct ieee8021
- memcpy(skb_put(skb, extra_len), extra, extra_len);
-
- if (auth_alg == WLAN_AUTH_SHARED_KEY && transaction == 3) {
-+ hdrlen = ieee80211_hdrlen(mgmt->frame_control);
- mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
-- err = ieee80211_wep_encrypt(local, skb, key, key_len, key_idx);
-+ err = ieee80211_wep_encrypt(local, skb, hdrlen, key,
-+ key_len, key_idx);
- WARN_ON(err);
- }
-
---- a/net/mac80211/wep.c
-+++ b/net/mac80211/wep.c
-@@ -89,11 +89,11 @@ static void ieee80211_wep_get_iv(struct
-
- static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local,
- struct sk_buff *skb,
-+ unsigned int hdrlen,
- int keylen, int keyidx)
- {
- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-- unsigned int hdrlen;
- u8 *newhdr;
-
- hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
-@@ -101,7 +101,6 @@ static u8 *ieee80211_wep_add_iv(struct i
- if (WARN_ON(skb_headroom(skb) < IEEE80211_WEP_IV_LEN))
- return NULL;
-
-- hdrlen = ieee80211_hdrlen(hdr->frame_control);
- newhdr = skb_push(skb, IEEE80211_WEP_IV_LEN);
- memmove(newhdr, newhdr + IEEE80211_WEP_IV_LEN, hdrlen);
-
-@@ -160,6 +159,7 @@ int ieee80211_wep_encrypt_data(struct cr
- */
- int ieee80211_wep_encrypt(struct ieee80211_local *local,
- struct sk_buff *skb,
-+ unsigned int hdrlen,
- const u8 *key, int keylen, int keyidx)
- {
- u8 *iv;
-@@ -169,7 +169,7 @@ int ieee80211_wep_encrypt(struct ieee802
- if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN))
- return -1;
-
-- iv = ieee80211_wep_add_iv(local, skb, keylen, keyidx);
-+ iv = ieee80211_wep_add_iv(local, skb, hdrlen, keylen, keyidx);
- if (!iv)
- return -1;
-
-@@ -306,13 +306,14 @@ static int wep_encrypt_skb(struct ieee80
- struct ieee80211_key_conf *hw_key = info->control.hw_key;
-
- if (!hw_key) {
-- if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key,
-+ if (ieee80211_wep_encrypt(tx->local, skb, tx->hdrlen,
-+ tx->key->conf.key,
- tx->key->conf.keylen,
- tx->key->conf.keyidx))
- return -1;
- } else if ((hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||
- (hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) {
-- if (!ieee80211_wep_add_iv(tx->local, skb,
-+ if (!ieee80211_wep_add_iv(tx->local, skb, tx->hdrlen,
- tx->key->conf.keylen,
- tx->key->conf.keyidx))
- return -1;
---- a/net/mac80211/wep.h
-+++ b/net/mac80211/wep.h
-@@ -22,6 +22,7 @@ int ieee80211_wep_encrypt_data(struct cr
- size_t klen, u8 *data, size_t data_len);
- int ieee80211_wep_encrypt(struct ieee80211_local *local,
- struct sk_buff *skb,
-+ unsigned int hdrlen,
- const u8 *key, int keylen, int keyidx);
- int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key,
- size_t klen, u8 *data, size_t data_len);
---- a/net/mac80211/wpa.c
-+++ b/net/mac80211/wpa.c
-@@ -43,7 +43,7 @@ ieee80211_tx_h_michael_mic_add(struct ie
- skb->len < 24 || !ieee80211_is_data_present(hdr->frame_control))
- return TX_CONTINUE;
-
-- hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+ hdrlen = tx->hdrlen;
- if (skb->len < hdrlen)
- return TX_DROP;
-
-@@ -186,7 +186,6 @@ mic_fail_no_key:
-
- static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
- {
-- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
- struct ieee80211_key *key = tx->key;
- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
- unsigned int hdrlen;
-@@ -201,7 +200,7 @@ static int tkip_encrypt_skb(struct ieee8
- return 0;
- }
-
-- hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+ hdrlen = tx->hdrlen;
- len = skb->len - hdrlen;
-
- if (info->control.hw_key)
-@@ -418,7 +417,7 @@ static int ccmp_encrypt_skb(struct ieee8
- return 0;
- }
-
-- hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+ hdrlen = tx->hdrlen;
- len = skb->len - hdrlen;
-
- if (info->control.hw_key)
-@@ -651,7 +650,7 @@ static int gcmp_encrypt_skb(struct ieee8
- return 0;
- }
-
-- hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+ hdrlen = tx->hdrlen;
- len = skb->len - hdrlen;
-
- if (info->control.hw_key)
-@@ -791,7 +790,6 @@ static ieee80211_tx_result
- ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx,
- struct sk_buff *skb)
- {
-- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
- 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
- pskb_expand_head(skb, iv_len, 0, GFP_ATOMIC)))
- return TX_DROP;
-
-- hdrlen = ieee80211_hdrlen(hdr->frame_control);
--
-+ hdrlen = tx->hdrlen;
- pos = skb_push(skb, iv_len);
- memmove(pos, pos + iv_len, hdrlen);
-
--- /dev/null
+From: Felix Fietkau <nbd@openwrt.org>
+Date: Thu, 2 Jul 2015 15:20:56 +0200
+Subject: [PATCH] ath9k: limit retries for powersave response frames
+
+In some cases, the channel might be busy enough that an ath9k AP's
+response to PS-Poll frames might be too slow and the station has already
+gone to sleep. To avoid wasting too much airtime on this, limit the
+number of retries on such frames and ensure that no sample rate gets
+used.
+
+Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/xmit.c
++++ b/drivers/net/wireless/ath/ath9k/xmit.c
+@@ -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,
+- struct ath_buf *bf)
++ struct ath_buf *bf, bool ps)
+ {
++ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(bf->bf_mpdu);
++
++ if (ps) {
++ /* Clear the first rate to avoid using a sample rate for PS frames */
++ info->control.rates[0].idx = -1;
++ info->control.rates[0].count = 0;
++ }
++
+ ieee80211_get_tx_rates(vif, sta, bf->bf_mpdu, bf->rates,
+ ARRAY_SIZE(bf->rates));
++ if (!ps)
++ return;
++
++ if (bf->rates[0].count > 2)
++ bf->rates[0].count = 2;
++
++ bf->rates[1].idx = -1;
+ }
+
+ static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
+@@ -1522,7 +1537,7 @@ ath_tx_form_burst(struct ath_softc *sc,
+ break;
+ }
+
+- ath_set_rates(tid->an->vif, tid->an->sta, bf);
++ ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
+ } while (1);
+ }
+
+@@ -1552,7 +1567,7 @@ static bool ath_tx_sched_aggr(struct ath
+ return false;
+ }
+
+- ath_set_rates(tid->an->vif, tid->an->sta, bf);
++ ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
+ if (aggr)
+ aggr_len = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf);
+ else
+@@ -1710,7 +1725,7 @@ void ath9k_release_buffered_frames(struc
+ break;
+
+ list_add_tail(&bf->list, &bf_q);
+- ath_set_rates(tid->an->vif, tid->an->sta, bf);
++ ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
+ if (bf_isampdu(bf)) {
+ ath_tx_addto_baw(sc, tid, bf);
+ bf->bf_state.bf_type &= ~BUF_AGGR;
+@@ -2410,7 +2425,7 @@ int ath_tx_start(struct ieee80211_hw *hw
+ if (txctl->paprd)
+ bf->bf_state.bfs_paprd_timestamp = jiffies;
+
+- ath_set_rates(vif, sta, bf);
++ ath_set_rates(vif, sta, bf, ps_resp);
+ ath_tx_send_normal(sc, txq, tid, skb);
+
+ out:
+@@ -2449,7 +2464,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw
+ break;
+
+ bf->bf_lastbf = bf;
+- ath_set_rates(vif, NULL, bf);
++ ath_set_rates(vif, NULL, bf, false);
+ ath_buf_set_rate(sc, bf, &info, fi->framelen, false);
+ duration += info.rates[0].PktDuration;
+ if (bf_tail)
+@@ -2968,7 +2983,7 @@ int ath9k_tx99_send(struct ath_softc *sc
+ return -EINVAL;
+ }
+
+- ath_set_rates(sc->tx99_vif, NULL, bf);
++ ath_set_rates(sc->tx99_vif, NULL, bf, false);
+
+ ath9k_hw_set_desc_link(sc->sc_ah, bf->bf_desc, bf->bf_daddr);
+ ath9k_hw_tx99_start(sc->sc_ah, txctl->txq->axq_qnum);
+++ /dev/null
-From: Janusz Dziedzic <janusz.dziedzic@tieto.com>
-Date: Fri, 19 Feb 2016 11:01:50 +0100
-Subject: [PATCH] mac80211: add NEED_ALIGNED4_SKBS hw flag
-
-HW/driver should set NEED_ALIGNED4_SKBS flag in case
-require aligned skbs to four-byte boundaries.
-This affect only TX direction.
-
-Padding is added after ieee80211_hdr, before IV/LLC.
-
-Before we have to do memmove(hdrlen) twice in the
-dirver. Once before we pass this to HW and next
-in tx completion (to be sure monitor will report
-this tx frame correctly).
-
-With this patch we can skip this memmove() and save CPU.
-
-Currently this was tested with ath9k, both hw/sw crypt for
-wep/tkip/ccmp.
-
-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.
- *
-+ * @IEEE80211_HW_NEEDS_ALIGNED4_SKBS: Driver need aligned skbs to four-byte.
-+ * Padding will be added after ieee80211_hdr, before IV/LLC.
-+ *
- * @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,
- IEEE80211_HW_TX_FRAG_LIST,
- IEEE80211_HW_REPORTS_LOW_ACK,
-+ 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),
- FLAG(TX_FRAG_LIST),
- FLAG(REPORTS_LOW_ACK),
-+ 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;
- }
-
-+static inline unsigned int
-+ieee80211_hdr_padsize(struct ieee80211_hw *hw, unsigned int hdrlen)
-+{
-+ /*
-+ * While hdrlen is already aligned to two-byte boundaries,
-+ * simple check with & 2 will return correct padsize.
-+ */
-+ if (ieee80211_hw_check(hw, NEEDS_ALIGNED4_SKBS))
-+ return hdrlen & 2;
-+ return 0;
-+}
-+
-+static inline unsigned int
-+ieee80211_padded_hdrlen(struct ieee80211_hw *hw, __le16 fc)
-+{
-+ unsigned int hdrlen;
-+
-+ hdrlen = ieee80211_hdrlen(fc);
-+ hdrlen += ieee80211_hdr_padsize(hw, hdrlen);
-+
-+ return hdrlen;
-+}
-+
- u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
- struct ieee80211_rx_status *status,
- unsigned int mpdu_len,
---- a/net/mac80211/sta_info.h
-+++ b/net/mac80211/sta_info.h
-@@ -282,7 +282,7 @@ struct ieee80211_fast_tx {
- u8 hdr_len;
- u8 sa_offs, da_offs, pn_offs;
- u8 band;
-- u8 hdr[30 + 2 + IEEE80211_FAST_XMIT_MAX_IV +
-+ u8 hdr[30 + 2 + 2 + IEEE80211_FAST_XMIT_MAX_IV +
- sizeof(rfc1042_header)] __aligned(2);
-
- 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
- struct sk_buff *skb2;
- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
- struct ieee80211_sub_if_data *sdata;
-+ struct ieee80211_hdr *hdr = (void *)skb->data;
- struct net_device *prev_dev = NULL;
-+ unsigned int hdrlen, padsize;
- int rtap_len;
-
-+ /* Remove padding if was added */
-+ if (ieee80211_hw_check(&local->hw, NEEDS_ALIGNED4_SKBS)) {
-+ hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+ padsize = ieee80211_hdr_padsize(&local->hw, hdrlen);
-+
-+ if (padsize && skb->len > hdrlen + padsize) {
-+ memmove(skb->data + padsize, skb->data, hdrlen);
-+ skb_pull(skb, padsize);
-+ }
-+ }
-+
- /* send frame to monitor interfaces now */
- rtap_len = ieee80211_tx_radiotap_len(info);
- if (WARN_ON_ONCE(skb_headroom(skb) < rtap_len)) {
---- a/net/mac80211/tkip.c
-+++ b/net/mac80211/tkip.c
-@@ -201,10 +201,12 @@ void ieee80211_get_tkip_p2k(struct ieee8
- {
- struct ieee80211_key *key = (struct ieee80211_key *)
- container_of(keyconf, struct ieee80211_key, conf);
-+ struct ieee80211_hw *hw = &key->local->hw;
- const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY];
- struct tkip_ctx *ctx = &key->u.tkip.tx;
- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
-- const u8 *data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
-+ const u8 *data = (u8 *)hdr + ieee80211_padded_hdrlen(hw,
-+ hdr->frame_control);
- u32 iv32 = get_unaligned_le32(&data[4]);
- u16 iv16 = data[2] | (data[0] << 8);
-
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -1206,8 +1206,7 @@ ieee80211_tx_prepare(struct ieee80211_su
- info->flags &= ~IEEE80211_TX_INTFL_NEED_TXPROCESSING;
-
- hdr = (struct ieee80211_hdr *) skb->data;
--
-- tx->hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+ tx->hdrlen = ieee80211_padded_hdrlen(&local->hw, hdr->frame_control);
-
- if (likely(sta)) {
- if (!IS_ERR(sta))
-@@ -2158,7 +2157,7 @@ netdev_tx_t ieee80211_monitor_start_xmit
- goto fail;
-
- hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr);
-- hdrlen = ieee80211_hdrlen(hdr->frame_control);
-+ hdrlen = ieee80211_padded_hdrlen(&local->hw, hdr->frame_control);
-
- if (skb->len < len_rthdr + hdrlen)
- goto fail;
-@@ -2376,7 +2375,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;
-- int ret;
-+ int padsize, ret;
-
- if (IS_ERR(sta))
- sta = NULL;
-@@ -2596,6 +2595,9 @@ static struct sk_buff *ieee80211_build_h
- hdrlen += 2;
- }
-
-+ /* Check aligned4 skb required */
-+ padsize = ieee80211_hdr_padsize(&sdata->local->hw, hdrlen);
-+
- /*
- * 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
-
- skb_pull(skb, skip_header_bytes);
- head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb);
-+ head_need += padsize;
-
- /*
- * 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
- memcpy(skb_push(skb, meshhdrlen), &mesh_hdr, meshhdrlen);
- #endif
-
-+ if (padsize)
-+ memset(skb_push(skb, padsize), 0, padsize);
-+
- if (ieee80211_is_data_qos(fc)) {
- __le16 *qos_control;
-
-@@ -2883,6 +2889,9 @@ void ieee80211_check_fast_xmit(struct st
- fc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA);
- }
-
-+ /* Check aligned4 skb required */
-+ build.hdr_len += ieee80211_hdr_padsize(&local->hw, build.hdr_len);
-+
- /* 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:
-
- if (tx.key &&
- (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
-- pn_offs = ieee80211_hdrlen(hdr->frame_control);
-+ pn_offs = tx.hdrlen;
-
- ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs,
- tx.key, skb);
---- a/net/mac80211/util.c
-+++ b/net/mac80211/util.c
-@@ -1225,6 +1225,7 @@ void ieee80211_send_auth(struct ieee8021
- u32 tx_flags)
- {
- struct ieee80211_local *local = sdata->local;
-+ struct ieee80211_hw *hw = &local->hw;
- struct sk_buff *skb;
- struct ieee80211_mgmt *mgmt;
- unsigned int hdrlen;
-@@ -1252,7 +1253,7 @@ void ieee80211_send_auth(struct ieee8021
- memcpy(skb_put(skb, extra_len), extra, extra_len);
-
- if (auth_alg == WLAN_AUTH_SHARED_KEY && transaction == 3) {
-- hdrlen = ieee80211_hdrlen(mgmt->frame_control);
-+ hdrlen = ieee80211_padded_hdrlen(hw, mgmt->frame_control);
- mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
- err = ieee80211_wep_encrypt(local, skb, hdrlen, key,
- key_len, key_idx);
--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Sat, 14 May 2016 14:51:02 +0200
+Subject: [PATCH] Revert "ath9k: interpret requested txpower in EIRP
+ domain"
+
+This reverts commit 71f5137bf010c6faffab50c0ec15374c59c4a411.
+---
+
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -2931,7 +2931,8 @@ void ath9k_hw_apply_txpower(struct ath_h
+ {
+ struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
+ struct ieee80211_channel *channel;
+- int chan_pwr, new_pwr;
++ int chan_pwr, new_pwr, max_gain;
++ int ant_gain, ant_reduction = 0;
+
+ if (!chan)
+ return;
+@@ -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);
++ max_gain = chan_pwr - new_pwr + channel->max_antenna_gain * 2;
++
++ ant_gain = get_antenna_gain(ah, chan);
++ if (ant_gain > max_gain)
++ ant_reduction = ant_gain - max_gain;
+
+ ah->eep_ops->set_txpower(ah, chan,
+ ath9k_regd_get_ctl(reg, chan),
+- get_antenna_gain(ah, chan), new_pwr, test);
++ ant_reduction, new_pwr, test);
+ }
+
+ void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
+++ /dev/null
-From: Chaitanya T K <chaitanya.mgit@gmail.com>
-Date: Mon, 27 Jun 2016 15:23:26 +0530
-Subject: [PATCH] mac80211: minstrel: Enable STBC and LDPC for VHT Rates
-
-If peer support reception of STBC and LDPC, enable them for better
-performance.
-
-Signed-off-by: Chaitanya TK <chaitanya.mgit@gmail.com>
----
-
---- a/include/linux/ieee80211.h
-+++ b/include/linux/ieee80211.h
-@@ -1551,6 +1551,7 @@ struct ieee80211_vht_operation {
- #define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300
- #define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400
- #define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700
-+#define IEEE80211_VHT_CAP_RXSTBC_SHIFT 8
- #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800
- #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000
- #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT 13
---- a/net/mac80211/rc80211_minstrel_ht.c
-+++ b/net/mac80211/rc80211_minstrel_ht.c
-@@ -1166,13 +1166,14 @@ minstrel_ht_update_caps(void *priv, stru
- struct minstrel_ht_sta_priv *msp = priv_sta;
- struct minstrel_ht_sta *mi = &msp->ht;
- struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs;
-- u16 sta_cap = sta->ht_cap.cap;
-+ u16 ht_cap = sta->ht_cap.cap;
- struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
- int use_vht;
- int n_supported = 0;
- int ack_dur;
- int stbc;
- int i;
-+ bool ldpc = false;
-
- /* fall back to the old minstrel for legacy stations */
- if (!sta->ht_cap.ht_supported)
-@@ -1210,16 +1211,24 @@ minstrel_ht_update_caps(void *priv, stru
- }
- mi->sample_tries = 4;
-
-- /* TODO tx_flags for vht - ATM the RC API is not fine-grained enough */
- if (!use_vht) {
-- stbc = (sta_cap & IEEE80211_HT_CAP_RX_STBC) >>
-+ stbc = (ht_cap & IEEE80211_HT_CAP_RX_STBC) >>
- IEEE80211_HT_CAP_RX_STBC_SHIFT;
-- mi->tx_flags |= stbc << IEEE80211_TX_CTL_STBC_SHIFT;
-
-- if (sta_cap & IEEE80211_HT_CAP_LDPC_CODING)
-- mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
-+ if (ht_cap & IEEE80211_HT_CAP_LDPC_CODING)
-+ ldpc = true;
-+ } else {
-+ stbc = (vht_cap->cap & IEEE80211_VHT_CAP_RXSTBC_MASK) >>
-+ IEEE80211_VHT_CAP_RXSTBC_SHIFT;
-+
-+ if (vht_cap->cap & IEEE80211_VHT_CAP_RXLDPC)
-+ ldpc = true;
- }
-
-+ mi->tx_flags |= stbc << IEEE80211_TX_CTL_STBC_SHIFT;
-+ if (ldpc)
-+ mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
-+
- for (i = 0; i < ARRAY_SIZE(mi->groups); i++) {
- u32 gflags = minstrel_mcs_groups[i].flags;
- int bw, nss;
-@@ -1232,10 +1241,10 @@ minstrel_ht_update_caps(void *priv, stru
-
- if (gflags & IEEE80211_TX_RC_SHORT_GI) {
- if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH) {
-- if (!(sta_cap & IEEE80211_HT_CAP_SGI_40))
-+ if (!(ht_cap & IEEE80211_HT_CAP_SGI_40))
- continue;
- } else {
-- if (!(sta_cap & IEEE80211_HT_CAP_SGI_20))
-+ if (!(ht_cap & IEEE80211_HT_CAP_SGI_20))
- continue;
- }
- }
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Sun, 28 Aug 2016 13:13:01 +0200
-Subject: [PATCH] ath9k: fix moredata bit in PS buffered frame release
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -1635,6 +1635,22 @@ void ath_tx_aggr_wakeup(struct ath_softc
- }
- }
-
-+
-+static void
-+ath9k_set_moredata(struct ath_softc *sc, struct ath_buf *bf, bool val)
-+{
-+ struct ieee80211_hdr *hdr;
-+ u16 mask = cpu_to_le16(IEEE80211_FCTL_MOREDATA);
-+ u16 mask_val = mask * val;
-+
-+ hdr = (struct ieee80211_hdr *) bf->bf_mpdu->data;
-+ if ((hdr->frame_control & mask) != mask_val) {
-+ hdr->frame_control = (hdr->frame_control & ~mask) | mask_val;
-+ dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
-+ sizeof(*hdr), DMA_TO_DEVICE);
-+ }
-+}
-+
- void ath9k_release_buffered_frames(struct ieee80211_hw *hw,
- struct ieee80211_sta *sta,
- u16 tids, int nframes,
-@@ -1665,6 +1681,7 @@ void ath9k_release_buffered_frames(struc
- if (!bf)
- break;
-
-+ ath9k_set_moredata(sc, bf, true);
- list_add_tail(&bf->list, &bf_q);
- ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
- if (bf_isampdu(bf)) {
-@@ -1688,6 +1705,9 @@ void ath9k_release_buffered_frames(struc
- if (list_empty(&bf_q))
- return;
-
-+ if (!more_data)
-+ ath9k_set_moredata(sc, bf_tail, false);
-+
- info = IEEE80211_SKB_CB(bf_tail->bf_mpdu);
- info->flags |= IEEE80211_TX_STATUS_EOSP;
-
--- /dev/null
+From: Janusz Dziedzic <janusz.dziedzic@tieto.com>
+Date: Fri, 19 Feb 2016 11:01:49 +0100
+Subject: [PATCH] mac80211: add hdrlen to ieee80211_tx_data
+
+Add hdrlen to ieee80211_tx_data and use this
+when wep/ccmd/tkip. This is preparation for
+aligned4 code.
+
+Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
+---
+
+--- a/net/mac80211/ieee80211_i.h
++++ b/net/mac80211/ieee80211_i.h
+@@ -177,6 +177,7 @@ struct ieee80211_tx_data {
+ struct ieee80211_tx_rate rate;
+
+ unsigned int flags;
++ unsigned int hdrlen;
+ };
+
+
+--- a/net/mac80211/tx.c
++++ b/net/mac80211/tx.c
+@@ -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;
+- int hdrlen;
++ int hdrlen = tx->hdrlen;
+ int fragnum;
+
+ /* no matter what happens, tx->skb moves to tx->skbs */
+@@ -946,8 +946,6 @@ ieee80211_tx_h_fragment(struct ieee80211
+ if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU))
+ return TX_DROP;
+
+- hdrlen = ieee80211_hdrlen(hdr->frame_control);
+-
+ /* internal error, why isn't DONTFRAG set? */
+ if (WARN_ON(skb->len + FCS_LEN <= frag_threshold))
+ return TX_DROP;
+@@ -1179,6 +1177,8 @@ ieee80211_tx_prepare(struct ieee80211_su
+
+ hdr = (struct ieee80211_hdr *) skb->data;
+
++ tx->hdrlen = ieee80211_hdrlen(hdr->frame_control);
++
+ if (likely(sta)) {
+ if (!IS_ERR(sta))
+ tx->sta = sta;
+@@ -3437,6 +3437,7 @@ begin:
+ tx.local = local;
+ tx.skb = skb;
+ tx.sdata = vif_to_sdata(info->control.vif);
++ tx.hdrlen = ieee80211_padded_hdrlen(hw, hdr->frame_control);
+
+ if (txq->sta)
+ tx.sta = container_of(txq->sta, struct sta_info, sta);
+@@ -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;
++ tx.hdrlen = ieee80211_padded_hdrlen(&tx.local->hw, hdr->frame_control);
+
+ if (ieee80211_tx_h_select_key(&tx) != TX_CONTINUE) {
+ rcu_read_unlock();
+--- a/net/mac80211/util.c
++++ b/net/mac80211/util.c
+@@ -1227,6 +1227,7 @@ void ieee80211_send_auth(struct ieee8021
+ struct ieee80211_local *local = sdata->local;
+ struct sk_buff *skb;
+ struct ieee80211_mgmt *mgmt;
++ unsigned int hdrlen;
+ int err;
+
+ /* 24 + 6 = header + auth_algo + auth_transaction + status_code */
+@@ -1251,8 +1252,10 @@ void ieee80211_send_auth(struct ieee8021
+ memcpy(skb_put(skb, extra_len), extra, extra_len);
+
+ if (auth_alg == WLAN_AUTH_SHARED_KEY && transaction == 3) {
++ hdrlen = ieee80211_hdrlen(mgmt->frame_control);
+ mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
+- err = ieee80211_wep_encrypt(local, skb, key, key_len, key_idx);
++ err = ieee80211_wep_encrypt(local, skb, hdrlen, key,
++ key_len, key_idx);
+ WARN_ON(err);
+ }
+
+--- a/net/mac80211/wep.c
++++ b/net/mac80211/wep.c
+@@ -89,11 +89,11 @@ static void ieee80211_wep_get_iv(struct
+
+ static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local,
+ struct sk_buff *skb,
++ unsigned int hdrlen,
+ int keylen, int keyidx)
+ {
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+- unsigned int hdrlen;
+ u8 *newhdr;
+
+ hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
+@@ -101,7 +101,6 @@ static u8 *ieee80211_wep_add_iv(struct i
+ if (WARN_ON(skb_headroom(skb) < IEEE80211_WEP_IV_LEN))
+ return NULL;
+
+- hdrlen = ieee80211_hdrlen(hdr->frame_control);
+ newhdr = skb_push(skb, IEEE80211_WEP_IV_LEN);
+ memmove(newhdr, newhdr + IEEE80211_WEP_IV_LEN, hdrlen);
+
+@@ -160,6 +159,7 @@ int ieee80211_wep_encrypt_data(struct cr
+ */
+ int ieee80211_wep_encrypt(struct ieee80211_local *local,
+ struct sk_buff *skb,
++ unsigned int hdrlen,
+ const u8 *key, int keylen, int keyidx)
+ {
+ u8 *iv;
+@@ -169,7 +169,7 @@ int ieee80211_wep_encrypt(struct ieee802
+ if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN))
+ return -1;
+
+- iv = ieee80211_wep_add_iv(local, skb, keylen, keyidx);
++ iv = ieee80211_wep_add_iv(local, skb, hdrlen, keylen, keyidx);
+ if (!iv)
+ return -1;
+
+@@ -307,13 +307,14 @@ static int wep_encrypt_skb(struct ieee80
+ struct ieee80211_key_conf *hw_key = info->control.hw_key;
+
+ if (!hw_key) {
+- if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key,
++ if (ieee80211_wep_encrypt(tx->local, skb, tx->hdrlen,
++ tx->key->conf.key,
+ tx->key->conf.keylen,
+ tx->key->conf.keyidx))
+ return -1;
+ } else if ((hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||
+ (hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) {
+- if (!ieee80211_wep_add_iv(tx->local, skb,
++ if (!ieee80211_wep_add_iv(tx->local, skb, tx->hdrlen,
+ tx->key->conf.keylen,
+ tx->key->conf.keyidx))
+ return -1;
+--- a/net/mac80211/wep.h
++++ b/net/mac80211/wep.h
+@@ -22,6 +22,7 @@ int ieee80211_wep_encrypt_data(struct cr
+ size_t klen, u8 *data, size_t data_len);
+ int ieee80211_wep_encrypt(struct ieee80211_local *local,
+ struct sk_buff *skb,
++ unsigned int hdrlen,
+ const u8 *key, int keylen, int keyidx);
+ int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key,
+ size_t klen, u8 *data, size_t data_len);
+--- a/net/mac80211/wpa.c
++++ b/net/mac80211/wpa.c
+@@ -43,7 +43,7 @@ ieee80211_tx_h_michael_mic_add(struct ie
+ skb->len < 24 || !ieee80211_is_data_present(hdr->frame_control))
+ return TX_CONTINUE;
+
+- hdrlen = ieee80211_hdrlen(hdr->frame_control);
++ hdrlen = tx->hdrlen;
+ if (skb->len < hdrlen)
+ return TX_DROP;
+
+@@ -186,7 +186,6 @@ mic_fail_no_key:
+
+ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
+ {
+- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+ struct ieee80211_key *key = tx->key;
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+ unsigned int hdrlen;
+@@ -201,7 +200,7 @@ static int tkip_encrypt_skb(struct ieee8
+ return 0;
+ }
+
+- hdrlen = ieee80211_hdrlen(hdr->frame_control);
++ hdrlen = tx->hdrlen;
+ len = skb->len - hdrlen;
+
+ if (info->control.hw_key)
+@@ -419,7 +418,7 @@ static int ccmp_encrypt_skb(struct ieee8
+ return 0;
+ }
+
+- hdrlen = ieee80211_hdrlen(hdr->frame_control);
++ hdrlen = tx->hdrlen;
+ len = skb->len - hdrlen;
+
+ if (info->control.hw_key)
+@@ -652,7 +651,7 @@ static int gcmp_encrypt_skb(struct ieee8
+ return 0;
+ }
+
+- hdrlen = ieee80211_hdrlen(hdr->frame_control);
++ hdrlen = tx->hdrlen;
+ len = skb->len - hdrlen;
+
+ if (info->control.hw_key)
+@@ -792,7 +791,6 @@ static ieee80211_tx_result
+ ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx,
+ struct sk_buff *skb)
+ {
+- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+ struct ieee80211_key *key = tx->key;
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+ int hdrlen;
+@@ -808,8 +806,7 @@ ieee80211_crypto_cs_encrypt(struct ieee8
+ pskb_expand_head(skb, iv_len, 0, GFP_ATOMIC)))
+ return TX_DROP;
+
+- hdrlen = ieee80211_hdrlen(hdr->frame_control);
+-
++ hdrlen = tx->hdrlen;
+ pos = skb_push(skb, iv_len);
+ memmove(pos, pos + iv_len, hdrlen);
+
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Sun, 28 Aug 2016 13:13:42 +0200
-Subject: [PATCH] ath9k: clear potentially stale EOSP status bit in
- intermediate queues
-
-Prevents spurious ieee80211_sta_eosp calls.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -945,7 +945,8 @@ ath_tx_get_tid_subframe(struct ath_softc
- bf->bf_lastbf = bf;
-
- tx_info = IEEE80211_SKB_CB(skb);
-- tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
-+ tx_info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT |
-+ IEEE80211_TX_STATUS_EOSP);
-
- /*
- * No aggregation session is running, but there may be frames
--- /dev/null
+From: Janusz Dziedzic <janusz.dziedzic@tieto.com>
+Date: Fri, 19 Feb 2016 11:01:50 +0100
+Subject: [PATCH] mac80211: add NEED_ALIGNED4_SKBS hw flag
+
+HW/driver should set NEED_ALIGNED4_SKBS flag in case
+require aligned skbs to four-byte boundaries.
+This affect only TX direction.
+
+Padding is added after ieee80211_hdr, before IV/LLC.
+
+Before we have to do memmove(hdrlen) twice in the
+dirver. Once before we pass this to HW and next
+in tx completion (to be sure monitor will report
+this tx frame correctly).
+
+With this patch we can skip this memmove() and save CPU.
+
+Currently this was tested with ath9k, both hw/sw crypt for
+wep/tkip/ccmp.
+
+Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
+---
+
+--- a/include/net/mac80211.h
++++ b/include/net/mac80211.h
+@@ -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.
++ *
+ * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
+ */
+ enum ieee80211_hw_flags {
+@@ -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
+@@ -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
+@@ -1553,6 +1553,29 @@ ieee80211_vif_get_num_mcast_if(struct ie
+ return -1;
+ }
+
++static inline unsigned int
++ieee80211_hdr_padsize(struct ieee80211_hw *hw, unsigned int hdrlen)
++{
++ /*
++ * While hdrlen is already aligned to two-byte boundaries,
++ * simple check with & 2 will return correct padsize.
++ */
++ if (ieee80211_hw_check(hw, NEEDS_ALIGNED4_SKBS))
++ return hdrlen & 2;
++ return 0;
++}
++
++static inline unsigned int
++ieee80211_padded_hdrlen(struct ieee80211_hw *hw, __le16 fc)
++{
++ unsigned int hdrlen;
++
++ hdrlen = ieee80211_hdrlen(fc);
++ hdrlen += ieee80211_hdr_padsize(hw, hdrlen);
++
++ return hdrlen;
++}
++
+ u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
+ struct ieee80211_rx_status *status,
+ unsigned int mpdu_len,
+--- a/net/mac80211/sta_info.h
++++ b/net/mac80211/sta_info.h
+@@ -282,7 +282,7 @@ struct ieee80211_fast_tx {
+ u8 hdr_len;
+ u8 sa_offs, da_offs, pn_offs;
+ u8 band;
+- u8 hdr[30 + 2 + IEEE80211_FAST_XMIT_MAX_IV +
++ u8 hdr[30 + 2 + 2 + IEEE80211_FAST_XMIT_MAX_IV +
+ sizeof(rfc1042_header)] __aligned(2);
+
+ struct rcu_head rcu_head;
+--- a/net/mac80211/status.c
++++ b/net/mac80211/status.c
+@@ -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;
++ struct ieee80211_hdr *hdr = (void *)skb->data;
+ struct net_device *prev_dev = NULL;
++ unsigned int hdrlen, padsize;
+ int rtap_len;
+
++ /* Remove padding if was added */
++ if (ieee80211_hw_check(&local->hw, NEEDS_ALIGNED4_SKBS)) {
++ hdrlen = ieee80211_hdrlen(hdr->frame_control);
++ padsize = ieee80211_hdr_padsize(&local->hw, hdrlen);
++
++ if (padsize && skb->len > hdrlen + padsize) {
++ memmove(skb->data + padsize, skb->data, hdrlen);
++ skb_pull(skb, padsize);
++ }
++ }
++
+ /* send frame to monitor interfaces now */
+ rtap_len = ieee80211_tx_radiotap_len(info);
+ if (WARN_ON_ONCE(skb_headroom(skb) < rtap_len)) {
+--- a/net/mac80211/tkip.c
++++ b/net/mac80211/tkip.c
+@@ -201,10 +201,12 @@ void ieee80211_get_tkip_p2k(struct ieee8
+ {
+ struct ieee80211_key *key = (struct ieee80211_key *)
+ container_of(keyconf, struct ieee80211_key, conf);
++ struct ieee80211_hw *hw = &key->local->hw;
+ const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY];
+ struct tkip_ctx *ctx = &key->u.tkip.tx;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+- const u8 *data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
++ const u8 *data = (u8 *)hdr + ieee80211_padded_hdrlen(hw,
++ hdr->frame_control);
+ u32 iv32 = get_unaligned_le32(&data[4]);
+ u16 iv16 = data[2] | (data[0] << 8);
+
+--- a/net/mac80211/tx.c
++++ b/net/mac80211/tx.c
+@@ -1176,8 +1176,7 @@ ieee80211_tx_prepare(struct ieee80211_su
+ info->flags &= ~IEEE80211_TX_INTFL_NEED_TXPROCESSING;
+
+ hdr = (struct ieee80211_hdr *) skb->data;
+-
+- tx->hdrlen = ieee80211_hdrlen(hdr->frame_control);
++ tx->hdrlen = ieee80211_padded_hdrlen(&local->hw, hdr->frame_control);
+
+ if (likely(sta)) {
+ if (!IS_ERR(sta))
+@@ -2152,7 +2151,7 @@ netdev_tx_t ieee80211_monitor_start_xmit
+ goto fail;
+
+ hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr);
+- hdrlen = ieee80211_hdrlen(hdr->frame_control);
++ hdrlen = ieee80211_padded_hdrlen(&local->hw, hdr->frame_control);
+
+ if (skb->len < len_rthdr + hdrlen)
+ goto fail;
+@@ -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;
+- int ret;
++ int padsize, ret;
+
+ if (IS_ERR(sta))
+ sta = NULL;
+@@ -2590,6 +2589,9 @@ static struct sk_buff *ieee80211_build_h
+ hdrlen += 2;
+ }
+
++ /* Check aligned4 skb required */
++ padsize = ieee80211_hdr_padsize(&sdata->local->hw, hdrlen);
++
+ /*
+ * Drop unicast frames to unauthorised stations unless they are
+ * EAPOL frames from the local station.
+@@ -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);
++ head_need += padsize;
+
+ /*
+ * So we need to modify the skb header and hence need a copy of
+@@ -2702,6 +2705,9 @@ static struct sk_buff *ieee80211_build_h
+ memcpy(skb_push(skb, meshhdrlen), &mesh_hdr, meshhdrlen);
+ #endif
+
++ if (padsize)
++ memset(skb_push(skb, padsize), 0, padsize);
++
+ if (ieee80211_is_data_qos(fc)) {
+ __le16 *qos_control;
+
+@@ -2877,6 +2883,9 @@ void ieee80211_check_fast_xmit(struct st
+ fc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA);
+ }
+
++ /* Check aligned4 skb required */
++ build.hdr_len += ieee80211_hdr_padsize(&local->hw, build.hdr_len);
++
+ /* 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,
+@@ -3464,7 +3473,7 @@ begin:
+
+ if (tx.key &&
+ (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
+- pn_offs = ieee80211_hdrlen(hdr->frame_control);
++ pn_offs = tx.hdrlen;
+
+ ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs,
+ tx.key, skb);
+--- a/net/mac80211/util.c
++++ b/net/mac80211/util.c
+@@ -1225,6 +1225,7 @@ void ieee80211_send_auth(struct ieee8021
+ u32 tx_flags)
+ {
+ struct ieee80211_local *local = sdata->local;
++ struct ieee80211_hw *hw = &local->hw;
+ struct sk_buff *skb;
+ struct ieee80211_mgmt *mgmt;
+ unsigned int hdrlen;
+@@ -1252,7 +1253,7 @@ void ieee80211_send_auth(struct ieee8021
+ memcpy(skb_put(skb, extra_len), extra, extra_len);
+
+ if (auth_alg == WLAN_AUTH_SHARED_KEY && transaction == 3) {
+- hdrlen = ieee80211_hdrlen(mgmt->frame_control);
++ hdrlen = ieee80211_padded_hdrlen(hw, mgmt->frame_control);
+ mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
+ err = ieee80211_wep_encrypt(local, skb, hdrlen, key,
+ key_len, key_idx);
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Sun, 28 Aug 2016 13:23:27 +0200
-Subject: [PATCH] ath9k: report tx status on EOSP
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -86,7 +86,8 @@ static void ath_tx_status(struct ieee802
- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
- struct ieee80211_sta *sta = info->status.status_driver_data[0];
-
-- if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) {
-+ if (info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS |
-+ IEEE80211_TX_STATUS_EOSP)) {
- ieee80211_tx_status(hw, skb);
- return;
- }
--- /dev/null
+From: Chaitanya T K <chaitanya.mgit@gmail.com>
+Date: Mon, 27 Jun 2016 15:23:26 +0530
+Subject: [PATCH] mac80211: minstrel: Enable STBC and LDPC for VHT Rates
+
+If peer support reception of STBC and LDPC, enable them for better
+performance.
+
+Signed-off-by: Chaitanya TK <chaitanya.mgit@gmail.com>
+---
+
+--- a/include/linux/ieee80211.h
++++ b/include/linux/ieee80211.h
+@@ -1553,6 +1553,7 @@ struct ieee80211_vht_operation {
+ #define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300
+ #define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400
+ #define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700
++#define IEEE80211_VHT_CAP_RXSTBC_SHIFT 8
+ #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800
+ #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000
+ #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT 13
+--- a/net/mac80211/rc80211_minstrel_ht.c
++++ b/net/mac80211/rc80211_minstrel_ht.c
+@@ -1130,7 +1130,7 @@ minstrel_ht_update_caps(void *priv, stru
+ struct minstrel_ht_sta_priv *msp = priv_sta;
+ struct minstrel_ht_sta *mi = &msp->ht;
+ struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs;
+- u16 sta_cap = sta->ht_cap.cap;
++ u16 ht_cap = sta->ht_cap.cap;
+ struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
+ struct sta_info *sinfo = container_of(sta, struct sta_info, sta);
+ int use_vht;
+@@ -1138,6 +1138,7 @@ minstrel_ht_update_caps(void *priv, stru
+ int ack_dur;
+ int stbc;
+ int i;
++ bool ldpc = false;
+
+ /* fall back to the old minstrel for legacy stations */
+ if (!sta->ht_cap.ht_supported)
+@@ -1175,16 +1176,24 @@ minstrel_ht_update_caps(void *priv, stru
+ }
+ mi->sample_tries = 4;
+
+- /* TODO tx_flags for vht - ATM the RC API is not fine-grained enough */
+ if (!use_vht) {
+- stbc = (sta_cap & IEEE80211_HT_CAP_RX_STBC) >>
++ stbc = (ht_cap & IEEE80211_HT_CAP_RX_STBC) >>
+ IEEE80211_HT_CAP_RX_STBC_SHIFT;
+- mi->tx_flags |= stbc << IEEE80211_TX_CTL_STBC_SHIFT;
+
+- if (sta_cap & IEEE80211_HT_CAP_LDPC_CODING)
+- mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
++ if (ht_cap & IEEE80211_HT_CAP_LDPC_CODING)
++ ldpc = true;
++ } else {
++ stbc = (vht_cap->cap & IEEE80211_VHT_CAP_RXSTBC_MASK) >>
++ IEEE80211_VHT_CAP_RXSTBC_SHIFT;
++
++ if (vht_cap->cap & IEEE80211_VHT_CAP_RXLDPC)
++ ldpc = true;
+ }
+
++ mi->tx_flags |= stbc << IEEE80211_TX_CTL_STBC_SHIFT;
++ if (ldpc)
++ mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
++
+ for (i = 0; i < ARRAY_SIZE(mi->groups); i++) {
+ u32 gflags = minstrel_mcs_groups[i].flags;
+ int bw, nss;
+@@ -1197,10 +1206,10 @@ minstrel_ht_update_caps(void *priv, stru
+
+ if (gflags & IEEE80211_TX_RC_SHORT_GI) {
+ if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH) {
+- if (!(sta_cap & IEEE80211_HT_CAP_SGI_40))
++ if (!(ht_cap & IEEE80211_HT_CAP_SGI_40))
+ continue;
+ } else {
+- if (!(sta_cap & IEEE80211_HT_CAP_SGI_20))
++ if (!(ht_cap & IEEE80211_HT_CAP_SGI_20))
+ continue;
+ }
+ }
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Tue, 30 Aug 2016 12:44:08 +0200
-Subject: [PATCH] ath9k: fix block-ack window tracking issues
-
-Ensure that a buffer gets tracked as part of the block-ack window as
-soon as it's dequeued from the tid for the first time. Ensure that
-double calls to ath_tx_addto_baw (e.g. on retransmission) don't cause
-any issues.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -62,7 +62,7 @@ static void ath_tx_rc_status(struct ath_
- struct ath_tx_status *ts, int nframes, int nbad,
- int txok);
- static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
-- int seqno);
-+ struct ath_buf *bf);
- static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
- struct ath_txq *txq,
- struct ath_atx_tid *tid,
-@@ -300,7 +300,7 @@ static void ath_tx_flush_tid(struct ath_
- }
-
- if (fi->baw_tracked) {
-- ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
-+ ath_tx_update_baw(sc, tid, bf);
- sendbar = true;
- }
-
-@@ -316,10 +316,15 @@ static void ath_tx_flush_tid(struct ath_
- }
-
- static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
-- int seqno)
-+ struct ath_buf *bf)
- {
-+ struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
-+ u16 seqno = bf->bf_state.seqno;
- int index, cindex;
-
-+ if (!fi->baw_tracked)
-+ return;
-+
- index = ATH_BA_INDEX(tid->seq_start, seqno);
- cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
-
-@@ -340,6 +345,9 @@ static void ath_tx_addto_baw(struct ath_
- u16 seqno = bf->bf_state.seqno;
- int index, cindex;
-
-+ if (fi->baw_tracked)
-+ return;
-+
- index = ATH_BA_INDEX(tid->seq_start, seqno);
- cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
- __set_bit(cindex, tid->tx_buf);
-@@ -616,7 +624,7 @@ static void ath_tx_complete_aggr(struct
- * complete the acked-ones/xretried ones; update
- * block-ack window
- */
-- ath_tx_update_baw(sc, tid, seqno);
-+ ath_tx_update_baw(sc, tid, bf);
-
- if (rc_update && (acked_cnt == 1 || txfail_cnt == 1)) {
- memcpy(tx_info->control.rates, rates, sizeof(rates));
-@@ -646,7 +654,7 @@ static void ath_tx_complete_aggr(struct
- * run out of tx buf.
- */
- if (!tbf) {
-- ath_tx_update_baw(sc, tid, seqno);
-+ ath_tx_update_baw(sc, tid, bf);
-
- ath_tx_complete_buf(sc, bf, txq,
- &bf_head, NULL, ts,
-@@ -987,11 +995,14 @@ ath_tx_get_tid_subframe(struct ath_softc
-
- INIT_LIST_HEAD(&bf_head);
- list_add(&bf->list, &bf_head);
-- ath_tx_update_baw(sc, tid, seqno);
-+ ath_tx_update_baw(sc, tid, bf);
- ath_tx_complete_buf(sc, bf, txq, &bf_head, NULL, &ts, 0);
- continue;
- }
-
-+ if (bf_isampdu(bf))
-+ ath_tx_addto_baw(sc, tid, bf);
-+
- return bf;
- }
-
-@@ -1049,8 +1060,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s
- bf->bf_next = NULL;
-
- /* link buffers of this frame to the aggregate */
-- if (!fi->baw_tracked)
-- ath_tx_addto_baw(sc, tid, bf);
- bf->bf_state.ndelim = ndelim;
-
- list_add_tail(&bf->list, bf_q);
-@@ -1686,10 +1695,8 @@ void ath9k_release_buffered_frames(struc
- ath9k_set_moredata(sc, bf, true);
- list_add_tail(&bf->list, &bf_q);
- ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
-- if (bf_isampdu(bf)) {
-- ath_tx_addto_baw(sc, tid, bf);
-+ if (bf_isampdu(bf))
- bf->bf_state.bf_type &= ~BUF_AGGR;
-- }
- if (bf_tail)
- bf_tail->bf_next = bf;
-
--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Sun, 28 Aug 2016 13:13:01 +0200
+Subject: [PATCH] ath9k: fix moredata bit in PS buffered frame release
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/xmit.c
++++ b/drivers/net/wireless/ath/ath9k/xmit.c
+@@ -1694,6 +1694,22 @@ void ath_tx_aggr_wakeup(struct ath_softc
+ }
+ }
+
++
++static void
++ath9k_set_moredata(struct ath_softc *sc, struct ath_buf *bf, bool val)
++{
++ struct ieee80211_hdr *hdr;
++ u16 mask = cpu_to_le16(IEEE80211_FCTL_MOREDATA);
++ u16 mask_val = mask * val;
++
++ hdr = (struct ieee80211_hdr *) bf->bf_mpdu->data;
++ if ((hdr->frame_control & mask) != mask_val) {
++ hdr->frame_control = (hdr->frame_control & ~mask) | mask_val;
++ dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
++ sizeof(*hdr), DMA_TO_DEVICE);
++ }
++}
++
+ void ath9k_release_buffered_frames(struct ieee80211_hw *hw,
+ struct ieee80211_sta *sta,
+ u16 tids, int nframes,
+@@ -1724,6 +1740,7 @@ void ath9k_release_buffered_frames(struc
+ if (!bf)
+ break;
+
++ ath9k_set_moredata(sc, bf, true);
+ list_add_tail(&bf->list, &bf_q);
+ ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
+ if (bf_isampdu(bf)) {
+@@ -1747,6 +1764,9 @@ void ath9k_release_buffered_frames(struc
+ if (list_empty(&bf_q))
+ return;
+
++ if (!more_data)
++ ath9k_set_moredata(sc, bf_tail, false);
++
+ info = IEEE80211_SKB_CB(bf_tail->bf_mpdu);
+ info->flags |= IEEE80211_TX_STATUS_EOSP;
+
--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Sun, 28 Aug 2016 13:13:42 +0200
+Subject: [PATCH] ath9k: clear potentially stale EOSP status bit in
+ intermediate queues
+
+Prevents spurious ieee80211_sta_eosp calls.
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/xmit.c
++++ b/drivers/net/wireless/ath/ath9k/xmit.c
+@@ -1004,7 +1004,8 @@ ath_tx_get_tid_subframe(struct ath_softc
+ bf->bf_lastbf = bf;
+
+ tx_info = IEEE80211_SKB_CB(skb);
+- tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
++ tx_info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT |
++ IEEE80211_TX_STATUS_EOSP);
+
+ /*
+ * No aggregation session is running, but there may be frames
--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Sun, 28 Aug 2016 13:23:27 +0200
+Subject: [PATCH] ath9k: report tx status on EOSP
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/xmit.c
++++ b/drivers/net/wireless/ath/ath9k/xmit.c
+@@ -86,7 +86,8 @@ static void ath_tx_status(struct ieee802
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+ struct ieee80211_sta *sta = info->status.status_driver_data[0];
+
+- if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) {
++ if (info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS |
++ IEEE80211_TX_STATUS_EOSP)) {
+ ieee80211_tx_status(hw, skb);
+ return;
+ }
+++ /dev/null
-From: Herbert Xu <herbert@gondor.apana.org.au>
-Date: Mon, 19 Sep 2016 19:00:10 +0800
-Subject: [PATCH] mac80211: Use rhltable instead of rhashtable
-
-mac80211 currently uses rhashtable with insecure_elasticity set
-to true. The latter is because of duplicate objects. What's
-more, mac80211 walks the rhashtable chains by hand which is broken
-as rhashtable may contain multiple tables due to resizing or
-rehashing.
-
-This patch fixes it by converting it to the newly added rhltable
-interface which is designed for use with duplicate objects.
-
-With rhltable a lookup returns a list of objects instead of a
-single one. This is then fed into the existing for_each_sta_info
-macro.
-
-This patch also deletes the sta_addr_hash function since rhashtable
-defaults to jhash.
-
-Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
----
-
---- a/net/mac80211/ieee80211_i.h
-+++ b/net/mac80211/ieee80211_i.h
-@@ -1233,7 +1233,7 @@ struct ieee80211_local {
- spinlock_t tim_lock;
- unsigned long num_sta;
- struct list_head sta_list;
-- struct rhashtable sta_hash;
-+ struct rhltable sta_hash;
- struct timer_list sta_cleanup;
- int sta_generation;
-
---- a/net/mac80211/rx.c
-+++ b/net/mac80211/rx.c
-@@ -4004,7 +4004,7 @@ static void __ieee80211_rx_handle_packet
- __le16 fc;
- struct ieee80211_rx_data rx;
- struct ieee80211_sub_if_data *prev;
-- struct rhash_head *tmp;
-+ struct rhlist_head *tmp;
- int err = 0;
-
- fc = ((struct ieee80211_hdr *)skb->data)->frame_control;
-@@ -4047,13 +4047,10 @@ static void __ieee80211_rx_handle_packet
- goto out;
- } else if (ieee80211_is_data(fc)) {
- struct sta_info *sta, *prev_sta;
-- const struct bucket_table *tbl;
-
- prev_sta = NULL;
-
-- tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash);
--
-- for_each_sta_info(local, tbl, hdr->addr2, sta, tmp) {
-+ for_each_sta_info(local, hdr->addr2, sta, tmp) {
- if (!prev_sta) {
- prev_sta = sta;
- continue;
---- a/net/mac80211/sta_info.c
-+++ b/net/mac80211/sta_info.c
-@@ -67,12 +67,10 @@
-
- static const struct rhashtable_params sta_rht_params = {
- .nelem_hint = 3, /* start small */
-- .insecure_elasticity = true, /* Disable chain-length checks. */
- .automatic_shrinking = true,
- .head_offset = offsetof(struct sta_info, hash_node),
- .key_offset = offsetof(struct sta_info, addr),
- .key_len = ETH_ALEN,
-- .hashfn = sta_addr_hash,
- .max_size = CPTCFG_MAC80211_STA_HASH_MAX_SIZE,
- };
-
-@@ -80,8 +78,8 @@ static const struct rhashtable_params st
- static int sta_info_hash_del(struct ieee80211_local *local,
- struct sta_info *sta)
- {
-- return rhashtable_remove_fast(&local->sta_hash, &sta->hash_node,
-- sta_rht_params);
-+ return rhltable_remove(&local->sta_hash, &sta->hash_node,
-+ sta_rht_params);
- }
-
- static void __cleanup_single_sta(struct sta_info *sta)
-@@ -157,19 +155,22 @@ static void cleanup_single_sta(struct st
- sta_info_free(local, sta);
- }
-
-+struct rhlist_head *sta_info_hash_lookup(struct ieee80211_local *local,
-+ const u8 *addr)
-+{
-+ return rhltable_lookup(&local->sta_hash, addr, sta_rht_params);
-+}
-+
- /* protected by RCU */
- struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata,
- const u8 *addr)
- {
- struct ieee80211_local *local = sdata->local;
-+ struct rhlist_head *tmp;
- struct sta_info *sta;
-- struct rhash_head *tmp;
-- const struct bucket_table *tbl;
-
- rcu_read_lock();
-- tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash);
--
-- for_each_sta_info(local, tbl, addr, sta, tmp) {
-+ for_each_sta_info(local, addr, sta, tmp) {
- if (sta->sdata == sdata) {
- rcu_read_unlock();
- /* this is safe as the caller must already hold
-@@ -190,14 +191,11 @@ struct sta_info *sta_info_get_bss(struct
- const u8 *addr)
- {
- struct ieee80211_local *local = sdata->local;
-+ struct rhlist_head *tmp;
- struct sta_info *sta;
-- struct rhash_head *tmp;
-- const struct bucket_table *tbl;
-
- rcu_read_lock();
-- tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash);
--
-- for_each_sta_info(local, tbl, addr, sta, tmp) {
-+ for_each_sta_info(local, addr, sta, tmp) {
- if (sta->sdata == sdata ||
- (sta->sdata->bss && sta->sdata->bss == sdata->bss)) {
- rcu_read_unlock();
-@@ -263,8 +261,8 @@ void sta_info_free(struct ieee80211_loca
- static int sta_info_hash_add(struct ieee80211_local *local,
- struct sta_info *sta)
- {
-- return rhashtable_insert_fast(&local->sta_hash, &sta->hash_node,
-- sta_rht_params);
-+ return rhltable_insert(&local->sta_hash, &sta->hash_node,
-+ sta_rht_params);
- }
-
- static void sta_deliver_ps_frames(struct work_struct *wk)
-@@ -453,9 +451,9 @@ static int sta_info_insert_check(struct
- is_multicast_ether_addr(sta->sta.addr)))
- return -EINVAL;
-
-- /* Strictly speaking this isn't necessary as we hold the mutex, but
-- * the rhashtable code can't really deal with that distinction. We
-- * do require the mutex for correctness though.
-+ /* The RCU read lock is required by rhashtable due to
-+ * asynchronous resize/rehash. We also require the mutex
-+ * for correctness.
- */
- rcu_read_lock();
- lockdep_assert_held(&sdata->local->sta_mtx);
-@@ -1043,16 +1041,11 @@ static void sta_info_cleanup(unsigned lo
- round_jiffies(jiffies + STA_INFO_CLEANUP_INTERVAL));
- }
-
--u32 sta_addr_hash(const void *key, u32 length, u32 seed)
--{
-- return jhash(key, ETH_ALEN, seed);
--}
--
- int sta_info_init(struct ieee80211_local *local)
- {
- int err;
-
-- err = rhashtable_init(&local->sta_hash, &sta_rht_params);
-+ err = rhltable_init(&local->sta_hash, &sta_rht_params);
- if (err)
- return err;
-
-@@ -1068,7 +1061,7 @@ int sta_info_init(struct ieee80211_local
- void sta_info_stop(struct ieee80211_local *local)
- {
- del_timer_sync(&local->sta_cleanup);
-- rhashtable_destroy(&local->sta_hash);
-+ rhltable_destroy(&local->sta_hash);
- }
-
-
-@@ -1138,17 +1131,14 @@ struct ieee80211_sta *ieee80211_find_sta
- const u8 *localaddr)
- {
- struct ieee80211_local *local = hw_to_local(hw);
-+ struct rhlist_head *tmp;
- struct sta_info *sta;
-- struct rhash_head *tmp;
-- const struct bucket_table *tbl;
--
-- tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash);
-
- /*
- * Just return a random station if localaddr is NULL
- * ... first in list.
- */
-- for_each_sta_info(local, tbl, addr, sta, tmp) {
-+ for_each_sta_info(local, addr, sta, tmp) {
- if (localaddr &&
- !ether_addr_equal(sta->sdata->vif.addr, localaddr))
- continue;
---- a/net/mac80211/sta_info.h
-+++ b/net/mac80211/sta_info.h
-@@ -455,7 +455,7 @@ struct sta_info {
- /* General information, mostly static */
- struct list_head list, free_list;
- struct rcu_head rcu_head;
-- struct rhash_head hash_node;
-+ struct rhlist_head hash_node;
- u8 addr[ETH_ALEN];
- struct ieee80211_local *local;
- struct ieee80211_sub_if_data *sdata;
-@@ -638,6 +638,9 @@ rcu_dereference_protected_tid_tx(struct
- */
- #define STA_INFO_CLEANUP_INTERVAL (10 * HZ)
-
-+struct rhlist_head *sta_info_hash_lookup(struct ieee80211_local *local,
-+ const u8 *addr);
-+
- /*
- * Get a STA info, must be under RCU read lock.
- */
-@@ -647,17 +650,9 @@ struct sta_info *sta_info_get(struct iee
- struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata,
- const u8 *addr);
-
--u32 sta_addr_hash(const void *key, u32 length, u32 seed);
--
--#define _sta_bucket_idx(_tbl, _a) \
-- rht_bucket_index(_tbl, sta_addr_hash(_a, ETH_ALEN, (_tbl)->hash_rnd))
--
--#define for_each_sta_info(local, tbl, _addr, _sta, _tmp) \
-- rht_for_each_entry_rcu(_sta, _tmp, tbl, \
-- _sta_bucket_idx(tbl, _addr), \
-- hash_node) \
-- /* compare address and run code only if it matches */ \
-- if (ether_addr_equal(_sta->addr, (_addr)))
-+#define for_each_sta_info(local, _addr, _sta, _tmp) \
-+ rhl_for_each_entry_rcu(_sta, _tmp, \
-+ sta_info_hash_lookup(local, _addr), hash_node)
-
- /*
- * Get STA info by index, BROKEN!
---- a/net/mac80211/status.c
-+++ b/net/mac80211/status.c
-@@ -759,8 +759,8 @@ void ieee80211_tx_status(struct ieee8021
- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
- __le16 fc;
- struct ieee80211_supported_band *sband;
-+ struct rhlist_head *tmp;
- struct sta_info *sta;
-- struct rhash_head *tmp;
- int retry_count;
- int rates_idx;
- bool send_to_cooked;
-@@ -768,7 +768,6 @@ void ieee80211_tx_status(struct ieee8021
- struct ieee80211_bar *bar;
- int shift = 0;
- int tid = IEEE80211_NUM_TIDS;
-- const struct bucket_table *tbl;
-
- rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
-
-@@ -777,9 +776,7 @@ void ieee80211_tx_status(struct ieee8021
- sband = local->hw.wiphy->bands[info->band];
- fc = hdr->frame_control;
-
-- tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash);
--
-- for_each_sta_info(local, tbl, hdr->addr1, sta, tmp) {
-+ for_each_sta_info(local, hdr->addr1, sta, tmp) {
- /* skip wrong virtual interface */
- if (!ether_addr_equal(hdr->addr2, sta->sdata->vif.addr))
- continue;
--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Tue, 30 Aug 2016 12:44:08 +0200
+Subject: [PATCH] ath9k: fix block-ack window tracking issues
+
+Ensure that a buffer gets tracked as part of the block-ack window as
+soon as it's dequeued from the tid for the first time. Ensure that
+double calls to ath_tx_addto_baw (e.g. on retransmission) don't cause
+any issues.
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/xmit.c
++++ b/drivers/net/wireless/ath/ath9k/xmit.c
+@@ -62,7 +62,7 @@ static void ath_tx_rc_status(struct ath_
+ struct ath_tx_status *ts, int nframes, int nbad,
+ int txok);
+ static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
+- int seqno);
++ struct ath_buf *bf);
+ static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
+ struct ath_txq *txq,
+ struct ath_atx_tid *tid,
+@@ -311,7 +311,7 @@ static void ath_tx_flush_tid(struct ath_
+ }
+
+ if (fi->baw_tracked) {
+- ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
++ ath_tx_update_baw(sc, tid, bf);
+ sendbar = true;
+ }
+
+@@ -327,10 +327,15 @@ static void ath_tx_flush_tid(struct ath_
+ }
+
+ static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
+- int seqno)
++ struct ath_buf *bf)
+ {
++ struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
++ u16 seqno = bf->bf_state.seqno;
+ int index, cindex;
+
++ if (!fi->baw_tracked)
++ return;
++
+ index = ATH_BA_INDEX(tid->seq_start, seqno);
+ cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
+
+@@ -351,6 +356,9 @@ static void ath_tx_addto_baw(struct ath_
+ u16 seqno = bf->bf_state.seqno;
+ int index, cindex;
+
++ if (fi->baw_tracked)
++ return;
++
+ index = ATH_BA_INDEX(tid->seq_start, seqno);
+ cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
+ __set_bit(cindex, tid->tx_buf);
+@@ -627,7 +635,7 @@ static void ath_tx_complete_aggr(struct
+ * complete the acked-ones/xretried ones; update
+ * block-ack window
+ */
+- ath_tx_update_baw(sc, tid, seqno);
++ ath_tx_update_baw(sc, tid, bf);
+
+ if (rc_update && (acked_cnt == 1 || txfail_cnt == 1)) {
+ memcpy(tx_info->control.rates, rates, sizeof(rates));
+@@ -657,7 +665,7 @@ static void ath_tx_complete_aggr(struct
+ * run out of tx buf.
+ */
+ if (!tbf) {
+- ath_tx_update_baw(sc, tid, seqno);
++ ath_tx_update_baw(sc, tid, bf);
+
+ ath_tx_complete_buf(sc, bf, txq,
+ &bf_head, NULL, ts,
+@@ -1046,11 +1054,14 @@ ath_tx_get_tid_subframe(struct ath_softc
+
+ INIT_LIST_HEAD(&bf_head);
+ list_add(&bf->list, &bf_head);
+- ath_tx_update_baw(sc, tid, seqno);
++ ath_tx_update_baw(sc, tid, bf);
+ ath_tx_complete_buf(sc, bf, txq, &bf_head, NULL, &ts, 0);
+ continue;
+ }
+
++ if (bf_isampdu(bf))
++ ath_tx_addto_baw(sc, tid, bf);
++
+ return bf;
+ }
+
+@@ -1108,8 +1119,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s
+ bf->bf_next = NULL;
+
+ /* link buffers of this frame to the aggregate */
+- if (!fi->baw_tracked)
+- ath_tx_addto_baw(sc, tid, bf);
+ bf->bf_state.ndelim = ndelim;
+
+ list_add_tail(&bf->list, bf_q);
+@@ -1745,10 +1754,8 @@ void ath9k_release_buffered_frames(struc
+ ath9k_set_moredata(sc, bf, true);
+ list_add_tail(&bf->list, &bf_q);
+ ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
+- if (bf_isampdu(bf)) {
+- ath_tx_addto_baw(sc, tid, bf);
++ if (bf_isampdu(bf))
+ bf->bf_state.bf_type &= ~BUF_AGGR;
+- }
+ if (bf_tail)
+ bf_tail->bf_next = bf;
+
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Tue, 11 Oct 2016 11:24:07 +0200
-Subject: [PATCH] mac80211: fix sequence number allocation regression
-
-The recent commit that moved around TX handlers dropped the sequence
-number allocation at the end of ieee80211_tx_dequeue and calls
-ieee80211_tx_h_sequence instead (for the non-fast-xmit case).
-However, it did not change the fast-xmit sequence allocation condition
-in ieee80211_xmit_fast_finish, which skipped seqno alloc if intermediate
-tx queues are being used.
-
-Drop the now obsolete condition.
-
-Fixes: bb42f2d13ffc ("mac80211: Move reorder-sensitive TX handlers to after TXQ dequeue")
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -3212,7 +3212,6 @@ static void ieee80211_xmit_fast_finish(s
- struct sk_buff *skb)
- {
- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-- struct ieee80211_local *local = sdata->local;
- struct ieee80211_hdr *hdr = (void *)skb->data;
- u8 tid = IEEE80211_NUM_TIDS;
-
-@@ -3224,8 +3223,7 @@ static void ieee80211_xmit_fast_finish(s
- if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
- tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
- *ieee80211_get_qos_ctl(hdr) = tid;
-- if (!ieee80211_get_txq(local, &sdata->vif, &sta->sta, skb))
-- hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid);
-+ hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid);
- } else {
- info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;
- hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number);
--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Wed, 25 Jan 2017 12:57:05 +0100
+Subject: [PATCH] ath9k: rename tx_complete_work to hw_check_work
+
+Also include common MAC alive check. This should make the hang checks
+more reliable for modes where beacons are not sent and is used as a
+starting point for further hang check improvements
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -108,7 +108,7 @@ int ath_descdma_setup(struct ath_softc *
+ #define ATH_AGGR_MIN_QDEPTH 2
+ /* minimum h/w qdepth for non-aggregated traffic */
+ #define ATH_NON_AGGR_MIN_QDEPTH 8
+-#define ATH_TX_COMPLETE_POLL_INT 1000
++#define ATH_HW_CHECK_POLL_INT 1000
+ #define ATH_TXFIFO_DEPTH 8
+ #define ATH_TX_ERROR 0x01
+
+@@ -745,7 +745,7 @@ void ath9k_csa_update(struct ath_softc *
+ #define ATH_PAPRD_TIMEOUT 100 /* msecs */
+ #define ATH_PLL_WORK_INTERVAL 100
+
+-void ath_tx_complete_poll_work(struct work_struct *work);
++void ath_hw_check_work(struct work_struct *work);
+ void ath_reset_work(struct work_struct *work);
+ bool ath_hw_check(struct ath_softc *sc);
+ void ath_hw_pll_work(struct work_struct *work);
+@@ -1053,7 +1053,7 @@ struct ath_softc {
+ #ifdef CPTCFG_ATH9K_DEBUGFS
+ struct ath9k_debug debug;
+ #endif
+- struct delayed_work tx_complete_work;
++ struct delayed_work hw_check_work;
+ struct delayed_work hw_pll_work;
+ struct timer_list sleep_timer;
+
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -681,6 +681,7 @@ static int ath9k_init_softc(u16 devid, s
+ INIT_WORK(&sc->hw_reset_work, ath_reset_work);
+ INIT_WORK(&sc->paprd_work, ath_paprd_calibrate);
+ INIT_DELAYED_WORK(&sc->hw_pll_work, ath_hw_pll_work);
++ INIT_DELAYED_WORK(&sc->hw_check_work, ath_hw_check_work);
+
+ ath9k_init_channel_context(sc);
+
+--- a/drivers/net/wireless/ath/ath9k/link.c
++++ b/drivers/net/wireless/ath/ath9k/link.c
+@@ -20,20 +20,13 @@
+ * TX polling - checks if the TX engine is stuck somewhere
+ * and issues a chip reset if so.
+ */
+-void ath_tx_complete_poll_work(struct work_struct *work)
++static bool ath_tx_complete_check(struct ath_softc *sc)
+ {
+- struct ath_softc *sc = container_of(work, struct ath_softc,
+- tx_complete_work.work);
+ struct ath_txq *txq;
+ int i;
+- bool needreset = false;
+-
+
+- if (sc->tx99_state) {
+- ath_dbg(ath9k_hw_common(sc->sc_ah), RESET,
+- "skip tx hung detection on tx99\n");
+- return;
+- }
++ if (sc->tx99_state)
++ return true;
+
+ for (i = 0; i < IEEE80211_NUM_ACS; i++) {
+ txq = sc->tx.txq_map[i];
+@@ -41,25 +34,36 @@ void ath_tx_complete_poll_work(struct wo
+ ath_txq_lock(sc, txq);
+ if (txq->axq_depth) {
+ if (txq->axq_tx_inprogress) {
+- needreset = true;
+ ath_txq_unlock(sc, txq);
+- break;
+- } else {
+- txq->axq_tx_inprogress = true;
++ goto reset;
+ }
++
++ txq->axq_tx_inprogress = true;
+ }
+ ath_txq_unlock(sc, txq);
+ }
+
+- if (needreset) {
+- ath_dbg(ath9k_hw_common(sc->sc_ah), RESET,
+- "tx hung, resetting the chip\n");
+- ath9k_queue_reset(sc, RESET_TYPE_TX_HANG);
++ return true;
++
++reset:
++ ath_dbg(ath9k_hw_common(sc->sc_ah), RESET,
++ "tx hung, resetting the chip\n");
++ ath9k_queue_reset(sc, RESET_TYPE_TX_HANG);
++ return false;
++
++}
++
++void ath_hw_check_work(struct work_struct *work)
++{
++ struct ath_softc *sc = container_of(work, struct ath_softc,
++ hw_check_work.work);
++
++ if (!ath_hw_check(sc) ||
++ !ath_tx_complete_check(sc))
+ return;
+- }
+
+- ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work,
+- msecs_to_jiffies(ATH_TX_COMPLETE_POLL_INT));
++ ieee80211_queue_delayed_work(sc->hw, &sc->hw_check_work,
++ msecs_to_jiffies(ATH_HW_CHECK_POLL_INT));
+ }
+
+ /*
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -181,7 +181,7 @@ void ath9k_ps_restore(struct ath_softc *
+ static void __ath_cancel_work(struct ath_softc *sc)
+ {
+ cancel_work_sync(&sc->paprd_work);
+- cancel_delayed_work_sync(&sc->tx_complete_work);
++ cancel_delayed_work_sync(&sc->hw_check_work);
+ cancel_delayed_work_sync(&sc->hw_pll_work);
+
+ #ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
+@@ -198,7 +198,8 @@ void ath_cancel_work(struct ath_softc *s
+
+ void ath_restart_work(struct ath_softc *sc)
+ {
+- ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
++ ieee80211_queue_delayed_work(sc->hw, &sc->hw_check_work,
++ ATH_HW_CHECK_POLL_INT);
+
+ if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9330(sc->sc_ah))
+ ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work,
+@@ -2091,7 +2092,7 @@ void __ath9k_flush(struct ieee80211_hw *
+ int timeout;
+ bool drain_txq;
+
+- cancel_delayed_work_sync(&sc->tx_complete_work);
++ cancel_delayed_work_sync(&sc->hw_check_work);
+
+ if (ah->ah_flags & AH_UNPLUGGED) {
+ ath_dbg(common, ANY, "Device has been unplugged!\n");
+@@ -2129,7 +2130,8 @@ void __ath9k_flush(struct ieee80211_hw *
+ ath9k_ps_restore(sc);
+ }
+
+- ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0);
++ ieee80211_queue_delayed_work(hw, &sc->hw_check_work,
++ ATH_HW_CHECK_POLL_INT);
+ }
+
+ static bool ath9k_tx_frames_pending(struct ieee80211_hw *hw)
+--- a/drivers/net/wireless/ath/ath9k/xmit.c
++++ b/drivers/net/wireless/ath/ath9k/xmit.c
+@@ -2916,8 +2916,6 @@ int ath_tx_init(struct ath_softc *sc, in
+ return error;
+ }
+
+- INIT_DELAYED_WORK(&sc->tx_complete_work, ath_tx_complete_poll_work);
+-
+ if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
+ error = ath_tx_edma_init(sc);
+
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Sat, 9 Jul 2016 15:25:24 +0200
-Subject: [PATCH] ath9k_hw: reset AHB-WMAC interface on AR91xx
-
-Should fix a few stability issues
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1394,8 +1394,12 @@ static bool ath9k_hw_set_reset(struct at
- if (!AR_SREV_9100(ah))
- REG_WRITE(ah, AR_RC, 0);
-
-- if (AR_SREV_9100(ah))
-+ if (AR_SREV_9100(ah)) {
-+ /* Reset the AHB-WMAC interface */
-+ if (ah->external_reset)
-+ ah->external_reset();
- udelay(50);
-+ }
-
- return true;
- }
--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Wed, 25 Jan 2017 12:58:17 +0100
+Subject: [PATCH] ath9k_hw: check if the chip failed to wake up
+
+In an RFC patch, Sven Eckelmann and Simon Wunderlich reported:
+
+"QCA 802.11n chips (especially AR9330/AR9340) sometimes end up in a
+state in which a read of AR_CFG always returns 0xdeadbeef.
+This should not happen when when the power_mode of the device is
+ATH9K_PM_AWAKE."
+
+Include the check for the default register state in the existing MAC
+hang check.
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -1624,6 +1624,10 @@ bool ath9k_hw_check_alive(struct ath_hw
+ int count = 50;
+ u32 reg, last_val;
+
++ /* Check if chip failed to wake up */
++ if (REG_READ(ah, AR_CFG) == 0xdeadbeef)
++ return false;
++
+ if (AR_SREV_9300(ah))
+ return !ath9k_hw_detect_mac_hang(ah);
+
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Sat, 9 Jul 2016 15:26:44 +0200
-Subject: [PATCH] ath9k_hw: issue external reset for QCA955x
-
-The RTC interface on the SoC needs to be reset along with the rest of
-the WMAC.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1271,39 +1271,56 @@ void ath9k_hw_get_delta_slope_vals(struc
- *coef_exponent = coef_exp - 16;
- }
-
--/* AR9330 WAR:
-- * call external reset function to reset WMAC if:
-- * - doing a cold reset
-- * - we have pending frames in the TX queues.
-- */
--static bool ath9k_hw_ar9330_reset_war(struct ath_hw *ah, int type)
-+static bool ath9k_hw_need_external_reset(struct ath_hw *ah, int type)
- {
-- int i, npend = 0;
-+ int i;
-
-- for (i = 0; i < AR_NUM_QCU; i++) {
-- npend = ath9k_hw_numtxpending(ah, i);
-- if (npend)
-- break;
-+ if (type == ATH9K_RESET_COLD)
-+ return true;
-+
-+ if (AR_SREV_9550(ah))
-+ return true;
-+
-+ /* AR9330 WAR:
-+ * call external reset function to reset WMAC if:
-+ * - doing a cold reset
-+ * - we have pending frames in the TX queues.
-+ */
-+ if (AR_SREV_9330(ah)) {
-+ 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");
-+
-+ 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);
-+
- return true;
- }
-
-@@ -1356,24 +1373,24 @@ static bool ath9k_hw_set_reset(struct at
- rst_flags |= AR_RTC_RC_MAC_COLD;
- }
-
-- if (AR_SREV_9330(ah)) {
-- if (!ath9k_hw_ar9330_reset_war(ah, type))
-- return false;
-- }
--
- if (ath9k_hw_mci_is_enabled(ah))
- ar9003_mci_check_gpm_offset(ah);
-
- /* DMA HALT added to resolve ar9300 and ar9580 bus error during
-- * RTC_RC reg read
-+ * RTC_RC reg read. Also needed for AR9550 external reset
- */
-- if (AR_SREV_9300(ah) || AR_SREV_9580(ah)) {
-+ if (AR_SREV_9300(ah) || AR_SREV_9580(ah) || AR_SREV_9550(ah)) {
- REG_SET_BIT(ah, AR_CFG, AR_CFG_HALT_REQ);
- ath9k_hw_wait(ah, AR_CFG, AR_CFG_HALT_ACK, AR_CFG_HALT_ACK,
- 20 * AH_WAIT_TIMEOUT);
-- REG_CLR_BIT(ah, AR_CFG, AR_CFG_HALT_REQ);
- }
-
-+ if (!AR_SREV_9100(ah))
-+ ath9k_hw_external_reset(ah, type);
-+
-+ if (AR_SREV_9300(ah) || AR_SREV_9580(ah))
-+ REG_CLR_BIT(ah, AR_CFG, AR_CFG_HALT_REQ);
-+
- REG_WRITE(ah, AR_RTC_RC, rst_flags);
-
- REGWRITE_BUFFER_FLUSH(ah);
--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Wed, 25 Jan 2017 15:10:37 +0100
+Subject: [PATCH] ath9k: fix race condition in enabling/disabling IRQs
+
+The code currently relies on refcounting to disable IRQs from within the
+IRQ handler and re-enabling them again after the tasklet has run.
+
+However, due to race conditions sometimes the IRQ handler might be
+called twice, or the tasklet may not run at all (if interrupted in the
+middle of a reset).
+
+This can cause nasty imbalances in the irq-disable refcount which will
+get the driver permanently stuck until the entire radio has been stopped
+and started again (ath_reset will not recover from this).
+
+Instead of using this fragile logic, change the code to ensure that
+running the irq handler during tasklet processing is safe, and leave the
+refcount untouched.
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -998,6 +998,7 @@ struct ath_softc {
+ struct survey_info *cur_survey;
+ struct survey_info survey[ATH9K_NUM_CHANNELS];
+
++ spinlock_t intr_lock;
+ struct tasklet_struct intr_tq;
+ struct tasklet_struct bcon_tasklet;
+ struct ath_hw *sc_ah;
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -669,6 +669,7 @@ static int ath9k_init_softc(u16 devid, s
+ common->bt_ant_diversity = 1;
+
+ spin_lock_init(&common->cc_lock);
++ spin_lock_init(&sc->intr_lock);
+ spin_lock_init(&sc->sc_serial_rw);
+ spin_lock_init(&sc->sc_pm_lock);
+ spin_lock_init(&sc->chan_lock);
+--- a/drivers/net/wireless/ath/ath9k/mac.c
++++ b/drivers/net/wireless/ath/ath9k/mac.c
+@@ -810,21 +810,12 @@ void ath9k_hw_disable_interrupts(struct
+ }
+ EXPORT_SYMBOL(ath9k_hw_disable_interrupts);
+
+-void ath9k_hw_enable_interrupts(struct ath_hw *ah)
++static void __ath9k_hw_enable_interrupts(struct ath_hw *ah)
+ {
+ struct ath_common *common = ath9k_hw_common(ah);
+ u32 sync_default = AR_INTR_SYNC_DEFAULT;
+ u32 async_mask;
+
+- if (!(ah->imask & ATH9K_INT_GLOBAL))
+- return;
+-
+- if (!atomic_inc_and_test(&ah->intr_ref_cnt)) {
+- ath_dbg(common, INTERRUPT, "Do not enable IER ref count %d\n",
+- atomic_read(&ah->intr_ref_cnt));
+- return;
+- }
+-
+ if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah) ||
+ AR_SREV_9561(ah))
+ sync_default &= ~AR_INTR_SYNC_HOST1_FATAL;
+@@ -846,6 +837,39 @@ void ath9k_hw_enable_interrupts(struct a
+ ath_dbg(common, INTERRUPT, "AR_IMR 0x%x IER 0x%x\n",
+ REG_READ(ah, AR_IMR), REG_READ(ah, AR_IER));
+ }
++
++void ath9k_hw_resume_interrupts(struct ath_hw *ah)
++{
++ struct ath_common *common = ath9k_hw_common(ah);
++
++ if (!(ah->imask & ATH9K_INT_GLOBAL))
++ return;
++
++ if (atomic_read(&ah->intr_ref_cnt) != 0) {
++ ath_dbg(common, INTERRUPT, "Do not enable IER ref count %d\n",
++ atomic_read(&ah->intr_ref_cnt));
++ return;
++ }
++
++ __ath9k_hw_enable_interrupts(ah);
++}
++EXPORT_SYMBOL(ath9k_hw_resume_interrupts);
++
++void ath9k_hw_enable_interrupts(struct ath_hw *ah)
++{
++ struct ath_common *common = ath9k_hw_common(ah);
++
++ if (!(ah->imask & ATH9K_INT_GLOBAL))
++ return;
++
++ if (!atomic_inc_and_test(&ah->intr_ref_cnt)) {
++ ath_dbg(common, INTERRUPT, "Do not enable IER ref count %d\n",
++ atomic_read(&ah->intr_ref_cnt));
++ return;
++ }
++
++ __ath9k_hw_enable_interrupts(ah);
++}
+ EXPORT_SYMBOL(ath9k_hw_enable_interrupts);
+
+ void ath9k_hw_set_interrupts(struct ath_hw *ah)
+--- a/drivers/net/wireless/ath/ath9k/mac.h
++++ b/drivers/net/wireless/ath/ath9k/mac.h
+@@ -744,6 +744,7 @@ void ath9k_hw_set_interrupts(struct ath_
+ void ath9k_hw_enable_interrupts(struct ath_hw *ah);
+ void ath9k_hw_disable_interrupts(struct ath_hw *ah);
+ void ath9k_hw_kill_interrupts(struct ath_hw *ah);
++void ath9k_hw_resume_interrupts(struct ath_hw *ah);
+
+ void ar9002_hw_attach_mac_ops(struct ath_hw *ah);
+
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -374,21 +374,20 @@ void ath9k_tasklet(unsigned long data)
+ struct ath_common *common = ath9k_hw_common(ah);
+ enum ath_reset_type type;
+ unsigned long flags;
+- u32 status = sc->intrstatus;
++ u32 status;
+ u32 rxmask;
+
++ spin_lock_irqsave(&sc->intr_lock, flags);
++ status = sc->intrstatus;
++ sc->intrstatus = 0;
++ spin_unlock_irqrestore(&sc->intr_lock, flags);
++
+ ath9k_ps_wakeup(sc);
+ spin_lock(&sc->sc_pcu_lock);
+
+ if (status & ATH9K_INT_FATAL) {
+ type = RESET_TYPE_FATAL_INT;
+ ath9k_queue_reset(sc, type);
+-
+- /*
+- * Increment the ref. counter here so that
+- * interrupts are enabled in the reset routine.
+- */
+- atomic_inc(&ah->intr_ref_cnt);
+ ath_dbg(common, RESET, "FATAL: Skipping interrupts\n");
+ goto out;
+ }
+@@ -404,11 +403,6 @@ void ath9k_tasklet(unsigned long data)
+ type = RESET_TYPE_BB_WATCHDOG;
+ ath9k_queue_reset(sc, type);
+
+- /*
+- * Increment the ref. counter here so that
+- * interrupts are enabled in the reset routine.
+- */
+- atomic_inc(&ah->intr_ref_cnt);
+ ath_dbg(common, RESET,
+ "BB_WATCHDOG: Skipping interrupts\n");
+ goto out;
+@@ -421,7 +415,6 @@ void ath9k_tasklet(unsigned long data)
+ if ((sc->gtt_cnt >= MAX_GTT_CNT) && !ath9k_hw_check_alive(ah)) {
+ type = RESET_TYPE_TX_GTT;
+ ath9k_queue_reset(sc, type);
+- atomic_inc(&ah->intr_ref_cnt);
+ ath_dbg(common, RESET,
+ "GTT: Skipping interrupts\n");
+ goto out;
+@@ -478,7 +471,7 @@ void ath9k_tasklet(unsigned long data)
+ ath9k_btcoex_handle_interrupt(sc, status);
+
+ /* re-enable hardware interrupt */
+- ath9k_hw_enable_interrupts(ah);
++ ath9k_hw_resume_interrupts(ah);
+ out:
+ spin_unlock(&sc->sc_pcu_lock);
+ ath9k_ps_restore(sc);
+@@ -542,7 +535,9 @@ irqreturn_t ath_isr(int irq, void *dev)
+ return IRQ_NONE;
+
+ /* Cache the status */
+- sc->intrstatus = status;
++ spin_lock(&sc->intr_lock);
++ sc->intrstatus |= status;
++ spin_unlock(&sc->intr_lock);
+
+ if (status & SCHED_INTR)
+ sched = true;
+@@ -588,7 +583,7 @@ chip_reset:
+
+ if (sched) {
+ /* turn off every interrupt */
+- ath9k_hw_disable_interrupts(ah);
++ ath9k_hw_kill_interrupts(ah);
+ tasklet_schedule(&sc->intr_tq);
+ }
+
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Mon, 11 Jul 2016 12:07:40 +0200
-Subject: [PATCH] ath9k_hw: set spectral scan enable bit on trigger for
- AR9003+
-
-AR9002 code and QCA AR9003+ code do the same.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
-@@ -1800,6 +1800,8 @@ static void ar9003_hw_spectral_scan_conf
-
- static void ar9003_hw_spectral_scan_trigger(struct ath_hw *ah)
- {
-+ REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN,
-+ AR_PHY_SPECTRAL_SCAN_ENABLE);
- /* Activate spectral scan */
- REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN,
- AR_PHY_SPECTRAL_SCAN_ACTIVE);
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Tue, 11 Oct 2016 19:45:41 +0200
-Subject: [PATCH] Revert "ath9k_hw: implement temperature compensation support
- for AR9003+"
-
-This reverts commit 171f6402e4aa5cd3b8407f82501f7ea21fa54ccc.
-Some users report that this commit causes a regression in performance
-under some conditions.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
-@@ -33,7 +33,6 @@ struct coeff {
-
- enum ar9003_cal_types {
- IQ_MISMATCH_CAL = BIT(0),
-- TEMP_COMP_CAL = BIT(1),
- };
-
- static void ar9003_hw_setup_calibration(struct ath_hw *ah,
-@@ -59,12 +58,6 @@ static void ar9003_hw_setup_calibration(
- /* Kick-off cal */
- REG_SET_BIT(ah, AR_PHY_TIMING4, AR_PHY_TIMING4_DO_CAL);
- break;
-- case TEMP_COMP_CAL:
-- ath_dbg(common, CALIBRATE,
-- "starting Temperature Compensation Calibration\n");
-- REG_SET_BIT(ah, AR_CH0_THERM, AR_CH0_THERM_LOCAL);
-- REG_SET_BIT(ah, AR_CH0_THERM, AR_CH0_THERM_START);
-- break;
- default:
- ath_err(common, "Invalid calibration type\n");
- break;
-@@ -93,8 +86,7 @@ static bool ar9003_hw_per_calibration(st
- /*
- * Accumulate cal measures for active chains
- */
-- if (cur_caldata->calCollect)
-- cur_caldata->calCollect(ah);
-+ cur_caldata->calCollect(ah);
- ah->cal_samples++;
-
- if (ah->cal_samples >= cur_caldata->calNumSamples) {
-@@ -107,8 +99,7 @@ static bool ar9003_hw_per_calibration(st
- /*
- * Process accumulated data
- */
-- if (cur_caldata->calPostProc)
-- cur_caldata->calPostProc(ah, numChains);
-+ cur_caldata->calPostProc(ah, numChains);
-
- /* Calibration has finished. */
- caldata->CalValid |= cur_caldata->calType;
-@@ -323,16 +314,9 @@ static const struct ath9k_percal_data iq
- ar9003_hw_iqcalibrate
- };
-
--static const struct ath9k_percal_data temp_cal_single_sample = {
-- TEMP_COMP_CAL,
-- MIN_CAL_SAMPLES,
-- PER_MAX_LOG_COUNT,
--};
--
- static void ar9003_hw_init_cal_settings(struct ath_hw *ah)
- {
- ah->iq_caldata.calData = &iq_cal_single_sample;
-- ah->temp_caldata.calData = &temp_cal_single_sample;
-
- if (AR_SREV_9300_20_OR_LATER(ah)) {
- ah->enabled_cals |= TX_IQ_CAL;
-@@ -340,7 +324,7 @@ static void ar9003_hw_init_cal_settings(
- ah->enabled_cals |= TX_IQ_ON_AGC_CAL;
- }
-
-- ah->supp_cals = IQ_MISMATCH_CAL | TEMP_COMP_CAL;
-+ ah->supp_cals = IQ_MISMATCH_CAL;
- }
-
- #define OFF_UPPER_LT 24
-@@ -1399,9 +1383,6 @@ static void ar9003_hw_init_cal_common(st
- INIT_CAL(&ah->iq_caldata);
- INSERT_CAL(ah, &ah->iq_caldata);
-
-- INIT_CAL(&ah->temp_caldata);
-- INSERT_CAL(ah, &ah->temp_caldata);
--
- /* Initialize current pointer to first element in list */
- ah->cal_list_curr = ah->cal_list;
-
---- a/drivers/net/wireless/ath/ath9k/hw.h
-+++ b/drivers/net/wireless/ath/ath9k/hw.h
-@@ -830,7 +830,6 @@ struct ath_hw {
- /* Calibration */
- u32 supp_cals;
- struct ath9k_cal_list iq_caldata;
-- struct ath9k_cal_list temp_caldata;
- struct ath9k_cal_list adcgain_caldata;
- struct ath9k_cal_list adcdc_caldata;
- struct ath9k_cal_list *cal_list;
--- /dev/null
+From: Stanislaw Gruszka <sgruszka@redhat.com>
+Date: Thu, 2 Feb 2017 10:57:40 +0100
+Subject: [PATCH] rt2x00: avoid introducing a USB dependency in the
+ rt2x00lib module
+
+As reported by Felix:
+
+Though protected by an ifdef, introducing an usb symbol dependency in
+the rt2x00lib module is a major inconvenience for distributions that
+package kernel modules split into individual packages.
+
+Get rid of this unnecessary dependency by calling the usb related
+function from a more suitable place.
+
+Cc: Vishal Thanki <vishalthanki@gmail.com>
+Reported-by: Felix Fietkau <nbd@nbd.name>
+Fixes: 8b4c0009313f ("rt2x00usb: Use usb anchor to manage URB")
+Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
+---
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+@@ -1436,21 +1436,6 @@ void rt2x00lib_remove_dev(struct rt2x00_
+ cancel_work_sync(&rt2x00dev->intf_work);
+ cancel_delayed_work_sync(&rt2x00dev->autowakeup_work);
+ cancel_work_sync(&rt2x00dev->sleep_work);
+-#if IS_ENABLED(CPTCFG_RT2X00_LIB_USB)
+- if (rt2x00_is_usb(rt2x00dev)) {
+- usb_kill_anchored_urbs(rt2x00dev->anchor);
+- hrtimer_cancel(&rt2x00dev->txstatus_timer);
+- cancel_work_sync(&rt2x00dev->rxdone_work);
+- cancel_work_sync(&rt2x00dev->txdone_work);
+- }
+-#endif
+- if (rt2x00dev->workqueue)
+- destroy_workqueue(rt2x00dev->workqueue);
+-
+- /*
+- * Free the tx status fifo.
+- */
+- kfifo_free(&rt2x00dev->txstatus_fifo);
+
+ /*
+ * Kill the tx status tasklet.
+@@ -1466,6 +1451,14 @@ void rt2x00lib_remove_dev(struct rt2x00_
+ */
+ rt2x00lib_uninitialize(rt2x00dev);
+
++ if (rt2x00dev->workqueue)
++ destroy_workqueue(rt2x00dev->workqueue);
++
++ /*
++ * Free the tx status fifo.
++ */
++ kfifo_free(&rt2x00dev->txstatus_fifo);
++
+ /*
+ * Free extra components
+ */
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
+@@ -744,6 +744,11 @@ void rt2x00usb_uninitialize(struct rt2x0
+ {
+ struct data_queue *queue;
+
++ usb_kill_anchored_urbs(rt2x00dev->anchor);
++ hrtimer_cancel(&rt2x00dev->txstatus_timer);
++ cancel_work_sync(&rt2x00dev->rxdone_work);
++ cancel_work_sync(&rt2x00dev->txdone_work);
++
+ queue_for_each(rt2x00dev, queue)
+ rt2x00usb_free_entries(queue);
+ }
--- /dev/null
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Mon, 30 Jan 2017 16:09:51 +0100
+Subject: [PATCH] brcmfmac: check brcmf_bus_get_memdump result for error
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This method may be unsupported (see: USB bus) or may just fail (see:
+SDIO bus).
+While at it rework logic in brcmf_sdio_bus_get_memdump function to avoid
+too many conditional code nesting levels.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
+@@ -32,16 +32,25 @@ static int brcmf_debug_create_memdump(st
+ {
+ void *dump;
+ size_t ramsize;
++ int err;
+
+ ramsize = brcmf_bus_get_ramsize(bus);
+- if (ramsize) {
+- dump = vzalloc(len + ramsize);
+- if (!dump)
+- return -ENOMEM;
+- memcpy(dump, data, len);
+- brcmf_bus_get_memdump(bus, dump + len, ramsize);
+- dev_coredumpv(bus->dev, dump, len + ramsize, GFP_KERNEL);
++ if (!ramsize)
++ return -ENOTSUPP;
++
++ dump = vzalloc(len + ramsize);
++ if (!dump)
++ return -ENOMEM;
++
++ memcpy(dump, data, len);
++ err = brcmf_bus_get_memdump(bus, dump + len, ramsize);
++ if (err) {
++ vfree(dump);
++ return err;
+ }
++
++ dev_coredumpv(bus->dev, dump, len + ramsize, GFP_KERNEL);
++
+ return 0;
+ }
+
+++ /dev/null
-From: Bob Copeland <me@bobcopeland.com>
-Date: Wed, 12 Oct 2016 08:24:54 -0400
-Subject: [PATCH] mac80211: fix up mismerge of ieee80211_tx_dequeue
-
-Looks like this spinlock wound up on the wrong side of the
-linearize, and I also lost the part that re-enters the loop.
-Fix up to match mac80211-next.
-
-Signed-off-by: Bob Copeland <me@bobcopeland.com>
----
-
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -3457,17 +3457,17 @@ begin:
- skb_queue_splice_tail(&tx.skbs, &txqi->frags);
- }
-
--out:
-- spin_unlock_bh(&fq->lock);
--
- if (skb && skb_has_frag_list(skb) &&
- !ieee80211_hw_check(&local->hw, TX_FRAG_LIST)) {
- if (skb_linearize(skb)) {
- ieee80211_free_txskb(&local->hw, skb);
-- return NULL;
-+ goto begin;
- }
- }
-
-+out:
-+ spin_unlock_bh(&fq->lock);
-+
- return skb;
- }
- EXPORT_SYMBOL(ieee80211_tx_dequeue);
--- /dev/null
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Mon, 30 Jan 2017 16:09:52 +0100
+Subject: [PATCH] brcmfmac: be more verbose when PSM's watchdog fires
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+It's important to inform user so he knows things went wrong. He may also
+want to get memory dump for further debugging purposes.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
+@@ -58,10 +58,18 @@ static int brcmf_debug_psm_watchdog_noti
+ const struct brcmf_event_msg *evtmsg,
+ void *data)
+ {
++ int err;
++
+ brcmf_dbg(TRACE, "enter: bsscfgidx=%d\n", ifp->bsscfgidx);
+
+- return brcmf_debug_create_memdump(ifp->drvr->bus_if, data,
+- evtmsg->datalen);
++ brcmf_err("PSM's watchdog has fired!\n");
++
++ err = brcmf_debug_create_memdump(ifp->drvr->bus_if, data,
++ evtmsg->datalen);
++ if (err)
++ brcmf_err("Failed to get memory dump, %d\n", err);
++
++ return err;
+ }
+
+ void brcmf_debugfs_init(void)
--- /dev/null
+From 0f83ff69735651cc7a3d150466a5257ff829b62b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Tue, 17 Jan 2017 23:35:50 +0100
+Subject: [PATCH] brcmfmac: use wiphy_read_of_freq_limits to respect limits
+ from DT
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This new helper reads extra frequency limits specified in DT and
+disables unavailable chanels. This is useful for devices (like home
+routers) with chipsets limited e.g. by board design.
+
+In order to respect info read from DT we simply need to check for
+IEEE80211_CHAN_DISABLED bit when constructing channel info.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -5908,6 +5908,9 @@ static int brcmf_construct_chaninfo(stru
+ continue;
+ }
+
++ if (channel->orig_flags & IEEE80211_CHAN_DISABLED)
++ continue;
++
+ /* assuming the chanspecs order is HT20,
+ * HT40 upper, HT40 lower, and VHT80.
+ */
+@@ -6509,6 +6512,9 @@ static int brcmf_setup_wiphy(struct wiph
+ wiphy->bands[NL80211_BAND_5GHZ] = band;
+ }
+ }
++
++ wiphy_read_of_freq_limits(wiphy);
++
+ return 0;
+ }
+
--- /dev/null
+From 9587a01a7ead9efc5032c16e0d9668de58be1186 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Thu, 2 Feb 2017 22:33:13 +0100
+Subject: [PATCH] brcmfmac: merge two brcmf_err macros into one
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This allows simplifying the code by adding a simple IS_ENABLED check for
+CONFIG_BRCMDB symbol.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
+@@ -45,20 +45,16 @@
+ #undef pr_fmt
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
++#ifndef CPTCFG_BRCM_TRACING
+ /* Macro for error messages. net_ratelimit() is used when driver
+ * debugging is not selected. When debugging the driver error
+ * messages are as important as other tracing or even more so.
+ */
+-#ifndef CPTCFG_BRCM_TRACING
+-#ifdef CPTCFG_BRCMDBG
+-#define brcmf_err(fmt, ...) pr_err("%s: " fmt, __func__, ##__VA_ARGS__)
+-#else
+ #define brcmf_err(fmt, ...) \
+ do { \
+- if (net_ratelimit()) \
++ if (IS_ENABLED(CPTCFG_BRCMDBG) || net_ratelimit()) \
+ pr_err("%s: " fmt, __func__, ##__VA_ARGS__); \
+ } while (0)
+-#endif
+ #else
+ __printf(2, 3)
+ void __brcmf_err(const char *func, const char *fmt, ...);
--- /dev/null
+From 087fa712a00685dac4bcc64b7c3dc8ae6bee8026 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Thu, 2 Feb 2017 22:33:14 +0100
+Subject: [PATCH] brcmfmac: switch to C function (__brcmf_err) for printing
+ errors
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This will allow extending code and using more detailed messages e.g.
+with the help of dev_err.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../net/wireless/broadcom/brcm80211/brcmfmac/common.c | 16 ++++++++++++++++
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h | 6 +++---
+ 2 files changed, 19 insertions(+), 3 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+@@ -218,6 +218,22 @@ done:
+ return err;
+ }
+
++#ifndef CPTCFG_BRCM_TRACING
++void __brcmf_err(const char *func, const char *fmt, ...)
++{
++ struct va_format vaf;
++ va_list args;
++
++ va_start(args, fmt);
++
++ vaf.fmt = fmt;
++ vaf.va = &args;
++ pr_err("%s: %pV", func, &vaf);
++
++ va_end(args);
++}
++#endif
++
+ #if defined(CPTCFG_BRCM_TRACING) || defined(CPTCFG_BRCMDBG)
+ void __brcmf_dbg(u32 level, const char *func, const char *fmt, ...)
+ {
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
+@@ -45,6 +45,8 @@
+ #undef pr_fmt
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
++__printf(2, 3)
++void __brcmf_err(const char *func, const char *fmt, ...);
+ #ifndef CPTCFG_BRCM_TRACING
+ /* Macro for error messages. net_ratelimit() is used when driver
+ * debugging is not selected. When debugging the driver error
+@@ -53,11 +55,9 @@
+ #define brcmf_err(fmt, ...) \
+ do { \
+ if (IS_ENABLED(CPTCFG_BRCMDBG) || net_ratelimit()) \
+- pr_err("%s: " fmt, __func__, ##__VA_ARGS__); \
++ __brcmf_err(__func__, fmt, ##__VA_ARGS__); \
+ } while (0)
+ #else
+-__printf(2, 3)
+-void __brcmf_err(const char *func, const char *fmt, ...);
+ #define brcmf_err(fmt, ...) \
+ __brcmf_err(__func__, fmt, ##__VA_ARGS__)
+ #endif
--- /dev/null
+From d0630555650a394cf5743268820511f527a561a5 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Thu, 2 Feb 2017 22:33:15 +0100
+Subject: [PATCH] brcmfmac: merge two remaining brcmf_err macros
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Now we always have __brcmf_err function we can do perfectly fine with
+just one macro.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h | 14 +++++---------
+ 1 file changed, 5 insertions(+), 9 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
+@@ -47,20 +47,16 @@
+
+ __printf(2, 3)
+ void __brcmf_err(const char *func, const char *fmt, ...);
+-#ifndef CPTCFG_BRCM_TRACING
+-/* Macro for error messages. net_ratelimit() is used when driver
+- * debugging is not selected. When debugging the driver error
+- * messages are as important as other tracing or even more so.
++/* Macro for error messages. When debugging / tracing the driver all error
++ * messages are important to us.
+ */
+ #define brcmf_err(fmt, ...) \
+ do { \
+- if (IS_ENABLED(CPTCFG_BRCMDBG) || net_ratelimit()) \
++ if (IS_ENABLED(CPTCFG_BRCMDBG) || \
++ IS_ENABLED(CPTCFG_BRCM_TRACING) || \
++ net_ratelimit()) \
+ __brcmf_err(__func__, fmt, ##__VA_ARGS__); \
+ } while (0)
+-#else
+-#define brcmf_err(fmt, ...) \
+- __brcmf_err(__func__, fmt, ##__VA_ARGS__)
+-#endif
+
+ #if defined(DEBUG) || defined(CPTCFG_BRCM_TRACING)
+ __printf(3, 4)
+++ /dev/null
-From: Michael Braun <michael-dev@fami-braun.de>
-Date: Sat, 15 Oct 2016 13:28:18 +0200
-Subject: [PATCH] mac80211: avoid extra memcpy in A-MSDU head creation
-
-Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
-Signed-off-by: Johannes Berg <johannes.berg@intel.com>
----
-
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -3069,11 +3069,11 @@ static bool ieee80211_amsdu_prepare_head
- struct ieee80211_local *local = sdata->local;
- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
- struct ieee80211_hdr *hdr;
-- struct ethhdr amsdu_hdr;
-+ struct ethhdr *amsdu_hdr;
- int hdr_len = fast_tx->hdr_len - sizeof(rfc1042_header);
- int subframe_len = skb->len - hdr_len;
- void *data;
-- u8 *qc;
-+ u8 *qc, *h_80211_src, *h_80211_dst;
-
- if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)
- return false;
-@@ -3081,19 +3081,22 @@ static bool ieee80211_amsdu_prepare_head
- if (info->control.flags & IEEE80211_TX_CTRL_AMSDU)
- return true;
-
-- if (!ieee80211_amsdu_realloc_pad(local, skb, sizeof(amsdu_hdr),
-+ if (!ieee80211_amsdu_realloc_pad(local, skb, sizeof(*amsdu_hdr),
- &subframe_len))
- return false;
-
-- amsdu_hdr.h_proto = cpu_to_be16(subframe_len);
-- memcpy(amsdu_hdr.h_source, skb->data + fast_tx->sa_offs, ETH_ALEN);
-- memcpy(amsdu_hdr.h_dest, skb->data + fast_tx->da_offs, ETH_ALEN);
-+ data = skb_push(skb, sizeof(*amsdu_hdr));
-+ memmove(data, data + sizeof(*amsdu_hdr), hdr_len);
-+ hdr = data;
-+ amsdu_hdr = data + hdr_len;
-+ /* h_80211_src/dst is addr* field within hdr */
-+ h_80211_src = data + fast_tx->sa_offs;
-+ h_80211_dst = data + fast_tx->da_offs;
-
-- data = skb_push(skb, sizeof(amsdu_hdr));
-- memmove(data, data + sizeof(amsdu_hdr), hdr_len);
-- memcpy(data + hdr_len, &amsdu_hdr, sizeof(amsdu_hdr));
-+ amsdu_hdr->h_proto = cpu_to_be16(subframe_len);
-+ ether_addr_copy(amsdu_hdr->h_source, h_80211_src);
-+ ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst);
-
-- hdr = data;
- qc = ieee80211_get_qos_ctl(hdr);
- *qc |= IEEE80211_QOS_CTL_A_MSDU_PRESENT;
-
--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Sun, 12 Feb 2017 13:13:05 +0100
+Subject: [PATCH] ath9k: clean up and fix ath_tx_count_airtime
+
+ath_tx_count_airtime is doing a lot of unnecessary work:
+
+- Redundant station lookup
+- Redundant rcu_read_lock/unlock
+- Useless memcpy of bf->rates
+- Useless NULL check of bf->bf_mpdu
+- Redundant lookup of the skb tid
+
+Additionally, it tries to look up the mac80211 queue index from the txq,
+which fails if the frame was delivered via the power save queue.
+
+This patch fixes all of these issues by passing down the right set of
+pointers instead of doing extra work
+
+Cc: stable@vger.kernel.org
+Fixes: 63fefa050477 ("ath9k: Introduce airtime fairness scheduling between stations")
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/drivers/net/wireless/ath/ath9k/xmit.c
++++ b/drivers/net/wireless/ath/ath9k/xmit.c
+@@ -723,51 +723,31 @@ static bool bf_is_ampdu_not_probing(stru
+ return bf_isampdu(bf) && !(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE);
+ }
+
+-static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_txq *txq,
+- struct ath_buf *bf, struct ath_tx_status *ts)
++static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_node *an,
++ struct ath_atx_tid *tid, struct ath_buf *bf,
++ struct ath_tx_status *ts)
+ {
+- struct ath_node *an;
+- struct ath_acq *acq = &sc->cur_chan->acq[txq->mac80211_qnum];
+- struct sk_buff *skb;
+- struct ieee80211_hdr *hdr;
+- struct ieee80211_hw *hw = sc->hw;
+- struct ieee80211_tx_rate rates[4];
+- struct ieee80211_sta *sta;
+- int i;
++ struct ath_txq *txq = tid->txq;
+ u32 airtime = 0;
+-
+- skb = bf->bf_mpdu;
+- if(!skb)
+- return;
+-
+- hdr = (struct ieee80211_hdr *)skb->data;
+- memcpy(rates, bf->rates, sizeof(rates));
+-
+- rcu_read_lock();
+-
+- sta = ieee80211_find_sta_by_ifaddr(hw, hdr->addr1, hdr->addr2);
+- if(!sta)
+- goto exit;
+-
+-
+- an = (struct ath_node *) sta->drv_priv;
++ int i;
+
+ airtime += ts->duration * (ts->ts_longretry + 1);
++ for(i = 0; i < ts->ts_rateindex; i++) {
++ int rate_dur = ath9k_hw_get_duration(sc->sc_ah, bf->bf_desc, i);
++ airtime += rate_dur * bf->rates[i].count;
++ }
+
+- for(i=0; i < ts->ts_rateindex; i++)
+- airtime += ath9k_hw_get_duration(sc->sc_ah, bf->bf_desc, i) * rates[i].count;
++ if (sc->airtime_flags & AIRTIME_USE_TX) {
++ int q = txq->mac80211_qnum;
++ struct ath_acq *acq = &sc->cur_chan->acq[q];
+
+- if (!!(sc->airtime_flags & AIRTIME_USE_TX)) {
+ spin_lock_bh(&acq->lock);
+- an->airtime_deficit[txq->mac80211_qnum] -= airtime;
+- if (an->airtime_deficit[txq->mac80211_qnum] <= 0)
+- __ath_tx_queue_tid(sc, ath_get_skb_tid(sc, an, skb));
++ an->airtime_deficit[q] -= airtime;
++ if (an->airtime_deficit[q] <= 0)
++ __ath_tx_queue_tid(sc, tid);
+ spin_unlock_bh(&acq->lock);
+ }
+ ath_debug_airtime(sc, an, 0, airtime);
+-
+-exit:
+- rcu_read_unlock();
+ }
+
+ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
+@@ -791,13 +771,13 @@ static void ath_tx_process_buffer(struct
+
+ ts->duration = ath9k_hw_get_duration(sc->sc_ah, bf->bf_desc,
+ ts->ts_rateindex);
+- ath_tx_count_airtime(sc, txq, bf, ts);
+
+ hdr = (struct ieee80211_hdr *) bf->bf_mpdu->data;
+ sta = ieee80211_find_sta_by_ifaddr(hw, hdr->addr1, hdr->addr2);
+ if (sta) {
+ struct ath_node *an = (struct ath_node *)sta->drv_priv;
+ tid = ath_get_skb_tid(sc, an, bf->bf_mpdu);
++ ath_tx_count_airtime(sc, an, tid, bf, ts);
+ if (ts->ts_status & (ATH9K_TXERR_FILT | ATH9K_TXERR_XRETRY))
+ tid->clear_ps_filter = true;
+ }
+++ /dev/null
-From: Michael Braun <michael-dev@fami-braun.de>
-Date: Sat, 15 Oct 2016 13:28:19 +0200
-Subject: [PATCH] mac80211: fix A-MSDU outer SA/DA
-
-According to IEEE 802.11-2012 section 8.3.2 table 8-19, the outer SA/DA
-of A-MSDU frames need to be changed depending on FromDS/ToDS values.
-
-Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
-[use ether_addr_copy and add alignment annotations]
-Signed-off-by: Johannes Berg <johannes.berg@intel.com>
----
-
---- a/include/net/mac80211.h
-+++ b/include/net/mac80211.h
-@@ -1438,7 +1438,7 @@ enum ieee80211_vif_flags {
- struct ieee80211_vif {
- enum nl80211_iftype type;
- struct ieee80211_bss_conf bss_conf;
-- u8 addr[ETH_ALEN];
-+ u8 addr[ETH_ALEN] __aligned(2);
- bool p2p;
- bool csa_active;
- bool mu_mimo_owner;
---- a/net/mac80211/ieee80211_i.h
-+++ b/net/mac80211/ieee80211_i.h
-@@ -443,7 +443,7 @@ struct ieee80211_if_managed {
- struct ieee80211_mgd_auth_data *auth_data;
- struct ieee80211_mgd_assoc_data *assoc_data;
-
-- u8 bssid[ETH_ALEN];
-+ u8 bssid[ETH_ALEN] __aligned(2);
-
- u16 aid;
-
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -3074,6 +3074,7 @@ static bool ieee80211_amsdu_prepare_head
- int subframe_len = skb->len - hdr_len;
- void *data;
- u8 *qc, *h_80211_src, *h_80211_dst;
-+ const u8 *bssid;
-
- if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)
- return false;
-@@ -3097,6 +3098,28 @@ static bool ieee80211_amsdu_prepare_head
- ether_addr_copy(amsdu_hdr->h_source, h_80211_src);
- ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst);
-
-+ /* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer SA/DA
-+ * fields needs to be changed to BSSID for A-MSDU frames depending
-+ * on FromDS/ToDS values.
-+ */
-+ switch (sdata->vif.type) {
-+ case NL80211_IFTYPE_STATION:
-+ bssid = sdata->u.mgd.bssid;
-+ break;
-+ case NL80211_IFTYPE_AP:
-+ case NL80211_IFTYPE_AP_VLAN:
-+ bssid = sdata->vif.addr;
-+ break;
-+ default:
-+ bssid = NULL;
-+ }
-+
-+ if (bssid && ieee80211_has_fromds(hdr->frame_control))
-+ ether_addr_copy(h_80211_src, bssid);
-+
-+ if (bssid && ieee80211_has_tods(hdr->frame_control))
-+ ether_addr_copy(h_80211_dst, bssid);
-+
- qc = ieee80211_get_qos_ctl(hdr);
- *qc |= IEEE80211_QOS_CTL_A_MSDU_PRESENT;
-
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Thu, 3 Nov 2016 12:10:34 +0100
-Subject: [PATCH] Revert "mac80211: allow using AP_LINK_PS with
- mac80211-generated TIM IE"
-
-This reverts commit c68df2e7be0c1238ea3c281fd744a204ef3b15a0.
-
-__sta_info_recalc_tim turns into a no-op if local->ops->set_tim is not
-set. This prevents the beacon TIM bit from being set for all drivers
-that do not implement this op (almost all of them), thus thoroughly
-essential AP mode powersave functionality.
-
-Cc: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
-Fixes: c68df2e7be0c ("mac80211: allow using AP_LINK_PS with mac80211-generated TIM IE")
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/sta_info.c
-+++ b/net/mac80211/sta_info.c
-@@ -688,7 +688,7 @@ static void __sta_info_recalc_tim(struct
- }
-
- /* No need to do anything if the driver does all */
-- if (!local->ops->set_tim)
-+ if (ieee80211_hw_check(&local->hw, AP_LINK_PS))
- return;
-
- if (sta->dead)
--- /dev/null
+From: Koen Vandeputte <koen.vandeputte@ncentric.com>
+Date: Wed, 8 Feb 2017 15:29:45 +0100
+Subject: [PATCH] mac80211: fix CSA in IBSS mode
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Add the missing IBSS capability flag during capability init as it needs
+to be inserted into the generated beacon in order for CSA to work.
+
+Signed-off-by: Piotr Gawlowicz <gawlowicz@tkn.tu-berlin.de>
+Signed-off-by: Mikołaj Chwalisz <chwalisz@tkn.tu-berlin.de>
+Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
+---
+
+--- a/net/mac80211/ibss.c
++++ b/net/mac80211/ibss.c
+@@ -487,14 +487,14 @@ int ieee80211_ibss_csa_beacon(struct iee
+ struct beacon_data *presp, *old_presp;
+ struct cfg80211_bss *cbss;
+ const struct cfg80211_bss_ies *ies;
+- u16 capability = 0;
++ u16 capability = WLAN_CAPABILITY_IBSS;
+ u64 tsf;
+ int ret = 0;
+
+ sdata_assert_lock(sdata);
+
+ if (ifibss->privacy)
+- capability = WLAN_CAPABILITY_PRIVACY;
++ capability |= WLAN_CAPABILITY_PRIVACY;
+
+ cbss = cfg80211_get_bss(sdata->local->hw.wiphy, ifibss->chandef.chan,
+ ifibss->bssid, ifibss->ssid,
--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Wed, 22 Feb 2017 16:13:17 +0100
+Subject: [PATCH] mac80211: don't handle filtered frames within a BA session
+
+When running a BA session, the driver (or the hardware) already takes
+care of retransmitting failed frames, since it has to keep the receiver
+reorder window in sync.
+
+Adding another layer of retransmit around that does not improve
+anything. In fact, it can only lead to some strong reordering with huge
+latency.
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/net/mac80211/status.c
++++ b/net/mac80211/status.c
+@@ -51,7 +51,8 @@ static void ieee80211_handle_filtered_fr
+ struct ieee80211_hdr *hdr = (void *)skb->data;
+ int ac;
+
+- if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER) {
++ if (info->flags & (IEEE80211_TX_CTL_NO_PS_BUFFER |
++ IEEE80211_TX_CTL_AMPDU)) {
+ ieee80211_free_txskb(&local->hw, skb);
+ return;
+ }
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Fri, 4 Nov 2016 10:13:34 +0100
-Subject: [PATCH] mac80211: update A-MPDU flag on tx dequeue
-
-The sequence number counter is used to derive the starting sequence
-number. Since that counter is updated on tx dequeue, the A-MPDU flag
-needs to be up to date at the tme of dequeue as well.
-
-This patch prevents sending more A-MPDU frames after the session has
-been terminated and also ensures that aggregation starts right after the
-session has been established
-
-Fixes: bb42f2d13ffc ("mac80211: Move reorder-sensitive TX handlers to after TXQ dequeue")
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -3462,6 +3462,11 @@ begin:
- goto begin;
- }
-
-+ if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags))
-+ info->flags |= IEEE80211_TX_CTL_AMPDU;
-+ else
-+ info->flags &= ~IEEE80211_TX_CTL_AMPDU;
-+
- if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) {
- struct sta_info *sta = container_of(txq->sta, struct sta_info,
- sta);
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Fri, 4 Nov 2016 10:17:38 +0100
-Subject: [PATCH] mac80211: remove bogus skb vif assignment
-
-The call to ieee80211_txq_enqueue overwrites the vif pointer with the
-codel enqueue time, so setting it just before that call makes no sense.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -1500,7 +1500,6 @@ static bool ieee80211_queue_skb(struct i
- struct sta_info *sta,
- struct sk_buff *skb)
- {
-- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
- struct fq *fq = &local->fq;
- struct ieee80211_vif *vif;
- struct txq_info *txqi;
-@@ -1525,8 +1524,6 @@ static bool ieee80211_queue_skb(struct i
- if (!txqi)
- return false;
-
-- info->control.vif = vif;
--
- spin_lock_bh(&fq->lock);
- ieee80211_txq_enqueue(local, txqi, skb);
- spin_unlock_bh(&fq->lock);
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Fri, 4 Nov 2016 10:18:51 +0100
-Subject: [PATCH] mac80211: fix A-MSDU aggregation with fast-xmit + txq
-
-A-MSDU aggregation alters the QoS header after a frame has been
-enqueued, so it needs to be ready before enqueue and not overwritten
-again afterwards
-
-Fixes: bb42f2d13ffc ("mac80211: Move reorder-sensitive TX handlers to after TXQ dequeue")
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -3245,7 +3245,6 @@ static void ieee80211_xmit_fast_finish(s
-
- if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
- tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
-- *ieee80211_get_qos_ctl(hdr) = tid;
- hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid);
- } else {
- info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;
-@@ -3370,6 +3369,11 @@ static bool ieee80211_xmit_fast(struct i
- (tid_tx ? IEEE80211_TX_CTL_AMPDU : 0);
- info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT;
-
-+ if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
-+ tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
-+ *ieee80211_get_qos_ctl(hdr) = tid;
-+ }
-+
- __skb_queue_head_init(&tx.skbs);
-
- tx.flags = IEEE80211_TX_UNICAST;
+++ /dev/null
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Tue, 15 Nov 2016 16:08:29 +0100
-Subject: [PATCH] ath9k: fix ath9k_hw_gpio_get() to return 0 or 1 on success
-
-Commit b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and
-SOC") refactored ath9k_hw_gpio_get() to support both WMAC and SOC GPIOs,
-changing the return on success from 1 to BIT(gpio). This broke some callers
-like ath_is_rfkill_set().
-
-Instead of fixing all callers, change ath9k_hw_gpio_get() back to only
-return 0 or 1.
-
-Fixes: b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and SOC")
-Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
----
- drivers/net/wireless/ath/ath9k/hw.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/drivers/net/wireless/ath/ath9k/hw.c
-+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -2813,7 +2813,7 @@ u32 ath9k_hw_gpio_get(struct ath_hw *ah,
- WARN_ON(1);
- }
-
-- return val;
-+ return !!val;
- }
- EXPORT_SYMBOL(ath9k_hw_gpio_get);
-
+++ /dev/null
-From b263e0bb9d4585ca3ec04d7257ca5308d21333bb Mon Sep 17 00:00:00 2001
-From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-Date: Sun, 16 Oct 2016 22:59:05 +0200
-Subject: [PATCH 1/3] Documentation: dt: net: add ath9k wireless device binding
-
-Add documentation how devicetree can be used to configure ath9k based
-devices.
-
-Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-Acked-by: Rob Herring <robh@kernel.org>
-Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
----
- .../devicetree/bindings/net/wireless/qca,ath9k.txt | 48 ++++++++++++++++++++++
- 1 file changed, 48 insertions(+)
- create mode 100644 Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt
-
---- /dev/null
-+++ b/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt
-@@ -0,0 +1,48 @@
-+* Qualcomm Atheros ath9k wireless devices
-+
-+This node provides properties for configuring the ath9k wireless device. The
-+node is expected to be specified as a child node of the PCI controller to
-+which the wireless chip is connected.
-+
-+Required properties:
-+- compatible: For PCI and PCIe devices this should be an identifier following
-+ the format as defined in "PCI Bus Binding to Open Firmware"
-+ Revision 2.1. One of the possible formats is "pciVVVV,DDDD"
-+ where VVVV is the PCI vendor ID and DDDD is PCI device ID.
-+ Typically QCA's PCI vendor ID 168c is used while the PCI device
-+ ID depends on the chipset - see the following (possibly
-+ incomplete) list:
-+ - 0023 for AR5416
-+ - 0024 for AR5418
-+ - 0027 for AR9160
-+ - 0029 for AR9220 and AR9223
-+ - 002a for AR9280 and AR9283
-+ - 002b for AR9285
-+ - 002c for AR2427
-+ - 002d for AR9227
-+ - 002e for AR9287
-+ - 0030 for AR9380, AR9381 and AR9382
-+ - 0032 for AR9485
-+ - 0033 for AR9580 and AR9590
-+ - 0034 for AR9462
-+ - 0036 for AR9565
-+ - 0037 for AR9485
-+- reg: Address and length of the register set for the device.
-+
-+Optional properties:
-+- qca,no-eeprom: Indicates that there is no physical EEPROM connected to the
-+ ath9k wireless chip (in this case the calibration /
-+ EEPROM data will be loaded from userspace using the
-+ kernel firmware loader).
-+- mac-address: See ethernet.txt in the parent directory
-+- local-mac-address: See ethernet.txt in the parent directory
-+
-+
-+In this example, the node is defined as child node of the PCI controller:
-+&pci0 {
-+ wifi@168c,002d {
-+ compatible = "pci168c,002d";
-+ reg = <0x7000 0 0 0 0x1000>;
-+ qca,no-eeprom;
-+ };
-+};
+++ /dev/null
-From 25b8b2d57def4854558c135228a52326a7d346ad Mon Sep 17 00:00:00 2001
-From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-Date: Sun, 16 Oct 2016 22:59:06 +0200
-Subject: [PATCH 2/3] ath9k: add a helper to get the string representation of
- ath_bus_type
-
-This can be used when the ath_bus_type has to be presented in a log
-message or firmware filename.
-
-Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
----
- drivers/net/wireless/ath/ath.h | 6 ++++++
- drivers/net/wireless/ath/main.c | 7 +++++++
- 2 files changed, 13 insertions(+)
-
---- a/drivers/net/wireless/ath/ath.h
-+++ b/drivers/net/wireless/ath/ath.h
-@@ -327,4 +327,10 @@ static inline const char *ath_opmode_to_
- }
- #endif
-
-+extern const char *ath_bus_type_strings[];
-+static inline const char *ath_bus_type_to_string(enum ath_bus_type bustype)
-+{
-+ return ath_bus_type_strings[bustype];
-+}
-+
- #endif /* ATH_H */
---- a/drivers/net/wireless/ath/main.c
-+++ b/drivers/net/wireless/ath/main.c
-@@ -90,3 +90,10 @@ void ath_printk(const char *level, const
- va_end(args);
- }
- EXPORT_SYMBOL(ath_printk);
-+
-+const char *ath_bus_type_strings[] = {
-+ [ATH_PCI] = "pci",
-+ [ATH_AHB] = "ahb",
-+ [ATH_USB] = "usb",
-+};
-+EXPORT_SYMBOL(ath_bus_type_strings);
+++ /dev/null
-From cea03be5a848823cb8052e2e7b93cb2249d5f60c Mon Sep 17 00:00:00 2001
-From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-Date: Sun, 16 Oct 2016 22:59:07 +0200
-Subject: [PATCH 3/3] ath9k: parse the device configuration from an OF node
-
-This allows setting the MAC address and specifying that the firmware
-will be requested from userspace (because there might not be a hardware
-EEPROM connected to the chip) for ath9k based PCI devices using
-the device tree.
-
-There is some out-of-tree code to "convert devicetree to
-ath9k_platform_data" (for example in OpenWrt and LEDE) which becomes
-obsolete with this patch.
-
-Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
----
- drivers/net/wireless/ath/ath9k/init.c | 42 +++++++++++++++++++++++++++++++++++
- 1 file changed, 42 insertions(+)
-
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -20,6 +20,8 @@
- #include <linux/slab.h>
- #include <linux/ath9k_platform.h>
- #include <linux/module.h>
-+#include <linux/of.h>
-+#include <linux/of_net.h>
- #include <linux/relay.h>
- #include <net/ieee80211_radiotap.h>
-
-@@ -554,6 +556,42 @@ static int ath9k_init_platform(struct at
- return 0;
- }
-
-+static int ath9k_of_init(struct ath_softc *sc)
-+{
-+ struct device_node *np = sc->dev->of_node;
-+ struct ath_hw *ah = sc->sc_ah;
-+ struct ath_common *common = ath9k_hw_common(ah);
-+ enum ath_bus_type bus_type = common->bus_ops->ath_bus_type;
-+ const char *mac;
-+ char eeprom_name[100];
-+ int ret;
-+
-+ if (!of_device_is_available(np))
-+ return 0;
-+
-+ ath_dbg(common, CONFIG, "parsing configuration from OF node\n");
-+
-+ if (of_property_read_bool(np, "qca,no-eeprom")) {
-+ /* ath9k-eeprom-<bus>-<id>.bin */
-+ scnprintf(eeprom_name, sizeof(eeprom_name),
-+ "ath9k-eeprom-%s-%s.bin",
-+ ath_bus_type_to_string(bus_type), dev_name(ah->dev));
-+
-+ ret = ath9k_eeprom_request(sc, eeprom_name);
-+ if (ret)
-+ return ret;
-+ }
-+
-+ mac = of_get_mac_address(np);
-+ if (mac)
-+ ether_addr_copy(common->macaddr, mac);
-+
-+ ah->ah_flags &= ~AH_USE_EEPROM;
-+ ah->ah_flags |= AH_NO_EEP_SWAP;
-+
-+ return 0;
-+}
-+
- static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
- const struct ath_bus_ops *bus_ops)
- {
-@@ -610,6 +648,10 @@ static int ath9k_init_softc(u16 devid, s
- if (ret)
- return ret;
-
-+ ret = ath9k_of_init(sc);
-+ if (ret)
-+ return ret;
-+
- if (ath9k_led_active_high != -1)
- ah->config.led_active_high = ath9k_led_active_high == 1;
-
+++ /dev/null
-From: Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de>
-Date: Mon, 12 Dec 2016 19:50:01 +0100
-Subject: [PATCH] ath9k: unlock rcu read when returning early
-
-Starting with ath9k: use ieee80211_tx_status_noskb where possible
-[d94a461d7a7df68991fb9663531173f60ef89c68] the driver uses rcu_read_lock() &&
-rcu_read_unlock() yet on returning early in ath_tx_edma_tasklet() the unlock is
-missing leading to stalls and suspicious RCU usage:
-
- ===============================
- [ INFO: suspicious RCU usage. ]
- 4.9.0-rc8 #11 Not tainted
- -------------------------------
- kernel/rcu/tree.c:705 Illegal idle entry in RCU read-side critical section.!
-
- other info that might help us debug this:
-
- RCU used illegally from idle CPU!
- rcu_scheduler_active = 1, debug_locks = 0
- RCU used illegally from extended quiescent state!
- 1 lock held by swapper/7/0:
- #0:
- (
- rcu_read_lock
- ){......}
- , at:
- [<ffffffffa06ed110>] ath_tx_edma_tasklet+0x0/0x450 [ath9k]
-
- stack backtrace:
- CPU: 7 PID: 0 Comm: swapper/7 Not tainted 4.9.0-rc8 #11
- Hardware name: Acer Aspire V3-571G/VA50_HC_CR, BIOS V2.21 12/16/2013
- ffff88025efc3f38 ffffffff8132b1e5 ffff88017ede4540 0000000000000001
- ffff88025efc3f68 ffffffff810a25f7 ffff88025efcee60 ffff88017edebdd8
- ffff88025eeb5400 0000000000000091 ffff88025efc3f88 ffffffff810c3cd4
- Call Trace:
- <IRQ>
- [<ffffffff8132b1e5>] dump_stack+0x68/0x93
- [<ffffffff810a25f7>] lockdep_rcu_suspicious+0xd7/0x110
- [<ffffffff810c3cd4>] rcu_eqs_enter_common.constprop.85+0x154/0x200
- [<ffffffff810c5a54>] rcu_irq_exit+0x44/0xa0
- [<ffffffff81058631>] irq_exit+0x61/0xd0
- [<ffffffff81018d25>] do_IRQ+0x65/0x110
- [<ffffffff81672189>] common_interrupt+0x89/0x89
- <EOI>
- [<ffffffff814ffe11>] ? cpuidle_enter_state+0x151/0x200
- [<ffffffff814ffee2>] cpuidle_enter+0x12/0x20
- [<ffffffff8109a6ae>] call_cpuidle+0x1e/0x40
- [<ffffffff8109a8f6>] cpu_startup_entry+0x146/0x220
- [<ffffffff810336f8>] start_secondary+0x148/0x170
-
-Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de>
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -2757,7 +2757,7 @@ void ath_tx_edma_tasklet(struct ath_soft
- fifo_list = &txq->txq_fifo[txq->txq_tailidx];
- if (list_empty(fifo_list)) {
- ath_txq_unlock(sc, txq);
-- return;
-+ break;
- }
-
- bf = list_first_entry(fifo_list, struct ath_buf, list);
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Wed, 14 Dec 2016 19:33:23 +0100
-Subject: [PATCH] mac80211: minstrel_ht: move supported bitrate mask out of
- group data
-
-Improves dcache footprint by ensuring that fewer cache lines need to be
-touched.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/rc80211_minstrel_ht.c
-+++ b/net/mac80211/rc80211_minstrel_ht.c
-@@ -301,7 +301,7 @@ minstrel_ht_get_stats(struct minstrel_pr
- break;
-
- /* short preamble */
-- if (!(mi->groups[group].supported & BIT(idx)))
-+ if (!(mi->supported[group] & BIT(idx)))
- idx += 4;
- }
- return &mi->groups[group].rates[idx];
-@@ -486,7 +486,7 @@ minstrel_ht_prob_rate_reduce_streams(str
- MCS_GROUP_RATES].streams;
- for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
- mg = &mi->groups[group];
-- if (!mg->supported || group == MINSTREL_CCK_GROUP)
-+ if (!mi->supported[group] || group == MINSTREL_CCK_GROUP)
- continue;
-
- tmp_idx = mg->max_group_prob_rate % MCS_GROUP_RATES;
-@@ -540,7 +540,7 @@ minstrel_ht_update_stats(struct minstrel
- for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
-
- mg = &mi->groups[group];
-- if (!mg->supported)
-+ if (!mi->supported[group])
- continue;
-
- mi->sample_count++;
-@@ -550,7 +550,7 @@ minstrel_ht_update_stats(struct minstrel
- tmp_group_tp_rate[j] = group;
-
- for (i = 0; i < MCS_GROUP_RATES; i++) {
-- if (!(mg->supported & BIT(i)))
-+ if (!(mi->supported[group] & BIT(i)))
- continue;
-
- index = MCS_GROUP_RATES * group + i;
-@@ -636,7 +636,7 @@ minstrel_set_next_sample_idx(struct mins
- mi->sample_group %= ARRAY_SIZE(minstrel_mcs_groups);
- mg = &mi->groups[mi->sample_group];
-
-- if (!mg->supported)
-+ if (!mi->supported[mi->sample_group])
- continue;
-
- if (++mg->index >= MCS_GROUP_RATES) {
-@@ -657,7 +657,7 @@ minstrel_downgrade_rate(struct minstrel_
- while (group > 0) {
- group--;
-
-- if (!mi->groups[group].supported)
-+ if (!mi->supported[group])
- continue;
-
- if (minstrel_mcs_groups[group].streams >
-@@ -994,7 +994,7 @@ minstrel_get_sample_rate(struct minstrel
- sample_idx = sample_table[mg->column][mg->index];
- minstrel_set_next_sample_idx(mi);
-
-- if (!(mg->supported & BIT(sample_idx)))
-+ if (!(mi->supported[sample_group] & BIT(sample_idx)))
- return -1;
-
- mrs = &mg->rates[sample_idx];
-@@ -1052,7 +1052,7 @@ static void
- minstrel_ht_check_cck_shortpreamble(struct minstrel_priv *mp,
- struct minstrel_ht_sta *mi, bool val)
- {
-- u8 supported = mi->groups[MINSTREL_CCK_GROUP].supported;
-+ u8 supported = mi->supported[MINSTREL_CCK_GROUP];
-
- if (!supported || !mi->cck_supported_short)
- return;
-@@ -1061,7 +1061,7 @@ minstrel_ht_check_cck_shortpreamble(stru
- return;
-
- supported ^= mi->cck_supported_short | (mi->cck_supported_short << 4);
-- mi->groups[MINSTREL_CCK_GROUP].supported = supported;
-+ mi->supported[MINSTREL_CCK_GROUP] = supported;
- }
-
- static void
-@@ -1154,7 +1154,7 @@ minstrel_ht_update_cck(struct minstrel_p
- mi->cck_supported_short |= BIT(i);
- }
-
-- mi->groups[MINSTREL_CCK_GROUP].supported = mi->cck_supported;
-+ mi->supported[MINSTREL_CCK_GROUP] = mi->cck_supported;
- }
-
- static void
-@@ -1233,7 +1233,7 @@ minstrel_ht_update_caps(void *priv, stru
- u32 gflags = minstrel_mcs_groups[i].flags;
- int bw, nss;
-
-- mi->groups[i].supported = 0;
-+ mi->supported[i] = 0;
- if (i == MINSTREL_CCK_GROUP) {
- minstrel_ht_update_cck(mp, mi, sband, sta);
- continue;
-@@ -1265,8 +1265,8 @@ minstrel_ht_update_caps(void *priv, stru
- if (use_vht && minstrel_vht_only)
- continue;
- #endif
-- mi->groups[i].supported = mcs->rx_mask[nss - 1];
-- if (mi->groups[i].supported)
-+ mi->supported[i] = mcs->rx_mask[nss - 1];
-+ if (mi->supported[i])
- n_supported++;
- continue;
- }
-@@ -1292,10 +1292,10 @@ minstrel_ht_update_caps(void *priv, stru
- else
- bw = BW_20;
-
-- mi->groups[i].supported = minstrel_get_valid_vht_rates(bw, nss,
-+ mi->supported[i] = minstrel_get_valid_vht_rates(bw, nss,
- vht_cap->vht_mcs.tx_mcs_map);
-
-- if (mi->groups[i].supported)
-+ if (mi->supported[i])
- n_supported++;
- }
-
---- a/net/mac80211/rc80211_minstrel_ht.h
-+++ b/net/mac80211/rc80211_minstrel_ht.h
-@@ -52,9 +52,6 @@ struct minstrel_mcs_group_data {
- u8 index;
- u8 column;
-
-- /* bitfield of supported MCS rates of this group */
-- u16 supported;
--
- /* sorted rate set within a MCS group*/
- u16 max_group_tp_rate[MAX_THR_RATES];
- u16 max_group_prob_rate;
-@@ -101,6 +98,9 @@ struct minstrel_ht_sta {
- u8 cck_supported;
- u8 cck_supported_short;
-
-+ /* Bitfield of supported MCS rates of all groups */
-+ u16 supported[MINSTREL_GROUPS_NB];
-+
- /* MCS rate group info and statistics */
- struct minstrel_mcs_group_data groups[MINSTREL_GROUPS_NB];
- };
---- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
-+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
-@@ -24,7 +24,7 @@ minstrel_ht_stats_dump(struct minstrel_h
- char gimode = 'L';
- u32 gflags;
-
-- if (!mi->groups[i].supported)
-+ if (!mi->supported[i])
- return p;
-
- mg = &minstrel_mcs_groups[i];
-@@ -42,7 +42,7 @@ minstrel_ht_stats_dump(struct minstrel_h
- static const int bitrates[4] = { 10, 20, 55, 110 };
- int idx = i * MCS_GROUP_RATES + j;
-
-- if (!(mi->groups[i].supported & BIT(j)))
-+ if (!(mi->supported[i] & BIT(j)))
- continue;
-
- if (gflags & IEEE80211_TX_RC_MCS) {
-@@ -170,7 +170,7 @@ minstrel_ht_stats_csv_dump(struct minstr
- char gimode = 'L';
- u32 gflags;
-
-- if (!mi->groups[i].supported)
-+ if (!mi->supported[i])
- return p;
-
- mg = &minstrel_mcs_groups[i];
-@@ -188,7 +188,7 @@ minstrel_ht_stats_csv_dump(struct minstr
- static const int bitrates[4] = { 10, 20, 55, 110 };
- int idx = i * MCS_GROUP_RATES + j;
-
-- if (!(mi->groups[i].supported & BIT(j)))
-+ if (!(mi->supported[i] & BIT(j)))
- continue;
-
- if (gflags & IEEE80211_TX_RC_MCS) {
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Wed, 14 Dec 2016 20:06:08 +0100
-Subject: [PATCH] mac80211: minstrel_ht: move short preamble check out of
- get_rate
-
-Test short preamble support in minstrel_ht_update_caps instead of
-looking at the per-packet flag. Makes the code more efficient.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/rc80211_minstrel_ht.c
-+++ b/net/mac80211/rc80211_minstrel_ht.c
-@@ -14,6 +14,7 @@
- #include <linux/ieee80211.h>
- #include <net/mac80211.h>
- #include "rate.h"
-+#include "sta_info.h"
- #include "rc80211_minstrel.h"
- #include "rc80211_minstrel_ht.h"
-
-@@ -1049,22 +1050,6 @@ minstrel_get_sample_rate(struct minstrel
- }
-
- static void
--minstrel_ht_check_cck_shortpreamble(struct minstrel_priv *mp,
-- struct minstrel_ht_sta *mi, bool val)
--{
-- u8 supported = mi->supported[MINSTREL_CCK_GROUP];
--
-- if (!supported || !mi->cck_supported_short)
-- return;
--
-- if (supported & (mi->cck_supported_short << (val * 4)))
-- return;
--
-- supported ^= mi->cck_supported_short | (mi->cck_supported_short << 4);
-- mi->supported[MINSTREL_CCK_GROUP] = supported;
--}
--
--static void
- minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
- struct ieee80211_tx_rate_control *txrc)
- {
-@@ -1087,7 +1072,6 @@ minstrel_ht_get_rate(void *priv, struct
- minstrel_aggr_check(sta, txrc->skb);
-
- info->flags |= mi->tx_flags;
-- minstrel_ht_check_cck_shortpreamble(mp, mi, txrc->short_preamble);
-
- #ifdef CPTCFG_MAC80211_DEBUGFS
- if (mp->fixed_rate_idx != -1)
-@@ -1168,6 +1152,7 @@ minstrel_ht_update_caps(void *priv, stru
- struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs;
- u16 ht_cap = sta->ht_cap.cap;
- struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
-+ struct sta_info *sinfo = container_of(sta, struct sta_info, sta);
- int use_vht;
- int n_supported = 0;
- int ack_dur;
-@@ -1302,6 +1287,9 @@ minstrel_ht_update_caps(void *priv, stru
- if (!n_supported)
- goto use_legacy;
-
-+ if (test_sta_flag(sinfo, WLAN_STA_SHORT_PREAMBLE))
-+ mi->cck_supported_short |= mi->cck_supported_short << 4;
-+
- /* create an initial rate table with the lowest supported rates */
- minstrel_ht_update_stats(mp, mi);
- minstrel_ht_update_rates(mp, mi);
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Wed, 14 Dec 2016 20:09:14 +0100
-Subject: [PATCH] mac80211: minstrel_ht: make att_hist and succ_hist u32
- instead of u64
-
-They are only used for debugging purposes and take a very long time to
-overflow. Visibly reduces the size of the per-sta rate control data.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/rc80211_minstrel.h
-+++ b/net/mac80211/rc80211_minstrel.h
-@@ -59,7 +59,7 @@ struct minstrel_rate_stats {
- u16 success, last_success;
-
- /* total attempts/success counters */
-- u64 att_hist, succ_hist;
-+ u32 att_hist, succ_hist;
-
- /* statistis of packet delivery probability
- * cur_prob - current prob within last update intervall
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Wed, 14 Dec 2016 20:12:25 +0100
-Subject: [PATCH] mac80211: check for MCS in ieee80211_duration before fetching
- chanctx
-
-Makes the code a bit more efficient
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -63,6 +63,10 @@ static __le16 ieee80211_duration(struct
- struct ieee80211_chanctx_conf *chanctx_conf;
- u32 rate_flags = 0;
-
-+ /* assume HW handles this */
-+ if (tx->rate.flags & (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS))
-+ return 0;
-+
- rcu_read_lock();
- chanctx_conf = rcu_dereference(tx->sdata->vif.chanctx_conf);
- if (chanctx_conf) {
-@@ -71,10 +75,6 @@ static __le16 ieee80211_duration(struct
- }
- rcu_read_unlock();
-
-- /* assume HW handles this */
-- if (tx->rate.flags & (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS))
-- return 0;
--
- /* uh huh? */
- if (WARN_ON_ONCE(tx->rate.idx < 0))
- return 0;
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Wed, 14 Dec 2016 20:13:58 +0100
-Subject: [PATCH] mac80211: minstrel: remove cur_prob from debugfs
-
-This field is redundant, because it is simply last success divided by
-last attempt count. Removing it from the rate stats struct saves about
-1.2 KiB per HT station.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/rc80211_minstrel.c
-+++ b/net/mac80211/rc80211_minstrel.c
-@@ -159,21 +159,23 @@ minstrel_update_rates(struct minstrel_pr
- void
- minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs)
- {
-+ unsigned int cur_prob;
-+
- if (unlikely(mrs->attempts > 0)) {
- mrs->sample_skipped = 0;
-- mrs->cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
-+ cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
- if (unlikely(!mrs->att_hist)) {
-- mrs->prob_ewma = mrs->cur_prob;
-+ mrs->prob_ewma = cur_prob;
- } else {
- /* update exponential weighted moving variance */
- mrs->prob_ewmsd = minstrel_ewmsd(mrs->prob_ewmsd,
-- mrs->cur_prob,
-+ cur_prob,
- mrs->prob_ewma,
- EWMA_LEVEL);
-
- /*update exponential weighted moving avarage */
- mrs->prob_ewma = minstrel_ewma(mrs->prob_ewma,
-- mrs->cur_prob,
-+ cur_prob,
- EWMA_LEVEL);
- }
- mrs->att_hist += mrs->attempts;
---- a/net/mac80211/rc80211_minstrel.h
-+++ b/net/mac80211/rc80211_minstrel.h
-@@ -62,10 +62,8 @@ struct minstrel_rate_stats {
- u32 att_hist, succ_hist;
-
- /* statistis of packet delivery probability
-- * cur_prob - current prob within last update intervall
- * prob_ewma - exponential weighted moving average of prob
- * prob_ewmsd - exp. weighted moving standard deviation of prob */
-- unsigned int cur_prob;
- unsigned int prob_ewma;
- u16 prob_ewmsd;
-
---- a/net/mac80211/rc80211_minstrel_debugfs.c
-+++ b/net/mac80211/rc80211_minstrel_debugfs.c
-@@ -75,7 +75,7 @@ minstrel_stats_open(struct inode *inode,
- {
- struct minstrel_sta_info *mi = inode->i_private;
- struct minstrel_debugfs_info *ms;
-- unsigned int i, tp_max, tp_avg, prob, eprob;
-+ unsigned int i, tp_max, tp_avg, eprob;
- char *p;
-
- ms = kmalloc(2048, GFP_KERNEL);
-@@ -86,9 +86,9 @@ minstrel_stats_open(struct inode *inode,
- p = ms->buf;
- p += sprintf(p, "\n");
- p += sprintf(p,
-- "best __________rate_________ ________statistics________ ________last_______ ______sum-of________\n");
-+ "best __________rate_________ ________statistics________ ____last_____ ______sum-of________\n");
- p += sprintf(p,
-- "rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] [prob.|retry|suc|att] [#success | #attempts]\n");
-+ "rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] [retry|suc|att] [#success | #attempts]\n");
-
- for (i = 0; i < mi->n_rates; i++) {
- struct minstrel_rate *mr = &mi->r[i];
-@@ -107,17 +107,15 @@ minstrel_stats_open(struct inode *inode,
-
- tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100));
- tp_avg = minstrel_get_tp_avg(mr, mrs->prob_ewma);
-- prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
- eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
-
- p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u %3u.%1u"
-- " %3u.%1u %3u %3u %-3u "
-+ " %3u %3u %-3u "
- "%9llu %-9llu\n",
- tp_max / 10, tp_max % 10,
- tp_avg / 10, tp_avg % 10,
- eprob / 10, eprob % 10,
- mrs->prob_ewmsd / 10, mrs->prob_ewmsd % 10,
-- prob / 10, prob % 10,
- mrs->retry_count,
- mrs->last_success,
- mrs->last_attempts,
-@@ -148,7 +146,7 @@ minstrel_stats_csv_open(struct inode *in
- {
- struct minstrel_sta_info *mi = inode->i_private;
- struct minstrel_debugfs_info *ms;
-- unsigned int i, tp_max, tp_avg, prob, eprob;
-+ unsigned int i, tp_max, tp_avg, eprob;
- char *p;
-
- ms = kmalloc(2048, GFP_KERNEL);
-@@ -175,16 +173,14 @@ minstrel_stats_csv_open(struct inode *in
-
- tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100));
- tp_avg = minstrel_get_tp_avg(mr, mrs->prob_ewma);
-- prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
- eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
-
-- p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,%u,"
-+ p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,%u,"
- "%llu,%llu,%d,%d\n",
- tp_max / 10, tp_max % 10,
- tp_avg / 10, tp_avg % 10,
- eprob / 10, eprob % 10,
- mrs->prob_ewmsd / 10, mrs->prob_ewmsd % 10,
-- prob / 10, prob % 10,
- mrs->retry_count,
- mrs->last_success,
- mrs->last_attempts,
---- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
-+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
-@@ -19,7 +19,7 @@ static char *
- minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
- {
- const struct mcs_group *mg;
-- unsigned int j, tp_max, tp_avg, prob, eprob, tx_time;
-+ unsigned int j, tp_max, tp_avg, eprob, tx_time;
- char htmode = '2';
- char gimode = 'L';
- u32 gflags;
-@@ -83,17 +83,15 @@ minstrel_ht_stats_dump(struct minstrel_h
-
- tp_max = minstrel_ht_get_tp_avg(mi, i, j, MINSTREL_FRAC(100, 100));
- tp_avg = minstrel_ht_get_tp_avg(mi, i, j, mrs->prob_ewma);
-- prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
- eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
-
- p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u %3u.%1u"
-- " %3u.%1u %3u %3u %-3u "
-+ " %3u %3u %-3u "
- "%9llu %-9llu\n",
- tp_max / 10, tp_max % 10,
- tp_avg / 10, tp_avg % 10,
- eprob / 10, eprob % 10,
- mrs->prob_ewmsd / 10, mrs->prob_ewmsd % 10,
-- prob / 10, prob % 10,
- mrs->retry_count,
- mrs->last_success,
- mrs->last_attempts,
-@@ -130,9 +128,9 @@ minstrel_ht_stats_open(struct inode *ino
-
- p += sprintf(p, "\n");
- p += sprintf(p,
-- " best ____________rate__________ ________statistics________ ________last_______ ______sum-of________\n");
-+ " best ____________rate__________ ________statistics________ _____last____ ______sum-of________\n");
- p += sprintf(p,
-- "mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] [prob.|retry|suc|att] [#success | #attempts]\n");
-+ "mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] [retry|suc|att] [#success | #attempts]\n");
-
- p = minstrel_ht_stats_dump(mi, MINSTREL_CCK_GROUP, p);
- for (i = 0; i < MINSTREL_CCK_GROUP; i++)
-@@ -165,7 +163,7 @@ static char *
- minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
- {
- const struct mcs_group *mg;
-- unsigned int j, tp_max, tp_avg, prob, eprob, tx_time;
-+ unsigned int j, tp_max, tp_avg, eprob, tx_time;
- char htmode = '2';
- char gimode = 'L';
- u32 gflags;
-@@ -226,16 +224,14 @@ minstrel_ht_stats_csv_dump(struct minstr
-
- tp_max = minstrel_ht_get_tp_avg(mi, i, j, MINSTREL_FRAC(100, 100));
- tp_avg = minstrel_ht_get_tp_avg(mi, i, j, mrs->prob_ewma);
-- prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
- eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
-
-- p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,"
-+ p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,"
- "%u,%llu,%llu,",
- tp_max / 10, tp_max % 10,
- tp_avg / 10, tp_avg % 10,
- eprob / 10, eprob % 10,
- mrs->prob_ewmsd / 10, mrs->prob_ewmsd % 10,
-- prob / 10, prob % 10,
- mrs->retry_count,
- mrs->last_success,
- mrs->last_attempts,
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Wed, 14 Dec 2016 20:15:33 +0100
-Subject: [PATCH] mac80211: minstrel: reduce MINSTREL_SCALE
-
-The loss of a bit of extra precision does not hurt the calculation, 12
-bits is still enough to calculate probabilities well. Reducing the scale
-makes it easier to avoid overflows
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/rc80211_minstrel.h
-+++ b/net/mac80211/rc80211_minstrel.h
-@@ -14,7 +14,7 @@
- #define SAMPLE_COLUMNS 10 /* number of columns in sample table */
-
- /* scaled fraction values */
--#define MINSTREL_SCALE 16
-+#define MINSTREL_SCALE 12
- #define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div)
- #define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE)
-
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Wed, 14 Dec 2016 20:17:06 +0100
-Subject: [PATCH] mac80211: minstrel: store probability variance instead of
- standard deviation
-
-This avoids the costly int_sqrt calls in the statistics update and moves
-it to the debugfs code instead.
-This also fixes an overflow in the previous standard deviation
-calculation.
-
-Signed-off-by: Thomas Huehn <thomas.huehn@evernet-eg.de>
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/rc80211_minstrel.c
-+++ b/net/mac80211/rc80211_minstrel.c
-@@ -168,10 +168,10 @@ minstrel_calc_rate_stats(struct minstrel
- mrs->prob_ewma = cur_prob;
- } else {
- /* update exponential weighted moving variance */
-- mrs->prob_ewmsd = minstrel_ewmsd(mrs->prob_ewmsd,
-- cur_prob,
-- mrs->prob_ewma,
-- EWMA_LEVEL);
-+ mrs->prob_ewmv = minstrel_ewmv(mrs->prob_ewmv,
-+ cur_prob,
-+ mrs->prob_ewma,
-+ EWMA_LEVEL);
-
- /*update exponential weighted moving avarage */
- mrs->prob_ewma = minstrel_ewma(mrs->prob_ewma,
---- a/net/mac80211/rc80211_minstrel.h
-+++ b/net/mac80211/rc80211_minstrel.h
-@@ -36,21 +36,16 @@ minstrel_ewma(int old, int new, int weig
- }
-
- /*
-- * Perform EWMSD (Exponentially Weighted Moving Standard Deviation) calculation
-+ * Perform EWMV (Exponentially Weighted Moving Variance) calculation
- */
- static inline int
--minstrel_ewmsd(int old_ewmsd, int cur_prob, int prob_ewma, int weight)
-+minstrel_ewmv(int old_ewmv, int cur_prob, int prob_ewma, int weight)
- {
-- int diff, incr, tmp_var;
-+ int diff, incr;
-
-- /* calculate exponential weighted moving variance */
-- diff = MINSTREL_TRUNC((cur_prob - prob_ewma) * 1000000);
-+ diff = cur_prob - prob_ewma;
- incr = (EWMA_DIV - weight) * diff / EWMA_DIV;
-- tmp_var = old_ewmsd * old_ewmsd;
-- tmp_var = weight * (tmp_var + diff * incr / 1000000) / EWMA_DIV;
--
-- /* return standard deviation */
-- return (u16) int_sqrt(tmp_var);
-+ return weight * (old_ewmv + MINSTREL_TRUNC(diff * incr)) / EWMA_DIV;
- }
-
- struct minstrel_rate_stats {
-@@ -65,7 +60,7 @@ struct minstrel_rate_stats {
- * prob_ewma - exponential weighted moving average of prob
- * prob_ewmsd - exp. weighted moving standard deviation of prob */
- unsigned int prob_ewma;
-- u16 prob_ewmsd;
-+ u16 prob_ewmv;
-
- /* maximum retry counts */
- u8 retry_count;
-@@ -151,6 +146,14 @@ struct minstrel_debugfs_info {
- char buf[];
- };
-
-+/* Get EWMSD (Exponentially Weighted Moving Standard Deviation) * 10 */
-+static inline int
-+minstrel_get_ewmsd10(struct minstrel_rate_stats *mrs)
-+{
-+ unsigned int ewmv = mrs->prob_ewmv;
-+ return int_sqrt(MINSTREL_TRUNC(ewmv * 1000 * 1000));
-+}
-+
- extern const struct rate_control_ops mac80211_minstrel;
- void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
- void minstrel_remove_sta_debugfs(void *priv, void *priv_sta);
---- a/net/mac80211/rc80211_minstrel_debugfs.c
-+++ b/net/mac80211/rc80211_minstrel_debugfs.c
-@@ -93,6 +93,7 @@ minstrel_stats_open(struct inode *inode,
- for (i = 0; i < mi->n_rates; i++) {
- struct minstrel_rate *mr = &mi->r[i];
- struct minstrel_rate_stats *mrs = &mi->r[i].stats;
-+ unsigned int prob_ewmsd;
-
- *(p++) = (i == mi->max_tp_rate[0]) ? 'A' : ' ';
- *(p++) = (i == mi->max_tp_rate[1]) ? 'B' : ' ';
-@@ -108,6 +109,7 @@ minstrel_stats_open(struct inode *inode,
- tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100));
- tp_avg = minstrel_get_tp_avg(mr, mrs->prob_ewma);
- eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
-+ prob_ewmsd = minstrel_get_ewmsd10(mrs);
-
- p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u %3u.%1u"
- " %3u %3u %-3u "
-@@ -115,7 +117,7 @@ minstrel_stats_open(struct inode *inode,
- tp_max / 10, tp_max % 10,
- tp_avg / 10, tp_avg % 10,
- eprob / 10, eprob % 10,
-- mrs->prob_ewmsd / 10, mrs->prob_ewmsd % 10,
-+ prob_ewmsd / 10, prob_ewmsd % 10,
- mrs->retry_count,
- mrs->last_success,
- mrs->last_attempts,
-@@ -159,6 +161,7 @@ minstrel_stats_csv_open(struct inode *in
- for (i = 0; i < mi->n_rates; i++) {
- struct minstrel_rate *mr = &mi->r[i];
- struct minstrel_rate_stats *mrs = &mi->r[i].stats;
-+ unsigned int prob_ewmsd;
-
- p += sprintf(p, "%s" ,((i == mi->max_tp_rate[0]) ? "A" : ""));
- p += sprintf(p, "%s" ,((i == mi->max_tp_rate[1]) ? "B" : ""));
-@@ -174,13 +177,14 @@ minstrel_stats_csv_open(struct inode *in
- tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100));
- tp_avg = minstrel_get_tp_avg(mr, mrs->prob_ewma);
- eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
-+ prob_ewmsd = minstrel_get_ewmsd10(mrs);
-
- p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,%u,"
- "%llu,%llu,%d,%d\n",
- tp_max / 10, tp_max % 10,
- tp_avg / 10, tp_avg % 10,
- eprob / 10, eprob % 10,
-- mrs->prob_ewmsd / 10, mrs->prob_ewmsd % 10,
-+ prob_ewmsd / 10, prob_ewmsd % 10,
- mrs->retry_count,
- mrs->last_success,
- mrs->last_attempts,
---- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
-+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
-@@ -41,6 +41,7 @@ minstrel_ht_stats_dump(struct minstrel_h
- struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
- static const int bitrates[4] = { 10, 20, 55, 110 };
- int idx = i * MCS_GROUP_RATES + j;
-+ unsigned int prob_ewmsd;
-
- if (!(mi->supported[i] & BIT(j)))
- continue;
-@@ -84,6 +85,7 @@ minstrel_ht_stats_dump(struct minstrel_h
- tp_max = minstrel_ht_get_tp_avg(mi, i, j, MINSTREL_FRAC(100, 100));
- tp_avg = minstrel_ht_get_tp_avg(mi, i, j, mrs->prob_ewma);
- eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
-+ prob_ewmsd = minstrel_get_ewmsd10(mrs);
-
- p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u %3u.%1u"
- " %3u %3u %-3u "
-@@ -91,7 +93,7 @@ minstrel_ht_stats_dump(struct minstrel_h
- tp_max / 10, tp_max % 10,
- tp_avg / 10, tp_avg % 10,
- eprob / 10, eprob % 10,
-- mrs->prob_ewmsd / 10, mrs->prob_ewmsd % 10,
-+ prob_ewmsd / 10, prob_ewmsd % 10,
- mrs->retry_count,
- mrs->last_success,
- mrs->last_attempts,
-@@ -185,6 +187,7 @@ minstrel_ht_stats_csv_dump(struct minstr
- struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
- static const int bitrates[4] = { 10, 20, 55, 110 };
- int idx = i * MCS_GROUP_RATES + j;
-+ unsigned int prob_ewmsd;
-
- if (!(mi->supported[i] & BIT(j)))
- continue;
-@@ -225,13 +228,14 @@ minstrel_ht_stats_csv_dump(struct minstr
- tp_max = minstrel_ht_get_tp_avg(mi, i, j, MINSTREL_FRAC(100, 100));
- tp_avg = minstrel_ht_get_tp_avg(mi, i, j, mrs->prob_ewma);
- eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
-+ prob_ewmsd = minstrel_get_ewmsd10(mrs);
-
- p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,"
- "%u,%llu,%llu,",
- tp_max / 10, tp_max % 10,
- tp_avg / 10, tp_avg % 10,
- eprob / 10, eprob % 10,
-- mrs->prob_ewmsd / 10, mrs->prob_ewmsd % 10,
-+ prob_ewmsd / 10, prob_ewmsd % 10,
- mrs->retry_count,
- mrs->last_success,
- mrs->last_attempts,
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Wed, 14 Dec 2016 20:19:56 +0100
-Subject: [PATCH] mac80211: minstrel: make prob_ewma u16 instead of u32
-
-Saves about 1.2 KiB memory per station
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/rc80211_minstrel.h
-+++ b/net/mac80211/rc80211_minstrel.h
-@@ -59,7 +59,7 @@ struct minstrel_rate_stats {
- /* statistis of packet delivery probability
- * prob_ewma - exponential weighted moving average of prob
- * prob_ewmsd - exp. weighted moving standard deviation of prob */
-- unsigned int prob_ewma;
-+ u16 prob_ewma;
- u16 prob_ewmv;
-
- /* maximum retry counts */
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Wed, 14 Dec 2016 20:23:29 +0100
-Subject: [PATCH] mac80211: minstrel_ht: remove obsolete #if for >= 3 streams
-
-This was added during early development when 3x3 hardware was not very
-common yet. This is completely unnecessary now.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/net/mac80211/rc80211_minstrel_ht.c
-+++ b/net/mac80211/rc80211_minstrel_ht.c
-@@ -155,67 +155,47 @@ MODULE_PARM_DESC(minstrel_vht_only,
- const struct mcs_group minstrel_mcs_groups[] = {
- MCS_GROUP(1, 0, BW_20),
- MCS_GROUP(2, 0, BW_20),
--#if MINSTREL_MAX_STREAMS >= 3
- MCS_GROUP(3, 0, BW_20),
--#endif
-
- MCS_GROUP(1, 1, BW_20),
- MCS_GROUP(2, 1, BW_20),
--#if MINSTREL_MAX_STREAMS >= 3
- MCS_GROUP(3, 1, BW_20),
--#endif
-
- MCS_GROUP(1, 0, BW_40),
- MCS_GROUP(2, 0, BW_40),
--#if MINSTREL_MAX_STREAMS >= 3
- MCS_GROUP(3, 0, BW_40),
--#endif
-
- MCS_GROUP(1, 1, BW_40),
- MCS_GROUP(2, 1, BW_40),
--#if MINSTREL_MAX_STREAMS >= 3
- MCS_GROUP(3, 1, BW_40),
--#endif
-
- CCK_GROUP,
-
- #ifdef CPTCFG_MAC80211_RC_MINSTREL_VHT
- VHT_GROUP(1, 0, BW_20),
- VHT_GROUP(2, 0, BW_20),
--#if MINSTREL_MAX_STREAMS >= 3
- VHT_GROUP(3, 0, BW_20),
--#endif
-
- VHT_GROUP(1, 1, BW_20),
- VHT_GROUP(2, 1, BW_20),
--#if MINSTREL_MAX_STREAMS >= 3
- VHT_GROUP(3, 1, BW_20),
--#endif
-
- VHT_GROUP(1, 0, BW_40),
- VHT_GROUP(2, 0, BW_40),
--#if MINSTREL_MAX_STREAMS >= 3
- VHT_GROUP(3, 0, BW_40),
--#endif
-
- VHT_GROUP(1, 1, BW_40),
- VHT_GROUP(2, 1, BW_40),
--#if MINSTREL_MAX_STREAMS >= 3
- VHT_GROUP(3, 1, BW_40),
--#endif
-
- VHT_GROUP(1, 0, BW_80),
- VHT_GROUP(2, 0, BW_80),
--#if MINSTREL_MAX_STREAMS >= 3
- VHT_GROUP(3, 0, BW_80),
--#endif
-
- VHT_GROUP(1, 1, BW_80),
- VHT_GROUP(2, 1, BW_80),
--#if MINSTREL_MAX_STREAMS >= 3
- VHT_GROUP(3, 1, BW_80),
- #endif
--#endif
- };
-
- static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly;
+++ /dev/null
-From: Johannes Berg <johannes.berg@intel.com>
-Date: Tue, 15 Nov 2016 12:05:11 +0100
-Subject: [PATCH] cfg80211: limit scan results cache size
-
-It's possible to make scanning consume almost arbitrary amounts
-of memory, e.g. by sending beacon frames with random BSSIDs at
-high rates while somebody is scanning.
-
-Limit the number of BSS table entries we're willing to cache to
-1000, limiting maximum memory usage to maybe 4-5MB, but lower
-in practice - that would be the case for having both full-sized
-beacon and probe response frames for each entry; this seems not
-possible in practice, so a limit of 1000 entries will likely be
-closer to 0.5 MB.
-
-Cc: stable@vger.kernel.org
-Signed-off-by: Johannes Berg <johannes.berg@intel.com>
----
-
---- a/net/wireless/core.h
-+++ b/net/wireless/core.h
-@@ -71,6 +71,7 @@ struct cfg80211_registered_device {
- struct list_head bss_list;
- struct rb_root bss_tree;
- u32 bss_generation;
-+ u32 bss_entries;
- struct cfg80211_scan_request *scan_req; /* protected by RTNL */
- struct sk_buff *scan_msg;
- struct cfg80211_sched_scan_request __rcu *sched_scan_req;
---- a/net/wireless/scan.c
-+++ b/net/wireless/scan.c
-@@ -57,6 +57,19 @@
- * also linked into the probe response struct.
- */
-
-+/*
-+ * Limit the number of BSS entries stored in mac80211. Each one is
-+ * a bit over 4k at most, so this limits to roughly 4-5M of memory.
-+ * If somebody wants to really attack this though, they'd likely
-+ * use small beacons, and only one type of frame, limiting each of
-+ * the entries to a much smaller size (in order to generate more
-+ * entries in total, so overhead is bigger.)
-+ */
-+static int bss_entries_limit = 1000;
-+module_param(bss_entries_limit, int, 0644);
-+MODULE_PARM_DESC(bss_entries_limit,
-+ "limit to number of scan BSS entries (per wiphy, default 1000)");
-+
- #define IEEE80211_SCAN_RESULT_EXPIRE (30 * HZ)
-
- static void bss_free(struct cfg80211_internal_bss *bss)
-@@ -137,6 +150,10 @@ static bool __cfg80211_unlink_bss(struct
-
- list_del_init(&bss->list);
- rb_erase(&bss->rbn, &rdev->bss_tree);
-+ rdev->bss_entries--;
-+ WARN_ONCE((rdev->bss_entries == 0) ^ list_empty(&rdev->bss_list),
-+ "rdev bss entries[%d]/list[empty:%d] corruption\n",
-+ rdev->bss_entries, list_empty(&rdev->bss_list));
- bss_ref_put(rdev, bss);
- return true;
- }
-@@ -163,6 +180,40 @@ static void __cfg80211_bss_expire(struct
- rdev->bss_generation++;
- }
-
-+static bool cfg80211_bss_expire_oldest(struct cfg80211_registered_device *rdev)
-+{
-+ struct cfg80211_internal_bss *bss, *oldest = NULL;
-+ bool ret;
-+
-+ lockdep_assert_held(&rdev->bss_lock);
-+
-+ list_for_each_entry(bss, &rdev->bss_list, list) {
-+ if (atomic_read(&bss->hold))
-+ continue;
-+
-+ if (!list_empty(&bss->hidden_list) &&
-+ !bss->pub.hidden_beacon_bss)
-+ continue;
-+
-+ if (oldest && time_before(oldest->ts, bss->ts))
-+ continue;
-+ oldest = bss;
-+ }
-+
-+ if (WARN_ON(!oldest))
-+ return false;
-+
-+ /*
-+ * The callers make sure to increase rdev->bss_generation if anything
-+ * gets removed (and a new entry added), so there's no need to also do
-+ * it here.
-+ */
-+
-+ ret = __cfg80211_unlink_bss(rdev, oldest);
-+ WARN_ON(!ret);
-+ return ret;
-+}
-+
- void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
- bool send_message)
- {
-@@ -689,6 +740,7 @@ static bool cfg80211_combine_bsses(struc
- const u8 *ie;
- int i, ssidlen;
- u8 fold = 0;
-+ u32 n_entries = 0;
-
- ies = rcu_access_pointer(new->pub.beacon_ies);
- if (WARN_ON(!ies))
-@@ -712,6 +764,12 @@ static bool cfg80211_combine_bsses(struc
- /* This is the bad part ... */
-
- list_for_each_entry(bss, &rdev->bss_list, list) {
-+ /*
-+ * we're iterating all the entries anyway, so take the
-+ * opportunity to validate the list length accounting
-+ */
-+ n_entries++;
-+
- if (!ether_addr_equal(bss->pub.bssid, new->pub.bssid))
- continue;
- if (bss->pub.channel != new->pub.channel)
-@@ -740,6 +798,10 @@ static bool cfg80211_combine_bsses(struc
- new->pub.beacon_ies);
- }
-
-+ WARN_ONCE(n_entries != rdev->bss_entries,
-+ "rdev bss entries[%d]/list[len:%d] corruption\n",
-+ rdev->bss_entries, n_entries);
-+
- return true;
- }
-
-@@ -894,7 +956,14 @@ cfg80211_bss_update(struct cfg80211_regi
- }
- }
-
-+ if (rdev->bss_entries >= bss_entries_limit &&
-+ !cfg80211_bss_expire_oldest(rdev)) {
-+ kfree(new);
-+ goto drop;
-+ }
-+
- list_add_tail(&new->list, &rdev->bss_list);
-+ rdev->bss_entries++;
- rb_insert_bss(rdev, new);
- found = new;
- }
+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Tue, 27 Dec 2016 12:15:14 +0100
-Subject: [PATCH] ath5k: drop bogus warning on drv_set_key with unsupported
- cipher
-
-Simply return -EOPNOTSUPP instead.
-
-Cc: stable@vger.kernel.org
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
-+++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
-@@ -502,8 +502,7 @@ ath5k_set_key(struct ieee80211_hw *hw, e
- break;
- return -EOPNOTSUPP;
- default:
-- WARN_ON(1);
-- return -EINVAL;
-+ return -EOPNOTSUPP;
- }
-
- mutex_lock(&ah->lock);
+++ /dev/null
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
-Date: Wed, 4 Jan 2017 18:58:30 +0100
-Subject: [PATCH] cfg80211: move function checking range fit to util.c
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-It is needed for another cfg80211 helper that will be out of reg.c so
-move it to common util.c file and make it non-static.
-
-Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-Signed-off-by: Johannes Berg <johannes.berg@intel.com>
----
-
---- a/net/wireless/core.h
-+++ b/net/wireless/core.h
-@@ -429,6 +429,9 @@ int cfg80211_change_iface(struct cfg8021
- void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev);
- void cfg80211_process_wdev_events(struct wireless_dev *wdev);
-
-+bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range,
-+ u32 center_freq_khz, u32 bw_khz);
-+
- /**
- * cfg80211_chandef_dfs_usable - checks if chandef is DFS usable
- * @wiphy: the wiphy to validate against
---- a/net/wireless/reg.c
-+++ b/net/wireless/reg.c
-@@ -748,21 +748,6 @@ static bool is_valid_rd(const struct iee
- return true;
- }
-
--static bool reg_does_bw_fit(const struct ieee80211_freq_range *freq_range,
-- u32 center_freq_khz, u32 bw_khz)
--{
-- u32 start_freq_khz, end_freq_khz;
--
-- start_freq_khz = center_freq_khz - (bw_khz/2);
-- end_freq_khz = center_freq_khz + (bw_khz/2);
--
-- if (start_freq_khz >= freq_range->start_freq_khz &&
-- end_freq_khz <= freq_range->end_freq_khz)
-- return true;
--
-- return false;
--}
--
- /**
- * freq_in_rule_band - tells us if a frequency is in a frequency band
- * @freq_range: frequency rule we want to query
-@@ -1070,7 +1055,7 @@ freq_reg_info_regd(u32 center_freq,
- if (!band_rule_found)
- band_rule_found = freq_in_rule_band(fr, center_freq);
-
-- bw_fits = reg_does_bw_fit(fr, center_freq, bw);
-+ bw_fits = cfg80211_does_bw_fit_range(fr, center_freq, bw);
-
- if (band_rule_found && bw_fits)
- return rr;
-@@ -1138,11 +1123,13 @@ static uint32_t reg_rule_to_chan_bw_flag
- max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule);
-
- /* If we get a reg_rule we can assume that at least 5Mhz fit */
-- if (!reg_does_bw_fit(freq_range, MHZ_TO_KHZ(chan->center_freq),
-- MHZ_TO_KHZ(10)))
-+ if (!cfg80211_does_bw_fit_range(freq_range,
-+ MHZ_TO_KHZ(chan->center_freq),
-+ MHZ_TO_KHZ(10)))
- bw_flags |= IEEE80211_CHAN_NO_10MHZ;
-- if (!reg_does_bw_fit(freq_range, MHZ_TO_KHZ(chan->center_freq),
-- MHZ_TO_KHZ(20)))
-+ if (!cfg80211_does_bw_fit_range(freq_range,
-+ MHZ_TO_KHZ(chan->center_freq),
-+ MHZ_TO_KHZ(20)))
- bw_flags |= IEEE80211_CHAN_NO_20MHZ;
-
- if (max_bandwidth_khz < MHZ_TO_KHZ(10))
---- a/net/wireless/util.c
-+++ b/net/wireless/util.c
-@@ -1788,6 +1788,21 @@ void cfg80211_free_nan_func(struct cfg80
- }
- EXPORT_SYMBOL(cfg80211_free_nan_func);
-
-+bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range,
-+ u32 center_freq_khz, u32 bw_khz)
-+{
-+ u32 start_freq_khz, end_freq_khz;
-+
-+ start_freq_khz = center_freq_khz - (bw_khz / 2);
-+ end_freq_khz = center_freq_khz + (bw_khz / 2);
-+
-+ if (start_freq_khz >= freq_range->start_freq_khz &&
-+ end_freq_khz <= freq_range->end_freq_khz)
-+ return true;
-+
-+ return false;
-+}
-+
- /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
- /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
- const unsigned char rfc1042_header[] __aligned(2) =
+++ /dev/null
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
-Date: Wed, 4 Jan 2017 18:58:31 +0100
-Subject: [PATCH] cfg80211: support ieee80211-freq-limit DT property
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This patch adds a helper for reading that new property and applying
-limitations of supported channels specified this way.
-It is used with devices that normally support a wide wireless band but
-in a given config are limited to some part of it (usually due to board
-design). For example a dual-band chipset may be able to support one band
-only because of used antennas.
-It's also common that tri-band routers have separated radios for lower
-and higher part of 5 GHz band and it may be impossible to say which is
-which without a DT info.
-
-Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-[add new function to documentation, fix link]
-Signed-off-by: Johannes Berg <johannes.berg@intel.com>
----
- create mode 100644 net/wireless/of.c
-
---- a/include/net/cfg80211.h
-+++ b/include/net/cfg80211.h
-@@ -311,6 +311,34 @@ struct ieee80211_supported_band {
- struct ieee80211_sta_vht_cap vht_cap;
- };
-
-+/**
-+ * wiphy_read_of_freq_limits - read frequency limits from device tree
-+ *
-+ * @wiphy: the wireless device to get extra limits for
-+ *
-+ * Some devices may have extra limitations specified in DT. This may be useful
-+ * for chipsets that normally support more bands but are limited due to board
-+ * design (e.g. by antennas or external power amplifier).
-+ *
-+ * This function reads info from DT and uses it to *modify* channels (disable
-+ * unavailable ones). It's usually a *bad* idea to use it in drivers with
-+ * shared channel data as DT limitations are device specific. You should make
-+ * sure to call it only if channels in wiphy are copied and can be modified
-+ * without affecting other devices.
-+ *
-+ * As this function access device node it has to be called after set_wiphy_dev.
-+ * It also modifies channels so they have to be set first.
-+ * If using this helper, call it before wiphy_register().
-+ */
-+#ifdef CONFIG_OF
-+void wiphy_read_of_freq_limits(struct wiphy *wiphy);
-+#else /* CONFIG_OF */
-+static inline void wiphy_read_of_freq_limits(struct wiphy *wiphy)
-+{
-+}
-+#endif /* !CONFIG_OF */
-+
-+
- /*
- * Wireless hardware/device configuration structures and methods
- */
---- a/net/wireless/Makefile
-+++ b/net/wireless/Makefile
-@@ -11,6 +11,7 @@ obj-$(CONFIG_WEXT_PRIV) += wext-priv.o
-
- cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o
- cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o mesh.o ap.o trace.o ocb.o
-+cfg80211-$(CONFIG_OF) += of.o
- cfg80211-$(CPTCFG_CFG80211_DEBUGFS) += debugfs.o
- cfg80211-$(CPTCFG_CFG80211_WEXT) += wext-compat.o wext-sme.o
- cfg80211-$(CPTCFG_CFG80211_INTERNAL_REGDB) += regdb.o
---- /dev/null
-+++ b/net/wireless/of.c
-@@ -0,0 +1,138 @@
-+/*
-+ * Copyright (C) 2017 Rafał Miłecki <rafal@milecki.pl>
-+ *
-+ * Permission to use, copy, modify, and/or distribute this software for any
-+ * purpose with or without fee is hereby granted, provided that the above
-+ * copyright notice and this permission notice appear in all copies.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-+ */
-+
-+#include <linux/of.h>
-+#include <net/cfg80211.h>
-+#include "core.h"
-+
-+static bool wiphy_freq_limits_valid_chan(struct wiphy *wiphy,
-+ struct ieee80211_freq_range *freq_limits,
-+ unsigned int n_freq_limits,
-+ struct ieee80211_channel *chan)
-+{
-+ u32 bw = MHZ_TO_KHZ(20);
-+ int i;
-+
-+ for (i = 0; i < n_freq_limits; i++) {
-+ struct ieee80211_freq_range *limit = &freq_limits[i];
-+
-+ if (cfg80211_does_bw_fit_range(limit,
-+ MHZ_TO_KHZ(chan->center_freq),
-+ bw))
-+ return true;
-+ }
-+
-+ return false;
-+}
-+
-+static void wiphy_freq_limits_apply(struct wiphy *wiphy,
-+ struct ieee80211_freq_range *freq_limits,
-+ unsigned int n_freq_limits)
-+{
-+ enum nl80211_band band;
-+ int i;
-+
-+ if (WARN_ON(!n_freq_limits))
-+ return;
-+
-+ for (band = 0; band < NUM_NL80211_BANDS; band++) {
-+ struct ieee80211_supported_band *sband = wiphy->bands[band];
-+
-+ if (!sband)
-+ continue;
-+
-+ for (i = 0; i < sband->n_channels; i++) {
-+ struct ieee80211_channel *chan = &sband->channels[i];
-+
-+ if (chan->flags & IEEE80211_CHAN_DISABLED)
-+ continue;
-+
-+ if (!wiphy_freq_limits_valid_chan(wiphy, freq_limits,
-+ n_freq_limits,
-+ chan)) {
-+ pr_debug("Disabling freq %d MHz as it's out of OF limits\n",
-+ chan->center_freq);
-+ chan->flags |= IEEE80211_CHAN_DISABLED;
-+ }
-+ }
-+ }
-+}
-+
-+void wiphy_read_of_freq_limits(struct wiphy *wiphy)
-+{
-+ struct device *dev = wiphy_dev(wiphy);
-+ struct device_node *np;
-+ struct property *prop;
-+ struct ieee80211_freq_range *freq_limits;
-+ unsigned int n_freq_limits;
-+ const __be32 *p;
-+ int len, i;
-+ int err = 0;
-+
-+ if (!dev)
-+ return;
-+ np = dev_of_node(dev);
-+ if (!np)
-+ return;
-+
-+ prop = of_find_property(np, "ieee80211-freq-limit", &len);
-+ if (!prop)
-+ return;
-+
-+ if (!len || len % sizeof(u32) || len / sizeof(u32) % 2) {
-+ dev_err(dev, "ieee80211-freq-limit wrong format");
-+ return;
-+ }
-+ n_freq_limits = len / sizeof(u32) / 2;
-+
-+ freq_limits = kcalloc(n_freq_limits, sizeof(*freq_limits), GFP_KERNEL);
-+ if (!freq_limits) {
-+ err = -ENOMEM;
-+ goto out_kfree;
-+ }
-+
-+ p = NULL;
-+ for (i = 0; i < n_freq_limits; i++) {
-+ struct ieee80211_freq_range *limit = &freq_limits[i];
-+
-+ p = of_prop_next_u32(prop, p, &limit->start_freq_khz);
-+ if (!p) {
-+ err = -EINVAL;
-+ goto out_kfree;
-+ }
-+
-+ p = of_prop_next_u32(prop, p, &limit->end_freq_khz);
-+ if (!p) {
-+ err = -EINVAL;
-+ goto out_kfree;
-+ }
-+
-+ if (!limit->start_freq_khz ||
-+ !limit->end_freq_khz ||
-+ limit->start_freq_khz >= limit->end_freq_khz) {
-+ err = -EINVAL;
-+ goto out_kfree;
-+ }
-+ }
-+
-+ wiphy_freq_limits_apply(wiphy, freq_limits, n_freq_limits);
-+
-+out_kfree:
-+ kfree(freq_limits);
-+ if (err)
-+ dev_err(dev, "Failed to get limits: %d\n", err);
-+}
-+EXPORT_SYMBOL(wiphy_read_of_freq_limits);
+++ /dev/null
-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
-
-The checks already prevents periodic cal from being started while noise
-floor calibration runs. It is missing checks for the other way around.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
-@@ -676,10 +676,10 @@ static int ar9002_hw_calibrate(struct at
- return 0;
-
- ah->cal_list_curr = currCal = currCal->calNext;
-- if (currCal->calState == CAL_WAITING) {
-+ if (currCal->calState == CAL_WAITING)
- ath9k_hw_reset_calibration(ah, currCal);
-- return 0;
-- }
-+
-+ return 0;
- }
-
- /* Do NF cal only at longer intervals */
-ath-$(CPTCFG_ATH_DEBUG) += debug.o
ath-$(CPTCFG_ATH_TRACEPOINTS) += trace.o
- ccflags-y += -D__CHECK_ENDIAN__
+ CFLAGS_trace.o := -I$(src)
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -318,14 +318,7 @@ void _ath_dbg(struct ath_common *common,
if (!wiphy->bands[NL80211_BAND_5GHZ])
return;
-@@ -633,6 +647,10 @@ ath_regd_init_wiphy(struct ath_regulator
+@@ -634,6 +648,10 @@ ath_regd_init_wiphy(struct ath_regulator
const struct ieee80211_regdomain *regd;
wiphy->reg_notifier = reg_notifier;
---help---
--- a/.local-symbols
+++ b/.local-symbols
-@@ -127,6 +127,7 @@ ADM8211=
+@@ -130,6 +130,7 @@ ADM8211=
ATH_COMMON=
WLAN_VENDOR_ATH=
ATH_DEBUG=
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
-@@ -2411,6 +2411,8 @@ void regulatory_hint_country_ie(struct w
+@@ -2398,6 +2398,8 @@ void regulatory_hint_country_ie(struct w
enum environment_cap env = ENVIRON_ANY;
struct regulatory_request *request = NULL, *lr;
/* IE len must be evenly divisible by 2 */
if (country_ie_len & 0x01)
return;
-@@ -2617,6 +2619,7 @@ static void restore_regulatory_settings(
+@@ -2604,6 +2606,7 @@ static void restore_regulatory_settings(
void regulatory_hint_disconnect(void)
{
bool ath_is_world_regd(struct ath_regulatory *reg)
{
return is_wwr_sku(ath_regd_get_eepromRD(reg));
-@@ -651,6 +659,9 @@ ath_regd_init_wiphy(struct ath_regulator
+@@ -652,6 +660,9 @@ ath_regd_init_wiphy(struct ath_regulator
if (IS_ENABLED(CPTCFG_ATH_USER_REGD))
return 0;
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -773,6 +773,7 @@ static const struct ieee80211_iface_limi
+@@ -777,6 +777,7 @@ static const struct ieee80211_iface_limi
BIT(NL80211_IFTYPE_AP) },
{ .max = 1, .types = BIT(NL80211_IFTYPE_P2P_CLIENT) |
BIT(NL80211_IFTYPE_P2P_GO) },
+ { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) },
};
- static const struct ieee80211_iface_limit wds_limits[] = {
+ #ifdef CPTCFG_WIRELESS_WDS
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
-@@ -823,6 +823,97 @@ static const struct file_operations fops
+@@ -822,6 +822,97 @@ static const struct file_operations fops
.llseek = default_llseek,
};
/* debugfs: queues etc */
-@@ -1010,6 +1101,9 @@ ath5k_debug_init_device(struct ath5k_hw
+@@ -1009,6 +1100,9 @@ ath5k_debug_init_device(struct ath5k_hw
debugfs_create_file("beacon", S_IWUSR | S_IRUSR, phydir, ah,
&fops_beacon);
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -1076,23 +1076,23 @@ static int __init ath9k_init(void)
+@@ -1086,23 +1086,23 @@ static int __init ath9k_init(void)
{
int error;
#define AR9160_DEVID_PCI 0x0027
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
-@@ -760,6 +760,7 @@ static const struct pci_device_id ath_pc
+@@ -763,6 +763,7 @@ static const struct pci_device_id ath_pc
.driver_data = ATH9K_PCI_BT_ANT_DIV },
#endif
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
-@@ -2562,6 +2562,7 @@ struct cfg80211_nan_func {
+@@ -2660,6 +2660,7 @@ struct cfg80211_nan_func {
* (as advertised by the nl80211 feature flag.)
* @get_tx_power: store the current TX power into the dbm variable;
* return 0 if successful
*
* @set_wds_peer: set the WDS peer for a WDS interface
*
-@@ -2836,6 +2837,7 @@ struct cfg80211_ops {
+@@ -2940,6 +2941,7 @@ struct cfg80211_ops {
enum nl80211_tx_power_setting type, int mbm);
int (*get_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
int *dbm);
const u8 *addr);
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
-@@ -1319,6 +1319,7 @@ enum ieee80211_smps_mode {
+@@ -1325,6 +1325,7 @@ enum ieee80211_smps_mode {
*
* @power_level: requested transmit power (in dBm), backward compatibility
* value only that is set to the minimum of all interfaces
*
* @chandef: the channel definition to tune to
* @radar_enabled: whether radar detection is enabled
-@@ -1339,6 +1340,7 @@ enum ieee80211_smps_mode {
+@@ -1345,6 +1346,7 @@ enum ieee80211_smps_mode {
struct ieee80211_conf {
u32 flags;
int power_level, dynamic_ps_timeout;
u8 ps_dtim_period;
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
-@@ -1937,6 +1937,9 @@ enum nl80211_commands {
- * @NL80211_ATTR_NAN_MATCH: used to report a match. This is a nested attribute.
- * See &enum nl80211_nan_match_attributes.
+@@ -2002,6 +2002,9 @@ enum nl80211_commands {
+ * u32 attribute with an &enum nl80211_timeout_reason value. This is used,
+ * e.g., with %NL80211_CMD_CONNECT event.
*
+ * @NL80211_ATTR_WIPHY_ANTENNA_GAIN: Configured antenna gain. Used to reduce
+ * transmit power to stay within regulatory limits. u32, dBi.
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
-@@ -2336,6 +2339,8 @@ enum nl80211_attrs {
- NL80211_ATTR_NAN_FUNC,
- NL80211_ATTR_NAN_MATCH,
+@@ -2413,6 +2416,8 @@ enum nl80211_attrs {
+
+ NL80211_ATTR_TIMEOUT_REASON,
+ NL80211_ATTR_WIPHY_ANTENNA_GAIN,
+
__NL80211_ATTR_AFTER_LAST,
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
-@@ -2406,6 +2406,19 @@ static int ieee80211_get_tx_power(struct
+@@ -2396,6 +2396,19 @@ static int ieee80211_get_tx_power(struct
return 0;
}
static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
const u8 *addr)
{
-@@ -3633,6 +3646,7 @@ const struct cfg80211_ops mac80211_confi
+@@ -3627,6 +3640,7 @@ const struct cfg80211_ops mac80211_confi
.set_wiphy_params = ieee80211_set_wiphy_params,
.set_tx_power = ieee80211_set_tx_power,
.get_tx_power = ieee80211_get_tx_power,
CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
-@@ -1363,6 +1363,7 @@ struct ieee80211_local {
+@@ -1370,6 +1370,7 @@ struct ieee80211_local {
int dynamic_ps_forced_timeout;
int user_power_level; /* in dBm, for all interfaces */
if (local->hw.conf.power_level != power) {
changed |= IEEE80211_CONF_CHANGE_POWER;
local->hw.conf.power_level = power;
-@@ -588,6 +594,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_
+@@ -589,6 +595,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_
IEEE80211_RADIOTAP_MCS_HAVE_BW;
local->hw.radiotap_vht_details = IEEE80211_RADIOTAP_VHT_KNOWN_GI |
IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH;
local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
-@@ -416,6 +416,7 @@ static const struct nla_policy nl80211_p
- [NL80211_ATTR_NAN_MASTER_PREF] = { .type = NLA_U8 },
- [NL80211_ATTR_NAN_DUAL] = { .type = NLA_U8 },
- [NL80211_ATTR_NAN_FUNC] = { .type = NLA_NESTED },
+@@ -424,6 +424,7 @@ static const struct nla_policy nl80211_p
+ .len = sizeof(struct nl80211_bss_select_rssi_adjust)
+ },
+ [NL80211_ATTR_TIMEOUT_REASON] = { .type = NLA_U32 },
+ [NL80211_ATTR_WIPHY_ANTENNA_GAIN] = { .type = NLA_U32 },
};
/* policy for the key attributes */
-@@ -2353,6 +2354,20 @@ static int nl80211_set_wiphy(struct sk_b
+@@ -2385,6 +2386,20 @@ static int nl80211_set_wiphy(struct sk_b
if (result)
return result;
}
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -827,6 +827,9 @@ static inline int ath9k_dump_btcoex(stru
+@@ -850,6 +850,9 @@ static inline int ath9k_dump_btcoex(stru
#ifdef CPTCFG_MAC80211_LEDS
void ath_init_leds(struct ath_softc *sc);
void ath_deinit_leds(struct ath_softc *sc);
#else
static inline void ath_init_leds(struct ath_softc *sc)
{
-@@ -963,6 +966,13 @@ void ath_ant_comb_scan(struct ath_softc
-
- #define ATH9K_NUM_CHANCTX 2 /* supports 2 operating channels */
+@@ -991,6 +994,13 @@ void ath_ant_comb_scan(struct ath_softc
+ #define AIRTIME_USE_NEW_QUEUES BIT(2)
+ #define AIRTIME_ACTIVE(flags) (!!(flags & (AIRTIME_USE_TX|AIRTIME_USE_RX)))
+struct ath_led {
+ struct list_head list;
struct ath_softc {
struct ieee80211_hw *hw;
struct device *dev;
-@@ -1015,9 +1025,8 @@ struct ath_softc {
+@@ -1046,9 +1056,8 @@ struct ath_softc {
spinlock_t chan_lock;
#ifdef CPTCFG_MAC80211_LEDS
+ GFP_KERNEL);
+ if (!led)
+ return -ENOMEM;
-
-- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, val);
++
+ led->gpio = gpio = (struct gpio_led *) (led + 1);
+ _name = (char *) (led->gpio + 1);
+
+ ret = ath_add_led(sc, led);
+ if (unlikely(ret < 0))
+ kfree(led);
-+
+
+- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, val);
+ return ret;
}
{
- if (!sc->led_registered)
- return;
--
-- ath_led_brightness(&sc->led_cdev, LED_OFF);
-- led_classdev_unregister(&sc->led_cdev);
+ struct ath_led *led;
+- ath_led_brightness(&sc->led_cdev, LED_OFF);
+- led_classdev_unregister(&sc->led_cdev);
+-
- ath9k_hw_gpio_free(sc->sc_ah, sc->sc_ah->led_pin);
+ while (!list_empty(&sc->leds)) {
+ led = list_first_entry(&sc->leds, struct ath_led, list);
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -988,7 +988,7 @@ int ath9k_init_device(u16 devid, struct
+@@ -998,7 +998,7 @@ int ath9k_init_device(u16 devid, struct
#ifdef CPTCFG_MAC80211_LEDS
/* must be initialized before ieee80211_register_hw */
struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah,
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1838,6 +1838,20 @@ u32 ath9k_hw_get_tsf_offset(struct times
+@@ -1842,6 +1842,20 @@ u32 ath9k_hw_get_tsf_offset(struct times
}
EXPORT_SYMBOL(ath9k_hw_get_tsf_offset);
int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
struct ath9k_hw_cal_data *caldata, bool fastcc)
{
-@@ -2046,6 +2060,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+@@ -2050,6 +2064,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
ar9003_hw_disable_phy_restart(ah);
ath9k_hw_apply_gpio_override(ah);
REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, AR_BTCOEX_WL_LNADIV_FORCE_ON);
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -533,6 +533,11 @@ irqreturn_t ath_isr(int irq, void *dev)
+@@ -527,6 +527,11 @@ irqreturn_t ath_isr(int irq, void *dev)
if (test_bit(ATH_OP_HW_RESET, &common->op_flags))
return IRQ_HANDLED;
ops->spectral_scan_config = ar9003_hw_spectral_scan_config;
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -761,7 +761,8 @@ static void ath9k_init_txpower_limits(st
+@@ -765,7 +765,8 @@ static void ath9k_init_txpower_limits(st
if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ)
ath9k_init_band_txpower(sc, NL80211_BAND_5GHZ);
}
static const struct ieee80211_iface_limit if_limits[] = {
-@@ -948,6 +949,18 @@ static void ath9k_set_hw_capab(struct at
+@@ -958,6 +959,18 @@ static void ath9k_set_hw_capab(struct at
SET_IEEE80211_PERM_ADDR(hw, common->macaddr);
}
int ath9k_init_device(u16 devid, struct ath_softc *sc,
const struct ath_bus_ops *bus_ops)
{
-@@ -993,6 +1006,8 @@ int ath9k_init_device(u16 devid, struct
+@@ -1003,6 +1016,8 @@ int ath9k_init_device(u16 devid, struct
ARRAY_SIZE(ath9k_tpt_blink));
#endif
return true;
}
-@@ -1816,8 +1835,14 @@ static int ath9k_hw_do_fastcc(struct ath
+@@ -1820,8 +1839,14 @@ static int ath9k_hw_do_fastcc(struct ath
if (AR_SREV_9271(ah))
ar9002_hw_load_ani_reg(ah, chan);
return -EINVAL;
}
-@@ -2071,6 +2096,9 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+@@ -2075,6 +2100,9 @@ int ath9k_hw_reset(struct ath_hw *ah, st
ath9k_hw_set_radar_params(ah);
}
#include "common.h"
#include "debug.h"
-@@ -973,6 +974,14 @@ struct ath_led {
+@@ -1001,6 +1002,14 @@ struct ath_led {
struct led_classdev cdev;
};
struct ath_softc {
struct ieee80211_hw *hw;
struct device *dev;
-@@ -1027,6 +1036,9 @@ struct ath_softc {
+@@ -1058,6 +1067,9 @@ struct ath_softc {
#ifdef CPTCFG_MAC80211_LEDS
const char *led_default_trigger;
struct list_head leds;
+ if (!gc)
+ return;
+
++ gc->sc = sc;
+ snprintf(gc->label, sizeof(gc->label), "ath9k-%s",
+ wiphy_name(sc->hw->wiphy));
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)
+
+ gc->gchip.owner = NULL;
+ sc->gpiochip = gc;
-+ gc->sc = sc;
+}
+
+/* remove GPIO chip */
---
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -1038,6 +1038,7 @@ struct ath_softc {
+@@ -1069,6 +1069,7 @@ struct ath_softc {
struct list_head leds;
#ifdef CONFIG_GPIOLIB
struct ath9k_gpio_chip *gpiochip;
+++ /dev/null
-From 9692ab1ff30ae0abc1000d11b2f929b6e2e4cb7f Mon Sep 17 00:00:00 2001
-From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-Date: Mon, 3 Oct 2016 00:29:07 +0200
-Subject: [v2 PATCH 1/7] ath9k: Add a #define for the EEPROM "eepmisc" endianness
- bit
-
-This replaces a magic number with a named #define. Additionally it
-removes two "eeprom format" specific #defines for the "big endianness"
-bit which are the same on all eeprom formats.
-
-Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
----
- drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 3 ++-
- drivers/net/wireless/ath/ath9k/ar9003_eeprom.h | 1 -
- drivers/net/wireless/ath/ath9k/eeprom.h | 4 +++-
- drivers/net/wireless/ath/ath9k/eeprom_4k.c | 2 +-
- drivers/net/wireless/ath/ath9k/eeprom_9287.c | 2 +-
- drivers/net/wireless/ath/ath9k/eeprom_def.c | 2 +-
- 6 files changed, 8 insertions(+), 6 deletions(-)
-
---- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
-@@ -3468,7 +3468,8 @@ static u32 ath9k_hw_ar9003_dump_eeprom(s
- AR5416_OPFLAGS_N_5G_HT20));
- PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags.opFlags &
- AR5416_OPFLAGS_N_5G_HT40));
-- PR_EEP("Big Endian", !!(pBase->opCapFlags.eepMisc & 0x01));
-+ PR_EEP("Big Endian", !!(pBase->opCapFlags.eepMisc &
-+ AR5416_EEPMISC_BIG_ENDIAN));
- PR_EEP("RF Silent", pBase->rfSilent);
- PR_EEP("BT option", pBase->blueToothOptions);
- PR_EEP("Device Cap", pBase->deviceCap);
---- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
-+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
-@@ -38,7 +38,6 @@
- #define AR9300_NUM_CTLS_2G 12
- #define AR9300_NUM_BAND_EDGES_5G 8
- #define AR9300_NUM_BAND_EDGES_2G 4
--#define AR9300_EEPMISC_BIG_ENDIAN 0x01
- #define AR9300_EEPMISC_WOW 0x02
- #define AR9300_CUSTOMER_DATA_SIZE 20
-
---- a/drivers/net/wireless/ath/ath9k/eeprom.h
-+++ b/drivers/net/wireless/ath/ath9k/eeprom.h
-@@ -161,6 +161,9 @@
- #define AR5416_EEP_TXGAIN_ORIGINAL 0
- #define AR5416_EEP_TXGAIN_HIGH_POWER 1
-
-+/* Endianness of EEPROM content */
-+#define AR5416_EEPMISC_BIG_ENDIAN 0x01
-+
- #define AR5416_EEP4K_START_LOC 64
- #define AR5416_EEP4K_NUM_2G_CAL_PIERS 3
- #define AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS 3
-@@ -191,7 +194,6 @@
- #define AR9287_NUM_CTLS 12
- #define AR9287_NUM_BAND_EDGES 4
- #define AR9287_PD_GAIN_ICEPTS 1
--#define AR9287_EEPMISC_BIG_ENDIAN 0x01
- #define AR9287_EEPMISC_WOW 0x02
- #define AR9287_MAX_CHAINS 2
- #define AR9287_ANT_16S 32
---- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
-@@ -154,7 +154,7 @@ static u32 ath9k_hw_4k_dump_eeprom(struc
- AR5416_OPFLAGS_N_5G_HT20));
- PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags &
- AR5416_OPFLAGS_N_5G_HT40));
-- PR_EEP("Big Endian", !!(pBase->eepMisc & 0x01));
-+ PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN));
- PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF);
- PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF);
- PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
---- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
-@@ -150,7 +150,7 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
- AR5416_OPFLAGS_N_5G_HT20));
- PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags &
- AR5416_OPFLAGS_N_5G_HT40));
-- PR_EEP("Big Endian", !!(pBase->eepMisc & 0x01));
-+ PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN));
- PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF);
- PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF);
- PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
---- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
-@@ -232,7 +232,7 @@ static u32 ath9k_hw_def_dump_eeprom(stru
- AR5416_OPFLAGS_N_5G_HT20));
- PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags &
- AR5416_OPFLAGS_N_5G_HT40));
-- PR_EEP("Big Endian", !!(pBase->eepMisc & 0x01));
-+ PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN));
- PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF);
- PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF);
- PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -571,6 +571,12 @@ static int ath9k_of_init(struct ath_soft
+
+ ath_dbg(common, CONFIG, "parsing configuration from OF node\n");
+
++ if (of_property_read_bool(np, "qca,disable-2ghz"))
++ ah->disable_2ghz = true;
++
++ if (of_property_read_bool(np, "qca,disable-5ghz"))
++ ah->disable_5ghz = true;
++
+ if (of_property_read_bool(np, "qca,no-eeprom")) {
+ /* ath9k-eeprom-<bus>-<id>.bin */
+ scnprintf(eeprom_name, sizeof(eeprom_name),
+++ /dev/null
-From e88ab4a2649d0fbf675193fb2c176f65375bdd2d Mon Sep 17 00:00:00 2001
-From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-Date: Mon, 3 Oct 2016 00:29:08 +0200
-Subject: [v2 PATCH 2/7] ath9k: indicate that the AR9003 EEPROM template values
- are little endian
-
-The eepMisc field was not set explicitly. The default value of 0 means
-that the values in the EEPROM (template) should be interpreted as little
-endian. However, this is not clear until comparing the AR9003 code with
-the other EEPROM formats.
-To make the code easier to understand we explicitly state that the values
-are little endian - there are no functional changes with this patch.
-
-Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
----
- drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 10 +++++-----
- drivers/net/wireless/ath/ath9k/ar9003_eeprom.h | 3 +++
- 2 files changed, 8 insertions(+), 5 deletions(-)
-
---- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
-@@ -53,7 +53,7 @@ static const struct ar9300_eeprom ar9300
- .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
- .opCapFlags = {
- .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
-- .eepMisc = 0,
-+ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
- },
- .rfSilent = 0,
- .blueToothOptions = 0,
-@@ -631,7 +631,7 @@ static const struct ar9300_eeprom ar9300
- .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
- .opCapFlags = {
- .opFlags = AR5416_OPFLAGS_11A,
-- .eepMisc = 0,
-+ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
- },
- .rfSilent = 0,
- .blueToothOptions = 0,
-@@ -1210,7 +1210,7 @@ static const struct ar9300_eeprom ar9300
- .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
- .opCapFlags = {
- .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
-- .eepMisc = 0,
-+ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
- },
- .rfSilent = 0,
- .blueToothOptions = 0,
-@@ -1789,7 +1789,7 @@ static const struct ar9300_eeprom ar9300
- .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
- .opCapFlags = {
- .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
-- .eepMisc = 0,
-+ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
- },
- .rfSilent = 0,
- .blueToothOptions = 0,
-@@ -2367,7 +2367,7 @@ static const struct ar9300_eeprom ar9300
- .txrxMask = 0x33, /* 4 bits tx and 4 bits rx */
- .opCapFlags = {
- .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
-- .eepMisc = 0,
-+ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
- },
- .rfSilent = 0,
- .blueToothOptions = 0,
---- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
-+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
-@@ -69,6 +69,9 @@
- #define AR9300_BASE_ADDR 0x3ff
- #define AR9300_BASE_ADDR_512 0x1ff
-
-+/* AR5416_EEPMISC_BIG_ENDIAN not set indicates little endian */
-+#define AR9300_EEPMISC_LITTLE_ENDIAN 0
-+
- #define AR9300_OTP_BASE \
- ((AR_SREV_9340(ah) || AR_SREV_9550(ah)) ? 0x30000 : 0x14000)
- #define AR9300_OTP_STATUS \
--- /dev/null
+--- a/drivers/net/wireless/ath/ath9k/channel.c
++++ b/drivers/net/wireless/ath/ath9k/channel.c
+@@ -15,6 +15,8 @@
+ */
+
+ #include "ath9k.h"
++#include <linux/ath9k_platform.h>
++#include "hsr.h"
+
+ /* Set/change channels. If the channel is really being changed, it's done
+ * by reseting the chip. To accomplish this we must first cleanup any pending
+@@ -22,6 +24,7 @@
+ */
+ static int ath_set_channel(struct ath_softc *sc)
+ {
++ struct ath9k_platform_data *pdata = sc->dev->platform_data;
+ struct ath_hw *ah = sc->sc_ah;
+ struct ath_common *common = ath9k_hw_common(ah);
+ struct ieee80211_hw *hw = sc->hw;
+@@ -41,6 +44,11 @@ static int ath_set_channel(struct ath_so
+ ath_dbg(common, CONFIG, "Set channel: %d MHz width: %d\n",
+ chan->center_freq, chandef->width);
+
++ if (pdata && pdata->ubnt_hsr) {
++ ath9k_hsr_enable(ah, chandef->width, chan->center_freq);
++ ath9k_hsr_status(ah);
++ }
++
+ /* update survey stats for the old channel before switching */
+ spin_lock_bh(&common->cc_lock);
+ ath_update_survey_stats(sc);
+--- /dev/null
++++ b/drivers/net/wireless/ath/ath9k/hsr.c
+@@ -0,0 +1,247 @@
++/*
++ *
++ * The MIT License (MIT)
++ *
++ * Copyright (c) 2015 Kirill Berezin
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this software and associated documentation files (the "Software"), to deal
++ * in the Software without restriction, including without limitation the rights
++ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the Software is
++ * furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
++ * SOFTWARE.
++ *
++ */
++
++#include <linux/io.h>
++#include <linux/slab.h>
++#include <linux/module.h>
++#include <linux/time.h>
++#include <linux/bitops.h>
++#include <linux/etherdevice.h>
++#include <linux/rtnetlink.h>
++#include <asm/unaligned.h>
++
++#include "hw.h"
++#include "ath9k.h"
++
++#define HSR_GPIO_CSN 8
++#define HSR_GPIO_CLK 6
++#define HSR_GPIO_DOUT 7
++#define HSR_GPIO_DIN 5
++
++/* delays are in useconds */
++#define HSR_DELAY_HALF_TICK 100
++#define HSR_DELAY_PRE_WRITE 75
++#define HSR_DELAY_FINAL 20000
++#define HSR_DELAY_TRAILING 200
++
++void ath9k_hsr_init(struct ath_hw *ah)
++{
++ ath9k_hw_gpio_request_in(ah, HSR_GPIO_DIN, NULL);
++ ath9k_hw_gpio_request_out(ah, HSR_GPIO_CSN, NULL,
++ AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
++ ath9k_hw_gpio_request_out(ah, HSR_GPIO_CLK, NULL,
++ AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
++ ath9k_hw_gpio_request_out(ah, HSR_GPIO_DOUT, NULL,
++ AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
++
++ ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 1);
++ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0);
++ ath9k_hw_set_gpio(ah, HSR_GPIO_DOUT, 0);
++
++ udelay(HSR_DELAY_TRAILING);
++}
++
++static u32 ath9k_hsr_write_byte(struct ath_hw *ah, int delay, u32 value)
++{
++ struct ath_common *common = ath9k_hw_common(ah);
++ int i;
++ u32 rval = 0;
++
++ udelay(delay);
++
++ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0);
++ udelay(HSR_DELAY_HALF_TICK);
++
++ ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 0);
++ udelay(HSR_DELAY_HALF_TICK);
++
++ for (i = 0; i < 8; ++i) {
++ rval = rval << 1;
++
++ /* pattern is left to right, that is 7-th bit runs first */
++ ath9k_hw_set_gpio(ah, HSR_GPIO_DOUT, (value >> (7 - i)) & 0x1);
++ udelay(HSR_DELAY_HALF_TICK);
++
++ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 1);
++ udelay(HSR_DELAY_HALF_TICK);
++
++ rval |= ath9k_hw_gpio_get(ah, HSR_GPIO_DIN);
++
++ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0);
++ udelay(HSR_DELAY_HALF_TICK);
++ }
++
++ ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 1);
++ udelay(HSR_DELAY_HALF_TICK);
++
++ ath_dbg(common, CONFIG, "ath9k_hsr_write_byte: write byte %d return value is %d %c\n",
++ value, rval, rval > 32 ? rval : '-');
++
++ return rval & 0xff;
++}
++
++static int ath9k_hsr_write_a_chain(struct ath_hw *ah, char *chain, int items)
++{
++ int status = 0;
++ int i = 0;
++ int err;
++
++ /* a preamble */
++ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
++ status = ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
++
++ /* clear HSR's reply buffer */
++ if (status) {
++ int loop = 0;
++
++ for (loop = 0; (loop < 42) && status; ++loop)
++ status = ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE,
++ 0);
++
++ if (loop >= 42) {
++ ATH_DBG_WARN(1,
++ "ath9k_hsr_write_a_chain: can't clear an output buffer after a 42 cycles.\n");
++ return -1;
++ }
++ }
++
++ for (i = 0; (i < items) && (chain[i] != 0); ++i)
++ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, (u32)chain[i]);
++
++ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
++ mdelay(HSR_DELAY_FINAL / 1000);
++
++ /* reply */
++ memset(chain, 0, items);
++
++ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
++ udelay(HSR_DELAY_TRAILING);
++
++ for (i = 0; i < (items - 1); ++i) {
++ u32 ret;
++
++ ret = ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
++ if (ret != 0)
++ chain[i] = (char)ret;
++ else
++ break;
++
++ udelay(HSR_DELAY_TRAILING);
++ }
++
++ if (i <= 1)
++ return 0;
++
++ err = kstrtoint(chain + 1, 10, &i);
++ if (err)
++ return err;
++
++ return i;
++}
++
++int ath9k_hsr_disable(struct ath_hw *ah)
++{
++ char cmd[10] = {'b', '4', '0', 0, 0, 0, 0, 0, 0, 0};
++ int ret;
++
++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd));
++ if ((ret > 0) && (*cmd == 'B'))
++ return 0;
++
++ return -1;
++}
++
++int ath9k_hsr_enable(struct ath_hw *ah, int bw, int fq)
++{
++ char cmd[10];
++ int ret;
++
++ /* Bandwidth argument is 0 sometimes. Assume default 802.11bgn
++ * 20MHz on invalid values
++ */
++ if ((bw != 5) && (bw != 10) && (bw != 20) && (bw != 40))
++ bw = 20;
++
++ memset(cmd, 0, sizeof(cmd));
++ *cmd = 'b';
++ snprintf(cmd + 1, 3, "%02d", bw);
++
++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd));
++ if ((*cmd != 'B') || (ret != bw)) {
++ ATH_DBG_WARN(1,
++ "ath9k_hsr_enable: failed changing bandwidth -> set (%d,%d) reply (%d, %d)\n",
++ 'b', bw, *cmd, ret);
++ return -1;
++ }
++
++ memset(cmd, 0, sizeof(cmd));
++ *cmd = 'x';
++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd));
++ if (*cmd != 'X') {
++ ATH_DBG_WARN(1,
++ "ath9k_hsr_enable: failed 'x' command -> reply (%d, %d)\n",
++ *cmd, ret);
++ return -1;
++ }
++
++ memset(cmd, 0, sizeof(cmd));
++ *cmd = 'm';
++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd));
++ if (*cmd != 'M') {
++ ATH_DBG_WARN(1,
++ "ath9k_hsr_enable: failed 'm' command -> reply (%d, %d)\n",
++ *cmd, ret);
++ return -1;
++ }
++
++ memset(cmd, 0, sizeof(cmd));
++ *cmd = 'f';
++ snprintf(cmd + 1, 6, "%05d", fq);
++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd));
++ if ((*cmd != 'F') && (ret != fq)) {
++ ATH_DBG_WARN(1,
++ "ath9k_hsr_enable: failed set frequency -> reply (%d, %d)\n",
++ *cmd, ret);
++ return -1;
++ }
++
++ return 0;
++}
++
++int ath9k_hsr_status(struct ath_hw *ah)
++{
++ char cmd[10] = {'s', 0, 0, 0, 0, 0, 0, 0, 0, 0};
++ int ret;
++
++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd));
++ if (*cmd != 'S') {
++ ATH_DBG_WARN(1, "ath9k_hsr_status: returned %d,%d\n", *cmd,
++ ret);
++ return -1;
++ }
++
++ return 0;
++}
+--- /dev/null
++++ b/drivers/net/wireless/ath/ath9k/hsr.h
+@@ -0,0 +1,48 @@
++/*
++ * The MIT License (MIT)
++ *
++ * Copyright (c) 2015 Kirill Berezin
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this software and associated documentation files (the "Software"), to deal
++ * in the Software without restriction, including without limitation the rights
++ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the Software is
++ * furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
++ * SOFTWARE.
++ */
++
++#ifndef HSR_H
++#define HSR_H
++
++#ifdef CPTCFG_ATH9K_UBNTHSR
++
++void ath9k_hsr_init(struct ath_hw *ah);
++int ath9k_hsr_disable(struct ath_hw *ah);
++int ath9k_hsr_enable(struct ath_hw *ah, int bw, int fq);
++int ath9k_hsr_status(struct ath_hw *ah);
++
++#else
++static inline void ath9k_hsr_init(struct ath_hw *ah) {}
++
++static inline int ath9k_hsr_enable(struct ath_hw *ah, int bw, int fq)
++{
++ return 0;
++}
++
++static inline int ath9k_hsr_disable(struct ath_hw *ah) { return 0; }
++static inline int ath9k_hsr_status(struct ath_hw *ah) { return 0; }
++
++#endif
++
++#endif /* HSR_H */
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -16,8 +16,10 @@
+
+ #include <linux/nl80211.h>
+ #include <linux/delay.h>
++#include <linux/ath9k_platform.h>
+ #include "ath9k.h"
+ #include "btcoex.h"
++#include "hsr.h"
+
+ u8 ath9k_parse_mpdudensity(u8 mpdudensity)
+ {
+@@ -648,6 +650,7 @@ void ath_reset_work(struct work_struct *
+ static int ath9k_start(struct ieee80211_hw *hw)
+ {
+ struct ath_softc *sc = hw->priv;
++ struct ath9k_platform_data *pdata = sc->dev->platform_data;
+ struct ath_hw *ah = sc->sc_ah;
+ struct ath_common *common = ath9k_hw_common(ah);
+ struct ieee80211_channel *curchan = sc->cur_chan->chandef.chan;
+@@ -726,6 +729,11 @@ static int ath9k_start(struct ieee80211_
+ AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
+ }
+
++ if (pdata && pdata->ubnt_hsr) {
++ ath9k_hsr_init(ah);
++ ath9k_hsr_disable(ah);
++ }
++
+ /*
+ * Reset key cache to sane defaults (all entries cleared) instead of
+ * semi-random values after suspend/resume.
+--- a/drivers/net/wireless/ath/ath9k/Makefile
++++ b/drivers/net/wireless/ath/ath9k/Makefile
+@@ -16,6 +16,7 @@ ath9k-$(CPTCFG_ATH9K_DFS_CERTIFIED) += d
+ ath9k-$(CPTCFG_ATH9K_TX99) += tx99.o
+ ath9k-$(CPTCFG_ATH9K_WOW) += wow.o
+ ath9k-$(CPTCFG_ATH9K_HWRNG) += rng.o
++ath9k-$(CPTCFG_ATH9K_UBNTHSR) += hsr.o
+
+ ath9k-$(CPTCFG_ATH9K_DEBUGFS) += debug.o
+
+--- a/include/linux/ath9k_platform.h
++++ b/include/linux/ath9k_platform.h
+@@ -54,6 +54,8 @@ struct ath9k_platform_data {
+ unsigned num_btns;
+ const struct gpio_keys_button *btns;
+ unsigned btn_poll_interval;
++
++ bool ubnt_hsr;
+ };
+
+ #endif /* _LINUX_ATH9K_PLATFORM_H */
+--- a/.local-symbols
++++ b/.local-symbols
+@@ -157,6 +157,7 @@ ATH9K_WOW=
+ ATH9K_RFKILL=
+ ATH9K_CHANNEL_CONTEXT=
+ ATH9K_PCOEM=
++ATH9K_UBNTHSR=
+ ATH9K_HTC=
+ ATH9K_HTC_DEBUGFS=
+ ATH9K_HWRNG=
+--- a/drivers/net/wireless/ath/ath9k/Kconfig
++++ b/drivers/net/wireless/ath/ath9k/Kconfig
+@@ -59,6 +59,19 @@ config ATH9K_AHB
+ Say Y, if you have a SoC with a compatible built-in
+ wireless MAC. Say N if unsure.
+
++config ATH9K_UBNTHSR
++ bool "Ubiquiti UniFi Outdoor Plus HSR support"
++ depends on ATH9K
++ ---help---
++ This options enables code to control the HSR RF
++ filter in the receive path of the Ubiquiti UniFi
++ Outdoor Plus access point.
++
++ Say Y if you want to use the access point. The
++ code will only be used if the device is detected,
++ so it does not harm other setup other than occupying
++ a bit of memory.
++
+ config ATH9K_DEBUGFS
+ bool "Atheros ath9k debugging"
+ depends on ATH9K && DEBUG_FS
+++ /dev/null
-From e8f60fa28e619ad238457ac84fb292541be180d3 Mon Sep 17 00:00:00 2001
-From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-Date: Mon, 3 Oct 2016 00:29:09 +0200
-Subject: [v2 PATCH 3/7] ath9k: Add an eeprom_ops callback for retrieving the
- eepmisc value
-
-This allows deciding if we have to swap the EEPROM data (so it matches
-the system's native endianness) even if no byte-swapping (swab16, based on
-the first two bytes in the EEPROM) is needed.
-
-Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
----
- drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 8 +++++++-
- drivers/net/wireless/ath/ath9k/eeprom.h | 1 +
- drivers/net/wireless/ath/ath9k/eeprom_4k.c | 8 +++++++-
- drivers/net/wireless/ath/ath9k/eeprom_9287.c | 8 +++++++-
- drivers/net/wireless/ath/ath9k/eeprom_def.c | 8 +++++++-
- 5 files changed, 29 insertions(+), 4 deletions(-)
-
---- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
-@@ -5498,6 +5498,11 @@ unsigned int ar9003_get_paprd_scale_fact
- }
- }
-
-+static u8 ar9003_get_eepmisc(struct ath_hw *ah)
-+{
-+ return ah->eeprom.map4k.baseEepHeader.eepMisc;
-+}
-+
- const struct eeprom_ops eep_ar9300_ops = {
- .check_eeprom = ath9k_hw_ar9300_check_eeprom,
- .get_eeprom = ath9k_hw_ar9300_get_eeprom,
-@@ -5508,5 +5513,6 @@ const struct eeprom_ops eep_ar9300_ops =
- .set_board_values = ath9k_hw_ar9300_set_board_values,
- .set_addac = ath9k_hw_ar9300_set_addac,
- .set_txpower = ath9k_hw_ar9300_set_txpower,
-- .get_spur_channel = ath9k_hw_ar9300_get_spur_channel
-+ .get_spur_channel = ath9k_hw_ar9300_get_spur_channel,
-+ .get_eepmisc = ar9003_get_eepmisc
- };
---- a/drivers/net/wireless/ath/ath9k/eeprom.h
-+++ b/drivers/net/wireless/ath/ath9k/eeprom.h
-@@ -655,6 +655,7 @@ struct eeprom_ops {
- u16 cfgCtl, u8 twiceAntennaReduction,
- u8 powerLimit, bool test);
- u16 (*get_spur_channel)(struct ath_hw *ah, u16 i, bool is2GHz);
-+ u8 (*get_eepmisc)(struct ath_hw *ah);
- };
-
- void ath9k_hw_analog_shift_regwrite(struct ath_hw *ah, u32 reg, u32 val);
---- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
-@@ -1064,6 +1064,11 @@ static u16 ath9k_hw_4k_get_spur_channel(
- return ah->eeprom.map4k.modalHeader.spurChans[i].spurChan;
- }
-
-+static u8 ath9k_hw_4k_get_eepmisc(struct ath_hw *ah)
-+{
-+ return ah->eeprom.map4k.baseEepHeader.eepMisc;
-+}
-+
- const struct eeprom_ops eep_4k_ops = {
- .check_eeprom = ath9k_hw_4k_check_eeprom,
- .get_eeprom = ath9k_hw_4k_get_eeprom,
-@@ -1073,5 +1078,6 @@ const struct eeprom_ops eep_4k_ops = {
- .get_eeprom_rev = ath9k_hw_4k_get_eeprom_rev,
- .set_board_values = ath9k_hw_4k_set_board_values,
- .set_txpower = ath9k_hw_4k_set_txpower,
-- .get_spur_channel = ath9k_hw_4k_get_spur_channel
-+ .get_spur_channel = ath9k_hw_4k_get_spur_channel,
-+ .get_eepmisc = ath9k_hw_4k_get_eepmisc
- };
---- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
-@@ -986,6 +986,11 @@ static u16 ath9k_hw_ar9287_get_spur_chan
- return ah->eeprom.map9287.modalHeader.spurChans[i].spurChan;
- }
-
-+static u8 ath9k_hw_ar9287_get_eepmisc(struct ath_hw *ah)
-+{
-+ return ah->eeprom.map9287.baseEepHeader.eepMisc;
-+}
-+
- const struct eeprom_ops eep_ar9287_ops = {
- .check_eeprom = ath9k_hw_ar9287_check_eeprom,
- .get_eeprom = ath9k_hw_ar9287_get_eeprom,
-@@ -995,5 +1000,6 @@ const struct eeprom_ops eep_ar9287_ops =
- .get_eeprom_rev = ath9k_hw_ar9287_get_eeprom_rev,
- .set_board_values = ath9k_hw_ar9287_set_board_values,
- .set_txpower = ath9k_hw_ar9287_set_txpower,
-- .get_spur_channel = ath9k_hw_ar9287_get_spur_channel
-+ .get_spur_channel = ath9k_hw_ar9287_get_spur_channel,
-+ .get_eepmisc = ath9k_hw_ar9287_get_eepmisc
- };
---- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
-@@ -1317,6 +1317,11 @@ static u16 ath9k_hw_def_get_spur_channel
- return ah->eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan;
- }
-
-+static u8 ath9k_hw_def_get_eepmisc(struct ath_hw *ah)
-+{
-+ return ah->eeprom.def.baseEepHeader.eepMisc;
-+}
-+
- const struct eeprom_ops eep_def_ops = {
- .check_eeprom = ath9k_hw_def_check_eeprom,
- .get_eeprom = ath9k_hw_def_get_eeprom,
-@@ -1327,5 +1332,6 @@ const struct eeprom_ops eep_def_ops = {
- .set_board_values = ath9k_hw_def_set_board_values,
- .set_addac = ath9k_hw_def_set_addac,
- .set_txpower = ath9k_hw_def_set_txpower,
-- .get_spur_channel = ath9k_hw_def_get_spur_channel
-+ .get_spur_channel = ath9k_hw_def_get_spur_channel,
-+ .get_eepmisc = ath9k_hw_def_get_eepmisc
- };
+++ /dev/null
-From 9f247f908d5166e16e1cc6a50b0901e0f6733410 Mon Sep 17 00:00:00 2001
-From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-Date: Mon, 3 Oct 2016 00:29:10 +0200
-Subject: [v2 PATCH 4/7] ath9k: replace eeprom_param EEP_MINOR_REV with
- get_eeprom_rev
-
-get_eeprom(ah, EEP_MINOR_REV) and get_eeprom_rev(ah) are both doing the
-same thing: returning the EEPROM revision (12 lowest bits). Make the
-code consistent by using get_eeprom_rev(ah) everywhere.
-
-Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
----
- drivers/net/wireless/ath/ath9k/ar5008_phy.c | 2 +-
- drivers/net/wireless/ath/ath9k/ar9002_hw.c | 6 ++----
- drivers/net/wireless/ath/ath9k/eeprom.h | 1 -
- drivers/net/wireless/ath/ath9k/eeprom_4k.c | 5 -----
- drivers/net/wireless/ath/ath9k/eeprom_9287.c | 6 +-----
- drivers/net/wireless/ath/ath9k/eeprom_def.c | 2 --
- 6 files changed, 4 insertions(+), 18 deletions(-)
-
---- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
-+++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
-@@ -524,7 +524,7 @@ static bool ar5008_hw_set_rf_regs(struct
- return true;
-
- /* Setup rf parameters */
-- eepMinorRev = ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV);
-+ eepMinorRev = ah->eep_ops->get_eeprom_rev(ah);
-
- for (i = 0; i < ah->iniBank6.ia_rows; i++)
- ah->analogBank6Data[i] = INI_RA(&ah->iniBank6, i, modesIndex);
---- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
-+++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
-@@ -108,8 +108,7 @@ static void ar9280_20_hw_init_rxgain_ini
- {
- u32 rxgain_type;
-
-- if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >=
-- AR5416_EEP_MINOR_VER_17) {
-+ if (ah->eep_ops->get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_17) {
- rxgain_type = ah->eep_ops->get_eeprom(ah, EEP_RXGAIN_TYPE);
-
- if (rxgain_type == AR5416_EEP_RXGAIN_13DB_BACKOFF)
-@@ -129,8 +128,7 @@ static void ar9280_20_hw_init_rxgain_ini
-
- static void ar9280_20_hw_init_txgain_ini(struct ath_hw *ah, u32 txgain_type)
- {
-- if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >=
-- AR5416_EEP_MINOR_VER_19) {
-+ if (ah->eep_ops->get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_19) {
- if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER)
- INIT_INI_ARRAY(&ah->iniModesTxGain,
- ar9280Modes_high_power_tx_gain_9280_2);
---- a/drivers/net/wireless/ath/ath9k/eeprom.h
-+++ b/drivers/net/wireless/ath/ath9k/eeprom.h
-@@ -230,7 +230,6 @@ enum eeprom_param {
- EEP_DB_5,
- EEP_OB_2,
- EEP_DB_2,
-- EEP_MINOR_REV,
- EEP_TX_MASK,
- EEP_RX_MASK,
- EEP_FSTCLK_5G,
---- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
-@@ -254,9 +254,6 @@ static u32 ath9k_hw_4k_get_eeprom(struct
- struct ar5416_eeprom_4k *eep = &ah->eeprom.map4k;
- struct modal_eep_4k_header *pModal = &eep->modalHeader;
- struct base_eep_header_4k *pBase = &eep->baseEepHeader;
-- u16 ver_minor;
--
-- ver_minor = pBase->version & AR5416_EEP_VER_MINOR_MASK;
-
- switch (param) {
- case EEP_NFTHRESH_2:
-@@ -279,8 +276,6 @@ static u32 ath9k_hw_4k_get_eeprom(struct
- return pModal->ob_0;
- case EEP_DB_2:
- return pModal->db1_1;
-- case EEP_MINOR_REV:
-- return ver_minor;
- case EEP_TX_MASK:
- return pBase->txMask;
- case EEP_RX_MASK:
---- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
-@@ -250,9 +250,7 @@ static u32 ath9k_hw_ar9287_get_eeprom(st
- struct ar9287_eeprom *eep = &ah->eeprom.map9287;
- struct modal_eep_ar9287_header *pModal = &eep->modalHeader;
- struct base_eep_ar9287_header *pBase = &eep->baseEepHeader;
-- u16 ver_minor;
--
-- ver_minor = pBase->version & AR9287_EEP_VER_MINOR_MASK;
-+ u16 ver_minor = ath9k_hw_ar9287_get_eeprom_rev(ah);
-
- switch (param) {
- case EEP_NFTHRESH_2:
-@@ -271,8 +269,6 @@ static u32 ath9k_hw_ar9287_get_eeprom(st
- return pBase->opCapFlags;
- case EEP_RF_SILENT:
- return pBase->rfSilent;
-- case EEP_MINOR_REV:
-- return ver_minor;
- case EEP_TX_MASK:
- return pBase->txMask;
- case EEP_RX_MASK:
---- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
-@@ -380,8 +380,6 @@ static u32 ath9k_hw_def_get_eeprom(struc
- return pModal[1].ob;
- case EEP_DB_2:
- return pModal[1].db;
-- case EEP_MINOR_REV:
-- return AR5416_VER_MASK;
- case EEP_TX_MASK:
- return pBase->txMask;
- case EEP_RX_MASK:
+++ /dev/null
-From c763af71bcc2f01bd5ef6e65c7c34b46c7235a16 Mon Sep 17 00:00:00 2001
-From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-Date: Mon, 3 Oct 2016 00:29:11 +0200
-Subject: [v2 PATCH 5/7] ath9k: consistently use get_eeprom_rev(ah)
-
-The AR5416_VER_MASK macro does the same as get_eeprom_rev, except that
-one has to know the actual EEPROM type (and providing a reference to
-that in a variable named "eep"). Additionally the eeprom_*.c
-implementations used the same shifting logic multiple times to get the
-eeprom revision which was also unnecessary duplication of
-get_eeprom_rev.
-
-Also use the AR5416_EEP_VER_MINOR_MASK macro where needed and introduce
-a similar macro (AR5416_EEP_VER_MAJOR_MASK) for the major version.
-Finally drop AR9287_EEP_VER_MINOR_MASK since it simply duplicates the
-already defined AR5416_EEP_VER_MINOR_MASK.
-
-Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
----
- drivers/net/wireless/ath/ath9k/eeprom.h | 4 +--
- drivers/net/wireless/ath/ath9k/eeprom_4k.c | 32 ++++++++++------------
- drivers/net/wireless/ath/ath9k/eeprom_9287.c | 19 +++++++------
- drivers/net/wireless/ath/ath9k/eeprom_def.c | 41 +++++++++++++++-------------
- drivers/net/wireless/ath/ath9k/xmit.c | 3 +-
- 5 files changed, 52 insertions(+), 47 deletions(-)
-
---- a/drivers/net/wireless/ath/ath9k/eeprom.h
-+++ b/drivers/net/wireless/ath/ath9k/eeprom.h
-@@ -99,7 +99,6 @@
- #define FBIN2FREQ(x, y) ((y) ? (2300 + x) : (4800 + 5 * x))
- #define ath9k_hw_use_flash(_ah) (!(_ah->ah_flags & AH_USE_EEPROM))
-
--#define AR5416_VER_MASK (eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK)
- #define OLC_FOR_AR9280_20_LATER (AR_SREV_9280_20_OR_LATER(ah) && \
- ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
- #define OLC_FOR_AR9287_10_LATER (AR_SREV_9287_11_OR_LATER(ah) && \
-@@ -121,6 +120,8 @@
-
- #define AR5416_EEP_NO_BACK_VER 0x1
- #define AR5416_EEP_VER 0xE
-+#define AR5416_EEP_VER_MAJOR_SHIFT 12
-+#define AR5416_EEP_VER_MAJOR_MASK 0xF000
- #define AR5416_EEP_VER_MINOR_MASK 0x0FFF
- #define AR5416_EEP_MINOR_VER_2 0x2
- #define AR5416_EEP_MINOR_VER_3 0x3
-@@ -177,7 +178,6 @@
- #define AR9280_TX_GAIN_TABLE_SIZE 22
-
- #define AR9287_EEP_VER 0xE
--#define AR9287_EEP_VER_MINOR_MASK 0xFFF
- #define AR9287_EEP_MINOR_VER_1 0x1
- #define AR9287_EEP_MINOR_VER_2 0x2
- #define AR9287_EEP_MINOR_VER_3 0x3
---- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
-@@ -20,12 +20,17 @@
-
- static int ath9k_hw_4k_get_eeprom_ver(struct ath_hw *ah)
- {
-- return ((ah->eeprom.map4k.baseEepHeader.version >> 12) & 0xF);
-+ u16 version = ah->eeprom.map4k.baseEepHeader.version;
-+
-+ return (version & AR5416_EEP_VER_MAJOR_MASK) >>
-+ AR5416_EEP_VER_MAJOR_SHIFT;
- }
-
- static int ath9k_hw_4k_get_eeprom_rev(struct ath_hw *ah)
- {
-- return ((ah->eeprom.map4k.baseEepHeader.version) & 0xFFF);
-+ u16 version = ah->eeprom.map4k.baseEepHeader.version;
-+
-+ return version & AR5416_EEP_VER_MINOR_MASK;
- }
-
- #define SIZE_EEPROM_4K (sizeof(struct ar5416_eeprom_4k) / sizeof(u16))
-@@ -136,8 +141,8 @@ static u32 ath9k_hw_4k_dump_eeprom(struc
- goto out;
- }
-
-- PR_EEP("Major Version", pBase->version >> 12);
-- PR_EEP("Minor Version", pBase->version & 0xFFF);
-+ PR_EEP("Major Version", ath9k_hw_4k_get_eeprom_ver(ah));
-+ PR_EEP("Minor Version", ath9k_hw_4k_get_eeprom_rev(ah));
- PR_EEP("Checksum", pBase->checksum);
- PR_EEP("Length", pBase->length);
- PR_EEP("RegDomain1", pBase->regDmn[0]);
-@@ -314,14 +319,12 @@ static void ath9k_hw_set_4k_power_cal_ta
-
- xpdMask = pEepData->modalHeader.xpdGain;
-
-- if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
-- AR5416_EEP_MINOR_VER_2) {
-+ if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2)
- pdGainOverlap_t2 =
- pEepData->modalHeader.pdGainOverlap;
-- } else {
-+ else
- pdGainOverlap_t2 = (u16)(MS(REG_READ(ah, AR_PHY_TPCRG5),
- AR_PHY_TPCRG5_PD_GAIN_OVERLAP));
-- }
-
- pCalBChans = pEepData->calFreqPier2G;
- numPiers = AR5416_EEP4K_NUM_2G_CAL_PIERS;
-@@ -607,10 +610,8 @@ static void ath9k_hw_4k_set_txpower(stru
-
- memset(ratesArray, 0, sizeof(ratesArray));
-
-- if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
-- AR5416_EEP_MINOR_VER_2) {
-+ if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2)
- ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
-- }
-
- ath9k_hw_set_4k_power_per_rate_table(ah, chan,
- &ratesArray[0], cfgCtl,
-@@ -730,8 +731,7 @@ static void ath9k_hw_4k_set_gain(struct
- SM(pModal->iqCalQCh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF),
- AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF | AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF);
-
-- if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
-- AR5416_EEP_MINOR_VER_3) {
-+ if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) {
- txRxAttenLocal = pModal->txRxAttenCh[0];
-
- REG_RMW_FIELD(ah, AR_PHY_GAIN_2GHZ,
-@@ -1009,16 +1009,14 @@ static void ath9k_hw_4k_set_board_values
- REG_RMW_FIELD(ah, AR_PHY_EXT_CCA0, AR_PHY_EXT_CCA0_THRESH62,
- pModal->thresh62);
-
-- if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
-- AR5416_EEP_MINOR_VER_2) {
-+ if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2) {
- REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_END_DATA_START,
- pModal->txFrameToDataStart);
- REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_END_PA_ON,
- pModal->txFrameToPaOn);
- }
-
-- if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
-- AR5416_EEP_MINOR_VER_3) {
-+ if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) {
- if (IS_CHAN_HT40(chan))
- REG_RMW_FIELD(ah, AR_PHY_SETTLING,
- AR_PHY_SETTLING_SWITCH,
---- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
-@@ -22,12 +22,17 @@
-
- static int ath9k_hw_ar9287_get_eeprom_ver(struct ath_hw *ah)
- {
-- return (ah->eeprom.map9287.baseEepHeader.version >> 12) & 0xF;
-+ u16 version = ah->eeprom.map9287.baseEepHeader.version;
-+
-+ return (version & AR5416_EEP_VER_MAJOR_MASK) >>
-+ AR5416_EEP_VER_MAJOR_SHIFT;
- }
-
- static int ath9k_hw_ar9287_get_eeprom_rev(struct ath_hw *ah)
- {
-- return (ah->eeprom.map9287.baseEepHeader.version) & 0xFFF;
-+ u16 version = ah->eeprom.map9287.baseEepHeader.version;
-+
-+ return version & AR5416_EEP_VER_MINOR_MASK;
- }
-
- static bool __ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah)
-@@ -132,8 +137,8 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
- goto out;
- }
-
-- PR_EEP("Major Version", pBase->version >> 12);
-- PR_EEP("Minor Version", pBase->version & 0xFFF);
-+ PR_EEP("Major Version", ath9k_hw_ar9287_get_eeprom_ver(ah));
-+ PR_EEP("Minor Version", ath9k_hw_ar9287_get_eeprom_rev(ah));
- PR_EEP("Checksum", pBase->checksum);
- PR_EEP("Length", pBase->length);
- PR_EEP("RegDomain1", pBase->regDmn[0]);
-@@ -383,8 +388,7 @@ static void ath9k_hw_set_ar9287_power_ca
-
- xpdMask = pEepData->modalHeader.xpdGain;
-
-- if ((pEepData->baseEepHeader.version & AR9287_EEP_VER_MINOR_MASK) >=
-- AR9287_EEP_MINOR_VER_2)
-+ if (ath9k_hw_ar9287_get_eeprom_rev(ah) >= AR9287_EEP_MINOR_VER_2)
- pdGainOverlap_t2 = pEepData->modalHeader.pdGainOverlap;
- else
- pdGainOverlap_t2 = (u16)(MS(REG_READ(ah, AR_PHY_TPCRG5),
-@@ -733,8 +737,7 @@ static void ath9k_hw_ar9287_set_txpower(
-
- memset(ratesArray, 0, sizeof(ratesArray));
-
-- if ((pEepData->baseEepHeader.version & AR9287_EEP_VER_MINOR_MASK) >=
-- AR9287_EEP_MINOR_VER_2)
-+ if (ath9k_hw_ar9287_get_eeprom_rev(ah) >= AR9287_EEP_MINOR_VER_2)
- ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
-
- ath9k_hw_set_ar9287_power_per_rate_table(ah, chan,
---- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
-@@ -79,12 +79,17 @@ static void ath9k_olc_get_pdadcs(struct
-
- static int ath9k_hw_def_get_eeprom_ver(struct ath_hw *ah)
- {
-- return ((ah->eeprom.def.baseEepHeader.version >> 12) & 0xF);
-+ u16 version = ah->eeprom.def.baseEepHeader.version;
-+
-+ return (version & AR5416_EEP_VER_MAJOR_MASK) >>
-+ AR5416_EEP_VER_MAJOR_SHIFT;
- }
-
- static int ath9k_hw_def_get_eeprom_rev(struct ath_hw *ah)
- {
-- return ((ah->eeprom.def.baseEepHeader.version) & 0xFFF);
-+ u16 version = ah->eeprom.def.baseEepHeader.version;
-+
-+ return version & AR5416_EEP_VER_MINOR_MASK;
- }
-
- #define SIZE_EEPROM_DEF (sizeof(struct ar5416_eeprom_def) / sizeof(u16))
-@@ -214,8 +219,8 @@ static u32 ath9k_hw_def_dump_eeprom(stru
- goto out;
- }
-
-- PR_EEP("Major Version", pBase->version >> 12);
-- PR_EEP("Minor Version", pBase->version & 0xFFF);
-+ PR_EEP("Major Version", ath9k_hw_def_get_eeprom_ver(ah));
-+ PR_EEP("Minor Version", ath9k_hw_def_get_eeprom_rev(ah));
- PR_EEP("Checksum", pBase->checksum);
- PR_EEP("Length", pBase->length);
- PR_EEP("RegDomain1", pBase->regDmn[0]);
-@@ -391,27 +396,27 @@ static u32 ath9k_hw_def_get_eeprom(struc
- case EEP_TXGAIN_TYPE:
- return pBase->txGainType;
- case EEP_OL_PWRCTRL:
-- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19)
-+ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_19)
- return pBase->openLoopPwrCntl ? true : false;
- else
- return false;
- case EEP_RC_CHAIN_MASK:
-- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19)
-+ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_19)
- return pBase->rcChainMask;
- else
- return 0;
- case EEP_DAC_HPWR_5G:
-- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_20)
-+ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_20)
- return pBase->dacHiPwrMode_5G;
- else
- return 0;
- case EEP_FRAC_N_5G:
-- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_22)
-+ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_22)
- return pBase->frac_n_5g;
- else
- return 0;
- case EEP_PWR_TABLE_OFFSET:
-- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_21)
-+ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_21)
- return pBase->pwr_table_offset;
- else
- return AR5416_PWR_TABLE_OFFSET_DB;
-@@ -434,7 +439,7 @@ static void ath9k_hw_def_set_gain(struct
- u8 txRxAttenLocal, int regChainOffset, int i)
- {
- ENABLE_REG_RMW_BUFFER(ah);
-- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_3) {
-+ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) {
- txRxAttenLocal = pModal->txRxAttenCh[i];
-
- if (AR_SREV_9280_20_OR_LATER(ah)) {
-@@ -603,7 +608,7 @@ static void ath9k_hw_def_set_board_value
- pModal->thresh62);
- }
-
-- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_2) {
-+ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2) {
- REG_RMW_FIELD(ah, AR_PHY_RF_CTL2,
- AR_PHY_TX_END_DATA_START,
- pModal->txFrameToDataStart);
-@@ -611,7 +616,7 @@ static void ath9k_hw_def_set_board_value
- pModal->txFrameToPaOn);
- }
-
-- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_3) {
-+ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) {
- if (IS_CHAN_HT40(chan))
- REG_RMW_FIELD(ah, AR_PHY_SETTLING,
- AR_PHY_SETTLING_SWITCH,
-@@ -619,13 +624,14 @@ static void ath9k_hw_def_set_board_value
- }
-
- if (AR_SREV_9280_20_OR_LATER(ah) &&
-- AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19)
-+ ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_19)
- REG_RMW_FIELD(ah, AR_PHY_CCK_TX_CTRL,
- AR_PHY_CCK_TX_CTRL_TX_DAC_SCALE_CCK,
- pModal->miscBits);
-
-
-- if (AR_SREV_9280_20(ah) && AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_20) {
-+ if (AR_SREV_9280_20(ah) &&
-+ ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_20) {
- if (IS_CHAN_2GHZ(chan))
- REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE,
- eep->baseEepHeader.dacLpMode);
-@@ -796,8 +802,7 @@ static void ath9k_hw_set_def_power_cal_t
-
- pwr_table_offset = ah->eep_ops->get_eeprom(ah, EEP_PWR_TABLE_OFFSET);
-
-- if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
-- AR5416_EEP_MINOR_VER_2) {
-+ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2) {
- pdGainOverlap_t2 =
- pEepData->modalHeader[modalIdx].pdGainOverlap;
- } else {
-@@ -1169,10 +1174,8 @@ static void ath9k_hw_def_set_txpower(str
-
- memset(ratesArray, 0, sizeof(ratesArray));
-
-- if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
-- AR5416_EEP_MINOR_VER_2) {
-+ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2)
- ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
-- }
-
- ath9k_hw_set_def_power_per_rate_table(ah, chan,
- &ratesArray[0], cfgCtl,
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -1177,8 +1177,9 @@ static u8 ath_get_rate_txpower(struct at
- if (is_40) {
- u8 power_ht40delta;
- struct ar5416_eeprom_def *eep = &ah->eeprom.def;
-+ u16 eeprom_rev = ah->eep_ops->get_eeprom_rev(ah);
-
-- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_2) {
-+ if (eeprom_rev >= AR5416_EEP_MINOR_VER_2) {
- bool is_2ghz;
- struct modal_eep_header *pmodal;
-
+++ /dev/null
-From 1f796f9265c10384a274ac330f671ef4ac6d56e5 Mon Sep 17 00:00:00 2001
-From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-Date: Mon, 3 Oct 2016 00:29:12 +0200
-Subject: [v2 PATCH 6/7] ath9k: Make the EEPROM swapping check use the eepmisc
- register
-
-There are two ways of swapping the EEPROM data in the ath9k driver:
-1) swab16 based on the first two EEPROM "magic" bytes (same for all
- EEPROM formats)
-2) field and EEPROM format specific swab16/swab32 (different for
- eeprom_def, eeprom_4k and eeprom_9287)
-
-The result of the first check was used to also enable the second swap.
-This behavior seems incorrect, since the data may only be byte-swapped
-(afterwards the data could be in the correct endianness).
-Thus we introduce a separate check based on the "eepmisc" register
-(which is part of the EEPROM data). When bit 0 is set, then the EEPROM
-format specific values are in "big endian". This is also done by the
-FreeBSD kernel, see [0] for example.
-
-This allows us to parse EEPROMs with the "correct" magic bytes but
-swapped EEPROM format specific values. These EEPROMs (mostly found in
-lantiq and broadcom based big endian MIPS based devices) only worked
-due to platform specific "hacks" which swapped the EEPROM so the
-magic was inverted, which also enabled the format specific swapping.
-With this patch the old behavior is still supported, but neither
-recommended nor needed anymore.
-
-[0]
-https://github.com/freebsd/freebsd/blob/50719b56d9ce8d7d4beb53b16e9edb2e9a4a7a18/sys/dev/ath/ath_hal/ah_eeprom_9287.c#L351
-
-Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
----
- drivers/net/wireless/ath/ath9k/eeprom.c | 57 ++++++++++++++++++++++++---------
- 1 file changed, 41 insertions(+), 16 deletions(-)
-
---- a/drivers/net/wireless/ath/ath9k/eeprom.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
-@@ -155,11 +155,19 @@ bool ath9k_hw_nvram_read(struct ath_hw *
- return ret;
- }
-
-+#ifdef __BIG_ENDIAN
-+#define EXPECTED_EEPMISC_ENDIAN AR5416_EEPMISC_BIG_ENDIAN
-+#else
-+#define EXPECTED_EEPMISC_ENDIAN 0
-+#endif
-+
- int ath9k_hw_nvram_swap_data(struct ath_hw *ah, bool *swap_needed, int size)
- {
- u16 magic;
- u16 *eepdata;
-+ u8 eepmisc;
- int i;
-+ bool needs_byteswap = false;
- struct ath_common *common = ath9k_hw_common(ah);
-
- if (!ath9k_hw_nvram_read(ah, AR5416_EEPROM_MAGIC_OFFSET, &magic)) {
-@@ -167,36 +175,53 @@ int ath9k_hw_nvram_swap_data(struct ath_
- return -EIO;
- }
-
-- *swap_needed = false;
- if (swab16(magic) == AR5416_EEPROM_MAGIC) {
-+ needs_byteswap = true;
-+ ath_dbg(common, EEPROM,
-+ "EEPROM needs byte-swapping to correct endianness.\n");
-+ } else if (magic != AR5416_EEPROM_MAGIC) {
-+ if (ath9k_hw_use_flash(ah)) {
-+ ath_dbg(common, EEPROM,
-+ "Ignoring invalid EEPROM magic (0x%04x).\n",
-+ magic);
-+ } else {
-+ ath_err(common,
-+ "Invalid EEPROM magic (0x%04x).\n", magic);
-+ return -EINVAL;
-+ }
-+ }
-+
-+ if (needs_byteswap) {
- if (ah->ah_flags & AH_NO_EEP_SWAP) {
- ath_info(common,
- "Ignoring endianness difference in EEPROM magic bytes.\n");
- } else {
-- *swap_needed = true;
-- }
-- } else if (magic != AR5416_EEPROM_MAGIC) {
-- if (ath9k_hw_use_flash(ah))
-- return 0;
-+ eepdata = (u16 *)(&ah->eeprom);
-
-- ath_err(common,
-- "Invalid EEPROM Magic (0x%04x).\n", magic);
-- return -EINVAL;
-+ for (i = 0; i < size; i++)
-+ eepdata[i] = swab16(eepdata[i]);
-+ }
- }
-
-- eepdata = (u16 *)(&ah->eeprom);
--
-- if (*swap_needed) {
-- ath_dbg(common, EEPROM,
-- "EEPROM Endianness is not native.. Changing.\n");
-+ *swap_needed = false;
-
-- for (i = 0; i < size; i++)
-- eepdata[i] = swab16(eepdata[i]);
-+ eepmisc = ah->eep_ops->get_eepmisc(ah);
-+ if ((eepmisc & AR5416_EEPMISC_BIG_ENDIAN) != EXPECTED_EEPMISC_ENDIAN) {
-+ if (ah->ah_flags & AH_NO_EEP_SWAP) {
-+ ath_info(common,
-+ "Ignoring endianness difference in eepmisc register.\n");
-+ } else {
-+ *swap_needed = true;
-+ ath_dbg(common, EEPROM,
-+ "EEPROM needs swapping according to the eepmisc register.\n");
-+ }
- }
-
- return 0;
- }
-
-+#undef EXPECTED_EEPMISC_VAL
-+
- bool ath9k_hw_nvram_validate_checksum(struct ath_hw *ah, int size)
- {
- u32 i, sum = 0;
+++ /dev/null
-From 7e1047f3cf8dcdb4825f3c785f7f708d07508096 Mon Sep 17 00:00:00 2001
-From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-Date: Mon, 3 Oct 2016 00:29:13 +0200
-Subject: [v2 PATCH 7/7] ath9k: define all EEPROM fields in Little Endian format
-
-The ar9300_eeprom logic is already using only 8-bit (endian neutral),
-__le16 and __le32 fields to state explicitly how the values should be
-interpreted.
-All other EEPROM implementations (4k, 9287 and def) were using u16 and
-u32 fields with additional logic to swap the values (read from the
-original EEPROM) so they match the current CPUs endianness.
-
-The EEPROM format defaults to "all values are Little Endian", indicated
-by the absence of the AR5416_EEPMISC_BIG_ENDIAN in the u8 EEPMISC
-register. If we detect that the EEPROM indicates Big Endian mode
-(AR5416_EEPMISC_BIG_ENDIAN is set in the EEPMISC register) then we'll
-swap the values to convert them into Little Endian. This is done by
-activating the EEPMISC based logic in ath9k_hw_nvram_swap_data even if
-AH_NO_EEP_SWAP is set (this makes ath9k behave like the FreeBSD driver,
-which also does not have a flag to enable swapping based on the
-AR5416_EEPMISC_BIG_ENDIAN bit). Before this logic was only used to
-enable swapping when "current CPU endianness != EEPROM endianness".
-
-After changing all relevant fields to __le16 and __le32 sparse was used
-to check that all code which reads any of these fields uses
-le{16,32}_to_cpu.
-
-Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
----
- drivers/net/wireless/ath/ath9k/eeprom.c | 27 ++-----
- drivers/net/wireless/ath/ath9k/eeprom.h | 75 ++++++++++--------
- drivers/net/wireless/ath/ath9k/eeprom_4k.c | 94 +++++++++-------------
- drivers/net/wireless/ath/ath9k/eeprom_9287.c | 98 ++++++++++-------------
- drivers/net/wireless/ath/ath9k/eeprom_def.c | 114 ++++++++++++---------------
- 5 files changed, 174 insertions(+), 234 deletions(-)
-
---- a/drivers/net/wireless/ath/ath9k/eeprom.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
-@@ -155,17 +155,10 @@ bool ath9k_hw_nvram_read(struct ath_hw *
- return ret;
- }
-
--#ifdef __BIG_ENDIAN
--#define EXPECTED_EEPMISC_ENDIAN AR5416_EEPMISC_BIG_ENDIAN
--#else
--#define EXPECTED_EEPMISC_ENDIAN 0
--#endif
--
- int ath9k_hw_nvram_swap_data(struct ath_hw *ah, bool *swap_needed, int size)
- {
- u16 magic;
- u16 *eepdata;
-- u8 eepmisc;
- int i;
- bool needs_byteswap = false;
- struct ath_common *common = ath9k_hw_common(ah);
-@@ -203,25 +196,17 @@ int ath9k_hw_nvram_swap_data(struct ath_
- }
- }
-
-- *swap_needed = false;
--
-- eepmisc = ah->eep_ops->get_eepmisc(ah);
-- if ((eepmisc & AR5416_EEPMISC_BIG_ENDIAN) != EXPECTED_EEPMISC_ENDIAN) {
-- if (ah->ah_flags & AH_NO_EEP_SWAP) {
-- ath_info(common,
-- "Ignoring endianness difference in eepmisc register.\n");
-- } else {
-- *swap_needed = true;
-- ath_dbg(common, EEPROM,
-- "EEPROM needs swapping according to the eepmisc register.\n");
-- }
-+ if (ah->eep_ops->get_eepmisc(ah) & AR5416_EEPMISC_BIG_ENDIAN) {
-+ *swap_needed = true;
-+ ath_dbg(common, EEPROM,
-+ "Big Endian EEPROM detected according to EEPMISC register.\n");
-+ } else {
-+ *swap_needed = false;
- }
-
- return 0;
- }
-
--#undef EXPECTED_EEPMISC_VAL
--
- bool ath9k_hw_nvram_validate_checksum(struct ath_hw *ah, int size)
- {
- u32 i, sum = 0;
---- a/drivers/net/wireless/ath/ath9k/eeprom.h
-+++ b/drivers/net/wireless/ath/ath9k/eeprom.h
-@@ -23,6 +23,17 @@
- #include <net/cfg80211.h>
- #include "ar9003_eeprom.h"
-
-+/* helpers to swap EEPROM fields, which are stored as __le16 or __le32. Since
-+ * we are 100% sure about it we __force these to u16/u32 for the swab calls to
-+ * silence the sparse checks. These macros are used when we have a Big Endian
-+ * EEPROM (according to AR5416_EEPMISC_BIG_ENDIAN) and need to convert the
-+ * fields to __le16/__le32.
-+ */
-+#define EEPROM_FIELD_SWAB16(field) \
-+ (field = (__force __le16)swab16((__force u16)field))
-+#define EEPROM_FIELD_SWAB32(field) \
-+ (field = (__force __le32)swab32((__force u32)field))
-+
- #ifdef __BIG_ENDIAN
- #define AR5416_EEPROM_MAGIC 0x5aa5
- #else
-@@ -270,19 +281,19 @@ enum ath9k_hal_freq_band {
- };
-
- struct base_eep_header {
-- u16 length;
-- u16 checksum;
-- u16 version;
-+ __le16 length;
-+ __le16 checksum;
-+ __le16 version;
- u8 opCapFlags;
- u8 eepMisc;
-- u16 regDmn[2];
-+ __le16 regDmn[2];
- u8 macAddr[6];
- u8 rxMask;
- u8 txMask;
-- u16 rfSilent;
-- u16 blueToothOptions;
-- u16 deviceCap;
-- u32 binBuildNumber;
-+ __le16 rfSilent;
-+ __le16 blueToothOptions;
-+ __le16 deviceCap;
-+ __le32 binBuildNumber;
- u8 deviceType;
- u8 pwdclkind;
- u8 fastClk5g;
-@@ -300,33 +311,33 @@ struct base_eep_header {
- } __packed;
-
- struct base_eep_header_4k {
-- u16 length;
-- u16 checksum;
-- u16 version;
-+ __le16 length;
-+ __le16 checksum;
-+ __le16 version;
- u8 opCapFlags;
- u8 eepMisc;
-- u16 regDmn[2];
-+ __le16 regDmn[2];
- u8 macAddr[6];
- u8 rxMask;
- u8 txMask;
-- u16 rfSilent;
-- u16 blueToothOptions;
-- u16 deviceCap;
-- u32 binBuildNumber;
-+ __le16 rfSilent;
-+ __le16 blueToothOptions;
-+ __le16 deviceCap;
-+ __le32 binBuildNumber;
- u8 deviceType;
- u8 txGainType;
- } __packed;
-
-
- struct spur_chan {
-- u16 spurChan;
-+ __le16 spurChan;
- u8 spurRangeLow;
- u8 spurRangeHigh;
- } __packed;
-
- struct modal_eep_header {
-- u32 antCtrlChain[AR5416_MAX_CHAINS];
-- u32 antCtrlCommon;
-+ __le32 antCtrlChain[AR5416_MAX_CHAINS];
-+ __le32 antCtrlCommon;
- u8 antennaGainCh[AR5416_MAX_CHAINS];
- u8 switchSettling;
- u8 txRxAttenCh[AR5416_MAX_CHAINS];
-@@ -361,7 +372,7 @@ struct modal_eep_header {
- u8 db_ch1;
- u8 lna_ctl;
- u8 miscBits;
-- u16 xpaBiasLvlFreq[3];
-+ __le16 xpaBiasLvlFreq[3];
- u8 futureModal[6];
-
- struct spur_chan spurChans[AR_EEPROM_MODAL_SPURS];
-@@ -375,8 +386,8 @@ struct calDataPerFreqOpLoop {
- } __packed;
-
- struct modal_eep_4k_header {
-- u32 antCtrlChain[AR5416_EEP4K_MAX_CHAINS];
-- u32 antCtrlCommon;
-+ __le32 antCtrlChain[AR5416_EEP4K_MAX_CHAINS];
-+ __le32 antCtrlCommon;
- u8 antennaGainCh[AR5416_EEP4K_MAX_CHAINS];
- u8 switchSettling;
- u8 txRxAttenCh[AR5416_EEP4K_MAX_CHAINS];
-@@ -440,19 +451,19 @@ struct modal_eep_4k_header {
- } __packed;
-
- struct base_eep_ar9287_header {
-- u16 length;
-- u16 checksum;
-- u16 version;
-+ __le16 length;
-+ __le16 checksum;
-+ __le16 version;
- u8 opCapFlags;
- u8 eepMisc;
-- u16 regDmn[2];
-+ __le16 regDmn[2];
- u8 macAddr[6];
- u8 rxMask;
- u8 txMask;
-- u16 rfSilent;
-- u16 blueToothOptions;
-- u16 deviceCap;
-- u32 binBuildNumber;
-+ __le16 rfSilent;
-+ __le16 blueToothOptions;
-+ __le16 deviceCap;
-+ __le32 binBuildNumber;
- u8 deviceType;
- u8 openLoopPwrCntl;
- int8_t pwrTableOffset;
-@@ -462,8 +473,8 @@ struct base_eep_ar9287_header {
- } __packed;
-
- struct modal_eep_ar9287_header {
-- u32 antCtrlChain[AR9287_MAX_CHAINS];
-- u32 antCtrlCommon;
-+ __le32 antCtrlChain[AR9287_MAX_CHAINS];
-+ __le32 antCtrlCommon;
- int8_t antennaGainCh[AR9287_MAX_CHAINS];
- u8 switchSettling;
- u8 txRxAttenCh[AR9287_MAX_CHAINS];
---- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
-@@ -20,7 +20,7 @@
-
- static int ath9k_hw_4k_get_eeprom_ver(struct ath_hw *ah)
- {
-- u16 version = ah->eeprom.map4k.baseEepHeader.version;
-+ u16 version = le16_to_cpu(ah->eeprom.map4k.baseEepHeader.version);
-
- return (version & AR5416_EEP_VER_MAJOR_MASK) >>
- AR5416_EEP_VER_MAJOR_SHIFT;
-@@ -28,7 +28,7 @@ static int ath9k_hw_4k_get_eeprom_ver(st
-
- static int ath9k_hw_4k_get_eeprom_rev(struct ath_hw *ah)
- {
-- u16 version = ah->eeprom.map4k.baseEepHeader.version;
-+ u16 version = le16_to_cpu(ah->eeprom.map4k.baseEepHeader.version);
-
- return version & AR5416_EEP_VER_MINOR_MASK;
- }
-@@ -76,8 +76,8 @@ static bool ath9k_hw_4k_fill_eeprom(stru
- static u32 ath9k_dump_4k_modal_eeprom(char *buf, u32 len, u32 size,
- struct modal_eep_4k_header *modal_hdr)
- {
-- PR_EEP("Chain0 Ant. Control", modal_hdr->antCtrlChain[0]);
-- PR_EEP("Ant. Common Control", modal_hdr->antCtrlCommon);
-+ PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0]));
-+ PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon));
- PR_EEP("Chain0 Ant. Gain", modal_hdr->antennaGainCh[0]);
- PR_EEP("Switch Settle", modal_hdr->switchSettling);
- PR_EEP("Chain0 TxRxAtten", modal_hdr->txRxAttenCh[0]);
-@@ -132,6 +132,7 @@ static u32 ath9k_hw_4k_dump_eeprom(struc
- {
- struct ar5416_eeprom_4k *eep = &ah->eeprom.map4k;
- struct base_eep_header_4k *pBase = &eep->baseEepHeader;
-+ u32 binBuildNumber = le32_to_cpu(pBase->binBuildNumber);
-
- if (!dump_base_hdr) {
- len += scnprintf(buf + len, size - len,
-@@ -143,10 +144,10 @@ static u32 ath9k_hw_4k_dump_eeprom(struc
-
- PR_EEP("Major Version", ath9k_hw_4k_get_eeprom_ver(ah));
- PR_EEP("Minor Version", ath9k_hw_4k_get_eeprom_rev(ah));
-- PR_EEP("Checksum", pBase->checksum);
-- PR_EEP("Length", pBase->length);
-- PR_EEP("RegDomain1", pBase->regDmn[0]);
-- PR_EEP("RegDomain2", pBase->regDmn[1]);
-+ PR_EEP("Checksum", le16_to_cpu(pBase->checksum));
-+ PR_EEP("Length", le16_to_cpu(pBase->length));
-+ PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0]));
-+ PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1]));
- PR_EEP("TX Mask", pBase->txMask);
- PR_EEP("RX Mask", pBase->rxMask);
- PR_EEP("Allow 5GHz", !!(pBase->opCapFlags & AR5416_OPFLAGS_11A));
-@@ -160,9 +161,9 @@ static u32 ath9k_hw_4k_dump_eeprom(struc
- PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags &
- AR5416_OPFLAGS_N_5G_HT40));
- PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN));
-- PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF);
-- PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF);
-- PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
-+ PR_EEP("Cal Bin Major Ver", (binBuildNumber >> 24) & 0xFF);
-+ PR_EEP("Cal Bin Minor Ver", (binBuildNumber >> 16) & 0xFF);
-+ PR_EEP("Cal Bin Build", (binBuildNumber >> 8) & 0xFF);
- PR_EEP("TX Gain type", pBase->txGainType);
-
- len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
-@@ -194,54 +195,31 @@ static int ath9k_hw_4k_check_eeprom(stru
- return err;
-
- if (need_swap)
-- el = swab16(eep->baseEepHeader.length);
-+ el = swab16((__force u16)eep->baseEepHeader.length);
- else
-- el = eep->baseEepHeader.length;
-+ el = le16_to_cpu(eep->baseEepHeader.length);
-
- el = min(el / sizeof(u16), SIZE_EEPROM_4K);
- if (!ath9k_hw_nvram_validate_checksum(ah, el))
- return -EINVAL;
-
- if (need_swap) {
-- u32 integer;
-- u16 word;
--
-- word = swab16(eep->baseEepHeader.length);
-- eep->baseEepHeader.length = word;
--
-- word = swab16(eep->baseEepHeader.checksum);
-- eep->baseEepHeader.checksum = word;
--
-- word = swab16(eep->baseEepHeader.version);
-- eep->baseEepHeader.version = word;
--
-- word = swab16(eep->baseEepHeader.regDmn[0]);
-- eep->baseEepHeader.regDmn[0] = word;
--
-- word = swab16(eep->baseEepHeader.regDmn[1]);
-- eep->baseEepHeader.regDmn[1] = word;
--
-- word = swab16(eep->baseEepHeader.rfSilent);
-- eep->baseEepHeader.rfSilent = word;
--
-- word = swab16(eep->baseEepHeader.blueToothOptions);
-- eep->baseEepHeader.blueToothOptions = word;
--
-- word = swab16(eep->baseEepHeader.deviceCap);
-- eep->baseEepHeader.deviceCap = word;
--
-- integer = swab32(eep->modalHeader.antCtrlCommon);
-- eep->modalHeader.antCtrlCommon = integer;
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.length);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.checksum);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.version);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[0]);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[1]);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.rfSilent);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.blueToothOptions);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.deviceCap);
-+ EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlCommon);
-
-- for (i = 0; i < AR5416_EEP4K_MAX_CHAINS; i++) {
-- integer = swab32(eep->modalHeader.antCtrlChain[i]);
-- eep->modalHeader.antCtrlChain[i] = integer;
-- }
-+ for (i = 0; i < AR5416_EEP4K_MAX_CHAINS; i++)
-+ EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlChain[i]);
-
-- for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
-- word = swab16(eep->modalHeader.spurChans[i].spurChan);
-- eep->modalHeader.spurChans[i].spurChan = word;
-- }
-+ for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++)
-+ EEPROM_FIELD_SWAB16(
-+ eep->modalHeader.spurChans[i].spurChan);
- }
-
- if (!ath9k_hw_nvram_check_version(ah, AR5416_EEP_VER,
-@@ -270,13 +248,13 @@ static u32 ath9k_hw_4k_get_eeprom(struct
- case EEP_MAC_MSW:
- return get_unaligned_be16(pBase->macAddr + 4);
- case EEP_REG_0:
-- return pBase->regDmn[0];
-+ return le16_to_cpu(pBase->regDmn[0]);
- case EEP_OP_CAP:
-- return pBase->deviceCap;
-+ return le16_to_cpu(pBase->deviceCap);
- case EEP_OP_MODE:
- return pBase->opCapFlags;
- case EEP_RF_SILENT:
-- return pBase->rfSilent;
-+ return le16_to_cpu(pBase->rfSilent);
- case EEP_OB_2:
- return pModal->ob_0;
- case EEP_DB_2:
-@@ -724,7 +702,7 @@ static void ath9k_hw_4k_set_gain(struct
- {
- ENABLE_REG_RMW_BUFFER(ah);
- REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0,
-- pModal->antCtrlChain[0], 0);
-+ le32_to_cpu(pModal->antCtrlChain[0]), 0);
-
- REG_RMW(ah, AR_PHY_TIMING_CTRL4(0),
- SM(pModal->iqCalICh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF) |
-@@ -790,7 +768,7 @@ static void ath9k_hw_4k_set_board_values
- pModal = &eep->modalHeader;
- txRxAttenLocal = 23;
-
-- REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon);
-+ REG_WRITE(ah, AR_PHY_SWITCH_COM, le32_to_cpu(pModal->antCtrlCommon));
-
- /* Single chain for 4K EEPROM*/
- ath9k_hw_4k_set_gain(ah, pModal, eep, txRxAttenLocal);
-@@ -1054,7 +1032,7 @@ static void ath9k_hw_4k_set_board_values
-
- static u16 ath9k_hw_4k_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz)
- {
-- return ah->eeprom.map4k.modalHeader.spurChans[i].spurChan;
-+ return le16_to_cpu(ah->eeprom.map4k.modalHeader.spurChans[i].spurChan);
- }
-
- static u8 ath9k_hw_4k_get_eepmisc(struct ath_hw *ah)
---- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
-@@ -22,7 +22,7 @@
-
- static int ath9k_hw_ar9287_get_eeprom_ver(struct ath_hw *ah)
- {
-- u16 version = ah->eeprom.map9287.baseEepHeader.version;
-+ u16 version = le16_to_cpu(ah->eeprom.map9287.baseEepHeader.version);
-
- return (version & AR5416_EEP_VER_MAJOR_MASK) >>
- AR5416_EEP_VER_MAJOR_SHIFT;
-@@ -30,7 +30,7 @@ static int ath9k_hw_ar9287_get_eeprom_ve
-
- static int ath9k_hw_ar9287_get_eeprom_rev(struct ath_hw *ah)
- {
-- u16 version = ah->eeprom.map9287.baseEepHeader.version;
-+ u16 version = le16_to_cpu(ah->eeprom.map9287.baseEepHeader.version);
-
- return version & AR5416_EEP_VER_MINOR_MASK;
- }
-@@ -79,9 +79,9 @@ static bool ath9k_hw_ar9287_fill_eeprom(
- static u32 ar9287_dump_modal_eeprom(char *buf, u32 len, u32 size,
- struct modal_eep_ar9287_header *modal_hdr)
- {
-- PR_EEP("Chain0 Ant. Control", modal_hdr->antCtrlChain[0]);
-- PR_EEP("Chain1 Ant. Control", modal_hdr->antCtrlChain[1]);
-- PR_EEP("Ant. Common Control", modal_hdr->antCtrlCommon);
-+ PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0]));
-+ PR_EEP("Chain1 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[1]));
-+ PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon));
- PR_EEP("Chain0 Ant. Gain", modal_hdr->antennaGainCh[0]);
- PR_EEP("Chain1 Ant. Gain", modal_hdr->antennaGainCh[1]);
- PR_EEP("Switch Settle", modal_hdr->switchSettling);
-@@ -128,6 +128,7 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
- {
- struct ar9287_eeprom *eep = &ah->eeprom.map9287;
- struct base_eep_ar9287_header *pBase = &eep->baseEepHeader;
-+ u32 binBuildNumber = le32_to_cpu(pBase->binBuildNumber);
-
- if (!dump_base_hdr) {
- len += scnprintf(buf + len, size - len,
-@@ -139,10 +140,10 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
-
- PR_EEP("Major Version", ath9k_hw_ar9287_get_eeprom_ver(ah));
- PR_EEP("Minor Version", ath9k_hw_ar9287_get_eeprom_rev(ah));
-- PR_EEP("Checksum", pBase->checksum);
-- PR_EEP("Length", pBase->length);
-- PR_EEP("RegDomain1", pBase->regDmn[0]);
-- PR_EEP("RegDomain2", pBase->regDmn[1]);
-+ PR_EEP("Checksum", le16_to_cpu(pBase->checksum));
-+ PR_EEP("Length", le16_to_cpu(pBase->length));
-+ PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0]));
-+ PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1]));
- PR_EEP("TX Mask", pBase->txMask);
- PR_EEP("RX Mask", pBase->rxMask);
- PR_EEP("Allow 5GHz", !!(pBase->opCapFlags & AR5416_OPFLAGS_11A));
-@@ -156,9 +157,9 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
- PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags &
- AR5416_OPFLAGS_N_5G_HT40));
- PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN));
-- PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF);
-- PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF);
-- PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
-+ PR_EEP("Cal Bin Major Ver", (binBuildNumber >> 24) & 0xFF);
-+ PR_EEP("Cal Bin Minor Ver", (binBuildNumber >> 16) & 0xFF);
-+ PR_EEP("Cal Bin Build", (binBuildNumber >> 8) & 0xFF);
- PR_EEP("Power Table Offset", pBase->pwrTableOffset);
- PR_EEP("OpenLoop Power Ctrl", pBase->openLoopPwrCntl);
-
-@@ -182,8 +183,7 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
-
- static int ath9k_hw_ar9287_check_eeprom(struct ath_hw *ah)
- {
-- u32 el, integer;
-- u16 word;
-+ u32 el;
- int i, err;
- bool need_swap;
- struct ar9287_eeprom *eep = &ah->eeprom.map9287;
-@@ -193,51 +193,31 @@ static int ath9k_hw_ar9287_check_eeprom(
- return err;
-
- if (need_swap)
-- el = swab16(eep->baseEepHeader.length);
-+ el = swab16((__force u16)eep->baseEepHeader.length);
- else
-- el = eep->baseEepHeader.length;
-+ el = le16_to_cpu(eep->baseEepHeader.length);
-
- el = min(el / sizeof(u16), SIZE_EEPROM_AR9287);
- if (!ath9k_hw_nvram_validate_checksum(ah, el))
- return -EINVAL;
-
- if (need_swap) {
-- word = swab16(eep->baseEepHeader.length);
-- eep->baseEepHeader.length = word;
--
-- word = swab16(eep->baseEepHeader.checksum);
-- eep->baseEepHeader.checksum = word;
--
-- word = swab16(eep->baseEepHeader.version);
-- eep->baseEepHeader.version = word;
--
-- word = swab16(eep->baseEepHeader.regDmn[0]);
-- eep->baseEepHeader.regDmn[0] = word;
--
-- word = swab16(eep->baseEepHeader.regDmn[1]);
-- eep->baseEepHeader.regDmn[1] = word;
--
-- word = swab16(eep->baseEepHeader.rfSilent);
-- eep->baseEepHeader.rfSilent = word;
--
-- word = swab16(eep->baseEepHeader.blueToothOptions);
-- eep->baseEepHeader.blueToothOptions = word;
--
-- word = swab16(eep->baseEepHeader.deviceCap);
-- eep->baseEepHeader.deviceCap = word;
--
-- integer = swab32(eep->modalHeader.antCtrlCommon);
-- eep->modalHeader.antCtrlCommon = integer;
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.length);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.checksum);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.version);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[0]);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[1]);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.rfSilent);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.blueToothOptions);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.deviceCap);
-+ EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlCommon);
-
-- for (i = 0; i < AR9287_MAX_CHAINS; i++) {
-- integer = swab32(eep->modalHeader.antCtrlChain[i]);
-- eep->modalHeader.antCtrlChain[i] = integer;
-- }
-+ for (i = 0; i < AR9287_MAX_CHAINS; i++)
-+ EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlChain[i]);
-
-- for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
-- word = swab16(eep->modalHeader.spurChans[i].spurChan);
-- eep->modalHeader.spurChans[i].spurChan = word;
-- }
-+ for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++)
-+ EEPROM_FIELD_SWAB16(
-+ eep->modalHeader.spurChans[i].spurChan);
- }
-
- if (!ath9k_hw_nvram_check_version(ah, AR9287_EEP_VER,
-@@ -267,13 +247,13 @@ static u32 ath9k_hw_ar9287_get_eeprom(st
- case EEP_MAC_MSW:
- return get_unaligned_be16(pBase->macAddr + 4);
- case EEP_REG_0:
-- return pBase->regDmn[0];
-+ return le16_to_cpu(pBase->regDmn[0]);
- case EEP_OP_CAP:
-- return pBase->deviceCap;
-+ return le16_to_cpu(pBase->deviceCap);
- case EEP_OP_MODE:
- return pBase->opCapFlags;
- case EEP_RF_SILENT:
-- return pBase->rfSilent;
-+ return le16_to_cpu(pBase->rfSilent);
- case EEP_TX_MASK:
- return pBase->txMask;
- case EEP_RX_MASK:
-@@ -878,13 +858,13 @@ static void ath9k_hw_ar9287_set_board_va
-
- pModal = &eep->modalHeader;
-
-- REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon);
-+ REG_WRITE(ah, AR_PHY_SWITCH_COM, le32_to_cpu(pModal->antCtrlCommon));
-
- for (i = 0; i < AR9287_MAX_CHAINS; i++) {
- regChainOffset = i * 0x1000;
-
- REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset,
-- pModal->antCtrlChain[i]);
-+ le32_to_cpu(pModal->antCtrlChain[i]));
-
- REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset,
- (REG_READ(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset)
-@@ -982,7 +962,9 @@ static void ath9k_hw_ar9287_set_board_va
- static u16 ath9k_hw_ar9287_get_spur_channel(struct ath_hw *ah,
- u16 i, bool is2GHz)
- {
-- return ah->eeprom.map9287.modalHeader.spurChans[i].spurChan;
-+ __le16 spur_ch = ah->eeprom.map9287.modalHeader.spurChans[i].spurChan;
-+
-+ return le16_to_cpu(spur_ch);
- }
-
- static u8 ath9k_hw_ar9287_get_eepmisc(struct ath_hw *ah)
---- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
-+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
-@@ -79,7 +79,7 @@ static void ath9k_olc_get_pdadcs(struct
-
- static int ath9k_hw_def_get_eeprom_ver(struct ath_hw *ah)
- {
-- u16 version = ah->eeprom.def.baseEepHeader.version;
-+ u16 version = le16_to_cpu(ah->eeprom.def.baseEepHeader.version);
-
- return (version & AR5416_EEP_VER_MAJOR_MASK) >>
- AR5416_EEP_VER_MAJOR_SHIFT;
-@@ -87,7 +87,7 @@ static int ath9k_hw_def_get_eeprom_ver(s
-
- static int ath9k_hw_def_get_eeprom_rev(struct ath_hw *ah)
- {
-- u16 version = ah->eeprom.def.baseEepHeader.version;
-+ u16 version = le16_to_cpu(ah->eeprom.def.baseEepHeader.version);
-
- return version & AR5416_EEP_VER_MINOR_MASK;
- }
-@@ -135,10 +135,10 @@ static bool ath9k_hw_def_fill_eeprom(str
- static u32 ath9k_def_dump_modal_eeprom(char *buf, u32 len, u32 size,
- struct modal_eep_header *modal_hdr)
- {
-- PR_EEP("Chain0 Ant. Control", modal_hdr->antCtrlChain[0]);
-- PR_EEP("Chain1 Ant. Control", modal_hdr->antCtrlChain[1]);
-- PR_EEP("Chain2 Ant. Control", modal_hdr->antCtrlChain[2]);
-- PR_EEP("Ant. Common Control", modal_hdr->antCtrlCommon);
-+ PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0]));
-+ PR_EEP("Chain1 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[1]));
-+ PR_EEP("Chain2 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[2]));
-+ PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon));
- PR_EEP("Chain0 Ant. Gain", modal_hdr->antennaGainCh[0]);
- PR_EEP("Chain1 Ant. Gain", modal_hdr->antennaGainCh[1]);
- PR_EEP("Chain2 Ant. Gain", modal_hdr->antennaGainCh[2]);
-@@ -194,9 +194,9 @@ static u32 ath9k_def_dump_modal_eeprom(c
- PR_EEP("Chain1 OutputBias", modal_hdr->ob_ch1);
- PR_EEP("Chain1 DriverBias", modal_hdr->db_ch1);
- PR_EEP("LNA Control", modal_hdr->lna_ctl);
-- PR_EEP("XPA Bias Freq0", modal_hdr->xpaBiasLvlFreq[0]);
-- PR_EEP("XPA Bias Freq1", modal_hdr->xpaBiasLvlFreq[1]);
-- PR_EEP("XPA Bias Freq2", modal_hdr->xpaBiasLvlFreq[2]);
-+ PR_EEP("XPA Bias Freq0", le16_to_cpu(modal_hdr->xpaBiasLvlFreq[0]));
-+ PR_EEP("XPA Bias Freq1", le16_to_cpu(modal_hdr->xpaBiasLvlFreq[1]));
-+ PR_EEP("XPA Bias Freq2", le16_to_cpu(modal_hdr->xpaBiasLvlFreq[2]));
-
- return len;
- }
-@@ -206,6 +206,7 @@ static u32 ath9k_hw_def_dump_eeprom(stru
- {
- struct ar5416_eeprom_def *eep = &ah->eeprom.def;
- struct base_eep_header *pBase = &eep->baseEepHeader;
-+ u32 binBuildNumber = le32_to_cpu(pBase->binBuildNumber);
-
- if (!dump_base_hdr) {
- len += scnprintf(buf + len, size - len,
-@@ -221,10 +222,10 @@ static u32 ath9k_hw_def_dump_eeprom(stru
-
- PR_EEP("Major Version", ath9k_hw_def_get_eeprom_ver(ah));
- PR_EEP("Minor Version", ath9k_hw_def_get_eeprom_rev(ah));
-- PR_EEP("Checksum", pBase->checksum);
-- PR_EEP("Length", pBase->length);
-- PR_EEP("RegDomain1", pBase->regDmn[0]);
-- PR_EEP("RegDomain2", pBase->regDmn[1]);
-+ PR_EEP("Checksum", le16_to_cpu(pBase->checksum));
-+ PR_EEP("Length", le16_to_cpu(pBase->length));
-+ PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0]));
-+ PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1]));
- PR_EEP("TX Mask", pBase->txMask);
- PR_EEP("RX Mask", pBase->rxMask);
- PR_EEP("Allow 5GHz", !!(pBase->opCapFlags & AR5416_OPFLAGS_11A));
-@@ -238,9 +239,9 @@ static u32 ath9k_hw_def_dump_eeprom(stru
- PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags &
- AR5416_OPFLAGS_N_5G_HT40));
- PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN));
-- PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF);
-- PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF);
-- PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
-+ PR_EEP("Cal Bin Major Ver", (binBuildNumber >> 24) & 0xFF);
-+ PR_EEP("Cal Bin Minor Ver", (binBuildNumber >> 16) & 0xFF);
-+ PR_EEP("Cal Bin Build", (binBuildNumber >> 8) & 0xFF);
- PR_EEP("OpenLoop Power Ctrl", pBase->openLoopPwrCntl);
-
- len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
-@@ -273,61 +274,40 @@ static int ath9k_hw_def_check_eeprom(str
- return err;
-
- if (need_swap)
-- el = swab16(eep->baseEepHeader.length);
-+ el = swab16((__force u16)eep->baseEepHeader.length);
- else
-- el = eep->baseEepHeader.length;
-+ el = le16_to_cpu(eep->baseEepHeader.length);
-
- el = min(el / sizeof(u16), SIZE_EEPROM_DEF);
- if (!ath9k_hw_nvram_validate_checksum(ah, el))
- return -EINVAL;
-
- if (need_swap) {
-- u32 integer, j;
-- u16 word;
--
-- word = swab16(eep->baseEepHeader.length);
-- eep->baseEepHeader.length = word;
--
-- word = swab16(eep->baseEepHeader.checksum);
-- eep->baseEepHeader.checksum = word;
--
-- word = swab16(eep->baseEepHeader.version);
-- eep->baseEepHeader.version = word;
--
-- word = swab16(eep->baseEepHeader.regDmn[0]);
-- eep->baseEepHeader.regDmn[0] = word;
--
-- word = swab16(eep->baseEepHeader.regDmn[1]);
-- eep->baseEepHeader.regDmn[1] = word;
--
-- word = swab16(eep->baseEepHeader.rfSilent);
-- eep->baseEepHeader.rfSilent = word;
--
-- word = swab16(eep->baseEepHeader.blueToothOptions);
-- eep->baseEepHeader.blueToothOptions = word;
-+ u32 j;
-
-- word = swab16(eep->baseEepHeader.deviceCap);
-- eep->baseEepHeader.deviceCap = word;
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.length);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.checksum);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.version);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[0]);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[1]);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.rfSilent);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.blueToothOptions);
-+ EEPROM_FIELD_SWAB16(eep->baseEepHeader.deviceCap);
-
- for (j = 0; j < ARRAY_SIZE(eep->modalHeader); j++) {
- struct modal_eep_header *pModal =
- &eep->modalHeader[j];
-- integer = swab32(pModal->antCtrlCommon);
-- pModal->antCtrlCommon = integer;
-+ EEPROM_FIELD_SWAB32(pModal->antCtrlCommon);
-
-- for (i = 0; i < AR5416_MAX_CHAINS; i++) {
-- integer = swab32(pModal->antCtrlChain[i]);
-- pModal->antCtrlChain[i] = integer;
-- }
-- for (i = 0; i < 3; i++) {
-- word = swab16(pModal->xpaBiasLvlFreq[i]);
-- pModal->xpaBiasLvlFreq[i] = word;
-- }
-+ for (i = 0; i < AR5416_MAX_CHAINS; i++)
-+ EEPROM_FIELD_SWAB32(pModal->antCtrlChain[i]);
-
-- for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
-- word = swab16(pModal->spurChans[i].spurChan);
-- pModal->spurChans[i].spurChan = word;
-- }
-+ for (i = 0; i < 3; i++)
-+ EEPROM_FIELD_SWAB16(pModal->xpaBiasLvlFreq[i]);
-+
-+ for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++)
-+ EEPROM_FIELD_SWAB16(
-+ pModal->spurChans[i].spurChan);
- }
- }
-
-@@ -337,7 +317,7 @@ static int ath9k_hw_def_check_eeprom(str
-
- /* Enable fixup for AR_AN_TOP2 if necessary */
- if ((ah->hw_version.devid == AR9280_DEVID_PCI) &&
-- ((eep->baseEepHeader.version & 0xff) > 0x0a) &&
-+ ((le16_to_cpu(eep->baseEepHeader.version) & 0xff) > 0x0a) &&
- (eep->baseEepHeader.pwdclkind == 0))
- ah->need_an_top2_fixup = true;
-
-@@ -370,13 +350,13 @@ static u32 ath9k_hw_def_get_eeprom(struc
- case EEP_MAC_MSW:
- return get_unaligned_be16(pBase->macAddr + 4);
- case EEP_REG_0:
-- return pBase->regDmn[0];
-+ return le16_to_cpu(pBase->regDmn[0]);
- case EEP_OP_CAP:
-- return pBase->deviceCap;
-+ return le16_to_cpu(pBase->deviceCap);
- case EEP_OP_MODE:
- return pBase->opCapFlags;
- case EEP_RF_SILENT:
-- return pBase->rfSilent;
-+ return le16_to_cpu(pBase->rfSilent);
- case EEP_OB_5:
- return pModal[0].ob;
- case EEP_DB_5:
-@@ -490,11 +470,13 @@ static void ath9k_hw_def_set_board_value
- struct ar5416_eeprom_def *eep = &ah->eeprom.def;
- int i, regChainOffset;
- u8 txRxAttenLocal;
-+ u32 antCtrlCommon;
-
- pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
- txRxAttenLocal = IS_CHAN_2GHZ(chan) ? 23 : 44;
-+ antCtrlCommon = le32_to_cpu(pModal->antCtrlCommon);
-
-- REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon & 0xffff);
-+ REG_WRITE(ah, AR_PHY_SWITCH_COM, antCtrlCommon & 0xffff);
-
- for (i = 0; i < AR5416_MAX_CHAINS; i++) {
- if (AR_SREV_9280(ah)) {
-@@ -508,7 +490,7 @@ static void ath9k_hw_def_set_board_value
- regChainOffset = i * 0x1000;
-
- REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset,
-- pModal->antCtrlChain[i]);
-+ le32_to_cpu(pModal->antCtrlChain[i]));
-
- REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset,
- (REG_READ(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset) &
-@@ -655,7 +637,7 @@ static void ath9k_hw_def_set_board_value
- static void ath9k_hw_def_set_addac(struct ath_hw *ah,
- struct ath9k_channel *chan)
- {
--#define XPA_LVL_FREQ(cnt) (pModal->xpaBiasLvlFreq[cnt])
-+#define XPA_LVL_FREQ(cnt) (le16_to_cpu(pModal->xpaBiasLvlFreq[cnt]))
- struct modal_eep_header *pModal;
- struct ar5416_eeprom_def *eep = &ah->eeprom.def;
- u8 biaslevel;
-@@ -1315,7 +1297,9 @@ static void ath9k_hw_def_set_txpower(str
-
- static u16 ath9k_hw_def_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz)
- {
-- return ah->eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan;
-+ __le16 spch = ah->eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan;
-+
-+ return le16_to_cpu(spch);
- }
-
- static u8 ath9k_hw_def_get_eepmisc(struct ath_hw *ah)
+++ /dev/null
---- a/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt
-+++ b/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt
-@@ -34,6 +34,14 @@ Optional properties:
- ath9k wireless chip (in this case the calibration /
- EEPROM data will be loaded from userspace using the
- kernel firmware loader).
-+- qca,disable-2ghz: Overrides the settings from the EEPROM and disables the
-+ 2.4GHz band. Setting this property is only needed
-+ when the RF circuit does not support the 2.4GHz band
-+ while it is enabled nevertheless in the EEPROM.
-+- qca,disable-5ghz: Overrides the settings from the EEPROM and disables the
-+ 5GHz band. Setting this property is only needed when
-+ the RF circuit does not support the 5GHz band while
-+ it is enabled nevertheless in the EEPROM.
- - mac-address: See ethernet.txt in the parent directory
- - local-mac-address: See ethernet.txt in the parent directory
-
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -571,6 +571,12 @@ static int ath9k_of_init(struct ath_soft
-
- ath_dbg(common, CONFIG, "parsing configuration from OF node\n");
-
-+ if (of_property_read_bool(np, "qca,disable-2ghz"))
-+ ah->disable_2ghz = true;
-+
-+ if (of_property_read_bool(np, "qca,disable-5ghz"))
-+ ah->disable_5ghz = true;
-+
- if (of_property_read_bool(np, "qca,no-eeprom")) {
- /* ath9k-eeprom-<bus>-<id>.bin */
- scnprintf(eeprom_name, sizeof(eeprom_name),
+++ /dev/null
---- a/drivers/net/wireless/ath/ath9k/channel.c
-+++ b/drivers/net/wireless/ath/ath9k/channel.c
-@@ -15,6 +15,8 @@
- */
-
- #include "ath9k.h"
-+#include <linux/ath9k_platform.h>
-+#include "hsr.h"
-
- /* Set/change channels. If the channel is really being changed, it's done
- * by reseting the chip. To accomplish this we must first cleanup any pending
-@@ -22,6 +24,7 @@
- */
- static int ath_set_channel(struct ath_softc *sc)
- {
-+ struct ath9k_platform_data *pdata = sc->dev->platform_data;
- struct ath_hw *ah = sc->sc_ah;
- struct ath_common *common = ath9k_hw_common(ah);
- struct ieee80211_hw *hw = sc->hw;
-@@ -41,6 +44,11 @@ static int ath_set_channel(struct ath_so
- ath_dbg(common, CONFIG, "Set channel: %d MHz width: %d\n",
- chan->center_freq, chandef->width);
-
-+ if (pdata && pdata->ubnt_hsr) {
-+ ath9k_hsr_enable(ah, chandef->width, chan->center_freq);
-+ ath9k_hsr_status(ah);
-+ }
-+
- /* update survey stats for the old channel before switching */
- spin_lock_bh(&common->cc_lock);
- ath_update_survey_stats(sc);
---- /dev/null
-+++ b/drivers/net/wireless/ath/ath9k/hsr.c
-@@ -0,0 +1,247 @@
-+/*
-+ *
-+ * The MIT License (MIT)
-+ *
-+ * Copyright (c) 2015 Kirill Berezin
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a copy
-+ * of this software and associated documentation files (the "Software"), to deal
-+ * in the Software without restriction, including without limitation the rights
-+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-+ * copies of the Software, and to permit persons to whom the Software is
-+ * furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included in
-+ * all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-+ * SOFTWARE.
-+ *
-+ */
-+
-+#include <linux/io.h>
-+#include <linux/slab.h>
-+#include <linux/module.h>
-+#include <linux/time.h>
-+#include <linux/bitops.h>
-+#include <linux/etherdevice.h>
-+#include <linux/rtnetlink.h>
-+#include <asm/unaligned.h>
-+
-+#include "hw.h"
-+#include "ath9k.h"
-+
-+#define HSR_GPIO_CSN 8
-+#define HSR_GPIO_CLK 6
-+#define HSR_GPIO_DOUT 7
-+#define HSR_GPIO_DIN 5
-+
-+/* delays are in useconds */
-+#define HSR_DELAY_HALF_TICK 100
-+#define HSR_DELAY_PRE_WRITE 75
-+#define HSR_DELAY_FINAL 20000
-+#define HSR_DELAY_TRAILING 200
-+
-+void ath9k_hsr_init(struct ath_hw *ah)
-+{
-+ ath9k_hw_gpio_request_in(ah, HSR_GPIO_DIN, NULL);
-+ ath9k_hw_gpio_request_out(ah, HSR_GPIO_CSN, NULL,
-+ AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-+ ath9k_hw_gpio_request_out(ah, HSR_GPIO_CLK, NULL,
-+ AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-+ ath9k_hw_gpio_request_out(ah, HSR_GPIO_DOUT, NULL,
-+ AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-+
-+ ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 1);
-+ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0);
-+ ath9k_hw_set_gpio(ah, HSR_GPIO_DOUT, 0);
-+
-+ udelay(HSR_DELAY_TRAILING);
-+}
-+
-+static u32 ath9k_hsr_write_byte(struct ath_hw *ah, int delay, u32 value)
-+{
-+ struct ath_common *common = ath9k_hw_common(ah);
-+ int i;
-+ u32 rval = 0;
-+
-+ udelay(delay);
-+
-+ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0);
-+ udelay(HSR_DELAY_HALF_TICK);
-+
-+ ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 0);
-+ udelay(HSR_DELAY_HALF_TICK);
-+
-+ for (i = 0; i < 8; ++i) {
-+ rval = rval << 1;
-+
-+ /* pattern is left to right, that is 7-th bit runs first */
-+ ath9k_hw_set_gpio(ah, HSR_GPIO_DOUT, (value >> (7 - i)) & 0x1);
-+ udelay(HSR_DELAY_HALF_TICK);
-+
-+ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 1);
-+ udelay(HSR_DELAY_HALF_TICK);
-+
-+ rval |= ath9k_hw_gpio_get(ah, HSR_GPIO_DIN);
-+
-+ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0);
-+ udelay(HSR_DELAY_HALF_TICK);
-+ }
-+
-+ ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 1);
-+ udelay(HSR_DELAY_HALF_TICK);
-+
-+ ath_dbg(common, CONFIG, "ath9k_hsr_write_byte: write byte %d return value is %d %c\n",
-+ value, rval, rval > 32 ? rval : '-');
-+
-+ return rval & 0xff;
-+}
-+
-+static int ath9k_hsr_write_a_chain(struct ath_hw *ah, char *chain, int items)
-+{
-+ int status = 0;
-+ int i = 0;
-+ int err;
-+
-+ /* a preamble */
-+ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
-+ status = ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
-+
-+ /* clear HSR's reply buffer */
-+ if (status) {
-+ int loop = 0;
-+
-+ for (loop = 0; (loop < 42) && status; ++loop)
-+ status = ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE,
-+ 0);
-+
-+ if (loop >= 42) {
-+ ATH_DBG_WARN(1,
-+ "ath9k_hsr_write_a_chain: can't clear an output buffer after a 42 cycles.\n");
-+ return -1;
-+ }
-+ }
-+
-+ for (i = 0; (i < items) && (chain[i] != 0); ++i)
-+ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, (u32)chain[i]);
-+
-+ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
-+ mdelay(HSR_DELAY_FINAL / 1000);
-+
-+ /* reply */
-+ memset(chain, 0, items);
-+
-+ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
-+ udelay(HSR_DELAY_TRAILING);
-+
-+ for (i = 0; i < (items - 1); ++i) {
-+ u32 ret;
-+
-+ ret = ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0);
-+ if (ret != 0)
-+ chain[i] = (char)ret;
-+ else
-+ break;
-+
-+ udelay(HSR_DELAY_TRAILING);
-+ }
-+
-+ if (i <= 1)
-+ return 0;
-+
-+ err = kstrtoint(chain + 1, 10, &i);
-+ if (err)
-+ return err;
-+
-+ return i;
-+}
-+
-+int ath9k_hsr_disable(struct ath_hw *ah)
-+{
-+ char cmd[10] = {'b', '4', '0', 0, 0, 0, 0, 0, 0, 0};
-+ int ret;
-+
-+ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd));
-+ if ((ret > 0) && (*cmd == 'B'))
-+ return 0;
-+
-+ return -1;
-+}
-+
-+int ath9k_hsr_enable(struct ath_hw *ah, int bw, int fq)
-+{
-+ char cmd[10];
-+ int ret;
-+
-+ /* Bandwidth argument is 0 sometimes. Assume default 802.11bgn
-+ * 20MHz on invalid values
-+ */
-+ if ((bw != 5) && (bw != 10) && (bw != 20) && (bw != 40))
-+ bw = 20;
-+
-+ memset(cmd, 0, sizeof(cmd));
-+ *cmd = 'b';
-+ snprintf(cmd + 1, 3, "%02d", bw);
-+
-+ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd));
-+ if ((*cmd != 'B') || (ret != bw)) {
-+ ATH_DBG_WARN(1,
-+ "ath9k_hsr_enable: failed changing bandwidth -> set (%d,%d) reply (%d, %d)\n",
-+ 'b', bw, *cmd, ret);
-+ return -1;
-+ }
-+
-+ memset(cmd, 0, sizeof(cmd));
-+ *cmd = 'x';
-+ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd));
-+ if (*cmd != 'X') {
-+ ATH_DBG_WARN(1,
-+ "ath9k_hsr_enable: failed 'x' command -> reply (%d, %d)\n",
-+ *cmd, ret);
-+ return -1;
-+ }
-+
-+ memset(cmd, 0, sizeof(cmd));
-+ *cmd = 'm';
-+ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd));
-+ if (*cmd != 'M') {
-+ ATH_DBG_WARN(1,
-+ "ath9k_hsr_enable: failed 'm' command -> reply (%d, %d)\n",
-+ *cmd, ret);
-+ return -1;
-+ }
-+
-+ memset(cmd, 0, sizeof(cmd));
-+ *cmd = 'f';
-+ snprintf(cmd + 1, 6, "%05d", fq);
-+ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd));
-+ if ((*cmd != 'F') && (ret != fq)) {
-+ ATH_DBG_WARN(1,
-+ "ath9k_hsr_enable: failed set frequency -> reply (%d, %d)\n",
-+ *cmd, ret);
-+ return -1;
-+ }
-+
-+ return 0;
-+}
-+
-+int ath9k_hsr_status(struct ath_hw *ah)
-+{
-+ char cmd[10] = {'s', 0, 0, 0, 0, 0, 0, 0, 0, 0};
-+ int ret;
-+
-+ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd));
-+ if (*cmd != 'S') {
-+ ATH_DBG_WARN(1, "ath9k_hsr_status: returned %d,%d\n", *cmd,
-+ ret);
-+ return -1;
-+ }
-+
-+ return 0;
-+}
---- /dev/null
-+++ b/drivers/net/wireless/ath/ath9k/hsr.h
-@@ -0,0 +1,48 @@
-+/*
-+ * The MIT License (MIT)
-+ *
-+ * Copyright (c) 2015 Kirill Berezin
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a copy
-+ * of this software and associated documentation files (the "Software"), to deal
-+ * in the Software without restriction, including without limitation the rights
-+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-+ * copies of the Software, and to permit persons to whom the Software is
-+ * furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included in
-+ * all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-+ * SOFTWARE.
-+ */
-+
-+#ifndef HSR_H
-+#define HSR_H
-+
-+#ifdef CPTCFG_ATH9K_UBNTHSR
-+
-+void ath9k_hsr_init(struct ath_hw *ah);
-+int ath9k_hsr_disable(struct ath_hw *ah);
-+int ath9k_hsr_enable(struct ath_hw *ah, int bw, int fq);
-+int ath9k_hsr_status(struct ath_hw *ah);
-+
-+#else
-+static inline void ath9k_hsr_init(struct ath_hw *ah) {}
-+
-+static inline int ath9k_hsr_enable(struct ath_hw *ah, int bw, int fq)
-+{
-+ return 0;
-+}
-+
-+static inline int ath9k_hsr_disable(struct ath_hw *ah) { return 0; }
-+static inline int ath9k_hsr_status(struct ath_hw *ah) { return 0; }
-+
-+#endif
-+
-+#endif /* HSR_H */
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -16,8 +16,10 @@
-
- #include <linux/nl80211.h>
- #include <linux/delay.h>
-+#include <linux/ath9k_platform.h>
- #include "ath9k.h"
- #include "btcoex.h"
-+#include "hsr.h"
-
- u8 ath9k_parse_mpdudensity(u8 mpdudensity)
- {
-@@ -652,6 +654,7 @@ void ath_reset_work(struct work_struct *
- static int ath9k_start(struct ieee80211_hw *hw)
- {
- struct ath_softc *sc = hw->priv;
-+ struct ath9k_platform_data *pdata = sc->dev->platform_data;
- struct ath_hw *ah = sc->sc_ah;
- struct ath_common *common = ath9k_hw_common(ah);
- struct ieee80211_channel *curchan = sc->cur_chan->chandef.chan;
-@@ -730,6 +733,11 @@ static int ath9k_start(struct ieee80211_
- AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
- }
-
-+ if (pdata && pdata->ubnt_hsr) {
-+ ath9k_hsr_init(ah);
-+ ath9k_hsr_disable(ah);
-+ }
-+
- /*
- * Reset key cache to sane defaults (all entries cleared) instead of
- * semi-random values after suspend/resume.
---- a/drivers/net/wireless/ath/ath9k/Makefile
-+++ b/drivers/net/wireless/ath/ath9k/Makefile
-@@ -16,6 +16,7 @@ ath9k-$(CPTCFG_ATH9K_DFS_CERTIFIED) += d
- ath9k-$(CPTCFG_ATH9K_TX99) += tx99.o
- ath9k-$(CPTCFG_ATH9K_WOW) += wow.o
- ath9k-$(CPTCFG_ATH9K_HWRNG) += rng.o
-+ath9k-$(CPTCFG_ATH9K_UBNTHSR) += hsr.o
-
- ath9k-$(CPTCFG_ATH9K_DEBUGFS) += debug.o
-
---- a/include/linux/ath9k_platform.h
-+++ b/include/linux/ath9k_platform.h
-@@ -54,6 +54,8 @@ struct ath9k_platform_data {
- unsigned num_btns;
- const struct gpio_keys_button *btns;
- unsigned btn_poll_interval;
-+
-+ bool ubnt_hsr;
- };
-
- #endif /* _LINUX_ATH9K_PLATFORM_H */
---- a/.local-symbols
-+++ b/.local-symbols
-@@ -153,6 +153,7 @@ ATH9K_WOW=
- ATH9K_RFKILL=
- ATH9K_CHANNEL_CONTEXT=
- ATH9K_PCOEM=
-+ATH9K_UBNTHSR=
- ATH9K_HTC=
- ATH9K_HTC_DEBUGFS=
- ATH9K_HWRNG=
---- a/drivers/net/wireless/ath/ath9k/Kconfig
-+++ b/drivers/net/wireless/ath/ath9k/Kconfig
-@@ -59,6 +59,19 @@ config ATH9K_AHB
- Say Y, if you have a SoC with a compatible built-in
- wireless MAC. Say N if unsure.
-
-+config ATH9K_UBNTHSR
-+ bool "Ubiquiti UniFi Outdoor Plus HSR support"
-+ depends on ATH9K
-+ ---help---
-+ This options enables code to control the HSR RF
-+ filter in the receive path of the Ubiquiti UniFi
-+ Outdoor Plus access point.
-+
-+ Say Y if you want to use the access point. The
-+ code will only be used if the device is detected,
-+ so it does not harm other setup other than occupying
-+ a bit of memory.
-+
- config ATH9K_DEBUGFS
- bool "Atheros ath9k debugging"
- depends on ATH9K && DEBUG_FS
--- /dev/null
+From 91094ed065f7794886b4a5490fd6de942f036bb4 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Sun, 24 Mar 2013 19:26:26 +0100
+Subject: [PATCH] rt2x00: allow to build rt2800soc module for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/Kconfig | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/Kconfig
++++ b/drivers/net/wireless/ralink/rt2x00/Kconfig
+@@ -210,7 +210,7 @@ endif
+ config RT2800SOC
+ tristate "Ralink WiSoC support"
+ depends on m
+- depends on SOC_RT288X || SOC_RT305X
++ depends on SOC_RT288X || SOC_RT305X || SOC_RT3883
+ select RT2X00_LIB_SOC
+ select RT2X00_LIB_MMIO
+ select RT2X00_LIB_CRYPTO
+@@ -245,7 +245,7 @@ config RT2X00_LIB_PCI
+
+ config RT2X00_LIB_SOC
+ tristate "RT2x00 SoC support"
+- depends on SOC_RT288X || SOC_RT305X
++ depends on SOC_RT288X || SOC_RT305X || SOC_RT3883
+ depends on m
+ select RT2X00_LIB
+
--- /dev/null
+From 4f16582c93a71eba9d389e0f0a8aa9099a9587cd Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Sun, 24 Mar 2013 19:26:26 +0100
+Subject: [PATCH] rt2x00: rt2800lib: enable support for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -7956,6 +7956,7 @@ static int rt2800_probe_rt(struct rt2x00
+ case RT3390:
+ case RT3572:
+ case RT3593:
++ case RT3883:
+ case RT5350:
+ case RT5390:
+ case RT5392:
--- /dev/null
+From ecb394ccf248d8652c463133c4f404458a57a9c1 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Sun, 24 Mar 2013 19:26:26 +0100
+Subject: [PATCH] rt2x00: rt2800lib: add rf_vals for RF3853
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800.h | 4 +-
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 65 +++++++++++++++++++++++++++++++
+ 2 files changed, 68 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
+@@ -48,7 +48,8 @@
+ * RF2853 2.4G/5G 3T3R
+ * RF3320 2.4G 1T1R(RT3350/RT3370/RT3390)
+ * RF3322 2.4G 2T2R(RT3352/RT3371/RT3372/RT3391/RT3392)
+- * RF3053 2.4G/5G 3T3R(RT3883/RT3563/RT3573/RT3593/RT3662)
++ * RF3053 2.4G/5G 3T3R(RT3563/RT3573/RT3593)
++ * RF3853 2.4G/5G 3T3R(RT3883/RT3662)
+ * RF5592 2.4G/5G 2T2R
+ * RF3070 2.4G 1T1R
+ * RF5360 2.4G 1T1R
+@@ -72,6 +73,7 @@
+ #define RF5592 0x000f
+ #define RF3070 0x3070
+ #define RF3290 0x3290
++#define RF3853 0x3853
+ #define RF5350 0x5350
+ #define RF5360 0x5360
+ #define RF5362 0x5362
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -7557,6 +7557,66 @@ static const struct rf_channel rf_vals_3
+ {14, 0xF0, 2, 0x18},
+ };
+
++static const struct rf_channel rf_vals_3853[] = {
++ {1, 241, 6, 2},
++ {2, 241, 6, 7},
++ {3, 242, 6, 2},
++ {4, 242, 6, 7},
++ {5, 243, 6, 2},
++ {6, 243, 6, 7},
++ {7, 244, 6, 2},
++ {8, 244, 6, 7},
++ {9, 245, 6, 2},
++ {10, 245, 6, 7},
++ {11, 246, 6, 2},
++ {12, 246, 6, 7},
++ {13, 247, 6, 2},
++ {14, 248, 6, 4},
++
++ {36, 0x56, 8, 4},
++ {38, 0x56, 8, 6},
++ {40, 0x56, 8, 8},
++ {44, 0x57, 8, 0},
++ {46, 0x57, 8, 2},
++ {48, 0x57, 8, 4},
++ {52, 0x57, 8, 8},
++ {54, 0x57, 8, 10},
++ {56, 0x58, 8, 0},
++ {60, 0x58, 8, 4},
++ {62, 0x58, 8, 6},
++ {64, 0x58, 8, 8},
++
++ {100, 0x5b, 8, 8},
++ {102, 0x5b, 8, 10},
++ {104, 0x5c, 8, 0},
++ {108, 0x5c, 8, 4},
++ {110, 0x5c, 8, 6},
++ {112, 0x5c, 8, 8},
++ {114, 0x5c, 8, 10},
++ {116, 0x5d, 8, 0},
++ {118, 0x5d, 8, 2},
++ {120, 0x5d, 8, 4},
++ {124, 0x5d, 8, 8},
++ {126, 0x5d, 8, 10},
++ {128, 0x5e, 8, 0},
++ {132, 0x5e, 8, 4},
++ {134, 0x5e, 8, 6},
++ {136, 0x5e, 8, 8},
++ {140, 0x5f, 8, 0},
++
++ {149, 0x5f, 8, 9},
++ {151, 0x5f, 8, 11},
++ {153, 0x60, 8, 1},
++ {157, 0x60, 8, 5},
++ {159, 0x60, 8, 7},
++ {161, 0x60, 8, 9},
++ {165, 0x61, 8, 1},
++ {167, 0x61, 8, 3},
++ {169, 0x61, 8, 5},
++ {171, 0x61, 8, 7},
++ {173, 0x61, 8, 9},
++};
++
+ static const struct rf_channel rf_vals_5592_xtal20[] = {
+ /* Channel, N, K, mod, R */
+ {1, 482, 4, 10, 3},
+@@ -7798,6 +7858,11 @@ static int rt2800_probe_hw_mode(struct r
+ spec->channels = rf_vals_3x;
+ break;
+
++ case RF3853:
++ spec->num_channels = ARRAY_SIZE(rf_vals_3853);
++ spec->channels = rf_vals_3853;
++ break;
++
+ case RF5592:
+ rt2800_register_read(rt2x00dev, MAC_DEBUG_INDEX, ®);
+ if (rt2x00_get_field32(reg, MAC_DEBUG_INDEX_XTAL)) {
--- /dev/null
+From f8e3fcf18e1f2d7f9e6a9680c5452da090f33d88 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Thu, 1 Aug 2013 14:40:44 +0200
+Subject: [PATCH] rt2x00: rt2800lib: enable VCO calibration for RF3853
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -4363,6 +4363,7 @@ void rt2800_vco_calibration(struct rt2x0
+ case RF3053:
+ case RF3070:
+ case RF3290:
++ case RF3853:
+ case RF5350:
+ case RF5360:
+ case RF5362:
+@@ -7980,6 +7981,7 @@ static int rt2800_probe_hw_mode(struct r
+ case RF3053:
+ case RF3070:
+ case RF3290:
++ case RF3853:
+ case RF5350:
+ case RF5360:
+ case RF5362:
--- /dev/null
+From 6e3a17190815c6aa4dc53c2cfe9125fb1154f187 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Sun, 24 Mar 2013 19:26:27 +0100
+Subject: [PATCH] rt2x00: rt2800lib: add channel configuration function for
+ RF3853
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 208 +++++++++++++++++++++++++++++++
+ 1 file changed, 208 insertions(+)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -2584,6 +2584,211 @@ static void rt2800_config_channel_rf3053
+ }
+ }
+
++static void rt2800_config_channel_rf3853(struct rt2x00_dev *rt2x00dev,
++ struct ieee80211_conf *conf,
++ struct rf_channel *rf,
++ struct channel_info *info)
++{
++ u8 rfcsr;
++ u8 bbp;
++ u8 pwr1, pwr2, pwr3;
++
++ const bool txbf_enabled = false; /* TODO */
++
++ /* TODO: add band selection */
++
++ if (rf->channel <= 14)
++ rt2800_rfcsr_write(rt2x00dev, 6, 0x40);
++ else if (rf->channel < 132)
++ rt2800_rfcsr_write(rt2x00dev, 6, 0x80);
++ else
++ rt2800_rfcsr_write(rt2x00dev, 6, 0x40);
++
++ rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1);
++ rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3);
++
++ if (rf->channel <= 14)
++ rt2800_rfcsr_write(rt2x00dev, 11, 0x46);
++ else
++ rt2800_rfcsr_write(rt2x00dev, 11, 0x48);
++
++ if (rf->channel <= 14)
++ rt2800_rfcsr_write(rt2x00dev, 12, 0x1a);
++ else
++ rt2800_rfcsr_write(rt2x00dev, 12, 0x52);
++
++ rt2800_rfcsr_write(rt2x00dev, 13, 0x12);
++
++ rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr);
++ rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 0);
++ rt2x00_set_field8(&rfcsr, RFCSR1_TX0_PD, 0);
++ rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 0);
++ rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 0);
++ rt2x00_set_field8(&rfcsr, RFCSR1_RX2_PD, 0);
++ rt2x00_set_field8(&rfcsr, RFCSR1_TX2_PD, 0);
++ rt2x00_set_field8(&rfcsr, RFCSR1_RF_BLOCK_EN, 1);
++ rt2x00_set_field8(&rfcsr, RFCSR1_PLL_PD, 1);
++
++ switch (rt2x00dev->default_ant.tx_chain_num) {
++ case 3:
++ rt2x00_set_field8(&rfcsr, RFCSR1_TX2_PD, 1);
++ /* fallthrough */
++ case 2:
++ rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 1);
++ /* fallthrough */
++ case 1:
++ rt2x00_set_field8(&rfcsr, RFCSR1_TX0_PD, 1);
++ break;
++ }
++
++ switch (rt2x00dev->default_ant.rx_chain_num) {
++ case 3:
++ rt2x00_set_field8(&rfcsr, RFCSR1_RX2_PD, 1);
++ /* fallthrough */
++ case 2:
++ rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 1);
++ /* fallthrough */
++ case 1:
++ rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 1);
++ break;
++ }
++ rt2800_rfcsr_write(rt2x00dev, 1, rfcsr);
++
++ rt2800_freq_cal_mode1(rt2x00dev);
++
++ rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr);
++ if (!conf_is_ht40(conf))
++ rfcsr &= ~(0x06);
++ else
++ rfcsr |= 0x06;
++ rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
++
++ if (rf->channel <= 14)
++ rt2800_rfcsr_write(rt2x00dev, 31, 0xa0);
++ else
++ rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
++
++ if (conf_is_ht40(conf))
++ rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
++ else
++ rt2800_rfcsr_write(rt2x00dev, 32, 0xd8);
++
++ if (rf->channel <= 14)
++ rt2800_rfcsr_write(rt2x00dev, 34, 0x3c);
++ else
++ rt2800_rfcsr_write(rt2x00dev, 34, 0x20);
++
++ /* loopback RF_BS */
++ rt2800_rfcsr_read(rt2x00dev, 36, &rfcsr);
++ if (rf->channel <= 14)
++ rt2x00_set_field8(&rfcsr, RFCSR36_RF_BS, 1);
++ else
++ rt2x00_set_field8(&rfcsr, RFCSR36_RF_BS, 0);
++ rt2800_rfcsr_write(rt2x00dev, 36, rfcsr);
++
++ if (rf->channel <= 14)
++ rfcsr = 0x23;
++ else if (rf->channel < 100)
++ rfcsr = 0x36;
++ else if (rf->channel < 132)
++ rfcsr = 0x32;
++ else
++ rfcsr = 0x30;
++
++ if (txbf_enabled)
++ rfcsr |= 0x40;
++
++ rt2800_rfcsr_write(rt2x00dev, 39, rfcsr);
++
++ if (rf->channel <= 14)
++ rt2800_rfcsr_write(rt2x00dev, 44, 0x93);
++ else
++ rt2800_rfcsr_write(rt2x00dev, 44, 0x9b);
++
++ if (rf->channel <= 14)
++ rfcsr = 0xbb;
++ else if (rf->channel < 100)
++ rfcsr = 0xeb;
++ else if (rf->channel < 132)
++ rfcsr = 0xb3;
++ else
++ rfcsr = 0x9b;
++ rt2800_rfcsr_write(rt2x00dev, 45, rfcsr);
++
++ if (rf->channel <= 14)
++ rfcsr = 0x8e;
++ else
++ rfcsr = 0x8a;
++
++ if (txbf_enabled)
++ rfcsr |= 0x20;
++
++ rt2800_rfcsr_write(rt2x00dev, 49, rfcsr);
++
++ rt2800_rfcsr_write(rt2x00dev, 50, 0x86);
++
++ rt2800_rfcsr_read(rt2x00dev, 51, &rfcsr);
++ if (rf->channel <= 14)
++ rt2800_rfcsr_write(rt2x00dev, 51, 0x75);
++ else
++ rt2800_rfcsr_write(rt2x00dev, 51, 0x51);
++
++ rt2800_rfcsr_read(rt2x00dev, 52, &rfcsr);
++ if (rf->channel <= 14)
++ rt2800_rfcsr_write(rt2x00dev, 52, 0x45);
++ else
++ rt2800_rfcsr_write(rt2x00dev, 52, 0x05);
++
++ if (rf->channel <= 14) {
++ pwr1 = info->default_power1 & 0x1f;
++ pwr2 = info->default_power2 & 0x1f;
++ pwr3 = info->default_power3 & 0x1f;
++ } else {
++ pwr1 = 0x48 | ((info->default_power1 & 0x18) << 1) |
++ (info->default_power1 & 0x7);
++ pwr2 = 0x48 | ((info->default_power2 & 0x18) << 1) |
++ (info->default_power2 & 0x7);
++ pwr3 = 0x48 | ((info->default_power3 & 0x18) << 1) |
++ (info->default_power3 & 0x7);
++ }
++
++ rt2800_rfcsr_write(rt2x00dev, 53, pwr1);
++ rt2800_rfcsr_write(rt2x00dev, 54, pwr2);
++ rt2800_rfcsr_write(rt2x00dev, 55, pwr3);
++
++ rt2x00_dbg(rt2x00dev, "Channel:%d, pwr1:%02x, pwr2:%02x, pwr3:%02x\n",
++ rf->channel, pwr1, pwr2, pwr3);
++
++ bbp = (info->default_power1 >> 5) |
++ ((info->default_power2 & 0xe0) >> 1);
++ rt2800_bbp_write(rt2x00dev, 109, bbp);
++
++ rt2800_bbp_read(rt2x00dev, 110, &bbp);
++ bbp &= 0x0f;
++ bbp |= (info->default_power3 & 0xe0) >> 1;
++ rt2800_bbp_write(rt2x00dev, 110, bbp);
++
++ rt2800_rfcsr_read(rt2x00dev, 57, &rfcsr);
++ if (rf->channel <= 14)
++ rt2800_rfcsr_write(rt2x00dev, 57, 0x6e);
++ else
++ rt2800_rfcsr_write(rt2x00dev, 57, 0x3e);
++
++ /* Enable RF tuning */
++ rt2800_rfcsr_read(rt2x00dev, 3, &rfcsr);
++ rt2x00_set_field8(&rfcsr, RFCSR3_VCOCAL_EN, 1);
++ rt2800_rfcsr_write(rt2x00dev, 3, rfcsr);
++
++ udelay(2000);
++
++ rt2800_bbp_read(rt2x00dev, 49, &bbp);
++ /* clear update flag */
++ rt2800_bbp_write(rt2x00dev, 49, bbp & 0xfe);
++ rt2800_bbp_write(rt2x00dev, 49, bbp);
++
++ /* TODO: add calibration for TxBF */
++}
++
+ #define POWER_BOUND 0x27
+ #define POWER_BOUND_5G 0x2b
+
+@@ -3203,6 +3408,9 @@ static void rt2800_config_channel(struct
+ case RF3322:
+ rt2800_config_channel_rf3322(rt2x00dev, conf, rf, info);
+ break;
++ case RF3853:
++ rt2800_config_channel_rf3853(rt2x00dev, conf, rf, info);
++ break;
+ case RF3070:
+ case RF5350:
+ case RF5360:
--- /dev/null
+From afd38ae82226551bf879b6c7c4b620c271fee9d2 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Thu, 1 Aug 2013 14:42:05 +0200
+Subject: [PATCH] rt2x00: rt2800lib: enable RF3853 support
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -7483,6 +7483,7 @@ static int rt2800_init_eeprom(struct rt2
+ case RF3290:
+ case RF3320:
+ case RF3322:
++ case RF3853:
+ case RF5350:
+ case RF5360:
+ case RF5362:
--- /dev/null
+From 0094872a5e8e4664c6ea1b2dfa487063d39ae363 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Sun, 24 Mar 2013 19:26:26 +0100
+Subject: [PATCH] rt2x00: rt2800lib: add MAC register initialization for
+ RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800.h | 14 ++++++++++++++
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 19 ++++++++++++++++---
+ 2 files changed, 30 insertions(+), 3 deletions(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
+@@ -1574,6 +1574,20 @@
+ #define TX_PWR_CFG_9_STBC7_CH2 FIELD32(0x00000f00)
+
+ /*
++ * TX_TXBF_CFG:
++ */
++#define TX_TXBF_CFG_0 0x138c
++#define TX_TXBF_CFG_1 0x13a4
++#define TX_TXBF_CFG_2 0x13a8
++#define TX_TXBF_CFG_3 0x13ac
++
++/*
++ * TX_FBK_CFG_3S:
++ */
++#define TX_FBK_CFG_3S_0 0x13c4
++#define TX_FBK_CFG_3S_1 0x13c8
++
++/*
+ * RX_FILTER_CFG: RX configuration register.
+ */
+ #define RX_FILTER_CFG 0x1400
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -4946,6 +4946,12 @@ static int rt2800_init_registers(struct
+ rt2800_register_write(rt2x00dev, TX_SW_CFG2,
+ 0x00000000);
+ }
++ } else if (rt2x00_rt(rt2x00dev, RT3883)) {
++ rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000402);
++ rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000);
++ rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00040000);
++ rt2800_register_write(rt2x00dev, TX_TXBF_CFG_0, 0x8000fc21);
++ rt2800_register_write(rt2x00dev, TX_TXBF_CFG_3, 0x00009c40);
+ } else if (rt2x00_rt(rt2x00dev, RT5390) ||
+ rt2x00_rt(rt2x00dev, RT5392)) {
+ rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000404);
+@@ -5140,6 +5146,11 @@ static int rt2800_init_registers(struct
+ reg = rt2x00_rt(rt2x00dev, RT5592) ? 0x00000082 : 0x00000002;
+ rt2800_register_write(rt2x00dev, TXOP_HLDR_ET, reg);
+
++ if (rt2x00_rt(rt2x00dev, RT3883)) {
++ rt2800_register_write(rt2x00dev, TX_FBK_CFG_3S_0, 0x12111008);
++ rt2800_register_write(rt2x00dev, TX_FBK_CFG_3S_1, 0x16151413);
++ }
++
+ rt2800_register_read(rt2x00dev, TX_RTS_CFG, ®);
+ rt2x00_set_field32(®, TX_RTS_CFG_AUTO_RTS_RETRY_LIMIT, 7);
+ rt2x00_set_field32(®, TX_RTS_CFG_RTS_THRES,
--- /dev/null
+From 6c2d32478159fffff0b85abb6817a21bb2338231 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Sun, 24 Mar 2013 19:26:27 +0100
+Subject: [PATCH] rt2x00: rt2800soc: fix rt2800soc_disable_radio for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800soc.c | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c
+@@ -51,9 +51,16 @@ static bool rt2800soc_hwcrypt_disabled(s
+
+ static void rt2800soc_disable_radio(struct rt2x00_dev *rt2x00dev)
+ {
++ u32 reg;
++
+ rt2800_disable_radio(rt2x00dev);
+ rt2x00mmio_register_write(rt2x00dev, PWR_PIN_CFG, 0);
+- rt2x00mmio_register_write(rt2x00dev, TX_PIN_CFG, 0);
++
++ reg = 0;
++ if (rt2x00_rt(rt2x00dev, RT3883))
++ rt2x00_set_field32(®, TX_PIN_CFG_RFTR_EN, 1);
++
++ rt2x00mmio_register_write(rt2x00dev, TX_PIN_CFG, reg);
+ }
+
+ static int rt2800soc_set_device_state(struct rt2x00_dev *rt2x00dev,
--- /dev/null
+From 84833056aa7dd25f5b097e31c78f2a0914c5160c Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Sun, 24 Mar 2013 19:26:26 +0100
+Subject: [PATCH] rt2x00: rt2800lib: add BBP register initialization for
+ RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 44 +++++++++++++++++++++++++++++++
+ 1 file changed, 44 insertions(+)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -5767,6 +5767,47 @@ static void rt2800_init_bbp_3593(struct
+ rt2800_bbp_write(rt2x00dev, 103, 0xc0);
+ }
+
++static void rt2800_init_bbp_3883(struct rt2x00_dev *rt2x00dev)
++{
++ rt2800_init_bbp_early(rt2x00dev);
++
++ rt2800_bbp_write(rt2x00dev, 4, 0x50);
++ rt2800_bbp_write(rt2x00dev, 47, 0x48);
++
++ rt2800_bbp_write(rt2x00dev, 86, 0x46);
++ rt2800_bbp_write(rt2x00dev, 88, 0x90);
++
++ rt2800_bbp_write(rt2x00dev, 92, 0x02);
++
++ rt2800_bbp_write(rt2x00dev, 103, 0xc0);
++ rt2800_bbp_write(rt2x00dev, 104, 0x92);
++ rt2800_bbp_write(rt2x00dev, 105, 0x34);
++ rt2800_bbp_write(rt2x00dev, 106, 0x12);
++ rt2800_bbp_write(rt2x00dev, 120, 0x50);
++ rt2800_bbp_write(rt2x00dev, 137, 0x0f);
++ rt2800_bbp_write(rt2x00dev, 163, 0x9d);
++
++ /* Set ITxBF timeout to 0x9C40=1000msec */
++ rt2800_bbp_write(rt2x00dev, 179, 0x02);
++ rt2800_bbp_write(rt2x00dev, 180, 0x00);
++ rt2800_bbp_write(rt2x00dev, 182, 0x40);
++ rt2800_bbp_write(rt2x00dev, 180, 0x01);
++ rt2800_bbp_write(rt2x00dev, 182, 0x9c);
++
++ rt2800_bbp_write(rt2x00dev, 179, 0x00);
++
++ /* Reprogram the inband interface to put right values in RXWI */
++ rt2800_bbp_write(rt2x00dev, 142, 0x04);
++ rt2800_bbp_write(rt2x00dev, 143, 0x3b);
++ rt2800_bbp_write(rt2x00dev, 142, 0x06);
++ rt2800_bbp_write(rt2x00dev, 143, 0xa0);
++ rt2800_bbp_write(rt2x00dev, 142, 0x07);
++ rt2800_bbp_write(rt2x00dev, 143, 0xa1);
++ rt2800_bbp_write(rt2x00dev, 142, 0x08);
++ rt2800_bbp_write(rt2x00dev, 143, 0xa2);
++ rt2800_bbp_write(rt2x00dev, 148, 0xc8);
++}
++
+ static void rt2800_init_bbp_53xx(struct rt2x00_dev *rt2x00dev)
+ {
+ int ant, div_mode;
+@@ -5986,6 +6027,9 @@ static void rt2800_init_bbp(struct rt2x0
+ case RT3593:
+ rt2800_init_bbp_3593(rt2x00dev);
+ return;
++ case RT3883:
++ rt2800_init_bbp_3883(rt2x00dev);
++ return;
+ case RT5390:
+ case RT5392:
+ rt2800_init_bbp_53xx(rt2x00dev);
--- /dev/null
+From 99c659cf345640fd0f733cbcaf4583cc2c868ec0 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Mon, 29 Apr 2013 13:21:48 +0200
+Subject: [PATCH] rt2x00: rt2800lib: add RFCSR initialization for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800.h | 1 +
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 141 +++++++++++++++++++++++++++++++
+ 2 files changed, 142 insertions(+)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
+@@ -2155,6 +2155,7 @@ struct mac_iveiv_entry {
+ /*
+ * RFCSR 2:
+ */
++#define RFCSR2_RESCAL_BP FIELD8(0x40)
+ #define RFCSR2_RESCAL_EN FIELD8(0x80)
+
+ /*
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -6899,6 +6899,144 @@ static void rt2800_init_rfcsr_5350(struc
+ rt2800_rfcsr_write(rt2x00dev, 63, 0x00);
+ }
+
++static void rt2800_init_rfcsr_3883(struct rt2x00_dev *rt2x00dev)
++{
++ u8 rfcsr;
++
++ /* TODO: get the actual ECO value from the SoC */
++ const unsigned int eco = 5;
++
++ rt2800_rf_init_calibration(rt2x00dev, 2);
++
++ rt2800_rfcsr_write(rt2x00dev, 0, 0xe0);
++ rt2800_rfcsr_write(rt2x00dev, 1, 0x03);
++ rt2800_rfcsr_write(rt2x00dev, 2, 0x50);
++ rt2800_rfcsr_write(rt2x00dev, 3, 0x20);
++ rt2800_rfcsr_write(rt2x00dev, 4, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 5, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 6, 0x40);
++ rt2800_rfcsr_write(rt2x00dev, 7, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 8, 0x5b);
++ rt2800_rfcsr_write(rt2x00dev, 9, 0x08);
++ rt2800_rfcsr_write(rt2x00dev, 10, 0xd3);
++ rt2800_rfcsr_write(rt2x00dev, 11, 0x48);
++ rt2800_rfcsr_write(rt2x00dev, 12, 0x1a);
++ rt2800_rfcsr_write(rt2x00dev, 13, 0x12);
++ rt2800_rfcsr_write(rt2x00dev, 14, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 15, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 16, 0x00);
++
++ /* RFCSR 17 will be initialized later based on the
++ * frequency offset stored in the EEPROM
++ */
++
++ rt2800_rfcsr_write(rt2x00dev, 18, 0x40);
++ rt2800_rfcsr_write(rt2x00dev, 19, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 20, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 21, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 22, 0x20);
++ rt2800_rfcsr_write(rt2x00dev, 23, 0xc0);
++ rt2800_rfcsr_write(rt2x00dev, 24, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 25, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 26, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 27, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 28, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 29, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 30, 0x10);
++ rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
++ rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
++ rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 34, 0x20);
++ rt2800_rfcsr_write(rt2x00dev, 35, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 36, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 37, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 38, 0x86);
++ rt2800_rfcsr_write(rt2x00dev, 39, 0x23);
++ rt2800_rfcsr_write(rt2x00dev, 40, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 41, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 42, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 43, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 44, 0x93);
++ rt2800_rfcsr_write(rt2x00dev, 45, 0xbb);
++ rt2800_rfcsr_write(rt2x00dev, 46, 0x60);
++ rt2800_rfcsr_write(rt2x00dev, 47, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 48, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 49, 0x8e);
++ rt2800_rfcsr_write(rt2x00dev, 50, 0x86);
++ rt2800_rfcsr_write(rt2x00dev, 51, 0x51);
++ rt2800_rfcsr_write(rt2x00dev, 52, 0x05);
++ rt2800_rfcsr_write(rt2x00dev, 53, 0x76);
++ rt2800_rfcsr_write(rt2x00dev, 54, 0x76);
++ rt2800_rfcsr_write(rt2x00dev, 55, 0x76);
++ rt2800_rfcsr_write(rt2x00dev, 56, 0xdb);
++ rt2800_rfcsr_write(rt2x00dev, 57, 0x3e);
++ rt2800_rfcsr_write(rt2x00dev, 58, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 59, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 60, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 61, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 62, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 63, 0x00);
++
++ /* TODO: rx filter calibration? */
++
++ rt2800_bbp_write(rt2x00dev, 137, 0x0f);
++
++ rt2800_bbp_write(rt2x00dev, 163, 0x9d);
++
++ rt2800_bbp_write(rt2x00dev, 105, 0x05);
++
++ rt2800_bbp_write(rt2x00dev, 179, 0x02);
++ rt2800_bbp_write(rt2x00dev, 180, 0x00);
++ rt2800_bbp_write(rt2x00dev, 182, 0x40);
++ rt2800_bbp_write(rt2x00dev, 180, 0x01);
++ rt2800_bbp_write(rt2x00dev, 182, 0x9c);
++
++ rt2800_bbp_write(rt2x00dev, 179, 0x00);
++
++ rt2800_bbp_write(rt2x00dev, 142, 0x04);
++ rt2800_bbp_write(rt2x00dev, 143, 0x3b);
++ rt2800_bbp_write(rt2x00dev, 142, 0x06);
++ rt2800_bbp_write(rt2x00dev, 143, 0xa0);
++ rt2800_bbp_write(rt2x00dev, 142, 0x07);
++ rt2800_bbp_write(rt2x00dev, 143, 0xa1);
++ rt2800_bbp_write(rt2x00dev, 142, 0x08);
++ rt2800_bbp_write(rt2x00dev, 143, 0xa2);
++ rt2800_bbp_write(rt2x00dev, 148, 0xc8);
++
++ if (eco == 5) {
++ rt2800_rfcsr_write(rt2x00dev, 32, 0xd8);
++ rt2800_rfcsr_write(rt2x00dev, 33, 0x32);
++ }
++
++ rt2800_rfcsr_read(rt2x00dev, 2, &rfcsr);
++ rt2x00_set_field8(&rfcsr, RFCSR2_RESCAL_BP, 0);
++ rt2x00_set_field8(&rfcsr, RFCSR2_RESCAL_EN, 1);
++ rt2800_rfcsr_write(rt2x00dev, 2, rfcsr);
++ msleep(1);
++ rt2x00_set_field8(&rfcsr, RFCSR2_RESCAL_EN, 0);
++ rt2800_rfcsr_write(rt2x00dev, 2, rfcsr);
++
++ rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr);
++ rt2x00_set_field8(&rfcsr, RFCSR1_RF_BLOCK_EN, 1);
++ rt2800_rfcsr_write(rt2x00dev, 1, rfcsr);
++
++ rt2800_rfcsr_read(rt2x00dev, 6, &rfcsr);
++ rfcsr |= 0xc0;
++ rt2800_rfcsr_write(rt2x00dev, 6, rfcsr);
++
++ rt2800_rfcsr_read(rt2x00dev, 22, &rfcsr);
++ rfcsr |= 0x20;
++ rt2800_rfcsr_write(rt2x00dev, 22, rfcsr);
++
++ rt2800_rfcsr_read(rt2x00dev, 46, &rfcsr);
++ rfcsr |= 0x20;
++ rt2800_rfcsr_write(rt2x00dev, 46, rfcsr);
++
++ rt2800_rfcsr_read(rt2x00dev, 20, &rfcsr);
++ rfcsr &= ~0xee;
++ rt2800_rfcsr_write(rt2x00dev, 20, rfcsr);
++}
++
+ static void rt2800_init_rfcsr_5390(struct rt2x00_dev *rt2x00dev)
+ {
+ rt2800_rf_init_calibration(rt2x00dev, 2);
+@@ -7130,6 +7268,9 @@ static void rt2800_init_rfcsr(struct rt2
+ case RT3390:
+ rt2800_init_rfcsr_3390(rt2x00dev);
+ break;
++ case RT3883:
++ rt2800_init_rfcsr_3883(rt2x00dev);
++ break;
+ case RT3572:
+ rt2800_init_rfcsr_3572(rt2x00dev);
+ break;
--- /dev/null
+From 86022438ffeb1b87dfcd018bf477fdbb43076691 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Wed, 8 May 2013 19:35:33 +0200
+Subject: [PATCH] rt2x00: rt2800lib: use the extended EEPROM map for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -309,7 +309,8 @@ static unsigned int rt2800_eeprom_word_i
+ wiphy_name(rt2x00dev->hw->wiphy), word))
+ return 0;
+
+- if (rt2x00_rt(rt2x00dev, RT3593))
++ if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883))
+ map = rt2800_eeprom_map_ext;
+ else
+ map = rt2800_eeprom_map;
--- /dev/null
+From 4cf5403f02fa65dc2207f61d223cffa9ae50e907 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Thu, 1 Aug 2013 14:48:21 +0200
+Subject: [PATCH] rt2x00: rt2800lib: force rf type to RF3853 on RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -7660,6 +7660,8 @@ static int rt2800_init_eeprom(struct rt2
+ rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf);
+ else if (rt2x00_rt(rt2x00dev, RT3352))
+ rf = RF3322;
++ else if (rt2x00_rt(rt2x00dev, RT3883))
++ rf = RF3853;
+ else if (rt2x00_rt(rt2x00dev, RT5350))
+ rf = RF5350;
+ else
--- /dev/null
+From 269f19c848a2380db03a3f207cafb88e28d71c53 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Sun, 24 Mar 2013 19:26:28 +0100
+Subject: [PATCH] rt2x00: rt2800lib: add channel configuration code for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 72 +++++++++++++++++++++++++++++--
+ 1 file changed, 69 insertions(+), 3 deletions(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -3371,6 +3371,36 @@ static char rt2800_txpower_to_dev(struct
+ return clamp_t(char, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER);
+ }
+
++static void rt3883_bbp_adjust(struct rt2x00_dev *rt2x00dev,
++ struct rf_channel *rf)
++{
++ u8 bbp;
++
++ bbp = (rf->channel > 14) ? 0x48 : 0x38;
++ rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp);
++
++ rt2800_bbp_write(rt2x00dev, 69, 0x12);
++
++ if (rf->channel <= 14) {
++ rt2800_bbp_write(rt2x00dev, 70, 0x0a);
++ } else {
++ /* Disable CCK packet detection */
++ rt2800_bbp_write(rt2x00dev, 70, 0x00);
++ }
++
++ rt2800_bbp_write(rt2x00dev, 73, 0x10);
++
++ if (rf->channel > 14) {
++ rt2800_bbp_write(rt2x00dev, 62, 0x1d);
++ rt2800_bbp_write(rt2x00dev, 63, 0x1d);
++ rt2800_bbp_write(rt2x00dev, 64, 0x1d);
++ } else {
++ rt2800_bbp_write(rt2x00dev, 62, 0x2d);
++ rt2800_bbp_write(rt2x00dev, 63, 0x2d);
++ rt2800_bbp_write(rt2x00dev, 64, 0x2d);
++ }
++}
++
+ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
+ struct ieee80211_conf *conf,
+ struct rf_channel *rf,
+@@ -3389,6 +3419,12 @@ static void rt2800_config_channel(struct
+ rt2800_txpower_to_dev(rt2x00dev, rf->channel,
+ info->default_power3);
+
++ switch (rt2x00dev->chip.rt) {
++ case RT3883:
++ rt3883_bbp_adjust(rt2x00dev, rf);
++ break;
++ }
++
+ switch (rt2x00dev->chip.rf) {
+ case RF2020:
+ case RF3020:
+@@ -3490,6 +3526,15 @@ static void rt2800_config_channel(struct
+ rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
+ rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
+ rt2800_bbp_write(rt2x00dev, 77, 0x98);
++ } else if (rt2x00_rt(rt2x00dev, RT3883)) {
++ rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
++ rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
++ rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
++
++ if (rt2x00dev->default_ant.rx_chain_num > 1)
++ rt2800_bbp_write(rt2x00dev, 86, 0x46);
++ else
++ rt2800_bbp_write(rt2x00dev, 86, 0);
+ } else {
+ rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
+ rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
+@@ -3502,6 +3547,7 @@ static void rt2800_config_channel(struct
+ !rt2x00_rt(rt2x00dev, RT5392)) {
+ if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
+ rt2800_bbp_write(rt2x00dev, 82, 0x62);
++ rt2800_bbp_write(rt2x00dev, 82, 0x62);
+ rt2800_bbp_write(rt2x00dev, 75, 0x46);
+ } else {
+ if (rt2x00_rt(rt2x00dev, RT3593))
+@@ -3510,19 +3556,22 @@ static void rt2800_config_channel(struct
+ rt2800_bbp_write(rt2x00dev, 82, 0x84);
+ rt2800_bbp_write(rt2x00dev, 75, 0x50);
+ }
+- if (rt2x00_rt(rt2x00dev, RT3593))
++ if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883))
+ rt2800_bbp_write(rt2x00dev, 83, 0x8a);
+ }
+
+ } else {
+ if (rt2x00_rt(rt2x00dev, RT3572))
+ rt2800_bbp_write(rt2x00dev, 82, 0x94);
+- else if (rt2x00_rt(rt2x00dev, RT3593))
++ else if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883))
+ rt2800_bbp_write(rt2x00dev, 82, 0x82);
+ else
+ rt2800_bbp_write(rt2x00dev, 82, 0xf2);
+
+- if (rt2x00_rt(rt2x00dev, RT3593))
++ if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883))
+ rt2800_bbp_write(rt2x00dev, 83, 0x9a);
+
+ if (rt2x00_has_cap_external_lna_a(rt2x00dev))
+@@ -3644,6 +3693,23 @@ static void rt2800_config_channel(struct
+
+ rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg);
+
++ usleep_range(1000, 1500);
++ }
++
++ if (rt2x00_rt(rt2x00dev, RT3883)) {
++ if (!conf_is_ht40(conf))
++ rt2800_bbp_write(rt2x00dev, 105, 0x34);
++ else
++ rt2800_bbp_write(rt2x00dev, 105, 0x04);
++
++ /* AGC init */
++ if (rf->channel <= 14)
++ reg = 0x2e + rt2x00dev->lna_gain;
++ else
++ reg = 0x20 + ((rt2x00dev->lna_gain * 5) / 3);
++
++ rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg);
++
+ usleep_range(1000, 1500);
+ }
+
--- /dev/null
+From e37d93abaabe3ab72b0332a18092acc162307274 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Mon, 30 Sep 2013 13:57:26 +0200
+Subject: [PATCH] rt2x00: rt2800lib: fix txpower_to_dev function for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -3358,13 +3358,15 @@ static char rt2800_txpower_to_dev(struct
+ unsigned int channel,
+ char txpower)
+ {
+- if (rt2x00_rt(rt2x00dev, RT3593))
++ if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883))
+ txpower = rt2x00_get_field8(txpower, EEPROM_TXPOWER_ALC);
+
+ if (channel <= 14)
+ return clamp_t(char, txpower, MIN_G_TXPOWER, MAX_G_TXPOWER);
+
+- if (rt2x00_rt(rt2x00dev, RT3593))
++ if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883))
+ return clamp_t(char, txpower, MIN_A_TXPOWER_3593,
+ MAX_A_TXPOWER_3593);
+ else
--- /dev/null
+From c4d79e344bd580d85821390d49f92dced7d8e125 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Sun, 24 Mar 2013 19:26:29 +0100
+Subject: [PATCH] rt2x00: rt2800lib: use correct txpower calculation function
+ for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -4596,7 +4596,8 @@ static void rt2800_config_txpower(struct
+ struct ieee80211_channel *chan,
+ int power_level)
+ {
+- if (rt2x00_rt(rt2x00dev, RT3593))
++ if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883))
+ rt2800_config_txpower_rt3593(rt2x00dev, chan, power_level);
+ else
+ rt2800_config_txpower_rt28xx(rt2x00dev, chan, power_level);
--- /dev/null
+From caea0671cd8fd9ade4f5969cbe0ee545e94ae105 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Sat, 24 Aug 2013 11:49:55 +0200
+Subject: [PATCH] rt2x00: rt2800lib: hardcode txmixer gain values to zero for
+ RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -7543,7 +7543,8 @@ static u8 rt2800_get_txmixer_gain_24g(st
+ {
+ u16 word;
+
+- if (rt2x00_rt(rt2x00dev, RT3593))
++ if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883))
+ return 0;
+
+ rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &word);
+@@ -7557,7 +7558,8 @@ static u8 rt2800_get_txmixer_gain_5g(str
+ {
+ u16 word;
+
+- if (rt2x00_rt(rt2x00dev, RT3593))
++ if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883))
+ return 0;
+
+ rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, &word);
--- /dev/null
+From 11c40fb47c4a4dd6ad060c2ae127ced89ffb9fe1 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Thu, 18 Apr 2013 14:33:33 +0200
+Subject: [PATCH] rt2x00: rt2800lib: use correct [RT]XWI size for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -520,6 +520,7 @@ void rt2800_get_txwi_rxwi_size(struct rt
+ {
+ switch (rt2x00dev->chip.rt) {
+ case RT3593:
++ case RT3883:
+ *txwi_size = TXWI_DESC_SIZE_4WORDS;
+ *rxwi_size = RXWI_DESC_SIZE_5WORDS;
+ break;
--- /dev/null
+From fa5ad9c025610c22048add2f0ad03f62b6ca1e74 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Mon, 30 Sep 2013 16:53:33 +0200
+Subject: [PATCH] rt2x00: rt2800lib: fix antenna configuration for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -1888,7 +1888,8 @@ void rt2800_config_ant(struct rt2x00_dev
+ rt2800_bbp_write(rt2x00dev, 3, r3);
+ rt2800_bbp_write(rt2x00dev, 1, r1);
+
+- if (rt2x00_rt(rt2x00dev, RT3593)) {
++ if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883)) {
+ if (ant->rx_chain_num == 1)
+ rt2800_bbp_write(rt2x00dev, 86, 0x00);
+ else
--- /dev/null
+From 6d668fef3a1baa60bdd715ee062ddb6333d2647c Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Mon, 30 Sep 2013 16:58:23 +0200
+Subject: [PATCH] rt2x00: rt2800lib: fix LNA gain configuration for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -1911,7 +1911,8 @@ static void rt2800_config_lna_gain(struc
+ rt2800_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
+ lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_A0);
+ } else if (libconf->rf.channel <= 128) {
+- if (rt2x00_rt(rt2x00dev, RT3593)) {
++ if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883)) {
+ rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2, &eeprom);
+ lna_gain = rt2x00_get_field16(eeprom,
+ EEPROM_EXT_LNA2_A1);
+@@ -1921,7 +1922,8 @@ static void rt2800_config_lna_gain(struc
+ EEPROM_RSSI_BG2_LNA_A1);
+ }
+ } else {
+- if (rt2x00_rt(rt2x00dev, RT3593)) {
++ if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883)) {
+ rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2, &eeprom);
+ lna_gain = rt2x00_get_field16(eeprom,
+ EEPROM_EXT_LNA2_A2);
--- /dev/null
+From c49b2d829aa1c816a46a577cdec6d2ff14d9f06e Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Tue, 1 Oct 2013 15:40:08 +0200
+Subject: [PATCH] rt2x00: rt2800lib: fix VGC setup for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -4799,7 +4799,8 @@ static u8 rt2800_get_default_vgc(struct
+ else
+ vgc = 0x2e + rt2x00dev->lna_gain;
+ } else { /* 5GHZ band */
+- if (rt2x00_rt(rt2x00dev, RT3593))
++ if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883))
+ vgc = 0x20 + (rt2x00dev->lna_gain * 5) / 3;
+ else if (rt2x00_rt(rt2x00dev, RT5592))
+ vgc = 0x24 + (2 * rt2x00dev->lna_gain);
+@@ -4819,7 +4820,8 @@ static inline void rt2800_set_vgc(struct
+ {
+ if (qual->vgc_level != vgc_level) {
+ if (rt2x00_rt(rt2x00dev, RT3572) ||
+- rt2x00_rt(rt2x00dev, RT3593)) {
++ rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883)) {
+ rt2800_bbp_write_with_rx_chain(rt2x00dev, 66,
+ vgc_level);
+ } else if (rt2x00_rt(rt2x00dev, RT5592)) {
+@@ -4866,6 +4868,11 @@ void rt2800_link_tuner(struct rt2x00_dev
+ }
+ break;
+
++ case RT3883:
++ if (qual->rssi > -65)
++ vgc += 0x10;
++ break;
++
+ case RT5592:
+ if (qual->rssi > -65)
+ vgc += 0x20;
--- /dev/null
+From 1616650aea676541d4dc8adc6f4219856d193c8b Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Tue, 1 Oct 2013 17:27:57 +0200
+Subject: [PATCH] rt2x00: rt2800lib: fix EEPROM LNA validation for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -7676,7 +7676,8 @@ static int rt2800_validate_eeprom(struct
+ rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word);
+ if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10)
+ rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0);
+- if (!rt2x00_rt(rt2x00dev, RT3593)) {
++ if (!rt2x00_rt(rt2x00dev, RT3593) &&
++ !rt2x00_rt(rt2x00dev, RT3883)) {
+ if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 ||
+ rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff)
+ rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1,
+@@ -7696,7 +7697,8 @@ static int rt2800_validate_eeprom(struct
+ rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word);
+ if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10)
+ rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0);
+- if (!rt2x00_rt(rt2x00dev, RT3593)) {
++ if (!rt2x00_rt(rt2x00dev, RT3593) &&
++ !rt2x00_rt(rt2x00dev, RT3883)) {
+ if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 ||
+ rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff)
+ rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2,
+@@ -7704,7 +7706,8 @@ static int rt2800_validate_eeprom(struct
+ }
+ rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word);
+
+- if (rt2x00_rt(rt2x00dev, RT3593)) {
++ if (rt2x00_rt(rt2x00dev, RT3593) ||
++ rt2x00_rt(rt2x00dev, RT3883)) {
+ rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2, &word);
+ if (rt2x00_get_field16(word, EEPROM_EXT_LNA2_A1) == 0x00 ||
+ rt2x00_get_field16(word, EEPROM_EXT_LNA2_A1) == 0xff)
--- /dev/null
+From e3871034a0e7c8a95152dc3eafbcc4535398cbdc Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Wed, 2 Oct 2013 10:11:59 +0200
+Subject: [PATCH] rt2x00: rt2800lib: fix txpower compensation for RT3883
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -3965,6 +3965,9 @@ static u8 rt2800_compensate_txpower(stru
+ if (rt2x00_rt(rt2x00dev, RT3593))
+ return min_t(u8, txpower, 0xc);
+
++ if (rt2x00_rt(rt2x00dev, RT3883))
++ return min_t(u8, txpower, 0xf);
++
+ if (rt2x00_has_cap_power_limit(rt2x00dev)) {
+ /*
+ * Check if eirp txpower exceed txpower_limit.
--- /dev/null
+From 5e67d4f8a46d19748b501c2ef86de3f50d3cfd51 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@openwrt.org>
+Date: Sun, 24 Mar 2013 19:26:27 +0100
+Subject: [PATCH] rt2x00: rt2800mmio: add a workaround for spurious
+ TX_FIFO_STATUS interrupts
+
+Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800mmio.c | 72 +++++++++++++++++++++++++-----
+ drivers/net/wireless/ralink/rt2x00/rt2x00.h | 5 +++
+ 2 files changed, 65 insertions(+), 12 deletions(-)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
+@@ -415,9 +415,9 @@ void rt2800mmio_autowake_tasklet(unsigne
+ }
+ EXPORT_SYMBOL_GPL(rt2800mmio_autowake_tasklet);
+
+-static void rt2800mmio_txstatus_interrupt(struct rt2x00_dev *rt2x00dev)
++static void rt2800mmio_txstatus_interrupt(struct rt2x00_dev *rt2x00dev,
++ u32 status)
+ {
+- u32 status;
+ int i;
+
+ /*
+@@ -438,29 +438,77 @@ static void rt2800mmio_txstatus_interrup
+ * Since we have only one producer and one consumer we don't
+ * need to lock the kfifo.
+ */
+- for (i = 0; i < rt2x00dev->tx->limit; i++) {
+- rt2x00mmio_register_read(rt2x00dev, TX_STA_FIFO, &status);
+-
+- if (!rt2x00_get_field32(status, TX_STA_FIFO_VALID))
+- break;
+-
++ i = 0;
++ do {
+ if (!kfifo_put(&rt2x00dev->txstatus_fifo, status)) {
+- rt2x00_warn(rt2x00dev, "TX status FIFO overrun, drop tx status report\n");
++ rt2x00_warn(rt2x00dev,
++ "TX status FIFO overrun, drop TX status report\n");
+ break;
+ }
+- }
++
++ if (++i >= rt2x00dev->tx->limit)
++ break;
++
++ rt2x00mmio_register_read(rt2x00dev, TX_STA_FIFO, &status);
++ } while (rt2x00_get_field32(status, TX_STA_FIFO_VALID));
+
+ /* Schedule the tasklet for processing the tx status. */
+ tasklet_schedule(&rt2x00dev->txstatus_tasklet);
+ }
+
++#define RT2800MMIO_TXSTATUS_IRQ_MAX_RETRIES 4
++
++static bool rt2800mmio_txstatus_is_spurious(struct rt2x00_dev *rt2x00dev,
++ u32 txstatus)
++{
++ if (likely(rt2x00_get_field32(txstatus, TX_STA_FIFO_VALID))) {
++ rt2x00dev->txstatus_irq_retries = 0;
++ return false;
++ }
++
++ rt2x00dev->txstatus_irq_retries++;
++
++ /* Ensure that we don't go into an infinite IRQ loop. */
++ if (rt2x00dev->txstatus_irq_retries >=
++ RT2800MMIO_TXSTATUS_IRQ_MAX_RETRIES) {
++ rt2x00_warn(rt2x00dev,
++ "%u spurious TX_FIFO_STATUS interrupt(s)\n",
++ rt2x00dev->txstatus_irq_retries);
++ rt2x00dev->txstatus_irq_retries = 0;
++ return false;
++ }
++
++ return true;
++}
++
+ irqreturn_t rt2800mmio_interrupt(int irq, void *dev_instance)
+ {
+ struct rt2x00_dev *rt2x00dev = dev_instance;
+ u32 reg, mask;
++ u32 txstatus = 0;
+
+- /* Read status and ACK all interrupts */
++ /* Read status */
+ rt2x00mmio_register_read(rt2x00dev, INT_SOURCE_CSR, ®);
++
++ if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) {
++ /* Due to unknown reason the hardware generates a
++ * TX_FIFO_STATUS interrupt before the TX_STA_FIFO
++ * register contain valid data. Read the TX status
++ * here to see if we have to process the actual
++ * request.
++ */
++ rt2x00mmio_register_read(rt2x00dev, TX_STA_FIFO, &txstatus);
++ if (rt2800mmio_txstatus_is_spurious(rt2x00dev, txstatus)) {
++ /* Remove the TX_FIFO_STATUS bit so it won't be
++ * processed in this turn. The hardware will
++ * generate another IRQ for us.
++ */
++ rt2x00_set_field32(®,
++ INT_SOURCE_CSR_TX_FIFO_STATUS, 0);
++ }
++ }
++
++ /* ACK interrupts */
+ rt2x00mmio_register_write(rt2x00dev, INT_SOURCE_CSR, reg);
+
+ if (!reg)
+@@ -477,7 +525,7 @@ irqreturn_t rt2800mmio_interrupt(int irq
+ mask = ~reg;
+
+ if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) {
+- rt2800mmio_txstatus_interrupt(rt2x00dev);
++ rt2800mmio_txstatus_interrupt(rt2x00dev, txstatus);
+ /*
+ * Never disable the TX_FIFO_STATUS interrupt.
+ */
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+@@ -999,6 +999,11 @@ struct rt2x00_dev {
+ int rf_channel;
+
+ /*
++ * Counter for tx status irq retries (rt2800pci).
++ */
++ unsigned int txstatus_irq_retries;
++
++ /*
+ * Protect the interrupt mask register.
+ */
+ spinlock_t irqmask_lock;
--- /dev/null
+--- /dev/null
++++ b/include/linux/rt2x00_platform.h
+@@ -0,0 +1,19 @@
++/*
++ * Platform data definition for the rt2x00 driver
++ *
++ * Copyright (C) 2011 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 _RT2X00_PLATFORM_H
++#define _RT2X00_PLATFORM_H
++
++struct rt2x00_platform_data {
++ char *eeprom_file_name;
++};
++
++#endif /* _RT2X00_PLATFORM_H */
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+@@ -40,6 +40,7 @@
+ #include <linux/average.h>
+ #include <linux/usb.h>
+ #include <linux/clk.h>
++#include <linux/rt2x00_platform.h>
+
+ #include <net/mac80211.h>
+
--- /dev/null
+--- a/.local-symbols
++++ b/.local-symbols
+@@ -336,6 +336,7 @@ RT2X00_LIB_FIRMWARE=
+ RT2X00_LIB_CRYPTO=
+ RT2X00_LIB_LEDS=
+ RT2X00_LIB_DEBUGFS=
++RT2X00_LIB_EEPROM=
+ RT2X00_DEBUG=
+ WLAN_VENDOR_REALTEK=
+ RTL8180=
+--- a/drivers/net/wireless/ralink/rt2x00/Kconfig
++++ b/drivers/net/wireless/ralink/rt2x00/Kconfig
+@@ -69,6 +69,7 @@ config RT2800PCI
+ select RT2X00_LIB_MMIO
+ select RT2X00_LIB_PCI
+ select RT2X00_LIB_FIRMWARE
++ select RT2X00_LIB_EEPROM
+ select RT2X00_LIB_CRYPTO
+ depends on CRC_CCITT
+ depends on EEPROM_93CX6
+@@ -215,6 +216,7 @@ config RT2800SOC
+ select RT2X00_LIB_MMIO
+ select RT2X00_LIB_CRYPTO
+ select RT2X00_LIB_FIRMWARE
++ select RT2X00_LIB_EEPROM
+ select RT2800_LIB
+ select RT2800_LIB_MMIO
+ ---help---
+@@ -265,6 +267,9 @@ config RT2X00_LIB_FIRMWARE
+ config RT2X00_LIB_CRYPTO
+ bool
+
++config RT2X00_LIB_EEPROM
++ boolean
++
+ config RT2X00_LIB_LEDS
+ bool
+ default y if (RT2X00_LIB=y && LEDS_CLASS=y) || (RT2X00_LIB=m && LEDS_CLASS!=n)
+--- a/drivers/net/wireless/ralink/rt2x00/Makefile
++++ b/drivers/net/wireless/ralink/rt2x00/Makefile
+@@ -7,6 +7,7 @@ rt2x00lib-$(CPTCFG_RT2X00_LIB_DEBUGFS) +
+ rt2x00lib-$(CPTCFG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o
+ rt2x00lib-$(CPTCFG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o
+ rt2x00lib-$(CPTCFG_RT2X00_LIB_LEDS) += rt2x00leds.o
++rt2x00lib-$(CPTCFG_RT2X00_LIB_EEPROM) += rt2x00eeprom.o
+
+ obj-$(CPTCFG_RT2X00_LIB) += rt2x00lib.o
+ obj-$(CPTCFG_RT2X00_LIB_MMIO) += rt2x00mmio.o
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
+@@ -20,6 +20,8 @@
+ #ifndef RT2800LIB_H
+ #define RT2800LIB_H
+
++#include "rt2800.h"
++
+ struct rt2800_ops {
+ void (*register_read)(struct rt2x00_dev *rt2x00dev,
+ const unsigned int offset, u32 *value);
+@@ -119,6 +121,15 @@ static inline int rt2800_read_eeprom(str
+ {
+ const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
+
++ if (rt2x00dev->eeprom_file) {
++ memcpy(rt2x00dev->eeprom, rt2x00dev->eeprom_file->data,
++ EEPROM_SIZE);
++ return 0;
++ }
++
++ if (!rt2800ops->read_eeprom)
++ return -EINVAL;
++
+ return rt2800ops->read_eeprom(rt2x00dev);
+ }
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c
+@@ -102,19 +102,6 @@ static int rt2800soc_set_device_state(st
+ return retval;
+ }
+
+-static int rt2800soc_read_eeprom(struct rt2x00_dev *rt2x00dev)
+-{
+- void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE);
+-
+- if (!base_addr)
+- return -ENOMEM;
+-
+- memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE);
+-
+- iounmap(base_addr);
+- return 0;
+-}
+-
+ /* Firmware functions */
+ static char *rt2800soc_get_firmware_name(struct rt2x00_dev *rt2x00dev)
+ {
+@@ -178,7 +165,6 @@ static const struct rt2800_ops rt2800soc
+ .register_multiread = rt2x00mmio_register_multiread,
+ .register_multiwrite = rt2x00mmio_register_multiwrite,
+ .regbusy_read = rt2x00mmio_regbusy_read,
+- .read_eeprom = rt2800soc_read_eeprom,
+ .hwcrypt_disabled = rt2800soc_hwcrypt_disabled,
+ .drv_write_firmware = rt2800soc_write_firmware,
+ .drv_init_registers = rt2800mmio_init_registers,
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+@@ -701,6 +701,7 @@ enum rt2x00_capability_flags {
+ REQUIRE_HT_TX_DESC,
+ REQUIRE_PS_AUTOWAKE,
+ REQUIRE_DELAYED_RFKILL,
++ REQUIRE_EEPROM_FILE,
+
+ /*
+ * Capabilities
+@@ -976,6 +977,11 @@ struct rt2x00_dev {
+ const struct firmware *fw;
+
+ /*
++ * EEPROM image.
++ */
++ const struct firmware *eeprom_file;
++
++ /*
+ * FIFO for storing tx status reports between isr and tasklet.
+ */
+ DECLARE_KFIFO_PTR(txstatus_fifo, u32);
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+@@ -1346,6 +1346,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de
+ INIT_DELAYED_WORK(&rt2x00dev->autowakeup_work, rt2x00lib_autowakeup);
+ INIT_WORK(&rt2x00dev->sleep_work, rt2x00lib_sleep);
+
++ retval = rt2x00lib_load_eeprom_file(rt2x00dev);
++ if (retval)
++ goto exit;
++
+ /*
+ * Let the driver probe the device to detect the capabilities.
+ */
+@@ -1484,6 +1488,11 @@ void rt2x00lib_remove_dev(struct rt2x00_
+ * Free the driver data.
+ */
+ kfree(rt2x00dev->drv_data);
++
++ /*
++ * Free EEPROM image.
++ */
++ rt2x00lib_free_eeprom_file(rt2x00dev);
+ }
+ EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev);
+
+--- /dev/null
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
+@@ -0,0 +1,105 @@
++/*
++ Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
++ Copyright (C) 2004 - 2009 Gertjan van Wingerde <gwingerde@gmail.com>
++ <http://rt2x00.serialmonkey.com>
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2 of the License, or
++ (at your option) any later version.
++
++ This program 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 this program; if not, write to the
++ Free Software Foundation, Inc.,
++ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ */
++
++/*
++ Module: rt2x00lib
++ Abstract: rt2x00 eeprom file loading routines.
++ */
++
++#include <linux/kernel.h>
++#include <linux/module.h>
++
++#include "rt2x00.h"
++#include "rt2x00lib.h"
++
++static const char *
++rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
++{
++ struct rt2x00_platform_data *pdata = rt2x00dev->dev->platform_data;
++
++ if (pdata && pdata->eeprom_file_name)
++ return pdata->eeprom_file_name;
++
++ return NULL
++}
++
++static int rt2x00lib_request_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++ const struct firmware *ee;
++ const char *ee_name;
++ int retval;
++
++ ee_name = rt2x00lib_get_eeprom_file_name(rt2x00dev);
++ if (!ee_name && test_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags)) {
++ rt2x00_err(rt2x00dev, "Required EEPROM name is missing.");
++ return -EINVAL;
++ }
++
++ if (!ee_name)
++ return 0;
++
++ rt2x00_info(rt2x00dev, "Loading EEPROM data from '%s'.\n", ee_name);
++
++ retval = request_firmware(&ee, ee_name, rt2x00dev->dev);
++ if (retval) {
++ rt2x00_err(rt2x00dev, "Failed to request EEPROM.\n");
++ return retval;
++ }
++
++ if (!ee || !ee->size || !ee->data) {
++ rt2x00_err(rt2x00dev, "Failed to read EEPROM file.\n");
++ retval = -ENOENT;
++ goto err_exit;
++ }
++
++ if (ee->size != rt2x00dev->ops->eeprom_size) {
++ rt2x00_err(rt2x00dev,
++ "EEPROM file size is invalid, it should be %d bytes\n",
++ rt2x00dev->ops->eeprom_size);
++ retval = -EINVAL;
++ goto err_release_ee;
++ }
++
++ rt2x00dev->eeprom_file = ee;
++ return 0;
++
++err_release_ee:
++ release_firmware(ee);
++err_exit:
++ return retval;
++}
++
++int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++ int retval;
++
++ retval = rt2x00lib_request_eeprom_file(rt2x00dev);
++ if (retval)
++ return retval;
++
++ return 0;
++}
++
++void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++ release_firmware(rt2x00dev->eeprom_file);
++ rt2x00dev->eeprom_file = NULL;
++}
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00lib.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00lib.h
+@@ -297,6 +297,22 @@ static inline void rt2x00lib_free_firmwa
+ #endif /* CPTCFG_RT2X00_LIB_FIRMWARE */
+
+ /*
++ * EEPROM file handlers.
++ */
++#ifdef CPTCFG_RT2X00_LIB_EEPROM
++int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev);
++void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev);
++#else
++static inline int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++ return 0;
++}
++static inline void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev)
++{
++}
++#endif /* CPTCFG_RT2X00_LIB_EEPROM */
++
++/*
+ * Debugfs handlers.
+ */
+ #ifdef CPTCFG_RT2X00_LIB_DEBUGFS
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00soc.c
+@@ -97,6 +97,7 @@ int rt2x00soc_probe(struct platform_devi
+ if (IS_ERR(rt2x00dev->clk))
+ rt2x00dev->clk = NULL;
+
++ set_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags);
+ rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);
+
+ retval = rt2x00soc_alloc_reg(rt2x00dev);
--- /dev/null
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
+@@ -26,6 +26,7 @@
+
+ #include <linux/kernel.h>
+ #include <linux/module.h>
++#include <linux/of.h>
+
+ #include "rt2x00.h"
+ #include "rt2x00lib.h"
+@@ -34,11 +35,21 @@ static const char *
+ rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
+ {
+ struct rt2x00_platform_data *pdata = rt2x00dev->dev->platform_data;
++#ifdef CONFIG_OF
++ struct device_node *np;
++ const char *eep;
++#endif
+
+ if (pdata && pdata->eeprom_file_name)
+ return pdata->eeprom_file_name;
+
+- return NULL
++#ifdef CONFIG_OF
++ np = rt2x00dev->dev->of_node;
++ if (np && of_property_read_string(np, "ralink,eeprom", &eep) == 0)
++ return eep;
++#endif
++
++ return NULL;
+ }
+
+ static int rt2x00lib_request_eeprom_file(struct rt2x00_dev *rt2x00dev)
--- /dev/null
+From 339fe73f340161a624cc08e738d2244814852c3e Mon Sep 17 00:00:00 2001
+From: John Crispin <blogic@openwrt.org>
+Date: Sun, 17 Mar 2013 00:55:04 +0100
+Subject: [PATCH] rt2x00: load eeprom on SoC from a mtd device defines inside
+ OF
+
+Signed-off-by: John Crispin <blogic@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/Kconfig | 1 +
+ drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c | 65 +++++++++++++++++++++++
+ 2 files changed, 66 insertions(+)
+
+--- a/drivers/net/wireless/ralink/rt2x00/Kconfig
++++ b/drivers/net/wireless/ralink/rt2x00/Kconfig
+@@ -219,6 +219,7 @@ config RT2800SOC
+ select RT2X00_LIB_EEPROM
+ select RT2800_LIB
+ select RT2800_LIB_MMIO
++ select MTD if SOC_RT288X || SOC_RT305X
+ ---help---
+ This adds support for Ralink WiSoC devices.
+ Supported chips: RT2880, RT3050, RT3052, RT3350, RT3352.
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
+@@ -26,11 +26,73 @@
+
+ #include <linux/kernel.h>
+ #include <linux/module.h>
++#include <linux/mtd/mtd.h>
++#include <linux/mtd/partitions.h>
+ #include <linux/of.h>
+
+ #include "rt2x00.h"
+ #include "rt2x00lib.h"
+
++static int rt2800lib_read_eeprom_mtd(struct rt2x00_dev *rt2x00dev)
++{
++ int ret = -EINVAL;
++#ifdef CONFIG_OF
++ static struct firmware mtd_fw;
++ struct device_node *np = rt2x00dev->dev->of_node, *mtd_np = NULL;
++ size_t retlen, len = rt2x00dev->ops->eeprom_size;
++ int i, size, offset = 0;
++ struct mtd_info *mtd;
++ const char *part;
++ const __be32 *list;
++ phandle phandle;
++
++ list = of_get_property(np, "ralink,mtd-eeprom", &size);
++ if (!list)
++ return -ENOENT;
++
++ phandle = be32_to_cpup(list++);
++ if (phandle)
++ mtd_np = of_find_node_by_phandle(phandle);
++ if (!mtd_np) {
++ dev_err(rt2x00dev->dev, "failed to load mtd phandle\n");
++ return -EINVAL;
++ }
++
++ part = of_get_property(mtd_np, "label", NULL);
++ if (!part)
++ part = mtd_np->name;
++
++ mtd = get_mtd_device_nm(part);
++ if (IS_ERR(mtd)) {
++ dev_err(rt2x00dev->dev, "failed to get mtd device \"%s\"\n", part);
++ return PTR_ERR(mtd);
++ }
++
++ if (size > sizeof(*list))
++ offset = be32_to_cpup(list);
++
++ ret = mtd_read(mtd, offset, len, &retlen, (u_char *) rt2x00dev->eeprom);
++ put_mtd_device(mtd);
++
++ if ((retlen != rt2x00dev->ops->eeprom_size) || ret) {
++ dev_err(rt2x00dev->dev, "failed to load eeprom from device \"%s\"\n", part);
++ return ret;
++ }
++
++ if (of_find_property(np, "ralink,mtd-eeprom-swap", NULL))
++ for (i = 0; i < len/sizeof(u16); i++)
++ rt2x00dev->eeprom[i] = swab16(rt2x00dev->eeprom[i]);
++
++ rt2x00dev->eeprom_file = &mtd_fw;
++ mtd_fw.size = len;
++ mtd_fw.data = (const u8 *) rt2x00dev->eeprom;
++
++ dev_info(rt2x00dev->dev, "loaded eeprom from mtd device \"%s\"\n", part);
++#endif
++
++ return ret;
++}
++
+ static const char *
+ rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
+ {
+@@ -58,6 +120,9 @@ static int rt2x00lib_request_eeprom_file
+ const char *ee_name;
+ int retval;
+
++ if (!rt2800lib_read_eeprom_mtd(rt2x00dev))
++ return 0;
++
+ ee_name = rt2x00lib_get_eeprom_file_name(rt2x00dev);
+ if (!ee_name && test_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags)) {
+ rt2x00_err(rt2x00dev, "Required EEPROM name is missing.");
--- /dev/null
+--- a/include/linux/rt2x00_platform.h
++++ b/include/linux/rt2x00_platform.h
+@@ -14,6 +14,9 @@
+
+ struct rt2x00_platform_data {
+ char *eeprom_file_name;
++
++ int disable_2ghz;
++ int disable_5ghz;
+ };
+
+ #endif /* _RT2X00_PLATFORM_H */
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+@@ -951,6 +951,22 @@ static int rt2x00lib_probe_hw_modes(stru
+ unsigned int num_rates;
+ unsigned int i;
+
++ if (rt2x00dev->dev->platform_data) {
++ struct rt2x00_platform_data *pdata;
++
++ pdata = rt2x00dev->dev->platform_data;
++ if (pdata->disable_2ghz)
++ spec->supported_bands &= ~SUPPORT_BAND_2GHZ;
++ if (pdata->disable_5ghz)
++ spec->supported_bands &= ~SUPPORT_BAND_5GHZ;
++ }
++
++ if ((spec->supported_bands & SUPPORT_BAND_BOTH) == 0) {
++ rt2x00_err(rt2x00dev, "No supported bands\n");
++ return -EINVAL;
++ }
++
++
+ num_rates = 0;
+ if (spec->supported_rates & SUPPORT_RATE_CCK)
+ num_rates += 4;
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+@@ -408,6 +408,7 @@ struct hw_mode_spec {
+ unsigned int supported_bands;
+ #define SUPPORT_BAND_2GHZ 0x00000001
+ #define SUPPORT_BAND_5GHZ 0x00000002
++#define SUPPORT_BAND_BOTH (SUPPORT_BAND_2GHZ | SUPPORT_BAND_5GHZ)
+
+ unsigned int supported_rates;
+ #define SUPPORT_RATE_CCK 0x00000001
--- /dev/null
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+@@ -929,8 +929,13 @@ static void rt2x00lib_rate(struct ieee80
+
+ void rt2x00lib_set_mac_address(struct rt2x00_dev *rt2x00dev, u8 *eeprom_mac_addr)
+ {
++ struct rt2x00_platform_data *pdata;
+ const char *mac_addr;
+
++ pdata = rt2x00dev->dev->platform_data;
++ if (pdata && pdata->mac_address)
++ ether_addr_copy(eeprom_mac_addr, pdata->mac_address);
++
+ mac_addr = of_get_mac_address(rt2x00dev->dev->of_node);
+ if (mac_addr)
+ ether_addr_copy(eeprom_mac_addr, mac_addr);
+--- a/include/linux/rt2x00_platform.h
++++ b/include/linux/rt2x00_platform.h
+@@ -14,6 +14,7 @@
+
+ struct rt2x00_platform_data {
+ char *eeprom_file_name;
++ const u8 *mac_address;
+
+ int disable_2ghz;
+ int disable_5ghz;
--- /dev/null
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+@@ -955,6 +955,16 @@ static int rt2x00lib_probe_hw_modes(stru
+ struct ieee80211_rate *rates;
+ unsigned int num_rates;
+ unsigned int i;
++#ifdef CONFIG_OF
++ struct device_node *np = rt2x00dev->dev->of_node;
++ unsigned int enabled;
++ if (!of_property_read_u32(np, "ralink,2ghz",
++ &enabled) && !enabled)
++ spec->supported_bands &= ~SUPPORT_BAND_2GHZ;
++ if (!of_property_read_u32(np, "ralink,5ghz",
++ &enabled) && !enabled)
++ spec->supported_bands &= ~SUPPORT_BAND_5GHZ;
++#endif /* CONFIG_OF */
+
+ if (rt2x00dev->dev->platform_data) {
+ struct rt2x00_platform_data *pdata;
--- /dev/null
+From 04dbd87265f6ba4a373b211ba324b437d224fb2d Mon Sep 17 00:00:00 2001
+From: John Crispin <blogic@openwrt.org>
+Date: Sun, 17 Mar 2013 00:03:31 +0100
+Subject: [PATCH 21/38] rt2x00: make wmac loadable via OF on rt288x/305x SoC
+
+This patch ads the match table to allow loading the wmac support from a
+devicetree.
+
+Signed-off-by: John Crispin <blogic@openwrt.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800pci.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c
+@@ -234,10 +234,17 @@ static int rt2800soc_probe(struct platfo
+ return rt2x00soc_probe(pdev, &rt2800soc_ops);
+ }
+
++static const struct of_device_id rt2880_wmac_match[] = {
++ { .compatible = "ralink,rt2880-wmac" },
++ {},
++};
++MODULE_DEVICE_TABLE(of, rt2880_wmac_match);
++
+ static struct platform_driver rt2800soc_driver = {
+ .driver = {
+ .name = "rt2800_wmac",
+ .mod_name = KBUILD_MODNAME,
++ .of_match_table = rt2880_wmac_match,
+ },
+ .probe = rt2800soc_probe,
+ .remove = rt2x00soc_remove,
--- /dev/null
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -36,6 +36,7 @@
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/slab.h>
++#include <linux/of.h>
+
+ #include "rt2x00.h"
+ #include "rt2800lib.h"
+@@ -7861,6 +7862,17 @@ static int rt2800_init_eeprom(struct rt2
+ rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
+ rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY);
+
++ {
++ struct device_node *np = rt2x00dev->dev->of_node;
++ unsigned int led_polarity;
++
++ /* Allow overriding polarity from OF */
++ if (!of_property_read_u32(np, "ralink,led-polarity",
++ &led_polarity))
++ rt2x00_set_field16(&eeprom, EEPROM_FREQ_LED_POLARITY,
++ led_polarity);
++ }
++
+ rt2x00dev->led_mcu_reg = eeprom;
+ #endif /* CPTCFG_RT2X00_LIB_LEDS */
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00leds.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00leds.c
+@@ -109,6 +109,9 @@ static int rt2x00leds_register_led(struc
+ led->led_dev.name = name;
+ led->led_dev.brightness = LED_OFF;
+
++ if (rt2x00_is_soc(rt2x00dev))
++ led->led_dev.brightness_set(&led->led_dev, LED_OFF);
++
+ retval = led_classdev_register(device, &led->led_dev);
+ if (retval) {
+ rt2x00_err(rt2x00dev, "Failed to register led handler\n");
--- /dev/null
+--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+@@ -1286,7 +1286,7 @@ static inline void rt2x00lib_set_if_comb
+ */
+ if_limit = &rt2x00dev->if_limits_ap;
+ if_limit->max = rt2x00dev->ops->max_ap_intf;
+- if_limit->types = BIT(NL80211_IFTYPE_AP);
++ if_limit->types = BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_STATION);
+ #ifdef CPTCFG_MAC80211_MESH
+ if_limit->types |= BIT(NL80211_IFTYPE_MESH_POINT);
+ #endif
--- /dev/null
+--- a/drivers/net/wireless/ralink/rt2x00/Kconfig
++++ b/drivers/net/wireless/ralink/rt2x00/Kconfig
+@@ -211,7 +211,7 @@ endif
+ config RT2800SOC
+ tristate "Ralink WiSoC support"
+ depends on m
+- depends on SOC_RT288X || SOC_RT305X || SOC_RT3883
++ depends on SOC_RT288X || SOC_RT305X || SOC_RT3883 || SOC_MT7620
+ select RT2X00_LIB_SOC
+ select RT2X00_LIB_MMIO
+ select RT2X00_LIB_CRYPTO
+@@ -248,7 +248,7 @@ config RT2X00_LIB_PCI
+
+ config RT2X00_LIB_SOC
+ tristate "RT2x00 SoC support"
+- depends on SOC_RT288X || SOC_RT305X || SOC_RT3883
++ depends on SOC_RT288X || SOC_RT305X || SOC_RT3883 || SOC_MT7620
+ depends on m
+ select RT2X00_LIB
+
--- /dev/null
+From: Roman Yeryomin <roman@advem.lv>
+Date: Tue, 1 Jul 2014 10:26:18 +0000
+Subject: [PATCH] mac80211: rt2x00: add support for mt7620
+
+Support for MT7620 was added to OpenWrt in r41441 and heavily reworked
+since in order to match the Kernel's code quality standards.
+
+Signed-off-by: Roman Yeryomin <roman@advem.lv>
+Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+---
+
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
+@@ -81,6 +81,7 @@
+ #define RF5372 0x5372
+ #define RF5390 0x5390
+ #define RF5392 0x5392
++#define RF7620 0x7620
+
+ /*
+ * Chipset revisions.
+@@ -641,6 +642,14 @@
+ #define RF_CSR_CFG_BUSY FIELD32(0x00020000)
+
+ /*
++ * mt7620 RF registers (reversed order)
++ */
++#define RF_CSR_CFG_DATA_MT7620 FIELD32(0x0000ff00)
++#define RF_CSR_CFG_REGNUM_MT7620 FIELD32(0x03ff0000)
++#define RF_CSR_CFG_WRITE_MT7620 FIELD32(0x00000010)
++#define RF_CSR_CFG_BUSY_MT7620 FIELD32(0x00000001)
++
++/*
+ * EFUSE_CSR: RT30x0 EEPROM
+ */
+ #define EFUSE_CTRL 0x0580
+@@ -1024,6 +1033,11 @@
+ #define AUTOWAKEUP_CFG_AUTOWAKE FIELD32(0x00008000)
+
+ /*
++ * mt7620
++ */
++#define MIMO_PS_CFG 0x1210
++
++/*
+ * EDCA_AC0_CFG:
+ */
+ #define EDCA_AC0_CFG 0x1300
+@@ -1203,6 +1217,8 @@
+ #define TX_PIN_CFG_RFTR_POL FIELD32(0x00020000)
+ #define TX_PIN_CFG_TRSW_EN FIELD32(0x00040000)
+ #define TX_PIN_CFG_TRSW_POL FIELD32(0x00080000)
++#define TX_PIN_CFG_RFRX_EN FIELD32(0x00100000) /* mt7620 */
++#define TX_PIN_CFG_RFRX_POL FIELD32(0x00200000) /* mt7620 */
+ #define TX_PIN_CFG_PA_PE_A2_EN FIELD32(0x01000000)
+ #define TX_PIN_CFG_PA_PE_G2_EN FIELD32(0x02000000)
+ #define TX_PIN_CFG_PA_PE_A2_POL FIELD32(0x04000000)
+@@ -1549,6 +1565,17 @@
+ #define TX_PWR_CFG_4_EXT_STBC4_CH2 FIELD32(0x0000000f)
+ #define TX_PWR_CFG_4_EXT_STBC6_CH2 FIELD32(0x00000f00)
+
++/* mt7620 */
++#define TX0_RF_GAIN_CORRECT 0x13a0
++#define TX1_RF_GAIN_CORRECT 0x13a4
++#define TX0_RF_GAIN_ATTEN 0x13a8
++#define TX1_RF_GAIN_ATTEN 0x13ac
++#define TX_ALG_CFG_0 0x13b0
++#define TX_ALG_CFG_1 0x13b4
++#define TX0_BB_GAIN_ATTEN 0x13c0
++#define TX1_BB_GAIN_ATTEN 0x13c4
++#define TX_ALC_VGA3 0x13c8
++
+ /* TX_PWR_CFG_7 */
+ #define TX_PWR_CFG_7 0x13d4
+ #define TX_PWR_CFG_7_OFDM54_CH0 FIELD32(0x0000000f)
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -60,6 +60,9 @@
+ rt2800_regbusy_read((__dev), BBP_CSR_CFG, BBP_CSR_CFG_BUSY, (__reg))
+ #define WAIT_FOR_RFCSR(__dev, __reg) \
+ rt2800_regbusy_read((__dev), RF_CSR_CFG, RF_CSR_CFG_BUSY, (__reg))
++#define WAIT_FOR_RFCSR_MT7620(__dev, __reg) \
++ rt2800_regbusy_read((__dev), RF_CSR_CFG, RF_CSR_CFG_BUSY_MT7620, \
++ (__reg))
+ #define WAIT_FOR_RF(__dev, __reg) \
+ rt2800_regbusy_read((__dev), RF_CSR_CFG0, RF_CSR_CFG0_BUSY, (__reg))
+ #define WAIT_FOR_MCU(__dev, __reg) \
+@@ -151,19 +154,56 @@ static void rt2800_rfcsr_write(struct rt
+ * Wait until the RFCSR becomes available, afterwards we
+ * can safely write the new data into the register.
+ */
+- if (WAIT_FOR_RFCSR(rt2x00dev, ®)) {
+- reg = 0;
+- rt2x00_set_field32(®, RF_CSR_CFG_DATA, value);
+- rt2x00_set_field32(®, RF_CSR_CFG_REGNUM, word);
+- rt2x00_set_field32(®, RF_CSR_CFG_WRITE, 1);
+- rt2x00_set_field32(®, RF_CSR_CFG_BUSY, 1);
++ switch (rt2x00dev->chip.rf) {
++ case RF7620:
++ if (WAIT_FOR_RFCSR_MT7620(rt2x00dev, ®)) {
++ reg = 0;
++ rt2x00_set_field32(®, RF_CSR_CFG_DATA_MT7620, value);
++ rt2x00_set_field32(®, RF_CSR_CFG_REGNUM_MT7620,
++ word);
++ rt2x00_set_field32(®, RF_CSR_CFG_WRITE_MT7620, 1);
++ rt2x00_set_field32(®, RF_CSR_CFG_BUSY_MT7620, 1);
++
++ rt2800_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
++ }
++ break;
++
++ default:
++ if (WAIT_FOR_RFCSR(rt2x00dev, ®)) {
++ reg = 0;
++ rt2x00_set_field32(®, RF_CSR_CFG_DATA, value);
++ rt2x00_set_field32(®, RF_CSR_CFG_REGNUM, word);
++ rt2x00_set_field32(®, RF_CSR_CFG_WRITE, 1);
++ rt2x00_set_field32(®, RF_CSR_CFG_BUSY, 1);
+
+- rt2800_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
++ rt2800_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
++ }
++ break;
+ }
+
+ mutex_unlock(&rt2x00dev->csr_mutex);
+ }
+
++static void rt2800_rfcsr_write_bank(struct rt2x00_dev *rt2x00dev, const u8 bank,
++ const unsigned int reg, const u8 value)
++{
++ rt2800_rfcsr_write(rt2x00dev, (reg | (bank << 6)), value);
++}
++
++static void rt2800_rfcsr_write_chanreg(struct rt2x00_dev *rt2x00dev,
++ const unsigned int reg, const u8 value)
++{
++ rt2800_rfcsr_write_bank(rt2x00dev, 4, reg, value);
++ rt2800_rfcsr_write_bank(rt2x00dev, 6, reg, value);
++}
++
++static void rt2800_rfcsr_write_dccal(struct rt2x00_dev *rt2x00dev,
++ const unsigned int reg, const u8 value)
++{
++ rt2800_rfcsr_write_bank(rt2x00dev, 5, reg, value);
++ rt2800_rfcsr_write_bank(rt2x00dev, 7, reg, value);
++}
++
+ static void rt2800_rfcsr_read(struct rt2x00_dev *rt2x00dev,
+ const unsigned int word, u8 *value)
+ {
+@@ -179,22 +219,48 @@ static void rt2800_rfcsr_read(struct rt2
+ * doesn't become available in time, reg will be 0xffffffff
+ * which means we return 0xff to the caller.
+ */
+- if (WAIT_FOR_RFCSR(rt2x00dev, ®)) {
+- reg = 0;
+- rt2x00_set_field32(®, RF_CSR_CFG_REGNUM, word);
+- rt2x00_set_field32(®, RF_CSR_CFG_WRITE, 0);
+- rt2x00_set_field32(®, RF_CSR_CFG_BUSY, 1);
++ switch (rt2x00dev->chip.rf) {
++ case RF7620:
++ if (WAIT_FOR_RFCSR_MT7620(rt2x00dev, ®)) {
++ reg = 0;
++ rt2x00_set_field32(®, RF_CSR_CFG_REGNUM_MT7620,
++ word);
++ rt2x00_set_field32(®, RF_CSR_CFG_WRITE_MT7620, 0);
++ rt2x00_set_field32(®, RF_CSR_CFG_BUSY_MT7620, 1);
+
+- rt2800_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
++ rt2800_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
+
+- WAIT_FOR_RFCSR(rt2x00dev, ®);
+- }
++ WAIT_FOR_RFCSR_MT7620(rt2x00dev, ®);
++ }
++
++ *value = rt2x00_get_field32(reg, RF_CSR_CFG_DATA_MT7620);
++ break;
++
++ default:
++ if (WAIT_FOR_RFCSR(rt2x00dev, ®)) {
++ reg = 0;
++ rt2x00_set_field32(®, RF_CSR_CFG_REGNUM, word);
++ rt2x00_set_field32(®, RF_CSR_CFG_WRITE, 0);
++ rt2x00_set_field32(®, RF_CSR_CFG_BUSY, 1);
+
+- *value = rt2x00_get_field32(reg, RF_CSR_CFG_DATA);
++ rt2800_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
++
++ WAIT_FOR_RFCSR(rt2x00dev, ®);
++ }
++
++ *value = rt2x00_get_field32(reg, RF_CSR_CFG_DATA);
++ break;
++ }
+
+ mutex_unlock(&rt2x00dev->csr_mutex);
+ }
+
++static void rt2800_rfcsr_read_bank(struct rt2x00_dev *rt2x00dev, const u8 bank,
++ const unsigned int reg, u8 *value)
++{
++ rt2800_rfcsr_read(rt2x00dev, (reg | (bank << 6)), value);
++}
++
+ static void rt2800_rf_write(struct rt2x00_dev *rt2x00dev,
+ const unsigned int word, const u32 value)
+ {
+@@ -526,6 +592,16 @@ void rt2800_get_txwi_rxwi_size(struct rt
+ *rxwi_size = RXWI_DESC_SIZE_5WORDS;
+ break;
+
++ case RT5390:
++ if (rt2x00dev->chip.rf == RF7620) {
++ *txwi_size = TXWI_DESC_SIZE_5WORDS;
++ *rxwi_size = RXWI_DESC_SIZE_6WORDS;
++ } else {
++ *txwi_size = TXWI_DESC_SIZE_4WORDS;
++ *rxwi_size = RXWI_DESC_SIZE_4WORDS;
++ }
++ break;
++
+ case RT5592:
+ *txwi_size = TXWI_DESC_SIZE_5WORDS;
+ *rxwi_size = RXWI_DESC_SIZE_6WORDS;
+@@ -3258,6 +3334,296 @@ static void rt2800_config_channel_rf55xx
+ rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x19 : 0x7F);
+ }
+
++static void rt2800_config_channel_rf7620(struct rt2x00_dev *rt2x00dev,
++ struct ieee80211_conf *conf,
++ struct rf_channel *rf,
++ struct channel_info *info)
++{
++ struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
++ u32 mac_sys_ctrl, mac_status;
++ u16 eeprom, target_power;
++ u32 tx_pin = 0x00150F0F;
++ u8 txrx_agc_fc;
++ u8 rfcsr;
++ u32 reg;
++ u8 bbp;
++ int i;
++
++ /* Frequeny plan setting */
++ /* Rdiv setting (stored in rf->rf1)
++ * R13[1:0]
++ */
++ rt2800_rfcsr_read(rt2x00dev, 13, &rfcsr);
++ rfcsr = rfcsr & (~0x03);
++ if (rt2800_clk_is_20mhz(rt2x00dev))
++ rfcsr |= (rf->rf1 & 0x03);
++
++ rt2800_rfcsr_write(rt2x00dev, 13, rfcsr);
++
++ /* N setting (stored in rf->rf2)
++ * R21[0], R20[7:0]
++ */
++ rt2800_rfcsr_read(rt2x00dev, 20, &rfcsr);
++ rfcsr = (rf->rf2 & 0x00ff);
++ rt2800_rfcsr_write(rt2x00dev, 20, rfcsr);
++
++ rt2800_rfcsr_read(rt2x00dev, 21, &rfcsr);
++ rfcsr = rfcsr & (~0x01);
++ rfcsr |= ((rf->rf2 & 0x0100) >> 8);
++ rt2800_rfcsr_write(rt2x00dev, 21, rfcsr);
++
++ /* K setting (stored in rf->rf3[0:7])
++ * R16[3:0] (RF PLL freq selection)
++ */
++ rt2800_rfcsr_read(rt2x00dev, 16, &rfcsr);
++ rfcsr = rfcsr & (~0x0f);
++ rfcsr |= (rf->rf3 & 0x0f);
++ rt2800_rfcsr_write(rt2x00dev, 16, rfcsr);
++
++ /* D setting (stored in rf->rf3[8:15])
++ * R22[2:0] (D=15, R22[2:0]=<111>)
++ */
++ rt2800_rfcsr_read(rt2x00dev, 22, &rfcsr);
++ rfcsr = rfcsr & (~0x07);
++ rfcsr |= ((rf->rf3 >> 8) & 0x07);
++ rt2800_rfcsr_write(rt2x00dev, 22, rfcsr);
++
++ /* Ksd setting (stored in rf->rf4)
++ * Ksd: R19<1:0>,R18<7:0>,R17<7:0>
++ */
++ rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
++ rfcsr = (rf->rf4 & 0x000000ff);
++ rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
++
++ rt2800_rfcsr_read(rt2x00dev, 18, &rfcsr);
++ rfcsr = ((rf->rf4 & 0x0000ff00) >> 8);
++ rt2800_rfcsr_write(rt2x00dev, 18, rfcsr);
++
++ rt2800_rfcsr_read(rt2x00dev, 19, &rfcsr);
++ rfcsr = rfcsr & (~0x03);
++ rfcsr |= ((rf->rf4 & 0x00030000) >> 16);
++ rt2800_rfcsr_write(rt2x00dev, 19, rfcsr);
++
++ /* Default: XO=20MHz , SDM mode */
++ rt2800_rfcsr_read(rt2x00dev, 16, &rfcsr);
++ rfcsr = rfcsr & (~0xE0);
++ rfcsr |= 0x80;
++ rt2800_rfcsr_write(rt2x00dev, 16, rfcsr);
++
++ rt2800_rfcsr_read(rt2x00dev, 21, &rfcsr);
++ rfcsr |= 0x80;
++ rt2800_rfcsr_write(rt2x00dev, 21, rfcsr);
++
++ rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr);
++ if (rt2x00dev->default_ant.tx_chain_num == 1)
++ rfcsr &= (~0x2);
++ else
++ rfcsr |= 0x2;
++ rt2800_rfcsr_write(rt2x00dev, 1, rfcsr);
++
++ rt2800_rfcsr_read(rt2x00dev, 2, &rfcsr);
++ if (rt2x00dev->default_ant.tx_chain_num == 1)
++ rfcsr &= (~0x20);
++ else
++ rfcsr |= 0x20;
++ if (rt2x00dev->default_ant.rx_chain_num == 1)
++ rfcsr &= (~0x02);
++ else
++ rfcsr |= 0x02;
++ rt2800_rfcsr_write(rt2x00dev, 2, rfcsr);
++
++ rt2800_rfcsr_read(rt2x00dev, 42, &rfcsr);
++ if (rt2x00dev->default_ant.tx_chain_num == 1)
++ rfcsr &= (~0x40);
++ else
++ rfcsr |= 0x40;
++ rt2800_rfcsr_write(rt2x00dev, 42, rfcsr);
++
++ /* RF for DC Cal BW */
++ if (conf_is_ht40(conf)) {
++ rt2800_rfcsr_write_dccal(rt2x00dev, 6, 0x10);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 7, 0x10);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 8, 0x04);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 58, 0x10);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 59, 0x10);
++ } else {
++ rt2800_rfcsr_write_dccal(rt2x00dev, 6, 0x20);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 7, 0x20);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 8, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 58, 0x20);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 59, 0x20);
++ }
++
++ if (conf_is_ht40(conf)) {
++ rt2800_rfcsr_write_dccal(rt2x00dev, 58, 0x08);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 59, 0x08);
++ } else {
++ rt2800_rfcsr_write_dccal(rt2x00dev, 58, 0x28);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 59, 0x28);
++ }
++
++ rt2800_rfcsr_read(rt2x00dev, 28, &rfcsr);
++ if (conf_is_ht40(conf) && (rf->channel == 11))
++ rfcsr |= 0x4;
++ else
++ rfcsr &= (~0x4);
++ rt2800_rfcsr_write(rt2x00dev, 28, rfcsr);
++
++ /*if (bScan == FALSE)*/
++ if (conf_is_ht40(conf)) {
++ txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw40,
++ RFCSR24_TX_AGC_FC);
++ } else {
++ txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw20,
++ RFCSR24_TX_AGC_FC);
++ }
++ rt2800_rfcsr_read_bank(rt2x00dev, 5, 6, &rfcsr);
++ rfcsr &= (~0x3F);
++ rfcsr |= txrx_agc_fc;
++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 6, rfcsr);
++ rt2800_rfcsr_read_bank(rt2x00dev, 5, 7, &rfcsr);
++ rfcsr &= (~0x3F);
++ rfcsr |= txrx_agc_fc;
++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 7, rfcsr);
++ rt2800_rfcsr_read_bank(rt2x00dev, 7, 6, &rfcsr);
++ rfcsr &= (~0x3F);
++ rfcsr |= txrx_agc_fc;
++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 6, rfcsr);
++ rt2800_rfcsr_read_bank(rt2x00dev, 7, 7, &rfcsr);
++ rfcsr &= (~0x3F);
++ rfcsr |= txrx_agc_fc;
++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 7, rfcsr);
++
++ rt2800_rfcsr_read_bank(rt2x00dev, 5, 58, &rfcsr);
++ rfcsr &= (~0x3F);
++ rfcsr |= txrx_agc_fc;
++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 58, rfcsr);
++ rt2800_rfcsr_read_bank(rt2x00dev, 5, 59, &rfcsr);
++ rfcsr &= (~0x3F);
++ rfcsr |= txrx_agc_fc;
++ rt2800_rfcsr_write_bank(rt2x00dev, 5, 59, rfcsr);
++ rt2800_rfcsr_read_bank(rt2x00dev, 7, 58, &rfcsr);
++ rfcsr &= (~0x3F);
++ rfcsr |= txrx_agc_fc;
++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 58, rfcsr);
++ rt2800_rfcsr_read_bank(rt2x00dev, 7, 59, &rfcsr);
++ rfcsr &= (~0x3F);
++ rfcsr |= txrx_agc_fc;
++ rt2800_rfcsr_write_bank(rt2x00dev, 7, 59, rfcsr);
++
++ rt2800_register_read(rt2x00dev, TX_ALG_CFG_0, ®);
++ reg = reg & (~0x3F3F);
++ reg |= info->default_power1;
++ reg |= (info->default_power2 << 8);
++ reg |= (0x2F << 16);
++ reg |= (0x2F << 24);
++
++ rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
++ if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_INTERNAL_TX_ALC)) {
++ /* init base power by e2p target power */
++ rt2800_eeprom_read(rt2x00dev, 0xD0, &target_power);
++ target_power &= 0x3F;
++ reg = reg & (~0x3F3F);
++ reg |= target_power;
++ reg |= (target_power << 8);
++ }
++ rt2800_register_write(rt2x00dev, TX_ALG_CFG_0, reg);
++
++ rt2800_register_read(rt2x00dev, TX_ALG_CFG_1, ®);
++ reg = reg & (~0x3F);
++ rt2800_register_write(rt2x00dev, TX_ALG_CFG_1, reg);
++
++ /*if (bScan == FALSE)*/
++ /* Save MAC SYS CTRL registers */
++ rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &mac_sys_ctrl);
++ /* Disable Tx/Rx */
++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0);
++ /* Check MAC Tx/Rx idle */
++ for (i = 0; i < 10000; i++) {
++ rt2800_register_read(rt2x00dev, MAC_STATUS_CFG, &mac_status);
++ if (mac_status & 0x3)
++ usleep_range(50, 200);
++ else
++ break;
++ }
++
++ if (i == 10000)
++ rt2x00_warn(rt2x00dev, "Wait MAC Status to MAX !!!\n");
++
++ if (rf->channel > 10) {
++ rt2800_bbp_read(rt2x00dev, 30, &bbp);
++ bbp = 0x40;
++ rt2800_bbp_write(rt2x00dev, 30, bbp);
++ rt2800_rfcsr_write(rt2x00dev, 39, 0);
++ if (rt2x00_has_cap_external_lna_bg(rt2x00dev))
++ rt2800_rfcsr_write(rt2x00dev, 42, 0xfb);
++ else
++ rt2800_rfcsr_write(rt2x00dev, 42, 0x7b);
++ } else {
++ rt2800_bbp_read(rt2x00dev, 30, &bbp);
++ bbp = 0x1f;
++ rt2800_bbp_write(rt2x00dev, 30, bbp);
++ rt2800_rfcsr_write(rt2x00dev, 39, 0x80);
++ if (rt2x00_has_cap_external_lna_bg(rt2x00dev))
++ rt2800_rfcsr_write(rt2x00dev, 42, 0xdb);
++ else
++ rt2800_rfcsr_write(rt2x00dev, 42, 0x5b);
++ }
++
++ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, mac_sys_ctrl);
++
++ rt2800_rfcsr_write(rt2x00dev, 5, 0x40);
++ rt2800_rfcsr_write(rt2x00dev, 4, 0x0C);
++
++ /* vcocal_en (initiate VCO calibration (reset after completion)) */
++ rt2800_rfcsr_read(rt2x00dev, 4, &rfcsr);
++ rfcsr = ((rfcsr & ~0x80) | 0x80);
++ rt2800_rfcsr_write(rt2x00dev, 4, rfcsr);
++ usleep_range(2000, 3000);
++
++ rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
++
++ if (rt2x00dev->default_ant.tx_chain_num == 1) {
++ rt2800_bbp_write(rt2x00dev, 91, 0x07);
++ rt2800_bbp_write(rt2x00dev, 95, 0x1A);
++ rt2800_bbp_write(rt2x00dev, 195, 128);
++ rt2800_bbp_write(rt2x00dev, 196, 0xA0);
++ rt2800_bbp_write(rt2x00dev, 195, 170);
++ rt2800_bbp_write(rt2x00dev, 196, 0x12);
++ rt2800_bbp_write(rt2x00dev, 195, 171);
++ rt2800_bbp_write(rt2x00dev, 196, 0x10);
++ } else {
++ rt2800_bbp_write(rt2x00dev, 91, 0x06);
++ rt2800_bbp_write(rt2x00dev, 95, 0x9A);
++ rt2800_bbp_write(rt2x00dev, 195, 128);
++ rt2800_bbp_write(rt2x00dev, 196, 0xE0);
++ rt2800_bbp_write(rt2x00dev, 195, 170);
++ rt2800_bbp_write(rt2x00dev, 196, 0x30);
++ rt2800_bbp_write(rt2x00dev, 195, 171);
++ rt2800_bbp_write(rt2x00dev, 196, 0x30);
++ }
++
++ if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
++ rt2800_bbp_write(rt2x00dev, 75, 0x60);
++ rt2800_bbp_write(rt2x00dev, 76, 0x44);
++ rt2800_bbp_write(rt2x00dev, 79, 0x1C);
++ rt2800_bbp_write(rt2x00dev, 80, 0x0C);
++ rt2800_bbp_write(rt2x00dev, 82, 0xB6);
++
++ if (!conf_is_ht40(conf)) {
++ rt2800_bbp_write(rt2x00dev, 195, 141);
++ rt2800_bbp_write(rt2x00dev, 196, 0x1A);
++ }
++ }
++
++ /* On 11A, We should delay and wait RF/BBP to be stable
++ * and the appropriate time should be 1000 micro seconds
++ * 2005/06/05 - On 11G, we also need this delay time.
++ * Otherwise it's difficult to pass the WHQL.
++ */
++ usleep_range(1000, 1500);
++}
++
+ static void rt2800_bbp_write_with_rx_chain(struct rt2x00_dev *rt2x00dev,
+ const unsigned int word,
+ const u8 value)
+@@ -3414,7 +3780,7 @@ static void rt2800_config_channel(struct
+ struct channel_info *info)
+ {
+ u32 reg;
+- unsigned int tx_pin;
++ u32 tx_pin;
+ u8 bbp, rfcsr;
+
+ info->default_power1 = rt2800_txpower_to_dev(rt2x00dev, rf->channel,
+@@ -3468,6 +3834,9 @@ static void rt2800_config_channel(struct
+ case RF5592:
+ rt2800_config_channel_rf55xx(rt2x00dev, conf, rf, info);
+ break;
++ case RF7620:
++ rt2800_config_channel_rf7620(rt2x00dev, conf, rf, info);
++ break;
+ default:
+ rt2800_config_channel_rf2xxx(rt2x00dev, conf, rf, info);
+ }
+@@ -3574,7 +3943,7 @@ static void rt2800_config_channel(struct
+ else if (rt2x00_rt(rt2x00dev, RT3593) ||
+ rt2x00_rt(rt2x00dev, RT3883))
+ rt2800_bbp_write(rt2x00dev, 82, 0x82);
+- else
++ else if (rt2x00dev->chip.rf != RF7620)
+ rt2800_bbp_write(rt2x00dev, 82, 0xf2);
+
+ if (rt2x00_rt(rt2x00dev, RT3593) ||
+@@ -3596,7 +3965,7 @@ static void rt2800_config_channel(struct
+ if (rt2x00_rt(rt2x00dev, RT3572))
+ rt2800_rfcsr_write(rt2x00dev, 8, 0);
+
+- tx_pin = 0;
++ rt2800_register_read(rt2x00dev, TX_PIN_CFG, &tx_pin);
+
+ switch (rt2x00dev->default_ant.tx_chain_num) {
+ case 3:
+@@ -3645,6 +4014,7 @@ static void rt2800_config_channel(struct
+
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
++ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFRX_EN, 1); /* mt7620 */
+
+ rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
+
+@@ -3720,7 +4090,8 @@ static void rt2800_config_channel(struct
+ usleep_range(1000, 1500);
+ }
+
+- if (rt2x00_rt(rt2x00dev, RT5592)) {
++ if (rt2x00_rt(rt2x00dev, RT5592) ||
++ (rt2x00_rt(rt2x00dev, RT5390) && rt2x00_rf(rt2x00dev, RF7620))) {
+ rt2800_bbp_write(rt2x00dev, 195, 141);
+ rt2800_bbp_write(rt2x00dev, 196, conf_is_ht40(conf) ? 0x10 : 0x1a);
+
+@@ -4662,6 +5033,15 @@ void rt2800_vco_calibration(struct rt2x0
+ rt2x00_set_field8(&rfcsr, RFCSR3_VCOCAL_EN, 1);
+ rt2800_rfcsr_write(rt2x00dev, 3, rfcsr);
+ break;
++ case RF7620:
++ rt2800_rfcsr_read(rt2x00dev, 4, &rfcsr);
++ /* vcocal_en (initiate VCO calibration (reset after completion))
++ * It should be at the end of RF configuration.
++ */
++ rfcsr = ((rfcsr & ~0x80) | 0x80);
++ rt2800_rfcsr_write(rt2x00dev, 4, rfcsr);
++ usleep_range(2000, 3000);
++ break;
+ default:
+ WARN_ONCE(1, "Not supported RF chipet %x for VCO recalibration",
+ rt2x00dev->chip.rf);
+@@ -5037,6 +5417,24 @@ static int rt2800_init_registers(struct
+ rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00040000);
+ rt2800_register_write(rt2x00dev, TX_TXBF_CFG_0, 0x8000fc21);
+ rt2800_register_write(rt2x00dev, TX_TXBF_CFG_3, 0x00009c40);
++ } else if (rt2x00_rf(rt2x00dev, RF7620)) {
++ rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000401);
++ rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x000C0000);
++ rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000);
++ rt2800_register_write(rt2x00dev, MIMO_PS_CFG, 0x00000002);
++ rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0x00150F0F);
++ rt2800_register_write(rt2x00dev, TX_ALC_VGA3, 0x06060606);
++ rt2800_register_write(rt2x00dev, TX0_BB_GAIN_ATTEN, 0x0);
++ rt2800_register_write(rt2x00dev, TX1_BB_GAIN_ATTEN, 0x0);
++ rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6C6C666C);
++ rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, 0x6C6C666C);
++ rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT,
++ 0x3630363A);
++ rt2800_register_write(rt2x00dev, TX1_RF_GAIN_CORRECT,
++ 0x3630363A);
++ rt2800_register_read(rt2x00dev, TX_ALG_CFG_1, ®);
++ reg = reg & (~0x80000000);
++ rt2800_register_write(rt2x00dev, TX_ALG_CFG_1, reg);
+ } else if (rt2x00_rt(rt2x00dev, RT5390) ||
+ rt2x00_rt(rt2x00dev, RT5392)) {
+ rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000404);
+@@ -6075,6 +6473,225 @@ static void rt2800_init_bbp_5592(struct
+ rt2800_bbp_write(rt2x00dev, 103, 0xc0);
+ }
+
++static void rt2800_bbp_glrt_write(struct rt2x00_dev *rt2x00dev,
++ const u8 reg, const u8 value)
++{
++ rt2800_bbp_write(rt2x00dev, 195, reg);
++ rt2800_bbp_write(rt2x00dev, 196, value);
++}
++
++static void rt2800_bbp_dcoc_write(struct rt2x00_dev *rt2x00dev,
++ const u8 reg, const u8 value)
++{
++ rt2800_bbp_write(rt2x00dev, 158, reg);
++ rt2800_bbp_write(rt2x00dev, 159, value);
++}
++
++static void rt2800_init_bbp_7620(struct rt2x00_dev *rt2x00dev)
++{
++ u8 bbp;
++
++ /* Apply Maximum Likelihood Detection (MLD) for 2 stream case */
++ rt2800_bbp_read(rt2x00dev, 105, &bbp);
++ rt2x00_set_field8(&bbp, BBP105_MLD,
++ rt2x00dev->default_ant.rx_chain_num == 2);
++ rt2800_bbp_write(rt2x00dev, 105, bbp);
++
++ /* Avoid data loss and CRC errors */
++ /* MAC interface control (MAC_IF_80M, 1: 80 MHz) */
++ rt2800_bbp4_mac_if_ctrl(rt2x00dev);
++
++ /* Fix I/Q swap issue */
++ rt2800_bbp_read(rt2x00dev, 1, &bbp);
++ bbp |= 0x04;
++ rt2800_bbp_write(rt2x00dev, 1, bbp);
++
++ /* BBP for G band */
++ rt2800_bbp_write(rt2x00dev, 3, 0x08);
++ rt2800_bbp_write(rt2x00dev, 4, 0x00); /* rt2800_bbp4_mac_if_ctrl? */
++ rt2800_bbp_write(rt2x00dev, 6, 0x08);
++ rt2800_bbp_write(rt2x00dev, 14, 0x09);
++ rt2800_bbp_write(rt2x00dev, 15, 0xFF);
++ rt2800_bbp_write(rt2x00dev, 16, 0x01);
++ rt2800_bbp_write(rt2x00dev, 20, 0x06);
++ rt2800_bbp_write(rt2x00dev, 21, 0x00);
++ rt2800_bbp_write(rt2x00dev, 22, 0x00);
++ rt2800_bbp_write(rt2x00dev, 27, 0x00);
++ rt2800_bbp_write(rt2x00dev, 28, 0x00);
++ rt2800_bbp_write(rt2x00dev, 30, 0x00);
++ rt2800_bbp_write(rt2x00dev, 31, 0x48);
++ rt2800_bbp_write(rt2x00dev, 47, 0x40);
++ rt2800_bbp_write(rt2x00dev, 62, 0x00);
++ rt2800_bbp_write(rt2x00dev, 63, 0x00);
++ rt2800_bbp_write(rt2x00dev, 64, 0x00);
++ rt2800_bbp_write(rt2x00dev, 65, 0x2C);
++ rt2800_bbp_write(rt2x00dev, 66, 0x1C);
++ rt2800_bbp_write(rt2x00dev, 67, 0x20);
++ rt2800_bbp_write(rt2x00dev, 68, 0xDD);
++ rt2800_bbp_write(rt2x00dev, 69, 0x10);
++ rt2800_bbp_write(rt2x00dev, 70, 0x05);
++ rt2800_bbp_write(rt2x00dev, 73, 0x18);
++ rt2800_bbp_write(rt2x00dev, 74, 0x0F);
++ rt2800_bbp_write(rt2x00dev, 75, 0x60);
++ rt2800_bbp_write(rt2x00dev, 76, 0x44);
++ rt2800_bbp_write(rt2x00dev, 77, 0x59);
++ rt2800_bbp_write(rt2x00dev, 78, 0x1E);
++ rt2800_bbp_write(rt2x00dev, 79, 0x1C);
++ rt2800_bbp_write(rt2x00dev, 80, 0x0C);
++ rt2800_bbp_write(rt2x00dev, 81, 0x3A);
++ rt2800_bbp_write(rt2x00dev, 82, 0xB6);
++ rt2800_bbp_write(rt2x00dev, 83, 0x9A);
++ rt2800_bbp_write(rt2x00dev, 84, 0x9A);
++ rt2800_bbp_write(rt2x00dev, 86, 0x38);
++ rt2800_bbp_write(rt2x00dev, 88, 0x90);
++ rt2800_bbp_write(rt2x00dev, 91, 0x04);
++ rt2800_bbp_write(rt2x00dev, 92, 0x02);
++ rt2800_bbp_write(rt2x00dev, 95, 0x9A);
++ rt2800_bbp_write(rt2x00dev, 96, 0x00);
++ rt2800_bbp_write(rt2x00dev, 103, 0xC0);
++ rt2800_bbp_write(rt2x00dev, 104, 0x92);
++ /* FIXME BBP105 owerwrite */
++ rt2800_bbp_write(rt2x00dev, 105, 0x3C);
++ rt2800_bbp_write(rt2x00dev, 106, 0x12);
++ rt2800_bbp_write(rt2x00dev, 109, 0x00);
++ rt2800_bbp_write(rt2x00dev, 134, 0x10);
++ rt2800_bbp_write(rt2x00dev, 135, 0xA6);
++ rt2800_bbp_write(rt2x00dev, 137, 0x04);
++ rt2800_bbp_write(rt2x00dev, 142, 0x30);
++ rt2800_bbp_write(rt2x00dev, 143, 0xF7);
++ rt2800_bbp_write(rt2x00dev, 160, 0xEC);
++ rt2800_bbp_write(rt2x00dev, 161, 0xC4);
++ rt2800_bbp_write(rt2x00dev, 162, 0x77);
++ rt2800_bbp_write(rt2x00dev, 163, 0xF9);
++ rt2800_bbp_write(rt2x00dev, 164, 0x00);
++ rt2800_bbp_write(rt2x00dev, 165, 0x00);
++ rt2800_bbp_write(rt2x00dev, 186, 0x00);
++ rt2800_bbp_write(rt2x00dev, 187, 0x00);
++ rt2800_bbp_write(rt2x00dev, 188, 0x00);
++ rt2800_bbp_write(rt2x00dev, 186, 0x00);
++ rt2800_bbp_write(rt2x00dev, 187, 0x01);
++ rt2800_bbp_write(rt2x00dev, 188, 0x00);
++ rt2800_bbp_write(rt2x00dev, 189, 0x00);
++
++ rt2800_bbp_write(rt2x00dev, 91, 0x06);
++ rt2800_bbp_write(rt2x00dev, 92, 0x04);
++ rt2800_bbp_write(rt2x00dev, 93, 0x54);
++ rt2800_bbp_write(rt2x00dev, 99, 0x50);
++ rt2800_bbp_write(rt2x00dev, 148, 0x84);
++ rt2800_bbp_write(rt2x00dev, 167, 0x80);
++ rt2800_bbp_write(rt2x00dev, 178, 0xFF);
++ rt2800_bbp_write(rt2x00dev, 106, 0x13);
++
++ /* BBP for G band GLRT function (BBP_128 ~ BBP_221) */
++ rt2800_bbp_glrt_write(rt2x00dev, 0, 0x00);
++ rt2800_bbp_glrt_write(rt2x00dev, 1, 0x14); /* ? see above */
++ rt2800_bbp_glrt_write(rt2x00dev, 2, 0x20);
++ rt2800_bbp_glrt_write(rt2x00dev, 3, 0x0A);
++ rt2800_bbp_glrt_write(rt2x00dev, 10, 0x16);
++ rt2800_bbp_glrt_write(rt2x00dev, 11, 0x06);
++ rt2800_bbp_glrt_write(rt2x00dev, 12, 0x02);
++ rt2800_bbp_glrt_write(rt2x00dev, 13, 0x07);
++ rt2800_bbp_glrt_write(rt2x00dev, 14, 0x05);
++ rt2800_bbp_glrt_write(rt2x00dev, 15, 0x09);
++ rt2800_bbp_glrt_write(rt2x00dev, 16, 0x20);
++ rt2800_bbp_glrt_write(rt2x00dev, 17, 0x08);
++ rt2800_bbp_glrt_write(rt2x00dev, 18, 0x4A);
++ rt2800_bbp_glrt_write(rt2x00dev, 19, 0x00);
++ rt2800_bbp_glrt_write(rt2x00dev, 20, 0x00);
++ rt2800_bbp_glrt_write(rt2x00dev, 128, 0xE0);
++ rt2800_bbp_glrt_write(rt2x00dev, 129, 0x1F);
++ rt2800_bbp_glrt_write(rt2x00dev, 130, 0x4F);
++ rt2800_bbp_glrt_write(rt2x00dev, 131, 0x32);
++ rt2800_bbp_glrt_write(rt2x00dev, 132, 0x08);
++ rt2800_bbp_glrt_write(rt2x00dev, 133, 0x28);
++ rt2800_bbp_glrt_write(rt2x00dev, 134, 0x19);
++ rt2800_bbp_glrt_write(rt2x00dev, 135, 0x0A);
++ rt2800_bbp_glrt_write(rt2x00dev, 138, 0x16);
++ rt2800_bbp_glrt_write(rt2x00dev, 139, 0x10);
++ rt2800_bbp_glrt_write(rt2x00dev, 140, 0x10);
++ rt2800_bbp_glrt_write(rt2x00dev, 141, 0x1A);
++ rt2800_bbp_glrt_write(rt2x00dev, 142, 0x36);
++ rt2800_bbp_glrt_write(rt2x00dev, 143, 0x2C);
++ rt2800_bbp_glrt_write(rt2x00dev, 144, 0x26);
++ rt2800_bbp_glrt_write(rt2x00dev, 145, 0x24);
++ rt2800_bbp_glrt_write(rt2x00dev, 146, 0x42);
++ rt2800_bbp_glrt_write(rt2x00dev, 147, 0x40);
++ rt2800_bbp_glrt_write(rt2x00dev, 148, 0x30);
++ rt2800_bbp_glrt_write(rt2x00dev, 149, 0x29);
++ rt2800_bbp_glrt_write(rt2x00dev, 150, 0x4C);
++ rt2800_bbp_glrt_write(rt2x00dev, 151, 0x46);
++ rt2800_bbp_glrt_write(rt2x00dev, 152, 0x3D);
++ rt2800_bbp_glrt_write(rt2x00dev, 153, 0x40);
++ rt2800_bbp_glrt_write(rt2x00dev, 154, 0x3E);
++ rt2800_bbp_glrt_write(rt2x00dev, 155, 0x38);
++ rt2800_bbp_glrt_write(rt2x00dev, 156, 0x3D);
++ rt2800_bbp_glrt_write(rt2x00dev, 157, 0x2F);
++ rt2800_bbp_glrt_write(rt2x00dev, 158, 0x3C);
++ rt2800_bbp_glrt_write(rt2x00dev, 159, 0x34);
++ rt2800_bbp_glrt_write(rt2x00dev, 160, 0x2C);
++ rt2800_bbp_glrt_write(rt2x00dev, 161, 0x2F);
++ rt2800_bbp_glrt_write(rt2x00dev, 162, 0x3C);
++ rt2800_bbp_glrt_write(rt2x00dev, 163, 0x35);
++ rt2800_bbp_glrt_write(rt2x00dev, 164, 0x2E);
++ rt2800_bbp_glrt_write(rt2x00dev, 165, 0x2F);
++ rt2800_bbp_glrt_write(rt2x00dev, 166, 0x49);
++ rt2800_bbp_glrt_write(rt2x00dev, 167, 0x41);
++ rt2800_bbp_glrt_write(rt2x00dev, 168, 0x36);
++ rt2800_bbp_glrt_write(rt2x00dev, 169, 0x39);
++ rt2800_bbp_glrt_write(rt2x00dev, 170, 0x30);
++ rt2800_bbp_glrt_write(rt2x00dev, 171, 0x30);
++ rt2800_bbp_glrt_write(rt2x00dev, 172, 0x0E);
++ rt2800_bbp_glrt_write(rt2x00dev, 173, 0x0D);
++ rt2800_bbp_glrt_write(rt2x00dev, 174, 0x28);
++ rt2800_bbp_glrt_write(rt2x00dev, 175, 0x21);
++ rt2800_bbp_glrt_write(rt2x00dev, 176, 0x1C);
++ rt2800_bbp_glrt_write(rt2x00dev, 177, 0x16);
++ rt2800_bbp_glrt_write(rt2x00dev, 178, 0x50);
++ rt2800_bbp_glrt_write(rt2x00dev, 179, 0x4A);
++ rt2800_bbp_glrt_write(rt2x00dev, 180, 0x43);
++ rt2800_bbp_glrt_write(rt2x00dev, 181, 0x50);
++ rt2800_bbp_glrt_write(rt2x00dev, 182, 0x10);
++ rt2800_bbp_glrt_write(rt2x00dev, 183, 0x10);
++ rt2800_bbp_glrt_write(rt2x00dev, 184, 0x10);
++ rt2800_bbp_glrt_write(rt2x00dev, 185, 0x10);
++ rt2800_bbp_glrt_write(rt2x00dev, 200, 0x7D);
++ rt2800_bbp_glrt_write(rt2x00dev, 201, 0x14);
++ rt2800_bbp_glrt_write(rt2x00dev, 202, 0x32);
++ rt2800_bbp_glrt_write(rt2x00dev, 203, 0x2C);
++ rt2800_bbp_glrt_write(rt2x00dev, 204, 0x36);
++ rt2800_bbp_glrt_write(rt2x00dev, 205, 0x4C);
++ rt2800_bbp_glrt_write(rt2x00dev, 206, 0x43);
++ rt2800_bbp_glrt_write(rt2x00dev, 207, 0x2C);
++ rt2800_bbp_glrt_write(rt2x00dev, 208, 0x2E);
++ rt2800_bbp_glrt_write(rt2x00dev, 209, 0x36);
++ rt2800_bbp_glrt_write(rt2x00dev, 210, 0x30);
++ rt2800_bbp_glrt_write(rt2x00dev, 211, 0x6E);
++
++ /* BBP for G band DCOC function */
++ rt2800_bbp_dcoc_write(rt2x00dev, 140, 0x0C);
++ rt2800_bbp_dcoc_write(rt2x00dev, 141, 0x00);
++ rt2800_bbp_dcoc_write(rt2x00dev, 142, 0x10);
++ rt2800_bbp_dcoc_write(rt2x00dev, 143, 0x10);
++ rt2800_bbp_dcoc_write(rt2x00dev, 144, 0x10);
++ rt2800_bbp_dcoc_write(rt2x00dev, 145, 0x10);
++ rt2800_bbp_dcoc_write(rt2x00dev, 146, 0x08);
++ rt2800_bbp_dcoc_write(rt2x00dev, 147, 0x40);
++ rt2800_bbp_dcoc_write(rt2x00dev, 148, 0x04);
++ rt2800_bbp_dcoc_write(rt2x00dev, 149, 0x04);
++ rt2800_bbp_dcoc_write(rt2x00dev, 150, 0x08);
++ rt2800_bbp_dcoc_write(rt2x00dev, 151, 0x08);
++ rt2800_bbp_dcoc_write(rt2x00dev, 152, 0x03);
++ rt2800_bbp_dcoc_write(rt2x00dev, 153, 0x03);
++ rt2800_bbp_dcoc_write(rt2x00dev, 154, 0x03);
++ rt2800_bbp_dcoc_write(rt2x00dev, 155, 0x02);
++ rt2800_bbp_dcoc_write(rt2x00dev, 156, 0x40);
++ rt2800_bbp_dcoc_write(rt2x00dev, 157, 0x40);
++ rt2800_bbp_dcoc_write(rt2x00dev, 158, 0x64);
++ rt2800_bbp_dcoc_write(rt2x00dev, 159, 0x64);
++
++ rt2800_bbp4_mac_if_ctrl(rt2x00dev);
++}
++
+ static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
+ {
+ unsigned int i;
+@@ -6117,7 +6734,10 @@ static void rt2800_init_bbp(struct rt2x0
+ return;
+ case RT5390:
+ case RT5392:
+- rt2800_init_bbp_53xx(rt2x00dev);
++ if (rt2x00dev->chip.rf == RF7620)
++ rt2800_init_bbp_7620(rt2x00dev);
++ else
++ rt2800_init_bbp_53xx(rt2x00dev);
+ break;
+ case RT5592:
+ rt2800_init_bbp_5592(rt2x00dev);
+@@ -7331,6 +7951,277 @@ static void rt2800_init_rfcsr_5592(struc
+ rt2800_led_open_drain_enable(rt2x00dev);
+ }
+
++static void rt2800_init_rfcsr_7620(struct rt2x00_dev *rt2x00dev)
++{
++ u8 rfvalue;
++ u16 freq;
++
++ /* Initialize RF central register to default value */
++ rt2800_rfcsr_write(rt2x00dev, 0, 0x02);
++ rt2800_rfcsr_write(rt2x00dev, 1, 0x03);
++ rt2800_rfcsr_write(rt2x00dev, 2, 0x33);
++ rt2800_rfcsr_write(rt2x00dev, 3, 0xFF);
++ rt2800_rfcsr_write(rt2x00dev, 4, 0x0C);
++ rt2800_rfcsr_write(rt2x00dev, 5, 0x40); /* Read only */
++ rt2800_rfcsr_write(rt2x00dev, 6, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 7, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 8, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 9, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 10, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 11, 0x00);
++ /* rt2800_rfcsr_write(rt2x00dev, 12, 0x43); *//* EEPROM */
++ rt2800_rfcsr_write(rt2x00dev, 13, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 14, 0x40);
++ rt2800_rfcsr_write(rt2x00dev, 15, 0x22);
++ rt2800_rfcsr_write(rt2x00dev, 16, 0x4C);
++ rt2800_rfcsr_write(rt2x00dev, 17, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 18, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 19, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 20, 0xA0);
++ rt2800_rfcsr_write(rt2x00dev, 21, 0x12);
++ rt2800_rfcsr_write(rt2x00dev, 22, 0x07);
++ rt2800_rfcsr_write(rt2x00dev, 23, 0x13);
++ rt2800_rfcsr_write(rt2x00dev, 24, 0xFE);
++ rt2800_rfcsr_write(rt2x00dev, 25, 0x24);
++ rt2800_rfcsr_write(rt2x00dev, 26, 0x7A);
++ rt2800_rfcsr_write(rt2x00dev, 27, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 28, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 29, 0x05);
++ rt2800_rfcsr_write(rt2x00dev, 30, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 31, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 32, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 34, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 35, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 36, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 37, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 38, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 39, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 40, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 41, 0xD0);
++ rt2800_rfcsr_write(rt2x00dev, 42, 0x5B);
++ rt2800_rfcsr_write(rt2x00dev, 43, 0x00);
++
++ rt2800_rfcsr_write(rt2x00dev, 11, 0x21);
++ if (rt2800_clk_is_20mhz(rt2x00dev))
++ rt2800_rfcsr_write(rt2x00dev, 13, 0x03);
++ else
++ rt2800_rfcsr_write(rt2x00dev, 13, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 14, 0x7C);
++ rt2800_rfcsr_write(rt2x00dev, 16, 0x80);
++ rt2800_rfcsr_write(rt2x00dev, 17, 0x99);
++ rt2800_rfcsr_write(rt2x00dev, 18, 0x99);
++ rt2800_rfcsr_write(rt2x00dev, 19, 0x09);
++ rt2800_rfcsr_write(rt2x00dev, 20, 0x50);
++ rt2800_rfcsr_write(rt2x00dev, 21, 0xB0);
++ rt2800_rfcsr_write(rt2x00dev, 22, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 23, 0x06);
++ rt2800_rfcsr_write(rt2x00dev, 24, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 25, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 26, 0x5D);
++ rt2800_rfcsr_write(rt2x00dev, 27, 0x00);
++ rt2800_rfcsr_write(rt2x00dev, 28, 0x61);
++ rt2800_rfcsr_write(rt2x00dev, 29, 0xB5);
++ rt2800_rfcsr_write(rt2x00dev, 43, 0x02);
++
++ rt2800_rfcsr_write(rt2x00dev, 28, 0x62);
++ rt2800_rfcsr_write(rt2x00dev, 29, 0xAD);
++ rt2800_rfcsr_write(rt2x00dev, 39, 0x80);
++
++ /* use rt2800_adjust_freq_offset ? */
++ rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &freq);
++ rfvalue = freq & 0xff;
++ rt2800_rfcsr_write(rt2x00dev, 12, rfvalue);
++
++ /* Initialize RF channel register to default value */
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 0, 0x03);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 1, 0x00);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 2, 0x00);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 3, 0x00);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 4, 0x00);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 5, 0x08);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 6, 0x00);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 7, 0x51);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 8, 0x53);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 9, 0x16);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 10, 0x61);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 11, 0x53);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 12, 0x22);
++ /* rt2800_rfcsr_write_chanreg(rt2x00dev, 13, 0x3D); */ /* fails */
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x06);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 15, 0x13);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 16, 0x22);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x27);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 18, 0x02);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 19, 0xA7);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 20, 0x01);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 21, 0x52);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 22, 0x80);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 23, 0xB3);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 24, 0x00);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 25, 0x00);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 26, 0x00);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 27, 0x00);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 28, 0x5C);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 29, 0x6B);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 30, 0x6B);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 31, 0x31);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 32, 0x5D);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 33, 0x00);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 34, 0xE6);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 35, 0x55);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 36, 0x00);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 37, 0xBB);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 38, 0xB3);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 39, 0xB3);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 40, 0x03);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 41, 0x00);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 42, 0x00);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0xB3);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0xD3);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0xD5);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 46, 0x07);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x68);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xEF);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x1C);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x07);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0xA8);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0x85);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 57, 0x10);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x07);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0x6A);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0x85);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x10);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 62, 0x1C);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 63, 0x00);
++
++ rt2800_rfcsr_write_bank(rt2x00dev, 6, 45, 0xC5);
++
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 9, 0x47);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 10, 0x71);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 11, 0x33);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x0E);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x23);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 19, 0xA4);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 20, 0x02);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 21, 0x12);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 28, 0x1C);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 29, 0xEB);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 32, 0x7D);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 34, 0xD6);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 36, 0x08);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 38, 0xB4);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0xD3);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0xB3);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0xD5);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 46, 0x27);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x69);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xFF);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x20);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x66);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xFF);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 57, 0x1C);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x20);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0x6B);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xF7);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x09);
++
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 10, 0x51);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x06);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 19, 0xA7);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 28, 0x2C);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x64);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 8, 0x51);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 9, 0x36);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 11, 0x53);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x16);
++
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x6C);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xFC);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x1F);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x27);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x66);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0x6B);
++
++ /* Initialize RF channel register for DRQFN */
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0xD3);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0xE3);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0xE5);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x28);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x68);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xF7);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x02);
++ rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xC7);
++
++ /* Initialize RF DC calibration register to default value */
++ rt2800_rfcsr_write_dccal(rt2x00dev, 0, 0x47);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 1, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 2, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 3, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 4, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 6, 0x10);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 7, 0x10);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 8, 0x04);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 9, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 10, 0x07);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 11, 0x01);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 12, 0x07);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 13, 0x07);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 14, 0x07);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 15, 0x20);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 16, 0x22);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 18, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 19, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 20, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 21, 0xF1);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 22, 0x11);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 23, 0x02);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 24, 0x41);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 25, 0x20);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 26, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 27, 0xD7);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 28, 0xA2);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 29, 0x20);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 30, 0x49);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 31, 0x20);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 32, 0x04);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 33, 0xF1);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 34, 0xA1);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 35, 0x01);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 41, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 42, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 43, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 44, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 45, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 46, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 47, 0x3E);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 48, 0x3D);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 49, 0x3E);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 50, 0x3D);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 51, 0x3E);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 52, 0x3D);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 53, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 54, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 55, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 56, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 57, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 58, 0x10);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 59, 0x10);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 60, 0x0A);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 61, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 62, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 63, 0x00);
++
++ rt2800_rfcsr_write_dccal(rt2x00dev, 3, 0x08);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 4, 0x04);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x20);
++
++ rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00);
++ rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C);
++}
++
+ static void rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
+ {
+ if (rt2800_is_305x_soc(rt2x00dev)) {
+@@ -7366,7 +8257,10 @@ static void rt2800_init_rfcsr(struct rt2
+ rt2800_init_rfcsr_5350(rt2x00dev);
+ break;
+ case RT5390:
+- rt2800_init_rfcsr_5390(rt2x00dev);
++ if (rt2x00dev->chip.rf == RF7620)
++ rt2800_init_rfcsr_7620(rt2x00dev);
++ else
++ rt2800_init_rfcsr_5390(rt2x00dev);
+ break;
+ case RT5392:
+ rt2800_init_rfcsr_5392(rt2x00dev);
+@@ -7780,6 +8674,7 @@ static int rt2800_init_eeprom(struct rt2
+ case RF5390:
+ case RF5392:
+ case RF5592:
++ case RF7620:
+ break;
+ default:
+ rt2x00_err(rt2x00dev, "Invalid RF chipset 0x%04x detected\n",
+@@ -8258,6 +9153,24 @@ static const struct rf_channel rf_vals_5
+ {196, 83, 0, 12, 1},
+ };
+
++static const struct rf_channel rf_vals_7620[] = {
++ /* Channel, Rdiv, N, K | (D >> 8), Ksd */
++ {1, 3, 0x50, 0 | (0 >> 8), 0x19999},
++ {2, 3, 0x50, 0 | (0 >> 8), 0x24444},
++ {3, 3, 0x50, 0 | (0 >> 8), 0x2EEEE},
++ {4, 3, 0x50, 0 | (0 >> 8), 0x39999},
++ {5, 3, 0x51, 0 | (0 >> 8), 0x04444},
++ {6, 3, 0x51, 0 | (0 >> 8), 0x0EEEE},
++ {7, 3, 0x51, 0 | (0 >> 8), 0x19999},
++ {8, 3, 0x51, 0 | (0 >> 8), 0x24444},
++ {9, 3, 0x51, 0 | (0 >> 8), 0x2EEEE},
++ {10, 3, 0x51, 0 | (0 >> 8), 0x39999},
++ {11, 3, 0x52, 0 | (0 >> 8), 0x04444},
++ {12, 3, 0x52, 0 | (0 >> 8), 0x0EEEE},
++ {13, 3, 0x52, 0 | (0 >> 8), 0x19999},
++ {14, 3, 0x52, 0 | (0 >> 8), 0x33333},
++};
++
+ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
+ {
+ struct hw_mode_spec *spec = &rt2x00dev->spec;
+@@ -8361,6 +9274,11 @@ static int rt2800_probe_hw_mode(struct r
+ spec->channels = rf_vals_3x;
+ break;
+
++ case RF7620:
++ spec->num_channels = ARRAY_SIZE(rf_vals_7620);
++ spec->channels = rf_vals_7620;
++ break;
++
+ case RF3052:
+ case RF3053:
+ spec->num_channels = ARRAY_SIZE(rf_vals_3x);
+@@ -8498,6 +9416,7 @@ static int rt2800_probe_hw_mode(struct r
+ case RF5390:
+ case RF5392:
+ case RF5592:
++ case RF7620:
+ __set_bit(CAPABILITY_VCO_RECALIBRATION, &rt2x00dev->cap_flags);
+ break;
+ }
+++ /dev/null
---- a/drivers/net/wireless/marvell/mwl8k.c
-+++ b/drivers/net/wireless/marvell/mwl8k.c
-@@ -5681,6 +5681,7 @@ MODULE_FIRMWARE("mwl8k/fmimage_8366.fw")
- MODULE_FIRMWARE(MWL8K_8366_AP_FW(MWL8K_8366_AP_FW_API));
-
- static const struct pci_device_id mwl8k_pci_id_table[] = {
-+ { PCI_VDEVICE(MARVELL, 0x2a02), .driver_data = MWL8363, },
- { PCI_VDEVICE(MARVELL, 0x2a0a), .driver_data = MWL8363, },
- { PCI_VDEVICE(MARVELL, 0x2a0c), .driver_data = MWL8363, },
- { PCI_VDEVICE(MARVELL, 0x2a24), .driver_data = MWL8363, },
--- /dev/null
+--- a/drivers/net/wireless/marvell/libertas/cfg.c
++++ b/drivers/net/wireless/marvell/libertas/cfg.c
+@@ -2127,6 +2127,8 @@ struct wireless_dev *lbs_cfg_alloc(struc
+ goto err_wiphy_new;
+ }
+
++ set_wiphy_dev(wdev->wiphy, dev);
++
+ lbs_deb_leave(LBS_DEB_CFG80211);
+ return wdev;
+
+--- a/drivers/net/wireless/marvell/libertas/main.c
++++ b/drivers/net/wireless/marvell/libertas/main.c
+@@ -986,6 +986,7 @@ struct lbs_private *lbs_add_card(void *c
+ goto err_adapter;
+ }
+
++ dev_net_set(dev, wiphy_net(wdev->wiphy));
+ dev->ieee80211_ptr = wdev;
+ dev->ml_priv = priv;
+ SET_NETDEV_DEV(dev, dmdev);
--- /dev/null
+--- a/drivers/net/wireless/marvell/libertas/cfg.c
++++ b/drivers/net/wireless/marvell/libertas/cfg.c
+@@ -2217,6 +2217,8 @@ int lbs_cfg_register(struct lbs_private
+ wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
+ wdev->wiphy->reg_notifier = lbs_reg_notifier;
+
++ memcpy(wdev->wiphy->perm_addr, priv->current_addr, ETH_ALEN);
++
+ ret = wiphy_register(wdev->wiphy);
+ if (ret < 0)
+ pr_err("cannot register wiphy device\n");
--- /dev/null
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c
+@@ -58,19 +58,12 @@
+ (((c) < 149) ? 3 : 4))))
+
+ #define BRCM_2GHZ_2412_2462 REG_RULE(2412-10, 2462+10, 40, 0, 19, 0)
+-#define BRCM_2GHZ_2467_2472 REG_RULE(2467-10, 2472+10, 20, 0, 19, \
+- NL80211_RRF_NO_IR)
++#define BRCM_2GHZ_2467_2472 REG_RULE(2467-10, 2472+10, 20, 0, 19, 0)
+
+-#define BRCM_5GHZ_5180_5240 REG_RULE(5180-10, 5240+10, 40, 0, 21, \
+- NL80211_RRF_NO_IR)
+-#define BRCM_5GHZ_5260_5320 REG_RULE(5260-10, 5320+10, 40, 0, 21, \
+- NL80211_RRF_DFS | \
+- NL80211_RRF_NO_IR)
+-#define BRCM_5GHZ_5500_5700 REG_RULE(5500-10, 5700+10, 40, 0, 21, \
+- NL80211_RRF_DFS | \
+- NL80211_RRF_NO_IR)
+-#define BRCM_5GHZ_5745_5825 REG_RULE(5745-10, 5825+10, 40, 0, 21, \
+- NL80211_RRF_NO_IR)
++#define BRCM_5GHZ_5180_5240 REG_RULE(5180-10, 5240+10, 40, 0, 21, 0)
++#define BRCM_5GHZ_5260_5320 REG_RULE(5260-10, 5320+10, 40, 0, 21, 0)
++#define BRCM_5GHZ_5500_5700 REG_RULE(5500-10, 5700+10, 40, 0, 21, 0)
++#define BRCM_5GHZ_5745_5825 REG_RULE(5745-10, 5825+10, 40, 0, 21, 0)
+
+ static const struct ieee80211_regdomain brcms_regdom_x2 = {
+ .n_reg_rules = 6,
--- /dev/null
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
+Date: Mon, 8 Jun 2015 16:11:40 +0200
+Subject: [PATCH] brcmfmac: register wiphy(s) during module_init
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This is needed by OpenWrt which expects all PHYs to be created after
+module loads successfully.
+
+Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
+---
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+@@ -1196,6 +1196,7 @@ int __init brcmf_core_init(void)
+ {
+ if (!schedule_work(&brcmf_driver_work))
+ return -EBUSY;
++ flush_work(&brcmf_driver_work);
+
+ return 0;
+ }
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+@@ -444,6 +444,7 @@ struct brcmf_fw {
+ u16 bus_nr;
+ void (*done)(struct device *dev, const struct firmware *fw,
+ void *nvram_image, u32 nvram_len);
++ struct completion *completion;
+ };
+
+ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
+@@ -478,6 +479,8 @@ static void brcmf_fw_request_nvram_done(
+ goto fail;
+
+ fwctx->done(fwctx->dev, fwctx->code, nvram, nvram_length);
++ if (fwctx->completion)
++ complete(fwctx->completion);
+ kfree(fwctx);
+ return;
+
+@@ -485,6 +488,8 @@ fail:
+ brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
+ release_firmware(fwctx->code);
+ device_release_driver(fwctx->dev);
++ if (fwctx->completion)
++ complete(fwctx->completion);
+ kfree(fwctx);
+ }
+
+@@ -500,6 +505,8 @@ static void brcmf_fw_request_code_done(c
+ /* only requested code so done here */
+ if (!(fwctx->flags & BRCMF_FW_REQUEST_NVRAM)) {
+ fwctx->done(fwctx->dev, fw, NULL, 0);
++ if (fwctx->completion)
++ complete(fwctx->completion);
+ kfree(fwctx);
+ return;
+ }
+@@ -517,6 +524,8 @@ static void brcmf_fw_request_code_done(c
+ fail:
+ brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
+ device_release_driver(fwctx->dev);
++ if (fwctx->completion)
++ complete(fwctx->completion);
+ kfree(fwctx);
+ }
+
+@@ -528,6 +537,8 @@ int brcmf_fw_get_firmwares_pcie(struct d
+ u16 domain_nr, u16 bus_nr)
+ {
+ struct brcmf_fw *fwctx;
++ struct completion completion;
++ int err;
+
+ brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev));
+ if (!fw_cb || !code)
+@@ -548,9 +559,17 @@ int brcmf_fw_get_firmwares_pcie(struct d
+ fwctx->domain_nr = domain_nr;
+ fwctx->bus_nr = bus_nr;
+
+- return request_firmware_nowait(THIS_MODULE, true, code, dev,
++ init_completion(&completion);
++ fwctx->completion = &completion;
++
++ err = request_firmware_nowait(THIS_MODULE, true, code, dev,
+ GFP_KERNEL, fwctx,
+ brcmf_fw_request_code_done);
++ if (!err)
++ wait_for_completion_timeout(fwctx->completion,
++ msecs_to_jiffies(5000));
++ fwctx->completion = NULL;
++ return err;
+ }
+
+ int brcmf_fw_get_firmwares(struct device *dev, u16 flags,
--- /dev/null
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
+Date: Thu, 9 Jul 2015 00:07:59 +0200
+Subject: [PATCH] brcmfmac: workaround bug with some inconsistent BSSes state
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
+---
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -656,9 +656,37 @@ static struct wireless_dev *brcmf_cfg802
+ u32 *flags,
+ struct vif_params *params)
+ {
++ struct net_device *dev;
+ struct wireless_dev *wdev;
+ int err;
+
++ /*
++ * There is a bug with in-firmware BSS management. When adding virtual
++ * interface brcmfmac first tells firmware to create new BSS and then
++ * it creates new struct net_device.
++ *
++ * If creating/registering netdev(ice) fails, BSS remains in some bugged
++ * state. It conflicts with existing BSSes by overtaking their auth
++ * requests.
++ *
++ * It results in one BSS (addresss X) sending beacons and another BSS
++ * (address Y) replying to authentication requests. This makes interface
++ * unusable as AP.
++ *
++ * To workaround this bug we may try to guess if register_netdev(ice)
++ * will fail. The most obvious case is using interface name that already
++ * exists. This is actually quite likely with brcmfmac & some user space
++ * scripts as brcmfmac doesn't allow deleting virtual interfaces.
++ * So this bug can be triggered even by something trivial like:
++ * iw dev wlan0 delete
++ * iw phy phy0 interface add wlan0 type __ap
++ */
++ dev = dev_get_by_name(&init_net, name);
++ if (dev) {
++ dev_put(dev);
++ return ERR_PTR(-ENFILE);
++ }
++
+ brcmf_dbg(TRACE, "enter: %s type %d\n", name, type);
+ err = brcmf_vif_add_validate(wiphy_to_cfg(wiphy), type);
+ if (err) {
--- /dev/null
+From 66ae1b1750720a33e29792a177b1e696f4f005fb Mon Sep 17 00:00:00 2001
+From: Phil Elwell <phil@raspberrypi.org>
+Date: Wed, 9 Mar 2016 17:25:59 +0000
+Subject: [PATCH] brcmfmac: Disable power management
+
+Disable wireless power saving in the brcmfmac WLAN driver. This is a
+temporary measure until the connectivity loss resulting from power
+saving is resolved.
+
+Signed-off-by: Phil Elwell <phil@raspberrypi.org>
+---
+ drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -2775,6 +2775,10 @@ brcmf_cfg80211_set_power_mgmt(struct wip
+ * preference in cfg struct to apply this to
+ * FW later while initializing the dongle
+ */
++#if defined(CONFIG_ARCH_BCM2835)
++ brcmf_dbg(INFO, "power management disabled\n");
++ enabled = false;
++#endif
+ cfg->pwr_save = enabled;
+ if (!check_vif_up(ifp->vif)) {
+
--- /dev/null
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Subject: [PATCH] brcmfmac: add in-driver tables with country codes
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This adds early support for changing region. Ideally this data should
+be stored in DT as all these mappings are devices specific.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+---
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
+@@ -23,6 +23,36 @@
+ #include "common.h"
+ #include "of.h"
+
++/* TODO: FIXME: Use DT */
++static void brcmf_of_probe_cc(struct device *dev,
++ struct brcmf_mp_device *settings)
++{
++ static struct brcmfmac_pd_cc_entry netgear_r8000_cc_ent[] = {
++ { "JP", "JP", 78 },
++ { "US", "Q2", 86 },
++ };
++ struct brcmfmac_pd_cc_entry *cc_ent = NULL;
++ int table_size = 0;
++
++ if (of_machine_is_compatible("netgear,r8000")) {
++ cc_ent = netgear_r8000_cc_ent;
++ table_size = ARRAY_SIZE(netgear_r8000_cc_ent);
++ }
++
++ if (cc_ent && table_size) {
++ struct brcmfmac_pd_cc *cc;
++ size_t memsize;
++
++ memsize = table_size * sizeof(struct brcmfmac_pd_cc_entry);
++ cc = devm_kzalloc(dev, sizeof(*cc) + memsize, GFP_KERNEL);
++ if (!cc)
++ return;
++ cc->table_size = table_size;
++ memcpy(cc->table, cc_ent, memsize);
++ settings->country_codes = cc;
++ }
++}
++
+ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
+ struct brcmf_mp_device *settings)
+ {
+@@ -32,6 +62,8 @@ void brcmf_of_probe(struct device *dev,
+ u32 irqf;
+ u32 val;
+
++ brcmf_of_probe_cc(dev, settings);
++
+ if (!np || bus_type != BRCMF_BUSTYPE_SDIO ||
+ !of_device_is_compatible(np, "brcm,bcm4329-fmac"))
+ return;
--- /dev/null
+brcmfmac: do not use internal roaming engine by default
+
+Some evidence of curing disconnects with this disabled, so make it a default.
+Can be overridden with module parameter roamoff=0
+See: http://projectable.me/optimize-my-pi-wi-fi/
+
+Signed-off-by: Phil Elwell <phil@raspberrypi.org>
+---
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+@@ -69,7 +69,11 @@ static int brcmf_fcmode;
+ module_param_named(fcmode, brcmf_fcmode, int, 0);
+ MODULE_PARM_DESC(fcmode, "Mode of firmware signalled flow control");
+
++#if defined(CONFIG_ARCH_BCM2835)
++static int brcmf_roamoff = 1;
++#else
+ static int brcmf_roamoff;
++#endif
+ module_param_named(roamoff, brcmf_roamoff, int, S_IRUSR);
+ MODULE_PARM_DESC(roamoff, "Do not use internal roaming engine");
+
case "$board" in
"om2p" | \
+ "om2pv4" | \
"om2p-hs" | \
"om2p-hsv2" | \
"om2p-hsv3" | \
+ "om2p-hsv4" | \
"om5p-acv2")
return 12
;;
"mr900" | \
"mr900v2" | \
"mr1750" | \
- "mr1750v2")
+ "mr1750v2" | \
+ "a40" | \
+ "a60")
return 16
;;
esac
config PCAP_HAS_USB
bool "Include USB support"
- depends on PACKAGE_kmod-usb-core
default n
config PCAP_HAS_BT
bool "Include bluetooth support"
- depends on PACKAGE_kmod-bluetooth
depends on BROKEN
default n
+config PCAP_HAS_NETFILTER
+ bool "Include netfilter support"
+ default n
+
endmenu
CONFIGURE_VARS += \
ac_cv_linux_vers=$(LINUX_VERSION) \
- ac_cv_header_libusb_1_0_libusb_h=no \
- ac_cv_netfilter_can_compile=no
+ ac_cv_header_libusb_1_0_libusb_h=no
+ifeq ($(CONFIG_PCAP_HAS_NETFILTER),)
+CONFIGURE_VARS += \
+ ac_cv_netfilter_can_compile=no
+endif
CONFIGURE_ARGS += \
--enable-shared \
PKG_NAME:=libtool
PKG_VERSION:=2.4
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@GNU/libtool
define Build/InstallDev
$(MAKE) -C $(PKG_BUILD_DIR) \
- bindir="$(2)/bin" \
- datadir="$(2)/share" \
- prefix="$(2)" \
- exec_prefix="$(2)" \
+ bindir="$(2)/libltdl/bin" \
+ datadir="$(2)/libltdl/share" \
+ prefix="$(2)/libltdl" \
+ exec_prefix="$(2)/libltdl" \
install
$(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include
- mv $(2)/lib/* $(1)/usr/lib/
- mv $(2)/include/* $(1)/usr/include/
+ mv $(2)/libltdl/lib/* $(1)/usr/lib/
+ mv $(2)/libltdl/include/* $(1)/usr/include/
endef
define Package/libltdl/install
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(LEDE_GIT)/project/libubox.git
-PKG_SOURCE_DATE:=2016-11-29
-PKG_SOURCE_VERSION:=77a629375d7387a33a59509d9d751a8798134cab
-PKG_MIRROR_HASH:=b11c24d45cdf5a1909f0f97d185c3e1ba49602561a8cf3ad18f594ca0eaf4a64
+PKG_SOURCE_DATE:=2017-02-24
+PKG_SOURCE_VERSION:=96305a3cafcc9c0df7f189567671bb26ce3eb129
+PKG_MIRROR_HASH:=19dc9f73621a65d1374427160f59e338db45ee6edc30edff6a6fee10dcdfc8b6
CMAKE_INSTALL:=1
PKG_LICENSE:=ISC
include $(TOPDIR)/rules.mk
PKG_NAME:=mbedtls
-PKG_VERSION:=2.4.0
-PKG_RELEASE:=2
+PKG_VERSION:=2.4.2
+PKG_RELEASE:=1
PKG_USE_MIPS16:=0
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-gpl.tgz
PKG_SOURCE_URL:=https://tls.mbed.org/download/
-PKG_HASH:=80eff0e0028f969355d6e34ffdd3dbf4eb2a9367b07ff2f3f70e6d75beee9e3f
+PKG_HASH:=d01f2d5586a52055329d194d909103f445bd2d0b6b2b5f1c830fbf828ac6299f
PKG_BUILD_PARALLEL:=1
PKG_LICENSE:=GPL-2.0+
PKG_INSTALL:=1
+TARGET_CFLAGS += -ffunction-sections -fdata-sections
+
CMAKE_OPTIONS += \
-DCMAKE_BUILD_TYPE:String="Release" \
-DUSE_SHARED_MBEDTLS_LIBRARY:Bool=ON \
$(CP) $(PKG_INSTALL_DIR)/usr/include/mbedtls $(1)/usr/include/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so* $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.a $(1)/usr/lib/
endef
define Package/libmbedtls/install
/**
* \def MBEDTLS_MD_C
@@ -2158,7 +2158,7 @@
- * Caller: library/mbedtls_md.c
+ * Caller: library/md.c
*
*/
-#define MBEDTLS_RIPEMD160_C
$(CP) $(PKG_INSTALL_DIR)/usr/bin/ncursesw6-config $(2)/bin/
$(SED) 's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' -e 's/$$$$INCS //g' \
$(2)/bin/ncursesw6-config
- ln -sf $(STAGING_DIR_HOSTPKG)/bin/ncursesw6-config $(1)/usr/bin/ncursesw6-config
+ ln -sf $(STAGING_DIR)/host/bin/ncursesw6-config $(1)/usr/bin/ncursesw6-config
endef
define Host/Compile
PKG_NAME:=openssl
PKG_BASE:=1.0.2
-PKG_BUGFIX:=j
+PKG_BUGFIX:=k
PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX)
PKG_RELEASE:=1
PKG_USE_MIPS16:=0
http://www.openssl.org/source/old/$(PKG_BASE)/ \
ftp://ftp.funet.fi/pub/crypt/mirrors/ftp.openssl.org/source \
ftp://ftp.sunet.se/pub/security/tools/net/openssl/source/
-PKG_HASH:=e7aff292be21c259c6af26469c7a9b3ba26e9abaaffd325e3dccc9785256c431
+PKG_HASH:=6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0
PKG_LICENSE:=OpenSSL
PKG_LICENSE_FILES:=LICENSE
--- a/Configure
+++ b/Configure
-@@ -468,6 +468,12 @@ my %table=(
+@@ -470,6 +470,12 @@ my %table=(
"linux-alpha-ccc","ccc:-fast -readonly_strings -DL_ENDIAN::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}",
"linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}",
--- a/Configure
+++ b/Configure
-@@ -2114,6 +2114,11 @@ EOF
+@@ -2128,6 +2128,11 @@ EOF
close(OUT);
}
WDIRS= windows
LIBS= libcrypto.a libssl.a
SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
-@@ -275,7 +275,7 @@ reflect:
+@@ -276,7 +276,7 @@ reflect:
sub_all: build_all
build_libs: build_libcrypto build_libssl openssl.pc
-@@ -533,7 +533,7 @@ dist:
+@@ -534,7 +534,7 @@ dist:
@$(MAKE) SDIRS='$(SDIRS)' clean
@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
@$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
--- a/Makefile.org
+++ b/Makefile.org
-@@ -531,7 +531,7 @@ dist:
+@@ -532,7 +532,7 @@ dist:
@$(MAKE) SDIRS='$(SDIRS)' clean
@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
# as we stick to -e, CLEARENV ensures that local variables in lower
# Makefiles remain local and variable. $${VAR+VAR} is tribute to Korn
-@@ -403,11 +403,6 @@ openssl.pc: Makefile
+@@ -404,11 +404,6 @@ openssl.pc: Makefile
echo 'Version: '$(VERSION); \
echo 'Requires: libssl libcrypto' ) > openssl.pc
--- a/Makefile.org
+++ b/Makefile.org
-@@ -281,17 +281,17 @@ build_libcrypto: build_crypto build_engi
+@@ -282,17 +282,17 @@ build_libcrypto: build_crypto build_engi
build_libssl: build_ssl libssl.pc
build_crypto:
all_testapps: build_libs build_testapps
build_testapps:
-@@ -464,7 +464,7 @@ update: errors stacks util/libeay.num ut
+@@ -465,7 +465,7 @@ update: errors stacks util/libeay.num ut
@set -e; target=update; $(RECURSIVE_BUILD_CMD)
depend:
lint:
@set -e; target=lint; $(RECURSIVE_BUILD_CMD)
-@@ -526,9 +526,9 @@ dist:
+@@ -527,9 +527,9 @@ dist:
@$(MAKE) SDIRS='$(SDIRS)' clean
@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
@$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR) \
$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines \
-@@ -537,12 +537,19 @@ install_sw:
+@@ -538,12 +538,19 @@ install_sw:
$(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
$(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
$(INSTALL_PREFIX)$(OPENSSLDIR)/private
@set -e; liblist="$(LIBS)"; for i in $$liblist ;\
do \
if [ -f "$$i" ]; then \
-@@ -626,12 +633,7 @@ install_html_docs:
+@@ -627,12 +634,7 @@ install_html_docs:
done; \
done
+++ /dev/null
-#
-# Copyright (C) 2011-2015 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:=polarssl
-SRC_PKG_NAME:=mbedtls
-PKG_VERSION:=1.3.18
-PKG_RELEASE:=1
-PKG_USE_MIPS16:=0
-
-PKG_SOURCE:=$(SRC_PKG_NAME)-$(PKG_VERSION)-gpl.tgz
-PKG_SOURCE_URL:=https://tls.mbed.org/download/
-PKG_HASH:=a229217182e024847deba3cb70bdd17e5ff4ffd9ff306cbbccfdbdff41950ea1
-
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(SRC_PKG_NAME)-$(PKG_VERSION)
-
-PKG_BUILD_PARALLEL:=1
-PKG_LICENSE:=GPL-2.0+
-
-include $(INCLUDE_DIR)/package.mk
-include $(INCLUDE_DIR)/cmake.mk
-
-define Package/polarssl/Default
- SUBMENU:=SSL
- TITLE:=Embedded SSL
- URL:=http://polarssl.org/
-endef
-
-define Package/polarssl/Default/description
-The aim of the PolarSSL project is to provide a quality, open-source
-cryptographic library written in C and targeted at embedded systems.
-endef
-
-define Package/libpolarssl
-$(call Package/polarssl/Default)
- SECTION:=libs
- CATEGORY:=Libraries
- TITLE+= (library)
- ABI_VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
-endef
-
-define Package/libpolarssl/description
-$(call Package/polarssl/Default/description)
-This package contains the PolarSSL library.
-endef
-
-PKG_INSTALL:=1
-
-CMAKE_OPTIONS += \
- -DCMAKE_BUILD_TYPE:String="Release" \
- -DUSE_SHARED_MBEDTLS_LIBRARY:Bool=ON \
- -DENABLE_TESTING:Bool=OFF \
- -DENABLE_PROGRAMS:Bool=OFF \
-
-define Build/InstallDev
- $(INSTALL_DIR) $(1)/usr/include
- $(CP) $(PKG_INSTALL_DIR)/usr/include/polarssl $(1)/usr/include/
- $(INSTALL_DIR) $(1)/usr/lib
- $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmbedtls.so.* $(1)/usr/lib/
- $(LN) libmbedtls.so.$(PKG_VERSION) $(1)/usr/lib/libpolarssl.so
-endef
-
-define Package/libpolarssl/install
- $(INSTALL_DIR) $(1)/usr/lib
- $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmbedtls.so.* $(1)/usr/lib/
- $(LN) libmbedtls.so.$(PKG_VERSION) $(1)/usr/lib/libpolarssl.so
-endef
-
-$(eval $(call BuildPackage,libpolarssl))
+++ /dev/null
---- a/include/polarssl/config.h
-+++ b/include/polarssl/config.h
-@@ -432,8 +432,8 @@
- * Requires: POLARSSL_HMAC_DRBG_C
- *
- * Comment this macro to disable deterministic ECDSA.
-- */
- #define POLARSSL_ECDSA_DETERMINISTIC
-+ */
-
- /**
- * \def POLARSSL_KEY_EXCHANGE_PSK_ENABLED
-@@ -454,8 +454,8 @@
- * TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_PSK_WITH_3DES_EDE_CBC_SHA
- * TLS_PSK_WITH_RC4_128_SHA
-- */
- #define POLARSSL_KEY_EXCHANGE_PSK_ENABLED
-+ */
-
- /**
- * \def POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED
-@@ -478,8 +478,8 @@
- * TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA
- * TLS_DHE_PSK_WITH_RC4_128_SHA
-- */
- #define POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED
-+ */
-
- /**
- * \def POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED
-@@ -498,8 +498,8 @@
- * TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA
- * TLS_ECDHE_PSK_WITH_RC4_128_SHA
-- */
- #define POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED
-+ */
-
- /**
- * \def POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED
-@@ -523,8 +523,8 @@
- * TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA
- * TLS_RSA_PSK_WITH_RC4_128_SHA
-- */
- #define POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED
-+ */
-
- /**
- * \def POLARSSL_KEY_EXCHANGE_RSA_ENABLED
-@@ -602,8 +602,8 @@
- * TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
- * TLS_ECDHE_RSA_WITH_RC4_128_SHA
-- */
- #define POLARSSL_KEY_EXCHANGE_ECDHE_RSA_ENABLED
-+ */
-
- /**
- * \def POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
-@@ -626,8 +626,8 @@
- * TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256
- * TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
- * TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
-- */
- #define POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
-+ */
-
- /**
- * \def POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
-@@ -650,8 +650,8 @@
- * TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384
-- */
- #define POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
-+ */
-
- /**
- * \def POLARSSL_KEY_EXCHANGE_ECDH_RSA_ENABLED
-@@ -674,8 +674,8 @@
- * TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384
-- */
- #define POLARSSL_KEY_EXCHANGE_ECDH_RSA_ENABLED
-+ */
-
- /**
- * \def POLARSSL_PK_PARSE_EC_EXTENDED
-@@ -835,8 +835,8 @@
- * \def POLARSSL_SELF_TEST
- *
- * Enable the checkup functions (*_self_test).
-- */
- #define POLARSSL_SELF_TEST
-+ */
-
- /**
- * \def POLARSSL_SSL_ALL_ALERT_MESSAGES
-@@ -1139,8 +1139,8 @@
- * Requires: POLARSSL_VERSION_C
- *
- * Comment this to disable run-time checking and save ROM space
-- */
- #define POLARSSL_VERSION_FEATURES
-+ */
-
- /**
- * \def POLARSSL_X509_ALLOW_EXTENSIONS_NON_V3
-@@ -1469,8 +1469,8 @@
- * TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384
- * TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256
- * TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256
-- */
- #define POLARSSL_CAMELLIA_C
-+ */
-
- /**
- * \def POLARSSL_CCM_C
-@@ -1497,8 +1497,8 @@
- * Requires: POLARSSL_PEM_PARSE_C
- *
- * This module is used for testing (ssl_client/server).
-- */
- #define POLARSSL_CERTS_C
-+ */
-
- /**
- * \def POLARSSL_CIPHER_C
-@@ -1537,8 +1537,8 @@
- * library/ssl_tls.c
- *
- * This module provides debugging functions.
-- */
- #define POLARSSL_DEBUG_C
-+ */
-
- /**
- * \def POLARSSL_DES_C
-@@ -1593,8 +1593,8 @@
- * ECDHE-ECDSA, ECDHE-RSA, DHE-PSK
- *
- * Requires: POLARSSL_ECP_C
-- */
- #define POLARSSL_ECDH_C
-+ */
-
- /**
- * \def POLARSSL_ECDSA_C
-@@ -1608,8 +1608,8 @@
- * ECDHE-ECDSA
- *
- * Requires: POLARSSL_ECP_C, POLARSSL_ASN1_WRITE_C, POLARSSL_ASN1_PARSE_C
-- */
- #define POLARSSL_ECDSA_C
-+ */
-
- /**
- * \def POLARSSL_ECP_C
-@@ -1621,8 +1621,8 @@
- * library/ecdsa.c
- *
- * Requires: POLARSSL_BIGNUM_C and at least one POLARSSL_ECP_DP_XXX_ENABLED
-- */
- #define POLARSSL_ECP_C
-+ */
-
- /**
- * \def POLARSSL_ENTROPY_C
-@@ -1698,8 +1698,8 @@
- * Requires: POLARSSL_MD_C
- *
- * Uncomment to enable the HMAC_DRBG random number geerator.
-- */
- #define POLARSSL_HMAC_DRBG_C
-+ */
-
- /**
- * \def POLARSSL_MD_C
-@@ -1825,8 +1825,8 @@
- * Requires: POLARSSL_HAVE_ASM
- *
- * This modules adds support for the VIA PadLock on x86.
-- */
- #define POLARSSL_PADLOCK_C
-+ */
-
- /**
- * \def POLARSSL_PBKDF2_C
-@@ -1991,8 +1991,8 @@
- * Module: library/ripemd160.c
- * Caller: library/md.c
- *
-- */
- #define POLARSSL_RIPEMD160_C
-+ */
-
- /**
- * \def POLARSSL_RSA_C
-@@ -2071,8 +2071,8 @@
- * Caller:
- *
- * Requires: POLARSSL_SSL_CACHE_C
-- */
- #define POLARSSL_SSL_CACHE_C
-+ */
-
- /**
- * \def POLARSSL_SSL_CLI_C
-@@ -2148,8 +2148,8 @@
- * Caller: library/havege.c
- *
- * This module is used by the HAVEGE random number generator.
-- */
- #define POLARSSL_TIMING_C
-+ */
-
- /**
- * \def POLARSSL_VERSION_C
-@@ -2159,8 +2159,8 @@
- * Module: library/version.c
- *
- * This module provides run-time version information.
-- */
- #define POLARSSL_VERSION_C
-+ */
-
- /**
- * \def POLARSSL_X509_USE_C
-@@ -2269,8 +2269,8 @@
- *
- * Module: library/xtea.c
- * Caller:
-- */
- #define POLARSSL_XTEA_C
-+ */
-
- /* \} name SECTION: mbed TLS modules */
-
--- /dev/null
+From 946b29e62927eadfc4e87f27b8d30e5974b78c4c Mon Sep 17 00:00:00 2001
+From: Ben Kelly <ben@benjii.net>
+Date: Mon, 6 Feb 2017 13:08:25 +0200
+Subject: [PATCH] Bugfix erase() on derived __base_associative
+
+When calling erase() on a containers derived from __base_associative
+(e.g. multimap) and providing a pair of iterators a segfault will
+occur.
+
+Example code to reproduce:
+
+ typedef std::multimap<int, int> testmap;
+ testmap t;
+ t.insert(std::pair<int, int>(1, 1));
+ t.insert(std::pair<int, int>(2, 1));
+ t.insert(std::pair<int, int>(3, 1));
+ t.erase(t.begin(), t.end());
+
+Signed-off-by: Ben Kelly <ben@benjii.net>
+---
+ include/associative_base | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/include/associative_base b/include/associative_base
+index 27ae0ef..be8b27f 100644
+--- a/include/associative_base
++++ b/include/associative_base
+@@ -200,8 +200,7 @@ public:
+ }
+ void erase(iterator first, iterator last){
+ while(first != last){
+- backing.erase(first.base_iterator());
+- ++first;
++ first = backing.erase(first.base_iterator());
+ }
+ }
+
+--
+2.7.4
+
include $(TOPDIR)/rules.mk
PKG_NAME:=zlib
-PKG_VERSION:=1.2.10
+PKG_VERSION:=1.2.11
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
-PKG_SOURCE_URL:=http://www.zlib.net @SF/libpng
-PKG_HASH:=9612bf086047078ce3a1c154fc9052113fc1a2a97234a059da17a6299bd4dd32
+PKG_SOURCE_URL:=@SF/libpng http://www.zlib.net
+PKG_HASH:=4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066
PKG_LICENSE:=Zlib
PKG_LICENSE_FILES:=README
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<buildpath>
- <buildpathentry kind="src" path="src"/>
- <buildpathentry kind="con" path="org.eclipse.dltk.launching.INTERPRETER_CONTAINER"/>
-</buildpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?>
-
-<cproject>
-<storageModule moduleId="org.eclipse.cdt.core.settings">
-<cconfiguration id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1510318341">
-<storageModule moduleId="cdtBuildSystem" version="4.0.0">
-<configuration artifactName="luci" buildProperties="" description="" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1510318341" name="Preference Configuration" parent="org.eclipse.cdt.build.core.prefbase.cfg">
-<folderInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1510318341." name="/" resourcePath="">
-<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.407447051" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
-<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.407447051.1470931541" name=""/>
-<builder id="org.eclipse.cdt.build.core.settings.default.builder.823611263" keepEnvironmentInBuildfile="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
-<tool id="org.eclipse.cdt.build.core.settings.holder.libs.1685234798" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
-<tool id="org.eclipse.cdt.build.core.settings.holder.570824141" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
-<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.491129717" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
-<listOptionValue builtIn="false" value="/usr/include/lua5.1"/>
-<listOptionValue builtIn="false" value="/usr/include"/>
-</option>
-<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.858094059" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
-</tool>
-<tool id="org.eclipse.cdt.build.core.settings.holder.344617955" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
-<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.564526987" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
-<listOptionValue builtIn="false" value="/usr/include/lua5.1"/>
-<listOptionValue builtIn="false" value="/usr/include"/>
-</option>
-<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1426860237" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
-</tool>
-<tool id="org.eclipse.cdt.build.core.settings.holder.869454750" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
-<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.838425449" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
-<listOptionValue builtIn="false" value="/usr/include/lua5.1"/>
-<listOptionValue builtIn="false" value="/usr/include"/>
-</option>
-<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1755775295" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
-</tool>
-</toolChain>
-</folderInfo>
-</configuration>
-</storageModule>
-<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1510318341" moduleId="org.eclipse.cdt.core.settings" name="Preference Configuration">
-<externalSettings/>
-<extensions>
-<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-</extensions>
-</storageModule>
-<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
-<storageModule moduleId="scannerConfiguration">
-<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
-<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="makefileGenerator">
-<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1510318341">
-<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
-<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="makefileGenerator">
-<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-</scannerConfigBuildInfo>
-</storageModule>
-</cconfiguration>
-</storageModule>
-<storageModule moduleId="cdtBuildSystem" version="4.0.0">
-<project id="luci.null.949486034" name="luci"/>
-</storageModule>
-</cproject>
+++ /dev/null
-dist/
-/host
-*.o
-*.so
-*.swp
-*.po~
-/docs
-modules/luci-base/src/po2lmo
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>luci</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
- <triggers>clean,full,incremental,</triggers>
- <arguments>
- <dictionary>
- <key>?name?</key>
- <value></value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.append_environment</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
- <value>all</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.buildArguments</key>
- <value></value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.buildCommand</key>
- <value>make</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
- <value>clean</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.contents</key>
- <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
- <value>false</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableFullBuild</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
- <value>all</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.stopOnError</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
- <value>true</value>
- </dictionary>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
- <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
- <nature>org.eclipse.cdt.core.cnature</nature>
- <nature>org.eclipse.dltk.lua.core.nature</nature>
- </natures>
-</projectDescription>
-- Additional options
-s2 = m:section(NamedSection, "backup", "service", translate("Backup options"))
+s2 = m:section(NamedSection, "global", "adblock", translate("Backup options"))
-o4 = s2:option(Flag, "enabled", translate("Enable blocklist backup"))
+o4 = s2:option(Flag, "adb_backup", translate("Enable blocklist backup"))
o4.rmempty = false
o4.default = 0
-o5 = s2:option(Value, "adb_dir", translate("Backup directory"))
+o5 = s2:option(Value, "adb_backupdir", translate("Backup directory"))
o5.rmempty = false
o5.datatype = "directory"
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: pt_BR\n"
+
+msgid ""
+"). Note that list URLs and Shallalist category selections are not "
+"configurable via Luci."
+msgstr ""
+"). Note que a lista de URL e as seleções de categoria da Shallalist não são "
+"configuráveis pelo Luci."
+
+msgid "Adblock"
+msgstr "Adblock"
+
+msgid "Available blocklist sources ("
+msgstr "Fontes de listas de bloqueio disponíveis ("
+
+msgid "Backup directory"
+msgstr "Diretório da cópia de segurança"
+
+msgid "Backup options"
+msgstr "Opções da cópia de segurança"
+
+msgid "Blocklist sources"
+msgstr "Fontes de listas de bloqueio"
+
+msgid ""
+"Configuration of the adblock package to block ad/abuse domains by using DNS."
+msgstr ""
+"Configuração do pacote adblock para bloquear, usando o DNS, domínios que "
+"distribuem propagandas abusivas."
+
+msgid "Description"
+msgstr "Descrição"
+
+msgid "Enable adblock"
+msgstr "Habilitar adblock"
+
+msgid "Enable blocklist backup"
+msgstr "Habilitar cópia de segurança da lista de bloqueio"
+
+msgid "Enable verbose debug logging"
+msgstr "Habilite registros detalhados para depuração"
+
+msgid "Enabled"
+msgstr "Habilitado"
+
+msgid "Extra options"
+msgstr "Opções adicionais"
+
+msgid ""
+"File with whitelisted hosts/domains that are allowed despite being on a "
+"blocklist."
+msgstr ""
+"Arquivo com a lista branca dos equipamentos/domínios que serão autorizados "
+"mesmo estando na lista de bloqueio."
+
+msgid "Global options"
+msgstr "Opções Globais"
+
+msgid ""
+"Options for further tweaking in case the defaults are not suitable for you."
+msgstr ""
+"Opções para aprimoramentos adicionais caso as opções padrão não sejam "
+"suficientes para você."
+
+msgid "Restrict reload trigger to certain interface(s)"
+msgstr "Restringir o gatilho de recarga para somente alguma(s) interface(s)"
+
+msgid ""
+"Space separated list of wan interfaces that trigger reload action. To "
+"disable reload trigger set it to 'false'. Default: empty"
+msgstr ""
+"Lista das interfaces WAN, separadas por espaço, que podem disparar uma ação "
+"de recarga. Para desabilitar este gatilho, defina-o como 'false'. Padrão: em "
+"branco"
+
+msgid "Whitelist file"
+msgstr "Arquivo da lista branca"
+
+msgid "see list details"
+msgstr "veja os detalhes da lista"
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"PO-Revision-Date: 2014-03-29 23:07+0200\n"
-"Last-Translator: Luiz Angelo <luizluca@gmail.com>\n"
+"Project-Id-Version: \n"
+"PO-Revision-Date: 2017-02-17 17:07-0200\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
"Language-Team: none\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-"X-Generator: Pootle 2.0.6\n"
+"X-Generator: Poedit 1.8.11\n"
+"POT-Creation-Date: \n"
msgid "AHCP Server"
msgstr "Servidor AHCP"
-#, fuzzy
msgid ""
"AHCP is an autoconfiguration protocol for IPv6 and dual-stack IPv6/IPv4 "
"networks designed to be used in place of router discovery or DHCP on "
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: pt_BR\n"
+
+msgid "\"Falloc\" is not available in all cases."
+msgstr "\"Falloc\" não está disponível em todas as classes."
+
+msgid "<abbr title=\"Distributed Hash Table\">DHT</abbr> enabled"
+msgstr ""
+"<abbr title=\"Distributed Hash Table/Tabla de disperção distribuída\">DHT</"
+"abbr> habilitado"
+
+msgid "<abbr title=\"Local Peer Discovery\">LPD</abbr> enabled"
+msgstr ""
+"<abbr title=\"Local Peer Discovery/Descoberta de Parceiros Locais\">LPD</"
+"abbr> habilitado"
+
+msgid "Additional Bt tracker enabled"
+msgstr "Rastreadores BitTorrent adicionais habilitado"
+
+msgid "Aria2"
+msgstr "Aria2"
+
+msgid "Aria2 Settings"
+msgstr "Configurações do Aria2"
+
+msgid "Aria2 Status"
+msgstr "Estado do Aria2"
+
+msgid ""
+"Aria2 is a multi-protocol & multi-source download utility, here you can "
+"configure the settings."
+msgstr ""
+"Aria2 é um utilitário de transferência multi-protocolo de múltiplas fontes, "
+"aqui você pode configurá-lo."
+
+msgid "Autosave session interval"
+msgstr "Intervalo para autossalvamento da sessão"
+
+msgid "BitTorrent Settings"
+msgstr "Configurações do BitTorrent"
+
+msgid "BitTorrent listen port"
+msgstr "Porta de escuta do BitTorrent"
+
+msgid "Collecting data..."
+msgstr "Coletando dados..."
+
+msgid "Config file directory"
+msgstr "Diretório dos arquivos de configuração"
+
+msgid "Debug"
+msgstr "Depuração"
+
+msgid "Default download directory"
+msgstr "Diretório padrão de arquivos baixados"
+
+msgid "Disk cache"
+msgstr "Cache em Disco"
+
+msgid "Enable log"
+msgstr "Habilitar registros"
+
+msgid "Enabled"
+msgstr "Habilitado"
+
+msgid "Error"
+msgstr "Erro"
+
+msgid "Extra Settings"
+msgstr "Configurações Adicionais"
+
+msgid "Falloc"
+msgstr "Falloc"
+
+msgid "Files and Locations"
+msgstr "Arquivos e Locais"
+
+msgid "Follow torrent"
+msgstr "Seguir torrent"
+
+msgid "General Settings"
+msgstr "Configurações Gerais"
+
+msgid "Generate Randomly"
+msgstr "Gerar aleatoriamente"
+
+msgid "Info"
+msgstr "Informações"
+
+msgid "List of additional Bt tracker"
+msgstr "Lista de rastreadores BitTorrent adicionais"
+
+msgid "List of extra settings"
+msgstr "Lista de configurações adicionais"
+
+msgid "Log file is in the config file dir."
+msgstr ""
+"Arquivo de registro (log) está no diretório do arquivo de configuração."
+
+msgid "Log level"
+msgstr "Nível do registro"
+
+msgid "Max concurrent downloads"
+msgstr "Número máximo de transferencias simultâneas"
+
+msgid "Max connection per server"
+msgstr "Numero máximo de conexões por servidor"
+
+msgid "Max number of peers per torrent"
+msgstr "Numero máximo de parceiros por torrent"
+
+msgid "Max number of split"
+msgstr "Numero máximo de divisões"
+
+msgid "Min split size"
+msgstr "Tamanho mínimo da divisão"
+
+msgid "No Authentication"
+msgstr "Sem Autenticação"
+
+msgid "Notice"
+msgstr "Aviso"
+
+msgid "Off"
+msgstr "Desligado"
+
+msgid "Open WebUI-Aria2"
+msgstr "Abrir WebUI-Aria2"
+
+msgid "Open YAAW"
+msgstr "Abrir YAAW"
+
+msgid "Overall download limit"
+msgstr "Limite global para baixar"
+
+msgid "Overall speed limit enabled"
+msgstr "Limite da taxa de transferência global habilitado"
+
+msgid "Overall upload limit"
+msgstr "Limite global para subir"
+
+msgid "Per task download limit"
+msgstr "Limite por tarefa para baixar"
+
+msgid "Per task speed limit enabled"
+msgstr "Limite da taxa de transferência por tarefa habilitado"
+
+msgid "Per task upload limit"
+msgstr "Limite por tarefa para subir"
+
+msgid "Prealloc"
+msgstr "Pré-alocação"
+
+msgid "Preallocation"
+msgstr "Pré-alocação"
+
+msgid "Prefix of peer ID"
+msgstr "Prefixo da identificação do paceiro"
+
+msgid "RPC Token"
+msgstr ""
+"Chave eletrônica do <abbr title=\"Remote Procedure Call/Chamada de "
+"Procedimento Remoto\">RPC</abbr>"
+
+msgid "RPC authentication method"
+msgstr ""
+"Método de autenticação do <abbr title=\"Remote Procedure Call/Chamada de "
+"Procedimento Remoto\">RPC</abbr>"
+
+msgid "RPC password"
+msgstr ""
+"Senha do <abbr title=\"Remote Procedure Call/Chamada de Procedimento Remoto"
+"\">RPC</abbr>"
+
+msgid "RPC port"
+msgstr ""
+"Porta do <abbr title=\"Remote Procedure Call/Chamada de Procedimento Remoto"
+"\">RPC</abbr>"
+
+msgid "RPC username"
+msgstr ""
+"Nome do usuario do <abbr title=\"Remote Procedure Call/Chamada de "
+"Procedimento Remoto\">RPC</abbr>"
+
+msgid "Run daemon as user"
+msgstr "Executar serviço como usuário"
+
+msgid "Sec"
+msgstr "Segurança"
+
+msgid "Task Settings"
+msgstr "Configurações das tarefas"
+
+msgid "The Aria2 service is not running."
+msgstr "O serviço Aria2 está parado."
+
+msgid "The Aria2 service is running."
+msgstr "O serviço Aria2 está em execução."
+
+msgid "Token"
+msgstr "Chave eletrônica"
+
+msgid "Trunc"
+msgstr "Truncar"
+
+msgid "Use WebSocket"
+msgstr "Use WebSockets"
+
+msgid "User agent value"
+msgstr "Valor da identificação do agente do usuário"
+
+msgid "Username & Password"
+msgstr "Usuário & Senha"
+
+msgid "View Json-RPC URL"
+msgstr "Visualizar URL do JSON-RPC"
+
+msgid "Warn"
+msgstr "Atenção"
+
+msgid "in bytes, You can append K or M."
+msgstr "em bytes. Você pode sufixar com K (quilo) ou M (mega)."
+
+msgid "in bytes/sec, You can append K or M."
+msgstr "em bytes por segundo. Você pode sufixar com K (quilo) ou M (mega)."
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"PO-Revision-Date: 2014-03-15 22:02+0200\n"
-"Last-Translator: Luiz Angelo <luizluca@gmail.com>\n"
+"Project-Id-Version: \n"
+"PO-Revision-Date: 2017-02-20 17:39-0300\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
"Language-Team: none\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-"X-Generator: Pootle 2.0.6\n"
+"X-Generator: Poedit 1.8.11\n"
+"POT-Creation-Date: \n"
msgid "A short textual description of the configured command"
msgstr "Uma pequena descrição textual do comando configurado"
msgid "Waiting for command to complete..."
msgstr "Aguardando a conclusão do comando..."
+
+#~ msgid "Command executed successfully."
+#~ msgstr "O comando executou com sucesso."
+
+#~ msgid "Command exited with status code"
+#~ msgstr "O comando encerrou com um estado de erro"
+
+#~ msgid "Download execution result"
+#~ msgstr "Baixar os resultados da execução"
+
+#~ msgid "Or display result"
+#~ msgstr "Ou mostre o resultado"
+
+#~ msgid "Standard Error"
+#~ msgstr "Saída de Erro"
+
+#~ msgid "Standard Output"
+#~ msgstr "Saída Padrão"
msgstr ""
"Project-Id-Version: luci-app-ddns 2.4.0-1\n"
"POT-Creation-Date: 2016-01-30 11:07+0100\n"
-"PO-Revision-Date: 2016-07-01 22:40-0300\n"
-"Last-Translator: Matheus Dal Mago <matheusdalmago10@gmail.com>\n"
+"PO-Revision-Date: 2017-02-20 17:41-0300\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
"Language-Team: \n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-"X-Generator: Poedit 1.8.8\n"
+"X-Generator: Poedit 1.8.11\n"
msgid "&"
msgstr "&"
msgstr "Intervalo de tentativas em Erro"
msgid "Event Network"
-msgstr ""
+msgstr "Rede de Evento"
msgid "File"
msgstr "Arquivo"
msgstr "Nenhum certificado encontrado"
msgid "No data"
-msgstr ""
+msgstr "Sem dados"
msgid "No logging"
-msgstr ""
+msgstr "Sem registros"
msgid "Non-public and by default blocked IP's"
msgstr "IPs não públicos e bloqueados por padrão"
msgid "Notice"
-msgstr ""
+msgstr "Aviso"
msgid "Number of last lines stored in log files"
msgstr "Número das últimas linhas salvas nos arquivos de log"
"Em Erro, o script irá para a execução após um número definido de tentativas"
msgid "OpenWrt Wiki"
-msgstr ""
+msgstr "Wiki do OpenWRT"
msgid "Optional Encoded Parameter"
msgstr "Parâmetro Opcionalmente Codificado"
msgstr "Opcional: Substitui [PARAMOPT] na URL de atualização"
msgid "Overview"
-msgstr ""
+msgstr "Visão Geral"
msgid "PROXY-Server"
msgstr "servidor PROXY"
msgstr "Não há serviço configurado"
msgid "Timer Settings"
-msgstr ""
+msgstr "Configurações do Controlador de Tempo"
msgid "To change global settings click here"
msgstr "Clique aqui para mudar configurações globais"
--- /dev/null
+#
+# Copyright (C) 2016 The LuCI Team <luci@lists.subsignal.org>
+#
+# This is free software, licensed under the GNU General Public License v3.
+#
+
+include $(TOPDIR)/rules.mk
+
+LUCI_TITLE:=LuCI Support for DynaPoint
+LUCI_DEPENDS:=+dynapoint
+
+PKG_NAME:=luci-app-dynapoint
+PKG_VERSION:=1.0
+PKG_RELEASE:=1
+PKG_LICENSE:=GPL-3.0+
+PKG_MAINTAINER:=Tobias Ilte <tobias.ilte@campus.tu-berlin.de>
+include ../../luci.mk
+
+# call BuildPackage - OpenWrt buildroot signature
+
--- /dev/null
+module("luci.controller.dynapoint", package.seeall)
+
+function index()
+ if not nixio.fs.access("/etc/config/dynapoint") then
+ return
+ end
+ entry({"admin", "services", "dynapoint"}, cbi("dynapoint"), _("DynaPoint"))
+end
+
--- /dev/null
+local uci = require "luci.model.uci".cursor()
+local a = require "luci.model.ipkg"
+local DISP = require "luci.dispatcher"
+
+local wlcursor = luci.model.uci.cursor_state()
+local wireless = wlcursor:get_all("wireless")
+local ifaces = {}
+
+for k, v in pairs(wireless) do
+ if v[".type"] == "wifi-iface" then
+ table.insert(ifaces, v)
+ end
+end
+
+m = Map("dynapoint")
+m:chain("wireless")
+
+s = m:section(NamedSection, "internet", "rule", translate("Configuration"), translate("Check Internet connectivity via HTTP header download"))
+
+hosts = s:option(DynamicList, "hosts", translate("List of host addresses"), translate("List of host addresses (url or IP) to track and request http headers from"))
+hosts.datatype = "string"
+
+interval = s:option(Value, "interval", translate("Test-run interval"), translate("Time interval in seconds to re-start a new test run"))
+interval.datatype = "uinteger"
+interval.default = "30"
+
+offline_treshold = s:option(Value, "offline_threshold", translate("Switch_to_offline threshold"), translate("Failure counter after how many failed download attempts, the state is considered as offline"))
+offline_treshold.datatype = "uinteger"
+offline_treshold.default = "1"
+
+add_hostname_to_ssid = s:option(Flag, "add_hostname_to_ssid", translate("Append hostname to ssid"), translate("Append the router's hostname to the SSID when connectivity check fails"))
+add_hostname_to_ssid.rmempty = false
+
+
+if (a.installed("curl") == true) then
+ use_curl = s:option(Flag, "use_curl", translate("Use curl"), translate("Use curl instead of wget for testing the connectivity."))
+ use_curl.rmempty = false
+
+ curl_interface = s:option(Value, "curl_interface", translate("Used interface"), translate("Which interface should curl use. (Use ifconfig to find out)"))
+ curl_interface.datatype = "string"
+ curl_interface:depends("use_curl","1")
+ curl_interface.placeholder = "eth0"
+else
+ use_curl = s:option(Flag, "use_curl", translate("Use curl instead of wget"), translate("Curl is currently not installed.")
+ .." Please install the package in the "
+ ..[[<a href="]] .. DISP.build_url("admin", "system", "packages")
+ .. "?display=available&query=curl"..[[">]]
+ .. "Software Section" .. [[</a>]]
+ .. "."
+ )
+ use_curl.rmempty = false
+ use_curl.template = "dynapoint/cbi_checkbox"
+end
+
+m1 = Map("wireless", "DynaPoint", translate("Dynamic Access Point Manager"))
+
+aps = m1:section(TypedSection, "wifi-iface", translate("List of Wireless Virtual Interfaces (wVIF)"))
+aps.addremove = false
+aps.anonymous = true
+aps.template = "cbi/tblsection"
+
+status = aps:option(DummyValue, "disabled", translate("WiFi Status"))
+status.template = "dynapoint/cbi_color"
+
+function status.cfgvalue(self,section)
+ local val = m1:get(section, "disabled")
+ if val == "1" then return translate("Disabled") end
+ if (val == nil or val == "0") then return translate("Enabled") end
+ return val
+end
+
+device = aps:option(DummyValue, "device", translate("Device"))
+function device.cfgvalue(self,section)
+ local dev = m1:get(section, "device")
+ local val = m1:get(dev, "hwmode")
+ if val == "11a" then return dev .. " (5 GHz)" else
+ return dev .. " (2,4 GHz)"
+ end
+ return val
+end
+
+
+
+
+
+mode = aps:option(DummyValue, "mode", translate("Mode"))
+
+ssid = aps:option(DummyValue, "ssid", translate("SSID"))
+
+
+action = aps:option(ListValue, "dynapoint_rule", translate("Activate this wVIF if status is:"))
+action.widget="select"
+action:value("internet",translate("Online"))
+action:value("!internet",translate("Offline"))
+action:value("",translate("Not used by DynaPoint"))
+action.default = ""
+
+return m1,m
+
--- /dev/null
+<%+cbi/valueheader%>
+
+<input class="cbi-input-checkbox" disabled data-update="click change" type="checkbox" id="cbid.dynapoint.internet.use_curl" name="cbid.dynapoint.internet.use_curl" value="1" />
+
+
+<%+cbi/valuefooter%>
--- /dev/null
+<%+cbi/valueheader%>
+
+
+<%
+if (self:cfgvalue(section) == translate("Disabled")) then
+%>
+
+<span id="<%=cbid%>.disabled" style="background-color:red;"><%=self:cfgvalue(section)%></span>
+
+<%
+else
+%>
+<span id="<%=cbid%>.disabled" style="background-color:lime;"><%=self:cfgvalue(section)%></span>
+<%
+end
+%>
+
+<%+cbi/valuefooter%>
--- /dev/null
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"PO-Revision-Date: 2016-08-31 15:51+0200\n"
+"Language-Team: German\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+msgid "Activate this wVIF if status is:"
+msgstr "Aktiviere diese drahtlose Schnittstelle wenn:"
+
+msgid "Append hostname to ssid"
+msgstr "Anfügen des hostname zur SSID"
+
+msgid "Append the router's hostname to the SSID when connectivity check fails"
+msgstr ""
+"Fügt den hostname des routers zur SSID an, wenn die Verbindungsüberprüfung "
+"fehl schlägt"
+
+msgid "Check Internet connectivity via HTTP header download"
+msgstr "Testen der Internetverfügbarkeit via HTTP header download"
+
+msgid "Configuration"
+msgstr "Konfiguration"
+
+msgid "Curl is currently not installed."
+msgstr "Curl ist momentan nicht installiert."
+
+msgid "Device"
+msgstr "Gerät"
+
+msgid "Disabled"
+msgstr "Deaktiviert"
+
+msgid "DynaPoint"
+msgstr ""
+
+msgid "Dynamic Access Point Manager"
+msgstr ""
+
+msgid "Enabled"
+msgstr "Aktiviert"
+
+msgid ""
+"Failure counter after how many failed download attempts, the state is "
+"considered as offline"
+msgstr ""
+"Anzahl der fehlgeschlagenen Downloadversuche, nach denen die Verbindung als offline angesehen wird"
+
+msgid "List of Wireless Virtual Interfaces (wVIF)"
+msgstr "Liste der Drahtlosen virtuellen Schnittstellen"
+
+msgid "List of host addresses"
+msgstr "Liste der Zieladressen"
+
+msgid ""
+"List of host addresses (url or IP) to track and request http headers from"
+msgstr "Liste der Zieladressen (URL oder IP) für den HTTP header download"
+
+msgid "Mode"
+msgstr "Modus"
+
+msgid "Not used by DynaPoint"
+msgstr "Nicht von DynaPoint benutzt"
+
+msgid "Offline"
+msgstr "Offline"
+
+msgid "Online"
+msgstr "Online"
+
+msgid "SSID"
+msgstr ""
+
+msgid "Switch_to_offline threshold"
+msgstr "Offline-Schwelle"
+
+msgid "Test-run interval"
+msgstr "Testlaufintervall"
+
+msgid "Time interval in seconds to re-start a new test run"
+msgstr "Zeitintervall in Sekunden für einen Testlauf"
+
+msgid "Use curl"
+msgstr "Curl benutzen"
+
+msgid "Use curl instead of wget"
+msgstr "Curl anstatt wget benutzen"
+
+msgid "Use curl instead of wget for testing the connectivity."
+msgstr "Curl anstatt wget benutzen, um die Internetverbindung zu überprüfen."
+
+msgid "Used interface"
+msgstr "Benutztes interface"
+
+msgid "Which interface should curl use. (Use ifconfig to find out)"
+msgstr ""
+"Welches Interface von curl benutzt werden soll. (ifconfig benutzen, um das "
+"herauszufinden"
+
+msgid "WiFi Status"
+msgstr ""
+
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: INAGAKI Hiroshi <musashino.open@gmail.com>\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+"Language: ja\n"
+
+msgid "Activate this wVIF if status is:"
+msgstr "wVIFを有効化する接続ステータス:"
+
+msgid "Append hostname to ssid"
+msgstr "ホスト名をSSIDに追加する"
+
+msgid "Append the router's hostname to the SSID when connectivity check fails"
+msgstr "接続性のチェックが失敗した場合、ルーターのホスト名をSSIDに追加します。"
+
+msgid "Check Internet connectivity via HTTP header download"
+msgstr ""
+"HTTP ヘッダーのダウンロードを通して、インターネットの接続性をチェックします。"
+
+msgid "Configuration"
+msgstr "設定"
+
+msgid "Curl is currently not installed."
+msgstr "curl は現在インストールされていません。"
+
+msgid "Device"
+msgstr "デバイス"
+
+msgid "Disabled"
+msgstr "無効"
+
+msgid "DynaPoint"
+msgstr "DynaPoint"
+
+msgid "Dynamic Access Point Manager"
+msgstr "ダイナミック アクセスポイント マネージャー"
+
+msgid "Enabled"
+msgstr "有効"
+
+msgid ""
+"Failure counter after how many failed download attempts, the state is "
+"considered as offline"
+msgstr "状態をオフラインと見なすまでの、ダウンロード試行の失敗回数です。"
+
+msgid "List of Wireless Virtual Interfaces (wVIF)"
+msgstr "無線仮想インターフェース (wVIF) のリスト"
+
+msgid "List of host addresses"
+msgstr "ホストアドレスのリスト"
+
+msgid ""
+"List of host addresses (url or IP) to track and request http headers from"
+msgstr ""
+"HTTP ヘッダーの追跡およびリクエストを行う、ホスト アドレス(URLまたはIP)のリ"
+"ストです。"
+
+msgid "Mode"
+msgstr "モード"
+
+msgid "Not used by DynaPoint"
+msgstr "DynaPointで使用しない"
+
+msgid "Offline"
+msgstr "オフライン"
+
+msgid "Online"
+msgstr "オンライン"
+
+msgid "SSID"
+msgstr "SSID"
+
+msgid "Switch_to_offline threshold"
+msgstr "オフライン化閾値"
+
+msgid "Test-run interval"
+msgstr "テスト実行間隔"
+
+msgid "Time interval in seconds to re-start a new test run"
+msgstr "接続性テストを再実行するまでの時間間隔(秒)です。"
+
+msgid "Use curl"
+msgstr "curl を使用する"
+
+msgid "Use curl instead of wget"
+msgstr "wget の代わりに curl を使用する"
+
+msgid "Use curl instead of wget for testing the connectivity."
+msgstr "接続性のテストの際、wget の代わりに curl を使用します。"
+
+msgid "Used interface"
+msgstr "使用するインターフェース"
+
+msgid "Which interface should curl use. (Use ifconfig to find out)"
+msgstr ""
+"curl が使用するインターフェースです。ifconfigを使用してインターフェース名を確"
+"認します。"
+
+msgid "WiFi Status"
+msgstr "無線ステータス"
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: pt_BR\n"
+
+msgid "Activate this wVIF if status is:"
+msgstr "Aivar este wVIF se o estado for:"
+
+msgid "Append hostname to ssid"
+msgstr "Sufixar o nome do equipamento ao SSID"
+
+msgid "Append the router's hostname to the SSID when connectivity check fails"
+msgstr ""
+"Sufixar o nome do roteador ao SSID quando a verificação da conectividade "
+"falhar"
+
+msgid "Check Internet connectivity via HTTP header download"
+msgstr "Cerifique a conectividade com a internet baixando o cabeçalho HTTP "
+
+msgid "Configuration"
+msgstr "Configuração"
+
+msgid "Curl is currently not installed."
+msgstr "O cURL não está instalado."
+
+msgid "Device"
+msgstr "Dispositivo"
+
+msgid "Disabled"
+msgstr "Desabilitado"
+
+msgid "DynaPoint"
+msgstr "DynaPoint"
+
+msgid "Dynamic Access Point Manager"
+msgstr "Gerenciamento do Ponto de Acesso Dinâmico"
+
+msgid "Enabled"
+msgstr "Habilitado"
+
+msgid ""
+"Failure counter after how many failed download attempts, the state is "
+"considered as offline"
+msgstr "Numero de falhar para considerar como inalcançável"
+
+msgid "List of Wireless Virtual Interfaces (wVIF)"
+msgstr "Lista de Interfaces Virtuais Wireless (wVIF)"
+
+msgid "List of host addresses"
+msgstr "Lista de endereços dos equipamentos"
+
+msgid ""
+"List of host addresses (url or IP) to track and request http headers from"
+msgstr ""
+"Lista de endereços dos equipamentos (URL ou endereço IP) para requisitar "
+"cabeçalhos HTTP"
+
+msgid "Mode"
+msgstr "Modo"
+
+msgid "Not used by DynaPoint"
+msgstr "Não usado pelo DynaPoint"
+
+msgid "Offline"
+msgstr "Desconectado"
+
+msgid "Online"
+msgstr "Conectado"
+
+msgid "SSID"
+msgstr "SSID"
+
+msgid "Switch_to_offline threshold"
+msgstr "Limiar para mudar para desconectado"
+
+msgid "Test-run interval"
+msgstr "Intervalo para execução do teste"
+
+msgid "Time interval in seconds to re-start a new test run"
+msgstr "Intervalo, em segundos, para reiniciar um nova execução do teste"
+
+msgid "Use curl"
+msgstr "Usar cURL"
+
+msgid "Use curl instead of wget"
+msgstr "Usar cURL ao invés do wget"
+
+msgid "Use curl instead of wget for testing the connectivity."
+msgstr "Usar cURL ao invés do wget para testar a conectividade."
+
+msgid "Used interface"
+msgstr "Dispositivos usadas"
+
+msgid "Which interface should curl use. (Use ifconfig to find out)"
+msgstr "Qual dispositivo o cURL deve usar. (Use ifconfig para listá-las)"
+
+msgid "WiFi Status"
+msgstr "Estado da WiFi"
--- /dev/null
+msgid ""
+msgstr "Content-Type: text/plain; charset=UTF-8"
+
+msgid "Activate this wVIF if status is:"
+msgstr ""
+
+msgid "Append hostname to ssid"
+msgstr ""
+
+msgid "Append the router's hostname to the SSID when connectivity check fails"
+msgstr ""
+
+msgid "Check Internet connectivity via HTTP header download"
+msgstr ""
+
+msgid "Configuration"
+msgstr ""
+
+msgid "Curl is currently not installed."
+msgstr ""
+
+msgid "Device"
+msgstr ""
+
+msgid "Disabled"
+msgstr ""
+
+msgid "DynaPoint"
+msgstr ""
+
+msgid "Dynamic Access Point Manager"
+msgstr ""
+
+msgid "Enabled"
+msgstr ""
+
+msgid ""
+"Failure counter after how many failed download attempts, the state is "
+"considered as offline"
+msgstr ""
+
+msgid "List of Wireless Virtual Interfaces (wVIF)"
+msgstr ""
+
+msgid "List of host addresses"
+msgstr ""
+
+msgid ""
+"List of host addresses (url or IP) to track and request http headers from"
+msgstr ""
+
+msgid "Mode"
+msgstr ""
+
+msgid "Not used by DynaPoint"
+msgstr ""
+
+msgid "Offline"
+msgstr ""
+
+msgid "Online"
+msgstr ""
+
+msgid "SSID"
+msgstr ""
+
+msgid "Switch_to_offline threshold"
+msgstr ""
+
+msgid "Test-run interval"
+msgstr ""
+
+msgid "Time interval in seconds to re-start a new test run"
+msgstr ""
+
+msgid "Use curl"
+msgstr ""
+
+msgid "Use curl instead of wget"
+msgstr ""
+
+msgid "Use curl instead of wget for testing the connectivity."
+msgstr ""
+
+msgid "Used interface"
+msgstr ""
+
+msgid "Which interface should curl use. (Use ifconfig to find out)"
+msgstr ""
+
+msgid "WiFi Status"
+msgstr ""
--- /dev/null
+#!/bin/sh
+
+# needed for "Save and Apply" to restart dynapoint
+uci -q batch <<-EOF >/dev/null
+ delete ucitrack.@dynapoint[-1]
+ add ucitrack dynapoint
+ set ucitrack.@dynapoint[-1].init="dynapoint"
+ commit dynapoint
+EOF
+
+rm -f /tmp/luci-indexcache
+exit 0
+
translate("Source IP address"),
translate("Only match incoming traffic from this IP or range."))
o.rmempty = true
-o.datatype = "neg(ip4addr)"
+o.datatype = "neg(ipmask4)"
o.placeholder = translate("any")
luci.sys.net.ipv4_hints(function(ip, name)
o.rmempty = true
-o.datatype = "neg(ip4addr)"
+o.datatype = "neg(ipmask4)"
o.placeholder = translate("any")
o = s:option(Value, "dest_ip", translate("Internal IP address"),
translate("Redirect matched incoming traffic to the specified \
internal host"))
-o.datatype = "ip4addr"
+o.datatype = "ipmask4"
luci.sys.net.ipv4_hints(function(ip, name)
o:value(ip, "%s (%s)" %{ ip, name })
o = s:option(Value, "src_ip", translate("Source IP address"))
o.rmempty = true
- o.datatype = "neg(ipaddr)"
+ o.datatype = "neg(ipmask4)"
o.placeholder = translate("any")
luci.sys.net.ipv4_hints(function(ip, name)
o = s:option(Value, "dest_ip", translate("Destination IP address"))
- o.datatype = "neg(ip4addr)"
+ o.datatype = "neg(ipmask4)"
luci.sys.net.ipv4_hints(function(ip, name)
o:value(ip, "%s (%s)" %{ ip, name })
o = s:option(Value, "src_ip", translate("Source address"))
- o.datatype = "neg(ipaddr)"
+ o.datatype = "neg(ipmask)"
o.placeholder = translate("any")
luci.sys.net.ipv4_hints(function(ip, name)
o = s:option(Value, "dest_ip", translate("Destination address"))
- o.datatype = "neg(ipaddr)"
+ o.datatype = "neg(ipmask)"
o.placeholder = translate("any")
luci.sys.net.ipv4_hints(function(ip, name)
translate("Restrict Masquerading to given source subnets"))
msrc.optional = true
-msrc.datatype = "list(neg(or(uciname,hostname,ip4addr)))"
+msrc.datatype = "list(neg(or(uciname,hostname,ipmask4)))"
msrc.placeholder = "0.0.0.0/0"
msrc:depends("family", "")
msrc:depends("family", "ipv4")
translate("Restrict Masquerading to given destination subnets"))
mdest.optional = true
-mdest.datatype = "list(neg(or(uciname,hostname,ip4addr)))"
+mdest.datatype = "list(neg(or(uciname,hostname,ipmask4)))"
mdest.placeholder = "0.0.0.0/0"
mdest:depends("family", "")
mdest:depends("family", "ipv4")
s:option(Flag, "syn_flood", translate("Enable SYN-flood protection"))
o = s:option(Flag, "drop_invalid", translate("Drop invalid packets"))
-o.default = o.enabled
p = {
s:option(ListValue, "input", translate("Input")),
--- /dev/null
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-30 17:00+0200\n"
+"PO-Revision-Date: 2012-11-14 17:32+0200\n"
+"Last-Translator: Weongyo Jeong <weongyo@gmail.com>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: ko\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+"X-Generator: Pootle 2.0.6\n"
+
+msgid "%s in %s"
+msgstr ""
+
+msgid "%s%s with %s"
+msgstr "%s%s ,%s"
+
+msgid "%s, %s in %s"
+msgstr ""
+
+msgid "(Unnamed Entry)"
+msgstr ""
+
+msgid "(Unnamed Rule)"
+msgstr ""
+
+msgid "(Unnamed SNAT)"
+msgstr ""
+
+msgid "<var>%d</var> pkts. per <var>%s</var>"
+msgstr ""
+
+msgid "<var>%d</var> pkts. per <var>%s</var>, burst <var>%d</var> pkts."
+msgstr ""
+
+msgid "<var>%s</var> and limit to %s"
+msgstr ""
+
+msgid "Action"
+msgstr ""
+
+msgid "Add"
+msgstr ""
+
+msgid "Add and edit..."
+msgstr "추가 후 수정..."
+
+msgid "Advanced Settings"
+msgstr ""
+
+msgid "Allow forward from <em>source zones</em>:"
+msgstr "<em>Source zone</em> 로부터의 forward 허용:"
+
+msgid "Allow forward to <em>destination zones</em>:"
+msgstr "<em>Destination zone</em> 으로 forward 허용:"
+
+msgid "Any"
+msgstr ""
+
+msgid "Covered networks"
+msgstr ""
+
+msgid "Custom Rules"
+msgstr "Custom Rule"
+
+msgid ""
+"Custom rules allow you to execute arbritary iptables commands which are not "
+"otherwise covered by the firewall framework. The commands are executed after "
+"each firewall restart, right after the default ruleset has been loaded."
+msgstr ""
+"Custom rule 은 방화벽 UI 로 해결이 되지 않는 임의의 iptables 명령을 실행할 "
+"수 있도록 합니다. 입력된 명령어들은 매 방화벽 재시작시 실행되는데 default "
+"ruleset 이 load 된 후 시점입니다."
+
+msgid "Destination IP address"
+msgstr "Destination IP 주소"
+
+msgid "Destination address"
+msgstr "Destination 주소"
+
+msgid "Destination port"
+msgstr ""
+
+msgid "Destination zone"
+msgstr ""
+
+msgid "Do not rewrite"
+msgstr ""
+
+msgid "Drop invalid packets"
+msgstr ""
+
+msgid "Enable"
+msgstr "활성화"
+
+msgid "Enable NAT Loopback"
+msgstr "NAT Loopback 활성화"
+
+msgid "Enable SYN-flood protection"
+msgstr "SYN-flood protection 활성화"
+
+msgid "Enable logging on this zone"
+msgstr "zone 의 logging 활성화"
+
+msgid "External IP address"
+msgstr "외부 IP 주소"
+
+msgid "External port"
+msgstr "외부 port"
+
+msgid "External zone"
+msgstr "외부 zone"
+
+msgid "Extra arguments"
+msgstr "추가 argument"
+
+msgid "Firewall"
+msgstr "방화벽"
+
+msgid "Firewall - Custom Rules"
+msgstr "방화벽 - Custom Rules"
+
+msgid "Firewall - Port Forwards"
+msgstr "방화벽 - Port Forwards"
+
+msgid "Firewall - Traffic Rules"
+msgstr "방화벽 - Traffic Rules"
+
+msgid "Firewall - Zone Settings"
+msgstr "방화벽 - Zone 설정"
+
+msgid "Force connection tracking"
+msgstr ""
+
+msgid "Forward"
+msgstr ""
+
+msgid "Forward to"
+msgstr ""
+
+msgid "Friday"
+msgstr "금요일"
+
+msgid "From %s in %s"
+msgstr ""
+
+msgid "From %s in %s with source %s"
+msgstr ""
+
+msgid "From %s in %s with source %s and %s"
+msgstr ""
+
+msgid "General Settings"
+msgstr ""
+
+msgid "IPv4"
+msgstr ""
+
+msgid "IPv4 and IPv6"
+msgstr ""
+
+msgid "IPv4 only"
+msgstr ""
+
+msgid "IPv6"
+msgstr ""
+
+msgid "IPv6 only"
+msgstr ""
+
+msgid "Input"
+msgstr ""
+
+msgid "Inter-Zone Forwarding"
+msgstr ""
+
+msgid "Internal IP address"
+msgstr "내부 IP 주소"
+
+msgid "Internal port"
+msgstr "내부 port"
+
+msgid "Internal zone"
+msgstr "내부 zone"
+
+msgid "Limit log messages"
+msgstr ""
+
+msgid "MSS clamping"
+msgstr ""
+
+msgid "Masquerading"
+msgstr ""
+
+msgid "Match"
+msgstr ""
+
+msgid "Match ICMP type"
+msgstr ""
+
+msgid "Match forwarded traffic to the given destination port or port range."
+msgstr ""
+
+msgid ""
+"Match incoming traffic directed at the given destination port or port range "
+"on this host"
+msgstr ""
+
+msgid ""
+"Match incoming traffic originating from the given source port or port range "
+"on the client host."
+msgstr ""
+
+msgid "Monday"
+msgstr "월요일"
+
+msgid "Month Days"
+msgstr ""
+
+msgid "Name"
+msgstr "이름"
+
+msgid "New SNAT rule"
+msgstr "새로운 SNAT rule"
+
+msgid "New forward rule"
+msgstr "새로운 forward rule"
+
+msgid "New input rule"
+msgstr "새로운 input rule"
+
+msgid "New port forward"
+msgstr "새로운 port forward"
+
+msgid "New source NAT"
+msgstr "새로운 source NAT"
+
+msgid "Only match incoming traffic directed at the given IP address."
+msgstr ""
+
+msgid "Only match incoming traffic from these MACs."
+msgstr ""
+
+msgid "Only match incoming traffic from this IP or range."
+msgstr ""
+
+msgid ""
+"Only match incoming traffic originating from the given source port or port "
+"range on the client host"
+msgstr ""
+
+msgid "Open ports on router"
+msgstr ""
+
+msgid "Other..."
+msgstr ""
+
+msgid "Output"
+msgstr ""
+
+msgid "Passes additional arguments to iptables. Use with care!"
+msgstr "iptables 명령에 추가 인자들을 더합니다. 조심해 사용하세요!"
+
+msgid "Port Forwards"
+msgstr "Port Forward"
+
+msgid ""
+"Port forwarding allows remote computers on the Internet to connect to a "
+"specific computer or service within the private LAN."
+msgstr ""
+"Port forwarding 기능은 인터넷 상의 원격 컴퓨터가 내부 LAN 에 속한 특정 컴퓨터"
+"나 서비스에 접속할 수 있도록 합니다."
+
+msgid "Protocol"
+msgstr ""
+
+msgid ""
+"Redirect matched incoming traffic to the given port on the internal host"
+msgstr ""
+
+msgid "Redirect matched incoming traffic to the specified internal host"
+msgstr ""
+
+msgid "Restart Firewall"
+msgstr ""
+
+msgid "Restrict Masquerading to given destination subnets"
+msgstr "주어진 destination subnet 으로 Masquerading 제한"
+
+msgid "Restrict Masquerading to given source subnets"
+msgstr "주어진 source subnet 으로 Masquerading 제한"
+
+msgid "Restrict to address family"
+msgstr "Address family 제한"
+
+msgid "Rewrite matched traffic to the given address."
+msgstr ""
+
+msgid ""
+"Rewrite matched traffic to the given source port. May be left empty to only "
+"rewrite the IP address."
+msgstr ""
+
+msgid "Rewrite to source %s"
+msgstr ""
+
+msgid "Rewrite to source %s, %s"
+msgstr ""
+
+msgid "SNAT IP address"
+msgstr ""
+
+msgid "SNAT port"
+msgstr ""
+
+msgid "Saturday"
+msgstr "토요일"
+
+msgid "Source IP address"
+msgstr "Source IP 주소"
+
+msgid "Source MAC address"
+msgstr "Source MAC 주소"
+
+msgid "Source NAT"
+msgstr ""
+
+msgid ""
+"Source NAT is a specific form of masquerading which allows fine grained "
+"control over the source IP used for outgoing traffic, for example to map "
+"multiple WAN addresses to internal subnets."
+msgstr ""
+"Source NAT 기능은 masquerading 의 한 형태로써 outgoing 트래픽이 사용할 "
+"source IP 를 세밀하게 제어할 수 있습니다. 예를 들어 다수의 WAN 주소들을 내"
+"부 subnet 에 매핑(mapping) 할 경우 사용됩니다."
+
+msgid "Source address"
+msgstr "Source 주소"
+
+msgid "Source port"
+msgstr ""
+
+msgid "Source zone"
+msgstr ""
+
+msgid "Start Date (yyyy-mm-dd)"
+msgstr "시작 날짜 (yyyy-mm-dd)"
+
+msgid "Start Time (hh:mm:ss)"
+msgstr "시작 시간 (hh:mm:ss)"
+
+msgid "Stop Date (yyyy-mm-dd)"
+msgstr "종료 날짜 (yyyy-mm-dd)"
+
+msgid "Stop Time (hh:mm:ss)"
+msgstr "종료 시간 (hh:mm:ss)"
+
+msgid "Sunday"
+msgstr "일요일"
+
+msgid ""
+"The firewall creates zones over your network interfaces to control network "
+"traffic flow."
+msgstr ""
+"방화벽 기능을 이용하여 네트워크 인터페이스와 연결된 zone 을 생성할 수 있고 이"
+"를 이용하여 네트워크 traffic flow 를 제어할 수 있습니다."
+
+msgid ""
+"The options below control the forwarding policies between this zone (%s) and "
+"other zones. <em>Destination zones</em> cover forwarded traffic "
+"<strong>originating from %q</strong>. <em>Source zones</em> match forwarded "
+"traffic from other zones <strong>targeted at %q</strong>. The forwarding "
+"rule is <em>unidirectional</em>, e.g. a forward from lan to wan does "
+"<em>not</em> imply a permission to forward from wan to lan as well."
+msgstr ""
+"이 zone (%s) 과 다른 zone 들 사이의 forwarding 정책을 제어하는 옵션들입니다. "
+"<em>Destination zones</em> 은 <strong>%q 에서 출발한 </strong> forward "
+"traffic 을 뜻하고, <em>Source zones</em> 은 다른 zone 들에서 <strong>%q 로 전"
+"달되는</strong> forward traffic 을 뜻합니다. Forwarding rule 은 "
+"<em>unidirectional</em> 인데, 예를 들어 LAN 에서 WAN 으로의 forward 규칙이 "
+"WAN 에서 LAN 으로의 forward 를 허락하는 것이 아닙니다."
+
+msgid ""
+"This page allows you to change advanced properties of the port forwarding "
+"entry. In most cases there is no need to modify those settings."
+msgstr ""
+"이 메뉴에서는 port forwarding 의 고급 설정 정보를 변경할 수 있습니다. 대부분"
+"의 경우 이 설정을 수정할 일이 없습니다."
+
+msgid ""
+"This page allows you to change advanced properties of the traffic rule "
+"entry, such as matched source and destination hosts."
+msgstr ""
+"이 메뉴에서는 traffic rule 항목의 고급 설정, 예를 들어 source host 와 "
+"destination host 매칭, 을 변경할 수 있습니다."
+
+#, fuzzy
+msgid ""
+"This section defines common properties of %q. The <em>input</em> and "
+"<em>output</em> options set the default policies for traffic entering and "
+"leaving this zone while the <em>forward</em> option describes the policy for "
+"forwarded traffic between different networks within the zone. <em>Covered "
+"networks</em> specifies which available networks are members of this zone."
+msgstr ""
+"이 섹션은 %q 의 공통 속성을 설정할 수 있습니다. <em>input</em> 과 "
+"<em>output</em> 옵션은 이 zone 으로 전달되어 들오거나 나가는 트래픽에 대한 기"
+"본 정책을 뜻합니다. <em>forward</em> 옵션은 zone 내에서 다른 네트워크들 사이"
+"를 오가는 forward traffic 에 대한 정책을 뜻합니다. <em>Covered networks</em> "
+"에서는 zone 의 영향을 받을 네트워크들을 지정할 수 있습니다."
+
+msgid "Thursday"
+msgstr "목요일"
+
+msgid "Time in UTC"
+msgstr "UTC 기준시"
+
+msgid "To %s at %s on <var>this device</var>"
+msgstr ""
+
+msgid "To %s in %s"
+msgstr ""
+
+msgid "To %s on <var>this device</var>"
+msgstr ""
+
+msgid "To %s, %s in %s"
+msgstr ""
+
+msgid "To source IP"
+msgstr ""
+
+msgid "To source port"
+msgstr ""
+
+msgid "Traffic Rules"
+msgstr "Traffic Rule"
+
+msgid ""
+"Traffic rules define policies for packets traveling between different zones, "
+"for example to reject traffic between certain hosts or to open WAN ports on "
+"the router."
+msgstr ""
+"Traffic rule 은 서로 다른 zone 사이를 오가는 패킷들에 대한 정책을 정의합니"
+"다. 예를 들어 특정 host 들 사이의 트래픽을 차단하거나 공유기의 WAN port 를 "
+"open 할때 사용됩니다."
+
+msgid "Tuesday"
+msgstr "화요일"
+
+msgid "Via %s"
+msgstr ""
+
+msgid "Via %s at %s"
+msgstr ""
+
+msgid "Wednesday"
+msgstr "수요일"
+
+msgid "Week Days"
+msgstr "주일"
+
+msgid ""
+"You may specify multiple by selecting \"-- custom --\" and then entering "
+"protocols separated by space."
+msgstr ""
+
+msgid "Zone %q"
+msgstr ""
+
+msgid "Zone ⇒ Forwardings"
+msgstr ""
+
+msgid "Zones"
+msgstr "Zone 내역"
+
+msgid "accept"
+msgstr ""
+
+msgid "any"
+msgstr ""
+
+msgid "any host"
+msgstr ""
+
+msgid "any router IP"
+msgstr ""
+
+msgid "any zone"
+msgstr ""
+
+msgid "don't track"
+msgstr ""
+
+msgid "drop"
+msgstr ""
+
+msgid "reject"
+msgstr ""
+
+msgid "traffic"
+msgstr ""
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
+"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-03-30 17:00+0200\n"
-"PO-Revision-Date: 2014-06-21 19:03+0200\n"
-"Last-Translator: Éder <eder.grigorio@openmailbox.org>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
+"PO-Revision-Date: 2017-02-20 17:43-0300\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-"X-Generator: Pootle 2.0.6\n"
+"X-Generator: Poedit 1.8.11\n"
+"Language-Team: \n"
msgid "%s in %s"
msgstr "%s in %s"
msgstr "Encaminhar para"
msgid "Friday"
-msgstr ""
+msgstr "Sexta-feira"
msgid "From %s in %s"
msgstr "Vindo de %s em %s"
"equipamento cliente."
msgid "Monday"
-msgstr ""
+msgstr "Segunda-Feira"
msgid "Month Days"
-msgstr ""
+msgstr "Dias do mês"
msgid "Name"
msgstr "Nome"
msgstr "Redireciona tráfego entrante para o computador interno especificado"
msgid "Restart Firewall"
-msgstr ""
+msgstr "Reiniciar o Firewall"
msgid "Restrict Masquerading to given destination subnets"
msgstr "Restringe o mascaramento para uma subrede de destino específica"
msgstr "Porta da SNAT"
msgid "Saturday"
-msgstr ""
+msgstr "Sábado"
msgid "Source IP address"
msgstr "Endereço IP de origem"
msgstr "Zona de origem"
msgid "Start Date (yyyy-mm-dd)"
-msgstr ""
+msgstr "Dia inicial (aaaa-mm-dd)"
msgid "Start Time (hh:mm:ss)"
-msgstr ""
+msgstr "Hora inicial (hh:mm:ss)"
msgid "Stop Date (yyyy-mm-dd)"
-msgstr ""
+msgstr "Dia final (aaaa-mm-dd)"
msgid "Stop Time (hh:mm:ss)"
-msgstr ""
+msgstr "Hora final (hh:mm:ss)"
msgid "Sunday"
-msgstr ""
+msgstr "Domingo"
msgid ""
"The firewall creates zones over your network interfaces to control network "
"Esta página permite que você mude propriedades avançadas da entrada da regra "
"de tráfego, como os equipamentos de origem e destino."
-#, fuzzy
msgid ""
"This section defines common properties of %q. The <em>input</em> and "
"<em>output</em> options set the default policies for traffic entering and "
"zona."
msgid "Thursday"
-msgstr ""
+msgstr "Quita-feira"
msgid "Time in UTC"
-msgstr ""
+msgstr "Hora em UTC"
msgid "To %s at %s on <var>this device</var>"
msgstr "Para %s em %s <var>neste dispositivo</var>"
"ou abrir portas WAN no roteador."
msgid "Tuesday"
-msgstr ""
+msgstr "Terça-feira"
msgid "Via %s"
msgstr "Via %s"
msgstr "Via %s at %s"
msgid "Wednesday"
-msgstr ""
+msgstr "Quarta-feira"
msgid "Week Days"
-msgstr ""
+msgstr "Dias da semana"
msgid ""
"You may specify multiple by selecting \"-- custom --\" and then entering "
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: pt_BR\n"
+
+msgid ""
+"Allow SPA clients to request access to services through an iptables firewall "
+"instead of just to it."
+msgstr ""
+"Permitir que clientes SPA requeiram acesso a serviços através de um firewall "
+"iptables ao invés de apenas fazê-lo."
+
+msgid "Allow SPA clients to request forwarding destination by DNS name."
+msgstr ""
+"Permitir que clientes SPA requeiram encaminhamento de destinos por nome DNS."
+
+msgid "Base 64 key"
+msgstr "Chave em formato base64"
+
+msgid ""
+"Define a set of ports and protocols (tcp or udp) that will be opened if a "
+"valid knock sequence is seen. If this entry is not set, fwknopd will attempt "
+"to honor any proto/port request specified in the SPA data (unless of it "
+"matches any “RESTRICT_PORTS” entries). Multiple entries are comma-separated."
+msgstr ""
+"Define um conjunto de porta e protocolos (TCP ou UDP) que serão abertos se "
+"uma sequência de batidas for observada. Se esta entrada não estiver "
+"definida, fwknopd irá tentar honrar qualquer requisição de protocolo/porta "
+"especificada nos dados SPA (a não ser se casar com qualquer entrada de "
+"\"RESTRICT_PORTS\"). Múltiplas entradas serão separadas por vírgula."
+
+msgid ""
+"Define the length of time access will be granted by fwknopd through the "
+"firewall after a valid knock sequence from a source IP address. If "
+"“FW_ACCESS_TIMEOUT” is not set then the default timeout of 30 seconds will "
+"automatically be set."
+msgstr ""
+"Define a duração do tempo de acesso que será concedido pelo fwknopd através "
+"do firewall depois de uma sequência de batidas válida de um endereço IP. Se "
+"“FW_ACCESS_TIMEOUT” não estiver definido, o valor padrão será de 30 "
+"segundos. "
+
+msgid ""
+"Define the symmetric key used for decrypting an incoming SPA packet that is "
+"encrypted by the fwknop client with Rijndael."
+msgstr ""
+"Define a chave simétrica usada para decifrar um pacote SPA entrante que foi "
+"cifrado pelo cliente fwknop com o algoritmo Rijndael."
+
+msgid "Enable Uci/Luci control"
+msgstr "Habilitar o controle UCI/Luci"
+
+msgid "Enable config overwrite"
+msgstr "Habilitar a sobrescrita da configuração"
+
+msgid "Firewall Knock Daemon"
+msgstr "Servidor do Firwall Knock"
+
+msgid "Firewall Knock Operator"
+msgstr "Operador do Firewall Knock"
+
+msgid ""
+"Force all SPA packets to contain a real IP address within the encrypted "
+"data. This makes it impossible to use the -s command line argument on the "
+"fwknop client command line, so either -R has to be used to automatically "
+"resolve the external address (if the client behind a NAT) or the client must "
+"know the external IP and set it via the -a argument."
+msgstr ""
+"Forçar que todos os pacotes SPA contenham um endereço IP real dentro do "
+"pacote cifrado. Isto torna impossível o uso do argumento de linha de comando "
+"'-s' no cliente fwknop. Desta forma, ou o argumento '-R' deve ser usada para "
+"resolver os endereços externos automaticamente (se o cliente estiver atrás "
+"de uma NAT) ou o ciente deve conhecer o seu endereço IP externo e defini-lo "
+"através do argumento '-a'."
+
+msgid ""
+"Maximum age in seconds that an SPA packet will be accepted. defaults to 120 "
+"seconds"
+msgstr ""
+"Idade máxima, em segundos, que um pacote SPA será aceito. Padrão é 120 "
+"segundos."
+
+msgid "Normal Key"
+msgstr "Chave Normal"
+
+msgid "Specify the ethernet interface on which fwknopd will sniff packets."
+msgstr ""
+"Especifica o dispositivo ethernet no qual o fwknopd irá observar os pacotes."
+
+msgid "The base64 hmac key"
+msgstr "A chave de autenticação HMAC em formato base64"
+
+msgid "Use ANY for any source ip"
+msgstr "Use \"ANY\" para qualquer endereço IP de origem"
+
+msgid ""
+"When unchecked, the config files in /etc/fwknopd will be used as is, "
+"ignoring any settings here."
+msgstr ""
+"Quando desmarcado, os arquivos de configuração em /etc/fwknopd serão usados "
+"como estão, ignorando qualquer ajustes feitos aqui."
+
+msgid "access.conf stanzas"
+msgstr "Estâncias do access.conf"
+
+msgid "fwknopd.conf config options"
+msgstr "Opções do fwknopd.conf"
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
+"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-10-11 00:23+0200\n"
-"PO-Revision-Date: 2014-03-17 10:01+0200\n"
-"Last-Translator: Luiz Angelo <luizluca@gmail.com>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
+"PO-Revision-Date: 2017-02-20 18:00-0300\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-"X-Generator: Pootle 2.0.6\n"
+"X-Generator: Poedit 1.8.11\n"
+"Language-Team: \n"
msgid "Activate or deactivate IPv6 config globally."
msgstr "Habilita e desabilita a configuração IPv6 globalmente."
msgid "Mesh Wizard"
msgstr "Assistente de Configuração da Rede em Malha"
-#, fuzzy
msgid ""
"Note: this will set up this interface for mesh operation, i.e. add it to "
"zone 'freifunk' and enable olsr."
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: pt_BR\n"
+
+msgid "Allow ringbuffer to exceed limit by this amount"
+msgstr "Permitir que o buffer em anel exceda o limite por essa quantidade"
+
+msgid "Ask for username and password on connect"
+msgstr "Pergunte por um usuário e senha na conexão"
+
+msgid "Authentication required"
+msgstr "Requer autenticação"
+
+msgid "Auto"
+msgstr "Automático"
+
+msgid "Automatic disabling of MJPEG mode"
+msgstr "Desativação automática do modo MJPEG"
+
+msgid "Blink"
+msgstr "Pisca"
+
+msgid "Check to save the stream to an mjpeg file"
+msgstr "Marque para salvar o fluxo em um arquivo MJPEG"
+
+msgid "Command to run"
+msgstr "Comando para executar:"
+
+msgid "Device"
+msgstr "Dispositivo"
+
+msgid "Do not initalize dynctrls of Linux-UVC driver"
+msgstr "Não inicie o dynctrls do driver do Linux-UVC"
+
+msgid "Don't initalize dynctrls"
+msgstr "Não inicia o dynctrls"
+
+msgid "Drop frames smaller then this limit"
+msgstr "Descarte quadros menores que este limite"
+
+msgid "Enable MJPG-streamer"
+msgstr "Ativa o MJPG-streamer"
+
+msgid "Enable YUYV format"
+msgstr "Ativar Formato YUYV"
+
+msgid "Enabled"
+msgstr "Habilitado"
+
+msgid "Exceed"
+msgstr "Ultrapassado"
+
+msgid ""
+"Execute command after saving picture. Mjpg-streamer parse the filename as "
+"first parameter to your script."
+msgstr ""
+"Execute o comando depois de salvar a imagem. Mjpg-streamer passa o nome do "
+"arquivo como primeiro parâmetro para o comando."
+
+msgid "File input"
+msgstr "Entrada do arquivo"
+
+msgid "File output"
+msgstr "Saída do arquivo"
+
+msgid "Folder"
+msgstr "Pasta"
+
+msgid "Folder that contains webpages"
+msgstr "Pasta que contém páginas web"
+
+msgid "Frames per second"
+msgstr "Quadros por segundos"
+
+msgid "General"
+msgstr "Geral"
+
+msgid "HTTP output"
+msgstr "Saída HTTP"
+
+msgid "Input plugin"
+msgstr "Plugins de entrada"
+
+msgid "Interval between saving pictures"
+msgstr "Intervalo entre o salvamento das imagens"
+
+msgid "JPEG compression quality"
+msgstr "Qualidade da compressão JPEG"
+
+msgid "Led control"
+msgstr "Controle de LED"
+
+msgid "MJPG-streamer"
+msgstr "MJPG-streamer"
+
+msgid "Max. number of pictures to hold"
+msgstr "Número máximo de imagens a serem mantidas"
+
+msgid "Mjpeg output"
+msgstr "Saída Mjpeg"
+
+msgid "Off"
+msgstr "Desligado"
+
+msgid "On"
+msgstr "Ligado"
+
+msgid "Output plugin"
+msgstr "Plugin de saída"
+
+msgid "Password"
+msgstr "Senha"
+
+msgid "Plugin settings"
+msgstr "Configurações do Plugin"
+
+msgid "Port"
+msgstr "Porta"
+
+msgid "Resolution"
+msgstr "Resolução"
+
+msgid "Ring buffer size"
+msgstr "Tamanho do buffer em anel"
+
+msgid "Set folder to save pictures"
+msgstr "Definir pasta para salvas as imagens"
+
+msgid "Set the inteval in millisecond"
+msgstr "Defina o intervalo em milisegundos"
+
+msgid ""
+"Set the minimum size if the webcam produces small-sized garbage frames. May "
+"happen under low light conditions"
+msgstr ""
+"Defina o tamanho mínimo se a webcam produz quadros lixo de tamanho pequeno. "
+"Pode acontecer sob condições de pouca luz"
+
+msgid ""
+"Set the quality in percent. This setting activates YUYV format, disables "
+"MJPEG"
+msgstr ""
+"Defina a qualidade em porcentagem. Esta definição ativa o formato YUYV, "
+"desativa MJPEG"
+
+msgid "TCP port for this HTTP server"
+msgstr "Porta TCP para este servidor HTTP"
+
+msgid "UVC input"
+msgstr "Dispositivo UVC de entrada"
+
+msgid "Username"
+msgstr "Usuário"
+
+msgid "WWW folder"
+msgstr "Pasta WWW"
+
+msgid ""
+"mjpg streamer is a streaming application for Linux-UVC compatible webcams"
+msgstr ""
+"Mjpg streamer é uma aplicação de streaming para webcams compatíveis com o "
+"Linux-UVC"
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
+"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-06-10 03:41+0200\n"
-"PO-Revision-Date: 2014-06-21 19:36+0200\n"
-"Last-Translator: Éder <eder.grigorio@openmailbox.org>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
+"PO-Revision-Date: 2017-02-20 18:01-0300\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-"X-Generator: Pootle 2.0.6\n"
+"X-Generator: Poedit 1.8.11\n"
+"Language-Team: \n"
msgid "Active MID announcements"
msgstr ""
"Somente pode ser um endereço IPv4 ou IPv6 válidos ou um endereço 'padrão'"
# 20140621: edersg: tradução
-#, fuzzy
msgid "Can only be a valid IPv6 address or 'default'"
msgstr ""
"Somente pode ser um endereço IPv4 ou IPv6 válidos ou um endereço 'padrão'"
"Validade do <abbr title=\"Host and network association, Associação de "
"equipamentos e redes\">HNA</abbr>"
-#, fuzzy
msgid "HNA6 Announcements"
msgstr ""
"Anúncios do <abbr title=\"Host and network association, Associação de "
"Equipamentos em uma rede roteada por OLSR podem anunciar conectividade para "
"redes externas usando mensagens HNA."
-#, fuzzy
msgid ""
"Hosts in a OLSR routed network can announce connecitivity to external "
"networks using HNA6 messages."
"> reduzir LQ para todos os nós nesta interface em 20%: padrão 0.8"
# 20140621: edersg: tradução
-#, fuzzy
msgid ""
"Multiply routes with the factor given here. Allowed values are between 0.01 "
"and 1.0. It is only used when LQ-Level is greater than 0. Examples:<br /"
"OLSR - Anúncios <abbr title=\"Host and network association, Associação de "
"equipamentos e redes\">HNA</abbr>"
-#, fuzzy
msgid "OLSR - HNA6-Announcements"
msgstr ""
"OLSR - Anúncios <abbr title=\"Host and network association, Associação de "
"durante o funcionamento do olsrd. O padrão é 0.0.0.0, que faz com que o "
"endereço da primeira interface seja usado."
-#, fuzzy
msgid ""
"Sets the main IP (originator ip) of the router. This IP will NEVER change "
"during the uptime of olsrd. Default is ::, which triggers usage of the IP of "
"and network association, Associação de equipamentos e redes\">HNA</abbr> "
"local de 0.0.0.0/0, ::ffff:0:0/96 ou 2000::/3. O padrão é \"ambos\"."
-#, fuzzy
msgid ""
"Which kind of uplink is exported to the other mesh nodes. An uplink is "
"detected by looking for a local HNA6 ::ffff:0:0/96 or 2000::/3. Default "
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
+"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-06-10 03:41+0200\n"
-"PO-Revision-Date: 2014-03-29 23:19+0200\n"
-"Last-Translator: Luiz Angelo <luizluca@gmail.com>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
+"PO-Revision-Date: 2017-02-20 18:04-0300\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-"X-Generator: Pootle 2.0.6\n"
+"X-Generator: Poedit 1.8.11\n"
+"Language-Team: \n"
msgid "%s"
msgstr "%s"
msgstr "Não registar a data/hora"
msgid "Don't pull routes automatically"
-msgstr ""
+msgstr "Não puxe as rotas automaticamente"
msgid "Don't re-read key on restart"
msgstr "Não reler a chave entre os reinícios"
msgstr "Diretório temporário para arquivo de retorno de conexão-cliente"
msgid "The highest supported TLS version"
-msgstr ""
+msgstr "A mais alta versão suporta do TLS"
msgid "The key direction for 'tls-auth' and 'secret' options"
-msgstr ""
+msgstr "A direção da chave para as opções 'tls-auth' e 'secret'"
msgid "The lowest supported TLS version"
-msgstr ""
+msgstr "A mais baixa versão suporta do TLS"
msgid "Timeframe for key exchange"
msgstr "Janela temporal para troca de chaves"
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: pt_BR\n"
+
+msgid ""
+"A URL to be displayed in the error page that users will see if access to an "
+"untrusted page is denied."
+msgstr ""
+"A URL a ser exibida na página de erro que os usuários verão se o acesso a "
+"uma página não confiável é negado."
+
+msgid ""
+"A URL to documentation about the local Privoxy setup, configuration or "
+"policies."
+msgstr ""
+"A URL para a documentação sobre o Privoxy local, configuração ou políticas."
+
+msgid "A directory where Privoxy can create temporary files."
+msgstr "Um diretório onde Privoxy pode criar arquivos temporários."
+
+msgid "Access Control"
+msgstr "Controle de Acesso"
+
+msgid "Actions that are applied to all sites and maybe overruled later on."
+msgstr ""
+"Ações que são aplicadas a todos as páginas e talvez descartado mais tarde."
+
+msgid "An alternative directory where the templates are loaded from."
+msgstr "Um diretório alternativo de onde os modelos são carregados."
+
+msgid "An email address to reach the Privoxy administrator."
+msgstr "Um endereço de e-mail para alcançar o administrador do Privoxy."
+
+msgid ""
+"Assumed server-side keep-alive timeout (in seconds) if not specified by the "
+"server."
+msgstr ""
+"Tempo limite, em segundos, da manutenção da conexão (keep-alive) do servidor "
+"se não for especificado."
+
+msgid "Boot delay"
+msgstr "Atraso de iniciação"
+
+msgid "CGI user interface"
+msgstr "Interface de usuário CGI"
+
+msgid "Common Log Format"
+msgstr "Formato de registros (log) comum"
+
+msgid ""
+"Configure here the routing of HTTP requests through a chain of multiple "
+"proxies. Note that parent proxies can severely decrease your privacy level. "
+"Also specified here are SOCKS proxies."
+msgstr ""
+"Configure aqui o encaminhamento de pedidos HTTP através de uma cadeia de "
+"múltiplos proxies. Note-se que proxies pai pode diminuir muito o nível de "
+"privacidade. Também serão aceitos proxies SOCKS."
+
+msgid "Debug GIF de-animation"
+msgstr "Depurar de-animação GIF"
+
+msgid "Debug force feature"
+msgstr "Recurso de depuração forçado"
+
+msgid "Debug redirects"
+msgstr "Redirecionamentos de depuração"
+
+msgid "Debug regular expression filters"
+msgstr "Depuração de filtros de expressão regular"
+
+msgid "Delay (in seconds) during system boot before Privoxy start"
+msgstr ""
+"Atraso (em segundos) durante a inicialização do sistema antes do Privoxy "
+"iniciar"
+
+msgid "Directory does not exist!"
+msgstr "O diretório não existe!"
+
+msgid "Disabled == Transparent Proxy Mode"
+msgstr "Desativado == Modo Proxy Transparente"
+
+msgid "Documentation"
+msgstr "Documentação"
+
+msgid "During delay ifup-events are not monitored !"
+msgstr "Durante a espera, eventos ifup não serão monitorados!"
+
+msgid "Enable proxy authentication forwarding"
+msgstr "Habilitar o encaminhamento de autenticação de proxy"
+
+msgid ""
+"Enable/Disable autostart of Privoxy on system startup and interface events"
+msgstr ""
+"Ativar/Desativar a iniciação automática do Privoxy junto com a iniciação do "
+"sistema ou eventos de interface"
+
+msgid "Enable/Disable filtering when Privoxy starts."
+msgstr "Ativar / Desativar filtragem quando Privoxy iniciar."
+
+msgid "Enabled"
+msgstr "Habilitado"
+
+msgid ""
+"Enabling this option is NOT recommended if there is no parent proxy that "
+"requires authentication!"
+msgstr ""
+"A ativação dessa opção não é recomendado se não houver nenhum proxy pai que "
+"requer autenticação!"
+
+msgid "File '%s' not found inside Configuration Directory"
+msgstr "O arquivo '%s' não foi encontrado dentro do Diretório de Configuração"
+
+msgid "File not found or empty"
+msgstr "Arquivo não encontrado ou vazio"
+
+msgid "Files and Directories"
+msgstr "Arquivos e diretórios"
+
+msgid "For help use link at the relevant option"
+msgstr "Para ajuda, use o link na respectiva opção"
+
+msgid "Forwarding"
+msgstr "Encaminhando"
+
+msgid ""
+"If enabled, Privoxy hides the 'go there anyway' link. The user obviously "
+"should not be able to bypass any blocks."
+msgstr ""
+"Se ativado, Privoxy esconde o link \"ir lá de qualquer maneira\". O usuário, "
+"obviamente, não deve ser capaz de contornar qualquer bloqueio."
+
+msgid ""
+"If you intend to operate Privoxy for more users than just yourself, it might "
+"be a good idea to let them know how to reach you, what you block and why you "
+"do that, your policies, etc."
+msgstr ""
+"Se você pretende operar Privoxy para mais usuários do que apenas a si mesmo, "
+"pode ser uma boa ideia para que eles saibam como falar com você, o que você "
+"bloquear e por que você faz isso, as suas políticas, etc."
+
+msgid "Invalid email address"
+msgstr "Endereço de e-mail inválido"
+
+msgid "It is NOT recommended for the casual user."
+msgstr "Não é recomendado para o usuário casual."
+
+msgid "Location of the Privoxy User Manual."
+msgstr "Localização do Manual do Usuário do Privoxy."
+
+msgid "Log File Viewer"
+msgstr "Visualizador de arquivo de registros (log)"
+
+msgid "Log all data read from the network"
+msgstr "Registrar todos os dados lidos da rede"
+
+msgid "Log all data written to the network"
+msgstr "Registrar todos os dados gravados na rede"
+
+msgid "Log the applying actions"
+msgstr "Registrar as ações aplicadas"
+
+msgid ""
+"Log the destination for each request Privoxy let through. See also 'Debug "
+"1024'."
+msgstr ""
+"Registrar o destino para cada pedido que o Privoxy deixou passar. Consulte "
+"também 'Debug 1024'."
+
+msgid ""
+"Log the destination for requests Privoxy didn't let through, and the reason "
+"why."
+msgstr ""
+"Registrar o destino para os pedidos que o Privoxy não deixou passar, e a "
+"razão pela qual."
+
+msgid "Logging"
+msgstr "Registrando (logging)"
+
+msgid "Main actions file"
+msgstr "Arquivo principal de ações"
+
+msgid "Mandatory Input: No Data given!"
+msgstr "Entrada obrigatória: Dados não foram informados!"
+
+msgid "Mandatory Input: No Directory given!"
+msgstr "Entrada obrigatória: Nenhum Diretório foi informado!"
+
+msgid "Mandatory Input: No File given!"
+msgstr "Entrada obrigatória: Nenhum Arquivo foi informado!"
+
+msgid "Mandatory Input: No Port given!"
+msgstr "Entrada obrigatória: Nenhuma Porta foi informado!"
+
+msgid "Mandatory Input: No files given!"
+msgstr "Entrada obrigatória: Nenhum Arquivo foi informado!"
+
+msgid "Mandatory Input: No valid IPv4 address or host given!"
+msgstr ""
+"Entrada obrigatória: Nenhum endereço IPv4 ou nome de equipamento válido foi "
+"fornecido!"
+
+msgid "Mandatory Input: No valid IPv6 address given!"
+msgstr "Entrada obrigatória: Nenhum endereço IPv6 válido foi informado!"
+
+msgid "Mandatory Input: No valid Port given!"
+msgstr "Entrada obrigatória: Nenhuma porta válida foi informada!"
+
+msgid "Maximum number of client connections that will be served."
+msgstr "O número máximo de conexões de cliente que será aceito."
+
+msgid "Maximum size (in KB) of the buffer for content filtering."
+msgstr "Tamanho máximo (em KB) do buffer para filtragem de conteúdo."
+
+msgid "Miscellaneous"
+msgstr "Diversos"
+
+msgid "NOT installed"
+msgstr "NÃO instalado"
+
+msgid "No trailing '/', please."
+msgstr "Sem '/' final, por favor."
+
+msgid "Non-fatal errors - *we highly recommended enabling this*"
+msgstr "Erros não fatais - *é altamente recomendado ativar isto*"
+
+msgid ""
+"Number of seconds after which a socket times out if no data is received."
+msgstr ""
+"Número de segundos após o qual uma conexão expira se nenhum dado for "
+"recebido."
+
+msgid ""
+"Number of seconds after which an open connection will no longer be reused."
+msgstr ""
+"Número de segundos após o qual uma conexão aberta deixará de ser reutilizada."
+
+msgid ""
+"Only when using 'external filters', Privoxy has to create temporary files."
+msgstr ""
+"Somente quando for usado os \"filtros externos\". O Privoxy tem que criar "
+"arquivos temporários."
+
+msgid "Please install current version !"
+msgstr "Por favor, instale a versão atual!"
+
+msgid "Please press [Read] button"
+msgstr "Por favor, pressione o botão [Ler]"
+
+msgid "Please read Privoxy manual for details!"
+msgstr "Por favor, leia o manual do Privoxy para mais detalhes!"
+
+msgid "Please update to the current version!"
+msgstr "Por favor, atualize para a versão atual!"
+
+msgid "Privoxy WEB proxy"
+msgstr "Privoxy Web Proxy"
+
+msgid ""
+"Privoxy can (and normally does) use a number of other files for additional "
+"configuration, help and logging. This section of the configuration file "
+"tells Privoxy where to find those other files."
+msgstr ""
+"Privoxy pode (e normalmente o faz) utilizar uma série de outros arquivos de "
+"configuração, ajuda e de registros. Esta seção do arquivo de configuração "
+"informa o Privoxy onde encontrar os outros arquivos."
+
+msgid ""
+"Privoxy is a non-caching web proxy with advanced filtering capabilities for "
+"enhancing privacy, modifying web page data and HTTP headers, controlling "
+"access, and removing ads and other obnoxious Internet junk."
+msgstr ""
+"Privoxy é um proxy web sem cache com capacidades avançadas de filtragem para "
+"aumentar a privacidade, modificar dados de páginas web e cabeçalhos HTTP, "
+"controlar o acesso e remover anúncios e outras porcarias detestável da "
+"Internet."
+
+msgid "Read / Reread log file"
+msgstr "Ler / Ler novamente o arquivo de registros (log)"
+
+msgid "Show I/O status"
+msgstr "Mostrar status de Entrada/Saída"
+
+msgid "Show each connection status"
+msgstr "Mostrar cada estado de conexão"
+
+msgid "Show header parsing"
+msgstr "Mostrar análise do cabeçalho"
+
+msgid "Software package '%s' is not installed."
+msgstr "O pacote de software '%s' não está instalado."
+
+msgid "Software package '%s' is outdated."
+msgstr "O pacote '%' está desatualizado."
+
+msgid "Start"
+msgstr "Iniciar"
+
+msgid "Start / Stop"
+msgstr "Iniciar / Parar"
+
+msgid "Start/Stop Privoxy WEB Proxy"
+msgstr "Inicia / Para o Privoxy Web Proxy"
+
+msgid "Startup banner and warnings."
+msgstr "Mensagens e avisos iniciais."
+
+msgid "Syntax:"
+msgstr "Sintaxe:"
+
+msgid "Syntax: Client header names delimited by spaces."
+msgstr "Sintaxe: nomes de cabeçalho do cliente delimitados por espaços."
+
+msgid "Syntax: target_pattern http_parent[:port]"
+msgstr "Sintaxe: padrão_alvo http_superior[:porta]"
+
+msgid "Syntax: target_pattern socks_proxy[:port] http_parent[:port]"
+msgstr "Sintaxe: padrão_alvo proxy_socks[:porta] http_superior[:porta]"
+
+msgid "System"
+msgstr "Sistema"
+
+msgid ""
+"The actions file(s) to use. Multiple actionsfile lines are permitted, and "
+"are in fact recommended!"
+msgstr ""
+"O(s) arquivo(s) ações a ser usado. Várias linhas no arquivo são permitidas, "
+"e são, de fato, recomendadas!"
+
+msgid ""
+"The address and TCP port on which Privoxy will listen for client requests."
+msgstr ""
+"O endereço e porta TCP em que Privoxy vai esperar por pedidos dos clientes."
+
+msgid ""
+"The compression level that is passed to the zlib library when compressing "
+"buffered content."
+msgstr ""
+"O nível de compressão que é passada para a biblioteca zlib ao comprimir o "
+"conteúdo em buffer."
+
+msgid ""
+"The directory where all logging takes place (i.e. where the logfile is "
+"located)."
+msgstr ""
+"O diretório onde todos os registros ocorrem (ex: onde o arquivo de log está "
+"localizado)."
+
+msgid "The directory where the other configuration files are located."
+msgstr "O diretório onde os outros arquivos de configuração estão localizados."
+
+msgid ""
+"The filter files contain content modification rules that use regular "
+"expressions."
+msgstr ""
+"Os arquivos de filtro contêm regras de modificação de conteúdo que usam "
+"expressões regulares."
+
+msgid "The hostname shown on the CGI pages."
+msgstr "O nome da máquina mostrado nas páginas de CGI."
+
+msgid "The log file to use. File name, relative to log directory."
+msgstr ""
+"O arquivo de registros a ser usado. O nome do arquivo, relativo ao diretório "
+"de log."
+
+msgid "The order in which client headers are sorted before forwarding them."
+msgstr ""
+"A ordem em que os cabeçalhos dos clientes são classificados antes de "
+"encaminhá-los."
+
+msgid ""
+"The status code Privoxy returns for pages blocked with +handle-as-empty-"
+"document."
+msgstr ""
+"O código de status Privoxy retorna para páginas bloqueadas com +handle-as-"
+"empty-document."
+
+msgid ""
+"The trust mechanism is an experimental feature for building white-lists and "
+"should be used with care."
+msgstr ""
+"O mecanismo de confiança é um recurso experimental para a construção de "
+"listas de destinos confiáveis e deve ser usado com cuidado."
+
+msgid ""
+"The value of this option only matters if the experimental trust mechanism "
+"has been activated."
+msgstr ""
+"O valor desta opção só importa se o mecanismo de confiança experimental foi "
+"ativado."
+
+msgid ""
+"This option is only there for debugging purposes. It will drastically reduce "
+"performance."
+msgstr ""
+"Esta opção só está lá para fins de depuração. Ele irá reduzir drasticamente "
+"o desempenho."
+
+msgid ""
+"This option will be removed in future releases as it has been obsoleted by "
+"the more general header taggers."
+msgstr ""
+"Esta opção será removida em versões futuras, uma vez que ficou obsoleta "
+"pelos marcadores de cabeçalho mais genéricos."
+
+msgid ""
+"This tab controls the security-relevant aspects of Privoxy's configuration."
+msgstr ""
+"Esta guia controla os aspectos da configuração do Privoxy relevantes para a "
+"segurança."
+
+msgid ""
+"Through which SOCKS proxy (and optionally to which parent HTTP proxy) "
+"specific requests should be routed."
+msgstr ""
+"Através de qual Proxy SOCKS (e, opcionalmente, para o qual proxy HTTP "
+"superior) pedidos específicos devem ser encaminhados."
+
+msgid "To which parent HTTP proxy specific requests should be routed."
+msgstr ""
+"Para qual proxy HTTP superior os pedidos específicos devem ser encaminhados."
+
+msgid "User customizations"
+msgstr "Personalizações do usuário"
+
+msgid "Value is not a number"
+msgstr "O valor não é um número"
+
+msgid "Value not between 0 and 300"
+msgstr "Valor não está entre 0 e 300"
+
+msgid "Value not between 0 and 9"
+msgstr "Valor não está entre 0 e 9"
+
+msgid "Value not between 1 and 4096"
+msgstr "Valor não entre 1 e 4096"
+
+msgid "Value not greater 0 or empty"
+msgstr "Valor não é maior que 0 ou vazio"
+
+msgid "Value range 1 to 4096, no entry defaults to 4096"
+msgstr "Faixa do valor de 1 até 4096. Se vazio, será 4096"
+
+msgid "Version"
+msgstr "Versão"
+
+msgid "Version Information"
+msgstr "Informação da Versão"
+
+msgid "Whether intercepted requests should be treated as valid."
+msgstr "Se as solicitações interceptados deve ser tratadas como válidas."
+
+msgid ""
+"Whether or not Privoxy recognizes special HTTP headers to change toggle "
+"state."
+msgstr ""
+"Se o Privoxy deve reconhecer cabeçalhos HTTP especiais para mudar de "
+"alternância do estado."
+
+msgid "Whether or not buffered content is compressed before delivery."
+msgstr "Se o conteúdo em buffer é comprimido antes da entrega."
+
+msgid ""
+"Whether or not outgoing connections that have been kept alive should be "
+"shared between different incoming connections."
+msgstr ""
+"Se as conexões de saída que foram mantidas vivas devem ser compartilhadas "
+"entre diferentes conexões de entrada."
+
+msgid "Whether or not pipelined requests should be served."
+msgstr "Se os pedidos de pipeline deve ser aceitos."
+
+msgid "Whether or not proxy authentication through Privoxy should work."
+msgstr "Se a autenticação de proxy através do Privoxy deve funcionar."
+
+msgid "Whether or not the web-based actions file editor may be used."
+msgstr "Se o editor de arquivos de ações baseadas na web deve ser utilizado."
+
+msgid "Whether or not the web-based toggle feature may be used."
+msgstr "Se deve ser usado o recurso de alternância baseado na web."
+
+msgid "Whether requests to Privoxy's CGI pages can be blocked or redirected."
+msgstr ""
+"Se as solicitações para páginas CGI do Privoxy podem ser bloqueadas ou "
+"redirecionadas."
+
+msgid ""
+"Whether the CGI interface should stay compatible with broken HTTP clients."
+msgstr ""
+"Se a interface CGI deve se manter compatível com clientes HTTP mal "
+"implementados."
+
+msgid "Whether to run only one server thread."
+msgstr "Se deseja executar o servidor como apenas uma thread."
+
+msgid "Who can access what."
+msgstr "Quem pode acessar o quê."
+
+msgid "installed"
+msgstr "instalado"
+
+msgid "or higher"
+msgstr "ou maior"
+
+msgid "required"
+msgstr "necessário"
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: pt_BR\n"
+
+msgid ""
+"'AUTO' selects the highest protocol version that client and server support."
+msgstr "'AUTO' seleciona a versão mais alto protocolo que o cliente e o servidor suportar."
+
+msgid ""
+"'Hostname:Port' or 'IPv4:Port' or '[IPv6]:Port' Radicale should listen on"
+msgstr "'NomeDoEquipamento:porta' ou 'IPv4:Porta' ou '[IPv6]:Porta' em que o Radicale deve escutar"
+
+msgid "AUTO"
+msgstr "AUTO"
+
+msgid "Access-Control-Allow-Headers"
+msgstr "Access-Control-Allow-Headers"
+
+msgid "Access-Control-Allow-Methods"
+msgstr "Access-Control-Allow-Methods"
+
+msgid "Access-Control-Allow-Origin"
+msgstr "Access-Control-Allow-Origin"
+
+msgid "Access-Control-Expose-Headers"
+msgstr "Access-Control-Expose-Headers"
+
+msgid "Additional HTTP headers"
+msgstr "Additional HTTP headers"
+
+msgid "Address:Port"
+msgstr "Endereço: Porta"
+
+#, fuzzy
+msgid "Authentication"
+msgstr "Autenticação"
+
+msgid ""
+"Authentication login is matched against the 'user' key, and collection's "
+"path is matched against the 'collection' key."
+msgstr "O nome do usuário na autenticação é comparado com a chave do 'user', e o caminho da coleção é comparado com a chave 'coleção'."
+
+msgid "Authentication method"
+msgstr "Método de autenticação"
+
+msgid "Authentication method to allow access to Radicale server."
+msgstr "Método de autenticação para permitir o acesso ao servidor Radicale."
+
+msgid "Auto-start"
+msgstr "Iniciar automaticamente"
+
+msgid "Boot delay"
+msgstr "Atraso na iniciação"
+
+msgid "CalDAV/CardDAV"
+msgstr "CalDAV/CardDAV"
+
+msgid ""
+"Calendars and address books are available for both local and remote access, "
+"possibly limited through authentication policies."
+msgstr "Agendas e contados estão disponíveis tanto para acesso local como remoto, possivelmente limitado através das políticas de autenticação."
+
+msgid "Certificate file"
+msgstr "Arquivo do certificado"
+
+msgid ""
+"Change here the encoding Radicale will use instead of 'UTF-8' for responses "
+"to the client and/or to store data inside collections."
+msgstr "Mude aqui a codificação que o Radicale usará em vez de 'UTF-8' para respostas a clientes ou para armazenar dados dentro das coleções."
+
+msgid "Ciphers"
+msgstr "Cifras"
+
+msgid "Console Log level"
+msgstr "Nível de detalhamento dos registros (log)"
+
+msgid "Control the access to data collections."
+msgstr "Controlar o acesso às coleções de dados."
+
+#, fuzzy
+msgid "Critical"
+msgstr "Crítico"
+
+msgid ""
+"Cross-origin resource sharing (CORS) is a mechanism that allows restricted "
+"resources (e.g. fonts, JavaScript, etc.) on a web page to be requested from "
+"another domain outside the domain from which the resource originated."
+msgstr "O compartilhamento de recursos de origem cruzada (CORS) é um mecanismo que permite que os recursos de acesso restrito (por exemplo, fontes, JavaScript, etc.) em uma página web ser solicitado de outro domínio fora do domínio a partir do qual o recurso foi originado."
+
+msgid "Custom"
+msgstr "Personalizadas"
+
+msgid "Database"
+msgstr "Banco de Dados"
+
+#, fuzzy
+msgid "Debug"
+msgstr "Depuração"
+
+msgid "Delay (in seconds) during system boot before Radicale start"
+msgstr "Atraso (em segundos) durante a inicialização do sistema antes do Radicale iniciar"
+
+#, fuzzy
+msgid "Directory"
+msgstr "Diretório"
+
+msgid "Directory not exists/found !"
+msgstr "O diretório não foi encontrado!"
+
+msgid "Directory required !"
+msgstr "O diretório é necessário!"
+
+msgid "Directory where the rotating log-files are stored"
+msgstr "O diretório onde os registros(log) rotativos são armazenados"
+
+msgid "During delay ifup-events are not monitored !"
+msgstr "Durante a espera, eventos ifup não serão monitorados!"
+
+msgid "Enable HTTPS"
+msgstr "Ativar HTTPS"
+
+msgid ""
+"Enable/Disable auto-start of Radicale on system start-up and interface events"
+msgstr "Ativar/Desativar iniciação automática do Radicale na iniciação do sistema e em eventos de interface"
+
+msgid "Encoding"
+msgstr "Codificação"
+
+msgid "Encoding for responding requests."
+msgstr "Codificação para responder pedidos."
+
+msgid "Encoding for storing local collections."
+msgstr "Codificação para armazenar coleções locais."
+
+msgid "Encryption method"
+msgstr "Método de criptografia"
+
+#, fuzzy
+msgid "Error"
+msgstr "Erro"
+
+msgid "File '%s' not found !"
+msgstr "Arquivo '%s' não encontrado!"
+
+msgid "File Log level"
+msgstr "Nível de detalhamento dos registos(log) em arquivos"
+
+msgid "File not found !"
+msgstr "Arquivo não encontrado!"
+
+msgid "File-system"
+msgstr "Sistema de arquivos"
+
+msgid ""
+"For example, for the 'user' key, '.+' means 'authenticated user' and '.*' "
+"means 'anybody' (including anonymous users)."
+msgstr "Por exemplo, para a chave 'user', '.+' Significa 'usuário autenticado' e '.*' Significa 'qualquer um' (incluindo usuários anônimos)."
+
+msgid "Full access for Owner only"
+msgstr "Acesso completo somente para o proprietário"
+
+msgid "Full access for authenticated Users"
+msgstr "Acesso completo para usuários autenticados"
+
+msgid "Full access for everybody (including anonymous)"
+msgstr "Acesso completo para todos (incluindo anônimo)"
+
+msgid "Full path and file name of certificate"
+msgstr "Caminho completo e nome do arquivo do certificado"
+
+msgid "Full path and file name of private key"
+msgstr "Caminho e arquivo nome completo da chave privada"
+
+#, fuzzy
+msgid "Info"
+msgstr "Informações"
+
+msgid "Keep in mind to use the correct hashing algorithm !"
+msgstr "Fique atento para usar o algoritmo de resumo digital(hash) correto!"
+
+msgid "Leading or ending slashes are trimmed from collection's path."
+msgstr "Barras inicias e finais serão removidas do caminho da coleção."
+
+msgid "Log-backup Count"
+msgstr "Contagem Registro(log) de Backup"
+
+msgid "Log-file Viewer"
+msgstr "Visualizador de Arquivo de Registros(log)"
+
+msgid "Log-file directory"
+msgstr "Diretório do arquivo de registros(log)"
+
+msgid "Log-file size"
+msgstr "Tamanho do arquivo de registros(log)"
+
+#, fuzzy
+msgid "Logging"
+msgstr "Registrando os eventos"
+
+msgid "Logon message"
+msgstr "Mensagem de entrada"
+
+msgid "Maximum size of each rotation log-file."
+msgstr "Tamanho máximo para a rotação do arquivo de registros(log)"
+
+msgid "Message displayed in the client when a password is needed."
+msgstr "Mensagem exibida para o cliente quando uma senha é necessária."
+
+#, fuzzy
+msgid "NOT installed"
+msgstr "NÃO instalado"
+
+#, fuzzy
+msgid "None"
+msgstr "Nada"
+
+msgid "Number of backup files of log to create."
+msgstr "Número de backups dos arquivos de registros(log) a serem criados."
+
+msgid "OPTIONAL: See python's ssl module for available ciphers"
+msgstr "Opcional: veja o módulo SSL do python para conhecer as cifras disponíveis"
+
+msgid "One or more missing/invalid fields on tab"
+msgstr "Um ou campos inválidos/ausentes na aba"
+
+msgid "Owner allow write, authenticated users allow read"
+msgstr "O proprietário pode escrever, os usuários autenticados podem ler"
+
+msgid "Path/File required !"
+msgstr "O caminho/arquivo é necessário!"
+
+msgid ""
+"Place here the 'user:password' pairs for your users which should have access "
+"to Radicale."
+msgstr "Coloque aqui os pares 'usuário:senha' para os seus usuários que devem ter acesso a Radicale."
+
+msgid "Please install current version !"
+msgstr "Por favor, instale a versão atual!"
+
+msgid "Please press [Reload] button below to reread the file."
+msgstr "Por favor, pressione o botão [Recarregar] abaixo para reler o arquivo."
+
+msgid "Please update to current version !"
+msgstr "Por favor, atualize para a versão atual!"
+
+msgid "Port numbers below 1024 (Privileged ports) are not supported"
+msgstr "Os porta abaixo de 1024 (portas privilegiadas) não são suportadas"
+
+msgid "Private key file"
+msgstr "Arquivo da chave privada"
+
+msgid "Radicale CalDAV/CardDAV Server"
+msgstr "Radicale Servidor CalDAV/CardDAV"
+
+msgid "Radicale uses '/etc/radicale/rights' as regexp-based file."
+msgstr "Radicale usa o '/etc/radicale/rights' como arquivo baseado em expressão regular."
+
+msgid "Radicale uses '/etc/radicale/users' as htpasswd file."
+msgstr "Radicale usa o '/etc/radicale/users' como o arquivo htpasswd."
+
+msgid "Read only!"
+msgstr "Somente leitura!"
+
+msgid "RegExp file"
+msgstr "Arquivo de expressões regulares"
+
+msgid "Reload"
+msgstr "Recarregar"
+
+msgid "Response Encoding"
+msgstr "Codificação da Resposta"
+
+msgid "Rights"
+msgstr "Direitos"
+
+msgid "Rights are based on a regexp-based file"
+msgstr "Os direitos são baseados em um arquivo baseado em expressões regulares"
+
+msgid "Rights backend"
+msgstr "Serviço de Direitos"
+
+msgid "SHA-1"
+msgstr "SHA-1"
+
+msgid "SSL Protocol"
+msgstr "Protocolo SSL"
+
+#, fuzzy
+msgid "Save"
+msgstr "Salvar"
+
+msgid "Section names are only used for naming the rule."
+msgstr "Os nomes das seção são usados apenas para nomear a regra."
+
+#, fuzzy
+msgid "Server"
+msgstr "Servidor"
+
+msgid "Setting this parameter to '0' will disable rotation of log-file."
+msgstr "Definindo este parâmetro para '0' irá desativar a rotação dos arquivos de registros(log)."
+
+msgid "Software package '%s' is not installed."
+msgstr "O pacote de software '%s' não está instalado."
+
+msgid "Software package '%s' is outdated."
+msgstr "O pacote '%' está desatualizado."
+
+#, fuzzy
+msgid "Software update required"
+msgstr "A atualização do software é necessária"
+
+#, fuzzy
+msgid "Start"
+msgstr "Iniciar"
+
+#, fuzzy
+msgid "Start / Stop"
+msgstr "Iniciar / Parar"
+
+msgid "Start/Stop Radicale server"
+msgstr "Iniciar/Parar o servidor Radicale"
+
+msgid "Storage"
+msgstr "Armazenamento"
+
+msgid "Storage Encoding"
+msgstr "Codificação do Armazenamento"
+
+msgid "Storage backend"
+msgstr "Serviço de armazenamento"
+
+msgid "Syslog Log level"
+msgstr "Nível de detalhamento do serviço de registro (syslog)"
+
+#, fuzzy
+msgid "System"
+msgstr "Sistema"
+
+msgid ""
+"The Radicale Project is a complete CalDAV (calendar) and CardDAV (contact) "
+"server solution."
+msgstr "O Projeto Radicale é uma solução completa de CalDAV (agenda) e CardDAV (contatos)."
+
+msgid ""
+"They can be viewed and edited by calendar and contact clients on mobile "
+"phones or computers."
+msgstr "Eles podem ser visualizados e editados pelos clientes de agenda e de contatos em telefones celulares ou computadores."
+
+msgid "To edit the file follow this link!"
+msgstr "Para editar o arquivo, siga este link!"
+
+msgid "To view latest log file follow this link!"
+msgstr "Para visualizar mais recente arquivo de registros(log), siga este link!"
+
+msgid "Value is not a number"
+msgstr "O valor não é um número"
+
+msgid "Value is not an Integer >= 0 !"
+msgstr "O valor não é um número natural (>=0)!"
+
+msgid "Value not between 0 and 300"
+msgstr "Valor não está entre 0 e 300"
+
+msgid "Value required ! Integer >= 0 !"
+msgstr "O valor é necessário! Número natural (>=0)!"
+
+#, fuzzy
+msgid "Version"
+msgstr "Versão"
+
+#, fuzzy
+msgid "Version Information"
+msgstr "Informação da Versão"
+
+msgid ""
+"WARNING: Only 'File-system' is documented and tested by Radicale development"
+msgstr "AVISO: Apenas 'Sistema de Arquivos "está documentado e testado pelo desenvolvimento do Radicale"
+
+#, fuzzy
+msgid "Warning"
+msgstr "Alerta"
+
+msgid ""
+"You can also get groups from the user regex in the collection with {0}, {1}, "
+"etc."
+msgstr "Você também pode obter grupos a partir da expressão regular do usuário na coleção com {0}, {1} , etc."
+
+msgid ""
+"You can use Python's ConfigParser interpolation values %(login)s and "
+"%(path)s."
+msgstr "Você pode usar a interpolação de valores %(login)s e %(path)s do ConfigParser do Python."
+
+msgid "crypt"
+msgstr "cifrar"
+
+msgid "custom"
+msgstr "personalizado"
+
+msgid "htpasswd file"
+msgstr "arquivo htpasswd"
+
+#, fuzzy
+msgid "installed"
+msgstr "instalado"
+
+msgid "no valid path given!"
+msgstr "Nenhum caminho válido foi informado!"
+
+#, fuzzy
+msgid "or higher"
+msgstr "ou maior"
+
+msgid "plain"
+msgstr "plano"
+
+#, fuzzy
+msgid "required"
+msgstr "necessário"
+
+msgid "salted SHA-1"
+msgstr "SHA-1 com salto"
+
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: pt_BR\n"
+
+msgid "Access Control"
+msgstr "Controle de Acesso"
+
+msgid "Allow all except listed"
+msgstr "Permitir todos, exceto os listados"
+
+msgid "Allow listed only"
+msgstr "Permitir somente os listados"
+
+msgid "Bypassed IP"
+msgstr "Endereços IP Ignorados"
+
+msgid "Connection Timeout"
+msgstr "Tempo limite de conexão"
+
+msgid "Custom"
+msgstr "Personalizado"
+
+msgid "Disabled"
+msgstr "Desabilitado"
+
+msgid "Enable"
+msgstr "Ativar"
+
+msgid "Enabled"
+msgstr "Ativado"
+
+msgid "Encrypt Method"
+msgstr "Método de Cifragem"
+
+msgid "Forwarded IP"
+msgstr "Endereço IP Encaminhado"
+
+msgid "Forwarding Tunnel"
+msgstr "Tunel para Encaminhamento"
+
+msgid "Global Setting"
+msgstr "Opções Globais"
+
+msgid "Ignore List"
+msgstr "Lista de Ignorados"
+
+msgid "LAN"
+msgstr "LAN"
+
+msgid "LAN IP List"
+msgstr "Lista de endereços IP da LAN"
+
+msgid "Local Port"
+msgstr "Porta Local"
+
+msgid "Password"
+msgstr "Senha"
+
+msgid "Relay Mode"
+msgstr "Modo de Retransmissor"
+
+msgid "Server Address"
+msgstr "Endereço do Servidor"
+
+msgid "Server Port"
+msgstr "Porta do servidor"
+
+msgid "ShadowSocks-libev"
+msgstr "ShadowSocks-libev"
+
+msgid "ShadowSocks-libev is not running"
+msgstr "O serviço ShadowSocks-libev está parado"
+
+msgid "ShadowSocks-libev is running"
+msgstr "O serviço ShadowSocks-libev está em execução."
+
+msgid "UDP Forward"
+msgstr "Encaminhamento UDP"
+
+msgid "UDP Local Port"
+msgstr "Porta Local UDP"
+
+msgid "UDP Relay"
+msgstr "Retransmissão UDP"
+
+msgid "WAN"
+msgstr "WAN"
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: pt_BR\n"
+"X-Poedit-Bookmarks: -1,5,-1,-1,-1,-1,-1,-1,-1,-1\n"
+
+msgid "AO Device ID"
+msgstr "Identificador do dispositivo AO"
+
+msgid "AO Device Name"
+msgstr "Nome do dispositivo AO"
+
+msgid "AO Driver"
+msgstr "Driver do AO"
+
+msgid "Airport Name"
+msgstr "Nome do Airport"
+
+msgid "Default"
+msgstr "Padrão"
+
+msgid "Enabled"
+msgstr "Habilitado"
+
+msgid "HW Address"
+msgstr "Endereço de Hardware"
+
+msgid "Password"
+msgstr "Senha"
+
+msgid "Port"
+msgstr "Porta"
+
+msgid "Respawn"
+msgstr "Redisparar"
+
+msgid "Shairplay"
+msgstr "Shairplay"
+
+msgid ""
+"Shairplay is a simple AirPlay server implementation, here you can configure "
+"the settings."
+msgstr ""
+"Shairplay é uma implementação simples de um servidor AirPlay. Aqui você pode "
+"configurá-lo."
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
+"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-06-10 03:41+0200\n"
-"PO-Revision-Date: 2014-03-15 22:12+0200\n"
-"Last-Translator: Luiz Angelo <luizluca@gmail.com>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
+"PO-Revision-Date: 2017-02-22 18:27-0300\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-"X-Generator: Pootle 2.0.6\n"
+"X-Generator: Poedit 1.8.11\n"
+"Language-Team: \n"
msgid "Action (target)"
msgstr "Ação (destino)"
msgstr "Adicionar o comando de notificação"
msgid "Aggregate number of connected users"
-msgstr ""
+msgstr "Numero agregado de usuários conectados"
msgid "Base Directory"
msgstr "Diretório Base"
msgstr "Monitoramento básico"
msgid "CPU Frequency"
-msgstr ""
+msgstr "Frequência da CPU"
msgid "CPU Frequency Plugin Configuration"
-msgstr ""
+msgstr "Configuração do Plugin da Frequência da CPU"
msgid "CPU Plugin Configuration"
msgstr "Configuração do plugin CPU"
msgstr "Email"
msgid "Empty value = monitor all"
-msgstr ""
+msgstr "Valor vazio = monitore todos"
msgid "Enable this plugin"
msgstr "Habilitar este plugin"
msgid "Entropy"
-msgstr ""
+msgstr "Entropia"
msgid "Entropy Plugin Configuration"
-msgstr ""
+msgstr "Configuração do Plugin de Entropia"
msgid "Exec"
msgstr "Exec"
"Encaminhamento entre o endereço de escuta e os endereços dos servidores"
msgid "Gather compression statistics"
-msgstr ""
+msgstr "Obter estatísticas sobre a compressão"
msgid "General plugins"
-msgstr ""
+msgstr "Plugins Gerais"
msgid "Generate a separate graph for each logged user"
-msgstr ""
+msgstr "Gerar um gráfico separado para cada usuário conectado"
msgid "Graphs"
msgstr "Gráficos"
msgid "Hold Ctrl to select multiple items or to deselect entries."
msgstr ""
+"Segure o Ctrl para selecionar múltiplos itens ou para retirar entradas. "
msgid "Host"
msgstr "Equipamento"
"Max values for a period can be used instead of averages when not using 'only "
"average RRAs'"
msgstr ""
+"Valores máximos para um período podem ser usados em vez de médias quando não "
+"estiver usando 'somente RRAs de médias'"
msgid "Maximum allowed connections"
msgstr "Máximo de conexões permitidas"
msgstr "Monitorar todas as portas locais"
msgid "Monitor all sensors"
-msgstr ""
+msgstr "Monitorar todas os sensores"
msgid "Monitor device(s) / thermal zone(s)"
-msgstr ""
+msgstr "Dispositivo(s) de monitoramento / zona(s) térmica(s)"
msgid "Monitor devices"
msgstr "Monitorar dispositivos"
msgstr "Somente criar RRAs de média"
msgid "OpenVPN"
-msgstr ""
+msgstr "OpenVPN"
msgid "OpenVPN Plugin Configuration"
-msgstr ""
+msgstr "Configuração do Plugin do OpenVPN"
msgid "OpenVPN status files"
-msgstr ""
+msgstr "Arquivos de estado do OpenVPN"
msgid "Options"
msgstr "Opções"
msgstr "Segundos"
msgid "Sensor list"
-msgstr ""
+msgstr "Lista de sensores"
msgid "Sensors"
-msgstr ""
+msgstr "Sensores"
msgid "Sensors Plugin Configuration"
-msgstr ""
+msgstr "Configuração do Plugin de Sensores"
msgid "Server host"
msgstr "Endereço do servidor"
msgstr "Porta do servidor"
msgid "Setup"
-msgstr ""
+msgstr "Configuração"
msgid "Shaping class monitoring"
msgstr "Monitoramento das Classes de Shaping"
msgid "Show max values instead of averages"
-msgstr ""
+msgstr "Mostrar valores máximos em vez de médias"
msgid "Socket file"
msgstr "Arquivo do socket"
msgstr "Especifica quais informações serão coletadas sobre a topologia global."
msgid "Splash Leases"
-msgstr ""
+msgstr "Concessões do Splash"
msgid "Splash Leases Plugin Configuration"
-msgstr ""
+msgstr "Configuração do Plugin das Concessões do Splash"
msgid "Statistics"
msgstr "Estatística"
"The OpenVPN plugin gathers information about the current vpn connection "
"status."
msgstr ""
+"O plugin OpenVPN reúne informações sobre o status atual da conexão VPN."
msgid ""
"The conntrack plugin collects statistics about the number of tracked "
"Plugin::Collectd mas pode ser utilizado de outras maneiras também."
msgid "The entropy plugin collects statistics about the available entropy."
-msgstr ""
+msgstr "O plugin de entropia coleta estatísticas sobre a entropia disponível."
msgid ""
"The exec plugin starts external commands to read values from or to notify "
"The sensors plugin uses the Linux Sensors framework to gather environmental "
"statistics."
msgstr ""
+"O plugin de sensores usa a estrutura de sensores do Linux para coletar "
+"estatísticas ambientais."
msgid ""
"The splash leases plugin uses libuci to collect statistics about splash "
"leases."
msgstr ""
+"O plug-in de concessões splash usa o libuci para coletar estatísticas sobre "
+"concessões de splash."
msgid ""
"The statistics package uses <a href=\"https://collectd.org/\">Collectd</a> "
"to gather data and <a href=\"http://oss.oetiker.ch/rrdtool/\">RRDtool</a> to "
"render diagram images."
msgstr ""
+"O pacote de estatísticas usa <a href=\"https://collectd.org/\"> Collectd </"
+"a> para coletar dados e <a href=\"http://oss.oetiker.ch/rrdtool/\">RRDtool</"
+"a> para desenhar os gráficos."
msgid ""
"The tcpconns plugin collects informations about open tcp connections on "
"read from /sys/class/thermal/*/temp ( '*' denotes the thermal device to be "
"read, e.g. thermal_zone1 )"
msgstr ""
+"O plugin térmico monitorará a temperatura do sistema. Os dados são "
+"tipicamente lidos de /sys/class/thermal/*/temp ('*' indica o dispositivo "
+"térmico a ser lido, ex:, thermal_zone1)"
msgid ""
"The unixsock plugin creates a unix socket which can be used to read "
msgid "The uptime plugin collects statistics about the uptime of the system."
msgstr ""
+"O plugin de tempo de atividade coleta estatísticas sobre o tempo de "
+"atividade do sistema."
msgid "Thermal"
-msgstr ""
+msgstr "Térmico"
msgid "Thermal Plugin Configuration"
-msgstr ""
+msgstr "Configuração do Plugin Térmico"
msgid "This plugin collects statistics about the processor frequency scaling."
msgstr ""
+"Este plugin coleta as estatísticas sobre o escalonamento da frequência do "
+"processador."
msgid ""
"This section defines on which interfaces collectd will wait for incoming "
msgstr "Configuração do plugin Unixsock"
msgid "Uptime"
-msgstr ""
+msgstr "Tempo de atividade"
msgid "Uptime Plugin Configuration"
-msgstr ""
+msgstr "Configuração do Plugin de Tempo de Atividade"
msgid "Use improved naming schema"
-msgstr ""
+msgstr "Use um esquema de nomeação melhorado"
msgid "Used PID file"
msgstr "Arquivo PID usado"
msgid ""
"You can install additional collectd-mod-* plugins to enable more statistics."
msgstr ""
+"Você pode instalar plugins adicionais (collectd-mod-*) para habilitar mais "
+"estatísticas."
msgid "e.g. br-ff"
msgstr "ex: br-ff"
msgid "server interfaces"
msgstr "interfaces do servidor"
+#~ msgid ""
+#~ "Note: as pages are rendered by user 'nobody', the *.rrd files, the "
+#~ "storage directory and all its parent directories need to be world "
+#~ "readable."
+#~ msgstr ""
+#~ "Nota: como as páginas são renderizadas pelo usuário 'nobody', os arquivos "
+#~ "* .rrd, o diretório de armazenamento e todos os seus diretórios "
+#~ "superiores precisam ser legíveis a todos."
+
#~ msgid "Collectd"
#~ msgstr "Coletar"
o.rmempty = false
o.default = 0
-o = s:option(Value, "trm_loop", translate("Loop timeout in seconds for wlan monitoring"),
- translate("Default 30, range 5-60"))
+o = s:option(Value, "trm_maxwait", translate("Max. timeout in seconds for wlan interface reload"),
+ translate("Default 20, range 10-60"))
o.rmempty = false
-o.default = 30
-o.datatype = "range(5,60)"
+o.default = 20
+o.datatype = "range(10,60)"
o = s:option(Value, "trm_maxretry", translate("Max. number of connection retries to an uplink"),
- translate("Default 3, range 0-10. Set to 0 to allow unlimited retries"))
+ translate("Default 3, range 1-10"))
o.rmempty = false
o.default = 3
-o.datatype = "range(0,10)"
+o.datatype = "range(1,10)"
-- Extra options
a.rmempty = true
a.default = a.disabled
-a = e:option(Value, "trm_device", translate("Use only one radio, e.g. 'radio0'"),
- translate("Default: empty = use all radios."))
+a = e:option(Value, "trm_iface", translate("Restrict reload trigger to certain interface(s)"),
+ translate("Space separated list of wwan interfaces that trigger reload action. To disable reload trigger set it to 'false'. Default: empty"))
a.rmempty = true
a.default = ""
a.datatype = "uciname"
msgid "Debug logging"
msgstr "デバッグ ログ"
-msgid "Default 3, range 0-10. Set to 0 to allow unlimited retries"
-msgstr "既定値 3、範囲 0 - 10。再試行回数を制限しない場合、0 に設定します。"
+msgid "Default 20, range 10-60"
+msgstr "既定値 20、範囲 10 - 60"
-msgid "Default 30, range 5-60"
-msgstr "既定値 30、範囲 5 - 60"
-
-msgid "Default: empty = use all radios."
-msgstr "デフォルト:(空)= 全ての無線を使用"
+msgid "Default 3, range 1-10"
+msgstr "既定値 3、範囲 1 - 10"
msgid "Disable this if you want to use iwinfo instead of iw"
msgstr "iw の代わりに iwinfo を使用したい場合、この設定を無効にします。"
msgid "Link to detailed advice"
msgstr "詳細な解説へのリンク"
-msgid "Loop timeout in seconds for wlan monitoring"
-msgstr "無線LAN モニターのループ タイムアウト(秒)"
-
msgid "Max. number of connection retries to an uplink"
msgstr "確立までの接続試行回数"
+msgid "Max. timeout in seconds for wlan interface reload"
+msgstr "無線LANインターフェース リロード時の最大待機時間(秒)"
+
+msgid "Restrict reload trigger to certain interface(s)"
+msgstr "リロード トリガを特定のインターフェースに限定する"
+
+msgid ""
+"Space separated list of wwan interfaces that trigger reload action. To "
+"disable reload trigger set it to 'false'. Default: empty"
+msgstr ""
+"リロード動作のトリガとなる、スペースで区切られたWWAN インターフェースのリスト"
+"です。リロードのトリガを無効にするには、'false' を設定します。既定値:(空)"
+
msgid "Travelmate"
msgstr "Travelmate"
msgid "Use iw for scanning"
msgstr "スキャンに iw を使用する"
-msgid "Use only one radio, e.g. 'radio0'"
-msgstr "単一の無線のみ使用する 例: 'radio0'"
+#~ msgid "Default 3, range 0-10. Set to 0 to allow unlimited retries"
+#~ msgstr "既定値 3、範囲 0 - 10。再試行回数を制限しない場合、0 に設定します。"
+
+#~ msgid "Default 30, range 5-60"
+#~ msgstr "既定値 30、範囲 5 - 60"
+
+#~ msgid "Default: empty = use all radios."
+#~ msgstr "デフォルト:(空)= 全ての無線を使用"
+
+#~ msgid "Loop timeout in seconds for wlan monitoring"
+#~ msgstr "無線LAN モニターのループ タイムアウト(秒)"
+
+#~ msgid "Use only one radio, e.g. 'radio0'"
+#~ msgstr "単一の無線のみ使用する 例: 'radio0'"
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: pt_BR\n"
+
+msgid ""
+"Brief advice: Create a wwan interface, configure it to use dhcp and add it "
+"to the wan zone in firewall. Create the wifi interfaces to be used ('client' "
+"mode, assigned to wwan network, left as disabled). Travelmate will try to "
+"connect to the known wifi client interfaces in the defined order."
+msgstr ""
+"Breve conselho: Crie uma interface wwan, configure-a para usar DHCP e "
+"adicione-a à zona wan no firewall. Crie as interfaces wifi a serem usadas "
+"(modo 'cliente', atribuído à rede wwan, deixado como desativado). O "
+"Travelmate tentará se conectar às interfaces de cliente wifi conhecidas na "
+"ordem definida."
+
+msgid ""
+"Configuration of the Travelmate package to enable travel router "
+"functionality."
+msgstr ""
+"Configuração do pacote Travelmate para permitir a funcionalidade de roteador "
+"de viagem."
+
+msgid "Debug logging"
+msgstr "Registros(log) para depuração"
+
+msgid "Default 20, range 10-60"
+msgstr "Padrão 20, faixa 10-60"
+
+msgid "Default 3, range 1-10"
+msgstr "Padrão 3, faixa 1-10"
+
+msgid "Disable this if you want to use iwinfo instead of iw"
+msgstr "Desabilite isto se você quer usar o iwinfo ao invés do iw"
+
+msgid "Enable Travelmate"
+msgstr "Habilitar o Travelmate"
+
+msgid "Extra options"
+msgstr "Opções adicionais"
+
+msgid "Global options"
+msgstr "Opções Globais"
+
+msgid "Link to detailed advice"
+msgstr "Endereço para conselhos detalhados"
+
+msgid "Max. number of connection retries to an uplink"
+msgstr "Máximo número de tentativas de conexão para um enlace"
+
+msgid "Max. timeout in seconds for wlan interface reload"
+msgstr "Tempo limite máximo em segundos para recarregar a interface wlan"
+
+msgid "Restrict reload trigger to certain interface(s)"
+msgstr "Restringir o gatilho de recarga para somente alguma(s) interface(s)"
+
+msgid ""
+"Space separated list of wwan interfaces that trigger reload action. To "
+"disable reload trigger set it to 'false'. Default: empty"
+msgstr ""
+"Lista separada por espaços de interfaces wwan que acionam a ação de recarga. "
+"Para desabilitar o gatilho de recarga, defina-o como 'false'. Padrão: vazio"
+
+msgid "Travelmate"
+msgstr "Travelmate"
+
+msgid "Use iw for scanning"
+msgstr "Use o iw para escaneamento"
msgid "Debug logging"
msgstr ""
-msgid "Default 3, range 0-10. Set to 0 to allow unlimited retries"
+msgid "Default 20, range 10-60"
msgstr ""
-msgid "Default 30, range 5-60"
-msgstr ""
-
-msgid "Default: empty = use all radios."
+msgid "Default 3, range 1-10"
msgstr ""
msgid "Disable this if you want to use iwinfo instead of iw"
msgid "Link to detailed advice"
msgstr ""
-msgid "Loop timeout in seconds for wlan monitoring"
+msgid "Max. number of connection retries to an uplink"
msgstr ""
-msgid "Max. number of connection retries to an uplink"
+msgid "Max. timeout in seconds for wlan interface reload"
msgstr ""
-msgid "Travelmate"
+msgid "Restrict reload trigger to certain interface(s)"
msgstr ""
-msgid "Use iw for scanning"
+msgid ""
+"Space separated list of wwan interfaces that trigger reload action. To "
+"disable reload trigger set it to 'false'. Default: empty"
msgstr ""
-msgid "Use only one radio, e.g. 'radio0'"
+msgid "Travelmate"
+msgstr ""
+
+msgid "Use iw for scanning"
msgstr ""
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: pt_BR\n"
+
+msgid ""
+"(/old/path=/new/path) or (just /old/path which becomes /cgi-prefix/old/path)"
+msgstr ""
+"(/old/path=/new/path) ou (just /old/path que se torna /cgi-prefix/old/path)"
+
+msgid "404 Error"
+msgstr "Erro 404"
+
+msgid "A lightweight single-threaded HTTP(S) server"
+msgstr "Um servidor HTTP(S) leve de únida thread."
+
+msgid "Advanced Settings"
+msgstr "Opções Avançadas"
+
+msgid "Aliases"
+msgstr "Pseudônimos (Aliases)"
+
+msgid "Base directory for files to be served"
+msgstr "Diretório Base para publicar arquivos"
+
+msgid "Bind to specific interface:port (by specifying interface address"
+msgstr ""
+"Escute em uma interface:porta específica (especificando o endereço da "
+"interface"
+
+msgid "CGI filetype handler"
+msgstr "Interpretador de tipo de arquivo CGI"
+
+msgid "CGI is disabled if not present."
+msgstr "O CGI estará desabilitado se não presente."
+
+msgid "Config file (e.g. for credentials for Basic Auth)"
+msgstr "Arquivo de configuração (ex: credenciais para autenticação básica)"
+
+msgid "Connection reuse"
+msgstr "Reutilizar conexão"
+
+msgid "Country"
+msgstr "País"
+
+msgid "Disable JSON-RPC authorization via ubus session API"
+msgstr "Desabilita a autorização JSON-RPC através da API de sessão ubus"
+
+msgid "Do not follow symlinks outside document root"
+msgstr "Não siga ligações simbólicas (symlinks) para fora do documento raiz"
+
+msgid "Do not generate directory listings."
+msgstr "Não gere listagens de diretórios"
+
+msgid "Document root"
+msgstr "Documento Raiz"
+
+msgid "E.g specify with index.html and index.php when using PHP"
+msgstr "Ex: use index.html e index.php quando usar PHP"
+
+msgid "Embedded Lua interpreter is disabled if not present."
+msgstr "O interpretador Lua embutido será desabilitado se não presente."
+
+msgid "Enable JSON-RPC Cross-Origin Resource Support"
+msgstr "Habilite o suporte para recursos JSON-RPC de origem cruzada"
+
+msgid "For settings primarily geared to serving more than the web UI"
+msgstr "Para ajustes envolvidos com mais do que prover a interface web"
+
+msgid "Full Web Server Settings"
+msgstr "Configurações Completas do Servidor Web"
+
+msgid "Full real path to handler for Lua scripts"
+msgstr "Caminho completo para o interpretador de scripts Lua"
+
+msgid "General Settings"
+msgstr "Configurações Gerais"
+
+msgid "HTTP listeners (address:port)"
+msgstr "Escutas do HTTP (endereço:porta)"
+
+msgid "HTTPS Certificate (DER Encoded)"
+msgstr "Certificado do HTTPS (codificado em formato PEM)"
+
+msgid "HTTPS Private Key (DER Encoded)"
+msgstr "Chave Privada do HTTPS (codificado como DER)"
+
+msgid "HTTPS listener (address:port)"
+msgstr "Escuta do HTTPS (endereço:porta)"
+
+msgid "Ignore private IPs on public interface"
+msgstr "Ignore endereços IP privados na interface pública"
+
+msgid "Index page(s)"
+msgstr "Página(s) Índice(s)"
+
+msgid ""
+"Interpreter to associate with file endings ('suffix=handler', e.g. '.php=/"
+"usr/bin/php-cgi')"
+msgstr ""
+"Interpretador para associar com extensões de arquivos "
+"('extensão=interpretador', ex: '.php=/usr/bin/php-cgi')"
+
+msgid "Length of key in bits"
+msgstr "Comprimento da chave em bits"
+
+msgid "Location"
+msgstr "Localização"
+
+msgid "Maximum number of connections"
+msgstr "Número máximo de requisições para script"
+
+msgid "Maximum number of script requests"
+msgstr "Número máximo de requisições para script"
+
+msgid "Maximum wait time for Lua, CGI, or ubus execution"
+msgstr "Tempo máximo de espera para execuções de Lua, CGI ou ubus"
+
+msgid "Maximum wait time for network activity"
+msgstr "Tempo máximo de espera para atividade na rede"
+
+msgid "Override path for ubus socket"
+msgstr "Sobrescrever o caminho do socket ubus"
+
+msgid "Path prefix for CGI scripts"
+msgstr "Prefixo do caminho para scripts CGI"
+
+msgid ""
+"Prevent access from private (RFC1918) IPs on an interface if it has an "
+"public IP address"
+msgstr ""
+"Evite acesso de endereços privados (RFC1918) na interface que tem um "
+"endereço IP público"
+
+msgid "Realm for Basic Auth"
+msgstr "Reino para Autenticação Simples"
+
+msgid "Redirect all HTTP to HTTPS"
+msgstr "Redirecionar todo tráfego HTTP para HTTPS"
+
+msgid "Remove configuration for certificate and key"
+msgstr "Remove a configuração para o certificado e chave"
+
+msgid "Remove old certificate and key"
+msgstr "Remove os certificados e chaves antigas"
+
+msgid "Server Hostname"
+msgstr "Nome do Servidor"
+
+msgid ""
+"Settings which are either rarely needed or which affect serving the WebUI"
+msgstr "Ajustes que são raramente usadas ou que afetam a interface web"
+
+msgid "State"
+msgstr "Estado"
+
+msgid "TCP Keepalive"
+msgstr "Manter conexões TCP abertas (Keepalive)"
+
+msgid "This permanently deletes the cert, key, and configuration to use same."
+msgstr "Isto apaga permanentemente o certificado, a chave e a configuração."
+
+msgid "Valid for # of Days"
+msgstr "Valido por # dias"
+
+msgid ""
+"Virtual URL or CGI script to display on status '404 Not Found'. Must begin "
+"with '/'"
+msgstr ""
+"URL virtual ou script CGI para mostrar quando ocorrer erro '404 Não "
+"Encontrado'. Deve começar com '/'"
+
+msgid "Virtual path prefix for Lua scripts"
+msgstr "Prefixo do caminho virtual para scripts Lua"
+
+msgid "Virtual path prefix for ubus via JSON-RPC integration"
+msgstr "Prefixo do caminho virtual para o ubus através da integração JSON-RPC"
+
+msgid "Will not use HTTP authentication if not present"
+msgstr "Não usar autenticação HTTP se não presente"
+
+msgid "a.k.a CommonName"
+msgstr "também conhecido como Nome Comum"
+
+msgid "uHTTPd"
+msgstr "uHTTPd"
+
+msgid "uHTTPd Self-signed Certificate Parameters"
+msgstr "Parâmetros do Certificado Auto-assinado do uHTTPd"
+
+msgid ""
+"uHTTPd will generate a new self-signed certificate using the configuration "
+"shown below."
+msgstr ""
+"o uHTTPd gerará um certificado auto-assinado usando a configuração mostrada "
+"abaixo."
+
+msgid "ubus integration is disabled if not present"
+msgstr "A integração com o ubus será desativada se não presente"
m = Map("unbound", translate("Recursive DNS"),
translate("Unbound is a validating, recursive, and caching DNS resolver."))
-
-s = m:section(TypedSection, "unbound", translate("Unbound Settings"))
-s.addremove = false
-s.anonymous = true
-s:tab("service", translate("Unbound Service"))
-s:tab("resource", translate("Unbound Resources"))
-s:tab("dnsmasq", translate("Dnsmasq Link"))
+s1 = m:section(TypedSection, "unbound")
+s1.addremove = false
+s1.anonymous = true
+s1:tab("service", translate("Basic Settings"))
+s1:tab("advanced", translate("Advanced Settings"))
+s1:tab("resource", translate("Resource Settings"))
---Enable Unbound
+--LuCI or Not
-e = s:taboption("service", Flag, "enabled", translate("Enable Unbound:"),
+ena = s1:taboption("service", Flag, "enabled", translate("Enable Unbound:"),
translate("Enable the initialization scripts for Unbound"))
-e.rmempty = false
+ena.rmempty = false
-function e.cfgvalue(self, section)
+mcf = s1:taboption("service", Flag, "manual_conf", translate("Manual Conf:"),
+ translate("Skip UCI and use /etc/unbound/unbound.conf"))
+mcf.rmempty = false
+
+function ena.cfgvalue(self, section)
return luci.sys.init.enabled("unbound") and self.enabled or self.disabled
end
-function e.write(self, section, value)
+function ena.write(self, section, value)
if value == "1" then
luci.sys.init.enable("unbound")
luci.sys.call("/etc/init.d/unbound start >/dev/null")
return Flag.write(self, section, value)
end
---Service Tab
-
-mcf = s:taboption("service", Flag, "manual_conf", translate("Manual Conf:"),
- translate("Skip UCI and use /etc/unbound/unbound.conf"))
-mcf.rmempty = false
+--Basic Tab
-lsv = s:taboption("service", Flag, "localservice", translate("Local Service:"),
+lsv = s1:taboption("service", Flag, "localservice", translate("Local Service:"),
translate("Accept queries only from local subnets"))
lsv.rmempty = false
-qry = s:taboption("service", Flag, "query_minimize", translate("Query Minimize:"),
- translate("Break down query components for small added privacy"))
-qry.rmempty = false
-
-rlh = s:taboption("service", Flag, "rebind_localhost", translate("Block Localhost Rebind:"),
+rlh = s1:taboption("service", Flag, "rebind_localhost", translate("Block Localhost Rebind:"),
translate("Prevent upstream response of 127.0.0.0/8"))
rlh.rmempty = false
-rpv = s:taboption("service", Flag, "rebind_protection", translate("Block Private Rebind:"),
+rpv = s1:taboption("service", Flag, "rebind_protection", translate("Block Private Rebind:"),
translate("Prevent upstream response of RFC1918 ranges"))
rpv.rmempty = false
-vld = s:taboption("service", Flag, "validator", translate("Enable DNSSEC:"),
+vld = s1:taboption("service", Flag, "validator", translate("Enable DNSSEC:"),
translate("Enable the DNSSEC validator module"))
vld.rmempty = false
-nvd = s:taboption("service", Flag, "validator_ntp", translate("DNSSEC NTP Fix:"),
+nvd = s1:taboption("service", Flag, "validator_ntp", translate("DNSSEC NTP Fix:"),
translate("Break the loop where DNSSEC needs NTP and NTP needs DNS"))
nvd.rmempty = false
+nvd:depends({ validator = true })
-eds = s:taboption("service", Value, "edns_size", translate("EDNS Size:"),
+eds = s1:taboption("service", Value, "edns_size", translate("EDNS Size:"),
translate("Limit extended DNS packet size"))
eds.datatype = "and(uinteger,min(512),max(4096))"
eds.rmempty = false
-prt = s:taboption("service", Value, "listen_port", translate("Listening Port:"),
+prt = s1:taboption("service", Value, "listen_port", translate("Listening Port:"),
translate("Choose Unbounds listening port"))
prt.datatype = "port"
prt.rmempty = false
-tlm = s:taboption("service", Value, "ttl_min", translate("TTL Minimum:"),
+tlm = s1:taboption("service", Value, "ttl_min", translate("TTL Minimum:"),
translate("Prevent excessively short cache periods"))
tlm.datatype = "and(uinteger,min(0),max(600))"
tlm.rmempty = false
-d64 = s:taboption("service", Flag, "dns64", translate("Enable DNS64:"),
+--Advanced Tab
+
+ctl = s1:taboption("advanced", Flag, "unbound_control", translate("Unbound Control App:"),
+ translate("Enable unecrypted localhost access for unbound-control"))
+ctl.rmempty = false
+
+dlk = s1:taboption("advanced", ListValue, "dhcp_link", translate("DHCP Link:"),
+ translate("Link to supported programs to load DHCP into DNS"))
+dlk:value("none", translate("No Link"))
+dlk:value("dnsmasq", "dnsmasq")
+dlk:value("odhcpd", "odhcpd")
+dlk.rmempty = false
+
+dom = s1:taboption("advanced", Value, "domain", translate("Local Domain:"),
+ translate("Domain suffix for this router and DHCP clients"))
+dom.placeholder = "lan"
+dom:depends({ dhcp_link = "none" })
+dom:depends({ dhcp_link = "odhcpd" })
+
+dty = s1:taboption("advanced", ListValue, "domain_type", translate("Local Domain Type:"),
+ translate("How to treat queries of this local domain"))
+dty:value("deny", translate("Ignored"))
+dty:value("refuse", translate("Refused"))
+dty:value("static", translate("Only Local"))
+dty:value("transparent", translate("Also Forwarded"))
+dty:depends({ dhcp_link = "none" })
+dty:depends({ dhcp_link = "odhcpd" })
+
+lfq = s1:taboption("advanced", ListValue, "add_local_fqdn", translate("LAN DNS:"),
+ translate("How to enter the LAN or local network router in DNS"))
+lfq:value("0", translate("No DNS"))
+lfq:value("1", translate("Hostname, Primary Address"))
+lfq:value("2", translate("Hostname, All Addresses"))
+lfq:value("3", translate("Host FQDN, All Addresses"))
+lfq:value("4", translate("Interface FQDN, All Addresses"))
+lfq:depends({ dhcp_link = "none" })
+lfq:depends({ dhcp_link = "odhcpd" })
+
+wfq = s1:taboption("advanced", ListValue, "add_wan_fqdn", translate("WAN DNS:"),
+ translate("Override the WAN side router entry in DNS"))
+wfq:value("0", translate("Upstream"))
+wfq:value("1", translate("Hostname, Primary Address"))
+wfq:value("2", translate("Hostname, All Addresses"))
+wfq:value("3", translate("Host FQDN, All Addresses"))
+wfq:value("4", translate("Interface FQDN, All Addresses"))
+wfq:depends({ dhcp_link = "none" })
+wfq:depends({ dhcp_link = "odhcpd" })
+
+ctl = s1:taboption("advanced", Flag, "dhcp4_slaac6", translate("DHCPv4 to SLAAC:"),
+ translate("Use DHCPv4 MAC to discover IP6 hosts SLAAC (EUI64)"))
+ctl.rmempty = false
+
+d64 = s1:taboption("advanced", Flag, "dns64", translate("Enable DNS64:"),
translate("Enable the DNS64 module"))
d64.rmempty = false
-pfx = s:taboption("service", Value, "dns64_prefix", translate("DNS64 Prefix:"),
+pfx = s1:taboption("advanced", Value, "dns64_prefix", translate("DNS64 Prefix:"),
translate("Prefix for generated DNS64 addresses"))
pfx.datatype = "ip6addr"
pfx.placeholder = "64:ff9b::/96"
pfx.optional = true
-pfx:depends({ dns64 = "1" })
+pfx:depends({ dns64 = true })
+
+qry = s1:taboption("advanced", Flag, "query_minimize", translate("Query Minimize:"),
+ translate("Break down query components for limited added privacy"))
+qry.rmempty = false
+
+qrs = s1:taboption("advanced", Flag, "query_min_strict", translate("Strict Minimize:"),
+ translate("Strict version of 'query minimize' but it can break DNS"))
+qrs.rmempty = false
+qrs:depends({ query_minimize = true })
+
+--TODO: dnsmasq needs to not reference resolve-file and get off port 53.
--Resource Tuning Tab
-rsn = s:taboption("resource", ListValue, "recursion", translate("Recursion Strength:"),
+pro = s1:taboption("resource", ListValue, "protocol", translate("Recursion Protocol:"),
+ translate("Chose the protocol recursion queries leave on"))
+pro:value("mixed", translate("IP4 and IP6"))
+pro:value("ip6_prefer", translate("IP6 Preferred"))
+pro:value("ip4_only", translate("IP4 Only"))
+pro:value("ip6_only", translate("IP6 Only"))
+pro.rmempty = false
+
+rsn = s1:taboption("resource", ListValue, "recursion", translate("Recursion Strength:"),
translate("Recursion activity affects memory growth and CPU load"))
rsn:value("aggressive", translate("Aggressive"))
rsn:value("default", translate("Default"))
rsn:value("passive", translate("Passive"))
rsn.rmempty = false
-rsc = s:taboption("resource", ListValue, "resource", translate("Memory Resource:"),
+rsc = s1:taboption("resource", ListValue, "resource", translate("Memory Resource:"),
translate("Use menu System/Processes to observe any memory growth"))
rsc:value("large", translate("Large"))
rsc:value("medium", translate("Medium"))
rsc:value("tiny", translate("Tiny"))
rsc.rmempty = false
-age = s:taboption("resource", Value, "root_age", translate("Root DSKEY Age:"),
+ag2 = s1:taboption("resource", Value, "root_age", translate("Root DSKEY Age:"),
translate("Limit days between RFC5011 to reduce flash writes"))
-age.datatype = "and(uinteger,min(1),max(99))"
-age:value("14", "14")
-age:value("28", "28 ("..translate("default")..")")
-age:value("45", "45")
-age:value("90", "90")
-age:value("99", "99 ("..translate("never")..")")
-
---Dnsmasq Link Tab
-
-dld = s:taboption("dnsmasq", Flag, "dnsmasq_link_dns", translate("Link dnsmasq:"),
- translate("Forward queries to dnsmasq for local clients"))
-dld.rmempty = false
-
-dgn = s:taboption("dnsmasq", Flag, "dnsmsaq_gate_name", translate("Local Gateway Name:"),
- translate("Also query dnsmasq for this hosts outbound gateway"))
-dgn.rmempty = false
-
---TODO: Read only repective dnsmasq options and inform user of link requirements.
---TODO: dnsmasq needs to not reference resolve-file and get off port 53.
+ag2.datatype = "and(uinteger,min(1),max(99))"
+ag2:value("14", "14")
+ag2:value("28", "28 ("..translate("default")..")")
+ag2:value("45", "45")
+ag2:value("90", "90")
+ag2:value("99", "99 ("..translate("never")..")")
return m
--- /dev/null
+#!/bin/sh
+
+uci -q batch <<-EOF >/dev/null
+ delete ucitrack.@unbound[-1]
+ add ucitrack unbound
+ set ucitrack.@unbound[-1].init=unbound
+ commit ucitrack
+EOF
+
+rm -f /tmp/luci-indexcache
+[ ! -x /usr/sbin/unbound-control ] && exit 0
+
+uci -q batch <<-EOF >/dev/null
+ set luci.unboundhosts=command
+ set luci.unboundhosts.name='Unbound Local Hosts'
+ set luci.unboundhosts.command='unbound-control -c /var/lib/unbound/unbound.conf list_local_data'
+ set luci.unboundzones=command
+ set luci.unboundzones.name='Unbound Local Zones'
+ set luci.unboundzones.command='unbound-control -c /var/lib/unbound/unbound.conf list_local_zones'
+ commit luci
+EOF
+
+rm -f /tmp/luci-indexcache
+exit 0
+
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: pt_BR\n"
+
+msgid "Configuration of VPN Bypass Settings"
+msgstr "Configurações do VPN Bypass"
+
+msgid "Domains to Bypass"
+msgstr "Domínios para evitar a VPN"
+
+msgid "Domains which will be accessed directly (outside of the VPN tunnel)"
+msgstr "Domínios que serão acessados diretamente (fora do túnel VPN)"
+
+msgid "Enable VPN Bypass"
+msgstr "Habilitar o VPN Bypass"
+
+msgid "Local IP Subnets to Bypass"
+msgstr "Subredes IP locais para evitar a VPN"
+
+msgid "Local IP ranges with direct internet access (outside of the VPN tunnel)"
+msgstr "Faixa de endereços IP locais que terão acesso internet direto (fora do túnel VPN)"
+
+msgid "Local Ports to Bypass"
+msgstr "Portas locais para evitar a VPN"
+
+msgid "Local ports to trigger VPN Bypass"
+msgstr "Portas locais para disparar o VPN Bypass"
+
+msgid "Remote IP Subnets to Bypass"
+msgstr "Subredes IP remotas para evitar a VPN"
+
+msgid "Remote IP ranges which will be accessed directly (outside of the VPN tunnel)"
+msgstr "Faixa de endereços IP remotos que serão acessados diretamente (fora do túnel VPN)"
+
+msgid "Remote Ports to Bypass"
+msgstr "Portas remotas para evitar a VPN"
+
+msgid "Remote ports to trigger VPN Bypass"
+msgstr "Portas remotas para disparar o VPN Bypass"
+
+msgid "VPN Bypass"
+msgstr "VPN Bypass"
+
+msgid "VPN Bypass Settings"
+msgstr "Configurações do VPN Bypass"
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"PO-Revision-Date: 2014-03-29 23:20+0200\n"
-"Last-Translator: Luiz Angelo <luizluca@gmail.com>\n"
+"Project-Id-Version: \n"
+"PO-Revision-Date: 2017-02-20 18:10-0300\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
"Language-Team: none\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-"X-Generator: Pootle 2.0.6\n"
+"X-Generator: Poedit 1.8.11\n"
+"POT-Creation-Date: \n"
msgid "Forced reboot delay"
msgstr "Atraso para reinício forçado"
msgid "Watchcat"
msgstr "Watchcat"
-#, fuzzy
msgid ""
"Watchcat allows configuring a periodic reboot when the Internet connection "
"has been lost for a certain period of time."
msgstr ""
-"Watchcat permite que se configure um período para reiniciar e/ou quando a "
+"Watchcat permite a configuração de um período para reiniciar e/ou quando a "
"conexão com à Internet foi perdida por um ser período de tempo."
-#, fuzzy
msgid ""
"When rebooting the system, the watchcat will trigger a soft reboot. Entering "
"a non zero value here will trigger a delayed hard reboot if the soft reboot "
--- /dev/null
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.8.11\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Language: pt_BR\n"
+
+msgid "Activate wifi"
+msgstr "Ativar a WiFi"
+
+msgid "Could not find required /usr/bin/wifi_schedule.sh or /sbin/wifi"
+msgstr ""
+"Não foi possível localizar os programas necessários '/usr/bin/wifi_schedule."
+"sh' ou '/sbin/wifi'."
+
+msgid "Could not find required programm /usr/bin/iwinfo"
+msgstr "Não foi possível localizar o programa necessário '/usr/bin/iwinfo'"
+
+msgid "Cron Jobs"
+msgstr "Tarefas da Cron"
+
+msgid "Day(s) of Week"
+msgstr "Dia(s) da semana"
+
+msgid "Defines a schedule when to turn on and off wifi."
+msgstr "Define um agendamento para quando ligar ou desligar a WiFi."
+
+msgid "Determine Modules Automatically"
+msgstr "Determinar os Módulos Automaticamente"
+
+msgid "Disable wifi gracefully"
+msgstr "Desabilitar a WiFi amistosamente"
+
+msgid "Disabled wifi forced"
+msgstr "WiFi foi desabilitada de forma forçada."
+
+msgid "Enable"
+msgstr "Habilitar"
+
+msgid "Enable Wifi Schedule"
+msgstr "Habilitar o agendamento da WiFi"
+
+msgid "Enable logging"
+msgstr "Habilite os registros (log)"
+
+msgid "Force disabling wifi even if stations associated"
+msgstr "Force a desativação da WiFi mesmo se existirem estações associadas "
+
+msgid "Friday"
+msgstr "Sexta-feira"
+
+msgid "Global Settings"
+msgstr "Configurações Globais"
+
+msgid "Monday"
+msgstr "Segunda-Feira"
+
+msgid "Saturday"
+msgstr "Sábado"
+
+msgid "Schedule"
+msgstr "Agendamento"
+
+msgid "Schedule events"
+msgstr "Eventos do agendamento"
+
+msgid "Start Time"
+msgstr "Hora Inicial"
+
+msgid "Start WiFi"
+msgstr "Iniciar WiFi"
+
+msgid "Stop Time"
+msgstr "Hora Final"
+
+msgid "Stop WiFi"
+msgstr "Parar WiFi"
+
+msgid "Sunday"
+msgstr "Domingo"
+
+msgid "The value %s is invalid"
+msgstr "O valor %s é inválido"
+
+msgid "Thursday"
+msgstr "Quita-feira"
+
+msgid "Tuesday"
+msgstr "Terça-feira"
+
+msgid "Unload Modules (experimental; saves more power)"
+msgstr "Descarregar Módulos (experimental, poupa mais energia)"
+
+msgid "View Cron Jobs"
+msgstr "Visualizar Tarefas da Cron"
+
+msgid "View Logfile"
+msgstr "Visualizar o Arquivo de Registros (log)"
+
+msgid "Wednesday"
+msgstr "Quarta-feira"
+
+msgid "Wifi Schedule"
+msgstr "Agendamento da Wifi"
+
+msgid "Wifi Schedule Logfile"
+msgstr "Arquivo de Registros (log) do Agendamento da Wifi"
#
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
+"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-04-19 00:29+0200\n"
-"PO-Revision-Date: 2011-10-11 20:31+0200\n"
-"Last-Translator: Luiz Angelo <luizluca@gmail.com>\n"
+"PO-Revision-Date: 2017-02-20 18:13-0300\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
"Language-Team: none\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-"X-Generator: Pootle 2.0.4\n"
+"X-Generator: Poedit 1.8.11\n"
msgid "Broadcast on all interfaces"
msgstr "Broadcast em todas as interfaces"
msgid "Network interface to use"
msgstr "Interfaces de rede para usar"
-#, fuzzy
msgid ""
"Sometimes only one of the two tools works. If one fails, try the other one"
msgstr ""
-"Algumas vezes, somente uma das ferramentas funciona. Se uma delas falhar, "
-"tente a outra"
+"Algumas vezes, somente uma das duas ferramentas funciona. Se uma delas "
+"falhar, tente a outra"
msgid "Specifies the interface the WoL packet is sent on"
msgstr "Especifica a interface para onde os pacotes de WoL serão enviados"
msgid "WoL program"
msgstr "Programa WoL"
+
+#~ msgid "Send to broadcast address"
+#~ msgstr "Enviar para o endereço de broadcast"
LUCI_TITLE:=LuCI with HTTPS support (OpenSSL as SSL backend)
LUCI_DESCRIPTION:=LuCI with OpenSSL as the SSL backend (libustream-openssl). \
- Note: px5g still requires libmbedtls (in LEDE) or libpolarssl (in Openwrt). \
- In LEDE it is also possible to replace px5g with openssl-util as uhttpd can \
- also generate keys with openssl commandline tools if px5g is not installed.
-LUCI_DEPENDS:=+luci +libustream-openssl +px5g
+ OpenSSL cmd tools (openssl-util) are used by uhttpd for SSL key generation \
+ instead of the default px5g. (If px5g is installed, uhttpd will prefer that.)
+
+LUCI_DEPENDS:=+luci +libustream-openssl +openssl-util
include ../../luci.mk
LUCI_BASENAME:=ssl
LUCI_TITLE:=LuCI with HTTPS support (mbedTLS as SSL backend)
-LUCI_DEPENDS:=+luci +libustream-mbedtls +px5g-mbedtls
+LUCI_DEPENDS:=+luci +libustream-mbedtls +px5g
include ../../luci.mk
include $(TOPDIR)/rules.mk
PKG_NAME:=freifunk-common
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_GITBRANCH?=$(if $(DUMP),x,$(strip $(shell \
variant="LuCI"; \
if git log -1 >/dev/null 2>/dev/null; then \
- branch="$$(git symbolic-ref --short -q HEAD 2>/dev/null)"; \
+ branch="$$(git branch --remote --verbose --no-abbrev --contains 2>/dev/null | \
+ sed -rne 's|^[^/]+/([^ ]+) [a-f0-9]{40} .+$$|\1|p' | head -n1)"; \
if [ "$$branch" != "master" ]; then \
variant="LuCI $$branch branch"; \
else \
return false;
},
+ 'ipmask': function()
+ {
+ return cbi_validators.ipmask4.apply(this) ||
+ cbi_validators.ipmask6.apply(this);
+ },
+
+ 'ipmask4': function()
+ {
+ var ip = this, mask = 32;
+
+ if (ip.match(/^(\S+)\/(\S+)$/))
+ {
+ ip = RegExp.$1;
+ mask = RegExp.$2;
+ }
+
+ if (!isNaN(mask) && (mask < 0 || mask > 32))
+ return false;
+
+ if (isNaN(mask) && !cbi_validators.ip4addr.apply(mask))
+ return false;
+
+ return cbi_validators.ip4addr.apply(ip);
+ },
+
+ 'ipmask6': function()
+ {
+ var ip = this, mask = 128;
+
+ if (ip.match(/^(\S+)\/(\S+)$/))
+ {
+ ip = RegExp.$1;
+ mask = RegExp.$2;
+ }
+
+ if (!isNaN(mask) && (mask < 0 || mask > 128))
+ return false;
+
+ if (isNaN(mask) && !cbi_validators.ip6addr.apply(mask))
+ return false;
+
+ return cbi_validators.ip6addr.apply(ip);
+ },
+
'port': function()
{
var p = Int(this);
}
}
- nodes = document.querySelectorAll('[data-type]');
-
- for (var i = 0, node; (node = nodes[i]) !== undefined; i++) {
- cbi_validate_field(node, node.getAttribute('data-optional') === 'true',
- node.getAttribute('data-type'));
- }
-
nodes = document.querySelectorAll('[data-choices]');
for (var i = 0, node; (node = nodes[i]) !== undefined; i++) {
cbi_dynlist_init(node, choices[2], choices[3], options);
}
+ nodes = document.querySelectorAll('[data-type]');
+
+ for (var i = 0, node; (node = nodes[i]) !== undefined; i++) {
+ cbi_validate_field(node, node.getAttribute('data-optional') === 'true',
+ node.getAttribute('data-type'));
+ }
+
cbi_d_update();
}
return ( val and val >= 0 and val <= 128 )
end
+function ipmask(val)
+ return ipmask4(val) or ipmask6(val)
+end
+
+function ipmask4(val)
+ local ip, mask = val:match("^([^/]+)/([^/]+)$")
+ local bits = tonumber(mask)
+
+ if bits and (bits < 0 or bits > 32) then
+ return false
+ end
+
+ if not bits and mask and not ip4addr(mask) then
+ return false
+ end
+
+ return ip4addr(ip or val)
+end
+
+function ipmask6(val)
+ local ip, mask = val:match("^([^/]+)/([^/]+)$")
+ local bits = tonumber(mask)
+
+ if bits and (bits < 0 or bits > 128) then
+ return false
+ end
+
+ if not bits and mask and not ip6addr(mask) then
+ return false
+ end
+
+ return ip6addr(ip or val)
+end
+
+function ip6hostid(val)
+ if val and val:match("^[a-fA-F0-9:]+$") and (#val > 2) then
+ return (ip6addr("2001:db8:0:0" .. val) or ip6addr("2001:db8:0:0:" .. val))
+ end
+
+ return false
+end
+
function port(val)
val = tonumber(val)
return ( val and val >= 0 and val <= 65535 )
end
end
+function hexstring(val)
+ if val then
+ return (val:match("^[a-fA-F0-9]+$") ~= nil)
+ end
+ return false
+end
+
+function hex(val, maxbytes)
+ maxbytes = tonumber(maxbytes)
+ if val and maxbytes ~= nil then
+ return ((val:match("^0x[a-fA-F0-9]+$") ~= nil) and (#val <= 2 + maxbytes * 2))
+ end
+ return false
+end
+
+function base64(val)
+ if val then
+ return (val:match("^[a-zA-Z0-9/+]+=?=?$") ~= nil) and (math.fmod(#val, 4) == 0)
+ end
+ return false
+end
+
function string(val)
return true -- Everything qualifies as valid string
end
return false;
end
- local days_in_month = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
-
- local function is_leap_year(year)
- return (year % 4 == 0) and ((year % 100 ~= 0) or (year % 400 == 0))
- end
-
- function get_days_in_month(month, year)
- if (month == 2) and is_leap_year(year) then
- return 29
- else
- return days_in_month[month]
- end
- end
- if (year < 2015) then
- return false
- end
- if ((month == 0) or (month > 12)) then
- return false
- end
- if ((day == 0) or (day > get_days_in_month(month, year))) then
- return false
- end
- return true
+ local days_in_month = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
+
+ local function is_leap_year(year)
+ return (year % 4 == 0) and ((year % 100 ~= 0) or (year % 400 == 0))
+ end
+
+ function get_days_in_month(month, year)
+ if (month == 2) and is_leap_year(year) then
+ return 29
+ else
+ return days_in_month[month]
+ end
+ end
+ if (year < 2015) then
+ return false
+ end
+ if ((month == 0) or (month > 12)) then
+ return false
+ end
+ if ((day == 0) or (day > get_days_in_month(month, year))) then
+ return false
+ end
+ return true
end
return false
end
return dns
end
+function protocol.ip6prefix(self)
+ local prefix = self:_ubus("ipv6-prefix")
+ if prefix and #prefix > 0 then
+ return "%s/%d" %{ prefix[1].address, prefix[1].mask }
+ end
+end
+
function protocol.is_bridge(self)
return (not self:is_virtual() and self:type() == "bridge")
end
<label<%= attr("for", cbid.."-"..key)%>></label>
<%=pcdata(self.vallist[i])%>
</label>
- <% if i == self.size then write('<br />') end %>
+ <% if self.size and (i % self.size) == 0 then write('<br />') end %>
<% end %>
</div>
<% end %>
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Càrrega d'1 minut:"
msgid "15 Minute Load:"
msgstr "Càrrega de 15 minuts:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Càrrega de 5 minuts:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr "Inhabilitat"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "Descarta les respostes RFC1918 des de dalt"
msgid "Enabled"
msgstr "Habilitat"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "Habilita l'Spanning Tree Protocol a aquest pont"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr ""
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "Adreça IP"
msgid "IPv6-Address"
msgstr "Adreça IPv6"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6-en-IPv4 (RFC4213)"
"requests to"
msgstr ""
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr "Manca l'extensió de protocol del protocol %q"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Mode"
msgid "Option removed"
msgstr "Opció treta"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr "PIN"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr "Calidad"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr ""
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr ""
msgid "Receiver Antenna"
msgstr "Antena receptora"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Reconnex aquesta interfície"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr "Alguns ISP ho requereixen, per exemple el Charter amb DOCSIS 3"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "Dispositiu USB"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr ""
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "etiquetat"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "desconegut"
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Zatížení za 1 minutu:"
msgid "15 Minute Load:"
msgstr "Zatížení za 15 minut:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Zatížení za 5 minut:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr "Zakázáno"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "Vyřadit upstream RFC1918 odpovědi"
msgid "Enabled"
msgstr "Povoleno"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "Na tomto síťovém mostě povolit Spanning Tree Protocol"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "Externí protokolovací server"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "IP adresy"
msgid "IPv6-Address"
msgstr "IPv6 adresa"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6-in-IPv4 (RFC4213)"
"Seznam <abbr title=\"Domain Name System\">DNS</abbr> serverů, na které "
"přeposílat požadavky"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr "Chybějící rozšíření protokolu %q"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Mód"
msgid "Option removed"
msgstr "Volba odstraněna"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr "PIN"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr "Kvalita"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr "Wireless v reálném čase"
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr "Opětovné nastavení ochrany"
msgid "Receiver Antenna"
msgstr "Přijímací anténa"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Přepojit toto rozhraní"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
# Charter je poskytovate
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr "Vyžadováno u některých ISP, např. Charter s DocSIS 3"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "USB zařízení"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr ""
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "označený"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "neznámý"
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Systemlast (1 Minute):"
msgid "15 Minute Load:"
msgstr "Systemlast (15 Minuten):"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Systemlast (5 Minuten):"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr "Deaktiviert"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "Eingehende RFC1918-Antworten verwerfen"
msgid "Enabled"
msgstr "Aktiviert"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "Aktiviert das Spanning Tree Protokoll auf dieser Netzwerkbrücke"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "Externer Protokollserver IP"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "IP-Adresse"
msgid "IPv6-Address"
msgstr "IPv6-Adresse"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6-in-IPv4 (RFC4213)"
"Liste von <abbr title=\"Domain Name System\">DNS</abbr>-Servern an welche "
"Requests weitergeleitet werden"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr "Erweiterung für Protokoll %q fehlt"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Modus"
msgid "Option removed"
msgstr "Option entfernt"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr "PIN"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr "Qualität"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr "Echtzeit-WLAN-Signal"
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr "DNS-Rebind-Schutz"
msgid "Receiver Antenna"
msgstr "Empfangsantenne"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Diese Schnittstelle neu verbinden"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr ""
"Wird von bestimmten Internet-Providern benötigt, z.B. Charter mit DOCSIS 3"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "USB-Gerät"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr "Benutzer Schlüsselindex"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "tagged"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "unbekannt"
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Φορτίο 1 λεπτού:"
msgid "15 Minute Load:"
msgstr "Φορτίο 15 λεπτών:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Φορτίο 5 λεπτών:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr "Απενεργοποιημένο"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "Αγνόησε τις απαντήσεις ανοδικής ροής RFC1918"
msgid "Enabled"
msgstr "Ενεργοποιημένο"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr ""
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "Εξωτερικός εξυπηρετητής καταγραφής συστήματος"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "Διεύθυνση IP"
msgid "IPv6-Address"
msgstr ""
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6-in-IPv4 (RFC4213)"
"requests to"
msgstr ""
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr ""
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Λειτουργία"
msgid "Option removed"
msgstr "Η επιλογή αφαιρέθηκε"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr "PIN"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr ""
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr ""
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr ""
msgid "Receiver Antenna"
msgstr "Κεραία Λήψης"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Επανασύνδεση της διεπαφής"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr ""
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "Συσκευή USB"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr "Χρησιμοποιούμενη Υποδοχή Κλειδιού"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr ""
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr ""
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "1 Minute Load:"
msgid "15 Minute Load:"
msgstr "15 Minute Load:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "5 Minute Load:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr "Disabled"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr ""
msgid "Enabled"
msgstr "Enabled"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "Enables the Spanning Tree Protocol on this bridge"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr ""
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "IP address"
msgid "IPv6-Address"
msgstr ""
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr ""
"requests to"
msgstr ""
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr ""
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Mode"
msgid "Option removed"
msgstr ""
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr ""
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr ""
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr ""
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr ""
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr ""
msgid "Receiver Antenna"
msgstr "Receiver Antenna"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr ""
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr ""
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr ""
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr ""
msgid "Used Key Slot"
msgstr ""
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr ""
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr ""
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Carga a 1 minuto:"
msgid "15 Minute Load:"
msgstr "Carga a 15 minutos:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Carga a 5 minutos:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr ""
"<abbr title=\"Identificador de conjunto de servicios básicos\">BSSID</abbr>"
msgid "Disabled"
msgstr "Desactivar"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "Descartar respuestas RFC1918 salientes"
msgid "Enabled"
msgstr "Activado"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "Activa el protocol STP en este puente"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "Servidor externo de registro del sistema"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "Dirección IP"
msgid "IPv6-Address"
msgstr "Dirección IPv6"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6-en-IPv4 (RFC4213)"
"Lista de servidores <abbr title=\"Domain Name System\">DNS</abbr> a los que "
"enviar solicitudes"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr "Extensión de protocolo faltante para %q"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Modo"
msgid "Option removed"
msgstr "Opción eliminada"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr "PIN"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr "Calidad"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr "Red inalámbrica en tiempo real"
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr "Protección contra reasociación"
msgid "Receiver Antenna"
msgstr "Antena Receptora"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Reconectar esta interfaz"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr "Necesario para ciertos ISPs, por ejemplo Charter con DOCSIS 3"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "Dispositivo USB"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr "Espacio de clave usado"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "marcado"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "desconocido"
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Charge sur 1 minute :"
msgid "15 Minute Load:"
msgstr "Charge sur 15 minutes :"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Charge sur 5 minutes :"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr "Désactivé"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "Jeter les réponses en RFC1918 amont"
msgid "Enabled"
msgstr "Activé"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr ""
"Activer le protocole <abbr title=\"Spanning Tree Protocol\">STP</abbr> sur "
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "Serveur distant de journaux système"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "Adresse IP"
msgid "IPv6-Address"
msgstr "Adresse IPv6"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6 dans IPv4 (RFC 4213)"
"Liste des serveurs auquels sont transmis les requêtes <abbr title=\"Domain "
"Name System\">DNS</abbr>"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr "Extention de protocole manquante pour le proto %q"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Mode"
msgid "Option removed"
msgstr "Option retirée"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr "code PIN"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr "Qualitée"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr "Qualité de réception actuelle"
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr "Protection contre l'attaque « rebind »"
msgid "Receiver Antenna"
msgstr "Antenne émettrice"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Reconnecter cet interface"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr "Nécessaire avec certains FAIs, par ex. : Charter avec DOCSIS 3"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "Périphérique USB"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr "Clé utilisée"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "marqué"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "inconnu"
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "עומס במשך דקה:"
msgid "15 Minute Load:"
msgstr "עומס במשך רבע שעה:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "עומס במשך 5 דקות:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr ""
msgid "Disabled"
msgstr ""
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr ""
msgid "Enabled"
msgstr "אפשר"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr ""
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr ""
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr ""
msgid "IPv6-Address"
msgstr ""
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr ""
"requests to"
msgstr ""
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr ""
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr ""
msgid "Option removed"
msgstr ""
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr ""
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr ""
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr ""
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr ""
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr ""
msgid "Receiver Antenna"
msgstr ""
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr ""
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr ""
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr ""
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr ""
msgid "Used Key Slot"
msgstr ""
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "מתויג"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr ""
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Terhelés (utolsó 1 perc):"
msgid "15 Minute Load:"
msgstr "Terhelés (utolsó 15 perc):"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Terhelés (utolsó 5 perc):"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr "Letiltva"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "Beérkező RFC1918 DHCP válaszok elvetése. "
msgid "Enabled"
msgstr "Engedélyezve"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "A Spanning Tree prokoll engedélyezése erre a hídra"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "Külső rendszernapló kiszolgáló"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "IP cím"
msgid "IPv6-Address"
msgstr "IPv6-cím"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6 IPv4-ben (RFC4213)"
"<abbr title=\"Domain Name System\">DNS</abbr> szerverek listája, ahová a "
"kérések továbbításra kerülnek"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr "Hiányzó protokoll kiterjesztés a %q progokoll számára"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Mód"
msgid "Option removed"
msgstr "Beállítás eltávolítva"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr "PIN"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr "Minőség"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr "Valósidejű vezetéknélküli adatok"
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr "Rebind elleni védelem"
msgid "Receiver Antenna"
msgstr "Vevő antenna"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Csatlakoztassa újra az interfészt"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr ""
"Szükséges bizonyos internetszolgáltatók esetén, pl. Charter 'DOCSIS 3'-al"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "USB eszköz"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr "Használt kulcsindex"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "cimkézett"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "ismeretlen"
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Carico in 1 minuto:"
msgid "15 Minute Load:"
msgstr "Carico in 15 minut:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Carico in 5 minuti:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr ""
"<abbr title=\"Servizio basilare di impostazione Identificatore\">BSSID</abbr>"
msgid "Disabled"
msgstr "Disabilitato"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "Ignora risposte RFC1918 upstream"
msgid "Enabled"
msgstr "Abilitato"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "Abilita il protocollo di Spanning Tree su questo bridge"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "Server Log di Sistema esterno"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "Indirizzo IP"
msgid "IPv6-Address"
msgstr "Indirizzo-IPv6"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6-in-IPv4 (RFC4213)"
"Elenco di Server <abbr title=\"Sistema Nome Dimio\">DNS</abbr>a cui "
"inoltrare le richieste in"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr ""
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Modalità"
msgid "Option removed"
msgstr "Opzione cancellata"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr ""
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr ""
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr ""
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr ""
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr ""
msgid "Receiver Antenna"
msgstr "Antenna ricevente"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Ricollega questa interfaccia"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr ""
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr ""
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr ""
msgid "Used Key Slot"
msgstr "Slot Chiave Usata"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "etichettato"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "sconosciuto"
msgid "-- match by label --"
msgstr "-- ラベルで設定 --"
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "過去1分の負荷:"
msgid "15 Minute Load:"
msgstr "過去15分の負荷:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "過去5分の負荷:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr "無効"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "RFC1918の応答を破棄します"
msgid "Enabled"
msgstr "有効"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "スパニングツリー・プロトコルを有効にする"
msgid "External"
msgstr "外部"
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "外部システムログ・サーバー"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "IPアドレス"
msgid "IPv6-Address"
msgstr "IPv6-アドレス"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6-in-IPv4 (RFC4213)"
"問い合わせを転送する<abbr title=\"Domain Name System\">DNS</abbr> サーバーの"
"リストを設定します"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr "認証用 SSH暗号キー ファイルのリスト"
msgid "Missing protocol extension for proto %q"
msgstr "プロトコル %qのプロトコル拡張が見つかりません"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "モード"
msgid "Option removed"
msgstr "削除されるオプション"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr "PIN"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr "事前共有鍵"
msgid "Quality"
msgstr "クオリティ"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr "リアルタイム・無線LAN"
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr "DNSリバインディング・プロテクション"
msgid "Receiver Antenna"
msgstr "受信アンテナ"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "インターフェースの再接続"
msgid "Require TLS"
msgstr "TLSが必要"
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr "DOCSIS 3.0を使用するいくつかのISPでは必要になります"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "USBデバイス"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr "使用するキースロット"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "tagged"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "不明"
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "1 분 부하:"
msgid "15 Minute Load:"
msgstr "15 분 부하:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "5 분 부하:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr ""
msgid "Disabled"
msgstr ""
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr ""
msgid "Enabled"
msgstr "활성화됨"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "이 bridge 에 Spanning Tree Protocol 활성화합니다"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "외부 system log 서버"
msgstr ""
msgid "Go to password configuration..."
-msgstr ""
+msgstr "암호 설정 하기"
msgid "Go to relevant configuration page"
msgstr ""
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "IP 주소"
msgid "IPv6-Address"
msgstr "IPv6-주소"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr ""
"requests to"
msgstr ""
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr ""
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr ""
msgstr ""
msgid "No password set!"
-msgstr ""
+msgstr "암호 설정을 해주세요!"
msgid "No rules in this chain"
msgstr ""
msgid "Option removed"
msgstr "삭제된 option"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr ""
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr ""
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr ""
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr ""
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr ""
msgid "Receiver Antenna"
msgstr ""
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "이 인터페이스를 재연결합니다"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr "특정 ISP 들에 요구됨. 예: Charter (DOCSIS 3 기반)"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgstr ""
msgid "Services"
-msgstr "Services"
+msgstr "서비스"
msgid "Set up Time Synchronization"
msgstr ""
"There is no password set on this router. Please configure a root password to "
"protect the web interface and enable SSH."
msgstr ""
+"이 공유기에 암호 설정이 되지 않았습니다. 웹 UI 와 SSH 부분을 보호하기 위해서 "
+"꼭 root 암호를 설정해 주세요."
msgid "This IPv4 address of the relay"
msgstr ""
msgid "USB Device"
msgstr ""
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr ""
msgid "Used Key Slot"
msgstr ""
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr ""
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr ""
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr ""
msgid "15 Minute Load:"
msgstr ""
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr ""
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr ""
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr ""
msgid "Enabled"
msgstr ""
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "Aktifkan spanning Tree Protokol di jambatan ini"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr ""
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "Alamat IP"
msgid "IPv6-Address"
msgstr ""
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr ""
"requests to"
msgstr ""
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr ""
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Mode"
msgid "Option removed"
msgstr ""
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr ""
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr ""
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr ""
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr ""
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr ""
msgid "Receiver Antenna"
msgstr "Antena Penerima"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr ""
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr ""
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr ""
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr ""
msgid "Used Key Slot"
msgstr ""
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr ""
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr ""
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "1 minutts belastning:"
msgid "15 Minute Load:"
msgstr "15 minutters belastning:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "5 minutters belastning:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr "Deaktivert"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "Forkast oppstrøms RFC1918 svar"
msgid "Enabled"
msgstr "Aktivert"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "Aktiverer Spanning Tree Protocol på denne broen"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "Ekstern systemlogg server"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "IP adresse"
msgid "IPv6-Address"
msgstr "IPv6-Adresse"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6-i-IPv4 (RFC4213)"
"Liste med <abbr title=\"Domain Name System\">DNS</abbr> servere som "
"forespørsler blir videresendt til"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr "Mangler protokoll utvidelse for proto %q"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Modus"
msgid "Option removed"
msgstr "Innstilling fjernet"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr "PIN"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr "Kvalitet"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr "Trådløst i sanntid"
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr "Binde beskyttelse"
msgid "Receiver Antenna"
msgstr "Mottak antenne"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Koble til igjen"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr "Er nødvendig for noen nettleverandører, f.eks Charter med DOCSIS 3"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "USB Enhet"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr "Brukte Nøkler"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "tagget"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "ukjent"
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Obciążenie 1 min.:"
msgid "15 Minute Load:"
msgstr "Obciążenie 15 min.:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Obciążenie 5 min.:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr "Wyłączony"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "Odrzuć wychodzące odpowiedzi RFC1918"
msgid "Enabled"
msgstr "Włączony"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr ""
"Włącz protokół <abbr title=\"Spanning Tree Protocol\">STP</abbr> na tym "
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "Zewnętrzny serwer dla loga systemowego"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "Adres IP"
msgid "IPv6-Address"
msgstr "Adres IPv6"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6-w-IPv4 (RFC4213)"
"Lista serwerów <abbr title=\"Domain Name System\">DNS</abbr> do których będą "
"przekazywane zapytania"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr "Brakujące rozszerzenie protokołu dla protokołu %q"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Tryb"
msgid "Option removed"
msgstr "Usunięto wartość"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr "PIN"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr "Jakość"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr "WiFi w czasie rzeczywistym"
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr "Przypisz ochronę"
msgid "Receiver Antenna"
msgstr "Antena odbiorcza"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Połącz ponownie ten interfejs"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr "Wymagany dla niektórych dostawców internetu, np. Charter z DOCSIS 3"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "Urządzenie USB"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr "Użyte gniazdo klucza"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "tagowane"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "nieznane"
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
+"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-06-10 03:41+0200\n"
-"PO-Revision-Date: 2014-03-29 23:31+0200\n"
-"Last-Translator: Luiz Angelo <luizluca@gmail.com>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
+"PO-Revision-Date: 2017-02-22 20:30-0300\n"
+"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-"X-Generator: Pootle 2.0.6\n"
+"X-Generator: Poedit 1.8.11\n"
+"Language-Team: \n"
msgid "%s is untagged in multiple VLANs!"
-msgstr ""
+msgstr "%s está sem etiqueta em múltiplas VLANs!"
msgid "(%d minute window, %d second interval)"
msgstr "(janela de %d minutos, intervalo de %d segundos)"
msgstr "-- personalizado --"
msgid "-- match by device --"
-msgstr ""
+msgstr "-- casar por dispositivo --"
msgid "-- match by label --"
+msgstr "-- casar por rótulo --"
+
+msgid "-- match by uuid --"
msgstr ""
+"-- casar por <abbr title=\"Universal Unique IDentifier/Identificador Único "
+"Universal\">UUID</abbr> --"
msgid "1 Minute Load:"
msgstr "Carga 1 Minuto:"
msgid "15 Minute Load:"
msgstr "Carga 15 Minutos:"
+msgid "4-character hexadecimal ID"
+msgstr "Identificador hexadecimal de 4 caracteres"
+
msgid "464XLAT (CLAT)"
-msgstr ""
+msgstr "464XLAT (CLAT)"
msgid "5 Minute Load:"
msgstr "Carga 5 Minutos:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+"Identificador de 6 octetos como uma cadeia hexadecimal - sem dois pontos"
+
+msgid "802.11r Fast Transition"
+msgstr "802.11r Fast Transition"
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr "Tempo de expiração máximo da consulta da Associação SA do 802.11w"
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+"Tempo de expiração de tentativa de consulta da Associação SA do 802.11w"
+
+msgid "802.11w Management Frame Protection"
+msgstr "Proteção do Quadro de Gerenciamento do 802.11w"
+
+msgid "802.11w maximum timeout"
+msgstr "Estouro de tempo máximo do 802.11w"
+
+msgid "802.11w retry timeout"
+msgstr "Estouro de tempo da nova tentativa do 802.11w"
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr ""
"<abbr title=\"Identificador de Conjunto Básico de Serviços\">BSSID</abbr>"
msgid "<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Suffix (hex)"
msgstr ""
+"<abbr title=\"Internet Protocol Version 6/Protocolo Internet Versão "
+"6\">IPv6</abbr>-Suffix (hex)"
msgid "<abbr title=\"Light Emitting Diode\">LED</abbr> Configuration"
msgstr "Configuração do <abbr title=\"Diodo Emissor de Luz\">LED</abbr>"
msgstr "<abbr title='Par: %s / Grupo: %s'>%s - %s</abbr>"
msgid "A43C + J43 + A43"
-msgstr ""
+msgstr "A43C + J43 + A43"
msgid "A43C + J43 + A43 + V43"
-msgstr ""
+msgstr "A43C + J43 + A43 + V43"
msgid "ADSL"
msgstr ""
+"<abbr title=\"Assymetrical Digital Subscriber Line/Linha Digital Assimétrica "
+"para Assinante\">ADSL</abbr>"
msgid "AICCU (SIXXS)"
msgstr ""
+"<abbr title=\"Automatic IPv6 Connectivity Client Utility/Utilitário Cliente "
+"de Conectividade IPv6 Automática\">AICCU (SIXXS)</abbr>"
msgid "ANSI T1.413"
-msgstr ""
+msgstr "ANSI T1.413"
msgid "APN"
msgstr "<abbr title=\"Access Point Name\">APN</abbr>"
"abbr>"
msgid "ATM (Asynchronous Transfer Mode)"
-msgstr ""
+msgstr "ATM (Asynchronous Transfer Mode)"
msgid "ATM Bridges"
msgstr "Ponte ATM"
msgid "ATM Virtual Channel Identifier (VCI)"
-msgstr "Identificador de Canal Virtual ATM (VCI)"
+msgstr ""
+"Identificador de Canal Virtual ATM (<abbr title=\"Virtual Channel Identifier"
+"\">VCI</abbr>)"
msgid "ATM Virtual Path Identifier (VPI)"
-msgstr "Identificador de Caminho Virtual ATM (VPI)"
+msgstr ""
+"Identificador de Caminho Virtual ATM (<abbr title=\"Virtual Path Identifier"
+"\">VPI</abbr>)"
msgid ""
"ATM bridges expose encapsulated ethernet in AAL5 connections as virtual "
msgstr "Número do dispositivo ATM"
msgid "ATU-C System Vendor ID"
-msgstr ""
+msgstr "Identificador de"
msgid "AYIYA"
-msgstr ""
+msgstr "AYIYA"
msgid "Access Concentrator"
msgstr "Concentrador de Acesso"
msgstr "Arquivos adicionais de equipamentos conhecidos (hosts)"
msgid "Additional servers file"
-msgstr ""
+msgstr "Arquivo de servidores adicionais"
msgid "Address"
msgstr "Endereço"
msgid "Aggregate Transmit Power(ACTATP)"
msgstr ""
+"Potência de Transmissão Agregada (<abbr title=\"Aggregate Transmit Power"
+"\">ACTATP</abbr>)"
msgid "Alert"
msgstr "Alerta"
"Allocate IP addresses sequentially, starting from the lowest available "
"address"
msgstr ""
+"Alocar endereços IP sequencialmente, iniciando a partir do endereço mais "
+"baixo disponível"
msgid "Allocate IP sequentially"
-msgstr ""
+msgstr "Alocar endereços IP sequencialmente"
msgid "Allow <abbr title=\"Secure Shell\">SSH</abbr> password authentication"
msgstr ""
"exemplo, para os serviços RBL"
msgid "Allowed IPs"
-msgstr ""
+msgstr "Endereços IP autorizados"
msgid ""
"Also see <a href=\"https://www.sixxs.net/faq/connectivity/?faq=comparison"
"\">Tunneling Comparison</a> on SIXXS"
msgstr ""
+"Veja também a <a href=\"https://www.sixxs.net/faq/connectivity/?"
+"faq=comparison\">Comparação de Tunelamentos</a> em SIXXS"
msgid "Always announce default router"
-msgstr ""
+msgstr "Sempre anuncie o roteador padrão"
msgid "Annex"
-msgstr ""
+msgstr "Anexo"
msgid "Annex A + L + M (all)"
-msgstr ""
+msgstr "Anexos A + L + M (todo)"
msgid "Annex A G.992.1"
-msgstr ""
+msgstr "Anexo A G.992.1"
msgid "Annex A G.992.2"
-msgstr ""
+msgstr "Anexo A G.992.2"
msgid "Annex A G.992.3"
-msgstr ""
+msgstr "Anexo A G.992.3"
msgid "Annex A G.992.5"
-msgstr ""
+msgstr "Anexo A G.992.5"
msgid "Annex B (all)"
-msgstr ""
+msgstr "Anexo B (todo)"
msgid "Annex B G.992.1"
-msgstr ""
+msgstr "Anexo B G.992.1"
msgid "Annex B G.992.3"
-msgstr ""
+msgstr "Anexo B G.992.3"
msgid "Annex B G.992.5"
-msgstr ""
+msgstr "Anexo B G.992.5"
msgid "Annex J (all)"
-msgstr ""
+msgstr "Anexo J (todo)"
msgid "Annex L G.992.3 POTS 1"
-msgstr ""
+msgstr "Anexo L G.992.3 POTS 1"
msgid "Annex M (all)"
-msgstr ""
+msgstr "Anexo M (todo)"
msgid "Annex M G.992.3"
-msgstr ""
+msgstr "Anexo M G.992.3"
msgid "Annex M G.992.5"
-msgstr ""
+msgstr "Anexo M G.992.5"
msgid "Announce as default router even if no public prefix is available."
msgstr ""
+"Anuncie-se como rotador padrão mesmo se não existir um prefixo público."
msgid "Announced DNS domains"
-msgstr ""
+msgstr "Domínios DNS anunciados"
msgid "Announced DNS servers"
-msgstr ""
+msgstr "Servidores DNS anunciados"
msgid "Anonymous Identity"
-msgstr ""
+msgstr "Identidade Anônima"
msgid "Anonymous Mount"
-msgstr ""
+msgstr "Montagem Anônima"
msgid "Anonymous Swap"
-msgstr ""
+msgstr "Espaço de Troca (swap) Anônimo"
msgid "Antenna 1"
msgstr "Antena 1"
msgid ""
"Assign a part of given length of every public IPv6-prefix to this interface"
msgstr ""
+"Atribua uma parte do comprimento de cada prefixo IPv6 público para esta "
+"interface"
msgid "Assign interfaces..."
msgstr "atribuir as interfaces"
msgid ""
"Assign prefix parts using this hexadecimal subprefix ID for this interface."
msgstr ""
+"Atribua partes do prefixo usando este identificador hexadecimal do "
+"subprefixo para esta interface"
msgid "Associated Stations"
msgstr "Estações associadas"
msgstr "Controlador Wireless Atheros 802.11%s"
msgid "Auth Group"
-msgstr ""
+msgstr "Grupo de Autenticação"
msgid "AuthGroup"
-msgstr ""
+msgstr "Grupo de Autenticação"
msgid "Authentication"
msgstr "Autenticação"
msgid "Authentication Type"
-msgstr ""
+msgstr "Tipo de Autenticação"
msgid "Authoritative"
msgstr "Autoritário"
msgstr "Atualização Automática"
msgid "Automatic"
-msgstr ""
+msgstr "Automático"
msgid "Automatic Homenet (HNCP)"
msgstr ""
+"Rede Doméstica Automática (<abbr title=\"Homenet Control Protocol\">HNCP</"
+"abbr>)"
msgid "Automatically check filesystem for errors before mounting"
msgstr ""
+"Execute automaticamente a verificação do sistema de arquivos antes da "
+"montagem do dispositivo"
msgid "Automatically mount filesystems on hotplug"
-msgstr ""
+msgstr "Monte automaticamente o espaço de troca (swap) ao conectar"
msgid "Automatically mount swap on hotplug"
-msgstr ""
+msgstr "Monte automaticamente o espaço de troca (swap) ao conectar"
msgid "Automount Filesystem"
-msgstr ""
+msgstr "Montagem Automática de Sistema de Arquivo"
msgid "Automount Swap"
-msgstr ""
+msgstr "Montagem Automática do Espaço de Troca (swap) "
msgid "Available"
msgstr "Disponível"
msgstr "Média:"
msgid "B43 + B43C"
-msgstr ""
+msgstr "B43 + B43C"
msgid "B43 + B43C + V43"
-msgstr ""
+msgstr "B43 + B43C + V43"
msgid "BR / DMR / AFTR"
-msgstr ""
+msgstr "BR / DMR / AFTR"
msgid "BSSID"
msgstr "BSSID"
msgstr "Endereço especificado está incorreto!"
msgid "Band"
-msgstr ""
+msgstr "Banda"
msgid "Behind NAT"
-msgstr ""
+msgstr "Atrás da NAT"
msgid ""
"Below is the determined list of files to backup. It consists of changed "
"padrões para a cópia de segurança definidos pelo usuário."
msgid "Bind interface"
-msgstr ""
+msgstr "Interface Vinculada"
msgid "Bind only to specific interfaces rather than wildcard address."
msgstr ""
+"Vincule somente para as explicitamenteinterfaces ao invés do endereço "
+"coringa."
msgid "Bind the tunnel to this interface (optional)."
-msgstr ""
+msgstr "Vincule o túnel a esta interface (opcional)"
msgid "Bitrate"
msgstr "Taxa de bits"
"Build/distribution specific feed definitions. This file will NOT be "
"preserved in any sysupgrade."
msgstr ""
+"Fonte de pacotes específico da compilação/distribuição. Esta NÃO será "
+"preservada em qualquer atualização do sistema."
msgid "Buttons"
msgstr "Botões"
msgid "CA certificate; if empty it will be saved after the first connection."
msgstr ""
+"Certificado da CA; se em branco, será salvo depois da primeira conexão."
msgid "CPU usage (%)"
msgstr "Uso da CPU (%)"
msgstr "Cancelar"
msgid "Category"
-msgstr ""
+msgstr "Categoria"
msgid "Chain"
msgstr "Cadeia"
msgid "Check fileystems before mount"
msgstr ""
+"Execute a verificação do sistema de arquivos antes da montagem do dispositivo"
msgid "Check this option to delete the existing networks from this radio."
-msgstr ""
+msgstr "Marque esta opção para remover as redes existentes neste rádio."
msgid "Checksum"
msgstr "Soma de verificação"
msgstr "Cifra"
msgid "Cisco UDP encapsulation"
-msgstr ""
+msgstr "Encapsulamento UDP da Cisco"
msgid ""
"Click \"Generate archive\" to download a tar archive of the current "
msgstr "Limite de conexão"
msgid "Connection to server fails when TLS cannot be used"
-msgstr ""
+msgstr "A conexão para este servidor falhará quando o TLS não puder ser usado"
msgid "Connections"
msgstr "Conexões"
msgstr "Interface Personalizada"
msgid "Custom delegated IPv6-prefix"
-msgstr ""
+msgstr "Prefixo IPv6 delegado personalizado"
msgid ""
"Custom feed definitions, e.g. private feeds. This file can be preserved in a "
"sysupgrade."
msgstr ""
+"Definições de fonte de pacotes personalizadas, ex: fontes privadas. Este "
+"arquivo será preservado em uma atualização do sistema."
msgid "Custom feeds"
-msgstr ""
+msgstr "Fontes de pacotes customizadas"
msgid ""
"Customizes the behaviour of the device <abbr title=\"Light Emitting Diode"
msgstr "Alocações DHCPv6"
msgid "DHCPv6 client"
-msgstr ""
+msgstr "Cliente DHCPv6"
msgid "DHCPv6-Mode"
-msgstr ""
+msgstr "Modo DHCPv6"
msgid "DHCPv6-Service"
-msgstr ""
+msgstr "Serviço DHCPv6"
msgid "DNS"
msgstr "DNS"
msgstr "Encaminhamentos DNS"
msgid "DNS-Label / FQDN"
-msgstr ""
+msgstr "Rótulo DNS / FQDN"
msgid "DNSSEC"
-msgstr ""
+msgstr "DNSSEC"
msgid "DNSSEC check unsigned"
-msgstr ""
+msgstr "Verificar DNSSEC sem assinatura"
msgid "DPD Idle Timeout"
-msgstr ""
+msgstr "Tempo de expiração para ociosidade do DPD"
msgid "DS-Lite AFTR address"
-msgstr ""
+msgstr "Endereço DS-Lite AFTR"
msgid "DSL"
-msgstr ""
+msgstr "DSL"
msgid "DSL Status"
-msgstr ""
+msgstr "Estado da DSL"
msgid "DSL line mode"
-msgstr ""
+msgstr "Modo de linha DSL"
msgid "DUID"
msgstr "DUID"
msgid "Data Rate"
-msgstr ""
+msgstr "Taxa de Dados"
msgid "Debug"
msgstr "Depurar"
msgstr "Roteador Padrão"
msgid "Default is stateless + stateful"
-msgstr ""
+msgstr "O padrão é sem estado + com estado"
msgid "Default route"
-msgstr ""
+msgstr "Rota padrão"
msgid "Default state"
msgstr "Estado padrão"
msgstr "Configuração do Dispositivo"
msgid "Device is rebooting..."
-msgstr ""
+msgstr "O dispositivo está reiniciando..."
msgid "Device unreachable"
-msgstr ""
+msgstr "Dispositivo não alcançável"
msgid "Diagnostics"
msgstr "Diagnóstico"
msgstr "Desabilita a configuração do DNS"
msgid "Disable Encryption"
-msgstr ""
+msgstr "Desabilitar Cifragem"
msgid "Disable HW-Beacon timer"
msgstr "Desativar temporizador de Beacon de Hardware"
msgid "Disabled"
msgstr "Desabilitado"
+msgid "Disabled (default)"
+msgstr "Desabilitado (padrão)"
+
msgid "Discard upstream RFC1918 responses"
msgstr ""
"Descartar respostas de servidores externos para redes privadas (RFC1918)"
msgstr "Distância para o computador mais distante da rede (em metros)."
msgid "Distribution feeds"
-msgstr ""
+msgstr "Fontes de pacotes da distribuição"
msgid "Diversity"
msgstr "Diversidade"
msgstr "Lista branca de domínios"
msgid "Don't Fragment"
-msgstr ""
+msgstr "Não Fragmentar"
msgid ""
"Don't forward <abbr title=\"Domain Name System\">DNS</abbr>-Requests without "
"integrado"
msgid "Dual-Stack Lite (RFC6333)"
-msgstr ""
+msgstr "Duas Pilhas Leve (RFC6333)"
msgid "Dynamic <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</abbr>"
msgstr ""
"somente os clientes com atribuições estáticas serão servidos. "
msgid "EA-bits length"
-msgstr ""
+msgstr "Comprimento dos bits EA"
msgid "EAP-Method"
msgstr "Método EAP"
"Edit the raw configuration data above to fix any error and hit \"Save\" to "
"reload the page."
msgstr ""
+"Edite os dados de configuração brutos abaixo para arrumar qualquer erro e "
+"clique em \"Salvar\" para recarregar a página."
msgid "Edit this interface"
msgstr "Editar esta interface"
msgstr "Ativar a atualização de ponto final dinâmico HE.net"
msgid "Enable IPv6 negotiation"
-msgstr ""
+msgstr "Ativar a negociação de IPv6"
msgid "Enable IPv6 negotiation on the PPP link"
msgstr "Ativar a negociação de IPv6 no enlace PPP"
msgstr "Ativar o cliente <abbr title=\"Network Time Protocol\">NTP</abbr>"
msgid "Enable Single DES"
-msgstr ""
+msgstr "Habilitar DES Simples"
msgid "Enable TFTP server"
msgstr "Ativar servidor TFTP"
msgstr "Ativar funcionalidade de VLAN"
msgid "Enable WPS pushbutton, requires WPA(2)-PSK"
-msgstr ""
+msgstr "Habilite o botão WPS. requer WPA(2)-PSK"
msgid "Enable learning and aging"
msgstr "Ativar o aprendizado e obsolescência"
msgid "Enable mirroring of incoming packets"
-msgstr ""
+msgstr "Habilitar espelhamento dos pacotes entrantes"
msgid "Enable mirroring of outgoing packets"
-msgstr ""
+msgstr "Habilitar espelhamento dos pacotes saintes"
msgid "Enable the DF (Don't Fragment) flag of the encapsulating packets."
-msgstr ""
+msgstr "Habilita o campo DF (Não Fragmentar) dos pacotes encapsulados."
msgid "Enable this mount"
msgstr "Ativar esta montagem"
msgid "Enabled"
msgstr "Ativado"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+"Ativa a troca rápida entre pontos de acesso que pertencem ao mesmo Domínio "
+"de Mobilidade"
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "Ativa o protocolo STP nesta ponte"
msgstr "Cifragem"
msgid "Endpoint Host"
-msgstr ""
+msgstr "Equipamento do ponto final"
msgid "Endpoint Port"
-msgstr ""
+msgstr "Porta do ponto final"
msgid "Erasing..."
msgstr "Apagando..."
msgstr "Erro"
msgid "Errored seconds (ES)"
-msgstr ""
+msgstr "Segundos com erro (ES)"
msgid "Ethernet Adapter"
msgstr "Adaptador Ethernet"
msgstr "Switch Ethernet"
msgid "Exclude interfaces"
-msgstr ""
+msgstr "Excluir interfaces"
msgid "Expand hosts"
msgstr "Expandir arquivos de equipamentos conhecidos (hosts)"
msgid "Expires"
msgstr "Expira"
-#, fuzzy
msgid ""
"Expiry time of leased addresses, minimum is 2 minutes (<code>2m</code>)."
msgstr ""
"code>)."
msgid "External"
-msgstr ""
+msgstr "Externo"
+
+msgid "External R0 Key Holder List"
+msgstr "Lista dos Detentor de Chave R0 Externa"
+
+msgid "External R1 Key Holder List"
+msgstr "Lista dos Detentor de Chave R1 Externa"
msgid "External system log server"
msgstr "Servidor externo de registros do sistema (syslog)"
msgstr "Porta do servidor externo de registro do sistema (syslog)"
msgid "External system log server protocol"
-msgstr ""
+msgstr "Protocolo do servidor externo de registro do sistema (syslog)"
msgid "Extra SSH command options"
-msgstr ""
+msgstr "Opções adicionais do comando SSH"
msgid "Fast Frames"
msgstr "Quadros Rápidos"
"Find all currently attached filesystems and swap and replace configuration "
"with defaults based on what was detected"
msgstr ""
+"Encontre todos os sistemas de arquivos e espaços de troca (swap) atualmente "
+"conectados e substitua a configuração com valores padrão baseados no que foi "
+"detectado"
msgid "Find and join network"
msgstr "Procurar e conectar à rede"
msgstr "Estado do Firewall"
msgid "Firmware File"
-msgstr ""
+msgstr "Arquivo da Firmware"
msgid "Firmware Version"
msgstr "Versão do Firmware"
msgstr "Forçar TKIP e CCMP (AES)"
msgid "Force use of NAT-T"
-msgstr ""
+msgstr "Force o uso do NAT-T"
msgid "Form token mismatch"
-msgstr ""
+msgstr "Chave eletrônica do formulário não casa"
msgid "Forward DHCP traffic"
msgstr "Encaminhar tráfego DHCP"
msgid "Forward Error Correction Seconds (FECS)"
msgstr ""
+"Segundos a frente de correção de erros ( <abbr title=\"Forward Error "
+"Correction Seconds\">FECS</abbr>)"
msgid "Forward broadcast traffic"
msgstr "Encaminhar tráfego broadcast"
"Further information about WireGuard interfaces and peers at <a href=\"http://"
"wireguard.io\">wireguard.io</a>."
msgstr ""
+"Mais informações sobre interfaces e parceiros WireGuard em <a href=\"http://"
+"wireguard.io\">wireguard.io</a>."
msgid "GHz"
msgstr "GHz"
msgstr "Configurações Gerais"
msgid "General options for opkg"
-msgstr ""
+msgstr "Opções gerais para o opkg"
msgid "Generate Config"
-msgstr ""
+msgstr "Gerar Configuração"
msgid "Generate archive"
msgstr "Gerar arquivo"
msgstr "A senha de confirmação informada não casa. Senha não alterada!"
msgid "Global Settings"
-msgstr ""
+msgstr "Configurações Globais"
msgid "Global network options"
-msgstr ""
+msgstr "Opções de rede globais"
msgid "Go to password configuration..."
msgstr "Ir para a configuração de senha..."
msgstr "Ir para a página de configuração pertinente"
msgid "Group Password"
-msgstr ""
+msgstr "Senha do Grupo"
msgid "Guest"
-msgstr ""
+msgstr "Convidado\t"
msgid "HE.net password"
msgstr "Senha HE.net"
msgid "HE.net username"
-msgstr ""
+msgstr "Usuário do HE.net"
msgid "HT mode (802.11n)"
msgstr ""
+"Modo <abbr title=\"High Throughput/Alta Taxa de Transferência\">HT</abbr> "
+"(802.11n)"
# Não sei que contexto isto está sendo usado
msgid "Handler"
msgid "Header Error Code Errors (HEC)"
msgstr ""
+"Erros de Código de Erro de Cabeçalho (<abbr title=\"Header Error Code\">HEC</"
+"abbr>)"
msgid "Heartbeat"
-msgstr ""
+msgstr "Pulso de vida"
msgid ""
"Here you can configure the basic aspects of your device like its hostname or "
"\">ESSID</abbr>"
msgid "Host"
-msgstr ""
+msgstr "Equipamento"
msgid "Host entries"
msgstr "Entradas de Equipamentos"
msgstr "Nome dos equipamentos"
msgid "Hybrid"
-msgstr ""
+msgstr "Híbrido"
msgid "IKE DH Group"
msgstr ""
+"Grupo <abbr title=\"Diffie-Hellman\">DH</abbr> do <abbr title=\"Internet "
+"Key Exchange/Troca de Chaves na Internet\">IKE</abbr>"
+
+msgid "IP Addresses"
+msgstr "Endereços IP"
msgid "IP address"
msgstr "Endereço IP"
msgstr "IPv4 e IPv6"
msgid "IPv4 assignment length"
-msgstr ""
+msgstr "Tamanho da atribuição IPv4"
msgid "IPv4 broadcast"
msgstr "Broadcast IPv4"
msgstr "Somente IPv4"
msgid "IPv4 prefix"
-msgstr ""
+msgstr "Prefixo IPv4"
msgid "IPv4 prefix length"
msgstr "Tamanho do prefixo IPv4"
msgstr "Endereço IPv4"
msgid "IPv4-in-IPv4 (RFC2003)"
-msgstr ""
+msgstr "IPv4-in-IPv4 (RFC2003)"
msgid "IPv6"
msgstr "IPv6"
msgstr "Firewall para IPv6"
msgid "IPv6 Neighbours"
-msgstr ""
+msgstr "Vizinhos IPv6"
msgid "IPv6 Settings"
-msgstr ""
+msgstr "Configurações IPv6"
msgid "IPv6 ULA-Prefix"
msgstr ""
+"Prefixo <abbr title=\"Unique Local Address/Endereço Local Único\">ULA</abbr> "
+"IPv6"
msgid "IPv6 WAN Status"
msgstr "Estado IPv6 da WAN"
msgstr "Endereço IPv6"
msgid "IPv6 address delegated to the local tunnel endpoint (optional)"
-msgstr ""
+msgstr "Endereços IPv6 delegados para o ponta local do túnel (opcional)"
msgid "IPv6 assignment hint"
-msgstr ""
+msgstr "Sugestão de atribuição IPv6"
msgid "IPv6 assignment length"
-msgstr ""
+msgstr "Tamanho da atribuição IPv6"
msgid "IPv6 gateway"
msgstr "Roteador padrão do IPv6"
msgstr "Tamanho Prefixo IPv6"
msgid "IPv6 routed prefix"
-msgstr ""
+msgstr "Prefixo roteável IPv6"
msgid "IPv6-Address"
msgstr "Endereço IPv6"
+msgid "IPv6-PD"
+msgstr "IPv6-PD"
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6-in-IPv4 (RFC4213)"
msgstr "Identidade PEAP"
msgid "If checked, 1DES is enaled"
-msgstr ""
+msgstr "Se marcado, a cifragem 1DES será habilitada"
msgid "If checked, encryption is disabled"
-msgstr ""
+msgstr "Se marcado, a cifragem estará desabilitada"
msgid ""
"If specified, mount the device by its UUID instead of a fixed device node"
"In order to prevent unauthorized access to the system, your request has been "
"blocked. Click \"Continue »\" below to return to the previous page."
msgstr ""
+"Para prevenir acesso não autorizado neste sistema, sua requisição foi "
+"bloqueada. Clique abaixo em \"Continuar »\" para retornar à página anterior."
msgid "Inactivity timeout"
msgstr "Tempo limite de inatividade"
msgstr "Instalar"
msgid "Install iputils-traceroute6 for IPv6 traceroute"
-msgstr ""
+msgstr "Instale iputils-traceroute6 para rastrear rotas IPv6"
msgid "Install package %q"
msgstr "Instalar pacote %q"
msgstr "A interface está desligando..."
msgid "Interface name"
-msgstr ""
+msgstr "Nome da Interface"
msgid "Interface not present or not connected yet."
msgstr "A interface não está presente ou não está conectada ainda."
msgstr "Interfaces"
msgid "Internal"
-msgstr ""
+msgstr "Interno"
msgid "Internal Server Error"
msgstr "erro no servidor interno"
msgid "Invalid username and/or password! Please try again."
msgstr "Usuário e/ou senha inválida! Por favor, tente novamente."
-#, fuzzy
msgid ""
"It appears that you are trying to flash an image that does not fit into the "
"flash memory, please verify the image file!"
msgstr "Conectar à Rede: Busca por Rede Sem Fio"
msgid "Joining Network: %q"
-msgstr ""
+msgstr "Juntando-se à rede %q"
msgid "Keep settings"
msgstr "Manter configurações"
msgstr "Idioma e Estilo"
msgid "Latency"
-msgstr ""
+msgstr "Latência"
msgid "Leaf"
-msgstr ""
+msgstr "Folha"
msgid "Lease time"
-msgstr ""
+msgstr "Tempo de concessão"
msgid "Lease validity time"
msgstr "Tempo de validade da atribuição"
msgid "Limit DNS service to subnets interfaces on which we are serving DNS."
msgstr ""
+"Limite o serviço DNS para subredes das interfaces nas quais estamos servindo "
+"DNS."
msgid "Limit listening to these interfaces, and loopback."
-msgstr ""
+msgstr "Escute somente nestas interfaces e na interface local (loopback) "
msgid "Line Attenuation (LATN)"
-msgstr ""
+msgstr "Atenuação de Linha (<abbr title=\"Line Attenuation\">LATN</abbr>)"
msgid "Line Mode"
-msgstr ""
+msgstr "Modo da Linha"
msgid "Line State"
-msgstr ""
+msgstr "Estado da Linha"
msgid "Line Uptime"
-msgstr ""
+msgstr "Tempo de Atividade da Linha"
msgid "Link On"
msgstr "Enlace Ativo"
"Lista dos servidores <abbr title=\"Domain Name System\">DNS</abbr> para "
"encaminhar as requisições"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+"Lista dos R0KHs no mesmo Domínio de Mobilidade. <br /> Formato: Endereço "
+"MAC, Identificador NAS, chave de 128 bits como cadeia hexadecimal. <br /> "
+"Esta lista é usada para mapear o Identificador R0KH (Identificador NAS) para "
+"um endereço MAC de destino ao solicitar a chave PMK-R1 a partir do R0KH que "
+"o STA usado durante a Associação de Domínio de Mobilidade Inicial."
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+"Lista dos R1KHs no mesmo Domínio de Mobilidade. <br /> Formato: Endereço "
+"MAC, R1KH-ID como 6 octetos com dois pontos, chave de 128 bits como cadeia "
+"hexadecimal. <br /> Esta lista é usada para mapear o identificador R1KH para "
+"um endereço MAC de destino ao enviar a chave PMK-R1 a partir do R0KH. Esta é "
+"também a lista de R1KHs autorizados no MD que podem solicitar chaves PMK-R1."
+
msgid "List of SSH key files for auth"
-msgstr ""
+msgstr "Lista de arquivos de chaves SSH para autenticação"
msgid "List of domains to allow RFC1918 responses for"
msgstr ""
"fornecem resultados errados para consultas a domínios inexistentes (NX)"
msgid "Listen Interfaces"
-msgstr ""
+msgstr "Interfaces de Escuta"
msgid "Listen Port"
-msgstr ""
+msgstr "Porta de Escuta"
msgid "Listen only on the given interface or, if unspecified, on all"
msgstr ""
msgstr "Carregando"
msgid "Local IP address to assign"
-msgstr ""
+msgstr "Endereço IP local para atribuir"
msgid "Local IPv4 address"
msgstr "Endereço IPv4 local"
msgstr "Endereço IPv6 local"
msgid "Local Service Only"
-msgstr ""
+msgstr "Somente Serviço Local"
msgid "Local Startup"
msgstr "Iniciação Local"
msgid "Local domain"
msgstr "Domínio Local"
-#, fuzzy
msgid ""
"Local domain specification. Names matching this domain are never forwarded "
"and are resolved from DHCP or hosts files only"
msgstr "Localizar consultas"
msgid "Locked to channel %s used by: %s"
-msgstr ""
+msgstr "Travado no canal %s usado por: %s"
msgid "Log output level"
msgstr "Nível de detalhamento de saída dos registros"
msgid "Loss of Signal Seconds (LOSS)"
msgstr ""
+"Segundos de Perda de Sinal (<abbr title=\"Loss of Signal Seconds\">LOSS</"
+"abbr>)"
msgid "Lowest leased address as offset from the network address."
msgstr "O endereço mais baixo concedido como deslocamento do endereço da rede."
msgstr "Lista de MAC"
msgid "MAP / LW4over6"
-msgstr ""
+msgstr "MAP / LW4over6"
msgid "MB/s"
msgstr "MB/s"
msgid "MD5"
-msgstr ""
+msgstr "MD5"
msgid "MHz"
msgstr "MHz"
"Make sure to clone the root filesystem using something like the commands "
"below:"
msgstr ""
+"Certifique-se que clonou o sistema de arquivos raiz com algo como o comando "
+"abaixo:"
msgid "Manual"
-msgstr ""
+msgstr "Manual"
msgid "Max. Attainable Data Rate (ATTNDR)"
msgstr ""
+"Taxa de Dados Atingível Máxima (<abbr title=\"Maximum Attainable Data Rate"
+"\">ATTNDR</abbr>)"
msgid "Maximum Rate"
msgstr "Taxa Máxima"
"Maximum length of the name is 15 characters including the automatic protocol/"
"bridge prefix (br-, 6in4-, pppoe- etc.)"
msgstr ""
+"Comprimento máximo do nome é de 15 caracteres, incluindo o prefixo "
+"automático do protocolo/ponte (br-, 6in4- pppoe-, etc.)"
msgid "Maximum number of leased addresses."
msgstr "Número máximo de endereços atribuídos."
msgstr "Tempo mínimo de espera"
msgid "Mirror monitor port"
-msgstr ""
+msgstr "Porta de monitoramento do espelho"
msgid "Mirror source port"
-msgstr ""
+msgstr "Porta de origem do espelho"
msgid "Missing protocol extension for proto %q"
msgstr "Extensão para o protocolo %q está ausente"
+msgid "Mobility Domain"
+msgstr "Domínio da Mobilidade"
+
msgid "Mode"
msgstr "Modo"
msgid "Model"
-msgstr ""
+msgstr "Modelo"
msgid "Modem device"
msgstr "Dispositivo do Modem"
"anexado ao sistema de arquivos"
msgid "Mount filesystems not specifically configured"
-msgstr ""
+msgstr "Monte sistemas de arquivos não especificamente configurados"
msgid "Mount options"
msgstr "Opções de montagem"
msgstr "Ponto de montagem"
msgid "Mount swap not specifically configured"
-msgstr ""
+msgstr "Montar espalho de troca (swap) não especificamente configurado"
msgid "Mounted file systems"
msgstr "Sistemas de arquivos montados"
msgstr "NAS ID"
msgid "NAT-T Mode"
-msgstr ""
+msgstr "Modo NAT-T"
msgid "NAT64 Prefix"
-msgstr ""
+msgstr "Prefixo NAT64"
msgid "NDP-Proxy"
-msgstr ""
+msgstr "Proxy NDP"
msgid "NT Domain"
-msgstr ""
+msgstr "Domínio NT"
msgid "NTP server candidates"
msgstr "Candidatos a servidor NTP"
msgid "NTP sync time-out"
-msgstr ""
+msgstr "Tempo limite da sincronia do NTP"
msgid "Name"
msgstr "Nome"
msgstr "Nenhum Servidor DHCP configurado para esta interface"
msgid "No NAT-T"
-msgstr ""
+msgstr "Sem NAT-T"
msgid "No chains in this table"
msgstr "Nenhuma cadeira nesta tabela"
msgstr "Ruído"
msgid "Noise Margin (SNR)"
-msgstr ""
+msgstr "Margem de Ruído (<abbr title=\"Noise Margin\">SNR</abbr>)"
msgid "Noise:"
msgstr "Ruído:"
msgid "Non Pre-emtive CRC errors (CRC_P)"
msgstr ""
+"Erros CRC Não Preemptivos<abbr title=\"Non Pre-emptive CRC errors\">CRC_P</"
+"abbr>"
msgid "Non-wildcard"
-msgstr ""
+msgstr "Sem caracter curinga"
msgid "None"
msgstr "Nenhum"
msgstr "Nota: Os arquivos de configuração serão apagados."
msgid "Note: interface name length"
-msgstr ""
+msgstr "Aviso: tamanho do nome da interface"
msgid "Notice"
msgstr "Aviso"
msgstr "Configuração-OPKG"
msgid "Obfuscated Group Password"
-msgstr ""
+msgstr "Senha Ofuscada do Grupo"
msgid "Obfuscated Password"
-msgstr ""
+msgstr "Senha Ofuscada"
msgid "Off-State Delay"
msgstr "Atraso no estado de desligado"
msgstr "Um ou mais campos contém valores inválidos!"
msgid "One or more invalid/required values on tab"
-msgstr ""
+msgstr "Um ou mais valores inválidos/obrigatórios na aba"
msgid "One or more required fields have no value!"
msgstr "Um ou mais campos obrigatórios não tem valor!"
msgstr "Abrir lista..."
msgid "OpenConnect (CISCO AnyConnect)"
-msgstr ""
+msgstr "OpenConnect (CISCO AnyConnect)"
msgid "Operating frequency"
-msgstr ""
+msgstr "Frequência de Operação"
msgid "Option changed"
msgstr "Opção alterada"
msgid "Option removed"
msgstr "Opção removida"
+msgid "Optional"
+msgstr "Opcional"
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
+"Opcional, especifique para sobrescrever o servidor padrão (tic.sixxs.net)"
msgid "Optional, use when the SIXXS account has more than one tunnel"
-msgstr ""
+msgstr "Opcional, para usar quando a conta SIXXS tem mais de um túnel"
msgid "Optional."
-msgstr ""
+msgstr "Opcional."
msgid ""
"Optional. Adds in an additional layer of symmetric-key cryptography for post-"
"quantum resistance."
msgstr ""
+"Opcional. Adiciona uma camada extra de cifragem simétrica para resistência "
+"pós quântica."
msgid "Optional. Create routes for Allowed IPs for this peer."
-msgstr ""
+msgstr "Opcional. Cria rotas para endereços IP Autorizados para este parceiro."
msgid ""
"Optional. Host of peer. Names are resolved prior to bringing up the "
"interface."
msgstr ""
+"Opcional. Equipamento do parceiro. Nomes serão resolvido antes de levantar a "
+"interface."
msgid "Optional. Maximum Transmission Unit of tunnel interface."
-msgstr ""
+msgstr "Opcional. Unidade Máxima de Transmissão da interface do túnel."
msgid "Optional. Port of peer."
-msgstr ""
+msgstr "Opcional. Porta do parceiro."
msgid ""
"Optional. Seconds between keep alive messages. Default is 0 (disabled). "
"Recommended value if this device is behind a NAT is 25."
msgstr ""
+"Opcional. Segundos entre mensagens para manutenção da conexão. O padrão é 0 "
+"(desabilitado). O valor recomendado caso este dispositivo esteja atrás de "
+"uma NAT é 25."
msgid "Optional. UDP port used for outgoing and incoming packets."
-msgstr ""
+msgstr "opcional. Porta UDP usada para pacotes saintes ou entrantes."
msgid "Options"
msgstr "Opções"
msgstr "Canais para externo"
msgid "Output Interface"
-msgstr ""
+msgstr "Interface de Saída"
msgid "Override MAC address"
msgstr "Sobrescrever o endereço MAC"
msgid "Override MTU"
-msgstr "Sobrescrever o MTU"
+msgstr ""
+"Sobrescrever o <abbr title=\"Maximum Transmission Unit/Unidade Máxima de "
+"Transmissão\">MTU</abbr>"
msgid "Override TOS"
-msgstr ""
+msgstr "Sobrescrever o TOS"
msgid "Override TTL"
-msgstr ""
+msgstr "Sobrescrever o TTL"
msgid "Override default interface name"
-msgstr ""
+msgstr "Sobrescrever o nome da nova interface"
msgid "Override the gateway in DHCP responses"
msgstr "Sobrescrever o roteador padrão nas respostas do DHCP"
msgid "PIN"
msgstr "PIN"
+msgid "PMK R1 Push"
+msgstr "PMK R1 Push"
+
msgid "PPP"
msgstr "PPP"
msgstr "PPPoE"
msgid "PPPoSSH"
-msgstr ""
+msgstr "PPPoSSH"
msgid "PPtP"
msgstr "PPtP"
msgid "PSID offset"
-msgstr ""
+msgstr "Deslocamento PSID"
msgid "PSID-bits length"
-msgstr ""
+msgstr "Comprimento dos bits PSID"
msgid "PTM/EFM (Packet Transfer Mode)"
-msgstr ""
+msgstr "PTM/EFM (Modo de Transferência de Pacotes)"
msgid "Package libiwinfo required!"
msgstr "O pacote libiwinfo é necessário!"
msgstr "Senha da Chave Privada"
msgid "Password of inner Private Key"
-msgstr ""
+msgstr "Senha da Chave Privada interna"
msgid "Password successfully changed!"
msgstr "A senha foi alterada com sucesso!"
msgstr "Caminho para o executável que trata o evento do botão"
msgid "Path to inner CA-Certificate"
-msgstr ""
+msgstr "Caminho para os certificados CA interno"
msgid "Path to inner Client-Certificate"
-msgstr ""
+msgstr "Caminho para o Certificado do Cliente interno"
msgid "Path to inner Private Key"
-msgstr ""
+msgstr "Caminho para a Chave Privada interna"
msgid "Peak:"
msgstr "Pico:"
msgid "Peer IP address to assign"
-msgstr ""
+msgstr "Endereço IP do parceiro para atribuir"
msgid "Peers"
-msgstr ""
+msgstr "Parceiros"
msgid "Perfect Forward Secrecy"
-msgstr ""
+msgstr "Sigilo Encaminhado Perfeito"
msgid "Perform reboot"
msgstr "Reiniciar o sistema"
msgstr "Zerar configuração"
msgid "Persistent Keep Alive"
-msgstr ""
+msgstr "Manutenção da Conexão Persistente"
msgid "Phy Rate:"
msgstr "Taxa física:"
msgstr "Status da porta"
msgid "Power Management Mode"
-msgstr ""
+msgstr "Modo de Gerenciamento de Energia"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+"Erros CRC Preemptivos<abbr title=\"Pre-emptive CRC errors\">CRCP_P</abbr>"
+
+msgid "Prefix Delegated"
+msgstr "Prefixo Delegado"
msgid "Preshared Key"
-msgstr ""
+msgstr "Chave Compartilhada"
msgid ""
"Presume peer to be dead after given amount of LCP echo failures, use 0 to "
"echo do LCP. Use 0 para ignorar as falhas"
msgid "Prevent listening on these interfaces."
-msgstr ""
+msgstr "Evite escutar nestas Interfaces."
msgid "Prevents client-to-client communication"
msgstr "Impede a comunicação de cliente para cliente"
msgstr "Prism2/2.5/3 802.11b Wireless Controlador"
msgid "Private Key"
-msgstr ""
+msgstr "Chave Privada"
msgid "Proceed"
msgstr "Proceder"
msgstr "Processos"
msgid "Profile"
-msgstr ""
+msgstr "Perfil"
msgid "Prot."
msgstr "Protocolo"
msgstr "Ad-Hoc falso (ahdemo)"
msgid "Public Key"
-msgstr ""
+msgstr "Chave Pública"
msgid "Public prefix routed to this device for distribution to clients."
msgstr ""
+"Prefixo público roteado para este dispositivo para distribuição a seus "
+"clientes."
msgid "QMI Cellular"
-msgstr ""
+msgstr "Celular QMI"
msgid "Quality"
msgstr "Qualidade"
+msgid "R0 Key Lifetime"
+msgstr "Validade da Chave R0"
+
+msgid "R1 Key Holder"
+msgstr "Detentor da Chave R1"
+
msgid "RFC3947 NAT-T mode"
-msgstr ""
+msgstr "Modo NAT-T (RFC3947)"
msgid "RTS/CTS Threshold"
msgstr "Limiar RTS/CTS"
msgid "Really reset all changes?"
msgstr "Realmente limpar todas as mudanças?"
-#, fuzzy
msgid ""
"Really shut down network?\\nYou might lose access to this device if you are "
"connected via this interface."
msgid "Realtime Wireless"
msgstr "Rede sem fio em Tempo Real"
+msgid "Reassociation Deadline"
+msgstr "Limite para Reassociação"
+
msgid "Rebind protection"
msgstr "Proteção contra \"Rebind\""
msgid "Receiver Antenna"
msgstr "Antena de Recepção"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr "Recomendado. Endereços IP da interface do WireGuard."
+
msgid "Reconnect this interface"
msgstr "Reconectar esta interface"
msgstr "Endereço IPv4 remoto"
msgid "Remote IPv4 address or FQDN"
-msgstr ""
+msgstr "Endereço IPv4 remoto ou FQDN"
msgid "Remove"
msgstr "Remover"
msgstr "Substituir a configuração da rede sem fio"
msgid "Request IPv6-address"
-msgstr ""
+msgstr "Solicita endereço IPv6"
msgid "Request IPv6-prefix of length"
-msgstr ""
+msgstr "Solicita prefixo IPv6 de tamanho"
msgid "Require TLS"
-msgstr ""
+msgstr "Requer TLS"
+
+msgid "Required"
+msgstr "Necessário"
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
-msgstr "Requerido para alguns provedores de internet, ex. Charter com DOCSIS 3"
+msgstr ""
+"Obrigatório para alguns provedores de internet, ex. Charter com DOCSIS 3"
msgid "Required. Base64-encoded private key for this interface."
-msgstr ""
+msgstr "Obrigatório. Chave privada codificada em Base64 para esta interface."
msgid ""
"Required. IP addresses and prefixes that this peer is allowed to use inside "
"the tunnel. Usually the peer's tunnel IP addresses and the networks the peer "
"routes through the tunnel."
msgstr ""
+"Obrigatório. Endereços IP e prefixos que este parceiro está autorizado a "
+"usar dentro do túnel. Normalmente é o endereço IP do parceiro no túnel e as "
+"redes que o parceiro roteia através do túnel."
msgid "Required. Public key of peer."
-msgstr ""
+msgstr "Obrigatório. Chave pública do parceiro."
+
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr "Obrigatório. Chave Pública do parceiro."
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgstr ""
+"Exige o suporte DNSSEC do servidor superior; verifica se resposta não "
+"assinadas realmente vẽm de domínios não assinados."
msgid "Reset"
msgstr "Limpar"
msgstr "Diretório raiz para arquivos disponibilizados pelo TFTP"
msgid "Root preparation"
-msgstr ""
+msgstr "Prepação da raiz (/)"
msgid "Route Allowed IPs"
-msgstr ""
+msgstr "Roteie Andereços IP Autorizados"
msgid "Route type"
-msgstr ""
+msgstr "Tipo de rota"
msgid "Routed IPv6 prefix for downstream interfaces"
-msgstr ""
+msgstr "Prefixo roteável IPv6 para interfaces internas"
msgid "Router Advertisement-Service"
-msgstr ""
+msgstr "Serviço de Anúncio de Roteador"
msgid "Router Password"
msgstr "Senha do Roteador"
msgstr "Execute a verificação do sistema de arquivos "
msgid "SHA256"
-msgstr ""
+msgstr "SHA256"
msgid ""
"SIXXS supports TIC only, for static tunnels using IP protocol 41 (RFC4213) "
"use 6in4 instead"
msgstr ""
+"O SIXXS suporta somente TIC. Use o 6in4 para túneis estáticos usando o "
+"protocolo IP 41 (RFC4213)"
msgid "SIXXS-handle[/Tunnel-ID]"
-msgstr ""
+msgstr "Identificador do SIXXS[/Identificador do Túnel]"
msgid "SNR"
-msgstr ""
+msgstr "SNR"
msgid "SSH Access"
msgstr "Acesso SSH"
msgid "SSH server address"
-msgstr ""
+msgstr "Endereço do servidor SSH"
msgid "SSH server port"
-msgstr ""
+msgstr "Porta do servidor SSH"
msgid "SSH username"
-msgstr ""
+msgstr "Usuário do SSH"
msgid "SSH-Keys"
msgstr "Chaves SSH"
msgstr "Configurações do Servidor"
msgid "Server password"
-msgstr ""
+msgstr "Senha do servidor"
msgid ""
"Server password, enter the specific password of the tunnel when the username "
"contains the tunnel ID"
msgstr ""
+"Senha do servidor. Informe a senha para este túnel quando o nome do usuário "
+"contiver o identificador do túnel"
msgid "Server username"
-msgstr ""
+msgstr "Usuário do servidor"
msgid "Service Name"
msgstr "Nome do Serviço"
msgid "Services"
msgstr "Serviços"
-#, fuzzy
msgid "Set up Time Synchronization"
msgstr "Configurar a Sincronização do Horário"
msgid "Severely Errored Seconds (SES)"
msgstr ""
+"Segundos com erro severos (<abbr title=\"Severely Errored Seconds\">SES</"
+"abbr>)"
msgid "Short GI"
-msgstr ""
+msgstr "Intervalo de guarda curto"
msgid "Show current backup file list"
msgstr "Mostra a lista atual de arquivos para a cópia de segurança"
msgstr "Sinal"
msgid "Signal Attenuation (SATN)"
-msgstr ""
+msgstr "Atenuação do Sinal (<abbr title=\"Signal Attenuation\">SATN</abbr>)"
msgid "Signal:"
msgstr "Sinal:"
msgstr "Tamanho"
msgid "Size (.ipk)"
-msgstr ""
+msgstr "Tamanho (.ipk)"
msgid "Skip"
msgstr "Pular"
msgstr "Software"
msgid "Software VLAN"
-msgstr ""
+msgstr "VLAN em Software"
msgid "Some fields are invalid, cannot save values!"
msgstr "Alguns campos estão inválidos e os valores não podem ser salvos!"
msgstr "Origem"
msgid "Source routing"
-msgstr ""
+msgstr "Roteamento pela origem"
msgid "Specifies the button state to handle"
msgstr "Especifica o estado do botão para ser tratado"
"equipamento está morto"
msgid "Specify a TOS (Type of Service)."
-msgstr ""
+msgstr "Especifique um Tipo de Serviço (TOS)"
msgid ""
"Specify a TTL (Time to Live) for the encapsulating packet other than the "
"default (64)."
msgstr ""
+"Especifica o tempo de vida (<abbr title=\"Time to Live\">TTL</abbr>) para os "
+"pacotes encapsulados ao invés do padrão (64)."
msgid ""
"Specify an MTU (Maximum Transmission Unit) other than the default (1280 "
"bytes)."
msgstr ""
+"Especifica a unidade máxima de transmissão (<abbr title=\"Maximum "
+"Transmission Unit\">MTU</abbr>) ao invés do valor padrão (1280 bytes)"
msgid "Specify the secret encryption key here."
msgstr "Especifique a chave de cifragem secreta aqui."
msgstr "Enviar"
msgid "Suppress logging"
-msgstr ""
+msgstr "Suprimir registros (log)"
msgid "Suppress logging of the routine operation of these protocols"
-msgstr ""
+msgstr "Suprimir registros (log) de operações rotineiras destes protocolos"
msgid "Swap"
-msgstr ""
+msgstr "Espaço de Troca (swap)"
msgid "Swap Entry"
msgstr "Entrada do espaço de troca (Swap)"
msgid ""
"Switch %q has an unknown topology - the VLAN settings might not be accurate."
msgstr ""
+"O Switch %q tem uma topologia desconhecida - as configurações de VLAN podem "
+"não ser precisas."
msgid "Switch VLAN"
-msgstr ""
+msgstr "Switch VLAN"
msgid "Switch protocol"
msgstr "Trocar o protocolo"
msgstr "Destino"
msgid "Target network"
-msgstr ""
+msgstr "Rede de destino"
msgid "Terminate"
msgstr "Terminar"
-#, fuzzy
msgid ""
"The <em>Device Configuration</em> section covers physical settings of the "
"radio hardware such as channel, transmit power or antenna selection which "
"The HE.net endpoint update configuration changed, you must now use the plain "
"username instead of the user ID!"
msgstr ""
+"A configuração da atualização de pontas HE.net mudou. Você deve agora usar o "
+"nome do usuário ao invés do identificador do usuário!"
msgid ""
"The IPv4 address or the fully-qualified domain name of the remote tunnel end."
-msgstr ""
+msgstr "O endereço IPv4 ou o nome completo (FQDN) da ponta remota do túnel."
msgid ""
"The IPv6 prefix assigned to the provider, usually ends with <code>::</code>"
msgid "The configuration file could not be loaded due to the following error:"
msgstr ""
+"O arquivo de configuração não pode ser carregado devido ao seguinte erro:"
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgstr ""
-"O arquivo do dispositivo de armazenamento ou da partição (<abbr title=\"por "
-"exemplo\">ex.</abbr> <code>/dev/sda1</code>)"
+"O arquivo do dispositivo de armazenamento ou da partição (ex: <code>/dev/"
+"sda1</code>)"
msgid ""
"The filesystem that was used to format the memory (<abbr title=\"for example"
msgid "The given network name is not unique"
msgstr "O nome de rede informado não é único"
-#, fuzzy
msgid ""
"The hardware is not multi-SSID capable and the existing configuration will "
"be replaced if you proceed."
msgstr "O comprimento do prefixo IPv6 em bits"
msgid "The local IPv4 address over which the tunnel is created (optional)."
-msgstr ""
+msgstr "O endereço IPv4 local sobre o qual o túnel será criado (opcional)."
msgid ""
"The network ports on this device can be combined to several <abbr title="
msgstr "O protocolo selecionado necessita estar associado a um dispositivo"
msgid "The submitted security token is invalid or already expired!"
-msgstr ""
+msgstr "A chave eletrônica enviada é inválida ou já expirou!"
msgid ""
"The system is erasing the configuration partition now and will reboot itself "
"O sistema está apagando agora a partição da configuração e irá reiniciar "
"quando terminado."
-#, fuzzy
msgid ""
"The system is flashing now.<br /> DO NOT POWER OFF THE DEVICE!<br /> Wait a "
"few minutes before you try to reconnect. It might be necessary to renew the "
"The tunnel end-point is behind NAT, defaults to disabled and only applies to "
"AYIYA"
msgstr ""
+"O final do túnel está atrás de um NAT. Por padrão será desabilitado e "
+"somente se aplica a AYIYA"
msgid ""
"The uploaded image file does not contain a supported format. Make sure that "
"'server=1.2.3.4' fordomain-specific or full upstream <abbr title=\"Domain "
"Name System\">DNS</abbr> servers."
msgstr ""
+"Este arquivo deve conter linhas como 'server=/domain/1.2.3.4' ou "
+"'server=1.2.3.4' para servidores <abbr title=\"Domain Name System/Sistema de "
+"Nomes de Domínios\">DNS</abbr> por domínio ou completos."
msgid ""
"This is a list of shell glob patterns for matching files and directories to "
"This is either the \"Update Key\" configured for the tunnel or the account "
"password if no update key has been configured"
msgstr ""
+"Isto é a \"Update Key\" configurada para o túnel ou a senha da cpnta se não "
+"tem uma \"Update Keu\" configurada"
msgid ""
"This is the content of /etc/rc.local. Insert your own commands here (in "
"\">DHCP</abbr> na rede local"
msgid "This is the plain username for logging into the account"
-msgstr ""
+msgstr "Este é o nome do usuário em para se autenticar na sua conta"
msgid ""
"This is the prefix routed to you by the tunnel broker for use by clients"
msgstr ""
+"Este é o prefixo roteado pelo agente do tunel para você usar com seus "
+"clientes"
msgid "This is the system crontab in which scheduled tasks can be defined."
msgstr "Este é o sistema de agendamento de tarefas."
"de segurança anterior."
msgid "Tone"
-msgstr ""
+msgstr "Tom"
msgid "Total Available"
msgstr "Total Disponível"
msgstr "Interface de Tunelamento"
msgid "Tunnel Link"
-msgstr ""
+msgstr "Enlace do túnel"
msgid "Tunnel broker protocol"
-msgstr ""
+msgstr "Protocolo do agente do túnel"
msgid "Tunnel setup server"
-msgstr ""
+msgstr "Servidor de configuração do túnel"
msgid "Tunnel type"
-msgstr ""
+msgstr "Tipo de túnel"
msgid "Turbo Mode"
msgstr "Modo Turbo"
msgid "USB Device"
msgstr "Dispositivo USB"
+msgid "USB Ports"
+msgstr "Portas USB"
+
msgid "UUID"
msgstr "UUID"
msgid "Unavailable Seconds (UAS)"
msgstr ""
+"Segundos de indisponibilidade (<abbr title=\"Unavailable Seconds\">UAS</"
+"abbr>)"
msgid "Unknown"
msgstr "Desconhecido"
msgstr "Não gerenciado"
msgid "Unmount"
-msgstr ""
+msgstr "Desmontar"
msgid "Unsaved Changes"
msgstr "Alterações Não Salvas"
msgstr "Usar códigos de países ISO/IEC 3166 alpha2."
msgid "Use MTU on tunnel interface"
-msgstr "Use MTU na interface do túnel"
+msgstr ""
+"Use o <abbr title=\"Maximum Transmission Unit/Unidade Máxima de Transmissão"
+"\">MTU</abbr> na interface do túnel"
msgid "Use TTL on tunnel interface"
msgstr "Use TTL na interface do túnel"
msgid "Use as external overlay (/overlay)"
-msgstr ""
+msgstr "Use como uma sobreposição externa (/overlay)"
msgid "Use as root filesystem (/)"
-msgstr ""
+msgstr "Usar como o sistema de arquivos raiz (/)"
msgid "Use broadcast flag"
msgstr "Use a marcação de broadcast"
msgid "Use builtin IPv6-management"
-msgstr ""
+msgstr "Use o gerenciamento do IPv6 embarcado"
msgid "Use custom DNS servers"
msgstr "Use servidores DNS personalizados"
msgid "Used Key Slot"
msgstr "Posição da Chave Usada"
-msgid "User certificate (PEM encoded)"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
msgstr ""
+"Usado para dois diferentes propósitos: identificador do RADIUS NAS e do "
+"802.11r R0KH. Não necessário com o WPA(2)-PSK normal."
+
+msgid "User certificate (PEM encoded)"
+msgstr "Certificado do usuário (codificado em formato PEM)"
msgid "User key (PEM encoded)"
-msgstr ""
+msgstr "Chave do usuário (codificada em formato PEM)"
msgid "Username"
msgstr "Usuário"
msgstr "VC-Mux"
msgid "VDSL"
-msgstr ""
+msgstr "VDSL"
msgid "VLANs on %q"
msgstr "VLANs em %q"
msgstr "VLANs em %q (%s)"
msgid "VPN Local address"
-msgstr ""
+msgstr "Endereço Local da VPN"
msgid "VPN Local port"
-msgstr ""
+msgstr "Porta Local da VPN"
msgid "VPN Server"
msgstr "Servidor VPN"
msgid "VPN Server port"
-msgstr ""
+msgstr "Porta do Servidor VPN"
msgid "VPN Server's certificate SHA1 hash"
-msgstr ""
+msgstr "Resumo digital SHA1 do certificado do servidor VPN"
msgid "VPNC (CISCO 3000 (and others) VPN)"
-msgstr ""
+msgstr "VPNC (VPN do CISCO 3000 (e outros))"
msgid "Vendor"
-msgstr ""
+msgstr "Fabricante"
msgid "Vendor Class to send when requesting DHCP"
msgstr "Classe do fabricante para enviar quando requisitar o DHCP"
msgid "Verbose"
-msgstr ""
+msgstr "Detalhado"
msgid "Verbose logging by aiccu daemon"
-msgstr ""
+msgstr "Habilite registros detalhados do serviço AICCU"
msgid "Verify"
msgstr "Verificar"
msgid ""
"Wait for NTP sync that many seconds, seting to 0 disables waiting (optional)"
msgstr ""
+"Espere esta quantidade de segundos pela sincronia do NTP. Definindo como 0 "
+"desabilita a espera (opcional)"
msgid "Waiting for changes to be applied..."
msgstr "Esperando a aplicação das mudanças..."
msgstr "Esperando o término do comando..."
msgid "Waiting for device..."
-msgstr ""
+msgstr "Esperando pelo dispositivo..."
msgid "Warning"
msgstr "Atenção"
msgid "Warning: There are unsaved changes that will get lost on reboot!"
-msgstr ""
+msgstr "Atenção: Existem mudanças não salvas que serão perdidas ao reiniciar!"
msgid "Whether to create an IPv6 default route over the tunnel"
-msgstr ""
+msgstr "Se deve criar uma rota padrão IPv6 sobre o túnel"
msgid "Whether to route only packets from delegated prefixes"
-msgstr ""
+msgstr "Se deve rotear somente pacotes de prefixos delegados"
msgid "Width"
-msgstr ""
+msgstr "Largura"
msgid "WireGuard VPN"
-msgstr ""
+msgstr "VPN WireGuard"
msgid "Wireless"
msgstr "Rede sem fio"
msgstr "Escreva as requisições DNS para o servidor de registro (syslog)"
msgid "Write system log to file"
-msgstr ""
+msgstr "Escrever registo do sistema (log) no arquivo"
msgid "XR Support"
msgstr "Suporte a XR"
"upgrade it to at least version 7 or use another browser like Firefox, Opera "
"or Safari."
msgstr ""
+"Seu Internet Explorer é muito velho para mostrar esta página corretamente. "
+"Por favor, atualiza para, ao menos, a versão 7 ou use outro navegador como o "
+"Firefox, Opera ou Safari."
msgid "any"
msgstr "qualquer"
msgid "auto"
msgstr "automático"
-#, fuzzy
msgid "automatic"
-msgstr "estático"
+msgstr "automático"
msgid "baseT"
msgstr "baseT"
msgstr "desativar"
msgid "disabled"
-msgstr ""
+msgstr "desabilitado"
msgid "expired"
msgstr "expirado"
msgstr "ocultar"
msgid "hybrid mode"
-msgstr ""
+msgstr "Modo Híbrido"
msgid "if target is a network"
msgstr "se o destino for uma rede"
"Arquivo local de <abbr title=\"Sistema de Nomes de Domínios\">DNS</abbr>"
msgid "minimum 1280, maximum 1480"
-msgstr ""
+msgstr "mínimo 1280, máximo 1480"
+
+msgid "minutes"
+msgstr "minutos"
msgid "navigation Navigation"
-msgstr ""
+msgstr "navegação Navegação"
# Is this yes/no or no like in no one?
msgid "no"
msgstr "nenhum"
msgid "not present"
-msgstr ""
+msgstr "não presente "
msgid "off"
msgstr "desligado"
msgstr "aberto"
msgid "overlay"
-msgstr ""
+msgstr "sobreposição"
msgid "relay mode"
-msgstr ""
+msgstr "modo retransmissor"
msgid "routed"
msgstr "roteado"
msgid "server mode"
-msgstr ""
+msgstr "modo servidor"
msgid "skiplink1 Skip to navigation"
-msgstr ""
+msgstr "skiplink1 Pular para a navegação"
msgid "skiplink2 Skip to content"
-msgstr ""
+msgstr "skiplink2 Pular para o conteúdo"
msgid "stateful-only"
-msgstr ""
+msgstr "somente com estado"
msgid "stateless"
-msgstr ""
+msgstr "sem estado"
msgid "stateless + stateful"
-msgstr ""
+msgstr "sem estado + com estado"
msgid "tagged"
msgstr "etiquetado"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr "unidades de tempo (TUs / 1.024 ms) [1000-65535]"
+
msgid "unknown"
msgstr "desconhecido"
msgid "« Back"
msgstr "« Voltar"
+#~ msgid "Required. Base64-encoded public key of peer."
+#~ msgstr "Necessário. Chave Pública do parceiro codificada como Base64."
+
#~ msgid "An additional network will be created if you leave this unchecked."
#~ msgstr "Uma rede adicional será criada se você deixar isto desmarcado."
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Carga de 1 Minuto:"
msgid "15 Minute Load:"
msgstr "Carga de 15 minutos:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Carga 5 Minutos:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr ""
"<abbr title=\"Identificador de Conjunto Básico de Serviços\">BSSID</abbr>"
msgid "Disabled"
msgstr "Desativado"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "Descartar respostas RFC1918 a montante"
msgid "Enabled"
msgstr "Ativado"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "Ativa o Spanning Tree nesta bridge"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "Servidor externo de logs de sistema"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "Endereço IP"
msgid "IPv6-Address"
msgstr "Endereço-IPv6"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6-em-IPv4 (RFC4213)"
"Lista de servidores <abbr title=\"Sistema Nomes de Domínio\">DNS</abbr> para "
"onde encaminhar os pedidos"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr "Falta a extensão de protocolo para o protocolo %q"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Modo"
msgid "Option removed"
msgstr "Opção removida"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr "PIN"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr "Qualidade"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr "Wireless em Tempo Real"
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr "Religar protecção"
msgid "Receiver Antenna"
msgstr "Antena de Recepção"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Reconetar esta interface"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr "Necessário para certos ISPs, p.ex. Charter with DOCSIS 3"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "Dispositivo USB"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr ""
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr ""
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "desconhecido"
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Incarcarea in ultimul minut"
msgid "15 Minute Load:"
msgstr "Incarcarea in ultimele 15 minute"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Incarcarea in ultimele 5 minute"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr "Dezactivat"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr ""
msgid "Enabled"
msgstr "Activat"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr ""
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "Server de log-uri extern"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "Adresa IP"
msgid "IPv6-Address"
msgstr ""
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr ""
"requests to"
msgstr ""
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr ""
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Mod"
msgid "Option removed"
msgstr "Optiunea eliminata"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr ""
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr ""
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr "Calitate"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr ""
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr ""
msgid "Receiver Antenna"
msgstr "Antena receptorului"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Reconecteaza aceasta interfata"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr ""
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "Dispozitiv USB"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr "Slot de cheie folosit"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "etichetat"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "necunoscut"
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Загрузка за 1 минуту:"
msgid "15 Minute Load:"
msgstr "Загрузка за 15 минут:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Загрузка за 5 минут:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Базовый идентификатор обслуживания\">BSSID</abbr>"
msgid "Disabled"
msgstr "Отключено"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "Отбрасывать ответы RFC1918"
msgid "Enabled"
msgstr "Включено"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "Включает Spanning Tree Protocol на этом мосту"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "Сервер системного журнала"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "IP-адрес"
msgid "IPv6-Address"
msgstr "IPv6-адрес"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6 в IPv4 (RFC4213)"
"Список <abbr title=\"Domain Name System\">DNS</abbr>-серверов для "
"перенаправления запросов"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr "Отсутствует расширение протокола %q"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Режим"
msgid "Option removed"
msgstr "Опция удалена"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr "PIN"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr "Качество"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr "Беспроводная сеть в реальном времени"
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr "Защита от DNS Rebinding"
msgid "Receiver Antenna"
msgstr "Приёмная антенна"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Переподключить этот интерфейс"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr "Требуется для некоторых интернет-провайдеров"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "USB-устройство"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr "Используемый слот ключа"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "с тегом"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "неизвестный"
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr ""
msgid "15 Minute Load:"
msgstr ""
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr ""
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr ""
msgid "Disabled"
msgstr ""
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr ""
msgid "Enabled"
msgstr ""
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr ""
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr ""
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr ""
msgid "IPv6-Address"
msgstr ""
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr ""
"requests to"
msgstr ""
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr ""
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr ""
msgid "Option removed"
msgstr ""
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr ""
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr ""
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr ""
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr ""
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr ""
msgid "Receiver Antenna"
msgstr ""
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr ""
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr ""
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr ""
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr ""
msgid "Used Key Slot"
msgstr ""
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr ""
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr ""
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Belastning senaste minuten:"
msgid "15 Minute Load:"
msgstr "Belastning senaste 15 minutrarna:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Belastning senaste 5 minutrarna:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr ""
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr ""
msgid "Enabled"
msgstr ""
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr ""
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr ""
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr ""
msgid "IPv6-Address"
msgstr ""
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr ""
"requests to"
msgstr ""
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr ""
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr ""
msgid "Option removed"
msgstr ""
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr ""
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr ""
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr ""
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr ""
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr ""
msgid "Receiver Antenna"
msgstr ""
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr ""
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr ""
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr ""
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr ""
msgid "Used Key Slot"
msgstr ""
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr ""
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr ""
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr ""
msgid "15 Minute Load:"
msgstr ""
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr ""
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr ""
msgid "Disabled"
msgstr ""
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr ""
msgid "Enabled"
msgstr ""
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr ""
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr ""
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr ""
msgid "IPv6-Address"
msgstr ""
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr ""
"requests to"
msgstr ""
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr ""
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr ""
msgid "Option removed"
msgstr ""
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr ""
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr ""
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr ""
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr ""
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr ""
msgid "Receiver Antenna"
msgstr ""
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr ""
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr ""
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr ""
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr ""
msgid "Used Key Slot"
msgstr ""
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr ""
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr ""
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "1 Dakikalık Yük:"
msgid "15 Minute Load:"
msgstr "15 Dakikalık Yük:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "5 Dakikalık Yük:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\\\"Temel Servis Ayar Tanımlayıcısı\\\"> BSSID </abbr>"
msgid "Disabled"
msgstr ""
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr ""
msgid "Enabled"
msgstr ""
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr ""
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr ""
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr ""
msgid "IPv6-Address"
msgstr ""
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr ""
"requests to"
msgstr ""
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr ""
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr ""
msgid "Option removed"
msgstr ""
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr ""
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr ""
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr ""
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr ""
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr ""
msgid "Receiver Antenna"
msgstr ""
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr ""
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr ""
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr ""
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr ""
msgid "Used Key Slot"
msgstr ""
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "etiketlendi"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr ""
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "Навантаження за 1 хвилину:"
msgid "15 Minute Load:"
msgstr "Навантаження за 15 хвилин:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "Навантаження за 5 хвилин:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr ""
"<abbr title=\"Basic Service Set Identifier — ідентифікатор основної служби "
msgid "Disabled"
msgstr "Вимкнено"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "Відкидати RFC1918-відповіді від клієнта на сервер"
msgid "Enabled"
msgstr "Увімкнено"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr ""
"Увімкнути <abbr title=\"Spanning Tree Protocol\">STP</abbr> на цьому мосту"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "Зовнішній сервер системного журналу"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "IP-адреса"
msgid "IPv6-Address"
msgstr "IPv6-адреса"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6 у IPv4 (RFC4213)"
"Список <abbr title=\"Domain Name System\">DNS</abbr>-серверів, до яких "
"пересилати запити"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr "Відсутні розширення для протоколу %q"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Режим"
msgid "Option removed"
msgstr "Опція видалена"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
"<abbr title=\"Personal Identification Number — Персональний ідентифікаційний "
"номер\">>PIN</abbr>"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr "Якість"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr "Бездротові мережі у реальному часі"
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr "Захист від переприв'язки"
msgid "Receiver Antenna"
msgstr "Антена приймача"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "Перепідключити цей інтерфейс"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr "Потрібно для деяких провайдерів, наприклад, Charter із DOCSIS 3"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "USB-пристрій"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr "Використовується слот ключа"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "з позначкою"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "невідомий"
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr ""
msgid "15 Minute Load:"
msgstr ""
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr ""
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Dịch vụ căn bản đặt Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr ""
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr ""
msgid "Enabled"
msgstr ""
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "Kích hoạt Spanning Tree Protocol trên cầu nối này"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr ""
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "Địa chỉ IP"
msgid "IPv6-Address"
msgstr ""
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr ""
"requests to"
msgstr ""
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr ""
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "Chế độ"
msgid "Option removed"
msgstr ""
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr ""
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr ""
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr ""
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr ""
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr ""
msgid "Receiver Antenna"
msgstr "Máy thu Antenna"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr ""
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr ""
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr ""
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr ""
msgid "Used Key Slot"
msgstr ""
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr ""
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr ""
msgid "-- match by label --"
msgstr "-- 根据标签匹配 --"
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "1分钟负载:"
msgid "15 Minute Load:"
msgstr "15分钟负载:"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr "464XLAT (CLAT)"
msgid "5 Minute Load:"
msgstr "5分钟负载:"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"基本服务集标识符\">BSSID</abbr>"
msgid "Disabled"
msgstr "禁用"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "丢弃RFC1918上行响应数据"
msgid "Enabled"
msgstr "启用"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "在此桥接上启用生成协议树"
msgid "External"
msgstr "远程"
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "远程日志服务器"
msgid "IKE DH Group"
msgstr "IKE DH组"
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "IP地址"
msgid "IPv6-Address"
msgstr "IPv6-地址"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6-in-IPv4 (RFC4213)"
"requests to"
msgstr "将指定的域名DNS解析转发到指定的DNS服务器(按照示例填写)"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr "用于认证的SSH密钥文件列表"
msgid "Missing protocol extension for proto %q"
msgstr "缺少协议 %q 的协议扩展"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "模式"
msgid "Option removed"
msgstr "移除的选项"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr "可选,设置这个选项会覆盖默认设定的服务器(tic.sixxs.net)"
msgid "PIN"
msgstr "PIN"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr "抢占式CRC错误(CRCP_P)"
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr "预共享密钥"
msgid "Quality"
msgstr "质量"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr "RFC3947 NAT-T模式"
msgid "Realtime Wireless"
msgstr "实时无线"
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr "重绑定保护"
msgid "Receiver Antenna"
msgstr "接收天线"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "重连此接口"
msgid "Require TLS"
msgstr "必须使用TLS"
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr "某些ISP需要,例如:同轴线网络DOCSIS 3"
msgid "Required. Public key of peer."
msgstr "必须,Peer的公钥。"
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "USB设备"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "UUID"
msgid "Used Key Slot"
msgstr "启用密码组"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr "客户证书(PEM加密的)"
msgid "minimum 1280, maximum 1480"
msgstr "最小值1280,最大值1480"
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr "导航"
msgid "tagged"
msgstr "关联"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "未知"
msgid "-- match by label --"
msgstr ""
+msgid "-- match by uuid --"
+msgstr ""
+
msgid "1 Minute Load:"
msgstr "1分鐘負載"
msgid "15 Minute Load:"
msgstr "15分鐘負載"
+msgid "4-character hexadecimal ID"
+msgstr ""
+
msgid "464XLAT (CLAT)"
msgstr ""
msgid "5 Minute Load:"
msgstr "5分鐘負載"
+msgid "6-octet identifier as a hex string - no colons"
+msgstr ""
+
+msgid "802.11r Fast Transition"
+msgstr ""
+
+msgid "802.11w Association SA Query maximum timeout"
+msgstr ""
+
+msgid "802.11w Association SA Query retry timeout"
+msgstr ""
+
+msgid "802.11w Management Frame Protection"
+msgstr ""
+
+msgid "802.11w maximum timeout"
+msgstr ""
+
+msgid "802.11w retry timeout"
+msgstr ""
+
msgid "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgstr "<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"
msgid "Disabled"
msgstr "關閉"
+msgid "Disabled (default)"
+msgstr ""
+
msgid "Discard upstream RFC1918 responses"
msgstr "丟棄上游RFC1918 虛擬IP網路的回應"
msgid "Enabled"
msgstr "啟用"
+msgid ""
+"Enables fast roaming among access points that belong to the same Mobility "
+"Domain"
+msgstr ""
+
msgid "Enables the Spanning Tree Protocol on this bridge"
msgstr "在橋接器上啟用802.1d Spanning Tree協定"
msgid "External"
msgstr ""
+msgid "External R0 Key Holder List"
+msgstr ""
+
+msgid "External R1 Key Holder List"
+msgstr ""
+
msgid "External system log server"
msgstr "外部系統日誌伺服器"
msgid "IKE DH Group"
msgstr ""
+msgid "IP Addresses"
+msgstr ""
+
msgid "IP address"
msgstr "IP位址"
msgid "IPv6-Address"
msgstr "IPv6-位址"
+msgid "IPv6-PD"
+msgstr ""
+
msgid "IPv6-in-IPv4 (RFC4213)"
msgstr "IPv6包覆在IPv4內(RFC4213)"
"requests to"
msgstr "列出 <abbr title=\"Domain Name System\">DNS</abbr> 伺服器以便轉發請求"
+msgid ""
+"List of R0KHs in the same Mobility Domain. <br />Format: MAC-address,NAS-"
+"Identifier,128-bit key as hex string. <br />This list is used to map R0KH-ID "
+"(NAS Identifier) to a destination MAC address when requesting PMK-R1 key "
+"from the R0KH that the STA used during the Initial Mobility Domain "
+"Association."
+msgstr ""
+
+msgid ""
+"List of R1KHs in the same Mobility Domain. <br />Format: MAC-address,R1KH-ID "
+"as 6 octets with colons,128-bit key as hex string. <br />This list is used "
+"to map R1KH-ID to a destination MAC address when sending PMK-R1 key from the "
+"R0KH. This is also the list of authorized R1KHs in the MD that can request "
+"PMK-R1 keys."
+msgstr ""
+
msgid "List of SSH key files for auth"
msgstr ""
msgid "Missing protocol extension for proto %q"
msgstr "協定 %q 漏失的延伸協定"
+msgid "Mobility Domain"
+msgstr ""
+
msgid "Mode"
msgstr "模式"
msgid "Option removed"
msgstr "選項已移除"
+msgid "Optional"
+msgstr ""
+
msgid "Optional, specify to override default server (tic.sixxs.net)"
msgstr ""
msgid "PIN"
msgstr "PIN碼"
+msgid "PMK R1 Push"
+msgstr ""
+
msgid "PPP"
msgstr "PPP協定"
msgid "Pre-emtive CRC errors (CRCP_P)"
msgstr ""
+msgid "Prefix Delegated"
+msgstr ""
+
msgid "Preshared Key"
msgstr ""
msgid "Quality"
msgstr "品質"
+msgid "R0 Key Lifetime"
+msgstr ""
+
+msgid "R1 Key Holder"
+msgstr ""
+
msgid "RFC3947 NAT-T mode"
msgstr ""
msgid "Realtime Wireless"
msgstr "即時無線網路"
+msgid "Reassociation Deadline"
+msgstr ""
+
msgid "Rebind protection"
msgstr "重新綁護"
msgid "Receiver Antenna"
msgstr "接收天線"
+msgid "Recommended. IP addresses of the WireGuard interface."
+msgstr ""
+
msgid "Reconnect this interface"
msgstr "重新連接這個介面"
msgid "Require TLS"
msgstr ""
+msgid "Required"
+msgstr ""
+
msgid "Required for certain ISPs, e.g. Charter with DOCSIS 3"
msgstr "對特定的ISP需要,例如.DOCSIS 3 加速有線電視寬頻網路"
msgid "Required. Public key of peer."
msgstr ""
+msgid ""
+"Requires the 'full' version of wpad/hostapd and support from the wifi driver "
+"<br />(as of Feb 2017: ath9k and ath10k, in LEDE also mwlwifi and mt76)"
+msgstr ""
+
msgid ""
"Requires upstream supports DNSSEC; verify unsigned domain responses really "
"come from unsigned domains"
msgid "USB Device"
msgstr "USB設備"
+msgid "USB Ports"
+msgstr ""
+
msgid "UUID"
msgstr "設備通用唯一識別碼UUID"
msgid "Used Key Slot"
msgstr "已使用的關鍵插槽"
+msgid ""
+"Used for two different purposes: RADIUS NAS ID and 802.11r R0KH-ID. Not "
+"needed with normal WPA(2)-PSK."
+msgstr ""
+
msgid "User certificate (PEM encoded)"
msgstr ""
msgid "minimum 1280, maximum 1480"
msgstr ""
+msgid "minutes"
+msgstr ""
+
msgid "navigation Navigation"
msgstr ""
msgid "tagged"
msgstr "標籤"
+msgid "time units (TUs / 1.024 ms) [1000-65535]"
+msgstr ""
+
msgid "unknown"
msgstr "未知"
end
end
else
- distname = "libreCMC"
+ distname = "OpenWrt"
distversion = "Development Snapshot"
end
ipaddrs = net:ipaddrs(),
ip6addrs = net:ip6addrs(),
dnsaddrs = net:dnsaddrs(),
+ ip6prefix = net:ip6prefix(),
name = device:shortname(),
type = device:type(),
ifname = device:name(),
entry({"admin", "status", "realtime", "bandwidth"}, template("admin_status/bandwidth"), _("Traffic"), 2).leaf = true
entry({"admin", "status", "realtime", "bandwidth_status"}, call("action_bandwidth")).leaf = true
- entry({"admin", "status", "realtime", "wireless"}, template("admin_status/wireless"), _("Wireless"), 3).leaf = true
- entry({"admin", "status", "realtime", "wireless_status"}, call("action_wireless")).leaf = true
+ if nixio.fs.access("/etc/config/wireless") then
+ entry({"admin", "status", "realtime", "wireless"}, template("admin_status/wireless"), _("Wireless"), 3).leaf = true
+ entry({"admin", "status", "realtime", "wireless_status"}, call("action_wireless")).leaf = true
+ end
entry({"admin", "status", "realtime", "connections"}, template("admin_status/connections"), _("Connections"), 4).leaf = true
entry({"admin", "status", "realtime", "connections_status"}, call("action_connections")).leaf = true
luci.sys.call("date -s '%04d-%02d-%02d %02d:%02d:%02d'" %{
date.year, date.month, date.day, date.hour, date.min, date.sec
})
+ luci.sys.call("/etc/init.d/sysfixtime restart")
end
end
-- wireless toggle was requested, commit and reload page
function m.parse(map)
+ local new_cc = m:formvalue("cbid.wireless.%s.country" % wdev:name())
+ local old_cc = m:get(wdev:name(), "country")
+
if m:formvalue("cbid.wireless.%s.__toggle" % wdev:name()) then
if wdev:get("disabled") == "1" or wnet:get("disabled") == "1" then
wnet:set("disabled", nil)
luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless", arg[1]))
return
end
+
Map.parse(map)
+
+ if m:get(wdev:name(), "type") == "mac80211" and new_cc and new_cc ~= old_cc then
+ luci.sys.call("iw reg set %q" % new_cc)
+ luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless", arg[1]))
+ return
+ end
end
m.title = luci.util.pcdata(wnet:get_i18n())
end
end
end
- return (list[#list] and list[#list].driver_dbm) or pwr or 0
+ return pwr or ""
end
local iw = luci.sys.wifi.getiwinfo(arg[1])
------------------- MAC80211 Device ------------------
if hwtype == "mac80211" then
- if #tx_power_list > 1 then
+ if #tx_power_list > 0 then
tp = s:taboption("general", ListValue,
"txpower", translate("Transmit Power"), "dBm")
tp.rmempty = true
return txpower_current(Value.cfgvalue(...), tx_power_list)
end
+ tp:value("", translate("auto"))
for _, p in ipairs(tx_power_list) do
tp:value(p.driver_dbm, "%i dBm (%i mW)"
%{ p.display_dbm, p.display_mw })
return txpower_current(Value.cfgvalue(...), tx_power_list)
end
+ tp:value("", translate("auto"))
for _, p in ipairs(tx_power_list) do
tp:value(p.driver_dbm, "%i dBm (%i mW)"
%{ p.display_dbm, p.display_mw })
return txpower_current(Value.cfgvalue(...), tx_power_list)
end
+ tp:value("", translate("auto"))
for _, p in ipairs(tx_power_list) do
tp:value(p.driver_dbm, "%i dBm (%i mW)"
%{ p.display_dbm, p.display_mw })
if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
- nasid = s:taboption("encryption", Value, "nasid", translate("NAS ID"))
+
+ -- Probe 802.11r support (and EAP support as a proxy for Openwrt)
+ local has_80211r = (os.execute("hostapd -v11r 2>/dev/null || hostapd -veap 2>/dev/null") == 0)
+
+ ieee80211r = s:taboption("encryption", Flag, "ieee80211r",
+ translate("802.11r Fast Transition"),
+ translate("Enables fast roaming among access points that belong " ..
+ "to the same Mobility Domain"))
+ ieee80211r:depends({mode="ap", encryption="wpa"})
+ ieee80211r:depends({mode="ap", encryption="wpa2"})
+ ieee80211r:depends({mode="ap-wds", encryption="wpa"})
+ ieee80211r:depends({mode="ap-wds", encryption="wpa2"})
+ if has_80211r then
+ ieee80211r:depends({mode="ap", encryption="psk"})
+ ieee80211r:depends({mode="ap", encryption="psk2"})
+ ieee80211r:depends({mode="ap", encryption="psk-mixed"})
+ end
+ ieee80211r.rmempty = true
+
+ nasid = s:taboption("encryption", Value, "nasid", translate("NAS ID"),
+ translate("Used for two different purposes: RADIUS NAS ID and " ..
+ "802.11r R0KH-ID. Not needed with normal WPA(2)-PSK."))
nasid:depends({mode="ap", encryption="wpa"})
nasid:depends({mode="ap", encryption="wpa2"})
nasid:depends({mode="ap-wds", encryption="wpa"})
nasid:depends({mode="ap-wds", encryption="wpa2"})
+ nasid:depends({ieee80211r="1"})
nasid.rmempty = true
+ mobility_domain = s:taboption("encryption", Value, "mobility_domain",
+ translate("Mobility Domain"),
+ translate("4-character hexadecimal ID"))
+ mobility_domain:depends({ieee80211r="1"})
+ mobility_domain.placeholder = "4f57"
+ mobility_domain.datatype = "and(hexstring,rangelength(4,4))"
+ mobility_domain.rmempty = true
+
+ r0_key_lifetime = s:taboption("encryption", Value, "r0_key_lifetime",
+ translate("R0 Key Lifetime"), translate("minutes"))
+ r0_key_lifetime:depends({ieee80211r="1"})
+ r0_key_lifetime.placeholder = "10000"
+ r0_key_lifetime.datatype = "uinteger"
+ r0_key_lifetime.rmempty = true
+
+ r1_key_holder = s:taboption("encryption", Value, "r1_key_holder",
+ translate("R1 Key Holder"),
+ translate("6-octet identifier as a hex string - no colons"))
+ r1_key_holder:depends({ieee80211r="1"})
+ r1_key_holder.placeholder = "00004f577274"
+ r1_key_holder.datatype = "and(hexstring,rangelength(12,12))"
+ r1_key_holder.rmempty = true
+
+ reassociation_deadline = s:taboption("encryption", Value, "reassociation_deadline",
+ translate("Reassociation Deadline"),
+ translate("time units (TUs / 1.024 ms) [1000-65535]"))
+ reassociation_deadline:depends({ieee80211r="1"})
+ reassociation_deadline.placeholder = "1000"
+ reassociation_deadline.datatype = "range(1000,65535)"
+ reassociation_deadline.rmempty = true
+
+ pmk_r1_push = s:taboption("encryption", Flag, "pmk_r1_push", translate("PMK R1 Push"))
+ pmk_r1_push:depends({ieee80211r="1"})
+ pmk_r1_push.placeholder = "0"
+ pmk_r1_push.rmempty = true
+
+ r0kh = s:taboption("encryption", DynamicList, "r0kh", translate("External R0 Key Holder List"),
+ translate("List of R0KHs in the same Mobility Domain. " ..
+ "<br />Format: MAC-address,NAS-Identifier,128-bit key as hex string. " ..
+ "<br />This list is used to map R0KH-ID (NAS Identifier) to a destination " ..
+ "MAC address when requesting PMK-R1 key from the R0KH that the STA " ..
+ "used during the Initial Mobility Domain Association."))
+
+ r0kh:depends({ieee80211r="1"})
+ r0kh.rmempty = true
+
+ r1kh = s:taboption("encryption", DynamicList, "r1kh", translate("External R1 Key Holder List"),
+ translate ("List of R1KHs in the same Mobility Domain. "..
+ "<br />Format: MAC-address,R1KH-ID as 6 octets with colons,128-bit key as hex string. "..
+ "<br />This list is used to map R1KH-ID to a destination MAC address " ..
+ "when sending PMK-R1 key from the R0KH. This is also the " ..
+ "list of authorized R1KHs in the MD that can request PMK-R1 keys."))
+ r1kh:depends({ieee80211r="1"})
+ r1kh.rmempty = true
+ -- End of 802.11r options
+
eaptype = s:taboption("encryption", ListValue, "eap_type", translate("EAP-Method"))
eaptype:value("tls", "TLS")
eaptype:value("ttls", "TTLS")
password.password = true
end
+-- ieee802.11w options
+if hwtype == "mac80211" then
+ local has_80211w = (os.execute("hostapd -v11w 2>/dev/null || hostapd -veap 2>/dev/null") == 0)
+ if has_80211w then
+ ieee80211w = s:taboption("encryption", ListValue, "ieee80211w",
+ translate("802.11w Management Frame Protection"),
+ translate("Requires the 'full' version of wpad/hostapd " ..
+ "and support from the wifi driver <br />(as of Feb 2017: " ..
+ "ath9k and ath10k, in LEDE also mwlwifi and mt76)"))
+ ieee80211w.default = ""
+ ieee80211w.rmempty = true
+ ieee80211w:value("", translate("Disabled (default)"))
+ ieee80211w:value("1", translate("Optional"))
+ ieee80211w:value("2", translate("Required"))
+ ieee80211w:depends({mode="ap", encryption="wpa2"})
+ ieee80211w:depends({mode="ap-wds", encryption="wpa2"})
+ ieee80211w:depends({mode="ap", encryption="psk2"})
+ ieee80211w:depends({mode="ap", encryption="psk-mixed"})
+ ieee80211w:depends({mode="ap-wds", encryption="psk2"})
+ ieee80211w:depends({mode="ap-wds", encryption="psk-mixed"})
+
+ max_timeout = s:taboption("encryption", Value, "ieee80211w_max_timeout",
+ translate("802.11w maximum timeout"),
+ translate("802.11w Association SA Query maximum timeout"))
+ max_timeout:depends({ieee80211w="1"})
+ max_timeout:depends({ieee80211w="2"})
+ max_timeout.datatype = "uinteger"
+ max_timeout.placeholder = "1000"
+ max_timeout.rmempty = true
+
+ retry_timeout = s:taboption("encryption", Value, "ieee80211w_retry_timeout",
+ translate("802.11w retry timeout"),
+ translate("802.11w Association SA Query retry timeout"))
+ retry_timeout:depends({ieee80211w="1"})
+ retry_timeout:depends({ieee80211w="2"})
+ retry_timeout.datatype = "uinteger"
+ retry_timeout.placeholder = "201"
+ retry_timeout.rmempty = true
+ end
+end
+
if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
local wpasupplicant = fs.access("/usr/sbin/wpa_supplicant")
local hostcli = fs.access("/usr/sbin/hostapd_cli")
return
end
-m = SimpleForm("network", translate("Joining Network: %q", http.formvalue("join")))
+m = SimpleForm("network", translatef("Joining Network: %q", http.formvalue("join")))
m.cancel = translate("Back to scan results")
m.reset = false
return { "_pass" }
end
-function m.on_commit(map)
+function m.parse(map)
local v1 = pw1:formvalue("_pass")
local v2 = pw2:formvalue("_pass")
m.message = translate("Given password confirmation did not match, password not changed!")
end
end
+
+ Map.parse(map)
end
o = mount:taboption("general", Value, "uuid", translate("UUID"),
translate("If specified, mount the device by its UUID instead of a fixed device node"))
+o:value("", translate("-- match by uuid --"))
+
for i, d in ipairs(devices) do
if d.uuid and d.size then
o:value(d.uuid, "%s (%s, %d MB)" %{ d.uuid, d.dev, d.size })
end
end
-o:value("", translate("-- match by label --"))
-
o = mount:taboption("general", Value, "label", translate("Label"),
translate("If specified, mount the device by the partition label instead of a fixed device node"))
+o:value("", translate("-- match by label --"))
+
o:depends("uuid", "")
for i, d in ipairs(devices) do
end
end
-o:value("", translate("-- match by device --"))
-
o = mount:taboption("general", Value, "device", translate("Device"),
translate("The device file of the memory or partition (<abbr title=\"for example\">e.g.</abbr> <code>/dev/sda1</code>)"))
+o:value("", translate("-- match by device --"))
+
o:depends({ uuid = "", label = "" })
for i, d in ipairs(devices) do
local leds = {}
local fs = require "nixio.fs"
-local util = require "nixio.util"
+local nu = require "nixio.util"
+local util = require "luci.util"
if fs.access(sysfs_path) then
- leds = util.consume((fs.dir(sysfs_path)))
+ leds = nu.consume((fs.dir(sysfs_path)))
end
if #leds == 0 then
end
end
+
+usbport = s:option(MultiValue, "port", translate("USB Ports"))
+usbport:depends("trigger", "usbport")
+usbport.rmempty = true
+usbport.widget = "checkbox"
+usbport.cast = "table"
+usbport.size = 1
+
+function usbport.valuelist(self, section)
+ local port, ports = nil, {}
+ for port in util.imatch(m.uci:get("system", section, "port")) do
+ local b, n = port:match("^usb(%d+)-port(%d+)$")
+ if not (b and n) then
+ b, n = port:match("^(%d+)-(%d+)$")
+ end
+ if b and n then
+ ports[#ports+1] = "usb%u-port%u" %{ tonumber(b), tonumber(n) }
+ end
+ end
+ return ports
+end
+
+function usbport.validate(self, value)
+ return type(value) == "string" and { value } or value
+end
+
+
for p in nixio.fs.glob("/sys/bus/usb/devices/[0-9]*/manufacturer") do
local id = p:match("%d+-%d+")
local mf = nixio.fs.readfile("/sys/bus/usb/devices/" .. id .. "/manufacturer") or "?"
usbdev:value(id, "%s (%s - %s)" %{ id, mf, pr })
end
+for p in nixio.fs.glob("/sys/bus/usb/devices/*/usb[0-9]*-port[0-9]*") do
+ local bus, port = p:match("usb(%d+)-port(%d+)")
+ if bus and port then
+ usbport:value("usb%u-port%u" %{ tonumber(bus), tonumber(port) },
+ "Hub %u, Port %u" %{ tonumber(bus), tonumber(port) })
+ end
+end
+
return m
ifc.ip6addrs[i]
);
}
+
+ if (ifc.ip6prefix)
+ {
+ html += String.format('<strong><%:IPv6-PD%>:</strong> %s<br />', ifc.ip6prefix);
+ }
d.innerHTML = html;
}
ifc.ip6addrs[i]
);
}
+
+ if (ifc.ip6prefix)
+ {
+ html += String.format('<strong><%:IPv6-PD%>:</strong> %s<br />', ifc.ip6prefix);
+ }
d.innerHTML = html;
}
{
var c = conn[i];
- if (c.src == '127.0.0.1' && c.dst == '127.0.0.1')
+ if ((c.src == '127.0.0.1' && c.dst == '127.0.0.1')
+ || (c.src == '::1' && c.dst == '::1'))
continue;
var tr = conn_table.rows[0].parentNode.insertRow(-1);
if wan6 then
rv.wan6 = {
- ip6addr = wan6:ip6addr(),
- gw6addr = wan6:gw6addr(),
- dns = wan6:dns6addrs(),
- uptime = wan6:uptime(),
- ifname = wan6:ifname(),
- link = wan6:adminlink()
+ ip6addr = wan6:ip6addr(),
+ gw6addr = wan6:gw6addr(),
+ dns = wan6:dns6addrs(),
+ ip6prefix = wan6:ip6prefix(),
+ uptime = wan6:uptime(),
+ proto = wan6:proto(),
+ ifname = wan6:ifname(),
+ link = wan6:adminlink()
}
end
if (ifc6 && ifc6.ifname && ifc6.proto != 'none')
{
var s = String.format(
- '<strong><%:Address%>: </strong>%s<br />' +
+ '<strong><%:Type%>: </strong>%s%s<br />',
+ ifc6.proto, (ifc6.ip6prefix) ? '-pd' : ''
+ );
+
+ if (!ifc6.ip6prefix)
+ {
+ s += String.format(
+ '<strong><%:Address%>: </strong>%s<br />',
+ (ifc6.ip6addr) ? ifc6.ip6addr : '::'
+ );
+ }
+ else
+ {
+ s += String.format(
+ '<strong><%:Prefix Delegated%>: </strong>%s<br />',
+ ifc6.ip6prefix
+ );
+ if (ifc6.ip6addr)
+ {
+ s += String.format(
+ '<strong><%:Address%>: </strong>%s<br />',
+ ifc6.ip6addr
+ );
+ }
+ }
+
+ s += String.format(
'<strong><%:Gateway%>: </strong>%s<br />',
- (ifc6.ip6addr) ? ifc6.ip6addr : '::',
(ifc6.gw6addr) ? ifc6.gw6addr : '::'
);
if (strstr(line, "TIME_WAIT"))
continue;
- if (strstr(line, "src=127.0.0.1 ") &&
- strstr(line, "dst=127.0.0.1 "))
+ if ((strstr(line, "src=127.0.0.1 ") && strstr(line, "dst=127.0.0.1 "))
+ || (strstr(line, "src=::1 ") && strstr(line, "dst=::1 ")))
continue;
if (sscanf(line, "%*s %*d %s", ifname) || sscanf(line, "%s %*d", ifname))
--- Copyright 2016 Dan Luedtke <mail@danrl.com>
+-- Copyright 2016-2017 Dan Luedtke <mail@danrl.com>
-- Licensed to the public under the Apache License 2.0.
listen_port.placeholder = "51820"
listen_port.optional = true
+addresses = section:taboption(
+ "general",
+ DynamicList,
+ "addresses",
+ translate("IP Addresses"),
+ translate("Recommended. IP addresses of the WireGuard interface.")
+)
+addresses.datatype = "ipaddr"
+addresses.optional = true
+
-- advanced --------------------------------------------------------------------
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(LEDE_GIT)/project/firewall3.git
-PKG_SOURCE_DATE:=2016-11-29
-PKG_SOURCE_VERSION:=13698aafb52c45817ee7815da3405e620657c8d0
-PKG_MIRROR_HASH:=6ba6e96a588dd3afd7e9db7e9246c5cc6c560aa95385592960c6b71b5a9c6395
+PKG_SOURCE_DATE:=2017-01-13
+PKG_SOURCE_VERSION:=37cb4cb437fd685f31926a4c326ba8afe329e4a6
+PKG_MIRROR_HASH:=7ee075f05977e5d9a78e661b537e6eb077c8f328ff2e71d1e2fbef44cca97355
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
PKG_LICENSE:=ISC
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(LEDE_GIT)/project/netifd.git
-PKG_SOURCE_DATE:=2016-12-23
-PKG_SOURCE_VERSION:=64a655d8ffa9f0cea1bbdd35cac6b3b99b865270
-PKG_MIRROR_HASH:=1fa244a10f6d12d8bad2e60c054c0542d6f9ebe1cde319085f02289e8676612a
+PKG_SOURCE_DATE:=2017-01-25
+PKG_SOURCE_VERSION:=650758b16e5185505a3fbc1307949340af70b611
+PKG_MIRROR_HASH:=d09c740bc1bf6269678bd75c9af52ecd4be3d1d59402a543ceb9d4459cecfa2b
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_LICENSE:=GPL-2.0
/sbin/wifi reload_legacy
}
-stop() {
+stop_service() {
/sbin/wifi down
- procd_kill network ''
+ ifdown -a
+ sleep 1
}
service_running() {
procd_close_validate
}
-restart() {
- ifdown -a
- sleep 1
- trap '' TERM
- stop "$@"
- start "$@"
-}
-
shutdown() {
ifdown -a
sleep 1
fi
add_insmod cls_fw
add_insmod sch_hfsc
- add_insmod sch_fq_codel
cat <<EOF
${INSMOD:+$INSMOD$N}${dev_up:+$dev_up
start_firewall() {
add_insmod xt_multiport
- add_insmod xt_CONNMARK
+ add_insmod xt_connmark
stop_firewall
for group in $CG; do
start_cg $group
s = uci_to_section(e);
if (!strcmp(s->type, "switch_port")) {
- char *devn, *port, *port_err = NULL;
+ char *devn = NULL, *port = NULL, *port_err = NULL;
int port_n;
uci_foreach_element(&s->options, os) {
swlib_map_settings(dev, SWLIB_ATTR_GROUP_PORT, port_n, s);
} else if (!strcmp(s->type, "switch_vlan")) {
- char *devn, *vlan, *vlan_err = NULL;
+ char *devn = NULL, *vlan = NULL, *vlan_err = NULL;
int vlan_n;
uci_foreach_element(&s->options, os) {
local http="http"
local urlget="uclient-fetch"
local urlget_opts="-qO-"
- local ca_path="${SSL_CERT_DIR-/etc/ssl/certs}"
+ local ca_path="${SSL_CERT_DIR:-/etc/ssl/certs}"
[ -f /lib/libustream-ssl.so ] && http=https
[ "$http" = "https" -a -z "$(find $ca_path -name "*.0" 2>/dev/null)" ] && {
PKG_NAME:=map
PKG_VERSION:=4
-PKG_RELEASE:=5
+PKG_RELEASE:=6
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
CATEGORY:=Network
DEPENDS:=@IPV6 +kmod-ip6-tunnel +libubox +libubus +iptables-mod-conntrack-extra
TITLE:=MAP-E and Lightweight 4over6 configuration support
- MAINTAINER:=Steven Barth <steven@midlink.org>
+ MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com>
endef
define Package/map/description
proto_map_teardown() {
local cfg="$1"
- ifdown "${cfg}_"
+ local link="map-$cfg"
+
+ json_get_var type type
+
+ [ -z "$type" ] && type="map-e"
+
+ case "$type" in
+ "map-e"|"lw4o6") ifdown "${cfg}_" ;;
+ "map-t") [ -f "/proc/net/nat46/control" ] && echo del $link > /proc/net/nat46/control ;;
+ esac
+
rm -f /tmp/map-$cfg.rules
}
PKG_NAME:=odhcp6c
PKG_RELEASE:=1
-PKG_SOURCE_URL:=git://git.lede-project.org/project/odhcp6c.git
PKG_SOURCE_PROTO:=git
-PKG_SOURCE_DATE:=2017-01-07
-PKG_SOURCE_VERSION:=d420f49396c627ce1072b83170889baf0720bc8b
-PKG_MIRROR_HASH:=a7c599b5600b6cca9aec221dd32fc7754e0e942b0192bd902f1e789f53345127
-PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
+PKG_SOURCE_URL:=$(LEDE_GIT)/project/odhcp6c.git
+PKG_SOURCE_DATE:=2017-01-30
+PKG_SOURCE_VERSION:=c13b6a05dbd9174356cc4b7fd1edf39445efd982
+PKG_MIRROR_HASH:=001e58f1ab6eb8903d9e47060ae037a2e4f021f1fef5032347b767f56f4664f6
+PKG_MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com>
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
PKG_NAME:=dnsmasq
PKG_VERSION:=2.76
-PKG_RELEASE:=7
+PKG_RELEASE:=6
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq
ADD_LOCAL_DOMAIN=1
ADD_LOCAL_HOSTNAME=1
-ADD_WAN_HOSTNAME=0
BASECONFIGFILE="/var/etc/dnsmasq.conf"
BASEHOSTFILE="/tmp/hosts/dhcp"
xappend "--dhcp-host=$macs${duid:+,id:$duid}${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip${hostid:+,[::$hostid]}}${name:+,$name}${leasetime:+,$leasetime}"
}
-dhcp_this_host_add() {
- # TODO: case-in do/not short-host or FQDN; UCI already intended ...
- local ifname="$1"
- local do_enable="$2"
- local routerstub routername ifdashname
-
-
- if [ "$do_enable" -gt 0 ] ; then
- # All IP addresses discovered by dnsmasq will be labeled robustly (except fe80::)
- ifdashname="${ifname//./-}"
- routerstub="$( md5sum /etc/os-release )"
- routerstub="router-${routerstub// */}"
- routername="$( uci_get system @system[0] hostname $routerstub )"
-
- xappend "--interface-name=$ifdashname.$routername.$DOMAIN,$ifname"
- xappend "--interface-name=$routername.$DOMAIN,$ifname"
- xappend "--interface-name=$routername,$ifname"
- fi
-}
-
dhcp_tag_add() {
local cfg="$1"
DNS_SERVERS="$DNS_SERVERS $dnsserver"
}
- append_bool "$cfg" ignore "--no-dhcp-interface=$ifname" && {
- # Many ISP do not have useful names for DHCP customers (your WAN).
- dhcp_this_host_add $ifname $ADD_WAN_HOSTNAME
- return 0
- }
+ append_bool "$cfg" ignore "--no-dhcp-interface=$ifname" && return 0
# Do not support non-static interfaces for now
[ static = "$proto" ] || return 0
config_get options "$cfg" options
config_get_bool dynamicdhcp "$cfg" dynamicdhcp 1
- # Put the router host name on this DHCP served interface address(es)
- dhcp_this_host_add $ifname $ADD_LOCAL_HOSTNAME
-
leasetime="${leasetime:-12h}"
start="$(dhcp_calc "${start:-100}")"
limit="${limit:-150}"
config_get_bool ADD_LOCAL_DOMAIN "$cfg" add_local_domain 1
config_get_bool ADD_LOCAL_HOSTNAME "$cfg" add_local_hostname 1
- config_get_bool ADD_WAN_HOSTNAME "$cfg" add_wan_hostname 0
config_get_bool readethers "$cfg" readethers
[ "$readethers" = "1" -a \! -e "/etc/ethers" ] && touch /etc/ethers
config_foreach filter_dnsmasq hostrecord dhcp_hostrecord_add "$cfg"
config_foreach filter_dnsmasq relay dhcp_relay_add "$cfg"
+ # add own hostname
+ [ $ADD_LOCAL_HOSTNAME -eq 1 ] && {
+ local lanaddr lanaddr6
+ local ulaprefix="$(uci_get network @globals[0] ula_prefix)"
+ local hostname="$(uci_get system @system[0] hostname Lede)"
+
+ network_get_ipaddr lanaddr "lan" && {
+ dhcp_domain_add "" "$hostname" "$lanaddr"
+ }
+
+ [ -n "$ulaprefix" ] && network_get_ipaddrs6 lanaddr6 "lan" && {
+ for lanaddr6 in $lanaddr6; do
+ case "$lanaddr6" in
+ "${ulaprefix%%:/*}"*)
+ dhcp_domain_add "" "$hostname" "$lanaddr6"
+ ;;
+ esac
+ done
+ }
+ }
+
echo >> $CONFIGFILE_TMP
config_foreach filter_dnsmasq srvhost dhcp_srv_add "$cfg"
config_foreach filter_dnsmasq mxhost dhcp_mx_add "$cfg"
#!/bin/sh
+. /lib/functions/procd.sh
+
TIMEVALIDFILE="/var/state/dnsmasqsec"
[ "$ACTION" = stratum ] || exit 0
[ -f "$TIMEVALIDFILE" ] || {
echo "ntpd says time is valid" >$TIMEVALIDFILE
/etc/init.d/dnsmasq enabled && {
- pid=$(pidof dnsmasq)
- [ "$(readlink /proc/$pid/exe)" = "/usr/sbin/dnsmasq" ] && kill -SIGHUP $pid \
- || /etc/init.d/dnsmasq restart
+ procd_send_signal dnsmasq
}
}
--- /dev/null
+From 68f6312d4bae30b78daafcd6f51dc441b8685b1e Mon Sep 17 00:00:00 2001
+From: Baptiste Jonglez <git@bitsofnetworks.org>
+Date: Mon, 6 Feb 2017 21:09:11 +0000
+Subject: [PATCH] Stop treating SERVFAIL as a successful response from upstream
+ servers.
+
+This effectively reverts most of 51967f9807 ("SERVFAIL is an expected
+error return, don't try all servers.") and 4ace25c5d6 ("Treat REFUSED (not
+SERVFAIL) as an unsuccessful upstream response").
+
+With the current behaviour, as soon as dnsmasq receives a SERVFAIL from an
+upstream server, it stops trying to resolve the query and simply returns
+SERVFAIL to the client. With this commit, dnsmasq will instead try to
+query other upstream servers upon receiving a SERVFAIL response.
+
+According to RFC 1034 and 1035, the semantic of SERVFAIL is that of a
+temporary error condition. Recursive resolvers are expected to encounter
+network or resources issues from time to time, and will respond with
+SERVFAIL in this case. Similarly, if a validating DNSSEC resolver [RFC
+4033] encounters issues when checking signatures (unknown signing
+algorithm, missing signatures, expired signatures because of a wrong
+system clock, etc), it will respond with SERVFAIL.
+
+Note that all those behaviours are entirely different from a negative
+response, which would provide a definite indication that the requested
+name does not exist. In our case, if an upstream server responds with
+SERVFAIL, another upstream server may well provide a positive answer for
+the same query.
+
+Thus, this commit will increase robustness whenever some upstream servers
+encounter temporary issues or are misconfigured.
+
+Quoting RFC 1034, Section 4.3.1. "Queries and responses":
+
+ If recursive service is requested and available, the recursive response
+ to a query will be one of the following:
+
+ - The answer to the query, possibly preface by one or more CNAME
+ RRs that specify aliases encountered on the way to an answer.
+
+ - A name error indicating that the name does not exist. This
+ may include CNAME RRs that indicate that the original query
+ name was an alias for a name which does not exist.
+
+ - A temporary error indication.
+
+Here is Section 5.2.3. of RFC 1034, "Temporary failures":
+
+ In a less than perfect world, all resolvers will occasionally be unable
+ to resolve a particular request. This condition can be caused by a
+ resolver which becomes separated from the rest of the network due to a
+ link failure or gateway problem, or less often by coincident failure or
+ unavailability of all servers for a particular domain.
+
+And finally, RFC 1035 specifies RRCODE 2 for this usage, which is now more
+widely known as SERVFAIL (RFC 1035, Section 4.1.1. "Header section format"):
+
+ RCODE Response code - this 4 bit field is set as part of
+ responses. The values have the following
+ interpretation:
+ (...)
+
+ 2 Server failure - The name server was
+ unable to process this query due to a
+ problem with the name server.
+
+For the DNSSEC-related usage of SERVFAIL, here is RFC 4033
+Section 5. "Scope of the DNSSEC Document Set and Last Hop Issues":
+
+ A validating resolver can determine the following 4 states:
+ (...)
+
+ Insecure: The validating resolver has a trust anchor, a chain of
+ trust, and, at some delegation point, signed proof of the
+ non-existence of a DS record. This indicates that subsequent
+ branches in the tree are provably insecure. A validating resolver
+ may have a local policy to mark parts of the domain space as
+ insecure.
+
+ Bogus: The validating resolver has a trust anchor and a secure
+ delegation indicating that subsidiary data is signed, but the
+ response fails to validate for some reason: missing signatures,
+ expired signatures, signatures with unsupported algorithms, data
+ missing that the relevant NSEC RR says should be present, and so
+ forth.
+ (...)
+
+ This specification only defines how security-aware name servers can
+ signal non-validating stub resolvers that data was found to be bogus
+ (using RCODE=2, "Server Failure"; see [RFC4035]).
+
+Notice the difference between a definite negative answer ("Insecure"
+state), and an indefinite error condition ("Bogus" state). The second
+type of error may be specific to a recursive resolver, for instance
+because its system clock has been incorrectly set, or because it does not
+implement newer cryptographic primitives. Another recursive resolver may
+succeed for the same query.
+
+There are other similar situations in which the specified behaviour is
+similar to the one implemented by this commit.
+
+For instance, RFC 2136 specifies the behaviour of a "requestor" that wants
+to update a zone using the DNS UPDATE mechanism. The requestor tries to
+contact all authoritative name servers for the zone, with the following
+behaviour specified in RFC 2136, Section 4:
+
+ 4.6. If a response is received whose RCODE is SERVFAIL or NOTIMP, or
+ if no response is received within an implementation dependent timeout
+ period, or if an ICMP error is received indicating that the server's
+ port is unreachable, then the requestor will delete the unusable
+ server from its internal name server list and try the next one,
+ repeating until the name server list is empty. If the requestor runs
+ out of servers to try, an appropriate error will be returned to the
+ requestor's caller.
+---
+ src/forward.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/src/forward.c
++++ b/src/forward.c
+@@ -853,7 +853,8 @@ void reply_query(int fd, int family, tim
+ we get a good reply from another server. Kill it when we've
+ had replies from all to avoid filling the forwarding table when
+ everything is broken */
+- if (forward->forwardall == 0 || --forward->forwardall == 1 || RCODE(header) != REFUSED)
++ if (forward->forwardall == 0 || --forward->forwardall == 1 ||
++ (RCODE(header) != REFUSED && RCODE(header) != SERVFAIL))
+ {
+ int check_rebind = 0, no_cache_dnssec = 0, cache_secure = 0, bogusanswer = 0;
+
PKG_NAME:=dropbear
PKG_VERSION:=2016.74
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:= \
* which are not the standard form. */
#define DROPBEAR_SHA1_HMAC
-#define DROPBEAR_SHA1_96_HMAC
--#define DROPBEAR_SHA2_256_HMAC
--#define DROPBEAR_SHA2_512_HMAC
+/*#define DROPBEAR_SHA1_96_HMAC*/
-+/*#define DROPBEAR_SHA2_256_HMAC*/
+ #define DROPBEAR_SHA2_256_HMAC
+-#define DROPBEAR_SHA2_512_HMAC
+/*#define DROPBEAR_SHA2_512_HMAC*/
#define DROPBEAR_MD5_HMAC
include $(TOPDIR)/rules.mk
PKG_NAME:=hostapd
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE_URL:=http://w1.fi/hostap.git
PKG_SOURCE_PROTO:=git
SECTION:=net
CATEGORY:=Network
VARIANT:=supplicant-full
- DEPENDS:=$(DRV_DEPENDS)
+ DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl
endef
endef
define Build/Compile/hostapd
- $(call Build/RunMake,hostapd, \
+ +$(call Build/RunMake,hostapd, \
hostapd hostapd_cli \
)
endef
define Build/Compile/supplicant
- $(call Build/RunMake,wpa_supplicant, \
+ +$(call Build/RunMake,wpa_supplicant, \
wpa_cli wpa_supplicant \
)
endef
define Build/Compile/supplicant-full
- $(call Build/RunMake,wpa_supplicant, \
+ +$(call Build/RunMake,wpa_supplicant, \
eapol_test \
)
endef
define Package/hostapd-common/install
$(INSTALL_DIR) $(1)/lib/netifd
- $(INSTALL_DATA) ./files/netifd.sh $(1)/lib/netifd/hostapd.sh
+ $(INSTALL_DATA) ./files/hostapd.sh $(1)/lib/netifd/hostapd.sh
endef
define Package/hostapd/install
# code is not needed.
#CONFIG_NO_STDOUT_DEBUG=y
+# Send debug messages to syslog instead of stdout
+CONFIG_DEBUG_SYSLOG=y
+
# Remove support for RADIUS accounting
#CONFIG_NO_ACCOUNTING=y
# code is not needed.
#CONFIG_NO_STDOUT_DEBUG=y
+# Send debug messages to syslog instead of stdout
+CONFIG_DEBUG_SYSLOG=y
+
# Remove support for RADIUS accounting
CONFIG_NO_ACCOUNTING=y
--- /dev/null
+. /lib/functions/network.sh
+
+wpa_supplicant_add_rate() {
+ local var="$1"
+ local val="$(($2 / 1000))"
+ local sub="$((($2 / 100) % 10))"
+ append $var "$val" ","
+ [ $sub -gt 0 ] && append $var "."
+}
+
+hostapd_add_rate() {
+ local var="$1"
+ local val="$(($2 / 100))"
+ append $var "$val" " "
+}
+
+hostapd_append_wep_key() {
+ local var="$1"
+
+ wep_keyidx=0
+ set_default key 1
+ case "$key" in
+ [1234])
+ for idx in 1 2 3 4; do
+ local zidx
+ zidx=$(($idx - 1))
+ json_get_var ckey "key${idx}"
+ [ -n "$ckey" ] && \
+ append $var "wep_key${zidx}=$(prepare_key_wep "$ckey")" "$N$T"
+ done
+ wep_keyidx=$((key - 1))
+ ;;
+ *)
+ append $var "wep_key0=$(prepare_key_wep "$key")" "$N$T"
+ ;;
+ esac
+}
+
+hostapd_append_wpa_key_mgmt() {
+ local auth_type="$(echo $auth_type | tr 'a-z' 'A-Z')"
+
+ append wpa_key_mgmt "WPA-$auth_type"
+ [ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-${auth_type}"
+ [ "${ieee80211w:-0}" -gt 0 ] && append wpa_key_mgmt "WPA-${auth_type}-SHA256"
+}
+
+hostapd_add_log_config() {
+ config_add_boolean \
+ log_80211 \
+ log_8021x \
+ log_radius \
+ log_wpa \
+ log_driver \
+ log_iapp \
+ log_mlme
+
+ config_add_int log_level
+}
+
+hostapd_common_add_device_config() {
+ config_add_array basic_rate
+ config_add_array supported_rates
+
+ config_add_string country
+ config_add_boolean country_ie doth
+ config_add_string require_mode
+
+ hostapd_add_log_config
+}
+
+hostapd_prepare_device_config() {
+ local config="$1"
+ local driver="$2"
+
+ local base="${config%%.conf}"
+ local base_cfg=
+
+ json_get_vars country country_ie beacon_int doth require_mode
+
+ hostapd_set_log_options base_cfg
+
+ set_default country_ie 1
+ set_default doth 1
+
+ [ -n "$country" ] && {
+ append base_cfg "country_code=$country" "$N"
+
+ [ "$country_ie" -gt 0 ] && append base_cfg "ieee80211d=1" "$N"
+ [ "$hwmode" = "a" -a "$doth" -gt 0 ] && append base_cfg "ieee80211h=1" "$N"
+ }
+ [ -n "$hwmode" ] && append base_cfg "hw_mode=$hwmode" "$N"
+
+ local brlist= br
+ json_get_values basic_rate_list basic_rate
+ for br in $basic_rate_list; do
+ hostapd_add_rate brlist "$br"
+ done
+ case "$require_mode" in
+ g) brlist="60 120 240" ;;
+ n) append base_cfg "require_ht=1" "$N";;
+ ac) append base_cfg "require_vht=1" "$N";;
+ esac
+
+ local rlist= r
+ json_get_values rate_list supported_rates
+ for r in $rate_list; do
+ hostapd_add_rate rlist "$r"
+ done
+
+ [ -n "$rlist" ] && append base_cfg "supported_rates=$rlist" "$N"
+ [ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N"
+ [ -n "$beacon_int" ] && append base_cfg "beacon_int=$beacon_int" "$N"
+
+ cat > "$config" <<EOF
+driver=$driver
+$base_cfg
+EOF
+}
+
+hostapd_common_add_bss_config() {
+ config_add_string 'bssid:macaddr' 'ssid:string'
+ config_add_boolean wds wmm uapsd hidden
+
+ config_add_int maxassoc max_inactivity
+ config_add_boolean disassoc_low_ack isolate short_preamble
+
+ config_add_int \
+ wep_rekey eap_reauth_period \
+ wpa_group_rekey wpa_pair_rekey wpa_master_rekey
+
+ config_add_boolean rsn_preauth auth_cache
+ config_add_int ieee80211w
+ config_add_int eapol_version
+
+ config_add_string 'auth_server:host' 'server:host'
+ config_add_string auth_secret
+ config_add_int 'auth_port:port' 'port:port'
+
+ config_add_string acct_server
+ config_add_string acct_secret
+ config_add_int acct_port
+
+ config_add_string dae_client
+ config_add_string dae_secret
+ config_add_int dae_port
+
+ config_add_string nasid
+ config_add_string ownip
+ config_add_string iapp_interface
+ config_add_string eap_type ca_cert client_cert identity anonymous_identity auth priv_key priv_key_pwd
+
+ config_add_int dynamic_vlan vlan_naming
+ config_add_string vlan_tagged_interface vlan_bridge
+ config_add_string vlan_file
+
+ config_add_string 'key1:wepkey' 'key2:wepkey' 'key3:wepkey' 'key4:wepkey' 'password:wpakey'
+
+ config_add_string wpa_psk_file
+
+ config_add_boolean wps_pushbutton wps_label ext_registrar wps_pbc_in_m1
+ config_add_int wps_ap_setup_locked wps_independent
+ config_add_string wps_device_type wps_device_name wps_manufacturer wps_pin
+
+ config_add_boolean ieee80211r pmk_r1_push
+ config_add_int r0_key_lifetime reassociation_deadline
+ config_add_string mobility_domain r1_key_holder
+ config_add_array r0kh r1kh
+
+ config_add_int ieee80211w_max_timeout ieee80211w_retry_timeout
+
+ config_add_string macfilter 'macfile:file'
+ config_add_array 'maclist:list(macaddr)'
+
+ config_add_array bssid_blacklist
+ config_add_array bssid_whitelist
+
+ config_add_int mcast_rate
+ config_add_array basic_rate
+ config_add_array supported_rates
+}
+
+hostapd_set_bss_options() {
+ local var="$1"
+ local phy="$2"
+ local vif="$3"
+
+ wireless_vif_parse_encryption
+
+ local bss_conf
+ local wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey wpa_key_mgmt
+
+ json_get_vars \
+ wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey \
+ maxassoc max_inactivity disassoc_low_ack isolate auth_cache \
+ wps_pushbutton wps_label ext_registrar wps_pbc_in_m1 wps_ap_setup_locked \
+ wps_independent wps_device_type wps_device_name wps_manufacturer wps_pin \
+ macfilter ssid wmm uapsd hidden short_preamble rsn_preauth \
+ iapp_interface eapol_version acct_server acct_secret acct_port \
+ dynamic_vlan ieee80211w
+
+ set_default isolate 0
+ set_default maxassoc 0
+ set_default max_inactivity 0
+ set_default short_preamble 1
+ set_default disassoc_low_ack 1
+ set_default hidden 0
+ set_default wmm 1
+ set_default uapsd 1
+ set_default eapol_version 0
+ set_default acct_port 1813
+
+ append bss_conf "ctrl_interface=/var/run/hostapd"
+ if [ "$isolate" -gt 0 ]; then
+ append bss_conf "ap_isolate=$isolate" "$N"
+ fi
+ if [ "$maxassoc" -gt 0 ]; then
+ append bss_conf "max_num_sta=$maxassoc" "$N"
+ fi
+ if [ "$max_inactivity" -gt 0 ]; then
+ append bss_conf "ap_max_inactivity=$max_inactivity" "$N"
+ fi
+
+ append bss_conf "disassoc_low_ack=$disassoc_low_ack" "$N"
+ append bss_conf "preamble=$short_preamble" "$N"
+ append bss_conf "wmm_enabled=$wmm" "$N"
+ append bss_conf "ignore_broadcast_ssid=$hidden" "$N"
+ append bss_conf "uapsd_advertisement_enabled=$uapsd" "$N"
+
+ [ "$wpa" -gt 0 ] && {
+ [ -n "$wpa_group_rekey" ] && append bss_conf "wpa_group_rekey=$wpa_group_rekey" "$N"
+ [ -n "$wpa_pair_rekey" ] && append bss_conf "wpa_ptk_rekey=$wpa_pair_rekey" "$N"
+ [ -n "$wpa_master_rekey" ] && append bss_conf "wpa_gmk_rekey=$wpa_master_rekey" "$N"
+ }
+
+ [ -n "$acct_server" ] && {
+ append bss_conf "acct_server_addr=$acct_server" "$N"
+ append bss_conf "acct_server_port=$acct_port" "$N"
+ [ -n "$acct_secret" ] && \
+ append bss_conf "acct_server_shared_secret=$acct_secret" "$N"
+ }
+
+ local vlan_possible=""
+
+ case "$auth_type" in
+ none)
+ wps_possible=1
+ # Here we make the assumption that if we're in open mode
+ # with WPS enabled, we got to be in unconfigured state.
+ wps_not_configured=1
+ ;;
+ psk)
+ json_get_vars key wpa_psk_file
+ if [ ${#key} -lt 8 ]; then
+ wireless_setup_vif_failed INVALID_WPA_PSK
+ return 1
+ elif [ ${#key} -eq 64 ]; then
+ append bss_conf "wpa_psk=$key" "$N"
+ else
+ append bss_conf "wpa_passphrase=$key" "$N"
+ fi
+ [ -n "$wpa_psk_file" ] && {
+ [ -e "$wpa_psk_file" ] || touch "$wpa_psk_file"
+ append bss_conf "wpa_psk_file=$wpa_psk_file" "$N"
+ }
+ [ "$eapol_version" -ge "1" -a "$eapol_version" -le "2" ] && append bss_conf "eapol_version=$eapol_version" "$N"
+
+ wps_possible=1
+ ;;
+ eap)
+ json_get_vars \
+ auth_server auth_secret auth_port \
+ dae_client dae_secret dae_port \
+ ownip \
+ eap_reauth_period
+
+ # radius can provide VLAN ID for clients
+ vlan_possible=1
+
+ # legacy compatibility
+ [ -n "$auth_server" ] || json_get_var auth_server server
+ [ -n "$auth_port" ] || json_get_var auth_port port
+ [ -n "$auth_secret" ] || json_get_var auth_secret key
+
+ set_default auth_port 1812
+ set_default dae_port 3799
+
+
+ append bss_conf "auth_server_addr=$auth_server" "$N"
+ append bss_conf "auth_server_port=$auth_port" "$N"
+ append bss_conf "auth_server_shared_secret=$auth_secret" "$N"
+
+ [ -n "$eap_reauth_period" ] && append bss_conf "eap_reauth_period=$eap_reauth_period" "$N"
+
+ [ -n "$dae_client" -a -n "$dae_secret" ] && {
+ append bss_conf "radius_das_port=$dae_port" "$N"
+ append bss_conf "radius_das_client=$dae_client $dae_secret" "$N"
+ }
+
+ [ -n "$ownip" ] && append bss_conf "own_ip_addr=$ownip" "$N"
+ append bss_conf "eapol_key_index_workaround=1" "$N"
+ append bss_conf "ieee8021x=1" "$N"
+
+ [ "$eapol_version" -ge "1" -a "$eapol_version" -le "2" ] && append bss_conf "eapol_version=$eapol_version" "$N"
+ ;;
+ wep)
+ local wep_keyidx=0
+ json_get_vars key
+ hostapd_append_wep_key bss_conf
+ append bss_conf "wep_default_key=$wep_keyidx" "$N"
+ [ -n "$wep_rekey" ] && append bss_conf "wep_rekey_period=$wep_rekey" "$N"
+ ;;
+ esac
+
+ local auth_algs=$((($auth_mode_shared << 1) | $auth_mode_open))
+ append bss_conf "auth_algs=${auth_algs:-1}" "$N"
+ append bss_conf "wpa=$wpa" "$N"
+ [ -n "$wpa_pairwise" ] && append bss_conf "wpa_pairwise=$wpa_pairwise" "$N"
+
+ set_default wps_pushbutton 0
+ set_default wps_label 0
+ set_default wps_pbc_in_m1 0
+
+ config_methods=
+ [ "$wps_pushbutton" -gt 0 ] && append config_methods push_button
+ [ "$wps_label" -gt 0 ] && append config_methods label
+
+ [ -n "$wps_possible" -a -n "$config_methods" ] && {
+ set_default ext_registrar 0
+ set_default wps_device_type "6-0050F204-1"
+ set_default wps_device_name "Lede AP"
+ set_default wps_manufacturer "www.lede-project.org"
+ set_default wps_independent 1
+
+ wps_state=2
+ [ -n "$wps_configured" ] && wps_state=1
+
+ [ "$ext_registrar" -gt 0 -a -n "$network_bridge" ] && append bss_conf "upnp_iface=$network_bridge" "$N"
+
+ append bss_conf "eap_server=1" "$N"
+ [ -n "$wps_pin" ] && append bss_conf "ap_pin=$wps_pin" "$N"
+ append bss_conf "wps_state=$wps_state" "$N"
+ append bss_conf "device_type=$wps_device_type" "$N"
+ append bss_conf "device_name=$wps_device_name" "$N"
+ append bss_conf "manufacturer=$wps_manufacturer" "$N"
+ append bss_conf "config_methods=$config_methods" "$N"
+ append bss_conf "wps_independent=$wps_independent" "$N"
+ [ -n "$wps_ap_setup_locked" ] && append bss_conf "ap_setup_locked=$wps_ap_setup_locked" "$N"
+ [ "$wps_pbc_in_m1" -gt 0 ] && append bss_conf "pbc_in_m1=$wps_pbc_in_m1" "$N"
+ }
+
+ append bss_conf "ssid=$ssid" "$N"
+ [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge" "$N"
+ [ -n "$iapp_interface" ] && {
+ local ifname
+ network_get_device ifname "$iapp_interface" || ifname = "$iapp_interface"
+ append bss_conf "iapp_interface=$ifname" "$N"
+ }
+
+ if [ "$wpa" -ge "1" ]; then
+ json_get_vars nasid ieee80211r
+ set_default ieee80211r 0
+ [ -n "$nasid" ] && append bss_conf "nas_identifier=$nasid" "$N"
+
+ if [ "$ieee80211r" -gt "0" ]; then
+ json_get_vars mobility_domain r0_key_lifetime r1_key_holder \
+ reassociation_deadline pmk_r1_push
+ json_get_values r0kh r0kh
+ json_get_values r1kh r1kh
+
+ set_default mobility_domain "4f57"
+ set_default r0_key_lifetime 10000
+ set_default r1_key_holder "00004f577274"
+ set_default reassociation_deadline 1000
+ set_default pmk_r1_push 0
+
+ append bss_conf "mobility_domain=$mobility_domain" "$N"
+ append bss_conf "r0_key_lifetime=$r0_key_lifetime" "$N"
+ append bss_conf "r1_key_holder=$r1_key_holder" "$N"
+ append bss_conf "reassociation_deadline=$reassociation_deadline" "$N"
+ append bss_conf "pmk_r1_push=$pmk_r1_push" "$N"
+
+ for kh in $r0kh; do
+ append bss_conf "r0kh=${kh//,/ }" "$N"
+ done
+ for kh in $r1kh; do
+ append bss_conf "r1kh=${kh//,/ }" "$N"
+ done
+ fi
+
+ hostapd_append_wpa_key_mgmt
+ [ -n "$wpa_key_mgmt" ] && append bss_conf "wpa_key_mgmt=$wpa_key_mgmt" "$N"
+ fi
+
+ if [ "$wpa" -ge "2" ]; then
+ if [ -n "$network_bridge" -a "$rsn_preauth" = 1 ]; then
+ set_default auth_cache 1
+ append bss_conf "rsn_preauth=1" "$N"
+ append bss_conf "rsn_preauth_interfaces=$network_bridge" "$N"
+ else
+ set_default auth_cache 0
+ fi
+
+ append bss_conf "okc=$auth_cache" "$N"
+ [ "$auth_cache" = 0 ] && append bss_conf "disable_pmksa_caching=1" "$N"
+
+ # RSN -> allow management frame protection
+ case "$ieee80211w" in
+ [012])
+ json_get_vars ieee80211w_max_timeout ieee80211w_retry_timeout
+ append bss_conf "ieee80211w=$ieee80211w" "$N"
+ [ "$ieee80211w" -gt "0" ] && {
+ [ -n "$ieee80211w_max_timeout" ] && \
+ append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
+ [ -n "$ieee80211w_retry_timeout" ] && \
+ append bss_conf "assoc_sa_query_retry_timeout=$ieee80211w_retry_timeout" "$N"
+ }
+ ;;
+ esac
+ fi
+
+ _macfile="/var/run/hostapd-$ifname.maclist"
+ case "$macfilter" in
+ allow)
+ append bss_conf "macaddr_acl=1" "$N"
+ append bss_conf "accept_mac_file=$_macfile" "$N"
+ # accept_mac_file can be used to set MAC to VLAN ID mapping
+ vlan_possible=1
+ ;;
+ deny)
+ append bss_conf "macaddr_acl=0" "$N"
+ append bss_conf "deny_mac_file=$_macfile" "$N"
+ ;;
+ *)
+ _macfile=""
+ ;;
+ esac
+
+ [ -n "$_macfile" ] && {
+ json_get_vars macfile
+ json_get_values maclist maclist
+
+ rm -f "$_macfile"
+ (
+ for mac in $maclist; do
+ echo "$mac"
+ done
+ [ -n "$macfile" -a -f "$macfile" ] && cat "$macfile"
+ ) > "$_macfile"
+ }
+
+ [ -n "$vlan_possible" -a -n "$dynamic_vlan" ] && {
+ json_get_vars vlan_naming vlan_tagged_interface vlan_bridge vlan_file
+ set_default vlan_naming 1
+ append bss_conf "dynamic_vlan=$dynamic_vlan" "$N"
+ append bss_conf "vlan_naming=$vlan_naming" "$N"
+ [ -n "$vlan_bridge" ] && \
+ append bss_conf "vlan_bridge=$vlan_bridge" "$N"
+ [ -n "$vlan_tagged_interface" ] && \
+ append bss_conf "vlan_tagged_interface=$vlan_tagged_interface" "$N"
+ [ -n "$vlan_file" ] && {
+ [ -e "$vlan_file" ] || touch "$vlan_file"
+ append bss_conf "vlan_file=$vlan_file" "$N"
+ }
+ }
+
+ append "$var" "$bss_conf" "$N"
+ return 0
+}
+
+hostapd_set_log_options() {
+ local var="$1"
+
+ local log_level log_80211 log_8021x log_radius log_wpa log_driver log_iapp log_mlme
+ json_get_vars log_level log_80211 log_8021x log_radius log_wpa log_driver log_iapp log_mlme
+
+ set_default log_level 2
+ set_default log_80211 1
+ set_default log_8021x 1
+ set_default log_radius 1
+ set_default log_wpa 1
+ set_default log_driver 1
+ set_default log_iapp 1
+ set_default log_mlme 1
+
+ local log_mask=$(( \
+ ($log_80211 << 0) | \
+ ($log_8021x << 1) | \
+ ($log_radius << 2) | \
+ ($log_wpa << 3) | \
+ ($log_driver << 4) | \
+ ($log_iapp << 5) | \
+ ($log_mlme << 6) \
+ ))
+
+ append "$var" "logger_syslog=$log_mask" "$N"
+ append "$var" "logger_syslog_level=$log_level" "$N"
+ append "$var" "logger_stdout=$log_mask" "$N"
+ append "$var" "logger_stdout_level=$log_level" "$N"
+
+ return 0
+}
+
+_wpa_supplicant_common() {
+ local ifname="$1"
+
+ _rpath="/var/run/wpa_supplicant"
+ _config="${_rpath}-$ifname.conf"
+}
+
+wpa_supplicant_teardown_interface() {
+ _wpa_supplicant_common "$1"
+ rm -rf "$_rpath/$1" "$_config"
+}
+
+wpa_supplicant_prepare_interface() {
+ local ifname="$1"
+ _w_driver="$2"
+
+ _wpa_supplicant_common "$1"
+
+ json_get_vars mode wds
+
+ [ -n "$network_bridge" ] && {
+ fail=
+ case "$mode" in
+ adhoc)
+ fail=1
+ ;;
+ sta)
+ [ "$wds" = 1 ] || fail=1
+ ;;
+ esac
+
+ [ -n "$fail" ] && {
+ wireless_setup_vif_failed BRIDGE_NOT_ALLOWED
+ return 1
+ }
+ }
+
+ local ap_scan=
+
+ _w_mode="$mode"
+ _w_modestr=
+
+ [[ "$mode" = adhoc ]] && {
+ ap_scan="ap_scan=2"
+
+ _w_modestr="mode=1"
+ }
+
+ local country_str=
+ [ -n "$country" ] && {
+ country_str="country=$country"
+ }
+
+ wpa_supplicant_teardown_interface "$ifname"
+ cat > "$_config" <<EOF
+$ap_scan
+$country_str
+EOF
+ return 0
+}
+
+wpa_supplicant_add_network() {
+ local ifname="$1"
+
+ _wpa_supplicant_common "$1"
+ wireless_vif_parse_encryption
+
+ json_get_vars \
+ ssid bssid key \
+ basic_rate mcast_rate \
+ ieee80211w ieee80211r
+
+ set_default ieee80211r 0
+
+ local key_mgmt='NONE'
+ local enc_str=
+ local network_data=
+ local T=" "
+
+ local scan_ssid="scan_ssid=1"
+ local freq wpa_key_mgmt
+
+ [[ "$_w_mode" = "adhoc" ]] && {
+ append network_data "mode=1" "$N$T"
+ [ -n "$channel" ] && {
+ freq="$(get_freq "$phy" "$channel")"
+ append network_data "fixed_freq=1" "$N$T"
+ append network_data "frequency=$freq" "$N$T"
+ }
+
+ scan_ssid="scan_ssid=0"
+
+ [ "$_w_driver" = "nl80211" ] || append wpa_key_mgmt "WPA-NONE"
+ }
+
+ [[ "$_w_mode" = "mesh" ]] && {
+ json_get_vars mesh_id
+ ssid="${mesh_id}"
+
+ append network_data "mode=5" "$N$T"
+ [ -n "$channel" ] && {
+ freq="$(get_freq "$phy" "$channel")"
+ append network_data "frequency=$freq" "$N$T"
+ }
+ append wpa_key_mgmt "SAE"
+ scan_ssid=""
+ }
+
+ [[ "$_w_mode" = "adhoc" -o "$_w_mode" = "mesh" ]] && append network_data "$_w_modestr" "$N$T"
+
+ case "$auth_type" in
+ none) ;;
+ wep)
+ local wep_keyidx=0
+ hostapd_append_wep_key network_data
+ append network_data "wep_tx_keyidx=$wep_keyidx" "$N$T"
+ ;;
+ psk)
+ local passphrase
+
+ if [ "$_w_mode" != "mesh" ]; then
+ hostapd_append_wpa_key_mgmt
+ fi
+
+ key_mgmt="$wpa_key_mgmt"
+
+ if [ ${#key} -eq 64 ]; then
+ passphrase="psk=${key}"
+ else
+ passphrase="psk=\"${key}\""
+ fi
+ append network_data "$passphrase" "$N$T"
+ ;;
+ eap)
+ hostapd_append_wpa_key_mgmt
+ key_mgmt="$wpa_key_mgmt"
+
+ json_get_vars eap_type identity anonymous_identity ca_cert
+ [ -n "$ca_cert" ] && append network_data "ca_cert=\"$ca_cert\"" "$N$T"
+ [ -n "$identity" ] && append network_data "identity=\"$identity\"" "$N$T"
+ [ -n "$anonymous_identity" ] && append network_data "anonymous_identity=\"$anonymous_identity\"" "$N$T"
+ case "$eap_type" in
+ tls)
+ json_get_vars client_cert priv_key priv_key_pwd
+ append network_data "client_cert=\"$client_cert\"" "$N$T"
+ append network_data "private_key=\"$priv_key\"" "$N$T"
+ append network_data "private_key_passwd=\"$priv_key_pwd\"" "$N$T"
+ ;;
+ fast|peap|ttls)
+ json_get_vars auth password ca_cert2 client_cert2 priv_key2 priv_key2_pwd
+ set_default auth MSCHAPV2
+
+ if [ "$auth" = "EAP-TLS" ]; then
+ [ -n "$ca_cert2" ] &&
+ append network_data "ca_cert2=\"$ca_cert2\"" "$N$T"
+ append network_data "client_cert2=\"$client_cert2\"" "$N$T"
+ append network_data "private_key2=\"$priv_key2\"" "$N$T"
+ append network_data "private_key2_passwd=\"$priv_key2_pwd\"" "$N$T"
+ else
+ append network_data "password=\"$password\"" "$N$T"
+ fi
+
+ phase2proto="auth="
+ case "$auth" in
+ "auth"*)
+ phase2proto=""
+ ;;
+ "EAP-"*)
+ auth="$(echo $auth | cut -b 5- )"
+ [ "$eap_type" = "ttls" ] &&
+ phase2proto="autheap="
+ ;;
+ esac
+ append network_data "phase2=\"$phase2proto$auth\"" "$N$T"
+ ;;
+ esac
+ append network_data "eap=$(echo $eap_type | tr 'a-z' 'A-Z')" "$N$T"
+ ;;
+ esac
+
+ [ "$mode" = mesh ] || {
+ case "$wpa" in
+ 1)
+ append network_data "proto=WPA" "$N$T"
+ ;;
+ 2)
+ append network_data "proto=RSN" "$N$T"
+ ;;
+ esac
+
+ case "$ieee80211w" in
+ [012])
+ [ "$wpa" -ge 2 ] && append network_data "ieee80211w=$ieee80211w" "$N$T"
+ ;;
+ esac
+ }
+ local beacon_int brates mrate
+ [ -n "$bssid" ] && append network_data "bssid=$bssid" "$N$T"
+ [ -n "$beacon_int" ] && append network_data "beacon_int=$beacon_int" "$N$T"
+
+ local bssid_blacklist bssid_whitelist
+ json_get_values bssid_blacklist bssid_blacklist
+ json_get_values bssid_whitelist bssid_whitelist
+
+ [ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
+ [ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
+
+ [ -n "$basic_rate" ] && {
+ local br rate_list=
+ for br in $basic_rate; do
+ wpa_supplicant_add_rate rate_list "$br"
+ done
+ [ -n "$rate_list" ] && append network_data "rates=$rate_list" "$N$T"
+ }
+
+ [ -n "$mcast_rate" ] && {
+ local mc_rate=
+ wpa_supplicant_add_rate mc_rate "$mcast_rate"
+ append network_data "mcast_rate=$mc_rate" "$N$T"
+ }
+
+ local ht_str
+ [[ "$_w_mode" = adhoc ]] || ibss_htmode=
+ [ -n "$ibss_htmode" ] && append network_data "htmode=$ibss_htmode" "$N$T"
+
+ cat >> "$_config" <<EOF
+network={
+ $scan_ssid
+ ssid="$ssid"
+ key_mgmt=$key_mgmt
+ $network_data
+}
+EOF
+ return 0
+}
+
+wpa_supplicant_run() {
+ local ifname="$1"; shift
+
+ _wpa_supplicant_common "$ifname"
+
+ /usr/sbin/wpa_supplicant -B \
+ ${network_bridge:+-b $network_bridge} \
+ -P "/var/run/wpa_supplicant-${ifname}.pid" \
+ -D ${_w_driver:-wext} \
+ -i "$ifname" \
+ -c "$_config" \
+ -C "$_rpath" \
+ "$@"
+
+ ret="$?"
+ wireless_add_process "$(cat "/var/run/wpa_supplicant-${ifname}.pid")" /usr/sbin/wpa_supplicant 1
+
+ [ "$ret" != 0 ] && wireless_setup_vif_failed WPA_SUPPLICANT_FAILED
+
+ return $ret
+}
+
+hostapd_common_cleanup() {
+ killall hostapd wpa_supplicant meshd-nl80211
+}
+++ /dev/null
-. /lib/functions/network.sh
-
-wpa_supplicant_add_rate() {
- local var="$1"
- local val="$(($2 / 1000))"
- local sub="$((($2 / 100) % 10))"
- append $var "$val" ","
- [ $sub -gt 0 ] && append $var "."
-}
-
-hostapd_add_rate() {
- local var="$1"
- local val="$(($2 / 100))"
- append $var "$val" " "
-}
-
-hostapd_append_wep_key() {
- local var="$1"
-
- wep_keyidx=0
- set_default key 1
- case "$key" in
- [1234])
- for idx in 1 2 3 4; do
- local zidx
- zidx=$(($idx - 1))
- json_get_var ckey "key${idx}"
- [ -n "$ckey" ] && \
- append $var "wep_key${zidx}=$(prepare_key_wep "$ckey")" "$N$T"
- done
- wep_keyidx=$((key - 1))
- ;;
- *)
- append $var "wep_key0=$(prepare_key_wep "$key")" "$N$T"
- ;;
- esac
-}
-
-hostapd_append_wpa_key_mgmt() {
- local auth_type="$(echo $auth_type | tr 'a-z' 'A-Z')"
-
- append wpa_key_mgmt "WPA-$auth_type"
- [ "$ieee80211r" -gt 0 ] && append wpa_key_mgmt "FT-${auth_type}"
- [ "$ieee80211w" -gt 0 ] && append wpa_key_mgmt "WPA-${auth_type}-SHA256"
-}
-
-hostapd_add_log_config() {
- config_add_boolean \
- log_80211 \
- log_8021x \
- log_radius \
- log_wpa \
- log_driver \
- log_iapp \
- log_mlme
-
- config_add_int log_level
-}
-
-hostapd_common_add_device_config() {
- config_add_array basic_rate
- config_add_array supported_rates
-
- config_add_string country
- config_add_boolean country_ie doth
- config_add_string require_mode
-
- hostapd_add_log_config
-}
-
-hostapd_prepare_device_config() {
- local config="$1"
- local driver="$2"
-
- local base="${config%%.conf}"
- local base_cfg=
-
- json_get_vars country country_ie beacon_int doth require_mode
-
- hostapd_set_log_options base_cfg
-
- set_default country_ie 1
- set_default doth 1
-
- [ -n "$country" ] && {
- append base_cfg "country_code=$country" "$N"
-
- [ "$country_ie" -gt 0 ] && append base_cfg "ieee80211d=1" "$N"
- [ "$hwmode" = "a" -a "$doth" -gt 0 ] && append base_cfg "ieee80211h=1" "$N"
- }
- [ -n "$hwmode" ] && append base_cfg "hw_mode=$hwmode" "$N"
-
- local brlist= br
- json_get_values basic_rate_list basic_rate
- for br in $basic_rate_list; do
- hostapd_add_rate brlist "$br"
- done
- case "$require_mode" in
- g) brlist="60 120 240" ;;
- n) append base_cfg "require_ht=1" "$N";;
- ac) append base_cfg "require_vht=1" "$N";;
- esac
-
- local rlist= r
- json_get_values rate_list supported_rates
- for r in $rate_list; do
- hostapd_add_rate rlist "$r"
- done
-
- [ -n "$rlist" ] && append base_cfg "supported_rates=$rlist" "$N"
- [ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N"
- [ -n "$beacon_int" ] && append base_cfg "beacon_int=$beacon_int" "$N"
-
- cat > "$config" <<EOF
-driver=$driver
-$base_cfg
-EOF
-}
-
-hostapd_common_add_bss_config() {
- config_add_string 'bssid:macaddr' 'ssid:string'
- config_add_boolean wds wmm uapsd hidden
-
- config_add_int maxassoc max_inactivity
- config_add_boolean disassoc_low_ack isolate short_preamble
-
- config_add_int \
- wep_rekey eap_reauth_period \
- wpa_group_rekey wpa_pair_rekey wpa_master_rekey
-
- config_add_boolean rsn_preauth auth_cache
- config_add_int ieee80211w
- config_add_int eapol_version
-
- config_add_string 'auth_server:host' 'server:host'
- config_add_string auth_secret
- config_add_int 'auth_port:port' 'port:port'
-
- config_add_string acct_server
- config_add_string acct_secret
- config_add_int acct_port
-
- config_add_string dae_client
- config_add_string dae_secret
- config_add_int dae_port
-
- config_add_string nasid
- config_add_string ownip
- config_add_string iapp_interface
- config_add_string eap_type ca_cert client_cert identity anonymous_identity auth priv_key priv_key_pwd
-
- config_add_int dynamic_vlan vlan_naming
- config_add_string vlan_tagged_interface vlan_bridge
- config_add_string vlan_file
-
- config_add_string 'key1:wepkey' 'key2:wepkey' 'key3:wepkey' 'key4:wepkey' 'password:wpakey'
-
- config_add_string wpa_psk_file
-
- config_add_boolean wps_pushbutton wps_label ext_registrar wps_pbc_in_m1
- config_add_string wps_device_type wps_device_name wps_manufacturer wps_pin
-
- config_add_boolean ieee80211r pmk_r1_push
- config_add_int r0_key_lifetime reassociation_deadline
- config_add_string mobility_domain r1_key_holder
- config_add_array r0kh r1kh
-
- config_add_int ieee80211w_max_timeout ieee80211w_retry_timeout
-
- config_add_string macfilter 'macfile:file'
- config_add_array 'maclist:list(macaddr)'
-
- config_add_array bssid_blacklist
- config_add_array bssid_whitelist
-
- config_add_int mcast_rate
- config_add_array basic_rate
- config_add_array supported_rates
-}
-
-hostapd_set_bss_options() {
- local var="$1"
- local phy="$2"
- local vif="$3"
-
- wireless_vif_parse_encryption
-
- local bss_conf
- local wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey wpa_key_mgmt
-
- json_get_vars \
- wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey \
- maxassoc max_inactivity disassoc_low_ack isolate auth_cache \
- wps_pushbutton wps_label ext_registrar wps_pbc_in_m1 \
- wps_device_type wps_device_name wps_manufacturer wps_pin \
- macfilter ssid wmm uapsd hidden short_preamble rsn_preauth \
- iapp_interface eapol_version acct_server acct_secret acct_port \
- dynamic_vlan ieee80211w
-
- set_default isolate 0
- set_default maxassoc 0
- set_default max_inactivity 0
- set_default short_preamble 1
- set_default disassoc_low_ack 1
- set_default hidden 0
- set_default wmm 1
- set_default uapsd 1
- set_default eapol_version 0
- set_default acct_port 1813
-
- append bss_conf "ctrl_interface=/var/run/hostapd"
- if [ "$isolate" -gt 0 ]; then
- append bss_conf "ap_isolate=$isolate" "$N"
- fi
- if [ "$maxassoc" -gt 0 ]; then
- append bss_conf "max_num_sta=$maxassoc" "$N"
- fi
- if [ "$max_inactivity" -gt 0 ]; then
- append bss_conf "ap_max_inactivity=$max_inactivity" "$N"
- fi
-
- append bss_conf "disassoc_low_ack=$disassoc_low_ack" "$N"
- append bss_conf "preamble=$short_preamble" "$N"
- append bss_conf "wmm_enabled=$wmm" "$N"
- append bss_conf "ignore_broadcast_ssid=$hidden" "$N"
- append bss_conf "uapsd_advertisement_enabled=$uapsd" "$N"
-
- [ "$wpa" -gt 0 ] && {
- [ -n "$wpa_group_rekey" ] && append bss_conf "wpa_group_rekey=$wpa_group_rekey" "$N"
- [ -n "$wpa_pair_rekey" ] && append bss_conf "wpa_ptk_rekey=$wpa_pair_rekey" "$N"
- [ -n "$wpa_master_rekey" ] && append bss_conf "wpa_gmk_rekey=$wpa_master_rekey" "$N"
- }
-
- [ -n "$acct_server" ] && {
- append bss_conf "acct_server_addr=$acct_server" "$N"
- append bss_conf "acct_server_port=$acct_port" "$N"
- [ -n "$acct_secret" ] && \
- append bss_conf "acct_server_shared_secret=$acct_secret" "$N"
- }
-
- local vlan_possible=""
-
- case "$auth_type" in
- none)
- wps_possible=1
- # Here we make the assumption that if we're in open mode
- # with WPS enabled, we got to be in unconfigured state.
- wps_not_configured=1
- ;;
- psk)
- json_get_vars key wpa_psk_file
- if [ ${#key} -lt 8 ]; then
- wireless_setup_vif_failed INVALID_WPA_PSK
- return 1
- elif [ ${#key} -eq 64 ]; then
- append bss_conf "wpa_psk=$key" "$N"
- else
- append bss_conf "wpa_passphrase=$key" "$N"
- fi
- [ -n "$wpa_psk_file" ] && {
- [ -e "$wpa_psk_file" ] || touch "$wpa_psk_file"
- append bss_conf "wpa_psk_file=$wpa_psk_file" "$N"
- }
- [ "$eapol_version" -ge "1" -a "$eapol_version" -le "2" ] && append bss_conf "eapol_version=$eapol_version" "$N"
-
- wps_possible=1
- ;;
- eap)
- json_get_vars \
- auth_server auth_secret auth_port \
- dae_client dae_secret dae_port \
- ownip \
- eap_reauth_period
-
- # radius can provide VLAN ID for clients
- vlan_possible=1
-
- # legacy compatibility
- [ -n "$auth_server" ] || json_get_var auth_server server
- [ -n "$auth_port" ] || json_get_var auth_port port
- [ -n "$auth_secret" ] || json_get_var auth_secret key
-
- set_default auth_port 1812
- set_default dae_port 3799
-
-
- append bss_conf "auth_server_addr=$auth_server" "$N"
- append bss_conf "auth_server_port=$auth_port" "$N"
- append bss_conf "auth_server_shared_secret=$auth_secret" "$N"
-
- [ -n "$eap_reauth_period" ] && append bss_conf "eap_reauth_period=$eap_reauth_period" "$N"
-
- [ -n "$dae_client" -a -n "$dae_secret" ] && {
- append bss_conf "radius_das_port=$dae_port" "$N"
- append bss_conf "radius_das_client=$dae_client $dae_secret" "$N"
- }
-
- [ -n "$ownip" ] && append bss_conf "own_ip_addr=$ownip" "$N"
- append bss_conf "eapol_key_index_workaround=1" "$N"
- append bss_conf "ieee8021x=1" "$N"
-
- [ "$eapol_version" -ge "1" -a "$eapol_version" -le "2" ] && append bss_conf "eapol_version=$eapol_version" "$N"
- ;;
- wep)
- local wep_keyidx=0
- json_get_vars key
- hostapd_append_wep_key bss_conf
- append bss_conf "wep_default_key=$wep_keyidx" "$N"
- [ -n "$wep_rekey" ] && append bss_conf "wep_rekey_period=$wep_rekey" "$N"
- ;;
- esac
-
- local auth_algs=$((($auth_mode_shared << 1) | $auth_mode_open))
- append bss_conf "auth_algs=${auth_algs:-1}" "$N"
- append bss_conf "wpa=$wpa" "$N"
- [ -n "$wpa_pairwise" ] && append bss_conf "wpa_pairwise=$wpa_pairwise" "$N"
-
- set_default wps_pushbutton 0
- set_default wps_label 0
- set_default wps_pbc_in_m1 0
-
- config_methods=
- [ "$wps_pushbutton" -gt 0 ] && append config_methods push_button
- [ "$wps_label" -gt 0 ] && append config_methods label
-
- [ -n "$wps_possible" -a -n "$config_methods" ] && {
- set_default ext_registrar 0
- set_default wps_device_type "6-0050F204-1"
- set_default wps_device_name "Lede AP"
- set_default wps_manufacturer "www.lede-project.org"
-
- wps_state=2
- [ -n "$wps_configured" ] && wps_state=1
-
- [ "$ext_registrar" -gt 0 -a -n "$network_bridge" ] && append bss_conf "upnp_iface=$network_bridge" "$N"
-
- append bss_conf "eap_server=1" "$N"
- [ -n "$wps_pin" ] && append bss_conf "ap_pin=$wps_pin" "$N"
- append bss_conf "wps_state=$wps_state" "$N"
- append bss_conf "ap_setup_locked=0" "$N"
- append bss_conf "device_type=$wps_device_type" "$N"
- append bss_conf "device_name=$wps_device_name" "$N"
- append bss_conf "manufacturer=$wps_manufacturer" "$N"
- append bss_conf "config_methods=$config_methods" "$N"
- [ "$wps_pbc_in_m1" -gt 0 ] && append bss_conf "pbc_in_m1=$wps_pbc_in_m1" "$N"
- }
-
- append bss_conf "ssid=$ssid" "$N"
- [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge" "$N"
- [ -n "$iapp_interface" ] && {
- local ifname
- network_get_device ifname "$iapp_interface" || ifname = "$iapp_interface"
- append bss_conf "iapp_interface=$ifname" "$N"
- }
-
- if [ "$wpa" -ge "1" ]; then
- json_get_vars nasid ieee80211r
- set_default ieee80211r 0
- [ -n "$nasid" ] && append bss_conf "nas_identifier=$nasid" "$N"
-
- if [ "$ieee80211r" -gt "0" ]; then
- json_get_vars mobility_domain r0_key_lifetime r1_key_holder \
- reassociation_deadline pmk_r1_push
- json_get_values r0kh r0kh
- json_get_values r1kh r1kh
-
- set_default mobility_domain "4f57"
- set_default r0_key_lifetime 10000
- set_default r1_key_holder "00004f577274"
- set_default reassociation_deadline 1000
- set_default pmk_r1_push 0
-
- append bss_conf "mobility_domain=$mobility_domain" "$N"
- append bss_conf "r0_key_lifetime=$r0_key_lifetime" "$N"
- append bss_conf "r1_key_holder=$r1_key_holder" "$N"
- append bss_conf "reassociation_deadline=$reassociation_deadline" "$N"
- append bss_conf "pmk_r1_push=$pmk_r1_push" "$N"
-
- for kh in $r0kh; do
- append bss_conf "r0kh=${kh//,/ }" "$N"
- done
- for kh in $r1kh; do
- append bss_conf "r1kh=${kh//,/ }" "$N"
- done
- fi
-
- hostapd_append_wpa_key_mgmt
- [ -n "$wpa_key_mgmt" ] && append bss_conf "wpa_key_mgmt=$wpa_key_mgmt" "$N"
- fi
-
- if [ "$wpa" -ge "2" ]; then
- if [ -n "$network_bridge" -a "$rsn_preauth" = 1 ]; then
- set_default auth_cache 1
- append bss_conf "rsn_preauth=1" "$N"
- append bss_conf "rsn_preauth_interfaces=$network_bridge" "$N"
- else
- set_default auth_cache 0
- fi
-
- append bss_conf "okc=$auth_cache" "$N"
- [ "$auth_cache" = 0 ] && append bss_conf "disable_pmksa_caching=1" "$N"
-
- # RSN -> allow management frame protection
- case "$ieee80211w" in
- [012])
- json_get_vars ieee80211w_max_timeout ieee80211w_retry_timeout
- append bss_conf "ieee80211w=$ieee80211w" "$N"
- [ "$ieee80211w" -gt "0" ] && {
- [ -n "$ieee80211w_max_timeout" ] && \
- append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
- [ -n "$ieee80211w_retry_timeout" ] && \
- append bss_conf "assoc_sa_query_retry_timeout=$ieee80211w_retry_timeout" "$N"
- }
- ;;
- esac
- fi
-
- _macfile="/var/run/hostapd-$ifname.maclist"
- case "$macfilter" in
- allow)
- append bss_conf "macaddr_acl=1" "$N"
- append bss_conf "accept_mac_file=$_macfile" "$N"
- # accept_mac_file can be used to set MAC to VLAN ID mapping
- vlan_possible=1
- ;;
- deny)
- append bss_conf "macaddr_acl=0" "$N"
- append bss_conf "deny_mac_file=$_macfile" "$N"
- ;;
- *)
- _macfile=""
- ;;
- esac
-
- [ -n "$_macfile" ] && {
- json_get_vars macfile
- json_get_values maclist maclist
-
- rm -f "$_macfile"
- (
- for mac in $maclist; do
- echo "$mac"
- done
- [ -n "$macfile" -a -f "$macfile" ] && cat "$macfile"
- ) > "$_macfile"
- }
-
- [ -n "$vlan_possible" -a -n "$dynamic_vlan" ] && {
- json_get_vars vlan_naming vlan_tagged_interface vlan_bridge vlan_file
- set_default vlan_naming 1
- append bss_conf "dynamic_vlan=$dynamic_vlan" "$N"
- append bss_conf "vlan_naming=$vlan_naming" "$N"
- [ -n "$vlan_bridge" ] && \
- append bss_conf "vlan_bridge=$vlan_bridge" "$N"
- [ -n "$vlan_tagged_interface" ] && \
- append bss_conf "vlan_tagged_interface=$vlan_tagged_interface" "$N"
- [ -n "$vlan_file" ] && {
- [ -e "$vlan_file" ] || touch "$vlan_file"
- append bss_conf "vlan_file=$vlan_file" "$N"
- }
- }
-
- append "$var" "$bss_conf" "$N"
- return 0
-}
-
-hostapd_set_log_options() {
- local var="$1"
-
- local log_level log_80211 log_8021x log_radius log_wpa log_driver log_iapp log_mlme
- json_get_vars log_level log_80211 log_8021x log_radius log_wpa log_driver log_iapp log_mlme
-
- set_default log_level 2
- set_default log_80211 1
- set_default log_8021x 1
- set_default log_radius 1
- set_default log_wpa 1
- set_default log_driver 1
- set_default log_iapp 1
- set_default log_mlme 1
-
- local log_mask=$(( \
- ($log_80211 << 0) | \
- ($log_8021x << 1) | \
- ($log_radius << 2) | \
- ($log_wpa << 3) | \
- ($log_driver << 4) | \
- ($log_iapp << 5) | \
- ($log_mlme << 6) \
- ))
-
- append "$var" "logger_syslog=$log_mask" "$N"
- append "$var" "logger_syslog_level=$log_level" "$N"
- append "$var" "logger_stdout=$log_mask" "$N"
- append "$var" "logger_stdout_level=$log_level" "$N"
-
- return 0
-}
-
-_wpa_supplicant_common() {
- local ifname="$1"
-
- _rpath="/var/run/wpa_supplicant"
- _config="${_rpath}-$ifname.conf"
-}
-
-wpa_supplicant_teardown_interface() {
- _wpa_supplicant_common "$1"
- rm -rf "$_rpath/$1" "$_config"
-}
-
-wpa_supplicant_prepare_interface() {
- local ifname="$1"
- _w_driver="$2"
-
- _wpa_supplicant_common "$1"
-
- json_get_vars mode wds
-
- [ -n "$network_bridge" ] && {
- fail=
- case "$mode" in
- adhoc)
- fail=1
- ;;
- sta)
- [ "$wds" = 1 ] || fail=1
- ;;
- esac
-
- [ -n "$fail" ] && {
- wireless_setup_vif_failed BRIDGE_NOT_ALLOWED
- return 1
- }
- }
-
- local ap_scan=
-
- _w_mode="$mode"
- _w_modestr=
-
- [[ "$mode" = adhoc ]] && {
- ap_scan="ap_scan=2"
-
- _w_modestr="mode=1"
- }
-
- local country_str=
- [ -n "$country" ] && {
- country_str="country=$country"
- }
-
- wpa_supplicant_teardown_interface "$ifname"
- cat > "$_config" <<EOF
-$ap_scan
-$country_str
-EOF
- return 0
-}
-
-wpa_supplicant_add_network() {
- local ifname="$1"
-
- _wpa_supplicant_common "$1"
- wireless_vif_parse_encryption
-
- json_get_vars \
- ssid bssid key \
- basic_rate mcast_rate \
- ieee80211w ieee80211r
-
- set_default ieee80211r 0
-
- local key_mgmt='NONE'
- local enc_str=
- local network_data=
- local T=" "
-
- local scan_ssid="scan_ssid=1"
- local freq wpa_key_mgmt
-
- [[ "$_w_mode" = "adhoc" ]] && {
- append network_data "mode=1" "$N$T"
- [ -n "$channel" ] && {
- freq="$(get_freq "$phy" "$channel")"
- append network_data "fixed_freq=1" "$N$T"
- append network_data "frequency=$freq" "$N$T"
- }
-
- scan_ssid="scan_ssid=0"
-
- [ "$_w_driver" = "nl80211" ] || append wpa_key_mgmt "WPA-NONE"
- }
-
- [[ "$_w_mode" = "mesh" ]] && {
- json_get_vars mesh_id
- ssid="${mesh_id}"
-
- append network_data "mode=5" "$N$T"
- [ -n "$channel" ] && {
- freq="$(get_freq "$phy" "$channel")"
- append network_data "frequency=$freq" "$N$T"
- }
- append wpa_key_mgmt "SAE"
- scan_ssid=""
- }
-
- [[ "$_w_mode" = "adhoc" -o "$_w_mode" = "mesh" ]] && append network_data "$_w_modestr" "$N$T"
-
- case "$auth_type" in
- none) ;;
- wep)
- local wep_keyidx=0
- hostapd_append_wep_key network_data
- append network_data "wep_tx_keyidx=$wep_keyidx" "$N$T"
- ;;
- psk)
- local passphrase
-
- if [ "$_w_mode" != "mesh" ]; then
- hostapd_append_wpa_key_mgmt
- fi
-
- key_mgmt="$wpa_key_mgmt"
-
- if [ ${#key} -eq 64 ]; then
- passphrase="psk=${key}"
- else
- passphrase="psk=\"${key}\""
- fi
- append network_data "$passphrase" "$N$T"
- ;;
- eap)
- hostapd_append_wpa_key_mgmt
- key_mgmt="$wpa_key_mgmt"
-
- json_get_vars eap_type identity anonymous_identity ca_cert
- [ -n "$ca_cert" ] && append network_data "ca_cert=\"$ca_cert\"" "$N$T"
- [ -n "$identity" ] && append network_data "identity=\"$identity\"" "$N$T"
- [ -n "$anonymous_identity" ] && append network_data "anonymous_identity=\"$anonymous_identity\"" "$N$T"
- case "$eap_type" in
- tls)
- json_get_vars client_cert priv_key priv_key_pwd
- append network_data "client_cert=\"$client_cert\"" "$N$T"
- append network_data "private_key=\"$priv_key\"" "$N$T"
- append network_data "private_key_passwd=\"$priv_key_pwd\"" "$N$T"
- ;;
- fast|peap|ttls)
- json_get_vars auth password ca_cert2 client_cert2 priv_key2 priv_key2_pwd
- set_default auth MSCHAPV2
-
- if [ "$auth" = "EAP-TLS" ]; then
- [ -n "$ca_cert2" ] &&
- append network_data "ca_cert2=\"$ca_cert2\"" "$N$T"
- append network_data "client_cert2=\"$client_cert2\"" "$N$T"
- append network_data "private_key2=\"$priv_key2\"" "$N$T"
- append network_data "private_key2_passwd=\"$priv_key2_pwd\"" "$N$T"
- else
- append network_data "password=\"$password\"" "$N$T"
- fi
-
- phase2proto="auth="
- case "$auth" in
- "auth"*)
- phase2proto=""
- ;;
- "EAP-"*)
- auth="$(echo $auth | cut -b 5- )"
- [ "$eap_type" = "ttls" ] &&
- phase2proto="autheap="
- ;;
- esac
- append network_data "phase2=\"$phase2proto$auth\"" "$N$T"
- ;;
- esac
- append network_data "eap=$(echo $eap_type | tr 'a-z' 'A-Z')" "$N$T"
- ;;
- esac
-
- [ "$mode" = mesh ] || {
- case "$wpa" in
- 1)
- append network_data "proto=WPA" "$N$T"
- ;;
- 2)
- append network_data "proto=RSN" "$N$T"
- ;;
- esac
-
- case "$ieee80211w" in
- [012])
- [ "$wpa" -ge 2 ] && append network_data "ieee80211w=$ieee80211w" "$N$T"
- ;;
- esac
- }
- local beacon_int brates mrate
- [ -n "$bssid" ] && append network_data "bssid=$bssid" "$N$T"
- [ -n "$beacon_int" ] && append network_data "beacon_int=$beacon_int" "$N$T"
-
- local bssid_blacklist bssid_whitelist
- json_get_values bssid_blacklist bssid_blacklist
- json_get_values bssid_whitelist bssid_whitelist
-
- [ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
- [ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
-
- [ -n "$basic_rate" ] && {
- local br rate_list=
- for br in $basic_rate; do
- wpa_supplicant_add_rate rate_list "$br"
- done
- [ -n "$rate_list" ] && append network_data "rates=$rate_list" "$N$T"
- }
-
- [ -n "$mcast_rate" ] && {
- local mc_rate=
- wpa_supplicant_add_rate mc_rate "$mcast_rate"
- append network_data "mcast_rate=$mc_rate" "$N$T"
- }
-
- local ht_str
- [[ "$_w_mode" = adhoc ]] || ibss_htmode=
- [ -n "$ibss_htmode" ] && append network_data "htmode=$ibss_htmode" "$N$T"
-
- cat >> "$_config" <<EOF
-network={
- $scan_ssid
- ssid="$ssid"
- key_mgmt=$key_mgmt
- $network_data
-}
-EOF
- return 0
-}
-
-wpa_supplicant_run() {
- local ifname="$1"; shift
-
- _wpa_supplicant_common "$ifname"
-
- /usr/sbin/wpa_supplicant -B \
- ${network_bridge:+-b $network_bridge} \
- -P "/var/run/wpa_supplicant-${ifname}.pid" \
- -D ${_w_driver:-wext} \
- -i "$ifname" \
- -c "$_config" \
- -C "$_rpath" \
- "$@"
-
- ret="$?"
- wireless_add_process "$(cat "/var/run/wpa_supplicant-${ifname}.pid")" /usr/sbin/wpa_supplicant 1
-
- [ "$ret" != 0 ] && wireless_setup_vif_failed WPA_SUPPLICANT_FAILED
-
- return $ret
-}
-
-hostapd_common_cleanup() {
- killall hostapd wpa_supplicant meshd-nl80211
-}
--- /dev/null
+From: Jouni Malinen <jouni@qca.qualcomm.com>
+Date: Tue, 20 Dec 2016 01:30:09 +0200
+Subject: [PATCH] Fix race condition between AssocResp callback and 4addr event
+
+It is apparently possible for the NL80211_CMD_UNEXPECTED_4ADDR_FRAME
+event to be delivered to hostapd before the NL80211_CMD_FRAME_TX_STATUS
+event for (Re)Association Response frame. This resulted in the 4-address
+WDS mode not getting enabled for a STA. This could occur in particular
+when operating under heavy load and the STA is reconnecting to the same
+AP in a sequence where Deauthentication frame is followed immediately by
+Authentication frame and the driver event processing gets delayed due to
+removal of the previous netdev taking time in the middle of this
+sequence.
+
+Fix this by recording a pending item for 4-address WDS enabling if the
+NL80211_CMD_UNEXPECTED_4ADDR_FRAME event would have been dropped due to
+incompleted association and then process this pending item if the TX
+status for the (Re)Association Response frame is received and it shows
+that the frame was acknowledged.
+
+Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
+---
+
+--- a/src/ap/ieee802_11.c
++++ b/src/ap/ieee802_11.c
+@@ -2634,6 +2634,8 @@ static void handle_assoc(struct hostapd_
+ taxonomy_sta_info_assoc_req(hapd, sta, pos, left);
+ #endif /* CONFIG_TAXONOMY */
+
++ sta->pending_wds_enable = 0;
++
+ fail:
+ /*
+ * In case of a successful response, add the station to the driver.
+@@ -3248,6 +3250,14 @@ static void handle_assoc_cb(struct hosta
+
+ hostapd_set_sta_flags(hapd, sta);
+
++ if (!(sta->flags & WLAN_STA_WDS) && sta->pending_wds_enable) {
++ wpa_printf(MSG_DEBUG, "Enable 4-address WDS mode for STA "
++ MACSTR " based on pending request",
++ MAC2STR(sta->addr));
++ sta->pending_wds_enable = 0;
++ sta->flags |= WLAN_STA_WDS;
++ }
++
+ if (sta->flags & WLAN_STA_WDS) {
+ int ret;
+ char ifname_wds[IFNAMSIZ + 1];
+@@ -3512,10 +3522,22 @@ void ieee802_11_rx_from_unknown(struct h
+ struct sta_info *sta;
+
+ sta = ap_get_sta(hapd, src);
+- if (sta && (sta->flags & WLAN_STA_ASSOC)) {
++ if (sta &&
++ ((sta->flags & WLAN_STA_ASSOC) ||
++ ((sta->flags & WLAN_STA_ASSOC_REQ_OK) && wds))) {
+ if (!hapd->conf->wds_sta)
+ return;
+
++ if ((sta->flags & (WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK)) ==
++ WLAN_STA_ASSOC_REQ_OK) {
++ wpa_printf(MSG_DEBUG,
++ "Postpone 4-address WDS mode enabling for STA "
++ MACSTR " since TX status for AssocResp is not yet known",
++ MAC2STR(sta->addr));
++ sta->pending_wds_enable = 1;
++ return;
++ }
++
+ if (wds && !(sta->flags & WLAN_STA_WDS)) {
+ int ret;
+ char ifname_wds[IFNAMSIZ + 1];
+--- a/src/ap/sta_info.h
++++ b/src/ap/sta_info.h
+@@ -115,6 +115,7 @@ struct sta_info {
+ unsigned int radius_das_match:1;
+ unsigned int ecsa_supported:1;
+ unsigned int added_unassoc:1;
++ unsigned int pending_wds_enable:1;
+
+ u16 auth_alg;
+
--- /dev/null
+From: Jouni Malinen <jouni@qca.qualcomm.com>
+Date: Sat, 14 Jan 2017 01:04:31 +0200
+Subject: [PATCH] Fix duplicate Reassociation Request frame dropping
+
+Relational operators (==) have higher precedence than the ternary
+conditional in C. The last_subtype check for association/reassociation
+was broken due to incorrect assumption about the precedence. Fix this by
+adding parenthesis around the ternary conditional.
+
+The previous implementation worked for Association Request frames by
+accident since WLAN_FC_STYPE_ASSOC_REQ happens to have value 0 and when
+the last receive frame was an Association Request frame, the
+sta->last_subtype == reassoc check was true and non-zero
+WLAN_FC_STYPE_REASSOC_REQ was interpreted as true. However, this was
+broken for Reassociation Request frame. reassoc == 1 in that case could
+have matched received Association Response frame (subtype == 1), but
+those are not received in AP mode and as such, this did not break other
+behavior apart from not being able to drop duplicated Reassociation
+Request frames.
+
+Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
+---
+
+--- a/src/ap/ieee802_11.c
++++ b/src/ap/ieee802_11.c
+@@ -2485,8 +2485,8 @@ static void handle_assoc(struct hostapd_
+ if ((fc & WLAN_FC_RETRY) &&
+ sta->last_seq_ctrl != WLAN_INVALID_MGMT_SEQ &&
+ sta->last_seq_ctrl == seq_ctrl &&
+- sta->last_subtype == reassoc ? WLAN_FC_STYPE_REASSOC_REQ :
+- WLAN_FC_STYPE_ASSOC_REQ) {
++ sta->last_subtype == (reassoc ? WLAN_FC_STYPE_REASSOC_REQ :
++ WLAN_FC_STYPE_ASSOC_REQ)) {
+ hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
+ HOSTAPD_LEVEL_DEBUG,
+ "Drop repeated association frame seq_ctrl=0x%x",
--- /dev/null
+From: Jouni Malinen <j@w1.fi>
+Date: Sat, 14 Jan 2017 13:56:18 +0200
+Subject: [PATCH] RSN IBSS: Fix TK clearing on Authentication frame RX
+
+When wpa_supplicant was processing a received Authentication frame (seq
+1) from a peer STA for which there was already a TK configured to the
+driver, debug log claimed that the PTK gets cleared, but the actual
+call to clear the key was actually dropped due to AUTH vs. SUPP set_key
+selection. Fix this by explicitly clearing the TK in case it was set
+and an Authentication frame (seq 1) is received.
+
+This fixes some cases where EAPOL-Key frames were sent encrypted using
+the old key when a peer STA restarted itself and lost the key and had to
+re-join the IBSS. Previously, that state required timing out the 4-way
+handshake and Deauthentication frame exchange to recover.
+
+Signed-off-by: Jouni Malinen <j@w1.fi>
+---
+
+--- a/wpa_supplicant/ibss_rsn.c
++++ b/wpa_supplicant/ibss_rsn.c
+@@ -838,6 +838,18 @@ static void ibss_rsn_handle_auth_1_of_2(
+ MAC2STR(addr));
+
+ if (peer &&
++ peer->authentication_status & (IBSS_RSN_SET_PTK_SUPP |
++ IBSS_RSN_SET_PTK_AUTH)) {
++ /* Clear the TK for this pair to allow recovery from the case
++ * where the peer STA has restarted and lost its key while we
++ * still have a pairwise key configured. */
++ wpa_printf(MSG_DEBUG, "RSN: Clear pairwise key for peer "
++ MACSTR, MAC2STR(addr));
++ wpa_drv_set_key(ibss_rsn->wpa_s, WPA_ALG_NONE, addr, 0, 0,
++ NULL, 0, NULL, 0);
++ }
++
++ if (peer &&
+ peer->authentication_status & IBSS_RSN_AUTH_EAPOL_BY_PEER) {
+ if (peer->own_auth_tx.sec) {
+ struct os_reltime now, diff;
--- /dev/null
+From cc3dae85bd694506cdea66ae532d452fb8716297 Mon Sep 17 00:00:00 2001
+From: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
+Date: Mon, 23 Jan 2017 13:55:04 +0100
+Subject: [PATCH] hostapd: Add possibility to send debug messages to syslog
+
+We can only send module specific messages to syslog and not debug
+messages printed with wpa_printf. Add an extra command line parameter
+'-s' to allow it. The feature is enabled with compile flag
+CONFIG_DEBUG_SYSLOG as for wpa_supplicant and behaves in the same manner
+as the wpa_supplicant -s command line argument.
+
+Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
+---
+ hostapd/Android.mk | 4 ++++
+ hostapd/Makefile | 4 ++++
+ hostapd/defconfig | 3 +++
+ hostapd/main.c | 19 ++++++++++++++++++-
+ src/utils/wpa_debug.c | 2 +-
+ src/utils/wpa_debug.h | 3 +++
+ 6 files changed, 33 insertions(+), 2 deletions(-)
+
+--- a/hostapd/Android.mk
++++ b/hostapd/Android.mk
+@@ -952,6 +952,10 @@ ifdef CONFIG_NO_STDOUT_DEBUG
+ L_CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
+ endif
+
++ifdef CONFIG_DEBUG_SYSLOG
++L_CFLAGS += -DCONFIG_DEBUG_SYSLOG
++endif
++
+ ifdef CONFIG_DEBUG_LINUX_TRACING
+ L_CFLAGS += -DCONFIG_DEBUG_LINUX_TRACING
+ endif
+--- a/hostapd/Makefile
++++ b/hostapd/Makefile
+@@ -997,6 +997,10 @@ ifdef CONFIG_NO_STDOUT_DEBUG
+ CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
+ endif
+
++ifdef CONFIG_DEBUG_SYSLOG
++CFLAGS += -DCONFIG_DEBUG_SYSLOG
++endif
++
+ ifdef CONFIG_DEBUG_LINUX_TRACING
+ CFLAGS += -DCONFIG_DEBUG_LINUX_TRACING
+ endif
+--- a/hostapd/defconfig
++++ b/hostapd/defconfig
+@@ -166,6 +166,9 @@ CONFIG_IPV6=y
+ # Disabled by default.
+ #CONFIG_DEBUG_FILE=y
+
++# Send debug messages to syslog instead of stdout
++#CONFIG_DEBUG_SYSLOG=y
++
+ # Add support for sending all debug messages (regardless of debug verbosity)
+ # to the Linux kernel tracing facility. This helps debug the entire stack by
+ # making it easy to record everything happening from the driver up into the
+--- a/hostapd/main.c
++++ b/hostapd/main.c
+@@ -108,6 +108,10 @@ static void hostapd_logger_cb(void *ctx,
+ module_str ? module_str : "",
+ module_str ? ": " : "", txt);
+
++#ifdef CONFIG_DEBUG_SYSLOG
++ if (wpa_debug_syslog)
++ conf_stdout = 0;
++#endif /* CONFIG_DEBUG_SYSLOG */
+ if ((conf_stdout & module) && level >= conf_stdout_level) {
+ wpa_debug_print_timestamp();
+ wpa_printf(MSG_INFO, "%s", format);
+@@ -484,6 +488,9 @@ static void usage(void)
+ " (records all messages regardless of debug verbosity)\n"
+ #endif /* CONFIG_DEBUG_LINUX_TRACING */
+ " -i list of interface names to use\n"
++#ifdef CONFIG_DEBUG_SYSLOG
++ " -s log output to syslog instead of stdout\n"
++#endif /* CONFIG_DEBUG_SYSLOG */
+ " -S start all the interfaces synchronously\n"
+ " -t include timestamps in some debug messages\n"
+ " -v show hostapd version\n");
+@@ -661,7 +668,7 @@ int main(int argc, char *argv[])
+ dl_list_init(&interfaces.global_ctrl_dst);
+
+ for (;;) {
+- c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:vg:G:");
++ c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:vg:G:");
+ if (c < 0)
+ break;
+ switch (c) {
+@@ -718,6 +725,11 @@ int main(int argc, char *argv[])
+ bss_config = tmp_bss;
+ bss_config[num_bss_configs++] = optarg;
+ break;
++#ifdef CONFIG_DEBUG_SYSLOG
++ case 's':
++ wpa_debug_syslog = 1;
++ break;
++#endif /* CONFIG_DEBUG_SYSLOG */
+ case 'S':
+ start_ifaces_in_sync = 1;
+ break;
+@@ -746,6 +758,10 @@ int main(int argc, char *argv[])
+ wpa_debug_open_file(log_file);
+ else
+ wpa_debug_setup_stdout();
++#ifdef CONFIG_DEBUG_SYSLOG
++ if (wpa_debug_syslog)
++ wpa_debug_open_syslog();
++#endif /* CONFIG_DEBUG_SYSLOG */
+ #ifdef CONFIG_DEBUG_LINUX_TRACING
+ if (enable_trace_dbg) {
+ int tret = wpa_debug_open_linux_tracing();
+@@ -882,6 +898,7 @@ int main(int argc, char *argv[])
+ hostapd_global_deinit(pid_file, interfaces.eloop_initialized);
+ os_free(pid_file);
+
++ wpa_debug_close_syslog();
+ if (log_file)
+ wpa_debug_close_file();
+ wpa_debug_close_linux_tracing();
+--- a/src/utils/wpa_debug.c
++++ b/src/utils/wpa_debug.c
+@@ -13,7 +13,7 @@
+ #ifdef CONFIG_DEBUG_SYSLOG
+ #include <syslog.h>
+
+-static int wpa_debug_syslog = 0;
++int wpa_debug_syslog = 0;
+ #endif /* CONFIG_DEBUG_SYSLOG */
+
+ #ifdef CONFIG_DEBUG_LINUX_TRACING
+--- a/src/utils/wpa_debug.h
++++ b/src/utils/wpa_debug.h
+@@ -14,6 +14,9 @@
+ extern int wpa_debug_level;
+ extern int wpa_debug_show_keys;
+ extern int wpa_debug_timestamp;
++#ifdef CONFIG_DEBUG_SYSLOG
++extern int wpa_debug_syslog;
++#endif /* CONFIG_DEBUG_SYSLOG */
+
+ /* Debugging function - conditional printf and hex dump. Driver wrappers can
+ * use these for debugging purposes. */
LIBS += $(DRV_AP_LIBS)
ifdef CONFIG_L2_PACKET
-@@ -1073,6 +1079,12 @@ install: $(addprefix $(DESTDIR)$(BINDIR)
+@@ -1077,6 +1083,12 @@ install: $(addprefix $(DESTDIR)$(BINDIR)
BCHECK=../src/drivers/build.hostapd
hostapd: $(BCHECK) $(OBJS)
$(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS)
@$(E) " LD " $@
-@@ -1114,6 +1126,12 @@ HOBJS += ../src/crypto/aes-internal.o
+@@ -1118,6 +1130,12 @@ HOBJS += ../src/crypto/aes-internal.o
HOBJS += ../src/crypto/aes-internal-enc.o
endif
wpa_debug_open_file(params->wpa_debug_file_path);
--- a/hostapd/main.c
+++ b/hostapd/main.c
-@@ -583,6 +583,11 @@ fail:
+@@ -590,6 +590,11 @@ fail:
return -1;
}
#ifdef CONFIG_WPS
static int gen_uuid(const char *txt_addr)
-@@ -660,6 +665,8 @@ int main(int argc, char *argv[])
+@@ -667,6 +672,8 @@ int main(int argc, char *argv[])
interfaces.global_ctrl_sock = -1;
dl_list_init(&interfaces.global_ctrl_dst);
+ wpa_supplicant_event = hostapd_wpa_event;
+ wpa_supplicant_event_global = hostapd_wpa_event_global;
for (;;) {
- c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:vg:G:");
+ c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:vg:G:");
if (c < 0)
--- a/src/drivers/drivers.c
+++ b/src/drivers/drivers.c
char *buf;
--- a/src/utils/wpa_debug.h
+++ b/src/utils/wpa_debug.h
-@@ -49,6 +49,17 @@ int wpa_debug_reopen_file(void);
+@@ -52,6 +52,17 @@ int wpa_debug_reopen_file(void);
void wpa_debug_close_file(void);
void wpa_debug_setup_stdout(void);
/**
* wpa_debug_printf_timestamp - Print timestamp for debug output
*
-@@ -69,9 +80,15 @@ void wpa_debug_print_timestamp(void);
+@@ -72,9 +83,15 @@ void wpa_debug_print_timestamp(void);
*
* Note: New line '\n' is added to the end of the text when printing to stdout.
*/
/**
* wpa_hexdump - conditional hex dump
* @level: priority level (MSG_*) of the message
-@@ -83,7 +100,13 @@ PRINTF_FORMAT(2, 3);
+@@ -86,7 +103,13 @@ PRINTF_FORMAT(2, 3);
* output may be directed to stdout, stderr, and/or syslog based on
* configuration. The contents of buf is printed out has hex dump.
*/
static inline void wpa_hexdump_buf(int level, const char *title,
const struct wpabuf *buf)
-@@ -105,7 +128,13 @@ static inline void wpa_hexdump_buf(int l
+@@ -108,7 +131,13 @@ static inline void wpa_hexdump_buf(int l
* like wpa_hexdump(), but by default, does not include secret keys (passwords,
* etc.) in debug output.
*/
static inline void wpa_hexdump_buf_key(int level, const char *title,
const struct wpabuf *buf)
-@@ -127,8 +156,14 @@ static inline void wpa_hexdump_buf_key(i
+@@ -130,8 +159,14 @@ static inline void wpa_hexdump_buf_key(i
* the hex numbers and ASCII characters (for printable range) are shown. 16
* bytes per line will be shown.
*/
/**
* wpa_hexdump_ascii_key - conditional hex dump, hide keys
-@@ -144,8 +179,14 @@ void wpa_hexdump_ascii(int level, const
+@@ -147,8 +182,14 @@ void wpa_hexdump_ascii(int level, const
* bytes per line will be shown. This works like wpa_hexdump_ascii(), but by
* default, does not include secret keys (passwords, etc.) in debug output.
*/
/*
* wpa_dbg() behaves like wpa_msg(), but it can be removed from build to reduce
-@@ -182,7 +223,12 @@ void wpa_hexdump_ascii_key(int level, co
+@@ -185,7 +226,12 @@ void wpa_hexdump_ascii_key(int level, co
*
* Note: New line '\n' is added to the end of the text when printing to stdout.
*/
/**
* wpa_msg_ctrl - Conditional printf for ctrl_iface monitors
-@@ -196,8 +242,13 @@ void wpa_msg(void *ctx, int level, const
+@@ -199,8 +245,13 @@ void wpa_msg(void *ctx, int level, const
* attached ctrl_iface monitors. In other words, it can be used for frequent
* events that do not need to be sent to syslog.
*/
#include "crypto/random.h"
#include "crypto/tls.h"
#include "common/version.h"
-@@ -668,7 +669,7 @@ int main(int argc, char *argv[])
+@@ -675,7 +676,7 @@ int main(int argc, char *argv[])
wpa_supplicant_event = hostapd_wpa_event;
wpa_supplicant_event_global = hostapd_wpa_event_global;
for (;;) {
-- c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:vg:G:");
-+ c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:g:G:v::");
+- c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:vg:G:");
++ c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:g:G:v::");
if (c < 0)
break;
switch (c) {
-@@ -705,6 +706,8 @@ int main(int argc, char *argv[])
+@@ -712,6 +713,8 @@ int main(int argc, char *argv[])
break;
#endif /* CONFIG_DEBUG_LINUX_TRACING */
case 'v':
#ifndef CONFIG_NO_HOSTAPD_LOGGER
-@@ -143,6 +145,14 @@ static void hostapd_logger_cb(void *ctx,
+@@ -147,6 +149,14 @@ static void hostapd_logger_cb(void *ctx,
}
#endif /* CONFIG_NO_HOSTAPD_LOGGER */
/**
* hostapd_driver_init - Preparate driver interface
-@@ -161,6 +171,8 @@ static int hostapd_driver_init(struct ho
+@@ -165,6 +175,8 @@ static int hostapd_driver_init(struct ho
return -1;
}
/* Initialize the driver interface */
if (!(b[0] | b[1] | b[2] | b[3] | b[4] | b[5]))
b = NULL;
-@@ -401,8 +413,6 @@ static void hostapd_global_deinit(const
+@@ -405,8 +417,6 @@ static void hostapd_global_deinit(const
#endif /* CONFIG_NATIVE_WINDOWS */
eap_server_unregister_methods();
}
-@@ -428,18 +438,6 @@ static int hostapd_global_run(struct hap
+@@ -432,18 +442,6 @@ static int hostapd_global_run(struct hap
}
#endif /* EAP_SERVER_TNC */
eloop_run();
return 0;
-@@ -638,8 +636,7 @@ int main(int argc, char *argv[])
+@@ -645,8 +643,7 @@ int main(int argc, char *argv[])
struct hapd_interfaces interfaces;
int ret = 1;
size_t i, j;
/*
* sta->capability is used in check_assoc_ies() for RRM enabled
* capability element.
-@@ -3023,7 +3049,7 @@ int ieee802_11_mgmt(struct hostapd_data
+@@ -3025,7 +3051,7 @@ int ieee802_11_mgmt(struct hostapd_data
if (stype == WLAN_FC_STYPE_PROBE_REQ) {
return 1;
}
-@@ -3041,17 +3067,17 @@ int ieee802_11_mgmt(struct hostapd_data
+@@ -3043,17 +3069,17 @@ int ieee802_11_mgmt(struct hostapd_data
switch (stype) {
case WLAN_FC_STYPE_AUTH:
wpa_printf(MSG_DEBUG, "mgmt::auth");
static inline int has_feature(const char *feat)
{
-#ifdef IEEE8021X_EAPOL
+#if defined(IEEE8021X_EAPOL) || (defined(HOSTAPD) && !defined(CONFIG_NO_RADIUS))
if (!strcmp(feat, "eap"))
return 1;
#endif
-#ifdef IEEE80211N
+#ifdef CONFIG_IEEE80211N
if (!strcmp(feat, "11n"))
return 1;
+#endif
+#ifdef CONFIG_IEEE80211AC
+ if (!strcmp(feat, "11ac"))
+ return 1;
+#endif
+#ifdef CONFIG_IEEE80211R
+ if (!strcmp(feat, "11r"))
+ return 1;
+#endif
+#ifdef CONFIG_IEEE80211W
+ if (!strcmp(feat, "11w"))
+ return 1;
#endif
return 0;
}
+++ /dev/null
-#
-# Copyright (C) 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:=mdns
-PKG_RELEASE:=1
-
-PKG_SOURCE_URL=$(LEDE_GIT)/project/mdnsd.git
-PKG_SOURCE_PROTO:=git
-PKG_SOURCE_DATE:=2016-12-19
-PKG_SOURCE_VERSION:=be8ae8d0b5f2e8651edf0cc8f35916fc4b71d1ac
-PKG_MIRROR_HASH:=fd6e8b17407b9e6dc96f485c62f54e02a0ab27b5878c271f95749495970dacc2
-
-PKG_MAINTAINER:=John Crispin <john@phrozen.org>
-PKG_LICENSE:=LGPL-2.1
-
-include $(INCLUDE_DIR)/package-seccomp.mk
-include $(INCLUDE_DIR)/package.mk
-include $(INCLUDE_DIR)/cmake.mk
-
-define Package/mdns
- SECTION:=net
- CATEGORY:=Network
- TITLE:=OpenWrt Multicast DNS Daemon
- DEPENDS:=+libubox +libubus +libblobmsg-json
-endef
-
-TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
-
-define Package/mdns/conffiles
-/etc/config/mdns
-endef
-
-define Package/mdns/install
- $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/mdns $(1)/usr/sbin/
- $(INSTALL_BIN) ./files/mdns.init $(1)/etc/init.d/mdns
- $(INSTALL_CONF) ./files/mdns.config $(1)/etc/config/mdns
- $(call InstallSeccomp,$(1),./files/mdns.json)
-endef
-
-$(eval $(call BuildPackage,mdns))
+++ /dev/null
-config mdns
- option jail 1
- list network lan
+++ /dev/null
-#!/bin/sh /etc/rc.common
-# Copyright (c) 2014 OpenWrt.org
-
-. /lib/functions/network.sh
-
-START=80
-
-USE_PROCD=1
-PROG=/usr/sbin/mdns
-IFACES=""
-
-load_ifaces() {
- local network="$(uci get mdns.@mdns[-1].network)"
- for n in $network; do
- local device
- json_load "$(ifstatus $n)"
- json_get_var device l3_device
- echo -n "$device "
- done
-}
-
-reload_service() {
- json_init
- json_add_array interfaces
- for i in $(load_ifaces); do
- json_add_string "" "$i"
- done
- json_close_array
-
- ubus call mdns set_config "$(json_dump)"
-}
-
-start_service() {
- local network="$(uci get mdns.@mdns[-1].network)"
-
- procd_open_instance
- procd_set_param command "$PROG"
- procd_set_param seccomp /etc/seccomp/mdns.json
- procd_set_param respawn
- procd_open_trigger
- procd_add_config_trigger "config.change" "mdns" /etc/init.d/mdns reload
- for n in $network; do
- procd_add_interface_trigger "interface.*" $n /etc/init.d/mdns reload
- done
- procd_add_raw_trigger "instance.update" 5000 "/bin/ubus" "call" "mdns" "reload"
- procd_close_trigger
- [ "$(uci get mdns.@mdns[-1].jail)" = 1 ] && procd_add_jail mdns ubus log
- procd_close_instance
-}
-
-service_started() {
- ubus -t 10 wait_for mdns
- [ $? = 0 ] && reload_service
-}
+++ /dev/null
-{
- "whitelist": [
- "read",
- "write",
- "open",
- "close",
- "time",
- "brk",
- "ioctl",
- "uname",
- "bind",
- "connect",
- "getsockname",
- "recvmsg",
- "sendmsg",
- "sendto",
- "setsockopt",
- "socket",
- "poll",
- "fcntl64",
- "epoll_create",
- "epoll_ctl",
- "epoll_wait",
- "rt_sigaction",
- "sigreturn",
- "rt_sigreturn",
- "exit_group",
- "exit",
- "clock_gettime"
- ],
- "policy": 1
-}
PKG_NAME:=odhcpd
PKG_RELEASE:=1
-PKG_SOURCE_URL:=git://git.lede-project.org/project/odhcpd.git
PKG_SOURCE_PROTO:=git
-PKG_SOURCE_DATE:=2017-01-06
-PKG_SOURCE_VERSION:=ef3c5632c100fda0fa463a3ed56ff926f3f86b20
-PKG_MIRROR_HASH:=a870ae200dd4b0776f18f19051f75a6654108e8f25044d37c6d0856193c3ccf0
+PKG_SOURCE_URL=$(LEDE_GIT)/project/odhcpd.git
+PKG_SOURCE_DATE:=2017-02-09
+PKG_SOURCE_VERSION:=8df4253ba73246d31f2e65f2004da3f9890c22c5
+PKG_MIRROR_HASH:=0040f94d11d0039505328a90b2ff48968db873e9e7967307631bf40ef5679275
-PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
+PKG_MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com>
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
SECTION:=net
CATEGORY:=Network
TITLE:=OpenWrt DHCP/DHCPv6(-PD)/RA Server & Relay
- DEPENDS:=+libubox +libuci +libubus
+ DEPENDS:=+libubox +libuci +libubus +libnl-tiny
endef
define Package/odhcpd/config
PKG_NAME:=openvpn
PKG_VERSION:=2.4.0
-PKG_RELEASE:=1
+PKG_RELEASE:=3
PKG_SOURCE_URL:=http://swupdate.openvpn.net/community/releases
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
MENU:=1
DEPENDS:=+kmod-tun +OPENVPN_$(1)_ENABLE_LZO:liblzo +OPENVPN_$(1)_ENABLE_IPROUTE2:ip $(3)
VARIANT:=$(1)
+ifeq ($(1),nossl)
+ PROVIDES:=openvpn
+else
+ PROVIDES:=openvpn openvpn-crypto
+endif
MAINTAINER:=Mirko Vogt <mirko@openwrt.org>
endef
# append flags
append_bools "$s" \
- auth_nocache auth_user_pass_optional bind ccd_exclusive client client_cert_not_required \
- client_to_client comp_noadapt disable \
- disable_occ down_pre duplicate_cn fast_io float http_proxy_retry \
+ allow_recursive_routing auth_nocache auth_user_pass_optional bind ccd_exclusive client client_cert_not_required \
+ client_to_client comp_noadapt disable disable_occ down_pre duplicate_cn fast_io float http_proxy_retry \
ifconfig_noexec ifconfig_nowarn ifconfig_pool_linear management_forget_disconnect management_hold \
management_query_passwords management_signal mktun mlock mtu_test multihome mute_replay_warnings \
- nobind no_iv no_name_remapping no_replay opt_verify passtos persist_key persist_local_ip \
- persist_remote_ip persist_tun ping_timer_rem pull push_reset \
- remote_random rmtun route_noexec route_nopull single_session socks_proxy_retry \
- suppress_timestamps tcp_nodelay test_crypto tls_client tls_exit tls_server \
+ ncp_disable nobind no_iv no_name_remapping no_replay opt_verify passtos persist_key persist_local_ip \
+ persist_remote_ip persist_tun ping_timer_rem pull push_reset remote_random rmtun route_noexec route_nopull \
+ single_session socks_proxy_retry suppress_timestamps tcp_nodelay test_crypto tls_client tls_exit tls_server \
tun_ipv6 up_delay up_restart username_as_common_name
# append params
append_params "$s" \
cd askpass auth auth_retry auth_user_pass auth_user_pass_verify bcast_buffers ca cert capath \
- chroot cipher client_config_dir client_connect client_disconnect comp_lzo connect_freq \
+ chroot cipher client_config_dir client_connect client_disconnect comp_lzo compress connect_freq \
connect_retry connect_timeout connect_retry_max crl_verify dev dev_node dev_type dh \
- echo engine explicit_exit_notify fragment group hand_window hash_size \
- http_proxy http_proxy_option http_proxy_timeout ifconfig ifconfig_pool \
- ifconfig_pool_persist ifconfig_push inactive ipchange iroute keepalive \
- key key_method keysize learn_address link_mtu lladdr local log log_append \
- lport management management_log_cache max_clients \
- max_routes_per_client mode mssfix mtu_disc mute nice ns_cert_type ping \
- ping_exit ping_restart pkcs12 plugin port port_share prng proto rcvbuf \
- redirect_gateway remap_usr1 remote remote_cert_eku remote_cert_ku remote_cert_tls \
- reneg_bytes reneg_pkts reneg_sec \
- replay_persist replay_window resolv_retry route route_delay route_gateway \
- route_metric route_pre_down route_up rport script_security secret server server_bridge setenv shaper sndbuf \
- socks_proxy status status_version syslog tcp_queue_limit tls_auth tls_version_min \
- tls_cipher tls_remote tls_timeout tls_verify tmp_dir topology tran_window \
- tun_mtu tun_mtu_extra txqueuelen user verb down push up \
- verify_x509_name x509_username_field \
- ifconfig_ipv6 route_ipv6 server_ipv6 ifconfig_ipv6_pool ifconfig_ipv6_push iroute_ipv6
+ ecdh_curve echo engine explicit_exit_notify fragment group hand_window hash_size http_proxy \
+ http_proxy_option http_proxy_timeout ifconfig ifconfig_pool ifconfig_pool_persist ifconfig_push \
+ inactive ipchange iroute keepalive key key_direction key_method keysize learn_address link_mtu lladdr \
+ local log log_append lport management management_log_cache max_clients max_routes_per_client mode \
+ mssfix mtu_disc mute ncp_ciphers nice ns_cert_type ping ping_exit ping_restart pkcs12 plugin \
+ port port_share prng proto pull_filter rcvbuf redirect_gateway remap_usr1 remote remote_cert_eku \
+ remote_cert_ku remote_cert_tls reneg_bytes reneg_pkts reneg_sec replay_persist replay_window \
+ resolv_retry route route_delay route_gateway route_metric route_pre_down route_up rport \
+ script_security secret server server_bridge setenv shaper sndbuf socks_proxy status status_version \
+ syslog tcp_queue_limit tls_auth tls_crypt tls_version_min tls_cipher tls_timeout \
+ tls_verify tmp_dir topology tran_window tun_mtu tun_mtu_extra txqueuelen user verb \
+ down push up verify_x509_name x509_username_field ifconfig_ipv6 route_ipv6 server_ipv6 \
+ ifconfig_ipv6_pool ifconfig_ipv6_push iroute_ipv6
openvpn_add_instance "$s" "/var/etc" "openvpn-$s.conf"
}
PKG_NAME:=ppp
PKG_VERSION:=2.4.7
-PKG_RELEASE:=10
+PKG_RELEASE:=11
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://download.samba.org/pub/ppp/
define Package/ppp/Default
SECTION:=net
CATEGORY:=Network
- URL:=http://ppp.samba.org/
+ URL:=https://ppp.samba.org/
endef
define Package/ppp
This package contains an utility to report PPP statistics.
endef
+define Package/pppoe-discovery
+$(call Package/ppp/Default)
+ DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink) +ppp-mod-pppoe
+ TITLE:=Perform a PPPoE-discovery process
+endef
+
+define Package/pppoe-discovery/description
+This tool performs the same discovery process as pppoe, but does
+not initiate a session. Can be useful to debug pppoe.
+endef
+
define Build/Configure
$(call Build/Configure/Default,, \
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/pppstats $(1)/usr/sbin/
endef
+define Package/pppoe-discovery/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/pppoe-discovery $(1)/usr/sbin/
+endef
+
$(eval $(call BuildPackage,ppp))
$(eval $(call BuildPackage,ppp-multilink))
$(eval $(call BuildPackage,ppp-mod-pppoa))
$(eval $(call BuildPackage,chat))
$(eval $(call BuildPackage,pppdump))
$(eval $(call BuildPackage,pppstats))
+$(eval $(call BuildPackage,pppoe-discovery))
json_add_string ifname "@$PPP_IPPARAM"
json_add_string proto "dhcpv6"
[ -n "$EXTENDPREFIX" ] && json_add_string extendprefix 1
+ [ -n "$IP6TABLE" ] && json_add_string ip6table $IP6TABLE
+ [ -n "$PEERDNS" ] && json_add_boolean peerdns $PEERDNS
json_close_object
ubus call network add_dynamic "$(json_dump)"
fi
local config="$1"; shift
local localip
- json_get_vars ipv6 demand keepalive keepalive_adaptive username password pppd_options pppname unnumbered persist maxfail holdoff
+ json_get_vars ipv6 ip6table demand keepalive keepalive_adaptive username password pppd_options pppname unnumbered persist maxfail holdoff peerdns
if [ "$ipv6" = 0 ]; then
ipv6=""
elif [ -z "$ipv6" -o "$ipv6" = auto ]; then
${lcp_failure:+lcp-echo-interval $lcp_interval lcp-echo-failure $lcp_failure $lcp_adaptive} \
${ipv6:++ipv6} \
${autoipv6:+set AUTOIPV6=1} \
+ ${ip6table:+set IP6TABLE=$ip6table} \
+ ${peerdns:+set PEERDNS=$peerdns} \
nodefaultroute \
usepeerdns \
$demand $persist maxfail $maxfail \
include $(TOPDIR)/rules.mk
PKG_NAME:=relayd
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE_URL=$(LEDE_GIT)/project/relayd.git
PKG_SOURCE_PROTO:=git
resolve_ifname() {
grep -qs "^ *$1:" /proc/net/dev && {
- procd_append_param command -I "$1"
- procd_append_param netdev "$1"
- append ifaces "$1"
+ append resolved_ifnames "$1"
}
}
start_relay() {
local cfg="$1"
-
- local args=""
- local ifaces=""
+ local proto disabled
config_get proto "$cfg" proto
[ "$proto" = "relay" ] || return 0
config_get_bool disabled "$cfg" disabled 0
[ "$disabled" -gt 0 ] && return 0
- SERVICE_DAEMONIZE=1
- SERVICE_WRITE_PID=1
- SERVICE_PID_FILE="/var/run/relay-$cfg.pid"
- [ -f "$SERVICE_PID_FILE" ] && {
- if grep -q relayd "/proc/$(cat $SERVICE_PID_FILE)/cmdline"; then
- return 0
- else
- rm -f "$SERVICE_PID_FILE"
- fi
- }
-
- procd_open_instance
- procd_set_param command "$PROG"
-
+ local resolved_ifnames
local net networks
config_get networks "$cfg" network
for net in $networks; do
local ifn ifnames
config_get ifnames "$cfg" ifname
for ifn in $ifnames; do
- resolve_ifname "$ifn"
+ resolve_ifname "$ifn" || {
+ return 1
+ }
done
+ procd_open_instance
+ procd_set_param command "$PROG"
+
+ for ifn in $resolved_ifnames; do
+ procd_append_param command -I "$ifn"
+ procd_append_param netdev "$ifn"
+ done
local ipaddr
config_get ipaddr "$cfg" ipaddr
[ -n "$ipaddr" ] && procd_append_param command -L "$ipaddr"
PKG_VERSION:=3.6.25
PKG_RELEASE:=5
-PKG_SOURCE_URL:=http://ftp.samba.org/pub/samba \
- http://ftp.samba.org/pub/samba/stable
+PKG_SOURCE_URL:=https://download.samba.org/pub/samba \
+ https://download.samba.org/pub/samba/stable
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_HASH:=8f2c8a7f2bd89b0dfd228ed917815852f7c625b2bc0936304ac3ed63aaf83751
SECTION:=net
CATEGORY:=Network
TITLE:=Samba 3.6 SMB/CIFS server
- URL:=http://www.samba.org/
+ URL:=https://www.samba.org/
DEPENDS:=+USE_GLIBC:librt $(ICONV_DEPENDS)
endef
SECTION:=net
CATEGORY:=Network
TITLE:=Samba 3.6 SMB/CIFS client
- URL:=http://www.samba.org/
+ URL:=https://www.samba.org/
DEPENDS:=+libreadline +libncurses
endef
# Prefer px5g for certificate generation (existence evaluated last)
local GENKEY_CMD=""
local UNIQUEID=$(dd if=/dev/urandom bs=1 count=4 | hexdump -e '1/1 "%02x"')
- [ -x "$OPENSSL_BIN" ] && GENKEY_CMD="$OPENSSL_BIN req -x509 -outform der -nodes"
+ [ -x "$OPENSSL_BIN" ] && GENKEY_CMD="$OPENSSL_BIN req -x509 -sha256 -outform der -nodes"
[ -x "$PX5G_BIN" ] && GENKEY_CMD="$PX5G_BIN selfsigned -der"
[ -n "$GENKEY_CMD" ] && {
$GENKEY_CMD \
--- /dev/null
+#
+# Copyright (C) 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:=umdns
+PKG_RELEASE:=1
+
+PKG_SOURCE_URL=$(LEDE_GIT)/project/mdnsd.git
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_DATE:=2017-03-10
+PKG_SOURCE_VERSION:=d4376788601c38963c4c836d325e3a66498079ea
+PKG_MIRROR_HASH:=be60c437e13cf712b967af08c7cf8bda8dc3ad6d169965e3108fe3107c59009b
+
+PKG_MAINTAINER:=John Crispin <john@phrozen.org>
+PKG_LICENSE:=LGPL-2.1
+
+include $(INCLUDE_DIR)/package-seccomp.mk
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/umdns
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=OpenWrt Multicast DNS Daemon
+ DEPENDS:=+libubox +libubus +libblobmsg-json
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+
+define Package/umdns/conffiles
+/etc/config/umdns
+endef
+
+define Package/umdns/install
+ $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/umdns $(1)/usr/sbin/
+ $(INSTALL_BIN) ./files/umdns.init $(1)/etc/init.d/umdns
+ $(INSTALL_CONF) ./files/umdns.config $(1)/etc/config/umdns
+ $(call InstallSeccomp,$(1),./files/umdns.json)
+endef
+
+$(eval $(call BuildPackage,umdns))
--- /dev/null
+config umdns
+ option jail 1
+ list network lan
--- /dev/null
+#!/bin/sh /etc/rc.common
+# Copyright (c) 2014 OpenWrt.org
+
+. /lib/functions/network.sh
+
+START=80
+
+USE_PROCD=1
+PROG=/usr/sbin/umdns
+IFACES=""
+
+load_ifaces() {
+ local network="$(uci get umdns.@umdns[-1].network)"
+ for n in $network; do
+ local device
+ json_load "$(ifstatus $n)"
+ json_get_var device l3_device
+ echo -n "$device "
+ done
+}
+
+reload_service() {
+ json_init
+ json_add_array interfaces
+ for i in $(load_ifaces); do
+ json_add_string "" "$i"
+ done
+ json_close_array
+
+ ubus call umdns set_config "$(json_dump)"
+}
+
+start_service() {
+ local network="$(uci get umdns.@umdns[-1].network)"
+
+ procd_open_instance
+ procd_set_param command "$PROG"
+ procd_set_param seccomp /etc/seccomp/umdns.json
+ procd_set_param respawn
+ procd_open_trigger
+ procd_add_config_trigger "config.change" "umdns" /etc/init.d/umdns reload
+ for n in $network; do
+ procd_add_interface_trigger "interface.*" $n /etc/init.d/umdns reload
+ done
+ procd_add_raw_trigger "instance.update" 5000 "/bin/ubus" "call" "umdns" "reload"
+ procd_close_trigger
+ [ "$(uci get umdns.@umdns[-1].jail)" = 1 ] && procd_add_jail umdns ubus log
+ procd_close_instance
+}
+
+service_started() {
+ ubus -t 10 wait_for umdns
+ [ $? = 0 ] && reload_service
+}
--- /dev/null
+{
+ "whitelist": [
+ "read",
+ "write",
+ "open",
+ "close",
+ "time",
+ "brk",
+ "ioctl",
+ "uname",
+ "bind",
+ "connect",
+ "getsockname",
+ "recvmsg",
+ "sendmsg",
+ "sendto",
+ "setsockopt",
+ "socket",
+ "poll",
+ "fcntl64",
+ "epoll_create",
+ "epoll_ctl",
+ "epoll_wait",
+ "rt_sigaction",
+ "sigreturn",
+ "rt_sigreturn",
+ "exit_group",
+ "exit",
+ "clock_gettime"
+ ],
+ "policy": 1
+}
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME).$(PKG_VERSION)
PKG_CHECK_FORMAT_SECURITY:=0
+PKG_FLAGS:=nonshared
+
include $(INCLUDE_DIR)/package.mk
define Package/comgt/Default
PKG_NAME:=curl
PKG_VERSION:=7.52.1
-PKG_RELEASE:=2
+PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://curl.haxx.se/download/ \
--- /dev/null
+From a7b38c9dc98481e4a5fc37e51a8690337c674dfb Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Mon, 26 Dec 2016 00:06:33 +0100
+Subject: [PATCH] vtls: s/SSLEAY/OPENSSL
+
+Fixed an old leftover use of the USE_SSLEAY define which would make a
+socket get removed from the applications sockets to monitor when the
+multi_socket API was used, leading to timeouts.
+
+Bug: #1174
+---
+ lib/vtls/vtls.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/lib/vtls/vtls.c
++++ b/lib/vtls/vtls.c
+@@ -484,7 +484,7 @@ void Curl_ssl_close_all(struct Curl_easy
+ curlssl_close_all(data);
+ }
+
+-#if defined(USE_SSLEAY) || defined(USE_GNUTLS) || defined(USE_SCHANNEL) || \
++#if defined(USE_OPENSSL) || defined(USE_GNUTLS) || defined(USE_SCHANNEL) || \
+ defined(USE_DARWINSSL) || defined(USE_NSS)
+ /* This function is for OpenSSL, GnuTLS, darwinssl, and schannel only. */
+ int Curl_ssl_getsock(struct connectdata *conn, curl_socket_t *socks,
+@@ -518,7 +518,7 @@ int Curl_ssl_getsock(struct connectdata
+ (void)numsocks;
+ return GETSOCK_BLANK;
+ }
+-/* USE_SSLEAY || USE_GNUTLS || USE_SCHANNEL || USE_DARWINSSL || USE_NSS */
++/* USE_OPENSSL || USE_GNUTLS || USE_SCHANNEL || USE_DARWINSSL || USE_NSS */
+ #endif
+
+ void Curl_ssl_close(struct connectdata *conn, int sockindex)
--- /dev/null
+From a00a42b4abe8363a46071bb3b43b1b7138f5259b Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Sun, 22 Jan 2017 18:11:55 +0100
+Subject: [PATCH] TLS: make SSL_VERIFYSTATUS work again
+
+The CURLOPT_SSL_VERIFYSTATUS option was not properly handled by libcurl
+and thus even if the status couldn't be verified, the connection would
+be allowed and the user would not be told about the failed verification.
+
+Regression since cb4e2be7c6d42ca
+
+CVE-2017-2629
+Bug: https://curl.haxx.se/docs/adv_20170222.html
+
+Reported-by: Marcus Hoffmann
+---
+ lib/url.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -4141,8 +4141,11 @@ static struct connectdata *allocate_conn
+ conn->bits.ftp_use_epsv = data->set.ftp_use_epsv;
+ conn->bits.ftp_use_eprt = data->set.ftp_use_eprt;
+
++ conn->ssl_config.verifystatus = data->set.ssl.primary.verifystatus;
+ conn->ssl_config.verifypeer = data->set.ssl.primary.verifypeer;
+ conn->ssl_config.verifyhost = data->set.ssl.primary.verifyhost;
++ conn->proxy_ssl_config.verifystatus =
++ data->set.proxy_ssl.primary.verifystatus;
+ conn->proxy_ssl_config.verifypeer = data->set.proxy_ssl.primary.verifypeer;
+ conn->proxy_ssl_config.verifyhost = data->set.proxy_ssl.primary.verifyhost;
+
include $(TOPDIR)/rules.mk
PKG_NAME:=ebtables
-PKG_VERSION:=2.0.10-4
-PKG_RELEASE:=5
+PKG_SOURCE_DATE:=2015-10-28
+PKG_RELEASE:=1
-PKG_SOURCE:=$(PKG_NAME)-v$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=@SF/ebtables
-PKG_HASH:=dc6f7b484f207dc712bfca81645f45120cb6aee3380e77a1771e9c34a9a4455d
+PKG_SOURCE_URL:=git://git.netfilter.org/ebtables
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_VERSION:=4c3e5cd3dbae3ea773e9dcca7cf019b2713af70d
+PKG_MIRROR_HASH:=997a877da02d6e2141e6d31c5d4dd005737facecfdbea07308c0e1286db8591c
-PKG_BUILD_DIR:=$(BUILD_DIR)/ebtables-v$(PKG_VERSION)
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
---- a/extensions/ebt_among.c
-+++ b/extensions/ebt_among.c
-@@ -13,7 +13,6 @@
- #include <ctype.h>
- #include <unistd.h>
- #include "../include/ebtables_u.h"
--#include <netinet/ether.h>
- #include "../include/ethernetdb.h"
- #include <linux/if_ether.h>
- #include <linux/netfilter_bridge/ebt_among.h>
---- a/extensions/ebt_arpreply.c
-+++ b/extensions/ebt_arpreply.c
-@@ -12,7 +12,6 @@
- #include <string.h>
- #include <getopt.h>
- #include "../include/ebtables_u.h"
--#include <netinet/ether.h>
- #include <linux/netfilter_bridge/ebt_arpreply.h>
-
- static int mac_supplied;
---- a/extensions/ebt_nat.c
-+++ b/extensions/ebt_nat.c
-@@ -11,7 +11,6 @@
- #include <string.h>
- #include <getopt.h>
- #include "../include/ebtables_u.h"
--#include <netinet/ether.h>
- #include <linux/netfilter_bridge/ebt_nat.h>
-
- static int to_source_supplied, to_dest_supplied;
---- a/useful_functions.c
-+++ b/useful_functions.c
-@@ -25,7 +25,6 @@
- #include "include/ebtables_u.h"
- #include "include/ethernetdb.h"
- #include <stdio.h>
--#include <netinet/ether.h>
- #include <string.h>
- #include <stdlib.h>
- #include <getopt.h>
--- a/include/ebtables_u.h
+++ b/include/ebtables_u.h
-@@ -23,7 +23,9 @@
+@@ -23,6 +23,7 @@
#ifndef EBTABLES_U_H
#define EBTABLES_U_H
-+#include <sys/types.h>
++#define _NETINET_IF_ETHER_H
#include <netinet/in.h>
-+#include <netinet/ether.h>
#include <linux/netfilter_bridge/ebtables.h>
#include <linux/netfilter/x_tables.h>
-
---- a/include/linux/if_ether.h
-+++ /dev/null
-@@ -1,126 +0,0 @@
--/*
-- * INET An implementation of the TCP/IP protocol suite for the LINUX
-- * operating system. INET is implemented using the BSD Socket
-- * interface as the means of communication with the user level.
-- *
-- * Global definitions for the Ethernet IEEE 802.3 interface.
-- *
-- * Version: @(#)if_ether.h 1.0.1a 02/08/94
-- *
-- * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
-- * Donald Becker, <becker@super.org>
-- * Alan Cox, <alan@lxorguk.ukuu.org.uk>
-- * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
-- *
-- * This program is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU General Public License
-- * as published by the Free Software Foundation; either version
-- * 2 of the License, or (at your option) any later version.
-- */
--
--#ifndef _LINUX_IF_ETHER_H
--#define _LINUX_IF_ETHER_H
--
--#include <linux/types.h>
--
--/*
-- * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
-- * and FCS/CRC (frame check sequence).
-- */
--
--#define ETH_ALEN 6 /* Octets in one ethernet addr */
--#define ETH_HLEN 14 /* Total octets in header. */
--#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
--#define ETH_DATA_LEN 1500 /* Max. octets in payload */
--#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */
--#define ETH_FCS_LEN 4 /* Octets in the FCS */
--
--/*
-- * These are the defined Ethernet Protocol ID's.
-- */
--
--#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */
--#define ETH_P_PUP 0x0200 /* Xerox PUP packet */
--#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */
--#define ETH_P_IP 0x0800 /* Internet Protocol packet */
--#define ETH_P_X25 0x0805 /* CCITT X.25 */
--#define ETH_P_ARP 0x0806 /* Address Resolution packet */
--#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] */
--#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */
--#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr Trans packet */
--#define ETH_P_DEC 0x6000 /* DEC Assigned proto */
--#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */
--#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */
--#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */
--#define ETH_P_LAT 0x6004 /* DEC LAT */
--#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */
--#define ETH_P_CUST 0x6006 /* DEC Customer use */
--#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */
--#define ETH_P_TEB 0x6558 /* Trans Ether Bridging */
--#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */
--#define ETH_P_ATALK 0x809B /* Appletalk DDP */
--#define ETH_P_AARP 0x80F3 /* Appletalk AARP */
--#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */
--#define ETH_P_IPX 0x8137 /* IPX over DIX */
--#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */
--#define ETH_P_PAUSE 0x8808 /* IEEE Pause frames. See 802.3 31B */
--#define ETH_P_SLOW 0x8809 /* Slow Protocol. See 802.3ad 43B */
--#define ETH_P_WCCP 0x883E /* Web-cache coordination protocol
-- * defined in draft-wilson-wrec-wccp-v2-00.txt */
--#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */
--#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */
--#define ETH_P_MPLS_UC 0x8847 /* MPLS Unicast traffic */
--#define ETH_P_MPLS_MC 0x8848 /* MPLS Multicast traffic */
--#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */
--#define ETH_P_LINK_CTL 0x886c /* HPNA, wlan link local tunnel */
--#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport
-- * over Ethernet
-- */
--#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
--#define ETH_P_AOE 0x88A2 /* ATA over Ethernet */
--#define ETH_P_TIPC 0x88CA /* TIPC */
--#define ETH_P_1588 0x88F7 /* IEEE 1588 Timesync */
--#define ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */
--#define ETH_P_FIP 0x8914 /* FCoE Initialization Protocol */
--#define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
--
--/*
-- * Non DIX types. Won't clash for 1500 types.
-- */
--
--#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */
--#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */
--#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
--#define ETH_P_802_2 0x0004 /* 802.2 frames */
--#define ETH_P_SNAP 0x0005 /* Internal only */
--#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */
--#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/
--#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */
--#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */
--#define ETH_P_CAN 0x000C /* Controller Area Network */
--#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/
--#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */
--#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */
--#define ETH_P_CONTROL 0x0016 /* Card specific control frames */
--#define ETH_P_IRDA 0x0017 /* Linux-IrDA */
--#define ETH_P_ECONET 0x0018 /* Acorn Econet */
--#define ETH_P_HDLC 0x0019 /* HDLC frames */
--#define ETH_P_ARCNET 0x001A /* 1A for ArcNet :-) */
--#define ETH_P_DSA 0x001B /* Distributed Switch Arch. */
--#define ETH_P_TRAILER 0x001C /* Trailer switch tagging */
--#define ETH_P_PHONET 0x00F5 /* Nokia Phonet frames */
--#define ETH_P_IEEE802154 0x00F6 /* IEEE802.15.4 frame */
--#define ETH_P_CAIF 0x00F7 /* ST-Ericsson CAIF protocol */
--
--/*
-- * This is an Ethernet frame header.
-- */
--
--struct ethhdr {
-- unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
-- unsigned char h_source[ETH_ALEN]; /* source ether addr */
-- __be16 h_proto; /* packet type ID field */
--} __attribute__((packed));
--
--
--#endif /* _LINUX_IF_ETHER_H */
}
--- a/extensions/ebt_among.c
+++ b/extensions/ebt_among.c
-@@ -490,7 +490,7 @@ static struct ebt_u_match among_match =
+@@ -491,7 +491,7 @@ static struct ebt_u_match among_match =
.extra_ops = opts,
};
}
--- a/extensions/ebt_arpreply.c
+++ b/extensions/ebt_arpreply.c
-@@ -132,7 +132,7 @@ static struct ebt_u_target arpreply_targ
+@@ -133,7 +133,7 @@ static struct ebt_u_target arpreply_targ
.extra_ops = opts,
};
}
--- a/extensions/ebt_ip6.c
+++ b/extensions/ebt_ip6.c
-@@ -556,7 +556,7 @@ static struct ebt_u_match ip6_match =
+@@ -560,7 +560,7 @@ static struct ebt_u_match ip6_match =
.extra_ops = opts,
};
}
--- a/extensions/ebt_nat.c
+++ b/extensions/ebt_nat.c
-@@ -230,7 +230,7 @@ static struct ebt_u_target dnat_target =
+@@ -231,7 +231,7 @@ static struct ebt_u_target dnat_target =
.extra_ops = opts_d,
};
include $(TOPDIR)/rules.mk
PKG_NAME:=iftop
-PKG_VERSION:=1.0pre4
-PKG_RELEASE:=2
-
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=http://www.ex-parrot.com/~pdw/iftop/download
-PKG_HASH:=f733eeea371a7577f8fe353d86dd88d16f5b2a2e702bd96f5ffb2c197d9b4f97
+PKG_RELEASE:=1
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://code.blinkace.com/pdw/iftop.git
+PKG_SOURCE_DATE:=2017-02-06
+PKG_SOURCE_VERSION:=35af3cf65f17961d173b31fd3b00166ec095c226
+PKG_MIRROR_HASH:=84131e2448ea5aa884d2bd7d58dc81741b5c476b4664a8c2c1eb34f62985804a
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
PKG_LICENSE:=GPL-2.0
+PKG_FIXUP:=autoreconf
+
include $(INCLUDE_DIR)/package.mk
define Package/iftop
+++ /dev/null
-iftop: fix mac address display
-
-iftop would display portions of mac address with large ffffff prefixes.
-Make if_hw_addr type consistent.
-
-Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
----
- addrs_dlpi.c | 2 +-
- addrs_ioctl.c | 2 +-
- addrs_ioctl.h | 2 +-
- iftop.c | 2 +-
- 4 files changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/addrs_dlpi.c b/addrs_dlpi.c
-index 188fef8..6c04ea1 100644
---- a/addrs_dlpi.c
-+++ b/addrs_dlpi.c
-@@ -50,7 +50,7 @@ extern char *strncat2(char *dest, char *src, int n);
- */
-
- int
--get_addrs_dlpi(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr)
-+get_addrs_dlpi(char *interface, u_int8_t if_hw_addr[], struct in_addr *if_ip_addr)
- {
- int got_hw_addr = 0;
- int got_ip_addr = 0;
-diff --git a/addrs_ioctl.c b/addrs_ioctl.c
-index 870c83b..7d01fb2 100644
---- a/addrs_ioctl.c
-+++ b/addrs_ioctl.c
-@@ -45,7 +45,7 @@
- */
-
- int
--get_addrs_ioctl(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr, struct in6_addr *if_ip6_addr)
-+get_addrs_ioctl(char *interface, u_int8_t if_hw_addr[], struct in_addr *if_ip_addr, struct in6_addr *if_ip6_addr)
- {
- int s;
- struct ifreq ifr = {};
-diff --git a/addrs_ioctl.h b/addrs_ioctl.h
-index f93a0b4..739de61 100644
---- a/addrs_ioctl.h
-+++ b/addrs_ioctl.h
-@@ -7,6 +7,6 @@
- #define __ADDRS_IOCTL_H_
-
- int
--get_addrs_ioctl(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr, struct in6_addr *if_ip6_addr);
-+get_addrs_ioctl(char *interface, u_int8_t if_hw_addr[], struct in_addr *if_ip_addr, struct in6_addr *if_ip6_addr);
-
- #endif /* __ADDRS_IOCTL_H_ */
-diff --git a/iftop.c b/iftop.c
-index a090dcf..f1b371a 100644
---- a/iftop.c
-+++ b/iftop.c
-@@ -55,7 +55,7 @@
-
- /* ethernet address of interface. */
- int have_hw_addr = 0;
--char if_hw_addr[6];
-+u_int8_t if_hw_addr[6];
-
- /* IP address of interface */
- int have_ip_addr = 0;
---
-1.9.1
-
PKG_NAME:=iproute2
PKG_VERSION:=4.4.0
-PKG_RELEASE:=6
+PKG_RELEASE:=9
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
+diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
+index 8d2530d..c55a9a8 100644
--- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h
-@@ -850,4 +850,59 @@ struct tc_pie_xstats {
+@@ -850,4 +850,60 @@ struct tc_pie_xstats {
__u32 maxq; /* maximum queue size */
__u32 ecn_mark; /* packets marked with ecn*/
};
+ TCA_CAKE_NAT,
+ TCA_CAKE_ETHERNET,
+ TCA_CAKE_WASH,
++ TCA_CAKE_MPU,
+ __TCA_CAKE_MAX
+};
+#define TCA_CAKE_MAX (__TCA_CAKE_MAX - 1)
+};
+
#endif
+diff --git a/tc/Makefile b/tc/Makefile
+index 56acbaa..d421b8e 100644
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -63,6 +63,7 @@ TCMODULES += q_codel.o
TCMODULES += q_hhf.o
TCMODULES += e_bpf.o
+diff --git a/tc/q_cake.c b/tc/q_cake.c
+new file mode 100644
+index 0000000..acbe56c
--- /dev/null
+++ b/tc/q_cake.c
-@@ -0,0 +1,663 @@
+@@ -0,0 +1,692 @@
+/*
+ * Common Applications Kept Enhanced -- CAKE
+ *
+
+static void explain(void)
+{
-+ fprintf(stderr, "Usage: ... cake [ bandwidth RATE | unlimited* | autorate_ingress ]\n"
-+ " [ rtt TIME | datacentre | lan | metro | regional | internet* | oceanic | satellite | interplanetary ]\n"
-+ " [ besteffort | precedence | diffserv8 | diffserv4 | diffserv-llt | diffserv3* ]\n"
-+ " [ flowblind | srchost | dsthost | hosts | flows | dual-srchost | dual-dsthost | triple-isolate* ] [ nat | nonat* ]\n"
-+ " [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n"
-+ " [ wash | nowash* ]\n"
-+ " [ memlimit LIMIT ]\n"
-+ " (* marks defaults)\n");
++ fprintf(stderr,
++"Usage: ... cake [ bandwidth RATE | unlimited* | autorate_ingress ]\n"
++" [ rtt TIME | datacentre | lan | metro | regional |\n"
++" internet* | oceanic | satellite | interplanetary ]\n"
++" [ besteffort | diffserv8 | diffserv4 | diffserv-llt |\n"
++" diffserv3* ]\n"
++" [ flowblind | srchost | dsthost | hosts | flows |\n"
++" dual-srchost | dual-dsthost | triple-isolate* ]\n"
++" [ nat | nonat* ]\n"
++" [ wash | nowash * ]\n"
++" [ memlimit LIMIT ]\n"
++" [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n"
++" [ mpu N ]\n"
++" (* marks defaults)\n");
+}
+
+static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
+ bool overhead_set = false;
+ bool overhead_override = false;
+ int wash = -1;
++ int mpu = 0;
+ int flowmode = -1;
+ int nat = -1;
+ int atm = -1;
+ * you may need to add vlan tag */
+ overhead += 38;
+ overhead_set = true;
++ mpu = 84;
+
+ /* Additional Ethernet-related overhead used by some ISPs */
+ } else if (strcmp(*argv, "ether-vlan") == 0) {
+ atm = 0;
+ overhead += 18;
+ overhead_set = true;
++ mpu = 64;
+
+ } else if (strcmp(*argv, "overhead") == 0) {
+ char* p = NULL;
+ }
+ overhead_set = true;
+
++ } else if (strcmp(*argv, "mpu") == 0) {
++ char* p = NULL;
++ NEXT_ARG();
++ mpu = strtol(*argv, &p, 10);
++ if(!p || *p || !*argv || mpu < 0 || mpu > 256) {
++ fprintf(stderr, "Illegal \"mpu\", valid range is 0 to 256\\n");
++ return -1;
++ }
++
+ } else if (strcmp(*argv, "memlimit") == 0) {
+ NEXT_ARG();
+ if(get_size(&memlimit, *argv)) {
+ unsigned zero = 0;
+ addattr_l(n, 1024, TCA_CAKE_ETHERNET, &zero, sizeof(zero));
+ }
++ if (mpu > 0)
++ addattr_l(n, 1024, TCA_CAKE_MPU, &mpu, sizeof(mpu));
+ if (interval)
+ addattr_l(n, 1024, TCA_CAKE_RTT, &interval, sizeof(interval));
+ if (target)
+ unsigned memlimit = 0;
+ int overhead = 0;
+ int ethernet = 0;
++ int mpu = 0;
+ int atm = 0;
+ int nat = 0;
+ int autorate = 0;
+ RTA_PAYLOAD(tb[TCA_CAKE_OVERHEAD]) >= sizeof(__u32)) {
+ overhead = rta_getattr_u32(tb[TCA_CAKE_OVERHEAD]);
+ }
++ if (tb[TCA_CAKE_MPU] &&
++ RTA_PAYLOAD(tb[TCA_CAKE_MPU]) >= sizeof(__u32)) {
++ mpu = rta_getattr_u32(tb[TCA_CAKE_MPU]);
++ }
+ if (tb[TCA_CAKE_ETHERNET] &&
+ RTA_PAYLOAD(tb[TCA_CAKE_ETHERNET]) >= sizeof(__u32)) {
+ ethernet = rta_getattr_u32(tb[TCA_CAKE_ETHERNET]);
+ fprintf(f, "via-ethernet ");
+ }
+
++ if (mpu) {
++ fprintf(f, "mpu %d ", mpu);
++ }
++
+ if (memlimit)
+ fprintf(f, "memlimit %s", sprint_size(memlimit, b1));
+
--- /dev/null
+From c44003f7e7254ac972eaa1b22a686471ea4ce2d7 Mon Sep 17 00:00:00 2001
+From: Liping Zhang <liping.zhang@spreadtrum.com>
+Date: Tue, 20 Sep 2016 02:09:02 -0700
+Subject: [PATCH] ipmonitor: fix ip monitor can't work when NET_NS is not
+ enabled
+
+In ip monitor, netns_map_init will check getnsid is supported or not.
+But when /proc/self/ns/net does not exist, we just print out error
+messages and exit. So user cannot use ip monitor anymore when
+CONFIG_NET_NS is disabled:
+ # ip monitor
+ open("/proc/self/ns/net"): No such file or directory
+
+If open "/proc/self/ns/net" failed, set have_rtnl_getnsid to false.
+
+Fixes: d652ccbf8195 ("netns: allow to dump and monitor nsid")
+Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
+Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
+---
+ ip/ipnetns.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/ip/ipnetns.c b/ip/ipnetns.c
+index af87065..ccc652c 100644
+--- a/ip/ipnetns.c
++++ b/ip/ipnetns.c
+@@ -72,8 +72,8 @@ static int ipnetns_have_nsid(void)
+ if (have_rtnl_getnsid < 0) {
+ fd = open("/proc/self/ns/net", O_RDONLY);
+ if (fd < 0) {
+- perror("open(\"/proc/self/ns/net\")");
+- exit(1);
++ have_rtnl_getnsid = 0;
++ return 0;
+ }
+
+ addattr32(&req.n, 1024, NETNSA_FD, fd);
+--
+2.6.4
+
--- a/nl80211.h
+++ b/nl80211.h
-@@ -1937,6 +1937,9 @@ enum nl80211_commands {
+@@ -323,7 +323,7 @@
+ * @NL80211_CMD_GET_SCAN: get scan results
+ * @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given parameters
+ * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
+- * probe requests at CCK rate or not. %NL80211_ATTR_MAC can be used to
++ * probe requests at CCK rate or not. %NL80211_ATTR_BSSID can be used to
+ * specify a BSSID to scan for; if not included, the wildcard BSSID will
+ * be used.
+ * @NL80211_CMD_NEW_SCAN_RESULTS: scan notification (as a reply to
+@@ -600,6 +600,20 @@
+ *
+ * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS interface.
+ *
++ * @NL80211_CMD_SET_MULTICAST_TO_UNICAST: Configure if this AP should perform
++ * multicast to unicast conversion. When enabled, all multicast packets
++ * with ethertype ARP, IPv4 or IPv6 (possibly within an 802.1Q header)
++ * will be sent out to each station once with the destination (multicast)
++ * MAC address replaced by the station's MAC address. Note that this may
++ * break certain expectations of the receiver, e.g. the ability to drop
++ * unicast IP packets encapsulated in multicast L2 frames, or the ability
++ * to not send destination unreachable messages in such cases.
++ * This can only be toggled per BSS. Configure this on an interface of
++ * type %NL80211_IFTYPE_AP. It applies to all its VLAN interfaces
++ * (%NL80211_IFTYPE_AP_VLAN), except for those in 4addr (WDS) mode.
++ * If %NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED is not present with this
++ * command, the feature is disabled.
++ *
+ * @NL80211_CMD_JOIN_MESH: Join a mesh. The mesh ID must be given, and initial
+ * mesh config parameters may be given.
+ * @NL80211_CMD_LEAVE_MESH: Leave the mesh network -- no special arguments, the
+@@ -874,6 +888,12 @@
+ * This will contain a %NL80211_ATTR_NAN_MATCH nested attribute and
+ * %NL80211_ATTR_COOKIE.
+ *
++ * @NL80211_CMD_UPDATE_CONNECT_PARAMS: Update one or more connect parameters
++ * for subsequent roaming cases if the driver or firmware uses internal
++ * BSS selection. This command can be issued only while connected and it
++ * does not result in a change for the current association. Currently,
++ * only the %NL80211_ATTR_IE data is used and updated with this command.
++ *
+ * @NL80211_CMD_MAX: highest used command number
+ * @__NL80211_CMD_AFTER_LAST: internal use
+ */
+@@ -1069,6 +1089,10 @@ enum nl80211_commands {
+ NL80211_CMD_CHANGE_NAN_CONFIG,
+ NL80211_CMD_NAN_MATCH,
+
++ NL80211_CMD_SET_MULTICAST_TO_UNICAST,
++
++ NL80211_CMD_UPDATE_CONNECT_PARAMS,
++
+ /* add new commands above here */
+
+ /* used to define NL80211_CMD_MAX below */
+@@ -1638,8 +1662,16 @@ enum nl80211_commands {
+ * the connection request from a station. nl80211_connect_failed_reason
+ * enum has different reasons of connection failure.
+ *
+- * @NL80211_ATTR_SAE_DATA: SAE elements in Authentication frames. This starts
+- * with the Authentication transaction sequence number field.
++ * @NL80211_ATTR_AUTH_DATA: Fields and elements in Authentication frames.
++ * This contains the authentication frame body (non-IE and IE data),
++ * excluding the Authentication algorithm number, i.e., starting at the
++ * Authentication transaction sequence number field. It is used with
++ * authentication algorithms that need special fields to be added into
++ * the frames (SAE and FILS). Currently, only the SAE cases use the
++ * initial two fields (Authentication transaction sequence number and
++ * Status code). However, those fields are included in the attribute data
++ * for all authentication algorithms to keep the attribute definition
++ * consistent.
+ *
+ * @NL80211_ATTR_VHT_CAPABILITY: VHT Capability information element (from
+ * association request when used with NL80211_CMD_NEW_STATION)
+@@ -1740,7 +1772,9 @@ enum nl80211_commands {
+ *
+ * @NL80211_ATTR_OPMODE_NOTIF: Operating mode field from Operating Mode
+ * Notification Element based on association request when used with
+- * %NL80211_CMD_NEW_STATION; u8 attribute.
++ * %NL80211_CMD_NEW_STATION or %NL80211_CMD_SET_STATION (only when
++ * %NL80211_FEATURE_FULL_AP_CLIENT_STATE is supported, or with TDLS);
++ * u8 attribute.
+ *
+ * @NL80211_ATTR_VENDOR_ID: The vendor ID, either a 24-bit OUI or, if
+ * %NL80211_VENDOR_ID_IS_LINUX is set, a special Linux ID (not used yet)
+@@ -1788,6 +1822,8 @@ enum nl80211_commands {
+ * and remove functions. NAN notifications will be sent in unicast to that
+ * socket. Without this attribute, any socket can add functions and the
+ * notifications will be sent to the %NL80211_MCGRP_NAN multicast group.
++ * If set during %NL80211_CMD_ASSOCIATE or %NL80211_CMD_CONNECT the
++ * station will deauthenticate when the socket is closed.
+ *
+ * @NL80211_ATTR_TDLS_INITIATOR: flag attribute indicating the current end is
+ * the TDLS link initiator.
+@@ -1936,6 +1972,38 @@ enum nl80211_commands {
+ * attribute.
* @NL80211_ATTR_NAN_MATCH: used to report a match. This is a nested attribute.
* See &enum nl80211_nan_match_attributes.
- *
++ * @NL80211_ATTR_FILS_KEK: KEK for FILS (Re)Association Request/Response frame
++ * protection.
++ * @NL80211_ATTR_FILS_NONCES: Nonces (part of AAD) for FILS (Re)Association
++ * Request/Response frame protection. This attribute contains the 16 octet
++ * STA Nonce followed by 16 octets of AP Nonce.
++ *
++ * @NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED: Indicates whether or not multicast
++ * packets should be send out as unicast to all stations (flag attribute).
++ *
++ * @NL80211_ATTR_BSSID: The BSSID of the AP. Note that %NL80211_ATTR_MAC is also
++ * used in various commands/events for specifying the BSSID.
++ *
++ * @NL80211_ATTR_SCHED_SCAN_RELATIVE_RSSI: Relative RSSI threshold by which
++ * other BSSs has to be better or slightly worse than the current
++ * connected BSS so that they get reported to user space.
++ * This will give an opportunity to userspace to consider connecting to
++ * other matching BSSs which have better or slightly worse RSSI than
++ * the current connected BSS by using an offloaded operation to avoid
++ * unnecessary wakeups.
++ *
++ * @NL80211_ATTR_SCHED_SCAN_RSSI_ADJUST: When present the RSSI level for BSSs in
++ * the specified band is to be adjusted before doing
++ * %NL80211_ATTR_SCHED_SCAN_RELATIVE_RSSI based comparision to figure out
++ * better BSSs. The attribute value is a packed structure
++ * value as specified by &struct nl80211_bss_select_rssi_adjust.
++ *
++ * @NL80211_ATTR_TIMEOUT_REASON: The reason for which an operation timed out.
++ * u32 attribute with an &enum nl80211_timeout_reason value. This is used,
++ * e.g., with %NL80211_CMD_CONNECT event.
++ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_GAIN: Configured antenna gain. Used to reduce
+ * transmit power to stay within regulatory limits. u32, dBi.
-+ *
+ *
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
- * @__NL80211_ATTR_AFTER_LAST: internal use
-@@ -2336,6 +2339,8 @@ enum nl80211_attrs {
+@@ -2195,7 +2263,7 @@ enum nl80211_attrs {
+
+ NL80211_ATTR_CONN_FAILED_REASON,
+
+- NL80211_ATTR_SAE_DATA,
++ NL80211_ATTR_AUTH_DATA,
+
+ NL80211_ATTR_VHT_CAPABILITY,
+
+@@ -2336,6 +2404,20 @@ enum nl80211_attrs {
NL80211_ATTR_NAN_FUNC,
NL80211_ATTR_NAN_MATCH,
++ NL80211_ATTR_FILS_KEK,
++ NL80211_ATTR_FILS_NONCES,
++
++ NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED,
++
++ NL80211_ATTR_BSSID,
++
++ NL80211_ATTR_SCHED_SCAN_RELATIVE_RSSI,
++ NL80211_ATTR_SCHED_SCAN_RSSI_ADJUST,
++
++ NL80211_ATTR_TIMEOUT_REASON,
++
+ NL80211_ATTR_WIPHY_ANTENNA_GAIN,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
+@@ -2347,6 +2429,7 @@ enum nl80211_attrs {
+ #define NL80211_ATTR_SCAN_GENERATION NL80211_ATTR_GENERATION
+ #define NL80211_ATTR_MESH_PARAMS NL80211_ATTR_MESH_CONFIG
+ #define NL80211_ATTR_IFACE_SOCKET_OWNER NL80211_ATTR_SOCKET_OWNER
++#define NL80211_ATTR_SAE_DATA NL80211_ATTR_AUTH_DATA
+
+ /*
+ * Allow user space programs to use #ifdef on new attributes by defining them
+@@ -3027,6 +3110,13 @@ enum nl80211_reg_rule_attr {
+ * how this API was implemented in the past. Also, due to the same problem,
+ * the only way to create a matchset with only an RSSI filter (with this
+ * attribute) is if there's only a single matchset with the RSSI attribute.
++ * @NL80211_SCHED_SCAN_MATCH_ATTR_RELATIVE_RSSI: Flag indicating whether
++ * %NL80211_SCHED_SCAN_MATCH_ATTR_RSSI to be used as absolute RSSI or
++ * relative to current bss's RSSI.
++ * @NL80211_SCHED_SCAN_MATCH_ATTR_RSSI_ADJUST: When present the RSSI level for
++ * BSS-es in the specified band is to be adjusted before doing
++ * RSSI-based BSS selection. The attribute value is a packed structure
++ * value as specified by &struct nl80211_bss_select_rssi_adjust.
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter
+ * attribute number currently defined
+ * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use
+@@ -3036,6 +3126,8 @@ enum nl80211_sched_scan_match_attr {
+
+ NL80211_SCHED_SCAN_MATCH_ATTR_SSID,
+ NL80211_SCHED_SCAN_MATCH_ATTR_RSSI,
++ NL80211_SCHED_SCAN_MATCH_ATTR_RELATIVE_RSSI,
++ NL80211_SCHED_SCAN_MATCH_ATTR_RSSI_ADJUST,
+
+ /* keep last */
+ __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST,
+@@ -3660,6 +3752,9 @@ enum nl80211_bss_status {
+ * @NL80211_AUTHTYPE_FT: Fast BSS Transition (IEEE 802.11r)
+ * @NL80211_AUTHTYPE_NETWORK_EAP: Network EAP (some Cisco APs and mainly LEAP)
+ * @NL80211_AUTHTYPE_SAE: Simultaneous authentication of equals
++ * @NL80211_AUTHTYPE_FILS_SK: Fast Initial Link Setup shared key
++ * @NL80211_AUTHTYPE_FILS_SK_PFS: Fast Initial Link Setup shared key with PFS
++ * @NL80211_AUTHTYPE_FILS_PK: Fast Initial Link Setup public key
+ * @__NL80211_AUTHTYPE_NUM: internal
+ * @NL80211_AUTHTYPE_MAX: maximum valid auth algorithm
+ * @NL80211_AUTHTYPE_AUTOMATIC: determine automatically (if necessary by
+@@ -3672,6 +3767,9 @@ enum nl80211_auth_type {
+ NL80211_AUTHTYPE_FT,
+ NL80211_AUTHTYPE_NETWORK_EAP,
+ NL80211_AUTHTYPE_SAE,
++ NL80211_AUTHTYPE_FILS_SK,
++ NL80211_AUTHTYPE_FILS_SK_PFS,
++ NL80211_AUTHTYPE_FILS_PK,
+
+ /* keep last */
+ __NL80211_AUTHTYPE_NUM,
+@@ -4280,6 +4378,9 @@ enum nl80211_iface_limit_attrs {
+ * of supported channel widths for radar detection.
+ * @NL80211_IFACE_COMB_RADAR_DETECT_REGIONS: u32 attribute containing the bitmap
+ * of supported regulatory regions for radar detection.
++ * @NL80211_IFACE_COMB_BI_MIN_GCD: u32 attribute specifying the minimum GCD of
++ * different beacon intervals supported by all the interface combinations
++ * in this group (if not present, all beacon intervals be identical).
+ * @NUM_NL80211_IFACE_COMB: number of attributes
+ * @MAX_NL80211_IFACE_COMB: highest attribute number
+ *
+@@ -4287,8 +4388,8 @@ enum nl80211_iface_limit_attrs {
+ * limits = [ #{STA} <= 1, #{AP} <= 1 ], matching BI, channels = 1, max = 2
+ * => allows an AP and a STA that must match BIs
+ *
+- * numbers = [ #{AP, P2P-GO} <= 8 ], channels = 1, max = 8
+- * => allows 8 of AP/GO
++ * numbers = [ #{AP, P2P-GO} <= 8 ], BI min gcd, channels = 1, max = 8,
++ * => allows 8 of AP/GO that can have BI gcd >= min gcd
+ *
+ * numbers = [ #{STA} <= 2 ], channels = 2, max = 2
+ * => allows two STAs on different channels
+@@ -4314,6 +4415,7 @@ enum nl80211_if_combination_attrs {
+ NL80211_IFACE_COMB_NUM_CHANNELS,
+ NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
+ NL80211_IFACE_COMB_RADAR_DETECT_REGIONS,
++ NL80211_IFACE_COMB_BI_MIN_GCD,
+
+ /* keep last */
+ NUM_NL80211_IFACE_COMB,
+@@ -4634,6 +4736,15 @@ enum nl80211_feature_flags {
+ * configuration (AP/mesh) with HT rates.
+ * @NL80211_EXT_FEATURE_BEACON_RATE_VHT: Driver supports beacon rate
+ * configuration (AP/mesh) with VHT rates.
++ * @NL80211_EXT_FEATURE_FILS_STA: This driver supports Fast Initial Link Setup
++ * with user space SME (NL80211_CMD_AUTHENTICATE) in station mode.
++ * @NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA: This driver supports randomized TA
++ * in @NL80211_CMD_FRAME while not associated.
++ * @NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED: This driver supports
++ * randomized TA in @NL80211_CMD_FRAME while associated.
++ * @NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI: The driver supports sched_scan
++ * for reporting BSSs with better RSSI than the current connected BSS
++ * (%NL80211_ATTR_SCHED_SCAN_RELATIVE_RSSI).
+ *
+ * @NUM_NL80211_EXT_FEATURES: number of extended features.
+ * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
+@@ -4648,6 +4759,10 @@ enum nl80211_ext_feature_index {
+ NL80211_EXT_FEATURE_BEACON_RATE_LEGACY,
+ NL80211_EXT_FEATURE_BEACON_RATE_HT,
+ NL80211_EXT_FEATURE_BEACON_RATE_VHT,
++ NL80211_EXT_FEATURE_FILS_STA,
++ NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA,
++ NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED,
++ NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI,
+
+ /* add new features before the definition below */
+ NUM_NL80211_EXT_FEATURES,
+@@ -4687,6 +4802,21 @@ enum nl80211_connect_failed_reason {
+ };
+
+ /**
++ * enum nl80211_timeout_reason - timeout reasons
++ *
++ * @NL80211_TIMEOUT_UNSPECIFIED: Timeout reason unspecified.
++ * @NL80211_TIMEOUT_SCAN: Scan (AP discovery) timed out.
++ * @NL80211_TIMEOUT_AUTH: Authentication timed out.
++ * @NL80211_TIMEOUT_ASSOC: Association timed out.
++ */
++enum nl80211_timeout_reason {
++ NL80211_TIMEOUT_UNSPECIFIED,
++ NL80211_TIMEOUT_SCAN,
++ NL80211_TIMEOUT_AUTH,
++ NL80211_TIMEOUT_ASSOC,
++};
++
++/**
+ * enum nl80211_scan_flags - scan request control flags
+ *
+ * Scan request control flags are used to control the handling
+@@ -4900,8 +5030,9 @@ enum nl80211_sched_scan_plan {
+ /**
+ * struct nl80211_bss_select_rssi_adjust - RSSI adjustment parameters.
+ *
+- * @band: band of BSS that must match for RSSI value adjustment.
+- * @delta: value used to adjust the RSSI value of matching BSS.
++ * @band: band of BSS that must match for RSSI value adjustment. The value
++ * of this field is according to &enum nl80211_band.
++ * @delta: value used to adjust the RSSI value of matching BSS in dB.
+ */
+ struct nl80211_bss_select_rssi_adjust {
+ __u8 band;
include $(TOPDIR)/rules.mk
PKG_NAME:=tcpdump
-PKG_VERSION:=4.8.1
+PKG_VERSION:=4.9.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.tcpdump.org/release/ \
http://www.at.tcpdump.org/
-PKG_HASH:=20e4341ec48fcf72abcae312ea913e6ba6b958617b2f3fb496d51f0ae88d831c
+PKG_HASH:=eae98121cbb1c9adbedd9a777bf2eae9fa1c1c676424a54740311c8abcee5a5e
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_PARALLEL:=1
--- a/configure
+++ b/configure
-@@ -6260,97 +6260,6 @@ $as_echo "no" >&6; }
+@@ -6259,97 +6259,6 @@ $as_echo "no" >&6; }
fi
fi
--- a/configure
+++ b/configure
-@@ -5472,37 +5472,6 @@ $as_echo "Using $pfopen" >&6; }
+@@ -5471,37 +5471,6 @@ $as_echo "Using $pfopen" >&6; }
LIBS="$LIBS $pfopen"
fi
fi
#
# Look for pcap-config.
-@@ -5658,51 +5627,6 @@ if test "x$ac_cv_lib_pcap_main" = xyes;
+@@ -5657,51 +5626,6 @@ if test "x$ac_cv_lib_pcap_main" = xyes;
libpcap="-lpcap"
fi
+
+CSRC=\
+ tcpdump.c \
-+ util.c \
++ netdissect.c \
+ setsignal.c \
+ addrtoname.c \
+ addrtostr.c \
+
+else
+
- CSRC = setsignal.c tcpdump.c util.c
+ CSRC = setsignal.c tcpdump.c
LIBNETDISSECT_SRC=\
-@@ -236,12 +312,16 @@ LIBNETDISSECT_SRC=\
+@@ -237,12 +313,16 @@ LIBNETDISSECT_SRC=\
strtoaddr.c \
util-print.c
SRC = $(CSRC) $(GENSRC) $(LOCALSRC) $(LIBNETDISSECT_SRC)
-@@ -367,10 +447,12 @@ $(PROG): $(OBJ) @V_PCAPDEP@
+@@ -373,10 +453,12 @@ $(PROG): $(OBJ) @V_PCAPDEP@
@rm -f $@
$(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c
--- a/addrtoname.c
+++ b/addrtoname.c
-@@ -564,8 +564,10 @@ linkaddr_string(netdissect_options *ndo,
+@@ -566,8 +566,10 @@ linkaddr_string(netdissect_options *ndo,
if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN)
return (etheraddr_string(ndo, ep));
tp = lookup_bytestring(ndo, ep, len);
if (tp->e_name)
-@@ -1200,6 +1202,7 @@ init_addrtoname(netdissect_options *ndo,
+@@ -1202,6 +1204,7 @@ init_addrtoname(netdissect_options *ndo,
init_ipxsaparray(ndo);
}
const char *
dnaddr_string(netdissect_options *ndo, u_short dnaddr)
{
-@@ -1219,6 +1222,7 @@ dnaddr_string(netdissect_options *ndo, u
+@@ -1221,6 +1224,7 @@ dnaddr_string(netdissect_options *ndo, u
return(tp->name);
}
--- a/print-ether.c
+++ b/print-ether.c
-@@ -332,6 +332,7 @@ ethertype_print(netdissect_options *ndo,
+@@ -342,6 +342,7 @@ ethertype_print(netdissect_options *ndo,
arp_print(ndo, p, length, caplen);
return (1);
case ETHERTYPE_DN:
decnet_print(ndo, p, length, caplen);
return (1);
-@@ -354,6 +355,7 @@ ethertype_print(netdissect_options *ndo,
- case ETHERTYPE_ISO:
- isoclns_print(ndo, p + 1, length - 1, length - 1);
+@@ -368,6 +369,7 @@ ethertype_print(netdissect_options *ndo,
+ }
+ isoclns_print(ndo, p + 1, length - 1, caplen - 1);
return(1);
+#endif
case ETHERTYPE_PPPOED:
case ETHERTYPE_PPPOES:
-@@ -366,9 +368,11 @@ ethertype_print(netdissect_options *ndo,
+@@ -380,9 +382,11 @@ ethertype_print(netdissect_options *ndo,
eap_print(ndo, p, length);
return (1);
+#ifndef TCPDUMP_MINI
case ETHERTYPE_RRCP:
- rrcp_print(ndo, p - 14 , length + 14);
+ rrcp_print(ndo, p, length, src, dst);
return (1);
+#endif
case ETHERTYPE_PPP:
if (length) {
-@@ -377,6 +381,7 @@ ethertype_print(netdissect_options *ndo,
+@@ -391,6 +395,7 @@ ethertype_print(netdissect_options *ndo,
}
return (1);
case ETHERTYPE_MPCP:
mpcp_print(ndo, p, length);
return (1);
-@@ -389,6 +394,7 @@ ethertype_print(netdissect_options *ndo,
+@@ -403,6 +408,7 @@ ethertype_print(netdissect_options *ndo,
case ETHERTYPE_CFM_OLD:
cfm_print(ndo, p, length);
return (1);
case ETHERTYPE_LLDP:
lldp_print(ndo, p, length);
-@@ -398,6 +404,7 @@ ethertype_print(netdissect_options *ndo,
+@@ -412,6 +418,7 @@ ethertype_print(netdissect_options *ndo,
loopback_print(ndo, p, length);
return (1);
case ETHERTYPE_MPLS:
case ETHERTYPE_MPLS_MULTI:
mpls_print(ndo, p, length);
-@@ -427,6 +434,7 @@ ethertype_print(netdissect_options *ndo,
+@@ -441,6 +448,7 @@ ethertype_print(netdissect_options *ndo,
case ETHERTYPE_MEDSA:
- medsa_print(ndo, p, length, caplen);
+ medsa_print(ndo, p, length, caplen, src, dst);
return (1);
+#endif
case ETHERTYPE_SCA:
--- a/print-gre.c
+++ b/print-gre.c
-@@ -203,6 +203,7 @@ gre_print_0(netdissect_options *ndo, con
+@@ -216,6 +216,7 @@ gre_print_0(netdissect_options *ndo, con
case ETHERTYPE_IPV6:
ip6_print(ndo, bp, len);
break;
case ETHERTYPE_MPLS:
mpls_print(ndo, bp, len);
break;
-@@ -218,6 +219,7 @@ gre_print_0(netdissect_options *ndo, con
+@@ -231,6 +232,7 @@ gre_print_0(netdissect_options *ndo, con
case ETHERTYPE_TEB:
- ether_print(ndo, bp, len, len, NULL, NULL);
+ ether_print(ndo, bp, len, ndo->ndo_snapend - bp, NULL, NULL);
break;
+#endif
default:
}
--- a/print-igmp.c
+++ b/print-igmp.c
-@@ -304,6 +304,7 @@ igmp_print(netdissect_options *ndo,
+@@ -306,6 +306,7 @@ igmp_print(netdissect_options *ndo,
ND_TCHECK2(bp[4], 4);
ND_PRINT((ndo, "igmp leave %s", ipaddr_string(ndo, &bp[4])));
break;
case 0x13:
ND_PRINT((ndo, "igmp dvmrp"));
if (len < 8)
-@@ -315,6 +316,7 @@ igmp_print(netdissect_options *ndo,
+@@ -317,6 +318,7 @@ igmp_print(netdissect_options *ndo,
ND_PRINT((ndo, "igmp pimv1"));
pimv1_print(ndo, bp, len);
break;
break;
--- a/print-ip6.c
+++ b/print-ip6.c
-@@ -297,6 +297,7 @@ ip6_print(netdissect_options *ndo, const
- advance = dstopt_print(ndo, cp);
+@@ -303,6 +303,7 @@ ip6_print(netdissect_options *ndo, const
+ return;
nh = *cp;
break;
+#ifndef TCPDUMP_MINI
case IPPROTO_FRAGMENT:
advance = frag6_print(ndo, cp, (const u_char *)ip6);
- if (ndo->ndo_snapend <= cp + advance)
-@@ -318,16 +319,19 @@ ip6_print(netdissect_options *ndo, const
+ if (advance < 0 || ndo->ndo_snapend <= cp + advance)
+@@ -324,16 +325,19 @@ ip6_print(netdissect_options *ndo, const
advance = mobility_print(ndo, cp, (const u_char *)ip6);
nh = *cp;
return;
case IPPROTO_TCP:
tcp_print(ndo, cp, len, (const u_char *)ip6, fragmented);
return;
-@@ -337,6 +341,7 @@ ip6_print(netdissect_options *ndo, const
+@@ -343,6 +347,7 @@ ip6_print(netdissect_options *ndo, const
case IPPROTO_ICMPV6:
icmp6_print(ndo, cp, len, (const u_char *)ip6, fragmented);
return;
case IPPROTO_AH:
advance = ah_print(ndo, cp);
nh = *cp;
-@@ -360,6 +365,7 @@ ip6_print(netdissect_options *ndo, const
+@@ -371,6 +376,7 @@ ip6_print(netdissect_options *ndo, const
case IPPROTO_PIM:
pim_print(ndo, cp, len, (const u_char *)ip6);
return;
case IPPROTO_OSPF:
ospf6_print(ndo, cp, len);
-@@ -373,9 +379,11 @@ ip6_print(netdissect_options *ndo, const
+@@ -384,9 +390,11 @@ ip6_print(netdissect_options *ndo, const
ip_print(ndo, cp, len);
return;
gre_print(ndo, cp, len);
--- a/print-ip.c
+++ b/print-ip.c
-@@ -327,6 +327,7 @@ ip_print_demux(netdissect_options *ndo,
+@@ -329,6 +329,7 @@ ip_print_demux(netdissect_options *ndo,
again:
switch (ipds->nh) {
+#ifndef TCPDUMP_MINI
case IPPROTO_AH:
- ipds->nh = *ipds->cp;
- ipds->advance = ah_print(ndo, ipds->cp);
-@@ -361,7 +362,9 @@ again:
- ipds->nh = enh & 0xff;
- goto again;
+ if (!ND_TTEST(*ipds->cp)) {
+ ND_PRINT((ndo, "[|AH]"));
+@@ -367,7 +368,9 @@ again:
+ */
+ break;
}
+#endif
case IPPROTO_SCTP:
sctp_print(ndo, ipds->cp, (const u_char *)ipds->ip, ipds->len);
break;
-@@ -369,6 +372,7 @@ again:
+@@ -375,6 +378,7 @@ again:
case IPPROTO_DCCP:
dccp_print(ndo, ipds->cp, (const u_char *)ipds->ip, ipds->len);
break;
case IPPROTO_TCP:
/* pass on the MF bit plus the offset to detect fragments */
-@@ -388,6 +392,7 @@ again:
+@@ -394,6 +398,7 @@ again:
ipds->off & (IP_MF|IP_OFFMASK));
break;
case IPPROTO_PIGP:
/*
* XXX - the current IANA protocol number assignments
-@@ -408,14 +413,17 @@ again:
+@@ -414,14 +419,17 @@ again:
case IPPROTO_EIGRP:
eigrp_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_OSPF:
ospf_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
-@@ -448,6 +456,7 @@ again:
+@@ -454,6 +462,7 @@ again:
gre_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_MOBILE:
mobile_print(ndo, ipds->cp, ipds->len);
break;
-@@ -476,6 +485,7 @@ again:
+@@ -482,6 +491,7 @@ again:
case IPPROTO_PGM:
pgm_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
break;
if (ndo->ndo_nflag==0 && (proto = getprotobynumber(ipds->nh)) != NULL)
--- a/print-llc.c
+++ b/print-llc.c
-@@ -204,6 +204,7 @@ llc_print(netdissect_options *ndo, const
+@@ -206,6 +206,7 @@ llc_print(netdissect_options *ndo, const
hdrlen = 4; /* DSAP, SSAP, 2-byte control field */
}
if (ssap_field == LLCSAP_GLOBAL && dsap_field == LLCSAP_GLOBAL) {
/*
* This is an Ethernet_802.3 IPX frame; it has an
-@@ -226,6 +227,7 @@ llc_print(netdissect_options *ndo, const
+@@ -228,6 +229,7 @@ llc_print(netdissect_options *ndo, const
ipx_print(ndo, p, length);
return (0); /* no LLC header */
}
dsap = dsap_field & ~LLC_IG;
ssap = ssap_field & ~LLC_GSAP;
-@@ -289,6 +291,7 @@ llc_print(netdissect_options *ndo, const
+@@ -291,6 +293,7 @@ llc_print(netdissect_options *ndo, const
return (hdrlen);
}
if (ssap == LLCSAP_IPX && dsap == LLCSAP_IPX &&
control == LLC_UI) {
/*
-@@ -302,6 +305,7 @@ llc_print(netdissect_options *ndo, const
+@@ -304,6 +307,7 @@ llc_print(netdissect_options *ndo, const
ipx_print(ndo, p, length);
return (hdrlen);
}
#ifdef ENABLE_SMB
if (ssap == LLCSAP_NETBEUI && dsap == LLCSAP_NETBEUI
-@@ -320,11 +324,13 @@ llc_print(netdissect_options *ndo, const
+@@ -322,11 +326,13 @@ llc_print(netdissect_options *ndo, const
return (hdrlen);
}
#endif
if (!ndo->ndo_eflag) {
if (ssap == dsap) {
-@@ -458,6 +464,7 @@ snap_print(netdissect_options *ndo, cons
+@@ -480,6 +486,7 @@ snap_print(netdissect_options *ndo, cons
case OUI_CISCO:
switch (et) {
case PID_CISCO_CDP:
cdp_print(ndo, p, length, caplen);
return (1);
-@@ -470,6 +477,7 @@ snap_print(netdissect_options *ndo, cons
+@@ -492,6 +499,7 @@ snap_print(netdissect_options *ndo, cons
case PID_CISCO_VTP:
vtp_print(ndo, p, length);
return (1);
case PID_CISCO_PVST:
case PID_CISCO_VLANBRIDGE:
stp_print(ndo, p, length);
-@@ -482,6 +490,7 @@ snap_print(netdissect_options *ndo, cons
+@@ -504,6 +512,7 @@ snap_print(netdissect_options *ndo, cons
case OUI_RFC2684:
switch (et) {
case PID_RFC2684_ETH_FCS:
case PID_RFC2684_ETH_NOFCS:
/*
-@@ -543,6 +552,7 @@ snap_print(netdissect_options *ndo, cons
+@@ -565,6 +574,7 @@ snap_print(netdissect_options *ndo, cons
*/
fddi_print(ndo, p, length, caplen);
return (1);
stp_print(ndo, p, length);
--- a/print-null.c
+++ b/print-null.c
-@@ -114,6 +114,7 @@ null_if_print(netdissect_options *ndo, c
+@@ -116,6 +116,7 @@ null_if_print(netdissect_options *ndo, c
ip6_print(ndo, p, length);
break;
case BSD_AFNUM_ISO:
isoclns_print(ndo, p, length, caplen);
break;
-@@ -125,6 +126,7 @@ null_if_print(netdissect_options *ndo, c
+@@ -127,6 +128,7 @@ null_if_print(netdissect_options *ndo, c
case BSD_AFNUM_IPX:
ipx_print(ndo, p, length);
break;
/* unknown AF_ value */
--- a/print-ppp.c
+++ b/print-ppp.c
-@@ -1346,6 +1346,7 @@ trunc:
+@@ -1358,6 +1358,7 @@ trunc:
return 0;
}
static void
ppp_hdlc(netdissect_options *ndo,
const u_char *p, int length)
-@@ -1424,6 +1425,7 @@ trunc:
+@@ -1436,6 +1437,7 @@ trunc:
free(b);
ND_PRINT((ndo, "[|ppp]"));
}
/* PPP */
-@@ -1431,10 +1433,12 @@ static void
+@@ -1443,10 +1445,12 @@ static void
handle_ppp(netdissect_options *ndo,
u_int proto, const u_char *p, int length)
{
switch (proto) {
case PPP_LCP: /* fall through */
-@@ -1467,6 +1471,7 @@ handle_ppp(netdissect_options *ndo,
+@@ -1479,6 +1483,7 @@ handle_ppp(netdissect_options *ndo,
case PPP_IPV6:
ip6_print(ndo, p, length);
break;
case ETHERTYPE_IPX: /*XXX*/
case PPP_IPX:
ipx_print(ndo, p, length);
-@@ -1478,6 +1483,7 @@ handle_ppp(netdissect_options *ndo,
+@@ -1490,6 +1495,7 @@ handle_ppp(netdissect_options *ndo,
case PPP_MPLS_MCAST:
mpls_print(ndo, p, length);
break;
case PPP_COMP:
ND_PRINT((ndo, "compressed PPP data"));
break;
-@@ -1618,6 +1624,7 @@ ppp_if_print(netdissect_options *ndo,
+@@ -1630,6 +1636,7 @@ ppp_if_print(netdissect_options *ndo,
return (0);
}
/*
* PPP I/F printer to use if we know that RFC 1662-style PPP in HDLC-like
* framing, or Cisco PPP with HDLC framing as per section 4.3.1 of RFC 1547,
-@@ -1840,6 +1847,7 @@ printx:
+@@ -1857,6 +1864,7 @@ printx:
#endif /* __bsdi__ */
return (hdrlength);
}
/*
--- a/print-sll.c
+++ b/print-sll.c
-@@ -236,12 +236,14 @@ recurse:
+@@ -238,12 +238,14 @@ recurse:
*/
switch (ether_type) {
/*
--- a/print-tcp.c
+++ b/print-tcp.c
-@@ -565,12 +565,14 @@ tcp_print(netdissect_options *ndo,
+@@ -589,12 +589,14 @@ tcp_print(netdissect_options *ndo,
ND_PRINT((ndo, " %u", utoval));
break;
case TCPOPT_FASTOPEN:
datalen = len - 2;
-@@ -645,6 +647,7 @@ tcp_print(netdissect_options *ndo,
+@@ -670,6 +672,7 @@ tcp_print(netdissect_options *ndo,
return;
}
if (ndo->ndo_packettype) {
switch (ndo->ndo_packettype) {
case PT_ZMTP1:
-@@ -656,28 +659,36 @@ tcp_print(netdissect_options *ndo,
+@@ -681,28 +684,36 @@ tcp_print(netdissect_options *ndo,
}
return;
}
else if (IS_SRC_OR_DST_PORT(FTP_PORT)) {
ND_PRINT((ndo, ": "));
ftp_print(ndo, bp, length);
-@@ -694,6 +705,7 @@ tcp_print(netdissect_options *ndo,
+@@ -719,6 +730,7 @@ tcp_print(netdissect_options *ndo,
* XXX packet could be unaligned, it can go strange
*/
ns_print(ndo, bp + 2, length - 2, 0);
} else if (IS_SRC_OR_DST_PORT(MSDP_PORT)) {
msdp_print(ndo, bp, length);
} else if (IS_SRC_OR_DST_PORT(RPKI_RTR_PORT)) {
-@@ -701,6 +713,7 @@ tcp_print(netdissect_options *ndo,
+@@ -726,6 +738,7 @@ tcp_print(netdissect_options *ndo,
}
else if (length > 0 && (IS_SRC_OR_DST_PORT(LDP_PORT))) {
ldp_print(ndo, bp, length);
length >= 4 && ND_TTEST2(*bp, 4)) {
--- a/print-udp.c
+++ b/print-udp.c
-@@ -397,10 +397,12 @@ udp_print(netdissect_options *ndo, regis
+@@ -430,10 +430,12 @@ udp_print(netdissect_options *ndo, regis
vat_print(ndo, (const void *)(up + 1), up);
break;
case PT_RPC:
rp = (const struct sunrpc_msg *)(up + 1);
-@@ -429,10 +431,12 @@ udp_print(netdissect_options *ndo, regis
+@@ -462,10 +464,12 @@ udp_print(netdissect_options *ndo, regis
snmp_print(ndo, (const u_char *)(up + 1), length);
break;
case PT_TFTP:
udpipaddr_print(ndo, ip, sport, dport);
-@@ -450,6 +454,7 @@ udp_print(netdissect_options *ndo, regis
+@@ -483,6 +487,7 @@ udp_print(netdissect_options *ndo, regis
radius_print(ndo, cp, length);
break;
case PT_VXLAN:
udpipaddr_print(ndo, ip, sport, dport);
vxlan_print(ndo, (const u_char *)(up + 1), length);
-@@ -464,6 +469,7 @@ udp_print(netdissect_options *ndo, regis
+@@ -497,6 +502,7 @@ udp_print(netdissect_options *ndo, regis
udpipaddr_print(ndo, ip, sport, dport);
lmp_print(ndo, cp, length);
break;
}
return;
}
-@@ -541,31 +547,40 @@ udp_print(netdissect_options *ndo, regis
+@@ -574,31 +580,40 @@ udp_print(netdissect_options *ndo, regis
ns_print(ndo, (const u_char *)(up + 1), length, 0);
else if (IS_SRC_OR_DST_PORT(MULTICASTDNS_PORT))
ns_print(ndo, (const u_char *)(up + 1), length, 1);
else if (IS_SRC_OR_DST_PORT(L2TP_PORT))
l2tp_print(ndo, (const u_char *)(up + 1), length);
#ifdef ENABLE_SMB
-@@ -576,6 +591,7 @@ udp_print(netdissect_options *ndo, regis
+@@ -609,6 +624,7 @@ udp_print(netdissect_options *ndo, regis
#endif
else if (dport == VAT_PORT)
vat_print(ndo, (const void *)(up + 1), up);
else if (IS_SRC_OR_DST_PORT(ZEPHYR_SRV_PORT) || IS_SRC_OR_DST_PORT(ZEPHYR_CLT_PORT))
zephyr_print(ndo, (const void *)(up + 1), length);
/*
-@@ -588,8 +604,11 @@ udp_print(netdissect_options *ndo, regis
+@@ -621,8 +637,11 @@ udp_print(netdissect_options *ndo, regis
(const u_char *) ip);
else if (IS_SRC_OR_DST_PORT(RIPNG_PORT))
ripng_print(ndo, (const u_char *)(up + 1), length);
else if (IS_SRC_OR_DST_PORT(AHCP_PORT))
ahcp_print(ndo, (const u_char *)(up + 1), length);
else if (IS_SRC_OR_DST_PORT(BABEL_PORT) || IS_SRC_OR_DST_PORT(BABEL_PORT_OLD))
-@@ -603,6 +622,7 @@ udp_print(netdissect_options *ndo, regis
+@@ -636,6 +655,7 @@ udp_print(netdissect_options *ndo, regis
wb_print(ndo, (const void *)(up + 1), length);
else if (IS_SRC_OR_DST_PORT(CISCO_AUTORP_PORT))
cisco_autorp_print(ndo, (const void *)(up + 1), length);
else if (IS_SRC_OR_DST_PORT(RADIUS_PORT) ||
IS_SRC_OR_DST_PORT(RADIUS_NEW_PORT) ||
IS_SRC_OR_DST_PORT(RADIUS_ACCOUNTING_PORT) ||
-@@ -610,15 +630,18 @@ udp_print(netdissect_options *ndo, regis
+@@ -643,15 +663,18 @@ udp_print(netdissect_options *ndo, regis
IS_SRC_OR_DST_PORT(RADIUS_CISCO_COA_PORT) ||
IS_SRC_OR_DST_PORT(RADIUS_COA_PORT) )
radius_print(ndo, (const u_char *)(up+1), length);
else if (IS_SRC_OR_DST_PORT(MPLS_LSP_PING_PORT))
lspping_print(ndo, (const u_char *)(up + 1), length);
else if (dport == BFD_CONTROL_PORT ||
-@@ -636,10 +659,12 @@ udp_print(netdissect_options *ndo, regis
+@@ -669,10 +692,12 @@ udp_print(netdissect_options *ndo, regis
lwapp_control_print(ndo, (const u_char *)(up + 1), length, 0);
else if (IS_SRC_OR_DST_PORT(LWAPP_DATA_PORT))
lwapp_data_print(ndo, (const u_char *)(up + 1), length);
else if (IS_SRC_OR_DST_PORT(OTV_PORT))
otv_print(ndo, (const u_char *)(up + 1), length);
else if (IS_SRC_OR_DST_PORT(VXLAN_PORT))
-@@ -656,7 +681,9 @@ udp_print(netdissect_options *ndo, regis
+@@ -689,7 +714,9 @@ udp_print(netdissect_options *ndo, regis
if (ndo->ndo_vflag)
ND_PRINT((ndo, "kip "));
llap_print(ndo, cp, length);
PKG_BUILD_PARALLEL:=1
+PKG_FLAGS:=nonshared
+
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
PKG_BUILD_PARALLEL:=1
+PKG_FLAGS:=nonshared
+
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
PKG_RELEASE:=5
PKG_SOURCE:=wireless_tools.$(PKG_VERSION)$(PKG_MINOR).tar.gz
-PKG_SOURCE_URL:=http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux
+PKG_SOURCE_URL:=https://hewlettpackard.github.io/wireless-tools
PKG_HASH:=6fb80935fe208538131ce2c4178221bab1078a1656306bce8909c19887e2e5a1
TAR_OPTIONS += || true
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(LEDE_GIT)/keyring.git
-PKG_SOURCE_DATE:=2016-04-30
-PKG_SOURCE_VERSION:=5c7857eed3fa06a9005f96b9b029388c7f316e83
-PKG_MIRROR_HASH:=6119196dad6c92df22617c5f4a923728a657b591c6a6901dda21acadc63da51d
+PKG_SOURCE_DATE:=2017-01-20
+PKG_SOURCE_VERSION:=a50b7529880988ca96e72dede0279ff139a8ab1a
+PKG_MIRROR_HASH:=811ba79ba71925e949d2c690db7d7b031ac1dd965aa831ca9b6d9d70f5657254
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
PKG_LICENSE:=GPL-2.0
SECTION:=utils
CATEGORY:=Utilities
TITLE:=OpenWrt automount daemon
- DEPENDS:=@USB_SUPPORT +uci +kmod-usb-storage +kmod-fs-autofs4
+ DEPENDS:=+uci +kmod-fs-autofs4
URL:=http://www.openwrt.org
endef
include $(INCLUDE_DIR)/feeds.mk
PKG_NAME:=opkg
-PKG_RELEASE:=16
+PKG_RELEASE:=17
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=http://git.yoctoproject.org/git/opkg
PKG_SOURCE_DATE:=2011-04-08
PKG_SOURCE_VERSION:=9c97d5ecd795709c8584e972bfdf3aee3a5b846d
PKG_MIRROR_HASH:=55e05270f3eb2f3aff5d3791463ce3d13b8197ca7b301cd58e731a249552c48f
-PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
PKG_FIXUP:=autoreconf
PKG_REMOVE_FILES = autogen.sh aclocal.m4
--- /dev/null
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -85,6 +85,7 @@ opkg_update_cmd(int argc, char **argv)
+ char *tmp;
+ int err;
+ int failures;
++ int pkglist_dl_error;
+ char *lists_dir;
+ pkg_src_list_elt_t *iter;
+ pkg_src_t *src;
+@@ -130,15 +131,19 @@ opkg_update_cmd(int argc, char **argv)
+ sprintf_alloc(&url, "%s/%s", src->value, src->gzip ? "Packages.gz" : "Packages");
+
+ sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
++ pkglist_dl_error = 0;
+ if (opkg_download(url, list_file_name, NULL, NULL, 0)) {
+ failures++;
++ pkglist_dl_error = 1;
++ opkg_msg(NOTICE, "*** Failed to download the package list from %s\n\n",
++ url);
+ } else {
+- opkg_msg(NOTICE, "Updated list of available packages in %s.\n",
++ opkg_msg(NOTICE, "Updated list of available packages in %s\n",
+ list_file_name);
+ }
+ free(url);
+ #if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN)
+- if (conf->check_signature) {
++ if (pkglist_dl_error == 0 && conf->check_signature) {
+ /* download detached signitures to verify the package lists */
+ /* get the url for the sig file */
+ if (src->extra_data) /* debian style? */
+@@ -156,7 +161,7 @@ opkg_update_cmd(int argc, char **argv)
+ err = opkg_download(url, tmp_file_name, NULL, NULL, 0);
+ if (err) {
+ failures++;
+- opkg_msg(NOTICE, "Signature check failed.\n");
++ opkg_msg(NOTICE, "Signature file download failed.\n");
+ } else {
+ err = opkg_verify_file (list_file_name, tmp_file_name);
+ if (err == 0)
+--- a/libopkg/opkg_download.c
++++ b/libopkg/opkg_download.c
+@@ -91,7 +91,7 @@ opkg_download(const char *src, const cha
+ char *src_base = basename(src_basec);
+ char *tmp_file_location;
+
+- opkg_msg(NOTICE,"Downloading %s.\n", src);
++ opkg_msg(NOTICE,"Downloading %s\n", src);
+
+ if (str_starts_with(src, "file:")) {
+ const char *file_src = src + 5;
+@@ -175,6 +175,8 @@ opkg_download(const char *src, const cha
+
+ if (res) {
+ opkg_msg(ERROR, "Failed to download %s, wget returned %d.\n", src, res);
++ if (res == 4)
++ opkg_msg(ERROR, "Check your network settings and connectivity.\n\n");
+ free(tmp_file_location);
+ return -1;
+ }
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(LEDE_GIT)/project/procd.git
-PKG_SOURCE_DATE:=2017-01-10
-PKG_SOURCE_VERSION:=f7069032290a9720142b2ee2c6315d7e1f1a1bd3
-PKG_MIRROR_HASH:=3917269c1ed1f9b6d4a8f5559b2cdec6f91da3ad00ffe5375b5680f9e230b21d
+PKG_SOURCE_DATE:=2017-02-15
+PKG_SOURCE_VERSION:=5f9124103410c178d816bb5229fba7dd2286a49b
+PKG_MIRROR_HASH:=ec887b349fc60ad3882fc9eaefb5cd299d64e7d43c062df9f7b7500591ba3e85
CMAKE_INSTALL:=1
PKG_LICENSE:=GPL-2.0
json_add_string "" "$@"
json_close_array
;;
- nice|reload_signal)
+ nice)
json_add_int "$type" "$1"
;;
+ reload_signal)
+ json_add_int "$type" $(kill -l "$1")
+ ;;
pidfile|user|seccomp|capabilities)
json_add_string "$type" "$1"
;;
json_close_array
json_close_array
- json_close_array
-
_procd_add_timeout
+ json_close_array
}
_procd_add_reload_interface_trigger() {
json_close_array
json_close_array
-
- json_close_array
-
_procd_add_timeout
+ json_close_array
}
_procd_add_raw_trigger() {
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(LEDE_GIT)/project/ubox.git
-PKG_SOURCE_DATE:=2016-09-26
+PKG_SOURCE_DATE:=2017-01-15
PKG_SOURCE_VERSION:=5649c028c426060616e2bd4e7ea83271cd333d21
PKG_MIRROR_HASH:=ae77504a4397f92173a7646fa3555e5b51abd7ff1dd1c419770223359e41937a
CMAKE_INSTALL:=1
TITLE:=OpenWrt system helper toolbox
endef
+define Package/logd
+SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=+libubox +libubus +libblobmsg-json +USE_GLIBC:librt
+ TITLE:=OpenWrt system log implementation
+endef
+
define Package/ubox/install
- $(INSTALL_DIR) $(1)/sbin $(1)/usr/sbin $(1)/lib $(1)/usr/bin $(1)/etc/init.d
+ $(INSTALL_DIR) $(1)/sbin $(1)/usr/sbin $(1)/lib $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{kmodloader,validate_data} $(1)/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/getrandom $(1)/usr/bin/
$(LN) ../../sbin/kmodloader $(1)/usr/sbin/lsmod
$(LN) ../../sbin/kmodloader $(1)/usr/sbin/modinfo
$(LN) ../../sbin/kmodloader $(1)/usr/sbin/modprobe
+endef
+
+define Package/logd/install
+ $(INSTALL_DIR) $(1)/sbin $(1)/etc/init.d/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{logd,logread} $(1)/sbin/
$(INSTALL_BIN) ./files/log.init $(1)/etc/init.d/log
endef
$(eval $(call BuildPackage,ubox))
+$(eval $(call BuildPackage,logd))
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(LEDE_GIT)/project/ubus.git
-PKG_SOURCE_DATE:=2016-10-12
-PKG_SOURCE_VERSION:=312448a5b147c221836827a7a641e76a4514db44
-PKG_MIRROR_HASH:=adeeae238deaac2b6af77c2e4473febdcbc0f1c256734b2ff019c76b2f3f2aa6
+PKG_SOURCE_DATE:=2017-02-18
+PKG_SOURCE_VERSION:=34c6e818e431cc53478a0f7c7c1eca07d194d692
+PKG_MIRROR_HASH:=fc4f1121faa4f5b8fa52ee25460b98b2e60e7d245aefa70e7f76c56ce5628fd5
CMAKE_INSTALL:=1
PKG_LICENSE:=LGPL-2.1
bugcheck_generic()
{
- echo "LEDE crashlog report" > $CRASHDIR/info.txt
+ echo "libreCMC crashlog report" > $CRASHDIR/info.txt
date >> $CRASHDIR/info.txt
echo >> $CRASHDIR/info.txt
echo "uname" >> $CRASHDIR/info.txt
PKG_NAME:=osafeloader
PKG_RELEASE:=1
+PKG_FLAGS:=nonshared
+
include $(INCLUDE_DIR)/package.mk
define Package/osafeloader
+++ /dev/null
-#
-# Copyright (C) 2010-2014 Jo-Philipp Wich <xm@subsignal.org>
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=px5g-standalone
-PKG_RELEASE:=2
-
-PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/px5g-standalone
- SECTION:=utils
- CATEGORY:=Utilities
- SUBMENU:=Encryption
- TITLE:=X.509 certificate generator (standalone version)
- MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
- PROVIDES:=px5g
-endef
-
-define Package/px5g-standalone/description
- Px5g is a tiny standalone X.509 certificate generator.
- It suitable to create key files and certificates in DER
- and PEM format for use with stunnel, uhttpd and others.
-endef
-
-define Package/px5g-standalone/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/px5g $(1)/usr/sbin/px5g
-endef
-
-$(eval $(call BuildPackage,px5g-standalone))
+++ /dev/null
-CFLAGS?=-O2
-CFLAGS+=
-SFLAGS:=--std=gnu99
-WFLAGS:=-Wall -Werror -pedantic
-LDFLAGS?=
-BINARY:=px5g
-
-all: $(BINARY)
-
-$(BINARY): *.c library/*.c
- $(CC) -I. $(CFLAGS) $(SFLAGS) $(WFLAGS) $(LDFLAGS) -o $@ $+
-
-clean:
- rm -f $(BINARY)
+++ /dev/null
-/*
- * RFC 1521 base64 encoding/decoding
- *
- * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
- *
- * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of PolarSSL or XySSL nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "polarssl/config.h"
-
-#if defined(POLARSSL_BASE64_C)
-
-#include "polarssl/base64.h"
-
-static const unsigned char base64_enc_map[64] =
-{
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
- 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
- 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
- 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
- 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
- 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', '+', '/'
-};
-
-static const unsigned char base64_dec_map[128] =
-{
- 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 62, 127, 127, 127, 63, 52, 53,
- 54, 55, 56, 57, 58, 59, 60, 61, 127, 127,
- 127, 64, 127, 127, 127, 0, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 127, 127, 127, 127, 127, 127, 26, 27, 28,
- 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 127, 127, 127, 127, 127
-};
-
-/*
- * Encode a buffer into base64 format
- */
-int base64_encode( unsigned char *dst, int *dlen,
- unsigned char *src, int slen )
-{
- int i, n;
- int C1, C2, C3;
- unsigned char *p;
-
- if( slen == 0 )
- return( 0 );
-
- n = (slen << 3) / 6;
-
- switch( (slen << 3) - (n * 6) )
- {
- case 2: n += 3; break;
- case 4: n += 2; break;
- default: break;
- }
-
- if( *dlen < n + 1 )
- {
- *dlen = n + 1;
- return( POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL );
- }
-
- n = (slen / 3) * 3;
-
- for( i = 0, p = dst; i < n; i += 3 )
- {
- C1 = *src++;
- C2 = *src++;
- C3 = *src++;
-
- *p++ = base64_enc_map[(C1 >> 2) & 0x3F];
- *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F];
- *p++ = base64_enc_map[(((C2 & 15) << 2) + (C3 >> 6)) & 0x3F];
- *p++ = base64_enc_map[C3 & 0x3F];
- }
-
- if( i < slen )
- {
- C1 = *src++;
- C2 = ((i + 1) < slen) ? *src++ : 0;
-
- *p++ = base64_enc_map[(C1 >> 2) & 0x3F];
- *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F];
-
- if( (i + 1) < slen )
- *p++ = base64_enc_map[((C2 & 15) << 2) & 0x3F];
- else *p++ = '=';
-
- *p++ = '=';
- }
-
- *dlen = p - dst;
- *p = 0;
-
- return( 0 );
-}
-
-/*
- * Decode a base64-formatted buffer
- */
-int base64_decode( unsigned char *dst, int *dlen,
- unsigned char *src, int slen )
-{
- int i, j, n;
- unsigned long x;
- unsigned char *p;
-
- for( i = j = n = 0; i < slen; i++ )
- {
- if( ( slen - i ) >= 2 &&
- src[i] == '\r' && src[i + 1] == '\n' )
- continue;
-
- if( src[i] == '\n' )
- continue;
-
- if( src[i] == '=' && ++j > 2 )
- return( POLARSSL_ERR_BASE64_INVALID_CHARACTER );
-
- if( src[i] > 127 || base64_dec_map[src[i]] == 127 )
- return( POLARSSL_ERR_BASE64_INVALID_CHARACTER );
-
- if( base64_dec_map[src[i]] < 64 && j != 0 )
- return( POLARSSL_ERR_BASE64_INVALID_CHARACTER );
-
- n++;
- }
-
- if( n == 0 )
- return( 0 );
-
- n = ((n * 6) + 7) >> 3;
-
- if( *dlen < n )
- {
- *dlen = n;
- return( POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL );
- }
-
- for( j = 3, n = x = 0, p = dst; i > 0; i--, src++ )
- {
- if( *src == '\r' || *src == '\n' )
- continue;
-
- j -= ( base64_dec_map[*src] == 64 );
- x = (x << 6) | ( base64_dec_map[*src] & 0x3F );
-
- if( ++n == 4 )
- {
- n = 0;
- if( j > 0 ) *p++ = (unsigned char)( x >> 16 );
- if( j > 1 ) *p++ = (unsigned char)( x >> 8 );
- if( j > 2 ) *p++ = (unsigned char)( x );
- }
- }
-
- *dlen = p - dst;
-
- return( 0 );
-}
-
-#if defined(POLARSSL_SELF_TEST)
-
-#include <string.h>
-#include <stdio.h>
-
-static const unsigned char base64_test_dec[64] =
-{
- 0x24, 0x48, 0x6E, 0x56, 0x87, 0x62, 0x5A, 0xBD,
- 0xBF, 0x17, 0xD9, 0xA2, 0xC4, 0x17, 0x1A, 0x01,
- 0x94, 0xED, 0x8F, 0x1E, 0x11, 0xB3, 0xD7, 0x09,
- 0x0C, 0xB6, 0xE9, 0x10, 0x6F, 0x22, 0xEE, 0x13,
- 0xCA, 0xB3, 0x07, 0x05, 0x76, 0xC9, 0xFA, 0x31,
- 0x6C, 0x08, 0x34, 0xFF, 0x8D, 0xC2, 0x6C, 0x38,
- 0x00, 0x43, 0xE9, 0x54, 0x97, 0xAF, 0x50, 0x4B,
- 0xD1, 0x41, 0xBA, 0x95, 0x31, 0x5A, 0x0B, 0x97
-};
-
-static const unsigned char base64_test_enc[] =
- "JEhuVodiWr2/F9mixBcaAZTtjx4Rs9cJDLbpEG8i7hPK"
- "swcFdsn6MWwINP+Nwmw4AEPpVJevUEvRQbqVMVoLlw==";
-
-/*
- * Checkup routine
- */
-int base64_self_test( int verbose )
-{
- int len;
- unsigned char *src, buffer[128];
-
- if( verbose != 0 )
- printf( " Base64 encoding test: " );
-
- len = sizeof( buffer );
- src = (unsigned char *) base64_test_dec;
-
- if( base64_encode( buffer, &len, src, 64 ) != 0 ||
- memcmp( base64_test_enc, buffer, 88 ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- printf( "passed\n Base64 decoding test: " );
-
- len = sizeof( buffer );
- src = (unsigned char *) base64_test_enc;
-
- if( base64_decode( buffer, &len, src, 88 ) != 0 ||
- memcmp( base64_test_dec, buffer, 64 ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- printf( "passed\n\n" );
-
- return( 0 );
-}
-
-#endif
-
-#endif
+++ /dev/null
-/*
- * Multi-precision integer library
- *
- * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
- *
- * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of PolarSSL or XySSL nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/*
- * This MPI implementation is based on:
- *
- * http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf
- * http://www.stillhq.com/extracted/gnupg-api/mpi/
- * http://math.libtomcrypt.com/files/tommath.pdf
- */
-
-#include "polarssl/config.h"
-
-#if defined(POLARSSL_BIGNUM_C)
-
-#include "polarssl/bignum.h"
-#include "polarssl/bn_mul.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#define ciL ((int) sizeof(t_int)) /* chars in limb */
-#define biL (ciL << 3) /* bits in limb */
-#define biH (ciL << 2) /* half limb size */
-
-/*
- * Convert between bits/chars and number of limbs
- */
-#define BITS_TO_LIMBS(i) (((i) + biL - 1) / biL)
-#define CHARS_TO_LIMBS(i) (((i) + ciL - 1) / ciL)
-
-/*
- * Initialize one or more mpi
- */
-void mpi_init( mpi *X, ... )
-{
- va_list args;
-
- va_start( args, X );
-
- while( X != NULL )
- {
- X->s = 1;
- X->n = 0;
- X->p = NULL;
-
- X = va_arg( args, mpi* );
- }
-
- va_end( args );
-}
-
-/*
- * Unallocate one or more mpi
- */
-void mpi_free( mpi *X, ... )
-{
- va_list args;
-
- va_start( args, X );
-
- while( X != NULL )
- {
- if( X->p != NULL )
- {
- memset( X->p, 0, X->n * ciL );
- free( X->p );
- }
-
- X->s = 1;
- X->n = 0;
- X->p = NULL;
-
- X = va_arg( args, mpi* );
- }
-
- va_end( args );
-}
-
-/*
- * Enlarge to the specified number of limbs
- */
-int mpi_grow( mpi *X, int nblimbs )
-{
- t_int *p;
-
- if( X->n < nblimbs )
- {
- if( ( p = (t_int *) malloc( nblimbs * ciL ) ) == NULL )
- return( 1 );
-
- memset( p, 0, nblimbs * ciL );
-
- if( X->p != NULL )
- {
- memcpy( p, X->p, X->n * ciL );
- memset( X->p, 0, X->n * ciL );
- free( X->p );
- }
-
- X->n = nblimbs;
- X->p = p;
- }
-
- return( 0 );
-}
-
-/*
- * Copy the contents of Y into X
- */
-int mpi_copy( mpi *X, mpi *Y )
-{
- int ret, i;
-
- if( X == Y )
- return( 0 );
-
- for( i = Y->n - 1; i > 0; i-- )
- if( Y->p[i] != 0 )
- break;
- i++;
-
- X->s = Y->s;
-
- MPI_CHK( mpi_grow( X, i ) );
-
- memset( X->p, 0, X->n * ciL );
- memcpy( X->p, Y->p, i * ciL );
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Swap the contents of X and Y
- */
-void mpi_swap( mpi *X, mpi *Y )
-{
- mpi T;
-
- memcpy( &T, X, sizeof( mpi ) );
- memcpy( X, Y, sizeof( mpi ) );
- memcpy( Y, &T, sizeof( mpi ) );
-}
-
-/*
- * Set value from integer
- */
-int mpi_lset( mpi *X, int z )
-{
- int ret;
-
- MPI_CHK( mpi_grow( X, 1 ) );
- memset( X->p, 0, X->n * ciL );
-
- X->p[0] = ( z < 0 ) ? -z : z;
- X->s = ( z < 0 ) ? -1 : 1;
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Return the number of least significant bits
- */
-int mpi_lsb( mpi *X )
-{
- int i, j, count = 0;
-
- for( i = 0; i < X->n; i++ )
- for( j = 0; j < (int) biL; j++, count++ )
- if( ( ( X->p[i] >> j ) & 1 ) != 0 )
- return( count );
-
- return( 0 );
-}
-
-/*
- * Return the number of most significant bits
- */
-int mpi_msb( mpi *X )
-{
- int i, j;
-
- for( i = X->n - 1; i > 0; i-- )
- if( X->p[i] != 0 )
- break;
-
- for( j = biL - 1; j >= 0; j-- )
- if( ( ( X->p[i] >> j ) & 1 ) != 0 )
- break;
-
- return( ( i * biL ) + j + 1 );
-}
-
-/*
- * Return the total size in bytes
- */
-int mpi_size( mpi *X )
-{
- return( ( mpi_msb( X ) + 7 ) >> 3 );
-}
-
-/*
- * Convert an ASCII character to digit value
- */
-static int mpi_get_digit( t_int *d, int radix, char c )
-{
- *d = 255;
-
- if( c >= 0x30 && c <= 0x39 ) *d = c - 0x30;
- if( c >= 0x41 && c <= 0x46 ) *d = c - 0x37;
- if( c >= 0x61 && c <= 0x66 ) *d = c - 0x57;
-
- if( *d >= (t_int) radix )
- return( POLARSSL_ERR_MPI_INVALID_CHARACTER );
-
- return( 0 );
-}
-
-/*
- * Import from an ASCII string
- */
-int mpi_read_string( mpi *X, int radix, char *s )
-{
- int ret, i, j, n;
- t_int d;
- mpi T;
-
- if( radix < 2 || radix > 16 )
- return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
-
- mpi_init( &T, NULL );
-
- if( radix == 16 )
- {
- n = BITS_TO_LIMBS( strlen( s ) << 2 );
-
- MPI_CHK( mpi_grow( X, n ) );
- MPI_CHK( mpi_lset( X, 0 ) );
-
- for( i = strlen( s ) - 1, j = 0; i >= 0; i--, j++ )
- {
- if( i == 0 && s[i] == '-' )
- {
- X->s = -1;
- break;
- }
-
- MPI_CHK( mpi_get_digit( &d, radix, s[i] ) );
- X->p[j / (2 * ciL)] |= d << ( (j % (2 * ciL)) << 2 );
- }
- }
- else
- {
- MPI_CHK( mpi_lset( X, 0 ) );
-
- for( i = 0; i < (int) strlen( s ); i++ )
- {
- if( i == 0 && s[i] == '-' )
- {
- X->s = -1;
- continue;
- }
-
- MPI_CHK( mpi_get_digit( &d, radix, s[i] ) );
- MPI_CHK( mpi_mul_int( &T, X, radix ) );
- MPI_CHK( mpi_add_int( X, &T, d ) );
- }
- }
-
-cleanup:
-
- mpi_free( &T, NULL );
-
- return( ret );
-}
-
-/*
- * Helper to write the digits high-order first
- */
-static int mpi_write_hlp( mpi *X, int radix, char **p )
-{
- int ret;
- t_int r;
-
- if( radix < 2 || radix > 16 )
- return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
-
- MPI_CHK( mpi_mod_int( &r, X, radix ) );
- MPI_CHK( mpi_div_int( X, NULL, X, radix ) );
-
- if( mpi_cmp_int( X, 0 ) != 0 )
- MPI_CHK( mpi_write_hlp( X, radix, p ) );
-
- if( r < 10 )
- *(*p)++ = (char)( r + 0x30 );
- else
- *(*p)++ = (char)( r + 0x37 );
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Export into an ASCII string
- */
-int mpi_write_string( mpi *X, int radix, char *s, int *slen )
-{
- int ret = 0, n;
- char *p;
- mpi T;
-
- if( radix < 2 || radix > 16 )
- return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
-
- n = mpi_msb( X );
- if( radix >= 4 ) n >>= 1;
- if( radix >= 16 ) n >>= 1;
- n += 3;
-
- if( *slen < n )
- {
- *slen = n;
- return( POLARSSL_ERR_MPI_BUFFER_TOO_SMALL );
- }
-
- p = s;
- mpi_init( &T, NULL );
-
- if( X->s == -1 )
- *p++ = '-';
-
- if( radix == 16 )
- {
- int c, i, j, k;
-
- for( i = X->n - 1, k = 0; i >= 0; i-- )
- {
- for( j = ciL - 1; j >= 0; j-- )
- {
- c = ( X->p[i] >> (j << 3) ) & 0xFF;
-
- if( c == 0 && k == 0 && (i + j) != 0 )
- continue;
-
- p += sprintf( p, "%02X", c );
- k = 1;
- }
- }
- }
- else
- {
- MPI_CHK( mpi_copy( &T, X ) );
- MPI_CHK( mpi_write_hlp( &T, radix, &p ) );
- }
-
- *p++ = '\0';
- *slen = p - s;
-
-cleanup:
-
- mpi_free( &T, NULL );
-
- return( ret );
-}
-
-/*
- * Read X from an opened file
- */
-int mpi_read_file( mpi *X, int radix, FILE *fin )
-{
- t_int d;
- int slen;
- char *p;
- char s[1024];
-
- memset( s, 0, sizeof( s ) );
- if( fgets( s, sizeof( s ) - 1, fin ) == NULL )
- return( POLARSSL_ERR_MPI_FILE_IO_ERROR );
-
- slen = strlen( s );
- if( s[slen - 1] == '\n' ) { slen--; s[slen] = '\0'; }
- if( s[slen - 1] == '\r' ) { slen--; s[slen] = '\0'; }
-
- p = s + slen;
- while( --p >= s )
- if( mpi_get_digit( &d, radix, *p ) != 0 )
- break;
-
- return( mpi_read_string( X, radix, p + 1 ) );
-}
-
-/*
- * Write X into an opened file (or stdout if fout == NULL)
- */
-int mpi_write_file( char *p, mpi *X, int radix, FILE *fout )
-{
- int n, ret;
- size_t slen;
- size_t plen;
- char s[1024];
-
- n = sizeof( s );
- memset( s, 0, n );
- n -= 2;
-
- MPI_CHK( mpi_write_string( X, radix, s, (int *) &n ) );
-
- if( p == NULL ) p = "";
-
- plen = strlen( p );
- slen = strlen( s );
- s[slen++] = '\r';
- s[slen++] = '\n';
-
- if( fout != NULL )
- {
- if( fwrite( p, 1, plen, fout ) != plen ||
- fwrite( s, 1, slen, fout ) != slen )
- return( POLARSSL_ERR_MPI_FILE_IO_ERROR );
- }
- else
- printf( "%s%s", p, s );
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Import X from unsigned binary data, big endian
- */
-int mpi_read_binary( mpi *X, unsigned char *buf, int buflen )
-{
- int ret, i, j, n;
-
- for( n = 0; n < buflen; n++ )
- if( buf[n] != 0 )
- break;
-
- MPI_CHK( mpi_grow( X, CHARS_TO_LIMBS( buflen - n ) ) );
- MPI_CHK( mpi_lset( X, 0 ) );
-
- for( i = buflen - 1, j = 0; i >= n; i--, j++ )
- X->p[j / ciL] |= ((t_int) buf[i]) << ((j % ciL) << 3);
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Export X into unsigned binary data, big endian
- */
-int mpi_write_binary( mpi *X, unsigned char *buf, int buflen )
-{
- int i, j, n;
-
- n = mpi_size( X );
-
- if( buflen < n )
- return( POLARSSL_ERR_MPI_BUFFER_TOO_SMALL );
-
- memset( buf, 0, buflen );
-
- for( i = buflen - 1, j = 0; n > 0; i--, j++, n-- )
- buf[i] = (unsigned char)( X->p[j / ciL] >> ((j % ciL) << 3) );
-
- return( 0 );
-}
-
-/*
- * Left-shift: X <<= count
- */
-int mpi_shift_l( mpi *X, int count )
-{
- int ret, i, v0, t1;
- t_int r0 = 0, r1;
-
- v0 = count / (biL );
- t1 = count & (biL - 1);
-
- i = mpi_msb( X ) + count;
-
- if( X->n * (int) biL < i )
- MPI_CHK( mpi_grow( X, BITS_TO_LIMBS( i ) ) );
-
- ret = 0;
-
- /*
- * shift by count / limb_size
- */
- if( v0 > 0 )
- {
- for( i = X->n - 1; i >= v0; i-- )
- X->p[i] = X->p[i - v0];
-
- for( ; i >= 0; i-- )
- X->p[i] = 0;
- }
-
- /*
- * shift by count % limb_size
- */
- if( t1 > 0 )
- {
- for( i = v0; i < X->n; i++ )
- {
- r1 = X->p[i] >> (biL - t1);
- X->p[i] <<= t1;
- X->p[i] |= r0;
- r0 = r1;
- }
- }
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Right-shift: X >>= count
- */
-int mpi_shift_r( mpi *X, int count )
-{
- int i, v0, v1;
- t_int r0 = 0, r1;
-
- v0 = count / biL;
- v1 = count & (biL - 1);
-
- /*
- * shift by count / limb_size
- */
- if( v0 > 0 )
- {
- for( i = 0; i < X->n - v0; i++ )
- X->p[i] = X->p[i + v0];
-
- for( ; i < X->n; i++ )
- X->p[i] = 0;
- }
-
- /*
- * shift by count % limb_size
- */
- if( v1 > 0 )
- {
- for( i = X->n - 1; i >= 0; i-- )
- {
- r1 = X->p[i] << (biL - v1);
- X->p[i] >>= v1;
- X->p[i] |= r0;
- r0 = r1;
- }
- }
-
- return( 0 );
-}
-
-/*
- * Compare unsigned values
- */
-int mpi_cmp_abs( mpi *X, mpi *Y )
-{
- int i, j;
-
- for( i = X->n - 1; i >= 0; i-- )
- if( X->p[i] != 0 )
- break;
-
- for( j = Y->n - 1; j >= 0; j-- )
- if( Y->p[j] != 0 )
- break;
-
- if( i < 0 && j < 0 )
- return( 0 );
-
- if( i > j ) return( 1 );
- if( j > i ) return( -1 );
-
- for( ; i >= 0; i-- )
- {
- if( X->p[i] > Y->p[i] ) return( 1 );
- if( X->p[i] < Y->p[i] ) return( -1 );
- }
-
- return( 0 );
-}
-
-/*
- * Compare signed values
- */
-int mpi_cmp_mpi( mpi *X, mpi *Y )
-{
- int i, j;
-
- for( i = X->n - 1; i >= 0; i-- )
- if( X->p[i] != 0 )
- break;
-
- for( j = Y->n - 1; j >= 0; j-- )
- if( Y->p[j] != 0 )
- break;
-
- if( i < 0 && j < 0 )
- return( 0 );
-
- if( i > j ) return( X->s );
- if( j > i ) return( -X->s );
-
- if( X->s > 0 && Y->s < 0 ) return( 1 );
- if( Y->s > 0 && X->s < 0 ) return( -1 );
-
- for( ; i >= 0; i-- )
- {
- if( X->p[i] > Y->p[i] ) return( X->s );
- if( X->p[i] < Y->p[i] ) return( -X->s );
- }
-
- return( 0 );
-}
-
-/*
- * Compare signed values
- */
-int mpi_cmp_int( mpi *X, int z )
-{
- mpi Y;
- t_int p[1];
-
- *p = ( z < 0 ) ? -z : z;
- Y.s = ( z < 0 ) ? -1 : 1;
- Y.n = 1;
- Y.p = p;
-
- return( mpi_cmp_mpi( X, &Y ) );
-}
-
-/*
- * Unsigned addition: X = |A| + |B| (HAC 14.7)
- */
-int mpi_add_abs( mpi *X, mpi *A, mpi *B )
-{
- int ret, i, j;
- t_int *o, *p, c;
-
- if( X == B )
- {
- mpi *T = A; A = X; B = T;
- }
-
- if( X != A )
- MPI_CHK( mpi_copy( X, A ) );
-
- for( j = B->n - 1; j >= 0; j-- )
- if( B->p[j] != 0 )
- break;
-
- MPI_CHK( mpi_grow( X, j + 1 ) );
-
- o = B->p; p = X->p; c = 0;
-
- for( i = 0; i <= j; i++, o++, p++ )
- {
- *p += c; c = ( *p < c );
- *p += *o; c += ( *p < *o );
- }
-
- while( c != 0 )
- {
- if( i >= X->n )
- {
- MPI_CHK( mpi_grow( X, i + 1 ) );
- p = X->p + i;
- }
-
- *p += c; c = ( *p < c ); i++;
- }
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Helper for mpi substraction
- */
-static void mpi_sub_hlp( int n, t_int *s, t_int *d )
-{
- int i;
- t_int c, z;
-
- for( i = c = 0; i < n; i++, s++, d++ )
- {
- z = ( *d < c ); *d -= c;
- c = ( *d < *s ) + z; *d -= *s;
- }
-
- while( c != 0 )
- {
- z = ( *d < c ); *d -= c;
- c = z; i++; d++;
- }
-}
-
-/*
- * Unsigned substraction: X = |A| - |B| (HAC 14.9)
- */
-int mpi_sub_abs( mpi *X, mpi *A, mpi *B )
-{
- mpi TB;
- int ret, n;
-
- if( mpi_cmp_abs( A, B ) < 0 )
- return( POLARSSL_ERR_MPI_NEGATIVE_VALUE );
-
- mpi_init( &TB, NULL );
-
- if( X == B )
- {
- MPI_CHK( mpi_copy( &TB, B ) );
- B = &TB;
- }
-
- if( X != A )
- MPI_CHK( mpi_copy( X, A ) );
-
- ret = 0;
-
- for( n = B->n - 1; n >= 0; n-- )
- if( B->p[n] != 0 )
- break;
-
- mpi_sub_hlp( n + 1, B->p, X->p );
-
-cleanup:
-
- mpi_free( &TB, NULL );
-
- return( ret );
-}
-
-/*
- * Signed addition: X = A + B
- */
-int mpi_add_mpi( mpi *X, mpi *A, mpi *B )
-{
- int ret, s = A->s;
-
- if( A->s * B->s < 0 )
- {
- if( mpi_cmp_abs( A, B ) >= 0 )
- {
- MPI_CHK( mpi_sub_abs( X, A, B ) );
- X->s = s;
- }
- else
- {
- MPI_CHK( mpi_sub_abs( X, B, A ) );
- X->s = -s;
- }
- }
- else
- {
- MPI_CHK( mpi_add_abs( X, A, B ) );
- X->s = s;
- }
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Signed substraction: X = A - B
- */
-int mpi_sub_mpi( mpi *X, mpi *A, mpi *B )
-{
- int ret, s = A->s;
-
- if( A->s * B->s > 0 )
- {
- if( mpi_cmp_abs( A, B ) >= 0 )
- {
- MPI_CHK( mpi_sub_abs( X, A, B ) );
- X->s = s;
- }
- else
- {
- MPI_CHK( mpi_sub_abs( X, B, A ) );
- X->s = -s;
- }
- }
- else
- {
- MPI_CHK( mpi_add_abs( X, A, B ) );
- X->s = s;
- }
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Signed addition: X = A + b
- */
-int mpi_add_int( mpi *X, mpi *A, int b )
-{
- mpi _B;
- t_int p[1];
-
- p[0] = ( b < 0 ) ? -b : b;
- _B.s = ( b < 0 ) ? -1 : 1;
- _B.n = 1;
- _B.p = p;
-
- return( mpi_add_mpi( X, A, &_B ) );
-}
-
-/*
- * Signed substraction: X = A - b
- */
-int mpi_sub_int( mpi *X, mpi *A, int b )
-{
- mpi _B;
- t_int p[1];
-
- p[0] = ( b < 0 ) ? -b : b;
- _B.s = ( b < 0 ) ? -1 : 1;
- _B.n = 1;
- _B.p = p;
-
- return( mpi_sub_mpi( X, A, &_B ) );
-}
-
-/*
- * Helper for mpi multiplication
- */
-static void mpi_mul_hlp( int i, t_int *s, t_int *d, t_int b )
-{
- t_int c = 0, t = 0;
-
-#if defined(MULADDC_HUIT)
- for( ; i >= 8; i -= 8 )
- {
- MULADDC_INIT
- MULADDC_HUIT
- MULADDC_STOP
- }
-
- for( ; i > 0; i-- )
- {
- MULADDC_INIT
- MULADDC_CORE
- MULADDC_STOP
- }
-#else
- for( ; i >= 16; i -= 16 )
- {
- MULADDC_INIT
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
-
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
- MULADDC_STOP
- }
-
- for( ; i >= 8; i -= 8 )
- {
- MULADDC_INIT
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
-
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
- MULADDC_STOP
- }
-
- for( ; i > 0; i-- )
- {
- MULADDC_INIT
- MULADDC_CORE
- MULADDC_STOP
- }
-#endif
-
- t++;
-
- do {
- *d += c; c = ( *d < c ); d++;
- }
- while( c != 0 );
-}
-
-/*
- * Baseline multiplication: X = A * B (HAC 14.12)
- */
-int mpi_mul_mpi( mpi *X, mpi *A, mpi *B )
-{
- int ret, i, j;
- mpi TA, TB;
-
- mpi_init( &TA, &TB, NULL );
-
- if( X == A ) { MPI_CHK( mpi_copy( &TA, A ) ); A = &TA; }
- if( X == B ) { MPI_CHK( mpi_copy( &TB, B ) ); B = &TB; }
-
- for( i = A->n - 1; i >= 0; i-- )
- if( A->p[i] != 0 )
- break;
-
- for( j = B->n - 1; j >= 0; j-- )
- if( B->p[j] != 0 )
- break;
-
- MPI_CHK( mpi_grow( X, i + j + 2 ) );
- MPI_CHK( mpi_lset( X, 0 ) );
-
- for( i++; j >= 0; j-- )
- mpi_mul_hlp( i, A->p, X->p + j, B->p[j] );
-
- X->s = A->s * B->s;
-
-cleanup:
-
- mpi_free( &TB, &TA, NULL );
-
- return( ret );
-}
-
-/*
- * Baseline multiplication: X = A * b
- */
-int mpi_mul_int( mpi *X, mpi *A, t_int b )
-{
- mpi _B;
- t_int p[1];
-
- _B.s = 1;
- _B.n = 1;
- _B.p = p;
- p[0] = b;
-
- return( mpi_mul_mpi( X, A, &_B ) );
-}
-
-/*
- * Division by mpi: A = Q * B + R (HAC 14.20)
- */
-int mpi_div_mpi( mpi *Q, mpi *R, mpi *A, mpi *B )
-{
- int ret, i, n, t, k;
- mpi X, Y, Z, T1, T2;
-
- if( mpi_cmp_int( B, 0 ) == 0 )
- return( POLARSSL_ERR_MPI_DIVISION_BY_ZERO );
-
- mpi_init( &X, &Y, &Z, &T1, &T2, NULL );
-
- if( mpi_cmp_abs( A, B ) < 0 )
- {
- if( Q != NULL ) MPI_CHK( mpi_lset( Q, 0 ) );
- if( R != NULL ) MPI_CHK( mpi_copy( R, A ) );
- return( 0 );
- }
-
- MPI_CHK( mpi_copy( &X, A ) );
- MPI_CHK( mpi_copy( &Y, B ) );
- X.s = Y.s = 1;
-
- MPI_CHK( mpi_grow( &Z, A->n + 2 ) );
- MPI_CHK( mpi_lset( &Z, 0 ) );
- MPI_CHK( mpi_grow( &T1, 2 ) );
- MPI_CHK( mpi_grow( &T2, 3 ) );
-
- k = mpi_msb( &Y ) % biL;
- if( k < (int) biL - 1 )
- {
- k = biL - 1 - k;
- MPI_CHK( mpi_shift_l( &X, k ) );
- MPI_CHK( mpi_shift_l( &Y, k ) );
- }
- else k = 0;
-
- n = X.n - 1;
- t = Y.n - 1;
- mpi_shift_l( &Y, biL * (n - t) );
-
- while( mpi_cmp_mpi( &X, &Y ) >= 0 )
- {
- Z.p[n - t]++;
- mpi_sub_mpi( &X, &X, &Y );
- }
- mpi_shift_r( &Y, biL * (n - t) );
-
- for( i = n; i > t ; i-- )
- {
- if( X.p[i] >= Y.p[t] )
- Z.p[i - t - 1] = ~0;
- else
- {
-#if defined(POLARSSL_HAVE_LONGLONG)
- t_dbl r;
-
- r = (t_dbl) X.p[i] << biL;
- r |= (t_dbl) X.p[i - 1];
- r /= Y.p[t];
- if( r > ((t_dbl) 1 << biL) - 1)
- r = ((t_dbl) 1 << biL) - 1;
-
- Z.p[i - t - 1] = (t_int) r;
-#else
- /*
- * __udiv_qrnnd_c, from gmp/longlong.h
- */
- t_int q0, q1, r0, r1;
- t_int d0, d1, d, m;
-
- d = Y.p[t];
- d0 = ( d << biH ) >> biH;
- d1 = ( d >> biH );
-
- q1 = X.p[i] / d1;
- r1 = X.p[i] - d1 * q1;
- r1 <<= biH;
- r1 |= ( X.p[i - 1] >> biH );
-
- m = q1 * d0;
- if( r1 < m )
- {
- q1--, r1 += d;
- while( r1 >= d && r1 < m )
- q1--, r1 += d;
- }
- r1 -= m;
-
- q0 = r1 / d1;
- r0 = r1 - d1 * q0;
- r0 <<= biH;
- r0 |= ( X.p[i - 1] << biH ) >> biH;
-
- m = q0 * d0;
- if( r0 < m )
- {
- q0--, r0 += d;
- while( r0 >= d && r0 < m )
- q0--, r0 += d;
- }
- r0 -= m;
-
- Z.p[i - t - 1] = ( q1 << biH ) | q0;
-#endif
- }
-
- Z.p[i - t - 1]++;
- do
- {
- Z.p[i - t - 1]--;
-
- MPI_CHK( mpi_lset( &T1, 0 ) );
- T1.p[0] = (t < 1) ? 0 : Y.p[t - 1];
- T1.p[1] = Y.p[t];
- MPI_CHK( mpi_mul_int( &T1, &T1, Z.p[i - t - 1] ) );
-
- MPI_CHK( mpi_lset( &T2, 0 ) );
- T2.p[0] = (i < 2) ? 0 : X.p[i - 2];
- T2.p[1] = (i < 1) ? 0 : X.p[i - 1];
- T2.p[2] = X.p[i];
- }
- while( mpi_cmp_mpi( &T1, &T2 ) > 0 );
-
- MPI_CHK( mpi_mul_int( &T1, &Y, Z.p[i - t - 1] ) );
- MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) );
- MPI_CHK( mpi_sub_mpi( &X, &X, &T1 ) );
-
- if( mpi_cmp_int( &X, 0 ) < 0 )
- {
- MPI_CHK( mpi_copy( &T1, &Y ) );
- MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) );
- MPI_CHK( mpi_add_mpi( &X, &X, &T1 ) );
- Z.p[i - t - 1]--;
- }
- }
-
- if( Q != NULL )
- {
- mpi_copy( Q, &Z );
- Q->s = A->s * B->s;
- }
-
- if( R != NULL )
- {
- mpi_shift_r( &X, k );
- mpi_copy( R, &X );
-
- R->s = A->s;
- if( mpi_cmp_int( R, 0 ) == 0 )
- R->s = 1;
- }
-
-cleanup:
-
- mpi_free( &X, &Y, &Z, &T1, &T2, NULL );
-
- return( ret );
-}
-
-/*
- * Division by int: A = Q * b + R
- *
- * Returns 0 if successful
- * 1 if memory allocation failed
- * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0
- */
-int mpi_div_int( mpi *Q, mpi *R, mpi *A, int b )
-{
- mpi _B;
- t_int p[1];
-
- p[0] = ( b < 0 ) ? -b : b;
- _B.s = ( b < 0 ) ? -1 : 1;
- _B.n = 1;
- _B.p = p;
-
- return( mpi_div_mpi( Q, R, A, &_B ) );
-}
-
-/*
- * Modulo: R = A mod B
- */
-int mpi_mod_mpi( mpi *R, mpi *A, mpi *B )
-{
- int ret;
-
- MPI_CHK( mpi_div_mpi( NULL, R, A, B ) );
-
- while( mpi_cmp_int( R, 0 ) < 0 )
- MPI_CHK( mpi_add_mpi( R, R, B ) );
-
- while( mpi_cmp_mpi( R, B ) >= 0 )
- MPI_CHK( mpi_sub_mpi( R, R, B ) );
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Modulo: r = A mod b
- */
-int mpi_mod_int( t_int *r, mpi *A, int b )
-{
- int i;
- t_int x, y, z;
-
- if( b == 0 )
- return( POLARSSL_ERR_MPI_DIVISION_BY_ZERO );
-
- if( b < 0 )
- b = -b;
-
- /*
- * handle trivial cases
- */
- if( b == 1 )
- {
- *r = 0;
- return( 0 );
- }
-
- if( b == 2 )
- {
- *r = A->p[0] & 1;
- return( 0 );
- }
-
- /*
- * general case
- */
- for( i = A->n - 1, y = 0; i >= 0; i-- )
- {
- x = A->p[i];
- y = ( y << biH ) | ( x >> biH );
- z = y / b;
- y -= z * b;
-
- x <<= biH;
- y = ( y << biH ) | ( x >> biH );
- z = y / b;
- y -= z * b;
- }
-
- *r = y;
-
- return( 0 );
-}
-
-/*
- * Fast Montgomery initialization (thanks to Tom St Denis)
- */
-static void mpi_montg_init( t_int *mm, mpi *N )
-{
- t_int x, m0 = N->p[0];
-
- x = m0;
- x += ( ( m0 + 2 ) & 4 ) << 1;
- x *= ( 2 - ( m0 * x ) );
-
- if( biL >= 16 ) x *= ( 2 - ( m0 * x ) );
- if( biL >= 32 ) x *= ( 2 - ( m0 * x ) );
- if( biL >= 64 ) x *= ( 2 - ( m0 * x ) );
-
- *mm = ~x + 1;
-}
-
-/*
- * Montgomery multiplication: A = A * B * R^-1 mod N (HAC 14.36)
- */
-static void mpi_montmul( mpi *A, mpi *B, mpi *N, t_int mm, mpi *T )
-{
- int i, n, m;
- t_int u0, u1, *d;
-
- memset( T->p, 0, T->n * ciL );
-
- d = T->p;
- n = N->n;
- m = ( B->n < n ) ? B->n : n;
-
- for( i = 0; i < n; i++ )
- {
- /*
- * T = (T + u0*B + u1*N) / 2^biL
- */
- u0 = A->p[i];
- u1 = ( d[0] + u0 * B->p[0] ) * mm;
-
- mpi_mul_hlp( m, B->p, d, u0 );
- mpi_mul_hlp( n, N->p, d, u1 );
-
- *d++ = u0; d[n + 1] = 0;
- }
-
- memcpy( A->p, d, (n + 1) * ciL );
-
- if( mpi_cmp_abs( A, N ) >= 0 )
- mpi_sub_hlp( n, N->p, A->p );
- else
- /* prevent timing attacks */
- mpi_sub_hlp( n, A->p, T->p );
-}
-
-/*
- * Montgomery reduction: A = A * R^-1 mod N
- */
-static void mpi_montred( mpi *A, mpi *N, t_int mm, mpi *T )
-{
- t_int z = 1;
- mpi U;
-
- U.n = U.s = z;
- U.p = &z;
-
- mpi_montmul( A, &U, N, mm, T );
-}
-
-/*
- * Sliding-window exponentiation: X = A^E mod N (HAC 14.85)
- */
-int mpi_exp_mod( mpi *X, mpi *A, mpi *E, mpi *N, mpi *_RR )
-{
- int ret, i, j, wsize, wbits;
- int bufsize, nblimbs, nbits;
- t_int ei, mm, state;
- mpi RR, T, W[64];
-
- if( mpi_cmp_int( N, 0 ) < 0 || ( N->p[0] & 1 ) == 0 )
- return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
-
- /*
- * Init temps and window size
- */
- mpi_montg_init( &mm, N );
- mpi_init( &RR, &T, NULL );
- memset( W, 0, sizeof( W ) );
-
- i = mpi_msb( E );
-
- wsize = ( i > 671 ) ? 6 : ( i > 239 ) ? 5 :
- ( i > 79 ) ? 4 : ( i > 23 ) ? 3 : 1;
-
- j = N->n + 1;
- MPI_CHK( mpi_grow( X, j ) );
- MPI_CHK( mpi_grow( &W[1], j ) );
- MPI_CHK( mpi_grow( &T, j * 2 ) );
-
- /*
- * If 1st call, pre-compute R^2 mod N
- */
- if( _RR == NULL || _RR->p == NULL )
- {
- MPI_CHK( mpi_lset( &RR, 1 ) );
- MPI_CHK( mpi_shift_l( &RR, N->n * 2 * biL ) );
- MPI_CHK( mpi_mod_mpi( &RR, &RR, N ) );
-
- if( _RR != NULL )
- memcpy( _RR, &RR, sizeof( mpi ) );
- }
- else
- memcpy( &RR, _RR, sizeof( mpi ) );
-
- /*
- * W[1] = A * R^2 * R^-1 mod N = A * R mod N
- */
- if( mpi_cmp_mpi( A, N ) >= 0 )
- mpi_mod_mpi( &W[1], A, N );
- else mpi_copy( &W[1], A );
-
- mpi_montmul( &W[1], &RR, N, mm, &T );
-
- /*
- * X = R^2 * R^-1 mod N = R mod N
- */
- MPI_CHK( mpi_copy( X, &RR ) );
- mpi_montred( X, N, mm, &T );
-
- if( wsize > 1 )
- {
- /*
- * W[1 << (wsize - 1)] = W[1] ^ (wsize - 1)
- */
- j = 1 << (wsize - 1);
-
- MPI_CHK( mpi_grow( &W[j], N->n + 1 ) );
- MPI_CHK( mpi_copy( &W[j], &W[1] ) );
-
- for( i = 0; i < wsize - 1; i++ )
- mpi_montmul( &W[j], &W[j], N, mm, &T );
-
- /*
- * W[i] = W[i - 1] * W[1]
- */
- for( i = j + 1; i < (1 << wsize); i++ )
- {
- MPI_CHK( mpi_grow( &W[i], N->n + 1 ) );
- MPI_CHK( mpi_copy( &W[i], &W[i - 1] ) );
-
- mpi_montmul( &W[i], &W[1], N, mm, &T );
- }
- }
-
- nblimbs = E->n;
- bufsize = 0;
- nbits = 0;
- wbits = 0;
- state = 0;
-
- while( 1 )
- {
- if( bufsize == 0 )
- {
- if( nblimbs-- == 0 )
- break;
-
- bufsize = sizeof( t_int ) << 3;
- }
-
- bufsize--;
-
- ei = (E->p[nblimbs] >> bufsize) & 1;
-
- /*
- * skip leading 0s
- */
- if( ei == 0 && state == 0 )
- continue;
-
- if( ei == 0 && state == 1 )
- {
- /*
- * out of window, square X
- */
- mpi_montmul( X, X, N, mm, &T );
- continue;
- }
-
- /*
- * add ei to current window
- */
- state = 2;
-
- nbits++;
- wbits |= (ei << (wsize - nbits));
-
- if( nbits == wsize )
- {
- /*
- * X = X^wsize R^-1 mod N
- */
- for( i = 0; i < wsize; i++ )
- mpi_montmul( X, X, N, mm, &T );
-
- /*
- * X = X * W[wbits] R^-1 mod N
- */
- mpi_montmul( X, &W[wbits], N, mm, &T );
-
- state--;
- nbits = 0;
- wbits = 0;
- }
- }
-
- /*
- * process the remaining bits
- */
- for( i = 0; i < nbits; i++ )
- {
- mpi_montmul( X, X, N, mm, &T );
-
- wbits <<= 1;
-
- if( (wbits & (1 << wsize)) != 0 )
- mpi_montmul( X, &W[1], N, mm, &T );
- }
-
- /*
- * X = A^E * R * R^-1 mod N = A^E mod N
- */
- mpi_montred( X, N, mm, &T );
-
-cleanup:
-
- for( i = (1 << (wsize - 1)); i < (1 << wsize); i++ )
- mpi_free( &W[i], NULL );
-
- if( _RR != NULL )
- mpi_free( &W[1], &T, NULL );
- else mpi_free( &W[1], &T, &RR, NULL );
-
- return( ret );
-}
-
-/*
- * Greatest common divisor: G = gcd(A, B) (HAC 14.54)
- */
-int mpi_gcd( mpi *G, mpi *A, mpi *B )
-{
- int ret, lz, lzt;
- mpi TG, TA, TB;
-
- mpi_init( &TG, &TA, &TB, NULL );
-
- MPI_CHK( mpi_copy( &TA, A ) );
- MPI_CHK( mpi_copy( &TB, B ) );
-
- lz = mpi_lsb( &TA );
- lzt = mpi_lsb( &TB );
-
- if ( lzt < lz )
- lz = lzt;
-
- MPI_CHK( mpi_shift_r( &TA, lz ) );
- MPI_CHK( mpi_shift_r( &TB, lz ) );
-
- TA.s = TB.s = 1;
-
- while( mpi_cmp_int( &TA, 0 ) != 0 )
- {
- MPI_CHK( mpi_shift_r( &TA, mpi_lsb( &TA ) ) );
- MPI_CHK( mpi_shift_r( &TB, mpi_lsb( &TB ) ) );
-
- if( mpi_cmp_mpi( &TA, &TB ) >= 0 )
- {
- MPI_CHK( mpi_sub_abs( &TA, &TA, &TB ) );
- MPI_CHK( mpi_shift_r( &TA, 1 ) );
- }
- else
- {
- MPI_CHK( mpi_sub_abs( &TB, &TB, &TA ) );
- MPI_CHK( mpi_shift_r( &TB, 1 ) );
- }
- }
-
- MPI_CHK( mpi_shift_l( &TB, lz ) );
- MPI_CHK( mpi_copy( G, &TB ) );
-
-cleanup:
-
- mpi_free( &TB, &TA, &TG, NULL );
-
- return( ret );
-}
-
-#if defined(POLARSSL_GENPRIME)
-
-/*
- * Modular inverse: X = A^-1 mod N (HAC 14.61 / 14.64)
- */
-int mpi_inv_mod( mpi *X, mpi *A, mpi *N )
-{
- int ret;
- mpi G, TA, TU, U1, U2, TB, TV, V1, V2;
-
- if( mpi_cmp_int( N, 0 ) <= 0 )
- return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
-
- mpi_init( &TA, &TU, &U1, &U2, &G,
- &TB, &TV, &V1, &V2, NULL );
-
- MPI_CHK( mpi_gcd( &G, A, N ) );
-
- if( mpi_cmp_int( &G, 1 ) != 0 )
- {
- ret = POLARSSL_ERR_MPI_NOT_ACCEPTABLE;
- goto cleanup;
- }
-
- MPI_CHK( mpi_mod_mpi( &TA, A, N ) );
- MPI_CHK( mpi_copy( &TU, &TA ) );
- MPI_CHK( mpi_copy( &TB, N ) );
- MPI_CHK( mpi_copy( &TV, N ) );
-
- MPI_CHK( mpi_lset( &U1, 1 ) );
- MPI_CHK( mpi_lset( &U2, 0 ) );
- MPI_CHK( mpi_lset( &V1, 0 ) );
- MPI_CHK( mpi_lset( &V2, 1 ) );
-
- do
- {
- while( ( TU.p[0] & 1 ) == 0 )
- {
- MPI_CHK( mpi_shift_r( &TU, 1 ) );
-
- if( ( U1.p[0] & 1 ) != 0 || ( U2.p[0] & 1 ) != 0 )
- {
- MPI_CHK( mpi_add_mpi( &U1, &U1, &TB ) );
- MPI_CHK( mpi_sub_mpi( &U2, &U2, &TA ) );
- }
-
- MPI_CHK( mpi_shift_r( &U1, 1 ) );
- MPI_CHK( mpi_shift_r( &U2, 1 ) );
- }
-
- while( ( TV.p[0] & 1 ) == 0 )
- {
- MPI_CHK( mpi_shift_r( &TV, 1 ) );
-
- if( ( V1.p[0] & 1 ) != 0 || ( V2.p[0] & 1 ) != 0 )
- {
- MPI_CHK( mpi_add_mpi( &V1, &V1, &TB ) );
- MPI_CHK( mpi_sub_mpi( &V2, &V2, &TA ) );
- }
-
- MPI_CHK( mpi_shift_r( &V1, 1 ) );
- MPI_CHK( mpi_shift_r( &V2, 1 ) );
- }
-
- if( mpi_cmp_mpi( &TU, &TV ) >= 0 )
- {
- MPI_CHK( mpi_sub_mpi( &TU, &TU, &TV ) );
- MPI_CHK( mpi_sub_mpi( &U1, &U1, &V1 ) );
- MPI_CHK( mpi_sub_mpi( &U2, &U2, &V2 ) );
- }
- else
- {
- MPI_CHK( mpi_sub_mpi( &TV, &TV, &TU ) );
- MPI_CHK( mpi_sub_mpi( &V1, &V1, &U1 ) );
- MPI_CHK( mpi_sub_mpi( &V2, &V2, &U2 ) );
- }
- }
- while( mpi_cmp_int( &TU, 0 ) != 0 );
-
- while( mpi_cmp_int( &V1, 0 ) < 0 )
- MPI_CHK( mpi_add_mpi( &V1, &V1, N ) );
-
- while( mpi_cmp_mpi( &V1, N ) >= 0 )
- MPI_CHK( mpi_sub_mpi( &V1, &V1, N ) );
-
- MPI_CHK( mpi_copy( X, &V1 ) );
-
-cleanup:
-
- mpi_free( &V2, &V1, &TV, &TB, &G,
- &U2, &U1, &TU, &TA, NULL );
-
- return( ret );
-}
-
-static const int small_prime[] =
-{
- 3, 5, 7, 11, 13, 17, 19, 23,
- 29, 31, 37, 41, 43, 47, 53, 59,
- 61, 67, 71, 73, 79, 83, 89, 97,
- 101, 103, 107, 109, 113, 127, 131, 137,
- 139, 149, 151, 157, 163, 167, 173, 179,
- 181, 191, 193, 197, 199, 211, 223, 227,
- 229, 233, 239, 241, 251, 257, 263, 269,
- 271, 277, 281, 283, 293, 307, 311, 313,
- 317, 331, 337, 347, 349, 353, 359, 367,
- 373, 379, 383, 389, 397, 401, 409, 419,
- 421, 431, 433, 439, 443, 449, 457, 461,
- 463, 467, 479, 487, 491, 499, 503, 509,
- 521, 523, 541, 547, 557, 563, 569, 571,
- 577, 587, 593, 599, 601, 607, 613, 617,
- 619, 631, 641, 643, 647, 653, 659, 661,
- 673, 677, 683, 691, 701, 709, 719, 727,
- 733, 739, 743, 751, 757, 761, 769, 773,
- 787, 797, 809, 811, 821, 823, 827, 829,
- 839, 853, 857, 859, 863, 877, 881, 883,
- 887, 907, 911, 919, 929, 937, 941, 947,
- 953, 967, 971, 977, 983, 991, 997, -103
-};
-
-/*
- * Miller-Rabin primality test (HAC 4.24)
- */
-int mpi_is_prime( mpi *X, int (*f_rng)(void *), void *p_rng )
-{
- int ret, i, j, n, s, xs;
- mpi W, R, T, A, RR;
- unsigned char *p;
-
- if( mpi_cmp_int( X, 0 ) == 0 )
- return( 0 );
-
- mpi_init( &W, &R, &T, &A, &RR, NULL );
-
- xs = X->s; X->s = 1;
-
- /*
- * test trivial factors first
- */
- if( ( X->p[0] & 1 ) == 0 )
- return( POLARSSL_ERR_MPI_NOT_ACCEPTABLE );
-
- for( i = 0; small_prime[i] > 0; i++ )
- {
- t_int r;
-
- if( mpi_cmp_int( X, small_prime[i] ) <= 0 )
- return( 0 );
-
- MPI_CHK( mpi_mod_int( &r, X, small_prime[i] ) );
-
- if( r == 0 )
- return( POLARSSL_ERR_MPI_NOT_ACCEPTABLE );
- }
-
- /*
- * W = |X| - 1
- * R = W >> lsb( W )
- */
- s = mpi_lsb( &W );
- MPI_CHK( mpi_sub_int( &W, X, 1 ) );
- MPI_CHK( mpi_copy( &R, &W ) );
- MPI_CHK( mpi_shift_r( &R, s ) );
-
- i = mpi_msb( X );
- /*
- * HAC, table 4.4
- */
- n = ( ( i >= 1300 ) ? 2 : ( i >= 850 ) ? 3 :
- ( i >= 650 ) ? 4 : ( i >= 350 ) ? 8 :
- ( i >= 250 ) ? 12 : ( i >= 150 ) ? 18 : 27 );
-
- for( i = 0; i < n; i++ )
- {
- /*
- * pick a random A, 1 < A < |X| - 1
- */
- MPI_CHK( mpi_grow( &A, X->n ) );
-
- p = (unsigned char *) A.p;
- for( j = 0; j < A.n * ciL; j++ )
- *p++ = (unsigned char) f_rng( p_rng );
-
- j = mpi_msb( &A ) - mpi_msb( &W );
- MPI_CHK( mpi_shift_r( &A, j + 1 ) );
- A.p[0] |= 3;
-
- /*
- * A = A^R mod |X|
- */
- MPI_CHK( mpi_exp_mod( &A, &A, &R, X, &RR ) );
-
- if( mpi_cmp_mpi( &A, &W ) == 0 ||
- mpi_cmp_int( &A, 1 ) == 0 )
- continue;
-
- j = 1;
- while( j < s && mpi_cmp_mpi( &A, &W ) != 0 )
- {
- /*
- * A = A * A mod |X|
- */
- MPI_CHK( mpi_mul_mpi( &T, &A, &A ) );
- MPI_CHK( mpi_mod_mpi( &A, &T, X ) );
-
- if( mpi_cmp_int( &A, 1 ) == 0 )
- break;
-
- j++;
- }
-
- /*
- * not prime if A != |X| - 1 or A == 1
- */
- if( mpi_cmp_mpi( &A, &W ) != 0 ||
- mpi_cmp_int( &A, 1 ) == 0 )
- {
- ret = POLARSSL_ERR_MPI_NOT_ACCEPTABLE;
- break;
- }
- }
-
-cleanup:
-
- X->s = xs;
-
- mpi_free( &RR, &A, &T, &R, &W, NULL );
-
- return( ret );
-}
-
-/*
- * Prime number generation
- */
-int mpi_gen_prime( mpi *X, int nbits, int dh_flag,
- int (*f_rng)(void *), void *p_rng )
-{
- int ret, k, n;
- unsigned char *p;
- mpi Y;
-
- if( nbits < 3 )
- return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
-
- mpi_init( &Y, NULL );
-
- n = BITS_TO_LIMBS( nbits );
-
- MPI_CHK( mpi_grow( X, n ) );
- MPI_CHK( mpi_lset( X, 0 ) );
-
- p = (unsigned char *) X->p;
- for( k = 0; k < X->n * ciL; k++ )
- *p++ = (unsigned char) f_rng( p_rng );
-
- k = mpi_msb( X );
- if( k < nbits ) MPI_CHK( mpi_shift_l( X, nbits - k ) );
- if( k > nbits ) MPI_CHK( mpi_shift_r( X, k - nbits ) );
-
- X->p[0] |= 3;
-
- if( dh_flag == 0 )
- {
- while( ( ret = mpi_is_prime( X, f_rng, p_rng ) ) != 0 )
- {
- if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
- goto cleanup;
-
- MPI_CHK( mpi_add_int( X, X, 2 ) );
- }
- }
- else
- {
- MPI_CHK( mpi_sub_int( &Y, X, 1 ) );
- MPI_CHK( mpi_shift_r( &Y, 1 ) );
-
- while( 1 )
- {
- if( ( ret = mpi_is_prime( X, f_rng, p_rng ) ) == 0 )
- {
- if( ( ret = mpi_is_prime( &Y, f_rng, p_rng ) ) == 0 )
- break;
-
- if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
- goto cleanup;
- }
-
- if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
- goto cleanup;
-
- MPI_CHK( mpi_add_int( &Y, X, 1 ) );
- MPI_CHK( mpi_add_int( X, X, 2 ) );
- MPI_CHK( mpi_shift_r( &Y, 1 ) );
- }
- }
-
-cleanup:
-
- mpi_free( &Y, NULL );
-
- return( ret );
-}
-
-#endif
-
-#if defined(POLARSSL_SELF_TEST)
-
-#define GCD_PAIR_COUNT 3
-
-static const int gcd_pairs[GCD_PAIR_COUNT][3] =
-{
- { 693, 609, 21 },
- { 1764, 868, 28 },
- { 768454923, 542167814, 1 }
-};
-
-/*
- * Checkup routine
- */
-int mpi_self_test( int verbose )
-{
- int ret, i;
- mpi A, E, N, X, Y, U, V;
-
- mpi_init( &A, &E, &N, &X, &Y, &U, &V, NULL );
-
- MPI_CHK( mpi_read_string( &A, 16,
- "EFE021C2645FD1DC586E69184AF4A31E" \
- "D5F53E93B5F123FA41680867BA110131" \
- "944FE7952E2517337780CB0DB80E61AA" \
- "E7C8DDC6C5C6AADEB34EB38A2F40D5E6" ) );
-
- MPI_CHK( mpi_read_string( &E, 16,
- "B2E7EFD37075B9F03FF989C7C5051C20" \
- "34D2A323810251127E7BF8625A4F49A5" \
- "F3E27F4DA8BD59C47D6DAABA4C8127BD" \
- "5B5C25763222FEFCCFC38B832366C29E" ) );
-
- MPI_CHK( mpi_read_string( &N, 16,
- "0066A198186C18C10B2F5ED9B522752A" \
- "9830B69916E535C8F047518A889A43A5" \
- "94B6BED27A168D31D4A52F88925AA8F5" ) );
-
- MPI_CHK( mpi_mul_mpi( &X, &A, &N ) );
-
- MPI_CHK( mpi_read_string( &U, 16,
- "602AB7ECA597A3D6B56FF9829A5E8B85" \
- "9E857EA95A03512E2BAE7391688D264A" \
- "A5663B0341DB9CCFD2C4C5F421FEC814" \
- "8001B72E848A38CAE1C65F78E56ABDEF" \
- "E12D3C039B8A02D6BE593F0BBBDA56F1" \
- "ECF677152EF804370C1A305CAF3B5BF1" \
- "30879B56C61DE584A0F53A2447A51E" ) );
-
- if( verbose != 0 )
- printf( " MPI test #1 (mul_mpi): " );
-
- if( mpi_cmp_mpi( &X, &U ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- printf( "passed\n" );
-
- MPI_CHK( mpi_div_mpi( &X, &Y, &A, &N ) );
-
- MPI_CHK( mpi_read_string( &U, 16,
- "256567336059E52CAE22925474705F39A94" ) );
-
- MPI_CHK( mpi_read_string( &V, 16,
- "6613F26162223DF488E9CD48CC132C7A" \
- "0AC93C701B001B092E4E5B9F73BCD27B" \
- "9EE50D0657C77F374E903CDFA4C642" ) );
-
- if( verbose != 0 )
- printf( " MPI test #2 (div_mpi): " );
-
- if( mpi_cmp_mpi( &X, &U ) != 0 ||
- mpi_cmp_mpi( &Y, &V ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- printf( "passed\n" );
-
- MPI_CHK( mpi_exp_mod( &X, &A, &E, &N, NULL ) );
-
- MPI_CHK( mpi_read_string( &U, 16,
- "36E139AEA55215609D2816998ED020BB" \
- "BD96C37890F65171D948E9BC7CBAA4D9" \
- "325D24D6A3C12710F10A09FA08AB87" ) );
-
- if( verbose != 0 )
- printf( " MPI test #3 (exp_mod): " );
-
- if( mpi_cmp_mpi( &X, &U ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- printf( "passed\n" );
-
- MPI_CHK( mpi_inv_mod( &X, &A, &N ) );
-
- MPI_CHK( mpi_read_string( &U, 16,
- "003A0AAEDD7E784FC07D8F9EC6E3BFD5" \
- "C3DBA76456363A10869622EAC2DD84EC" \
- "C5B8A74DAC4D09E03B5E0BE779F2DF61" ) );
-
- if( verbose != 0 )
- printf( " MPI test #4 (inv_mod): " );
-
- if( mpi_cmp_mpi( &X, &U ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- printf( "passed\n" );
-
- if( verbose != 0 )
- printf( " MPI test #5 (simple gcd): " );
-
- for ( i = 0; i < GCD_PAIR_COUNT; i++)
- {
- MPI_CHK( mpi_lset( &X, gcd_pairs[i][0] ) );
- MPI_CHK( mpi_lset( &Y, gcd_pairs[i][1] ) );
-
- MPI_CHK( mpi_gcd( &A, &X, &Y ) );
-
- if( mpi_cmp_int( &A, gcd_pairs[i][2] ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed at %d\n", i );
-
- return( 1 );
- }
- }
-
- if( verbose != 0 )
- printf( "passed\n" );
-
-cleanup:
-
- if( ret != 0 && verbose != 0 )
- printf( "Unexpected error, return code = %08X\n", ret );
-
- mpi_free( &V, &U, &Y, &X, &N, &E, &A, NULL );
-
- if( verbose != 0 )
- printf( "\n" );
-
- return( ret );
-}
-
-#endif
-
-#endif
+++ /dev/null
-/*
- * The RSA public-key cryptosystem
- *
- * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
- *
- * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of PolarSSL or XySSL nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/*
- * RSA was designed by Ron Rivest, Adi Shamir and Len Adleman.
- *
- * http://theory.lcs.mit.edu/~rivest/rsapaper.pdf
- * http://www.cacr.math.uwaterloo.ca/hac/about/chap8.pdf
- */
-
-#include "polarssl/config.h"
-
-#if defined(POLARSSL_RSA_C)
-
-#include "polarssl/rsa.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-/*
- * Initialize an RSA context
- */
-void rsa_init( rsa_context *ctx,
- int padding,
- int hash_id,
- int (*f_rng)(void *),
- void *p_rng )
-{
- memset( ctx, 0, sizeof( rsa_context ) );
-
- ctx->padding = padding;
- ctx->hash_id = hash_id;
-
- ctx->f_rng = f_rng;
- ctx->p_rng = p_rng;
-}
-
-#if defined(POLARSSL_GENPRIME)
-
-/*
- * Generate an RSA keypair
- */
-int rsa_gen_key( rsa_context *ctx, int nbits, int exponent )
-{
- int ret;
- mpi P1, Q1, H, G;
-
- if( ctx->f_rng == NULL || nbits < 128 || exponent < 3 )
- return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
-
- mpi_init( &P1, &Q1, &H, &G, NULL );
-
- /*
- * find primes P and Q with Q < P so that:
- * GCD( E, (P-1)*(Q-1) ) == 1
- */
- MPI_CHK( mpi_lset( &ctx->E, exponent ) );
-
- do
- {
- MPI_CHK( mpi_gen_prime( &ctx->P, ( nbits + 1 ) >> 1, 0,
- ctx->f_rng, ctx->p_rng ) );
-
- MPI_CHK( mpi_gen_prime( &ctx->Q, ( nbits + 1 ) >> 1, 0,
- ctx->f_rng, ctx->p_rng ) );
-
- if( mpi_cmp_mpi( &ctx->P, &ctx->Q ) < 0 )
- mpi_swap( &ctx->P, &ctx->Q );
-
- if( mpi_cmp_mpi( &ctx->P, &ctx->Q ) == 0 )
- continue;
-
- MPI_CHK( mpi_mul_mpi( &ctx->N, &ctx->P, &ctx->Q ) );
- if( mpi_msb( &ctx->N ) != nbits )
- continue;
-
- MPI_CHK( mpi_sub_int( &P1, &ctx->P, 1 ) );
- MPI_CHK( mpi_sub_int( &Q1, &ctx->Q, 1 ) );
- MPI_CHK( mpi_mul_mpi( &H, &P1, &Q1 ) );
- MPI_CHK( mpi_gcd( &G, &ctx->E, &H ) );
- }
- while( mpi_cmp_int( &G, 1 ) != 0 );
-
- /*
- * D = E^-1 mod ((P-1)*(Q-1))
- * DP = D mod (P - 1)
- * DQ = D mod (Q - 1)
- * QP = Q^-1 mod P
- */
- MPI_CHK( mpi_inv_mod( &ctx->D , &ctx->E, &H ) );
- MPI_CHK( mpi_mod_mpi( &ctx->DP, &ctx->D, &P1 ) );
- MPI_CHK( mpi_mod_mpi( &ctx->DQ, &ctx->D, &Q1 ) );
- MPI_CHK( mpi_inv_mod( &ctx->QP, &ctx->Q, &ctx->P ) );
-
- ctx->len = ( mpi_msb( &ctx->N ) + 7 ) >> 3;
-
-cleanup:
-
- mpi_free( &G, &H, &Q1, &P1, NULL );
-
- if( ret != 0 )
- {
- rsa_free( ctx );
- return( POLARSSL_ERR_RSA_KEY_GEN_FAILED | ret );
- }
-
- return( 0 );
-}
-
-#endif
-
-/*
- * Check a public RSA key
- */
-int rsa_check_pubkey( rsa_context *ctx )
-{
- if( ( ctx->N.p[0] & 1 ) == 0 ||
- ( ctx->E.p[0] & 1 ) == 0 )
- return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
-
- if( mpi_msb( &ctx->N ) < 128 ||
- mpi_msb( &ctx->N ) > 4096 )
- return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
-
- if( mpi_msb( &ctx->E ) < 2 ||
- mpi_msb( &ctx->E ) > 64 )
- return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED );
-
- return( 0 );
-}
-
-/*
- * Check a private RSA key
- */
-int rsa_check_privkey( rsa_context *ctx )
-{
- int ret;
- mpi PQ, DE, P1, Q1, H, I, G;
-
- if( ( ret = rsa_check_pubkey( ctx ) ) != 0 )
- return( ret );
-
- mpi_init( &PQ, &DE, &P1, &Q1, &H, &I, &G, NULL );
-
- MPI_CHK( mpi_mul_mpi( &PQ, &ctx->P, &ctx->Q ) );
- MPI_CHK( mpi_mul_mpi( &DE, &ctx->D, &ctx->E ) );
- MPI_CHK( mpi_sub_int( &P1, &ctx->P, 1 ) );
- MPI_CHK( mpi_sub_int( &Q1, &ctx->Q, 1 ) );
- MPI_CHK( mpi_mul_mpi( &H, &P1, &Q1 ) );
- MPI_CHK( mpi_mod_mpi( &I, &DE, &H ) );
- MPI_CHK( mpi_gcd( &G, &ctx->E, &H ) );
-
- if( mpi_cmp_mpi( &PQ, &ctx->N ) == 0 &&
- mpi_cmp_int( &I, 1 ) == 0 &&
- mpi_cmp_int( &G, 1 ) == 0 )
- {
- mpi_free( &G, &I, &H, &Q1, &P1, &DE, &PQ, NULL );
- return( 0 );
- }
-
-cleanup:
-
- mpi_free( &G, &I, &H, &Q1, &P1, &DE, &PQ, NULL );
- return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED | ret );
-}
-
-/*
- * Do an RSA public key operation
- */
-int rsa_public( rsa_context *ctx,
- unsigned char *input,
- unsigned char *output )
-{
- int ret, olen;
- mpi T;
-
- mpi_init( &T, NULL );
-
- MPI_CHK( mpi_read_binary( &T, input, ctx->len ) );
-
- if( mpi_cmp_mpi( &T, &ctx->N ) >= 0 )
- {
- mpi_free( &T, NULL );
- return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
- }
-
- olen = ctx->len;
- MPI_CHK( mpi_exp_mod( &T, &T, &ctx->E, &ctx->N, &ctx->RN ) );
- MPI_CHK( mpi_write_binary( &T, output, olen ) );
-
-cleanup:
-
- mpi_free( &T, NULL );
-
- if( ret != 0 )
- return( POLARSSL_ERR_RSA_PUBLIC_FAILED | ret );
-
- return( 0 );
-}
-
-/*
- * Do an RSA private key operation
- */
-int rsa_private( rsa_context *ctx,
- unsigned char *input,
- unsigned char *output )
-{
- int ret, olen;
- mpi T, T1, T2;
-
- mpi_init( &T, &T1, &T2, NULL );
-
- MPI_CHK( mpi_read_binary( &T, input, ctx->len ) );
-
- if( mpi_cmp_mpi( &T, &ctx->N ) >= 0 )
- {
- mpi_free( &T, NULL );
- return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
- }
-
-#if 0
- MPI_CHK( mpi_exp_mod( &T, &T, &ctx->D, &ctx->N, &ctx->RN ) );
-#else
- /*
- * faster decryption using the CRT
- *
- * T1 = input ^ dP mod P
- * T2 = input ^ dQ mod Q
- */
- MPI_CHK( mpi_exp_mod( &T1, &T, &ctx->DP, &ctx->P, &ctx->RP ) );
- MPI_CHK( mpi_exp_mod( &T2, &T, &ctx->DQ, &ctx->Q, &ctx->RQ ) );
-
- /*
- * T = (T1 - T2) * (Q^-1 mod P) mod P
- */
- MPI_CHK( mpi_sub_mpi( &T, &T1, &T2 ) );
- MPI_CHK( mpi_mul_mpi( &T1, &T, &ctx->QP ) );
- MPI_CHK( mpi_mod_mpi( &T, &T1, &ctx->P ) );
-
- /*
- * output = T2 + T * Q
- */
- MPI_CHK( mpi_mul_mpi( &T1, &T, &ctx->Q ) );
- MPI_CHK( mpi_add_mpi( &T, &T2, &T1 ) );
-#endif
-
- olen = ctx->len;
- MPI_CHK( mpi_write_binary( &T, output, olen ) );
-
-cleanup:
-
- mpi_free( &T, &T1, &T2, NULL );
-
- if( ret != 0 )
- return( POLARSSL_ERR_RSA_PRIVATE_FAILED | ret );
-
- return( 0 );
-}
-
-/*
- * Add the message padding, then do an RSA operation
- */
-int rsa_pkcs1_encrypt( rsa_context *ctx,
- int mode, int ilen,
- unsigned char *input,
- unsigned char *output )
-{
- int nb_pad, olen;
- unsigned char *p = output;
-
- olen = ctx->len;
-
- switch( ctx->padding )
- {
- case RSA_PKCS_V15:
-
- if( ilen < 0 || olen < ilen + 11 )
- return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
-
- nb_pad = olen - 3 - ilen;
-
- *p++ = 0;
- *p++ = RSA_CRYPT;
-
- while( nb_pad-- > 0 )
- {
- do {
- *p = (unsigned char) rand();
- } while( *p == 0 );
- p++;
- }
- *p++ = 0;
- memcpy( p, input, ilen );
- break;
-
- default:
-
- return( POLARSSL_ERR_RSA_INVALID_PADDING );
- }
-
- return( ( mode == RSA_PUBLIC )
- ? rsa_public( ctx, output, output )
- : rsa_private( ctx, output, output ) );
-}
-
-/*
- * Do an RSA operation, then remove the message padding
- */
-int rsa_pkcs1_decrypt( rsa_context *ctx,
- int mode, int *olen,
- unsigned char *input,
- unsigned char *output,
- int output_max_len)
-{
- int ret, ilen;
- unsigned char *p;
- unsigned char buf[512];
-
- ilen = ctx->len;
-
- if( ilen < 16 || ilen > (int) sizeof( buf ) )
- return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
-
- ret = ( mode == RSA_PUBLIC )
- ? rsa_public( ctx, input, buf )
- : rsa_private( ctx, input, buf );
-
- if( ret != 0 )
- return( ret );
-
- p = buf;
-
- switch( ctx->padding )
- {
- case RSA_PKCS_V15:
-
- if( *p++ != 0 || *p++ != RSA_CRYPT )
- return( POLARSSL_ERR_RSA_INVALID_PADDING );
-
- while( *p != 0 )
- {
- if( p >= buf + ilen - 1 )
- return( POLARSSL_ERR_RSA_INVALID_PADDING );
- p++;
- }
- p++;
- break;
-
- default:
-
- return( POLARSSL_ERR_RSA_INVALID_PADDING );
- }
-
- if (ilen - (int)(p - buf) > output_max_len)
- return( POLARSSL_ERR_RSA_OUTPUT_TO_LARGE );
-
- *olen = ilen - (int)(p - buf);
- memcpy( output, p, *olen );
-
- return( 0 );
-}
-
-/*
- * Do an RSA operation to sign the message digest
- */
-int rsa_pkcs1_sign( rsa_context *ctx,
- int mode,
- int hash_id,
- int hashlen,
- unsigned char *hash,
- unsigned char *sig )
-{
- int nb_pad, olen;
- unsigned char *p = sig;
-
- olen = ctx->len;
-
- switch( ctx->padding )
- {
- case RSA_PKCS_V15:
-
- switch( hash_id )
- {
- case RSA_RAW:
- nb_pad = olen - 3 - hashlen;
- break;
-
- case RSA_MD2:
- case RSA_MD4:
- case RSA_MD5:
- nb_pad = olen - 3 - 34;
- break;
-
- case RSA_SHA1:
- nb_pad = olen - 3 - 35;
- break;
-
- default:
- return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
- }
-
- if( nb_pad < 8 )
- return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
-
- *p++ = 0;
- *p++ = RSA_SIGN;
- memset( p, 0xFF, nb_pad );
- p += nb_pad;
- *p++ = 0;
- break;
-
- default:
-
- return( POLARSSL_ERR_RSA_INVALID_PADDING );
- }
-
- switch( hash_id )
- {
- case RSA_RAW:
- memcpy( p, hash, hashlen );
- break;
-
- case RSA_MD2:
- memcpy( p, ASN1_HASH_MDX, 18 );
- memcpy( p + 18, hash, 16 );
- p[13] = 2; break;
-
- case RSA_MD4:
- memcpy( p, ASN1_HASH_MDX, 18 );
- memcpy( p + 18, hash, 16 );
- p[13] = 4; break;
-
- case RSA_MD5:
- memcpy( p, ASN1_HASH_MDX, 18 );
- memcpy( p + 18, hash, 16 );
- p[13] = 5; break;
-
- case RSA_SHA1:
- memcpy( p, ASN1_HASH_SHA1, 15 );
- memcpy( p + 15, hash, 20 );
- break;
-
- default:
- return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
- }
-
- return( ( mode == RSA_PUBLIC )
- ? rsa_public( ctx, sig, sig )
- : rsa_private( ctx, sig, sig ) );
-}
-
-/*
- * Do an RSA operation and check the message digest
- */
-int rsa_pkcs1_verify( rsa_context *ctx,
- int mode,
- int hash_id,
- int hashlen,
- unsigned char *hash,
- unsigned char *sig )
-{
- int ret, len, siglen;
- unsigned char *p, c;
- unsigned char buf[512];
-
- siglen = ctx->len;
-
- if( siglen < 16 || siglen > (int) sizeof( buf ) )
- return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
-
- ret = ( mode == RSA_PUBLIC )
- ? rsa_public( ctx, sig, buf )
- : rsa_private( ctx, sig, buf );
-
- if( ret != 0 )
- return( ret );
-
- p = buf;
-
- switch( ctx->padding )
- {
- case RSA_PKCS_V15:
-
- if( *p++ != 0 || *p++ != RSA_SIGN )
- return( POLARSSL_ERR_RSA_INVALID_PADDING );
-
- while( *p != 0 )
- {
- if( p >= buf + siglen - 1 || *p != 0xFF )
- return( POLARSSL_ERR_RSA_INVALID_PADDING );
- p++;
- }
- p++;
- break;
-
- default:
-
- return( POLARSSL_ERR_RSA_INVALID_PADDING );
- }
-
- len = siglen - (int)( p - buf );
-
- if( len == 34 )
- {
- c = p[13];
- p[13] = 0;
-
- if( memcmp( p, ASN1_HASH_MDX, 18 ) != 0 )
- return( POLARSSL_ERR_RSA_VERIFY_FAILED );
-
- if( ( c == 2 && hash_id == RSA_MD2 ) ||
- ( c == 4 && hash_id == RSA_MD4 ) ||
- ( c == 5 && hash_id == RSA_MD5 ) )
- {
- if( memcmp( p + 18, hash, 16 ) == 0 )
- return( 0 );
- else
- return( POLARSSL_ERR_RSA_VERIFY_FAILED );
- }
- }
-
- if( len == 35 && hash_id == RSA_SHA1 )
- {
- if( memcmp( p, ASN1_HASH_SHA1, 15 ) == 0 &&
- memcmp( p + 15, hash, 20 ) == 0 )
- return( 0 );
- else
- return( POLARSSL_ERR_RSA_VERIFY_FAILED );
- }
-
- if( len == hashlen && hash_id == RSA_RAW )
- {
- if( memcmp( p, hash, hashlen ) == 0 )
- return( 0 );
- else
- return( POLARSSL_ERR_RSA_VERIFY_FAILED );
- }
-
- return( POLARSSL_ERR_RSA_INVALID_PADDING );
-}
-
-/*
- * Free the components of an RSA key
- */
-void rsa_free( rsa_context *ctx )
-{
- mpi_free( &ctx->RQ, &ctx->RP, &ctx->RN,
- &ctx->QP, &ctx->DQ, &ctx->DP,
- &ctx->Q, &ctx->P, &ctx->D,
- &ctx->E, &ctx->N, NULL );
-}
-
-#if defined(POLARSSL_SELF_TEST)
-
-#include "polarssl/sha1.h"
-
-/*
- * Example RSA-1024 keypair, for test purposes
- */
-#define KEY_LEN 128
-
-#define RSA_N "9292758453063D803DD603D5E777D788" \
- "8ED1D5BF35786190FA2F23EBC0848AEA" \
- "DDA92CA6C3D80B32C4D109BE0F36D6AE" \
- "7130B9CED7ACDF54CFC7555AC14EEBAB" \
- "93A89813FBF3C4F8066D2D800F7C38A8" \
- "1AE31942917403FF4946B0A83D3D3E05" \
- "EE57C6F5F5606FB5D4BC6CD34EE0801A" \
- "5E94BB77B07507233A0BC7BAC8F90F79"
-
-#define RSA_E "10001"
-
-#define RSA_D "24BF6185468786FDD303083D25E64EFC" \
- "66CA472BC44D253102F8B4A9D3BFA750" \
- "91386C0077937FE33FA3252D28855837" \
- "AE1B484A8A9A45F7EE8C0C634F99E8CD" \
- "DF79C5CE07EE72C7F123142198164234" \
- "CABB724CF78B8173B9F880FC86322407" \
- "AF1FEDFDDE2BEB674CA15F3E81A1521E" \
- "071513A1E85B5DFA031F21ECAE91A34D"
-
-#define RSA_P "C36D0EB7FCD285223CFB5AABA5BDA3D8" \
- "2C01CAD19EA484A87EA4377637E75500" \
- "FCB2005C5C7DD6EC4AC023CDA285D796" \
- "C3D9E75E1EFC42488BB4F1D13AC30A57"
-
-#define RSA_Q "C000DF51A7C77AE8D7C7370C1FF55B69" \
- "E211C2B9E5DB1ED0BF61D0D9899620F4" \
- "910E4168387E3C30AA1E00C339A79508" \
- "8452DD96A9A5EA5D9DCA68DA636032AF"
-
-#define RSA_DP "C1ACF567564274FB07A0BBAD5D26E298" \
- "3C94D22288ACD763FD8E5600ED4A702D" \
- "F84198A5F06C2E72236AE490C93F07F8" \
- "3CC559CD27BC2D1CA488811730BB5725"
-
-#define RSA_DQ "4959CBF6F8FEF750AEE6977C155579C7" \
- "D8AAEA56749EA28623272E4F7D0592AF" \
- "7C1F1313CAC9471B5C523BFE592F517B" \
- "407A1BD76C164B93DA2D32A383E58357"
-
-#define RSA_QP "9AE7FBC99546432DF71896FC239EADAE" \
- "F38D18D2B2F0E2DD275AA977E2BF4411" \
- "F5A3B2A5D33605AEBBCCBA7FEB9F2D2F" \
- "A74206CEC169D74BF5A8C50D6F48EA08"
-
-#define PT_LEN 24
-#define RSA_PT "\xAA\xBB\xCC\x03\x02\x01\x00\xFF\xFF\xFF\xFF\xFF" \
- "\x11\x22\x33\x0A\x0B\x0C\xCC\xDD\xDD\xDD\xDD\xDD"
-
-/*
- * Checkup routine
- */
-int rsa_self_test( int verbose )
-{
- int len;
- rsa_context rsa;
- unsigned char sha1sum[20];
- unsigned char rsa_plaintext[PT_LEN];
- unsigned char rsa_decrypted[PT_LEN];
- unsigned char rsa_ciphertext[KEY_LEN];
-
- memset( &rsa, 0, sizeof( rsa_context ) );
-
- rsa.len = KEY_LEN;
- mpi_read_string( &rsa.N , 16, RSA_N );
- mpi_read_string( &rsa.E , 16, RSA_E );
- mpi_read_string( &rsa.D , 16, RSA_D );
- mpi_read_string( &rsa.P , 16, RSA_P );
- mpi_read_string( &rsa.Q , 16, RSA_Q );
- mpi_read_string( &rsa.DP, 16, RSA_DP );
- mpi_read_string( &rsa.DQ, 16, RSA_DQ );
- mpi_read_string( &rsa.QP, 16, RSA_QP );
-
- if( verbose != 0 )
- printf( " RSA key validation: " );
-
- if( rsa_check_pubkey( &rsa ) != 0 ||
- rsa_check_privkey( &rsa ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- printf( "passed\n PKCS#1 encryption : " );
-
- memcpy( rsa_plaintext, RSA_PT, PT_LEN );
-
- if( rsa_pkcs1_encrypt( &rsa, RSA_PUBLIC, PT_LEN,
- rsa_plaintext, rsa_ciphertext ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- printf( "passed\n PKCS#1 decryption : " );
-
- if( rsa_pkcs1_decrypt( &rsa, RSA_PRIVATE, &len,
- rsa_ciphertext, rsa_decrypted,
- sizeof(rsa_decrypted) ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( memcmp( rsa_decrypted, rsa_plaintext, len ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- printf( "passed\n PKCS#1 data sign : " );
-
- sha1( rsa_plaintext, PT_LEN, sha1sum );
-
- if( rsa_pkcs1_sign( &rsa, RSA_PRIVATE, RSA_SHA1, 20,
- sha1sum, rsa_ciphertext ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- printf( "passed\n PKCS#1 sig. verify: " );
-
- if( rsa_pkcs1_verify( &rsa, RSA_PUBLIC, RSA_SHA1, 20,
- sha1sum, rsa_ciphertext ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- printf( "passed\n\n" );
-
- rsa_free( &rsa );
-
- return( 0 );
-}
-
-#endif
-
-#endif
+++ /dev/null
-/*
- * FIPS-180-1 compliant SHA-1 implementation
- *
- * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
- *
- * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of PolarSSL or XySSL nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/*
- * The SHA-1 standard was published by NIST in 1993.
- *
- * http://www.itl.nist.gov/fipspubs/fip180-1.htm
- */
-
-#include "polarssl/config.h"
-
-#if defined(POLARSSL_SHA1_C)
-
-#include "polarssl/sha1.h"
-
-#include <string.h>
-#include <stdio.h>
-
-/*
- * 32-bit integer manipulation macros (big endian)
- */
-#ifndef GET_ULONG_BE
-#define GET_ULONG_BE(n,b,i) \
-{ \
- (n) = ( (unsigned long) (b)[(i) ] << 24 ) \
- | ( (unsigned long) (b)[(i) + 1] << 16 ) \
- | ( (unsigned long) (b)[(i) + 2] << 8 ) \
- | ( (unsigned long) (b)[(i) + 3] ); \
-}
-#endif
-
-#ifndef PUT_ULONG_BE
-#define PUT_ULONG_BE(n,b,i) \
-{ \
- (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
- (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
- (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
- (b)[(i) + 3] = (unsigned char) ( (n) ); \
-}
-#endif
-
-/*
- * SHA-1 context setup
- */
-void sha1_starts( sha1_context *ctx )
-{
- ctx->total[0] = 0;
- ctx->total[1] = 0;
-
- ctx->state[0] = 0x67452301;
- ctx->state[1] = 0xEFCDAB89;
- ctx->state[2] = 0x98BADCFE;
- ctx->state[3] = 0x10325476;
- ctx->state[4] = 0xC3D2E1F0;
-}
-
-static void sha1_process( sha1_context *ctx, unsigned char data[64] )
-{
- unsigned long temp, W[16], A, B, C, D, E;
-
- GET_ULONG_BE( W[ 0], data, 0 );
- GET_ULONG_BE( W[ 1], data, 4 );
- GET_ULONG_BE( W[ 2], data, 8 );
- GET_ULONG_BE( W[ 3], data, 12 );
- GET_ULONG_BE( W[ 4], data, 16 );
- GET_ULONG_BE( W[ 5], data, 20 );
- GET_ULONG_BE( W[ 6], data, 24 );
- GET_ULONG_BE( W[ 7], data, 28 );
- GET_ULONG_BE( W[ 8], data, 32 );
- GET_ULONG_BE( W[ 9], data, 36 );
- GET_ULONG_BE( W[10], data, 40 );
- GET_ULONG_BE( W[11], data, 44 );
- GET_ULONG_BE( W[12], data, 48 );
- GET_ULONG_BE( W[13], data, 52 );
- GET_ULONG_BE( W[14], data, 56 );
- GET_ULONG_BE( W[15], data, 60 );
-
-#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
-
-#define R(t) \
-( \
- temp = W[(t - 3) & 0x0F] ^ W[(t - 8) & 0x0F] ^ \
- W[(t - 14) & 0x0F] ^ W[ t & 0x0F], \
- ( W[t & 0x0F] = S(temp,1) ) \
-)
-
-#define P(a,b,c,d,e,x) \
-{ \
- e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \
-}
-
- A = ctx->state[0];
- B = ctx->state[1];
- C = ctx->state[2];
- D = ctx->state[3];
- E = ctx->state[4];
-
-#define F(x,y,z) (z ^ (x & (y ^ z)))
-#define K 0x5A827999
-
- P( A, B, C, D, E, W[0] );
- P( E, A, B, C, D, W[1] );
- P( D, E, A, B, C, W[2] );
- P( C, D, E, A, B, W[3] );
- P( B, C, D, E, A, W[4] );
- P( A, B, C, D, E, W[5] );
- P( E, A, B, C, D, W[6] );
- P( D, E, A, B, C, W[7] );
- P( C, D, E, A, B, W[8] );
- P( B, C, D, E, A, W[9] );
- P( A, B, C, D, E, W[10] );
- P( E, A, B, C, D, W[11] );
- P( D, E, A, B, C, W[12] );
- P( C, D, E, A, B, W[13] );
- P( B, C, D, E, A, W[14] );
- P( A, B, C, D, E, W[15] );
- P( E, A, B, C, D, R(16) );
- P( D, E, A, B, C, R(17) );
- P( C, D, E, A, B, R(18) );
- P( B, C, D, E, A, R(19) );
-
-#undef K
-#undef F
-
-#define F(x,y,z) (x ^ y ^ z)
-#define K 0x6ED9EBA1
-
- P( A, B, C, D, E, R(20) );
- P( E, A, B, C, D, R(21) );
- P( D, E, A, B, C, R(22) );
- P( C, D, E, A, B, R(23) );
- P( B, C, D, E, A, R(24) );
- P( A, B, C, D, E, R(25) );
- P( E, A, B, C, D, R(26) );
- P( D, E, A, B, C, R(27) );
- P( C, D, E, A, B, R(28) );
- P( B, C, D, E, A, R(29) );
- P( A, B, C, D, E, R(30) );
- P( E, A, B, C, D, R(31) );
- P( D, E, A, B, C, R(32) );
- P( C, D, E, A, B, R(33) );
- P( B, C, D, E, A, R(34) );
- P( A, B, C, D, E, R(35) );
- P( E, A, B, C, D, R(36) );
- P( D, E, A, B, C, R(37) );
- P( C, D, E, A, B, R(38) );
- P( B, C, D, E, A, R(39) );
-
-#undef K
-#undef F
-
-#define F(x,y,z) ((x & y) | (z & (x | y)))
-#define K 0x8F1BBCDC
-
- P( A, B, C, D, E, R(40) );
- P( E, A, B, C, D, R(41) );
- P( D, E, A, B, C, R(42) );
- P( C, D, E, A, B, R(43) );
- P( B, C, D, E, A, R(44) );
- P( A, B, C, D, E, R(45) );
- P( E, A, B, C, D, R(46) );
- P( D, E, A, B, C, R(47) );
- P( C, D, E, A, B, R(48) );
- P( B, C, D, E, A, R(49) );
- P( A, B, C, D, E, R(50) );
- P( E, A, B, C, D, R(51) );
- P( D, E, A, B, C, R(52) );
- P( C, D, E, A, B, R(53) );
- P( B, C, D, E, A, R(54) );
- P( A, B, C, D, E, R(55) );
- P( E, A, B, C, D, R(56) );
- P( D, E, A, B, C, R(57) );
- P( C, D, E, A, B, R(58) );
- P( B, C, D, E, A, R(59) );
-
-#undef K
-#undef F
-
-#define F(x,y,z) (x ^ y ^ z)
-#define K 0xCA62C1D6
-
- P( A, B, C, D, E, R(60) );
- P( E, A, B, C, D, R(61) );
- P( D, E, A, B, C, R(62) );
- P( C, D, E, A, B, R(63) );
- P( B, C, D, E, A, R(64) );
- P( A, B, C, D, E, R(65) );
- P( E, A, B, C, D, R(66) );
- P( D, E, A, B, C, R(67) );
- P( C, D, E, A, B, R(68) );
- P( B, C, D, E, A, R(69) );
- P( A, B, C, D, E, R(70) );
- P( E, A, B, C, D, R(71) );
- P( D, E, A, B, C, R(72) );
- P( C, D, E, A, B, R(73) );
- P( B, C, D, E, A, R(74) );
- P( A, B, C, D, E, R(75) );
- P( E, A, B, C, D, R(76) );
- P( D, E, A, B, C, R(77) );
- P( C, D, E, A, B, R(78) );
- P( B, C, D, E, A, R(79) );
-
-#undef K
-#undef F
-
- ctx->state[0] += A;
- ctx->state[1] += B;
- ctx->state[2] += C;
- ctx->state[3] += D;
- ctx->state[4] += E;
-}
-
-/*
- * SHA-1 process buffer
- */
-void sha1_update( sha1_context *ctx, unsigned char *input, int ilen )
-{
- int fill;
- unsigned long left;
-
- if( ilen <= 0 )
- return;
-
- left = ctx->total[0] & 0x3F;
- fill = 64 - left;
-
- ctx->total[0] += ilen;
- ctx->total[0] &= 0xFFFFFFFF;
-
- if( ctx->total[0] < (unsigned long) ilen )
- ctx->total[1]++;
-
- if( left && ilen >= fill )
- {
- memcpy( (void *) (ctx->buffer + left),
- (void *) input, fill );
- sha1_process( ctx, ctx->buffer );
- input += fill;
- ilen -= fill;
- left = 0;
- }
-
- while( ilen >= 64 )
- {
- sha1_process( ctx, input );
- input += 64;
- ilen -= 64;
- }
-
- if( ilen > 0 )
- {
- memcpy( (void *) (ctx->buffer + left),
- (void *) input, ilen );
- }
-}
-
-static const unsigned char sha1_padding[64] =
-{
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-/*
- * SHA-1 final digest
- */
-void sha1_finish( sha1_context *ctx, unsigned char output[20] )
-{
- unsigned long last, padn;
- unsigned long high, low;
- unsigned char msglen[8];
-
- high = ( ctx->total[0] >> 29 )
- | ( ctx->total[1] << 3 );
- low = ( ctx->total[0] << 3 );
-
- PUT_ULONG_BE( high, msglen, 0 );
- PUT_ULONG_BE( low, msglen, 4 );
-
- last = ctx->total[0] & 0x3F;
- padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
-
- sha1_update( ctx, (unsigned char *) sha1_padding, padn );
- sha1_update( ctx, msglen, 8 );
-
- PUT_ULONG_BE( ctx->state[0], output, 0 );
- PUT_ULONG_BE( ctx->state[1], output, 4 );
- PUT_ULONG_BE( ctx->state[2], output, 8 );
- PUT_ULONG_BE( ctx->state[3], output, 12 );
- PUT_ULONG_BE( ctx->state[4], output, 16 );
-}
-
-/*
- * output = SHA-1( input buffer )
- */
-void sha1( unsigned char *input, int ilen, unsigned char output[20] )
-{
- sha1_context ctx;
-
- sha1_starts( &ctx );
- sha1_update( &ctx, input, ilen );
- sha1_finish( &ctx, output );
-
- memset( &ctx, 0, sizeof( sha1_context ) );
-}
-
-/*
- * output = SHA-1( file contents )
- */
-int sha1_file( char *path, unsigned char output[20] )
-{
- FILE *f;
- size_t n;
- sha1_context ctx;
- unsigned char buf[1024];
-
- if( ( f = fopen( path, "rb" ) ) == NULL )
- return( 1 );
-
- sha1_starts( &ctx );
-
- while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
- sha1_update( &ctx, buf, (int) n );
-
- sha1_finish( &ctx, output );
-
- memset( &ctx, 0, sizeof( sha1_context ) );
-
- if( ferror( f ) != 0 )
- {
- fclose( f );
- return( 2 );
- }
-
- fclose( f );
- return( 0 );
-}
-
-/*
- * SHA-1 HMAC context setup
- */
-void sha1_hmac_starts( sha1_context *ctx, unsigned char *key, int keylen )
-{
- int i;
- unsigned char sum[20];
-
- if( keylen > 64 )
- {
- sha1( key, keylen, sum );
- keylen = 20;
- key = sum;
- }
-
- memset( ctx->ipad, 0x36, 64 );
- memset( ctx->opad, 0x5C, 64 );
-
- for( i = 0; i < keylen; i++ )
- {
- ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] );
- ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] );
- }
-
- sha1_starts( ctx );
- sha1_update( ctx, ctx->ipad, 64 );
-
- memset( sum, 0, sizeof( sum ) );
-}
-
-/*
- * SHA-1 HMAC process buffer
- */
-void sha1_hmac_update( sha1_context *ctx, unsigned char *input, int ilen )
-{
- sha1_update( ctx, input, ilen );
-}
-
-/*
- * SHA-1 HMAC final digest
- */
-void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] )
-{
- unsigned char tmpbuf[20];
-
- sha1_finish( ctx, tmpbuf );
- sha1_starts( ctx );
- sha1_update( ctx, ctx->opad, 64 );
- sha1_update( ctx, tmpbuf, 20 );
- sha1_finish( ctx, output );
-
- memset( tmpbuf, 0, sizeof( tmpbuf ) );
-}
-
-/*
- * output = HMAC-SHA-1( hmac key, input buffer )
- */
-void sha1_hmac( unsigned char *key, int keylen,
- unsigned char *input, int ilen,
- unsigned char output[20] )
-{
- sha1_context ctx;
-
- sha1_hmac_starts( &ctx, key, keylen );
- sha1_hmac_update( &ctx, input, ilen );
- sha1_hmac_finish( &ctx, output );
-
- memset( &ctx, 0, sizeof( sha1_context ) );
-}
-
-#if defined(POLARSSL_SELF_TEST)
-/*
- * FIPS-180-1 test vectors
- */
-static unsigned char sha1_test_buf[3][57] =
-{
- { "abc" },
- { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" },
- { "" }
-};
-
-static const int sha1_test_buflen[3] =
-{
- 3, 56, 1000
-};
-
-static const unsigned char sha1_test_sum[3][20] =
-{
- { 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E,
- 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D },
- { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE,
- 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1 },
- { 0x34, 0xAA, 0x97, 0x3C, 0xD4, 0xC4, 0xDA, 0xA4, 0xF6, 0x1E,
- 0xEB, 0x2B, 0xDB, 0xAD, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6F }
-};
-
-/*
- * RFC 2202 test vectors
- */
-static unsigned char sha1_hmac_test_key[7][26] =
-{
- { "\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B"
- "\x0B\x0B\x0B\x0B" },
- { "Jefe" },
- { "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
- "\xAA\xAA\xAA\xAA" },
- { "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10"
- "\x11\x12\x13\x14\x15\x16\x17\x18\x19" },
- { "\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C"
- "\x0C\x0C\x0C\x0C" },
- { "" }, /* 0xAA 80 times */
- { "" }
-};
-
-static const int sha1_hmac_test_keylen[7] =
-{
- 20, 4, 20, 25, 20, 80, 80
-};
-
-static unsigned char sha1_hmac_test_buf[7][74] =
-{
- { "Hi There" },
- { "what do ya want for nothing?" },
- { "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
- "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
- "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
- "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"
- "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" },
- { "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
- "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
- "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
- "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
- "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" },
- { "Test With Truncation" },
- { "Test Using Larger Than Block-Size Key - Hash Key First" },
- { "Test Using Larger Than Block-Size Key and Larger"
- " Than One Block-Size Data" }
-};
-
-static const int sha1_hmac_test_buflen[7] =
-{
- 8, 28, 50, 50, 20, 54, 73
-};
-
-static const unsigned char sha1_hmac_test_sum[7][20] =
-{
- { 0xB6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64, 0xE2, 0x8B,
- 0xC0, 0xB6, 0xFB, 0x37, 0x8C, 0x8E, 0xF1, 0x46, 0xBE, 0x00 },
- { 0xEF, 0xFC, 0xDF, 0x6A, 0xE5, 0xEB, 0x2F, 0xA2, 0xD2, 0x74,
- 0x16, 0xD5, 0xF1, 0x84, 0xDF, 0x9C, 0x25, 0x9A, 0x7C, 0x79 },
- { 0x12, 0x5D, 0x73, 0x42, 0xB9, 0xAC, 0x11, 0xCD, 0x91, 0xA3,
- 0x9A, 0xF4, 0x8A, 0xA1, 0x7B, 0x4F, 0x63, 0xF1, 0x75, 0xD3 },
- { 0x4C, 0x90, 0x07, 0xF4, 0x02, 0x62, 0x50, 0xC6, 0xBC, 0x84,
- 0x14, 0xF9, 0xBF, 0x50, 0xC8, 0x6C, 0x2D, 0x72, 0x35, 0xDA },
- { 0x4C, 0x1A, 0x03, 0x42, 0x4B, 0x55, 0xE0, 0x7F, 0xE7, 0xF2,
- 0x7B, 0xE1 },
- { 0xAA, 0x4A, 0xE5, 0xE1, 0x52, 0x72, 0xD0, 0x0E, 0x95, 0x70,
- 0x56, 0x37, 0xCE, 0x8A, 0x3B, 0x55, 0xED, 0x40, 0x21, 0x12 },
- { 0xE8, 0xE9, 0x9D, 0x0F, 0x45, 0x23, 0x7D, 0x78, 0x6D, 0x6B,
- 0xBA, 0xA7, 0x96, 0x5C, 0x78, 0x08, 0xBB, 0xFF, 0x1A, 0x91 }
-};
-
-/*
- * Checkup routine
- */
-int sha1_self_test( int verbose )
-{
- int i, j, buflen;
- unsigned char buf[1024];
- unsigned char sha1sum[20];
- sha1_context ctx;
-
- /*
- * SHA-1
- */
- for( i = 0; i < 3; i++ )
- {
- if( verbose != 0 )
- printf( " SHA-1 test #%d: ", i + 1 );
-
- sha1_starts( &ctx );
-
- if( i == 2 )
- {
- memset( buf, 'a', buflen = 1000 );
-
- for( j = 0; j < 1000; j++ )
- sha1_update( &ctx, buf, buflen );
- }
- else
- sha1_update( &ctx, sha1_test_buf[i],
- sha1_test_buflen[i] );
-
- sha1_finish( &ctx, sha1sum );
-
- if( memcmp( sha1sum, sha1_test_sum[i], 20 ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- printf( "passed\n" );
- }
-
- if( verbose != 0 )
- printf( "\n" );
-
- for( i = 0; i < 7; i++ )
- {
- if( verbose != 0 )
- printf( " HMAC-SHA-1 test #%d: ", i + 1 );
-
- if( i == 5 || i == 6 )
- {
- memset( buf, '\xAA', buflen = 80 );
- sha1_hmac_starts( &ctx, buf, buflen );
- }
- else
- sha1_hmac_starts( &ctx, sha1_hmac_test_key[i],
- sha1_hmac_test_keylen[i] );
-
- sha1_hmac_update( &ctx, sha1_hmac_test_buf[i],
- sha1_hmac_test_buflen[i] );
-
- sha1_hmac_finish( &ctx, sha1sum );
-
- buflen = ( i == 4 ) ? 12 : 20;
-
- if( memcmp( sha1sum, sha1_hmac_test_sum[i], buflen ) != 0 )
- {
- if( verbose != 0 )
- printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- printf( "passed\n" );
- }
-
- if( verbose != 0 )
- printf( "\n" );
-
- return( 0 );
-}
-
-#endif
-
-#endif
+++ /dev/null
-/*
- * Portable interface to the CPU cycle counter
- *
- * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
- *
- * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of PolarSSL or XySSL nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "polarssl/config.h"
-
-#if defined(POLARSSL_TIMING_C)
-
-#include "polarssl/timing.h"
-
-#if defined(WIN32)
-
-#include <windows.h>
-#include <winbase.h>
-
-struct _hr_time
-{
- LARGE_INTEGER start;
-};
-
-#else
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <signal.h>
-#include <time.h>
-
-struct _hr_time
-{
- struct timeval start;
-};
-
-#endif
-
-#if (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
-
-unsigned long hardclock( void )
-{
- unsigned long tsc;
- __asm rdtsc
- __asm mov [tsc], eax
- return( tsc );
-}
-
-#else
-#if defined(__GNUC__) && defined(__i386__)
-
-unsigned long hardclock( void )
-{
- unsigned long tsc;
- asm( "rdtsc" : "=a" (tsc) );
- return( tsc );
-}
-
-#else
-#if defined(__GNUC__) && (defined(__amd64__) || defined(__x86_64__))
-
-unsigned long hardclock( void )
-{
- unsigned long lo, hi;
- asm( "rdtsc" : "=a" (lo), "=d" (hi) );
- return( lo | (hi << 32) );
-}
-
-#else
-#if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
-
-unsigned long hardclock( void )
-{
- unsigned long tbl, tbu0, tbu1;
-
- do
- {
- asm( "mftbu %0" : "=r" (tbu0) );
- asm( "mftb %0" : "=r" (tbl ) );
- asm( "mftbu %0" : "=r" (tbu1) );
- }
- while( tbu0 != tbu1 );
-
- return( tbl );
-}
-
-#else
-#if defined(__GNUC__) && defined(__sparc__)
-
-unsigned long hardclock( void )
-{
- unsigned long tick;
- asm( ".byte 0x83, 0x41, 0x00, 0x00" );
- asm( "mov %%g1, %0" : "=r" (tick) );
- return( tick );
-}
-
-#else
-#if defined(__GNUC__) && defined(__alpha__)
-
-unsigned long hardclock( void )
-{
- unsigned long cc;
- asm( "rpcc %0" : "=r" (cc) );
- return( cc & 0xFFFFFFFF );
-}
-
-#else
-#if defined(__GNUC__) && defined(__ia64__)
-
-unsigned long hardclock( void )
-{
- unsigned long itc;
- asm( "mov %0 = ar.itc" : "=r" (itc) );
- return( itc );
-}
-
-#else
-
-static int hardclock_init = 0;
-static struct timeval tv_init;
-
-unsigned long hardclock( void )
-{
- struct timeval tv_cur;
-
- if( hardclock_init == 0 )
- {
- gettimeofday( &tv_init, NULL );
- hardclock_init = 1;
- }
-
- gettimeofday( &tv_cur, NULL );
- return( ( tv_cur.tv_sec - tv_init.tv_sec ) * 1000000
- + ( tv_cur.tv_usec - tv_init.tv_usec ) );
-}
-
-#endif /* generic */
-#endif /* IA-64 */
-#endif /* Alpha */
-#endif /* SPARC8 */
-#endif /* PowerPC */
-#endif /* AMD64 */
-#endif /* i586+ */
-
-int alarmed = 0;
-
-#if defined(WIN32)
-
-unsigned long get_timer( struct hr_time *val, int reset )
-{
- unsigned long delta;
- LARGE_INTEGER offset, hfreq;
- struct _hr_time *t = (struct _hr_time *) val;
-
- QueryPerformanceCounter( &offset );
- QueryPerformanceFrequency( &hfreq );
-
- delta = (unsigned long)( ( 1000 *
- ( offset.QuadPart - t->start.QuadPart ) ) /
- hfreq.QuadPart );
-
- if( reset )
- QueryPerformanceCounter( &t->start );
-
- return( delta );
-}
-
-DWORD WINAPI TimerProc( LPVOID uElapse )
-{
- Sleep( (DWORD) uElapse );
- alarmed = 1;
- return( TRUE );
-}
-
-void set_alarm( int seconds )
-{
- DWORD ThreadId;
-
- alarmed = 0;
- CloseHandle( CreateThread( NULL, 0, TimerProc,
- (LPVOID) ( seconds * 1000 ), 0, &ThreadId ) );
-}
-
-void m_sleep( int milliseconds )
-{
- Sleep( milliseconds );
-}
-
-#else
-
-unsigned long get_timer( struct hr_time *val, int reset )
-{
- unsigned long delta;
- struct timeval offset;
- struct _hr_time *t = (struct _hr_time *) val;
-
- gettimeofday( &offset, NULL );
-
- delta = ( offset.tv_sec - t->start.tv_sec ) * 1000
- + ( offset.tv_usec - t->start.tv_usec ) / 1000;
-
- if( reset )
- {
- t->start.tv_sec = offset.tv_sec;
- t->start.tv_usec = offset.tv_usec;
- }
-
- return( delta );
-}
-
-static void sighandler( int signum )
-{
- alarmed = 1;
- signal( signum, sighandler );
-}
-
-void set_alarm( int seconds )
-{
- alarmed = 0;
- signal( SIGALRM, sighandler );
- alarm( seconds );
-}
-
-void m_sleep( int milliseconds )
-{
- struct timeval tv;
-
- tv.tv_sec = milliseconds / 1000;
- tv.tv_usec = milliseconds * 1000;
-
- select( 0, NULL, NULL, NULL, &tv );
-}
-
-#endif
-
-#endif
+++ /dev/null
-/*
- * X.509 certificate and private key writing
- *
- * Copyright (C) 2006-2007 Pascal Vizeli <pvizeli@yahoo.de>
- * Modifications (C) 2009 Steven Barth <steven@midlink.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License, version 2.1 as published by the Free Software Foundation.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-/*
- * The ITU-T X.509 standard defines a certificat format for PKI.
- *
- * http://www.ietf.org/rfc/rfc2459.txt
- * http://www.ietf.org/rfc/rfc3279.txt
- *
- * ftp://ftp.rsasecurity.com/pub/pkcs/ascii/pkcs-1v2.asc
- *
- * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf
- * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf
- *
- * For CRS:
- * http://www.faqs.org/rfcs/rfc2314.html
- */
-#include "polarssl/config.h"
-#include "polarssl/x509.h"
-#include "polarssl/base64.h"
-#include "polarssl/sha1.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <time.h>
-
-#define and &&
-#define or ||
-
-#if defined _MSC_VER && !defined snprintf
-#define snprintf _snprintf
-#endif
-
-static int x509write_realloc_node(x509_node *node, size_t larger);
-static int x509write_file(x509_node *node, char *path, int format, const char* pem_prolog, const char* pem_epilog);
-
-/*
- * evaluate how mani octet have this integer
- */
-static int asn1_eval_octet(unsigned int digit)
-{
- int i, byte;
-
- for (byte = 4, i = 24; i >= 0; i -= 8, --byte)
- if (((digit >> i) & 0xFF) != 0)
- return byte;
-
- return 0;
-}
-
-/*
- * write the asn.1 lenght form into p
- */
-static int asn1_add_len(unsigned int size, x509_node *node)
-{
- if (size > 127) {
-
- /* long size */
- int byte = asn1_eval_octet(size);
- int i = 0;
-
- *(node->p) = (0x80 | byte) & 0xFF;
- ++node->p;
-
- for (i = byte; i > 0; --i) {
-
- *(node->p) = (size >> ((i - 1) * 8)) & 0xFF;
- ++node->p;
- }
-
- } else {
-
- /* short size */
- *(node->p) = size & 0xFF;
- if (size != 0)
- ++node->p;
- }
-
- return 0;
-}
-
-/*
- * write a ans.1 object into p
- */
-static int asn1_add_obj(unsigned char *value, unsigned int size, int tag,
- x509_node *node)
-{
- int tl = 2;
-
- if (tag == ASN1_BIT_STRING)
- ++tl;
-
- if (size > 127)
- x509write_realloc_node(node, (size_t) size + tl +
- asn1_eval_octet(size));
- else
- x509write_realloc_node(node, (size_t) size + tl);
-
- if (node->data == NULL)
- return 1;
-
- /* tag */
- *(node->p) = tag & 0xFF;
- ++node->p;
-
- /* len */
- if (tag == ASN1_BIT_STRING) {
- asn1_add_len((unsigned int) size + 1, node);
- *(node->p) = 0x00;
- ++node->p;
- } else {
- asn1_add_len((unsigned int) size, node);
- }
-
- /* value */
- if (size > 0) {
-
- memcpy(node->p, value, (size_t) size);
- if ((node->p += size -1) != node->end)
- return POLARSSL_ERR_X509_POINT_ERROR;
- } else {
- /* make nothing -> NULL */
- }
-
- return 0;
-}
-
-/*
- * write a asn.1 conform integer object
- */
-static int asn1_add_int(signed int value, x509_node *node)
-{
- signed int i = 0, neg = 1;
- unsigned int byte, u_val = 0, tmp_val = 0;
-
- /* if negate? */
- if (value < 0) {
- neg = -1;
- u_val = ~value;
- } else {
- u_val = value;
- }
-
- byte = asn1_eval_octet(u_val);
- /* 0 isn't NULL */
- if (byte == 0)
- byte = 1;
-
- /* ASN.1 integer is signed! */
- if (byte < 4 and ((u_val >> ((byte -1) * 8)) & 0xFF) == 0x80)
- byte += 1;
-
- if (x509write_realloc_node(node, (size_t) byte + 2) != 0)
- return 1;
-
- /* tag */
- *(node->p) = ASN1_INTEGER;
- ++node->p;
-
- /* len */
- asn1_add_len(byte, node);
-
- /* value */
- for (i = byte; i > 0; --i) {
-
- tmp_val = (u_val >> ((i - 1) * 8)) & 0xFF;
- if (neg == 1)
- *(node->p) = tmp_val;
- else
- *(node->p) = ~tmp_val;
-
- if (i > 1)
- ++node->p;
- }
-
- if (node->p != node->end)
- return POLARSSL_ERR_X509_POINT_ERROR;
-
- return 0;
-}
-
-/*
- * write a asn.1 conform mpi object
- */
-static int asn1_add_mpi(mpi *value, int tag, x509_node *node)
-{
- size_t size = (mpi_msb(value) / 8) + 1;
- unsigned char *buf;
- int buf_len = (int) size, tl = 2;
-
- if (tag == ASN1_BIT_STRING)
- ++tl;
-
- if (size > 127)
- x509write_realloc_node(node, size + (size_t) tl +
- asn1_eval_octet((unsigned int)size));
- else
- x509write_realloc_node(node, size + (size_t) tl);
-
- if (node->data == NULL)
- return 1;
-
- buf = (unsigned char*) malloc(size);
- if (mpi_write_binary(value, buf, buf_len) != 0)
- return POLARSSL_ERR_MPI_BUFFER_TOO_SMALL;
-
- /* tag */
- *(node->p) = tag & 0xFF;
- ++node->p;
-
- /* len */
- if (tag == ASN1_BIT_STRING) {
- asn1_add_len((unsigned int) size + 1, node);
- *(node->p) = 0x00;
- ++node->p;
- } else {
- asn1_add_len((unsigned int) size, node);
- }
-
- /* value */
- memcpy(node->p, buf, size);
- free(buf);
-
- if ((node->p += (int) size -1) != node->end)
- return POLARSSL_ERR_X509_POINT_ERROR;
-
- return 0;
-}
-
-/*
- * write a node into asn.1 conform object
- */
-static int asn1_append_tag(x509_node *node, int tag)
-{
- int tl = 2;
-
- x509_node tmp;
- x509write_init_node(&tmp);
-
- if (tag == ASN1_BIT_STRING)
- ++tl;
-
- if (node->len > 127)
- x509write_realloc_node(&tmp, node->len + (size_t) tl +
- asn1_eval_octet((unsigned int)node->len));
- else
- x509write_realloc_node(&tmp, node->len + (size_t) tl);
-
- if (tmp.data == NULL) {
- x509write_free_node(&tmp);
- return 1;
- }
-
- /* tag */
- *(tmp.p) = tag & 0xFF;
- ++tmp.p;
-
- /* len */
- if (tag == ASN1_BIT_STRING) {
- asn1_add_len((unsigned int) node->len + 1, &tmp);
- *(tmp.p) = 0x00;
- ++tmp.p;
- } else {
- asn1_add_len((unsigned int) node->len, &tmp);
- }
-
- /* value */
- memcpy(tmp.p, node->data, node->len);
-
- /* good? */
- if ((tmp.p += (int) node->len -1) != tmp.end) {
- x509write_free_node(&tmp);
- return POLARSSL_ERR_X509_POINT_ERROR;
- }
-
- free(node->data);
- node->data = tmp.data;
- node->p = tmp.p;
- node->end = tmp.end;
- node->len = tmp.len;
-
- return 0;
-}
-
-/*
- * write nodes into a asn.1 object
- */
-static int asn1_append_nodes(x509_node *node, int tag, int anz, ...)
-{
- va_list ap;
- size_t size = 0;
- x509_node *tmp;
- int count;
-
- va_start(ap, anz);
- count = anz;
-
- while (count--) {
-
- tmp = va_arg(ap, x509_node*);
- if (tmp->data != NULL)
- size += tmp->len;
- }
-
- if ( size > 127) {
- if (x509write_realloc_node(node, size + (size_t) 2 +
- asn1_eval_octet(size)) != 0)
- return 1;
- } else {
- if (x509write_realloc_node(node, size + (size_t) 2) != 0)
- return 1;
- }
-
- /* tag */
- *(node->p) = tag & 0xFF;
- ++node->p;
-
- /* len */
- asn1_add_len(size, node);
-
- /* value */
- va_start(ap, anz);
- count = anz;
-
- while (count--) {
-
- tmp = va_arg(ap, x509_node*);
- if (tmp->data != NULL) {
-
- memcpy(node->p, tmp->data, tmp->len);
- if ((node->p += (int) tmp->len -1) != node->end)
- ++node->p;
- }
- }
-
- va_end(ap);
- return 0;
-}
-
-/*
- * write a ASN.1 conform object identifiere include a "tag"
- */
-static int asn1_add_oid(x509_node *node, unsigned char *oid, size_t len,
- int tag, int tag_val, unsigned char *value, size_t val_len)
-{
- int ret;
- x509_node tmp;
-
- x509write_init_node(&tmp);
-
- /* OBJECT IDENTIFIER */
- if ((ret = asn1_add_obj(oid, len, ASN1_OID, &tmp)) != 0) {
- x509write_free_node(&tmp);
- return ret;
- }
-
- /* value */
- if ((ret = asn1_add_obj(value, val_len, tag_val, &tmp)) != 0) {
- x509write_free_node(&tmp);
- return ret;
- }
-
- /* SET/SEQUENCE */
- if ((ret = asn1_append_nodes(node, tag, 1, &tmp)) != 0) {
- x509write_free_node(&tmp);
- return ret;
- }
-
- x509write_free_node(&tmp);
- return 0;
-}
-
-/*
- * utcTime UTCTime
- */
-static int asn1_add_date_utc(unsigned char *time, x509_node *node)
-{
- unsigned char date[13], *sp;
- x509_time xtime;
- int ret;
-
- sscanf((char*)time, "%d-%d-%d %d:%d:%d", &xtime.year, &xtime.mon,
- &xtime.day, &xtime.hour, &xtime.min, &xtime.sec);
-
- /* convert to YY */
- if (xtime.year > 2000)
- xtime.year -= 2000;
- else
- xtime.year -= 1900;
-
- snprintf((char*)date, 13, "%2d%2d%2d%2d%2d%2d", xtime.year, xtime.mon, xtime.day,
- xtime.hour, xtime.min, xtime.sec);
-
- /* replace ' ' to '0' */
- for (sp = date; *sp != '\0'; ++sp)
- if (*sp == '\x20')
- *sp = '\x30';
-
- date[12] = 'Z';
-
- if ((ret = asn1_add_obj(date, 13, ASN1_UTC_TIME, node)) != 0)
- return ret;
-
- return 0;
-}
-
-/*
- * serialize an rsa key into DER
- */
-
-int x509write_serialize_key(rsa_context *rsa, x509_node *node)
-{
- int ret = 0;
- x509write_init_node(node);
-
- /* vers, n, e, d, p, q, dp, dq, pq */
- if ((ret = asn1_add_int(rsa->ver, node)) != 0)
- return ret;
- if ((ret = asn1_add_mpi(&rsa->N, ASN1_INTEGER, node)) != 0)
- return ret;
- if ((ret = asn1_add_mpi(&rsa->E, ASN1_INTEGER, node)) != 0)
- return ret;
- if ((ret = asn1_add_mpi(&rsa->D, ASN1_INTEGER, node)) != 0)
- return ret;
- if ((ret = asn1_add_mpi(&rsa->P, ASN1_INTEGER, node)) != 0)
- return ret;
- if ((ret = asn1_add_mpi(&rsa->Q, ASN1_INTEGER, node)) != 0)
- return ret;
- if ((ret = asn1_add_mpi(&rsa->DP, ASN1_INTEGER, node)) != 0)
- return ret;
- if ((ret = asn1_add_mpi(&rsa->DQ, ASN1_INTEGER, node)) != 0)
- return ret;
- if ((ret = asn1_add_mpi(&rsa->QP, ASN1_INTEGER, node)) != 0)
- return ret;
- if ((ret = asn1_append_tag(node, ASN1_CONSTRUCTED | ASN1_SEQUENCE)) != 0)
- return ret;
-
- return 0;
-}
-
-/*
- * write a der/pem encoded rsa private key into a file
- */
-int x509write_keyfile(rsa_context *rsa, char *path, int out_flag)
-{
- int ret = 0;
- const char key_beg[] = "-----BEGIN RSA PRIVATE KEY-----\n",
- key_end[] = "-----END RSA PRIVATE KEY-----\n";
- x509_node node;
-
- x509write_init_node(&node);
- if ((ret = x509write_serialize_key(rsa,&node)) != 0) {
- x509write_free_node(&node);
- return ret;
- }
-
- ret = x509write_file(&node,path,out_flag,key_beg,key_end);
- x509write_free_node(&node);
-
- return ret;
-}
-
-
-/*
- * reasize the memory for node
- */
-static int x509write_realloc_node(x509_node *node, size_t larger)
-{
- /* init len */
- if (node->data == NULL) {
- node->len = 0;
- node->data = malloc(larger);
- if(node->data == NULL)
- return 1;
- } else {
- /* realloc memory */
- if ((node->data = realloc(node->data, node->len + larger)) == NULL)
- return 1;
- }
-
- /* init pointer */
- node->p = &node->data[node->len];
- node->len += larger;
- node->end = &node->data[node->len -1];
-
- return 0;
-}
-
-/*
- * init node
- */
-void x509write_init_node(x509_node *node)
-{
- memset(node, 0, sizeof(x509_node));
-}
-
-/*
- * clean memory
- */
-void x509write_free_node(x509_node *node)
-{
- if (node->data != NULL)
- free(node->data);
- node->p = NULL;
- node->end = NULL;
- node->len = 0;
-}
-
-/*
- * write a x509 certificate into file
- */
-int x509write_crtfile(x509_raw *chain, unsigned char *path, int out_flag)
-{
- const char cer_beg[] = "-----BEGIN CERTIFICATE-----\n",
- cer_end[] = "-----END CERTIFICATE-----\n";
-
- return x509write_file(&chain->raw, (char*)path, out_flag, cer_beg, cer_end);
-}
-
-/*
- * write a x509 certificate into file
- */
-int x509write_csrfile(x509_raw *chain, unsigned char *path, int out_flag)
-{
- const char cer_beg[] = "-----BEGIN CERTIFICATE REQUEST-----\n",
- cer_end[] = "-----END CERTIFICATE REQUEST-----\n";
-
- return x509write_file(&chain->raw, (char*)path, out_flag, cer_beg, cer_end);
-}
-
-/*
- * write an x509 file
- */
-static int x509write_file(x509_node *node, char *path, int format,
- const char* pem_prolog, const char* pem_epilog)
-{
- FILE *ofstream = stdout;
- int is_err = 1, buf_len, i, n;
- unsigned char* base_buf;
-
- if (path) {
- if ((ofstream = fopen(path, "wb")) == NULL)
- return 1;
- }
-
- switch (format) {
- case X509_OUTPUT_DER:
- if (fwrite(node->data, 1, node->len, ofstream)
- != node->len)
- is_err = -1;
- break;
-
- case X509_OUTPUT_PEM:
- if (fprintf(ofstream, "%s", pem_prolog)<0) {
- is_err = -1;
- break;
- }
-
- buf_len = node->len << 1;
- base_buf = (unsigned char*) malloc((size_t)buf_len);
- memset(base_buf,0,buf_len);
- if (base64_encode(base_buf, &buf_len, node->data,
- (int) node->len) != 0) {
- is_err = -1;
- break;
- }
-
- n=strlen((char*)base_buf);
- for(i=0;i<n;i+=64) {
- fprintf(ofstream,"%.64s\n",&base_buf[i]);
- }
-
- if (fprintf(ofstream, "%s", pem_epilog)<0) {
- is_err = -1;
- break;
- }
-
- free(base_buf);
- }
-
- fclose(ofstream);
-
- if (is_err == -1)
- return 1;
-
- return 0;
-}
-
-
-/*
- * add the owner public key to x509 certificate
- */
-int x509write_add_pubkey(x509_raw *chain, rsa_context *pubkey)
-{
- x509_node n_tmp, n_tmp2, *node;
- int ret;
-
- node = &chain->subpubkey;
-
- x509write_init_node(&n_tmp);
- x509write_init_node(&n_tmp2);
-
- /*
- * RSAPublicKey ::= SEQUENCE {
- * modulus INTEGER, -- n
- * publicExponent INTEGER -- e
- * }
- */
- if ((ret = asn1_add_mpi(&pubkey->N, ASN1_INTEGER, &n_tmp)) != 0) {
- x509write_free_node(&n_tmp);
- x509write_free_node(&n_tmp2);
- return ret;
- }
- if ((ret = asn1_add_mpi(&pubkey->E, ASN1_INTEGER, &n_tmp)) != 0) {
- x509write_free_node(&n_tmp);
- x509write_free_node(&n_tmp2);
- return ret;
- }
- if ((ret = asn1_append_tag(&n_tmp, ASN1_CONSTRUCTED | ASN1_SEQUENCE))
- != 0) {
- x509write_free_node(&n_tmp);
- x509write_free_node(&n_tmp2);
- return ret;
- }
-
- /*
- * SubjectPublicKeyInfo ::= SEQUENCE {
- * algorithm AlgorithmIdentifier,
- * subjectPublicKey BIT STRING }
- */
- if ((ret = asn1_append_tag(&n_tmp, ASN1_BIT_STRING)) != 0) {
- x509write_free_node(&n_tmp);
- x509write_free_node(&n_tmp2);
- return ret;
- }
- if ((ret = asn1_add_oid(&n_tmp2, (unsigned char*)OID_PKCS1_RSA, 9,
- ASN1_CONSTRUCTED | ASN1_SEQUENCE, ASN1_NULL,
- (unsigned char *)"", 0)) != 0) {
- x509write_free_node(&n_tmp);
- x509write_free_node(&n_tmp2);
- return ret;
- }
-
- if ((ret = asn1_append_nodes(node, ASN1_CONSTRUCTED | ASN1_SEQUENCE, 2,
- &n_tmp2, &n_tmp))) {
- x509write_free_node(&n_tmp);
- x509write_free_node(&n_tmp2);
- return ret;
- }
-
- x509write_free_node(&n_tmp);
- x509write_free_node(&n_tmp2);
- return 0;
-}
-
-/*
- * RelativeDistinguishedName ::=
- * SET OF AttributeTypeAndValue
- *
- * AttributeTypeAndValue ::= SEQUENCE {
- * type AttributeType,
- * value AttributeValue }
- */
-static int x509write_add_name(x509_node *node, unsigned char *oid,
- unsigned int oid_len, unsigned char *value, int len, int value_tag)
-{
- int ret;
- x509_node n_tmp;
-
- x509write_init_node(&n_tmp);
-
- if ((ret = asn1_add_oid(&n_tmp, oid, oid_len,
- ASN1_CONSTRUCTED | ASN1_SEQUENCE, value_tag,
- value, len))) {
- x509write_free_node(&n_tmp);
- return ret;
- }
-
- if ((asn1_append_nodes(node, ASN1_CONSTRUCTED | ASN1_SET, 1, &n_tmp))
- != 0) {
- x509write_free_node(&n_tmp);
- return ret;
- }
-
- x509write_free_node(&n_tmp);
- return 0;
-}
-
-/*
- * Parse the name string and add to node
- */
-static int x509write_parse_names(x509_node *node, unsigned char *names)
-{
- unsigned char *sp, *begin = NULL;
- unsigned char oid[3] = OID_X520, tag[4], *tag_sp = tag;
- unsigned char *C = NULL, *CN = NULL, *O = NULL, *OU = NULL,
- *ST = NULL, *L = NULL, *R = NULL;
- int C_len = 0, CN_len = 0, O_len = 0, OU_len = 0, ST_len = 0,
- L_len = 0, R_len = 0;
- int ret = 0, is_tag = 1, is_begin = -1, len = 0;
-
-
- for (sp = names; ; ++sp) {
-
- /* filter tag */
- if (is_tag == 1) {
-
- if (tag_sp == &tag[3])
- return POLARSSL_ERR_X509_VALUE_TO_LENGTH;
-
- /* is tag end? */
- if (*sp == '=') {
- is_tag = -1;
- *tag_sp = '\0';
- is_begin = 1;
- /* set len 0 (reset) */
- len = 0;
- } else {
- /* tag hasn't ' '! */
- if (*sp != ' ') {
- *tag_sp = *sp;
- ++tag_sp;
- }
- }
- /* filter value */
- } else {
-
- /* set pointer of value begin */
- if (is_begin == 1) {
- begin = sp;
- is_begin = -1;
- }
-
- /* is value at end? */
- if (*sp == ';' or *sp == '\0') {
- is_tag = 1;
-
- /* common name */
- if (tag[0] == 'C' and tag[1] == 'N') {
- CN = begin;
- CN_len = len;
-
- /* organization */
- } else if (tag[0] == 'O' and tag[1] == '\0') {
- O = begin;
- O_len = len;
-
- /* country */
- } else if (tag[0] == 'C' and tag[1] == '\0') {
- C = begin;
- C_len = len;
-
- /* organisation unit */
- } else if (tag[0] == 'O' and tag[1] == 'U') {
- OU = begin;
- OU_len = len;
-
- /* state */
- } else if (tag[0] == 'S' and tag[1] == 'T') {
- ST = begin;
- ST_len = len;
-
- /* locality */
- } else if (tag[0] == 'L' and tag[1] == '\0') {
- L = begin;
- L_len = len;
-
- /* email */
- } else if (tag[0] == 'R' and tag[1] == '\0') {
- R = begin;
- R_len = len;
- }
-
- /* set tag poiner to begin */
- tag_sp = tag;
-
- /* is at end? */
- if (*sp == '\0' or *(sp +1) == '\0')
- break;
- } else {
- ++len;
- }
- }
-
- /* make saver */
- if (*sp == '\0')
- break;
- } /* end for */
-
- /* country */
- if (C != NULL) {
- oid[2] = X520_COUNTRY;
- if ((ret = x509write_add_name(node, oid, 3, C, C_len,
- ASN1_PRINTABLE_STRING)) != 0)
- return ret;
- }
-
- /* state */
- if (ST != NULL) {
- oid[2] = X520_STATE;
- if ((ret = x509write_add_name(node, oid, 3, ST, ST_len,
- ASN1_PRINTABLE_STRING)) != 0)
- return ret;
- }
-
- /* locality */
- if (L != NULL) {
- oid[2] = X520_LOCALITY;
- if ((ret = x509write_add_name(node, oid, 3, L, L_len,
- ASN1_PRINTABLE_STRING)) != 0)
- return ret;
- }
-
- /* organization */
- if (O != NULL) {
- oid[2] = X520_ORGANIZATION;
- if ((ret = x509write_add_name(node, oid, 3, O, O_len,
- ASN1_PRINTABLE_STRING)) != 0)
- return ret;
- }
-
- /* organisation unit */
- if (OU != NULL) {
- oid[2] = X520_ORG_UNIT;
- if ((ret = x509write_add_name(node, oid, 3, OU, OU_len,
- ASN1_PRINTABLE_STRING)) != 0)
- return ret;
- }
-
- /* common name */
- if (CN != NULL) {
- oid[2] = X520_COMMON_NAME;
- if ((ret = x509write_add_name(node, oid, 3, CN, CN_len,
- ASN1_PRINTABLE_STRING)) != 0)
- return ret;
- }
-
- /* email */
- if (R != NULL) {
- if ((ret = x509write_add_name(node, (unsigned char*)OID_PKCS9_EMAIL,
- 9, R, R_len, ASN1_IA5_STRING)) != 0)
- return ret;
- }
-
- if ((asn1_append_tag(node, ASN1_CONSTRUCTED | ASN1_SEQUENCE)) != 0)
- return ret;
-
- return 0;
-}
-
-/*
- * Copy raw data from orginal ca to node
- */
-static int x509write_copy_from_raw(x509_node *node, x509_buf *raw)
-{
- if (x509write_realloc_node(node, raw->len) != 0)
- return 1;
-
- memcpy(node->p, raw->p, (size_t)raw->len);
- if ((node->p += raw->len -1) != node->end)
- return POLARSSL_ERR_X509_POINT_ERROR;
-
- return 0;
-}
-
-/*
- * Add the issuer
- */
-
-int x509write_add_issuer(x509_raw *crt, unsigned char *issuer)
-{
- return x509write_parse_names(&crt->issuer, issuer);
-}
-
-/*
- * Add the subject
- */
-int x509write_add_subject(x509_raw *crt, unsigned char *subject)
-{
- return x509write_parse_names(&crt->subject, subject);
-}
-
-/*
- * Copy issuer line from another cert to issuer
- */
-int x509write_copy_issuer(x509_raw *crt, x509_cert *from_crt)
-{
- return x509write_copy_from_raw(&crt->issuer, &from_crt->issuer_raw);
-}
-
-/*
- * Copy subject line from another cert
- */
-int x509write_copy_subject(x509_raw *crt, x509_cert *from_crt)
-{
- return x509write_copy_from_raw(&crt->subject, &from_crt->subject_raw);
-}
-
-/*
- * Copy subject line form antoher cert into issuer
- */
-int x509write_copy_issuer_form_subject(x509_raw *crt,
- x509_cert *from_crt)
-{
- return x509write_copy_from_raw(&crt->issuer, &from_crt->subject_raw);
-}
-
-/*
- * Copy issuer line from another cert into subject
- */
-int x509write_copy_subject_from_issuer(x509_raw *crt,
- x509_cert * from_crt)
-{
- return x509write_copy_from_raw(&crt->subject, &from_crt->issuer_raw);
-}
-
-/*
- * Validity ::= SEQUENCE {
- * notBefore Time,
- * notAfter Time }
- *
- * Time ::= CHOICE {
- * utcTime UTCTime,
- * generalTime GeneralizedTime }
- */
-/* TODO: No handle GeneralizedTime! */
-int x509write_add_validity(x509_raw *chain, unsigned char *befor,
- unsigned char *after)
-{
- int ret;
-
- x509_node *node = &chain->validity;
-
- /* notBefore */
- if ((ret = asn1_add_date_utc(befor, node)) != 0)
- return ret;
-
- /* notAfter */
- if ((ret = asn1_add_date_utc(after, node)) != 0)
- return ret;
-
- if ((ret = asn1_append_tag(node, ASN1_CONSTRUCTED | ASN1_SEQUENCE)) != 0)
- return ret;
-
- return 0;
-}
-
-/*
- * make hash from tbs and sign that with private key
- */
-static int x509write_make_sign(x509_raw *chain, rsa_context *privkey)
-{
- int ret;
- unsigned char hash[20], *sign;
- size_t sign_len = (size_t) mpi_size(&privkey->N);
-
- /* make hash */
- sha1(chain->tbs.data, chain->tbs.len, hash);
-
- /* create sign */
- sign = (unsigned char *) malloc(sign_len);
- if (sign == NULL)
- return 1;
-
- if ((ret = rsa_pkcs1_sign(privkey, RSA_PRIVATE, RSA_SHA1, 20, hash,
- sign)) != 0)
- return ret;
-
- if ((ret = asn1_add_obj(sign, sign_len, ASN1_BIT_STRING,
- &chain->sign)) != 0)
- return ret;
-
- /*
- * AlgorithmIdentifier ::= SEQUENCE {
- * algorithm OBJECT IDENTIFIER,
- * parameters ANY DEFINED BY algorithm OPTIONAL }
- */
- return asn1_add_oid(&chain->signalg, (unsigned char*)OID_PKCS1_RSA_SHA, 9,
- ASN1_CONSTRUCTED | ASN1_SEQUENCE, ASN1_NULL,
- (unsigned char*)"", 0);
-}
-
-/*
- * Create a random serial
- */
-static int get_random_serial(void)
-{
- int random = 0;
- FILE *fd;
-
- fd = fopen("/dev/urandom", "r");
-
- if (fd) {
- if (fread(&random, 1, sizeof(random), fd) != sizeof(random))
- random = 0;
-
- fclose(fd);
- }
-
- return random;
-}
-
-/*
- * Create a self signed certificate
- */
-int x509write_create_sign(x509_raw *chain, rsa_context *privkey)
-{
- int ret, serial;
-
- /*
- * Version ::= INTEGER { v1(0), v2(1), v3(2) }
- */
- if ((ret = asn1_add_int(2, &chain->version)) != 0)
- return ret;
-
- if ((ret = asn1_append_tag(&chain->version, ASN1_CONTEXT_SPECIFIC |
- ASN1_CONSTRUCTED)) != 0)
- return ret;
-
-
- /*
- * CertificateSerialNumber ::= INTEGER
- */
- serial = get_random_serial();
-
- if (serial == 0)
- return 1;
-
- if ((ret = asn1_add_int(serial, &chain->serial)) != 0)
- return ret;
-
- /*
- * AlgorithmIdentifier ::= SEQUENCE {
- * algorithm OBJECT IDENTIFIER,
- * parameters ANY DEFINED BY algorithm OPTIONAL }
- */
- if ((ret = asn1_add_oid(&chain->tbs_signalg,
- (unsigned char*)OID_PKCS1_RSA_SHA, 9, ASN1_CONSTRUCTED |
- ASN1_SEQUENCE, ASN1_NULL, (unsigned char*)"", 0)) != 0)
- return ret;
-
- /*
- * Create the tbs
- */
- if ((ret = asn1_append_nodes(&chain->tbs, ASN1_CONSTRUCTED |
- ASN1_SEQUENCE, 7, &chain->version, &chain->serial,
- &chain->tbs_signalg, &chain->issuer, &chain->validity,
- &chain->subject, &chain->subpubkey)) != 0)
- return ret;
-
- /* make signing */
- if ((ret = x509write_make_sign(chain, privkey)) != 0)
- return ret;
-
- /* finishing */
- if ((ret = asn1_append_nodes(&chain->raw, ASN1_CONSTRUCTED |
- ASN1_SEQUENCE, 3, &chain->tbs, &chain->signalg,
- &chain->sign)) != 0)
- return ret;
-
- return 0;
-}
-
-int x509write_create_selfsign(x509_raw *chain, rsa_context *privkey)
-{
- /*
- * On self signed certificate are subject and issuer the same
- */
- x509write_free_node(&chain->issuer);
- chain->issuer = chain->subject;
- return x509write_create_sign(chain, privkey);
-}
-
-/*
- * CertificationRequestInfo ::= SEQUENCE {
- * version Version,
- * subject Name,
- * subjectPublicKeyInfo SubjectPublicKeyInfo,
- * attributes [0] IMPLICIT Attributes }
- *
- * CertificationRequest ::= SEQUENCE {
- * certificationRequestInfo CertificationRequestInfo,
- * signatureAlgorithm SignatureAlgorithmIdentifier,
- * signature Signature }
- *
- * It use chain.serail for attributes!
- *
- */
-int x509write_create_csr(x509_raw *chain, rsa_context *privkey)
-{
- int ret;
-
- /* version ::= INTEGER */
- if ((ret = asn1_add_int(0, &chain->version)) != 0)
- return ret;
-
- /* write attributes */
- if ((ret = asn1_add_obj((unsigned char*)"", 0, ASN1_CONTEXT_SPECIFIC |
- ASN1_CONSTRUCTED, &chain->serial)) != 0)
- return ret;
-
- /* create CertificationRequestInfo */
- if ((ret = asn1_append_nodes(&chain->tbs, ASN1_CONSTRUCTED |
- ASN1_SEQUENCE, 4, &chain->version, &chain->subject,
- &chain->subpubkey, &chain->serial)) != 0)
- return ret;
-
- /* make signing */
- if ((ret = x509write_make_sign(chain, privkey)) != 0)
- return ret;
-
- /* finish */
- if ((ret = asn1_append_nodes(&chain->raw, ASN1_CONSTRUCTED | ASN1_SEQUENCE,
- 3, &chain->tbs, &chain->signalg, &chain->sign)) != 0)
- return ret;
-
- return ret;
-}
-
-/*
- * Free memory
- */
-void x509write_free_raw(x509_raw *chain)
-{
- x509write_free_node(&chain->raw);
- x509write_free_node(&chain->tbs);
- x509write_free_node(&chain->version);
- x509write_free_node(&chain->serial);
- x509write_free_node(&chain->tbs_signalg);
- x509write_free_node(&chain->issuer);
- x509write_free_node(&chain->validity);
- if (chain->subject.data != chain->issuer.data)
- x509write_free_node(&chain->subject);
- x509write_free_node(&chain->subpubkey);
- x509write_free_node(&chain->signalg);
- x509write_free_node(&chain->sign);
-}
-
-void x509write_init_raw(x509_raw *chain)
-{
- memset((void *) chain, 0, sizeof(x509_raw));
-}
-
+++ /dev/null
-/**
- * \file base64.h
- *
- * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
- *
- * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of PolarSSL or XySSL nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef POLARSSL_BASE64_H
-#define POLARSSL_BASE64_H
-
-#define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x0010
-#define POLARSSL_ERR_BASE64_INVALID_CHARACTER -0x0012
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief Encode a buffer into base64 format
- *
- * \param dst destination buffer
- * \param dlen size of the buffer
- * \param src source buffer
- * \param slen amount of data to be encoded
- *
- * \return 0 if successful, or POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL.
- * *dlen is always updated to reflect the amount
- * of data that has (or would have) been written.
- *
- * \note Call this function with *dlen = 0 to obtain the
- * required buffer size in *dlen
- */
-int base64_encode( unsigned char *dst, int *dlen,
- unsigned char *src, int slen );
-
-/**
- * \brief Decode a base64-formatted buffer
- *
- * \param dst destination buffer
- * \param dlen size of the buffer
- * \param src source buffer
- * \param slen amount of data to be decoded
- *
- * \return 0 if successful, POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, or
- * POLARSSL_ERR_BASE64_INVALID_DATA if the input data is not
- * correct. *dlen is always updated to reflect the amount
- * of data that has (or would have) been written.
- *
- * \note Call this function with *dlen = 0 to obtain the
- * required buffer size in *dlen
- */
-int base64_decode( unsigned char *dst, int *dlen,
- unsigned char *src, int slen );
-
-/**
- * \brief Checkup routine
- *
- * \return 0 if successful, or 1 if the test failed
- */
-int base64_self_test( int verbose );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* base64.h */
+++ /dev/null
-/**
- * \file bignum.h
- *
- * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
- *
- * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of PolarSSL or XySSL nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef POLARSSL_BIGNUM_H
-#define POLARSSL_BIGNUM_H
-
-#include <stdio.h>
-
-#define POLARSSL_ERR_MPI_FILE_IO_ERROR -0x0002
-#define POLARSSL_ERR_MPI_BAD_INPUT_DATA -0x0004
-#define POLARSSL_ERR_MPI_INVALID_CHARACTER -0x0006
-#define POLARSSL_ERR_MPI_BUFFER_TOO_SMALL -0x0008
-#define POLARSSL_ERR_MPI_NEGATIVE_VALUE -0x000A
-#define POLARSSL_ERR_MPI_DIVISION_BY_ZERO -0x000C
-#define POLARSSL_ERR_MPI_NOT_ACCEPTABLE -0x000E
-
-#define MPI_CHK(f) if( ( ret = f ) != 0 ) goto cleanup
-
-/*
- * Define the base integer type, architecture-wise
- */
-#if defined(POLARSSL_HAVE_INT8)
-typedef unsigned char t_int;
-typedef unsigned short t_dbl;
-#else
-#if defined(POLARSSL_HAVE_INT16)
-typedef unsigned short t_int;
-typedef unsigned long t_dbl;
-#else
- typedef unsigned long t_int;
- #if defined(_MSC_VER) && defined(_M_IX86)
- typedef unsigned __int64 t_dbl;
- #else
- #if defined(__amd64__) || defined(__x86_64__) || \
- defined(__ppc64__) || defined(__powerpc64__) || \
- defined(__ia64__) || defined(__alpha__)
- typedef unsigned int t_dbl __attribute__((mode(TI)));
- #else
- typedef unsigned long long t_dbl;
- #endif
- #endif
-#endif
-#endif
-
-/**
- * \brief MPI structure
- */
-typedef struct
-{
- int s; /*!< integer sign */
- int n; /*!< total # of limbs */
- t_int *p; /*!< pointer to limbs */
-}
-mpi;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief Initialize one or more mpi
- */
-void mpi_init( mpi *X, ... );
-
-/**
- * \brief Unallocate one or more mpi
- */
-void mpi_free( mpi *X, ... );
-
-/**
- * \brief Enlarge to the specified number of limbs
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_grow( mpi *X, int nblimbs );
-
-/**
- * \brief Copy the contents of Y into X
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_copy( mpi *X, mpi *Y );
-
-/**
- * \brief Swap the contents of X and Y
- */
-void mpi_swap( mpi *X, mpi *Y );
-
-/**
- * \brief Set value from integer
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_lset( mpi *X, int z );
-
-/**
- * \brief Return the number of least significant bits
- */
-int mpi_lsb( mpi *X );
-
-/**
- * \brief Return the number of most significant bits
- */
-int mpi_msb( mpi *X );
-
-/**
- * \brief Return the total size in bytes
- */
-int mpi_size( mpi *X );
-
-/**
- * \brief Import from an ASCII string
- *
- * \param X destination mpi
- * \param radix input numeric base
- * \param s null-terminated string buffer
- *
- * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
- */
-int mpi_read_string( mpi *X, int radix, char *s );
-
-/**
- * \brief Export into an ASCII string
- *
- * \param X source mpi
- * \param radix output numeric base
- * \param s string buffer
- * \param slen string buffer size
- *
- * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
- *
- * \note Call this function with *slen = 0 to obtain the
- * minimum required buffer size in *slen.
- */
-int mpi_write_string( mpi *X, int radix, char *s, int *slen );
-
-/**
- * \brief Read X from an opened file
- *
- * \param X destination mpi
- * \param radix input numeric base
- * \param fin input file handle
- *
- * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
- */
-int mpi_read_file( mpi *X, int radix, FILE *fin );
-
-/**
- * \brief Write X into an opened file, or stdout
- *
- * \param p prefix, can be NULL
- * \param X source mpi
- * \param radix output numeric base
- * \param fout output file handle
- *
- * \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
- *
- * \note Set fout == NULL to print X on the console.
- */
-int mpi_write_file( char *p, mpi *X, int radix, FILE *fout );
-
-/**
- * \brief Import X from unsigned binary data, big endian
- *
- * \param X destination mpi
- * \param buf input buffer
- * \param buflen input buffer size
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_read_binary( mpi *X, unsigned char *buf, int buflen );
-
-/**
- * \brief Export X into unsigned binary data, big endian
- *
- * \param X source mpi
- * \param buf output buffer
- * \param buflen output buffer size
- *
- * \return 0 if successful,
- * POLARSSL_ERR_MPI_BUFFER_TOO_SMALL if buf isn't large enough
- *
- * \note Call this function with *buflen = 0 to obtain the
- * minimum required buffer size in *buflen.
- */
-int mpi_write_binary( mpi *X, unsigned char *buf, int buflen );
-
-/**
- * \brief Left-shift: X <<= count
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_shift_l( mpi *X, int count );
-
-/**
- * \brief Right-shift: X >>= count
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_shift_r( mpi *X, int count );
-
-/**
- * \brief Compare unsigned values
- *
- * \return 1 if |X| is greater than |Y|,
- * -1 if |X| is lesser than |Y| or
- * 0 if |X| is equal to |Y|
- */
-int mpi_cmp_abs( mpi *X, mpi *Y );
-
-/**
- * \brief Compare signed values
- *
- * \return 1 if X is greater than Y,
- * -1 if X is lesser than Y or
- * 0 if X is equal to Y
- */
-int mpi_cmp_mpi( mpi *X, mpi *Y );
-
-/**
- * \brief Compare signed values
- *
- * \return 1 if X is greater than z,
- * -1 if X is lesser than z or
- * 0 if X is equal to z
- */
-int mpi_cmp_int( mpi *X, int z );
-
-/**
- * \brief Unsigned addition: X = |A| + |B|
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_add_abs( mpi *X, mpi *A, mpi *B );
-
-/**
- * \brief Unsigned substraction: X = |A| - |B|
- *
- * \return 0 if successful,
- * POLARSSL_ERR_MPI_NEGATIVE_VALUE if B is greater than A
- */
-int mpi_sub_abs( mpi *X, mpi *A, mpi *B );
-
-/**
- * \brief Signed addition: X = A + B
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_add_mpi( mpi *X, mpi *A, mpi *B );
-
-/**
- * \brief Signed substraction: X = A - B
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_sub_mpi( mpi *X, mpi *A, mpi *B );
-
-/**
- * \brief Signed addition: X = A + b
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_add_int( mpi *X, mpi *A, int b );
-
-/**
- * \brief Signed substraction: X = A - b
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_sub_int( mpi *X, mpi *A, int b );
-
-/**
- * \brief Baseline multiplication: X = A * B
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_mul_mpi( mpi *X, mpi *A, mpi *B );
-
-/**
- * \brief Baseline multiplication: X = A * b
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_mul_int( mpi *X, mpi *A, t_int b );
-
-/**
- * \brief Division by mpi: A = Q * B + R
- *
- * \return 0 if successful,
- * 1 if memory allocation failed,
- * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0
- *
- * \note Either Q or R can be NULL.
- */
-int mpi_div_mpi( mpi *Q, mpi *R, mpi *A, mpi *B );
-
-/**
- * \brief Division by int: A = Q * b + R
- *
- * \return 0 if successful,
- * 1 if memory allocation failed,
- * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0
- *
- * \note Either Q or R can be NULL.
- */
-int mpi_div_int( mpi *Q, mpi *R, mpi *A, int b );
-
-/**
- * \brief Modulo: R = A mod B
- *
- * \return 0 if successful,
- * 1 if memory allocation failed,
- * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0
- */
-int mpi_mod_mpi( mpi *R, mpi *A, mpi *B );
-
-/**
- * \brief Modulo: r = A mod b
- *
- * \return 0 if successful,
- * 1 if memory allocation failed,
- * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0
- */
-int mpi_mod_int( t_int *r, mpi *A, int b );
-
-/**
- * \brief Sliding-window exponentiation: X = A^E mod N
- *
- * \return 0 if successful,
- * 1 if memory allocation failed,
- * POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or even
- *
- * \note _RR is used to avoid re-computing R*R mod N across
- * multiple calls, which speeds up things a bit. It can
- * be set to NULL if the extra performance is unneeded.
- */
-int mpi_exp_mod( mpi *X, mpi *A, mpi *E, mpi *N, mpi *_RR );
-
-/**
- * \brief Greatest common divisor: G = gcd(A, B)
- *
- * \return 0 if successful,
- * 1 if memory allocation failed
- */
-int mpi_gcd( mpi *G, mpi *A, mpi *B );
-
-/**
- * \brief Modular inverse: X = A^-1 mod N
- *
- * \return 0 if successful,
- * 1 if memory allocation failed,
- * POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or nil
- * POLARSSL_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N
- */
-int mpi_inv_mod( mpi *X, mpi *A, mpi *N );
-
-/**
- * \brief Miller-Rabin primality test
- *
- * \return 0 if successful (probably prime),
- * 1 if memory allocation failed,
- * POLARSSL_ERR_MPI_NOT_ACCEPTABLE if X is not prime
- */
-int mpi_is_prime( mpi *X, int (*f_rng)(void *), void *p_rng );
-
-/**
- * \brief Prime number generation
- *
- * \param X destination mpi
- * \param nbits required size of X in bits
- * \param dh_flag if 1, then (X-1)/2 will be prime too
- * \param f_rng RNG function
- * \param p_rng RNG parameter
- *
- * \return 0 if successful (probably prime),
- * 1 if memory allocation failed,
- * POLARSSL_ERR_MPI_BAD_INPUT_DATA if nbits is < 3
- */
-int mpi_gen_prime( mpi *X, int nbits, int dh_flag,
- int (*f_rng)(void *), void *p_rng );
-
-/**
- * \brief Checkup routine
- *
- * \return 0 if successful, or 1 if the test failed
- */
-int mpi_self_test( int verbose );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* bignum.h */
+++ /dev/null
-/**
- * \file bn_mul.h
- *
- * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
- *
- * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of PolarSSL or XySSL nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/*
- * Multiply source vector [s] with b, add result
- * to destination vector [d] and set carry c.
- *
- * Currently supports:
- *
- * . IA-32 (386+) . AMD64 / EM64T
- * . IA-32 (SSE2) . Motorola 68000
- * . PowerPC, 32-bit . MicroBlaze
- * . PowerPC, 64-bit . TriCore
- * . SPARC v8 . ARM v3+
- * . Alpha . MIPS32
- * . C, longlong . C, generic
- */
-#ifndef POLARSSL_BN_MUL_H
-#define POLARSSL_BN_MUL_H
-
-#include "polarssl/config.h"
-
-#if defined(POLARSSL_HAVE_ASM)
-
-#if defined(__GNUC__)
-#if defined(__i386__)
-
-#define MULADDC_INIT \
- asm( "movl %%ebx, %0 " : "=m" (t)); \
- asm( "movl %0, %%esi " :: "m" (s)); \
- asm( "movl %0, %%edi " :: "m" (d)); \
- asm( "movl %0, %%ecx " :: "m" (c)); \
- asm( "movl %0, %%ebx " :: "m" (b));
-
-#define MULADDC_CORE \
- asm( "lodsl " ); \
- asm( "mull %ebx " ); \
- asm( "addl %ecx, %eax " ); \
- asm( "adcl $0, %edx " ); \
- asm( "addl (%edi), %eax " ); \
- asm( "adcl $0, %edx " ); \
- asm( "movl %edx, %ecx " ); \
- asm( "stosl " );
-
-#if defined(POLARSSL_HAVE_SSE2)
-
-#define MULADDC_HUIT \
- asm( "movd %ecx, %mm1 " ); \
- asm( "movd %ebx, %mm0 " ); \
- asm( "movd (%edi), %mm3 " ); \
- asm( "paddq %mm3, %mm1 " ); \
- asm( "movd (%esi), %mm2 " ); \
- asm( "pmuludq %mm0, %mm2 " ); \
- asm( "movd 4(%esi), %mm4 " ); \
- asm( "pmuludq %mm0, %mm4 " ); \
- asm( "movd 8(%esi), %mm6 " ); \
- asm( "pmuludq %mm0, %mm6 " ); \
- asm( "movd 12(%esi), %mm7 " ); \
- asm( "pmuludq %mm0, %mm7 " ); \
- asm( "paddq %mm2, %mm1 " ); \
- asm( "movd 4(%edi), %mm3 " ); \
- asm( "paddq %mm4, %mm3 " ); \
- asm( "movd 8(%edi), %mm5 " ); \
- asm( "paddq %mm6, %mm5 " ); \
- asm( "movd 12(%edi), %mm4 " ); \
- asm( "paddq %mm4, %mm7 " ); \
- asm( "movd %mm1, (%edi) " ); \
- asm( "movd 16(%esi), %mm2 " ); \
- asm( "pmuludq %mm0, %mm2 " ); \
- asm( "psrlq $32, %mm1 " ); \
- asm( "movd 20(%esi), %mm4 " ); \
- asm( "pmuludq %mm0, %mm4 " ); \
- asm( "paddq %mm3, %mm1 " ); \
- asm( "movd 24(%esi), %mm6 " ); \
- asm( "pmuludq %mm0, %mm6 " ); \
- asm( "movd %mm1, 4(%edi) " ); \
- asm( "psrlq $32, %mm1 " ); \
- asm( "movd 28(%esi), %mm3 " ); \
- asm( "pmuludq %mm0, %mm3 " ); \
- asm( "paddq %mm5, %mm1 " ); \
- asm( "movd 16(%edi), %mm5 " ); \
- asm( "paddq %mm5, %mm2 " ); \
- asm( "movd %mm1, 8(%edi) " ); \
- asm( "psrlq $32, %mm1 " ); \
- asm( "paddq %mm7, %mm1 " ); \
- asm( "movd 20(%edi), %mm5 " ); \
- asm( "paddq %mm5, %mm4 " ); \
- asm( "movd %mm1, 12(%edi) " ); \
- asm( "psrlq $32, %mm1 " ); \
- asm( "paddq %mm2, %mm1 " ); \
- asm( "movd 24(%edi), %mm5 " ); \
- asm( "paddq %mm5, %mm6 " ); \
- asm( "movd %mm1, 16(%edi) " ); \
- asm( "psrlq $32, %mm1 " ); \
- asm( "paddq %mm4, %mm1 " ); \
- asm( "movd 28(%edi), %mm5 " ); \
- asm( "paddq %mm5, %mm3 " ); \
- asm( "movd %mm1, 20(%edi) " ); \
- asm( "psrlq $32, %mm1 " ); \
- asm( "paddq %mm6, %mm1 " ); \
- asm( "movd %mm1, 24(%edi) " ); \
- asm( "psrlq $32, %mm1 " ); \
- asm( "paddq %mm3, %mm1 " ); \
- asm( "movd %mm1, 28(%edi) " ); \
- asm( "addl $32, %edi " ); \
- asm( "addl $32, %esi " ); \
- asm( "psrlq $32, %mm1 " ); \
- asm( "movd %mm1, %ecx " );
-
-#define MULADDC_STOP \
- asm( "emms " ); \
- asm( "movl %0, %%ebx " :: "m" (t)); \
- asm( "movl %%ecx, %0 " : "=m" (c)); \
- asm( "movl %%edi, %0 " : "=m" (d)); \
- asm( "movl %%esi, %0 " : "=m" (s) :: \
- "eax", "ecx", "edx", "esi", "edi" );
-
-#else
-
-#define MULADDC_STOP \
- asm( "movl %0, %%ebx " :: "m" (t)); \
- asm( "movl %%ecx, %0 " : "=m" (c)); \
- asm( "movl %%edi, %0 " : "=m" (d)); \
- asm( "movl %%esi, %0 " : "=m" (s) :: \
- "eax", "ecx", "edx", "esi", "edi" );
-
-#endif /* SSE2 */
-#endif /* i386 */
-
-#if defined(__amd64__) || defined (__x86_64__)
-
-#define MULADDC_INIT \
- asm( "movq %0, %%rsi " :: "m" (s)); \
- asm( "movq %0, %%rdi " :: "m" (d)); \
- asm( "movq %0, %%rcx " :: "m" (c)); \
- asm( "movq %0, %%rbx " :: "m" (b)); \
- asm( "xorq %r8, %r8 " );
-
-#define MULADDC_CORE \
- asm( "movq (%rsi),%rax " ); \
- asm( "mulq %rbx " ); \
- asm( "addq $8, %rsi " ); \
- asm( "addq %rcx, %rax " ); \
- asm( "movq %r8, %rcx " ); \
- asm( "adcq $0, %rdx " ); \
- asm( "nop " ); \
- asm( "addq %rax, (%rdi) " ); \
- asm( "adcq %rdx, %rcx " ); \
- asm( "addq $8, %rdi " );
-
-#define MULADDC_STOP \
- asm( "movq %%rcx, %0 " : "=m" (c)); \
- asm( "movq %%rdi, %0 " : "=m" (d)); \
- asm( "movq %%rsi, %0 " : "=m" (s) :: \
- "rax", "rcx", "rdx", "rbx", "rsi", "rdi", "r8" );
-
-#endif /* AMD64 */
-
-#if defined(__mc68020__) || defined(__mcpu32__)
-
-#define MULADDC_INIT \
- asm( "movl %0, %%a2 " :: "m" (s)); \
- asm( "movl %0, %%a3 " :: "m" (d)); \
- asm( "movl %0, %%d3 " :: "m" (c)); \
- asm( "movl %0, %%d2 " :: "m" (b)); \
- asm( "moveq #0, %d0 " );
-
-#define MULADDC_CORE \
- asm( "movel %a2@+, %d1 " ); \
- asm( "mulul %d2, %d4:%d1 " ); \
- asm( "addl %d3, %d1 " ); \
- asm( "addxl %d0, %d4 " ); \
- asm( "moveq #0, %d3 " ); \
- asm( "addl %d1, %a3@+ " ); \
- asm( "addxl %d4, %d3 " );
-
-#define MULADDC_STOP \
- asm( "movl %%d3, %0 " : "=m" (c)); \
- asm( "movl %%a3, %0 " : "=m" (d)); \
- asm( "movl %%a2, %0 " : "=m" (s) :: \
- "d0", "d1", "d2", "d3", "d4", "a2", "a3" );
-
-#define MULADDC_HUIT \
- asm( "movel %a2@+, %d1 " ); \
- asm( "mulul %d2, %d4:%d1 " ); \
- asm( "addxl %d3, %d1 " ); \
- asm( "addxl %d0, %d4 " ); \
- asm( "addl %d1, %a3@+ " ); \
- asm( "movel %a2@+, %d1 " ); \
- asm( "mulul %d2, %d3:%d1 " ); \
- asm( "addxl %d4, %d1 " ); \
- asm( "addxl %d0, %d3 " ); \
- asm( "addl %d1, %a3@+ " ); \
- asm( "movel %a2@+, %d1 " ); \
- asm( "mulul %d2, %d4:%d1 " ); \
- asm( "addxl %d3, %d1 " ); \
- asm( "addxl %d0, %d4 " ); \
- asm( "addl %d1, %a3@+ " ); \
- asm( "movel %a2@+, %d1 " ); \
- asm( "mulul %d2, %d3:%d1 " ); \
- asm( "addxl %d4, %d1 " ); \
- asm( "addxl %d0, %d3 " ); \
- asm( "addl %d1, %a3@+ " ); \
- asm( "movel %a2@+, %d1 " ); \
- asm( "mulul %d2, %d4:%d1 " ); \
- asm( "addxl %d3, %d1 " ); \
- asm( "addxl %d0, %d4 " ); \
- asm( "addl %d1, %a3@+ " ); \
- asm( "movel %a2@+, %d1 " ); \
- asm( "mulul %d2, %d3:%d1 " ); \
- asm( "addxl %d4, %d1 " ); \
- asm( "addxl %d0, %d3 " ); \
- asm( "addl %d1, %a3@+ " ); \
- asm( "movel %a2@+, %d1 " ); \
- asm( "mulul %d2, %d4:%d1 " ); \
- asm( "addxl %d3, %d1 " ); \
- asm( "addxl %d0, %d4 " ); \
- asm( "addl %d1, %a3@+ " ); \
- asm( "movel %a2@+, %d1 " ); \
- asm( "mulul %d2, %d3:%d1 " ); \
- asm( "addxl %d4, %d1 " ); \
- asm( "addxl %d0, %d3 " ); \
- asm( "addl %d1, %a3@+ " ); \
- asm( "addxl %d0, %d3 " );
-
-#endif /* MC68000 */
-
-#if defined(__powerpc__) || defined(__ppc__)
-#if defined(__powerpc64__) || defined(__ppc64__)
-
-#if defined(__MACH__) && defined(__APPLE__)
-
-#define MULADDC_INIT \
- asm( "ld r3, %0 " :: "m" (s)); \
- asm( "ld r4, %0 " :: "m" (d)); \
- asm( "ld r5, %0 " :: "m" (c)); \
- asm( "ld r6, %0 " :: "m" (b)); \
- asm( "addi r3, r3, -8 " ); \
- asm( "addi r4, r4, -8 " ); \
- asm( "addic r5, r5, 0 " );
-
-#define MULADDC_CORE \
- asm( "ldu r7, 8(r3) " ); \
- asm( "mulld r8, r7, r6 " ); \
- asm( "mulhdu r9, r7, r6 " ); \
- asm( "adde r8, r8, r5 " ); \
- asm( "ld r7, 8(r4) " ); \
- asm( "addze r5, r9 " ); \
- asm( "addc r8, r8, r7 " ); \
- asm( "stdu r8, 8(r4) " );
-
-#define MULADDC_STOP \
- asm( "addze r5, r5 " ); \
- asm( "addi r4, r4, 8 " ); \
- asm( "addi r3, r3, 8 " ); \
- asm( "std r5, %0 " : "=m" (c)); \
- asm( "std r4, %0 " : "=m" (d)); \
- asm( "std r3, %0 " : "=m" (s) :: \
- "r3", "r4", "r5", "r6", "r7", "r8", "r9" );
-
-#else
-
-#define MULADDC_INIT \
- asm( "ld %%r3, %0 " :: "m" (s)); \
- asm( "ld %%r4, %0 " :: "m" (d)); \
- asm( "ld %%r5, %0 " :: "m" (c)); \
- asm( "ld %%r6, %0 " :: "m" (b)); \
- asm( "addi %r3, %r3, -8 " ); \
- asm( "addi %r4, %r4, -8 " ); \
- asm( "addic %r5, %r5, 0 " );
-
-#define MULADDC_CORE \
- asm( "ldu %r7, 8(%r3) " ); \
- asm( "mulld %r8, %r7, %r6 " ); \
- asm( "mulhdu %r9, %r7, %r6 " ); \
- asm( "adde %r8, %r8, %r5 " ); \
- asm( "ld %r7, 8(%r4) " ); \
- asm( "addze %r5, %r9 " ); \
- asm( "addc %r8, %r8, %r7 " ); \
- asm( "stdu %r8, 8(%r4) " );
-
-#define MULADDC_STOP \
- asm( "addze %r5, %r5 " ); \
- asm( "addi %r4, %r4, 8 " ); \
- asm( "addi %r3, %r3, 8 " ); \
- asm( "std %%r5, %0 " : "=m" (c)); \
- asm( "std %%r4, %0 " : "=m" (d)); \
- asm( "std %%r3, %0 " : "=m" (s) :: \
- "r3", "r4", "r5", "r6", "r7", "r8", "r9" );
-
-#endif
-
-#else /* PPC32 */
-
-#if defined(__MACH__) && defined(__APPLE__)
-
-#define MULADDC_INIT \
- asm( "lwz r3, %0 " :: "m" (s)); \
- asm( "lwz r4, %0 " :: "m" (d)); \
- asm( "lwz r5, %0 " :: "m" (c)); \
- asm( "lwz r6, %0 " :: "m" (b)); \
- asm( "addi r3, r3, -4 " ); \
- asm( "addi r4, r4, -4 " ); \
- asm( "addic r5, r5, 0 " );
-
-#define MULADDC_CORE \
- asm( "lwzu r7, 4(r3) " ); \
- asm( "mullw r8, r7, r6 " ); \
- asm( "mulhwu r9, r7, r6 " ); \
- asm( "adde r8, r8, r5 " ); \
- asm( "lwz r7, 4(r4) " ); \
- asm( "addze r5, r9 " ); \
- asm( "addc r8, r8, r7 " ); \
- asm( "stwu r8, 4(r4) " );
-
-#define MULADDC_STOP \
- asm( "addze r5, r5 " ); \
- asm( "addi r4, r4, 4 " ); \
- asm( "addi r3, r3, 4 " ); \
- asm( "stw r5, %0 " : "=m" (c)); \
- asm( "stw r4, %0 " : "=m" (d)); \
- asm( "stw r3, %0 " : "=m" (s) :: \
- "r3", "r4", "r5", "r6", "r7", "r8", "r9" );
-
-#else
-
-#define MULADDC_INIT \
- asm( "lwz %%r3, %0 " :: "m" (s)); \
- asm( "lwz %%r4, %0 " :: "m" (d)); \
- asm( "lwz %%r5, %0 " :: "m" (c)); \
- asm( "lwz %%r6, %0 " :: "m" (b)); \
- asm( "addi %r3, %r3, -4 " ); \
- asm( "addi %r4, %r4, -4 " ); \
- asm( "addic %r5, %r5, 0 " );
-
-#define MULADDC_CORE \
- asm( "lwzu %r7, 4(%r3) " ); \
- asm( "mullw %r8, %r7, %r6 " ); \
- asm( "mulhwu %r9, %r7, %r6 " ); \
- asm( "adde %r8, %r8, %r5 " ); \
- asm( "lwz %r7, 4(%r4) " ); \
- asm( "addze %r5, %r9 " ); \
- asm( "addc %r8, %r8, %r7 " ); \
- asm( "stwu %r8, 4(%r4) " );
-
-#define MULADDC_STOP \
- asm( "addze %r5, %r5 " ); \
- asm( "addi %r4, %r4, 4 " ); \
- asm( "addi %r3, %r3, 4 " ); \
- asm( "stw %%r5, %0 " : "=m" (c)); \
- asm( "stw %%r4, %0 " : "=m" (d)); \
- asm( "stw %%r3, %0 " : "=m" (s) :: \
- "r3", "r4", "r5", "r6", "r7", "r8", "r9" );
-
-#endif
-
-#endif /* PPC32 */
-#endif /* PPC64 */
-
-#if defined(__sparc__)
-
-#define MULADDC_INIT \
- asm( "ld %0, %%o0 " :: "m" (s)); \
- asm( "ld %0, %%o1 " :: "m" (d)); \
- asm( "ld %0, %%o2 " :: "m" (c)); \
- asm( "ld %0, %%o3 " :: "m" (b));
-
-#define MULADDC_CORE \
- asm( "ld [%o0], %o4 " ); \
- asm( "inc 4, %o0 " ); \
- asm( "ld [%o1], %o5 " ); \
- asm( "umul %o3, %o4, %o4 " ); \
- asm( "addcc %o4, %o2, %o4 " ); \
- asm( "rd %y, %g1 " ); \
- asm( "addx %g1, 0, %g1 " ); \
- asm( "addcc %o4, %o5, %o4 " ); \
- asm( "st %o4, [%o1] " ); \
- asm( "addx %g1, 0, %o2 " ); \
- asm( "inc 4, %o1 " );
-
-#define MULADDC_STOP \
- asm( "st %%o2, %0 " : "=m" (c)); \
- asm( "st %%o1, %0 " : "=m" (d)); \
- asm( "st %%o0, %0 " : "=m" (s) :: \
- "g1", "o0", "o1", "o2", "o3", "o4", "o5" );
-
-#endif /* SPARCv8 */
-
-#if defined(__microblaze__) || defined(microblaze)
-
-#define MULADDC_INIT \
- asm( "lwi r3, %0 " :: "m" (s)); \
- asm( "lwi r4, %0 " :: "m" (d)); \
- asm( "lwi r5, %0 " :: "m" (c)); \
- asm( "lwi r6, %0 " :: "m" (b)); \
- asm( "andi r7, r6, 0xffff" ); \
- asm( "bsrli r6, r6, 16 " );
-
-#define MULADDC_CORE \
- asm( "lhui r8, r3, 0 " ); \
- asm( "addi r3, r3, 2 " ); \
- asm( "lhui r9, r3, 0 " ); \
- asm( "addi r3, r3, 2 " ); \
- asm( "mul r10, r9, r6 " ); \
- asm( "mul r11, r8, r7 " ); \
- asm( "mul r12, r9, r7 " ); \
- asm( "mul r13, r8, r6 " ); \
- asm( "bsrli r8, r10, 16 " ); \
- asm( "bsrli r9, r11, 16 " ); \
- asm( "add r13, r13, r8 " ); \
- asm( "add r13, r13, r9 " ); \
- asm( "bslli r10, r10, 16 " ); \
- asm( "bslli r11, r11, 16 " ); \
- asm( "add r12, r12, r10 " ); \
- asm( "addc r13, r13, r0 " ); \
- asm( "add r12, r12, r11 " ); \
- asm( "addc r13, r13, r0 " ); \
- asm( "lwi r10, r4, 0 " ); \
- asm( "add r12, r12, r10 " ); \
- asm( "addc r13, r13, r0 " ); \
- asm( "add r12, r12, r5 " ); \
- asm( "addc r5, r13, r0 " ); \
- asm( "swi r12, r4, 0 " ); \
- asm( "addi r4, r4, 4 " );
-
-#define MULADDC_STOP \
- asm( "swi r5, %0 " : "=m" (c)); \
- asm( "swi r4, %0 " : "=m" (d)); \
- asm( "swi r3, %0 " : "=m" (s) :: \
- "r3", "r4" , "r5" , "r6" , "r7" , "r8" , \
- "r9", "r10", "r11", "r12", "r13" );
-
-#endif /* MicroBlaze */
-
-#if defined(__tricore__)
-
-#define MULADDC_INIT \
- asm( "ld.a %%a2, %0 " :: "m" (s)); \
- asm( "ld.a %%a3, %0 " :: "m" (d)); \
- asm( "ld.w %%d4, %0 " :: "m" (c)); \
- asm( "ld.w %%d1, %0 " :: "m" (b)); \
- asm( "xor %d5, %d5 " );
-
-#define MULADDC_CORE \
- asm( "ld.w %d0, [%a2+] " ); \
- asm( "madd.u %e2, %e4, %d0, %d1 " ); \
- asm( "ld.w %d0, [%a3] " ); \
- asm( "addx %d2, %d2, %d0 " ); \
- asm( "addc %d3, %d3, 0 " ); \
- asm( "mov %d4, %d3 " ); \
- asm( "st.w [%a3+], %d2 " );
-
-#define MULADDC_STOP \
- asm( "st.w %0, %%d4 " : "=m" (c)); \
- asm( "st.a %0, %%a3 " : "=m" (d)); \
- asm( "st.a %0, %%a2 " : "=m" (s) :: \
- "d0", "d1", "e2", "d4", "a2", "a3" );
-
-#endif /* TriCore */
-
-#if defined(__arm__)
-
-#define MULADDC_INIT \
- asm( "ldr r0, %0 " :: "m" (s)); \
- asm( "ldr r1, %0 " :: "m" (d)); \
- asm( "ldr r2, %0 " :: "m" (c)); \
- asm( "ldr r3, %0 " :: "m" (b));
-
-#define MULADDC_CORE \
- asm( "ldr r4, [r0], #4 " ); \
- asm( "mov r5, #0 " ); \
- asm( "ldr r6, [r1] " ); \
- asm( "umlal r2, r5, r3, r4 " ); \
- asm( "adds r7, r6, r2 " ); \
- asm( "adc r2, r5, #0 " ); \
- asm( "str r7, [r1], #4 " );
-
-#define MULADDC_STOP \
- asm( "str r2, %0 " : "=m" (c)); \
- asm( "str r1, %0 " : "=m" (d)); \
- asm( "str r0, %0 " : "=m" (s) :: \
- "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7" );
-
-#endif /* ARMv3 */
-
-#if defined(__alpha__)
-
-#define MULADDC_INIT \
- asm( "ldq $1, %0 " :: "m" (s)); \
- asm( "ldq $2, %0 " :: "m" (d)); \
- asm( "ldq $3, %0 " :: "m" (c)); \
- asm( "ldq $4, %0 " :: "m" (b));
-
-#define MULADDC_CORE \
- asm( "ldq $6, 0($1) " ); \
- asm( "addq $1, 8, $1 " ); \
- asm( "mulq $6, $4, $7 " ); \
- asm( "umulh $6, $4, $6 " ); \
- asm( "addq $7, $3, $7 " ); \
- asm( "cmpult $7, $3, $3 " ); \
- asm( "ldq $5, 0($2) " ); \
- asm( "addq $7, $5, $7 " ); \
- asm( "cmpult $7, $5, $5 " ); \
- asm( "stq $7, 0($2) " ); \
- asm( "addq $2, 8, $2 " ); \
- asm( "addq $6, $3, $3 " ); \
- asm( "addq $5, $3, $3 " );
-
-#define MULADDC_STOP \
- asm( "stq $3, %0 " : "=m" (c)); \
- asm( "stq $2, %0 " : "=m" (d)); \
- asm( "stq $1, %0 " : "=m" (s) :: \
- "$1", "$2", "$3", "$4", "$5", "$6", "$7" );
-
-#endif /* Alpha */
-
-#if defined(__mips__)
-
-#define MULADDC_INIT \
- asm( "lw $10, %0 " :: "m" (s)); \
- asm( "lw $11, %0 " :: "m" (d)); \
- asm( "lw $12, %0 " :: "m" (c)); \
- asm( "lw $13, %0 " :: "m" (b));
-
-#define MULADDC_CORE \
- asm( "lw $14, 0($10) " ); \
- asm( "multu $13, $14 " ); \
- asm( "addi $10, $10, 4 " ); \
- asm( "mflo $14 " ); \
- asm( "mfhi $9 " ); \
- asm( "addu $14, $12, $14 " ); \
- asm( "lw $15, 0($11) " ); \
- asm( "sltu $12, $14, $12 " ); \
- asm( "addu $15, $14, $15 " ); \
- asm( "sltu $14, $15, $14 " ); \
- asm( "addu $12, $12, $9 " ); \
- asm( "sw $15, 0($11) " ); \
- asm( "addu $12, $12, $14 " ); \
- asm( "addi $11, $11, 4 " );
-
-#define MULADDC_STOP \
- asm( "sw $12, %0 " : "=m" (c)); \
- asm( "sw $11, %0 " : "=m" (d)); \
- asm( "sw $10, %0 " : "=m" (s) :: \
- "$9", "$10", "$11", "$12", "$13", "$14", "$15" );
-
-#endif /* MIPS */
-#endif /* GNUC */
-
-#if (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
-
-#define MULADDC_INIT \
- __asm mov esi, s \
- __asm mov edi, d \
- __asm mov ecx, c \
- __asm mov ebx, b
-
-#define MULADDC_CORE \
- __asm lodsd \
- __asm mul ebx \
- __asm add eax, ecx \
- __asm adc edx, 0 \
- __asm add eax, [edi] \
- __asm adc edx, 0 \
- __asm mov ecx, edx \
- __asm stosd
-
-#if defined(POLARSSL_HAVE_SSE2)
-
-#define EMIT __asm _emit
-
-#define MULADDC_HUIT \
- EMIT 0x0F EMIT 0x6E EMIT 0xC9 \
- EMIT 0x0F EMIT 0x6E EMIT 0xC3 \
- EMIT 0x0F EMIT 0x6E EMIT 0x1F \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
- EMIT 0x0F EMIT 0x6E EMIT 0x16 \
- EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \
- EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x04 \
- EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \
- EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x08 \
- EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \
- EMIT 0x0F EMIT 0x6E EMIT 0x7E EMIT 0x0C \
- EMIT 0x0F EMIT 0xF4 EMIT 0xF8 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCA \
- EMIT 0x0F EMIT 0x6E EMIT 0x5F EMIT 0x04 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xDC \
- EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x08 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xEE \
- EMIT 0x0F EMIT 0x6E EMIT 0x67 EMIT 0x0C \
- EMIT 0x0F EMIT 0xD4 EMIT 0xFC \
- EMIT 0x0F EMIT 0x7E EMIT 0x0F \
- EMIT 0x0F EMIT 0x6E EMIT 0x56 EMIT 0x10 \
- EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x14 \
- EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
- EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x18 \
- EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x04 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0x6E EMIT 0x5E EMIT 0x1C \
- EMIT 0x0F EMIT 0xF4 EMIT 0xD8 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCD \
- EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x10 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xD5 \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x08 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCF \
- EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x14 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xE5 \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x0C \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCA \
- EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x18 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xF5 \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x10 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCC \
- EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x1C \
- EMIT 0x0F EMIT 0xD4 EMIT 0xDD \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x14 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCE \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x18 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x1C \
- EMIT 0x83 EMIT 0xC7 EMIT 0x20 \
- EMIT 0x83 EMIT 0xC6 EMIT 0x20 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0x7E EMIT 0xC9
-
-#define MULADDC_STOP \
- EMIT 0x0F EMIT 0x77 \
- __asm mov c, ecx \
- __asm mov d, edi \
- __asm mov s, esi \
-
-#else
-
-#define MULADDC_STOP \
- __asm mov c, ecx \
- __asm mov d, edi \
- __asm mov s, esi \
-
-#endif /* SSE2 */
-#endif /* MSVC */
-
-#endif /* POLARSSL_HAVE_ASM */
-
-#if !defined(MULADDC_CORE)
-#if defined(POLARSSL_HAVE_LONGLONG)
-
-#define MULADDC_INIT \
-{ \
- t_dbl r; \
- t_int r0, r1;
-
-#define MULADDC_CORE \
- r = *(s++) * (t_dbl) b; \
- r0 = r; \
- r1 = r >> biL; \
- r0 += c; r1 += (r0 < c); \
- r0 += *d; r1 += (r0 < *d); \
- c = r1; *(d++) = r0;
-
-#define MULADDC_STOP \
-}
-
-#else
-#define MULADDC_INIT \
-{ \
- t_int s0, s1, b0, b1; \
- t_int r0, r1, rx, ry; \
- b0 = ( b << biH ) >> biH; \
- b1 = ( b >> biH );
-
-#define MULADDC_CORE \
- s0 = ( *s << biH ) >> biH; \
- s1 = ( *s >> biH ); s++; \
- rx = s0 * b1; r0 = s0 * b0; \
- ry = s1 * b0; r1 = s1 * b1; \
- r1 += ( rx >> biH ); \
- r1 += ( ry >> biH ); \
- rx <<= biH; ry <<= biH; \
- r0 += rx; r1 += (r0 < rx); \
- r0 += ry; r1 += (r0 < ry); \
- r0 += c; r1 += (r0 < c); \
- r0 += *d; r1 += (r0 < *d); \
- c = r1; *(d++) = r0;
-
-#define MULADDC_STOP \
-}
-
-#endif /* C (generic) */
-#endif /* C (longlong) */
-
-#endif /* bn_mul.h */
+++ /dev/null
-/**
- * \file config.h
- *
- * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
- *
- * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of PolarSSL or XySSL nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This set of compile-time options may be used to enable
- * or disable features selectively, and reduce the global
- * memory footprint.
- */
-#ifndef POLARSSL_CONFIG_H
-#define POLARSSL_CONFIG_H
-
-#ifndef _CRT_SECURE_NO_DEPRECATE
-#define _CRT_SECURE_NO_DEPRECATE 1
-#endif
-
-/*
- * Uncomment if native integers are 8-bit wide.
- *
-#define POLARSSL_HAVE_INT8
- */
-
-/*
- * Uncomment if native integers are 16-bit wide.
- *
-#define POLARSSL_HAVE_INT16
- */
-
-/*
- * Uncomment if the compiler supports long long.
-#define POLARSSL_HAVE_LONGLONG
- */
-
-
-/*
- * Uncomment to enable the use of assembly code.
- */
-/* #define POLARSSL_HAVE_ASM */
-
-/*
- * Uncomment if the CPU supports SSE2 (IA-32 specific).
- *
-#define POLARSSL_HAVE_SSE2
- */
-
-/*
- * Enable all SSL/TLS debugging messages.
- */
-#define POLARSSL_DEBUG_MSG
-
-/*
- * Enable the checkup functions (*_self_test).
- */
-#define POLARSSL_SELF_TEST
-
-/*
- * Enable the prime-number generation code.
- */
-#define POLARSSL_GENPRIME
-
-/*
- * Uncomment this macro to store the AES tables in ROM.
- *
-#define POLARSSL_AES_ROM_TABLES
- */
-
-/*
- * Module: library/aes.c
- * Caller: library/ssl_tls.c
- *
- * This module enables the following ciphersuites:
- * SSL_RSA_AES_128_SHA
- * SSL_RSA_AES_256_SHA
- * SSL_EDH_RSA_AES_256_SHA
- */
-#define POLARSSL_AES_C
-
-/*
- * Module: library/arc4.c
- * Caller: library/ssl_tls.c
- *
- * This module enables the following ciphersuites:
- * SSL_RSA_RC4_128_MD5
- * SSL_RSA_RC4_128_SHA
- */
-#define POLARSSL_ARC4_C
-
-/*
- * Module: library/base64.c
- * Caller: library/x509parse.c
- *
- * This module is required for X.509 support.
- */
-#define POLARSSL_BASE64_C
-
-/*
- * Module: library/bignum.c
- * Caller: library/dhm.c
- * library/rsa.c
- * library/ssl_tls.c
- * library/x509parse.c
- *
- * This module is required for RSA and DHM support.
- */
-#define POLARSSL_BIGNUM_C
-
-/*
- * Module: library/camellia.c
- * Caller:
- *
- * This module enabled the following cipher suites:
- */
-#define POLARSSL_CAMELLIA_C
-
-/*
- * Module: library/certs.c
- * Caller:
- *
- * This module is used for testing (ssl_client/server).
- */
-#define POLARSSL_CERTS_C
-
-/*
- * Module: library/debug.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- * library/ssl_tls.c
- *
- * This module provides debugging functions.
- */
-#define POLARSSL_DEBUG_C
-
-/*
- * Module: library/des.c
- * Caller: library/ssl_tls.c
- *
- * This module enables the following ciphersuites:
- * SSL_RSA_DES_168_SHA
- * SSL_EDH_RSA_DES_168_SHA
- */
-#define POLARSSL_DES_C
-
-/*
- * Module: library/dhm.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- *
- * This module enables the following ciphersuites:
- * SSL_EDH_RSA_DES_168_SHA
- * SSL_EDH_RSA_AES_256_SHA
- */
-#define POLARSSL_DHM_C
-
-/*
- * Module: library/havege.c
- * Caller:
- *
- * This module enables the HAVEGE random number generator.
- */
-#define POLARSSL_HAVEGE_C
-
-/*
- * Module: library/md2.c
- * Caller: library/x509parse.c
- *
- * Uncomment to enable support for (rare) MD2-signed X.509 certs.
- *
-#define POLARSSL_MD2_C
- */
-
-/*
- * Module: library/md4.c
- * Caller: library/x509parse.c
- *
- * Uncomment to enable support for (rare) MD4-signed X.509 certs.
- *
-#define POLARSSL_MD4_C
- */
-
-/*
- * Module: library/md5.c
- * Caller: library/ssl_tls.c
- * library/x509parse.c
- *
- * This module is required for SSL/TLS and X.509.
- */
-#define POLARSSL_MD5_C
-
-/*
- * Module: library/net.c
- * Caller:
- *
- * This module provides TCP/IP networking routines.
- */
-#define POLARSSL_NET_C
-
-/*
- * Module: library/padlock.c
- * Caller: library/aes.c
- *
- * This modules adds support for the VIA PadLock on x86.
- */
-#define POLARSSL_PADLOCK_C
-
-/*
- * Module: library/rsa.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- * library/ssl_tls.c
- * library/x509.c
- *
- * This module is required for SSL/TLS and MD5-signed certificates.
- */
-#define POLARSSL_RSA_C
-
-/*
- * Module: library/sha1.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- * library/ssl_tls.c
- * library/x509parse.c
- *
- * This module is required for SSL/TLS and SHA1-signed certificates.
- */
-#define POLARSSL_SHA1_C
-
-/*
- * Module: library/sha2.c
- * Caller:
- *
- * This module adds support for SHA-224 and SHA-256.
- */
-#define POLARSSL_SHA2_C
-
-/*
- * Module: library/sha4.c
- * Caller:
- *
- * This module adds support for SHA-384 and SHA-512.
- */
-#define POLARSSL_SHA4_C
-
-/*
- * Module: library/ssl_cli.c
- * Caller:
- *
- * This module is required for SSL/TLS client support.
- */
-#define POLARSSL_SSL_CLI_C
-
-/*
- * Module: library/ssl_srv.c
- * Caller:
- *
- * This module is required for SSL/TLS server support.
- */
-#define POLARSSL_SSL_SRV_C
-
-/*
- * Module: library/ssl_tls.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- *
- * This module is required for SSL/TLS.
- */
-#define POLARSSL_SSL_TLS_C
-
-/*
- * Module: library/timing.c
- * Caller: library/havege.c
- *
- * This module is used by the HAVEGE random number generator.
- */
-#define POLARSSL_TIMING_C
-
-/*
- * Module: library/x509parse.c
- * Caller: library/ssl_cli.c
- * library/ssl_srv.c
- * library/ssl_tls.c
- *
- * This module is required for X.509 certificate parsing.
- */
-#define POLARSSL_X509_PARSE_C
-
-/*
- * Module: library/x509_write.c
- * Caller:
- *
- * This module is required for X.509 certificate writing.
- */
-#define POLARSSL_X509_WRITE_C
-
-/*
- * Module: library/xtea.c
- * Caller:
- */
-#define POLARSSL_XTEA_C
-
-#endif /* config.h */
+++ /dev/null
-/**
- * \file rsa.h
- *
- * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
- *
- * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of PolarSSL or XySSL nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef POLARSSL_RSA_H
-#define POLARSSL_RSA_H
-
-#include "polarssl/bignum.h"
-
-#define POLARSSL_ERR_RSA_BAD_INPUT_DATA -0x0400
-#define POLARSSL_ERR_RSA_INVALID_PADDING -0x0410
-#define POLARSSL_ERR_RSA_KEY_GEN_FAILED -0x0420
-#define POLARSSL_ERR_RSA_KEY_CHECK_FAILED -0x0430
-#define POLARSSL_ERR_RSA_PUBLIC_FAILED -0x0440
-#define POLARSSL_ERR_RSA_PRIVATE_FAILED -0x0450
-#define POLARSSL_ERR_RSA_VERIFY_FAILED -0x0460
-#define POLARSSL_ERR_RSA_OUTPUT_TO_LARGE -0x0470
-
-/*
- * PKCS#1 constants
- */
-#define RSA_RAW 0
-#define RSA_MD2 2
-#define RSA_MD4 3
-#define RSA_MD5 4
-#define RSA_SHA1 5
-#define RSA_SHA256 6
-
-#define RSA_PUBLIC 0
-#define RSA_PRIVATE 1
-
-#define RSA_PKCS_V15 0
-#define RSA_PKCS_V21 1
-
-#define RSA_SIGN 1
-#define RSA_CRYPT 2
-
-/*
- * DigestInfo ::= SEQUENCE {
- * digestAlgorithm DigestAlgorithmIdentifier,
- * digest Digest }
- *
- * DigestAlgorithmIdentifier ::= AlgorithmIdentifier
- *
- * Digest ::= OCTET STRING
- */
-#define ASN1_HASH_MDX \
- "\x30\x20\x30\x0C\x06\x08\x2A\x86\x48" \
- "\x86\xF7\x0D\x02\x00\x05\x00\x04\x10"
-
-#define ASN1_HASH_SHA1 \
- "\x30\x21\x30\x09\x06\x05\x2B\x0E\x03" \
- "\x02\x1A\x05\x00\x04\x14"
-
-/**
- * \brief RSA context structure
- */
-typedef struct
-{
- int ver; /*!< always 0 */
- int len; /*!< size(N) in chars */
-
- mpi N; /*!< public modulus */
- mpi E; /*!< public exponent */
-
- mpi D; /*!< private exponent */
- mpi P; /*!< 1st prime factor */
- mpi Q; /*!< 2nd prime factor */
- mpi DP; /*!< D % (P - 1) */
- mpi DQ; /*!< D % (Q - 1) */
- mpi QP; /*!< 1 / (Q % P) */
-
- mpi RN; /*!< cached R^2 mod N */
- mpi RP; /*!< cached R^2 mod P */
- mpi RQ; /*!< cached R^2 mod Q */
-
- int padding; /*!< 1.5 or OAEP/PSS */
- int hash_id; /*!< hash identifier */
- int (*f_rng)(void *); /*!< RNG function */
- void *p_rng; /*!< RNG parameter */
-}
-rsa_context;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief Initialize an RSA context
- *
- * \param ctx RSA context to be initialized
- * \param padding RSA_PKCS_V15 or RSA_PKCS_V21
- * \param hash_id RSA_PKCS_V21 hash identifier
- * \param f_rng RNG function
- * \param p_rng RNG parameter
- *
- * \note The hash_id parameter is actually ignored
- * when using RSA_PKCS_V15 padding.
- *
- * \note Currently (xyssl-0.8), RSA_PKCS_V21 padding
- * is not supported.
- */
-void rsa_init( rsa_context *ctx,
- int padding,
- int hash_id,
- int (*f_rng)(void *),
- void *p_rng );
-
-/**
- * \brief Generate an RSA keypair
- *
- * \param ctx RSA context that will hold the key
- * \param nbits size of the public key in bits
- * \param exponent public exponent (e.g., 65537)
- *
- * \note rsa_init() must be called beforehand to setup
- * the RSA context (especially f_rng and p_rng).
- *
- * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
- */
-int rsa_gen_key( rsa_context *ctx, int nbits, int exponent );
-
-/**
- * \brief Check a public RSA key
- *
- * \param ctx RSA context to be checked
- *
- * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
- */
-int rsa_check_pubkey( rsa_context *ctx );
-
-/**
- * \brief Check a private RSA key
- *
- * \param ctx RSA context to be checked
- *
- * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
- */
-int rsa_check_privkey( rsa_context *ctx );
-
-/**
- * \brief Do an RSA public key operation
- *
- * \param ctx RSA context
- * \param input input buffer
- * \param output output buffer
- *
- * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
- *
- * \note This function does NOT take care of message
- * padding. Also, be sure to set input[0] = 0.
- *
- * \note The input and output buffers must be large
- * enough (eg. 128 bytes if RSA-1024 is used).
- */
-int rsa_public( rsa_context *ctx,
- unsigned char *input,
- unsigned char *output );
-
-/**
- * \brief Do an RSA private key operation
- *
- * \param ctx RSA context
- * \param input input buffer
- * \param output output buffer
- *
- * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
- *
- * \note The input and output buffers must be large
- * enough (eg. 128 bytes if RSA-1024 is used).
- */
-int rsa_private( rsa_context *ctx,
- unsigned char *input,
- unsigned char *output );
-
-/**
- * \brief Add the message padding, then do an RSA operation
- *
- * \param ctx RSA context
- * \param mode RSA_PUBLIC or RSA_PRIVATE
- * \param ilen contains the the plaintext length
- * \param input buffer holding the data to be encrypted
- * \param output buffer that will hold the ciphertext
- *
- * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
- *
- * \note The output buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- */
-int rsa_pkcs1_encrypt( rsa_context *ctx,
- int mode, int ilen,
- unsigned char *input,
- unsigned char *output );
-
-/**
- * \brief Do an RSA operation, then remove the message padding
- *
- * \param ctx RSA context
- * \param mode RSA_PUBLIC or RSA_PRIVATE
- * \param input buffer holding the encrypted data
- * \param output buffer that will hold the plaintext
- * \param olen will contain the plaintext length
- * \param output_max_len maximum length of the output buffer
- *
- * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code
- *
- * \note The output buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise
- * an error is thrown.
- */
-int rsa_pkcs1_decrypt( rsa_context *ctx,
- int mode, int *olen,
- unsigned char *input,
- unsigned char *output,
- int output_max_len);
-
-/**
- * \brief Do a private RSA to sign a message digest
- *
- * \param ctx RSA context
- * \param mode RSA_PUBLIC or RSA_PRIVATE
- * \param hash_id RSA_RAW, RSA_MD{2,4,5} or RSA_SHA{1,256}
- * \param hashlen message digest length (for RSA_RAW only)
- * \param hash buffer holding the message digest
- * \param sig buffer that will hold the ciphertext
- *
- * \return 0 if the signing operation was successful,
- * or an POLARSSL_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- */
-int rsa_pkcs1_sign( rsa_context *ctx,
- int mode,
- int hash_id,
- int hashlen,
- unsigned char *hash,
- unsigned char *sig );
-
-/**
- * \brief Do a public RSA and check the message digest
- *
- * \param ctx points to an RSA public key
- * \param mode RSA_PUBLIC or RSA_PRIVATE
- * \param hash_id RSA_RAW, RSA_MD{2,4,5} or RSA_SHA{1,256}
- * \param hashlen message digest length (for RSA_RAW only)
- * \param hash buffer holding the message digest
- * \param sig buffer holding the ciphertext
- *
- * \return 0 if the verify operation was successful,
- * or an POLARSSL_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- */
-int rsa_pkcs1_verify( rsa_context *ctx,
- int mode,
- int hash_id,
- int hashlen,
- unsigned char *hash,
- unsigned char *sig );
-
-/**
- * \brief Free the components of an RSA key
- */
-void rsa_free( rsa_context *ctx );
-
-/**
- * \brief Checkup routine
- *
- * \return 0 if successful, or 1 if the test failed
- */
-int rsa_self_test( int verbose );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* rsa.h */
+++ /dev/null
-/**
- * \file sha1.h
- *
- * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
- *
- * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of PolarSSL or XySSL nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef POLARSSL_SHA1_H
-#define POLARSSL_SHA1_H
-
-/**
- * \brief SHA-1 context structure
- */
-typedef struct
-{
- unsigned long total[2]; /*!< number of bytes processed */
- unsigned long state[5]; /*!< intermediate digest state */
- unsigned char buffer[64]; /*!< data block being processed */
-
- unsigned char ipad[64]; /*!< HMAC: inner padding */
- unsigned char opad[64]; /*!< HMAC: outer padding */
-}
-sha1_context;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief SHA-1 context setup
- *
- * \param ctx context to be initialized
- */
-void sha1_starts( sha1_context *ctx );
-
-/**
- * \brief SHA-1 process buffer
- *
- * \param ctx SHA-1 context
- * \param input buffer holding the data
- * \param ilen length of the input data
- */
-void sha1_update( sha1_context *ctx, unsigned char *input, int ilen );
-
-/**
- * \brief SHA-1 final digest
- *
- * \param ctx SHA-1 context
- * \param output SHA-1 checksum result
- */
-void sha1_finish( sha1_context *ctx, unsigned char output[20] );
-
-/**
- * \brief Output = SHA-1( input buffer )
- *
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output SHA-1 checksum result
- */
-void sha1( unsigned char *input, int ilen, unsigned char output[20] );
-
-/**
- * \brief Output = SHA-1( file contents )
- *
- * \param path input file name
- * \param output SHA-1 checksum result
- *
- * \return 0 if successful, 1 if fopen failed,
- * or 2 if fread failed
- */
-int sha1_file( char *path, unsigned char output[20] );
-
-/**
- * \brief SHA-1 HMAC context setup
- *
- * \param ctx HMAC context to be initialized
- * \param key HMAC secret key
- * \param keylen length of the HMAC key
- */
-void sha1_hmac_starts( sha1_context *ctx, unsigned char *key, int keylen );
-
-/**
- * \brief SHA-1 HMAC process buffer
- *
- * \param ctx HMAC context
- * \param input buffer holding the data
- * \param ilen length of the input data
- */
-void sha1_hmac_update( sha1_context *ctx, unsigned char *input, int ilen );
-
-/**
- * \brief SHA-1 HMAC final digest
- *
- * \param ctx HMAC context
- * \param output SHA-1 HMAC checksum result
- */
-void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] );
-
-/**
- * \brief Output = HMAC-SHA-1( hmac key, input buffer )
- *
- * \param key HMAC secret key
- * \param keylen length of the HMAC key
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output HMAC-SHA-1 result
- */
-void sha1_hmac( unsigned char *key, int keylen,
- unsigned char *input, int ilen,
- unsigned char output[20] );
-
-/**
- * \brief Checkup routine
- *
- * \return 0 if successful, or 1 if the test failed
- */
-int sha1_self_test( int verbose );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* sha1.h */
+++ /dev/null
-/**
- * \file timing.h
- *
- * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
- *
- * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of PolarSSL or XySSL nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef POLARSSL_TIMING_H
-#define POLARSSL_TIMING_H
-
-/**
- * \brief timer structure
- */
-struct hr_time
-{
- unsigned char opaque[32];
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int alarmed;
-
-/**
- * \brief Return the CPU cycle counter value
- */
-unsigned long hardclock( void );
-
-/**
- * \brief Return the elapsed time in milliseconds
- *
- * \param val points to a timer structure
- * \param reset if set to 1, the timer is restarted
- */
-unsigned long get_timer( struct hr_time *val, int reset );
-
-/**
- * \brief Setup an alarm clock
- *
- * \param seconds delay before the "alarmed" flag is set
- */
-void set_alarm( int seconds );
-
-/**
- * \brief Sleep for a certain amount of time
- */
-void m_sleep( int milliseconds );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* timing.h */
+++ /dev/null
-/**
- * \file x509.h
- *
- * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
- *
- * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of PolarSSL or XySSL nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef POLARSSL_X509_H
-#define POLARSSL_X509_H
-
-#include "polarssl/rsa.h"
-
-#define POLARSSL_ERR_ASN1_OUT_OF_DATA -0x0014
-#define POLARSSL_ERR_ASN1_UNEXPECTED_TAG -0x0016
-#define POLARSSL_ERR_ASN1_INVALID_LENGTH -0x0018
-#define POLARSSL_ERR_ASN1_LENGTH_MISMATCH -0x001A
-#define POLARSSL_ERR_ASN1_INVALID_DATA -0x001C
-
-#define POLARSSL_ERR_X509_FEATURE_UNAVAILABLE -0x0020
-#define POLARSSL_ERR_X509_CERT_INVALID_PEM -0x0040
-#define POLARSSL_ERR_X509_CERT_INVALID_FORMAT -0x0060
-#define POLARSSL_ERR_X509_CERT_INVALID_VERSION -0x0080
-#define POLARSSL_ERR_X509_CERT_INVALID_SERIAL -0x00A0
-#define POLARSSL_ERR_X509_CERT_INVALID_ALG -0x00C0
-#define POLARSSL_ERR_X509_CERT_INVALID_NAME -0x00E0
-#define POLARSSL_ERR_X509_CERT_INVALID_DATE -0x0100
-#define POLARSSL_ERR_X509_CERT_INVALID_PUBKEY -0x0120
-#define POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE -0x0140
-#define POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS -0x0160
-#define POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION -0x0180
-#define POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG -0x01A0
-#define POLARSSL_ERR_X509_CERT_UNKNOWN_PK_ALG -0x01C0
-#define POLARSSL_ERR_X509_CERT_SIG_MISMATCH -0x01E0
-#define POLARSSL_ERR_X509_CERT_VERIFY_FAILED -0x0200
-#define POLARSSL_ERR_X509_KEY_INVALID_PEM -0x0220
-#define POLARSSL_ERR_X509_KEY_INVALID_VERSION -0x0240
-#define POLARSSL_ERR_X509_KEY_INVALID_FORMAT -0x0260
-#define POLARSSL_ERR_X509_KEY_INVALID_ENC_IV -0x0280
-#define POLARSSL_ERR_X509_KEY_UNKNOWN_ENC_ALG -0x02A0
-#define POLARSSL_ERR_X509_KEY_PASSWORD_REQUIRED -0x02C0
-#define POLARSSL_ERR_X509_KEY_PASSWORD_MISMATCH -0x02E0
-#define POLARSSL_ERR_X509_POINT_ERROR -0x0300
-#define POLARSSL_ERR_X509_VALUE_TO_LENGTH -0x0320
-
-#define BADCERT_EXPIRED 1
-#define BADCERT_REVOKED 2
-#define BADCERT_CN_MISMATCH 4
-#define BADCERT_NOT_TRUSTED 8
-
-/*
- * DER constants
- */
-#define ASN1_BOOLEAN 0x01
-#define ASN1_INTEGER 0x02
-#define ASN1_BIT_STRING 0x03
-#define ASN1_OCTET_STRING 0x04
-#define ASN1_NULL 0x05
-#define ASN1_OID 0x06
-#define ASN1_UTF8_STRING 0x0C
-#define ASN1_SEQUENCE 0x10
-#define ASN1_SET 0x11
-#define ASN1_PRINTABLE_STRING 0x13
-#define ASN1_T61_STRING 0x14
-#define ASN1_IA5_STRING 0x16
-#define ASN1_UTC_TIME 0x17
-#define ASN1_UNIVERSAL_STRING 0x1C
-#define ASN1_BMP_STRING 0x1E
-#define ASN1_PRIMITIVE 0x00
-#define ASN1_CONSTRUCTED 0x20
-#define ASN1_CONTEXT_SPECIFIC 0x80
-
-/*
- * various object identifiers
- */
-#define X520_COMMON_NAME 3
-#define X520_COUNTRY 6
-#define X520_LOCALITY 7
-#define X520_STATE 8
-#define X520_ORGANIZATION 10
-#define X520_ORG_UNIT 11
-#define PKCS9_EMAIL 1
-
-#define X509_OUTPUT_DER 0x01
-#define X509_OUTPUT_PEM 0x02
-#define PEM_LINE_LENGTH 72
-#define X509_ISSUER 0x01
-#define X509_SUBJECT 0x02
-
-#define OID_X520 "\x55\x04"
-#define OID_CN "\x55\x04\x03"
-#define OID_PKCS1 "\x2A\x86\x48\x86\xF7\x0D\x01\x01"
-#define OID_PKCS1_RSA "\x2A\x86\x48\x86\xF7\x0D\x01\x01\x01"
-#define OID_PKCS1_RSA_SHA "\x2A\x86\x48\x86\xF7\x0D\x01\x01\x05"
-#define OID_PKCS9 "\x2A\x86\x48\x86\xF7\x0D\x01\x09"
-#define OID_PKCS9_EMAIL "\x2A\x86\x48\x86\xF7\x0D\x01\x09\x01"
-
-/*
- * Structures for parsing X.509 certificates
- */
-typedef struct _x509_buf
-{
- int tag;
- int len;
- unsigned char *p;
-}
-x509_buf;
-
-typedef struct _x509_name
-{
- x509_buf oid;
- x509_buf val;
- struct _x509_name *next;
-}
-x509_name;
-
-typedef struct _x509_time
-{
- int year, mon, day;
- int hour, min, sec;
-}
-x509_time;
-
-typedef struct _x509_cert
-{
- x509_buf raw;
- x509_buf tbs;
-
- int version;
- x509_buf serial;
- x509_buf sig_oid1;
-
- x509_buf issuer_raw;
- x509_buf subject_raw;
-
- x509_name issuer;
- x509_name subject;
-
- x509_time valid_from;
- x509_time valid_to;
-
- x509_buf pk_oid;
- rsa_context rsa;
-
- x509_buf issuer_id;
- x509_buf subject_id;
- x509_buf v3_ext;
-
- int ca_istrue;
- int max_pathlen;
-
- x509_buf sig_oid2;
- x509_buf sig;
-
- struct _x509_cert *next;
-}
-x509_cert;
-
-/*
- * Structures for writing X.509 certificates
- */
-typedef struct _x509_node
-{
- unsigned char *data;
- unsigned char *p;
- unsigned char *end;
-
- size_t len;
-}
-x509_node;
-
-typedef struct _x509_raw
-{
- x509_node raw;
- x509_node tbs;
-
- x509_node version;
- x509_node serial;
- x509_node tbs_signalg;
- x509_node issuer;
- x509_node validity;
- x509_node subject;
- x509_node subpubkey;
-
- x509_node signalg;
- x509_node sign;
-}
-x509_raw;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief Parse one or more certificates and add them
- * to the chained list
- *
- * \param chain points to the start of the chain
- * \param buf buffer holding the certificate data
- * \param buflen size of the buffer
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509parse_crt( x509_cert *crt, unsigned char *buf, int buflen );
-
-/**
- * \brief Load one or more certificates and add them
- * to the chained list
- *
- * \param chain points to the start of the chain
- * \param path filename to read the certificates from
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509parse_crtfile( x509_cert *crt, char *path );
-
-/**
- * \brief Parse a private RSA key
- *
- * \param rsa RSA context to be initialized
- * \param buf input buffer
- * \param buflen size of the buffer
- * \param pwd password for decryption (optional)
- * \param pwdlen size of the password
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509parse_key( rsa_context *rsa,
- unsigned char *buf, int buflen,
- unsigned char *pwd, int pwdlen );
-
-/**
- * \brief Load and parse a private RSA key
- *
- * \param rsa RSA context to be initialized
- * \param path filename to read the private key from
- * \param pwd password to decrypt the file (can be NULL)
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509parse_keyfile( rsa_context *rsa, char *path, char *password );
-
-/**
- * \brief Store the certificate DN in printable form into buf;
- * no more than (end - buf) characters will be written.
- */
-int x509parse_dn_gets( char *buf, char *end, x509_name *dn );
-
-/**
- * \brief Returns an informational string about the
- * certificate.
- */
-char *x509parse_cert_info( char *prefix, x509_cert *crt );
-
-/**
- * \brief Return 0 if the certificate is still valid,
- * or BADCERT_EXPIRED
- */
-int x509parse_expired( x509_cert *crt );
-
-/**
- * \brief Verify the certificate signature
- *
- * \param crt a certificate to be verified
- * \param trust_ca the trusted CA chain
- * \param cn expected Common Name (can be set to
- * NULL if the CN must not be verified)
- * \param flags result of the verification
- *
- * \return 0 if successful or POLARSSL_ERR_X509_SIG_VERIFY_FAILED,
- * in which case *flags will have one or more of
- * the following values set:
- * BADCERT_EXPIRED --
- * BADCERT_REVOKED --
- * BADCERT_CN_MISMATCH --
- * BADCERT_NOT_TRUSTED
- *
- * \note TODO: add two arguments, depth and crl
- */
-int x509parse_verify( x509_cert *crt,
- x509_cert *trust_ca,
- char *cn, int *flags );
-
-/**
- * \brief Unallocate all certificate data
- */
-void x509_free( x509_cert *crt );
-
-/**
- * \brief Checkup routine
- *
- * \return 0 if successful, or 1 if the test failed
- */
-int x509_self_test( int verbose );
-
-/**
- * \brief Write a certificate info file
- *
- * \param chain points to the raw certificate data
- * \param path filename to write the certificate to
- * \param format X509_OUTPUT_DER or X509_OUTPUT_PEM
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509write_crtfile( x509_raw *chain,
- unsigned char *path,
- int format );
-
-/**
- * \brief Write a certificate signing request message format file
- *
- * \param chain points to the raw certificate (with x509write_create_csr) data
- * \param path filename to write the certificate to
- * \param format X509_OUTPUT_DER or X509_OUTPUT_PEM
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509write_csrfile( x509_raw *chain,
- unsigned char *path,
- int format );
-
-/*
- * \brief Write a private RSA key into a file
- *
- * \param rsa points to an RSA key
- * \param path filename to write the key to
- * \param format X509_OUTPUT_DER or X509_OUTPUT_PEM
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509write_keyfile( rsa_context *rsa,
- char *path,
- int format );
-
-/**
- * \brief Add a public key to certificate
- *
- * \param chain points to the raw certificate data
- * \param pubkey points to an RSA key
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509write_add_pubkey( x509_raw *chain, rsa_context *pubkey );
-
-/**
- * \brief Create x509 subject/issuer field to raw certificate
- * from string or CA cert. Make string NULL if you will
- * use the CA copy function or make CA NULL then used
- * the string parse.
- *
- * \param chain points to the raw certificate data
- * \param names a string that can hold (separete with ";"):
- * CN=CommonName
- * -- O=Organization
- * -- OU=OrgUnit
- * -- ST=State
- * -- L=Locality
- * -- R=Email
- * -- C=Country
- * . Make that NULL if you didn't need that.
- * \param flag flag is X509_ISSUER or X509_SUBJECT that defined
- * where change
- * \param ca the certificate for copy data. Make that NULL if you
- * didn't need that.
- * \param ca_flag set the ca field from copy to crt
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509write_add_customize ( x509_raw *crt,
- unsigned char *names,
- int flag,
- x509_cert *ca,
- int ca_flag );
-
-/**
-* \brief Add x509 issuer field
-*
-* \param chain points to the raw certificate data
-* \param issuer a string holding (separete with ";"):
-* CN=CommonName
-* -- O=Organization
-* -- OU=OrgUnit
-* -- ST=State
-* -- L=Locality
-* -- R=Email
-* -- C=Country
-* . Set this to NULL if not needed.
-* \return 0 if successful, or a specific X509 error code
-*/
-int x509write_add_issuer( x509_raw *crt, unsigned char *issuer);
-
-/**
- * \brief Add x509 subject field
- *
- * \param chain points to the raw certificate data
- * \param subject a string holding (separete with ";"):
- * CN=CommonName
- * -- O=Organization
- * -- OU=OrgUnit
- * -- ST=State
- * -- L=Locality
- * -- R=Email
- * -- C=Country
- * . Set this to NULL if not needed.
- * \return 0 if successful, or a specific X509 error code
- */
-int x509write_add_subject( x509_raw *crt, unsigned char *subject);
-
-/**
-* \brief Copy x509 issuer field from another certificate
-*
-* \param chain points to the raw certificate data
-* \param from_crt the certificate whose issuer is to be copied.
-* \return 0 if successful, or a specific X509 error code
-*/
-int x509write_copy_issuer(x509_raw *crt, x509_cert *from_crt);
-
-/**
-* \brief Copy x509 subject field from another certificate
-*
-* \param chain points to the raw certificate data
-* \param from_crt the certificate whose subject is to be copied.
-* \return 0 if successful, or a specific X509 error code
-*/
-int x509write_copy_subject(x509_raw *crt, x509_cert *from_crt);
-
-/**
-* \brief Copy x509 issuer field from the subject of another certificate
-*
-* \param chain points to the raw certificate data
-* \param from_crt the certificate whose subject is to be copied.
-* \return 0 if successful, or a specific X509 error code
-*/
-int x509write_copy_issuer_from_subject(x509_raw *crt, x509_cert *from_crt);
-
-/**
-* \brief Copy x509 subject field from the issuer of another certificate
-*
-* \param chain points to the raw certificate data
-* \param from_crt the certificate whose issuer is to be copied.
-* \return 0 if successful, or a specific X509 error code
-*/
-int x509write_copy_subject_from_issuer(x509_raw *crt, x509_cert *from_crt);
-
-/**
- * \brief Create x509 validity time in UTC
- *
- * \param chain points to the raw certificate data
- * \param before valid not before in format YYYY-MM-DD hh:mm:ss
- * \param after valid not after in format YYYY-MM-DD hh:mm:ss
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509write_add_validity( x509_raw *crt,
- unsigned char *before,
- unsigned char *after );
-
-/**
- * \brief Create a self-signed certificate
- *
- * \param chain points to the raw certificate data
- * \param rsa a private key to sign the certificate
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509write_create_selfsign( x509_raw *crt, rsa_context *raw );
-
-/**
- * \brief Create a certificate
- *
- * \param chain points to the raw certificate data
- * \param rsa a private key to sign the certificate
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509write_create_sign( x509_raw *crt, rsa_context *raw );
-
-/**
- * \brief Create a certificate signing request
- *
- * \param chain points to the raw certificate data. Didn't use the
- * same chain that u have use for certificate.
- * \param privkey a rsa private key
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509write_create_csr( x509_raw *chain, rsa_context *privkey );
-
-/**
- * \brief Serialize an rsa key into DER
- *
- * \param rsa a rsa key for output
- * \param node a x509 node for write into
- *
- * \return 0 if successful, or a specific X509 error code
- */
-int x509write_serialize_key( rsa_context *rsa, x509_node *node );
-
-/**
- * \brief Unallocate all raw certificate data
- */
-void x509write_free_raw( x509_raw *crt );
-
-/**
- * \brief Allocate all raw certificate data
- */
-void x509write_init_raw( x509_raw *crt );
-
-/**
- * \brief Unallocate all node certificate data
- */
-void x509write_free_node( x509_node *crt_node );
-
-/**
- * \brief Allocate all node certificate data
- */
-void x509write_init_node( x509_node *crt_node );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* x509.h */
+++ /dev/null
-/*
- * px5g - Embedded x509 key and certificate generator based on PolarSSL
- *
- * Copyright (C) 2009 Steven Barth <steven@midlink.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License, version 2.1 as published by the Free Software Foundation.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <limits.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include "polarssl/bignum.h"
-#include "polarssl/x509.h"
-#include "polarssl/rsa.h"
-
-#define PX5G_VERSION "0.1"
-#define PX5G_COPY "Copyright (c) 2009 Steven Barth <steven@midlink.org>"
-#define PX5G_LICENSE "Licensed under the GNU Lesser General Public License v2.1"
-
-static int urandom_fd;
-
-static int _urandom(void *ctx)
-{
- int ret;
- read(urandom_fd, &ret, sizeof(ret));
- return ret;
-}
-
-
-int rsakey(char **arg) {
- rsa_context rsa;
-
- unsigned int ksize = 512;
- int exp = 65537;
- char *path = NULL;
- int flag = X509_OUTPUT_PEM;
-
- while (*arg && **arg == '-') {
- if (!strcmp(*arg, "-out") && arg[1]) {
- path = arg[1];
- arg++;
- } else if (!strcmp(*arg, "-3")) {
- exp = 3;
- } else if (!strcmp(*arg, "-der")) {
- flag = X509_OUTPUT_DER;
- }
- arg++;
- }
-
- if (*arg) {
- ksize = (unsigned int)atoi(*arg);
- }
-
- rsa_init(&rsa, RSA_PKCS_V15, 0, _urandom, NULL);
-
- fprintf(stderr, "Generating RSA private key, %i bit long modulus\n", ksize);
- if (rsa_gen_key(&rsa, ksize, exp)) {
- fprintf(stderr, "error: key generation failed\n");
- return 1;
- }
-
- if (x509write_keyfile(&rsa, path, flag)) {
- fprintf(stderr, "error: I/O error\n");
- return 1;
- }
-
- rsa_free(&rsa);
- return 0;
-}
-
-int selfsigned(char **arg) {
- rsa_context rsa;
- x509_node node;
-
- char *subject = "";
- unsigned int ksize = 512;
- int exp = 65537;
- unsigned int days = 30;
- char *keypath = NULL, *certpath = NULL;
- int flag = X509_OUTPUT_PEM;
- time_t from = time(NULL), to;
- char fstr[20], tstr[20];
-
- while (*arg && **arg == '-') {
- if (!strcmp(*arg, "-der")) {
- flag = X509_OUTPUT_DER;
- } else if (!strcmp(*arg, "-newkey") && arg[1]) {
- if (strncmp(arg[1], "rsa:", 4)) {
- fprintf(stderr, "error: invalid algorithm");
- return 1;
- }
- ksize = (unsigned int)atoi(arg[1] + 4);
- arg++;
- } else if (!strcmp(*arg, "-days") && arg[1]) {
- days = (unsigned int)atoi(arg[1]);
- arg++;
- } else if (!strcmp(*arg, "-keyout") && arg[1]) {
- keypath = arg[1];
- arg++;
- } else if (!strcmp(*arg, "-out") && arg[1]) {
- certpath = arg[1];
- arg++;
- } else if (!strcmp(*arg, "-subj") && arg[1]) {
- if (arg[1][0] != '/' || strchr(arg[1], ';')) {
- fprintf(stderr, "error: invalid subject");
- return 1;
- }
- subject = calloc(strlen(arg[1]) + 1, 1);
- char *oldc = arg[1] + 1, *newc = subject, *delim;
- do {
- delim = strchr(oldc, '=');
- if (!delim) {
- fprintf(stderr, "error: invalid subject");
- return 1;
- }
- memcpy(newc, oldc, delim - oldc + 1);
- newc += delim - oldc + 1;
- oldc = delim + 1;
-
- delim = strchr(oldc, '/');
- if (!delim) {
- delim = arg[1] + strlen(arg[1]);
- }
- memcpy(newc, oldc, delim - oldc);
- newc += delim - oldc;
- *newc++ = ';';
- oldc = delim + 1;
- } while(*delim);
- arg++;
- }
- arg++;
- }
-
- rsa_init(&rsa, RSA_PKCS_V15, 0, _urandom, NULL);
- x509write_init_node(&node);
- fprintf(stderr, "Generating RSA private key, %i bit long modulus\n", ksize);
- if (rsa_gen_key(&rsa, ksize, exp)) {
- fprintf(stderr, "error: key generation failed\n");
- return 1;
- }
-
- if (keypath) {
- if (x509write_keyfile(&rsa, keypath, flag)) {
- fprintf(stderr, "error: I/O error\n");
- return 1;
- }
- }
-
- from = (from < 1000000000) ? 1000000000 : from;
- strftime(fstr, sizeof(fstr), "%F %H:%M:%S", gmtime(&from));
- to = from + 60 * 60 * 24 * days;
- if (to < from)
- to = INT_MAX;
- strftime(tstr, sizeof(tstr), "%F %H:%M:%S", gmtime(&to));
-
- x509_raw cert;
- x509write_init_raw(&cert);
- x509write_add_pubkey(&cert, &rsa);
- x509write_add_subject(&cert, (unsigned char*)subject);
- x509write_add_validity(&cert, (unsigned char*)fstr, (unsigned char*)tstr);
- fprintf(stderr, "Generating selfsigned certificate with subject '%s'"
- " and validity %s-%s\n", subject, fstr, tstr);
- if (x509write_create_selfsign(&cert, &rsa)) {
- fprintf(stderr, "error: certificate generation failed\n");
- }
-
- if (x509write_crtfile(&cert, (unsigned char*)certpath, flag)) {
- fprintf(stderr, "error: I/O error\n");
- return 1;
- }
-
- x509write_free_raw(&cert);
- rsa_free(&rsa);
- return 0;
-}
-
-int main(int argc, char *argv[]) {
- urandom_fd = open("/dev/urandom", O_RDONLY);
- if (urandom_fd < 0) {
- perror("open(/dev/urandom)");
- return 1;
- }
-
- if (!argv[1]) {
- //Usage
- } else if (!strcmp(argv[1], "rsakey")) {
- return rsakey(argv+2);
- } else if (!strcmp(argv[1], "selfsigned")) {
- return selfsigned(argv+2);
- }
-
- fprintf(stderr,
- "PX5G X.509 Certificate Generator Utility v" PX5G_VERSION "\n" PX5G_COPY
- "\nbased on PolarSSL by Christophe Devine and Paul Bakker\n\n");
- fprintf(stderr, "Usage: %s [rsakey|selfsigned]\n", *argv);
- return 1;
-}
PKG_NAME:=px5g
PKG_RELEASE:=4
PKG_LICENSE:=LGPL-2.1
-PKG_BUILD_DIR:=$(BUILD_DIR)/px5g
+PKG_BUILD_DIR:=$(BUILD_DIR)/px5g-$(BUILD_VARIANT)
PKG_USE_MIPS16:=0
+PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
+
include $(INCLUDE_DIR)/package.mk
define Package/px5g-mbedtls
CATEGORY:=Utilities
SUBMENU:=Encryption
TITLE:=X.509 certificate generator (using mbedtls)
- MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
DEPENDS:=+libmbedtls
PROVIDES:=px5g
+ VARIANT:=mbedtls
endef
define Package/px5g-mbedtls/description
and PEM format for use with stunnel, uhttpd and others.
endef
+define Package/px5g-standalone
+ SECTION:=utils
+ CATEGORY:=Utilities
+ SUBMENU:=Encryption
+ TITLE:=X.509 certificate generator (standalone)
+ VARIANT:=standalone
+endef
+Package/px5g-standalone/description = $(Package/px5g-mbedtls/description)
+
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
TARGET_LDFLAGS := -lmbedtls -lmbedx509 -lmbedcrypto
+ifeq ($(BUILD_VARIANT),standalone)
+ TARGET_LDFLAGS := -Wl,-Bstatic $(TARGET_LDFLAGS) -Wl,-Bdynamic
+endif
+
+TARGET_CFLAGS += -Wl,--gc-sections
+
define Build/Compile
$(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/px5g px5g.c $(TARGET_LDFLAGS)
endef
$(INSTALL_BIN) $(PKG_BUILD_DIR)/px5g $(1)/usr/sbin/px5g
endef
+Package/px5g-standalone/install = $(Package/px5g-mbedtls/install)
+
$(eval $(call BuildPackage,px5g-mbedtls))
+$(eval $(call BuildPackage,px5g-standalone))
include $(TOPDIR)/rules.mk
PKG_NAME:=ugps
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE_URL=$(LEDE_GIT)/project/ugps.git
PKG_SOURCE_PROTO:=git
config gps
option 'tty' 'ttyACM0'
- option 'adjust_time ' '1'
+ option 'adjust_time' '1'
}
return $have_curl
- ? (qw(curl --connect-timeout 20 --retry 5 --location --insecure), shellwords($ENV{CURL_OPTIONS} || ''), $url)
+ ? (qw(curl -f --connect-timeout 20 --retry 5 --location --insecure), shellwords($ENV{CURL_OPTIONS} || ''), $url)
: (qw(wget --tries=5 --timeout=20 --no-check-certificate --output-document=-), shellwords($ENV{WGET_OPTIONS} || ''), $url)
;
}
}
#push @mirrors, 'http://mirror1.openwrt.org';
-push @mirrors, 'https://librecmc.org/librecmc/downloads/sources/v1.4/';
+push @mirrors, 'https://librecmc.org/librecmc/downloads/sources/v1.4';
push @mirrors, 'http://sources.lede-project.org';
push @mirrors, 'http://mirror2.openwrt.org/sources';
push @mirrors, 'http://downloads.openwrt.org/sources';
use Cwd 'abs_path';
chdir "$FindBin::Bin/..";
-$ENV{TOPDIR}=getcwd();
+$ENV{TOPDIR} //= getcwd();
+chdir $ENV{TOPDIR};
$ENV{GIT_CONFIG_PARAMETERS}="'core.autocrlf=false'";
$ENV{GREP_OPTIONS}="";
}
find $TARGETS -type f -a -exec file {} \; | \
- sed -n -e 's/^\(.*\):.*ELF.*\(executable\|shared object\).*,.* stripped/\1/p' | \
+ sed -n -e 's/^\(.*\):.*ELF.*\(executable\|shared object\).*,.*/\1/p' | \
$XARGS -n1 $READELF -d | \
awk '$2 ~ /NEEDED/ && $NF !~ /interpreter/ && $NF ~ /^\[?lib.*\.so/ { gsub(/[\[\]]/, "", $NF); print $NF }' | \
sort -u
try_hg() {
[ -d .hg ] || return 1
- SOURCE_DATE_EPOCH=""
+ SOURCE_DATE_EPOCH="$(hg log --template '{date}' -l 1 | cut -d. -f1)"
[ -n "$SOURCE_DATE_EPOCH" ]
}
-try_version || try_git || try_hg || SOURCE_DATE_EPOCH=""
+try_mtime() {
+ perl -e 'print((stat $ARGV[0])[9])' "$0"
+ [ -n "$SOURCE_DATE_EPOCH" ]
+}
+
+try_version || try_git || try_hg || try_mtime || SOURCE_DATE_EPOCH=""
echo "$SOURCE_DATE_EPOCH"
}
try_git() {
- REBOOT=375587f4b29039d86880030c6ab9a135e0342567
+ REBOOT=ee53a240ac902dc83209008a2671e7fdcf55957a
git rev-parse --git-dir >/dev/null 2>&1 || return 1
[ -n "$GET_REV" ] || GET_REV="HEAD"
REV="${UPSTREAM_REV}+$((REV - UPSTREAM_REV))"
fi
- REV="${REV:+r$REV-$(git log --format="%h" -1)}"
+ REV="${REV:+r$REV-$(git log -n 1 --format="%h" $UPSTREAM_BASE)}"
+
;;
esac
#
usage() {
- echo "Usage: $0 <OM2P|OM5P|OM5PAC|MR600|MR900|MR1750> <out file path> <kernel path> <rootfs path>"
+ echo "Usage: $0 <OM2P|OM5P|OM5PAC|MR600|MR900|MR1750|A60> <out file path> <kernel path> <rootfs path>"
rm -f $CFG_OUT
exit 1
}
FLASH_BS=262144
MD5_SKIP_BLOCKS=1
;;
- OM5P|OM5PAC|MR600|MR900|MR1750)
+ OM5P|OM5PAC|MR600|MR900|MR1750|A60)
MAX_PART_SIZE=7808
KERNEL_FLASH_ADDR=0xb0000
FLASH_BS=65536
$flags =~ /@/ or $depend = "PACKAGE_$depend";
}
}
+
if ($condition) {
if ($m =~ /select/) {
next if $depend eq $condition;
$depend = "$depend if $condition";
} else {
+ next if $dep->{"$depend if $condition"};
$depend = "!($condition) || $depend" unless $dep->{$condition} eq 'select';
}
}
}
find $TARGETS -type f -a -exec file {} \; | \
- sed -n -e 's/^\(.*\):.*ELF.*\(executable\|relocatable\|shared object\).*,.* stripped/\1:\2/p' | \
+ sed -n -e 's/^\(.*\):.*ELF.*\(executable\|relocatable\|shared object\).*,.*/\1:\2/p' | \
(
IFS=":"
while read F S; do
choice
prompt "Target Profile"
+ default TARGET_MULTI_PROFILE if BUILDBOT
EOF
foreach my $target (@target) {
my $profile = $target->{profiles}->[0];
$profile or next;
print <<EOF;
- default TARGET_$target->{conf}_$profile->{id} if TARGET_$target->{conf}
+ default TARGET_$target->{conf}_$profile->{id} if TARGET_$target->{conf} && !BUILDBOT
EOF
}
config TARGET_ALL_PROFILES
bool "Enable all profiles by default"
+ default BUILDBOT
config TARGET_PER_DEVICE_ROOTFS
bool "Use a per-device root filesystem that adds profile packages"
+ default BUILDBOT
help
When disabled, all device packages from all selected devices
will be included in all images by default. (Marked as <*>) You will
config IB
- bool "Build the libreCMC Image Builder"
+ bool "Build the LEDE Image Builder"
depends on !EXTERNAL_TOOLCHAIN
+ default BUILDBOT
help
This is essentially a stripped-down version of the buildroot
with precompiled packages, kernel image and image building tools.
config IB_STANDALONE
bool "Include package repositories"
- default y
+ default y if !BUILDBOT
depends on IB
help
Disabling this option will cause the ImageBuilder to embed only
$(PKG_BUILD_DIR)/target/linux/*/patches{,-*}
-cp $(KERNEL_BUILD_DIR)/* $(IB_KDIR)/ # don't copy subdirectories here
-cp $(LINUX_DIR)/.config $(IB_LDIR)/
+ rm -f $(IB_KDIR)/root.*
+ rm -f $(IB_KDIR)/vmlinux.debug
if [ -x $(LINUX_DIR)/scripts/dtc/dtc ]; then \
$(INSTALL_DIR) $(IB_LDIR)/scripts/dtc; \
$(INSTALL_BIN) $(LINUX_DIR)/scripts/dtc/dtc $(IB_LDIR)/scripts/dtc/dtc; \
USER_PROFILE ?= $(firstword $(PROFILE_NAMES))
PROFILE_LIST = $(foreach p,$(PROFILE_NAMES), \
- echo '$(patsubst DEVICE_%,%,$(p)):'; $(if $($(p)_NAME),echo ' $($(p)_NAME)'; ) echo ' Packages: $($(p)_PACKAGES)'; \
+ echo '$(patsubst DEVICE_%,%,$(p)):'; $(if $($(p)_NAME),echo ' $(subst ','"'"',$($(p)_NAME))'; ) echo ' Packages: $($(p)_PACKAGES)'; \
)
.profiles.mk: .targetinfo
ARCH:=mips
BOARD:=ar71xx
BOARDNAME:=Atheros AR7xxx/AR9xxx
-FEATURES:=mips16
+FEATURES:=
CPU_TYPE:=24kc
SUBTARGETS:=generic nand mikrotik
board=$(ar71xx_board_name)
case "$board" in
+a40)
+ ucidef_set_led_default "status-red" "Status (red)" "a40:red:status" "0"
+ ucidef_set_led_default "status-blue" "Status (blue)" "a40:blue:status" "0"
+ ;;
+a60)
+ ucidef_set_led_default "status-red" "Status (red)" "a60:red:status" "0"
+ ucidef_set_led_default "status-blue" "Status (blue)" "a60:blue:status" "0"
+ ;;
airgateway|\
airgatewaypro)
ucidef_set_led_wlan "wlan" "WLAN" "ubnt:blue:wlan" "phy0tpt"
ucidef_set_led_switch "port4" "port4" "rb750:green:port4" "switch0" "0x04"
ucidef_set_led_switch "port5" "port5" "rb750:green:port5" "switch0" "0x02"
;;
+rb-941-2nd)
+ ucidef_set_led_timer "act" "act" "rb:green:act" "1000" "1000"
+ ;;
rb-2011l|\
rb-2011uas|\
rb-2011uias|\
;;
om2p|\
om2pv2|\
+om2pv4|\
om2p-hs|\
om2p-hsv2|\
om2p-hsv3|\
+om2p-hsv4|\
om2p-lc)
ucidef_set_led_netdev "port1" "port1" "om2p:blue:wan" "eth0"
ucidef_set_led_netdev "port2" "port2" "om2p:blue:lan" "eth1"
tl-wr741nd|\
tl-wr741nd-v4|\
tl-wr841n-v11|\
- tl-wr841n-v7|\
tl-wr841n-v9|\
tl-wr842n-v3|\
whr-g301n|\
mr900v2|\
mynet-rext|\
rb-411|\
+ rb-411u|\
rb-911g-2hpnd|\
rb-911g-5hpacd|\
rb-911g-5hpnd|\
wp543)
ucidef_set_interface_lan "eth0"
;;
+ a40|\
+ a60|\
alfa-ap96|\
alfa-nx|\
gl-ar150|\
gl-inet|\
gl-mifi|\
jwap003|\
+ om2pv4|\
+ om2p-hsv4|\
pb42|\
pb44|\
rb-951ui-2hnd|\
dap-2695-a1)
ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:wan" "6@eth1"
;;
+ rb-941-2nd)
+ ucidef_add_switch "switch0" \
+ "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:wan:1"
+ ;;
db120|\
rb-2011l|\
rb-2011uas|\
tl-wr941nd-v5|\
tl-wr941nd-v6|\
wnr1000-v2|\
- wnr2000-v3|\
wnr2000-v4|\
wnr2200|\
wnr612-v2|\
ucidef_add_switch "switch0" \
"2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "0@eth0" "1:wan"
;;
- gl-ar300)
+ gl-ar300|\
+ wnr2000-v3)
ucidef_set_interfaces_lan_wan "eth1" "eth0"
ucidef_add_switch "switch0" \
"0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
ucidef_set_interface_raw "eth" "eth0"
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
;;
+ tl-wr841n-v7)
+ ucidef_set_interfaces_lan_wan "eth0" "eth1"
+ ucidef_add_switch "switch0" \
+ "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
+ ;;
tl-wr842n-v2)
ucidef_set_interfaces_lan_wan "eth1" "eth0"
ucidef_add_switch "switch0" \
ucidef_add_switch "switch0" \
"0@eth0" "2:lan" "3:wan"
;;
- wndr3700)
+ wndr3700|\
+ wndr3700v2|\
+ wndr3800|\
+ wndr3800ch)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
- "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
+ "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth0"
ucidef_add_switch_attr "switch0" "blinkrate" 2
ucidef_add_switch_port_attr "switch0" 1 led 6
;;
rb-912uag-2hpnd|\
rb-912uag-5hpnd)
- ucidef_add_gpio_switch "usb_power_switch" "USB Power Switch" "52"
+ ucidef_add_gpio_switch "usb_power_switch" "USB Power Switch" "52" "1"
;;
esac
local board=$(ar71xx_board_name)
case $board in
+ a40)
+ status_led="a40:green:status"
+ ;;
+ a60)
+ status_led="a60:green:status"
+ ;;
alfa-nx)
status_led="alfa:green:led_8"
;;
;;
om2p|\
om2pv2|\
+ om2pv4|\
om2p-hs|\
om2p-hsv2|\
om2p-hsv3|\
+ om2p-hsv4|\
om2p-lc)
status_led="om2p:blue:power"
;;
rb-912uag-5hpnd)
status_led="rb:green:user"
;;
- rb-951ui-2hnd)
+ rb-951ui-2hnd | rb-941-2nd)
status_led="rb:green:act"
;;
rb-sxt2n|\
ath10kcal_extract "art" 20480 2116
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -1)
;;
+ a40 | \
+ a60 | \
mr1750 | \
mr1750v2 | \
om5p-acv2)
*"Oolite V1.0")
name="oolite"
;;
+ *"A40")
+ name="a40"
+ ;;
+ *"A60")
+ name="a60"
+ ;;
*"AC1750DB")
name="f9k1115v2"
;;
*OM2Pv2)
name="om2pv2"
;;
+ *OM2Pv4)
+ name="om2pv4"
+ ;;
*"OM2P HS")
name="om2p-hs"
;;
*"OM2P HSv3")
name="om2p-hsv3"
;;
+ *"OM2P HSv4")
+ name="om2p-hsv4"
+ ;;
*"OM2P LC")
name="om2p-lc"
;;
*"RouterBOARD 912UAG-5HPnD")
name="rb-912uag-5hpnd"
;;
+ *"RouterBOARD 941-2nD")
+ name="rb-941-2nd"
+ ;;
*"RouterBOARD 951G-2HnD")
name="rb-951g-2hnd"
;;
img_board_target="$1"
case "$img_board_target" in
+ A60)
+ [ "$board" = "a40" ] && return 0
+ [ "$board" = "a60" ] && return 0
+ echo "Invalid image board target ($img_board_target) for this platform: $board. Use the correct image for this platform"
+ return 1
+ ;;
OM2P)
[ "$board" = "om2p" ] && return 0
[ "$board" = "om2pv2" ] && return 0
+ [ "$board" = "om2pv4" ] && return 0
[ "$board" = "om2p-lc" ] && return 0
[ "$board" = "om2p-hs" ] && return 0
[ "$board" = "om2p-hsv2" ] && return 0
[ "$board" = "om2p-hsv3" ] && return 0
+ [ "$board" = "om2p-hsv4" ] && return 0
echo "Invalid image board target ($img_board_target) for this platform: $board. Use the correct image for this platform"
return 1
;;
kernel_start_addr1=0x9f1c0000
kernel_start_addr2=0x9f8c0000
;;
- OM5P|OM5PAC|MR600|MR900|MR1750)
+ OM5P|OM5PAC|MR600|MR900|MR1750|A60)
block_size=$((64 * 1024))
total_size=7995392
kernel_start_addr1=0x9f0b0000
PART_NAME=firmware
RAMFS_COPY_DATA=/lib/ar71xx.sh
+[ -x /usr/sbin/nandwrite ] && RAMFS_COPY_BIN=/usr/sbin/nandwrite
CI_BLKSZ=65536
CI_LDADR=0x80060000
+PLATFORM_DO_UPGRADE_COMBINED_SEPARATE_MTD=0
+
platform_find_partitions() {
local first dev size erasesize name
while read dev size erasesize name; do
done
}
+platform_find_rootfspart() {
+ local part
+ for part in "${1%:*}" "${1#*:}"; do
+ [ "$part" != "$2" ] && echo "$part" && break
+ done
+}
+
platform_do_upgrade_combined() {
local partitions=$(platform_find_partitions)
local kernelpart=$(platform_find_kernelpart "${partitions#*:}")
[ ${root_blocks:-0} -gt 0 ] && \
[ ${erase_size:-0} -gt 0 ];
then
+ local rootfspart=$(platform_find_rootfspart "$partitions" "$kernelpart")
local append=""
[ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR"
- ( dd if="$1" bs=$CI_BLKSZ skip=1 count=$kern_blocks 2>/dev/null; \
- dd if="$1" bs=$CI_BLKSZ skip=$((1+$kern_blocks)) count=$root_blocks 2>/dev/null ) | \
- mtd -r $append -F$kernelpart:$kern_length:$CI_LDADR,rootfs write - $partitions
+ if [ "$PLATFORM_DO_UPGRADE_COMBINED_SEPARATE_MTD" -ne 1 ]; then
+ ( dd if="$1" bs=$CI_BLKSZ skip=1 count=$kern_blocks 2>/dev/null; \
+ dd if="$1" bs=$CI_BLKSZ skip=$((1+$kern_blocks)) count=$root_blocks 2>/dev/null ) | \
+ mtd -r $append -F$kernelpart:$kern_length:$CI_LDADR,rootfs write - $partitions
+ elif [ -n "$rootfspart" ]; then
+ dd if="$1" bs=$CI_BLKSZ skip=1 count=$kern_blocks 2>/dev/null | \
+ mtd write - $kernelpart
+ dd if="$1" bs=$CI_BLKSZ skip=$((1+$kern_blocks)) count=$root_blocks 2>/dev/null | \
+ mtd -r $append write - $rootfspart
+ fi
fi
+ PLATFORM_DO_UPGRADE_COMBINED_SEPARATE_MTD=0
}
tplink_get_image_hwid() {
return 0
}
+platform_nand_board_name() {
+ local board=$(ar71xx_board_name)
+
+ case "$board" in
+ rb*) echo "routerboard";;
+ *) echo "$board";;
+ esac
+}
+
platform_check_image() {
local board=$(ar71xx_board_name)
local magic="$(get_magic_word "$1")"
ls-sr71|\
pb42|\
pb44|\
+ rb-941-2nd|\
routerstation-pro|\
routerstation|\
wp543|\
tew-673gru)
dir825b_check_image "$1" && return 0
;;
+ rb*)
+ nand_do_platform_check routerboard $1
+ return $?
+ ;;
c-60|\
nbg6716|\
r6100|\
tplink_pharos_check_image "$1" && return 0
return 1
;;
+ a40|\
+ a60|\
mr1750v2|\
mr1750|\
mr600v2|\
mr900|\
om2p-hsv2|\
om2p-hsv3|\
+ om2p-hsv4|\
om2p-hs|\
om2p-lc|\
om2pv2|\
+ om2pv4|\
om2p|\
om5p-acv2|\
om5p-ac|\
local board=$(ar71xx_board_name)
case "$board" in
+ rb-941-2nd)
+ ;;
+ rb*|\
c-60|\
nbg6716|\
r6100|\
esac
}
+platform_nand_pre_upgrade() {
+ local board=$(ar71xx_board_name)
+
+ case "$board" in
+ rb*)
+ CI_KERNPART=none
+ local fw_mtd=$(find_mtd_part kernel)
+ fw_mtd="${fw_mtd/block/}"
+ [ -n "$fw_mtd" ] || return
+ mtd erase kernel
+ tar xf "$1" sysupgrade-routerboard/kernel -O | nandwrite -o "$fw_mtd" -
+ ;;
+ esac
+}
+
platform_do_upgrade() {
local board=$(ar71xx_board_name)
case "$board" in
+ rb-941-2nd)
+ PLATFORM_DO_UPGRADE_COMBINED_SEPARATE_MTD=1
+ platform_do_upgrade_combined "$ARGV"
+ ;;
all0258n)
platform_do_upgrade_allnet "0x9f050000" "$ARGV"
;;
tew-673gru)
platform_do_upgrade_dir825b "$ARGV"
;;
+ a40|\
+ a60|\
mr1750v2|\
mr1750|\
mr600v2|\
mr900|\
om2p-hsv2|\
om2p-hsv3|\
+ om2p-hsv4|\
om2p-hs|\
om2p-lc|\
om2pv2|\
+ om2pv4|\
om2p|\
om5p-acv2|\
om5p-ac|\
+++ /dev/null
-#!/bin/sh
-# wget2nand
-# This script can be used to download a TGZ file from your build system which
-# contains the files to be installed on the NAND flash on your RB1xx card.
-# The one parameter is the URL of the TGZ file to be downloaded.
-# Licence GPL V2
-# Author david.goodenough@linkchoose.co.uk
-# Based on cf2nand from RB532 support
-. /lib/functions.sh
-
-wget2nand_dir=/tmp/wget2nand
-mnt_kernel=$wget2nand_dir/mnt_kernel
-mnt_rootfs=$wget2nand_dir/mnt_rootfs
-src_rootfs=$wget2nand_dir/rootfs.tgz
-src_kernel=$wget2nand_dir/kernel
-
-[ -d "$wget2nand_dir" ] && {
- echo "$wget2nand_dir already exists"
- exit 1
-}
-
-# need to find the wget server from the command line
-url=$1
-[ -z "$url" ] && {
- echo "No URL specified for image TGZ"
- echo "Usage : $0 URL"
- exit 1
-}
-
-url_kernel=$url/lede-ar71xx-mikrotik-vmlinux-lzma.elf
-url_rootfs=$url/lede-ar71xx-mikrotik-defaultnowifi-rootfs.tar.gz
-
-mtd_kernel="$(find_mtd_part 'kernel')"
-mtd_rootfs="$(find_mtd_part 'rootfs')"
-[ -z "$mtd_kernel" -o -z "$mtd_rootfs" ] && {
- echo "Cannot find NAND Flash partitions"
- exit 1
-}
-
-mkdir "$wget2nand_dir"
-wget $url_kernel -O "$src_kernel" || {
- echo "Unable to download $url_kernel"
- exit 1
-}
-
-wget $url_rootfs -O "$src_rootfs" || {
- echo "Unable to download $url_rootfs"
- exit 1
-}
-
-echo "Erasing filesystem..."
-mtd erase kernel 2>/dev/null >/dev/null
-mtd erase rootfs 2>/dev/null >/dev/null
-
-echo "Mounting $mtd_rootfs as new root and $mtd_kernel as kernel partition"
-
-mkdir "$mnt_kernel"
-mkdir "$mnt_rootfs"
-mount -t yaffs2 "$mtd_kernel" "$mnt_kernel"
-mount -t yaffs2 "$mtd_rootfs" "$mnt_rootfs"
-
-echo "Copying kernel..."
-cp $src_kernel $mnt_kernel/kernel || {
- echo "Error occured while copying the kernel"
- exit 1
-}
-chmod +x $mnt_kernel/kernel
-
-echo "Preparing filesystem..."
-( cd "$mnt_rootfs"; tar xvz -f "$src_rootfs" )
-
-# make sure everything is written before we unmount the partitions
-echo "chmod ugo+x /" > $mnt_rootfs/etc/uci-defaults/set_root_permission
-sync
-ls $mnt_kernel >/dev/null
-ls $mnt_rootfs >/dev/null
-
-echo "Cleaning up..."
-# unmount the partitions and remove the directories into which they were mounted
-umount $mnt_kernel
-umount $mnt_rootfs
-rm -rf $wget2nand_dir
-
-# all done
-echo "Image written, you can now reboot. Remember to change the boot source to Boot from Nand"
CONFIG_ATH79_DEV_SPI=y
CONFIG_ATH79_DEV_USB=y
CONFIG_ATH79_DEV_WMAC=y
+CONFIG_ATH79_MACH_A60=y
CONFIG_ATH79_MACH_ALFA_AP120C=y
CONFIG_ATH79_MACH_ALFA_AP96=y
CONFIG_ATH79_MACH_ALFA_NX=y
# CONFIG_ATH79_MACH_RB750 is not set
# CONFIG_ATH79_MACH_RB91X is not set
# CONFIG_ATH79_MACH_RB922 is not set
+# CONFIG_ATH79_MACH_RB941 is not set
# CONFIG_ATH79_MACH_RB95X is not set
# CONFIG_ATH79_MACH_RBSXTLITE is not set
CONFIG_ATH79_MACH_RE450=y
+config ATH79_MACH_A60
+ bool "OpenMesh A40/A60 board support"
+ select SOC_QCA955X
+ select ATH79_DEV_AP9X_PCI if PCI
+ select ATH79_DEV_ETH
+ select ATH79_DEV_LEDS_GPIO
+ select ATH79_DEV_M25P80
+ select ATH79_DEV_WMAC
+ select ATH79_DEV_USB
+
config ATH79_MACH_ALFA_AP120C
bool "ALFA Network AP120C board support"
select ATH79_DEV_AP9X_PCI if PCI
select ATH79_ROUTERBOOT
select RLE_DECOMPRESS
+config ATH79_MACH_RB941
+ bool "MikroTik RouterBOARD 941-2nd support"
+ select SOC_QCA953X
+ select ATH79_DEV_ETH
+ select ATH79_DEV_GPIO_BUTTONS
+ select ATH79_DEV_LEDS_GPIO
+ select ATH79_DEV_M25P80
+ select ATH79_DEV_WMAC
+ select ATH79_ROUTERBOOT
+
config ATH79_MACH_RB95X
bool "MikroTik RouterBOARD 95X support"
select SOC_AR934X
bool "OpenMesh OM2P board support"
select SOC_AR724X
select SOC_AR933X
+ select SOC_QCA953X
select ATH79_DEV_AP9X_PCI if PCI
select ATH79_DEV_ETH
select ATH79_DEV_GPIO_BUTTONS
#
# Machines
#
+obj-$(CONFIG_ATH79_MACH_A60) += mach-a60.o
obj-$(CONFIG_ATH79_MACH_ALFA_AP120C) += mach-alfa-ap120c.o
obj-$(CONFIG_ATH79_MACH_ALFA_AP96) += mach-alfa-ap96.o
obj-$(CONFIG_ATH79_MACH_ALFA_NX) += mach-alfa-nx.o
obj-$(CONFIG_ATH79_MACH_RB750) += mach-rb750.o
obj-$(CONFIG_ATH79_MACH_RB91X) += mach-rb91x.o
obj-$(CONFIG_ATH79_MACH_RB922) += mach-rb922.o
+obj-$(CONFIG_ATH79_MACH_RB941) += mach-rb941.o
obj-$(CONFIG_ATH79_MACH_RB95X) += mach-rb95x.o
obj-$(CONFIG_ATH79_MACH_RBSXTLITE) += mach-rbsxtlite.o
obj-$(CONFIG_ATH79_MACH_RE450) += mach-re450.o
if (pdata->phy_if_mode == PHY_INTERFACE_MODE_SGMII)
pdata->set_speed = qca956x_set_speed_sgmii;
else
- pdata->set_speed = ath79_set_speed_ge0;
+ pdata->set_speed = ar934x_set_speed_ge0;
} else {
pdata->reset_bit = QCA955X_RESET_GE1_MAC |
QCA955X_RESET_GE1_MDIO;
--- /dev/null
+/*
+ * OpenMesh A60 support
+ *
+ * Copyright (C) 2013 Marek Lindner <marek@open-mesh.com>
+ * Copyright (C) 2014-2017 Sven Eckelmann <sven@open-mesh.com>
+ *
+ * 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 <linux/gpio.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/platform_device.h>
+#include <linux/platform_data/phy-at803x.h>
+
+#include <asm/mach-ath79/ar71xx_regs.h>
+#include <asm/mach-ath79/ath79.h>
+
+#include "common.h"
+#include "dev-ap9x-pci.h"
+#include "dev-eth.h"
+#include "dev-leds-gpio.h"
+#include "dev-gpio-buttons.h"
+#include "dev-m25p80.h"
+#include "dev-wmac.h"
+#include "machtypes.h"
+#include "pci.h"
+#include "dev-usb.h"
+
+#define A60_GPIO_LED_RED 22
+#define A60_GPIO_LED_GREEN 23
+#define A60_GPIO_LED_BLUE 13
+
+#define A60_GPIO_BTN_RESET 17
+
+#define A60_KEYS_POLL_INTERVAL 20 /* msecs */
+#define A60_KEYS_DEBOUNCE_INTERVAL (3 * A60_KEYS_POLL_INTERVAL)
+
+#define A60_WMAC_CALDATA_OFFSET 0x1000
+
+static struct gpio_led a40_leds_gpio[] __initdata = {
+ {
+ .name = "a40:red:status",
+ .gpio = A60_GPIO_LED_RED,
+ }, {
+ .name = "a40:green:status",
+ .gpio = A60_GPIO_LED_GREEN,
+ }, {
+ .name = "a40:blue:status",
+ .gpio = A60_GPIO_LED_BLUE,
+ }
+};
+
+static struct gpio_led a60_leds_gpio[] __initdata = {
+ {
+ .name = "a60:red:status",
+ .gpio = A60_GPIO_LED_RED,
+ }, {
+ .name = "a60:green:status",
+ .gpio = A60_GPIO_LED_GREEN,
+ }, {
+ .name = "a60:blue:status",
+ .gpio = A60_GPIO_LED_BLUE,
+ }
+};
+
+static struct gpio_keys_button a60_gpio_keys[] __initdata = {
+ {
+ .desc = "Reset button",
+ .type = EV_KEY,
+ .code = KEY_RESTART,
+ .debounce_interval = A60_KEYS_DEBOUNCE_INTERVAL,
+ .gpio = A60_GPIO_BTN_RESET,
+ .active_low = 1,
+ },
+};
+
+static struct at803x_platform_data a60_at803x_data = {
+ .disable_smarteee = 1,
+ .enable_rgmii_rx_delay = 1,
+ .enable_rgmii_tx_delay = 1,
+};
+
+static struct mdio_board_info a60_mdio0_info[] = {
+ {
+ .bus_id = "ag71xx-mdio.0",
+ .phy_addr = 1,
+ .platform_data = &a60_at803x_data,
+ },
+ {
+ .bus_id = "ag71xx-mdio.0",
+ .phy_addr = 2,
+ .platform_data = &a60_at803x_data,
+ },
+};
+
+static void __init a60_setup_qca955x_eth_cfg(u32 mask,
+ unsigned int rxd,
+ unsigned int rxdv,
+ unsigned int txd,
+ unsigned int txe)
+{
+ void __iomem *base;
+ u32 t;
+
+ base = ioremap(QCA955X_GMAC_BASE, QCA955X_GMAC_SIZE);
+
+ t = mask;
+ t |= rxd << QCA955X_ETH_CFG_RXD_DELAY_SHIFT;
+ t |= rxdv << QCA955X_ETH_CFG_RDV_DELAY_SHIFT;
+ t |= txd << QCA955X_ETH_CFG_TXD_DELAY_SHIFT;
+ t |= txe << QCA955X_ETH_CFG_TXE_DELAY_SHIFT;
+
+ __raw_writel(t, base + QCA955X_GMAC_REG_ETH_CFG);
+
+ iounmap(base);
+}
+
+static void __init a60_setup_common(void)
+{
+ u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
+ u8 mac[6];
+
+ ath79_register_usb();
+
+ ath79_register_m25p80(NULL);
+ ath79_register_gpio_keys_polled(-1, A60_KEYS_POLL_INTERVAL,
+ ARRAY_SIZE(a60_gpio_keys),
+ a60_gpio_keys);
+
+ ath79_init_mac(mac, art, 0x02);
+ ath79_register_wmac(art + A60_WMAC_CALDATA_OFFSET, mac);
+
+ a60_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN, 3, 3, 0, 0);
+ ath79_register_mdio(0, 0x0);
+
+ mdiobus_register_board_info(a60_mdio0_info, ARRAY_SIZE(a60_mdio0_info));
+
+ ath79_init_mac(ath79_eth0_data.mac_addr, art, 0x00);
+ ath79_init_mac(ath79_eth1_data.mac_addr, art, 0x01);
+
+ /* GMAC0 is connected to the PHY1 */
+ ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
+ ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
+ ath79_eth0_data.phy_mask = BIT(1);
+ ath79_eth0_pll_data.pll_1000 = 0x82000101;
+ ath79_eth0_pll_data.pll_100 = 0x80000101;
+ ath79_eth0_pll_data.pll_10 = 0x80001313;
+ ath79_register_eth(0);
+
+ /* GMAC1 is connected to MDIO1 in SGMII mode */
+ ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
+ ath79_eth1_data.mii_bus_dev = &ath79_mdio0_device.dev;
+ ath79_eth1_data.phy_mask = BIT(2);
+ ath79_eth1_pll_data.pll_1000 = 0x03000101;
+ ath79_eth1_pll_data.pll_100 = 0x80000101;
+ ath79_eth1_pll_data.pll_10 = 0x80001313;
+ ath79_eth1_data.speed = SPEED_1000;
+ ath79_eth1_data.duplex = DUPLEX_FULL;
+ ath79_register_eth(1);
+
+ ath79_register_pci();
+}
+
+static void __init a40_setup(void)
+{
+ ath79_register_leds_gpio(-1, ARRAY_SIZE(a40_leds_gpio), a40_leds_gpio);
+ a60_setup_common();
+}
+
+MIPS_MACHINE(ATH79_MACH_A40, "A40", "OpenMesh A40", a40_setup);
+
+static void __init a60_setup(void)
+{
+ ath79_register_leds_gpio(-1, ARRAY_SIZE(a60_leds_gpio), a60_leds_gpio);
+ a60_setup_common();
+}
+
+MIPS_MACHINE(ATH79_MACH_A60, "A60", "OpenMesh A60", a60_setup);
#define OM2P_LC_GPIO_LED_WAN 17
#define OM2P_LC_GPIO_BTN_RESET 12
+#define OM2Pv4_GPIO_LED_POWER 0
+#define OM2Pv4_GPIO_LED_GREEN 2
+#define OM2Pv4_GPIO_LED_RED 4
+#define OM2Pv4_GPIO_LED_YELLOW 3
+#define OM2Pv4_GPIO_LED_LAN 14
+#define OM2Pv4_GPIO_LED_WAN 13
+#define OM2Pv4_GPIO_BTN_RESET 1
+
+#define OM2P_WMAC_CALDATA_OFFSET 0x1000
+
static struct flash_platform_data om2p_flash_data = {
.type = "s25sl12800",
.name = "ar7240-nor0",
MIPS_MACHINE(ATH79_MACH_OM2P_HS, "OM2P-HS", "OpenMesh OM2P HS", om2p_hs_setup);
MIPS_MACHINE(ATH79_MACH_OM2P_HSv2, "OM2P-HSv2", "OpenMesh OM2P HSv2", om2p_hs_setup);
MIPS_MACHINE(ATH79_MACH_OM2P_HSv3, "OM2P-HSv3", "OpenMesh OM2P HSv3", om2p_hs_setup);
+
+static struct flash_platform_data om2pv4_flash_data = {
+ .type = "s25sl12800",
+};
+
+static struct gpio_led om2pv4_leds_gpio[] __initdata = {
+ {
+ .name = "om2p:blue:power",
+ .gpio = OM2Pv4_GPIO_LED_POWER,
+ .active_low = 1,
+ }, {
+ .name = "om2p:red:wifi",
+ .gpio = OM2Pv4_GPIO_LED_RED,
+ .active_low = 1,
+ }, {
+ .name = "om2p:yellow:wifi",
+ .gpio = OM2Pv4_GPIO_LED_YELLOW,
+ .active_low = 1,
+ }, {
+ .name = "om2p:green:wifi",
+ .gpio = OM2Pv4_GPIO_LED_GREEN,
+ .active_low = 1,
+ }, {
+ .name = "om2p:blue:lan",
+ .gpio = OM2Pv4_GPIO_LED_LAN,
+ .active_low = 1,
+ }, {
+ .name = "om2p:blue:wan",
+ .gpio = OM2Pv4_GPIO_LED_WAN,
+ .active_low = 1,
+ }
+};
+
+static struct gpio_keys_button om2pv4_gpio_keys[] __initdata = {
+ {
+ .desc = "reset",
+ .type = EV_KEY,
+ .code = KEY_RESTART,
+ .debounce_interval = OM2P_KEYS_DEBOUNCE_INTERVAL,
+ .gpio = OM2Pv4_GPIO_BTN_RESET,
+ .active_low = 1,
+ }
+};
+
+static void __init om2pv4_setup(void)
+{
+ u8 *mac1 = (u8 *)KSEG1ADDR(0x1ffc0000);
+ u8 *mac2 = (u8 *)KSEG1ADDR(0x1ffc0000 + ETH_ALEN);
+ u8 *art = (u8 *)KSEG1ADDR(0x1ffc0000);
+ u8 wmac[6];
+
+ ath79_register_m25p80(&om2pv4_flash_data);
+ ath79_register_leds_gpio(-1, ARRAY_SIZE(om2pv4_leds_gpio),
+ om2pv4_leds_gpio);
+ ath79_register_gpio_keys_polled(-1, OM2P_KEYS_POLL_INTERVAL,
+ ARRAY_SIZE(om2pv4_gpio_keys),
+ om2pv4_gpio_keys);
+
+ ath79_init_mac(wmac, art, 0x02);
+ ath79_register_wmac(art + OM2P_WMAC_CALDATA_OFFSET, wmac);
+
+ ath79_setup_ar933x_phy4_switch(false, false);
+
+ ath79_register_mdio(0, 0x0);
+
+ /* LAN */
+ ath79_switch_data.phy4_mii_en = 1;
+ ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+ ath79_eth0_data.duplex = DUPLEX_FULL;
+ ath79_eth0_data.speed = SPEED_100;
+ ath79_eth0_data.phy_mask = BIT(4);
+ ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
+ ath79_register_eth(0);
+
+ /* WAN */
+ ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
+ ath79_eth1_data.duplex = DUPLEX_FULL;
+ ath79_switch_data.phy_poll_mask |= BIT(4);
+ ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
+ ath79_register_eth(1);
+}
+
+MIPS_MACHINE(ATH79_MACH_OM2Pv4, "OM2Pv4", "OpenMesh OM2Pv4", om2pv4_setup);
+MIPS_MACHINE(ATH79_MACH_OM2P_HSv4, "OM2P-HSv4", "OpenMesh OM2P HSv4", om2pv4_setup);
.size = (4 * 1024 * 1024) - (256 * 1024),
},
{
- .name = "rootfs",
+ .name = "ubi",
.offset = MTDPART_OFS_NXTBLK,
.size = MTDPART_SIZ_FULL,
},
rb750_nand_data.disable_pins = rb750_nand_disable_pins;
rb750_nand_data.latch_change = rb750_latch_change;
platform_device_register(&rb750_nand_device);
+
+ /* USB */
+ ath79_register_usb();
}
MIPS_MACHINE(ATH79_MACH_RB_750, "750i", "MikroTik RouterBOARD 750",
.size = (4 * 1024 * 1024) - (256 * 1024),
},
{
- .name = "rootfs",
+ .name = "ubi",
.offset = MTDPART_OFS_NXTBLK,
.size = MTDPART_SIZ_FULL,
},
--- /dev/null
+/*
+ * MikroTik RouterBOARD 941-2nD support
+ *
+ * Copyright (C) 2016 Sergey Sergeev <adron@yapic.net>
+ *
+ * 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 <linux/export.h>
+#include <linux/pci.h>
+#include <linux/ath9k_platform.h>
+#include <linux/platform_device.h>
+#include <linux/phy.h>
+#include <linux/ar8216_platform.h>
+#include <linux/rle.h>
+#include <linux/routerboot.h>
+#include <linux/gpio.h>
+
+#include <linux/mtd/mtd.h>
+//#include <linux/mtd/nand.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/mach-ath79/ar71xx_regs.h>
+#include <asm/mach-ath79/ath79.h>
+#include <asm/mach-ath79/irq.h>
+
+#include "common.h"
+#include "dev-ap9x-pci.h"
+#include "dev-eth.h"
+#include "dev-spi.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-m25p80.h"
+//#include "dev-usb.h"
+#include "dev-wmac.h"
+#include "machtypes.h"
+#include "routerboot.h"
+
+#define RB941_GPIO_LED_ACT 14
+#define RB941_GPIO_BTN_RESET 16
+
+#define RB941_KEYS_POLL_INTERVAL 20 /* msecs */
+#define RB941_KEYS_DEBOUNCE_INTERVAL (3 * RB941_KEYS_POLL_INTERVAL)
+
+#define RB_ROUTERBOOT_OFFSET 0x0000
+#define RB_ROUTERBOOT_SIZE 0xe000
+#define RB_HARD_CFG_OFFSET 0xe000
+#define RB_HARD_CFG_SIZE 0x1000
+#define RB_BIOS_OFFSET 0xf000
+#define RB_BIOS_SIZE 0x1000
+#define RB_ROUTERBOOT2_OFFSET 0x10000
+#define RB_ROUTERBOOT2_SIZE 0xf000
+#define RB_SOFT_CFG_OFFSET 0x1f000
+#define RB_SOFT_CFG_SIZE 0x1000
+#define RB_ROOTFS_OFFSET 0x20000
+#define RB_ROOTFS_SIZE 0x9e0000
+#define RB_KERNEL_OFFSET 0xa00000
+#define RB_KERNEL_SIZE MTDPART_SIZ_FULL
+
+void __init rb941_wlan_init(void)
+{
+ char *art_buf;
+ u8 wlan_mac[ETH_ALEN];
+
+ art_buf = rb_get_wlan_data();
+ if (art_buf == NULL)
+ return;
+
+ ath79_init_mac(wlan_mac, ath79_mac_base, 11);
+ ath79_register_wmac(art_buf + 0x1000, wlan_mac);
+
+ kfree(art_buf);
+}
+
+static struct mtd_partition rb941_spi_partitions[] = {
+ {
+ .name = "routerboot",
+ .offset = RB_ROUTERBOOT_OFFSET,
+ .mask_flags = MTD_WRITEABLE,
+ .size = RB_ROUTERBOOT_SIZE,
+ }, {
+ .name = "hard_config",
+ .offset = RB_HARD_CFG_OFFSET,
+ .size = RB_HARD_CFG_SIZE,
+ .mask_flags = MTD_WRITEABLE,
+ }, {
+ .name = "bios",
+ .offset = RB_BIOS_OFFSET,
+ .size = RB_BIOS_SIZE,
+ .mask_flags = MTD_WRITEABLE,
+ }, {
+ .name = "routerboot2",
+ .offset = RB_ROUTERBOOT2_OFFSET,
+ .size = RB_ROUTERBOOT2_SIZE,
+ .mask_flags = MTD_WRITEABLE,
+ }, {
+ .name = "soft_config",
+ .offset = RB_SOFT_CFG_OFFSET,
+ .size = RB_SOFT_CFG_SIZE,
+ }, {
+ .name = "rootfs",
+ .offset = RB_ROOTFS_OFFSET,
+ .size = RB_ROOTFS_SIZE,
+ }, {
+ .name = "kernel",
+ .offset = RB_KERNEL_OFFSET,
+ .size = RB_KERNEL_SIZE,
+ }
+};
+
+static struct flash_platform_data rb941_spi_flash_data = {
+ .parts = rb941_spi_partitions,
+ .nr_parts = ARRAY_SIZE(rb941_spi_partitions),
+};
+
+static struct gpio_led rb941_leds[] __initdata = {
+ {
+ .name = "rb:green:act",
+ .gpio = RB941_GPIO_LED_ACT,
+ .active_low = 1,
+ },
+};
+
+static struct gpio_keys_button rb941_gpio_keys[] __initdata = {
+ {
+ .desc = "Reset button",
+ .type = EV_KEY,
+ .code = KEY_RESTART,
+ .debounce_interval = RB941_KEYS_DEBOUNCE_INTERVAL,
+ .gpio = RB941_GPIO_BTN_RESET,
+ .active_low = 1,
+ },
+};
+
+static void __init rb941_setup(void)
+{
+ const struct rb_info *info;
+ //try to get rb_info data
+ info = rb_init_info((void *)(KSEG1ADDR(AR71XX_SPI_BASE)), 0x20000);
+ if (!info){
+ pr_err("%s: Can't get rb_info data from flash!\n", __func__);
+ //return -EINVAL; //Not critical ... continue!
+ }
+ ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
+ ath79_register_m25p80(&rb941_spi_flash_data);
+ ath79_register_mdio(0, 0x0);
+
+ /* WAN. We have no WAN. Only LAN. */
+ /*ath79_switch_data.phy4_mii_en = 1;
+ ath79_switch_data.phy_poll_mask = BIT(4);
+ ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+ ath79_eth0_data.phy_mask = BIT(4);
+ ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
+ ath79_register_eth(0); */
+
+ /* LAN */
+ ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 0);
+ ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
+ ath79_register_eth(1);
+
+ //ath79_register_usb();
+
+ rb941_wlan_init();
+
+ ath79_register_leds_gpio(-1, ARRAY_SIZE(rb941_leds), rb941_leds);
+ ath79_register_gpio_keys_polled(-1, RB941_KEYS_POLL_INTERVAL,
+ ARRAY_SIZE(rb941_gpio_keys),
+ rb941_gpio_keys);
+}
+
+MIPS_MACHINE(ATH79_MACH_RB_941, "H951L", "MikroTik RouterBOARD 941-2nD", rb941_setup);
.size = (4 * 1024 * 1024) - (256 * 1024),
},
{
- .name = "rootfs",
+ .name = "ubi",
.offset = MTDPART_OFS_NXTBLK,
.size = MTDPART_SIZ_FULL,
},
.size = (4 * 1024 * 1024) - (256 * 1024),
},
{
- .name = "rootfs",
+ .name = "ubi",
.offset = MTDPART_OFS_NXTBLK,
.size = MTDPART_SIZ_FULL,
},
enum ath79_mach_type {
ATH79_MACH_GENERIC_OF = -1, /* Device tree board */
ATH79_MACH_GENERIC = 0,
+ ATH79_MACH_A40, /* OpenMesh A40 */
+ ATH79_MACH_A60, /* OpenMesh A60 */
ATH79_MACH_ALFA_AP120C, /* ALFA Network AP120C board */
ATH79_MACH_ALFA_AP96, /* ALFA Network AP96 board */
ATH79_MACH_ALFA_NX, /* ALFA Network N2/N5 board */
ATH79_MACH_NBG6716, /* Zyxel NBG6716 */
ATH79_MACH_OM2P, /* OpenMesh OM2P */
ATH79_MACH_OM2Pv2, /* OpenMesh OM2Pv2 */
+ ATH79_MACH_OM2Pv4, /* OpenMesh OM2Pv4 */
ATH79_MACH_OM2P_HS, /* OpenMesh OM2P-HS */
ATH79_MACH_OM2P_HSv2, /* OpenMesh OM2P-HSv2 */
ATH79_MACH_OM2P_HSv3, /* OpenMesh OM2P-HSv3 */
+ ATH79_MACH_OM2P_HSv4, /* OpenMesh OM2P-HSv4 */
ATH79_MACH_OM2P_LC, /* OpenMesh OM2P-LC */
ATH79_MACH_OM5P, /* OpenMesh OM5P */
ATH79_MACH_OM5P_AC, /* OpenMesh OM5P-AC */
ATH79_MACH_RB_751, /* MikroTik RouterBOARD 751 */
ATH79_MACH_RB_751G, /* Mikrotik RouterBOARD 751G */
ATH79_MACH_RB_922GS, /* Mikrotik RouterBOARD 911/922GS boards */
+ ATH79_MACH_RB_941, /* MikroTik RouterBOARD 941-2nD */
ATH79_MACH_RB_951G, /* Mikrotik RouterBOARD 951G */
ATH79_MACH_RB_951U, /* Mikrotik RouterBOARD 951Ui-2HnD */
ATH79_MACH_RB_SXTLITE2ND, /* Mikrotik RouterBOARD SXT Lite 2nD */
.size = (4 * 1024 * 1024) - (256 * 1024),
},
{
- .name = "rootfs",
+ .name = "ubi",
.offset = MTDPART_OFS_NXTBLK,
.size = MTDPART_SIZ_FULL,
},
.offset = (256 * 1024),
.size = (4 * 1024 * 1024) - (256 * 1024),
}, {
- .name = "rootfs",
+ .name = "ubi",
.offset = MTDPART_OFS_NXTBLK,
.size = MTDPART_SIZ_FULL,
},
.offset = (256 * 1024),
.size = (4 * 1024 * 1024) - (256 * 1024),
}, {
- .name = "rootfs",
+ .name = "ubi",
.offset = MTDPART_OFS_NXTBLK,
.size = MTDPART_SIZ_FULL,
},
ifeq ($(SUBTARGET),nand)
include ./nand.mk
endif
+ifeq ($(SUBTARGET),mikrotik)
+include ./mikrotik.mk
+endif
include ./legacy.mk
define Build/netgear-squashfs
mkimage -A $(LINUX_KARCH) \
-O linux -T kernel \
-C $(1) -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
- -n 'tw150v1 $(call toupper,$(LINUX_KARCH)) LEDE Linux-$(LINUX_VERSION)' -d $@ $@.new
+ -n 'tw150v1 $(call toupper,$(LINUX_KARCH)) libreCMC Linux-$(LINUX_VERSION)' -d $@ $@.new
@mv $@.new $@
endef
$(STAGING_DIR_HOST)/bin/mkwrggimg -b \
-i $@ -o $@.imghdr -d /dev/mtdblock/1 \
-m $(BOARDNAME) -s $(DAP_SIGNATURE) \
- -v LEDE -B $(REVISION)
+ -v libreCMC -B $(REVISION)
mv $@.imghdr $@
endef
MTDPARTS := spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14528k(rootfs),1472k(kernel),64k(art)ro,16000k@0x50000(firmware)
IMAGES := sysupgrade.bin factory.bin
IMAGE/sysupgrade.bin = append-rootfs | pad-rootfs | pad-to $$$$(ROOTFS_SIZE) | append-kernel | check-size $$$$(IMAGE_SIZE)
- IMAGE/factory.bin = append-kernel | pad-to $$$$(KERNEL_SIZE) | append-rootfs | mkbuffaloimg
+ IMAGE/factory.bin = append-kernel | pad-to $$$$(KERNEL_SIZE) | append-rootfs | pad-rootfs | mkbuffaloimg
endef
TARGET_DEVICES += bhr-4grv2
+define LegacyDevice/A60
+ DEVICE_TITLE := OpenMesh A40/A60
+ DEVICE_PACKAGES := om-watchdog kmod-ath10k ath10k-firmware-qca988x \
+ mod-usb-core kmod-usb2
+endef
+LEGACY_DEVICES += A60
+
define LegacyDevice/ALFANX
DEVICE_TITLE := ALFA Network N2/N5 board
endef
LEGACY_DEVICES += WPN824N
define LegacyDevice/OM2P
- DEVICE_TITLE := OpenMesh OM2P/OM2Pv2/OM2P-HS/OM2P-HSv2/OM2P-HSv3/OM2P-LC
+ DEVICE_TITLE := OpenMesh OM2P/OM2P-HS/OM2P-LC
DEVICE_PACKAGES := om-watchdog
endef
LEGACY_DEVICES += OM2P
LEGACY_DEVICES += OM5P
define LegacyDevice/OM5PAC
- DEVICE_TITLE := OpenMesh OM5P-AC/OM5P-ACv2
+ DEVICE_TITLE := OpenMesh OM5P-AC
DEVICE_PACKAGES := kmod-ath10k ath10k-firmware-qca988x om-watchdog
endef
LEGACY_DEVICES += OM5PAC
LEGACY_DEVICES += MR600
define LegacyDevice/MR900
- DEVICE_TITLE := OpenMesh MR900/MR900v2
+ DEVICE_TITLE := OpenMesh MR900
DEVICE_PACKAGES := om-watchdog
endef
LEGACY_DEVICES += MR900
define LegacyDevice/MR1750
- DEVICE_TITLE := OpenMesh MR1750/MR1750v2
- DEVICE_PACKAGES := kmod-ath10k ath10k-firmware-qca988x
+ DEVICE_TITLE := OpenMesh MR1750
+ DEVICE_PACKAGES := om-watchdog kmod-ath10k ath10k-firmware-qca988x
endef
LEGACY_DEVICES += MR1750
$(eval $(call SingleProfile,Netgear,64kraw,WNR1000V2_VC,wnr1000v2-vc,WNR1000V2,ttyS0,115200,$$(wnr2000v3_mtdlayout),0x31303030,WNR1000V2-VC,"",))
$(eval $(call SingleProfile,Netgear,64kraw,WPN824N,wpn824n,WPN824N,ttyS0,115200,$$(wnr2000v3_mtdlayout),0x31313030,WPN824N,"" NA,))
+$(eval $(call SingleProfile,OpenMesh,squashfs-only,A60,a60,,,,A60))
$(eval $(call SingleProfile,OpenMesh,squashfs-only,OM2P,om2p,,,,OM2P))
$(eval $(call SingleProfile,OpenMesh,squashfs-only,OM5P,om5p,,,,OM5P))
$(eval $(call SingleProfile,OpenMesh,squashfs-only,OM5PAC,om5pac,,,,OM5PAC))
--- /dev/null
+define Device/mikrotik
+ PROFILES := Default
+ DEVICE_PACKAGES := kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport nand-utils
+ BOARD_NAME := routerboard
+ KERNEL_INITRAMFS :=
+ KERNEL_NAME := loader-generic.elf
+ KERNEL := kernel-bin | kernel2minor -s 2048 -e -c
+ FILESYSTEMS := squashfs
+ IMAGES := sysupgrade.bin
+ IMAGE/sysupgrade.bin := sysupgrade-tar
+endef
+
+define Device/nand-64m
+ DEVICE_TITLE := MikroTik RouterBoard with 64 MB NAND flash
+$(Device/mikrotik)
+ KERNEL := kernel-bin | kernel2minor -s 512 -e -c
+endef
+
+define Device/nand-large
+ DEVICE_TITLE := MikroTik RouterBoard with >= 128 MB NAND flash
+$(Device/mikrotik)
+ KERNEL := kernel-bin | kernel2minor -s 2048 -e -c
+endef
+
+TARGET_DEVICES += nand-64m nand-large
+
+define Device/rb-nor-flash-16M
+ DEVICE_TITLE := MikroTik RouterBoard with 16 MB NOR flash
+ DEVICE_PACKAGES := rbcfg
+ BLOCKSIZE := 64k
+ IMAGE_SIZE := 16000k
+ LOADER_TYPE := elf
+ KERNEL_INSTALL := 1
+ KERNEL := kernel-bin | lzma | loader-kernel | kernel2minor -s 1024 -e
+ KERNEL_INITRAMFS := kernel-bin | lzma | loader-kernel
+ IMAGES := sysupgrade.bin
+ IMAGE/sysupgrade.bin = append-rootfs | pad-rootfs | combined-image | check-size $$$$(IMAGE_SIZE)
+endef
+
+define Device/rb-941-2nd
+$(Device/rb-nor-flash-16M)
+ DEVICE_TITLE := hAP lite
+ BOARDNAME:= rb-941-2nd
+endef
define LegacyDevice/R6100
DEVICE_TITLE := NETGEAR R6100
- DEVICE_PACKAGES := kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport
+ DEVICE_PACKAGES := kmod-ath10k ath10k-firmware-qca988x kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport
endef
LEGACY_DEVICES += R6100
# CONFIG_ATH79_DEV_DSA is not set
+# CONFIG_ATH79_MACH_ALFA_AP120C is not set
# CONFIG_ATH79_MACH_ALFA_AP96 is not set
# CONFIG_ATH79_MACH_ALFA_NX is not set
# CONFIG_ATH79_MACH_ALL0258N is not set
# CONFIG_ATH79_MACH_ALL0315N is not set
# CONFIG_ATH79_MACH_ANTMINER_S1 is not set
+# CONFIG_ATH79_MACH_ANTMINER_S3 is not set
+# CONFIG_ATH79_MACH_ANTROUTER_R1 is not set
# CONFIG_ATH79_MACH_AP121 is not set
# CONFIG_ATH79_MACH_AP132 is not set
# CONFIG_ATH79_MACH_AP136 is not set
+# CONFIG_ATH79_MACH_AP143 is not set
# CONFIG_ATH79_MACH_AP147 is not set
+# CONFIG_ATH79_MACH_AP152 is not set
+# CONFIG_ATH79_MACH_AP90Q is not set
# CONFIG_ATH79_MACH_AP96 is not set
# CONFIG_ATH79_MACH_ARCHER_C7 is not set
+# CONFIG_ATH79_MACH_ARDUINO_YUN is not set
# CONFIG_ATH79_MACH_AW_NR580 is not set
+# CONFIG_ATH79_MACH_BHR_4GRV2 is not set
# CONFIG_ATH79_MACH_BHU_BXU2000N2_A is not set
+# CONFIG_ATH79_MACH_BSB is not set
+# CONFIG_ATH79_MACH_C55 is not set
+# CONFIG_ATH79_MACH_C60 is not set
# CONFIG_ATH79_MACH_CAP324 is not set
# CONFIG_ATH79_MACH_CAP4200AG is not set
# CONFIG_ATH79_MACH_CARAMBOLA2 is not set
+# CONFIG_ATH79_MACH_CF_E316N_V2 is not set
+# CONFIG_ATH79_MACH_CF_E320N_V2 is not set
+# CONFIG_ATH79_MACH_CF_E380AC_V1 is not set
+# CONFIG_ATH79_MACH_CF_E380AC_V2 is not set
+# CONFIG_ATH79_MACH_CF_E520N is not set
+# CONFIG_ATH79_MACH_CF_E530N is not set
# CONFIG_ATH79_MACH_CPE510 is not set
+# CONFIG_ATH79_MACH_CPE830 is not set
+# CONFIG_ATH79_MACH_CPE870 is not set
# CONFIG_ATH79_MACH_CR3000 is not set
# CONFIG_ATH79_MACH_CR5000 is not set
+# CONFIG_ATH79_MACH_DAP_2695_A1 is not set
# CONFIG_ATH79_MACH_DB120 is not set
# CONFIG_ATH79_MACH_DGL_5500_A1 is not set
# CONFIG_ATH79_MACH_DHP_1565_A1 is not set
# CONFIG_ATH79_MACH_DIR_505_A1 is not set
# CONFIG_ATH79_MACH_DIR_600_A1 is not set
# CONFIG_ATH79_MACH_DIR_615_C1 is not set
+# CONFIG_ATH79_MACH_DIR_615_I1 is not set
# CONFIG_ATH79_MACH_DIR_825_B1 is not set
# CONFIG_ATH79_MACH_DIR_825_C1 is not set
# CONFIG_ATH79_MACH_DIR_869_A1 is not set
+# CONFIG_ATH79_MACH_DLAN_HOTSPOT is not set
+# CONFIG_ATH79_MACH_DLAN_PRO_1200_AC is not set
+# CONFIG_ATH79_MACH_DLAN_PRO_500_WP is not set
+# CONFIG_ATH79_MACH_DOMYWIFI_DW33D is not set
+# CONFIG_ATH79_MACH_DR344 is not set
+# CONFIG_ATH79_MACH_DR531 is not set
# CONFIG_ATH79_MACH_DRAGINO2 is not set
+# CONFIG_ATH79_MACH_E2100L is not set
+# CONFIG_ATH79_MACH_EAP120 is not set
# CONFIG_ATH79_MACH_EAP300V2 is not set
# CONFIG_ATH79_MACH_EAP7660D is not set
# CONFIG_ATH79_MACH_EL_M150 is not set
# CONFIG_ATH79_MACH_ESR900 is not set
# CONFIG_ATH79_MACH_EW_DORIN is not set
# CONFIG_ATH79_MACH_F9K1115V2 is not set
+# CONFIG_ATH79_MACH_GL_AR150 is not set
+# CONFIG_ATH79_MACH_GL_AR300 is not set
+# CONFIG_ATH79_MACH_GL_AR300M is not set
+# CONFIG_ATH79_MACH_GL_DOMINO is not set
# CONFIG_ATH79_MACH_GL_INET is not set
+# CONFIG_ATH79_MACH_GL_MIFI is not set
+# CONFIG_ATH79_MACH_GS_MINIBOX_V1 is not set
# CONFIG_ATH79_MACH_GS_OOLITE is not set
# CONFIG_ATH79_MACH_HIWIFI_HC6361 is not set
# CONFIG_ATH79_MACH_HORNET_UB is not set
# CONFIG_ATH79_MACH_JA76PF is not set
# CONFIG_ATH79_MACH_JWAP003 is not set
+# CONFIG_ATH79_MACH_JWAP230 is not set
# CONFIG_ATH79_MACH_MC_MAC1200R is not set
# CONFIG_ATH79_MACH_MR12 is not set
# CONFIG_ATH79_MACH_MR16 is not set
+# CONFIG_ATH79_MACH_MR1750 is not set
+# CONFIG_ATH79_MACH_MR18 is not set
# CONFIG_ATH79_MACH_MR600 is not set
# CONFIG_ATH79_MACH_MR900 is not set
# CONFIG_ATH79_MACH_MYNET_N600 is not set
# CONFIG_ATH79_MACH_NBG6716 is not set
# CONFIG_ATH79_MACH_OM2P is not set
# CONFIG_ATH79_MACH_OM5P is not set
+# CONFIG_ATH79_MACH_OM5P_AC is not set
+# CONFIG_ATH79_MACH_OM5P_ACv2 is not set
+# CONFIG_ATH79_MACH_OMY_G1 is not set
+# CONFIG_ATH79_MACH_OMY_X1 is not set
+# CONFIG_ATH79_MACH_ONION_OMEGA is not set
# CONFIG_ATH79_MACH_PB42 is not set
# CONFIG_ATH79_MACH_PB44 is not set
# CONFIG_ATH79_MACH_QIHOO_C301 is not set
CONFIG_ATH79_MACH_RB750=y
CONFIG_ATH79_MACH_RB91X=y
CONFIG_ATH79_MACH_RB922=y
+CONFIG_ATH79_MACH_RB941=y
CONFIG_ATH79_MACH_RB95X=y
CONFIG_ATH79_MACH_RBSXTLITE=y
# CONFIG_ATH79_MACH_RE450 is not set
# CONFIG_ATH79_MACH_RW2458N is not set
# CONFIG_ATH79_MACH_SMART_300 is not set
+# CONFIG_ATH79_MACH_SOM9331 is not set
+# CONFIG_ATH79_MACH_SR3200 is not set
+# CONFIG_ATH79_MACH_TELLSTICK_ZNET_LITE is not set
# CONFIG_ATH79_MACH_TEW_632BRP is not set
# CONFIG_ATH79_MACH_TEW_673GRU is not set
# CONFIG_ATH79_MACH_TEW_712BR is not set
# CONFIG_ATH79_MACH_TEW_732BR is not set
+# CONFIG_ATH79_MACH_TEW_823DRU is not set
# CONFIG_ATH79_MACH_TL_MR11U is not set
# CONFIG_ATH79_MACH_TL_MR13U is not set
# CONFIG_ATH79_MACH_TL_MR3020 is not set
# CONFIG_ATH79_MACH_TL_MR3X20 is not set
# CONFIG_ATH79_MACH_TL_WA701ND_V2 is not set
# CONFIG_ATH79_MACH_TL_WA7210N_V2 is not set
+# CONFIG_ATH79_MACH_TL_WA801ND_V3 is not set
# CONFIG_ATH79_MACH_TL_WA830RE_V2 is not set
# CONFIG_ATH79_MACH_TL_WA901ND is not set
# CONFIG_ATH79_MACH_TL_WA901ND_V2 is not set
+# CONFIG_ATH79_MACH_TL_WA901ND_V4 is not set
# CONFIG_ATH79_MACH_TL_WAX50RE is not set
+# CONFIG_ATH79_MACH_TL_WDR3320_V2 is not set
# CONFIG_ATH79_MACH_TL_WDR3500 is not set
# CONFIG_ATH79_MACH_TL_WDR4300 is not set
+# CONFIG_ATH79_MACH_TL_WDR6500_V2 is not set
+# CONFIG_ATH79_MACH_TL_WPA8630 is not set
# CONFIG_ATH79_MACH_TL_WR1041N_V2 is not set
# CONFIG_ATH79_MACH_TL_WR1043ND is not set
# CONFIG_ATH79_MACH_TL_WR1043ND_V2 is not set
# CONFIG_ATH79_MACH_TL_WR741ND is not set
# CONFIG_ATH79_MACH_TL_WR741ND_V4 is not set
# CONFIG_ATH79_MACH_TL_WR802N_V1 is not set
+# CONFIG_ATH79_MACH_TL_WR810N is not set
# CONFIG_ATH79_MACH_TL_WR841N_V1 is not set
# CONFIG_ATH79_MACH_TL_WR841N_V8 is not set
# CONFIG_ATH79_MACH_TL_WR841N_V9 is not set
-# CONFIG_ATH79_MACH_TL_WR941ND is not set
# CONFIG_ATH79_MACH_TL_WR940N_V4 is not set
+# CONFIG_ATH79_MACH_TL_WR941ND is not set
+# CONFIG_ATH79_MACH_TL_WR941ND_V6 is not set
# CONFIG_ATH79_MACH_TUBE2H is not set
# CONFIG_ATH79_MACH_UBNT is not set
# CONFIG_ATH79_MACH_UBNT_UNIFIAC is not set
# CONFIG_ATH79_MACH_UBNT_XM is not set
+# CONFIG_ATH79_MACH_WEIO is not set
# CONFIG_ATH79_MACH_WHR_HP_G300N is not set
# CONFIG_ATH79_MACH_WLAE_AG300N is not set
# CONFIG_ATH79_MACH_WLR8100 is not set
# CONFIG_ATH79_MACH_WPJ558 is not set
# CONFIG_ATH79_MACH_WRT160NL is not set
# CONFIG_ATH79_MACH_WRT400N is not set
+# CONFIG_ATH79_MACH_WRTNODE2Q is not set
# CONFIG_ATH79_MACH_WZR_450HP2 is not set
# CONFIG_ATH79_MACH_WZR_HP_AG300H is not set
# CONFIG_ATH79_MACH_WZR_HP_G300NH is not set
# CONFIG_ATH79_MACH_WZR_HP_G300NH2 is not set
# CONFIG_ATH79_MACH_WZR_HP_G450H is not set
+# CONFIG_ATH79_MACH_XD3200 is not set
+# CONFIG_ATH79_MACH_Z1 is not set
+# CONFIG_ATH79_MACH_ZBT_WE1526 is not set
# CONFIG_ATH79_MACH_ZCN_1523H is not set
# CONFIG_ATH79_NVRAM is not set
CONFIG_ATH79_ROUTERBOOT=y
-CONFIG_CMDLINE="rootfstype=yaffs noinitrd"
+CONFIG_CMDLINE="rootfstype=squashfs noinitrd"
+CONFIG_CRC16=y
+CONFIG_CRYPTO_DEFLATE=y
CONFIG_GPIO_74X164=y
CONFIG_GPIO_LATCH=y
-# CONFIG_JFFS2_FS is not set
CONFIG_LEDS_RB750=y
CONFIG_LZO_DECOMPRESS=y
-CONFIG_MDIO_BITBANG=y
-CONFIG_MDIO_GPIO=y
# CONFIG_MTD_CFI is not set
CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CYBERTAN_PARTS is not set
CONFIG_MTD_MAP_BANK_WIDTH_1=y
CONFIG_MTD_MAP_BANK_WIDTH_4=y
# CONFIG_MTD_MYLOADER_PARTS is not set
CONFIG_MTD_NAND_RB750=y
CONFIG_MTD_NAND_RB91X=y
# CONFIG_MTD_REDBOOT_PARTS is not set
-CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y
# CONFIG_MTD_TPLINK_PARTS is not set
-# CONFIG_OVERLAY_FS is not set
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_BEB_LIMIT=20
+CONFIG_MTD_UBI_BLOCK=y
+# CONFIG_MTD_UBI_FASTMAP is not set
+# CONFIG_MTD_UBI_GLUEBI is not set
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_RLE_DECOMPRESS=y
# CONFIG_SOC_AR913X is not set
# CONFIG_SOC_AR933X is not set
-# CONFIG_SOC_QCA953X is not set
+# CONFIG_SOC_QCA956X is not set
CONFIG_SPI_RB4XX=y
CONFIG_SPI_RB4XX_CPLD=y
-# CONFIG_SQUASHFS is not set
-CONFIG_YAFFS_9BYTE_TAGS=y
-CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED=y
-CONFIG_YAFFS_AUTO_YAFFS2=y
-# CONFIG_YAFFS_DISABLE_BACKGROUND is not set
-# CONFIG_YAFFS_DISABLE_BLOCK_REFRESHING is not set
-# CONFIG_YAFFS_DISABLE_TAGS_ECC is not set
-# CONFIG_YAFFS_EMPTY_LOST_AND_FOUND is not set
-CONFIG_YAFFS_FS=y
-CONFIG_YAFFS_XATTR=y
-CONFIG_YAFFS_YAFFS1=y
-CONFIG_YAFFS_YAFFS2=y
+CONFIG_UBIFS_FS=y
+CONFIG_UBIFS_FS_ADVANCED_COMPR=y
+# CONFIG_UBIFS_FS_LZO is not set
+CONFIG_UBIFS_FS_ZLIB=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_ZLIB_INFLATE=y
--- /dev/null
+#
+# Copyright (C) 2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/Default
+ NAME:=Default Profile
+ PACKAGES:= \
+ kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport nand-utils
+ PRIORITY := 1
+endef
+
+define Profile/Default/Description
+ Default package set compatible with most boards.
+endef
+$(eval $(call Profile,Default))
+++ /dev/null
-#
-# Copyright (C) 2009 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-define Profile/DefaultNoWifi
- NAME:=Default Profile (no WiFi)
- PACKAGES:=
- PRIORITY := 2
-endef
-
-define Profile/DefaultNoWifi/Description
- Default package set compatible with most boards.
-endef
-$(eval $(call Profile,DefaultNoWifi))
+++ /dev/null
-#
-# Copyright (C) 2009-2012 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-define Profile/Ath5k
- NAME:=Atheros WiFi (ath5k)
- PACKAGES:=kmod-ath5k -kmod-ath9k
- PRIORITY := 3
-endef
-
-define Profile/Ath5k/Description
- Package set compatible with hardware using Atheros WiFi cards.
-endef
-$(eval $(call Profile,Ath5k))
BOARDNAME:=Mikrotik devices with NAND/NOR flash
-FEATURES += targz ramdisk minor
+FEATURES += squashfs ramdisk minor nand
define Target/Description
Build firmware images for Atheros AR71xx/AR913x based Mikrotik boards.
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
-@@ -1117,6 +1117,9 @@ config MIPS_MSC
+@@ -1118,6 +1118,9 @@ config MIPS_MSC
config MIPS_NILE4
bool
--- a/arch/mips/ath79/prom.c
+++ b/arch/mips/ath79/prom.c
-@@ -136,6 +136,16 @@ void __init prom_init(void)
+@@ -136,6 +136,18 @@ void __init prom_init(void)
initrd_end = initrd_start + fw_getenvl("initrd_size");
}
#endif
+
+ if (strstr(arcs_cmdline, "board=750Gr3") ||
+ strstr(arcs_cmdline, "board=750i") ||
++ strstr(arcs_cmdline, "board=411") ||
++ strstr(arcs_cmdline, "board=433") ||
+ strstr(arcs_cmdline, "board=450") ||
+ strstr(arcs_cmdline, "board=493") ||
+ strstr(arcs_cmdline, "board=951G") ||
case IPV6_2292HOPOPTS:
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
-@@ -394,7 +394,7 @@ static void ip6gre_err(struct sk_buff *s
+@@ -395,7 +395,7 @@ static void ip6gre_err(struct sk_buff *s
+ return;
+ ipv6h = (const struct ipv6hdr *)skb->data;
+ greh = (const struct gre_base_hdr *)(skb->data + offset);
+- key = key_off ? *(__be32 *)(skb->data + key_off) : 0;
++ key = key_off ? net_hdr_word((__be32 *)(skb->data + key_off)) : 0;
t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr,
- flags & GRE_KEY ?
-- *(((__be32 *)p) + (grehlen / 4) - 1) : 0,
-+ net_hdr_word(((__be32 *)p) + (grehlen / 4) - 1) : 0,
- p[1]);
- if (!t)
- return;
-@@ -476,11 +476,11 @@ static int ip6gre_rcv(struct sk_buff *sk
+ key, greh->protocol);
+@@ -479,11 +479,11 @@ static int ip6gre_rcv(struct sk_buff *sk
offset += 4;
}
if (flags&GRE_KEY) {
offset += 4;
}
}
-@@ -742,7 +742,7 @@ static netdev_tx_t ip6gre_xmit2(struct s
+@@ -745,7 +745,7 @@ static netdev_tx_t ip6gre_xmit2(struct s
if (tunnel->parms.o_flags&GRE_SEQ) {
++tunnel->o_seqno;
ptr--;
}
if (tunnel->parms.o_flags&GRE_KEY) {
-@@ -838,7 +838,7 @@ static inline int ip6gre_xmit_ipv6(struc
+@@ -841,7 +841,7 @@ static inline int ip6gre_xmit_ipv6(struc
dsfield = ipv6_get_dsfield(ipv6h);
if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
-@@ -1397,7 +1397,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, str
+@@ -1407,7 +1407,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, str
dsfield = ipv6_get_dsfield(ipv6h);
if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
memcpy(p, foc->val, foc->len);
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
-@@ -500,7 +500,7 @@ static struct sk_buff *add_grec(struct s
+@@ -505,7 +505,7 @@ static struct sk_buff *add_grec(struct s
if (!skb)
return NULL;
psrc = (__be32 *)skb_put(skb, sizeof(__be32));
goto next_ht;
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
-@@ -221,7 +221,7 @@ static struct sk_buff **ipv6_gro_receive
+@@ -222,7 +222,7 @@ static struct sk_buff **ipv6_gro_receive
continue;
iph2 = (struct ipv6hdr *)(p->data + off);
--- /dev/null
+#
+# Copyright (C) 2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+ARCH:=aarch64
+BOARD:=arm64
+BOARDNAME:=ARMv8 multiplatform
+FEATURES:=fpu ramdisk
+CFLAGS:=-Os -pipe -fno-caller-saves
+MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+
+KERNEL_PATCHVER:=4.4
+
+DEVICE_TYPE:=developerboard
+
+define Target/Description
+ Build multi-platform images for the ARMv8 instruction set architecture
+endef
+
+include $(INCLUDE_DIR)/target.mk
+
+KERNELNAME:=Image dtbs
+
+$(eval $(call BuildTarget))
--- /dev/null
+This multi-platform ARMv8 target can be used either with ARM Ltd.'s Foundation_V8
+fast-model doing the following:
+
+Foundation_v8 --image bin/arm64-eglibc/openwrt-arm64-vexpress-foundation.axf
+
+or you can also use QEMU:
+
+qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic \
+ -smp 1 -m 2048 \
+ -kernel bin/arm64-eglibc/openwrt-arm64-qemu-virt-initramfs.Image \
+ --append "console=ttyAMA0"
+
+and enjoy the system booting.
--- /dev/null
+::sysinit:/etc/init.d/rcS S boot
+::shutdown:/etc/init.d/rcS K shutdown
+tts/0::askfirst:/usr/libexec/login.sh
+ttyAMA0::askfirst:/usr/libexec/login.sh
+tty1::askfirst:/usr/libexec/login.sh
--- /dev/null
+CONFIG_64BIT=y
+CONFIG_ACPI=y
+CONFIG_ACPI_CCA_REQUIRED=y
+# CONFIG_ACPI_CONTAINER is not set
+# CONFIG_ACPI_CUSTOM_DSDT is not set
+# CONFIG_ACPI_DEBUG is not set
+# CONFIG_ACPI_DEBUGGER is not set
+# CONFIG_ACPI_DOCK is not set
+# CONFIG_ACPI_EC_DEBUGFS is not set
+CONFIG_ACPI_FAN=y
+CONFIG_ACPI_GENERIC_GSI=y
+# CONFIG_ACPI_PCI_SLOT is not set
+CONFIG_ACPI_PROCESSOR=y
+CONFIG_ACPI_REDUCED_HARDWARE_ONLY=y
+CONFIG_ACPI_THERMAL=y
+# CONFIG_ARCH_BCM_IPROC is not set
+CONFIG_ARCH_DMA_ADDR_T_64BIT=y
+# CONFIG_ARCH_EXYNOS7 is not set
+CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
+CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
+CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
+CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
+CONFIG_ARCH_HAS_HOLES_MEMORYMODEL=y
+CONFIG_ARCH_HAS_SG_CHAIN=y
+CONFIG_ARCH_HAS_TICK_BROADCAST=y
+# CONFIG_ARCH_LAYERSCAPE is not set
+CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+# CONFIG_ARCH_SEATTLE is not set
+CONFIG_ARCH_SELECT_MEMORY_MODEL=y
+CONFIG_ARCH_SPARSEMEM_DEFAULT=y
+CONFIG_ARCH_SPARSEMEM_ENABLE=y
+# CONFIG_ARCH_SPRD is not set
+# CONFIG_ARCH_STRATIX10 is not set
+CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+# CONFIG_ARCH_THUNDER is not set
+CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y
+CONFIG_ARCH_VEXPRESS=y
+CONFIG_ARCH_WANT_COMPAT_IPC_PARSE_VERSION=y
+CONFIG_ARCH_WANT_FRAME_POINTERS=y
+CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
+CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
+CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
+# CONFIG_ARCH_XGENE is not set
+# CONFIG_ARCH_ZYNQMP is not set
+CONFIG_ARM64=y
+# CONFIG_ARM64_16K_PAGES is not set
+CONFIG_ARM64_4K_PAGES=y
+# CONFIG_ARM64_64K_PAGES is not set
+# CONFIG_ARM64_CRYPTO is not set
+CONFIG_ARM64_ERRATUM_819472=y
+CONFIG_ARM64_ERRATUM_824069=y
+CONFIG_ARM64_ERRATUM_826319=y
+CONFIG_ARM64_ERRATUM_827319=y
+CONFIG_ARM64_ERRATUM_832075=y
+CONFIG_ARM64_ERRATUM_843419=y
+CONFIG_ARM64_ERRATUM_845719=y
+CONFIG_ARM64_HW_AFDBM=y
+# CONFIG_ARM64_LSE_ATOMICS is not set
+CONFIG_ARM64_PAN=y
+# CONFIG_ARM64_PTDUMP is not set
+# CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET is not set
+CONFIG_ARM64_VA_BITS=39
+CONFIG_ARM64_VA_BITS_39=y
+# CONFIG_ARM64_VA_BITS_48 is not set
+# CONFIG_ARMV8_DEPRECATED is not set
+CONFIG_ARM_AMBA=y
+CONFIG_ARM_ARCH_TIMER=y
+CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y
+CONFIG_ARM_GIC=y
+CONFIG_ARM_GIC_V3=y
+CONFIG_ARM_PSCI_FW=y
+# CONFIG_ARM_SP805_WATCHDOG is not set
+CONFIG_ATOMIC64_SELFTEST=y
+CONFIG_AUDIT_ARCH_COMPAT_GENERIC=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_BLOCK_COMPAT=y
+CONFIG_BOUNCE=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_BUILD_BIN2C=y
+# CONFIG_CAVIUM_ERRATUM_22375 is not set
+# CONFIG_CAVIUM_ERRATUM_23144 is not set
+# CONFIG_CAVIUM_ERRATUM_23154 is not set
+# CONFIG_CAVIUM_ERRATUM_27456 is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_CLKDEV_LOOKUP=y
+CONFIG_CLKSRC_ACPI=y
+CONFIG_CLKSRC_MMIO=y
+CONFIG_CLKSRC_OF=y
+CONFIG_CLKSRC_PROBE=y
+CONFIG_CLK_SP810=y
+CONFIG_CLK_VEXPRESS_OSC=y
+CONFIG_CLONE_BACKWARDS=y
+CONFIG_CMDLINE="console=ttyAMA0"
+CONFIG_COMMON_CLK=y
+CONFIG_COMMON_CLK_VERSATILE=y
+CONFIG_COMMON_CLK_XGENE=y
+CONFIG_COMPAT=y
+CONFIG_COMPAT_BINFMT_ELF=y
+CONFIG_COMPAT_NETLINK_MESSAGES=y
+CONFIG_COMPAT_OLD_SIGACTION=y
+# CONFIG_CPU_BIG_ENDIAN is not set
+CONFIG_CPU_RMAP=y
+CONFIG_CRC16=y
+CONFIG_CRYPTO_CRC32C=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_WORKQUEUE=y
+CONFIG_CUSE=y
+CONFIG_DCACHE_WORD_ACCESS=y
+CONFIG_DEBUG_INFO=y
+CONFIG_DEFAULT_IOSCHED="noop"
+CONFIG_DEFAULT_NOOP=y
+CONFIG_DTC=y
+CONFIG_EDAC_SUPPORT=y
+# CONFIG_EFI is not set
+CONFIG_EXT4_FS=y
+CONFIG_FAT_FS=y
+CONFIG_FB=y
+CONFIG_FB_ARMCLCD=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+CONFIG_FB_CMDLINE=y
+CONFIG_FB_MODE_HELPERS=y
+CONFIG_FIX_EARLYCON_MEM=y
+CONFIG_FRAME_POINTER=y
+# CONFIG_FSL_MC_BUS is not set
+CONFIG_FS_MBCACHE=y
+CONFIG_FUSE_FS=y
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_GENERIC_BUG=y
+CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
+CONFIG_GENERIC_CPU_AUTOPROBE=y
+CONFIG_GENERIC_CSUM=y
+CONFIG_GENERIC_EARLY_IOREMAP=y
+CONFIG_GENERIC_IDLE_POLL_SETUP=y
+CONFIG_GENERIC_IO=y
+CONFIG_GENERIC_IRQ_SHOW=y
+CONFIG_GENERIC_IRQ_SHOW_LEVEL=y
+CONFIG_GENERIC_PCI_IOMAP=y
+CONFIG_GENERIC_SCHED_CLOCK=y
+CONFIG_GENERIC_SMP_IDLE_THREAD=y
+CONFIG_GENERIC_STRNCPY_FROM_USER=y
+CONFIG_GENERIC_STRNLEN_USER=y
+CONFIG_GENERIC_TIME_VSYSCALL=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_ACPI=y
+# CONFIG_GPIO_AMDPT is not set
+CONFIG_GPIO_DEVRES=y
+CONFIG_GPIO_GENERIC=y
+CONFIG_GPIO_GENERIC_PLATFORM=y
+# CONFIG_GPIO_XGENE is not set
+CONFIG_GRACE_PERIOD=y
+CONFIG_HANDLE_DOMAIN_IRQ=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_HAS_DMA=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT_MAP=y
+# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
+CONFIG_HAVE_ALIGNED_STRUCT_PAGE=y
+CONFIG_HAVE_ARCH_AUDITSYSCALL=y
+CONFIG_HAVE_ARCH_BITREVERSE=y
+CONFIG_HAVE_ARCH_JUMP_LABEL=y
+CONFIG_HAVE_ARCH_KASAN=y
+CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_HAVE_ARCH_PFN_VALID=y
+CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y
+# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
+CONFIG_HAVE_BPF_JIT=y
+CONFIG_HAVE_CC_STACKPROTECTOR=y
+CONFIG_HAVE_CLK=y
+CONFIG_HAVE_CLK_PREPARE=y
+CONFIG_HAVE_CMPXCHG_DOUBLE=y
+CONFIG_HAVE_CMPXCHG_LOCAL=y
+CONFIG_HAVE_CONTEXT_TRACKING=y
+CONFIG_HAVE_C_RECORDMCOUNT=y
+CONFIG_HAVE_DEBUG_BUGVERBOSE=y
+CONFIG_HAVE_DEBUG_KMEMLEAK=y
+CONFIG_HAVE_DMA_API_DEBUG=y
+CONFIG_HAVE_DMA_ATTRS=y
+CONFIG_HAVE_DMA_CONTIGUOUS=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_HAVE_GENERIC_RCU_GUP=y
+CONFIG_HAVE_MEMBLOCK=y
+CONFIG_HAVE_MEMORY_PRESENT=y
+CONFIG_HAVE_NET_DSA=y
+CONFIG_HAVE_PATA_PLATFORM=y
+CONFIG_HAVE_PERF_EVENTS=y
+CONFIG_HAVE_PERF_REGS=y
+CONFIG_HAVE_PERF_USER_STACK_DUMP=y
+CONFIG_HAVE_RCU_TABLE_FREE=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
+CONFIG_HAVE_UID16=y
+CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
+# CONFIG_HPET is not set
+# CONFIG_HUGETLBFS is not set
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_VIRTIO=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_IOMMU_HELPER=y
+# CONFIG_IOSCHED_DEADLINE is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_RARP is not set
+CONFIG_IRQCHIP=y
+CONFIG_IRQ_DOMAIN=y
+CONFIG_IRQ_DOMAIN_HIERARCHY=y
+CONFIG_IRQ_FORCED_THREADING=y
+CONFIG_IRQ_WORK=y
+CONFIG_JBD2=y
+CONFIG_LIBFDT=y
+# CONFIG_LIQUIDIO is not set
+CONFIG_LOCKD=y
+CONFIG_LOCK_SPIN_ON_OWNER=y
+CONFIG_LOGO=y
+CONFIG_LOGO_LINUX_CLUT224=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+CONFIG_LZO_COMPRESS=y
+CONFIG_LZO_DECOMPRESS=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_MFD_CORE=y
+CONFIG_MFD_SYSCON=y
+CONFIG_MFD_VEXPRESS_SYSREG=y
+# CONFIG_MISC_FILESYSTEMS is not set
+CONFIG_MMC=y
+CONFIG_MMC_ARMMMCI=y
+# CONFIG_MMC_TIFM_SD is not set
+CONFIG_MODULES_USE_ELF_RELA=y
+# CONFIG_MTD_PHYSMAP_OF is not set
+CONFIG_MUTEX_SPIN_ON_OWNER=y
+CONFIG_NEED_DMA_MAP_STATE=y
+CONFIG_NEED_SG_DMA_LENGTH=y
+CONFIG_NET_FLOW_LIMIT=y
+CONFIG_NFS_FS=y
+CONFIG_NLS=y
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NO_BOOTMEM=y
+CONFIG_NO_HZ=y
+CONFIG_NO_HZ_COMMON=y
+CONFIG_NO_HZ_IDLE=y
+CONFIG_NR_CPUS=4
+CONFIG_OF=y
+CONFIG_OF_ADDRESS=y
+CONFIG_OF_ADDRESS_PCI=y
+CONFIG_OF_EARLY_FLATTREE=y
+CONFIG_OF_FLATTREE=y
+CONFIG_OF_GPIO=y
+CONFIG_OF_IRQ=y
+CONFIG_OF_MTD=y
+CONFIG_OF_NET=y
+CONFIG_OF_PCI=y
+CONFIG_OF_PCI_IRQ=y
+CONFIG_OF_RESERVED_MEM=y
+CONFIG_OLD_SIGSUSPEND3=y
+CONFIG_PCI=y
+CONFIG_PCI_BUS_ADDR_T_64BIT=y
+CONFIG_PCI_DOMAINS=y
+CONFIG_PCI_DOMAINS_GENERIC=y
+# CONFIG_PCI_HISI is not set
+CONFIG_PCI_LABEL=y
+CONFIG_PERF_USE_VMALLOC=y
+CONFIG_PGTABLE_LEVELS=3
+CONFIG_PHYS_ADDR_T_64BIT=y
+# CONFIG_PHY_XGENE is not set
+# CONFIG_PMIC_OPREGION is not set
+CONFIG_PNP=y
+CONFIG_PNPACPI=y
+CONFIG_PNP_DEBUG_MESSAGES=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_POSIX_MQUEUE_SYSCTL=y
+CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_VEXPRESS=y
+# CONFIG_POWER_RESET_XGENE is not set
+CONFIG_POWER_SUPPLY=y
+# CONFIG_PREEMPT_NONE is not set
+CONFIG_PREEMPT_VOLUNTARY=y
+CONFIG_PROFILING=y
+CONFIG_RATIONAL=y
+CONFIG_RCU_STALL_COMMON=y
+CONFIG_REGMAP=y
+CONFIG_REGMAP_MMIO=y
+CONFIG_RFS_ACCEL=y
+CONFIG_ROOT_NFS=y
+CONFIG_RPS=y
+CONFIG_RWSEM_SPIN_ON_OWNER=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_SCHED_HRTICK=y
+# CONFIG_SCHED_INFO is not set
+CONFIG_SCSI=y
+# CONFIG_SCSI_LOWLEVEL is not set
+# CONFIG_SCSI_PROC_FS is not set
+CONFIG_SERIAL_8250_FSL=y
+CONFIG_SERIAL_8250_PNP=y
+# CONFIG_SERIAL_AMBA_PL010 is not set
+CONFIG_SERIAL_AMBA_PL011=y
+CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
+CONFIG_SMC91X=y
+CONFIG_SMP=y
+CONFIG_SPARSEMEM=y
+CONFIG_SPARSEMEM_EXTREME=y
+CONFIG_SPARSEMEM_MANUAL=y
+CONFIG_SPARSEMEM_VMEMMAP=y
+CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
+CONFIG_SPARSE_IRQ=y
+CONFIG_SRCU=y
+CONFIG_SUNRPC=y
+# CONFIG_SWAP is not set
+CONFIG_SWIOTLB=y
+CONFIG_SYSCTL_EXCEPTION_TRACE=y
+CONFIG_SYSVIPC_COMPAT=y
+CONFIG_SYS_SUPPORTS_HUGETLBFS=y
+CONFIG_THERMAL=y
+CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
+CONFIG_THERMAL_GOV_STEP_WISE=y
+CONFIG_THERMAL_OF=y
+# CONFIG_THUNDER_NIC_BGX is not set
+# CONFIG_THUNDER_NIC_PF is not set
+# CONFIG_THUNDER_NIC_VF is not set
+CONFIG_TICK_CPU_ACCOUNTING=y
+CONFIG_TREE_RCU=y
+CONFIG_VEXPRESS_CONFIG=y
+CONFIG_VEXPRESS_SYSCFG=y
+CONFIG_VFAT_FS=y
+CONFIG_VIDEOMODE_HELPERS=y
+CONFIG_VIRTIO=y
+CONFIG_VIRTIO_BLK=y
+# CONFIG_VIRTIO_CONSOLE is not set
+CONFIG_VIRTIO_MMIO=y
+# CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES is not set
+CONFIG_VIRTIO_NET=y
+CONFIG_XPS=y
--- /dev/null
+#
+# Copyright (C) 2010 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)/image.mk
+
+define Image/Prepare
+ -rm -rf $(KDIR)/linux-system.axf
+ cp $(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/Image $(KDIR)/Image
+ $(MAKE) -C boot-wrapper clean
+ $(MAKE) -C boot-wrapper compile
+endef
+
+define Build/Clean
+ $(MAKE) -C boot-wrapper clean
+endef
+
+define Image/Build/QemuVirt
+ $(CP) $(KDIR)/Image $(BIN_DIR)/$(IMG_PREFIX)-qemu-virt.Image
+ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
+ $(CP) $(KDIR)/Image-initramfs $(BIN_DIR)/$(IMG_PREFIX)-qemu-virt-initramfs.Image
+endif
+endef
+
+define Image/Build/VexpressFoundation
+ $(CP) $(KDIR)/linux-system.axf $(BIN_DIR)/$(IMG_PREFIX)-vexpress-foundation.axf
+endef
+
+define Image/BuildKernel
+ $(call Image/Build/QemuVirt)
+ $(call Image/Build/VexpressFoundation)
+endef
+
+define Image/Build/squashfs
+ $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
+endef
+
+define Image/Build
+ $(call Image/Build/$(1))
+ dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
+endef
+
+$(eval $(call BuildImage))
--- /dev/null
+#
+# Copyright (C) 2013 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:=aarch64-boot-wrapper
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://git.kernel.org/pub/scm/linux/kernel/git/mark/boot-wrapper-aarch64.git
+PKG_SOURCE_DATE:=2013-01-10
+PKG_SOURCE_VERSION:=c51dde817b5ed5b8f741b67ac51bd67bd87b4a2a
+PKG_MIRROR_HASH:=2f029a20c906af68e9fe067c1b0ed394e4c455e142454a039f41d1d82d6e17c8
+PKG_MAINTAINER:=Florian Fainelli <florian@openwrt.org>
+
+include $(INCLUDE_DIR)/kernel.mk
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/image.mk
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ KERNEL="../Image" \
+ DTC="$(LINUX_DIR)/scripts/dtc/dtc" \
+ FDT_SRC="$(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/dts/arm/foundation-v8.dts" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ BOOTARGS="console=ttyAMA0 earlyprintk"
+endef
+
+define Build/InstallDev
+ $(CP) $(PKG_BUILD_DIR)/linux-system.axf $(KDIR)/linux-system.axf
+endef
+
+$(eval $(call Build/DefaultTargets))
--- /dev/null
+#
+# Copyright (C) 2016 Yousong Zhou <yszhou4tech@gmail.com>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+ARCH:=arm
+BOARD:=armvirt
+BOARDNAME:=QEMU ARM Virtual Machine
+FEATURES:=fpu pci rtc usb
+FEATURES+=cpiogz ext4 ramdisk squashfs targz
+CPU_TYPE:=cortex-a15
+CPU_SUBTYPE:=neon-vfpv4
+MAINTAINER:=Yousong Zhou <yszhou4tech@gmail.com>
+
+KERNEL_PATCHVER:=4.4
+
+define Target/Description
+ Build images for QEMU ARM Virtual Machine
+endef
+
+include $(INCLUDE_DIR)/target.mk
+
+KERNELNAME:=zImage
+
+$(eval $(call BuildTarget))
--- /dev/null
+This is intended to be used with LEDE project to provide image for use with
+QEMU arm-softmmu virt machine.
+
+Run with qemu-system-arm
+
+ # boot with initramfs embedded in
+ qemu-system-arm -nographic -M virt -m 64 -kernel lede-armvirt-zImage-initramfs
+
+ # boot with accel=kvm
+ qemu-system-arm -nographic -M virt,accel=kvm -cpu host -m 64 -kernel lede-armvirt-zImage-initramfs
+
+ # boot with a separate rootfs
+ qemu-system-arm -nographic -M virt -m 64 -kernel lede-armvirt-zImage \
+ -drive file=lede-armvirt-root.ext4,format=raw,if=virtio -append 'root=/dev/vda rootwait'
+
+ # boot with local dir as rootfs
+ qemu-system-arm -nographic -M virt -m 64 -kernel lede-armvirt-zImage \
+ -fsdev local,id=rootdev,path=root-armvirt/,security_model=none \
+ -device virtio-9p-pci,fsdev=rootdev,mount_tag=/dev/root \
+ -append 'rootflags=trans=virtio,version=9p2000.L,cache=loose rootfstype=9p'
+
+Run with kvmtool
+
+ # start a named machine
+ lkvm run -k lede-armvirt-zImage -i lede-armvirt-rootfs.cpio --name armvirt0
+
+ # start with virtio-9p rootfs
+ lkvm run -k lede-armvirt-zImage -d root-armvirt/
+
+ # stop "armvirt0"
+ lkvm stop --name armvirt0
+
+ # stop all
+ lkvm stop --all
--- /dev/null
+#!/bin/sh
+# Copyright (C) 2015 OpenWrt.org
+# Copyright (C) 2016 Yousong Zhou <yszhou4tech@gmail.com>
+
+. /lib/functions/uci-defaults.sh
+
+board_config_update
+
+ucidef_set_board_id "armvirt"
+ucidef_set_model_name "QEMU ARM Virtual Machine"
+
+board_config_flush
+
+exit 0
--- /dev/null
+::sysinit:/etc/init.d/rcS S boot
+::shutdown:/etc/init.d/rcS K shutdown
+ttyAMA0::askfirst:/usr/libexec/login.sh
+ttyS0::askfirst:/usr/libexec/login.sh
+hvc0::askfirst:/usr/libexec/login.sh
--- /dev/null
+CONFIG_9P_FS=y
+# CONFIG_9P_FS_POSIX_ACL is not set
+# CONFIG_9P_FS_SECURITY is not set
+CONFIG_ALIGNMENT_TRAP=y
+CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
+CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
+CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
+CONFIG_ARCH_HAS_SG_CHAIN=y
+CONFIG_ARCH_HAS_TICK_BROADCAST=y
+CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
+CONFIG_ARCH_MULTIPLATFORM=y
+# CONFIG_ARCH_MULTI_CPU_AUTO is not set
+CONFIG_ARCH_MULTI_V6_V7=y
+CONFIG_ARCH_MULTI_V7=y
+CONFIG_ARCH_NR_GPIO=0
+# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
+# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
+CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
+CONFIG_ARCH_SUPPORTS_UPROBES=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_ARCH_USE_BUILTIN_BSWAP=y
+CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y
+CONFIG_ARCH_VIRT=y
+CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
+CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
+CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
+CONFIG_ARM=y
+CONFIG_ARM_AMBA=y
+CONFIG_ARM_ARCH_TIMER=y
+CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y
+# CONFIG_ARM_CPU_SUSPEND is not set
+CONFIG_ARM_GIC=y
+CONFIG_ARM_GIC_V3=y
+CONFIG_ARM_HAS_SG_CHAIN=y
+CONFIG_ARM_HEAVY_MB=y
+CONFIG_ARM_L1_CACHE_SHIFT=6
+CONFIG_ARM_L1_CACHE_SHIFT_6=y
+# CONFIG_ARM_LPAE is not set
+CONFIG_ARM_PATCH_PHYS_VIRT=y
+CONFIG_ARM_PSCI=y
+CONFIG_ARM_PSCI_FW=y
+# CONFIG_ARM_SP805_WATCHDOG is not set
+CONFIG_ARM_THUMB=y
+# CONFIG_ARM_THUMBEE is not set
+CONFIG_ARM_VIRT_EXT=y
+CONFIG_AUTO_ZRELADDR=y
+CONFIG_CACHE_L2X0=y
+CONFIG_CLKDEV_LOOKUP=y
+CONFIG_CLKSRC_OF=y
+CONFIG_CLKSRC_PROBE=y
+CONFIG_CLONE_BACKWARDS=y
+CONFIG_COMMON_CLK=y
+CONFIG_CPU_32v6K=y
+CONFIG_CPU_32v7=y
+CONFIG_CPU_ABRT_EV7=y
+# CONFIG_CPU_BPREDICT_DISABLE is not set
+CONFIG_CPU_CACHE_V7=y
+CONFIG_CPU_CACHE_VIPT=y
+CONFIG_CPU_COPY_V6=y
+CONFIG_CPU_CP15=y
+CONFIG_CPU_CP15_MMU=y
+CONFIG_CPU_HAS_ASID=y
+# CONFIG_CPU_ICACHE_DISABLE is not set
+CONFIG_CPU_PABRT_V7=y
+CONFIG_CPU_RMAP=y
+CONFIG_CPU_TLB_V7=y
+CONFIG_CPU_V7=y
+CONFIG_CRC16=y
+CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_CRC32C=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+CONFIG_CRYPTO_NULL2=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_WORKQUEUE=y
+CONFIG_DCACHE_WORD_ACCESS=y
+CONFIG_DEBUG_BUGVERBOSE=y
+CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S"
+# CONFIG_DEBUG_UART_8250 is not set
+# CONFIG_DEBUG_USER is not set
+CONFIG_DTC=y
+CONFIG_EDAC_ATOMIC_SCRUB=y
+CONFIG_EDAC_SUPPORT=y
+CONFIG_EXT4_FS=y
+CONFIG_FIX_EARLYCON_MEM=y
+CONFIG_FRAME_POINTER=y
+CONFIG_FS_MBCACHE=y
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_GENERIC_BUG=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
+CONFIG_GENERIC_IDLE_POLL_SETUP=y
+CONFIG_GENERIC_IO=y
+CONFIG_GENERIC_IRQ_SHOW=y
+CONFIG_GENERIC_IRQ_SHOW_LEVEL=y
+CONFIG_GENERIC_PCI_IOMAP=y
+CONFIG_GENERIC_SCHED_CLOCK=y
+CONFIG_GENERIC_SMP_IDLE_THREAD=y
+CONFIG_GENERIC_STRNCPY_FROM_USER=y
+CONFIG_GENERIC_STRNLEN_USER=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIOLIB_IRQCHIP=y
+CONFIG_GPIO_DEVRES=y
+CONFIG_GPIO_PL061=y
+CONFIG_HANDLE_DOMAIN_IRQ=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_HAS_DMA=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT_MAP=y
+# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
+CONFIG_HAVE_ARCH_AUDITSYSCALL=y
+CONFIG_HAVE_ARCH_BITREVERSE=y
+CONFIG_HAVE_ARCH_JUMP_LABEL=y
+CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_HAVE_ARCH_PFN_VALID=y
+CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+CONFIG_HAVE_ARM_ARCH_TIMER=y
+# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
+CONFIG_HAVE_BPF_JIT=y
+CONFIG_HAVE_CC_STACKPROTECTOR=y
+CONFIG_HAVE_CLK=y
+CONFIG_HAVE_CLK_PREPARE=y
+CONFIG_HAVE_CONTEXT_TRACKING=y
+CONFIG_HAVE_C_RECORDMCOUNT=y
+CONFIG_HAVE_DEBUG_KMEMLEAK=y
+CONFIG_HAVE_DMA_API_DEBUG=y
+CONFIG_HAVE_DMA_ATTRS=y
+CONFIG_HAVE_DMA_CONTIGUOUS=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_HAVE_IDE=y
+CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
+CONFIG_HAVE_MEMBLOCK=y
+CONFIG_HAVE_MOD_ARCH_SPECIFIC=y
+CONFIG_HAVE_NET_DSA=y
+CONFIG_HAVE_OPROFILE=y
+CONFIG_HAVE_OPTPROBES=y
+CONFIG_HAVE_PERF_EVENTS=y
+CONFIG_HAVE_PERF_REGS=y
+CONFIG_HAVE_PERF_USER_STACK_DUMP=y
+CONFIG_HAVE_PROC_CPU=y
+CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
+CONFIG_HAVE_SMP=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
+CONFIG_HAVE_UID16=y
+CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
+CONFIG_HOTPLUG_CPU=y
+CONFIG_HVC_DRIVER=y
+CONFIG_HZ_FIXED=0
+CONFIG_HZ_PERIODIC=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_IOMMU_HELPER=y
+CONFIG_IRQCHIP=y
+CONFIG_IRQ_DOMAIN=y
+CONFIG_IRQ_DOMAIN_HIERARCHY=y
+CONFIG_IRQ_FORCED_THREADING=y
+CONFIG_IRQ_WORK=y
+CONFIG_JBD2=y
+CONFIG_LIBFDT=y
+CONFIG_LOCK_SPIN_ON_OWNER=y
+CONFIG_MEMORY_BALLOON=y
+CONFIG_MIGHT_HAVE_CACHE_L2X0=y
+CONFIG_MIGHT_HAVE_PCI=y
+CONFIG_MODULES_USE_ELF_REL=y
+CONFIG_MULTI_IRQ_HANDLER=y
+CONFIG_MUTEX_SPIN_ON_OWNER=y
+CONFIG_NEED_DMA_MAP_STATE=y
+CONFIG_NEON=y
+CONFIG_NET_9P=y
+# CONFIG_NET_9P_DEBUG is not set
+CONFIG_NET_9P_VIRTIO=y
+CONFIG_NET_FLOW_LIMIT=y
+CONFIG_NO_BOOTMEM=y
+CONFIG_NR_CPUS=4
+CONFIG_OF=y
+CONFIG_OF_ADDRESS=y
+CONFIG_OF_ADDRESS_PCI=y
+CONFIG_OF_EARLY_FLATTREE=y
+CONFIG_OF_FLATTREE=y
+CONFIG_OF_GPIO=y
+CONFIG_OF_IRQ=y
+CONFIG_OF_MTD=y
+CONFIG_OF_NET=y
+CONFIG_OF_PCI=y
+CONFIG_OF_PCI_IRQ=y
+CONFIG_OF_RESERVED_MEM=y
+CONFIG_OLD_SIGACTION=y
+CONFIG_OLD_SIGSUSPEND3=y
+CONFIG_OUTER_CACHE=y
+CONFIG_OUTER_CACHE_SYNC=y
+CONFIG_PADATA=y
+CONFIG_PAGE_OFFSET=0xC0000000
+CONFIG_PCI=y
+# CONFIG_PCI_DOMAINS_GENERIC is not set
+CONFIG_PCI_HOST_GENERIC=y
+CONFIG_PERF_USE_VMALLOC=y
+CONFIG_PGTABLE_LEVELS=2
+# CONFIG_PL310_ERRATA_588369 is not set
+# CONFIG_PL310_ERRATA_727915 is not set
+# CONFIG_PL310_ERRATA_753970 is not set
+# CONFIG_PL310_ERRATA_769419 is not set
+CONFIG_RATIONAL=y
+CONFIG_RCU_STALL_COMMON=y
+CONFIG_RFS_ACCEL=y
+CONFIG_RPS=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_PL031=y
+CONFIG_RWSEM_SPIN_ON_OWNER=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_SCHED_HRTICK=y
+# CONFIG_SCHED_INFO is not set
+CONFIG_SCSI=y
+CONFIG_SCSI_VIRTIO=y
+CONFIG_SERIAL_8250_FSL=y
+# CONFIG_SERIAL_AMBA_PL010 is not set
+CONFIG_SERIAL_AMBA_PL011=y
+CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
+CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_SMP=y
+CONFIG_SMP_ON_UP=y
+CONFIG_SPARSE_IRQ=y
+CONFIG_SRCU=y
+CONFIG_SWIOTLB=y
+CONFIG_SWP_EMULATE=y
+CONFIG_SYS_SUPPORTS_APM_EMULATION=y
+# CONFIG_THUMB2_KERNEL is not set
+CONFIG_TICK_CPU_ACCOUNTING=y
+CONFIG_TREE_RCU=y
+CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h"
+CONFIG_USB_SUPPORT=y
+CONFIG_USE_OF=y
+CONFIG_VECTORS_BASE=0xffff0000
+CONFIG_VFP=y
+CONFIG_VFPv3=y
+CONFIG_VIRTIO=y
+CONFIG_VIRTIO_BALLOON=y
+CONFIG_VIRTIO_BLK=y
+CONFIG_VIRTIO_CONSOLE=y
+CONFIG_VIRTIO_MMIO=y
+# CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES is not set
+CONFIG_VIRTIO_NET=y
+CONFIG_VIRTIO_PCI=y
+CONFIG_VIRTIO_PCI_LEGACY=y
+CONFIG_XPS=y
+CONFIG_XZ_DEC_ARM=y
+CONFIG_XZ_DEC_BCJ=y
+CONFIG_ZBOOT_ROM_BSS=0
+CONFIG_ZBOOT_ROM_TEXT=0
+CONFIG_ZONE_DMA_FLAG=0
--- /dev/null
+#
+# Copyright (C) 2016 Yousong Zhou <yszhou4tech@gmail.com>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/image.mk
+
+define Image/BuildKernel
+ cp $(KDIR)/$(KERNELNAME) $(BIN_DIR)/$(IMG_PREFIX)-$(KERNELNAME)
+endef
+
+define Image/Build/Initramfs
+ cp $(KDIR)/$(KERNELNAME)-initramfs $(BIN_DIR)/$(IMG_PREFIX)-$(KERNELNAME)-initramfs
+endef
+
+define Image/Build
+ $(call Image/Build/$(1))
+ dd if=$(KDIR)/root.$(1) bs=128k conv=sync | \
+ gzip -9n >$(BIN_DIR)/$(IMG_PREFIX)-root.$(1).gz
+endef
+
+$(eval $(call BuildImage))
struct led_netdev_data {
spinlock_t lock;
- struct timer_list timer;
+ struct delayed_work work;
struct notifier_block notifier;
struct led_classdev *led_cdev;
led_set_brightness(trigger_data->led_cdev, LED_OFF);
if ((trigger_data->mode & (MODE_TX | MODE_RX)) != 0 && trigger_data->link_up)
- mod_timer(&trigger_data->timer, jiffies + trigger_data->interval);
+ schedule_delayed_work(&trigger_data->work, trigger_data->interval);
}
static ssize_t led_device_name_show(struct device *dev,
if (size < 0 || size >= IFNAMSIZ)
return -EINVAL;
+ cancel_delayed_work_sync(&trigger_data->work);
+
spin_lock_bh(&trigger_data->lock);
- del_timer_sync(&trigger_data->timer);
strcpy(trigger_data->device_name, buf);
if (size > 0 && trigger_data->device_name[size-1] == '\n')
if (new_mode == -1)
return -EINVAL;
- spin_lock_bh(&trigger_data->lock);
- del_timer_sync(&trigger_data->timer);
+ cancel_delayed_work_sync(&trigger_data->work);
+ spin_lock_bh(&trigger_data->lock);
trigger_data->mode = new_mode;
-
set_baseline_state(trigger_data);
spin_unlock_bh(&trigger_data->lock);
/* impose some basic bounds on the timer interval */
if (count == size && value >= 5 && value <= 10000) {
- spin_lock_bh(&trigger_data->lock);
- del_timer_sync(&trigger_data->timer);
+ cancel_delayed_work_sync(&trigger_data->work);
+ spin_lock_bh(&trigger_data->lock);
trigger_data->interval = msecs_to_jiffies(value);
-
set_baseline_state(trigger_data); /* resets timer */
spin_unlock_bh(&trigger_data->lock);
if (evt != NETDEV_UP && evt != NETDEV_DOWN && evt != NETDEV_CHANGE && evt != NETDEV_REGISTER && evt != NETDEV_UNREGISTER && evt != NETDEV_CHANGENAME)
return NOTIFY_DONE;
- spin_lock_bh(&trigger_data->lock);
-
if (strcmp(dev->name, trigger_data->device_name))
- goto done;
+ return NOTIFY_DONE;
- del_timer_sync(&trigger_data->timer);
+ cancel_delayed_work_sync(&trigger_data->work);
+
+ spin_lock_bh(&trigger_data->lock);
if (evt == NETDEV_REGISTER || evt == NETDEV_CHANGENAME) {
if (trigger_data->net_dev != NULL)
}
/* here's the real work! */
-static void netdev_trig_timer(unsigned long arg)
+static void netdev_trig_work(struct work_struct *work)
{
- struct led_netdev_data *trigger_data = (struct led_netdev_data *)arg;
+ struct led_netdev_data *trigger_data = container_of(work, struct led_netdev_data, work.work);
struct rtnl_link_stats64 *dev_stats;
unsigned new_activity;
struct rtnl_link_stats64 temp;
}
trigger_data->last_activity = new_activity;
- mod_timer(&trigger_data->timer, jiffies + trigger_data->interval);
+ schedule_delayed_work(&trigger_data->work, trigger_data->interval);
}
static void netdev_trig_activate(struct led_classdev *led_cdev)
trigger_data->notifier.notifier_call = netdev_trig_notify;
trigger_data->notifier.priority = 10;
- setup_timer(&trigger_data->timer, netdev_trig_timer, (unsigned long) trigger_data);
+ INIT_DELAYED_WORK(&trigger_data->work, netdev_trig_work);
trigger_data->led_cdev = led_cdev;
trigger_data->net_dev = NULL;
device_remove_file(led_cdev->dev, &dev_attr_mode);
device_remove_file(led_cdev->dev, &dev_attr_interval);
+ cancel_delayed_work_sync(&trigger_data->work);
+
spin_lock_bh(&trigger_data->lock);
- del_timer_sync(&trigger_data->timer);
if (trigger_data->net_dev) {
dev_put(trigger_data->net_dev);
priv->arl_age_time = AR8XXX_DEFAULT_ARL_AGE_TIME;
chip->init_globals(priv);
+ chip->atu_flush(priv);
mutex_unlock(&priv->reg_mutex);
case MV_IDENT_VALUE_6176:
model_str = MV_IDENT_STR_6176;
break;
+ case MV_IDENT_VALUE_6352:
+ model_str = MV_IDENT_STR_6352;
+ break;
default:
dev_err(&pdev->dev, "No compatible switch found at 0x%02x\n",
state->base_addr);
{ .compatible = "marvell,88e6171" },
{ .compatible = "marvell,88e6172" },
{ .compatible = "marvell,88e6176" },
+ { .compatible = "marvell,88e6352" },
{ }
};
MODULE_DEVICE_TABLE(of, mvsw61xx_match);
#define MV_IDENT_VALUE_6176 0x1760
#define MV_IDENT_STR_6176 "MV88E6176"
+#define MV_IDENT_VALUE_6352 0x3520
+#define MV_IDENT_STR_6352 "MV88E6352"
+
#define MV_PVID_MASK 0x0fff
#define MV_FDB_HI_MASK 0x00ff
return 0;
}
-@@ -287,9 +529,33 @@ int module_finalize(const Elf_Ehdr *hdr,
+@@ -287,9 +529,36 @@ int module_finalize(const Elf_Ehdr *hdr,
list_add(&me->arch.dbe_list, &dbe_list);
spin_unlock_irq(&dbe_lock);
}
+void module_arch_freeing_init(struct module *mod)
+{
++ if (mod->state == MODULE_STATE_LIVE)
++ return;
++
+ if (mod->arch.phys_plt_tbl) {
+ __module_free(mod->arch.phys_plt_tbl);
+ mod->arch.phys_plt_tbl = NULL;
/* Board types (on PCI usually equals to the subsystem dev id) */
/* BCM4313 */
+--- a/drivers/bcma/main.c
++++ b/drivers/bcma/main.c
+@@ -209,6 +209,8 @@ static void bcma_of_fill_device(struct p
+ core->dev.of_node = node;
+
+ core->irq = bcma_of_get_irq(parent, core, 0);
++
++ of_dma_configure(&core->dev, node);
+ }
+
+ unsigned int bcma_core_irq(struct bcma_device *core, int num)
+@@ -248,12 +250,12 @@ void bcma_prepare_core(struct bcma_bus *
+ core->irq = bus->host_pci->irq;
+ break;
+ case BCMA_HOSTTYPE_SOC:
+- core->dev.dma_mask = &core->dev.coherent_dma_mask;
+- if (bus->host_pdev) {
++ if (IS_ENABLED(CONFIG_OF) && bus->host_pdev) {
+ core->dma_dev = &bus->host_pdev->dev;
+ core->dev.parent = &bus->host_pdev->dev;
+ bcma_of_fill_device(bus->host_pdev, core);
+ } else {
++ core->dev.dma_mask = &core->dev.coherent_dma_mask;
+ core->dma_dev = &core->dev;
+ }
+ break;
--- /dev/null
+--- a/drivers/bcma/main.c
++++ b/drivers/bcma/main.c
+@@ -136,17 +136,17 @@ static bool bcma_is_core_needed_early(u1
+ return false;
+ }
+
+-static struct device_node *bcma_of_find_child_device(struct platform_device *parent,
++static struct device_node *bcma_of_find_child_device(struct device *parent,
+ struct bcma_device *core)
+ {
+ struct device_node *node;
+ u64 size;
+ const __be32 *reg;
+
+- if (!parent || !parent->dev.of_node)
++ if (!parent->of_node)
+ return NULL;
+
+- for_each_child_of_node(parent->dev.of_node, node) {
++ for_each_child_of_node(parent->of_node, node) {
+ reg = of_get_address(node, 0, &size, NULL);
+ if (!reg)
+ continue;
+@@ -156,7 +156,7 @@ static struct device_node *bcma_of_find_
+ return NULL;
+ }
+
+-static int bcma_of_irq_parse(struct platform_device *parent,
++static int bcma_of_irq_parse(struct device *parent,
+ struct bcma_device *core,
+ struct of_phandle_args *out_irq, int num)
+ {
+@@ -169,7 +169,7 @@ static int bcma_of_irq_parse(struct plat
+ return rc;
+ }
+
+- out_irq->np = parent->dev.of_node;
++ out_irq->np = parent->of_node;
+ out_irq->args_count = 1;
+ out_irq->args[0] = num;
+
+@@ -177,13 +177,13 @@ static int bcma_of_irq_parse(struct plat
+ return of_irq_parse_raw(laddr, out_irq);
+ }
+
+-static unsigned int bcma_of_get_irq(struct platform_device *parent,
++static unsigned int bcma_of_get_irq(struct device *parent,
+ struct bcma_device *core, int num)
+ {
+ struct of_phandle_args out_irq;
+ int ret;
+
+- if (!IS_ENABLED(CONFIG_OF_IRQ) || !parent || !parent->dev.of_node)
++ if (!IS_ENABLED(CONFIG_OF_IRQ) || !parent->of_node)
+ return 0;
+
+ ret = bcma_of_irq_parse(parent, core, &out_irq, num);
+@@ -196,7 +196,7 @@ static unsigned int bcma_of_get_irq(stru
+ return irq_create_of_mapping(&out_irq);
+ }
+
+-static void bcma_of_fill_device(struct platform_device *parent,
++static void bcma_of_fill_device(struct device *parent,
+ struct bcma_device *core)
+ {
+ struct device_node *node;
+@@ -227,7 +227,7 @@ unsigned int bcma_core_irq(struct bcma_d
+ return mips_irq <= 4 ? mips_irq + 2 : 0;
+ }
+ if (bus->host_pdev)
+- return bcma_of_get_irq(bus->host_pdev, core, num);
++ return bcma_of_get_irq(&bus->host_pdev->dev, core, num);
+ return 0;
+ case BCMA_HOSTTYPE_SDIO:
+ return 0;
+@@ -253,7 +253,8 @@ void bcma_prepare_core(struct bcma_bus *
+ if (IS_ENABLED(CONFIG_OF) && bus->host_pdev) {
+ core->dma_dev = &bus->host_pdev->dev;
+ core->dev.parent = &bus->host_pdev->dev;
+- bcma_of_fill_device(bus->host_pdev, core);
++ if (core->dev.parent)
++ bcma_of_fill_device(core->dev.parent, core);
+ } else {
+ core->dev.dma_mask = &core->dev.coherent_dma_mask;
+ core->dma_dev = &core->dev;
+@@ -633,8 +634,11 @@ static int bcma_device_probe(struct devi
+ drv);
+ int err = 0;
+
++ get_device(dev);
+ if (adrv->probe)
+ err = adrv->probe(core);
++ if (err)
++ put_device(dev);
+
+ return err;
+ }
+@@ -647,6 +651,7 @@ static int bcma_device_remove(struct dev
+
+ if (adrv->remove)
+ adrv->remove(core);
++ put_device(dev);
+
+ return 0;
+ }
--- /dev/null
+From be5e5099183301fb7920f8f6b66bd3ac1f820a97 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Mon, 16 Jan 2017 17:28:18 +0100
+Subject: [PATCH] mtd: bcm47xxsflash: use platform_(set|get)_drvdata
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+We have generic place & helpers for storing platform driver data so
+there is no reason for using custom priv pointer.
+
+This allows cleaning up struct bcma_sflash from unneeded fields.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Kalle Valo <kvalo@codeaurora.org>
+Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
+Signed-off-by: Brian Norris <computersforpeace@gmail.com>
+---
+ drivers/mtd/devices/bcm47xxsflash.c | 6 +++---
+ include/linux/bcma/bcma_driver_chipcommon.h | 3 ---
+ 2 files changed, 3 insertions(+), 6 deletions(-)
+
+--- a/drivers/mtd/devices/bcm47xxsflash.c
++++ b/drivers/mtd/devices/bcm47xxsflash.c
+@@ -284,7 +284,6 @@ static int bcm47xxsflash_bcma_probe(stru
+ b47s = devm_kzalloc(dev, sizeof(*b47s), GFP_KERNEL);
+ if (!b47s)
+ return -ENOMEM;
+- sflash->priv = b47s;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+@@ -334,6 +333,8 @@ static int bcm47xxsflash_bcma_probe(stru
+ b47s->size = sflash->size;
+ bcm47xxsflash_fill_mtd(b47s, &pdev->dev);
+
++ platform_set_drvdata(pdev, b47s);
++
+ err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0);
+ if (err) {
+ pr_err("Failed to register MTD device: %d\n", err);
+@@ -349,8 +350,7 @@ static int bcm47xxsflash_bcma_probe(stru
+
+ static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
+ {
+- struct bcma_sflash *sflash = dev_get_platdata(&pdev->dev);
+- struct bcm47xxsflash *b47s = sflash->priv;
++ struct bcm47xxsflash *b47s = platform_get_drvdata(pdev);
+
+ mtd_device_unregister(&b47s->mtd);
+ iounmap(b47s->window);
+--- a/include/linux/bcma/bcma_driver_chipcommon.h
++++ b/include/linux/bcma/bcma_driver_chipcommon.h
+@@ -591,9 +591,6 @@ struct bcma_sflash {
+ u32 blocksize;
+ u16 numblocks;
+ u32 size;
+-
+- struct mtd_info *mtd;
+- void *priv;
+ };
+ #endif
+
--- /dev/null
+From ccc38234fdc70120be79e7fb2df5c27ca5cd4c8a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Wed, 8 Feb 2017 23:53:44 +0100
+Subject: [PATCH] mtd: bcm47xxsflash: support reading flash out of mapping
+ window
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+For reading flash content we use MMIO but it's possible to read only
+first 16 MiB this way. It's simply an arch design/limitation.
+To support flash sizes bigger than 16 MiB implement indirect access
+using ChipCommon registers.
+This has been tested using MX25L25635F.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Marek Vasut <marek.vasut@gmail.com>
+Signed-off-by: Brian Norris <computersforpeace@gmail.com>
+---
+ drivers/mtd/devices/bcm47xxsflash.c | 24 +++++++++++++++++++++---
+ drivers/mtd/devices/bcm47xxsflash.h | 3 +++
+ 2 files changed, 24 insertions(+), 3 deletions(-)
+
+--- a/drivers/mtd/devices/bcm47xxsflash.c
++++ b/drivers/mtd/devices/bcm47xxsflash.c
+@@ -105,15 +105,33 @@ static int bcm47xxsflash_read(struct mtd
+ size_t *retlen, u_char *buf)
+ {
+ struct bcm47xxsflash *b47s = mtd->priv;
++ size_t orig_len = len;
+
+ /* Check address range */
+ if ((from + len) > mtd->size)
+ return -EINVAL;
+
+- memcpy_fromio(buf, b47s->window + from, len);
+- *retlen = len;
++ /* Read as much as possible using fast MMIO window */
++ if (from < BCM47XXSFLASH_WINDOW_SZ) {
++ size_t memcpy_len;
+
+- return len;
++ memcpy_len = min(len, (size_t)(BCM47XXSFLASH_WINDOW_SZ - from));
++ memcpy_fromio(buf, b47s->window + from, memcpy_len);
++ from += memcpy_len;
++ len -= memcpy_len;
++ buf += memcpy_len;
++ }
++
++ /* Use indirect access for content out of the window */
++ for (; len; len--) {
++ b47s->cc_write(b47s, BCMA_CC_FLASHADDR, from++);
++ bcm47xxsflash_cmd(b47s, OPCODE_ST_READ4B);
++ *buf++ = b47s->cc_read(b47s, BCMA_CC_FLASHDATA);
++ }
++
++ *retlen = orig_len;
++
++ return orig_len;
+ }
+
+ static int bcm47xxsflash_write_st(struct mtd_info *mtd, u32 offset, size_t len,
+--- a/drivers/mtd/devices/bcm47xxsflash.h
++++ b/drivers/mtd/devices/bcm47xxsflash.h
+@@ -3,6 +3,8 @@
+
+ #include <linux/mtd/mtd.h>
+
++#define BCM47XXSFLASH_WINDOW_SZ SZ_16M
++
+ /* Used for ST flashes only. */
+ #define OPCODE_ST_WREN 0x0006 /* Write Enable */
+ #define OPCODE_ST_WRDIS 0x0004 /* Write Disable */
+@@ -16,6 +18,7 @@
+ #define OPCODE_ST_RES 0x03ab /* Read Electronic Signature */
+ #define OPCODE_ST_CSA 0x1000 /* Keep chip select asserted */
+ #define OPCODE_ST_SSE 0x0220 /* Sub-sector Erase */
++#define OPCODE_ST_READ4B 0x6313 /* Read Data Bytes in 4Byte addressing mode */
+
+ /* Used for Atmel flashes only. */
+ #define OPCODE_AT_READ 0x07e8
--- /dev/null
+From b522d7b0ebe3539340c2a6d46d787ae3d33bcb92 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Tue, 10 Jan 2017 23:15:24 +0100
+Subject: [PATCH] mtd: bcm47xxpart: move TRX parsing code to separated function
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This change simplifies main parsing loop logic a bit. In future it may
+be useful for moving TRX support to separated module / parser (if we
+implement support for them at some point).
+Finally parsing TRX at the end puts us in a better position as we have
+better flash layout knowledge. It may be useful e.g. if it appears there
+is more than 1 TRX partition.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Marek Vasut <marek.vasut@gmail.com>
+Signed-off-by: Brian Norris <computersforpeace@gmail.com>
+---
+ drivers/mtd/bcm47xxpart.c | 121 ++++++++++++++++++++++++++++------------------
+ 1 file changed, 74 insertions(+), 47 deletions(-)
+
+--- a/drivers/mtd/bcm47xxpart.c
++++ b/drivers/mtd/bcm47xxpart.c
+@@ -83,6 +83,67 @@ out_default:
+ return "rootfs";
+ }
+
++static int bcm47xxpart_parse_trx(struct mtd_info *master,
++ struct mtd_partition *trx,
++ struct mtd_partition *parts,
++ size_t parts_len)
++{
++ struct trx_header header;
++ size_t bytes_read;
++ int curr_part = 0;
++ int i, err;
++
++ if (parts_len < 3) {
++ pr_warn("No enough space to add TRX partitions!\n");
++ return -ENOMEM;
++ }
++
++ err = mtd_read(master, trx->offset, sizeof(header), &bytes_read,
++ (uint8_t *)&header);
++ if (err && !mtd_is_bitflip(err)) {
++ pr_err("mtd_read error while reading TRX header: %d\n", err);
++ return err;
++ }
++
++ i = 0;
++
++ /* We have LZMA loader if offset[2] points to sth */
++ if (header.offset[2]) {
++ bcm47xxpart_add_part(&parts[curr_part++], "loader",
++ trx->offset + header.offset[i], 0);
++ i++;
++ }
++
++ if (header.offset[i]) {
++ bcm47xxpart_add_part(&parts[curr_part++], "linux",
++ trx->offset + header.offset[i], 0);
++ i++;
++ }
++
++ if (header.offset[i]) {
++ size_t offset = trx->offset + header.offset[i];
++ const char *name = bcm47xxpart_trx_data_part_name(master,
++ offset);
++
++ bcm47xxpart_add_part(&parts[curr_part++], name, offset, 0);
++ i++;
++ }
++
++ /*
++ * Assume that every partition ends at the beginning of the one it is
++ * followed by.
++ */
++ for (i = 0; i < curr_part; i++) {
++ u64 next_part_offset = (i < curr_part - 1) ?
++ parts[i + 1].offset :
++ trx->offset + trx->size;
++
++ parts[i].size = next_part_offset - parts[i].offset;
++ }
++
++ return curr_part;
++}
++
+ static int bcm47xxpart_parse(struct mtd_info *master,
+ struct mtd_partition **pparts,
+ struct mtd_part_parser_data *data)
+@@ -93,9 +154,7 @@ static int bcm47xxpart_parse(struct mtd_
+ size_t bytes_read;
+ uint32_t offset;
+ uint32_t blocksize = master->erasesize;
+- struct trx_header *trx;
+ int trx_part = -1;
+- int last_trx_part = -1;
+ int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, };
+ int err;
+
+@@ -182,54 +241,14 @@ static int bcm47xxpart_parse(struct mtd_
+
+ /* TRX */
+ if (buf[0x000 / 4] == TRX_MAGIC) {
+- if (BCM47XXPART_MAX_PARTS - curr_part < 4) {
+- pr_warn("Not enough partitions left to register trx, scanning stopped!\n");
+- break;
+- }
+-
+- trx = (struct trx_header *)buf;
++ struct trx_header *trx;
+
+ trx_part = curr_part;
+ bcm47xxpart_add_part(&parts[curr_part++], "firmware",
+ offset, 0);
+
+- i = 0;
+- /* We have LZMA loader if offset[2] points to sth */
+- if (trx->offset[2]) {
+- bcm47xxpart_add_part(&parts[curr_part++],
+- "loader",
+- offset + trx->offset[i],
+- 0);
+- i++;
+- }
+-
+- if (trx->offset[i]) {
+- bcm47xxpart_add_part(&parts[curr_part++],
+- "linux",
+- offset + trx->offset[i],
+- 0);
+- i++;
+- }
+-
+- /*
+- * Pure rootfs size is known and can be calculated as:
+- * trx->length - trx->offset[i]. We don't fill it as
+- * we want to have jffs2 (overlay) in the same mtd.
+- */
+- if (trx->offset[i]) {
+- const char *name;
+-
+- name = bcm47xxpart_trx_data_part_name(master, offset + trx->offset[i]);
+- bcm47xxpart_add_part(&parts[curr_part++],
+- name,
+- offset + trx->offset[i],
+- 0);
+- i++;
+- }
+-
+- last_trx_part = curr_part - 1;
+-
+ /* Jump to the end of TRX */
++ trx = (struct trx_header *)buf;
+ offset = roundup(offset + trx->length, blocksize);
+ /* Next loop iteration will increase the offset */
+ offset -= blocksize;
+@@ -307,9 +326,17 @@ static int bcm47xxpart_parse(struct mtd_
+ parts[i + 1].offset : master->size;
+
+ parts[i].size = next_part_offset - parts[i].offset;
+- if (i == last_trx_part && trx_part >= 0)
+- parts[trx_part].size = next_part_offset -
+- parts[trx_part].offset;
++ }
++
++ /* If there was TRX parse it now */
++ if (trx_part >= 0) {
++ int num_parts;
++
++ num_parts = bcm47xxpart_parse_trx(master, &parts[trx_part],
++ parts + curr_part,
++ BCM47XXPART_MAX_PARTS - curr_part);
++ if (num_parts > 0)
++ curr_part += num_parts;
+ }
+
+ *pparts = parts;
--- /dev/null
+From 89a0d9a9f1941a086a82bc7cd73d275cec98ba14 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Tue, 10 Jan 2017 23:15:25 +0100
+Subject: [PATCH] mtd: bcm47xxpart: support layouts with multiple TRX
+ partitions
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Some devices may have an extra TRX partition used as failsafe one. If
+we detect such partition we should set a proper name for it and don't
+parse it.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Marek Vasut <marek.vasut@gmail.com>
+Signed-off-by: Brian Norris <computersforpeace@gmail.com>
+---
+ drivers/mtd/bcm47xxpart.c | 56 ++++++++++++++++++++++++++++++++++++++---------
+ 1 file changed, 46 insertions(+), 10 deletions(-)
+
+--- a/drivers/mtd/bcm47xxpart.c
++++ b/drivers/mtd/bcm47xxpart.c
+@@ -9,6 +9,7 @@
+ *
+ */
+
++#include <linux/bcm47xx_nvram.h>
+ #include <linux/module.h>
+ #include <linux/kernel.h>
+ #include <linux/slab.h>
+@@ -144,6 +145,30 @@ static int bcm47xxpart_parse_trx(struct
+ return curr_part;
+ }
+
++/**
++ * bcm47xxpart_bootpartition - gets index of TRX partition used by bootloader
++ *
++ * Some devices may have more than one TRX partition. In such case one of them
++ * is the main one and another a failsafe one. Bootloader may fallback to the
++ * failsafe firmware if it detects corruption of the main image.
++ *
++ * This function provides info about currently used TRX partition. It's the one
++ * containing kernel started by the bootloader.
++ */
++static int bcm47xxpart_bootpartition(void)
++{
++ char buf[4];
++ int bootpartition;
++
++ /* Check CFE environment variable */
++ if (bcm47xx_nvram_getenv("bootpartition", buf, sizeof(buf)) > 0) {
++ if (!kstrtoint(buf, 0, &bootpartition))
++ return bootpartition;
++ }
++
++ return 0;
++}
++
+ static int bcm47xxpart_parse(struct mtd_info *master,
+ struct mtd_partition **pparts,
+ struct mtd_part_parser_data *data)
+@@ -154,7 +179,8 @@ static int bcm47xxpart_parse(struct mtd_
+ size_t bytes_read;
+ uint32_t offset;
+ uint32_t blocksize = master->erasesize;
+- int trx_part = -1;
++ int trx_parts[2]; /* Array with indexes of TRX partitions */
++ int trx_num = 0; /* Number of found TRX partitions */
+ int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, };
+ int err;
+
+@@ -243,7 +269,11 @@ static int bcm47xxpart_parse(struct mtd_
+ if (buf[0x000 / 4] == TRX_MAGIC) {
+ struct trx_header *trx;
+
+- trx_part = curr_part;
++ if (trx_num >= ARRAY_SIZE(trx_parts))
++ pr_warn("No enough space to store another TRX found at 0x%X\n",
++ offset);
++ else
++ trx_parts[trx_num++] = curr_part;
+ bcm47xxpart_add_part(&parts[curr_part++], "firmware",
+ offset, 0);
+
+@@ -329,14 +359,20 @@ static int bcm47xxpart_parse(struct mtd_
+ }
+
+ /* If there was TRX parse it now */
+- if (trx_part >= 0) {
+- int num_parts;
++ for (i = 0; i < trx_num; i++) {
++ struct mtd_partition *trx = &parts[trx_parts[i]];
+
+- num_parts = bcm47xxpart_parse_trx(master, &parts[trx_part],
+- parts + curr_part,
+- BCM47XXPART_MAX_PARTS - curr_part);
+- if (num_parts > 0)
+- curr_part += num_parts;
++ if (i == bcm47xxpart_bootpartition()) {
++ int num_parts;
++
++ num_parts = bcm47xxpart_parse_trx(master, trx,
++ parts + curr_part,
++ BCM47XXPART_MAX_PARTS - curr_part);
++ if (num_parts > 0)
++ curr_part += num_parts;
++ } else {
++ trx->name = "failsafe";
++ }
+ }
+
+ *pparts = parts;
--- /dev/null
+From: Matt Redfearn <matt.redfearn@imgtec.com>
+Date: Mon, 19 Dec 2016 14:20:56 +0000
+Subject: [PATCH] MIPS: Introduce irq_stack
+
+Allocate a per-cpu irq stack for use within interrupt handlers.
+
+Also add a utility function on_irq_stack to determine if a given stack
+pointer is within the irq stack for that cpu.
+
+Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
+---
+
+--- a/arch/mips/include/asm/irq.h
++++ b/arch/mips/include/asm/irq.h
+@@ -17,6 +17,18 @@
+
+ #include <irq.h>
+
++#define IRQ_STACK_SIZE THREAD_SIZE
++
++extern void *irq_stack[NR_CPUS];
++
++static inline bool on_irq_stack(int cpu, unsigned long sp)
++{
++ unsigned long low = (unsigned long)irq_stack[cpu];
++ unsigned long high = low + IRQ_STACK_SIZE;
++
++ return (low <= sp && sp <= high);
++}
++
+ #ifdef CONFIG_I8259
+ static inline int irq_canonicalize(int irq)
+ {
+--- a/arch/mips/kernel/asm-offsets.c
++++ b/arch/mips/kernel/asm-offsets.c
+@@ -101,6 +101,7 @@ void output_thread_info_defines(void)
+ OFFSET(TI_REGS, thread_info, regs);
+ DEFINE(_THREAD_SIZE, THREAD_SIZE);
+ DEFINE(_THREAD_MASK, THREAD_MASK);
++ DEFINE(_IRQ_STACK_SIZE, IRQ_STACK_SIZE);
+ BLANK();
+ }
+
+--- a/arch/mips/kernel/irq.c
++++ b/arch/mips/kernel/irq.c
+@@ -25,6 +25,8 @@
+ #include <linux/atomic.h>
+ #include <asm/uaccess.h>
+
++void *irq_stack[NR_CPUS];
++
+ /*
+ * 'what should we do if we get a hw irq event on an illegal vector'.
+ * each architecture has to answer this themselves.
+@@ -55,6 +57,15 @@ void __init init_IRQ(void)
+ irq_set_noprobe(i);
+
+ arch_init_irq();
++
++ for_each_possible_cpu(i) {
++ int irq_pages = IRQ_STACK_SIZE / PAGE_SIZE;
++ void *s = (void *)__get_free_pages(GFP_KERNEL, irq_pages);
++
++ irq_stack[i] = s;
++ pr_debug("CPU%d IRQ stack at 0x%p - 0x%p\n", i,
++ irq_stack[i], irq_stack[i] + IRQ_STACK_SIZE);
++ }
+ }
+
+ #ifdef CONFIG_DEBUG_STACKOVERFLOW
--- /dev/null
+From: Matt Redfearn <matt.redfearn@imgtec.com>
+Date: Mon, 19 Dec 2016 14:20:57 +0000
+Subject: [PATCH] MIPS: Stack unwinding while on IRQ stack
+
+Within unwind stack, check if the stack pointer being unwound is within
+the CPU's irq_stack and if so use that page rather than the task's stack
+page.
+
+Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
+---
+
+--- a/arch/mips/kernel/process.c
++++ b/arch/mips/kernel/process.c
+@@ -32,6 +32,7 @@
+ #include <asm/cpu.h>
+ #include <asm/dsp.h>
+ #include <asm/fpu.h>
++#include <asm/irq.h>
+ #include <asm/msa.h>
+ #include <asm/pgtable.h>
+ #include <asm/mipsregs.h>
+@@ -507,7 +508,19 @@ EXPORT_SYMBOL(unwind_stack_by_address);
+ unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
+ unsigned long pc, unsigned long *ra)
+ {
+- unsigned long stack_page = (unsigned long)task_stack_page(task);
++ unsigned long stack_page = 0;
++ int cpu;
++
++ for_each_possible_cpu(cpu) {
++ if (on_irq_stack(cpu, *sp)) {
++ stack_page = (unsigned long)irq_stack[cpu];
++ break;
++ }
++ }
++
++ if (!stack_page)
++ stack_page = (unsigned long)task_stack_page(task);
++
+ return unwind_stack_by_address(stack_page, sp, pc, ra);
+ }
+ #endif
--- /dev/null
+From: Matt Redfearn <matt.redfearn@imgtec.com>
+Date: Mon, 19 Dec 2016 14:20:58 +0000
+Subject: [PATCH] MIPS: Only change $28 to thread_info if coming from user
+ mode
+
+The SAVE_SOME macro is used to save the execution context on all
+exceptions.
+If an exception occurs while executing user code, the stack is switched
+to the kernel's stack for the current task, and register $28 is switched
+to point to the current_thread_info, which is at the bottom of the stack
+region.
+If the exception occurs while executing kernel code, the stack is left,
+and this change ensures that register $28 is not updated. This is the
+correct behaviour when the kernel can be executing on the separate irq
+stack, because the thread_info will not be at the base of it.
+
+With this change, register $28 is only switched to it's kernel
+conventional usage of the currrent thread info pointer at the point at
+which execution enters kernel space. Doing it on every exception was
+redundant, but OK without an IRQ stack, but will be erroneous once that
+is introduced.
+
+Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
+Reviewed-by: Maciej W. Rozycki <macro@imgtec.com>
+---
+
+--- a/arch/mips/include/asm/stackframe.h
++++ b/arch/mips/include/asm/stackframe.h
+@@ -216,12 +216,19 @@
+ LONG_S $25, PT_R25(sp)
+ LONG_S $28, PT_R28(sp)
+ LONG_S $31, PT_R31(sp)
++
++ /* Set thread_info if we're coming from user mode */
++ mfc0 k0, CP0_STATUS
++ sll k0, 3 /* extract cu0 bit */
++ bltz k0, 9f
++
+ ori $28, sp, _THREAD_MASK
+ xori $28, _THREAD_MASK
+ #ifdef CONFIG_CPU_CAVIUM_OCTEON
+ .set mips64
+ pref 0, 0($28) /* Prefetch the current pointer */
+ #endif
++9:
+ .set pop
+ .endm
+
--- /dev/null
+From: Matt Redfearn <matt.redfearn@imgtec.com>
+Date: Mon, 19 Dec 2016 14:20:59 +0000
+Subject: [PATCH] MIPS: Switch to the irq_stack in interrupts
+
+When enterring interrupt context via handle_int or except_vec_vi, switch
+to the irq_stack of the current CPU if it is not already in use.
+
+The current stack pointer is masked with the thread size and compared to
+the base or the irq stack. If it does not match then the stack pointer
+is set to the top of that stack, otherwise this is a nested irq being
+handled on the irq stack so the stack pointer should be left as it was.
+
+The in-use stack pointer is placed in the callee saved register s1. It
+will be saved to the stack when plat_irq_dispatch is invoked and can be
+restored once control returns here.
+
+Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
+---
+
+--- a/arch/mips/kernel/genex.S
++++ b/arch/mips/kernel/genex.S
+@@ -188,9 +188,44 @@ NESTED(handle_int, PT_SIZE, sp)
+
+ LONG_L s0, TI_REGS($28)
+ LONG_S sp, TI_REGS($28)
+- PTR_LA ra, ret_from_irq
+- PTR_LA v0, plat_irq_dispatch
+- jr v0
++
++ /*
++ * SAVE_ALL ensures we are using a valid kernel stack for the thread.
++ * Check if we are already using the IRQ stack.
++ */
++ move s1, sp # Preserve the sp
++
++ /* Get IRQ stack for this CPU */
++ ASM_CPUID_MFC0 k0, ASM_SMP_CPUID_REG
++#if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
++ lui k1, %hi(irq_stack)
++#else
++ lui k1, %highest(irq_stack)
++ daddiu k1, %higher(irq_stack)
++ dsll k1, 16
++ daddiu k1, %hi(irq_stack)
++ dsll k1, 16
++#endif
++ LONG_SRL k0, SMP_CPUID_PTRSHIFT
++ LONG_ADDU k1, k0
++ LONG_L t0, %lo(irq_stack)(k1)
++
++ # Check if already on IRQ stack
++ PTR_LI t1, ~(_THREAD_SIZE-1)
++ and t1, t1, sp
++ beq t0, t1, 2f
++
++ /* Switch to IRQ stack */
++ li t1, _IRQ_STACK_SIZE
++ PTR_ADD sp, t0, t1
++
++2:
++ jal plat_irq_dispatch
++
++ /* Restore sp */
++ move sp, s1
++
++ j ret_from_irq
+ #ifdef CONFIG_CPU_MICROMIPS
+ nop
+ #endif
+@@ -263,8 +298,44 @@ NESTED(except_vec_vi_handler, 0, sp)
+
+ LONG_L s0, TI_REGS($28)
+ LONG_S sp, TI_REGS($28)
+- PTR_LA ra, ret_from_irq
+- jr v0
++
++ /*
++ * SAVE_ALL ensures we are using a valid kernel stack for the thread.
++ * Check if we are already using the IRQ stack.
++ */
++ move s1, sp # Preserve the sp
++
++ /* Get IRQ stack for this CPU */
++ ASM_CPUID_MFC0 k0, ASM_SMP_CPUID_REG
++#if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
++ lui k1, %hi(irq_stack)
++#else
++ lui k1, %highest(irq_stack)
++ daddiu k1, %higher(irq_stack)
++ dsll k1, 16
++ daddiu k1, %hi(irq_stack)
++ dsll k1, 16
++#endif
++ LONG_SRL k0, SMP_CPUID_PTRSHIFT
++ LONG_ADDU k1, k0
++ LONG_L t0, %lo(irq_stack)(k1)
++
++ # Check if already on IRQ stack
++ PTR_LI t1, ~(_THREAD_SIZE-1)
++ and t1, t1, sp
++ beq t0, t1, 2f
++
++ /* Switch to IRQ stack */
++ li t1, _IRQ_STACK_SIZE
++ PTR_ADD sp, t0, t1
++
++2:
++ jal plat_irq_dispatch
++
++ /* Restore sp */
++ move sp, s1
++
++ j ret_from_irq
+ END(except_vec_vi_handler)
+
+ /*
--- /dev/null
+From: Matt Redfearn <matt.redfearn@imgtec.com>
+Date: Mon, 19 Dec 2016 14:21:00 +0000
+Subject: [PATCH] MIPS: Select HAVE_IRQ_EXIT_ON_IRQ_STACK
+
+Since do_IRQ is now invoked on a separate IRQ stack, we select
+HAVE_IRQ_EXIT_ON_IRQ_STACK so that softirq's may be invoked directly
+from irq_exit(), rather than requiring do_softirq_own_stack.
+
+Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
+---
+
+--- a/arch/mips/Kconfig
++++ b/arch/mips/Kconfig
+@@ -9,6 +9,7 @@ config MIPS
+ select HAVE_CONTEXT_TRACKING
+ select HAVE_GENERIC_DMA_COHERENT
+ select HAVE_IDE
++ select HAVE_IRQ_EXIT_ON_IRQ_STACK
+ select HAVE_OPROFILE
+ select HAVE_PERF_EVENTS
+ select PERF_USE_VMALLOC
--- /dev/null
+From de856416e7143e32afc4849625616554aa060f7a Mon Sep 17 00:00:00 2001
+From: Matt Redfearn <matt.redfearn@imgtec.com>
+Date: Wed, 25 Jan 2017 17:00:25 +0000
+Subject: [PATCH] MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch
+
+Commit dda45f701c9d ("MIPS: Switch to the irq_stack in interrupts")
+changed both the normal and vectored interrupt handlers. Unfortunately
+the vectored version, "except_vec_vi_handler", was incorrectly modified
+to unconditionally jal to plat_irq_dispatch, rather than doing a jalr to
+the vectored handler that has been set up. This is ok for many platforms
+which set the vectored handler to plat_irq_dispatch anyway, but will
+cause problems with platforms that use other handlers.
+
+Fixes: dda45f701c9d ("MIPS: Switch to the irq_stack in interrupts")
+Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
+Cc: Ralf Baechle <ralf@linux-mips.org>
+Cc: Paul Burton <paul.burton@imgtec.com>
+Cc: linux-mips@linux-mips.org
+Patchwork: https://patchwork.linux-mips.org/patch/15110/
+Signed-off-by: James Hogan <james.hogan@imgtec.com>
+---
+ arch/mips/kernel/genex.S | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/mips/kernel/genex.S
++++ b/arch/mips/kernel/genex.S
+@@ -330,7 +330,7 @@ NESTED(except_vec_vi_handler, 0, sp)
+ PTR_ADD sp, t0, t1
+
+ 2:
+- jal plat_irq_dispatch
++ jalr v0
+
+ /* Restore sp */
+ move sp, s1
+++ /dev/null
-From f1640c3ddeec12804bc9a21feee85fc15aca95f6 Mon Sep 17 00:00:00 2001
-From: wangweidong <wangweidong1@huawei.com>
-Date: Wed, 13 Jan 2016 11:06:41 +0800
-Subject: [PATCH] bgmac: fix a missing check for build_skb
-
-when build_skb failed, it may occure a NULL pointer.
-So add a 'NULL check' for it.
-
-Signed-off-by: Weidong Wang <wangweidong1@huawei.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -469,6 +469,11 @@ static int bgmac_dma_rx_read(struct bgma
- len -= ETH_FCS_LEN;
-
- skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
-+ if (unlikely(skb)) {
-+ bgmac_err(bgmac, "build_skb failed\n");
-+ put_page(virt_to_head_page(buf));
-+ break;
-+ }
- skb_put(skb, BGMAC_RX_FRAME_OFFSET +
- BGMAC_RX_BUF_OFFSET + len);
- skb_pull(skb, BGMAC_RX_FRAME_OFFSET +
+++ /dev/null
-From 750afbf8ee9c6a1c74a1fe5fc9852146b1d72687 Mon Sep 17 00:00:00 2001
-From: "David S. Miller" <davem@davemloft.net>
-Date: Fri, 15 Jan 2016 16:07:13 -0500
-Subject: [PATCH] bgmac: Fix reversed test of build_skb() return value.
-
-Fixes: f1640c3ddeec ("bgmac: fix a missing check for build_skb")
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -469,7 +469,7 @@ static int bgmac_dma_rx_read(struct bgma
- len -= ETH_FCS_LEN;
-
- skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
-- if (unlikely(skb)) {
-+ if (unlikely(!skb)) {
- bgmac_err(bgmac, "build_skb failed\n");
- put_page(virt_to_head_page(buf));
- break;
--- /dev/null
+From f1640c3ddeec12804bc9a21feee85fc15aca95f6 Mon Sep 17 00:00:00 2001
+From: wangweidong <wangweidong1@huawei.com>
+Date: Wed, 13 Jan 2016 11:06:41 +0800
+Subject: [PATCH] bgmac: fix a missing check for build_skb
+
+when build_skb failed, it may occure a NULL pointer.
+So add a 'NULL check' for it.
+
+Signed-off-by: Weidong Wang <wangweidong1@huawei.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -469,6 +469,11 @@ static int bgmac_dma_rx_read(struct bgma
+ len -= ETH_FCS_LEN;
+
+ skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
++ if (unlikely(skb)) {
++ bgmac_err(bgmac, "build_skb failed\n");
++ put_page(virt_to_head_page(buf));
++ break;
++ }
+ skb_put(skb, BGMAC_RX_FRAME_OFFSET +
+ BGMAC_RX_BUF_OFFSET + len);
+ skb_pull(skb, BGMAC_RX_FRAME_OFFSET +
--- /dev/null
+From 750afbf8ee9c6a1c74a1fe5fc9852146b1d72687 Mon Sep 17 00:00:00 2001
+From: "David S. Miller" <davem@davemloft.net>
+Date: Fri, 15 Jan 2016 16:07:13 -0500
+Subject: [PATCH] bgmac: Fix reversed test of build_skb() return value.
+
+Fixes: f1640c3ddeec ("bgmac: fix a missing check for build_skb")
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -469,7 +469,7 @@ static int bgmac_dma_rx_read(struct bgma
+ len -= ETH_FCS_LEN;
+
+ skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
+- if (unlikely(skb)) {
++ if (unlikely(!skb)) {
+ bgmac_err(bgmac, "build_skb failed\n");
+ put_page(virt_to_head_page(buf));
+ break;
--- /dev/null
+From 1f820f538f7396db7fd40684b9c3620816acc5a3 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Fri, 29 Jan 2016 12:39:12 +0100
+Subject: [PATCH] net: bgmac: clarify CONFIG_BCMA dependency
+
+The bgmac driver depends on BCMA_HOST_SOC, which is only used
+when CONFIG_BCMA is enabled. However, it is a bool option and can
+be set when CONFIG_BCMA=m, and then bgmac can be built-in, leading
+to an obvious link error:
+
+drivers/built-in.o: In function `bgmac_init':
+:(.init.text+0x7f2c): undefined reference to `__bcma_driver_register'
+drivers/built-in.o: In function `bgmac_exit':
+:(.exit.text+0x110a): undefined reference to `bcma_driver_unregister'
+
+To avoid this case, we need to depend on both BCMA and BCMA_SOC,
+as this patch does. I'm also trying to make the dependency more
+readable by splitting it into three lines, and adding a COMPILE_TEST
+alternative so we can test-build it in all configurations that
+support BCMA.
+
+The added dependency on FIXED_PHY addresses a related issue where
+we cannot call fixed_phy_register() when CONFIG_FIXED_PHY=m and
+CONFIG_BGMAC=y.
+
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/Kconfig | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/ethernet/broadcom/Kconfig
++++ b/drivers/net/ethernet/broadcom/Kconfig
+@@ -151,8 +151,11 @@ config BNX2X_VXLAN
+
+ config BGMAC
+ tristate "BCMA bus GBit core support"
+- depends on BCMA_HOST_SOC && HAS_DMA && (BCM47XX || ARCH_BCM_5301X)
++ depends on BCMA && BCMA_HOST_SOC
++ depends on HAS_DMA
++ depends on BCM47XX || ARCH_BCM_5301X || COMPILE_TEST
+ select PHYLIB
++ select FIXED_PHY
+ ---help---
+ This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus.
+ They can be found on BCM47xx SoCs and provide gigabit ethernet.
--- /dev/null
+From 387b75f8b31437792e8334390fdf5cf060d1e3da Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
+Date: Tue, 2 Feb 2016 07:47:14 +0100
+Subject: [PATCH] bgmac: add helper checking for BCM4707 / BCM53018 chip id
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Chipsets with BCM4707 / BCM53018 ID require special handling at a few
+places in the code. It's likely there will be more IDs to check in the
+future. To simplify it add this trivial helper.
+
+Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 30 ++++++++++++++++--------------
+ 1 file changed, 16 insertions(+), 14 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -26,6 +26,17 @@ static const struct bcma_device_id bgmac
+ };
+ MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl);
+
++static inline bool bgmac_is_bcm4707_family(struct bgmac *bgmac)
++{
++ switch (bgmac->core->bus->chipinfo.id) {
++ case BCMA_CHIP_ID_BCM4707:
++ case BCMA_CHIP_ID_BCM53018:
++ return true;
++ default:
++ return false;
++ }
++}
++
+ static bool bgmac_wait_value(struct bcma_device *core, u16 reg, u32 mask,
+ u32 value, int timeout)
+ {
+@@ -990,11 +1001,9 @@ static void bgmac_mac_speed(struct bgmac
+ static void bgmac_miiconfig(struct bgmac *bgmac)
+ {
+ struct bcma_device *core = bgmac->core;
+- struct bcma_chipinfo *ci = &core->bus->chipinfo;
+ u8 imode;
+
+- if (ci->id == BCMA_CHIP_ID_BCM4707 ||
+- ci->id == BCMA_CHIP_ID_BCM53018) {
++ if (bgmac_is_bcm4707_family(bgmac)) {
+ bcma_awrite32(core, BCMA_IOCTL,
+ bcma_aread32(core, BCMA_IOCTL) | 0x40 |
+ BGMAC_BCMA_IOCTL_SW_CLKEN);
+@@ -1058,9 +1067,7 @@ static void bgmac_chip_reset(struct bgma
+ }
+
+ /* Request Misc PLL for corerev > 2 */
+- if (core->id.rev > 2 &&
+- ci->id != BCMA_CHIP_ID_BCM4707 &&
+- ci->id != BCMA_CHIP_ID_BCM53018) {
++ if (core->id.rev > 2 && !bgmac_is_bcm4707_family(bgmac)) {
+ bgmac_set(bgmac, BCMA_CLKCTLST,
+ BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ);
+ bgmac_wait_value(bgmac->core, BCMA_CLKCTLST,
+@@ -1196,8 +1203,7 @@ static void bgmac_enable(struct bgmac *b
+ break;
+ }
+
+- if (ci->id != BCMA_CHIP_ID_BCM4707 &&
+- ci->id != BCMA_CHIP_ID_BCM53018) {
++ if (!bgmac_is_bcm4707_family(bgmac)) {
+ rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
+ rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
+ bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) /
+@@ -1475,14 +1481,12 @@ static int bgmac_fixed_phy_register(stru
+
+ static int bgmac_mii_register(struct bgmac *bgmac)
+ {
+- struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo;
+ struct mii_bus *mii_bus;
+ struct phy_device *phy_dev;
+ char bus_id[MII_BUS_ID_SIZE + 3];
+ int i, err = 0;
+
+- if (ci->id == BCMA_CHIP_ID_BCM4707 ||
+- ci->id == BCMA_CHIP_ID_BCM53018)
++ if (bgmac_is_bcm4707_family(bgmac))
+ return bgmac_fixed_phy_register(bgmac);
+
+ mii_bus = mdiobus_alloc();
+@@ -1553,7 +1557,6 @@ static void bgmac_mii_unregister(struct
+ /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
+ static int bgmac_probe(struct bcma_device *core)
+ {
+- struct bcma_chipinfo *ci = &core->bus->chipinfo;
+ struct net_device *net_dev;
+ struct bgmac *bgmac;
+ struct ssb_sprom *sprom = &core->bus->sprom;
+@@ -1634,8 +1637,7 @@ static int bgmac_probe(struct bcma_devic
+ bgmac_chip_reset(bgmac);
+
+ /* For Northstar, we have to take all GMAC core out of reset */
+- if (ci->id == BCMA_CHIP_ID_BCM4707 ||
+- ci->id == BCMA_CHIP_ID_BCM53018) {
++ if (bgmac_is_bcm4707_family(bgmac)) {
+ struct bcma_device *ns_core;
+ int ns_gmac;
+
--- /dev/null
+From 9e4e6206c67ae11d68fc96882256f37c237087d4 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
+Date: Mon, 22 Feb 2016 22:51:13 +0100
+Subject: [PATCH] bgmac: support Ethernet device on BCM47094 SoC
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+It needs very similar workarounds to the one on BCM4707. It was tested
+on D-Link DIR-885L home router.
+
+Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -30,6 +30,7 @@ static inline bool bgmac_is_bcm4707_fami
+ {
+ switch (bgmac->core->bus->chipinfo.id) {
+ case BCMA_CHIP_ID_BCM4707:
++ case BCMA_CHIP_ID_BCM47094:
+ case BCMA_CHIP_ID_BCM53018:
+ return true;
+ default:
+@@ -1055,8 +1056,9 @@ static void bgmac_chip_reset(struct bgma
+ (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == BCMA_PKG_ID_BCM47188))
+ iost &= ~BGMAC_BCMA_IOST_ATTACHED;
+
+- /* 3GMAC: for BCM4707, only do core reset at bgmac_probe() */
+- if (ci->id != BCMA_CHIP_ID_BCM4707) {
++ /* 3GMAC: for BCM4707 & BCM47094, only do core reset at bgmac_probe() */
++ if (ci->id != BCMA_CHIP_ID_BCM4707 &&
++ ci->id != BCMA_CHIP_ID_BCM47094) {
+ flags = 0;
+ if (iost & BGMAC_BCMA_IOST_ATTACHED) {
+ flags = BGMAC_BCMA_IOCTL_SW_CLKEN;
--- /dev/null
+From b4dfd8e92956b396d3438212bc9a0be6267b8b34 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
+Date: Tue, 12 Apr 2016 13:30:45 +0200
+Subject: [PATCH] bgmac: reset & enable Ethernet core before using it
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This fixes Ethernet on D-Link DIR-885L with BCM47094 SoC. Felix reported
+similar fix was needed for his BCM4709 device (Buffalo WXR-1900DHP?).
+I tested this for regressions on BCM4706, BCM4708A0 and BCM47081A0.
+
+Cc: Felix Fietkau <nbd@nbd.name>
+Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -1586,6 +1586,11 @@ static int bgmac_probe(struct bcma_devic
+ dev_warn(&core->dev, "Using random MAC: %pM\n", mac);
+ }
+
++ /* This (reset &) enable is not preset in specs or reference driver but
++ * Broadcom does it in arch PCI code when enabling fake PCI device.
++ */
++ bcma_core_enable(core, 0);
++
+ /* Allocation and references */
+ net_dev = alloc_etherdev(sizeof(*bgmac));
+ if (!net_dev)
--- /dev/null
+From c02bc350f9dbce7d637c394a6e1c4d29dc5b28b2 Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <nbd@nbd.name>
+Date: Tue, 12 Apr 2016 18:27:29 +0200
+Subject: [PATCH] bgmac: fix MAC soft-reset bit for corerev > 4
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Only core revisions older than 4 use BGMAC_CMDCFG_SR_REV0. This mainly
+fixes support for BCM4708A0KF SoCs with Ethernet core rev 5 (it means
+only some devices as most of BCM4708A0KF-s got core rev 4).
+This was tested for regressions on BCM47094 which doesn't seem to care
+which bit gets used.
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -199,9 +199,9 @@
+ #define BGMAC_CMDCFG_TAI 0x00000200
+ #define BGMAC_CMDCFG_HD 0x00000400 /* Set if in half duplex mode */
+ #define BGMAC_CMDCFG_HD_SHIFT 10
+-#define BGMAC_CMDCFG_SR_REV0 0x00000800 /* Set to reset mode, for other revs */
+-#define BGMAC_CMDCFG_SR_REV4 0x00002000 /* Set to reset mode, only for core rev 4 */
+-#define BGMAC_CMDCFG_SR(rev) ((rev == 4) ? BGMAC_CMDCFG_SR_REV4 : BGMAC_CMDCFG_SR_REV0)
++#define BGMAC_CMDCFG_SR_REV0 0x00000800 /* Set to reset mode, for core rev 0-3 */
++#define BGMAC_CMDCFG_SR_REV4 0x00002000 /* Set to reset mode, for core rev >= 4 */
++#define BGMAC_CMDCFG_SR(rev) ((rev >= 4) ? BGMAC_CMDCFG_SR_REV4 : BGMAC_CMDCFG_SR_REV0)
+ #define BGMAC_CMDCFG_ML 0x00008000 /* Set to activate mac loopback mode */
+ #define BGMAC_CMDCFG_AE 0x00400000
+ #define BGMAC_CMDCFG_CFE 0x00800000
--- /dev/null
+From 2022e9d50798aa592887ccb5a7d045e537f3855f Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Tue, 7 Jun 2016 15:06:13 -0700
+Subject: [PATCH 1/3] bgmac: Bind net_device with backing device structure
+
+In preparation for allowing different helpers to be utilized against
+network devices created by the bgmac driver, make sure that we bind the
+net_device with core->dev.
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -1602,6 +1602,7 @@ static int bgmac_probe(struct bcma_devic
+ bgmac->net_dev = net_dev;
+ bgmac->core = core;
+ bcma_set_drvdata(core, bgmac);
++ SET_NETDEV_DEV(net_dev, &core->dev);
+
+ /* Defaults */
+ memcpy(bgmac->net_dev->dev_addr, mac, ETH_ALEN);
--- /dev/null
+From f6613d4fa937fa8388f2c1cb4e69ccc25e9e2336 Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Tue, 7 Jun 2016 15:06:14 -0700
+Subject: [PATCH 2/3] bgmac: Add support for ethtool statistics
+
+Read the statistics from the BGMAC's builtin MAC and return them to
+user-space using the standard ethtool helpers.
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 124 ++++++++++++++++++++++++++++++++++
+ drivers/net/ethernet/broadcom/bgmac.h | 4 +-
+ 2 files changed, 126 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -1385,6 +1385,127 @@ static const struct net_device_ops bgmac
+ * ethtool_ops
+ **************************************************/
+
++struct bgmac_stat {
++ u8 size;
++ u32 offset;
++ const char *name;
++};
++
++static struct bgmac_stat bgmac_get_strings_stats[] = {
++ { 8, BGMAC_TX_GOOD_OCTETS, "tx_good_octets" },
++ { 4, BGMAC_TX_GOOD_PKTS, "tx_good" },
++ { 8, BGMAC_TX_OCTETS, "tx_octets" },
++ { 4, BGMAC_TX_PKTS, "tx_pkts" },
++ { 4, BGMAC_TX_BROADCAST_PKTS, "tx_broadcast" },
++ { 4, BGMAC_TX_MULTICAST_PKTS, "tx_multicast" },
++ { 4, BGMAC_TX_LEN_64, "tx_64" },
++ { 4, BGMAC_TX_LEN_65_TO_127, "tx_65_127" },
++ { 4, BGMAC_TX_LEN_128_TO_255, "tx_128_255" },
++ { 4, BGMAC_TX_LEN_256_TO_511, "tx_256_511" },
++ { 4, BGMAC_TX_LEN_512_TO_1023, "tx_512_1023" },
++ { 4, BGMAC_TX_LEN_1024_TO_1522, "tx_1024_1522" },
++ { 4, BGMAC_TX_LEN_1523_TO_2047, "tx_1523_2047" },
++ { 4, BGMAC_TX_LEN_2048_TO_4095, "tx_2048_4095" },
++ { 4, BGMAC_TX_LEN_4096_TO_8191, "tx_4096_8191" },
++ { 4, BGMAC_TX_LEN_8192_TO_MAX, "tx_8192_max" },
++ { 4, BGMAC_TX_JABBER_PKTS, "tx_jabber" },
++ { 4, BGMAC_TX_OVERSIZE_PKTS, "tx_oversize" },
++ { 4, BGMAC_TX_FRAGMENT_PKTS, "tx_fragment" },
++ { 4, BGMAC_TX_UNDERRUNS, "tx_underruns" },
++ { 4, BGMAC_TX_TOTAL_COLS, "tx_total_cols" },
++ { 4, BGMAC_TX_SINGLE_COLS, "tx_single_cols" },
++ { 4, BGMAC_TX_MULTIPLE_COLS, "tx_multiple_cols" },
++ { 4, BGMAC_TX_EXCESSIVE_COLS, "tx_excessive_cols" },
++ { 4, BGMAC_TX_LATE_COLS, "tx_late_cols" },
++ { 4, BGMAC_TX_DEFERED, "tx_defered" },
++ { 4, BGMAC_TX_CARRIER_LOST, "tx_carrier_lost" },
++ { 4, BGMAC_TX_PAUSE_PKTS, "tx_pause" },
++ { 4, BGMAC_TX_UNI_PKTS, "tx_unicast" },
++ { 4, BGMAC_TX_Q0_PKTS, "tx_q0" },
++ { 8, BGMAC_TX_Q0_OCTETS, "tx_q0_octets" },
++ { 4, BGMAC_TX_Q1_PKTS, "tx_q1" },
++ { 8, BGMAC_TX_Q1_OCTETS, "tx_q1_octets" },
++ { 4, BGMAC_TX_Q2_PKTS, "tx_q2" },
++ { 8, BGMAC_TX_Q2_OCTETS, "tx_q2_octets" },
++ { 4, BGMAC_TX_Q3_PKTS, "tx_q3" },
++ { 8, BGMAC_TX_Q3_OCTETS, "tx_q3_octets" },
++ { 8, BGMAC_RX_GOOD_OCTETS, "rx_good_octets" },
++ { 4, BGMAC_RX_GOOD_PKTS, "rx_good" },
++ { 8, BGMAC_RX_OCTETS, "rx_octets" },
++ { 4, BGMAC_RX_PKTS, "rx_pkts" },
++ { 4, BGMAC_RX_BROADCAST_PKTS, "rx_broadcast" },
++ { 4, BGMAC_RX_MULTICAST_PKTS, "rx_multicast" },
++ { 4, BGMAC_RX_LEN_64, "rx_64" },
++ { 4, BGMAC_RX_LEN_65_TO_127, "rx_65_127" },
++ { 4, BGMAC_RX_LEN_128_TO_255, "rx_128_255" },
++ { 4, BGMAC_RX_LEN_256_TO_511, "rx_256_511" },
++ { 4, BGMAC_RX_LEN_512_TO_1023, "rx_512_1023" },
++ { 4, BGMAC_RX_LEN_1024_TO_1522, "rx_1024_1522" },
++ { 4, BGMAC_RX_LEN_1523_TO_2047, "rx_1523_2047" },
++ { 4, BGMAC_RX_LEN_2048_TO_4095, "rx_2048_4095" },
++ { 4, BGMAC_RX_LEN_4096_TO_8191, "rx_4096_8191" },
++ { 4, BGMAC_RX_LEN_8192_TO_MAX, "rx_8192_max" },
++ { 4, BGMAC_RX_JABBER_PKTS, "rx_jabber" },
++ { 4, BGMAC_RX_OVERSIZE_PKTS, "rx_oversize" },
++ { 4, BGMAC_RX_FRAGMENT_PKTS, "rx_fragment" },
++ { 4, BGMAC_RX_MISSED_PKTS, "rx_missed" },
++ { 4, BGMAC_RX_CRC_ALIGN_ERRS, "rx_crc_align" },
++ { 4, BGMAC_RX_UNDERSIZE, "rx_undersize" },
++ { 4, BGMAC_RX_CRC_ERRS, "rx_crc" },
++ { 4, BGMAC_RX_ALIGN_ERRS, "rx_align" },
++ { 4, BGMAC_RX_SYMBOL_ERRS, "rx_symbol" },
++ { 4, BGMAC_RX_PAUSE_PKTS, "rx_pause" },
++ { 4, BGMAC_RX_NONPAUSE_PKTS, "rx_nonpause" },
++ { 4, BGMAC_RX_SACHANGES, "rx_sa_changes" },
++ { 4, BGMAC_RX_UNI_PKTS, "rx_unicast" },
++};
++
++#define BGMAC_STATS_LEN ARRAY_SIZE(bgmac_get_strings_stats)
++
++static int bgmac_get_sset_count(struct net_device *dev, int string_set)
++{
++ switch (string_set) {
++ case ETH_SS_STATS:
++ return BGMAC_STATS_LEN;
++ }
++
++ return -EOPNOTSUPP;
++}
++
++static void bgmac_get_strings(struct net_device *dev, u32 stringset,
++ u8 *data)
++{
++ int i;
++
++ if (stringset != ETH_SS_STATS)
++ return;
++
++ for (i = 0; i < BGMAC_STATS_LEN; i++)
++ strlcpy(data + i * ETH_GSTRING_LEN,
++ bgmac_get_strings_stats[i].name, ETH_GSTRING_LEN);
++}
++
++static void bgmac_get_ethtool_stats(struct net_device *dev,
++ struct ethtool_stats *ss, uint64_t *data)
++{
++ struct bgmac *bgmac = netdev_priv(dev);
++ const struct bgmac_stat *s;
++ unsigned int i;
++ u64 val;
++
++ if (!netif_running(dev))
++ return;
++
++ for (i = 0; i < BGMAC_STATS_LEN; i++) {
++ s = &bgmac_get_strings_stats[i];
++ val = 0;
++ if (s->size == 8)
++ val = (u64)bgmac_read(bgmac, s->offset + 4) << 32;
++ val |= bgmac_read(bgmac, s->offset);
++ data[i] = val;
++ }
++}
++
+ static int bgmac_get_settings(struct net_device *net_dev,
+ struct ethtool_cmd *cmd)
+ {
+@@ -1409,6 +1530,9 @@ static void bgmac_get_drvinfo(struct net
+ }
+
+ static const struct ethtool_ops bgmac_ethtool_ops = {
++ .get_strings = bgmac_get_strings,
++ .get_sset_count = bgmac_get_sset_count,
++ .get_ethtool_stats = bgmac_get_ethtool_stats,
+ .get_settings = bgmac_get_settings,
+ .set_settings = bgmac_set_settings,
+ .get_drvinfo = bgmac_get_drvinfo,
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -123,7 +123,7 @@
+ #define BGMAC_TX_LEN_1024_TO_1522 0x334
+ #define BGMAC_TX_LEN_1523_TO_2047 0x338
+ #define BGMAC_TX_LEN_2048_TO_4095 0x33c
+-#define BGMAC_TX_LEN_4095_TO_8191 0x340
++#define BGMAC_TX_LEN_4096_TO_8191 0x340
+ #define BGMAC_TX_LEN_8192_TO_MAX 0x344
+ #define BGMAC_TX_JABBER_PKTS 0x348 /* Error */
+ #define BGMAC_TX_OVERSIZE_PKTS 0x34c /* Error */
+@@ -166,7 +166,7 @@
+ #define BGMAC_RX_LEN_1024_TO_1522 0x3e4
+ #define BGMAC_RX_LEN_1523_TO_2047 0x3e8
+ #define BGMAC_RX_LEN_2048_TO_4095 0x3ec
+-#define BGMAC_RX_LEN_4095_TO_8191 0x3f0
++#define BGMAC_RX_LEN_4096_TO_8191 0x3f0
+ #define BGMAC_RX_LEN_8192_TO_MAX 0x3f4
+ #define BGMAC_RX_JABBER_PKTS 0x3f8 /* Error */
+ #define BGMAC_RX_OVERSIZE_PKTS 0x3fc /* Error */
--- /dev/null
+From 6d490f62a4c7f11c552591bdd08eda3636aa0db9 Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Tue, 7 Jun 2016 15:06:15 -0700
+Subject: [PATCH 3/3] bgmac: Maintain some netdev statistics
+
+Add a few netdev statistics to report transmitted and received bytes and
+packets and a few obvious errors.
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -246,6 +246,8 @@ err_dma_head:
+
+ err_drop:
+ dev_kfree_skb(skb);
++ net_dev->stats.tx_dropped++;
++ net_dev->stats.tx_errors++;
+ return NETDEV_TX_OK;
+ }
+
+@@ -284,6 +286,8 @@ static void bgmac_dma_tx_free(struct bgm
+ DMA_TO_DEVICE);
+
+ if (slot->skb) {
++ bgmac->net_dev->stats.tx_bytes += slot->skb->len;
++ bgmac->net_dev->stats.tx_packets++;
+ bytes_compl += slot->skb->len;
+ pkts_compl++;
+
+@@ -467,6 +471,7 @@ static int bgmac_dma_rx_read(struct bgma
+ bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n",
+ ring->start);
+ put_page(virt_to_head_page(buf));
++ bgmac->net_dev->stats.rx_errors++;
+ break;
+ }
+
+@@ -474,6 +479,8 @@ static int bgmac_dma_rx_read(struct bgma
+ bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n",
+ ring->start);
+ put_page(virt_to_head_page(buf));
++ bgmac->net_dev->stats.rx_length_errors++;
++ bgmac->net_dev->stats.rx_errors++;
+ break;
+ }
+
+@@ -484,6 +491,7 @@ static int bgmac_dma_rx_read(struct bgma
+ if (unlikely(!skb)) {
+ bgmac_err(bgmac, "build_skb failed\n");
+ put_page(virt_to_head_page(buf));
++ bgmac->net_dev->stats.rx_errors++;
+ break;
+ }
+ skb_put(skb, BGMAC_RX_FRAME_OFFSET +
+@@ -493,6 +501,8 @@ static int bgmac_dma_rx_read(struct bgma
+
+ skb_checksum_none_assert(skb);
+ skb->protocol = eth_type_trans(skb, bgmac->net_dev);
++ bgmac->net_dev->stats.rx_bytes += len;
++ bgmac->net_dev->stats.rx_packets++;
+ napi_gro_receive(&bgmac->napi, skb);
+ handled++;
+ } while (0);
--- /dev/null
+From b21fcb259313bcf7d4f73ecd5e44948995c8957c Mon Sep 17 00:00:00 2001
+From: Philippe Reynes <tremyfr@gmail.com>
+Date: Sun, 19 Jun 2016 22:37:05 +0200
+Subject: [PATCH 1/2] net: ethernet: bgmac: use phydev from struct net_device
+
+The private structure contain a pointer to phydev, but the structure
+net_device already contain such pointer. So we can remove the pointer
+phydev in the private structure, and update the driver to use the
+one contained in struct net_device.
+
+Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 17 ++++++-----------
+ drivers/net/ethernet/broadcom/bgmac.h | 1 -
+ 2 files changed, 6 insertions(+), 12 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -1323,7 +1323,7 @@ static int bgmac_open(struct net_device
+ }
+ napi_enable(&bgmac->napi);
+
+- phy_start(bgmac->phy_dev);
++ phy_start(net_dev->phydev);
+
+ netif_carrier_on(net_dev);
+ return 0;
+@@ -1335,7 +1335,7 @@ static int bgmac_stop(struct net_device
+
+ netif_carrier_off(net_dev);
+
+- phy_stop(bgmac->phy_dev);
++ phy_stop(net_dev->phydev);
+
+ napi_disable(&bgmac->napi);
+ bgmac_chip_intrs_off(bgmac);
+@@ -1373,12 +1373,10 @@ static int bgmac_set_mac_address(struct
+
+ static int bgmac_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
+ {
+- struct bgmac *bgmac = netdev_priv(net_dev);
+-
+ if (!netif_running(net_dev))
+ return -EINVAL;
+
+- return phy_mii_ioctl(bgmac->phy_dev, ifr, cmd);
++ return phy_mii_ioctl(net_dev->phydev, ifr, cmd);
+ }
+
+ static const struct net_device_ops bgmac_netdev_ops = {
+@@ -1521,7 +1519,7 @@ static int bgmac_get_settings(struct net
+ {
+ struct bgmac *bgmac = netdev_priv(net_dev);
+
+- return phy_ethtool_gset(bgmac->phy_dev, cmd);
++ return phy_ethtool_gset(net_dev->phydev, cmd);
+ }
+
+ static int bgmac_set_settings(struct net_device *net_dev,
+@@ -1529,7 +1527,7 @@ static int bgmac_set_settings(struct net
+ {
+ struct bgmac *bgmac = netdev_priv(net_dev);
+
+- return phy_ethtool_sset(bgmac->phy_dev, cmd);
++ return phy_ethtool_sset(net_dev->phydev, cmd);
+ }
+
+ static void bgmac_get_drvinfo(struct net_device *net_dev,
+@@ -1566,7 +1564,7 @@ static int bgmac_mii_write(struct mii_bu
+ static void bgmac_adjust_link(struct net_device *net_dev)
+ {
+ struct bgmac *bgmac = netdev_priv(net_dev);
+- struct phy_device *phy_dev = bgmac->phy_dev;
++ struct phy_device *phy_dev = net_dev->phydev;
+ bool update = false;
+
+ if (phy_dev->link) {
+@@ -1610,8 +1608,6 @@ static int bgmac_fixed_phy_register(stru
+ return err;
+ }
+
+- bgmac->phy_dev = phy_dev;
+-
+ return err;
+ }
+
+@@ -1664,7 +1660,6 @@ static int bgmac_mii_register(struct bgm
+ err = PTR_ERR(phy_dev);
+ goto err_unregister_bus;
+ }
+- bgmac->phy_dev = phy_dev;
+
+ return err;
+
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -441,7 +441,6 @@ struct bgmac {
+ struct net_device *net_dev;
+ struct napi_struct napi;
+ struct mii_bus *mii_bus;
+- struct phy_device *phy_dev;
+
+ /* DMA */
+ struct bgmac_dma_ring tx_ring[BGMAC_MAX_TX_RINGS];
+++ /dev/null
-From 1f820f538f7396db7fd40684b9c3620816acc5a3 Mon Sep 17 00:00:00 2001
-From: Arnd Bergmann <arnd@arndb.de>
-Date: Fri, 29 Jan 2016 12:39:12 +0100
-Subject: [PATCH] net: bgmac: clarify CONFIG_BCMA dependency
-
-The bgmac driver depends on BCMA_HOST_SOC, which is only used
-when CONFIG_BCMA is enabled. However, it is a bool option and can
-be set when CONFIG_BCMA=m, and then bgmac can be built-in, leading
-to an obvious link error:
-
-drivers/built-in.o: In function `bgmac_init':
-:(.init.text+0x7f2c): undefined reference to `__bcma_driver_register'
-drivers/built-in.o: In function `bgmac_exit':
-:(.exit.text+0x110a): undefined reference to `bcma_driver_unregister'
-
-To avoid this case, we need to depend on both BCMA and BCMA_SOC,
-as this patch does. I'm also trying to make the dependency more
-readable by splitting it into three lines, and adding a COMPILE_TEST
-alternative so we can test-build it in all configurations that
-support BCMA.
-
-The added dependency on FIXED_PHY addresses a related issue where
-we cannot call fixed_phy_register() when CONFIG_FIXED_PHY=m and
-CONFIG_BGMAC=y.
-
-Signed-off-by: Arnd Bergmann <arnd@arndb.de>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/Kconfig | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
---- a/drivers/net/ethernet/broadcom/Kconfig
-+++ b/drivers/net/ethernet/broadcom/Kconfig
-@@ -151,8 +151,11 @@ config BNX2X_VXLAN
-
- config BGMAC
- tristate "BCMA bus GBit core support"
-- depends on BCMA_HOST_SOC && HAS_DMA && (BCM47XX || ARCH_BCM_5301X)
-+ depends on BCMA && BCMA_HOST_SOC
-+ depends on HAS_DMA
-+ depends on BCM47XX || ARCH_BCM_5301X || COMPILE_TEST
- select PHYLIB
-+ select FIXED_PHY
- ---help---
- This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus.
- They can be found on BCM47xx SoCs and provide gigabit ethernet.
+++ /dev/null
-From 387b75f8b31437792e8334390fdf5cf060d1e3da Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
-Date: Tue, 2 Feb 2016 07:47:14 +0100
-Subject: [PATCH] bgmac: add helper checking for BCM4707 / BCM53018 chip id
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Chipsets with BCM4707 / BCM53018 ID require special handling at a few
-places in the code. It's likely there will be more IDs to check in the
-future. To simplify it add this trivial helper.
-
-Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 30 ++++++++++++++++--------------
- 1 file changed, 16 insertions(+), 14 deletions(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -26,6 +26,17 @@ static const struct bcma_device_id bgmac
- };
- MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl);
-
-+static inline bool bgmac_is_bcm4707_family(struct bgmac *bgmac)
-+{
-+ switch (bgmac->core->bus->chipinfo.id) {
-+ case BCMA_CHIP_ID_BCM4707:
-+ case BCMA_CHIP_ID_BCM53018:
-+ return true;
-+ default:
-+ return false;
-+ }
-+}
-+
- static bool bgmac_wait_value(struct bcma_device *core, u16 reg, u32 mask,
- u32 value, int timeout)
- {
-@@ -990,11 +1001,9 @@ static void bgmac_mac_speed(struct bgmac
- static void bgmac_miiconfig(struct bgmac *bgmac)
- {
- struct bcma_device *core = bgmac->core;
-- struct bcma_chipinfo *ci = &core->bus->chipinfo;
- u8 imode;
-
-- if (ci->id == BCMA_CHIP_ID_BCM4707 ||
-- ci->id == BCMA_CHIP_ID_BCM53018) {
-+ if (bgmac_is_bcm4707_family(bgmac)) {
- bcma_awrite32(core, BCMA_IOCTL,
- bcma_aread32(core, BCMA_IOCTL) | 0x40 |
- BGMAC_BCMA_IOCTL_SW_CLKEN);
-@@ -1058,9 +1067,7 @@ static void bgmac_chip_reset(struct bgma
- }
-
- /* Request Misc PLL for corerev > 2 */
-- if (core->id.rev > 2 &&
-- ci->id != BCMA_CHIP_ID_BCM4707 &&
-- ci->id != BCMA_CHIP_ID_BCM53018) {
-+ if (core->id.rev > 2 && !bgmac_is_bcm4707_family(bgmac)) {
- bgmac_set(bgmac, BCMA_CLKCTLST,
- BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ);
- bgmac_wait_value(bgmac->core, BCMA_CLKCTLST,
-@@ -1196,8 +1203,7 @@ static void bgmac_enable(struct bgmac *b
- break;
- }
-
-- if (ci->id != BCMA_CHIP_ID_BCM4707 &&
-- ci->id != BCMA_CHIP_ID_BCM53018) {
-+ if (!bgmac_is_bcm4707_family(bgmac)) {
- rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
- rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
- bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) /
-@@ -1475,14 +1481,12 @@ static int bgmac_fixed_phy_register(stru
-
- static int bgmac_mii_register(struct bgmac *bgmac)
- {
-- struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo;
- struct mii_bus *mii_bus;
- struct phy_device *phy_dev;
- char bus_id[MII_BUS_ID_SIZE + 3];
- int i, err = 0;
-
-- if (ci->id == BCMA_CHIP_ID_BCM4707 ||
-- ci->id == BCMA_CHIP_ID_BCM53018)
-+ if (bgmac_is_bcm4707_family(bgmac))
- return bgmac_fixed_phy_register(bgmac);
-
- mii_bus = mdiobus_alloc();
-@@ -1553,7 +1557,6 @@ static void bgmac_mii_unregister(struct
- /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
- static int bgmac_probe(struct bcma_device *core)
- {
-- struct bcma_chipinfo *ci = &core->bus->chipinfo;
- struct net_device *net_dev;
- struct bgmac *bgmac;
- struct ssb_sprom *sprom = &core->bus->sprom;
-@@ -1634,8 +1637,7 @@ static int bgmac_probe(struct bcma_devic
- bgmac_chip_reset(bgmac);
-
- /* For Northstar, we have to take all GMAC core out of reset */
-- if (ci->id == BCMA_CHIP_ID_BCM4707 ||
-- ci->id == BCMA_CHIP_ID_BCM53018) {
-+ if (bgmac_is_bcm4707_family(bgmac)) {
- struct bcma_device *ns_core;
- int ns_gmac;
-
+++ /dev/null
-From 9e4e6206c67ae11d68fc96882256f37c237087d4 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
-Date: Mon, 22 Feb 2016 22:51:13 +0100
-Subject: [PATCH] bgmac: support Ethernet device on BCM47094 SoC
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-It needs very similar workarounds to the one on BCM4707. It was tested
-on D-Link DIR-885L home router.
-
-Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 6 ++++--
- 1 file changed, 4 insertions(+), 2 deletions(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -30,6 +30,7 @@ static inline bool bgmac_is_bcm4707_fami
- {
- switch (bgmac->core->bus->chipinfo.id) {
- case BCMA_CHIP_ID_BCM4707:
-+ case BCMA_CHIP_ID_BCM47094:
- case BCMA_CHIP_ID_BCM53018:
- return true;
- default:
-@@ -1055,8 +1056,9 @@ static void bgmac_chip_reset(struct bgma
- (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == BCMA_PKG_ID_BCM47188))
- iost &= ~BGMAC_BCMA_IOST_ATTACHED;
-
-- /* 3GMAC: for BCM4707, only do core reset at bgmac_probe() */
-- if (ci->id != BCMA_CHIP_ID_BCM4707) {
-+ /* 3GMAC: for BCM4707 & BCM47094, only do core reset at bgmac_probe() */
-+ if (ci->id != BCMA_CHIP_ID_BCM4707 &&
-+ ci->id != BCMA_CHIP_ID_BCM47094) {
- flags = 0;
- if (iost & BGMAC_BCMA_IOST_ATTACHED) {
- flags = BGMAC_BCMA_IOCTL_SW_CLKEN;
+++ /dev/null
-From b4dfd8e92956b396d3438212bc9a0be6267b8b34 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
-Date: Tue, 12 Apr 2016 13:30:45 +0200
-Subject: [PATCH] bgmac: reset & enable Ethernet core before using it
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This fixes Ethernet on D-Link DIR-885L with BCM47094 SoC. Felix reported
-similar fix was needed for his BCM4709 device (Buffalo WXR-1900DHP?).
-I tested this for regressions on BCM4706, BCM4708A0 and BCM47081A0.
-
-Cc: Felix Fietkau <nbd@nbd.name>
-Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -1586,6 +1586,11 @@ static int bgmac_probe(struct bcma_devic
- dev_warn(&core->dev, "Using random MAC: %pM\n", mac);
- }
-
-+ /* This (reset &) enable is not preset in specs or reference driver but
-+ * Broadcom does it in arch PCI code when enabling fake PCI device.
-+ */
-+ bcma_core_enable(core, 0);
-+
- /* Allocation and references */
- net_dev = alloc_etherdev(sizeof(*bgmac));
- if (!net_dev)
+++ /dev/null
-From c02bc350f9dbce7d637c394a6e1c4d29dc5b28b2 Mon Sep 17 00:00:00 2001
-From: Felix Fietkau <nbd@nbd.name>
-Date: Tue, 12 Apr 2016 18:27:29 +0200
-Subject: [PATCH] bgmac: fix MAC soft-reset bit for corerev > 4
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Only core revisions older than 4 use BGMAC_CMDCFG_SR_REV0. This mainly
-fixes support for BCM4708A0KF SoCs with Ethernet core rev 5 (it means
-only some devices as most of BCM4708A0KF-s got core rev 4).
-This was tested for regressions on BCM47094 which doesn't seem to care
-which bit gets used.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
-Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
-
---- a/drivers/net/ethernet/broadcom/bgmac.h
-+++ b/drivers/net/ethernet/broadcom/bgmac.h
-@@ -199,9 +199,9 @@
- #define BGMAC_CMDCFG_TAI 0x00000200
- #define BGMAC_CMDCFG_HD 0x00000400 /* Set if in half duplex mode */
- #define BGMAC_CMDCFG_HD_SHIFT 10
--#define BGMAC_CMDCFG_SR_REV0 0x00000800 /* Set to reset mode, for other revs */
--#define BGMAC_CMDCFG_SR_REV4 0x00002000 /* Set to reset mode, only for core rev 4 */
--#define BGMAC_CMDCFG_SR(rev) ((rev == 4) ? BGMAC_CMDCFG_SR_REV4 : BGMAC_CMDCFG_SR_REV0)
-+#define BGMAC_CMDCFG_SR_REV0 0x00000800 /* Set to reset mode, for core rev 0-3 */
-+#define BGMAC_CMDCFG_SR_REV4 0x00002000 /* Set to reset mode, for core rev >= 4 */
-+#define BGMAC_CMDCFG_SR(rev) ((rev >= 4) ? BGMAC_CMDCFG_SR_REV4 : BGMAC_CMDCFG_SR_REV0)
- #define BGMAC_CMDCFG_ML 0x00008000 /* Set to activate mac loopback mode */
- #define BGMAC_CMDCFG_AE 0x00400000
- #define BGMAC_CMDCFG_CFE 0x00800000
--- /dev/null
+From d2b13233879ca1268a1c027d4573109e5a777811 Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Thu, 23 Jun 2016 14:23:12 -0700
+Subject: [PATCH 1/3] net: bgmac: Fix SOF bit checking
+
+We are checking for the Start of Frame bit in the ctl1 word, while this
+bit is set in the ctl0 word instead. Read the ctl0 word and update the
+check to verify that.
+
+Fixes: 9cde94506eac ("bgmac: implement scatter/gather support")
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -269,15 +269,16 @@ static void bgmac_dma_tx_free(struct bgm
+ while (ring->start != ring->end) {
+ int slot_idx = ring->start % BGMAC_TX_RING_SLOTS;
+ struct bgmac_slot_info *slot = &ring->slots[slot_idx];
+- u32 ctl1;
++ u32 ctl0, ctl1;
+ int len;
+
+ if (slot_idx == empty_slot)
+ break;
+
++ ctl0 = le32_to_cpu(ring->cpu_base[slot_idx].ctl0);
+ ctl1 = le32_to_cpu(ring->cpu_base[slot_idx].ctl1);
+ len = ctl1 & BGMAC_DESC_CTL1_LEN;
+- if (ctl1 & BGMAC_DESC_CTL0_SOF)
++ if (ctl0 & BGMAC_DESC_CTL0_SOF)
+ /* Unmap no longer used buffer */
+ dma_unmap_single(dma_dev, slot->dma_addr, len,
+ DMA_TO_DEVICE);
--- /dev/null
+From c3897f2a69e54dd113fc9abd2daf872e5b495798 Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Thu, 23 Jun 2016 14:25:32 -0700
+Subject: [PATCH 2/3] net: bgmac: Start transmit queue in bgmac_open
+
+The driver does not start the transmit queue in bgmac_open(). If the
+queue was stopped prior to closing then re-opening the interface, we
+would never be able to wake-up again.
+
+Fixes: dd4544f05469 ("bgmac: driver for GBit MAC core on BCMA bus")
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -1327,6 +1327,9 @@ static int bgmac_open(struct net_device
+ phy_start(net_dev->phydev);
+
+ netif_carrier_on(net_dev);
++
++ netif_start_queue(net_dev);
++
+ return 0;
+ }
+
--- /dev/null
+From 3894396e64994f31c3ef5c7e6f63dded0593e567 Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Thu, 23 Jun 2016 14:25:33 -0700
+Subject: [PATCH 3/3] net: bgmac: Remove superflous netif_carrier_on()
+
+bgmac_open() calls phy_start() to initialize the PHY state machine,
+which will set the interface's carrier state accordingly, no need to
+force that as this could be conflicting with the PHY state determined by
+PHYLIB.
+
+Fixes: dd4544f05469 ("bgmac: driver for GBit MAC core on BCMA bus")
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -1326,8 +1326,6 @@ static int bgmac_open(struct net_device
+
+ phy_start(net_dev->phydev);
+
+- netif_carrier_on(net_dev);
+-
+ netif_start_queue(net_dev);
+
+ return 0;
--- /dev/null
+From d00a8281bcc962027dfe409c2f3e3f0546be9200 Mon Sep 17 00:00:00 2001
+From: Jon Mason <jon.mason@broadcom.com>
+Date: Thu, 7 Jul 2016 19:08:53 -0400
+Subject: [PATCH 1/5] net: ethernet: bgmac: change bgmac_* prints to dev_*
+ prints
+
+The bgmac_* print wrappers call dev_* prints with the dev pointer from
+the bcma core. In anticipation of removing the bcma requirement for
+this driver, these must be changed to not reference that struct. So,
+simply change all of the bgmac_* prints to their dev_* counterparts. In
+some cases netdev_* prints are more appropriate, so change those as
+well.
+
+Signed-off-by: Jon Mason <jon.mason@broadcom.com>
+Acked-by: Arnd Bergmann <arnd@arndb.de>
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Tested-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 103 +++++++++++++++++-----------------
+ drivers/net/ethernet/broadcom/bgmac.h | 14 +----
+ 2 files changed, 55 insertions(+), 62 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -50,7 +50,7 @@ static bool bgmac_wait_value(struct bcma
+ return true;
+ udelay(10);
+ }
+- pr_err("Timeout waiting for reg 0x%X\n", reg);
++ dev_err(&core->dev, "Timeout waiting for reg 0x%X\n", reg);
+ return false;
+ }
+
+@@ -84,8 +84,8 @@ static void bgmac_dma_tx_reset(struct bg
+ udelay(10);
+ }
+ if (i)
+- bgmac_err(bgmac, "Timeout suspending DMA TX ring 0x%X (BGMAC_DMA_TX_STAT: 0x%08X)\n",
+- ring->mmio_base, val);
++ dev_err(bgmac->dev, "Timeout suspending DMA TX ring 0x%X (BGMAC_DMA_TX_STAT: 0x%08X)\n",
++ ring->mmio_base, val);
+
+ /* Remove SUSPEND bit */
+ bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_CTL, 0);
+@@ -93,13 +93,13 @@ static void bgmac_dma_tx_reset(struct bg
+ ring->mmio_base + BGMAC_DMA_TX_STATUS,
+ BGMAC_DMA_TX_STAT, BGMAC_DMA_TX_STAT_DISABLED,
+ 10000)) {
+- bgmac_warn(bgmac, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
+- ring->mmio_base);
++ dev_warn(bgmac->dev, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
++ ring->mmio_base);
+ udelay(300);
+ val = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_TX_STATUS);
+ if ((val & BGMAC_DMA_TX_STAT) != BGMAC_DMA_TX_STAT_DISABLED)
+- bgmac_err(bgmac, "Reset of DMA TX ring 0x%X failed\n",
+- ring->mmio_base);
++ dev_err(bgmac->dev, "Reset of DMA TX ring 0x%X failed\n",
++ ring->mmio_base);
+ }
+ }
+
+@@ -161,7 +161,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
+ int i;
+
+ if (skb->len > BGMAC_DESC_CTL1_LEN) {
+- bgmac_err(bgmac, "Too long skb (%d)\n", skb->len);
++ netdev_err(bgmac->net_dev, "Too long skb (%d)\n", skb->len);
+ goto err_drop;
+ }
+
+@@ -174,7 +174,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
+ * even when ring->end overflows
+ */
+ if (ring->end - ring->start + nr_frags + 1 >= BGMAC_TX_RING_SLOTS) {
+- bgmac_err(bgmac, "TX ring is full, queue should be stopped!\n");
++ netdev_err(bgmac->net_dev, "TX ring is full, queue should be stopped!\n");
+ netif_stop_queue(net_dev);
+ return NETDEV_TX_BUSY;
+ }
+@@ -241,8 +241,8 @@ err_dma:
+ }
+
+ err_dma_head:
+- bgmac_err(bgmac, "Mapping error of skb on ring 0x%X\n",
+- ring->mmio_base);
++ netdev_err(bgmac->net_dev, "Mapping error of skb on ring 0x%X\n",
++ ring->mmio_base);
+
+ err_drop:
+ dev_kfree_skb(skb);
+@@ -321,8 +321,8 @@ static void bgmac_dma_rx_reset(struct bg
+ ring->mmio_base + BGMAC_DMA_RX_STATUS,
+ BGMAC_DMA_RX_STAT, BGMAC_DMA_RX_STAT_DISABLED,
+ 10000))
+- bgmac_err(bgmac, "Reset of ring 0x%X RX failed\n",
+- ring->mmio_base);
++ dev_err(bgmac->dev, "Reset of ring 0x%X RX failed\n",
++ ring->mmio_base);
+ }
+
+ static void bgmac_dma_rx_enable(struct bgmac *bgmac,
+@@ -374,7 +374,7 @@ static int bgmac_dma_rx_skb_for_slot(str
+ dma_addr = dma_map_single(dma_dev, buf + BGMAC_RX_BUF_OFFSET,
+ BGMAC_RX_BUF_SIZE, DMA_FROM_DEVICE);
+ if (dma_mapping_error(dma_dev, dma_addr)) {
+- bgmac_err(bgmac, "DMA mapping error\n");
++ netdev_err(bgmac->net_dev, "DMA mapping error\n");
+ put_page(virt_to_head_page(buf));
+ return -ENOMEM;
+ }
+@@ -469,16 +469,16 @@ static int bgmac_dma_rx_read(struct bgma
+
+ /* Check for poison and drop or pass the packet */
+ if (len == 0xdead && flags == 0xbeef) {
+- bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n",
+- ring->start);
++ netdev_err(bgmac->net_dev, "Found poisoned packet at slot %d, DMA issue!\n",
++ ring->start);
+ put_page(virt_to_head_page(buf));
+ bgmac->net_dev->stats.rx_errors++;
+ break;
+ }
+
+ if (len > BGMAC_RX_ALLOC_SIZE) {
+- bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n",
+- ring->start);
++ netdev_err(bgmac->net_dev, "Found oversized packet at slot %d, DMA issue!\n",
++ ring->start);
+ put_page(virt_to_head_page(buf));
+ bgmac->net_dev->stats.rx_length_errors++;
+ bgmac->net_dev->stats.rx_errors++;
+@@ -490,7 +490,7 @@ static int bgmac_dma_rx_read(struct bgma
+
+ skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
+ if (unlikely(!skb)) {
+- bgmac_err(bgmac, "build_skb failed\n");
++ netdev_err(bgmac->net_dev, "build_skb failed\n");
+ put_page(virt_to_head_page(buf));
+ bgmac->net_dev->stats.rx_errors++;
+ break;
+@@ -644,7 +644,7 @@ static int bgmac_dma_alloc(struct bgmac
+ BUILD_BUG_ON(BGMAC_MAX_RX_RINGS > ARRAY_SIZE(ring_base));
+
+ if (!(bcma_aread32(bgmac->core, BCMA_IOST) & BCMA_IOST_DMA64)) {
+- bgmac_err(bgmac, "Core does not report 64-bit DMA\n");
++ dev_err(bgmac->dev, "Core does not report 64-bit DMA\n");
+ return -ENOTSUPP;
+ }
+
+@@ -658,8 +658,8 @@ static int bgmac_dma_alloc(struct bgmac
+ &ring->dma_base,
+ GFP_KERNEL);
+ if (!ring->cpu_base) {
+- bgmac_err(bgmac, "Allocation of TX ring 0x%X failed\n",
+- ring->mmio_base);
++ dev_err(bgmac->dev, "Allocation of TX ring 0x%X failed\n",
++ ring->mmio_base);
+ goto err_dma_free;
+ }
+
+@@ -683,8 +683,8 @@ static int bgmac_dma_alloc(struct bgmac
+ &ring->dma_base,
+ GFP_KERNEL);
+ if (!ring->cpu_base) {
+- bgmac_err(bgmac, "Allocation of RX ring 0x%X failed\n",
+- ring->mmio_base);
++ dev_err(bgmac->dev, "Allocation of RX ring 0x%X failed\n",
++ ring->mmio_base);
+ err = -ENOMEM;
+ goto err_dma_free;
+ }
+@@ -803,8 +803,8 @@ static u16 bgmac_phy_read(struct bgmac *
+ bcma_write32(core, phy_access_addr, tmp);
+
+ if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
+- bgmac_err(bgmac, "Reading PHY %d register 0x%X failed\n",
+- phyaddr, reg);
++ dev_err(bgmac->dev, "Reading PHY %d register 0x%X failed\n",
++ phyaddr, reg);
+ return 0xffff;
+ }
+
+@@ -836,7 +836,7 @@ static int bgmac_phy_write(struct bgmac
+
+ bgmac_write(bgmac, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
+ if (bgmac_read(bgmac, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
+- bgmac_warn(bgmac, "Error setting MDIO int\n");
++ dev_warn(bgmac->dev, "Error setting MDIO int\n");
+
+ tmp = BGMAC_PA_START;
+ tmp |= BGMAC_PA_WRITE;
+@@ -846,8 +846,8 @@ static int bgmac_phy_write(struct bgmac
+ bcma_write32(core, phy_access_addr, tmp);
+
+ if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
+- bgmac_err(bgmac, "Writing to PHY %d register 0x%X failed\n",
+- phyaddr, reg);
++ dev_err(bgmac->dev, "Writing to PHY %d register 0x%X failed\n",
++ phyaddr, reg);
+ return -ETIMEDOUT;
+ }
+
+@@ -900,7 +900,7 @@ static void bgmac_phy_reset(struct bgmac
+ bgmac_phy_write(bgmac, bgmac->phyaddr, MII_BMCR, BMCR_RESET);
+ udelay(100);
+ if (bgmac_phy_read(bgmac, bgmac->phyaddr, MII_BMCR) & BMCR_RESET)
+- bgmac_err(bgmac, "PHY reset failed\n");
++ dev_err(bgmac->dev, "PHY reset failed\n");
+ bgmac_phy_init(bgmac);
+ }
+
+@@ -1001,7 +1001,8 @@ static void bgmac_mac_speed(struct bgmac
+ set |= BGMAC_CMDCFG_ES_2500;
+ break;
+ default:
+- bgmac_err(bgmac, "Unsupported speed: %d\n", bgmac->mac_speed);
++ dev_err(bgmac->dev, "Unsupported speed: %d\n",
++ bgmac->mac_speed);
+ }
+
+ if (bgmac->mac_duplex == DUPLEX_HALF)
+@@ -1100,8 +1101,8 @@ static void bgmac_chip_reset(struct bgma
+
+ if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
+ if (kstrtou8(buf, 0, &et_swtype))
+- bgmac_err(bgmac, "Failed to parse et_swtype (%s)\n",
+- buf);
++ dev_err(bgmac->dev, "Failed to parse et_swtype (%s)\n",
++ buf);
+ et_swtype &= 0x0f;
+ et_swtype <<= 4;
+ sw_type = et_swtype;
+@@ -1264,7 +1265,7 @@ static irqreturn_t bgmac_interrupt(int i
+
+ int_status &= ~(BGMAC_IS_TX0 | BGMAC_IS_RX);
+ if (int_status)
+- bgmac_err(bgmac, "Unknown IRQs: 0x%08X\n", int_status);
++ dev_err(bgmac->dev, "Unknown IRQs: 0x%08X\n", int_status);
+
+ /* Disable new interrupts until handling existing ones */
+ bgmac_chip_intrs_off(bgmac);
+@@ -1318,7 +1319,7 @@ static int bgmac_open(struct net_device
+ err = request_irq(bgmac->core->irq, bgmac_interrupt, IRQF_SHARED,
+ KBUILD_MODNAME, net_dev);
+ if (err < 0) {
+- bgmac_err(bgmac, "IRQ request error: %d!\n", err);
++ dev_err(bgmac->dev, "IRQ request error: %d!\n", err);
+ bgmac_dma_cleanup(bgmac);
+ return err;
+ }
+@@ -1599,14 +1600,14 @@ static int bgmac_fixed_phy_register(stru
+
+ phy_dev = fixed_phy_register(PHY_POLL, &fphy_status, -1, NULL);
+ if (!phy_dev || IS_ERR(phy_dev)) {
+- bgmac_err(bgmac, "Failed to register fixed PHY device\n");
++ dev_err(bgmac->dev, "Failed to register fixed PHY device\n");
+ return -ENODEV;
+ }
+
+ err = phy_connect_direct(bgmac->net_dev, phy_dev, bgmac_adjust_link,
+ PHY_INTERFACE_MODE_MII);
+ if (err) {
+- bgmac_err(bgmac, "Connecting PHY failed\n");
++ dev_err(bgmac->dev, "Connecting PHY failed\n");
+ return err;
+ }
+
+@@ -1646,7 +1647,7 @@ static int bgmac_mii_register(struct bgm
+
+ err = mdiobus_register(mii_bus);
+ if (err) {
+- bgmac_err(bgmac, "Registration of mii bus failed\n");
++ dev_err(bgmac->dev, "Registration of mii bus failed\n");
+ goto err_free_irq;
+ }
+
+@@ -1658,7 +1659,7 @@ static int bgmac_mii_register(struct bgm
+ phy_dev = phy_connect(bgmac->net_dev, bus_id, &bgmac_adjust_link,
+ PHY_INTERFACE_MODE_MII);
+ if (IS_ERR(phy_dev)) {
+- bgmac_err(bgmac, "PHY connecton failed\n");
++ dev_err(bgmac->dev, "PHY connecton failed\n");
+ err = PTR_ERR(phy_dev);
+ goto err_unregister_bus;
+ }
+@@ -1707,7 +1708,8 @@ static int bgmac_probe(struct bcma_devic
+ mac = sprom->et2mac;
+ break;
+ default:
+- pr_err("Unsupported core_unit %d\n", core->core_unit);
++ dev_err(&core->dev, "Unsupported core_unit %d\n",
++ core->core_unit);
+ return -ENOTSUPP;
+ }
+
+@@ -1730,6 +1732,7 @@ static int bgmac_probe(struct bcma_devic
+ net_dev->irq = core->irq;
+ net_dev->ethtool_ops = &bgmac_ethtool_ops;
+ bgmac = netdev_priv(net_dev);
++ bgmac->dev = &core->dev;
+ bgmac->net_dev = net_dev;
+ bgmac->core = core;
+ bcma_set_drvdata(core, bgmac);
+@@ -1741,7 +1744,7 @@ static int bgmac_probe(struct bcma_devic
+ /* On BCM4706 we need common core to access PHY */
+ if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
+ !core->bus->drv_gmac_cmn.core) {
+- bgmac_err(bgmac, "GMAC CMN core not found (required for BCM4706)\n");
++ dev_err(bgmac->dev, "GMAC CMN core not found (required for BCM4706)\n");
+ err = -ENODEV;
+ goto err_netdev_free;
+ }
+@@ -1760,15 +1763,15 @@ static int bgmac_probe(struct bcma_devic
+ }
+ bgmac->phyaddr &= BGMAC_PHY_MASK;
+ if (bgmac->phyaddr == BGMAC_PHY_MASK) {
+- bgmac_err(bgmac, "No PHY found\n");
++ dev_err(bgmac->dev, "No PHY found\n");
+ err = -ENODEV;
+ goto err_netdev_free;
+ }
+- bgmac_info(bgmac, "Found PHY addr: %d%s\n", bgmac->phyaddr,
+- bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
++ dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
++ bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
+
+ if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) {
+- bgmac_err(bgmac, "PCI setup not implemented\n");
++ dev_err(bgmac->dev, "PCI setup not implemented\n");
+ err = -ENOTSUPP;
+ goto err_netdev_free;
+ }
+@@ -1797,7 +1800,7 @@ static int bgmac_probe(struct bcma_devic
+
+ err = bgmac_dma_alloc(bgmac);
+ if (err) {
+- bgmac_err(bgmac, "Unable to alloc memory for DMA\n");
++ dev_err(bgmac->dev, "Unable to alloc memory for DMA\n");
+ goto err_netdev_free;
+ }
+
+@@ -1811,16 +1814,16 @@ static int bgmac_probe(struct bcma_devic
+ bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo &
+ BGMAC_BFL_ENETROBO);
+ if (bgmac->has_robosw)
+- bgmac_warn(bgmac, "Support for Roboswitch not implemented\n");
++ dev_warn(bgmac->dev, "Support for Roboswitch not implemented\n");
+
+ if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
+- bgmac_warn(bgmac, "Support for ADMtek ethernet switch not implemented\n");
++ dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
+
+ netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
+
+ err = bgmac_mii_register(bgmac);
+ if (err) {
+- bgmac_err(bgmac, "Cannot register MDIO\n");
++ dev_err(bgmac->dev, "Cannot connect to phy\n");
+ goto err_dma_free;
+ }
+
+@@ -1830,7 +1833,7 @@ static int bgmac_probe(struct bcma_devic
+
+ err = register_netdev(bgmac->net_dev);
+ if (err) {
+- bgmac_err(bgmac, "Cannot register net device\n");
++ dev_err(bgmac->dev, "Cannot register net device\n");
+ goto err_mii_unregister;
+ }
+
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -1,17 +1,6 @@
+ #ifndef _BGMAC_H
+ #define _BGMAC_H
+
+-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+-
+-#define bgmac_err(bgmac, fmt, ...) \
+- dev_err(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
+-#define bgmac_warn(bgmac, fmt, ...) \
+- dev_warn(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
+-#define bgmac_info(bgmac, fmt, ...) \
+- dev_info(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
+-#define bgmac_dbg(bgmac, fmt, ...) \
+- dev_dbg(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
+-
+ #include <linux/bcma/bcma.h>
+ #include <linux/brcmphy.h>
+ #include <linux/netdevice.h>
+@@ -438,6 +427,8 @@ struct bgmac_rx_header {
+ struct bgmac {
+ struct bcma_device *core;
+ struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
++
++ struct device *dev;
+ struct net_device *net_dev;
+ struct napi_struct napi;
+ struct mii_bus *mii_bus;
+@@ -489,5 +480,4 @@ static inline void bgmac_set(struct bgma
+ {
+ bgmac_maskset(bgmac, offset, ~0, set);
+ }
+-
+ #endif /* _BGMAC_H */
--- /dev/null
+From a0b68486f6f680c7c0352a47c60042d7d95ffd87 Mon Sep 17 00:00:00 2001
+From: Jon Mason <jon.mason@broadcom.com>
+Date: Thu, 7 Jul 2016 19:08:54 -0400
+Subject: [PATCH 2/5] net: ethernet: bgmac: add dma_dev pointer
+
+The dma buffer allocation, etc references a dma_dev device pointer from
+the bcma core. In anticipation of removing the bcma requirement for
+this driver, these must be changed to not reference that struct. Add a
+dma_dev device pointer to the bgmac stuct and reference that instead.
+
+Signed-off-by: Jon Mason <jon.mason@broadcom.com>
+Acked-by: Arnd Bergmann <arnd@arndb.de>
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Tested-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 17 +++++++++--------
+ drivers/net/ethernet/broadcom/bgmac.h | 1 +
+ 2 files changed, 10 insertions(+), 8 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -152,7 +152,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
+ struct bgmac_dma_ring *ring,
+ struct sk_buff *skb)
+ {
+- struct device *dma_dev = bgmac->core->dma_dev;
++ struct device *dma_dev = bgmac->dma_dev;
+ struct net_device *net_dev = bgmac->net_dev;
+ int index = ring->end % BGMAC_TX_RING_SLOTS;
+ struct bgmac_slot_info *slot = &ring->slots[index];
+@@ -254,7 +254,7 @@ err_drop:
+ /* Free transmitted packets */
+ static void bgmac_dma_tx_free(struct bgmac *bgmac, struct bgmac_dma_ring *ring)
+ {
+- struct device *dma_dev = bgmac->core->dma_dev;
++ struct device *dma_dev = bgmac->dma_dev;
+ int empty_slot;
+ bool freed = false;
+ unsigned bytes_compl = 0, pkts_compl = 0;
+@@ -355,7 +355,7 @@ static void bgmac_dma_rx_enable(struct b
+ static int bgmac_dma_rx_skb_for_slot(struct bgmac *bgmac,
+ struct bgmac_slot_info *slot)
+ {
+- struct device *dma_dev = bgmac->core->dma_dev;
++ struct device *dma_dev = bgmac->dma_dev;
+ dma_addr_t dma_addr;
+ struct bgmac_rx_header *rx;
+ void *buf;
+@@ -444,7 +444,7 @@ static int bgmac_dma_rx_read(struct bgma
+ end_slot /= sizeof(struct bgmac_dma_desc);
+
+ while (ring->start != end_slot) {
+- struct device *dma_dev = bgmac->core->dma_dev;
++ struct device *dma_dev = bgmac->dma_dev;
+ struct bgmac_slot_info *slot = &ring->slots[ring->start];
+ struct bgmac_rx_header *rx = slot->buf + BGMAC_RX_BUF_OFFSET;
+ struct sk_buff *skb;
+@@ -547,7 +547,7 @@ static bool bgmac_dma_unaligned(struct b
+ static void bgmac_dma_tx_ring_free(struct bgmac *bgmac,
+ struct bgmac_dma_ring *ring)
+ {
+- struct device *dma_dev = bgmac->core->dma_dev;
++ struct device *dma_dev = bgmac->dma_dev;
+ struct bgmac_dma_desc *dma_desc = ring->cpu_base;
+ struct bgmac_slot_info *slot;
+ int i;
+@@ -573,7 +573,7 @@ static void bgmac_dma_tx_ring_free(struc
+ static void bgmac_dma_rx_ring_free(struct bgmac *bgmac,
+ struct bgmac_dma_ring *ring)
+ {
+- struct device *dma_dev = bgmac->core->dma_dev;
++ struct device *dma_dev = bgmac->dma_dev;
+ struct bgmac_slot_info *slot;
+ int i;
+
+@@ -594,7 +594,7 @@ static void bgmac_dma_ring_desc_free(str
+ struct bgmac_dma_ring *ring,
+ int num_slots)
+ {
+- struct device *dma_dev = bgmac->core->dma_dev;
++ struct device *dma_dev = bgmac->dma_dev;
+ int size;
+
+ if (!ring->cpu_base)
+@@ -632,7 +632,7 @@ static void bgmac_dma_free(struct bgmac
+
+ static int bgmac_dma_alloc(struct bgmac *bgmac)
+ {
+- struct device *dma_dev = bgmac->core->dma_dev;
++ struct device *dma_dev = bgmac->dma_dev;
+ struct bgmac_dma_ring *ring;
+ static const u16 ring_base[] = { BGMAC_DMA_BASE0, BGMAC_DMA_BASE1,
+ BGMAC_DMA_BASE2, BGMAC_DMA_BASE3, };
+@@ -1733,6 +1733,7 @@ static int bgmac_probe(struct bcma_devic
+ net_dev->ethtool_ops = &bgmac_ethtool_ops;
+ bgmac = netdev_priv(net_dev);
+ bgmac->dev = &core->dev;
++ bgmac->dma_dev = core->dma_dev;
+ bgmac->net_dev = net_dev;
+ bgmac->core = core;
+ bcma_set_drvdata(core, bgmac);
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -429,6 +429,7 @@ struct bgmac {
+ struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
+
+ struct device *dev;
++ struct device *dma_dev;
+ struct net_device *net_dev;
+ struct napi_struct napi;
+ struct mii_bus *mii_bus;
--- /dev/null
+From 55954f3bfdacc5908515b0c306cea23e77fab740 Mon Sep 17 00:00:00 2001
+From: Jon Mason <jon.mason@broadcom.com>
+Date: Thu, 7 Jul 2016 19:08:55 -0400
+Subject: [PATCH 3/5] net: ethernet: bgmac: move BCMA MDIO Phy code into a
+ separate file
+
+Move the BCMA MDIO phy into a separate file, as it is very tightly
+coupled with the BCMA bus. This will help with the upcoming BCMA
+removal from the bgmac driver. Optimally, this should be moved into
+phy drivers, but it is too tightly coupled with the bgmac driver to
+effectively move it without more changes to the driver.
+
+Note: the phy_reset was intentionally removed, as the mdio phy subsystem
+automatically resets the phy if a reset function pointer is present. In
+addition to the moving of the driver, this reset function is added.
+
+Signed-off-by: Jon Mason <jon.mason@broadcom.com>
+Acked-by: Arnd Bergmann <arnd@arndb.de>
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Tested-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/Makefile | 2 +-
+ drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c | 264 ++++++++++++++++++++++++
+ drivers/net/ethernet/broadcom/bgmac.c | 246 +++-------------------
+ drivers/net/ethernet/broadcom/bgmac.h | 3 +
+ 4 files changed, 298 insertions(+), 217 deletions(-)
+ create mode 100644 drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
+
+--- a/drivers/net/ethernet/broadcom/Makefile
++++ b/drivers/net/ethernet/broadcom/Makefile
+@@ -10,6 +10,6 @@ obj-$(CONFIG_CNIC) += cnic.o
+ obj-$(CONFIG_BNX2X) += bnx2x/
+ obj-$(CONFIG_SB1250_MAC) += sb1250-mac.o
+ obj-$(CONFIG_TIGON3) += tg3.o
+-obj-$(CONFIG_BGMAC) += bgmac.o
++obj-$(CONFIG_BGMAC) += bgmac.o bgmac-bcma-mdio.o
+ obj-$(CONFIG_SYSTEMPORT) += bcmsysport.o
+ obj-$(CONFIG_BNXT) += bnxt/
+--- /dev/null
++++ b/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
+@@ -0,0 +1,275 @@
++/*
++ * Driver for (BCM4706)? GBit MAC core on BCMA bus.
++ *
++ * Copyright (C) 2012 Rafał Miłecki <zajec5@gmail.com>
++ *
++ * Licensed under the GNU/GPL. See COPYING for details.
++ */
++
++#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
++
++#include <linux/bcma/bcma.h>
++#include <linux/brcmphy.h>
++#include "bgmac.h"
++
++struct bcma_mdio {
++ struct bcma_device *core;
++ u8 phyaddr;
++};
++
++static bool bcma_mdio_wait_value(struct bcma_device *core, u16 reg, u32 mask,
++ u32 value, int timeout)
++{
++ u32 val;
++ int i;
++
++ for (i = 0; i < timeout / 10; i++) {
++ val = bcma_read32(core, reg);
++ if ((val & mask) == value)
++ return true;
++ udelay(10);
++ }
++ dev_err(&core->dev, "Timeout waiting for reg 0x%X\n", reg);
++ return false;
++}
++
++/**************************************************
++ * PHY ops
++ **************************************************/
++
++static u16 bcma_mdio_phy_read(struct bcma_mdio *bcma_mdio, u8 phyaddr, u8 reg)
++{
++ struct bcma_device *core;
++ u16 phy_access_addr;
++ u16 phy_ctl_addr;
++ u32 tmp;
++
++ BUILD_BUG_ON(BGMAC_PA_DATA_MASK != BCMA_GMAC_CMN_PA_DATA_MASK);
++ BUILD_BUG_ON(BGMAC_PA_ADDR_MASK != BCMA_GMAC_CMN_PA_ADDR_MASK);
++ BUILD_BUG_ON(BGMAC_PA_ADDR_SHIFT != BCMA_GMAC_CMN_PA_ADDR_SHIFT);
++ BUILD_BUG_ON(BGMAC_PA_REG_MASK != BCMA_GMAC_CMN_PA_REG_MASK);
++ BUILD_BUG_ON(BGMAC_PA_REG_SHIFT != BCMA_GMAC_CMN_PA_REG_SHIFT);
++ BUILD_BUG_ON(BGMAC_PA_WRITE != BCMA_GMAC_CMN_PA_WRITE);
++ BUILD_BUG_ON(BGMAC_PA_START != BCMA_GMAC_CMN_PA_START);
++ BUILD_BUG_ON(BGMAC_PC_EPA_MASK != BCMA_GMAC_CMN_PC_EPA_MASK);
++ BUILD_BUG_ON(BGMAC_PC_MCT_MASK != BCMA_GMAC_CMN_PC_MCT_MASK);
++ BUILD_BUG_ON(BGMAC_PC_MCT_SHIFT != BCMA_GMAC_CMN_PC_MCT_SHIFT);
++ BUILD_BUG_ON(BGMAC_PC_MTE != BCMA_GMAC_CMN_PC_MTE);
++
++ if (bcma_mdio->core->id.id == BCMA_CORE_4706_MAC_GBIT) {
++ core = bcma_mdio->core->bus->drv_gmac_cmn.core;
++ phy_access_addr = BCMA_GMAC_CMN_PHY_ACCESS;
++ phy_ctl_addr = BCMA_GMAC_CMN_PHY_CTL;
++ } else {
++ core = bcma_mdio->core;
++ phy_access_addr = BGMAC_PHY_ACCESS;
++ phy_ctl_addr = BGMAC_PHY_CNTL;
++ }
++
++ tmp = bcma_read32(core, phy_ctl_addr);
++ tmp &= ~BGMAC_PC_EPA_MASK;
++ tmp |= phyaddr;
++ bcma_write32(core, phy_ctl_addr, tmp);
++
++ tmp = BGMAC_PA_START;
++ tmp |= phyaddr << BGMAC_PA_ADDR_SHIFT;
++ tmp |= reg << BGMAC_PA_REG_SHIFT;
++ bcma_write32(core, phy_access_addr, tmp);
++
++ if (!bcma_mdio_wait_value(core, phy_access_addr, BGMAC_PA_START, 0,
++ 1000)) {
++ dev_err(&core->dev, "Reading PHY %d register 0x%X failed\n",
++ phyaddr, reg);
++ return 0xffff;
++ }
++
++ return bcma_read32(core, phy_access_addr) & BGMAC_PA_DATA_MASK;
++}
++
++/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphywr */
++static int bcma_mdio_phy_write(struct bcma_mdio *bcma_mdio, u8 phyaddr, u8 reg,
++ u16 value)
++{
++ struct bcma_device *core;
++ u16 phy_access_addr;
++ u16 phy_ctl_addr;
++ u32 tmp;
++
++ if (bcma_mdio->core->id.id == BCMA_CORE_4706_MAC_GBIT) {
++ core = bcma_mdio->core->bus->drv_gmac_cmn.core;
++ phy_access_addr = BCMA_GMAC_CMN_PHY_ACCESS;
++ phy_ctl_addr = BCMA_GMAC_CMN_PHY_CTL;
++ } else {
++ core = bcma_mdio->core;
++ phy_access_addr = BGMAC_PHY_ACCESS;
++ phy_ctl_addr = BGMAC_PHY_CNTL;
++ }
++
++ tmp = bcma_read32(core, phy_ctl_addr);
++ tmp &= ~BGMAC_PC_EPA_MASK;
++ tmp |= phyaddr;
++ bcma_write32(core, phy_ctl_addr, tmp);
++
++ bcma_write32(bcma_mdio->core, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
++ if (bcma_read32(bcma_mdio->core, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
++ dev_warn(&core->dev, "Error setting MDIO int\n");
++
++ tmp = BGMAC_PA_START;
++ tmp |= BGMAC_PA_WRITE;
++ tmp |= phyaddr << BGMAC_PA_ADDR_SHIFT;
++ tmp |= reg << BGMAC_PA_REG_SHIFT;
++ tmp |= value;
++ bcma_write32(core, phy_access_addr, tmp);
++
++ if (!bcma_mdio_wait_value(core, phy_access_addr, BGMAC_PA_START, 0,
++ 1000)) {
++ dev_err(&core->dev, "Writing to PHY %d register 0x%X failed\n",
++ phyaddr, reg);
++ return -ETIMEDOUT;
++ }
++
++ return 0;
++}
++
++/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphyinit */
++static void bcma_mdio_phy_init(struct bcma_mdio *bcma_mdio)
++{
++ struct bcma_chipinfo *ci = &bcma_mdio->core->bus->chipinfo;
++ u8 i;
++
++ if (ci->id == BCMA_CHIP_ID_BCM5356) {
++ for (i = 0; i < 5; i++) {
++ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x008b);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x15, 0x0100);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000f);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x12, 0x2aaa);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000b);
++ }
++ }
++ if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg != 10) ||
++ (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg != 10) ||
++ (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg != 9)) {
++ struct bcma_drv_cc *cc = &bcma_mdio->core->bus->drv_cc;
++
++ bcma_chipco_chipctl_maskset(cc, 2, ~0xc0000000, 0);
++ bcma_chipco_chipctl_maskset(cc, 4, ~0x80000000, 0);
++ for (i = 0; i < 5; i++) {
++ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000f);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x16, 0x5284);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000b);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x0010);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000f);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x16, 0x5296);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x1073);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x9073);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x16, 0x52b6);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x9273);
++ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000b);
++ }
++ }
++}
++
++/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphyreset */
++static int bcma_mdio_phy_reset(struct mii_bus *bus)
++{
++ struct bcma_mdio *bcma_mdio = bus->priv;
++ u8 phyaddr = bcma_mdio->phyaddr;
++
++ if (bcma_mdio->phyaddr == BGMAC_PHY_NOREGS)
++ return 0;
++
++ bcma_mdio_phy_write(bcma_mdio, phyaddr, MII_BMCR, BMCR_RESET);
++ udelay(100);
++ if (bcma_mdio_phy_read(bcma_mdio, phyaddr, MII_BMCR) & BMCR_RESET)
++ dev_err(&bcma_mdio->core->dev, "PHY reset failed\n");
++ bcma_mdio_phy_init(bcma_mdio);
++
++ return 0;
++}
++
++/**************************************************
++ * MII
++ **************************************************/
++
++static int bcma_mdio_mii_read(struct mii_bus *bus, int mii_id, int regnum)
++{
++ return bcma_mdio_phy_read(bus->priv, mii_id, regnum);
++}
++
++static int bcma_mdio_mii_write(struct mii_bus *bus, int mii_id, int regnum,
++ u16 value)
++{
++ return bcma_mdio_phy_write(bus->priv, mii_id, regnum, value);
++}
++
++struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr)
++{
++ struct bcma_mdio *bcma_mdio;
++ struct mii_bus *mii_bus;
++ int i, err;
++
++ bcma_mdio = kzalloc(sizeof(*bcma_mdio), GFP_KERNEL);
++ if (!bcma_mdio)
++ return ERR_PTR(-ENOMEM);
++
++ mii_bus = mdiobus_alloc();
++ if (!mii_bus) {
++ err = -ENOMEM;
++ goto err;
++ }
++
++ mii_bus->name = "bcma_mdio mii bus";
++ sprintf(mii_bus->id, "%s-%d-%d", "bcma_mdio", core->bus->num,
++ core->core_unit);
++ mii_bus->priv = bcma_mdio;
++ mii_bus->read = bcma_mdio_mii_read;
++ mii_bus->write = bcma_mdio_mii_write;
++ mii_bus->reset = bcma_mdio_phy_reset;
++ mii_bus->parent = &core->dev;
++ mii_bus->phy_mask = ~(1 << phyaddr);
++
++ mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
++ if (!mii_bus->irq) {
++ err = -ENOMEM;
++ goto err_free_bus;
++ }
++ for (i = 0; i < PHY_MAX_ADDR; i++)
++ mii_bus->irq[i] = PHY_POLL;
++
++ bcma_mdio->core = core;
++ bcma_mdio->phyaddr = phyaddr;
++
++ err = mdiobus_register(mii_bus);
++ if (err) {
++ dev_err(&core->dev, "Registration of mii bus failed\n");
++ goto err_free_irq;
++ }
++
++ return mii_bus;
++
++err_free_irq:
++ kfree(mii_bus->irq);
++err_free_bus:
++ mdiobus_free(mii_bus);
++err:
++ kfree(bcma_mdio);
++ return ERR_PTR(err);
++}
++
++void bcma_mdio_mii_unregister(struct mii_bus *mii_bus)
++{
++ struct bcma_mdio *bcma_mdio;
++
++ if (!mii_bus)
++ return;
++
++ bcma_mdio = mii_bus->priv;
++
++ mdiobus_unregister(mii_bus);
++ kfree(mii_bus->irq);
++ mdiobus_free(mii_bus);
++ kfree(bcma_mdio);
++}
++
++MODULE_AUTHOR("Rafał Miłecki");
++MODULE_LICENSE("GPL");
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -759,150 +759,6 @@ error:
+ return err;
+ }
+
+-/**************************************************
+- * PHY ops
+- **************************************************/
+-
+-static u16 bgmac_phy_read(struct bgmac *bgmac, u8 phyaddr, u8 reg)
+-{
+- struct bcma_device *core;
+- u16 phy_access_addr;
+- u16 phy_ctl_addr;
+- u32 tmp;
+-
+- BUILD_BUG_ON(BGMAC_PA_DATA_MASK != BCMA_GMAC_CMN_PA_DATA_MASK);
+- BUILD_BUG_ON(BGMAC_PA_ADDR_MASK != BCMA_GMAC_CMN_PA_ADDR_MASK);
+- BUILD_BUG_ON(BGMAC_PA_ADDR_SHIFT != BCMA_GMAC_CMN_PA_ADDR_SHIFT);
+- BUILD_BUG_ON(BGMAC_PA_REG_MASK != BCMA_GMAC_CMN_PA_REG_MASK);
+- BUILD_BUG_ON(BGMAC_PA_REG_SHIFT != BCMA_GMAC_CMN_PA_REG_SHIFT);
+- BUILD_BUG_ON(BGMAC_PA_WRITE != BCMA_GMAC_CMN_PA_WRITE);
+- BUILD_BUG_ON(BGMAC_PA_START != BCMA_GMAC_CMN_PA_START);
+- BUILD_BUG_ON(BGMAC_PC_EPA_MASK != BCMA_GMAC_CMN_PC_EPA_MASK);
+- BUILD_BUG_ON(BGMAC_PC_MCT_MASK != BCMA_GMAC_CMN_PC_MCT_MASK);
+- BUILD_BUG_ON(BGMAC_PC_MCT_SHIFT != BCMA_GMAC_CMN_PC_MCT_SHIFT);
+- BUILD_BUG_ON(BGMAC_PC_MTE != BCMA_GMAC_CMN_PC_MTE);
+-
+- if (bgmac->core->id.id == BCMA_CORE_4706_MAC_GBIT) {
+- core = bgmac->core->bus->drv_gmac_cmn.core;
+- phy_access_addr = BCMA_GMAC_CMN_PHY_ACCESS;
+- phy_ctl_addr = BCMA_GMAC_CMN_PHY_CTL;
+- } else {
+- core = bgmac->core;
+- phy_access_addr = BGMAC_PHY_ACCESS;
+- phy_ctl_addr = BGMAC_PHY_CNTL;
+- }
+-
+- tmp = bcma_read32(core, phy_ctl_addr);
+- tmp &= ~BGMAC_PC_EPA_MASK;
+- tmp |= phyaddr;
+- bcma_write32(core, phy_ctl_addr, tmp);
+-
+- tmp = BGMAC_PA_START;
+- tmp |= phyaddr << BGMAC_PA_ADDR_SHIFT;
+- tmp |= reg << BGMAC_PA_REG_SHIFT;
+- bcma_write32(core, phy_access_addr, tmp);
+-
+- if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
+- dev_err(bgmac->dev, "Reading PHY %d register 0x%X failed\n",
+- phyaddr, reg);
+- return 0xffff;
+- }
+-
+- return bcma_read32(core, phy_access_addr) & BGMAC_PA_DATA_MASK;
+-}
+-
+-/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphywr */
+-static int bgmac_phy_write(struct bgmac *bgmac, u8 phyaddr, u8 reg, u16 value)
+-{
+- struct bcma_device *core;
+- u16 phy_access_addr;
+- u16 phy_ctl_addr;
+- u32 tmp;
+-
+- if (bgmac->core->id.id == BCMA_CORE_4706_MAC_GBIT) {
+- core = bgmac->core->bus->drv_gmac_cmn.core;
+- phy_access_addr = BCMA_GMAC_CMN_PHY_ACCESS;
+- phy_ctl_addr = BCMA_GMAC_CMN_PHY_CTL;
+- } else {
+- core = bgmac->core;
+- phy_access_addr = BGMAC_PHY_ACCESS;
+- phy_ctl_addr = BGMAC_PHY_CNTL;
+- }
+-
+- tmp = bcma_read32(core, phy_ctl_addr);
+- tmp &= ~BGMAC_PC_EPA_MASK;
+- tmp |= phyaddr;
+- bcma_write32(core, phy_ctl_addr, tmp);
+-
+- bgmac_write(bgmac, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
+- if (bgmac_read(bgmac, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
+- dev_warn(bgmac->dev, "Error setting MDIO int\n");
+-
+- tmp = BGMAC_PA_START;
+- tmp |= BGMAC_PA_WRITE;
+- tmp |= phyaddr << BGMAC_PA_ADDR_SHIFT;
+- tmp |= reg << BGMAC_PA_REG_SHIFT;
+- tmp |= value;
+- bcma_write32(core, phy_access_addr, tmp);
+-
+- if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
+- dev_err(bgmac->dev, "Writing to PHY %d register 0x%X failed\n",
+- phyaddr, reg);
+- return -ETIMEDOUT;
+- }
+-
+- return 0;
+-}
+-
+-/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphyinit */
+-static void bgmac_phy_init(struct bgmac *bgmac)
+-{
+- struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo;
+- struct bcma_drv_cc *cc = &bgmac->core->bus->drv_cc;
+- u8 i;
+-
+- if (ci->id == BCMA_CHIP_ID_BCM5356) {
+- for (i = 0; i < 5; i++) {
+- bgmac_phy_write(bgmac, i, 0x1f, 0x008b);
+- bgmac_phy_write(bgmac, i, 0x15, 0x0100);
+- bgmac_phy_write(bgmac, i, 0x1f, 0x000f);
+- bgmac_phy_write(bgmac, i, 0x12, 0x2aaa);
+- bgmac_phy_write(bgmac, i, 0x1f, 0x000b);
+- }
+- }
+- if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg != 10) ||
+- (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg != 10) ||
+- (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg != 9)) {
+- bcma_chipco_chipctl_maskset(cc, 2, ~0xc0000000, 0);
+- bcma_chipco_chipctl_maskset(cc, 4, ~0x80000000, 0);
+- for (i = 0; i < 5; i++) {
+- bgmac_phy_write(bgmac, i, 0x1f, 0x000f);
+- bgmac_phy_write(bgmac, i, 0x16, 0x5284);
+- bgmac_phy_write(bgmac, i, 0x1f, 0x000b);
+- bgmac_phy_write(bgmac, i, 0x17, 0x0010);
+- bgmac_phy_write(bgmac, i, 0x1f, 0x000f);
+- bgmac_phy_write(bgmac, i, 0x16, 0x5296);
+- bgmac_phy_write(bgmac, i, 0x17, 0x1073);
+- bgmac_phy_write(bgmac, i, 0x17, 0x9073);
+- bgmac_phy_write(bgmac, i, 0x16, 0x52b6);
+- bgmac_phy_write(bgmac, i, 0x17, 0x9273);
+- bgmac_phy_write(bgmac, i, 0x1f, 0x000b);
+- }
+- }
+-}
+-
+-/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphyreset */
+-static void bgmac_phy_reset(struct bgmac *bgmac)
+-{
+- if (bgmac->phyaddr == BGMAC_PHY_NOREGS)
+- return;
+-
+- bgmac_phy_write(bgmac, bgmac->phyaddr, MII_BMCR, BMCR_RESET);
+- udelay(100);
+- if (bgmac_phy_read(bgmac, bgmac->phyaddr, MII_BMCR) & BMCR_RESET)
+- dev_err(bgmac->dev, "PHY reset failed\n");
+- bgmac_phy_init(bgmac);
+-}
+
+ /**************************************************
+ * Chip ops
+@@ -1159,7 +1015,8 @@ static void bgmac_chip_reset(struct bgma
+ else
+ bgmac_set(bgmac, BGMAC_PHY_CNTL, BGMAC_PC_MTE);
+ bgmac_miiconfig(bgmac);
+- bgmac_phy_init(bgmac);
++ if (bgmac->mii_bus)
++ bgmac->mii_bus->reset(bgmac->mii_bus);
+
+ netdev_reset_queue(bgmac->net_dev);
+ }
+@@ -1553,17 +1410,6 @@ static const struct ethtool_ops bgmac_et
+ * MII
+ **************************************************/
+
+-static int bgmac_mii_read(struct mii_bus *bus, int mii_id, int regnum)
+-{
+- return bgmac_phy_read(bus->priv, mii_id, regnum);
+-}
+-
+-static int bgmac_mii_write(struct mii_bus *bus, int mii_id, int regnum,
+- u16 value)
+-{
+- return bgmac_phy_write(bus->priv, mii_id, regnum, value);
+-}
+-
+ static void bgmac_adjust_link(struct net_device *net_dev)
+ {
+ struct bgmac *bgmac = netdev_priv(net_dev);
+@@ -1588,7 +1434,7 @@ static void bgmac_adjust_link(struct net
+ }
+ }
+
+-static int bgmac_fixed_phy_register(struct bgmac *bgmac)
++static int bgmac_phy_connect_direct(struct bgmac *bgmac)
+ {
+ struct fixed_phy_status fphy_status = {
+ .link = 1,
+@@ -1614,81 +1460,24 @@ static int bgmac_fixed_phy_register(stru
+ return err;
+ }
+
+-static int bgmac_mii_register(struct bgmac *bgmac)
++static int bgmac_phy_connect(struct bgmac *bgmac)
+ {
+- struct mii_bus *mii_bus;
+ struct phy_device *phy_dev;
+ char bus_id[MII_BUS_ID_SIZE + 3];
+- int i, err = 0;
+-
+- if (bgmac_is_bcm4707_family(bgmac))
+- return bgmac_fixed_phy_register(bgmac);
+-
+- mii_bus = mdiobus_alloc();
+- if (!mii_bus)
+- return -ENOMEM;
+-
+- mii_bus->name = "bgmac mii bus";
+- sprintf(mii_bus->id, "%s-%d-%d", "bgmac", bgmac->core->bus->num,
+- bgmac->core->core_unit);
+- mii_bus->priv = bgmac;
+- mii_bus->read = bgmac_mii_read;
+- mii_bus->write = bgmac_mii_write;
+- mii_bus->parent = &bgmac->core->dev;
+- mii_bus->phy_mask = ~(1 << bgmac->phyaddr);
+-
+- mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
+- if (!mii_bus->irq) {
+- err = -ENOMEM;
+- goto err_free_bus;
+- }
+- for (i = 0; i < PHY_MAX_ADDR; i++)
+- mii_bus->irq[i] = PHY_POLL;
+-
+- err = mdiobus_register(mii_bus);
+- if (err) {
+- dev_err(bgmac->dev, "Registration of mii bus failed\n");
+- goto err_free_irq;
+- }
+-
+- bgmac->mii_bus = mii_bus;
+
+ /* Connect to the PHY */
+- snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, mii_bus->id,
++ snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, bgmac->mii_bus->id,
+ bgmac->phyaddr);
+ phy_dev = phy_connect(bgmac->net_dev, bus_id, &bgmac_adjust_link,
+ PHY_INTERFACE_MODE_MII);
+ if (IS_ERR(phy_dev)) {
+ dev_err(bgmac->dev, "PHY connecton failed\n");
+- err = PTR_ERR(phy_dev);
+- goto err_unregister_bus;
++ return PTR_ERR(phy_dev);
+ }
+
+- return err;
+-
+-err_unregister_bus:
+- mdiobus_unregister(mii_bus);
+-err_free_irq:
+- kfree(mii_bus->irq);
+-err_free_bus:
+- mdiobus_free(mii_bus);
+- return err;
+-}
+-
+-static void bgmac_mii_unregister(struct bgmac *bgmac)
+-{
+- struct mii_bus *mii_bus = bgmac->mii_bus;
+-
+- mdiobus_unregister(mii_bus);
+- kfree(mii_bus->irq);
+- mdiobus_free(mii_bus);
++ return 0;
+ }
+
+-/**************************************************
+- * BCMA bus ops
+- **************************************************/
+-
+-/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
+ static int bgmac_probe(struct bcma_device *core)
+ {
+ struct net_device *net_dev;
+@@ -1809,9 +1598,6 @@ static int bgmac_probe(struct bcma_devic
+ if (bcm47xx_nvram_getenv("et0_no_txint", NULL, 0) == 0)
+ bgmac->int_mask &= ~BGMAC_IS_TX_MASK;
+
+- /* TODO: reset the external phy. Specs are needed */
+- bgmac_phy_reset(bgmac);
+-
+ bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo &
+ BGMAC_BFL_ENETROBO);
+ if (bgmac->has_robosw)
+@@ -1822,10 +1608,25 @@ static int bgmac_probe(struct bcma_devic
+
+ netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
+
+- err = bgmac_mii_register(bgmac);
++ if (!bgmac_is_bcm4707_family(bgmac)) {
++ struct mii_bus *mii_bus;
++
++ mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
++ if (!IS_ERR(mii_bus)) {
++ err = PTR_ERR(mii_bus);
++ goto err_dma_free;
++ }
++
++ bgmac->mii_bus = mii_bus;
++ }
++
++ if (!bgmac->mii_bus)
++ err = bgmac_phy_connect_direct(bgmac);
++ else
++ err = bgmac_phy_connect(bgmac);
+ if (err) {
+ dev_err(bgmac->dev, "Cannot connect to phy\n");
+- goto err_dma_free;
++ goto err_mii_unregister;
+ }
+
+ net_dev->features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
+@@ -1835,18 +1636,19 @@ static int bgmac_probe(struct bcma_devic
+ err = register_netdev(bgmac->net_dev);
+ if (err) {
+ dev_err(bgmac->dev, "Cannot register net device\n");
+- goto err_mii_unregister;
++ goto err_phy_disconnect;
+ }
+
+ netif_carrier_off(net_dev);
+
+ return 0;
+
++err_phy_disconnect:
++ phy_disconnect(net_dev->phydev);
+ err_mii_unregister:
+- bgmac_mii_unregister(bgmac);
++ bcma_mdio_mii_unregister(bgmac->mii_bus);
+ err_dma_free:
+ bgmac_dma_free(bgmac);
+-
+ err_netdev_free:
+ bcma_set_drvdata(core, NULL);
+ free_netdev(net_dev);
+@@ -1859,7 +1661,8 @@ static void bgmac_remove(struct bcma_dev
+ struct bgmac *bgmac = bcma_get_drvdata(core);
+
+ unregister_netdev(bgmac->net_dev);
+- bgmac_mii_unregister(bgmac);
++ phy_disconnect(bgmac->net_dev->phydev);
++ bcma_mdio_mii_unregister(bgmac->mii_bus);
+ netif_napi_del(&bgmac->napi);
+ bgmac_dma_free(bgmac);
+ bcma_set_drvdata(core, NULL);
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -456,6 +456,9 @@ struct bgmac {
+ bool loopback;
+ };
+
++struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr);
++void bcma_mdio_mii_unregister(struct mii_bus *mii_bus);
++
+ static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset)
+ {
+ return bcma_read32(bgmac->core, offset);
--- /dev/null
+From db791eb2970bad193b1dc95a4461b222dd22cb64 Mon Sep 17 00:00:00 2001
+From: Jon Mason <jon.mason@broadcom.com>
+Date: Thu, 7 Jul 2016 19:08:56 -0400
+Subject: [PATCH 4/5] net: ethernet: bgmac: convert to feature flags
+
+The bgmac driver is using the bcma provides device ID and revision, as
+well as the SoC ID and package, to determine which features are
+necessary to enable, reset, etc in the driver. In anticipation of
+removing the bcma requirement for this driver, these must be changed to
+not reference that struct. In place of that, each "feature" has been
+given a flag, and the flags are enabled for their respective device and
+SoC.
+
+Signed-off-by: Jon Mason <jon.mason@broadcom.com>
+Acked-by: Arnd Bergmann <arnd@arndb.de>
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Tested-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 167 ++++++++++++++++++++++++----------
+ drivers/net/ethernet/broadcom/bgmac.h | 21 ++++-
+ 2 files changed, 140 insertions(+), 48 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -109,7 +109,7 @@ static void bgmac_dma_tx_enable(struct b
+ u32 ctl;
+
+ ctl = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_TX_CTL);
+- if (bgmac->core->id.rev >= 4) {
++ if (bgmac->feature_flags & BGMAC_FEAT_TX_MASK_SETUP) {
+ ctl &= ~BGMAC_DMA_TX_BL_MASK;
+ ctl |= BGMAC_DMA_TX_BL_128 << BGMAC_DMA_TX_BL_SHIFT;
+
+@@ -335,7 +335,7 @@ static void bgmac_dma_rx_enable(struct b
+ /* preserve ONLY bits 16-17 from current hardware value */
+ ctl &= BGMAC_DMA_RX_ADDREXT_MASK;
+
+- if (bgmac->core->id.rev >= 4) {
++ if (bgmac->feature_flags & BGMAC_FEAT_RX_MASK_SETUP) {
+ ctl &= ~BGMAC_DMA_RX_BL_MASK;
+ ctl |= BGMAC_DMA_RX_BL_128 << BGMAC_DMA_RX_BL_SHIFT;
+
+@@ -772,14 +772,20 @@ static void bgmac_cmdcfg_maskset(struct
+ {
+ u32 cmdcfg = bgmac_read(bgmac, BGMAC_CMDCFG);
+ u32 new_val = (cmdcfg & mask) | set;
++ u32 cmdcfg_sr;
+
+- bgmac_set(bgmac, BGMAC_CMDCFG, BGMAC_CMDCFG_SR(bgmac->core->id.rev));
++ if (bgmac->feature_flags & BGMAC_FEAT_CMDCFG_SR_REV4)
++ cmdcfg_sr = BGMAC_CMDCFG_SR_REV4;
++ else
++ cmdcfg_sr = BGMAC_CMDCFG_SR_REV0;
++
++ bgmac_set(bgmac, BGMAC_CMDCFG, cmdcfg_sr);
+ udelay(2);
+
+ if (new_val != cmdcfg || force)
+ bgmac_write(bgmac, BGMAC_CMDCFG, new_val);
+
+- bgmac_mask(bgmac, BGMAC_CMDCFG, ~BGMAC_CMDCFG_SR(bgmac->core->id.rev));
++ bgmac_mask(bgmac, BGMAC_CMDCFG, ~cmdcfg_sr);
+ udelay(2);
+ }
+
+@@ -808,7 +814,7 @@ static void bgmac_chip_stats_update(stru
+ {
+ int i;
+
+- if (bgmac->core->id.id != BCMA_CORE_4706_MAC_GBIT) {
++ if (!(bgmac->feature_flags & BGMAC_FEAT_NO_CLR_MIB)) {
+ for (i = 0; i < BGMAC_NUM_MIB_TX_REGS; i++)
+ bgmac->mib_tx_regs[i] =
+ bgmac_read(bgmac,
+@@ -827,7 +833,7 @@ static void bgmac_clear_mib(struct bgmac
+ {
+ int i;
+
+- if (bgmac->core->id.id == BCMA_CORE_4706_MAC_GBIT)
++ if (bgmac->feature_flags & BGMAC_FEAT_NO_CLR_MIB)
+ return;
+
+ bgmac_set(bgmac, BGMAC_DEV_CTL, BGMAC_DC_MROR);
+@@ -870,9 +876,8 @@ static void bgmac_mac_speed(struct bgmac
+ static void bgmac_miiconfig(struct bgmac *bgmac)
+ {
+ struct bcma_device *core = bgmac->core;
+- u8 imode;
+
+- if (bgmac_is_bcm4707_family(bgmac)) {
++ if (bgmac->feature_flags & BGMAC_FEAT_FORCE_SPEED_2500) {
+ bcma_awrite32(core, BCMA_IOCTL,
+ bcma_aread32(core, BCMA_IOCTL) | 0x40 |
+ BGMAC_BCMA_IOCTL_SW_CLKEN);
+@@ -880,6 +885,8 @@ static void bgmac_miiconfig(struct bgmac
+ bgmac->mac_duplex = DUPLEX_FULL;
+ bgmac_mac_speed(bgmac);
+ } else {
++ u8 imode;
++
+ imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) &
+ BGMAC_DS_MM_MASK) >> BGMAC_DS_MM_SHIFT;
+ if (imode == 0 || imode == 1) {
+@@ -894,9 +901,7 @@ static void bgmac_miiconfig(struct bgmac
+ static void bgmac_chip_reset(struct bgmac *bgmac)
+ {
+ struct bcma_device *core = bgmac->core;
+- struct bcma_bus *bus = core->bus;
+- struct bcma_chipinfo *ci = &bus->chipinfo;
+- u32 flags;
++ u32 cmdcfg_sr;
+ u32 iost;
+ int i;
+
+@@ -919,15 +924,12 @@ static void bgmac_chip_reset(struct bgma
+ }
+
+ iost = bcma_aread32(core, BCMA_IOST);
+- if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM47186) ||
+- (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg == 10) ||
+- (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == BCMA_PKG_ID_BCM47188))
++ if (bgmac->feature_flags & BGMAC_FEAT_IOST_ATTACHED)
+ iost &= ~BGMAC_BCMA_IOST_ATTACHED;
+
+ /* 3GMAC: for BCM4707 & BCM47094, only do core reset at bgmac_probe() */
+- if (ci->id != BCMA_CHIP_ID_BCM4707 &&
+- ci->id != BCMA_CHIP_ID_BCM47094) {
+- flags = 0;
++ if (!(bgmac->feature_flags & BGMAC_FEAT_NO_RESET)) {
++ u32 flags = 0;
+ if (iost & BGMAC_BCMA_IOST_ATTACHED) {
+ flags = BGMAC_BCMA_IOCTL_SW_CLKEN;
+ if (!bgmac->has_robosw)
+@@ -937,7 +939,7 @@ static void bgmac_chip_reset(struct bgma
+ }
+
+ /* Request Misc PLL for corerev > 2 */
+- if (core->id.rev > 2 && !bgmac_is_bcm4707_family(bgmac)) {
++ if (bgmac->feature_flags & BGMAC_FEAT_MISC_PLL_REQ) {
+ bgmac_set(bgmac, BCMA_CLKCTLST,
+ BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ);
+ bgmac_wait_value(bgmac->core, BCMA_CLKCTLST,
+@@ -946,9 +948,7 @@ static void bgmac_chip_reset(struct bgma
+ 1000);
+ }
+
+- if (ci->id == BCMA_CHIP_ID_BCM5357 ||
+- ci->id == BCMA_CHIP_ID_BCM4749 ||
+- ci->id == BCMA_CHIP_ID_BCM53572) {
++ if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_PHY) {
+ struct bcma_drv_cc *cc = &bgmac->core->bus->drv_cc;
+ u8 et_swtype = 0;
+ u8 sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHY |
+@@ -962,11 +962,9 @@ static void bgmac_chip_reset(struct bgma
+ et_swtype &= 0x0f;
+ et_swtype <<= 4;
+ sw_type = et_swtype;
+- } else if (ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM5358) {
++ } else if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_EPHYRMII) {
+ sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHYRMII;
+- } else if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM47186) ||
+- (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg == 10) ||
+- (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == BCMA_PKG_ID_BCM47188)) {
++ } else if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_RGMII) {
+ sw_type = BGMAC_CHIPCTL_1_IF_TYPE_RGMII |
+ BGMAC_CHIPCTL_1_SW_TYPE_RGMII;
+ }
+@@ -986,6 +984,11 @@ static void bgmac_chip_reset(struct bgma
+ * BGMAC_CMDCFG is read _after_ putting chip in a reset. So it has to
+ * be keps until taking MAC out of the reset.
+ */
++ if (bgmac->feature_flags & BGMAC_FEAT_CMDCFG_SR_REV4)
++ cmdcfg_sr = BGMAC_CMDCFG_SR_REV4;
++ else
++ cmdcfg_sr = BGMAC_CMDCFG_SR_REV0;
++
+ bgmac_cmdcfg_maskset(bgmac,
+ ~(BGMAC_CMDCFG_TE |
+ BGMAC_CMDCFG_RE |
+@@ -1003,13 +1006,13 @@ static void bgmac_chip_reset(struct bgma
+ BGMAC_CMDCFG_PROM |
+ BGMAC_CMDCFG_NLC |
+ BGMAC_CMDCFG_CFE |
+- BGMAC_CMDCFG_SR(core->id.rev),
++ cmdcfg_sr,
+ false);
+ bgmac->mac_speed = SPEED_UNKNOWN;
+ bgmac->mac_duplex = DUPLEX_UNKNOWN;
+
+ bgmac_clear_mib(bgmac);
+- if (core->id.id == BCMA_CORE_4706_MAC_GBIT)
++ if (bgmac->feature_flags & BGMAC_FEAT_CMN_PHY_CTL)
+ bcma_maskset32(bgmac->cmn, BCMA_GMAC_CMN_PHY_CTL, ~0,
+ BCMA_GMAC_CMN_PC_MTE);
+ else
+@@ -1035,46 +1038,48 @@ static void bgmac_chip_intrs_off(struct
+ /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/gmac_enable */
+ static void bgmac_enable(struct bgmac *bgmac)
+ {
+- struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo;
++ u32 cmdcfg_sr;
+ u32 cmdcfg;
+ u32 mode;
+- u32 rxq_ctl;
+- u32 fl_ctl;
+- u16 bp_clk;
+- u8 mdp;
++
++ if (bgmac->feature_flags & BGMAC_FEAT_CMDCFG_SR_REV4)
++ cmdcfg_sr = BGMAC_CMDCFG_SR_REV4;
++ else
++ cmdcfg_sr = BGMAC_CMDCFG_SR_REV0;
+
+ cmdcfg = bgmac_read(bgmac, BGMAC_CMDCFG);
+ bgmac_cmdcfg_maskset(bgmac, ~(BGMAC_CMDCFG_TE | BGMAC_CMDCFG_RE),
+- BGMAC_CMDCFG_SR(bgmac->core->id.rev), true);
++ cmdcfg_sr, true);
+ udelay(2);
+ cmdcfg |= BGMAC_CMDCFG_TE | BGMAC_CMDCFG_RE;
+ bgmac_write(bgmac, BGMAC_CMDCFG, cmdcfg);
+
+ mode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
+ BGMAC_DS_MM_SHIFT;
+- if (ci->id != BCMA_CHIP_ID_BCM47162 || mode != 0)
++ if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST || mode != 0)
+ bgmac_set(bgmac, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
+- if (ci->id == BCMA_CHIP_ID_BCM47162 && mode == 2)
++ if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST && mode == 2)
+ bcma_chipco_chipctl_maskset(&bgmac->core->bus->drv_cc, 1, ~0,
+ BGMAC_CHIPCTL_1_RXC_DLL_BYPASS);
+
+- switch (ci->id) {
+- case BCMA_CHIP_ID_BCM5357:
+- case BCMA_CHIP_ID_BCM4749:
+- case BCMA_CHIP_ID_BCM53572:
+- case BCMA_CHIP_ID_BCM4716:
+- case BCMA_CHIP_ID_BCM47162:
+- fl_ctl = 0x03cb04cb;
+- if (ci->id == BCMA_CHIP_ID_BCM5357 ||
+- ci->id == BCMA_CHIP_ID_BCM4749 ||
+- ci->id == BCMA_CHIP_ID_BCM53572)
++ if (bgmac->feature_flags & (BGMAC_FEAT_FLW_CTRL1 |
++ BGMAC_FEAT_FLW_CTRL2)) {
++ u32 fl_ctl;
++
++ if (bgmac->feature_flags & BGMAC_FEAT_FLW_CTRL1)
+ fl_ctl = 0x2300e1;
++ else
++ fl_ctl = 0x03cb04cb;
++
+ bgmac_write(bgmac, BGMAC_FLOW_CTL_THRESH, fl_ctl);
+ bgmac_write(bgmac, BGMAC_PAUSE_CTL, 0x27fff);
+- break;
+ }
+
+- if (!bgmac_is_bcm4707_family(bgmac)) {
++ if (bgmac->feature_flags & BGMAC_FEAT_SET_RXQ_CLK) {
++ u32 rxq_ctl;
++ u16 bp_clk;
++ u8 mdp;
++
+ rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
+ rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
+ bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) /
+@@ -1606,6 +1611,74 @@ static int bgmac_probe(struct bcma_devic
+ if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
+ dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
+
++ /* Feature Flags */
++ switch (core->bus->chipinfo.id) {
++ case BCMA_CHIP_ID_BCM5357:
++ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
++ if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47186) {
++ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
++ }
++ if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM5358)
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_EPHYRMII;
++ break;
++ case BCMA_CHIP_ID_BCM53572:
++ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
++ if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47188) {
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
++ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
++ }
++ break;
++ case BCMA_CHIP_ID_BCM4749:
++ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
++ if (core->bus->chipinfo.pkg == 10) {
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
++ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
++ }
++ break;
++ case BCMA_CHIP_ID_BCM4716:
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ /* fallthrough */
++ case BCMA_CHIP_ID_BCM47162:
++ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL2;
++ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
++ break;
++ /* bcm4707_family */
++ case BCMA_CHIP_ID_BCM4707:
++ case BCMA_CHIP_ID_BCM47094:
++ case BCMA_CHIP_ID_BCM53018:
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
++ bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
++ break;
++ default:
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
++ }
++
++ if (!bgmac_is_bcm4707_family(bgmac) && core->id.rev > 2)
++ bgmac->feature_flags |= BGMAC_FEAT_MISC_PLL_REQ;
++
++ if (core->id.id == BCMA_CORE_4706_MAC_GBIT) {
++ bgmac->feature_flags |= BGMAC_FEAT_CMN_PHY_CTL;
++ bgmac->feature_flags |= BGMAC_FEAT_NO_CLR_MIB;
++ }
++
++ if (core->id.rev >= 4) {
++ bgmac->feature_flags |= BGMAC_FEAT_CMDCFG_SR_REV4;
++ bgmac->feature_flags |= BGMAC_FEAT_TX_MASK_SETUP;
++ bgmac->feature_flags |= BGMAC_FEAT_RX_MASK_SETUP;
++ }
++
+ netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
+
+ if (!bgmac_is_bcm4707_family(bgmac)) {
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -190,7 +190,6 @@
+ #define BGMAC_CMDCFG_HD_SHIFT 10
+ #define BGMAC_CMDCFG_SR_REV0 0x00000800 /* Set to reset mode, for core rev 0-3 */
+ #define BGMAC_CMDCFG_SR_REV4 0x00002000 /* Set to reset mode, for core rev >= 4 */
+-#define BGMAC_CMDCFG_SR(rev) ((rev >= 4) ? BGMAC_CMDCFG_SR_REV4 : BGMAC_CMDCFG_SR_REV0)
+ #define BGMAC_CMDCFG_ML 0x00008000 /* Set to activate mac loopback mode */
+ #define BGMAC_CMDCFG_AE 0x00400000
+ #define BGMAC_CMDCFG_CFE 0x00800000
+@@ -376,6 +375,24 @@
+
+ #define ETHER_MAX_LEN 1518
+
++/* Feature Flags */
++#define BGMAC_FEAT_TX_MASK_SETUP BIT(0)
++#define BGMAC_FEAT_RX_MASK_SETUP BIT(1)
++#define BGMAC_FEAT_IOST_ATTACHED BIT(2)
++#define BGMAC_FEAT_NO_RESET BIT(3)
++#define BGMAC_FEAT_MISC_PLL_REQ BIT(4)
++#define BGMAC_FEAT_SW_TYPE_PHY BIT(5)
++#define BGMAC_FEAT_SW_TYPE_EPHYRMII BIT(6)
++#define BGMAC_FEAT_SW_TYPE_RGMII BIT(7)
++#define BGMAC_FEAT_CMN_PHY_CTL BIT(8)
++#define BGMAC_FEAT_FLW_CTRL1 BIT(9)
++#define BGMAC_FEAT_FLW_CTRL2 BIT(10)
++#define BGMAC_FEAT_SET_RXQ_CLK BIT(11)
++#define BGMAC_FEAT_CLKCTLST BIT(12)
++#define BGMAC_FEAT_NO_CLR_MIB BIT(13)
++#define BGMAC_FEAT_FORCE_SPEED_2500 BIT(14)
++#define BGMAC_FEAT_CMDCFG_SR_REV4 BIT(15)
++
+ struct bgmac_slot_info {
+ union {
+ struct sk_buff *skb;
+@@ -430,6 +447,8 @@ struct bgmac {
+
+ struct device *dev;
+ struct device *dma_dev;
++ u32 feature_flags;
++
+ struct net_device *net_dev;
+ struct napi_struct napi;
+ struct mii_bus *mii_bus;
--- /dev/null
+From f6a95a24957aec5bb488c3f978c4ed508177998f Mon Sep 17 00:00:00 2001
+From: Jon Mason <jon.mason@broadcom.com>
+Date: Thu, 7 Jul 2016 19:08:57 -0400
+Subject: [PATCH 5/5] net: ethernet: bgmac: Add platform device support
+
+The bcma portion of the driver has been split off into a bcma specific
+driver. This has been mirrored for the platform driver. The last
+references to the bcma core struct have been changed into a generic
+function call. These function calls are wrappers to either the original
+bcma code or new platform functions that access the same areas via MMIO.
+This necessitated adding function pointers for both platform and bcma to
+hide which backend is being used from the generic bgmac code.
+
+Signed-off-by: Jon Mason <jon.mason@broadcom.com>
+Acked-by: Arnd Bergmann <arnd@arndb.de>
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Tested-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/Kconfig | 23 +-
+ drivers/net/ethernet/broadcom/Makefile | 4 +-
+ drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c | 2 +
+ drivers/net/ethernet/broadcom/bgmac-bcma.c | 315 +++++++++++++++++++++++
+ drivers/net/ethernet/broadcom/bgmac-platform.c | 189 ++++++++++++++
+ drivers/net/ethernet/broadcom/bgmac.c | 329 ++++--------------------
+ drivers/net/ethernet/broadcom/bgmac.h | 73 +++++-
+ 7 files changed, 650 insertions(+), 285 deletions(-)
+ create mode 100644 drivers/net/ethernet/broadcom/bgmac-bcma.c
+ create mode 100644 drivers/net/ethernet/broadcom/bgmac-platform.c
+
+--- a/drivers/net/ethernet/broadcom/Kconfig
++++ b/drivers/net/ethernet/broadcom/Kconfig
+@@ -150,10 +150,18 @@ config BNX2X_VXLAN
+ Virtual eXtensible Local Area Network (VXLAN) in the driver.
+
+ config BGMAC
+- tristate "BCMA bus GBit core support"
++ tristate
++ help
++ This enables the integrated ethernet controller support for many
++ Broadcom (mostly iProc) SoCs. An appropriate bus interface driver
++ needs to be enabled to select this.
++
++config BGMAC_BCMA
++ tristate "Broadcom iProc GBit BCMA support"
+ depends on BCMA && BCMA_HOST_SOC
+ depends on HAS_DMA
+ depends on BCM47XX || ARCH_BCM_5301X || COMPILE_TEST
++ select BGMAC
+ select PHYLIB
+ select FIXED_PHY
+ ---help---
+@@ -162,6 +170,19 @@ config BGMAC
+ In case of using this driver on BCM4706 it's also requires to enable
+ BCMA_DRIVER_GMAC_CMN to make it work.
+
++config BGMAC_PLATFORM
++ tristate "Broadcom iProc GBit platform support"
++ depends on HAS_DMA
++ depends on ARCH_BCM_IPROC || COMPILE_TEST
++ depends on OF
++ select BGMAC
++ select PHYLIB
++ select FIXED_PHY
++ default ARCH_BCM_IPROC
++ ---help---
++ Say Y here if you want to use the Broadcom iProc Gigabit Ethernet
++ controller through the generic platform interface
++
+ config SYSTEMPORT
+ tristate "Broadcom SYSTEMPORT internal MAC support"
+ depends on OF
+--- a/drivers/net/ethernet/broadcom/Makefile
++++ b/drivers/net/ethernet/broadcom/Makefile
+@@ -10,6 +10,8 @@ obj-$(CONFIG_CNIC) += cnic.o
+ obj-$(CONFIG_BNX2X) += bnx2x/
+ obj-$(CONFIG_SB1250_MAC) += sb1250-mac.o
+ obj-$(CONFIG_TIGON3) += tg3.o
+-obj-$(CONFIG_BGMAC) += bgmac.o bgmac-bcma-mdio.o
++obj-$(CONFIG_BGMAC) += bgmac.o
++obj-$(CONFIG_BGMAC_BCMA) += bgmac-bcma.o bgmac-bcma-mdio.o
++obj-$(CONFIG_BGMAC_PLATFORM) += bgmac-platform.o
+ obj-$(CONFIG_SYSTEMPORT) += bcmsysport.o
+ obj-$(CONFIG_BNXT) += bnxt/
+--- a/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
++++ b/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
+@@ -255,6 +255,7 @@ err:
+ kfree(bcma_mdio);
+ return ERR_PTR(err);
+ }
++EXPORT_SYMBOL_GPL(bcma_mdio_mii_register);
+
+ void bcma_mdio_mii_unregister(struct mii_bus *mii_bus)
+ {
+@@ -270,6 +271,7 @@ void bcma_mdio_mii_unregister(struct mii
+ mdiobus_free(mii_bus);
+ kfree(bcma_mdio);
+ }
++EXPORT_SYMBOL_GPL(bcma_mdio_mii_unregister);
+
+ MODULE_AUTHOR("Rafał Miłecki");
+ MODULE_LICENSE("GPL");
+--- /dev/null
++++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
+@@ -0,0 +1,315 @@
++/*
++ * Driver for (BCM4706)? GBit MAC core on BCMA bus.
++ *
++ * Copyright (C) 2012 Rafał Miłecki <zajec5@gmail.com>
++ *
++ * Licensed under the GNU/GPL. See COPYING for details.
++ */
++
++#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
++
++#include <linux/bcma/bcma.h>
++#include <linux/brcmphy.h>
++#include <linux/etherdevice.h>
++#include "bgmac.h"
++
++static inline bool bgmac_is_bcm4707_family(struct bcma_device *core)
++{
++ switch (core->bus->chipinfo.id) {
++ case BCMA_CHIP_ID_BCM4707:
++ case BCMA_CHIP_ID_BCM47094:
++ case BCMA_CHIP_ID_BCM53018:
++ return true;
++ default:
++ return false;
++ }
++}
++
++/**************************************************
++ * BCMA bus ops
++ **************************************************/
++
++static u32 bcma_bgmac_read(struct bgmac *bgmac, u16 offset)
++{
++ return bcma_read32(bgmac->bcma.core, offset);
++}
++
++static void bcma_bgmac_write(struct bgmac *bgmac, u16 offset, u32 value)
++{
++ bcma_write32(bgmac->bcma.core, offset, value);
++}
++
++static u32 bcma_bgmac_idm_read(struct bgmac *bgmac, u16 offset)
++{
++ return bcma_aread32(bgmac->bcma.core, offset);
++}
++
++static void bcma_bgmac_idm_write(struct bgmac *bgmac, u16 offset, u32 value)
++{
++ return bcma_awrite32(bgmac->bcma.core, offset, value);
++}
++
++static bool bcma_bgmac_clk_enabled(struct bgmac *bgmac)
++{
++ return bcma_core_is_enabled(bgmac->bcma.core);
++}
++
++static void bcma_bgmac_clk_enable(struct bgmac *bgmac, u32 flags)
++{
++ bcma_core_enable(bgmac->bcma.core, flags);
++}
++
++static void bcma_bgmac_cco_ctl_maskset(struct bgmac *bgmac, u32 offset,
++ u32 mask, u32 set)
++{
++ struct bcma_drv_cc *cc = &bgmac->bcma.core->bus->drv_cc;
++
++ bcma_chipco_chipctl_maskset(cc, offset, mask, set);
++}
++
++static u32 bcma_bgmac_get_bus_clock(struct bgmac *bgmac)
++{
++ struct bcma_drv_cc *cc = &bgmac->bcma.core->bus->drv_cc;
++
++ return bcma_pmu_get_bus_clock(cc);
++}
++
++static void bcma_bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset, u32 mask,
++ u32 set)
++{
++ bcma_maskset32(bgmac->bcma.cmn, offset, mask, set);
++}
++
++static const struct bcma_device_id bgmac_bcma_tbl[] = {
++ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_4706_MAC_GBIT,
++ BCMA_ANY_REV, BCMA_ANY_CLASS),
++ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_MAC_GBIT, BCMA_ANY_REV,
++ BCMA_ANY_CLASS),
++ {},
++};
++MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl);
++
++/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
++static int bgmac_probe(struct bcma_device *core)
++{
++ struct ssb_sprom *sprom = &core->bus->sprom;
++ struct mii_bus *mii_bus;
++ struct bgmac *bgmac;
++ u8 *mac;
++ int err;
++
++ bgmac = kzalloc(sizeof(*bgmac), GFP_KERNEL);
++ if (!bgmac)
++ return -ENOMEM;
++
++ bgmac->bcma.core = core;
++ bgmac->dev = &core->dev;
++ bgmac->dma_dev = core->dma_dev;
++ bgmac->irq = core->irq;
++
++ bcma_set_drvdata(core, bgmac);
++
++ switch (core->core_unit) {
++ case 0:
++ mac = sprom->et0mac;
++ break;
++ case 1:
++ mac = sprom->et1mac;
++ break;
++ case 2:
++ mac = sprom->et2mac;
++ break;
++ default:
++ dev_err(bgmac->dev, "Unsupported core_unit %d\n",
++ core->core_unit);
++ err = -ENOTSUPP;
++ goto err;
++ }
++
++ ether_addr_copy(bgmac->mac_addr, mac);
++
++ /* On BCM4706 we need common core to access PHY */
++ if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
++ !core->bus->drv_gmac_cmn.core) {
++ dev_err(bgmac->dev, "GMAC CMN core not found (required for BCM4706)\n");
++ err = -ENODEV;
++ goto err;
++ }
++ bgmac->bcma.cmn = core->bus->drv_gmac_cmn.core;
++
++ switch (core->core_unit) {
++ case 0:
++ bgmac->phyaddr = sprom->et0phyaddr;
++ break;
++ case 1:
++ bgmac->phyaddr = sprom->et1phyaddr;
++ break;
++ case 2:
++ bgmac->phyaddr = sprom->et2phyaddr;
++ break;
++ }
++ bgmac->phyaddr &= BGMAC_PHY_MASK;
++ if (bgmac->phyaddr == BGMAC_PHY_MASK) {
++ dev_err(bgmac->dev, "No PHY found\n");
++ err = -ENODEV;
++ goto err;
++ }
++ dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
++ bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
++
++ if (!bgmac_is_bcm4707_family(core)) {
++ mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
++ if (!IS_ERR(mii_bus)) {
++ err = PTR_ERR(mii_bus);
++ goto err;
++ }
++
++ bgmac->mii_bus = mii_bus;
++ }
++
++ if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) {
++ dev_err(bgmac->dev, "PCI setup not implemented\n");
++ err = -ENOTSUPP;
++ goto err1;
++ }
++
++ bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo &
++ BGMAC_BFL_ENETROBO);
++ if (bgmac->has_robosw)
++ dev_warn(bgmac->dev, "Support for Roboswitch not implemented\n");
++
++ if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
++ dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
++
++ /* Feature Flags */
++ switch (core->bus->chipinfo.id) {
++ case BCMA_CHIP_ID_BCM5357:
++ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
++ if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47186) {
++ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
++ }
++ if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM5358)
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_EPHYRMII;
++ break;
++ case BCMA_CHIP_ID_BCM53572:
++ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
++ if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47188) {
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
++ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
++ }
++ break;
++ case BCMA_CHIP_ID_BCM4749:
++ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
++ if (core->bus->chipinfo.pkg == 10) {
++ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
++ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
++ }
++ break;
++ case BCMA_CHIP_ID_BCM4716:
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ /* fallthrough */
++ case BCMA_CHIP_ID_BCM47162:
++ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL2;
++ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
++ break;
++ /* bcm4707_family */
++ case BCMA_CHIP_ID_BCM4707:
++ case BCMA_CHIP_ID_BCM47094:
++ case BCMA_CHIP_ID_BCM53018:
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
++ bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
++ break;
++ default:
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
++ }
++
++ if (!bgmac_is_bcm4707_family(core) && core->id.rev > 2)
++ bgmac->feature_flags |= BGMAC_FEAT_MISC_PLL_REQ;
++
++ if (core->id.id == BCMA_CORE_4706_MAC_GBIT) {
++ bgmac->feature_flags |= BGMAC_FEAT_CMN_PHY_CTL;
++ bgmac->feature_flags |= BGMAC_FEAT_NO_CLR_MIB;
++ }
++
++ if (core->id.rev >= 4) {
++ bgmac->feature_flags |= BGMAC_FEAT_CMDCFG_SR_REV4;
++ bgmac->feature_flags |= BGMAC_FEAT_TX_MASK_SETUP;
++ bgmac->feature_flags |= BGMAC_FEAT_RX_MASK_SETUP;
++ }
++
++ bgmac->read = bcma_bgmac_read;
++ bgmac->write = bcma_bgmac_write;
++ bgmac->idm_read = bcma_bgmac_idm_read;
++ bgmac->idm_write = bcma_bgmac_idm_write;
++ bgmac->clk_enabled = bcma_bgmac_clk_enabled;
++ bgmac->clk_enable = bcma_bgmac_clk_enable;
++ bgmac->cco_ctl_maskset = bcma_bgmac_cco_ctl_maskset;
++ bgmac->get_bus_clock = bcma_bgmac_get_bus_clock;
++ bgmac->cmn_maskset32 = bcma_bgmac_cmn_maskset32;
++
++ err = bgmac_enet_probe(bgmac);
++ if (err)
++ goto err1;
++
++ return 0;
++
++err1:
++ bcma_mdio_mii_unregister(bgmac->mii_bus);
++err:
++ kfree(bgmac);
++ bcma_set_drvdata(core, NULL);
++
++ return err;
++}
++
++static void bgmac_remove(struct bcma_device *core)
++{
++ struct bgmac *bgmac = bcma_get_drvdata(core);
++
++ bcma_mdio_mii_unregister(bgmac->mii_bus);
++ bgmac_enet_remove(bgmac);
++ bcma_set_drvdata(core, NULL);
++ kfree(bgmac);
++}
++
++static struct bcma_driver bgmac_bcma_driver = {
++ .name = KBUILD_MODNAME,
++ .id_table = bgmac_bcma_tbl,
++ .probe = bgmac_probe,
++ .remove = bgmac_remove,
++};
++
++static int __init bgmac_init(void)
++{
++ int err;
++
++ err = bcma_driver_register(&bgmac_bcma_driver);
++ if (err)
++ return err;
++ pr_info("Broadcom 47xx GBit MAC driver loaded\n");
++
++ return 0;
++}
++
++static void __exit bgmac_exit(void)
++{
++ bcma_driver_unregister(&bgmac_bcma_driver);
++}
++
++module_init(bgmac_init)
++module_exit(bgmac_exit)
++
++MODULE_AUTHOR("Rafał Miłecki");
++MODULE_LICENSE("GPL");
+--- /dev/null
++++ b/drivers/net/ethernet/broadcom/bgmac-platform.c
+@@ -0,0 +1,189 @@
++/*
++ * Copyright (C) 2016 Broadcom
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation version 2.
++ *
++ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
++ * kind, whether express or implied; without even the implied warranty
++ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ */
++
++#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
++
++#include <linux/bcma/bcma.h>
++#include <linux/etherdevice.h>
++#include <linux/of_address.h>
++#include <linux/of_net.h>
++#include "bgmac.h"
++
++static u32 platform_bgmac_read(struct bgmac *bgmac, u16 offset)
++{
++ return readl(bgmac->plat.base + offset);
++}
++
++static void platform_bgmac_write(struct bgmac *bgmac, u16 offset, u32 value)
++{
++ writel(value, bgmac->plat.base + offset);
++}
++
++static u32 platform_bgmac_idm_read(struct bgmac *bgmac, u16 offset)
++{
++ return readl(bgmac->plat.idm_base + offset);
++}
++
++static void platform_bgmac_idm_write(struct bgmac *bgmac, u16 offset, u32 value)
++{
++ return writel(value, bgmac->plat.idm_base + offset);
++}
++
++static bool platform_bgmac_clk_enabled(struct bgmac *bgmac)
++{
++ if ((bgmac_idm_read(bgmac, BCMA_IOCTL) &
++ (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC)) != BCMA_IOCTL_CLK)
++ return false;
++ if (bgmac_idm_read(bgmac, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
++ return false;
++ return true;
++}
++
++static void platform_bgmac_clk_enable(struct bgmac *bgmac, u32 flags)
++{
++ bgmac_idm_write(bgmac, BCMA_IOCTL,
++ (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC | flags));
++ bgmac_idm_read(bgmac, BCMA_IOCTL);
++
++ bgmac_idm_write(bgmac, BCMA_RESET_CTL, 0);
++ bgmac_idm_read(bgmac, BCMA_RESET_CTL);
++ udelay(1);
++
++ bgmac_idm_write(bgmac, BCMA_IOCTL, (BCMA_IOCTL_CLK | flags));
++ bgmac_idm_read(bgmac, BCMA_IOCTL);
++ udelay(1);
++}
++
++static void platform_bgmac_cco_ctl_maskset(struct bgmac *bgmac, u32 offset,
++ u32 mask, u32 set)
++{
++ /* This shouldn't be encountered */
++ WARN_ON(1);
++}
++
++static u32 platform_bgmac_get_bus_clock(struct bgmac *bgmac)
++{
++ /* This shouldn't be encountered */
++ WARN_ON(1);
++
++ return 0;
++}
++
++static void platform_bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset,
++ u32 mask, u32 set)
++{
++ /* This shouldn't be encountered */
++ WARN_ON(1);
++}
++
++static int bgmac_probe(struct platform_device *pdev)
++{
++ struct device_node *np = pdev->dev.of_node;
++ struct bgmac *bgmac;
++ struct resource *regs;
++ const u8 *mac_addr;
++
++ bgmac = devm_kzalloc(&pdev->dev, sizeof(*bgmac), GFP_KERNEL);
++ if (!bgmac)
++ return -ENOMEM;
++
++ platform_set_drvdata(pdev, bgmac);
++
++ /* Set the features of the 4707 family */
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
++ bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
++ bgmac->feature_flags |= BGMAC_FEAT_CMDCFG_SR_REV4;
++ bgmac->feature_flags |= BGMAC_FEAT_TX_MASK_SETUP;
++ bgmac->feature_flags |= BGMAC_FEAT_RX_MASK_SETUP;
++
++ bgmac->dev = &pdev->dev;
++ bgmac->dma_dev = &pdev->dev;
++
++ mac_addr = of_get_mac_address(np);
++ if (mac_addr)
++ ether_addr_copy(bgmac->mac_addr, mac_addr);
++ else
++ dev_warn(&pdev->dev, "MAC address not present in device tree\n");
++
++ bgmac->irq = platform_get_irq(pdev, 0);
++ if (bgmac->irq < 0) {
++ dev_err(&pdev->dev, "Unable to obtain IRQ\n");
++ return bgmac->irq;
++ }
++
++ regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "amac_base");
++ if (!regs) {
++ dev_err(&pdev->dev, "Unable to obtain base resource\n");
++ return -EINVAL;
++ }
++
++ bgmac->plat.base = devm_ioremap_resource(&pdev->dev, regs);
++ if (IS_ERR(bgmac->plat.base)) {
++ dev_err(&pdev->dev, "Unable to map base resource\n");
++ return PTR_ERR(bgmac->plat.base);
++ }
++
++ regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "idm_base");
++ if (!regs) {
++ dev_err(&pdev->dev, "Unable to obtain idm resource\n");
++ return -EINVAL;
++ }
++
++ bgmac->plat.idm_base = devm_ioremap_resource(&pdev->dev, regs);
++ if (!bgmac->plat.idm_base) {
++ dev_err(&pdev->dev, "Unable to map idm resource\n");
++ return PTR_ERR(bgmac->plat.idm_base);
++ }
++
++ bgmac->read = platform_bgmac_read;
++ bgmac->write = platform_bgmac_write;
++ bgmac->idm_read = platform_bgmac_idm_read;
++ bgmac->idm_write = platform_bgmac_idm_write;
++ bgmac->clk_enabled = platform_bgmac_clk_enabled;
++ bgmac->clk_enable = platform_bgmac_clk_enable;
++ bgmac->cco_ctl_maskset = platform_bgmac_cco_ctl_maskset;
++ bgmac->get_bus_clock = platform_bgmac_get_bus_clock;
++ bgmac->cmn_maskset32 = platform_bgmac_cmn_maskset32;
++
++ return bgmac_enet_probe(bgmac);
++}
++
++static int bgmac_remove(struct platform_device *pdev)
++{
++ struct bgmac *bgmac = platform_get_drvdata(pdev);
++
++ bgmac_enet_remove(bgmac);
++
++ return 0;
++}
++
++static const struct of_device_id bgmac_of_enet_match[] = {
++ {.compatible = "brcm,amac",},
++ {.compatible = "brcm,nsp-amac",},
++ {},
++};
++
++MODULE_DEVICE_TABLE(of, bgmac_of_enet_match);
++
++static struct platform_driver bgmac_enet_driver = {
++ .driver = {
++ .name = "bgmac-enet",
++ .of_match_table = bgmac_of_enet_match,
++ },
++ .probe = bgmac_probe,
++ .remove = bgmac_remove,
++};
++
++module_platform_driver(bgmac_enet_driver);
++MODULE_LICENSE("GPL");
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -6,51 +6,27 @@
+ * Licensed under the GNU/GPL. See COPYING for details.
+ */
+
+-#include "bgmac.h"
+
+-#include <linux/kernel.h>
+-#include <linux/module.h>
+-#include <linux/delay.h>
++#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
++
++#include <linux/bcma/bcma.h>
+ #include <linux/etherdevice.h>
+-#include <linux/mii.h>
+-#include <linux/phy.h>
+-#include <linux/phy_fixed.h>
+-#include <linux/interrupt.h>
+-#include <linux/dma-mapping.h>
+ #include <linux/bcm47xx_nvram.h>
++#include "bgmac.h"
+
+-static const struct bcma_device_id bgmac_bcma_tbl[] = {
+- BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_4706_MAC_GBIT, BCMA_ANY_REV, BCMA_ANY_CLASS),
+- BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_MAC_GBIT, BCMA_ANY_REV, BCMA_ANY_CLASS),
+- {},
+-};
+-MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl);
+-
+-static inline bool bgmac_is_bcm4707_family(struct bgmac *bgmac)
+-{
+- switch (bgmac->core->bus->chipinfo.id) {
+- case BCMA_CHIP_ID_BCM4707:
+- case BCMA_CHIP_ID_BCM47094:
+- case BCMA_CHIP_ID_BCM53018:
+- return true;
+- default:
+- return false;
+- }
+-}
+-
+-static bool bgmac_wait_value(struct bcma_device *core, u16 reg, u32 mask,
++static bool bgmac_wait_value(struct bgmac *bgmac, u16 reg, u32 mask,
+ u32 value, int timeout)
+ {
+ u32 val;
+ int i;
+
+ for (i = 0; i < timeout / 10; i++) {
+- val = bcma_read32(core, reg);
++ val = bgmac_read(bgmac, reg);
+ if ((val & mask) == value)
+ return true;
+ udelay(10);
+ }
+- dev_err(&core->dev, "Timeout waiting for reg 0x%X\n", reg);
++ dev_err(bgmac->dev, "Timeout waiting for reg 0x%X\n", reg);
+ return false;
+ }
+
+@@ -89,7 +65,7 @@ static void bgmac_dma_tx_reset(struct bg
+
+ /* Remove SUSPEND bit */
+ bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_CTL, 0);
+- if (!bgmac_wait_value(bgmac->core,
++ if (!bgmac_wait_value(bgmac,
+ ring->mmio_base + BGMAC_DMA_TX_STATUS,
+ BGMAC_DMA_TX_STAT, BGMAC_DMA_TX_STAT_DISABLED,
+ 10000)) {
+@@ -317,7 +293,7 @@ static void bgmac_dma_rx_reset(struct bg
+ return;
+
+ bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_CTL, 0);
+- if (!bgmac_wait_value(bgmac->core,
++ if (!bgmac_wait_value(bgmac,
+ ring->mmio_base + BGMAC_DMA_RX_STATUS,
+ BGMAC_DMA_RX_STAT, BGMAC_DMA_RX_STAT_DISABLED,
+ 10000))
+@@ -643,7 +619,7 @@ static int bgmac_dma_alloc(struct bgmac
+ BUILD_BUG_ON(BGMAC_MAX_TX_RINGS > ARRAY_SIZE(ring_base));
+ BUILD_BUG_ON(BGMAC_MAX_RX_RINGS > ARRAY_SIZE(ring_base));
+
+- if (!(bcma_aread32(bgmac->core, BCMA_IOST) & BCMA_IOST_DMA64)) {
++ if (!(bgmac_idm_read(bgmac, BCMA_IOST) & BCMA_IOST_DMA64)) {
+ dev_err(bgmac->dev, "Core does not report 64-bit DMA\n");
+ return -ENOTSUPP;
+ }
+@@ -875,12 +851,10 @@ static void bgmac_mac_speed(struct bgmac
+
+ static void bgmac_miiconfig(struct bgmac *bgmac)
+ {
+- struct bcma_device *core = bgmac->core;
+-
+ if (bgmac->feature_flags & BGMAC_FEAT_FORCE_SPEED_2500) {
+- bcma_awrite32(core, BCMA_IOCTL,
+- bcma_aread32(core, BCMA_IOCTL) | 0x40 |
+- BGMAC_BCMA_IOCTL_SW_CLKEN);
++ bgmac_idm_write(bgmac, BCMA_IOCTL,
++ bgmac_idm_read(bgmac, BCMA_IOCTL) | 0x40 |
++ BGMAC_BCMA_IOCTL_SW_CLKEN);
+ bgmac->mac_speed = SPEED_2500;
+ bgmac->mac_duplex = DUPLEX_FULL;
+ bgmac_mac_speed(bgmac);
+@@ -900,12 +874,11 @@ static void bgmac_miiconfig(struct bgmac
+ /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipreset */
+ static void bgmac_chip_reset(struct bgmac *bgmac)
+ {
+- struct bcma_device *core = bgmac->core;
+ u32 cmdcfg_sr;
+ u32 iost;
+ int i;
+
+- if (bcma_core_is_enabled(core)) {
++ if (bgmac_clk_enabled(bgmac)) {
+ if (!bgmac->stats_grabbed) {
+ /* bgmac_chip_stats_update(bgmac); */
+ bgmac->stats_grabbed = true;
+@@ -923,7 +896,7 @@ static void bgmac_chip_reset(struct bgma
+ /* TODO: Clear software multicast filter list */
+ }
+
+- iost = bcma_aread32(core, BCMA_IOST);
++ iost = bgmac_idm_read(bgmac, BCMA_IOST);
+ if (bgmac->feature_flags & BGMAC_FEAT_IOST_ATTACHED)
+ iost &= ~BGMAC_BCMA_IOST_ATTACHED;
+
+@@ -935,21 +908,20 @@ static void bgmac_chip_reset(struct bgma
+ if (!bgmac->has_robosw)
+ flags |= BGMAC_BCMA_IOCTL_SW_RESET;
+ }
+- bcma_core_enable(core, flags);
++ bgmac_clk_enable(bgmac, flags);
+ }
+
+ /* Request Misc PLL for corerev > 2 */
+ if (bgmac->feature_flags & BGMAC_FEAT_MISC_PLL_REQ) {
+ bgmac_set(bgmac, BCMA_CLKCTLST,
+ BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ);
+- bgmac_wait_value(bgmac->core, BCMA_CLKCTLST,
++ bgmac_wait_value(bgmac, BCMA_CLKCTLST,
+ BGMAC_BCMA_CLKCTLST_MISC_PLL_ST,
+ BGMAC_BCMA_CLKCTLST_MISC_PLL_ST,
+ 1000);
+ }
+
+ if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_PHY) {
+- struct bcma_drv_cc *cc = &bgmac->core->bus->drv_cc;
+ u8 et_swtype = 0;
+ u8 sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHY |
+ BGMAC_CHIPCTL_1_IF_TYPE_MII;
+@@ -968,16 +940,15 @@ static void bgmac_chip_reset(struct bgma
+ sw_type = BGMAC_CHIPCTL_1_IF_TYPE_RGMII |
+ BGMAC_CHIPCTL_1_SW_TYPE_RGMII;
+ }
+- bcma_chipco_chipctl_maskset(cc, 1,
+- ~(BGMAC_CHIPCTL_1_IF_TYPE_MASK |
+- BGMAC_CHIPCTL_1_SW_TYPE_MASK),
+- sw_type);
++ bgmac_cco_ctl_maskset(bgmac, 1, ~(BGMAC_CHIPCTL_1_IF_TYPE_MASK |
++ BGMAC_CHIPCTL_1_SW_TYPE_MASK),
++ sw_type);
+ }
+
+ if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw)
+- bcma_awrite32(core, BCMA_IOCTL,
+- bcma_aread32(core, BCMA_IOCTL) &
+- ~BGMAC_BCMA_IOCTL_SW_RESET);
++ bgmac_idm_write(bgmac, BCMA_IOCTL,
++ bgmac_idm_read(bgmac, BCMA_IOCTL) &
++ ~BGMAC_BCMA_IOCTL_SW_RESET);
+
+ /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/gmac_reset
+ * Specs don't say about using BGMAC_CMDCFG_SR, but in this routine
+@@ -1013,8 +984,8 @@ static void bgmac_chip_reset(struct bgma
+
+ bgmac_clear_mib(bgmac);
+ if (bgmac->feature_flags & BGMAC_FEAT_CMN_PHY_CTL)
+- bcma_maskset32(bgmac->cmn, BCMA_GMAC_CMN_PHY_CTL, ~0,
+- BCMA_GMAC_CMN_PC_MTE);
++ bgmac_cmn_maskset32(bgmac, BCMA_GMAC_CMN_PHY_CTL, ~0,
++ BCMA_GMAC_CMN_PC_MTE);
+ else
+ bgmac_set(bgmac, BGMAC_PHY_CNTL, BGMAC_PC_MTE);
+ bgmac_miiconfig(bgmac);
+@@ -1059,8 +1030,8 @@ static void bgmac_enable(struct bgmac *b
+ if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST || mode != 0)
+ bgmac_set(bgmac, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
+ if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST && mode == 2)
+- bcma_chipco_chipctl_maskset(&bgmac->core->bus->drv_cc, 1, ~0,
+- BGMAC_CHIPCTL_1_RXC_DLL_BYPASS);
++ bgmac_cco_ctl_maskset(bgmac, 1, ~0,
++ BGMAC_CHIPCTL_1_RXC_DLL_BYPASS);
+
+ if (bgmac->feature_flags & (BGMAC_FEAT_FLW_CTRL1 |
+ BGMAC_FEAT_FLW_CTRL2)) {
+@@ -1082,8 +1053,7 @@ static void bgmac_enable(struct bgmac *b
+
+ rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
+ rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
+- bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) /
+- 1000000;
++ bp_clk = bgmac_get_bus_clock(bgmac) / 1000000;
+ mdp = (bp_clk * 128 / 1000) - 3;
+ rxq_ctl |= (mdp << BGMAC_RXQ_CTL_MDP_SHIFT);
+ bgmac_write(bgmac, BGMAC_RXQ_CTL, rxq_ctl);
+@@ -1178,7 +1148,7 @@ static int bgmac_open(struct net_device
+ /* Specs say about reclaiming rings here, but we do that in DMA init */
+ bgmac_chip_init(bgmac);
+
+- err = request_irq(bgmac->core->irq, bgmac_interrupt, IRQF_SHARED,
++ err = request_irq(bgmac->irq, bgmac_interrupt, IRQF_SHARED,
+ KBUILD_MODNAME, net_dev);
+ if (err < 0) {
+ dev_err(bgmac->dev, "IRQ request error: %d!\n", err);
+@@ -1204,7 +1174,7 @@ static int bgmac_stop(struct net_device
+
+ napi_disable(&bgmac->napi);
+ bgmac_chip_intrs_off(bgmac);
+- free_irq(bgmac->core->irq, net_dev);
++ free_irq(bgmac->irq, net_dev);
+
+ bgmac_chip_reset(bgmac);
+ bgmac_dma_cleanup(bgmac);
+@@ -1399,7 +1369,7 @@ static void bgmac_get_drvinfo(struct net
+ struct ethtool_drvinfo *info)
+ {
+ strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
+- strlcpy(info->bus_info, "BCMA", sizeof(info->bus_info));
++ strlcpy(info->bus_info, "AXI", sizeof(info->bus_info));
+ }
+
+ static const struct ethtool_ops bgmac_ethtool_ops = {
+@@ -1483,116 +1453,41 @@ static int bgmac_phy_connect(struct bgma
+ return 0;
+ }
+
+-static int bgmac_probe(struct bcma_device *core)
++int bgmac_enet_probe(struct bgmac *info)
+ {
+ struct net_device *net_dev;
+ struct bgmac *bgmac;
+- struct ssb_sprom *sprom = &core->bus->sprom;
+- u8 *mac;
+ int err;
+
+- switch (core->core_unit) {
+- case 0:
+- mac = sprom->et0mac;
+- break;
+- case 1:
+- mac = sprom->et1mac;
+- break;
+- case 2:
+- mac = sprom->et2mac;
+- break;
+- default:
+- dev_err(&core->dev, "Unsupported core_unit %d\n",
+- core->core_unit);
+- return -ENOTSUPP;
+- }
+-
+- if (!is_valid_ether_addr(mac)) {
+- dev_err(&core->dev, "Invalid MAC addr: %pM\n", mac);
+- eth_random_addr(mac);
+- dev_warn(&core->dev, "Using random MAC: %pM\n", mac);
+- }
+-
+- /* This (reset &) enable is not preset in specs or reference driver but
+- * Broadcom does it in arch PCI code when enabling fake PCI device.
+- */
+- bcma_core_enable(core, 0);
+-
+ /* Allocation and references */
+ net_dev = alloc_etherdev(sizeof(*bgmac));
+ if (!net_dev)
+ return -ENOMEM;
++
+ net_dev->netdev_ops = &bgmac_netdev_ops;
+- net_dev->irq = core->irq;
+ net_dev->ethtool_ops = &bgmac_ethtool_ops;
+ bgmac = netdev_priv(net_dev);
+- bgmac->dev = &core->dev;
+- bgmac->dma_dev = core->dma_dev;
++ memcpy(bgmac, info, sizeof(*bgmac));
+ bgmac->net_dev = net_dev;
+- bgmac->core = core;
+- bcma_set_drvdata(core, bgmac);
+- SET_NETDEV_DEV(net_dev, &core->dev);
+-
+- /* Defaults */
+- memcpy(bgmac->net_dev->dev_addr, mac, ETH_ALEN);
+-
+- /* On BCM4706 we need common core to access PHY */
+- if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
+- !core->bus->drv_gmac_cmn.core) {
+- dev_err(bgmac->dev, "GMAC CMN core not found (required for BCM4706)\n");
+- err = -ENODEV;
+- goto err_netdev_free;
+- }
+- bgmac->cmn = core->bus->drv_gmac_cmn.core;
++ net_dev->irq = bgmac->irq;
++ SET_NETDEV_DEV(net_dev, bgmac->dev);
+
+- switch (core->core_unit) {
+- case 0:
+- bgmac->phyaddr = sprom->et0phyaddr;
+- break;
+- case 1:
+- bgmac->phyaddr = sprom->et1phyaddr;
+- break;
+- case 2:
+- bgmac->phyaddr = sprom->et2phyaddr;
+- break;
++ if (!is_valid_ether_addr(bgmac->mac_addr)) {
++ dev_err(bgmac->dev, "Invalid MAC addr: %pM\n",
++ bgmac->mac_addr);
++ eth_random_addr(bgmac->mac_addr);
++ dev_warn(bgmac->dev, "Using random MAC: %pM\n",
++ bgmac->mac_addr);
+ }
+- bgmac->phyaddr &= BGMAC_PHY_MASK;
+- if (bgmac->phyaddr == BGMAC_PHY_MASK) {
+- dev_err(bgmac->dev, "No PHY found\n");
+- err = -ENODEV;
+- goto err_netdev_free;
+- }
+- dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
+- bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
++ ether_addr_copy(net_dev->dev_addr, bgmac->mac_addr);
+
+- if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) {
+- dev_err(bgmac->dev, "PCI setup not implemented\n");
+- err = -ENOTSUPP;
+- goto err_netdev_free;
+- }
++ /* This (reset &) enable is not preset in specs or reference driver but
++ * Broadcom does it in arch PCI code when enabling fake PCI device.
++ */
++ bgmac_clk_enable(bgmac, 0);
+
+ bgmac_chip_reset(bgmac);
+
+- /* For Northstar, we have to take all GMAC core out of reset */
+- if (bgmac_is_bcm4707_family(bgmac)) {
+- struct bcma_device *ns_core;
+- int ns_gmac;
+-
+- /* Northstar has 4 GMAC cores */
+- for (ns_gmac = 0; ns_gmac < 4; ns_gmac++) {
+- /* As Northstar requirement, we have to reset all GMACs
+- * before accessing one. bgmac_chip_reset() call
+- * bcma_core_enable() for this core. Then the other
+- * three GMACs didn't reset. We do it here.
+- */
+- ns_core = bcma_find_core_unit(core->bus,
+- BCMA_CORE_MAC_GBIT,
+- ns_gmac);
+- if (ns_core && !bcma_core_is_enabled(ns_core))
+- bcma_core_enable(ns_core, 0);
+- }
+- }
+-
+ err = bgmac_dma_alloc(bgmac);
+ if (err) {
+ dev_err(bgmac->dev, "Unable to alloc memory for DMA\n");
+@@ -1603,103 +1498,15 @@ static int bgmac_probe(struct bcma_devic
+ if (bcm47xx_nvram_getenv("et0_no_txint", NULL, 0) == 0)
+ bgmac->int_mask &= ~BGMAC_IS_TX_MASK;
+
+- bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo &
+- BGMAC_BFL_ENETROBO);
+- if (bgmac->has_robosw)
+- dev_warn(bgmac->dev, "Support for Roboswitch not implemented\n");
+-
+- if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
+- dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
+-
+- /* Feature Flags */
+- switch (core->bus->chipinfo.id) {
+- case BCMA_CHIP_ID_BCM5357:
+- bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
+- bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+- bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
+- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
+- if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47186) {
+- bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
+- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
+- }
+- if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM5358)
+- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_EPHYRMII;
+- break;
+- case BCMA_CHIP_ID_BCM53572:
+- bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
+- bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+- bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
+- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
+- if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47188) {
+- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
+- bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
+- }
+- break;
+- case BCMA_CHIP_ID_BCM4749:
+- bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
+- bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+- bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
+- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
+- if (core->bus->chipinfo.pkg == 10) {
+- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
+- bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
+- }
+- break;
+- case BCMA_CHIP_ID_BCM4716:
+- bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+- /* fallthrough */
+- case BCMA_CHIP_ID_BCM47162:
+- bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL2;
+- bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
+- break;
+- /* bcm4707_family */
+- case BCMA_CHIP_ID_BCM4707:
+- case BCMA_CHIP_ID_BCM47094:
+- case BCMA_CHIP_ID_BCM53018:
+- bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+- bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
+- bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
+- break;
+- default:
+- bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+- bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
+- }
+-
+- if (!bgmac_is_bcm4707_family(bgmac) && core->id.rev > 2)
+- bgmac->feature_flags |= BGMAC_FEAT_MISC_PLL_REQ;
+-
+- if (core->id.id == BCMA_CORE_4706_MAC_GBIT) {
+- bgmac->feature_flags |= BGMAC_FEAT_CMN_PHY_CTL;
+- bgmac->feature_flags |= BGMAC_FEAT_NO_CLR_MIB;
+- }
+-
+- if (core->id.rev >= 4) {
+- bgmac->feature_flags |= BGMAC_FEAT_CMDCFG_SR_REV4;
+- bgmac->feature_flags |= BGMAC_FEAT_TX_MASK_SETUP;
+- bgmac->feature_flags |= BGMAC_FEAT_RX_MASK_SETUP;
+- }
+-
+ netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
+
+- if (!bgmac_is_bcm4707_family(bgmac)) {
+- struct mii_bus *mii_bus;
+-
+- mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
+- if (!IS_ERR(mii_bus)) {
+- err = PTR_ERR(mii_bus);
+- goto err_dma_free;
+- }
+-
+- bgmac->mii_bus = mii_bus;
+- }
+-
+ if (!bgmac->mii_bus)
+ err = bgmac_phy_connect_direct(bgmac);
+ else
+ err = bgmac_phy_connect(bgmac);
+ if (err) {
+ dev_err(bgmac->dev, "Cannot connect to phy\n");
+- goto err_mii_unregister;
++ goto err_dma_free;
+ }
+
+ net_dev->features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
+@@ -1718,56 +1525,24 @@ static int bgmac_probe(struct bcma_devic
+
+ err_phy_disconnect:
+ phy_disconnect(net_dev->phydev);
+-err_mii_unregister:
+- bcma_mdio_mii_unregister(bgmac->mii_bus);
+ err_dma_free:
+ bgmac_dma_free(bgmac);
+ err_netdev_free:
+- bcma_set_drvdata(core, NULL);
+ free_netdev(net_dev);
+
+ return err;
+ }
++EXPORT_SYMBOL_GPL(bgmac_enet_probe);
+
+-static void bgmac_remove(struct bcma_device *core)
++void bgmac_enet_remove(struct bgmac *bgmac)
+ {
+- struct bgmac *bgmac = bcma_get_drvdata(core);
+-
+ unregister_netdev(bgmac->net_dev);
+ phy_disconnect(bgmac->net_dev->phydev);
+- bcma_mdio_mii_unregister(bgmac->mii_bus);
+ netif_napi_del(&bgmac->napi);
+ bgmac_dma_free(bgmac);
+- bcma_set_drvdata(core, NULL);
+ free_netdev(bgmac->net_dev);
+ }
+-
+-static struct bcma_driver bgmac_bcma_driver = {
+- .name = KBUILD_MODNAME,
+- .id_table = bgmac_bcma_tbl,
+- .probe = bgmac_probe,
+- .remove = bgmac_remove,
+-};
+-
+-static int __init bgmac_init(void)
+-{
+- int err;
+-
+- err = bcma_driver_register(&bgmac_bcma_driver);
+- if (err)
+- return err;
+- pr_info("Broadcom 47xx GBit MAC driver loaded\n");
+-
+- return 0;
+-}
+-
+-static void __exit bgmac_exit(void)
+-{
+- bcma_driver_unregister(&bgmac_bcma_driver);
+-}
+-
+-module_init(bgmac_init)
+-module_exit(bgmac_exit)
++EXPORT_SYMBOL_GPL(bgmac_enet_remove);
+
+ MODULE_AUTHOR("Rafał Miłecki");
+ MODULE_LICENSE("GPL");
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -1,8 +1,6 @@
+ #ifndef _BGMAC_H
+ #define _BGMAC_H
+
+-#include <linux/bcma/bcma.h>
+-#include <linux/brcmphy.h>
+ #include <linux/netdevice.h>
+
+ #define BGMAC_DEV_CTL 0x000
+@@ -442,11 +440,21 @@ struct bgmac_rx_header {
+ };
+
+ struct bgmac {
+- struct bcma_device *core;
+- struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
++ union {
++ struct {
++ void *base;
++ void *idm_base;
++ } plat;
++ struct {
++ struct bcma_device *core;
++ /* Reference to CMN core for BCM4706 */
++ struct bcma_device *cmn;
++ } bcma;
++ };
+
+ struct device *dev;
+ struct device *dma_dev;
++ unsigned char mac_addr[ETH_ALEN];
+ u32 feature_flags;
+
+ struct net_device *net_dev;
+@@ -463,6 +471,7 @@ struct bgmac {
+ u32 mib_rx_regs[BGMAC_NUM_MIB_RX_REGS];
+
+ /* Int */
++ int irq;
+ u32 int_mask;
+
+ /* Current MAC state */
+@@ -473,19 +482,71 @@ struct bgmac {
+ bool has_robosw;
+
+ bool loopback;
++
++ u32 (*read)(struct bgmac *bgmac, u16 offset);
++ void (*write)(struct bgmac *bgmac, u16 offset, u32 value);
++ u32 (*idm_read)(struct bgmac *bgmac, u16 offset);
++ void (*idm_write)(struct bgmac *bgmac, u16 offset, u32 value);
++ bool (*clk_enabled)(struct bgmac *bgmac);
++ void (*clk_enable)(struct bgmac *bgmac, u32 flags);
++ void (*cco_ctl_maskset)(struct bgmac *bgmac, u32 offset, u32 mask,
++ u32 set);
++ u32 (*get_bus_clock)(struct bgmac *bgmac);
++ void (*cmn_maskset32)(struct bgmac *bgmac, u16 offset, u32 mask,
++ u32 set);
+ };
+
++int bgmac_enet_probe(struct bgmac *info);
++void bgmac_enet_remove(struct bgmac *bgmac);
++
+ struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr);
+ void bcma_mdio_mii_unregister(struct mii_bus *mii_bus);
+
+ static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset)
+ {
+- return bcma_read32(bgmac->core, offset);
++ return bgmac->read(bgmac, offset);
+ }
+
+ static inline void bgmac_write(struct bgmac *bgmac, u16 offset, u32 value)
+ {
+- bcma_write32(bgmac->core, offset, value);
++ bgmac->write(bgmac, offset, value);
++}
++
++static inline u32 bgmac_idm_read(struct bgmac *bgmac, u16 offset)
++{
++ return bgmac->idm_read(bgmac, offset);
++}
++
++static inline void bgmac_idm_write(struct bgmac *bgmac, u16 offset, u32 value)
++{
++ bgmac->idm_write(bgmac, offset, value);
++}
++
++static inline bool bgmac_clk_enabled(struct bgmac *bgmac)
++{
++ return bgmac->clk_enabled(bgmac);
++}
++
++static inline void bgmac_clk_enable(struct bgmac *bgmac, u32 flags)
++{
++ bgmac->clk_enable(bgmac, flags);
++}
++
++static inline void bgmac_cco_ctl_maskset(struct bgmac *bgmac, u32 offset,
++ u32 mask, u32 set)
++{
++ bgmac->cco_ctl_maskset(bgmac, offset, mask, set);
++}
++
++static inline u32 bgmac_get_bus_clock(struct bgmac *bgmac)
++{
++ return bgmac->get_bus_clock(bgmac);
++}
++
++static inline void bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset,
++ u32 mask, u32 set)
++{
++ bgmac->cmn_maskset32(bgmac, offset, mask, set);
+ }
+
+ static inline void bgmac_maskset(struct bgmac *bgmac, u16 offset, u32 mask,
--- /dev/null
+From 12c2e32f14da857b58af281b029d4549d24c3292 Mon Sep 17 00:00:00 2001
+From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
+Date: Tue, 12 Jul 2016 00:17:28 +0000
+Subject: [PATCH] net: ethernet: bgmac: Fix return value check in bgmac_probe()
+
+In case of error, the function devm_ioremap_resource() returns ERR_PTR()
+and never returns NULL. The NULL test in the return value check should be
+replaced with IS_ERR().
+
+Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac-platform.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac-platform.c
++++ b/drivers/net/ethernet/broadcom/bgmac-platform.c
+@@ -141,7 +141,7 @@ static int bgmac_probe(struct platform_d
+ }
+
+ bgmac->plat.idm_base = devm_ioremap_resource(&pdev->dev, regs);
+- if (!bgmac->plat.idm_base) {
++ if (IS_ERR(bgmac->plat.idm_base)) {
+ dev_err(&pdev->dev, "Unable to map idm resource\n");
+ return PTR_ERR(bgmac->plat.idm_base);
+ }
--- /dev/null
+From ce3a380dddd0cb16cb3d8d947b69657d7646c121 Mon Sep 17 00:00:00 2001
+From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
+Date: Wed, 13 Jul 2016 12:46:57 +0000
+Subject: [PATCH] net: ethernet: bgmac: Remove redundant dev_err call in
+ bgmac_probe()
+
+There is a error message within devm_ioremap_resource
+already, so remove the dev_err call to avoid redundant
+error message.
+
+Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac-platform.c | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac-platform.c
++++ b/drivers/net/ethernet/broadcom/bgmac-platform.c
+@@ -129,10 +129,8 @@ static int bgmac_probe(struct platform_d
+ }
+
+ bgmac->plat.base = devm_ioremap_resource(&pdev->dev, regs);
+- if (IS_ERR(bgmac->plat.base)) {
+- dev_err(&pdev->dev, "Unable to map base resource\n");
++ if (IS_ERR(bgmac->plat.base))
+ return PTR_ERR(bgmac->plat.base);
+- }
+
+ regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "idm_base");
+ if (!regs) {
+@@ -141,10 +139,8 @@ static int bgmac_probe(struct platform_d
+ }
+
+ bgmac->plat.idm_base = devm_ioremap_resource(&pdev->dev, regs);
+- if (IS_ERR(bgmac->plat.idm_base)) {
+- dev_err(&pdev->dev, "Unable to map idm resource\n");
++ if (IS_ERR(bgmac->plat.idm_base))
+ return PTR_ERR(bgmac->plat.idm_base);
+- }
+
+ bgmac->read = platform_bgmac_read;
+ bgmac->write = platform_bgmac_write;
--- /dev/null
+From b9f63ae7ba2de2ba19137c5757c0607ce40f3ed5 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Wed, 17 Aug 2016 15:37:14 +0200
+Subject: [PATCH] net: bgmac: fix reversed check for MII registration error
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+It was failing on successful registration returning meaningless errors.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Fixes: 55954f3bfdac ("net: ethernet: bgmac: move BCMA MDIO Phy code into a separate file")
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac-bcma.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
++++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
+@@ -159,7 +159,7 @@ static int bgmac_probe(struct bcma_devic
+
+ if (!bgmac_is_bcm4707_family(core)) {
+ mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
+- if (!IS_ERR(mii_bus)) {
++ if (IS_ERR(mii_bus)) {
+ err = PTR_ERR(mii_bus);
+ goto err;
+ }
--- /dev/null
+From 1cb94db3d1bfe0075bde78fb2989f17e0a8a3936 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Wed, 17 Aug 2016 23:00:30 +0200
+Subject: [PATCH] net: bgmac: support Ethernet core on BCM53573 SoCs
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+BCM53573 is a new series of Broadcom's SoCs. It's based on ARM and can
+be found in two packages (versions): BCM53573 and BCM47189. It shares
+some code with the Northstar family, but also requires some new quirks.
+
+First of all there can be up to 2 Ethernet cores on this SoC. If that is
+the case, they are connected to two different switch ports allowing some
+more complex/optimized setups. It seems the second unit doesn't come
+fully configured and requires some IRQ quirk.
+
+Other than that only the first core is connected to the PHY. For the
+second one we have to register fixed PHY (similarly to the Northstar),
+otherwise generic PHY driver would get some invalid info.
+
+This has been successfully tested on Tenda AC9 (BCM47189B0).
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac-bcma.c | 19 ++++++++++++++++++-
+ drivers/net/ethernet/broadcom/bgmac.c | 25 +++++++++++++++++++++++++
+ drivers/net/ethernet/broadcom/bgmac.h | 19 +++++++++++++++++++
+ include/linux/bcma/bcma.h | 3 +++
+ include/linux/bcma/bcma_regs.h | 1 +
+ 5 files changed, 66 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
++++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
+@@ -92,6 +92,7 @@ MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl
+ /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
+ static int bgmac_probe(struct bcma_device *core)
+ {
++ struct bcma_chipinfo *ci = &core->bus->chipinfo;
+ struct ssb_sprom *sprom = &core->bus->sprom;
+ struct mii_bus *mii_bus;
+ struct bgmac *bgmac;
+@@ -157,7 +158,8 @@ static int bgmac_probe(struct bcma_devic
+ dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
+ bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
+
+- if (!bgmac_is_bcm4707_family(core)) {
++ if (!bgmac_is_bcm4707_family(core) &&
++ !(ci->id == BCMA_CHIP_ID_BCM53573 && core->core_unit == 1)) {
+ mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
+ if (IS_ERR(mii_bus)) {
+ err = PTR_ERR(mii_bus);
+@@ -230,6 +232,21 @@ static int bgmac_probe(struct bcma_devic
+ bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
+ bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
+ break;
++ case BCMA_CHIP_ID_BCM53573:
++ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
++ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
++ if (ci->pkg == BCMA_PKG_ID_BCM47189)
++ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
++ if (core->core_unit == 0) {
++ bgmac->feature_flags |= BGMAC_FEAT_CC4_IF_SW_TYPE;
++ if (ci->pkg == BCMA_PKG_ID_BCM47189)
++ bgmac->feature_flags |=
++ BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII;
++ } else if (core->core_unit == 1) {
++ bgmac->feature_flags |= BGMAC_FEAT_IRQ_ID_OOB_6;
++ bgmac->feature_flags |= BGMAC_FEAT_CC7_IF_TYPE_RGMII;
++ }
++ break;
+ default:
+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
+ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -943,6 +943,27 @@ static void bgmac_chip_reset(struct bgma
+ bgmac_cco_ctl_maskset(bgmac, 1, ~(BGMAC_CHIPCTL_1_IF_TYPE_MASK |
+ BGMAC_CHIPCTL_1_SW_TYPE_MASK),
+ sw_type);
++ } else if (bgmac->feature_flags & BGMAC_FEAT_CC4_IF_SW_TYPE) {
++ u32 sw_type = BGMAC_CHIPCTL_4_IF_TYPE_MII |
++ BGMAC_CHIPCTL_4_SW_TYPE_EPHY;
++ u8 et_swtype = 0;
++ char buf[4];
++
++ if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
++ if (kstrtou8(buf, 0, &et_swtype))
++ dev_err(bgmac->dev, "Failed to parse et_swtype (%s)\n",
++ buf);
++ sw_type = (et_swtype & 0x0f) << 12;
++ } else if (bgmac->feature_flags & BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII) {
++ sw_type = BGMAC_CHIPCTL_4_IF_TYPE_RGMII |
++ BGMAC_CHIPCTL_4_SW_TYPE_RGMII;
++ }
++ bgmac_cco_ctl_maskset(bgmac, 4, ~(BGMAC_CHIPCTL_4_IF_TYPE_MASK |
++ BGMAC_CHIPCTL_4_SW_TYPE_MASK),
++ sw_type);
++ } else if (bgmac->feature_flags & BGMAC_FEAT_CC7_IF_TYPE_RGMII) {
++ bgmac_cco_ctl_maskset(bgmac, 7, ~BGMAC_CHIPCTL_7_IF_TYPE_MASK,
++ BGMAC_CHIPCTL_7_IF_TYPE_RGMII);
+ }
+
+ if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw)
+@@ -1486,6 +1507,10 @@ int bgmac_enet_probe(struct bgmac *info)
+ */
+ bgmac_clk_enable(bgmac, 0);
+
++ /* This seems to be fixing IRQ by assigning OOB #6 to the core */
++ if (bgmac->feature_flags & BGMAC_FEAT_IRQ_ID_OOB_6)
++ bgmac_idm_write(bgmac, BCMA_OOB_SEL_OUT_A30, 0x86);
++
+ bgmac_chip_reset(bgmac);
+
+ err = bgmac_dma_alloc(bgmac);
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -369,6 +369,21 @@
+ #define BGMAC_CHIPCTL_1_SW_TYPE_RGMII 0x000000C0
+ #define BGMAC_CHIPCTL_1_RXC_DLL_BYPASS 0x00010000
+
++#define BGMAC_CHIPCTL_4_IF_TYPE_MASK 0x00003000
++#define BGMAC_CHIPCTL_4_IF_TYPE_RMII 0x00000000
++#define BGMAC_CHIPCTL_4_IF_TYPE_MII 0x00001000
++#define BGMAC_CHIPCTL_4_IF_TYPE_RGMII 0x00002000
++#define BGMAC_CHIPCTL_4_SW_TYPE_MASK 0x0000C000
++#define BGMAC_CHIPCTL_4_SW_TYPE_EPHY 0x00000000
++#define BGMAC_CHIPCTL_4_SW_TYPE_EPHYMII 0x00004000
++#define BGMAC_CHIPCTL_4_SW_TYPE_EPHYRMII 0x00008000
++#define BGMAC_CHIPCTL_4_SW_TYPE_RGMII 0x0000C000
++
++#define BGMAC_CHIPCTL_7_IF_TYPE_MASK 0x000000C0
++#define BGMAC_CHIPCTL_7_IF_TYPE_RMII 0x00000000
++#define BGMAC_CHIPCTL_7_IF_TYPE_MII 0x00000040
++#define BGMAC_CHIPCTL_7_IF_TYPE_RGMII 0x00000080
++
+ #define BGMAC_WEIGHT 64
+
+ #define ETHER_MAX_LEN 1518
+@@ -390,6 +405,10 @@
+ #define BGMAC_FEAT_NO_CLR_MIB BIT(13)
+ #define BGMAC_FEAT_FORCE_SPEED_2500 BIT(14)
+ #define BGMAC_FEAT_CMDCFG_SR_REV4 BIT(15)
++#define BGMAC_FEAT_IRQ_ID_OOB_6 BIT(16)
++#define BGMAC_FEAT_CC4_IF_SW_TYPE BIT(17)
++#define BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII BIT(18)
++#define BGMAC_FEAT_CC7_IF_TYPE_RGMII BIT(19)
+
+ struct bgmac_slot_info {
+ union {
+--- a/include/linux/bcma/bcma_regs.h
++++ b/include/linux/bcma/bcma_regs.h
+@@ -23,6 +23,7 @@
+ #define BCMA_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
+
+ /* Agent registers (common for every core) */
++#define BCMA_OOB_SEL_OUT_A30 0x0100
+ #define BCMA_IOCTL 0x0408 /* IO control */
+ #define BCMA_IOCTL_CLK 0x0001
+ #define BCMA_IOCTL_FGC 0x0002
--- /dev/null
+From e2d8f646c79f26e094bfaf9b21be614d1e148a67 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Wed, 17 Aug 2016 23:11:52 +0200
+Subject: [PATCH] net: bgmac: make it clear when setting interface type to RMII
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+It doesn't really change anything as BGMAC_CHIPCTL_1_IF_TYPE_RMII is
+equal to 0. It make code a bit clener, so far when reading it one could
+think we forgot to set a proper mode. It also keeps this mode code in
+sync with other ones.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -935,7 +935,8 @@ static void bgmac_chip_reset(struct bgma
+ et_swtype <<= 4;
+ sw_type = et_swtype;
+ } else if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_EPHYRMII) {
+- sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHYRMII;
++ sw_type = BGMAC_CHIPCTL_1_IF_TYPE_RMII |
++ BGMAC_CHIPCTL_1_SW_TYPE_EPHYRMII;
+ } else if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_RGMII) {
+ sw_type = BGMAC_CHIPCTL_1_IF_TYPE_RGMII |
+ BGMAC_CHIPCTL_1_SW_TYPE_RGMII;
--- /dev/null
+From 4af1474e6198b10fee7bb20e81f7e033ad1b586c Mon Sep 17 00:00:00 2001
+From: Jon Mason <jon.mason@broadcom.com>
+Date: Wed, 5 Oct 2016 15:36:49 -0400
+Subject: [PATCH] net: bgmac: Fix errant feature flag check
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+During the conversion to the feature flags, a check against
+ci->id != BCMA_CHIP_ID_BCM47162
+became
+bgmac->feature_flags & BGMAC_FEAT_CLKCTLS
+instead of
+!(bgmac->feature_flags & BGMAC_FEAT_CLKCTLS)
+
+Reported-by: Rafał Miłecki <zajec5@gmail.com>
+Signed-off-by: Jon Mason <jon.mason@broadcom.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -1049,7 +1049,7 @@ static void bgmac_enable(struct bgmac *b
+
+ mode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
+ BGMAC_DS_MM_SHIFT;
+- if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST || mode != 0)
++ if (!(bgmac->feature_flags & BGMAC_FEAT_CLKCTLST) || mode != 0)
+ bgmac_set(bgmac, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
+ if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST && mode == 2)
+ bgmac_cco_ctl_maskset(bgmac, 1, ~0,
--- /dev/null
+From c121f72a66c5f92fbe2fc53baa274eef39875cec Mon Sep 17 00:00:00 2001
+From: Colin Ian King <colin.king@canonical.com>
+Date: Mon, 24 Oct 2016 23:46:18 +0100
+Subject: [PATCH] net: bgmac: fix spelling mistake: "connecton" -> "connection"
+
+trivial fix to spelling mistake in dev_err message
+
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Acked-by: Jon Mason <jon.mason@broadcom.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -1468,7 +1468,7 @@ static int bgmac_phy_connect(struct bgma
+ phy_dev = phy_connect(bgmac->net_dev, bus_id, &bgmac_adjust_link,
+ PHY_INTERFACE_MODE_MII);
+ if (IS_ERR(phy_dev)) {
+- dev_err(bgmac->dev, "PHY connecton failed\n");
++ dev_err(bgmac->dev, "PHY connection failed\n");
+ return PTR_ERR(phy_dev);
+ }
+
--- /dev/null
+From cdb26d3387f0cdf7b2a2eea581385173547ef21f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Mon, 7 Nov 2016 13:53:27 +0100
+Subject: [PATCH] net: bgmac: fix reversed checks for clock control flag
+
+This fixes regression introduced by patch adding feature flags. It was
+already reported and patch followed (it got accepted) but it appears it
+was incorrect. Instead of fixing reversed condition it broke a good one.
+
+This patch was verified to actually fix SoC hanges caused by bgmac on
+BCM47186B0.
+
+Fixes: db791eb2970b ("net: ethernet: bgmac: convert to feature flags")
+Fixes: 4af1474e6198 ("net: bgmac: Fix errant feature flag check")
+Cc: Jon Mason <jon.mason@broadcom.com>
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -1049,9 +1049,9 @@ static void bgmac_enable(struct bgmac *b
+
+ mode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
+ BGMAC_DS_MM_SHIFT;
+- if (!(bgmac->feature_flags & BGMAC_FEAT_CLKCTLST) || mode != 0)
++ if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST || mode != 0)
+ bgmac_set(bgmac, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
+- if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST && mode == 2)
++ if (!(bgmac->feature_flags & BGMAC_FEAT_CLKCTLST) && mode == 2)
+ bgmac_cco_ctl_maskset(bgmac, 1, ~0,
+ BGMAC_CHIPCTL_1_RXC_DLL_BYPASS);
+
+++ /dev/null
-From 2022e9d50798aa592887ccb5a7d045e537f3855f Mon Sep 17 00:00:00 2001
-From: Florian Fainelli <f.fainelli@gmail.com>
-Date: Tue, 7 Jun 2016 15:06:13 -0700
-Subject: [PATCH 1/3] bgmac: Bind net_device with backing device structure
-
-In preparation for allowing different helpers to be utilized against
-network devices created by the bgmac driver, make sure that we bind the
-net_device with core->dev.
-
-Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 1 +
- 1 file changed, 1 insertion(+)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -1602,6 +1602,7 @@ static int bgmac_probe(struct bcma_devic
- bgmac->net_dev = net_dev;
- bgmac->core = core;
- bcma_set_drvdata(core, bgmac);
-+ SET_NETDEV_DEV(net_dev, &core->dev);
-
- /* Defaults */
- memcpy(bgmac->net_dev->dev_addr, mac, ETH_ALEN);
+++ /dev/null
-From f6613d4fa937fa8388f2c1cb4e69ccc25e9e2336 Mon Sep 17 00:00:00 2001
-From: Florian Fainelli <f.fainelli@gmail.com>
-Date: Tue, 7 Jun 2016 15:06:14 -0700
-Subject: [PATCH 2/3] bgmac: Add support for ethtool statistics
-
-Read the statistics from the BGMAC's builtin MAC and return them to
-user-space using the standard ethtool helpers.
-
-Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 124 ++++++++++++++++++++++++++++++++++
- drivers/net/ethernet/broadcom/bgmac.h | 4 +-
- 2 files changed, 126 insertions(+), 2 deletions(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -1385,6 +1385,127 @@ static const struct net_device_ops bgmac
- * ethtool_ops
- **************************************************/
-
-+struct bgmac_stat {
-+ u8 size;
-+ u32 offset;
-+ const char *name;
-+};
-+
-+static struct bgmac_stat bgmac_get_strings_stats[] = {
-+ { 8, BGMAC_TX_GOOD_OCTETS, "tx_good_octets" },
-+ { 4, BGMAC_TX_GOOD_PKTS, "tx_good" },
-+ { 8, BGMAC_TX_OCTETS, "tx_octets" },
-+ { 4, BGMAC_TX_PKTS, "tx_pkts" },
-+ { 4, BGMAC_TX_BROADCAST_PKTS, "tx_broadcast" },
-+ { 4, BGMAC_TX_MULTICAST_PKTS, "tx_multicast" },
-+ { 4, BGMAC_TX_LEN_64, "tx_64" },
-+ { 4, BGMAC_TX_LEN_65_TO_127, "tx_65_127" },
-+ { 4, BGMAC_TX_LEN_128_TO_255, "tx_128_255" },
-+ { 4, BGMAC_TX_LEN_256_TO_511, "tx_256_511" },
-+ { 4, BGMAC_TX_LEN_512_TO_1023, "tx_512_1023" },
-+ { 4, BGMAC_TX_LEN_1024_TO_1522, "tx_1024_1522" },
-+ { 4, BGMAC_TX_LEN_1523_TO_2047, "tx_1523_2047" },
-+ { 4, BGMAC_TX_LEN_2048_TO_4095, "tx_2048_4095" },
-+ { 4, BGMAC_TX_LEN_4096_TO_8191, "tx_4096_8191" },
-+ { 4, BGMAC_TX_LEN_8192_TO_MAX, "tx_8192_max" },
-+ { 4, BGMAC_TX_JABBER_PKTS, "tx_jabber" },
-+ { 4, BGMAC_TX_OVERSIZE_PKTS, "tx_oversize" },
-+ { 4, BGMAC_TX_FRAGMENT_PKTS, "tx_fragment" },
-+ { 4, BGMAC_TX_UNDERRUNS, "tx_underruns" },
-+ { 4, BGMAC_TX_TOTAL_COLS, "tx_total_cols" },
-+ { 4, BGMAC_TX_SINGLE_COLS, "tx_single_cols" },
-+ { 4, BGMAC_TX_MULTIPLE_COLS, "tx_multiple_cols" },
-+ { 4, BGMAC_TX_EXCESSIVE_COLS, "tx_excessive_cols" },
-+ { 4, BGMAC_TX_LATE_COLS, "tx_late_cols" },
-+ { 4, BGMAC_TX_DEFERED, "tx_defered" },
-+ { 4, BGMAC_TX_CARRIER_LOST, "tx_carrier_lost" },
-+ { 4, BGMAC_TX_PAUSE_PKTS, "tx_pause" },
-+ { 4, BGMAC_TX_UNI_PKTS, "tx_unicast" },
-+ { 4, BGMAC_TX_Q0_PKTS, "tx_q0" },
-+ { 8, BGMAC_TX_Q0_OCTETS, "tx_q0_octets" },
-+ { 4, BGMAC_TX_Q1_PKTS, "tx_q1" },
-+ { 8, BGMAC_TX_Q1_OCTETS, "tx_q1_octets" },
-+ { 4, BGMAC_TX_Q2_PKTS, "tx_q2" },
-+ { 8, BGMAC_TX_Q2_OCTETS, "tx_q2_octets" },
-+ { 4, BGMAC_TX_Q3_PKTS, "tx_q3" },
-+ { 8, BGMAC_TX_Q3_OCTETS, "tx_q3_octets" },
-+ { 8, BGMAC_RX_GOOD_OCTETS, "rx_good_octets" },
-+ { 4, BGMAC_RX_GOOD_PKTS, "rx_good" },
-+ { 8, BGMAC_RX_OCTETS, "rx_octets" },
-+ { 4, BGMAC_RX_PKTS, "rx_pkts" },
-+ { 4, BGMAC_RX_BROADCAST_PKTS, "rx_broadcast" },
-+ { 4, BGMAC_RX_MULTICAST_PKTS, "rx_multicast" },
-+ { 4, BGMAC_RX_LEN_64, "rx_64" },
-+ { 4, BGMAC_RX_LEN_65_TO_127, "rx_65_127" },
-+ { 4, BGMAC_RX_LEN_128_TO_255, "rx_128_255" },
-+ { 4, BGMAC_RX_LEN_256_TO_511, "rx_256_511" },
-+ { 4, BGMAC_RX_LEN_512_TO_1023, "rx_512_1023" },
-+ { 4, BGMAC_RX_LEN_1024_TO_1522, "rx_1024_1522" },
-+ { 4, BGMAC_RX_LEN_1523_TO_2047, "rx_1523_2047" },
-+ { 4, BGMAC_RX_LEN_2048_TO_4095, "rx_2048_4095" },
-+ { 4, BGMAC_RX_LEN_4096_TO_8191, "rx_4096_8191" },
-+ { 4, BGMAC_RX_LEN_8192_TO_MAX, "rx_8192_max" },
-+ { 4, BGMAC_RX_JABBER_PKTS, "rx_jabber" },
-+ { 4, BGMAC_RX_OVERSIZE_PKTS, "rx_oversize" },
-+ { 4, BGMAC_RX_FRAGMENT_PKTS, "rx_fragment" },
-+ { 4, BGMAC_RX_MISSED_PKTS, "rx_missed" },
-+ { 4, BGMAC_RX_CRC_ALIGN_ERRS, "rx_crc_align" },
-+ { 4, BGMAC_RX_UNDERSIZE, "rx_undersize" },
-+ { 4, BGMAC_RX_CRC_ERRS, "rx_crc" },
-+ { 4, BGMAC_RX_ALIGN_ERRS, "rx_align" },
-+ { 4, BGMAC_RX_SYMBOL_ERRS, "rx_symbol" },
-+ { 4, BGMAC_RX_PAUSE_PKTS, "rx_pause" },
-+ { 4, BGMAC_RX_NONPAUSE_PKTS, "rx_nonpause" },
-+ { 4, BGMAC_RX_SACHANGES, "rx_sa_changes" },
-+ { 4, BGMAC_RX_UNI_PKTS, "rx_unicast" },
-+};
-+
-+#define BGMAC_STATS_LEN ARRAY_SIZE(bgmac_get_strings_stats)
-+
-+static int bgmac_get_sset_count(struct net_device *dev, int string_set)
-+{
-+ switch (string_set) {
-+ case ETH_SS_STATS:
-+ return BGMAC_STATS_LEN;
-+ }
-+
-+ return -EOPNOTSUPP;
-+}
-+
-+static void bgmac_get_strings(struct net_device *dev, u32 stringset,
-+ u8 *data)
-+{
-+ int i;
-+
-+ if (stringset != ETH_SS_STATS)
-+ return;
-+
-+ for (i = 0; i < BGMAC_STATS_LEN; i++)
-+ strlcpy(data + i * ETH_GSTRING_LEN,
-+ bgmac_get_strings_stats[i].name, ETH_GSTRING_LEN);
-+}
-+
-+static void bgmac_get_ethtool_stats(struct net_device *dev,
-+ struct ethtool_stats *ss, uint64_t *data)
-+{
-+ struct bgmac *bgmac = netdev_priv(dev);
-+ const struct bgmac_stat *s;
-+ unsigned int i;
-+ u64 val;
-+
-+ if (!netif_running(dev))
-+ return;
-+
-+ for (i = 0; i < BGMAC_STATS_LEN; i++) {
-+ s = &bgmac_get_strings_stats[i];
-+ val = 0;
-+ if (s->size == 8)
-+ val = (u64)bgmac_read(bgmac, s->offset + 4) << 32;
-+ val |= bgmac_read(bgmac, s->offset);
-+ data[i] = val;
-+ }
-+}
-+
- static int bgmac_get_settings(struct net_device *net_dev,
- struct ethtool_cmd *cmd)
- {
-@@ -1409,6 +1530,9 @@ static void bgmac_get_drvinfo(struct net
- }
-
- static const struct ethtool_ops bgmac_ethtool_ops = {
-+ .get_strings = bgmac_get_strings,
-+ .get_sset_count = bgmac_get_sset_count,
-+ .get_ethtool_stats = bgmac_get_ethtool_stats,
- .get_settings = bgmac_get_settings,
- .set_settings = bgmac_set_settings,
- .get_drvinfo = bgmac_get_drvinfo,
---- a/drivers/net/ethernet/broadcom/bgmac.h
-+++ b/drivers/net/ethernet/broadcom/bgmac.h
-@@ -123,7 +123,7 @@
- #define BGMAC_TX_LEN_1024_TO_1522 0x334
- #define BGMAC_TX_LEN_1523_TO_2047 0x338
- #define BGMAC_TX_LEN_2048_TO_4095 0x33c
--#define BGMAC_TX_LEN_4095_TO_8191 0x340
-+#define BGMAC_TX_LEN_4096_TO_8191 0x340
- #define BGMAC_TX_LEN_8192_TO_MAX 0x344
- #define BGMAC_TX_JABBER_PKTS 0x348 /* Error */
- #define BGMAC_TX_OVERSIZE_PKTS 0x34c /* Error */
-@@ -166,7 +166,7 @@
- #define BGMAC_RX_LEN_1024_TO_1522 0x3e4
- #define BGMAC_RX_LEN_1523_TO_2047 0x3e8
- #define BGMAC_RX_LEN_2048_TO_4095 0x3ec
--#define BGMAC_RX_LEN_4095_TO_8191 0x3f0
-+#define BGMAC_RX_LEN_4096_TO_8191 0x3f0
- #define BGMAC_RX_LEN_8192_TO_MAX 0x3f4
- #define BGMAC_RX_JABBER_PKTS 0x3f8 /* Error */
- #define BGMAC_RX_OVERSIZE_PKTS 0x3fc /* Error */
+++ /dev/null
-From 6d490f62a4c7f11c552591bdd08eda3636aa0db9 Mon Sep 17 00:00:00 2001
-From: Florian Fainelli <f.fainelli@gmail.com>
-Date: Tue, 7 Jun 2016 15:06:15 -0700
-Subject: [PATCH 3/3] bgmac: Maintain some netdev statistics
-
-Add a few netdev statistics to report transmitted and received bytes and
-packets and a few obvious errors.
-
-Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 10 ++++++++++
- 1 file changed, 10 insertions(+)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -246,6 +246,8 @@ err_dma_head:
-
- err_drop:
- dev_kfree_skb(skb);
-+ net_dev->stats.tx_dropped++;
-+ net_dev->stats.tx_errors++;
- return NETDEV_TX_OK;
- }
-
-@@ -284,6 +286,8 @@ static void bgmac_dma_tx_free(struct bgm
- DMA_TO_DEVICE);
-
- if (slot->skb) {
-+ bgmac->net_dev->stats.tx_bytes += slot->skb->len;
-+ bgmac->net_dev->stats.tx_packets++;
- bytes_compl += slot->skb->len;
- pkts_compl++;
-
-@@ -467,6 +471,7 @@ static int bgmac_dma_rx_read(struct bgma
- bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n",
- ring->start);
- put_page(virt_to_head_page(buf));
-+ bgmac->net_dev->stats.rx_errors++;
- break;
- }
-
-@@ -474,6 +479,8 @@ static int bgmac_dma_rx_read(struct bgma
- bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n",
- ring->start);
- put_page(virt_to_head_page(buf));
-+ bgmac->net_dev->stats.rx_length_errors++;
-+ bgmac->net_dev->stats.rx_errors++;
- break;
- }
-
-@@ -484,6 +491,7 @@ static int bgmac_dma_rx_read(struct bgma
- if (unlikely(!skb)) {
- bgmac_err(bgmac, "build_skb failed\n");
- put_page(virt_to_head_page(buf));
-+ bgmac->net_dev->stats.rx_errors++;
- break;
- }
- skb_put(skb, BGMAC_RX_FRAME_OFFSET +
-@@ -493,6 +501,8 @@ static int bgmac_dma_rx_read(struct bgma
-
- skb_checksum_none_assert(skb);
- skb->protocol = eth_type_trans(skb, bgmac->net_dev);
-+ bgmac->net_dev->stats.rx_bytes += len;
-+ bgmac->net_dev->stats.rx_packets++;
- napi_gro_receive(&bgmac->napi, skb);
- handled++;
- } while (0);
--- /dev/null
+From 40be0dda0725886b623d67868db3219a2e74683b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Sat, 28 Jan 2017 15:15:42 +0100
+Subject: [PATCH] net: add devm version of alloc_etherdev_mqs function
+
+This patch adds devm_alloc_etherdev_mqs function and devm_alloc_etherdev
+macro. These can be used for simpler netdev allocation without having to
+care about calling free_netdev.
+
+Thanks to this change drivers, their error paths and removal paths may
+get simpler by a bit.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ include/linux/etherdevice.h | 5 +++++
+ net/ethernet/eth.c | 28 ++++++++++++++++++++++++++++
+ 2 files changed, 33 insertions(+)
+
+--- a/include/linux/etherdevice.h
++++ b/include/linux/etherdevice.h
+@@ -51,6 +51,11 @@ struct net_device *alloc_etherdev_mqs(in
+ #define alloc_etherdev(sizeof_priv) alloc_etherdev_mq(sizeof_priv, 1)
+ #define alloc_etherdev_mq(sizeof_priv, count) alloc_etherdev_mqs(sizeof_priv, count, count)
+
++struct net_device *devm_alloc_etherdev_mqs(struct device *dev, int sizeof_priv,
++ unsigned int txqs,
++ unsigned int rxqs);
++#define devm_alloc_etherdev(dev, sizeof_priv) devm_alloc_etherdev_mqs(dev, sizeof_priv, 1, 1)
++
+ struct sk_buff **eth_gro_receive(struct sk_buff **head,
+ struct sk_buff *skb);
+ int eth_gro_complete(struct sk_buff *skb, int nhoff);
+--- a/net/ethernet/eth.c
++++ b/net/ethernet/eth.c
+@@ -388,6 +388,34 @@ struct net_device *alloc_etherdev_mqs(in
+ }
+ EXPORT_SYMBOL(alloc_etherdev_mqs);
+
++static void devm_free_netdev(struct device *dev, void *res)
++{
++ free_netdev(*(struct net_device **)res);
++}
++
++struct net_device *devm_alloc_etherdev_mqs(struct device *dev, int sizeof_priv,
++ unsigned int txqs, unsigned int rxqs)
++{
++ struct net_device **dr;
++ struct net_device *netdev;
++
++ dr = devres_alloc(devm_free_netdev, sizeof(*dr), GFP_KERNEL);
++ if (!dr)
++ return NULL;
++
++ netdev = alloc_etherdev_mqs(sizeof_priv, txqs, rxqs);
++ if (!netdev) {
++ devres_free(dr);
++ return NULL;
++ }
++
++ *dr = netdev;
++ devres_add(dev, dr);
++
++ return netdev;
++}
++EXPORT_SYMBOL(devm_alloc_etherdev_mqs);
++
+ ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len)
+ {
+ return scnprintf(buf, PAGE_SIZE, "%*phC\n", len, addr);
+++ /dev/null
-From b21fcb259313bcf7d4f73ecd5e44948995c8957c Mon Sep 17 00:00:00 2001
-From: Philippe Reynes <tremyfr@gmail.com>
-Date: Sun, 19 Jun 2016 22:37:05 +0200
-Subject: [PATCH 1/2] net: ethernet: bgmac: use phydev from struct net_device
-
-The private structure contain a pointer to phydev, but the structure
-net_device already contain such pointer. So we can remove the pointer
-phydev in the private structure, and update the driver to use the
-one contained in struct net_device.
-
-Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 17 ++++++-----------
- drivers/net/ethernet/broadcom/bgmac.h | 1 -
- 2 files changed, 6 insertions(+), 12 deletions(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -1323,7 +1323,7 @@ static int bgmac_open(struct net_device
- }
- napi_enable(&bgmac->napi);
-
-- phy_start(bgmac->phy_dev);
-+ phy_start(net_dev->phydev);
-
- netif_carrier_on(net_dev);
- return 0;
-@@ -1335,7 +1335,7 @@ static int bgmac_stop(struct net_device
-
- netif_carrier_off(net_dev);
-
-- phy_stop(bgmac->phy_dev);
-+ phy_stop(net_dev->phydev);
-
- napi_disable(&bgmac->napi);
- bgmac_chip_intrs_off(bgmac);
-@@ -1373,12 +1373,10 @@ static int bgmac_set_mac_address(struct
-
- static int bgmac_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
- {
-- struct bgmac *bgmac = netdev_priv(net_dev);
--
- if (!netif_running(net_dev))
- return -EINVAL;
-
-- return phy_mii_ioctl(bgmac->phy_dev, ifr, cmd);
-+ return phy_mii_ioctl(net_dev->phydev, ifr, cmd);
- }
-
- static const struct net_device_ops bgmac_netdev_ops = {
-@@ -1521,7 +1519,7 @@ static int bgmac_get_settings(struct net
- {
- struct bgmac *bgmac = netdev_priv(net_dev);
-
-- return phy_ethtool_gset(bgmac->phy_dev, cmd);
-+ return phy_ethtool_gset(net_dev->phydev, cmd);
- }
-
- static int bgmac_set_settings(struct net_device *net_dev,
-@@ -1529,7 +1527,7 @@ static int bgmac_set_settings(struct net
- {
- struct bgmac *bgmac = netdev_priv(net_dev);
-
-- return phy_ethtool_sset(bgmac->phy_dev, cmd);
-+ return phy_ethtool_sset(net_dev->phydev, cmd);
- }
-
- static void bgmac_get_drvinfo(struct net_device *net_dev,
-@@ -1566,7 +1564,7 @@ static int bgmac_mii_write(struct mii_bu
- static void bgmac_adjust_link(struct net_device *net_dev)
- {
- struct bgmac *bgmac = netdev_priv(net_dev);
-- struct phy_device *phy_dev = bgmac->phy_dev;
-+ struct phy_device *phy_dev = net_dev->phydev;
- bool update = false;
-
- if (phy_dev->link) {
-@@ -1610,8 +1608,6 @@ static int bgmac_fixed_phy_register(stru
- return err;
- }
-
-- bgmac->phy_dev = phy_dev;
--
- return err;
- }
-
-@@ -1664,7 +1660,6 @@ static int bgmac_mii_register(struct bgm
- err = PTR_ERR(phy_dev);
- goto err_unregister_bus;
- }
-- bgmac->phy_dev = phy_dev;
-
- return err;
-
---- a/drivers/net/ethernet/broadcom/bgmac.h
-+++ b/drivers/net/ethernet/broadcom/bgmac.h
-@@ -441,7 +441,6 @@ struct bgmac {
- struct net_device *net_dev;
- struct napi_struct napi;
- struct mii_bus *mii_bus;
-- struct phy_device *phy_dev;
-
- /* DMA */
- struct bgmac_dma_ring tx_ring[BGMAC_MAX_TX_RINGS];
--- /dev/null
+From 34a5102c3235c470a6c77fba16cb971964d9c136 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Tue, 31 Jan 2017 19:37:54 +0100
+Subject: [PATCH 1/3] net: bgmac: allocate struct bgmac just once & don't copy
+ it
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+So far were were allocating struct bgmac in 3 places: platform code,
+bcma code and shared bgmac_enet_probe function. The reason for this was
+bgmac_enet_probe:
+1) Requiring early-filled struct bgmac
+2) Calling alloc_etherdev on its own in order to use netdev_priv later
+
+This solution got few drawbacks:
+1) Was duplicating allocating code
+2) Required copying early-filled struct
+3) Resulted in platform/bcma code having access only to unused struct
+
+Solve this situation by simply extracting some probe code into the new
+bgmac_alloc function.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac-bcma.c | 4 +---
+ drivers/net/ethernet/broadcom/bgmac-platform.c | 2 +-
+ drivers/net/ethernet/broadcom/bgmac.c | 25 +++++++++++++++++--------
+ drivers/net/ethernet/broadcom/bgmac.h | 3 ++-
+ 4 files changed, 21 insertions(+), 13 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
++++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
+@@ -99,12 +99,11 @@ static int bgmac_probe(struct bcma_devic
+ u8 *mac;
+ int err;
+
+- bgmac = kzalloc(sizeof(*bgmac), GFP_KERNEL);
++ bgmac = bgmac_alloc(&core->dev);
+ if (!bgmac)
+ return -ENOMEM;
+
+ bgmac->bcma.core = core;
+- bgmac->dev = &core->dev;
+ bgmac->dma_dev = core->dma_dev;
+ bgmac->irq = core->irq;
+
+@@ -285,7 +284,6 @@ static int bgmac_probe(struct bcma_devic
+ err1:
+ bcma_mdio_mii_unregister(bgmac->mii_bus);
+ err:
+- kfree(bgmac);
+ bcma_set_drvdata(core, NULL);
+
+ return err;
+--- a/drivers/net/ethernet/broadcom/bgmac-platform.c
++++ b/drivers/net/ethernet/broadcom/bgmac-platform.c
+@@ -93,7 +93,7 @@ static int bgmac_probe(struct platform_d
+ struct resource *regs;
+ const u8 *mac_addr;
+
+- bgmac = devm_kzalloc(&pdev->dev, sizeof(*bgmac), GFP_KERNEL);
++ bgmac = bgmac_alloc(&pdev->dev);
+ if (!bgmac)
+ return -ENOMEM;
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -1475,22 +1475,32 @@ static int bgmac_phy_connect(struct bgma
+ return 0;
+ }
+
+-int bgmac_enet_probe(struct bgmac *info)
++struct bgmac *bgmac_alloc(struct device *dev)
+ {
+ struct net_device *net_dev;
+ struct bgmac *bgmac;
+- int err;
+
+ /* Allocation and references */
+- net_dev = alloc_etherdev(sizeof(*bgmac));
++ net_dev = devm_alloc_etherdev(dev, sizeof(*bgmac));
+ if (!net_dev)
+- return -ENOMEM;
++ return NULL;
+
+ net_dev->netdev_ops = &bgmac_netdev_ops;
+ net_dev->ethtool_ops = &bgmac_ethtool_ops;
++
+ bgmac = netdev_priv(net_dev);
+- memcpy(bgmac, info, sizeof(*bgmac));
++ bgmac->dev = dev;
+ bgmac->net_dev = net_dev;
++
++ return bgmac;
++}
++EXPORT_SYMBOL_GPL(bgmac_alloc);
++
++int bgmac_enet_probe(struct bgmac *bgmac)
++{
++ struct net_device *net_dev = bgmac->net_dev;
++ int err;
++
+ net_dev->irq = bgmac->irq;
+ SET_NETDEV_DEV(net_dev, bgmac->dev);
+
+@@ -1517,7 +1527,7 @@ int bgmac_enet_probe(struct bgmac *info)
+ err = bgmac_dma_alloc(bgmac);
+ if (err) {
+ dev_err(bgmac->dev, "Unable to alloc memory for DMA\n");
+- goto err_netdev_free;
++ goto err_out;
+ }
+
+ bgmac->int_mask = BGMAC_IS_ERRMASK | BGMAC_IS_RX | BGMAC_IS_TX_MASK;
+@@ -1553,8 +1563,7 @@ err_phy_disconnect:
+ phy_disconnect(net_dev->phydev);
+ err_dma_free:
+ bgmac_dma_free(bgmac);
+-err_netdev_free:
+- free_netdev(net_dev);
++err_out:
+
+ return err;
+ }
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -515,7 +515,8 @@ struct bgmac {
+ u32 set);
+ };
+
+-int bgmac_enet_probe(struct bgmac *info);
++struct bgmac *bgmac_alloc(struct device *dev);
++int bgmac_enet_probe(struct bgmac *bgmac);
+ void bgmac_enet_remove(struct bgmac *bgmac);
+
+ struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr);
--- /dev/null
+From aa8863e5d49417094b9457a0d53e8505e95a1863 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Tue, 31 Jan 2017 19:37:55 +0100
+Subject: [PATCH 2/3] net: bgmac: drop struct bcma_mdio we don't need anymore
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adding struct bcma_mdio was a workaround for bcma code not having access
+to the struct bgmac used in the core code. Now we don't duplicate this
+struct we can just use it internally in bcma code.
+
+This simplifies code & allows access to all bgmac driver details from
+all places in bcma code.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c | 98 ++++++++++---------------
+ drivers/net/ethernet/broadcom/bgmac-bcma.c | 2 +-
+ drivers/net/ethernet/broadcom/bgmac.h | 2 +-
+ 3 files changed, 42 insertions(+), 60 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
++++ b/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
+@@ -12,11 +12,6 @@
+ #include <linux/brcmphy.h>
+ #include "bgmac.h"
+
+-struct bcma_mdio {
+- struct bcma_device *core;
+- u8 phyaddr;
+-};
+-
+ static bool bcma_mdio_wait_value(struct bcma_device *core, u16 reg, u32 mask,
+ u32 value, int timeout)
+ {
+@@ -37,7 +32,7 @@ static bool bcma_mdio_wait_value(struct
+ * PHY ops
+ **************************************************/
+
+-static u16 bcma_mdio_phy_read(struct bcma_mdio *bcma_mdio, u8 phyaddr, u8 reg)
++static u16 bcma_mdio_phy_read(struct bgmac *bgmac, u8 phyaddr, u8 reg)
+ {
+ struct bcma_device *core;
+ u16 phy_access_addr;
+@@ -56,12 +51,12 @@ static u16 bcma_mdio_phy_read(struct bcm
+ BUILD_BUG_ON(BGMAC_PC_MCT_SHIFT != BCMA_GMAC_CMN_PC_MCT_SHIFT);
+ BUILD_BUG_ON(BGMAC_PC_MTE != BCMA_GMAC_CMN_PC_MTE);
+
+- if (bcma_mdio->core->id.id == BCMA_CORE_4706_MAC_GBIT) {
+- core = bcma_mdio->core->bus->drv_gmac_cmn.core;
++ if (bgmac->bcma.core->id.id == BCMA_CORE_4706_MAC_GBIT) {
++ core = bgmac->bcma.core->bus->drv_gmac_cmn.core;
+ phy_access_addr = BCMA_GMAC_CMN_PHY_ACCESS;
+ phy_ctl_addr = BCMA_GMAC_CMN_PHY_CTL;
+ } else {
+- core = bcma_mdio->core;
++ core = bgmac->bcma.core;
+ phy_access_addr = BGMAC_PHY_ACCESS;
+ phy_ctl_addr = BGMAC_PHY_CNTL;
+ }
+@@ -87,7 +82,7 @@ static u16 bcma_mdio_phy_read(struct bcm
+ }
+
+ /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphywr */
+-static int bcma_mdio_phy_write(struct bcma_mdio *bcma_mdio, u8 phyaddr, u8 reg,
++static int bcma_mdio_phy_write(struct bgmac *bgmac, u8 phyaddr, u8 reg,
+ u16 value)
+ {
+ struct bcma_device *core;
+@@ -95,12 +90,12 @@ static int bcma_mdio_phy_write(struct bc
+ u16 phy_ctl_addr;
+ u32 tmp;
+
+- if (bcma_mdio->core->id.id == BCMA_CORE_4706_MAC_GBIT) {
+- core = bcma_mdio->core->bus->drv_gmac_cmn.core;
++ if (bgmac->bcma.core->id.id == BCMA_CORE_4706_MAC_GBIT) {
++ core = bgmac->bcma.core->bus->drv_gmac_cmn.core;
+ phy_access_addr = BCMA_GMAC_CMN_PHY_ACCESS;
+ phy_ctl_addr = BCMA_GMAC_CMN_PHY_CTL;
+ } else {
+- core = bcma_mdio->core;
++ core = bgmac->bcma.core;
+ phy_access_addr = BGMAC_PHY_ACCESS;
+ phy_ctl_addr = BGMAC_PHY_CNTL;
+ }
+@@ -110,8 +105,8 @@ static int bcma_mdio_phy_write(struct bc
+ tmp |= phyaddr;
+ bcma_write32(core, phy_ctl_addr, tmp);
+
+- bcma_write32(bcma_mdio->core, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
+- if (bcma_read32(bcma_mdio->core, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
++ bcma_write32(bgmac->bcma.core, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
++ if (bcma_read32(bgmac->bcma.core, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
+ dev_warn(&core->dev, "Error setting MDIO int\n");
+
+ tmp = BGMAC_PA_START;
+@@ -132,39 +127,39 @@ static int bcma_mdio_phy_write(struct bc
+ }
+
+ /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphyinit */
+-static void bcma_mdio_phy_init(struct bcma_mdio *bcma_mdio)
++static void bcma_mdio_phy_init(struct bgmac *bgmac)
+ {
+- struct bcma_chipinfo *ci = &bcma_mdio->core->bus->chipinfo;
++ struct bcma_chipinfo *ci = &bgmac->bcma.core->bus->chipinfo;
+ u8 i;
+
+ if (ci->id == BCMA_CHIP_ID_BCM5356) {
+ for (i = 0; i < 5; i++) {
+- bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x008b);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x15, 0x0100);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000f);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x12, 0x2aaa);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000b);
++ bcma_mdio_phy_write(bgmac, i, 0x1f, 0x008b);
++ bcma_mdio_phy_write(bgmac, i, 0x15, 0x0100);
++ bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000f);
++ bcma_mdio_phy_write(bgmac, i, 0x12, 0x2aaa);
++ bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000b);
+ }
+ }
+ if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg != 10) ||
+ (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg != 10) ||
+ (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg != 9)) {
+- struct bcma_drv_cc *cc = &bcma_mdio->core->bus->drv_cc;
++ struct bcma_drv_cc *cc = &bgmac->bcma.core->bus->drv_cc;
+
+ bcma_chipco_chipctl_maskset(cc, 2, ~0xc0000000, 0);
+ bcma_chipco_chipctl_maskset(cc, 4, ~0x80000000, 0);
+ for (i = 0; i < 5; i++) {
+- bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000f);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x16, 0x5284);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000b);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x0010);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000f);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x16, 0x5296);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x1073);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x9073);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x16, 0x52b6);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x9273);
+- bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000b);
++ bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000f);
++ bcma_mdio_phy_write(bgmac, i, 0x16, 0x5284);
++ bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000b);
++ bcma_mdio_phy_write(bgmac, i, 0x17, 0x0010);
++ bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000f);
++ bcma_mdio_phy_write(bgmac, i, 0x16, 0x5296);
++ bcma_mdio_phy_write(bgmac, i, 0x17, 0x1073);
++ bcma_mdio_phy_write(bgmac, i, 0x17, 0x9073);
++ bcma_mdio_phy_write(bgmac, i, 0x16, 0x52b6);
++ bcma_mdio_phy_write(bgmac, i, 0x17, 0x9273);
++ bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000b);
+ }
+ }
+ }
+@@ -172,17 +167,17 @@ static void bcma_mdio_phy_init(struct bc
+ /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphyreset */
+ static int bcma_mdio_phy_reset(struct mii_bus *bus)
+ {
+- struct bcma_mdio *bcma_mdio = bus->priv;
+- u8 phyaddr = bcma_mdio->phyaddr;
++ struct bgmac *bgmac = bus->priv;
++ u8 phyaddr = bgmac->phyaddr;
+
+- if (bcma_mdio->phyaddr == BGMAC_PHY_NOREGS)
++ if (phyaddr == BGMAC_PHY_NOREGS)
+ return 0;
+
+- bcma_mdio_phy_write(bcma_mdio, phyaddr, MII_BMCR, BMCR_RESET);
++ bcma_mdio_phy_write(bgmac, phyaddr, MII_BMCR, BMCR_RESET);
+ udelay(100);
+- if (bcma_mdio_phy_read(bcma_mdio, phyaddr, MII_BMCR) & BMCR_RESET)
+- dev_err(&bcma_mdio->core->dev, "PHY reset failed\n");
+- bcma_mdio_phy_init(bcma_mdio);
++ if (bcma_mdio_phy_read(bgmac, phyaddr, MII_BMCR) & BMCR_RESET)
++ dev_err(bgmac->dev, "PHY reset failed\n");
++ bcma_mdio_phy_init(bgmac);
+
+ return 0;
+ }
+@@ -202,16 +197,12 @@ static int bcma_mdio_mii_write(struct mi
+ return bcma_mdio_phy_write(bus->priv, mii_id, regnum, value);
+ }
+
+-struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr)
++struct mii_bus *bcma_mdio_mii_register(struct bgmac *bgmac)
+ {
+- struct bcma_mdio *bcma_mdio;
++ struct bcma_device *core = bgmac->bcma.core;
+ struct mii_bus *mii_bus;
+ int i, err;
+
+- bcma_mdio = kzalloc(sizeof(*bcma_mdio), GFP_KERNEL);
+- if (!bcma_mdio)
+- return ERR_PTR(-ENOMEM);
+-
+ mii_bus = mdiobus_alloc();
+ if (!mii_bus) {
+ err = -ENOMEM;
+@@ -221,12 +212,12 @@ struct mii_bus *bcma_mdio_mii_register(s
+ mii_bus->name = "bcma_mdio mii bus";
+ sprintf(mii_bus->id, "%s-%d-%d", "bcma_mdio", core->bus->num,
+ core->core_unit);
+- mii_bus->priv = bcma_mdio;
++ mii_bus->priv = bgmac;
+ mii_bus->read = bcma_mdio_mii_read;
+ mii_bus->write = bcma_mdio_mii_write;
+ mii_bus->reset = bcma_mdio_phy_reset;
+ mii_bus->parent = &core->dev;
+- mii_bus->phy_mask = ~(1 << phyaddr);
++ mii_bus->phy_mask = ~(1 << bgmac->phyaddr);
+
+ mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
+ if (!mii_bus->irq) {
+@@ -236,9 +227,6 @@ struct mii_bus *bcma_mdio_mii_register(s
+ for (i = 0; i < PHY_MAX_ADDR; i++)
+ mii_bus->irq[i] = PHY_POLL;
+
+- bcma_mdio->core = core;
+- bcma_mdio->phyaddr = phyaddr;
+-
+ err = mdiobus_register(mii_bus);
+ if (err) {
+ dev_err(&core->dev, "Registration of mii bus failed\n");
+@@ -252,24 +240,18 @@ err_free_irq:
+ err_free_bus:
+ mdiobus_free(mii_bus);
+ err:
+- kfree(bcma_mdio);
+ return ERR_PTR(err);
+ }
+ EXPORT_SYMBOL_GPL(bcma_mdio_mii_register);
+
+ void bcma_mdio_mii_unregister(struct mii_bus *mii_bus)
+ {
+- struct bcma_mdio *bcma_mdio;
+-
+ if (!mii_bus)
+ return;
+
+- bcma_mdio = mii_bus->priv;
+-
+ mdiobus_unregister(mii_bus);
+ kfree(mii_bus->irq);
+ mdiobus_free(mii_bus);
+- kfree(bcma_mdio);
+ }
+ EXPORT_SYMBOL_GPL(bcma_mdio_mii_unregister);
+
+--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
++++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
+@@ -159,7 +159,7 @@ static int bgmac_probe(struct bcma_devic
+
+ if (!bgmac_is_bcm4707_family(core) &&
+ !(ci->id == BCMA_CHIP_ID_BCM53573 && core->core_unit == 1)) {
+- mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
++ mii_bus = bcma_mdio_mii_register(bgmac);
+ if (IS_ERR(mii_bus)) {
+ err = PTR_ERR(mii_bus);
+ goto err;
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -519,7 +519,7 @@ struct bgmac *bgmac_alloc(struct device
+ int bgmac_enet_probe(struct bgmac *bgmac);
+ void bgmac_enet_remove(struct bgmac *bgmac);
+
+-struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr);
++struct mii_bus *bcma_mdio_mii_register(struct bgmac *bgmac);
+ void bcma_mdio_mii_unregister(struct mii_bus *mii_bus);
+
+ static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset)
--- /dev/null
+From 8e6f31baba7e2c13ab7e954fe6179420a7545a8b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Tue, 31 Jan 2017 19:37:56 +0100
+Subject: [PATCH 3/3] net: bgmac: use PHY subsystem for initializing PHY
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This adds support for using bgmac with PHYs supported by standalone PHY
+drivers. Having any PHY initialization in bgmac is hacky and shouldn't
+be extended but rather removed if anyone has hardware to test it.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
++++ b/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
+@@ -132,6 +132,10 @@ static void bcma_mdio_phy_init(struct bg
+ struct bcma_chipinfo *ci = &bgmac->bcma.core->bus->chipinfo;
+ u8 i;
+
++ /* For some legacy hardware we do chipset-based PHY initialization here
++ * without even detecting PHY ID. It's hacky and should be cleaned as
++ * soon as someone can test it.
++ */
+ if (ci->id == BCMA_CHIP_ID_BCM5356) {
+ for (i = 0; i < 5; i++) {
+ bcma_mdio_phy_write(bgmac, i, 0x1f, 0x008b);
+@@ -140,6 +144,7 @@ static void bcma_mdio_phy_init(struct bg
+ bcma_mdio_phy_write(bgmac, i, 0x12, 0x2aaa);
+ bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000b);
+ }
++ return;
+ }
+ if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg != 10) ||
+ (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg != 10) ||
+@@ -161,7 +166,12 @@ static void bcma_mdio_phy_init(struct bg
+ bcma_mdio_phy_write(bgmac, i, 0x17, 0x9273);
+ bcma_mdio_phy_write(bgmac, i, 0x1f, 0x000b);
+ }
++ return;
+ }
++
++ /* For all other hw do initialization using PHY subsystem. */
++ if (bgmac->net_dev && bgmac->net_dev->phydev)
++ phy_init_hw(bgmac->net_dev->phydev);
+ }
+
+ /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphyreset */
+++ /dev/null
-From d2b13233879ca1268a1c027d4573109e5a777811 Mon Sep 17 00:00:00 2001
-From: Florian Fainelli <f.fainelli@gmail.com>
-Date: Thu, 23 Jun 2016 14:23:12 -0700
-Subject: [PATCH 1/3] net: bgmac: Fix SOF bit checking
-
-We are checking for the Start of Frame bit in the ctl1 word, while this
-bit is set in the ctl0 word instead. Read the ctl0 word and update the
-check to verify that.
-
-Fixes: 9cde94506eac ("bgmac: implement scatter/gather support")
-Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 5 +++--
- 1 file changed, 3 insertions(+), 2 deletions(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -269,15 +269,16 @@ static void bgmac_dma_tx_free(struct bgm
- while (ring->start != ring->end) {
- int slot_idx = ring->start % BGMAC_TX_RING_SLOTS;
- struct bgmac_slot_info *slot = &ring->slots[slot_idx];
-- u32 ctl1;
-+ u32 ctl0, ctl1;
- int len;
-
- if (slot_idx == empty_slot)
- break;
-
-+ ctl0 = le32_to_cpu(ring->cpu_base[slot_idx].ctl0);
- ctl1 = le32_to_cpu(ring->cpu_base[slot_idx].ctl1);
- len = ctl1 & BGMAC_DESC_CTL1_LEN;
-- if (ctl1 & BGMAC_DESC_CTL0_SOF)
-+ if (ctl0 & BGMAC_DESC_CTL0_SOF)
- /* Unmap no longer used buffer */
- dma_unmap_single(dma_dev, slot->dma_addr, len,
- DMA_TO_DEVICE);
+++ /dev/null
-From c3897f2a69e54dd113fc9abd2daf872e5b495798 Mon Sep 17 00:00:00 2001
-From: Florian Fainelli <f.fainelli@gmail.com>
-Date: Thu, 23 Jun 2016 14:25:32 -0700
-Subject: [PATCH 2/3] net: bgmac: Start transmit queue in bgmac_open
-
-The driver does not start the transmit queue in bgmac_open(). If the
-queue was stopped prior to closing then re-opening the interface, we
-would never be able to wake-up again.
-
-Fixes: dd4544f05469 ("bgmac: driver for GBit MAC core on BCMA bus")
-Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 3 +++
- 1 file changed, 3 insertions(+)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -1327,6 +1327,9 @@ static int bgmac_open(struct net_device
- phy_start(net_dev->phydev);
-
- netif_carrier_on(net_dev);
-+
-+ netif_start_queue(net_dev);
-+
- return 0;
- }
-
+++ /dev/null
-From 3894396e64994f31c3ef5c7e6f63dded0593e567 Mon Sep 17 00:00:00 2001
-From: Florian Fainelli <f.fainelli@gmail.com>
-Date: Thu, 23 Jun 2016 14:25:33 -0700
-Subject: [PATCH 3/3] net: bgmac: Remove superflous netif_carrier_on()
-
-bgmac_open() calls phy_start() to initialize the PHY state machine,
-which will set the interface's carrier state accordingly, no need to
-force that as this could be conflicting with the PHY state determined by
-PHYLIB.
-
-Fixes: dd4544f05469 ("bgmac: driver for GBit MAC core on BCMA bus")
-Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 2 --
- 1 file changed, 2 deletions(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -1326,8 +1326,6 @@ static int bgmac_open(struct net_device
-
- phy_start(net_dev->phydev);
-
-- netif_carrier_on(net_dev);
--
- netif_start_queue(net_dev);
-
- return 0;
+++ /dev/null
-From d00a8281bcc962027dfe409c2f3e3f0546be9200 Mon Sep 17 00:00:00 2001
-From: Jon Mason <jon.mason@broadcom.com>
-Date: Thu, 7 Jul 2016 19:08:53 -0400
-Subject: [PATCH 1/5] net: ethernet: bgmac: change bgmac_* prints to dev_*
- prints
-
-The bgmac_* print wrappers call dev_* prints with the dev pointer from
-the bcma core. In anticipation of removing the bcma requirement for
-this driver, these must be changed to not reference that struct. So,
-simply change all of the bgmac_* prints to their dev_* counterparts. In
-some cases netdev_* prints are more appropriate, so change those as
-well.
-
-Signed-off-by: Jon Mason <jon.mason@broadcom.com>
-Acked-by: Arnd Bergmann <arnd@arndb.de>
-Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-Tested-by: Florian Fainelli <f.fainelli@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 103 +++++++++++++++++-----------------
- drivers/net/ethernet/broadcom/bgmac.h | 14 +----
- 2 files changed, 55 insertions(+), 62 deletions(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -50,7 +50,7 @@ static bool bgmac_wait_value(struct bcma
- return true;
- udelay(10);
- }
-- pr_err("Timeout waiting for reg 0x%X\n", reg);
-+ dev_err(&core->dev, "Timeout waiting for reg 0x%X\n", reg);
- return false;
- }
-
-@@ -84,8 +84,8 @@ static void bgmac_dma_tx_reset(struct bg
- udelay(10);
- }
- if (i)
-- bgmac_err(bgmac, "Timeout suspending DMA TX ring 0x%X (BGMAC_DMA_TX_STAT: 0x%08X)\n",
-- ring->mmio_base, val);
-+ dev_err(bgmac->dev, "Timeout suspending DMA TX ring 0x%X (BGMAC_DMA_TX_STAT: 0x%08X)\n",
-+ ring->mmio_base, val);
-
- /* Remove SUSPEND bit */
- bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_CTL, 0);
-@@ -93,13 +93,13 @@ static void bgmac_dma_tx_reset(struct bg
- ring->mmio_base + BGMAC_DMA_TX_STATUS,
- BGMAC_DMA_TX_STAT, BGMAC_DMA_TX_STAT_DISABLED,
- 10000)) {
-- bgmac_warn(bgmac, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
-- ring->mmio_base);
-+ dev_warn(bgmac->dev, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
-+ ring->mmio_base);
- udelay(300);
- val = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_TX_STATUS);
- if ((val & BGMAC_DMA_TX_STAT) != BGMAC_DMA_TX_STAT_DISABLED)
-- bgmac_err(bgmac, "Reset of DMA TX ring 0x%X failed\n",
-- ring->mmio_base);
-+ dev_err(bgmac->dev, "Reset of DMA TX ring 0x%X failed\n",
-+ ring->mmio_base);
- }
- }
-
-@@ -161,7 +161,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
- int i;
-
- if (skb->len > BGMAC_DESC_CTL1_LEN) {
-- bgmac_err(bgmac, "Too long skb (%d)\n", skb->len);
-+ netdev_err(bgmac->net_dev, "Too long skb (%d)\n", skb->len);
- goto err_drop;
- }
-
-@@ -174,7 +174,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
- * even when ring->end overflows
- */
- if (ring->end - ring->start + nr_frags + 1 >= BGMAC_TX_RING_SLOTS) {
-- bgmac_err(bgmac, "TX ring is full, queue should be stopped!\n");
-+ netdev_err(bgmac->net_dev, "TX ring is full, queue should be stopped!\n");
- netif_stop_queue(net_dev);
- return NETDEV_TX_BUSY;
- }
-@@ -241,8 +241,8 @@ err_dma:
- }
-
- err_dma_head:
-- bgmac_err(bgmac, "Mapping error of skb on ring 0x%X\n",
-- ring->mmio_base);
-+ netdev_err(bgmac->net_dev, "Mapping error of skb on ring 0x%X\n",
-+ ring->mmio_base);
-
- err_drop:
- dev_kfree_skb(skb);
-@@ -321,8 +321,8 @@ static void bgmac_dma_rx_reset(struct bg
- ring->mmio_base + BGMAC_DMA_RX_STATUS,
- BGMAC_DMA_RX_STAT, BGMAC_DMA_RX_STAT_DISABLED,
- 10000))
-- bgmac_err(bgmac, "Reset of ring 0x%X RX failed\n",
-- ring->mmio_base);
-+ dev_err(bgmac->dev, "Reset of ring 0x%X RX failed\n",
-+ ring->mmio_base);
- }
-
- static void bgmac_dma_rx_enable(struct bgmac *bgmac,
-@@ -374,7 +374,7 @@ static int bgmac_dma_rx_skb_for_slot(str
- dma_addr = dma_map_single(dma_dev, buf + BGMAC_RX_BUF_OFFSET,
- BGMAC_RX_BUF_SIZE, DMA_FROM_DEVICE);
- if (dma_mapping_error(dma_dev, dma_addr)) {
-- bgmac_err(bgmac, "DMA mapping error\n");
-+ netdev_err(bgmac->net_dev, "DMA mapping error\n");
- put_page(virt_to_head_page(buf));
- return -ENOMEM;
- }
-@@ -469,16 +469,16 @@ static int bgmac_dma_rx_read(struct bgma
-
- /* Check for poison and drop or pass the packet */
- if (len == 0xdead && flags == 0xbeef) {
-- bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n",
-- ring->start);
-+ netdev_err(bgmac->net_dev, "Found poisoned packet at slot %d, DMA issue!\n",
-+ ring->start);
- put_page(virt_to_head_page(buf));
- bgmac->net_dev->stats.rx_errors++;
- break;
- }
-
- if (len > BGMAC_RX_ALLOC_SIZE) {
-- bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n",
-- ring->start);
-+ netdev_err(bgmac->net_dev, "Found oversized packet at slot %d, DMA issue!\n",
-+ ring->start);
- put_page(virt_to_head_page(buf));
- bgmac->net_dev->stats.rx_length_errors++;
- bgmac->net_dev->stats.rx_errors++;
-@@ -490,7 +490,7 @@ static int bgmac_dma_rx_read(struct bgma
-
- skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
- if (unlikely(!skb)) {
-- bgmac_err(bgmac, "build_skb failed\n");
-+ netdev_err(bgmac->net_dev, "build_skb failed\n");
- put_page(virt_to_head_page(buf));
- bgmac->net_dev->stats.rx_errors++;
- break;
-@@ -644,7 +644,7 @@ static int bgmac_dma_alloc(struct bgmac
- BUILD_BUG_ON(BGMAC_MAX_RX_RINGS > ARRAY_SIZE(ring_base));
-
- if (!(bcma_aread32(bgmac->core, BCMA_IOST) & BCMA_IOST_DMA64)) {
-- bgmac_err(bgmac, "Core does not report 64-bit DMA\n");
-+ dev_err(bgmac->dev, "Core does not report 64-bit DMA\n");
- return -ENOTSUPP;
- }
-
-@@ -658,8 +658,8 @@ static int bgmac_dma_alloc(struct bgmac
- &ring->dma_base,
- GFP_KERNEL);
- if (!ring->cpu_base) {
-- bgmac_err(bgmac, "Allocation of TX ring 0x%X failed\n",
-- ring->mmio_base);
-+ dev_err(bgmac->dev, "Allocation of TX ring 0x%X failed\n",
-+ ring->mmio_base);
- goto err_dma_free;
- }
-
-@@ -683,8 +683,8 @@ static int bgmac_dma_alloc(struct bgmac
- &ring->dma_base,
- GFP_KERNEL);
- if (!ring->cpu_base) {
-- bgmac_err(bgmac, "Allocation of RX ring 0x%X failed\n",
-- ring->mmio_base);
-+ dev_err(bgmac->dev, "Allocation of RX ring 0x%X failed\n",
-+ ring->mmio_base);
- err = -ENOMEM;
- goto err_dma_free;
- }
-@@ -803,8 +803,8 @@ static u16 bgmac_phy_read(struct bgmac *
- bcma_write32(core, phy_access_addr, tmp);
-
- if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
-- bgmac_err(bgmac, "Reading PHY %d register 0x%X failed\n",
-- phyaddr, reg);
-+ dev_err(bgmac->dev, "Reading PHY %d register 0x%X failed\n",
-+ phyaddr, reg);
- return 0xffff;
- }
-
-@@ -836,7 +836,7 @@ static int bgmac_phy_write(struct bgmac
-
- bgmac_write(bgmac, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
- if (bgmac_read(bgmac, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
-- bgmac_warn(bgmac, "Error setting MDIO int\n");
-+ dev_warn(bgmac->dev, "Error setting MDIO int\n");
-
- tmp = BGMAC_PA_START;
- tmp |= BGMAC_PA_WRITE;
-@@ -846,8 +846,8 @@ static int bgmac_phy_write(struct bgmac
- bcma_write32(core, phy_access_addr, tmp);
-
- if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
-- bgmac_err(bgmac, "Writing to PHY %d register 0x%X failed\n",
-- phyaddr, reg);
-+ dev_err(bgmac->dev, "Writing to PHY %d register 0x%X failed\n",
-+ phyaddr, reg);
- return -ETIMEDOUT;
- }
-
-@@ -900,7 +900,7 @@ static void bgmac_phy_reset(struct bgmac
- bgmac_phy_write(bgmac, bgmac->phyaddr, MII_BMCR, BMCR_RESET);
- udelay(100);
- if (bgmac_phy_read(bgmac, bgmac->phyaddr, MII_BMCR) & BMCR_RESET)
-- bgmac_err(bgmac, "PHY reset failed\n");
-+ dev_err(bgmac->dev, "PHY reset failed\n");
- bgmac_phy_init(bgmac);
- }
-
-@@ -1001,7 +1001,8 @@ static void bgmac_mac_speed(struct bgmac
- set |= BGMAC_CMDCFG_ES_2500;
- break;
- default:
-- bgmac_err(bgmac, "Unsupported speed: %d\n", bgmac->mac_speed);
-+ dev_err(bgmac->dev, "Unsupported speed: %d\n",
-+ bgmac->mac_speed);
- }
-
- if (bgmac->mac_duplex == DUPLEX_HALF)
-@@ -1100,8 +1101,8 @@ static void bgmac_chip_reset(struct bgma
-
- if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
- if (kstrtou8(buf, 0, &et_swtype))
-- bgmac_err(bgmac, "Failed to parse et_swtype (%s)\n",
-- buf);
-+ dev_err(bgmac->dev, "Failed to parse et_swtype (%s)\n",
-+ buf);
- et_swtype &= 0x0f;
- et_swtype <<= 4;
- sw_type = et_swtype;
-@@ -1264,7 +1265,7 @@ static irqreturn_t bgmac_interrupt(int i
-
- int_status &= ~(BGMAC_IS_TX0 | BGMAC_IS_RX);
- if (int_status)
-- bgmac_err(bgmac, "Unknown IRQs: 0x%08X\n", int_status);
-+ dev_err(bgmac->dev, "Unknown IRQs: 0x%08X\n", int_status);
-
- /* Disable new interrupts until handling existing ones */
- bgmac_chip_intrs_off(bgmac);
-@@ -1318,7 +1319,7 @@ static int bgmac_open(struct net_device
- err = request_irq(bgmac->core->irq, bgmac_interrupt, IRQF_SHARED,
- KBUILD_MODNAME, net_dev);
- if (err < 0) {
-- bgmac_err(bgmac, "IRQ request error: %d!\n", err);
-+ dev_err(bgmac->dev, "IRQ request error: %d!\n", err);
- bgmac_dma_cleanup(bgmac);
- return err;
- }
-@@ -1599,14 +1600,14 @@ static int bgmac_fixed_phy_register(stru
-
- phy_dev = fixed_phy_register(PHY_POLL, &fphy_status, -1, NULL);
- if (!phy_dev || IS_ERR(phy_dev)) {
-- bgmac_err(bgmac, "Failed to register fixed PHY device\n");
-+ dev_err(bgmac->dev, "Failed to register fixed PHY device\n");
- return -ENODEV;
- }
-
- err = phy_connect_direct(bgmac->net_dev, phy_dev, bgmac_adjust_link,
- PHY_INTERFACE_MODE_MII);
- if (err) {
-- bgmac_err(bgmac, "Connecting PHY failed\n");
-+ dev_err(bgmac->dev, "Connecting PHY failed\n");
- return err;
- }
-
-@@ -1646,7 +1647,7 @@ static int bgmac_mii_register(struct bgm
-
- err = mdiobus_register(mii_bus);
- if (err) {
-- bgmac_err(bgmac, "Registration of mii bus failed\n");
-+ dev_err(bgmac->dev, "Registration of mii bus failed\n");
- goto err_free_irq;
- }
-
-@@ -1658,7 +1659,7 @@ static int bgmac_mii_register(struct bgm
- phy_dev = phy_connect(bgmac->net_dev, bus_id, &bgmac_adjust_link,
- PHY_INTERFACE_MODE_MII);
- if (IS_ERR(phy_dev)) {
-- bgmac_err(bgmac, "PHY connecton failed\n");
-+ dev_err(bgmac->dev, "PHY connecton failed\n");
- err = PTR_ERR(phy_dev);
- goto err_unregister_bus;
- }
-@@ -1707,7 +1708,8 @@ static int bgmac_probe(struct bcma_devic
- mac = sprom->et2mac;
- break;
- default:
-- pr_err("Unsupported core_unit %d\n", core->core_unit);
-+ dev_err(&core->dev, "Unsupported core_unit %d\n",
-+ core->core_unit);
- return -ENOTSUPP;
- }
-
-@@ -1730,6 +1732,7 @@ static int bgmac_probe(struct bcma_devic
- net_dev->irq = core->irq;
- net_dev->ethtool_ops = &bgmac_ethtool_ops;
- bgmac = netdev_priv(net_dev);
-+ bgmac->dev = &core->dev;
- bgmac->net_dev = net_dev;
- bgmac->core = core;
- bcma_set_drvdata(core, bgmac);
-@@ -1741,7 +1744,7 @@ static int bgmac_probe(struct bcma_devic
- /* On BCM4706 we need common core to access PHY */
- if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
- !core->bus->drv_gmac_cmn.core) {
-- bgmac_err(bgmac, "GMAC CMN core not found (required for BCM4706)\n");
-+ dev_err(bgmac->dev, "GMAC CMN core not found (required for BCM4706)\n");
- err = -ENODEV;
- goto err_netdev_free;
- }
-@@ -1760,15 +1763,15 @@ static int bgmac_probe(struct bcma_devic
- }
- bgmac->phyaddr &= BGMAC_PHY_MASK;
- if (bgmac->phyaddr == BGMAC_PHY_MASK) {
-- bgmac_err(bgmac, "No PHY found\n");
-+ dev_err(bgmac->dev, "No PHY found\n");
- err = -ENODEV;
- goto err_netdev_free;
- }
-- bgmac_info(bgmac, "Found PHY addr: %d%s\n", bgmac->phyaddr,
-- bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
-+ dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
-+ bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
-
- if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) {
-- bgmac_err(bgmac, "PCI setup not implemented\n");
-+ dev_err(bgmac->dev, "PCI setup not implemented\n");
- err = -ENOTSUPP;
- goto err_netdev_free;
- }
-@@ -1797,7 +1800,7 @@ static int bgmac_probe(struct bcma_devic
-
- err = bgmac_dma_alloc(bgmac);
- if (err) {
-- bgmac_err(bgmac, "Unable to alloc memory for DMA\n");
-+ dev_err(bgmac->dev, "Unable to alloc memory for DMA\n");
- goto err_netdev_free;
- }
-
-@@ -1811,16 +1814,16 @@ static int bgmac_probe(struct bcma_devic
- bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo &
- BGMAC_BFL_ENETROBO);
- if (bgmac->has_robosw)
-- bgmac_warn(bgmac, "Support for Roboswitch not implemented\n");
-+ dev_warn(bgmac->dev, "Support for Roboswitch not implemented\n");
-
- if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
-- bgmac_warn(bgmac, "Support for ADMtek ethernet switch not implemented\n");
-+ dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
-
- netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
-
- err = bgmac_mii_register(bgmac);
- if (err) {
-- bgmac_err(bgmac, "Cannot register MDIO\n");
-+ dev_err(bgmac->dev, "Cannot connect to phy\n");
- goto err_dma_free;
- }
-
-@@ -1830,7 +1833,7 @@ static int bgmac_probe(struct bcma_devic
-
- err = register_netdev(bgmac->net_dev);
- if (err) {
-- bgmac_err(bgmac, "Cannot register net device\n");
-+ dev_err(bgmac->dev, "Cannot register net device\n");
- goto err_mii_unregister;
- }
-
---- a/drivers/net/ethernet/broadcom/bgmac.h
-+++ b/drivers/net/ethernet/broadcom/bgmac.h
-@@ -1,17 +1,6 @@
- #ifndef _BGMAC_H
- #define _BGMAC_H
-
--#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
--
--#define bgmac_err(bgmac, fmt, ...) \
-- dev_err(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
--#define bgmac_warn(bgmac, fmt, ...) \
-- dev_warn(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
--#define bgmac_info(bgmac, fmt, ...) \
-- dev_info(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
--#define bgmac_dbg(bgmac, fmt, ...) \
-- dev_dbg(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
--
- #include <linux/bcma/bcma.h>
- #include <linux/brcmphy.h>
- #include <linux/netdevice.h>
-@@ -438,6 +427,8 @@ struct bgmac_rx_header {
- struct bgmac {
- struct bcma_device *core;
- struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
-+
-+ struct device *dev;
- struct net_device *net_dev;
- struct napi_struct napi;
- struct mii_bus *mii_bus;
-@@ -489,5 +480,4 @@ static inline void bgmac_set(struct bgma
- {
- bgmac_maskset(bgmac, offset, ~0, set);
- }
--
- #endif /* _BGMAC_H */
+++ /dev/null
-From a0b68486f6f680c7c0352a47c60042d7d95ffd87 Mon Sep 17 00:00:00 2001
-From: Jon Mason <jon.mason@broadcom.com>
-Date: Thu, 7 Jul 2016 19:08:54 -0400
-Subject: [PATCH 2/5] net: ethernet: bgmac: add dma_dev pointer
-
-The dma buffer allocation, etc references a dma_dev device pointer from
-the bcma core. In anticipation of removing the bcma requirement for
-this driver, these must be changed to not reference that struct. Add a
-dma_dev device pointer to the bgmac stuct and reference that instead.
-
-Signed-off-by: Jon Mason <jon.mason@broadcom.com>
-Acked-by: Arnd Bergmann <arnd@arndb.de>
-Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-Tested-by: Florian Fainelli <f.fainelli@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 17 +++++++++--------
- drivers/net/ethernet/broadcom/bgmac.h | 1 +
- 2 files changed, 10 insertions(+), 8 deletions(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -152,7 +152,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
- struct bgmac_dma_ring *ring,
- struct sk_buff *skb)
- {
-- struct device *dma_dev = bgmac->core->dma_dev;
-+ struct device *dma_dev = bgmac->dma_dev;
- struct net_device *net_dev = bgmac->net_dev;
- int index = ring->end % BGMAC_TX_RING_SLOTS;
- struct bgmac_slot_info *slot = &ring->slots[index];
-@@ -254,7 +254,7 @@ err_drop:
- /* Free transmitted packets */
- static void bgmac_dma_tx_free(struct bgmac *bgmac, struct bgmac_dma_ring *ring)
- {
-- struct device *dma_dev = bgmac->core->dma_dev;
-+ struct device *dma_dev = bgmac->dma_dev;
- int empty_slot;
- bool freed = false;
- unsigned bytes_compl = 0, pkts_compl = 0;
-@@ -355,7 +355,7 @@ static void bgmac_dma_rx_enable(struct b
- static int bgmac_dma_rx_skb_for_slot(struct bgmac *bgmac,
- struct bgmac_slot_info *slot)
- {
-- struct device *dma_dev = bgmac->core->dma_dev;
-+ struct device *dma_dev = bgmac->dma_dev;
- dma_addr_t dma_addr;
- struct bgmac_rx_header *rx;
- void *buf;
-@@ -444,7 +444,7 @@ static int bgmac_dma_rx_read(struct bgma
- end_slot /= sizeof(struct bgmac_dma_desc);
-
- while (ring->start != end_slot) {
-- struct device *dma_dev = bgmac->core->dma_dev;
-+ struct device *dma_dev = bgmac->dma_dev;
- struct bgmac_slot_info *slot = &ring->slots[ring->start];
- struct bgmac_rx_header *rx = slot->buf + BGMAC_RX_BUF_OFFSET;
- struct sk_buff *skb;
-@@ -547,7 +547,7 @@ static bool bgmac_dma_unaligned(struct b
- static void bgmac_dma_tx_ring_free(struct bgmac *bgmac,
- struct bgmac_dma_ring *ring)
- {
-- struct device *dma_dev = bgmac->core->dma_dev;
-+ struct device *dma_dev = bgmac->dma_dev;
- struct bgmac_dma_desc *dma_desc = ring->cpu_base;
- struct bgmac_slot_info *slot;
- int i;
-@@ -573,7 +573,7 @@ static void bgmac_dma_tx_ring_free(struc
- static void bgmac_dma_rx_ring_free(struct bgmac *bgmac,
- struct bgmac_dma_ring *ring)
- {
-- struct device *dma_dev = bgmac->core->dma_dev;
-+ struct device *dma_dev = bgmac->dma_dev;
- struct bgmac_slot_info *slot;
- int i;
-
-@@ -594,7 +594,7 @@ static void bgmac_dma_ring_desc_free(str
- struct bgmac_dma_ring *ring,
- int num_slots)
- {
-- struct device *dma_dev = bgmac->core->dma_dev;
-+ struct device *dma_dev = bgmac->dma_dev;
- int size;
-
- if (!ring->cpu_base)
-@@ -632,7 +632,7 @@ static void bgmac_dma_free(struct bgmac
-
- static int bgmac_dma_alloc(struct bgmac *bgmac)
- {
-- struct device *dma_dev = bgmac->core->dma_dev;
-+ struct device *dma_dev = bgmac->dma_dev;
- struct bgmac_dma_ring *ring;
- static const u16 ring_base[] = { BGMAC_DMA_BASE0, BGMAC_DMA_BASE1,
- BGMAC_DMA_BASE2, BGMAC_DMA_BASE3, };
-@@ -1733,6 +1733,7 @@ static int bgmac_probe(struct bcma_devic
- net_dev->ethtool_ops = &bgmac_ethtool_ops;
- bgmac = netdev_priv(net_dev);
- bgmac->dev = &core->dev;
-+ bgmac->dma_dev = core->dma_dev;
- bgmac->net_dev = net_dev;
- bgmac->core = core;
- bcma_set_drvdata(core, bgmac);
---- a/drivers/net/ethernet/broadcom/bgmac.h
-+++ b/drivers/net/ethernet/broadcom/bgmac.h
-@@ -429,6 +429,7 @@ struct bgmac {
- struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
-
- struct device *dev;
-+ struct device *dma_dev;
- struct net_device *net_dev;
- struct napi_struct napi;
- struct mii_bus *mii_bus;
+++ /dev/null
-From 55954f3bfdacc5908515b0c306cea23e77fab740 Mon Sep 17 00:00:00 2001
-From: Jon Mason <jon.mason@broadcom.com>
-Date: Thu, 7 Jul 2016 19:08:55 -0400
-Subject: [PATCH 3/5] net: ethernet: bgmac: move BCMA MDIO Phy code into a
- separate file
-
-Move the BCMA MDIO phy into a separate file, as it is very tightly
-coupled with the BCMA bus. This will help with the upcoming BCMA
-removal from the bgmac driver. Optimally, this should be moved into
-phy drivers, but it is too tightly coupled with the bgmac driver to
-effectively move it without more changes to the driver.
-
-Note: the phy_reset was intentionally removed, as the mdio phy subsystem
-automatically resets the phy if a reset function pointer is present. In
-addition to the moving of the driver, this reset function is added.
-
-Signed-off-by: Jon Mason <jon.mason@broadcom.com>
-Acked-by: Arnd Bergmann <arnd@arndb.de>
-Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-Tested-by: Florian Fainelli <f.fainelli@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/Makefile | 2 +-
- drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c | 264 ++++++++++++++++++++++++
- drivers/net/ethernet/broadcom/bgmac.c | 246 +++-------------------
- drivers/net/ethernet/broadcom/bgmac.h | 3 +
- 4 files changed, 298 insertions(+), 217 deletions(-)
- create mode 100644 drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
-
---- a/drivers/net/ethernet/broadcom/Makefile
-+++ b/drivers/net/ethernet/broadcom/Makefile
-@@ -10,6 +10,6 @@ obj-$(CONFIG_CNIC) += cnic.o
- obj-$(CONFIG_BNX2X) += bnx2x/
- obj-$(CONFIG_SB1250_MAC) += sb1250-mac.o
- obj-$(CONFIG_TIGON3) += tg3.o
--obj-$(CONFIG_BGMAC) += bgmac.o
-+obj-$(CONFIG_BGMAC) += bgmac.o bgmac-bcma-mdio.o
- obj-$(CONFIG_SYSTEMPORT) += bcmsysport.o
- obj-$(CONFIG_BNXT) += bnxt/
---- /dev/null
-+++ b/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
-@@ -0,0 +1,275 @@
-+/*
-+ * Driver for (BCM4706)? GBit MAC core on BCMA bus.
-+ *
-+ * Copyright (C) 2012 Rafał Miłecki <zajec5@gmail.com>
-+ *
-+ * Licensed under the GNU/GPL. See COPYING for details.
-+ */
-+
-+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-+
-+#include <linux/bcma/bcma.h>
-+#include <linux/brcmphy.h>
-+#include "bgmac.h"
-+
-+struct bcma_mdio {
-+ struct bcma_device *core;
-+ u8 phyaddr;
-+};
-+
-+static bool bcma_mdio_wait_value(struct bcma_device *core, u16 reg, u32 mask,
-+ u32 value, int timeout)
-+{
-+ u32 val;
-+ int i;
-+
-+ for (i = 0; i < timeout / 10; i++) {
-+ val = bcma_read32(core, reg);
-+ if ((val & mask) == value)
-+ return true;
-+ udelay(10);
-+ }
-+ dev_err(&core->dev, "Timeout waiting for reg 0x%X\n", reg);
-+ return false;
-+}
-+
-+/**************************************************
-+ * PHY ops
-+ **************************************************/
-+
-+static u16 bcma_mdio_phy_read(struct bcma_mdio *bcma_mdio, u8 phyaddr, u8 reg)
-+{
-+ struct bcma_device *core;
-+ u16 phy_access_addr;
-+ u16 phy_ctl_addr;
-+ u32 tmp;
-+
-+ BUILD_BUG_ON(BGMAC_PA_DATA_MASK != BCMA_GMAC_CMN_PA_DATA_MASK);
-+ BUILD_BUG_ON(BGMAC_PA_ADDR_MASK != BCMA_GMAC_CMN_PA_ADDR_MASK);
-+ BUILD_BUG_ON(BGMAC_PA_ADDR_SHIFT != BCMA_GMAC_CMN_PA_ADDR_SHIFT);
-+ BUILD_BUG_ON(BGMAC_PA_REG_MASK != BCMA_GMAC_CMN_PA_REG_MASK);
-+ BUILD_BUG_ON(BGMAC_PA_REG_SHIFT != BCMA_GMAC_CMN_PA_REG_SHIFT);
-+ BUILD_BUG_ON(BGMAC_PA_WRITE != BCMA_GMAC_CMN_PA_WRITE);
-+ BUILD_BUG_ON(BGMAC_PA_START != BCMA_GMAC_CMN_PA_START);
-+ BUILD_BUG_ON(BGMAC_PC_EPA_MASK != BCMA_GMAC_CMN_PC_EPA_MASK);
-+ BUILD_BUG_ON(BGMAC_PC_MCT_MASK != BCMA_GMAC_CMN_PC_MCT_MASK);
-+ BUILD_BUG_ON(BGMAC_PC_MCT_SHIFT != BCMA_GMAC_CMN_PC_MCT_SHIFT);
-+ BUILD_BUG_ON(BGMAC_PC_MTE != BCMA_GMAC_CMN_PC_MTE);
-+
-+ if (bcma_mdio->core->id.id == BCMA_CORE_4706_MAC_GBIT) {
-+ core = bcma_mdio->core->bus->drv_gmac_cmn.core;
-+ phy_access_addr = BCMA_GMAC_CMN_PHY_ACCESS;
-+ phy_ctl_addr = BCMA_GMAC_CMN_PHY_CTL;
-+ } else {
-+ core = bcma_mdio->core;
-+ phy_access_addr = BGMAC_PHY_ACCESS;
-+ phy_ctl_addr = BGMAC_PHY_CNTL;
-+ }
-+
-+ tmp = bcma_read32(core, phy_ctl_addr);
-+ tmp &= ~BGMAC_PC_EPA_MASK;
-+ tmp |= phyaddr;
-+ bcma_write32(core, phy_ctl_addr, tmp);
-+
-+ tmp = BGMAC_PA_START;
-+ tmp |= phyaddr << BGMAC_PA_ADDR_SHIFT;
-+ tmp |= reg << BGMAC_PA_REG_SHIFT;
-+ bcma_write32(core, phy_access_addr, tmp);
-+
-+ if (!bcma_mdio_wait_value(core, phy_access_addr, BGMAC_PA_START, 0,
-+ 1000)) {
-+ dev_err(&core->dev, "Reading PHY %d register 0x%X failed\n",
-+ phyaddr, reg);
-+ return 0xffff;
-+ }
-+
-+ return bcma_read32(core, phy_access_addr) & BGMAC_PA_DATA_MASK;
-+}
-+
-+/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphywr */
-+static int bcma_mdio_phy_write(struct bcma_mdio *bcma_mdio, u8 phyaddr, u8 reg,
-+ u16 value)
-+{
-+ struct bcma_device *core;
-+ u16 phy_access_addr;
-+ u16 phy_ctl_addr;
-+ u32 tmp;
-+
-+ if (bcma_mdio->core->id.id == BCMA_CORE_4706_MAC_GBIT) {
-+ core = bcma_mdio->core->bus->drv_gmac_cmn.core;
-+ phy_access_addr = BCMA_GMAC_CMN_PHY_ACCESS;
-+ phy_ctl_addr = BCMA_GMAC_CMN_PHY_CTL;
-+ } else {
-+ core = bcma_mdio->core;
-+ phy_access_addr = BGMAC_PHY_ACCESS;
-+ phy_ctl_addr = BGMAC_PHY_CNTL;
-+ }
-+
-+ tmp = bcma_read32(core, phy_ctl_addr);
-+ tmp &= ~BGMAC_PC_EPA_MASK;
-+ tmp |= phyaddr;
-+ bcma_write32(core, phy_ctl_addr, tmp);
-+
-+ bcma_write32(bcma_mdio->core, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
-+ if (bcma_read32(bcma_mdio->core, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
-+ dev_warn(&core->dev, "Error setting MDIO int\n");
-+
-+ tmp = BGMAC_PA_START;
-+ tmp |= BGMAC_PA_WRITE;
-+ tmp |= phyaddr << BGMAC_PA_ADDR_SHIFT;
-+ tmp |= reg << BGMAC_PA_REG_SHIFT;
-+ tmp |= value;
-+ bcma_write32(core, phy_access_addr, tmp);
-+
-+ if (!bcma_mdio_wait_value(core, phy_access_addr, BGMAC_PA_START, 0,
-+ 1000)) {
-+ dev_err(&core->dev, "Writing to PHY %d register 0x%X failed\n",
-+ phyaddr, reg);
-+ return -ETIMEDOUT;
-+ }
-+
-+ return 0;
-+}
-+
-+/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphyinit */
-+static void bcma_mdio_phy_init(struct bcma_mdio *bcma_mdio)
-+{
-+ struct bcma_chipinfo *ci = &bcma_mdio->core->bus->chipinfo;
-+ u8 i;
-+
-+ if (ci->id == BCMA_CHIP_ID_BCM5356) {
-+ for (i = 0; i < 5; i++) {
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x008b);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x15, 0x0100);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000f);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x12, 0x2aaa);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000b);
-+ }
-+ }
-+ if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg != 10) ||
-+ (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg != 10) ||
-+ (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg != 9)) {
-+ struct bcma_drv_cc *cc = &bcma_mdio->core->bus->drv_cc;
-+
-+ bcma_chipco_chipctl_maskset(cc, 2, ~0xc0000000, 0);
-+ bcma_chipco_chipctl_maskset(cc, 4, ~0x80000000, 0);
-+ for (i = 0; i < 5; i++) {
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000f);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x16, 0x5284);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000b);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x0010);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000f);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x16, 0x5296);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x1073);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x9073);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x16, 0x52b6);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x17, 0x9273);
-+ bcma_mdio_phy_write(bcma_mdio, i, 0x1f, 0x000b);
-+ }
-+ }
-+}
-+
-+/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphyreset */
-+static int bcma_mdio_phy_reset(struct mii_bus *bus)
-+{
-+ struct bcma_mdio *bcma_mdio = bus->priv;
-+ u8 phyaddr = bcma_mdio->phyaddr;
-+
-+ if (bcma_mdio->phyaddr == BGMAC_PHY_NOREGS)
-+ return 0;
-+
-+ bcma_mdio_phy_write(bcma_mdio, phyaddr, MII_BMCR, BMCR_RESET);
-+ udelay(100);
-+ if (bcma_mdio_phy_read(bcma_mdio, phyaddr, MII_BMCR) & BMCR_RESET)
-+ dev_err(&bcma_mdio->core->dev, "PHY reset failed\n");
-+ bcma_mdio_phy_init(bcma_mdio);
-+
-+ return 0;
-+}
-+
-+/**************************************************
-+ * MII
-+ **************************************************/
-+
-+static int bcma_mdio_mii_read(struct mii_bus *bus, int mii_id, int regnum)
-+{
-+ return bcma_mdio_phy_read(bus->priv, mii_id, regnum);
-+}
-+
-+static int bcma_mdio_mii_write(struct mii_bus *bus, int mii_id, int regnum,
-+ u16 value)
-+{
-+ return bcma_mdio_phy_write(bus->priv, mii_id, regnum, value);
-+}
-+
-+struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr)
-+{
-+ struct bcma_mdio *bcma_mdio;
-+ struct mii_bus *mii_bus;
-+ int i, err;
-+
-+ bcma_mdio = kzalloc(sizeof(*bcma_mdio), GFP_KERNEL);
-+ if (!bcma_mdio)
-+ return ERR_PTR(-ENOMEM);
-+
-+ mii_bus = mdiobus_alloc();
-+ if (!mii_bus) {
-+ err = -ENOMEM;
-+ goto err;
-+ }
-+
-+ mii_bus->name = "bcma_mdio mii bus";
-+ sprintf(mii_bus->id, "%s-%d-%d", "bcma_mdio", core->bus->num,
-+ core->core_unit);
-+ mii_bus->priv = bcma_mdio;
-+ mii_bus->read = bcma_mdio_mii_read;
-+ mii_bus->write = bcma_mdio_mii_write;
-+ mii_bus->reset = bcma_mdio_phy_reset;
-+ mii_bus->parent = &core->dev;
-+ mii_bus->phy_mask = ~(1 << phyaddr);
-+
-+ mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
-+ if (!mii_bus->irq) {
-+ err = -ENOMEM;
-+ goto err_free_bus;
-+ }
-+ for (i = 0; i < PHY_MAX_ADDR; i++)
-+ mii_bus->irq[i] = PHY_POLL;
-+
-+ bcma_mdio->core = core;
-+ bcma_mdio->phyaddr = phyaddr;
-+
-+ err = mdiobus_register(mii_bus);
-+ if (err) {
-+ dev_err(&core->dev, "Registration of mii bus failed\n");
-+ goto err_free_irq;
-+ }
-+
-+ return mii_bus;
-+
-+err_free_irq:
-+ kfree(mii_bus->irq);
-+err_free_bus:
-+ mdiobus_free(mii_bus);
-+err:
-+ kfree(bcma_mdio);
-+ return ERR_PTR(err);
-+}
-+
-+void bcma_mdio_mii_unregister(struct mii_bus *mii_bus)
-+{
-+ struct bcma_mdio *bcma_mdio;
-+
-+ if (!mii_bus)
-+ return;
-+
-+ bcma_mdio = mii_bus->priv;
-+
-+ mdiobus_unregister(mii_bus);
-+ kfree(mii_bus->irq);
-+ mdiobus_free(mii_bus);
-+ kfree(bcma_mdio);
-+}
-+
-+MODULE_AUTHOR("Rafał Miłecki");
-+MODULE_LICENSE("GPL");
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -759,150 +759,6 @@ error:
- return err;
- }
-
--/**************************************************
-- * PHY ops
-- **************************************************/
--
--static u16 bgmac_phy_read(struct bgmac *bgmac, u8 phyaddr, u8 reg)
--{
-- struct bcma_device *core;
-- u16 phy_access_addr;
-- u16 phy_ctl_addr;
-- u32 tmp;
--
-- BUILD_BUG_ON(BGMAC_PA_DATA_MASK != BCMA_GMAC_CMN_PA_DATA_MASK);
-- BUILD_BUG_ON(BGMAC_PA_ADDR_MASK != BCMA_GMAC_CMN_PA_ADDR_MASK);
-- BUILD_BUG_ON(BGMAC_PA_ADDR_SHIFT != BCMA_GMAC_CMN_PA_ADDR_SHIFT);
-- BUILD_BUG_ON(BGMAC_PA_REG_MASK != BCMA_GMAC_CMN_PA_REG_MASK);
-- BUILD_BUG_ON(BGMAC_PA_REG_SHIFT != BCMA_GMAC_CMN_PA_REG_SHIFT);
-- BUILD_BUG_ON(BGMAC_PA_WRITE != BCMA_GMAC_CMN_PA_WRITE);
-- BUILD_BUG_ON(BGMAC_PA_START != BCMA_GMAC_CMN_PA_START);
-- BUILD_BUG_ON(BGMAC_PC_EPA_MASK != BCMA_GMAC_CMN_PC_EPA_MASK);
-- BUILD_BUG_ON(BGMAC_PC_MCT_MASK != BCMA_GMAC_CMN_PC_MCT_MASK);
-- BUILD_BUG_ON(BGMAC_PC_MCT_SHIFT != BCMA_GMAC_CMN_PC_MCT_SHIFT);
-- BUILD_BUG_ON(BGMAC_PC_MTE != BCMA_GMAC_CMN_PC_MTE);
--
-- if (bgmac->core->id.id == BCMA_CORE_4706_MAC_GBIT) {
-- core = bgmac->core->bus->drv_gmac_cmn.core;
-- phy_access_addr = BCMA_GMAC_CMN_PHY_ACCESS;
-- phy_ctl_addr = BCMA_GMAC_CMN_PHY_CTL;
-- } else {
-- core = bgmac->core;
-- phy_access_addr = BGMAC_PHY_ACCESS;
-- phy_ctl_addr = BGMAC_PHY_CNTL;
-- }
--
-- tmp = bcma_read32(core, phy_ctl_addr);
-- tmp &= ~BGMAC_PC_EPA_MASK;
-- tmp |= phyaddr;
-- bcma_write32(core, phy_ctl_addr, tmp);
--
-- tmp = BGMAC_PA_START;
-- tmp |= phyaddr << BGMAC_PA_ADDR_SHIFT;
-- tmp |= reg << BGMAC_PA_REG_SHIFT;
-- bcma_write32(core, phy_access_addr, tmp);
--
-- if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
-- dev_err(bgmac->dev, "Reading PHY %d register 0x%X failed\n",
-- phyaddr, reg);
-- return 0xffff;
-- }
--
-- return bcma_read32(core, phy_access_addr) & BGMAC_PA_DATA_MASK;
--}
--
--/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphywr */
--static int bgmac_phy_write(struct bgmac *bgmac, u8 phyaddr, u8 reg, u16 value)
--{
-- struct bcma_device *core;
-- u16 phy_access_addr;
-- u16 phy_ctl_addr;
-- u32 tmp;
--
-- if (bgmac->core->id.id == BCMA_CORE_4706_MAC_GBIT) {
-- core = bgmac->core->bus->drv_gmac_cmn.core;
-- phy_access_addr = BCMA_GMAC_CMN_PHY_ACCESS;
-- phy_ctl_addr = BCMA_GMAC_CMN_PHY_CTL;
-- } else {
-- core = bgmac->core;
-- phy_access_addr = BGMAC_PHY_ACCESS;
-- phy_ctl_addr = BGMAC_PHY_CNTL;
-- }
--
-- tmp = bcma_read32(core, phy_ctl_addr);
-- tmp &= ~BGMAC_PC_EPA_MASK;
-- tmp |= phyaddr;
-- bcma_write32(core, phy_ctl_addr, tmp);
--
-- bgmac_write(bgmac, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
-- if (bgmac_read(bgmac, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
-- dev_warn(bgmac->dev, "Error setting MDIO int\n");
--
-- tmp = BGMAC_PA_START;
-- tmp |= BGMAC_PA_WRITE;
-- tmp |= phyaddr << BGMAC_PA_ADDR_SHIFT;
-- tmp |= reg << BGMAC_PA_REG_SHIFT;
-- tmp |= value;
-- bcma_write32(core, phy_access_addr, tmp);
--
-- if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
-- dev_err(bgmac->dev, "Writing to PHY %d register 0x%X failed\n",
-- phyaddr, reg);
-- return -ETIMEDOUT;
-- }
--
-- return 0;
--}
--
--/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphyinit */
--static void bgmac_phy_init(struct bgmac *bgmac)
--{
-- struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo;
-- struct bcma_drv_cc *cc = &bgmac->core->bus->drv_cc;
-- u8 i;
--
-- if (ci->id == BCMA_CHIP_ID_BCM5356) {
-- for (i = 0; i < 5; i++) {
-- bgmac_phy_write(bgmac, i, 0x1f, 0x008b);
-- bgmac_phy_write(bgmac, i, 0x15, 0x0100);
-- bgmac_phy_write(bgmac, i, 0x1f, 0x000f);
-- bgmac_phy_write(bgmac, i, 0x12, 0x2aaa);
-- bgmac_phy_write(bgmac, i, 0x1f, 0x000b);
-- }
-- }
-- if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg != 10) ||
-- (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg != 10) ||
-- (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg != 9)) {
-- bcma_chipco_chipctl_maskset(cc, 2, ~0xc0000000, 0);
-- bcma_chipco_chipctl_maskset(cc, 4, ~0x80000000, 0);
-- for (i = 0; i < 5; i++) {
-- bgmac_phy_write(bgmac, i, 0x1f, 0x000f);
-- bgmac_phy_write(bgmac, i, 0x16, 0x5284);
-- bgmac_phy_write(bgmac, i, 0x1f, 0x000b);
-- bgmac_phy_write(bgmac, i, 0x17, 0x0010);
-- bgmac_phy_write(bgmac, i, 0x1f, 0x000f);
-- bgmac_phy_write(bgmac, i, 0x16, 0x5296);
-- bgmac_phy_write(bgmac, i, 0x17, 0x1073);
-- bgmac_phy_write(bgmac, i, 0x17, 0x9073);
-- bgmac_phy_write(bgmac, i, 0x16, 0x52b6);
-- bgmac_phy_write(bgmac, i, 0x17, 0x9273);
-- bgmac_phy_write(bgmac, i, 0x1f, 0x000b);
-- }
-- }
--}
--
--/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipphyreset */
--static void bgmac_phy_reset(struct bgmac *bgmac)
--{
-- if (bgmac->phyaddr == BGMAC_PHY_NOREGS)
-- return;
--
-- bgmac_phy_write(bgmac, bgmac->phyaddr, MII_BMCR, BMCR_RESET);
-- udelay(100);
-- if (bgmac_phy_read(bgmac, bgmac->phyaddr, MII_BMCR) & BMCR_RESET)
-- dev_err(bgmac->dev, "PHY reset failed\n");
-- bgmac_phy_init(bgmac);
--}
-
- /**************************************************
- * Chip ops
-@@ -1159,7 +1015,8 @@ static void bgmac_chip_reset(struct bgma
- else
- bgmac_set(bgmac, BGMAC_PHY_CNTL, BGMAC_PC_MTE);
- bgmac_miiconfig(bgmac);
-- bgmac_phy_init(bgmac);
-+ if (bgmac->mii_bus)
-+ bgmac->mii_bus->reset(bgmac->mii_bus);
-
- netdev_reset_queue(bgmac->net_dev);
- }
-@@ -1553,17 +1410,6 @@ static const struct ethtool_ops bgmac_et
- * MII
- **************************************************/
-
--static int bgmac_mii_read(struct mii_bus *bus, int mii_id, int regnum)
--{
-- return bgmac_phy_read(bus->priv, mii_id, regnum);
--}
--
--static int bgmac_mii_write(struct mii_bus *bus, int mii_id, int regnum,
-- u16 value)
--{
-- return bgmac_phy_write(bus->priv, mii_id, regnum, value);
--}
--
- static void bgmac_adjust_link(struct net_device *net_dev)
- {
- struct bgmac *bgmac = netdev_priv(net_dev);
-@@ -1588,7 +1434,7 @@ static void bgmac_adjust_link(struct net
- }
- }
-
--static int bgmac_fixed_phy_register(struct bgmac *bgmac)
-+static int bgmac_phy_connect_direct(struct bgmac *bgmac)
- {
- struct fixed_phy_status fphy_status = {
- .link = 1,
-@@ -1614,81 +1460,24 @@ static int bgmac_fixed_phy_register(stru
- return err;
- }
-
--static int bgmac_mii_register(struct bgmac *bgmac)
-+static int bgmac_phy_connect(struct bgmac *bgmac)
- {
-- struct mii_bus *mii_bus;
- struct phy_device *phy_dev;
- char bus_id[MII_BUS_ID_SIZE + 3];
-- int i, err = 0;
--
-- if (bgmac_is_bcm4707_family(bgmac))
-- return bgmac_fixed_phy_register(bgmac);
--
-- mii_bus = mdiobus_alloc();
-- if (!mii_bus)
-- return -ENOMEM;
--
-- mii_bus->name = "bgmac mii bus";
-- sprintf(mii_bus->id, "%s-%d-%d", "bgmac", bgmac->core->bus->num,
-- bgmac->core->core_unit);
-- mii_bus->priv = bgmac;
-- mii_bus->read = bgmac_mii_read;
-- mii_bus->write = bgmac_mii_write;
-- mii_bus->parent = &bgmac->core->dev;
-- mii_bus->phy_mask = ~(1 << bgmac->phyaddr);
--
-- mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
-- if (!mii_bus->irq) {
-- err = -ENOMEM;
-- goto err_free_bus;
-- }
-- for (i = 0; i < PHY_MAX_ADDR; i++)
-- mii_bus->irq[i] = PHY_POLL;
--
-- err = mdiobus_register(mii_bus);
-- if (err) {
-- dev_err(bgmac->dev, "Registration of mii bus failed\n");
-- goto err_free_irq;
-- }
--
-- bgmac->mii_bus = mii_bus;
-
- /* Connect to the PHY */
-- snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, mii_bus->id,
-+ snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, bgmac->mii_bus->id,
- bgmac->phyaddr);
- phy_dev = phy_connect(bgmac->net_dev, bus_id, &bgmac_adjust_link,
- PHY_INTERFACE_MODE_MII);
- if (IS_ERR(phy_dev)) {
- dev_err(bgmac->dev, "PHY connecton failed\n");
-- err = PTR_ERR(phy_dev);
-- goto err_unregister_bus;
-+ return PTR_ERR(phy_dev);
- }
-
-- return err;
--
--err_unregister_bus:
-- mdiobus_unregister(mii_bus);
--err_free_irq:
-- kfree(mii_bus->irq);
--err_free_bus:
-- mdiobus_free(mii_bus);
-- return err;
--}
--
--static void bgmac_mii_unregister(struct bgmac *bgmac)
--{
-- struct mii_bus *mii_bus = bgmac->mii_bus;
--
-- mdiobus_unregister(mii_bus);
-- kfree(mii_bus->irq);
-- mdiobus_free(mii_bus);
-+ return 0;
- }
-
--/**************************************************
-- * BCMA bus ops
-- **************************************************/
--
--/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
- static int bgmac_probe(struct bcma_device *core)
- {
- struct net_device *net_dev;
-@@ -1809,9 +1598,6 @@ static int bgmac_probe(struct bcma_devic
- if (bcm47xx_nvram_getenv("et0_no_txint", NULL, 0) == 0)
- bgmac->int_mask &= ~BGMAC_IS_TX_MASK;
-
-- /* TODO: reset the external phy. Specs are needed */
-- bgmac_phy_reset(bgmac);
--
- bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo &
- BGMAC_BFL_ENETROBO);
- if (bgmac->has_robosw)
-@@ -1822,10 +1608,25 @@ static int bgmac_probe(struct bcma_devic
-
- netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
-
-- err = bgmac_mii_register(bgmac);
-+ if (!bgmac_is_bcm4707_family(bgmac)) {
-+ struct mii_bus *mii_bus;
-+
-+ mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
-+ if (!IS_ERR(mii_bus)) {
-+ err = PTR_ERR(mii_bus);
-+ goto err_dma_free;
-+ }
-+
-+ bgmac->mii_bus = mii_bus;
-+ }
-+
-+ if (!bgmac->mii_bus)
-+ err = bgmac_phy_connect_direct(bgmac);
-+ else
-+ err = bgmac_phy_connect(bgmac);
- if (err) {
- dev_err(bgmac->dev, "Cannot connect to phy\n");
-- goto err_dma_free;
-+ goto err_mii_unregister;
- }
-
- net_dev->features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
-@@ -1835,18 +1636,19 @@ static int bgmac_probe(struct bcma_devic
- err = register_netdev(bgmac->net_dev);
- if (err) {
- dev_err(bgmac->dev, "Cannot register net device\n");
-- goto err_mii_unregister;
-+ goto err_phy_disconnect;
- }
-
- netif_carrier_off(net_dev);
-
- return 0;
-
-+err_phy_disconnect:
-+ phy_disconnect(net_dev->phydev);
- err_mii_unregister:
-- bgmac_mii_unregister(bgmac);
-+ bcma_mdio_mii_unregister(bgmac->mii_bus);
- err_dma_free:
- bgmac_dma_free(bgmac);
--
- err_netdev_free:
- bcma_set_drvdata(core, NULL);
- free_netdev(net_dev);
-@@ -1859,7 +1661,8 @@ static void bgmac_remove(struct bcma_dev
- struct bgmac *bgmac = bcma_get_drvdata(core);
-
- unregister_netdev(bgmac->net_dev);
-- bgmac_mii_unregister(bgmac);
-+ phy_disconnect(bgmac->net_dev->phydev);
-+ bcma_mdio_mii_unregister(bgmac->mii_bus);
- netif_napi_del(&bgmac->napi);
- bgmac_dma_free(bgmac);
- bcma_set_drvdata(core, NULL);
---- a/drivers/net/ethernet/broadcom/bgmac.h
-+++ b/drivers/net/ethernet/broadcom/bgmac.h
-@@ -456,6 +456,9 @@ struct bgmac {
- bool loopback;
- };
-
-+struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr);
-+void bcma_mdio_mii_unregister(struct mii_bus *mii_bus);
-+
- static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset)
- {
- return bcma_read32(bgmac->core, offset);
+++ /dev/null
-From db791eb2970bad193b1dc95a4461b222dd22cb64 Mon Sep 17 00:00:00 2001
-From: Jon Mason <jon.mason@broadcom.com>
-Date: Thu, 7 Jul 2016 19:08:56 -0400
-Subject: [PATCH 4/5] net: ethernet: bgmac: convert to feature flags
-
-The bgmac driver is using the bcma provides device ID and revision, as
-well as the SoC ID and package, to determine which features are
-necessary to enable, reset, etc in the driver. In anticipation of
-removing the bcma requirement for this driver, these must be changed to
-not reference that struct. In place of that, each "feature" has been
-given a flag, and the flags are enabled for their respective device and
-SoC.
-
-Signed-off-by: Jon Mason <jon.mason@broadcom.com>
-Acked-by: Arnd Bergmann <arnd@arndb.de>
-Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-Tested-by: Florian Fainelli <f.fainelli@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 167 ++++++++++++++++++++++++----------
- drivers/net/ethernet/broadcom/bgmac.h | 21 ++++-
- 2 files changed, 140 insertions(+), 48 deletions(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -109,7 +109,7 @@ static void bgmac_dma_tx_enable(struct b
- u32 ctl;
-
- ctl = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_TX_CTL);
-- if (bgmac->core->id.rev >= 4) {
-+ if (bgmac->feature_flags & BGMAC_FEAT_TX_MASK_SETUP) {
- ctl &= ~BGMAC_DMA_TX_BL_MASK;
- ctl |= BGMAC_DMA_TX_BL_128 << BGMAC_DMA_TX_BL_SHIFT;
-
-@@ -335,7 +335,7 @@ static void bgmac_dma_rx_enable(struct b
- /* preserve ONLY bits 16-17 from current hardware value */
- ctl &= BGMAC_DMA_RX_ADDREXT_MASK;
-
-- if (bgmac->core->id.rev >= 4) {
-+ if (bgmac->feature_flags & BGMAC_FEAT_RX_MASK_SETUP) {
- ctl &= ~BGMAC_DMA_RX_BL_MASK;
- ctl |= BGMAC_DMA_RX_BL_128 << BGMAC_DMA_RX_BL_SHIFT;
-
-@@ -772,14 +772,20 @@ static void bgmac_cmdcfg_maskset(struct
- {
- u32 cmdcfg = bgmac_read(bgmac, BGMAC_CMDCFG);
- u32 new_val = (cmdcfg & mask) | set;
-+ u32 cmdcfg_sr;
-
-- bgmac_set(bgmac, BGMAC_CMDCFG, BGMAC_CMDCFG_SR(bgmac->core->id.rev));
-+ if (bgmac->feature_flags & BGMAC_FEAT_CMDCFG_SR_REV4)
-+ cmdcfg_sr = BGMAC_CMDCFG_SR_REV4;
-+ else
-+ cmdcfg_sr = BGMAC_CMDCFG_SR_REV0;
-+
-+ bgmac_set(bgmac, BGMAC_CMDCFG, cmdcfg_sr);
- udelay(2);
-
- if (new_val != cmdcfg || force)
- bgmac_write(bgmac, BGMAC_CMDCFG, new_val);
-
-- bgmac_mask(bgmac, BGMAC_CMDCFG, ~BGMAC_CMDCFG_SR(bgmac->core->id.rev));
-+ bgmac_mask(bgmac, BGMAC_CMDCFG, ~cmdcfg_sr);
- udelay(2);
- }
-
-@@ -808,7 +814,7 @@ static void bgmac_chip_stats_update(stru
- {
- int i;
-
-- if (bgmac->core->id.id != BCMA_CORE_4706_MAC_GBIT) {
-+ if (!(bgmac->feature_flags & BGMAC_FEAT_NO_CLR_MIB)) {
- for (i = 0; i < BGMAC_NUM_MIB_TX_REGS; i++)
- bgmac->mib_tx_regs[i] =
- bgmac_read(bgmac,
-@@ -827,7 +833,7 @@ static void bgmac_clear_mib(struct bgmac
- {
- int i;
-
-- if (bgmac->core->id.id == BCMA_CORE_4706_MAC_GBIT)
-+ if (bgmac->feature_flags & BGMAC_FEAT_NO_CLR_MIB)
- return;
-
- bgmac_set(bgmac, BGMAC_DEV_CTL, BGMAC_DC_MROR);
-@@ -870,9 +876,8 @@ static void bgmac_mac_speed(struct bgmac
- static void bgmac_miiconfig(struct bgmac *bgmac)
- {
- struct bcma_device *core = bgmac->core;
-- u8 imode;
-
-- if (bgmac_is_bcm4707_family(bgmac)) {
-+ if (bgmac->feature_flags & BGMAC_FEAT_FORCE_SPEED_2500) {
- bcma_awrite32(core, BCMA_IOCTL,
- bcma_aread32(core, BCMA_IOCTL) | 0x40 |
- BGMAC_BCMA_IOCTL_SW_CLKEN);
-@@ -880,6 +885,8 @@ static void bgmac_miiconfig(struct bgmac
- bgmac->mac_duplex = DUPLEX_FULL;
- bgmac_mac_speed(bgmac);
- } else {
-+ u8 imode;
-+
- imode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) &
- BGMAC_DS_MM_MASK) >> BGMAC_DS_MM_SHIFT;
- if (imode == 0 || imode == 1) {
-@@ -894,9 +901,7 @@ static void bgmac_miiconfig(struct bgmac
- static void bgmac_chip_reset(struct bgmac *bgmac)
- {
- struct bcma_device *core = bgmac->core;
-- struct bcma_bus *bus = core->bus;
-- struct bcma_chipinfo *ci = &bus->chipinfo;
-- u32 flags;
-+ u32 cmdcfg_sr;
- u32 iost;
- int i;
-
-@@ -919,15 +924,12 @@ static void bgmac_chip_reset(struct bgma
- }
-
- iost = bcma_aread32(core, BCMA_IOST);
-- if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM47186) ||
-- (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg == 10) ||
-- (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == BCMA_PKG_ID_BCM47188))
-+ if (bgmac->feature_flags & BGMAC_FEAT_IOST_ATTACHED)
- iost &= ~BGMAC_BCMA_IOST_ATTACHED;
-
- /* 3GMAC: for BCM4707 & BCM47094, only do core reset at bgmac_probe() */
-- if (ci->id != BCMA_CHIP_ID_BCM4707 &&
-- ci->id != BCMA_CHIP_ID_BCM47094) {
-- flags = 0;
-+ if (!(bgmac->feature_flags & BGMAC_FEAT_NO_RESET)) {
-+ u32 flags = 0;
- if (iost & BGMAC_BCMA_IOST_ATTACHED) {
- flags = BGMAC_BCMA_IOCTL_SW_CLKEN;
- if (!bgmac->has_robosw)
-@@ -937,7 +939,7 @@ static void bgmac_chip_reset(struct bgma
- }
-
- /* Request Misc PLL for corerev > 2 */
-- if (core->id.rev > 2 && !bgmac_is_bcm4707_family(bgmac)) {
-+ if (bgmac->feature_flags & BGMAC_FEAT_MISC_PLL_REQ) {
- bgmac_set(bgmac, BCMA_CLKCTLST,
- BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ);
- bgmac_wait_value(bgmac->core, BCMA_CLKCTLST,
-@@ -946,9 +948,7 @@ static void bgmac_chip_reset(struct bgma
- 1000);
- }
-
-- if (ci->id == BCMA_CHIP_ID_BCM5357 ||
-- ci->id == BCMA_CHIP_ID_BCM4749 ||
-- ci->id == BCMA_CHIP_ID_BCM53572) {
-+ if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_PHY) {
- struct bcma_drv_cc *cc = &bgmac->core->bus->drv_cc;
- u8 et_swtype = 0;
- u8 sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHY |
-@@ -962,11 +962,9 @@ static void bgmac_chip_reset(struct bgma
- et_swtype &= 0x0f;
- et_swtype <<= 4;
- sw_type = et_swtype;
-- } else if (ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM5358) {
-+ } else if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_EPHYRMII) {
- sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHYRMII;
-- } else if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM47186) ||
-- (ci->id == BCMA_CHIP_ID_BCM4749 && ci->pkg == 10) ||
-- (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == BCMA_PKG_ID_BCM47188)) {
-+ } else if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_RGMII) {
- sw_type = BGMAC_CHIPCTL_1_IF_TYPE_RGMII |
- BGMAC_CHIPCTL_1_SW_TYPE_RGMII;
- }
-@@ -986,6 +984,11 @@ static void bgmac_chip_reset(struct bgma
- * BGMAC_CMDCFG is read _after_ putting chip in a reset. So it has to
- * be keps until taking MAC out of the reset.
- */
-+ if (bgmac->feature_flags & BGMAC_FEAT_CMDCFG_SR_REV4)
-+ cmdcfg_sr = BGMAC_CMDCFG_SR_REV4;
-+ else
-+ cmdcfg_sr = BGMAC_CMDCFG_SR_REV0;
-+
- bgmac_cmdcfg_maskset(bgmac,
- ~(BGMAC_CMDCFG_TE |
- BGMAC_CMDCFG_RE |
-@@ -1003,13 +1006,13 @@ static void bgmac_chip_reset(struct bgma
- BGMAC_CMDCFG_PROM |
- BGMAC_CMDCFG_NLC |
- BGMAC_CMDCFG_CFE |
-- BGMAC_CMDCFG_SR(core->id.rev),
-+ cmdcfg_sr,
- false);
- bgmac->mac_speed = SPEED_UNKNOWN;
- bgmac->mac_duplex = DUPLEX_UNKNOWN;
-
- bgmac_clear_mib(bgmac);
-- if (core->id.id == BCMA_CORE_4706_MAC_GBIT)
-+ if (bgmac->feature_flags & BGMAC_FEAT_CMN_PHY_CTL)
- bcma_maskset32(bgmac->cmn, BCMA_GMAC_CMN_PHY_CTL, ~0,
- BCMA_GMAC_CMN_PC_MTE);
- else
-@@ -1035,46 +1038,48 @@ static void bgmac_chip_intrs_off(struct
- /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/gmac_enable */
- static void bgmac_enable(struct bgmac *bgmac)
- {
-- struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo;
-+ u32 cmdcfg_sr;
- u32 cmdcfg;
- u32 mode;
-- u32 rxq_ctl;
-- u32 fl_ctl;
-- u16 bp_clk;
-- u8 mdp;
-+
-+ if (bgmac->feature_flags & BGMAC_FEAT_CMDCFG_SR_REV4)
-+ cmdcfg_sr = BGMAC_CMDCFG_SR_REV4;
-+ else
-+ cmdcfg_sr = BGMAC_CMDCFG_SR_REV0;
-
- cmdcfg = bgmac_read(bgmac, BGMAC_CMDCFG);
- bgmac_cmdcfg_maskset(bgmac, ~(BGMAC_CMDCFG_TE | BGMAC_CMDCFG_RE),
-- BGMAC_CMDCFG_SR(bgmac->core->id.rev), true);
-+ cmdcfg_sr, true);
- udelay(2);
- cmdcfg |= BGMAC_CMDCFG_TE | BGMAC_CMDCFG_RE;
- bgmac_write(bgmac, BGMAC_CMDCFG, cmdcfg);
-
- mode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
- BGMAC_DS_MM_SHIFT;
-- if (ci->id != BCMA_CHIP_ID_BCM47162 || mode != 0)
-+ if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST || mode != 0)
- bgmac_set(bgmac, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
-- if (ci->id == BCMA_CHIP_ID_BCM47162 && mode == 2)
-+ if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST && mode == 2)
- bcma_chipco_chipctl_maskset(&bgmac->core->bus->drv_cc, 1, ~0,
- BGMAC_CHIPCTL_1_RXC_DLL_BYPASS);
-
-- switch (ci->id) {
-- case BCMA_CHIP_ID_BCM5357:
-- case BCMA_CHIP_ID_BCM4749:
-- case BCMA_CHIP_ID_BCM53572:
-- case BCMA_CHIP_ID_BCM4716:
-- case BCMA_CHIP_ID_BCM47162:
-- fl_ctl = 0x03cb04cb;
-- if (ci->id == BCMA_CHIP_ID_BCM5357 ||
-- ci->id == BCMA_CHIP_ID_BCM4749 ||
-- ci->id == BCMA_CHIP_ID_BCM53572)
-+ if (bgmac->feature_flags & (BGMAC_FEAT_FLW_CTRL1 |
-+ BGMAC_FEAT_FLW_CTRL2)) {
-+ u32 fl_ctl;
-+
-+ if (bgmac->feature_flags & BGMAC_FEAT_FLW_CTRL1)
- fl_ctl = 0x2300e1;
-+ else
-+ fl_ctl = 0x03cb04cb;
-+
- bgmac_write(bgmac, BGMAC_FLOW_CTL_THRESH, fl_ctl);
- bgmac_write(bgmac, BGMAC_PAUSE_CTL, 0x27fff);
-- break;
- }
-
-- if (!bgmac_is_bcm4707_family(bgmac)) {
-+ if (bgmac->feature_flags & BGMAC_FEAT_SET_RXQ_CLK) {
-+ u32 rxq_ctl;
-+ u16 bp_clk;
-+ u8 mdp;
-+
- rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
- rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
- bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) /
-@@ -1606,6 +1611,74 @@ static int bgmac_probe(struct bcma_devic
- if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
- dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
-
-+ /* Feature Flags */
-+ switch (core->bus->chipinfo.id) {
-+ case BCMA_CHIP_ID_BCM5357:
-+ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
-+ if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47186) {
-+ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
-+ }
-+ if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM5358)
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_EPHYRMII;
-+ break;
-+ case BCMA_CHIP_ID_BCM53572:
-+ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
-+ if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47188) {
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
-+ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
-+ }
-+ break;
-+ case BCMA_CHIP_ID_BCM4749:
-+ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
-+ if (core->bus->chipinfo.pkg == 10) {
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
-+ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
-+ }
-+ break;
-+ case BCMA_CHIP_ID_BCM4716:
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ /* fallthrough */
-+ case BCMA_CHIP_ID_BCM47162:
-+ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL2;
-+ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-+ break;
-+ /* bcm4707_family */
-+ case BCMA_CHIP_ID_BCM4707:
-+ case BCMA_CHIP_ID_BCM47094:
-+ case BCMA_CHIP_ID_BCM53018:
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
-+ bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
-+ break;
-+ default:
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-+ }
-+
-+ if (!bgmac_is_bcm4707_family(bgmac) && core->id.rev > 2)
-+ bgmac->feature_flags |= BGMAC_FEAT_MISC_PLL_REQ;
-+
-+ if (core->id.id == BCMA_CORE_4706_MAC_GBIT) {
-+ bgmac->feature_flags |= BGMAC_FEAT_CMN_PHY_CTL;
-+ bgmac->feature_flags |= BGMAC_FEAT_NO_CLR_MIB;
-+ }
-+
-+ if (core->id.rev >= 4) {
-+ bgmac->feature_flags |= BGMAC_FEAT_CMDCFG_SR_REV4;
-+ bgmac->feature_flags |= BGMAC_FEAT_TX_MASK_SETUP;
-+ bgmac->feature_flags |= BGMAC_FEAT_RX_MASK_SETUP;
-+ }
-+
- netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
-
- if (!bgmac_is_bcm4707_family(bgmac)) {
---- a/drivers/net/ethernet/broadcom/bgmac.h
-+++ b/drivers/net/ethernet/broadcom/bgmac.h
-@@ -190,7 +190,6 @@
- #define BGMAC_CMDCFG_HD_SHIFT 10
- #define BGMAC_CMDCFG_SR_REV0 0x00000800 /* Set to reset mode, for core rev 0-3 */
- #define BGMAC_CMDCFG_SR_REV4 0x00002000 /* Set to reset mode, for core rev >= 4 */
--#define BGMAC_CMDCFG_SR(rev) ((rev >= 4) ? BGMAC_CMDCFG_SR_REV4 : BGMAC_CMDCFG_SR_REV0)
- #define BGMAC_CMDCFG_ML 0x00008000 /* Set to activate mac loopback mode */
- #define BGMAC_CMDCFG_AE 0x00400000
- #define BGMAC_CMDCFG_CFE 0x00800000
-@@ -376,6 +375,24 @@
-
- #define ETHER_MAX_LEN 1518
-
-+/* Feature Flags */
-+#define BGMAC_FEAT_TX_MASK_SETUP BIT(0)
-+#define BGMAC_FEAT_RX_MASK_SETUP BIT(1)
-+#define BGMAC_FEAT_IOST_ATTACHED BIT(2)
-+#define BGMAC_FEAT_NO_RESET BIT(3)
-+#define BGMAC_FEAT_MISC_PLL_REQ BIT(4)
-+#define BGMAC_FEAT_SW_TYPE_PHY BIT(5)
-+#define BGMAC_FEAT_SW_TYPE_EPHYRMII BIT(6)
-+#define BGMAC_FEAT_SW_TYPE_RGMII BIT(7)
-+#define BGMAC_FEAT_CMN_PHY_CTL BIT(8)
-+#define BGMAC_FEAT_FLW_CTRL1 BIT(9)
-+#define BGMAC_FEAT_FLW_CTRL2 BIT(10)
-+#define BGMAC_FEAT_SET_RXQ_CLK BIT(11)
-+#define BGMAC_FEAT_CLKCTLST BIT(12)
-+#define BGMAC_FEAT_NO_CLR_MIB BIT(13)
-+#define BGMAC_FEAT_FORCE_SPEED_2500 BIT(14)
-+#define BGMAC_FEAT_CMDCFG_SR_REV4 BIT(15)
-+
- struct bgmac_slot_info {
- union {
- struct sk_buff *skb;
-@@ -430,6 +447,8 @@ struct bgmac {
-
- struct device *dev;
- struct device *dma_dev;
-+ u32 feature_flags;
-+
- struct net_device *net_dev;
- struct napi_struct napi;
- struct mii_bus *mii_bus;
+++ /dev/null
-From f6a95a24957aec5bb488c3f978c4ed508177998f Mon Sep 17 00:00:00 2001
-From: Jon Mason <jon.mason@broadcom.com>
-Date: Thu, 7 Jul 2016 19:08:57 -0400
-Subject: [PATCH 5/5] net: ethernet: bgmac: Add platform device support
-
-The bcma portion of the driver has been split off into a bcma specific
-driver. This has been mirrored for the platform driver. The last
-references to the bcma core struct have been changed into a generic
-function call. These function calls are wrappers to either the original
-bcma code or new platform functions that access the same areas via MMIO.
-This necessitated adding function pointers for both platform and bcma to
-hide which backend is being used from the generic bgmac code.
-
-Signed-off-by: Jon Mason <jon.mason@broadcom.com>
-Acked-by: Arnd Bergmann <arnd@arndb.de>
-Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-Tested-by: Florian Fainelli <f.fainelli@gmail.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/Kconfig | 23 +-
- drivers/net/ethernet/broadcom/Makefile | 4 +-
- drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c | 2 +
- drivers/net/ethernet/broadcom/bgmac-bcma.c | 315 +++++++++++++++++++++++
- drivers/net/ethernet/broadcom/bgmac-platform.c | 189 ++++++++++++++
- drivers/net/ethernet/broadcom/bgmac.c | 329 ++++--------------------
- drivers/net/ethernet/broadcom/bgmac.h | 73 +++++-
- 7 files changed, 650 insertions(+), 285 deletions(-)
- create mode 100644 drivers/net/ethernet/broadcom/bgmac-bcma.c
- create mode 100644 drivers/net/ethernet/broadcom/bgmac-platform.c
-
---- a/drivers/net/ethernet/broadcom/Kconfig
-+++ b/drivers/net/ethernet/broadcom/Kconfig
-@@ -150,10 +150,18 @@ config BNX2X_VXLAN
- Virtual eXtensible Local Area Network (VXLAN) in the driver.
-
- config BGMAC
-- tristate "BCMA bus GBit core support"
-+ tristate
-+ help
-+ This enables the integrated ethernet controller support for many
-+ Broadcom (mostly iProc) SoCs. An appropriate bus interface driver
-+ needs to be enabled to select this.
-+
-+config BGMAC_BCMA
-+ tristate "Broadcom iProc GBit BCMA support"
- depends on BCMA && BCMA_HOST_SOC
- depends on HAS_DMA
- depends on BCM47XX || ARCH_BCM_5301X || COMPILE_TEST
-+ select BGMAC
- select PHYLIB
- select FIXED_PHY
- ---help---
-@@ -162,6 +170,19 @@ config BGMAC
- In case of using this driver on BCM4706 it's also requires to enable
- BCMA_DRIVER_GMAC_CMN to make it work.
-
-+config BGMAC_PLATFORM
-+ tristate "Broadcom iProc GBit platform support"
-+ depends on HAS_DMA
-+ depends on ARCH_BCM_IPROC || COMPILE_TEST
-+ depends on OF
-+ select BGMAC
-+ select PHYLIB
-+ select FIXED_PHY
-+ default ARCH_BCM_IPROC
-+ ---help---
-+ Say Y here if you want to use the Broadcom iProc Gigabit Ethernet
-+ controller through the generic platform interface
-+
- config SYSTEMPORT
- tristate "Broadcom SYSTEMPORT internal MAC support"
- depends on OF
---- a/drivers/net/ethernet/broadcom/Makefile
-+++ b/drivers/net/ethernet/broadcom/Makefile
-@@ -10,6 +10,8 @@ obj-$(CONFIG_CNIC) += cnic.o
- obj-$(CONFIG_BNX2X) += bnx2x/
- obj-$(CONFIG_SB1250_MAC) += sb1250-mac.o
- obj-$(CONFIG_TIGON3) += tg3.o
--obj-$(CONFIG_BGMAC) += bgmac.o bgmac-bcma-mdio.o
-+obj-$(CONFIG_BGMAC) += bgmac.o
-+obj-$(CONFIG_BGMAC_BCMA) += bgmac-bcma.o bgmac-bcma-mdio.o
-+obj-$(CONFIG_BGMAC_PLATFORM) += bgmac-platform.o
- obj-$(CONFIG_SYSTEMPORT) += bcmsysport.o
- obj-$(CONFIG_BNXT) += bnxt/
---- a/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
-+++ b/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
-@@ -255,6 +255,7 @@ err:
- kfree(bcma_mdio);
- return ERR_PTR(err);
- }
-+EXPORT_SYMBOL_GPL(bcma_mdio_mii_register);
-
- void bcma_mdio_mii_unregister(struct mii_bus *mii_bus)
- {
-@@ -270,6 +271,7 @@ void bcma_mdio_mii_unregister(struct mii
- mdiobus_free(mii_bus);
- kfree(bcma_mdio);
- }
-+EXPORT_SYMBOL_GPL(bcma_mdio_mii_unregister);
-
- MODULE_AUTHOR("Rafał Miłecki");
- MODULE_LICENSE("GPL");
---- /dev/null
-+++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
-@@ -0,0 +1,315 @@
-+/*
-+ * Driver for (BCM4706)? GBit MAC core on BCMA bus.
-+ *
-+ * Copyright (C) 2012 Rafał Miłecki <zajec5@gmail.com>
-+ *
-+ * Licensed under the GNU/GPL. See COPYING for details.
-+ */
-+
-+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-+
-+#include <linux/bcma/bcma.h>
-+#include <linux/brcmphy.h>
-+#include <linux/etherdevice.h>
-+#include "bgmac.h"
-+
-+static inline bool bgmac_is_bcm4707_family(struct bcma_device *core)
-+{
-+ switch (core->bus->chipinfo.id) {
-+ case BCMA_CHIP_ID_BCM4707:
-+ case BCMA_CHIP_ID_BCM47094:
-+ case BCMA_CHIP_ID_BCM53018:
-+ return true;
-+ default:
-+ return false;
-+ }
-+}
-+
-+/**************************************************
-+ * BCMA bus ops
-+ **************************************************/
-+
-+static u32 bcma_bgmac_read(struct bgmac *bgmac, u16 offset)
-+{
-+ return bcma_read32(bgmac->bcma.core, offset);
-+}
-+
-+static void bcma_bgmac_write(struct bgmac *bgmac, u16 offset, u32 value)
-+{
-+ bcma_write32(bgmac->bcma.core, offset, value);
-+}
-+
-+static u32 bcma_bgmac_idm_read(struct bgmac *bgmac, u16 offset)
-+{
-+ return bcma_aread32(bgmac->bcma.core, offset);
-+}
-+
-+static void bcma_bgmac_idm_write(struct bgmac *bgmac, u16 offset, u32 value)
-+{
-+ return bcma_awrite32(bgmac->bcma.core, offset, value);
-+}
-+
-+static bool bcma_bgmac_clk_enabled(struct bgmac *bgmac)
-+{
-+ return bcma_core_is_enabled(bgmac->bcma.core);
-+}
-+
-+static void bcma_bgmac_clk_enable(struct bgmac *bgmac, u32 flags)
-+{
-+ bcma_core_enable(bgmac->bcma.core, flags);
-+}
-+
-+static void bcma_bgmac_cco_ctl_maskset(struct bgmac *bgmac, u32 offset,
-+ u32 mask, u32 set)
-+{
-+ struct bcma_drv_cc *cc = &bgmac->bcma.core->bus->drv_cc;
-+
-+ bcma_chipco_chipctl_maskset(cc, offset, mask, set);
-+}
-+
-+static u32 bcma_bgmac_get_bus_clock(struct bgmac *bgmac)
-+{
-+ struct bcma_drv_cc *cc = &bgmac->bcma.core->bus->drv_cc;
-+
-+ return bcma_pmu_get_bus_clock(cc);
-+}
-+
-+static void bcma_bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset, u32 mask,
-+ u32 set)
-+{
-+ bcma_maskset32(bgmac->bcma.cmn, offset, mask, set);
-+}
-+
-+static const struct bcma_device_id bgmac_bcma_tbl[] = {
-+ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_4706_MAC_GBIT,
-+ BCMA_ANY_REV, BCMA_ANY_CLASS),
-+ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_MAC_GBIT, BCMA_ANY_REV,
-+ BCMA_ANY_CLASS),
-+ {},
-+};
-+MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl);
-+
-+/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
-+static int bgmac_probe(struct bcma_device *core)
-+{
-+ struct ssb_sprom *sprom = &core->bus->sprom;
-+ struct mii_bus *mii_bus;
-+ struct bgmac *bgmac;
-+ u8 *mac;
-+ int err;
-+
-+ bgmac = kzalloc(sizeof(*bgmac), GFP_KERNEL);
-+ if (!bgmac)
-+ return -ENOMEM;
-+
-+ bgmac->bcma.core = core;
-+ bgmac->dev = &core->dev;
-+ bgmac->dma_dev = core->dma_dev;
-+ bgmac->irq = core->irq;
-+
-+ bcma_set_drvdata(core, bgmac);
-+
-+ switch (core->core_unit) {
-+ case 0:
-+ mac = sprom->et0mac;
-+ break;
-+ case 1:
-+ mac = sprom->et1mac;
-+ break;
-+ case 2:
-+ mac = sprom->et2mac;
-+ break;
-+ default:
-+ dev_err(bgmac->dev, "Unsupported core_unit %d\n",
-+ core->core_unit);
-+ err = -ENOTSUPP;
-+ goto err;
-+ }
-+
-+ ether_addr_copy(bgmac->mac_addr, mac);
-+
-+ /* On BCM4706 we need common core to access PHY */
-+ if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
-+ !core->bus->drv_gmac_cmn.core) {
-+ dev_err(bgmac->dev, "GMAC CMN core not found (required for BCM4706)\n");
-+ err = -ENODEV;
-+ goto err;
-+ }
-+ bgmac->bcma.cmn = core->bus->drv_gmac_cmn.core;
-+
-+ switch (core->core_unit) {
-+ case 0:
-+ bgmac->phyaddr = sprom->et0phyaddr;
-+ break;
-+ case 1:
-+ bgmac->phyaddr = sprom->et1phyaddr;
-+ break;
-+ case 2:
-+ bgmac->phyaddr = sprom->et2phyaddr;
-+ break;
-+ }
-+ bgmac->phyaddr &= BGMAC_PHY_MASK;
-+ if (bgmac->phyaddr == BGMAC_PHY_MASK) {
-+ dev_err(bgmac->dev, "No PHY found\n");
-+ err = -ENODEV;
-+ goto err;
-+ }
-+ dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
-+ bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
-+
-+ if (!bgmac_is_bcm4707_family(core)) {
-+ mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
-+ if (!IS_ERR(mii_bus)) {
-+ err = PTR_ERR(mii_bus);
-+ goto err;
-+ }
-+
-+ bgmac->mii_bus = mii_bus;
-+ }
-+
-+ if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) {
-+ dev_err(bgmac->dev, "PCI setup not implemented\n");
-+ err = -ENOTSUPP;
-+ goto err1;
-+ }
-+
-+ bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo &
-+ BGMAC_BFL_ENETROBO);
-+ if (bgmac->has_robosw)
-+ dev_warn(bgmac->dev, "Support for Roboswitch not implemented\n");
-+
-+ if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
-+ dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
-+
-+ /* Feature Flags */
-+ switch (core->bus->chipinfo.id) {
-+ case BCMA_CHIP_ID_BCM5357:
-+ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
-+ if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47186) {
-+ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
-+ }
-+ if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM5358)
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_EPHYRMII;
-+ break;
-+ case BCMA_CHIP_ID_BCM53572:
-+ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
-+ if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47188) {
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
-+ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
-+ }
-+ break;
-+ case BCMA_CHIP_ID_BCM4749:
-+ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
-+ if (core->bus->chipinfo.pkg == 10) {
-+ bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
-+ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
-+ }
-+ break;
-+ case BCMA_CHIP_ID_BCM4716:
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ /* fallthrough */
-+ case BCMA_CHIP_ID_BCM47162:
-+ bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL2;
-+ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-+ break;
-+ /* bcm4707_family */
-+ case BCMA_CHIP_ID_BCM4707:
-+ case BCMA_CHIP_ID_BCM47094:
-+ case BCMA_CHIP_ID_BCM53018:
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
-+ bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
-+ break;
-+ default:
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-+ }
-+
-+ if (!bgmac_is_bcm4707_family(core) && core->id.rev > 2)
-+ bgmac->feature_flags |= BGMAC_FEAT_MISC_PLL_REQ;
-+
-+ if (core->id.id == BCMA_CORE_4706_MAC_GBIT) {
-+ bgmac->feature_flags |= BGMAC_FEAT_CMN_PHY_CTL;
-+ bgmac->feature_flags |= BGMAC_FEAT_NO_CLR_MIB;
-+ }
-+
-+ if (core->id.rev >= 4) {
-+ bgmac->feature_flags |= BGMAC_FEAT_CMDCFG_SR_REV4;
-+ bgmac->feature_flags |= BGMAC_FEAT_TX_MASK_SETUP;
-+ bgmac->feature_flags |= BGMAC_FEAT_RX_MASK_SETUP;
-+ }
-+
-+ bgmac->read = bcma_bgmac_read;
-+ bgmac->write = bcma_bgmac_write;
-+ bgmac->idm_read = bcma_bgmac_idm_read;
-+ bgmac->idm_write = bcma_bgmac_idm_write;
-+ bgmac->clk_enabled = bcma_bgmac_clk_enabled;
-+ bgmac->clk_enable = bcma_bgmac_clk_enable;
-+ bgmac->cco_ctl_maskset = bcma_bgmac_cco_ctl_maskset;
-+ bgmac->get_bus_clock = bcma_bgmac_get_bus_clock;
-+ bgmac->cmn_maskset32 = bcma_bgmac_cmn_maskset32;
-+
-+ err = bgmac_enet_probe(bgmac);
-+ if (err)
-+ goto err1;
-+
-+ return 0;
-+
-+err1:
-+ bcma_mdio_mii_unregister(bgmac->mii_bus);
-+err:
-+ kfree(bgmac);
-+ bcma_set_drvdata(core, NULL);
-+
-+ return err;
-+}
-+
-+static void bgmac_remove(struct bcma_device *core)
-+{
-+ struct bgmac *bgmac = bcma_get_drvdata(core);
-+
-+ bcma_mdio_mii_unregister(bgmac->mii_bus);
-+ bgmac_enet_remove(bgmac);
-+ bcma_set_drvdata(core, NULL);
-+ kfree(bgmac);
-+}
-+
-+static struct bcma_driver bgmac_bcma_driver = {
-+ .name = KBUILD_MODNAME,
-+ .id_table = bgmac_bcma_tbl,
-+ .probe = bgmac_probe,
-+ .remove = bgmac_remove,
-+};
-+
-+static int __init bgmac_init(void)
-+{
-+ int err;
-+
-+ err = bcma_driver_register(&bgmac_bcma_driver);
-+ if (err)
-+ return err;
-+ pr_info("Broadcom 47xx GBit MAC driver loaded\n");
-+
-+ return 0;
-+}
-+
-+static void __exit bgmac_exit(void)
-+{
-+ bcma_driver_unregister(&bgmac_bcma_driver);
-+}
-+
-+module_init(bgmac_init)
-+module_exit(bgmac_exit)
-+
-+MODULE_AUTHOR("Rafał Miłecki");
-+MODULE_LICENSE("GPL");
---- /dev/null
-+++ b/drivers/net/ethernet/broadcom/bgmac-platform.c
-@@ -0,0 +1,189 @@
-+/*
-+ * Copyright (C) 2016 Broadcom
-+ *
-+ * This program is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU General Public License as
-+ * published by the Free Software Foundation version 2.
-+ *
-+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
-+ * kind, whether express or implied; without even the implied warranty
-+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
-+ */
-+
-+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-+
-+#include <linux/bcma/bcma.h>
-+#include <linux/etherdevice.h>
-+#include <linux/of_address.h>
-+#include <linux/of_net.h>
-+#include "bgmac.h"
-+
-+static u32 platform_bgmac_read(struct bgmac *bgmac, u16 offset)
-+{
-+ return readl(bgmac->plat.base + offset);
-+}
-+
-+static void platform_bgmac_write(struct bgmac *bgmac, u16 offset, u32 value)
-+{
-+ writel(value, bgmac->plat.base + offset);
-+}
-+
-+static u32 platform_bgmac_idm_read(struct bgmac *bgmac, u16 offset)
-+{
-+ return readl(bgmac->plat.idm_base + offset);
-+}
-+
-+static void platform_bgmac_idm_write(struct bgmac *bgmac, u16 offset, u32 value)
-+{
-+ return writel(value, bgmac->plat.idm_base + offset);
-+}
-+
-+static bool platform_bgmac_clk_enabled(struct bgmac *bgmac)
-+{
-+ if ((bgmac_idm_read(bgmac, BCMA_IOCTL) &
-+ (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC)) != BCMA_IOCTL_CLK)
-+ return false;
-+ if (bgmac_idm_read(bgmac, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
-+ return false;
-+ return true;
-+}
-+
-+static void platform_bgmac_clk_enable(struct bgmac *bgmac, u32 flags)
-+{
-+ bgmac_idm_write(bgmac, BCMA_IOCTL,
-+ (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC | flags));
-+ bgmac_idm_read(bgmac, BCMA_IOCTL);
-+
-+ bgmac_idm_write(bgmac, BCMA_RESET_CTL, 0);
-+ bgmac_idm_read(bgmac, BCMA_RESET_CTL);
-+ udelay(1);
-+
-+ bgmac_idm_write(bgmac, BCMA_IOCTL, (BCMA_IOCTL_CLK | flags));
-+ bgmac_idm_read(bgmac, BCMA_IOCTL);
-+ udelay(1);
-+}
-+
-+static void platform_bgmac_cco_ctl_maskset(struct bgmac *bgmac, u32 offset,
-+ u32 mask, u32 set)
-+{
-+ /* This shouldn't be encountered */
-+ WARN_ON(1);
-+}
-+
-+static u32 platform_bgmac_get_bus_clock(struct bgmac *bgmac)
-+{
-+ /* This shouldn't be encountered */
-+ WARN_ON(1);
-+
-+ return 0;
-+}
-+
-+static void platform_bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset,
-+ u32 mask, u32 set)
-+{
-+ /* This shouldn't be encountered */
-+ WARN_ON(1);
-+}
-+
-+static int bgmac_probe(struct platform_device *pdev)
-+{
-+ struct device_node *np = pdev->dev.of_node;
-+ struct bgmac *bgmac;
-+ struct resource *regs;
-+ const u8 *mac_addr;
-+
-+ bgmac = devm_kzalloc(&pdev->dev, sizeof(*bgmac), GFP_KERNEL);
-+ if (!bgmac)
-+ return -ENOMEM;
-+
-+ platform_set_drvdata(pdev, bgmac);
-+
-+ /* Set the features of the 4707 family */
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
-+ bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
-+ bgmac->feature_flags |= BGMAC_FEAT_CMDCFG_SR_REV4;
-+ bgmac->feature_flags |= BGMAC_FEAT_TX_MASK_SETUP;
-+ bgmac->feature_flags |= BGMAC_FEAT_RX_MASK_SETUP;
-+
-+ bgmac->dev = &pdev->dev;
-+ bgmac->dma_dev = &pdev->dev;
-+
-+ mac_addr = of_get_mac_address(np);
-+ if (mac_addr)
-+ ether_addr_copy(bgmac->mac_addr, mac_addr);
-+ else
-+ dev_warn(&pdev->dev, "MAC address not present in device tree\n");
-+
-+ bgmac->irq = platform_get_irq(pdev, 0);
-+ if (bgmac->irq < 0) {
-+ dev_err(&pdev->dev, "Unable to obtain IRQ\n");
-+ return bgmac->irq;
-+ }
-+
-+ regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "amac_base");
-+ if (!regs) {
-+ dev_err(&pdev->dev, "Unable to obtain base resource\n");
-+ return -EINVAL;
-+ }
-+
-+ bgmac->plat.base = devm_ioremap_resource(&pdev->dev, regs);
-+ if (IS_ERR(bgmac->plat.base)) {
-+ dev_err(&pdev->dev, "Unable to map base resource\n");
-+ return PTR_ERR(bgmac->plat.base);
-+ }
-+
-+ regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "idm_base");
-+ if (!regs) {
-+ dev_err(&pdev->dev, "Unable to obtain idm resource\n");
-+ return -EINVAL;
-+ }
-+
-+ bgmac->plat.idm_base = devm_ioremap_resource(&pdev->dev, regs);
-+ if (!bgmac->plat.idm_base) {
-+ dev_err(&pdev->dev, "Unable to map idm resource\n");
-+ return PTR_ERR(bgmac->plat.idm_base);
-+ }
-+
-+ bgmac->read = platform_bgmac_read;
-+ bgmac->write = platform_bgmac_write;
-+ bgmac->idm_read = platform_bgmac_idm_read;
-+ bgmac->idm_write = platform_bgmac_idm_write;
-+ bgmac->clk_enabled = platform_bgmac_clk_enabled;
-+ bgmac->clk_enable = platform_bgmac_clk_enable;
-+ bgmac->cco_ctl_maskset = platform_bgmac_cco_ctl_maskset;
-+ bgmac->get_bus_clock = platform_bgmac_get_bus_clock;
-+ bgmac->cmn_maskset32 = platform_bgmac_cmn_maskset32;
-+
-+ return bgmac_enet_probe(bgmac);
-+}
-+
-+static int bgmac_remove(struct platform_device *pdev)
-+{
-+ struct bgmac *bgmac = platform_get_drvdata(pdev);
-+
-+ bgmac_enet_remove(bgmac);
-+
-+ return 0;
-+}
-+
-+static const struct of_device_id bgmac_of_enet_match[] = {
-+ {.compatible = "brcm,amac",},
-+ {.compatible = "brcm,nsp-amac",},
-+ {},
-+};
-+
-+MODULE_DEVICE_TABLE(of, bgmac_of_enet_match);
-+
-+static struct platform_driver bgmac_enet_driver = {
-+ .driver = {
-+ .name = "bgmac-enet",
-+ .of_match_table = bgmac_of_enet_match,
-+ },
-+ .probe = bgmac_probe,
-+ .remove = bgmac_remove,
-+};
-+
-+module_platform_driver(bgmac_enet_driver);
-+MODULE_LICENSE("GPL");
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -6,51 +6,27 @@
- * Licensed under the GNU/GPL. See COPYING for details.
- */
-
--#include "bgmac.h"
-
--#include <linux/kernel.h>
--#include <linux/module.h>
--#include <linux/delay.h>
-+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-+
-+#include <linux/bcma/bcma.h>
- #include <linux/etherdevice.h>
--#include <linux/mii.h>
--#include <linux/phy.h>
--#include <linux/phy_fixed.h>
--#include <linux/interrupt.h>
--#include <linux/dma-mapping.h>
- #include <linux/bcm47xx_nvram.h>
-+#include "bgmac.h"
-
--static const struct bcma_device_id bgmac_bcma_tbl[] = {
-- BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_4706_MAC_GBIT, BCMA_ANY_REV, BCMA_ANY_CLASS),
-- BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_MAC_GBIT, BCMA_ANY_REV, BCMA_ANY_CLASS),
-- {},
--};
--MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl);
--
--static inline bool bgmac_is_bcm4707_family(struct bgmac *bgmac)
--{
-- switch (bgmac->core->bus->chipinfo.id) {
-- case BCMA_CHIP_ID_BCM4707:
-- case BCMA_CHIP_ID_BCM47094:
-- case BCMA_CHIP_ID_BCM53018:
-- return true;
-- default:
-- return false;
-- }
--}
--
--static bool bgmac_wait_value(struct bcma_device *core, u16 reg, u32 mask,
-+static bool bgmac_wait_value(struct bgmac *bgmac, u16 reg, u32 mask,
- u32 value, int timeout)
- {
- u32 val;
- int i;
-
- for (i = 0; i < timeout / 10; i++) {
-- val = bcma_read32(core, reg);
-+ val = bgmac_read(bgmac, reg);
- if ((val & mask) == value)
- return true;
- udelay(10);
- }
-- dev_err(&core->dev, "Timeout waiting for reg 0x%X\n", reg);
-+ dev_err(bgmac->dev, "Timeout waiting for reg 0x%X\n", reg);
- return false;
- }
-
-@@ -89,7 +65,7 @@ static void bgmac_dma_tx_reset(struct bg
-
- /* Remove SUSPEND bit */
- bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_CTL, 0);
-- if (!bgmac_wait_value(bgmac->core,
-+ if (!bgmac_wait_value(bgmac,
- ring->mmio_base + BGMAC_DMA_TX_STATUS,
- BGMAC_DMA_TX_STAT, BGMAC_DMA_TX_STAT_DISABLED,
- 10000)) {
-@@ -317,7 +293,7 @@ static void bgmac_dma_rx_reset(struct bg
- return;
-
- bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_CTL, 0);
-- if (!bgmac_wait_value(bgmac->core,
-+ if (!bgmac_wait_value(bgmac,
- ring->mmio_base + BGMAC_DMA_RX_STATUS,
- BGMAC_DMA_RX_STAT, BGMAC_DMA_RX_STAT_DISABLED,
- 10000))
-@@ -643,7 +619,7 @@ static int bgmac_dma_alloc(struct bgmac
- BUILD_BUG_ON(BGMAC_MAX_TX_RINGS > ARRAY_SIZE(ring_base));
- BUILD_BUG_ON(BGMAC_MAX_RX_RINGS > ARRAY_SIZE(ring_base));
-
-- if (!(bcma_aread32(bgmac->core, BCMA_IOST) & BCMA_IOST_DMA64)) {
-+ if (!(bgmac_idm_read(bgmac, BCMA_IOST) & BCMA_IOST_DMA64)) {
- dev_err(bgmac->dev, "Core does not report 64-bit DMA\n");
- return -ENOTSUPP;
- }
-@@ -875,12 +851,10 @@ static void bgmac_mac_speed(struct bgmac
-
- static void bgmac_miiconfig(struct bgmac *bgmac)
- {
-- struct bcma_device *core = bgmac->core;
--
- if (bgmac->feature_flags & BGMAC_FEAT_FORCE_SPEED_2500) {
-- bcma_awrite32(core, BCMA_IOCTL,
-- bcma_aread32(core, BCMA_IOCTL) | 0x40 |
-- BGMAC_BCMA_IOCTL_SW_CLKEN);
-+ bgmac_idm_write(bgmac, BCMA_IOCTL,
-+ bgmac_idm_read(bgmac, BCMA_IOCTL) | 0x40 |
-+ BGMAC_BCMA_IOCTL_SW_CLKEN);
- bgmac->mac_speed = SPEED_2500;
- bgmac->mac_duplex = DUPLEX_FULL;
- bgmac_mac_speed(bgmac);
-@@ -900,12 +874,11 @@ static void bgmac_miiconfig(struct bgmac
- /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipreset */
- static void bgmac_chip_reset(struct bgmac *bgmac)
- {
-- struct bcma_device *core = bgmac->core;
- u32 cmdcfg_sr;
- u32 iost;
- int i;
-
-- if (bcma_core_is_enabled(core)) {
-+ if (bgmac_clk_enabled(bgmac)) {
- if (!bgmac->stats_grabbed) {
- /* bgmac_chip_stats_update(bgmac); */
- bgmac->stats_grabbed = true;
-@@ -923,7 +896,7 @@ static void bgmac_chip_reset(struct bgma
- /* TODO: Clear software multicast filter list */
- }
-
-- iost = bcma_aread32(core, BCMA_IOST);
-+ iost = bgmac_idm_read(bgmac, BCMA_IOST);
- if (bgmac->feature_flags & BGMAC_FEAT_IOST_ATTACHED)
- iost &= ~BGMAC_BCMA_IOST_ATTACHED;
-
-@@ -935,21 +908,20 @@ static void bgmac_chip_reset(struct bgma
- if (!bgmac->has_robosw)
- flags |= BGMAC_BCMA_IOCTL_SW_RESET;
- }
-- bcma_core_enable(core, flags);
-+ bgmac_clk_enable(bgmac, flags);
- }
-
- /* Request Misc PLL for corerev > 2 */
- if (bgmac->feature_flags & BGMAC_FEAT_MISC_PLL_REQ) {
- bgmac_set(bgmac, BCMA_CLKCTLST,
- BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ);
-- bgmac_wait_value(bgmac->core, BCMA_CLKCTLST,
-+ bgmac_wait_value(bgmac, BCMA_CLKCTLST,
- BGMAC_BCMA_CLKCTLST_MISC_PLL_ST,
- BGMAC_BCMA_CLKCTLST_MISC_PLL_ST,
- 1000);
- }
-
- if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_PHY) {
-- struct bcma_drv_cc *cc = &bgmac->core->bus->drv_cc;
- u8 et_swtype = 0;
- u8 sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHY |
- BGMAC_CHIPCTL_1_IF_TYPE_MII;
-@@ -968,16 +940,15 @@ static void bgmac_chip_reset(struct bgma
- sw_type = BGMAC_CHIPCTL_1_IF_TYPE_RGMII |
- BGMAC_CHIPCTL_1_SW_TYPE_RGMII;
- }
-- bcma_chipco_chipctl_maskset(cc, 1,
-- ~(BGMAC_CHIPCTL_1_IF_TYPE_MASK |
-- BGMAC_CHIPCTL_1_SW_TYPE_MASK),
-- sw_type);
-+ bgmac_cco_ctl_maskset(bgmac, 1, ~(BGMAC_CHIPCTL_1_IF_TYPE_MASK |
-+ BGMAC_CHIPCTL_1_SW_TYPE_MASK),
-+ sw_type);
- }
-
- if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw)
-- bcma_awrite32(core, BCMA_IOCTL,
-- bcma_aread32(core, BCMA_IOCTL) &
-- ~BGMAC_BCMA_IOCTL_SW_RESET);
-+ bgmac_idm_write(bgmac, BCMA_IOCTL,
-+ bgmac_idm_read(bgmac, BCMA_IOCTL) &
-+ ~BGMAC_BCMA_IOCTL_SW_RESET);
-
- /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/gmac_reset
- * Specs don't say about using BGMAC_CMDCFG_SR, but in this routine
-@@ -1013,8 +984,8 @@ static void bgmac_chip_reset(struct bgma
-
- bgmac_clear_mib(bgmac);
- if (bgmac->feature_flags & BGMAC_FEAT_CMN_PHY_CTL)
-- bcma_maskset32(bgmac->cmn, BCMA_GMAC_CMN_PHY_CTL, ~0,
-- BCMA_GMAC_CMN_PC_MTE);
-+ bgmac_cmn_maskset32(bgmac, BCMA_GMAC_CMN_PHY_CTL, ~0,
-+ BCMA_GMAC_CMN_PC_MTE);
- else
- bgmac_set(bgmac, BGMAC_PHY_CNTL, BGMAC_PC_MTE);
- bgmac_miiconfig(bgmac);
-@@ -1059,8 +1030,8 @@ static void bgmac_enable(struct bgmac *b
- if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST || mode != 0)
- bgmac_set(bgmac, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
- if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST && mode == 2)
-- bcma_chipco_chipctl_maskset(&bgmac->core->bus->drv_cc, 1, ~0,
-- BGMAC_CHIPCTL_1_RXC_DLL_BYPASS);
-+ bgmac_cco_ctl_maskset(bgmac, 1, ~0,
-+ BGMAC_CHIPCTL_1_RXC_DLL_BYPASS);
-
- if (bgmac->feature_flags & (BGMAC_FEAT_FLW_CTRL1 |
- BGMAC_FEAT_FLW_CTRL2)) {
-@@ -1082,8 +1053,7 @@ static void bgmac_enable(struct bgmac *b
-
- rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
- rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
-- bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) /
-- 1000000;
-+ bp_clk = bgmac_get_bus_clock(bgmac) / 1000000;
- mdp = (bp_clk * 128 / 1000) - 3;
- rxq_ctl |= (mdp << BGMAC_RXQ_CTL_MDP_SHIFT);
- bgmac_write(bgmac, BGMAC_RXQ_CTL, rxq_ctl);
-@@ -1178,7 +1148,7 @@ static int bgmac_open(struct net_device
- /* Specs say about reclaiming rings here, but we do that in DMA init */
- bgmac_chip_init(bgmac);
-
-- err = request_irq(bgmac->core->irq, bgmac_interrupt, IRQF_SHARED,
-+ err = request_irq(bgmac->irq, bgmac_interrupt, IRQF_SHARED,
- KBUILD_MODNAME, net_dev);
- if (err < 0) {
- dev_err(bgmac->dev, "IRQ request error: %d!\n", err);
-@@ -1204,7 +1174,7 @@ static int bgmac_stop(struct net_device
-
- napi_disable(&bgmac->napi);
- bgmac_chip_intrs_off(bgmac);
-- free_irq(bgmac->core->irq, net_dev);
-+ free_irq(bgmac->irq, net_dev);
-
- bgmac_chip_reset(bgmac);
- bgmac_dma_cleanup(bgmac);
-@@ -1399,7 +1369,7 @@ static void bgmac_get_drvinfo(struct net
- struct ethtool_drvinfo *info)
- {
- strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
-- strlcpy(info->bus_info, "BCMA", sizeof(info->bus_info));
-+ strlcpy(info->bus_info, "AXI", sizeof(info->bus_info));
- }
-
- static const struct ethtool_ops bgmac_ethtool_ops = {
-@@ -1483,116 +1453,41 @@ static int bgmac_phy_connect(struct bgma
- return 0;
- }
-
--static int bgmac_probe(struct bcma_device *core)
-+int bgmac_enet_probe(struct bgmac *info)
- {
- struct net_device *net_dev;
- struct bgmac *bgmac;
-- struct ssb_sprom *sprom = &core->bus->sprom;
-- u8 *mac;
- int err;
-
-- switch (core->core_unit) {
-- case 0:
-- mac = sprom->et0mac;
-- break;
-- case 1:
-- mac = sprom->et1mac;
-- break;
-- case 2:
-- mac = sprom->et2mac;
-- break;
-- default:
-- dev_err(&core->dev, "Unsupported core_unit %d\n",
-- core->core_unit);
-- return -ENOTSUPP;
-- }
--
-- if (!is_valid_ether_addr(mac)) {
-- dev_err(&core->dev, "Invalid MAC addr: %pM\n", mac);
-- eth_random_addr(mac);
-- dev_warn(&core->dev, "Using random MAC: %pM\n", mac);
-- }
--
-- /* This (reset &) enable is not preset in specs or reference driver but
-- * Broadcom does it in arch PCI code when enabling fake PCI device.
-- */
-- bcma_core_enable(core, 0);
--
- /* Allocation and references */
- net_dev = alloc_etherdev(sizeof(*bgmac));
- if (!net_dev)
- return -ENOMEM;
-+
- net_dev->netdev_ops = &bgmac_netdev_ops;
-- net_dev->irq = core->irq;
- net_dev->ethtool_ops = &bgmac_ethtool_ops;
- bgmac = netdev_priv(net_dev);
-- bgmac->dev = &core->dev;
-- bgmac->dma_dev = core->dma_dev;
-+ memcpy(bgmac, info, sizeof(*bgmac));
- bgmac->net_dev = net_dev;
-- bgmac->core = core;
-- bcma_set_drvdata(core, bgmac);
-- SET_NETDEV_DEV(net_dev, &core->dev);
--
-- /* Defaults */
-- memcpy(bgmac->net_dev->dev_addr, mac, ETH_ALEN);
--
-- /* On BCM4706 we need common core to access PHY */
-- if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
-- !core->bus->drv_gmac_cmn.core) {
-- dev_err(bgmac->dev, "GMAC CMN core not found (required for BCM4706)\n");
-- err = -ENODEV;
-- goto err_netdev_free;
-- }
-- bgmac->cmn = core->bus->drv_gmac_cmn.core;
-+ net_dev->irq = bgmac->irq;
-+ SET_NETDEV_DEV(net_dev, bgmac->dev);
-
-- switch (core->core_unit) {
-- case 0:
-- bgmac->phyaddr = sprom->et0phyaddr;
-- break;
-- case 1:
-- bgmac->phyaddr = sprom->et1phyaddr;
-- break;
-- case 2:
-- bgmac->phyaddr = sprom->et2phyaddr;
-- break;
-+ if (!is_valid_ether_addr(bgmac->mac_addr)) {
-+ dev_err(bgmac->dev, "Invalid MAC addr: %pM\n",
-+ bgmac->mac_addr);
-+ eth_random_addr(bgmac->mac_addr);
-+ dev_warn(bgmac->dev, "Using random MAC: %pM\n",
-+ bgmac->mac_addr);
- }
-- bgmac->phyaddr &= BGMAC_PHY_MASK;
-- if (bgmac->phyaddr == BGMAC_PHY_MASK) {
-- dev_err(bgmac->dev, "No PHY found\n");
-- err = -ENODEV;
-- goto err_netdev_free;
-- }
-- dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
-- bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
-+ ether_addr_copy(net_dev->dev_addr, bgmac->mac_addr);
-
-- if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) {
-- dev_err(bgmac->dev, "PCI setup not implemented\n");
-- err = -ENOTSUPP;
-- goto err_netdev_free;
-- }
-+ /* This (reset &) enable is not preset in specs or reference driver but
-+ * Broadcom does it in arch PCI code when enabling fake PCI device.
-+ */
-+ bgmac_clk_enable(bgmac, 0);
-
- bgmac_chip_reset(bgmac);
-
-- /* For Northstar, we have to take all GMAC core out of reset */
-- if (bgmac_is_bcm4707_family(bgmac)) {
-- struct bcma_device *ns_core;
-- int ns_gmac;
--
-- /* Northstar has 4 GMAC cores */
-- for (ns_gmac = 0; ns_gmac < 4; ns_gmac++) {
-- /* As Northstar requirement, we have to reset all GMACs
-- * before accessing one. bgmac_chip_reset() call
-- * bcma_core_enable() for this core. Then the other
-- * three GMACs didn't reset. We do it here.
-- */
-- ns_core = bcma_find_core_unit(core->bus,
-- BCMA_CORE_MAC_GBIT,
-- ns_gmac);
-- if (ns_core && !bcma_core_is_enabled(ns_core))
-- bcma_core_enable(ns_core, 0);
-- }
-- }
--
- err = bgmac_dma_alloc(bgmac);
- if (err) {
- dev_err(bgmac->dev, "Unable to alloc memory for DMA\n");
-@@ -1603,103 +1498,15 @@ static int bgmac_probe(struct bcma_devic
- if (bcm47xx_nvram_getenv("et0_no_txint", NULL, 0) == 0)
- bgmac->int_mask &= ~BGMAC_IS_TX_MASK;
-
-- bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo &
-- BGMAC_BFL_ENETROBO);
-- if (bgmac->has_robosw)
-- dev_warn(bgmac->dev, "Support for Roboswitch not implemented\n");
--
-- if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
-- dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
--
-- /* Feature Flags */
-- switch (core->bus->chipinfo.id) {
-- case BCMA_CHIP_ID_BCM5357:
-- bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-- bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-- bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
-- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
-- if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47186) {
-- bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
-- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
-- }
-- if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM5358)
-- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_EPHYRMII;
-- break;
-- case BCMA_CHIP_ID_BCM53572:
-- bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-- bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-- bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
-- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
-- if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47188) {
-- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
-- bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
-- }
-- break;
-- case BCMA_CHIP_ID_BCM4749:
-- bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-- bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-- bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
-- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
-- if (core->bus->chipinfo.pkg == 10) {
-- bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
-- bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
-- }
-- break;
-- case BCMA_CHIP_ID_BCM4716:
-- bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-- /* fallthrough */
-- case BCMA_CHIP_ID_BCM47162:
-- bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL2;
-- bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-- break;
-- /* bcm4707_family */
-- case BCMA_CHIP_ID_BCM4707:
-- case BCMA_CHIP_ID_BCM47094:
-- case BCMA_CHIP_ID_BCM53018:
-- bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-- bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
-- bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
-- break;
-- default:
-- bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-- bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-- }
--
-- if (!bgmac_is_bcm4707_family(bgmac) && core->id.rev > 2)
-- bgmac->feature_flags |= BGMAC_FEAT_MISC_PLL_REQ;
--
-- if (core->id.id == BCMA_CORE_4706_MAC_GBIT) {
-- bgmac->feature_flags |= BGMAC_FEAT_CMN_PHY_CTL;
-- bgmac->feature_flags |= BGMAC_FEAT_NO_CLR_MIB;
-- }
--
-- if (core->id.rev >= 4) {
-- bgmac->feature_flags |= BGMAC_FEAT_CMDCFG_SR_REV4;
-- bgmac->feature_flags |= BGMAC_FEAT_TX_MASK_SETUP;
-- bgmac->feature_flags |= BGMAC_FEAT_RX_MASK_SETUP;
-- }
--
- netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
-
-- if (!bgmac_is_bcm4707_family(bgmac)) {
-- struct mii_bus *mii_bus;
--
-- mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
-- if (!IS_ERR(mii_bus)) {
-- err = PTR_ERR(mii_bus);
-- goto err_dma_free;
-- }
--
-- bgmac->mii_bus = mii_bus;
-- }
--
- if (!bgmac->mii_bus)
- err = bgmac_phy_connect_direct(bgmac);
- else
- err = bgmac_phy_connect(bgmac);
- if (err) {
- dev_err(bgmac->dev, "Cannot connect to phy\n");
-- goto err_mii_unregister;
-+ goto err_dma_free;
- }
-
- net_dev->features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
-@@ -1718,56 +1525,24 @@ static int bgmac_probe(struct bcma_devic
-
- err_phy_disconnect:
- phy_disconnect(net_dev->phydev);
--err_mii_unregister:
-- bcma_mdio_mii_unregister(bgmac->mii_bus);
- err_dma_free:
- bgmac_dma_free(bgmac);
- err_netdev_free:
-- bcma_set_drvdata(core, NULL);
- free_netdev(net_dev);
-
- return err;
- }
-+EXPORT_SYMBOL_GPL(bgmac_enet_probe);
-
--static void bgmac_remove(struct bcma_device *core)
-+void bgmac_enet_remove(struct bgmac *bgmac)
- {
-- struct bgmac *bgmac = bcma_get_drvdata(core);
--
- unregister_netdev(bgmac->net_dev);
- phy_disconnect(bgmac->net_dev->phydev);
-- bcma_mdio_mii_unregister(bgmac->mii_bus);
- netif_napi_del(&bgmac->napi);
- bgmac_dma_free(bgmac);
-- bcma_set_drvdata(core, NULL);
- free_netdev(bgmac->net_dev);
- }
--
--static struct bcma_driver bgmac_bcma_driver = {
-- .name = KBUILD_MODNAME,
-- .id_table = bgmac_bcma_tbl,
-- .probe = bgmac_probe,
-- .remove = bgmac_remove,
--};
--
--static int __init bgmac_init(void)
--{
-- int err;
--
-- err = bcma_driver_register(&bgmac_bcma_driver);
-- if (err)
-- return err;
-- pr_info("Broadcom 47xx GBit MAC driver loaded\n");
--
-- return 0;
--}
--
--static void __exit bgmac_exit(void)
--{
-- bcma_driver_unregister(&bgmac_bcma_driver);
--}
--
--module_init(bgmac_init)
--module_exit(bgmac_exit)
-+EXPORT_SYMBOL_GPL(bgmac_enet_remove);
-
- MODULE_AUTHOR("Rafał Miłecki");
- MODULE_LICENSE("GPL");
---- a/drivers/net/ethernet/broadcom/bgmac.h
-+++ b/drivers/net/ethernet/broadcom/bgmac.h
-@@ -1,8 +1,6 @@
- #ifndef _BGMAC_H
- #define _BGMAC_H
-
--#include <linux/bcma/bcma.h>
--#include <linux/brcmphy.h>
- #include <linux/netdevice.h>
-
- #define BGMAC_DEV_CTL 0x000
-@@ -442,11 +440,21 @@ struct bgmac_rx_header {
- };
-
- struct bgmac {
-- struct bcma_device *core;
-- struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
-+ union {
-+ struct {
-+ void *base;
-+ void *idm_base;
-+ } plat;
-+ struct {
-+ struct bcma_device *core;
-+ /* Reference to CMN core for BCM4706 */
-+ struct bcma_device *cmn;
-+ } bcma;
-+ };
-
- struct device *dev;
- struct device *dma_dev;
-+ unsigned char mac_addr[ETH_ALEN];
- u32 feature_flags;
-
- struct net_device *net_dev;
-@@ -463,6 +471,7 @@ struct bgmac {
- u32 mib_rx_regs[BGMAC_NUM_MIB_RX_REGS];
-
- /* Int */
-+ int irq;
- u32 int_mask;
-
- /* Current MAC state */
-@@ -473,19 +482,71 @@ struct bgmac {
- bool has_robosw;
-
- bool loopback;
-+
-+ u32 (*read)(struct bgmac *bgmac, u16 offset);
-+ void (*write)(struct bgmac *bgmac, u16 offset, u32 value);
-+ u32 (*idm_read)(struct bgmac *bgmac, u16 offset);
-+ void (*idm_write)(struct bgmac *bgmac, u16 offset, u32 value);
-+ bool (*clk_enabled)(struct bgmac *bgmac);
-+ void (*clk_enable)(struct bgmac *bgmac, u32 flags);
-+ void (*cco_ctl_maskset)(struct bgmac *bgmac, u32 offset, u32 mask,
-+ u32 set);
-+ u32 (*get_bus_clock)(struct bgmac *bgmac);
-+ void (*cmn_maskset32)(struct bgmac *bgmac, u16 offset, u32 mask,
-+ u32 set);
- };
-
-+int bgmac_enet_probe(struct bgmac *info);
-+void bgmac_enet_remove(struct bgmac *bgmac);
-+
- struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr);
- void bcma_mdio_mii_unregister(struct mii_bus *mii_bus);
-
- static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset)
- {
-- return bcma_read32(bgmac->core, offset);
-+ return bgmac->read(bgmac, offset);
- }
-
- static inline void bgmac_write(struct bgmac *bgmac, u16 offset, u32 value)
- {
-- bcma_write32(bgmac->core, offset, value);
-+ bgmac->write(bgmac, offset, value);
-+}
-+
-+static inline u32 bgmac_idm_read(struct bgmac *bgmac, u16 offset)
-+{
-+ return bgmac->idm_read(bgmac, offset);
-+}
-+
-+static inline void bgmac_idm_write(struct bgmac *bgmac, u16 offset, u32 value)
-+{
-+ bgmac->idm_write(bgmac, offset, value);
-+}
-+
-+static inline bool bgmac_clk_enabled(struct bgmac *bgmac)
-+{
-+ return bgmac->clk_enabled(bgmac);
-+}
-+
-+static inline void bgmac_clk_enable(struct bgmac *bgmac, u32 flags)
-+{
-+ bgmac->clk_enable(bgmac, flags);
-+}
-+
-+static inline void bgmac_cco_ctl_maskset(struct bgmac *bgmac, u32 offset,
-+ u32 mask, u32 set)
-+{
-+ bgmac->cco_ctl_maskset(bgmac, offset, mask, set);
-+}
-+
-+static inline u32 bgmac_get_bus_clock(struct bgmac *bgmac)
-+{
-+ return bgmac->get_bus_clock(bgmac);
-+}
-+
-+static inline void bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset,
-+ u32 mask, u32 set)
-+{
-+ bgmac->cmn_maskset32(bgmac, offset, mask, set);
- }
-
- static inline void bgmac_maskset(struct bgmac *bgmac, u16 offset, u32 mask,
+++ /dev/null
-From 12c2e32f14da857b58af281b029d4549d24c3292 Mon Sep 17 00:00:00 2001
-From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
-Date: Tue, 12 Jul 2016 00:17:28 +0000
-Subject: [PATCH] net: ethernet: bgmac: Fix return value check in bgmac_probe()
-
-In case of error, the function devm_ioremap_resource() returns ERR_PTR()
-and never returns NULL. The NULL test in the return value check should be
-replaced with IS_ERR().
-
-Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac-platform.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac-platform.c
-+++ b/drivers/net/ethernet/broadcom/bgmac-platform.c
-@@ -141,7 +141,7 @@ static int bgmac_probe(struct platform_d
- }
-
- bgmac->plat.idm_base = devm_ioremap_resource(&pdev->dev, regs);
-- if (!bgmac->plat.idm_base) {
-+ if (IS_ERR(bgmac->plat.idm_base)) {
- dev_err(&pdev->dev, "Unable to map idm resource\n");
- return PTR_ERR(bgmac->plat.idm_base);
- }
+++ /dev/null
-From ce3a380dddd0cb16cb3d8d947b69657d7646c121 Mon Sep 17 00:00:00 2001
-From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
-Date: Wed, 13 Jul 2016 12:46:57 +0000
-Subject: [PATCH] net: ethernet: bgmac: Remove redundant dev_err call in
- bgmac_probe()
-
-There is a error message within devm_ioremap_resource
-already, so remove the dev_err call to avoid redundant
-error message.
-
-Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac-platform.c | 8 ++------
- 1 file changed, 2 insertions(+), 6 deletions(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac-platform.c
-+++ b/drivers/net/ethernet/broadcom/bgmac-platform.c
-@@ -129,10 +129,8 @@ static int bgmac_probe(struct platform_d
- }
-
- bgmac->plat.base = devm_ioremap_resource(&pdev->dev, regs);
-- if (IS_ERR(bgmac->plat.base)) {
-- dev_err(&pdev->dev, "Unable to map base resource\n");
-+ if (IS_ERR(bgmac->plat.base))
- return PTR_ERR(bgmac->plat.base);
-- }
-
- regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "idm_base");
- if (!regs) {
-@@ -141,10 +139,8 @@ static int bgmac_probe(struct platform_d
- }
-
- bgmac->plat.idm_base = devm_ioremap_resource(&pdev->dev, regs);
-- if (IS_ERR(bgmac->plat.idm_base)) {
-- dev_err(&pdev->dev, "Unable to map idm resource\n");
-+ if (IS_ERR(bgmac->plat.idm_base))
- return PTR_ERR(bgmac->plat.idm_base);
-- }
-
- bgmac->read = platform_bgmac_read;
- bgmac->write = platform_bgmac_write;
+++ /dev/null
-From b9f63ae7ba2de2ba19137c5757c0607ce40f3ed5 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
-Date: Wed, 17 Aug 2016 15:37:14 +0200
-Subject: [PATCH] net: bgmac: fix reversed check for MII registration error
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-It was failing on successful registration returning meaningless errors.
-
-Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-Fixes: 55954f3bfdac ("net: ethernet: bgmac: move BCMA MDIO Phy code into a separate file")
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac-bcma.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
-+++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
-@@ -159,7 +159,7 @@ static int bgmac_probe(struct bcma_devic
-
- if (!bgmac_is_bcm4707_family(core)) {
- mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
-- if (!IS_ERR(mii_bus)) {
-+ if (IS_ERR(mii_bus)) {
- err = PTR_ERR(mii_bus);
- goto err;
- }
+++ /dev/null
-From 1cb94db3d1bfe0075bde78fb2989f17e0a8a3936 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
-Date: Wed, 17 Aug 2016 23:00:30 +0200
-Subject: [PATCH] net: bgmac: support Ethernet core on BCM53573 SoCs
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-BCM53573 is a new series of Broadcom's SoCs. It's based on ARM and can
-be found in two packages (versions): BCM53573 and BCM47189. It shares
-some code with the Northstar family, but also requires some new quirks.
-
-First of all there can be up to 2 Ethernet cores on this SoC. If that is
-the case, they are connected to two different switch ports allowing some
-more complex/optimized setups. It seems the second unit doesn't come
-fully configured and requires some IRQ quirk.
-
-Other than that only the first core is connected to the PHY. For the
-second one we have to register fixed PHY (similarly to the Northstar),
-otherwise generic PHY driver would get some invalid info.
-
-This has been successfully tested on Tenda AC9 (BCM47189B0).
-
-Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac-bcma.c | 19 ++++++++++++++++++-
- drivers/net/ethernet/broadcom/bgmac.c | 25 +++++++++++++++++++++++++
- drivers/net/ethernet/broadcom/bgmac.h | 19 +++++++++++++++++++
- include/linux/bcma/bcma.h | 3 +++
- include/linux/bcma/bcma_regs.h | 1 +
- 5 files changed, 66 insertions(+), 1 deletion(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
-+++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
-@@ -92,6 +92,7 @@ MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl
- /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
- static int bgmac_probe(struct bcma_device *core)
- {
-+ struct bcma_chipinfo *ci = &core->bus->chipinfo;
- struct ssb_sprom *sprom = &core->bus->sprom;
- struct mii_bus *mii_bus;
- struct bgmac *bgmac;
-@@ -157,7 +158,8 @@ static int bgmac_probe(struct bcma_devic
- dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
- bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
-
-- if (!bgmac_is_bcm4707_family(core)) {
-+ if (!bgmac_is_bcm4707_family(core) &&
-+ !(ci->id == BCMA_CHIP_ID_BCM53573 && core->core_unit == 1)) {
- mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
- if (IS_ERR(mii_bus)) {
- err = PTR_ERR(mii_bus);
-@@ -230,6 +232,21 @@ static int bgmac_probe(struct bcma_devic
- bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
- bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
- break;
-+ case BCMA_CHIP_ID_BCM53573:
-+ bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-+ bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
-+ if (ci->pkg == BCMA_PKG_ID_BCM47189)
-+ bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
-+ if (core->core_unit == 0) {
-+ bgmac->feature_flags |= BGMAC_FEAT_CC4_IF_SW_TYPE;
-+ if (ci->pkg == BCMA_PKG_ID_BCM47189)
-+ bgmac->feature_flags |=
-+ BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII;
-+ } else if (core->core_unit == 1) {
-+ bgmac->feature_flags |= BGMAC_FEAT_IRQ_ID_OOB_6;
-+ bgmac->feature_flags |= BGMAC_FEAT_CC7_IF_TYPE_RGMII;
-+ }
-+ break;
- default:
- bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
- bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -943,6 +943,27 @@ static void bgmac_chip_reset(struct bgma
- bgmac_cco_ctl_maskset(bgmac, 1, ~(BGMAC_CHIPCTL_1_IF_TYPE_MASK |
- BGMAC_CHIPCTL_1_SW_TYPE_MASK),
- sw_type);
-+ } else if (bgmac->feature_flags & BGMAC_FEAT_CC4_IF_SW_TYPE) {
-+ u32 sw_type = BGMAC_CHIPCTL_4_IF_TYPE_MII |
-+ BGMAC_CHIPCTL_4_SW_TYPE_EPHY;
-+ u8 et_swtype = 0;
-+ char buf[4];
-+
-+ if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
-+ if (kstrtou8(buf, 0, &et_swtype))
-+ dev_err(bgmac->dev, "Failed to parse et_swtype (%s)\n",
-+ buf);
-+ sw_type = (et_swtype & 0x0f) << 12;
-+ } else if (bgmac->feature_flags & BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII) {
-+ sw_type = BGMAC_CHIPCTL_4_IF_TYPE_RGMII |
-+ BGMAC_CHIPCTL_4_SW_TYPE_RGMII;
-+ }
-+ bgmac_cco_ctl_maskset(bgmac, 4, ~(BGMAC_CHIPCTL_4_IF_TYPE_MASK |
-+ BGMAC_CHIPCTL_4_SW_TYPE_MASK),
-+ sw_type);
-+ } else if (bgmac->feature_flags & BGMAC_FEAT_CC7_IF_TYPE_RGMII) {
-+ bgmac_cco_ctl_maskset(bgmac, 7, ~BGMAC_CHIPCTL_7_IF_TYPE_MASK,
-+ BGMAC_CHIPCTL_7_IF_TYPE_RGMII);
- }
-
- if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw)
-@@ -1486,6 +1507,10 @@ int bgmac_enet_probe(struct bgmac *info)
- */
- bgmac_clk_enable(bgmac, 0);
-
-+ /* This seems to be fixing IRQ by assigning OOB #6 to the core */
-+ if (bgmac->feature_flags & BGMAC_FEAT_IRQ_ID_OOB_6)
-+ bgmac_idm_write(bgmac, BCMA_OOB_SEL_OUT_A30, 0x86);
-+
- bgmac_chip_reset(bgmac);
-
- err = bgmac_dma_alloc(bgmac);
---- a/drivers/net/ethernet/broadcom/bgmac.h
-+++ b/drivers/net/ethernet/broadcom/bgmac.h
-@@ -369,6 +369,21 @@
- #define BGMAC_CHIPCTL_1_SW_TYPE_RGMII 0x000000C0
- #define BGMAC_CHIPCTL_1_RXC_DLL_BYPASS 0x00010000
-
-+#define BGMAC_CHIPCTL_4_IF_TYPE_MASK 0x00003000
-+#define BGMAC_CHIPCTL_4_IF_TYPE_RMII 0x00000000
-+#define BGMAC_CHIPCTL_4_IF_TYPE_MII 0x00001000
-+#define BGMAC_CHIPCTL_4_IF_TYPE_RGMII 0x00002000
-+#define BGMAC_CHIPCTL_4_SW_TYPE_MASK 0x0000C000
-+#define BGMAC_CHIPCTL_4_SW_TYPE_EPHY 0x00000000
-+#define BGMAC_CHIPCTL_4_SW_TYPE_EPHYMII 0x00004000
-+#define BGMAC_CHIPCTL_4_SW_TYPE_EPHYRMII 0x00008000
-+#define BGMAC_CHIPCTL_4_SW_TYPE_RGMII 0x0000C000
-+
-+#define BGMAC_CHIPCTL_7_IF_TYPE_MASK 0x000000C0
-+#define BGMAC_CHIPCTL_7_IF_TYPE_RMII 0x00000000
-+#define BGMAC_CHIPCTL_7_IF_TYPE_MII 0x00000040
-+#define BGMAC_CHIPCTL_7_IF_TYPE_RGMII 0x00000080
-+
- #define BGMAC_WEIGHT 64
-
- #define ETHER_MAX_LEN 1518
-@@ -390,6 +405,10 @@
- #define BGMAC_FEAT_NO_CLR_MIB BIT(13)
- #define BGMAC_FEAT_FORCE_SPEED_2500 BIT(14)
- #define BGMAC_FEAT_CMDCFG_SR_REV4 BIT(15)
-+#define BGMAC_FEAT_IRQ_ID_OOB_6 BIT(16)
-+#define BGMAC_FEAT_CC4_IF_SW_TYPE BIT(17)
-+#define BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII BIT(18)
-+#define BGMAC_FEAT_CC7_IF_TYPE_RGMII BIT(19)
-
- struct bgmac_slot_info {
- union {
---- a/include/linux/bcma/bcma_regs.h
-+++ b/include/linux/bcma/bcma_regs.h
-@@ -23,6 +23,7 @@
- #define BCMA_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
-
- /* Agent registers (common for every core) */
-+#define BCMA_OOB_SEL_OUT_A30 0x0100
- #define BCMA_IOCTL 0x0408 /* IO control */
- #define BCMA_IOCTL_CLK 0x0001
- #define BCMA_IOCTL_FGC 0x0002
+++ /dev/null
-From e2d8f646c79f26e094bfaf9b21be614d1e148a67 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
-Date: Wed, 17 Aug 2016 23:11:52 +0200
-Subject: [PATCH] net: bgmac: make it clear when setting interface type to RMII
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-It doesn't really change anything as BGMAC_CHIPCTL_1_IF_TYPE_RMII is
-equal to 0. It make code a bit clener, so far when reading it one could
-think we forgot to set a proper mode. It also keeps this mode code in
-sync with other ones.
-
-Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -935,7 +935,8 @@ static void bgmac_chip_reset(struct bgma
- et_swtype <<= 4;
- sw_type = et_swtype;
- } else if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_EPHYRMII) {
-- sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHYRMII;
-+ sw_type = BGMAC_CHIPCTL_1_IF_TYPE_RMII |
-+ BGMAC_CHIPCTL_1_SW_TYPE_EPHYRMII;
- } else if (bgmac->feature_flags & BGMAC_FEAT_SW_TYPE_RGMII) {
- sw_type = BGMAC_CHIPCTL_1_IF_TYPE_RGMII |
- BGMAC_CHIPCTL_1_SW_TYPE_RGMII;
+++ /dev/null
-From 4af1474e6198b10fee7bb20e81f7e033ad1b586c Mon Sep 17 00:00:00 2001
-From: Jon Mason <jon.mason@broadcom.com>
-Date: Wed, 5 Oct 2016 15:36:49 -0400
-Subject: [PATCH] net: bgmac: Fix errant feature flag check
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-During the conversion to the feature flags, a check against
-ci->id != BCMA_CHIP_ID_BCM47162
-became
-bgmac->feature_flags & BGMAC_FEAT_CLKCTLS
-instead of
-!(bgmac->feature_flags & BGMAC_FEAT_CLKCTLS)
-
-Reported-by: Rafał Miłecki <zajec5@gmail.com>
-Signed-off-by: Jon Mason <jon.mason@broadcom.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -1049,7 +1049,7 @@ static void bgmac_enable(struct bgmac *b
-
- mode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
- BGMAC_DS_MM_SHIFT;
-- if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST || mode != 0)
-+ if (!(bgmac->feature_flags & BGMAC_FEAT_CLKCTLST) || mode != 0)
- bgmac_set(bgmac, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
- if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST && mode == 2)
- bgmac_cco_ctl_maskset(bgmac, 1, ~0,
+++ /dev/null
-From c121f72a66c5f92fbe2fc53baa274eef39875cec Mon Sep 17 00:00:00 2001
-From: Colin Ian King <colin.king@canonical.com>
-Date: Mon, 24 Oct 2016 23:46:18 +0100
-Subject: [PATCH] net: bgmac: fix spelling mistake: "connecton" -> "connection"
-
-trivial fix to spelling mistake in dev_err message
-
-Signed-off-by: Colin Ian King <colin.king@canonical.com>
-Acked-by: Jon Mason <jon.mason@broadcom.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/broadcom/bgmac.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -1468,7 +1468,7 @@ static int bgmac_phy_connect(struct bgma
- phy_dev = phy_connect(bgmac->net_dev, bus_id, &bgmac_adjust_link,
- PHY_INTERFACE_MODE_MII);
- if (IS_ERR(phy_dev)) {
-- dev_err(bgmac->dev, "PHY connecton failed\n");
-+ dev_err(bgmac->dev, "PHY connection failed\n");
- return PTR_ERR(phy_dev);
- }
-
--- /dev/null
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Subject: [PATCH 1/2] net: phy: cherry-pick Broadcom drivers updates from
+ v4.10-rc1
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+---
+
+--- a/drivers/net/phy/broadcom.c
++++ b/drivers/net/phy/broadcom.c
+@@ -18,7 +18,7 @@
+ #include <linux/module.h>
+ #include <linux/phy.h>
+ #include <linux/brcmphy.h>
+-
++#include <linux/of.h>
+
+ #define BRCM_PHY_MODEL(phydev) \
+ ((phydev)->drv->phy_id & (phydev)->drv->phy_id_mask)
+@@ -30,9 +30,32 @@ MODULE_DESCRIPTION("Broadcom PHY driver"
+ MODULE_AUTHOR("Maciej W. Rozycki");
+ MODULE_LICENSE("GPL");
+
+-static int bcm54xx_auxctl_write(struct phy_device *phydev, u16 regnum, u16 val)
++static int bcm54810_config(struct phy_device *phydev)
+ {
+- return phy_write(phydev, MII_BCM54XX_AUX_CTL, regnum | val);
++ int rc, val;
++
++ val = bcm_phy_read_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL);
++ val &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN;
++ rc = bcm_phy_write_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL,
++ val);
++ if (rc < 0)
++ return rc;
++
++ val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
++ val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
++ val |= MII_BCM54XX_AUXCTL_MISC_WREN;
++ rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
++ val);
++ if (rc < 0)
++ return rc;
++
++ val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL);
++ val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN;
++ rc = bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, val);
++ if (rc < 0)
++ return rc;
++
++ return 0;
+ }
+
+ /* Needs SMDSP clock enabled via bcm54xx_phydsp_config() */
+@@ -207,6 +230,12 @@ static int bcm54xx_config_init(struct ph
+ (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
+ bcm54xx_adjust_rxrefclk(phydev);
+
++ if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810) {
++ err = bcm54810_config(phydev);
++ if (err)
++ return err;
++ }
++
+ bcm54xx_phydsp_config(phydev);
+
+ return 0;
+@@ -304,6 +333,7 @@ static int bcm5482_read_status(struct ph
+
+ static int bcm5481_config_aneg(struct phy_device *phydev)
+ {
++ struct device_node *np = phydev->dev.of_node;
+ int ret;
+
+ /* Aneg firsly. */
+@@ -334,6 +364,49 @@ static int bcm5481_config_aneg(struct ph
+ phy_write(phydev, 0x18, reg);
+ }
+
++ if (of_property_read_bool(np, "enet-phy-lane-swap")) {
++ /* Lane Swap - Undocumented register...magic! */
++ ret = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0x9,
++ 0x11B);
++ if (ret < 0)
++ return ret;
++ }
++
++ return ret;
++}
++
++static int bcm54612e_config_aneg(struct phy_device *phydev)
++{
++ int ret;
++
++ /* First, auto-negotiate. */
++ ret = genphy_config_aneg(phydev);
++
++ /* Clear TX internal delay unless requested. */
++ if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
++ (phydev->interface != PHY_INTERFACE_MODE_RGMII_TXID)) {
++ /* Disable TXD to GTXCLK clock delay (default set) */
++ /* Bit 9 is the only field in shadow register 00011 */
++ bcm_phy_write_shadow(phydev, 0x03, 0);
++ }
++
++ /* Clear RX internal delay unless requested. */
++ if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
++ (phydev->interface != PHY_INTERFACE_MODE_RGMII_RXID)) {
++ u16 reg;
++
++ /* Errata: reads require filling in the write selector field */
++ bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
++ MII_BCM54XX_AUXCTL_MISC_RDSEL_MISC);
++ reg = phy_read(phydev, MII_BCM54XX_AUX_CTL);
++ /* Disable RXD to RXC delay (default set) */
++ reg &= ~MII_BCM54XX_AUXCTL_MISC_RXD_RXC_SKEW;
++ /* Clear shadow selector field */
++ reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MASK;
++ bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
++ MII_BCM54XX_AUXCTL_MISC_WREN | reg);
++ }
++
+ return ret;
+ }
+
+@@ -488,6 +561,19 @@ static struct phy_driver broadcom_driver
+ .config_intr = bcm_phy_config_intr,
+ .driver = { .owner = THIS_MODULE },
+ }, {
++ .phy_id = PHY_ID_BCM54612E,
++ .phy_id_mask = 0xfffffff0,
++ .name = "Broadcom BCM54612E",
++ .features = PHY_GBIT_FEATURES |
++ SUPPORTED_Pause | SUPPORTED_Asym_Pause,
++ .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
++ .config_init = bcm54xx_config_init,
++ .config_aneg = bcm54612e_config_aneg,
++ .read_status = genphy_read_status,
++ .ack_interrupt = bcm_phy_ack_intr,
++ .config_intr = bcm_phy_config_intr,
++ .driver = { .owner = THIS_MODULE },
++}, {
+ .phy_id = PHY_ID_BCM54616S,
+ .phy_id_mask = 0xfffffff0,
+ .name = "Broadcom BCM54616S",
+@@ -527,6 +613,19 @@ static struct phy_driver broadcom_driver
+ .config_intr = bcm_phy_config_intr,
+ .driver = { .owner = THIS_MODULE },
+ }, {
++ .phy_id = PHY_ID_BCM54810,
++ .phy_id_mask = 0xfffffff0,
++ .name = "Broadcom BCM54810",
++ .features = PHY_GBIT_FEATURES |
++ SUPPORTED_Pause | SUPPORTED_Asym_Pause,
++ .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
++ .config_init = bcm54xx_config_init,
++ .config_aneg = bcm5481_config_aneg,
++ .read_status = genphy_read_status,
++ .ack_interrupt = bcm_phy_ack_intr,
++ .config_intr = bcm_phy_config_intr,
++ .driver = { .owner = THIS_MODULE },
++}, {
+ .phy_id = PHY_ID_BCM5482,
+ .phy_id_mask = 0xfffffff0,
+ .name = "Broadcom BCM5482",
+@@ -612,9 +711,11 @@ static struct mdio_device_id __maybe_unu
+ { PHY_ID_BCM5411, 0xfffffff0 },
+ { PHY_ID_BCM5421, 0xfffffff0 },
+ { PHY_ID_BCM5461, 0xfffffff0 },
++ { PHY_ID_BCM54612E, 0xfffffff0 },
+ { PHY_ID_BCM54616S, 0xfffffff0 },
+ { PHY_ID_BCM5464, 0xfffffff0 },
+ { PHY_ID_BCM5481, 0xfffffff0 },
++ { PHY_ID_BCM54810, 0xfffffff0 },
+ { PHY_ID_BCM5482, 0xfffffff0 },
+ { PHY_ID_BCM50610, 0xfffffff0 },
+ { PHY_ID_BCM50610M, 0xfffffff0 },
+--- a/include/linux/brcmphy.h
++++ b/include/linux/brcmphy.h
+@@ -13,11 +13,13 @@
+ #define PHY_ID_BCM5241 0x0143bc30
+ #define PHY_ID_BCMAC131 0x0143bc70
+ #define PHY_ID_BCM5481 0x0143bca0
++#define PHY_ID_BCM54810 0x03625d00
+ #define PHY_ID_BCM5482 0x0143bcb0
+ #define PHY_ID_BCM5411 0x00206070
+ #define PHY_ID_BCM5421 0x002060e0
+ #define PHY_ID_BCM5464 0x002060b0
+ #define PHY_ID_BCM5461 0x002060c0
++#define PHY_ID_BCM54612E 0x03625e60
+ #define PHY_ID_BCM54616S 0x03625d10
+ #define PHY_ID_BCM57780 0x03625d90
+
+@@ -52,6 +54,7 @@
+ #define PHY_BRCM_EXT_IBND_TX_ENABLE 0x00002000
+ #define PHY_BRCM_CLEAR_RGMII_MODE 0x00004000
+ #define PHY_BRCM_DIS_TXCRXC_NOENRGY 0x00008000
++
+ /* Broadcom BCM7xxx specific workarounds */
+ #define PHY_BRCM_7XXX_REV(x) (((x) >> 8) & 0xff)
+ #define PHY_BRCM_7XXX_PATCH(x) ((x) & 0xff)
+@@ -102,11 +105,14 @@
+ #define MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA 0x0800
+
+ #define MII_BCM54XX_AUXCTL_MISC_WREN 0x8000
++#define MII_BCM54XX_AUXCTL_MISC_RXD_RXC_SKEW 0x0100
+ #define MII_BCM54XX_AUXCTL_MISC_FORCE_AMDIX 0x0200
+ #define MII_BCM54XX_AUXCTL_MISC_RDSEL_MISC 0x7000
+ #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC 0x0007
++#define MII_BCM54XX_AUXCTL_SHDWSEL_READ_SHIFT 12
++#define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN (1 << 8)
+
+-#define MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL 0x0000
++#define MII_BCM54XX_AUXCTL_SHDWSEL_MASK 0x0007
+
+ /*
+ * Broadcom LED source encodings. These are used in BCM5461, BCM5481,
+@@ -186,6 +192,12 @@
+ #define BCM5482_SSD_SGMII_SLAVE_EN 0x0002 /* Slave mode enable */
+ #define BCM5482_SSD_SGMII_SLAVE_AD 0x0001 /* Slave auto-detection */
+
++/* BCM54810 Registers */
++#define BCM54810_EXP_BROADREACH_LRE_MISC_CTL (MII_BCM54XX_EXP_SEL_ER + 0x90)
++#define BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN (1 << 0)
++#define BCM54810_SHD_CLK_CTL 0x3
++#define BCM54810_SHD_CLK_CTL_GTXCLK_EN (1 << 9)
++
+
+ /*****************************************************************************/
+ /* Fast Ethernet Transceiver definitions. */
+--- a/drivers/net/phy/Kconfig
++++ b/drivers/net/phy/Kconfig
+@@ -77,7 +77,7 @@ config BROADCOM_PHY
+ select BCM_NET_PHYLIB
+ ---help---
+ Currently supports the BCM5411, BCM5421, BCM5461, BCM54616S, BCM5464,
+- BCM5481 and BCM5482 PHYs.
++ BCM5481, BCM54810 and BCM5482 PHYs.
+
+ config BCM_CYGNUS_PHY
+ tristate "Drivers for Broadcom Cygnus SoC internal PHY"
+--- a/drivers/net/phy/bcm-phy-lib.c
++++ b/drivers/net/phy/bcm-phy-lib.c
+@@ -50,6 +50,23 @@ int bcm_phy_read_exp(struct phy_device *
+ }
+ EXPORT_SYMBOL_GPL(bcm_phy_read_exp);
+
++int bcm54xx_auxctl_read(struct phy_device *phydev, u16 regnum)
++{
++ /* The register must be written to both the Shadow Register Select and
++ * the Shadow Read Register Selector
++ */
++ phy_write(phydev, MII_BCM54XX_AUX_CTL, regnum |
++ regnum << MII_BCM54XX_AUXCTL_SHDWSEL_READ_SHIFT);
++ return phy_read(phydev, MII_BCM54XX_AUX_CTL);
++}
++EXPORT_SYMBOL_GPL(bcm54xx_auxctl_read);
++
++int bcm54xx_auxctl_write(struct phy_device *phydev, u16 regnum, u16 val)
++{
++ return phy_write(phydev, MII_BCM54XX_AUX_CTL, regnum | val);
++}
++EXPORT_SYMBOL(bcm54xx_auxctl_write);
++
+ int bcm_phy_write_misc(struct phy_device *phydev,
+ u16 reg, u16 chl, u16 val)
+ {
+--- a/drivers/net/phy/bcm-phy-lib.h
++++ b/drivers/net/phy/bcm-phy-lib.h
+@@ -19,6 +19,9 @@
+ int bcm_phy_write_exp(struct phy_device *phydev, u16 reg, u16 val);
+ int bcm_phy_read_exp(struct phy_device *phydev, u16 reg);
+
++int bcm54xx_auxctl_write(struct phy_device *phydev, u16 regnum, u16 val);
++int bcm54xx_auxctl_read(struct phy_device *phydev, u16 regnum);
++
+ int bcm_phy_write_misc(struct phy_device *phydev,
+ u16 reg, u16 chl, u16 value);
+ int bcm_phy_read_misc(struct phy_device *phydev,
--- /dev/null
+--- a/drivers/net/phy/broadcom.c
++++ b/drivers/net/phy/broadcom.c
+@@ -30,6 +30,50 @@ MODULE_DESCRIPTION("Broadcom PHY driver"
+ MODULE_AUTHOR("Maciej W. Rozycki");
+ MODULE_LICENSE("GPL");
+
++static int bcm54210e_config_init(struct phy_device *phydev)
++{
++ int val;
++
++ val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
++ val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
++ val |= MII_BCM54XX_AUXCTL_MISC_WREN;
++ bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC, val);
++
++ val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL);
++ val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN;
++ bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, val);
++
++ return 0;
++}
++
++static int bcm54612e_config_init(struct phy_device *phydev)
++{
++ /* Clear TX internal delay unless requested. */
++ if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
++ (phydev->interface != PHY_INTERFACE_MODE_RGMII_TXID)) {
++ /* Disable TXD to GTXCLK clock delay (default set) */
++ /* Bit 9 is the only field in shadow register 00011 */
++ bcm_phy_write_shadow(phydev, 0x03, 0);
++ }
++
++ /* Clear RX internal delay unless requested. */
++ if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
++ (phydev->interface != PHY_INTERFACE_MODE_RGMII_RXID)) {
++ u16 reg;
++
++ reg = bcm54xx_auxctl_read(phydev,
++ MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
++ /* Disable RXD to RXC delay (default set) */
++ reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
++ /* Clear shadow selector field */
++ reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MASK;
++ bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
++ MII_BCM54XX_AUXCTL_MISC_WREN | reg);
++ }
++
++ return 0;
++}
++
+ static int bcm54810_config(struct phy_device *phydev)
+ {
+ int rc, val;
+@@ -230,7 +274,15 @@ static int bcm54xx_config_init(struct ph
+ (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
+ bcm54xx_adjust_rxrefclk(phydev);
+
+- if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810) {
++ if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E) {
++ err = bcm54210e_config_init(phydev);
++ if (err)
++ return err;
++ } else if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54612E) {
++ err = bcm54612e_config_init(phydev);
++ if (err)
++ return err;
++ } else if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810) {
+ err = bcm54810_config(phydev);
+ if (err)
+ return err;
+@@ -375,41 +427,6 @@ static int bcm5481_config_aneg(struct ph
+ return ret;
+ }
+
+-static int bcm54612e_config_aneg(struct phy_device *phydev)
+-{
+- int ret;
+-
+- /* First, auto-negotiate. */
+- ret = genphy_config_aneg(phydev);
+-
+- /* Clear TX internal delay unless requested. */
+- if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
+- (phydev->interface != PHY_INTERFACE_MODE_RGMII_TXID)) {
+- /* Disable TXD to GTXCLK clock delay (default set) */
+- /* Bit 9 is the only field in shadow register 00011 */
+- bcm_phy_write_shadow(phydev, 0x03, 0);
+- }
+-
+- /* Clear RX internal delay unless requested. */
+- if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
+- (phydev->interface != PHY_INTERFACE_MODE_RGMII_RXID)) {
+- u16 reg;
+-
+- /* Errata: reads require filling in the write selector field */
+- bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
+- MII_BCM54XX_AUXCTL_MISC_RDSEL_MISC);
+- reg = phy_read(phydev, MII_BCM54XX_AUX_CTL);
+- /* Disable RXD to RXC delay (default set) */
+- reg &= ~MII_BCM54XX_AUXCTL_MISC_RXD_RXC_SKEW;
+- /* Clear shadow selector field */
+- reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MASK;
+- bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
+- MII_BCM54XX_AUXCTL_MISC_WREN | reg);
+- }
+-
+- return ret;
+-}
+-
+ static int brcm_phy_setbits(struct phy_device *phydev, int reg, int set)
+ {
+ int val;
+@@ -548,6 +565,19 @@ static struct phy_driver broadcom_driver
+ .config_intr = bcm_phy_config_intr,
+ .driver = { .owner = THIS_MODULE },
+ }, {
++ .phy_id = PHY_ID_BCM54210E,
++ .phy_id_mask = 0xfffffff0,
++ .name = "Broadcom BCM54210E",
++ .features = PHY_GBIT_FEATURES |
++ SUPPORTED_Pause | SUPPORTED_Asym_Pause,
++ .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
++ .config_init = bcm54xx_config_init,
++ .config_aneg = genphy_config_aneg,
++ .read_status = genphy_read_status,
++ .ack_interrupt = bcm_phy_ack_intr,
++ .config_intr = bcm_phy_config_intr,
++ .driver = { .owner = THIS_MODULE },
++}, {
+ .phy_id = PHY_ID_BCM5461,
+ .phy_id_mask = 0xfffffff0,
+ .name = "Broadcom BCM5461",
+@@ -568,7 +598,7 @@ static struct phy_driver broadcom_driver
+ SUPPORTED_Pause | SUPPORTED_Asym_Pause,
+ .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
+ .config_init = bcm54xx_config_init,
+- .config_aneg = bcm54612e_config_aneg,
++ .config_aneg = genphy_config_aneg,
+ .read_status = genphy_read_status,
+ .ack_interrupt = bcm_phy_ack_intr,
+ .config_intr = bcm_phy_config_intr,
+@@ -710,6 +740,7 @@ module_phy_driver(broadcom_drivers);
+ static struct mdio_device_id __maybe_unused broadcom_tbl[] = {
+ { PHY_ID_BCM5411, 0xfffffff0 },
+ { PHY_ID_BCM5421, 0xfffffff0 },
++ { PHY_ID_BCM54210E, 0xfffffff0 },
+ { PHY_ID_BCM5461, 0xfffffff0 },
+ { PHY_ID_BCM54612E, 0xfffffff0 },
+ { PHY_ID_BCM54616S, 0xfffffff0 },
+--- a/include/linux/brcmphy.h
++++ b/include/linux/brcmphy.h
+@@ -17,6 +17,7 @@
+ #define PHY_ID_BCM5482 0x0143bcb0
+ #define PHY_ID_BCM5411 0x00206070
+ #define PHY_ID_BCM5421 0x002060e0
++#define PHY_ID_BCM54210E 0x600d84a0
+ #define PHY_ID_BCM5464 0x002060b0
+ #define PHY_ID_BCM5461 0x002060c0
+ #define PHY_ID_BCM54612E 0x03625e60
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
-@@ -2752,10 +2752,10 @@ choice
+@@ -2753,10 +2753,10 @@ choice
the documented boot protocol using a device tree.
config MIPS_RAW_APPENDED_DTB
(e.g. cat vmlinux.bin <filename>.dtb > vmlinux_w_dtb).
This is meant as a backward compatibility convenience for those
-@@ -2767,24 +2767,6 @@ choice
+@@ -2768,24 +2768,6 @@ choice
look like a DTB header after a reboot if no actual DTB is appended
to vmlinux.bin. Do not leave this option active in a production kernel
if you don't intend to always append a DTB.
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
-@@ -1618,6 +1618,7 @@ config CPU_CAVIUM_OCTEON
+@@ -1619,6 +1619,7 @@ config CPU_CAVIUM_OCTEON
select USB_EHCI_BIG_ENDIAN_MMIO if CPU_BIG_ENDIAN
select USB_OHCI_BIG_ENDIAN_MMIO if CPU_BIG_ENDIAN
select MIPS_L1_CACHE_SHIFT_7
help
The Cavium Octeon processor is a highly integrated chip containing
many ethernet hardware widgets for networking tasks. The processor
-@@ -1913,6 +1914,9 @@ config MIPS_MALTA_PM
+@@ -1914,6 +1915,9 @@ config MIPS_MALTA_PM
bool
default y
+++ /dev/null
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
-Subject: [PATCH 1/2] mtd: bcm47xxpart: move TRX parsing code to separated
- function
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This change simplifies main parsing loop logic a bit. In future it may
-be useful for moving TRX support to separated module / parser (if we
-implement support for them at some point).
-Finally parsing TRX at the end puts us in a better position as we have
-better flash layout knowledge. It may be useful e.g. if it appears there
-is more than 1 TRX partition.
-
-Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
----
- drivers/mtd/bcm47xxpart.c | 121 ++++++++++++++++++++++++++++------------------
- 1 file changed, 74 insertions(+), 47 deletions(-)
-
---- a/drivers/mtd/bcm47xxpart.c
-+++ b/drivers/mtd/bcm47xxpart.c
-@@ -83,6 +83,67 @@ out_default:
- return "rootfs";
- }
-
-+static int bcm47xxpart_parse_trx(struct mtd_info *master,
-+ struct mtd_partition *trx,
-+ struct mtd_partition *parts,
-+ size_t parts_len)
-+{
-+ struct trx_header header;
-+ size_t bytes_read;
-+ int curr_part = 0;
-+ int i, err;
-+
-+ if (parts_len < 3) {
-+ pr_warn("No enough space to add TRX partitions!\n");
-+ return -ENOMEM;
-+ }
-+
-+ err = mtd_read(master, trx->offset, sizeof(header), &bytes_read,
-+ (uint8_t *)&header);
-+ if (err && !mtd_is_bitflip(err)) {
-+ pr_err("mtd_read error while reading TRX header: %d\n", err);
-+ return err;
-+ }
-+
-+ i = 0;
-+
-+ /* We have LZMA loader if offset[2] points to sth */
-+ if (header.offset[2]) {
-+ bcm47xxpart_add_part(&parts[curr_part++], "loader",
-+ trx->offset + header.offset[i], 0);
-+ i++;
-+ }
-+
-+ if (header.offset[i]) {
-+ bcm47xxpart_add_part(&parts[curr_part++], "linux",
-+ trx->offset + header.offset[i], 0);
-+ i++;
-+ }
-+
-+ if (header.offset[i]) {
-+ size_t offset = trx->offset + header.offset[i];
-+ const char *name = bcm47xxpart_trx_data_part_name(master,
-+ offset);
-+
-+ bcm47xxpart_add_part(&parts[curr_part++], name, offset, 0);
-+ i++;
-+ }
-+
-+ /*
-+ * Assume that every partition ends at the beginning of the one it is
-+ * followed by.
-+ */
-+ for (i = 0; i < curr_part; i++) {
-+ u64 next_part_offset = (i < curr_part - 1) ?
-+ parts[i + 1].offset :
-+ trx->offset + trx->size;
-+
-+ parts[i].size = next_part_offset - parts[i].offset;
-+ }
-+
-+ return curr_part;
-+}
-+
- static int bcm47xxpart_parse(struct mtd_info *master,
- struct mtd_partition **pparts,
- struct mtd_part_parser_data *data)
-@@ -93,9 +154,7 @@ static int bcm47xxpart_parse(struct mtd_
- size_t bytes_read;
- uint32_t offset;
- uint32_t blocksize = master->erasesize;
-- struct trx_header *trx;
- int trx_part = -1;
-- int last_trx_part = -1;
- int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, };
- int err;
-
-@@ -182,54 +241,14 @@ static int bcm47xxpart_parse(struct mtd_
-
- /* TRX */
- if (buf[0x000 / 4] == TRX_MAGIC) {
-- if (BCM47XXPART_MAX_PARTS - curr_part < 4) {
-- pr_warn("Not enough partitions left to register trx, scanning stopped!\n");
-- break;
-- }
--
-- trx = (struct trx_header *)buf;
-+ struct trx_header *trx;
-
- trx_part = curr_part;
- bcm47xxpart_add_part(&parts[curr_part++], "firmware",
- offset, 0);
-
-- i = 0;
-- /* We have LZMA loader if offset[2] points to sth */
-- if (trx->offset[2]) {
-- bcm47xxpart_add_part(&parts[curr_part++],
-- "loader",
-- offset + trx->offset[i],
-- 0);
-- i++;
-- }
--
-- if (trx->offset[i]) {
-- bcm47xxpart_add_part(&parts[curr_part++],
-- "linux",
-- offset + trx->offset[i],
-- 0);
-- i++;
-- }
--
-- /*
-- * Pure rootfs size is known and can be calculated as:
-- * trx->length - trx->offset[i]. We don't fill it as
-- * we want to have jffs2 (overlay) in the same mtd.
-- */
-- if (trx->offset[i]) {
-- const char *name;
--
-- name = bcm47xxpart_trx_data_part_name(master, offset + trx->offset[i]);
-- bcm47xxpart_add_part(&parts[curr_part++],
-- name,
-- offset + trx->offset[i],
-- 0);
-- i++;
-- }
--
-- last_trx_part = curr_part - 1;
--
- /* Jump to the end of TRX */
-+ trx = (struct trx_header *)buf;
- offset = roundup(offset + trx->length, blocksize);
- /* Next loop iteration will increase the offset */
- offset -= blocksize;
-@@ -307,9 +326,17 @@ static int bcm47xxpart_parse(struct mtd_
- parts[i + 1].offset : master->size;
-
- parts[i].size = next_part_offset - parts[i].offset;
-- if (i == last_trx_part && trx_part >= 0)
-- parts[trx_part].size = next_part_offset -
-- parts[trx_part].offset;
-+ }
-+
-+ /* If there was TRX parse it now */
-+ if (trx_part >= 0) {
-+ int num_parts;
-+
-+ num_parts = bcm47xxpart_parse_trx(master, &parts[trx_part],
-+ parts + curr_part,
-+ BCM47XXPART_MAX_PARTS - curr_part);
-+ if (num_parts > 0)
-+ curr_part += num_parts;
- }
-
- *pparts = parts;
+++ /dev/null
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
-Subject: [PATCH 2/2] mtd: bcm47xxpart: support layouts with multiple TRX
- partitions
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Some devices may have an extra TRX partition used as failsafe one. If
-we detect such partition we should set a proper name for it and don't
-parse it.
-
-Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
----
- drivers/mtd/bcm47xxpart.c | 56 ++++++++++++++++++++++++++++++++++++++---------
- 1 file changed, 46 insertions(+), 10 deletions(-)
-
---- a/drivers/mtd/bcm47xxpart.c
-+++ b/drivers/mtd/bcm47xxpart.c
-@@ -9,6 +9,7 @@
- *
- */
-
-+#include <linux/bcm47xx_nvram.h>
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/slab.h>
-@@ -144,6 +145,30 @@ static int bcm47xxpart_parse_trx(struct
- return curr_part;
- }
-
-+/**
-+ * bcm47xxpart_bootpartition - gets index of TRX partition used by bootloader
-+ *
-+ * Some devices may have more than one TRX partition. In such case one of them
-+ * is the main one and another a failsafe one. Bootloader may fallback to the
-+ * failsafe firmware if it detects corruption of the main image.
-+ *
-+ * This function provides info about currently used TRX partition. It's the one
-+ * containing kernel started by the bootloader.
-+ */
-+static int bcm47xxpart_bootpartition(void)
-+{
-+ char buf[4];
-+ int bootpartition;
-+
-+ /* Check CFE environment variable */
-+ if (bcm47xx_nvram_getenv("bootpartition", buf, sizeof(buf)) > 0) {
-+ if (!kstrtoint(buf, 0, &bootpartition))
-+ return bootpartition;
-+ }
-+
-+ return 0;
-+}
-+
- static int bcm47xxpart_parse(struct mtd_info *master,
- struct mtd_partition **pparts,
- struct mtd_part_parser_data *data)
-@@ -154,7 +179,8 @@ static int bcm47xxpart_parse(struct mtd_
- size_t bytes_read;
- uint32_t offset;
- uint32_t blocksize = master->erasesize;
-- int trx_part = -1;
-+ int trx_parts[2]; /* Array with indexes of TRX partitions */
-+ int trx_num = 0; /* Number of found TRX partitions */
- int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, };
- int err;
-
-@@ -243,7 +269,11 @@ static int bcm47xxpart_parse(struct mtd_
- if (buf[0x000 / 4] == TRX_MAGIC) {
- struct trx_header *trx;
-
-- trx_part = curr_part;
-+ if (trx_num >= ARRAY_SIZE(trx_parts))
-+ pr_warn("No enough space to store another TRX found at 0x%X\n",
-+ offset);
-+ else
-+ trx_parts[trx_num++] = curr_part;
- bcm47xxpart_add_part(&parts[curr_part++], "firmware",
- offset, 0);
-
-@@ -329,14 +359,20 @@ static int bcm47xxpart_parse(struct mtd_
- }
-
- /* If there was TRX parse it now */
-- if (trx_part >= 0) {
-- int num_parts;
-+ for (i = 0; i < trx_num; i++) {
-+ struct mtd_partition *trx = &parts[trx_parts[i]];
-
-- num_parts = bcm47xxpart_parse_trx(master, &parts[trx_part],
-- parts + curr_part,
-- BCM47XXPART_MAX_PARTS - curr_part);
-- if (num_parts > 0)
-- curr_part += num_parts;
-+ if (i == bcm47xxpart_bootpartition()) {
-+ int num_parts;
-+
-+ num_parts = bcm47xxpart_parse_trx(master, trx,
-+ parts + curr_part,
-+ BCM47XXPART_MAX_PARTS - curr_part);
-+ if (num_parts > 0)
-+ curr_part += num_parts;
-+ } else {
-+ trx->name = "failsafe";
-+ }
- }
-
- *pparts = parts;
+++ /dev/null
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
-Date: Mon, 7 Nov 2016 13:19:42 +0100
-Subject: [PATCH] net: bgmac: fix reversed checks for clock control flag
-
-This fixes regression introduced by patch adding feature flags. It was
-already reported and patch followed (it got accepted) but it appears it
-was incorrect. Instead of fixing reversed condition it broke a good one.
-
-This patch was verified to actually fix SoC hanges caused by bgmac on
-BCM47186B0.
-
-Fixes: db791eb2970b ("net: ethernet: bgmac: convert to feature flags")
-Fixes: 4af1474e6198 ("net: bgmac: Fix errant feature flag check")
-Cc: Jon Mason <jon.mason@broadcom.com>
----
- drivers/net/ethernet/broadcom/bgmac.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/drivers/net/ethernet/broadcom/bgmac.c
-+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -1049,9 +1049,9 @@ static void bgmac_enable(struct bgmac *b
-
- mode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
- BGMAC_DS_MM_SHIFT;
-- if (!(bgmac->feature_flags & BGMAC_FEAT_CLKCTLST) || mode != 0)
-+ if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST || mode != 0)
- bgmac_set(bgmac, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
-- if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST && mode == 2)
-+ if (!(bgmac->feature_flags & BGMAC_FEAT_CLKCTLST) && mode == 2)
- bgmac_cco_ctl_maskset(bgmac, 1, ~0,
- BGMAC_CHIPCTL_1_RXC_DLL_BYPASS);
-
--- /dev/null
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Subject: [PATCH] Revert "bcma: init serial console directly from ChipCommon
+ code"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This reverts commit 4c81acab3816 ("bcma: init serial console directly
+from ChipCommon code") as it broke IRQ assignment. Getting IRQ with
+bcma_core_irq helper on SoC requires MIPS core to be set. It happens
+*after* ChipCommon initialization so we can't do this so early.
+
+This fixes a user reported regression. It wasn't critical as serial was
+still somehow working but lack of IRQs was making in unreliable.
+
+Fixes: 4c81acab3816 ("bcma: init serial console directly from ChipCommon code")
+Reported-by: Felix Fietkau <nbd@nbd.name>
+Cc: stable@vger.kernel.org # 4.6+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+---
+ drivers/bcma/bcma_private.h | 3 +++
+ drivers/bcma/driver_chipcommon.c | 11 +++--------
+ drivers/bcma/driver_mips.c | 3 +++
+ 3 files changed, 9 insertions(+), 8 deletions(-)
+
+--- a/drivers/bcma/bcma_private.h
++++ b/drivers/bcma/bcma_private.h
+@@ -45,6 +45,9 @@ int bcma_sprom_get(struct bcma_bus *bus)
+ void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
+ void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
+ void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
++#ifdef CONFIG_BCMA_DRIVER_MIPS
++void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
++#endif /* CONFIG_BCMA_DRIVER_MIPS */
+
+ /* driver_chipcommon_b.c */
+ int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb);
+--- a/drivers/bcma/driver_chipcommon.c
++++ b/drivers/bcma/driver_chipcommon.c
+@@ -15,8 +15,6 @@
+ #include <linux/platform_device.h>
+ #include <linux/bcma/bcma.h>
+
+-static void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
+-
+ static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
+ u32 mask, u32 value)
+ {
+@@ -186,9 +184,6 @@ void bcma_core_chipcommon_early_init(str
+ if (cc->capabilities & BCMA_CC_CAP_PMU)
+ bcma_pmu_early_init(cc);
+
+- if (IS_BUILTIN(CONFIG_BCM47XX) && bus->hosttype == BCMA_HOSTTYPE_SOC)
+- bcma_chipco_serial_init(cc);
+-
+ if (bus->hosttype == BCMA_HOSTTYPE_SOC)
+ bcma_core_chipcommon_flash_detect(cc);
+
+@@ -378,9 +373,9 @@ u32 bcma_chipco_gpio_pulldown(struct bcm
+ return res;
+ }
+
+-static void bcma_chipco_serial_init(struct bcma_drv_cc *cc)
++#ifdef CONFIG_BCMA_DRIVER_MIPS
++void bcma_chipco_serial_init(struct bcma_drv_cc *cc)
+ {
+-#if IS_BUILTIN(CONFIG_BCM47XX)
+ unsigned int irq;
+ u32 baud_base;
+ u32 i;
+@@ -422,5 +417,5 @@ static void bcma_chipco_serial_init(stru
+ ports[i].baud_base = baud_base;
+ ports[i].reg_shift = 0;
+ }
+-#endif /* CONFIG_BCM47XX */
+ }
++#endif /* CONFIG_BCMA_DRIVER_MIPS */
+--- a/drivers/bcma/driver_mips.c
++++ b/drivers/bcma/driver_mips.c
+@@ -278,9 +278,12 @@ static void bcma_core_mips_nvram_init(st
+
+ void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
+ {
++ struct bcma_bus *bus = mcore->core->bus;
++
+ if (mcore->early_setup_done)
+ return;
+
++ bcma_chipco_serial_init(&bus->drv_cc);
+ bcma_core_mips_nvram_init(mcore);
+
+ mcore->early_setup_done = true;
---
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
-@@ -1032,9 +1032,6 @@ config FW_ARC
+@@ -1033,9 +1033,6 @@ config FW_ARC
config ARCH_MAY_HAVE_PC_FDC
bool
config CEVT_BCM1480
bool
-@@ -2792,6 +2789,18 @@ choice
+@@ -2793,6 +2790,18 @@ choice
bool "Bootloader kernel arguments if available"
endchoice
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
-@@ -1123,6 +1123,10 @@ config SYNC_R4K
+@@ -1124,6 +1124,10 @@ config SYNC_R4K
config MIPS_MACHINE
def_bool n
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
-@@ -2724,6 +2724,20 @@ config MIPS_O32_FP64_SUPPORT
+@@ -2725,6 +2725,20 @@ config MIPS_O32_FP64_SUPPORT
If unsure, say N.
return 0;
}
-@@ -287,9 +528,33 @@ int module_finalize(const Elf_Ehdr *hdr,
+@@ -287,9 +528,36 @@ int module_finalize(const Elf_Ehdr *hdr,
list_add(&me->arch.dbe_list, &dbe_list);
spin_unlock_irq(&dbe_lock);
}
+void module_arch_freeing_init(struct module *mod)
+{
++ if (mod->state == MODULE_STATE_LIVE)
++ return;
++
+ if (mod->arch.phys_plt_tbl) {
+ __module_free(mod->arch.phys_plt_tbl);
+ mod->arch.phys_plt_tbl = NULL;
#define PACKET_FANOUT_LB 1
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
-@@ -1763,6 +1763,7 @@ static int packet_rcv_spkt(struct sk_buf
+@@ -1776,6 +1776,7 @@ static int packet_rcv_spkt(struct sk_buf
{
struct sock *sk;
struct sockaddr_pkt *spkt;
/*
* When we registered the protocol we saved the socket in the data
-@@ -1770,6 +1771,7 @@ static int packet_rcv_spkt(struct sk_buf
+@@ -1783,6 +1784,7 @@ static int packet_rcv_spkt(struct sk_buf
*/
sk = pt->af_packet_priv;
/*
* Yank back the headers [hope the device set this
-@@ -1782,7 +1784,7 @@ static int packet_rcv_spkt(struct sk_buf
+@@ -1795,7 +1797,7 @@ static int packet_rcv_spkt(struct sk_buf
* so that this procedure is noop.
*/
goto out;
if (!net_eq(dev_net(dev), sock_net(sk)))
-@@ -1985,12 +1987,12 @@ static int packet_rcv(struct sk_buff *sk
+@@ -1998,12 +2000,12 @@ static int packet_rcv(struct sk_buff *sk
int skb_len = skb->len;
unsigned int snaplen, res;
if (!net_eq(dev_net(dev), sock_net(sk)))
goto drop;
-@@ -2110,12 +2112,12 @@ static int tpacket_rcv(struct sk_buff *s
+@@ -2123,12 +2125,12 @@ static int tpacket_rcv(struct sk_buff *s
BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h2)) != 32);
BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h3)) != 48);
if (!net_eq(dev_net(dev), sock_net(sk)))
goto drop;
-@@ -3091,6 +3093,7 @@ static int packet_create(struct net *net
+@@ -3111,6 +3113,7 @@ static int packet_create(struct net *net
mutex_init(&po->pg_vec_lock);
po->rollover = NULL;
po->prot_hook.func = packet_rcv;
if (sock->type == SOCK_PACKET)
po->prot_hook.func = packet_rcv_spkt;
-@@ -3713,6 +3716,16 @@ packet_setsockopt(struct socket *sock, i
+@@ -3733,6 +3736,16 @@ packet_setsockopt(struct socket *sock, i
po->xmit = val ? packet_direct_xmit : dev_queue_xmit;
return 0;
}
default:
return -ENOPROTOOPT;
}
-@@ -3765,6 +3778,13 @@ static int packet_getsockopt(struct sock
+@@ -3785,6 +3798,13 @@ static int packet_getsockopt(struct sock
case PACKET_VNET_HDR:
val = po->has_vnet_hdr;
break;
if (dev == ip6n->fb_tnl_dev)
RCU_INIT_POINTER(ip6n->tnls_wc[0], NULL);
else
-@@ -846,6 +861,108 @@ int ip6_tnl_rcv_ctl(struct ip6_tnl *t,
+@@ -856,6 +871,108 @@ int ip6_tnl_rcv_ctl(struct ip6_tnl *t,
}
EXPORT_SYMBOL_GPL(ip6_tnl_rcv_ctl);
/**
* ip6_tnl_rcv - decapsulate IPv6 packet and retransmit it locally
* @skb: received socket buffer
-@@ -891,6 +1008,26 @@ static int ip6_tnl_rcv(struct sk_buff *s
+@@ -901,6 +1018,26 @@ static int ip6_tnl_rcv(struct sk_buff *s
skb_reset_network_header(skb);
skb->protocol = htons(protocol);
memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
__skb_tunnel_rx(skb, t->dev, t->net);
-@@ -1235,6 +1372,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, str
+@@ -1245,6 +1382,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, str
__u32 mtu;
u8 tproto;
int err;
tproto = ACCESS_ONCE(t->parms.proto);
if ((tproto != IPPROTO_IPV6 && tproto != 0) ||
-@@ -1265,6 +1403,18 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, str
+@@ -1275,6 +1413,18 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, str
if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
fl6.flowi6_mark = skb->mark;
err = ip6_tnl_xmit2(skb, dev, dsfield, &fl6, encap_limit, &mtu);
if (err != 0) {
if (err == -EMSGSIZE)
-@@ -1379,6 +1529,14 @@ ip6_tnl_change(struct ip6_tnl *t, const
+@@ -1389,6 +1539,14 @@ ip6_tnl_change(struct ip6_tnl *t, const
t->parms.flowinfo = p->flowinfo;
t->parms.link = p->link;
t->parms.proto = p->proto;
ip6_tnl_dst_reset(t);
ip6_tnl_link_config(t);
return 0;
-@@ -1417,6 +1575,7 @@ ip6_tnl_parm_from_user(struct __ip6_tnl_
+@@ -1427,6 +1585,7 @@ ip6_tnl_parm_from_user(struct __ip6_tnl_
p->flowinfo = u->flowinfo;
p->link = u->link;
p->proto = u->proto;
memcpy(p->name, u->name, sizeof(u->name));
}
-@@ -1712,6 +1871,15 @@ static int ip6_tnl_validate(struct nlatt
+@@ -1722,6 +1881,15 @@ static int ip6_tnl_validate(struct nlatt
return 0;
}
static void ip6_tnl_netlink_parms(struct nlattr *data[],
struct __ip6_tnl_parm *parms)
{
-@@ -1743,6 +1911,46 @@ static void ip6_tnl_netlink_parms(struct
+@@ -1753,6 +1921,46 @@ static void ip6_tnl_netlink_parms(struct
if (data[IFLA_IPTUN_PROTO])
parms->proto = nla_get_u8(data[IFLA_IPTUN_PROTO]);
}
static int ip6_tnl_newlink(struct net *src_net, struct net_device *dev,
-@@ -1795,6 +2003,12 @@ static void ip6_tnl_dellink(struct net_d
+@@ -1805,6 +2013,12 @@ static void ip6_tnl_dellink(struct net_d
static size_t ip6_tnl_get_size(const struct net_device *dev)
{
return
/* IFLA_IPTUN_LINK */
nla_total_size(4) +
-@@ -1812,6 +2026,24 @@ static size_t ip6_tnl_get_size(const str
+@@ -1822,6 +2036,24 @@ static size_t ip6_tnl_get_size(const str
nla_total_size(4) +
/* IFLA_IPTUN_PROTO */
nla_total_size(1) +
0;
}
-@@ -1819,6 +2051,9 @@ static int ip6_tnl_fill_info(struct sk_b
+@@ -1829,6 +2061,9 @@ static int ip6_tnl_fill_info(struct sk_b
{
struct ip6_tnl *tunnel = netdev_priv(dev);
struct __ip6_tnl_parm *parm = &tunnel->parms;
if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
nla_put_in6_addr(skb, IFLA_IPTUN_LOCAL, &parm->laddr) ||
-@@ -1827,8 +2062,27 @@ static int ip6_tnl_fill_info(struct sk_b
+@@ -1837,8 +2072,27 @@ static int ip6_tnl_fill_info(struct sk_b
nla_put_u8(skb, IFLA_IPTUN_ENCAP_LIMIT, parm->encap_limit) ||
nla_put_be32(skb, IFLA_IPTUN_FLOWINFO, parm->flowinfo) ||
nla_put_u32(skb, IFLA_IPTUN_FLAGS, parm->flags) ||
return 0;
nla_put_failure:
-@@ -1852,6 +2106,7 @@ static const struct nla_policy ip6_tnl_p
+@@ -1862,6 +2116,7 @@ static const struct nla_policy ip6_tnl_p
[IFLA_IPTUN_FLOWINFO] = { .type = NLA_U32 },
[IFLA_IPTUN_FLAGS] = { .type = NLA_U32 },
[IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
case -EAGAIN:
rtm->rtm_type = RTN_THROW;
break;
-@@ -3362,6 +3399,8 @@ static int ip6_route_dev_notify(struct n
+@@ -3363,6 +3400,8 @@ static int ip6_route_dev_notify(struct n
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
net->ipv6.ip6_prohibit_entry->dst.dev = dev;
net->ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(dev);
net->ipv6.ip6_blk_hole_entry->dst.dev = dev;
net->ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(dev);
#endif
-@@ -3578,6 +3617,17 @@ static int __net_init ip6_route_net_init
+@@ -3579,6 +3618,17 @@ static int __net_init ip6_route_net_init
net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops;
dst_init_metrics(&net->ipv6.ip6_blk_hole_entry->dst,
ip6_template_metrics, true);
#endif
net->ipv6.sysctl.flush_delay = 0;
-@@ -3596,6 +3646,8 @@ out:
+@@ -3597,6 +3647,8 @@ out:
return ret;
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
out_ip6_prohibit_entry:
kfree(net->ipv6.ip6_prohibit_entry);
out_ip6_null_entry:
-@@ -3613,6 +3665,7 @@ static void __net_exit ip6_route_net_exi
+@@ -3614,6 +3666,7 @@ static void __net_exit ip6_route_net_exi
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
kfree(net->ipv6.ip6_prohibit_entry);
kfree(net->ipv6.ip6_blk_hole_entry);
#endif
dst_entries_destroy(&net->ipv6.ip6_dst_ops);
}
-@@ -3710,6 +3763,9 @@ int __init ip6_route_init(void)
+@@ -3711,6 +3764,9 @@ int __init ip6_route_init(void)
init_net.ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev);
init_net.ipv6.ip6_blk_hole_entry->dst.dev = init_net.loopback_dev;
init_net.ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev);
--- a/net/core/dev.c
+++ b/net/core/dev.c
-@@ -4222,6 +4222,9 @@ static enum gro_result dev_gro_receive(s
+@@ -4219,6 +4219,9 @@ static enum gro_result dev_gro_receive(s
enum gro_result ret;
int grow;
if (!(skb->dev->features & NETIF_F_GRO))
goto normal;
-@@ -5381,6 +5384,48 @@ static void __netdev_adjacent_dev_unlink
+@@ -5378,6 +5381,48 @@ static void __netdev_adjacent_dev_unlink
&upper_dev->adj_list.lower);
}
static int __netdev_upper_dev_link(struct net_device *dev,
struct net_device *upper_dev, bool master,
void *private)
-@@ -5452,6 +5497,7 @@ static int __netdev_upper_dev_link(struc
+@@ -5449,6 +5494,7 @@ static int __netdev_upper_dev_link(struc
goto rollback_lower_mesh;
}
call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev,
&changeupper_info.info);
return 0;
-@@ -5578,6 +5624,7 @@ void netdev_upper_dev_unlink(struct net_
+@@ -5575,6 +5621,7 @@ void netdev_upper_dev_unlink(struct net_
list_for_each_entry(i, &upper_dev->all_adj_list.upper, list)
__netdev_adjacent_dev_unlink(dev, i->dev, i->ref_nr);
call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev,
&changeupper_info.info);
}
-@@ -6118,6 +6165,7 @@ int dev_set_mac_address(struct net_devic
+@@ -6115,6 +6162,7 @@ int dev_set_mac_address(struct net_devic
if (err)
return err;
dev->addr_assign_type = NET_ADDR_SET;
return 0;
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
-@@ -1637,6 +1637,8 @@ struct net_device {
+@@ -1639,6 +1639,8 @@ struct net_device {
struct netdev_hw_addr_list mc;
struct netdev_hw_addr_list dev_addrs;
/**
* struct net_device - The DEVICE structure.
-@@ -1602,6 +1604,11 @@ struct net_device {
+@@ -1603,6 +1605,11 @@ struct net_device {
const struct l3mdev_ops *l3mdev_ops;
#endif
const struct header_ops *header_ops;
unsigned int flags;
-@@ -1668,6 +1675,10 @@ struct net_device {
+@@ -1670,6 +1677,10 @@ struct net_device {
struct mpls_dev __rcu *mpls_ptr;
#endif
help
--- a/net/core/dev.c
+++ b/net/core/dev.c
-@@ -2713,10 +2713,20 @@ static int xmit_one(struct sk_buff *skb,
+@@ -2708,10 +2708,20 @@ static int xmit_one(struct sk_buff *skb,
if (!list_empty(&ptype_all) || !list_empty(&dev->ptype_all))
dev_queue_xmit_nit(skb, dev);
/**************************************************
* MII
**************************************************/
-@@ -1539,6 +1551,14 @@ int bgmac_enet_probe(struct bgmac *info)
+@@ -1549,6 +1561,14 @@ int bgmac_enet_probe(struct bgmac *bgmac
net_dev->hw_features = net_dev->features;
net_dev->vlan_features = net_dev->features;
err = register_netdev(bgmac->net_dev);
if (err) {
dev_err(bgmac->dev, "Cannot register net device\n");
-@@ -1562,6 +1582,10 @@ EXPORT_SYMBOL_GPL(bgmac_enet_probe);
+@@ -1571,6 +1591,10 @@ EXPORT_SYMBOL_GPL(bgmac_enet_probe);
void bgmac_enet_remove(struct bgmac *bgmac)
{
+ struct platform_device *b53_device;
};
- int bgmac_enet_probe(struct bgmac *info);
+ struct bgmac *bgmac_alloc(struct device *dev);
--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
+++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
-@@ -231,6 +231,7 @@ static int bgmac_probe(struct bcma_devic
+@@ -230,6 +230,7 @@ static int bgmac_probe(struct bcma_devic
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
BOARD:=ramips
BOARDNAME:=MediaTek Ralink MIPS
SUBTARGETS:=rt305x mt7620 mt7621 mt7628 mt7688 rt3883 rt288x
-FEATURES:=squashfs gpio mips16
+FEATURES:=squashfs gpio
MAINTAINER:=John Crispin <john@phrozen.org>
KERNEL_PATCHVER:=4.4
set_usb_led "$board:orange:usb"
set_wifi_led "$board:orange:wifi"
;;
-gb-pc1|\
- ucidef_set_led_default "$board:green:status"
- ;;
gl-mt300a|\
gl-mt300n|\
gl-mt750)
ucidef_set_led_netdev "eth" "ETH" "$board:orange:eth" "eth0"
set_wifi_led "$board:green:status"
;;
+vocore2)
+ set_wifi_led "$board:fuchsia:status"
+ ;;
w502u)
set_usb_led "$board:blue:usb"
set_wifi_led "rt2800pci-phy0::radio"
microwrt|\
mpr-a2|\
ncs601w|\
+ omega2 | \
+ omega2p | \
timecloud|\
w150m|\
widora-neo|\
dir-320-b1|\
dir-610-a1|\
dir-615-h1|\
- gb-pc1|\
firewrt|\
hlk-rm04|\
mac1200rv2|\
"0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5@eth0"
;;
asl26555|\
- re6500|\
rp-n53)
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
"0:lan" "4:lan" "6t@eth0"
;;
newifi-d1)
- ucidef_set_interface_lan_wan "eth0.1" "eth0.2"
ucidef_add_switch "switch0" \
- "0:lan" "1:lan" "2:lan" "3:lan" "5:wan" "6t@eth0" "7t@eth0"
- ucidef_add_switch "switch1" \
- "4:lan" "6t@eth0" "7t@eth0"
+ "1:lan:2" "2:lan:1" "4:wan" "6@eth0"
+ ;;
+ re6500)
+ ucidef_add_switch "switch0" \
+ "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "6@eth0"
;;
rt-n56u)
ucidef_add_switch "switch0" \
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0"
;;
+ vocore2)
+ ucidef_add_switch "switch0" \
+ "0:lan" "2:lan" "6t@eth0"
+ ;;
f5d8235-v1|\
tew-714tru|\
v11st-fe|\
lan_mac=$(cat /sys/class/net/eth0/address)
lan_mac=$(macaddr_add "$lan_mac" 2)
;;
+ omega2|\
+ omega2p)
+ wan_mac=$(mtd_get_mac_binary factory 4)
+ lan_mac=$(mtd_get_mac_binary factory 46)
+ ;;
oy-0001)
lan_mac=$(mtd_get_mac_binary factory 40)
wan_mac=$(mtd_get_mac_binary factory 46)
dir-620-a1|\
dir-620-d1|\
dwr-512-b|\
- gb-pc1|\
hpm|\
hw550-3g|\
mac1200rv2|\
newifi-d1)
status_led="$board:blue:status"
;;
+ omega2| \
+ omega2p)
+ status_led="$board:amber:system"
+ ;;
oy-0001|\
sl-r7205|\
zbt-we826)
v22rw-2x2)
status_led="$board:green:security"
;;
+ vocore2)
+ status_led="$board:fuchsia:status"
+ ;;
w306r-v20|\
witi|\
zbt-wr8305rt)
*"FreeStation5")
name="freestation5"
;;
- *"GB-PC1")
- name="gb-pc1"
- ;;
*"GL-MT300A")
name="gl-mt300a"
;;
*"NW718")
name="nw718"
;;
+ *"Onion Omega2")
+ name="omega2"
+ ;;
+ *"Onion Omega2+")
+ name="omega2p"
+ ;;
*"OY-0001")
name="oy-0001"
;;
*"VoCore (16M)")
name="vocore-16M"
;;
+ *"VoCore2")
+ name="vocore2"
+ ;;
*"VR500")
name="vr500"
;;
firewrt|\
fonera20n|\
freestation5|\
- gb-pc1|\
gl-mt300a|\
gl-mt300n|\
gl-mt750|\
newifi-d1|\
nixcore|\
nw718|\
+ omega2|\
+ omega2p|\
oy-0001|\
pbr-d1|\
pbr-m1|\
ur-336un|\
v22rw-2x2|\
vocore|\
+ vocore2|\
vr500|\
w150m|\
w2914nsv2|\
+++ /dev/null
-/dts-v1/;
-
-#include "mt7621.dtsi"
-
-#include <dt-bindings/gpio/gpio.h>
-#include <dt-bindings/input/input.h>
-
-/ {
- compatible = "mediatek,mt7621-eval-board", "mediatek,mt7621-soc";
- model = "GB-PC1";
-
- memory@0 {
- device_type = "memory";
- reg = <0x0 0x1c000000>, <0x20000000 0x4000000>;
- };
-
- chosen {
- bootargs = "console=ttyS0,57600";
- };
-
- sdhci@10130000 {
- status = "okay";
- };
-
- palmbus@1E000000 {
- spi@b00 {
- status = "okay";
-
- m25p80@0 {
- #address-cells = <1>;
- #size-cells = <1>;
- compatible = "jedec,spi-nor";
- reg = <0 0>;
- linux,modalias = "m25p80";
- spi-max-frequency = <10000000>;
- m25p,chunked-io = <32>;
-
- partition@0 {
- label = "u-boot";
- reg = <0x0 0x30000>;
- read-only;
- };
-
- partition@30000 {
- label = "u-boot-env";
- reg = <0x30000 0x10000>;
- };
-
- partition@40000 {
- label = "firmware";
- reg = <0x50000 0x1fb0000>;
- };
-
- };
- };
-
- i2c@900 {
- compatible = "ralink,i2c-mt7621";
- reg = <0x900 0x100>;
- #address-cells = <1>;
- #size-cells = <0>;
- pinctrl-names = "default";
- pinctrl-0 = <&i2c_pins>;
- status = "okay";
- };
- };
-
- pcie@1e140000 {
- status = "okay";
- };
-
- ethernet@1e100000 {
- status = "okay";
- };
-
- gpio-keys-polled {
- compatible = "gpio-keys-polled";
- #address-cells = <1>;
- #size-cells = <0>;
- poll-interval = <20>;
-
- reset {
- label = "reset";
- gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>;
- linux,code = <KEY_RESTART>;
- };
- };
-
- gpio-leds {
- compatible = "gpio-leds";
-
- status {
- label = "gnubee:green:status";
- gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>;
- };
-
- system {
- label = "gnubee:green:system";
- gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
- };
- };
-
- gpio-power {
- compatible = "gpio-power";
-
- 26 {
- label = "gnubee:power:gpio26";
- gpios = <&gpio0 26 GPIO_ACTIVE_LOW>;
- };
-
- 28 {
- label = "gnubee:power:gpio28";
- gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
- };
-
- 29 {
- label = "gnubee:power:gpio29";
- gpios = <&gpio0 29 GPIO_ACTIVE_LOW>;
- };
-
- 30 {
- label = "gnubee:power:gpio30";
- gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>;
- };
- };
-
- pinctrl {
- state_default: pinctrl0 {
- gpio {
- ralink,group = "wdt", "rgmii2", "mdio";
- ralink,function = "gpio";
- };
- };
- };
-};
--- /dev/null
+/dts-v1/;
+
+#include "OMEGA2.dtsi"
+
+/ {
+ model = "Onion Omega2";
+
+ memory@0 {
+ device_type = "memory";
+ reg = <0x0 0x4000000>;
+ };
+};
+
+&firmware {
+ reg = <0x50000 0xfb0000>;
+};
+
+&system_led {
+ label = "omega2:amber:system";
+};
--- /dev/null
+#include "mt7628an.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+ compatible = "onion,omega", "mediatek,mt7628an-soc";
+
+ chosen {
+ bootargs = "console=ttyS0,115200";
+ };
+
+ gpio-leds {
+ compatible = "gpio-leds";
+
+ system_led: system {
+ gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ gpio-keys-polled {
+ compatible = "gpio-keys-polled";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ poll-interval = <20>;
+
+ reset {
+ label = "reset";
+ gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>;
+ linux,code = <KEY_RESTART>;
+ };
+ };
+};
+
+&pinctrl {
+ state_default: pinctrl0 {
+ gpio {
+ ralink,group = "gpio";
+ ralink,function = "gpio";
+ };
+
+ perst {
+ ralink,group = "perst";
+ ralink,function = "gpio";
+ };
+
+ refclk {
+ ralink,group = "refclk";
+ ralink,function = "gpio";
+ };
+
+ i2s {
+ ralink,group = "i2s";
+ ralink,function = "gpio";
+ };
+
+ spis {
+ ralink,group = "spis";
+ ralink,function = "gpio";
+ };
+
+ wled_kn {
+ ralink,group = "wled_kn";
+ ralink,function = "gpio";
+ };
+
+ wled_an {
+ ralink,group = "wled_an";
+ ralink,function = "gpio";
+ };
+
+ wdt {
+ ralink,group = "wdt";
+ ralink,function = "gpio";
+ };
+
+ pwm0 {
+ ralink,group = "pwm0";
+ ralink,function = "gpio";
+ };
+
+ pwm1 {
+ ralink,group = "pwm1";
+ ralink,function = "gpio";
+ };
+ };
+};
+
+&gpio1 {
+ status = "okay";
+};
+
+&gpio2 {
+ status = "okay";
+};
+
+&wmac {
+ status = "okay";
+};
+
+&spi0 {
+ status = "okay";
+
+ pinctrl-names = "default";
+ pinctrl-0 = <&spi_pins>, <&spi_cs1_pins>;
+
+ m25p80@0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "jedec,spi-nor";
+ reg = <0>;
+ spi-max-frequency = <40000000>;
+ m25p,chunked-io = <31>;
+
+ partition@0 {
+ label = "u-boot";
+ reg = <0x0 0x30000>;
+ read-only;
+ };
+
+ partition@30000 {
+ label = "u-boot-env";
+ reg = <0x30000 0x10000>;
+ read-only;
+ };
+
+ factory: partition@40000 {
+ label = "factory";
+ reg = <0x40000 0x10000>;
+ read-only;
+ };
+
+ firmware: partition@50000 {
+ label = "firmware";
+ };
+ };
+
+ spidev@1 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "linux,spidev";
+ reg = <1>;
+ spi-max-frequency = <40000000>;
+ };
+};
+
+&i2c {
+ status = "okay";
+};
+
+&uart1 {
+ status = "okay";
+};
+
+&uart2 {
+ status = "okay";
+};
+
+ðernet {
+ mtd-mac-address = <&factory 0x28>;
+};
+
+&sdhci {
+ status = "okay";
+ mediatek,cd-low;
+};
+
+&wmac {
+ status = "okay";
+};
--- /dev/null
+/dts-v1/;
+
+#include "OMEGA2.dtsi"
+
+/ {
+ model = "Onion Omega2+";
+
+ memory@0 {
+ device_type = "memory";
+ reg = <0x0 0x8000000>;
+ };
+};
+
+&firmware {
+ reg = <0x50000 0x1fb0000>;
+};
+
+&system_led {
+ label = "omega2p:amber:system";
+};
--- /dev/null
+/dts-v1/;
+
+#include "mt7628an.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+ compatible = "vocore,VoCore2", "mediatek,mt7628an-soc";
+ model = "VoCore2";
+
+ chosen {
+ bootargs = "console=ttyS2,115200";
+ };
+
+ memory@0 {
+ device_type = "memory";
+ reg = <0x0 0x4000000>;
+ };
+
+ gpio-leds {
+ compatible = "gpio-leds";
+
+ status {
+ label = "vocore2:fuchsia:status";
+ gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
+ };
+ };
+};
+
+&pinctrl {
+ state_default: pinctrl0 {
+ gpio {
+ ralink,group = "refclk", "gpio";
+ ralink,function = "gpio";
+ };
+
+ agpio {
+ ralink,group = "agpio";
+ ralink,function = "uart2";
+ };
+ };
+
+ uart1_pins: uart1 {
+ uart1 {
+ ralink,group = "uart1";
+ ralink,function = "uart1";
+ };
+ };
+
+ uart2_pins: uart2 {
+ uart2 {
+ ralink,group = "spis";
+ ralink,function = "pwm";
+ };
+ };
+};
+
+&wmac {
+ status = "okay";
+ ralink,mtd-eeprom = <&factory 0x4>;
+};
+
+&spi0 {
+ status = "okay";
+
+ m25p80@0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "jedec,spi-nor";
+ reg = <0>;
+ spi-max-frequency = <10000000>;
+ m25p,chunked-io = <32>;
+
+ partition@0 {
+ label = "u-boot";
+ reg = <0x0 0x30000>;
+ read-only;
+ };
+
+ partition@30000 {
+ label = "u-boot-env";
+ reg = <0x30000 0x10000>;
+ read-only;
+ };
+
+ factory: partition@40000 {
+ label = "factory";
+ reg = <0x40000 0x10000>;
+ read-only;
+ };
+
+ partition@50000 {
+ label = "firmware";
+ reg = <0x50000 0xfb0000>;
+ };
+ };
+};
+
+&esw {
+ mediatek,portmap = <0x7>;
+ mediatek,portdisable = <0x3a>;
+};
+
+&i2s {
+ status = "okay";
+};
+
+&gdma {
+ status = "okay";
+};
+
+&pwm {
+ status = "okay";
+};
+
+&uart1 {
+ status = "okay";
+};
+
+&uart2 {
+ status = "okay";
+};
};
partition@50000 {
- label = "linux";
+ label = "firmware";
reg = <0x50000 0x3b0000>;
};
};
mtd-mac-address = <&factory 0x4>;
port@0 {
- mediatek,fixed-link = <1000 1 1 1>;
+ mediatek,fixed-link = <100 1 1 1>;
+ };
+
+ mdio-bus {
+ status = "okay";
+
+ phy0: ethernet-phy@0 {
+ phy-mode = "mii";
+ reg = <0>;
+ };
};
};
};
};
+&pcie {
+ status = "okay";
+
+ pcie0 {
+ rt5592@0,0 {
+ reg = <0x0000 0 0 0 0>;
+ device_type = "pci";
+ ralink,mtd-eeprom = <&factory 0x8000>;
+ };
+ };
+
+ pcie1 {
+ mt76@1,0 {
+ reg = <0x0000 0 0 0 0>;
+ device_type = "pci";
+ mediatek,mtd-eeprom = <&factory 0x0000>;
+ mediatek,5ghz = <0>;
+ };
+ };
+};
+
&xhci {
status = "disabled";
};
--- /dev/null
+#
+# MT7620A Profiles
+#
+
+define Build/tplink-header
+ $(STAGING_DIR_HOST)/bin/mktplinkfw2 -a 0x4 -V "ver. 2.0" -B $(1) \
+ -o $@.new -k $@ -r $(IMAGE_ROOTFS) && mv $@.new $@
+endef
+
+define Build/pad-kernel-ex2700
+ cp $@ $@.tmp && dd if=/dev/zero bs=64 count=1 >> $@.tmp \
+ && dd if=$@.tmp of=$@.new bs=64k conv=sync && truncate -s -64 $@.new \
+ && cat ex2700-fakeroot.uImage >> $@.new && rm $@.tmp && mv $@.new $@
+endef
+
+define Build/netgear-header
+ $(STAGING_DIR_HOST)/bin/mkdniimg \
+ $(1) -v OpenWrt -i $@ \
+ -o $@.new && mv $@.new $@
+endef
+
+define Build/elecom-header
+ cp $@ $(KDIR)/v_0.0.0.bin
+ ( \
+ mkhash md5 $(KDIR)/v_0.0.0.bin && \
+ echo 458 \
+ ) | mkhash md5 > $(KDIR)/v_0.0.0.md5
+ $(STAGING_DIR_HOST)/bin/tar -cf $@ -C $(KDIR) v_0.0.0.bin v_0.0.0.md5
+endef
+
+define Build/zyimage
+ $(STAGING_DIR_HOST)/bin/zyimage $(1) $@
+endef
+
+define Device/ArcherC20i
+ DTS := ArcherC20i
+ SUPPORTED_DEVICES := c20i
+ KERNEL := $(KERNEL_DTB)
+ KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-header ArcherC20i -c
+ IMAGE/sysupgrade.bin := append-kernel | tplink-header ArcherC20i -j | append-metadata
+ DEVICE_TITLE := TP-Link ArcherC20i
+endef
+TARGET_DEVICES += ArcherC20i
+
+define Device/ArcherC50
+ DTS := ArcherC50
+ SUPPORTED_DEVICES := c50
+ KERNEL := $(KERNEL_DTB)
+ KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-header ArcherC50 -c
+ IMAGE/sysupgrade.bin := append-kernel | tplink-header ArcherC50 -j | append-metadata
+ DEVICE_TITLE := TP-Link ArcherC50
+endef
+TARGET_DEVICES += ArcherC50
+
+define Device/ArcherMR200
+ DTS := ArcherMR200
+ SUPPORTED_DEVICES := mr200
+ KERNEL := $(KERNEL_DTB)
+ KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-header ArcherMR200 -c
+ IMAGE/sysupgrade.bin := append-kernel | tplink-header ArcherMR200 -j | append-metadata
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-net kmod-usb-net-rndis kmod-usb-serial kmod-usb-serial-option adb
+ DEVICE_TITLE := TP-Link ArcherMR200
+endef
+TARGET_DEVICES += ArcherMR200
+
+define Device/ex2700
+ DTS := EX2700
+ BLOCKSIZE := 4k
+ IMAGE_SIZE := $(ralink_default_fw_size_4M)
+ IMAGES += factory.bin
+ KERNEL := $(KERNEL_DTB) | uImage lzma | pad-kernel-ex2700
+ IMAGE/factory.bin := $$(sysupgrade_bin) | check-size $$$$(IMAGE_SIZE) | \
+ netgear-header -B EX2700 -H 29764623+4+0+32+2x2+0
+ DEVICE_TITLE := Netgear EX2700
+endef
+TARGET_DEVICES += ex2700
+
+define Device/wt3020-4M
+ DTS := WT3020-4M
+ BLOCKSIZE := 4k
+ IMAGE_SIZE := $(ralink_default_fw_size_4M)
+ IMAGES += factory.bin
+ IMAGE/factory.bin := $$(sysupgrade_bin) | check-size $$$$(IMAGE_SIZE) | \
+ poray-header -B WT3020 -F 4M
+ DEVICE_TITLE := Nexx WT3020 (4MB)
+endef
+TARGET_DEVICES += wt3020-4M
+
+define Device/wt3020-8M
+ DTS := WT3020-8M
+ IMAGES += factory.bin
+ IMAGE/factory.bin := $$(sysupgrade_bin) | check-size $$$$(IMAGE_SIZE) | \
+ poray-header -B WT3020 -F 8M
+ DEVICE_TITLE := Nexx WT3020 (8MB)
+endef
+TARGET_DEVICES += wt3020-8M
+
+define Device/wrh-300cr
+ DTS := WRH-300CR
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ IMAGES += factory.bin
+ IMAGE/factory.bin := $$(sysupgrade_bin) | check-size $$$$(IMAGE_SIZE) | \
+ elecom-header
+ DEVICE_TITLE := Elecom WRH-300CR
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
+endef
+TARGET_DEVICES += wrh-300cr
+
+define Device/e1700
+ DTS := E1700
+ IMAGES += factory.bin
+ IMAGE/factory.bin := $$(sysupgrade_bin) | check-size $$$$(IMAGE_SIZE) | \
+ umedia-header 0x013326
+ DEVICE_TITLE := Linksys E1700
+endef
+TARGET_DEVICES += e1700
+
+define Device/ai-br100
+ DTS := AI-BR100
+ IMAGE_SIZE := 7936k
+ DEVICE_TITLE := Aigale Ai-BR100
+ DEVICE_PACKAGES:= kmod-usb2 kmod-usb-ohci
+endef
+TARGET_DEVICES += ai-br100
+
+define Device/whr-300hp2
+ DTS := WHR-300HP2
+ IMAGE_SIZE := 6848k
+ DEVICE_TITLE := Buffalo WHR-300HP2
+endef
+TARGET_DEVICES += whr-300hp2
+
+define Device/whr-600d
+ DTS := WHR-600D
+ IMAGE_SIZE := 6848k
+ DEVICE_TITLE := Buffalo WHR-600D
+endef
+TARGET_DEVICES += whr-600d
+
+define Device/whr-1166d
+ DTS := WHR-1166D
+ IMAGE_SIZE := 15040k
+ DEVICE_TITLE := Buffalo WHR-1166D
+endef
+TARGET_DEVICES += whr-1166d
+
+define Device/dir-810l
+ DTS := DIR-810L
+ IMAGE_SIZE := 6720k
+ DEVICE_TITLE := D-Link DIR-810L
+endef
+TARGET_DEVICES += dir-810l
+
+define Device/na930
+ DTS := NA930
+ IMAGE_SIZE := 20m
+ DEVICE_TITLE := Sercomm NA930
+endef
+TARGET_DEVICES += na930
+
+define Device/microwrt
+ DTS := MicroWRT
+ IMAGE_SIZE := 16128k
+ DEVICE_TITLE := Microduino MicroWRT
+endef
+TARGET_DEVICES += microwrt
+
+define Device/mt7620a
+ DTS := MT7620a
+ DEVICE_TITLE := MediaTek MT7620a EVB
+endef
+TARGET_DEVICES += mt7620a
+
+define Device/mt7620a_mt7610e
+ DTS := MT7620a_MT7610e
+ DEVICE_TITLE := MediaTek MT7620a + MT7610e EVB
+endef
+TARGET_DEVICES += mt7620a_mt7610e
+
+define Device/mt7620a_mt7530
+ DTS := MT7620a_MT7530
+ DEVICE_TITLE := MediaTek MT7620a + MT7530 EVB
+endef
+TARGET_DEVICES += mt7620a_mt7530
+
+define Device/mt7620a_v22sg
+ DTS := MT7620a_V22SG
+ DEVICE_TITLE := MediaTek MT7620a V22SG
+endef
+TARGET_DEVICES += mt7620a_v22sg
+
+define Device/rp-n53
+ DTS := RP-N53
+ DEVICE_TITLE := Asus RP-N53
+endef
+TARGET_DEVICES += rp-n53
+
+define Device/cf-wr800n
+ DTS := CF-WR800N
+ DEVICE_TITLE := Comfast CF-WR800N
+endef
+TARGET_DEVICES += cf-wr800n
+
+define Device/cs-qr10
+ DTS := CS-QR10
+ DEVICE_TITLE := Planex CS-QR10
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-i2c-core kmod-i2c-ralink kmod-sound-core kmod-sound-mtk kmod-sdhci-mt7620
+endef
+TARGET_DEVICES += cs-qr10
+
+define Device/db-wrt01
+ DTS := DB-WRT01
+ DEVICE_TITLE := Planex DB-WRT01
+endef
+TARGET_DEVICES += db-wrt01
+
+define Device/mzk-750dhp
+ DTS := MZK-750DHP
+ DEVICE_TITLE := Planex MZK-750DHP
+ DEVICE_PACKAGES := kmod-mt76
+endef
+TARGET_DEVICES += mzk-750dhp
+
+define Device/mzk-ex300np
+ DTS := MZK-EX300NP
+ DEVICE_TITLE := Planex MZK-EX300NP
+endef
+TARGET_DEVICES += mzk-ex300np
+
+define Device/mzk-ex750np
+ DTS := MZK-EX750NP
+ DEVICE_TITLE := Planex MZK-EX750NP
+ DEVICE_PACKAGES := kmod-mt76
+endef
+TARGET_DEVICES += mzk-ex750np
+
+define Device/hc5661
+ DTS := HC5661
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := HiWiFi HC5661
+ DEVICE_PACKAGES := kmod-usb2 kmod-sdhci kmod-sdhci-mt7620 kmod-usb-ledtrig-usbport
+endef
+TARGET_DEVICES += hc5661
+
+define Device/hc5761
+ DTS := HC5761
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := HiWiFi HC5761
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-sdhci kmod-sdhci-mt7620 kmod-usb-ledtrig-usbport
+endef
+TARGET_DEVICES += hc5761
+
+define Device/hc5861
+ DTS := HC5861
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := HiWiFi HC5861
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-sdhci kmod-sdhci-mt7620 kmod-usb-ledtrig-usbport
+endef
+TARGET_DEVICES += hc5861
+
+define Device/oy-0001
+ DTS := OY-0001
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := Oh Yeah OY-0001
+endef
+TARGET_DEVICES += oy-0001
+
+define Device/psg1208
+ DTS := PSG1208
+ DEVICE_TITLE := Phicomm PSG1208
+ DEVICE_PACKAGES := kmod-mt76
+endef
+TARGET_DEVICES += psg1208
+
+define Device/psg1218
+ DTS := PSG1218
+ DEVICE_TITLE := Phicomm PSG1218
+ DEVICE_PACKAGES := kmod-mt76
+endef
+TARGET_DEVICES += psg1218
+
+define Device/y1
+ DTS := Y1
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := Lenovo Y1
+endef
+TARGET_DEVICES += y1
+
+define Device/y1s
+ DTS := Y1S
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := Lenovo Y1S
+endef
+TARGET_DEVICES += y1s
+
+define Device/mlw221
+ DTS := MLW221
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := Kingston MLW221
+endef
+TARGET_DEVICES += mlw221
+
+define Device/mlwg2
+ DTS := MLWG2
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := Kingston MLWG2
+endef
+TARGET_DEVICES += mlwg2
+
+define Device/wmr-300
+ DTS := WMR-300
+ DEVICE_TITLE := Buffalo WMR-300
+endef
+TARGET_DEVICES += wmr-300
+
+define Device/rt-n14u
+ DTS := RT-N14U
+ DEVICE_TITLE := Asus RT-N14u
+endef
+TARGET_DEVICES += rt-n14u
+
+define Device/wrtnode
+ DTS := WRTNODE
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := WRTNode
+endef
+TARGET_DEVICES += wrtnode
+
+define Device/miwifi-mini
+ DTS := MIWIFI-MINI
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := Xiaomi MiWiFi Mini
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
+endef
+TARGET_DEVICES += miwifi-mini
+
+define Device/gl-mt300a
+ DTS := GL-MT300A
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := GL-Inet GL-MT300A
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-mt76
+endef
+TARGET_DEVICES += gl-mt300a
+
+define Device/gl-mt300n
+ DTS := GL-MT300N
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := GL-Inet GL-MT300N
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-mt76
+endef
+TARGET_DEVICES += gl-mt300n
+
+define Device/gl-mt750
+ DTS := GL-MT750
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := GL-Inet GL-MT750
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-mt76
+endef
+TARGET_DEVICES += gl-mt750
+
+define Device/zte-q7
+ DTS := ZTE-Q7
+ DEVICE_TITLE := ZTE Q7
+endef
+TARGET_DEVICES += zte-q7
+
+define Device/youku-yk1
+ DTS := YOUKU-YK1
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := YOUKU YK1
+endef
+TARGET_DEVICES += youku-yk1
+
+define Device/zbt-ape522ii
+ DTS := ZBT-APE522II
+ DEVICE_TITLE := Zbtlink ZBT-APE522II
+ DEVICE_PACKAGES := kmod-mt76
+endef
+TARGET_DEVICES += zbt-ape522ii
+
+define Device/zbt-cpe102
+ DTS := ZBT-CPE102
+ DEVICE_TITLE := Zbtlink ZBT-CPE102
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
+endef
+TARGET_DEVICES += zbt-cpe102
+
+define Device/zbt-wa05
+ DTS := ZBT-WA05
+ DEVICE_TITLE := Zbtlink ZBT-WA05
+endef
+TARGET_DEVICES += zbt-wa05
+
+define Device/zbt-we826
+ DTS := ZBT-WE826
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := Zbtlink ZBT-WE826
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-mt76 kmod-sdhci-mt7620
+endef
+TARGET_DEVICES += zbt-we826
+
+define Device/zbt-wr8305rt
+ DTS := ZBT-WR8305RT
+ DEVICE_TITLE := Zbtlink ZBT-WR8305RT
+endef
+TARGET_DEVICES += zbt-wr8305rt
+
+define Device/tiny-ac
+ DTS := TINY-AC
+ DEVICE_TITLE := Dovado Tiny AC
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
+endef
+TARGET_DEVICES += tiny-ac
+
+define Device/dch-m225
+ DTS := DCH-M225
+ BLOCKSIZE := 4k
+ IMAGES += factory.bin
+ IMAGE_SIZE := 6848k
+ IMAGE/sysupgrade.bin := \
+ append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-rootfs | \
+ seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \
+ pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE)
+ IMAGE/factory.bin := \
+ append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \
+ append-rootfs | pad-rootfs -x 64 | \
+ seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \
+ seama-seal -m "signature=wapn22_dlink.2013gui_dap1320b" | \
+ check-size $$$$(IMAGE_SIZE)
+ DEVICE_TITLE := D-Link DCH-M225
+ DEVICE_PACKAGES := kmod-mt76
+endef
+TARGET_DEVICES += dch-m225
+
+define Device/kn_rc
+ DTS := kn_rc
+ DEVICE_TITLE := ZyXEL Keenetic Omni
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport
+ IMAGES += factory.bin
+ IMAGE/factory.bin := $$(IMAGE/sysupgrade.bin) | check-size $$$$(IMAGE_SIZE) | \
+ zyimage -d 4882 -v "ZyXEL Keenetic Omni"
+endef
+TARGET_DEVICES += kn_rc
+
+define Device/kn_rf
+ DTS := kn_rf
+ DEVICE_TITLE := ZyXEL Keenetic Omni II
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport
+ IMAGES += factory.bin
+ IMAGE/factory.bin := $$(IMAGE/sysupgrade.bin) | check-size $$$$(IMAGE_SIZE) | \
+ zyimage -d 2102034 -v "ZyXEL Keenetic Omni II"
+endef
+TARGET_DEVICES += kn_rf
+
+define Device/kng_rc
+ DTS := kng_rc
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := ZyXEL Keenetic Viva
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport kmod-switch-rtl8366-smi kmod-switch-rtl8367b
+ IMAGES += factory.bin
+ IMAGE/factory.bin := $$(sysupgrade_bin) | check-size $$$$(IMAGE_SIZE) | \
+ zyimage -d 8997 -v "ZyXEL Keenetic Viva"
+endef
+TARGET_DEVICES += kng_rc
# MT7621 Profiles
#
-define Device/gb-pc1
- DTS := GB-PC1
- DEVICE_TITLE := GnuBee Personal Cloud One
- DEVICE_PACKAGES := kmod-ata-core kmod-ata-ahci
+define Build/ubnt-erx-factory-image
+ if [ -e $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE) -a "$$(stat -c%s $@)" -lt "$(KERNEL_SIZE)" ]; then \
+ echo '21001:6' > $(1).compat; \
+ $(TAR) -cf $(1) --transform='s/^.*/compat/' $(1).compat; \
+ \
+ $(TAR) -rf $(1) --transform='s/^.*/vmlinux.tmp/' $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE); \
+ mkhash md5 $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE) > $(1).md5; \
+ $(TAR) -rf $(1) --transform='s/^.*/vmlinux.tmp.md5/' $(1).md5; \
+ \
+ echo "dummy" > $(1).rootfs; \
+ $(TAR) -rf $(1) --transform='s/^.*/squashfs.tmp/' $(1).rootfs; \
+ \
+ mkhash md5 $(1).rootfs > $(1).md5; \
+ $(TAR) -rf $(1) --transform='s/^.*/squashfs.tmp.md5/' $(1).md5; \
+ \
+ echo '$(BOARD) $(VERSION_CODE) $(VERSION_NUMBER)' > $(1).version; \
+ $(TAR) -rf $(1) --transform='s/^.*/version.tmp/' $(1).version; \
+ \
+ $(CP) $(1) $(BIN_DIR)/; \
+ else \
+ echo "WARNING: initramfs kernel image too big, cannot generate factory image" >&2; \
+ fi
+endef
+
+define Device/11acnas
+ DTS := 11ACNAS
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := WeVO 11AC NAS Router
+ DEVICE_PACKAGES := kmod-usb3 kmod-usb-ledtrig-usbport kmod-mt76
+endef
+TARGET_DEVICES += 11acnas
+
+define Device/ac1200pro
+ DTS := AC1200pro
IMAGE_SIZE := $(ralink_default_fw_size_32M)
+ DEVICE_TITLE := Digineo AC1200 Pro
+ DEVICE_PACKAGES := kmod-usb3 kmod-ata-core kmod-ata-ahci
+endef
+TARGET_DEVICES += ac1200pro
+
+define Device/dir-860l-b1
+ DTS := DIR-860L-B1
+ BLOCKSIZE := 64k
+ IMAGES += factory.bin
+ KERNEL := kernel-bin | patch-dtb | relocate-kernel | lzma | uImage lzma
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ IMAGE/sysupgrade.bin := \
+ append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-rootfs | \
+ seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \
+ pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE)
+ IMAGE/factory.bin := \
+ append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \
+ append-rootfs | pad-rootfs -x 64 | \
+ seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \
+ seama-seal -m "signature=wrgac13_dlink.2013gui_dir860lb" | \
+ check-size $$$$(IMAGE_SIZE)
+ DEVICE_TITLE := D-Link DIR-860L B1
+ DEVICE_PACKAGES := kmod-usb3 kmod-usb-ledtrig-usbport
endef
+TARGET_DEVICES += dir-860l-b1
-TARGET_DEVICES += gb-pc1
+define Device/firewrt
+ DTS := FIREWRT
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := Firefly FireWRT
+ DEVICE_PACKAGES := kmod-usb3 kmod-usb-ledtrig-usbport
+endef
+TARGET_DEVICES += firewrt
define Device/mt7621
DTS := MT7621
endef
TARGET_DEVICES += mt7621
+define Device/newifi-d1
+ DTS := Newifi-D1
+ IMAGE_SIZE := $(ralink_default_fw_size_32M)
+ DEVICE_TITLE := Newifi D1
+ DEVICE_PACKAGES := kmod-usb3 kmod-usb-ledtrig-usbport
+endef
+TARGET_DEVICES += newifi-d1
+
+define Device/pbr-m1
+ DTS := PBR-M1
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := PBR-M1
+ DEVICE_PACKAGES := kmod-usb3 kmod-usb-ledtrig-usbport kmod-ata-core kmod-ata-ahci
+endef
+TARGET_DEVICES += pbr-m1
+
+define Device/rb750gr3
+ DTS := RB750Gr3
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := MikroTik RB750Gr3
+ DEVICE_PACKAGES := kmod-usb3 uboot-envtools -kmod-mt76 -kmod-rt2x00-lib -kmod-mac80211 -kmod-cfg80211 -wpad-mini -iwinfo
+endef
+TARGET_DEVICES += rb750gr3
+
+define Device/re6500
+ DTS := RE6500
+ DEVICE_TITLE := Linksys RE6500
+endef
+TARGET_DEVICES += re6500
+
+define Device/sap-g3200u3
+ DTS := SAP-G3200U3
+ DEVICE_TITLE := STORYLiNK SAP-G3200U3
+ DEVICE_PACKAGES := kmod-usb3 kmod-usb-ledtrig-usbport
+endef
+TARGET_DEVICES += sap-g3200u3
+
+define Device/sk-wb8
+ DTS := SK-WB8
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := SamKnows Whitebox 8
+ DEVICE_PACKAGES := kmod-usb3 kmod-usb-ledtrig-usbport uboot-envtools
+endef
+TARGET_DEVICES += sk-wb8
+
define Device/timecloud
DTS := Timecloud
DEVICE_TITLE := Thunder Timecloud
+ DEVICE_PACKAGES := kmod-usb3
endef
TARGET_DEVICES += timecloud
+define Device/ubnt-erx
+ DTS := UBNT-ERX
+ FILESYSTEMS := squashfs
+ KERNEL_SIZE := 3145728
+ KERNEL := $(KERNEL_DTB) | uImage lzma
+ IMAGES := sysupgrade.tar
+ KERNEL_INITRAMFS := $$(KERNEL) | ubnt-erx-factory-image $(KDIR)/tmp/$$(KERNEL_INITRAMFS_PREFIX)-factory.tar
+ IMAGE/sysupgrade.tar := sysupgrade-tar | append-metadata
+ DEVICE_TITLE := Ubiquiti EdgeRouter X
+ DEVICE_PACKAGES := -kmod-mt76 -kmod-rt2x00-lib -kmod-mac80211 -kmod-cfg80211 -wpad-mini -iwinfo
+endef
+TARGET_DEVICES += ubnt-erx
+
define Device/vr500
DTS := VR500
IMAGE_SIZE := 66453504
DEVICE_TITLE := Planex VR500
+ DEVICE_PACKAGES := kmod-usb3
endef
TARGET_DEVICES += vr500
+define Device/w2914nsv2
+ DTS := W2914NSV2
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := WeVO W2914NS v2
+ DEVICE_PACKAGES := kmod-usb3 kmod-usb-ledtrig-usbport kmod-mt76
+endef
+TARGET_DEVICES += w2914nsv2
+
+define Device/wf-2881
+ DTS := WF-2881
+ BLOCKSIZE := 128k
+ PAGESIZE := 2048
+ FILESYSTEMS := squashfs
+ IMAGE_SIZE := 129280k
+ KERNEL := $(KERNEL_DTB) | pad-offset $$(BLOCKSIZE) 64 | uImage lzma
+ UBINIZE_OPTS := -E 5
+ IMAGE/sysupgrade.bin := append-kernel | append-ubi | append-metadata | check-size $$$$(IMAGE_SIZE)
+ DEVICE_TITLE := NETIS WF-2881
+ DEVICE_PACKAGES := kmod-usb3 kmod-usb-ledtrig-usbport
+endef
+TARGET_DEVICES += wf-2881
+
+define Device/witi
+ DTS := WITI
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := MQmaker WiTi
+ DEVICE_PACKAGES := kmod-usb3 kmod-usb-ledtrig-usbport kmod-ata-core kmod-ata-ahci
+endef
+TARGET_DEVICES += witi
+
+define Device/wndr3700v5
+ DTS := WNDR3700V5
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := Netgear WNDR3700v5
+ DEVICE_PACKAGES := kmod-usb3
+endef
+TARGET_DEVICES += wndr3700v5
+
+define Device/wsr-1166
+ DTS := WSR-1166
+ IMAGE/sysupgrade.bin := trx | pad-rootfs | append-metadata
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := Buffalo WSR-1166
+endef
+TARGET_DEVICES += wsr-1166
+
+define Device/wsr-600
+ DTS := WSR-600
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := Buffalo WSR-600
+endef
+TARGET_DEVICES += wsr-600
+
+define Device/zbt-wg2626
+ DTS := ZBT-WG2626
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := ZBT WG2626
+ DEVICE_PACKAGES := kmod-usb3 kmod-usb-ledtrig-usbport kmod-ata-core kmod-ata-ahci
+endef
+TARGET_DEVICES += zbt-wg2626
+
+define Device/zbt-wg3526
+ DTS := ZBT-WG3526
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := ZBT WG3526
+ DEVICE_PACKAGES := kmod-usb3 kmod-usb-ledtrig-usbport kmod-ata-core kmod-ata-ahci
+endef
+TARGET_DEVICES += zbt-wg3526
+
# FIXME: is this still needed?
define Image/Prepare
#define Build/Compile
endef
TARGET_DEVICES += miwifi-nano
+define Device/vocore2
+ DTS := VOCORE2
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := VoCore VoCore2
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport \
+ kmod-sdhci kmod-sdhci-mt7620
+endef
+TARGET_DEVICES += vocore2
+
define Device/wl-wn575a3
DTS := WL-WN575A3
IMAGE_SIZE := $(ralink_default_fw_size_8M)
DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
endef
TARGET_DEVICES += widora-neo
+
+define Device/omega2
+ DTS := OMEGA2
+ IMAGE_SIZE := $(ralink_default_fw_size_16M)
+ DEVICE_TITLE := Onion Omega2
+ DEVICE_PACKAGES:= kmod-usb2 kmod-usb-ohci uboot-envtools
+endef
+TARGET_DEVICES += omega2
+
+define Device/omega2p
+ DTS := OMEGA2P
+ IMAGE_SIZE := $(ralink_default_fw_size_32M)
+ DEVICE_TITLE := Onion Omega2+
+ DEVICE_PACKAGES:= kmod-usb2 kmod-usb-ohci uboot-envtools kmod-sdhci-mt7620
+endef
+TARGET_DEVICES += omega2p
#
define Build/gemtek-header
- mkheader_gemtek $@ $@.new $(1) && mv $@.new $@
+ if [ -f $@ ]; then \
+ mkheader_gemtek $@ $@.new $(1) && \
+ mv $@.new $@; \
+ fi
endef
define Device/ar670w
BLOCKSIZE := 64k
DEVICE_TITLE := Airlink AR670W
IMAGE_SIZE := $(ralink_default_fw_size_4M)
- KERNEL := $(KERNEL_DTB)
+ KERNEL := $(KERNEL_DTB) | pad-to $$(BLOCKSIZE)
IMAGES += factory.bin
IMAGE/factory.bin := $$(sysupgrade_bin) | check-size $$$$(IMAGE_SIZE) | \
wrg-header wrgn16a_airlink_ar670w
define Device/ar725w
DTS := AR725W
- DEVICE_TITLE := Gemtek AR725W
+ DEVICE_TITLE := Airlink AR725W
IMAGES += factory.bin
- IMAGE/factory.bin := $$(sysupgrade_bin) | check-size $$$$(IMAGE_SIZE) | \
+ IMAGE/factory.bin := $$(sysupgrade_bin) | check-size 3328k | \
gemtek-header ar725w
endef
TARGET_DEVICES += ar725w
define Device/dwr-512-b
DTS := DWR-512-B
+ IMAGE_SIZE := 7700k
DEVICE_TITLE := D-Link DWR-512 B
DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-i2c-core kmod-i2c-ralink kmod-spi-dev \
kmod-usb-serial kmod-usb-serial-option kmod-usb-serial-wwan comgt
I2C_MT7621_MODULES:= \
CONFIG_I2C_MT7621:drivers/i2c/busses/i2c-mt7621
-define KernelPackage/i2c-mt7621
+define KernelPackage/i2c-mt7628
$(call i2c_defaults,$(I2C_MT7621_MODULES),59)
- TITLE:=MT7621 I2C Controller
+ TITLE:=MT7628/88 I2C Controller
DEPENDS:=kmod-i2c-core \
- @(TARGET_ramips_mt7621||TARGET_ramips_mt7628||TARGET_ramips_mt7688)
+ @(TARGET_ramips_mt7628||TARGET_ramips_mt7688)
endef
-define KernelPackage/i2c-mt7621/description
+define KernelPackage/i2c-mt7628/description
Kernel modules for enable mt7621 i2c controller.
endef
-$(eval $(call KernelPackage,i2c-mt7621))
+$(eval $(call KernelPackage,i2c-mt7628))
define KernelPackage/dma-ralink
SUBMENU:=Other modules
--- /dev/null
+CONFIG_ARCH_BINFMT_ELF_STATE=y
+CONFIG_ARCH_CLOCKSOURCE_DATA=y
+CONFIG_ARCH_DISCARD_MEMBLOCK=y
+CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
+CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
+# CONFIG_ARCH_HAS_GCOV_PROFILE_ALL is not set
+CONFIG_ARCH_HAS_RESET_CONTROLLER=y
+# CONFIG_ARCH_HAS_SG_CHAIN is not set
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
+CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+CONFIG_ARCH_SUPPORTS_UPROBES=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_ARCH_USE_BUILTIN_BSWAP=y
+CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
+CONFIG_AT803X_PHY=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_CEVT_R4K=y
+CONFIG_CEVT_SYSTICK_QUIRK=y
+CONFIG_CLKDEV_LOOKUP=y
+CONFIG_CLKEVT_RT3352=y
+CONFIG_CLKSRC_MMIO=y
+CONFIG_CLKSRC_OF=y
+CONFIG_CLKSRC_PROBE=y
+CONFIG_CLONE_BACKWARDS=y
+CONFIG_CMDLINE="rootfstype=squashfs,jffs2"
+CONFIG_CMDLINE_BOOL=y
+# CONFIG_CMDLINE_OVERRIDE is not set
+CONFIG_CPU_GENERIC_DUMP_TLB=y
+CONFIG_CPU_HAS_PREFETCH=y
+CONFIG_CPU_HAS_SYNC=y
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_CPU_MIPS32=y
+# CONFIG_CPU_MIPS32_R1 is not set
+CONFIG_CPU_MIPS32_R2=y
+CONFIG_CPU_MIPSR2=y
+CONFIG_CPU_NEEDS_NO_SMARTMIPS_OR_MICROMIPS=y
+CONFIG_CPU_R4K_CACHE_TLB=y
+CONFIG_CPU_R4K_FPU=y
+CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
+CONFIG_CPU_SUPPORTS_HIGHMEM=y
+CONFIG_CPU_SUPPORTS_MSA=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_WORKQUEUE=y
+CONFIG_CSRC_R4K=y
+CONFIG_DEBUG_PINCTRL=y
+CONFIG_DMA_NONCOHERENT=y
+# CONFIG_DTB_MT7620A_EVAL is not set
+CONFIG_DTB_RT_NONE=y
+CONFIG_DTC=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_GENERIC_ATOMIC64=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_GENERIC_IO=y
+CONFIG_GENERIC_IRQ_CHIP=y
+CONFIG_GENERIC_IRQ_SHOW=y
+CONFIG_GENERIC_PCI_IOMAP=y
+CONFIG_GENERIC_PHY=y
+CONFIG_GENERIC_SCHED_CLOCK=y
+CONFIG_GENERIC_SMP_IDLE_THREAD=y
+CONFIG_GENERIC_TIME_VSYSCALL=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_DEVRES=y
+# CONFIG_GPIO_MT7621 is not set
+CONFIG_GPIO_RALINK=y
+CONFIG_GPIO_SYSFS=y
+CONFIG_HARDWARE_WATCHPOINTS=y
+CONFIG_HAS_DMA=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT_MAP=y
+# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
+# CONFIG_HAVE_ARCH_BITREVERSE is not set
+CONFIG_HAVE_ARCH_JUMP_LABEL=y
+CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
+CONFIG_HAVE_BPF_JIT=y
+CONFIG_HAVE_CC_STACKPROTECTOR=y
+CONFIG_HAVE_CLK=y
+CONFIG_HAVE_CONTEXT_TRACKING=y
+CONFIG_HAVE_C_RECORDMCOUNT=y
+CONFIG_HAVE_DEBUG_KMEMLEAK=y
+CONFIG_HAVE_DEBUG_STACKOVERFLOW=y
+CONFIG_HAVE_DMA_API_DEBUG=y
+CONFIG_HAVE_DMA_ATTRS=y
+CONFIG_HAVE_DMA_CONTIGUOUS=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_HAVE_IDE=y
+CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
+CONFIG_HAVE_KVM=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_HAVE_MACH_CLKDEV=y
+CONFIG_HAVE_MEMBLOCK=y
+CONFIG_HAVE_MEMBLOCK_NODE_MAP=y
+CONFIG_HAVE_MOD_ARCH_SPECIFIC=y
+CONFIG_HAVE_NET_DSA=y
+CONFIG_HAVE_OPROFILE=y
+CONFIG_HAVE_PERF_EVENTS=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
+CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
+CONFIG_HW_HAS_PCI=y
+CONFIG_HZ_PERIODIC=y
+CONFIG_ICPLUS_PHY=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_IRQCHIP=y
+CONFIG_IRQ_DOMAIN=y
+CONFIG_IRQ_FORCED_THREADING=y
+CONFIG_IRQ_INTC=y
+CONFIG_IRQ_MIPS_CPU=y
+CONFIG_IRQ_WORK=y
+CONFIG_LIBFDT=y
+CONFIG_MDIO_BOARDINFO=y
+CONFIG_MIPS=y
+CONFIG_MIPS_CLOCK_VSYSCALL=y
+# CONFIG_MIPS_CMDLINE_DTB_EXTEND is not set
+# CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set
+CONFIG_MIPS_CMDLINE_FROM_DTB=y
+# CONFIG_MIPS_ELF_APPENDED_DTB is not set
+# CONFIG_MIPS_HUGE_TLB_SUPPORT is not set
+CONFIG_MIPS_L1_CACHE_SHIFT=5
+# CONFIG_MIPS_MACHINE is not set
+CONFIG_MIPS_NO_APPENDED_DTB=y
+# CONFIG_MIPS_RAW_APPENDED_DTB is not set
+CONFIG_MIPS_SPRAM=y
+CONFIG_MODULES_USE_ELF_REL=y
+# CONFIG_MT7621_WDT is not set
+# CONFIG_MTD_CFI_INTELEXT is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+CONFIG_MTD_M25P80=y
+CONFIG_MTD_NAND_MT7620=y
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_SPI_NOR=y
+CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y
+CONFIG_MTD_SPLIT_FIRMWARE=y
+CONFIG_MTD_SPLIT_SEAMA_FW=y
+CONFIG_MTD_SPLIT_TPLINK_FW=y
+CONFIG_MTD_SPLIT_UIMAGE_FW=y
+CONFIG_NEED_DMA_MAP_STATE=y
+CONFIG_NEED_PER_CPU_KM=y
+CONFIG_NET_MEDIATEK_GSW_MT7620=y
+CONFIG_NET_MEDIATEK_MDIO=y
+CONFIG_NET_MEDIATEK_MDIO_MT7620=y
+CONFIG_NET_MEDIATEK_MT7620=y
+# CONFIG_NET_MEDIATEK_RT3050 is not set
+CONFIG_NET_MEDIATEK_SOC=y
+CONFIG_NET_VENDOR_MEDIATEK=y
+CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y
+# CONFIG_NO_IOPORT_MAP is not set
+CONFIG_OF=y
+CONFIG_OF_ADDRESS=y
+CONFIG_OF_ADDRESS_PCI=y
+CONFIG_OF_EARLY_FLATTREE=y
+CONFIG_OF_FLATTREE=y
+CONFIG_OF_GPIO=y
+CONFIG_OF_IRQ=y
+CONFIG_OF_MDIO=y
+CONFIG_OF_MTD=y
+CONFIG_OF_NET=y
+CONFIG_OF_PCI=y
+CONFIG_OF_PCI_IRQ=y
+CONFIG_PCI=y
+CONFIG_PCI_DOMAINS=y
+CONFIG_PERF_USE_VMALLOC=y
+CONFIG_PGTABLE_LEVELS=2
+CONFIG_PHYLIB=y
+CONFIG_PHY_RALINK_USB=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_RT2880=y
+# CONFIG_PINCTRL_SINGLE is not set
+CONFIG_RALINK=y
+CONFIG_RALINK_WDT=y
+# CONFIG_RCU_STALL_COMMON is not set
+CONFIG_RESET_CONTROLLER=y
+CONFIG_SCHED_HRTICK=y
+# CONFIG_SCHED_INFO is not set
+# CONFIG_SCSI_DMA is not set
+# CONFIG_SERIAL_8250_FSL is not set
+CONFIG_SERIAL_8250_RT288X=y
+CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_SOC_MT7620=y
+# CONFIG_SOC_MT7621 is not set
+# CONFIG_SOC_RT288X is not set
+# CONFIG_SOC_RT305X is not set
+# CONFIG_SOC_RT3883 is not set
+CONFIG_SPI=y
+CONFIG_SPI_MASTER=y
+# CONFIG_SPI_MT7621 is not set
+CONFIG_SPI_RT2880=y
+CONFIG_SRCU=y
+CONFIG_SWCONFIG=y
+CONFIG_SWCONFIG_LEDS=y
+CONFIG_SYSCTL_EXCEPTION_TRACE=y
+CONFIG_SYS_HAS_CPU_MIPS32_R1=y
+CONFIG_SYS_HAS_CPU_MIPS32_R2=y
+CONFIG_SYS_HAS_EARLY_PRINTK=y
+CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
+CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
+CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
+CONFIG_SYS_SUPPORTS_MIPS16=y
+CONFIG_TICK_CPU_ACCOUNTING=y
+CONFIG_USB_SUPPORT=y
+CONFIG_USE_OF=y
+CONFIG_WATCHDOG_CORE=y
+CONFIG_ZONE_DMA_FLAG=0
--- /dev/null
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/Default
+ NAME:=Default Profile
+ PACKAGES:= kmod-usb-core kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport
+ PRIORITY:=1
+endef
+
+define Profile/Default/Description
+ Default package set compatible with most boards.
+endef
+$(eval $(call Profile,Default))
--- /dev/null
+#
+# Copyright (C) 2009 OpenWrt.org
+#
+
+SUBTARGET:=mt7620
+BOARDNAME:=MT7620 based boards
+FEATURES+=usb
+CPU_TYPE:=24kc
+
+DEFAULT_PACKAGES += kmod-rt2800-pci kmod-rt2800-soc kmod-mt76
+
+define Target/Description
+ Build firmware images for Ralink MT7620 based boards.
+endef
+
FEATURES+=usb rtc nand
CPU_TYPE:=24kc
-DEFAULT_PACKAGES += kmod-usb3
+DEFAULT_PACKAGES += kmod-mt76
KERNEL_PATCHVER:=4.4
--- /dev/null
+CONFIG_ARCH_BINFMT_ELF_STATE=y
+CONFIG_ARCH_CLOCKSOURCE_DATA=y
+CONFIG_ARCH_DISCARD_MEMBLOCK=y
+CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
+CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
+# CONFIG_ARCH_HAS_GCOV_PROFILE_ALL is not set
+CONFIG_ARCH_HAS_RESET_CONTROLLER=y
+# CONFIG_ARCH_HAS_SG_CHAIN is not set
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
+CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+CONFIG_ARCH_SUPPORTS_UPROBES=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_ARCH_USE_BUILTIN_BSWAP=y
+CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
+CONFIG_AT803X_PHY=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_CEVT_R4K=y
+CONFIG_CEVT_SYSTICK_QUIRK=y
+CONFIG_CLKDEV_LOOKUP=y
+CONFIG_CLKEVT_RT3352=y
+CONFIG_CLKSRC_MMIO=y
+CONFIG_CLKSRC_OF=y
+CONFIG_CLKSRC_PROBE=y
+CONFIG_CLONE_BACKWARDS=y
+CONFIG_CMDLINE="rootfstype=squashfs,jffs2"
+CONFIG_CMDLINE_BOOL=y
+# CONFIG_CMDLINE_OVERRIDE is not set
+CONFIG_CPU_GENERIC_DUMP_TLB=y
+CONFIG_CPU_HAS_PREFETCH=y
+CONFIG_CPU_HAS_SYNC=y
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_CPU_MIPS32=y
+# CONFIG_CPU_MIPS32_R1 is not set
+CONFIG_CPU_MIPS32_R2=y
+CONFIG_CPU_MIPSR2=y
+CONFIG_CPU_NEEDS_NO_SMARTMIPS_OR_MICROMIPS=y
+CONFIG_CPU_R4K_CACHE_TLB=y
+CONFIG_CPU_R4K_FPU=y
+CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
+CONFIG_CPU_SUPPORTS_HIGHMEM=y
+CONFIG_CPU_SUPPORTS_MSA=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_WORKQUEUE=y
+CONFIG_CSRC_R4K=y
+CONFIG_DEBUG_PINCTRL=y
+CONFIG_DMA_NONCOHERENT=y
+# CONFIG_DTB_MT7620A_EVAL is not set
+CONFIG_DTB_RT_NONE=y
+CONFIG_DTC=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_GENERIC_ATOMIC64=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_GENERIC_IO=y
+CONFIG_GENERIC_IRQ_CHIP=y
+CONFIG_GENERIC_IRQ_SHOW=y
+CONFIG_GENERIC_PCI_IOMAP=y
+CONFIG_GENERIC_PHY=y
+CONFIG_GENERIC_SCHED_CLOCK=y
+CONFIG_GENERIC_SMP_IDLE_THREAD=y
+CONFIG_GENERIC_TIME_VSYSCALL=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_DEVRES=y
+CONFIG_GPIO_MT7621=y
+# CONFIG_GPIO_RALINK is not set
+CONFIG_GPIO_SYSFS=y
+CONFIG_HARDWARE_WATCHPOINTS=y
+CONFIG_HAS_DMA=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT_MAP=y
+# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
+# CONFIG_HAVE_ARCH_BITREVERSE is not set
+CONFIG_HAVE_ARCH_JUMP_LABEL=y
+CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
+CONFIG_HAVE_BPF_JIT=y
+CONFIG_HAVE_CC_STACKPROTECTOR=y
+CONFIG_HAVE_CLK=y
+CONFIG_HAVE_CONTEXT_TRACKING=y
+CONFIG_HAVE_C_RECORDMCOUNT=y
+CONFIG_HAVE_DEBUG_KMEMLEAK=y
+CONFIG_HAVE_DEBUG_STACKOVERFLOW=y
+CONFIG_HAVE_DMA_API_DEBUG=y
+CONFIG_HAVE_DMA_ATTRS=y
+CONFIG_HAVE_DMA_CONTIGUOUS=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_HAVE_IDE=y
+CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
+CONFIG_HAVE_KVM=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_HAVE_MACH_CLKDEV=y
+CONFIG_HAVE_MEMBLOCK=y
+CONFIG_HAVE_MEMBLOCK_NODE_MAP=y
+CONFIG_HAVE_MOD_ARCH_SPECIFIC=y
+CONFIG_HAVE_NET_DSA=y
+CONFIG_HAVE_OPROFILE=y
+CONFIG_HAVE_PERF_EVENTS=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
+CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
+CONFIG_HW_HAS_PCI=y
+CONFIG_HZ_PERIODIC=y
+CONFIG_ICPLUS_PHY=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_IRQCHIP=y
+CONFIG_IRQ_DOMAIN=y
+CONFIG_IRQ_FORCED_THREADING=y
+CONFIG_IRQ_INTC=y
+CONFIG_IRQ_MIPS_CPU=y
+CONFIG_IRQ_WORK=y
+CONFIG_LIBFDT=y
+CONFIG_MDIO_BOARDINFO=y
+CONFIG_MIPS=y
+CONFIG_MIPS_CLOCK_VSYSCALL=y
+# CONFIG_MIPS_CMDLINE_DTB_EXTEND is not set
+# CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set
+CONFIG_MIPS_CMDLINE_FROM_DTB=y
+# CONFIG_MIPS_ELF_APPENDED_DTB is not set
+# CONFIG_MIPS_HUGE_TLB_SUPPORT is not set
+CONFIG_MIPS_L1_CACHE_SHIFT=5
+# CONFIG_MIPS_MACHINE is not set
+CONFIG_MIPS_NO_APPENDED_DTB=y
+# CONFIG_MIPS_RAW_APPENDED_DTB is not set
+CONFIG_MIPS_SPRAM=y
+CONFIG_MODULES_USE_ELF_REL=y
+CONFIG_MT7621_WDT=y
+# CONFIG_MTD_CFI_INTELEXT is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+CONFIG_MTD_M25P80=y
+CONFIG_MTD_NAND_MT7620=y
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_SPI_NOR=y
+CONFIG_MTD_SPLIT_FIRMWARE=y
+CONFIG_MTD_SPLIT_UIMAGE_FW=y
+CONFIG_NEED_DMA_MAP_STATE=y
+CONFIG_NEED_PER_CPU_KM=y
+CONFIG_NET_MEDIATEK_ESW_RT3050=y
+# CONFIG_NET_MEDIATEK_MT7620 is not set
+CONFIG_NET_MEDIATEK_RT3050=y
+CONFIG_NET_MEDIATEK_SOC=y
+CONFIG_NET_VENDOR_MEDIATEK=y
+CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y
+# CONFIG_NO_IOPORT_MAP is not set
+CONFIG_OF=y
+CONFIG_OF_ADDRESS=y
+CONFIG_OF_ADDRESS_PCI=y
+CONFIG_OF_EARLY_FLATTREE=y
+CONFIG_OF_FLATTREE=y
+CONFIG_OF_GPIO=y
+CONFIG_OF_IRQ=y
+CONFIG_OF_MDIO=y
+CONFIG_OF_MTD=y
+CONFIG_OF_NET=y
+CONFIG_OF_PCI=y
+CONFIG_OF_PCI_IRQ=y
+CONFIG_PCI=y
+CONFIG_PCI_DOMAINS=y
+CONFIG_PERF_USE_VMALLOC=y
+CONFIG_PGTABLE_LEVELS=2
+CONFIG_PHYLIB=y
+CONFIG_PHY_RALINK_USB=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_RT2880=y
+# CONFIG_PINCTRL_SINGLE is not set
+CONFIG_RALINK=y
+# CONFIG_RALINK_WDT is not set
+# CONFIG_RCU_STALL_COMMON is not set
+CONFIG_RESET_CONTROLLER=y
+CONFIG_SCHED_HRTICK=y
+# CONFIG_SCHED_INFO is not set
+# CONFIG_SCSI_DMA is not set
+# CONFIG_SERIAL_8250_FSL is not set
+CONFIG_SERIAL_8250_NR_UARTS=3
+CONFIG_SERIAL_8250_RUNTIME_UARTS=3
+CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_SOC_MT7620=y
+# CONFIG_SOC_MT7621 is not set
+# CONFIG_SOC_RT288X is not set
+# CONFIG_SOC_RT305X is not set
+# CONFIG_SOC_RT3883 is not set
+CONFIG_SPI=y
+CONFIG_SPI_MASTER=y
+CONFIG_SPI_MT7621=y
+# CONFIG_SPI_RT2880 is not set
+CONFIG_SRCU=y
+CONFIG_SWCONFIG=y
+CONFIG_SYSCTL_EXCEPTION_TRACE=y
+CONFIG_SYS_HAS_CPU_MIPS32_R1=y
+CONFIG_SYS_HAS_CPU_MIPS32_R2=y
+CONFIG_SYS_HAS_EARLY_PRINTK=y
+CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
+CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
+CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
+CONFIG_SYS_SUPPORTS_MIPS16=y
+CONFIG_TICK_CPU_ACCOUNTING=y
+CONFIG_USB_SUPPORT=y
+CONFIG_USE_OF=y
+CONFIG_WATCHDOG_CORE=y
+CONFIG_ZONE_DMA_FLAG=0
--- /dev/null
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/Default
+ NAME:=Default Profile
+ PRIORITY:=1
+ PACKAGES:= kmod-usb-core kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport
+endef
+
+define Profile/Default/Description
+ Default package set compatible with most boards.
+endef
+$(eval $(call Profile,Default))
--- /dev/null
+#
+# Copyright (C) 2009 OpenWrt.org
+#
+
+SUBTARGET:=mt7628
+BOARDNAME:=MT7628 based boards
+FEATURES+=usb
+CPU_TYPE:=24kc
+
+DEFAULT_PACKAGES += kmod-mt76
+
+define Target/Description
+ Build firmware images for Ralink MT7628 based boards.
+endef
+
--- /dev/null
+CONFIG_ARCH_BINFMT_ELF_STATE=y
+CONFIG_ARCH_CLOCKSOURCE_DATA=y
+CONFIG_ARCH_DISCARD_MEMBLOCK=y
+CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
+CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
+# CONFIG_ARCH_HAS_GCOV_PROFILE_ALL is not set
+CONFIG_ARCH_HAS_RESET_CONTROLLER=y
+# CONFIG_ARCH_HAS_SG_CHAIN is not set
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
+CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+CONFIG_ARCH_SUPPORTS_UPROBES=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_ARCH_USE_BUILTIN_BSWAP=y
+CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
+CONFIG_AT803X_PHY=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_CEVT_R4K=y
+CONFIG_CEVT_SYSTICK_QUIRK=y
+CONFIG_CLKDEV_LOOKUP=y
+CONFIG_CLKEVT_RT3352=y
+CONFIG_CLKSRC_MMIO=y
+CONFIG_CLKSRC_OF=y
+CONFIG_CLKSRC_PROBE=y
+CONFIG_CLONE_BACKWARDS=y
+CONFIG_CMDLINE="rootfstype=squashfs,jffs2"
+CONFIG_CMDLINE_BOOL=y
+# CONFIG_CMDLINE_OVERRIDE is not set
+CONFIG_CPU_GENERIC_DUMP_TLB=y
+CONFIG_CPU_HAS_PREFETCH=y
+CONFIG_CPU_HAS_SYNC=y
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_CPU_MIPS32=y
+# CONFIG_CPU_MIPS32_R1 is not set
+CONFIG_CPU_MIPS32_R2=y
+CONFIG_CPU_MIPSR2=y
+CONFIG_CPU_NEEDS_NO_SMARTMIPS_OR_MICROMIPS=y
+CONFIG_CPU_R4K_CACHE_TLB=y
+CONFIG_CPU_R4K_FPU=y
+CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
+CONFIG_CPU_SUPPORTS_HIGHMEM=y
+CONFIG_CPU_SUPPORTS_MSA=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_WORKQUEUE=y
+CONFIG_CSRC_R4K=y
+CONFIG_DEBUG_PINCTRL=y
+CONFIG_DMA_NONCOHERENT=y
+# CONFIG_DTB_MT7620A_EVAL is not set
+CONFIG_DTB_RT_NONE=y
+CONFIG_DTC=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_GENERIC_ATOMIC64=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_GENERIC_IO=y
+CONFIG_GENERIC_IRQ_CHIP=y
+CONFIG_GENERIC_IRQ_SHOW=y
+CONFIG_GENERIC_PCI_IOMAP=y
+CONFIG_GENERIC_PHY=y
+CONFIG_GENERIC_SCHED_CLOCK=y
+CONFIG_GENERIC_SMP_IDLE_THREAD=y
+CONFIG_GENERIC_TIME_VSYSCALL=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_DEVRES=y
+CONFIG_GPIO_MT7621=y
+# CONFIG_GPIO_RALINK is not set
+CONFIG_GPIO_SYSFS=y
+CONFIG_HARDWARE_WATCHPOINTS=y
+CONFIG_HAS_DMA=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT_MAP=y
+# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
+# CONFIG_HAVE_ARCH_BITREVERSE is not set
+CONFIG_HAVE_ARCH_JUMP_LABEL=y
+CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
+CONFIG_HAVE_BPF_JIT=y
+CONFIG_HAVE_CC_STACKPROTECTOR=y
+CONFIG_HAVE_CLK=y
+CONFIG_HAVE_CONTEXT_TRACKING=y
+CONFIG_HAVE_C_RECORDMCOUNT=y
+CONFIG_HAVE_DEBUG_KMEMLEAK=y
+CONFIG_HAVE_DEBUG_STACKOVERFLOW=y
+CONFIG_HAVE_DMA_API_DEBUG=y
+CONFIG_HAVE_DMA_ATTRS=y
+CONFIG_HAVE_DMA_CONTIGUOUS=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_HAVE_IDE=y
+CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
+CONFIG_HAVE_KVM=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_HAVE_MACH_CLKDEV=y
+CONFIG_HAVE_MEMBLOCK=y
+CONFIG_HAVE_MEMBLOCK_NODE_MAP=y
+CONFIG_HAVE_MOD_ARCH_SPECIFIC=y
+CONFIG_HAVE_NET_DSA=y
+CONFIG_HAVE_OPROFILE=y
+CONFIG_HAVE_PERF_EVENTS=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
+CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
+CONFIG_HW_HAS_PCI=y
+CONFIG_HZ_PERIODIC=y
+CONFIG_ICPLUS_PHY=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_IRQCHIP=y
+CONFIG_IRQ_DOMAIN=y
+CONFIG_IRQ_FORCED_THREADING=y
+CONFIG_IRQ_INTC=y
+CONFIG_IRQ_MIPS_CPU=y
+CONFIG_IRQ_WORK=y
+CONFIG_LIBFDT=y
+CONFIG_MDIO_BOARDINFO=y
+CONFIG_MIPS=y
+CONFIG_MIPS_CLOCK_VSYSCALL=y
+# CONFIG_MIPS_CMDLINE_DTB_EXTEND is not set
+# CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set
+CONFIG_MIPS_CMDLINE_FROM_DTB=y
+# CONFIG_MIPS_ELF_APPENDED_DTB is not set
+CONFIG_MIPS_FPU_EMULATOR=y
+# CONFIG_MIPS_HUGE_TLB_SUPPORT is not set
+CONFIG_MIPS_L1_CACHE_SHIFT=5
+# CONFIG_MIPS_MACHINE is not set
+CONFIG_MIPS_NO_APPENDED_DTB=y
+# CONFIG_MIPS_RAW_APPENDED_DTB is not set
+CONFIG_MIPS_SPRAM=y
+CONFIG_MODULES_USE_ELF_REL=y
+CONFIG_MT7621_WDT=y
+# CONFIG_MTD_CFI_INTELEXT is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+CONFIG_MTD_M25P80=y
+CONFIG_MTD_NAND_MT7620=y
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_SPI_NOR=y
+CONFIG_MTD_SPLIT_FIRMWARE=y
+CONFIG_MTD_SPLIT_UIMAGE_FW=y
+CONFIG_NEED_DMA_MAP_STATE=y
+CONFIG_NEED_PER_CPU_KM=y
+CONFIG_NET_MEDIATEK_ESW_RT3050=y
+# CONFIG_NET_MEDIATEK_MT7620 is not set
+CONFIG_NET_MEDIATEK_RT3050=y
+CONFIG_NET_MEDIATEK_SOC=y
+CONFIG_NET_VENDOR_MEDIATEK=y
+CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y
+# CONFIG_NO_IOPORT_MAP is not set
+CONFIG_OF=y
+CONFIG_OF_ADDRESS=y
+CONFIG_OF_ADDRESS_PCI=y
+CONFIG_OF_EARLY_FLATTREE=y
+CONFIG_OF_FLATTREE=y
+CONFIG_OF_GPIO=y
+CONFIG_OF_IRQ=y
+CONFIG_OF_MDIO=y
+CONFIG_OF_MTD=y
+CONFIG_OF_NET=y
+CONFIG_OF_PCI=y
+CONFIG_OF_PCI_IRQ=y
+CONFIG_PCI=y
+CONFIG_PCI_DOMAINS=y
+CONFIG_PERF_USE_VMALLOC=y
+CONFIG_PGTABLE_LEVELS=2
+CONFIG_PHYLIB=y
+CONFIG_PHY_RALINK_USB=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_RT2880=y
+# CONFIG_PINCTRL_SINGLE is not set
+CONFIG_PWM=y
+CONFIG_PWM_MEDIATEK=y
+CONFIG_PWM_SYSFS=y
+CONFIG_RALINK=y
+# CONFIG_RALINK_WDT is not set
+# CONFIG_RCU_STALL_COMMON is not set
+CONFIG_RESET_CONTROLLER=y
+CONFIG_SCHED_HRTICK=y
+# CONFIG_SCHED_INFO is not set
+# CONFIG_SCSI_DMA is not set
+# CONFIG_SERIAL_8250_FSL is not set
+CONFIG_SERIAL_8250_NR_UARTS=3
+CONFIG_SERIAL_8250_RUNTIME_UARTS=3
+CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_SOC_MT7620=y
+# CONFIG_SOC_MT7621 is not set
+# CONFIG_SOC_RT288X is not set
+# CONFIG_SOC_RT305X is not set
+# CONFIG_SOC_RT3883 is not set
+CONFIG_SPI=y
+CONFIG_SPI_MASTER=y
+CONFIG_SPI_MT7621=y
+# CONFIG_SPI_RT2880 is not set
+# CONFIG_SPI_SPIDEV is not set
+CONFIG_SRCU=y
+CONFIG_SWCONFIG=y
+CONFIG_SYSCTL_EXCEPTION_TRACE=y
+CONFIG_SYS_HAS_CPU_MIPS32_R1=y
+CONFIG_SYS_HAS_CPU_MIPS32_R2=y
+CONFIG_SYS_HAS_EARLY_PRINTK=y
+CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
+CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
+CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
+CONFIG_SYS_SUPPORTS_MIPS16=y
+CONFIG_TICK_CPU_ACCOUNTING=y
+CONFIG_USB_SUPPORT=y
+CONFIG_USE_OF=y
+CONFIG_WATCHDOG_CORE=y
+CONFIG_ZONE_DMA_FLAG=0
--- /dev/null
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/Default
+ NAME:=Default Profile
+ PRIORITY:=1
+ PACKAGES:= kmod-usb-core kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport
+endef
+
+define Profile/Default/Description
+ Default package set compatible with most boards.
+endef
+$(eval $(call Profile,Default))
--- /dev/null
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+
+SUBTARGET:=mt7688
+BOARDNAME:=MT7688 based boards
+FEATURES+=usb
+CPU_TYPE:=24kc
+
+DEFAULT_PACKAGES += kmod-mt76
+
+define Target/Description
+ Build firmware images for Ralink MT7688 based boards.
+endef
+
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
-@@ -585,6 +585,8 @@ config RALINK
+@@ -586,6 +586,8 @@ config RALINK
select CLKDEV_LOOKUP
select ARCH_HAS_RESET_CONTROLLER
select RESET_CONTROLLER
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
-@@ -587,6 +587,9 @@ config RALINK
+@@ -588,6 +588,9 @@ config RALINK
select RESET_CONTROLLER
select PINCTRL
select PINCTRL_RT2880
/*
* Returns zero if the TRB isn't in this segment, otherwise it returns the DMA
-@@ -3088,17 +3089,22 @@ static u32 xhci_td_remainder(struct xhci
+@@ -3110,17 +3111,22 @@ static u32 xhci_td_remainder(struct xhci
{
u32 maxp, total_packet_count;
/* Queueing functions don't count the current TRB into transferred */
return (total_packet_count - ((transferred + trb_buff_len) / maxp));
}
-@@ -3486,7 +3492,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *
+@@ -3508,7 +3514,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *
field |= 0x1;
/* xHCI 1.0/1.1 6.4.1.2.1: Transfer Type field */
writel(temp, &xhci->ir_set->irq_control);
/* Set the HCD state before we enable the irqs */
-@@ -1704,6 +1709,9 @@ int xhci_drop_endpoint(struct usb_hcd *h
+@@ -1691,6 +1696,9 @@ int xhci_drop_endpoint(struct usb_hcd *h
xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep);
xhci_dbg(xhci, "drop ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x\n",
(unsigned int) ep->desc.bEndpointAddress,
udev->slot_id,
-@@ -1799,6 +1807,15 @@ int xhci_add_endpoint(struct usb_hcd *hc
+@@ -1786,6 +1794,15 @@ int xhci_add_endpoint(struct usb_hcd *hc
return -ENOMEM;
}
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
-@@ -1631,6 +1631,7 @@ struct xhci_hcd {
+@@ -1634,6 +1634,7 @@ struct xhci_hcd {
/* For controllers with a broken beyond repair streams implementation */
#define XHCI_BROKEN_STREAMS (1 << 19)
#define XHCI_PME_STUCK_QUIRK (1 << 20)
+#define XHCI_MTK_HOST (1 << 21)
+ #define XHCI_MISSING_CAS (1 << 24)
unsigned int num_active_eps;
unsigned int limit_active_eps;
- /* There are two roothubs to keep track of bus suspend info for */
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
-@@ -811,3 +811,5 @@ config MMC_MTK
+@@ -786,3 +786,5 @@ config MMC_MTK
If you have a machine with a integrated SD/MMC card reader, say Y or M here.
This is needed if support for any SD/SDIO/MMC devices is required.
If unsure, say N.
--- a/drivers/net/ethernet/mediatek/mt7530.c
+++ b/drivers/net/ethernet/mediatek/mt7530.c
-@@ -543,6 +543,7 @@ mt7530_apply_config(struct switch_dev *d
+@@ -547,6 +547,7 @@ mt7530_apply_config(struct switch_dev *d
u8 etags = priv->vlan_entries[i].etags;
u32 val;
/* vid of vlan */
val = mt7530_r32(priv, REG_ESW_VLAN_VTIM(i));
if (i % 2 == 0) {
-@@ -553,7 +554,7 @@ mt7530_apply_config(struct switch_dev *d
+@@ -557,7 +558,7 @@ mt7530_apply_config(struct switch_dev *d
val |= (vid << 12);
}
mt7530_w32(priv, REG_ESW_VLAN_VTIM(i), val);
/* vlan port membership */
if (member)
mt7530_w32(priv, REG_ESW_VLAN_VAWD1, REG_ESW_VLAN_VAWD1_IVL_MAC |
-@@ -573,7 +574,11 @@ mt7530_apply_config(struct switch_dev *d
+@@ -577,7 +578,11 @@ mt7530_apply_config(struct switch_dev *d
mt7530_w32(priv, REG_ESW_VLAN_VAWD2, val);
/* write to vlan table */
+++ /dev/null
-diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
-index fe9ceb7..2151975 100644
---- a/drivers/mtd/devices/m25p80.c
-+++ b/drivers/mtd/devices/m25p80.c
-@@ -27,6 +27,9 @@
- #include <linux/spi/flash.h>
- #include <linux/mtd/spi-nor.h>
-
-+#define OPCODE_RESET_ENABLE 0x66
-+#define OPCODE_RESET 0x99
-+
- #define MAX_CMD_SIZE 6
- struct m25p {
- struct spi_device *spi;
-@@ -168,6 +171,17 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset)
- return 0;
- }
-
-+void m25p80_reboot(struct mtd_info *mtd)
-+{
-+ struct spi_nor *nor = container_of(mtd, struct spi_nor, mtd);
-+ struct m25p *flash = nor->priv;
-+
-+ flash->command[0] = OPCODE_RESET_ENABLE;
-+ spi_write(flash->spi, flash->command, 1);
-+ flash->command[0] = OPCODE_RESET;
-+ spi_write(flash->spi, flash->command, 1);
-+}
-+
- /*
- * board specific setup should have ensured the SPI clock used here
- * matches what the READ command supports, at least until this driver
-@@ -197,6 +211,7 @@ static int m25p_probe(struct spi_device *spi)
- nor->erase = m25p80_erase;
- nor->write_reg = m25p80_write_reg;
- nor->read_reg = m25p80_read_reg;
-+ nor->mtd._reboot = m25p80_reboot;
-
- nor->dev = &spi->dev;
- nor->flash_node = spi->dev.of_node;
---
-2.9.3
-
--- /dev/null
+From 2583143af8111d430bdca0268b6cdb7ccc7c3f9d Mon Sep 17 00:00:00 2001
+From: Daniel Golle <daniel@makrotopia.org>
+Date: Fri, 13 Jan 2017 05:40:04 +0100
+Subject: [PATCH] mips: ralink/rt3883: fix typo in pinctrl lna_g_func
+
+Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+---
+ arch/mips/ralink/rt3883.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/mips/ralink/rt3883.c
++++ b/arch/mips/ralink/rt3883.c
+@@ -36,7 +36,7 @@ static struct rt2880_pmx_func uartlite_f
+ static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 5) };
+ static struct rt2880_pmx_func mdio_func[] = { FUNC("mdio", 0, 22, 2) };
+ static struct rt2880_pmx_func lna_a_func[] = { FUNC("lna a", 0, 32, 3) };
+-static struct rt2880_pmx_func lna_g_func[] = { FUNC("lna a", 0, 35, 3) };
++static struct rt2880_pmx_func lna_g_func[] = { FUNC("lna g", 0, 35, 3) };
+ static struct rt2880_pmx_func pci_func[] = {
+ FUNC("pci-dev", 0, 40, 32),
+ FUNC("pci-host2", 1, 40, 32),
SUBTARGET:=rt288x
BOARDNAME:=RT288x based boards
-CPU_TYPE:=mips32r2
+CPU_TYPE:=24kc
DEFAULT_PACKAGES += kmod-rt2800-soc
)
BOARD:=uml
BOARDNAME:=User Mode Linux
-FEATURES:=squashfs ext4 audio
+FEATURES:=squashfs ext4 audio source-only
MAINTAINER:=Florian Fainelli <florian@openwrt.org>
KERNEL_PATCHVER:=4.4
CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
CONFIG_GENERIC_CPU=y
CONFIG_GENERIC_PENDING_IRQ=y
+CONFIG_GPIOLIB=y
+# CONFIG_GPIO_104_IDIO_16 is not set
+# CONFIG_GPIO_AMDPT is not set
+# CONFIG_GPIO_F7188X is not set
+# CONFIG_GPIO_INTEL_MID is not set
+# CONFIG_GPIO_IT87 is not set
+# CONFIG_GPIO_LYNXPOINT is not set
+CONFIG_GPIO_SYSFS=y
CONFIG_HAVE_ACPI_APEI=y
CONFIG_HAVE_ACPI_APEI_NMI=y
# CONFIG_HAVE_AOUT is not set
# CONFIG_KVM_DEBUG_FS is not set
CONFIG_KVM_GUEST=y
# CONFIG_LCD_CLASS_DEVICE is not set
+CONFIG_LEDS_GPIO=y
# CONFIG_LEGACY_VSYSCALL_EMULATE is not set
# CONFIG_LEGACY_VSYSCALL_NATIVE is not set
CONFIG_LEGACY_VSYSCALL_NONE=y
ARCH:=x86_64
BOARDNAME:=x86_64
-DEFAULT_PACKAGES += kmod-button-hotplug kmod-e1000e kmod-e1000 kmod-igb
+DEFAULT_PACKAGES += kmod-button-hotplug kmod-e1000e kmod-e1000 kmod-r8169 kmod-igb
define Target/Description
Build images for 64 bit systems including virtualized guests.
BOARD:=x86
BOARDNAME:=x86
FEATURES:=squashfs ext4 vdi vmdk pcmcia targz fpu
-SUBTARGETS:=generic legacy xen_domu geode 64
+SUBTARGETS:=generic legacy geode 64
MAINTAINER:=Felix Fietkau <nbd@nbd.name>
KERNEL_PATCHVER:=4.4
--- /dev/null
+#!/bin/sh
+#
+# Copyright © 2017 OpenWrt.org
+#
+
+. /lib/functions/uci-defaults.sh
+
+board_config_update
+
+board=$(cat /tmp/sysinfo/board_name) 2>/dev/null
+
+case "$board" in
+pc-engines-apu2)
+ ucidef_set_led_netdev "wan" "WAN" "apu2:green:led3" "eth0"
+ ucidef_set_led_netdev "lan" "LAN" "apu2:green:led2" "br-lan"
+ ucidef_set_led_default "diag" "DIAG" "apu2:green:power" "1"
+ ;;
+traverse-technologies-geos)
+ ucidef_set_led_netdev "lan" "LAN" "geos:1" "br-lan" "tx rx"
+ ucidef_set_led_netdev "wlan" "WiFi" "geos:2" "phy0tpt"
+ ucidef_set_led_default "diag" "DIAG" "geos:3" "1"
+ ;;
+esac
+board_config_flush
+
+exit 0
--- /dev/null
+#!/bin/sh
+#
+# Copyright © 2017 OpenWrt.org
+#
+
+. /lib/functions/system.sh
+. /lib/functions/uci-defaults.sh
+
+board_config_update
+
+board="$(cat /tmp/sysinfo/board_name)" 2>/dev/null
+
+case "$board" in
+pc-engines-apu2)
+ ucidef_set_interfaces_lan_wan "eth1 eth2" "eth0"
+ ;;
+traverse-technologies-geos)
+ ucidef_set_interface_lan "eth0 eth1"
+ ucidef_add_atm_bridge "0" "35" "llc" "bridged"
+ ucidef_set_interface_wan "nas0" "dhcp"
+ macaddr="$(cat /sys/class/net/eth0/address)" 2>/dev/null
+ [ -n "$macaddr" ] && ucidef_set_interface_macaddr "wan" "$macaddr"
+ ;;
+esac
+board_config_flush
+
+exit 0
--- /dev/null
+#!/bin/sh
+#
+# Copyright © 2017 OpenWrt.org
+#
+
+. /lib/functions.sh
+. /lib/functions/leds.sh
+. /usr/share/libubox/jshn.sh
+
+preinit_match_diag_led() {
+ local CFG keys key cfg name sysfs default
+
+ CFG=/etc/board.json
+ if [ ! -s $CFG ]; then
+ CFG=/tmp/board.json
+ [ -s /tmp/sysinfo/model ] || return
+ /bin/board_detect $CFG || return
+ fi
+
+ json_init
+ json_load "$(cat $CFG)"
+ json_get_keys keys led
+ json_select led
+ for key in $keys; do
+ json_select "$key"
+ json_get_vars name sysfs default
+
+ if [ "$name" = "DIAG" -a "$default" = "1" ]; then
+ status_led="$sysfs"
+ return
+ fi
+ json_select ..
+ done
+}
+
+match_diag_led() {
+ local name
+ local default
+ local sysfs
+ config_get name "$1" name
+ config_get default "$1" default
+ config_get sysfs "$1" sysfs
+
+ if [ "$name" = "DIAG" -a "$default" = "1" ]; then
+ status_led="$sysfs"
+ fi
+}
+
+get_status_led() {
+ if [ -s /etc/config/system ]; then
+ config_load system
+ config_foreach match_diag_led led
+ else
+ preinit_match_diag_led
+ fi
+}
+
+set_state() {
+ get_status_led
+
+ case "$1" in
+ preinit)
+ status_led_blink_preinit
+ ;;
+
+ failsafe)
+ status_led_blink_failsafe
+ ;;
+
+ preinit_regular)
+ status_led_blink_preinit_regular
+ ;;
+
+ done)
+ status_led_on
+ ;;
+ esac
+}
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K shutdown
ttyS0::askfirst:/usr/libexec/login.sh
+hvc0::askfirst:/usr/libexec/login.sh
tty1::askfirst:/usr/libexec/login.sh
}
platform_do_upgrade() {
- local diskdev partdev ibs diff
+ local diskdev partdev diff
if export_bootdevice && export_partdevice diskdev 0; then
sync
if [ "$SAVE_PARTITIONS" = "1" ]; then
get_partitions "/dev/$diskdev" bootdisk
- #get block size
- if [ -f "/sys/block/$diskdev/queue/physical_block_size" ]; then
- ibs="$(cat "/sys/block/$diskdev/queue/physical_block_size")"
- else
- ibs=512
- fi
-
#extract the boot sector from the image
get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b
while read part start size; do
if export_partdevice partdev $part; then
echo "Writing image to /dev/$partdev..."
- get_image "$@" | dd of="/dev/$partdev" ibs="$ibs" obs=1M skip="$start" count="$size" conv=fsync
+ get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
else
echo "Unable to find partition $part device, skipped."
fi
CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE=y
CONFIG_CLOCKSOURCE_WATCHDOG=y
CONFIG_CLONE_BACKWARDS=y
-CONFIG_COMPAT_VDSO=y
+# CONFIG_COMPAT_VDSO is not set
CONFIG_CONSOLE_TRANSLATIONS=y
# CONFIG_CPU5_WDT is not set
CONFIG_CPU_FREQ=y
CONFIG_CPU_SUP_INTEL=y
CONFIG_CPU_SUP_TRANSMETA_32=y
CONFIG_CPU_SUP_UMC_32=y
+# CONFIG_CRASHLOG is not set
CONFIG_CRC16=y
CONFIG_CRYPTO_AES_586=y
CONFIG_CRYPTO_CRC32C=y
CONFIG_FIRMWARE_MEMMAP=y
CONFIG_FIX_EARLYCON_MEM=y
CONFIG_FS_MBCACHE=y
+CONFIG_FUSION=y
+# CONFIG_FUSION_CTL is not set
+# CONFIG_FUSION_LOGGING is not set
+CONFIG_FUSION_MAX_SGE=128
+CONFIG_FUSION_SPI=y
CONFIG_GENERIC_ALLOCATOR=y
CONFIG_GENERIC_BUG=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_SCHED_HRTICK=y
# CONFIG_SCHED_INFO is not set
CONFIG_SCSI=y
+CONFIG_SCSI_SPI_ATTRS=y
CONFIG_SCx200=y
CONFIG_SCx200HR_TIMER=y
# CONFIG_SCx200_GPIO is not set
--- /dev/null
+#!/bin/sh
+# Copyright (C) 2010 OpenWrt.org
+
+do_mount_xenfs() {
+ grep -q xenfs /proc/filesystems && \
+ mount -o noatime -t xenfs none /proc/xen
+}
+
+boot_hook_add preinit_mount_root do_mount_xenfs
# CONFIG_ACPI_BGRT is not set
CONFIG_ACPI_BUTTON=y
# CONFIG_ACPI_CMPC is not set
-# CONFIG_ACPI_CONTAINER is not set
+CONFIG_ACPI_CONTAINER=y
CONFIG_ACPI_CPU_FREQ_PSS=y
# CONFIG_ACPI_CUSTOM_DSDT is not set
# CONFIG_ACPI_DEBUG is not set
# CONFIG_ACPI_DOCK is not set
# CONFIG_ACPI_EC_DEBUGFS is not set
# CONFIG_ACPI_FAN is not set
+CONFIG_ACPI_HOTPLUG_CPU=y
CONFIG_ACPI_HOTPLUG_IOAPIC=y
# CONFIG_ACPI_I2C_OPREGION is not set
# CONFIG_ACPI_INITRD_TABLE_OVERRIDE is not set
# CONFIG_AGP_SIS is not set
# CONFIG_AGP_SWORKS is not set
# CONFIG_AGP_VIA is not set
+# CONFIG_APM is not set
CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK=y
CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC=y
CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
CONFIG_BACKLIGHT_LCD_SUPPORT=y
CONFIG_BLK_DEV_SR=y
# CONFIG_BLK_DEV_SR_VENDOR is not set
+# CONFIG_BOOTPARAM_HOTPLUG_CPU0 is not set
CONFIG_CLKDEV_LOOKUP=y
CONFIG_COMMON_CLK=y
CONFIG_CPU_IDLE_GOV_MENU=y
CONFIG_CPU_RMAP=y
+CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+CONFIG_CRYPTO_NULL2=y
+# CONFIG_DEBUG_HOTPLUG_CPU0 is not set
CONFIG_DMA_SHARED_BUFFER=y
CONFIG_DRM=y
CONFIG_DRM_AMDGPU=y
CONFIG_FB_CFB_FILLRECT=y
CONFIG_FB_CFB_IMAGEBLIT=y
CONFIG_FB_CMDLINE=y
+CONFIG_FB_DEFERRED_IO=y
CONFIG_FB_EFI=y
# CONFIG_FB_I810 is not set
CONFIG_FB_SYS_COPYAREA=y
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
+CONFIG_FREEZER=y
CONFIG_GENERIC_PENDING_IRQ=y
CONFIG_GENERIC_PINCONF=y
CONFIG_GPIOLIB=y
CONFIG_HAVE_KVM_IRQ_ROUTING=y
CONFIG_HAVE_KVM_MSI=y
CONFIG_HDMI=y
+CONFIG_HIBERNATE_CALLBACKS=y
CONFIG_HID=y
CONFIG_HID_BATTERY_STRENGTH=y
# CONFIG_HIGHMEM64G is not set
+CONFIG_HOTPLUG_CPU=y
CONFIG_HPET=y
CONFIG_HPET_MMAP=y
# CONFIG_HP_ACCEL is not set
CONFIG_HVC_DRIVER=y
+CONFIG_HVC_IRQ=y
+CONFIG_HVC_XEN=y
+CONFIG_HVC_XEN_FRONTEND=y
CONFIG_HWMON=y
CONFIG_HW_RANDOM_VIRTIO=y
CONFIG_HYPERVISOR_GUEST=y
CONFIG_INPUT_MOUSEDEV_PSAUX=y
CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_XEN_KBDDEV_FRONTEND=y
CONFIG_INTEL_GTT=y
CONFIG_INTEL_IDLE=y
# CONFIG_INTEL_IPS is not set
CONFIG_KVM_VFIO=y
# CONFIG_LANCE is not set
# CONFIG_LCD_CLASS_DEVICE is not set
-# CONFIG_LGUEST is not set
# CONFIG_LGUEST_GUEST is not set
CONFIG_LOCK_SPIN_ON_OWNER=y
# CONFIG_M486 is not set
CONFIG_NET_FLOW_LIMIT=y
CONFIG_NO_HZ=y
CONFIG_NR_CPUS=4
+CONFIG_PADATA=y
CONFIG_PARAVIRT=y
CONFIG_PARAVIRT_CLOCK=y
# CONFIG_PARAVIRT_DEBUG is not set
CONFIG_PATA_VIA=y
CONFIG_PCIEAER=y
CONFIG_PCIEPORTBUS=y
+CONFIG_PCIE_PME=y
CONFIG_PCI_MMCONFIG=y
+CONFIG_PCI_XEN=y
# CONFIG_PCWATCHDOG is not set
CONFIG_PGTABLE_LEVELS=3
CONFIG_PHYS_ADDR_T_64BIT=y
CONFIG_PINCTRL_CHERRYVIEW=y
CONFIG_PINCTRL_INTEL=y
CONFIG_PINCTRL_SUNRISEPOINT=y
+CONFIG_PM=y
# CONFIG_PMIC_OPREGION is not set
+CONFIG_PM_CLK=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP=y
+CONFIG_PM_SLEEP_SMP=y
CONFIG_PNP=y
CONFIG_PNPACPI=y
# CONFIG_PNPBIOS is not set
CONFIG_SMP=y
# CONFIG_SURFACE_PRO3_BUTTON is not set
CONFIG_SWIOTLB=y
+CONFIG_SWIOTLB_XEN=y
+CONFIG_SYS_HYPERVISOR=y
CONFIG_TASKSTATS=y
CONFIG_TASK_DELAY_ACCT=y
-# CONFIG_TASK_XACCT is not set
# CONFIG_TOSHIBA_BT_RFKILL is not set
CONFIG_TREE_RCU=y
CONFIG_UCS2_STRING=y
CONFIG_VGACON_SOFT_SCROLLBACK=y
CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64
CONFIG_VHOST=y
-# CONFIG_VHOST_CROSS_ENDIAN_LEGACY is not set
CONFIG_VHOST_NET=y
CONFIG_VHOST_RING=y
CONFIG_VIRTIO=y
CONFIG_VIRTIO_PCI=y
CONFIG_VIRTIO_PCI_LEGACY=y
CONFIG_VIRTUALIZATION=y
+CONFIG_VT_CONSOLE_SLEEP=y
# CONFIG_WDT is not set
CONFIG_X86_32_SMP=y
CONFIG_X86_ACPI_CPUFREQ=y
# CONFIG_X86_POWERNOW_K8 is not set
CONFIG_X86_TSC=y
CONFIG_X86_USE_PPRO_CHECKSUM=y
+CONFIG_XEN=y
+CONFIG_XENFS=y
+CONFIG_XEN_ACPI=y
+CONFIG_XEN_ACPI_PROCESSOR=y
+CONFIG_XEN_AUTO_XLATE=y
+# CONFIG_XEN_BACKEND is not set
+CONFIG_XEN_BALLOON=y
+CONFIG_XEN_BLKDEV_FRONTEND=y
+CONFIG_XEN_COMPAT_XENFS=y
+CONFIG_XEN_DEBUG_FS=y
+CONFIG_XEN_DEV_EVTCHN=y
+CONFIG_XEN_DOM0=y
+CONFIG_XEN_FBDEV_FRONTEND=y
+CONFIG_XEN_GNTDEV=y
+CONFIG_XEN_GRANT_DEV_ALLOC=y
+CONFIG_XEN_HAVE_PVMMU=y
+CONFIG_XEN_HAVE_VPMU=y
+CONFIG_XEN_NETDEV_FRONTEND=y
+CONFIG_XEN_PCIDEV_FRONTEND=y
+CONFIG_XEN_PRIVCMD=y
+CONFIG_XEN_PVHVM=y
+CONFIG_XEN_SAVE_RESTORE=y
+CONFIG_XEN_SCRUB_PAGES=y
+CONFIG_XEN_SCSI_FRONTEND=y
+CONFIG_XEN_SYMS=y
+CONFIG_XEN_SYS_HYPERVISOR=y
+CONFIG_XEN_WDT=y
+CONFIG_XEN_XENBUS_FRONTEND=y
CONFIG_XPS=y
define Profile/Generic
NAME:=Generic
PACKAGES:=kmod-3c59x kmod-e100 kmod-e1000 kmod-natsemi kmod-ne2k-pci \
- kmod-pcnet32 kmod-sis900 kmod-tg3 \
+ kmod-pcnet32 kmod-8139too kmod-r8169 kmod-sis900 kmod-tg3 \
kmod-via-rhine kmod-via-velocity
endef
--- /dev/null
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/Generic
+ NAME:=Generic
+ PACKAGES:= \
+ soloscli linux-atm br2684ctl ppp-mod-pppoa pppdump pppstats \
+ hwclock flashrom tc kmod-pppoa kmod-8139cp kmod-mppe \
+ kmod-usb-ohci-pci kmod-hwmon-lm90 \
+ kmod-via-rhine
+endef
+
+define Profile/Generic/Description
+ Generic Profile for all Geode boards.
+endef
+$(eval $(call Profile,Generic))
--- /dev/null
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/Geos
+ NAME:=Geos
+ PACKAGES:= \
+ soloscli linux-atm br2684ctl ppp-mod-pppoa pppdump pppstats \
+ hwclock flashrom tc kmod-pppoa kmod-8139cp kmod-mppe \
+ kmod-usb-ohci-pci kmod-hwmon-lm90
+endef
+
+define Profile/Geos/Description
+ Traverse Technologies Geos ADSL router
+endef
+$(eval $(call Profile,Geos))
kmod-button-hotplug \
kmod-ledtrig-heartbeat kmod-ledtrig-gpio \
kmod-ledtrig-netdev hwclock wpad-mini
-
-CPU_TYPE := geode
+# Geos
+DEFAULT_PACKAGES += \
+ soloscli linux-atm br2684ctl ppp-mod-pppoa pppdump pppstats \
+ hwclock flashrom tc kmod-pppoa kmod-8139cp kmod-mppe \
+ kmod-usb-ohci-pci kmod-hwmon-lm90
define Target/Description
Build firmware images for AMD Geode GX/LX based systems (net5501, alix, geos)
set timeout="@TIMEOUT@"
set root='(cd)'
-menuentry "LEDE" {
+menuentry "libreCMC" {
linux /boot/vmlinuz @CMDLINE@ noinitrd
}
set timeout="@TIMEOUT@"
set root='(@ROOT@)'
-menuentry "LEDE" {
+menuentry "libreCMC" {
linux /boot/vmlinuz @CMDLINE@ noinitrd
}
-menuentry "LEDE (failsafe)" {
+menuentry "libreCMC (failsafe)" {
linux /boot/vmlinuz failsafe=true @CMDLINE@ noinitrd
}
define Profile/Generic
NAME:=Generic
PACKAGES:=kmod-3c59x kmod-e100 kmod-e1000 kmod-natsemi kmod-ne2k-pci \
- kmod-pcnet32 kmod-sis900 kmod-tg3 \
+ kmod-pcnet32 kmod-8139too kmod-r8169 kmod-sis900 kmod-tg3 \
kmod-via-rhine kmod-via-velocity
endef
endef
$(eval $(call KernelPackage,sound-cs5535audio))
+
+define KernelPackage/sp5100_tco
+ SUBMENU:=$(OTHER_MENU)
+ TITLE:=SP5100 Watchdog Support
+ DEPENDS:=@TARGET_x86
+ KCONFIG:=CONFIG_SP5100_TCO
+ FILES:=$(LINUX_DIR)/drivers/watchdog/sp5100_tco.ko
+ AUTOLOAD:=$(call AutoLoad,50,sp5100_tco,1)
+endef
+
+define KernelPackage/sp5100_tco/description
+ Kernel module for the SP5100_TCO hardware watchdog.
+endef
+
+$(eval $(call KernelPackage,sp5100_tco))
--- /dev/null
+From 190aa4304de6fe2185d96392ddf56580fa133e99 Mon Sep 17 00:00:00 2001
+From: Denis Turischev <denis.turischev@compulab.co.il>
+Date: Tue, 24 Nov 2015 10:46:12 +0200
+Subject: [PATCH] sp5100_tco: Add AMD Mullins platform support
+
+AMD Mullins watchdog is fully compatible to the previous Hudson chipset,
+reuse the existent sp5100_tco driver.
+
+Signed-off-by: Denis Turischev <denis.turischev@compulab.co.il>
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
+---
+ drivers/watchdog/sp5100_tco.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/watchdog/sp5100_tco.c
++++ b/drivers/watchdog/sp5100_tco.c
+@@ -306,6 +306,8 @@ static struct miscdevice sp5100_tco_misc
+ static const struct pci_device_id sp5100_tco_pci_tbl[] = {
+ { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS, PCI_ANY_ID,
+ PCI_ANY_ID, },
++ { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, PCI_ANY_ID,
++ PCI_ANY_ID, },
+ { 0, }, /* End of list */
+ };
+ MODULE_DEVICE_TABLE(pci, sp5100_tco_pci_tbl);
--- /dev/null
+From cca118fa2a0a94e0f0b3c8dd1dda922cdee45089 Mon Sep 17 00:00:00 2001
+From: Huang Rui <ray.huang@amd.com>
+Date: Mon, 23 Nov 2015 18:07:36 +0800
+Subject: [PATCH] sp5100_tco: Add AMD Carrizo platform support
+
+sp5100_tco watchdog is also supported on AMD KernCZ chipset of Carrizo
+platform.
+
+Signed-off-by: Huang Rui <ray.huang@amd.com>
+Cc: Denis Turischev <denis.turischev@compulab.co.il>
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
+---
+ drivers/watchdog/sp5100_tco.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/watchdog/sp5100_tco.c
++++ b/drivers/watchdog/sp5100_tco.c
+@@ -308,6 +308,8 @@ static const struct pci_device_id sp5100
+ PCI_ANY_ID, },
+ { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, PCI_ANY_ID,
+ PCI_ANY_ID, },
++ { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_KERNCZ_SMBUS, PCI_ANY_ID,
++ PCI_ANY_ID, },
+ { 0, }, /* End of list */
+ };
+ MODULE_DEVICE_TABLE(pci, sp5100_tco_pci_tbl);
--- /dev/null
+From bdecfcdb5461834aab24002bb18d3cbdd907b7fb Mon Sep 17 00:00:00 2001
+From: Huang Rui <ray.huang@amd.com>
+Date: Mon, 23 Nov 2015 18:07:35 +0800
+Subject: [PATCH] sp5100_tco: fix the device check for SB800 and later chipsets
+
+For SB800 and later chipsets, the register definitions are the same
+with SB800. And for SB700 and older chipsets, the definitions should
+be same with SP5100/SB7x0.
+
+Signed-off-by: Huang Rui <ray.huang@amd.com>
+Cc: Denis Turischev <denis.turischev@compulab.co.il>
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
+---
+ drivers/watchdog/sp5100_tco.c | 28 ++++++++++++++++------------
+ 1 file changed, 16 insertions(+), 12 deletions(-)
+
+--- a/drivers/watchdog/sp5100_tco.c
++++ b/drivers/watchdog/sp5100_tco.c
+@@ -335,21 +335,24 @@ static unsigned char sp5100_tco_setupdev
+ if (!sp5100_tco_pci)
+ return 0;
+
+- pr_info("PCI Revision ID: 0x%x\n", sp5100_tco_pci->revision);
++ pr_info("PCI Vendor ID: 0x%x, Device ID: 0x%x, Revision ID: 0x%x\n",
++ sp5100_tco_pci->vendor, sp5100_tco_pci->device,
++ sp5100_tco_pci->revision);
+
+ /*
+ * Determine type of southbridge chipset.
+ */
+- if (sp5100_tco_pci->revision >= 0x40) {
+- dev_name = SB800_DEVNAME;
+- index_reg = SB800_IO_PM_INDEX_REG;
+- data_reg = SB800_IO_PM_DATA_REG;
+- base_addr = SB800_PM_WATCHDOG_BASE;
+- } else {
++ if (sp5100_tco_pci->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
++ sp5100_tco_pci->revision < 0x40) {
+ dev_name = SP5100_DEVNAME;
+ index_reg = SP5100_IO_PM_INDEX_REG;
+ data_reg = SP5100_IO_PM_DATA_REG;
+ base_addr = SP5100_PM_WATCHDOG_BASE;
++ } else {
++ dev_name = SB800_DEVNAME;
++ index_reg = SB800_IO_PM_INDEX_REG;
++ data_reg = SB800_IO_PM_DATA_REG;
++ base_addr = SB800_PM_WATCHDOG_BASE;
+ }
+
+ /* Request the IO ports used by this driver */
+@@ -385,7 +388,12 @@ static unsigned char sp5100_tco_setupdev
+ * Secondly, Find the watchdog timer MMIO address
+ * from SBResource_MMIO register.
+ */
+- if (sp5100_tco_pci->revision >= 0x40) {
++ if (sp5100_tco_pci->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
++ sp5100_tco_pci->revision < 0x40) {
++ /* Read SBResource_MMIO from PCI config(PCI_Reg: 9Ch) */
++ pci_read_config_dword(sp5100_tco_pci,
++ SP5100_SB_RESOURCE_MMIO_BASE, &val);
++ } else {
+ /* Read SBResource_MMIO from AcpiMmioEn(PM_Reg: 24h) */
+ outb(SB800_PM_ACPI_MMIO_EN+3, SB800_IO_PM_INDEX_REG);
+ val = inb(SB800_IO_PM_DATA_REG);
+@@ -395,10 +403,6 @@ static unsigned char sp5100_tco_setupdev
+ val = val << 8 | inb(SB800_IO_PM_DATA_REG);
+ outb(SB800_PM_ACPI_MMIO_EN+0, SB800_IO_PM_INDEX_REG);
+ val = val << 8 | inb(SB800_IO_PM_DATA_REG);
+- } else {
+- /* Read SBResource_MMIO from PCI config(PCI_Reg: 9Ch) */
+- pci_read_config_dword(sp5100_tco_pci,
+- SP5100_SB_RESOURCE_MMIO_BASE, &val);
+ }
+
+ /* The SBResource_MMIO is enabled and mapped memory space? */
--- /dev/null
+From 46856fabe40cc80f92134683cdec7dc0fc8f4000 Mon Sep 17 00:00:00 2001
+From: Lucas Stach <dev@lynxeye.de>
+Date: Tue, 3 May 2016 19:15:58 +0200
+Subject: [PATCH] watchdog: sp5100_tco: properly check for new register layouts
+
+Commits 190aa4304de6 (Add AMD Mullins platform support) and
+cca118fa2a0a94 (Add AMD Carrizo platform support) enabled the
+driver on a lot more devices, but the following commit missed
+a single location in the code when checking if the SB800 register
+offsets should be used. This leads to the wrong register being
+written which in turn causes ACPI to go haywire.
+
+Fix this by introducing a helper function to check for the new
+register layout and use this consistently.
+
+https://bugzilla.kernel.org/show_bug.cgi?id=114201
+https://bugzilla.redhat.com/show_bug.cgi?id=1329910
+Fixes: bdecfcdb5461 (sp5100_tco: fix the device check for SB800
+and later chipsets)
+Cc: stable@vger.kernel.org (4.5+)
+Signed-off-by: Lucas Stach <dev@lynxeye.de>
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
+---
+ drivers/watchdog/sp5100_tco.c | 15 ++++++++++-----
+ 1 file changed, 10 insertions(+), 5 deletions(-)
+
+--- a/drivers/watchdog/sp5100_tco.c
++++ b/drivers/watchdog/sp5100_tco.c
+@@ -73,6 +73,13 @@ MODULE_PARM_DESC(nowayout, "Watchdog can
+ /*
+ * Some TCO specific functions
+ */
++
++static bool tco_has_sp5100_reg_layout(struct pci_dev *dev)
++{
++ return dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
++ dev->revision < 0x40;
++}
++
+ static void tco_timer_start(void)
+ {
+ u32 val;
+@@ -129,7 +136,7 @@ static void tco_timer_enable(void)
+ {
+ int val;
+
+- if (sp5100_tco_pci->revision >= 0x40) {
++ if (!tco_has_sp5100_reg_layout(sp5100_tco_pci)) {
+ /* For SB800 or later */
+ /* Set the Watchdog timer resolution to 1 sec */
+ outb(SB800_PM_WATCHDOG_CONFIG, SB800_IO_PM_INDEX_REG);
+@@ -342,8 +349,7 @@ static unsigned char sp5100_tco_setupdev
+ /*
+ * Determine type of southbridge chipset.
+ */
+- if (sp5100_tco_pci->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
+- sp5100_tco_pci->revision < 0x40) {
++ if (tco_has_sp5100_reg_layout(sp5100_tco_pci)) {
+ dev_name = SP5100_DEVNAME;
+ index_reg = SP5100_IO_PM_INDEX_REG;
+ data_reg = SP5100_IO_PM_DATA_REG;
+@@ -388,8 +394,7 @@ static unsigned char sp5100_tco_setupdev
+ * Secondly, Find the watchdog timer MMIO address
+ * from SBResource_MMIO register.
+ */
+- if (sp5100_tco_pci->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
+- sp5100_tco_pci->revision < 0x40) {
++ if (tco_has_sp5100_reg_layout(sp5100_tco_pci)) {
+ /* Read SBResource_MMIO from PCI config(PCI_Reg: 9Ch) */
+ pci_read_config_dword(sp5100_tco_pci,
+ SP5100_SB_RESOURCE_MMIO_BASE, &val);
+++ /dev/null
-::sysinit:/etc/init.d/rcS S boot
-::shutdown:/etc/init.d/rcS K stop
-tts/0::askfirst:/usr/libexec/login.sh
-hvc0::askfirst:/usr/libexec/login.sh
-tty1::askfirst:/usr/libexec/login.sh
+++ /dev/null
-#!/bin/sh
-# Copyright (C) 2010 OpenWrt.org
-
-do_mount_xenfs() {
- [ -f /etc/modules.d/??-xenfs ] && {
- insmod $(cat /etc/modules.d/??-xenfs)
- mount -o noatime none /proc/xen -t xenfs
- }
-}
-
-boot_hook_add preinit_mount_root do_mount_xenfs
+++ /dev/null
-# CONFIG_APM is not set
-CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK=y
-CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
-CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH=y
-# CONFIG_BOOTPARAM_HOTPLUG_CPU0 is not set
-CONFIG_CPU_RMAP=y
-# CONFIG_DEBUG_HOTPLUG_CPU0 is not set
-CONFIG_FB=y
-CONFIG_FB_CMDLINE=y
-CONFIG_FB_DEFERRED_IO=y
-CONFIG_FB_SYS_COPYAREA=y
-CONFIG_FB_SYS_FILLRECT=y
-CONFIG_FB_SYS_FOPS=y
-CONFIG_FB_SYS_IMAGEBLIT=y
-# CONFIG_FB_VESA is not set
-CONFIG_FREEZER=y
-CONFIG_GENERIC_PENDING_IRQ=y
-CONFIG_HAVE_ARCH_HUGE_VMAP=y
-CONFIG_HIBERNATE_CALLBACKS=y
-# CONFIG_HIGHMEM64G is not set
-CONFIG_HOTPLUG_CPU=y
-CONFIG_HVC_DRIVER=y
-CONFIG_HVC_IRQ=y
-CONFIG_HVC_XEN=y
-CONFIG_HVC_XEN_FRONTEND=y
-CONFIG_HYPERVISOR_GUEST=y
-CONFIG_INPUT_XEN_KBDDEV_FRONTEND=y
-CONFIG_IOMMU_HELPER=y
-CONFIG_KERNEL_GZIP=y
-# CONFIG_KERNEL_XZ is not set
-# CONFIG_LGUEST_GUEST is not set
-CONFIG_LOCK_SPIN_ON_OWNER=y
-# CONFIG_M486 is not set
-CONFIG_MMU_NOTIFIER=y
-CONFIG_MPENTIUM4=y
-CONFIG_MUTEX_SPIN_ON_OWNER=y
-CONFIG_NEED_DMA_MAP_STATE=y
-CONFIG_NET_FLOW_LIMIT=y
-CONFIG_NR_CPUS=4
-CONFIG_PARAVIRT=y
-CONFIG_PARAVIRT_CLOCK=y
-# CONFIG_PARAVIRT_DEBUG is not set
-CONFIG_PARAVIRT_SPINLOCKS=y
-# CONFIG_PARAVIRT_TIME_ACCOUNTING is not set
-CONFIG_PCI_XEN=y
-CONFIG_PGTABLE_LEVELS=3
-CONFIG_PHYS_ADDR_T_64BIT=y
-CONFIG_PM=y
-# CONFIG_PM_DEBUG is not set
-CONFIG_PM_SLEEP=y
-CONFIG_PM_SLEEP_SMP=y
-CONFIG_QUEUED_RWLOCKS=y
-CONFIG_QUEUED_SPINLOCKS=y
-CONFIG_RCU_STALL_COMMON=y
-CONFIG_RFS_ACCEL=y
-CONFIG_RPS=y
-CONFIG_RWSEM_SPIN_ON_OWNER=y
-CONFIG_SCHED_MC=y
-CONFIG_SMP=y
-CONFIG_SWIOTLB=y
-CONFIG_SWIOTLB_XEN=y
-CONFIG_SYS_HYPERVISOR=y
-CONFIG_TREE_RCU=y
-CONFIG_VT_CONSOLE_SLEEP=y
-CONFIG_X86_32_SMP=y
-# CONFIG_X86_BIGSMP is not set
-CONFIG_X86_CMOV=y
-CONFIG_X86_CMPXCHG64=y
-CONFIG_X86_DEBUGCTLMSR=y
-CONFIG_X86_INTERNODE_CACHE_SHIFT=7
-CONFIG_X86_L1_CACHE_SHIFT=7
-CONFIG_X86_MINIMUM_CPU_FAMILY=5
-CONFIG_X86_PAE=y
-# CONFIG_X86_PMEM_LEGACY is not set
-CONFIG_X86_TSC=y
-CONFIG_X86_USE_PPRO_CHECKSUM=y
-CONFIG_XEN=y
-CONFIG_XENFS=y
-CONFIG_XEN_AUTO_XLATE=y
-CONFIG_XEN_BALLOON=y
-CONFIG_XEN_BLKDEV_FRONTEND=y
-CONFIG_XEN_COMPAT_XENFS=y
-CONFIG_XEN_DEBUG_FS=y
-CONFIG_XEN_DEV_EVTCHN=y
-CONFIG_XEN_FBDEV_FRONTEND=y
-CONFIG_XEN_GNTDEV=y
-CONFIG_XEN_GRANT_DEV_ALLOC=y
-CONFIG_XEN_HAVE_PVMMU=y
-CONFIG_XEN_HAVE_VPMU=y
-CONFIG_XEN_NETDEV_FRONTEND=y
-CONFIG_XEN_PCIDEV_FRONTEND=y
-CONFIG_XEN_PRIVCMD=y
-CONFIG_XEN_PVHVM=y
-CONFIG_XEN_SAVE_RESTORE=y
-CONFIG_XEN_SCRUB_PAGES=y
-CONFIG_XEN_SCSI_FRONTEND=y
-CONFIG_XEN_SYS_HYPERVISOR=y
-# CONFIG_XEN_WDT is not set
-CONFIG_XEN_XENBUS_FRONTEND=y
-CONFIG_XPS=y
+++ /dev/null
-#
-# Copyright (C) 2006-2015 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-define Profile/Generic
- NAME:=Generic
-endef
-
-define Profile/Generic/Description
- Generic Profile
-endef
-$(eval $(call Profile,Generic))
+++ /dev/null
-BOARDNAME:=Xen Paravirt Guest
-FEATURES:=display ext4 targz
-CPU_TYPE := pentium4
ARCH:=mipsel
BOARD:=xburst
BOARDNAME:=Ingenic XBurst
-FEATURES:=targz nand ubifs audio
+FEATURES:=targz nand ubifs audio source-only
SUBTARGETS:=qi_lb60
KERNEL_PATCHVER:=3.18
UIMAGE:=$(BIN_DIR)/$(IMG_PREFIX)-uImage.bin
-define kernel_entry
-0x$(shell $(TARGET_CROSS)nm $(1) 2>/dev/null | grep " kernel_entry" | cut -f1 -d ' ')
-endef
-
-
define MkImageGzip
gzip -9n -c $(1) > $(1).gz
mkimage -A mips -O linux -T kernel -a 0x80010000 -C gzip \
- -e $(call kernel_entry,$(KDIR)/vmlinux.debug) -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
+ -e 0x80010000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
-d $(1).gz $(2)
endef
config SDK
bool "Build the libreCMC SDK"
depends on !EXTERNAL_TOOLCHAIN
+ default BUILDBOT
help
This is essentially a stripped-down version of the buildroot
with a precompiled toolchain. It can be used to develop and
SDK_BUILD_DIR:=$(BUILD_DIR)/$(SDK_NAME)
STAGING_SUBDIR_HOST := staging_dir/host
+STAGING_SUBDIR_TARGET := staging_dir/$(TARGET_DIR_NAME)
STAGING_SUBDIR_TOOLCHAIN := staging_dir/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)_$(LIBC)-$(LIBCV)$(if $(CONFIG_arm),_eabi)
EXCLUDE_DIRS:=*/ccache/* \
*.install.clean \
*.install.flags \
*.install \
- */doc
+ */doc \
+ */share/locale
SDK_DIRS = \
$(STAGING_SUBDIR_HOST) \
$(STAGING_SUBDIR_TOOLCHAIN)
-BASE_FEED:=$(shell git config --get remote.origin.url 2>/dev/null | sed -ne 's/^/src-git base /p')
+GIT_URL:=$(filter git://% http://% https://%,$(shell git config --get remote.origin.url 2>/dev/null))
+GIT_COMMIT:=$(shell git rev-parse HEAD 2>/dev/null)
+GIT_BRANCH:=$(filter-out master HEAD,$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null))
+GIT_TAGNAME:=$(shell git show-ref --tags --dereference 2>/dev/null | sed -ne '/^$(GIT_COMMIT) / { s|^.*/||; s|\^.*||; p }')
+
+BASE_FEED:=$(if $(GIT_URL),src-git base $(GIT_URL)$(if $(GIT_BRANCH),;$(GIT_BRANCH),$(if $(GIT_TAGNAME),;$(GIT_TAGNAME))))
BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),$(shell cd $(TOPDIR); LC_ALL=C git svn info 2>/dev/null | sed -ne 's/^URL: /src-gitsvn base /p'))
BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),$(shell cd $(TOPDIR); LC_ALL=C svn info 2>/dev/null | sed -ne 's/^URL: /src-svn base /p'))
-BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),src-git base https://git.lede-project.org/source.git$(filter-out ;master,;$(shell git rev-parse --abbrev-ref HEAD)))
+BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),src-git base https://git.lede-project.org/source.git$(if $(GIT_BRANCH),;$(GIT_BRANCH),$(if $(GIT_TAGNAME),;$(GIT_TAGNAME))))
KDIR_BASE = $(patsubst $(TOPDIR)/%,%,$(LINUX_DIR))
find \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/lib \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/lib \
- -type f -name \*.so\* -or -name \*.a; \
+ -type f -name \*.so\*; \
) | xargs strip 2>/dev/null >/dev/null
mkdir -p $(SDK_BUILD_DIR)/target/linux
$(TOPDIR)/package/kernel/linux \
$(SDK_BUILD_DIR)/package/
+ -rm -rf \
+ $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/ccache \
+ $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TARGET)/ccache \
+ $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/ccache
+
-rm -f $(SDK_BUILD_DIR)/feeds.conf.default
$(if $(BASE_FEED),echo "$(BASE_FEED)" > $(SDK_BUILD_DIR)/feeds.conf.default)
if [ -f $(TOPDIR)/feeds.conf ]; then \
find $(SDK_BUILD_DIR) -name .git | $(XARGS) rm -rf
find $(SDK_BUILD_DIR) -name .svn | $(XARGS) rm -rf
find $(SDK_BUILD_DIR) -name CVS | $(XARGS) rm -rf
+ -make -C $(SDK_BUILD_DIR)/scripts/config clean
(cd $(BUILD_DIR); \
tar -I 'xz -7e' -cf $@ $(SDK_NAME); \
)
-This is the libreCMC SDK. It contains a stripped-down version of
+This is the LEDE SDK. It contains a stripped-down version of
the buildroot. You can use it to test/develop packages without
having to compile your own toolchain or any of the libraries
-included with libreCMC.
+included with LEDE.
To use it, just put your buildroot-compatible package directory
(including its dependencies) in the subdir 'package/' and run
config MUSL_VERSION
string
depends on USE_MUSL
- default "1.1.15"
+ default "1.1.16"
endif
PKG_VERSION:=$(call qstrip,$(CONFIG_MUSL_VERSION))
PKG_RELEASE=1
-PKG_HASH:=97e447c7ee2a7f613186ec54a93054fe15469fe34d7d323080f7ef38f5ecb0fa
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=769f53598e781ffc89191520f3f8a93cb58db91f
+PKG_MIRROR_HASH:=c148c570cc46471ab30a1b36e96531519837e41c4347f3164bf610ab98741d80
+PKG_SOURCE_URL:=git://git.musl-libc.org/musl
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz
-PKG_SOURCE_URL:=http://www.musl-libc.org/releases
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
LIBC_SO_VERSION:=$(PKG_VERSION)
PATCH_DIR:=$(PATH_PREFIX)/patches
+++ /dev/null
-From 6399fa9d29ea83de4735680b77d457bd59606532 Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Thu, 7 Jul 2016 16:51:37 -0400
-Subject: fix asctime day/month names not to vary by locale
-
-the FIXME comment here was overlooked at the time locale support was
-added.
----
- src/time/__asctime.c | 9 ++++-----
- 1 file changed, 4 insertions(+), 5 deletions(-)
-
-diff --git a/src/time/__asctime.c b/src/time/__asctime.c
-index e7e7f07..f114dfe 100644
---- a/src/time/__asctime.c
-+++ b/src/time/__asctime.c
-@@ -1,17 +1,16 @@
- #include <time.h>
- #include <stdio.h>
- #include <langinfo.h>
-+#include "locale_impl.h"
- #include "atomic.h"
-
--const char *__nl_langinfo(nl_item);
-+const char *__nl_langinfo_l(nl_item, locale_t);
-
- char *__asctime(const struct tm *restrict tm, char *restrict buf)
- {
-- /* FIXME: change __nl_langinfo to __nl_langinfo_l with explicit C
-- * locale once we have locales */
- if (snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
-- __nl_langinfo(ABDAY_1+tm->tm_wday),
-- __nl_langinfo(ABMON_1+tm->tm_mon),
-+ __nl_langinfo_l(ABDAY_1+tm->tm_wday, C_LOCALE),
-+ __nl_langinfo_l(ABMON_1+tm->tm_mon, C_LOCALE),
- tm->tm_mday, tm->tm_hour,
- tm->tm_min, tm->tm_sec,
- 1900 + tm->tm_year) >= 26)
---
-cgit v0.11.2
-
-
+++ /dev/null
-From cff5747c74c41b22f1ce1340978b1c226a8cdf32 Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Wed, 13 Jul 2016 15:04:30 -0400
-Subject: [PATCH] fix regression in tcsetattr on all mips archs
-
-revert commit 8c316e9e49d37ad92c2e7493e16166a2afca419f. it was wrong
-and does not match how the kernel API works.
----
- arch/mips/bits/termios.h | 6 +++---
- arch/mips64/bits/termios.h | 6 +++---
- arch/mipsn32/bits/termios.h | 6 +++---
- 4 files changed, 10 insertions(+), 10 deletions(-)
-
-diff --git a/arch/mips/bits/termios.h b/arch/mips/bits/termios.h
-index f559f76..6a1205d 100644
---- a/arch/mips/bits/termios.h
-+++ b/arch/mips/bits/termios.h
-@@ -141,9 +141,9 @@ struct termios {
- #define TCOFLUSH 1
- #define TCIOFLUSH 2
-
--#define TCSANOW 0x540e
--#define TCSADRAIN 0x540f
--#define TCSAFLUSH 0x5410
-+#define TCSANOW 0
-+#define TCSADRAIN 1
-+#define TCSAFLUSH 2
-
- #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
- #define EXTA 0000016
-diff --git a/arch/mips64/bits/termios.h b/arch/mips64/bits/termios.h
-index f559f76..6a1205d 100644
---- a/arch/mips64/bits/termios.h
-+++ b/arch/mips64/bits/termios.h
-@@ -141,9 +141,9 @@ struct termios {
- #define TCOFLUSH 1
- #define TCIOFLUSH 2
-
--#define TCSANOW 0x540e
--#define TCSADRAIN 0x540f
--#define TCSAFLUSH 0x5410
-+#define TCSANOW 0
-+#define TCSADRAIN 1
-+#define TCSAFLUSH 2
-
- #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
- #define EXTA 0000016
-diff --git a/arch/mipsn32/bits/termios.h b/arch/mipsn32/bits/termios.h
-index f559f76..6a1205d 100644
---- a/arch/mipsn32/bits/termios.h
-+++ b/arch/mipsn32/bits/termios.h
-@@ -141,9 +141,9 @@ struct termios {
- #define TCOFLUSH 1
- #define TCIOFLUSH 2
-
--#define TCSANOW 0x540e
--#define TCSADRAIN 0x540f
--#define TCSAFLUSH 0x5410
-+#define TCSANOW 0
-+#define TCSADRAIN 1
-+#define TCSAFLUSH 2
-
- #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
- #define EXTA 0000016
---
-2.8.1
-
+++ /dev/null
-From 7cc3a28eed7e3b72a1ce4568fb55154bb0540726 Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Thu, 11 Aug 2016 18:36:46 -0400
-Subject: fix pread/pwrite syscall calling convention on sh
-
-despite sh not generally using register-pair alignment for 64-bit
-syscall arguments, there are arch-specific versions of the syscall
-entry points for pread and pwrite which include a dummy argument for
-alignment before the 64-bit offset argument.
----
- arch/sh/syscall_arch.h | 1 +
- src/internal/syscall.h | 4 ++++
- src/unistd/pread.c | 2 +-
- src/unistd/pwrite.c | 2 +-
- 4 files changed, 7 insertions(+), 2 deletions(-)
-
-diff --git a/arch/sh/syscall_arch.h b/arch/sh/syscall_arch.h
-index f63675a..84758fe 100644
---- a/arch/sh/syscall_arch.h
-+++ b/arch/sh/syscall_arch.h
-@@ -2,6 +2,7 @@
- ((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
- ((union { long long ll; long l[2]; }){ .ll = x }).l[1]
- #define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))
-+#define __SYSCALL_LL_PRW(x) 0, __SYSCALL_LL_E((x))
-
- /* The extra OR instructions are to work around a hardware bug:
- * http://documentation.renesas.com/doc/products/mpumcu/tu/tnsh7456ae.pdf
-diff --git a/src/internal/syscall.h b/src/internal/syscall.h
-index ff3cf53..6d378a8 100644
---- a/src/internal/syscall.h
-+++ b/src/internal/syscall.h
-@@ -12,6 +12,10 @@
- #define SYSCALL_MMAP2_UNIT 4096ULL
- #endif
-
-+#ifndef __SYSCALL_LL_PRW
-+#define __SYSCALL_LL_PRW(x) __SYSCALL_LL_O(x)
-+#endif
-+
- #ifndef __scc
- #define __scc(X) ((long) (X))
- typedef long syscall_arg_t;
-diff --git a/src/unistd/pread.c b/src/unistd/pread.c
-index 3d2799f..5483eb9 100644
---- a/src/unistd/pread.c
-+++ b/src/unistd/pread.c
-@@ -4,7 +4,7 @@
-
- ssize_t pread(int fd, void *buf, size_t size, off_t ofs)
- {
-- return syscall_cp(SYS_pread, fd, buf, size, __SYSCALL_LL_O(ofs));
-+ return syscall_cp(SYS_pread, fd, buf, size, __SYSCALL_LL_PRW(ofs));
- }
-
- LFS64(pread);
-diff --git a/src/unistd/pwrite.c b/src/unistd/pwrite.c
-index bbe4c34..4bf3d7d 100644
---- a/src/unistd/pwrite.c
-+++ b/src/unistd/pwrite.c
-@@ -4,7 +4,7 @@
-
- ssize_t pwrite(int fd, const void *buf, size_t size, off_t ofs)
- {
-- return syscall_cp(SYS_pwrite, fd, buf, size, __SYSCALL_LL_O(ofs));
-+ return syscall_cp(SYS_pwrite, fd, buf, size, __SYSCALL_LL_PRW(ofs));
- }
-
- LFS64(pwrite);
---
-cgit v0.11.2
+++ /dev/null
-From 0a950dcf15bb9f7274c804dca490e9e20e475f3e Mon Sep 17 00:00:00 2001
-From: Szabolcs Nagy <nsz@port70.net>
-Date: Sat, 20 Aug 2016 21:04:31 +0200
-Subject: verify that ttyname refers to the same file as the fd
-
-linux containers use separate mount namespace so the /proc
-symlink might not point to the right device if the fd was
-opened in the parent namespace, in this case return ENOENT.
----
- src/unistd/ttyname_r.c | 15 +++++++++++----
- 1 file changed, 11 insertions(+), 4 deletions(-)
-
-diff --git a/src/unistd/ttyname_r.c b/src/unistd/ttyname_r.c
-index 8bac7b2..a38ba4f 100644
---- a/src/unistd/ttyname_r.c
-+++ b/src/unistd/ttyname_r.c
-@@ -1,10 +1,12 @@
- #include <unistd.h>
- #include <errno.h>
-+#include <sys/stat.h>
-
- void __procfdname(char *, unsigned);
-
- int ttyname_r(int fd, char *name, size_t size)
- {
-+ struct stat st1, st2;
- char procname[sizeof "/proc/self/fd/" + 3*sizeof(int) + 2];
- ssize_t l;
-
-@@ -15,8 +17,13 @@ int ttyname_r(int fd, char *name, size_t size)
-
- if (l < 0) return errno;
- else if (l == size) return ERANGE;
-- else {
-- name[l] = 0;
-- return 0;
-- }
-+
-+ name[l] = 0;
-+
-+ if (stat(name, &st1) || fstat(fd, &st2))
-+ return errno;
-+ if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
-+ return ENOENT;
-+
-+ return 0;
- }
---
-cgit v0.11.2
+++ /dev/null
-From c1f4ed150137d793c9d07356305a89e8785e7e02 Mon Sep 17 00:00:00 2001
-From: Duncan Overbruck <duncaen@voidlinux.eu>
-Date: Thu, 18 Aug 2016 17:06:16 +0200
-Subject: fix FFSYNC by changing it to O_SYNC
-
-O_FSYNC was never defined and is legacy/wrong, nothing seems to use it.
----
- include/fcntl.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/include/fcntl.h b/include/fcntl.h
-index e683e4d..0e165ca 100644
---- a/include/fcntl.h
-+++ b/include/fcntl.h
-@@ -99,7 +99,7 @@ int posix_fallocate(int, off_t, off_t);
- #define AT_EMPTY_PATH 0x1000
-
- #define FAPPEND O_APPEND
--#define FFSYNC O_FSYNC
-+#define FFSYNC O_SYNC
- #define FASYNC O_ASYNC
- #define FNONBLOCK O_NONBLOCK
- #define FNDELAY O_NDELAY
---
-cgit v0.11.2
+++ /dev/null
-From 78897b0dc00b7cd5c29af5e0b7eebf2396d8dce0 Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Fri, 16 Sep 2016 17:40:08 -0400
-Subject: fix printf regression with alt-form octal, zero flag, and field width
-
-commit b91cdbe2bc8b626aa04dc6e3e84345accf34e4b1, in fixing another
-issue, changed the logic for how alt-form octal adds the leading zero
-to adjust the precision rather than using a prefix character. this
-wrongly suppressed the zero flag by mimicing an explicit precision
-given by the format string. switch back to using a prefix character.
-
-based on bug report and patch by Dmitry V. Levin, but simplified.
----
- src/stdio/vfprintf.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
-index 2ecf769..e439a07 100644
---- a/src/stdio/vfprintf.c
-+++ b/src/stdio/vfprintf.c
-@@ -570,7 +570,7 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
- if (0) {
- case 'o':
- a = fmt_o(arg.i, z);
-- if ((fl&ALT_FORM) && p<z-a+1) p=z-a+1;
-+ if ((fl&ALT_FORM) && p<z-a+1) prefix+=5, pl=1;
- } if (0) {
- case 'd': case 'i':
- pl=1;
---
-cgit v0.11.2
+++ /dev/null
-From 3848a99f65952a77c03bbd905cae988f37f13ea6 Mon Sep 17 00:00:00 2001
-From: Daniel Sabogal <dsabogalcc@gmail.com>
-Date: Fri, 16 Sep 2016 13:34:24 -0400
-Subject: fix ifru_data and ifcu_buf types in net/if.h
-
-glibc, freebsd, and openbsd use character pointers (caddr_t) for
-these fields. only linux uses void pointer for the ifru_data type.
----
- include/net/if.h | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/include/net/if.h b/include/net/if.h
-index 1a4059d..2f2fcc1 100644
---- a/include/net/if.h
-+++ b/include/net/if.h
-@@ -89,7 +89,7 @@ struct ifreq {
- struct ifmap ifru_map;
- char ifru_slave[IFNAMSIZ];
- char ifru_newname[IFNAMSIZ];
-- void *ifru_data;
-+ char *ifru_data;
- } ifr_ifru;
- };
-
-@@ -116,7 +116,7 @@ struct ifreq {
- struct ifconf {
- int ifc_len;
- union {
-- void *ifcu_buf;
-+ char *ifcu_buf;
- struct ifreq *ifcu_req;
- } ifc_ifcu;
- };
---
-cgit v0.11.2
+++ /dev/null
-From 32055d52ca43d867d6dbb763dc5213a8d3536a23 Mon Sep 17 00:00:00 2001
-From: Daniel Sabogal <dsabogalcc@gmail.com>
-Date: Thu, 15 Sep 2016 11:27:30 -0400
-Subject: fix if_indextoname error case
-
-posix requires errno to be set to ENXIO if the interface does not exist.
-linux returns ENODEV instead so we handle this.
----
- src/network/if_indextoname.c | 7 ++++++-
- 1 file changed, 6 insertions(+), 1 deletion(-)
-
-diff --git a/src/network/if_indextoname.c b/src/network/if_indextoname.c
-index 6ee7f13..3b368bf 100644
---- a/src/network/if_indextoname.c
-+++ b/src/network/if_indextoname.c
-@@ -3,6 +3,7 @@
- #include <sys/socket.h>
- #include <sys/ioctl.h>
- #include <string.h>
-+#include <errno.h>
- #include "syscall.h"
-
- char *if_indextoname(unsigned index, char *name)
-@@ -14,5 +15,9 @@ char *if_indextoname(unsigned index, char *name)
- ifr.ifr_ifindex = index;
- r = ioctl(fd, SIOCGIFNAME, &ifr);
- __syscall(SYS_close, fd);
-- return r < 0 ? 0 : strncpy(name, ifr.ifr_name, IF_NAMESIZE);
-+ if (r < 0) {
-+ if (errno == ENODEV) errno = ENXIO;
-+ return 0;
-+ }
-+ return strncpy(name, ifr.ifr_name, IF_NAMESIZE);
- }
---
-cgit v0.11.2
+++ /dev/null
-From 5505f6afae9acf37ef565c68a07ca3df7b1ae2cb Mon Sep 17 00:00:00 2001
-From: Daniel Sabogal <dsabogalcc@gmail.com>
-Date: Fri, 9 Sep 2016 21:23:17 -0400
-Subject: add missing *_unlocked and wcsftime_l prototypes to wchar.h
-
-these functions had been implemented, but prototypes were not made available
----
- include/wchar.h | 15 +++++++++++++++
- 1 file changed, 15 insertions(+)
-
-diff --git a/include/wchar.h b/include/wchar.h
-index 0167dce..3e6db5f 100644
---- a/include/wchar.h
-+++ b/include/wchar.h
-@@ -136,6 +136,21 @@ size_t wcsftime (wchar_t *__restrict, size_t, const wchar_t *__restrict, const s
-
- #undef iswdigit
-
-+#if defined(_GNU_SOURCE)
-+wint_t fgetwc_unlocked (FILE *);
-+wint_t getwc_unlocked (FILE *);
-+wint_t getwchar_unlocked (void);
-+wint_t fputwc_unlocked (wchar_t, FILE *);
-+wint_t putwc_unlocked (wchar_t, FILE *);
-+wint_t putwchar_unlocked (wchar_t);
-+wchar_t *fgetws_unlocked (wchar_t *__restrict, int, FILE *__restrict);
-+int fputws_unlocked (const wchar_t *__restrict, FILE *__restrict);
-+#endif
-+
-+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
-+size_t wcsftime_l (wchar_t *__restrict, size_t, const wchar_t *__restrict, const struct tm *__restrict, locale_t);
-+#endif
-+
- #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
- || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
- FILE *open_wmemstream(wchar_t **, size_t *);
---
-cgit v0.11.2
+++ /dev/null
-From 66570ec9c465e3c6c5d6dbd7dd42e45041a39288 Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Mon, 19 Sep 2016 11:15:51 -0400
-Subject: fix undefined behavior in sched.h cpu_set_t usage
-
-since cpu sets can be dynamically allocated and have variable size,
-accessing their contents via ->__bits is not valid; performing pointer
-arithmetic outside the range of the size of the declared __bits array
-results in undefined beahavior. instead, only use cpu_set_t for
-fixed-size cpu set objects (instantiated by the caller) and as an
-abstract pointer type for dynamically allocated ones. perform all
-accesses simply by casting the abstract pointer type cpuset_t * back
-to unsigned long *.
----
- include/sched.h | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/include/sched.h b/include/sched.h
-index af82d6c..d1cccb7 100644
---- a/include/sched.h
-+++ b/include/sched.h
-@@ -82,7 +82,7 @@ int sched_getaffinity(pid_t, size_t, cpu_set_t *);
- int sched_setaffinity(pid_t, size_t, const cpu_set_t *);
-
- #define __CPU_op_S(i, size, set, op) ( (i)/8U >= (size) ? 0 : \
-- ((set)->__bits[(i)/8/sizeof(long)] op (1UL<<((i)%(8*sizeof(long))))) )
-+ (((unsigned long *)(set))[(i)/8/sizeof(long)] op (1UL<<((i)%(8*sizeof(long))))) )
-
- #define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=)
- #define CPU_CLR_S(i, size, set) __CPU_op_S(i, size, set, &=~)
-@@ -94,8 +94,8 @@ static __inline void __CPU_##func##_S(size_t __size, cpu_set_t *__dest, \
- { \
- size_t __i; \
- for (__i=0; __i<__size/sizeof(long); __i++) \
-- __dest->__bits[__i] = __src1->__bits[__i] \
-- op __src2->__bits[__i] ; \
-+ ((unsigned long *)__dest)[__i] = ((unsigned long *)__src1)[__i] \
-+ op ((unsigned long *)__src2)[__i] ; \
- }
-
- __CPU_op_func_S(AND, &)
---
-cgit v0.11.2
+++ /dev/null
-From 8d7a3f40c8de414122eb8eb2131291782ee8ed15 Mon Sep 17 00:00:00 2001
-From: Daniel Sabogal <dsabogalcc@gmail.com>
-Date: Fri, 23 Sep 2016 21:10:07 -0400
-Subject: fix getservby*_r result pointer value on error
-
-this is a clone of the fix to the gethostby*_r functions in
-commit fe82bb9b921be34370e6b71a1c6f062c20999ae0. the man pages
-document that the getservby*_r functions set this pointer to
-NULL if there was an error or if no record was found.
----
- src/network/getservbyname_r.c | 2 ++
- src/network/getservbyport_r.c | 1 +
- 2 files changed, 3 insertions(+)
-
-diff --git a/src/network/getservbyname_r.c b/src/network/getservbyname_r.c
-index 056c2f3..ad3d616 100644
---- a/src/network/getservbyname_r.c
-+++ b/src/network/getservbyname_r.c
-@@ -15,6 +15,8 @@ int getservbyname_r(const char *name, const char *prots,
- struct service servs[MAXSERVS];
- int cnt, proto, align;
-
-+ *res = 0;
-+
- /* Align buffer */
- align = -(uintptr_t)buf & ALIGN-1;
- if (buflen < 2*sizeof(char *)+align)
-diff --git a/src/network/getservbyport_r.c b/src/network/getservbyport_r.c
-index a0a7cae..0ae0e41 100644
---- a/src/network/getservbyport_r.c
-+++ b/src/network/getservbyport_r.c
-@@ -20,6 +20,7 @@ int getservbyport_r(int port, const char *prots,
- if (r) r = getservbyport_r(port, "udp", se, buf, buflen, res);
- return r;
- }
-+ *res = 0;
-
- /* Align buffer */
- i = (uintptr_t)buf & sizeof(char *)-1;
---
-cgit v0.11.2
+++ /dev/null
-From 583ea83541dcc6481c7a1bd1a9b485526bad84a1 Mon Sep 17 00:00:00 2001
-From: Szabolcs Nagy <nsz@port70.net>
-Date: Tue, 4 Oct 2016 17:14:57 +0000
-Subject: fix strftime %y for negative tm_year
-
----
- src/time/strftime.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/src/time/strftime.c b/src/time/strftime.c
-index f1ccc4d..e103e02 100644
---- a/src/time/strftime.c
-+++ b/src/time/strftime.c
-@@ -167,6 +167,7 @@ const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm *
- goto nl_strftime;
- case 'y':
- val = tm->tm_year % 100;
-+ if (val<0) val += 100;
- goto number;
- case 'Y':
- val = tm->tm_year + 1900LL;
---
-cgit v0.11.2
+++ /dev/null
-From c3edc06d1e1360f3570db9155d6b318ae0d0f0f7 Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Thu, 6 Oct 2016 18:34:58 -0400
-Subject: fix missing integer overflow checks in regexec buffer size
- computations
-
-most of the possible overflows were already ruled out in practice by
-regcomp having already succeeded performing larger allocations.
-however at least the num_states*num_tags multiplication can clearly
-overflow in practice. for safety, check them all, and use the proper
-type, size_t, rather than int.
-
-also improve comments, use calloc in place of malloc+memset, and
-remove bogus casts.
----
- src/regex/regexec.c | 23 ++++++++++++++++++-----
- 1 file changed, 18 insertions(+), 5 deletions(-)
-
-diff --git a/src/regex/regexec.c b/src/regex/regexec.c
-index 16c5d0a..dd52319 100644
---- a/src/regex/regexec.c
-+++ b/src/regex/regexec.c
-@@ -34,6 +34,7 @@
- #include <wchar.h>
- #include <wctype.h>
- #include <limits.h>
-+#include <stdint.h>
-
- #include <regex.h>
-
-@@ -206,11 +207,24 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
-
- /* Allocate memory for temporary data required for matching. This needs to
- be done for every matching operation to be thread safe. This allocates
-- everything in a single large block from the stack frame using alloca()
-- or with malloc() if alloca is unavailable. */
-+ everything in a single large block with calloc(). */
- {
-- int tbytes, rbytes, pbytes, xbytes, total_bytes;
-+ size_t tbytes, rbytes, pbytes, xbytes, total_bytes;
- char *tmp_buf;
-+
-+ /* Ensure that tbytes and xbytes*num_states cannot overflow, and that
-+ * they don't contribute more than 1/8 of SIZE_MAX to total_bytes. */
-+ if (num_tags > SIZE_MAX/(8 * sizeof(int) * tnfa->num_states))
-+ goto error_exit;
-+
-+ /* Likewise check rbytes. */
-+ if (tnfa->num_states+1 > SIZE_MAX/(8 * sizeof(*reach_next)))
-+ goto error_exit;
-+
-+ /* Likewise check pbytes. */
-+ if (tnfa->num_states > SIZE_MAX/(8 * sizeof(*reach_pos)))
-+ goto error_exit;
-+
- /* Compute the length of the block we need. */
- tbytes = sizeof(*tmp_tags) * num_tags;
- rbytes = sizeof(*reach_next) * (tnfa->num_states + 1);
-@@ -221,10 +235,9 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
- + (rbytes + xbytes * tnfa->num_states) * 2 + tbytes + pbytes;
-
- /* Allocate the memory. */
-- buf = xmalloc((unsigned)total_bytes);
-+ buf = calloc(total_bytes, 1);
- if (buf == NULL)
- return REG_ESPACE;
-- memset(buf, 0, (size_t)total_bytes);
-
- /* Get the various pointers within tmp_buf (properly aligned). */
- tmp_tags = (void *)buf;
---
-cgit v0.11.2
+++ /dev/null
-From aee6abb2400b9a955c2b41166db1c22f63ad42ef Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Thu, 6 Oct 2016 12:15:47 -0400
-Subject: fix regexec with haystack strings longer than INT_MAX
-
-we inherited from TRE regexec code that's utterly wrong with respect
-to the integer types it's using. while it doesn't appear that
-compilers are producing unsafe output, signed integer overflows seem
-to happen, and regexec fails to find matches past offset INT_MAX.
-
-this patch fixes the type of all variables/fields used to store
-offsets in the string from int to regoff_t. after the changes, basic
-testing showed that regexec can now find matches past 2GB (INT_MAX)
-and past 4GB on x86_64, and code generation is unchanged on i386.
----
- src/regex/regexec.c | 54 +++++++++++++++++++++++++++--------------------------
- 1 file changed, 28 insertions(+), 26 deletions(-)
-
-diff --git a/src/regex/regexec.c b/src/regex/regexec.c
-index dd52319..5c4cb92 100644
---- a/src/regex/regexec.c
-+++ b/src/regex/regexec.c
-@@ -44,7 +44,7 @@
-
- static void
- tre_fill_pmatch(size_t nmatch, regmatch_t pmatch[], int cflags,
-- const tre_tnfa_t *tnfa, int *tags, int match_eo);
-+ const tre_tnfa_t *tnfa, regoff_t *tags, regoff_t match_eo);
-
- /***********************************************************************
- from tre-match-utils.h
-@@ -97,7 +97,7 @@ tre_fill_pmatch(size_t nmatch, regmatch_t pmatch[], int cflags,
- /* Returns 1 if `t1' wins `t2', 0 otherwise. */
- static int
- tre_tag_order(int num_tags, tre_tag_direction_t *tag_directions,
-- int *t1, int *t2)
-+ regoff_t *t1, regoff_t *t2)
- {
- int i;
- for (i = 0; i < num_tags; i++)
-@@ -157,25 +157,25 @@ tre_neg_char_classes_match(tre_ctype_t *classes, tre_cint_t wc, int icase)
-
- typedef struct {
- tre_tnfa_transition_t *state;
-- int *tags;
-+ regoff_t *tags;
- } tre_tnfa_reach_t;
-
- typedef struct {
-- int pos;
-- int **tags;
-+ regoff_t pos;
-+ regoff_t **tags;
- } tre_reach_pos_t;
-
-
- static reg_errcode_t
- tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
-- int *match_tags, int eflags,
-- int *match_end_ofs)
-+ regoff_t *match_tags, int eflags,
-+ regoff_t *match_end_ofs)
- {
- /* State variables required by GET_NEXT_WCHAR. */
- tre_char_t prev_c = 0, next_c = 0;
- const char *str_byte = string;
-- int pos = -1;
-- int pos_add_next = 1;
-+ regoff_t pos = -1;
-+ regoff_t pos_add_next = 1;
- #ifdef TRE_MBSTATE
- mbstate_t mbstate;
- #endif /* TRE_MBSTATE */
-@@ -191,10 +191,10 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
- int *tag_i;
- int num_tags, i;
-
-- int match_eo = -1; /* end offset of match (-1 if no match found yet) */
-+ regoff_t match_eo = -1; /* end offset of match (-1 if no match found yet) */
- int new_match = 0;
-- int *tmp_tags = NULL;
-- int *tmp_iptr;
-+ regoff_t *tmp_tags = NULL;
-+ regoff_t *tmp_iptr;
-
- #ifdef TRE_MBSTATE
- memset(&mbstate, '\0', sizeof(mbstate));
-@@ -214,7 +214,7 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
-
- /* Ensure that tbytes and xbytes*num_states cannot overflow, and that
- * they don't contribute more than 1/8 of SIZE_MAX to total_bytes. */
-- if (num_tags > SIZE_MAX/(8 * sizeof(int) * tnfa->num_states))
-+ if (num_tags > SIZE_MAX/(8 * sizeof(regoff_t) * tnfa->num_states))
- goto error_exit;
-
- /* Likewise check rbytes. */
-@@ -229,7 +229,7 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
- tbytes = sizeof(*tmp_tags) * num_tags;
- rbytes = sizeof(*reach_next) * (tnfa->num_states + 1);
- pbytes = sizeof(*reach_pos) * tnfa->num_states;
-- xbytes = sizeof(int) * num_tags;
-+ xbytes = sizeof(regoff_t) * num_tags;
- total_bytes =
- (sizeof(long) - 1) * 4 /* for alignment paddings */
- + (rbytes + xbytes * tnfa->num_states) * 2 + tbytes + pbytes;
-@@ -490,12 +490,12 @@ error_exit:
- */
-
- typedef struct {
-- int pos;
-+ regoff_t pos;
- const char *str_byte;
- tre_tnfa_transition_t *state;
- int state_id;
- int next_c;
-- int *tags;
-+ regoff_t *tags;
- #ifdef TRE_MBSTATE
- mbstate_t mbstate;
- #endif /* TRE_MBSTATE */
-@@ -591,13 +591,13 @@ typedef struct tre_backtrack_struct {
-
- static reg_errcode_t
- tre_tnfa_run_backtrack(const tre_tnfa_t *tnfa, const void *string,
-- int *match_tags, int eflags, int *match_end_ofs)
-+ regoff_t *match_tags, int eflags, regoff_t *match_end_ofs)
- {
- /* State variables required by GET_NEXT_WCHAR. */
- tre_char_t prev_c = 0, next_c = 0;
- const char *str_byte = string;
-- int pos = 0;
-- int pos_add_next = 1;
-+ regoff_t pos = 0;
-+ regoff_t pos_add_next = 1;
- #ifdef TRE_MBSTATE
- mbstate_t mbstate;
- #endif /* TRE_MBSTATE */
-@@ -610,15 +610,16 @@ tre_tnfa_run_backtrack(const tre_tnfa_t *tnfa, const void *string,
- started from. */
- int next_c_start;
- const char *str_byte_start;
-- int pos_start = -1;
-+ regoff_t pos_start = -1;
- #ifdef TRE_MBSTATE
- mbstate_t mbstate_start;
- #endif /* TRE_MBSTATE */
-
- /* End offset of best match so far, or -1 if no match found yet. */
-- int match_eo = -1;
-+ regoff_t match_eo = -1;
- /* Tag arrays. */
-- int *next_tags, *tags = NULL;
-+ int *next_tags;
-+ regoff_t *tags = NULL;
- /* Current TNFA state. */
- tre_tnfa_transition_t *state;
- int *states_seen = NULL;
-@@ -768,8 +769,9 @@ tre_tnfa_run_backtrack(const tre_tnfa_t *tnfa, const void *string,
- /* This is a back reference state. All transitions leaving from
- this state have the same back reference "assertion". Instead
- of reading the next character, we match the back reference. */
-- int so, eo, bt = trans_i->u.backref;
-- int bt_len;
-+ regoff_t so, eo;
-+ int bt = trans_i->u.backref;
-+ regoff_t bt_len;
- int result;
-
- /* Get the substring we need to match against. Remember to
-@@ -926,7 +928,7 @@ tre_tnfa_run_backtrack(const tre_tnfa_t *tnfa, const void *string,
- endpoint values. */
- static void
- tre_fill_pmatch(size_t nmatch, regmatch_t pmatch[], int cflags,
-- const tre_tnfa_t *tnfa, int *tags, int match_eo)
-+ const tre_tnfa_t *tnfa, regoff_t *tags, regoff_t match_eo)
- {
- tre_submatch_data_t *submatch_data;
- unsigned int i, j;
-@@ -996,7 +998,7 @@ regexec(const regex_t *restrict preg, const char *restrict string,
- {
- tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD;
- reg_errcode_t status;
-- int *tags = NULL, eo;
-+ regoff_t *tags = NULL, eo;
- if (tnfa->cflags & REG_NOSUB) nmatch = 0;
- if (tnfa->num_tags > 0 && nmatch > 0)
- {
---
-cgit v0.11.2
+++ /dev/null
-From 70d2687d85c314963cf280759b23fd4573ff0d82 Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Wed, 19 Oct 2016 20:17:16 -0400
-Subject: fix integer overflow in float printf needed-precision computation
-
-if the requested precision is close to INT_MAX, adding
-LDBL_MANT_DIG/3+8 overflows. in practice the resulting undefined
-behavior manifests as a large negative result, which is then used to
-compute the new end pointer (z) with a wildly out-of-bounds value
-(more overflow, more undefined behavior). the end result is at least
-incorrect output and character count (return value); worse things do
-not seem to happen, but detailed analysis has not been done.
-
-this patch fixes the overflow by performing the intermediate
-computation as unsigned; after division by 9, the final result
-necessarily fits in int.
----
- src/stdio/vfprintf.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
-index e439a07..cd17ad7 100644
---- a/src/stdio/vfprintf.c
-+++ b/src/stdio/vfprintf.c
-@@ -312,7 +312,7 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t)
- }
- while (e2<0) {
- uint32_t carry=0, *b;
-- int sh=MIN(9,-e2), need=1+(p+LDBL_MANT_DIG/3+8)/9;
-+ int sh=MIN(9,-e2), need=1+(p+LDBL_MANT_DIG/3U+8)/9;
- for (d=a; d<z; d++) {
- uint32_t rm = *d & (1<<sh)-1;
- *d = (*d>>sh) + carry;
---
-cgit v0.11.2
+++ /dev/null
-From 167dfe9672c116b315e72e57a55c7769f180dffa Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Thu, 20 Oct 2016 00:22:09 -0400
-Subject: fix integer overflows and uncaught EOVERFLOW in printf core
-
-this patch fixes a large number of missed internal signed-overflow
-checks and errors in determining when the return value (output length)
-would exceed INT_MAX, which should result in EOVERFLOW. some of the
-issues fixed were reported by Alexander Cherepanov; others were found
-in subsequent review of the code.
-
-aside from the signed overflows being undefined behavior, the
-following specific bugs were found to exist in practice:
-
-- overflows computing length of floating point formats with huge
- explicit precisions, integer formats with prefix characters and huge
- explicit precisions, or string arguments or format strings longer
- than INT_MAX, resulted in wrong return value and wrong %n results.
-
-- literal width and precision values outside the range of int were
- misinterpreted, yielding wrong behavior in at least one well-defined
- case: string formats with precision greater than INT_MAX were
- sometimes truncated.
-
-- in cases where EOVERFLOW is produced, incorrect values could be
- written for %n specifiers past the point of exceeding INT_MAX.
-
-in addition to fixing these bugs, we now stop producing output
-immediately when output length would exceed INT_MAX, rather than
-continuing and returning an error only at the end.
----
- src/stdio/vfprintf.c | 72 +++++++++++++++++++++++++++++++++++----------------
- src/stdio/vfwprintf.c | 63 +++++++++++++++++++++++++++-----------------
- 2 files changed, 89 insertions(+), 46 deletions(-)
-
-diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
-index cd17ad7..e2ab2dc 100644
---- a/src/stdio/vfprintf.c
-+++ b/src/stdio/vfprintf.c
-@@ -272,6 +272,8 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t)
- if (s-buf==1 && (y||p>0||(fl&ALT_FORM))) *s++='.';
- } while (y);
-
-+ if (p > INT_MAX-2-(ebuf-estr)-pl)
-+ return -1;
- if (p && s-buf-2 < p)
- l = (p+2) + (ebuf-estr);
- else
-@@ -383,17 +385,22 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t)
- p = MIN(p,MAX(0,9*(z-r-1)+e-j));
- }
- }
-+ if (p > INT_MAX-1-(p || (fl&ALT_FORM)))
-+ return -1;
- l = 1 + p + (p || (fl&ALT_FORM));
- if ((t|32)=='f') {
-+ if (e > INT_MAX-l) return -1;
- if (e>0) l+=e;
- } else {
- estr=fmt_u(e<0 ? -e : e, ebuf);
- while(ebuf-estr<2) *--estr='0';
- *--estr = (e<0 ? '-' : '+');
- *--estr = t;
-+ if (ebuf-estr > INT_MAX-l) return -1;
- l += ebuf-estr;
- }
-
-+ if (l > INT_MAX-pl) return -1;
- pad(f, ' ', w, pl+l, fl);
- out(f, prefix, pl);
- pad(f, '0', w, pl+l, fl^ZERO_PAD);
-@@ -437,8 +444,10 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t)
-
- static int getint(char **s) {
- int i;
-- for (i=0; isdigit(**s); (*s)++)
-- i = 10*i + (**s-'0');
-+ for (i=0; isdigit(**s); (*s)++) {
-+ if (i > INT_MAX/10U || **s-'0' > INT_MAX-10*i) i = -1;
-+ else i = 10*i + (**s-'0');
-+ }
- return i;
- }
-
-@@ -446,12 +455,12 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
- {
- char *a, *z, *s=(char *)fmt;
- unsigned l10n=0, fl;
-- int w, p;
-+ int w, p, xp;
- union arg arg;
- int argpos;
- unsigned st, ps;
- int cnt=0, l=0;
-- int i;
-+ size_t i;
- char buf[sizeof(uintmax_t)*3+3+LDBL_MANT_DIG/4];
- const char *prefix;
- int t, pl;
-@@ -459,18 +468,19 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
- char mb[4];
-
- for (;;) {
-+ /* This error is only specified for snprintf, but since it's
-+ * unspecified for other forms, do the same. Stop immediately
-+ * on overflow; otherwise %n could produce wrong results. */
-+ if (l > INT_MAX - cnt) goto overflow;
-+
- /* Update output count, end loop when fmt is exhausted */
-- if (cnt >= 0) {
-- if (l > INT_MAX - cnt) {
-- errno = EOVERFLOW;
-- cnt = -1;
-- } else cnt += l;
-- }
-+ cnt += l;
- if (!*s) break;
-
- /* Handle literal text and %% format specifiers */
- for (a=s; *s && *s!='%'; s++);
- for (z=s; s[0]=='%' && s[1]=='%'; z++, s+=2);
-+ if (z-a > INT_MAX-cnt) goto overflow;
- l = z-a;
- if (f) out(f, a, l);
- if (l) continue;
-@@ -498,9 +508,9 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
- } else if (!l10n) {
- w = f ? va_arg(*ap, int) : 0;
- s++;
-- } else return -1;
-+ } else goto inval;
- if (w<0) fl|=LEFT_ADJ, w=-w;
-- } else if ((w=getint(&s))<0) return -1;
-+ } else if ((w=getint(&s))<0) goto overflow;
-
- /* Read precision */
- if (*s=='.' && s[1]=='*') {
-@@ -511,24 +521,29 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
- } else if (!l10n) {
- p = f ? va_arg(*ap, int) : 0;
- s+=2;
-- } else return -1;
-+ } else goto inval;
-+ xp = (p>=0);
- } else if (*s=='.') {
- s++;
- p = getint(&s);
-- } else p = -1;
-+ xp = 1;
-+ } else {
-+ p = -1;
-+ xp = 0;
-+ }
-
- /* Format specifier state machine */
- st=0;
- do {
-- if (OOB(*s)) return -1;
-+ if (OOB(*s)) goto inval;
- ps=st;
- st=states[st]S(*s++);
- } while (st-1<STOP);
-- if (!st) return -1;
-+ if (!st) goto inval;
-
- /* Check validity of argument type (nl/normal) */
- if (st==NOARG) {
-- if (argpos>=0) return -1;
-+ if (argpos>=0) goto inval;
- } else {
- if (argpos>=0) nl_type[argpos]=st, arg=nl_arg[argpos];
- else if (f) pop_arg(&arg, st, ap);
-@@ -584,6 +599,7 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
- case 'u':
- a = fmt_u(arg.i, z);
- }
-+ if (xp && p<0) goto overflow;
- if (p>=0) fl &= ~ZERO_PAD;
- if (!arg.i && !p) {
- a=z;
-@@ -599,9 +615,9 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
- if (1) a = strerror(errno); else
- case 's':
- a = arg.p ? arg.p : "(null)";
-- z = memchr(a, 0, p);
-- if (!z) z=a+p;
-- else p=z-a;
-+ z = a + strnlen(a, p<0 ? INT_MAX : p);
-+ if (p<0 && *z) goto overflow;
-+ p = z-a;
- fl &= ~ZERO_PAD;
- break;
- case 'C':
-@@ -611,8 +627,9 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
- p = -1;
- case 'S':
- ws = arg.p;
-- for (i=l=0; i<0U+p && *ws && (l=wctomb(mb, *ws++))>=0 && l<=0U+p-i; i+=l);
-+ for (i=l=0; i<p && *ws && (l=wctomb(mb, *ws++))>=0 && l<=p-i; i+=l);
- if (l<0) return -1;
-+ if (i > INT_MAX) goto overflow;
- p = i;
- pad(f, ' ', w, p, fl);
- ws = arg.p;
-@@ -623,12 +640,16 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
- continue;
- case 'e': case 'f': case 'g': case 'a':
- case 'E': case 'F': case 'G': case 'A':
-+ if (xp && p<0) goto overflow;
- l = fmt_fp(f, arg.f, w, p, fl, t);
-+ if (l<0) goto overflow;
- continue;
- }
-
- if (p < z-a) p = z-a;
-+ if (p > INT_MAX-pl) goto overflow;
- if (w < pl+p) w = pl+p;
-+ if (w > INT_MAX-cnt) goto overflow;
-
- pad(f, ' ', w, pl+p, fl);
- out(f, prefix, pl);
-@@ -646,8 +667,15 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
- for (i=1; i<=NL_ARGMAX && nl_type[i]; i++)
- pop_arg(nl_arg+i, nl_type[i], ap);
- for (; i<=NL_ARGMAX && !nl_type[i]; i++);
-- if (i<=NL_ARGMAX) return -1;
-+ if (i<=NL_ARGMAX) goto inval;
- return 1;
-+
-+inval:
-+ errno = EINVAL;
-+ return -1;
-+overflow:
-+ errno = EOVERFLOW;
-+ return -1;
- }
-
- int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap)
-diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c
-index f9f1ecf..b8fff20 100644
---- a/src/stdio/vfwprintf.c
-+++ b/src/stdio/vfwprintf.c
-@@ -154,8 +154,10 @@ static void out(FILE *f, const wchar_t *s, size_t l)
-
- static int getint(wchar_t **s) {
- int i;
-- for (i=0; iswdigit(**s); (*s)++)
-- i = 10*i + (**s-'0');
-+ for (i=0; iswdigit(**s); (*s)++) {
-+ if (i > INT_MAX/10U || **s-'0' > INT_MAX-10*i) i = -1;
-+ else i = 10*i + (**s-'0');
-+ }
- return i;
- }
-
-@@ -168,8 +170,8 @@ static const char sizeprefix['y'-'a'] = {
- static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_arg, int *nl_type)
- {
- wchar_t *a, *z, *s=(wchar_t *)fmt;
-- unsigned l10n=0, litpct, fl;
-- int w, p;
-+ unsigned l10n=0, fl;
-+ int w, p, xp;
- union arg arg;
- int argpos;
- unsigned st, ps;
-@@ -181,20 +183,19 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
- wchar_t wc;
-
- for (;;) {
-+ /* This error is only specified for snprintf, but since it's
-+ * unspecified for other forms, do the same. Stop immediately
-+ * on overflow; otherwise %n could produce wrong results. */
-+ if (l > INT_MAX - cnt) goto overflow;
-+
- /* Update output count, end loop when fmt is exhausted */
-- if (cnt >= 0) {
-- if (l > INT_MAX - cnt) {
-- if (!ferror(f)) errno = EOVERFLOW;
-- cnt = -1;
-- } else cnt += l;
-- }
-+ cnt += l;
- if (!*s) break;
-
- /* Handle literal text and %% format specifiers */
- for (a=s; *s && *s!='%'; s++);
-- litpct = wcsspn(s, L"%")/2; /* Optimize %%%% runs */
-- z = s+litpct;
-- s += 2*litpct;
-+ for (z=s; s[0]=='%' && s[1]=='%'; z++, s+=2);
-+ if (z-a > INT_MAX-cnt) goto overflow;
- l = z-a;
- if (f) out(f, a, l);
- if (l) continue;
-@@ -222,9 +223,9 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
- } else if (!l10n) {
- w = f ? va_arg(*ap, int) : 0;
- s++;
-- } else return -1;
-+ } else goto inval;
- if (w<0) fl|=LEFT_ADJ, w=-w;
-- } else if ((w=getint(&s))<0) return -1;
-+ } else if ((w=getint(&s))<0) goto overflow;
-
- /* Read precision */
- if (*s=='.' && s[1]=='*') {
-@@ -235,24 +236,29 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
- } else if (!l10n) {
- p = f ? va_arg(*ap, int) : 0;
- s+=2;
-- } else return -1;
-+ } else goto inval;
-+ xp = (p>=0);
- } else if (*s=='.') {
- s++;
- p = getint(&s);
-- } else p = -1;
-+ xp = 1;
-+ } else {
-+ p = -1;
-+ xp = 0;
-+ }
-
- /* Format specifier state machine */
- st=0;
- do {
-- if (OOB(*s)) return -1;
-+ if (OOB(*s)) goto inval;
- ps=st;
- st=states[st]S(*s++);
- } while (st-1<STOP);
-- if (!st) return -1;
-+ if (!st) goto inval;
-
- /* Check validity of argument type (nl/normal) */
- if (st==NOARG) {
-- if (argpos>=0) return -1;
-+ if (argpos>=0) goto inval;
- } else {
- if (argpos>=0) nl_type[argpos]=st, arg=nl_arg[argpos];
- else if (f) pop_arg(&arg, st, ap);
-@@ -285,8 +291,9 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
- continue;
- case 'S':
- a = arg.p;
-- z = wmemchr(a, 0, p);
-- if (z) p=z-a;
-+ z = a + wcsnlen(a, p<0 ? INT_MAX : p);
-+ if (p<0 && *z) goto overflow;
-+ p = z-a;
- if (w<p) w=p;
- if (!(fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, "");
- out(f, a, p);
-@@ -298,9 +305,9 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
- case 's':
- if (!arg.p) arg.p = "(null)";
- bs = arg.p;
-- if (p<0) p = INT_MAX;
-- for (i=l=0; l<p && (i=mbtowc(&wc, bs, MB_LEN_MAX))>0; bs+=i, l++);
-+ for (i=l=0; l<(p<0?INT_MAX:p) && (i=mbtowc(&wc, bs, MB_LEN_MAX))>0; bs+=i, l++);
- if (i<0) return -1;
-+ if (p<0 && *bs) goto overflow;
- p=l;
- if (w<p) w=p;
- if (!(fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, "");
-@@ -315,6 +322,7 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
- continue;
- }
-
-+ if (xp && p<0) goto overflow;
- snprintf(charfmt, sizeof charfmt, "%%%s%s%s%s%s*.*%c%c",
- "#"+!(fl & ALT_FORM),
- "+"+!(fl & MARK_POS),
-@@ -341,6 +349,13 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
- for (; i<=NL_ARGMAX && !nl_type[i]; i++);
- if (i<=NL_ARGMAX) return -1;
- return 1;
-+
-+inval:
-+ errno = EINVAL;
-+ return -1;
-+overflow:
-+ errno = EOVERFLOW;
-+ return -1;
- }
-
- int vfwprintf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap)
---
-cgit v0.11.2
+++ /dev/null
-From 688d3da0f1730daddbc954bbc2d27cc96ceee04c Mon Sep 17 00:00:00 2001
-From: Szabolcs Nagy <nsz@port70.net>
-Date: Tue, 4 Oct 2016 03:58:56 +0200
-Subject: math: fix pow signed shift ub
-
-j is int32_t and thus j<<31 is undefined if j==1, so j is changed to
-uint32_t locally as a quick fix, the generated code is not affected.
-
-(this is a strict conformance fix, future c standard may allow 1<<31,
-see DR 463. the bug was inherited from freebsd fdlibm, the proper fix
-is to use uint32_t for all bit hacks, but that requires more intrusive
-changes.)
-
-reported by Daniel Sabogal
----
- src/math/pow.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/math/pow.c b/src/math/pow.c
-index b66f632..3ddc1b6 100644
---- a/src/math/pow.c
-+++ b/src/math/pow.c
-@@ -125,11 +125,11 @@ double pow(double x, double y)
- else if (iy >= 0x3ff00000) {
- k = (iy>>20) - 0x3ff; /* exponent */
- if (k > 20) {
-- j = ly>>(52-k);
-+ uint32_t j = ly>>(52-k);
- if ((j<<(52-k)) == ly)
- yisint = 2 - (j&1);
- } else if (ly == 0) {
-- j = iy>>(20-k);
-+ uint32_t j = iy>>(20-k);
- if ((j<<(20-k)) == iy)
- yisint = 2 - (j&1);
- }
---
-cgit v0.11.2
+++ /dev/null
-From 3ca2d2d4aef910663785fe232d7d2127a22d8a84 Mon Sep 17 00:00:00 2001
-From: Daniel Sabogal <dsabogalcc@gmail.com>
-Date: Sat, 17 Sep 2016 12:05:45 -0400
-Subject: fix clock_nanosleep error case
-
-posix requires that EINVAL be returned if the first parameter specifies
-the cpu-time clock of the calling thread (CLOCK_THREAD_CPUTIME_ID).
-linux returns ENOTSUP instead so we handle this.
----
- src/time/clock_nanosleep.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/src/time/clock_nanosleep.c b/src/time/clock_nanosleep.c
-index ec87b9e..9e4d9f1 100644
---- a/src/time/clock_nanosleep.c
-+++ b/src/time/clock_nanosleep.c
-@@ -1,8 +1,10 @@
- #include <time.h>
-+#include <errno.h>
- #include "syscall.h"
- #include "libc.h"
-
- int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem)
- {
-- return -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
-+ int r = -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
-+ return clk == CLOCK_THREAD_CPUTIME_ID ? EINVAL : r;
- }
---
-cgit v0.11.2
+++ /dev/null
-From 8fb28b0b3e7a5e958fb844722a4b2ef9bc244af1 Mon Sep 17 00:00:00 2001
-From: Felix Janda <felix.janda@posteo.de>
-Date: Fri, 16 Sep 2016 20:54:00 -0400
-Subject: add pthread_setname_np
-
-the thread name is displayed by gdb's "info threads".
----
- include/pthread.h | 1 +
- src/thread/pthread_setname_np.c | 26 ++++++++++++++++++++++++++
- 2 files changed, 27 insertions(+)
- create mode 100644 src/thread/pthread_setname_np.c
-
-diff --git a/include/pthread.h b/include/pthread.h
-index 3d2e0c4..94ef919 100644
---- a/include/pthread.h
-+++ b/include/pthread.h
-@@ -214,6 +214,7 @@ struct cpu_set_t;
- int pthread_getaffinity_np(pthread_t, size_t, struct cpu_set_t *);
- int pthread_setaffinity_np(pthread_t, size_t, const struct cpu_set_t *);
- int pthread_getattr_np(pthread_t, pthread_attr_t *);
-+int pthread_setname_np(pthread_t, const char *);
- int pthread_tryjoin_np(pthread_t, void **);
- int pthread_timedjoin_np(pthread_t, void **, const struct timespec *);
- #endif
-diff --git a/src/thread/pthread_setname_np.c b/src/thread/pthread_setname_np.c
-new file mode 100644
-index 0000000..82d35e1
---- /dev/null
-+++ b/src/thread/pthread_setname_np.c
-@@ -0,0 +1,26 @@
-+#define _GNU_SOURCE
-+#include <fcntl.h>
-+#include <string.h>
-+#include <unistd.h>
-+#include <sys/prctl.h>
-+
-+#include "pthread_impl.h"
-+
-+int pthread_setname_np(pthread_t thread, const char *name)
-+{
-+ int fd, cs, status = 0;
-+ char f[sizeof "/proc/self/task//comm" + 3*sizeof(int)];
-+ size_t len;
-+
-+ if ((len = strnlen(name, 16)) > 15) return ERANGE;
-+
-+ if (thread == pthread_self())
-+ return prctl(PR_SET_NAME, (unsigned long)name, 0UL, 0UL, 0UL) ? errno : 0;
-+
-+ snprintf(f, sizeof f, "/proc/self/task/%d/comm", thread->tid);
-+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-+ if ((fd = open(f, O_WRONLY)) < 0 || write(fd, name, len) < 0) status = errno;
-+ if (fd >= 0) close(fd);
-+ pthread_setcancelstate(cs, 0);
-+ return status;
-+}
---
-cgit v0.11.2
+++ /dev/null
-From 51ab6db4ed115d079d7131975e4adb074ba9ef9d Mon Sep 17 00:00:00 2001
-From: Szabolcs Nagy <nsz@port70.net>
-Date: Wed, 12 Oct 2016 00:49:59 +0200
-Subject: fix float formatting of some exact halfway cases
-
-in nearest rounding mode exact halfway cases were not following the
-round to even rule if the rounding happened at a base 1000000000 digit
-boundary of the internal representation and the previous digit was odd.
-
-e.g. printf("%.0f", 1.5) printed 1 instead of 2.
----
- src/stdio/vfprintf.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
-index e2ab2dc..60da14d 100644
---- a/src/stdio/vfprintf.c
-+++ b/src/stdio/vfprintf.c
-@@ -345,7 +345,8 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t)
- if (x || d+1!=z) {
- long double round = 2/LDBL_EPSILON;
- long double small;
-- if (*d/i & 1) round += 2;
-+ if ((*d/i & 1) || (i==1000000000 && d>a && (d[-1]&1)))
-+ round += 2;
- if (x<i/2) small=0x0.8p0;
- else if (x==i/2 && d+1==z) small=0x1.0p0;
- else small=0x1.8p0;
---
-cgit v0.11.2
+++ /dev/null
-From b24f1d2520c87077cef21e085893e5f3c565a6df Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Thu, 20 Oct 2016 12:13:33 -0400
-Subject: fix getopt_long_only misinterpreting "--" as an option
-
----
- src/misc/getopt_long.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/misc/getopt_long.c b/src/misc/getopt_long.c
-index 480c001..c6e1462 100644
---- a/src/misc/getopt_long.c
-+++ b/src/misc/getopt_long.c
-@@ -53,7 +53,7 @@ static int __getopt_long_core(int argc, char *const *argv, const char *optstring
- {
- optarg = 0;
- if (longopts && argv[optind][0] == '-' &&
-- ((longonly && argv[optind][1]) ||
-+ ((longonly && argv[optind][1] && argv[optind][1] != '-') ||
- (argv[optind][1] == '-' && argv[optind][2])))
- {
- int colon = optstring[optstring[0]=='+'||optstring[0]=='-']==':';
---
-cgit v0.11.2
+++ /dev/null
-From f33b17585058381491e6fda08f491b8e48c7980c Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Thu, 20 Oct 2016 13:22:20 -0400
-Subject: fix gratuitous undefined behavior in strptime
-
-accessing an object of type const char *restrict as if it had type
-char * is not defined.
----
- src/time/strptime.c | 9 +++++++--
- 1 file changed, 7 insertions(+), 2 deletions(-)
-
-diff --git a/src/time/strptime.c b/src/time/strptime.c
-index f41f55f..55c7ed1 100644
---- a/src/time/strptime.c
-+++ b/src/time/strptime.c
-@@ -22,8 +22,13 @@ char *strptime(const char *restrict s, const char *restrict f, struct tm *restri
- }
- f++;
- if (*f == '+') f++;
-- if (isdigit(*f)) w=strtoul(f, (void *)&f, 10);
-- else w=-1;
-+ if (isdigit(*f)) {
-+ char *new_f;
-+ w=strtoul(f, &new_f, 10);
-+ f = new_f;
-+ } else {
-+ w=-1;
-+ }
- adj=0;
- switch (*f++) {
- case 'a': case 'A':
---
-cgit v0.11.2
+++ /dev/null
-From d184a09e0529f33d8ddddb8825039133483a2c41 Mon Sep 17 00:00:00 2001
-From: Szabolcs Nagy <nsz@port70.net>
-Date: Sun, 4 Sep 2016 04:46:00 +0200
-Subject: fix strtod and strtof rounding with many trailing zeros
-
-in certain cases excessive trailing zeros could cause incorrect
-rounding from long double to double or float in decfloat.
-
-e.g. in strtof("9444733528689243848704.000000", 0) the argument
-is 0x1.000001p+73, exactly halfway between two representible floats,
-this incorrectly got rounded to 0x1.000002p+73 instead of 0x1p+73,
-but with less trailing 0 the rounding was fine.
-
-the fix makes sure that the z index always points one past the last
-non-zero digit in the base 10^9 representation, this way trailing
-zeros don't affect the rounding logic.
----
- src/internal/floatscan.c | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/src/internal/floatscan.c b/src/internal/floatscan.c
-index eef70df..80305ee 100644
---- a/src/internal/floatscan.c
-+++ b/src/internal/floatscan.c
-@@ -172,6 +172,9 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po
- return sign * (long double)x[0] * p10s[rp-10];
- }
-
-+ /* Drop trailing zeros */
-+ for (; !x[z-1]; z--);
-+
- /* Align radix point to B1B digit boundary */
- if (rp % 9) {
- int rpm9 = rp>=0 ? rp%9 : rp%9+9;
---
-cgit v0.11.2
+++ /dev/null
-From 6ffdc4579ffb34f4aab69ab4c081badabc7c0a9a Mon Sep 17 00:00:00 2001
-From: Szabolcs Nagy <nsz@port70.net>
-Date: Sun, 4 Sep 2016 04:51:03 +0200
-Subject: fix strtod int optimization in non-nearest rounding mode
-
-the mid-sized integer optimization relies on lnz set up properly
-to mark the last non-zero decimal digit, but this was not done
-if the non-zero digit lied outside the KMAX digits of the base
-10^9 number representation.
-
-so if the fractional part was a very long list of zeros (>2048*9 on
-x86) followed by non-zero digits then the integer optimization could
-kick in discarding the tiny non-zero fraction which can mean wrong
-result on non-nearest rounding mode.
-
-strtof, strtod and strtold were all affected.
----
- src/internal/floatscan.c | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/src/internal/floatscan.c b/src/internal/floatscan.c
-index 80305ee..ae09852 100644
---- a/src/internal/floatscan.c
-+++ b/src/internal/floatscan.c
-@@ -110,7 +110,10 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po
- gotdig=1;
- } else {
- dc++;
-- if (c!='0') x[KMAX-4] |= 1;
-+ if (c!='0') {
-+ lnz = (KMAX-4)*9;
-+ x[KMAX-4] |= 1;
-+ }
- }
- }
- if (!gotrad) lrp=dc;
---
-cgit v0.11.2
+++ /dev/null
-From bc1e7731cee963e422575f81048792f4d5db9641 Mon Sep 17 00:00:00 2001
-From: Daniel Sabogal <dsabogal@ufl.edu>
-Date: Wed, 2 Nov 2016 22:29:36 -0400
-Subject: fix integer overflow of tm_year in __secs_to_tm
-
-the overflow check for years+100 did not account for the extra
-year computed from the remaining months. instead, perform this
-check after obtaining the final number of years.
----
- src/time/__secs_to_tm.c | 9 +++++----
- 1 file changed, 5 insertions(+), 4 deletions(-)
-
-diff --git a/src/time/__secs_to_tm.c b/src/time/__secs_to_tm.c
-index 3a3123a..093d902 100644
---- a/src/time/__secs_to_tm.c
-+++ b/src/time/__secs_to_tm.c
-@@ -60,15 +60,16 @@ int __secs_to_tm(long long t, struct tm *tm)
- for (months=0; days_in_month[months] <= remdays; months++)
- remdays -= days_in_month[months];
-
-+ if (months >= 10) {
-+ months -= 12;
-+ years++;
-+ }
-+
- if (years+100 > INT_MAX || years+100 < INT_MIN)
- return -1;
-
- tm->tm_year = years + 100;
- tm->tm_mon = months + 2;
-- if (tm->tm_mon >= 12) {
-- tm->tm_mon -=12;
-- tm->tm_year++;
-- }
- tm->tm_mday = remdays + 1;
- tm->tm_wday = wday;
- tm->tm_yday = yday;
---
-cgit v0.11.2
+++ /dev/null
-From 7442442ccc665641a8827177e8e7ed45bbbd6584 Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Mon, 7 Nov 2016 20:39:59 -0500
-Subject: fix swprintf internal buffer state and error handling
-
-the swprintf write callback never reset its buffer pointers, so after
-its 256-byte buffer filled up, it would keep repeating those bytes
-over and over in the output until the destination buffer filled up. it
-also failed to set the error indicator for the stream on EILSEQ,
-potentially allowing output to continue after the error.
----
- src/stdio/vswprintf.c | 9 ++++++++-
- 1 file changed, 8 insertions(+), 1 deletion(-)
-
-diff --git a/src/stdio/vswprintf.c b/src/stdio/vswprintf.c
-index 7d237ba..6eb2f6a 100644
---- a/src/stdio/vswprintf.c
-+++ b/src/stdio/vswprintf.c
-@@ -24,7 +24,14 @@ static size_t sw_write(FILE *f, const unsigned char *s, size_t l)
- c->ws++;
- }
- *c->ws = 0;
-- return i<0 ? i : l0;
-+ if (i < 0) {
-+ f->wpos = f->wbase = f->wend = 0;
-+ f->flags |= F_ERR;
-+ return i;
-+ }
-+ f->wend = f->buf + f->buf_size;
-+ f->wpos = f->wbase = f->buf;
-+ return l0;
- }
-
- int vswprintf(wchar_t *restrict s, size_t n, const wchar_t *restrict fmt, va_list ap)
---
-cgit v0.11.2
+++ /dev/null
-From 4078a5c31fa67987051c2180db7a07702534032f Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Tue, 8 Nov 2016 18:03:42 -0500
-Subject: fix build regression on archs with variable page size
-
-commit 31fb174dd295e50f7c5cf18d31fcfd5fe5a063b7 used
-DEFAULT_GUARD_SIZE from pthread_impl.h in a static initializer,
-breaking build on archs where its definition, PAGE_SIZE, is not a
-constant. instead, just define DEFAULT_GUARD_SIZE as 4096, the minimal
-page size on any arch we support. pthread_create rounds up to whole
-pages anyway, so defining it to 1 would also work, but a moderately
-meaningful value is nicer to programs that use
-pthread_attr_getguardsize on default-initialized attribute objects.
----
- src/internal/pthread_impl.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
-index 3890bb5..7a679db 100644
---- a/src/internal/pthread_impl.h
-+++ b/src/internal/pthread_impl.h
-@@ -143,7 +143,7 @@ void __block_app_sigs(void *);
- void __restore_sigs(void *);
-
- #define DEFAULT_STACK_SIZE 81920
--#define DEFAULT_GUARD_SIZE PAGE_SIZE
-+#define DEFAULT_GUARD_SIZE 4096
-
- #define __ATTRP_C11_THREAD ((void*)(uintptr_t)-1)
-
---
-cgit v0.11.2
+++ /dev/null
-From e6683d001a95d7c3d4d992496f00f77e01fcd268 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@hauke-m.de>
-Date: Sun, 22 Nov 2015 15:04:23 +0100
-Subject: [PATCH v2] Add format attribute to some function declarations
-
-GCC and Clang are able to check the format arguments given to a
-function and warn the user if there is a error in the format arguments
-or if there is a potential uncontrolled format string security problem
-in the code. GCC does this automatically for some functions like
-printf(), but it is also possible to annotate other functions in a way
-that it will check them too. This feature is used by glibc for many
-functions. This patch adds the attribute to the some functions of musl
-expect for these functions where gcc automatically adds it.
-
-GCC automatically adds checks for these functions: printf, fprintf,
-sprintf, scanf, fscanf, sscanf, strftime, vprintf, vfprintf and
-vsprintf.
-
-The documentation from gcc is here:
-https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
-
-The documentation from Clang is here:
-http://clang.llvm.org/docs/AttributeReference.html#format-gnu-format
-
-Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
----
- include/err.h | 26 +++++++++++++++++---------
- include/monetary.h | 12 ++++++++++--
- include/stdio.h | 29 ++++++++++++++++++++---------
- include/syslog.h | 12 ++++++++++--
- 4 files changed, 57 insertions(+), 22 deletions(-)
-
---- a/include/err.h
-+++ b/include/err.h
-@@ -8,15 +8,23 @@
- extern "C" {
- #endif
-
--void warn(const char *, ...);
--void vwarn(const char *, va_list);
--void warnx(const char *, ...);
--void vwarnx(const char *, va_list);
-+#if __GNUC__ >= 3
-+#define __fp(x, y) __attribute__ ((__format__ (__printf__, x, y)))
-+#else
-+#define __fp(x, y)
-+#endif
-
--_Noreturn void err(int, const char *, ...);
--_Noreturn void verr(int, const char *, va_list);
--_Noreturn void errx(int, const char *, ...);
--_Noreturn void verrx(int, const char *, va_list);
-+void warn(const char *, ...) __fp(1, 2);
-+void vwarn(const char *, va_list) __fp(1, 0);
-+void warnx(const char *, ...) __fp(1, 2);
-+void vwarnx(const char *, va_list) __fp(1, 0);
-+
-+_Noreturn void err(int, const char *, ...) __fp(2, 3);
-+_Noreturn void verr(int, const char *, va_list) __fp(2, 0);
-+_Noreturn void errx(int, const char *, ...) __fp(2, 3);
-+_Noreturn void verrx(int, const char *, va_list) __fp(2, 0);
-+
-+#undef __fp
-
- #ifdef __cplusplus
- }
---- a/include/monetary.h
-+++ b/include/monetary.h
-@@ -13,8 +13,16 @@ extern "C" {
-
- #include <bits/alltypes.h>
-
--ssize_t strfmon(char *__restrict, size_t, const char *__restrict, ...);
--ssize_t strfmon_l(char *__restrict, size_t, locale_t, const char *__restrict, ...);
-+#if __GNUC__ >= 3
-+#define __fsfm(x, y) __attribute__ ((__format__ (__strfmon__, x, y)))
-+#else
-+#define __fsfm(x, y)
-+#endif
-+
-+ssize_t strfmon(char *__restrict, size_t, const char *__restrict, ...) __fsfm(3, 4);
-+ssize_t strfmon_l(char *__restrict, size_t, locale_t, const char *__restrict, ...) __fsfm(4, 5);
-+
-+#undef __fsfm
-
- #ifdef __cplusplus
- }
---- a/include/stdio.h
-+++ b/include/stdio.h
-@@ -21,6 +21,14 @@ extern "C" {
-
- #include <bits/alltypes.h>
-
-+#if __GNUC__ >= 3
-+#define __fp(x, y) __attribute__ ((__format__ (__printf__, x, y)))
-+#define __fs(x, y) __attribute__ ((__format__ (__scanf__, x, y)))
-+#else
-+#define __fp(x, y)
-+#define __fs(x, y)
-+#endif
-+
- #ifdef __cplusplus
- #define NULL 0L
- #else
-@@ -102,19 +110,19 @@ int puts(const char *);
- int printf(const char *__restrict, ...);
- int fprintf(FILE *__restrict, const char *__restrict, ...);
- int sprintf(char *__restrict, const char *__restrict, ...);
--int snprintf(char *__restrict, size_t, const char *__restrict, ...);
-+int snprintf(char *__restrict, size_t, const char *__restrict, ...) __fp(3, 4);
-
- int vprintf(const char *__restrict, __isoc_va_list);
- int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list);
- int vsprintf(char *__restrict, const char *__restrict, __isoc_va_list);
--int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list);
-+int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list) __fp(3, 0);
-
- int scanf(const char *__restrict, ...);
- int fscanf(FILE *__restrict, const char *__restrict, ...);
- int sscanf(const char *__restrict, const char *__restrict, ...);
--int vscanf(const char *__restrict, __isoc_va_list);
--int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list);
--int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list);
-+int vscanf(const char *__restrict, __isoc_va_list) __fs(1, 0);
-+int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list) __fs(2, 0);
-+int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list) __fs(2, 0);
-
- void perror(const char *);
-
-@@ -135,8 +143,8 @@ int pclose(FILE *);
- int fileno(FILE *);
- int fseeko(FILE *, off_t, int);
- off_t ftello(FILE *);
--int dprintf(int, const char *__restrict, ...);
--int vdprintf(int, const char *__restrict, __isoc_va_list);
-+int dprintf(int, const char *__restrict, ...) __fp(2, 3);
-+int vdprintf(int, const char *__restrict, __isoc_va_list) __fp(2, 0);
- void flockfile(FILE *);
- int ftrylockfile(FILE *);
- void funlockfile(FILE *);
-@@ -175,8 +183,8 @@ int fileno_unlocked(FILE *);
- int getw(FILE *);
- int putw(int, FILE *);
- char *fgetln(FILE *, size_t *);
--int asprintf(char **, const char *, ...);
--int vasprintf(char **, const char *, __isoc_va_list);
-+int asprintf(char **, const char *, ...) __fp(2, 3);
-+int vasprintf(char **, const char *, __isoc_va_list) __fp(2, 0);
- #endif
-
- #ifdef _GNU_SOURCE
-@@ -184,6 +192,9 @@ char *fgets_unlocked(char *, int, FILE *
- int fputs_unlocked(const char *, FILE *);
- #endif
-
-+#undef __fp
-+#undef __fs
-+
- #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
- #define tmpfile64 tmpfile
- #define fopen64 fopen
---- a/include/syslog.h
-+++ b/include/syslog.h
-@@ -56,16 +56,22 @@ extern "C" {
- #define LOG_NOWAIT 0x10
- #define LOG_PERROR 0x20
-
-+#if __GNUC__ >= 3
-+#define __fp(x, y) __attribute__ ((__format__ (__printf__, x, y)))
-+#else
-+#define __fp(x, y)
-+#endif
-+
- void closelog (void);
- void openlog (const char *, int, int);
- int setlogmask (int);
--void syslog (int, const char *, ...);
-+void syslog (int, const char *, ...) __fp(2, 3);
-
- #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
- #define _PATH_LOG "/dev/log"
- #define __NEED_va_list
- #include <bits/alltypes.h>
--void vsyslog (int, const char *, va_list);
-+void vsyslog (int, const char *, va_list) __fp(2, 0);
- #if defined(SYSLOG_NAMES)
- #define INTERNAL_NOPRI 0x10
- #define INTERNAL_MARK (LOG_NFACILITIES<<3)
-@@ -93,6 +99,8 @@ typedef struct {
- #endif
- #endif
-
-+#undef __fp
-+
- #ifdef __cplusplus
- }
- #endif
--- /dev/null
+From e6683d001a95d7c3d4d992496f00f77e01fcd268 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sun, 22 Nov 2015 15:04:23 +0100
+Subject: [PATCH v2] Add format attribute to some function declarations
+
+GCC and Clang are able to check the format arguments given to a
+function and warn the user if there is a error in the format arguments
+or if there is a potential uncontrolled format string security problem
+in the code. GCC does this automatically for some functions like
+printf(), but it is also possible to annotate other functions in a way
+that it will check them too. This feature is used by glibc for many
+functions. This patch adds the attribute to the some functions of musl
+expect for these functions where gcc automatically adds it.
+
+GCC automatically adds checks for these functions: printf, fprintf,
+sprintf, scanf, fscanf, sscanf, strftime, vprintf, vfprintf and
+vsprintf.
+
+The documentation from gcc is here:
+https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
+
+The documentation from Clang is here:
+http://clang.llvm.org/docs/AttributeReference.html#format-gnu-format
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ include/err.h | 26 +++++++++++++++++---------
+ include/monetary.h | 12 ++++++++++--
+ include/stdio.h | 29 ++++++++++++++++++++---------
+ include/syslog.h | 12 ++++++++++--
+ 4 files changed, 57 insertions(+), 22 deletions(-)
+
+--- a/include/err.h
++++ b/include/err.h
+@@ -8,15 +8,23 @@
+ extern "C" {
+ #endif
+
+-void warn(const char *, ...);
+-void vwarn(const char *, va_list);
+-void warnx(const char *, ...);
+-void vwarnx(const char *, va_list);
++#if __GNUC__ >= 3
++#define __fp(x, y) __attribute__ ((__format__ (__printf__, x, y)))
++#else
++#define __fp(x, y)
++#endif
+
+-_Noreturn void err(int, const char *, ...);
+-_Noreturn void verr(int, const char *, va_list);
+-_Noreturn void errx(int, const char *, ...);
+-_Noreturn void verrx(int, const char *, va_list);
++void warn(const char *, ...) __fp(1, 2);
++void vwarn(const char *, va_list) __fp(1, 0);
++void warnx(const char *, ...) __fp(1, 2);
++void vwarnx(const char *, va_list) __fp(1, 0);
++
++_Noreturn void err(int, const char *, ...) __fp(2, 3);
++_Noreturn void verr(int, const char *, va_list) __fp(2, 0);
++_Noreturn void errx(int, const char *, ...) __fp(2, 3);
++_Noreturn void verrx(int, const char *, va_list) __fp(2, 0);
++
++#undef __fp
+
+ #ifdef __cplusplus
+ }
+--- a/include/monetary.h
++++ b/include/monetary.h
+@@ -13,8 +13,16 @@ extern "C" {
+
+ #include <bits/alltypes.h>
+
+-ssize_t strfmon(char *__restrict, size_t, const char *__restrict, ...);
+-ssize_t strfmon_l(char *__restrict, size_t, locale_t, const char *__restrict, ...);
++#if __GNUC__ >= 3
++#define __fsfm(x, y) __attribute__ ((__format__ (__strfmon__, x, y)))
++#else
++#define __fsfm(x, y)
++#endif
++
++ssize_t strfmon(char *__restrict, size_t, const char *__restrict, ...) __fsfm(3, 4);
++ssize_t strfmon_l(char *__restrict, size_t, locale_t, const char *__restrict, ...) __fsfm(4, 5);
++
++#undef __fsfm
+
+ #ifdef __cplusplus
+ }
+--- a/include/stdio.h
++++ b/include/stdio.h
+@@ -21,6 +21,14 @@ extern "C" {
+
+ #include <bits/alltypes.h>
+
++#if __GNUC__ >= 3
++#define __fp(x, y) __attribute__ ((__format__ (__printf__, x, y)))
++#define __fs(x, y) __attribute__ ((__format__ (__scanf__, x, y)))
++#else
++#define __fp(x, y)
++#define __fs(x, y)
++#endif
++
+ #ifdef __cplusplus
+ #define NULL 0L
+ #else
+@@ -102,19 +110,19 @@ int puts(const char *);
+ int printf(const char *__restrict, ...);
+ int fprintf(FILE *__restrict, const char *__restrict, ...);
+ int sprintf(char *__restrict, const char *__restrict, ...);
+-int snprintf(char *__restrict, size_t, const char *__restrict, ...);
++int snprintf(char *__restrict, size_t, const char *__restrict, ...) __fp(3, 4);
+
+ int vprintf(const char *__restrict, __isoc_va_list);
+ int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list);
+ int vsprintf(char *__restrict, const char *__restrict, __isoc_va_list);
+-int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list);
++int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list) __fp(3, 0);
+
+ int scanf(const char *__restrict, ...);
+ int fscanf(FILE *__restrict, const char *__restrict, ...);
+ int sscanf(const char *__restrict, const char *__restrict, ...);
+-int vscanf(const char *__restrict, __isoc_va_list);
+-int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list);
+-int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list);
++int vscanf(const char *__restrict, __isoc_va_list) __fs(1, 0);
++int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list) __fs(2, 0);
++int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list) __fs(2, 0);
+
+ void perror(const char *);
+
+@@ -135,8 +143,8 @@ int pclose(FILE *);
+ int fileno(FILE *);
+ int fseeko(FILE *, off_t, int);
+ off_t ftello(FILE *);
+-int dprintf(int, const char *__restrict, ...);
+-int vdprintf(int, const char *__restrict, __isoc_va_list);
++int dprintf(int, const char *__restrict, ...) __fp(2, 3);
++int vdprintf(int, const char *__restrict, __isoc_va_list) __fp(2, 0);
+ void flockfile(FILE *);
+ int ftrylockfile(FILE *);
+ void funlockfile(FILE *);
+@@ -175,8 +183,8 @@ int fileno_unlocked(FILE *);
+ int getw(FILE *);
+ int putw(int, FILE *);
+ char *fgetln(FILE *, size_t *);
+-int asprintf(char **, const char *, ...);
+-int vasprintf(char **, const char *, __isoc_va_list);
++int asprintf(char **, const char *, ...) __fp(2, 3);
++int vasprintf(char **, const char *, __isoc_va_list) __fp(2, 0);
+ #endif
+
+ #ifdef _GNU_SOURCE
+@@ -184,6 +192,9 @@ char *fgets_unlocked(char *, int, FILE *
+ int fputs_unlocked(const char *, FILE *);
+ #endif
+
++#undef __fp
++#undef __fs
++
+ #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+ #define tmpfile64 tmpfile
+ #define fopen64 fopen
+--- a/include/syslog.h
++++ b/include/syslog.h
+@@ -56,16 +56,22 @@ extern "C" {
+ #define LOG_NOWAIT 0x10
+ #define LOG_PERROR 0x20
+
++#if __GNUC__ >= 3
++#define __fp(x, y) __attribute__ ((__format__ (__printf__, x, y)))
++#else
++#define __fp(x, y)
++#endif
++
+ void closelog (void);
+ void openlog (const char *, int, int);
+ int setlogmask (int);
+-void syslog (int, const char *, ...);
++void syslog (int, const char *, ...) __fp(2, 3);
+
+ #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+ #define _PATH_LOG "/dev/log"
+ #define __NEED_va_list
+ #include <bits/alltypes.h>
+-void vsyslog (int, const char *, va_list);
++void vsyslog (int, const char *, va_list) __fp(2, 0);
+ #if defined(SYSLOG_NAMES)
+ #define INTERNAL_NOPRI 0x10
+ #define INTERNAL_MARK (LOG_NFACILITIES<<3)
+@@ -93,6 +99,8 @@ typedef struct {
+ #endif
+ #endif
+
++#undef __fp
++
+ #ifdef __cplusplus
+ }
+ #endif
+++ /dev/null
---- a/src/time/__tz.c
-+++ b/src/time/__tz.c
-@@ -87,7 +87,7 @@
- int i;
- if (**p == '<') {
- ++*p;
-- for (i=0; **p!='>' && i<TZNAME_MAX; i++)
-+ for (i=0; (*p)[i]!='>' && i<TZNAME_MAX; i++)
- d[i] = (*p)[i];
- ++*p;
- } else {
$(curdir)/e2fsprogs/compile := $(curdir)/libtool/install
$(curdir)/libelf/compile := $(curdir)/libtool/install
$(curdir)/sdcc/compile := $(curdir)/bison/install
+$(curdir)/b43-tools/compile := $(curdir)/bison/install
$(curdir)/padjffs2/compile := $(curdir)/findutils/install
$(curdir)/isl/compile := $(curdir)/gmp/install
$(curdir)/bc/compile := $(curdir)/bison/install
PKG_VERSION:=3.3.2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
-PKG_SOURCE_URL:=https://samba.org/ftp/ccache/
+PKG_SOURCE_URL:=https://download.samba.org/pub/ccache/ \
+ https://samba.org/ftp/ccache/
PKG_HASH:=907685cb23d8f82074b8d1a9b4ebabb36914d151ac7b96a840c68c08d1a14530
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/host-build.mk
-HOST_CONFIGURE_CMD := \
- MAKEFLAGS="$(HOST_JOBS)" $(BASH) ./configure
-
-HOST_CONFIGURE_VARS :=
+HOST_CONFIGURE_VARS += \
+ MAKEFLAGS="$(HOST_JOBS)" \
+ CXXFLAGS="$(HOST_CFLAGS)"
HOST_CONFIGURE_ARGS := \
+ $(if $(MAKE_JOBSERVER),--parallel="$(MAKE_JOBSERVER)") \
--prefix=$(STAGING_DIR_HOST)
+ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
+ HOST_MAKE_FLAGS += VERBOSE=1
+endif
+
$(eval $(call HostBuild))
--- /dev/null
+--- a/bootstrap
++++ b/bootstrap
+@@ -958,7 +958,10 @@ int main(){ printf("1%c", (char)0x0a); r
+ ' > "test.c"
+ cmake_original_make_flags="${cmake_make_flags}"
+ if [ "x${cmake_parallel_make}" != "x" ]; then
+- cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
++ case "$cmake_paralle_make" in
++ [0-9]*) cmake_parallel_make="-j ${cmake_parallel_make}";;
++ esac
++ cmake_make_flags="${cmake_make_flags} ${cmake_parallel_make}"
+ fi
+ for a in ${cmake_make_processors}; do
+ if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then
include $(TOPDIR)/rules.mk
PKG_NAME:=kernel2minor
-PKG_VERSION:=0.22
-PKG_RELEASE:=1
+PKG_VERSION:=0.24
+PKG_RELEASE:=3
-PKG_MIRROR_HASH:=8e509deb78e4eddc5f4d0798d3c5fbc99bf6dd151faaf0332a640607042d7f82
PKG_SOURCE_URL:=https://github.com/adron-s/kernel2minor.git
PKG_SOURCE_PROTO:=git
-PKG_SOURCE_VERSION:=0587740de3e398dbe89d965334c492609cb9739d
+PKG_SOURCE_VERSION:=2cacb4dec6673a60a972a3a7f7629464a26a8492
+PKG_HASH:=33ca413403a3341af0c9a8e6d9bb58f4ad080a5339e8a8729b83637d35bfaf1b
include $(INCLUDE_DIR)/host-build.mk
+++ /dev/null
---- a/yaffs2/yaffs_guts.h
-+++ b/yaffs2/yaffs_guts.h
-@@ -17,8 +17,9 @@
- #define __YAFFS_GUTS_H__
-
- #include "yportenv.h"
-+#include <stdint.h>
-
--typedef __loff_t loff_t;
-+typedef int64_t loff_t;
-
- #define YAFFS_OK 1
- #define YAFFS_FAIL 0
+++ /dev/null
---- a/k2m_biops.h
-+++ b/k2m_biops.h
-@@ -10,7 +10,9 @@
- */
-
- //нужна ли конвертация. устанавливавется автоматически в 1 для НЕ big_endian систем
--static int endian_need_conv = __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__;
-+static int big_endian;
-+
-+#define endian_need_conv (!!big_endian ^ (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
-
- /* конвертор из одного байтового порядка в обратный
- x обязательно должна быть переменной но не выражением !
---- a/kernel2minor.c
-+++ b/kernel2minor.c
-@@ -76,7 +76,7 @@ void print_help(void){
- char *usage[] =
- { "-k", "Path to kernel file", kernel_file,
- "-r", "Path to result file", res_file,
-- "-e", "Enable endian convert", endian_need_conv ? "Yes" : "No",
-+ "-e", "Enable endian convert to big-endian", big_endian ? "Yes" : "No",
- "-c", "Use ECC", use_ecc ? "Yes" : "No",
- "-s", "FLASH Unit(Chunk) size", chunk_size_str,
- "-i", "Add image info block", add_image_info_block ? info_block_size_str : "No",
-@@ -595,7 +595,7 @@ int main(int argc, char *argv[]){
- case 'k': snprintf(kernel_file, sizeof(kernel_file) - 1, "%s", optarg); break;
- case 'r': snprintf(res_file, sizeof(res_file) - 1, "%s", optarg); break;
- case 'c': use_ecc = 1; break;
-- case 'e': endian_need_conv = 1; break;
-+ case 'e': big_endian = 1; break;
- case 's': chunk_size = atoi(optarg); break;
- case 'i': add_image_info_block = 1; align_size = atoi(optarg); break;
- case 'p': strncpy(platform_name, optarg, sizeof(platform_name)); break;
+++ /dev/null
---- a/kernel2minor.c
-+++ b/kernel2minor.c
-@@ -622,7 +622,7 @@ int main(int argc, char *argv[]){
- perror("Can't open kernel file");
- exit(-1);
- }
-- r = creat(res_file, 0);
-+ r = open(res_file, O_CREAT | O_TRUNC | O_WRONLY, 0644);
- if(r <= 0){
- perror("Can't create result file");
- close(k);
search_space = dtb_max_size = atoi(argv[3]);
}
- fddtb = open(argv[1], O_RDONLY);
- if (!fddtb)
- goto err1;
-
if (stat(argv[2], &s)) {
fprintf(stderr, "DTB not found\n");
goto err1;
include $(INCLUDE_DIR)/host-build.mk
-HOST_CFLAGS += -I$(STAGING_DIR_HOST)/include/e2fsprogs
-
-define Host/Configure
- (cd $(HOST_BUILD_DIR); \
- CFLAGS="$(HOST_CFLAGS)" \
- LDFLAGS="$(HOST_LDFLAGS)" \
- $(HOST_CONFIGURE_CMD) \
- --extra-cflags="$(HOST_CFLAGS)" \
- --enable-uuid \
- )
-endef
+HOST_CFLAGS += \
+ -I$(STAGING_DIR_HOST)/include/e2fsprogs \
+ -DAES_cbc_encrypt=QEMU_AES_cbc_encrypt \
+ -DAES_decrypt=QEMU_AES_decrypt \
+ -DAES_encrypt=QEMU_AES_encrypt \
+ -DAES_set_decrypt_key=QEMU_AES_set_decrypt_key \
+ -DAES_set_encrypt_key=QEMU_AES_set_encrypt_key
+
+HOST_CONFIGURE_VARS := \
+ CFLAGS="$(HOST_CFLAGS)" \
+ LDFLAGS="$(HOST_LDFLAGS)"
+
+HOST_CONFIGURE_ARGS := \
+ --extra-cflags="$(HOST_CFLAGS)" \
+ --enable-uuid
define Host/Compile
$(MAKE) -C $(HOST_BUILD_DIR) qemu-img