aboutsummaryrefslogtreecommitdiffstats
path: root/package/system
diff options
context:
space:
mode:
Diffstat (limited to 'package/system')
-rw-r--r--package/system/ar7-atm/Config.in22
-rw-r--r--package/system/ar7-atm/Makefile100
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/100-compile_fix.patch768
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/110-interrupt_fix.patch37
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/120-no_dumb_inline.patch11
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/130-powercutback.patch44
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/140-debug_mode.patch16
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/150-tasklet_mode.patch11
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/160-module-params.patch589
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/170-bus_id_removal.patch30
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/180-git_headers_include.patch54
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/190-2.6.32_proc_fixes.patch79
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/200-2.6.37_args.patch36
-rw-r--r--package/system/ar7-atm/patches-D7.04.03.00/210-3.3-remove-smp_lock.h.patch33
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/100-compile_fix.patch808
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/110-interrupt_fix.patch37
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/120-no_dumb_inline.patch11
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/130-powercutback.patch44
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/140-debug_mode.patch16
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/150-tasklet_mode.patch11
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/160-module-params.patch675
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/170-bus_id_removal.patch30
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/180-git_headers_include.patch54
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/190-2.6.32_proc_fixes.patch79
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/200-2.6.37_args.patch36
-rw-r--r--package/system/ar7-atm/patches-D7.05.01.00/210-3.3-remove-smp_lock.h.patch33
-rw-r--r--package/system/avila-wdt/Makefile40
-rw-r--r--package/system/avila-wdt/src/Makefile1
-rw-r--r--package/system/avila-wdt/src/avila-wdt.c231
-rw-r--r--package/system/brcm2708-gpu-fw/Makefile44
-rw-r--r--package/system/button-hotplug/Makefile53
-rw-r--r--package/system/button-hotplug/src/Kconfig2
-rw-r--r--package/system/button-hotplug/src/Makefile1
-rw-r--r--package/system/button-hotplug/src/button-hotplug.c349
-rw-r--r--package/system/ep80579-drivers/Makefile92
-rw-r--r--package/system/ep80579-drivers/patches/001-igbe_update.patch11755
-rw-r--r--package/system/ep80579-drivers/patches/002-cflags_cleanup.patch22
-rw-r--r--package/system/ep80579-drivers/patches/003-new_irqf_constants.patch53
-rw-r--r--package/system/ep80579-drivers/patches/100-iegbe_netdev_ops.patch56
-rw-r--r--package/system/ep80579-drivers/patches/101-iegbe_fix_napi_interface.patch41
-rw-r--r--package/system/ep80579-drivers/patches/102-iegbe_nuke_polling_netdev.patch103
-rw-r--r--package/system/ep80579-drivers/patches/103-iegbe_convert_unicast_addr_list.patch60
-rw-r--r--package/system/ep80579-drivers/patches/104-iegbe_group_address_list_and_its_count.patch20
-rw-r--r--package/system/ep80579-drivers/patches/105-iegbe_new_dma_masks.patch20
-rw-r--r--package/system/ep80579-drivers/patches/106-iegbe_new_irqf_constant.patch12
-rw-r--r--package/system/ep80579-drivers/patches/150-ocracoke_island.patch747
-rw-r--r--package/system/ep80579-drivers/patches/200-can_fix_ioctl_numbers.patch11
-rw-r--r--package/system/ep80579-drivers/patches/210-can_include_linux_fs_h.patch11
-rw-r--r--package/system/ep80579-drivers/patches/220-can_fix_irq_request.patch23
-rw-r--r--package/system/ep80579-drivers/patches/230-can_remove_driver_data_direct_access.patch40
-rw-r--r--package/system/ep80579-drivers/patches/300-wdt_compile_fix.patch59
-rw-r--r--package/system/ep80579-drivers/patches/400-edma_fix_irq_request_warning.patch22
-rw-r--r--package/system/ep80579-drivers/patches/500-1588_fix_irq_request_warning.patch22
-rw-r--r--package/system/ep80579-drivers/patches/600-2.6.27_includes.patch22
-rw-r--r--package/system/ep80579-drivers/patches/601-2.6.32_includes.patch30
-rw-r--r--package/system/ep80579-drivers/patches/700-iegbe_kcompat_2.6.30.patch31
-rw-r--r--package/system/ep80579-drivers/patches/701-iegbe_poll_dev.patch11
-rw-r--r--package/system/ep80579-drivers/patches/710-3.3-fix-generated-header-locations.patch91
-rw-r--r--package/system/ep80579-drivers/patches/711-3.3-gbe-fixes.patch392
-rw-r--r--package/system/ep80579-drivers/patches/712-3.3-can-fixes.patch41
-rw-r--r--package/system/ep80579-drivers/patches/713-3.3-gpio-fixes.patch33
-rw-r--r--package/system/ep80579-drivers/patches/714-3.3-wdt-fixes.patch31
-rw-r--r--package/system/ep80579-drivers/patches/715-3.3-1588-fixes.patch33
-rw-r--r--package/system/gpio-button-hotplug/Makefile44
-rw-r--r--package/system/gpio-button-hotplug/src/Makefile1
-rw-r--r--package/system/gpio-button-hotplug/src/gpio-button-hotplug.c564
-rw-r--r--package/system/hostap-driver/Makefile117
-rwxr-xr-xpackage/system/hostap-driver/files/lib/wifi/hostap.sh270
-rw-r--r--package/system/hostap-driver/patches/001-fix-txpower.patch175
-rw-r--r--package/system/i2c-gpio-custom/Makefile53
-rw-r--r--package/system/i2c-gpio-custom/src/Kconfig10
-rw-r--r--package/system/i2c-gpio-custom/src/Makefile1
-rw-r--r--package/system/i2c-gpio-custom/src/i2c-gpio-custom.c198
-rw-r--r--package/system/mmc_over_gpio/Makefile77
-rw-r--r--package/system/mmc_over_gpio/files/mmc_over_gpio.config8
-rw-r--r--package/system/mmc_over_gpio/files/mmc_over_gpio.init83
-rw-r--r--package/system/mountd/Makefile47
-rw-r--r--package/system/mountd/files/mountd.config3
-rwxr-xr-xpackage/system/mountd/files/mountd.init19
-rw-r--r--package/system/mountd/patches/010-uci_rename_history_to_delta.patch27
-rw-r--r--package/system/mountd/patches/020-handle_timeout.patch32
-rw-r--r--package/system/mountd/patches/030-ext4_support.patch85
-rw-r--r--package/system/mountd/patches/040-optional-daemonize.patch13
-rw-r--r--package/system/mtd/Makefile53
-rw-r--r--package/system/mtd/src/Makefile18
-rw-r--r--package/system/mtd/src/crc32.c95
-rw-r--r--package/system/mtd/src/crc32.h26
-rw-r--r--package/system/mtd/src/fis.c262
-rw-r--r--package/system/mtd/src/fis.h14
-rw-r--r--package/system/mtd/src/imagetag.c316
-rw-r--r--package/system/mtd/src/jffs2.c357
-rw-r--r--package/system/mtd/src/jffs2.h216
-rw-r--r--package/system/mtd/src/md5.c307
-rw-r--r--package/system/mtd/src/md5.h65
-rw-r--r--package/system/mtd/src/mtd.c761
-rw-r--r--package/system/mtd/src/mtd.h29
-rw-r--r--package/system/mtd/src/seama.c179
-rw-r--r--package/system/mtd/src/seama.h108
-rw-r--r--package/system/mtd/src/trx.c220
-rw-r--r--package/system/om-watchdog/Makefile45
-rw-r--r--package/system/om-watchdog/files/om-watchdog15
-rw-r--r--package/system/om-watchdog/files/om-watchdog.init30
-rw-r--r--package/system/opkg/Makefile102
-rw-r--r--package/system/opkg/files/opkg.conf5
-rw-r--r--package/system/opkg/patches/001-ship-pkg-m4.patch168
-rw-r--r--package/system/opkg/patches/002-no-shave.patch37
-rw-r--r--package/system/opkg/patches/004-host_cpu.patch20
-rw-r--r--package/system/opkg/patches/007-force_static.patch71
-rw-r--r--package/system/opkg/patches/009-remove-upgrade-all.patch41
-rw-r--r--package/system/opkg/patches/011-old-config-location.patch12
-rw-r--r--package/system/opkg/patches/012-strip-trailing-conffiles-whitespace.patch23
-rw-r--r--package/system/opkg/patches/014-errors-to-stderr.patch15
-rw-r--r--package/system/opkg/patches/020-avoid_getline.patch317
-rw-r--r--package/system/opkg/patches/030-fix-double-free.patch10
-rw-r--r--package/system/opkg/patches/040-wrap-descriptions-only-on-ttys.patch31
-rw-r--r--package/system/opkg/patches/050-add-case-insensitive-flag.patch169
-rw-r--r--package/system/opkg/patches/060-add-find-command.patch58
-rw-r--r--package/system/opkg/patches/070-use_gzipped_pkg_list.patch120
-rw-r--r--package/system/procd/Makefile40
-rw-r--r--package/system/procd/files/hotplug-preinit.json20
-rw-r--r--package/system/procd/files/hotplug.json77
-rw-r--r--package/system/procd/files/procd.init19
-rw-r--r--package/system/procd/files/procd.sh171
-rw-r--r--package/system/rotary-gpio-custom/Makefile53
-rw-r--r--package/system/rotary-gpio-custom/src/Kconfig9
-rw-r--r--package/system/rotary-gpio-custom/src/Makefile1
-rw-r--r--package/system/rotary-gpio-custom/src/rotary-gpio-custom.c188
-rw-r--r--package/system/rtc-rv5c386a/Makefile38
-rw-r--r--package/system/rtc-rv5c386a/src/Makefile18
-rw-r--r--package/system/rtc-rv5c386a/src/rtc.c613
-rw-r--r--package/system/spi-ks8995/Makefile54
-rw-r--r--package/system/spi-ks8995/src/Kconfig3
-rw-r--r--package/system/spi-ks8995/src/Makefile1
-rw-r--r--package/system/spi-ks8995/src/spi_ks8995.c419
-rw-r--r--package/system/spidev_test/Makefile43
-rw-r--r--package/system/ubox/Makefile58
-rw-r--r--package/system/ubox/files/mount.hotplug1
-rw-r--r--package/system/ubus/Makefile84
-rwxr-xr-xpackage/system/ubus/files/ubus.init14
-rw-r--r--package/system/uci/Makefile92
-rw-r--r--package/system/uci/files/lib/config/uci.sh137
-rw-r--r--package/system/udev/Config.in118
-rw-r--r--package/system/udev/Makefile156
-rw-r--r--package/system/udev/patches/0001-build-don-t-use-gc-sections.patch31
-rw-r--r--package/system/udev/patches/0002-udevd-add-lrt-for-message-queue-symbols.patch25
-rw-r--r--package/system/udev/patches/0003-add_btn_trigger_happy_define.patch13
-rw-r--r--package/system/utils/e2fsprogs/Makefile169
-rw-r--r--package/system/utils/e2fsprogs/files/e2fsck.conf3
-rw-r--r--package/system/utils/e2fsprogs/files/e2fsck.sh38
-rw-r--r--package/system/utils/e2fsprogs/patches/001-link-against-libuuid.patch38
-rw-r--r--package/system/utils/e2fsprogs/patches/002-no_malloc_h.patch10
-rw-r--r--package/system/utils/fbtest/Makefile44
-rw-r--r--package/system/utils/fbtest/src/Makefile14
-rw-r--r--package/system/utils/fbtest/src/fbtest.c448
-rw-r--r--package/system/utils/hostap-utils/Makefile44
-rw-r--r--package/system/utils/nvram/Makefile60
-rwxr-xr-xpackage/system/utils/nvram/files/nvram.init98
-rw-r--r--package/system/utils/nvram/src/Makefile33
-rw-r--r--package/system/utils/nvram/src/cli.c246
-rw-r--r--package/system/utils/nvram/src/crc.c69
-rw-r--r--package/system/utils/nvram/src/nvram.c556
-rw-r--r--package/system/utils/nvram/src/nvram.h123
-rw-r--r--package/system/utils/nvram/src/sdinitvals.h30
-rw-r--r--package/system/utils/robocfg/Makefile39
-rw-r--r--package/system/utils/robocfg/src/Makefile11
-rw-r--r--package/system/utils/robocfg/src/etc53xx.h619
-rw-r--r--package/system/utils/robocfg/src/robocfg.c581
-rw-r--r--package/system/utils/usbmode/Makefile57
-rw-r--r--package/system/utils/usbmode/files/usbmode.hotplug7
-rw-r--r--package/system/utils/usbreset/Makefile44
-rw-r--r--package/system/utils/usbreset/src/usbreset.c253
-rw-r--r--package/system/utils/usbutils/Makefile57
-rw-r--r--package/system/utils/util-linux/Makefile594
-rw-r--r--package/system/utils/util-linux/patches/000-compile.patch44
-rw-r--r--package/system/utils/util-linux/patches/001-no-printf-alloc.patch108
-rw-r--r--package/system/utils/util-linux/patches/002-fix-endianess.patch13
-rw-r--r--package/system/utils/xfsprogs/Makefile87
-rw-r--r--package/system/utils/xfsprogs/patches/001-automake-compat.patch84
-rw-r--r--package/system/utils/xfsprogs/patches/100-no_aio.patch21
-rw-r--r--package/system/utils/xfsprogs/patches/110-uclibc_no_ustat.patch36
-rw-r--r--package/system/utils/xfsprogs/patches/120-portability.patch47
-rw-r--r--package/system/utils/xfsprogs/patches/130-uclibc_no_xattr.patch36
-rw-r--r--package/system/utils/xfsprogs/patches/140-no_po.patch20
-rw-r--r--package/system/w1-gpio-custom/Makefile54
-rw-r--r--package/system/w1-gpio-custom/src/Kconfig4
-rw-r--r--package/system/w1-gpio-custom/src/Makefile1
-rw-r--r--package/system/w1-gpio-custom/src/w1-gpio-custom.c185
-rw-r--r--package/system/wrt55agv2-spidevs/Makefile53
-rw-r--r--package/system/wrt55agv2-spidevs/src/Kconfig3
-rw-r--r--package/system/wrt55agv2-spidevs/src/Makefile1
-rw-r--r--package/system/wrt55agv2-spidevs/src/wrt55agv2_spidevs.c114
-rw-r--r--package/system/zram-swap/Makefile46
-rw-r--r--package/system/zram-swap/files/zram.init123
193 files changed, 5676 insertions, 26596 deletions
diff --git a/package/system/ar7-atm/Config.in b/package/system/ar7-atm/Config.in
deleted file mode 100644
index 479b7ad072..0000000000
--- a/package/system/ar7-atm/Config.in
+++ /dev/null
@@ -1,22 +0,0 @@
-menu "Configuration"
- depends on (PACKAGE_kmod-sangam-atm-annex-a || PACKAGE_kmod-sangam-atm-annex-b)
-
-choice
- prompt "Firmware version"
- default AR7_ATM_FW_VERSION_704
- help
- This option allows you to switch between firmware/driver versions which
- might improve the DSL line speed.
-
-config AR7_ATM_FW_VERSION_705
- bool "D7.05.01.00"
-
-config AR7_ATM_FW_VERSION_704
- bool "D7.04.03.00"
-
-config AR7_ATM_FW_VERSION_703
- bool "D7.03.01.00"
-
-endchoice
-
-endmenu
diff --git a/package/system/ar7-atm/Makefile b/package/system/ar7-atm/Makefile
deleted file mode 100644
index 59e9e79183..0000000000
--- a/package/system/ar7-atm/Makefile
+++ /dev/null
@@ -1,100 +0,0 @@
-#
-# Copyright (C) 2006-2009 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:=sangam_atm
-
-ifeq ($(CONFIG_AR7_ATM_FW_VERSION_705),y)
-PKG_VERSION:=D7.05.01.00
-PKG_MD5SUM:=42ee465be5cfbe9476fc25deb260d450
-PKG_RELEASE:=R1
-PATCH_DIR:=patches-$(PKG_VERSION)
-endif
-
-ifeq ($(CONFIG_AR7_ATM_FW_VERSION_704),y)
-PKG_VERSION:=D7.04.03.00
-PKG_MD5SUM:=3d76004e46f09e88931f91670cb420ad
-PKG_RELEASE:=R1
-PATCH_DIR:=patches-$(PKG_VERSION)
-endif
-
-ifeq ($(CONFIG_AR7_ATM_FW_VERSION_703),y)
-PKG_VERSION:=D7.03.01.00
-PKG_MD5SUM:=bc6e9c6adb1be25820c7ee661de8ca7d
-PKG_RELEASE:=R2
-PATCH_DIR:=patches-D7.04.03.00
-endif
-
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE).tar.bz2
-PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/sangam-atm/Default
- SUBMENU:=Network Devices
- DEPENDS:=@TARGET_ar7_generic +kmod-atm
- TITLE:=AR7 ADSL driver
- FILES:=$(PKG_BUILD_DIR)/tiatm.ko
- AUTOLOAD:=$(call AutoLoad,50,tiatm)
- MAINTAINER:=Florian Fainelli <florian@openwrt.org>
- MENU:=1
-endef
-
-define KernelPackage/sangam-atm/config
- source "$(SOURCE)/Config.in"
-endef
-
-define KernelPackage/sangam-atm-annex-a
-$(call KernelPackage/sangam-atm/Default)
- TITLE+= (Annex A, ADSL over POTS)
-endef
-
-define KernelPackage/sangam-atm-annex-a/description
- The AR7 ADSL driver for Annex A (ADSL over POTS).
-endef
-
-define KernelPackage/sangam-atm-annex-a/config
-$(call KernelPackage/sangam-atm/config)
-endef
-
-define KernelPackage/sangam-atm-annex-b
-$(call KernelPackage/sangam-atm/Default)
- TITLE+= (Annex B, ADSL over ISDN)
-endef
-
-define KernelPackage/sangam-atm-annex-b/description
- The AR7 ADSL driver for Annex B (ADSL over ISDN).
-endef
-
-define KernelPackage/sangam-atm-annex-a/config
-$(call KernelPackage/sangam-atm/config)
-endef
-
-define Build/Compile
- $(MAKE) -C "$(LINUX_DIR)" \
- CROSS_COMPILE="$(TARGET_CROSS)" \
- ARCH="$(LINUX_KARCH)" \
- SUBDIRS="$(PKG_BUILD_DIR)" \
- modules
-endef
-
-define KernelPackage/sangam-atm-annex-a/install
- mkdir -p $(1)/lib/firmware
- $(INSTALL_DATA) $(PKG_BUILD_DIR)/ar0700mp.bin $(1)/lib/firmware/
- ln -sf ar0700mp.bin $(1)/lib/firmware/ar0700xx.bin
-endef
-
-define KernelPackage/sangam-atm-annex-b/install
- mkdir -p $(1)/lib/firmware
- $(INSTALL_DATA) $(PKG_BUILD_DIR)/ar0700db.bin $(1)/lib/firmware/
- ln -sf ar0700db.bin $(1)/lib/firmware/ar0700xx.bin
-endef
-
-$(eval $(call KernelPackage,sangam-atm-annex-a))
-$(eval $(call KernelPackage,sangam-atm-annex-b))
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/100-compile_fix.patch b/package/system/ar7-atm/patches-D7.04.03.00/100-compile_fix.patch
deleted file mode 100644
index df5fe53967..0000000000
--- a/package/system/ar7-atm/patches-D7.04.03.00/100-compile_fix.patch
+++ /dev/null
@@ -1,768 +0,0 @@
---- a/cppi_cpaal5.c
-+++ b/cppi_cpaal5.c
-@@ -352,7 +352,7 @@ static int halRxReturn(HAL_RECEIVEINFO *
- {
- /* malloc failed, add this RCB to Needs Buffer List */
- TempRcb->FragCount = 1; /*MJH+030417*/
-- (HAL_RCB *)TempRcb->Eop = TempRcb; /* GSG +030430 */
-+ TempRcb->Eop = TempRcb; /* GSG +030430 */
-
- if(HalDev->NeedsCount < MAX_NEEDS) /* +MJH 030410 */
- { /* +MJH 030410 */
---- a/dsl_hal_api.c
-+++ b/dsl_hal_api.c
-@@ -254,15 +254,15 @@
- * of phyEnableDisableWord & phyControlWord to avoid changing API struct
- * which may cause change required to application data structure.
- ******************************************************************************/
--#include <dev_host_interface.h>
--#include <dsl_hal_register.h>
--#include <dsl_hal_support.h>
-+#include "dev_host_interface.h"
-+#include "dsl_hal_register.h"
-+#include "dsl_hal_support.h"
-
- #ifndef NO_ADV_STATS
--#include <dsl_hal_logtable.h>
-+#include "dsl_hal_logtable.h"
- #endif
-
--#include <dsl_hal_version.h>
-+#include "dsl_hal_version.h"
-
- // UR8_MERGE_START CQ11054 Jack Zhang
- static unsigned int highprecision_selected = 0; //By default we use low precision for backward compt.
---- a/dsl_hal_support.c
-+++ b/dsl_hal_support.c
-@@ -140,9 +140,9 @@
- * oamFeature are overriden
- // UR8_MERGE_END CQ10774 Ram
- *******************************************************************************/
--#include <dev_host_interface.h>
--#include <dsl_hal_register.h>
--#include <dsl_hal_support.h>
-+#include "dev_host_interface.h"
-+#include "dsl_hal_register.h"
-+#include "dsl_hal_support.h"
-
- #define NUM_READ_RETRIES 3
- static unsigned int dslhal_support_adsl2ByteSwap32(unsigned int in32Bits);
---- a/dsl_hal_support.h
-+++ b/dsl_hal_support.h
-@@ -49,7 +49,7 @@
- * 04Nov05 0.11.00 CPH Fixed T1413 mode got Zero DS/US rate when DSL_BIT_TMODE is set.
- *******************************************************************************/
-
--#include <dsl_hal_api.h>
-+#include "dsl_hal_api.h"
-
- #define virtual2Physical(a) (((int)a)&~0xe0000000)
- /* External Function Prototype Declarations */
---- a/Makefile
-+++ b/Makefile
-@@ -1,18 +1,9 @@
--# File: drivers/atm/ti_evm3/Makefile
- #
--# Makefile for the Texas Instruments EVM3 ADSL/ATM driver.
-+# Makefile for the TIATM device driver.
- #
--#
--# Copyright (c) 2000 Texas Instruments Incorporated.
--# Jeff Harrell (jharrell@telogy.com)
--# Viren Balar (vbalar@ti.com)
--# Victor Wells (vwells@telogy.com)
--#
--include $(TOPDIR)/Rules.make
--
--
--
--
--
--
-
-+CONFIG_SANGAM_ATM=m
-+#EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
-+EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
-+obj-$(CONFIG_SANGAM_ATM) := tiatm.o
-+tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
---- a/tn7atm.c
-+++ b/tn7atm.c
-@@ -61,7 +61,6 @@
- * UR8_MERGE_END CQ11057*
- *********************************************************************************************/
-
--#include <linux/config.h>
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <linux/init.h>
-@@ -69,11 +68,14 @@
- #include <linux/delay.h>
- #include <linux/spinlock.h>
- #include <linux/smp_lock.h>
--#include <asm/io.h>
--#include <asm/mips-boards/prom.h>
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
-+
-+#include <asm/io.h>
-+#include <asm/ar7/ar7.h>
-+#include <asm/ar7/prom.h>
-+
- #include "dsl_hal_api.h"
- #include "tn7atm.h"
- #include "tn7api.h"
-@@ -82,6 +84,7 @@
- #include "dsl_hal_register.h"
-
- #ifdef MODULE
-+MODULE_LICENSE("GPL");
- MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
- MODULE_AUTHOR ("Zhicheng Tang");
- #endif
-@@ -100,9 +103,9 @@ MODULE_AUTHOR ("Zhicheng Tang");
-
- /*end of externs */
-
--#ifndef TI_STATIC_ALLOCATIONS
--#define TI_STATIC_ALLOCATIONS
--#endif
-+//#ifndef TI_STATIC_ALLOCATIONS
-+//#define TI_STATIC_ALLOCATIONS
-+//#endif
-
- #define tn7atm_kfree_skb(x) dev_kfree_skb(x)
-
-@@ -114,7 +117,7 @@ static int EnableQoS = FALSE;
- /* prototypes */
- static int tn7atm_set_can_support_adsl2 (int can);
-
--static int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci);
-+static int tn7atm_open (struct atm_vcc *vcc);
-
- static void tn7atm_close (struct atm_vcc *vcc);
-
-@@ -257,13 +260,12 @@ static const struct atmdev_ops tn7atm_op
- getsockopt: NULL,
- setsockopt: NULL,
- send: tn7atm_send,
-- sg_send: NULL,
- phy_put: NULL,
- phy_get: NULL,
- change_qos: tn7atm_change_qos,
- };
-
--const char drv_proc_root_folder[] = "avalanche/";
-+const char drv_proc_root_folder[] = "avalanche";
- static struct proc_dir_entry *root_proc_dir_entry = NULL;
- #define DRV_PROC_MODE 0644
- static int proc_root_already_exists = TRUE;
-@@ -559,56 +561,6 @@ static int turbodsl_check_priority_type(
-
- /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
-- * Function: int tn7atm_walk_vccs(struct atm_dev *dev, short *vcc, int *vci)
-- *
-- * Description: retrieve VPI/VCI for connection
-- *
-- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
--static int tn7atm_walk_vccs (struct atm_vcc *vcc, short *vpi, int *vci)
--{
-- struct atm_vcc *walk;
--
-- /*
-- * find a free VPI
-- */
-- if (*vpi == ATM_VPI_ANY)
-- {
--
-- for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next)
-- {
--
-- if ((walk->vci == *vci) && (walk->vpi == *vpi))
-- {
-- (*vpi)++;
-- walk = vcc->dev->vccs;
-- }
-- }
-- }
--
-- /*
-- * find a free VCI
-- */
-- if (*vci == ATM_VCI_ANY)
-- {
--
-- for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk;
-- walk = walk->next)
-- {
--
-- if ((walk->vpi = *vpi) && (walk->vci == *vci))
-- {
-- *vci = walk->vci + 1;
-- walk = vcc->dev->vccs;
-- }
-- }
-- }
--
-- return 0;
--}
--
--
--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- *
- * Function: int tn7atm_sar_irq(void)
- *
- * Description: tnetd73xx SAR interrupt.
-@@ -693,7 +645,7 @@ static int __init tn7atm_irq_request (st
- * Register SAR interrupt
- */
- priv->sar_irq = LNXINTNUM (ATM_SAR_INT); /* Interrupt line # */
-- if (request_irq (priv->sar_irq, tn7atm_sar_irq, SA_INTERRUPT, "SAR ", dev))
-+ if (request_irq (priv->sar_irq, tn7atm_sar_irq, IRQF_DISABLED, "SAR ", dev))
- printk ("Could not register tn7atm_sar_irq\n");
-
- /*
-@@ -704,14 +656,14 @@ static int __init tn7atm_irq_request (st
- {
- def_sar_inter_pace = os_atoi (ptr);
- }
-- avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
-- def_sar_inter_pace);
-+/* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
-+ def_sar_inter_pace);*/
-
- /*
- * Reigster Receive interrupt A
- */
- priv->dsl_irq = LNXINTNUM (ATM_DSL_INT); /* Interrupt line # */
-- if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, SA_INTERRUPT, "DSL ", dev))
-+ if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, IRQF_DISABLED, "DSL ", dev))
- printk ("Could not register tn7atm_dsl_irq\n");
-
- /***** VRB Tasklet Mode ****/
-@@ -875,11 +827,15 @@ static int __init tn7atm_get_ESI (struct
- #define ATM_VBR_RT 5
- #endif
-
--int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci)
-+int tn7atm_open (struct atm_vcc *vcc)
- {
- tn7atm_activate_vc_parm_t tn7atm_activate_vc_parm;
- int rc;
- //int flags;
-+ tn7atm_activate_vc_parm.pcr = 0x20000;
-+ tn7atm_activate_vc_parm.scr = 0x20000;
-+ tn7atm_activate_vc_parm.mbs = 0x20000;
-+ tn7atm_activate_vc_parm.cdvt = 10000;
-
- dgprintf(1, "tn7atm_open()\n");
-
-@@ -891,24 +847,18 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- return -1;
- }
-
-- MOD_INC_USE_COUNT;
-+// MOD_INC_USE_COUNT;
-
-- /* find a free VPI/VCI */
-- tn7atm_walk_vccs(vcc, &vpi, &vci);
--
-- vcc->vpi = vpi;
-- vcc->vci = vci;
--
-- if ((vci == ATM_VCI_UNSPEC) || (vpi == ATM_VCI_UNSPEC))
-+ if ((vcc->vci == ATM_VCI_UNSPEC) || (vcc->vpi == ATM_VCI_UNSPEC))
- {
-- MOD_DEC_USE_COUNT;
-+// MOD_DEC_USE_COUNT;
- return -EBUSY;
- }
-
-- tn7atm_activate_vc_parm.vpi = vpi;
-- tn7atm_activate_vc_parm.vci = vci;
-+ tn7atm_activate_vc_parm.vpi = vcc->vpi;
-+ tn7atm_activate_vc_parm.vci = vcc->vci;
-
-- if ((vpi == CLEAR_EOC_VPI) && (vci == CLEAR_EOC_VCI))
-+ if ((vcc->vpi == CLEAR_EOC_VPI) && (vcc->vci == CLEAR_EOC_VCI))
- {
- /* always use (max_dma_chan+1) for clear eoc */
- tn7atm_activate_vc_parm.chan = EOC_DMA_CHAN;
-@@ -916,7 +866,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- /* check to see whether clear eoc is opened or not */
- if (tn7atm_activate_vc_parm.priv->lut[tn7atm_activate_vc_parm.chan].inuse)
- {
-- MOD_DEC_USE_COUNT;
-+// MOD_DEC_USE_COUNT;
- printk("tn7atm_open: Clear EOC channel (dmachan=%d) already in use.\n", tn7atm_activate_vc_parm.chan);
- return -EBUSY;
- }
-@@ -925,7 +875,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- if (rc)
- {
- printk("tn7atm_open: failed to setup clear_eoc\n");
-- MOD_DEC_USE_COUNT;
-+// MOD_DEC_USE_COUNT;
- return -EBUSY;
- }
- tn7atm_set_lut(tn7atm_activate_vc_parm.priv,vcc, tn7atm_activate_vc_parm.chan);
-@@ -934,17 +884,17 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- }
- else /* PVC channel setup */
- {
-- if ((vpi==REMOTE_MGMT_VPI) && (vci==REMOTE_MGMT_VCI))
-+ if ((vcc->vpi==REMOTE_MGMT_VPI) && (vcc->vci==REMOTE_MGMT_VCI))
- {
- tn7atm_activate_vc_parm.chan = 14; /* always use chan 14 for MII PVC-base romote mgmt */
- }
- else
- {
-- rc = tn7atm_lut_find(vpi, vci);
-+ rc = tn7atm_lut_find(vcc->vpi, vcc->vci);
- /* check to see whether PVC is opened or not */
- if(ATM_NO_DMA_CHAN != rc)
- {
-- MOD_DEC_USE_COUNT;
-+// MOD_DEC_USE_COUNT;
- printk("PVC already opened. dmachan = %d\n", rc);
- return -EBUSY;
- }
-@@ -976,6 +926,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- tn7atm_activate_vc_parm.priority = 2;
- break;
-
-+#if 0
- case ATM_VBR: /* Variable Bit Rate-Non RealTime*/
- tn7atm_activate_vc_parm.qos = 1;
- tn7atm_activate_vc_parm.priority = 1;
-@@ -997,6 +948,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- tn7atm_activate_vc_parm.mbs = vcc->qos.txtp.max_pcr;
- tn7atm_activate_vc_parm.cdvt = vcc->qos.txtp.max_cdv;
- break;
-+#endif
-
- default:
- tn7atm_activate_vc_parm.qos = 2;
-@@ -1024,7 +976,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- if (rc < 0)
- {
- printk("failed to activate hw channel\n");
-- MOD_DEC_USE_COUNT;
-+// MOD_DEC_USE_COUNT;
- tn7atm_lut_clear(vcc, tn7atm_activate_vc_parm.chan);
- //spin_unlock_irqrestore(&chan_init_lock, flags);
- return -EBUSY;
-@@ -1114,7 +1066,7 @@ void tn7atm_close (struct atm_vcc *vcc)
- tn7atm_lut_clear (vcc, dmachan);
- //spin_unlock_irqrestore (&closeLock, closeFlag);
-
-- MOD_DEC_USE_COUNT;
-+// MOD_DEC_USE_COUNT;
-
- dgprintf (1, "Leave tn7atm_close\n");
- }
-@@ -1528,8 +1480,7 @@ int tn7atm_receive (void *os_dev, int ch
- * firewall is on */
-
- dgprintf (3, "pushing the skb...\n");
--
-- skb->stamp = vcc->timestamp = xtime;
-+ __net_timestamp(skb);
-
- xdump ((unsigned char *) skb->data, skb->len, 5);
-
-@@ -1725,8 +1676,7 @@ static void tn7atm_exit (void)
-
- kfree (dev->dev_data);
-
-- // atm_dev_deregister (dev);
-- shutdown_atm_dev (dev);
-+ atm_dev_deregister (dev);
-
- /*
- * remove proc entries
-@@ -1885,9 +1835,6 @@ static int __init tn7atm_detect (void)
- /*
- * Set up proc entry for atm stats
- */
-- if (tn7atm_xlate_proc_name
-- (drv_proc_root_folder, &root_proc_dir_entry, &residual))
-- {
- printk ("Creating new root folder %s in the proc for the driver stats \n",
- drv_proc_root_folder);
- root_proc_dir_entry = proc_mkdir (drv_proc_root_folder, NULL);
-@@ -1897,7 +1844,6 @@ static int __init tn7atm_detect (void)
- return -ENOMEM;
- }
- proc_root_already_exists = FALSE;
-- }
-
- /*
- * AV: Clean-up. Moved all the definitions to the data structure.
-@@ -2479,7 +2425,5 @@ static int tn7atm_proc_qos_write(struct
- return count;
- }
-
--#ifdef MODULE
- module_init (tn7atm_detect);
- module_exit (tn7atm_exit);
--#endif /* MODULE */
---- a/tn7atm.h
-+++ b/tn7atm.h
-@@ -19,7 +19,8 @@
- //#include "mips_support.h"
- #include <linux/list.h>
-
--#include <linux/config.h>
-+#define MIPS_EXCEPTION_OFFSET 8
-+#define LNXINTNUM(x)((x) + MIPS_EXCEPTION_OFFSET)
-
- #ifdef CONFIG_MODVERSIONS
- #include <linux/modversions.h>
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -94,7 +94,6 @@
- * 1/02/07 JZ CQ11054: Data Precision and Range Changes for TR-069 Conformance
- * UR8_MERGE_END CQ11054*
- *********************************************************************************************/
--#include <linux/config.h>
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <linux/init.h>
-@@ -102,8 +101,6 @@
- #include <linux/delay.h>
- #include <linux/spinlock.h>
- #include <linux/smp_lock.h>
--#include <asm/io.h>
--#include <asm/mips-boards/prom.h>
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
-@@ -111,6 +108,12 @@
- #include <linux/timer.h>
- #include <linux/vmalloc.h>
- #include <linux/file.h>
-+#include <linux/firmware.h>
-+
-+#include <asm/io.h>
-+#include <asm/ar7/ar7.h>
-+#include <asm/ar7/prom.h>
-+
- /* Modules specific header files */
- #include "tn7atm.h"
- #include "tn7api.h"
-@@ -173,7 +176,7 @@ led_reg_t ledreg[2];
- static struct led_funcs ledreg[2];
- #endif
-
--#define DEV_DSLMOD 1
-+#define DEV_DSLMOD CTL_UNNUMBERED
- #define MAX_STR_SIZE 256
- #define DSL_MOD_SIZE 256
-
-@@ -299,7 +302,7 @@ static PITIDSLHW_T pIhw;
- static volatile int bshutdown;
- static char info[MAX_STR_SIZE];
- /* Used for DSL Polling enable */
--static DECLARE_MUTEX_LOCKED (adsl_sem_overlay);
-+static struct semaphore adsl_sem_overlay;
-
- //kthread_t overlay_thread;
- /* end of module wide declars */
-@@ -323,6 +326,14 @@ static int tn7dsl_proc_snr_print (char *
- #define gDot1(a) ((a>0)?(a%10):((-a)%10))
- // UR8_MERGE_END CQ11054*
-
-+int avalanche_request_intr_pacing(int irq_nr, unsigned int blk_num,
-+ unsigned int pace_value)
-+{
-+ printk("avalanche_request_pacing(%d, %u, %u); // not implemented\n", irq_nr, blk_num, pace_value);
-+ return 0;
-+}
-+
-+
- int os_atoi(const char *pStr)
- {
- int MulNeg = (*pStr == '-' ? -1 : 1);
-@@ -359,39 +370,6 @@ void dprintf (int uDbgLevel, char *szFmt
- #endif
- }
-
--int strcmp(const char *s1, const char *s2)
--{
--
-- int size = strlen(s1);
--
-- return(strncmp(s1, s2, size));
--}
--
--int strncmp(const char *s1, const char *s2, size_t size)
--{
-- int i = 0;
-- int max_size = (int)size;
--
-- while((s1[i] != 0) && i < max_size)
-- {
-- if(s2[i] == 0)
-- {
-- return -1;
-- }
-- if(s1[i] != s2[i])
-- {
-- return 1;
-- }
-- i++;
-- }
-- if(s2[i] != 0)
-- {
-- return 1;
-- }
--
-- return 0;
--}
--
- // * UR8_MERGE_START CQ10640 Jack Zhang
- int tn7dsl_dump_dsp_memory(char *input_str) //cph99
- {
-@@ -441,101 +419,74 @@ unsigned int shim_osGetCpuFrequency(void
- return CpuFrequency;
- }
-
--int shim_osLoadFWImage(unsigned char *ptr)
-+static void avsar_release(struct device *dev)
- {
-- unsigned int bytesRead;
-- mm_segment_t oldfs;
-- static struct file *filp;
-- unsigned int imageLength=0x5ffff;
--
--
-- dgprintf(4, "tn7dsl_read_dsp()\n");
--
-- dgprintf(4,"open file %s\n", DSP_FIRMWARE_PATH);
--
-- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
-- if(filp ==NULL)
-- {
-- printk("Failed: Could not open DSP binary file\n");
-- return -1;
-- }
--
-- if (filp->f_dentry != NULL)
-- {
-- if (filp->f_dentry->d_inode != NULL)
-- {
-- printk ("DSP binary filesize = %d bytes\n",
-- (int) filp->f_dentry->d_inode->i_size);
-- imageLength = (unsigned int)filp->f_dentry->d_inode->i_size + 0x200;
-- }
-- }
--
-- if (filp->f_op->read==NULL)
-- return -1; /* File(system) doesn't allow reads */
--
-- /*
-- * Disable parameter checking
-- */
-- oldfs = get_fs();
-- set_fs(KERNEL_DS);
--
-- /*
-- * Now read bytes from postion "StartPos"
-- */
-- filp->f_pos = 0;
--
-- bytesRead = filp->f_op->read(filp,ptr,imageLength,&filp->f_pos);
--
-- dgprintf(4,"file length = %d\n", bytesRead);
--
-- set_fs(oldfs);
--
-- /*
-- * Close the file
-- */
-- fput(filp);
--
-- return bytesRead;
-+ printk(KERN_DEBUG "avsar firmware released\n");
- }
-
-+static struct device avsar = {
-+ .bus_id = "vlynq",
-+ .release = avsar_release,
-+};
-
--unsigned int shim_read_overlay_page (void *ptr, unsigned int secOffset,
-- unsigned int secLength)
-+int shim_osLoadFWImage(unsigned char *ptr)
- {
-- unsigned int bytesRead;
-- mm_segment_t oldfs;
-- struct file *filp;
--
-- dgprintf(4,"shim_read_overlay_page\n");
-- //dgprintf(4,"sec offset=%d, sec length =%d\n", secOffset, secLength);
-+ const struct firmware *fw_entry;
-+ size_t size;
-
-- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
-- if(filp ==NULL)
-- {
-- printk("Failed: Could not open DSP binary file\n");
-- return -1;
-- }
--
-- if (filp->f_op->read==NULL)
-- return -1; /* File(system) doesn't allow reads */
--
-- /*
-- * Now read bytes from postion "StartPos"
-- */
--
-- if(filp->f_op->llseek)
-- filp->f_op->llseek(filp,secOffset, 0);
-- oldfs = get_fs();
-- set_fs(KERNEL_DS);
-- filp->f_pos = secOffset;
-- bytesRead = filp->f_op->read(filp,ptr,secLength,&filp->f_pos);
--
-- set_fs(oldfs);
-- /*
-- * Close the file
-- */
-- fput(filp);
-- return bytesRead;
-+ printk("requesting firmware image \"ar0700xx.bin\"\n");
-+ if(device_register(&avsar) < 0) {
-+ printk(KERN_ERR
-+ "avsar: device_register fails\n");
-+ return -1;
-+ }
-+
-+ if(request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
-+ printk(KERN_ERR
-+ "avsar: Firmware not available\n");
-+ device_unregister(&avsar);
-+ return -1;
-+ }
-+ size = fw_entry->size;
-+ device_unregister(&avsar);
-+ if(size > 0x5ffff) {
-+ printk(KERN_ERR
-+ "avsar: Firmware too big (%d bytes)\n", size);
-+ release_firmware(fw_entry);
-+ return -1;
-+ }
-+ memcpy(ptr, fw_entry->data, size);
-+ release_firmware(fw_entry);
-+ return size;
-+}
-+
-+unsigned int shim_read_overlay_page(void *ptr, unsigned int secOffset, unsigned int secLength)
-+{
-+ const struct firmware *fw_entry;
-+
-+ printk("requesting firmware image \"ar0700xx.bin\"\n");
-+ if(device_register(&avsar) < 0) {
-+ printk(KERN_ERR
-+ "avsar: device_register fails\n");
-+ return -1;
-+ }
-+
-+ if(request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
-+ printk(KERN_ERR
-+ "avsar: Firmware not available\n");
-+ device_unregister(&avsar);
-+ return -1;
-+ }
-+ device_unregister(&avsar);
-+ if(fw_entry->size > secLength) {
-+ printk(KERN_ERR
-+ "avsar: Firmware too big (%d bytes)\n", fw_entry->size);
-+ release_firmware(fw_entry);
-+ return -1;
-+ }
-+ memcpy(ptr + secOffset, fw_entry->data, secLength);
-+ release_firmware(fw_entry);
-+ return secLength;
- }
-
- int shim_osLoadDebugFWImage(unsigned char *ptr)
-@@ -3064,6 +3015,7 @@ int tn7dsl_init(void *priv)
- int high_precision_selected = 0;
- // UR8_MERGE_END CQ11054*
-
-+ sema_init(&adsl_sem_overlay, 0);
- /*
- * start dsl
- */
-@@ -3442,7 +3394,7 @@ static int dslmod_sysctl(ctl_table *ctl,
- */
- if(write)
- {
-- ret = proc_dostring(ctl, write, filp, buffer, lenp);
-+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
-
- switch (ctl->ctl_name)
- {
-@@ -3528,14 +3480,14 @@ static int dslmod_sysctl(ctl_table *ctl,
- else
- {
- len += sprintf(info+len, mod_req);
-- ret = proc_dostring(ctl, write, filp, buffer, lenp);
-+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
- }
- return ret;
- }
-
-
- ctl_table dslmod_table[] = {
-- {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, &dslmod_sysctl}
-+ {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
- ,
- {0}
- };
-@@ -3558,8 +3510,7 @@ void tn7dsl_dslmod_sysctl_register(void)
- if (initialized == 1)
- return;
-
-- dslmod_sysctl_header = register_sysctl_table(dslmod_root_table, 1);
-- dslmod_root_table->child->de->owner = THIS_MODULE;
-+ dslmod_sysctl_header = register_sysctl_table(dslmod_root_table);
-
- /*
- * set the defaults
-@@ -4821,4 +4772,4 @@ int tn7dsl_proc_PMDus(char* buf, char **
- }
- #endif //NO_ADV_STATS
- #endif //TR69_PMD_IN
--// * UR8_MERGE_END CQ11057 *
-\ No newline at end of file
-+// * UR8_MERGE_END CQ11057 *
---- a/tn7sar.c
-+++ b/tn7sar.c
-@@ -42,7 +42,6 @@
- * UR8_MERGE_END CQ10700
- *******************************************************************************/
-
--#include <linux/config.h>
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <linux/init.h>
-@@ -50,12 +49,13 @@
- #include <linux/delay.h>
- #include <linux/spinlock.h>
- #include <linux/smp_lock.h>
--#include <asm/io.h>
--#include <asm/mips-boards/prom.h>
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
-
-+#include <asm/io.h>
-+#include <asm/ar7/ar7.h>
-+#include <asm/ar7/prom.h>
-
- #define _CPHAL_AAL5
- #define _CPHAL_SAR
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/110-interrupt_fix.patch b/package/system/ar7-atm/patches-D7.04.03.00/110-interrupt_fix.patch
deleted file mode 100644
index 9acb862e5d..0000000000
--- a/package/system/ar7-atm/patches-D7.04.03.00/110-interrupt_fix.patch
+++ /dev/null
@@ -1,37 +0,0 @@
---- a/tn7atm.c
-+++ b/tn7atm.c
-@@ -566,7 +566,7 @@ static int turbodsl_check_priority_type(
- * Description: tnetd73xx SAR interrupt.
- *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
--static void tn7atm_sar_irq (int irq, void *voiddev, struct pt_regs *regs)
-+static irqreturn_t tn7atm_sar_irq (int irq, void *voiddev)
- {
- struct atm_dev *atmdev;
- Tn7AtmPrivate *priv;
-@@ -593,6 +593,7 @@ static void tn7atm_sar_irq (int irq, voi
- #ifdef TIATM_INST_SUPP
- psp_trace_par (ATM_DRV_SAR_ISR_EXIT, retval);
- #endif
-+ return IRQ_HANDLED;
- }
-
- /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-@@ -602,7 +603,7 @@ static void tn7atm_sar_irq (int irq, voi
- * Description: tnetd73xx DSL interrupt.
- *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
--static void tn7atm_dsl_irq (int irq, void *voiddev, struct pt_regs *regs)
-+static irqreturn_t tn7atm_dsl_irq (int irq, void *voiddev)
- {
- struct atm_dev *atmdev;
- Tn7AtmPrivate *priv;
-@@ -624,6 +625,8 @@ static void tn7atm_dsl_irq (int irq, voi
- #ifdef TIATM_INST_SUPP
- psp_trace_par (ATM_DRV_DSL_ISR_EXIT, retval);
- #endif
-+
-+ return IRQ_HANDLED;
- }
-
- /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/120-no_dumb_inline.patch b/package/system/ar7-atm/patches-D7.04.03.00/120-no_dumb_inline.patch
deleted file mode 100644
index 2968fdc166..0000000000
--- a/package/system/ar7-atm/patches-D7.04.03.00/120-no_dumb_inline.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/tn7api.h
-+++ b/tn7api.h
-@@ -107,7 +107,7 @@ int tn7dsl_proc_dbg_rmsgs4(char* buf, ch
-
- int tn7dsl_proc_write_stats(struct file *fp, const char * buf, unsigned long count, void * data);
- int tn7dsl_proc_modem(char* buf, char **start, off_t offset, int count,int *eof, void *data);
--inline int tn7dsl_handle_interrupt(void);
-+int tn7dsl_handle_interrupt(void);
-
- void tn7dsl_dslmod_sysctl_register(void);
- void tn7dsl_dslmod_sysctl_unregister(void);
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/130-powercutback.patch b/package/system/ar7-atm/patches-D7.04.03.00/130-powercutback.patch
deleted file mode 100644
index ec00df97ab..0000000000
--- a/package/system/ar7-atm/patches-D7.04.03.00/130-powercutback.patch
+++ /dev/null
@@ -1,44 +0,0 @@
---- a/dsl_hal_advcfg.c
-+++ b/dsl_hal_advcfg.c
-@@ -36,9 +36,9 @@
- * 05Jul05 0.00.09 CPH CQ9775: Change dslhal_advcfg_configDsTones input parameters & support for ADSL2+
- * 24Jul05 0.00.10 CPH Fixed comments in dslhal_advcfg_configDsTones function header
- *******************************************************************************/
--#include <dev_host_interface.h>
--#include <dsl_hal_register.h>
--#include <dsl_hal_support.h>
-+#include "dev_host_interface.h"
-+#include "dsl_hal_register.h"
-+#include "dsl_hal_support.h"
-
- /*****************************************************************************/
- /* ACT API functions -- To be moved into their own independent module --RamP */
---- a/Makefile
-+++ b/Makefile
-@@ -4,6 +4,7 @@
-
- CONFIG_SANGAM_ATM=m
- #EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
--EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
-+#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
-+EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
- obj-$(CONFIG_SANGAM_ATM) := tiatm.o
--tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
-+tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -2869,6 +2869,14 @@ static int tn7dsl_set_dsl(void)
- dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
- }
-
-+ // set powercutback
-+ ptr = NULL;
-+ ptr = prom_getenv("powercutback");
-+ if(ptr)
-+ {
-+ dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
-+ }
-+
- // trellis
- ptr = NULL;
- ptr = prom_getenv("trellis");
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/140-debug_mode.patch b/package/system/ar7-atm/patches-D7.04.03.00/140-debug_mode.patch
deleted file mode 100644
index ce3697b10d..0000000000
--- a/package/system/ar7-atm/patches-D7.04.03.00/140-debug_mode.patch
+++ /dev/null
@@ -1,16 +0,0 @@
---- a/tn7sar.c
-+++ b/tn7sar.c
-@@ -103,10 +103,10 @@ enum
-
- #define RESERVED_OAM_CHANNEL 15
-
--#define AAL5_PARM "id=aal5, base = 0x03000000, offset = 0, int_line=15, ch0=[RxBufSize=1522; RxNumBuffers = 32; RxServiceMax = 50; TxServiceMax=50; TxNumBuffers=32; CpcsUU=0x5aa5; TxVc_CellRate=0x3000; TxVc_AtmHeader=0x00000640]"
--#define SAR_PARM "id=sar,base = 0x03000000, reset_bit = 9, offset = 0; UniNni = 0, PdspEnable = 1"
-+#define CH0_PARM "RxBufSize=1522, RxNumBuffers=32, RxServiceMax=50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
-+#define AAL5_PARM "id=aal5, base=0x03000000, offset=0, int_line=15, ch0=[" CH0_PARM "]"
-+#define SAR_PARM "id=sar, base=0x03000000, reset_bit=9, offset=0; UniNni=0, PdspEnable=1, Debug=0xFFFFFFFF"
- #define RESET_PARM "id=ResetControl, base=0xA8611600"
--#define CH0_PARM "RxBufSize=1522, RxNumBuffers = 32, RxServiceMax = 50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
-
- #define MAX_PVC_TABLE_ENTRY 16
-
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/150-tasklet_mode.patch b/package/system/ar7-atm/patches-D7.04.03.00/150-tasklet_mode.patch
deleted file mode 100644
index 97b8cecdd9..0000000000
--- a/package/system/ar7-atm/patches-D7.04.03.00/150-tasklet_mode.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/Makefile
-+++ b/Makefile
-@@ -5,6 +5,7 @@
- CONFIG_SANGAM_ATM=m
- #EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
- #EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
--EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
-+#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
-+EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL -DCPATM_TASKLET_MODE
- obj-$(CONFIG_SANGAM_ATM) := tiatm.o
- tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/160-module-params.patch b/package/system/ar7-atm/patches-D7.04.03.00/160-module-params.patch
deleted file mode 100644
index 67802ae1e9..0000000000
--- a/package/system/ar7-atm/patches-D7.04.03.00/160-module-params.patch
+++ /dev/null
@@ -1,589 +0,0 @@
---- a/tn7atm.c
-+++ b/tn7atm.c
-@@ -87,6 +87,146 @@
- MODULE_LICENSE("GPL");
- MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
- MODULE_AUTHOR ("Zhicheng Tang");
-+
-+int mp_sar_ipacemax = -1;
-+module_param_named(ipacemax, mp_sar_ipacemax, int, 0);
-+MODULE_PARM_DESC(ipacemax, "Interrupt pacing");
-+
-+char *mp_macc = NULL;
-+module_param_named(macc, mp_macc, charp, 0);
-+MODULE_PARM_DESC(macc, "MAC address");
-+
-+int mp_dsp_noboost = -1;
-+module_param_named(dsp_noboost, mp_dsp_noboost, int, 0);
-+MODULE_PARM_DESC(dsp_noboost, "Suppress DSP frequency boost");
-+
-+int mp_dsp_freq = -1;
-+module_param_named(dsp_freq, mp_dsp_freq, int, 0);
-+MODULE_PARM_DESC(dsp_freq, "Frequency to boost the DSP to");
-+
-+char *mp_featctl0 = NULL;
-+module_param_named(featctl0, mp_featctl0, charp, 0);
-+MODULE_PARM_DESC(featctl0, "DSL feature control 0");
-+
-+char *mp_featctl1 = NULL;
-+module_param_named(featctl1, mp_featctl1, charp, 0);
-+MODULE_PARM_DESC(featctl1, "DSL feature control 1");
-+
-+char *mp_phyctl0 = NULL;
-+module_param_named(phyctl0, mp_phyctl0, charp, 0);
-+MODULE_PARM_DESC(phyctl0, "DSL PHY control 0");
-+
-+char *mp_phyctl1 = NULL;
-+module_param_named(phyctl1, mp_phyctl1, charp, 0);
-+MODULE_PARM_DESC(phyctl1, "DSL PHY control 1");
-+
-+int mp_turbodsl = -1;
-+module_param_named(turbodsl, mp_turbodsl, int, 0);
-+MODULE_PARM_DESC(turbodsl, "Enable TurboDSL");
-+
-+int mp_sar_rxbuf = -1;
-+module_param_named(sar_rxbuf, mp_sar_rxbuf, int, 0);
-+MODULE_PARM_DESC(sar_rxbuf, "SAR RxBuf size");
-+
-+int mp_sar_rxmax = -1;
-+module_param_named(sar_rxmax, mp_sar_rxmax, int, 0);
-+MODULE_PARM_DESC(sar_rxmax, "SAR RxMax size");
-+
-+int mp_sar_txbuf = -1;
-+module_param_named(sar_txbuf, mp_sar_txbuf, int, 0);
-+MODULE_PARM_DESC(sar_txbuf, "SAR TxBuf size");
-+
-+int mp_sar_txmax = -1;
-+module_param_named(sar_txmax, mp_sar_txmax, int, 0);
-+MODULE_PARM_DESC(sar_txmax, "SAR TxMax size");
-+
-+char *mp_modulation = NULL;
-+module_param_named(modulation, mp_modulation, charp, 0);
-+MODULE_PARM_DESC(modulation, "Modulation");
-+
-+int mp_fine_gain_control = -1;
-+module_param_named(fine_gain_control, mp_fine_gain_control, int, 0);
-+MODULE_PARM_DESC(fine_gain_control, "Fine gain control");
-+
-+int mp_fine_gain_value = -1;
-+module_param_named(fine_gain_value, mp_fine_gain_value, int, 0);
-+MODULE_PARM_DESC(fine_gain_value, "Fine gain value");
-+
-+int mp_enable_margin_retrain = -1;
-+module_param_named(enable_margin_retrain, mp_enable_margin_retrain, int, 0);
-+MODULE_PARM_DESC(enable_margin_retrain, "Enable margin retrain");
-+
-+int mp_margin_threshold = -1;
-+module_param_named(margin_threshold, mp_margin_threshold, int, 0);
-+MODULE_PARM_DESC(margin_threshold, "Margin retrain treshold");
-+
-+int mp_enable_rate_adapt = -1;
-+module_param_named(enable_rate_adapt, mp_enable_rate_adapt, int, 0);
-+MODULE_PARM_DESC(enable_rate_adapt, "Enable rate adaption");
-+
-+int mp_powercutback = -1;
-+module_param_named(powercutback, mp_powercutback, int, 0);
-+MODULE_PARM_DESC(powercutback, "Enable / disable powercutback");
-+
-+int mp_trellis = -1;
-+module_param_named(trellis, mp_trellis, int, 0);
-+MODULE_PARM_DESC(trellis, "Enable / disable trellis coding");
-+
-+int mp_bitswap = -1;
-+module_param_named(bitswap, mp_bitswap, int, 0);
-+MODULE_PARM_DESC(bitswap, "Enable / disable bitswap");
-+
-+int mp_maximum_bits_per_carrier = -1;
-+module_param_named(maximum_bits_per_carrier, mp_maximum_bits_per_carrier, int, 0);
-+MODULE_PARM_DESC(maximum_bits_per_carrier, "Maximum bits per carrier");
-+
-+int mp_maximum_interleave_depth = -1;
-+module_param_named(maximum_interleave_depth, mp_maximum_interleave_depth, int, 0);
-+MODULE_PARM_DESC(maximum_interleave_depth, "Maximum interleave depth");
-+
-+int mp_pair_selection = -1;
-+module_param_named(pair_selection, mp_pair_selection, int, 0);
-+MODULE_PARM_DESC(pair_selection, "Pair selection");
-+
-+int mp_dgas_polarity = -1;
-+module_param_named(dgas_polarity, mp_dgas_polarity, int, 0);
-+MODULE_PARM_DESC(dgas_polarity, "DGAS polarity");
-+
-+int mp_los_alarm = -1;
-+module_param_named(los_alarm, mp_los_alarm, int, 0);
-+MODULE_PARM_DESC(los_alarm, "LOS alarm");
-+
-+char *mp_eoc_vendor_id = NULL;
-+module_param_named(eoc_vendor_id, mp_eoc_vendor_id, charp, 0);
-+MODULE_PARM_DESC(eoc_vendor_id, "EOC vendor id");
-+
-+int mp_eoc_vendor_revision = -1;
-+module_param_named(eoc_vendor_revision, mp_eoc_vendor_revision, int, 0);
-+MODULE_PARM_DESC(eoc_vendor_revision, "EOC vendor revision");
-+
-+char *mp_eoc_vendor_serialnum = NULL;
-+module_param_named(eoc_vendor_serialnum, mp_eoc_vendor_serialnum, charp, 0);
-+MODULE_PARM_DESC(eoc_vendor_serialnum, "EOC vendor serial number");
-+
-+char *mp_invntry_vernum = NULL;
-+module_param_named(invntry_vernum, mp_invntry_vernum, charp, 0);
-+MODULE_PARM_DESC(invntry_vernum, "Inventory revision number");
-+
-+int mp_dsl_bit_tmode = -1;
-+module_param_named(dsl_bit_tmode, mp_dsl_bit_tmode, int, 0);
-+MODULE_PARM_DESC(dsl_bit_tmode, "DSL bit training mode");
-+
-+int mp_high_precision = -1;
-+module_param_named(high_precision, mp_high_precision, int, 0);
-+MODULE_PARM_DESC(high_precision, "High precision");
-+
-+int mp_autopvc_enable = -1;
-+module_param_named(autopvc_enable, mp_autopvc_enable, int, 0);
-+MODULE_PARM_DESC(autopvc_enable, "Enable / disable automatic PVC");
-+
-+int mp_oam_lb_timeout = -1;
-+module_param_named(oam_lb_timeout, mp_oam_lb_timeout, int, 0);
-+MODULE_PARM_DESC(oam_lb_timeout, "OAM LB timeout");
- #endif
-
- #ifndef TRUE
-@@ -655,9 +795,9 @@
- * interrupt pacing
- */
- ptr = prom_getenv ("sar_ipacemax");
-- if (ptr)
-+ if (ptr || mp_sar_ipacemax != -1)
- {
-- def_sar_inter_pace = os_atoi (ptr);
-+ def_sar_inter_pace = mp_sar_ipacemax == -1 ? os_atoi (ptr) : mp_sar_ipacemax;
- }
- /* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
- def_sar_inter_pace);*/
-@@ -795,9 +935,18 @@
- {
- int i;
- char esi_addr[ESI_LEN] = { 0x00, 0x00, 0x11, 0x22, 0x33, 0x44 };
-- char *esiaddr_str = NULL;
-+ char *esiaddr_str = mp_macc;
-
-- esiaddr_str = prom_getenv ("maca");
-+ if (esiaddr_str == NULL)
-+ esiaddr_str = prom_getenv ("macdsl");
-+ if (esiaddr_str == NULL)
-+ esiaddr_str = prom_getenv ("macc");
-+ if (esiaddr_str == NULL)
-+ esiaddr_str = prom_getenv ("HWA_1");
-+ if (esiaddr_str == NULL)
-+ esiaddr_str = prom_getenv ("macb");
-+ if (esiaddr_str == NULL)
-+ esiaddr_str = prom_getenv ("maca");
-
- if (!esiaddr_str)
- {
-@@ -1930,15 +2079,15 @@
- //UR8_MERGE_END CQ10450*
-
- cp = prom_getenv ("dsp_noboost");
-- if (cp)
-+ if (cp || mp_dsp_noboost != -1)
- {
-- dsp_noboost = os_atoi (cp);
-+ dsp_noboost = mp_dsp_noboost == -1 ? os_atoi (cp) : mp_dsp_noboost;
- }
-
- cp = (char *) prom_getenv ("dsp_freq");
-- if (cp)
-+ if (cp || mp_dsp_freq != -1)
- {
-- dspfreq = os_atoi (cp);
-+ dspfreq = mp_dsp_freq == -1 ? os_atoi (cp) : mp_dsp_freq;
- if (dspfreq == 250)
- {
- boostDsp = 1;
-@@ -2187,8 +2336,9 @@
- // Inter-Op DSL phy Control
- // Note the setting of _dsl_Feature_0 and _dsl_Feature_1 must before
- // dslhal_api_dslStartup (in tn7dsl_init()).
-- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL)
-+ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL || mp_featctl0 != NULL)
- {
-+ if (mp_featctl0 != NULL) ptr = mp_featctl0;
- if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
- // os_atoh
- ptr += 2;
-@@ -2196,8 +2346,9 @@
- _dsl_Feature_0_defined = 1;
- }
-
-- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL)
-+ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL || mp_featctl1 != NULL)
- {
-+ if (mp_featctl1 != NULL) ptr = mp_featctl1;
- if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
- // os_atoh
- ptr += 2;
-@@ -2209,8 +2360,9 @@
- // DSL phy Feature Control
- // Note the setting of _dsl_PhyControl_0 and _dsl_PhyControl_1 must before
- // dslhal_api_dslStartup (in tn7dsl_init()).
-- if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL)
-+ if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL || mp_phyctl0 != NULL)
- {
-+ if (mp_phyctl0 != NULL) ptr = mp_phyctl0;
- if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
- // os_atoh
- ptr += 2;
-@@ -2218,8 +2370,9 @@
- _dsl_PhyControl_0_defined = 1;
- }
-
-- if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL)
-+ if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL || mp_phyctl1 != NULL)
- {
-+ if (mp_phyctl1 != NULL) ptr = mp_phyctl1;
- if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
- // os_atoh
- ptr += 2;
-@@ -2247,9 +2400,9 @@
- priv->bTurboDsl = 1;
- // read config for turbo dsl
- ptr = prom_getenv ("TurboDSL");
-- if (ptr)
-+ if (ptr || mp_turbodsl != -1)
- {
-- priv->bTurboDsl = os_atoi (ptr);
-+ priv->bTurboDsl = mp_turbodsl == -1 ? os_atoi (ptr) : mp_turbodsl;
- }
-
- // @Added to make Rx buffer number & Service max configurable through
-@@ -2257,30 +2410,30 @@
- priv->sarRxBuf = RX_BUFFER_NUM;
- ptr = NULL;
- ptr = prom_getenv ("SarRxBuf");
-- if (ptr)
-+ if (ptr || mp_sar_rxbuf != -1)
- {
-- priv->sarRxBuf = os_atoi (ptr);
-+ priv->sarRxBuf = mp_sar_rxbuf == -1 ? os_atoi (ptr) : mp_sar_rxbuf;
- }
- priv->sarRxMax = RX_SERVICE_MAX;
- ptr = NULL;
- ptr = prom_getenv ("SarRxMax");
-- if (ptr)
-+ if (ptr || mp_sar_rxmax != -1)
- {
-- priv->sarRxMax = os_atoi (ptr);
-+ priv->sarRxMax = mp_sar_rxmax == -1 ? os_atoi (ptr) : mp_sar_rxmax;
- }
- priv->sarTxBuf = TX_BUFFER_NUM;
- ptr = NULL;
- ptr = prom_getenv ("SarTxBuf");
-- if (ptr)
-+ if (ptr || mp_sar_txbuf != -1)
- {
-- priv->sarTxBuf = os_atoi (ptr);
-+ priv->sarTxBuf = mp_sar_txbuf == -1 ? os_atoi (ptr) : mp_sar_txbuf;
- }
- priv->sarTxMax = TX_SERVICE_MAX;
- ptr = NULL;
- ptr = prom_getenv ("SarTxMax");
-- if (ptr)
-+ if (ptr || mp_sar_txmax != -1)
- {
-- priv->sarTxMax = os_atoi (ptr);
-+ priv->sarTxMax = mp_sar_txmax == -1 ? os_atoi (ptr) : mp_sar_txmax;
- }
-
- return 0;
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -136,6 +136,27 @@
- #define NEW_TRAINING_VAL_T1413 128
- #define NEW_TRAINING_VAL_MMODE 255
-
-+extern char *mp_modulation;
-+extern int mp_fine_gain_control;
-+extern int mp_fine_gain_value;
-+extern int mp_enable_margin_retrain;
-+extern int mp_margin_threshold;
-+extern int mp_enable_rate_adapt;
-+extern int mp_powercutback;
-+extern int mp_trellis;
-+extern int mp_bitswap;
-+extern int mp_maximum_bits_per_carrier;
-+extern int mp_maximum_interleave_depth;
-+extern int mp_pair_selection;
-+extern int mp_dgas_polarity;
-+extern int mp_los_alarm;
-+extern char *mp_eoc_vendor_id;
-+extern int mp_eoc_vendor_revision;
-+extern char *mp_eoc_vendor_serialnum;
-+extern char *mp_invntry_vernum;
-+extern int mp_dsl_bit_tmode;
-+extern int mp_high_precision;
-+
- int testflag1 = 0;
- extern int __guDbgLevel;
- extern sar_stat_t sarStat;
-@@ -2818,84 +2839,80 @@ static int tn7dsl_set_dsl(void)
-
- // modulation
- ptr = prom_getenv("modulation");
-- if (ptr)
-+ if (ptr || mp_modulation != NULL)
- {
-- tn7dsl_set_modulation(ptr, FALSE);
-+ tn7dsl_set_modulation(mp_modulation == NULL ? ptr : mp_modulation, FALSE);
- }
-
- // Fine Gains
- ptr = prom_getenv("fine_gain_control");
-- if (ptr)
-+ if (ptr || mp_fine_gain_control != -1)
- {
-- value = os_atoi(ptr);
-+ value = mp_fine_gain_control == -1 ? os_atoi(ptr) : mp_fine_gain_control;
- tn7dsl_ctrl_fineGain(value);
- }
- ptr = NULL;
- ptr = prom_getenv("fine_gain_value");
-- if(ptr)
-- tn7dsl_set_fineGainValue(os_atoh(ptr));
-+ if(ptr || mp_fine_gain_value != -1)
-+ tn7dsl_set_fineGainValue(mp_fine_gain_value == -1 ? os_atoh(ptr) : mp_fine_gain_value);
-
- // margin retrain
- ptr = NULL;
- ptr = prom_getenv("enable_margin_retrain");
-- if(ptr)
-+ value = mp_enable_margin_retrain == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_enable_margin_retrain;
-+
-+ if (value == 1)
- {
-- value = os_atoi(ptr);
-- if(value == 1)
-+ dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
-+ bMarginRetrainEnable = 1;
-+ //printk("enable showtime margin monitor.\n");
-+
-+ ptr = NULL;
-+ ptr = prom_getenv("margin_threshold");
-+ value = mp_margin_threshold == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_margin_threshold;
-+
-+ if(value >= 0)
- {
-- dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
-- bMarginRetrainEnable = 1;
-- //printk("enable showtime margin monitor.\n");
-- ptr = NULL;
-- ptr = prom_getenv("margin_threshold");
-- if(ptr)
-- {
-- value = os_atoi(ptr);
-- //printk("Set margin threshold to %d x 0.5 db\n",value);
-- if(value >= 0)
-- {
-- dslhal_api_setMarginThreshold(pIhw, value);
-- bMarginThConfig=1;
-- }
-- }
-+ dslhal_api_setMarginThreshold(pIhw, value);
-+ bMarginThConfig=1;
- }
- }
-
- // rate adapt
- ptr = NULL;
- ptr = prom_getenv("enable_rate_adapt");
-- if(ptr)
-+ if(ptr || mp_enable_rate_adapt != -1)
- {
-- dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
-+ dslhal_api_setRateAdaptFlag(pIhw, mp_enable_rate_adapt == -1 ? os_atoi(ptr) : mp_enable_rate_adapt);
- }
-
- // set powercutback
- ptr = NULL;
- ptr = prom_getenv("powercutback");
-- if(ptr)
-+ if(ptr || mp_powercutback != -1)
- {
-- dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
-+ dslhal_advcfg_onOffPcb(pIhw, mp_powercutback == -1 ? os_atoi(ptr) : mp_powercutback);
- }
-
- // trellis
- ptr = NULL;
- ptr = prom_getenv("trellis");
-- if(ptr)
-+ if(ptr || mp_trellis != -1)
- {
-- dslhal_api_setTrellisFlag(pIhw, os_atoi(ptr));
-- trellis = os_atoi(ptr);
-+ trellis = mp_trellis == -1 ? os_atoi(ptr) : mp_trellis;
-+ dslhal_api_setTrellisFlag(pIhw, trellis);
- //printk("trellis=%d\n");
- }
-
- // bitswap
- ptr = NULL;
- ptr = prom_getenv("bitswap");
-- if(ptr)
-+ if(ptr || mp_bitswap != -1)
- {
- int offset[2] = {33, 0};
- unsigned int bitswap;
-
-- bitswap = os_atoi(ptr);
-+ bitswap = mp_bitswap == -1 ? os_atoi(ptr) : mp_bitswap;
-
- tn7dsl_generic_read(2, offset);
- dslReg &= dslhal_support_byteSwap32(0xFFFFFF00);
-@@ -2913,46 +2930,47 @@ static int tn7dsl_set_dsl(void)
- // maximum bits per carrier
- ptr = NULL;
- ptr = prom_getenv("maximum_bits_per_carrier");
-- if(ptr)
-+ if(ptr || mp_maximum_bits_per_carrier != -1)
- {
-- dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, os_atoi(ptr));
-+ dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, mp_maximum_bits_per_carrier == -1 ? os_atoi(ptr) : mp_maximum_bits_per_carrier);
- }
-
- // maximum interleave depth
- ptr = NULL;
- ptr = prom_getenv("maximum_interleave_depth");
-- if(ptr)
-+ if(ptr || mp_maximum_interleave_depth != -1)
- {
-- dslhal_api_setMaxInterleaverDepth(pIhw, os_atoi(ptr));
-+ dslhal_api_setMaxInterleaverDepth(pIhw, mp_maximum_interleave_depth == -1 ? os_atoi(ptr) : mp_maximum_interleave_depth);
- }
-
- // inner and outer pairs
- ptr = NULL;
- ptr = prom_getenv("pair_selection");
-- if(ptr)
-+ if(ptr || mp_pair_selection != -1)
- {
-- dslhal_api_selectInnerOuterPair(pIhw, os_atoi(ptr));
-+ dslhal_api_selectInnerOuterPair(pIhw, mp_pair_selection == -1 ? os_atoi(ptr) : mp_pair_selection);
- }
-
- ptr = NULL;
- ptr = prom_getenv("dgas_polarity");
-- if(ptr)
-+ if(ptr || mp_dgas_polarity != -1)
- {
- dslhal_api_configureDgaspLpr(pIhw, 1, 1);
-- dslhal_api_configureDgaspLpr(pIhw, 0, os_atoi(ptr));
-+ dslhal_api_configureDgaspLpr(pIhw, 0, mp_dgas_polarity == -1 ? os_atoi(ptr) : mp_dgas_polarity);
- }
-
- ptr = NULL;
- ptr = prom_getenv("los_alarm");
-- if(ptr)
-+ if(ptr || mp_los_alarm != -1)
- {
-- dslhal_api_disableLosAlarm(pIhw, os_atoi(ptr));
-+ dslhal_api_disableLosAlarm(pIhw, mp_los_alarm == -1 ? os_atoi(ptr) : mp_los_alarm);
- }
-
- ptr = NULL;
- ptr = prom_getenv("eoc_vendor_id");
-- if(ptr)
-+ if(ptr || mp_eoc_vendor_id != NULL)
- {
-+ ptr = mp_eoc_vendor_id == NULL ? ptr : mp_eoc_vendor_id;
- for(i=0;i<8;i++)
- {
- tmp[0]=ptr[i*2];
-@@ -2977,26 +2995,26 @@ static int tn7dsl_set_dsl(void)
- }
- ptr = NULL;
- ptr = prom_getenv("eoc_vendor_revision");
-- if(ptr)
-+ if(ptr || mp_eoc_vendor_revision != -1)
- {
-- value = os_atoi(ptr);
-+ value = mp_eoc_vendor_revision == -1 ? os_atoi(ptr) : mp_eoc_vendor_revision;
- //printk("eoc rev=%d\n", os_atoi(ptr));
- dslhal_api_setEocRevisionNumber(pIhw, (char *)&value);
-
- }
- ptr = NULL;
- ptr = prom_getenv("eoc_vendor_serialnum");
-- if(ptr)
-+ if(ptr || mp_eoc_vendor_serialnum != NULL)
- {
-- dslhal_api_setEocSerialNumber(pIhw, ptr);
-+ dslhal_api_setEocSerialNumber(pIhw, mp_eoc_vendor_serialnum == NULL ? ptr : mp_eoc_vendor_serialnum);
- }
-
- // CQ10037 Added invntry_vernum environment variable to be able to set version number in ADSL2, ADSL2+ modes.
- ptr = NULL;
- ptr = prom_getenv("invntry_vernum");
-- if(ptr)
-+ if(ptr || mp_invntry_vernum != NULL)
- {
-- dslhal_api_setEocRevisionNumber(pIhw, ptr);
-+ dslhal_api_setEocRevisionNumber(pIhw, mp_invntry_vernum == NULL ? ptr : mp_invntry_vernum);
- }
-
- return 0;
-@@ -3041,7 +3059,7 @@ int tn7dsl_init(void *priv)
- * backward compatibility.
- */
- cp = prom_getenv("DSL_BIT_TMODE");
-- if (cp)
-+ if (cp || mp_dsl_bit_tmode != -1)
- {
- printk("%s : env var DSL_BIT_TMODE is set\n", __FUNCTION__);
- /*
-@@ -3070,9 +3088,9 @@ int tn7dsl_init(void *priv)
-
- // UR8_MERGE_START CQ11054 Jack Zhang
- cp = prom_getenv("high_precision");
-- if (cp)
-+ if (cp || mp_high_precision != -1)
- {
-- high_precision_selected = os_atoi(cp);
-+ high_precision_selected = mp_high_precision == -1 ? os_atoi(cp) : mp_high_precision;
- }
- if ( high_precision_selected)
- {
---- a/tn7sar.c
-+++ b/tn7sar.c
-@@ -74,6 +74,8 @@ typedef void OS_SETUP;
- /* PDSP Firmware files */
- #include "tnetd7300_sar_firm.h"
-
-+extern int mp_oam_lb_timeout;
-+extern int mp_autopvc_enable;
-
- enum
- {
-@@ -817,9 +819,9 @@ int tn7sar_setup_oam_channel(Tn7AtmPriva
- pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
-
- pauto_pvc = prom_getenv("autopvc_enable");
-- if(pauto_pvc) //CQ10273
-+ if(pauto_pvc || mp_autopvc_enable != -1) //CQ10273
- {
-- auto_pvc =tn7sar_strtoul(pauto_pvc, NULL, 10);
-+ auto_pvc = mp_autopvc_enable == -1 ? tn7sar_strtoul(pauto_pvc, NULL, 10) : mp_autopvc_enable;
- }
-
- memset(&chInfo, 0xff, sizeof(chInfo));
-@@ -985,9 +987,9 @@ int tn7sar_init(struct atm_dev *dev, Tn7
-
- /* read in oam lb timeout value */
- pLbTimeout = prom_getenv("oam_lb_timeout");
-- if(pLbTimeout)
-+ if(pLbTimeout || mp_oam_lb_timeout != -1)
- {
-- lbTimeout =tn7sar_strtoul(pLbTimeout, NULL, 10);
-+ lbTimeout = mp_oam_lb_timeout == -1 ? tn7sar_strtoul(pLbTimeout, NULL, 10) : mp_oam_lb_timeout;
- oamLbTimeout = lbTimeout;
- pHalFunc->Control(pHalDev,"OamLbTimeout", "Set", &lbTimeout);
- }
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/170-bus_id_removal.patch b/package/system/ar7-atm/patches-D7.04.03.00/170-bus_id_removal.patch
deleted file mode 100644
index 9f1f0fdae4..0000000000
--- a/package/system/ar7-atm/patches-D7.04.03.00/170-bus_id_removal.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -109,6 +109,7 @@
- #include <linux/vmalloc.h>
- #include <linux/file.h>
- #include <linux/firmware.h>
-+#include <linux/version.h>
-
- #include <asm/io.h>
- #include <asm/ar7/ar7.h>
-@@ -446,7 +447,9 @@ static void avsar_release(struct device
- }
-
- static struct device avsar = {
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
- .bus_id = "vlynq",
-+#endif
- .release = avsar_release,
- };
-
-@@ -455,6 +458,9 @@ int shim_osLoadFWImage(unsigned char *pt
- const struct firmware *fw_entry;
- size_t size;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
-+ dev_set_name(&avsar, "avsar");
-+#endif
- printk("requesting firmware image \"ar0700xx.bin\"\n");
- if(device_register(&avsar) < 0) {
- printk(KERN_ERR
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/180-git_headers_include.patch b/package/system/ar7-atm/patches-D7.04.03.00/180-git_headers_include.patch
deleted file mode 100644
index 6bd8f48760..0000000000
--- a/package/system/ar7-atm/patches-D7.04.03.00/180-git_headers_include.patch
+++ /dev/null
@@ -1,54 +0,0 @@
---- a/tn7atm.c
-+++ b/tn7atm.c
-@@ -71,10 +71,16 @@
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
-+#include <linux/version.h>
-
- #include <asm/io.h>
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
- #include <asm/ar7/ar7.h>
- #include <asm/ar7/prom.h>
-+#else
-+#include <asm/mach-ar7/ar7.h>
-+#include <asm/mach-ar7/prom.h>
-+#endif
-
- #include "dsl_hal_api.h"
- #include "tn7atm.h"
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -112,8 +112,13 @@
- #include <linux/version.h>
-
- #include <asm/io.h>
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
- #include <asm/ar7/ar7.h>
- #include <asm/ar7/prom.h>
-+#else
-+#include <asm/mach-ar7/ar7.h>
-+#include <asm/mach-ar7/prom.h>
-+#endif
-
- /* Modules specific header files */
- #include "tn7atm.h"
---- a/tn7sar.c
-+++ b/tn7sar.c
-@@ -52,10 +52,16 @@
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
-+#include <linux/version.h>
-
- #include <asm/io.h>
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
- #include <asm/ar7/ar7.h>
- #include <asm/ar7/prom.h>
-+#else
-+#include <asm/mach-ar7/ar7.h>
-+#include <asm/mach-ar7/prom.h>
-+#endif
-
- #define _CPHAL_AAL5
- #define _CPHAL_SAR
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/190-2.6.32_proc_fixes.patch b/package/system/ar7-atm/patches-D7.04.03.00/190-2.6.32_proc_fixes.patch
deleted file mode 100644
index 11487bf7a6..0000000000
--- a/package/system/ar7-atm/patches-D7.04.03.00/190-2.6.32_proc_fixes.patch
+++ /dev/null
@@ -1,79 +0,0 @@
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -203,7 +203,11 @@ led_reg_t ledreg[2];
- static struct led_funcs ledreg[2];
- #endif
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
- #define DEV_DSLMOD CTL_UNNUMBERED
-+#else
-+#define DEV_DSLMOD 0
-+#endif
- #define MAX_STR_SIZE 256
- #define DSL_MOD_SIZE 256
-
-@@ -3431,9 +3435,16 @@ static int dslmod_sysctl(ctl_table *ctl,
- */
- if(write)
- {
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
- ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
--
-+#else
-+ ret = proc_dostring(ctl, write, buffer, lenp, 0);
-+#endif
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
- switch (ctl->ctl_name)
-+#else
-+ switch ((long)ctl->extra2)
-+#endif
- {
- case DEV_DSLMOD:
- ptr = strpbrk(info, " \t");
-@@ -3517,14 +3528,29 @@ static int dslmod_sysctl(ctl_table *ctl,
- else
- {
- len += sprintf(info+len, mod_req);
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
- ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
-+#else
-+ ret = proc_dostring(ctl, write, buffer, lenp, 0);
-+#endif
- }
- return ret;
- }
-
-
- ctl_table dslmod_table[] = {
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
- {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
-+#else
-+ {
-+ .procname = "dslmod",
-+ .data = info,
-+ .maxlen = DSL_MOD_SIZE,
-+ .mode = 0644,
-+ .proc_handler = &dslmod_sysctl,
-+ .extra2 = (void *)DEV_DSLMOD,
-+ }
-+#endif
- ,
- {0}
- };
-@@ -3532,7 +3558,16 @@ ctl_table dslmod_table[] = {
- /* Make sure that /proc/sys/dev is there */
- ctl_table dslmod_root_table[] = {
- #ifdef CONFIG_PROC_FS
-+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
- {CTL_DEV, "dev", NULL, 0, 0555, dslmod_table}
-+ #else
-+ {
-+ .procname = "dev",
-+ .maxlen = 0,
-+ .mode = 0555,
-+ .child = dslmod_table,
-+ }
-+ #endif
- ,
- #endif /* CONFIG_PROC_FS */
- {0}
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/200-2.6.37_args.patch b/package/system/ar7-atm/patches-D7.04.03.00/200-2.6.37_args.patch
deleted file mode 100644
index 59c1d58d15..0000000000
--- a/package/system/ar7-atm/patches-D7.04.03.00/200-2.6.37_args.patch
+++ /dev/null
@@ -1,36 +0,0 @@
---- a/tn7atm.c
-+++ b/tn7atm.c
-@@ -1867,7 +1867,11 @@ static int __init tn7atm_register (Tn7At
-
- dgprintf (4, "device %s being registered\n", priv->name);
-
-+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
- mydev = atm_dev_register (priv->proc_name, &tn7atm_ops, -1, NULL);
-+ #else
-+ mydev = atm_dev_register (priv->proc_name, NULL, &tn7atm_ops, -1, NULL);
-+ #endif
-
- if (mydev == NULL)
- {
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -466,14 +466,17 @@ int shim_osLoadFWImage(unsigned char *pt
- {
- const struct firmware *fw_entry;
- size_t size;
-+ int ret;
-
- #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
- dev_set_name(&avsar, "avsar");
- #endif
- printk("requesting firmware image \"ar0700xx.bin\"\n");
-- if(device_register(&avsar) < 0) {
-+ dev_set_name(&avsar, "avsar");
-+ ret = device_register(&avsar);
-+ if (ret < 0) {
- printk(KERN_ERR
-- "avsar: device_register fails\n");
-+ "avsar: device_register fails, error%i\n", ret);
- return -1;
- }
-
diff --git a/package/system/ar7-atm/patches-D7.04.03.00/210-3.3-remove-smp_lock.h.patch b/package/system/ar7-atm/patches-D7.04.03.00/210-3.3-remove-smp_lock.h.patch
deleted file mode 100644
index 525218c3b4..0000000000
--- a/package/system/ar7-atm/patches-D7.04.03.00/210-3.3-remove-smp_lock.h.patch
+++ /dev/null
@@ -1,33 +0,0 @@
---- a/tn7atm.c
-+++ b/tn7atm.c
-@@ -67,7 +67,7 @@
- #include <linux/atmdev.h>
- #include <linux/delay.h>
- #include <linux/spinlock.h>
--#include <linux/smp_lock.h>
-+#include <linux/interrupt.h>
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
---- a/tn7sar.c
-+++ b/tn7sar.c
-@@ -48,7 +48,7 @@
- #include <linux/atmdev.h>
- #include <linux/delay.h>
- #include <linux/spinlock.h>
--#include <linux/smp_lock.h>
-+#include <linux/interrupt.h>
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -100,7 +100,7 @@
- #include <linux/atmdev.h>
- #include <linux/delay.h>
- #include <linux/spinlock.h>
--#include <linux/smp_lock.h>
-+#include <linux/interrupt.h>
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/100-compile_fix.patch b/package/system/ar7-atm/patches-D7.05.01.00/100-compile_fix.patch
deleted file mode 100644
index 7dee220256..0000000000
--- a/package/system/ar7-atm/patches-D7.05.01.00/100-compile_fix.patch
+++ /dev/null
@@ -1,808 +0,0 @@
---- a/cppi_cpaal5.c
-+++ b/cppi_cpaal5.c
-@@ -360,7 +360,7 @@ static int halRxReturn(HAL_RECEIVEINFO *
- {
- /* malloc failed, add this RCB to Needs Buffer List */
- TempRcb->FragCount = 1; /*MJH+030417*/
-- (HAL_RCB *)TempRcb->Eop = TempRcb; /* GSG +030430 */
-+ TempRcb->Eop = TempRcb; /* GSG +030430 */
-
- if(HalDev->NeedsCount < MAX_NEEDS) /* +MJH 030410 */
- { /* +MJH 030410 */
---- a/dsl_hal_api.c
-+++ b/dsl_hal_api.c
-@@ -273,15 +273,15 @@
- * 09/15/07 CPH CQ11466 Added EFM support
- * 09/27/07 EYin CQ11929: Added NFEC/INP/Lp/Rp reporting for only ADSL2/2+ mode.
- ******************************************************************************/
--#include <dev_host_interface.h>
--#include <dsl_hal_register.h>
--#include <dsl_hal_support.h>
-+#include "dev_host_interface.h"
-+#include "dsl_hal_register.h"
-+#include "dsl_hal_support.h"
-
- #ifndef NO_ADV_STATS
--#include <dsl_hal_logtable.h>
-+#include "dsl_hal_logtable.h"
- #endif
-
--#include <dsl_hal_version.h>
-+#include "dsl_hal_version.h"
-
- // UR8_MERGE_START CQ11054 Jack Zhang
- static unsigned int highprecision_selected = 0; //By default we use low precision for backward compt.
---- a/dsl_hal_support.c
-+++ b/dsl_hal_support.c
-@@ -142,9 +142,9 @@
- * UR8_MERGE_START_END CQ11922 Tim
- * 04Sep07 0.14.00 Tim CQ11922: Added support for new scratchram for INP NDR tables
- *******************************************************************************/
--#include <dev_host_interface.h>
--#include <dsl_hal_register.h>
--#include <dsl_hal_support.h>
-+#include "dev_host_interface.h"
-+#include "dsl_hal_register.h"
-+#include "dsl_hal_support.h"
-
- #define NUM_READ_RETRIES 3
- static unsigned int dslhal_support_adsl2ByteSwap32(unsigned int in32Bits);
---- a/dsl_hal_support.h
-+++ b/dsl_hal_support.h
-@@ -49,7 +49,7 @@
- * 04Nov05 0.11.00 CPH Fixed T1413 mode got Zero DS/US rate when DSL_BIT_TMODE is set.
- *******************************************************************************/
-
--#include <dsl_hal_api.h>
-+#include "dsl_hal_api.h"
-
- #define virtual2Physical(a) (((int)a)&~0xe0000000)
- /* External Function Prototype Declarations */
---- a/Makefile
-+++ b/Makefile
-@@ -1,18 +1,9 @@
--# File: drivers/atm/ti_evm3/Makefile
- #
--# Makefile for the Texas Instruments EVM3 ADSL/ATM driver.
-+# Makefile for the TIATM device driver.
- #
--#
--# Copyright (c) 2000 Texas Instruments Incorporated.
--# Jeff Harrell (jharrell@telogy.com)
--# Viren Balar (vbalar@ti.com)
--# Victor Wells (vwells@telogy.com)
--#
--include $(TOPDIR)/Rules.make
--
--
--
--
--
--
-
-+CONFIG_SANGAM_ATM=m
-+#EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
-+EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
-+obj-$(CONFIG_SANGAM_ATM) := tiatm.o
-+tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
---- a/tn7atm.c
-+++ b/tn7atm.c
-@@ -66,7 +66,6 @@
- * 09/18/07 CPH CQ11466 Added EFM Support
- *********************************************************************************************/
-
--#include <linux/config.h>
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <linux/init.h>
-@@ -74,11 +73,14 @@
- #include <linux/delay.h>
- #include <linux/spinlock.h>
- #include <linux/smp_lock.h>
--#include <asm/io.h>
--#include <asm/mips-boards/prom.h>
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
-+
-+#include <asm/io.h>
-+#include <asm/ar7/ar7.h>
-+#include <asm/ar7/prom.h>
-+
- #include "dsl_hal_api.h"
- #ifdef AR7_EFM
- #include "tn7efm.h"
-@@ -90,6 +92,7 @@
- #include "dsl_hal_register.h"
-
- #ifdef MODULE
-+MODULE_LICENSE("GPL");
- MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
- MODULE_AUTHOR ("Zhicheng Tang");
- #endif
-@@ -108,9 +111,9 @@ MODULE_AUTHOR ("Zhicheng Tang");
-
- /*end of externs */
-
--#ifndef TI_STATIC_ALLOCATIONS
--#define TI_STATIC_ALLOCATIONS
--#endif
-+//#ifndef TI_STATIC_ALLOCATIONS
-+//#define TI_STATIC_ALLOCATIONS
-+//#endif
-
- #define tn7atm_kfree_skb(x) dev_kfree_skb(x)
-
-@@ -135,7 +138,7 @@ static int EnableQoS = FALSE;
- /* prototypes */
- static int tn7atm_set_can_support_adsl2 (int can);
-
--static int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci);
-+static int tn7atm_open (struct atm_vcc *vcc);
-
- void tn7atm_close (struct atm_vcc *vcc);
-
-@@ -298,13 +301,12 @@ static const struct atmdev_ops tn7atm_op
- getsockopt: NULL,
- setsockopt: NULL,
- send: tn7atm_send,
-- sg_send: NULL,
- phy_put: NULL,
- phy_get: NULL,
- change_qos: tn7atm_change_qos,
- };
-
--const char drv_proc_root_folder[] = "avalanche/";
-+const char drv_proc_root_folder[] = "avalanche";
- static struct proc_dir_entry *root_proc_dir_entry = NULL;
- #define DRV_PROC_MODE 0644
- static int proc_root_already_exists = TRUE;
-@@ -626,56 +628,6 @@ static int turbodsl_check_priority_type(
-
- /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
-- * Function: int tn7atm_walk_vccs(struct atm_dev *dev, short *vcc, int *vci)
-- *
-- * Description: retrieve VPI/VCI for connection
-- *
-- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
--static int tn7atm_walk_vccs (struct atm_vcc *vcc, short *vpi, int *vci)
--{
-- struct atm_vcc *walk;
--
-- /*
-- * find a free VPI
-- */
-- if (*vpi == ATM_VPI_ANY)
-- {
--
-- for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next)
-- {
--
-- if ((walk->vci == *vci) && (walk->vpi == *vpi))
-- {
-- (*vpi)++;
-- walk = vcc->dev->vccs;
-- }
-- }
-- }
--
-- /*
-- * find a free VCI
-- */
-- if (*vci == ATM_VCI_ANY)
-- {
--
-- for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk;
-- walk = walk->next)
-- {
--
-- if ((walk->vpi = *vpi) && (walk->vci == *vci))
-- {
-- *vci = walk->vci + 1;
-- walk = vcc->dev->vccs;
-- }
-- }
-- }
--
-- return 0;
--}
--
--
--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- *
- * Function: int tn7atm_sar_irq(void)
- *
- * Description: tnetd73xx SAR interrupt.
-@@ -766,7 +718,7 @@ static int __init tn7atm_irq_request (st
-
- priv->sar_irq = LNXINTNUM (ATM_SAR_INT); /* Interrupt line # */
-
-- if (request_irq (priv->sar_irq, tn7atm_sar_irq, SA_INTERRUPT, "SAR ", dev))
-+ if (request_irq (priv->sar_irq, tn7atm_sar_irq, IRQF_DISABLED, "SAR ", dev))
- printk ("Could not register tn7atm_sar_irq\n");
-
- /*
-@@ -777,8 +729,8 @@ static int __init tn7atm_irq_request (st
- {
- def_sar_inter_pace = os_atoi (ptr);
- }
-- avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
-- def_sar_inter_pace);
-+ /* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
-+ def_sar_inter_pace); */
-
-
- #ifdef AR7_EFM
-@@ -790,7 +742,7 @@ static int __init tn7atm_irq_request (st
- * Reigster Receive interrupt A
- */
- priv->dsl_irq = LNXINTNUM (ATM_DSL_INT); /* Interrupt line # */
-- if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, SA_INTERRUPT, "DSL ", dev))
-+ if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, IRQF_DISABLED, "DSL ", dev))
- printk ("Could not register tn7atm_dsl_irq\n");
-
- /***** VRB Tasklet Mode ****/
-@@ -958,11 +910,15 @@ static int __init tn7atm_get_ESI (struct
- #define ATM_VBR_RT 5
- #endif
-
--int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci)
-+int tn7atm_open (struct atm_vcc *vcc)
- {
- tn7atm_activate_vc_parm_t tn7atm_activate_vc_parm;
- int rc;
- //int flags;
-+ tn7atm_activate_vc_parm.pcr = 0x20000;
-+ tn7atm_activate_vc_parm.scr = 0x20000;
-+ tn7atm_activate_vc_parm.mbs = 0x20000;
-+ tn7atm_activate_vc_parm.cdvt = 10000;
-
- dgprintf(1, "tn7atm_open()\n");
-
-@@ -974,24 +930,18 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- return -1;
- }
-
-- MOD_INC_USE_COUNT;
-+// MOD_INC_USE_COUNT;
-
-- /* find a free VPI/VCI */
-- tn7atm_walk_vccs(vcc, &vpi, &vci);
--
-- vcc->vpi = vpi;
-- vcc->vci = vci;
--
-- if ((vci == ATM_VCI_UNSPEC) || (vpi == ATM_VCI_UNSPEC))
-+ if ((vcc->vci == ATM_VCI_UNSPEC) || (vcc->vpi == ATM_VCI_UNSPEC))
- {
-- MOD_DEC_USE_COUNT;
-+// MOD_DEC_USE_COUNT;
- return -EBUSY;
- }
-
-- tn7atm_activate_vc_parm.vpi = vpi;
-- tn7atm_activate_vc_parm.vci = vci;
-+ tn7atm_activate_vc_parm.vpi = vcc->vpi;
-+ tn7atm_activate_vc_parm.vci = vcc->vci;
-
-- if ((vpi == CLEAR_EOC_VPI) && (vci == CLEAR_EOC_VCI))
-+ if ((vcc->vpi == CLEAR_EOC_VPI) && (vcc->vci == CLEAR_EOC_VCI))
- {
- /* always use (max_dma_chan+1) for clear eoc */
- tn7atm_activate_vc_parm.chan = EOC_DMA_CHAN;
-@@ -999,7 +949,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- /* check to see whether clear eoc is opened or not */
- if (tn7atm_activate_vc_parm.priv->lut[tn7atm_activate_vc_parm.chan].inuse)
- {
-- MOD_DEC_USE_COUNT;
-+// MOD_DEC_USE_COUNT;
- printk("tn7atm_open: Clear EOC channel (dmachan=%d) already in use.\n", tn7atm_activate_vc_parm.chan);
- return -EBUSY;
- }
-@@ -1008,7 +958,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- if (rc)
- {
- printk("tn7atm_open: failed to setup clear_eoc\n");
-- MOD_DEC_USE_COUNT;
-+// MOD_DEC_USE_COUNT;
- return -EBUSY;
- }
- tn7atm_set_lut(tn7atm_activate_vc_parm.priv,vcc, tn7atm_activate_vc_parm.chan);
-@@ -1017,17 +967,17 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- }
- else /* PVC channel setup */
- {
-- if ((vpi==REMOTE_MGMT_VPI) && (vci==REMOTE_MGMT_VCI))
-+ if ((vcc->vpi==REMOTE_MGMT_VPI) && (vcc->vci==REMOTE_MGMT_VCI))
- {
- tn7atm_activate_vc_parm.chan = 14; /* always use chan 14 for MII PVC-base romote mgmt */
- }
- else
- {
-- rc = tn7atm_lut_find(vpi, vci);
-+ rc = tn7atm_lut_find(vcc->vpi, vcc->vci);
- /* check to see whether PVC is opened or not */
- if(ATM_NO_DMA_CHAN != rc)
- {
-- MOD_DEC_USE_COUNT;
-+// MOD_DEC_USE_COUNT;
- printk("PVC already opened. dmachan = %d\n", rc);
- return -EBUSY;
- }
-@@ -1059,6 +1009,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- tn7atm_activate_vc_parm.priority = 2;
- break;
-
-+#if 0
- case ATM_VBR: /* Variable Bit Rate-Non RealTime*/
- tn7atm_activate_vc_parm.qos = 1;
- tn7atm_activate_vc_parm.priority = 1;
-@@ -1080,6 +1031,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- tn7atm_activate_vc_parm.mbs = vcc->qos.txtp.max_pcr;
- tn7atm_activate_vc_parm.cdvt = vcc->qos.txtp.max_cdv;
- break;
-+#endif
-
- default:
- tn7atm_activate_vc_parm.qos = 2;
-@@ -1107,7 +1059,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
- if (rc < 0)
- {
- printk("failed to activate hw channel\n");
-- MOD_DEC_USE_COUNT;
-+// MOD_DEC_USE_COUNT;
- tn7atm_lut_clear(vcc, tn7atm_activate_vc_parm.chan);
- //spin_unlock_irqrestore(&chan_init_lock, flags);
- return -EBUSY;
-@@ -1197,7 +1149,7 @@ void tn7atm_close (struct atm_vcc *vcc)
- tn7atm_lut_clear (vcc, dmachan);
- //spin_unlock_irqrestore (&closeLock, closeFlag);
-
-- MOD_DEC_USE_COUNT;
-+// MOD_DEC_USE_COUNT;
-
- dgprintf (1, "Leave tn7atm_close\n");
- }
-@@ -1630,8 +1582,7 @@ int tn7atm_receive (void *os_dev, int ch
- * firewall is on */
-
- dgprintf (3, "pushing the skb...\n");
--
-- skb->stamp = vcc->timestamp = xtime;
-+ __net_timestamp(skb);
-
- xdump ((unsigned char *) skb->data, skb->len, 5);
-
-@@ -1854,8 +1805,7 @@ printk("!!!free atm irq: tn7atm_exit\n")
-
- kfree (dev->dev_data);
-
-- // atm_dev_deregister (dev);
-- shutdown_atm_dev (dev);
-+ atm_dev_deregister (dev);
-
- /*
- * remove proc entries
-@@ -2086,9 +2036,6 @@ static int __init tn7atm_detect (void)
- * Set up proc entry for atm stats
- */
-
-- if (tn7atm_xlate_proc_name
-- (drv_proc_root_folder, &root_proc_dir_entry, &residual))
-- {
- printk ("Creating new root folder %s in the proc for the driver stats \n",
- drv_proc_root_folder);
- root_proc_dir_entry = proc_mkdir (drv_proc_root_folder, NULL);
-@@ -2098,7 +2045,6 @@ static int __init tn7atm_detect (void)
- return -ENOMEM;
- }
- proc_root_already_exists = FALSE;
-- }
-
-
- /*
-@@ -2731,7 +2677,5 @@ int tn7atm_proc_turbodsl_write(struct fi
- return count;
- }
-
--#ifdef MODULE
- module_init (tn7atm_detect);
- module_exit (tn7atm_exit);
--#endif /* MODULE */
---- a/tn7atm.h
-+++ b/tn7atm.h
-@@ -20,7 +20,8 @@
- //#include "mips_support.h"
- #include <linux/list.h>
-
--#include <linux/config.h>
-+#define MIPS_EXCEPTION_OFFSET 8
-+#define LNXINTNUM(x)((x) + MIPS_EXCEPTION_OFFSET)
-
- #ifdef CONFIG_MODVERSIONS
- #include <linux/modversions.h>
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -102,7 +102,6 @@
- * UR8_MERGE_END CQ11813
- * 09/18/07 CPH CQ11466: Added EFM support.
- *********************************************************************************************/
--#include <linux/config.h>
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <linux/init.h>
-@@ -110,8 +109,6 @@
- #include <linux/delay.h>
- #include <linux/spinlock.h>
- #include <linux/smp_lock.h>
--#include <asm/io.h>
--#include <asm/mips-boards/prom.h>
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
-@@ -119,6 +116,12 @@
- #include <linux/timer.h>
- #include <linux/vmalloc.h>
- #include <linux/file.h>
-+#include <linux/firmware.h>
-+
-+#include <asm/io.h>
-+#include <asm/ar7/ar7.h>
-+#include <asm/ar7/prom.h>
-+
- /* Modules specific header files */
- #ifdef AR7_EFM
- #include "tn7efm.h"
-@@ -185,7 +188,7 @@ led_reg_t ledreg[2];
- static struct led_funcs ledreg[2];
- #endif
-
--#define DEV_DSLMOD 1
-+#define DEV_DSLMOD CTL_UNNUMBERED
- #define MAX_STR_SIZE 256
- #define DSL_MOD_SIZE 256
-
-@@ -316,7 +319,7 @@ static PITIDSLHW_T pIhw;
- static volatile int bshutdown;
- static char info[MAX_STR_SIZE];
- /* Used for DSL Polling enable */
--static DECLARE_MUTEX_LOCKED (adsl_sem_overlay);
-+static struct semaphore adsl_sem_overlay;
-
- //kthread_t overlay_thread;
- /* end of module wide declars */
-@@ -369,6 +372,14 @@ int os_atoih (const char *pstr)
- return val;
- }
-
-+int avalanche_request_intr_pacing(int irq_nr, unsigned int blk_num,
-+ unsigned int pace_value)
-+{
-+ printk("avalanche_request_pacing(%d, %u, %u); // not implemented\n", irq_nr, blk_num, pace_value);
-+ return 0;
-+}
-+
-+
- int os_atoi(const char *pStr)
- {
- int MulNeg = (*pStr == '-' ? -1 : 1);
-@@ -405,39 +416,6 @@ void dprintf (int uDbgLevel, char *szFmt
- #endif
- }
-
--int strcmp(const char *s1, const char *s2)
--{
--
-- int size = strlen(s1);
--
-- return(strncmp(s1, s2, size));
--}
--
--int strncmp(const char *s1, const char *s2, size_t size)
--{
-- int i = 0;
-- int max_size = (int)size;
--
-- while((s1[i] != 0) && i < max_size)
-- {
-- if(s2[i] == 0)
-- {
-- return -1;
-- }
-- if(s1[i] != s2[i])
-- {
-- return 1;
-- }
-- i++;
-- }
-- if(s2[i] != 0)
-- {
-- return 1;
-- }
--
-- return 0;
--}
--
- // * UR8_MERGE_START CQ10640 Jack Zhang
- int tn7dsl_dump_dsp_memory(char *input_str) //cph99
- {
-@@ -487,144 +465,78 @@ unsigned int shim_osGetCpuFrequency(void
- return CpuFrequency;
- }
-
--int shim_osLoadFWImage(unsigned char *ptr)
-+static void avsar_release(struct device *dev)
- {
-- unsigned int bytesRead;
-- mm_segment_t oldfs;
-- static struct file *filp;
-- unsigned int imageLength=0x5ffff;
--
--#ifdef AR7_EFM
-- int dp_alt=0;
-- char *ptr1=NULL;
--#ifdef EFM_DEBUG
-- char *ptr2=NULL;
-- char *ptr3=NULL;
--#endif
--
-- if ((ptr1 = prom_getenv("DSL_DP_ALT")) != NULL)
-- {
-- dp_alt=os_atoi(ptr1);
-- if (dp_alt==1)
-- {
-- filp = filp_open(DSP_DEBUG_FIRMWARE_PATH,00,O_RDONLY);
-- if (!IS_ERR(filp))
-- {
-- strcpy (DSP_FIRMWARE_PATH, DSP_DEBUG_FIRMWARE_PATH);
-- }
-- }
--#ifdef EFM_DEBUG
-- else if (dp_alt==2)
-- {
-- if ((ptr2 = prom_getenv("DSL_DP")) != NULL)
-- {
-- if (!strncmp(ptr2, "DSL_DP", 6))
-- { // indirect naming
-- if ((ptr3 = prom_getenv(ptr2)) != NULL)
-- filp = filp_open(ptr3,00,O_RDONLY);
-- ptr2 = ptr3; // redirect ptr2 to ptr3
-- }
--
-- filp = filp_open(ptr2,00,O_RDONLY);
-- if (!IS_ERR(filp))
-- {
-- strcpy (DSP_FIRMWARE_PATH, ptr2);
-- }
-- }
-- }
-- printk("dp_path=%s\n", DSP_FIRMWARE_PATH);
--#endif
-- }
--#endif
--
-- dgprintf(4, "tn7dsl_read_dsp()\n");
--
-- dgprintf(4,"open file %s\n", DSP_FIRMWARE_PATH);
--
-- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
-- if(IS_ERR(filp))
-- {
-- printk("Failed: Could not open DSP binary file\n");
-- return -1;
-- }
--
-- if (filp->f_dentry != NULL)
-- {
-- if (filp->f_dentry->d_inode != NULL)
-- {
-- printk ("DSP binary filesize = %d bytes\n",
-- (int) filp->f_dentry->d_inode->i_size);
-- imageLength = (unsigned int)filp->f_dentry->d_inode->i_size + 0x200;
-- }
-- }
--
-- if (filp->f_op->read==NULL)
-- return -1; /* File(system) doesn't allow reads */
--
-- /*
-- * Disable parameter checking
-- */
-- oldfs = get_fs();
-- set_fs(KERNEL_DS);
--
-- /*
-- * Now read bytes from postion "StartPos"
-- */
-- filp->f_pos = 0;
--
-- bytesRead = filp->f_op->read(filp,ptr,imageLength,&filp->f_pos);
--
-- dgprintf(4,"file length = %d\n", bytesRead);
--
-- set_fs(oldfs);
--
-- /*
-- * Close the file
-- */
-- fput(filp);
--
-- return bytesRead;
-+ printk(KERN_DEBUG "avsar firmware released\n");
- }
-
-+static struct device avsar = {
-+ .bus_id = "vlynq",
-+ .release = avsar_release,
-+};
-
--unsigned int shim_read_overlay_page (void *ptr, unsigned int secOffset,
-- unsigned int secLength)
-+int shim_osLoadFWImage(unsigned char *ptr)
- {
-- unsigned int bytesRead;
-- mm_segment_t oldfs;
-- struct file *filp;
--
-- dgprintf(4,"shim_read_overlay_page\n");
-- //dgprintf(4,"sec offset=%d, sec length =%d\n", secOffset, secLength);
-+ const struct firmware *fw_entry;
-+ size_t size;
-
-- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
-- if(filp ==NULL)
-- {
-- printk("Failed: Could not open DSP binary file\n");
-- return -1;
-- }
--
-- if (filp->f_op->read==NULL)
-- return -1; /* File(system) doesn't allow reads */
--
-- /*
-- * Now read bytes from postion "StartPos"
-- */
-+ printk("requesting firmware image \"ar0700xx.bin\"\n");
-+ if(device_register(&avsar) < 0) {
-+ printk(KERN_ERR
-+ "avsar: device_register fails\n");
-+ return -1;
-+ }
-+
-+ if (request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
-+ printk(KERN_ERR
-+ "avsar: Firmware not available\n");
-+ device_unregister(&avsar);
-+ return -1;
-+ }
-+ size = fw_entry->size;
-+ device_unregister(&avsar);
-+ if (size > 0x6ffff) {
-+ printk(KERN_ERR
-+ "avsar: Firmware too big (%d bytes)\n", size);
-+ release_firmware(fw_entry);
-+ return -1;
-+ }
-+ memcpy(ptr, fw_entry->data, size);
-+ release_firmware(fw_entry);
-+ return size;
-+}
-+
-+unsigned int shim_read_overlay_page(void *ptr, unsigned int secOffset, unsigned int secLength)
-+{
-+ const struct firmware *fw_entry;
-+
-+ printk("requesting firmware image \"ar0700xx.bin\"\n");
-+ if (device_register(&avsar) < 0) {
-+ printk(KERN_ERR
-+ "avsar: device_register fails\n");
-+ return -1;
-+ }
-+
-+ if (request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
-+ printk(KERN_ERR
-+ "avsar: Firmware not available\n");
-+ device_unregister(&avsar);
-+ return -1;
-+ }
-+
-+ device_unregister(&avsar);
-+ if (fw_entry->size > secLength) {
-+ printk(KERN_ERR
-+ "avsar: Firmware too big (%d bytes)\n", fw_entry->size);
-+ release_firmware(fw_entry);
-+ return -1;
-+ }
-+ memcpy(ptr + secOffset, fw_entry->data, secLength);
-+ release_firmware(fw_entry);
-+ return secLength;
-+}
-
-- if(filp->f_op->llseek)
-- filp->f_op->llseek(filp,secOffset, 0);
-- oldfs = get_fs();
-- set_fs(KERNEL_DS);
-- filp->f_pos = secOffset;
-- bytesRead = filp->f_op->read(filp,ptr,secLength,&filp->f_pos);
-
-- set_fs(oldfs);
-- /*
-- * Close the file
-- */
-- fput(filp);
-- return bytesRead;
--}
-
- int shim_osLoadDebugFWImage(unsigned char *ptr)
- {
-@@ -3287,6 +3199,7 @@ int tn7dsl_init(void *priv)
- int high_precision_selected = 0;
- // UR8_MERGE_END CQ11054*
-
-+ sema_init(&adsl_sem_overlay, 0);
- /*
- * start dsl
- */
-@@ -3665,7 +3578,7 @@ static int dslmod_sysctl(ctl_table *ctl,
- */
- if(write)
- {
-- ret = proc_dostring(ctl, write, filp, buffer, lenp);
-+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
-
- switch (ctl->ctl_name)
- {
-@@ -3751,14 +3664,14 @@ static int dslmod_sysctl(ctl_table *ctl,
- else
- {
- len += sprintf(info+len, mod_req);
-- ret = proc_dostring(ctl, write, filp, buffer, lenp);
-+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
- }
- return ret;
- }
-
-
- ctl_table dslmod_table[] = {
-- {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, &dslmod_sysctl}
-+ {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
- ,
- {0}
- };
-@@ -3781,8 +3694,7 @@ void tn7dsl_dslmod_sysctl_register(void)
- if (initialized == 1)
- return;
-
-- dslmod_sysctl_header = register_sysctl_table(dslmod_root_table, 1);
-- dslmod_root_table->child->de->owner = THIS_MODULE;
-+ dslmod_sysctl_header = register_sysctl_table(dslmod_root_table);
-
- /*
- * set the defaults
---- a/tn7sar.c
-+++ b/tn7sar.c
-@@ -43,7 +43,6 @@
- * 09/18/07 CPH CQ11466: Added EFM support.
- *******************************************************************************/
-
--#include <linux/config.h>
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <linux/init.h>
-@@ -51,12 +50,13 @@
- #include <linux/delay.h>
- #include <linux/spinlock.h>
- #include <linux/smp_lock.h>
--#include <asm/io.h>
--#include <asm/mips-boards/prom.h>
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
-
-+#include <asm/io.h>
-+#include <asm/ar7/ar7.h>
-+#include <asm/ar7/prom.h>
-
- #define _CPHAL_AAL5
- #define _CPHAL_SAR
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/110-interrupt_fix.patch b/package/system/ar7-atm/patches-D7.05.01.00/110-interrupt_fix.patch
deleted file mode 100644
index 1122457691..0000000000
--- a/package/system/ar7-atm/patches-D7.05.01.00/110-interrupt_fix.patch
+++ /dev/null
@@ -1,37 +0,0 @@
---- a/tn7atm.c
-+++ b/tn7atm.c
-@@ -633,7 +633,7 @@ static int turbodsl_check_priority_type(
- * Description: tnetd73xx SAR interrupt.
- *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
--static void tn7atm_sar_irq (int irq, void *voiddev, struct pt_regs *regs)
-+static irqreturn_t tn7atm_sar_irq (int irq, void *voiddev)
- {
- struct atm_dev *atmdev;
- Tn7AtmPrivate *priv;
-@@ -660,6 +660,7 @@ static void tn7atm_sar_irq (int irq, voi
- #ifdef TIATM_INST_SUPP
- psp_trace_par (ATM_DRV_SAR_ISR_EXIT, retval);
- #endif
-+ return IRQ_HANDLED;
- }
-
- /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-@@ -669,7 +670,7 @@ static void tn7atm_sar_irq (int irq, voi
- * Description: tnetd73xx DSL interrupt.
- *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
--static void tn7atm_dsl_irq (int irq, void *voiddev, struct pt_regs *regs)
-+static irqreturn_t tn7atm_dsl_irq (int irq, void *voiddev)
- {
- struct atm_dev *atmdev;
- Tn7AtmPrivate *priv;
-@@ -691,6 +692,8 @@ static void tn7atm_dsl_irq (int irq, voi
- #ifdef TIATM_INST_SUPP
- psp_trace_par (ATM_DRV_DSL_ISR_EXIT, retval);
- #endif
-+
-+ return IRQ_HANDLED;
- }
-
- /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/120-no_dumb_inline.patch b/package/system/ar7-atm/patches-D7.05.01.00/120-no_dumb_inline.patch
deleted file mode 100644
index e9d99dff42..0000000000
--- a/package/system/ar7-atm/patches-D7.05.01.00/120-no_dumb_inline.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/tn7api.h
-+++ b/tn7api.h
-@@ -118,7 +118,7 @@ int tn7dsl_proc_dbgmsg_write(struct file
- int tn7dsl_proc_dbgmsg_read(char* buf, char **start, off_t offset, int count,int *eof, void *data);
- #endif
- //UR8_MERGE_END CQ11813
--inline int tn7dsl_handle_interrupt(void);
-+int tn7dsl_handle_interrupt(void);
-
- void tn7dsl_dslmod_sysctl_register(void);
- void tn7dsl_dslmod_sysctl_unregister(void);
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/130-powercutback.patch b/package/system/ar7-atm/patches-D7.05.01.00/130-powercutback.patch
deleted file mode 100644
index 415486482e..0000000000
--- a/package/system/ar7-atm/patches-D7.05.01.00/130-powercutback.patch
+++ /dev/null
@@ -1,44 +0,0 @@
---- a/dsl_hal_advcfg.c
-+++ b/dsl_hal_advcfg.c
-@@ -36,9 +36,9 @@
- * 05Jul05 0.00.09 CPH CQ9775: Change dslhal_advcfg_configDsTones input parameters & support for ADSL2+
- * 24Jul05 0.00.10 CPH Fixed comments in dslhal_advcfg_configDsTones function header
- *******************************************************************************/
--#include <dev_host_interface.h>
--#include <dsl_hal_register.h>
--#include <dsl_hal_support.h>
-+#include "dev_host_interface.h"
-+#include "dsl_hal_register.h"
-+#include "dsl_hal_support.h"
-
- /*****************************************************************************/
- /* ACT API functions -- To be moved into their own independent module --RamP */
---- a/Makefile
-+++ b/Makefile
-@@ -4,6 +4,7 @@
-
- CONFIG_SANGAM_ATM=m
- #EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
--EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
-+#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
-+EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
- obj-$(CONFIG_SANGAM_ATM) := tiatm.o
--tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
-+tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -3053,6 +3053,14 @@ static int tn7dsl_set_dsl(void)
- dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
- }
-
-+ // set powercutback
-+ ptr = NULL;
-+ ptr = prom_getenv("powercutback");
-+ if(ptr)
-+ {
-+ dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
-+ }
-+
- // trellis
- ptr = NULL;
- ptr = prom_getenv("trellis");
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/140-debug_mode.patch b/package/system/ar7-atm/patches-D7.05.01.00/140-debug_mode.patch
deleted file mode 100644
index 3873827afc..0000000000
--- a/package/system/ar7-atm/patches-D7.05.01.00/140-debug_mode.patch
+++ /dev/null
@@ -1,16 +0,0 @@
---- a/tn7sar.c
-+++ b/tn7sar.c
-@@ -125,10 +125,10 @@ enum
- //09/05/07: cph, move to tn7atm.h
- // #define RESERVED_OAM_CHANNEL 15
-
--#define AAL5_PARM "id=aal5, base = 0x03000000, offset = 0, int_line=15, ch0=[RxBufSize=1522; RxNumBuffers = 32; RxServiceMax = 50; TxServiceMax=50; TxNumBuffers=32; CpcsUU=0x5aa5; TxVc_CellRate=0x3000; TxVc_AtmHeader=0x00000640]"
--#define SAR_PARM "id=sar,base = 0x03000000, reset_bit = 9, offset = 0; UniNni = 0, PdspEnable = 1"
-+#define CH0_PARM "RxBufSize=1522, RxNumBuffers=32, RxServiceMax=50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
-+#define AAL5_PARM "id=aal5, base=0x03000000, offset=0, int_line=15, ch0=[" CH0_PARM "]"
-+#define SAR_PARM "id=sar, base=0x03000000, reset_bit=9, offset=0; UniNni=0, PdspEnable=1, Debug=0xFFFFFFFF"
- #define RESET_PARM "id=ResetControl, base=0xA8611600"
--#define CH0_PARM "RxBufSize=1522, RxNumBuffers = 32, RxServiceMax = 50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
-
- #define MAX_PVC_TABLE_ENTRY 16
-
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/150-tasklet_mode.patch b/package/system/ar7-atm/patches-D7.05.01.00/150-tasklet_mode.patch
deleted file mode 100644
index 97b8cecdd9..0000000000
--- a/package/system/ar7-atm/patches-D7.05.01.00/150-tasklet_mode.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/Makefile
-+++ b/Makefile
-@@ -5,6 +5,7 @@
- CONFIG_SANGAM_ATM=m
- #EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
- #EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
--EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
-+#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
-+EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL -DCPATM_TASKLET_MODE
- obj-$(CONFIG_SANGAM_ATM) := tiatm.o
- tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/160-module-params.patch b/package/system/ar7-atm/patches-D7.05.01.00/160-module-params.patch
deleted file mode 100644
index 75a41d1e36..0000000000
--- a/package/system/ar7-atm/patches-D7.05.01.00/160-module-params.patch
+++ /dev/null
@@ -1,675 +0,0 @@
---- a/tn7atm.c
-+++ b/tn7atm.c
-@@ -95,6 +95,146 @@
- MODULE_LICENSE("GPL");
- MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
- MODULE_AUTHOR ("Zhicheng Tang");
-+
-+int mp_sar_ipacemax = -1;
-+module_param_named(ipacemax, mp_sar_ipacemax, int, 0);
-+MODULE_PARM_DESC(ipacemax, "Interrupt pacing");
-+
-+char *mp_macc = NULL;
-+module_param_named(macc, mp_macc, charp, 0);
-+MODULE_PARM_DESC(macc, "MAC address");
-+
-+int mp_dsp_noboost = -1;
-+module_param_named(dsp_noboost, mp_dsp_noboost, int, 0);
-+MODULE_PARM_DESC(dsp_noboost, "Suppress DSP frequency boost");
-+
-+int mp_dsp_freq = -1;
-+module_param_named(dsp_freq, mp_dsp_freq, int, 0);
-+MODULE_PARM_DESC(dsp_freq, "Frequency to boost the DSP to");
-+
-+char *mp_featctl0 = NULL;
-+module_param_named(featctl0, mp_featctl0, charp, 0);
-+MODULE_PARM_DESC(featctl0, "DSL feature control 0");
-+
-+char *mp_featctl1 = NULL;
-+module_param_named(featctl1, mp_featctl1, charp, 0);
-+MODULE_PARM_DESC(featctl1, "DSL feature control 1");
-+
-+char *mp_phyctl0 = NULL;
-+module_param_named(phyctl0, mp_phyctl0, charp, 0);
-+MODULE_PARM_DESC(phyctl0, "DSL PHY control 0");
-+
-+char *mp_phyctl1 = NULL;
-+module_param_named(phyctl1, mp_phyctl1, charp, 0);
-+MODULE_PARM_DESC(phyctl1, "DSL PHY control 1");
-+
-+int mp_turbodsl = -1;
-+module_param_named(turbodsl, mp_turbodsl, int, 0);
-+MODULE_PARM_DESC(turbodsl, "Enable TurboDSL");
-+
-+int mp_sar_rxbuf = -1;
-+module_param_named(sar_rxbuf, mp_sar_rxbuf, int, 0);
-+MODULE_PARM_DESC(sar_rxbuf, "SAR RxBuf size");
-+
-+int mp_sar_rxmax = -1;
-+module_param_named(sar_rxmax, mp_sar_rxmax, int, 0);
-+MODULE_PARM_DESC(sar_rxmax, "SAR RxMax size");
-+
-+int mp_sar_txbuf = -1;
-+module_param_named(sar_txbuf, mp_sar_txbuf, int, 0);
-+MODULE_PARM_DESC(sar_txbuf, "SAR TxBuf size");
-+
-+int mp_sar_txmax = -1;
-+module_param_named(sar_txmax, mp_sar_txmax, int, 0);
-+MODULE_PARM_DESC(sar_txmax, "SAR TxMax size");
-+
-+char *mp_modulation = NULL;
-+module_param_named(modulation, mp_modulation, charp, 0);
-+MODULE_PARM_DESC(modulation, "Modulation");
-+
-+int mp_fine_gain_control = -1;
-+module_param_named(fine_gain_control, mp_fine_gain_control, int, 0);
-+MODULE_PARM_DESC(fine_gain_control, "Fine gain control");
-+
-+int mp_fine_gain_value = -1;
-+module_param_named(fine_gain_value, mp_fine_gain_value, int, 0);
-+MODULE_PARM_DESC(fine_gain_value, "Fine gain value");
-+
-+int mp_enable_margin_retrain = -1;
-+module_param_named(enable_margin_retrain, mp_enable_margin_retrain, int, 0);
-+MODULE_PARM_DESC(enable_margin_retrain, "Enable margin retrain");
-+
-+int mp_margin_threshold = -1;
-+module_param_named(margin_threshold, mp_margin_threshold, int, 0);
-+MODULE_PARM_DESC(margin_threshold, "Margin retrain treshold");
-+
-+int mp_enable_rate_adapt = -1;
-+module_param_named(enable_rate_adapt, mp_enable_rate_adapt, int, 0);
-+MODULE_PARM_DESC(enable_rate_adapt, "Enable rate adaption");
-+
-+int mp_powercutback = -1;
-+module_param_named(powercutback, mp_powercutback, int, 0);
-+MODULE_PARM_DESC(powercutback, "Enable / disable powercutback");
-+
-+int mp_trellis = -1;
-+module_param_named(trellis, mp_trellis, int, 0);
-+MODULE_PARM_DESC(trellis, "Enable / disable trellis coding");
-+
-+int mp_bitswap = -1;
-+module_param_named(bitswap, mp_bitswap, int, 0);
-+MODULE_PARM_DESC(bitswap, "Enable / disable bitswap");
-+
-+int mp_maximum_bits_per_carrier = -1;
-+module_param_named(maximum_bits_per_carrier, mp_maximum_bits_per_carrier, int, 0);
-+MODULE_PARM_DESC(maximum_bits_per_carrier, "Maximum bits per carrier");
-+
-+int mp_maximum_interleave_depth = -1;
-+module_param_named(maximum_interleave_depth, mp_maximum_interleave_depth, int, 0);
-+MODULE_PARM_DESC(maximum_interleave_depth, "Maximum interleave depth");
-+
-+int mp_pair_selection = -1;
-+module_param_named(pair_selection, mp_pair_selection, int, 0);
-+MODULE_PARM_DESC(pair_selection, "Pair selection");
-+
-+int mp_dgas_polarity = -1;
-+module_param_named(dgas_polarity, mp_dgas_polarity, int, 0);
-+MODULE_PARM_DESC(dgas_polarity, "DGAS polarity");
-+
-+int mp_los_alarm = -1;
-+module_param_named(los_alarm, mp_los_alarm, int, 0);
-+MODULE_PARM_DESC(los_alarm, "LOS alarm");
-+
-+char *mp_eoc_vendor_id = NULL;
-+module_param_named(eoc_vendor_id, mp_eoc_vendor_id, charp, 0);
-+MODULE_PARM_DESC(eoc_vendor_id, "EOC vendor id");
-+
-+int mp_eoc_vendor_revision = -1;
-+module_param_named(eoc_vendor_revision, mp_eoc_vendor_revision, int, 0);
-+MODULE_PARM_DESC(eoc_vendor_revision, "EOC vendor revision");
-+
-+char *mp_eoc_vendor_serialnum = NULL;
-+module_param_named(eoc_vendor_serialnum, mp_eoc_vendor_serialnum, charp, 0);
-+MODULE_PARM_DESC(eoc_vendor_serialnum, "EOC vendor serial number");
-+
-+char *mp_invntry_vernum = NULL;
-+module_param_named(invntry_vernum, mp_invntry_vernum, charp, 0);
-+MODULE_PARM_DESC(invntry_vernum, "Inventory revision number");
-+
-+int mp_dsl_bit_tmode = -1;
-+module_param_named(dsl_bit_tmode, mp_dsl_bit_tmode, int, 0);
-+MODULE_PARM_DESC(dsl_bit_tmode, "DSL bit training mode");
-+
-+int mp_high_precision = -1;
-+module_param_named(high_precision, mp_high_precision, int, 0);
-+MODULE_PARM_DESC(high_precision, "High precision");
-+
-+int mp_autopvc_enable = -1;
-+module_param_named(autopvc_enable, mp_autopvc_enable, int, 0);
-+MODULE_PARM_DESC(autopvc_enable, "Enable / disable automatic PVC");
-+
-+int mp_oam_lb_timeout = -1;
-+module_param_named(oam_lb_timeout, mp_oam_lb_timeout, int, 0);
-+MODULE_PARM_DESC(oam_lb_timeout, "OAM LB timeout");
- #endif
-
- #ifndef TRUE
-@@ -728,9 +868,9 @@
- * interrupt pacing
- */
- ptr = prom_getenv ("sar_ipacemax");
-- if (ptr)
-+ if (ptr || mp_sar_ipacemax != -1)
- {
-- def_sar_inter_pace = os_atoi (ptr);
-+ def_sar_inter_pace = mp_sar_ipacemax == -1 ? os_atoi (ptr) : mp_sar_ipacemax;
- }
- /* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
- def_sar_inter_pace); */
-@@ -878,9 +1018,18 @@
- {
- int i;
- char esi_addr[ESI_LEN] = { 0x00, 0x00, 0x11, 0x22, 0x33, 0x44 };
-- char *esiaddr_str = NULL;
-+ char *esiaddr_str = mp_macc;
-
-- esiaddr_str = prom_getenv ("macc");
-+ if (esiaddr_str == NULL)
-+ esiaddr_str = prom_getenv ("macdsl");
-+ if (esiaddr_str == NULL)
-+ esiaddr_str = prom_getenv ("macc");
-+ if (esiaddr_str == NULL)
-+ esiaddr_str = prom_getenv ("HWA_1");
-+ if (esiaddr_str == NULL)
-+ esiaddr_str = prom_getenv ("macb");
-+ if (esiaddr_str == NULL)
-+ esiaddr_str = prom_getenv ("maca");
-
- if (!esiaddr_str)
- {
-@@ -2139,15 +2288,15 @@
- //UR8_MERGE_END CQ10450*
-
- cp = prom_getenv ("dsp_noboost");
-- if (cp)
-+ if (cp || mp_dsp_noboost != -1)
- {
-- dsp_noboost = os_atoi (cp);
-+ dsp_noboost = mp_dsp_noboost == -1 ? os_atoi (cp) : mp_dsp_noboost;
- }
-
- cp = (char *) prom_getenv ("dsp_freq");
-- if (cp)
-+ if (cp || mp_dsp_freq != -1)
- {
-- dspfreq = os_atoi (cp);
-+ dspfreq = mp_dsp_freq == -1 ? os_atoi (cp) : mp_dsp_freq;
- if (dspfreq == 250)
- {
- boostDsp = 1;
-@@ -2396,15 +2545,17 @@
- // Inter-Op DSL phy Control
- // Note the setting of _dsl_Feature_0 and _dsl_Feature_1 must before
- // dslhal_api_dslStartup (in tn7dsl_init()).
-- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL)
-+ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL || mp_featctl0 != NULL)
- {
-- _dsl_Feature_0 = os_atoih (ptr);
-+ if (mp_featctl0 != NULL) ptr = mp_featctl0;
-+ _dsl_Feature_0 = os_atoh (ptr);
- _dsl_Feature_0_defined = 1;
- }
-
-- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL)
-+ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL || mp_featctl1 != NULL)
- {
-- _dsl_Feature_1 = os_atoih (ptr);
-+ if (mp_featctl1 != NULL) ptr = mp_featctl1;
-+ _dsl_Feature_1 = os_atoh (ptr);
- _dsl_Feature_1_defined = 1;
- }
-
-@@ -2412,15 +2563,17 @@
- // DSL phy Feature Control
- // Note the setting of _dsl_PhyControl_0 and _dsl_PhyControl_1 must before
- // dslhal_api_dslStartup (in tn7dsl_init()).
-- if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL)
-+ if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL || mp_phyctl0 != NULL)
- {
-- _dsl_PhyControl_0 = os_atoih (ptr);
-+ if (mp_phyctl0 != NULL) ptr = mp_phyctl0;
-+ _dsl_PhyControl_0 = os_atoh (ptr);
- _dsl_PhyControl_0_defined = 1;
- }
-
-- if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL)
-+ if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL || mp_phyctl1 != NULL)
- {
-- _dsl_PhyControl_1 = os_atoih (ptr);
-+ if (mp_phyctl1 != NULL) ptr = mp_phyctl1;
-+ _dsl_PhyControl_1 = os_atoh (ptr);
- _dsl_PhyControl_1_defined = 1;
- }
-
-@@ -2440,12 +2593,12 @@
- // read config for turbo dsl
-
- ptr = prom_getenv ("TurboDSL");
-- if (ptr)
-+ if (ptr || mp_turbodsl != -1)
- {
- #if 1 //[KT]
- bTurboDsl = os_atoi (ptr);
- #else
-- priv->bTurboDsl = os_atoi (ptr);
-+ priv->bTurboDsl = mp_turbodsl == -1 ? os_atoi (ptr) : mp_turbodsl;
- #endif
- }
- else
-@@ -2459,33 +2612,33 @@
- priv->sarRxBuf = RX_BUFFER_NUM;
- ptr = NULL;
- ptr = prom_getenv ("SarRxBuf");
-- if (ptr)
-+ if (ptr || mp_sar_rxbuf != -1)
- {
-- priv->sarRxBuf = os_atoi (ptr);
-+ priv->sarRxBuf = mp_sar_rxbuf == -1 ? os_atoi (ptr) : mp_sar_rxbuf;
- }
-
- priv->sarRxMax = RX_SERVICE_MAX;
- ptr = NULL;
- ptr = prom_getenv ("SarRxMax");
-- if (ptr)
-+ if (ptr || mp_sar_rxmax != -1)
- {
-- priv->sarRxMax = os_atoi (ptr);
-+ priv->sarRxMax = mp_sar_rxmax == -1 ? os_atoi (ptr) : mp_sar_rxmax;
- }
-
- priv->sarTxBuf = TX_BUFFER_NUM;
- ptr = NULL;
- ptr = prom_getenv ("SarTxBuf");
-- if (ptr)
-+ if (ptr || mp_sar_txbuf != -1)
- {
-- priv->sarTxBuf = os_atoi (ptr);
-+ priv->sarTxBuf = mp_sar_txbuf == -1 ? os_atoi (ptr) : mp_sar_txbuf;
- }
-
- priv->sarTxMax = TX_SERVICE_MAX;
- ptr = NULL;
- ptr = prom_getenv ("SarTxMax");
-- if (ptr)
-+ if (ptr || mp_sar_txmax != -1)
- {
-- priv->sarTxMax = os_atoi (ptr);
-+ priv->sarTxMax = mp_sar_txmax == -1 ? os_atoi (ptr) : mp_sar_txmax;
- }
-
- #ifdef AR7_EFM
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -148,6 +148,27 @@
- #define NEW_TRAINING_VAL_T1413 128
- #define NEW_TRAINING_VAL_MMODE 255
-
-+extern char *mp_modulation;
-+extern int mp_fine_gain_control;
-+extern int mp_fine_gain_value;
-+extern int mp_enable_margin_retrain;
-+extern int mp_margin_threshold;
-+extern int mp_enable_rate_adapt;
-+extern int mp_powercutback;
-+extern int mp_trellis;
-+extern int mp_bitswap;
-+extern int mp_maximum_bits_per_carrier;
-+extern int mp_maximum_interleave_depth;
-+extern int mp_pair_selection;
-+extern int mp_dgas_polarity;
-+extern int mp_los_alarm;
-+extern char *mp_eoc_vendor_id;
-+extern int mp_eoc_vendor_revision;
-+extern char *mp_eoc_vendor_serialnum;
-+extern char *mp_invntry_vernum;
-+extern int mp_dsl_bit_tmode;
-+extern int mp_high_precision;
-+
- int testflag1 = 0;
- extern int __guDbgLevel;
- extern sar_stat_t sarStat;
-@@ -2933,24 +2954,24 @@ static int tn7dsl_set_dsl(void)
- (unsigned char *) &oamFeature, 4);
-
- ptr = prom_getenv("DSL_FEATURE_CNTL_0");
-- if(!ptr)
-- prom_setenv("DSL_FEATURE_CNTL_0", "0x00004000");
-+ //if(!ptr)
-+ //prom_setenv("DSL_FEATURE_CNTL_0", "0x00004000");
-
- ptr = prom_getenv("DSL_FEATURE_CNTL_1");
-- if(!ptr)
-- prom_setenv("DSL_FEATURE_CNTL_1", "0x00000000");
-+ //if(!ptr)
-+ //prom_setenv("DSL_FEATURE_CNTL_1", "0x00000000");
-
- ptr = prom_getenv("DSL_PHY_CNTL_0");
-- if(!ptr)
-- prom_setenv("DSL_PHY_CNTL_0", "0x00000400");
-+ //if(!ptr)
-+ //prom_setenv("DSL_PHY_CNTL_0", "0x00000400");
-
- ptr = prom_getenv("enable_margin_retrain");
-- if(!ptr)
-- prom_setenv("enable_margin_retrain", "0");
-+ //if(!ptr)
-+ //prom_setenv("enable_margin_retrain", "0");
-
- ptr = prom_getenv("modulation");
-- if(!ptr)
-- prom_setenv("modulation", "0xbf");
-+ //if(!ptr)
-+ //prom_setenv("modulation", "0xbf");
-
- #define EOC_VENDOR_ID "4200534153000000"
- #define EOC_VENDOR_REVISION "FW370090708b1_55"
-@@ -2959,25 +2980,25 @@ static int tn7dsl_set_dsl(void)
- ptr = prom_getenv("eoc_vendor_id");
- if(!ptr || strcmp(ptr,EOC_VENDOR_ID) != 0 || strlen(ptr) != strlen(EOC_VENDOR_ID))
- {
-- if(ptr)
-- prom_unsetenv("eoc_vendor_id");
-- prom_setenv("eoc_vendor_id",EOC_VENDOR_ID);
-+ //if(ptr)
-+ //prom_unsetenv("eoc_vendor_id");
-+ //prom_setenv("eoc_vendor_id",EOC_VENDOR_ID);
- }
-
- ptr = prom_getenv("eoc_vendor_revision");
- if(!ptr || strcmp(ptr,EOC_VENDOR_REVISION) != 0 || strlen(ptr) != strlen(EOC_VENDOR_REVISION))
- {
-- if(ptr)
-- prom_unsetenv("eoc_vendor_revision");
-- prom_setenv("eoc_vendor_revision",EOC_VENDOR_REVISION);
-+ //if(ptr)
-+ //prom_unsetenv("eoc_vendor_revision");
-+ //prom_setenv("eoc_vendor_revision",EOC_VENDOR_REVISION);
- }
-
- ptr = prom_getenv("eoc_vendor_serialnum");
- if(!ptr || strcmp(ptr,EOC_VENDOR_SERIALNUM) != 0 || strlen(ptr) != strlen(EOC_VENDOR_SERIALNUM))
- {
-- if(ptr)
-- prom_unsetenv("eoc_vendor_serialnum");
-- prom_setenv("eoc_vendor_serialnum",EOC_VENDOR_SERIALNUM);
-+ //if(ptr)
-+ // prom_unsetenv("eoc_vendor_serialnum");
-+ //prom_setenv("eoc_vendor_serialnum",EOC_VENDOR_SERIALNUM);
- }
-
- /* Do only if we are in the new Base PSP 7.4.*/
-@@ -2994,92 +3015,88 @@ static int tn7dsl_set_dsl(void)
- we clear the modulation environment variable, as this could potentially
- not have the same meaning in the new mode.
- */
-- prom_unsetenv("modulation");
-- prom_setenv("DSL_UPG_DONE", "1");
-+ //prom_unsetenv("modulation");
-+ //prom_setenv("DSL_UPG_DONE", "1");
- }
- }
- #endif
-
- // modulation
- ptr = prom_getenv("modulation");
-- if (ptr)
-+ if (ptr || mp_modulation != NULL)
- {
-- tn7dsl_set_modulation(ptr, FALSE);
-+ tn7dsl_set_modulation(mp_modulation == NULL ? ptr : mp_modulation, FALSE);
- }
-
- // Fine Gains
- ptr = prom_getenv("fine_gain_control");
-- if (ptr)
-+ if (ptr || mp_fine_gain_control != -1)
- {
-- value = os_atoi(ptr);
-+ value = mp_fine_gain_control == -1 ? os_atoi(ptr) : mp_fine_gain_control;
- tn7dsl_ctrl_fineGain(value);
- }
- ptr = NULL;
- ptr = prom_getenv("fine_gain_value");
-- if(ptr)
-- tn7dsl_set_fineGainValue(os_atoh(ptr));
-+ if(ptr || mp_fine_gain_value != -1)
-+ tn7dsl_set_fineGainValue(mp_fine_gain_value == -1 ? os_atoh(ptr) : mp_fine_gain_value);
-
- // margin retrain
- ptr = NULL;
- ptr = prom_getenv("enable_margin_retrain");
-- if(ptr)
-+ value = mp_enable_margin_retrain == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_enable_margin_retrain;
-+
-+ if (value == 1)
- {
-- value = os_atoi(ptr);
-- if(value == 1)
-+ dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
-+ bMarginRetrainEnable = 1;
-+ //printk("enable showtime margin monitor.\n");
-+
-+ ptr = NULL;
-+ ptr = prom_getenv("margin_threshold");
-+ value = mp_margin_threshold == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_margin_threshold;
-+
-+ if(value >= 0)
- {
-- dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
-- bMarginRetrainEnable = 1;
-- //printk("enable showtime margin monitor.\n");
-- ptr = NULL;
-- ptr = prom_getenv("margin_threshold");
-- if(ptr)
-- {
-- value = os_atoi(ptr);
-- //printk("Set margin threshold to %d x 0.5 db\n",value);
-- if(value >= 0)
-- {
-- dslhal_api_setMarginThreshold(pIhw, value);
-- bMarginThConfig=1;
-- }
-- }
-+ dslhal_api_setMarginThreshold(pIhw, value);
-+ bMarginThConfig=1;
- }
- }
-
- // rate adapt
- ptr = NULL;
- ptr = prom_getenv("enable_rate_adapt");
-- if(ptr)
-+ if(ptr || mp_enable_rate_adapt != -1)
- {
-- dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
-+ dslhal_api_setRateAdaptFlag(pIhw, mp_enable_rate_adapt == -1 ? os_atoi(ptr) : mp_enable_rate_adapt);
- }
-
- // set powercutback
- ptr = NULL;
- ptr = prom_getenv("powercutback");
-- if(ptr)
-+ if(ptr || mp_powercutback != -1)
- {
-- dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
-+ dslhal_advcfg_onOffPcb(pIhw, mp_powercutback == -1 ? os_atoi(ptr) : mp_powercutback);
- }
-
- // trellis
- ptr = NULL;
- ptr = prom_getenv("trellis");
-- if(ptr)
-+ if(ptr || mp_trellis != -1)
- {
-- dslhal_api_setTrellisFlag(pIhw, os_atoi(ptr));
-- trellis = os_atoi(ptr);
-+ trellis = mp_trellis == -1 ? os_atoi(ptr) : mp_trellis;
-+ dslhal_api_setTrellisFlag(pIhw, trellis);
- //printk("trellis=%d\n");
- }
-
- // bitswap
- ptr = NULL;
- ptr = prom_getenv("bitswap");
-- if(ptr)
-+ if(ptr || mp_bitswap != -1)
- {
- int offset[2] = {33, 0};
- unsigned int bitswap;
-
-- bitswap = os_atoi(ptr);
-+ bitswap = mp_bitswap == -1 ? os_atoi(ptr) : mp_bitswap;
-
- tn7dsl_generic_read(2, offset);
- dslReg &= dslhal_support_byteSwap32(0xFFFFFF00);
-@@ -3097,46 +3114,47 @@ static int tn7dsl_set_dsl(void)
- // maximum bits per carrier
- ptr = NULL;
- ptr = prom_getenv("maximum_bits_per_carrier");
-- if(ptr)
-+ if(ptr || mp_maximum_bits_per_carrier != -1)
- {
-- dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, os_atoi(ptr));
-+ dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, mp_maximum_bits_per_carrier == -1 ? os_atoi(ptr) : mp_maximum_bits_per_carrier);
- }
-
- // maximum interleave depth
- ptr = NULL;
- ptr = prom_getenv("maximum_interleave_depth");
-- if(ptr)
-+ if(ptr || mp_maximum_interleave_depth != -1)
- {
-- dslhal_api_setMaxInterleaverDepth(pIhw, os_atoi(ptr));
-+ dslhal_api_setMaxInterleaverDepth(pIhw, mp_maximum_interleave_depth == -1 ? os_atoi(ptr) : mp_maximum_interleave_depth);
- }
-
- // inner and outer pairs
- ptr = NULL;
- ptr = prom_getenv("pair_selection");
-- if(ptr)
-+ if(ptr || mp_pair_selection != -1)
- {
-- dslhal_api_selectInnerOuterPair(pIhw, os_atoi(ptr));
-+ dslhal_api_selectInnerOuterPair(pIhw, mp_pair_selection == -1 ? os_atoi(ptr) : mp_pair_selection);
- }
-
- ptr = NULL;
- ptr = prom_getenv("dgas_polarity");
-- if(ptr)
-+ if(ptr || mp_dgas_polarity != -1)
- {
- dslhal_api_configureDgaspLpr(pIhw, 1, 1);
-- dslhal_api_configureDgaspLpr(pIhw, 0, os_atoi(ptr));
-+ dslhal_api_configureDgaspLpr(pIhw, 0, mp_dgas_polarity == -1 ? os_atoi(ptr) : mp_dgas_polarity);
- }
-
- ptr = NULL;
- ptr = prom_getenv("los_alarm");
-- if(ptr)
-+ if(ptr || mp_los_alarm != -1)
- {
-- dslhal_api_disableLosAlarm(pIhw, os_atoi(ptr));
-+ dslhal_api_disableLosAlarm(pIhw, mp_los_alarm == -1 ? os_atoi(ptr) : mp_los_alarm);
- }
-
- ptr = NULL;
- ptr = prom_getenv("eoc_vendor_id");
-- if(ptr)
-+ if(ptr || mp_eoc_vendor_id != NULL)
- {
-+ ptr = mp_eoc_vendor_id == NULL ? ptr : mp_eoc_vendor_id;
- for(i=0;i<8;i++)
- {
- tmp[0]=ptr[i*2];
-@@ -3161,26 +3179,26 @@ static int tn7dsl_set_dsl(void)
- }
- ptr = NULL;
- ptr = prom_getenv("eoc_vendor_revision");
-- if(ptr)
-+ if(ptr || mp_eoc_vendor_revision != -1)
- {
-- value = os_atoi(ptr);
-+ value = mp_eoc_vendor_revision == -1 ? os_atoi(ptr) : mp_eoc_vendor_revision;
- //printk("eoc rev=%d\n", os_atoi(ptr));
- dslhal_api_setEocRevisionNumber(pIhw, (char *)&value);
-
- }
- ptr = NULL;
- ptr = prom_getenv("eoc_vendor_serialnum");
-- if(ptr)
-+ if(ptr || mp_eoc_vendor_serialnum != NULL)
- {
-- dslhal_api_setEocSerialNumber(pIhw, ptr);
-+ dslhal_api_setEocSerialNumber(pIhw, mp_eoc_vendor_serialnum == NULL ? ptr : mp_eoc_vendor_serialnum);
- }
-
- // CQ10037 Added invntry_vernum environment variable to be able to set version number in ADSL2, ADSL2+ modes.
- ptr = NULL;
- ptr = prom_getenv("invntry_vernum");
-- if(ptr)
-+ if(ptr || mp_invntry_vernum != NULL)
- {
-- dslhal_api_setEocRevisionNumber(pIhw, ptr);
-+ dslhal_api_setEocRevisionNumber(pIhw, mp_invntry_vernum == NULL ? ptr : mp_invntry_vernum);
- }
-
- return 0;
-@@ -3225,7 +3243,7 @@ int tn7dsl_init(void *priv)
- * backward compatibility.
- */
- cp = prom_getenv("DSL_BIT_TMODE");
-- if (cp)
-+ if (cp || mp_dsl_bit_tmode != -1)
- {
- printk("%s : env var DSL_BIT_TMODE is set\n", __FUNCTION__);
- /*
-@@ -3254,9 +3272,9 @@ int tn7dsl_init(void *priv)
-
- // UR8_MERGE_START CQ11054 Jack Zhang
- cp = prom_getenv("high_precision");
-- if (cp)
-+ if (cp || mp_high_precision != -1)
- {
-- high_precision_selected = os_atoi(cp);
-+ high_precision_selected = mp_high_precision == -1 ? os_atoi(cp) : mp_high_precision;
- }
- if ( high_precision_selected)
- {
---- a/tn7sar.c
-+++ b/tn7sar.c
-@@ -76,6 +76,8 @@ typedef void OS_SETUP;
- #include "tn7atm.h"
- #include "tn7api.h"
-
-+extern int mp_oam_lb_timeout;
-+extern int mp_autopvc_enable;
-
- /* PDSP Firmware files */
- #include "tnetd7300_sar_firm.h"
-@@ -932,9 +934,9 @@ int tn7sar_setup_oam_channel(Tn7AtmPriva
- pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
-
- pauto_pvc = prom_getenv("autopvc_enable");
-- if(pauto_pvc) //CQ10273
-+ if(pauto_pvc || mp_autopvc_enable != -1) //CQ10273
- {
-- auto_pvc =tn7sar_strtoul(pauto_pvc, NULL, 10);
-+ auto_pvc = mp_autopvc_enable == -1 ? tn7sar_strtoul(pauto_pvc, NULL, 10) : mp_autopvc_enable;
- }
-
- memset(&chInfo, 0xff, sizeof(chInfo));
-@@ -1133,9 +1135,9 @@ int tn7sar_init(struct atm_dev *dev, Tn7
-
- /* read in oam lb timeout value */
- pLbTimeout = prom_getenv("oam_lb_timeout");
-- if(pLbTimeout)
-+ if(pLbTimeout || mp_oam_lb_timeout != -1)
- {
-- lbTimeout =tn7sar_strtoul(pLbTimeout, NULL, 10);
-+ lbTimeout = mp_oam_lb_timeout == -1 ? tn7sar_strtoul(pLbTimeout, NULL, 10) : mp_oam_lb_timeout;
- oamLbTimeout = lbTimeout;
- pHalFunc->Control(pHalDev,"OamLbTimeout", "Set", &lbTimeout);
- }
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/170-bus_id_removal.patch b/package/system/ar7-atm/patches-D7.05.01.00/170-bus_id_removal.patch
deleted file mode 100644
index 6692f40f6a..0000000000
--- a/package/system/ar7-atm/patches-D7.05.01.00/170-bus_id_removal.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -117,6 +117,7 @@
- #include <linux/vmalloc.h>
- #include <linux/file.h>
- #include <linux/firmware.h>
-+#include <linux/version.h>
-
- #include <asm/io.h>
- #include <asm/ar7/ar7.h>
-@@ -492,7 +493,9 @@ static void avsar_release(struct device
- }
-
- static struct device avsar = {
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
- .bus_id = "vlynq",
-+#endif
- .release = avsar_release,
- };
-
-@@ -501,6 +504,9 @@ int shim_osLoadFWImage(unsigned char *pt
- const struct firmware *fw_entry;
- size_t size;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
-+ dev_set_name(&avsar, "avsar");
-+#endif
- printk("requesting firmware image \"ar0700xx.bin\"\n");
- if(device_register(&avsar) < 0) {
- printk(KERN_ERR
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/180-git_headers_include.patch b/package/system/ar7-atm/patches-D7.05.01.00/180-git_headers_include.patch
deleted file mode 100644
index feb6ea8605..0000000000
--- a/package/system/ar7-atm/patches-D7.05.01.00/180-git_headers_include.patch
+++ /dev/null
@@ -1,54 +0,0 @@
---- a/tn7atm.c
-+++ b/tn7atm.c
-@@ -76,10 +76,16 @@
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
-+#include <linux/version.h>
-
- #include <asm/io.h>
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
- #include <asm/ar7/ar7.h>
- #include <asm/ar7/prom.h>
-+#else
-+#include <asm/mach-ar7/ar7.h>
-+#include <asm/mach-ar7/prom.h>
-+#endif
-
- #include "dsl_hal_api.h"
- #ifdef AR7_EFM
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -120,8 +120,13 @@
- #include <linux/version.h>
-
- #include <asm/io.h>
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
- #include <asm/ar7/ar7.h>
- #include <asm/ar7/prom.h>
-+#else
-+#include <asm/mach-ar7/ar7.h>
-+#include <asm/mach-ar7/prom.h>
-+#endif
-
- /* Modules specific header files */
- #ifdef AR7_EFM
---- a/tn7sar.c
-+++ b/tn7sar.c
-@@ -53,10 +53,16 @@
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
-+#include <linux/version.h>
-
- #include <asm/io.h>
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
- #include <asm/ar7/ar7.h>
- #include <asm/ar7/prom.h>
-+#else
-+#include <asm/mach-ar7/ar7.h>
-+#include <asm/mach-ar7/prom.h>
-+#endif
-
- #define _CPHAL_AAL5
- #define _CPHAL_SAR
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/190-2.6.32_proc_fixes.patch b/package/system/ar7-atm/patches-D7.05.01.00/190-2.6.32_proc_fixes.patch
deleted file mode 100644
index 52ebbc1529..0000000000
--- a/package/system/ar7-atm/patches-D7.05.01.00/190-2.6.32_proc_fixes.patch
+++ /dev/null
@@ -1,79 +0,0 @@
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -215,7 +215,11 @@ led_reg_t ledreg[2];
- static struct led_funcs ledreg[2];
- #endif
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
- #define DEV_DSLMOD CTL_UNNUMBERED
-+#else
-+#define DEV_DSLMOD 0
-+#endif
- #define MAX_STR_SIZE 256
- #define DSL_MOD_SIZE 256
-
-@@ -3615,9 +3619,16 @@ static int dslmod_sysctl(ctl_table *ctl,
- */
- if(write)
- {
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
- ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
--
-+#else
-+ ret = proc_dostring(ctl, write, buffer, lenp, 0);
-+#endif
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
- switch (ctl->ctl_name)
-+#else
-+ switch ((long)ctl->extra2)
-+#endif
- {
- case DEV_DSLMOD:
- ptr = strpbrk(info, " \t");
-@@ -3701,14 +3712,29 @@ static int dslmod_sysctl(ctl_table *ctl,
- else
- {
- len += sprintf(info+len, mod_req);
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
- ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
-+#else
-+ ret = proc_dostring(ctl, write, buffer, lenp, 0);
-+#endif
- }
- return ret;
- }
-
-
- ctl_table dslmod_table[] = {
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
- {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
-+#else
-+ {
-+ .procname = "dslmod",
-+ .data = info,
-+ .maxlen = DSL_MOD_SIZE,
-+ .mode = 0644,
-+ .proc_handler = &dslmod_sysctl,
-+ .extra2 = (void *)DEV_DSLMOD,
-+ }
-+#endif
- ,
- {0}
- };
-@@ -3716,7 +3742,16 @@ ctl_table dslmod_table[] = {
- /* Make sure that /proc/sys/dev is there */
- ctl_table dslmod_root_table[] = {
- #ifdef CONFIG_PROC_FS
-+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
- {CTL_DEV, "dev", NULL, 0, 0555, dslmod_table}
-+ #else
-+ {
-+ .procname = "dev",
-+ .maxlen = 0,
-+ .mode = 0555,
-+ .child = dslmod_table,
-+ }
-+ #endif
- ,
- #endif /* CONFIG_PROC_FS */
- {0}
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/200-2.6.37_args.patch b/package/system/ar7-atm/patches-D7.05.01.00/200-2.6.37_args.patch
deleted file mode 100644
index a3bff1b940..0000000000
--- a/package/system/ar7-atm/patches-D7.05.01.00/200-2.6.37_args.patch
+++ /dev/null
@@ -1,36 +0,0 @@
---- a/tn7atm.c
-+++ b/tn7atm.c
-@@ -2000,7 +2000,11 @@ static int __init tn7atm_register (Tn7At
-
- dgprintf (4, "device %s being registered\n", priv->name);
-
-+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
- mydev = atm_dev_register (priv->proc_name, &tn7atm_ops, -1, NULL);
-+ #else
-+ mydev = atm_dev_register (priv->proc_name, NULL, &tn7atm_ops, -1, NULL);
-+ #endif
-
- if (mydev == NULL)
- {
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -512,14 +512,17 @@ int shim_osLoadFWImage(unsigned char *pt
- {
- const struct firmware *fw_entry;
- size_t size;
-+ int ret;
-
- #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
- dev_set_name(&avsar, "avsar");
- #endif
- printk("requesting firmware image \"ar0700xx.bin\"\n");
-- if(device_register(&avsar) < 0) {
-+ dev_set_name(&avsar, "avsar");
-+ ret = device_register(&avsar);
-+ if (ret < 0) {
- printk(KERN_ERR
-- "avsar: device_register fails\n");
-+ "avsar: device_register fails, error%i\n", ret);
- return -1;
- }
-
diff --git a/package/system/ar7-atm/patches-D7.05.01.00/210-3.3-remove-smp_lock.h.patch b/package/system/ar7-atm/patches-D7.05.01.00/210-3.3-remove-smp_lock.h.patch
deleted file mode 100644
index 975ebaf299..0000000000
--- a/package/system/ar7-atm/patches-D7.05.01.00/210-3.3-remove-smp_lock.h.patch
+++ /dev/null
@@ -1,33 +0,0 @@
---- a/tn7atm.c
-+++ b/tn7atm.c
-@@ -72,7 +72,7 @@
- #include <linux/atmdev.h>
- #include <linux/delay.h>
- #include <linux/spinlock.h>
--#include <linux/smp_lock.h>
-+#include <linux/interrupt.h>
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
---- a/tn7sar.c
-+++ b/tn7sar.c
-@@ -49,7 +49,7 @@
- #include <linux/atmdev.h>
- #include <linux/delay.h>
- #include <linux/spinlock.h>
--#include <linux/smp_lock.h>
-+#include <linux/interrupt.h>
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
---- a/tn7dsl.c
-+++ b/tn7dsl.c
-@@ -108,7 +108,7 @@
- #include <linux/atmdev.h>
- #include <linux/delay.h>
- #include <linux/spinlock.h>
--#include <linux/smp_lock.h>
-+#include <linux/interrupt.h>
- #include <linux/proc_fs.h>
- #include <linux/string.h>
- #include <linux/ctype.h>
diff --git a/package/system/avila-wdt/Makefile b/package/system/avila-wdt/Makefile
deleted file mode 100644
index 5bf6bf4ad0..0000000000
--- a/package/system/avila-wdt/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Copyright (C) 2008 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-include $(INCLUDE_DIR)/kernel.mk
-
-PKG_NAME:=avila-wdt
-PKG_RELEASE:=1
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/avila-wdt
- SUBMENU:=Other modules
- TITLE:=GPIO hardware watchdog driver for modified Avila boards
- DEPENDS:=@GPIO_SUPPORT @TARGET_ixp4xx
- FILES:=$(PKG_BUILD_DIR)/avila-wdt.ko
- AUTOLOAD:=$(call AutoLoad,10,avila-wdt)
-endef
-
-MAKE_OPTS:= \
- ARCH="$(LINUX_KARCH)" \
- CROSS_COMPILE="$(TARGET_CROSS)" \
- SUBDIRS="$(PKG_BUILD_DIR)"
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
- $(CP) ./src/* $(PKG_BUILD_DIR)/
-endef
-
-define Build/Compile
- $(MAKE) -C "$(LINUX_DIR)" \
- $(MAKE_OPTS) \
- modules
-endef
-
-$(eval $(call KernelPackage,avila-wdt))
diff --git a/package/system/avila-wdt/src/Makefile b/package/system/avila-wdt/src/Makefile
deleted file mode 100644
index 90d90657ed..0000000000
--- a/package/system/avila-wdt/src/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-m := avila-wdt.o
diff --git a/package/system/avila-wdt/src/avila-wdt.c b/package/system/avila-wdt/src/avila-wdt.c
deleted file mode 100644
index 981f3857ad..0000000000
--- a/package/system/avila-wdt/src/avila-wdt.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * avila-wdt.c
- * Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
- *
- * 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@openwrt.org>");
-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);
-
diff --git a/package/system/brcm2708-gpu-fw/Makefile b/package/system/brcm2708-gpu-fw/Makefile
deleted file mode 100644
index 0b79cd15a9..0000000000
--- a/package/system/brcm2708-gpu-fw/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright (C) 2012 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:=brcm2708-gpu-fw
-PKG_REV:=d5b05be2147bf5dc0137798837af24b0bbbe398d
-PKG_VERSION:=20130517
-PKG_RELEASE:=1
-
-PKG_SOURCE:=$(PKG_REV).tar.gz
-PKG_SOURCE_URL:=https://github.com/Hexxeh/rpi-firmware/archive/
-PKG_MD5SUM:=9b0ce0a530e237f4c6fe43a36ccf57c3
-
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/rpi-firmware-$(PKG_REV)
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/brcm2708-gpu-fw
- SECTION:=boot
- CATEGORY:=Boot Loaders
- DEPENDS:=@TARGET_brcm2708
- TITLE:=brcm2708-gpu-fw
- DEFAULT:=y if (TARGET_brcm2708)
-endef
-
-define Package/brcm2708-gpu-fw/description
- GPU and kernel boot firmware for brcm2708.
-endef
-
-define Build/Compile
-endef
-
-define Build/InstallDev
- $(INSTALL_DIR) $(BUILD_DIR)/brcm2708-gpu-fw-boot
- $(CP) $(PKG_BUILD_DIR)/* $(BUILD_DIR)/brcm2708-gpu-fw-boot
-endef
-
-$(eval $(call BuildPackage,brcm2708-gpu-fw))
-
diff --git a/package/system/button-hotplug/Makefile b/package/system/button-hotplug/Makefile
deleted file mode 100644
index 348ea13401..0000000000
--- a/package/system/button-hotplug/Makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# Copyright (C) 2008-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)/kernel.mk
-
-PKG_NAME:=button-hotplug
-PKG_RELEASE:=3
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/button-hotplug
- SUBMENU:=Other modules
- TITLE:=Button Hotplug driver
- FILES:=$(PKG_BUILD_DIR)/button-hotplug.ko
- AUTOLOAD:=$(call AutoLoad,30,button-hotplug,1)
- KCONFIG:=
-endef
-
-define KernelPackage/button-hotplug/description
- Kernel module to generate button hotplug events
-endef
-
-EXTRA_KCONFIG:= \
- CONFIG_BUTTON_HOTPLUG=m
-
-EXTRA_CFLAGS:= \
- $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
- $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
-
-MAKE_OPTS:= \
- ARCH="$(LINUX_KARCH)" \
- CROSS_COMPILE="$(TARGET_CROSS)" \
- SUBDIRS="$(PKG_BUILD_DIR)" \
- EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
- $(EXTRA_KCONFIG)
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
- $(CP) ./src/* $(PKG_BUILD_DIR)/
-endef
-
-define Build/Compile
- $(MAKE) -C "$(LINUX_DIR)" \
- $(MAKE_OPTS) \
- modules
-endef
-
-$(eval $(call KernelPackage,button-hotplug))
diff --git a/package/system/button-hotplug/src/Kconfig b/package/system/button-hotplug/src/Kconfig
deleted file mode 100644
index aa292e9c13..0000000000
--- a/package/system/button-hotplug/src/Kconfig
+++ /dev/null
@@ -1,2 +0,0 @@
-config BUTTON_HOTPLUG
- tristate "Button Hotplug driver"
diff --git a/package/system/button-hotplug/src/Makefile b/package/system/button-hotplug/src/Makefile
deleted file mode 100644
index 230d604f8c..0000000000
--- a/package/system/button-hotplug/src/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-${CONFIG_BUTTON_HOTPLUG} += button-hotplug.o \ No newline at end of file
diff --git a/package/system/button-hotplug/src/button-hotplug.c b/package/system/button-hotplug/src/button-hotplug.c
deleted file mode 100644
index 4a8c4a88ed..0000000000
--- a/package/system/button-hotplug/src/button-hotplug.c
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- * Button Hotplug driver
- *
- * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
- *
- * Based on the diag.c - GPIO interface driver for Broadcom boards
- * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
- * Copyright (C) 2006-2007 Felix Fietkau <nbd@openwrt.org>
- * Copyright (C) 2008 Andy Boyett <agb@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 <linux/module.h>
-#include <linux/version.h>
-#include <linux/kmod.h>
-#include <linux/input.h>
-
-#include <linux/workqueue.h>
-#include <linux/skbuff.h>
-#include <linux/netlink.h>
-#include <linux/kobject.h>
-
-#define DRV_NAME "button-hotplug"
-#define DRV_VERSION "0.4.1"
-#define DRV_DESC "Button Hotplug driver"
-
-#define BH_SKB_SIZE 2048
-
-#define PFX DRV_NAME ": "
-
-#undef BH_DEBUG
-
-#ifdef BH_DEBUG
-#define BH_DBG(fmt, args...) printk(KERN_DEBUG "%s: " fmt, DRV_NAME, ##args )
-#else
-#define BH_DBG(fmt, args...) do {} while (0)
-#endif
-
-#define BH_ERR(fmt, args...) printk(KERN_ERR "%s: " fmt, DRV_NAME, ##args )
-
-#ifndef BIT_MASK
-#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
-#endif
-
-struct bh_priv {
- unsigned long *seen;
- struct input_handle handle;
-};
-
-struct bh_event {
- const char *name;
- char *action;
- unsigned long seen;
-
- struct sk_buff *skb;
- struct work_struct work;
-};
-
-struct bh_map {
- unsigned int code;
- const char *name;
-};
-
-extern u64 uevent_next_seqnum(void);
-
-#define BH_MAP(_code, _name) \
- { \
- .code = (_code), \
- .name = (_name), \
- }
-
-static struct bh_map button_map[] = {
- BH_MAP(BTN_0, "BTN_0"),
- BH_MAP(BTN_1, "BTN_1"),
- BH_MAP(BTN_2, "BTN_2"),
- BH_MAP(BTN_3, "BTN_3"),
- BH_MAP(BTN_4, "BTN_4"),
- BH_MAP(BTN_5, "BTN_5"),
- BH_MAP(BTN_6, "BTN_6"),
- BH_MAP(BTN_7, "BTN_7"),
- BH_MAP(BTN_8, "BTN_8"),
- BH_MAP(BTN_9, "BTN_9"),
- BH_MAP(KEY_RESTART, "reset"),
-#ifdef KEY_WPS_BUTTON
- BH_MAP(KEY_WPS_BUTTON, "wps"),
-#endif /* KEY_WPS_BUTTON */
-};
-
-/* -------------------------------------------------------------------------*/
-
-static int bh_event_add_var(struct bh_event *event, int argv,
- const char *format, ...)
-{
- static char buf[128];
- char *s;
- va_list args;
- int len;
-
- if (argv)
- return 0;
-
- va_start(args, format);
- len = vsnprintf(buf, sizeof(buf), format, args);
- va_end(args);
-
- if (len >= sizeof(buf)) {
- BH_ERR("buffer size too small\n");
- WARN_ON(1);
- return -ENOMEM;
- }
-
- s = skb_put(event->skb, len + 1);
- strcpy(s, buf);
-
- BH_DBG("added variable '%s'\n", s);
-
- return 0;
-}
-
-static int button_hotplug_fill_event(struct bh_event *event)
-{
- int ret;
-
- ret = bh_event_add_var(event, 0, "HOME=%s", "/");
- if (ret)
- return ret;
-
- ret = bh_event_add_var(event, 0, "PATH=%s",
- "/sbin:/bin:/usr/sbin:/usr/bin");
- if (ret)
- return ret;
-
- ret = bh_event_add_var(event, 0, "SUBSYSTEM=%s", "button");
- if (ret)
- return ret;
-
- ret = bh_event_add_var(event, 0, "ACTION=%s", event->action);
- if (ret)
- return ret;
-
- ret = bh_event_add_var(event, 0, "BUTTON=%s", event->name);
- if (ret)
- return ret;
-
- ret = bh_event_add_var(event, 0, "SEEN=%ld", event->seen);
- if (ret)
- return ret;
-
- ret = bh_event_add_var(event, 0, "SEQNUM=%llu", uevent_next_seqnum());
-
- return ret;
-}
-
-static void button_hotplug_work(struct work_struct *work)
-{
- struct bh_event *event = container_of(work, struct bh_event, work);
- int ret = 0;
-
- event->skb = alloc_skb(BH_SKB_SIZE, GFP_KERNEL);
- if (!event->skb)
- goto out_free_event;
-
- ret = bh_event_add_var(event, 0, "%s@", event->action);
- if (ret)
- goto out_free_skb;
-
- ret = button_hotplug_fill_event(event);
- if (ret)
- goto out_free_skb;
-
- NETLINK_CB(event->skb).dst_group = 1;
- broadcast_uevent(event->skb, 0, 1, GFP_KERNEL);
-
- out_free_skb:
- if (ret) {
- BH_ERR("work error %d\n", ret);
- kfree_skb(event->skb);
- }
- out_free_event:
- kfree(event);
-}
-
-static int button_hotplug_create_event(const char *name, unsigned long seen,
- int pressed)
-{
- struct bh_event *event;
-
- BH_DBG("create event, name=%s, seen=%lu, pressed=%d\n",
- name, seen, pressed);
-
- event = kzalloc(sizeof(*event), GFP_KERNEL);
- if (!event)
- return -ENOMEM;
-
- event->name = name;
- event->seen = seen;
- event->action = pressed ? "pressed" : "released";
-
- INIT_WORK(&event->work, (void *)(void *)button_hotplug_work);
- schedule_work(&event->work);
-
- return 0;
-}
-
-/* -------------------------------------------------------------------------*/
-
-#ifdef CONFIG_HOTPLUG
-static int button_get_index(unsigned int code)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(button_map); i++)
- if (button_map[i].code == code)
- return i;
-
- return -1;
-}
-static void button_hotplug_event(struct input_handle *handle,
- unsigned int type, unsigned int code, int value)
-{
- struct bh_priv *priv = handle->private;
- unsigned long seen = jiffies;
- int btn;
-
- BH_DBG("event type=%u, code=%u, value=%d\n", type, code, value);
-
- if (type != EV_KEY)
- return;
-
- btn = button_get_index(code);
- if (btn < 0)
- return;
-
- button_hotplug_create_event(button_map[btn].name,
- (seen - priv->seen[btn]) / HZ, value);
- priv->seen[btn] = seen;
-}
-#else
-static void button_hotplug_event(struct input_handle *handle,
- unsigned int type, unsigned int code, int value)
-{
-}
-#endif /* CONFIG_HOTPLUG */
-
-static int button_hotplug_connect(struct input_handler *handler,
- struct input_dev *dev, const struct input_device_id *id)
-{
- struct bh_priv *priv;
- int ret;
- int i;
-
- for (i = 0; i < ARRAY_SIZE(button_map); i++)
- if (test_bit(button_map[i].code, dev->keybit))
- break;
-
- if (i == ARRAY_SIZE(button_map))
- return -ENODEV;
-
- priv = kzalloc(sizeof(*priv) +
- (sizeof(unsigned long) * ARRAY_SIZE(button_map)),
- GFP_KERNEL);
- if (!priv)
- return -ENOMEM;
-
- priv->seen = (unsigned long *) &priv[1];
- priv->handle.private = priv;
- priv->handle.dev = dev;
- priv->handle.handler = handler;
- priv->handle.name = DRV_NAME;
-
- ret = input_register_handle(&priv->handle);
- if (ret)
- goto err_free_priv;
-
- ret = input_open_device(&priv->handle);
- if (ret)
- goto err_unregister_handle;
-
- BH_DBG("connected to %s\n", dev->name);
-
- return 0;
-
- err_unregister_handle:
- input_unregister_handle(&priv->handle);
-
- err_free_priv:
- kfree(priv);
- return ret;
-}
-
-static void button_hotplug_disconnect(struct input_handle *handle)
-{
- struct bh_priv *priv = handle->private;
-
- input_close_device(handle);
- input_unregister_handle(handle);
-
- kfree(priv);
-}
-
-static const struct input_device_id button_hotplug_ids[] = {
- {
- .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
- .evbit = { BIT_MASK(EV_KEY) },
- },
- {
- /* Terminating entry */
- },
-};
-
-MODULE_DEVICE_TABLE(input, button_hotplug_ids);
-
-static struct input_handler button_hotplug_handler = {
- .event = button_hotplug_event,
- .connect = button_hotplug_connect,
- .disconnect = button_hotplug_disconnect,
- .name = DRV_NAME,
- .id_table = button_hotplug_ids,
-};
-
-/* -------------------------------------------------------------------------*/
-
-static int __init button_hotplug_init(void)
-{
- int ret;
-
- printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
- ret = input_register_handler(&button_hotplug_handler);
- if (ret)
- BH_ERR("unable to register input handler\n");
-
- return ret;
-}
-module_init(button_hotplug_init);
-
-static void __exit button_hotplug_exit(void)
-{
- input_unregister_handler(&button_hotplug_handler);
-}
-module_exit(button_hotplug_exit);
-
-MODULE_DESCRIPTION(DRV_DESC);
-MODULE_VERSION(DRV_VERSION);
-MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
-MODULE_LICENSE("GPL v2");
-
diff --git a/package/system/ep80579-drivers/Makefile b/package/system/ep80579-drivers/Makefile
deleted file mode 100644
index 61d3bc2a1f..0000000000
--- a/package/system/ep80579-drivers/Makefile
+++ /dev/null
@@ -1,92 +0,0 @@
-#
-# 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)/kernel.mk
-
-PKG_NAME:=ep80579-drivers
-PKG_VERSION:=1.0.34
-PKG_RELEASE:=1
-
-PKG_SOURCE:=Embedded.L.1.0.34.ADI.R100.tar.gz
-PKG_SOURCE_URL:=ftp://ftp.adiengineering.com/Archive/OcracokeIsland/Drivers/Linux/1.0.34/
-PKG_MD5SUM:=61df9778f8c1f919257d2f48a0bcb000
-
-PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/ep80579-drivers/Default
- DEPENDS:=@TARGET_x86_ep80579
-endef
-
-define KernelPackage/ep80579-eth
-$(call KernelPackage/ep80579-drivers/Default)
- SUBMENU:=Network Devices
- TITLE:=Intel EP80579 ethernet driver
- FILES:= \
- $(PKG_BUILD_DIR)/Embedded/src/GbE/gcu.ko \
- $(PKG_BUILD_DIR)/Embedded/src/GbE/iegbe.ko
- AUTOLOAD:=$(call AutoLoad,40,gcu iegbe)
-endef
-
-define KernelPackage/ep80579-misc
-$(call KernelPackage/ep80579-drivers/Default)
- SUBMENU:=Other modules
- TITLE:=Misc. Intel EP80579 drivers (DMA,, gpio)
- FILES:= \
- $(PKG_BUILD_DIR)/Embedded/src/EDMA/dma.ko \
- $(PKG_BUILD_DIR)/Embedded/src/GPIO/gpio.ko
- AUTOLOAD:=$(call AutoLoad,40,gpio dma)
-endef
-
-define KernelPackage/ep80579-can
-$(call KernelPackage/ep80579-drivers/Default)
- SUBMENU:=Other modules
- TITLE:=Intel EP80579 CAN driver
- FILES:= \
- $(PKG_BUILD_DIR)/Embedded/src/1588/timesync.ko \
- $(PKG_BUILD_DIR)/Embedded/src/CAN/can.ko
- AUTOLOAD:=$(call AutoLoad,40,timesync can)
-endef
-
-define Build/Prepare
- rm -rf $(PKG_BUILD_DIR)
- mkdir -p $(PKG_BUILD_DIR)
- tar xzvf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR)/
- $(Build/Patch)
-endef
-
-define Build/Compile/Subdir
- $(MAKE) -C "$(LINUX_DIR)" \
- KSRC="$(LINUX_DIR)" \
- KOBJ="$(LINUX_DIR)" \
- ENV_DIR=$(PKG_BUILD_DIR)/Embedded \
- SUBDIRS="$(PKG_BUILD_DIR)/Embedded/src/$(1)" \
- CROSS_COMPILE="$(TARGET_CROSS)" \
- ARCHIVER="$(TARGET_CROSS)ar" \
- COMPILER="$(TARGET_CC)" \
- LINKER="$(TARGET_CROSS)ld" \
- ARCH="$(LINUX_KARCH)"
-endef
-
-define Build/Compile
- $(call Build/Compile/Subdir,GbE)
- $(call Build/Compile/Subdir,CAN)
- $(call Build/Compile/Subdir,EDMA)
- $(call Build/Compile/Subdir,GPIO)
- $(call Build/Compile/Subdir,WDT)
- $(call Build/Compile/Subdir,1588)
-endef
-
-define KernelPackage/ep80579-eth/install
-endef
-
-$(eval $(call KernelPackage,ep80579-can))
-$(eval $(call KernelPackage,ep80579-eth))
-$(eval $(call KernelPackage,ep80579-misc))
-
diff --git a/package/system/ep80579-drivers/patches/001-igbe_update.patch b/package/system/ep80579-drivers/patches/001-igbe_update.patch
deleted file mode 100644
index 80ca0ef8b9..0000000000
--- a/package/system/ep80579-drivers/patches/001-igbe_update.patch
+++ /dev/null
@@ -1,11755 +0,0 @@
---- a/Embedded/src/GbE/gcu.h
-+++ b/Embedded/src/GbE/gcu.h
-@@ -2,7 +2,7 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
---- a/Embedded/src/GbE/gcu_if.c
-+++ b/Embedded/src/GbE/gcu_if.c
-@@ -2,7 +2,7 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
-@@ -330,10 +330,17 @@ gcu_write_verify(uint32_t phy_num, uint3
- */
- void gcu_iegbe_resume(struct pci_dev *pdev)
- {
-+#if ( ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6) ) && \
-+ ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) ) )
-+ struct net_device *netdev = pci_get_drvdata(pdev);
-+ struct gcu_adapter *adapter = netdev_priv(netdev);
-+#endif
-+
- GCU_DBG("%s\n", __func__);
-
- pci_restore_state(pdev);
-- pci_enable_device(pdev);
-+ if(!pci_enable_device(pdev))
-+ GCU_DBG("pci_enable_device failed!\n",);
-
- return;
- }
-@@ -348,6 +355,12 @@ EXPORT_SYMBOL(gcu_iegbe_resume);
- */
- int gcu_iegbe_suspend(struct pci_dev *pdev, uint32_t state)
- {
-+#if ( ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6) ) && \
-+ ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) ) )
-+ struct net_device *netdev = pci_get_drvdata(pdev);
-+ struct gcu_adapter *adapter = netdev_priv(netdev);
-+#endif
-+
- GCU_DBG("%s\n", __func__);
-
- pci_save_state(pdev);
---- a/Embedded/src/GbE/gcu_if.h
-+++ b/Embedded/src/GbE/gcu_if.h
-@@ -2,7 +2,7 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
---- a/Embedded/src/GbE/gcu_main.c
-+++ b/Embedded/src/GbE/gcu_main.c
-@@ -2,7 +2,7 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
-@@ -94,6 +94,7 @@ static struct pci_driver gcu_driver = {
-
- static struct gcu_adapter *global_adapter = 0;
- static spinlock_t global_adapter_spinlock = SPIN_LOCK_UNLOCKED;
-+static unsigned long g_intflags = 0;
-
- MODULE_AUTHOR("Intel(R) Corporation");
- MODULE_DESCRIPTION("Global Configuration Unit Driver");
-@@ -124,7 +125,7 @@ gcu_init_module(void)
-
- printk(KERN_INFO "%s\n", gcu_copyright);
-
-- ret = pci_module_init(&gcu_driver);
-+ ret = pci_register_driver(&gcu_driver);
- if(ret >= 0) {
- register_reboot_notifier(&gcu_notifier_reboot);
- }
-@@ -199,8 +200,6 @@ gcu_probe(struct pci_dev *pdev,
- return -ENOMEM;
- }
-
-- SET_MODULE_OWNER(adapter);
--
- pci_set_drvdata(pdev, adapter);
-
- adapter->pdev = pdev;
-@@ -238,7 +237,6 @@ gcu_probe(struct pci_dev *pdev,
- return 0;
- }
-
--
- /**
- * gcu_probe_err - gcu_probe error handler
- * @err: gcu_err_type
-@@ -295,7 +293,7 @@ gcu_notify_reboot(struct notifier_block
- case SYS_DOWN:
- case SYS_HALT:
- case SYS_POWER_OFF:
-- while((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
-+ while((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
- if(pci_dev_driver(pdev) == &gcu_driver){
- gcu_suspend(pdev, 0x3);
- }
-@@ -318,6 +316,11 @@ static int
- gcu_suspend(struct pci_dev *pdev, uint32_t state)
- {
- /*struct gcu_adapter *adapter = pci_get_drvdata(pdev); */
-+#if ( ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6) ) && \
-+ ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) ) )
-+ struct net_device *netdev = pci_get_drvdata(pdev);
-+ struct gcu_adapter *adapter = netdev_priv(netdev);
-+#endif
-
- GCU_DBG("%s\n", __func__);
-
-@@ -338,7 +341,6 @@ gcu_suspend(struct pci_dev *pdev, uint32
- return state;
- }
-
--
- /**
- * alloc_gcu_adapter
- *
-@@ -412,7 +414,7 @@ gcu_get_adapter(void)
- return NULL;
- }
-
-- spin_lock(&global_adapter_spinlock);
-+ spin_lock_irqsave(&global_adapter_spinlock, g_intflags);
-
- return global_adapter;
- }
-@@ -437,7 +439,7 @@ gcu_release_adapter(const struct gcu_ada
- *adapter = 0;
- }
-
-- spin_unlock(&global_adapter_spinlock);
-+ spin_unlock_irqrestore(&global_adapter_spinlock, g_intflags);
-
- return;
- }
---- a/Embedded/src/GbE/gcu_reg.h
-+++ b/Embedded/src/GbE/gcu_reg.h
-@@ -2,7 +2,7 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
---- a/Embedded/src/GbE/iegbe.7
-+++ b/Embedded/src/GbE/iegbe.7
-@@ -1,7 +1,7 @@
-
- .\" GPL LICENSE SUMMARY
- .\"
--.\" Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+.\" Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
- .\"
- .\" This program is free software; you can redistribute it and/or modify
- .\" it under the terms of version 2 of the GNU General Public License as
-@@ -21,7 +21,7 @@
- .\" Contact Information:
- .\" Intel Corporation
- .\"
--.\" version: Embedded.L.1.0.34
-+.\" version: Embedded.Release.Patch.L.1.0.7-5
-
- .\" LICENSE
- .\"
---- a/Embedded/src/GbE/iegbe_ethtool.c
-+++ b/Embedded/src/GbE/iegbe_ethtool.c
-@@ -2,7 +2,7 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
-@@ -132,22 +132,6 @@ static const struct iegbe_stats iegbe_gs
- { "cpp_master", E1000_STAT(icr_cpp_master) },
- { "stat", E1000_STAT(icr_stat) },
- #endif
--#ifdef IEGBE_GBE_WORKAROUND
-- { "txqec", E1000_STAT(stats.txqec) },
-- { "tx_next_to_clean", E1000_STAT(stats.tx_next_to_clean) },
-- { "tx_next_to_use", E1000_STAT(stats.tx_next_to_use) },
-- { "num_tx_queues", E1000_STAT(stats.num_tx_queues) },
--
-- { "num_rx_buf_alloc", E1000_STAT(stats.num_rx_buf_alloc) },
-- { "rx_next_to_clean", E1000_STAT(stats.rx_next_to_clean) },
-- { "rx_next_to_use", E1000_STAT(stats.rx_next_to_use) },
-- { "cc_gt_num_rx", E1000_STAT(stats.cc_gt_num_rx) },
-- { "tx_hnet", E1000_STAT(stats.tx_hnet) },
-- { "tx_hnentu", E1000_STAT(stats.tx_hnentu) },
-- { "RUC", E1000_STAT(stats.ruc) },
-- { "RFC", E1000_STAT(stats.rfc) },
--
--#endif
- };
- #define E1000_STATS_LEN \
- sizeof(iegbe_gstrings_stats) / sizeof(struct iegbe_stats)
-@@ -158,7 +142,7 @@ static const char iegbe_gstrings_test[][
- "Interrupt test (offline)", "Loopback test (offline)",
- "Link test (on/offline)"
- };
--#define E1000_TEST_LEN (sizeof(iegbe_gstrings_test) / (ETH_GSTRING_LEN))
-+#define E1000_TEST_LEN (sizeof(iegbe_gstrings_test) / ETH_GSTRING_LEN)
- #endif /* ETHTOOL_TEST */
-
- #define E1000_REGS_LEN 0x20
-@@ -176,9 +160,7 @@ iegbe_get_settings(struct net_device *ne
- SUPPORTED_10baseT_Full |
- SUPPORTED_100baseT_Half |
- SUPPORTED_100baseT_Full |
--#ifndef IEGBE_10_100_ONLY
- SUPPORTED_1000baseT_Full|
--#endif
- SUPPORTED_Autoneg |
- SUPPORTED_TP);
-
-@@ -259,21 +241,13 @@ iegbe_set_settings(struct net_device *ne
- ADVERTISED_10baseT_Full |
- ADVERTISED_100baseT_Half |
- ADVERTISED_100baseT_Full |
--#ifndef IEGBE_10_100_ONLY
- ADVERTISED_1000baseT_Full|
--#endif
--
- ADVERTISED_Autoneg |
- ADVERTISED_TP;
- ecmd->advertising = hw->autoneg_advertised;
- }
-- } else {
-- uint16_t duplex;
--
-- // ethtool uses DUPLEX_FULL/DUPLEX_HALF
-- // the driver needs FULL_DUPLEX/HALF_DUPLEX
-- duplex = (ecmd->duplex == DUPLEX_FULL) ? FULL_DUPLEX : HALF_DUPLEX;
-- if(iegbe_set_spd_dplx(adapter, ecmd->speed + duplex))
-+ } else
-+ if(iegbe_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)){
- return -EINVAL;
- }
- /* reset the link */
-@@ -728,8 +702,8 @@ iegbe_set_ringparam(struct net_device *n
- struct iegbe_rx_ring *rxdr, *rx_old, *rx_new;
- int i, err, tx_ring_size, rx_ring_size;
-
-- tx_ring_size = sizeof(struct iegbe_tx_ring) * adapter->num_queues;
-- rx_ring_size = sizeof(struct iegbe_rx_ring) * adapter->num_queues;
-+ tx_ring_size = sizeof(struct iegbe_tx_ring) * adapter->num_tx_queues;
-+ rx_ring_size = sizeof(struct iegbe_rx_ring) * adapter->num_rx_queues;
-
- if (netif_running(adapter->netdev)){
- iegbe_down(adapter);
-@@ -768,10 +742,10 @@ iegbe_set_ringparam(struct net_device *n
- E1000_MAX_TXD : E1000_MAX_82544_TXD));
- E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
-
-- for (i = 0; i < adapter->num_queues; i++) {
-- txdr[i].count = txdr->count;
-- rxdr[i].count = rxdr->count;
-- }
-+ for (i = 0; i < adapter->num_tx_queues; i++)
-+ txdr[i].count = txdr->count;
-+ for (i = 0; i < adapter->num_rx_queues; i++)
-+ rxdr[i].count = rxdr->count;
-
- if(netif_running(adapter->netdev)) {
- /* Try to get new resources before deleting old */
-@@ -950,8 +924,7 @@ iegbe_eeprom_test(struct iegbe_adapter *
-
- static irqreturn_t
- iegbe_test_intr(int irq,
-- void *data,
-- struct pt_regs *regs)
-+ void *data)
- {
- struct net_device *netdev = (struct net_device *) data;
- struct iegbe_adapter *adapter = netdev_priv(netdev);
-@@ -973,7 +946,7 @@ iegbe_intr_test(struct iegbe_adapter *ad
- /* Hook up test interrupt handler just for this test */
- if(!request_irq(irq, &iegbe_test_intr, 0, netdev->name, netdev)) {
- shared_int = FALSE;
-- } else if(request_irq(irq, &iegbe_test_intr, SA_SHIRQ,
-+ } else if(request_irq(irq, &iegbe_test_intr, IRQF_SHARED,
- netdev->name, netdev)){
- *data = 1;
- return -1;
-@@ -1393,7 +1366,7 @@ iegbe_set_phy_loopback(struct iegbe_adap
- * attempt this 10 times.
- */
- while(iegbe_nonintegrated_phy_loopback(adapter) &&
-- count++ < 0xa) { };
-+ count++ < 0xa);
- if(count < 0xb) {
- return 0;
- }
---- a/Embedded/src/GbE/iegbe.h
-+++ b/Embedded/src/GbE/iegbe.h
-@@ -1,7 +1,7 @@
- /*******************************************************************************
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -21,7 +21,7 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
-@@ -127,9 +127,12 @@ struct iegbe_adapter;
- #define E1000_MIN_RXD 80
- #define E1000_MAX_82544_RXD 4096
-
-+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
- /* Supported Rx Buffer Sizes */
- #define E1000_RXBUFFER_128 128 /* Used for packet split */
- #define E1000_RXBUFFER_256 256 /* Used for packet split */
-+#define E1000_RXBUFFER_512 512
-+#define E1000_RXBUFFER_1024 1024
- #define E1000_RXBUFFER_2048 2048
- #define E1000_RXBUFFER_4096 4096
- #define E1000_RXBUFFER_8192 8192
-@@ -164,11 +167,9 @@ struct iegbe_adapter;
- #define E1000_MASTER_SLAVE iegbe_ms_hw_default
- #endif
-
--#ifdef NETIF_F_HW_VLAN_TX
--#define E1000_MNG_VLAN_NONE -1
--#endif
-+#define E1000_MNG_VLAN_NONE (-1)
- /* Number of packet split data buffers (not including the header buffer) */
--#define PS_PAGE_BUFFERS MAX_PS_BUFFERS-1
-+#define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
-
- /* only works for sizes that are powers of 2 */
- #define E1000_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
-@@ -206,6 +207,7 @@ struct iegbe_tx_ring {
- spinlock_t tx_lock;
- uint16_t tdh;
- uint16_t tdt;
-+ boolean_t last_tx_tso;
- uint64_t pkt;
- };
-
-@@ -228,6 +230,9 @@ struct iegbe_rx_ring {
- struct iegbe_ps_page *ps_page;
- struct iegbe_ps_page_dma *ps_page_dma;
-
-+ /* cpu for rx queue */
-+ int cpu;
-+
- uint16_t rdh;
- uint16_t rdt;
- uint64_t pkt;
-@@ -252,10 +257,8 @@ struct iegbe_adapter {
- struct timer_list tx_fifo_stall_timer;
- struct timer_list watchdog_timer;
- struct timer_list phy_info_timer;
--#ifdef NETIF_F_HW_VLAN_TX
- struct vlan_group *vlgrp;
- uint16_t mng_vlan_id;
--#endif
- uint32_t bd_number;
- uint32_t rx_buffer_len;
- uint32_t part_num;
-@@ -265,8 +268,18 @@ struct iegbe_adapter {
- uint16_t link_speed;
- uint16_t link_duplex;
- spinlock_t stats_lock;
-- atomic_t irq_sem;
-- struct work_struct tx_timeout_task;
-+ spinlock_t tx_queue_lock;
-+ unsigned int total_tx_bytes;
-+ unsigned int total_tx_packets;
-+ unsigned int total_rx_bytes;
-+ unsigned int total_rx_packets;
-+ /* Interrupt Throttle Rate */
-+ uint32_t itr;
-+ uint32_t itr_setting;
-+ uint16_t tx_itr;
-+ uint16_t rx_itr;
-+
-+ struct work_struct reset_task;
- uint8_t fc_autoneg;
-
- #ifdef ETHTOOL_PHYS_ID
-@@ -276,9 +289,8 @@ struct iegbe_adapter {
-
- /* TX */
- struct iegbe_tx_ring *tx_ring; /* One per active queue */
--#ifdef CONFIG_E1000_MQ
-- struct iegbe_tx_ring **cpu_tx_ring; /* per-cpu */
--#endif
-+ unsigned int restart_queue;
-+ unsigned long tx_queue_len;
- uint32_t txd_cmd;
- uint32_t tx_int_delay;
- uint32_t tx_abs_int_delay;
-@@ -286,46 +298,33 @@ struct iegbe_adapter {
- uint64_t gotcl_old;
- uint64_t tpt_old;
- uint64_t colc_old;
-+ uint32_t tx_timeout_count;
- uint32_t tx_fifo_head;
- uint32_t tx_head_addr;
- uint32_t tx_fifo_size;
-+ uint8_t tx_timeout_factor;
- atomic_t tx_fifo_stall;
- boolean_t pcix_82544;
- boolean_t detect_tx_hung;
-
- /* RX */
--#ifdef CONFIG_E1000_NAPI
-- boolean_t (*clean_rx) (struct iegbe_adapter *adapter,
-+ bool (*clean_rx)(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rx_ring,
- int *work_done, int work_to_do);
--#else
-- boolean_t (*clean_rx) (struct iegbe_adapter *adapter,
-- struct iegbe_rx_ring *rx_ring);
--#endif
--
--#ifdef IEGBE_GBE_WORKAROUND
- void (*alloc_rx_buf) (struct iegbe_adapter *adapter,
-- struct iegbe_rx_ring *rx_ring,
-- int cleaned_count);
--#else
-- void (*alloc_rx_buf) (struct iegbe_adapter *adapter,
-- struct iegbe_rx_ring *rx_ring);
--#endif
--
-+ struct iegbe_rx_ring *rx_ring,
-+ int cleaned_count);
- struct iegbe_rx_ring *rx_ring; /* One per active queue */
--#ifdef CONFIG_E1000_NAPI
-+ struct napi_struct napi;
- struct net_device *polling_netdev; /* One per active queue */
--#endif
--#ifdef CONFIG_E1000_MQ
-- struct net_device **cpu_netdev; /* per-cpu */
-- struct call_async_data_struct rx_sched_call_data;
-- int cpu_for_queue[4];
--#endif
-- int num_queues;
-+
-+ int num_tx_queues;
-+ int num_rx_queues;
-
- uint64_t hw_csum_err;
- uint64_t hw_csum_good;
- uint64_t rx_hdr_split;
-+ uint32_t alloc_rx_buff_failed;
- uint32_t rx_int_delay;
- uint32_t rx_abs_int_delay;
- boolean_t rx_csum;
-@@ -334,8 +333,6 @@ struct iegbe_adapter {
- uint64_t gorcl_old;
- uint16_t rx_ps_bsize0;
-
-- /* Interrupt Throttle Rate */
-- uint32_t itr;
-
- /* OS defined structs */
- struct net_device *netdev;
-@@ -378,7 +375,21 @@ struct iegbe_adapter {
- #ifdef CONFIG_PCI_MSI
- boolean_t have_msi;
- #endif
--#define IEGBE_INTD_DISABLE 0x0400
-+ /* to not mess up cache alignment, always add to the bottom */
-+ boolean_t tso_force;
-+ boolean_t smart_power_down; /* phy smart power down */
-+ boolean_t quad_port_a;
-+ unsigned long flags;
-+ uint32_t eeprom_wol;
-+ int bars;
-+ int need_ioport;
- };
-+
-+enum iegbe_state_t {
-+ __E1000_TESTING,
-+ __E1000_RESETTING,
-+ __E1000_DOWN
-+};
-+#define IEGBE_INTD_DISABLE 0x0400
- #endif /* _IEGBE_H_ */
-
---- a/Embedded/src/GbE/iegbe_hw.c
-+++ b/Embedded/src/GbE/iegbe_hw.c
-@@ -2,7 +2,7 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
-@@ -2115,7 +2115,7 @@ iegbe_config_mac_to_phy(struct iegbe_hw
-
- ret_val = iegbe_oem_set_trans_gasket(hw);
- if(ret_val){
-- return ret_val;
-+ return ret_val;
- }
- ret_val = iegbe_oem_phy_is_full_duplex(
- hw, (int *) &is_FullDuplex);
-@@ -2164,7 +2164,7 @@ iegbe_config_mac_to_phy(struct iegbe_hw
- }
- /* Write the configured values back to the Device Control Reg. */
- E1000_WRITE_REG(hw, CTRL, ctrl);
-- return E1000_SUCCESS;
-+ return ret_val;
- }
-
- /*****************************************************************************
-@@ -2684,7 +2684,7 @@ iegbe_check_for_link(struct iegbe_hw *hw
-
- if(hw->autoneg_failed == 0) {
- hw->autoneg_failed = 1;
-- return 0;
-+ return E1000_SUCCESS;
- }
- DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\r\n");
-
-@@ -5875,7 +5875,7 @@ iegbe_get_cable_length(struct iegbe_hw *
- max_agc = cur_agc;
- }
- }
--
-+
- /* This is to fix a Klockwork defect, that the array index might
- * be out of bounds. 113 is table size */
- if (cur_agc < 0x71){
---- a/Embedded/src/GbE/iegbe_hw.h
-+++ b/Embedded/src/GbE/iegbe_hw.h
-@@ -2,7 +2,7 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
-@@ -299,7 +299,7 @@ void iegbe_set_media_type(struct iegbe_h
- /* Link Configuration */
- int32_t iegbe_setup_link(struct iegbe_hw *hw);
- int32_t iegbe_phy_setup_autoneg(struct iegbe_hw *hw);
--void iegbe_config_collision_dist(struct iegbe_hw *hw);
-+void iegbe_config_collision_dist(struct iegbe_hw *hw);
- int32_t iegbe_config_fc_after_link_up(struct iegbe_hw *hw);
- int32_t iegbe_check_for_link(struct iegbe_hw *hw);
- int32_t iegbe_get_speed_and_duplex(struct iegbe_hw *hw, uint16_t * speed, uint16_t * duplex);
-@@ -588,14 +588,6 @@ uint8_t iegbe_arc_subsystem_valid(struct
- * o LSC = Link Status Change
- */
-
--#ifdef IEGBE_GBE_WORKAROUND
--#define IMS_ENABLE_MASK ( \
-- E1000_IMS_RXT0 | \
-- E1000_IMS_TXQE | \
-- E1000_IMS_RXDMT0 | \
-- E1000_IMS_RXSEQ | \
-- E1000_IMS_LSC)
--#else
- #define IMS_ENABLE_MASK ( \
- E1000_IMS_RXT0 | \
- E1000_IMS_TXDW | \
-@@ -606,8 +598,7 @@ uint8_t iegbe_arc_subsystem_valid(struct
- E1000_ICR_PB | \
- E1000_ICR_CPP_TARGET | \
- E1000_ICR_CPP_MASTER | \
-- E1000_IMS_LSC)
--#endif
-+ E1000_ICR_LSC)
-
- /* Number of high/low register pairs in the RAR. The RAR (Receive Address
- * Registers) holds the directed and multicast addresses that we monitor. We
-@@ -923,10 +914,15 @@ struct iegbe_ffvt_entry {
- #define E1000_ICS 0x000C8 /* Interrupt Cause Set - WO */
- #define E1000_IMS 0x000D0 /* Interrupt Mask Set - RW */
- #define E1000_IMC 0x000D8 /* Interrupt Mask Clear - WO */
--// Register conflict, does not exist for ICP_xxxx hardware
--// #define E1000_IAM 0x000E0 /* Interrupt Acknowledge Auto Mask */
- #define E1000_CTRL_AUX 0x000E0 /* Aux Control -RW */
-+#define E1000_IAM 0x000E0 /* Interrupt Acknowledge Auto Mask */
- #define E1000_RCTL 0x00100 /* RX Control - RW */
-+#define E1000_RDTR1 0x02820 /* RX Delay Timer (1) - RW */
-+#define E1000_RDBAL1 0x02900 /* RX Descriptor Base Address Low (1) - RW */
-+#define E1000_RDBAH1 0x02904 /* RX Descriptor Base Address High (1) - RW */
-+#define E1000_RDLEN1 0x02908 /* RX Descriptor Length (1) - RW */
-+#define E1000_RDH1 0x02910 /* RX Descriptor Head (1) - RW */
-+#define E1000_RDT1 0x02918 /* RX Descriptor Tail (1) - RW */
- #define E1000_FCTTV 0x00170 /* Flow Control Transmit Timer Value - RW */
- #define E1000_TXCW 0x00178 /* TX Configuration Word - RW */
- #define E1000_RXCW 0x00180 /* RX Configuration Word - RO */
-@@ -1282,8 +1278,6 @@ struct iegbe_ffvt_entry {
- #define E1000_82542_FFMT E1000_FFMT
- #define E1000_82542_FFVT E1000_FFVT
- #define E1000_82542_HOST_IF E1000_HOST_IF
--// Register conflict with ICP_xxxx hardware, no IAM
--// #define E1000_82542_IAM E1000_IAM
- #define E1000_82542_EEMNGCTL E1000_EEMNGCTL
- #define E1000_82542_PSRCTL E1000_PSRCTL
- #define E1000_82542_RAID E1000_RAID
-@@ -1329,6 +1323,7 @@ struct iegbe_hw_stats {
- uint64_t algnerrc;
- uint64_t symerrs;
- uint64_t rxerrc;
-+ uint64_t txerrc;
- uint64_t mpc;
- uint64_t scc;
- uint64_t ecol;
-@@ -1363,6 +1358,7 @@ struct iegbe_hw_stats {
- uint64_t ruc;
- uint64_t rfc;
- uint64_t roc;
-+ uint64_t rlerrc;
- uint64_t rjc;
- uint64_t mgprc;
- uint64_t mgpdc;
-@@ -1392,19 +1388,6 @@ struct iegbe_hw_stats {
- uint64_t ictxqmtc;
- uint64_t icrxdmtc;
- uint64_t icrxoc;
--#ifdef IEGBE_GBE_WORKAROUND
-- u64 txqec;
-- u64 tx_next_to_clean;
-- u64 tx_next_to_use;
-- u64 cc_gt_num_rx;
-- u64 tx_hnet;
-- u64 tx_hnentu;
-- u64 num_tx_queues;
--
-- u64 num_rx_buf_alloc;
-- u64 rx_next_to_clean;
-- u64 rx_next_to_use;
--#endif
- };
-
- /* Structure containing variables used by the shared code (iegbe_hw.c) */
-@@ -1484,6 +1467,7 @@ struct iegbe_hw {
- boolean_t ifs_params_forced;
- boolean_t in_ifs_mode;
- boolean_t mng_reg_access_disabled;
-+ boolean_t rx_needs_kicking;
- boolean_t icp_xxxx_is_link_up;
- };
-
-@@ -2358,17 +2342,23 @@ struct iegbe_host_command_info {
- #define E1000_EXTCNF_SIZE_EXT_PHY_LENGTH 0x000000FF
- #define E1000_EXTCNF_SIZE_EXT_DOCK_LENGTH 0x0000FF00
- #define E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH 0x00FF0000
-+#define E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE 0x00000001
-+#define E1000_EXTCNF_CTRL_SWFLAG 0x00000020
-
- /* PBA constants */
-+#define E1000_PBA_8K 0x0008 /* 8KB, default Rx allocation */
- #define E1000_PBA_12K 0x000C /* 12KB, default Rx allocation */
- #define E1000_PBA_16K 0x0010 /* 16KB, default TX allocation */
-+#define E1000_PBA_20K 0x0014
- #define E1000_PBA_22K 0x0016
- #define E1000_PBA_24K 0x0018
- #define E1000_PBA_30K 0x001E
- #define E1000_PBA_32K 0x0020
-+#define E1000_PBA_34K 0x0022
- #define E1000_PBA_38K 0x0026
- #define E1000_PBA_40K 0x0028
- #define E1000_PBA_48K 0x0030 /* 48KB, default RX allocation */
-+#define E1000_PBS_16K E1000_PBA_16K
-
- /* Flow Control Constants */
- #define FLOW_CONTROL_ADDRESS_LOW 0x00C28001
-@@ -2899,7 +2889,7 @@ struct iegbe_host_command_info {
- #define M88E1000_14_PHY_ID M88E1000_E_PHY_ID
- #define M88E1011_I_REV_4 0x04
- #define M88E1111_I_PHY_ID 0x01410CC2
--#define M88E1141_E_PHY_ID 0x01410CD4
-+#define M88E1141_E_PHY_ID 0x01410CD0
- #define L1LXT971A_PHY_ID 0x001378E0
-
- /* Miscellaneous PHY bit definitions. */
---- a/Embedded/src/GbE/iegbe_main.c
-+++ b/Embedded/src/GbE/iegbe_main.c
-@@ -2,7 +2,7 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
-@@ -42,103 +42,15 @@ GPL LICENSE SUMMARY
-
- #include "iegbe.h"
- #include "gcu_if.h"
--
--/* Change Log
-- * 6.0.58 4/20/05
-- * o iegbe_set_spd_dplx tests for compatible speed/duplex specification
-- * for fiber adapters
-- * 6.0.57 4/19/05
-- * o Added code to fix register test failure for devices >= 82571
-- *
-- * 6.0.52 3/15/05
-- * o Added stats_lock around iegbe_read_phy_reg commands to avoid concurrent
-- * calls, one from mii_ioctl and other from within update_stats while
-- * processing MIIREG ioctl.
-- *
-- * 6.1.2 4/13/05
-- * o Fixed ethtool diagnostics
-- * o Enabled flow control to take default eeprom settings
-- * o Added stats_lock around iegbe_read_phy_reg commands to avoid concurrent
-- * calls, one from mii_ioctl and other from within update_stats while processing
-- * MIIREG ioctl.
-- * 6.0.55 3/23/05
-- * o Support for MODULE_VERSION
-- * o Fix APM setting for 82544 based adapters
-- * 6.0.54 3/26/05
-- * o Added a timer to expire packets that were deferred for cleanup
-- * 6.0.52 3/15/05
-- * o Added stats_lock around iegbe_read_phy_reg commands to avoid concurrent
-- * calls, one from mii_ioctl and other from within update_stats while
-- * processing MIIREG ioctl.
-- * 6.0.47 3/2/05
-- * o Added enhanced functionality to the loopback diags to wrap the
-- * descriptor rings
-- * o Added manageability vlan filtering workaround.
-- *
-- * 6.0.44+ 2/15/05
-- * o Added code to handle raw packet based DHCP packets
-- * o Added code to fix the errata 10 buffer overflow issue
-- * o Sync up with WR01-05
-- * o applied Anton's patch to resolve tx hang in hardware
-- * o iegbe timeouts with early writeback patch
-- * o Removed Queensport IDs
-- * o fixed driver panic if MAC receives a bad large packets when packet
-- * split is enabled
-- * o Applied Andrew Mortons patch - iegbe stops working after resume
-- * 5.2.29 12/24/03
-- * o Bug fix: Endianess issue causing ethtool diags to fail on ppc.
-- * o Bug fix: Use pdev->irq instead of netdev->irq for MSI support.
-- * o Report driver message on user override of InterruptThrottleRate module
-- * parameter.
-- * o Bug fix: Change I/O address storage from uint32_t to unsigned long.
-- * o Feature: Added ethtool RINGPARAM support.
-- * o Feature: Added netpoll support.
-- * o Bug fix: Race between Tx queue and Tx clean fixed with a spin lock.
-- * o Bug fix: Allow 1000/Full setting for autoneg param for fiber connections.
-- * Jon D Mason [jonmason@us.ibm.com].
-- *
-- * 5.2.22 10/15/03
-- * o Bug fix: SERDES devices might be connected to a back-plane switch that
-- * doesn't support auto-neg, so add the capability to force 1000/Full.
-- * Also, since forcing 1000/Full, sample RxSynchronize bit to detect link
-- * state.
-- * o Bug fix: Flow control settings for hi/lo watermark didn't consider
-- * changes in the RX FIFO size, which could occur with Jumbo Frames or with
-- * the reduced FIFO in 82547.
-- * o Bug fix: Better propagation of error codes.
-- * [Janice Girouard (janiceg -a-t- us.ibm.com)]
-- * o Bug fix: hang under heavy Tx stress when running out of Tx descriptors;
-- * wasn't clearing context descriptor when backing out of send because of
-- * no-resource condition.
-- * o Bug fix: check netif_running in dev->poll so we don't have to hang in
-- * dev->close until all polls are finished. [Rober Olsson
-- * (robert.olsson@data.slu.se)].
-- * o Revert TxDescriptor ring size back to 256 since change to 1024 wasn't
-- * accepted into the kernel.
-- *
-- * 5.2.16 8/8/03
-- */
--
--#ifdef IEGBE_GBE_WORKAROUND
--#define IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS 1
--#endif
-+#include <linux/ipv6.h>
-+#include <net/ip6_checksum.h>
-
- char iegbe_driver_name[] = "iegbe";
- char iegbe_driver_string[] = "Gigabit Ethernet Controller Driver";
--#ifndef CONFIG_E1000_NAPI
--#define DRIVERNAPI
--#else
--#define DRIVERNAPI "-NAPI"
--#endif
--#define DRV_VERSION "0.8.0"DRIVERNAPI
-+#define DRV_VERSION "1.0.0-K28-NAPI"
- char iegbe_driver_version[] = DRV_VERSION;
--char iegbe_copyright[] = "Copyright (c) 1999-2007 Intel Corporation.";
-+char iegbe_copyright[] = "Copyright (c) 1999-2009 Intel Corporation.";
-
--#define E1000_FIFO_HDR 0x10
--#define E1000_82547_PAD_LEN 0x3E0
--#define MINIMUM_DHCP_PACKET_SIZE 282
--#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
--#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
-
- /* iegbe_pci_tbl - PCI Device ID Table
- *
-@@ -148,95 +60,48 @@ char iegbe_copyright[] = "Copyright (c)
- * {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
- */
- static struct pci_device_id iegbe_pci_tbl[] = {
--/* INTEL_E1000_ETHERNET_DEVICE(0x1000), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1001), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1004), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1008), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1009), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x100C), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x100D), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x100E), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x100F), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1010), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1011), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1012), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1013), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1014), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1015), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1016), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1017), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1018), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1019), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x101A), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x101D), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x101E), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1026), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1027), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1028), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x105E), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x105F), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1060), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1075), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1076), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1077), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1078), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x1079), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x107A), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x107B), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x107C), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x107D), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x107E), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x107F), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x108A), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x108B), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x108C), */
--/* INTEL_E1000_ETHERNET_DEVICE(0x109A), */
-- INTEL_E1000_ETHERNET_DEVICE(0x5040),
-- INTEL_E1000_ETHERNET_DEVICE(0x5041),
-- INTEL_E1000_ETHERNET_DEVICE(0x5042),
-- INTEL_E1000_ETHERNET_DEVICE(0x5043),
-- INTEL_E1000_ETHERNET_DEVICE(0x5044),
-- INTEL_E1000_ETHERNET_DEVICE(0x5045),
-- INTEL_E1000_ETHERNET_DEVICE(0x5046),
-- INTEL_E1000_ETHERNET_DEVICE(0x5047),
-- INTEL_E1000_ETHERNET_DEVICE(0x5048),
-- INTEL_E1000_ETHERNET_DEVICE(0x5049),
-- INTEL_E1000_ETHERNET_DEVICE(0x504A),
-- INTEL_E1000_ETHERNET_DEVICE(0x504B),
-- /* required last entry */
-+ INTEL_E1000_ETHERNET_DEVICE(0x5040),
-+ INTEL_E1000_ETHERNET_DEVICE(0x5041),
-+ INTEL_E1000_ETHERNET_DEVICE(0x5042),
-+ INTEL_E1000_ETHERNET_DEVICE(0x5043),
-+ INTEL_E1000_ETHERNET_DEVICE(0x5044),
-+ INTEL_E1000_ETHERNET_DEVICE(0x5045),
-+ INTEL_E1000_ETHERNET_DEVICE(0x5046),
-+ INTEL_E1000_ETHERNET_DEVICE(0x5047),
-+ INTEL_E1000_ETHERNET_DEVICE(0x5048),
-+ INTEL_E1000_ETHERNET_DEVICE(0x5049),
-+ INTEL_E1000_ETHERNET_DEVICE(0x504A),
-+ INTEL_E1000_ETHERNET_DEVICE(0x504B),
-+ /* required last entry */
- {0,}
- };
-
- MODULE_DEVICE_TABLE(pci, iegbe_pci_tbl);
-
--DEFINE_SPINLOCK(print_lock);
-
- int iegbe_up(struct iegbe_adapter *adapter);
- void iegbe_down(struct iegbe_adapter *adapter);
-+void iegbe_reinit_locked(struct iegbe_adapter *adapter);
- void iegbe_reset(struct iegbe_adapter *adapter);
- int iegbe_set_spd_dplx(struct iegbe_adapter *adapter, uint16_t spddplx);
- int iegbe_setup_all_tx_resources(struct iegbe_adapter *adapter);
- int iegbe_setup_all_rx_resources(struct iegbe_adapter *adapter);
- void iegbe_free_all_tx_resources(struct iegbe_adapter *adapter);
- void iegbe_free_all_rx_resources(struct iegbe_adapter *adapter);
--int iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
-+static int iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
- struct iegbe_tx_ring *txdr);
--int iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
-+static int iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rxdr);
--void iegbe_free_tx_resources(struct iegbe_adapter *adapter,
-+static void iegbe_free_tx_resources(struct iegbe_adapter *adapter,
- struct iegbe_tx_ring *tx_ring);
--void iegbe_free_rx_resources(struct iegbe_adapter *adapter,
-+static void iegbe_free_rx_resources(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rx_ring);
- void iegbe_update_stats(struct iegbe_adapter *adapter);
--
- static int iegbe_init_module(void);
- static void iegbe_exit_module(void);
- static int iegbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
- static void __devexit iegbe_remove(struct pci_dev *pdev);
- static int iegbe_alloc_queues(struct iegbe_adapter *adapter);
--#ifdef CONFIG_E1000_MQ
--static void iegbe_setup_queue_mapping(struct iegbe_adapter *adapter);
--#endif
- static int iegbe_sw_init(struct iegbe_adapter *adapter);
- static int iegbe_open(struct net_device *netdev);
- static int iegbe_close(struct net_device *netdev);
-@@ -249,7 +114,8 @@ static void iegbe_clean_tx_ring(struct i
- struct iegbe_tx_ring *tx_ring);
- static void iegbe_clean_rx_ring(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rx_ring);
--static void iegbe_set_multi(struct net_device *netdev);
-+
-+static void iegbe_set_rx_mode(struct net_device *netdev);
- static void iegbe_update_phy_info(unsigned long data);
- static void iegbe_watchdog(unsigned long data);
- static void iegbe_82547_tx_fifo_stall(unsigned long data);
-@@ -257,66 +123,46 @@ static int iegbe_xmit_frame(struct sk_bu
- static struct net_device_stats * iegbe_get_stats(struct net_device *netdev);
- static int iegbe_change_mtu(struct net_device *netdev, int new_mtu);
- static int iegbe_set_mac(struct net_device *netdev, void *p);
--static irqreturn_t iegbe_intr(int irq, void *data, struct pt_regs *regs);
-+static irqreturn_t iegbe_intr(int irq, void *data);
-
--void iegbe_tasklet(unsigned long);
-+static irqreturn_t iegbe_intr_msi(int irq, void *data);
-
--#ifndef IEGBE_GBE_WORKAROUND
--static boolean_t iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
-+static bool iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
- struct iegbe_tx_ring *tx_ring);
--#endif
--
--#ifdef CONFIG_E1000_NAPI
--static int iegbe_clean(struct net_device *poll_dev, int *budget);
--static boolean_t iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
-+static int iegbe_clean(struct napi_struct *napi, int budget);
-+static bool iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rx_ring,
- int *work_done, int work_to_do);
--static boolean_t iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
-+static bool iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rx_ring,
- int *work_done, int work_to_do);
--#else
--static boolean_t iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
-- struct iegbe_rx_ring *rx_ring);
--static boolean_t iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
-- struct iegbe_rx_ring *rx_ring);
--#endif
-
--#ifdef IEGBE_GBE_WORKAROUND
-+
- static void iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rx_ring,
- int cleaned_count);
- static void iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rx_ring,
- int cleaned_count);
--#else
--static void iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
-- struct iegbe_rx_ring *rx_ring);
--static void iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
-- struct iegbe_rx_ring *rx_ring);
--#endif
-+
-
- static int iegbe_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
--#ifdef SIOCGMIIPHY
- static int iegbe_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
-- int cmd);
--#endif
-+ int cmd);
- void set_ethtool_ops(struct net_device *netdev);
- extern int ethtool_ioctl(struct ifreq *ifr);
- static void iegbe_enter_82542_rst(struct iegbe_adapter *adapter);
- static void iegbe_leave_82542_rst(struct iegbe_adapter *adapter);
- static void iegbe_tx_timeout(struct net_device *dev);
--static void iegbe_tx_timeout_task(struct net_device *dev);
-+static void iegbe_reset_task(struct work_struct *work);
- static void iegbe_smartspeed(struct iegbe_adapter *adapter);
- static inline int iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter,
-- struct sk_buff *skb);
-+ struct sk_buff *skb);
-
--#ifdef NETIF_F_HW_VLAN_TX
--static void iegbe_vlan_rx_register(struct net_device *netdev,
-- struct vlan_group *grp);
-+static void iegbe_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
- static void iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
- static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
- static void iegbe_restore_vlan(struct iegbe_adapter *adapter);
--#endif
-
- static int iegbe_notify_reboot(struct notifier_block *,
- unsigned long event,
-@@ -331,15 +177,17 @@ static int iegbe_resume(struct pci_dev *
- static void iegbe_netpoll (struct net_device *netdev);
- #endif
-
--#ifdef CONFIG_E1000_MQ
--/* for multiple Rx queues */
-+#define COPYBREAK_DEFAULT 256
-+static unsigned int copybreak __read_mostly = COPYBREAK_DEFAULT;
-+module_param(copybreak, uint, 0644);
-+MODULE_PARM_DESC(copybreak,
-+ "Maximum size of packet that is copied to a new buffer on receive");
- void iegbe_rx_schedule(void *data);
--#endif
-
- struct notifier_block iegbe_notifier_reboot = {
-- .notifier_call = iegbe_notify_reboot,
-- .next = NULL,
-- .priority = 0
-+ .notifier_call = iegbe_notify_reboot,
-+ .next = NULL,
-+ .priority = 0
- };
-
- /* Exported from other modules */
-@@ -347,14 +195,14 @@ struct notifier_block iegbe_notifier_reb
- extern void iegbe_check_options(struct iegbe_adapter *adapter);
-
- static struct pci_driver iegbe_driver = {
-- .name = iegbe_driver_name,
-- .id_table = iegbe_pci_tbl,
-- .probe = iegbe_probe,
-- .remove = __devexit_p(iegbe_remove),
-- /* Power Managment Hooks */
-+ .name = iegbe_driver_name,
-+ .id_table = iegbe_pci_tbl,
-+ .probe = iegbe_probe,
-+ .remove = __devexit_p(iegbe_remove),
-+ /* Power Managment Hooks */
- #ifdef CONFIG_PM
-- .suspend = iegbe_suspend,
-- .resume = iegbe_resume
-+ .suspend = iegbe_suspend,
-+ .resume = iegbe_resume
- #endif
- };
-
-@@ -364,46 +212,17 @@ MODULE_LICENSE("GPL");
- MODULE_VERSION(DRV_VERSION);
-
- static int debug = NETIF_MSG_DRV | NETIF_MSG_PROBE;
--module_param(debug, int, 0);
-+module_param(debug, int, 0x0);
- MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
-
--static uint8_t gcu_suspend = 0;
--static uint8_t gcu_resume = 0;
-+static uint8_t gcu_suspend = 0x0;
-+static uint8_t gcu_resume = 0x0;
- struct pci_dev *gcu = NULL;
-
--unsigned long tasklet_data;
--DECLARE_TASKLET(iegbe_reset_tasklet, iegbe_tasklet, (unsigned long) &tasklet_data);
-
- /**
- * iegbe_iegbe_tasklet -*
- **/
--void iegbe_tasklet(unsigned long data)
--{
-- char* err_msg = "TEST";
-- uint32_t *icr = (uint32_t*) data;
-- uint32_t gbe = *icr & 0x000000FF;
-- if( *icr & E1000_ICR_RX_DESC_FIFO_PAR) { /* 21 */
-- err_msg = "DMA Transmit Descriptor 2-bit ECC Error!";
-- }
-- if( *icr & E1000_ICR_TX_DESC_FIFO_PAR) { /* 20 */
-- err_msg = "DMA Receive Descriptor 2-bit ECC Error!";
-- }
-- if( *icr & E1000_ICR_PB) { /* 23 */
-- err_msg = "DMA Packet Buffer 2-bit ECC Error!";
-- }
-- if( *icr & E1000_ICR_CPP_TARGET) { /* 27 */
-- err_msg = "Statistic Register ECC Error!";
-- }
-- if( *icr & E1000_ICR_CPP_MASTER) {
-- err_msg = "CPP Error!";
-- }
-- spin_lock(&print_lock);
-- printk("IEGBE%d: System Reset due to: %s\n", gbe, err_msg);
-- dump_stack();
-- spin_unlock(&print_lock);
-- panic(err_msg);
-- return;
--}
- /**
- * iegbe_init_module - Driver Registration Routine
- *
-@@ -411,21 +230,24 @@ void iegbe_tasklet(unsigned long data)
- * loaded. All it does is register with the PCI subsystem.
- **/
-
--static int __init
--iegbe_init_module(void)
-+static int __init iegbe_init_module(void)
- {
-- int ret;
-+ int ret;
-
- printk(KERN_INFO "%s - version %s\n",
-- iegbe_driver_string, iegbe_driver_version);
-+ iegbe_driver_string, iegbe_driver_version);
-
-- printk(KERN_INFO "%s\n", iegbe_copyright);
-+ printk(KERN_INFO "%s\n", iegbe_copyright);
-
-- ret = pci_module_init(&iegbe_driver);
-- if(ret >= 0) {
-- register_reboot_notifier(&iegbe_notifier_reboot);
-- }
-- return ret;
-+ ret = pci_register_driver(&iegbe_driver);
-+ if (copybreak != COPYBREAK_DEFAULT) {
-+ if (copybreak == 0)
-+ printk(KERN_INFO "iegbe: copybreak disabled\n");
-+ else
-+ printk(KERN_INFO "iegbe: copybreak enabled for "
-+ "packets <= %u bytes\n", copybreak);
-+ }
-+ return ret;
- }
-
- module_init(iegbe_init_module);
-@@ -437,29 +259,51 @@ module_init(iegbe_init_module);
- * from memory.
- **/
-
--static void __exit
--iegbe_exit_module(void)
-+static void __exit iegbe_exit_module(void)
- {
--
-- unregister_reboot_notifier(&iegbe_notifier_reboot);
-- pci_unregister_driver(&iegbe_driver);
-+ pci_unregister_driver(&iegbe_driver);
- }
-
- module_exit(iegbe_exit_module);
-
-+static int iegbe_request_irq(struct iegbe_adapter *adapter)
-+{
-+ struct net_device *netdev = adapter->netdev;
-+ irq_handler_t handler = iegbe_intr;
-+ int irq_flags = IRQF_SHARED;
-+ int err;
-+ adapter->have_msi = !pci_enable_msi(adapter->pdev);
-+ if (adapter->have_msi) {
-+ handler = iegbe_intr_msi;
-+ irq_flags = 0;
-+ }
-+ err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
-+ netdev);
-+ if (err) {
-+ if (adapter->have_msi)
-+ pci_disable_msi(adapter->pdev);
-+ DPRINTK(PROBE, ERR,
-+ "Unable to allocate interrupt Error: %d\n", err);
-+ }
-+ return err;
-+}
-+static void iegbe_free_irq(struct iegbe_adapter *adapter)
-+{
-+ struct net_device *netdev = adapter->netdev;
-+ free_irq(adapter->pdev->irq, netdev);
-+ if (adapter->have_msi)
-+ pci_disable_msi(adapter->pdev);
-+}
- /**
- * iegbe_irq_disable - Mask off interrupt generation on the NIC
- * @adapter: board private structure
- **/
-
--static inline void
--iegbe_irq_disable(struct iegbe_adapter *adapter)
-+static void iegbe_irq_disable(struct iegbe_adapter *adapter)
- {
--
-- atomic_inc(&adapter->irq_sem);
-- E1000_WRITE_REG(&adapter->hw, IMC, ~0);
-- E1000_WRITE_FLUSH(&adapter->hw);
-- synchronize_irq(adapter->pdev->irq);
-+ E1000_WRITE_REG(&adapter->hw, IMC, ~0);
-+ E1000_WRITE_FLUSH(&adapter->hw);
-+ synchronize_irq(adapter->pdev->irq);
- }
-
- /**
-@@ -470,244 +314,414 @@ iegbe_irq_disable(struct iegbe_adapter *
- static inline void
- iegbe_irq_enable(struct iegbe_adapter *adapter)
- {
--
-- if(likely(atomic_dec_and_test(&adapter->irq_sem))) {
-- E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK);
-- E1000_WRITE_FLUSH(&adapter->hw);
-- }
-+ E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK);
-+ E1000_WRITE_FLUSH(&adapter->hw);
- }
--#ifdef NETIF_F_HW_VLAN_TX
--void
--iegbe_update_mng_vlan(struct iegbe_adapter *adapter)
--{
-- struct net_device *netdev = adapter->netdev;
-- uint16_t vid = adapter->hw.mng_cookie.vlan_id;
-- uint16_t old_vid = adapter->mng_vlan_id;
-
-- if(adapter->vlgrp) {
-- if(!adapter->vlgrp->vlan_devices[vid]) {
-- if(adapter->hw.mng_cookie.status &
-- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
-- iegbe_vlan_rx_add_vid(netdev, vid);
-- adapter->mng_vlan_id = vid;
-- } else {
-- adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
-- }
-- if((old_vid != (uint16_t)E1000_MNG_VLAN_NONE) &&
-- (vid != old_vid) &&
-- !adapter->vlgrp->vlan_devices[old_vid]) {
-- iegbe_vlan_rx_kill_vid(netdev, old_vid);
-- }
-- }
--}
-+static void iegbe_update_mng_vlan(struct iegbe_adapter *adapter)
-+{
-+ struct iegbe_hw *hw = &adapter->hw;
-+ struct net_device *netdev = adapter->netdev;
-+ u16 vid = hw->mng_cookie.vlan_id;
-+ u16 old_vid = adapter->mng_vlan_id;
-+ if (adapter->vlgrp) {
-+ if (!vlan_group_get_device(adapter->vlgrp, vid)) {
-+ if (hw->mng_cookie.status &
-+ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
-+ iegbe_vlan_rx_add_vid(netdev, vid);
-+ adapter->mng_vlan_id = vid;
-+ } else
-+ adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
-+
-+ if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
-+ (vid != old_vid) &&
-+ !vlan_group_get_device(adapter->vlgrp, old_vid))
-+ iegbe_vlan_rx_kill_vid(netdev, old_vid);
-+ } else
-+ adapter->mng_vlan_id = vid;
-+ }
- }
--#endif
-
--int
--iegbe_up(struct iegbe_adapter *adapter)
-+/**
-+ * iegbe_configure - configure the hardware for RX and TX
-+ * @adapter = private board structure
-+ **/
-+static void iegbe_configure(struct iegbe_adapter *adapter)
- {
- struct net_device *netdev = adapter->netdev;
-- int i, err;
-- uint16_t pci_cmd;
--
-- /* hardware has been reset, we need to reload some things */
--
-- /* Reset the PHY if it was previously powered down */
-- if(adapter->hw.media_type == iegbe_media_type_copper
-- || (adapter->hw.media_type == iegbe_media_type_oem
-- && iegbe_oem_phy_is_copper(&adapter->hw))) {
-- uint16_t mii_reg;
-- iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
-- if(mii_reg & MII_CR_POWER_DOWN){
-- iegbe_phy_reset(&adapter->hw);
-- }
-- }
-+ int i;
-
-- iegbe_set_multi(netdev);
-+ iegbe_set_rx_mode(netdev);
-
--#ifdef NETIF_F_HW_VLAN_TX
- iegbe_restore_vlan(adapter);
--#endif
-
- iegbe_configure_tx(adapter);
- iegbe_setup_rctl(adapter);
- iegbe_configure_rx(adapter);
-+ /* call E1000_DESC_UNUSED which always leaves
-+ * at least 1 descriptor unused to make sure
-+ * next_to_use != next_to_clean */
-+ for (i = 0; i < adapter->num_rx_queues; i++) {
-+ struct iegbe_rx_ring *ring = &adapter->rx_ring[i];
-+ adapter->alloc_rx_buf(adapter, ring,
-+ E1000_DESC_UNUSED(ring));
-+ }
-
--#ifdef IEGBE_GBE_WORKAROUND
-- for (i = 0; i < adapter->num_queues; i++)
-- adapter->alloc_rx_buf(adapter, &adapter->rx_ring[i],
-- IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS + 1);
--#else
-- for (i = 0; i < adapter->num_queues; i++)
-- adapter->alloc_rx_buf(adapter, &adapter->rx_ring[i]);
--#endif
-+ adapter->tx_queue_len = netdev->tx_queue_len;
-+}
-
--#ifdef CONFIG_PCI_MSI
-- if(adapter->hw.mac_type > iegbe_82547_rev_2
-- || adapter->hw.mac_type == iegbe_icp_xxxx) {
-- adapter->have_msi = TRUE;
-- if((err = pci_enable_msi(adapter->pdev))) {
-- DPRINTK(PROBE, ERR,
-- "Unable to allocate MSI interrupt Error: %d\n", err);
-- adapter->have_msi = FALSE;
-- }
-- }
-- pci_read_config_word(adapter->pdev, PCI_COMMAND, &pci_cmd);
-- pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd | IEGBE_INTD_DISABLE);
-+int iegbe_up(struct iegbe_adapter *adapter)
-+{
-+ /* hardware has been reset, we need to reload some things */
-+ iegbe_configure(adapter);
-
--#endif
-- if((err = request_irq(adapter->pdev->irq, &iegbe_intr,
-- SA_SHIRQ | SA_SAMPLE_RANDOM,
-- netdev->name, netdev))) {
-- DPRINTK(PROBE, ERR,
-- "Unable to allocate interrupt Error: %d\n", err);
-- return err;
-- }
-+ clear_bit(__E1000_DOWN, &adapter->flags);
-
-- mod_timer(&adapter->watchdog_timer, jiffies);
-+ napi_enable(&adapter->napi);
-
--#ifdef CONFIG_E1000_NAPI
-- netif_poll_enable(netdev);
--#endif
- iegbe_irq_enable(adapter);
-
-+ adapter->hw.get_link_status = 0x1;
- return 0;
- }
-
--void
--iegbe_down(struct iegbe_adapter *adapter)
--{
-- struct net_device *netdev = adapter->netdev;
--
-- iegbe_irq_disable(adapter);
--#ifdef CONFIG_E1000_MQ
-- while (atomic_read(&adapter->rx_sched_call_data.count) != 0) { };
--#endif
-- free_irq(adapter->pdev->irq, netdev);
--#ifdef CONFIG_PCI_MSI
-- if((adapter->hw.mac_type > iegbe_82547_rev_2
-- || adapter->hw.mac_type == iegbe_icp_xxxx)
-- && adapter->have_msi == TRUE) {
-- pci_disable_msi(adapter->pdev);
-- }
--#endif
-- del_timer_sync(&adapter->tx_fifo_stall_timer);
-- del_timer_sync(&adapter->watchdog_timer);
-- del_timer_sync(&adapter->phy_info_timer);
-+/**
-+ * iegbe_power_up_phy - restore link in case the phy was powered down
-+ * @adapter: address of board private structure
-+ *
-+ * The phy may be powered down to save power and turn off link when the
-+ * driver is unloaded and wake on lan is not enabled (among others)
-+ * *** this routine MUST be followed by a call to iegbe_reset ***
-+ *
-+ **/
-
--#ifdef CONFIG_E1000_NAPI
-- netif_poll_disable(netdev);
--#endif
-- adapter->link_speed = 0;
-- adapter->link_duplex = 0;
-- netif_carrier_off(netdev);
-- netif_stop_queue(netdev);
-+void iegbe_power_up_phy(struct iegbe_adapter *adapter)
-+{
-+ struct iegbe_hw *hw = &adapter->hw;
-+ u16 mii_reg = 0;
-
-- iegbe_reset(adapter);
-- iegbe_clean_all_tx_rings(adapter);
-- iegbe_clean_all_rx_rings(adapter);
-+ /* Just clear the power down bit to wake the phy back up */
-+ if (hw->media_type == iegbe_media_type_copper) {
-+ /* according to the manual, the phy will retain its
-+ * settings across a power-down/up cycle */
-+ iegbe_read_phy_reg(hw, PHY_CTRL, &mii_reg);
-+ mii_reg &= ~MII_CR_POWER_DOWN;
-+ iegbe_write_phy_reg(hw, PHY_CTRL, mii_reg);
-+ }
-+}
-
-- /* If WoL is not enabled and management mode is not IAMT
-- * or if WoL is not enabled and OEM PHY is copper based,
-- * power down the PHY so no link is implied when interface is down */
-- if(!adapter->wol
-- && ((adapter->hw.mac_type >= iegbe_82540
-- && adapter->hw.media_type == iegbe_media_type_copper
-- && !iegbe_check_mng_mode(&adapter->hw)
-- && !(E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN))
-- || (adapter->hw.media_type == iegbe_media_type_oem
-- && iegbe_oem_phy_is_copper(&adapter->hw)))){
-+static void iegbe_power_down_phy(struct iegbe_adapter *adapter)
-+{
-+ struct iegbe_hw *hw = &adapter->hw;
-
-- uint16_t mii_reg;
-- iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
-+ /* Power down the PHY so no link is implied when interface is down *
-+ * The PHY cannot be powered down if any of the following is true *
-+ * (a) WoL is enabled
-+ * (b) AMT is active
-+ * (c) SoL/IDER session is active */
-+ if (!adapter->wol && hw->mac_type >= iegbe_82540 &&
-+ hw->media_type == iegbe_media_type_copper) {
-+ u16 mii_reg = 0;
-+
-+ switch (hw->mac_type) {
-+ case iegbe_82540:
-+ case iegbe_82545:
-+ case iegbe_82545_rev_3:
-+ case iegbe_82546:
-+ case iegbe_82546_rev_3:
-+ case iegbe_82541:
-+ case iegbe_82541_rev_2:
-+ case iegbe_82547:
-+ case iegbe_82547_rev_2:
-+ if (E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN)
-+ goto out;
-+ break;
-+ case iegbe_82571:
-+ case iegbe_82572:
-+ case iegbe_82573:
-+ if (iegbe_check_mng_mode(hw) ||
-+ iegbe_check_phy_reset_block(hw))
-+ goto out;
-+ break;
-+ default:
-+ goto out;
-+ }
-+ iegbe_read_phy_reg(hw, PHY_CTRL, &mii_reg);
- mii_reg |= MII_CR_POWER_DOWN;
-- iegbe_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg);
-+ iegbe_write_phy_reg(hw, PHY_CTRL, mii_reg);
- mdelay(1);
- }
-+out:
-+ return;
- }
-
--void
--iegbe_reset(struct iegbe_adapter *adapter)
-+void iegbe_down(struct iegbe_adapter *adapter)
- {
-- struct net_device *netdev = adapter->netdev;
-- uint32_t pba, manc;
-- uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF;
-- uint16_t fc_low_water_mark = E1000_FC_LOW_DIFF;
-+ struct net_device *netdev = adapter->netdev;
-
-+ /* signal that we're down so the interrupt handler does not
-+ * reschedule our watchdog timer */
-+ set_bit(__E1000_DOWN, &adapter->flags);
-
-- /* Repartition Pba for greater than 9k mtu
-- * To take effect CTRL.RST is required.
-- */
-+ napi_disable(&adapter->napi);
-
-- switch (adapter->hw.mac_type) {
-- case iegbe_82547:
-- case iegbe_82547_rev_2:
-- pba = E1000_PBA_30K;
-- break;
-- case iegbe_82571:
-- case iegbe_82572:
-- pba = E1000_PBA_38K;
-- break;
-- case iegbe_82573:
-- pba = E1000_PBA_12K;
-+ iegbe_irq_disable(adapter);
-+
-+ del_timer_sync(&adapter->tx_fifo_stall_timer);
-+ del_timer_sync(&adapter->watchdog_timer);
-+ del_timer_sync(&adapter->phy_info_timer);
-+
-+ netdev->tx_queue_len = adapter->tx_queue_len;
-+ adapter->link_speed = 0;
-+ adapter->link_duplex = 0;
-+ netif_carrier_off(netdev);
-+ netif_stop_queue(netdev);
-+
-+ iegbe_reset(adapter);
-+ iegbe_clean_all_tx_rings(adapter);
-+ iegbe_clean_all_rx_rings(adapter);
-+}
-+void iegbe_reinit_locked(struct iegbe_adapter *adapter)
-+{
-+ WARN_ON(in_interrupt());
-+ while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
-+ msleep(1);
-+ iegbe_down(adapter);
-+ iegbe_up(adapter);
-+ clear_bit(__E1000_RESETTING, &adapter->flags);
-+}
-+
-+void iegbe_reset(struct iegbe_adapter *adapter)
-+{
-+ struct iegbe_hw *hw = &adapter->hw;
-+ u32 pba = 0, tx_space, min_tx_space, min_rx_space;
-+ u16 fc_high_water_mark = E1000_FC_HIGH_DIFF;
-+ bool legacy_pba_adjust = false;
-+
-+ /* Repartition Pba for greater than 9k mtu
-+ * To take effect CTRL.RST is required.
-+ */
-+
-+ switch (hw->mac_type) {
-+ case iegbe_82542_rev2_0:
-+ case iegbe_82542_rev2_1:
-+ case iegbe_82543:
-+ case iegbe_82544:
-+ case iegbe_82540:
-+ case iegbe_82541:
-+ case iegbe_82541_rev_2:
-+ case iegbe_icp_xxxx:
-+ legacy_pba_adjust = true;
-+ pba = E1000_PBA_48K;
- break;
-- default:
-+ case iegbe_82545:
-+ case iegbe_82545_rev_3:
-+ case iegbe_82546:
-+ case iegbe_82546_rev_3:
- pba = E1000_PBA_48K;
- break;
-- }
-+ case iegbe_82547:
-+ case iegbe_82573:
-+ case iegbe_82547_rev_2:
-+ legacy_pba_adjust = true;
-+ pba = E1000_PBA_30K;
-+ break;
-+ case iegbe_82571:
-+ case iegbe_82572:
-+ case iegbe_undefined:
-+ case iegbe_num_macs:
-+ break;
-+ }
-+
-+ if (legacy_pba_adjust) {
-+ if (adapter->netdev->mtu > E1000_RXBUFFER_8192)
-+ pba -= 8; /* allocate more FIFO for Tx */
-+ /* send an XOFF when there is enough space in the
-+ * Rx FIFO to hold one extra full size Rx packet
-+ */
-
-- if((adapter->hw.mac_type != iegbe_82573) &&
-- (adapter->rx_buffer_len > E1000_RXBUFFER_8192)) {
-- pba -= 0x8; /* allocate more FIFO for Tx */
-- /* send an XOFF when there is enough space in the
-- * Rx FIFO to hold one extra full size Rx packet
-- */
-- fc_high_water_mark = netdev->mtu + ENET_HEADER_SIZE +
-- ETHERNET_FCS_SIZE + 0x1;
-- fc_low_water_mark = fc_high_water_mark + 0x8;
-- }
-
-+ if (hw->mac_type == iegbe_82547) {
-+ adapter->tx_fifo_head = 0;
-+ adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
-+ adapter->tx_fifo_size =
-+ (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
-+ atomic_set(&adapter->tx_fifo_stall, 0);
-+ }
-+ } else if (hw->max_frame_size > MAXIMUM_ETHERNET_FRAME_SIZE) {
-+ E1000_WRITE_REG(&adapter->hw, PBA, pba);
-+
-+ /* To maintain wire speed transmits, the Tx FIFO should be
-+ * large enough to accomodate two full transmit packets,
-+ * rounded up to the next 1KB and expressed in KB. Likewise,
-+ * the Rx FIFO should be large enough to accomodate at least
-+ * one full receive packet and is similarly rounded up and
-+ * expressed in KB. */
-+ pba = E1000_READ_REG(&adapter->hw, PBA);
-+ /* upper 16 bits has Tx packet buffer allocation size in KB */
-+ tx_space = pba >> 16;
-+ /* lower 16 bits has Rx packet buffer allocation size in KB */
-+ pba &= 0xffff;
-+ /* don't include ethernet FCS because hardware appends/strips */
-+ min_rx_space = adapter->netdev->mtu + ENET_HEADER_SIZE +
-+ VLAN_TAG_SIZE;
-+ min_tx_space = min_rx_space;
-+ min_tx_space *= 2;
-+ min_tx_space = ALIGN(min_tx_space, 1024);
-+ min_tx_space >>= 10;
-+ min_rx_space = ALIGN(min_rx_space, 1024);
-+ min_rx_space >>= 10;
-+
-+ /* If current Tx allocation is less than the min Tx FIFO size,
-+ * and the min Tx FIFO size is less than the current Rx FIFO
-+ * allocation, take space away from current Rx allocation */
-+ if (tx_space < min_tx_space &&
-+ ((min_tx_space - tx_space) < pba)) {
-+ pba = pba - (min_tx_space - tx_space);
-+
-+ /* PCI/PCIx hardware has PBA alignment constraints */
-+ switch (hw->mac_type) {
-+ case iegbe_82545 ... iegbe_82546_rev_3:
-+ pba &= ~(E1000_PBA_8K - 1);
-+ break;
-+ default:
-+ break;
-+ }
-
-- if(adapter->hw.mac_type == iegbe_82547) {
-- adapter->tx_fifo_head = 0;
-- adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
-- adapter->tx_fifo_size =
-- (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
-- atomic_set(&adapter->tx_fifo_stall, 0);
-+ /* if short on rx space, rx wins and must trump tx
-+ * adjustment or use Early Receive if available */
-+ if (pba < min_rx_space) {
-+ switch (hw->mac_type) {
-+ case iegbe_82573:
-+ /* ERT enabled in iegbe_configure_rx */
-+ break;
-+ default:
-+ pba = min_rx_space;
-+ break;
-+ }
-+ }
-+ }
- }
-
- E1000_WRITE_REG(&adapter->hw, PBA, pba);
-
- /* flow control settings */
-- adapter->hw.fc_high_water = (pba << E1000_PBA_BYTES_SHIFT) -
-- fc_high_water_mark;
-- adapter->hw.fc_low_water = (pba << E1000_PBA_BYTES_SHIFT) -
-- fc_low_water_mark;
-- adapter->hw.fc_pause_time = E1000_FC_PAUSE_TIME;
-- adapter->hw.fc_send_xon = 1;
-- adapter->hw.fc = adapter->hw.original_fc;
-+ /* Set the FC high water mark to 90% of the FIFO size.
-+ * Required to clear last 3 LSB */
-+ fc_high_water_mark = ((pba * 9216)/10) & 0xFFF8;
-+ /* We can't use 90% on small FIFOs because the remainder
-+ * would be less than 1 full frame. In this case, we size
-+ * it to allow at least a full frame above the high water
-+ * mark. */
-+ if (pba < E1000_PBA_16K)
-+ fc_high_water_mark = (pba * 1024) - 1600;
-+
-+ hw->fc_high_water = fc_high_water_mark;
-+ hw->fc_low_water = fc_high_water_mark - 8;
-+ hw->fc_pause_time = E1000_FC_PAUSE_TIME;
-+ hw->fc_send_xon = 1;
-+ hw->fc = hw->original_fc;
-
- /* Allow time for pending master requests to run */
-- iegbe_reset_hw(&adapter->hw);
-- if(adapter->hw.mac_type >= iegbe_82544){
-+ iegbe_reset_hw(hw);
-+ if (hw->mac_type >= iegbe_82544)
- E1000_WRITE_REG(&adapter->hw, WUC, 0);
-- }
-- if(iegbe_init_hw(&adapter->hw)) {
-+
-+ if (iegbe_init_hw(hw))
- DPRINTK(PROBE, ERR, "Hardware Error\n");
-- }
--#ifdef NETIF_F_HW_VLAN_TX
- iegbe_update_mng_vlan(adapter);
--#endif
-+
-+ /* if (adapter->hwflags & HWFLAGS_PHY_PWR_BIT) { */
-+ if (hw->mac_type >= iegbe_82544 &&
-+ hw->mac_type <= iegbe_82547_rev_2 &&
-+ hw->autoneg == 1 &&
-+ hw->autoneg_advertised == ADVERTISE_1000_FULL) {
-+ u32 ctrl = E1000_READ_REG(&adapter->hw, CTRL);
-+ /* clear phy power management bit if we are in gig only mode,
-+ * which if enabled will attempt negotiation to 100Mb, which
-+ * can cause a loss of link at power off or driver unload */
-+ ctrl &= ~E1000_CTRL_SWDPIN3;
-+ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
-+ }
-+
- /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
- E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE);
-
-- iegbe_reset_adaptive(&adapter->hw);
-- iegbe_phy_get_info(&adapter->hw, &adapter->phy_info);
-- if(adapter->en_mng_pt) {
-- manc = E1000_READ_REG(&adapter->hw, MANC);
-- manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST);
-- E1000_WRITE_REG(&adapter->hw, MANC, manc);
-+ iegbe_reset_adaptive(hw);
-+ iegbe_phy_get_info(hw, &adapter->phy_info);
-+
-+ if (!adapter->smart_power_down &&
-+ (hw->mac_type == iegbe_82571 ||
-+ hw->mac_type == iegbe_82572)) {
-+ u16 phy_data = 0;
-+ /* speed up time to link by disabling smart power down, ignore
-+ * the return value of this function because there is nothing
-+ * different we would do if it failed */
-+ iegbe_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
-+ &phy_data);
-+ phy_data &= ~IGP02E1000_PM_SPD;
-+ iegbe_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
-+ phy_data);
-+ }
-+
-+}
-+
-+/**
-+ * Dump the eeprom for users having checksum issues
-+ **/
-+static void iegbe_dump_eeprom(struct iegbe_adapter *adapter)
-+{
-+ struct net_device *netdev = adapter->netdev;
-+ struct ethtool_eeprom eeprom;
-+ const struct ethtool_ops *ops = netdev->ethtool_ops;
-+ u8 *data;
-+ int i;
-+ u16 csum_old, csum_new = 0;
-+
-+ eeprom.len = ops->get_eeprom_len(netdev);
-+ eeprom.offset = 0;
-+
-+ data = kmalloc(eeprom.len, GFP_KERNEL);
-+ if (!data) {
-+ printk(KERN_ERR "Unable to allocate memory to dump EEPROM"
-+ " data\n");
-+ return;
- }
-+
-+ ops->get_eeprom(netdev, &eeprom, data);
-+
-+ csum_old = (data[EEPROM_CHECKSUM_REG * 2]) +
-+ (data[EEPROM_CHECKSUM_REG * 2 + 1] << 8);
-+ for (i = 0; i < EEPROM_CHECKSUM_REG * 2; i += 2)
-+ csum_new += data[i] + (data[i + 1] << 8);
-+ csum_new = EEPROM_SUM - csum_new;
-+
-+ printk(KERN_ERR "/*********************/\n");
-+ printk(KERN_ERR "Current EEPROM Checksum : 0x%04x\n", csum_old);
-+ printk(KERN_ERR "Calculated : 0x%04x\n", csum_new);
-+
-+ printk(KERN_ERR "Offset Values\n");
-+ printk(KERN_ERR "======== ======\n");
-+ print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1, data, 128, 0);
-+
-+ printk(KERN_ERR "Include this output when contacting your support "
-+ "provider.\n");
-+ printk(KERN_ERR "This is not a software error! Something bad "
-+ "happened to your hardware or\n");
-+ printk(KERN_ERR "EEPROM image. Ignoring this "
-+ "problem could result in further problems,\n");
-+ printk(KERN_ERR "possibly loss of data, corruption or system hangs!\n");
-+ printk(KERN_ERR "The MAC Address will be reset to 00:00:00:00:00:00, "
-+ "which is invalid\n");
-+ printk(KERN_ERR "and requires you to set the proper MAC "
-+ "address manually before continuing\n");
-+ printk(KERN_ERR "to enable this network device.\n");
-+ printk(KERN_ERR "Please inspect the EEPROM dump and report the issue "
-+ "to your hardware vendor\n");
-+ printk(KERN_ERR "or Intel Customer Support.\n");
-+ printk(KERN_ERR "/*********************/\n");
-+
-+ kfree(data);
- }
-
- /**
-@@ -721,184 +735,166 @@ iegbe_reset(struct iegbe_adapter *adapte
- * The OS initialization, configuring of the adapter private structure,
- * and a hardware reset occur.
- **/
--
--static int __devinit
--iegbe_probe(struct pci_dev *pdev,
-+static int __devinit iegbe_probe(struct pci_dev *pdev,
- const struct pci_device_id *ent)
- {
-- struct net_device *netdev;
-- struct iegbe_adapter *adapter;
-- unsigned long mmio_start, mmio_len;
-- uint32_t ctrl_ext;
-- uint32_t swsm;
-+ struct net_device *netdev;
-+ struct iegbe_adapter *adapter;
-+ struct iegbe_hw *hw;
-
- static int cards_found = 0;
-+ int i, err, pci_using_dac;
-+ u16 eeprom_data = 0;
-+ u16 eeprom_apme_mask = E1000_EEPROM_APME;
-+ int bars;
-+ DECLARE_MAC_BUF(mac);
-
-- int i, err, pci_using_dac;
-- uint16_t eeprom_data = 0;
-- uint16_t eeprom_apme_mask = E1000_EEPROM_APME;
-+ bars = pci_select_bars(pdev, IORESOURCE_MEM);
-+ err = pci_enable_device(pdev);
-
-+ if (err)
-+ return err;
-
-- if((err = pci_enable_device(pdev))) {
-- return err;
-- }
-- if(!(err = pci_set_dma_mask(pdev, PCI_DMA_64BIT))) {
-+ if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK) &&
-+ !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
- pci_using_dac = 1;
-- } else {
-- if((err = pci_set_dma_mask(pdev, PCI_DMA_32BIT))) {
-- E1000_ERR("No usable DMA configuration, aborting\n");
-- return err;
-- }
-+ } else {
-+ err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
-+ if (err) {
-+ err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
-+ if (err) {
-+ E1000_ERR("No usable DMA configuration, "
-+ "aborting\n");
-+ goto err_dma;
-+ }
-+ }
- pci_using_dac = 0;
-- }
--
-- if((err = pci_request_regions(pdev, iegbe_driver_name))) {
-- return err;
- }
-- pci_set_master(pdev);
-
-- netdev = alloc_etherdev(sizeof(struct iegbe_adapter));
-- if(!netdev) {
-- err = -ENOMEM;
-- goto err_alloc_etherdev;
-- }
-+ err = pci_request_selected_regions(pdev, bars, iegbe_driver_name);
-+ if (err)
-+ goto err_pci_reg;
-+
-+ pci_set_master(pdev);
-+
-+ err = -ENOMEM;
-+ netdev = alloc_etherdev(sizeof(struct iegbe_adapter));
-+ if (!netdev)
-+ goto err_alloc_etherdev;
-
-- SET_MODULE_OWNER(netdev);
- SET_NETDEV_DEV(netdev, &pdev->dev);
-
-- pci_set_drvdata(pdev, netdev);
-- adapter = netdev_priv(netdev);
-- adapter->netdev = netdev;
-- adapter->pdev = pdev;
-- adapter->hw.back = adapter;
-- adapter->msg_enable = (0x1 << debug) - 0x1;
--
-- mmio_start = pci_resource_start(pdev, BAR_0);
-- mmio_len = pci_resource_len(pdev, BAR_0);
--
-- adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
-- if(!adapter->hw.hw_addr) {
-- err = -EIO;
-- goto err_ioremap;
-- }
--
-- for(i = BAR_1; i <= BAR_5; i++) {
-- if(pci_resource_len(pdev, i) == 0) {
-- continue;
-- }
-- if(pci_resource_flags(pdev, i) & IORESOURCE_IO) {
-- adapter->hw.io_base = pci_resource_start(pdev, i);
-- break;
-- }
-- }
--
-- netdev->open = &iegbe_open;
-- netdev->stop = &iegbe_close;
-- netdev->hard_start_xmit = &iegbe_xmit_frame;
-- netdev->get_stats = &iegbe_get_stats;
-- netdev->set_multicast_list = &iegbe_set_multi;
-+ pci_set_drvdata(pdev, netdev);
-+ adapter = netdev_priv(netdev);
-+ adapter->netdev = netdev;
-+ adapter->pdev = pdev;
-+ adapter->msg_enable = (1 << debug) - 1;
-+ adapter->bars = bars;
-+
-+ hw = &adapter->hw;
-+ hw->back = adapter;
-+
-+ err = -EIO;
-+ hw->hw_addr = ioremap(pci_resource_start(pdev, BAR_0),
-+ pci_resource_len(pdev, BAR_0));
-+ if (!hw->hw_addr)
-+ goto err_ioremap;
-+
-+ netdev->open = &iegbe_open;
-+ netdev->stop = &iegbe_close;
-+ netdev->hard_start_xmit = &iegbe_xmit_frame;
-+ netdev->get_stats = &iegbe_get_stats;
-+ netdev->set_rx_mode = &iegbe_set_rx_mode;
- netdev->set_mac_address = &iegbe_set_mac;
-- netdev->change_mtu = &iegbe_change_mtu;
-- netdev->do_ioctl = &iegbe_ioctl;
-+ netdev->change_mtu = &iegbe_change_mtu;
-+ netdev->do_ioctl = &iegbe_ioctl;
- set_ethtool_ops(netdev);
--#ifdef HAVE_TX_TIMEOUT
-- netdev->tx_timeout = &iegbe_tx_timeout;
-- netdev->watchdog_timeo = 0x5 * HZ;
--#endif
--#ifdef CONFIG_E1000_NAPI
-- netdev->poll = &iegbe_clean;
-- netdev->weight = 0x40;
--#endif
--#ifdef NETIF_F_HW_VLAN_TX
-- netdev->vlan_rx_register = iegbe_vlan_rx_register;
-- netdev->vlan_rx_add_vid = iegbe_vlan_rx_add_vid;
-- netdev->vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid;
--#endif
-+ netdev->tx_timeout = &iegbe_tx_timeout;
-+ netdev->watchdog_timeo = 5 * HZ;
-+ netif_napi_add(netdev, &adapter->napi, iegbe_clean, 64);
-+ netdev->vlan_rx_register = iegbe_vlan_rx_register;
-+ netdev->vlan_rx_add_vid = iegbe_vlan_rx_add_vid;
-+ netdev->vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid;
- #ifdef CONFIG_NET_POLL_CONTROLLER
-- netdev->poll_controller = iegbe_netpoll;
-+ netdev->poll_controller = iegbe_netpoll;
- #endif
-- strcpy(netdev->name, pci_name(pdev));
-+ strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
-
-- netdev->mem_start = mmio_start;
-- netdev->mem_end = mmio_start + mmio_len;
-- netdev->base_addr = adapter->hw.io_base;
-
-- adapter->bd_number = cards_found;
-+ adapter->bd_number = cards_found;
-
-- /* setup the private structure */
-+ /* setup the private structure */
-
-- if((err = iegbe_sw_init(adapter))) {
-- goto err_sw_init;
-- }
-- if((err = iegbe_check_phy_reset_block(&adapter->hw))) {
-- DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
-- }
--#ifdef MAX_SKB_FRAGS
-- if(adapter->hw.mac_type >= iegbe_82543) {
--#ifdef NETIF_F_HW_VLAN_TX
-- netdev->features = NETIF_F_SG |
-- NETIF_F_HW_CSUM |
-- NETIF_F_HW_VLAN_TX |
-- NETIF_F_HW_VLAN_RX |
-- NETIF_F_HW_VLAN_FILTER;
--#else
-- netdev->features = NETIF_F_SG | NETIF_F_HW_CSUM;
--#endif
-- }
-+ err = iegbe_sw_init(adapter);
-+ if (err)
-+ goto err_sw_init;
-+ err = -EIO;
-+ if (iegbe_check_phy_reset_block(hw))
-+ DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
-
--#ifdef NETIF_F_TSO
-- if((adapter->hw.mac_type >= iegbe_82544) &&
-- (adapter->hw.mac_type != iegbe_82547)) {
-- netdev->features |= NETIF_F_TSO;
-- }
--#ifdef NETIF_F_TSO_IPV6
-- if(adapter->hw.mac_type > iegbe_82547_rev_2) {
-- netdev->features |= NETIF_F_TSO_IPV6;
-- }
--#endif
--#endif
-- if(pci_using_dac) {
-- netdev->features |= NETIF_F_HIGHDMA;
-+ if (hw->mac_type >= iegbe_82543) {
-+ netdev->features = NETIF_F_SG |
-+ NETIF_F_HW_CSUM |
-+ NETIF_F_HW_VLAN_TX |
-+ NETIF_F_HW_VLAN_RX |
-+ NETIF_F_HW_VLAN_FILTER;
- }
--#endif
--#ifdef NETIF_F_LLTX
-- netdev->features |= NETIF_F_LLTX;
--#endif
-
-- adapter->en_mng_pt = iegbe_enable_mng_pass_thru(&adapter->hw);
-+ if ((hw->mac_type >= iegbe_82544) &&
-+ (hw->mac_type != iegbe_82547))
-+ netdev->features |= NETIF_F_TSO;
-
-- /* before reading the EEPROM, reset the controller to
-- * put the device in a known good starting state */
-+ if (hw->mac_type > iegbe_82547_rev_2)
-+ netdev->features |= NETIF_F_TSO6;
-+ if (pci_using_dac)
-+ netdev->features |= NETIF_F_HIGHDMA;
-+
-+ netdev->features |= NETIF_F_LLTX;
-
-- iegbe_reset_hw(&adapter->hw);
-+ adapter->en_mng_pt = iegbe_enable_mng_pass_thru(hw);
-
-- /* make sure the EEPROM is good */
-- if(iegbe_validate_eeprom_checksum(&adapter->hw) < 0) {
-- DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
-- err = -EIO;
-+ /* initialize eeprom parameters */
-+
-+ if (iegbe_init_eeprom_params(hw)) {
-+ E1000_ERR("EEPROM initialization failed\n");
- goto err_eeprom;
- }
-
-- /* copy the MAC address out of the EEPROM */
-+ /* before reading the EEPROM, reset the controller to
-+ * put the device in a known good starting state */
-
-- if(iegbe_read_mac_addr(&adapter->hw)) {
-- DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
-- }
-- memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
-+ iegbe_reset_hw(hw);
-
-- if(!is_valid_ether_addr(netdev->dev_addr)) {
-- DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
-- err = -EIO;
-- goto err_eeprom;
-- }
-+ /* make sure the EEPROM is good */
-+ if (iegbe_validate_eeprom_checksum(hw) < 0) {
-+ DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
-+ iegbe_dump_eeprom(adapter);
-+ /*
-+ * set MAC address to all zeroes to invalidate and temporary
-+ * disable this device for the user. This blocks regular
-+ * traffic while still permitting ethtool ioctls from reaching
-+ * the hardware as well as allowing the user to run the
-+ * interface after manually setting a hw addr using
-+ * `ip set address`
-+ */
-+ memset(hw->mac_addr, 0, netdev->addr_len);
-+ } else {
-+ /* copy the MAC address out of the EEPROM */
-+ if (iegbe_read_mac_addr(hw))
-+ DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
-+ }
-+ /* don't block initalization here due to bad MAC address */
-+ memcpy(netdev->dev_addr, hw->mac_addr, netdev->addr_len);
-+ memcpy(netdev->perm_addr, hw->mac_addr, netdev->addr_len);
-
-- iegbe_read_part_num(&adapter->hw, &(adapter->part_num));
-+ if (!is_valid_ether_addr(netdev->perm_addr))
-+ DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
-
-- iegbe_get_bus_info(&adapter->hw);
-+ iegbe_get_bus_info(hw);
-
- init_timer(&adapter->tx_fifo_stall_timer);
- adapter->tx_fifo_stall_timer.function = &iegbe_82547_tx_fifo_stall;
-- adapter->tx_fifo_stall_timer.data = (unsigned long) adapter;
-+ adapter->tx_fifo_stall_timer.data = (unsigned long)adapter;
-
- init_timer(&adapter->watchdog_timer);
- adapter->watchdog_timer.function = &iegbe_watchdog;
-@@ -906,75 +902,50 @@ iegbe_probe(struct pci_dev *pdev,
-
- init_timer(&adapter->phy_info_timer);
- adapter->phy_info_timer.function = &iegbe_update_phy_info;
-- adapter->phy_info_timer.data = (unsigned long) adapter;
--
-- INIT_WORK(&adapter->tx_timeout_task,
-- (void (*)(void *))iegbe_tx_timeout_task, netdev);
-+ adapter->phy_info_timer.data = (unsigned long)adapter;
-
-- /* we're going to reset, so assume we have no link for now */
--
-- netif_carrier_off(netdev);
-- netif_stop_queue(netdev);
-+ INIT_WORK(&adapter->reset_task, iegbe_reset_task);
-
-- iegbe_check_options(adapter);
-+ iegbe_check_options(adapter);
-
-- /* Initial Wake on LAN setting
-- * If APM wake is enabled in the EEPROM,
-- * enable the ACPI Magic Packet filter
-- */
-+ /* Initial Wake on LAN setting
-+ * If APM wake is enabled in the EEPROM,
-+ * enable the ACPI Magic Packet filter
-+ */
-
-- switch(adapter->hw.mac_type) {
-- case iegbe_82542_rev2_0:
-- case iegbe_82542_rev2_1:
-- case iegbe_82543:
-- break;
-- case iegbe_82544:
-- iegbe_read_eeprom(&adapter->hw,
-- EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
-- eeprom_apme_mask = E1000_EEPROM_82544_APM;
-- break;
-+ switch(adapter->hw.mac_type) {
-+ case iegbe_82542_rev2_0:
-+ case iegbe_82542_rev2_1:
-+ case iegbe_82543:
-+ break;
-+ case iegbe_82544:
-+ iegbe_read_eeprom(&adapter->hw,
-+ EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
-+ eeprom_apme_mask = E1000_EEPROM_82544_APM;
-+ break;
- case iegbe_icp_xxxx:
-- iegbe_read_eeprom(&adapter->hw,
-- EEPROM_INIT_CONTROL3_ICP_xxxx(adapter->bd_number),
-- 1, &eeprom_data);
-- eeprom_apme_mask = EEPROM_CTRL3_APME_ICP_xxxx;
-- break;
-- case iegbe_82546:
-- case iegbe_82546_rev_3:
-- if((E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)
-- && (adapter->hw.media_type == iegbe_media_type_copper)) {
-- iegbe_read_eeprom(&adapter->hw,
-- EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
-- break;
-- }
-- /* Fall Through */
-- default:
-- iegbe_read_eeprom(&adapter->hw,
-- EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
-- break;
-- }
-+ iegbe_read_eeprom(&adapter->hw,
-+ EEPROM_INIT_CONTROL3_ICP_xxxx(adapter->bd_number),
-+ 1, &eeprom_data);
-+ eeprom_apme_mask = EEPROM_CTRL3_APME_ICP_xxxx;
-+ break;
-+ case iegbe_82546:
-+ case iegbe_82546_rev_3:
-+ if((E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)
-+ && (adapter->hw.media_type == iegbe_media_type_copper)) {
-+ iegbe_read_eeprom(&adapter->hw,
-+ EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
-+ break;
-+ }
-+ /* Fall Through */
-+ default:
-+ iegbe_read_eeprom(&adapter->hw,
-+ EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
-+ break;
-+ }
- if(eeprom_data & eeprom_apme_mask) {
-- adapter->wol |= E1000_WUFC_MAG;
-+ adapter->wol |= E1000_WUFC_MAG;
- }
-- /* reset the hardware with the new settings */
-- iegbe_reset(adapter);
--
-- /* Let firmware know the driver has taken over */
-- switch(adapter->hw.mac_type) {
-- case iegbe_82571:
-- case iegbe_82572:
-- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
-- E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
-- ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
-- break;
-- case iegbe_82573:
-- swsm = E1000_READ_REG(&adapter->hw, SWSM);
-- E1000_WRITE_REG(&adapter->hw, SWSM,
-- swsm | E1000_SWSM_DRV_LOAD);
-- break;
-- default:
-- break;
-- }
-
- /* The ICP_xxxx device has multiple, duplicate interrupt
- * registers, so disable all but the first one
-@@ -987,24 +958,40 @@ iegbe_probe(struct pci_dev *pdev,
- E1000_WRITE_REG(&adapter->hw, IMC2, ~0UL);
- }
-
-- strcpy(netdev->name, "eth%d");
-- if((err = register_netdev(netdev))) {
-- goto err_register;
-- }
-+ iegbe_reset(adapter);
-+ netif_carrier_off(netdev);
-+ netif_stop_queue(netdev);
-+ strcpy(netdev->name, "eth%d");
-+ err = register_netdev(netdev);
-+ if (err)
-+ goto err_register;
-+
- DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
-
-- cards_found++;
-- return 0;
-+ cards_found++;
-+ return 0;
-
- err_register:
--err_sw_init:
- err_eeprom:
-- iounmap(adapter->hw.hw_addr);
-+ if (!iegbe_check_phy_reset_block(hw))
-+ iegbe_phy_hw_reset(hw);
-+ if (hw->flash_address)
-+ iounmap(hw->flash_address);
-+ for (i = 0; i < adapter->num_rx_queues; i++)
-+ dev_put(&adapter->polling_netdev[i]);
-+ kfree(adapter->tx_ring);
-+ kfree(adapter->rx_ring);
-+ kfree(adapter->polling_netdev);
-+err_sw_init:
-+ iounmap(hw->hw_addr);
- err_ioremap:
-- free_netdev(netdev);
-+ free_netdev(netdev);
- err_alloc_etherdev:
-- pci_release_regions(pdev);
-- return err;
-+ pci_release_selected_regions(pdev, bars);
-+err_pci_reg:
-+err_dma:
-+ pci_disable_device(pdev);
-+ return err;
- }
-
- /**
-@@ -1020,64 +1007,36 @@ err_alloc_etherdev:
- static void __devexit
- iegbe_remove(struct pci_dev *pdev)
- {
-- struct net_device *netdev = pci_get_drvdata(pdev);
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-- uint32_t ctrl_ext;
-- uint32_t manc, swsm;
--#ifdef CONFIG_E1000_NAPI
-- int i;
--#endif
--
-- if(adapter->hw.mac_type >= iegbe_82540
-- && adapter->hw.mac_type != iegbe_icp_xxxx
-- && adapter->hw.media_type == iegbe_media_type_copper) {
-- manc = E1000_READ_REG(&adapter->hw, MANC);
-- if(manc & E1000_MANC_SMBUS_EN) {
-- manc |= E1000_MANC_ARP_EN;
-- E1000_WRITE_REG(&adapter->hw, MANC, manc);
-- }
-- }
--
-- switch(adapter->hw.mac_type) {
-- case iegbe_82571:
-- case iegbe_82572:
-- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
-- E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
-- ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
-- break;
-- case iegbe_82573:
-- swsm = E1000_READ_REG(&adapter->hw, SWSM);
-- E1000_WRITE_REG(&adapter->hw, SWSM,
-- swsm & ~E1000_SWSM_DRV_LOAD);
-- break;
--
-- default:
-- break;
-- }
-+ struct net_device *netdev = pci_get_drvdata(pdev);
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ uint32_t manc;
-+ int i;
-+
-+ if(adapter->hw.mac_type >= iegbe_82540
-+ && adapter->hw.mac_type != iegbe_icp_xxxx
-+ && adapter->hw.media_type == iegbe_media_type_copper) {
-+ manc = E1000_READ_REG(&adapter->hw, MANC);
-+ if(manc & E1000_MANC_SMBUS_EN) {
-+ manc |= E1000_MANC_ARP_EN;
-+ E1000_WRITE_REG(&adapter->hw, MANC, manc);
-+ }
-+ }
-
-- unregister_netdev(netdev);
--#ifdef CONFIG_E1000_NAPI
-- for (i = 0; i < adapter->num_queues; i++)
-+ unregister_netdev(netdev);
-+ for (i = 0x0; i < adapter->num_rx_queues; i++)
- dev_put(&adapter->polling_netdev[i]);
--#endif
-
- if(!iegbe_check_phy_reset_block(&adapter->hw)) {
-- iegbe_phy_hw_reset(&adapter->hw);
-+ iegbe_phy_hw_reset(&adapter->hw);
- }
-- kfree(adapter->tx_ring);
-- kfree(adapter->rx_ring);
--#ifdef CONFIG_E1000_NAPI
-- kfree(adapter->polling_netdev);
--#endif
-+ kfree(adapter->tx_ring);
-+ kfree(adapter->rx_ring);
-+ kfree(adapter->polling_netdev);
-
-- iounmap(adapter->hw.hw_addr);
-- pci_release_regions(pdev);
-+ iounmap(adapter->hw.hw_addr);
-+ pci_release_regions(pdev);
-
--#ifdef CONFIG_E1000_MQ
-- free_percpu(adapter->cpu_netdev);
-- free_percpu(adapter->cpu_tx_ring);
--#endif
-- free_netdev(netdev);
-+ free_netdev(netdev);
- }
-
- /**
-@@ -1092,118 +1051,78 @@ iegbe_remove(struct pci_dev *pdev)
- static int __devinit
- iegbe_sw_init(struct iegbe_adapter *adapter)
- {
-- struct iegbe_hw *hw = &adapter->hw;
-- struct net_device *netdev = adapter->netdev;
-- struct pci_dev *pdev = adapter->pdev;
--#ifdef CONFIG_E1000_NAPI
-- int i;
--#endif
-+ struct iegbe_hw *hw = &adapter->hw;
-+ struct net_device *netdev = adapter->netdev;
-+ struct pci_dev *pdev = adapter->pdev;
-+ int i;
-
-- /* PCI config space info */
-+ /* PCI config space info */
-
-- hw->vendor_id = pdev->vendor;
-- hw->device_id = pdev->device;
-- hw->subsystem_vendor_id = pdev->subsystem_vendor;
-- hw->subsystem_id = pdev->subsystem_device;
-+ hw->vendor_id = pdev->vendor;
-+ hw->device_id = pdev->device;
-+ hw->subsystem_vendor_id = pdev->subsystem_vendor;
-+ hw->subsystem_id = pdev->subsystem_device;
-
-- pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
-+ pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
-
-- pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
-+ pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
-
-- adapter->rx_buffer_len = E1000_RXBUFFER_2048;
-- adapter->rx_ps_bsize0 = E1000_RXBUFFER_256;
-- hw->max_frame_size = netdev->mtu +
-- ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
-- hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
-+ adapter->rx_buffer_len = E1000_RXBUFFER_2048;
-+ adapter->rx_ps_bsize0 = E1000_RXBUFFER_256;
-+ hw->max_frame_size = netdev->mtu +
-+ ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
-+ hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
-
-- /* identify the MAC */
-+ /* identify the MAC */
-
-- if(iegbe_set_mac_type(hw)) {
-+ if (iegbe_set_mac_type(hw)) {
- DPRINTK(PROBE, ERR, "Unknown MAC Type\n");
- return -EIO;
- }
-
-- /* initialize eeprom parameters */
--
-- if(iegbe_init_eeprom_params(hw)) {
-- E1000_ERR("EEPROM initialization failed\n");
-- return -EIO;
-- }
--
-- switch(hw->mac_type) {
-- default:
-- break;
-- case iegbe_82541:
-- case iegbe_82547:
-- case iegbe_82541_rev_2:
-- case iegbe_82547_rev_2:
-- hw->phy_init_script = 0x1;
-- break;
-- }
--
-- iegbe_set_media_type(hw);
-+ iegbe_set_media_type(hw);
-
-- hw->wait_autoneg_complete = FALSE;
-- hw->tbi_compatibility_en = TRUE;
-- hw->adaptive_ifs = TRUE;
-+ hw->wait_autoneg_complete = FALSE;
-+ hw->tbi_compatibility_en = TRUE;
-+ hw->adaptive_ifs = TRUE;
-
-- /* Copper options */
-+ /* Copper options */
-
-- if(hw->media_type == iegbe_media_type_copper
-+ if(hw->media_type == iegbe_media_type_copper
- || (hw->media_type == iegbe_media_type_oem
- && iegbe_oem_phy_is_copper(&adapter->hw))) {
-- hw->mdix = AUTO_ALL_MODES;
-- hw->disable_polarity_correction = FALSE;
-- hw->master_slave = E1000_MASTER_SLAVE;
-- }
-+ hw->mdix = AUTO_ALL_MODES;
-+ hw->disable_polarity_correction = FALSE;
-+ hw->master_slave = E1000_MASTER_SLAVE;
-+ }
-
--#ifdef CONFIG_E1000_MQ
-- /* Number of supported queues */
-- switch (hw->mac_type) {
-- case iegbe_82571:
-- case iegbe_82572:
-- adapter->num_queues = 0x2;
-- break;
-- default:
-- adapter->num_queues = 0x1;
-- break;
-- }
-- adapter->num_queues = min(adapter->num_queues, num_online_cpus());
--#else
-- adapter->num_queues = 0x1;
--#endif
-+ adapter->num_tx_queues = 0x1;
-+ adapter->num_rx_queues = 0x1;
-
- if (iegbe_alloc_queues(adapter)) {
- DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n");
- return -ENOMEM;
- }
-
--#ifdef CONFIG_E1000_NAPI
-- for (i = 0; i < adapter->num_queues; i++) {
-+ for (i = 0; i < adapter->num_rx_queues; i++) {
- adapter->polling_netdev[i].priv = adapter;
-- adapter->polling_netdev[i].poll = &iegbe_clean;
-- adapter->polling_netdev[i].weight = 0x40;
- dev_hold(&adapter->polling_netdev[i]);
- set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
- }
--#endif
--
--#ifdef CONFIG_E1000_MQ
-- iegbe_setup_queue_mapping(adapter);
--#endif
-+ spin_lock_init(&adapter->tx_queue_lock);
-
- /*
-- * for ICP_XXXX style controllers, it is necessary to keep
-- * track of the last known state of the link to determine if
-- * the link experienced a change in state when iegbe_watchdog
-- * fires
-- */
-- adapter->hw.icp_xxxx_is_link_up = FALSE;
-+ * for ICP_XXXX style controllers, it is necessary to keep
-+ * track of the last known state of the link to determine if
-+ * the link experienced a change in state when iegbe_watchdog
-+ * fires
-+ */
-+ adapter->hw.icp_xxxx_is_link_up = FALSE;
-
-- atomic_set(&adapter->irq_sem, 1);
-- spin_lock_init(&adapter->stats_lock);
-+ spin_lock_init(&adapter->stats_lock);
-
-- return 0;
-+ set_bit(__E1000_DOWN, &adapter->flags);
-+ return 0x0;
- }
-
- /**
-@@ -1218,71 +1137,31 @@ iegbe_sw_init(struct iegbe_adapter *adap
- static int __devinit
- iegbe_alloc_queues(struct iegbe_adapter *adapter)
- {
-- int size;
-
-- size = sizeof(struct iegbe_tx_ring) * adapter->num_queues;
-- adapter->tx_ring = kmalloc(size, GFP_KERNEL);
-- if (!adapter->tx_ring){
-+
-+ adapter->tx_ring = kcalloc(adapter->num_tx_queues,
-+ sizeof(struct iegbe_tx_ring), GFP_KERNEL);
-+ if (!adapter->tx_ring)
- return -ENOMEM;
-- }
-- memset(adapter->tx_ring, 0, size);
-
-- size = sizeof(struct iegbe_rx_ring) * adapter->num_queues;
-- adapter->rx_ring = kmalloc(size, GFP_KERNEL);
-+ adapter->rx_ring = kcalloc(adapter->num_rx_queues,
-+ sizeof(struct iegbe_rx_ring), GFP_KERNEL);
- if (!adapter->rx_ring) {
- kfree(adapter->tx_ring);
- return -ENOMEM;
- }
-- memset(adapter->rx_ring, 0, size);
-
--#ifdef CONFIG_E1000_NAPI
-- size = sizeof(struct net_device) * adapter->num_queues;
-- adapter->polling_netdev = kmalloc(size, GFP_KERNEL);
-+ adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
-+ sizeof(struct net_device),
-+ GFP_KERNEL);
- if (!adapter->polling_netdev) {
- kfree(adapter->tx_ring);
- kfree(adapter->rx_ring);
- return -ENOMEM;
- }
-- memset(adapter->polling_netdev, 0, size);
--#endif
--
-- return E1000_SUCCESS;
--}
-
--#ifdef CONFIG_E1000_MQ
--static void __devinit
--iegbe_setup_queue_mapping(struct iegbe_adapter *adapter)
--{
-- int i, cpu;
--
-- adapter->rx_sched_call_data.func = iegbe_rx_schedule;
-- adapter->rx_sched_call_data.info = adapter->netdev;
-- cpus_clear(adapter->rx_sched_call_data.cpumask);
--
-- adapter->cpu_netdev = alloc_percpu(struct net_device *);
-- adapter->cpu_tx_ring = alloc_percpu(struct iegbe_tx_ring *);
--
-- lock_cpu_hotplug();
-- i = 0;
-- for_each_online_cpu(cpu) {
-- *per_cpu_ptr(adapter->cpu_tx_ring, cpu) =
-- &adapter->tx_ring[i % adapter->num_queues];
-- /* This is incomplete because we'd like to assign separate
-- * physical cpus to these netdev polling structures and
-- * avoid saturating a subset of cpus.
-- */
-- if (i < adapter->num_queues) {
-- *per_cpu_ptr(adapter->cpu_netdev, cpu) =
-- &adapter->polling_netdev[i];
-- adapter->cpu_for_queue[i] = cpu;
-- } else {
-- *per_cpu_ptr(adapter->cpu_netdev, cpu) = NULL;
-- }
-- i++;
-- }
-- unlock_cpu_hotplug();
-+ return E1000_SUCCESS;
- }
--#endif
-
- /**
- * iegbe_open - Called when a network interface is made active
-@@ -1300,40 +1179,62 @@ iegbe_setup_queue_mapping(struct iegbe_a
- static int
- iegbe_open(struct net_device *netdev)
- {
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-- int err;
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ struct iegbe_hw *hw = &adapter->hw;
-+ int err;
-+
-
-+ /* allocate receive descriptors */
-+ if (test_bit(__E1000_TESTING, &adapter->flags))
-+ return -EBUSY;
-
-- /* allocate receive descriptors */
-+ /* allocate transmit descriptors */
-+ err = iegbe_setup_all_tx_resources(adapter);
-+ if (err)
-+ goto err_setup_tx;
-
-- if ((err = iegbe_setup_all_rx_resources(adapter))) {
-+ err = iegbe_setup_all_rx_resources(adapter);
-+ if (err)
- goto err_setup_rx;
-- }
-- /* allocate transmit descriptors */
-- if ((err = iegbe_setup_all_tx_resources(adapter))) {
-- goto err_setup_tx;
-- }
-- if ((err = iegbe_up(adapter))) {
-- goto err_up;
-- }
--#ifdef NETIF_F_HW_VLAN_TX
-- adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
-- if ((adapter->hw.mng_cookie.status &
-- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
-- iegbe_update_mng_vlan(adapter);
-- }
--#endif
-
-- return E1000_SUCCESS;
-+ iegbe_power_up_phy(adapter);
-+ adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
-+ if ((hw->mng_cookie.status &
-+ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
-+ iegbe_update_mng_vlan(adapter);
-+ }
-+
-+ /* before we allocate an interrupt, we must be ready to handle it.
-+ * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
-+ * as soon as we call pci_request_irq, so we have to setup our
-+ * clean_rx handler before we do so. */
-+ iegbe_configure(adapter);
-+ err = iegbe_request_irq(adapter);
-+ if (err)
-+ goto err_req_irq;
-
--err_up:
-- iegbe_free_all_tx_resources(adapter);
--err_setup_tx:
-- iegbe_free_all_rx_resources(adapter);
-+ /* From here on the code is the same as iegbe_up() */
-+ clear_bit(__E1000_DOWN, &adapter->flags);
-+
-+ napi_enable(&adapter->napi);
-+
-+ iegbe_irq_enable(adapter);
-+
-+ netif_start_queue(netdev);
-+
-+ /* fire a link status change interrupt to start the watchdog */
-+
-+ return E1000_SUCCESS;
-+
-+err_req_irq:
-+ iegbe_power_down_phy(adapter);
-+ iegbe_free_all_rx_resources(adapter);
- err_setup_rx:
-- iegbe_reset(adapter);
-+ iegbe_free_all_tx_resources(adapter);
-+err_setup_tx:
-+ iegbe_reset(adapter);
-
-- return err;
-+ return err;
- }
-
- /**
-@@ -1348,22 +1249,25 @@ err_setup_rx:
- * hardware, and all transmit and receive resources are freed.
- **/
-
--static int
--iegbe_close(struct net_device *netdev)
-+static int iegbe_close(struct net_device *netdev)
- {
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
--
-- iegbe_down(adapter);
--
-- iegbe_free_all_tx_resources(adapter);
-- iegbe_free_all_rx_resources(adapter);
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ struct iegbe_hw *hw = &adapter->hw;
-
--#ifdef NETIF_F_HW_VLAN_TX
-- if((adapter->hw.mng_cookie.status &
-- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
-+ WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
-+ iegbe_down(adapter);
-+ iegbe_power_down_phy(adapter);
-+ iegbe_free_irq(adapter);
-+
-+ iegbe_free_all_tx_resources(adapter);
-+ iegbe_free_all_rx_resources(adapter);
-+
-+ if ((hw->mng_cookie.status &
-+ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
-+ !(adapter->vlgrp &&
-+ vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) {
- iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
- }
--#endif
- return 0;
- }
-
-@@ -1375,19 +1279,19 @@ iegbe_close(struct net_device *netdev)
- **/
- static inline boolean_t
- iegbe_check_64k_bound(struct iegbe_adapter *adapter,
-- void *start, unsigned long len)
-+ void *start, unsigned long len)
- {
-- unsigned long begin = (unsigned long) start;
-- unsigned long end = begin + len;
-+ unsigned long begin = (unsigned long) start;
-+ unsigned long end = begin + len;
-
-- /* First rev 82545 and 82546 need to not allow any memory
-- * write location to cross 64k boundary due to errata 23 */
-- if(adapter->hw.mac_type == iegbe_82545 ||
-- adapter->hw.mac_type == iegbe_82546) {
-- return ((begin ^ (end - 1)) >> 0x10) != 0 ? FALSE : TRUE;
-- }
-+ /* First rev 82545 and 82546 need to not allow any memory
-+ * write location to cross 64k boundary due to errata 23 */
-+ if(adapter->hw.mac_type == iegbe_82545 ||
-+ adapter->hw.mac_type == iegbe_82546) {
-+ return ((begin ^ (end - 1)) >> 0x10) != 0x0 ? FALSE : TRUE;
-+ }
-
-- return TRUE;
-+ return TRUE;
- }
-
- /**
-@@ -1398,102 +1302,98 @@ iegbe_check_64k_bound(struct iegbe_adapt
- * Return 0 on success, negative on failure
- **/
-
--int
--iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
-+static int iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
- struct iegbe_tx_ring *txdr)
- {
-- struct pci_dev *pdev = adapter->pdev;
-- int size;
-+ struct pci_dev *pdev = adapter->pdev;
-+ int size;
-
-- size = sizeof(struct iegbe_buffer) * txdr->count;
-- txdr->buffer_info = vmalloc(size);
-- if (!txdr->buffer_info) {
-- DPRINTK(PROBE, ERR,
-- "Unable to allocate memory for the transmit descriptor ring\n");
-- return -ENOMEM;
-- }
-+ size = sizeof(struct iegbe_buffer) * txdr->count;
-+ txdr->buffer_info = vmalloc(size);
-+ if (!txdr->buffer_info) {
-+ DPRINTK(PROBE, ERR,
-+ "Unable to allocate memory for the transmit descriptor ring\n");
-+ return -ENOMEM;
-+ }
- memset(txdr->buffer_info, 0, size);
-- memset(&txdr->previous_buffer_info, 0, sizeof(struct iegbe_buffer));
-
-- /* round up to nearest 4K */
-+ /* round up to nearest 4K */
-
-- txdr->size = txdr->count * sizeof(struct iegbe_tx_desc);
-- E1000_ROUNDUP(txdr->size, 0x1000);
-+ txdr->size = txdr->count * sizeof(struct iegbe_tx_desc);
-+ txdr->size = ALIGN(txdr->size, 4096);
-
-- txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
-- if (!txdr->desc) {
-+ txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
-+ if (!txdr->desc) {
- setup_tx_desc_die:
-- vfree(txdr->buffer_info);
-- DPRINTK(PROBE, ERR,
-- "Unable to allocate memory for the transmit descriptor ring\n");
-- return -ENOMEM;
-- }
--
-- /* Fix for errata 23, can't cross 64kB boundary */
-- if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
-- void *olddesc = txdr->desc;
-- dma_addr_t olddma = txdr->dma;
-- DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes "
-- "at %p\n", txdr->size, txdr->desc);
-- /* Try again, without freeing the previous */
-- txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
-- /* Failed allocation, critical failure */
-- if (!txdr->desc) {
-- pci_free_consistent(pdev, txdr->size, olddesc, olddma);
-- goto setup_tx_desc_die;
-- }
-+ vfree(txdr->buffer_info);
-+ DPRINTK(PROBE, ERR,
-+ "Unable to allocate memory for the transmit descriptor ring\n");
-+ return -ENOMEM;
-+ }
-+
-+ /* Fix for errata 23, can't cross 64kB boundary */
-+ if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
-+ void *olddesc = txdr->desc;
-+ dma_addr_t olddma = txdr->dma;
-+ DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes "
-+ "at %p\n", txdr->size, txdr->desc);
-+ /* Try again, without freeing the previous */
-+ txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
-+ /* Failed allocation, critical failure */
-+ if (!txdr->desc) {
-+ pci_free_consistent(pdev, txdr->size, olddesc, olddma);
-+ goto setup_tx_desc_die;
-+ }
-
-- if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
-- /* give up */
-- pci_free_consistent(pdev, txdr->size, txdr->desc,
-- txdr->dma);
-- pci_free_consistent(pdev, txdr->size, olddesc, olddma);
-- DPRINTK(PROBE, ERR,
-- "Unable to allocate aligned memory "
-- "for the transmit descriptor ring\n");
-- vfree(txdr->buffer_info);
-- return -ENOMEM;
-- } else {
-- /* Free old allocation, new allocation was successful */
-- pci_free_consistent(pdev, txdr->size, olddesc, olddma);
-- }
-- }
-+ if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
-+ /* give up */
-+ pci_free_consistent(pdev, txdr->size, txdr->desc,
-+ txdr->dma);
-+ pci_free_consistent(pdev, txdr->size, olddesc, olddma);
-+ DPRINTK(PROBE, ERR,
-+ "Unable to allocate aligned memory "
-+ "for the transmit descriptor ring\n");
-+ vfree(txdr->buffer_info);
-+ return -ENOMEM;
-+ } else {
-+ /* Free old allocation, new allocation was successful */
-+ pci_free_consistent(pdev, txdr->size, olddesc, olddma);
-+ }
-+ }
- memset(txdr->desc, 0, txdr->size);
-
- txdr->next_to_use = 0;
- txdr->next_to_clean = 0;
-- spin_lock_init(&txdr->tx_lock);
-+ spin_lock_init(&txdr->tx_lock);
-
- return 0;
- }
-
- /**
- * iegbe_setup_all_tx_resources - wrapper to allocate Tx resources
-- * (Descriptors) for all queues
-+ * (Descriptors) for all queues
- * @adapter: board private structure
- *
-- * If this function returns with an error, then it's possible one or
-- * more of the rings is populated (while the rest are not). It is the
-- * callers duty to clean those orphaned rings.
-- *
- * Return 0 on success, negative on failure
- **/
-
--int
--iegbe_setup_all_tx_resources(struct iegbe_adapter *adapter)
-+int iegbe_setup_all_tx_resources(struct iegbe_adapter *adapter)
- {
- int i, err = 0;
-
-- for (i = 0; i < adapter->num_queues; i++) {
-+ for (i = 0; i < adapter->num_tx_queues; i++) {
- err = iegbe_setup_tx_resources(adapter, &adapter->tx_ring[i]);
- if (err) {
- DPRINTK(PROBE, ERR,
- "Allocation for Tx Queue %u failed\n", i);
-+ for (i-- ; i >= 0; i--)
-+ iegbe_free_tx_resources(adapter,
-+ &adapter->tx_ring[i]);
- break;
- }
- }
-
-- return err;
-+ return err;
- }
-
- /**
-@@ -1512,113 +1412,108 @@ iegbe_configure_tx(struct iegbe_adapter
-
- /* Setup the HW Tx Head and Tail descriptor pointers */
-
-- switch (adapter->num_queues) {
-+ switch (adapter->num_tx_queues) {
- case 0x2:
- tdba = adapter->tx_ring[0x1].dma;
- tdlen = adapter->tx_ring[0x1].count *
-- sizeof(struct iegbe_tx_desc);
-- E1000_WRITE_REG(hw, TDBAL1, (tdba & 0x00000000ffffffffULL));
-+ sizeof(struct iegbe_tx_desc);
-+ E1000_WRITE_REG(hw, TDBAL1, (tdba & 0x00000000ffffffffULL));
- E1000_WRITE_REG(hw, TDBAH1, (tdba >> 0x20));
-- E1000_WRITE_REG(hw, TDLEN1, tdlen);
-- E1000_WRITE_REG(hw, TDH1, 0);
-- E1000_WRITE_REG(hw, TDT1, 0);
-+ E1000_WRITE_REG(hw, TDLEN1, tdlen);
-+ E1000_WRITE_REG(hw, TDH1, 0x0);
-+ E1000_WRITE_REG(hw, TDT1, 0x0);
- adapter->tx_ring[0x1].tdh = E1000_TDH1;
- adapter->tx_ring[0x1].tdt = E1000_TDT1;
-- /* Fall Through */
-+ /* Fall Through */
- case 0x1:
-- default:
-- tdba = adapter->tx_ring[0].dma;
-- tdlen = adapter->tx_ring[0].count *
-- sizeof(struct iegbe_tx_desc);
-- E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
-+ default:
-+ tdba = adapter->tx_ring[0x0].dma;
-+ tdlen = adapter->tx_ring[0x0].count *
-+ sizeof(struct iegbe_tx_desc);
-+ E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
- E1000_WRITE_REG(hw, TDBAH, (tdba >> 0x20));
-- E1000_WRITE_REG(hw, TDLEN, tdlen);
-- E1000_WRITE_REG(hw, TDH, 0);
-- E1000_WRITE_REG(hw, TDT, 0);
-- adapter->tx_ring[0].tdh = E1000_TDH;
-- adapter->tx_ring[0].tdt = E1000_TDT;
-- break;
-- }
--
-- /* Set the default values for the Tx Inter Packet Gap timer */
--
-- switch (hw->mac_type) {
-- case iegbe_82542_rev2_0:
-- case iegbe_82542_rev2_1:
-- tipg = DEFAULT_82542_TIPG_IPGT;
-- tipg |= DEFAULT_82542_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
-- tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
-- break;
-- default:
-- switch(hw->media_type) {
-- case iegbe_media_type_fiber:
-- case iegbe_media_type_internal_serdes:
-- tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
-- break;
-- case iegbe_media_type_copper:
-- tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
-- break;
-- case iegbe_media_type_oem:
-- default:
-+ E1000_WRITE_REG(hw, TDLEN, tdlen);
-+ E1000_WRITE_REG(hw, TDH, 0x0);
-+ E1000_WRITE_REG(hw, TDT, 0x0);
-+ adapter->tx_ring[0x0].tdh = E1000_TDH;
-+ adapter->tx_ring[0x0].tdt = E1000_TDT;
-+ break;
-+ }
-+
-+ /* Set the default values for the Tx Inter Packet Gap timer */
-+
-+ switch (hw->mac_type) {
-+ case iegbe_82542_rev2_0:
-+ case iegbe_82542_rev2_1:
-+ tipg = DEFAULT_82542_TIPG_IPGT;
-+ tipg |= DEFAULT_82542_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
-+ tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
-+ break;
-+ default:
-+ switch(hw->media_type) {
-+ case iegbe_media_type_fiber:
-+ case iegbe_media_type_internal_serdes:
-+ tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
-+ break;
-+ case iegbe_media_type_copper:
-+ tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
-+ break;
-+ case iegbe_media_type_oem:
-+ default:
- tipg = (0xFFFFFFFFUL >> (sizeof(tipg)*0x8 -
- E1000_TIPG_IPGR1_SHIFT))
-- & iegbe_oem_get_tipg(&adapter->hw);
-- break;
-- }
-- tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
-- tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
-- }
-- E1000_WRITE_REG(hw, TIPG, tipg);
-+ & iegbe_oem_get_tipg(&adapter->hw);
-+ break;
-+ }
-+ tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
-+ tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
-+ }
-+ E1000_WRITE_REG(hw, TIPG, tipg);
-
-- /* Set the Tx Interrupt Delay register */
-+ /* Set the Tx Interrupt Delay register */
-
-- E1000_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
-+ E1000_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
- if (hw->mac_type >= iegbe_82540) {
-- E1000_WRITE_REG(hw, TADV, adapter->tx_abs_int_delay);
-+ E1000_WRITE_REG(hw, TADV, adapter->tx_abs_int_delay);
- }
-- /* Program the Transmit Control Register */
-+ /* Program the Transmit Control Register */
-
-- tctl = E1000_READ_REG(hw, TCTL);
-+ tctl = E1000_READ_REG(hw, TCTL);
-
-- tctl &= ~E1000_TCTL_CT;
-- tctl |= E1000_TCTL_EN | E1000_TCTL_PSP | E1000_TCTL_RTLC |
-- (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
-+ tctl &= ~E1000_TCTL_CT;
-+ tctl |= E1000_TCTL_EN | E1000_TCTL_PSP | E1000_TCTL_RTLC |
-+ (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
-
-- E1000_WRITE_REG(hw, TCTL, tctl);
-+ E1000_WRITE_REG(hw, TCTL, tctl);
-
-- if (hw->mac_type == iegbe_82571 || hw->mac_type == iegbe_82572) {
-- tarc = E1000_READ_REG(hw, TARC0);
-+ if (hw->mac_type == iegbe_82571 || hw->mac_type == iegbe_82572) {
-+ tarc = E1000_READ_REG(hw, TARC0);
- tarc |= ((0x1 << 0x19) | (0x1 << 0x15));
-- E1000_WRITE_REG(hw, TARC0, tarc);
-- tarc = E1000_READ_REG(hw, TARC1);
-+ E1000_WRITE_REG(hw, TARC0, tarc);
-+ tarc = E1000_READ_REG(hw, TARC1);
- tarc |= (0x1 << 0x19);
- if (tctl & E1000_TCTL_MULR) {
- tarc &= ~(0x1 << 0x1c);
- } else {
- tarc |= (0x1 << 0x1c);
- }
-- E1000_WRITE_REG(hw, TARC1, tarc);
-- }
-+ E1000_WRITE_REG(hw, TARC1, tarc);
-+ }
-
-- iegbe_config_collision_dist(hw);
-+ iegbe_config_collision_dist(hw);
-
-- /* Setup Transmit Descriptor Settings for eop descriptor */
-- adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP |
-- E1000_TXD_CMD_IFCS;
-+ /* Setup Transmit Descriptor Settings for eop descriptor */
-+ adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP |
-+ E1000_TXD_CMD_IFCS;
-
- if (hw->mac_type < iegbe_82543) {
-- adapter->txd_cmd |= E1000_TXD_CMD_RPS;
-+ adapter->txd_cmd |= E1000_TXD_CMD_RPS;
- } else {
--#ifdef IEGBE_GBE_WORKAROUND
-- /* Disable the RS bit in the Tx descriptor */
-- adapter->txd_cmd &= ~E1000_TXD_CMD_RS;
--#else
-- adapter->txd_cmd |= E1000_TXD_CMD_RS;
--#endif
-+ adapter->txd_cmd |= E1000_TXD_CMD_RS;
- }
-- /* Cache if we're 82544 running in PCI-X because we'll
-- * need this to apply a workaround later in the send path. */
-- if (hw->mac_type == iegbe_82544 &&
-+ /* Cache if we're 82544 running in PCI-X because we'll
-+ * need this to apply a workaround later in the send path. */
-+ if (hw->mac_type == iegbe_82544 &&
- hw->bus_type == iegbe_bus_type_pcix) {
- adapter->pcix_82544 = 0x1;
- }
-@@ -1632,96 +1527,95 @@ iegbe_configure_tx(struct iegbe_adapter
- * Returns 0 on success, negative on failure
- **/
-
--int
--iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
-+static int iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rxdr)
- {
-- struct pci_dev *pdev = adapter->pdev;
-- int size, desc_len;
--
-- size = sizeof(struct iegbe_buffer) * rxdr->count;
-- rxdr->buffer_info = vmalloc(size);
-- if (!rxdr->buffer_info) {
-- DPRINTK(PROBE, ERR,
-- "Unable to allocate memory for the receive descriptor ring\n");
-- return -ENOMEM;
-- }
-- memset(rxdr->buffer_info, 0, size);
--
-- size = sizeof(struct iegbe_ps_page) * rxdr->count;
-- rxdr->ps_page = kmalloc(size, GFP_KERNEL);
-- if (!rxdr->ps_page) {
-- vfree(rxdr->buffer_info);
-- DPRINTK(PROBE, ERR,
-- "Unable to allocate memory for the receive descriptor ring\n");
-- return -ENOMEM;
-- }
-- memset(rxdr->ps_page, 0, size);
--
-- size = sizeof(struct iegbe_ps_page_dma) * rxdr->count;
-- rxdr->ps_page_dma = kmalloc(size, GFP_KERNEL);
-- if (!rxdr->ps_page_dma) {
-- vfree(rxdr->buffer_info);
-- kfree(rxdr->ps_page);
-- DPRINTK(PROBE, ERR,
-- "Unable to allocate memory for the receive descriptor ring\n");
-- return -ENOMEM;
-- }
-- memset(rxdr->ps_page_dma, 0, size);
-+ struct iegbe_hw *hw = &adapter->hw;
-+ struct pci_dev *pdev = adapter->pdev;
-+ int size, desc_len;
-
-- if (adapter->hw.mac_type <= iegbe_82547_rev_2) {
-- desc_len = sizeof(struct iegbe_rx_desc);
-- } else {
-- desc_len = sizeof(union iegbe_rx_desc_packet_split);
-+ size = sizeof(struct iegbe_buffer) * rxdr->count;
-+ rxdr->buffer_info = vmalloc(size);
-+ if (!rxdr->buffer_info) {
-+ DPRINTK(PROBE, ERR,
-+ "Unable to allocate memory for the receive descriptor ring\n");
-+ return -ENOMEM;
- }
-- /* Round up to nearest 4K */
--
-- rxdr->size = rxdr->count * desc_len;
-- E1000_ROUNDUP(rxdr->size, 0x1000);
--
-- rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
-+ memset(rxdr->buffer_info, 0, size);
-
-- if (!rxdr->desc) {
-- DPRINTK(PROBE, ERR,
-- "Unable to allocate memory for the receive descriptor ring\n");
-+ rxdr->ps_page = kcalloc(rxdr->count, sizeof(struct iegbe_ps_page),
-+ GFP_KERNEL);
-+ if (!rxdr->ps_page) {
-+ vfree(rxdr->buffer_info);
-+ DPRINTK(PROBE, ERR,
-+ "Unable to allocate memory for the receive descriptor ring\n");
-+ return -ENOMEM;
-+ }
-+
-+ rxdr->ps_page_dma = kcalloc(rxdr->count,
-+ sizeof(struct iegbe_ps_page_dma),
-+ GFP_KERNEL);
-+ if (!rxdr->ps_page_dma) {
-+ vfree(rxdr->buffer_info);
-+ kfree(rxdr->ps_page);
-+ DPRINTK(PROBE, ERR,
-+ "Unable to allocate memory for the receive descriptor ring\n");
-+ return -ENOMEM;
-+ }
-+
-+ if (hw->mac_type <= iegbe_82547_rev_2)
-+ desc_len = sizeof(struct iegbe_rx_desc);
-+ else
-+ desc_len = sizeof(union iegbe_rx_desc_packet_split);
-+
-+ /* Round up to nearest 4K */
-+
-+ rxdr->size = rxdr->count * desc_len;
-+ rxdr->size = ALIGN(rxdr->size, 4096);
-+
-+ rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
-+
-+ if (!rxdr->desc) {
-+ DPRINTK(PROBE, ERR,
-+ "Unable to allocate memory for the receive descriptor ring\n");
- setup_rx_desc_die:
-- vfree(rxdr->buffer_info);
-- kfree(rxdr->ps_page);
-- kfree(rxdr->ps_page_dma);
-- return -ENOMEM;
-- }
--
-- /* Fix for errata 23, can't cross 64kB boundary */
-- if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
-- void *olddesc = rxdr->desc;
-- dma_addr_t olddma = rxdr->dma;
-- DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes "
-- "at %p\n", rxdr->size, rxdr->desc);
-- /* Try again, without freeing the previous */
-- rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
-- /* Failed allocation, critical failure */
-- if (!rxdr->desc) {
-- pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
-- DPRINTK(PROBE, ERR,
-- "Unable to allocate memory "
-- "for the receive descriptor ring\n");
-- goto setup_rx_desc_die;
-- }
-+ vfree(rxdr->buffer_info);
-+ kfree(rxdr->ps_page);
-+ kfree(rxdr->ps_page_dma);
-+ return -ENOMEM;
-+ }
-+
-+ /* Fix for errata 23, can't cross 64kB boundary */
-+ if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
-+ void *olddesc = rxdr->desc;
-+ dma_addr_t olddma = rxdr->dma;
-+ DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes "
-+ "at %p\n", rxdr->size, rxdr->desc);
-+ /* Try again, without freeing the previous */
-+ rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
-+ /* Failed allocation, critical failure */
-+ if (!rxdr->desc) {
-+ pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
-+ DPRINTK(PROBE, ERR,
-+ "Unable to allocate memory "
-+ "for the receive descriptor ring\n");
-+ goto setup_rx_desc_die;
-+ }
-
-- if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
-- /* give up */
-- pci_free_consistent(pdev, rxdr->size, rxdr->desc,
-- rxdr->dma);
-- pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
-- DPRINTK(PROBE, ERR,
-- "Unable to allocate aligned memory "
-- "for the receive descriptor ring\n");
-- goto setup_rx_desc_die;
-- } else {
-- /* Free old allocation, new allocation was successful */
-- pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
-- }
-- }
-+ if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
-+ /* give up */
-+ pci_free_consistent(pdev, rxdr->size, rxdr->desc,
-+ rxdr->dma);
-+ pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
-+ DPRINTK(PROBE, ERR,
-+ "Unable to allocate aligned memory "
-+ "for the receive descriptor ring\n");
-+ goto setup_rx_desc_die;
-+ } else {
-+ /* Free old allocation, new allocation was successful */
-+ pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
-+ }
-+ }
- memset(rxdr->desc, 0, rxdr->size);
-
- rxdr->next_to_clean = 0;
-@@ -1732,7 +1626,7 @@ setup_rx_desc_die:
-
- /**
- * iegbe_setup_all_rx_resources - wrapper to allocate Rx resources
-- * (Descriptors) for all queues
-+ * (Descriptors) for all queues
- * @adapter: board private structure
- *
- * If this function returns with an error, then it's possible one or
-@@ -1742,21 +1636,23 @@ setup_rx_desc_die:
- * Return 0 on success, negative on failure
- **/
-
--int
--iegbe_setup_all_rx_resources(struct iegbe_adapter *adapter)
-+int iegbe_setup_all_rx_resources(struct iegbe_adapter *adapter)
- {
- int i, err = 0;
-
-- for (i = 0; i < adapter->num_queues; i++) {
-+ for (i = 0; i < adapter->num_rx_queues; i++) {
- err = iegbe_setup_rx_resources(adapter, &adapter->rx_ring[i]);
- if (err) {
- DPRINTK(PROBE, ERR,
- "Allocation for Rx Queue %u failed\n", i);
-+ for (i-- ; i >= 0; i--)
-+ iegbe_free_rx_resources(adapter,
-+ &adapter->rx_ring[i]);
- break;
- }
- }
-
-- return err;
-+ return err;
- }
-
- /**
-@@ -1765,105 +1661,104 @@ iegbe_setup_all_rx_resources(struct iegb
- **/
- #define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
- (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
--static void
--iegbe_setup_rctl(struct iegbe_adapter *adapter)
-+static void iegbe_setup_rctl(struct iegbe_adapter *adapter)
- {
-- uint32_t rctl, rfctl;
-- uint32_t psrctl = 0;
--#ifdef CONFIG_E1000_PACKET_SPLIT
-- uint32_t pages = 0;
--#endif
--
-- rctl = E1000_READ_REG(&adapter->hw, RCTL);
--
-- rctl &= ~(0x3 << E1000_RCTL_MO_SHIFT);
--
-- rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
-- E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
-- (adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT);
--
-- if(adapter->hw.tbi_compatibility_on == 0x1) {
-- rctl |= E1000_RCTL_SBP;
-- } else {
-- rctl &= ~E1000_RCTL_SBP;
-- }
-- if(adapter->netdev->mtu <= ETH_DATA_LEN) {
-- rctl &= ~E1000_RCTL_LPE;
-- } else {
-- rctl |= E1000_RCTL_LPE;
-- }
-- /* Setup buffer sizes */
-- if(adapter->hw.mac_type >= iegbe_82571) {
-- /* We can now specify buffers in 1K increments.
-- * BSIZE and BSEX are ignored in this case. */
-- rctl |= adapter->rx_buffer_len << 0x11;
-- } else {
-- rctl &= ~E1000_RCTL_SZ_4096;
-- rctl |= E1000_RCTL_BSEX;
-- switch (adapter->rx_buffer_len) {
-- case E1000_RXBUFFER_2048:
-- default:
-- rctl |= E1000_RCTL_SZ_2048;
-+ struct iegbe_hw *hw = &adapter->hw;
-+ u32 rctl, rfctl;
-+ u32 psrctl = 0;
-+#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
-+ u32 pages = 0;
-+#endif
-+
-+ rctl = E1000_READ_REG(&adapter->hw, RCTL);
-+
-+ rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
-+
-+ rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
-+ E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
-+ (hw->mc_filter_type << E1000_RCTL_MO_SHIFT);
-+
-+ if (hw->tbi_compatibility_on == 1)
-+ rctl |= E1000_RCTL_SBP;
-+ else
-+ rctl &= ~E1000_RCTL_SBP;
-+
-+ if (adapter->netdev->mtu <= ETH_DATA_LEN)
-+ rctl &= ~E1000_RCTL_LPE;
-+ else
-+ rctl |= E1000_RCTL_LPE;
-+
-+ /* Setup buffer sizes */
-+ /* We can now specify buffers in 1K increments.
-+ * BSIZE and BSEX are ignored in this case. */
-+ rctl &= ~E1000_RCTL_SZ_4096;
-+ rctl |= E1000_RCTL_BSEX;
-+ switch (adapter->rx_buffer_len) {
-+ case E1000_RXBUFFER_256:
-+ rctl |= E1000_RCTL_SZ_256;
- rctl &= ~E1000_RCTL_BSEX;
- break;
-- case E1000_RXBUFFER_4096:
-- rctl |= E1000_RCTL_SZ_4096;
-- break;
-- case E1000_RXBUFFER_8192:
-- rctl |= E1000_RCTL_SZ_8192;
-- break;
-- case E1000_RXBUFFER_16384:
-- rctl |= E1000_RCTL_SZ_16384;
-- break;
-- }
-- }
-+ case E1000_RXBUFFER_2048:
-+ default:
-+ rctl |= E1000_RCTL_SZ_2048;
-+ rctl &= ~E1000_RCTL_BSEX;
-+ break;
-+ case E1000_RXBUFFER_4096:
-+ rctl |= E1000_RCTL_SZ_4096;
-+ break;
-+ case E1000_RXBUFFER_8192:
-+ rctl |= E1000_RCTL_SZ_8192;
-+ break;
-+ case E1000_RXBUFFER_16384:
-+ rctl |= E1000_RCTL_SZ_16384;
-+ break;
-+ }
-
--#ifdef CONFIG_E1000_PACKET_SPLIT
-- /* 82571 and greater support packet-split where the protocol
-- * header is placed in skb->data and the packet data is
-- * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
-- * In the case of a non-split, skb->data is linearly filled,
-- * followed by the page buffers. Therefore, skb->data is
-- * sized to hold the largest protocol header.
-- */
-- pages = PAGE_USE_COUNT(adapter->netdev->mtu);
-- if ((adapter->hw.mac_type > iegbe_82547_rev_2) && (pages <= 0x3) &&
-- PAGE_SIZE <= 0x4000) {
-- adapter->rx_ps_pages = pages;
-- } else {
-+#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
-+ /* 82571 and greater support packet-split where the protocol
-+ * header is placed in skb->data and the packet data is
-+ * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
-+ * In the case of a non-split, skb->data is linearly filled,
-+ * followed by the page buffers. Therefore, skb->data is
-+ * sized to hold the largest protocol header.
-+ */
-+ pages = PAGE_USE_COUNT(adapter->netdev->mtu);
-+ if ((hw->mac_type >= iegbe_82571) && (pages <= 3) &&
-+ PAGE_SIZE <= 16384 && (rctl & E1000_RCTL_LPE))
-+ adapter->rx_ps_pages = pages;
-+ else
- adapter->rx_ps_pages = 0;
-- }
- #endif
-- if (adapter->rx_ps_pages) {
-- /* Configure extra packet-split registers */
-- rfctl = E1000_READ_REG(&adapter->hw, RFCTL);
-- rfctl |= E1000_RFCTL_EXTEN;
-- /* disable IPv6 packet split support */
-- rfctl |= E1000_RFCTL_IPV6_DIS;
-- E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl);
--
-- rctl |= E1000_RCTL_DTYP_PS | E1000_RCTL_SECRC;
--
-- psrctl |= adapter->rx_ps_bsize0 >>
-- E1000_PSRCTL_BSIZE0_SHIFT;
--
-- switch (adapter->rx_ps_pages) {
-- case 0x3:
-- psrctl |= PAGE_SIZE <<
-- E1000_PSRCTL_BSIZE3_SHIFT;
-- case 0x2:
-- psrctl |= PAGE_SIZE <<
-- E1000_PSRCTL_BSIZE2_SHIFT;
-- case 0x1:
-- psrctl |= PAGE_SIZE >>
-- E1000_PSRCTL_BSIZE1_SHIFT;
-- break;
-- }
-+ if (adapter->rx_ps_pages) {
-+ /* Configure extra packet-split registers */
-+ rfctl = E1000_READ_REG(&adapter->hw, RFCTL);
-+ rfctl |= E1000_RFCTL_EXTEN;
-+ /* disable IPv6 packet split support */
-+ rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
-+ E1000_RFCTL_NEW_IPV6_EXT_DIS);
-+
-+ rctl |= E1000_RCTL_DTYP_PS;
-+
-+ psrctl |= adapter->rx_ps_bsize0 >>
-+ E1000_PSRCTL_BSIZE0_SHIFT;
-+
-+ switch (adapter->rx_ps_pages) {
-+ case 3:
-+ psrctl |= PAGE_SIZE <<
-+ E1000_PSRCTL_BSIZE3_SHIFT;
-+ case 2:
-+ psrctl |= PAGE_SIZE <<
-+ E1000_PSRCTL_BSIZE2_SHIFT;
-+ case 1:
-+ psrctl |= PAGE_SIZE >>
-+ E1000_PSRCTL_BSIZE1_SHIFT;
-+ break;
-+ }
-
-- E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl);
-- }
-+ E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl);
-+ }
-
-- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
-+ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
- }
-
- /**
-@@ -1873,145 +1768,87 @@ iegbe_setup_rctl(struct iegbe_adapter *a
- * Configure the Rx unit of the MAC after a reset.
- **/
-
--static void
--iegbe_configure_rx(struct iegbe_adapter *adapter)
-+static void iegbe_configure_rx(struct iegbe_adapter *adapter)
- {
-- uint64_t rdba;
-- struct iegbe_hw *hw = &adapter->hw;
-- uint32_t rdlen, rctl, rxcsum, ctrl_ext;
--#ifdef CONFIG_E1000_MQ
-- uint32_t reta, mrqc;
-- int i;
--#endif
-+ u64 rdba;
-+ struct iegbe_hw *hw = &adapter->hw;
-+ u32 rdlen, rctl, rxcsum, ctrl_ext;
-
-- if (adapter->rx_ps_pages) {
-+ if (adapter->rx_ps_pages) {
- rdlen = adapter->rx_ring[0].count *
-- sizeof(union iegbe_rx_desc_packet_split);
-- adapter->clean_rx = iegbe_clean_rx_irq_ps;
-- adapter->alloc_rx_buf = iegbe_alloc_rx_buffers_ps;
-- } else {
-+ sizeof(union iegbe_rx_desc_packet_split);
-+ adapter->clean_rx = iegbe_clean_rx_irq_ps;
-+ adapter->alloc_rx_buf = iegbe_alloc_rx_buffers_ps;
-+ } else {
- rdlen = adapter->rx_ring[0].count *
-- sizeof(struct iegbe_rx_desc);
-- adapter->clean_rx = iegbe_clean_rx_irq;
-- adapter->alloc_rx_buf = iegbe_alloc_rx_buffers;
-- }
-+ sizeof(struct iegbe_rx_desc);
-+ adapter->clean_rx = iegbe_clean_rx_irq;
-+ adapter->alloc_rx_buf = iegbe_alloc_rx_buffers;
-+ }
-
-- /* disable receives while setting up the descriptors */
-- rctl = E1000_READ_REG(hw, RCTL);
-- E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
-+ /* disable receives while setting up the descriptors */
-+ rctl = E1000_READ_REG(hw, RCTL);
-+ E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
-
-- /* set the Receive Delay Timer Register */
-- E1000_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
-+ /* set the Receive Delay Timer Register */
-+ E1000_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
-
-- if (hw->mac_type >= iegbe_82540) {
-- E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay);
-- if(adapter->itr > 0x1) {
-- E1000_WRITE_REG(hw, ITR,
-- 0x3b9aca00 / (adapter->itr * 0x100));
-+ if (hw->mac_type >= iegbe_82540) {
-+ E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay);
-+ if (adapter->itr_setting != 0)
-+ E1000_WRITE_REG(&adapter->hw, ITR, 1000000000 / (adapter->itr * 256));
- }
-- }
-
-- if (hw->mac_type >= iegbe_82571) {
-- /* Reset delay timers after every interrupt */
-- ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
-- ctrl_ext |= E1000_CTRL_EXT_CANC;
-- E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
-- E1000_WRITE_FLUSH(hw);
-- }
-+ if (hw->mac_type >= iegbe_82571) {
-+ /* Reset delay timers after every interrupt */
-+ ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
-+ ctrl_ext |= E1000_CTRL_EXT_CANC;
-+ E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
-+ E1000_WRITE_FLUSH(hw);
-+ }
-
- /* Setup the HW Rx Head and Tail Descriptor Pointers and
- * the Base and Length of the Rx Descriptor Ring */
-- switch (adapter->num_queues) {
--#ifdef CONFIG_E1000_MQ
-- case 0x2:
-- rdba = adapter->rx_ring[0x1].dma;
-- E1000_WRITE_REG(hw, RDBAL1, (rdba & 0x00000000ffffffffULL));
-- E1000_WRITE_REG(hw, RDBAH1, (rdba >> 0x20));
-- E1000_WRITE_REG(hw, RDLEN1, rdlen);
-- E1000_WRITE_REG(hw, RDH1, 0);
-- E1000_WRITE_REG(hw, RDT1, 0);
-- adapter->rx_ring[1].rdh = E1000_RDH1;
-- adapter->rx_ring[1].rdt = E1000_RDT1;
-- /* Fall Through */
--#endif
-- case 0x1:
-- default:
-+ switch (adapter->num_rx_queues) {
-+ case 1:
-+ default:
- rdba = adapter->rx_ring[0].dma;
-- E1000_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
-+ E1000_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
- E1000_WRITE_REG(hw, RDBAH, (rdba >> 0x20));
-- E1000_WRITE_REG(hw, RDLEN, rdlen);
-- E1000_WRITE_REG(hw, RDH, 0);
-- E1000_WRITE_REG(hw, RDT, 0);
-- adapter->rx_ring[0].rdh = E1000_RDH;
-- adapter->rx_ring[0].rdt = E1000_RDT;
-- break;
-- }
-+ E1000_WRITE_REG(hw, RDLEN, rdlen);
-+ adapter->rx_ring[0].rdh = ((hw->mac_type >= iegbe_82543) ? E1000_RDH : E1000_82542_RDH);
-+ adapter->rx_ring[0].rdt = ((hw->mac_type >= iegbe_82543) ? E1000_RDT : E1000_82542_RDT);
-+ break;
-+ }
-
--#ifdef CONFIG_E1000_MQ
-- if (adapter->num_queues > 0x1) {
-- uint32_t random[0xa];
--
-- get_random_bytes(&random[0], FORTY);
--
-- if (hw->mac_type <= iegbe_82572) {
-- E1000_WRITE_REG(hw, RSSIR, 0);
-- E1000_WRITE_REG(hw, RSSIM, 0);
-- }
-
-- switch (adapter->num_queues) {
-- case 0x2:
-- default:
-- reta = 0x00800080;
-- mrqc = E1000_MRQC_ENABLE_RSS_2Q;
-- break;
-- }
--
-- /* Fill out redirection table */
-- for (i = 0; i < 0x20; i++)
-- E1000_WRITE_REG_ARRAY(hw, RETA, i, reta);
-- /* Fill out hash function seeds */
-- for (i = 0; i < 0xa; i++)
-- E1000_WRITE_REG_ARRAY(hw, RSSRK, i, random[i]);
--
-- mrqc |= (E1000_MRQC_RSS_FIELD_IPV4 |
-- E1000_MRQC_RSS_FIELD_IPV4_TCP);
-- E1000_WRITE_REG(hw, MRQC, mrqc);
-- }
--
-- /* Multiqueue and packet checksumming are mutually exclusive. */
-- if (hw->mac_type >= iegbe_82571) {
-- rxcsum = E1000_READ_REG(hw, RXCSUM);
-- rxcsum |= E1000_RXCSUM_PCSD;
-- E1000_WRITE_REG(hw, RXCSUM, rxcsum);
-- }
--
--#else
-+ /* Enable 82543 Receive Checksum Offload for TCP and UDP */
-+ if (hw->mac_type >= iegbe_82543) {
-+ rxcsum = E1000_READ_REG(hw, RXCSUM);
-+ if(adapter->rx_csum == TRUE) {
-+ rxcsum |= E1000_RXCSUM_TUOFL;
-+
-+ /* Enable 82571 IPv4 payload checksum for UDP fragments
-+ * Must be used in conjunction with packet-split. */
-+ if ((hw->mac_type >= iegbe_82571) &&
-+ (adapter->rx_ps_pages)) {
-+ rxcsum |= E1000_RXCSUM_IPPCSE;
-+ }
-+ } else {
-+ rxcsum &= ~E1000_RXCSUM_TUOFL;
-+ /* don't need to clear IPPCSE as it defaults to 0 */
-+ }
-+ E1000_WRITE_REG(hw, RXCSUM, rxcsum);
-+ }
-
-- /* Enable 82543 Receive Checksum Offload for TCP and UDP */
-- if (hw->mac_type >= iegbe_82543) {
-- rxcsum = E1000_READ_REG(hw, RXCSUM);
-- if(adapter->rx_csum == TRUE) {
-- rxcsum |= E1000_RXCSUM_TUOFL;
--
-- /* Enable 82571 IPv4 payload checksum for UDP fragments
-- * Must be used in conjunction with packet-split. */
-- if ((hw->mac_type >= iegbe_82571) &&
-- (adapter->rx_ps_pages)) {
-- rxcsum |= E1000_RXCSUM_IPPCSE;
-- }
-- } else {
-- rxcsum &= ~E1000_RXCSUM_TUOFL;
-- /* don't need to clear IPPCSE as it defaults to 0 */
-- }
-- E1000_WRITE_REG(hw, RXCSUM, rxcsum);
-- }
--#endif /* CONFIG_E1000_MQ */
-+ /* enable early receives on 82573, only takes effect if using > 2048
-+ * byte total frame size. for example only for jumbo frames */
-+#define E1000_ERT_2048 0x100
-+ if (hw->mac_type == iegbe_82573)
-+ E1000_WRITE_REG(&adapter->hw, ERT, E1000_ERT_2048);
-
-- if (hw->mac_type == iegbe_82573) {
-- E1000_WRITE_REG(hw, ERT, 0x0100);
-- }
- /* Enable Receives */
-- E1000_WRITE_REG(hw, RCTL, rctl);
-+ E1000_WRITE_REG(hw, RCTL, rctl);
- }
-
- /**
-@@ -2022,20 +1859,19 @@ iegbe_configure_rx(struct iegbe_adapter
- * Free all transmit software resources
- **/
-
--void
--iegbe_free_tx_resources(struct iegbe_adapter *adapter,
-+static void iegbe_free_tx_resources(struct iegbe_adapter *adapter,
- struct iegbe_tx_ring *tx_ring)
- {
-- struct pci_dev *pdev = adapter->pdev;
-+ struct pci_dev *pdev = adapter->pdev;
-
-- iegbe_clean_tx_ring(adapter, tx_ring);
-+ iegbe_clean_tx_ring(adapter, tx_ring);
-
-- vfree(tx_ring->buffer_info);
-- tx_ring->buffer_info = NULL;
-+ vfree(tx_ring->buffer_info);
-+ tx_ring->buffer_info = NULL;
-
-- pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma);
-+ pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma);
-
-- tx_ring->desc = NULL;
-+ tx_ring->desc = NULL;
- }
-
- /**
-@@ -2048,85 +1884,29 @@ iegbe_free_tx_resources(struct iegbe_ada
- void
- iegbe_free_all_tx_resources(struct iegbe_adapter *adapter)
- {
-- int i;
-+ int i;
-
-- for (i = 0; i < adapter->num_queues; i++)
-+ for (i = 0x0; i < adapter->num_tx_queues; i++)
- iegbe_free_tx_resources(adapter, &adapter->tx_ring[i]);
- }
-
- static inline void
- iegbe_unmap_and_free_tx_resource(struct iegbe_adapter *adapter,
-- struct iegbe_buffer *buffer_info)
--{
-- if(buffer_info->dma) {
-- pci_unmap_page(adapter->pdev,
-- buffer_info->dma,
-- buffer_info->length,
-- PCI_DMA_TODEVICE);
-- buffer_info->dma = 0;
-- }
-- if(buffer_info->skb) {
-- dev_kfree_skb_any(buffer_info->skb);
-- buffer_info->skb = NULL;
-- }
--}
--
--#ifdef IEGBE_GBE_WORKAROUND
--/**
-- * iegbe_clean_tx_ring_partial - Free Tx Buffers without using the DD
-- * bit in the descriptor
-- * @adapter: board private structure
-- * @tx_ring: ring to be cleaned
-- **/
--static void iegbe_clean_tx_ring_partial(struct iegbe_adapter *adapter,
-- struct iegbe_tx_ring *tx_ring)
-+ struct iegbe_buffer *buffer_info)
- {
-- struct iegbe_buffer *buffer_info;
-- struct iegbe_tx_desc *tx_desc;
-- struct net_device *netdev = adapter->netdev;
-- unsigned int i;
-- unsigned tail;
-- unsigned head;
-- int cleaned = FALSE;
--
-- tail = readl(adapter->hw.hw_addr + tx_ring->tdt);
-- head = readl(adapter->hw.hw_addr + tx_ring->tdh);
--
-- if (head != tail) {
-- adapter->stats.tx_hnet++;
-- }
-- if (head != tx_ring->next_to_use) {
-- adapter->stats.tx_hnentu++;
-- }
-- /* Free all the Tx ring sk_buffs from next_to_clean up until
-- * the current head pointer
-- */
-- i = tx_ring->next_to_clean;
-- while(i != head) {
-- cleaned = TRUE;
-- tx_desc = E1000_TX_DESC(*tx_ring, i);
--
-- buffer_info = &tx_ring->buffer_info[i];
-- iegbe_unmap_and_free_tx_resource(adapter, buffer_info);
--
-- tx_desc->upper.data = 0;
--
-- if (unlikely(++i == tx_ring->count)) { i = 0; }
--
-- }
-- tx_ring->next_to_clean = head;
--
-- spin_lock(&tx_ring->tx_lock);
--
-- /* Wake up the queue if it's currently stopped */
-- if (unlikely(cleaned && netif_queue_stopped(netdev) &&
-- netif_carrier_ok(netdev))) {
-- netif_wake_queue(netdev);
-+ if(buffer_info->dma) {
-+ pci_unmap_page(adapter->pdev,
-+ buffer_info->dma,
-+ buffer_info->length,
-+ PCI_DMA_TODEVICE);
-+ buffer_info->dma = 0x0;
-+ }
-+ if(buffer_info->skb) {
-+ dev_kfree_skb_any(buffer_info->skb);
-+ buffer_info->skb = NULL;
- }
--
-- spin_unlock(&tx_ring->tx_lock);
- }
--#endif
-+
-
- /**
- * iegbe_clean_tx_ring - Free Tx Buffers
-@@ -2134,38 +1914,34 @@ static void iegbe_clean_tx_ring_partial(
- * @tx_ring: ring to be cleaned
- **/
-
--static void
--iegbe_clean_tx_ring(struct iegbe_adapter *adapter,
-+static void iegbe_clean_tx_ring(struct iegbe_adapter *adapter,
- struct iegbe_tx_ring *tx_ring)
- {
-- struct iegbe_buffer *buffer_info;
-- unsigned long size;
-- unsigned int i;
--
-- /* Free all the Tx ring sk_buffs */
-+ struct iegbe_hw *hw = &adapter->hw;
-+ struct iegbe_buffer *buffer_info;
-+ unsigned long size;
-+ unsigned int i;
-
-- if (likely(tx_ring->previous_buffer_info.skb != NULL)) {
-- iegbe_unmap_and_free_tx_resource(adapter,
-- &tx_ring->previous_buffer_info);
-- }
-+ /* Free all the Tx ring sk_buffs */
-
- for (i = 0; i < tx_ring->count; i++) {
-- buffer_info = &tx_ring->buffer_info[i];
-- iegbe_unmap_and_free_tx_resource(adapter, buffer_info);
-- }
-+ buffer_info = &tx_ring->buffer_info[i];
-+ iegbe_unmap_and_free_tx_resource(adapter, buffer_info);
-+ }
-
-- size = sizeof(struct iegbe_buffer) * tx_ring->count;
-+ size = sizeof(struct iegbe_buffer) * tx_ring->count;
- memset(tx_ring->buffer_info, 0, size);
-
-- /* Zero out the descriptor ring */
-+ /* Zero out the descriptor ring */
-
- memset(tx_ring->desc, 0, tx_ring->size);
-
- tx_ring->next_to_use = 0;
- tx_ring->next_to_clean = 0;
-+ tx_ring->last_tx_tso = 0;
-
-- writel(0, adapter->hw.hw_addr + tx_ring->tdh);
-- writel(0, adapter->hw.hw_addr + tx_ring->tdt);
-+ writel(0, hw->hw_addr + tx_ring->tdh);
-+ writel(0, hw->hw_addr + tx_ring->tdt);
- }
-
- /**
-@@ -2173,12 +1949,11 @@ iegbe_clean_tx_ring(struct iegbe_adapter
- * @adapter: board private structure
- **/
-
--static void
--iegbe_clean_all_tx_rings(struct iegbe_adapter *adapter)
-+static void iegbe_clean_all_tx_rings(struct iegbe_adapter *adapter)
- {
-- int i;
-+ int i;
-
-- for (i = 0; i < adapter->num_queues; i++)
-+ for (i = 0; i < adapter->num_tx_queues; i++)
- iegbe_clean_tx_ring(adapter, &adapter->tx_ring[i]);
- }
-
-@@ -2190,24 +1965,23 @@ iegbe_clean_all_tx_rings(struct iegbe_ad
- * Free all receive software resources
- **/
-
--void
--iegbe_free_rx_resources(struct iegbe_adapter *adapter,
-+static void iegbe_free_rx_resources(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rx_ring)
- {
-- struct pci_dev *pdev = adapter->pdev;
-+ struct pci_dev *pdev = adapter->pdev;
-
-- iegbe_clean_rx_ring(adapter, rx_ring);
-+ iegbe_clean_rx_ring(adapter, rx_ring);
-
-- vfree(rx_ring->buffer_info);
-- rx_ring->buffer_info = NULL;
-- kfree(rx_ring->ps_page);
-- rx_ring->ps_page = NULL;
-- kfree(rx_ring->ps_page_dma);
-- rx_ring->ps_page_dma = NULL;
-+ vfree(rx_ring->buffer_info);
-+ rx_ring->buffer_info = NULL;
-+ kfree(rx_ring->ps_page);
-+ rx_ring->ps_page = NULL;
-+ kfree(rx_ring->ps_page_dma);
-+ rx_ring->ps_page_dma = NULL;
-
-- pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
-+ pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
-
-- rx_ring->desc = NULL;
-+ rx_ring->desc = NULL;
- }
-
- /**
-@@ -2217,12 +1991,11 @@ iegbe_free_rx_resources(struct iegbe_ada
- * Free all receive software resources
- **/
-
--void
--iegbe_free_all_rx_resources(struct iegbe_adapter *adapter)
-+void iegbe_free_all_rx_resources(struct iegbe_adapter *adapter)
- {
-- int i;
-+ int i;
-
-- for (i = 0; i < adapter->num_queues; i++)
-+ for (i = 0; i < adapter->num_rx_queues; i++)
- iegbe_free_rx_resources(adapter, &adapter->rx_ring[i]);
- }
-
-@@ -2232,60 +2005,59 @@ iegbe_free_all_rx_resources(struct iegbe
- * @rx_ring: ring to free buffers from
- **/
-
--static void
--iegbe_clean_rx_ring(struct iegbe_adapter *adapter,
-+static void iegbe_clean_rx_ring(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rx_ring)
- {
-- struct iegbe_buffer *buffer_info;
-- struct iegbe_ps_page *ps_page;
-- struct iegbe_ps_page_dma *ps_page_dma;
-- struct pci_dev *pdev = adapter->pdev;
-- unsigned long size;
-- unsigned int i, j;
--
-- /* Free all the Rx ring sk_buffs */
-+ struct iegbe_hw *hw = &adapter->hw;
-+ struct iegbe_buffer *buffer_info;
-+ struct iegbe_ps_page *ps_page;
-+ struct iegbe_ps_page_dma *ps_page_dma;
-+ struct pci_dev *pdev = adapter->pdev;
-+ unsigned long size;
-+ unsigned int i, j;
-+
-+ /* Free all the Rx ring sk_buffs */
-+
-+ for (i = 0; i < rx_ring->count; i++) {
-+ buffer_info = &rx_ring->buffer_info[i];
-+ if(buffer_info->skb) {
-+ pci_unmap_single(pdev,
-+ buffer_info->dma,
-+ buffer_info->length,
-+ PCI_DMA_FROMDEVICE);
-
-- for(i = 0; i < rx_ring->count; i++) {
-- buffer_info = &rx_ring->buffer_info[i];
-- if(buffer_info->skb) {
-- ps_page = &rx_ring->ps_page[i];
-- ps_page_dma = &rx_ring->ps_page_dma[i];
-- pci_unmap_single(pdev,
-- buffer_info->dma,
-- buffer_info->length,
-- PCI_DMA_FROMDEVICE);
--
-- dev_kfree_skb(buffer_info->skb);
-- buffer_info->skb = NULL;
--
-- for(j = 0; j < adapter->rx_ps_pages; j++) {
-- if(!ps_page->ps_page[j]) { break; }
-- pci_unmap_single(pdev,
-- ps_page_dma->ps_page_dma[j],
-- PAGE_SIZE, PCI_DMA_FROMDEVICE);
-- ps_page_dma->ps_page_dma[j] = 0;
-- put_page(ps_page->ps_page[j]);
-- ps_page->ps_page[j] = NULL;
-- }
-+ dev_kfree_skb(buffer_info->skb);
-+ buffer_info->skb = NULL;
- }
-- }
-+ ps_page = &rx_ring->ps_page[i];
-+ ps_page_dma = &rx_ring->ps_page_dma[i];
-+ for (j = 0; j < adapter->rx_ps_pages; j++) {
-+ if (!ps_page->ps_page[j]) break;
-+ pci_unmap_page(pdev,
-+ ps_page_dma->ps_page_dma[j],
-+ PAGE_SIZE, PCI_DMA_FROMDEVICE);
-+ ps_page_dma->ps_page_dma[j] = 0;
-+ put_page(ps_page->ps_page[j]);
-+ ps_page->ps_page[j] = NULL;
-+ }
-+ }
-
-- size = sizeof(struct iegbe_buffer) * rx_ring->count;
-+ size = sizeof(struct iegbe_buffer) * rx_ring->count;
- memset(rx_ring->buffer_info, 0, size);
-- size = sizeof(struct iegbe_ps_page) * rx_ring->count;
-+ size = sizeof(struct iegbe_ps_page) * rx_ring->count;
- memset(rx_ring->ps_page, 0, size);
-- size = sizeof(struct iegbe_ps_page_dma) * rx_ring->count;
-+ size = sizeof(struct iegbe_ps_page_dma) * rx_ring->count;
- memset(rx_ring->ps_page_dma, 0, size);
-
-- /* Zero out the descriptor ring */
-+ /* Zero out the descriptor ring */
-
- memset(rx_ring->desc, 0, rx_ring->size);
-
- rx_ring->next_to_clean = 0;
- rx_ring->next_to_use = 0;
-
-- writel(0, adapter->hw.hw_addr + rx_ring->rdh);
-- writel(0, adapter->hw.hw_addr + rx_ring->rdt);
-+ writel(0, hw->hw_addr + rx_ring->rdh);
-+ writel(0, hw->hw_addr + rx_ring->rdt);
- }
-
- /**
-@@ -2293,60 +2065,54 @@ iegbe_clean_rx_ring(struct iegbe_adapter
- * @adapter: board private structure
- **/
-
--static void
--iegbe_clean_all_rx_rings(struct iegbe_adapter *adapter)
-+static void iegbe_clean_all_rx_rings(struct iegbe_adapter *adapter)
- {
-- int i;
-+ int i;
-
-- for (i = 0; i < adapter->num_queues; i++)
-+ for (i = 0; i < adapter->num_rx_queues; i++)
- iegbe_clean_rx_ring(adapter, &adapter->rx_ring[i]);
- }
-
- /* The 82542 2.0 (revision 2) needs to have the receive unit in reset
- * and memory write and invalidate disabled for certain operations
- */
--static void
--iegbe_enter_82542_rst(struct iegbe_adapter *adapter)
-+static void iegbe_enter_82542_rst(struct iegbe_adapter *adapter)
- {
-- struct net_device *netdev = adapter->netdev;
-- uint32_t rctl;
-+ struct net_device *netdev = adapter->netdev;
-+ uint32_t rctl;
-
-- iegbe_pci_clear_mwi(&adapter->hw);
-+ iegbe_pci_clear_mwi(&adapter->hw);
-
-- rctl = E1000_READ_REG(&adapter->hw, RCTL);
-- rctl |= E1000_RCTL_RST;
-- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
-- E1000_WRITE_FLUSH(&adapter->hw);
-+ rctl = E1000_READ_REG(&adapter->hw, RCTL);
-+ rctl |= E1000_RCTL_RST;
-+ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
-+ E1000_WRITE_FLUSH(&adapter->hw);
- mdelay(0x5);
-
- if(netif_running(netdev)) {
-- iegbe_clean_all_rx_rings(adapter);
--}
-+ iegbe_clean_all_rx_rings(adapter);
-+ }
- }
-
- static void
- iegbe_leave_82542_rst(struct iegbe_adapter *adapter)
- {
-- struct net_device *netdev = adapter->netdev;
-- uint32_t rctl;
-+ struct net_device *netdev = adapter->netdev;
-+ uint32_t rctl;
-
-- rctl = E1000_READ_REG(&adapter->hw, RCTL);
-- rctl &= ~E1000_RCTL_RST;
-- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
-- E1000_WRITE_FLUSH(&adapter->hw);
-+ rctl = E1000_READ_REG(&adapter->hw, RCTL);
-+ rctl &= ~E1000_RCTL_RST;
-+ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
-+ E1000_WRITE_FLUSH(&adapter->hw);
- mdelay(0x5);
-
- if(adapter->hw.pci_cmd_word & PCI_COMMAND_INVALIDATE) {
-- iegbe_pci_set_mwi(&adapter->hw);
-+ iegbe_pci_set_mwi(&adapter->hw);
- }
- if(netif_running(netdev)) {
-+ struct iegbe_rx_ring *ring = &adapter->rx_ring[0x0];
- iegbe_configure_rx(adapter);
--#ifdef IEGBE_GBE_WORKAROUND
-- iegbe_alloc_rx_buffers(adapter, &adapter->rx_ring[0],
-- IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS + 1);
--#else
-- iegbe_alloc_rx_buffers(adapter, &adapter->rx_ring[0]);
--#endif
-+ adapter->alloc_rx_buf(adapter, ring, E1000_DESC_UNUSED(ring));
- }
- }
-
-@@ -2358,133 +2124,153 @@ iegbe_leave_82542_rst(struct iegbe_adapt
- * Returns 0 on success, negative on failure
- **/
-
--static int
--iegbe_set_mac(struct net_device *netdev, void *p)
-+static int iegbe_set_mac(struct net_device *netdev, void *p)
- {
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-- struct sockaddr *addr = p;
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ struct sockaddr *addr = p;
-
- if(!is_valid_ether_addr(addr->sa_data)) {
-- return -EADDRNOTAVAIL;
-+ return -EADDRNOTAVAIL;
- }
-- /* 82542 2.0 needs to be in reset to write receive address registers */
-+ /* 82542 2.0 needs to be in reset to write receive address registers */
-
- if(adapter->hw.mac_type == iegbe_82542_rev2_0) {
-- iegbe_enter_82542_rst(adapter);
-+ iegbe_enter_82542_rst(adapter);
- }
-- memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
-- memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len);
-+ memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
-+ memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len);
-
-- iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
-+ iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr, 0x0);
-
-- /* With 82571 controllers, LAA may be overwritten (with the default)
-- * due to controller reset from the other port. */
-- if (adapter->hw.mac_type == iegbe_82571) {
-- /* activate the work around */
-+ /* With 82571 controllers, LAA may be overwritten (with the default)
-+ * due to controller reset from the other port. */
-+ if (adapter->hw.mac_type == iegbe_82571) {
-+ /* activate the work around */
- adapter->hw.laa_is_present = 0x1;
-
-- /* Hold a copy of the LAA in RAR[14] This is done so that
-- * between the time RAR[0] gets clobbered and the time it
-- * gets fixed (in iegbe_watchdog), the actual LAA is in one
-- * of the RARs and no incoming packets directed to this port
-- * are dropped. Eventaully the LAA will be in RAR[0] and
-- * RAR[14] */
-- iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr,
-+ /* Hold a copy of the LAA in RAR[14] This is done so that
-+ * between the time RAR[0] gets clobbered and the time it
-+ * gets fixed (in iegbe_watchdog), the actual LAA is in one
-+ * of the RARs and no incoming packets directed to this port
-+ * are dropped. Eventaully the LAA will be in RAR[0] and
-+ * RAR[14] */
-+ iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr,
- E1000_RAR_ENTRIES - 0x1);
-- }
-+ }
-
- if(adapter->hw.mac_type == iegbe_82542_rev2_0) {
-- iegbe_leave_82542_rst(adapter);
-+ iegbe_leave_82542_rst(adapter);
- }
-- return 0;
-+ return 0x0;
- }
-
- /**
-- * iegbe_set_multi - Multicast and Promiscuous mode set
-+ * iegbe_set_rx_mode - Secondary Unicast, Multicast and Promiscuous mode set
- * @netdev: network interface device structure
- *
-- * The set_multi entry point is called whenever the multicast address
-- * list or the network interface flags are updated. This routine is
-- * responsible for configuring the hardware for proper multicast,
-+ * The set_rx_mode entry point is called whenever the unicast or multicast
-+ * address lists or the network interface flags are updated. This routine is
-+ * responsible for configuring the hardware for proper unicast, multicast,
- * promiscuous mode, and all-multi behavior.
- **/
-
--static void
--iegbe_set_multi(struct net_device *netdev)
-+static void iegbe_set_rx_mode(struct net_device *netdev)
- {
- struct iegbe_adapter *adapter = netdev_priv(netdev);
- struct iegbe_hw *hw = &adapter->hw;
-- struct dev_mc_list *mc_ptr;
-- uint32_t rctl;
-- uint32_t hash_value;
-+ struct dev_addr_list *uc_ptr;
-+ struct dev_addr_list *mc_ptr;
-+ u32 rctl;
-+ u32 hash_value;
- int i, rar_entries = E1000_RAR_ENTRIES;
-+int mta_reg_count = E1000_NUM_MTA_REGISTERS;
-
- /* reserve RAR[14] for LAA over-write work-around */
-- if (adapter->hw.mac_type == iegbe_82571) {
-+ if (hw->mac_type == iegbe_82571)
- rar_entries--;
-- }
-+
- /* Check for Promiscuous and All Multicast modes */
-
-- rctl = E1000_READ_REG(hw, RCTL);
-+ rctl = E1000_READ_REG(&adapter->hw, RCTL);
-
- if (netdev->flags & IFF_PROMISC) {
- rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
-- } else if (netdev->flags & IFF_ALLMULTI) {
-- rctl |= E1000_RCTL_MPE;
-- rctl &= ~E1000_RCTL_UPE;
-+ rctl &= ~E1000_RCTL_VFE;
- } else {
-- rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
-+ if (netdev->flags & IFF_ALLMULTI) {
-+ rctl |= E1000_RCTL_MPE;
-+ } else {
-+ rctl &= ~E1000_RCTL_MPE;
-+ }
-+ }
-+
-+ uc_ptr = NULL;
-+ if (netdev->uc_count > rar_entries - 1) {
-+ rctl |= E1000_RCTL_UPE;
-+ } else if (!(netdev->flags & IFF_PROMISC)) {
-+ rctl &= ~E1000_RCTL_UPE;
-+ uc_ptr = netdev->uc_list;
- }
-
-- E1000_WRITE_REG(hw, RCTL, rctl);
-+ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
-
- /* 82542 2.0 needs to be in reset to write receive address registers */
-
-- if (hw->mac_type == iegbe_82542_rev2_0) {
-+ if (hw->mac_type == iegbe_82542_rev2_0)
- iegbe_enter_82542_rst(adapter);
-- }
-- /* load the first 14 multicast address into the exact filters 1-14
-+
-+ /* load the first 14 addresses into the exact filters 1-14. Unicast
-+ * addresses take precedence to avoid disabling unicast filtering
-+ * when possible.
-+ *
- * RAR 0 is used for the station MAC adddress
- * if there are not 14 addresses, go ahead and clear the filters
- * -- with 82571 controllers only 0-13 entries are filled here
- */
- mc_ptr = netdev->mc_list;
-
-- for (i = 0x1; i < rar_entries; i++) {
-- if (mc_ptr) {
-- iegbe_rar_set(hw, mc_ptr->dmi_addr, i);
-+ for (i = 1; i < rar_entries; i++) {
-+ if (uc_ptr) {
-+ iegbe_rar_set(hw, uc_ptr->da_addr, i);
-+ uc_ptr = uc_ptr->next;
-+ } else if (mc_ptr) {
-+ iegbe_rar_set(hw, mc_ptr->da_addr, i);
- mc_ptr = mc_ptr->next;
- } else {
-- E1000_WRITE_REG_ARRAY(hw, RA, i << 0x1, 0);
-- E1000_WRITE_REG_ARRAY(hw, RA, (i << 0x1) + 0x1, 0);
-+ E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
-+ E1000_WRITE_FLUSH(&adapter->hw);
-+ E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
-+ E1000_WRITE_FLUSH(&adapter->hw);
- }
- }
-+ WARN_ON(uc_ptr != NULL);
-
- /* clear the old settings from the multicast hash table */
-
-- for (i = 0; i < E1000_NUM_MTA_REGISTERS; i++)
-+ for (i = 0; i < mta_reg_count; i++) {
- E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
-+ E1000_WRITE_FLUSH(&adapter->hw);
-+ }
-
- /* load any remaining addresses into the hash table */
-
- for (; mc_ptr; mc_ptr = mc_ptr->next) {
-- hash_value = iegbe_hash_mc_addr(hw, mc_ptr->dmi_addr);
-+ hash_value = iegbe_hash_mc_addr(hw, mc_ptr->da_addr);
- iegbe_mta_set(hw, hash_value);
- }
-
-- if (hw->mac_type == iegbe_82542_rev2_0) {
-+ if (hw->mac_type == iegbe_82542_rev2_0)
- iegbe_leave_82542_rst(adapter);
- }
--}
-
- /* Need to wait a few seconds after link up to get diagnostic information from
- * the phy */
-
--static void
--iegbe_update_phy_info(unsigned long data)
-+static void iegbe_update_phy_info(unsigned long data)
- {
-- struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
-- iegbe_phy_get_info(&adapter->hw, &adapter->phy_info);
-+ struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
-+ struct iegbe_hw *hw = &adapter->hw;
-+ iegbe_phy_get_info(hw, &adapter->phy_info);
- }
-
- /**
-@@ -2492,54 +2278,54 @@ iegbe_update_phy_info(unsigned long data
- * @data: pointer to adapter cast into an unsigned long
- **/
-
--static void
--iegbe_82547_tx_fifo_stall(unsigned long data)
-+static void iegbe_82547_tx_fifo_stall(unsigned long data)
- {
-- struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
-- struct net_device *netdev = adapter->netdev;
-- uint32_t tctl;
-+ struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
-+ struct net_device *netdev = adapter->netdev;
-+ u32 tctl;
-
-- if(atomic_read(&adapter->tx_fifo_stall)) {
-- if((E1000_READ_REG(&adapter->hw, TDT) ==
-- E1000_READ_REG(&adapter->hw, TDH)) &&
-- (E1000_READ_REG(&adapter->hw, TDFT) ==
-- E1000_READ_REG(&adapter->hw, TDFH)) &&
-- (E1000_READ_REG(&adapter->hw, TDFTS) ==
-- E1000_READ_REG(&adapter->hw, TDFHS))) {
-- tctl = E1000_READ_REG(&adapter->hw, TCTL);
-- E1000_WRITE_REG(&adapter->hw, TCTL,
-- tctl & ~E1000_TCTL_EN);
-- E1000_WRITE_REG(&adapter->hw, TDFT,
-- adapter->tx_head_addr);
-- E1000_WRITE_REG(&adapter->hw, TDFH,
-- adapter->tx_head_addr);
-- E1000_WRITE_REG(&adapter->hw, TDFTS,
-- adapter->tx_head_addr);
-- E1000_WRITE_REG(&adapter->hw, TDFHS,
-- adapter->tx_head_addr);
-- E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
-- E1000_WRITE_FLUSH(&adapter->hw);
--
-- adapter->tx_fifo_head = 0;
-- atomic_set(&adapter->tx_fifo_stall, 0);
-- netif_wake_queue(netdev);
-- } else {
-+ if(atomic_read(&adapter->tx_fifo_stall)) {
-+ if((E1000_READ_REG(&adapter->hw, TDT) ==
-+ E1000_READ_REG(&adapter->hw, TDH)) &&
-+ (E1000_READ_REG(&adapter->hw, TDFT) ==
-+ E1000_READ_REG(&adapter->hw, TDFH)) &&
-+ (E1000_READ_REG(&adapter->hw, TDFTS) ==
-+ E1000_READ_REG(&adapter->hw, TDFHS))) {
-+ tctl = E1000_READ_REG(&adapter->hw, TCTL);
-+ E1000_WRITE_REG(&adapter->hw, TCTL,
-+ tctl & ~E1000_TCTL_EN);
-+ E1000_WRITE_REG(&adapter->hw, TDFT,
-+ adapter->tx_head_addr);
-+ E1000_WRITE_REG(&adapter->hw, TDFH,
-+ adapter->tx_head_addr);
-+ E1000_WRITE_REG(&adapter->hw, TDFTS,
-+ adapter->tx_head_addr);
-+ E1000_WRITE_REG(&adapter->hw, TDFHS,
-+ adapter->tx_head_addr);
-+ E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
-+ E1000_WRITE_FLUSH(&adapter->hw);
-+
-+ adapter->tx_fifo_head = 0x0;
-+ atomic_set(&adapter->tx_fifo_stall, 0x0);
-+ netif_wake_queue(netdev);
-+ } else {
- mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 0x1);
-- }
-- }
-+ }
-+ }
- }
-
-+
- /**
- * iegbe_watchdog - Timer Call-back
- * @data: pointer to adapter cast into an unsigned long
- **/
--static void
--iegbe_watchdog(unsigned long data)
-+static void iegbe_watchdog(unsigned long data)
- {
-- struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
-- struct net_device *netdev = adapter->netdev;
-- struct iegbe_tx_ring *txdr = &adapter->tx_ring[0];
-- uint32_t link;
-+ struct iegbe_adapter *adapter = (struct iegbe_adapter *) data;
-+ struct iegbe_hw *hw = &adapter->hw;
-+ struct net_device *netdev = adapter->netdev;
-+ struct iegbe_tx_ring *txdr = adapter->tx_ring;
-+ u32 link, tctl;
-
- /*
- * Test the PHY for link status on icp_xxxx MACs.
-@@ -2547,123 +2333,305 @@ iegbe_watchdog(unsigned long data)
- * in the adapter->hw structure, then set hw->get_link_status = 1
- */
- if(adapter->hw.mac_type == iegbe_icp_xxxx) {
-- int isUp = 0;
-+ int isUp = 0x0;
- int32_t ret_val;
-
- ret_val = iegbe_oem_phy_is_link_up(&adapter->hw, &isUp);
- if(ret_val != E1000_SUCCESS) {
-- isUp = 0;
-- }
-+ isUp = 0x0;
-+ }
- if(isUp != adapter->hw.icp_xxxx_is_link_up) {
- adapter->hw.get_link_status = 0x1;
- }
- }
-
-- iegbe_check_for_link(&adapter->hw);
-- if (adapter->hw.mac_type == iegbe_82573) {
-- iegbe_enable_tx_pkt_filtering(&adapter->hw);
-+ iegbe_check_for_link(&adapter->hw);
-+ if (adapter->hw.mac_type == iegbe_82573) {
-+ iegbe_enable_tx_pkt_filtering(&adapter->hw);
- #ifdef NETIF_F_HW_VLAN_TX
- if (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id) {
-- iegbe_update_mng_vlan(adapter);
-+ iegbe_update_mng_vlan(adapter);
- }
- #endif
-- }
-+ }
-
-- if ((adapter->hw.media_type == iegbe_media_type_internal_serdes) &&
-- !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE)) {
-- link = !adapter->hw.serdes_link_down;
-- } else {
-+ if ((adapter->hw.media_type == iegbe_media_type_internal_serdes) &&
-+ !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE)) {
-+ link = !adapter->hw.serdes_link_down;
-+ } else {
-
-- if(adapter->hw.mac_type != iegbe_icp_xxxx) {
-- link = E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU;
-- } else {
-- int isUp = 0;
-+ if(adapter->hw.mac_type != iegbe_icp_xxxx) {
-+ link = E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU;
-+ } else {
-+ int isUp = 0x0;
- if(iegbe_oem_phy_is_link_up(&adapter->hw, &isUp) != E1000_SUCCESS) {
-- isUp = 0;
-+ isUp = 0x0;
- }
-- link = isUp;
-- }
-- }
-+ link = isUp;
-+ }
-+ }
-
-- if (link) {
-- if (!netif_carrier_ok(netdev)) {
-- iegbe_get_speed_and_duplex(&adapter->hw,
-- &adapter->link_speed,
-- &adapter->link_duplex);
--
-- DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s\n",
-- adapter->link_speed,
-- adapter->link_duplex == FULL_DUPLEX ?
-- "Full Duplex" : "Half Duplex");
-+ if (link) {
-+ if (!netif_carrier_ok(netdev)) {
-+ u32 ctrl;
-+ bool txb2b = true;
-+ iegbe_get_speed_and_duplex(hw,
-+ &adapter->link_speed,
-+ &adapter->link_duplex);
-
-- netif_carrier_on(netdev);
-- netif_wake_queue(netdev);
-- mod_timer(&adapter->phy_info_timer, jiffies + 0x2 * HZ);
-+ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
-+ DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s, "
-+ "Flow Control: %s\n",
-+ adapter->link_speed,
-+ adapter->link_duplex == FULL_DUPLEX ?
-+ "Full Duplex" : "Half Duplex",
-+ ((ctrl & E1000_CTRL_TFCE) && (ctrl &
-+ E1000_CTRL_RFCE)) ? "RX/TX" : ((ctrl &
-+ E1000_CTRL_RFCE) ? "RX" : ((ctrl &
-+ E1000_CTRL_TFCE) ? "TX" : "None" )));
-+
-+ /* tweak tx_queue_len according to speed/duplex
-+ * and adjust the timeout factor */
-+ netdev->tx_queue_len = adapter->tx_queue_len;
-+ adapter->tx_timeout_factor = 1;
-+ switch (adapter->link_speed) {
-+ case SPEED_10:
-+ txb2b = false;
-+ netdev->tx_queue_len = 10;
-+ adapter->tx_timeout_factor = 8;
-+ break;
-+ case SPEED_100:
-+ txb2b = false;
-+ netdev->tx_queue_len = 100;
-+ break;
-+ }
-+ if ((hw->mac_type == iegbe_82571 ||
-+ hw->mac_type == iegbe_82572) &&
-+ !txb2b) {
-+ u32 tarc0;
-+ tarc0 = E1000_READ_REG(&adapter->hw, TARC0);
-+ tarc0 &= ~(1 << 21);
-+ E1000_WRITE_REG(&adapter->hw, TARC0, tarc0);
-+ }
-+ /* disable TSO for pcie and 10/100 speeds, to avoid
-+ * some hardware issues */
-+ if (!adapter->tso_force &&
-+ hw->bus_type == iegbe_bus_type_pci_express){
-+ switch (adapter->link_speed) {
-+ case SPEED_10:
-+ case SPEED_100:
-+ DPRINTK(PROBE,INFO,
-+ "10/100 speed: disabling TSO\n");
-+ netdev->features &= ~NETIF_F_TSO;
-+ netdev->features &= ~NETIF_F_TSO6;
-+ break;
-+ case SPEED_1000:
-+ netdev->features |= NETIF_F_TSO;
-+ netdev->features |= NETIF_F_TSO6;
-+ break;
-+ default:
-+ break;
-+ }
-+ }
-+ tctl = E1000_READ_REG(&adapter->hw, TCTL);
-+ tctl |= E1000_TCTL_EN;
-+ E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
-+ netif_carrier_on(netdev);
-+ netif_wake_queue(netdev);
-+ mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
- adapter->smartspeed = 0;
-+ } else {
-+ if (hw->rx_needs_kicking) {
-+ u32 rctl = E1000_READ_REG(&adapter->hw, RCTL);
-+ E1000_WRITE_REG(&adapter->hw, RCTL, rctl | E1000_RCTL_EN);
-+ }
- }
-- } else {
-- if (netif_carrier_ok(netdev)) {
-+ } else {
-+ if (netif_carrier_ok(netdev)) {
- adapter->link_speed = 0;
- adapter->link_duplex = 0;
-- DPRINTK(LINK, INFO, "NIC Link is Down\n");
-- netif_carrier_off(netdev);
-- netif_stop_queue(netdev);
-- mod_timer(&adapter->phy_info_timer, jiffies + 0x2 * HZ);
-- }
-+ DPRINTK(LINK, INFO, "NIC Link is Down\n");
-+ netif_carrier_off(netdev);
-+ netif_stop_queue(netdev);
-+ mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
-+ }
-
-- iegbe_smartspeed(adapter);
-- }
-+ iegbe_smartspeed(adapter);
-+ }
-+
-+ iegbe_update_stats(adapter);
-+
-+ hw->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
-+ adapter->tpt_old = adapter->stats.tpt;
-+ hw->collision_delta = adapter->stats.colc - adapter->colc_old;
-+ adapter->colc_old = adapter->stats.colc;
-+
-+ adapter->gorcl = adapter->stats.gorcl - adapter->gorcl_old;
-+ adapter->gorcl_old = adapter->stats.gorcl;
-+ adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old;
-+ adapter->gotcl_old = adapter->stats.gotcl;
-+
-+ iegbe_update_adaptive(hw);
-+
-+ if (!netif_carrier_ok(netdev)) {
-+ if (E1000_DESC_UNUSED(txdr) + 1 < txdr->count) {
-+ /* We've lost link, so the controller stops DMA,
-+ * but we've got queued Tx work that's never going
-+ * to get done, so reset controller to flush Tx.
-+ * (Do the reset outside of interrupt context). */
-+ adapter->tx_timeout_count++;
-+ schedule_work(&adapter->reset_task);
-+ }
-+ }
-+
-+ /* Cause software interrupt to ensure rx ring is cleaned */
-+ E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0);
-+
-+ /* Force detection of hung controller every watchdog period */
-+ adapter->detect_tx_hung = TRUE;
-+
-+ /* With 82571 controllers, LAA may be overwritten due to controller
-+ * reset from the other port. Set the appropriate LAA in RAR[0] */
-+ if (adapter->hw.mac_type == iegbe_82571 && adapter->hw.laa_is_present) {
-+ iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr, 0x0);
-+ }
-+ /* Reset the timer */
-+ mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 2 * HZ));
-+}
-+
-+enum latency_range {
-+ lowest_latency = 0,
-+ low_latency = 1,
-+ bulk_latency = 2,
-+ latency_invalid = 255
-+};
-
-- iegbe_update_stats(adapter);
-+/**
-+ * iegbe_update_itr - update the dynamic ITR value based on statistics
-+ * Stores a new ITR value based on packets and byte
-+ * counts during the last interrupt. The advantage of per interrupt
-+ * computation is faster updates and more accurate ITR for the current
-+ * traffic pattern. Constants in this function were computed
-+ * based on theoretical maximum wire speed and thresholds were set based
-+ * on testing data as well as attempting to minimize response time
-+ * while increasing bulk throughput.
-+ * this functionality is controlled by the InterruptThrottleRate module
-+ * parameter (see iegbe_param.c)
-+ * @adapter: pointer to adapter
-+ * @itr_setting: current adapter->itr
-+ * @packets: the number of packets during this measurement interval
-+ * @bytes: the number of bytes during this measurement interval
-+ **/
-+static unsigned int iegbe_update_itr(struct iegbe_adapter *adapter,
-+ u16 itr_setting, int packets, int bytes)
-+{
-+ unsigned int retval = itr_setting;
-+ struct iegbe_hw *hw = &adapter->hw;
-
-- adapter->hw.tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
-- adapter->tpt_old = adapter->stats.tpt;
-- adapter->hw.collision_delta = adapter->stats.colc - adapter->colc_old;
-- adapter->colc_old = adapter->stats.colc;
--
-- adapter->gorcl = adapter->stats.gorcl - adapter->gorcl_old;
-- adapter->gorcl_old = adapter->stats.gorcl;
-- adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old;
-- adapter->gotcl_old = adapter->stats.gotcl;
--
-- iegbe_update_adaptive(&adapter->hw);
--
-- if (adapter->num_queues == 0x1 && !netif_carrier_ok(netdev)) {
-- if (E1000_DESC_UNUSED(txdr) + 0x1 < txdr->count) {
-- /* We've lost link, so the controller stops DMA,
-- * but we've got queued Tx work that's never going
-- * to get done, so reset controller to flush Tx.
-- * (Do the reset outside of interrupt context). */
-- schedule_work(&adapter->tx_timeout_task);
-+ if (unlikely(hw->mac_type < iegbe_82540))
-+ goto update_itr_done;
-+
-+ if (packets == 0)
-+ goto update_itr_done;
-+
-+ switch (itr_setting) {
-+ case lowest_latency:
-+ /* jumbo frames get bulk treatment*/
-+ if (bytes/packets > 8000)
-+ retval = bulk_latency;
-+ else if ((packets < 5) && (bytes > 512))
-+ retval = low_latency;
-+ break;
-+ case low_latency: /* 50 usec aka 20000 ints/s */
-+ if (bytes > 10000) {
-+ /* jumbo frames need bulk latency setting */
-+ if (bytes/packets > 8000)
-+ retval = bulk_latency;
-+ else if ((packets < 10) || ((bytes/packets) > 1200))
-+ retval = bulk_latency;
-+ else if ((packets > 35))
-+ retval = lowest_latency;
-+ } else if (bytes/packets > 2000)
-+ retval = bulk_latency;
-+ else if (packets <= 2 && bytes < 512)
-+ retval = lowest_latency;
-+ break;
-+ case bulk_latency: /* 250 usec aka 4000 ints/s */
-+ if (bytes > 25000) {
-+ if (packets > 35)
-+ retval = low_latency;
-+ } else if (bytes < 6000) {
-+ retval = low_latency;
- }
-+ break;
- }
-
-- /* Dynamic mode for Interrupt Throttle Rate (ITR) */
-- if (adapter->hw.mac_type >= iegbe_82540 && adapter->itr == 0x1) {
-- /* Symmetric Tx/Rx gets a reduced ITR=2000; Total
-- * asymmetrical Tx or Rx gets ITR=8000; everyone
-- * else is between 2000-8000. */
-- uint32_t goc = (adapter->gotcl + adapter->gorcl) / 0x2710;
-- uint32_t dif = (adapter->gotcl > adapter->gorcl ?
-- adapter->gotcl - adapter->gorcl :
-- adapter->gorcl - adapter->gotcl) / 0x2710;
-- uint32_t itr = goc > 0 ? (dif * 0x1770 / goc + 0x7d0) : 0x1f40;
-- E1000_WRITE_REG(&adapter->hw, ITR, 0x3b9aca00 / (itr * 0x100));
-- }
-+update_itr_done:
-+ return retval;
-+}
-
-- /* Cause software interrupt to ensure rx ring is cleaned */
-- E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0);
-+static void iegbe_set_itr(struct iegbe_adapter *adapter)
-+{
-+ struct iegbe_hw *hw = &adapter->hw;
-+ u16 current_itr;
-+ u32 new_itr = adapter->itr;
-
-- /* Force detection of hung controller every watchdog period */
-- adapter->detect_tx_hung = TRUE;
-+ if (unlikely(hw->mac_type < iegbe_82540))
-+ return;
-
-- /* With 82571 controllers, LAA may be overwritten due to controller
-- * reset from the other port. Set the appropriate LAA in RAR[0] */
-- if (adapter->hw.mac_type == iegbe_82571 && adapter->hw.laa_is_present) {
-- iegbe_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
-- }
-- /* Reset the timer */
-- mod_timer(&adapter->watchdog_timer, jiffies + 0x2 * HZ);
-+ /* for non-gigabit speeds, just fix the interrupt rate at 4000 */
-+ if (unlikely(adapter->link_speed != SPEED_1000)) {
-+ current_itr = 0;
-+ new_itr = 4000;
-+ goto set_itr_now;
-+ }
-+
-+ adapter->tx_itr = iegbe_update_itr(adapter,
-+ adapter->tx_itr,
-+ adapter->total_tx_packets,
-+ adapter->total_tx_bytes);
-+ /* conservative mode (itr 3) eliminates the lowest_latency setting */
-+ if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)
-+ adapter->tx_itr = low_latency;
-+
-+ adapter->rx_itr = iegbe_update_itr(adapter,
-+ adapter->rx_itr,
-+ adapter->total_rx_packets,
-+ adapter->total_rx_bytes);
-+ /* conservative mode (itr 3) eliminates the lowest_latency setting */
-+ if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)
-+ adapter->rx_itr = low_latency;
-+
-+ current_itr = max(adapter->rx_itr, adapter->tx_itr);
-+
-+ switch (current_itr) {
-+ /* counts and packets in update_itr are dependent on these numbers */
-+ case lowest_latency:
-+ new_itr = 70000;
-+ break;
-+ case low_latency:
-+ new_itr = 20000; /* aka hwitr = ~200 */
-+ break;
-+ case bulk_latency:
-+ new_itr = 4000;
-+ break;
-+ default:
-+ break;
-+ }
-+
-+set_itr_now:
-+ if (new_itr != adapter->itr) {
-+ /* this attempts to bias the interrupt rate towards Bulk
-+ * by adding intermediate steps when interrupt rate is
-+ * increasing */
-+ new_itr = new_itr > adapter->itr ?
-+ min(adapter->itr + (new_itr >> 2), new_itr) :
-+ new_itr;
-+ adapter->itr = new_itr;
-+ E1000_WRITE_REG(&adapter->hw, ITR, 1000000000 / (new_itr * 256));
-+ }
-+
-+ return;
- }
-
- #define E1000_TX_FLAGS_CSUM 0x00000001
-@@ -2673,55 +2641,48 @@ iegbe_watchdog(unsigned long data)
- #define E1000_TX_FLAGS_VLAN_MASK 0xffff0000
- #define E1000_TX_FLAGS_VLAN_SHIFT 16
-
--static inline int
--iegbe_tso(struct iegbe_adapter *adapter, struct iegbe_tx_ring *tx_ring,
-- struct sk_buff *skb)
-+static int iegbe_tso(struct iegbe_adapter *adapter,
-+ struct iegbe_tx_ring *tx_ring, struct sk_buff *skb)
- {
--#ifdef NETIF_F_TSO
- struct iegbe_context_desc *context_desc;
-+ struct iegbe_buffer *buffer_info;
- unsigned int i;
-- uint32_t cmd_length = 0;
-- uint16_t ipcse = 0, tucse, mss;
-- uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
-+ u32 cmd_length = 0;
-+ u16 ipcse = 0, tucse, mss;
-+ u8 ipcss, ipcso, tucss, tucso, hdr_len;
- int err;
-
- if (skb_is_gso(skb)) {
- if (skb_header_cloned(skb)) {
- err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
-- if (err) {
-+ if (err)
- return err;
- }
-- }
-
-- hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 0x2));
-+ hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
- mss = skb_shinfo(skb)->gso_size;
- if (skb->protocol == htons(ETH_P_IP)) {
-- skb->nh.iph->tot_len = 0;
-- skb->nh.iph->check = 0;
-- skb->h.th->check =
-- ~csum_tcpudp_magic(skb->nh.iph->saddr,
-- skb->nh.iph->daddr,
-- 0,
-- IPPROTO_TCP,
-- 0);
-+ struct iphdr *iph = ip_hdr(skb);
-+ iph->tot_len = 0;
-+ iph->check = 0;
-+ tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
-+ iph->daddr, 0,
-+ IPPROTO_TCP,
-+ 0);
- cmd_length = E1000_TXD_CMD_IP;
-- ipcse = skb->h.raw - skb->data - 0x1;
--#ifdef NETIF_F_TSO_IPV6
-- } else if (skb->protocol == ntohs(ETH_P_IPV6)) {
-- skb->nh.ipv6h->payload_len = 0;
-- skb->h.th->check =
-- ~csum_ipv6_magic(&skb->nh.ipv6h->saddr,
-- &skb->nh.ipv6h->daddr,
-- 0,
-- IPPROTO_TCP,
-- 0);
-+ ipcse = skb_transport_offset(skb) - 1;
-+ } else if (skb->protocol == htons(ETH_P_IPV6)) {
-+ ipv6_hdr(skb)->payload_len = 0;
-+ tcp_hdr(skb)->check =
-+ ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
-+ &ipv6_hdr(skb)->daddr,
-+ 0, IPPROTO_TCP, 0);
- ipcse = 0;
--#endif
- }
-- ipcss = skb->nh.raw - skb->data;
-- ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
-- tucss = skb->h.raw - skb->data;
-- tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
-+ ipcss = skb_network_offset(skb);
-+ ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
-+ tucss = skb_transport_offset(skb);
-+ tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
- tucse = 0;
-
- cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
-@@ -2729,6 +2690,7 @@ iegbe_tso(struct iegbe_adapter *adapter,
-
- i = tx_ring->next_to_use;
- context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
-+ buffer_info = &tx_ring->buffer_info[i];
-
- context_desc->lower_setup.ip_fields.ipcss = ipcss;
- context_desc->lower_setup.ip_fields.ipcso = ipcso;
-@@ -2740,205 +2702,218 @@ iegbe_tso(struct iegbe_adapter *adapter,
- context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
- context_desc->cmd_and_length = cpu_to_le32(cmd_length);
-
-- if (++i == tx_ring->count) { i = 0; }
-+ buffer_info->time_stamp = jiffies;
-+ buffer_info->next_to_watch = i;
-+
-+ if (++i == tx_ring->count) i = 0;
- tx_ring->next_to_use = i;
-
-- return TRUE;
-+ return true;
- }
--#endif
--
-- return FALSE;
-+ return false;
- }
-
--static inline boolean_t
--iegbe_tx_csum(struct iegbe_adapter *adapter, struct iegbe_tx_ring *tx_ring,
-- struct sk_buff *skb)
-+static bool iegbe_tx_csum(struct iegbe_adapter *adapter,
-+ struct iegbe_tx_ring *tx_ring, struct sk_buff *skb)
- {
- struct iegbe_context_desc *context_desc;
-+ struct iegbe_buffer *buffer_info;
- unsigned int i;
-- uint8_t css;
-+ u8 css;
-
-- if (likely(skb->ip_summed == CHECKSUM_HW)) {
-- css = skb->h.raw - skb->data;
-+ if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
-+ css = skb_transport_offset(skb);
-
-- i = tx_ring->next_to_use;
-- context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
-+ i = tx_ring->next_to_use;
-+ buffer_info = &tx_ring->buffer_info[i];
-+ context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
-
-+ context_desc->lower_setup.ip_config = 0;
- context_desc->upper_setup.tcp_fields.tucss = css;
-- context_desc->upper_setup.tcp_fields.tucso = css + skb->csum;
-+ context_desc->upper_setup.tcp_fields.tucso =
-+ css + skb->csum_offset;
- context_desc->upper_setup.tcp_fields.tucse = 0;
- context_desc->tcp_seg_setup.data = 0;
- context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT);
-
-- if (unlikely(++i == tx_ring->count)) { i = 0; }
-+ buffer_info->time_stamp = jiffies;
-+ buffer_info->next_to_watch = i;
-+
-+ if (unlikely(++i == tx_ring->count)) i = 0;
- tx_ring->next_to_use = i;
-
-- return TRUE;
-+ return true;
- }
-
-- return FALSE;
-+ return false;
- }
-
--#define E1000_MAX_TXD_PWR 12
--#define E1000_MAX_DATA_PER_TXD (1<<E1000_MAX_TXD_PWR)
-+#define E1000_MAX_TXD_PWR 12
-+#define E1000_MAX_DATA_PER_TXD (1<<E1000_MAX_TXD_PWR)
-
--static inline int
--iegbe_tx_map(struct iegbe_adapter *adapter, struct iegbe_tx_ring *tx_ring,
-- struct sk_buff *skb, unsigned int first, unsigned int max_per_txd,
-- unsigned int nr_frags, unsigned int mss)
-+static int iegbe_tx_map(struct iegbe_adapter *adapter,
-+ struct iegbe_tx_ring *tx_ring,
-+ struct sk_buff *skb, unsigned int first,
-+ unsigned int max_per_txd, unsigned int nr_frags,
-+ unsigned int mss)
- {
-- struct iegbe_buffer *buffer_info;
-- unsigned int len = skb->len;
-+ struct iegbe_hw *hw = &adapter->hw;
-+ struct iegbe_buffer *buffer_info;
-+ unsigned int len = skb->len;
- unsigned int offset = 0, size, count = 0, i;
--#ifdef MAX_SKB_FRAGS
-- unsigned int f;
-- len -= skb->data_len;
--#endif
-+ unsigned int f;
-+ len -= skb->data_len;
-
-- i = tx_ring->next_to_use;
-+ i = tx_ring->next_to_use;
-+
-+ while(len) {
-+ buffer_info = &tx_ring->buffer_info[i];
-+ size = min(len, max_per_txd);
-+ /* Workaround for Controller erratum --
-+ * descriptor for non-tso packet in a linear SKB that follows a
-+ * tso gets written back prematurely before the data is fully
-+ * DMA'd to the controller */
-+ if (!skb->data_len && tx_ring->last_tx_tso &&
-+ !skb_is_gso(skb)) {
-+ tx_ring->last_tx_tso = 0;
-+ size -= 4;
-+ }
-
-- while(len) {
-- buffer_info = &tx_ring->buffer_info[i];
-- size = min(len, max_per_txd);
--#ifdef NETIF_F_TSO
- /* Workaround for premature desc write-backs
- * in TSO mode. Append 4-byte sentinel desc */
-- if(unlikely(mss && !nr_frags && size == len && size > 0x8)) {
-- size -= 0x4;
-+ if (unlikely(mss && !nr_frags && size == len && size > 8))
-+ size -= 4;
-+ /* work-around for errata 10 and it applies
-+ * to all controllers in PCI-X mode
-+ * The fix is to make sure that the first descriptor of a
-+ * packet is smaller than 2048 - 16 - 16 (or 2016) bytes
-+ */
-+ if (unlikely((hw->bus_type == iegbe_bus_type_pcix) &&
-+ (size > 2015) && count == 0))
-+ size = 2015;
-+
-+ /* Workaround for potential 82544 hang in PCI-X. Avoid
-+ * terminating buffers within evenly-aligned dwords. */
-+ if(unlikely(adapter->pcix_82544 &&
-+ !((unsigned long)(skb->data + offset + size - 1) & 4) &&
-+ size > 4))
-+ size -= 4;
-+
-+ buffer_info->length = size;
-+ buffer_info->dma =
-+ pci_map_single(adapter->pdev,
-+ skb->data + offset,
-+ size,
-+ PCI_DMA_TODEVICE);
-+ buffer_info->time_stamp = jiffies;
-+ buffer_info->next_to_watch = i;
-+
-+ len -= size;
-+ offset += size;
-+ count++;
-+ if (unlikely(++i == tx_ring->count)) i = 0;
-+ }
-+
-+ for (f = 0; f < nr_frags; f++) {
-+ struct skb_frag_struct *frag;
-+
-+ frag = &skb_shinfo(skb)->frags[f];
-+ len = frag->size;
-+ offset = frag->page_offset;
-+
-+ while(len) {
-+ buffer_info = &tx_ring->buffer_info[i];
-+ size = min(len, max_per_txd);
-+ /* Workaround for premature desc write-backs
-+ * in TSO mode. Append 4-byte sentinel desc */
-+ if (unlikely(mss && f == (nr_frags-1) && size == len && size > 8))
-+ size -= 4;
-+ /* Workaround for potential 82544 hang in PCI-X.
-+ * Avoid terminating buffers within evenly-aligned
-+ * dwords. */
-+ if(unlikely(adapter->pcix_82544 &&
-+ !((unsigned long)(frag->page+offset+size-1) & 4) &&
-+ size > 4))
-+ size -= 4;
-+
-+ buffer_info->length = size;
-+ buffer_info->dma =
-+ pci_map_page(adapter->pdev,
-+ frag->page,
-+ offset,
-+ size,
-+ PCI_DMA_TODEVICE);
-+ buffer_info->time_stamp = jiffies;
-+ buffer_info->next_to_watch = i;
-+
-+ len -= size;
-+ offset += size;
-+ count++;
-+ if (unlikely(++i == tx_ring->count)) i = 0;
- }
--#endif
-- /* work-around for errata 10 and it applies
-- * to all controllers in PCI-X mode
-- * The fix is to make sure that the first descriptor of a
-- * packet is smaller than 2048 - 16 - 16 (or 2016) bytes
-- */
-- if(unlikely((adapter->hw.bus_type == iegbe_bus_type_pcix) &&
-- (size > 0x7df) && count == 0)) {
-- size = 0x7df;
-- }
-- /* Workaround for potential 82544 hang in PCI-X. Avoid
-- * terminating buffers within evenly-aligned dwords. */
-- if(unlikely(adapter->pcix_82544 &&
-- !((unsigned long)(skb->data + offset + size - 0x8) & 0x4) &&
-- size > 0x4)) {
-- size -= 0x4;
-- }
-- buffer_info->length = size;
-- buffer_info->dma =
-- pci_map_single(adapter->pdev,
-- skb->data + offset,
-- size,
-- PCI_DMA_TODEVICE);
-- buffer_info->time_stamp = jiffies;
--
-- len -= size;
-- offset += size;
-- count++;
-- if(unlikely(++i == tx_ring->count)) { i = 0; }
-- }
--
--#ifdef MAX_SKB_FRAGS
-- for(f = 0; f < nr_frags; f++) {
-- struct skb_frag_struct *frag;
--
-- frag = &skb_shinfo(skb)->frags[f];
-- len = frag->size;
-- offset = frag->page_offset;
--
-- while(len) {
-- buffer_info = &tx_ring->buffer_info[i];
-- size = min(len, max_per_txd);
--#ifdef NETIF_F_TSO
-- /* Workaround for premature desc write-backs
-- * in TSO mode. Append 4-byte sentinel desc */
-- if(unlikely(mss && f == (nr_frags-0x1) &&
-- size == len && size > 0x8)) {
-- size -= 0x4;
-- }
--#endif
-- /* Workaround for potential 82544 hang in PCI-X.
-- * Avoid terminating buffers within evenly-aligned
-- * dwords. */
-- if(unlikely(adapter->pcix_82544 &&
-- !((unsigned long)(frag->page+offset+size-0x1) & 0x4) &&
-- size > 0x4)) {
-- size -= 0x4;
-- }
-- buffer_info->length = size;
-- buffer_info->dma =
-- pci_map_page(adapter->pdev,
-- frag->page,
-- offset,
-- size,
-- PCI_DMA_TODEVICE);
-- buffer_info->time_stamp = jiffies;
--
-- len -= size;
-- offset += size;
-- count++;
-- if(unlikely(++i == tx_ring->count)) { i = 0; }
-- }
-- }
--#endif
-+ }
-
-- i = (i == 0) ? tx_ring->count - 0x1 : i - 0x1;
-- tx_ring->buffer_info[i].skb = skb;
-- tx_ring->buffer_info[first].next_to_watch = i;
-+ i = (i == 0) ? tx_ring->count - 1 : i - 1;
-+ tx_ring->buffer_info[i].skb = skb;
-+ tx_ring->buffer_info[first].next_to_watch = i;
-
-- return count;
-+ return count;
- }
-
--static inline void
--iegbe_tx_queue(struct iegbe_adapter *adapter, struct iegbe_tx_ring *tx_ring,
-- int tx_flags, int count)
-+static void iegbe_tx_queue(struct iegbe_adapter *adapter,
-+ struct iegbe_tx_ring *tx_ring, int tx_flags,
-+ int count)
- {
-+ struct iegbe_hw *hw = &adapter->hw;
- struct iegbe_tx_desc *tx_desc = NULL;
- struct iegbe_buffer *buffer_info;
-- uint32_t txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
-+ u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
- unsigned int i;
-
-- if(likely(tx_flags & E1000_TX_FLAGS_TSO)) {
-+ if (likely(tx_flags & E1000_TX_FLAGS_TSO)) {
- txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
- E1000_TXD_CMD_TSE;
-- txd_upper |= E1000_TXD_POPTS_TXSM << 0x8;
-+ txd_upper |= E1000_TXD_POPTS_TXSM << 8;
-
-- if(likely(tx_flags & E1000_TX_FLAGS_IPV4)) {
-- txd_upper |= E1000_TXD_POPTS_IXSM << 0x8;
-- }
-+ if (likely(tx_flags & E1000_TX_FLAGS_IPV4))
-+ txd_upper |= E1000_TXD_POPTS_IXSM << 8;
- }
-
-- if(likely(tx_flags & E1000_TX_FLAGS_CSUM)) {
-+ if (likely(tx_flags & E1000_TX_FLAGS_CSUM)) {
- txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
-- txd_upper |= E1000_TXD_POPTS_TXSM << 0x8;
-- }
--
-- if(unlikely(tx_flags & E1000_TX_FLAGS_VLAN)) {
-- txd_lower |= E1000_TXD_CMD_VLE;
-- txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
-+ txd_upper |= E1000_TXD_POPTS_TXSM << 8;
- }
-
-- i = tx_ring->next_to_use;
-+ if(unlikely(tx_flags & E1000_TX_FLAGS_VLAN)) {
-+ txd_lower |= E1000_TXD_CMD_VLE;
-+ txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
-+ }
-
-- while(count--) {
-- buffer_info = &tx_ring->buffer_info[i];
-- tx_desc = E1000_TX_DESC(*tx_ring, i);
-- tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
-- tx_desc->lower.data =
-- cpu_to_le32(txd_lower | buffer_info->length);
-- tx_desc->upper.data = cpu_to_le32(txd_upper);
-- if(unlikely(++i == tx_ring->count)) { i = 0; }
-- }
-- if(tx_desc != NULL) {
-- tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
-- }
-- /* Force memory writes to complete before letting h/w
-- * know there are new descriptors to fetch. (Only
-- * applicable for weak-ordered memory model archs,
-- * such as IA-64). */
-- wmb();
-+ i = tx_ring->next_to_use;
-
-- tx_ring->next_to_use = i;
-- writel(i, adapter->hw.hw_addr + tx_ring->tdt);
-+ while(count--) {
-+ buffer_info = &tx_ring->buffer_info[i];
-+ tx_desc = E1000_TX_DESC(*tx_ring, i);
-+ tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
-+ tx_desc->lower.data =
-+ cpu_to_le32(txd_lower | buffer_info->length);
-+ tx_desc->upper.data = cpu_to_le32(txd_upper);
-+ if (unlikely(++i == tx_ring->count)) i = 0;
-+ }
-+
-+ tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
-+
-+ /* Force memory writes to complete before letting h/w
-+ * know there are new descriptors to fetch. (Only
-+ * applicable for weak-ordered memory model archs,
-+ * such as IA-64). */
-+ wmb();
-+
-+ tx_ring->next_to_use = i;
-+ writel(i, hw->hw_addr + tx_ring->tdt);
-+ /* we need this if more than one processor can write to our tail
-+ * at a time, it syncronizes IO on IA64/Altix systems */
-+ mmiowb();
- }
-
- /**
-@@ -2950,113 +2925,132 @@ iegbe_tx_queue(struct iegbe_adapter *ada
- * to the beginning of the Tx FIFO.
- **/
-
--static inline int
--iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter, struct sk_buff *skb)
-+#define E1000_FIFO_HDR 0x10
-+#define E1000_82547_PAD_LEN 0x3E0
-+static int iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter,
-+ struct sk_buff *skb)
- {
-- uint32_t fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head;
-- uint32_t skb_fifo_len = skb->len + E1000_FIFO_HDR;
-+ u32 fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head;
-+ u32 skb_fifo_len = skb->len + E1000_FIFO_HDR;
-
-- E1000_ROUNDUP(skb_fifo_len, E1000_FIFO_HDR);
-+ skb_fifo_len = ALIGN(skb_fifo_len, E1000_FIFO_HDR);
-
-- if(adapter->link_duplex != HALF_DUPLEX) {
-- goto no_fifo_stall_required;
-- }
-- if(atomic_read(&adapter->tx_fifo_stall)) {
-- return 1;
-+ if (adapter->link_duplex != HALF_DUPLEX)
-+ goto no_fifo_stall_required;
-+
-+ if (atomic_read(&adapter->tx_fifo_stall))
-+ return 1;
-+
-+ if(skb_fifo_len >= (E1000_82547_PAD_LEN + fifo_space)) {
-+ atomic_set(&adapter->tx_fifo_stall, 1);
-+ return 1;
- }
-- if(skb_fifo_len >= (E1000_82547_PAD_LEN + fifo_space)) {
-- atomic_set(&adapter->tx_fifo_stall, 0x1);
-- return 1;
-- }
-
- no_fifo_stall_required:
-- adapter->tx_fifo_head += skb_fifo_len;
-- if(adapter->tx_fifo_head >= adapter->tx_fifo_size) {
-- adapter->tx_fifo_head -= adapter->tx_fifo_size;
-- }
-+ adapter->tx_fifo_head += skb_fifo_len;
-+ if (adapter->tx_fifo_head >= adapter->tx_fifo_size)
-+ adapter->tx_fifo_head -= adapter->tx_fifo_size;
- return 0;
- }
-
--static inline int
--iegbe_transfer_dhcp_info(struct iegbe_adapter *adapter, struct sk_buff *skb)
-+#define MINIMUM_DHCP_PACKET_SIZE 282
-+static int iegbe_transfer_dhcp_info(struct iegbe_adapter *adapter,
-+ struct sk_buff *skb)
- {
- struct iegbe_hw *hw = &adapter->hw;
-- uint16_t length, offset;
--#ifdef NETIF_F_HW_VLAN_TX
-- if(vlan_tx_tag_present(skb)) {
-- if(!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) &&
-- ( adapter->hw.mng_cookie.status &
-- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) ) {
-+ u16 length, offset;
-+ if (vlan_tx_tag_present(skb)) {
-+ if (!((vlan_tx_tag_get(skb) == hw->mng_cookie.vlan_id) &&
-+ ( hw->mng_cookie.status &
-+ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
- return 0;
- }
-- }
--#endif
-- if(htons(ETH_P_IP) == skb->protocol) {
-- const struct iphdr *ip = skb->nh.iph;
-- if(IPPROTO_UDP == ip->protocol) {
-- struct udphdr *udp = (struct udphdr *)(skb->h.uh);
-- if(ntohs(udp->dest) == 0x43) { /* 0x43 = 67 */
-- offset = (uint8_t *)udp + 0x8 - skb->data;
-- length = skb->len - offset;
--
-- return iegbe_mng_write_dhcp_info(hw,
-- (uint8_t *)udp + 0x8, length);
-- }
-- }
-- } else if((skb->len > MINIMUM_DHCP_PACKET_SIZE) && (!skb->protocol)) {
-- struct ethhdr *eth = (struct ethhdr *) skb->data;
-- if((htons(ETH_P_IP) == eth->h_proto)) {
-+ if (skb->len > MINIMUM_DHCP_PACKET_SIZE) {
-+ struct ethhdr *eth = (struct ethhdr *)skb->data;
-+ if ((htons(ETH_P_IP) == eth->h_proto)) {
- const struct iphdr *ip =
-- (struct iphdr *)((uint8_t *)skb->data+0xe);
-- if(IPPROTO_UDP == ip->protocol) {
-+ (struct iphdr *)((u8 *)skb->data+14);
-+ if (IPPROTO_UDP == ip->protocol) {
- struct udphdr *udp =
-- (struct udphdr *)((uint8_t *)ip +
-- (ip->ihl << 0x2));
-- if(ntohs(udp->dest) == 0x43) {
-- offset = (uint8_t *)udp + 0x8 - skb->data;
-+ (struct udphdr *)((u8 *)ip +
-+ (ip->ihl << 2));
-+ if (ntohs(udp->dest) == 67) {
-+ offset = (u8 *)udp + 8 - skb->data;
- length = skb->len - offset;
-
- return iegbe_mng_write_dhcp_info(hw,
-- (uint8_t *)udp + 0x8,
-+ (u8 *)udp + 8,
- length);
-- }
-+ }
- }
- }
- }
- return 0;
- }
-
--static int
--iegbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
-+static int __iegbe_maybe_stop_tx(struct net_device *netdev, int size)
-+{
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ struct iegbe_tx_ring *tx_ring = adapter->tx_ring;
-+
-+ netif_stop_queue(netdev);
-+ /* Herbert's original patch had:
-+ * smp_mb__after_netif_stop_queue();
-+ * but since that doesn't exist yet, just open code it. */
-+ smp_mb();
-+
-+ /* We need to check again in a case another CPU has just
-+ * made room available. */
-+ if (likely(E1000_DESC_UNUSED(tx_ring) < size))
-+ return -EBUSY;
-+
-+ /* A reprieve! */
-+ netif_start_queue(netdev);
-+ ++adapter->restart_queue;
-+ return 0;
-+}
-+
-+static int iegbe_maybe_stop_tx(struct net_device *netdev,
-+ struct iegbe_tx_ring *tx_ring, int size)
-+{
-+ if (likely(E1000_DESC_UNUSED(tx_ring) >= size))
-+ return 0;
-+ return __iegbe_maybe_stop_tx(netdev, size);
-+}
-+
-+#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
-+static int iegbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
- {
- struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ struct iegbe_hw *hw = &adapter->hw;
- struct iegbe_tx_ring *tx_ring;
- unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD;
- unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
- unsigned int tx_flags = 0;
-- unsigned int len = skb->len;
-+ unsigned int len = skb->len - skb->data_len;
- unsigned long flags = 0;
-- unsigned int nr_frags = 0;
-- unsigned int mss = 0;
-+ unsigned int nr_frags;
-+ unsigned int mss;
- int count = 0;
-- int tso;
--#ifdef MAX_SKB_FRAGS
-+ int tso;
- unsigned int f;
-- len -= skb->data_len;
--#endif
-
--#ifdef CONFIG_E1000_MQ
-- tx_ring = *per_cpu_ptr(adapter->cpu_tx_ring, smp_processor_id());
--#else
-+ /* This goes back to the question of how to logically map a tx queue
-+ * to a flow. Right now, performance is impacted slightly negatively
-+ * if using multiple tx queues. If the stack breaks away from a
-+ * single qdisc implementation, we can look at this again. */
- tx_ring = adapter->tx_ring;
--#endif
-
- if (unlikely(skb->len <= 0)) {
- dev_kfree_skb_any(skb);
- return NETDEV_TX_OK;
- }
-
--#ifdef NETIF_F_TSO
-+ /* 82571 and newer doesn't need the workaround that limited descriptor
-+ * length to 4kB */
-+ if (hw->mac_type >= iegbe_82571)
-+ max_per_txd = 8192;
-+
- mss = skb_shinfo(skb)->gso_size;
- /* The controller does a simple calculation to
- * make sure there is enough room in the FIFO before
-@@ -3064,164 +3058,150 @@ iegbe_xmit_frame(struct sk_buff *skb, st
- * 4 = ceil(buffer len/mss). To make sure we don't
- * overrun the FIFO, adjust the max buffer len if mss
- * drops. */
-- if(mss) {
-- max_per_txd = min(mss << 0x2, max_per_txd);
-- max_txd_pwr = fls(max_per_txd) - 0x1;
-+ if (mss) {
-+ u8 hdr_len;
-+ max_per_txd = min(mss << 2, max_per_txd);
-+ max_txd_pwr = fls(max_per_txd) - 1;
-+
-+ /* TSO Workaround for 82571/2/3 Controllers -- if skb->data
-+ * points to just header, pull a few bytes of payload from
-+ * frags into skb->data */
-+ hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
-+ if (skb->data_len && hdr_len == len) {
-+ switch (hw->mac_type) {
-+ case iegbe_82544:
-+ /* Make sure we have room to chop off 4 bytes,
-+ * and that the end alignment will work out to
-+ * this hardware's requirements
-+ * NOTE: this is a TSO only workaround
-+ * if end byte alignment not correct move us
-+ * into the next dword */
-+ break;
-+ /* fall through */
-+ case iegbe_82571:
-+ case iegbe_82572:
-+ case iegbe_82573:
-+ break;
-+ default:
-+ /* do nothing */
-+ break;
-+ }
-+ }
- }
-
-- if((mss) || (skb->ip_summed == CHECKSUM_HW)) {
-+ /* reserve a descriptor for the offload context */
-+ if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL))
- count++;
-- }
- count++;
--#else
-- if(skb->ip_summed == CHECKSUM_HW) {
-+
-+ /* Controller Erratum workaround */
-+ if (!skb->data_len && tx_ring->last_tx_tso && !skb_is_gso(skb))
- count++;
-- {
--#endif
-+
- count += TXD_USE_COUNT(len, max_txd_pwr);
-
-- if(adapter->pcix_82544) {
-+ if (adapter->pcix_82544)
- count++;
-- }
-+
- /* work-around for errata 10 and it applies to all controllers
- * in PCI-X mode, so add one more descriptor to the count
- */
-- if(unlikely((adapter->hw.bus_type == iegbe_bus_type_pcix) &&
-- (len > 0x7df))) {
-+ if (unlikely((hw->bus_type == iegbe_bus_type_pcix) &&
-+ (len > 2015)))
- count++;
-- }
--#ifdef MAX_SKB_FRAGS
-+
- nr_frags = skb_shinfo(skb)->nr_frags;
-- for(f = 0; f < nr_frags; f++)
-+ for (f = 0; f < nr_frags; f++)
- count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
- max_txd_pwr);
-- if(adapter->pcix_82544) {
-+ if (adapter->pcix_82544)
- count += nr_frags;
-- }
--#ifdef NETIF_F_TSO
-- /* TSO Workaround for 82571/2 Controllers -- if skb->data
-- * points to just header, pull a few bytes of payload from
-- * frags into skb->data */
-- if (skb_is_gso(skb)) {
-- uint8_t hdr_len;
-- hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 0x2));
-- if (skb->data_len && (hdr_len < (skb->len - skb->data_len)) &&
-- (adapter->hw.mac_type == iegbe_82571 ||
-- adapter->hw.mac_type == iegbe_82572)) {
-- unsigned int pull_size;
-- pull_size = min((unsigned int)0x4, skb->data_len);
-- if (!__pskb_pull_tail(skb, pull_size)) {
-- printk(KERN_ERR "__pskb_pull_tail failed.\n");
-- dev_kfree_skb_any(skb);
-- return -EFAULT;
-- }
-- }
-- }
--#endif
--#endif
-
-- if(adapter->hw.tx_pkt_filtering && (adapter->hw.mac_type == iegbe_82573) ) {
-+
-+ if (hw->tx_pkt_filtering &&
-+ (hw->mac_type == iegbe_82573))
- iegbe_transfer_dhcp_info(adapter, skb);
-- }
--#ifdef NETIF_F_LLTX
-- local_irq_save(flags);
-- if (!spin_trylock(&tx_ring->tx_lock)) {
-+
-+ if (!spin_trylock_irqsave(&tx_ring->tx_lock, flags))
- /* Collision - tell upper layer to requeue */
-- local_irq_restore(flags);
- return NETDEV_TX_LOCKED;
-- }
--#else
-- spin_lock_irqsave(&tx_ring->tx_lock, flags);
--#endif
-
- /* need: count + 2 desc gap to keep tail from touching
- * head, otherwise try next time */
-- if (unlikely(E1000_DESC_UNUSED(tx_ring) < count + 0x2)) {
-- netif_stop_queue(netdev);
-+ if (unlikely(iegbe_maybe_stop_tx(netdev, tx_ring, count + 2))) {
- spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
- return NETDEV_TX_BUSY;
- }
-
-- if(unlikely(adapter->hw.mac_type == iegbe_82547)) {
-- if(unlikely(iegbe_82547_fifo_workaround(adapter, skb))) {
-+ if (unlikely(hw->mac_type == iegbe_82547)) {
-+ if (unlikely(iegbe_82547_fifo_workaround(adapter, skb))) {
- netif_stop_queue(netdev);
-- mod_timer(&adapter->tx_fifo_stall_timer, jiffies);
-+ mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
- spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
- return NETDEV_TX_BUSY;
- }
- }
-
--#ifndef NETIF_F_LLTX
-- spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
--#endif
--
--#ifdef NETIF_F_HW_VLAN_TX
-- if(unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
-+ if (unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
- tx_flags |= E1000_TX_FLAGS_VLAN;
- tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
- }
--#endif
-
- first = tx_ring->next_to_use;
-
- tso = iegbe_tso(adapter, tx_ring, skb);
- if (tso < 0) {
- dev_kfree_skb_any(skb);
--#ifdef NETIF_F_LLTX
- spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
--#endif
- return NETDEV_TX_OK;
- }
-
-- if (likely(tso)) {
-+ if (likely(tso)) {
-+ tx_ring->last_tx_tso = 1;
- tx_flags |= E1000_TX_FLAGS_TSO;
-- } else if (likely(iegbe_tx_csum(adapter, tx_ring, skb))) {
-+ } else if (likely(iegbe_tx_csum(adapter, tx_ring, skb)))
- tx_flags |= E1000_TX_FLAGS_CSUM;
-- }
-+
- /* Old method was to assume IPv4 packet by default if TSO was enabled.
- * 82571 hardware supports TSO capabilities for IPv6 as well...
- * no longer assume, we must. */
-- if (likely(skb->protocol == ntohs(ETH_P_IP))) {
-+ if (likely(skb->protocol == htons(ETH_P_IP)))
- tx_flags |= E1000_TX_FLAGS_IPV4;
-- }
-+
- iegbe_tx_queue(adapter, tx_ring, tx_flags,
- iegbe_tx_map(adapter, tx_ring, skb, first,
- max_per_txd, nr_frags, mss));
-
- netdev->trans_start = jiffies;
-
--#ifdef NETIF_F_LLTX
- /* Make sure there is space in the ring for the next send. */
-- if (unlikely(E1000_DESC_UNUSED(tx_ring) < MAX_SKB_FRAGS + 0x2)) {
-- netif_stop_queue(netdev);
-- }
-- spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
--#endif
-+ iegbe_maybe_stop_tx(netdev, tx_ring, MAX_SKB_FRAGS + 2);
-
-+ spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
- return NETDEV_TX_OK;
- }
-
-+
- /**
- * iegbe_tx_timeout - Respond to a Tx Hang
- * @netdev: network interface device structure
- **/
-
--static void
--iegbe_tx_timeout(struct net_device *netdev)
-+static void iegbe_tx_timeout(struct net_device *netdev)
- {
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-
-- /* Do the reset outside of interrupt context */
-- schedule_work(&adapter->tx_timeout_task);
-+ /* Do the reset outside of interrupt context */
-+ adapter->tx_timeout_count++;
-+ schedule_work(&adapter->reset_task);
- }
-
--static void
--iegbe_tx_timeout_task(struct net_device *netdev)
-+static void iegbe_reset_task(struct work_struct *work)
- {
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ struct iegbe_adapter *adapter =
-+ container_of(work, struct iegbe_adapter, reset_task);
-
-- iegbe_down(adapter);
-- iegbe_up(adapter);
-+ iegbe_reinit_locked(adapter);
- }
-
- /**
-@@ -3232,13 +3212,12 @@ iegbe_tx_timeout_task(struct net_device
- * The statistics are actually updated from the timer callback.
- **/
-
--static struct net_device_stats *
--iegbe_get_stats(struct net_device *netdev)
-+static struct net_device_stats *iegbe_get_stats(struct net_device *netdev)
- {
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-
-- iegbe_update_stats(adapter);
-- return &adapter->net_stats;
-+ /* only return the current stats */
-+ return &adapter->net_stats;
- }
-
- /**
-@@ -3249,67 +3228,55 @@ iegbe_get_stats(struct net_device *netde
- * Returns 0 on success, negative on failure
- **/
-
--static int
--iegbe_change_mtu(struct net_device *netdev, int new_mtu)
-+static int iegbe_change_mtu(struct net_device *netdev, int new_mtu)
- {
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-- int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ struct iegbe_hw *hw = &adapter->hw;
-+ int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
-
-- if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
-- (max_frame > MAX_JUMBO_FRAME_SIZE)) {
-- DPRINTK(PROBE, ERR, "Invalid MTU setting\n");
-- return -EINVAL;
-- }
-+ if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
-+ (max_frame > MAX_JUMBO_FRAME_SIZE)) {
-+ DPRINTK(PROBE, ERR, "Invalid MTU setting\n");
-+ return -EINVAL;
-+ }
-
-+ /* Adapter-specific max frame size limits. */
-+ switch (hw->mac_type) {
-+ case iegbe_undefined ... iegbe_82542_rev2_1:
-+ if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
-+ DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n");
-+ return -EINVAL;
-+ }
-+ break;
-+ case iegbe_82571:
-+ case iegbe_82572:
- #define MAX_STD_JUMBO_FRAME_SIZE 9234
-- /* might want this to be bigger enum check... */
-- /* 82571 controllers limit jumbo frame size to 10500 bytes */
-- if ((adapter->hw.mac_type == iegbe_82571 ||
-- adapter->hw.mac_type == iegbe_82572) &&
-- max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
-- DPRINTK(PROBE, ERR, "MTU > 9216 bytes not supported "
-- "on 82571 and 82572 controllers.\n");
-- return -EINVAL;
-- }
--
-- if(adapter->hw.mac_type == iegbe_82573 &&
-- max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
-- DPRINTK(PROBE, ERR, "Jumbo Frames not supported "
-- "on 82573\n");
-- return -EINVAL;
-- }
--
-- if(adapter->hw.mac_type > iegbe_82547_rev_2) {
-- adapter->rx_buffer_len = max_frame;
-- E1000_ROUNDUP(adapter->rx_buffer_len, 0x1024);
-- } else {
-- if(unlikely((adapter->hw.mac_type < iegbe_82543) &&
-- (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE))) {
-- DPRINTK(PROBE, ERR, "Jumbo Frames not supported "
-- "on 82542\n");
-- return -EINVAL;
--
-- } else {
-- if(max_frame <= E1000_RXBUFFER_2048) {
-- adapter->rx_buffer_len = E1000_RXBUFFER_2048;
-- } else if(max_frame <= E1000_RXBUFFER_4096) {
-- adapter->rx_buffer_len = E1000_RXBUFFER_4096;
-- } else if(max_frame <= E1000_RXBUFFER_8192) {
-- adapter->rx_buffer_len = E1000_RXBUFFER_8192;
-- } else if(max_frame <= E1000_RXBUFFER_16384) {
-- adapter->rx_buffer_len = E1000_RXBUFFER_16384;
-- }
-+ if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
-+ DPRINTK(PROBE, ERR, "MTU > 9216 not supported.\n");
-+ return -EINVAL;
- }
-+ break;
-+ default:
-+ break;
- }
-+ if (max_frame <= E1000_RXBUFFER_256)
-+ adapter->rx_buffer_len = E1000_RXBUFFER_256;
-+ else if (max_frame <= E1000_RXBUFFER_2048)
-+ adapter->rx_buffer_len = E1000_RXBUFFER_2048;
-+ else if (max_frame <= E1000_RXBUFFER_4096)
-+ adapter->rx_buffer_len = E1000_RXBUFFER_4096;
-+ else if (max_frame <= E1000_RXBUFFER_8192)
-+ adapter->rx_buffer_len = E1000_RXBUFFER_8192;
-+ else if (max_frame <= E1000_RXBUFFER_16384)
-+ adapter->rx_buffer_len = E1000_RXBUFFER_16384;
-
-- netdev->mtu = new_mtu;
-+ /* adjust allocation if LPE protects us, and we aren't using SBP */
-
-- if(netif_running(netdev)) {
-- iegbe_down(adapter);
-- iegbe_up(adapter);
-- }
-+ netdev->mtu = new_mtu;
-+ hw->max_frame_size = max_frame;
-
-- adapter->hw.max_frame_size = max_frame;
-+ if (netif_running(netdev))
-+ iegbe_reinit_locked(adapter);
-
- return 0;
- }
-@@ -3319,224 +3286,189 @@ iegbe_change_mtu(struct net_device *netd
- * @adapter: board private structure
- **/
-
--void
--iegbe_update_stats(struct iegbe_adapter *adapter)
-+void iegbe_update_stats(struct iegbe_adapter *adapter)
- {
-- struct iegbe_hw *hw = &adapter->hw;
-- unsigned long flags = 0;
-- uint16_t phy_tmp;
-+ struct iegbe_hw *hw = &adapter->hw;
-+ unsigned long flags = 0x0;
-+ uint16_t phy_tmp;
-
- #define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
-
-- spin_lock_irqsave(&adapter->stats_lock, flags);
-+ spin_lock_irqsave(&adapter->stats_lock, flags);
-
-- /* these counters are modified from iegbe_adjust_tbi_stats,
-- * called from the interrupt context, so they must only
-- * be written while holding adapter->stats_lock
-- */
-+ /* these counters are modified from iegbe_adjust_tbi_stats,
-+ * called from the interrupt context, so they must only
-+ * be written while holding adapter->stats_lock
-+ */
-
-- adapter->stats.crcerrs += E1000_READ_REG(hw, CRCERRS);
-- adapter->stats.gprc += E1000_READ_REG(hw, GPRC);
-- adapter->stats.gorcl += E1000_READ_REG(hw, GORCL);
-- adapter->stats.gorch += E1000_READ_REG(hw, GORCH);
-- adapter->stats.bprc += E1000_READ_REG(hw, BPRC);
-- adapter->stats.mprc += E1000_READ_REG(hw, MPRC);
-- adapter->stats.roc += E1000_READ_REG(hw, ROC);
-- adapter->stats.prc64 += E1000_READ_REG(hw, PRC64);
-- adapter->stats.prc127 += E1000_READ_REG(hw, PRC127);
-- adapter->stats.prc255 += E1000_READ_REG(hw, PRC255);
-- adapter->stats.prc511 += E1000_READ_REG(hw, PRC511);
-- adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023);
-- adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522);
--
-- adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS);
-- adapter->stats.mpc += E1000_READ_REG(hw, MPC);
-- adapter->stats.scc += E1000_READ_REG(hw, SCC);
-- adapter->stats.ecol += E1000_READ_REG(hw, ECOL);
-- adapter->stats.mcc += E1000_READ_REG(hw, MCC);
-- adapter->stats.latecol += E1000_READ_REG(hw, LATECOL);
-- adapter->stats.dc += E1000_READ_REG(hw, DC);
-- adapter->stats.sec += E1000_READ_REG(hw, SEC);
-- adapter->stats.rlec += E1000_READ_REG(hw, RLEC);
-- adapter->stats.xonrxc += E1000_READ_REG(hw, XONRXC);
-- adapter->stats.xontxc += E1000_READ_REG(hw, XONTXC);
-- adapter->stats.xoffrxc += E1000_READ_REG(hw, XOFFRXC);
-- adapter->stats.xofftxc += E1000_READ_REG(hw, XOFFTXC);
-- adapter->stats.fcruc += E1000_READ_REG(hw, FCRUC);
-- adapter->stats.gptc += E1000_READ_REG(hw, GPTC);
-- adapter->stats.gotcl += E1000_READ_REG(hw, GOTCL);
-- adapter->stats.gotch += E1000_READ_REG(hw, GOTCH);
-- adapter->stats.rnbc += E1000_READ_REG(hw, RNBC);
-- adapter->stats.ruc += E1000_READ_REG(hw, RUC);
-- adapter->stats.rfc += E1000_READ_REG(hw, RFC);
-- adapter->stats.rjc += E1000_READ_REG(hw, RJC);
-- adapter->stats.torl += E1000_READ_REG(hw, TORL);
-- adapter->stats.torh += E1000_READ_REG(hw, TORH);
-- adapter->stats.totl += E1000_READ_REG(hw, TOTL);
-- adapter->stats.toth += E1000_READ_REG(hw, TOTH);
-- adapter->stats.tpr += E1000_READ_REG(hw, TPR);
-- adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64);
-- adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127);
-- adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255);
-- adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511);
-- adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023);
-- adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522);
-- adapter->stats.mptc += E1000_READ_REG(hw, MPTC);
-- adapter->stats.bptc += E1000_READ_REG(hw, BPTC);
--
-- /* used for adaptive IFS */
--
-- hw->tx_packet_delta = E1000_READ_REG(hw, TPT);
-- adapter->stats.tpt += hw->tx_packet_delta;
-- hw->collision_delta = E1000_READ_REG(hw, COLC);
-- adapter->stats.colc += hw->collision_delta;
--
-- if(hw->mac_type >= iegbe_82543) {
-- adapter->stats.algnerrc += E1000_READ_REG(hw, ALGNERRC);
-- adapter->stats.rxerrc += E1000_READ_REG(hw, RXERRC);
-- adapter->stats.tncrs += E1000_READ_REG(hw, TNCRS);
-- adapter->stats.cexterr += E1000_READ_REG(hw, CEXTERR);
-- adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC);
-- adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC);
-- }
-- if(hw->mac_type > iegbe_82547_rev_2) {
-- adapter->stats.iac += E1000_READ_REG(hw, IAC);
-- adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC);
-- adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC);
-- adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC);
-- adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC);
-- adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC);
-- adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC);
-- adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC);
-- adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC);
-- }
--
-- /* Fill out the OS statistics structure */
--
-- adapter->net_stats.rx_packets = adapter->stats.gprc;
-- adapter->net_stats.tx_packets = adapter->stats.gptc;
-- adapter->net_stats.rx_bytes = adapter->stats.gorcl;
-- adapter->net_stats.tx_bytes = adapter->stats.gotcl;
-- adapter->net_stats.multicast = adapter->stats.mprc;
-- adapter->net_stats.collisions = adapter->stats.colc;
--
-- /* Rx Errors */
--
-- adapter->net_stats.rx_errors = adapter->stats.rxerrc +
-- adapter->stats.crcerrs + adapter->stats.algnerrc +
-- adapter->stats.rlec + adapter->stats.mpc +
-- adapter->stats.cexterr;
-- adapter->net_stats.rx_dropped = adapter->stats.mpc;
-- adapter->net_stats.rx_length_errors = adapter->stats.rlec;
-- adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
-- adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
-- adapter->net_stats.rx_fifo_errors = adapter->stats.mpc;
-- adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
--
-- /* Tx Errors */
--
-- adapter->net_stats.tx_errors = adapter->stats.ecol +
-- adapter->stats.latecol;
-- adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
-- adapter->net_stats.tx_window_errors = adapter->stats.latecol;
-- adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
-+ adapter->stats.crcerrs += E1000_READ_REG(hw, CRCERRS);
-+ adapter->stats.gprc += E1000_READ_REG(hw, GPRC);
-+ adapter->stats.gorcl += E1000_READ_REG(hw, GORCL);
-+ adapter->stats.gorch += E1000_READ_REG(hw, GORCH);
-+ adapter->stats.bprc += E1000_READ_REG(hw, BPRC);
-+ adapter->stats.mprc += E1000_READ_REG(hw, MPRC);
-+ adapter->stats.roc += E1000_READ_REG(hw, ROC);
-+ adapter->stats.prc64 += E1000_READ_REG(hw, PRC64);
-+ adapter->stats.prc127 += E1000_READ_REG(hw, PRC127);
-+ adapter->stats.prc255 += E1000_READ_REG(hw, PRC255);
-+ adapter->stats.prc511 += E1000_READ_REG(hw, PRC511);
-+ adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023);
-+ adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522);
-+
-+ adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS);
-+ adapter->stats.mpc += E1000_READ_REG(hw, MPC);
-+ adapter->stats.scc += E1000_READ_REG(hw, SCC);
-+ adapter->stats.ecol += E1000_READ_REG(hw, ECOL);
-+ adapter->stats.mcc += E1000_READ_REG(hw, MCC);
-+ adapter->stats.latecol += E1000_READ_REG(hw, LATECOL);
-+ adapter->stats.dc += E1000_READ_REG(hw, DC);
-+ adapter->stats.sec += E1000_READ_REG(hw, SEC);
-+ adapter->stats.rlec += E1000_READ_REG(hw, RLEC);
-+ adapter->stats.xonrxc += E1000_READ_REG(hw, XONRXC);
-+ adapter->stats.xontxc += E1000_READ_REG(hw, XONTXC);
-+ adapter->stats.xoffrxc += E1000_READ_REG(hw, XOFFRXC);
-+ adapter->stats.xofftxc += E1000_READ_REG(hw, XOFFTXC);
-+ adapter->stats.fcruc += E1000_READ_REG(hw, FCRUC);
-+ adapter->stats.gptc += E1000_READ_REG(hw, GPTC);
-+ adapter->stats.gotcl += E1000_READ_REG(hw, GOTCL);
-+ adapter->stats.gotch += E1000_READ_REG(hw, GOTCH);
-+ adapter->stats.rnbc += E1000_READ_REG(hw, RNBC);
-+ adapter->stats.ruc += E1000_READ_REG(hw, RUC);
-+ adapter->stats.rfc += E1000_READ_REG(hw, RFC);
-+ adapter->stats.rjc += E1000_READ_REG(hw, RJC);
-+ adapter->stats.torl += E1000_READ_REG(hw, TORL);
-+ adapter->stats.torh += E1000_READ_REG(hw, TORH);
-+ adapter->stats.totl += E1000_READ_REG(hw, TOTL);
-+ adapter->stats.toth += E1000_READ_REG(hw, TOTH);
-+ adapter->stats.tpr += E1000_READ_REG(hw, TPR);
-+ adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64);
-+ adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127);
-+ adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255);
-+ adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511);
-+ adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023);
-+ adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522);
-+ adapter->stats.mptc += E1000_READ_REG(hw, MPTC);
-+ adapter->stats.bptc += E1000_READ_REG(hw, BPTC);
-+
-+ /* used for adaptive IFS */
-+
-+ hw->tx_packet_delta = E1000_READ_REG(hw, TPT);
-+ adapter->stats.tpt += hw->tx_packet_delta;
-+ hw->collision_delta = E1000_READ_REG(hw, COLC);
-+ adapter->stats.colc += hw->collision_delta;
-+
-+ if(hw->mac_type >= iegbe_82543) {
-+ adapter->stats.algnerrc += E1000_READ_REG(hw, ALGNERRC);
-+ adapter->stats.rxerrc += E1000_READ_REG(hw, RXERRC);
-+ adapter->stats.tncrs += E1000_READ_REG(hw, TNCRS);
-+ adapter->stats.cexterr += E1000_READ_REG(hw, CEXTERR);
-+ adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC);
-+ adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC);
-+ }
-+ if(hw->mac_type > iegbe_82547_rev_2) {
-+ adapter->stats.iac += E1000_READ_REG(hw, IAC);
-+ adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC);
-+ adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC);
-+ adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC);
-+ adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC);
-+ adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC);
-+ adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC);
-+ adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC);
-+ adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC);
-+ }
-+
-+ /* Fill out the OS statistics structure */
-+
-+ adapter->net_stats.rx_packets = adapter->stats.gprc;
-+ adapter->net_stats.tx_packets = adapter->stats.gptc;
-+ adapter->net_stats.rx_bytes = adapter->stats.gorcl;
-+ adapter->net_stats.tx_bytes = adapter->stats.gotcl;
-+ adapter->net_stats.multicast = adapter->stats.mprc;
-+ adapter->net_stats.collisions = adapter->stats.colc;
-+
-+ /* Rx Errors */
-+
-+ adapter->net_stats.rx_errors = adapter->stats.rxerrc +
-+ adapter->stats.crcerrs + adapter->stats.algnerrc +
-+ adapter->stats.rlec + adapter->stats.mpc +
-+ adapter->stats.cexterr;
-+ adapter->net_stats.rx_dropped = adapter->stats.mpc;
-+ adapter->net_stats.rx_length_errors = adapter->stats.rlec;
-+ adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
-+ adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
-+ adapter->net_stats.rx_fifo_errors = adapter->stats.mpc;
-+ adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
-+
-+ /* Tx Errors */
-+
-+ adapter->net_stats.tx_errors = adapter->stats.ecol +
-+ adapter->stats.latecol;
-+ adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
-+ adapter->net_stats.tx_window_errors = adapter->stats.latecol;
-+ adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
-
-- /* Tx Dropped needs to be maintained elsewhere */
-+ /* Tx Dropped needs to be maintained elsewhere */
-
-- /* Phy Stats */
-+ /* Phy Stats */
-
-- if(hw->media_type == iegbe_media_type_copper
-+ if(hw->media_type == iegbe_media_type_copper
- || (hw->media_type == iegbe_media_type_oem
- && iegbe_oem_phy_is_copper(&adapter->hw))) {
-- if((adapter->link_speed == SPEED_1000) &&
-- (!iegbe_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
-- phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
-- adapter->phy_stats.idle_errors += phy_tmp;
-- }
-+ if((adapter->link_speed == SPEED_1000) &&
-+ (!iegbe_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
-+ phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
-+ adapter->phy_stats.idle_errors += phy_tmp;
-+ }
-
-- if((hw->mac_type <= iegbe_82546) &&
-- (hw->phy_type == iegbe_phy_m88) &&
-+ if((hw->mac_type <= iegbe_82546) &&
-+ (hw->phy_type == iegbe_phy_m88) &&
- !iegbe_read_phy_reg(hw, M88E1000_RX_ERR_CNTR, &phy_tmp)) {
-- adapter->phy_stats.receive_errors += phy_tmp;
-- }
-+ adapter->phy_stats.receive_errors += phy_tmp;
-+ }
- }
-
-- spin_unlock_irqrestore(&adapter->stats_lock, flags);
-+ spin_unlock_irqrestore(&adapter->stats_lock, flags);
- }
-
--#ifdef CONFIG_E1000_MQ
--void
--iegbe_rx_schedule(void *data)
-+/**
-+ * iegbe_intr_msi - Interrupt Handler
-+ * @irq: interrupt number
-+ * @data: pointer to a network interface device structure
-+ **/
-+
-+static irqreturn_t iegbe_intr_msi(int irq, void *data)
- {
-- struct net_device *poll_dev, *netdev = data;
-- struct iegbe_adapter *adapter = netdev->priv;
-- int this_cpu = get_cpu();
--
-- poll_dev = *per_cpu_ptr(adapter->cpu_netdev, this_cpu);
-- if (poll_dev == NULL) {
-- put_cpu();
-- return;
-+ struct net_device *netdev = data;
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ struct iegbe_hw *hw = &adapter->hw;
-+ u32 icr = E1000_READ_REG(&adapter->hw, ICR);
-+ if (icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
-+ hw->get_link_status = 1;
-+ if (!test_bit(__E1000_DOWN, &adapter->flags))
-+ mod_timer(&adapter->watchdog_timer, jiffies + 1);
- }
-
-- if (likely(netif_rx_schedule_prep(poll_dev))) {
-- __netif_rx_schedule(poll_dev);
-- } else {
-- iegbe_irq_enable(adapter);
-- }
-- put_cpu();
--}
--#endif
--
--#ifdef IEGBE_GBE_WORKAROUND
--/*
-- * Check for tx hang condition. This is the condition where a
-- * decsriptor is in the hardware and hasn't been processed for a
-- * while. This code is similar to the check in iegbe_clean_rx_irq()
-- */
--static void
--iegbe_tx_hang_check(struct iegbe_adapter *adapter,
-- struct iegbe_tx_ring *tx_ring)
--{
-- struct net_device *netdev = adapter->netdev;
-- unsigned int i;
-+ if(unlikely(icr & (E1000_ICR_RX_DESC_FIFO_PAR
-+ | E1000_ICR_TX_DESC_FIFO_PAR
-+ | E1000_ICR_PB
-+ | E1000_ICR_CPP_TARGET
-+ | E1000_ICR_CPP_MASTER ))) {
-
-- /* Check for a hang condition using the buffer currently at the Tx
-- head pointer */
-- i = readl(adapter->hw.hw_addr + tx_ring->tdh);
--
-- if (adapter->detect_tx_hung) {
-- /* Detect a transmit hang in hardware, this serializes the
-- * check with the clearing of time_stamp and movement of i */
-- adapter->detect_tx_hung = FALSE;
--
-- if (tx_ring->buffer_info[i].dma &&
-- time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ)
-- && !(E1000_READ_REG(&adapter->hw, STATUS) &
-- E1000_STATUS_TXOFF)) {
--
-- /* detected Tx unit hang */
-- DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
-- " TDH <%x>\n"
-- " TDT <%x>\n"
-- " next_to_use <%x>\n"
-- " next_to_clean <%x>\n"
-- "buffer_info[tdh]\n"
-- " dma <%zx>\n"
-- " time_stamp <%lx>\n"
-- " jiffies <%lx>\n",
-- readl(adapter->hw.hw_addr + tx_ring->tdh),
-- readl(adapter->hw.hw_addr + tx_ring->tdt),
-- tx_ring->next_to_use,
-- tx_ring->next_to_clean,
-- (size_t)tx_ring->buffer_info[i].dma,
-- tx_ring->buffer_info[i].time_stamp,
-- jiffies);
-- netif_stop_queue(netdev);
-- }
-+ iegbe_irq_disable(adapter);
-+ printk("Critical error! ICR = 0x%x\n", icr);
-+ return IRQ_HANDLED;
- }
--}
-+ if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
-+ adapter->total_tx_bytes = 0;
-+ adapter->total_tx_packets = 0;
-+ adapter->total_rx_bytes = 0;
-+ adapter->total_rx_packets = 0;
-+ __netif_rx_schedule(netdev, &adapter->napi);
-+ } else
-+ iegbe_irq_enable(adapter);
-
--#endif
-+ return IRQ_HANDLED;
-+}
-
- /**
- * iegbe_intr - Interrupt Handler
-@@ -3546,364 +3478,208 @@ iegbe_tx_hang_check(struct iegbe_adapter
- **/
-
- static irqreturn_t
--iegbe_intr(int irq, void *data, struct pt_regs *regs)
-+iegbe_intr(int irq, void *data)
- {
-- struct net_device *netdev = data;
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-- struct iegbe_hw *hw = &adapter->hw;
-- uint32_t rctl, tctl;
-- uint32_t icr = E1000_READ_REG(hw, ICR);
--#ifndef CONFIG_E1000_NAPI
-- uint32_t i;
--#ifdef IEGBE_GBE_WORKAROUND
-- int rx_cleaned;
--#endif
--#endif
-+ struct net_device *netdev = data;
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ struct iegbe_hw *hw = &adapter->hw;
-+ u32 icr = E1000_READ_REG(&adapter->hw, ICR);
-
-- if(unlikely(!icr)) {
-+ if (unlikely(!icr))
- return IRQ_NONE; /* Not our interrupt */
-- }
-+
-+ /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
-+ * not set, then the adapter didn't send an interrupt */
-+ if (unlikely(hw->mac_type >= iegbe_82571 &&
-+ !(icr & E1000_ICR_INT_ASSERTED)))
-+ return IRQ_NONE;
-+
-+
- if(unlikely(icr & (E1000_ICR_RX_DESC_FIFO_PAR
-- | E1000_ICR_TX_DESC_FIFO_PAR
-- | E1000_ICR_PB
-- | E1000_ICR_CPP_TARGET
-- | E1000_ICR_CPP_MASTER ))) {
-+ | E1000_ICR_TX_DESC_FIFO_PAR
-+ | E1000_ICR_PB
-+ | E1000_ICR_CPP_TARGET
-+ | E1000_ICR_CPP_MASTER ))) {
-
- iegbe_irq_disable(adapter);
-- tctl = E1000_READ_REG(&adapter->hw, TCTL);
-- rctl = E1000_READ_REG(&adapter->hw, RCTL);
-- E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_TCTL_EN);
-- E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_RCTL_EN);
--
-- tasklet_data = (unsigned long) (icr + adapter->bd_number);
-- tasklet_schedule(&iegbe_reset_tasklet);
--
-- return IRQ_HANDLED;
-- }
--
--#ifdef CONFIG_E1000_NAPI
-- atomic_inc(&adapter->irq_sem);
--#ifdef IEGBE_GBE_WORKAROUND
-- /* Ensure that the TXQE interrupt is enabled in NAPI mode */
-- E1000_WRITE_REG(hw, IMC, ~E1000_IMS_TXQE);
--#else
-- E1000_WRITE_REG(hw, IMC, ~0);
--#endif
-- E1000_WRITE_FLUSH(hw);
--#ifdef CONFIG_E1000_MQ
-- if (atomic_read(&adapter->rx_sched_call_data.count) == 0) {
-- cpu_set(adapter->cpu_for_queue[0],
-- adapter->rx_sched_call_data.cpumask);
-- for (i = 1; i < adapter->num_queues; i++) {
-- cpu_set(adapter->cpu_for_queue[i],
-- adapter->rx_sched_call_data.cpumask);
-- atomic_inc(&adapter->irq_sem);
-- }
-- atomic_set(&adapter->rx_sched_call_data.count, i);
-- smp_call_async_mask(&adapter->rx_sched_call_data);
-- } else {
-- DEBUGOUT("call_data.count == %u\n",
-- atomic_read(&adapter->rx_sched_call_data.count));
-+ printk("Critical error! ICR = 0x%x\n", icr);
-+ return IRQ_HANDLED;
- }
--#else
-- if (likely(netif_rx_schedule_prep(&adapter->polling_netdev[0]))) {
-- __netif_rx_schedule(&adapter->polling_netdev[0]);
-- } else {
-- iegbe_irq_enable(adapter);
-- }
--#endif
--
--#ifdef IEGBE_GBE_WORKAROUND
-- /* Clean the Tx ring */
-- for (i = 0; i < E1000_MAX_INTR; i++) {
-- adapter->stats.rx_next_to_clean = adapter->rx_ring->next_to_clean;
-- adapter->stats.rx_next_to_use = adapter->rx_ring->next_to_use;
--
-- adapter->stats.tx_next_to_clean = adapter->tx_ring->next_to_clean;
-- adapter->stats.tx_next_to_use = adapter->tx_ring->next_to_use;
--
-- /* Only clean Tx descriptors for a TXQE interrupt */
-- if(icr & E1000_ICR_TXQE) {
-- adapter->stats.txqec++;
-- iegbe_clean_tx_ring_partial(adapter, adapter->tx_ring);
-- }
-- else {
-- iegbe_tx_hang_check(adapter, adapter->tx_ring);
-- }
-- }
-
--#endif /*IEGBE_GBE_WORKAROUND */
--
--#else
-- /* Writing IMC and IMS is needed for 82547.
-- * Due to Hub Link bus being occupied, an interrupt
-- * de-assertion message is not able to be sent.
-- * When an interrupt assertion message is generated later,
-- * two messages are re-ordered and sent out.
-- * That causes APIC to think 82547 is in de-assertion
-- * state, while 82547 is in assertion state, resulting
-- * in dead lock. Writing IMC forces 82547 into
-- * de-assertion state.
-- */
-- if (hw->mac_type == iegbe_82547 || hw->mac_type == iegbe_82547_rev_2) {
-- atomic_inc(&adapter->irq_sem);
-- E1000_WRITE_REG(hw, IMC, ~0);
-- }
--
--#ifdef IEGBE_GBE_WORKAROUND
--
-- for (i = 0; i < E1000_MAX_INTR; i++) {
-- rx_cleaned = adapter->clean_rx(adapter, adapter->rx_ring);
-- adapter->stats.rx_next_to_clean = adapter->rx_ring->next_to_clean;
-- adapter->stats.rx_next_to_use = adapter->rx_ring->next_to_use;
--
-- adapter->stats.tx_next_to_clean = adapter->tx_ring->next_to_clean;
-- adapter->stats.tx_next_to_use = adapter->tx_ring->next_to_use;
--
-- /* Only clean Tx descriptors for a TXQE interrupt */
-- if(icr & E1000_ICR_TXQE) {
-- adapter->stats.txqec++;
-- iegbe_clean_tx_ring_partial(adapter, adapter->tx_ring);
-- }
-- else {
-- iegbe_tx_hang_check(adapter, adapter->tx_ring);
-- }
-- if(!rx_cleaned) {
-- break;
-- }
-+ /* Interrupt Auto-Mask...upon reading ICR, interrupts are masked. No
-+ * need for the IMC write */
-+ if (unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) {
-+ hw->get_link_status = 1;
-+ /* guard against interrupt when we're going down */
-+ if (!test_bit(__E1000_DOWN, &adapter->flags))
-+ mod_timer(&adapter->watchdog_timer, jiffies + 1);
-+
- }
-
--#else
-- for (i = 0; i < E1000_MAX_INTR; i++)
-- if(unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
-- !iegbe_clean_tx_irq(adapter, adapter->tx_ring))) {
-- break;
-- }
--#endif
--
-- if (hw->mac_type == iegbe_82547 || hw->mac_type == iegbe_82547_rev_2) {
-- iegbe_irq_enable(adapter);
-- }
--#endif
--#ifdef E1000_COUNT_ICR
-- adapter->icr_txdw += icr & 0x01UL;
-- icr >>= 0x1;
-- adapter->icr_txqe += icr & 0x01UL;
-- icr >>= 0x1;
-- adapter->icr_lsc += icr & 0x01UL;
-- icr >>= 0x1;
-- adapter->icr_rxseq += icr & 0x01UL;
-- icr >>= 0x1;
-- adapter->icr_rxdmt += icr & 0x01UL;
-- icr >>= 0x1;
-- adapter->icr_rxo += icr & 0x01UL;
-- icr >>= 0x1;
-- adapter->icr_rxt += icr & 0x01UL;
-- if(hw->mac_type != iegbe_icp_xxxx) {
-- icr >>= 0x2;
-- adapter->icr_mdac += icr & 0x01UL;
-- icr >>= 0x1;
-- adapter->icr_rxcfg += icr & 0x01UL;
-- icr >>= 0x1;
-- adapter->icr_gpi += icr & 0x01UL;
-- } else {
-- icr >>= 0x4;
-- }
-- if(hw->mac_type == iegbe_icp_xxxx) {
-- icr >>= 0xc;
-- adapter->icr_pb += icr & 0x01UL;
-- icr >>= 0x3;
-- adapter->icr_intmem_icp_xxxx += icr & 0x01UL;
-- icr >>= 0x1;
-- adapter->icr_cpp_target += icr & 0x01UL;
-- icr >>= 0x1;
-- adapter->icr_cpp_master += icr & 0x01UL;
-- icr >>= 0x1;
-- adapter->icr_stat += icr & 0x01UL;
-+ if (unlikely(hw->mac_type < iegbe_82571)) {
-+ E1000_WRITE_REG(&adapter->hw, IMC, ~0);
-+ E1000_WRITE_FLUSH(&adapter->hw);
- }
--#endif
-+ if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
-+ adapter->total_tx_bytes = 0;
-+ adapter->total_tx_packets = 0;
-+ adapter->total_rx_bytes = 0;
-+ adapter->total_rx_packets = 0;
-+ __netif_rx_schedule(netdev, &adapter->napi);
-+ } else
-+ /* this really should not happen! if it does it is basically a
-+ * bug, but not a hard error, so enable ints and continue */
-+ iegbe_irq_enable(adapter);
-
- return IRQ_HANDLED;
- }
-
--#ifdef CONFIG_E1000_NAPI
- /**
- * iegbe_clean - NAPI Rx polling callback
- * @adapter: board private structure
- **/
--
--static int
--iegbe_clean(struct net_device *poll_dev, int *budget)
-+static int iegbe_clean(struct napi_struct *napi, int budget)
- {
-- struct iegbe_adapter *adapter;
-- int work_to_do = min(*budget, poll_dev->quota);
-- int tx_cleaned, i = 0, work_done = 0;
-+ struct iegbe_adapter *adapter = container_of(napi, struct iegbe_adapter, napi);
-+ struct net_device *poll_dev = adapter->netdev;
-+ int tx_cleaned = 0, work_done = 0;
-
- /* Must NOT use netdev_priv macro here. */
- adapter = poll_dev->priv;
-
-- /* Keep link state information with original netdev */
-- if (!netif_carrier_ok(adapter->netdev)) {
-- goto quit_polling;
-- }
-- while (poll_dev != &adapter->polling_netdev[i]) {
-- i++;
-- if (unlikely(i == adapter->num_queues)) {
-- BUG();
-- }
-- }
--
--#ifdef IEGBE_GBE_WORKAROUND
-- /* Tx descriptors are cleaned in iegbe_intr(). No need to clean
-- them here */
-- tx_cleaned = FALSE;
--#else
-- tx_cleaned = iegbe_clean_tx_irq(adapter, &adapter->tx_ring[i]);
--#endif
-- adapter->clean_rx(adapter, &adapter->rx_ring[i],
-- &work_done, work_to_do);
--
-- *budget -= work_done;
-- poll_dev->quota -= work_done;
--
-- /* If no Tx and not enough Rx work done, exit the polling mode */
-- if((!tx_cleaned && (work_done == 0)) ||
-- !netif_running(adapter->netdev)) {
--quit_polling:
-- netif_rx_complete(poll_dev);
-+ /* iegbe_clean is called per-cpu. This lock protects
-+ * tx_ring[0] from being cleaned by multiple cpus
-+ * simultaneously. A failure obtaining the lock means
-+ * tx_ring[0] is currently being cleaned anyway. */
-+ if (spin_trylock(&adapter->tx_queue_lock)) {
-+ tx_cleaned = iegbe_clean_tx_irq(adapter,
-+ &adapter->tx_ring[0]);
-+ spin_unlock(&adapter->tx_queue_lock);
-+ }
-+
-+ adapter->clean_rx(adapter, &adapter->rx_ring[0],
-+ &work_done, budget);
-+
-+ if (tx_cleaned)
-+ work_done = budget;
-+
-+ /* If budget not fully consumed, exit the polling mode */
-+ if (work_done < budget) {
-+ if (likely(adapter->itr_setting & 3))
-+ iegbe_set_itr(adapter);
-+ netif_rx_complete(poll_dev, napi);
- iegbe_irq_enable(adapter);
-- return 0;
- }
-
-- return 1;
-+ return work_done;
- }
-
--#endif
--
--
--#ifndef IEGBE_GBE_WORKAROUND
- /**
- * iegbe_clean_tx_irq - Reclaim resources after transmit completes
- * @adapter: board private structure
- **/
--
--static boolean_t
--iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
-+static bool iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
- struct iegbe_tx_ring *tx_ring)
- {
-- struct net_device *netdev = adapter->netdev;
-- struct iegbe_tx_desc *tx_desc, *eop_desc;
-- struct iegbe_buffer *buffer_info;
-- unsigned int i, eop;
-- boolean_t cleaned = FALSE;
-+ struct iegbe_hw *hw = &adapter->hw;
-+ struct net_device *netdev = adapter->netdev;
-+ struct iegbe_tx_desc *tx_desc, *eop_desc;
-+ struct iegbe_buffer *buffer_info;
-+ unsigned int i, eop;
-+ unsigned int count = 0;
-+ bool cleaned = false;
-+ unsigned int total_tx_bytes=0, total_tx_packets=0;
-
-- i = tx_ring->next_to_clean;
-- eop = tx_ring->buffer_info[i].next_to_watch;
-- eop_desc = E1000_TX_DESC(*tx_ring, eop);
-+ i = tx_ring->next_to_clean;
-+ eop = tx_ring->buffer_info[i].next_to_watch;
-+ eop_desc = E1000_TX_DESC(*tx_ring, eop);
-
- while (eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
-- /* Premature writeback of Tx descriptors clear (free buffers
-- * and unmap pci_mapping) previous_buffer_info */
-- if (likely(tx_ring->previous_buffer_info.skb != NULL)) {
-- iegbe_unmap_and_free_tx_resource(adapter,
-- &tx_ring->previous_buffer_info);
-- }
--
-- for (cleaned = FALSE; !cleaned; ) {
-- tx_desc = E1000_TX_DESC(*tx_ring, i);
-- buffer_info = &tx_ring->buffer_info[i];
-- cleaned = (i == eop);
--
--#ifdef NETIF_F_TSO
-- if (!(netdev->features & NETIF_F_TSO)) {
--#endif
-- iegbe_unmap_and_free_tx_resource(adapter,
-- buffer_info);
--#ifdef NETIF_F_TSO
-- } else {
-- if (cleaned) {
-- memcpy(&tx_ring->previous_buffer_info,
-- buffer_info,
-- sizeof(struct iegbe_buffer));
-- memset(buffer_info, 0,
-- sizeof(struct iegbe_buffer));
-- } else {
-- iegbe_unmap_and_free_tx_resource(
-- adapter, buffer_info);
-- }
-- }
--#endif
--
-- tx_desc->buffer_addr = 0;
-- tx_desc->lower.data = 0;
-+ for (cleaned = false; !cleaned; ) {
-+ tx_desc = E1000_TX_DESC(*tx_ring, i);
-+ buffer_info = &tx_ring->buffer_info[i];
-+ cleaned = (i == eop);
-+
-+ if (cleaned) {
-+ struct sk_buff *skb = buffer_info->skb;
-+ unsigned int segs = 0, bytecount;
-+ segs = skb_shinfo(skb)->gso_segs ?: 1;
-+ bytecount = ((segs - 1) * skb_headlen(skb)) +
-+ skb->len;
-+ total_tx_packets += segs;
-+ total_tx_bytes += bytecount;
-+ }
-+ iegbe_unmap_and_free_tx_resource(adapter, buffer_info);
- tx_desc->upper.data = 0;
-
-- if (unlikely(++i == tx_ring->count)) { i = 0; }
-- }
--
-- tx_ring->pkt++;
-+ if (unlikely(++i == tx_ring->count)) i = 0;
-+ }
-
-- eop = tx_ring->buffer_info[i].next_to_watch;
-- eop_desc = E1000_TX_DESC(*tx_ring, eop);
-- }
-+ eop = tx_ring->buffer_info[i].next_to_watch;
-+ eop_desc = E1000_TX_DESC(*tx_ring, eop);
-+#define E1000_TX_WEIGHT 64
-+ /* weight of a sort for tx, to avoid endless transmit cleanup */
-+ if (count++ == E1000_TX_WEIGHT)
-+ break;
-+ }
-
- tx_ring->next_to_clean = i;
-
-- spin_lock(&tx_ring->tx_lock);
-+#define TX_WAKE_THRESHOLD 32
-
-- if (unlikely(cleaned && netif_queue_stopped(netdev) &&
-- netif_carrier_ok(netdev))) {
-- netif_wake_queue(netdev);
-- }
-- spin_unlock(&tx_ring->tx_lock);
--
-- if (adapter->detect_tx_hung) {
-- /* Detect a transmit hang in hardware, this serializes the
-- * check with the clearing of time_stamp and movement of i */
-- adapter->detect_tx_hung = FALSE;
--
-- if (tx_ring->buffer_info[i].dma &&
-- time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ)
-- && !(E1000_READ_REG(&adapter->hw, STATUS) &
-- E1000_STATUS_TXOFF)) {
--
-- /* detected Tx unit hang */
-- i = tx_ring->next_to_clean;
-- eop = tx_ring->buffer_info[i].next_to_watch;
-- eop_desc = E1000_TX_DESC(*tx_ring, eop);
-- DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
-- " TDH <%x>\n"
-- " TDT <%x>\n"
-- " next_to_use <%x>\n"
-- " next_to_clean <%x>\n"
-- "buffer_info[next_to_clean]\n"
-- " dma <%zx>\n"
-- " time_stamp <%lx>\n"
-- " next_to_watch <%x>\n"
-- " jiffies <%lx>\n"
-- " next_to_watch.status <%x>\n",
-- readl(adapter->hw.hw_addr + tx_ring->tdh),
-- readl(adapter->hw.hw_addr + tx_ring->tdt),
-- tx_ring->next_to_use,
-- i,
-- (size_t)tx_ring->buffer_info[i].dma,
-- tx_ring->buffer_info[i].time_stamp,
-- eop,
-- jiffies,
-- eop_desc->upper.fields.status);
-- netif_stop_queue(netdev);
-+ if (unlikely(cleaned && netif_carrier_ok(netdev) &&
-+ E1000_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD)) {
-+ /* Make sure that anybody stopping the queue after this
-+ * sees the new next_to_clean.
-+ */
-+ smp_mb();
-+ if (netif_queue_stopped(netdev)) {
-+ netif_wake_queue(netdev);
-+ ++adapter->restart_queue;
- }
- }
--#ifdef NETIF_F_TSO
-- if (unlikely(!(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
-- time_after(jiffies, tx_ring->previous_buffer_info.time_stamp + HZ))) {
-- iegbe_unmap_and_free_tx_resource(
-- adapter, &tx_ring->previous_buffer_info);
-+
-+ if (adapter->detect_tx_hung) {
-+ /* Detect a transmit hang in hardware, this serializes the
-+ * check with the clearing of time_stamp and movement of i */
-+ adapter->detect_tx_hung = false;
-+
-+ if (tx_ring->buffer_info[eop].dma &&
-+ time_after(jiffies, tx_ring->buffer_info[eop].time_stamp +
-+ (adapter->tx_timeout_factor * HZ))
-+ && !(E1000_READ_REG(hw, STATUS) & E1000_STATUS_TXOFF)) {
-+
-+ /* detected Tx unit hang */
-+ DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
-+ " Tx Queue <%lu>\n"
-+ " TDH <%x>\n"
-+ " TDT <%x>\n"
-+ " next_to_use <%x>\n"
-+ " next_to_clean <%x>\n"
-+ "buffer_info[next_to_clean]\n"
-+ " time_stamp <%lx>\n"
-+ " next_to_watch <%x>\n"
-+ " jiffies <%lx>\n"
-+ " next_to_watch.status <%x>\n",
-+ (unsigned long)((tx_ring - adapter->tx_ring) /
-+ sizeof(struct iegbe_tx_ring)),
-+ readl(hw->hw_addr + tx_ring->tdh),
-+ readl(hw->hw_addr + tx_ring->tdt),
-+ tx_ring->next_to_use,
-+ tx_ring->next_to_clean,
-+ tx_ring->buffer_info[eop].time_stamp,
-+ eop,
-+ jiffies,
-+ eop_desc->upper.fields.status);
-+ netif_stop_queue(netdev);
-+ }
- }
--#endif
-- return cleaned;
-+ adapter->total_tx_bytes += total_tx_bytes;
-+ adapter->total_tx_packets += total_tx_packets;
-+ adapter->net_stats.tx_bytes += total_tx_bytes;
-+ adapter->net_stats.tx_packets += total_tx_packets;
-+ return cleaned;
- }
--#endif
-
- /**
- * iegbe_rx_checksum - Receive Checksum Offload for 82543
-@@ -3913,192 +3689,193 @@ iegbe_clean_tx_irq(struct iegbe_adapter
- * @sk_buff: socket buffer with received data
- **/
-
--static inline void
--iegbe_rx_checksum(struct iegbe_adapter *adapter,
-- uint32_t status_err, uint32_t csum,
-- struct sk_buff *skb)
-+static void iegbe_rx_checksum(struct iegbe_adapter *adapter, u32 status_err,
-+ u32 csum, struct sk_buff *skb)
- {
-- uint16_t status = (uint16_t)status_err;
-- uint8_t errors = (uint8_t)(status_err >> 0x18);
-+ struct iegbe_hw *hw = &adapter->hw;
-+ u16 status = (u16)status_err;
-+ u8 errors = (u8)(status_err >> 24);
- skb->ip_summed = CHECKSUM_NONE;
-
-- /* 82543 or newer only */
-- if(unlikely(adapter->hw.mac_type < iegbe_82543)) { return; }
-- /* Ignore Checksum bit is set */
-- if(unlikely(status & E1000_RXD_STAT_IXSM)) { return; }
-- /* TCP/UDP checksum error bit is set */
-- if(unlikely(errors & E1000_RXD_ERR_TCPE)) {
-- /* let the stack verify checksum errors */
-- adapter->hw_csum_err++;
-- return;
-- }
-- /* TCP/UDP Checksum has not been calculated */
-- if(adapter->hw.mac_type <= iegbe_82547_rev_2) {
-- if(!(status & E1000_RXD_STAT_TCPCS)) {
-- return;
-+ /* 82543 or newer only */
-+ if (unlikely(hw->mac_type < iegbe_82543)) return;
-+ /* Ignore Checksum bit is set */
-+ if (unlikely(status & E1000_RXD_STAT_IXSM)) return;
-+ /* TCP/UDP checksum error bit is set */
-+ if(unlikely(errors & E1000_RXD_ERR_TCPE)) {
-+ /* let the stack verify checksum errors */
-+ adapter->hw_csum_err++;
-+ return;
-+ }
-+ /* TCP/UDP Checksum has not been calculated */
-+ if (hw->mac_type <= iegbe_82547_rev_2) {
-+ if (!(status & E1000_RXD_STAT_TCPCS))
-+ return;
-+ } else {
-+ if (!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)))
-+ return;
- }
-- } else {
-- if(!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS))) {
-- return;
-- }
-+ /* It must be a TCP or UDP packet with a valid checksum */
-+ if(likely(status & E1000_RXD_STAT_TCPCS)) {
-+ /* TCP checksum is good */
-+ skb->ip_summed = CHECKSUM_UNNECESSARY;
-+ } else if (hw->mac_type > iegbe_82547_rev_2) {
-+ /* IP fragment with UDP payload */
-+ /* Hardware complements the payload checksum, so we undo it
-+ * and then put the value in host order for further stack use.
-+ */
-+ __sum16 sum = (__force __sum16)htons(csum);
-+ skb->csum = csum_unfold(~sum);
-+ skb->ip_summed = CHECKSUM_COMPLETE;
- }
-- /* It must be a TCP or UDP packet with a valid checksum */
-- if(likely(status & E1000_RXD_STAT_TCPCS)) {
-- /* TCP checksum is good */
-- skb->ip_summed = CHECKSUM_UNNECESSARY;
-- } else if(adapter->hw.mac_type > iegbe_82547_rev_2) {
-- /* IP fragment with UDP payload */
-- /* Hardware complements the payload checksum, so we undo it
-- * and then put the value in host order for further stack use.
-- */
-- csum = ntohl(csum ^ 0xFFFF);
-- skb->csum = csum;
-- skb->ip_summed = CHECKSUM_HW;
-- }
-- adapter->hw_csum_good++;
-+ adapter->hw_csum_good++;
- }
-
- /**
- * iegbe_clean_rx_irq - Send received data up the network stack; legacy
- * @adapter: board private structure
- **/
--
--static boolean_t
--#ifdef CONFIG_E1000_NAPI
--iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
-+static bool iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rx_ring,
- int *work_done, int work_to_do)
--#else
--iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
-- struct iegbe_rx_ring *rx_ring)
--#endif
- {
-- struct net_device *netdev = adapter->netdev;
-- struct pci_dev *pdev = adapter->pdev;
-- struct iegbe_rx_desc *rx_desc;
-- struct iegbe_buffer *buffer_info;
-- struct sk_buff *skb;
-- unsigned long flags = 0;
-- uint32_t length;
-- uint8_t last_byte;
-- unsigned int i;
-- boolean_t cleaned = FALSE;
--
--#ifdef IEGBE_GBE_WORKAROUND
-- /* Need to keep track of the amount of Rx descriptors that we
-- cleaned to ensure that we don't supply too many back to the
-- hardware */
-- int cleaned_count = 0;
--#endif
--
-- i = rx_ring->next_to_clean;
-- rx_desc = E1000_RX_DESC(*rx_ring, i);
--
-- while(rx_desc->status & E1000_RXD_STAT_DD) {
-- buffer_info = &rx_ring->buffer_info[i];
--#ifdef CONFIG_E1000_NAPI
-- if(*work_done >= work_to_do) {
-- break;
-- }
-- (*work_done)++;
--#endif
-- cleaned = TRUE;
-+ struct iegbe_hw *hw = &adapter->hw;
-+ struct net_device *netdev = adapter->netdev;
-+ struct pci_dev *pdev = adapter->pdev;
-+ struct iegbe_rx_desc *rx_desc, *next_rxd;
-+ struct iegbe_buffer *buffer_info, *next_buffer;
-+ unsigned long flags;
-+ u32 length;
-+ u8 last_byte;
-+ unsigned int i;
-+ int cleaned_count = 0;
-+ bool cleaned = false;
-+ unsigned int total_rx_bytes=0, total_rx_packets=0;
-
--#ifdef IEGBE_GBE_WORKAROUND
-- cleaned_count++;
--#endif
-+ i = rx_ring->next_to_clean;
-+ rx_desc = E1000_RX_DESC(*rx_ring, i);
-+ buffer_info = &rx_ring->buffer_info[i];
-
-- pci_unmap_single(pdev,
-- buffer_info->dma,
-- buffer_info->length,
-- PCI_DMA_FROMDEVICE);
-+ while(rx_desc->status & E1000_RXD_STAT_DD) {
-+ struct sk_buff *skb;
-+ u8 status;
-+ if (*work_done >= work_to_do)
-+ break;
-+ (*work_done)++;
-
-+ status = rx_desc->status;
- skb = buffer_info->skb;
-- length = le16_to_cpu(rx_desc->length);
-+ buffer_info->skb = NULL;
-+ prefetch(skb->data - NET_IP_ALIGN);
-+ if (++i == rx_ring->count) i = 0;
-+ next_rxd = E1000_RX_DESC(*rx_ring, i);
-+ prefetch(next_rxd);
-+ next_buffer = &rx_ring->buffer_info[i];
-+ cleaned = true;
-+ cleaned_count++;
-+ pci_unmap_single(pdev,
-+ buffer_info->dma,
-+ buffer_info->length,
-+ PCI_DMA_FROMDEVICE);
-+
-+ length = le16_to_cpu(rx_desc->length);
-+
-+ if (unlikely(!(status & E1000_RXD_STAT_EOP))) {
-+ /* All receives must fit into a single buffer */
-+ E1000_DBG("%s: Receive packet consumed multiple"
-+ " buffers\n", netdev->name);
-+ buffer_info->skb = skb;
-+ goto next_desc;
-+ }
-
-- if(unlikely(!(rx_desc->status & E1000_RXD_STAT_EOP))) {
-- /* All receives must fit into a single buffer */
-- E1000_DBG("%s: Receive packet consumed multiple"
-- " buffers\n", netdev->name);
-- dev_kfree_skb_irq(skb);
-- goto next_desc;
-- }
-+ if(unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
-+ last_byte = *(skb->data + length - 1);
-+ if (TBI_ACCEPT(hw, status, rx_desc->errors, length,
-+ last_byte)) {
-+ spin_lock_irqsave(&adapter->stats_lock, flags);
-+ iegbe_tbi_adjust_stats(hw, &adapter->stats,
-+ length, skb->data);
-+ spin_unlock_irqrestore(&adapter->stats_lock,
-+ flags);
-+ length--;
-+ } else {
-+ buffer_info->skb = skb;
-+ goto next_desc;
-+ }
-+ }
-
-- if(unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
-- last_byte = *(skb->data + length - 0x1);
-- if(TBI_ACCEPT(&adapter->hw, rx_desc->status,
-- rx_desc->errors, length, last_byte)) {
-- spin_lock_irqsave(&adapter->stats_lock, flags);
-- iegbe_tbi_adjust_stats(&adapter->hw,
-- &adapter->stats,
-- length, skb->data);
-- spin_unlock_irqrestore(&adapter->stats_lock,
-- flags);
-- length--;
-- } else {
-- dev_kfree_skb_irq(skb);
-- goto next_desc;
-+ /* adjust length to remove Ethernet CRC, this must be
-+ * done after the TBI_ACCEPT workaround above */
-+ length -= 4;
-+
-+ /* probably a little skewed due to removing CRC */
-+ total_rx_bytes += length;
-+ total_rx_packets++;
-+
-+ /* code added for copybreak, this should improve
-+ * performance for small packets with large amounts
-+ * of reassembly being done in the stack */
-+ if (length < copybreak) {
-+ struct sk_buff *new_skb =
-+ netdev_alloc_skb(netdev, length + NET_IP_ALIGN);
-+ if (new_skb) {
-+ skb_reserve(new_skb, NET_IP_ALIGN);
-+ skb_copy_to_linear_data_offset(new_skb,
-+ -NET_IP_ALIGN,
-+ (skb->data -
-+ NET_IP_ALIGN),
-+ (length +
-+ NET_IP_ALIGN));
-+ /* save the skb in buffer_info as good */
-+ buffer_info->skb = skb;
-+ skb = new_skb;
- }
-+ /* else just continue with the old one */
- }
--
-- /* Good Receive */
-- skb_put(skb, length - ETHERNET_FCS_SIZE);
-+ /* Good Receive */
-+ skb_put(skb, length);
-
- /* Receive Checksum Offload */
- iegbe_rx_checksum(adapter,
-- (uint32_t)(rx_desc->status) |
-- ((uint32_t)(rx_desc->errors) << 0x18),
-- rx_desc->csum, skb);
-+ (u32)(status) |
-+ ((u32)(rx_desc->errors) << 24),
-+ le16_to_cpu(rx_desc->csum), skb);
-+
- skb->protocol = eth_type_trans(skb, netdev);
--#ifdef CONFIG_E1000_NAPI
--#ifdef NETIF_F_HW_VLAN_TX
-- if(unlikely(adapter->vlgrp &&
-- (rx_desc->status & E1000_RXD_STAT_VP))) {
-+
-+ if (unlikely(adapter->vlgrp &&
-+ (status & E1000_RXD_STAT_VP))) {
- vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
-- le16_to_cpu(rx_desc->special) &
-- E1000_RXD_SPC_VLAN_MASK);
-+ le16_to_cpu(rx_desc->special));
- } else {
- netif_receive_skb(skb);
- }
--#else
-- netif_receive_skb(skb);
--#endif
--#else /* CONFIG_E1000_NAPI */
--#ifdef NETIF_F_HW_VLAN_TX
-- if(unlikely(adapter->vlgrp &&
-- (rx_desc->status & E1000_RXD_STAT_VP))) {
-- vlan_hwaccel_rx(skb, adapter->vlgrp,
-- le16_to_cpu(rx_desc->special) &
-- E1000_RXD_SPC_VLAN_MASK);
-- } else {
-- netif_rx(skb);
-- }
--#else
-- netif_rx(skb);
--#endif
--#endif /* CONFIG_E1000_NAPI */
-+
- netdev->last_rx = jiffies;
-- rx_ring->pkt++;
-
- next_desc:
- rx_desc->status = 0;
-- buffer_info->skb = NULL;
-- if(unlikely(++i == rx_ring->count)) { i = 0; }
-
-- rx_desc = E1000_RX_DESC(*rx_ring, i);
-+ /* return some buffers to hardware, one at a time is too slow */
-+ if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
-+ adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
-+ cleaned_count = 0;
-+ }
-+
-+ /* use prefetched values */
-+ rx_desc = next_rxd;
-+ buffer_info = next_buffer;
- }
- rx_ring->next_to_clean = i;
-
--#ifdef IEGBE_GBE_WORKAROUND
-- /* Only allocate the number of buffers that we have actually
-- cleaned! */
-- if (cleaned_count) {
-- adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
-- }
--#else
-- adapter->alloc_rx_buf(adapter, rx_ring);
--#endif
--
-+ cleaned_count = E1000_DESC_UNUSED(rx_ring);
-+ if (cleaned_count)
-+ adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
-+
-+ adapter->total_rx_packets += total_rx_packets;
-+ adapter->total_rx_bytes += total_rx_bytes;
-+ adapter->net_stats.rx_bytes += total_rx_bytes;
-+ adapter->net_stats.rx_packets += total_rx_packets;
- return cleaned;
- }
-
-@@ -4107,161 +3884,153 @@ next_desc:
- * @adapter: board private structure
- **/
-
--static boolean_t
--#ifdef CONFIG_E1000_NAPI
--iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
-+static bool iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rx_ring,
- int *work_done, int work_to_do)
--#else
--iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
-- struct iegbe_rx_ring *rx_ring)
--#endif
- {
-- union iegbe_rx_desc_packet_split *rx_desc;
-- struct net_device *netdev = adapter->netdev;
-- struct pci_dev *pdev = adapter->pdev;
-- struct iegbe_buffer *buffer_info;
-- struct iegbe_ps_page *ps_page;
-- struct iegbe_ps_page_dma *ps_page_dma;
-- struct sk_buff *skb;
-- unsigned int i, j;
-- uint32_t length, staterr;
-- boolean_t cleaned = FALSE;
--
--#ifdef IEGBE_GBE_WORKAROUND
-- /* Need to keep track of the amount of Rx descriptors that we
-- cleaned to ensure that we don't supply too many back to the
-- hardware */
-- int cleaned_count = 0;
--#endif
--
-- i = rx_ring->next_to_clean;
-- rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
-- staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
--
-- while(staterr & E1000_RXD_STAT_DD) {
-- buffer_info = &rx_ring->buffer_info[i];
-- ps_page = &rx_ring->ps_page[i];
-- ps_page_dma = &rx_ring->ps_page_dma[i];
--#ifdef CONFIG_E1000_NAPI
-- if(unlikely(*work_done >= work_to_do)) {
-- break;
-- }
-- (*work_done)++;
--#endif
-- cleaned = TRUE;
--
--#ifdef IEGBE_GBE_WORKAROUND
-- cleaned_count++;
--#endif
-+ union iegbe_rx_desc_packet_split *rx_desc, *next_rxd;
-+ struct net_device *netdev = adapter->netdev;
-+ struct pci_dev *pdev = adapter->pdev;
-+ struct iegbe_buffer *buffer_info, *next_buffer;
-+ struct iegbe_ps_page *ps_page;
-+ struct iegbe_ps_page_dma *ps_page_dma;
-+ struct sk_buff *skb;
-+ unsigned int i, j;
-+ u32 length, staterr;
-+ int cleaned_count = 0;
-+ bool cleaned = false;
-+ unsigned int total_rx_bytes=0, total_rx_packets=0;
-+
-+ i = rx_ring->next_to_clean;
-+ rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
-+ staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
-+ buffer_info = &rx_ring->buffer_info[i];
-
-- pci_unmap_single(pdev, buffer_info->dma,
-- buffer_info->length,
-- PCI_DMA_FROMDEVICE);
-+ while(staterr & E1000_RXD_STAT_DD) {
-+ ps_page = &rx_ring->ps_page[i];
-+ ps_page_dma = &rx_ring->ps_page_dma[i];
-+
-+ if (unlikely(*work_done >= work_to_do))
-+ break;
-+ (*work_done)++;
-
- skb = buffer_info->skb;
-+ prefetch(skb->data - NET_IP_ALIGN);
-+ if (++i == rx_ring->count) i = 0;
-+ next_rxd = E1000_RX_DESC_PS(*rx_ring, i);
-+ prefetch(next_rxd);
-+ next_buffer = &rx_ring->buffer_info[i];
-+ cleaned = true;
-+ cleaned_count++;
-+ pci_unmap_single(pdev, buffer_info->dma,
-+ buffer_info->length,
-+ PCI_DMA_FROMDEVICE);
-+
-+ if(unlikely(!(staterr & E1000_RXD_STAT_EOP))) {
-+ E1000_DBG("%s: Packet Split buffers didn't pick up"
-+ " the full packet\n", netdev->name);
-+ dev_kfree_skb_irq(skb);
-+ goto next_desc;
-+ }
-
-- if(unlikely(!(staterr & E1000_RXD_STAT_EOP))) {
-- E1000_DBG("%s: Packet Split buffers didn't pick up"
-- " the full packet\n", netdev->name);
-- dev_kfree_skb_irq(skb);
-- goto next_desc;
-- }
--
-- if(unlikely(staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
-- dev_kfree_skb_irq(skb);
-- goto next_desc;
-- }
--
-- length = le16_to_cpu(rx_desc->wb.middle.length0);
-+ if(unlikely(staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
-+ dev_kfree_skb_irq(skb);
-+ goto next_desc;
-+ }
-
-- if(unlikely(!length)) {
-- E1000_DBG("%s: Last part of the packet spanning"
-- " multiple descriptors\n", netdev->name);
-- dev_kfree_skb_irq(skb);
-- goto next_desc;
-- }
-+ length = le16_to_cpu(rx_desc->wb.middle.length0);
-
-- /* Good Receive */
-- skb_put(skb, length);
--
-- for(j = 0; j < adapter->rx_ps_pages; j++) {
-- if(!(length = le16_to_cpu(rx_desc->wb.upper.length[j]))) {
-- break;
-- }
-- pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j],
-- PAGE_SIZE, PCI_DMA_FROMDEVICE);
-- ps_page_dma->ps_page_dma[j] = 0;
-- skb_shinfo(skb)->frags[j].page =
-- ps_page->ps_page[j];
-- ps_page->ps_page[j] = NULL;
-- skb_shinfo(skb)->frags[j].page_offset = 0;
-- skb_shinfo(skb)->frags[j].size = length;
-- skb_shinfo(skb)->nr_frags++;
-- skb->len += length;
-- skb->data_len += length;
-- }
-+ if(unlikely(!length)) {
-+ E1000_DBG("%s: Last part of the packet spanning"
-+ " multiple descriptors\n", netdev->name);
-+ dev_kfree_skb_irq(skb);
-+ goto next_desc;
-+ }
-
-- iegbe_rx_checksum(adapter, staterr,
-- rx_desc->wb.lower.hi_dword.csum_ip.csum, skb);
-- skb->protocol = eth_type_trans(skb, netdev);
-+ /* Good Receive */
-+ skb_put(skb, length);
-
-- if(likely(rx_desc->wb.upper.header_status &
-- E1000_RXDPS_HDRSTAT_HDRSP)) {
-- adapter->rx_hdr_split++;
--#ifdef HAVE_RX_ZERO_COPY
-- skb_shinfo(skb)->zero_copy = TRUE;
--#endif
-- }
--#ifdef CONFIG_E1000_NAPI
--#ifdef NETIF_F_HW_VLAN_TX
-- if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
-- vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
-- le16_to_cpu(rx_desc->wb.middle.vlan) &
-- E1000_RXD_SPC_VLAN_MASK);
-- } else {
-- netif_receive_skb(skb);
-- }
--#else
-- netif_receive_skb(skb);
--#endif
--#else /* CONFIG_E1000_NAPI */
--#ifdef NETIF_F_HW_VLAN_TX
-- if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
-- vlan_hwaccel_rx(skb, adapter->vlgrp,
-- le16_to_cpu(rx_desc->wb.middle.vlan) &
-- E1000_RXD_SPC_VLAN_MASK);
-- } else {
-- netif_rx(skb);
-- }
--#else
-- netif_rx(skb);
--#endif
--#endif /* CONFIG_E1000_NAPI */
-- netdev->last_rx = jiffies;
-- rx_ring->pkt++;
-+ {
-+ int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]);
-+ if (l1 && (l1 <= copybreak) && ((length + l1) <= adapter->rx_ps_bsize0)) {
-+ u8 *vaddr;
-+ pci_dma_sync_single_for_cpu(pdev,
-+ ps_page_dma->ps_page_dma[0],
-+ PAGE_SIZE,
-+ PCI_DMA_FROMDEVICE);
-+ vaddr = kmap_atomic(ps_page->ps_page[0],
-+ KM_SKB_DATA_SOFTIRQ);
-+ memcpy(skb_tail_pointer(skb), vaddr, l1);
-+ kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
-+ pci_dma_sync_single_for_device(pdev,
-+ ps_page_dma->ps_page_dma[0],
-+ PAGE_SIZE, PCI_DMA_FROMDEVICE);
-+ l1 -= 4;
-+ skb_put(skb, l1);
-+ goto copydone;
-+ } /* if */
-+ }
-+ for (j = 0; j < adapter->rx_ps_pages; j++) {
-+ length = le16_to_cpu(rx_desc->wb.upper.length[j]);
-+ if (!length)
-+ break;
-+ pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j],
-+ PAGE_SIZE, PCI_DMA_FROMDEVICE);
-+ ps_page_dma->ps_page_dma[j] = 0;
-+ skb_fill_page_desc(skb, j, ps_page->ps_page[j], 0,
-+ length);
-+ ps_page->ps_page[j] = NULL;
-+ skb->len += length;
-+ skb->data_len += length;
-+ skb->truesize += length;
-+ }
-
--next_desc:
-- rx_desc->wb.middle.status_error &= ~0xFF;
-- buffer_info->skb = NULL;
-- if(unlikely(++i == rx_ring->count)) { i = 0; }
-+ pskb_trim(skb, skb->len - 4);
-+copydone:
-+ total_rx_bytes += skb->len;
-+ total_rx_packets++;
-+ iegbe_rx_checksum(adapter, staterr,
-+ le16_to_cpu(rx_desc->wb.lower.hi_dword.csum_ip.csum), skb);
-+ skb->protocol = eth_type_trans(skb, netdev);
-+
-+ if(likely(rx_desc->wb.upper.header_status &
-+ cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)))
-+ adapter->rx_hdr_split++;
-+
-+ if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
-+ vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
-+ le16_to_cpu(rx_desc->wb.middle.vlan));
-+ } else {
-+ netif_receive_skb(skb);
-+ }
-
-- rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
-- staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
-- }
-- rx_ring->next_to_clean = i;
-+ netdev->last_rx = jiffies;
-
--#ifdef IEGBE_GBE_WORKAROUND
-- /* Only allocate the number of buffers that we have actually
-- cleaned! */
-- if (cleaned_count) {
-- adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
-- }
--#else
-- adapter->alloc_rx_buf(adapter, rx_ring);
--#endif
-+next_desc:
-+ rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF);
-+ buffer_info->skb = NULL;
-
-- return cleaned;
-+ if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
-+ adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
-+ cleaned_count = 0;
-+ }
-+
-+ /* use prefetched values */
-+ rx_desc = next_rxd;
-+ buffer_info = next_buffer;
-+ staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
-+ }
-+ rx_ring->next_to_clean = i;
-+
-+ cleaned_count = E1000_DESC_UNUSED(rx_ring);
-+ if (cleaned_count)
-+ adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
-+
-+ adapter->total_rx_packets += total_rx_packets;
-+ adapter->total_rx_bytes += total_rx_bytes;
-+ adapter->net_stats.rx_bytes += total_rx_bytes;
-+ adapter->net_stats.rx_packets += total_rx_packets;
-+ return cleaned;
- }
-
- /**
-@@ -4269,142 +4038,115 @@ next_desc:
- * @adapter: address of board private structure
- **/
-
--#ifdef IEGBE_GBE_WORKAROUND
--static void
--iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
-+
-+static void iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rx_ring,
- int cleaned_count)
--#else
--static void
--iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
-- struct iegbe_rx_ring *rx_ring)
--#endif
- {
-- struct net_device *netdev = adapter->netdev;
-- struct pci_dev *pdev = adapter->pdev;
-- struct iegbe_rx_desc *rx_desc;
-- struct iegbe_buffer *buffer_info;
-- struct sk_buff *skb;
-- unsigned int i;
-- unsigned int bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
--
-- i = rx_ring->next_to_use;
-- buffer_info = &rx_ring->buffer_info[i];
-+ struct iegbe_hw *hw = &adapter->hw;
-+ struct net_device *netdev = adapter->netdev;
-+ struct pci_dev *pdev = adapter->pdev;
-+ struct iegbe_rx_desc *rx_desc;
-+ struct iegbe_buffer *buffer_info;
-+ struct sk_buff *skb;
-+ unsigned int i;
-+ unsigned int bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
-
--#ifdef IEGBE_GBE_WORKAROUND
-- if (cleaned_count > IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS) {
-- adapter->stats.cc_gt_num_rx++;
-- }
-- while(cleaned_count-- && !buffer_info->skb) {
--#else
-- while(!buffer_info->skb) {
--#endif
-- skb = dev_alloc_skb(bufsz);
-+ i = rx_ring->next_to_use;
-+ buffer_info = &rx_ring->buffer_info[i];
-
-- if(unlikely(!skb)) {
-- /* Better luck next round */
-- break;
-- }
-+ while (cleaned_count--) {
-+ skb = buffer_info->skb;
-+ if (skb) {
-+ skb_trim(skb, 0);
-+ goto map_skb;
-+ }
-+ skb = netdev_alloc_skb(netdev, bufsz);
-+
-+ if(unlikely(!skb)) {
-+ /* Better luck next round */
-+ adapter->alloc_rx_buff_failed++;
-+ break;
-+ }
-
-- /* Fix for errata 23, can't cross 64kB boundary */
-- if(!iegbe_check_64k_bound(adapter, skb->data, bufsz)) {
-- struct sk_buff *oldskb = skb;
-- DPRINTK(RX_ERR, ERR, "skb align check failed: %u bytes "
-- "at %p\n", bufsz, skb->data);
-- /* Try again, without freeing the previous */
-- skb = dev_alloc_skb(bufsz);
-- /* Failed allocation, critical failure */
-- if(!skb) {
-- dev_kfree_skb(oldskb);
-- break;
-- }
-+ /* Fix for errata 23, can't cross 64kB boundary */
-+ if(!iegbe_check_64k_bound(adapter, skb->data, bufsz)) {
-+ struct sk_buff *oldskb = skb;
-+ DPRINTK(RX_ERR, ERR, "skb align check failed: %u bytes "
-+ "at %p\n", bufsz, skb->data);
-+ /* Try again, without freeing the previous */
-+ skb = netdev_alloc_skb(netdev, bufsz);
-+ /* Failed allocation, critical failure */
-+ if(!skb) {
-+ dev_kfree_skb(oldskb);
-+ break;
-+ }
-
-- if(!iegbe_check_64k_bound(adapter, skb->data, bufsz)) {
-- /* give up */
-- dev_kfree_skb(skb);
-- dev_kfree_skb(oldskb);
-- break; /* while !buffer_info->skb */
-- } else {
-- /* Use new allocation */
-- dev_kfree_skb(oldskb);
-+ if(!iegbe_check_64k_bound(adapter, skb->data, bufsz)) {
-+ /* give up */
-+ dev_kfree_skb(skb);
-+ dev_kfree_skb(oldskb);
-+ break; /* while !buffer_info->skb */
- }
-- }
-- /* Make buffer alignment 2 beyond a 16 byte boundary
-- * this will result in a 16 byte aligned IP header after
-- * the 14 byte MAC header is removed
-- */
-- skb_reserve(skb, NET_IP_ALIGN);
--
-- skb->dev = netdev;
--
-- buffer_info->skb = skb;
-- buffer_info->length = adapter->rx_buffer_len;
-- buffer_info->dma = pci_map_single(pdev,
-- skb->data,
-- adapter->rx_buffer_len,
-- PCI_DMA_FROMDEVICE);
--
-- /* Fix for errata 23, can't cross 64kB boundary */
-- if(!iegbe_check_64k_bound(adapter,
-- (void *)(unsigned long)buffer_info->dma,
-- adapter->rx_buffer_len)) {
-- DPRINTK(RX_ERR, ERR,
-- "dma align check failed: %u bytes at %p\n",
-- adapter->rx_buffer_len,
-- (void *)(unsigned long)buffer_info->dma);
-- dev_kfree_skb(skb);
-- buffer_info->skb = NULL;
--
-- pci_unmap_single(pdev, buffer_info->dma,
-- adapter->rx_buffer_len,
-- PCI_DMA_FROMDEVICE);
--
-- break; /* while !buffer_info->skb */
-- }
-- rx_desc = E1000_RX_DESC(*rx_ring, i);
-- rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
--
--#ifdef IEGBE_GBE_WORKAROUND_DISABLED
-- adapter->stats.num_rx_buf_alloc++;
-+ /* Use new allocation */
-+ dev_kfree_skb(oldskb);
-+ }
-+ /* Make buffer alignment 2 beyond a 16 byte boundary
-+ * this will result in a 16 byte aligned IP header after
-+ * the 14 byte MAC header is removed
-+ */
-+ skb_reserve(skb, NET_IP_ALIGN);
-+
-+
-+ buffer_info->skb = skb;
-+ buffer_info->length = adapter->rx_buffer_len;
-+map_skb:
-+ buffer_info->dma = pci_map_single(pdev,
-+ skb->data,
-+ adapter->rx_buffer_len,
-+ PCI_DMA_FROMDEVICE);
-+
-+ /* Fix for errata 23, can't cross 64kB boundary */
-+ if(!iegbe_check_64k_bound(adapter,
-+ (void *)(unsigned long)buffer_info->dma,
-+ adapter->rx_buffer_len)) {
-+ DPRINTK(RX_ERR, ERR,
-+ "dma align check failed: %u bytes at %p\n",
-+ adapter->rx_buffer_len,
-+ (void *)(unsigned long)buffer_info->dma);
-+ dev_kfree_skb(skb);
-+ buffer_info->skb = NULL;
-+
-+ pci_unmap_single(pdev, buffer_info->dma,
-+ adapter->rx_buffer_len,
-+ PCI_DMA_FROMDEVICE);
-
-- /* Force memory writes to complete before letting h/w
-- * know there are new descriptors to fetch. (Only
-- * applicable for weak-ordered memory model archs,
-- * such as IA-64). */
-- wmb();
-- writel(i, adapter->hw.hw_addr + rx_ring->rdt);
-+ break; /* while !buffer_info->skb */
-+ }
-+ rx_desc = E1000_RX_DESC(*rx_ring, i);
-+ rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
-
--#endif
--#ifndef IEGBE_GBE_WORKAROUND
-- if(unlikely((i & ~(E1000_RX_BUFFER_WRITE - 0x1)) == i)) {
-- /* Force memory writes to complete before letting h/w
-- * know there are new descriptors to fetch. (Only
-- * applicable for weak-ordered memory model archs,
-- * such as IA-64). */
-- wmb();
-- writel(i, adapter->hw.hw_addr + rx_ring->rdt);
-- }
--#endif
-- if(unlikely(++i == rx_ring->count)) { i = 0; }
-- buffer_info = &rx_ring->buffer_info[i];
-- }
-+ /* Force memory writes to complete before letting h/w
-+ * know there are new descriptors to fetch. (Only
-+ * applicable for weak-ordered memory model archs,
-+ * such as IA-64). */
-+ if (unlikely(++i == rx_ring->count))
-+ i = 0;
-+ buffer_info = &rx_ring->buffer_info[i];
-+ }
-
--#ifdef IEGBE_GBE_WORKAROUND
- if (likely(rx_ring->next_to_use != i)) {
-- rx_ring->next_to_use = i;
-- if (unlikely(i-- == 0)) {
-- i = (rx_ring->count - 0x1);
-- }
-+ rx_ring->next_to_use = i;
-+ if (unlikely(i-- == 0))
-+ i = (rx_ring->count - 1);
-+
- /* Force memory writes to complete before letting h/w
- * know there are new descriptors to fetch. (Only
- * applicable for weak-ordered memory model archs,
- * such as IA-64). */
- wmb();
-- writel(i, adapter->hw.hw_addr + rx_ring->rdt);
-+ writel(i, hw->hw_addr + rx_ring->rdt);
- }
--#else
-- rx_ring->next_to_use = i;
--#endif
- }
-
- /**
-@@ -4412,49 +4154,41 @@ iegbe_alloc_rx_buffers(struct iegbe_adap
- * @adapter: address of board private structure
- **/
-
--#ifdef IEGBE_GBE_WORKAROUND
--static void
--iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
-+
-+static void iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
- struct iegbe_rx_ring *rx_ring,
- int cleaned_count)
--#else
--static void
--iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
-- struct iegbe_rx_ring *rx_ring)
--#endif
- {
-- struct net_device *netdev = adapter->netdev;
-- struct pci_dev *pdev = adapter->pdev;
-- union iegbe_rx_desc_packet_split *rx_desc;
-- struct iegbe_buffer *buffer_info;
-- struct iegbe_ps_page *ps_page;
-- struct iegbe_ps_page_dma *ps_page_dma;
-- struct sk_buff *skb;
-- unsigned int i, j;
--
-- i = rx_ring->next_to_use;
-- buffer_info = &rx_ring->buffer_info[i];
-- ps_page = &rx_ring->ps_page[i];
-- ps_page_dma = &rx_ring->ps_page_dma[i];
-+ struct iegbe_hw *hw = &adapter->hw;
-+ struct net_device *netdev = adapter->netdev;
-+ struct pci_dev *pdev = adapter->pdev;
-+ union iegbe_rx_desc_packet_split *rx_desc;
-+ struct iegbe_buffer *buffer_info;
-+ struct iegbe_ps_page *ps_page;
-+ struct iegbe_ps_page_dma *ps_page_dma;
-+ struct sk_buff *skb;
-+ unsigned int i, j;
-+
-+ i = rx_ring->next_to_use;
-+ buffer_info = &rx_ring->buffer_info[i];
-+ ps_page = &rx_ring->ps_page[i];
-+ ps_page_dma = &rx_ring->ps_page_dma[i];
-
--#ifdef IEGBE_GBE_WORKAROUND
-- while(cleaned_count-- && !buffer_info->skb) {
--#else
-- while(!buffer_info->skb) {
--#endif
-- rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
-+ while (cleaned_count--) {
-+ rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
-
- for (j = 0; j < PS_PAGE_BUFFERS; j++) {
-- if (j < adapter->rx_ps_pages) {
-- if (likely(!ps_page->ps_page[j])) {
-- ps_page->ps_page[j] =
-- alloc_page(GFP_ATOMIC);
-+ if (j < adapter->rx_ps_pages) {
-+ if (likely(!ps_page->ps_page[j])) {
-+ ps_page->ps_page[j] =
-+ alloc_page(GFP_ATOMIC);
- if (unlikely(!ps_page->ps_page[j])) {
-- goto no_buffers;
-+ adapter->alloc_rx_buff_failed++;
-+ goto no_buffers;
- }
-- ps_page_dma->ps_page_dma[j] =
-- pci_map_page(pdev,
-- ps_page->ps_page[j],
-+ ps_page_dma->ps_page_dma[j] =
-+ pci_map_page(pdev,
-+ ps_page->ps_page[j],
- 0, PAGE_SIZE,
- PCI_DMA_FROMDEVICE);
- }
-@@ -4462,26 +4196,26 @@ iegbe_alloc_rx_buffers_ps(struct iegbe_a
- * change because each write-back erases
- * this info.
- */
-- rx_desc->read.buffer_addr[j+0x1] =
-+ rx_desc->read.buffer_addr[j+1] =
- cpu_to_le64(ps_page_dma->ps_page_dma[j]);
-- } else {
-- rx_desc->read.buffer_addr[j+0x1] = ~0;
-- }
-+ } else
-+ rx_desc->read.buffer_addr[j+1] = ~cpu_to_le64(0);
- }
-
-- skb = dev_alloc_skb(adapter->rx_ps_bsize0 + NET_IP_ALIGN);
-+ skb = netdev_alloc_skb(netdev,
-+ adapter->rx_ps_bsize0 + NET_IP_ALIGN);
-
-- if (unlikely(!skb)) {
-+ if (unlikely(!skb)) {
-+ adapter->alloc_rx_buff_failed++;
- break;
-- }
-+ }
-+
- /* Make buffer alignment 2 beyond a 16 byte boundary
- * this will result in a 16 byte aligned IP header after
- * the 14 byte MAC header is removed
- */
- skb_reserve(skb, NET_IP_ALIGN);
-
-- skb->dev = netdev;
--
- buffer_info->skb = skb;
- buffer_info->length = adapter->rx_ps_bsize0;
- buffer_info->dma = pci_map_single(pdev, skb->data,
-@@ -4490,27 +4224,28 @@ iegbe_alloc_rx_buffers_ps(struct iegbe_a
-
- rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma);
-
-- if (unlikely((i & ~(E1000_RX_BUFFER_WRITE - 0x1)) == i)) {
-- /* Force memory writes to complete before letting h/w
-- * know there are new descriptors to fetch. (Only
-- * applicable for weak-ordered memory model archs,
-- * such as IA-64). */
-- wmb();
-- /* Hardware increments by 16 bytes, but packet split
-- * descriptors are 32 bytes...so we increment tail
-- * twice as much.
-- */
-- writel(i<<1, adapter->hw.hw_addr + rx_ring->rdt);
-- }
--
-- if (unlikely(++i == rx_ring->count)) { i = 0; }
-+ if (unlikely(++i == rx_ring->count)) i = 0;
- buffer_info = &rx_ring->buffer_info[i];
- ps_page = &rx_ring->ps_page[i];
- ps_page_dma = &rx_ring->ps_page_dma[i];
- }
-
- no_buffers:
-- rx_ring->next_to_use = i;
-+ if (likely(rx_ring->next_to_use != i)) {
-+ rx_ring->next_to_use = i;
-+ if (unlikely(i-- == 0)) i = (rx_ring->count - 1);
-+
-+ /* Force memory writes to complete before letting h/w
-+ * know there are new descriptors to fetch. (Only
-+ * applicable for weak-ordered memory model archs,
-+ * such as IA-64). */
-+ wmb();
-+ /* Hardware increments by 16 bytes, but packet split
-+ * descriptors are 32 bytes...so we increment tail
-+ * twice as much.
-+ */
-+ writel(i<<1, hw->hw_addr + rx_ring->rdt);
-+ }
- }
-
- /**
-@@ -4521,52 +4256,52 @@ no_buffers:
- static void
- iegbe_smartspeed(struct iegbe_adapter *adapter)
- {
-- uint16_t phy_status;
-- uint16_t phy_ctrl;
-+ uint16_t phy_status;
-+ uint16_t phy_ctrl;
-
-- if((adapter->hw.phy_type != iegbe_phy_igp) || !adapter->hw.autoneg ||
-+ if((adapter->hw.phy_type != iegbe_phy_igp) || !adapter->hw.autoneg ||
- !(adapter->hw.autoneg_advertised & ADVERTISE_1000_FULL)) {
-- return;
-+ return;
- }
-- if(adapter->smartspeed == 0) {
-- /* If Master/Slave config fault is asserted twice,
-- * we assume back-to-back */
-- iegbe_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
-+ if(adapter->smartspeed == 0x0) {
-+ /* If Master/Slave config fault is asserted twice,
-+ * we assume back-to-back */
-+ iegbe_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
- if(!(phy_status & SR_1000T_MS_CONFIG_FAULT)) { return; }
-- iegbe_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
-+ iegbe_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
- if(!(phy_status & SR_1000T_MS_CONFIG_FAULT)) { return; }
-- iegbe_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
-- if(phy_ctrl & CR_1000T_MS_ENABLE) {
-- phy_ctrl &= ~CR_1000T_MS_ENABLE;
-- iegbe_write_phy_reg(&adapter->hw, PHY_1000T_CTRL,
-- phy_ctrl);
-- adapter->smartspeed++;
-- if(!iegbe_phy_setup_autoneg(&adapter->hw) &&
-- !iegbe_read_phy_reg(&adapter->hw, PHY_CTRL,
-- &phy_ctrl)) {
-- phy_ctrl |= (MII_CR_AUTO_NEG_EN |
-- MII_CR_RESTART_AUTO_NEG);
-- iegbe_write_phy_reg(&adapter->hw, PHY_CTRL,
-- phy_ctrl);
-- }
-- }
-- return;
-- } else if(adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) {
-- /* If still no link, perhaps using 2/3 pair cable */
-- iegbe_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
-- phy_ctrl |= CR_1000T_MS_ENABLE;
-- iegbe_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, phy_ctrl);
-- if(!iegbe_phy_setup_autoneg(&adapter->hw) &&
-- !iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_ctrl)) {
-- phy_ctrl |= (MII_CR_AUTO_NEG_EN |
-- MII_CR_RESTART_AUTO_NEG);
-- iegbe_write_phy_reg(&adapter->hw, PHY_CTRL, phy_ctrl);
-- }
-- }
-- /* Restart process after E1000_SMARTSPEED_MAX iterations */
-+ iegbe_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
-+ if(phy_ctrl & CR_1000T_MS_ENABLE) {
-+ phy_ctrl &= ~CR_1000T_MS_ENABLE;
-+ iegbe_write_phy_reg(&adapter->hw, PHY_1000T_CTRL,
-+ phy_ctrl);
-+ adapter->smartspeed++;
-+ if(!iegbe_phy_setup_autoneg(&adapter->hw) &&
-+ !iegbe_read_phy_reg(&adapter->hw, PHY_CTRL,
-+ &phy_ctrl)) {
-+ phy_ctrl |= (MII_CR_AUTO_NEG_EN |
-+ MII_CR_RESTART_AUTO_NEG);
-+ iegbe_write_phy_reg(&adapter->hw, PHY_CTRL,
-+ phy_ctrl);
-+ }
-+ }
-+ return;
-+ } else if(adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) {
-+ /* If still no link, perhaps using 2/3 pair cable */
-+ iegbe_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
-+ phy_ctrl |= CR_1000T_MS_ENABLE;
-+ iegbe_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, phy_ctrl);
-+ if(!iegbe_phy_setup_autoneg(&adapter->hw) &&
-+ !iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_ctrl)) {
-+ phy_ctrl |= (MII_CR_AUTO_NEG_EN |
-+ MII_CR_RESTART_AUTO_NEG);
-+ iegbe_write_phy_reg(&adapter->hw, PHY_CTRL, phy_ctrl);
-+ }
-+ }
-+ /* Restart process after E1000_SMARTSPEED_MAX iterations */
- if(adapter->smartspeed++ == E1000_SMARTSPEED_MAX) {
-- adapter->smartspeed = 0;
--}
-+ adapter->smartspeed = 0x0;
-+ }
- }
-
- /**
-@@ -4576,23 +4311,22 @@ iegbe_smartspeed(struct iegbe_adapter *a
- * @cmd:
- **/
-
--static int
--iegbe_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
-+static int iegbe_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
- {
-- switch (cmd) {
-+ switch (cmd) {
- #ifdef SIOCGMIIPHY
-- case SIOCGMIIPHY:
-- case SIOCGMIIREG:
-- case SIOCSMIIREG:
-- return iegbe_mii_ioctl(netdev, ifr, cmd);
-+ case SIOCGMIIPHY:
-+ case SIOCGMIIREG:
-+ case SIOCSMIIREG:
-+ return iegbe_mii_ioctl(netdev, ifr, cmd);
- #endif
- #ifdef ETHTOOL_OPS_COMPAT
-- case SIOCETHTOOL:
-- return ethtool_ioctl(ifr);
-+ case SIOCETHTOOL:
-+ return ethtool_ioctl(ifr);
- #endif
-- default:
-- return -EOPNOTSUPP;
-- }
-+ default:
-+ return -EOPNOTSUPP;
-+ }
- }
-
- #ifdef SIOCGMIIPHY
-@@ -4603,534 +4337,510 @@ iegbe_ioctl(struct net_device *netdev, s
- * @cmd:
- **/
-
--static int
--iegbe_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
-+static int iegbe_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
-+ int cmd)
- {
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-- struct mii_ioctl_data *data = if_mii(ifr);
-- int retval;
-- uint16_t mii_reg;
-- uint16_t spddplx;
-- unsigned long flags;
--
-- if((adapter->hw.media_type == iegbe_media_type_oem &&
-- !iegbe_oem_phy_is_copper(&adapter->hw)) ||
-- adapter->hw.media_type == iegbe_media_type_fiber ||
-- adapter->hw.media_type == iegbe_media_type_internal_serdes ) {
-- return -EOPNOTSUPP;
-- }
-- switch (cmd) {
-- case SIOCGMIIPHY:
-- data->phy_id = adapter->hw.phy_addr;
-- break;
-- case SIOCGMIIREG:
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ struct mii_ioctl_data *data = if_mii(ifr);
-+ int retval;
-+ uint16_t mii_reg;
-+ uint16_t spddplx;
-+ unsigned long flags = 0;
-+
-+ if((adapter->hw.media_type == iegbe_media_type_oem
-+ && !iegbe_oem_phy_is_copper(&adapter->hw))
-+ ||adapter->hw.media_type != iegbe_media_type_copper) {
-+ return -EOPNOTSUPP;
-+ }
-+ switch (cmd) {
-+ case SIOCGMIIPHY:
-+ data->phy_id = adapter->hw.phy_addr;
-+ break;
-+ case SIOCGMIIREG:
- if(!capable(CAP_NET_ADMIN)) {
-- return -EPERM;
-+ return -EPERM;
- }
-- spin_lock_irqsave(&adapter->stats_lock, flags);
-- if(iegbe_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
-- &data->val_out)) {
-- spin_unlock_irqrestore(&adapter->stats_lock, flags);
-- return -EIO;
-- }
-- spin_unlock_irqrestore(&adapter->stats_lock, flags);
-- break;
-- case SIOCSMIIREG:
-+ spin_lock_irqsave(&adapter->stats_lock, flags);
-+ if(iegbe_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
-+ &data->val_out)) {
-+ spin_unlock_irqrestore(&adapter->stats_lock, flags);
-+ return -EIO;
-+ }
-+ spin_unlock_irqrestore(&adapter->stats_lock, flags);
-+ break;
-+ case SIOCSMIIREG:
- if(!capable(CAP_NET_ADMIN)){
-- return -EPERM;
-+ return -EPERM;
- }
- if(data->reg_num & ~(0x1F)) {
-- return -EFAULT;
-+ return -EFAULT;
- }
-- mii_reg = data->val_in;
-- spin_lock_irqsave(&adapter->stats_lock, flags);
-- if(iegbe_write_phy_reg(&adapter->hw, data->reg_num,
-- mii_reg)) {
-- spin_unlock_irqrestore(&adapter->stats_lock, flags);
-- return -EIO;
-- }
-- switch(adapter->hw.phy_type) {
-- case iegbe_phy_m88:
-- switch (data->reg_num) {
-- case PHY_CTRL:
-+ mii_reg = data->val_in;
-+ spin_lock_irqsave(&adapter->stats_lock, flags);
-+ if(iegbe_write_phy_reg(&adapter->hw, data->reg_num,
-+ mii_reg)) {
-+ spin_unlock_irqrestore(&adapter->stats_lock, flags);
-+ return -EIO;
-+ }
-+ switch(adapter->hw.phy_type) {
-+ case iegbe_phy_m88:
-+ switch (data->reg_num) {
-+ case PHY_CTRL:
- if(mii_reg & MII_CR_POWER_DOWN) {
-- break;
-+ break;
- }
-- if(mii_reg & MII_CR_AUTO_NEG_EN) {
-- adapter->hw.autoneg = 1;
-- adapter->hw.autoneg_advertised = 0x2F;
-- } else {
-+ if(mii_reg & MII_CR_AUTO_NEG_EN) {
-+ adapter->hw.autoneg = 1;
-+ adapter->hw.autoneg_advertised = 0x2F;
-+ } else {
- if(mii_reg & 0x40){
-- spddplx = SPEED_1000;
-+ spddplx = SPEED_1000;
- } else if(mii_reg & 0x2000) {
-- spddplx = SPEED_100;
-+ spddplx = SPEED_100;
- } else {
-- spddplx = SPEED_10;
-+ spddplx = SPEED_10;
- }
-- spddplx += (mii_reg & 0x100)
-- ? FULL_DUPLEX :
-- HALF_DUPLEX;
-- retval = iegbe_set_spd_dplx(adapter,
-- spddplx);
-- if(retval) {
-- spin_unlock_irqrestore(
-- &adapter->stats_lock,
-- flags);
-- return retval;
-- }
-- }
-- if(netif_running(adapter->netdev)) {
-- iegbe_down(adapter);
-- iegbe_up(adapter);
-+ spddplx += (mii_reg & 0x100)
-+ ? FULL_DUPLEX :
-+ HALF_DUPLEX;
-+ retval = iegbe_set_spd_dplx(adapter,
-+ spddplx);
-+ if(retval) {
-+ spin_unlock_irqrestore(
-+ &adapter->stats_lock,
-+ flags);
-+ return retval;
-+ }
-+ }
-+ if(netif_running(adapter->netdev)) {
-+ iegbe_down(adapter);
-+ iegbe_up(adapter);
- } else {
-- iegbe_reset(adapter);
-+ iegbe_reset(adapter);
- }
-- break;
-- case M88E1000_PHY_SPEC_CTRL:
-- case M88E1000_EXT_PHY_SPEC_CTRL:
-- if(iegbe_phy_reset(&adapter->hw)) {
-- spin_unlock_irqrestore(
-- &adapter->stats_lock, flags);
-- return -EIO;
-- }
-- break;
-- }
-- break;
-+ break;
-+ case M88E1000_PHY_SPEC_CTRL:
-+ case M88E1000_EXT_PHY_SPEC_CTRL:
-+ if(iegbe_phy_reset(&adapter->hw)) {
-+ spin_unlock_irqrestore(
-+ &adapter->stats_lock, flags);
-+ return -EIO;
-+ }
-+ break;
-+ }
-+ break;
-
-- case iegbe_phy_oem:
-- retval = iegbe_oem_mii_ioctl(adapter, flags, ifr, cmd);
-- if(retval) {
-- spin_unlock_irqrestore(
-- &adapter->stats_lock, flags);
-- return retval;
-- }
-- break;
-+ case iegbe_phy_oem:
-+ retval = iegbe_oem_mii_ioctl(adapter, flags, ifr, cmd);
-+ if(retval) {
-+ spin_unlock_irqrestore(
-+ &adapter->stats_lock, flags);
-+ return retval;
-+ }
-+ break;
-
-- default:
-- switch (data->reg_num) {
-- case PHY_CTRL:
-+ default:
-+ switch (data->reg_num) {
-+ case PHY_CTRL:
- if(mii_reg & MII_CR_POWER_DOWN) {
-- break;
-+ break;
- }
-- if(netif_running(adapter->netdev)) {
-- iegbe_down(adapter);
-- iegbe_up(adapter);
-+ if(netif_running(adapter->netdev)) {
-+ iegbe_down(adapter);
-+ iegbe_up(adapter);
- } else {
-- iegbe_reset(adapter);
-+ iegbe_reset(adapter);
- }
-- break;
-- }
-- }
-- spin_unlock_irqrestore(&adapter->stats_lock, flags);
-- break;
-- default:
-- return -EOPNOTSUPP;
-- }
-- return E1000_SUCCESS;
-+ break;
-+ }
-+ }
-+ spin_unlock_irqrestore(&adapter->stats_lock, flags);
-+ break;
-+ default:
-+ return -EOPNOTSUPP;
-+ }
-+ return E1000_SUCCESS;
- }
- #endif
-
--void
--iegbe_pci_set_mwi(struct iegbe_hw *hw)
-+void iegbe_pci_set_mwi(struct iegbe_hw *hw)
- {
-- struct iegbe_adapter *adapter = hw->back;
--#ifdef HAVE_PCI_SET_MWI
-- int ret_val = pci_set_mwi(adapter->pdev);
--
-- if(ret_val) {
-- DPRINTK(PROBE, ERR, "Error in setting MWI\n");
-- }
--#else
-- pci_write_config_word(adapter->pdev, PCI_COMMAND,
-- adapter->hw.pci_cmd_word |
-- PCI_COMMAND_INVALIDATE);
--#endif
-+ struct iegbe_adapter *adapter = hw->back;
-+ int ret_val = pci_set_mwi(adapter->pdev);
-+
-+ if (ret_val)
-+ DPRINTK(PROBE, ERR, "Error in setting MWI\n");
- }
-
--void
--iegbe_pci_clear_mwi(struct iegbe_hw *hw)
-+void iegbe_pci_clear_mwi(struct iegbe_hw *hw)
- {
-- struct iegbe_adapter *adapter = hw->back;
-+ struct iegbe_adapter *adapter = hw->back;
-
--#ifdef HAVE_PCI_SET_MWI
-- pci_clear_mwi(adapter->pdev);
--#else
-- pci_write_config_word(adapter->pdev, PCI_COMMAND,
-- adapter->hw.pci_cmd_word &
-- ~PCI_COMMAND_INVALIDATE);
--#endif
-+ pci_clear_mwi(adapter->pdev);
- }
-
- void
- iegbe_read_pci_cfg(struct iegbe_hw *hw, uint32_t reg, uint16_t *value)
- {
-- struct iegbe_adapter *adapter = hw->back;
-+ struct iegbe_adapter *adapter = hw->back;
-
-- pci_read_config_word(adapter->pdev, reg, value);
-+ pci_read_config_word(adapter->pdev, reg, value);
- }
-
- void
- iegbe_write_pci_cfg(struct iegbe_hw *hw, uint32_t reg, uint16_t *value)
- {
-- struct iegbe_adapter *adapter = hw->back;
-+ struct iegbe_adapter *adapter = hw->back;
-
-- pci_write_config_word(adapter->pdev, reg, *value);
-+ pci_write_config_word(adapter->pdev, reg, *value);
- }
-
- uint32_t
- iegbe_io_read(struct iegbe_hw *hw, unsigned long port)
- {
-- return inl(port);
-+ return inl(port);
- }
-
- void
- iegbe_io_write(struct iegbe_hw *hw, unsigned long port, uint32_t value)
- {
-- outl(value, port);
-+ outl(value, port);
- }
-
--#ifdef NETIF_F_HW_VLAN_TX
--static void
--iegbe_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
-+static void iegbe_vlan_rx_register(struct net_device *netdev,
-+ struct vlan_group *grp)
- {
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-- uint32_t ctrl, rctl;
--
-- iegbe_irq_disable(adapter);
-- adapter->vlgrp = grp;
--
-- if(grp) {
-- /* enable VLAN tag insert/strip */
-- ctrl = E1000_READ_REG(&adapter->hw, CTRL);
-- ctrl |= E1000_CTRL_VME;
-- E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
--
-- /* enable VLAN receive filtering */
-- rctl = E1000_READ_REG(&adapter->hw, RCTL);
-- rctl |= E1000_RCTL_VFE;
-- rctl &= ~E1000_RCTL_CFIEN;
-- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
-- iegbe_update_mng_vlan(adapter);
-- } else {
-- /* disable VLAN tag insert/strip */
-- ctrl = E1000_READ_REG(&adapter->hw, CTRL);
-- ctrl &= ~E1000_CTRL_VME;
-- E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ uint32_t ctrl, rctl;
-
-- /* disable VLAN filtering */
-- rctl = E1000_READ_REG(&adapter->hw, RCTL);
-- rctl &= ~E1000_RCTL_VFE;
-- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
-- if(adapter->mng_vlan_id != (uint16_t)E1000_MNG_VLAN_NONE) {
-- iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
-- adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
-- }
-- }
-+ if (!test_bit(__E1000_DOWN, &adapter->flags))
-+ iegbe_irq_disable(adapter);
-+ adapter->vlgrp = grp;
-+
-+ if(grp) {
-+ /* enable VLAN tag insert/strip */
-+ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
-+ ctrl |= E1000_CTRL_VME;
-+ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
-+
-+ /* enable VLAN receive filtering */
-+ rctl = E1000_READ_REG(&adapter->hw, RCTL);
-+ rctl |= E1000_RCTL_VFE;
-+ rctl &= ~E1000_RCTL_CFIEN;
-+ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
-+ iegbe_update_mng_vlan(adapter);
-+ } else {
-+ /* disable VLAN tag insert/strip */
-+ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
-+ ctrl &= ~E1000_CTRL_VME;
-+ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
-+
-+ /* disable VLAN filtering */
-+ rctl = E1000_READ_REG(&adapter->hw, RCTL);
-+ rctl &= ~E1000_RCTL_VFE;
-+ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
-+ if(adapter->mng_vlan_id != (uint16_t)E1000_MNG_VLAN_NONE) {
-+ iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
-+ adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
-+ }
-+ }
-
-- iegbe_irq_enable(adapter);
-+ if (!test_bit(__E1000_DOWN, &adapter->flags))
-+ iegbe_irq_enable(adapter);
- }
-
--static void
--iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
-+static void iegbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
- {
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-- uint32_t vfta, index;
-- if((adapter->hw.mng_cookie.status &
-- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ uint32_t vfta, index;
-+ if((adapter->hw.mng_cookie.status &
-+ E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
- (vid == adapter->mng_vlan_id)) {
-- return;
-+ return;
- }
-- /* add VID to filter table */
-+ /* add VID to filter table */
- index = (vid >> 0x5) & 0x7F;
-- vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
-+ vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
- vfta |= (0x1 << (vid & 0x1F));
-- iegbe_write_vfta(&adapter->hw, index, vfta);
-+ iegbe_write_vfta(&adapter->hw, index, vfta);
- }
-
--static void
--iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
-+static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
- {
- struct iegbe_adapter *adapter = netdev_priv(netdev);
-- uint32_t vfta, index;
-+ u32 vfta, index;
-
-+ if (!test_bit(__E1000_DOWN, &adapter->flags))
- iegbe_irq_disable(adapter);
--
-- if(adapter->vlgrp) {
-- adapter->vlgrp->vlan_devices[vid] = NULL;
-- }
-+ vlan_group_set_device(adapter->vlgrp, vid, NULL);
-+ if (!test_bit(__E1000_DOWN, &adapter->flags))
- iegbe_irq_enable(adapter);
-
-- if((adapter->hw.mng_cookie.status &
-- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
-- (vid == adapter->mng_vlan_id)) {
-- return;
-- }
- /* remove VID from filter table */
-- index = (vid >> 0x5) & 0x7F;
-+ index = (vid >> 0x5) & 0x7F;
- vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
-- vfta &= ~(0x1 << (vid & 0x1F));
-+ vfta &= ~(0x1 << (vid & 0x1F));
- iegbe_write_vfta(&adapter->hw, index, vfta);
- }
-
--static void
--iegbe_restore_vlan(struct iegbe_adapter *adapter)
-+static void iegbe_restore_vlan(struct iegbe_adapter *adapter)
- {
- iegbe_vlan_rx_register(adapter->netdev, adapter->vlgrp);
-
-- if(adapter->vlgrp) {
-- uint16_t vid;
-- for(vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
-- if(!adapter->vlgrp->vlan_devices[vid]) {
-+ if (adapter->vlgrp) {
-+ u16 vid;
-+ for (vid = 0x0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
-+ if (!vlan_group_get_device(adapter->vlgrp, vid))
- continue;
-- }
- iegbe_vlan_rx_add_vid(adapter->netdev, vid);
- }
- }
- }
--#endif
-
--int
--iegbe_set_spd_dplx(struct iegbe_adapter *adapter, uint16_t spddplx)
-+
-+int iegbe_set_spd_dplx(struct iegbe_adapter *adapter, u16 spddplx)
- {
-- adapter->hw.autoneg = 0;
-+ adapter->hw.autoneg = 0x0;
-
-- /* Fiber NICs only allow 1000 gbps Full duplex */
-- if((adapter->hw.media_type == iegbe_media_type_fiber
-+ /* Fiber NICs only allow 1000 gbps Full duplex */
-+ if((adapter->hw.media_type == iegbe_media_type_fiber
- || (adapter->hw.media_type == iegbe_media_type_oem
- && !iegbe_oem_phy_is_copper(&adapter->hw)))
-- && spddplx != (SPEED_1000 + FULL_DUPLEX)) {
-- DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
-- return -EINVAL;
-- }
--
-- switch(spddplx) {
-- case SPEED_10 + HALF_DUPLEX:
-- adapter->hw.forced_speed_duplex = iegbe_10_half;
-- break;
-- case SPEED_10 + FULL_DUPLEX:
-- adapter->hw.forced_speed_duplex = iegbe_10_full;
-- break;
-- case SPEED_100 + HALF_DUPLEX:
-- adapter->hw.forced_speed_duplex = iegbe_100_half;
-- break;
-- case SPEED_100 + FULL_DUPLEX:
-- adapter->hw.forced_speed_duplex = iegbe_100_full;
-- break;
-- case SPEED_1000 + FULL_DUPLEX:
-+ && spddplx != (SPEED_1000 + DUPLEX_FULL)) {
-+ DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
-+ return -EINVAL;
-+ }
-+
-+ switch(spddplx) {
-+ case SPEED_10 + DUPLEX_HALF:
-+ adapter->hw.forced_speed_duplex = iegbe_10_half;
-+ break;
-+ case SPEED_10 + DUPLEX_FULL:
-+ adapter->hw.forced_speed_duplex = iegbe_10_full;
-+ break;
-+ case SPEED_100 + DUPLEX_HALF:
-+ adapter->hw.forced_speed_duplex = iegbe_100_half;
-+ break;
-+ case SPEED_100 + DUPLEX_FULL:
-+ adapter->hw.forced_speed_duplex = iegbe_100_full;
-+ break;
-+ case SPEED_1000 + DUPLEX_FULL:
- adapter->hw.autoneg = 0x1;
-- adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
-- break;
-- case SPEED_1000 + HALF_DUPLEX: /* not supported */
-- default:
-- DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
-- return -EINVAL;
-- }
-- return 0;
-+ adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
-+ break;
-+ case SPEED_1000 + DUPLEX_HALF: /* not supported */
-+ default:
-+ DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
-+ return -EINVAL;
-+ }
-+ return 0x0;
- }
-
- static int
- iegbe_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
- {
-- struct pci_dev *pdev = NULL;
-+ struct pci_dev *pdev = NULL;
- pm_message_t state = {0x3};
-
-
-- switch(event) {
-- case SYS_DOWN:
-- case SYS_HALT:
-- case SYS_POWER_OFF:
-- while((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
-+ switch(event) {
-+ case SYS_DOWN:
-+ case SYS_HALT:
-+ case SYS_POWER_OFF:
-+ while((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
- if(pci_dev_driver(pdev) == &iegbe_driver) {
-- iegbe_suspend(pdev, state);
-- }
-- }
-+ iegbe_suspend(pdev, state);
-+ }
-+ }
- }
-- return NOTIFY_DONE;
-+ return NOTIFY_DONE;
- }
-
- static int
- iegbe_suspend(struct pci_dev *pdev, pm_message_t state)
- {
-- struct net_device *netdev = pci_get_drvdata(pdev);
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-- uint32_t ctrl, ctrl_ext, rctl, manc, status, swsm;
-- uint32_t wufc = adapter->wol;
-- uint16_t cmd_word;
-+ struct net_device *netdev = pci_get_drvdata(pdev);
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ uint32_t ctrl, ctrl_ext, rctl, manc, status, swsm;
-+ uint32_t wufc = adapter->wol;
-+ uint16_t cmd_word;
-
-- netif_device_detach(netdev);
-+ netif_device_detach(netdev);
-
- if(netif_running(netdev)) {
-- iegbe_down(adapter);
-+ WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
-+ iegbe_down(adapter);
- }
-- /*
-- * ICP_XXXX style MACs do not have a link up bit in
-- * the STATUS register, query the PHY directly
-- */
-- if(adapter->hw.mac_type != iegbe_icp_xxxx) {
-- status = E1000_READ_REG(&adapter->hw, STATUS);
-+ /*
-+ * ICP_XXXX style MACs do not have a link up bit in
-+ * the STATUS register, query the PHY directly
-+ */
-+ if(adapter->hw.mac_type != iegbe_icp_xxxx) {
-+ status = E1000_READ_REG(&adapter->hw, STATUS);
- if(status & E1000_STATUS_LU) {
-- wufc &= ~E1000_WUFC_LNKC;
-+ wufc &= ~E1000_WUFC_LNKC;
- }
-- } else {
-- int isUp = 0;
-+ } else {
-+ int isUp = 0x0;
- if(iegbe_oem_phy_is_link_up(&adapter->hw, &isUp) != E1000_SUCCESS) {
-- isUp = 0;
-+ isUp = 0x0;
- }
- if(isUp) {
-- wufc &= ~E1000_WUFC_LNKC;
-- }
-+ wufc &= ~E1000_WUFC_LNKC;
-+ }
- }
-
-- if(wufc) {
-- iegbe_setup_rctl(adapter);
-- iegbe_set_multi(netdev);
--
-- /* turn on all-multi mode if wake on multicast is enabled */
-- if(adapter->wol & E1000_WUFC_MC) {
-- rctl = E1000_READ_REG(&adapter->hw, RCTL);
-- rctl |= E1000_RCTL_MPE;
-- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
-- }
-+ if(wufc) {
-+ iegbe_setup_rctl(adapter);
-+ iegbe_set_rx_mode(netdev);
-+
-+ /* turn on all-multi mode if wake on multicast is enabled */
-+ if(adapter->wol & E1000_WUFC_MC) {
-+ rctl = E1000_READ_REG(&adapter->hw, RCTL);
-+ rctl |= E1000_RCTL_MPE;
-+ E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
-+ }
-
-- if(adapter->hw.mac_type >= iegbe_82540) {
-- ctrl = E1000_READ_REG(&adapter->hw, CTRL);
-- /* advertise wake from D3Cold */
-- #define E1000_CTRL_ADVD3WUC 0x00100000
-- /* phy power management enable */
-- ctrl |= E1000_CTRL_ADVD3WUC |
-- (adapter->hw.mac_type != iegbe_icp_xxxx
-- ? E1000_CTRL_EN_PHY_PWR_MGMT : 0);
-+ if(adapter->hw.mac_type >= iegbe_82540) {
-+ ctrl = E1000_READ_REG(&adapter->hw, CTRL);
-+ /* advertise wake from D3Cold */
-+ #define E1000_CTRL_ADVD3WUC 0x00100000
-+ /* phy power management enable */
-+ #define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
-+ ctrl |= E1000_CTRL_ADVD3WUC |
-+ (adapter->hw.mac_type != iegbe_icp_xxxx
-+ ? E1000_CTRL_EN_PHY_PWR_MGMT : 0x0);
-
-- E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
-- }
-+ E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
-+ }
-
-- if(adapter->hw.media_type == iegbe_media_type_fiber ||
-- adapter->hw.media_type == iegbe_media_type_internal_serdes) {
-- /* keep the laser running in D3 */
-- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
-- ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
-- E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext);
-- }
-+ if(adapter->hw.media_type == iegbe_media_type_fiber ||
-+ adapter->hw.media_type == iegbe_media_type_internal_serdes) {
-+ /* keep the laser running in D3 */
-+ ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
-+ ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
-+ E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext);
-+ }
-
- /* Allow OEM PHYs (if any exist) to keep the laser
- *running in D3 */
- iegbe_oem_fiber_live_in_suspend(&adapter->hw);
-
-- /* Allow time for pending master requests to run */
-- iegbe_disable_pciex_master(&adapter->hw);
-+ /* Allow time for pending master requests to run */
-+ iegbe_disable_pciex_master(&adapter->hw);
-
-- E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN);
-- E1000_WRITE_REG(&adapter->hw, WUFC, wufc);
-+ E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN);
-+ E1000_WRITE_REG(&adapter->hw, WUFC, wufc);
- pci_enable_wake(pdev, 0x3, 0x1);
- pci_enable_wake(pdev, 0x4, 0x1); /* 4 == D3 cold */
-- } else {
-- E1000_WRITE_REG(&adapter->hw, WUC, 0);
-- E1000_WRITE_REG(&adapter->hw, WUFC, 0);
-- pci_enable_wake(pdev, 0x3, 0);
-- pci_enable_wake(pdev, 0x4, 0); /* 4 == D3 cold */
-- }
-+ } else {
-+ E1000_WRITE_REG(&adapter->hw, WUC, 0x0);
-+ E1000_WRITE_REG(&adapter->hw, WUFC, 0x0);
-+ pci_enable_wake(pdev, 0x3, 0x0);
-+ pci_enable_wake(pdev, 0x4, 0x0); /* 4 == D3 cold */
-+ }
-
-- pci_save_state(pdev);
--
-- if(adapter->hw.mac_type >= iegbe_82540
-- && adapter->hw.mac_type != iegbe_icp_xxxx
-- && adapter->hw.media_type == iegbe_media_type_copper) {
-- manc = E1000_READ_REG(&adapter->hw, MANC);
-- if(manc & E1000_MANC_SMBUS_EN) {
-- manc |= E1000_MANC_ARP_EN;
-- E1000_WRITE_REG(&adapter->hw, MANC, manc);
-+ pci_save_state(pdev);
-+
-+ if(adapter->hw.mac_type >= iegbe_82540
-+ && adapter->hw.mac_type != iegbe_icp_xxxx
-+ && adapter->hw.media_type == iegbe_media_type_copper) {
-+ manc = E1000_READ_REG(&adapter->hw, MANC);
-+ if(manc & E1000_MANC_SMBUS_EN) {
-+ manc |= E1000_MANC_ARP_EN;
-+ E1000_WRITE_REG(&adapter->hw, MANC, manc);
- pci_enable_wake(pdev, 0x3, 0x1);
- pci_enable_wake(pdev, 0x4, 0x1); /* 4 == D3 cold */
-- }
-- }
-+ }
-+ }
-
-- switch(adapter->hw.mac_type) {
-- case iegbe_82571:
-- case iegbe_82572:
-- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
-- E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
-- ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
-- break;
-- case iegbe_82573:
-- swsm = E1000_READ_REG(&adapter->hw, SWSM);
-- E1000_WRITE_REG(&adapter->hw, SWSM,
-- swsm & ~E1000_SWSM_DRV_LOAD);
-- break;
-- default:
-- break;
-- }
-+ switch(adapter->hw.mac_type) {
-+ case iegbe_82571:
-+ case iegbe_82572:
-+ ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
-+ E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
-+ ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
-+ break;
-+ case iegbe_82573:
-+ swsm = E1000_READ_REG(&adapter->hw, SWSM);
-+ E1000_WRITE_REG(&adapter->hw, SWSM,
-+ swsm & ~E1000_SWSM_DRV_LOAD);
-+ break;
-+ default:
-+ break;
-+ }
-
-- pci_disable_device(pdev);
-- if(adapter->hw.mac_type == iegbe_icp_xxxx) {
-- /*
-- * ICP xxxx devices are not true PCI devices, in the context
-- * of power management, disabling the bus mastership is not
-- * sufficient to disable the device, it is also necessary to
-- * disable IO, Memory, and Interrupts if they are enabled.
-- */
-- pci_read_config_word(pdev, PCI_COMMAND, &cmd_word);
-+ pci_disable_device(pdev);
-+ if(adapter->hw.mac_type == iegbe_icp_xxxx) {
-+ /*
-+ * ICP xxxx devices are not true PCI devices, in the context
-+ * of power management, disabling the bus mastership is not
-+ * sufficient to disable the device, it is also necessary to
-+ * disable IO, Memory, and Interrupts if they are enabled.
-+ */
-+ pci_read_config_word(pdev, PCI_COMMAND, &cmd_word);
- if(cmd_word & PCI_COMMAND_IO) {
-- cmd_word &= ~PCI_COMMAND_IO;
-+ cmd_word &= ~PCI_COMMAND_IO;
- }
- if(cmd_word & PCI_COMMAND_MEMORY) {
-- cmd_word &= ~PCI_COMMAND_MEMORY;
-+ cmd_word &= ~PCI_COMMAND_MEMORY;
- }
- if(cmd_word & PCI_COMMAND_INTX_DISABLE) {
-- cmd_word &= ~PCI_COMMAND_INTX_DISABLE;
-+ cmd_word &= ~PCI_COMMAND_INTX_DISABLE;
- }
-- pci_write_config_word(pdev, PCI_COMMAND, cmd_word);
-- }
-+ pci_write_config_word(pdev, PCI_COMMAND, cmd_word);
-+ }
-
-- state.event = (state.event > 0) ? 0x3 : 0;
-- pci_set_power_state(pdev, state.event);
-- if(gcu_suspend == 0)
-+ state.event = (state.event > 0x0) ? 0x3 : 0x0;
-+ pci_set_power_state(pdev, state.event);
-+ if(gcu_suspend == 0x0)
- {
- if(gcu == NULL) {
-- gcu = pci_find_device(PCI_VENDOR_ID_INTEL, GCU_DEVID, NULL);
-- }
-+ gcu = pci_get_device(PCI_VENDOR_ID_INTEL, GCU_DEVID, NULL);
-+ }
- gcu_iegbe_suspend(gcu, 0x3);
-- gcu_suspend = 1;
-- gcu_resume = 0;
-+ gcu_suspend = 0x1;
-+ gcu_resume = 0x0;
- }
-- return 0;
-+ return 0x0;
- }
-
- #ifdef CONFIG_PM
- static int
- iegbe_resume(struct pci_dev *pdev)
- {
-- struct net_device *netdev = pci_get_drvdata(pdev);
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-- uint32_t manc, ret_val, swsm;
-- uint32_t ctrl_ext;
-+ struct net_device *netdev = pci_get_drvdata(pdev);
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ uint32_t manc, ret_val, swsm;
-+ uint32_t ctrl_ext;
- int offset;
- uint32_t vdid;
-
-- if(gcu_resume == 0)
-+ if(gcu_resume == 0x0)
- {
- if(gcu == NULL) {
-- gcu = pci_find_device(PCI_VENDOR_ID_INTEL, GCU_DEVID, NULL);
-+ gcu = pci_get_device(PCI_VENDOR_ID_INTEL, GCU_DEVID, NULL);
- pci_read_config_dword(gcu, 0x00, &vdid);
-- }
--
-+ }
-+
- if(gcu) {
- gcu_iegbe_resume(gcu);
-- gcu_resume = 1;
-- gcu_suspend = 0;
-+ gcu_resume = 0x1;
-+ gcu_suspend = 0x0;
- } else {
- printk("Unable to resume GCU!\n");
-- }
-+ }
- }
- pci_set_power_state(pdev, 0x0);
-- pci_restore_state(pdev);
-- ret_val = pci_enable_device(pdev);
-- pci_set_master(pdev);
-+ pci_restore_state(pdev);
-+ ret_val = pci_enable_device(pdev);
-+ pci_set_master(pdev);
-
- pci_enable_wake(pdev, 0x3, 0x0);
- pci_enable_wake(pdev, 0x4, 0x0); /* 4 == D3 cold */
-
-- iegbe_reset(adapter);
-- E1000_WRITE_REG(&adapter->hw, WUS, ~0);
-+ iegbe_reset(adapter);
-+ E1000_WRITE_REG(&adapter->hw, WUS, ~0);
- offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_ST)
- + PCI_ST_SMIA_OFFSET;
- pci_write_config_dword(adapter->pdev, offset, 0x00000006);
-@@ -5138,51 +4848,52 @@ iegbe_resume(struct pci_dev *pdev)
- E1000_WRITE_REG(&adapter->hw, IMC2, ~0UL);
-
- if(netif_running(netdev)) {
-- iegbe_up(adapter);
-+ iegbe_up(adapter);
- }
-- netif_device_attach(netdev);
--
-- if(adapter->hw.mac_type >= iegbe_82540
-- && adapter->hw.mac_type != iegbe_icp_xxxx
-- && adapter->hw.media_type == iegbe_media_type_copper) {
-- manc = E1000_READ_REG(&adapter->hw, MANC);
-- manc &= ~(E1000_MANC_ARP_EN);
-- E1000_WRITE_REG(&adapter->hw, MANC, manc);
-- }
-+ netif_device_attach(netdev);
-
-- switch(adapter->hw.mac_type) {
-- case iegbe_82571:
-- case iegbe_82572:
-- ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
-- E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
-- ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
-- break;
-- case iegbe_82573:
-- swsm = E1000_READ_REG(&adapter->hw, SWSM);
-- E1000_WRITE_REG(&adapter->hw, SWSM,
-- swsm | E1000_SWSM_DRV_LOAD);
-- break;
-- default:
-- break;
-- }
-+ if(adapter->hw.mac_type >= iegbe_82540
-+ && adapter->hw.mac_type != iegbe_icp_xxxx
-+ && adapter->hw.media_type == iegbe_media_type_copper) {
-+ manc = E1000_READ_REG(&adapter->hw, MANC);
-+ manc &= ~(E1000_MANC_ARP_EN);
-+ E1000_WRITE_REG(&adapter->hw, MANC, manc);
-+ }
-+
-+ switch(adapter->hw.mac_type) {
-+ case iegbe_82571:
-+ case iegbe_82572:
-+ ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
-+ E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
-+ ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
-+ break;
-+ case iegbe_82573:
-+ swsm = E1000_READ_REG(&adapter->hw, SWSM);
-+ E1000_WRITE_REG(&adapter->hw, SWSM,
-+ swsm | E1000_SWSM_DRV_LOAD);
-+ break;
-+ default:
-+ break;
-+ }
-+#endif
-
-- return 0;
-+ return 0x0;
- }
--#endif
-+
- #ifdef CONFIG_NET_POLL_CONTROLLER
- /*
- * Polling 'interrupt' - used by things like netconsole to send skbs
- * without having to re-enable interrupts. It's not called while
- * the interrupt routine is executing.
- */
--static void
--iegbe_netpoll(struct net_device *netdev)
-+static void iegbe_netpoll(struct net_device *netdev)
- {
-- struct iegbe_adapter *adapter = netdev_priv(netdev);
-- disable_irq(adapter->pdev->irq);
-- iegbe_intr(adapter->pdev->irq, netdev, NULL);
-- enable_irq(adapter->pdev->irq);
-+ struct iegbe_adapter *adapter = netdev_priv(netdev);
-+ disable_irq(adapter->pdev->irq);
-+ iegbe_intr(adapter->pdev->irq, netdev);
-+ enable_irq(adapter->pdev->irq);
- }
- #endif
-
-+
- /* iegbe_main.c */
---- a/Embedded/src/GbE/iegbe_oem_phy.c
-+++ b/Embedded/src/GbE/iegbe_oem_phy.c
-@@ -2,31 +2,31 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
-- This program is free software; you can redistribute it and/or modify
-+ This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
-- 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
-+ 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
-+ 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
-- The full GNU General Public License is included in this distribution
-+ The full GNU General Public License is included in this distribution
- in the file called LICENSE.GPL.
-
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
-- Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
-+ Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
-
- *****************************************************************************/
- /**************************************************************************
-@@ -65,11 +65,6 @@ static int32_t iegbe_oem_link_m88_setup(
- static int32_t iegbe_oem_set_phy_mode(struct iegbe_hw *hw);
- static int32_t iegbe_oem_detect_phy(struct iegbe_hw *hw);
-
--/* Define specific BCM functions */
--static int32_t iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw);
--static int32_t bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data);
--static int32_t oi_phy_setup (struct iegbe_hw *hw);
--
- /**
- * iegbe_oem_setup_link
- * @hw: iegbe_hw struct containing device specific information
-@@ -84,7 +79,7 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
- {
- #ifdef EXTERNAL_MDIO
-
-- /*
-+ /*
- * see iegbe_setup_copper_link() as the primary example. Look at both
- * the M88 and IGP functions that are called for ideas, possibly for
- * power management.
-@@ -102,14 +97,14 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
- }
- /* AFU: add test to exit out if improper phy type
- */
-- /* relevent parts of iegbe_copper_link_preconfig */
-- ctrl = E1000_READ_REG(hw, CTRL);
-- ctrl |= E1000_CTRL_SLU;
-- ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
-- E1000_WRITE_REG(hw, CTRL, ctrl);
--
-+ /* relevent parts of iegbe_copper_link_preconfig */
-+ ctrl = E1000_READ_REG(hw, CTRL);
-+ ctrl |= E1000_CTRL_SLU;
-+ ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
-+ E1000_WRITE_REG(hw, CTRL, ctrl);
-+
- /* this is required for *hw init */
-- ret_val = iegbe_oem_detect_phy(hw);
-+ ret_val = iegbe_oem_detect_phy(hw);
- if(ret_val) {
- return ret_val;
- }
-@@ -119,23 +114,13 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
- }
-
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- return E1000_SUCCESS;
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- ret_val = iegbe_oem_link_m88_setup(hw);
-- if(ret_val) {
-- return ret_val;
-- }
-- break;
-- case BCM5481_PHY_ID:
-- ret_val = iegbe_oem_link_bcm5481_setup(hw);
-- if(ret_val) {
-- return ret_val;
-+ if(ret_val) {
-+ return ret_val;
- }
-- break;
-+ break;
- default:
- DEBUGOUT("Invalid PHY ID\n");
- return -E1000_ERR_PHY_TYPE;
-@@ -143,16 +128,16 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
-
- if(hw->autoneg) {
- ret_val = iegbe_copper_link_autoneg(hw);
-- if(ret_val) {
-- return ret_val;
-- }
-+ if(ret_val) {
-+ return ret_val;
- }
-+ }
- else {
- DEBUGOUT("Forcing speed and duplex\n");
- ret_val = iegbe_phy_force_speed_duplex(hw);
- }
--
-- /*
-+
-+ /*
- * Check link status. Wait up to 100 microseconds for link to become
- * valid.
- */
-@@ -194,51 +179,6 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
- #endif /* ifdef EXTERNAL_MDIO */
- }
-
--/**
-- * iegbe_oem_link_bcm5481_setup
-- * @hw: iegbe_hw struct containing device specific information
-- *
-- * Returns E1000_SUCCESS, negative E1000 error code on failure
-- *
-- * copied verbatim from iegbe_oem_link_m88_setup
-- **/
--static int32_t
--iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw)
--{
-- int32_t ret_val;
-- uint16_t phy_data;
--
-- //DEBUGFUNC(__func__);
--
-- if(!hw)
-- return -1;
--
-- /* phy_reset_disable is set in iegbe_oem_set_phy_mode */
-- if(hw->phy_reset_disable)
-- return E1000_SUCCESS;
--
-- // Enable MDIX in extended control reg.
-- ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ECTRL, &phy_data);
-- if(ret_val)
-- {
-- DEBUGOUT("Unable to read BCM5481_ECTRL register\n");
-- return ret_val;
-- }
--
-- phy_data &= ~BCM5481_ECTRL_DISMDIX;
-- ret_val = iegbe_oem_write_phy_reg_ex(hw, BCM5481_ECTRL, phy_data);
-- if(ret_val)
-- {
-- DEBUGOUT("Unable to write BCM5481_ECTRL register\n");
-- return ret_val;
-- }
--
-- ret_val = oi_phy_setup (hw);
-- if (ret_val)
-- return ret_val;
--
-- return E1000_SUCCESS;
--}
-
- /**
- * iegbe_oem_link_m88_setup
-@@ -253,7 +193,7 @@ static int32_t
- iegbe_oem_link_m88_setup(struct iegbe_hw *hw)
- {
- int32_t ret_val;
-- uint16_t phy_data;
-+ uint16_t phy_data = 0;
-
- DEBUGFUNC1("%s",__func__);
-
-@@ -261,7 +201,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
- return -1;
- }
-
-- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
- &phy_data);
- phy_data |= 0x00000008;
- ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
-@@ -279,7 +219,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
-
- phy_data &= ~M88E1000_PSCR_ASSERT_CRS_ON_TX;
-
-- /*
-+ /*
- * Options:
- * MDI/MDI-X = 0 (default)
- * 0 - Auto for all speeds
-@@ -305,7 +245,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
- break;
- }
-
-- /*
-+ /*
- * Options:
- * disable_polarity_correction = 0 (default)
- * Automatic Correction for Reversed Cable Polarity
-@@ -316,25 +256,25 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
-
- if(hw->disable_polarity_correction == 1) {
- phy_data |= M88E1000_PSCR_POLARITY_REVERSAL;
-- }
-+ }
- ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to write M88E1000_PHY_SPEC_CTRL register\n");
- return ret_val;
- }
-
-- /*
-+ /*
- * Force TX_CLK in the Extended PHY Specific Control Register
- * to 25MHz clock.
- */
-- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_EXT_PHY_SPEC_CTRL,
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_EXT_PHY_SPEC_CTRL,
- &phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to read M88E1000_EXT_PHY_SPEC_CTRL register\n");
- return ret_val;
- }
-
-- /*
-+ /*
- * For Truxton, it is necessary to add RGMII tx and rx
- * timing delay though the EXT_PHY_SPEC_CTRL register
- */
-@@ -350,13 +290,13 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
- phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
- M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
- }
-- ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_EXT_PHY_SPEC_CTRL,
-+ ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_EXT_PHY_SPEC_CTRL,
- phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to read M88E1000_EXT_PHY_SPEC_CTRL register\n");
- return ret_val;
- }
--
-+
-
- /* SW Reset the PHY so all changes take effect */
- ret_val = iegbe_phy_hw_reset(hw);
-@@ -371,7 +311,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
- /**
- * iegbe_oem_force_mdi
- * @hw: iegbe_hw struct containing device specific information
-- * @resetPhy: returns true if after calling this function the
-+ * @resetPhy: returns true if after calling this function the
- * PHY requires a reset
- *
- * Returns E1000_SUCCESS, negative E1000 error code on failure
-@@ -379,7 +319,7 @@ iegbe_oem_link_m88_setup(struct iegbe_hw
- * This is called from iegbe_phy_force_speed_duplex, which is
- * called from iegbe_oem_setup_link.
- **/
--int32_t
-+int32_t
- iegbe_oem_force_mdi(struct iegbe_hw *hw, int *resetPhy)
- {
- #ifdef EXTERNAL_MDIO
-@@ -393,35 +333,30 @@ iegbe_oem_force_mdi(struct iegbe_hw *hw,
- return -1;
- }
-
-- /*
-+ /*
- * a boolean to indicate if the phy needs to be reset
-- *
-+ *
- * Make note that the M88 phy is what'll be used on Truxton
- * see iegbe_phy_force_speed_duplex, which does the following for M88
- */
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- case BCM5481_PHY_ID:
-- DEBUGOUT("WARNING: An empty iegbe_oem_force_mdi() has been called!\n");
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- ret_val = iegbe_oem_read_phy_reg_ex(hw,
-- M88E1000_PHY_SPEC_CTRL,
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw,
-+ M88E1000_PHY_SPEC_CTRL,
- &phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to read M88E1000_PHY_SPEC_CTRL register\n");
- return ret_val;
- }
--
-+
- /*
-- * Clear Auto-Crossover to force MDI manually. M88E1000 requires
-+ * Clear Auto-Crossover to force MDI manually. M88E1000 requires
- * MDI forced whenever speed are duplex are forced.
- */
--
-+
- phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
-- ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
-+ ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
- phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to write M88E1000_PHY_SPEC_CTRL register\n");
-@@ -458,7 +393,7 @@ iegbe_oem_force_mdi(struct iegbe_hw *hw,
- * This is called from iegbe_phy_force_speed_duplex, which is
- * called from iegbe_oem_setup_link.
- **/
--int32_t
-+int32_t
- iegbe_oem_phy_reset_dsp(struct iegbe_hw *hw)
- {
- #ifdef EXTERNAL_MDIO
-@@ -478,10 +413,8 @@ iegbe_oem_phy_reset_dsp(struct iegbe_hw
- * no-op.
- */
- switch (hw->phy_id) {
-- case M88E1000_I_PHY_ID:
-- case M88E1141_E_PHY_ID:
-- case BCM5481_PHY_ID:
-- case BCM5395S_PHY_ID:
-+ case M88E1000_I_PHY_ID:
-+ case M88E1141_E_PHY_ID:
- DEBUGOUT("No DSP to reset on OEM PHY\n");
- break;
- default:
-@@ -508,7 +441,7 @@ iegbe_oem_phy_reset_dsp(struct iegbe_hw
- * This is called from iegbe_phy_force_speed_duplex, which is
- * called from iegbe_oem_setup_link.
- **/
--int32_t
-+int32_t
- iegbe_oem_cleanup_after_phy_reset(struct iegbe_hw *hw)
- {
- #ifdef EXTERNAL_MDIO
-@@ -520,29 +453,24 @@ iegbe_oem_cleanup_after_phy_reset(struct
-
- if(!hw) {
- return -1;
-- }
-+ }
-
-- /*
-+ /*
- * Make note that the M88 phy is what'll be used on Truxton.
- * see iegbe_phy_force_speed_duplex, which does the following for M88
- */
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- case BCM5481_PHY_ID:
-- DEBUGOUT("WARNING: An empty iegbe_oem_cleanup_after_phy_reset() has been called!\n");
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- /*
-- * Because we reset the PHY above, we need to re-force
-+ * Because we reset the PHY above, we need to re-force
- * TX_CLK in the Extended PHY Specific Control Register to
- * 25MHz clock. This value defaults back to a 2.5MHz clock
- * when the PHY is reset.
- */
-
- ret_val = iegbe_oem_read_phy_reg_ex(hw,
-- M88E1000_EXT_PHY_SPEC_CTRL,
-+ M88E1000_EXT_PHY_SPEC_CTRL,
- &phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to read M88E1000_EXT_SPEC_CTRL register\n");
-@@ -550,22 +478,23 @@ iegbe_oem_cleanup_after_phy_reset(struct
- }
-
- phy_data |= M88E1000_EPSCR_TX_CLK_25;
-- ret_val = iegbe_oem_write_phy_reg_ex(hw,
-- M88E1000_EXT_PHY_SPEC_CTRL,
-+ ret_val = iegbe_oem_write_phy_reg_ex(hw,
-+ M88E1000_EXT_PHY_SPEC_CTRL,
- phy_data);
- if(ret_val) {
-- DEBUGOUT("Unable to write M88E1000_EXT_PHY_SPEC_CTRL register\n");
-+ DEBUGOUT("Unable to write M88E1000_EXT_PHY_SPEC_CTRL "
-+ "register\n");
- return ret_val;
- }
-
- /*
- * In addition, because of the s/w reset above, we need to enable
-- * CRX on TX. This must be set for both full and half duplex
-+ * CRX on TX. This must be set for both full and half duplex
- * operation.
- */
-
-- ret_val = iegbe_oem_read_phy_reg_ex(hw,
-- M88E1000_PHY_SPEC_CTRL,
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw,
-+ M88E1000_PHY_SPEC_CTRL,
- &phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to read M88E1000_PHY_SPEC_CTRL register\n");
-@@ -573,12 +502,12 @@ iegbe_oem_cleanup_after_phy_reset(struct
- }
-
- phy_data &= ~M88E1000_PSCR_ASSERT_CRS_ON_TX;
-- ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
-+ ret_val = iegbe_oem_write_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
- phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to write M88E1000_PHY_SPEC_CTRL register\n");
- return ret_val;
-- }
-+ }
- break;
- default:
- DEBUGOUT("Invalid PHY ID\n");
-@@ -604,12 +533,12 @@ iegbe_oem_cleanup_after_phy_reset(struct
- * This is called from iegbe_oem_setup_link which is
- * called from iegbe_setup_link.
- **/
--static int32_t
-+static int32_t
- iegbe_oem_set_phy_mode(struct iegbe_hw *hw)
- {
- /*
- * it is unclear if it is necessary to set the phy mode. Right now only
-- * one MAC 82545 Rev 3 does it, but the other MACs like Tolapai do not.
-+ * one MAC 82545 Rev 3 does it, but the other MACs like tola do not.
- * Leave the functionality off for now until it is determined that Tolapai
- * needs it as well.
- */
-@@ -638,41 +567,37 @@ iegbe_oem_set_phy_mode(struct iegbe_hw *
- #ifndef skip_set_mode
- DEBUGOUT("No need to call oem_set_phy_mode on Truxton\n");
- #else
-- /*
-+ /*
- * Make note that the M88 phy is what'll be used on Truxton.
- *
- * use iegbe_set_phy_mode as example
- */
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- case BCM5481_PHY_ID:
-- DEBUGOUT("WARNING: An empty iegbe_oem_set_phy_mode() has been called!\n");
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- ret_val = iegbe_read_eeprom(hw,
-- EEPROM_PHY_CLASS_WORD,
-- 1,
-+ ret_val = iegbe_read_eeprom(hw,
-+ EEPROM_PHY_CLASS_WORD,
-+ 1,
- &eeprom_data);
- if(ret_val) {
- return ret_val;
- }
-
-- if((eeprom_data != EEPROM_RESERVED_WORD) &&
-- (eeprom_data & EEPROM_PHY_CLASS_A))
-+ if((eeprom_data != EEPROM_RESERVED_WORD) &&
-+ (eeprom_data & EEPROM_PHY_CLASS_A))
- {
-- ret_val = iegbe_oem_write_phy_reg_ex(hw,
-- M88E1000_PHY_PAGE_SELECT,
-- 0x000B);
-+ ret_val = iegbe_oem_write_phy_reg_ex(hw,
-+ M88E1000_PHY_PAGE_SELECT,
-+ 0x000B);
- if(ret_val) {
-- DEBUGOUT("Unable to write to M88E1000_PHY_PAGE_SELECT register on PHY\n");
-+ DEBUGOUT("Unable to write to M88E1000_PHY_PAGE_SELECT "
-+ "register on PHY\n");
- return ret_val;
- }
-
-- ret_val = iegbe_oem_write_phy_reg_ex(hw,
-- M88E1000_PHY_GEN_CONTROL,
-- 0x8104);
-+ ret_val = iegbe_oem_write_phy_reg_ex(hw,
-+ M88E1000_PHY_GEN_CONTROL,
-+ 0x8104);
- if(ret_val) {
- DEBUGOUT("Unable to write to M88E1000_PHY_GEN_CONTROL"
- "register on PHY\n");
-@@ -687,11 +612,12 @@ iegbe_oem_set_phy_mode(struct iegbe_hw *
- return -E1000_ERR_PHY_TYPE;
- }
- #endif
--
-+
- return E1000_SUCCESS;
-
- }
-
-+
- /**
- * iegbe_oem_detect_phy
- * @hw: iegbe_hw struct containing device specific information
-@@ -702,7 +628,7 @@ iegbe_oem_set_phy_mode(struct iegbe_hw *
- *
- * This borrows heavily from iegbe_detect_gig_phy
- **/
--static int32_t
-+static int32_t
- iegbe_oem_detect_phy(struct iegbe_hw *hw)
- {
- int32_t ret_val;
-@@ -715,33 +641,20 @@ iegbe_oem_detect_phy(struct iegbe_hw *hw
- }
- hw->phy_type = iegbe_phy_oem;
-
--{
-- // If MAC2 (BCM5395 switch), manually detect the phy
-- struct iegbe_adapter *adapter;
-- uint32_t device_number;
-- adapter = (struct iegbe_adapter *) hw->back;
-- device_number = PCI_SLOT(adapter->pdev->devfn);
-- if (device_number == ICP_XXXX_MAC_2) {
-- hw->phy_id = BCM5395S_PHY_ID;
-- hw->phy_revision = 0;
-- return E1000_SUCCESS;
-- }
--}
--
--
- ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_ID1, &phy_id_high);
- if(ret_val) {
- DEBUGOUT("Unable to read PHY register PHY_ID1\n");
- return ret_val;
- }
--
-+
- usec_delay(0x14);
- ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_ID2, &phy_id_low);
- if(ret_val) {
- DEBUGOUT("Unable to read PHY register PHY_ID2\n");
- return ret_val;
- }
-- hw->phy_id = (uint32_t) ((phy_id_high << 0x10) + phy_id_low);
-+ hw->phy_id = (uint32_t) ((phy_id_high << 0x10) +
-+ (phy_id_low & PHY_REVISION_MASK));
- hw->phy_revision = (uint32_t) phy_id_low & ~PHY_REVISION_MASK;
-
- return E1000_SUCCESS;
-@@ -753,15 +666,15 @@ iegbe_oem_detect_phy(struct iegbe_hw *hw
- * @hw: iegbe_hw struct containing device specific information
- *
- * Returns the value of the Inter Packet Gap (IPG) Transmit Time (IPGT) in the
-- * Transmit IPG register appropriate for the given PHY. This field is only 10
-+ * Transmit IPG register appropriate for the given PHY. This field is only 10
- * bits wide.
- *
- * In the original iegbe code, only the IPGT field varied between media types.
-- * If the OEM phy requires setting IPG Receive Time 1 & 2 Registers, it would
-+ * If the OEM phy requires setting IPG Receive Time 1 & 2 Registers, it would
- * be required to modify the iegbe_config_tx() function to accomdate the change
- *
- **/
--uint32_t
-+uint32_t
- iegbe_oem_get_tipg(struct iegbe_hw *hw)
- {
- #ifdef EXTERNAL_MDIO
-@@ -777,15 +690,13 @@ iegbe_oem_get_tipg(struct iegbe_hw *hw)
- switch (hw->phy_id) {
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- case BCM5481_PHY_ID:
-- case BCM5395S_PHY_ID:
- phy_num = DEFAULT_ICP_XXXX_TIPG_IPGT;
- break;
- default:
- DEBUGOUT("Invalid PHY ID\n");
- return DEFAULT_ICP_XXXX_TIPG_IPGT;
- }
--
-+
- return phy_num;
-
- #else /* ifdef EXTERNAL_MDIO */
-@@ -803,15 +714,15 @@ iegbe_oem_get_tipg(struct iegbe_hw *hw)
- * iegbe_oem_phy_is_copper
- * @hw: iegbe_hw struct containing device specific information
- *
-- * Test for media type within the iegbe driver is common, so this is a simple
-- * test for copper PHYs. The ICP_XXXX family of controllers initially only
-- * supported copper interconnects (no TBI (ten bit interface) for Fiber
-- * existed). If future revs support either Fiber or an internal SERDES, it
-- * may become necessary to evaluate where this function is used to go beyond
-+ * Test for media type within the iegbe driver is common, so this is a simple
-+ * test for copper PHYs. The ICP_XXXX family of controllers initially only
-+ * supported copper interconnects (no TBI (ten bit interface) for Fiber
-+ * existed). If future revs support either Fiber or an internal SERDES, it
-+ * may become necessary to evaluate where this function is used to go beyond
- * determining whether or not media type is just copper.
- *
- **/
--int
-+int
- iegbe_oem_phy_is_copper(struct iegbe_hw *hw)
- {
- #ifdef EXTERNAL_MDIO
-@@ -827,23 +738,21 @@ iegbe_oem_phy_is_copper(struct iegbe_hw
- switch (hw->phy_id) {
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- case BCM5481_PHY_ID:
-- case BCM5395S_PHY_ID:
- isCopper = TRUE;
- break;
- default:
- DEBUGOUT("Invalid PHY ID\n");
- return -E1000_ERR_PHY_TYPE;
- }
--
-+
- return isCopper;
-
- #else /* ifdef EXTERNAL_MDIO */
-
-- /*
-+ /*
- * caught between returning true or false. True allows it to
- * be entered into && statements w/o ill effect, but false
-- * would make more sense
-+ * would make more sense
- */
- DEBUGOUT("Invalid value for transceiver type, return FALSE\n");
- return FALSE;
-@@ -856,19 +765,19 @@ iegbe_oem_phy_is_copper(struct iegbe_hw
- * iegbe_oem_get_phy_dev_number
- * @hw: iegbe_hw struct containing device specific information
- *
-- * For ICP_XXXX family of devices, there are 3 MACs, each of which may
-- * have a different PHY (and indeed a different media interface). This
-- * function is used to indicate which of the MAC/PHY pairs we are interested
-+ * For ICP_XXXX family of devices, there are 3 MACs, each of which may
-+ * have a different PHY (and indeed a different media interface). This
-+ * function is used to indicate which of the MAC/PHY pairs we are interested
- * in.
-- *
-+ *
- **/
--uint32_t
-+uint32_t
- iegbe_oem_get_phy_dev_number(struct iegbe_hw *hw)
- {
- #ifdef EXTERNAL_MDIO
-
-- /*
-- * for ICP_XXXX family of devices, the three network interfaces are
-+ /*
-+ * for ICP_XXXX family of devices, the three network interfaces are
- * differentiated by their PCI device number, where the three share
- * the same PCI bus
- */
-@@ -886,15 +795,15 @@ iegbe_oem_get_phy_dev_number(struct iegb
-
- switch(device_number)
- {
-- case ICP_XXXX_MAC_0:
-+ case ICP_XXXX_MAC_0:
-+ hw->phy_addr = 0x00;
-+ break;
-+ case ICP_XXXX_MAC_1:
- hw->phy_addr = 0x01;
- break;
-- case ICP_XXXX_MAC_1:
-+ case ICP_XXXX_MAC_2:
- hw->phy_addr = 0x02;
- break;
-- case ICP_XXXX_MAC_2:
-- hw->phy_addr = 0x00;
-- break;
- default: hw->phy_addr = 0x00;
- }
- return hw->phy_addr;
-@@ -915,7 +824,7 @@ iegbe_oem_get_phy_dev_number(struct iegb
- * @cmd: the original IOCTL command that instigated the call chain.
- *
- * This function abstracts out the code necessary to service the
-- * SIOCSMIIREG case within the iegbe_mii_ioctl() for oem PHYs.
-+ * SIOCSMIIREG case within the iegbe_mii_ioctl() for oem PHYs.
- * iegbe_mii_ioctl() was implemented for copper phy's only and this
- * function will only be called if iegbe_oem_phy_is_copper() returns true for
- * a given MAC. Note that iegbe_mii_ioctl() has a compile flag
-@@ -924,14 +833,14 @@ iegbe_oem_get_phy_dev_number(struct iegb
- * NOTE: a spinlock is in effect for the duration of this call. It is
- * imperative that a negative value be returned on any error, so
- * the spinlock can be released properly.
-- *
-+ *
- **/
- int
- iegbe_oem_mii_ioctl(struct iegbe_adapter *adapter, unsigned long flags,
- struct ifreq *ifr, int cmd)
- {
- #ifdef EXTERNAL_MDIO
--
-+
- struct mii_ioctl_data *data = if_mii(ifr);
- uint16_t mii_reg = data->val_in;
- uint16_t spddplx;
-@@ -942,12 +851,6 @@ iegbe_oem_mii_ioctl(struct iegbe_adapter
- if(!adapter || !ifr) {
- return -1;
- }
--
-- // If MAC2 (BCM5395 switch) then leave now
-- if ((PCI_SLOT(adapter->pdev->devfn)) == ICP_XXXX_MAC_2) {
-- return -1;
-- }
--
- switch (data->reg_num) {
- case PHY_CTRL:
- if(mii_reg & MII_CR_POWER_DOWN) {
-@@ -956,7 +859,7 @@ iegbe_oem_mii_ioctl(struct iegbe_adapter
- if(mii_reg & MII_CR_AUTO_NEG_EN) {
- adapter->hw.autoneg = 1;
- adapter->hw.autoneg_advertised = ICP_XXXX_AUTONEG_ADV_DEFAULT;
-- }
-+ }
- else {
- if(mii_reg & 0x40) {
- spddplx = SPEED_1000;
-@@ -976,7 +879,7 @@ iegbe_oem_mii_ioctl(struct iegbe_adapter
- if(netif_running(adapter->netdev)) {
- iegbe_down(adapter);
- iegbe_up(adapter);
-- }
-+ }
- else {
- iegbe_reset(adapter);
- }
-@@ -1043,10 +946,10 @@ void iegbe_oem_fiber_live_in_suspend(str
- * Note: The call to iegbe_get_regs() assumed an array of 24 elements
- * where the last 11 are passed to this function. If the array
- * that is passed to the calling function has its size or element
-- * defintions changed, this function becomes broken.
-+ * defintions changed, this function becomes broken.
- *
- **/
--void iegbe_oem_get_phy_regs(struct iegbe_adapter *adapter, uint32_t *data,
-+void iegbe_oem_get_phy_regs(struct iegbe_adapter *adapter, uint32_t *data,
- uint32_t data_len)
- {
- #define EXPECTED_ARRAY_LEN 11
-@@ -1062,13 +965,13 @@ void iegbe_oem_get_phy_regs(struct iegbe
- * Use the corrected_length variable to make sure we don't exceed that
- * length
- */
-- corrected_len = data_len>EXPECTED_ARRAY_LEN
-+ corrected_len = data_len>EXPECTED_ARRAY_LEN
- ? EXPECTED_ARRAY_LEN : data_len;
- memset(data, 0, corrected_len*sizeof(uint32_t));
-
- #ifdef EXTERNAL_MDIO
-
-- /*
-+ /*
- * Fill data[] with...
- *
- * [0] = cable length
-@@ -1084,16 +987,11 @@ void iegbe_oem_get_phy_regs(struct iegbe
- * [10] = mdix mode
- */
- switch (adapter->hw.phy_id) {
-- case BCM5395S_PHY_ID:
-- case BCM5481_PHY_ID:
-- DEBUGOUT("WARNING: An empty iegbe_oem_get_phy_regs() has been called!\n");
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- if(corrected_len > 0) {
-- iegbe_oem_read_phy_reg_ex(&adapter->hw,
-- M88E1000_PHY_SPEC_STATUS,
-+ iegbe_oem_read_phy_reg_ex(&adapter->hw,
-+ M88E1000_PHY_SPEC_STATUS,
- (uint16_t *) &data[0]);
- }
- if(corrected_len > 0x1){
-@@ -1106,7 +1004,7 @@ void iegbe_oem_get_phy_regs(struct iegbe
- data[0x3] = 0x0; /* Dummy (to align w/ IGP phy reg dump) */
- }
- if(corrected_len > 0x4) {
-- iegbe_oem_read_phy_reg_ex(&adapter->hw, M88E1000_PHY_SPEC_CTRL,
-+ iegbe_oem_read_phy_reg_ex(&adapter->hw, M88E1000_PHY_SPEC_CTRL,
- (uint16_t *) &data[0x4]);
- }
- if(corrected_len > 0x5) {
-@@ -1144,7 +1042,7 @@ void iegbe_oem_get_phy_regs(struct iegbe
- * This is called from iegbe_set_phy_loopback in response from call from
- * ethtool to place the PHY into loopback mode.
- **/
--int
-+int
- iegbe_oem_phy_loopback(struct iegbe_adapter *adapter)
- {
- #ifdef EXTERNAL_MDIO
-@@ -1165,23 +1063,18 @@ iegbe_oem_phy_loopback(struct iegbe_adap
- * was that nonintegrated called iegbe_phy_reset_clk_and_crs(),
- * hopefully this won't matter as CRS required for half-duplex
- * operation and this is set to full duplex.
-- *
-+ *
- * Make note that the M88 phy is what'll be used on Truxton
- * Loopback configuration is the same for each of the supported PHYs.
- */
- switch (adapter->hw.phy_id) {
-- case BCM5395S_PHY_ID:
-- DEBUGOUT("WARNING: An empty iegbe_oem_phy_loopback() has been called!\n");
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- case BCM5481_PHY_ID:
-
- adapter->hw.autoneg = FALSE;
-
- /* turn off Auto-MDI/MDIX */
-- /*ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw,
-+ /*ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw,
- M88E1000_PHY_SPEC_CTRL, 0x0808);
- if(ret_val)
- {
-@@ -1206,10 +1099,10 @@ iegbe_oem_phy_loopback(struct iegbe_adap
- DEBUGOUT("Unable to write to register PHY_CTRL\n");
- return ret_val;
- }
--
--
-+
-+
- /* force 1000, set loopback */
-- /*ret_val =
-+ /*ret_val =
- iegbe_oem_write_phy_reg_ex(&adapter->hw, PHY_CTRL, 0x4140); */
- ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw, PHY_CTRL, 0x6100);
- if(ret_val) {
-@@ -1228,21 +1121,21 @@ iegbe_oem_phy_loopback(struct iegbe_adap
- E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg);
-
- /*
-- * Write out to PHY registers 29 and 30 to disable the Receiver.
-+ * Write out to PHY registers 29 and 30 to disable the Receiver.
- * This directly lifted from iegbe_phy_disable_receiver().
-- *
-+ *
- * The code is currently commented out as for the M88 used in
- * Truxton, registers 29 and 30 are unutilized. Leave in, just
-- * in case we are on the receiving end of an 'undocumented'
-+ * in case we are on the receiving end of an 'undocumented'
- * feature
- */
-- /*
-+ /*
- * iegbe_oem_write_phy_reg_ex(&adapter->hw, 29, 0x001F);
- * iegbe_oem_write_phy_reg_ex(&adapter->hw, 30, 0x8FFC);
- * iegbe_oem_write_phy_reg_ex(&adapter->hw, 29, 0x001A);
- * iegbe_oem_write_phy_reg_ex(&adapter->hw, 30, 0x8FF0);
- */
--
-+
- break;
- default:
- DEBUGOUT("Invalid PHY ID\n");
-@@ -1268,15 +1161,15 @@ iegbe_oem_phy_loopback(struct iegbe_adap
- * ethtool to place the PHY out of loopback mode. This handles the OEM
- * specific part of loopback cleanup.
- **/
--void
-+void
- iegbe_oem_loopback_cleanup(struct iegbe_adapter *adapter)
- {
- #ifdef EXTERNAL_MDIO
-
-- /*
-- * This borrows liberally from iegbe_loopback_cleanup().
-+ /*
-+ * This borrows liberally from iegbe_loopback_cleanup().
- * making note that the M88 phy is what'll be used on Truxton
-- *
-+ *
- * Loopback cleanup is the same for all supported PHYs.
- */
- int32_t ret_val;
-@@ -1289,38 +1182,32 @@ iegbe_oem_loopback_cleanup(struct iegbe_
- }
-
- switch (adapter->hw.phy_id) {
-- case BCM5395S_PHY_ID:
-- DEBUGOUT("WARNING: An empty iegbe_oem_loopback_cleanup() has been called!\n");
-- return;
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- case BCM5481_PHY_ID:
- default:
- adapter->hw.autoneg = TRUE;
--
-- ret_val = iegbe_oem_read_phy_reg_ex(&adapter->hw, PHY_CTRL,
-+
-+ ret_val = iegbe_oem_read_phy_reg_ex(&adapter->hw, PHY_CTRL,
- &phy_reg);
- if(ret_val) {
- DEBUGOUT("Unable to read to register PHY_CTRL\n");
- return;
- }
--
-+
- if(phy_reg & MII_CR_LOOPBACK) {
- phy_reg &= ~MII_CR_LOOPBACK;
--
-- ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw, PHY_CTRL,
-+
-+ ret_val = iegbe_oem_write_phy_reg_ex(&adapter->hw, PHY_CTRL,
- phy_reg);
- if(ret_val) {
- DEBUGOUT("Unable to write to register PHY_CTRL\n");
- return;
- }
--
-+
- iegbe_phy_reset(&adapter->hw);
- }
- }
--
-+
- #endif /* ifdef EXTERNAL_MDIO */
- return;
-
-@@ -1336,7 +1223,7 @@ iegbe_oem_loopback_cleanup(struct iegbe_
- * Called by iegbe_check_downshift(), checks the PHY to see if it running
- * at as speed slower than its maximum.
- **/
--uint32_t
-+uint32_t
- iegbe_oem_phy_speed_downgraded(struct iegbe_hw *hw, uint16_t *isDowngraded)
- {
- #ifdef EXTERNAL_MDIO
-@@ -1356,24 +1243,19 @@ iegbe_oem_phy_speed_downgraded(struct ie
- */
-
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- case BCM5481_PHY_ID:
-- *isDowngraded = 0;
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
- &phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
- return ret_val;
- }
--
-- *isDowngraded = (phy_data & M88E1000_PSSR_DOWNSHIFT)
-+
-+ *isDowngraded = (phy_data & M88E1000_PSSR_DOWNSHIFT)
- >> M88E1000_PSSR_DOWNSHIFT_SHIFT;
--
-- break;
-+
-+ break;
- default:
- DEBUGOUT("Invalid PHY ID\n");
- return 1;
-@@ -1388,7 +1270,7 @@ iegbe_oem_phy_speed_downgraded(struct ie
- }
-
- *isDowngraded = 0;
-- return 0;
-+ return 0;
-
- #endif /* ifdef EXTERNAL_MDIO */
- }
-@@ -1403,7 +1285,7 @@ iegbe_oem_phy_speed_downgraded(struct ie
- * Called by iegbe_check_downshift(), checks the PHY to see if it running
- * at as speed slower than its maximum.
- **/
--int32_t
-+int32_t
- iegbe_oem_check_polarity(struct iegbe_hw *hw, uint16_t *polarity)
- {
- #ifdef EXTERNAL_MDIO
-@@ -1417,33 +1299,27 @@ iegbe_oem_check_polarity(struct iegbe_hw
- return -1;
- }
-
-- /*
-+ /*
- * borrow liberally from iegbe_check_polarity.
- * Make note that the M88 phy is what'll be used on Truxton
- */
-
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- case BCM5481_PHY_ID:
-- *polarity = 0;
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- /* return the Polarity bit in the Status register. */
-- ret_val = iegbe_oem_read_phy_reg_ex(hw,
-- M88E1000_PHY_SPEC_STATUS,
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw,
-+ M88E1000_PHY_SPEC_STATUS,
- &phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
- return ret_val;
- }
-
-- *polarity = (phy_data & M88E1000_PSSR_REV_POLARITY)
-+ *polarity = (phy_data & M88E1000_PSSR_REV_POLARITY)
- >> M88E1000_PSSR_REV_POLARITY_SHIFT;
--
-- break;
--
-+
-+ break;
- default:
- DEBUGOUT("Invalid PHY ID\n");
- return -E1000_ERR_PHY_TYPE;
-@@ -1472,7 +1348,7 @@ iegbe_oem_check_polarity(struct iegbe_hw
- * the MAC with the PHY. It turns out on ICP_XXXX, this is not
- * done automagically.
- **/
--int32_t
-+int32_t
- iegbe_oem_phy_is_full_duplex(struct iegbe_hw *hw, int *isFD)
- {
- #ifdef EXTERNAL_MDIO
-@@ -1485,40 +1361,22 @@ iegbe_oem_phy_is_full_duplex(struct iegb
- if(!hw || !isFD) {
- return -1;
- }
-- /*
-+ /*
- * Make note that the M88 phy is what'll be used on Truxton
- * see iegbe_config_mac_to_phy
- */
--
-+
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- /* Always full duplex */
-- *isFD = 1;
-- break;
--
-- case BCM5481_PHY_ID:
-- ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
-- if(ret_val) return ret_val;
--
-- switch (BCM5481_ASTAT_HCD(phy_data)) {
-- case BCM5481_ASTAT_1KBTFD:
-- case BCM5481_ASTAT_100BTXFD:
-- *isFD = 1;
-- break;
-- default:
-- *isFD = 0;
-- }
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
-- if(ret_val) {
-- DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
-- return ret_val;
-- }
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
-+ &phy_data);
-+ if(ret_val) {
-+ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
-+ return ret_val;
-+ }
- *isFD = (phy_data & M88E1000_PSSR_DPLX) != 0;
--
-+
- break;
- default:
- DEBUGOUT("Invalid PHY ID\n");
-@@ -1546,7 +1404,7 @@ iegbe_oem_phy_is_full_duplex(struct iegb
- * the MAC with the PHY. It turns out on ICP_XXXX, this is not
- * done automagically.
- **/
--int32_t
-+int32_t
- iegbe_oem_phy_is_speed_1000(struct iegbe_hw *hw, int *is1000)
- {
- #ifdef EXTERNAL_MDIO
-@@ -1565,28 +1423,10 @@ iegbe_oem_phy_is_speed_1000(struct iegbe
- */
-
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- /* Always 1000mb */
-- *is1000 = 1;
-- break;
--
-- case BCM5481_PHY_ID:
-- ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
-- if(ret_val) return ret_val;
--
-- switch (BCM5481_ASTAT_HCD(phy_data)) {
-- case BCM5481_ASTAT_1KBTFD:
-- case BCM5481_ASTAT_1KBTHD:
-- *is1000 = 1;
-- break;
-- default:
-- *is1000 = 0;
-- }
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
-+ &phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
- return ret_val;
-@@ -1638,28 +1478,9 @@ iegbe_oem_phy_is_speed_100(struct iegbe_
- * see iegbe_config_mac_to_phy
- */
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- /* Always 1000Mb, never 100mb */
-- *is100 = 0;
-- break;
--
-- case BCM5481_PHY_ID:
-- ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
-- if(ret_val) return ret_val;
--
-- switch (BCM5481_ASTAT_HCD(phy_data)) {
-- case BCM5481_ASTAT_100BTXFD:
-- case BCM5481_ASTAT_100BTXHD:
-- *is100 = 1;
-- break;
-- default:
-- *is100 = 0;
-- }
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- ret_val = iegbe_oem_read_phy_reg_ex(hw,
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw,
- M88E1000_PHY_SPEC_STATUS,
- &phy_data);
- if(ret_val) {
-@@ -1714,29 +1535,24 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
- * see iegbe_phy_m88_get_info
- */
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- case BCM5481_PHY_ID:
-- DEBUGOUT("WARNING: An empty iegbe_oem_phy_get_info() has been called!\n");
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- /* The downshift status is checked only once, after link is
-- * established and it stored in the hw->speed_downgraded parameter.*/
-+ /* The downshift status is checked only once, after link is
-+ * established and it stored in the hw->speed_downgraded parameter.*/
- phy_info->downshift = (iegbe_downshift)hw->speed_downgraded;
--
-- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
-+
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_CTRL,
- &phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_CTRL\n");
- return ret_val;
- }
-
-- phy_info->extended_10bt_distance =
-- (phy_data & M88E1000_PSCR_10BT_EXT_DIST_ENABLE)
-+ phy_info->extended_10bt_distance =
-+ (phy_data & M88E1000_PSCR_10BT_EXT_DIST_ENABLE)
- >> M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT;
- phy_info->polarity_correction =
-- (phy_data & M88E1000_PSCR_POLARITY_REVERSAL)
-+ (phy_data & M88E1000_PSCR_POLARITY_REVERSAL)
- >> M88E1000_PSCR_POLARITY_REVERSAL_SHIFT;
-
- /* Check polarity status */
-@@ -1747,11 +1563,11 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
-
- phy_info->cable_polarity = polarity;
-
-- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
- &phy_data);
- if(ret_val) {
-- DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
-- return ret_val;
-+ DEBUGOUT("Unable to read register M88E1000_PHY_SPEC_STATUS\n");
-+ return ret_val;
- }
-
- phy_info->mdix_mode = (phy_data & M88E1000_PSSR_MDIX)
-@@ -1761,24 +1577,24 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
- /* Cable Length Estimation and Local/Remote Receiver Information
- * are only valid at 1000 Mbps.
- */
-- phy_info->cable_length =
-+ phy_info->cable_length =
- (phy_data & M88E1000_PSSR_CABLE_LENGTH)
- >> M88E1000_PSSR_CABLE_LENGTH_SHIFT;
-
-- ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_1000T_STATUS,
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_1000T_STATUS,
- &phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to read register PHY_1000T_STATUS\n");
- return ret_val;
- }
-
-- phy_info->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS)
-+ phy_info->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS)
- >> SR_1000T_LOCAL_RX_STATUS_SHIFT;
--
-- phy_info->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS)
-+
-+ phy_info->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS)
- >> SR_1000T_REMOTE_RX_STATUS_SHIFT;
- }
--
-+
- break;
- default:
- DEBUGOUT("Invalid PHY ID\n");
-@@ -1801,7 +1617,7 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
- * This function will perform a software initiated reset of
- * the PHY
- **/
--int32_t
-+int32_t
- iegbe_oem_phy_hw_reset(struct iegbe_hw *hw)
- {
- #ifdef EXTERNAL_MDIO
-@@ -1815,18 +1631,13 @@ iegbe_oem_phy_hw_reset(struct iegbe_hw *
- return -1;
- }
- /*
-- * This code pretty much copies the default case from
-+ * This code pretty much copies the default case from
- * iegbe_phy_reset() as that is what is appropriate for
-- * the M88 used in truxton.
-+ * the M88 used in truxton.
- */
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- DEBUGOUT("WARNING: An empty iegbe_oem_phy_hw_reset() has been called!\n");
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- case BCM5481_PHY_ID:
- ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_CTRL, &phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to read register PHY_CTRL\n");
-@@ -1864,7 +1675,7 @@ iegbe_oem_phy_hw_reset(struct iegbe_hw *
- * to perform and post reset initialiation. Not all PHYs require
- * this, which is why it was split off as a seperate function.
- **/
--void
-+void
- iegbe_oem_phy_init_script(struct iegbe_hw *hw)
- {
- #ifdef EXTERNAL_MDIO
-@@ -1877,19 +1688,17 @@ iegbe_oem_phy_init_script(struct iegbe_h
-
- /* call the GCU func that can do any phy specific init
- * functions after a reset
-- *
-+ *
- * Make note that the M88 phy is what'll be used on Truxton
- *
-- * The closest thing is in iegbe_phy_init_script, however this is
-+ * The closest thing is in iegbe_phy_init_script, however this is
- * for the IGP style of phy. This is probably a no-op for truxton
- * but may be needed by OEM's later on
-- *
-+ *
- */
- switch (hw->phy_id) {
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- case BCM5481_PHY_ID:
-- case BCM5395S_PHY_ID:
- DEBUGOUT("Nothing to do for OEM PHY Init");
- break;
- default:
-@@ -1926,13 +1735,8 @@ iegbe_oem_read_phy_reg_ex(struct iegbe_h
- return -1;
- }
-
-- if (hw->phy_id == BCM5395S_PHY_ID) {
-- DEBUGOUT("WARNING: iegbe_oem_read_phy_reg_ex() has been unexpectedly called!\n");
-- return -1;
-- }
--
- /* call the GCU func that will read the phy
-- *
-+ *
- * Make note that the M88 phy is what'll be used on Truxton.
- *
- * The closest thing is in iegbe_read_phy_reg_ex.
-@@ -1940,7 +1744,7 @@ iegbe_oem_read_phy_reg_ex(struct iegbe_h
- * NOTE: this is 1 (of 2) functions that is truly dependant on the
- * gcu module
- */
--
-+
- ret_val = gcu_read_eth_phy(iegbe_oem_get_phy_dev_number(hw),
- reg_addr, phy_data);
- if(ret_val) {
-@@ -1962,10 +1766,10 @@ iegbe_oem_read_phy_reg_ex(struct iegbe_h
- *
- * Returns E1000_SUCCESS, negative E1000 error code on failure
- *
-- * This is called from iegbe_config_mac_to_phy. Various supported
-+ * This is called from iegbe_config_mac_to_phy. Various supported
- * Phys may require the RGMII/RMII Translation gasket be set to RMII.
- **/
--int32_t
-+int32_t
- iegbe_oem_set_trans_gasket(struct iegbe_hw *hw)
- {
- #ifdef EXTERNAL_MDIO
-@@ -1978,17 +1782,12 @@ iegbe_oem_set_trans_gasket(struct iegbe_
- }
-
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- case BCM5481_PHY_ID:
-- DEBUGOUT("WARNING: An empty iegbe_oem_set_trans_gasket() has been called!\n");
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- /* Gasket set correctly for Marvell Phys, so nothing to do */
- break;
- /* Add your PHY_ID here if your device requires an RMII interface
-- case YOUR_PHY_ID:
-+ case YOUR_PHY_ID:
- ctrl_aux_reg = E1000_READ_REG(hw, CTRL_AUX);
- ctrl_aux_reg |= E1000_CTRL_AUX_ICP_xxxx_MII_TGS; // Set the RGMII_RMII bit
- */
-@@ -2032,7 +1831,7 @@ iegbe_oem_write_phy_reg_ex(struct iegbe_
- return -1;
- }
- /* call the GCU func that will write to the phy
-- *
-+ *
- * Make note that the M88 phy is what'll be used on Truxton.
- *
- * The closest thing is in iegbe_write_phy_reg_ex
-@@ -2062,11 +1861,11 @@ iegbe_oem_write_phy_reg_ex(struct iegbe_
- * @hw struct iegbe_hw hardware specific data
- *
- * iegbe_reset_hw is called to reset the MAC. If, for
-- * some reason the PHY needs to be reset as well, this
-+ * some reason the PHY needs to be reset as well, this
- * should return TRUE and then iegbe_oem_phy_hw_reset()
- * will be called.
- **/
--int
-+int
- iegbe_oem_phy_needs_reset_with_mac(struct iegbe_hw *hw)
- {
- #ifdef EXTERNAL_MDIO
-@@ -2079,16 +1878,14 @@ iegbe_oem_phy_needs_reset_with_mac(struc
- return FALSE;
- }
-
-- /*
-+ /*
- * From the original iegbe driver, the M88
-- * PHYs did not seem to need this reset,
-+ * PHYs did not seem to need this reset,
- * so returning FALSE.
- */
- switch (hw->phy_id) {
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- case BCM5481_PHY_ID:
-- case BCM5395S_PHY_ID:
- ret_val = FALSE;
- break;
- default:
-@@ -2116,7 +1913,7 @@ iegbe_oem_phy_needs_reset_with_mac(struc
- * tweaking of the PHY, for PHYs that support a DSP.
- *
- **/
--int32_t
-+int32_t
- iegbe_oem_config_dsp_after_link_change(struct iegbe_hw *hw,
- int link_up)
- {
-@@ -2138,8 +1935,6 @@ iegbe_oem_config_dsp_after_link_change(s
- switch (hw->phy_id) {
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- case BCM5481_PHY_ID:
-- case BCM5395S_PHY_ID:
- DEBUGOUT("No DSP to configure on OEM PHY");
- break;
- default:
-@@ -2165,7 +1960,7 @@ iegbe_oem_config_dsp_after_link_change(s
- *
- *
- **/
--int32_t
-+int32_t
- iegbe_oem_get_cable_length(struct iegbe_hw *hw,
- uint16_t *min_length,
- uint16_t *max_length)
-@@ -2177,21 +1972,15 @@ iegbe_oem_get_cable_length(struct iegbe_
- uint16_t phy_data;
-
- DEBUGFUNC1("%s",__func__);
--
-+
- if(!hw || !min_length || !max_length) {
- return -1;
- }
-
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- case BCM5481_PHY_ID:
-- *min_length = 0;
-- *max_length = iegbe_igp_cable_length_150;
-- break;
--
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- ret_val = iegbe_oem_read_phy_reg_ex(hw,
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw,
- M88E1000_PHY_SPEC_STATUS,
- &phy_data);
- if(ret_val) {
-@@ -2246,13 +2035,13 @@ iegbe_oem_get_cable_length(struct iegbe_
- /**
- * iegbe_oem_phy_is_link_up
- * @hw iegbe_hw struct containing device specific information
-- * @isUp a boolean returning true if link is up
-+ * @isUp a boolean returning true if link is up
- *
- * This is called as part of iegbe_config_mac_to_phy() to align
- * the MAC with the PHY. It turns out on ICP_XXXX, this is not
- * done automagically.
- **/
--int32_t
-+int32_t
- iegbe_oem_phy_is_link_up(struct iegbe_hw *hw, int *isUp)
- {
- #ifdef EXTERNAL_MDIO
-@@ -2266,35 +2055,19 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
- if(!hw || !isUp) {
- return -1;
- }
-- /*
-+ /*
- * Make note that the M88 phy is what'll be used on Truxton
- * see iegbe_config_mac_to_phy
- */
-
- switch (hw->phy_id) {
-- case BCM5395S_PHY_ID:
-- /* Link always up */
-- *isUp = TRUE;
-- return E1000_SUCCESS;
-- break;
--
-- case BCM5481_PHY_ID:
-- iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
-- ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
-- if(ret_val)
-- {
-- DEBUGOUT("Unable to read PHY register BCM5481_ESTAT\n");
-- return ret_val;
-- }
-- statusMask = BCM5481_ESTAT_LINK;
-- break;
--
-- case M88E1000_I_PHY_ID:
-+ case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-- iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
-- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
-+ iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
-+ &phy_data);
- statusMask = M88E1000_PSSR_LINK;
-- break;
-+ break;
- default:
- DEBUGOUT("Invalid PHY ID\n");
- return -E1000_ERR_PHY_TYPE;
-@@ -2319,213 +2092,3 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
- #endif /* ifdef EXTERNAL_MDIO */
- }
-
--
--
--//-----
--// Read BCM5481 expansion register
--//
--int32_t
--bcm5481_read_ex (struct iegbe_hw *hw, uint16_t reg, uint16_t *data)
--{
-- int ret;
-- uint16_t selector;
-- uint16_t reg_data;
--
-- // Get the current value of bits 15:12
-- ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &selector);
-- if (ret)
-- return ret;
--
-- // Select the expansion register
-- selector &= 0xf000;
-- selector |= (0xf << 8) | (reg);
-- iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
--
-- // Read the expansion register
-- ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &reg_data);
--
-- // De-select the expansion registers.
-- selector &= 0xf000;
-- iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
--
-- if (ret)
-- return ret;
--
-- *data = reg_data;
-- return ret;
--}
--
--//-----
--// Read reg 0x18 sub-register
--//
--static int32_t
--bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data)
--{
-- int ret;
-- uint16_t tmp_data;
--
-- // Select reg 0x18, sv
-- tmp_data = ((sv & BCM5481_R18H_SV_MASK) << 12) | BCM5481_R18H_SV_MCTRL;
-- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, tmp_data);
-- if(ret)
-- return ret;
--
-- // Read reg 0x18, sv
-- ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R18H, &tmp_data);
-- if(ret)
-- return ret;
--
-- *data = tmp_data;
-- return ret;
--}
--
--//-----
--// Read reg 0x1C sub-register
--//
--int32_t
--bcm5481_read_1csv (struct iegbe_hw *hw, int sv, uint16_t *data)
--{
-- int ret;
-- uint16_t tmp_data;
--
-- // Select reg 0x1c, sv
-- tmp_data = ((sv & BCM5481_R1CH_SV_MASK) << BCM5481_R1CH_SV_SHIFT);
--
-- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, tmp_data);
-- if(ret)
-- return ret;
--
-- // Read reg 0x1c, sv
-- ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R1CH, &tmp_data);
-- if(ret)
-- return ret;
--
-- *data = tmp_data;
-- return ret;
--}
--
--//-----
--// Read-modify-write a 0x1C register.
--//
--// hw - hardware access info.
--// reg - 0x1C register to modify.
--// data - bits which should be set.
--// mask - the '1' bits in this argument will be cleared in the data
--// read from 'reg' then 'data' will be or'd in and the result
--// will be written to 'reg'.
--
--int32_t
--bcm5481_rmw_1csv (struct iegbe_hw *hw, uint16_t reg, uint16_t data, uint16_t mask)
--{
-- int32_t ret;
-- uint16_t reg_data;
--
-- ret = 0;
--
-- ret = bcm5481_read_1csv (hw, reg, &reg_data);
-- if (ret)
-- {
-- DEBUGOUT("Unable to read BCM5481 1CH register\n");
-- printk (KERN_ERR "Unable to read BCM5481 1CH register [0x%x]\n", reg);
-- return ret;
-- }
--
-- reg_data &= ~mask;
-- reg_data |= (BCM5481_R1CH_WE | data);
--
-- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, reg_data);
-- if(ret)
-- {
-- DEBUGOUT("Unable to write BCM5481 1CH register\n");
-- printk (KERN_ERR "Unable to write BCM5481 1CH register\n");
-- return ret;
-- }
--
-- return ret;
--}
--
--int32_t
--oi_phy_setup (struct iegbe_hw *hw)
--{
-- int ret;
-- uint16_t pmii_data;
-- uint16_t mctrl_data;
-- uint16_t cacr_data;
-- uint16_t sc1_data;
-- uint16_t lctl_data;
--
-- ret = 0;
--
-- // Set low power mode via reg 0x18, sv010, bit 6
-- // Do a read-modify-write on reg 0x18, sv010 register to preserve existing bits.
-- ret = bcm5481_read_18sv (hw, BCM5481_R18H_SV_PMII, &pmii_data);
-- if (ret)
-- {
-- DEBUGOUT("Unable to read BCM5481_R18H_SV_PMII register\n");
-- printk (KERN_ERR "Unable to read BCM5481_R18H_SV_PMII register\n");
-- return ret;
-- }
--
-- // Set the LPM bit in the data just read and write back to sv010
-- // The shadow register select bits [2:0] are set by reading the sv010
-- // register.
-- pmii_data |= BCM5481_R18H_SV010_LPM;
-- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, pmii_data);
-- if(ret)
-- {
-- DEBUGOUT("Unable to write BCM5481_R18H register\n");
-- printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
-- return ret;
-- }
--
--
-- // Set the RGMII RXD to RXC skew bit in reg 0x18, sv111
--
-- if (bcm5481_read_18sv (hw, BCM5481_R18H_SV_MCTRL, &mctrl_data))
-- {
-- DEBUGOUT("Unable to read BCM5481_R18H_SV_MCTRL register\n");
-- printk (KERN_ERR "Unable to read BCM5481_R18H_SV_MCTRL register\n");
-- return ret;
-- }
-- mctrl_data |= (BCM5481_R18H_WE | BCM5481_R18H_SV111_SKEW);
--
-- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, mctrl_data);
-- if(ret)
-- {
-- DEBUGOUT("Unable to write BCM5481_R18H register\n");
-- printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
-- return ret;
-- }
--
--
-- // Enable RGMII transmit clock delay in reg 0x1c, sv00011
-- ret = bcm5481_read_1csv (hw, BCM5481_R1CH_CACR, &cacr_data);
-- if (ret)
-- {
-- DEBUGOUT("Unable to read BCM5481_R1CH_CACR register\n");
-- printk (KERN_ERR "Unable to read BCM5481_R1CH_CACR register\n");
-- return ret;
-- }
--
-- cacr_data |= (BCM5481_R1CH_WE | BCM5481_R1CH_CACR_TCD);
--
-- ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, cacr_data);
-- if(ret)
-- {
-- DEBUGOUT("Unable to write BCM5481_R1CH register\n");
-- printk (KERN_ERR "Unable to write BCM5481_R1CH register\n");
-- return ret;
-- }
--
-- // Enable dual link speed indication (0x1c, sv 00010, bit 2)
-- ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_SC1, BCM5481_R1CH_SC1_LINK, BCM5481_R1CH_SC1_LINK);
-- if (ret)
-- return ret;
--
-- // Enable link and activity on ACTIVITY LED (0x1c, sv 01001, bit 4=1, bit 3=0)
-- ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_LCTRL, BCM5481_R1CH_LCTRL_ALEN, BCM5481_R1CH_LCTRL_ALEN | BCM5481_R1CH_LCTRL_AEN);
-- if (ret)
-- return ret;
--
-- return ret;
--}
---- a/Embedded/src/GbE/iegbe_oem_phy.h
-+++ b/Embedded/src/GbE/iegbe_oem_phy.h
-@@ -2,31 +2,31 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
-- This program is free software; you can redistribute it and/or modify
-+ This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
-- 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
-+ 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
-+ 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
-- The full GNU General Public License is included in this distribution
-+ The full GNU General Public License is included in this distribution
- in the file called LICENSE.GPL.
-
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
--
-- Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
-+
-+ Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
-
- *******************************************************************************/
- #ifndef _IEGBE_OEM_PHY_H_
-@@ -45,10 +45,10 @@ int32_t iegbe_oem_set_trans_gasket(struc
- uint32_t iegbe_oem_get_tipg(struct iegbe_hw *hw);
- int iegbe_oem_phy_is_copper(struct iegbe_hw *hw);
- uint32_t iegbe_oem_get_phy_dev_number(struct iegbe_hw *hw);
--int iegbe_oem_mii_ioctl(struct iegbe_adapter *adapter, unsigned long flags,
-+int iegbe_oem_mii_ioctl(struct iegbe_adapter *adapter, unsigned long flags,
- struct ifreq *ifr, int cmd);
- void iegbe_oem_fiber_live_in_suspend(struct iegbe_hw *hw);
--void iegbe_oem_get_phy_regs(struct iegbe_adapter *adapter, uint32_t *data,
-+void iegbe_oem_get_phy_regs(struct iegbe_adapter *adapter, uint32_t *data,
- uint32_t data_length);
- int iegbe_oem_phy_loopback(struct iegbe_adapter *adapter);
- void iegbe_oem_loopback_cleanup(struct iegbe_adapter *adapter);
-@@ -94,81 +94,14 @@ int32_t iegbe_oem_phy_is_link_up(struct
- #define ICP_XXXX_MAC_2 2
-
- #define DEFAULT_ICP_XXXX_TIPG_IPGT 8 /* Inter Packet Gap Transmit Time */
--#define ICP_XXXX_TIPG_IPGT_MASK 0x000003FFUL
--#define BCM5481_PHY_ID 0x0143BCA2
--#define BCM5395S_PHY_ID 0x0143BCF0
-+#define ICP_XXXX_TIPG_IPGT_MASK 0x000003FFUL
-
- /* Miscellaneous defines */
- #ifdef IEGBE_10_100_ONLY
-- #define ICP_XXXX_AUTONEG_ADV_DEFAULT 0x0F
-+ #define ICP_XXXX_AUTONEG_ADV_DEFAULT 0x0F
- #else
- #define ICP_XXXX_AUTONEG_ADV_DEFAULT 0x2F
- #endif
-
--//-----
--// BCM5481 specifics
--
--#define BCM5481_ECTRL (0x10)
--#define BCM5481_ESTAT (0x11)
--#define BCM5481_RXERR (0x12)
--#define BCM5481_EXPRW (0x15)
--#define BCM5481_EXPACC (0x17)
--#define BCM5481_ASTAT (0x19)
--#define BCM5481_R18H (0x18)
--#define BCM5481_R1CH (0x1c)
--
--//-----
--// indirect register access via register 18h
--
--#define BCM5481_R18H_SV_MASK (7) // Mask for SV bits.
--#define BCM5481_R18H_SV_ACTRL (0) // SV000 Aux. control
--#define BCM5481_R18H_SV_10BT (1) // SV001 10Base-T
--#define BCM5481_R18H_SV_PMII (2) // SV010 Power/MII control
--#define BCM5481_R18H_SV_MTEST (4) // SV100 Misc. test
--#define BCM5481_R18H_SV_MCTRL (7) // SV111 Misc. control
--
--#define BCM5481_R18H_SV001_POL (1 << 13) // Polarity
--#define BCM5481_R18H_SV010_LPM (1 << 6)
--#define BCM5481_R18H_SV111_SKEW (1 << 8)
--#define BCM5481_R18H_WE (1 << 15) // Write enable
--
--// 0x1c registers
--#define BCM5481_R1CH_SV_SHIFT (10)
--#define BCM5481_R1CH_SV_MASK (0x1f)
--#define BCM5481_R1CH_SC1 (0x02) // sv00010 Spare control 1
--#define BCM5481_R1CH_CACR (0x03) // sv00011 Clock alignment control
--#define BCM5481_R1CH_LCTRL (0x09) // sv01001 LED control
--#define BCM5481_R1CH_LEDS1 (0x0d) // sv01101 LED selector 1
--
--// 0x1c common
--#define BCM5481_R1CH_WE (1 << 15) // Write enable
--
--// 0x1c, sv 00010
--#define BCM5481_R1CH_SC1_LINK (1 << 2) // sv00010 Linkspeed
--
--// 0x1c, sv 00011
--#define BCM5481_R1CH_CACR_TCD (1 << 9) // sv00011 RGMII tx clock delay
--
--// 0x1c, sv 01001
--#define BCM5481_R1CH_LCTRL_ALEN (1 << 4) // Activity/Link enable on ACTIVITY LED
--#define BCM5481_R1CH_LCTRL_AEN (1 << 3) // Activity enable on ACTIVITY LED
--
--
--#define BCM5481_ECTRL_DISMDIX (1 <<14)
--
--#define BCM5481_MCTRL_AUTOMDIX (1 <<9)
--
--#define BCM5481_ESTAT_LINK (1 << 8)
--
--#define BCM5481_ASTAT_ANC (1 << 15)
--#define BCM5481_ASTAT_ANHCD (7 << 8)
--#define BCM5481_ASTAT_HCD(x) ((x >> 8) & 7)
--#define BCM5481_ASTAT_1KBTFD (0x7)
--#define BCM5481_ASTAT_1KBTHD (0x6)
--#define BCM5481_ASTAT_100BTXFD (0x5)
--#define BCM5481_ASTAT_100BTXHD (0x3)
--
--// end BCM5481 specifics
--
- #endif /* ifndef _IEGBE_OEM_PHY_H_ */
--
-+
---- a/Embedded/src/GbE/iegbe_osdep.h
-+++ b/Embedded/src/GbE/iegbe_osdep.h
-@@ -2,7 +2,7 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
---- a/Embedded/src/GbE/iegbe_param.c
-+++ b/Embedded/src/GbE/iegbe_param.c
-@@ -2,7 +2,7 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
-@@ -239,11 +239,7 @@ E1000_PARAM(InterruptThrottleRate, "Inte
- #define MAX_TXABSDELAY 0xFFFF
- #define MIN_TXABSDELAY 0
-
--#ifdef IEGBE_GBE_WORKAROUND
--#define DEFAULT_ITR 0
--#else
- #define DEFAULT_ITR 8000
--#endif
-
-
- #define MAX_ITR 100000
-@@ -373,7 +369,7 @@ iegbe_check_options(struct iegbe_adapter
- tx_ring->count = opt.def;
- }
- #endif
-- for (i = 0; i < adapter->num_queues; i++)
-+ for (i = 0; i < adapter->num_tx_queues; i++)
- tx_ring[i].count = tx_ring->count;
- }
- { /* Receive Descriptor Count */
-@@ -403,7 +399,7 @@ iegbe_check_options(struct iegbe_adapter
- rx_ring->count = opt.def;
- }
- #endif
-- for (i = 0; i < adapter->num_queues; i++)
-+ for (i = 0; i < adapter->num_rx_queues; i++)
- rx_ring[i].count = rx_ring->count;
- }
- { /* Checksum Offload Enable/Disable */
---- a/Embedded/src/GbE/kcompat.c
-+++ b/Embedded/src/GbE/kcompat.c
-@@ -1,8 +1,8 @@
--/************************************************************
--
-+/************************************************************
-+
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -22,183 +22,192 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
--
-- Contact Information:
--
-- Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
--
--**************************************************************/
--/**************************************************************************
-- * @ingroup KCOMPAT_GENERAL
-- *
-- * @file kcompat.c
-- *
-- * @description
-- *
-- *
-- **************************************************************************/
--#include "kcompat.h"
--
--/*************************************************************/
--/* 2.4.13 => 2.4.3 */
--#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0xd) )
--
--/**************************************/
--/* PCI DMA MAPPING */
--
--#if defined(CONFIG_HIGHMEM)
--
--#ifndef PCI_DRAM_OFFSET
--#define PCI_DRAM_OFFSET 0
--#endif
--
--u64 _kc_pci_map_page(struct pci_dev *dev,
-- struct page *page,
-- unsigned long offset,
-- size_t size,
-- int direction)
--{
-- u64 ret_val;
-- ret_val = (((u64)(page - mem_map) << PAGE_SHIFT) + offset +
-- PCI_DRAM_OFFSET);
-- return ret_val;
--}
--
--#else /* CONFIG_HIGHMEM */
--
--u64 _kc_pci_map_page(struct pci_dev *dev,
-- struct page *page,
-- unsigned long offset,
-- size_t size,
-- int direction)
--{
-- return pci_map_single(dev, (void *)page_address(page) + offset,
-- size, direction);
--}
--
--#endif /* CONFIG_HIGHMEM */
--
--void _kc_pci_unmap_page(struct pci_dev *dev,
-- u64 dma_addr,
-- size_t size,
-- int direction)
--{
-- return pci_unmap_single(dev, dma_addr, size, direction);
--}
--
--#endif /* 2.4.13 => 2.4.3 */
--
--
--/*****************************************************************************/
--/* 2.4.3 => 2.4.0 */
--#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0x3) )
--
--/**************************************/
--/* PCI DRIVER API */
--
--int _kc_pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask)
--{
-- if(!pci_dma_supported(dev, mask)) {
-- return -EIO;
-- }
-- dev->dma_mask = mask;
-- return 0;
--}
--
--int _kc_pci_request_regions(struct pci_dev *dev, char *res_name)
--{
-- int i;
--
-- for (i = 0; i < 0x6; i++) {
-- if (pci_resource_len(dev, i) == 0) {
-- continue;
-- }
-- if (pci_resource_flags(dev, i) & IORESOURCE_IO) {
-- if (!request_region(pci_resource_start(dev, i),
-- pci_resource_len(dev, i), res_name)) {
-- pci_release_regions(dev);
-- return -EBUSY;
-- }
-- } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
-- if (!request_mem_region(pci_resource_start(dev, i),
-- pci_resource_len(dev, i),
-- res_name)) {
-- pci_release_regions(dev);
-- return -EBUSY;
-- }
-- }
-- }
-- return 0;
--}
--
--void _kc_pci_release_regions(struct pci_dev *dev)
--{
-- int i;
--
-- for (i = 0; i < 0x6; i++) {
-- if (pci_resource_len(dev, i) == 0) {
-- continue;
-- }
-- if (pci_resource_flags(dev, i) & IORESOURCE_IO){
-- release_region(pci_resource_start(dev, i),
-- pci_resource_len(dev, i));
-- } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
-- release_mem_region(pci_resource_start(dev, i),
-- pci_resource_len(dev, i));
-- }
-- }
--}
--
--/**************************************/
--/* NETWORK DRIVER API */
--
--struct net_device * _kc_alloc_etherdev(int sizeof_priv)
--{
-- struct net_device *dev;
-- int alloc_size;
--
-- alloc_size = sizeof(*dev) + sizeof_priv + IFNAMSIZ + 0x1f;
--
-- dev = kmalloc(alloc_size, GFP_KERNEL);
--
-- if (!dev) { return NULL; }
--
-- memset(dev, 0, alloc_size);
--
-- if (sizeof_priv) {
-- dev->priv = (void *) (((unsigned long)(dev + 1) + 0x1f) & ~0x1f);
-- }
-- dev->name[0] = '\0';
--
-- ether_setup(dev);
--
-- return dev;
--}
--
--int _kc_is_valid_ether_addr(u8 *addr)
--{
-- const char zaddr[0x6] = {0,};
--
-- return !(addr[0]&1) && memcmp( addr, zaddr, 0x6);
--}
--
--#endif /* 2.4.3 => 2.4.0 */
--
--
--/*****************************************************************/
--/* 2.4.6 => 2.4.3 */
--#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0x6) )
--
--int _kc_pci_set_power_state(struct pci_dev *dev, int state)
--{ return 0; }
--int _kc_pci_save_state(struct pci_dev *dev, u32 *buffer)
--{ return 0; }
--int _kc_pci_restore_state(struct pci_dev *pdev, u32 *buffer)
--{ return 0; }
--int _kc_pci_enable_wake(struct pci_dev *pdev, u32 state, int enable)
--{ return 0; }
--
--#endif /* 2.4.6 => 2.4.3 */
--
--
-+ version: Embedded.Release.Patch.L.1.0.7-5
-+
-+ Contact Information:
-+
-+ Intel Corporation, 5000 W Chandler Blvd, Chandler, AZ 85226
-+
-+**************************************************************/
-+/**************************************************************************
-+ * @ingroup KCOMPAT_GENERAL
-+ *
-+ * @file kcompat.c
-+ *
-+ * @description
-+ *
-+ *
-+ **************************************************************************/
-+#include "kcompat.h"
-+
-+/*************************************************************/
-+/* 2.4.13 => 2.4.3 */
-+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0xd) )
-+
-+/**************************************/
-+/* PCI DMA MAPPING */
-+
-+#if defined(CONFIG_HIGHMEM)
-+
-+#ifndef PCI_DRAM_OFFSET
-+#define PCI_DRAM_OFFSET 0
-+#endif
-+
-+u64 _kc_pci_map_page(struct pci_dev *dev,
-+ struct page *page,
-+ unsigned long offset,
-+ size_t size,
-+ int direction)
-+{
-+ u64 ret_val;
-+ ret_val = (((u64)(page - mem_map) << PAGE_SHIFT) + offset +
-+ PCI_DRAM_OFFSET);
-+ return ret_val;
-+}
-+
-+#else /* CONFIG_HIGHMEM */
-+
-+u64 _kc_pci_map_page(struct pci_dev *dev,
-+ struct page *page,
-+ unsigned long offset,
-+ size_t size,
-+ int direction)
-+{
-+ return pci_map_single(dev, (void *)page_address(page) + offset,
-+ size, direction);
-+}
-+
-+#endif /* CONFIG_HIGHMEM */
-+
-+void _kc_pci_unmap_page(struct pci_dev *dev,
-+ u64 dma_addr,
-+ size_t size,
-+ int direction)
-+{
-+ return pci_unmap_single(dev, dma_addr, size, direction);
-+}
-+
-+#endif /* 2.4.13 => 2.4.3 */
-+
-+
-+/*****************************************************************************/
-+/* 2.4.3 => 2.4.0 */
-+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0x3) )
-+
-+/**************************************/
-+/* PCI DRIVER API */
-+
-+int _kc_pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask)
-+{
-+ if(!pci_dma_supported(dev, mask)) {
-+ return -EIO;
-+ }
-+ dev->dma_mask = mask;
-+ return 0;
-+}
-+
-+int _kc_pci_request_regions(struct pci_dev *dev, char *res_name)
-+{
-+ int i;
-+
-+ for (i = 0; i < 0x6; i++) {
-+ if (pci_resource_len(dev, i) == 0) {
-+ continue;
-+ }
-+ if (pci_resource_flags(dev, i) & IORESOURCE_IO) {
-+ if (!request_region(pci_resource_start(dev, i),
-+ pci_resource_len(dev, i), res_name)) {
-+ pci_release_regions(dev);
-+ return -EBUSY;
-+ }
-+ } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
-+ if (!request_mem_region(pci_resource_start(dev, i),
-+ pci_resource_len(dev, i),
-+ res_name)) {
-+ pci_release_regions(dev);
-+ return -EBUSY;
-+ }
-+ }
-+ }
-+ return 0;
-+}
-+
-+void _kc_pci_release_regions(struct pci_dev *dev)
-+{
-+ int i;
-+
-+ for (i = 0; i < 0x6; i++) {
-+ if (pci_resource_len(dev, i) == 0) {
-+ continue;
-+ }
-+ if (pci_resource_flags(dev, i) & IORESOURCE_IO){
-+ release_region(pci_resource_start(dev, i),
-+ pci_resource_len(dev, i));
-+ } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
-+ release_mem_region(pci_resource_start(dev, i),
-+ pci_resource_len(dev, i));
-+ }
-+ }
-+}
-+
-+/**************************************/
-+/* NETWORK DRIVER API */
-+
-+struct net_device * _kc_alloc_etherdev(int sizeof_priv)
-+{
-+ struct net_device *dev;
-+ int alloc_size;
-+
-+ alloc_size = sizeof(*dev) + sizeof_priv + IFNAMSIZ + 0x1f;
-+
-+ dev = kmalloc(alloc_size, GFP_KERNEL);
-+
-+ if (!dev) { return NULL; }
-+
-+ memset(dev, 0, alloc_size);
-+
-+ if (sizeof_priv) {
-+ dev->priv = (void *) (((unsigned long)(dev + 1) + 0x1f) & ~0x1f);
-+ }
-+ dev->name[0] = '\0';
-+
-+ ether_setup(dev);
-+
-+ return dev;
-+}
-+
-+int _kc_is_valid_ether_addr(u8 *addr)
-+{
-+ const char zaddr[0x6] = {0,};
-+
-+ return !(addr[0]&1) && memcmp( addr, zaddr, 0x6);
-+}
-+
-+#endif /* 2.4.3 => 2.4.0 */
-+
-+
-+/*****************************************************************/
-+/* 2.4.6 => 2.4.3 */
-+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(0x2,0x4,0x6) )
-+
-+int _kc_pci_set_power_state(struct pci_dev *dev, int state)
-+{ return 0; }
-+int _kc_pci_save_state(struct pci_dev *dev, u32 *buffer)
-+{ return 0; }
-+int _kc_pci_restore_state(struct pci_dev *pdev, u32 *buffer)
-+{ return 0; }
-+int _kc_pci_enable_wake(struct pci_dev *pdev, u32 state, int enable)
-+{ return 0; }
-+
-+#endif /* 2.4.6 => 2.4.3 */
-+
-+
-+
-+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24) )
-+
-+void dump_stack(void)
-+{
-+}
-+
-+#endif /* 2.4.24 */
-+
---- a/Embedded/src/GbE/kcompat_ethtool.c
-+++ b/Embedded/src/GbE/kcompat_ethtool.c
-@@ -2,7 +2,7 @@
- /*
- * GPL LICENSE SUMMARY
- *
-- * Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
-@@ -22,7 +22,7 @@
- * Contact Information:
- * Intel Corporation
- *
-- * version: Embedded.L.1.0.34
-+ * version: Embedded.Release.Patch.L.1.0.7-5
- */
-
- /**************************************************************************
-@@ -779,6 +779,7 @@ static int ethtool_get_stats(struct net_
- }
-
- /* The main entry point in this file. Called from net/core/dev.c */
-+
- #define ETHTOOL_OPS_COMPAT
- int ethtool_ioctl(struct ifreq *ifr)
- {
---- a/Embedded/src/GbE/kcompat.h
-+++ b/Embedded/src/GbE/kcompat.h
-@@ -2,7 +2,7 @@
-
- GPL LICENSE SUMMARY
-
-- Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+ Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
-@@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
- Contact Information:
- Intel Corporation
-
-- version: Embedded.L.1.0.34
-+ version: Embedded.Release.Patch.L.1.0.7-5
-
- Contact Information:
-
-@@ -69,15 +69,6 @@ GPL LICENSE SUMMARY
- #define CONFIG_NET_POLL_CONTROLLER
- #endif
-
--#ifdef E1000_NAPI
--#undef CONFIG_E1000_NAPI
--#define CONFIG_E1000_NAPI
--#endif
--
--#ifdef E1000_NO_NAPI
--#undef CONFIG_E1000_NAPI
--#endif
--
- #ifndef module_param
- #define module_param(v,t,p) MODULE_PARM(v, "i");
- #endif
-@@ -554,35 +545,14 @@ extern void _kc_pci_unmap_page(struct pc
- #endif
-
- /*****************************************************************************/
--/* 2.4.23 => 2.4.22 */
--#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) )
--#ifdef CONFIG_E1000_NAPI
--#ifndef netif_poll_disable
--#define netif_poll_disable(x) _kc_netif_poll_disable(x)
--static inline void _kc_netif_poll_disable(struct net_device *netdev)
--{
-- while (test_and_set_bit(__LINK_STATE_RX_SCHED, &netdev->state)) {
-- /* No hurry */
-- current->state = TASK_INTERRUPTIBLE;
-- schedule_timeout(1);
-- }
--}
--#endif
--#ifndef netif_poll_enable
--#define netif_poll_enable(x) _kc_netif_poll_enable(x)
--static inline void _kc_netif_poll_enable(struct net_device *netdev)
--{
-- clear_bit(__LINK_STATE_RX_SCHED, &netdev->state);
--}
--#endif
--#endif
--#endif
--
--/*****************************************************************************/
- /* 2.5.28 => 2.4.23 */
- #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,28) )
-
-+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) )
-+static inline void _kc_synchronize_irq(void) { barrier(); }
-+#else
- static inline void _kc_synchronize_irq() { synchronize_irq(); }
-+#endif /* 2.4.23 */
- #undef synchronize_irq
- #define synchronize_irq(X) _kc_synchronize_irq()
-
-@@ -747,6 +717,37 @@ static inline struct mii_ioctl_data *_kc
- #define skb_header_cloned(x) 0
- #endif /* SKB_DATAREF_SHIFT not defined */
-
-+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) )
-+
-+#define ioread32(addr) readl(addr)
-+#define iowrite32(val,addr) writel(val,addr)
-+
-+#endif /* 2.6.10 */
-+
-+#ifndef DEFINE_SPINLOCK
-+#define DEFINE_SPINLOCK(s) spinlock_t s = SPIN_LOCK_UNLOCKED
-+#endif /* DEFINE_SPINLOCK */
-+
-+#ifndef PCI_COMMAND_INTX_DISABLE
-+#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */
-+#endif /* PCI_COMMAND_INTX_DISABLE */
-+
-+#ifndef ETH_GSTRING_LEN
-+#define ETH_GSTRING_LEN 32
-+#endif /* ETH_GSTRING_LEN */
-+
-+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,24) )
-+
-+extern void dump_stack(void);
-+
-+#undef register_reboot_notifier
-+#define register_reboot_notifier(a)
-+
-+#undef unregister_reboot_notifier
-+#define unregister_reboot_notifier(a)
-+
-+#endif /* 2.4.24 */
-+
- #endif /* _KCOMPAT_H_ */
-
-
---- a/Embedded/src/GbE/Makefile
-+++ b/Embedded/src/GbE/Makefile
-@@ -1,6 +1,6 @@
- # GPL LICENSE SUMMARY
- #
--# Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
-+# Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of version 2 of the GNU General Public License as
-@@ -20,7 +20,7 @@
- # Contact Information:
- # Intel Corporation
- #
--# version: Embedded.L.1.0.34
-+# version: Embedded.Release.Patch.L.1.0.7-5
-
- ###########################################################################
- # Driver files
-@@ -35,6 +35,8 @@ MDIO_PHONY_CFILES = gcu.c
- MDIO_CFILES = gcu_main.c gcu_if.c
- MDIO_HFILES = gcu.h gcu_if.h gcu_reg.h kcompat.h
-
-+KVER=$(shell uname -r)
-+
- #
- # Variables:
- # KSRC (path to kernel source to build against)
-@@ -50,45 +52,16 @@ MDIO_HFILES = gcu.h gcu_if.h gcu_reg.h k
-
- # set KSRC, KOBJ, and EXTERNAL_MDIO to default values of not already set
- #
--KOBJ ?= /usr/src/kernels/linux
--KSRC ?= /usr/src/kernels/linux
-+#KOBJ=/usr/src/kernels/linux
-+#KSRC=/usr/src/kernels/linux
-+#KSRC=$(KOBJ)
- EXTERNAL_MDIO ?= 1
- GBE_NAME = iegbe
- GCU_NAME = gcu
-
--# By default the workaround for the IEGBE writeback issue is enabled
--#
--IEGBE_GBE_WORKAROUND ?= 0
--
--# If the platform only supports 10/100 this variable needs to be set
--# so the default advertisement is set appropriately.
--# By default, this variable will be disabled.
--#
--IEGBE_10_100_ONLY ?= 0
--
--# check for version.h and autoconf.h for running kernel in /boot (SUSE)
--ifneq (,$(wildcard /boot/vmlinuz.version.h))
-- VERSION_FILE := /boot/vmlinuz.version.h
-- CONFIG_FILE := /boot/vmlinuz.autoconf.h
-- KVER := $(shell $(CC) $(CFLAGS) -E -dM $(VERSION_FILE) | \
-- grep UTS_RELEASE | awk '{ print $$3 }' | sed 's/\"//g')
-- ifeq ($(KVER),$(shell uname -r))
-- # set up include path to override headers from kernel source
-- x:=$(shell rm -rf include)
-- x:=$(shell mkdir -p include/linux)
-- x:=$(shell cp /boot/vmlinuz.version.h include/linux/version.h)
-- x:=$(shell cp /boot/vmlinuz.autoconf.h include/linux/autoconf.h)
-- CFLAGS += -I./include
-- else
-- VERSION_FILE := $(KOBJ)/include/linux/version.h
-- UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
-- CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
-- endif
--else
-- VERSION_FILE := $(KOBJ)/include/linux/version.h
-- UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
-- CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
--endif
-+VERSION_FILE := $(KSRC)/include/linux/version.h
-+UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
-+CONFIG_FILE := $(KSRC)/include/linux/autoconf.h
-
- ifeq (,$(wildcard $(VERSION_FILE)))
- $(error Linux kernel source not configured - missing version.h)
-@@ -98,83 +71,8 @@ ifeq (,$(wildcard $(CONFIG_FILE)))
- $(error Linux kernel source not configured - missing autoconf.h)
- endif
-
--# as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
--# so check that file for kernel version string instead of version.h
--USE_UTS_REL := $(shell [ -f $(UTS_REL_FILE) ] && echo "1")
--
--# pick a compiler
--ifneq (,$(findstring egcs-2.91.66, $(shell cat /proc/version)))
-- CC := kgcc gcc cc
--else
-- CC := gcc cc
--endif
--test_cc = $(shell $(cc) --version > /dev/null 2>&1 && echo $(cc))
--CC := $(foreach cc, $(CC), $(test_cc))
--CC := $(firstword $(CC))
--ifeq (,$(CC))
-- $(error Compiler not found)
--endif
--
--# we need to know what platform the driver is being built on
--# some additional features are only built on Intel platforms
--ARCH := $(shell uname -m | sed 's/i.86/i386/')
--ifeq ($(ARCH),alpha)
-- CFLAGS += -ffixed-8 -mno-fp-regs
--endif
--ifeq ($(ARCH),x86_64)
-- CFLAGS += -mcmodel=kernel -mno-red-zone
--endif
--ifeq ($(ARCH),ppc)
-- CFLAGS += -msoft-float
--endif
--ifeq ($(ARCH),ppc64)
-- CFLAGS += -m64 -msoft-float
-- LDFLAGS += -melf64ppc
--endif
--
--# standard flags for module builds
--CFLAGS += -DLINUX -D__KERNEL__ -DMODULE -O2 -pipe -Wall
--CFLAGS += -I$(KSRC)/include -I.
--CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \
-- echo "-DMODVERSIONS -DEXPORT_SYMTAB \
-- -include $(KSRC)/include/linux/modversions.h")
--
--ifeq ($(IEGBE_GBE_WORKAROUND), 1)
--CFLAGS += -DIEGBE_GBE_WORKAROUND -DE1000_NO_NAPI
--endif
--
--ifeq ($(IEGBE_10_100_ONLY), 1)
--CFLAGS += -DIEGBE_10_100_ONLY
--endif
--
--CFLAGS += $(CFLAGS_EXTRA)
--#ifeq (,$(shell echo $(CFLAGS_EXTRA) | grep NAPI))
--#CFLAGS += -DE1000_NO_NAPI
--#CFLAGS_EXTRA += -DE1000_NO_NAPI
--#endif
--
--RHC := $(KSRC)/include/linux/rhconfig.h
--ifneq (,$(wildcard $(RHC)))
-- # 7.3 typo in rhconfig.h
-- ifneq (,$(shell $(CC) $(CFLAGS) -E -dM $(RHC) | grep __module__bigmem))
-- CFLAGS += -D__module_bigmem
-- endif
--endif
--
--# get the kernel version - we use this to find the correct install path
--ifeq ($(USE_UTS_REL), 1)
-- KVER := $(shell $(CC) $(CFLAGS) -E -dM $(UTS_REL_FILE) | grep UTS_RELEASE | \
-- awk '{ print $$3 }' | sed 's/\"//g')
--else
-- KVER := $(shell $(CC) $(CFLAGS) -E -dM $(VERSION_FILE) | grep UTS_RELEASE | \
-- awk '{ print $$3 }' | sed 's/\"//g')
--endif
--
--KKVER := $(shell echo $(KVER) | \
-- awk '{ if ($$0 ~ /2\.[6-9]\./) print "1"; else print "0"}')
--ifeq ($(KKVER), 0)
-- $(error *** Aborting the build. \
-- *** This driver is not supported on kernel versions older than 2.6.18)
-+ifeq (,$(wildcard $(UTS_REL_FILE)))
-+ $(error Linux kernel source not configured - missing utsrelease.h)
- endif
-
- # set the install path
-@@ -202,11 +100,11 @@ ifneq ($(SMP),$(shell uname -a | grep SM
- endif
-
- ifeq ($(SMP),1)
-- CFLAGS += -D__SMP__
-+ EXTRA_CFLAGS += -D__SMP__
- endif
-
- ifeq ($(EXTERNAL_MDIO), 1)
-- CFLAGS += -DEXTERNAL_MDIO
-+ EXTRA_CFLAGS += -DEXTERNAL_MDIO
- endif
-
- ###########################################################################
-@@ -223,7 +121,6 @@ MANSECTION = 7
- MANFILE = $(TARGET:.ko=.$(MANSECTION))
-
- ifneq ($(PATCHLEVEL),)
-- EXTRA_CFLAGS += $(CFLAGS_EXTRA)
- obj-m += $(TARGET:.ko=.o)
- iegbe-objs := $(CFILES:.c=.o)
- ifeq ($(EXTERNAL_MDIO),1)
---- a/filelist
-+++ b/filelist
-@@ -1,41 +1,3 @@
--Embedded/Makefile
--Embedded/environment.mk
--Embedded/src/1588/1588.c
--Embedded/src/1588/1588.h
--Embedded/src/1588/IxTimeSyncAcc_p.h
--Embedded/src/1588/Makefile
--Embedded/src/1588/ixtimesyncacc.c
--Embedded/src/1588/ixtimesyncacc.h
--Embedded/src/1588/linux_ioctls.h
--Embedded/src/CAN/Makefile
--Embedded/src/CAN/can_fifo.c
--Embedded/src/CAN/can_fifo.h
--Embedded/src/CAN/can_ioctl.h
--Embedded/src/CAN/can_main.c
--Embedded/src/CAN/can_main.h
--Embedded/src/CAN/can_port.h
--Embedded/src/CAN/icp_can.c
--Embedded/src/CAN/icp_can.h
--Embedded/src/CAN/icp_can_regs.h
--Embedded/src/CAN/icp_can_types.h
--Embedded/src/CAN/icp_can_user.h
--Embedded/src/EDMA/Makefile
--Embedded/src/EDMA/dma.h
--Embedded/src/EDMA/dma_api.h
--Embedded/src/EDMA/dma_client_api.c
--Embedded/src/EDMA/dma_common.c
--Embedded/src/EDMA/dma_internals.h
--Embedded/src/EDMA/dma_linux.c
--Embedded/src/EDMA/os/os.c
--Embedded/src/EDMA/os/os.h
--Embedded/src/EDMA/os/os_list.c
--Embedded/src/EDMA/os/os_list.h
--Embedded/src/EDMA/os/os_types.h
--Embedded/src/GPIO/Makefile
--Embedded/src/GPIO/common.h
--Embedded/src/GPIO/gpio.h
--Embedded/src/GPIO/gpio_ref.c
--Embedded/src/GPIO/linux_ioctls.h
- Embedded/src/GbE/Makefile
- Embedded/src/GbE/gcu.h
- Embedded/src/GbE/gcu_if.c
-@@ -55,16 +17,6 @@ Embedded/src/GbE/iegbe_param.c
- Embedded/src/GbE/kcompat.c
- Embedded/src/GbE/kcompat.h
- Embedded/src/GbE/kcompat_ethtool.c
--Embedded/src/WDT/Makefile
--Embedded/src/WDT/iwdt.c
--Embedded/src/WDT/iwdt.h
--Embedded/src/patches/Intel_EP80579_RHEL5.patch
--Embedded/src/patches/pci.ids_RHEL5.patch
- LICENSE.GPL
--build_system/build_files/Core/ia.mk
--build_system/build_files/OS/linux_2.6.mk
--build_system/build_files/OS/linux_2.6_kernel_space_rules.mk
--build_system/build_files/common.mk
--build_system/build_files/rules.mk
- filelist
- versionfile
---- a/versionfile
-+++ b/versionfile
-@@ -1,4 +1,4 @@
--PACKAGE_TYPE=Embedded
-+PACKAGE_TYPE=Embedded.Release.Patch
-
- PACKAGE_OS=L
-
-@@ -6,4 +6,6 @@ PACKAGE_VERSION_MAJOR_NUMBER=1
-
- PACKAGE_VERSION_MINOR_NUMBER=0
-
--PACKAGE_VERSION_PATCH_NUMBER=34
-+PACKAGE_VERSION_PATCH_NUMBER=7
-+
-+PACKAGE_VERSION_BUILD_NUMBER=5
diff --git a/package/system/ep80579-drivers/patches/002-cflags_cleanup.patch b/package/system/ep80579-drivers/patches/002-cflags_cleanup.patch
deleted file mode 100644
index f897527956..0000000000
--- a/package/system/ep80579-drivers/patches/002-cflags_cleanup.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- a/build_system/build_files/common.mk
-+++ b/build_system/build_files/common.mk
-@@ -122,7 +122,7 @@ CC=$(COMPILER)
- LD=$(LINKER)
- AR=$(ARCHIVER)
-
--CFLAGS+=-O2
-+#CFLAGS+=-O2
-
-
- PWD= $(shell pwd)
---- a/build_system/build_files/OS/linux_2.6.mk
-+++ b/build_system/build_files/OS/linux_2.6.mk
-@@ -80,7 +80,7 @@ endif
-
-
- ifeq ($(OS_LEVEL), kernel_space)
--CFLAGS+=
-+#CFLAGS+=
- endif
-
-
diff --git a/package/system/ep80579-drivers/patches/003-new_irqf_constants.patch b/package/system/ep80579-drivers/patches/003-new_irqf_constants.patch
deleted file mode 100644
index af231f2184..0000000000
--- a/package/system/ep80579-drivers/patches/003-new_irqf_constants.patch
+++ /dev/null
@@ -1,53 +0,0 @@
---- a/Embedded/src/1588/1588.c
-+++ b/Embedded/src/1588/1588.c
-@@ -291,7 +291,7 @@ int pci_probe(struct pci_dev *dev, const
-
- }
-
-- if ( request_irq(dev->irq, &timesync_isr, SA_SHIRQ, DRIVERNAME,
-+ if ( request_irq(dev->irq, &timesync_isr, IRQF_SHARED, DRIVERNAME,
- &g_drvr_data) )
- {
- printk("%s-pci_probe: irq\n", DRIVERNAME);
---- a/Embedded/src/CAN/can_main.c
-+++ b/Embedded/src/CAN/can_main.c
-@@ -424,7 +424,7 @@ int can_open(struct inode *inode, struct
- err = request_irq(
- can_os->irq,
- can_irq_handler,
-- SA_SHIRQ,
-+ IRQF_SHARED,
- iminor(can_os->inode) ? CAN_PROC_1 : CAN_PROC_0,
- &(g_can_os[iminor(can_os->inode)])
- );
---- a/Embedded/src/EDMA/dma_linux.c
-+++ b/Embedded/src/EDMA/dma_linux.c
-@@ -367,7 +367,7 @@ int32_t edma_resume(struct pci_dev *dev)
- return -ENODEV;
- }
-
-- if (request_irq(dev->irq, &edma_irq_handler, SA_SHIRQ,
-+ if (request_irq(dev->irq, &edma_irq_handler, IRQF_SHARED,
- g_char_drvr_name, dev) )
- {
-
-@@ -829,7 +829,7 @@ int32_t edma_probe(struct pci_dev * dev,
- /*
- * Obtain a (shared) Interrupt Request (IRQ) Line from the OS.
- */
-- if (request_irq(dev->irq, &edma_irq_handler, SA_SHIRQ,
-+ if (request_irq(dev->irq, &edma_irq_handler, IRQF_SHARED,
- g_char_drvr_name, dev) )
- {
-
---- a/Embedded/src/WDT/iwdt.c
-+++ b/Embedded/src/WDT/iwdt.c
-@@ -1461,7 +1461,7 @@ static int __init wdt_init_one(struct pc
-
- /* Request irq only if wdt_irq is other than 0 */
- if (wdt_irq) {
-- if (request_irq(wdt_irq, wdt_isr, SA_INTERRUPT | SA_SHIRQ,
-+ if (request_irq(wdt_irq, wdt_isr, IRQF_DISABLED | IRQF_SHARED,
- "iwdt", &wdt_miscdev)) {
- printk("IRQ %d is not free.\n", wdt_irq);
- return -EIO;
diff --git a/package/system/ep80579-drivers/patches/100-iegbe_netdev_ops.patch b/package/system/ep80579-drivers/patches/100-iegbe_netdev_ops.patch
deleted file mode 100644
index 162449c69b..0000000000
--- a/package/system/ep80579-drivers/patches/100-iegbe_netdev_ops.patch
+++ /dev/null
@@ -1,56 +0,0 @@
---- a/Embedded/src/GbE/iegbe_main.c
-+++ b/Embedded/src/GbE/iegbe_main.c
-@@ -724,6 +724,26 @@ static void iegbe_dump_eeprom(struct ieg
- kfree(data);
- }
-
-+static const struct net_device_ops iegbe_netdev_ops = {
-+ .ndo_open = iegbe_open,
-+ .ndo_stop = iegbe_close,
-+ .ndo_start_xmit = iegbe_xmit_frame,
-+ .ndo_get_stats = iegbe_get_stats,
-+ .ndo_set_rx_mode = iegbe_set_rx_mode,
-+ .ndo_set_mac_address = iegbe_set_mac,
-+ .ndo_tx_timeout = iegbe_tx_timeout,
-+ .ndo_change_mtu = iegbe_change_mtu,
-+ .ndo_do_ioctl = iegbe_ioctl,
-+ .ndo_validate_addr = eth_validate_addr,
-+
-+ .ndo_vlan_rx_register = iegbe_vlan_rx_register,
-+ .ndo_vlan_rx_add_vid = iegbe_vlan_rx_add_vid,
-+ .ndo_vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid,
-+#ifdef CONFIG_NET_POLL_CONTROLLER
-+ .ndo_poll_controller = iegbe_netpoll,
-+#endif
-+};
-+
- /**
- * iegbe_probe - Device Initialization Routine
- * @pdev: PCI device information struct
-@@ -800,24 +820,11 @@ static int __devinit iegbe_probe(struct
- if (!hw->hw_addr)
- goto err_ioremap;
-
-- netdev->open = &iegbe_open;
-- netdev->stop = &iegbe_close;
-- netdev->hard_start_xmit = &iegbe_xmit_frame;
-- netdev->get_stats = &iegbe_get_stats;
-- netdev->set_rx_mode = &iegbe_set_rx_mode;
-- netdev->set_mac_address = &iegbe_set_mac;
-- netdev->change_mtu = &iegbe_change_mtu;
-- netdev->do_ioctl = &iegbe_ioctl;
-+ netdev->netdev_ops = &iegbe_netdev_ops;
- set_ethtool_ops(netdev);
-- netdev->tx_timeout = &iegbe_tx_timeout;
- netdev->watchdog_timeo = 5 * HZ;
- netif_napi_add(netdev, &adapter->napi, iegbe_clean, 64);
-- netdev->vlan_rx_register = iegbe_vlan_rx_register;
-- netdev->vlan_rx_add_vid = iegbe_vlan_rx_add_vid;
-- netdev->vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid;
--#ifdef CONFIG_NET_POLL_CONTROLLER
-- netdev->poll_controller = iegbe_netpoll;
--#endif
-+
- strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
-
-
diff --git a/package/system/ep80579-drivers/patches/101-iegbe_fix_napi_interface.patch b/package/system/ep80579-drivers/patches/101-iegbe_fix_napi_interface.patch
deleted file mode 100644
index 921d464bad..0000000000
--- a/package/system/ep80579-drivers/patches/101-iegbe_fix_napi_interface.patch
+++ /dev/null
@@ -1,41 +0,0 @@
---- a/Embedded/src/GbE/iegbe_main.c
-+++ b/Embedded/src/GbE/iegbe_main.c
-@@ -3465,12 +3465,12 @@ static irqreturn_t iegbe_intr_msi(int ir
- printk("Critical error! ICR = 0x%x\n", icr);
- return IRQ_HANDLED;
- }
-- if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
-+ if (likely(napi_schedule_prep(&adapter->napi))) {
- adapter->total_tx_bytes = 0;
- adapter->total_tx_packets = 0;
- adapter->total_rx_bytes = 0;
- adapter->total_rx_packets = 0;
-- __netif_rx_schedule(netdev, &adapter->napi);
-+ __napi_schedule(&adapter->napi);
- } else
- iegbe_irq_enable(adapter);
-
-@@ -3527,12 +3527,12 @@ iegbe_intr(int irq, void *data)
- E1000_WRITE_REG(&adapter->hw, IMC, ~0);
- E1000_WRITE_FLUSH(&adapter->hw);
- }
-- if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
-+ if (likely(napi_schedule_prep(&adapter->napi))) {
- adapter->total_tx_bytes = 0;
- adapter->total_tx_packets = 0;
- adapter->total_rx_bytes = 0;
- adapter->total_rx_packets = 0;
-- __netif_rx_schedule(netdev, &adapter->napi);
-+ __napi_schedule(&adapter->napi);
- } else
- /* this really should not happen! if it does it is basically a
- * bug, but not a hard error, so enable ints and continue */
-@@ -3574,7 +3574,7 @@ static int iegbe_clean(struct napi_struc
- if (work_done < budget) {
- if (likely(adapter->itr_setting & 3))
- iegbe_set_itr(adapter);
-- netif_rx_complete(poll_dev, napi);
-+ napi_complete(napi);
- iegbe_irq_enable(adapter);
- }
-
diff --git a/package/system/ep80579-drivers/patches/102-iegbe_nuke_polling_netdev.patch b/package/system/ep80579-drivers/patches/102-iegbe_nuke_polling_netdev.patch
deleted file mode 100644
index f7ca62709d..0000000000
--- a/package/system/ep80579-drivers/patches/102-iegbe_nuke_polling_netdev.patch
+++ /dev/null
@@ -1,103 +0,0 @@
---- a/Embedded/src/GbE/iegbe.h
-+++ b/Embedded/src/GbE/iegbe.h
-@@ -316,7 +316,6 @@ struct iegbe_adapter {
- int cleaned_count);
- struct iegbe_rx_ring *rx_ring; /* One per active queue */
- struct napi_struct napi;
-- struct net_device *polling_netdev; /* One per active queue */
-
- int num_tx_queues;
- int num_rx_queues;
---- a/Embedded/src/GbE/iegbe_main.c
-+++ b/Embedded/src/GbE/iegbe_main.c
-@@ -763,7 +763,7 @@ static int __devinit iegbe_probe(struct
- struct iegbe_hw *hw;
-
- static int cards_found = 0;
-- int i, err, pci_using_dac;
-+ int err, pci_using_dac;
- u16 eeprom_data = 0;
- u16 eeprom_apme_mask = E1000_EEPROM_APME;
- int bars;
-@@ -984,11 +984,8 @@ err_eeprom:
- iegbe_phy_hw_reset(hw);
- if (hw->flash_address)
- iounmap(hw->flash_address);
-- for (i = 0; i < adapter->num_rx_queues; i++)
-- dev_put(&adapter->polling_netdev[i]);
- kfree(adapter->tx_ring);
- kfree(adapter->rx_ring);
-- kfree(adapter->polling_netdev);
- err_sw_init:
- iounmap(hw->hw_addr);
- err_ioremap:
-@@ -1017,7 +1014,6 @@ iegbe_remove(struct pci_dev *pdev)
- struct net_device *netdev = pci_get_drvdata(pdev);
- struct iegbe_adapter *adapter = netdev_priv(netdev);
- uint32_t manc;
-- int i;
-
- if(adapter->hw.mac_type >= iegbe_82540
- && adapter->hw.mac_type != iegbe_icp_xxxx
-@@ -1030,15 +1026,11 @@ iegbe_remove(struct pci_dev *pdev)
- }
-
- unregister_netdev(netdev);
-- for (i = 0x0; i < adapter->num_rx_queues; i++)
-- dev_put(&adapter->polling_netdev[i]);
--
- if(!iegbe_check_phy_reset_block(&adapter->hw)) {
- iegbe_phy_hw_reset(&adapter->hw);
- }
- kfree(adapter->tx_ring);
- kfree(adapter->rx_ring);
-- kfree(adapter->polling_netdev);
-
- iounmap(adapter->hw.hw_addr);
- pci_release_regions(pdev);
-@@ -1061,7 +1053,6 @@ iegbe_sw_init(struct iegbe_adapter *adap
- struct iegbe_hw *hw = &adapter->hw;
- struct net_device *netdev = adapter->netdev;
- struct pci_dev *pdev = adapter->pdev;
-- int i;
-
- /* PCI config space info */
-
-@@ -1111,11 +1102,6 @@ iegbe_sw_init(struct iegbe_adapter *adap
- return -ENOMEM;
- }
-
-- for (i = 0; i < adapter->num_rx_queues; i++) {
-- adapter->polling_netdev[i].priv = adapter;
-- dev_hold(&adapter->polling_netdev[i]);
-- set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
-- }
- spin_lock_init(&adapter->tx_queue_lock);
-
- /*
-@@ -1137,8 +1123,7 @@ iegbe_sw_init(struct iegbe_adapter *adap
- * @adapter: board private structure to initialize
- *
- * We allocate one ring per queue at run-time since we don't know the
-- * number of queues at compile-time. The polling_netdev array is
-- * intended for Multiqueue, but should work fine with a single queue.
-+ * number of queues at compile-time.
- **/
-
- static int __devinit
-@@ -1158,15 +1143,6 @@ iegbe_alloc_queues(struct iegbe_adapter
- return -ENOMEM;
- }
-
-- adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
-- sizeof(struct net_device),
-- GFP_KERNEL);
-- if (!adapter->polling_netdev) {
-- kfree(adapter->tx_ring);
-- kfree(adapter->rx_ring);
-- return -ENOMEM;
-- }
--
- return E1000_SUCCESS;
- }
-
diff --git a/package/system/ep80579-drivers/patches/103-iegbe_convert_unicast_addr_list.patch b/package/system/ep80579-drivers/patches/103-iegbe_convert_unicast_addr_list.patch
deleted file mode 100644
index 71d2d54e6b..0000000000
--- a/package/system/ep80579-drivers/patches/103-iegbe_convert_unicast_addr_list.patch
+++ /dev/null
@@ -1,60 +0,0 @@
---- a/Embedded/src/GbE/iegbe_main.c
-+++ b/Embedded/src/GbE/iegbe_main.c
-@@ -2161,7 +2161,8 @@ static void iegbe_set_rx_mode(struct net
- {
- struct iegbe_adapter *adapter = netdev_priv(netdev);
- struct iegbe_hw *hw = &adapter->hw;
-- struct dev_addr_list *uc_ptr;
-+ struct netdev_hw_addr *ha;
-+ bool use_uc = false;
- struct dev_addr_list *mc_ptr;
- u32 rctl;
- u32 hash_value;
-@@ -2187,12 +2188,11 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
- }
- }
-
-- uc_ptr = NULL;
- if (netdev->uc_count > rar_entries - 1) {
- rctl |= E1000_RCTL_UPE;
- } else if (!(netdev->flags & IFF_PROMISC)) {
- rctl &= ~E1000_RCTL_UPE;
-- uc_ptr = netdev->uc_list;
-+ use_uc = true;
- }
-
- E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
-@@ -2210,13 +2210,20 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
- * if there are not 14 addresses, go ahead and clear the filters
- * -- with 82571 controllers only 0-13 entries are filled here
- */
-+ i = 1;
-+ if (use_uc)
-+ list_for_each_entry(ha, &netdev->uc_list, list) {
-+ if (i == rar_entries)
-+ break;
-+ iegbe_rar_set(hw, ha->addr, i++);
-+ }
-+
-+ WARN_ON(i == rar_entries);
-+
- mc_ptr = netdev->mc_list;
-
-- for (i = 1; i < rar_entries; i++) {
-- if (uc_ptr) {
-- iegbe_rar_set(hw, uc_ptr->da_addr, i);
-- uc_ptr = uc_ptr->next;
-- } else if (mc_ptr) {
-+ for (; i < rar_entries; i++) {
-+ if (mc_ptr) {
- iegbe_rar_set(hw, mc_ptr->da_addr, i);
- mc_ptr = mc_ptr->next;
- } else {
-@@ -2226,7 +2233,6 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
- E1000_WRITE_FLUSH(&adapter->hw);
- }
- }
-- WARN_ON(uc_ptr != NULL);
-
- /* clear the old settings from the multicast hash table */
-
diff --git a/package/system/ep80579-drivers/patches/104-iegbe_group_address_list_and_its_count.patch b/package/system/ep80579-drivers/patches/104-iegbe_group_address_list_and_its_count.patch
deleted file mode 100644
index c6eced6a5c..0000000000
--- a/package/system/ep80579-drivers/patches/104-iegbe_group_address_list_and_its_count.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/Embedded/src/GbE/iegbe_main.c
-+++ b/Embedded/src/GbE/iegbe_main.c
-@@ -2188,7 +2188,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
- }
- }
-
-- if (netdev->uc_count > rar_entries - 1) {
-+ if (netdev->uc.count > rar_entries - 1) {
- rctl |= E1000_RCTL_UPE;
- } else if (!(netdev->flags & IFF_PROMISC)) {
- rctl &= ~E1000_RCTL_UPE;
-@@ -2212,7 +2212,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
- */
- i = 1;
- if (use_uc)
-- list_for_each_entry(ha, &netdev->uc_list, list) {
-+ list_for_each_entry(ha, &netdev->uc.list, list) {
- if (i == rar_entries)
- break;
- iegbe_rar_set(hw, ha->addr, i++);
diff --git a/package/system/ep80579-drivers/patches/105-iegbe_new_dma_masks.patch b/package/system/ep80579-drivers/patches/105-iegbe_new_dma_masks.patch
deleted file mode 100644
index d5fc46f796..0000000000
--- a/package/system/ep80579-drivers/patches/105-iegbe_new_dma_masks.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/Embedded/src/GbE/iegbe_main.c
-+++ b/Embedded/src/GbE/iegbe_main.c
-@@ -775,13 +775,13 @@ static int __devinit iegbe_probe(struct
- if (err)
- return err;
-
-- if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK) &&
-- !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
-+ if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) &&
-+ !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
- pci_using_dac = 1;
- } else {
-- err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
-+ err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
- if (err) {
-- err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
-+ err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
- if (err) {
- E1000_ERR("No usable DMA configuration, "
- "aborting\n");
diff --git a/package/system/ep80579-drivers/patches/106-iegbe_new_irqf_constant.patch b/package/system/ep80579-drivers/patches/106-iegbe_new_irqf_constant.patch
deleted file mode 100644
index a08e8c7697..0000000000
--- a/package/system/ep80579-drivers/patches/106-iegbe_new_irqf_constant.patch
+++ /dev/null
@@ -1,12 +0,0 @@
---- a/Embedded/src/GbE/iegbe_ethtool.c
-+++ b/Embedded/src/GbE/iegbe_ethtool.c
-@@ -944,7 +944,8 @@ iegbe_intr_test(struct iegbe_adapter *ad
- *data = 0;
-
- /* Hook up test interrupt handler just for this test */
-- if(!request_irq(irq, &iegbe_test_intr, 0, netdev->name, netdev)) {
-+ if(!request_irq(irq, &iegbe_test_intr, IRQF_PROBE_SHARED, netdev->name,
-+ netdev)) {
- shared_int = FALSE;
- } else if(request_irq(irq, &iegbe_test_intr, IRQF_SHARED,
- netdev->name, netdev)){
diff --git a/package/system/ep80579-drivers/patches/150-ocracoke_island.patch b/package/system/ep80579-drivers/patches/150-ocracoke_island.patch
deleted file mode 100644
index ae74e0c905..0000000000
--- a/package/system/ep80579-drivers/patches/150-ocracoke_island.patch
+++ /dev/null
@@ -1,747 +0,0 @@
---- a/Embedded/src/GbE/iegbe_oem_phy.c
-+++ b/Embedded/src/GbE/iegbe_oem_phy.c
-@@ -65,6 +65,10 @@ static int32_t iegbe_oem_link_m88_setup(
- static int32_t iegbe_oem_set_phy_mode(struct iegbe_hw *hw);
- static int32_t iegbe_oem_detect_phy(struct iegbe_hw *hw);
-
-+static int32_t iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw);
-+static int32_t bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data);
-+static int32_t oi_phy_setup (struct iegbe_hw *hw);
-+
- /**
- * iegbe_oem_setup_link
- * @hw: iegbe_hw struct containing device specific information
-@@ -114,6 +118,10 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
- }
-
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ return E1000_SUCCESS;
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- ret_val = iegbe_oem_link_m88_setup(hw);
-@@ -121,6 +129,12 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
- return ret_val;
- }
- break;
-+ case BCM5481_PHY_ID:
-+ ret_val = iegbe_oem_link_bcm5481_setup(hw);
-+ if(ret_val) {
-+ return ret_val;
-+ }
-+ break;
- default:
- DEBUGOUT("Invalid PHY ID\n");
- return -E1000_ERR_PHY_TYPE;
-@@ -179,6 +193,51 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
- #endif /* ifdef EXTERNAL_MDIO */
- }
-
-+/**
-+ * iegbe_oem_link_bcm5481_setup
-+ * @hw: iegbe_hw struct containing device specific information
-+ *
-+ * Returns E1000_SUCCESS, negative E1000 error code on failure
-+ *
-+ * copied verbatim from iegbe_oem_link_m88_setup
-+ **/
-+static int32_t
-+iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw)
-+{
-+ int32_t ret_val;
-+ uint16_t phy_data;
-+
-+ //DEBUGFUNC(__func__);
-+
-+ if(!hw)
-+ return -1;
-+
-+ /* phy_reset_disable is set in iegbe_oem_set_phy_mode */
-+ if(hw->phy_reset_disable)
-+ return E1000_SUCCESS;
-+
-+ // Enable MDIX in extended control reg.
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ECTRL, &phy_data);
-+ if(ret_val)
-+ {
-+ DEBUGOUT("Unable to read BCM5481_ECTRL register\n");
-+ return ret_val;
-+ }
-+
-+ phy_data &= ~BCM5481_ECTRL_DISMDIX;
-+ ret_val = iegbe_oem_write_phy_reg_ex(hw, BCM5481_ECTRL, phy_data);
-+ if(ret_val)
-+ {
-+ DEBUGOUT("Unable to write BCM5481_ECTRL register\n");
-+ return ret_val;
-+ }
-+
-+ ret_val = oi_phy_setup (hw);
-+ if (ret_val)
-+ return ret_val;
-+
-+ return E1000_SUCCESS;
-+}
-
- /**
- * iegbe_oem_link_m88_setup
-@@ -340,6 +399,11 @@ iegbe_oem_force_mdi(struct iegbe_hw *hw,
- * see iegbe_phy_force_speed_duplex, which does the following for M88
- */
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ DEBUGOUT("WARNING: An empty iegbe_oem_force_mdi() has been called!\n");
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- ret_val = iegbe_oem_read_phy_reg_ex(hw,
-@@ -415,6 +479,8 @@ iegbe_oem_phy_reset_dsp(struct iegbe_hw
- switch (hw->phy_id) {
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ case BCM5395S_PHY_ID:
- DEBUGOUT("No DSP to reset on OEM PHY\n");
- break;
- default:
-@@ -460,6 +526,11 @@ iegbe_oem_cleanup_after_phy_reset(struct
- * see iegbe_phy_force_speed_duplex, which does the following for M88
- */
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ DEBUGOUT("WARNING: An empty iegbe_oem_cleanup_after_phy_reset() has been called!\n");
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- /*
-@@ -573,6 +644,11 @@ iegbe_oem_set_phy_mode(struct iegbe_hw *
- * use iegbe_set_phy_mode as example
- */
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ DEBUGOUT("WARNING: An empty iegbe_oem_set_phy_mode() has been called!\n");
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- ret_val = iegbe_read_eeprom(hw,
-@@ -641,6 +717,19 @@ iegbe_oem_detect_phy(struct iegbe_hw *hw
- }
- hw->phy_type = iegbe_phy_oem;
-
-+{
-+ // If MAC2 (BCM5395 switch), manually detect the phy
-+ struct iegbe_adapter *adapter;
-+ uint32_t device_number;
-+ adapter = (struct iegbe_adapter *) hw->back;
-+ device_number = PCI_SLOT(adapter->pdev->devfn);
-+ if (device_number == ICP_XXXX_MAC_2) {
-+ hw->phy_id = BCM5395S_PHY_ID;
-+ hw->phy_revision = 0;
-+ return E1000_SUCCESS;
-+ }
-+}
-+
- ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_ID1, &phy_id_high);
- if(ret_val) {
- DEBUGOUT("Unable to read PHY register PHY_ID1\n");
-@@ -690,6 +779,8 @@ iegbe_oem_get_tipg(struct iegbe_hw *hw)
- switch (hw->phy_id) {
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ case BCM5395S_PHY_ID:
- phy_num = DEFAULT_ICP_XXXX_TIPG_IPGT;
- break;
- default:
-@@ -738,6 +829,8 @@ iegbe_oem_phy_is_copper(struct iegbe_hw
- switch (hw->phy_id) {
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ case BCM5395S_PHY_ID:
- isCopper = TRUE;
- break;
- default:
-@@ -796,13 +889,13 @@ iegbe_oem_get_phy_dev_number(struct iegb
- switch(device_number)
- {
- case ICP_XXXX_MAC_0:
-- hw->phy_addr = 0x00;
-+ hw->phy_addr = 0x01;
- break;
- case ICP_XXXX_MAC_1:
-- hw->phy_addr = 0x01;
-+ hw->phy_addr = 0x02;
- break;
- case ICP_XXXX_MAC_2:
-- hw->phy_addr = 0x02;
-+ hw->phy_addr = 0x00;
- break;
- default: hw->phy_addr = 0x00;
- }
-@@ -851,6 +944,12 @@ iegbe_oem_mii_ioctl(struct iegbe_adapter
- if(!adapter || !ifr) {
- return -1;
- }
-+
-+ // If MAC2 (BCM5395 switch) then leave now
-+ if ((PCI_SLOT(adapter->pdev->devfn)) == ICP_XXXX_MAC_2) {
-+ return -1;
-+ }
-+
- switch (data->reg_num) {
- case PHY_CTRL:
- if(mii_reg & MII_CR_POWER_DOWN) {
-@@ -987,6 +1086,11 @@ void iegbe_oem_get_phy_regs(struct iegbe
- * [10] = mdix mode
- */
- switch (adapter->hw.phy_id) {
-+ case BCM5395S_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ DEBUGOUT("WARNING: An empty iegbe_oem_get_phy_regs() has been called!\n");
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- if(corrected_len > 0) {
-@@ -1068,8 +1172,13 @@ iegbe_oem_phy_loopback(struct iegbe_adap
- * Loopback configuration is the same for each of the supported PHYs.
- */
- switch (adapter->hw.phy_id) {
-+ case BCM5395S_PHY_ID:
-+ DEBUGOUT("WARNING: An empty iegbe_oem_phy_loopback() has been called!\n");
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-+ case BCM5481_PHY_ID:
-
- adapter->hw.autoneg = FALSE;
-
-@@ -1182,8 +1291,14 @@ iegbe_oem_loopback_cleanup(struct iegbe_
- }
-
- switch (adapter->hw.phy_id) {
-+ case BCM5395S_PHY_ID:
-+ DEBUGOUT("WARNING: An empty iegbe_oem_loopback_cleanup() has been called!\n");
-+ return;
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-+ case BCM5481_PHY_ID:
- default:
- adapter->hw.autoneg = TRUE;
-
-@@ -1243,6 +1358,11 @@ iegbe_oem_phy_speed_downgraded(struct ie
- */
-
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ *isDowngraded = 0;
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
-@@ -1305,6 +1425,11 @@ iegbe_oem_check_polarity(struct iegbe_hw
- */
-
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ *polarity = 0;
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- /* return the Polarity bit in the Status register. */
-@@ -1367,6 +1492,25 @@ iegbe_oem_phy_is_full_duplex(struct iegb
- */
-
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ /* Always full duplex */
-+ *isFD = 1;
-+ break;
-+
-+ case BCM5481_PHY_ID:
-+ ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
-+ if(ret_val) return ret_val;
-+
-+ switch (BCM5481_ASTAT_HCD(phy_data)) {
-+ case BCM5481_ASTAT_1KBTFD:
-+ case BCM5481_ASTAT_100BTXFD:
-+ *isFD = 1;
-+ break;
-+ default:
-+ *isFD = 0;
-+ }
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
-@@ -1423,6 +1567,25 @@ iegbe_oem_phy_is_speed_1000(struct iegbe
- */
-
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ /* Always 1000mb */
-+ *is1000 = 1;
-+ break;
-+
-+ case BCM5481_PHY_ID:
-+ ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
-+ if(ret_val) return ret_val;
-+
-+ switch (BCM5481_ASTAT_HCD(phy_data)) {
-+ case BCM5481_ASTAT_1KBTFD:
-+ case BCM5481_ASTAT_1KBTHD:
-+ *is1000 = 1;
-+ break;
-+ default:
-+ *is1000 = 0;
-+ }
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
-@@ -1478,6 +1641,25 @@ iegbe_oem_phy_is_speed_100(struct iegbe_
- * see iegbe_config_mac_to_phy
- */
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ /* Always 1000Mb, never 100mb */
-+ *is100 = 0;
-+ break;
-+
-+ case BCM5481_PHY_ID:
-+ ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
-+ if(ret_val) return ret_val;
-+
-+ switch (BCM5481_ASTAT_HCD(phy_data)) {
-+ case BCM5481_ASTAT_100BTXFD:
-+ case BCM5481_ASTAT_100BTXHD:
-+ *is100 = 1;
-+ break;
-+ default:
-+ *is100 = 0;
-+ }
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- ret_val = iegbe_oem_read_phy_reg_ex(hw,
-@@ -1535,6 +1717,11 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
- * see iegbe_phy_m88_get_info
- */
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ DEBUGOUT("WARNING: An empty iegbe_oem_phy_get_info() has been called!\n");
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- /* The downshift status is checked only once, after link is
-@@ -1636,8 +1823,13 @@ iegbe_oem_phy_hw_reset(struct iegbe_hw *
- * the M88 used in truxton.
- */
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ DEBUGOUT("WARNING: An empty iegbe_oem_phy_hw_reset() has been called!\n");
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-+ case BCM5481_PHY_ID:
- ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_CTRL, &phy_data);
- if(ret_val) {
- DEBUGOUT("Unable to read register PHY_CTRL\n");
-@@ -1699,6 +1891,8 @@ iegbe_oem_phy_init_script(struct iegbe_h
- switch (hw->phy_id) {
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ case BCM5395S_PHY_ID:
- DEBUGOUT("Nothing to do for OEM PHY Init");
- break;
- default:
-@@ -1735,6 +1929,11 @@ iegbe_oem_read_phy_reg_ex(struct iegbe_h
- return -1;
- }
-
-+ if (hw->phy_id == BCM5395S_PHY_ID) {
-+ DEBUGOUT("WARNING: iegbe_oem_read_phy_reg_ex() has been unexpectedly called!\n");
-+ return -1;
-+ }
-+
- /* call the GCU func that will read the phy
- *
- * Make note that the M88 phy is what'll be used on Truxton.
-@@ -1782,6 +1981,11 @@ iegbe_oem_set_trans_gasket(struct iegbe_
- }
-
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ DEBUGOUT("WARNING: An empty iegbe_oem_set_trans_gasket() has been called!\n");
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- /* Gasket set correctly for Marvell Phys, so nothing to do */
-@@ -1886,6 +2090,8 @@ iegbe_oem_phy_needs_reset_with_mac(struc
- switch (hw->phy_id) {
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ case BCM5395S_PHY_ID:
- ret_val = FALSE;
- break;
- default:
-@@ -1935,6 +2141,8 @@ iegbe_oem_config_dsp_after_link_change(s
- switch (hw->phy_id) {
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ case BCM5395S_PHY_ID:
- DEBUGOUT("No DSP to configure on OEM PHY");
- break;
- default:
-@@ -1978,6 +2186,12 @@ iegbe_oem_get_cable_length(struct iegbe_
- }
-
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ case BCM5481_PHY_ID:
-+ *min_length = 0;
-+ *max_length = iegbe_igp_cable_length_150;
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- ret_val = iegbe_oem_read_phy_reg_ex(hw,
-@@ -2061,6 +2275,23 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
- */
-
- switch (hw->phy_id) {
-+ case BCM5395S_PHY_ID:
-+ /* Link always up */
-+ *isUp = TRUE;
-+ return E1000_SUCCESS;
-+ break;
-+
-+ case BCM5481_PHY_ID:
-+ iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
-+ ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
-+ if(ret_val)
-+ {
-+ DEBUGOUT("Unable to read PHY register BCM5481_ESTAT\n");
-+ return ret_val;
-+ }
-+ statusMask = BCM5481_ESTAT_LINK;
-+ break;
-+
- case M88E1000_I_PHY_ID:
- case M88E1141_E_PHY_ID:
- iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
-@@ -2092,3 +2323,210 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
- #endif /* ifdef EXTERNAL_MDIO */
- }
-
-+
-+
-+//-----
-+// Read BCM5481 expansion register
-+//
-+int32_t
-+bcm5481_read_ex (struct iegbe_hw *hw, uint16_t reg, uint16_t *data)
-+{
-+ int ret;
-+ uint16_t selector;
-+ uint16_t reg_data;
-+
-+ // Get the current value of bits 15:12
-+ ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &selector);
-+ if (ret)
-+ return ret;
-+
-+ // Select the expansion register
-+ selector &= 0xf000;
-+ selector |= (0xf << 8) | (reg);
-+ iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
-+
-+ // Read the expansion register
-+ ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &reg_data);
-+
-+ // De-select the expansion registers.
-+ selector &= 0xf000;
-+ iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
-+
-+ if (ret)
-+ return ret;
-+
-+ *data = reg_data;
-+ return ret;
-+}
-+
-+//-----
-+// Read reg 0x18 sub-register
-+//
-+static int32_t
-+bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data)
-+{
-+ int ret;
-+ uint16_t tmp_data;
-+
-+ // Select reg 0x18, sv
-+ tmp_data = ((sv & BCM5481_R18H_SV_MASK) << 12) | BCM5481_R18H_SV_MCTRL;
-+ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, tmp_data);
-+ if(ret)
-+ return ret;
-+
-+ // Read reg 0x18, sv
-+ ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R18H, &tmp_data);
-+ if(ret)
-+ return ret;
-+
-+ *data = tmp_data;
-+ return ret;
-+}
-+
-+//-----
-+// Read reg 0x1C sub-register
-+//
-+int32_t
-+bcm5481_read_1csv (struct iegbe_hw *hw, int sv, uint16_t *data)
-+{
-+ int ret;
-+ uint16_t tmp_data;
-+
-+ // Select reg 0x1c, sv
-+ tmp_data = ((sv & BCM5481_R1CH_SV_MASK) << BCM5481_R1CH_SV_SHIFT);
-+
-+ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, tmp_data);
-+ if(ret)
-+ return ret;
-+
-+ // Read reg 0x1c, sv
-+ ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R1CH, &tmp_data);
-+ if(ret)
-+ return ret;
-+
-+ *data = tmp_data;
-+ return ret;
-+}
-+
-+//-----
-+// Read-modify-write a 0x1C register.
-+//
-+// hw - hardware access info.
-+// reg - 0x1C register to modify.
-+// data - bits which should be set.
-+// mask - the '1' bits in this argument will be cleared in the data
-+// read from 'reg' then 'data' will be or'd in and the result
-+// will be written to 'reg'.
-+
-+int32_t
-+bcm5481_rmw_1csv (struct iegbe_hw *hw, uint16_t reg, uint16_t data, uint16_t mask)
-+{
-+ int32_t ret;
-+ uint16_t reg_data;
-+
-+ ret = 0;
-+
-+ ret = bcm5481_read_1csv (hw, reg, &reg_data);
-+ if (ret)
-+ {
-+ DEBUGOUT("Unable to read BCM5481 1CH register\n");
-+ printk (KERN_ERR "Unable to read BCM5481 1CH register [0x%x]\n", reg);
-+ return ret;
-+ }
-+
-+ reg_data &= ~mask;
-+ reg_data |= (BCM5481_R1CH_WE | data);
-+
-+ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, reg_data);
-+ if(ret)
-+ {
-+ DEBUGOUT("Unable to write BCM5481 1CH register\n");
-+ printk (KERN_ERR "Unable to write BCM5481 1CH register\n");
-+ return ret;
-+ }
-+
-+ return ret;
-+}
-+
-+int32_t
-+oi_phy_setup (struct iegbe_hw *hw)
-+{
-+ int ret;
-+ uint16_t pmii_data;
-+ uint16_t mctrl_data;
-+ uint16_t cacr_data;
-+
-+ ret = 0;
-+
-+ // Set low power mode via reg 0x18, sv010, bit 6
-+ // Do a read-modify-write on reg 0x18, sv010 register to preserve existing bits.
-+ ret = bcm5481_read_18sv (hw, BCM5481_R18H_SV_PMII, &pmii_data);
-+ if (ret)
-+ {
-+ DEBUGOUT("Unable to read BCM5481_R18H_SV_PMII register\n");
-+ printk (KERN_ERR "Unable to read BCM5481_R18H_SV_PMII register\n");
-+ return ret;
-+ }
-+
-+ // Set the LPM bit in the data just read and write back to sv010
-+ // The shadow register select bits [2:0] are set by reading the sv010
-+ // register.
-+ pmii_data |= BCM5481_R18H_SV010_LPM;
-+ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, pmii_data);
-+ if(ret)
-+ {
-+ DEBUGOUT("Unable to write BCM5481_R18H register\n");
-+ printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
-+ return ret;
-+ }
-+
-+
-+ // Set the RGMII RXD to RXC skew bit in reg 0x18, sv111
-+
-+ if (bcm5481_read_18sv (hw, BCM5481_R18H_SV_MCTRL, &mctrl_data))
-+ {
-+ DEBUGOUT("Unable to read BCM5481_R18H_SV_MCTRL register\n");
-+ printk (KERN_ERR "Unable to read BCM5481_R18H_SV_MCTRL register\n");
-+ return ret;
-+ }
-+ mctrl_data |= (BCM5481_R18H_WE | BCM5481_R18H_SV111_SKEW);
-+
-+ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, mctrl_data);
-+ if(ret)
-+ {
-+ DEBUGOUT("Unable to write BCM5481_R18H register\n");
-+ printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
-+ return ret;
-+ }
-+
-+ // Enable RGMII transmit clock delay in reg 0x1c, sv00011
-+ ret = bcm5481_read_1csv (hw, BCM5481_R1CH_CACR, &cacr_data);
-+ if (ret)
-+ {
-+ DEBUGOUT("Unable to read BCM5481_R1CH_CACR register\n");
-+ printk (KERN_ERR "Unable to read BCM5481_R1CH_CACR register\n");
-+ return ret;
-+ }
-+
-+ cacr_data |= (BCM5481_R1CH_WE | BCM5481_R1CH_CACR_TCD);
-+
-+ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, cacr_data);
-+ if(ret)
-+ {
-+ DEBUGOUT("Unable to write BCM5481_R1CH register\n");
-+ printk (KERN_ERR "Unable to write BCM5481_R1CH register\n");
-+ return ret;
-+ }
-+
-+ // Enable dual link speed indication (0x1c, sv 00010, bit 2)
-+ ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_SC1, BCM5481_R1CH_SC1_LINK, BCM5481_R1CH_SC1_LINK);
-+ if (ret)
-+ return ret;
-+
-+ // Enable link and activity on ACTIVITY LED (0x1c, sv 01001, bit 4=1, bit 3=0)
-+ ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_LCTRL, BCM5481_R1CH_LCTRL_ALEN, BCM5481_R1CH_LCTRL_ALEN | BCM5481_R1CH_LCTRL_AEN);
-+ if (ret)
-+ return ret;
-+
-+ return ret;
-+}
---- a/Embedded/src/GbE/iegbe_oem_phy.h
-+++ b/Embedded/src/GbE/iegbe_oem_phy.h
-@@ -95,6 +95,8 @@ int32_t iegbe_oem_phy_is_link_up(struct
-
- #define DEFAULT_ICP_XXXX_TIPG_IPGT 8 /* Inter Packet Gap Transmit Time */
- #define ICP_XXXX_TIPG_IPGT_MASK 0x000003FFUL
-+#define BCM5481_PHY_ID 0x0143BCA0
-+#define BCM5395S_PHY_ID 0x0143BCF0
-
- /* Miscellaneous defines */
- #ifdef IEGBE_10_100_ONLY
-@@ -103,5 +105,65 @@ int32_t iegbe_oem_phy_is_link_up(struct
- #define ICP_XXXX_AUTONEG_ADV_DEFAULT 0x2F
- #endif
-
-+/* BCM5481 specifics */
-+
-+#define BCM5481_ECTRL (0x10)
-+#define BCM5481_ESTAT (0x11)
-+#define BCM5481_RXERR (0x12)
-+#define BCM5481_EXPRW (0x15)
-+#define BCM5481_EXPACC (0x17)
-+#define BCM5481_ASTAT (0x19)
-+#define BCM5481_R18H (0x18)
-+#define BCM5481_R1CH (0x1c)
-+
-+/* indirect register access via register 18h */
-+
-+#define BCM5481_R18H_SV_MASK (7) // Mask for SV bits.
-+#define BCM5481_R18H_SV_ACTRL (0) // SV000 Aux. control
-+#define BCM5481_R18H_SV_10BT (1) // SV001 10Base-T
-+#define BCM5481_R18H_SV_PMII (2) // SV010 Power/MII control
-+#define BCM5481_R18H_SV_MTEST (4) // SV100 Misc. test
-+#define BCM5481_R18H_SV_MCTRL (7) // SV111 Misc. control
-+
-+#define BCM5481_R18H_SV001_POL (1 << 13) // Polarity
-+#define BCM5481_R18H_SV010_LPM (1 << 6)
-+#define BCM5481_R18H_SV111_SKEW (1 << 8)
-+#define BCM5481_R18H_WE (1 << 15) // Write enable
-+
-+// 0x1c registers
-+#define BCM5481_R1CH_SV_SHIFT (10)
-+#define BCM5481_R1CH_SV_MASK (0x1f)
-+#define BCM5481_R1CH_SC1 (0x02) // sv00010 Spare control 1
-+#define BCM5481_R1CH_CACR (0x03) // sv00011 Clock alignment control
-+#define BCM5481_R1CH_LCTRL (0x09) // sv01001 LED control
-+#define BCM5481_R1CH_LEDS1 (0x0d) // sv01101 LED selector 1
-+
-+// 0x1c common
-+#define BCM5481_R1CH_WE (1 << 15) // Write enable
-+
-+// 0x1c, sv 00010
-+#define BCM5481_R1CH_SC1_LINK (1 << 2) // sv00010 Linkspeed
-+
-+// 0x1c, sv 00011
-+#define BCM5481_R1CH_CACR_TCD (1 << 9) // sv00011 RGMII tx clock delay
-+
-+// 0x1c, sv 01001
-+#define BCM5481_R1CH_LCTRL_ALEN (1 << 4) // Activity/Link enable on ACTIVITY LED
-+#define BCM5481_R1CH_LCTRL_AEN (1 << 3) // Activity enable on ACTIVITY LED
-+
-+#define BCM5481_ECTRL_DISMDIX (1 <<14)
-+
-+#define BCM5481_MCTRL_AUTOMDIX (1 <<9)
-+
-+#define BCM5481_ESTAT_LINK (1 << 8)
-+
-+#define BCM5481_ASTAT_ANC (1 << 15)
-+#define BCM5481_ASTAT_ANHCD (7 << 8)
-+#define BCM5481_ASTAT_HCD(x) ((x >> 8) & 7)
-+#define BCM5481_ASTAT_1KBTFD (0x7)
-+#define BCM5481_ASTAT_1KBTHD (0x6)
-+#define BCM5481_ASTAT_100BTXFD (0x5)
-+#define BCM5481_ASTAT_100BTXHD (0x3)
-+
- #endif /* ifndef _IEGBE_OEM_PHY_H_ */
-
diff --git a/package/system/ep80579-drivers/patches/200-can_fix_ioctl_numbers.patch b/package/system/ep80579-drivers/patches/200-can_fix_ioctl_numbers.patch
deleted file mode 100644
index 2919466251..0000000000
--- a/package/system/ep80579-drivers/patches/200-can_fix_ioctl_numbers.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/Embedded/src/CAN/icp_can_user.h
-+++ b/Embedded/src/CAN/icp_can_user.h
-@@ -63,6 +63,8 @@
- #ifndef __ICP_CAN_USER_H__
- #define __ICP_CAN_USER_H__
-
-+#include <linux/ioctl.h>
-+
- /*****************************************************************************
- * Device IO control codes.
- *****************************************************************************/
diff --git a/package/system/ep80579-drivers/patches/210-can_include_linux_fs_h.patch b/package/system/ep80579-drivers/patches/210-can_include_linux_fs_h.patch
deleted file mode 100644
index 26c53dcea4..0000000000
--- a/package/system/ep80579-drivers/patches/210-can_include_linux_fs_h.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/Embedded/src/CAN/can_main.c
-+++ b/Embedded/src/CAN/can_main.c
-@@ -70,6 +70,8 @@
-
- #include "can_main.h"
- #include "can_ioctl.h"
-+#include <linux/fs.h>
-+
-
- MODULE_AUTHOR("Intel(R) Corporation");
- MODULE_DESCRIPTION("Controller Area Network Driver");
diff --git a/package/system/ep80579-drivers/patches/220-can_fix_irq_request.patch b/package/system/ep80579-drivers/patches/220-can_fix_irq_request.patch
deleted file mode 100644
index 2950cc79e5..0000000000
--- a/package/system/ep80579-drivers/patches/220-can_fix_irq_request.patch
+++ /dev/null
@@ -1,23 +0,0 @@
---- a/Embedded/src/CAN/can_main.c
-+++ b/Embedded/src/CAN/can_main.c
-@@ -654,7 +654,7 @@ int can_dev_io(struct inode *inode, stru
- /*****************************************************************************
- * Interrupt handler.
- *****************************************************************************/
--irqreturn_t can_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
-+irqreturn_t can_irq_handler(int irq, void *dev_id)
- {
- can_os_t *can_os = (can_os_t *) dev_id;
- unsigned int int_status;
---- a/Embedded/src/CAN/can_main.h
-+++ b/Embedded/src/CAN/can_main.h
-@@ -165,8 +165,7 @@ int can_dev_io(
-
- irqreturn_t can_irq_handler(
- int irq,
-- void *dev_id,
-- struct pt_regs *regs);
-+ void *dev_id);
-
- void can_tasklet(
- unsigned long arg
diff --git a/package/system/ep80579-drivers/patches/230-can_remove_driver_data_direct_access.patch b/package/system/ep80579-drivers/patches/230-can_remove_driver_data_direct_access.patch
deleted file mode 100644
index 19dbb7e0b2..0000000000
--- a/package/system/ep80579-drivers/patches/230-can_remove_driver_data_direct_access.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- a/Embedded/src/CAN/can_main.c
-+++ b/Embedded/src/CAN/can_main.c
-@@ -214,8 +214,8 @@ int can_pci_probe(struct pci_dev *dev, c
- spin_lock_init(&(g_can_os[can_num].int_spinlock));
- spin_lock_init(&(g_can_os[can_num].open_spinlock));
-
-- dev->dev.driver_data = (void *) &(g_can_os[can_num]);
-- if (!dev->dev.driver_data)
-+ dev_set_drvdata(&dev->dev, (void *) &(g_can_os[can_num]));
-+ if (!dev_get_drvdata(&dev->dev))
- {
- printk("Couldn't create CAN device %d. Exiting.\n",
- dev->device);
-@@ -237,7 +237,7 @@ int can_pci_probe(struct pci_dev *dev, c
- *****************************************************************************/
- void can_pci_remove(struct pci_dev *dev)
- {
-- can_os_t *can_os = dev->dev.driver_data;
-+ can_os_t *can_os = dev_get_drvdata(&dev->dev);
-
- iounmap(can_os->pci_remap);
- icp_can_destroy(can_os->can);
-@@ -251,7 +251,7 @@ int can_pci_suspend(struct pci_dev *dev,
- {
- unsigned int i;
- unsigned int int_status;
-- can_os_t *can_os = dev->dev.driver_data;
-+ can_os_t *can_os = dev_get_drvdata(&dev->dev);
- int err;
-
- /* Indicate that we are suspending */
-@@ -322,7 +322,7 @@ int can_pci_suspend(struct pci_dev *dev,
- int can_pci_resume(struct pci_dev *dev)
- {
- unsigned int i;
-- can_os_t *can_os = dev->dev.driver_data;
-+ can_os_t *can_os = dev_get_drvdata(&dev->dev);
-
- /* Restore PCI CFG space */
- pci_restore_state(dev);
diff --git a/package/system/ep80579-drivers/patches/300-wdt_compile_fix.patch b/package/system/ep80579-drivers/patches/300-wdt_compile_fix.patch
deleted file mode 100644
index 59242b80b3..0000000000
--- a/package/system/ep80579-drivers/patches/300-wdt_compile_fix.patch
+++ /dev/null
@@ -1,59 +0,0 @@
---- a/Embedded/src/WDT/iwdt.c
-+++ b/Embedded/src/WDT/iwdt.c
-@@ -180,19 +180,19 @@ MODULE_PARM_DESC(wdt_scale, "Intel WDT s
- module_param(wdt_intr_type, byte, WDT_INT_TYPE_IRQ);
- MODULE_PARM_DESC(wdt_intr_type, "Intel WDT interrupt type (default SERIRQ).");
-
--module_param(wdt_margin1, uint, TIMER_MARGIN);
-+module_param(wdt_margin1, uint, 0);
- MODULE_PARM_DESC(wdt_margin1, "First stage Intel WDT timeout in steps of 1 ms by default.");
-
--module_param(wdt_margin2, uint, TIMER_MARGIN);
-+module_param(wdt_margin2, uint, 0);
- MODULE_PARM_DESC(wdt_margin2, "Second stage Intel WDT timeout in steps of 1 ms by default.");
-
- module_param(nowayout, int, 0);
- MODULE_PARM_DESC(nowayout, "Intel WDT can't be stopped once started (default=0)");
-
--module_param(wdt_index_port, int, 0x4E);
-+module_param(wdt_index_port, int, 0);
- MODULE_PARM_DESC(wdt_index_port, "WDT Index Port (default 0x4e)");
-
--module_param(wdt_data_port, int, 0x4E);
-+module_param(wdt_data_port, int, 0);
- MODULE_PARM_DESC(wdt_data_port, "WDT Data Port (default 0x4f)");
-
- static int wdt_get_iobase(struct pci_dev *dev, u16 *iobase, int *irq);
-@@ -218,7 +218,7 @@ static ssize_t wdt_write(struct file *fi
- size_t count, loff_t * pos);
- static int wdt_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg);
--static irqreturn_t wdt_isr(int irq, void *dev_id, struct pt_regs *regs);
-+static irqreturn_t wdt_isr(int irq, void *dev_id);
- static void __exit wdt_cleanup(void);
- static int __init wdt_init(void);
- static int __init wdt_init_one(struct pci_dev *dev,
-@@ -255,7 +255,7 @@ static struct pci_driver wdt_driver = {
- name: "iwdt",
- id_table: lpc_pci_tbl,
- probe: wdt_init_one,
-- remove: __devexit(wdt_remove_one),
-+ remove: __devexit_p(wdt_remove_one),
- suspend: wdt_pci_suspend,
- resume: wdt_pci_resume,
- };
-@@ -1393,12 +1393,12 @@ static int wdt_ioctl(struct inode *inode
-
- /*
- * Function Name: wdt_isr()
-- * Parameter: int irq - irq number, void *dev_id, struct pt_regs *regs
-+ * Parameter: int irq - irq number, void *dev_id
- * Return Value:: IRQ_NONE - if the interrupt is not for wdt.
- * IRQ_HANDLED - if it is for wdt.
- * Description: This is the interrupt service routine of the WDT.
- */
--static irqreturn_t wdt_isr(int irq, void *dev_id, struct pt_regs *regs)
-+static irqreturn_t wdt_isr(int irq, void *dev_id)
- {
- u8 val;
-
diff --git a/package/system/ep80579-drivers/patches/400-edma_fix_irq_request_warning.patch b/package/system/ep80579-drivers/patches/400-edma_fix_irq_request_warning.patch
deleted file mode 100644
index d858aff1ff..0000000000
--- a/package/system/ep80579-drivers/patches/400-edma_fix_irq_request_warning.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- a/Embedded/src/EDMA/dma_linux.c
-+++ b/Embedded/src/EDMA/dma_linux.c
-@@ -149,8 +149,7 @@ int32_t edma_suspend (struct pci_dev *de
- int32_t edma_resume(struct pci_dev *dev);
- int32_t initialize_edma_device(struct edma_device *device);
-
--static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id,
-- struct pt_regs * regs);
-+static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id);
-
- /* Prototypes - Misc. */
-
-@@ -429,8 +428,7 @@ int32_t edma_release(struct inode * inod
- * Return Values: HANDLED = 1, NOT_HANDLED = 0
- *****************************************************************************/
-
--static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id,
-- struct pt_regs * regs)
-+static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id)
- {
-
- uint32_t clear_bits;
diff --git a/package/system/ep80579-drivers/patches/500-1588_fix_irq_request_warning.patch b/package/system/ep80579-drivers/patches/500-1588_fix_irq_request_warning.patch
deleted file mode 100644
index f3f9acb1e0..0000000000
--- a/package/system/ep80579-drivers/patches/500-1588_fix_irq_request_warning.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- a/Embedded/src/1588/1588.c
-+++ b/Embedded/src/1588/1588.c
-@@ -631,7 +631,7 @@ int restore_interrupts(void)
- IRQ_NONE => this device did not interrupt
-
- ******************************************************************************/
--irqreturn_t timesync_isr(int irq, void *dev_id, struct pt_regs *regs)
-+irqreturn_t timesync_isr(int irq, void *dev_id)
- {
- if ( !ixTimeSyncAccEventAmmsFlagGet() && !ixTimeSyncAccEventAsmsFlagGet()&&
- !ixTimeSyncAccEventAtmFlagGet() && !ixTimeSyncAccEventPpsmFlagGet()&&
---- a/Embedded/src/1588/1588.h
-+++ b/Embedded/src/1588/1588.h
-@@ -128,7 +128,7 @@ int pci_suspend(struct pci_dev *dev, pm_
- int pci_resume(struct pci_dev *dev);
- int pci_probe(struct pci_dev *dev, const struct pci_device_id *id);
- void pci_remove(struct pci_dev *dev);
--irqreturn_t timesync_isr(int irq, void *dev_id, struct pt_regs *regs);
-+irqreturn_t timesync_isr(int irq, void *dev_id);
-
- // private functions
- int save_reg_state(void);
diff --git a/package/system/ep80579-drivers/patches/600-2.6.27_includes.patch b/package/system/ep80579-drivers/patches/600-2.6.27_includes.patch
deleted file mode 100644
index c11275ece6..0000000000
--- a/package/system/ep80579-drivers/patches/600-2.6.27_includes.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- a/Embedded/src/CAN/can_main.h
-+++ b/Embedded/src/CAN/can_main.h
-@@ -65,7 +65,7 @@
-
- #include <linux/interrupt.h>
- #include <linux/pci.h>
--#include <asm/semaphore.h>
-+#include <linux/semaphore.h>
- #include <linux/spinlock.h>
- #include <linux/cdev.h>
- #include <asm/uaccess.h>
---- a/Embedded/src/EDMA/dma_linux.c
-+++ b/Embedded/src/EDMA/dma_linux.c
-@@ -87,7 +87,7 @@
- #include <linux/fcntl.h> /* O_ACCMODE */
- #include <asm/system.h> /* cli, *_flags */
- #include <asm/uaccess.h> /* copy_to_user */
--#include <asm/semaphore.h>
-+#include <linux/semaphore.h>
- #include <asm/io.h> /* inb(), outb() */
- #include <linux/kmod.h>
- #include <linux/ioport.h> /* request_region */
diff --git a/package/system/ep80579-drivers/patches/601-2.6.32_includes.patch b/package/system/ep80579-drivers/patches/601-2.6.32_includes.patch
deleted file mode 100644
index 291fb0a33d..0000000000
--- a/package/system/ep80579-drivers/patches/601-2.6.32_includes.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- a/Embedded/src/1588/1588.c
-+++ b/Embedded/src/1588/1588.c
-@@ -72,6 +72,7 @@
- *
- ****************************************************************************/
-
-+#include <linux/sched.h>
- #include "1588.h"
-
- MODULE_AUTHOR("Intel(R) Corporation");
---- a/Embedded/src/CAN/can_main.c
-+++ b/Embedded/src/CAN/can_main.c
-@@ -68,6 +68,7 @@
- *
- **************************************************************************/
-
-+#include <linux/sched.h>
- #include "can_main.h"
- #include "can_ioctl.h"
- #include <linux/fs.h>
---- a/Embedded/src/WDT/iwdt.c
-+++ b/Embedded/src/WDT/iwdt.c
-@@ -137,6 +137,7 @@
- #include <linux/watchdog.h>
- #include <linux/miscdevice.h>
- #include <linux/interrupt.h>
-+#include <linux/sched.h>
- #include "iwdt.h"
-
- MODULE_AUTHOR("Intel(R) Corporation");
diff --git a/package/system/ep80579-drivers/patches/700-iegbe_kcompat_2.6.30.patch b/package/system/ep80579-drivers/patches/700-iegbe_kcompat_2.6.30.patch
deleted file mode 100644
index ca8c1bb9ea..0000000000
--- a/package/system/ep80579-drivers/patches/700-iegbe_kcompat_2.6.30.patch
+++ /dev/null
@@ -1,31 +0,0 @@
---- a/Embedded/src/GbE/kcompat.h
-+++ b/Embedded/src/GbE/kcompat.h
-@@ -46,12 +46,6 @@ GPL LICENSE SUMMARY
- #include <linux/sched.h>
- #include <asm/io.h>
-
--#ifndef IRQ_HANDLED
--#define irqreturn_t void
--#define IRQ_HANDLED
--#define IRQ_NONE
--#endif
--
- #ifndef SET_NETDEV_DEV
- #define SET_NETDEV_DEV(net, pdev)
- #endif
-@@ -748,6 +742,15 @@ extern void dump_stack(void);
-
- #endif /* 2.4.24 */
-
-+/*****************************************************************************/
-+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) )
-+#ifndef IRQ_HANDLED
-+#define irqreturn_t void
-+#define IRQ_HANDLED
-+#define IRQ_NONE
-+#endif
-+#endif /* < 2.6.30 */
-+
- #endif /* _KCOMPAT_H_ */
-
-
diff --git a/package/system/ep80579-drivers/patches/701-iegbe_poll_dev.patch b/package/system/ep80579-drivers/patches/701-iegbe_poll_dev.patch
deleted file mode 100644
index 63a1326853..0000000000
--- a/package/system/ep80579-drivers/patches/701-iegbe_poll_dev.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/Embedded/src/GbE/iegbe_main.c
-+++ b/Embedded/src/GbE/iegbe_main.c
-@@ -3534,7 +3534,7 @@ static int iegbe_clean(struct napi_struc
- int tx_cleaned = 0, work_done = 0;
-
- /* Must NOT use netdev_priv macro here. */
-- adapter = poll_dev->priv;
-+ adapter = netdev_priv(poll_dev);
-
- /* iegbe_clean is called per-cpu. This lock protects
- * tx_ring[0] from being cleaned by multiple cpus
diff --git a/package/system/ep80579-drivers/patches/710-3.3-fix-generated-header-locations.patch b/package/system/ep80579-drivers/patches/710-3.3-fix-generated-header-locations.patch
deleted file mode 100644
index 793d08d39b..0000000000
--- a/package/system/ep80579-drivers/patches/710-3.3-fix-generated-header-locations.patch
+++ /dev/null
@@ -1,91 +0,0 @@
---- a/Embedded/src/GbE/Makefile
-+++ b/Embedded/src/GbE/Makefile
-@@ -60,19 +60,19 @@ GBE_NAME = iegbe
- GCU_NAME = gcu
-
- VERSION_FILE := $(KSRC)/include/linux/version.h
--UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
--CONFIG_FILE := $(KSRC)/include/linux/autoconf.h
-+UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
-+CONFIG_FILE := $(KSRC)/include/generated/autoconf.h
-
- ifeq (,$(wildcard $(VERSION_FILE)))
- $(error Linux kernel source not configured - missing version.h)
- endif
-
- ifeq (,$(wildcard $(CONFIG_FILE)))
-- $(error Linux kernel source not configured - missing autoconf.h)
-+ $(error Linux kernel source not configured - missing autoconf.h)
- endif
-
- ifeq (,$(wildcard $(UTS_REL_FILE)))
-- $(error Linux kernel source not configured - missing utsrelease.h)
-+ $(error Linux kernel source not configured - missing utsrelease.h)
- endif
-
- # set the install path
---- a/Embedded/src/1588/Makefile
-+++ b/Embedded/src/1588/Makefile
-@@ -97,8 +97,8 @@ OUTPUT_PATH ?= /
- EXTRA_LDFLAGS += -whole-archive
-
- VERSION_FILE := $(KOBJ)/include/linux/version.h
--UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
--CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
-+UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
-+CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
-
-
- # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
---- a/Embedded/src/CAN/Makefile
-+++ b/Embedded/src/CAN/Makefile
-@@ -100,8 +100,8 @@ OUTPUT_PATH ?= /
- EXTRA_LDFLAGS += -whole-archive
-
- VERSION_FILE := $(KOBJ)/include/linux/version.h
--UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
--CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
-+UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
-+CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
-
-
- # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
---- a/Embedded/src/EDMA/Makefile
-+++ b/Embedded/src/EDMA/Makefile
-@@ -114,8 +114,8 @@ OUTPUT_PATH ?= /
- EXTRA_LDFLAGS += -whole-archive
-
- VERSION_FILE := $(KOBJ)/include/linux/version.h
--UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
--CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
-+UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
-+CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
-
-
- # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
---- a/Embedded/src/GPIO/Makefile
-+++ b/Embedded/src/GPIO/Makefile
-@@ -97,8 +97,8 @@ OUTPUT_PATH ?= /
- EXTRA_LDFLAGS += -whole-archive
-
- VERSION_FILE := $(KOBJ)/include/linux/version.h
--UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
--CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
-+UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
-+CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
-
-
- # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
---- a/Embedded/src/WDT/Makefile
-+++ b/Embedded/src/WDT/Makefile
-@@ -99,8 +99,8 @@ OUTPUT_PATH ?= /
- EXTRA_LDFLAGS += -whole-archive
-
- VERSION_FILE := $(KOBJ)/include/linux/version.h
--UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
--CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
-+UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
-+CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
-
-
- # as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
diff --git a/package/system/ep80579-drivers/patches/711-3.3-gbe-fixes.patch b/package/system/ep80579-drivers/patches/711-3.3-gbe-fixes.patch
deleted file mode 100644
index 7b2df63984..0000000000
--- a/package/system/ep80579-drivers/patches/711-3.3-gbe-fixes.patch
+++ /dev/null
@@ -1,392 +0,0 @@
---- a/Embedded/src/GbE/kcompat.h
-+++ b/Embedded/src/GbE/kcompat.h
-@@ -590,6 +590,10 @@ static inline void _kc_synchronize_irq()
- #define ETHTOOL_OPS_COMPAT
- #endif
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
-+#define HAVE_NETIF_MSG 1
-+#endif
-+
- #ifndef HAVE_NETIF_MSG
- #define HAVE_NETIF_MSG 1
- enum {
---- a/Embedded/src/GbE/iegbe_main.c
-+++ b/Embedded/src/GbE/iegbe_main.c
-@@ -159,9 +159,9 @@ static void iegbe_smartspeed(struct iegb
- static inline int iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter,
- struct sk_buff *skb);
-
--static void iegbe_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
--static void iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
--static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
-+static bool iegbe_vlan_used(struct iegbe_adapter *adapter);
-+static int iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
-+static int iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
- static void iegbe_restore_vlan(struct iegbe_adapter *adapter);
-
- static int iegbe_notify_reboot(struct notifier_block *,
-@@ -324,8 +324,8 @@ static void iegbe_update_mng_vlan(struct
- struct net_device *netdev = adapter->netdev;
- u16 vid = hw->mng_cookie.vlan_id;
- u16 old_vid = adapter->mng_vlan_id;
-- if (adapter->vlgrp) {
-- if (!vlan_group_get_device(adapter->vlgrp, vid)) {
-+ if (iegbe_vlan_used(adapter)) {
-+ if (!test_bit(old_vid, adapter->active_vlans)) {
- if (hw->mng_cookie.status &
- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
- iegbe_vlan_rx_add_vid(netdev, vid);
-@@ -335,7 +335,7 @@ static void iegbe_update_mng_vlan(struct
-
- if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
- (vid != old_vid) &&
-- !vlan_group_get_device(adapter->vlgrp, old_vid))
-+ !test_bit(old_vid, adapter->active_vlans))
- iegbe_vlan_rx_kill_vid(netdev, old_vid);
- } else
- adapter->mng_vlan_id = vid;
-@@ -736,7 +736,6 @@ static const struct net_device_ops iegbe
- .ndo_do_ioctl = iegbe_ioctl,
- .ndo_validate_addr = eth_validate_addr,
-
-- .ndo_vlan_rx_register = iegbe_vlan_rx_register,
- .ndo_vlan_rx_add_vid = iegbe_vlan_rx_add_vid,
- .ndo_vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid,
- #ifdef CONFIG_NET_POLL_CONTROLLER
-@@ -767,7 +766,6 @@ static int __devinit iegbe_probe(struct
- u16 eeprom_data = 0;
- u16 eeprom_apme_mask = E1000_EEPROM_APME;
- int bars;
-- DECLARE_MAC_BUF(mac);
-
- bars = pci_select_bars(pdev, IORESOURCE_MEM);
- err = pci_enable_device(pdev);
-@@ -1247,8 +1245,7 @@ static int iegbe_close(struct net_device
-
- if ((hw->mng_cookie.status &
- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
-- !(adapter->vlgrp &&
-- vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) {
-+ !test_bit(adapter->mng_vlan_id, adapter->active_vlans)) {
- iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
- }
- return 0;
-@@ -2163,11 +2160,13 @@ static void iegbe_set_rx_mode(struct net
- struct iegbe_hw *hw = &adapter->hw;
- struct netdev_hw_addr *ha;
- bool use_uc = false;
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
- struct dev_addr_list *mc_ptr;
-- u32 rctl;
- u32 hash_value;
-- int i, rar_entries = E1000_RAR_ENTRIES;
- int mta_reg_count = E1000_NUM_MTA_REGISTERS;
-+#endif
-+ u32 rctl;
-+ int i, rar_entries = E1000_RAR_ENTRIES;
-
- /* reserve RAR[14] for LAA over-write work-around */
- if (hw->mac_type == iegbe_82571)
-@@ -2220,6 +2219,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
-
- WARN_ON(i == rar_entries);
-
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
- mc_ptr = netdev->mc_list;
-
- for (; i < rar_entries; i++) {
-@@ -2247,6 +2247,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
- hash_value = iegbe_hash_mc_addr(hw, mc_ptr->da_addr);
- iegbe_mta_set(hw, hash_value);
- }
-+#endif
-
- if (hw->mac_type == iegbe_82542_rev2_0)
- iegbe_leave_82542_rst(adapter);
-@@ -2821,14 +2822,14 @@ static int iegbe_tx_map(struct iegbe_ada
- * Avoid terminating buffers within evenly-aligned
- * dwords. */
- if(unlikely(adapter->pcix_82544 &&
-- !((unsigned long)(frag->page+offset+size-1) & 4) &&
-+ !((unsigned long)(frag->page.p+offset+size-1) & 4) &&
- size > 4))
- size -= 4;
-
- buffer_info->length = size;
- buffer_info->dma =
- pci_map_page(adapter->pdev,
-- frag->page,
-+ frag->page.p,
- offset,
- size,
- PCI_DMA_TODEVICE);
-@@ -3131,7 +3132,7 @@ static int iegbe_xmit_frame(struct sk_bu
- }
- }
-
-- if (unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
-+ if (unlikely(iegbe_vlan_used(adapter) && vlan_tx_tag_present(skb))) {
- tx_flags |= E1000_TX_FLAGS_VLAN;
- tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
- }
-@@ -3832,10 +3833,12 @@ static bool iegbe_clean_rx_irq(struct ie
-
- skb->protocol = eth_type_trans(skb, netdev);
-
-- if (unlikely(adapter->vlgrp &&
-+ if (unlikely(iegbe_vlan_used(adapter) &&
- (status & E1000_RXD_STAT_VP))) {
-- vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
-- le16_to_cpu(rx_desc->special));
-+ u16 vid;
-+
-+ vid = le16_to_cpu(rx_desc->special);
-+ __vlan_hwaccel_put_tag(skb, vid);
- } else {
- netif_receive_skb(skb);
- }
-@@ -3986,9 +3989,10 @@ copydone:
- cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)))
- adapter->rx_hdr_split++;
-
-- if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
-- vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
-- le16_to_cpu(rx_desc->wb.middle.vlan));
-+ if(unlikely(iegbe_vlan_used(adapter) && (staterr & E1000_RXD_STAT_VP))) {
-+ u16 vid;
-+ vid = le16_to_cpu(rx_desc->wb.middle.vlan);
-+ __vlan_hwaccel_put_tag(skb, vid);
- } else {
- netif_receive_skb(skb);
- }
-@@ -4496,17 +4500,25 @@ iegbe_io_write(struct iegbe_hw *hw, unsi
- outl(value, port);
- }
-
--static void iegbe_vlan_rx_register(struct net_device *netdev,
-- struct vlan_group *grp)
-+static bool iegbe_vlan_used(struct iegbe_adapter *adapter)
-+{
-+ u16 vid;
-+
-+ for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
-+ return true;
-+
-+ return false;
-+}
-+
-+static void iegbe_vlan_mode(struct net_device *netdev, bool vlan_on)
- {
- struct iegbe_adapter *adapter = netdev_priv(netdev);
- uint32_t ctrl, rctl;
-
- if (!test_bit(__E1000_DOWN, &adapter->flags))
- iegbe_irq_disable(adapter);
-- adapter->vlgrp = grp;
-
-- if(grp) {
-+ if(vlan_on) {
- /* enable VLAN tag insert/strip */
- ctrl = E1000_READ_REG(&adapter->hw, CTRL);
- ctrl |= E1000_CTRL_VME;
-@@ -4538,30 +4550,37 @@ static void iegbe_vlan_rx_register(struc
- iegbe_irq_enable(adapter);
- }
-
--static void iegbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
-+static int iegbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
- {
- struct iegbe_adapter *adapter = netdev_priv(netdev);
- uint32_t vfta, index;
- if((adapter->hw.mng_cookie.status &
- E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
- (vid == adapter->mng_vlan_id)) {
-- return;
-+ return 0;
- }
-+
-+ if (!iegbe_vlan_used(adapter))
-+ iegbe_vlan_mode(netdev, true);
-+
- /* add VID to filter table */
- index = (vid >> 0x5) & 0x7F;
- vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
- vfta |= (0x1 << (vid & 0x1F));
- iegbe_write_vfta(&adapter->hw, index, vfta);
-+
-+ set_bit(vid, adapter->active_vlans);
-+
-+ return 0;
- }
-
--static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
-+static int iegbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
- {
- struct iegbe_adapter *adapter = netdev_priv(netdev);
- u32 vfta, index;
-
- if (!test_bit(__E1000_DOWN, &adapter->flags))
- iegbe_irq_disable(adapter);
-- vlan_group_set_device(adapter->vlgrp, vid, NULL);
- if (!test_bit(__E1000_DOWN, &adapter->flags))
- iegbe_irq_enable(adapter);
-
-@@ -4570,21 +4589,26 @@ static void iegbe_vlan_rx_kill_vid(struc
- vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
- vfta &= ~(0x1 << (vid & 0x1F));
- iegbe_write_vfta(&adapter->hw, index, vfta);
-+
-+ clear_bit(vid, adapter->active_vlans);
-+
-+ if (!iegbe_vlan_used(adapter))
-+ iegbe_vlan_mode(netdev, false);
-+
-+ return 0;
- }
-
- static void iegbe_restore_vlan(struct iegbe_adapter *adapter)
- {
-- iegbe_vlan_rx_register(adapter->netdev, adapter->vlgrp);
--
-- if (adapter->vlgrp) {
- u16 vid;
-- for (vid = 0x0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
-- if (!vlan_group_get_device(adapter->vlgrp, vid))
-- continue;
-+
-+ if (!iegbe_vlan_used(adapter))
-+ return;
-+
-+ iegbe_vlan_mode(adapter->netdev, true);
-+ for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
- iegbe_vlan_rx_add_vid(adapter->netdev, vid);
- }
-- }
--}
-
-
- int iegbe_set_spd_dplx(struct iegbe_adapter *adapter, u16 spddplx)
-@@ -4864,10 +4888,11 @@ iegbe_resume(struct pci_dev *pdev)
- default:
- break;
- }
--#endif
-
- return 0x0;
- }
-+#endif
-+
-
- #ifdef CONFIG_NET_POLL_CONTROLLER
- /*
---- a/Embedded/src/GbE/iegbe_ethtool.c
-+++ b/Embedded/src/GbE/iegbe_ethtool.c
-@@ -327,6 +327,7 @@ iegbe_set_pauseparam(struct net_device *
- return 0;
- }
-
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
- static uint32_t
- iegbe_get_rx_csum(struct net_device *netdev)
- {
-@@ -392,6 +393,7 @@ iegbe_set_tso(struct net_device *netdev,
- return 0;
- }
- #endif /* NETIF_F_TSO */
-+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */
-
- static uint32_t
- iegbe_get_msglevel(struct net_device *netdev)
-@@ -807,6 +809,7 @@ err_setup_rx:
- E1000_82542_##R : E1000_##R; \
- return 1; } }
-
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
- static int
- iegbe_reg_test(struct iegbe_adapter *adapter, uint64_t *data)
- {
-@@ -1710,6 +1713,7 @@ iegbe_diag_test(struct net_device *netde
- }
- msleep_interruptible(0xfa0);
- }
-+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */
-
- static void
- iegbe_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
-@@ -1812,6 +1816,7 @@ iegbe_set_wol(struct net_device *netdev,
- /* bit defines for adapter->led_status */
- #define E1000_LED_ON 0
-
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
- static void
- iegbe_led_blink_callback(unsigned long data)
- {
-@@ -1864,6 +1869,7 @@ iegbe_phys_id(struct net_device *netdev,
-
- return 0;
- }
-+#endif
-
- static int
- iegbe_nway_reset(struct net_device *netdev)
-@@ -1876,11 +1882,13 @@ iegbe_nway_reset(struct net_device *netd
- return 0;
- }
-
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
- static int
- iegbe_get_stats_count(struct net_device *netdev)
- {
- return E1000_STATS_LEN;
- }
-+#endif
-
- static void
- iegbe_get_ethtool_stats(struct net_device *netdev,
-@@ -1936,6 +1944,8 @@ struct ethtool_ops iegbe_ethtool_ops = {
- .set_ringparam = iegbe_set_ringparam,
- .get_pauseparam = iegbe_get_pauseparam,
- .set_pauseparam = iegbe_set_pauseparam,
-+
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
- .get_rx_csum = iegbe_get_rx_csum,
- .set_rx_csum = iegbe_set_rx_csum,
- .get_tx_csum = iegbe_get_tx_csum,
-@@ -1946,11 +1956,13 @@ struct ethtool_ops iegbe_ethtool_ops = {
- .get_tso = ethtool_op_get_tso,
- .set_tso = iegbe_set_tso,
- #endif
-+
- .self_test_count = iegbe_diag_test_count,
- .self_test = iegbe_diag_test,
-- .get_strings = iegbe_get_strings,
- .phys_id = iegbe_phys_id,
- .get_stats_count = iegbe_get_stats_count,
-+#endif
-+ .get_strings = iegbe_get_strings,
- .get_ethtool_stats = iegbe_get_ethtool_stats,
- };
-
---- a/Embedded/src/GbE/gcu_main.c
-+++ b/Embedded/src/GbE/gcu_main.c
-@@ -93,7 +93,7 @@ static struct pci_driver gcu_driver = {
- };
-
- static struct gcu_adapter *global_adapter = 0;
--static spinlock_t global_adapter_spinlock = SPIN_LOCK_UNLOCKED;
-+static DEFINE_SPINLOCK(global_adapter_spinlock);
- static unsigned long g_intflags = 0;
-
- MODULE_AUTHOR("Intel(R) Corporation");
---- a/Embedded/src/GbE/iegbe.h
-+++ b/Embedded/src/GbE/iegbe.h
-@@ -257,7 +257,7 @@ struct iegbe_adapter {
- struct timer_list tx_fifo_stall_timer;
- struct timer_list watchdog_timer;
- struct timer_list phy_info_timer;
-- struct vlan_group *vlgrp;
-+ unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
- uint16_t mng_vlan_id;
- uint32_t bd_number;
- uint32_t rx_buffer_len;
diff --git a/package/system/ep80579-drivers/patches/712-3.3-can-fixes.patch b/package/system/ep80579-drivers/patches/712-3.3-can-fixes.patch
deleted file mode 100644
index f46f900931..0000000000
--- a/package/system/ep80579-drivers/patches/712-3.3-can-fixes.patch
+++ /dev/null
@@ -1,41 +0,0 @@
---- a/Embedded/src/CAN/can_main.c
-+++ b/Embedded/src/CAN/can_main.c
-@@ -72,6 +72,7 @@
- #include "can_main.h"
- #include "can_ioctl.h"
- #include <linux/fs.h>
-+#include <linux/module.h>
-
-
- MODULE_AUTHOR("Intel(R) Corporation");
-@@ -110,7 +111,7 @@ struct file_operations file_ops = {
- .owner = THIS_MODULE,
- .read = can_read,
- .write = can_write,
-- .ioctl = can_dev_io,
-+ .unlocked_ioctl = can_dev_io,
- .open = can_open,
- .release = can_release
- };
-@@ -594,8 +595,7 @@ int icp_can_reset(can_os_t *can_os)
- /*****************************************************************************
- * Device IO control function. Used by user apps to configure CAN device.
- *****************************************************************************/
--int can_dev_io(struct inode *inode, struct file *filp, unsigned int cmd,
-- unsigned long arg)
-+long can_dev_io(struct file *filp, unsigned int cmd, unsigned long arg)
- {
- can_os_t *can_os;
- unsigned int err=0;
---- a/Embedded/src/CAN/can_main.h
-+++ b/Embedded/src/CAN/can_main.h
-@@ -157,8 +157,7 @@ ssize_t can_write(
- int icp_can_reset(
- can_os_t *can_os);
-
--int can_dev_io(
-- struct inode *inode,
-+long can_dev_io(
- struct file *filp,
- unsigned int cmd,
- unsigned long arg);
diff --git a/package/system/ep80579-drivers/patches/713-3.3-gpio-fixes.patch b/package/system/ep80579-drivers/patches/713-3.3-gpio-fixes.patch
deleted file mode 100644
index 47fb920d0a..0000000000
--- a/package/system/ep80579-drivers/patches/713-3.3-gpio-fixes.patch
+++ /dev/null
@@ -1,33 +0,0 @@
---- a/Embedded/src/GPIO/gpio.h
-+++ b/Embedded/src/GPIO/gpio.h
-@@ -121,8 +121,7 @@ int gpio_init(void);
- void gpio_close(void);
- int gpio_open(struct inode *inode, struct file *filp);
- int gpio_release(struct inode *inode, struct file *filp);
--int gpio_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
-- unsigned long arg);
-+long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
-
- // private driver functions
- int gpio_getpininfo(int Signal, char *pBuff);
-@@ -134,7 +133,7 @@ struct file_operations file_ops =
- .owner = THIS_MODULE,
- .open = gpio_open,
- .release = gpio_release,
-- .ioctl = gpio_ioctl,
-+ .unlocked_ioctl = gpio_ioctl,
- };
-
- #endif
---- a/Embedded/src/GPIO/gpio_ref.c
-+++ b/Embedded/src/GPIO/gpio_ref.c
-@@ -251,8 +251,7 @@ int gpio_release(struct inode *inode, st
- 0 => success
- < 0 => error
- ******************************************************************************/
--int gpio_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
-- unsigned long arg)
-+long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
- {
- gpio_ioctl_t Info;
- u_int bitstr = 0;
diff --git a/package/system/ep80579-drivers/patches/714-3.3-wdt-fixes.patch b/package/system/ep80579-drivers/patches/714-3.3-wdt-fixes.patch
deleted file mode 100644
index 60cc4aeb73..0000000000
--- a/package/system/ep80579-drivers/patches/714-3.3-wdt-fixes.patch
+++ /dev/null
@@ -1,31 +0,0 @@
---- a/Embedded/src/WDT/iwdt.c
-+++ b/Embedded/src/WDT/iwdt.c
-@@ -217,8 +217,7 @@ static int wdt_open(struct inode *inode,
- static int wdt_release(struct inode *inode, struct file *file);
- static ssize_t wdt_write(struct file *file, const char *data,
- size_t count, loff_t * pos);
--static int wdt_ioctl(struct inode *inode, struct file *file,
-- unsigned int cmd, unsigned long arg);
-+static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
- static irqreturn_t wdt_isr(int irq, void *dev_id);
- static void __exit wdt_cleanup(void);
- static int __init wdt_init(void);
-@@ -243,7 +242,7 @@ static struct pci_device_id lpc_pci_tbl[
- static struct file_operations wdt_fops = {
- owner: THIS_MODULE,
- write: wdt_write,
-- ioctl: wdt_ioctl,
-+ unlocked_ioctl: wdt_ioctl,
- open: wdt_open,
- release: wdt_release,
- };
-@@ -1201,8 +1200,7 @@ char *wdt_get_ioctl_string(unsigned int
- * Return Value: 0 - successful, negative value - failed.
- * Description: This function is used to provide IO interface.
- */
--static int wdt_ioctl(struct inode *inode, struct file *file,
-- unsigned int cmd, unsigned long arg)
-+static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
- {
- u8 mode=0, scale=0, int_type=0;
- u32 u_margin=0, dcount=0;
diff --git a/package/system/ep80579-drivers/patches/715-3.3-1588-fixes.patch b/package/system/ep80579-drivers/patches/715-3.3-1588-fixes.patch
deleted file mode 100644
index ac5dd1f2ec..0000000000
--- a/package/system/ep80579-drivers/patches/715-3.3-1588-fixes.patch
+++ /dev/null
@@ -1,33 +0,0 @@
---- a/Embedded/src/1588/1588.c
-+++ b/Embedded/src/1588/1588.c
-@@ -664,8 +664,7 @@ irqreturn_t timesync_isr(int irq, void *
- 0 => success
- < 0 => error
- ******************************************************************************/
--int timesync_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
-- unsigned long arg)
-+long timesync_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
- {
- wait_queue_head_t *event = NULL;
- unsigned int bytes_ret = 0;
---- a/Embedded/src/1588/1588.h
-+++ b/Embedded/src/1588/1588.h
-@@ -121,8 +121,7 @@ MODULE_DEVICE_TABLE(pci, pci_ids);
- // Linux functions
- int timesync_open(struct inode *inode, struct file *filp);
- int timesync_release(struct inode *inode, struct file *filp);
--int timesync_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
-- unsigned long arg);
-+long timesync_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
- void timesync_close(void);
- int pci_suspend(struct pci_dev *dev, pm_message_t state);
- int pci_resume(struct pci_dev *dev);
-@@ -142,7 +141,7 @@ struct file_operations file_ops =
- .owner = THIS_MODULE,
- .open = timesync_open,
- .release = timesync_release,
-- .ioctl = timesync_ioctl,
-+ .unlocked_ioctl = timesync_ioctl,
- };
-
- // Linux pci operations
diff --git a/package/system/gpio-button-hotplug/Makefile b/package/system/gpio-button-hotplug/Makefile
deleted file mode 100644
index 1778aadf09..0000000000
--- a/package/system/gpio-button-hotplug/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright (C) 2008-2012 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:=gpio-button-hotplug
-PKG_RELEASE:=1
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/gpio-button-hotplug
- SUBMENU:=Other modules
- TITLE:=Simple GPIO Button Hotplug driver
- FILES:=$(PKG_BUILD_DIR)/gpio-button-hotplug.ko
- AUTOLOAD:=$(call AutoLoad,30,gpio-button-hotplug,1)
- KCONFIG:=
-endef
-
-define KernelPackage/button-hotplug/description
- Kernel module to generate GPIO button hotplug events
-endef
-
-MAKE_OPTS:= \
- ARCH="$(LINUX_KARCH)" \
- CROSS_COMPILE="$(TARGET_CROSS)" \
- SUBDIRS="$(PKG_BUILD_DIR)"
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
- $(CP) ./src/* $(PKG_BUILD_DIR)/
-endef
-
-define Build/Compile
- $(MAKE) -C "$(LINUX_DIR)" \
- $(MAKE_OPTS) \
- modules
-endef
-
-$(eval $(call KernelPackage,gpio-button-hotplug))
diff --git a/package/system/gpio-button-hotplug/src/Makefile b/package/system/gpio-button-hotplug/src/Makefile
deleted file mode 100644
index e968865631..0000000000
--- a/package/system/gpio-button-hotplug/src/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-m += gpio-button-hotplug.o
diff --git a/package/system/gpio-button-hotplug/src/gpio-button-hotplug.c b/package/system/gpio-button-hotplug/src/gpio-button-hotplug.c
deleted file mode 100644
index 9d91b57b56..0000000000
--- a/package/system/gpio-button-hotplug/src/gpio-button-hotplug.c
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- * GPIO Button Hotplug driver
- *
- * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
- * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
- *
- * Based on the diag.c - GPIO interface driver for Broadcom boards
- * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
- * Copyright (C) 2006-2007 Felix Fietkau <nbd@openwrt.org>
- * Copyright (C) 2008 Andy Boyett <agb@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 <linux/module.h>
-#include <linux/version.h>
-#include <linux/kmod.h>
-
-#include <linux/workqueue.h>
-#include <linux/skbuff.h>
-#include <linux/netlink.h>
-#include <linux/kobject.h>
-#include <linux/input.h>
-#include <linux/platform_device.h>
-#include <linux/of_gpio.h>
-#include <linux/gpio_keys.h>
-
-#define DRV_NAME "gpio-keys-polled"
-
-#define BH_SKB_SIZE 2048
-
-#define PFX DRV_NAME ": "
-
-#undef BH_DEBUG
-
-#ifdef BH_DEBUG
-#define BH_DBG(fmt, args...) printk(KERN_DEBUG "%s: " fmt, DRV_NAME, ##args )
-#else
-#define BH_DBG(fmt, args...) do {} while (0)
-#endif
-
-#define BH_ERR(fmt, args...) printk(KERN_ERR "%s: " fmt, DRV_NAME, ##args )
-
-struct bh_priv {
- unsigned long seen;
-};
-
-struct bh_event {
- const char *name;
- char *action;
- unsigned long seen;
-
- struct sk_buff *skb;
- struct work_struct work;
-};
-
-struct bh_map {
- unsigned int code;
- const char *name;
-};
-
-struct gpio_keys_button_data {
- struct delayed_work work;
- struct bh_priv bh;
- int last_state;
- int count;
- int threshold;
- int can_sleep;
-};
-
-extern u64 uevent_next_seqnum(void);
-
-#define BH_MAP(_code, _name) \
- { \
- .code = (_code), \
- .name = (_name), \
- }
-
-static struct bh_map button_map[] = {
- BH_MAP(BTN_0, "BTN_0"),
- BH_MAP(BTN_1, "BTN_1"),
- BH_MAP(BTN_2, "BTN_2"),
- BH_MAP(BTN_3, "BTN_3"),
- BH_MAP(BTN_4, "BTN_4"),
- BH_MAP(BTN_5, "BTN_5"),
- BH_MAP(BTN_6, "BTN_6"),
- BH_MAP(BTN_7, "BTN_7"),
- BH_MAP(BTN_8, "BTN_8"),
- BH_MAP(BTN_9, "BTN_9"),
- BH_MAP(KEY_RESTART, "reset"),
- BH_MAP(KEY_RFKILL, "rfkill"),
-#ifdef KEY_WPS_BUTTON
- BH_MAP(KEY_WPS_BUTTON, "wps"),
-#endif /* KEY_WPS_BUTTON */
-};
-
-/* -------------------------------------------------------------------------*/
-
-static int bh_event_add_var(struct bh_event *event, int argv,
- const char *format, ...)
-{
- static char buf[128];
- char *s;
- va_list args;
- int len;
-
- if (argv)
- return 0;
-
- va_start(args, format);
- len = vsnprintf(buf, sizeof(buf), format, args);
- va_end(args);
-
- if (len >= sizeof(buf)) {
- BH_ERR("buffer size too small\n");
- WARN_ON(1);
- return -ENOMEM;
- }
-
- s = skb_put(event->skb, len + 1);
- strcpy(s, buf);
-
- BH_DBG("added variable '%s'\n", s);
-
- return 0;
-}
-
-static int button_hotplug_fill_event(struct bh_event *event)
-{
- int ret;
-
- ret = bh_event_add_var(event, 0, "HOME=%s", "/");
- if (ret)
- return ret;
-
- ret = bh_event_add_var(event, 0, "PATH=%s",
- "/sbin:/bin:/usr/sbin:/usr/bin");
- if (ret)
- return ret;
-
- ret = bh_event_add_var(event, 0, "SUBSYSTEM=%s", "button");
- if (ret)
- return ret;
-
- ret = bh_event_add_var(event, 0, "ACTION=%s", event->action);
- if (ret)
- return ret;
-
- ret = bh_event_add_var(event, 0, "BUTTON=%s", event->name);
- if (ret)
- return ret;
-
- ret = bh_event_add_var(event, 0, "SEEN=%ld", event->seen);
- if (ret)
- return ret;
-
- ret = bh_event_add_var(event, 0, "SEQNUM=%llu", uevent_next_seqnum());
-
- return ret;
-}
-
-static void button_hotplug_work(struct work_struct *work)
-{
- struct bh_event *event = container_of(work, struct bh_event, work);
- int ret = 0;
-
- event->skb = alloc_skb(BH_SKB_SIZE, GFP_KERNEL);
- if (!event->skb)
- goto out_free_event;
-
- ret = bh_event_add_var(event, 0, "%s@", event->action);
- if (ret)
- goto out_free_skb;
-
- ret = button_hotplug_fill_event(event);
- if (ret)
- goto out_free_skb;
-
- NETLINK_CB(event->skb).dst_group = 1;
- broadcast_uevent(event->skb, 0, 1, GFP_KERNEL);
-
- out_free_skb:
- if (ret) {
- BH_ERR("work error %d\n", ret);
- kfree_skb(event->skb);
- }
- out_free_event:
- kfree(event);
-}
-
-static int button_hotplug_create_event(const char *name, unsigned long seen,
- int pressed)
-{
- struct bh_event *event;
-
- BH_DBG("create event, name=%s, seen=%lu, pressed=%d\n",
- name, seen, pressed);
-
- event = kzalloc(sizeof(*event), GFP_KERNEL);
- if (!event)
- return -ENOMEM;
-
- event->name = name;
- event->seen = seen;
- event->action = pressed ? "pressed" : "released";
-
- INIT_WORK(&event->work, (void *)(void *)button_hotplug_work);
- schedule_work(&event->work);
-
- return 0;
-}
-
-/* -------------------------------------------------------------------------*/
-
-#ifdef CONFIG_HOTPLUG
-static int button_get_index(unsigned int code)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(button_map); i++)
- if (button_map[i].code == code)
- return i;
-
- return -1;
-}
-static void button_hotplug_event(struct gpio_keys_button_data *data,
- unsigned int type, unsigned int code, int value)
-{
- struct bh_priv *priv = &data->bh;
- unsigned long seen = jiffies;
- int btn;
-
- BH_DBG("event type=%u, code=%u, value=%d\n", type, code, value);
-
- if (type != EV_KEY)
- return;
-
- btn = button_get_index(code);
- if (btn < 0)
- return;
-
- button_hotplug_create_event(button_map[btn].name,
- (seen - priv->seen) / HZ, value);
- priv->seen = seen;
-}
-#else
-static void button_hotplug_event(struct gpio_keys_button_data *data,
- unsigned int type, unsigned int code, int value)
-{
-}
-#endif /* CONFIG_HOTPLUG */
-
-struct gpio_keys_polled_dev {
- struct delayed_work work;
-
- struct device *dev;
- struct gpio_keys_platform_data *pdata;
- struct gpio_keys_button_data data[0];
-};
-
-static void gpio_keys_polled_check_state(struct gpio_keys_button *button,
- struct gpio_keys_button_data *bdata)
-{
- int state;
-
- if (bdata->can_sleep)
- state = !!gpio_get_value_cansleep(button->gpio);
- else
- state = !!gpio_get_value(button->gpio);
-
- state = !!(state ^ button->active_low);
- if (state != bdata->last_state) {
- unsigned int type = button->type ?: EV_KEY;
-
- button_hotplug_event(bdata, type, button->code, state);
- bdata->count = 0;
- bdata->last_state = state;
- }
-}
-
-static void gpio_keys_polled_queue_work(struct gpio_keys_polled_dev *bdev)
-{
- struct gpio_keys_platform_data *pdata = bdev->pdata;
- unsigned long delay = msecs_to_jiffies(pdata->poll_interval);
-
- if (delay >= HZ)
- delay = round_jiffies_relative(delay);
- schedule_delayed_work(&bdev->work, delay);
-}
-
-static void gpio_keys_polled_poll(struct work_struct *work)
-{
- struct gpio_keys_polled_dev *bdev =
- container_of(work, struct gpio_keys_polled_dev, work.work);
- struct gpio_keys_platform_data *pdata = bdev->pdata;
- int i;
-
- for (i = 0; i < bdev->pdata->nbuttons; i++) {
- struct gpio_keys_button_data *bdata = &bdev->data[i];
-
- if (bdata->count < bdata->threshold)
- bdata->count++;
- else
- gpio_keys_polled_check_state(&pdata->buttons[i], bdata);
- }
- gpio_keys_polled_queue_work(bdev);
-}
-
-static void gpio_keys_polled_open(struct gpio_keys_polled_dev *bdev)
-{
- struct gpio_keys_platform_data *pdata = bdev->pdata;
- int i;
-
- if (pdata->enable)
- pdata->enable(bdev->dev);
-
- /* report initial state of the buttons */
- for (i = 0; i < pdata->nbuttons; i++)
- gpio_keys_polled_check_state(&pdata->buttons[i], &bdev->data[i]);
-
- gpio_keys_polled_queue_work(bdev);
-}
-
-#ifdef CONFIG_OF
-static struct gpio_keys_platform_data *
-gpio_keys_polled_get_devtree_pdata(struct device *dev)
-{
- struct device_node *node, *pp;
- struct gpio_keys_platform_data *pdata;
- struct gpio_keys_button *button;
- int error;
- int nbuttons;
- int i;
-
- node = dev->of_node;
- if (!node)
- return NULL;
-
- nbuttons = of_get_child_count(node);
- if (nbuttons == 0)
- return NULL;
-
- pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button),
- GFP_KERNEL);
- if (!pdata) {
- error = -ENOMEM;
- goto err_out;
- }
-
- pdata->buttons = (struct gpio_keys_button *)(pdata + 1);
- pdata->nbuttons = nbuttons;
-
- pdata->rep = !!of_get_property(node, "autorepeat", NULL);
- of_property_read_u32(node, "poll-interval", &pdata->poll_interval);
-
- i = 0;
- for_each_child_of_node(node, pp) {
- enum of_gpio_flags flags;
-
- if (!of_find_property(pp, "gpios", NULL)) {
- pdata->nbuttons--;
- dev_warn(dev, "Found button without gpios\n");
- continue;
- }
-
- button = &pdata->buttons[i++];
-
- button->gpio = of_get_gpio_flags(pp, 0, &flags);
- button->active_low = flags & OF_GPIO_ACTIVE_LOW;
-
- if (of_property_read_u32(pp, "linux,code", &button->code)) {
- dev_err(dev, "Button without keycode: 0x%x\n",
- button->gpio);
- error = -EINVAL;
- goto err_free_pdata;
- }
-
- button->desc = of_get_property(pp, "label", NULL);
-
- if (of_property_read_u32(pp, "linux,input-type", &button->type))
- button->type = EV_KEY;
-
- button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL);
-
- if (of_property_read_u32(pp, "debounce-interval",
- &button->debounce_interval))
- button->debounce_interval = 5;
- }
-
- if (pdata->nbuttons == 0) {
- error = -EINVAL;
- goto err_free_pdata;
- }
-
- return pdata;
-
-err_free_pdata:
- kfree(pdata);
-err_out:
- return ERR_PTR(error);
-}
-
-static struct of_device_id gpio_keys_polled_of_match[] = {
- { .compatible = "gpio-keys-polled", },
- { },
-};
-MODULE_DEVICE_TABLE(of, gpio_keys_polled_of_match);
-
-#else
-
-static inline struct gpio_keys_platform_data *
-gpio_keys_polled_get_devtree_pdata(struct device *dev)
-{
- return NULL;
-}
-#endif
-
-static void gpio_keys_polled_close(struct gpio_keys_polled_dev *bdev)
-{
- struct gpio_keys_platform_data *pdata = bdev->pdata;
-
- cancel_delayed_work_sync(&bdev->work);
-
- if (pdata->disable)
- pdata->disable(bdev->dev);
-}
-
-static int gpio_keys_polled_probe(struct platform_device *pdev)
-{
- struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
- struct device *dev = &pdev->dev;
- struct gpio_keys_polled_dev *bdev;
- int error;
- int i;
-
- if (!pdata) {
- pdata = gpio_keys_polled_get_devtree_pdata(dev);
- if (IS_ERR(pdata))
- return PTR_ERR(pdata);
- if (!pdata) {
- dev_err(dev, "missing platform data\n");
- return -EINVAL;
- }
- }
-
- if (!pdata->poll_interval) {
- dev_err(dev, "missing poll_interval value\n");
- error = -EINVAL;
- goto err_free_pdata;
- }
-
- bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) +
- pdata->nbuttons * sizeof(struct gpio_keys_button_data),
- GFP_KERNEL);
- if (!bdev) {
- dev_err(dev, "no memory for private data\n");
- return -ENOMEM;
- }
-
- for (i = 0; i < pdata->nbuttons; i++) {
- struct gpio_keys_button *button = &pdata->buttons[i];
- struct gpio_keys_button_data *bdata = &bdev->data[i];
- unsigned int gpio = button->gpio;
-
- if (button->wakeup) {
- dev_err(dev, DRV_NAME " does not support wakeup\n");
- error = -EINVAL;
- goto err_free_gpio;
- }
-
- error = gpio_request(gpio,
- button->desc ? button->desc : DRV_NAME);
- if (error) {
- dev_err(dev, "unable to claim gpio %u, err=%d\n",
- gpio, error);
- goto err_free_gpio;
- }
-
- error = gpio_direction_input(gpio);
- if (error) {
- dev_err(dev,
- "unable to set direction on gpio %u, err=%d\n",
- gpio, error);
- goto err_free_gpio;
- }
-
- bdata->can_sleep = gpio_cansleep(gpio);
- bdata->last_state = 0;
- bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
- pdata->poll_interval);
- }
-
- bdev->dev = &pdev->dev;
- bdev->pdata = pdata;
- platform_set_drvdata(pdev, bdev);
-
- INIT_DELAYED_WORK(&bdev->work, gpio_keys_polled_poll);
-
- gpio_keys_polled_open(bdev);
-
- return 0;
-
-err_free_gpio:
- while (--i >= 0)
- gpio_free(pdata->buttons[i].gpio);
-
- kfree(bdev);
- platform_set_drvdata(pdev, NULL);
-
-err_free_pdata:
- /* If we have no platform_data, we allocated pdata dynamically. */
- if (!dev_get_platdata(&pdev->dev))
- kfree(pdata);
-
- return error;
-}
-
-static int gpio_keys_polled_remove(struct platform_device *pdev)
-{
- struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev);
- struct gpio_keys_platform_data *pdata = bdev->pdata;
- int i = pdata->nbuttons;
-
- gpio_keys_polled_close(bdev);
-
- while (--i >= 0)
- gpio_free(pdata->buttons[i].gpio);
-
- kfree(bdev);
- platform_set_drvdata(pdev, NULL);
-
- return 0;
-}
-
-static struct platform_driver gpio_keys_polled_driver = {
- .probe = gpio_keys_polled_probe,
- .remove = gpio_keys_polled_remove,
- .driver = {
- .name = DRV_NAME,
- .owner = THIS_MODULE,
- .of_match_table = of_match_ptr(gpio_keys_polled_of_match),
- },
-};
-
-static int __init gpio_keys_polled_init(void)
-{
- return platform_driver_register(&gpio_keys_polled_driver);
-}
-
-static void __exit gpio_keys_polled_exit(void)
-{
- platform_driver_unregister(&gpio_keys_polled_driver);
-}
-
-module_init(gpio_keys_polled_init);
-module_exit(gpio_keys_polled_exit);
-
-MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
-MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");
-MODULE_DESCRIPTION("Polled GPIO Buttons hotplug driver");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/package/system/hostap-driver/Makefile b/package/system/hostap-driver/Makefile
deleted file mode 100644
index d08fd9c0a5..0000000000
--- a/package/system/hostap-driver/Makefile
+++ /dev/null
@@ -1,117 +0,0 @@
-#
-# 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:=hostap-driver
-PKG_VERSION:=0.4.9
-PKG_RELEASE:=2
-
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=http://hostap.epitest.fi/releases/
-PKG_MD5SUM:=c7534dc040ab90218257a78488ecd378
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/hostap/Default
- VERSION:=$(LINUX_VERSION)-$(BOARD)-$(PKG_RELEASE)
- SUBMENU:=Wireless Drivers
- URL:=http://hostap.epitest.fi/
-endef
-
-define KernelPackage/hostap/Default/description
- Host AP is a driver for 802.11b wireless cards based on Intersil
- Prism2/2.5/3 chipset. It supports so called Host AP mode that allows the
- card to act as an IEEE 802.11 access point.
-endef
-
-
-define KernelPackage/hostap
-$(call KernelPackage/hostap/Default)
- TITLE:=Host AP support for Prism2/2.5/3
- DEPENDS:=@PCI_SUPPORT||PCMCIA_SUPPORT +kmod-lib80211 +wireless-tools
- KCONFIG:=CONFIG_HOSTAP CONFIG_HOSTAP_FIRMWARE=y CONFIG_HOSTAP_FIRMWARE_NVRAM=y
- FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap.ko
- AUTOLOAD:=$(call AutoLoad,60,hostap)
-endef
-
-define KernelPackage/hostap/description
-$(call KernelPackage/hostap/Default/description)
- This package contains the base Host AP driver code that is shared by
- different hardware models. You will also need to enable support for
- PLX/PCI/CS version of the driver to actually use the driver.
-endef
-
-
-define KernelPackage/hostap-cs
-$(call KernelPackage/hostap/Default)
- TITLE:=Host AP driver for PCMCIA adaptors
- DEPENDS:=@PCMCIA_SUPPORT +kmod-hostap +kmod-pcmcia-core
- KCONFIG:=CONFIG_HOSTAP_CS
- FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap_cs.ko
- AUTOLOAD:=$(call AutoLoad,60,hostap_cs)
-endef
-
-define KernelPackage/hostap-cs/description
-$(call KernelPackage/hostap/Default/description)
- This package contains the Host AP driver for Prism2/2.5/3 PC cards.
-endef
-
-
-define KernelPackage/hostap-pci
-$(call KernelPackage/hostap/Default)
- TITLE:=Host AP driver for PCI adaptors
- DEPENDS:=@PCI_SUPPORT +kmod-hostap
- KCONFIG:=CONFIG_HOSTAP_PCI
- FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap_pci.ko
- AUTOLOAD:=$(call AutoLoad,60,hostap_pci)
-endef
-
-define KernelPackage/hostap-pci/description
-$(call KernelPackage/hostap/Default/description)
- This package contains the Host AP driver for Prism2.5 PCI adaptors.
-endef
-
-
-define KernelPackage/hostap-plx
-$(call KernelPackage/hostap/Default)
- TITLE:=Host AP driver for PLX9052 based PCI adaptors
- DEPENDS:=@PCI_SUPPORT +kmod-hostap
- KCONFIG:=CONFIG_HOSTAP_PLX
- FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap_plx.ko
- AUTOLOAD:=$(call AutoLoad,60,hostap_plx)
-endef
-
-define KernelPackage/hostap-plx/description
-$(call KernelPackage/hostap/Default/description)
- This package contains the Host AP driver for Prism2/2.5/3 in PLX9052
- based PCI adaptors.
-endef
-
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
-endef
-
-define Build/Configure
-
-endef
-
-define Build/Compile
-
-endef
-
-define KernelPackage/hostap/install
- $(INSTALL_DIR) $(1)/lib/wifi
- $(INSTALL_DATA) ./files/lib/wifi/hostap.sh $(1)/lib/wifi
-endef
-
-$(eval $(call KernelPackage,hostap))
-$(eval $(call KernelPackage,hostap-cs))
-$(eval $(call KernelPackage,hostap-pci))
-$(eval $(call KernelPackage,hostap-plx))
diff --git a/package/system/hostap-driver/files/lib/wifi/hostap.sh b/package/system/hostap-driver/files/lib/wifi/hostap.sh
deleted file mode 100755
index 62d2e7e472..0000000000
--- a/package/system/hostap-driver/files/lib/wifi/hostap.sh
+++ /dev/null
@@ -1,270 +0,0 @@
-#!/bin/sh
-append DRIVERS "prism2"
-
-find_prism2_phy() {
- local device="$1"
-
- local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"
- config_get phy "$device" phy
- [ -z "$phy" -a -n "$macaddr" ] && {
- cd /proc/net/hostap
- for phy in $(ls -d wlan* 2>&-); do
- [ "$macaddr" = "$(cat /sys/class/net/${phy}/address)" ] || continue
- config_set "$device" phy "$phy"
- break
- done
- config_get phy "$device" phy
- }
- [ -n "$phy" -a -d "/proc/net/hostap/$phy" ] || {
- echo "phy for wifi device $1 not found"
- return 1
- }
- [ -z "$macaddr" ] && {
- config_set "$device" macaddr "$(cat /sys/class/net/${phy}/address)"
- }
- return 0
-}
-
-scan_prism2() {
- local device="$1"
- local mainvif
- local wds
-
- [ ${device%[0-9]} = "wlan" ] && config_set "$device" phy "$device" || find_prism2_phy "$device" || {
- config_unset "$device" vifs
- return 0
- }
- config_get phy "$device" phy
-
- config_get vifs "$device" vifs
- local _c=0
- for vif in $vifs; do
- config_get_bool disabled "$vif" disabled 0
- [ $disabled = 0 ] || continue
-
- config_get mode "$vif" mode
- case "$mode" in
- adhoc|sta|ap|monitor)
- # Only one vif is allowed on AP, station, Ad-hoc or monitor mode
- [ -z "$mainvif" ] && {
- mainvif="$vif"
- config_set "$vif" ifname "$phy"
- }
- ;;
- wds)
- config_get ssid "$vif" ssid
- [ -z "$ssid" ] && continue
- config_set "$vif" ifname "${phy}wds${_c}"
- _c=$(($_c + 1))
- addr="$ssid"
- ${addr:+append wds "$vif"}
- ;;
- *) echo "$device($vif): Invalid mode, ignored."; continue;;
- esac
- done
- config_set "$device" vifs "${mainvif:+$mainvif }${wds:+$wds}"
-}
-
-disable_prism2() (
- local device="$1"
-
- find_prism2_phy "$device" || return 0
- config_get phy "$device" phy
-
- set_wifi_down "$device"
-
- include /lib/network
- while read line < /proc/net/hostap/${phy}/wds; do
- set $line
- [ -f "/var/run/wifi-${1}.pid" ] &&
- kill "$(cat "/var/run/wifi-${1}.pid")"
- ifconfig "$1" down
- unbridge "$1"
- iwpriv "$phy" wds_del "$2"
- done
- unbridge "$phy"
- return 0
-)
-
-enable_prism2() {
- local device="$1"
-
- find_prism2_phy "$device" || return 0
- config_get phy "$device" phy
-
- config_get rxantenna "$device" rxantenna
- config_get txantenna "$device" txantenna
- config_get_bool diversity "$device" diversity
- [ -n "$diversity" ] && {
- rxantenna="1"
- txantenna="1"
- }
- [ -n "$rxantenna" ] && iwpriv "$phy" antsel_rx "$rxantenna"
- [ -n "$txantenna" ] && iwpriv "$phy" antsel_tx "$txantenna"
-
- config_get channel "$device" channel
- [ -n "$channel" ] && iwconfig "$phy" channel "$channel" >/dev/null 2>/dev/null
-
- config_get txpower "$device" txpower
- [ -n "$txpower" ] && iwconfig "$phy" txpower "${txpower%%.*}"
-
- config_get vifs "$device" vifs
- local first=1
- for vif in $vifs; do
- config_get ifname "$vif" ifname
- config_get ssid "$vif" ssid
- config_get mode "$vif" mode
-
- [ "$mode" = "wds" ] || iwconfig "$phy" essid ${ssid:+-- }"${ssid:-any}"
-
- case "$mode" in
- sta)
- iwconfig "$phy" mode managed
- config_get addr "$device" bssid
- [ -z "$addr" ] || {
- iwconfig "$phy" ap "$addr"
- }
- ;;
- ap) iwconfig "$phy" mode master;;
- wds) iwpriv "$phy" wds_add "$ssid";;
- adhoc) iwconfig "$phy" mode ad-hoc;;
- *) iwconfig "$phy" mode "$mode";;
- esac
-
- [ "$first" = 1 ] && {
- config_get rate "$vif" rate
- [ -n "$rate" ] && iwconfig "$phy" rate "${rate%%.*}"
-
- config_get_bool hidden "$vif" hidden 0
- iwpriv "$phy" enh_sec "$hidden"
-
- config_get frag "$vif" frag
- [ -n "$frag" ] && iwconfig "$phy" frag "${frag%%.*}"
-
- config_get rts "$vif" rts
- [ -n "$rts" ] && iwconfig "$phy" rts "${rts%%.*}"
-
- config_get maclist "$vif" maclist
- [ -n "$maclist" ] && {
- # flush MAC list
- iwpriv "$phy" maccmd 3
- for mac in $maclist; do
- iwpriv "$phy" addmac "$mac"
- done
- }
- config_get macpolicy "$vif" macpolicy
- case "$macpolicy" in
- allow)
- iwpriv "$phy" maccmd 2
- ;;
- deny)
- iwpriv "$phy" maccmd 1
- ;;
- *)
- # default deny policy if mac list exists
- [ -n "$maclist" ] && iwpriv "$phy" maccmd 1
- ;;
- esac
- # kick all stations if we have policy explicitly set
- [ -n "$macpolicy" ] && iwpriv "$phy" maccmd 4
- }
-
- config_get enc "$vif" encryption
- case "$enc" in
- WEP|wep)
- for idx in 1 2 3 4; do
- config_get key "$vif" "key${idx}"
- iwconfig "$ifname" enc "[$idx]" "${key:-off}"
- done
- config_get key "$vif" key
- key="${key:-1}"
- case "$key" in
- [1234]) iwconfig "$ifname" enc "[$key]";;
- *) iwconfig "$ifname" enc "$key";;
- esac
- ;;
- psk*|wpa*)
- start_hostapd=1
- config_get key "$vif" key
- ;;
- esac
-
- local net_cfg bridge
- net_cfg="$(find_net_config "$vif")"
- [ -z "$net_cfg" ] || {
- bridge="$(bridge_interface "$net_cfg")"
- config_set "$vif" bridge "$bridge"
- start_net "$ifname" "$net_cfg"
- }
- set_wifi_up "$vif" "$ifname"
-
- case "$mode" in
- ap)
- if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev/null >/dev/null; then
- hostapd_setup_vif "$vif" hostap || {
- echo "enable_prism2($device): Failed to set up hostapd for interface $ifname" >&2
- # make sure this wifi interface won't accidentally stay open without encryption
- ifconfig "$ifname" down
- continue
- }
- fi
- ;;
- wds|sta)
- if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
- wpa_supplicant_setup_vif "$vif" wext || {
- echo "enable_prism2($device): Failed to set up wpa_supplicant for interface $ifname" >&2
- ifconfig "$ifname" down
- continue
- }
- fi
- ;;
- esac
- first=0
- done
-
-}
-
-check_prism2_device() {
- [ ${1%[0-9]} = "wlan" ] && config_set "$1" phy "$1"
- config_get phy "$1" phy
- [ -z "$phy" ] && {
- find_prism2_phy "$1" >/dev/null || return 0
- config_get phy "$1" phy
- }
- [ "$phy" = "$dev" ] && found=1
-}
-
-detect_prism2() {
- devidx=0
- config_load wireless
- while :; do
- config_get type "radio$devidx" type
- [ -n "$type" ] || break
- devidx=$(($devidx + 1))
- done
- cd /proc/net/hostap
- [ -d wlan* ] || return
- for dev in $(ls -d wlan* 2>&-); do
- found=0
- config_foreach check_prism2_device wifi-device
- [ "$found" -gt 0 ] && continue
- cat <<EOF
-config wifi-device radio$devidx
- option type prism2
- option channel 11
- option macaddr $(cat /sys/class/net/${dev}/address)
-
- # REMOVE THIS LINE TO ENABLE WIFI:
- option disabled 1
-
-config wifi-iface
- option device radio$devidx
- option network lan
- option mode ap
- option ssid OpenWrt
- option encryption none
-
-EOF
- devidx=$(($devidx + 1))
- done
-}
diff --git a/package/system/hostap-driver/patches/001-fix-txpower.patch b/package/system/hostap-driver/patches/001-fix-txpower.patch
deleted file mode 100644
index 94ca344943..0000000000
--- a/package/system/hostap-driver/patches/001-fix-txpower.patch
+++ /dev/null
@@ -1,175 +0,0 @@
-diff -Naur hostap-driver-0.3.7/driver/modules/hostap.c hostap-driver-0.3.7-patched/driver/modules/hostap.c
---- hostap-driver-0.3.7/driver/modules/hostap.c 2004-08-28 06:26:46.000000000 +0300
-+++ hostap-driver-0.3.7-patched/driver/modules/hostap.c 2005-04-20 17:20:56.000000000 +0300
-@@ -1164,6 +1164,36 @@
- return ret;
- }
-
-+/* BUG FIX: Restore power setting value when lost due to F/W bug */
-+
-+int hostap_restore_power(struct net_device *dev)
-+{
-+ struct hostap_interface *iface = dev->priv;
-+ local_info_t *local = iface->local;
-+
-+ u16 val;
-+ int ret = 0;
-+
-+ if (local->txpower_type == PRISM2_TXPOWER_OFF) {
-+ val = 0xff; /* use all standby and sleep modes */
-+ ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
-+ HFA386X_CR_A_D_TEST_MODES2,
-+ &val, NULL);
-+ }
-+
-+#ifdef RAW_TXPOWER_SETTING
-+ if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
-+ val = HFA384X_TEST_CFG_BIT_ALC;
-+ local->func->cmd(dev, HFA384X_CMDCODE_TEST |
-+ (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
-+ val = prism2_txpower_dBm_to_hfa386x(local->txpower);
-+ ret = (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
-+ HFA386X_CR_MANUAL_TX_POWER, &val, NULL));
-+ }
-+#endif /* RAW_TXPOWER_SETTING */
-+ return (ret ? -EOPNOTSUPP : 0);
-+}
-+
-
- struct proc_dir_entry *hostap_proc;
-
-@@ -1214,6 +1244,7 @@
- EXPORT_SYMBOL(hostap_set_hostapd_sta);
- EXPORT_SYMBOL(hostap_add_interface);
- EXPORT_SYMBOL(hostap_remove_interface);
-+EXPORT_SYMBOL(hostap_restore_power);
- EXPORT_SYMBOL(prism2_update_comms_qual);
-
- module_init(hostap_init);
-diff -Naur hostap-driver-0.3.7/driver/modules/hostap.h hostap-driver-0.3.7-patched/driver/modules/hostap.h
---- hostap-driver-0.3.7/driver/modules/hostap.h 2003-11-30 04:14:26.000000000 +0200
-+++ hostap-driver-0.3.7-patched/driver/modules/hostap.h 2005-04-20 17:21:23.000000000 +0300
-@@ -36,6 +36,7 @@
- const char *prefix, const char *name);
- void hostap_remove_interface(struct net_device *dev, int rtnl_locked,
- int remove_from_list);
-+int hostap_restore_power(struct net_device *dev);
- int prism2_update_comms_qual(struct net_device *dev);
- int prism2_sta_send_mgmt(local_info_t *local, u8 *dst, u8 stype,
- u8 *body, size_t bodylen);
-diff -Naur hostap-driver-0.3.7/driver/modules/hostap_ap.c hostap-driver-0.3.7-patched/driver/modules/hostap_ap.c
---- hostap-driver-0.3.7/driver/modules/hostap_ap.c 2005-01-24 04:52:00.000000000 +0200
-+++ hostap-driver-0.3.7-patched/driver/modules/hostap_ap.c 2005-04-21 20:06:12.000000000 +0300
-@@ -2346,13 +2346,13 @@
- addr[count].sa_family = ARPHRD_ETHER;
- memcpy(addr[count].sa_data, sta->addr, ETH_ALEN);
- if (sta->last_rx_silence == 0)
-- qual[count].qual = sta->last_rx_signal < 27 ?
-- 0 : (sta->last_rx_signal - 27) * 92 / 127;
-+ qual[count].qual = (sta->last_rx_signal - 156) == 0 ?
-+ 0 : (sta->last_rx_signal - 156) * 92 / 64;
- else
-- qual[count].qual = sta->last_rx_signal -
-- sta->last_rx_silence - 35;
-- qual[count].level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
-- qual[count].noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
-+ qual[count].qual = (sta->last_rx_signal -
-+ sta->last_rx_silence) * 92 / 64;
-+ qual[count].level = sta->last_rx_signal;
-+ qual[count].noise = sta->last_rx_silence;
- qual[count].updated = sta->last_rx_updated;
-
- sta->last_rx_updated = 0;
-@@ -2413,13 +2413,13 @@
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = IWEVQUAL;
- if (sta->last_rx_silence == 0)
-- iwe.u.qual.qual = sta->last_rx_signal < 27 ?
-- 0 : (sta->last_rx_signal - 27) * 92 / 127;
-+ iwe.u.qual.qual = (sta->last_rx_signal -156) == 0 ?
-+ 0 : (sta->last_rx_signal - 156) * 92 / 64;
- else
-- iwe.u.qual.qual = sta->last_rx_signal -
-- sta->last_rx_silence - 35;
-- iwe.u.qual.level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
-- iwe.u.qual.noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
-+ iwe.u.qual.qual = (sta->last_rx_signal -
-+ sta->last_rx_silence) * 92 / 64;
-+ iwe.u.qual.level = sta->last_rx_signal;
-+ iwe.u.qual.noise = sta->last_rx_silence;
- iwe.u.qual.updated = sta->last_rx_updated;
- iwe.len = IW_EV_QUAL_LEN;
- current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
-diff -Naur hostap-driver-0.3.7/driver/modules/hostap_config.h hostap-driver-0.3.7-patched/driver/modules/hostap_config.h
---- hostap-driver-0.3.7/driver/modules/hostap_config.h 2005-02-12 18:12:56.000000000 +0200
-+++ hostap-driver-0.3.7-patched/driver/modules/hostap_config.h 2005-04-20 17:25:23.000000000 +0300
-@@ -94,6 +94,12 @@
- */
- /* #define PRISM2_NO_STATION_MODES */
-
-+/* Enable TX power Setting functions
-+ * (min att = -128 , max att = 127)
-+ */
-+
-+#define RAW_TXPOWER_SETTING
-+
- /* Use Linux crypto API instead of own encryption implementation whenever
- * possible. */
- /* #define HOSTAP_USE_CRYPTO_API */
-diff -Naur hostap-driver-0.3.7/driver/modules/hostap_hw.c hostap-driver-0.3.7-patched/driver/modules/hostap_hw.c
---- hostap-driver-0.3.7/driver/modules/hostap_hw.c 2005-02-05 09:20:09.000000000 +0200
-+++ hostap-driver-0.3.7-patched/driver/modules/hostap_hw.c 2005-04-20 17:25:55.000000000 +0300
-@@ -1039,6 +1039,7 @@
- dev->name, local->fragm_threshold);
- }
-
-+ hostap_restore_power(dev);
- return res;
- }
-
-diff -Naur hostap-driver-0.3.7/driver/modules/hostap_info.c hostap-driver-0.3.7-patched/driver/modules/hostap_info.c
---- hostap-driver-0.3.7/driver/modules/hostap_info.c 2004-02-29 20:05:44.000000000 +0200
-+++ hostap-driver-0.3.7-patched/driver/modules/hostap_info.c 2005-04-20 17:26:36.000000000 +0300
-@@ -418,6 +418,11 @@
- }
-
- /* Get BSSID if we have a valid AP address */
-+
-+ if ( val == HFA384X_LINKSTATUS_CONNECTED ||
-+ val == HFA384X_LINKSTATUS_DISCONNECTED )
-+ hostap_restore_power(local->dev);
-+
- if (connected) {
- netif_carrier_on(local->dev);
- netif_carrier_on(local->ddev);
-diff -Naur hostap-driver-0.3.7/driver/modules/hostap_ioctl.c hostap-driver-0.3.7-patched/driver/modules/hostap_ioctl.c
---- hostap-driver-0.3.7/driver/modules/hostap_ioctl.c 2004-11-22 08:03:05.000000000 +0200
-+++ hostap-driver-0.3.7-patched/driver/modules/hostap_ioctl.c 2005-04-20 17:42:41.000000000 +0300
-@@ -1453,23 +1453,20 @@
- val = 255;
-
- tmp = val;
-- tmp >>= 2;
-
-- return -12 - tmp;
-+ return tmp;
- }
-
- static u16 prism2_txpower_dBm_to_hfa386x(int val)
- {
- signed char tmp;
-
-- if (val > 20)
-- return 128;
-- else if (val < -43)
-+ if (val > 127)
- return 127;
-+ else if (val < -128)
-+ return 128;
-
- tmp = val;
-- tmp = -12 - tmp;
-- tmp <<= 2;
-
- return (unsigned char) tmp;
- }
diff --git a/package/system/i2c-gpio-custom/Makefile b/package/system/i2c-gpio-custom/Makefile
deleted file mode 100644
index 8585a5ab57..0000000000
--- a/package/system/i2c-gpio-custom/Makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# Copyright (C) 2008 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-include $(INCLUDE_DIR)/kernel.mk
-
-PKG_NAME:=i2c-gpio-custom
-PKG_RELEASE:=2
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/i2c-gpio-custom
- SUBMENU:=I2C support
- TITLE:=Custom GPIO-based I2C device
- DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core +kmod-i2c-gpio
- FILES:=$(PKG_BUILD_DIR)/i2c-gpio-custom.ko
- KCONFIG:=
-endef
-
-define KernelPackage/i2c-gpio-custom/description
- Kernel module for register a custom i2c-gpio platform device.
-endef
-
-EXTRA_KCONFIG:= \
- CONFIG_I2C_GPIO_CUSTOM=m
-
-EXTRA_CFLAGS:= \
- $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
- $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
-
-MAKE_OPTS:= \
- ARCH="$(LINUX_KARCH)" \
- CROSS_COMPILE="$(TARGET_CROSS)" \
- SUBDIRS="$(PKG_BUILD_DIR)" \
- EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
- $(EXTRA_KCONFIG)
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
- $(CP) ./src/* $(PKG_BUILD_DIR)/
-endef
-
-define Build/Compile
- $(MAKE) -C "$(LINUX_DIR)" \
- $(MAKE_OPTS) \
- modules
-endef
-
-$(eval $(call KernelPackage,i2c-gpio-custom))
diff --git a/package/system/i2c-gpio-custom/src/Kconfig b/package/system/i2c-gpio-custom/src/Kconfig
deleted file mode 100644
index e2e3a68d92..0000000000
--- a/package/system/i2c-gpio-custom/src/Kconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-config I2C_GPIO_CUSTOM
- tristate "Custom GPIO-based I2C driver"
- depends on GENERIC_GPIO
- select I2C_GPIO
- help
- This is an I2C driver to register 1 to 4 custom I2C buses using
- GPIO lines.
-
- This support is also available as a module. If so, the module
- will be called i2c-gpio-custom.
diff --git a/package/system/i2c-gpio-custom/src/Makefile b/package/system/i2c-gpio-custom/src/Makefile
deleted file mode 100644
index dcb2e2abe2..0000000000
--- a/package/system/i2c-gpio-custom/src/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-${CONFIG_I2C_GPIO_CUSTOM} += i2c-gpio-custom.o \ No newline at end of file
diff --git a/package/system/i2c-gpio-custom/src/i2c-gpio-custom.c b/package/system/i2c-gpio-custom/src/i2c-gpio-custom.c
deleted file mode 100644
index 76ab5f39cc..0000000000
--- a/package/system/i2c-gpio-custom/src/i2c-gpio-custom.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Custom GPIO-based I2C driver
- *
- * Copyright (C) 2007-2008 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.
- *
- * ---------------------------------------------------------------------------
- *
- * The behaviour of this driver can be altered by setting some parameters
- * from the insmod command line.
- *
- * The following parameters are adjustable:
- *
- * bus0 These four arguments can be arrays of
- * bus1 1-8 unsigned integers as follows:
- * bus2
- * bus3 <id>,<sda>,<scl>,<udelay>,<timeout>,<sda_od>,<scl_od>,<scl_oo>
- *
- * where:
- *
- * <id> ID to used as device_id for the corresponding bus (required)
- * <sda> GPIO pin ID to used for SDA (required)
- * <scl> GPIO pin ID to used for SCL (required)
- * <udelay> signal toggle delay.
- * <timeout> clock stretching timeout.
- * <sda_od> SDA is configured as open drain.
- * <scl_od> SCL is configured as open drain.
- * <scl_oo> SCL output drivers cannot be turned off.
- *
- * See include/i2c-gpio.h for more information about the parameters.
- *
- * If this driver is built into the kernel, you can use the following kernel
- * command line parameters, with the same values as the corresponding module
- * parameters listed above:
- *
- * i2c-gpio-custom.bus0
- * i2c-gpio-custom.bus1
- * i2c-gpio-custom.bus2
- * i2c-gpio-custom.bus3
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-
-#include <linux/i2c-gpio.h>
-
-#define DRV_NAME "i2c-gpio-custom"
-#define DRV_DESC "Custom GPIO-based I2C driver"
-#define DRV_VERSION "0.1.1"
-
-#define PFX DRV_NAME ": "
-
-#define BUS_PARAM_ID 0
-#define BUS_PARAM_SDA 1
-#define BUS_PARAM_SCL 2
-#define BUS_PARAM_UDELAY 3
-#define BUS_PARAM_TIMEOUT 4
-#define BUS_PARAM_SDA_OD 5
-#define BUS_PARAM_SCL_OD 6
-#define BUS_PARAM_SCL_OO 7
-
-#define BUS_PARAM_REQUIRED 3
-#define BUS_PARAM_COUNT 8
-#define BUS_COUNT_MAX 4
-
-static unsigned int bus0[BUS_PARAM_COUNT] __initdata;
-static unsigned int bus1[BUS_PARAM_COUNT] __initdata;
-static unsigned int bus2[BUS_PARAM_COUNT] __initdata;
-static unsigned int bus3[BUS_PARAM_COUNT] __initdata;
-
-static unsigned int bus_nump[BUS_COUNT_MAX] __initdata;
-
-#define BUS_PARM_DESC \
- " config -> id,sda,scl[,udelay,timeout,sda_od,scl_od,scl_oo]"
-
-module_param_array(bus0, uint, &bus_nump[0], 0);
-MODULE_PARM_DESC(bus0, "bus0" BUS_PARM_DESC);
-module_param_array(bus1, uint, &bus_nump[1], 0);
-MODULE_PARM_DESC(bus1, "bus1" BUS_PARM_DESC);
-module_param_array(bus2, uint, &bus_nump[2], 0);
-MODULE_PARM_DESC(bus2, "bus2" BUS_PARM_DESC);
-module_param_array(bus3, uint, &bus_nump[3], 0);
-MODULE_PARM_DESC(bus3, "bus3" BUS_PARM_DESC);
-
-static struct platform_device *devices[BUS_COUNT_MAX];
-static unsigned int nr_devices;
-
-static void i2c_gpio_custom_cleanup(void)
-{
- int i;
-
- for (i = 0; i < nr_devices; i++)
- if (devices[i])
- platform_device_put(devices[i]);
-}
-
-static int __init i2c_gpio_custom_add_one(unsigned int id, unsigned int *params)
-{
- struct platform_device *pdev;
- struct i2c_gpio_platform_data pdata;
- int err;
-
- if (!bus_nump[id])
- return 0;
-
- if (bus_nump[id] < BUS_PARAM_REQUIRED) {
- printk(KERN_ERR PFX "not enough parameters for bus%d\n", id);
- err = -EINVAL;
- goto err;
- }
-
- pdev = platform_device_alloc("i2c-gpio", params[BUS_PARAM_ID]);
- if (!pdev) {
- err = -ENOMEM;
- goto err;
- }
-
- pdata.sda_pin = params[BUS_PARAM_SDA];
- pdata.scl_pin = params[BUS_PARAM_SCL];
- pdata.udelay = params[BUS_PARAM_UDELAY];
- pdata.timeout = params[BUS_PARAM_TIMEOUT];
- pdata.sda_is_open_drain = params[BUS_PARAM_SDA_OD] != 0;
- pdata.scl_is_open_drain = params[BUS_PARAM_SCL_OD] != 0;
- pdata.scl_is_output_only = params[BUS_PARAM_SCL_OO] != 0;
-
- err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
- if (err)
- goto err_put;
-
- err = platform_device_add(pdev);
- if (err)
- goto err_put;
-
- devices[nr_devices++] = pdev;
- return 0;
-
-err_put:
- platform_device_put(pdev);
-err:
- return err;
-}
-
-static int __init i2c_gpio_custom_probe(void)
-{
- int err;
-
- printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
-
- err = i2c_gpio_custom_add_one(0, bus0);
- if (err) goto err;
-
- err = i2c_gpio_custom_add_one(1, bus1);
- if (err) goto err;
-
- err = i2c_gpio_custom_add_one(2, bus2);
- if (err) goto err;
-
- err = i2c_gpio_custom_add_one(3, bus3);
- if (err) goto err;
-
- if (!nr_devices) {
- printk(KERN_ERR PFX "no bus parameter(s) specified\n");
- err = -ENODEV;
- goto err;
- }
-
- return 0;
-
-err:
- i2c_gpio_custom_cleanup();
- return err;
-}
-
-#ifdef MODULE
-static int __init i2c_gpio_custom_init(void)
-{
- return i2c_gpio_custom_probe();
-}
-module_init(i2c_gpio_custom_init);
-
-static void __exit i2c_gpio_custom_exit(void)
-{
- i2c_gpio_custom_cleanup();
-}
-module_exit(i2c_gpio_custom_exit);
-#else
-subsys_initcall(i2c_gpio_custom_probe);
-#endif /* MODULE*/
-
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org >");
-MODULE_DESCRIPTION(DRV_DESC);
-MODULE_VERSION(DRV_VERSION);
diff --git a/package/system/mmc_over_gpio/Makefile b/package/system/mmc_over_gpio/Makefile
deleted file mode 100644
index 62d0ba5b7d..0000000000
--- a/package/system/mmc_over_gpio/Makefile
+++ /dev/null
@@ -1,77 +0,0 @@
-#
-# Copyright (C) 2008 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-
-include $(TOPDIR)/rules.mk
-include $(INCLUDE_DIR)/kernel.mk
-
-PKG_NAME:=mmc-over-gpio
-PKG_RELEASE:=4
-
-include $(INCLUDE_DIR)/package.mk
-
-
-define KernelPackage/mmc-over-gpio
- SUBMENU:=Other modules
- DEPENDS:=@GPIO_SUPPORT +kmod-mmc-spi +kmod-spi-gpio-old +kmod-fs-configfs
- KCONFIG:=CONFIG_GPIOMMC
- TITLE:=MMC/SD card over GPIO support
- FILES:=$(LINUX_DIR)/drivers/mmc/host/gpiommc.ko
- AUTOLOAD:=$(call AutoLoad,93,gpiommc)
- MENU:=1
-endef
-
-define Package/kmod-mmc-over-gpio/config
- menu "Configuration"
- depends on PACKAGE_kmod-mmc-over-gpio
-
- config KMOD_MMC_OVER_GPIO_DI_PIN
- int "GPIO DI (Data-In) pin"
- default 1
-
- config KMOD_MMC_OVER_GPIO_DO_PIN
- int "GPIO DO (Data-Out) pin"
- default 3
-
- config KMOD_MMC_OVER_GPIO_CLK_PIN
- int "GPIO CLK (Clock) pin"
- default 4
-
- config KMOD_MMC_OVER_GPIO_CS_PIN
- int "GPIO CS (Chip-Select) pin"
- default 7
-
- endmenu
-endef
-
-define KernelPackage/mmc-over-gpio/description
- Support for driving an MMC/SD card over GPIO pins via SPI.
-endef
-
-define KernelPackage/mmc-over-gpio/conffiles
-/etc/config/mmc_over_gpio
-endef
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
-endef
-
-define Build/Compile
-endef
-
-define KernelPackage/mmc-over-gpio/install
- $(INSTALL_DIR) $(1)/etc/config
- $(INSTALL_DATA) ./files/mmc_over_gpio.config $(1)/etc/config/mmc_over_gpio
- $(INSTALL_DIR) $(1)/etc/init.d
- $(INSTALL_BIN) ./files/mmc_over_gpio.init $(1)/etc/init.d/mmc_over_gpio
-
- $(SED) 's,@GPIO_DI_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_DI_PIN),g' \
- -e 's,@GPIO_DO_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_DO_PIN),g' \
- -e 's,@GPIO_CLK_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_CLK_PIN),g' \
- -e 's,@GPIO_CS_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_CS_PIN),g' \
- $(1)/etc/config/mmc_over_gpio
-endef
-
-$(eval $(call KernelPackage,mmc-over-gpio))
diff --git a/package/system/mmc_over_gpio/files/mmc_over_gpio.config b/package/system/mmc_over_gpio/files/mmc_over_gpio.config
deleted file mode 100644
index 23f0084857..0000000000
--- a/package/system/mmc_over_gpio/files/mmc_over_gpio.config
+++ /dev/null
@@ -1,8 +0,0 @@
-config 'mmc_over_gpio'
- option 'name' 'default'
- option 'enabled' '0'
- option 'DI_pin' '@GPIO_DI_PIN@'
- option 'DO_pin' '@GPIO_DO_PIN@'
- option 'CLK_pin' '@GPIO_CLK_PIN@'
- option 'CS_pin' '@GPIO_CS_PIN@'
- option 'mode' '0'
diff --git a/package/system/mmc_over_gpio/files/mmc_over_gpio.init b/package/system/mmc_over_gpio/files/mmc_over_gpio.init
deleted file mode 100644
index 121c80398c..0000000000
--- a/package/system/mmc_over_gpio/files/mmc_over_gpio.init
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/bin/sh /etc/rc.common
-# Copyright (C) 2008 OpenWrt.org
-START=90
-
-CONFIGFS_DIR="/config/gpiommc"
-
-# add_device(name, DI_pin, DO_pin, CLK_pin, CS_pin, mode)
-add_device() {
- local dir="$CONFIGFS_DIR/$1"
-
- mkdir -p $dir
- [ $? -eq 0 ] || return 1
- echo $2 > $dir/gpio_data_in
- [ $? -eq 0 ] || return 1
- echo $3 > $dir/gpio_data_out
- [ $? -eq 0 ] || return 1
- echo $4 > $dir/gpio_clock
- [ $? -eq 0 ] || return 1
- echo $5 > $dir/gpio_chipselect
- [ $? -eq 0 ] || return 1
- echo $6 > $dir/spi_mode
- [ $? -eq 0 ] || return 1
- # XXX We have more config options available. Use defaults for now.
-
- echo 1 > $dir/register
- [ $? -eq 0 ] || return 1
-
- return 0
-}
-
-# remove_device(name)
-remove_device() {
- local dir="$CONFIGFS_DIR/$1"
-
- rmdir $dir
-}
-
-mount_configfs() {
- # FIXME: This should probably be done somewhere else.
- mount | grep configfs
- if [ $? -eq 0 ]; then
- # already mounted
- return 0
- fi
- mkdir -p /config
- [ $? -eq 0 ] || return 1
- mount configfs -t configfs /config
- [ $? -eq 0 ] || return 1
-
- return 0
-}
-
-start_service() {
- local section="$1"
- config_get "name" "$section" "name"
- config_get "DI_pin" "$section" "DI_pin"
- config_get "DO_pin" "$section" "DO_pin"
- config_get "CLK_pin" "$section" "CLK_pin"
- config_get "CS_pin" "$section" "CS_pin"
- config_get "mode" "$section" "mode"
- config_get_bool "enabled" "$section" "enabled" '1'
- [ "$enabled" -gt 0 ] && add_device "$name" $DI_pin $DO_pin $CLK_pin $CS_pin $mode &
-}
-
-stop_service() {
- local section="$1"
- config_get "name" "$section" "name"
- remove_device "$name"
-}
-
-start() {
- # Make sure configfs is mounted
- mount_configfs
- [ $? -eq 0 ] || return 1
-
- config_load "mmc_over_gpio"
- config_foreach start_service "mmc_over_gpio"
-}
-
-stop() {
- config_load "mmc_over_gpio"
- config_foreach stop_service "mmc_over_gpio"
-}
diff --git a/package/system/mountd/Makefile b/package/system/mountd/Makefile
new file mode 100644
index 0000000000..10534ccdf4
--- /dev/null
+++ b/package/system/mountd/Makefile
@@ -0,0 +1,47 @@
+# Copyright (C) 2009-2012 OpenWrt.org
+# All rights reserved.
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=mountd
+PKG_VERSION:=0.1
+PKG_RELEASE:=6
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
+PKG_MD5SUM:=b77253ee4321d24d200fffc4f7ca3d15
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/mountd
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=OpenWrt automount daemon
+ DEPENDS:=@USB_SUPPORT +uci +kmod-usb-storage +kmod-fs-autofs4
+ URL:=http://www.openwrt.org
+endef
+
+define Package/mountd/description
+ openwrt automount daemon
+endef
+
+define Package/mountd/conffiles
+/etc/config/mountd
+endef
+
+define Build/Compile
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -I$(PKG_BUILD_DIR)" \
+ LDFLAGS="$(TARGET_LDFLAGS)" \
+ $(MAKE) -C $(PKG_BUILD_DIR)
+endef
+
+define Package/mountd/install
+ $(INSTALL_DIR) $(1)/sbin/ $(1)/etc/config/ $(1)/etc/init.d/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/mountd $(1)/sbin/
+ $(INSTALL_DATA) ./files/mountd.config $(1)/etc/config/mountd
+ $(INSTALL_BIN) ./files/mountd.init $(1)/etc/init.d/mountd
+endef
+
+$(eval $(call BuildPackage,mountd))
diff --git a/package/system/mountd/files/mountd.config b/package/system/mountd/files/mountd.config
new file mode 100644
index 0000000000..5610129501
--- /dev/null
+++ b/package/system/mountd/files/mountd.config
@@ -0,0 +1,3 @@
+config mountd mountd
+ option timeout 60
+ option path /tmp/mounts/
diff --git a/package/system/mountd/files/mountd.init b/package/system/mountd/files/mountd.init
new file mode 100755
index 0000000000..c294c50f5c
--- /dev/null
+++ b/package/system/mountd/files/mountd.init
@@ -0,0 +1,19 @@
+#!/bin/sh /etc/rc.common
+
+START=80
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+SERVICE_PID_FILE=/var/run/mountd.pid
+
+MOUNTD_BIN=/sbin/mountd
+
+start()
+{
+ service_start $MOUNTD_BIN -f
+}
+
+stop()
+{
+ service_stop $MOUNTD_BIN
+}
diff --git a/package/system/mountd/patches/010-uci_rename_history_to_delta.patch b/package/system/mountd/patches/010-uci_rename_history_to_delta.patch
new file mode 100644
index 0000000000..65b2f84343
--- /dev/null
+++ b/package/system/mountd/patches/010-uci_rename_history_to_delta.patch
@@ -0,0 +1,27 @@
+---
+ lib/uci.c | 2 +-
+ lib/ucix.c | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/lib/uci.c
++++ b/lib/uci.c
+@@ -28,7 +28,7 @@ struct uci_package *p = NULL;
+ struct uci_context* uci_init(char *config_file)
+ {
+ struct uci_context *ctx = uci_alloc_context();
+- uci_add_history_path(ctx, "/var/state");
++ uci_add_delta_path(ctx, "/var/state");
+ if(uci_load(ctx, config_file, &p) != UCI_OK)
+ {
+ log_printf("/etc/config/%s is missing or corrupt\n", config_file);
+--- a/lib/ucix.c
++++ b/lib/ucix.c
+@@ -18,7 +18,7 @@ static inline int ucix_get_ptr(struct uc
+ struct uci_context* ucix_init(const char *config_file)
+ {
+ struct uci_context *ctx = uci_alloc_context();
+- uci_add_history_path(ctx, "/var/state");
++ uci_add_delta_path(ctx, "/var/state");
+ if(uci_load(ctx, config_file, NULL) != UCI_OK)
+ {
+ printf("%s/%s is missing or corrupt\n", ctx->savedir, config_file);
diff --git a/package/system/mountd/patches/020-handle_timeout.patch b/package/system/mountd/patches/020-handle_timeout.patch
new file mode 100644
index 0000000000..badf40fe4d
--- /dev/null
+++ b/package/system/mountd/patches/020-handle_timeout.patch
@@ -0,0 +1,32 @@
+--- a/lib/autofs.c
++++ b/lib/autofs.c
+@@ -140,6 +140,7 @@ static int fullread(void *ptr, size_t le
+
+ static int autofs_in(union autofs_v5_packet_union *pkt)
+ {
++ int res;
+ struct pollfd fds[1];
+
+ fds[0].fd = fdout;
+@@ -147,15 +148,19 @@ static int autofs_in(union autofs_v5_pac
+
+ while(1)
+ {
+- if(poll(fds, 2, 1000) == -1)
++ res = poll(fds, 1, -1);
++
++ if (res == -1)
+ {
+ if (errno == EINTR)
+ continue;
+ log_printf("failed while trying to read packet from kernel\n");
+ return -1;
+ }
+- if(fds[0].revents & POLLIN)
++ else if ((res > 0) && (fds[0].revents & POLLIN))
++ {
+ return fullread(pkt, sizeof(*pkt));
++ }
+ }
+ }
+
diff --git a/package/system/mountd/patches/030-ext4_support.patch b/package/system/mountd/patches/030-ext4_support.patch
new file mode 100644
index 0000000000..7bbaf14ac9
--- /dev/null
+++ b/package/system/mountd/patches/030-ext4_support.patch
@@ -0,0 +1,85 @@
+diff -ruN mountd-0.1.orig/include/fs.h mountd-0.1/include/fs.h
+--- mountd-0.1.orig/include/fs.h 2009-10-02 22:57:04.000000000 +0200
++++ mountd-0.1/include/fs.h 2012-07-08 18:42:32.000000000 +0200
+@@ -7,5 +7,6 @@
+ #define EFI 7
+ #define NTFS 8
+ #define EXTENDED 9
++#define EXT4 10
+
+ int detect_fs(char *device);
+diff -ruN mountd-0.1.orig/lib/fs.c mountd-0.1/lib/fs.c
+--- mountd-0.1.orig/lib/fs.c 2009-10-02 23:26:22.000000000 +0200
++++ mountd-0.1/lib/fs.c 2012-07-08 19:28:08.000000000 +0200
+@@ -91,9 +91,14 @@
+ goto out;
+ if(get_le_short(buffer + 56) == 0xEF53)
+ {
+- if((get_le_long(buffer + 96) & 0x0008)
+- || (get_le_long(buffer + 92) & 0x0004))
+- ret = EXT3;
++ if(get_le_long(buffer + 92) & 0x0004)
++ {
++ if ((get_le_long(buffer + 96) < 0x0000040)
++ && (get_le_long(buffer + 100) < 0x0000008))
++ ret = EXT3;
++ else
++ ret = EXT4;
++ }
+ else
+ ret = EXT2;
+ }
+diff -ruN mountd-0.1.orig/lib/mount.c mountd-0.1/lib/mount.c
+--- mountd-0.1.orig/lib/mount.c 2009-10-03 12:54:57.000000000 +0200
++++ mountd-0.1/lib/mount.c 2012-07-08 19:04:29.000000000 +0200
+@@ -53,7 +53,10 @@
+ "EXT3",
+ "FAT",
+ "HFSPLUS",
+- "NTFS"
++ "",
++ "NTFS",
++ "",
++ "EXT4"
+ };
+
+ #define MAX_MOUNTED 32
+@@ -93,7 +96,7 @@
+ ucix_add_option(ctx, mountd, q->serial, "rev", q->rev);
+ snprintf(t, 64, "size%d", atoi(&q->dev[3]));
+ ucix_add_option(ctx, mountd, q->serial, t, q->size);
+- if(q->fs > MBR && q->fs <= NTFS)
++ if(q->fs > MBR && q->fs <= EXT4)
+ {
+ snprintf(t, 64, "fs%d", atoi(&q->dev[3]));
+ ucix_add_option(ctx, mountd, q->serial, t, fs_names[q->fs]);
+@@ -131,7 +134,7 @@
+ {
+ struct mount *mount;
+ char tmp[64], tmp2[64];
+- if(fs <= MBR || fs > NTFS)
++ if(fs <= MBR || fs > EXT4)
+ return;
+ mount = malloc(sizeof(struct mount));
+ INIT_LIST_HEAD(&mount->list);
+@@ -147,7 +150,7 @@
+ mount->mounted = 0;
+ mount->fs = fs;
+ list_add(&mount->list, &mounts);
+- if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= NTFS))
++ if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= EXT4))
+ {
+ log_printf("new mount : %s -> %s (%s)\n", name, dev, fs_names[mount->fs]);
+ snprintf(tmp, 64, "%s%s", uci_path, name);
+@@ -226,6 +229,11 @@
+ log_printf("mount -t vfat -o rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
+ ret = system_printf("mount -t vfat -o rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
+ }
++ if(mount->fs == EXT4)
++ {
++ log_printf("mount -t ext4 -o rw,defaults /dev/%s %s", mount->dev, tmp);
++ ret = system_printf("mount -t ext4 -o rw,defaults /dev/%s %s", mount->dev, tmp);
++ }
+ if(mount->fs == EXT3)
+ {
+ log_printf("mount -t ext3 -o rw,defaults /dev/%s %s", mount->dev, tmp);
diff --git a/package/system/mountd/patches/040-optional-daemonize.patch b/package/system/mountd/patches/040-optional-daemonize.patch
new file mode 100644
index 0000000000..4d159ec668
--- /dev/null
+++ b/package/system/mountd/patches/040-optional-daemonize.patch
@@ -0,0 +1,13 @@
+--- a/main.c
++++ b/main.c
+@@ -13,7 +13,9 @@
+
+ int main(int argc, char *argv[])
+ {
+- daemon(0,0);
++ if ((argc < 2) || strcmp(argv[1], "-f"))
++ daemon(0,0);
++
+ daemonize = 1;
+ log_start();
+ log_printf("Starting OpenWrt (auto)mountd V1\n");
diff --git a/package/system/mtd/Makefile b/package/system/mtd/Makefile
new file mode 100644
index 0000000000..f429128e02
--- /dev/null
+++ b/package/system/mtd/Makefile
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2006-2012 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:=mtd
+PKG_RELEASE:=20
+
+PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)
+STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
+
+PKG_LICENSE:=GPLv2 GPLv2+
+PKG_LICENSE_FILES:=
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/mtd
+ SECTION:=utils
+ CATEGORY:=Base system
+ TITLE:=Update utility for trx firmware images
+endef
+
+define Package/mtd/description
+ This package contains an utility useful to upgrade from other firmware or
+ older OpenWrt releases.
+endef
+
+define Build/Prepare
+ mkdir -p $(PKG_BUILD_DIR)
+ $(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+target=$(firstword $(subst -, ,$(BOARD)))
+
+MAKE_FLAGS += TARGET="$(target)"
+TARGET_CFLAGS := $(TARGET_CFLAGS) -Dtarget_$(target)=1 -Wall
+
+ifdef CONFIG_MTD_REDBOOT_PARTS
+ MAKE_FLAGS += FIS_SUPPORT=1
+ TARGET_CFLAGS += -DFIS_SUPPORT=1
+endif
+
+define Package/mtd/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/mtd $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,mtd))
diff --git a/package/system/mtd/src/Makefile b/package/system/mtd/src/Makefile
new file mode 100644
index 0000000000..4e6aee8eb5
--- /dev/null
+++ b/package/system/mtd/src/Makefile
@@ -0,0 +1,18 @@
+CC = gcc
+CFLAGS += -Wall
+
+obj = mtd.o jffs2.o crc32.o
+obj.seama = seama.o md5.o
+obj.ar71xx = trx.o
+obj.brcm = trx.o
+obj.brcm47xx = $(obj.brcm)
+obj.brcm63xx = imagetag.o
+obj.ramips = $(obj.seama)
+
+ifdef FIS_SUPPORT
+ obj += fis.o
+endif
+
+mtd: $(obj) $(obj.$(TARGET))
+clean:
+ rm -f *.o jffs2
diff --git a/package/system/mtd/src/crc32.c b/package/system/mtd/src/crc32.c
new file mode 100644
index 0000000000..6b1e50c42d
--- /dev/null
+++ b/package/system/mtd/src/crc32.c
@@ -0,0 +1,95 @@
+/*
+ * 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
+ *
+ * Note that we take it "backwards" and put the highest-order term in
+ * the lowest-order bit. The X^32 term is "implied"; the LSB is the
+ * X^31 term, etc. The X^0 term (usually shown as "+1") results in
+ * the MSB being 1
+ *
+ * Note that the usual hardware shift register implementation, which
+ * is what we're using (we're merely optimizing it by doing eight-bit
+ * chunks at a time) shifts bits into the lowest-order term. In our
+ * implementation, that means shifting towards the right. Why do we
+ * do it this way? Because the calculated CRC must be transmitted in
+ * order from highest-order term to lowest-order term. UARTs transmit
+ * characters in order from LSB to MSB. By storing the CRC this way
+ * we hand it to the UART in the order low-byte to high-byte; the UART
+ * sends each low-bit to hight-bit; and the result is transmission bit
+ * by bit from highest- to lowest-order term without requiring any bit
+ * shuffling on our part. Reception works similarly
+ *
+ * The feedback terms table consists of 256, 32-bit entries. Notes
+ *
+ * The table can be generated at runtime if desired; code to do so
+ * is shown later. It might not be obvious, but the feedback
+ * terms simply represent the results of eight shift/xor opera
+ * tions for all combinations of data and CRC register values
+ *
+ * The values must be right-shifted by eight bits by the "updcrc
+ * logic; the shift must be unsigned (bring in zeroes). On some
+ * hardware you could probably optimize the shift in assembler by
+ * using byte-swap instructions
+ * polynomial $edb88320
+ */
+
+#include <stdint.h>
+
+const uint32_t crc32_table[256] = {
+ 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
+};
diff --git a/package/system/mtd/src/crc32.h b/package/system/mtd/src/crc32.h
new file mode 100644
index 0000000000..68f8ee4feb
--- /dev/null
+++ b/package/system/mtd/src/crc32.h
@@ -0,0 +1,26 @@
+#ifndef CRC32_H
+#define CRC32_H
+
+#include <stdint.h>
+
+extern const uint32_t crc32_table[256];
+
+/* Return a 32-bit CRC of the contents of the buffer. */
+
+static inline uint32_t
+crc32(uint32_t val, const void *ss, int len)
+{
+ const unsigned char *s = ss;
+ while (--len >= 0)
+ val = crc32_table[(val ^ *s++) & 0xff] ^ (val >> 8);
+ return val;
+}
+
+static inline unsigned int crc32buf(char *buf, size_t len)
+{
+ return crc32(0xFFFFFFFF, buf, len);
+}
+
+
+
+#endif
diff --git a/package/system/mtd/src/fis.c b/package/system/mtd/src/fis.c
new file mode 100644
index 0000000000..f825f590c9
--- /dev/null
+++ b/package/system/mtd/src/fis.c
@@ -0,0 +1,262 @@
+/*
+ * FIS table updating code for mtd
+ *
+ * Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License v2
+ * as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#include <sys/mman.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include "crc32.h"
+#include "mtd.h"
+#include "fis.h"
+
+struct fis_image_hdr {
+ unsigned char name[16];
+ uint32_t flash_base;
+ uint32_t mem_base;
+ uint32_t size;
+ uint32_t entry_point;
+ uint32_t data_length;
+} __attribute__((packed));
+
+struct fis_image_crc {
+ uint32_t desc;
+ uint32_t file;
+} __attribute__((packed));
+
+struct fis_image_desc {
+ struct fis_image_hdr hdr;
+ char _pad[256 - sizeof(struct fis_image_hdr) - sizeof(struct fis_image_crc)];
+ struct fis_image_crc crc;
+} __attribute__((packed));
+
+static int fis_fd = -1;
+static struct fis_image_desc *fis_desc;
+static int fis_erasesize = 0;
+
+static void
+fis_close(void)
+{
+ if (fis_desc)
+ munmap(fis_desc, fis_erasesize);
+
+ if (fis_fd >= 0)
+ close(fis_fd);
+
+ fis_fd = -1;
+ fis_desc = NULL;
+}
+
+static struct fis_image_desc *
+fis_open(void)
+{
+ struct fis_image_desc *desc;
+
+ if (fis_fd >= 0)
+ fis_close();
+
+ fis_fd = mtd_check_open("FIS directory");
+ if (fis_fd < 0)
+ goto error;
+
+ close(fis_fd);
+ fis_fd = mtd_open("FIS directory", true);
+ if (fis_fd < 0)
+ goto error;
+
+ fis_erasesize = erasesize;
+ desc = mmap(NULL, erasesize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, fis_fd, 0);
+ if (desc == MAP_FAILED)
+ goto error;
+
+ fis_desc = desc;
+ return desc;
+
+error:
+ fis_close();
+ return NULL;
+}
+
+int
+fis_validate(struct fis_part *old, int n_old, struct fis_part *new, int n_new)
+{
+ struct fis_image_desc *desc;
+ void *end;
+ int found = 0;
+ int i;
+
+ desc = fis_open();
+ if (!desc)
+ return -1;
+
+ for (i = 0; i < n_new - 1; i++) {
+ if (!new[i].size) {
+ fprintf(stderr, "FIS error: only the last partition can detect the size automatically\n");
+ i = -1;
+ goto done;
+ }
+ }
+
+ end = desc;
+ end = (char *) end + fis_erasesize;
+ while ((void *) desc < end) {
+ if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff))
+ break;
+
+ for (i = 0; i < n_old; i++) {
+ if (!strncmp((char *) desc->hdr.name, (char *) old[i].name, sizeof(desc->hdr.name))) {
+ found++;
+ goto next;
+ }
+ }
+next:
+ desc++;
+ continue;
+ }
+
+ if (found == n_old)
+ i = 1;
+ else
+ i = -1;
+
+done:
+ fis_close();
+ return i;
+}
+
+int
+fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new)
+{
+ struct fis_image_desc *fisdir = NULL;
+ struct fis_image_desc *redboot = NULL;
+ struct fis_image_desc *first = NULL;
+ struct fis_image_desc *last = NULL;
+ struct fis_image_desc *first_fb = NULL;
+ struct fis_image_desc *last_fb = NULL;
+ struct fis_image_desc *desc;
+ struct fis_part *part;
+ uint32_t offset = 0, size = 0;
+ char *start, *end, *tmp;
+ int i;
+
+ desc = fis_open();
+ if (!desc)
+ return -1;
+
+ if (!quiet)
+ fprintf(stderr, "Updating FIS table... \n");
+
+ start = (char *) desc;
+ end = (char *) desc + fis_erasesize;
+ while ((char *) desc < end) {
+ if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff))
+ break;
+
+ if (!strcmp((char *) desc->hdr.name, "FIS directory"))
+ fisdir = desc;
+
+ if (!strcmp((char *) desc->hdr.name, "RedBoot"))
+ redboot = desc;
+
+ /* update max offset */
+ if (offset < desc->hdr.flash_base)
+ offset = desc->hdr.flash_base;
+
+ for (i = 0; i < n_old; i++) {
+ if (!strncmp((char *) desc->hdr.name, (char *) old[i].name, sizeof(desc->hdr.name))) {
+ last = desc;
+ if (!first)
+ first = desc;
+ break;
+ }
+ }
+ desc++;
+ }
+ desc--;
+
+ first_fb = first;
+ last_fb = last;
+
+ if (first_fb->hdr.flash_base > last_fb->hdr.flash_base) {
+ first_fb = last;
+ last_fb = first;
+ }
+
+ /* determine size of available space */
+ desc = (struct fis_image_desc *) start;
+ while ((char *) desc < end) {
+ if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff))
+ break;
+
+ if (desc->hdr.flash_base > last_fb->hdr.flash_base &&
+ desc->hdr.flash_base < offset)
+ offset = desc->hdr.flash_base;
+
+ desc++;
+ }
+ desc--;
+
+ size = offset - first_fb->hdr.flash_base;
+
+#ifdef notyet
+ desc = first - 1;
+ if (redboot && (desc >= redboot)) {
+ if (first->hdr.flash_base - desc->hdr.size > desc->hdr.flash_base) {
+ int delta = first->hdr.flash_base - desc->hdr.size - desc->hdr.flash_base;
+
+ offset -= delta;
+ size += delta;
+ }
+ }
+#endif
+
+ last++;
+ desc = first + n_new;
+ offset = first_fb->hdr.flash_base;
+
+ if (desc != last) {
+ if (desc > last)
+ tmp = (char *) desc;
+ else
+ tmp = (char *) last;
+
+ memmove(desc, last, end - tmp);
+ if (desc < last) {
+ tmp = end - (last - desc) * sizeof(struct fis_image_desc);
+ memset(tmp, 0xff, tmp - end);
+ }
+ }
+
+ for (part = new, desc = first; desc < first + n_new; desc++, part++) {
+ memset(desc, 0, sizeof(struct fis_image_desc));
+ memcpy(desc->hdr.name, part->name, sizeof(desc->hdr.name));
+ desc->crc.desc = 0;
+ desc->crc.file = 0;
+
+ desc->hdr.flash_base = offset;
+ desc->hdr.mem_base = part->loadaddr;
+ desc->hdr.entry_point = part->loadaddr;
+ desc->hdr.size = (part->size > 0) ? part->size : size;
+ desc->hdr.data_length = desc->hdr.size;
+
+ offset += desc->hdr.size;
+ size -= desc->hdr.size;
+ }
+
+ msync(fis_desc, fis_erasesize, MS_SYNC|MS_INVALIDATE);
+ fis_close();
+
+ return 0;
+}
diff --git a/package/system/mtd/src/fis.h b/package/system/mtd/src/fis.h
new file mode 100644
index 0000000000..bdf1103d8a
--- /dev/null
+++ b/package/system/mtd/src/fis.h
@@ -0,0 +1,14 @@
+#ifndef __FIS_H
+#define __FIS_H
+
+struct fis_part {
+ unsigned char name[16];
+ uint32_t offset;
+ uint32_t loadaddr;
+ uint32_t size;
+};
+
+int fis_validate(struct fis_part *old, int n_old, struct fis_part *new, int n_new);
+int fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new);
+
+#endif
diff --git a/package/system/mtd/src/imagetag.c b/package/system/mtd/src/imagetag.c
new file mode 100644
index 0000000000..a53c17a703
--- /dev/null
+++ b/package/system/mtd/src/imagetag.c
@@ -0,0 +1,316 @@
+/*
+ * imagetag.c
+ *
+ * Copyright (C) 2005 Mike Baker
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ * Copyrigth (C) 2010 Daniel Dickinson <openwrt@cshore.neomailbox.net>
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/ioctl.h>
+#include <mtd/mtd-user.h>
+#include <linux/bcm963xx_tag.h>
+
+#include "mtd.h"
+#include "crc32.h"
+
+ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+
+#define CRC_START 0xFFFFFFFF
+
+static uint32_t strntoul(char *str, char **endptr, int base, size_t len) {
+ char *newstr;
+ uint32_t res = 0;
+
+ newstr = calloc(len + 1, sizeof(char));
+ if (newstr) {
+ strncpy(newstr, str, len);
+ res = strtoul(newstr, endptr, base);
+ free(newstr);
+ }
+ return res;
+}
+
+uint32_t compute_crc32(uint32_t crc, off_t start, size_t compute_len, int fd)
+{
+ uint8_t readbuf[1024];
+ ssize_t res;
+ off_t offset = start;
+
+ /* Read a buffer's worth of bytes */
+ while (fd && (compute_len >= sizeof(readbuf))) {
+ res = pread(fd, readbuf, sizeof(readbuf), offset);
+ crc = crc32(crc, readbuf, res);
+ compute_len = compute_len - res;
+ offset += res;
+ }
+
+ /* Less than buffer-size bytes remains, read compute_len bytes */
+ if (fd && (compute_len > 0)) {
+ res = pread(fd, readbuf, compute_len, offset);
+ crc = crc32(crc, readbuf, res);
+ }
+
+ return crc;
+}
+
+int
+trx_fixup(int fd, const char *name)
+{
+ struct mtd_info_user mtdInfo;
+ unsigned long len;
+ void *ptr, *scan;
+ int bfd;
+ struct bcm_tag *tag;
+ ssize_t res;
+ uint32_t cfelen, imagelen, imagestart, rootfslen;
+ uint32_t imagecrc, rootfscrc, headercrc;
+ uint32_t offset = 0;
+ cfelen = imagelen = imagestart = imagecrc = rootfscrc = headercrc = rootfslen = 0;
+
+
+ if (ioctl(fd, MEMGETINFO, &mtdInfo) < 0) {
+ fprintf(stderr, "Failed to get mtd info\n");
+ goto err;
+ }
+
+ len = mtdInfo.size;
+ if (mtdInfo.size <= 0) {
+ fprintf(stderr, "Invalid MTD device size\n");
+ goto err;
+ }
+
+ bfd = mtd_open(name, true);
+ ptr = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, bfd, 0);
+ if (!ptr || (ptr == (void *) -1)) {
+ perror("mmap");
+ goto err1;
+ }
+
+ tag = (struct bcm_tag *) (ptr);
+
+ cfelen = strntoul(&tag->cfe_length[0], NULL, 10, IMAGE_LEN);
+ if (cfelen) {
+ fprintf(stderr, "Non-zero CFE length. This is currently unsupported.\n");
+ exit(1);
+ }
+
+ headercrc = compute_crc32(CRC_START, offset, offsetof(struct bcm_tag, header_crc), fd);
+ if (headercrc != *(uint32_t *)(&tag->header_crc)) {
+ fprintf(stderr, "Tag verify failed. This may not be a valid image.\n");
+ exit(1);
+ }
+
+ sprintf(&tag->root_length[0], "%u", 0);
+ strncpy(&tag->total_length[0], &tag->kernel_length[0], IMAGE_LEN);
+
+ imagestart = sizeof(tag);
+ memcpy(&tag->image_crc, &tag->kernel_crc, sizeof(uint32_t));
+ memcpy(&tag->fskernel_crc, &tag->kernel_crc, sizeof(uint32_t));
+ rootfscrc = CRC_START;
+ memcpy(&tag->rootfs_crc, &rootfscrc, sizeof(uint32_t));
+ headercrc = crc32(CRC_START, tag, offsetof(struct bcm_tag, header_crc));
+ memcpy(&tag->header_crc, &headercrc, sizeof(uint32_t));
+
+ msync(ptr, sizeof(struct bcm_tag), MS_SYNC|MS_INVALIDATE);
+ munmap(ptr, len);
+ close(bfd);
+ return 0;
+
+err1:
+ close(bfd);
+err:
+ fprintf(stderr, "Error fixing up imagetag header\n");
+ return -1;
+}
+
+
+int
+trx_check(int imagefd, const char *mtd, char *buf, int *len)
+{
+ struct bcm_tag *tag = (const struct bcm_tag *) buf;
+ int fd;
+ uint32_t headerCRC;
+ uint32_t imageLen;
+
+ if (strcmp(mtd, "linux") != 0)
+ return 1;
+
+ *len = read(imagefd, buf, sizeof(struct bcm_tag));
+ if (*len < sizeof(struct bcm_tag)) {
+ fprintf(stdout, "Could not get image header, file too small (%d bytes)\n", *len);
+ return 0;
+ }
+ headerCRC = crc32buf(buf, offsetof(struct bcm_tag, header_crc));
+ if (*(uint32_t *)(&tag->header_crc) != headerCRC) {
+
+ if (quiet < 2) {
+ fprintf(stderr, "Bad header CRC got %08x, calculated %08x\n",
+ *(uint32_t *)(&tag->header_crc), headerCRC);
+ fprintf(stderr, "This is not the correct file format; refusing to flash.\n"
+ "Please specify the correct file or use -f to force.\n");
+ }
+ return 0;
+ }
+
+ /* check if image fits to mtd device */
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ imageLen = strntoul(&tag->total_length[0], NULL, 10, IMAGE_LEN);
+
+ if(mtdsize < imageLen) {
+ fprintf(stderr, "Image too big for partition: %s\n", mtd);
+ close(fd);
+ return 0;
+ }
+
+ close(fd);
+ return 1;
+}
+
+int
+mtd_fixtrx(const char *mtd, size_t offset)
+{
+ int fd;
+ struct bcm_tag *tag;
+ char *buf;
+ ssize_t res;
+ size_t block_offset;
+ uint32_t cfelen, imagelen, imagestart, rootfslen;
+ uint32_t imagecrc, rootfscrc, headercrc;
+ cfelen = imagelen = imagestart = imagecrc = rootfscrc = headercrc = rootfslen = 0;
+
+ if (quiet < 2)
+ fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", mtd, offset);
+
+ block_offset = offset & ~(erasesize - 1);
+ offset -= block_offset;
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (block_offset + erasesize > mtdsize) {
+ fprintf(stderr, "Offset too large, device size 0x%x\n", mtdsize);
+ exit(1);
+ }
+
+ buf = malloc(erasesize);
+ if (!buf) {
+ perror("malloc");
+ exit(1);
+ }
+
+ res = pread(fd, buf, erasesize, block_offset);
+ if (res != erasesize) {
+ perror("pread");
+ exit(1);
+ }
+
+ tag = (struct bcm_tag *) (buf + offset);
+
+ cfelen = strntoul(tag->cfe_length, NULL, 10, IMAGE_LEN);
+ if (cfelen) {
+ fprintf(stderr, "Non-zero CFE length. This is currently unsupported.\n");
+ exit(1);
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "Verifying we actually have an imagetag.\n");
+ }
+
+ headercrc = compute_crc32(CRC_START, offset, offsetof(struct bcm_tag, header_crc), fd);
+ if (headercrc != *(uint32_t *)(&tag->header_crc)) {
+ fprintf(stderr, "Tag verify failed. This may not be a valid image.\n");
+ exit(1);
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "Checking current fixed status.\n");
+ }
+
+ rootfslen = strntoul(&tag->root_length[0], NULL, 10, IMAGE_LEN);
+ if (rootfslen == 0) {
+ if (quiet < 2)
+ fprintf(stderr, "Header already fixed, exiting\n");
+ close(fd);
+ return 0;
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "Setting root length to 0.\n");
+ }
+
+ sprintf(&tag->root_length[0], "%u", 0);
+ strncpy(&tag->total_length[0], &tag->kernel_length[0], IMAGE_LEN);
+
+ if (quiet < 2) {
+ fprintf(stderr, "Recalculating CRCs.\n");
+ }
+
+ imagestart = sizeof(tag);
+ memcpy(&tag->image_crc, &tag->kernel_crc, sizeof(uint32_t));
+ memcpy(&tag->fskernel_crc, &tag->kernel_crc, sizeof(uint32_t));
+ rootfscrc = CRC_START;
+ memcpy(&tag->rootfs_crc, &rootfscrc, sizeof(uint32_t));
+ headercrc = crc32(CRC_START, tag, offsetof(struct bcm_tag, header_crc));
+ memcpy(&tag->header_crc, &headercrc, sizeof(uint32_t));
+
+ if (quiet < 2) {
+ fprintf(stderr, "Erasing imagetag block\n");
+ }
+
+ if (mtd_erase_block(fd, block_offset)) {
+ fprintf(stderr, "Can't erase block at 0x%x (%s)\n", block_offset, strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "New image crc32: 0x%x, rewriting block\n",
+ *(uint32_t *)(&tag->image_crc));
+ fprintf(stderr, "New header crc32: 0x%x, rewriting block\n", headercrc);
+ }
+
+ if (pwrite(fd, buf, erasesize, block_offset) != erasesize) {
+ fprintf(stderr, "Error writing block (%s)\n", strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Done.\n");
+
+ close (fd);
+ sync();
+ return 0;
+
+}
diff --git a/package/system/mtd/src/jffs2.c b/package/system/mtd/src/jffs2.c
new file mode 100644
index 0000000000..2a83bd47f4
--- /dev/null
+++ b/package/system/mtd/src/jffs2.c
@@ -0,0 +1,357 @@
+/*
+ * jffs2 on-disk structure generator for mtd
+ *
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License v2
+ * as published by the Free Software Foundation.
+ *
+ * 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.
+ * Based on:
+ * JFFS2 -- Journalling Flash File System, Version 2.
+ * Copyright © 2001-2007 Red Hat, Inc.
+ * Created by David Woodhouse <dwmw2@infradead.org>
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <endian.h>
+#include "jffs2.h"
+#include "crc32.h"
+#include "mtd.h"
+
+#define PAD(x) (((x)+3)&~3)
+
+#if BYTE_ORDER == BIG_ENDIAN
+# define CLEANMARKER "\x19\x85\x20\x03\x00\x00\x00\x0c\xf0\x60\xdc\x98"
+#else
+# define CLEANMARKER "\x85\x19\x03\x20\x0c\x00\x00\x00\xb1\xb0\x1e\xe4"
+#endif
+
+static int last_ino = 0;
+static int last_version = 0;
+static char *buf = NULL;
+static int ofs = 0;
+static int outfd = -1;
+static int mtdofs = 0;
+static int target_ino = 0;
+
+static void prep_eraseblock(void);
+
+static void pad(int size)
+{
+ if ((ofs % size == 0) && (ofs < erasesize))
+ return;
+
+ if (ofs < erasesize) {
+ memset(buf + ofs, 0xff, (size - (ofs % size)));
+ ofs += (size - (ofs % size));
+ }
+ ofs = ofs % erasesize;
+ if (ofs == 0) {
+ mtd_erase_block(outfd, mtdofs);
+ write(outfd, buf, erasesize);
+ mtdofs += erasesize;
+ }
+}
+
+static inline int rbytes(void)
+{
+ return erasesize - (ofs % erasesize);
+}
+
+static inline void add_data(char *ptr, int len)
+{
+ if (ofs + len > erasesize) {
+ pad(erasesize);
+ prep_eraseblock();
+ }
+ memcpy(buf + ofs, ptr, len);
+ ofs += len;
+}
+
+static void prep_eraseblock(void)
+{
+ if (ofs > 0)
+ return;
+
+ add_data(CLEANMARKER, sizeof(CLEANMARKER) - 1);
+}
+
+static int add_dirent(const char *name, const char type, int parent)
+{
+ struct jffs2_raw_dirent *de;
+
+ if (ofs - erasesize < sizeof(struct jffs2_raw_dirent) + strlen(name))
+ pad(erasesize);
+
+ prep_eraseblock();
+ last_ino++;
+ memset(buf + ofs, 0, sizeof(struct jffs2_raw_dirent));
+ de = (struct jffs2_raw_dirent *) (buf + ofs);
+
+ de->magic = JFFS2_MAGIC_BITMASK;
+ de->nodetype = JFFS2_NODETYPE_DIRENT;
+ de->type = type;
+ de->name_crc = crc32(0, name, strlen(name));
+ de->ino = last_ino++;
+ de->pino = parent;
+ de->totlen = sizeof(*de) + strlen(name);
+ de->hdr_crc = crc32(0, (void *) de, sizeof(struct jffs2_unknown_node) - 4);
+ de->version = last_version++;
+ de->mctime = 0;
+ de->nsize = strlen(name);
+ de->node_crc = crc32(0, (void *) de, sizeof(*de) - 8);
+ memcpy(de->name, name, strlen(name));
+
+ ofs += sizeof(struct jffs2_raw_dirent) + de->nsize;
+ pad(4);
+
+ return de->ino;
+}
+
+static int add_dir(const char *name, int parent)
+{
+ struct jffs2_raw_inode ri;
+ int inode;
+
+ inode = add_dirent(name, IFTODT(S_IFDIR), parent);
+
+ if (rbytes() < sizeof(ri))
+ pad(erasesize);
+ prep_eraseblock();
+
+ memset(&ri, 0, sizeof(ri));
+ ri.magic = JFFS2_MAGIC_BITMASK;
+ ri.nodetype = JFFS2_NODETYPE_INODE;
+ ri.totlen = sizeof(ri);
+ ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node) - 4);
+
+ ri.ino = inode;
+ ri.mode = S_IFDIR | 0755;
+ ri.uid = ri.gid = 0;
+ ri.atime = ri.ctime = ri.mtime = 0;
+ ri.isize = ri.csize = ri.dsize = 0;
+ ri.version = 1;
+ ri.node_crc = crc32(0, &ri, sizeof(ri) - 8);
+ ri.data_crc = 0;
+
+ add_data((char *) &ri, sizeof(ri));
+ pad(4);
+ return inode;
+}
+
+static void add_file(const char *name, int parent)
+{
+ int inode, f_offset = 0, fd;
+ struct jffs2_raw_inode ri;
+ struct stat st;
+ char wbuf[4096];
+ const char *fname;
+
+ if (stat(name, &st)) {
+ fprintf(stderr, "File %s does not exist\n", name);
+ return;
+ }
+
+ fname = strrchr(name, '/');
+ if (fname)
+ fname++;
+ else
+ fname = name;
+
+ inode = add_dirent(fname, IFTODT(S_IFREG), parent);
+ memset(&ri, 0, sizeof(ri));
+ ri.magic = JFFS2_MAGIC_BITMASK;
+ ri.nodetype = JFFS2_NODETYPE_INODE;
+
+ ri.ino = inode;
+ ri.mode = st.st_mode;
+ ri.uid = ri.gid = 0;
+ ri.atime = st.st_atime;
+ ri.ctime = st.st_ctime;
+ ri.mtime = st.st_mtime;
+ ri.isize = st.st_size;
+ ri.compr = 0;
+ ri.usercompr = 0;
+
+ fd = open(name, 0);
+ if (fd < 0) {
+ fprintf(stderr, "File %s does not exist\n", name);
+ return;
+ }
+
+ for (;;) {
+ int len = 0;
+
+ for (;;) {
+ len = rbytes() - sizeof(ri);
+ if (len > 128)
+ break;
+
+ pad(erasesize);
+ prep_eraseblock();
+ }
+
+ if (len > sizeof(wbuf))
+ len = sizeof(wbuf);
+
+ len = read(fd, wbuf, len);
+ if (len <= 0)
+ break;
+
+ ri.totlen = sizeof(ri) + len;
+ ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node) - 4);
+ ri.version = ++last_version;
+ ri.offset = f_offset;
+ ri.csize = ri.dsize = len;
+ ri.node_crc = crc32(0, &ri, sizeof(ri) - 8);
+ ri.data_crc = crc32(0, wbuf, len);
+ f_offset += len;
+ add_data((char *) &ri, sizeof(ri));
+ add_data(wbuf, len);
+ pad(4);
+ prep_eraseblock();
+ }
+
+ close(fd);
+}
+
+int mtd_replace_jffs2(const char *mtd, int fd, int ofs, const char *filename)
+{
+ outfd = fd;
+ mtdofs = ofs;
+
+ buf = malloc(erasesize);
+ target_ino = 1;
+ if (!last_ino)
+ last_ino = 1;
+ add_file(filename, target_ino);
+ pad(erasesize);
+
+ /* add eof marker, pad to eraseblock size and write the data */
+ add_data(JFFS2_EOF, sizeof(JFFS2_EOF) - 1);
+ pad(erasesize);
+ free(buf);
+
+ return (mtdofs - ofs);
+}
+
+void mtd_parse_jffs2data(const char *buf, const char *dir)
+{
+ struct jffs2_unknown_node *node = (struct jffs2_unknown_node *) buf;
+ unsigned int ofs = 0;
+
+ while (ofs < erasesize) {
+ node = (struct jffs2_unknown_node *) (buf + ofs);
+ if (node->magic != 0x1985)
+ break;
+
+ ofs += PAD(node->totlen);
+ if (node->nodetype == JFFS2_NODETYPE_DIRENT) {
+ struct jffs2_raw_dirent *de = (struct jffs2_raw_dirent *) node;
+
+ /* is this the right directory name and is it a subdirectory of / */
+ if (*dir && (de->pino == 1) && !strncmp((char *) de->name, dir, de->nsize))
+ target_ino = de->ino;
+
+ /* store the last inode and version numbers for adding extra files */
+ if (last_ino < de->ino)
+ last_ino = de->ino;
+ if (last_version < de->version)
+ last_version = de->version;
+ }
+ }
+}
+
+int mtd_write_jffs2(const char *mtd, const char *filename, const char *dir)
+{
+ int err = -1, fdeof = 0;
+
+ outfd = mtd_check_open(mtd);
+ if (outfd < 0)
+ return -1;
+
+ if (quiet < 2)
+ fprintf(stderr, "Appending %s to jffs2 partition %s\n", filename, mtd);
+
+ buf = malloc(erasesize);
+ if (!buf) {
+ fprintf(stderr, "Out of memory!\n");
+ goto done;
+ }
+
+ if (!*dir)
+ target_ino = 1;
+
+ /* parse the structure of the jffs2 first
+ * locate the directory that the file is going to be placed in */
+ for(;;) {
+ struct jffs2_unknown_node *node = (struct jffs2_unknown_node *) buf;
+
+ if (read(outfd, buf, erasesize) != erasesize) {
+ fdeof = 1;
+ break;
+ }
+ mtdofs += erasesize;
+
+ if (node->magic == 0x8519) {
+ fprintf(stderr, "Error: wrong endianness filesystem\n");
+ goto done;
+ }
+
+ /* assume no magic == end of filesystem
+ * the filesystem will probably end with be32(0xdeadc0de) */
+ if (node->magic != 0x1985)
+ break;
+
+ mtd_parse_jffs2data(buf, dir);
+ }
+
+ if (fdeof) {
+ fprintf(stderr, "Error: No room for additional data\n");
+ goto done;
+ }
+
+ /* jump back one eraseblock */
+ mtdofs -= erasesize;
+ lseek(outfd, mtdofs, SEEK_SET);
+
+ ofs = 0;
+
+ if (!last_ino)
+ last_ino = 1;
+
+ if (!target_ino)
+ target_ino = add_dir(dir, 1);
+
+ add_file(filename, target_ino);
+ pad(erasesize);
+
+ /* add eof marker, pad to eraseblock size and write the data */
+ add_data(JFFS2_EOF, sizeof(JFFS2_EOF) - 1);
+ pad(erasesize);
+
+ err = 0;
+
+ if (trx_fixup) {
+ trx_fixup(outfd, mtd);
+ }
+
+done:
+ close(outfd);
+ if (buf)
+ free(buf);
+
+ return err;
+}
diff --git a/package/system/mtd/src/jffs2.h b/package/system/mtd/src/jffs2.h
new file mode 100644
index 0000000000..858e77a017
--- /dev/null
+++ b/package/system/mtd/src/jffs2.h
@@ -0,0 +1,216 @@
+/*
+ * JFFS2 -- Journalling Flash File System, Version 2.
+ *
+ * Copyright (C) 2001-2003 Red Hat, Inc.
+ *
+ * Created by David Woodhouse <dwmw2@infradead.org>
+ *
+ * For licensing information, see the file 'LICENCE' in the
+ * jffs2 directory.
+ *
+ *
+ */
+
+#ifndef __LINUX_JFFS2_H__
+#define __LINUX_JFFS2_H__
+
+#define JFFS2_SUPER_MAGIC 0x72b6
+
+/* You must include something which defines the C99 uintXX_t types.
+ We don't do it from here because this file is used in too many
+ different environments. */
+
+/* Values we may expect to find in the 'magic' field */
+#define JFFS2_OLD_MAGIC_BITMASK 0x1984
+#define JFFS2_MAGIC_BITMASK 0x1985
+#define KSAMTIB_CIGAM_2SFFJ 0x8519 /* For detecting wrong-endian fs */
+#define JFFS2_EMPTY_BITMASK 0xffff
+#define JFFS2_DIRTY_BITMASK 0x0000
+
+/* Summary node MAGIC marker */
+#define JFFS2_SUM_MAGIC 0x02851885
+
+/* We only allow a single char for length, and 0xFF is empty flash so
+ we don't want it confused with a real length. Hence max 254.
+*/
+#define JFFS2_MAX_NAME_LEN 254
+
+/* How small can we sensibly write nodes? */
+#define JFFS2_MIN_DATA_LEN 128
+
+#define JFFS2_COMPR_NONE 0x00
+#define JFFS2_COMPR_ZERO 0x01
+#define JFFS2_COMPR_RTIME 0x02
+#define JFFS2_COMPR_RUBINMIPS 0x03
+#define JFFS2_COMPR_COPY 0x04
+#define JFFS2_COMPR_DYNRUBIN 0x05
+#define JFFS2_COMPR_ZLIB 0x06
+/* Compatibility flags. */
+#define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */
+#define JFFS2_NODE_ACCURATE 0x2000
+/* INCOMPAT: Fail to mount the filesystem */
+#define JFFS2_FEATURE_INCOMPAT 0xc000
+/* ROCOMPAT: Mount read-only */
+#define JFFS2_FEATURE_ROCOMPAT 0x8000
+/* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */
+#define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
+/* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */
+#define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
+
+#define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
+#define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
+#define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
+#define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
+
+#define JFFS2_NODETYPE_SUMMARY (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 6)
+
+#define JFFS2_NODETYPE_XATTR (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 8)
+#define JFFS2_NODETYPE_XREF (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 9)
+
+/* XATTR Related */
+#define JFFS2_XPREFIX_USER 1 /* for "user." */
+#define JFFS2_XPREFIX_SECURITY 2 /* for "security." */
+#define JFFS2_XPREFIX_ACL_ACCESS 3 /* for "system.posix_acl_access" */
+#define JFFS2_XPREFIX_ACL_DEFAULT 4 /* for "system.posix_acl_default" */
+#define JFFS2_XPREFIX_TRUSTED 5 /* for "trusted.*" */
+
+#define JFFS2_ACL_VERSION 0x0001
+
+// Maybe later...
+//#define JFFS2_NODETYPE_CHECKPOINT (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
+//#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
+
+
+#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at
+ mount time, don't wait for it to
+ happen later */
+#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
+ compression type */
+
+
+/* These can go once we've made sure we've caught all uses without
+ byteswapping */
+
+typedef uint32_t jint32_t;
+
+typedef uint32_t jmode_t;
+
+typedef uint16_t jint16_t;
+
+struct jffs2_unknown_node
+{
+ /* All start like this */
+ jint16_t magic;
+ jint16_t nodetype;
+ jint32_t totlen; /* So we can skip over nodes we don't grok */
+ jint32_t hdr_crc;
+};
+
+struct jffs2_raw_dirent
+{
+ jint16_t magic;
+ jint16_t nodetype; /* == JFFS2_NODETYPE_DIRENT */
+ jint32_t totlen;
+ jint32_t hdr_crc;
+ jint32_t pino;
+ jint32_t version;
+ jint32_t ino; /* == zero for unlink */
+ jint32_t mctime;
+ uint8_t nsize;
+ uint8_t type;
+ uint8_t unused[2];
+ jint32_t node_crc;
+ jint32_t name_crc;
+ uint8_t name[0];
+};
+
+/* The JFFS2 raw inode structure: Used for storage on physical media. */
+/* The uid, gid, atime, mtime and ctime members could be longer, but
+ are left like this for space efficiency. If and when people decide
+ they really need them extended, it's simple enough to add support for
+ a new type of raw node.
+*/
+struct jffs2_raw_inode
+{
+ jint16_t magic; /* A constant magic number. */
+ jint16_t nodetype; /* == JFFS2_NODETYPE_INODE */
+ jint32_t totlen; /* Total length of this node (inc data, etc.) */
+ jint32_t hdr_crc;
+ jint32_t ino; /* Inode number. */
+ jint32_t version; /* Version number. */
+ jmode_t mode; /* The file's type or mode. */
+ jint16_t uid; /* The file's owner. */
+ jint16_t gid; /* The file's group. */
+ jint32_t isize; /* Total resultant size of this inode (used for truncations) */
+ jint32_t atime; /* Last access time. */
+ jint32_t mtime; /* Last modification time. */
+ jint32_t ctime; /* Change time. */
+ jint32_t offset; /* Where to begin to write. */
+ jint32_t csize; /* (Compressed) data size */
+ jint32_t dsize; /* Size of the node's data. (after decompression) */
+ uint8_t compr; /* Compression algorithm used */
+ uint8_t usercompr; /* Compression algorithm requested by the user */
+ jint16_t flags; /* See JFFS2_INO_FLAG_* */
+ jint32_t data_crc; /* CRC for the (compressed) data. */
+ jint32_t node_crc; /* CRC for the raw inode (excluding data) */
+ uint8_t data[0];
+};
+
+struct jffs2_raw_xattr {
+ jint16_t magic;
+ jint16_t nodetype; /* = JFFS2_NODETYPE_XATTR */
+ jint32_t totlen;
+ jint32_t hdr_crc;
+ jint32_t xid; /* XATTR identifier number */
+ jint32_t version;
+ uint8_t xprefix;
+ uint8_t name_len;
+ jint16_t value_len;
+ jint32_t data_crc;
+ jint32_t node_crc;
+ uint8_t data[0];
+} __attribute__((packed));
+
+struct jffs2_raw_xref
+{
+ jint16_t magic;
+ jint16_t nodetype; /* = JFFS2_NODETYPE_XREF */
+ jint32_t totlen;
+ jint32_t hdr_crc;
+ jint32_t ino; /* inode number */
+ jint32_t xid; /* XATTR identifier number */
+ jint32_t xseqno; /* xref sequencial number */
+ jint32_t node_crc;
+} __attribute__((packed));
+
+struct jffs2_raw_summary
+{
+ jint16_t magic;
+ jint16_t nodetype; /* = JFFS2_NODETYPE_SUMMARY */
+ jint32_t totlen;
+ jint32_t hdr_crc;
+ jint32_t sum_num; /* number of sum entries*/
+ jint32_t cln_mkr; /* clean marker size, 0 = no cleanmarker */
+ jint32_t padded; /* sum of the size of padding nodes */
+ jint32_t sum_crc; /* summary information crc */
+ jint32_t node_crc; /* node crc */
+ jint32_t sum[0]; /* inode summary info */
+};
+
+union jffs2_node_union
+{
+ struct jffs2_raw_inode i;
+ struct jffs2_raw_dirent d;
+ struct jffs2_raw_xattr x;
+ struct jffs2_raw_xref r;
+ struct jffs2_raw_summary s;
+ struct jffs2_unknown_node u;
+};
+
+/* Data payload for device nodes. */
+union jffs2_device_node {
+ jint16_t old;
+ jint32_t new;
+};
+
+#endif /* __LINUX_JFFS2_H__ */
diff --git a/package/system/mtd/src/md5.c b/package/system/mtd/src/md5.c
new file mode 100644
index 0000000000..2039760383
--- /dev/null
+++ b/package/system/mtd/src/md5.c
@@ -0,0 +1,307 @@
+
+
+/*
+ ***********************************************************************
+ ** md5.c -- the source code for MD5 routines **
+ ** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
+ ** Created: 2/17/90 RLR **
+ ** Revised: 1/91 SRD,AJ,BSK,JT Reference C ver., 7/10 constant corr. **
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
+ ** **
+ ** License to copy and use this software is granted provided that **
+ ** it is identified as the "RSA Data Security, Inc. MD5 Message- **
+ ** Digest Algorithm" in all material mentioning or referencing this **
+ ** software or this function. **
+ ** **
+ ** License is also granted to make and use derivative works **
+ ** provided that such works are identified as "derived from the RSA **
+ ** Data Security, Inc. MD5 Message-Digest Algorithm" in all **
+ ** material mentioning or referencing the derived work. **
+ ** **
+ ** RSA Data Security, Inc. makes no representations concerning **
+ ** either the merchantability of this software or the suitability **
+ ** of this software for any particular purpose. It is provided "as **
+ ** is" without express or implied warranty of any kind. **
+ ** **
+ ** These notices must be retained in any copies of any part of this **
+ ** documentation and/or software. **
+ ***********************************************************************
+ */
+
+#include <string.h>
+#include "md5.h"
+
+/*
+ ***********************************************************************
+ ** Message-digest routines: **
+ ** To form the message digest for a message M **
+ ** (1) Initialize a context buffer mdContext using MD5_Init **
+ ** (2) Call MD5_Update on mdContext and M **
+ ** (3) Call MD5_Final on mdContext **
+ ** The message digest is now in mdContext->digest[0...15] **
+ ***********************************************************************
+ */
+
+/* forward declaration */
+static void Transform ();
+
+static unsigned char PADDING[64] = {
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/* F, G, H and I are basic MD5 functions */
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
+
+/* ROTATE_LEFT rotates x left n bits */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
+/* Rotation is separate from addition to prevent recomputation */
+#define FF(a, b, c, d, x, s, ac) \
+ {(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define GG(a, b, c, d, x, s, ac) \
+ {(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define HH(a, b, c, d, x, s, ac) \
+ {(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define II(a, b, c, d, x, s, ac) \
+ {(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+
+#ifdef __STDC__
+#define UL(x) x##U
+#else
+#define UL(x) x
+#endif
+
+/* The routine MD5_Init initializes the message-digest context
+ mdContext. All fields are set to zero.
+ */
+void MD5_Init (mdContext)
+MD5_CTX *mdContext;
+{
+ mdContext->i[0] = mdContext->i[1] = (UINT4)0;
+
+ /* Load magic initialization constants.
+ */
+ mdContext->buf[0] = (UINT4)0x67452301;
+ mdContext->buf[1] = (UINT4)0xefcdab89;
+ mdContext->buf[2] = (UINT4)0x98badcfe;
+ mdContext->buf[3] = (UINT4)0x10325476;
+}
+
+/* The routine MD5Update updates the message-digest context to
+ account for the presence of each of the characters inBuf[0..inLen-1]
+ in the message whose digest is being computed.
+ */
+void MD5_Update (mdContext, inBuf, inLen)
+MD5_CTX *mdContext;
+unsigned char *inBuf;
+unsigned int inLen;
+{
+ UINT4 in[16];
+ int mdi;
+ unsigned int i, ii;
+
+ /* compute number of bytes mod 64 */
+ mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
+
+ /* update number of bits */
+ if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0])
+ mdContext->i[1]++;
+ mdContext->i[0] += ((UINT4)inLen << 3);
+ mdContext->i[1] += ((UINT4)inLen >> 29);
+
+ while (inLen--) {
+ /* add new character to buffer, increment mdi */
+ mdContext->in[mdi++] = *inBuf++;
+
+ /* transform if necessary */
+ if (mdi == 0x40) {
+ for (i = 0, ii = 0; i < 16; i++, ii += 4)
+ in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
+ (((UINT4)mdContext->in[ii+2]) << 16) |
+ (((UINT4)mdContext->in[ii+1]) << 8) |
+ ((UINT4)mdContext->in[ii]);
+ Transform (mdContext->buf, in);
+ mdi = 0;
+ }
+ }
+}
+
+/* The routine MD5Final terminates the message-digest computation and
+ ends with the desired message digest in mdContext->digest[0...15].
+ */
+void MD5_Final (hash, mdContext)
+unsigned char hash[];
+MD5_CTX *mdContext;
+{
+ UINT4 in[16];
+ int mdi;
+ unsigned int i, ii;
+ unsigned int padLen;
+
+ /* save number of bits */
+ in[14] = mdContext->i[0];
+ in[15] = mdContext->i[1];
+
+ /* compute number of bytes mod 64 */
+ mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
+
+ /* pad out to 56 mod 64 */
+ padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
+ MD5_Update (mdContext, PADDING, padLen);
+
+ /* append length in bits and transform */
+ for (i = 0, ii = 0; i < 14; i++, ii += 4)
+ in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
+ (((UINT4)mdContext->in[ii+2]) << 16) |
+ (((UINT4)mdContext->in[ii+1]) << 8) |
+ ((UINT4)mdContext->in[ii]);
+ Transform (mdContext->buf, in);
+
+ /* store buffer in digest */
+ for (i = 0, ii = 0; i < 4; i++, ii += 4) {
+ mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
+ mdContext->digest[ii+1] =
+ (unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
+ mdContext->digest[ii+2] =
+ (unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
+ mdContext->digest[ii+3] =
+ (unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
+ }
+ memcpy(hash, mdContext->digest, 16);
+}
+
+/* Basic MD5 step. Transforms buf based on in.
+ */
+static void Transform (buf, in)
+UINT4 *buf;
+UINT4 *in;
+{
+ UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
+
+ /* Round 1 */
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+ FF ( a, b, c, d, in[ 0], S11, UL(3614090360)); /* 1 */
+ FF ( d, a, b, c, in[ 1], S12, UL(3905402710)); /* 2 */
+ FF ( c, d, a, b, in[ 2], S13, UL( 606105819)); /* 3 */
+ FF ( b, c, d, a, in[ 3], S14, UL(3250441966)); /* 4 */
+ FF ( a, b, c, d, in[ 4], S11, UL(4118548399)); /* 5 */
+ FF ( d, a, b, c, in[ 5], S12, UL(1200080426)); /* 6 */
+ FF ( c, d, a, b, in[ 6], S13, UL(2821735955)); /* 7 */
+ FF ( b, c, d, a, in[ 7], S14, UL(4249261313)); /* 8 */
+ FF ( a, b, c, d, in[ 8], S11, UL(1770035416)); /* 9 */
+ FF ( d, a, b, c, in[ 9], S12, UL(2336552879)); /* 10 */
+ FF ( c, d, a, b, in[10], S13, UL(4294925233)); /* 11 */
+ FF ( b, c, d, a, in[11], S14, UL(2304563134)); /* 12 */
+ FF ( a, b, c, d, in[12], S11, UL(1804603682)); /* 13 */
+ FF ( d, a, b, c, in[13], S12, UL(4254626195)); /* 14 */
+ FF ( c, d, a, b, in[14], S13, UL(2792965006)); /* 15 */
+ FF ( b, c, d, a, in[15], S14, UL(1236535329)); /* 16 */
+
+ /* Round 2 */
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+ GG ( a, b, c, d, in[ 1], S21, UL(4129170786)); /* 17 */
+ GG ( d, a, b, c, in[ 6], S22, UL(3225465664)); /* 18 */
+ GG ( c, d, a, b, in[11], S23, UL( 643717713)); /* 19 */
+ GG ( b, c, d, a, in[ 0], S24, UL(3921069994)); /* 20 */
+ GG ( a, b, c, d, in[ 5], S21, UL(3593408605)); /* 21 */
+ GG ( d, a, b, c, in[10], S22, UL( 38016083)); /* 22 */
+ GG ( c, d, a, b, in[15], S23, UL(3634488961)); /* 23 */
+ GG ( b, c, d, a, in[ 4], S24, UL(3889429448)); /* 24 */
+ GG ( a, b, c, d, in[ 9], S21, UL( 568446438)); /* 25 */
+ GG ( d, a, b, c, in[14], S22, UL(3275163606)); /* 26 */
+ GG ( c, d, a, b, in[ 3], S23, UL(4107603335)); /* 27 */
+ GG ( b, c, d, a, in[ 8], S24, UL(1163531501)); /* 28 */
+ GG ( a, b, c, d, in[13], S21, UL(2850285829)); /* 29 */
+ GG ( d, a, b, c, in[ 2], S22, UL(4243563512)); /* 30 */
+ GG ( c, d, a, b, in[ 7], S23, UL(1735328473)); /* 31 */
+ GG ( b, c, d, a, in[12], S24, UL(2368359562)); /* 32 */
+
+ /* Round 3 */
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+ HH ( a, b, c, d, in[ 5], S31, UL(4294588738)); /* 33 */
+ HH ( d, a, b, c, in[ 8], S32, UL(2272392833)); /* 34 */
+ HH ( c, d, a, b, in[11], S33, UL(1839030562)); /* 35 */
+ HH ( b, c, d, a, in[14], S34, UL(4259657740)); /* 36 */
+ HH ( a, b, c, d, in[ 1], S31, UL(2763975236)); /* 37 */
+ HH ( d, a, b, c, in[ 4], S32, UL(1272893353)); /* 38 */
+ HH ( c, d, a, b, in[ 7], S33, UL(4139469664)); /* 39 */
+ HH ( b, c, d, a, in[10], S34, UL(3200236656)); /* 40 */
+ HH ( a, b, c, d, in[13], S31, UL( 681279174)); /* 41 */
+ HH ( d, a, b, c, in[ 0], S32, UL(3936430074)); /* 42 */
+ HH ( c, d, a, b, in[ 3], S33, UL(3572445317)); /* 43 */
+ HH ( b, c, d, a, in[ 6], S34, UL( 76029189)); /* 44 */
+ HH ( a, b, c, d, in[ 9], S31, UL(3654602809)); /* 45 */
+ HH ( d, a, b, c, in[12], S32, UL(3873151461)); /* 46 */
+ HH ( c, d, a, b, in[15], S33, UL( 530742520)); /* 47 */
+ HH ( b, c, d, a, in[ 2], S34, UL(3299628645)); /* 48 */
+
+ /* Round 4 */
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+ II ( a, b, c, d, in[ 0], S41, UL(4096336452)); /* 49 */
+ II ( d, a, b, c, in[ 7], S42, UL(1126891415)); /* 50 */
+ II ( c, d, a, b, in[14], S43, UL(2878612391)); /* 51 */
+ II ( b, c, d, a, in[ 5], S44, UL(4237533241)); /* 52 */
+ II ( a, b, c, d, in[12], S41, UL(1700485571)); /* 53 */
+ II ( d, a, b, c, in[ 3], S42, UL(2399980690)); /* 54 */
+ II ( c, d, a, b, in[10], S43, UL(4293915773)); /* 55 */
+ II ( b, c, d, a, in[ 1], S44, UL(2240044497)); /* 56 */
+ II ( a, b, c, d, in[ 8], S41, UL(1873313359)); /* 57 */
+ II ( d, a, b, c, in[15], S42, UL(4264355552)); /* 58 */
+ II ( c, d, a, b, in[ 6], S43, UL(2734768916)); /* 59 */
+ II ( b, c, d, a, in[13], S44, UL(1309151649)); /* 60 */
+ II ( a, b, c, d, in[ 4], S41, UL(4149444226)); /* 61 */
+ II ( d, a, b, c, in[11], S42, UL(3174756917)); /* 62 */
+ II ( c, d, a, b, in[ 2], S43, UL( 718787259)); /* 63 */
+ II ( b, c, d, a, in[ 9], S44, UL(3951481745)); /* 64 */
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
+}
+
+/*
+ ***********************************************************************
+ ** End of md5.c **
+ ******************************** (cut) ********************************
+ */
diff --git a/package/system/mtd/src/md5.h b/package/system/mtd/src/md5.h
new file mode 100644
index 0000000000..f7a0c96418
--- /dev/null
+++ b/package/system/mtd/src/md5.h
@@ -0,0 +1,65 @@
+/*
+ ***********************************************************************
+ ** md5.h -- header file for implementation of MD5 **
+ ** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
+ ** Created: 2/17/90 RLR **
+ ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
+ ** Revised (for MD5): RLR 4/27/91 **
+ ** -- G modified to have y&~z instead of y&z **
+ ** -- FF, GG, HH modified to add in last register done **
+ ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 **
+ ** -- distinct additive constant for each step **
+ ** -- round 4 added, working mod 7 **
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
+ ** **
+ ** License to copy and use this software is granted provided that **
+ ** it is identified as the "RSA Data Security, Inc. MD5 Message- **
+ ** Digest Algorithm" in all material mentioning or referencing this **
+ ** software or this function. **
+ ** **
+ ** License is also granted to make and use derivative works **
+ ** provided that such works are identified as "derived from the RSA **
+ ** Data Security, Inc. MD5 Message-Digest Algorithm" in all **
+ ** material mentioning or referencing the derived work. **
+ ** **
+ ** RSA Data Security, Inc. makes no representations concerning **
+ ** either the merchantability of this software or the suitability **
+ ** of this software for any particular purpose. It is provided "as **
+ ** is" without express or implied warranty of any kind. **
+ ** **
+ ** These notices must be retained in any copies of any part of this **
+ ** documentation and/or software. **
+ ***********************************************************************
+ */
+
+#ifndef __MD5_INCLUDE__
+
+/* typedef a 32-bit type */
+#ifdef _LP64
+typedef unsigned int UINT4;
+typedef int INT4;
+#else
+typedef unsigned long UINT4;
+typedef long INT4;
+#endif
+#define _UINT4_T
+
+/* Data structure for MD5 (Message-Digest) computation */
+typedef struct {
+ UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
+ UINT4 buf[4]; /* scratch buffer */
+ unsigned char in[64]; /* input buffer */
+ unsigned char digest[16]; /* actual digest after MD5Final call */
+} MD5_CTX;
+
+void MD5_Init ();
+void MD5_Update ();
+void MD5_Final ();
+
+#define __MD5_INCLUDE__
+#endif /* __MD5_INCLUDE__ */
diff --git a/package/system/mtd/src/mtd.c b/package/system/mtd/src/mtd.c
new file mode 100644
index 0000000000..bdbaab51a4
--- /dev/null
+++ b/package/system/mtd/src/mtd.c
@@ -0,0 +1,761 @@
+/*
+ * mtd - simple memory technology device manipulation tool
+ *
+ * Copyright (C) 2005 Waldemar Brodkorb <wbx@dass-it.de>,
+ * Copyright (C) 2005-2009 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License v2
+ * as published by the Free Software Foundation.
+ *
+ * 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.
+ *
+ *
+ * The code is based on the linux-mtd examples.
+ */
+
+#include <limits.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <signal.h>
+#include <sys/ioctl.h>
+#include <sys/syscall.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <time.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/reboot.h>
+#include <linux/reboot.h>
+#include <mtd/mtd-user.h>
+#include "fis.h"
+#include "mtd.h"
+
+#ifndef MTDREFRESH
+#define MTDREFRESH _IO('M', 50)
+#endif
+
+#define MAX_ARGS 8
+#define JFFS2_DEFAULT_DIR "" /* directory name without /, empty means root dir */
+
+static char *buf = NULL;
+static char *imagefile = NULL;
+static char *jffs2file = NULL, *jffs2dir = JFFS2_DEFAULT_DIR;
+static int buflen = 0;
+int quiet;
+int no_erase;
+int mtdsize = 0;
+int erasesize = 0;
+
+int mtd_open(const char *mtd, bool block)
+{
+ FILE *fp;
+ char dev[PATH_MAX];
+ int i;
+ int ret;
+ int flags = O_RDWR | O_SYNC;
+
+ if ((fp = fopen("/proc/mtd", "r"))) {
+ while (fgets(dev, sizeof(dev), fp)) {
+ if (sscanf(dev, "mtd%d:", &i) && strstr(dev, mtd)) {
+ snprintf(dev, sizeof(dev), "/dev/mtd%s/%d", (block ? "block" : ""), i);
+ if ((ret=open(dev, flags))<0) {
+ snprintf(dev, sizeof(dev), "/dev/mtd%s%d", (block ? "block" : ""), i);
+ ret=open(dev, flags);
+ }
+ fclose(fp);
+ return ret;
+ }
+ }
+ fclose(fp);
+ }
+
+ return open(mtd, flags);
+}
+
+int mtd_check_open(const char *mtd)
+{
+ struct mtd_info_user mtdInfo;
+ int fd;
+
+ fd = mtd_open(mtd, false);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ return -1;
+ }
+
+ if(ioctl(fd, MEMGETINFO, &mtdInfo)) {
+ fprintf(stderr, "Could not get MTD device info from %s\n", mtd);
+ close(fd);
+ return -1;
+ }
+ mtdsize = mtdInfo.size;
+ erasesize = mtdInfo.erasesize;
+
+ return fd;
+}
+
+int mtd_erase_block(int fd, int offset)
+{
+ struct erase_info_user mtdEraseInfo;
+
+ mtdEraseInfo.start = offset;
+ mtdEraseInfo.length = erasesize;
+ ioctl(fd, MEMUNLOCK, &mtdEraseInfo);
+ if (ioctl (fd, MEMERASE, &mtdEraseInfo) < 0)
+ return -1;
+
+ return 0;
+}
+
+int mtd_write_buffer(int fd, const char *buf, int offset, int length)
+{
+ lseek(fd, offset, SEEK_SET);
+ write(fd, buf, length);
+ return 0;
+}
+
+
+static int
+image_check(int imagefd, const char *mtd)
+{
+ int ret = 1;
+ if (trx_check) {
+ ret = trx_check(imagefd, mtd, buf, &buflen);
+ }
+
+ return ret;
+}
+
+static int mtd_check(const char *mtd)
+{
+ char *next = NULL;
+ char *str = NULL;
+ int fd;
+
+ if (strchr(mtd, ':')) {
+ str = strdup(mtd);
+ mtd = str;
+ }
+
+ do {
+ next = strchr(mtd, ':');
+ if (next) {
+ *next = 0;
+ next++;
+ }
+
+ fd = mtd_check_open(mtd);
+ if (fd < 0)
+ return 0;
+
+ if (!buf)
+ buf = malloc(erasesize);
+
+ close(fd);
+ mtd = next;
+ } while (next);
+
+ if (str)
+ free(str);
+
+ return 1;
+}
+
+static int
+mtd_unlock(const char *mtd)
+{
+ struct erase_info_user mtdLockInfo;
+ char *next = NULL;
+ char *str = NULL;
+ int fd;
+
+ if (strchr(mtd, ':')) {
+ str = strdup(mtd);
+ mtd = str;
+ }
+
+ do {
+ next = strchr(mtd, ':');
+ if (next) {
+ *next = 0;
+ next++;
+ }
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Unlocking %s ...\n", mtd);
+
+ mtdLockInfo.start = 0;
+ mtdLockInfo.length = mtdsize;
+ ioctl(fd, MEMUNLOCK, &mtdLockInfo);
+ close(fd);
+ mtd = next;
+ } while (next);
+
+ if (str)
+ free(str);
+
+ return 0;
+}
+
+static int
+mtd_erase(const char *mtd)
+{
+ int fd;
+ struct erase_info_user mtdEraseInfo;
+
+ if (quiet < 2)
+ fprintf(stderr, "Erasing %s ...\n", mtd);
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ mtdEraseInfo.length = erasesize;
+
+ for (mtdEraseInfo.start = 0;
+ mtdEraseInfo.start < mtdsize;
+ mtdEraseInfo.start += erasesize) {
+
+ ioctl(fd, MEMUNLOCK, &mtdEraseInfo);
+ if(ioctl(fd, MEMERASE, &mtdEraseInfo))
+ fprintf(stderr, "Failed to erase block on %s at 0x%x\n", mtd, mtdEraseInfo.start);
+ }
+
+ close(fd);
+ return 0;
+
+}
+
+static int
+mtd_refresh(const char *mtd)
+{
+ int fd;
+
+ if (quiet < 2)
+ fprintf(stderr, "Refreshing mtd partition %s ... ", mtd);
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (ioctl(fd, MTDREFRESH, NULL)) {
+ fprintf(stderr, "Failed to refresh the MTD device\n");
+ close(fd);
+ exit(1);
+ }
+ close(fd);
+
+ if (quiet < 2)
+ fprintf(stderr, "\n");
+
+ return 0;
+}
+
+static void
+indicate_writing(const char *mtd)
+{
+ if (quiet < 2)
+ fprintf(stderr, "\nWriting from %s to %s ... ", imagefile, mtd);
+
+ if (!quiet)
+ fprintf(stderr, " [ ]");
+}
+
+static int
+mtd_write(int imagefd, const char *mtd, char *fis_layout, size_t part_offset)
+{
+ char *next = NULL;
+ char *str = NULL;
+ int fd, result;
+ ssize_t r, w, e;
+ ssize_t skip = 0;
+ uint32_t offset = 0;
+ int jffs2_replaced = 0;
+
+#ifdef FIS_SUPPORT
+ static struct fis_part new_parts[MAX_ARGS];
+ static struct fis_part old_parts[MAX_ARGS];
+ int n_new = 0, n_old = 0;
+
+ if (fis_layout) {
+ const char *tmp = mtd;
+ char *word, *brkt;
+ int ret;
+
+ memset(&old_parts, 0, sizeof(old_parts));
+ memset(&new_parts, 0, sizeof(new_parts));
+
+ do {
+ next = strchr(tmp, ':');
+ if (!next)
+ next = (char *) tmp + strlen(tmp);
+
+ memcpy(old_parts[n_old].name, tmp, next - tmp);
+
+ n_old++;
+ tmp = next + 1;
+ } while(*next);
+
+ for (word = strtok_r(fis_layout, ",", &brkt);
+ word;
+ word = strtok_r(NULL, ",", &brkt)) {
+
+ tmp = strtok(word, ":");
+ strncpy((char *) new_parts[n_new].name, tmp, sizeof(new_parts[n_new].name) - 1);
+
+ tmp = strtok(NULL, ":");
+ if (!tmp)
+ goto next;
+
+ new_parts[n_new].size = strtoul(tmp, NULL, 0);
+
+ tmp = strtok(NULL, ":");
+ if (!tmp)
+ goto next;
+
+ new_parts[n_new].loadaddr = strtoul(tmp, NULL, 16);
+next:
+ n_new++;
+ }
+ ret = fis_validate(old_parts, n_old, new_parts, n_new);
+ if (ret < 0) {
+ fprintf(stderr, "Failed to validate the new FIS partition table\n");
+ exit(1);
+ }
+ if (ret == 0)
+ fis_layout = NULL;
+ }
+#endif
+
+ if (strchr(mtd, ':')) {
+ str = strdup(mtd);
+ mtd = str;
+ }
+
+ r = 0;
+
+resume:
+ next = strchr(mtd, ':');
+ if (next) {
+ *next = 0;
+ next++;
+ }
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (part_offset > 0) {
+ fprintf(stderr, "Seeking on mtd device '%s' to: %u\n", mtd, part_offset);
+ lseek(fd, part_offset, SEEK_SET);
+ }
+
+ indicate_writing(mtd);
+
+ w = e = 0;
+ for (;;) {
+ /* buffer may contain data already (from trx check or last mtd partition write attempt) */
+ while (buflen < erasesize) {
+ r = read(imagefd, buf + buflen, erasesize - buflen);
+ if (r < 0) {
+ if ((errno == EINTR) || (errno == EAGAIN))
+ continue;
+ else {
+ perror("read");
+ break;
+ }
+ }
+
+ if (r == 0)
+ break;
+
+ buflen += r;
+ }
+
+ if (buflen == 0)
+ break;
+
+ if (skip > 0) {
+ skip -= buflen;
+ buflen = 0;
+ if (skip <= 0)
+ indicate_writing(mtd);
+
+ continue;
+ }
+
+ if (jffs2file) {
+ if (memcmp(buf, JFFS2_EOF, sizeof(JFFS2_EOF) - 1) == 0) {
+ if (!quiet)
+ fprintf(stderr, "\b\b\b ");
+ if (quiet < 2)
+ fprintf(stderr, "\nAppending jffs2 data from %s to %s...", jffs2file, mtd);
+ /* got an EOF marker - this is the place to add some jffs2 data */
+ skip = mtd_replace_jffs2(mtd, fd, e, jffs2file);
+ jffs2_replaced = 1;
+
+ /* don't add it again */
+ jffs2file = NULL;
+
+ w += skip;
+ e += skip;
+ skip -= buflen;
+ buflen = 0;
+ offset = 0;
+ continue;
+ }
+ /* no EOF marker, make sure we figure out the last inode number
+ * before appending some data */
+ mtd_parse_jffs2data(buf, jffs2dir);
+ }
+
+ /* need to erase the next block before writing data to it */
+ if(!no_erase)
+ {
+ while (w + buflen > e) {
+ if (!quiet)
+ fprintf(stderr, "\b\b\b[e]");
+
+
+ if (mtd_erase_block(fd, e) < 0) {
+ if (next) {
+ if (w < e) {
+ write(fd, buf + offset, e - w);
+ offset = e - w;
+ }
+ w = 0;
+ e = 0;
+ close(fd);
+ mtd = next;
+ fprintf(stderr, "\b\b\b \n");
+ goto resume;
+ } else {
+ fprintf(stderr, "Failed to erase block\n");
+ exit(1);
+ }
+ }
+
+ /* erase the chunk */
+ e += erasesize;
+ }
+ }
+
+ if (!quiet)
+ fprintf(stderr, "\b\b\b[w]");
+
+ if ((result = write(fd, buf + offset, buflen)) < buflen) {
+ if (result < 0) {
+ fprintf(stderr, "Error writing image.\n");
+ exit(1);
+ } else {
+ fprintf(stderr, "Insufficient space.\n");
+ exit(1);
+ }
+ }
+ w += buflen;
+
+ buflen = 0;
+ offset = 0;
+ }
+
+ if (jffs2_replaced && trx_fixup) {
+ trx_fixup(fd, mtd);
+ }
+
+ if (!quiet)
+ fprintf(stderr, "\b\b\b\b ");
+
+done:
+ if (quiet < 2)
+ fprintf(stderr, "\n");
+
+#ifdef FIS_SUPPORT
+ if (fis_layout) {
+ if (fis_remap(old_parts, n_old, new_parts, n_new) < 0)
+ fprintf(stderr, "Failed to update the FIS partition table\n");
+ }
+#endif
+
+ close(fd);
+ return 0;
+}
+
+static void usage(void)
+{
+ fprintf(stderr, "Usage: mtd [<options> ...] <command> [<arguments> ...] <device>[:<device>...]\n\n"
+ "The device is in the format of mtdX (eg: mtd4) or its label.\n"
+ "mtd recognizes these commands:\n"
+ " unlock unlock the device\n"
+ " refresh refresh mtd partition\n"
+ " erase erase all data on device\n"
+ " write <imagefile>|- write <imagefile> (use - for stdin) to device\n"
+ " jffs2write <file> append <file> to the jffs2 partition on the device\n");
+ if (mtd_fixtrx) {
+ fprintf(stderr,
+ " fixtrx fix the checksum in a trx header on first boot\n");
+ }
+ if (mtd_fixseama) {
+ fprintf(stderr,
+ " fixseama fix the checksum in a seama header on first boot\n");
+ }
+ fprintf(stderr,
+ "Following options are available:\n"
+ " -q quiet mode (once: no [w] on writing,\n"
+ " twice: no status messages)\n"
+ " -n write without first erasing the blocks\n"
+ " -r reboot after successful command\n"
+ " -f force write without trx checks\n"
+ " -e <device> erase <device> before executing the command\n"
+ " -d <name> directory for jffs2write, defaults to \"tmp\"\n"
+ " -j <name> integrate <file> into jffs2 data when writing an image\n"
+ " -p write beginning at partition offset\n");
+ if (mtd_fixtrx) {
+ fprintf(stderr,
+ " -o offset offset of the image header in the partition(for fixtrx)\n");
+ }
+ fprintf(stderr,
+#ifdef FIS_SUPPORT
+ " -F <part>[:<size>[:<entrypoint>]][,<part>...]\n"
+ " alter the fis partition table to create new partitions replacing\n"
+ " the partitions provided as argument to the write command\n"
+ " (only valid together with the write command)\n"
+#endif
+ "\n"
+ "Example: To write linux.trx to mtd4 labeled as linux and reboot afterwards\n"
+ " mtd -r write linux.trx linux\n\n");
+ exit(1);
+}
+
+static void do_reboot(void)
+{
+ fprintf(stderr, "Rebooting ...\n");
+ fflush(stderr);
+
+ /* try regular reboot method first */
+ system("/sbin/reboot");
+ sleep(2);
+
+ /* if we're still alive at this point, force the kernel to reboot */
+ syscall(SYS_reboot,LINUX_REBOOT_MAGIC1,LINUX_REBOOT_MAGIC2,LINUX_REBOOT_CMD_RESTART,NULL);
+}
+
+int main (int argc, char **argv)
+{
+ int ch, i, boot, imagefd = 0, force, unlocked;
+ char *erase[MAX_ARGS], *device = NULL;
+ char *fis_layout = NULL;
+ size_t offset = 0, part_offset = 0;
+ enum {
+ CMD_ERASE,
+ CMD_WRITE,
+ CMD_UNLOCK,
+ CMD_REFRESH,
+ CMD_JFFS2WRITE,
+ CMD_FIXTRX,
+ CMD_FIXSEAMA,
+ } cmd = -1;
+
+ erase[0] = NULL;
+ boot = 0;
+ force = 0;
+ buflen = 0;
+ quiet = 0;
+ no_erase = 0;
+
+ while ((ch = getopt(argc, argv,
+#ifdef FIS_SUPPORT
+ "F:"
+#endif
+ "frnqe:d:j:p:o:")) != -1)
+ switch (ch) {
+ case 'f':
+ force = 1;
+ break;
+ case 'r':
+ boot = 1;
+ break;
+ case 'n':
+ no_erase = 1;
+ break;
+ case 'j':
+ jffs2file = optarg;
+ break;
+ case 'q':
+ quiet++;
+ break;
+ case 'e':
+ i = 0;
+ while ((erase[i] != NULL) && ((i + 1) < MAX_ARGS))
+ i++;
+
+ erase[i++] = optarg;
+ erase[i] = NULL;
+ break;
+ case 'd':
+ jffs2dir = optarg;
+ break;
+ case 'p':
+ errno = 0;
+ part_offset = strtoul(optarg, 0, 0);
+ if (errno) {
+ fprintf(stderr, "-p: illegal numeric string\n");
+ usage();
+ }
+ break;
+ case 'o':
+ if (!mtd_fixtrx) {
+ fprintf(stderr, "-o: is not available on this platform\n");
+ usage();
+ }
+ errno = 0;
+ offset = strtoul(optarg, 0, 0);
+ if (errno) {
+ fprintf(stderr, "-o: illegal numeric string\n");
+ usage();
+ }
+ break;
+#ifdef FIS_SUPPORT
+ case 'F':
+ fis_layout = optarg;
+ break;
+#endif
+ case '?':
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 2)
+ usage();
+
+ if ((strcmp(argv[0], "unlock") == 0) && (argc == 2)) {
+ cmd = CMD_UNLOCK;
+ device = argv[1];
+ } else if ((strcmp(argv[0], "refresh") == 0) && (argc == 2)) {
+ cmd = CMD_REFRESH;
+ device = argv[1];
+ } else if ((strcmp(argv[0], "erase") == 0) && (argc == 2)) {
+ cmd = CMD_ERASE;
+ device = argv[1];
+ } else if (((strcmp(argv[0], "fixtrx") == 0) && (argc == 2)) && mtd_fixtrx) {
+ cmd = CMD_FIXTRX;
+ device = argv[1];
+ } else if (((strcmp(argv[0], "fixseama") == 0) && (argc == 2)) && mtd_fixseama) {
+ cmd = CMD_FIXSEAMA;
+ device = argv[1];
+ } else if ((strcmp(argv[0], "write") == 0) && (argc == 3)) {
+ cmd = CMD_WRITE;
+ device = argv[2];
+
+ if (strcmp(argv[1], "-") == 0) {
+ imagefile = "<stdin>";
+ imagefd = 0;
+ } else {
+ imagefile = argv[1];
+ if ((imagefd = open(argv[1], O_RDONLY)) < 0) {
+ fprintf(stderr, "Couldn't open image file: %s!\n", imagefile);
+ exit(1);
+ }
+ }
+
+ if (!mtd_check(device)) {
+ fprintf(stderr, "Can't open device for writing!\n");
+ exit(1);
+ }
+ /* check trx file before erasing or writing anything */
+ if (!image_check(imagefd, device) && !force) {
+ fprintf(stderr, "Image check failed.\n");
+ exit(1);
+ }
+ } else if ((strcmp(argv[0], "jffs2write") == 0) && (argc == 3)) {
+ cmd = CMD_JFFS2WRITE;
+ device = argv[2];
+
+ imagefile = argv[1];
+ if (!mtd_check(device)) {
+ fprintf(stderr, "Can't open device for writing!\n");
+ exit(1);
+ }
+ } else {
+ usage();
+ }
+
+ sync();
+
+ i = 0;
+ unlocked = 0;
+ while (erase[i] != NULL) {
+ mtd_unlock(erase[i]);
+ mtd_erase(erase[i]);
+ if (strcmp(erase[i], device) == 0)
+ unlocked = 1;
+ i++;
+ }
+
+ switch (cmd) {
+ case CMD_UNLOCK:
+ if (!unlocked)
+ mtd_unlock(device);
+ break;
+ case CMD_ERASE:
+ if (!unlocked)
+ mtd_unlock(device);
+ mtd_erase(device);
+ break;
+ case CMD_WRITE:
+ if (!unlocked)
+ mtd_unlock(device);
+ mtd_write(imagefd, device, fis_layout, part_offset);
+ break;
+ case CMD_JFFS2WRITE:
+ if (!unlocked)
+ mtd_unlock(device);
+ mtd_write_jffs2(device, imagefile, jffs2dir);
+ break;
+ case CMD_REFRESH:
+ mtd_refresh(device);
+ break;
+ case CMD_FIXTRX:
+ if (mtd_fixtrx) {
+ mtd_fixtrx(device, offset);
+ }
+ case CMD_FIXSEAMA:
+ if (mtd_fixseama)
+ mtd_fixseama(device, 0);
+ break;
+ }
+
+ sync();
+
+ if (boot)
+ do_reboot();
+
+ return 0;
+}
diff --git a/package/system/mtd/src/mtd.h b/package/system/mtd/src/mtd.h
new file mode 100644
index 0000000000..c2133fc37c
--- /dev/null
+++ b/package/system/mtd/src/mtd.h
@@ -0,0 +1,29 @@
+#ifndef __mtd_h
+#define __mtd_h
+
+#include <stdbool.h>
+
+#ifdef target_brcm47xx
+#define target_brcm 1
+#endif
+
+#define JFFS2_EOF "\xde\xad\xc0\xde"
+
+extern int quiet;
+extern int mtdsize;
+extern int erasesize;
+
+extern int mtd_open(const char *mtd, bool block);
+extern int mtd_check_open(const char *mtd);
+extern int mtd_erase_block(int fd, int offset);
+extern int mtd_write_buffer(int fd, const char *buf, int offset, int length);
+extern int mtd_write_jffs2(const char *mtd, const char *filename, const char *dir);
+extern int mtd_replace_jffs2(const char *mtd, int fd, int ofs, const char *filename);
+extern void mtd_parse_jffs2data(const char *buf, const char *dir);
+
+/* target specific functions */
+extern int trx_fixup(int fd, const char *name) __attribute__ ((weak));
+extern int trx_check(int imagefd, const char *mtd, char *buf, int *len) __attribute__ ((weak));
+extern int mtd_fixtrx(const char *mtd, size_t offset) __attribute__ ((weak));
+extern int mtd_fixseama(const char *mtd, size_t offset) __attribute__ ((weak));
+#endif /* __mtd_h */
diff --git a/package/system/mtd/src/seama.c b/package/system/mtd/src/seama.c
new file mode 100644
index 0000000000..b0c8bf3d0d
--- /dev/null
+++ b/package/system/mtd/src/seama.c
@@ -0,0 +1,179 @@
+/*
+ * seama.c
+ *
+ * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * Based on the trx fixup code:
+ * Copyright (C) 2005 Mike Baker
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+#include <arpa/inet.h>
+
+#include <sys/ioctl.h>
+#include <mtd/mtd-user.h>
+#include "mtd.h"
+#include "seama.h"
+#include "md5.h"
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define STORE32_LE(X) ((((X) & 0x000000FF) << 24) | (((X) & 0x0000FF00) << 8) | (((X) & 0x00FF0000) >> 8) | (((X) & 0xFF000000) >> 24))
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define STORE32_LE(X) (X)
+#else
+#error unknown endianness!
+#endif
+
+ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+
+int
+seama_fix_md5(char *buf, size_t len)
+{
+ struct seama_hdr *shdr;
+ char *data;
+ size_t msize;
+ size_t isize;
+ MD5_CTX ctx;
+ unsigned char digest[16];
+ int i;
+
+ if (len < sizeof(struct seama_hdr))
+ return -1;
+
+ shdr = (struct seama_hdr *) buf;
+ if (shdr->magic != htonl(SEAMA_MAGIC)) {
+ fprintf(stderr, "no SEAMA header found\n");
+ return -1;
+ }
+
+ isize = ntohl(shdr->size);
+ msize = ntohs(shdr->metasize);
+ if (isize == 0) {
+ /* the image contains no checksum */
+ return -1;
+ }
+
+ len -= sizeof(struct seama_hdr) + sizeof(digest) + msize;
+ if (isize > len)
+ isize = len;
+
+ data = buf + sizeof(struct seama_hdr) + sizeof(digest) + msize;
+
+ MD5_Init(&ctx);
+ MD5_Update(&ctx, data, isize);
+ MD5_Final(digest, &ctx);
+
+ if (!memcmp(digest, &buf[sizeof(struct seama_hdr)], sizeof(digest))) {
+ if (quiet < 2)
+ fprintf(stderr, "the header is fixed already\n");
+ return -1;
+ }
+
+ if (quiet < 2) {
+ fprintf(stderr, "new size:%u, new MD5: ", isize);
+ for (i = 0; i < sizeof(digest); i++)
+ fprintf(stderr, "%02x", digest[i]);
+
+ fprintf(stderr, "\n");
+ }
+
+ /* update the size in the image */
+ shdr->size = htonl(isize);
+
+ /* update the checksum in the image */
+ for (i = 0; i < sizeof(digest); i++)
+ buf[sizeof(struct seama_hdr) + i] = digest[i];
+
+ return 0;
+}
+
+int
+mtd_fixseama(const char *mtd, size_t offset)
+{
+ int fd;
+ char *buf;
+ ssize_t res;
+ size_t block_offset;
+
+ if (quiet < 2)
+ fprintf(stderr, "Trying to fix SEAMA header in %s at 0x%x...\n",
+ mtd, offset);
+
+ block_offset = offset & ~(erasesize - 1);
+ offset -= block_offset;
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if (block_offset + erasesize > mtdsize) {
+ fprintf(stderr, "Offset too large, device size 0x%x\n",
+ mtdsize);
+ exit(1);
+ }
+
+ buf = malloc(mtdsize);
+ if (!buf) {
+ perror("malloc");
+ exit(1);
+ }
+
+ res = pread(fd, buf, mtdsize, block_offset);
+ if (res != mtdsize) {
+ perror("pread");
+ exit(1);
+ }
+
+ if (seama_fix_md5(buf, mtdsize))
+ goto out;
+
+ if (mtd_erase_block(fd, block_offset)) {
+ fprintf(stderr, "Can't erease block at 0x%x (%s)\n",
+ block_offset, strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Rewriting block at 0x%x\n", block_offset);
+
+ if (pwrite(fd, buf, erasesize, block_offset) != erasesize) {
+ fprintf(stderr, "Error writing block (%s)\n", strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Done.\n");
+
+out:
+ close (fd);
+ sync();
+
+ return 0;
+}
+
diff --git a/package/system/mtd/src/seama.h b/package/system/mtd/src/seama.h
new file mode 100644
index 0000000000..02683b6e98
--- /dev/null
+++ b/package/system/mtd/src/seama.h
@@ -0,0 +1,108 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * (SEA)ttle i(MA)ge is the image which used in project seattle.
+ *
+ * Created by David Hsieh <david_hsieh@alphanetworks.com>
+ * Copyright (C) 2008-2009 Alpha Networks, Inc.
+ *
+ * This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either'
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * The GNU C 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 the GNU C Library; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef __SEAMA_HEADER_FILE__
+#define __SEAMA_HEADER_FILE__
+
+#include <stdint.h>
+
+#define SEAMA_MAGIC 0x5EA3A417
+
+/*
+ * SEAMA looks like the following map.
+ * All the data of the header should be in network byte order.
+ *
+ * +-------------+-------------+------------
+ * | SEAMA magic | ^
+ * +-------------+-------------+ |
+ * | reserved | meta size | |
+ * +-------------+-------------+ header
+ * | image size (0 bytes) | |
+ * +-------------+-------------+ |
+ * ~ Meta data ~ v
+ * +-------------+-------------+------------
+ * | SEAMA magic | ^ ^
+ * +-------------+-------------+ | |
+ * | reserved | meta size | | |
+ * +-------------+-------------+ | |
+ * | image size | | |
+ * +-------------+-------------+ header |
+ * | | | |
+ * | 16 bytes of MD5 digest | | |
+ * | | | |
+ * | | | |
+ * +-------------+-------------+ | |
+ * ~ Meta data ~ v |
+ * +-------------+-------------+------- |
+ * | | |
+ * | Image of the 1st entity | |
+ * ~ ~ 1st entity
+ * | | |
+ * | | v
+ * +-------------+-------------+-------------
+ * | SEAMA magic | ^ ^
+ * +-------------+-------------+ | |
+ * | reserved | meta size | | |
+ * +-------------+-------------+ | |
+ * | image size | | |
+ * +-------------+-------------+ header |
+ * | | | |
+ * | 16 bytes of MD5 digest | | |
+ * | | | |
+ * | | | |
+ * +-------------+-------------+ | |
+ * ~ Meta data ~ v |
+ * +-------------+-------------+------- |
+ * | | |
+ * | Image of the 2nd entity | |
+ * ~ ~ 2nd entity
+ * | | |
+ * | | v
+ * +-------------+-------------+-------------
+ */
+
+
+/*
+ * SEAMA header
+ *
+ * |<-------- 32 bits -------->|
+ * +-------------+-------------+
+ * | SEAMA magic |
+ * +-------------+-------------+
+ * | reserved | meta size |
+ * +-------------+-------------+
+ * | image size |
+ * +-------------+-------------+
+ */
+/* seama header */
+typedef struct seama_hdr seamahdr_t;
+struct seama_hdr
+{
+ uint32_t magic; /* should always be SEAMA_MAGIC. */
+ uint16_t reserved; /* reserved for */
+ uint16_t metasize; /* size of the META data */
+ uint32_t size; /* size of the image */
+} __attribute__ ((packed));
+
+
+#endif
diff --git a/package/system/mtd/src/trx.c b/package/system/mtd/src/trx.c
new file mode 100644
index 0000000000..65c24404c2
--- /dev/null
+++ b/package/system/mtd/src/trx.c
@@ -0,0 +1,220 @@
+/*
+ * trx.c
+ *
+ * Copyright (C) 2005 Mike Baker
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/ioctl.h>
+#include <mtd/mtd-user.h>
+#include "mtd.h"
+#include "crc32.h"
+
+#define TRX_MAGIC 0x30524448 /* "HDR0" */
+struct trx_header {
+ uint32_t magic; /* "HDR0" */
+ uint32_t len; /* Length of file including header */
+ uint32_t crc32; /* 32-bit CRC from flag_version to end of file */
+ uint32_t flag_version; /* 0:15 flags, 16:31 version */
+ uint32_t offsets[3]; /* Offsets of partitions from start of header */
+};
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define STORE32_LE(X) ((((X) & 0x000000FF) << 24) | (((X) & 0x0000FF00) << 8) | (((X) & 0x00FF0000) >> 8) | (((X) & 0xFF000000) >> 24))
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define STORE32_LE(X) (X)
+#else
+#error unknown endianness!
+#endif
+
+ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+
+int
+trx_fixup(int fd, const char *name)
+{
+ struct mtd_info_user mtdInfo;
+ unsigned long len;
+ struct trx_header *trx;
+ void *ptr, *scan;
+ int bfd;
+
+ if (ioctl(fd, MEMGETINFO, &mtdInfo) < 0) {
+ fprintf(stderr, "Failed to get mtd info\n");
+ goto err;
+ }
+
+ len = mtdInfo.size;
+ if (mtdInfo.size <= 0) {
+ fprintf(stderr, "Invalid MTD device size\n");
+ goto err;
+ }
+
+ bfd = mtd_open(name, true);
+ ptr = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, bfd, 0);
+ if (!ptr || (ptr == (void *) -1)) {
+ perror("mmap");
+ goto err1;
+ }
+
+ trx = ptr;
+ if (trx->magic != TRX_MAGIC) {
+ fprintf(stderr, "TRX header not found\n");
+ goto err;
+ }
+
+ scan = ptr + offsetof(struct trx_header, flag_version);
+ trx->crc32 = crc32buf(scan, trx->len - (scan - ptr));
+ msync(ptr, sizeof(struct trx_header), MS_SYNC|MS_INVALIDATE);
+ munmap(ptr, len);
+ close(bfd);
+ return 0;
+
+err1:
+ close(bfd);
+err:
+ fprintf(stderr, "Error fixing up TRX header\n");
+ return -1;
+}
+
+int
+trx_check(int imagefd, const char *mtd, char *buf, int *len)
+{
+ const struct trx_header *trx = (const struct trx_header *) buf;
+ int fd;
+
+ if (strcmp(mtd, "linux") != 0)
+ return 1;
+
+ *len = read(imagefd, buf, 32);
+ if (*len < 32) {
+ fprintf(stdout, "Could not get image header, file too small (%d bytes)\n", *len);
+ return 0;
+ }
+
+ if (trx->magic != TRX_MAGIC || trx->len < sizeof(struct trx_header)) {
+ if (quiet < 2) {
+ fprintf(stderr, "Bad trx header\n");
+ fprintf(stderr, "This is not the correct file format; refusing to flash.\n"
+ "Please specify the correct file or use -f to force.\n");
+ }
+ return 0;
+ }
+
+ /* check if image fits to mtd device */
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ if(mtdsize < trx->len) {
+ fprintf(stderr, "Image too big for partition: %s\n", mtd);
+ close(fd);
+ return 0;
+ }
+
+ close(fd);
+ return 1;
+}
+
+int
+mtd_fixtrx(const char *mtd, size_t offset)
+{
+ int fd;
+ struct trx_header *trx;
+ char *buf;
+ ssize_t res;
+ size_t block_offset;
+
+ if (quiet < 2)
+ fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", mtd, offset);
+
+ fd = mtd_check_open(mtd);
+ if(fd < 0) {
+ fprintf(stderr, "Could not open mtd device: %s\n", mtd);
+ exit(1);
+ }
+
+ block_offset = offset & ~(erasesize - 1);
+ offset -= block_offset;
+
+ if (block_offset + erasesize > mtdsize) {
+ fprintf(stderr, "Offset too large, device size 0x%x\n", mtdsize);
+ exit(1);
+ }
+
+ buf = malloc(erasesize);
+ if (!buf) {
+ perror("malloc");
+ exit(1);
+ }
+
+ res = pread(fd, buf, erasesize, block_offset);
+ if (res != erasesize) {
+ perror("pread");
+ exit(1);
+ }
+
+ trx = (struct trx_header *) (buf + offset);
+ if (trx->magic != STORE32_LE(0x30524448)) {
+ fprintf(stderr, "No trx magic found\n");
+ exit(1);
+ }
+
+ if (trx->len == STORE32_LE(erasesize - offset)) {
+ if (quiet < 2)
+ fprintf(stderr, "Header already fixed, exiting\n");
+ close(fd);
+ return 0;
+ }
+
+ trx->len = STORE32_LE(erasesize - offset);
+
+ trx->crc32 = STORE32_LE(crc32buf((char*) &trx->flag_version, erasesize - offset - 3*4));
+ if (mtd_erase_block(fd, block_offset)) {
+ fprintf(stderr, "Can't erease block at 0x%x (%s)\n", block_offset, strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "New crc32: 0x%x, rewriting block\n", trx->crc32);
+
+ if (pwrite(fd, buf, erasesize, block_offset) != erasesize) {
+ fprintf(stderr, "Error writing block (%s)\n", strerror(errno));
+ exit(1);
+ }
+
+ if (quiet < 2)
+ fprintf(stderr, "Done.\n");
+
+ close (fd);
+ sync();
+ return 0;
+
+}
+
diff --git a/package/system/om-watchdog/Makefile b/package/system/om-watchdog/Makefile
deleted file mode 100644
index 7d517a11eb..0000000000
--- a/package/system/om-watchdog/Makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# Copyright (C) 2011 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:=om-watchdog
-PKG_RELEASE:=1
-PKG_VERSION:=1
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/om-watchdog
- SECTION:=base
- CATEGORY:=Base system
- TITLE:=om watchdog
- URL:=http://openwrt.org/
-endef
-
-define Package/om-watchdog/description
- This package contains the hw watchdog script for the OM1P and OM2P device.
-endef
-
-define Build/Prepare
-endef
-
-define Build/Compile
-endef
-
-define Build/Compile
-endef
-
-define Package/om-watchdog/install
- $(INSTALL_DIR) $(1)/etc/init.d/
- $(INSTALL_DIR) $(1)/sbin/
- $(INSTALL_BIN) ./files/om-watchdog.init $(1)/etc/init.d/om-watchdog
- $(INSTALL_BIN) ./files/om-watchdog $(1)/sbin/om-watchdog
-endef
-
-
-$(eval $(call BuildPackage,om-watchdog))
-
diff --git a/package/system/om-watchdog/files/om-watchdog b/package/system/om-watchdog/files/om-watchdog
deleted file mode 100644
index d730c68447..0000000000
--- a/package/system/om-watchdog/files/om-watchdog
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-GPIO=$1
-
-trap "" INT HUP
-
-echo $GPIO > /sys/class/gpio/export
-echo out > /sys/class/gpio/gpio${GPIO}/direction
-
-while true; do
- echo 1 > /sys/class/gpio/gpio${GPIO}/value
- sleep 1
- echo 0 > /sys/class/gpio/gpio${GPIO}/value
- sleep 180
-done
diff --git a/package/system/om-watchdog/files/om-watchdog.init b/package/system/om-watchdog/files/om-watchdog.init
deleted file mode 100644
index 0298bce046..0000000000
--- a/package/system/om-watchdog/files/om-watchdog.init
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh /etc/rc.common
-#
-# Copyright (C) 2011 OpenWrt.org
-#
-
-START=11
-
-SERVICE_DAEMONIZE=1
-
-boot() {
- if [ -r /lib/ar71xx.sh ]; then
- . /lib/ar71xx.sh
- local board=$(ar71xx_board_name)
-
- case "$board" in
- "om2p"|"om2p-hs")
- service_start /sbin/om-watchdog 12
- ;;
- "om2p-lc")
- service_start /sbin/om-watchdog 26
- ;;
- "mr600v2")
- service_start /sbin/om-watchdog 15
- ;;
- esac
- else
- #we assume it is om1p in this case
- service_start /sbin/om-watchdog 3
- fi
-}
diff --git a/package/system/opkg/Makefile b/package/system/opkg/Makefile
new file mode 100644
index 0000000000..6407ab451f
--- /dev/null
+++ b/package/system/opkg/Makefile
@@ -0,0 +1,102 @@
+#
+# Copyright (C) 2006-2012 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
+include $(INCLUDE_DIR)/version.mk
+
+PKG_NAME:=opkg
+PKG_REV:=618
+PKG_VERSION:=$(PKG_REV)
+PKG_RELEASE:=3
+
+PKG_SOURCE_PROTO:=svn
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE_SUBDIR:=opkg-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://opkg.googlecode.com/svn/trunk/
+PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
+PKG_FIXUP:=autoreconf
+PKG_REMOVE_FILES = autogen.sh aclocal.m4
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=COPYING
+
+PKG_BUILD_PARALLEL:=1
+HOST_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/opkg
+ SECTION:=base
+ CATEGORY:=Base system
+ TITLE:=opkg package management system
+ MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
+ URL:=http://wiki.openmoko.org/wiki/Opkg
+endef
+
+define Package/opkg/description
+ Lightweight package management system
+ opkg is the opkg Package Management System, for handling
+ installation and removal of packages on a system. It can
+ recursively follow dependencies and download all packages
+ necessary to install a particular package.
+
+ opkg knows how to install both .ipk and .deb packages.
+endef
+
+define Package/opkg/conffiles
+/etc/opkg.conf
+endef
+
+TARGET_CFLAGS += $(if $(CONFIG_GCC_VERSION_4_3)$(CONFIG_GCC_VERSION_4_4),-Wno-array-bounds)
+TARGET_CFLAGS += -ffunction-sections -fdata-sections
+EXTRA_CFLAGS += $(TARGET_CPPFLAGS)
+
+CONFIGURE_ARGS += \
+ --disable-curl \
+ --disable-gpg \
+ --with-opkgetcdir=/etc \
+ --with-opkglockfile=/var/lock/opkg.lock
+
+MAKE_FLAGS = \
+ CC="$(TARGET_CC)" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ HOST_CPU="$(PKGARCH)" \
+ LDFLAGS="-Wl,--gc-sections" \
+
+define Package/opkg/install
+ $(INSTALL_DIR) $(1)/usr/lib/opkg
+ $(INSTALL_DIR) $(1)/bin
+ $(INSTALL_DIR) $(1)/etc
+ $(INSTALL_DATA) ./files/opkg.conf $(1)/etc/
+ $(VERSION_SED) $(1)/etc/opkg.conf
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/opkg-cl $(1)/bin/opkg
+endef
+
+define Build/InstallDev
+ mkdir -p $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/libopkg $(1)/usr/include/
+endef
+
+
+HOST_CONFIGURE_ARGS+= \
+ --disable-curl \
+ --disable-gpg \
+ --with-opkgetcdir=/etc \
+ --with-opkglockfile=/tmp/opkg.lock
+
+define Host/Compile
+ +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) CC="$(HOSTCC)" all
+endef
+
+define Host/Install
+ $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/opkg-cl $(STAGING_DIR_HOST)/bin/opkg
+endef
+
+$(eval $(call BuildPackage,opkg))
+$(eval $(call HostBuild))
diff --git a/package/system/opkg/files/opkg.conf b/package/system/opkg/files/opkg.conf
new file mode 100644
index 0000000000..6fb42b7fa4
--- /dev/null
+++ b/package/system/opkg/files/opkg.conf
@@ -0,0 +1,5 @@
+src/gz %n %U
+dest root /
+dest ram /tmp
+lists_dir ext /var/opkg-lists
+option overlay_root /overlay
diff --git a/package/system/opkg/patches/001-ship-pkg-m4.patch b/package/system/opkg/patches/001-ship-pkg-m4.patch
new file mode 100644
index 0000000000..4ca0f88970
--- /dev/null
+++ b/package/system/opkg/patches/001-ship-pkg-m4.patch
@@ -0,0 +1,168 @@
+--- /dev/null
++++ b/m4/pkg.m4
+@@ -0,0 +1,157 @@
++# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
++#
++# Copyright © 2004 Scott James Remnant <scott@netsplit.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.
++#
++# As a special exception to the GNU General Public License, if you
++# distribute this file as part of a program that contains a
++# configuration script generated by Autoconf, you may include it under
++# the same distribution terms that you use for the rest of that program.
++
++# PKG_PROG_PKG_CONFIG([MIN-VERSION])
++# ----------------------------------
++AC_DEFUN([PKG_PROG_PKG_CONFIG],
++[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
++m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
++AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
++if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
++ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
++fi
++if test -n "$PKG_CONFIG"; then
++ _pkg_min_version=m4_default([$1], [0.9.0])
++ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
++ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
++ AC_MSG_RESULT([yes])
++ else
++ AC_MSG_RESULT([no])
++ PKG_CONFIG=""
++ fi
++
++fi[]dnl
++])# PKG_PROG_PKG_CONFIG
++
++# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
++#
++# Check to see whether a particular set of modules exists. Similar
++# to PKG_CHECK_MODULES(), but does not set variables or print errors.
++#
++#
++# Similar to PKG_CHECK_MODULES, make sure that the first instance of
++# this or PKG_CHECK_MODULES is called, or make sure to call
++# PKG_CHECK_EXISTS manually
++# --------------------------------------------------------------
++AC_DEFUN([PKG_CHECK_EXISTS],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++if test -n "$PKG_CONFIG" && \
++ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
++ m4_ifval([$2], [$2], [:])
++m4_ifvaln([$3], [else
++ $3])dnl
++fi])
++
++
++# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
++# ---------------------------------------------
++m4_define([_PKG_CONFIG],
++[if test -n "$PKG_CONFIG"; then
++ if test -n "$$1"; then
++ pkg_cv_[]$1="$$1"
++ else
++ PKG_CHECK_EXISTS([$3],
++ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
++ [pkg_failed=yes])
++ fi
++else
++ pkg_failed=untried
++fi[]dnl
++])# _PKG_CONFIG
++
++# _PKG_SHORT_ERRORS_SUPPORTED
++# -----------------------------
++AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
++ _pkg_short_errors_supported=yes
++else
++ _pkg_short_errors_supported=no
++fi[]dnl
++])# _PKG_SHORT_ERRORS_SUPPORTED
++
++
++# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
++# [ACTION-IF-NOT-FOUND])
++#
++#
++# Note that if there is a possibility the first call to
++# PKG_CHECK_MODULES might not happen, you should be sure to include an
++# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
++#
++#
++# --------------------------------------------------------------
++AC_DEFUN([PKG_CHECK_MODULES],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
++AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
++
++pkg_failed=no
++AC_MSG_CHECKING([for $1])
++
++_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
++_PKG_CONFIG([$1][_LIBS], [libs], [$2])
++
++m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
++and $1[]_LIBS to avoid the need to call pkg-config.
++See the pkg-config man page for more details.])
++
++if test $pkg_failed = yes; then
++ _PKG_SHORT_ERRORS_SUPPORTED
++ if test $_pkg_short_errors_supported = yes; then
++ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
++ else
++ $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
++ fi
++ # Put the nasty error message in config.log where it belongs
++ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
++
++ ifelse([$4], , [AC_MSG_ERROR(dnl
++[Package requirements ($2) were not met:
++
++$$1_PKG_ERRORS
++
++Consider adjusting the PKG_CONFIG_PATH environment variable if you
++installed software in a non-standard prefix.
++
++_PKG_TEXT
++])],
++ [AC_MSG_RESULT([no])
++ $4])
++elif test $pkg_failed = untried; then
++ ifelse([$4], , [AC_MSG_FAILURE(dnl
++[The pkg-config script could not be found or is too old. Make sure it
++is in your PATH or set the PKG_CONFIG environment variable to the full
++path to pkg-config.
++
++_PKG_TEXT
++
++To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
++ [$4])
++else
++ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
++ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
++ AC_MSG_RESULT([yes])
++ ifelse([$3], , :, [$3])
++fi[]dnl
++])# PKG_CHECK_MODULES
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,4 +1,4 @@
+-ACLOCAL_AMFLAGS = -I shave
++ACLOCAL_AMFLAGS = -I shave -I m4
+
+ SUBDIRS = libbb libopkg src tests utils man
+
diff --git a/package/system/opkg/patches/002-no-shave.patch b/package/system/opkg/patches/002-no-shave.patch
new file mode 100644
index 0000000000..313aa71b00
--- /dev/null
+++ b/package/system/opkg/patches/002-no-shave.patch
@@ -0,0 +1,37 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -4,7 +4,6 @@ AC_CONFIG_SRCDIR([libopkg/pkg.c])
+
+ AC_CONFIG_AUX_DIR([conf])
+ AC_CONFIG_MACRO_DIR([m4])
+-AC_CONFIG_MACRO_DIR([shave])
+
+ AM_INIT_AUTOMAKE
+ AM_CONFIG_HEADER(libopkg/config.h)
+@@ -277,9 +276,6 @@ AC_SUBST(opkgetcdir)
+ AC_SUBST(opkglockfile)
+ AC_SUBST([CLEAN_DATE])
+
+-# Setup output beautifier.
+-SHAVE_INIT([shave], [enable])
+-
+ AC_OUTPUT(
+ Makefile
+ libopkg/Makefile
+@@ -289,8 +285,6 @@ AC_OUTPUT(
+ utils/Makefile
+ utils/update-alternatives
+ libopkg.pc
+- shave/shave
+- shave/shave-libtool
+ man/Makefile
+ man/opkg-cl.1
+ man/opkg-key.1
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,4 +1,4 @@
+-ACLOCAL_AMFLAGS = -I shave -I m4
++ACLOCAL_AMFLAGS = -I m4
+
+ SUBDIRS = libbb libopkg src tests utils man
+
diff --git a/package/system/opkg/patches/004-host_cpu.patch b/package/system/opkg/patches/004-host_cpu.patch
new file mode 100644
index 0000000000..d500d603da
--- /dev/null
+++ b/package/system/opkg/patches/004-host_cpu.patch
@@ -0,0 +1,20 @@
+--- a/libbb/Makefile.am
++++ b/libbb/Makefile.am
+@@ -1,6 +1,6 @@
+ HOST_CPU=@host_cpu@
+ BUILD_CPU=@build_cpu@
+-ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@
++ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@
+
+ noinst_LTLIBRARIES = libbb.la
+
+--- a/libopkg/Makefile.am
++++ b/libopkg/Makefile.am
+@@ -1,5 +1,5 @@
+-
+-AM_CFLAGS=-Wall -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DOPKGETCDIR=\"@opkgetcdir@\" -DOPKGLOCKFILE=\"@opkglockfile@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS) $(PATHFINDER_CFLAGS)
++HOST_CPU=@host_cpu@
++AM_CFLAGS=-Wall -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DOPKGETCDIR=\"@opkgetcdir@\" -DOPKGLOCKFILE=\"@opkglockfile@\" -DDATADIR=\"@datadir@\" -I$(top_srcdir) $(BIGENDIAN_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS) $(PATHFINDER_CFLAGS)
+
+ libopkg_includedir=$(includedir)/libopkg
+ libopkg_include_HEADERS= *.h
diff --git a/package/system/opkg/patches/007-force_static.patch b/package/system/opkg/patches/007-force_static.patch
new file mode 100644
index 0000000000..80a9815a8e
--- /dev/null
+++ b/package/system/opkg/patches/007-force_static.patch
@@ -0,0 +1,71 @@
+--- a/libopkg/Makefile.am
++++ b/libopkg/Makefile.am
+@@ -38,16 +38,10 @@ if HAVE_SHA256
+ opkg_util_sources += sha256.c sha256.h
+ endif
+
+-lib_LTLIBRARIES = libopkg.la
+-libopkg_la_SOURCES = \
++noinst_LIBRARIES = libopkg.a
++libopkg_a_SOURCES = \
+ $(opkg_libcore_sources) \
+ $(opkg_cmd_sources) $(opkg_db_sources) \
+ $(opkg_util_sources) $(opkg_list_sources)
+
+-libopkg_la_LIBADD = $(top_builddir)/libbb/libbb.la $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS)
+-
+-# make sure we only export symbols that are for public use
+-#libopkg_la_LDFLAGS = -export-symbols-regex "^opkg_.*"
+-
+-
+-
++libopkg_a_LIBADD = $(top_builddir)/libbb/libbb.a $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS)
+--- a/libbb/Makefile.am
++++ b/libbb/Makefile.am
+@@ -2,9 +2,9 @@ HOST_CPU=@host_cpu@
+ BUILD_CPU=@build_cpu@
+ ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"$(HOST_CPU)\" -DBUILD_CPU=@build_cpu@
+
+-noinst_LTLIBRARIES = libbb.la
++noinst_LIBRARIES = libbb.a
+
+-libbb_la_SOURCES = gz_open.c \
++libbb_a_SOURCES = gz_open.c \
+ libbb.h \
+ unzip.c \
+ wfopen.c \
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -4,11 +4,11 @@ AM_CFLAGS = $(ALL_CFLAGS) -Wall -g -O3 -
+ #noinst_PROGRAMS = libopkg_test opkg_active_list_test
+ noinst_PROGRAMS = libopkg_test
+
+-#opkg_hash_test_LDADD = $(top_builddir)/libbb/libbb.la $(top_builddir)/libopkg/libopkg.la
++#opkg_hash_test_LDADD = $(top_builddir)/libbb/libbb.a $(top_builddir)/libopkg/libopkg.a
+ #opkg_hash_test_SOURCES = opkg_hash_test.c
+ #opkg_hash_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir)
+
+-#opkg_extract_test_LDADD = $(top_builddir)/libbb/libbb.la $(top_builddir)/libopkg/libopkg.la
++#opkg_extract_test_LDADD = $(top_builddir)/libbb/libbb.a $(top_builddir)/libopkg/libopkg.a
+ #opkg_extract_test_SOURCES = opkg_extract_test.c
+ #opkg_extract_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir)
+
+@@ -16,7 +16,7 @@ noinst_PROGRAMS = libopkg_test
+ #opkg_active_list_test_SOURCES = opkg_active_list_test.c
+ #opkg_active_list_test_CFLAGS = $(ALL_CFLAGS) -I$(top_srcdir)
+
+-libopkg_test_LDADD = $(top_builddir)/libopkg/libopkg.la
++libopkg_test_LDADD = $(top_builddir)/libopkg/libopkg.a $(top_builddir)/libbb/libbb.a
+ libopkg_test_SOURCE = libopkg_test.c
+ libopkg_test_LDFLAGS = -static
+
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -2,5 +2,5 @@ AM_CFLAGS = -I${top_srcdir}/libopkg ${AL
+ bin_PROGRAMS = opkg-cl
+
+ opkg_cl_SOURCES = opkg-cl.c
+-opkg_cl_LDADD = $(top_builddir)/libopkg/libopkg.la \
+- $(top_builddir)/libbb/libbb.la
++opkg_cl_LDADD = $(top_builddir)/libopkg/libopkg.a \
++ $(top_builddir)/libbb/libbb.a
diff --git a/package/system/opkg/patches/009-remove-upgrade-all.patch b/package/system/opkg/patches/009-remove-upgrade-all.patch
new file mode 100644
index 0000000000..395a2a6f91
--- /dev/null
+++ b/package/system/opkg/patches/009-remove-upgrade-all.patch
@@ -0,0 +1,41 @@
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -551,18 +551,6 @@ opkg_upgrade_cmd(int argc, char **argv)
+ err = -1;
+ }
+ }
+- } else {
+- pkg_vec_t *installed = pkg_vec_alloc();
+-
+- pkg_info_preinstall_check();
+-
+- pkg_hash_fetch_all_installed(installed);
+- for (i = 0; i < installed->len; i++) {
+- pkg = installed->pkgs[i];
+- if (opkg_upgrade_pkg(pkg))
+- err = -1;
+- }
+- pkg_vec_free(installed);
+ }
+
+ if (opkg_configure_packages(NULL))
+@@ -1258,7 +1246,7 @@ opkg_print_architecture_cmd(int argc, ch
+ array for easier maintenance */
+ static opkg_cmd_t cmds[] = {
+ {"update", 0, (opkg_cmd_fun_t)opkg_update_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+- {"upgrade", 0, (opkg_cmd_fun_t)opkg_upgrade_cmd, PFM_DESCRIPTION|PFM_SOURCE},
++ {"upgrade", 1, (opkg_cmd_fun_t)opkg_upgrade_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"list", 0, (opkg_cmd_fun_t)opkg_list_cmd, PFM_SOURCE},
+ {"list_installed", 0, (opkg_cmd_fun_t)opkg_list_installed_cmd, PFM_SOURCE},
+ {"list-installed", 0, (opkg_cmd_fun_t)opkg_list_installed_cmd, PFM_SOURCE},
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -221,7 +221,7 @@ usage()
+
+ printf("\nPackage Manipulation:\n");
+ printf("\tupdate Update list of available packages\n");
+- printf("\tupgrade Upgrade installed packages\n");
++ printf("\tupgrade <pkgs> Upgrade packages\n");
+ printf("\tinstall <pkgs> Install package(s)\n");
+ printf("\tconfigure <pkgs> Configure unpacked package(s)\n");
+ printf("\tremove <pkgs|regexp> Remove package(s)\n");
diff --git a/package/system/opkg/patches/011-old-config-location.patch b/package/system/opkg/patches/011-old-config-location.patch
new file mode 100644
index 0000000000..0555926864
--- /dev/null
+++ b/package/system/opkg/patches/011-old-config-location.patch
@@ -0,0 +1,12 @@
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -207,6 +207,9 @@ args_parse(int argc, char *argv[])
+ }
+ }
+
++ if(!conf->conf_file && !conf->offline_root)
++ conf->conf_file = xstrdup("/etc/opkg.conf");
++
+ if (parse_err)
+ return parse_err;
+ else
diff --git a/package/system/opkg/patches/012-strip-trailing-conffiles-whitespace.patch b/package/system/opkg/patches/012-strip-trailing-conffiles-whitespace.patch
new file mode 100644
index 0000000000..a47ae77cee
--- /dev/null
+++ b/package/system/opkg/patches/012-strip-trailing-conffiles-whitespace.patch
@@ -0,0 +1,23 @@
+--- a/libopkg/opkg_install.c
++++ b/libopkg/opkg_install.c
+@@ -274,6 +274,7 @@ unpack_pkg_control_files(pkg_t *pkg)
+ while (1) {
+ char *cf_name;
+ char *cf_name_in_dest;
++ int i;
+
+ cf_name = file_read_line_alloc(conffiles_file);
+ if (cf_name == NULL) {
+@@ -282,6 +283,12 @@ unpack_pkg_control_files(pkg_t *pkg)
+ if (cf_name[0] == '\0') {
+ continue;
+ }
++ for (i = strlen(cf_name) - 1;
++ (i >= 0) && (cf_name[i] == ' ' || cf_name[i] == '\t');
++ i--
++ ) {
++ cf_name[i] = '\0';
++ }
+
+ /* Prepend dest->root_dir to conffile name.
+ Take pains to avoid multiple slashes. */
diff --git a/package/system/opkg/patches/014-errors-to-stderr.patch b/package/system/opkg/patches/014-errors-to-stderr.patch
new file mode 100644
index 0000000000..f0a93a8717
--- /dev/null
+++ b/package/system/opkg/patches/014-errors-to-stderr.patch
@@ -0,0 +1,15 @@
+--- a/libopkg/opkg_message.c
++++ b/libopkg/opkg_message.c
+@@ -64,10 +64,10 @@ print_error_list(void)
+ struct errlist *err = error_list_head;
+
+ if (err) {
+- printf("Collected errors:\n");
++ fprintf(stderr, "Collected errors:\n");
+ /* Here we print the errors collected and free the list */
+ while (err != NULL) {
+- printf(" * %s", err->errmsg);
++ fprintf(stderr, " * %s", err->errmsg);
+ err = err->next;
+ }
+ }
diff --git a/package/system/opkg/patches/020-avoid_getline.patch b/package/system/opkg/patches/020-avoid_getline.patch
new file mode 100644
index 0000000000..8a1a8f6272
--- /dev/null
+++ b/package/system/opkg/patches/020-avoid_getline.patch
@@ -0,0 +1,317 @@
+--- a/libopkg/parse_util.c
++++ b/libopkg/parse_util.c
+@@ -22,6 +22,7 @@
+ #include "libbb/libbb.h"
+
+ #include "parse_util.h"
++#include "pkg_parse.h"
+
+ int
+ is_field(const char *type, const char *line)
+@@ -86,3 +87,84 @@ parse_list(const char *raw, unsigned int
+ *count = line_count;
+ return depends;
+ }
++
++int
++parse_from_stream_nomalloc(parse_line_t parse_line, void *item, FILE *fp, uint mask,
++ char **buf0, size_t buf0len)
++{
++ int ret, lineno;
++ char *buf, *nl;
++ size_t buflen;
++
++ lineno = 1;
++ ret = 0;
++
++ buflen = buf0len;
++ buf = *buf0;
++ buf[0] = '\0';
++
++ while (1) {
++ if (fgets(buf, (int)buflen, fp) == NULL) {
++ if (ferror(fp)) {
++ opkg_perror(ERROR, "fgets");
++ ret = -1;
++ } else if (strlen(*buf0) == buf0len-1) {
++ opkg_msg(ERROR, "Missing new line character"
++ " at end of file!\n");
++ parse_line(item, *buf0, mask);
++ }
++ break;
++ }
++
++ nl = strchr(buf, '\n');
++ if (nl == NULL) {
++ if (strlen(buf) < buflen-1) {
++ /*
++ * Line could be exactly buflen-1 long and
++ * missing a newline, but we won't know until
++ * fgets fails to read more data.
++ */
++ opkg_msg(ERROR, "Missing new line character"
++ " at end of file!\n");
++ parse_line(item, *buf0, mask);
++ break;
++ }
++ if (buf0len >= EXCESSIVE_LINE_LEN) {
++ opkg_msg(ERROR, "Excessively long line at "
++ "%d. Corrupt file?\n",
++ lineno);
++ ret = -1;
++ break;
++ }
++
++ /*
++ * Realloc and point buf past the data already read,
++ * at the NULL terminator inserted by fgets.
++ * |<--------------- buf0len ----------------->|
++ * | |<------- buflen ---->|
++ * |---------------------|---------------------|
++ * buf0 buf
++ */
++ buflen = buf0len +1;
++ buf0len *= 2;
++ *buf0 = xrealloc(*buf0, buf0len);
++ buf = *buf0 + buflen -2;
++
++ continue;
++ }
++
++ *nl = '\0';
++
++ lineno++;
++
++ if (parse_line(item, *buf0, mask))
++ break;
++
++ buf = *buf0;
++ buflen = buf0len;
++ buf[0] = '\0';
++ }
++
++ return ret;
++}
++
+--- a/libopkg/parse_util.h
++++ b/libopkg/parse_util.h
+@@ -22,4 +22,8 @@ int is_field(const char *type, const cha
+ char *parse_simple(const char *type, const char *line);
+ char **parse_list(const char *raw, unsigned int *count, const char sep, int skip_field);
+
++typedef int (*parse_line_t)(void *, const char *, uint);
++int parse_from_stream_nomalloc(parse_line_t parse_line, void *item, FILE *fp, uint mask,
++ char **buf0, size_t buf0len);
++
+ #endif
+--- a/libopkg/pkg_hash.c
++++ b/libopkg/pkg_hash.c
+@@ -23,6 +23,7 @@
+ #include "opkg_message.h"
+ #include "pkg_vec.h"
+ #include "pkg_hash.h"
++#include "parse_util.h"
+ #include "pkg_parse.h"
+ #include "opkg_utils.h"
+ #include "sprintf_alloc.h"
+@@ -119,8 +120,14 @@ pkg_hash_add_from_file(const char *file_
+ pkg->src = src;
+ pkg->dest = dest;
+
+- ret = pkg_parse_from_stream_nomalloc(pkg, fp, 0,
++ ret = parse_from_stream_nomalloc(pkg_parse_line, pkg, fp, 0,
+ &buf, len);
++
++ if (pkg->name == NULL) {
++ /* probably just a blank line */
++ ret = 1;
++ }
++
+ if (ret) {
+ pkg_deinit (pkg);
+ free(pkg);
+--- a/libopkg/pkg_parse.c
++++ b/libopkg/pkg_parse.c
+@@ -104,9 +104,11 @@ get_arch_priority(const char *arch)
+ return 0;
+ }
+
+-static int
+-pkg_parse_line(pkg_t *pkg, const char *line, uint mask)
++int
++pkg_parse_line(void *ptr, const char *line, uint mask)
+ {
++ pkg_t *pkg = (pkg_t *) ptr;
++
+ /* these flags are a bit hackish... */
+ static int reading_conffiles = 0, reading_description = 0;
+ int ret = 0;
+@@ -266,91 +268,6 @@ dont_reset_flags:
+ }
+
+ int
+-pkg_parse_from_stream_nomalloc(pkg_t *pkg, FILE *fp, uint mask,
+- char **buf0, size_t buf0len)
+-{
+- int ret, lineno;
+- char *buf, *nl;
+- size_t buflen;
+-
+- lineno = 1;
+- ret = 0;
+-
+- buflen = buf0len;
+- buf = *buf0;
+- buf[0] = '\0';
+-
+- while (1) {
+- if (fgets(buf, (int)buflen, fp) == NULL) {
+- if (ferror(fp)) {
+- opkg_perror(ERROR, "fgets");
+- ret = -1;
+- } else if (strlen(*buf0) == buf0len-1) {
+- opkg_msg(ERROR, "Missing new line character"
+- " at end of file!\n");
+- pkg_parse_line(pkg, *buf0, mask);
+- }
+- break;
+- }
+-
+- nl = strchr(buf, '\n');
+- if (nl == NULL) {
+- if (strlen(buf) < buflen-1) {
+- /*
+- * Line could be exactly buflen-1 long and
+- * missing a newline, but we won't know until
+- * fgets fails to read more data.
+- */
+- opkg_msg(ERROR, "Missing new line character"
+- " at end of file!\n");
+- pkg_parse_line(pkg, *buf0, mask);
+- break;
+- }
+- if (buf0len >= EXCESSIVE_LINE_LEN) {
+- opkg_msg(ERROR, "Excessively long line at "
+- "%d. Corrupt file?\n",
+- lineno);
+- ret = -1;
+- break;
+- }
+-
+- /*
+- * Realloc and point buf past the data already read,
+- * at the NULL terminator inserted by fgets.
+- * |<--------------- buf0len ----------------->|
+- * | |<------- buflen ---->|
+- * |---------------------|---------------------|
+- * buf0 buf
+- */
+- buflen = buf0len +1;
+- buf0len *= 2;
+- *buf0 = xrealloc(*buf0, buf0len);
+- buf = *buf0 + buflen -2;
+-
+- continue;
+- }
+-
+- *nl = '\0';
+-
+- lineno++;
+-
+- if (pkg_parse_line(pkg, *buf0, mask))
+- break;
+-
+- buf = *buf0;
+- buflen = buf0len;
+- buf[0] = '\0';
+- }
+-
+- if (pkg->name == NULL) {
+- /* probably just a blank line */
+- ret = 1;
+- }
+-
+- return ret;
+-}
+-
+-int
+ pkg_parse_from_stream(pkg_t *pkg, FILE *fp, uint mask)
+ {
+ int ret;
+@@ -358,8 +275,13 @@ pkg_parse_from_stream(pkg_t *pkg, FILE *
+ const size_t len = 4096;
+
+ buf = xmalloc(len);
+- ret = pkg_parse_from_stream_nomalloc(pkg, fp, mask, &buf, len);
++ ret = parse_from_stream_nomalloc(pkg_parse_line, pkg, fp, mask, &buf, len);
+ free(buf);
+
++ if (pkg->name == NULL) {
++ /* probably just a blank line */
++ ret = 1;
++ }
++
+ return ret;
+ }
+--- a/libopkg/pkg_parse.h
++++ b/libopkg/pkg_parse.h
+@@ -18,10 +18,11 @@
+ #ifndef PKG_PARSE_H
+ #define PKG_PARSE_H
+
++#include "pkg.h"
++
+ int parse_version(pkg_t *pkg, const char *raw);
+ int pkg_parse_from_stream(pkg_t *pkg, FILE *fp, uint mask);
+-int pkg_parse_from_stream_nomalloc(pkg_t *pkg, FILE *fp, uint mask,
+- char **buf0, size_t buf0len);
++int pkg_parse_line(void *ptr, const char *line, uint mask);
+
+ #define EXCESSIVE_LINE_LEN (4096 << 8)
+
+--- a/libopkg/release_parse.c
++++ b/libopkg/release_parse.c
+@@ -23,8 +23,10 @@
+ #include "parse_util.h"
+
+ static int
+-release_parse_line(release_t *release, const char *line)
++release_parse_line(void *ptr, const char *line, uint mask)
+ {
++ release_t *release = (release_t *) ptr;
++
+ int ret = 0;
+ unsigned int count = 0;
+ char **list = 0;
+@@ -111,25 +113,14 @@ dont_reset_flags:
+ int
+ release_parse_from_stream(release_t *release, FILE *fp)
+ {
+- int ret = 0;
+- char *buf = NULL;
+- size_t buflen, nread;
+-
+- nread = getline(&buf, &buflen, fp);
+- while ( nread != -1 ) {
+- if (buf[nread-1] == '\n') buf[nread-1] = '\0';
+- if (release_parse_line(release, buf))
+- opkg_msg(DEBUG, "Failed to parse release line for %s:\n\t%s\n",
+- release->name, buf);
+- nread = getline(&buf, &buflen, fp);
+- }
+-
+- if (!feof(fp)) {
+- opkg_perror(ERROR, "Problems reading Release file for %sd\n", release->name);
+- ret = -1;
+- }
++ int ret;
++ char *buf;
++ const size_t len = 4096;
+
++ buf = xmalloc(len);
++ ret = parse_from_stream_nomalloc(release_parse_line, release, fp, 0, &buf, len);
+ free(buf);
++
+ return ret;
+ }
+
diff --git a/package/system/opkg/patches/030-fix-double-free.patch b/package/system/opkg/patches/030-fix-double-free.patch
new file mode 100644
index 0000000000..312e06c548
--- /dev/null
+++ b/package/system/opkg/patches/030-fix-double-free.patch
@@ -0,0 +1,10 @@
+--- a/libopkg/opkg_remove.c
++++ b/libopkg/opkg_remove.c
+@@ -138,7 +138,6 @@ opkg_remove_dependent_pkgs(pkg_t *pkg, a
+ for (i = 0; i < dependent_pkgs->len; i++) {
+ err = opkg_remove_pkg(dependent_pkgs->pkgs[i],0);
+ if (err) {
+- pkg_vec_free(dependent_pkgs);
+ break;
+ }
+ }
diff --git a/package/system/opkg/patches/040-wrap-descriptions-only-on-ttys.patch b/package/system/opkg/patches/040-wrap-descriptions-only-on-ttys.patch
new file mode 100644
index 0000000000..95406687b6
--- /dev/null
+++ b/package/system/opkg/patches/040-wrap-descriptions-only-on-ttys.patch
@@ -0,0 +1,31 @@
+--- a/libopkg/pkg_parse.c
++++ b/libopkg/pkg_parse.c
+@@ -20,6 +20,7 @@
+
+ #include <stdio.h>
+ #include <ctype.h>
++#include <unistd.h>
+
+ #include "pkg.h"
+ #include "opkg_utils.h"
+@@ -239,10 +240,16 @@ pkg_parse_line(void *ptr, const char *li
+
+ case ' ':
+ if ((mask & PFM_DESCRIPTION) && reading_description) {
+- pkg->description = xrealloc(pkg->description,
+- strlen(pkg->description)
+- + 1 + strlen(line) + 1);
+- strcat(pkg->description, "\n");
++ if (isatty(1)) {
++ pkg->description = xrealloc(pkg->description,
++ strlen(pkg->description)
++ + 1 + strlen(line) + 1);
++ strcat(pkg->description, "\n");
++ } else {
++ pkg->description = xrealloc(pkg->description,
++ strlen(pkg->description)
++ + 1 + strlen(line));
++ }
+ strcat(pkg->description, (line));
+ goto dont_reset_flags;
+ } else if ((mask & PFM_CONFFILES) && reading_conffiles) {
diff --git a/package/system/opkg/patches/050-add-case-insensitive-flag.patch b/package/system/opkg/patches/050-add-case-insensitive-flag.patch
new file mode 100644
index 0000000000..4b9215b87a
--- /dev/null
+++ b/package/system/opkg/patches/050-add-case-insensitive-flag.patch
@@ -0,0 +1,169 @@
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -436,7 +436,7 @@ opkg_configure_packages(char *pkg_name)
+ for(i = 0; i < ordered->len; i++) {
+ pkg = ordered->pkgs[i];
+
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+
+ if (pkg->state_status == SS_UNPACKED) {
+@@ -610,7 +610,7 @@ opkg_list_cmd(int argc, char **argv)
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+ print_pkg(pkg);
+ }
+@@ -637,7 +637,7 @@ opkg_list_installed_cmd(int argc, char *
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+ print_pkg(pkg);
+ }
+@@ -666,7 +666,7 @@ opkg_list_changed_conffiles_cmd(int argc
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
+ continue;
+ if (nv_pair_list_empty(&pkg->conffiles))
+ continue;
+@@ -722,7 +722,7 @@ opkg_info_status_cmd(int argc, char **ar
+
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+- if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) {
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase)) {
+ continue;
+ }
+
+@@ -792,7 +792,7 @@ opkg_remove_cmd(int argc, char **argv)
+ for (i=0; i<argc; i++) {
+ for (a=0; a<available->len; a++) {
+ pkg = available->pkgs[a];
+- if (fnmatch(argv[i], pkg->name, 0)) {
++ if (fnmatch(argv[i], pkg->name, conf->nocase)) {
+ continue;
+ }
+ if (conf->restrict_to_default_dest) {
+@@ -926,7 +926,7 @@ opkg_depends_cmd(int argc, char **argv)
+ for (j=0; j<available_pkgs->len; j++) {
+ pkg = available_pkgs->pkgs[j];
+
+- if (fnmatch(argv[i], pkg->name, 0) != 0)
++ if (fnmatch(argv[i], pkg->name, conf->nocase) != 0)
+ continue;
+
+ depends_count = pkg->depends_count +
+@@ -1147,9 +1147,9 @@ opkg_what_provides_replaces_cmd(enum wha
+ ((what_field_type == WHATPROVIDES)
+ ? pkg->provides[k]
+ : pkg->replaces[k]);
+- if (fnmatch(target, apkg->name, 0) == 0) {
++ if (fnmatch(target, apkg->name, conf->nocase) == 0) {
+ opkg_msg(NOTICE, " %s", pkg->name);
+- if (strcmp(target, apkg->name) != 0)
++ if ((conf->nocase ? strcasecmp(target, apkg->name) : strcmp(target, apkg->name)) != 0)
+ opkg_msg(NOTICE, "\t%s %s\n",
+ rel_str, apkg->name);
+ opkg_message(NOTICE, "\n");
+@@ -1200,7 +1200,7 @@ opkg_search_cmd(int argc, char **argv)
+
+ for (iter = str_list_first(installed_files); iter; iter = str_list_next(installed_files, iter)) {
+ installed_file = (char *)iter->data;
+- if (fnmatch(argv[0], installed_file, 0)==0)
++ if (fnmatch(argv[0], installed_file, conf->nocase)==0)
+ print_pkg(pkg);
+ }
+
+--- a/libopkg/opkg_conf.c
++++ b/libopkg/opkg_conf.c
+@@ -62,6 +62,7 @@ opkg_option_t options[] = {
+ { "noaction", OPKG_OPT_TYPE_BOOL, &_conf.noaction },
+ { "download_only", OPKG_OPT_TYPE_BOOL, &_conf.download_only },
+ { "nodeps", OPKG_OPT_TYPE_BOOL, &_conf.nodeps },
++ { "nocase", OPKG_OPT_TYPE_BOOL, &_conf.nocase },
+ { "offline_root", OPKG_OPT_TYPE_STRING, &_conf.offline_root },
+ { "overlay_root", OPKG_OPT_TYPE_STRING, &_conf.overlay_root },
+ { "proxy_passwd", OPKG_OPT_TYPE_STRING, &_conf.proxy_passwd },
+--- a/libopkg/opkg_conf.h
++++ b/libopkg/opkg_conf.h
+@@ -24,6 +24,7 @@ extern opkg_conf_t *conf;
+ #include "config.h"
+
+ #include <stdarg.h>
++#include <fnmatch.h> /* FNM_CASEFOLD */
+
+ #include "hash_table.h"
+ #include "pkg_src_list.h"
+@@ -79,6 +80,7 @@ struct opkg_conf
+ int force_remove;
+ int check_signature;
+ int nodeps; /* do not follow dependencies */
++ int nocase; /* perform case insensitive matching */
+ char *offline_root;
+ char *overlay_root;
+ int query_all;
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -47,6 +47,7 @@ enum {
+ ARGS_OPT_NOACTION,
+ ARGS_OPT_DOWNLOAD_ONLY,
+ ARGS_OPT_NODEPS,
++ ARGS_OPT_NOCASE,
+ ARGS_OPT_AUTOREMOVE,
+ ARGS_OPT_CACHE,
+ };
+@@ -86,6 +87,7 @@ static struct option long_options[] = {
+ {"noaction", 0, 0, ARGS_OPT_NOACTION},
+ {"download-only", 0, 0, ARGS_OPT_DOWNLOAD_ONLY},
+ {"nodeps", 0, 0, ARGS_OPT_NODEPS},
++ {"nocase", 0, 0, ARGS_OPT_NOCASE},
+ {"offline", 1, 0, 'o'},
+ {"offline-root", 1, 0, 'o'},
+ {"add-arch", 1, 0, ARGS_OPT_ADD_ARCH},
+@@ -107,7 +109,7 @@ args_parse(int argc, char *argv[])
+ char *tuple, *targ;
+
+ while (1) {
+- c = getopt_long_only(argc, argv, "Ad:f:no:p:t:vV::",
++ c = getopt_long_only(argc, argv, "Ad:f:ino:p:t:vV::",
+ long_options, &option_index);
+ if (c == -1)
+ break;
+@@ -122,6 +124,9 @@ args_parse(int argc, char *argv[])
+ case 'f':
+ conf->conf_file = xstrdup(optarg);
+ break;
++ case 'i':
++ conf->nocase = FNM_CASEFOLD;
++ break;
+ case 'o':
+ conf->offline_root = xstrdup(optarg);
+ break;
+@@ -176,6 +181,9 @@ args_parse(int argc, char *argv[])
+ case ARGS_OPT_NODEPS:
+ conf->nodeps = 1;
+ break;
++ case ARGS_OPT_NOCASE:
++ conf->nocase = FNM_CASEFOLD;
++ break;
+ case ARGS_OPT_ADD_ARCH:
+ case ARGS_OPT_ADD_DEST:
+ tuple = xstrdup(optarg);
+@@ -287,6 +295,7 @@ usage()
+ printf("\t--noaction No action -- test only\n");
+ printf("\t--download-only No action -- download only\n");
+ printf("\t--nodeps Do not follow dependencies\n");
++ printf("\t--nocase Perform case insensitive pattern matching\n");
+ printf("\t--force-removal-of-dependent-packages\n");
+ printf("\t Remove package and all dependencies\n");
+ printf("\t--autoremove Remove packages that were installed\n");
diff --git a/package/system/opkg/patches/060-add-find-command.patch b/package/system/opkg/patches/060-add-find-command.patch
new file mode 100644
index 0000000000..17625349f8
--- /dev/null
+++ b/package/system/opkg/patches/060-add-find-command.patch
@@ -0,0 +1,58 @@
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -594,7 +594,7 @@ opkg_download_cmd(int argc, char **argv)
+
+
+ static int
+-opkg_list_cmd(int argc, char **argv)
++opkg_list_find_cmd(int argc, char **argv, int use_desc)
+ {
+ int i;
+ pkg_vec_t *available;
+@@ -610,7 +610,8 @@ opkg_list_cmd(int argc, char **argv)
+ for (i=0; i < available->len; i++) {
+ pkg = available->pkgs[i];
+ /* if we have package name or pattern and pkg does not match, then skip it */
+- if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
++ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase) &&
++ (!use_desc || !pkg->description || fnmatch(pkg_name, pkg->description, conf->nocase)))
+ continue;
+ print_pkg(pkg);
+ }
+@@ -619,6 +620,18 @@ opkg_list_cmd(int argc, char **argv)
+ return 0;
+ }
+
++static int
++opkg_list_cmd(int argc, char **argv)
++{
++ return opkg_list_find_cmd(argc, argv, 0);
++}
++
++static int
++opkg_find_cmd(int argc, char **argv)
++{
++ return opkg_list_find_cmd(argc, argv, 1);
++}
++
+
+ static int
+ opkg_list_installed_cmd(int argc, char **argv)
+@@ -1262,6 +1275,7 @@ static opkg_cmd_t cmds[] = {
+ {"configure", 0, (opkg_cmd_fun_t)opkg_configure_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"files", 1, (opkg_cmd_fun_t)opkg_files_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"search", 1, (opkg_cmd_fun_t)opkg_search_cmd, PFM_DESCRIPTION|PFM_SOURCE},
++ {"find", 1, (opkg_cmd_fun_t)opkg_find_cmd, PFM_SOURCE},
+ {"download", 1, (opkg_cmd_fun_t)opkg_download_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"compare_versions", 1, (opkg_cmd_fun_t)opkg_compare_versions_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+ {"compare-versions", 1, (opkg_cmd_fun_t)opkg_compare_versions_cmd, PFM_DESCRIPTION|PFM_SOURCE},
+--- a/src/opkg-cl.c
++++ b/src/opkg-cl.c
+@@ -246,6 +246,7 @@ usage()
+ printf("\tlist-changed-conffiles List user modified configuration files\n");
+ printf("\tfiles <pkg> List files belonging to <pkg>\n");
+ printf("\tsearch <file|regexp> List package providing <file>\n");
++ printf("\tfind <regexp> List packages whose name or description matches <regexp>\n");
+ printf("\tinfo [pkg|regexp] Display all info for <pkg>\n");
+ printf("\tstatus [pkg|regexp] Display all status for <pkg>\n");
+ printf("\tdownload <pkg> Download <pkg> to current directory\n");
diff --git a/package/system/opkg/patches/070-use_gzipped_pkg_list.patch b/package/system/opkg/patches/070-use_gzipped_pkg_list.patch
new file mode 100644
index 0000000000..d32b519182
--- /dev/null
+++ b/package/system/opkg/patches/070-use_gzipped_pkg_list.patch
@@ -0,0 +1,120 @@
+--- a/libopkg/opkg.c
++++ b/libopkg/opkg.c
+@@ -592,49 +592,8 @@ opkg_update_package_lists(opkg_progress_
+ src->gzip ? "Packages.gz" : "Packages");
+
+ sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
+- if (src->gzip) {
+- FILE *in, *out;
+- struct _curl_cb_data cb_data;
+- char *tmp_file_name = NULL;
+
+- sprintf_alloc(&tmp_file_name, "%s/%s.gz", tmp,
+- src->name);
+-
+- opkg_msg(INFO, "Downloading %s to %s...\n", url,
+- tmp_file_name);
+-
+- cb_data.cb = progress_callback;
+- cb_data.progress_data = &pdata;
+- cb_data.user_data = user_data;
+- cb_data.start_range =
+- 100 * sources_done / sources_list_count;
+- cb_data.finish_range =
+- 100 * (sources_done + 1) / sources_list_count;
+-
+- err = opkg_download(url, tmp_file_name,
+- (curl_progress_func) curl_progress_cb,
+- &cb_data, 0);
+-
+- if (err == 0) {
+- opkg_msg(INFO, "Inflating %s...\n",
+- tmp_file_name);
+- in = fopen(tmp_file_name, "r");
+- out = fopen(list_file_name, "w");
+- if (in && out)
+- unzip(in, out);
+- else
+- err = 1;
+- if (in)
+- fclose(in);
+- if (out)
+- fclose(out);
+- unlink(tmp_file_name);
+- }
+- free(tmp_file_name);
+- } else
+- err = opkg_download(url, list_file_name, NULL, NULL, 0);
+-
+- if (err) {
++ if (opkg_download(url, list_file_name, NULL, NULL, 0)) {
+ opkg_msg(ERROR, "Couldn't retrieve %s\n", url);
+ result = -1;
+ }
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -162,30 +162,7 @@ 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);
+- if (src->gzip) {
+- char *tmp_file_name;
+- FILE *in, *out;
+-
+- sprintf_alloc (&tmp_file_name, "%s/%s.gz", tmp, src->name);
+- err = opkg_download(url, tmp_file_name, NULL, NULL, 0);
+- if (err == 0) {
+- opkg_msg(NOTICE, "Inflating %s.\n", url);
+- in = fopen (tmp_file_name, "r");
+- out = fopen (list_file_name, "w");
+- if (in && out)
+- unzip (in, out);
+- else
+- err = 1;
+- if (in)
+- fclose (in);
+- if (out)
+- fclose (out);
+- unlink (tmp_file_name);
+- }
+- free(tmp_file_name);
+- } else
+- err = opkg_download(url, list_file_name, NULL, NULL, 0);
+- if (err) {
++ if (opkg_download(url, list_file_name, NULL, NULL, 0)) {
+ failures++;
+ } else {
+ opkg_msg(NOTICE, "Updated list of available packages in %s.\n",
+--- a/libopkg/pkg_hash.c
++++ b/libopkg/pkg_hash.c
+@@ -102,12 +102,18 @@ pkg_hash_add_from_file(const char *file_
+ pkg_src_t *src, pkg_dest_t *dest, int is_status_file)
+ {
+ pkg_t *pkg;
+- FILE *fp;
++ FILE *fp, *fp_c = NULL;
+ char *buf;
+ const size_t len = 4096;
+ int ret = 0;
++ int pid;
+
+ fp = fopen(file_name, "r");
++ if (fp && src && src->gzip) {
++ fp_c = fp;
++ fp = gz_open(fp_c, &pid);
++ }
++
+ if (fp == NULL) {
+ opkg_perror(ERROR, "Failed to open %s", file_name);
+ return -1;
+@@ -154,6 +160,10 @@ pkg_hash_add_from_file(const char *file_
+
+ free(buf);
+ fclose(fp);
++ if (fp_c) {
++ fclose(fp_c);
++ gz_close(pid);
++ }
+
+ return ret;
+ }
diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile
new file mode 100644
index 0000000000..b94cd2e78b
--- /dev/null
+++ b/package/system/procd/Makefile
@@ -0,0 +1,40 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=procd
+PKG_VERSION:=2013-06-19
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/luci2/procd.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=c23413feeb5179911d623e6ffb84b36671652788
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+TARGET_LDFLAGS += $(if $(CONFIG_USE_EGLIBC),-lrt)
+
+define Package/procd
+ SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=+ubusd +ubus +libjson-script +ubox +USE_EGLIBC:librt
+ TITLE:=OpenWrt system process manager
+endef
+
+define Package/procd/install
+ $(INSTALL_DIR) $(1)/sbin $(1)/lib/functions $(1)/etc
+
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/{procd,askfirst,udevtrigger,logread} $(1)/sbin/
+ $(INSTALL_DATA) ./files/hotplug*.json $(1)/etc/
+ $(INSTALL_DATA) ./files/procd.sh $(1)/lib/functions/
+ ln -s /sbin/procd $(1)/sbin/init
+endef
+
+$(eval $(call BuildPackage,procd))
diff --git a/package/system/procd/files/hotplug-preinit.json b/package/system/procd/files/hotplug-preinit.json
new file mode 100644
index 0000000000..614b104711
--- /dev/null
+++ b/package/system/procd/files/hotplug-preinit.json
@@ -0,0 +1,20 @@
+[
+ [ "case", "ACTION", {
+ "add": [
+ [ "if",
+ [ "has", "FIRMWARE" ],
+ [
+ [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ],
+ [ "load-firmware", "/lib/firmware" ],
+ [ "return" ]
+ ]
+ ],
+ ],
+ }, ],
+ [ "if",
+ [ "and",
+ [ "eq", "SUBSYSTEM", "button" ],
+ ],
+ [ "exec", "/etc/rc.button/failsafe" ]
+ ],
+]
diff --git a/package/system/procd/files/hotplug.json b/package/system/procd/files/hotplug.json
new file mode 100644
index 0000000000..c1b45c6e86
--- /dev/null
+++ b/package/system/procd/files/hotplug.json
@@ -0,0 +1,77 @@
+[
+ [ "case", "ACTION", {
+ "add": [
+ [ "if",
+ [ "and",
+ [ "has", "MAJOR" ],
+ [ "has", "MINOR" ],
+ ],
+ [
+ [ "if",
+ [ "or",
+ [ "eq", "DEVNAME",
+ [ "null", "full", "ptmx", "zero" ],
+ ],
+ [ "regex", "DEVNAME",
+ [ "^gpio", "^hvc", "^tty" ],
+ ],
+ ],
+ [
+ [ "makedev", "/dev/%DEVNAME%", "0666" ],
+ [ "return" ],
+ ]
+ ],
+ [ "if",
+ [ "or",
+ [ "eq", "DEVNAME", "mapper/control" ],
+ [ "regex", "DEVPATH", "^ppp" ],
+ ],
+ [
+ [ "makedev", "/dev/%DEVNAME%", "0600" ],
+ [ "return" ],
+ ],
+ ],
+ [ "if",
+ [ "has", "DEVNAME" ],
+ [ "makedev", "/dev/%DEVNAME%", "0644" ],
+ ],
+ ],
+ ],
+ [ "if",
+ [ "has", "FIRMWARE" ],
+ [
+ [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ],
+ [ "load-firmware", "/lib/firmware" ],
+ [ "return" ]
+ ]
+ ],
+ ],
+ "remove" : [
+ [ "if",
+ [ "and",
+ [ "has", "DEVNAME" ],
+ [ "has", "MAJOR" ],
+ [ "has", "MINOR" ],
+ ],
+ [ "rm", "/dev/%DEVNAME%" ]
+ ]
+ ]
+ } ],
+ [ "if",
+ [ "eq", "SUBSYSTEM", "platform" ],
+ [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
+ ],
+ [ "if",
+ [ "and",
+ [ "has", "BUTTON" ],
+ [ "eq", "SUBSYSTEM", "button" ],
+ ],
+ [ "exec", "/etc/rc.button/%BUTTON%" ]
+ ],
+ [ "if",
+ [ "eq", "SUBSYSTEM",
+ [ "net", "input", "usb", "ieee1394", "block", "atm", "zaptel", "tty" ]
+ ],
+ [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
+ ],
+]
diff --git a/package/system/procd/files/procd.init b/package/system/procd/files/procd.init
new file mode 100644
index 0000000000..3df5f48e60
--- /dev/null
+++ b/package/system/procd/files/procd.init
@@ -0,0 +1,19 @@
+#!/bin/sh /etc/rc.common
+
+START=11
+
+start_stop() {
+ start-stop-daemon $1 -b -m -p /var/run/procd.pid -x /sbin/procd
+}
+
+start() {
+ start_stop -S
+}
+
+reload() {
+ return
+}
+
+stop() {
+ start_stop -K
+}
diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh
new file mode 100644
index 0000000000..e771e0c156
--- /dev/null
+++ b/package/system/procd/files/procd.sh
@@ -0,0 +1,171 @@
+# procd API:
+#
+# procd_open_service(name, [script]):
+# Initialize a new procd command message containing a service with one or more instances
+#
+# procd_close_service()
+# Send the command message for the service
+#
+# procd_open_instance([name]):
+# Add an instance to the service described by the previous procd_open_service call
+#
+# procd_set_param(type, [value...])
+# Available types:
+# command: command line (array).
+# env: environment variable (passed to the process)
+# data: arbitrary name/value pairs for detecting config changes (table)
+# file: configuration files (array)
+# netdev: bound network device (detects ifindex changes)
+#
+# No space separation is done for arrays/tables - use one function argument per command line argument
+#
+# procd_close_instance():
+# Complete the instance being prepared
+#
+# procd_kill(service, [instance]):
+# Kill a service instance (or all instances)
+#
+
+. $IPKG_INSTROOT/usr/share/libubox/jshn.sh
+
+_PROCD_SERVICE=
+
+_procd_call() {
+ local old_cb
+
+ json_set_namespace procd old_cb
+ "$@"
+ json_set_namespace $old_cb
+}
+
+_procd_wrapper() {
+ while [ -n "$1" ]; do
+ eval "$1() { _procd_call _$1 \"\$@\"; }"
+ shift
+ done
+}
+
+_procd_ubus_call() {
+ local cmd="$1"
+
+ ubus call service "$cmd" "$(json_dump)"
+ json_cleanup
+}
+
+_procd_open_service() {
+ local name="$1"
+ local script="$2"
+
+ _PROCD_SERVICE="$name"
+ _PROCD_INSTANCE_SEQ=0
+
+ json_init
+ json_add_string name "$name"
+ [ -n "$script" ] && json_add_string script "$script"
+ json_add_object instances
+}
+
+_procd_close_service() {
+ json_close_object
+ _procd_ubus_call set
+}
+
+_procd_add_array_data() {
+ while [ -n "$1" ]; do
+ json_add_string "" "$1"
+ shift
+ done
+}
+
+_procd_add_array() {
+ json_add_array "$1"
+ shift
+ _procd_add_array_data "$@"
+ json_close_array
+}
+
+_procd_add_table_data() {
+ while [ -n "$1" ]; do
+ local var="${1%%=*}"
+ local val="${1#*=}"
+ [[ "$1" == "$val" ]] && val=
+ json_add_string "$var" "$val"
+ shift
+ done
+}
+
+_procd_add_table() {
+ json_add_object "$1"
+ shift
+ _procd_add_table_data "$@"
+ json_close_object
+}
+
+_procd_open_instance() {
+ local name="$1"; shift
+
+ _PROCD_INSTANCE_SEQ="$(($_PROCD_INSTANCE_SEQ + 1))"
+ name="${name:-instance$_PROCD_INSTANCE_SEQ}"
+ json_add_object "$name"
+}
+
+_procd_set_param() {
+ local type="$1"; shift
+
+ case "$type" in
+ env|data)
+ _procd_add_table "$type" "$@"
+ ;;
+ command|netdev|file)
+ _procd_add_array "$type" "$@"
+ ;;
+ nice)
+ json_add_int "$type" "$1"
+ ;;
+ esac
+}
+
+_procd_append_param() {
+ local type="$1"; shift
+
+ json_select "$type"
+ case "$type" in
+ env|data)
+ _procd_add_table_data "$@"
+ ;;
+ command|netdev|file)
+ _procd_add_array_data "$@"
+ ;;
+ esac
+ json_select ..
+}
+
+_procd_close_instance() {
+ json_close_object
+}
+
+_procd_add_instance() {
+ _procd_open_instance
+ _procd_set_command "$@"
+ _procd_close_instance
+}
+
+_procd_kill() {
+ local service="$1"
+ local instance="$2"
+
+ json_init
+ [ -n "$service" ] && json_add_string service "$service"
+ [ -n "$instance" ] && json_add_string instance "$instance"
+ _procd_ubus_call delete
+}
+
+_procd_wrapper \
+ procd_open_service \
+ procd_close_service \
+ procd_add_instance \
+ procd_open_instance \
+ procd_close_instance \
+ procd_set_param \
+ procd_append_param \
+ procd_kill
diff --git a/package/system/rotary-gpio-custom/Makefile b/package/system/rotary-gpio-custom/Makefile
deleted file mode 100644
index 315ec31f4b..0000000000
--- a/package/system/rotary-gpio-custom/Makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# Copyright (C) 2008-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)/kernel.mk
-
-PKG_NAME:=rotary-gpio-custom
-PKG_RELEASE:=1
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/rotary-gpio-custom
- SUBMENU:=Other modules
- TITLE:=Custom GPIO-based rotary encoder device
- DEPENDS:=@GPIO_SUPPORT +kmod-input-gpio-encoder
- FILES:=$(PKG_BUILD_DIR)/rotary-gpio-custom.ko
- KCONFIG:=
-endef
-
-define KernelPackage/rotary-gpio-custom/description
- Kernel module for register a custom rotary-gpio-encoder platform device.
-endef
-
-EXTRA_KCONFIG:= \
- CONFIG_ROTARY_GPIO_CUSTOM=m
-
-EXTRA_CFLAGS:= \
- $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
- $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
-
-MAKE_OPTS:= \
- ARCH="$(LINUX_KARCH)" \
- CROSS_COMPILE="$(TARGET_CROSS)" \
- SUBDIRS="$(PKG_BUILD_DIR)" \
- EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
- $(EXTRA_KCONFIG)
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
- $(CP) ./src/* $(PKG_BUILD_DIR)/
-endef
-
-define Build/Compile
- $(MAKE) -C "$(LINUX_DIR)" \
- $(MAKE_OPTS) \
- modules
-endef
-
-$(eval $(call KernelPackage,rotary-gpio-custom))
diff --git a/package/system/rotary-gpio-custom/src/Kconfig b/package/system/rotary-gpio-custom/src/Kconfig
deleted file mode 100644
index b4d55d5354..0000000000
--- a/package/system/rotary-gpio-custom/src/Kconfig
+++ /dev/null
@@ -1,9 +0,0 @@
-config ROTARY_GPIO_CUSTOM
- tristate "Custom GPIO-based rotary driver"
- depends on GENERIC_GPIO
- help
- This is a driver to register 1 to 4 custom rotary encoder using
- GPIO lines.
-
- This support is also available as a module. If so, the module
- will be called rotary-gpio-custom.
diff --git a/package/system/rotary-gpio-custom/src/Makefile b/package/system/rotary-gpio-custom/src/Makefile
deleted file mode 100644
index 133672687b..0000000000
--- a/package/system/rotary-gpio-custom/src/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-${CONFIG_ROTARY_GPIO_CUSTOM} += rotary-gpio-custom.o
diff --git a/package/system/rotary-gpio-custom/src/rotary-gpio-custom.c b/package/system/rotary-gpio-custom/src/rotary-gpio-custom.c
deleted file mode 100644
index 8cd8ef12ab..0000000000
--- a/package/system/rotary-gpio-custom/src/rotary-gpio-custom.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Custom GPIO-based rotary driver
- *
- * Copyright (C) 2010 Claudio Mignanti <c.mignanti@gmail.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.
- *
- * Strongly based on Custom GPIO-based I2C driver by:
- * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
- *
- * ---------------------------------------------------------------------------
- *
- * The behaviour of this driver can be altered by setting some parameters
- * from the insmod command line.
- *
- * The following parameters are adjustable:
- *
- * bus0 These four arguments can be arrays of
- * bus1 1-8 unsigned integers as follows:
- * bus2
- * bus3 <id>,<steps>,<axis>,<gpioa>,<gpiob>,<inverted>
- *
- *
- * If this driver is built into the kernel, you can use the following kernel
- * command line parameters, with the same values as the corresponding module
- * parameters listed above:
- *
- * rotary-gpio-custom.bus0
- * rotary-gpio-custom.bus1
- * rotary-gpio-custom.bus2
- * rotary-gpio-custom.bus3
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/input.h>
-#include <linux/platform_device.h>
-#include <linux/rotary_encoder.h>
-
-#define DRV_NAME "rotary-gpio-custom"
-#define DRV_DESC "Custom GPIO-based rotary driver"
-#define DRV_VERSION "0.1.0"
-
-#define PFX DRV_NAME ": "
-
-#define BUS_PARAM_REQUIRED 5
-#define BUS_PARAM_COUNT 6
-#define BUS_COUNT_MAX 4
-
-static unsigned int bus0[BUS_PARAM_COUNT] __initdata;
-static unsigned int bus1[BUS_PARAM_COUNT] __initdata;
-static unsigned int bus2[BUS_PARAM_COUNT] __initdata;
-static unsigned int bus3[BUS_PARAM_COUNT] __initdata;
-
-static unsigned int bus_nump[BUS_COUNT_MAX] __initdata;
-
-#define BUS_PARM_DESC \
- " config -> id,steps,axis,gpioa,gpiob[,inverted]"
-
-module_param_array(bus0, uint, &bus_nump[0], 0);
-MODULE_PARM_DESC(bus0, "bus0" BUS_PARM_DESC);
-module_param_array(bus1, uint, &bus_nump[1], 0);
-MODULE_PARM_DESC(bus1, "bus1" BUS_PARM_DESC);
-module_param_array(bus2, uint, &bus_nump[2], 0);
-MODULE_PARM_DESC(bus2, "bus2" BUS_PARM_DESC);
-module_param_array(bus3, uint, &bus_nump[3], 0);
-MODULE_PARM_DESC(bus3, "bus3" BUS_PARM_DESC);
-
-static struct platform_device *devices[BUS_COUNT_MAX];
-static unsigned int nr_devices;
-
-static void rotary_gpio_custom_cleanup(void)
-{
- int i;
-
- for (i = 0; i < nr_devices; i++)
- if (devices[i])
- platform_device_put(devices[i]);
-}
-
-static int __init rotary_gpio_custom_add_one(unsigned int id, unsigned int *params)
-{
- struct platform_device *pdev;
- struct rotary_encoder_platform_data pdata;
- int err;
-
- if (!bus_nump[id])
- return 0;
-
- if (bus_nump[id] < BUS_PARAM_REQUIRED) {
- printk(KERN_ERR PFX "not enough parameters for bus%d\n", id);
- err = -EINVAL;
- goto err;
- }
-
- pdev = platform_device_alloc("rotary-gpio", params[0]);
- if (!pdev) {
- err = -ENOMEM;
- goto err;
- }
-
- pdata.steps = params[1];
- pdata.axis = params[2];
- pdata.relative_axis = false;
- pdata.rollover = false;
- pdata.gpio_a = params[3];
- pdata.gpio_b = params[4];
-
- if (params[5] == 1) {
- pdata.inverted_a = 1;
- pdata.inverted_b = 1;
- } else {
- pdata.inverted_a = 0;
- pdata.inverted_b = 0;
- }
-
- err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
- if (err)
- goto err_put;
-
- err = platform_device_add(pdev);
- if (err)
- goto err_put;
-
- devices[nr_devices++] = pdev;
- return 0;
-
-err_put:
- platform_device_put(pdev);
-err:
- return err;
-}
-
-static int __init rotary_gpio_custom_probe(void)
-{
- int err;
-
- printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
-
- err = rotary_gpio_custom_add_one(0, bus0);
- if (err) goto err;
-
- err = rotary_gpio_custom_add_one(1, bus1);
- if (err) goto err;
-
- err = rotary_gpio_custom_add_one(2, bus2);
- if (err) goto err;
-
- err = rotary_gpio_custom_add_one(3, bus3);
- if (err) goto err;
-
- if (!nr_devices) {
- printk(KERN_ERR PFX "no bus parameter(s) specified\n");
- err = -ENODEV;
- goto err;
- }
-
- return 0;
-
-err:
- rotary_gpio_custom_cleanup();
- return err;
-}
-
-#ifdef MODULE
-static int __init rotary_gpio_custom_init(void)
-{
- return rotary_gpio_custom_probe();
-}
-module_init(rotary_gpio_custom_init);
-
-static void __exit rotary_gpio_custom_exit(void)
-{
- rotary_gpio_custom_cleanup();
-}
-module_exit(rotary_gpio_custom_exit);
-#else
-subsys_initcall(rotary_gpio_custom_probe);
-#endif /* MODULE*/
-
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org >");
-MODULE_AUTHOR("Claudio Mignanti <c.mignanti@gmail.com>");
-MODULE_DESCRIPTION(DRV_DESC);
-MODULE_VERSION(DRV_VERSION);
diff --git a/package/system/rtc-rv5c386a/Makefile b/package/system/rtc-rv5c386a/Makefile
deleted file mode 100644
index e13ead528a..0000000000
--- a/package/system/rtc-rv5c386a/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Copyright (C) 2006-2009 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:=rtc-rv5c386a
-PKG_RELEASE:=1
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/rtc-rv5c386a
- SUBMENU:=Other modules
- DEPENDS:=@TARGET_brcm47xx
- TITLE:=Driver for RTC RV5C386A (used in WL-700gE and WL-HDD)
- AUTOLOAD:=$(call AutoLoad,70,rtc)
- FILES:=$(PKG_BUILD_DIR)/rtc.ko
-endef
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
- $(CP) ./src/* $(PKG_BUILD_DIR)/
-endef
-
-define Build/Compile
- $(MAKE) -C "$(LINUX_DIR)" \
- CROSS_COMPILE="$(TARGET_CROSS)" \
- ARCH="$(LINUX_KARCH)" \
- SUBDIRS="$(PKG_BUILD_DIR)" \
- EXTRA_CFLAGS="$(BUILDFLAGS)" \
- modules
-endef
-
-$(eval $(call KernelPackage,rtc-rv5c386a))
diff --git a/package/system/rtc-rv5c386a/src/Makefile b/package/system/rtc-rv5c386a/src/Makefile
deleted file mode 100644
index eeb0430774..0000000000
--- a/package/system/rtc-rv5c386a/src/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# $Id$
-#
-# Makefile for Real Time Clock driver for WL-HDD
-#
-# Copyright (C) 2007 Andreas Engel
-#
-# 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.
-#
-
-obj-m := rtc.o
-
-ifeq ($(MAKING_MODULES),1)
-
--include $(TOPDIR)/Rules.make
-endif
diff --git a/package/system/rtc-rv5c386a/src/rtc.c b/package/system/rtc-rv5c386a/src/rtc.c
deleted file mode 100644
index 2fc6f093cf..0000000000
--- a/package/system/rtc-rv5c386a/src/rtc.c
+++ /dev/null
@@ -1,613 +0,0 @@
-/*
- * Real Time Clock driver for WL-HDD
- *
- * Copyright (C) 2007 Andreas Engel
- *
- * Hacked together mostly by copying the relevant code parts from:
- * drivers/i2c/i2c-bcm5365.c
- * drivers/i2c/i2c-algo-bit.c
- * drivers/char/rtc.c
- *
- * Note 1:
- * This module uses the standard char device (10,135), while the Asus module
- * rtcdrv.o uses (12,0). So, both can coexist which might be handy during
- * development (but see the comment in rtc_open()).
- *
- * Note 2:
- * You might need to set the clock once after loading the driver the first
- * time because the driver switches the chip into 24h mode if it is running
- * in 12h mode.
- *
- * Usage:
- * For compatibility reasons with the original asus driver, the time can be
- * read and set via the /dev/rtc device entry. The only accepted data format
- * is "YYYY:MM:DD:W:HH:MM:SS\n". See OpenWrt wiki for a script which handles
- * this format.
- *
- * In addition, this driver supports the standard ioctl() calls for setting
- * and reading the hardware clock, so the ordinary hwclock utility can also
- * be used.
- *
- * 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.
- *
- * TODO:
- * - add a /proc/driver/rtc interface?
- * - make the battery failure bit available through the /proc interface?
- *
- * $Id: rtc.c 7 2007-05-25 19:37:01Z ae $
- */
-
-#include <linux/module.h>
-#include <linux/kmod.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/miscdevice.h>
-#include <linux/ioport.h>
-#include <linux/fcntl.h>
-#include <linux/mc146818rtc.h>
-#include <linux/init.h>
-#include <linux/spinlock.h>
-#include <linux/rtc.h>
-#include <linux/delay.h>
-#include <linux/version.h>
-#include <linux/gpio.h>
-#include <linux/uaccess.h>
-
-#include <asm/current.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
-#include <asm/system.h>
-#endif
-
-#include <bcm47xx.h>
-#include <bcm47xx_nvram.h>
-
-#define RTC_IS_OPEN 0x01 /* Means /dev/rtc is in use. */
-
-/* Can be changed via a module parameter. */
-static int rtc_debug = 0;
-
-static unsigned long rtc_status = 0; /* Bitmapped status byte. */
-
-/* These settings are platform dependents. */
-unsigned int sda_index = 0;
-unsigned int scl_index = 0;
-
-#define I2C_READ_MASK 1
-#define I2C_WRITE_MASK 0
-
-#define I2C_ACK 1
-#define I2C_NAK 0
-
-#define RTC_EPOCH 1900
-#define RTC_I2C_ADDRESS (0x32 << 1)
-#define RTC_24HOUR_MODE_MASK 0x20
-#define RTC_PM_MASK 0x20
-#define RTC_VDET_MASK 0x40
-#define RTC_Y2K_MASK 0x80
-
-/*
- * Delay in microseconds for generating the pulses on the I2C bus. We use
- * a rather conservative setting here. See datasheet of the RTC chip.
- */
-#define ADAP_DELAY 50
-
-/* Avoid spurious compiler warnings. */
-#define UNUSED __attribute__((unused))
-
-MODULE_AUTHOR("Andreas Engel");
-MODULE_LICENSE("GPL");
-
-/* Test stolen from switch-adm.c. */
-module_param(rtc_debug, int, 0);
-
-static inline void sdalo(void)
-{
- gpio_direction_output(sda_index, 1);
- udelay(ADAP_DELAY);
-}
-
-static inline void sdahi(void)
-{
- gpio_direction_input(sda_index);
- udelay(ADAP_DELAY);
-}
-
-static inline void scllo(void)
-{
- gpio_direction_output(scl_index, 1);
- udelay(ADAP_DELAY);
-}
-
-static inline int getscl(void)
-{
- return (gpio_get_value(scl_index));
-}
-
-static inline int getsda(void)
-{
- return (gpio_get_value(sda_index));
-}
-
-/*
- * We shouldn't simply set the SCL pin to high. Like SDA, the SCL line is
- * bidirectional too. According to the I2C spec, the slave is allowed to
- * pull down the SCL line to slow down the clock, so we need to check this.
- * Generally, we'd need a timeout here, but in our case, we just check the
- * line, assuming the RTC chip behaves well.
- */
-static int sclhi(void)
-{
- gpio_direction_input(scl_index);
- udelay(ADAP_DELAY);
- if (!getscl()) {
- printk(KERN_ERR "SCL pin should be low\n");
- return -ETIMEDOUT;
- }
- return 0;
-}
-
-static void i2c_start(void)
-{
- sdalo();
- scllo();
-}
-
-static void i2c_stop(void)
-{
- sdalo();
- sclhi();
- sdahi();
-}
-
-static int i2c_outb(int c)
-{
- int i;
- int ack;
-
- /* assert: scl is low */
- for (i = 7; i >= 0; i--) {
- if (c & ( 1 << i )) {
- sdahi();
- } else {
- sdalo();
- }
- if (sclhi() < 0) { /* timed out */
- sdahi(); /* we don't want to block the net */
- return -ETIMEDOUT;
- };
- scllo();
- }
- sdahi();
- if (sclhi() < 0) {
- return -ETIMEDOUT;
- };
- /* read ack: SDA should be pulled down by slave */
- ack = getsda() == 0; /* ack: sda is pulled low ->success. */
- scllo();
-
- if (rtc_debug)
- printk(KERN_DEBUG "i2c_outb(0x%02x) -> %s\n",
- c, ack ? "ACK": "NAK");
-
- return ack; /* return 1 if device acked */
- /* assert: scl is low (sda undef) */
-}
-
-static int i2c_inb(int ack)
-{
- int i;
- unsigned int indata = 0;
-
- /* assert: scl is low */
-
- sdahi();
- for (i = 0; i < 8; i++) {
- if (sclhi() < 0) {
- return -ETIMEDOUT;
- };
- indata *= 2;
- if (getsda())
- indata |= 0x01;
- scllo();
- }
- if (ack) {
- sdalo();
- } else {
- sdahi();
- }
-
- if (sclhi() < 0) {
- sdahi();
- return -ETIMEDOUT;
- }
- scllo();
- sdahi();
-
- if (rtc_debug)
- printk(KERN_DEBUG "i2c_inb() -> 0x%02x\n", indata);
-
- /* assert: scl is low */
- return indata & 0xff;
-}
-
-static void i2c_init(void)
-{
- /* no gpio_control for EXTIF */
- // ssb_gpio_control(&ssb, sda_mask | scl_mask, 0);
-
- gpio_set_value(sda_index, 0);
- gpio_set_value(scl_index, 0);
- sdahi();
- sclhi();
-}
-
-static int rtc_open(UNUSED struct inode *inode, UNUSED struct file *filp)
-{
- spin_lock_irq(&rtc_lock);
-
- if (rtc_status & RTC_IS_OPEN) {
- spin_unlock_irq(&rtc_lock);
- return -EBUSY;
- }
-
- rtc_status |= RTC_IS_OPEN;
-
- /*
- * The following call is only necessary if we use both this driver and
- * the proprietary one from asus at the same time (which, b.t.w. only
- * makes sense during development). Otherwise, each access via the asus
- * driver will make access via this driver impossible.
- */
- i2c_init();
-
- spin_unlock_irq(&rtc_lock);
-
- return 0;
-}
-
-static int rtc_release(UNUSED struct inode *inode, UNUSED struct file *filp)
-{
- /* No need for locking here. */
- rtc_status &= ~RTC_IS_OPEN;
- return 0;
-}
-
-static int from_bcd(int bcdnum)
-{
- int fac, num = 0;
-
- for (fac = 1; bcdnum; fac *= 10) {
- num += (bcdnum % 16) * fac;
- bcdnum /= 16;
- }
-
- return num;
-}
-
-static int to_bcd(int decnum)
-{
- int fac, num = 0;
-
- for (fac = 1; decnum; fac *= 16) {
- num += (decnum % 10) * fac;
- decnum /= 10;
- }
-
- return num;
-}
-
-static void get_rtc_time(struct rtc_time *rtc_tm)
-{
- int cr2;
-
- /*
- * Read date and time from the RTC. We use read method (3).
- */
-
- spin_lock_irq(&rtc_lock);
- i2c_start();
- i2c_outb(RTC_I2C_ADDRESS | I2C_READ_MASK);
- cr2 = i2c_inb(I2C_ACK);
- rtc_tm->tm_sec = i2c_inb(I2C_ACK);
- rtc_tm->tm_min = i2c_inb(I2C_ACK);
- rtc_tm->tm_hour = i2c_inb(I2C_ACK);
- rtc_tm->tm_wday = i2c_inb(I2C_ACK);
- rtc_tm->tm_mday = i2c_inb(I2C_ACK);
- rtc_tm->tm_mon = i2c_inb(I2C_ACK);
- rtc_tm->tm_year = i2c_inb(I2C_NAK);
- i2c_stop();
- spin_unlock_irq(&rtc_lock);
-
- if (cr2 & RTC_VDET_MASK) {
- printk(KERN_WARNING "***RTC BATTERY FAILURE***\n");
- }
-
- /* Handle century bit */
- if (rtc_tm->tm_mon & RTC_Y2K_MASK) {
- rtc_tm->tm_mon &= ~RTC_Y2K_MASK;
- rtc_tm->tm_year += 0x100;
- }
-
- rtc_tm->tm_sec = from_bcd(rtc_tm->tm_sec);
- rtc_tm->tm_min = from_bcd(rtc_tm->tm_min);
- rtc_tm->tm_hour = from_bcd(rtc_tm->tm_hour);
- rtc_tm->tm_mday = from_bcd(rtc_tm->tm_mday);
- rtc_tm->tm_mon = from_bcd(rtc_tm->tm_mon) - 1;
- rtc_tm->tm_year = from_bcd(rtc_tm->tm_year);
-
- rtc_tm->tm_isdst = -1; /* DST not known */
-}
-
-static void set_rtc_time(struct rtc_time *rtc_tm)
-{
- rtc_tm->tm_sec = to_bcd(rtc_tm->tm_sec);
- rtc_tm->tm_min = to_bcd(rtc_tm->tm_min);
- rtc_tm->tm_hour = to_bcd(rtc_tm->tm_hour);
- rtc_tm->tm_mday = to_bcd(rtc_tm->tm_mday);
- rtc_tm->tm_mon = to_bcd(rtc_tm->tm_mon + 1);
- rtc_tm->tm_year = to_bcd(rtc_tm->tm_year);
-
- if (rtc_tm->tm_year >= 0x100) {
- rtc_tm->tm_year -= 0x100;
- rtc_tm->tm_mon |= RTC_Y2K_MASK;
- }
-
- spin_lock_irq(&rtc_lock);
- i2c_start();
- i2c_outb(RTC_I2C_ADDRESS | I2C_WRITE_MASK);
- i2c_outb(0x00); /* set starting register to 0 (=seconds) */
- i2c_outb(rtc_tm->tm_sec);
- i2c_outb(rtc_tm->tm_min);
- i2c_outb(rtc_tm->tm_hour);
- i2c_outb(rtc_tm->tm_wday);
- i2c_outb(rtc_tm->tm_mday);
- i2c_outb(rtc_tm->tm_mon);
- i2c_outb(rtc_tm->tm_year);
- i2c_stop();
- spin_unlock_irq(&rtc_lock);
-}
-
-static ssize_t rtc_write(UNUSED struct file *filp, const char *buf,
- size_t count, loff_t *ppos)
-{
- struct rtc_time rtc_tm;
- char buffer[23];
- char *p;
-
- if (!capable(CAP_SYS_TIME))
- return -EACCES;
-
- if (ppos != &filp->f_pos)
- return -ESPIPE;
-
- /*
- * For simplicity, the only acceptable format is:
- * YYYY:MM:DD:W:HH:MM:SS\n
- */
-
- if (count != 22)
- goto err_out;
-
- if (copy_from_user(buffer, buf, count))
- return -EFAULT;
-
- buffer[sizeof(buffer)-1] = '\0';
-
- p = &buffer[0];
-
- rtc_tm.tm_year = simple_strtoul(p, &p, 10);
- if (*p++ != ':') goto err_out;
-
- rtc_tm.tm_mon = simple_strtoul(p, &p, 10) - 1;
- if (*p++ != ':') goto err_out;
-
- rtc_tm.tm_mday = simple_strtoul(p, &p, 10);
- if (*p++ != ':') goto err_out;
-
- rtc_tm.tm_wday = simple_strtoul(p, &p, 10);
- if (*p++ != ':') goto err_out;
-
- rtc_tm.tm_hour = simple_strtoul(p, &p, 10);
- if (*p++ != ':') goto err_out;
-
- rtc_tm.tm_min = simple_strtoul(p, &p, 10);
- if (*p++ != ':') goto err_out;
-
- rtc_tm.tm_sec = simple_strtoul(p, &p, 10);
- if (*p != '\n') goto err_out;
-
- rtc_tm.tm_year -= RTC_EPOCH;
-
- set_rtc_time(&rtc_tm);
-
- *ppos += count;
-
- return count;
-
- err_out:
- printk(KERN_ERR "invalid format: use YYYY:MM:DD:W:HH:MM:SS\\n\n");
- return -EINVAL;
-}
-
-
-static ssize_t rtc_read(UNUSED struct file *filp, char *buf, size_t count,
- loff_t *ppos)
-{
- char wbuf[23];
- struct rtc_time tm;
- ssize_t len;
-
- if (count == 0 || *ppos != 0)
- return 0;
-
- get_rtc_time(&tm);
-
- len = sprintf(wbuf, "%04d:%02d:%02d:%d:%02d:%02d:%02d\n",
- tm.tm_year + RTC_EPOCH,
- tm.tm_mon + 1,
- tm.tm_mday,
- tm.tm_wday,
- tm.tm_hour,
- tm.tm_min,
- tm.tm_sec);
-
- if (len > (ssize_t)count)
- len = count;
-
- if (copy_to_user(buf, wbuf, len))
- return -EFAULT;
-
- *ppos += len;
-
- return len;
-}
-
-static int rtc_do_ioctl(unsigned int cmd, unsigned long arg)
-{
- struct rtc_time rtc_tm;
-
- switch (cmd) {
- case RTC_RD_TIME:
- memset(&rtc_tm, 0, sizeof(struct rtc_time));
- get_rtc_time(&rtc_tm);
- if (copy_to_user((void *)arg, &rtc_tm, sizeof(rtc_tm)))
- return -EFAULT;
- break;
-
- case RTC_SET_TIME:
- if (!capable(CAP_SYS_TIME))
- return -EACCES;
-
- if (copy_from_user(&rtc_tm, (struct rtc_time *)arg,
- sizeof(struct rtc_time)))
- return -EFAULT;
-
- set_rtc_time(&rtc_tm);
- break;
-
- default:
- return -ENOTTY;
- }
-
- return 0;
-}
-
-static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
- long ret;
- ret = rtc_do_ioctl(cmd, arg);
- return ret;
-}
-
-static const struct file_operations rtc_fops = {
- .owner = THIS_MODULE,
- .llseek = no_llseek,
- .read = rtc_read,
- .write = rtc_write,
- .unlocked_ioctl = rtc_ioctl,
- .open = rtc_open,
- .release = rtc_release,
-};
-
-static struct miscdevice rtc_dev = {
- .minor = RTC_MINOR,
- .name = "rtc",
- .fops = &rtc_fops,
-};
-
-/* Savagely ripped from diag.c. */
-static inline int startswith (char *source, char *cmp)
-{
- return !strncmp(source, cmp, strlen(cmp));
-}
-
-static void platform_detect(void)
-{
- char buf[20];
- int et0phyaddr, et1phyaddr;
-
- /* Based on "model_no". */
- if (bcm47xx_nvram_getenv("model_no", buf, sizeof(buf)) >= 0) {
- if (startswith(buf, "WL700")) { /* WL700* */
- sda_index = 2;
- scl_index = 5;
- return;
- }
- }
-
- if (bcm47xx_nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 )
- et0phyaddr = simple_strtoul(buf, NULL, 0);
- if (bcm47xx_nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 )
- et1phyaddr = simple_strtoul(buf, NULL, 0);
-
- if (bcm47xx_nvram_getenv("hardware_version", buf, sizeof(buf)) >= 0) {
- /* Either WL-300g or WL-HDD, do more extensive checks */
- if (startswith(buf, "WL300-") && et0phyaddr == 0 && et1phyaddr == 1) {
- sda_index = 4;
- scl_index = 5;
- return;
- }
- }
- /* not found */
-}
-
-static int __init rtc_init(void)
-{
- int cr1;
-
- platform_detect();
-
- if (sda_index == scl_index) {
- printk(KERN_ERR "RTC-RV5C386A: unrecognized platform!\n");
- return -ENODEV;
- }
-
- i2c_init();
-
- /*
- * Switch RTC to 24h mode
- */
- spin_lock_irq(&rtc_lock);
- i2c_start();
- i2c_outb(RTC_I2C_ADDRESS | I2C_WRITE_MASK);
- i2c_outb(0xE4); /* start at address 0xE, transmission mode 4 */
- cr1 = i2c_inb(I2C_NAK);
- i2c_stop();
- spin_unlock_irq(&rtc_lock);
- if ((cr1 & RTC_24HOUR_MODE_MASK) == 0) {
- /* RTC is running in 12h mode */
- printk(KERN_INFO "rtc.o: switching to 24h mode\n");
- spin_lock_irq(&rtc_lock);
- i2c_start();
- i2c_outb(RTC_I2C_ADDRESS | I2C_WRITE_MASK);
- i2c_outb(0xE0);
- i2c_outb(cr1 | RTC_24HOUR_MODE_MASK);
- i2c_stop();
- spin_unlock_irq(&rtc_lock);
- }
-
- misc_register(&rtc_dev);
-
- printk(KERN_INFO "RV5C386A Real Time Clock Driver loaded\n");
-
- return 0;
-}
-
-static void __exit rtc_exit (void)
-{
- misc_deregister(&rtc_dev);
- printk(KERN_INFO "Successfully removed RTC RV5C386A driver\n");
-}
-
-module_init(rtc_init);
-module_exit(rtc_exit);
-
-/*
- * Local Variables:
- * indent-tabs-mode:t
- * c-basic-offset:8
- * End:
- */
diff --git a/package/system/spi-ks8995/Makefile b/package/system/spi-ks8995/Makefile
deleted file mode 100644
index 0be9fe3dc6..0000000000
--- a/package/system/spi-ks8995/Makefile
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# Copyright (C) 2008 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-include $(INCLUDE_DIR)/kernel.mk
-
-PKG_NAME:=spi-ks8995
-PKG_RELEASE:=1
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/spi-ks8995
- SUBMENU:=SPI Support
- TITLE:=Micrel/Kendin KS8995 Ethernet switch control
- FILES:=$(PKG_BUILD_DIR)/spi_ks8995.ko
- KCONFIG:=CONFIG_SPI=y \
- CONFIG_SPI_MASTER=y
- AUTOLOAD:=$(call AutoLoad,50,spi_ks8995)
-endef
-
-define KernelPackage/spi-ks8995/description
- Kernel module for Micrel/Kendin KS8995 ethernet switch
-endef
-
-EXTRA_KCONFIG:= \
- CONFIG_SPI_KS8995=m
-
-EXTRA_CFLAGS:= \
- $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
- $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
-
-MAKE_OPTS:= \
- ARCH="$(LINUX_KARCH)" \
- CROSS_COMPILE="$(TARGET_CROSS)" \
- SUBDIRS="$(PKG_BUILD_DIR)" \
- EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
- $(EXTRA_KCONFIG)
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
- $(CP) ./src/* $(PKG_BUILD_DIR)/
-endef
-
-define Build/Compile
- $(MAKE) -C "$(LINUX_DIR)" \
- $(MAKE_OPTS) \
- modules
-endef
-
-$(eval $(call KernelPackage,spi-ks8995))
diff --git a/package/system/spi-ks8995/src/Kconfig b/package/system/spi-ks8995/src/Kconfig
deleted file mode 100644
index 7859be183d..0000000000
--- a/package/system/spi-ks8995/src/Kconfig
+++ /dev/null
@@ -1,3 +0,0 @@
-config SPI_KS8995
- tristate "Micrel/Kendin KS8995 Ethernet switch"
- depends on SPI
diff --git a/package/system/spi-ks8995/src/Makefile b/package/system/spi-ks8995/src/Makefile
deleted file mode 100644
index 810c3bd1db..0000000000
--- a/package/system/spi-ks8995/src/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-${CONFIG_SPI_KS8995} += spi_ks8995.o \ No newline at end of file
diff --git a/package/system/spi-ks8995/src/spi_ks8995.c b/package/system/spi-ks8995/src/spi_ks8995.c
deleted file mode 100644
index dc42b5d318..0000000000
--- a/package/system/spi-ks8995/src/spi_ks8995.c
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * SPI driver for Micrel/Kendin KS8995M ethernet switch
- *
- * Copyright (C) 2008 Gabor Juhos <juhosg at openwrt.org>
- *
- * This file was based on: drivers/spi/at25.c
- * Copyright (C) 2006 David Brownell
- *
- * 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/types.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/delay.h>
-#include <linux/device.h>
-
-#include <linux/spi/spi.h>
-
-#define DRV_VERSION "0.1.1"
-#define DRV_DESC "Micrel/Kendin KS8995 Ethernet switch SPI driver"
-
-/*-------------------------------------------------------------------------*/
-
-#define KS8995_REG_ID0 0x00 /* Chip ID0 */
-#define KS8995_REG_ID1 0x01 /* Chip ID1 */
-
-#define KS8995_REG_GC0 0x02 /* Global Control 0 */
-#define KS8995_REG_GC1 0x03 /* Global Control 1 */
-#define KS8995_REG_GC2 0x04 /* Global Control 2 */
-#define KS8995_REG_GC3 0x05 /* Global Control 3 */
-#define KS8995_REG_GC4 0x06 /* Global Control 4 */
-#define KS8995_REG_GC5 0x07 /* Global Control 5 */
-#define KS8995_REG_GC6 0x08 /* Global Control 6 */
-#define KS8995_REG_GC7 0x09 /* Global Control 7 */
-#define KS8995_REG_GC8 0x0a /* Global Control 8 */
-#define KS8995_REG_GC9 0x0b /* Global Control 9 */
-
-#define KS8995_REG_PC(p,r) ((0x10 * p) + r) /* Port Control */
-#define KS8995_REG_PS(p,r) ((0x10 * p) + r + 0xe) /* Port Status */
-
-#define KS8995_REG_TPC0 0x60 /* TOS Priority Control 0 */
-#define KS8995_REG_TPC1 0x61 /* TOS Priority Control 1 */
-#define KS8995_REG_TPC2 0x62 /* TOS Priority Control 2 */
-#define KS8995_REG_TPC3 0x63 /* TOS Priority Control 3 */
-#define KS8995_REG_TPC4 0x64 /* TOS Priority Control 4 */
-#define KS8995_REG_TPC5 0x65 /* TOS Priority Control 5 */
-#define KS8995_REG_TPC6 0x66 /* TOS Priority Control 6 */
-#define KS8995_REG_TPC7 0x67 /* TOS Priority Control 7 */
-
-#define KS8995_REG_MAC0 0x68 /* MAC address 0 */
-#define KS8995_REG_MAC1 0x69 /* MAC address 1 */
-#define KS8995_REG_MAC2 0x6a /* MAC address 2 */
-#define KS8995_REG_MAC3 0x6b /* MAC address 3 */
-#define KS8995_REG_MAC4 0x6c /* MAC address 4 */
-#define KS8995_REG_MAC5 0x6d /* MAC address 5 */
-
-#define KS8995_REG_IAC0 0x6e /* Indirect Access Control 0 */
-#define KS8995_REG_IAC1 0x6f /* Indirect Access Control 0 */
-
-#define KS8995_REG_IAD7 0x70 /* Indirect Access Data 7 */
-#define KS8995_REG_IAD6 0x71 /* Indirect Access Data 6 */
-#define KS8995_REG_IAD5 0x72 /* Indirect Access Data 5 */
-#define KS8995_REG_IAD4 0x73 /* Indirect Access Data 4 */
-#define KS8995_REG_IAD3 0x74 /* Indirect Access Data 3 */
-#define KS8995_REG_IAD2 0x75 /* Indirect Access Data 2 */
-#define KS8995_REG_IAD1 0x76 /* Indirect Access Data 1 */
-#define KS8995_REG_IAD0 0x77 /* Indirect Access Data 0 */
-
-#define KS8995_REGS_SIZE 0x80
-
-#define ID1_CHIPID_M 0xf
-#define ID1_CHIPID_S 4
-#define ID1_REVISION_M 0x7
-#define ID1_REVISION_S 1
-#define ID1_START_SW 1 /* start the switch */
-
-#define FAMILY_KS8995 0x95
-#define CHIPID_M 0
-
-#define KS8995_CMD_WRITE 0x02U
-#define KS8995_CMD_READ 0x03U
-
-#define KS8995_RESET_DELAY 10 /* usec */
-
-/*-------------------------------------------------------------------------*/
-
-struct ks8995_pdata {
- /* not yet implemented */
-};
-
-struct ks8995_switch {
- struct spi_device *spi;
- struct mutex lock;
- struct ks8995_pdata *pdata;
-};
-
-/*-------------------------------------------------------------------------*/
-
-static inline u8 get_chip_id(u8 val)
-{
- return ((val >> ID1_CHIPID_S) & ID1_CHIPID_M);
-}
-
-static inline u8 get_chip_rev(u8 val)
-{
- return ((val >> ID1_REVISION_S) & ID1_REVISION_M);
-}
-
-/*-------------------------------------------------------------------------*/
-
-static int ks8995_read(struct ks8995_switch *ks, char *buf,
- unsigned offset, size_t count)
-{
- u8 cmd[2];
- struct spi_transfer t[2];
- struct spi_message m;
- int err;
-
- spi_message_init(&m);
-
- memset(&t, 0, sizeof(t));
-
- t[0].tx_buf = cmd;
- t[0].len = sizeof(cmd);
- spi_message_add_tail(&t[0], &m);
-
- t[1].rx_buf = buf;
- t[1].len = count;
- spi_message_add_tail(&t[1], &m);
-
- cmd[0] = KS8995_CMD_READ;
- cmd[1] = offset;
-
- mutex_lock(&ks->lock);
- err = spi_sync(ks->spi, &m);
- mutex_unlock(&ks->lock);
-
- return err ? err : count;
-}
-
-
-static int ks8995_write(struct ks8995_switch *ks, char *buf,
- unsigned offset, size_t count)
-{
- u8 cmd[2];
- struct spi_transfer t[2];
- struct spi_message m;
- int err;
-
- spi_message_init(&m);
-
- memset(&t, 0, sizeof(t));
-
- t[0].tx_buf = cmd;
- t[0].len = sizeof(cmd);
- spi_message_add_tail(&t[0], &m);
-
- t[1].tx_buf = buf;
- t[1].len = count;
- spi_message_add_tail(&t[1], &m);
-
- cmd[0] = KS8995_CMD_WRITE;
- cmd[1] = offset;
-
- mutex_lock(&ks->lock);
- err = spi_sync(ks->spi, &m);
- mutex_unlock(&ks->lock);
-
- return err ? err : count;
-}
-
-static inline int ks8995_read_reg(struct ks8995_switch *ks, u8 addr, u8 *buf)
-{
- return (ks8995_read(ks, buf, addr, 1) != 1);
-}
-
-static inline int ks8995_write_reg(struct ks8995_switch *ks, u8 addr, u8 val)
-{
- char buf = val;
-
- return (ks8995_write(ks, &buf, addr, 1) != 1);
-}
-
-/*-------------------------------------------------------------------------*/
-
-#if 0
-static int ks8995_setup(struct spi_device *spi)
-{
- struct ks8995_switch *ks;
- u8 t;
-
- ks = dev_get_drvdata(&spi->dev);
-
- ks8995_write_reg(ks, KS8995_REG_GC0, 0x4c);
- ks8995_write_reg(ks, KS8995_REG_GC1, 0x05);
-
- ks8995_read_reg(ks, KS8995_REG_GC2, &t);
- ks8995_write_reg(ks, KS8995_REG_GC2, t | 1);
-
- ks8995_write_reg(ks, KS8995_REG_GC4, 0x20);
-
- ks8995_write_reg(ks, KS8995_REG_PC(1,0), 0x61);
- ks8995_write_reg(ks, KS8995_REG_PC(2,0), 0x61);
- ks8995_write_reg(ks, KS8995_REG_PC(3,0), 0x61);
- ks8995_write_reg(ks, KS8995_REG_PC(4,0), 0x61);
- ks8995_write_reg(ks, KS8995_REG_PC(5,0), 0x61);
-
- ks8995_write_reg(ks, KS8995_REG_PC(5,11), 0x18);
-
- ks8995_write_reg(ks, KS8995_REG_TPC0, 0xff);
- ks8995_write_reg(ks, KS8995_REG_TPC1, 0xff);
- ks8995_write_reg(ks, KS8995_REG_TPC2, 0xff);
- ks8995_write_reg(ks, KS8995_REG_TPC3, 0xff);
- ks8995_write_reg(ks, KS8995_REG_TPC4, 0xff);
- ks8995_write_reg(ks, KS8995_REG_TPC5, 0xff);
- ks8995_write_reg(ks, KS8995_REG_TPC6, 0xff);
- ks8995_write_reg(ks, KS8995_REG_TPC7, 0xfe);
-
- return 0;
-}
-#endif
-
-static int ks8995_stop(struct ks8995_switch *ks)
-{
- return ks8995_write_reg(ks, KS8995_REG_ID1, 0);
-}
-
-static int ks8995_start(struct ks8995_switch *ks)
-{
- return ks8995_write_reg(ks, KS8995_REG_ID1, 1);
-}
-
-static int ks8995_reset(struct ks8995_switch *ks)
-{
- int err;
-
- err = ks8995_stop(ks);
- if (err)
- return err;
-
- udelay(KS8995_RESET_DELAY);
-
- return ks8995_start(ks);
-}
-
-/*-------------------------------------------------------------------------*/
-
-static int ks8995_registers_read(struct kobject *kobj,
- struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
-{
- struct device *dev;
- struct ks8995_switch *ks8995;
-
- dev = container_of(kobj, struct device, kobj);
- ks8995 = dev_get_drvdata(dev);
-
- if (unlikely(off > KS8995_REGS_SIZE))
- return 0;
-
- if ((off + count) > KS8995_REGS_SIZE)
- count = KS8995_REGS_SIZE - off;
-
- if (unlikely(!count))
- return count;
-
- return ks8995_read(ks8995, buf, off, count);
-}
-
-
-static int ks8995_registers_write(struct kobject *kobj,
- struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
-{
- struct device *dev;
- struct ks8995_switch *ks8995;
-
- dev = container_of(kobj, struct device, kobj);
- ks8995 = dev_get_drvdata(dev);
-
- if (unlikely(off >= KS8995_REGS_SIZE))
- return -EFBIG;
-
- if ((off + count) > KS8995_REGS_SIZE)
- count = KS8995_REGS_SIZE - off;
-
- if (unlikely(!count))
- return count;
-
- return ks8995_write(ks8995, buf, off, count);
-}
-
-
-static struct bin_attribute ks8995_registers_attr = {
- .attr = {
- .name = "registers",
- .mode = S_IRUSR | S_IWUSR,
- },
- .size = KS8995_REGS_SIZE,
- .read = ks8995_registers_read,
- .write = ks8995_registers_write,
-};
-
-/*-------------------------------------------------------------------------*/
-
-static int ks8995_probe(struct spi_device *spi)
-{
- struct ks8995_switch *ks;
- struct ks8995_pdata *pdata;
- u8 ids[2];
- int err;
-
- /* Chip description */
- pdata = spi->dev.platform_data;
-
- ks = kzalloc(sizeof(*ks), GFP_KERNEL);
- if (!ks) {
- dev_err(&spi->dev, "no memory for private data\n");
- return-ENOMEM;
- }
-
- mutex_init(&ks->lock);
- ks->pdata = pdata;
- ks->spi = spi_dev_get(spi);
- dev_set_drvdata(&spi->dev, ks);
-
- spi->mode = SPI_MODE_0;
- spi->bits_per_word = 8;
- err = spi_setup(spi);
- if (err) {
- dev_err(&spi->dev, "spi_setup failed, err=%d \n", err);
- goto err_drvdata;
- }
-
- err = ks8995_read(ks, ids, KS8995_REG_ID0, sizeof(ids));
- if (err < 0) {
- dev_err(&spi->dev, "unable to read id registers, err=%d \n",
- err);
- goto err_drvdata;
- }
-
- switch (ids[0]) {
- case FAMILY_KS8995:
- break;
- default:
- dev_err(&spi->dev, "unknown family id:%02x\n", ids[0]);
- err = -ENODEV;
- goto err_drvdata;
- }
-
- err = ks8995_reset(ks);
- if (err)
- goto err_drvdata;
-
- err = sysfs_create_bin_file(&spi->dev.kobj, &ks8995_registers_attr);
- if (err) {
- dev_err(&spi->dev, "unable to create sysfs file, err=%d\n",
- err);
- goto err_drvdata;
- }
-
- dev_info(&spi->dev, "KS89%02X device found, Chip ID:%01x, "
- "Revision:%01x\n", ids[0],
- get_chip_id(ids[1]), get_chip_rev(ids[1]));
-
- return 0;
-
-err_drvdata:
- dev_set_drvdata(&spi->dev, NULL);
- kfree(ks);
- return err;
-}
-
-static int ks8995_remove(struct spi_device *spi)
-{
- struct ks8995_data *ks8995;
-
- ks8995 = dev_get_drvdata(&spi->dev);
- sysfs_remove_bin_file(&spi->dev.kobj, &ks8995_registers_attr);
-
- dev_set_drvdata(&spi->dev, NULL);
- kfree(ks8995);
-
- return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-static struct spi_driver ks8995_driver = {
- .driver = {
- .name = "spi-ks8995",
- .bus = &spi_bus_type,
- .owner = THIS_MODULE,
- },
- .probe = ks8995_probe,
- .remove = ks8995_remove,
-};
-
-static int __init ks8995_init(void)
-{
- printk(KERN_INFO DRV_DESC " version " DRV_VERSION"\n");
-
- return spi_register_driver(&ks8995_driver);
-}
-module_init(ks8995_init);
-
-static void __exit ks8995_exit(void)
-{
- spi_unregister_driver(&ks8995_driver);
-}
-module_exit(ks8995_exit);
-
-MODULE_DESCRIPTION(DRV_DESC);
-MODULE_VERSION(DRV_VERSION);
-MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
-MODULE_LICENSE("GPL v2");
-
diff --git a/package/system/spidev_test/Makefile b/package/system/spidev_test/Makefile
deleted file mode 100644
index 807039a1f5..0000000000
--- a/package/system/spidev_test/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# Copyright (C) 2009 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:=spidev-test
-PKG_RELEASE:=$(LINUX_VERSION)
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/spidev-test
- SECTION:=utils
- CATEGORY:=Utilities
- DEPENDS:=+kmod-spi-dev
- TITLE:=SPI testing utility
- VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE)
- URL:=http://www.kernel.org
- MAINTAINER:=Florian Fainelli <florian@openwrt.org>
-endef
-
-define Package/spidev-test/description
- SPI testing utility.
-endef
-
-define Build/Prepare
-endef
-
-define Build/Compile
- $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/spidev_test \
- $(LINUX_DIR)/Documentation/spi/spidev_test.c
-endef
-
-define Package/spidev-test/install
- $(INSTALL_DIR) $(1)/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/spidev_test $(1)/sbin/
-endef
-
-$(eval $(call BuildPackage,spidev-test))
diff --git a/package/system/ubox/Makefile b/package/system/ubox/Makefile
new file mode 100644
index 0000000000..3db0632077
--- /dev/null
+++ b/package/system/ubox/Makefile
@@ -0,0 +1,58 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ubox
+PKG_VERSION:=2013-06-20
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/luci2/ubox.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=1b19fc217e33e9b2fc2fab6f9552da740d03a98a
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+TARGET_LDFLAGS += $(if $(CONFIG_USE_EGLIBC),-lrt)
+
+define Package/ubox
+ SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=+ubusd +ubus +libuci +USE_EGLIBC:librt
+ TITLE:=OpenWrt system helper toolbox
+endef
+
+define Package/block-mount
+ SECTION:=base
+ CATEGORY:=Base system
+ TITLE:=Block device mounting and checking
+ DEPENDS:=+ubox
+ MENU:=1
+endef
+
+define Package/ubox/install
+ $(INSTALL_DIR) $(1)/sbin $(1)/usr/sbin
+
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/{mount_root,kmodloader,lsbloader,board} $(1)/sbin/
+ ln -s /sbin/mount_root $(1)/sbin/switch2jffs
+ ln -s /sbin/kmodloader $(1)/usr/sbin/lsmod
+ ln -s /sbin/kmodloader $(1)/usr/sbin/modinfo
+endef
+
+define Package/block-mount/install
+ $(INSTALL_DIR) $(1)/sbin $(1)/usr/sbin $(1)/etc/hotplug.d/block
+
+ $(CP) ./files/mount.hotplug $(1)/etc/hotplug.d/block/10-mount
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/block $(1)/sbin/
+ ln -s /sbin/block $(1)/usr/sbin/swapon
+ ln -s /sbin/block $(1)/usr/sbin/swapoff
+endef
+
+$(eval $(call BuildPackage,ubox))
+$(eval $(call BuildPackage,block-mount))
diff --git a/package/system/ubox/files/mount.hotplug b/package/system/ubox/files/mount.hotplug
new file mode 100644
index 0000000000..946924e351
--- /dev/null
+++ b/package/system/ubox/files/mount.hotplug
@@ -0,0 +1 @@
+/sbin/block hotplug
diff --git a/package/system/ubus/Makefile b/package/system/ubus/Makefile
new file mode 100644
index 0000000000..abd0a7653b
--- /dev/null
+++ b/package/system/ubus/Makefile
@@ -0,0 +1,84 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ubus
+PKG_VERSION:=2013-05-30
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://nbd.name/luci2/ubus.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=f72dca720bb50d45b1b01bab5b01cb80c78c5230
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_MIRROR_MD5SUM:=
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=LGPLv2.1
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/ubus
+ SECTION:=luci2
+ CATEGORY:=LuCI2
+ SUBMENU:=System
+ DEPENDS:=+libubus +libblobmsg-json +ubusd
+ TITLE:=OpenWrt RPC client utility
+endef
+
+define Package/ubusd
+ SECTION:=luci2
+ CATEGORY:=LuCI2
+ SUBMENU:=System
+ TITLE:=OpenWrt RPC daemon
+ DEPENDS:=+libubox
+endef
+
+define Package/libubus
+ SECTION:=luci2
+ CATEGORY:=LuCI2
+ SUBMENU:=Libraries
+ DEPENDS:=+libubox
+ TITLE:=OpenWrt RPC client library
+endef
+
+define Package/libubus-lua
+ SECTION:=luci2
+ CATEGORY:=LuCI2
+ SUBMENU:=Libraries
+ DEPENDS:=+libubus +liblua
+ TITLE:=Lua binding for the OpenWrt RPC client
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+
+CMAKE_OPTIONS = \
+ -DLUAPATH=/usr/lib/lua
+
+define Package/ubus/install
+ $(INSTALL_DIR) $(1)/bin
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/ubus $(1)/bin/
+endef
+
+define Package/ubusd/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ubusd $(1)/sbin/
+endef
+
+define Package/libubus/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/lib/
+endef
+
+define Package/libubus-lua/install
+ $(INSTALL_DIR) $(1)/usr/lib/lua
+ $(CP) $(PKG_BUILD_DIR)/lua/ubus.so $(1)/usr/lib/lua/
+endef
+
+$(eval $(call BuildPackage,ubus))
+$(eval $(call BuildPackage,ubusd))
+$(eval $(call BuildPackage,libubus))
+$(eval $(call BuildPackage,libubus-lua))
+
diff --git a/package/system/ubus/files/ubus.init b/package/system/ubus/files/ubus.init
new file mode 100755
index 0000000000..70fe21c6aa
--- /dev/null
+++ b/package/system/ubus/files/ubus.init
@@ -0,0 +1,14 @@
+#!/bin/sh /etc/rc.common
+
+START=11
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+start() {
+ service_start /sbin/ubusd
+}
+
+stop() {
+ service_stop /sbin/ubusd
+}
diff --git a/package/system/uci/Makefile b/package/system/uci/Makefile
new file mode 100644
index 0000000000..54ad80bda9
--- /dev/null
+++ b/package/system/uci/Makefile
@@ -0,0 +1,92 @@
+#
+# Copyright (C) 2008-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+UCI_VERSION=2013-06-11
+UCI_RELEASE=1
+
+PKG_NAME:=uci
+PKG_VERSION:=$(UCI_VERSION)$(if $(UCI_RELEASE),.$(UCI_RELEASE))
+PKG_RELEASE:=1
+PKG_REV:=c9c9d5cb085acc58b6579ace83fb79c085a9db27
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=git://nbd.name/uci.git
+PKG_SOURCE_SUBDIR:=uci-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE_PROTO:=git
+
+PKG_LICENSE:=LGPLv2.1 GPLv2
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+
+PKG_BUILD_PARALLEL:=0
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+# set to 1 to enable debugging
+DEBUG=
+
+define Package/libuci
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=C library for the Unified Configuration Interface (UCI)
+ DEPENDS:=+libubox
+endef
+
+define Package/uci
+ SECTION:=base
+ CATEGORY:=Base system
+ DEPENDS:=+libuci
+ TITLE:=Utility for the Unified Configuration Interface (UCI)
+endef
+
+define Package/libuci-lua
+ SECTION=libs
+ CATEGORY=Libraries
+ DEPENDS:=+libuci +liblua
+ TITLE:=Lua plugin for UCI
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+TARGET_LDFLAGS += -L$(STAGING_DIR)/usr/lib
+
+CMAKE_OPTIONS = \
+ -DLUAPATH=/usr/lib/lua \
+ $(if $(DEBUG),-DUCI_DEBUG=ON)
+
+define Package/libuci/install
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(PKG_BUILD_DIR)/libuci.so* $(1)/lib/
+endef
+
+define Package/libuci-lua/install
+ $(INSTALL_DIR) $(1)/usr/lib/lua
+ $(CP) $(PKG_BUILD_DIR)/lua/uci.so $(1)/usr/lib/lua/
+endef
+
+define Package/uci/install
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/uci $(1)/sbin/
+ $(CP) ./files/* $(1)/
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_BUILD_DIR)/uci{,_config,_blob,map}.h $(1)/usr/include
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libuci.so* $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libucimap.a $(1)/usr/lib
+endef
+
+$(eval $(call BuildPackage,uci))
+$(eval $(call BuildPackage,libuci))
+$(eval $(call BuildPackage,libuci-lua))
diff --git a/package/system/uci/files/lib/config/uci.sh b/package/system/uci/files/lib/config/uci.sh
new file mode 100644
index 0000000000..db84c8343e
--- /dev/null
+++ b/package/system/uci/files/lib/config/uci.sh
@@ -0,0 +1,137 @@
+#!/bin/sh
+# Shell script compatibility wrappers for /sbin/uci
+#
+# Copyright (C) 2008-2010 OpenWrt.org
+# Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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
+
+CONFIG_APPEND=
+uci_load() {
+ local PACKAGE="$1"
+ local DATA
+ local RET
+ local VAR
+
+ _C=0
+ if [ -z "$CONFIG_APPEND" ]; then
+ for VAR in $CONFIG_LIST_STATE; do
+ export ${NO_EXPORT:+-n} CONFIG_${VAR}=
+ export ${NO_EXPORT:+-n} CONFIG_${VAR}_LENGTH=
+ done
+ export ${NO_EXPORT:+-n} CONFIG_LIST_STATE=
+ export ${NO_EXPORT:+-n} CONFIG_SECTIONS=
+ export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=0
+ export ${NO_EXPORT:+-n} CONFIG_SECTION=
+ fi
+
+ DATA="$(/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${LOAD_STATE:+-P /var/state} -S -n export "$PACKAGE" 2>/dev/null)"
+ RET="$?"
+ [ "$RET" != 0 -o -z "$DATA" ] || eval "$DATA"
+ unset DATA
+
+ ${CONFIG_SECTION:+config_cb}
+ return "$RET"
+}
+
+uci_set_default() {
+ local PACKAGE="$1"
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q show "$PACKAGE" > /dev/null && return 0
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} import "$PACKAGE"
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit "$PACKAGE"
+}
+
+uci_revert_state() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state revert "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
+}
+
+uci_set_state() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+ local VALUE="$4"
+
+ [ "$#" = 4 ] || return 0
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set "$PACKAGE.$CONFIG${OPTION:+.$OPTION}=$VALUE"
+}
+
+uci_toggle_state() {
+ uci_revert_state "$1" "$2" "$3"
+ uci_set_state "$1" "$2" "$3" "$4"
+}
+
+uci_set() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+ local VALUE="$4"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG.$OPTION=$VALUE"
+}
+
+uci_get_state() {
+ uci_get "$1" "$2" "$3" "$4" "/var/state"
+}
+
+uci_get() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+ local DEFAULT="$4"
+ local STATE="$5"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${STATE:+-P $STATE} -q get "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
+ RET="$?"
+ [ "$RET" -ne 0 ] && [ -n "$DEFAULT" ] && echo "$DEFAULT"
+ return "$RET"
+}
+
+uci_add() {
+ local PACKAGE="$1"
+ local TYPE="$2"
+ local CONFIG="$3"
+
+ if [ -z "$CONFIG" ]; then
+ export ${NO_EXPORT:+-n} CONFIG_SECTION="$(/sbin/uci add "$PACKAGE" "$TYPE")"
+ else
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG=$TYPE"
+ export ${NO_EXPORT:+-n} CONFIG_SECTION="$CONFIG"
+ fi
+}
+
+uci_rename() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local VALUE="$3"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} rename "$PACKAGE.$CONFIG=$VALUE"
+}
+
+uci_remove() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} del "$PACKAGE.$CONFIG${OPTION:+.$OPTION}"
+}
+
+uci_commit() {
+ local PACKAGE="$1"
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit $PACKAGE
+}
diff --git a/package/system/udev/Config.in b/package/system/udev/Config.in
new file mode 100644
index 0000000000..56033d8eee
--- /dev/null
+++ b/package/system/udev/Config.in
@@ -0,0 +1,118 @@
+# udev package config
+
+menu "Configuration"
+ depends on PACKAGE_udev
+
+config UDEV_DISABLE_LOGGING
+ bool "Disable udev logging to syslog"
+ default n
+ help
+ Disable logging of udev messages to the syslog. If
+ unsure, choose the default N.
+
+config UDEV_ENABLE_DEBUG
+ bool "Enable debug build of the udev package"
+ default n
+ help
+ Compile in udev debug messages. If unsure, choose
+ the default N.
+
+config UDEV_EXTRA_accelerometer
+ bool "Install udev acceleroometer callout"
+ default y
+ help
+ accelerometer - udev callout to export device orientation
+ through property
+
+config UDEV_EXTRA_ata_id
+ bool "Install udev ata_id callout"
+ default y
+ help
+ ata_id - udev callout to read product/serial number
+ from ATA drives
+
+config UDEV_EXTRA_cdrom_id
+ bool "Install udev cdrom_id callout"
+ default y
+ help
+ cdrom_id - udev callout to determine the capabilities
+ of optical drives and media
+
+config UDEV_EXTRA_collect
+ bool "Install udev collect"
+ default n
+ help
+ Adds ID to the list governed by <checkpoint>
+
+config UDEV_EXTRA_edd_id
+ bool "Install udev edd_id callout"
+ default n
+ help
+ edd_id - udev callout to identify BIOS disk drives
+ via EDD
+
+config UDEV_EXTRA_firmware
+ bool "Install firmware support"
+ default n
+ help
+ udev firmware loader
+ via EDD
+
+config UDEV_EXTRA_floppy
+ bool "Install create_floppy_devices callout"
+ default n
+ help
+ create_floppy_devices - udev callout to create all
+ possible floppy device based on the CMOS type
+
+config UDEV_EXTRA_input_id
+ bool "Install input_id callout"
+ default y
+ help
+ input_id - udev callout to classify input devices
+
+config UDEV_EXTRA_mtd_probe
+ bool "Install mtd_probe callout"
+ default y
+ help
+ mtd_probe - udev callout to probe mtd devices
+
+config UDEV_EXTRA_path_id
+ bool "Install udev path_id callout"
+ default y
+ help
+ path_id - udev callout to create a device path based
+ unique name for a device to implement the Linux
+ Persistent Device Naming scheme
+
+config UDEV_EXTRA_qemu
+ bool "Install qemu specific rules"
+ default y
+ help
+ Install rules for autosuspension of QEMU emulated
+ USB HID devices
+
+config UDEV_EXTRA_rule_generator
+ bool "Install udev rule_generator"
+ default y
+ help
+
+config UDEV_EXTRA_scsi_id
+ bool "Install udev scsi_id callout"
+ default y
+ help
+ scsi_id - retrieve and generate a unique SCSI identifier
+
+config UDEV_EXTRA_usb_id
+ bool "Install udev usb_id callout"
+ default y
+ help
+ usb_id - can find the unique id of USB devices
+
+config UDEV_EXTRA_v4l_id
+ bool "Install udev v4l_id callout"
+ default y
+ help
+ v4l_id - udev callout to identify Video4Linux devices
+
+endmenu
diff --git a/package/system/udev/Makefile b/package/system/udev/Makefile
new file mode 100644
index 0000000000..46799177e6
--- /dev/null
+++ b/package/system/udev/Makefile
@@ -0,0 +1,156 @@
+#
+# Copyright (C) 2006-2008 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:=udev
+PKG_VERSION:=173
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/hotplug/
+PKG_MD5SUM:=91a88a359b60bbd074b024883cc0dbde
+
+include $(INCLUDE_DIR)/package.mk
+
+PKG_INSTALL=1
+
+define Package/udev
+ SECTION:=base
+ CATEGORY:=Base system
+ TITLE:=Dynamic device management subsystem
+ URL:=http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
+ MAINTAINER:=Geoff Levand <geoff@infradead.org>
+ MENU:=1
+ DEPENDS:=+librt
+endef
+
+define Package/udev/description
+ udev allows Linux users to have a dynamic /dev directory and it
+ provides the ability to have persistent device names.
+endef
+
+define Package/udev/conffiles
+/etc/udev/udev.conf
+endef
+
+define Package/udev/config
+ source "$(SOURCE)/Config.in"
+endef
+
+udev-args-$(CONFIG_UDEV_DISABLE_LOGGING) += --disable-logging
+udev-args-$(CONFIG_UDEV_ENABLE_DEBUG) += --enable-debug
+udev-args-$(CONFIG_UDEV_EXTRA_edd_id) += --enable-edd
+udev-args-$(CONFIG_UDEV_EXTRA_floppy) += --enable-floppy
+
+# TODO: make hwdb and introspection work
+
+CONFIGURE_ARGS += --prefix=/usr --exec-prefix= --sysconfdir=/etc \
+ --disable-hwdb --disable-keymap --disable-gudev --disable-introspection \
+ --libexecdir=/lib/udev --disable-gtk-doc-html \
+ --sbindir=/sbin $(udev-args-y)
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_accelerometer) += accelerometer
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_accelerometer) += 61-accelerometer.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_ata_id) += ata_id
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_cdrom_id) += cdrom_id
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_cdrom_id) += 60-cdrom_id.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_collect) += collect
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_edd_id) += edd_id
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_edd_id) += 61-persistent-storage-edd.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_firmware) += firmware
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_firmware) += 50-firmware.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_floppy) += create_floppy_devices
+
+# TODO: make gudev work
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_input_id) += input_id
+
+# TODO: make keymap work
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_mtd_probe) += mtd_probe
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_mtd_probe) += 75-probe_mtd.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_path_id) += path_id
+
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_qemu) += 42-qemu-usb.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_rule_generator) += \
+ write_cd_rules write_net_rules
+udev-extra-lib-data-$(CONFIG_UDEV_EXTRA_rule_generator) += \
+ rule_generator.functions
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_rule_generator) += \
+ 75-cd-aliases-generator.rules 75-persistent-net-generator.rules
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_scsi_id) += scsi_id
+
+# TODO: make udev-acl work
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_usb_id) += usb_id
+
+udev-extra-lib-bin-$(CONFIG_UDEV_EXTRA_v4l_id) += v4l_id
+udev-extra-rules-$(CONFIG_UDEV_EXTRA_v4l_id) += 60-persistent-v4l.rules
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/libudev.h $(1)/usr/include
+ $(INSTALL_DIR) $(1)/usr/share/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/share/pkgconfig/udev.pc $(1)/usr/share/pkgconfig
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(PKG_INSTALL_DIR)/lib/libudev.so* $(1)/lib
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/lib/pkgconfig/libudev.pc $(1)/usr/lib/pkgconfig
+endef
+
+define Package/udev/install
+ $(INSTALL_DIR) $(1)/etc/udev/rules.d
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/udev/udev.conf $(1)/etc/udev
+
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) \
+ $(PKG_INSTALL_DIR)/sbin/udevadm \
+ $(PKG_INSTALL_DIR)/sbin/udevd \
+ $(1)/sbin
+
+ $(INSTALL_DIR) $(1)/lib/udev/rules.d
+ $(INSTALL_DATA) \
+ $(addprefix $(PKG_INSTALL_DIR)/lib/udev/rules.d/, \
+ $(udev-extra-rules-y)) \
+ $(addprefix $(PKG_INSTALL_DIR)/lib/udev/rules.d/, \
+ 50-udev-default.rules \
+ 60-persistent-input.rules \
+ 60-persistent-serial.rules \
+ 60-persistent-storage.rules \
+ 80-drivers.rules \
+ 95-udev-late.rules) \
+ $(1)/lib/udev/rules.d
+
+ $(INSTALL_DIR) $(1)/lib
+ $(CP) $(PKG_INSTALL_DIR)/lib/libudev.so* $(1)/lib
+
+ $(INSTALL_DIR) $(1)/lib/udev
+ifneq ($(udev-extra-lib-bin-y),)
+ $(INSTALL_BIN) \
+ $(addprefix $(PKG_INSTALL_DIR)/lib/udev/, \
+ $(udev-extra-lib-bin-y)) \
+ $(1)/lib/udev/
+endif
+ifneq ($(udev-extra-lib-data-y),)
+ $(INSTALL_DATA) \
+ $(addprefix $(PKG_INSTALL_DIR)/lib/udev/, \
+ $(udev-extra-lib-data-y)) \
+ $(1)/lib/udev/
+endif
+endef
+
+$(eval $(call BuildPackage,udev))
diff --git a/package/system/udev/patches/0001-build-don-t-use-gc-sections.patch b/package/system/udev/patches/0001-build-don-t-use-gc-sections.patch
new file mode 100644
index 0000000000..f01a5ae1af
--- /dev/null
+++ b/package/system/udev/patches/0001-build-don-t-use-gc-sections.patch
@@ -0,0 +1,31 @@
+From 971a09345f108189ed899b236784a5440e43c8b6 Mon Sep 17 00:00:00 2001
+From: Daniel Mierswa <impulze@impulze.org>
+Date: Sun, 31 Jul 2011 23:51:49 +0000
+Subject: [PATCH 1/2] build: don't use --gc-sections
+
+somehow won't work with the wrt toolchain
+---
+ Makefile.am | 5 +----
+ 1 files changed, 1 insertions(+), 4 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index a0c007a..3d8ce92 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -18,12 +18,9 @@ AM_CPPFLAGS = \
+ -DLIBEXECDIR=\""$(libexecdir)"\"
+
+ AM_CFLAGS = \
+- -fvisibility=hidden \
+- -ffunction-sections \
+- -fdata-sections
++ -fvisibility=hidden
+
+ AM_LDFLAGS = \
+- -Wl,--gc-sections \
+ -Wl,--as-needed
+
+ DISTCHECK_CONFIGURE_FLAGS = \
+--
+1.7.6
+
diff --git a/package/system/udev/patches/0002-udevd-add-lrt-for-message-queue-symbols.patch b/package/system/udev/patches/0002-udevd-add-lrt-for-message-queue-symbols.patch
new file mode 100644
index 0000000000..55466bc256
--- /dev/null
+++ b/package/system/udev/patches/0002-udevd-add-lrt-for-message-queue-symbols.patch
@@ -0,0 +1,25 @@
+From ae90737100d901723af9890e69798bd1dac9a86d Mon Sep 17 00:00:00 2001
+From: Daniel Mierswa <impulze@impulze.org>
+Date: Sun, 31 Jul 2011 23:53:21 +0000
+Subject: [PATCH 2/2] udevd: add -lrt for message queue symbols
+
+---
+ Makefile.am | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 3d8ce92..7d8a4b6 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -164,7 +164,7 @@ udev_udevd_SOURCES = \
+ udev/udevd.c \
+ udev/sd-daemon.h \
+ udev/sd-daemon.c
+-udev_udevd_LDADD = libudev/libudev-private.la
++udev_udevd_LDADD = libudev/libudev-private.la -lrt
+
+ udev_udevadm_SOURCES = \
+ $(udev_common_sources) \
+--
+1.7.6
+
diff --git a/package/system/udev/patches/0003-add_btn_trigger_happy_define.patch b/package/system/udev/patches/0003-add_btn_trigger_happy_define.patch
new file mode 100644
index 0000000000..77eaf13aa5
--- /dev/null
+++ b/package/system/udev/patches/0003-add_btn_trigger_happy_define.patch
@@ -0,0 +1,13 @@
+--- a/extras/input_id/input_id.c
++++ b/extras/input_id/input_id.c
+@@ -30,6 +30,10 @@
+ #include "libudev.h"
+ #include "libudev-private.h"
+
++#ifndef BTN_TRIGGER_HAPPY
++#define BTN_TRIGGER_HAPPY 0x2c0
++#endif
++
+ /* we must use this kernel-compatible implementation */
+ #define BITS_PER_LONG (sizeof(unsigned long) * 8)
+ #define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
diff --git a/package/system/utils/e2fsprogs/Makefile b/package/system/utils/e2fsprogs/Makefile
deleted file mode 100644
index ebc21c9067..0000000000
--- a/package/system/utils/e2fsprogs/Makefile
+++ /dev/null
@@ -1,169 +0,0 @@
-#
-# Copyright (C) 2006-2012 OpenWrt.org
-# Copyright 2010 Vertical Communications
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=e2fsprogs
-PKG_VERSION:=1.42.4
-PKG_MD5SUM:=b6e296f210d642361b7394437ff0f318
-PKG_RELEASE:=1
-
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=@SF/e2fsprogs
-
-PKG_BUILD_DEPENDS:=util-linux
-PKG_INSTALL:=1
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/e2fsprogs/Default
- URL:=http://e2fsprogs.sourceforge.net/
- SUBMENU:=Filesystem
-endef
-
-define Package/e2fsprogs
-$(call Package/e2fsprogs/Default)
- SECTION:=utils
- CATEGORY:=Utilities
- TITLE:=Ext2/3/4 filesystem utilities
- DEPENDS:=+libblkid +libuuid +libext2fs
-endef
-
-define Package/e2fsprogs/description
- This package contains essential ext2 filesystem utilities which consists of
- e2fsck, mke2fs, tune2fs, and most of the other core ext2
- filesystem utilities.
-endef
-
-define Package/libext2fs
-$(call Package/e2fsprogs/Default)
- DEPENDS:=+libcom_err
- SECTION:=libs
- CATEGORY:=Libraries
- TITLE:=ext2/3/4 filesystem library
-endef
-
-define Package/libext2fs/description
- libext2fs is a library which can access ext2, ext3 and ext4 filesystems.
-endef
-
-define Package/libcom_err
-$(call Package/e2fsprogs/Default)
- DEPENDS:=+libpthread
- SECTION:=libs
- CATEGORY:=Libraries
- TITLE:=Common error description library
-endef
-
-define Package/libcom_err/description
- libcom_err is a library providing common error descriptions
-endef
-
-define Package/tune2fs
-$(call Package/e2fsprogs)
- TITLE:=Ext2 Filesystem tune utility
- DEPENDS:= +e2fsprogs
-endef
-
-define Package/resize2fs
-$(call Package/e2fsprogs)
- TITLE:=Ext2 Filesystem resize utility
- DEPENDS:= +e2fsprogs
-endef
-
-define Package/badblocks
-$(call Package/e2fsprogs)
- TITLE:=Ext2 Filesystem badblocks utility
- DEPENDS:= +e2fsprogs
-endef
-
-TARGET_CFLAGS += $(FPIC)
-
-CONFIGURE_ARGS += \
- --enable-elf-shlibs \
- --disable-libuuid \
- --disable-libblkid \
- --disable-uuidd \
- --disable-tls \
- --disable-nls \
- --disable-rpath
-
-define Build/Prepare
- $(call Build/Prepare/Default)
- $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(PKG_BUILD_DIR)/config/
-endef
-
-define Build/Compile
- $(MAKE) -C $(PKG_BUILD_DIR)/util \
- BUILDCC="$(HOSTCC)" \
- CFLAGS="" \
- CPPFLAGS="" \
- LDFLAGS="" \
- subst
- $(MAKE) -C $(PKG_BUILD_DIR) \
- BUILDCC="$(HOSTCC)" \
- DESTDIR="$(PKG_INSTALL_DIR)" \
- all
-endef
-
-define Build/InstallDev
- $(MAKE) -C $(PKG_BUILD_DIR) \
- BUILDCC="$(HOSTCC)" \
- DESTDIR="$(1)" \
- install-libs
- $(MAKE) -C $(PKG_BUILD_DIR)/lib/ext2fs \
- BUILDCC="$(HOSTCC)" \
- DESTDIR="$(1)" \
- install
-endef
-
-define Package/e2fsprogs/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/e2fsck $(1)/usr/sbin/
- $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/mke2fs $(1)/usr/sbin/
- ln -sf mke2fs $(1)/usr/sbin/mkfs.ext2
- ln -sf mke2fs $(1)/usr/sbin/mkfs.ext3
- ln -sf mke2fs $(1)/usr/sbin/mkfs.ext4
- $(INSTALL_DIR) $(1)/usr/lib
- $(CP) $(PKG_INSTALL_DIR)/usr/lib/libe2p.so.* $(1)/usr/lib/
- $(INSTALL_DIR) $(1)/etc/init.d
- $(INSTALL_DIR) $(1)/lib/functions/fsck
- $(INSTALL_DATA) ./files/e2fsck.sh $(1)/lib/functions/fsck/
- $(INSTALL_DATA) ./files/e2fsck.conf $(1)/etc/e2fsck.conf
-endef
-
-define Package/libcom_err/install
- $(INSTALL_DIR) $(1)/usr/lib
- $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcom_err.so.* $(1)/usr/lib/
-endef
-
-define Package/libext2fs/install
- $(INSTALL_DIR) $(1)/usr/lib
- $(CP) $(PKG_INSTALL_DIR)/usr/lib/libext2fs.so.* $(1)/usr/lib/
-endef
-
-define Package/tune2fs/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tune2fs $(1)/usr/sbin/
-endef
-
-define Package/resize2fs/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/resize2fs $(1)/usr/sbin/
-endef
-
-define Package/badblocks/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/badblocks $(1)/usr/sbin/
-endef
-
-$(eval $(call BuildPackage,e2fsprogs))
-$(eval $(call BuildPackage,libext2fs))
-$(eval $(call BuildPackage,libcom_err))
-$(eval $(call BuildPackage,tune2fs))
-$(eval $(call BuildPackage,resize2fs))
-$(eval $(call BuildPackage,badblocks))
diff --git a/package/system/utils/e2fsprogs/files/e2fsck.conf b/package/system/utils/e2fsprogs/files/e2fsck.conf
deleted file mode 100644
index 9c96b49585..0000000000
--- a/package/system/utils/e2fsprogs/files/e2fsck.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-[options]
-broken_system_clock = true
-
diff --git a/package/system/utils/e2fsprogs/files/e2fsck.sh b/package/system/utils/e2fsprogs/files/e2fsck.sh
deleted file mode 100644
index 22031edb67..0000000000
--- a/package/system/utils/e2fsprogs/files/e2fsck.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-# Copyright 2010 Vertical Communications
-# Copyright 2012 OpenWrt.org
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-fsck_e2fsck() {
- set -o pipefail
- e2fsck -p "$device" 2>&1 | logger -t "fstab: e2fsck ($device)"
- local status="$?"
- set +o pipefail
- case "$status" in
- 0|1) ;; #success
- 2) reboot;;
- 4) echo "e2fsck ($device): Warning! Uncorrected errors."| logger -t fstab
- return 1
- ;;
- *) echo "e2fsck ($device): Error $status. Check not complete."| logger -t fstab;;
- esac
- return 0
-}
-
-fsck_ext2() {
- fsck_e2fsck "$@"
-}
-
-fsck_ext3() {
- fsck_e2fsck "$@"
-}
-
-fsck_ext4() {
- fsck_e2fsck "$@"
-}
-
-append libmount_known_fsck "ext2"
-append libmount_known_fsck "ext3"
-append libmount_known_fsck "ext4"
diff --git a/package/system/utils/e2fsprogs/patches/001-link-against-libuuid.patch b/package/system/utils/e2fsprogs/patches/001-link-against-libuuid.patch
deleted file mode 100644
index e0564dc355..0000000000
--- a/package/system/utils/e2fsprogs/patches/001-link-against-libuuid.patch
+++ /dev/null
@@ -1,38 +0,0 @@
---- a/configure
-+++ b/configure
-@@ -5038,7 +5038,7 @@ if test "${ac_cv_lib_blkid_blkid_get_cac
- $as_echo_n "(cached) " >&6
- else
- ac_check_lib_save_LIBS=$LIBS
--LIBS="-lblkid $LIBBLKID $LIBS"
-+LIBS="-lblkid $LIBBLKID $LIBUUID $LIBS"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
-
---- a/misc/Makefile.in
-+++ b/misc/Makefile.in
-@@ -146,10 +146,10 @@ partinfo: partinfo.o
- $(E) " LD $@"
- $(Q) $(CC) $(ALL_LDFLAGS) -o partinfo partinfo.o
-
--e2initrd_helper: e2initrd_helper.o $(DEPLIBS) $(DEPLIBBLKID) $(LIBEXT2FS)
-+e2initrd_helper: e2initrd_helper.o $(DEPLIBS) $(DEPLIBBLKID) $(DEPLIBUUID) $(LIBEXT2FS)
- $(E) " LD $@"
- $(Q) $(CC) $(ALL_LDFLAGS) -o e2initrd_helper e2initrd_helper.o $(LIBS) \
-- $(LIBBLKID) $(LIBEXT2FS) $(LIBINTL)
-+ $(LIBBLKID) $(LIBUUID) $(LIBEXT2FS) $(LIBINTL)
-
- tune2fs: $(TUNE2FS_OBJS) $(DEPLIBS) $(DEPLIBS_E2P) $(DEPLIBBLKID) \
- $(DEPLIBUUID) $(DEPLIBQUOTA) $(LIBEXT2FS)
-@@ -289,9 +289,9 @@ dumpe2fs.profiled: $(PROFILED_DUMPE2FS_O
- $(PROFILED_DUMPE2FS_OBJS) $(PROFILED_LIBS) \
- $(PROFILED_LIBE2P) $(PROFILED_LIBUUID) $(LIBINTL)
-
--fsck: $(FSCK_OBJS) $(DEPLIBBLKID)
-+fsck: $(FSCK_OBJS) $(DEPLIBBLKID) $(DEPLIBUUID)
- $(E) " LD $@"
-- $(Q) $(CC) $(ALL_LDFLAGS) -o fsck $(FSCK_OBJS) $(LIBBLKID) $(LIBINTL)
-+ $(Q) $(CC) $(ALL_LDFLAGS) -o fsck $(FSCK_OBJS) $(LIBBLKID) $(LIBUUID) $(LIBINTL)
-
- fsck.profiled: $(PROFILED_FSCK_OBJS) $(PROFILED_DEPLIBBLKID)
- $(E) " LD $@"
diff --git a/package/system/utils/e2fsprogs/patches/002-no_malloc_h.patch b/package/system/utils/e2fsprogs/patches/002-no_malloc_h.patch
deleted file mode 100644
index 209b47c1cc..0000000000
--- a/package/system/utils/e2fsprogs/patches/002-no_malloc_h.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/util/symlinks.c
-+++ b/util/symlinks.c
-@@ -8,7 +8,6 @@
- #endif
- #include <stdio.h>
- #include <stdlib.h>
--#include <malloc.h>
- #include <string.h>
- #include <fcntl.h>
- #include <sys/param.h>
diff --git a/package/system/utils/fbtest/Makefile b/package/system/utils/fbtest/Makefile
deleted file mode 100644
index 05e67cb63a..0000000000
--- a/package/system/utils/fbtest/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright (C) 2012 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:=fbtest
-PKG_RELEASE:=1
-
-PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/fbtest
- SECTION:=utils
- CATEGORY:=Utilities
- TITLE:=Frame buffer device testing tool
- DEPENDS:=@DISPLAY_SUPPORT
-endef
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
- $(CP) ./src/* $(PKG_BUILD_DIR)/
-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/fbtest/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/fbtest $(1)/usr/sbin/
-endef
-
-$(eval $(call BuildPackage,fbtest))
diff --git a/package/system/utils/fbtest/src/Makefile b/package/system/utils/fbtest/src/Makefile
deleted file mode 100644
index 075bc0ecbf..0000000000
--- a/package/system/utils/fbtest/src/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-CC = gcc
-CFLAGS = -Wall
-OBJS = fbtest.o
-
-all: fbtest
-
-%.o: %.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-fbtest: $(OBJS)
- $(CC) -o $@ $(OBJS)
-
-clean:
- rm -f rbcfg *.o
diff --git a/package/system/utils/fbtest/src/fbtest.c b/package/system/utils/fbtest/src/fbtest.c
deleted file mode 100644
index 6e9c2f85fa..0000000000
--- a/package/system/utils/fbtest/src/fbtest.c
+++ /dev/null
@@ -1,448 +0,0 @@
-/******************************************************************************
- * fbtest - fbtest.c
- * test program for the tuxbox-framebuffer device
- * tests all GTX/eNX supported modes
- *
- * (c) 2003 Carsten Juttner (carjay@gmx.net)
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- ******************************************************************************
- * $Id: fbtest.c,v 1.5 2005/01/14 23:14:41 carjay Exp $
- ******************************************************************************/
-
-// TODO: - should restore the colour map and mode to what it was before
-// - is colour map handled correctly?
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-
-#include <linux/fb.h>
-
-#include <error.h>
-
-#define FBDEV "/dev/fb0"
-
-struct vidsize{
- int width;
- int height;
-};
-static
-const struct vidsize vidsizetable[]={ // all supported sizes
- {720,576},{720,480},{720,288},{720,240},
- {640,576},{640,480},{640,288},{640,240},
- {360,576},{360,480},{360,288},{360,240},
- {320,576},{320,480},{320,288},{320,240}
-};
-#define VIDSIZENUM (sizeof(vidsizetable)/sizeof(struct vidsize))
-
-enum pixenum{ // keep in sync with pixname !
- CLUT4=0,
- CLUT8,
- RGB565,
- ARGB1555,
- ARGB
-};
-const char *pixname[] = {
- "CLUT4",
- "CLUT8",
- "RGB565",
- "ARGB1555",
- "ARGB"
-};
-
-struct pixelformat{
- char *name;
- struct fb_bitfield red;
- struct fb_bitfield green;
- struct fb_bitfield blue;
- struct fb_bitfield transp;
- char bpp;
- char pixenum;
-};
-
-static // so far these are all modes supported by the eNX (only partially by GTX)
-const struct pixelformat pixelformattable[] = {
- { .name = "CLUT4 ARGB8888", // CLUT4 (ARGB8888)
- .bpp = 4, .pixenum = CLUT4,
- .red = { .offset = 0, .length=8, .msb_right =0 },
- .green = { .offset = 0, .length=8, .msb_right =0 },
- .blue = { .offset = 0, .length=8, .msb_right =0 },
- .transp= { .offset = 0, .length=8, .msb_right =0 }
- },
- { .name = "CLUT4 ARGB1555", // CLUT4 (ARGB1555)
- .bpp = 4, .pixenum = CLUT4,
- .red = { .offset = 0, .length=5, .msb_right =0 },
- .green = { .offset = 0, .length=5, .msb_right =0 },
- .blue = { .offset = 0, .length=5, .msb_right =0 },
- .transp= { .offset = 0, .length=1, .msb_right =0 }
- },
- { .name = "CLUT8 ARGB8888", // CLUT8 (ARGB8888)
- .bpp = 8, .pixenum = CLUT8,
- .red = { .offset = 0, .length=8, .msb_right =0 },
- .green = { .offset = 0, .length=8, .msb_right =0 },
- .blue = { .offset = 0, .length=8, .msb_right =0 },
- .transp= { .offset = 0, .length=8, .msb_right =0 }
- },
- { .name = "CLUT8 ARGB1555", // CLUT8 (ARGB1555)
- .bpp = 8, .pixenum = CLUT8,
- .red = { .offset = 0, .length=5, .msb_right =0 },
- .green = { .offset = 0, .length=5, .msb_right =0 },
- .blue = { .offset = 0, .length=5, .msb_right =0 },
- .transp= { .offset = 0, .length=1, .msb_right =0 }
- },
- { .name = "ARGB1555", // ARGB1555
- .bpp = 16, .pixenum = ARGB1555,
- .red = { .offset = 10, .length=5, .msb_right =0 },
- .green = { .offset = 5, .length=5, .msb_right =0 },
- .blue = { .offset = 0, .length=5, .msb_right =0 },
- .transp= { .offset = 15, .length=1, .msb_right =0 }
- },
- { .name = "RGB565", // RGB565
- .bpp = 16, .pixenum = RGB565,
- .red = { .offset = 11, .length=5, .msb_right =0 },
- .green = { .offset = 5, .length=6, .msb_right =0 },
- .blue = { .offset = 0, .length=5, .msb_right =0 },
- .transp= { .offset = 0, .length=0, .msb_right =0 }
- },
- { .name = "ARGB", // 32 f*cking bits, the real McCoy :)
- .bpp = 32, .pixenum = ARGB,
- .red = { .offset = 16, .length=8, .msb_right =0 },
- .green = { .offset = 8, .length=8, .msb_right =0 },
- .blue = { .offset = 0, .length=8, .msb_right =0 },
- .transp= { .offset = 24, .length=8, .msb_right =0 }
- }
-};
-#define PIXELFORMATNUM (sizeof(pixelformattable)/sizeof(struct pixelformat))
-
-struct colour {
- __u16 r;
- __u16 g;
- __u16 b;
- __u16 a;
-};
-static
-struct colour colourtable[] = {
- {.r =0xffff, .g = 0xffff, .b=0xffff, .a=0xffff}, // fully transparent white
- {.r =0xffff, .g = 0x0000, .b=0x0000, .a=0x0000}, // red
- {.r =0x0000, .g = 0xffff, .b=0x0000, .a=0x0000}, // green
- {.r =0x0000, .g = 0x0000, .b=0xffff, .a=0x0000}, // blue
- {.r =0x0000, .g = 0x0000, .b=0x0000, .a=0x0000} // black
-};
-#define COLOURNUM (sizeof(colourtable)/sizeof(struct colour))
-
-struct rect{
- int x;
- int y;
- int width;
- int height;
- const struct colour *col;
-};
-struct pixel{ // up to 32 bits of pixel information
- char byte[4];
-};
-
-void col2pixel (struct pixel *pix, const struct pixelformat *pixf, const struct colour *col){
- switch (pixf->pixenum){
- case RGB565:
- pix->byte[0]=(col->r&0xf8)|(col->g&0xfc)>>5;
- pix->byte[1]=(col->g&0xfc)<<3|(col->b&0xf8)>>3;
- break;
- case ARGB1555:
- pix->byte[0]=(col->a&0x80)|(col->r&0xf8)>>1|(col->g&0xf8)>>6;
- pix->byte[1]=(col->g&0xf8)<<2|(col->b&0xf8)>>3;
- break;
- case ARGB:
- pix->byte[0]=col->a;
- pix->byte[1]=col->r;
- pix->byte[2]=col->g;
- pix->byte[3]=col->b;
- break;
- default:
- printf ("unknown pixelformat\n");
- exit(1);
- }
-}
-
-int setmode(int fbd, const struct pixelformat *pixf,const struct vidsize *vids){
- struct fb_var_screeninfo var;
- int stat;
- stat = ioctl (fbd, FBIOGET_VSCREENINFO,&var);
- if (stat<0) return -2;
-
- var.xres= vids->width;
- var.xres_virtual = vids->width;
- var.yres= vids->height;
- var.yres_virtual = vids->height;
-
- var.bits_per_pixel = pixf->bpp;
- var.red = pixf->red;
- var.green = pixf->green;
- var.blue = pixf->blue;
- var.transp = pixf->transp;
-
- stat = ioctl (fbd, FBIOPUT_VSCREENINFO,&var);
- if (stat<0) return -1;
- return 0;
-}
-
-// unefficient implementation, do NOT use it for your next ego shooter, please :)
-// for 4-Bit only rectangles with even width are supported
-// CLUT-modes use value of red component as index
-void drawrect(void *videoram, struct rect *r, const struct pixelformat *pixf, const struct vidsize *vids){
- int x,y,corwidth, bpp = 0, tocopy = 1;
- struct pixel pix;
- unsigned char *pmem = videoram;
- corwidth = r->width; // actually only "corrected" for 4 Bit
-
- if (pixf->pixenum!=CLUT4&&pixf->pixenum!=CLUT8){
- switch (pixf->pixenum){
- case ARGB1555:
- case RGB565:
- bpp = 16;
- tocopy = 2;
- break;
- case ARGB:
- bpp = 32;
- tocopy = 4;
- break;
- default:
- printf ("drawrect: unknown pixelformat(%d) bpp:%d\n",pixf->pixenum,pixf->bpp);
- exit(1);
- }
- col2pixel(&pix,pixf,r->col);
- } else {
- switch (pixf->pixenum){ // CLUT = Colour LookUp Table (palette)
- case CLUT4: // take red value as index in this case
- pix.byte[0]=(r->col->r)<<4|(r->col->r&0xf); // slightly cryptic... "rect->colour->red"
- corwidth>>=1; // we copy bytes
- bpp=4;
- tocopy=1;
- break;
- case CLUT8:
- pix.byte[0]=(r->col->r&0xff);
- bpp=8;
- tocopy=1;
- break;
- }
- }
- pmem=videoram+((((r->y*vids->width)+r->x)*bpp)>>3);
- for (y=0;y<r->height;y++){
- int offset = 0;
- for (x=0;x<corwidth;x++){
- memcpy (pmem+offset,pix.byte,tocopy);
- offset+=tocopy;
- }
- pmem +=((vids->width*bpp)>>3); // skip one whole line, actually should be taken from "fix-info"
- }
-}
-
-// create quick little test image, 4 colours from table
-void draw4field(void *videoram, const struct pixelformat *pixf, const struct vidsize *vids){
- struct rect r;
- struct colour c;
- int height, width;
- c.r = 1; // only used for the indexed modes, r is taken as index
- height = vids->height;
- width = vids->width;
-
- r.height = height>>1;
- r.width = width>>1;
- r.x = 0; r.y = 0;
- if (pixf->pixenum==CLUT4||pixf->pixenum==CLUT8) r.col = &c;
- else r.col = &colourtable[1];
- drawrect (videoram, &r, pixf, vids);
-
- r.x = width/2; r.y = 0;
- if (pixf->pixenum==CLUT4||pixf->pixenum==CLUT8) c.r = 2;
- else r.col = &colourtable[2];
- drawrect (videoram, &r, pixf, vids);
-
- r.x = 0; r.y = height/2;
- if (pixf->pixenum==CLUT4||pixf->pixenum==CLUT8) c.r = 3;
- else r.col = &colourtable[3];
- drawrect (videoram, &r, pixf, vids);
-
- r.x = width/2; r.y = height/2;
- if (pixf->pixenum==CLUT4||pixf->pixenum==CLUT8) c.r = 0;
- else r.col = &colourtable[0];
- drawrect (videoram, &r, pixf, vids);
-}
-
-void usage(char *name){
- printf ("Usage: %s [options]\n"
- "Options: -f<pixelformat>\n"
- " where format is one of:\n"
- " CLUT4,CLUT8,ARGB1555,RGB565,ARGB\n"
- " -s<width>x<heigth>\n"
- " where width is either 720,640,360,320\n"
- " and height is either 288,240,480,576\n"
- " -n\n"
- " disables clearing the framebuffer after drawing\n"
- " the testimage. This can be useful to keep the last\n"
- " drawn image onscreen.\n"
- "\nExample: %s -fRGB322\n",name,name);
- exit(0);
-}
-
-int main (int argc,char **argv){
- struct fb_fix_screeninfo fix;
- struct fb_var_screeninfo var;
- struct fb_cmap cmap;
- struct rect r;
- int fbd;
- unsigned char *pfb;
- int stat;
- int optchar,fmode=-1,smode=-1,clear=1;
- int i_cmap,i_size,i_pix;
- extern char *optarg;
-
- if (argc!=0&&argc>4) usage(argv[0]);
- while ( (optchar = getopt (argc,argv,"f:s:n"))!= -1){
- int i,height,width;
- switch (optchar){
- case 'f':
- for (i=0;i<(sizeof(pixname)/sizeof(char*));i++){
- if (!strncmp (optarg,pixname[i],strlen(pixname[i]))){
- fmode=i;
- printf ("displaying only %s-modes\n",pixname[i]);
- break;
- }
- }
- if (fmode==-1){
- printf ("unknown pixelformat\n");
- exit(0);
- }
- break;
- case 's':
- if (sscanf (optarg,"%dx%d",&width,&height)!=2){
- printf ("parsing size failed\n");
- exit(0);
- } else {
- printf ("requested size %dx%d\n",width,height);
- for (i=0;i<VIDSIZENUM;i++){
- if (vidsizetable[i].width == width &&
- vidsizetable[i].height == height){
- smode = i;
- break;
- }
- }
- if (smode==-1){
- printf ("this size is not supported\n");
- exit(0);
- }
- }
- break;
- case 'n':
- clear = 0;
- printf ("clearing framebuffer after drawing is disabled\n");
- break;
- case '?':
- usage (argv[0]);
- }
- }
-
- fbd = open (FBDEV, O_RDWR);
- if (fbd<0){
- perror ("Error opening framebuffer device");
- return 1;
- }
- stat = ioctl (fbd, FBIOGET_FSCREENINFO,&fix);
- if (stat<0){
- perror ("Error getting fix screeninfo");
- return 1;
- }
- stat = ioctl (fbd, FBIOGET_VSCREENINFO,&var);
- if (stat<0){
- perror ("Error getting var screeninfo");
- return 1;
- }
- stat = ioctl (fbd, FBIOPUT_VSCREENINFO,&var);
- if (stat<0){
- perror ("Error setting mode");
- return 1;
- }
- pfb = mmap (0, fix.smem_len, PROT_READ|PROT_WRITE, MAP_SHARED, fbd, 0);
- if (pfb == MAP_FAILED){
- perror ("Error mmap'ing framebuffer device");
- return 1;
- }
-
- // iterate over all modes
- for (i_pix=0;i_pix<PIXELFORMATNUM;i_pix++){
- if (fmode!=-1 && pixelformattable[i_pix].pixenum != fmode) continue;
- printf ("testing: %s",pixelformattable[i_pix].name);
- printf (" for sizes: \n");
- for (i_size=0;i_size<VIDSIZENUM;i_size++){
- if (smode!=-1 && i_size!=smode) continue;
- printf ("%dx%d ",vidsizetable[i_size].width,vidsizetable[i_size].height);
- fflush(stdout);
- if ((i_size%4)==3) printf ("\n");
-
- // try to set mode
- stat = setmode(fbd,&pixelformattable[i_pix],&vidsizetable[i_size]);
- if (stat==-2) perror ("fbtest: could not get fb_var-screeninfo from fb-device");
- else if (stat==-1){
- printf ("\nCould not set mode %s (%dx%d), possible reasons:\n"
- "- you have a GTX (soz m8)\n"
- "- your configuration does not have enough graphics RAM\n"
- "- you found a bug\n"
- "choose your poison accordingly...\n",
- pixelformattable[i_pix].name,vidsizetable[i_size].width,vidsizetable[i_size].height);
- continue;
- }
- // fill cmap;
- cmap.len = 1;
- if ((pixelformattable[i_pix].bpp==4)||
- ((pixelformattable[i_pix].bpp==8)&&(pixelformattable[i_pix].red.length!=3))){
- for (i_cmap=0;i_cmap<COLOURNUM;i_cmap++){
- cmap.start=i_cmap;
- cmap.red=&colourtable[i_cmap].r;
- cmap.green=&colourtable[i_cmap].g;
- cmap.blue=&colourtable[i_cmap].b;
- cmap.transp=&colourtable[i_cmap].a;
- stat = ioctl (fbd, FBIOPUTCMAP, &cmap);
- if (stat<0) printf ("setting colourmap failed\n");
- }
- }
- // create the test image
- draw4field(pfb,&pixelformattable[i_pix],&vidsizetable[i_size]);
- usleep (500000);
- // clear screen
- if (clear){
- r.x=r.y=0;r.width = vidsizetable[i_size].width; r.height = vidsizetable[i_size].height;
- r.col = &colourtable[4];
- drawrect(pfb,&r,&pixelformattable[i_pix],&vidsizetable[i_size]);
- }
- }
- printf ("\n");
- }
-
- stat = munmap (pfb,fix.smem_len);
- if (stat<0){
- perror ("Error munmap'ing framebuffer device");
- return 1;
- }
- close (fbd);
- return 0;
-}
diff --git a/package/system/utils/hostap-utils/Makefile b/package/system/utils/hostap-utils/Makefile
deleted file mode 100644
index 1d7b22122e..0000000000
--- a/package/system/utils/hostap-utils/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright (C) 2006 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:=hostap-utils
-PKG_VERSION:=0.4.7
-PKG_RELEASE:=1
-
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=http://hostap.epitest.fi/releases/
-PKG_MD5SUM:=afe041581b8f01666e353bec20917c85
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/hostap-utils
- SECTION:=net
- CATEGORY:=Network
- DEPENDS:=kmod-hostap
- TITLE:=Host AP driver utility programs
- URL:=http://hostap.epitest.fi/
-endef
-
-define Build/Compile
- $(MAKE) -C $(PKG_BUILD_DIR) \
- $(TARGET_CONFIGURE_OPTS) \
- CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -Wall" \
- all
-endef
-
-define Package/hostap-utils/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostap_crypt_conf $(1)/usr/sbin/
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostap_diag $(1)/usr/sbin/
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostap_io_debug $(1)/usr/sbin/
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostap_rid $(1)/usr/sbin/
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/prism2_srec $(1)/usr/sbin/
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/split_combined_hex $(1)/usr/sbin/
-endef
-
-$(eval $(call BuildPackage,hostap-utils))
diff --git a/package/system/utils/nvram/Makefile b/package/system/utils/nvram/Makefile
deleted file mode 100644
index 81cff034c4..0000000000
--- a/package/system/utils/nvram/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Copyright (C) 2009-2010 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:=nvram
-PKG_RELEASE:=9
-
-PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/nvram
- SECTION:=utils
- CATEGORY:=Base system
- TITLE:=Userspace port of the Broadcom NVRAM manipulation tool
- MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
- DEPENDS:=@TARGET_brcm47xx||@TARGET_ar71xx
-endef
-
-define Package/nvram/description
- This package contains an utility to manipulate NVRAM on Broadcom based devices.
- It works on bcm47xx (Linux 2.6) without using the kernel api.
-endef
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
- $(CP) ./src/* $(PKG_BUILD_DIR)/
-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 Build/InstallDev
- $(INSTALL_DIR) $(1)/usr/lib
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/libnvram.so.0.1 $(1)/usr/lib/
- ln -s libnvram.so.0.1 $(1)/usr/lib/libnvram.so
-endef
-
-define Package/nvram/install
- $(INSTALL_DIR) $(1)/etc/init.d
- $(INSTALL_BIN) ./files/nvram.init $(1)/etc/init.d/nvram
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/nvram $(1)/usr/sbin/
- $(INSTALL_DIR) $(1)/usr/lib
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/libnvram.so.0.1 $(1)/usr/lib/
-endef
-
-$(eval $(call BuildPackage,nvram))
diff --git a/package/system/utils/nvram/files/nvram.init b/package/system/utils/nvram/files/nvram.init
deleted file mode 100755
index 467ab28195..0000000000
--- a/package/system/utils/nvram/files/nvram.init
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/bin/sh /etc/rc.common
-# NVRAM setup
-#
-# This file handles the NVRAM quirks of various hardware.
-
-START=02
-alias debug=${DEBUG:-:}
-
-nvram_default() {
- [ -z "$(nvram get $1)" ] && nvram set "$1=$2"
-}
-
-nvram_set() { # for the linksys fixup part
- [ "$(nvram get "$1")" = "$2" -a "$2" != "" ] || {
- COMMIT=1
- /usr/sbin/nvram set "$1=$2"
- }
-}
-
-fixup_linksys() {
- # work around braindead CFE defaults in linksys routers
- boardtype=$(nvram get boardtype)
- boardnum=$(nvram get boardnum)
- boardflags=$(($(nvram get boardflags)))
- adm_switch="$(( ($boardflags & 0x80) >> 7 ))"
-
- [ -n "$(nvram get vxkilled)" ] && boardtype=0 # don't mess with the ram settings on the hacked cfe
- case "$(( $boardtype ))" in
- "1800") #0x708
- if [ "$adm_switch" = 0 ]; then
- nvram_set sdram_init "$(printf 0x%04x $(( $(/usr/sbin/nvram get sdram_init) | 0x0100 )))"
- [ "$COMMIT" = 1 ] && {
- nvram_set clkfreq 216
- nvram_set sdram_ncdl 0x0
- nvram_set pa0itssit 62
- nvram_set pa0b0 0x15eb
- nvram_set pa0b1 0xfa82
- nvram_set pa0b2 0xfe66
- nvram_set pa0maxpwr 0x4e
- }
- fi
- ;;
- "1127") #0x467
- nvram_set sdram_init "$(printf 0x%04x $(( $(/usr/sbin/nvram get sdram_init) | 0x0100 )))"
- [ "$COMMIT" = 1 ] && {
- nvram_set sdram_ncdl 0x0
- nvram_set pa0itssit 62
- nvram_set pa0b0 0x168b
- nvram_set pa0b1 0xfabf
- nvram_set pa0b2 0xfeaf
- nvram_set pa0maxpwr 0x4e
- }
- ;;
- "1071") #0x042f
- # do sanity check first! max 0x0011 = 128mb
- SDRAM_INIT=$(printf %d $(/usr/sbin/nvram get sdram_init))
- [ "$SDRAM_INIT" -lt "9" -o "$SDRAM_INIT" -gt "17" ] && {
- # set this to default: 0x09 only if value is invaild like 16MB on Asus WL-500GP
- echo "sdram_init is invaild: $(printf 0x%04x $SDRAM_INIT), force to default!"
- nvram_set sdram_init 0x0009
- }
- # on WRT54G3GV2 set flag, so checksum errors of firmware image 2 don't stop the boot process
- noset_try_flag=$(nvram get noset_try_flag)
- [ "$noset_try_flag" = 0 ] && {
- echo "setting noset_try_flag to 1."
- nvram_set noset_try_flag 1
- }
- [ "$COMMIT" = 1 ] && {
- nvram_set sdram_ncdl 0x0
- }
- esac
-}
-
-start() {
- # Don't do any fixups on the WGT634U
- [ "$(cat /proc/diag/model)" = "Netgear WGT634U" ] && return
-
- fixup_linksys
-
- # OFDM Power Offset is set incorrectly on many boards.
- # Setting it to 0 will increase the tx power to normal levels.
- nvram_set opo 0x0
-
- [ "$(nvram get il0macaddr)" = "00:90:4c:5f:00:2a" ] && {
- # if default wifi mac, set two higher than the lan mac
- nvram set il0macaddr=$(nvram get et0macaddr|
- awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')
- }
-
- [ "$(nvram get et0macaddr)" = "00:90:4c:c0:00:08" ] && {
- # OvisLink WL-1600GL mac workaround
- nvram set et0macaddr=$(hexdump -n 6 -s 130976 -e '5/1 "%02x:" "%02x" ' /dev/mtd/0)
- nvram set il0macaddr=$(nvram get et0macaddr|
- awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')
- }
-
- [ "$COMMIT" = "1" ] && nvram commit
-}
diff --git a/package/system/utils/nvram/src/Makefile b/package/system/utils/nvram/src/Makefile
deleted file mode 100644
index 4872728baf..0000000000
--- a/package/system/utils/nvram/src/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-CLI_FILENAME = nvram
-
-LIB_VERMAJOR = 0
-LIB_VERMINOR = 1
-LIB_FILENAME = libnvram.so
-
-LIB_CFLAGS = $(CFLAGS) -shared -fPIC
-LIB_LDFLAGS = $(LDFLAGS) -Wl,-soname,$(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR)
-
-CLI_CFLAGS = $(CFLAGS)
-CLI_LDFLAGS = $(LDFLAGS)
-
-CLI_OBJ = cli.o
-LIB_OBJ = crc.o nvram.o
-
-all: cli libnvram
-
-cli: libnvram
- $(CC) $(CLI_CFLAGS) -c -o cli.o cli.c
- $(CC) -o $(CLI_FILENAME) $(CLI_LDFLAGS) $(CLI_OBJ) \
- $(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR)
-
-cli.o: cli.c
- $(CC) $(CLI_CFLAGS) -c -o $@ $<
-
-libnvram:
- $(CC) $(LIB_CFLAGS) -c -o crc.o crc.c
- $(CC) $(LIB_CFLAGS) -c -o nvram.o nvram.c
- $(CC) $(LIB_CFLAGS) $(LIB_LDFLAGS) \
- -o $(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR) $(LIB_OBJ)
-
-clean:
- rm -f $(CLI_FILENAME) $(LIB_FILENAME)* *.o
diff --git a/package/system/utils/nvram/src/cli.c b/package/system/utils/nvram/src/cli.c
deleted file mode 100644
index 66ef904885..0000000000
--- a/package/system/utils/nvram/src/cli.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Command line interface for libnvram
- *
- * Copyright 2009, Jo-Philipp Wich <xm@subsignal.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * 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.
- *
- *
- * The libnvram code is based on Broadcom code for Linux 2.4.x .
- *
- */
-
-#include "nvram.h"
-
-
-static nvram_handle_t * nvram_open_rdonly(void)
-{
- const char *file = nvram_find_staging();
-
- if( file == NULL )
- file = nvram_find_mtd();
-
- if( file != NULL )
- return nvram_open(file, NVRAM_RO);
-
- return NULL;
-}
-
-static nvram_handle_t * nvram_open_staging(void)
-{
- if( nvram_find_staging() != NULL || nvram_to_staging() == 0 )
- return nvram_open(NVRAM_STAGING, NVRAM_RW);
-
- return NULL;
-}
-
-static int do_show(nvram_handle_t *nvram)
-{
- nvram_tuple_t *t;
- int stat = 1;
-
- if( (t = nvram_getall(nvram)) != NULL )
- {
- while( t )
- {
- printf("%s=%s\n", t->name, t->value);
- t = t->next;
- }
-
- stat = 0;
- }
-
- return stat;
-}
-
-static int do_get(nvram_handle_t *nvram, const char *var)
-{
- const char *val;
- int stat = 1;
-
- if( (val = nvram_get(nvram, var)) != NULL )
- {
- printf("%s\n", val);
- stat = 0;
- }
-
- return stat;
-}
-
-static int do_unset(nvram_handle_t *nvram, const char *var)
-{
- return nvram_unset(nvram, var);
-}
-
-static int do_set(nvram_handle_t *nvram, const char *pair)
-{
- char *val = strstr(pair, "=");
- char var[strlen(pair)];
- int stat = 1;
-
- if( val != NULL )
- {
- memset(var, 0, sizeof(var));
- strncpy(var, pair, (int)(val-pair));
- stat = nvram_set(nvram, var, (char *)(val + 1));
- }
-
- return stat;
-}
-
-static int do_info(nvram_handle_t *nvram)
-{
- nvram_header_t *hdr = nvram_header(nvram);
-
- /* CRC8 over the last 11 bytes of the header and data bytes */
- uint8_t crc = hndcrc8((unsigned char *) &hdr[0] + NVRAM_CRC_START_POSITION,
- hdr->len - NVRAM_CRC_START_POSITION, 0xff);
-
- /* Show info */
- printf("Magic: 0x%08X\n", hdr->magic);
- printf("Length: 0x%08X\n", hdr->len);
- printf("Offset: 0x%08X\n", nvram->offset);
-
- printf("CRC8: 0x%02X (calculated: 0x%02X)\n",
- hdr->crc_ver_init & 0xFF, crc);
-
- printf("Version: 0x%02X\n", (hdr->crc_ver_init >> 8) & 0xFF);
- printf("SDRAM init: 0x%04X\n", (hdr->crc_ver_init >> 16) & 0xFFFF);
- printf("SDRAM config: 0x%04X\n", hdr->config_refresh & 0xFFFF);
- printf("SDRAM refresh: 0x%04X\n", (hdr->config_refresh >> 16) & 0xFFFF);
- printf("NCDL values: 0x%08X\n\n", hdr->config_ncdl);
-
- printf("%i bytes used / %i bytes available (%.2f%%)\n",
- hdr->len, NVRAM_SPACE - hdr->len,
- (100.00 / (double)NVRAM_SPACE) * (double)hdr->len);
-
- return 0;
-}
-
-
-int main( int argc, const char *argv[] )
-{
- nvram_handle_t *nvram;
- int commit = 0;
- int write = 0;
- int stat = 1;
- int done = 0;
- int i;
-
- /* Ugly... iterate over arguments to see whether we can expect a write */
- for( i = 1; i < argc; i++ )
- if( ( !strcmp(argv[i], "set") && ++i < argc ) ||
- ( !strcmp(argv[i], "unset") && ++i < argc ) ||
- !strcmp(argv[i], "commit") )
- {
- write = 1;
- break;
- }
-
-
- nvram = write ? nvram_open_staging() : nvram_open_rdonly();
-
- if( nvram != NULL && argc > 1 )
- {
- for( i = 1; i < argc; i++ )
- {
- if( !strcmp(argv[i], "show") )
- {
- stat = do_show(nvram);
- done++;
- }
- else if( !strcmp(argv[i], "info") )
- {
- stat = do_info(nvram);
- done++;
- }
- else if( !strcmp(argv[i], "get") || !strcmp(argv[i], "unset") || !strcmp(argv[i], "set") )
- {
- if( (i+1) < argc )
- {
- switch(argv[i++][0])
- {
- case 'g':
- stat = do_get(nvram, argv[i]);
- break;
-
- case 'u':
- stat = do_unset(nvram, argv[i]);
- break;
-
- case 's':
- stat = do_set(nvram, argv[i]);
- break;
- }
- done++;
- }
- else
- {
- fprintf(stderr, "Command '%s' requires an argument!\n", argv[i]);
- done = 0;
- break;
- }
- }
- else if( !strcmp(argv[i], "commit") )
- {
- commit = 1;
- done++;
- }
- else
- {
- fprintf(stderr, "Unknown option '%s' !\n", argv[i]);
- done = 0;
- break;
- }
- }
-
- if( write )
- stat = nvram_commit(nvram);
-
- nvram_close(nvram);
-
- if( commit )
- stat = staging_to_nvram();
- }
-
- if( !nvram )
- {
- fprintf(stderr,
- "Could not open nvram! Possible reasons are:\n"
- " - No device found (/proc not mounted or no nvram present)\n"
- " - Insufficient permissions to open mtd device\n"
- " - Insufficient memory to complete operation\n"
- " - Memory mapping failed or not supported\n"
- );
-
- stat = 1;
- }
- else if( !done )
- {
- fprintf(stderr,
- "Usage:\n"
- " nvram show\n"
- " nvram info\n"
- " nvram get variable\n"
- " nvram set variable=value [set ...]\n"
- " nvram unset variable [unset ...]\n"
- " nvram commit\n"
- );
-
- stat = 1;
- }
-
- return stat;
-}
diff --git a/package/system/utils/nvram/src/crc.c b/package/system/utils/nvram/src/crc.c
deleted file mode 100644
index 22a36652aa..0000000000
--- a/package/system/utils/nvram/src/crc.c
+++ /dev/null
@@ -1,69 +0,0 @@
-#include "nvram.h"
-
-/*******************************************************************************
- * crc8
- *
- * Computes a crc8 over the input data using the polynomial:
- *
- * x^8 + x^7 +x^6 + x^4 + x^2 + 1
- *
- * The caller provides the initial value (either CRC8_INIT_VALUE
- * or the previous returned value) to allow for processing of
- * discontiguous blocks of data. When generating the CRC the
- * caller is responsible for complementing the final return value
- * and inserting it into the byte stream. When checking, a final
- * return value of CRC8_GOOD_VALUE indicates a valid CRC.
- *
- * Reference: Dallas Semiconductor Application Note 27
- * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
- * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
- * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
- *
- * ****************************************************************************
- */
-
-static const uint8_t crc8_table[256] = {
- 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B,
- 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21,
- 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF,
- 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5,
- 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14,
- 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E,
- 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80,
- 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA,
- 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95,
- 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF,
- 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01,
- 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B,
- 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA,
- 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0,
- 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E,
- 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34,
- 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0,
- 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A,
- 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54,
- 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E,
- 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF,
- 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5,
- 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B,
- 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61,
- 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E,
- 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74,
- 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA,
- 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0,
- 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41,
- 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B,
- 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5,
- 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F
-};
-
-uint8_t hndcrc8 (
- uint8_t * pdata, /* pointer to array of data to process */
- uint32_t nbytes, /* number of input data bytes to process */
- uint8_t crc /* either CRC8_INIT_VALUE or previous return value */
-) {
- while (nbytes-- > 0)
- crc = crc8_table[(crc ^ *pdata++) & 0xff];
-
- return crc;
-}
diff --git a/package/system/utils/nvram/src/nvram.c b/package/system/utils/nvram/src/nvram.c
deleted file mode 100644
index a0bc006d15..0000000000
--- a/package/system/utils/nvram/src/nvram.c
+++ /dev/null
@@ -1,556 +0,0 @@
-/*
- * NVRAM variable manipulation (common)
- *
- * Copyright 2004, Broadcom Corporation
- * Copyright 2009-2010, OpenWrt.org
- * All Rights Reserved.
- *
- * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
- * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
- * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
- *
- */
-
-#include "nvram.h"
-
-#define TRACE(msg) \
- printf("%s(%i) in %s(): %s\n", \
- __FILE__, __LINE__, __FUNCTION__, msg ? msg : "?")
-
-size_t nvram_erase_size = 0;
-
-
-/*
- * -- Helper functions --
- */
-
-/* String hash */
-static uint32_t hash(const char *s)
-{
- uint32_t hash = 0;
-
- while (*s)
- hash = 31 * hash + *s++;
-
- return hash;
-}
-
-/* Free all tuples. */
-static void _nvram_free(nvram_handle_t *h)
-{
- uint32_t i;
- nvram_tuple_t *t, *next;
-
- /* Free hash table */
- for (i = 0; i < NVRAM_ARRAYSIZE(h->nvram_hash); i++) {
- for (t = h->nvram_hash[i]; t; t = next) {
- next = t->next;
- free(t);
- }
- h->nvram_hash[i] = NULL;
- }
-
- /* Free dead table */
- for (t = h->nvram_dead; t; t = next) {
- next = t->next;
- free(t);
- }
-
- h->nvram_dead = NULL;
-}
-
-/* (Re)allocate NVRAM tuples. */
-static nvram_tuple_t * _nvram_realloc( nvram_handle_t *h, nvram_tuple_t *t,
- const char *name, const char *value )
-{
- if ((strlen(value) + 1) > NVRAM_SPACE)
- return NULL;
-
- if (!t) {
- if (!(t = malloc(sizeof(nvram_tuple_t) + strlen(name) + 1)))
- return NULL;
-
- /* Copy name */
- t->name = (char *) &t[1];
- strcpy(t->name, name);
-
- t->value = NULL;
- }
-
- /* Copy value */
- if (!t->value || strcmp(t->value, value))
- {
- if(!(t->value = (char *) realloc(t->value, strlen(value)+1)))
- return NULL;
-
- strcpy(t->value, value);
- t->value[strlen(value)] = '\0';
- }
-
- return t;
-}
-
-/* (Re)initialize the hash table. */
-static int _nvram_rehash(nvram_handle_t *h)
-{
- nvram_header_t *header = nvram_header(h);
- char buf[] = "0xXXXXXXXX", *name, *value, *eq;
-
- /* (Re)initialize hash table */
- _nvram_free(h);
-
- /* Parse and set "name=value\0 ... \0\0" */
- name = (char *) &header[1];
-
- for (; *name; name = value + strlen(value) + 1) {
- if (!(eq = strchr(name, '=')))
- break;
- *eq = '\0';
- value = eq + 1;
- nvram_set(h, name, value);
- *eq = '=';
- }
-
- /* Set special SDRAM parameters */
- if (!nvram_get(h, "sdram_init")) {
- sprintf(buf, "0x%04X", (uint16_t)(header->crc_ver_init >> 16));
- nvram_set(h, "sdram_init", buf);
- }
- if (!nvram_get(h, "sdram_config")) {
- sprintf(buf, "0x%04X", (uint16_t)(header->config_refresh & 0xffff));
- nvram_set(h, "sdram_config", buf);
- }
- if (!nvram_get(h, "sdram_refresh")) {
- sprintf(buf, "0x%04X",
- (uint16_t)((header->config_refresh >> 16) & 0xffff));
- nvram_set(h, "sdram_refresh", buf);
- }
- if (!nvram_get(h, "sdram_ncdl")) {
- sprintf(buf, "0x%08X", header->config_ncdl);
- nvram_set(h, "sdram_ncdl", buf);
- }
-
- return 0;
-}
-
-
-/*
- * -- Public functions --
- */
-
-/* Get nvram header. */
-nvram_header_t * nvram_header(nvram_handle_t *h)
-{
- return (nvram_header_t *) &h->mmap[h->offset];
-}
-
-/* Get the value of an NVRAM variable. */
-char * nvram_get(nvram_handle_t *h, const char *name)
-{
- uint32_t i;
- nvram_tuple_t *t;
- char *value;
-
- if (!name)
- return NULL;
-
- /* Hash the name */
- i = hash(name) % NVRAM_ARRAYSIZE(h->nvram_hash);
-
- /* Find the associated tuple in the hash table */
- for (t = h->nvram_hash[i]; t && strcmp(t->name, name); t = t->next);
-
- value = t ? t->value : NULL;
-
- return value;
-}
-
-/* Set the value of an NVRAM variable. */
-int nvram_set(nvram_handle_t *h, const char *name, const char *value)
-{
- uint32_t i;
- nvram_tuple_t *t, *u, **prev;
-
- /* Hash the name */
- i = hash(name) % NVRAM_ARRAYSIZE(h->nvram_hash);
-
- /* Find the associated tuple in the hash table */
- for (prev = &h->nvram_hash[i], t = *prev;
- t && strcmp(t->name, name); prev = &t->next, t = *prev);
-
- /* (Re)allocate tuple */
- if (!(u = _nvram_realloc(h, t, name, value)))
- return -12; /* -ENOMEM */
-
- /* Value reallocated */
- if (t && t == u)
- return 0;
-
- /* Move old tuple to the dead table */
- if (t) {
- *prev = t->next;
- t->next = h->nvram_dead;
- h->nvram_dead = t;
- }
-
- /* Add new tuple to the hash table */
- u->next = h->nvram_hash[i];
- h->nvram_hash[i] = u;
-
- return 0;
-}
-
-/* Unset the value of an NVRAM variable. */
-int nvram_unset(nvram_handle_t *h, const char *name)
-{
- uint32_t i;
- nvram_tuple_t *t, **prev;
-
- if (!name)
- return 0;
-
- /* Hash the name */
- i = hash(name) % NVRAM_ARRAYSIZE(h->nvram_hash);
-
- /* Find the associated tuple in the hash table */
- for (prev = &h->nvram_hash[i], t = *prev;
- t && strcmp(t->name, name); prev = &t->next, t = *prev);
-
- /* Move it to the dead table */
- if (t) {
- *prev = t->next;
- t->next = h->nvram_dead;
- h->nvram_dead = t;
- }
-
- return 0;
-}
-
-/* Get all NVRAM variables. */
-nvram_tuple_t * nvram_getall(nvram_handle_t *h)
-{
- int i;
- nvram_tuple_t *t, *l, *x;
-
- l = NULL;
-
- for (i = 0; i < NVRAM_ARRAYSIZE(h->nvram_hash); i++) {
- for (t = h->nvram_hash[i]; t; t = t->next) {
- if( (x = (nvram_tuple_t *) malloc(sizeof(nvram_tuple_t))) != NULL )
- {
- x->name = t->name;
- x->value = t->value;
- x->next = l;
- l = x;
- }
- else
- {
- break;
- }
- }
- }
-
- return l;
-}
-
-/* Regenerate NVRAM. */
-int nvram_commit(nvram_handle_t *h)
-{
- nvram_header_t *header = nvram_header(h);
- char *init, *config, *refresh, *ncdl;
- char *ptr, *end;
- int i;
- nvram_tuple_t *t;
- nvram_header_t tmp;
- uint8_t crc;
-
- /* Regenerate header */
- header->magic = NVRAM_MAGIC;
- header->crc_ver_init = (NVRAM_VERSION << 8);
- if (!(init = nvram_get(h, "sdram_init")) ||
- !(config = nvram_get(h, "sdram_config")) ||
- !(refresh = nvram_get(h, "sdram_refresh")) ||
- !(ncdl = nvram_get(h, "sdram_ncdl"))) {
- header->crc_ver_init |= SDRAM_INIT << 16;
- header->config_refresh = SDRAM_CONFIG;
- header->config_refresh |= SDRAM_REFRESH << 16;
- header->config_ncdl = 0;
- } else {
- header->crc_ver_init |= (strtoul(init, NULL, 0) & 0xffff) << 16;
- header->config_refresh = strtoul(config, NULL, 0) & 0xffff;
- header->config_refresh |= (strtoul(refresh, NULL, 0) & 0xffff) << 16;
- header->config_ncdl = strtoul(ncdl, NULL, 0);
- }
-
- /* Clear data area */
- ptr = (char *) header + sizeof(nvram_header_t);
- memset(ptr, 0xFF, NVRAM_SPACE - sizeof(nvram_header_t));
- memset(&tmp, 0, sizeof(nvram_header_t));
-
- /* Leave space for a double NUL at the end */
- end = (char *) header + NVRAM_SPACE - 2;
-
- /* Write out all tuples */
- for (i = 0; i < NVRAM_ARRAYSIZE(h->nvram_hash); i++) {
- for (t = h->nvram_hash[i]; t; t = t->next) {
- if ((ptr + strlen(t->name) + 1 + strlen(t->value) + 1) > end)
- break;
- ptr += sprintf(ptr, "%s=%s", t->name, t->value) + 1;
- }
- }
-
- /* End with a double NULL and pad to 4 bytes */
- *ptr = '\0';
- ptr++;
-
- if( (int)ptr % 4 )
- memset(ptr, 0, 4 - ((int)ptr % 4));
-
- ptr++;
-
- /* Set new length */
- header->len = NVRAM_ROUNDUP(ptr - (char *) header, 4);
-
- /* Little-endian CRC8 over the last 11 bytes of the header */
- tmp.crc_ver_init = header->crc_ver_init;
- tmp.config_refresh = header->config_refresh;
- tmp.config_ncdl = header->config_ncdl;
- crc = hndcrc8((unsigned char *) &tmp + NVRAM_CRC_START_POSITION,
- sizeof(nvram_header_t) - NVRAM_CRC_START_POSITION, 0xff);
-
- /* Continue CRC8 over data bytes */
- crc = hndcrc8((unsigned char *) &header[0] + sizeof(nvram_header_t),
- header->len - sizeof(nvram_header_t), crc);
-
- /* Set new CRC8 */
- header->crc_ver_init |= crc;
-
- /* Write out */
- msync(h->mmap, h->length, MS_SYNC);
- fsync(h->fd);
-
- /* Reinitialize hash table */
- return _nvram_rehash(h);
-}
-
-/* Open NVRAM and obtain a handle. */
-nvram_handle_t * nvram_open(const char *file, int rdonly)
-{
- int i;
- int fd;
- char *mtd = NULL;
- nvram_handle_t *h;
- nvram_header_t *header;
- int offset = -1;
-
- /* If erase size or file are undefined then try to define them */
- if( (nvram_erase_size == 0) || (file == NULL) )
- {
- /* Finding the mtd will set the appropriate erase size */
- if( (mtd = nvram_find_mtd()) == NULL || nvram_erase_size == 0 )
- {
- free(mtd);
- return NULL;
- }
- }
-
- if( (fd = open(file ? file : mtd, O_RDWR)) > -1 )
- {
- char *mmap_area = (char *) mmap(
- NULL, nvram_erase_size, PROT_READ | PROT_WRITE,
- (( rdonly == NVRAM_RO ) ? MAP_PRIVATE : MAP_SHARED) | MAP_LOCKED, fd, 0);
-
- if( mmap_area != MAP_FAILED )
- {
- for( i = 0; i <= ((nvram_erase_size - NVRAM_SPACE) / sizeof(uint32_t)); i++ )
- {
- if( ((uint32_t *)mmap_area)[i] == NVRAM_MAGIC )
- {
- offset = i * sizeof(uint32_t);
- break;
- }
- }
-
- if( offset < 0 )
- {
- free(mtd);
- return NULL;
- }
- else if( (h = malloc(sizeof(nvram_handle_t))) != NULL )
- {
- memset(h, 0, sizeof(nvram_handle_t));
-
- h->fd = fd;
- h->mmap = mmap_area;
- h->length = nvram_erase_size;
- h->offset = offset;
-
- header = nvram_header(h);
-
- if( header->magic == NVRAM_MAGIC )
- {
- _nvram_rehash(h);
- free(mtd);
- return h;
- }
- else
- {
- munmap(h->mmap, h->length);
- free(h);
- }
- }
- }
- }
-
- free(mtd);
- return NULL;
-}
-
-/* Close NVRAM and free memory. */
-int nvram_close(nvram_handle_t *h)
-{
- _nvram_free(h);
- munmap(h->mmap, h->length);
- close(h->fd);
- free(h);
-
- return 0;
-}
-
-/* Determine NVRAM device node. */
-char * nvram_find_mtd(void)
-{
- FILE *fp;
- int i, esz;
- char dev[PATH_MAX];
- char *path = NULL;
- struct stat s;
- int supported = 1;
-
- /* Refuse any operation on the WGT634U */
- if( (fp = fopen("/proc/diag/model", "r")) )
- {
- if( fgets(dev, sizeof(dev), fp) && !strncmp(dev, "Netgear WGT634U", 15) )
- supported = 0;
-
- fclose(fp);
- }
-
- if( supported && (fp = fopen("/proc/mtd", "r")) )
- {
- while( fgets(dev, sizeof(dev), fp) )
- {
- if( strstr(dev, "nvram") && sscanf(dev, "mtd%d: %08x", &i, &esz) )
- {
- nvram_erase_size = esz;
-
- sprintf(dev, "/dev/mtdblock/%d", i);
- if( stat(dev, &s) > -1 && (s.st_mode & S_IFBLK) )
- {
- if( (path = (char *) malloc(strlen(dev)+1)) != NULL )
- {
- strncpy(path, dev, strlen(dev)+1);
- break;
- }
- }
- else
- {
- sprintf(dev, "/dev/mtdblock%d", i);
- if( stat(dev, &s) > -1 && (s.st_mode & S_IFBLK) )
- {
- if( (path = (char *) malloc(strlen(dev)+1)) != NULL )
- {
- strncpy(path, dev, strlen(dev)+1);
- break;
- }
- }
- }
- }
- }
- fclose(fp);
- }
-
- return path;
-}
-
-/* Check NVRAM staging file. */
-char * nvram_find_staging(void)
-{
- struct stat s;
-
- if( (stat(NVRAM_STAGING, &s) > -1) && (s.st_mode & S_IFREG) )
- {
- return NVRAM_STAGING;
- }
-
- return NULL;
-}
-
-/* Copy NVRAM contents to staging file. */
-int nvram_to_staging(void)
-{
- int fdmtd, fdstg, stat;
- char *mtd = nvram_find_mtd();
- char buf[nvram_erase_size];
-
- stat = -1;
-
- if( (mtd != NULL) && (nvram_erase_size > 0) )
- {
- if( (fdmtd = open(mtd, O_RDONLY)) > -1 )
- {
- if( read(fdmtd, buf, sizeof(buf)) == sizeof(buf) )
- {
- if((fdstg = open(NVRAM_STAGING, O_WRONLY | O_CREAT, 0600)) > -1)
- {
- write(fdstg, buf, sizeof(buf));
- fsync(fdstg);
- close(fdstg);
-
- stat = 0;
- }
- }
-
- close(fdmtd);
- }
- }
-
- free(mtd);
- return stat;
-}
-
-/* Copy staging file to NVRAM device. */
-int staging_to_nvram(void)
-{
- int fdmtd, fdstg, stat;
- char *mtd = nvram_find_mtd();
- char buf[nvram_erase_size];
-
- stat = -1;
-
- if( (mtd != NULL) && (nvram_erase_size > 0) )
- {
- if( (fdstg = open(NVRAM_STAGING, O_RDONLY)) > -1 )
- {
- if( read(fdstg, buf, sizeof(buf)) == sizeof(buf) )
- {
- if( (fdmtd = open(mtd, O_WRONLY | O_SYNC)) > -1 )
- {
- write(fdmtd, buf, sizeof(buf));
- fsync(fdmtd);
- close(fdmtd);
- stat = 0;
- }
- }
-
- close(fdstg);
-
- if( !stat )
- stat = unlink(NVRAM_STAGING) ? 1 : 0;
- }
- }
-
- free(mtd);
- return stat;
-}
diff --git a/package/system/utils/nvram/src/nvram.h b/package/system/utils/nvram/src/nvram.h
deleted file mode 100644
index c72f67e9a8..0000000000
--- a/package/system/utils/nvram/src/nvram.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * NVRAM variable manipulation
- *
- * Copyright 2007, Broadcom Corporation
- * Copyright 2009, OpenWrt.org
- * All Rights Reserved.
- *
- * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
- * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
- * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
- *
- */
-
-#ifndef _nvram_h_
-#define _nvram_h_
-
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <linux/limits.h>
-
-#include "sdinitvals.h"
-
-
-struct nvram_header {
- uint32_t magic;
- uint32_t len;
- uint32_t crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
- uint32_t config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
- uint32_t config_ncdl; /* ncdl values for memc */
-} __attribute__((__packed__));
-
-struct nvram_tuple {
- char *name;
- char *value;
- struct nvram_tuple *next;
-};
-
-struct nvram_handle {
- int fd;
- char *mmap;
- unsigned int length;
- unsigned int offset;
- struct nvram_tuple *nvram_hash[257];
- struct nvram_tuple *nvram_dead;
-};
-
-typedef struct nvram_handle nvram_handle_t;
-typedef struct nvram_header nvram_header_t;
-typedef struct nvram_tuple nvram_tuple_t;
-
-
-/* Get nvram header. */
-nvram_header_t * nvram_header(nvram_handle_t *h);
-
-/* Set the value of an NVRAM variable */
-int nvram_set(nvram_handle_t *h, const char *name, const char *value);
-
-/* Get the value of an NVRAM variable. */
-char * nvram_get(nvram_handle_t *h, const char *name);
-
-/* Unset the value of an NVRAM variable. */
-int nvram_unset(nvram_handle_t *h, const char *name);
-
-/* Get all NVRAM variables. */
-nvram_tuple_t * nvram_getall(nvram_handle_t *h);
-
-/* Regenerate NVRAM. */
-int nvram_commit(nvram_handle_t *h);
-
-/* Open NVRAM and obtain a handle. */
-nvram_handle_t * nvram_open(const char *file, int rdonly);
-
-/* Close NVRAM and free memory. */
-int nvram_close(nvram_handle_t *h);
-
-/* Get the value of an NVRAM variable in a safe way, use "" instead of NULL. */
-#define nvram_safe_get(h, name) (nvram_get(h, name) ? : "")
-
-/* Computes a crc8 over the input data. */
-uint8_t hndcrc8 (uint8_t * pdata, uint32_t nbytes, uint8_t crc);
-
-/* Returns the crc value of the nvram. */
-uint8_t nvram_calc_crc(nvram_header_t * nvh);
-
-/* Determine NVRAM device node. */
-char * nvram_find_mtd(void);
-
-/* Copy NVRAM contents to staging file. */
-int nvram_to_staging(void);
-
-/* Copy staging file to NVRAM device. */
-int staging_to_nvram(void);
-
-/* Check NVRAM staging file. */
-char * nvram_find_staging(void);
-
-
-/* Staging file for NVRAM */
-#define NVRAM_STAGING "/tmp/.nvram"
-#define NVRAM_RO 1
-#define NVRAM_RW 0
-
-/* Helper macros */
-#define NVRAM_ARRAYSIZE(a) sizeof(a)/sizeof(a[0])
-#define NVRAM_ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
-
-/* NVRAM constants */
-#define NVRAM_SPACE 0x8000
-#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
-#define NVRAM_VERSION 1
-
-#define NVRAM_CRC_START_POSITION 9 /* magic, len, crc8 to be skipped */
-
-
-#endif /* _nvram_h_ */
diff --git a/package/system/utils/nvram/src/sdinitvals.h b/package/system/utils/nvram/src/sdinitvals.h
deleted file mode 100644
index 5a289adece..0000000000
--- a/package/system/utils/nvram/src/sdinitvals.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * SDRAM init values
- *
- * Copyright 2007, Broadcom Corporation
- * Copyright 2009, OpenWrt.org
- * All Rights Reserved.
- *
- * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
- * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
- * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
- *
- */
-
-#ifndef _sdinitvals_h_
-#define _sdinitvals_h_
-
-/* SDRAM refresh control (refresh) register bits */
-#define SDRAM_REF(p) (((p)&0xff) | SDRAM_REF_EN) /* Refresh period */
-#define SDRAM_REF_EN 0x8000 /* Writing 1 enables periodic refresh */
-
-/* SDRAM Core default Init values (OCP ID 0x803) */
-#define MEM4MX16X2 0x419 /* 16 MB */
-
-#define SDRAM_INIT MEM4MX16X2
-#define SDRAM_BURSTFULL 0x0000 /* Use full page bursts */
-#define SDRAM_CONFIG SDRAM_BURSTFULL
-#define SDRAM_REFRESH SDRAM_REF(0x40)
-
-#endif /* _sdinitvals_h_ */
diff --git a/package/system/utils/robocfg/Makefile b/package/system/utils/robocfg/Makefile
deleted file mode 100644
index 4bc72f51db..0000000000
--- a/package/system/utils/robocfg/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Copyright (C) 2006 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:=robocfg
-PKG_VERSION:=0.01
-PKG_RELEASE:=1
-
-PKG_BUILD_DIR:=$(BUILD_DIR)/robocfg
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/robocfg
- SECTION:=utils
- CATEGORY:=Utilities
- TITLE:=BCM5325E/536x switch configuration utility
-endef
-
-define Package/robocfg/description
- This package contains an utility for configuring the Broadcom BCM5325E/536x
- based switches.
-endef
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
- $(CP) ./src/* $(PKG_BUILD_DIR)/
-endef
-
-define Package/robocfg/install
- $(INSTALL_DIR) $(1)/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/robocfg $(1)/sbin/
-endef
-
-$(eval $(call BuildPackage,robocfg))
diff --git a/package/system/utils/robocfg/src/Makefile b/package/system/utils/robocfg/src/Makefile
deleted file mode 100644
index e11acb020a..0000000000
--- a/package/system/utils/robocfg/src/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-
-all: robocfg
-
-%.o: %.c
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $^
-
-robocfg: robocfg.o
- $(CC) -o $@ $^
-
-clean:
- rm -f *.o robocfg
diff --git a/package/system/utils/robocfg/src/etc53xx.h b/package/system/utils/robocfg/src/etc53xx.h
deleted file mode 100644
index d5b1310cb6..0000000000
--- a/package/system/utils/robocfg/src/etc53xx.h
+++ /dev/null
@@ -1,619 +0,0 @@
-/*
- * Broadcom Home Gateway Reference Design
- * BCM53xx Register definitions
- *
- * Copyright 2004, Broadcom Corporation
- * All Rights Reserved.
- *
- * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
- * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
- * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
- */
-
-#ifndef __BCM535M_H_
-#define __BCM535M_H_
-
-/* ROBO embedded device type */
-#define ROBO_DEV_5380 1
-#define ROBO_DEV_5365 2
-#define ROBO_DEV_5350 3
-
-/* BCM5325m GLOBAL PAGE REGISTER MAP */
-#ifndef _CFE_
-#pragma pack(1)
-#endif
-
-/* BCM5325m Serial Management Port (SMP) Page offsets */
-#define ROBO_CTRL_PAGE 0x00 /* Control registers */
-#define ROBO_STAT_PAGE 0x01 /* Status register */
-#define ROBO_MGMT_PAGE 0x02 /* Management Mode registers */
-#define ROBO_MIB_AC_PAGE 0x03 /* MIB Autocast registers */
-#define ROBO_ARLCTRL_PAGE 0x04 /* ARL Control Registers */
-#define ROBO_ARLIO_PAGE 0x05 /* ARL Access Registers */
-#define ROBO_FRAMEBUF_PAGE 0x06 /* Management frame access registers */
-#define ROBO_MEM_ACCESS_PAGE 0x08 /* Memory access registers */
-
-/* PHY Registers */
-#define ROBO_PORT0_MII_PAGE 0x10 /* Port 0 MII Registers */
-#define ROBO_PORT1_MII_PAGE 0x11 /* Port 1 MII Registers */
-#define ROBO_PORT2_MII_PAGE 0x12 /* Port 2 MII Registers */
-#define ROBO_PORT3_MII_PAGE 0x13 /* Port 3 MII Registers */
-#define ROBO_PORT4_MII_PAGE 0x14 /* Port 4 MII Registers */
-/* (start) registers only for BCM5380 */
-#define ROBO_PORT5_MII_PAGE 0x15 /* Port 5 MII Registers */
-#define ROBO_PORT6_MII_PAGE 0x16 /* Port 6 MII Registers */
-#define ROBO_PORT7_MII_PAGE 0x17 /* Port 7 MII Registers */
-/* (end) registers only for BCM5380 */
-#define ROBO_IM_PORT_PAGE 0x18 /* Inverse MII Port (to EMAC) */
-#define ROBO_ALL_PORT_PAGE 0x19 /* All ports MII Registers (broadcast)*/
-
-/* MAC Statistics registers */
-#define ROBO_PORT0_MIB_PAGE 0x20 /* Port 0 10/100 MIB Statistics */
-#define ROBO_PORT1_MIB_PAGE 0x21 /* Port 1 10/100 MIB Statistics */
-#define ROBO_PORT2_MIB_PAGE 0x22 /* Port 2 10/100 MIB Statistics */
-#define ROBO_PORT3_MIB_PAGE 0x23 /* Port 3 10/100 MIB Statistics */
-#define ROBO_PORT4_MIB_PAGE 0x24 /* Port 4 10/100 MIB Statistics */
-/* (start) registers only for BCM5380 */
-#define ROBO_PORT5_MIB_PAGE 0x25 /* Port 5 10/100 MIB Statistics */
-#define ROBO_PORT6_MIB_PAGE 0x26 /* Port 6 10/100 MIB Statistics */
-#define ROBO_PORT7_MIB_PAGE 0x27 /* Port 7 10/100 MIB Statistics */
-/* (end) registers only for BCM5380 */
-#define ROBO_IM_PORT_MIB_PAGE 0x28 /* Inverse MII Port MIB Statistics */
-
-/* Quality of Service (QoS) Registers */
-#define ROBO_QOS_PAGE 0x30 /* QoS Registers */
-
-/* VLAN Registers */
-#define ROBO_VLAN_PAGE 0x34 /* VLAN Registers */
-
-/* Note SPI Data/IO Registers not used */
-#define ROBO_SPI_DATA_IO_0_PAGE 0xf0 /* SPI Data I/O 0 */
-#define ROBO_SPI_DATA_IO_1_PAGE 0xf1 /* SPI Data I/O 1 */
-#define ROBO_SPI_DATA_IO_2_PAGE 0xf2 /* SPI Data I/O 2 */
-#define ROBO_SPI_DATA_IO_3_PAGE 0xf3 /* SPI Data I/O 3 */
-#define ROBO_SPI_DATA_IO_4_PAGE 0xf4 /* SPI Data I/O 4 */
-#define ROBO_SPI_DATA_IO_5_PAGE 0xf5 /* SPI Data I/O 5 */
-#define ROBO_SPI_DATA_IO_6_PAGE 0xf6 /* SPI Data I/O 6 */
-#define ROBO_SPI_DATA_IO_7_PAGE 0xf7 /* SPI Data I/O 7 */
-
-#define ROBO_SPI_STATUS_PAGE 0xfe /* SPI Status Registers */
-#define ROBO_PAGE_PAGE 0xff /* Page Registers */
-
-
-/* BCM5325m CONTROL PAGE (0x00) REGISTER MAP : 8bit (byte) registers */
-typedef struct _ROBO_PORT_CTRL_STRUC
-{
- unsigned char rx_disable:1; /* rx disable */
- unsigned char tx_disable:1; /* tx disable */
- unsigned char rsvd:3; /* reserved */
- unsigned char stp_state:3; /* spanning tree state */
-} ROBO_PORT_CTRL_STRUC;
-
-#define ROBO_PORT0_CTRL 0x00 /* 10/100 Port 0 Control */
-#define ROBO_PORT1_CTRL 0x01 /* 10/100 Port 1 Control */
-#define ROBO_PORT2_CTRL 0x02 /* 10/100 Port 2 Control */
-#define ROBO_PORT3_CTRL 0x03 /* 10/100 Port 3 Control */
-#define ROBO_PORT4_CTRL 0x04 /* 10/100 Port 4 Control */
-/* (start) registers only for BCM5380 */
-#define ROBO_PORT5_CTRL 0x05 /* 10/100 Port 5 Control */
-#define ROBO_PORT6_CTRL 0x06 /* 10/100 Port 6 Control */
-#define ROBO_PORT7_CTRL 0x07 /* 10/100 Port 7 Control */
-/* (end) registers only for BCM5380 */
-#define ROBO_IM_PORT_CTRL 0x08 /* 10/100 Port 8 Control */
-#define ROBO_SMP_CTRL 0x0a /* SMP Control register */
-#define ROBO_SWITCH_MODE 0x0b /* Switch Mode Control */
-#define ROBO_PORT_OVERRIDE_CTRL 0x0e /* Port state override */
-#define ROBO_PORT_OVERRIDE_RVMII (1<<4) /* Bit 4 enables RvMII */
-#define ROBO_PD_MODE_CTRL 0x0f /* Power-down mode control */
-#define ROBO_IP_MULTICAST_CTRL 0x21 /* IP Multicast control */
-
-/* BCM5325m STATUS PAGE (0x01) REGISTER MAP : 16bit/48bit registers */
-#define ROBO_HALF_DUPLEX 0
-#define ROBO_FULL_DUPLEX 1
-
-#define ROBO_LINK_STAT_SUMMARY 0x00 /* Link Status Summary: 16bit */
-#define ROBO_LINK_STAT_CHANGE 0x02 /* Link Status Change: 16bit */
-#define ROBO_SPEED_STAT_SUMMARY 0x04 /* Port Speed Summary: 16bit*/
-#define ROBO_DUPLEX_STAT_SUMMARY 0x06 /* Duplex Status Summary: 16bit */
-#define ROBO_PAUSE_STAT_SUMMARY 0x08 /* PAUSE Status Summary: 16bit */
-#define ROBO_SOURCE_ADDR_CHANGE 0x0C /* Source Address Change: 16bit */
-#define ROBO_LSA_PORT0 0x10 /* Last Source Addr, Port 0: 48bits*/
-#define ROBO_LSA_PORT1 0x16 /* Last Source Addr, Port 1: 48bits*/
-#define ROBO_LSA_PORT2 0x1c /* Last Source Addr, Port 2: 48bits*/
-#define ROBO_LSA_PORT3 0x22 /* Last Source Addr, Port 3: 48bits*/
-#define ROBO_LSA_PORT4 0x28 /* Last Source Addr, Port 4: 48bits*/
-#define ROBO_LSA_IM_PORT 0x40 /* Last Source Addr, IM Port: 48bits*/
-
-/* BCM5325m MANAGEMENT MODE REGISTERS (0x02) REGISTER MAP: 8/48 bit regs*/
-typedef struct _ROBO_GLOBAL_CONFIG_STRUC
-{
- unsigned char resetMIB:1; /* reset MIB counters */
- unsigned char rxBPDU:1; /* receive BDPU enable */
- unsigned char rsvd1:2; /* reserved */
- unsigned char MIBacHdrCtrl:1; /* MIB autocast header control */
- unsigned char MIBac:1; /* MIB autocast enable */
- unsigned char frameMgmtPort:2; /* frame management port */
-} ROBO_GLOBAL_CONFIG_STRUC;
-#define ROBO_GLOBAL_CONFIG 0x00 /* Global Management Config: 8bit*/
-#define ROBO_MGMT_PORT_ID 0x02 /* Management Port ID: 8bit*/
-#define ROBO_RMON_MIB_STEER 0x04 /* RMON Mib Steering: 16bit */
-#define ROBO_MIB_MODE_SELECT 0x04 /* MIB Mode select: 16bit (BCM5350) */
-#define ROBO_AGE_TIMER_CTRL 0x06 /* Age time control: 32bit */
-#define ROBO_MIRROR_CAP_CTRL 0x10 /* Mirror Capture : 16bit */
-#define ROBO_MIRROR_ING_CTRL 0x12 /* Mirror Ingress Control: 16bit */
-#define ROBO_MIRROR_ING_DIV_CTRL 0x14 /* Mirror Ingress Divider: 16bit */
-#define ROBO_MIRROR_ING_MAC_ADDR 0x16 /* Ingress Mirror MAC Addr: 48bit*/
-#define ROBO_MIRROR_EGR_CTRL 0x1c /* Mirror Egress Control: 16bit */
-#define ROBO_MIRROR_EGR_DIV_CTRL 0x1e /* Mirror Egress Divider: 16bit */
-#define ROBO_MIRROR_EGR_MAC_ADDR 0x20 /* Egress Mirror MAC Addr: 48bit*/
-
-/* BCM5325m MIB AUTOCAST REGISTERS (0x03) REGISTER MAP: 8/16/48 bit regs */
-#define ROBO_MIB_AC_PORT 0x00 /* MIB Autocast Port: 16bit */
-#define ROBO_MIB_AC_HDR_PTR 0x02 /* MIB Autocast Header pointer:16bit*/
-#define ROBO_MIB_AC_HDR_LEN 0x04 /* MIB Autocast Header Len: 16bit */
-#define ROBO_MIB_AC_DA 0x06 /* MIB Autocast DA: 48bit */
-#define ROBO_MIB_AC_SA 0x0c /* MIB Autocast SA: 48bit */
-#define ROBO_MIB_AC_TYPE 0x12 /* MIB Autocast Type: 16bit */
-#define ROBO_MIB_AC_RATE 0x14 /* MIB Autocast Rate: 8bit */
-#define ROBO_GET_AC_RATE(secs) ((secs)*10)
-#define ROBO_AC_RATE_MAX 0xff
-#define ROBO_AC_RATE_DEFAULT 0x64 /* 10 secs */
-typedef struct _ROBO_MIB_AC_STRUCT
-{
- unsigned char opcode:4; /* Tx MIB Autocast opcode */
- unsigned char portno:4; /* zero-based port no. */
- unsigned char portstate:8; /* port state */
- unsigned long long TxOctets;
- unsigned int TxDropPkts;
- unsigned int rsvd;
- unsigned int TxBroadcastPkts;
- unsigned int TxMulticastPkts;
- unsigned int TxUnicastPkts;
- unsigned int TxCollisions;
- unsigned int TxSingleCollision;
- unsigned int TxMultiCollision;
- unsigned int TxDeferredTransmit;
- unsigned int TxLateCollision;
- unsigned int TxExcessiveCollision;
- unsigned int TxFrameInDiscards;
- unsigned int TxPausePkts;
- unsigned int rsvd1[2];
- unsigned long long RxOctets;
- unsigned int RxUndersizePkts;
- unsigned int RxPausePkts;
- unsigned int RxPkts64Octets;
- unsigned int RxPkts64to127Octets;
- unsigned int RxPkts128to255Octets;
- unsigned int RxPkts256to511Octets;
- unsigned int RxPkts512to1023Octets;
- unsigned int RxPkts1024to1522Octets;
- unsigned int RxOversizePkts;
- unsigned int RxJabbers;
- unsigned int RxAlignmentErrors;
- unsigned int RxFCSErrors;
- unsigned long long RxGoodOctets;
- unsigned int RxDropPkts;
- unsigned int RxUnicastPkts;
- unsigned int RxMulticastPkts;
- unsigned int RxBroadcastPkts;
- unsigned int RxSAChanges;
- unsigned int RxFragments;
- unsigned int RxExcessSizeDisc;
- unsigned int RxSymbolError;
-} ROBO_MIB_AC_STRUCT;
-
-/* BCM5325m ARL CONTROL REGISTERS (0x04) REGISTER MAP: 8/16/48/64 bit regs */
-#define ROBO_ARL_CONFIG 0x00 /* ARL Global Configuration: 8bit*/
-#define ROBO_BPDU_MC_ADDR_REG 0x04 /* BPDU Multicast Address Reg:64bit*/
-#define ROBO_MULTIPORT_ADDR_1 0x10 /* Multiport Address 1: 48 bits*/
-#define ROBO_MULTIPORT_VECTOR_1 0x16 /* Multiport Vector 1: 16 bits */
-#define ROBO_MULTIPORT_ADDR_2 0x20 /* Multiport Address 2: 48 bits*/
-#define ROBO_MULTIPORT_VECTOR_2 0x26 /* Multiport Vector 2: 16 bits */
-#define ROBO_SECURE_SRC_PORT_MASK 0x30 /* Secure Source Port Mask: 16 bits*/
-#define ROBO_SECURE_DST_PORT_MASK 0x32 /* Secure Dest Port Mask: 16 bits */
-
-
-/* BCM5325m ARL IO REGISTERS (0x05) REGISTER MAP: 8/16/48/64 bit regs */
-#define ARL_TABLE_WRITE 0 /* for read/write state in control reg */
-#define ARL_TABLE_READ 1 /* for read/write state in control reg */
-#ifdef BCM5380
-#define ARL_VID_BYTES 2 /* number of bytes for VID */
-#else
-#define ARL_VID_BYTES 1 /* number of bytes for VID */
-#endif
-typedef struct _ROBO_ARL_RW_CTRL_STRUC
-{
- unsigned char ARLrw:1; /* ARL read/write (1=read) */
- unsigned char rsvd:6; /* reserved */
- unsigned char ARLStart:1; /* ARL start/done (1=start) */
-} ROBO_ARL_RW_CTRL_STRUC;
-typedef struct _ROBO_ARL_SEARCH_CTRL_STRUC
-{
- unsigned char valid:1; /* ARL search result valid */
- unsigned char rsvd:6; /* reserved */
- unsigned char ARLStart:1; /* ARL start/done (1=start) */
-} ROBO_ARL_SEARCH_CTRL_STRUC;
-typedef struct _ROBO_ARL_ENTRY_CTRL_STRUC
-{
- unsigned char portID:4; /* port id */
- unsigned char chipID:2; /* chip id */
- unsigned char rsvd:5; /* reserved */
- unsigned char prio:2; /* priority */
- unsigned char age:1; /* age */
- unsigned char staticEn:1; /* static */
- unsigned char valid:1; /* valid */
-} ROBO_ARL_ENTRY_CTRL_STRUC;
-typedef struct _ROBO_ARL_SEARCH_RESULT_CTRL_STRUC
-{
- unsigned char portID:4; /* port id */
- unsigned char rsvd:1; /* reserved */
- unsigned char vid:8; /* vlan id */
- unsigned char age:1; /* age */
- unsigned char staticEn:1; /* static */
- unsigned char valid:1; /* valid */
-} ROBO_ARL_SEARCH_RESULT_CTRL_STRUC;
-typedef struct _ROBO_ARL_ENTRY_MAC_STRUC
-{
- unsigned char macBytes[6]; /* MAC address */
-} ROBO_ARL_ENTRY_MAC_STRUC;
-
-typedef struct _ROBO_ARL_ENTRY_STRUC
-{
- ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
- ROBO_ARL_ENTRY_CTRL_STRUC ctrl; /* control bits */
-} ROBO_ARL_ENTRY_STRUC;
-
-typedef struct _ROBO_ARL_SEARCH_RESULT_STRUC
-{
- ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
- ROBO_ARL_SEARCH_RESULT_CTRL_STRUC ctrl; /* control bits */
-} ROBO_ARL_SEARCH_RESULT_STRUC;
-
-/* multicast versions of ARL entry structs */
-typedef struct _ROBO_ARL_ENTRY_MCAST_CTRL_STRUC
-{
- unsigned int portMask:12;/* multicast port mask */
- unsigned char prio:1; /* priority */
- unsigned char gigPort:1; /* gigabit port 1 mask */
- unsigned char staticEn:1; /* static */
- unsigned char valid:1; /* valid */
-} ROBO_ARL_ENTRY_MCAST_CTRL_STRUC;
-typedef struct _ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC
-{
- unsigned int portMask:13; /* multicast port mask */
- unsigned char age:1; /* age */
- unsigned char staticEn:1; /* static */
- unsigned char valid:1; /* valid */
-} ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC;
-/* BCM5350 extension register */
-typedef struct _ROBO_ARL_SEARCH_RESULT_EXTENSION
-{
- unsigned int prio:2; /* priority */
- unsigned int portMask:1; /* MSB (MII) of port mask for multicast */
- unsigned int reserved:5;
-} ROBO_ARL_SEARCH_RESULT_EXTENSION;
-
-typedef struct _ROBO_ARL_ENTRY_MCAST_STRUC
-{
- ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
- ROBO_ARL_ENTRY_MCAST_CTRL_STRUC ctrl; /* control bits */
-} ROBO_ARL_ENTRY_MCAST_STRUC;
-typedef struct _ROBO_ARL_SEARCH_RESULT_MCAST_STRUC
-{
- ROBO_ARL_ENTRY_MAC_STRUC mac; /* MAC address */
- ROBO_ARL_SEARCH_RESULT_MCAST_CTRL_STRUC ctrl; /* control bits */
-} ROBO_ARL_SEARCH_RESULT_MCAST_STRUC;
-
-#define ROBO_ARL_RW_CTRL 0x00 /* ARL Read/Write Control : 8bit */
-#define ROBO_ARL_MAC_ADDR_IDX 0x02 /* MAC Address Index: 48bit */
-#define ROBO_ARL_VID_TABLE_IDX 0x08 /* VID Table Address Index: 8bit */
-#define ROBO_ARL_ENTRY0 0x10 /* ARL Entry 0 : 64 bit */
-#define ROBO_ARL_ENTRY1 0x18 /* ARL Entry 1 : 64 bit */
-#define ROBO_ARL_SEARCH_CTRL 0x20 /* ARL Search Control: 8bit */
-#define ROBO_ARL_SEARCH_ADDR 0x22 /* ARL Search Address: 16bit */
-#define ROBO_ARL_SEARCH_RESULT 0x24 /* ARL Search Result: 64bit */
-#define ROBO_ARL_SEARCH_RESULT_EXT 0x2c /* ARL Search Result Extension (5350): 8bit */
-#define ROBO_ARL_VID_ENTRY0 0x30 /* ARL VID Entry 0: 64bit */
-#define ROBO_ARL_VID_ENTRY1 0x32 /* ARL VID Entry 1: 64bit */
-
-/* BCM5325m MANAGEMENT FRAME REGISTERS (0x6) REGISTER MAP: 8/16 bit regs */
-#define ROBO_MGMT_FRAME_RD_DATA 0x00 /* Management Frame Read Data :8bit*/
-#define ROBO_MGMT_FRAME_WR_DATA 0x01 /* Management Frame Write Data:8bit*/
-#define ROBO_MGMT_FRAME_WR_CTRL 0x02 /* Write Control: 16bit */
-#define ROBO_MGMT_FRAME_RD_STAT 0x04 /* Read Status: 16bit */
-
-/* BCM5325m MEMORY ACCESS REGISTERS (Page 0x08) REGISTER MAP: 32 bit regs */
-#define MEM_TABLE_READ 1 /* for read/write state in mem access reg */
-#define MEM_TABLE_WRITE 0 /* for read/write state in mem access reg */
-#define MEM_TABLE_ACCESS_START 1 /* for mem access read/write start */
-#define MEM_TABLE_ACCESS_DONE 0 /* for mem access read/write done */
-#define VLAN_TABLE_ADDR 0x3800 /* BCM5380 only */
-#ifdef BCM5380
-#define NUM_ARL_TABLE_ENTRIES 4096 /* number of entries in ARL table */
-#define NUM_VLAN_TABLE_ENTRIES 2048 /* number of entries in VLAN table */
-#define ARL_TABLE_ADDR 0 /* offset of ARL table start */
-#else
-#define NUM_ARL_TABLE_ENTRIES 2048 /* number of entries in ARL table */
-#define NUM_VLAN_TABLE_ENTRIES 256 /* number of entries in VLAN table */
-#define ARL_TABLE_ADDR 0x3800 /* offset of ARL table start */
-/* corresponding values for 5350 */
-#define NUM_ARL_TABLE_ENTRIES_5350 1024 /* number of entries in ARL table (5350) */
-#define NUM_VLAN_TABLE_ENTRIES_5350 16 /* number of entries in VLAN table */
-#define ARL_TABLE_ADDR_5350 0x1c00 /* offset of ARL table start (5350) */
-#endif
-typedef struct _ROBO_MEM_ACCESS_CTRL_STRUC
-{
- unsigned int memAddr:14; /* 64-bit memory address */
- unsigned char rsvd:4; /* reserved */
- unsigned char readEn:1; /* read enable (0 == write) */
- unsigned char startDone:1;/* memory access start/done */
- unsigned int rsvd1:12; /* reserved */
-} ROBO_MEM_ACCESS_CTRL_STRUC;
-typedef struct _ROBO_MEM_ACCESS_DATA_STRUC
-{
- unsigned int memData[2]; /* 64-bit data */
- unsigned short rsvd; /* reserved */
-} ROBO_MEM_ACCESS_DATA_STRUC;
-
-#ifdef BCM5380
-typedef struct _ROBO_ARL_TABLE_DATA_STRUC
-{
- unsigned char MACaddr[6]; /* MAC addr */
- unsigned int portID:4; /* port ID */
- unsigned int chipID:2; /* chip ID */
- unsigned int rsvd:6; /* reserved */
- unsigned int highPrio:1; /* high priority address */
- unsigned int age:1; /* entry accessed/learned since ageing process */
- unsigned int staticAddr:1;/* entry is static */
- unsigned int valid:1; /* entry is valid */
- unsigned int vid:12; /* vlan id */
- unsigned int rsvd2:4; /* reserved */
-} ROBO_ARL_TABLE_DATA_STRUC;
-#else
-typedef struct _ROBO_ARL_TABLE_DATA_STRUC
-{
- unsigned char MACaddr[6]; /* MAC addr */
- unsigned int portID:4; /* port ID */
- unsigned int chipID:2; /* chip ID */
- unsigned int rsvd:7; /* reserved */
- unsigned int age:1; /* entry accessed/learned since ageing process */
- unsigned int staticAddr:1;/* entry is static */
- unsigned int valid:1; /* entry is valid */
-} ROBO_ARL_TABLE_DATA_STRUC;
-#endif
-
-/* multicast format*/
-typedef struct _ROBO_ARL_TABLE_MCAST_DATA_STRUC
-{
- unsigned char MACaddr[6]; /* MAC addr */
- unsigned int portMask:12;/* multicast port mask */
- unsigned char prio:1; /* priority */
- unsigned char gigPort:1; /* gigabit port 1 mask */
- unsigned char staticEn:1; /* static */
- unsigned char valid:1; /* valid */
- unsigned int vid:12; /* vlan id */
- unsigned int rsvd2:4; /* reserved */
-} ROBO_ARL_TABLE_MCAST_DATA_STRUC;
-#define ROBO_MEM_ACCESS_CTRL 0x00 /* Memory Read/Write Control :32bit*/
-#define ROBO_MEM_ACCESS_DATA 0x04 /* Memory Read/Write Data:64bit*/
-
-/* BCM5325m SWITCH PORT (0x10-18) REGISTER MAP: 8/16 bit regs */
-typedef struct _ROBO_MII_CTRL_STRUC
-{
- unsigned char rsvd:8; /* reserved */
- unsigned char duplex:1; /* duplex mode */
- unsigned char restartAN:1;/* restart auto-negotiation */
- unsigned char rsvd1:1; /* reserved */
- unsigned char powerDown:1;/* power down */
- unsigned char ANenable:1; /* auto-negotiation enable */
- unsigned char speed:1; /* forced speed selection */
- unsigned char loopback:1; /* loopback */
- unsigned char reset:1; /* reset */
-} ROBO_MII_CTRL_STRUC;
-typedef struct _ROBO_MII_AN_ADVERT_STRUC
-{
- unsigned char selector:5; /* advertise selector field */
- unsigned char T10BaseT:1; /* advertise 10BaseT */
- unsigned char T10BaseTFull:1; /* advertise 10BaseT, full duplex */
- unsigned char T100BaseX:1; /* advertise 100BaseX */
- unsigned char T100BaseXFull:1;/* advertise 100BaseX full duplex */
- unsigned char noT4:1; /* do not advertise T4 */
- unsigned char pause:1; /* advertise pause for full duplex */
- unsigned char rsvd:2; /* reserved */
- unsigned char remoteFault:1; /* transmit remote fault */
- unsigned char rsvd1:1; /* reserved */
- unsigned char nextPage:1; /* nex page operation supported */
-} ROBO_MII_AN_ADVERT_STRUC;
-#define ROBO_MII_CTRL 0x00 /* Port MII Control */
-#define ROBO_MII_STAT 0x02 /* Port MII Status */
-/* Fields of link status register */
-#define ROBO_MII_STAT_JABBER (1<<1) /* Jabber detected */
-#define ROBO_MII_STAT_LINK (1<<2) /* Link status */
-
-#define ROBO_MII_PHYID_HI 0x04 /* Port PHY ID High */
-#define ROBO_MII_PHYID_LO 0x06 /* Port PHY ID Low */
-#define ROBO_MII_ANA_REG 0x08 /* MII Auto-Neg Advertisement */
-#define ROBO_MII_ANP_REG 0x0a /* MII Auto-Neg Partner Ability */
-#define ROBO_MII_AN_EXP_REG 0x0c /* MII Auto-Neg Expansion */
-#define ROBO_MII_AN_NP_REG 0x0e /* MII next page */
-#define ROBO_MII_ANP_NP_REG 0x10 /* MII Partner next page */
-#define ROBO_MII_100BX_AUX_CTRL 0x20 /* 100BASE-X Auxiliary Control */
-#define ROBO_MII_100BX_AUX_STAT 0x22 /* 100BASE-X Auxiliary Status */
-#define ROBO_MII_100BX_RCV_ERR_CTR 0x24 /* 100BASE-X Receive Error Ctr */
-#define ROBO_MII_100BX_RCV_FS_ERR 0x26 /* 100BASE-X Rcv False Sense Ctr */
-#define ROBO_MII_AUX_CTRL 0x30 /* Auxiliary Control/Status */
-/* Fields of Auxiliary control register */
-#define ROBO_MII_AUX_CTRL_FD (1<<0) /* Full duplex link detected*/
-#define ROBO_MII_AUX_CTRL_SP100 (1<<1) /* Speed 100 indication */
-#define ROBO_MII_AUX_STATUS 0x32 /* Aux Status Summary */
-#define ROBO_MII_CONN_STATUS 0x34 /* Aux Connection Status */
-#define ROBO_MII_AUX_MODE2 0x36 /* Aux Mode 2 */
-#define ROBO_MII_AUX_ERR_STATUS 0x38 /* Aux Error and General Status */
-#define ROBO_MII_AUX_MULTI_PHY 0x3c /* Aux Multiple PHY Register*/
-#define ROBO_MII_BROADCOM_TEST 0x3e /* Broadcom Test Register */
-
-
-/* BCM5325m PORT MIB REGISTERS (Pages 0x20-0x24,0x28) REGISTER MAP: 64/32 */
-/* Tranmit Statistics */
-#define ROBO_MIB_TX_OCTETS 0x00 /* 64b: TxOctets */
-#define ROBO_MIB_TX_DROP_PKTS 0x08 /* 32b: TxDropPkts */
-#define ROBO_MIB_TX_BC_PKTS 0x10 /* 32b: TxBroadcastPkts */
-#define ROBO_MIB_TX_MC_PKTS 0x14 /* 32b: TxMulticastPkts */
-#define ROBO_MIB_TX_UC_PKTS 0x18 /* 32b: TxUnicastPkts */
-#define ROBO_MIB_TX_COLLISIONS 0x1c /* 32b: TxCollisions */
-#define ROBO_MIB_TX_SINGLE_COLLISIONS 0x20 /* 32b: TxSingleCollision */
-#define ROBO_MIB_TX_MULTI_COLLISIONS 0x24 /* 32b: TxMultiCollision */
-#define ROBO_MIB_TX_DEFER_TX 0x28 /* 32b: TxDeferred Transmit */
-#define ROBO_MIB_TX_LATE_COLLISIONS 0x2c /* 32b: TxLateCollision */
-#define ROBO_MIB_EXCESS_COLLISIONS 0x30 /* 32b: TxExcessiveCollision*/
-#define ROBO_MIB_FRAME_IN_DISCARDS 0x34 /* 32b: TxFrameInDiscards */
-#define ROBO_MIB_TX_PAUSE_PKTS 0x38 /* 32b: TxPausePkts */
-
-/* Receive Statistics */
-#define ROBO_MIB_RX_OCTETS 0x44 /* 64b: RxOctets */
-#define ROBO_MIB_RX_UNDER_SIZE_PKTS 0x4c /* 32b: RxUndersizePkts(runts)*/
-#define ROBO_MIB_RX_PAUSE_PKTS 0x50 /* 32b: RxPausePkts */
-#define ROBO_MIB_RX_PKTS_64 0x54 /* 32b: RxPkts64Octets */
-#define ROBO_MIB_RX_PKTS_65_TO_127 0x58 /* 32b: RxPkts64to127Octets*/
-#define ROBO_MIB_RX_PKTS_128_TO_255 0x5c /* 32b: RxPkts128to255Octets*/
-#define ROBO_MIB_RX_PKTS_256_TO_511 0x60 /* 32b: RxPkts256to511Octets*/
-#define ROBO_MIB_RX_PKTS_512_TO_1023 0x64 /* 32b: RxPkts512to1023Octets*/
-#define ROBO_MIB_RX_PKTS_1024_TO_1522 0x68 /* 32b: RxPkts1024to1522Octets*/
-#define ROBO_MIB_RX_OVER_SIZE_PKTS 0x6c /* 32b: RxOversizePkts*/
-#define ROBO_MIB_RX_JABBERS 0x70 /* 32b: RxJabbers*/
-#define ROBO_MIB_RX_ALIGNMENT_ERRORS 0x74 /* 32b: RxAlignmentErrors*/
-#define ROBO_MIB_RX_FCS_ERRORS 0x78 /* 32b: RxFCSErrors */
-#define ROBO_MIB_RX_GOOD_OCTETS 0x7c /* 32b: RxGoodOctets */
-#define ROBO_MIB_RX_DROP_PKTS 0x84 /* 32b: RxDropPkts */
-#define ROBO_MIB_RX_UC_PKTS 0x88 /* 32b: RxUnicastPkts */
-#define ROBO_MIB_RX_MC_PKTS 0x8c /* 32b: RxMulticastPkts */
-#define ROBO_MIB_RX_BC_PKTS 0x90 /* 32b: RxBroadcastPkts */
-#define ROBO_MIB_RX_SA_CHANGES 0x94 /* 32b: RxSAChanges */
-#define ROBO_MIB_RX_FRAGMENTS 0x98 /* 32b: RxFragments */
-#define ROBO_MIB_RX_EXCESS_SZ_DISC 0x9c /* 32b: RxExcessSizeDisc*/
-#define ROBO_MIB_RX_SYMBOL_ERROR 0xa0 /* 32b: RxSymbolError */
-
-/* BCM5350 MIB Statistics */
-/* Group 0 */
-#define ROBO_MIB_TX_GOOD_PKTS 0x00 /* 16b: TxGoodPkts */
-#define ROBO_MIB_TX_UNICAST_PKTS 0x02 /* 16b: TxUnicastPkts */
-#define ROBO_MIB_RX_GOOD_PKTS 0x04 /* 16b: RxGoodPkts */
-#define ROBO_MIB_RX_GOOD_UNICAST_PKTS 0x06 /* 16b: RxGoodUnicastPkts */
-/* Group 1 */
-#define ROBO_MIB_TX_COLLISION 0x00 /* 16b: TxCollision */
-#define ROBO_MIB_TX_OCTETS_5350 0x02 /* 16b: TxOctets */
-#define ROBO_MIB_RX_FCS_ERRORS_5350 0x04 /* 16b: RxFCSErrors */
-#define ROBO_MIB_RX_GOOD_OCTETS_5350 0x06 /* 16b: RxGoodOctets */
-
-/* BCM5325m QoS REGISTERS (Page 0x30) REGISTER MAP: 8/16 */
-#define ROBO_QOS_CTRL 0x00 /* 16b: QoS Control Register */
-#define ROBO_QOS_LOCAL_WEIGHT_CTRL 0x10 /* 8b: Local HQ/LQ Weight Register*/
-#define ROBO_QOS_CPU_WEIGHT_CTRL 0x12 /* 8b: CPU HQ/LQ Weight Register*/
-#define ROBO_QOS_PAUSE_ENA 0x13 /* 16b: Qos Pause Enable Register*/
-#define ROBO_QOS_PRIO_THRESHOLD 0x15 /* 8b: Priority Threshold Register*/
-#define ROBO_QOS_RESERVED 0x16 /* 8b: Qos Reserved Register */
-
-/* BCM5325m VLAN REGISTERS (Page 0x34) REGISTER MAP: 8/16bit */
-typedef struct _ROBO_VLAN_CTRL0_STRUC
-{
- unsigned char frameControlP:2; /* 802.1P frame control */
- unsigned char frameControlQ:2; /* 802.1Q frame control */
- unsigned char dropMissedVID:1; /* enable drop missed VID packet */
- unsigned char vidMacHash:1; /* VID_MAC hash enable */
- unsigned char vidMacCheck:1; /* VID_MAC check enable */
- unsigned char VLANen:1; /* 802.1Q VLAN enable */
-} ROBO_VLAN_CTRL0_STRUC;
-#define VLAN_TABLE_WRITE 1 /* for read/write state in table access reg */
-#define VLAN_TABLE_READ 0 /* for read/write state in table access reg */
-#define VLAN_ID_HIGH_BITS 0 /* static high bits in table access reg */
-#define VLAN_ID_MAX 255 /* max VLAN id */
-#define VLAN_ID_MAX5350 15 /* max VLAN id (5350) */
-#define VLAN_ID_MASK VLAN_ID_MAX /* VLAN id mask */
-#ifdef BCM5380
-#define VLAN_UNTAG_SHIFT 13 /* for postioning untag bits in write reg */
-#define VLAN_VALID 0x4000000 /* valid bit in write reg */
-#else
-#define VLAN_UNTAG_SHIFT 7 /* for postioning untag bits in write reg */
-#define VLAN_VALID 0x4000 /* valid bit in write reg */
-/* corresponding values for 5350 */
-#define VLAN_UNTAG_SHIFT_5350 6 /* for postioning untag bits in write reg */
-#define VLAN_VALID_5350 0x00100000 /* valid bit in write reg */
-#endif
-typedef struct _ROBO_VLAN_TABLE_ACCESS_STRUC
-{
- unsigned char VLANid:8; /* VLAN ID (low 8 bits) */
- unsigned char VLANidHi:4; /* VLAN ID (fixed upper portion) */
- unsigned char readWriteState:1; /* read/write state (write = 1) */
- volatile unsigned char readWriteEnable:1; /* table read/write enable */
- unsigned char rsvd:2; /* reserved */
-} ROBO_VLAN_TABLE_ACCESS_STRUC;
-#ifdef BCM5380
-typedef struct _ROBO_VLAN_READ_WRITE_STRUC
-{
- unsigned int VLANgroup:13;/* VLAN group mask */
- unsigned int VLANuntag:13;/* VLAN untag enable mask */
- unsigned char valid:1; /* valid */
- unsigned char rsvd:5; /* reserved */
-} ROBO_VLAN_READ_WRITE_STRUC;
-#else
-typedef struct _ROBO_VLAN_READ_WRITE_STRUC
-{
- unsigned char VLANgroup:7; /* VLAN group mask */
- unsigned char VLANuntag:7; /* VLAN untag enable mask */
- unsigned char valid:1; /* valid */
- unsigned char rsvd:1; /* reserved */
-} ROBO_VLAN_READ_WRITE_STRUC;
-typedef struct _ROBO_VLAN_READ_WRITE_STRUC_5350
-{
- unsigned char VLANgroup:6; /* VLAN group mask */
- unsigned char VLANuntag:6; /* VLAN untag enable mask */
- unsigned char highVID:8; /* upper bits of vid */
- unsigned char valid:1; /* valid */
- unsigned int rsvd:11; /* reserved */
-} ROBO_VLAN_READ_WRITE_STRUC_5350;
-#endif
-#define ROBO_VLAN_CTRL0 0x00 /* 8b: VLAN Control 0 Register */
-#define ROBO_VLAN_CTRL1 0x01 /* 8b: VLAN Control 1 Register */
-#define ROBO_VLAN_CTRL2 0x02 /* 8b: VLAN Control 2 Register */
-#define ROBO_VLAN_CTRL3 0x03 /* 8b: VLAN Control 3 Register */
-#define ROBO_VLAN_CTRL4 0x04 /* 8b: VLAN Control 4 Register */
-#define ROBO_VLAN_CTRL5 0x05 /* 8b: VLAN Control 5 Register */
-#define ROBO_VLAN_TABLE_ACCESS 0x08 /* 14b: VLAN Table Access Register */
-#define ROBO_VLAN_TABLE_ACCESS_5350 0x06 /* 14b: VLAN Table Access Register (5350) */
-#define ROBO_VLAN_WRITE 0x0a /* 15b: VLAN Write Register */
-#define ROBO_VLAN_WRITE_5350 0x08 /* 15b: VLAN Write Register (5350) */
-#define ROBO_VLAN_READ 0x0c /* 15b: VLAN Read Register */
-#define ROBO_VLAN_PORT0_DEF_TAG 0x10 /* 16b: VLAN Port 0 Default Tag Register */
-#define ROBO_VLAN_PORT1_DEF_TAG 0x12 /* 16b: VLAN Port 1 Default Tag Register */
-#define ROBO_VLAN_PORT2_DEF_TAG 0x14 /* 16b: VLAN Port 2 Default Tag Register */
-#define ROBO_VLAN_PORT3_DEF_TAG 0x16 /* 16b: VLAN Port 3 Default Tag Register */
-#define ROBO_VLAN_PORT4_DEF_TAG 0x18 /* 16b: VLAN Port 4 Default Tag Register */
-#define ROBO_VLAN_PORTMII_DEF_TAG 0x1a /* 16b: VLAN Port MII Default Tag Register */
-/* 5380 only */
-#define ROBO_VLAN_PORT5_DEF_TAG 0x1a /* 16b: VLAN Port 5 Default Tag Register */
-#define ROBO_VLAN_PORT6_DEF_TAG 0x1c /* 16b: VLAN Port 6 Default Tag Register */
-#define ROBO_VLAN_PORT7_DEF_TAG 0x1e /* 16b: VLAN Port 7 Default Tag Register */
-
-/* obsolete */
-#define ROBO_VLAN_PORT0_CTRL 0x00 /* 16b: Port 0 VLAN Register */
-#define ROBO_VLAN_PORT1_CTRL 0x02 /* 16b: Port 1 VLAN Register */
-#define ROBO_VLAN_PORT2_CTRL 0x04 /* 16b: Port 2 VLAN Register */
-#define ROBO_VLAN_PORT3_CTRL 0x06 /* 16b: Port 3 VLAN Register */
-#define ROBO_VLAN_PORT4_CTRL 0x08 /* 16b: Port 4 VLAN Register */
-#define ROBO_VLAN_IM_PORT_CTRL 0x10 /* 16b: Inverse MII Port VLAN Reg */
-#define ROBO_VLAN_SMP_PORT_CTRL 0x12 /* 16b: Serial Port VLAN Register */
-#define ROBO_VLAN_PORTSPI_DEF_TAG 0x1c /* 16b: VLAN Port SPI Default Tag Register */
-#define ROBO_VLAN_PRIORITY_REMAP 0x20 /* 24b: VLAN Priority Re-Map Register */
-
-#ifndef _CFE_
-#pragma pack()
-#endif
-
-
-#endif /* !__BCM535M_H_ */
-
-
-
-
-
diff --git a/package/system/utils/robocfg/src/robocfg.c b/package/system/utils/robocfg/src/robocfg.c
deleted file mode 100644
index 7a4094dd41..0000000000
--- a/package/system/utils/robocfg/src/robocfg.c
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
- * Broadcom BCM5325E/536x switch configuration utility
- *
- * Copyright (C) 2005 Oleg I. Vdovikin
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-
-/* linux stuff */
-typedef u_int64_t u64;
-typedef u_int32_t u32;
-typedef u_int16_t u16;
-typedef u_int8_t u8;
-
-#include <linux/if.h>
-#include <linux/sockios.h>
-#include <linux/ethtool.h>
-#include <linux/mii.h>
-
-#include "etc53xx.h"
-#define ROBO_PHY_ADDR 0x1E /* robo switch phy address */
-
-/* MII registers */
-#define REG_MII_PAGE 0x10 /* MII Page register */
-#define REG_MII_ADDR 0x11 /* MII Address register */
-#define REG_MII_DATA0 0x18 /* MII Data register 0 */
-
-#define REG_MII_PAGE_ENABLE 1
-#define REG_MII_ADDR_WRITE 1
-#define REG_MII_ADDR_READ 2
-
-/* Private et.o ioctls */
-#define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9)
-#define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10)
-
-typedef struct {
- struct ifreq ifr;
- int fd;
- int et; /* use private ioctls */
-} robo_t;
-
-static u16 mdio_read(robo_t *robo, u16 phy_id, u8 reg)
-{
- if (robo->et) {
- int args[2] = { reg };
-
- if (phy_id != ROBO_PHY_ADDR) {
- fprintf(stderr,
- "Access to real 'phy' registers unavaliable.\n"
- "Upgrade kernel driver.\n");
-
- return 0xffff;
- }
-
- robo->ifr.ifr_data = (caddr_t) args;
- if (ioctl(robo->fd, SIOCGETCPHYRD, (caddr_t)&robo->ifr) < 0) {
- perror("SIOCGETCPHYRD");
- exit(1);
- }
-
- return args[1];
- } else {
- struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&robo->ifr.ifr_data;
- mii->phy_id = phy_id;
- mii->reg_num = reg;
- if (ioctl(robo->fd, SIOCGMIIREG, &robo->ifr) < 0) {
- perror("SIOCGMIIREG");
- exit(1);
- }
- return mii->val_out;
- }
-}
-
-static void mdio_write(robo_t *robo, u16 phy_id, u8 reg, u16 val)
-{
- if (robo->et) {
- int args[2] = { reg, val };
-
- if (phy_id != ROBO_PHY_ADDR) {
- fprintf(stderr,
- "Access to real 'phy' registers unavaliable.\n"
- "Upgrade kernel driver.\n");
- return;
- }
-
- robo->ifr.ifr_data = (caddr_t) args;
- if (ioctl(robo->fd, SIOCSETCPHYWR, (caddr_t)&robo->ifr) < 0) {
- perror("SIOCGETCPHYWR");
- exit(1);
- }
- } else {
- struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&robo->ifr.ifr_data;
- mii->phy_id = phy_id;
- mii->reg_num = reg;
- mii->val_in = val;
- if (ioctl(robo->fd, SIOCSMIIREG, &robo->ifr) < 0) {
- perror("SIOCSMIIREG");
- exit(1);
- }
- }
-}
-
-static int robo_reg(robo_t *robo, u8 page, u8 reg, u8 op)
-{
- int i = 3;
-
- /* set page number */
- mdio_write(robo, ROBO_PHY_ADDR, REG_MII_PAGE,
- (page << 8) | REG_MII_PAGE_ENABLE);
-
- /* set register address */
- mdio_write(robo, ROBO_PHY_ADDR, REG_MII_ADDR,
- (reg << 8) | op);
-
- /* check if operation completed */
- while (i--) {
- if ((mdio_read(robo, ROBO_PHY_ADDR, REG_MII_ADDR) & 3) == 0)
- return 0;
- }
-
- fprintf(stderr, "robo_reg: timeout\n");
- exit(1);
-
- return 0;
-}
-
-static void robo_read(robo_t *robo, u8 page, u8 reg, u16 *val, int count)
-{
- int i;
-
- robo_reg(robo, page, reg, REG_MII_ADDR_READ);
-
- for (i = 0; i < count; i++)
- val[i] = mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0 + i);
-}
-
-static u16 robo_read16(robo_t *robo, u8 page, u8 reg)
-{
- robo_reg(robo, page, reg, REG_MII_ADDR_READ);
-
- return mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0);
-}
-
-static u32 robo_read32(robo_t *robo, u8 page, u8 reg)
-{
- robo_reg(robo, page, reg, REG_MII_ADDR_READ);
-
- return mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0) +
- (mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0 + 1) << 16);
-}
-
-static void robo_write16(robo_t *robo, u8 page, u8 reg, u16 val16)
-{
- /* write data */
- mdio_write(robo, ROBO_PHY_ADDR, REG_MII_DATA0, val16);
-
- robo_reg(robo, page, reg, REG_MII_ADDR_WRITE);
-}
-
-static void robo_write32(robo_t *robo, u8 page, u8 reg, u32 val32)
-{
- /* write data */
- mdio_write(robo, ROBO_PHY_ADDR, REG_MII_DATA0, val32 & 65535);
- mdio_write(robo, ROBO_PHY_ADDR, REG_MII_DATA0 + 1, val32 >> 16);
-
- robo_reg(robo, page, reg, REG_MII_ADDR_WRITE);
-}
-
-/* checks that attached switch is 5325E/5350 */
-static int robo_vlan5350(robo_t *robo)
-{
- /* set vlan access id to 15 and read it back */
- u16 val16 = 15;
- robo_write16(robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
-
- /* 5365 will refuse this as it does not have this reg */
- return (robo_read16(robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350) == val16);
-}
-
-u8 port[6] = { 0, 1, 2, 3, 4, 8 };
-char ports[6] = { 'W', '4', '3', '2', '1', 'C' };
-char *rxtx[4] = { "enabled", "rx_disabled", "tx_disabled", "disabled" };
-char *stp[8] = { "none", "disable", "block", "listen", "learn", "forward", "6", "7" };
-
-struct {
- char *name;
- u16 bmcr;
-} media[5] = { { "auto", BMCR_ANENABLE | BMCR_ANRESTART },
- { "10HD", 0 }, { "10FD", BMCR_FULLDPLX },
- { "100HD", BMCR_SPEED100 }, { "100FD", BMCR_SPEED100 | BMCR_FULLDPLX } };
-
-struct {
- char *name;
- u16 value;
-} mdix[3] = { { "auto", 0x0000 }, { "on", 0x1800 }, { "off", 0x0800 } };
-
-void usage()
-{
- fprintf(stderr, "Broadcom BCM5325E/536x switch configuration utility\n"
- "Copyright (C) 2005 Oleg I. Vdovikin\n\n"
- "This program is distributed in the hope that it will be useful,\n"
- "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
- "GNU General Public License for more details.\n\n");
-
- fprintf(stderr, "Usage: robocfg <op> ... <op>\n"
- "Operations are as below:\n"
- "\tshow\n"
- "\tswitch <enable|disable>\n"
- "\tport <port_number> [state <%s|%s|%s|%s>]\n\t\t[stp %s|%s|%s|%s|%s|%s] [tag <vlan_tag>]\n"
- "\t\t[media %s|%s|%s|%s|%s] [mdi-x %s|%s|%s]\n"
- "\tvlan <vlan_number> [ports <ports_list>]\n"
- "\tvlans <enable|disable|reset>\n\n"
- "\tports_list should be one argument, space separated, quoted if needed,\n"
- "\tport number could be followed by 't' to leave packet vlan tagged (CPU \n"
- "\tport default) or by 'u' to untag packet (other ports default) before \n"
- "\tbringing it to the port, '*' is ignored\n"
- "\nSamples:\n"
- "1) ASUS WL-500g Deluxe stock config (eth0 is WAN, eth0.1 is LAN):\n"
- "robocfg switch disable vlans enable reset vlan 0 ports \"0 5u\" vlan 1 ports \"1 2 3 4 5t\""
- " port 0 state enabled stp none switch enable\n"
- "2) WRT54g, WL-500g Deluxe OpenWRT config (vlan0 is LAN, vlan1 is WAN):\n"
- "robocfg switch disable vlans enable reset vlan 0 ports \"1 2 3 4 5t\" vlan 1 ports \"0 5t\""
- " port 0 state enabled stp none switch enable\n",
- rxtx[0], rxtx[1], rxtx[2], rxtx[3], stp[0], stp[1], stp[2], stp[3], stp[4], stp[5],
- media[0].name, media[1].name, media[2].name, media[3].name, media[4].name,
- mdix[0].name, mdix[1].name, mdix[2].name);
-}
-
-static robo_t robo;
-int bcm53xx_probe(const char *dev)
-{
- struct ethtool_drvinfo info;
- unsigned int phyid;
- int ret;
-
- fprintf(stderr, "probing %s\n", dev);
-
- strcpy(robo.ifr.ifr_name, dev);
- memset(&info, 0, sizeof(info));
- info.cmd = ETHTOOL_GDRVINFO;
- robo.ifr.ifr_data = (caddr_t)&info;
- ret = ioctl(robo.fd, SIOCETHTOOL, (caddr_t)&robo.ifr);
- if (ret < 0) {
- perror("SIOCETHTOOL");
- return ret;
- }
-
- if ( strcmp(info.driver, "et0") &&
- strcmp(info.driver, "b44") &&
- strcmp(info.driver, "bcm63xx_enet") ) {
- fprintf(stderr, "driver not supported %s\n", info.driver);
- return -ENOSYS;
- }
-
- /* try access using MII ioctls - get phy address */
- robo.et = 0;
- if (ioctl(robo.fd, SIOCGMIIPHY, &robo.ifr) < 0)
- robo.et = 1;
-
- if (robo.et) {
- unsigned int args[2] = { 2 };
-
- robo.ifr.ifr_data = (caddr_t) args;
- ret = ioctl(robo.fd, SIOCGETCPHYRD, (caddr_t)&robo.ifr);
- if (ret < 0) {
- perror("SIOCGETCPHYRD");
- return ret;
- }
- phyid = args[1] & 0xffff;
-
- args[0] = 3;
- robo.ifr.ifr_data = (caddr_t) args;
- ret = ioctl(robo.fd, SIOCGETCPHYRD, (caddr_t)&robo.ifr);
- if (ret < 0) {
- perror("SIOCGETCPHYRD");
- return ret;
- }
- phyid |= args[1] << 16;
- } else {
- struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&robo.ifr.ifr_data;
- mii->phy_id = ROBO_PHY_ADDR;
- mii->reg_num = 2;
- ret = ioctl(robo.fd, SIOCGMIIREG, &robo.ifr);
- if (ret < 0) {
- perror("SIOCGMIIREG");
- return ret;
- }
- phyid = mii->val_out & 0xffff;
-
- mii->phy_id = ROBO_PHY_ADDR;
- mii->reg_num = 3;
- ret = ioctl(robo.fd, SIOCGMIIREG, &robo.ifr);
- if (ret < 0) {
- perror("SIOCGMIIREG");
- return ret;
- }
- phyid |= mii->val_out << 16;
- }
-
- if (phyid == 0xffffffff || phyid == 0x55210022) {
- perror("phyid");
- return -EIO;
- }
-
- return 0;
-}
-
-int
-main(int argc, char *argv[])
-{
- u16 val16;
- u16 mac[3];
- int i = 0, j;
- int robo5350 = 0;
- u32 phyid;
-
- if ((robo.fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- perror("socket");
- exit(1);
- }
-
- if (bcm53xx_probe("eth1")) {
- if (bcm53xx_probe("eth0")) {
- perror("bcm53xx_probe");
- exit(1);
- }
- }
-
- robo5350 = robo_vlan5350(&robo);
-
- for (i = 1; i < argc;) {
- if (strcasecmp(argv[i], "port") == 0 && (i + 1) < argc)
- {
- int index = atoi(argv[++i]);
- /* read port specs */
- while (++i < argc) {
- if (strcasecmp(argv[i], "state") == 0 && ++i < argc) {
- for (j = 0; j < 4 && strcasecmp(argv[i], rxtx[j]); j++);
- if (j < 4) {
- /* change state */
- robo_write16(&robo,ROBO_CTRL_PAGE, port[index],
- (robo_read16(&robo, ROBO_CTRL_PAGE, port[index]) & ~(3 << 0)) | (j << 0));
- } else {
- fprintf(stderr, "Invalid state '%s'.\n", argv[i]);
- exit(1);
- }
- } else
- if (strcasecmp(argv[i], "stp") == 0 && ++i < argc) {
- for (j = 0; j < 8 && strcasecmp(argv[i], stp[j]); j++);
- if (j < 8) {
- /* change stp */
- robo_write16(&robo,ROBO_CTRL_PAGE, port[index],
- (robo_read16(&robo, ROBO_CTRL_PAGE, port[index]) & ~(7 << 5)) | (j << 5));
- } else {
- fprintf(stderr, "Invalid stp '%s'.\n", argv[i]);
- exit(1);
- }
- } else
- if (strcasecmp(argv[i], "media") == 0 && ++i < argc) {
- for (j = 0; j < 5 && strcasecmp(argv[i], media[j].name); j++);
- if (j < 5) {
- mdio_write(&robo, port[index], MII_BMCR, media[j].bmcr);
- } else {
- fprintf(stderr, "Invalid media '%s'.\n", argv[i]);
- exit(1);
- }
- } else
- if (strcasecmp(argv[i], "mdi-x") == 0 && ++i < argc) {
- for (j = 0; j < 3 && strcasecmp(argv[i], mdix[j].name); j++);
- if (j < 3) {
- mdio_write(&robo, port[index], 0x1c, mdix[j].value |
- (mdio_read(&robo, port[index], 0x1c) & ~0x1800));
- } else {
- fprintf(stderr, "Invalid mdi-x '%s'.\n", argv[i]);
- exit(1);
- }
- } else
- if (strcasecmp(argv[i], "tag") == 0 && ++i < argc) {
- j = atoi(argv[i]);
- /* change vlan tag */
- robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (index << 1), j);
- } else break;
- }
- } else
- if (strcasecmp(argv[i], "vlan") == 0 && (i + 1) < argc)
- {
- int index = atoi(argv[++i]);
- while (++i < argc) {
- if (strcasecmp(argv[i], "ports") == 0 && ++i < argc) {
- char *ports = argv[i];
- int untag = 0;
- int member = 0;
-
- while (*ports >= '0' && *ports <= '9') {
- j = *ports++ - '0';
- member |= 1 << j;
-
- /* untag if needed, CPU port requires special handling */
- if (*ports == 'u' || (j != 5 && (*ports == ' ' || *ports == 0)))
- {
- untag |= 1 << j;
- if (*ports) ports++;
- /* change default vlan tag */
- robo_write16(&robo, ROBO_VLAN_PAGE,
- ROBO_VLAN_PORT0_DEF_TAG + (j << 1), index);
- } else
- if (*ports == '*' || *ports == 't' || *ports == ' ') ports++;
- else break;
-
- while (*ports == ' ') ports++;
- }
-
- if (*ports) {
- fprintf(stderr, "Invalid ports '%s'.\n", argv[i]);
- exit(1);
- } else {
- /* write config now */
- val16 = (index) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
- if (robo5350) {
- robo_write32(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350,
- (1 << 20) /* valid */ | (untag << 6) | member);
- robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
- } else {
- robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE,
- (1 << 14) /* valid */ | (untag << 7) | member);
- robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
- }
- }
- } else break;
- }
- } else
- if (strcasecmp(argv[i], "switch") == 0 && (i + 1) < argc)
- {
- /* enable/disable switching */
- robo_write16(&robo, ROBO_CTRL_PAGE, ROBO_SWITCH_MODE,
- (robo_read16(&robo, ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & ~2) |
- (*argv[++i] == 'e' ? 2 : 0));
- i++;
- } else
- if (strcasecmp(argv[i], "vlans") == 0 && (i + 1) < argc)
- {
- while (++i < argc) {
- if (strcasecmp(argv[i], "reset") == 0) {
- /* reset vlan validity bit */
- for (j = 0; j <= (robo5350 ? VLAN_ID_MAX5350 : VLAN_ID_MAX); j++)
- {
- /* write config now */
- val16 = (j) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
- if (robo5350) {
- robo_write32(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, 0);
- robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
- } else {
- robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 0);
- robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
- }
- }
- } else
- if (strcasecmp(argv[i], "enable") == 0 || strcasecmp(argv[i], "disable") == 0)
- {
- int disable = (*argv[i] == 'd') || (*argv[i] == 'D');
- /* enable/disable vlans */
- robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0, disable ? 0 :
- (1 << 7) /* 802.1Q VLAN */ | (3 << 5) /* mac check and hash */);
-
- robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL1, disable ? 0 :
- (1 << 1) | (1 << 2) | (1 << 3) /* RSV multicast */);
-
- robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL4, disable ? 0 :
- (1 << 6) /* drop invalid VID frames */);
-
- robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL5, disable ? 0 :
- (1 << 3) /* drop miss V table frames */);
-
- } else break;
- }
- } else
- if (strcasecmp(argv[i], "show") == 0)
- {
- break;
- } else {
- fprintf(stderr, "Invalid option %s\n", argv[i]);
- usage();
- exit(1);
- }
- }
-
- if (i == argc) {
- if (argc == 1) usage();
- return 0;
- }
-
- /* show config */
-
- printf("Switch: %sabled\n", robo_read16(&robo, ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & 2 ? "en" : "dis");
-
- for (i = 0; i < 6; i++) {
- printf(robo_read16(&robo, ROBO_STAT_PAGE, ROBO_LINK_STAT_SUMMARY) & (1 << port[i]) ?
- "Port %d(%c): %s%s " : "Port %d(%c): DOWN ", i, ports[i],
- robo_read16(&robo, ROBO_STAT_PAGE, ROBO_SPEED_STAT_SUMMARY) & (1 << port[i]) ? "100" : " 10",
- robo_read16(&robo, ROBO_STAT_PAGE, ROBO_DUPLEX_STAT_SUMMARY) & (1 << port[i]) ? "FD" : "HD");
-
- val16 = robo_read16(&robo, ROBO_CTRL_PAGE, port[i]);
-
- printf("%s stp: %s vlan: %d ", rxtx[val16 & 3], stp[(val16 >> 5) & 7],
- robo_read16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (i << 1)));
-
- robo_read(&robo, ROBO_STAT_PAGE, ROBO_LSA_PORT0 + port[i] * 6, mac, 3);
-
- printf("mac: %02x:%02x:%02x:%02x:%02x:%02x\n",
- mac[2] >> 8, mac[2] & 255, mac[1] >> 8, mac[1] & 255, mac[0] >> 8, mac[0] & 255);
- }
-
- val16 = robo_read16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0);
-
- printf("VLANs: %s %sabled%s%s\n",
- robo5350 ? "BCM5325/535x" : "BCM536x",
- (val16 & (1 << 7)) ? "en" : "dis",
- (val16 & (1 << 6)) ? " mac_check" : "",
- (val16 & (1 << 5)) ? " mac_hash" : "");
-
- /* scan VLANs */
- for (i = 0; i <= (robo5350 ? VLAN_ID_MAX5350 : VLAN_ID_MAX); i++) {
- /* issue read */
- val16 = (i) /* vlan */ | (0 << 12) /* read */ | (1 << 13) /* enable */;
-
- if (robo5350) {
- u32 val32;
- robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
- /* actual read */
- val32 = robo_read32(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_READ);
- if ((val32 & (1 << 20)) /* valid */) {
- printf("vlan%d:", i);
- for (j = 0; j < 6; j++) {
- if (val32 & (1 << j)) {
- printf(" %d%s", j, (val32 & (1 << (j + 6))) ?
- (j == 5 ? "u" : "") : "t");
- }
- }
- printf("\n");
- }
- } else {
- robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
- /* actual read */
- val16 = robo_read16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_READ);
- if ((val16 & (1 << 14)) /* valid */) {
- printf("vlan%d:", i);
- for (j = 0; j < 6; j++) {
- if (val16 & (1 << j)) {
- printf(" %d%s", j, (val16 & (1 << (j + 7))) ?
- (j == 5 ? "u" : "") : "t");
- }
- }
- printf("\n");
- }
- }
- }
-
- return (0);
-}
diff --git a/package/system/utils/usbmode/Makefile b/package/system/utils/usbmode/Makefile
deleted file mode 100644
index 491f3e572f..0000000000
--- a/package/system/utils/usbmode/Makefile
+++ /dev/null
@@ -1,57 +0,0 @@
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=usbmode
-PKG_VERSION:=2013-05-31
-PKG_RELEASE=$(PKG_SOURCE_VERSION)
-
-PKG_SOURCE_PROTO:=git
-PKG_SOURCE_URL:=git://git.openwrt.org/project/usbmode.git
-PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
-PKG_SOURCE_VERSION:=b62a33af03c39a8970249ce7afe7baec7ea9b91b
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
-CMAKE_INSTALL:=1
-
-PKG_LICENSE:=GPLv2
-PKG_LICENSE_FILES:=
-
-PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
-
-PKG_DATA_VERSION:=20121109
-PKG_DATA_URL:=http://www.draisberghof.de/usb_modeswitch
-PKG_DATA_PATH:=usb-modeswitch-data-$(PKG_DATA_VERSION)
-PKG_DATA_FILENAME:=$(PKG_DATA_PATH).tar.bz2
-
-include $(INCLUDE_DIR)/package.mk
-include $(INCLUDE_DIR)/cmake.mk
-
-define Download/data
- FILE:=$(PKG_DATA_FILENAME)
- URL:=$(PKG_DATA_URL)
- MD5SUM:=a7d23a03157871013a0d708ab2b1b6df
-endef
-$(eval $(call Download,data))
-
-define Package/usb-modeswitch
- SECTION:=utils
- CATEGORY:=Utilities
- DEPENDS:=+libubox +libblobmsg-json +libusb-1.0
- TITLE:=USB mode switching utility
-endef
-
-define Build/Prepare
- $(Build/Prepare/Default)
- tar xvfj $(DL_DIR)/$(PKG_DATA_FILENAME) -C $(PKG_BUILD_DIR)
- rm -f \
- $(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/05c6:1000:sVe=GT
-endef
-
-define Package/usb-modeswitch/install
- $(INSTALL_DIR) $(1)/etc/hotplug.d/usb $(1)/sbin
- perl $(PKG_BUILD_DIR)/convert-modeswitch.pl \
- $(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/* \
- > $(1)/etc/usb-mode.json
- $(CP) ./files/usbmode.hotplug $(1)/etc/hotplug.d/usb/20-usb_mode
- $(CP) $(PKG_INSTALL_DIR)/usr/sbin/usbmode $(1)/sbin/
-endef
-
-$(eval $(call BuildPackage,usb-modeswitch))
diff --git a/package/system/utils/usbmode/files/usbmode.hotplug b/package/system/utils/usbmode/files/usbmode.hotplug
deleted file mode 100644
index 4ef2bd8daa..0000000000
--- a/package/system/utils/usbmode/files/usbmode.hotplug
+++ /dev/null
@@ -1,7 +0,0 @@
-. /lib/functions/procd.sh
-
-procd_open_service "usbmode"
-procd_open_instance
-procd_set_param command "/sbin/usbmode" -s
-procd_close_instance
-procd_close_service
diff --git a/package/system/utils/usbreset/Makefile b/package/system/utils/usbreset/Makefile
deleted file mode 100644
index 75bfd85138..0000000000
--- a/package/system/utils/usbreset/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright (C) 2011-2012 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:=usbreset
-PKG_RELEASE:=2
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/usbreset
- SECTION:=utils
- CATEGORY:=Utilities
- TITLE:=Utility to send a USB port reset to a USB device
- MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
-endef
-
-define Package/usbreset/description
- This package contains the small usbreset utility which
- can be used to send a USB port reset to a USB device -
- useful for debugging or to force re-detection of particular
- devices.
-endef
-
-define Build/Prepare
- $(INSTALL_DIR) $(PKG_BUILD_DIR)
- $(INSTALL_DATA) ./src/usbreset.c $(PKG_BUILD_DIR)/
-endef
-
-define Build/Compile
- $(TARGET_CC) $(TARGET_CFLAGS) -Wall \
- -o $(PKG_BUILD_DIR)/usbreset $(PKG_BUILD_DIR)/usbreset.c
-endef
-
-define Package/usbreset/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/usbreset $(1)/usr/bin/
-endef
-
-$(eval $(call BuildPackage,usbreset))
diff --git a/package/system/utils/usbreset/src/usbreset.c b/package/system/utils/usbreset/src/usbreset.c
deleted file mode 100644
index 087a14cfa4..0000000000
--- a/package/system/utils/usbreset/src/usbreset.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/* usbreset -- send a USB port reset to a USB device */
-
-/*
-
-http://marc.info/?l=linux-usb-users&m=116827193506484&w=2
-
-and needs mounted usbfs filesystem
-
- sudo mount -t usbfs none /proc/bus/usb
-
-There is a way to suspend a USB device. In order to use it,
-you must have a kernel with CONFIG_PM_SYSFS_DEPRECATED turned on. To
-suspend a device, do (as root):
-
- echo -n 2 >/sys/bus/usb/devices/.../power/state
-
-where the "..." is the ID for your device. To unsuspend, do the same
-thing but with a "0" instead of the "2" above.
-
-Note that this mechanism is slated to be removed from the kernel within
-the next year. Hopefully some other mechanism will take its place.
-
-> To reset a
-> device?
-
-Here's a program to do it. You invoke it as either
-
- usbreset /proc/bus/usb/BBB/DDD
-or
- usbreset /dev/usbB.D
-
-depending on how your system is set up, where BBB and DDD are the bus and
-device address numbers.
-
-Alan Stern
-
-*/
-
-#include <stdio.h>
-#include <stdbool.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/ioctl.h>
-
-#include <linux/usbdevice_fs.h>
-
-
-static char *usbfs = NULL;
-
-struct usbentry {
- int bus_num;
- int dev_num;
- int vendor_id;
- int product_id;
- char vendor_name[128];
- char product_name[128];
-};
-
-
-static bool find_usbfs(void)
-{
- FILE *mtab;
-
- char buf[1024], type[32];
- static char path[1024];
-
- if ((mtab = fopen("/proc/mounts", "r")) != NULL)
- {
- while (fgets(buf, sizeof(buf), mtab))
- {
- if (sscanf(buf, "%*s %1023s %31s ", path, type) == 2 &&
- !strncmp(type, "usbfs", 5))
- {
- usbfs = path;
- break;
- }
- }
-
- fclose(mtab);
- }
-
- return !!usbfs;
-}
-
-static FILE * open_devlist(void)
-{
- char buf[1024];
- snprintf(buf, sizeof(buf), "%s/devices", usbfs);
- return fopen(buf, "r");
-}
-
-static void close_devlist(FILE *devs)
-{
- fclose(devs);
-}
-
-static struct usbentry * parse_devlist(FILE *devs)
-{
- char buf[1024];
- static struct usbentry dev;
-
- memset(&dev, 0, sizeof(dev));
-
- while (fgets(buf, sizeof(buf), devs))
- {
- buf[strlen(buf)-1] = 0;
-
- switch (buf[0])
- {
- case 'T':
- sscanf(buf, "T: Bus=%d Lev=%*d Prnt=%*d Port=%*d Cnt=%*d Dev#=%d",
- &dev.bus_num, &dev.dev_num);
- break;
-
- case 'P':
- sscanf(buf, "P: Vendor=%x ProdID=%x",
- &dev.vendor_id, &dev.product_id);
- break;
-
- case 'S':
- if (!strncmp(buf, "S: Manufacturer=", 17))
- snprintf(dev.vendor_name, sizeof(dev.vendor_name),
- "%s", buf+17);
- else if (!strncmp(buf, "S: Product=", 12))
- snprintf(dev.product_name, sizeof(dev.product_name),
- "%s", buf+12);
- break;
- }
-
- if (dev.product_name[0])
- return &dev;
- }
-
- return NULL;
-}
-
-static void list_devices(void)
-{
- FILE *devs = open_devlist();
- struct usbentry *dev;
-
- if (!devs)
- return;
-
- while ((dev = parse_devlist(devs)) != NULL)
- {
- printf(" Number %03d/%03d ID %04x:%04x %s\n",
- dev->bus_num, dev->dev_num,
- dev->vendor_id, dev->product_id,
- dev->product_name);
- }
-
- close_devlist(devs);
-}
-
-struct usbentry * find_device(int *bus, int *dev,
- int *vid, int *pid,
- const char *product)
-{
- FILE *devs = open_devlist();
-
- struct usbentry *e, *match = NULL;
-
- if (!devs)
- return NULL;
-
- while ((e = parse_devlist(devs)) != NULL)
- {
- if ((bus && (e->bus_num == *bus) && (e->dev_num == *dev)) ||
- (vid && (e->vendor_id == *vid) && (e->product_id == *pid)) ||
- (product && !strcasecmp(e->product_name, product)))
- {
- match = e;
- break;
- }
- }
-
- close_devlist(devs);
-
- return match;
-}
-
-static void reset_device(struct usbentry *dev)
-{
- int fd;
- char path[1024];
-
- snprintf(path, sizeof(path), "%s/%03d/%03d",
- usbfs, dev->bus_num, dev->dev_num);
-
- printf("Resetting %s ... ", dev->product_name);
-
- if ((fd = open(path, O_WRONLY)) > -1)
- {
- if (ioctl(fd, USBDEVFS_RESET, 0) < 0)
- printf("failed [%s]\n", strerror(errno));
- else
- printf("ok\n");
-
- close(fd);
- }
- else
- {
- printf("can't open [%s]\n", strerror(errno));
- }
-}
-
-
-int main(int argc, char **argv)
-{
- int id1, id2;
- struct usbentry *dev;
-
- if (!find_usbfs())
- {
- fprintf(stderr, "Unable to find usbfs, is it mounted?\n");
- return 1;
- }
-
- if ((argc == 2) && (sscanf(argv[1], "%3d/%3d", &id1, &id2) == 2))
- {
- dev = find_device(&id1, &id2, NULL, NULL, NULL);
- }
- else if ((argc == 2) && (sscanf(argv[1], "%4x:%4x", &id1, &id2) == 2))
- {
- dev = find_device(NULL, NULL, &id1, &id2, NULL);
- }
- else if ((argc == 2) && strlen(argv[1]) < 128)
- {
- dev = find_device(NULL, NULL, NULL, NULL, argv[1]);
- }
- else
- {
- printf("Usage:\n"
- " usbreset PPPP:VVVV - reset by product and vendor id\n"
- " usbreset BBB/DDD - reset by bus and device number\n"
- " usbreset \"Product\" - reset by product name\n\n"
- "Devices:\n");
- list_devices();
- return 1;
- }
-
- if (!dev)
- {
- fprintf(stderr, "No such device found\n");
- return 1;
- }
-
- reset_device(dev);
- return 0;
-}
diff --git a/package/system/utils/usbutils/Makefile b/package/system/utils/usbutils/Makefile
deleted file mode 100644
index 2cd59ae74c..0000000000
--- a/package/system/utils/usbutils/Makefile
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# Copyright (C) 2007-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:=usbutils
-PKG_VERSION:=006
-PKG_RELEASE:=1
-
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
-PKG_SOURCE_URL:=@KERNEL/linux/utils/usb/usbutils
-PKG_MD5SUM:=9d13954981f4adbe3fd02aae6dbfafa9
-
-USB_IDS_VERSION:=2013-01-16
-USB_IDS_MD5SUM:=2a2344907b6344f0935c86efaf9de620
-USB_IDS_FILE:=usb.ids.$(USB_IDS_VERSION).gz
-
-PKG_BUILD_PARALLEL:=1
-PKG_INSTALL:=1
-
-PKG_MAINTAINER := Felix Fietkau <nbd@openwrt.org>
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/usbutils
- SECTION:=utils
- CATEGORY:=Utilities
- DEPENDS:=+libusb-1.0 +zlib +librt +libpthread
- TITLE:=USB devices listing utilities
- URL:=http://www.linux-usb.org/
-endef
-
-define Download/usb_ids
- FILE:=$(USB_IDS_FILE)
- URL:=http://mirror2.openwrt.org/sources
- MD5SUM:=$(USB_IDS_MD5SUM)
-endef
-$(eval $(call Download,usb_ids))
-
-define Build/Prepare
- $(Build/Prepare/Default)
- echo '#!/bin/sh' > $(PKG_BUILD_DIR)/update-usbids.sh.in
- echo 'cp $(DL_DIR)/$(USB_IDS_FILE) usb.ids.gz' >> $(PKG_BUILD_DIR)/update-usbids.sh.in
-endef
-
-define Package/usbutils/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lsusb $(1)/usr/bin/
- $(INSTALL_DIR) $(1)/usr/share
- $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/usb.ids.gz $(1)/usr/share/
-endef
-
-$(eval $(call BuildPackage,usbutils))
diff --git a/package/system/utils/util-linux/Makefile b/package/system/utils/util-linux/Makefile
deleted file mode 100644
index ed2c10f172..0000000000
--- a/package/system/utils/util-linux/Makefile
+++ /dev/null
@@ -1,594 +0,0 @@
-#
-# Copyright (C) 2007-2012 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:=util-linux
-PKG_VERSION:=2.21.2
-PKG_RELEASE:=2
-
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
-PKG_SOURCE_URL:=@KERNEL/linux/utils/$(PKG_NAME)/v2.21
-PKG_MD5SUM:=54ba880f1d66782c2287ee2c898520e9
-
-PKG_LICENSE:=GPLv2 LGPLv2.1 BSD-3c
-PKG_LICENSE_FILES:=COPYING getopt/COPYING libblkid/COPYING libmount/COPYING Documentation/licenses/COPYING.GPLv2 Documentation/licenses/COPYING.LGPLv2.1 libuuid/COPYING Documentation/licenses/COPYING.BSD-3
-
-PKG_BUILD_PARALLEL:=1
-PKG_BUILD_DEPENDS:=libncurses
-PKG_FIXUP:=autoreconf
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/util-linux/Default
- SECTION:=utils
- CATEGORY:=Utilities
- URL:=http://www.kernel.org/pub/linux/utils/util-linux/
-endef
-
-CONFIGURE_ARGS += \
- --enable-new-mount \
- --with-ncurses \
- --disable-nls \
- --disable-tls \
- --without-udev
-
-TARGET_CFLAGS += $(FPIC)
-
-define Build/InstallDev
- $(MAKE) -C $(PKG_BUILD_DIR) \
- BUILDCC="$(HOSTCC)" \
- DESTDIR="$(1)" \
- installdirs install-data
-
- $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
- $(CP) $(PKG_BUILD_DIR)/libblkid/blkid.pc $(1)/usr/lib/pkgconfig
- $(CP) $(PKG_BUILD_DIR)/libmount/mount.pc $(1)/usr/lib/pkgconfig
- $(CP) $(PKG_BUILD_DIR)/libuuid/uuid.pc $(1)/usr/lib/pkgconfig
-
- $(INSTALL_DIR) $(1)/usr/include/blkid
- $(CP) $(PKG_BUILD_DIR)/libblkid/src/blkid.h $(1)/usr/include/blkid
- $(INSTALL_DIR) $(1)/usr/include/libmount
- $(CP) $(PKG_BUILD_DIR)/libmount/src/libmount.h $(1)/usr/include/libmount
- $(INSTALL_DIR) $(1)/usr/include/uuid
- $(CP) $(PKG_BUILD_DIR)/libuuid/src/uuid.h $(1)/usr/include/uuid
-
- $(INSTALL_DIR) $(1)/usr/lib
- $(CP) $(PKG_BUILD_DIR)/libblkid/src/.libs/libblkid.{a,so*} $(1)/usr/lib
- $(CP) $(PKG_BUILD_DIR)/libmount/src/.libs/libmount.{a,so*} $(1)/usr/lib
- $(CP) $(PKG_BUILD_DIR)/libuuid/src/.libs/libuuid.{a,so*} $(1)/usr/lib
-endef
-
-define Package/libblkid
-$(call Package/util-linux/Default)
- DEPENDS:=+libuuid
- TITLE:=block device id library
- SECTION:=libs
- CATEGORY:=Libraries
-endef
-
-define Package/libblkid/description
- The libblkid library is used to identify block devices (disks) as to their
- content (e.g. filesystem type, partitions) as well as extracting additional
- information such as filesystem labels/volume names, partitions, unique
- identifiers/serial numbers...
-endef
-
-define Package/libmount
-$(call Package/util-linux/Default)
- DEPENDS:=+libblkid
- TITLE:=mount library
- SECTION:=libs
- CATEGORY:=Libraries
-endef
-
-define Package/libmount/description
- The libmount library is used to parse /etc/fstab, /etc/mtab and
- /proc/self/mountinfo files, manage the mtab file, evaluate mount options...
-endef
-
-define Package/libuuid
-$(call Package/util-linux/Default)
- TITLE:=DCE compatible Universally Unique Identifier library
- SECTION:=libs
- CATEGORY:=Libraries
-endef
-
-define Package/libuuid/description
- The UUID library is used to generate unique identifiers for objects
- that may be accessible beyond the local system. This library
- generates UUIDs compatible with those created by the Open Software
- Foundation (OSF) Distributed Computing Environment (DCE) utility.
-endef
-
-define Package/agetty
-$(call Package/util-linux/Default)
- TITLE:=alternative Linux getty
- SUBMENU=Terminal
-endef
-
-define Package/agetty/description
- agetty opens a tty port, prompts for a login name and invokes the
- /bin/login command
-endef
-
-define Package/blkid
-$(call Package/util-linux/Default)
- TITLE:=locate/print block device attributes
- DEPENDS:= +libblkid
- SUBMENU=disc
-endef
-
-define Package/blkid/description
- The blkid program is the command-line interface to working with the libblkid
- library.
-endef
-
-define Package/cal
-$(call Package/util-linux/Default)
- TITLE:=display a calendar
- DEPENDS:= +libncurses
-endef
-
-define Package/cal/description
- cal displays a simple calendar
-endef
-
-define Package/cfdisk
-$(call Package/util-linux/Default)
- TITLE:=display or manipulate disk partition table
- DEPENDS:= +libblkid +libncurses
- SUBMENU:=disc
-endef
-
-define Package/cfdisk/description
- cfdisk is a curses-based program for partitioning any hard disk drive
-endef
-
-define Package/dmesg
-$(call Package/util-linux/Default)
- TITLE:=print or control the kernel ring buffer
-endef
-
-define Package/dmesg/description
- dmesg is used to examine or control the kernel ring buffer
-endef
-
-define Package/fdisk
-$(call Package/util-linux/Default)
- TITLE:=manipulate disk partition table
- DEPENDS:= +libblkid
- SUBMENU=disc
-endef
-
-define Package/fdisk/description
- a menu-driven program for creation and manipulation of partition tables
-endef
-
-define Package/findfs
-$(call Package/util-linux/Default)
- TITLE:=find a filesystem by label or UUID
- DEPENDS:= +libblkid
- SUBMENU=disc
-endef
-
-define Package/findfs/description
- findfs will search the disks in the system looking for a filesystem which has
- a label matching label or a UUID equal to uuid
-endef
-
-define Package/flock
-$(call Package/util-linux/Default)
- TITLE:=manage locks from shell scripts
-endef
-
-define Package/flock/description
- manages flock locks from within shell scripts or the command line
-endef
-
-define Package/getopt
-$(call Package/util-linux/Default)
- TITLE:=parse command options (enhanced)
-endef
-
-define Package/getopt/description
- getopt is used to break up (parse) options in command lines for easy parsing
- by shell procedures, and to check for legal options
-endef
-
-define Package/hwclock
-$(call Package/util-linux/Default)
- TITLE:=query or set the hardware clock
-endef
-
-define Package/hwclock/description
- hwclock is a tool for accessing the Hardware Clock
-endef
-
-define Package/logger
-$(call Package/util-linux/Default)
- TITLE:=a shell command interface to the syslog system log module
-endef
-
-define Package/logger/description
- logger makes entries in the system log, it provides a shell command interface
- to the syslog system log module
-endef
-
-define Package/look
-$(call Package/util-linux/Default)
- TITLE:=display lines beginning with a given string
-endef
-
-define Package/look/description
- look utility displays any lines in file which contain string
-endef
-
-define Package/losetup
-$(call Package/util-linux/Default)
- TITLE:=set up and control loop devices
-endef
-
-define Package/losetup/description
- losetup is used to associate loop devices with regular files or block devices,
- to detach loop devices and to query the status of a loop device
-endef
-
-define Package/lsblk
-$(call Package/util-linux/Default)
- TITLE:=list block devices
- DEPENDS:= +libblkid
- SUBMENU=disc
-endef
-
-define Package/lsblk/description
- lsblk lists information about all or the specified block devices
-endef
-
-define Package/mcookie
-$(call Package/util-linux/Default)
- TITLE:=generate magic cookies for xauth
-endef
-
-define Package/mcookie/description
- mcookie generates a 128-bit random hexadecimal number for use with the X
- authority system
-endef
-
-define Package/mount-utils
-$(call Package/util-linux/Default)
- TITLE:=related (u)mount utilities
- DEPENDS+= +libmount
-endef
-
-define Package/mount-utils/description
- contains: mount, umount, findmnt
-endef
-
-define Package/namei
-$(call Package/util-linux/Default)
- TITLE:=follow a pathname until a terminal point is found
-endef
-
-define Package/namei/description
- namei uses its arguments as pathnames to any type of Unix file (symlinks,
- files, directories, and so forth)
-endef
-
-define Package/rename
-$(call Package/util-linux/Default)
- TITLE:=rename files
-endef
-
-define Package/rename/description
- rename will rename the specified files by replacing the first occurrence of
- expression in their name by replacement
-endef
-
-define Package/partx-utils
-$(call Package/util-linux/Default)
- TITLE:=inform kernel about the presence and numbering of on-disk partitions
- DEPENDS:= +libblkid
- SUBMENU=disc
-endef
-
-define Package/partx-utils/description
- contains partx, addpart, delpart
-endef
-
-define Package/script-utils
-$(call Package/util-linux/Default)
- TITLE:=make and replay typescript of terminal session
- SUBMENU=Terminal
-endef
-
-define Package/script-utils/description
- contains: script, scriptreplay
-endef
-
-define Package/setterm
-$(call Package/util-linux/Default)
- TITLE:=set terminal attributes
- DEPENDS:= +libncurses
- SUBMENU:=Terminal
-endef
-
-define Package/setterm/description
- setterm writes to standard output a character string that will invoke the
- specified terminal capabilities
-endef
-
-define Package/sfdisk
-$(call Package/util-linux/Default)
- TITLE:=partition table manipulator for Linux
- SUBMENU=disc
-endef
-
-define Package/sfdisk/description
- list the size of a partition, list the partitions on a device, check the
- partitions on a device and repartition a device
-endef
-
-define Package/swap-utils
-$(call Package/util-linux/Default)
- TITLE:=swap space management utilities
- DEPENDS+= +libblkid
- SUBMENU:=disc
-endef
-
-define Package/swap-utils/description
- contains: mkswap, swaplabel, swapon, swapoff
-endef
-
-define Package/uuidd
-$(call Package/util-linux/Default)
- TITLE:=UUID generation daemon
- DEPENDS:= +libuuid
-endef
-
-define Package/uuidd/description
- The uuidd daemon is used by the UUID library to generate universally unique
- identifiers (UUIDs), especially time-based UUIDs, in a secure and
- guaranteed-unique fashion, even in the face of large numbers of threads
- running on different CPUs trying to grab UUIDs.
-endef
-
-define Package/uuidgen
-$(call Package/util-linux/Default)
- TITLE:=create a new UUID value
- DEPENDS:= +libuuid
-endef
-
-define Package/uuidgen/description
- The uuidgen program creates (and prints) a new universally unique identifier
- (UUID) using the libuuid library. The new UUID can reasonably be considered
- unique among all UUIDs created on the local system, and among UUIDs created on
- other systems in the past and in the future.
-endef
-
-define Package/wall
-$(call Package/util-linux/Default)
- TITLE:=send a message to everybody's terminal
- SUBMENU=Terminal
-endef
-
-define Package/wall/description
- wall sends a message to everybody logged in with their mesg permission
- set to yes
-endef
-
-define Package/whereis
-$(call Package/util-linux/Default)
- TITLE:=locate the binary, source, and manual page files for a command
-endef
-
-define Package/whereis/description
- whereis locates source/binary and manuals sections for specified files
-endef
-
-define Package/wipefs
-$(call Package/util-linux/Default)
- TITLE:=wipe a signature from a device
- DEPENDS:= +libblkid
- SUBMENU:=disc
-endef
-
-define Package/wipefs/description
- wipefs can erase filesystem, raid or partition table signatures (magic
- strings) from the specified device to make the signature invisible for
- libblkid.
-endef
-
-define Package/libblkid/install
- $(INSTALL_DIR) $(1)/usr/lib
- $(CP) $(PKG_BUILD_DIR)/libblkid/src/.libs/libblkid.so.* $(1)/usr/lib/
-endef
-
-define Package/libmount/install
- $(INSTALL_DIR) $(1)/usr/lib
- $(CP) $(PKG_BUILD_DIR)/libmount/src/.libs/libmount.so.* $(1)/usr/lib/
-endef
-
-define Package/libuuid/install
- $(INSTALL_DIR) $(1)/usr/lib
- $(CP) $(PKG_BUILD_DIR)/libuuid/src/.libs/libuuid.so.* $(1)/usr/lib/
-endef
-
-define Package/agetty/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/agetty $(1)/usr/sbin/
-endef
-
-define Package/blkid/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/blkid $(1)/usr/sbin/
-endef
-
-define Package/cal/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/cal $(1)/usr/bin/
-endef
-
-define Package/cfdisk/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/fdisk/.libs/cfdisk $(1)/usr/sbin/
-endef
-
-define Package/fdisk/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/fdisk/.libs/fdisk $(1)/usr/sbin/
-endef
-
-define Package/findfs/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/findfs $(1)/usr/sbin/
-endef
-
-define Package/flock/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/flock $(1)/usr/bin/
-endef
-
-define Package/getopt/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/getopt/getopt $(1)/usr/bin/
-endef
-
-define Package/hwclock/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/hwclock/hwclock $(1)/usr/sbin/
-endef
-
-define Package/logger/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/logger $(1)/usr/bin/
-endef
-
-define Package/look/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/look $(1)/usr/bin/
-endef
-
-define Package/losetup/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/losetup $(1)/usr/sbin/
-endef
-
-define Package/lsblk/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/lsblk $(1)/usr/bin/
-endef
-
-define Package/mcookie/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/mcookie $(1)/usr/bin/
-endef
-
-define Package/mount-utils/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/.libs/{u,}mount $(1)/usr/bin/
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/.libs/mountpoint $(1)/usr/bin/
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/findmnt $(1)/usr/bin/
-endef
-
-define Package/namei/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/namei $(1)/usr/bin/
-endef
-
-define Package/rename/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/rename $(1)/usr/bin/
-endef
-
-define Package/partx-utils/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/partx/.libs/partx $(1)/usr/sbin/
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/partx/addpart $(1)/usr/sbin/
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/partx/delpart $(1)/usr/sbin/
-endef
-
-define Package/script-utils/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/script $(1)/usr/bin/
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/scriptreplay $(1)/usr/bin/
-endef
-
-define Package/setterm/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/setterm $(1)/usr/bin/
-endef
-
-define Package/sfdisk/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/fdisk/sfdisk $(1)/usr/sbin/
-endef
-
-define Package/swap-utils/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/disk-utils/.libs/mkswap $(1)/usr/sbin/
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/disk-utils/.libs/swaplabel $(1)/usr/sbin/
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/sys-utils/.libs/swapon $(1)/usr/sbin/
- ln -sf swapon $(1)/usr/sbin/swapoff
-endef
-
-define Package/uuidd/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/uuidd $(1)/usr/sbin/
-endef
-
-define Package/uuidgen/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/uuidgen $(1)/usr/bin/
-endef
-
-define Package/wall/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/term-utils/wall $(1)/usr/bin/
-endef
-
-define Package/whereis/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/whereis $(1)/usr/bin/
-endef
-
-define Package/wipefs/install
- $(INSTALL_DIR) $(1)/usr/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc-utils/.libs/wipefs $(1)/usr/sbin/
-endef
-
-$(eval $(call BuildPackage,libblkid))
-$(eval $(call BuildPackage,libmount))
-$(eval $(call BuildPackage,libuuid))
-$(eval $(call BuildPackage,agetty))
-$(eval $(call BuildPackage,blkid))
-$(eval $(call BuildPackage,cal))
-$(eval $(call BuildPackage,cfdisk))
-$(eval $(call BuildPackage,dmesg))
-$(eval $(call BuildPackage,fdisk))
-$(eval $(call BuildPackage,findfs))
-$(eval $(call BuildPackage,flock))
-$(eval $(call BuildPackage,getopt))
-$(eval $(call BuildPackage,hwclock))
-$(eval $(call BuildPackage,logger))
-$(eval $(call BuildPackage,look))
-$(eval $(call BuildPackage,losetup))
-$(eval $(call BuildPackage,lsblk))
-$(eval $(call BuildPackage,mcookie))
-$(eval $(call BuildPackage,mount-utils))
-$(eval $(call BuildPackage,namei))
-$(eval $(call BuildPackage,rename))
-$(eval $(call BuildPackage,partx-utils))
-$(eval $(call BuildPackage,script-utils))
-$(eval $(call BuildPackage,setterm))
-$(eval $(call BuildPackage,sfdisk))
-$(eval $(call BuildPackage,swap-utils))
-$(eval $(call BuildPackage,uuidd))
-$(eval $(call BuildPackage,uuidgen))
-$(eval $(call BuildPackage,wall))
-$(eval $(call BuildPackage,whereis))
-$(eval $(call BuildPackage,wipefs))
diff --git a/package/system/utils/util-linux/patches/000-compile.patch b/package/system/utils/util-linux/patches/000-compile.patch
deleted file mode 100644
index b7cc18b40c..0000000000
--- a/package/system/utils/util-linux/patches/000-compile.patch
+++ /dev/null
@@ -1,44 +0,0 @@
---- a/misc-utils/cal.c
-+++ b/misc-utils/cal.c
-@@ -291,41 +291,6 @@ main(int argc, char **argv) {
- }
- #endif
-
--/*
-- * The traditional Unix cal utility starts the week at Sunday,
-- * while ISO 8601 starts at Monday. We read the start day from
-- * the locale database, which can be overridden with the
-- * -s (Sunday) or -m (Monday) options.
-- */
--#if HAVE_DECL__NL_TIME_WEEK_1STDAY
-- /*
-- * You need to use 2 locale variables to get the first day of the week.
-- * This is needed to support first_weekday=2 and first_workday=1 for
-- * the rare case where working days span across 2 weeks.
-- * This shell script shows the combinations and calculations involved:
-- *
-- * for LANG in en_US ru_RU fr_FR csb_PL POSIX; do
-- * printf "%s:\t%s + %s -1 = " $LANG $(locale week-1stday first_weekday)
-- * date -d"$(locale week-1stday) +$(($(locale first_weekday)-1))day" +%w
-- * done
-- *
-- * en_US: 19971130 + 1 -1 = 0 #0 = sunday
-- * ru_RU: 19971130 + 2 -1 = 1
-- * fr_FR: 19971201 + 1 -1 = 1
-- * csb_PL: 19971201 + 2 -1 = 2
-- * POSIX: 19971201 + 7 -1 = 0
-- */
-- {
-- int wfd;
-- union { unsigned int word; char *string; } val;
-- val.string = nl_langinfo(_NL_TIME_WEEK_1STDAY);
--
-- wfd = val.word;
-- wfd = day_in_week(wfd % 100, (wfd / 100) % 100, wfd / (100 * 100));
-- weekstart = (wfd + *nl_langinfo(_NL_TIME_FIRST_WEEKDAY) - 1) % 7;
-- }
--#endif
--
- yflag = 0;
- while ((ch = getopt_long(argc, argv, "13mjsyVh", longopts, NULL)) != -1)
- switch(ch) {
diff --git a/package/system/utils/util-linux/patches/001-no-printf-alloc.patch b/package/system/utils/util-linux/patches/001-no-printf-alloc.patch
deleted file mode 100644
index e3f048ab3c..0000000000
--- a/package/system/utils/util-linux/patches/001-no-printf-alloc.patch
+++ /dev/null
@@ -1,108 +0,0 @@
-for systems that don't support latest POSIX standard: %as
-
-https://bugs.gentoo.org/406303
-
---- a/configure.ac
-+++ b/configure.ac
-@@ -688,7 +688,6 @@ AC_ARG_ENABLE([libmount],
- UL_BUILD_INIT([libmount])
- UL_REQUIRES_LINUX([libmount])
- UL_REQUIRES_BUILD([libmount], [libblkid])
--UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier])
- AM_CONDITIONAL(BUILD_LIBMOUNT, test "x$build_libmount" = xyes)
-
- AC_SUBST([LIBMOUNT_VERSION])
---- a/libmount/src/tab_parse.c
-+++ b/libmount/src/tab_parse.c
-@@ -22,6 +22,10 @@
- #include "pathnames.h"
- #include "strutils.h"
-
-+#ifndef HAVE_SCANF_MS_MODIFIER
-+# define UL_SCNsA "%s"
-+#endif
-+
- static inline char *skip_spaces(char *s)
- {
- assert(s);
-@@ -61,16 +65,31 @@ static int mnt_parse_table_line(struct l
- int rc, n = 0, xrc;
- char *src = NULL, *fstype = NULL, *optstr = NULL;
-
-+#ifndef HAVE_SCANF_MS_MODIFIER
-+ size_t len = strlen(s) + 1;
-+ src = malloc(len);
-+ fstype = malloc(len);
-+ fs->target = malloc(len);
-+ optstr = malloc(len);
-+#endif
-+
- rc = sscanf(s, UL_SCNsA" " /* (1) source */
- UL_SCNsA" " /* (2) target */
- UL_SCNsA" " /* (3) FS type */
- UL_SCNsA" " /* (4) options */
- "%n", /* byte count */
-
-+#ifdef HAVE_SCANF_MS_MODIFIER
- &src,
- &fs->target,
- &fstype,
- &optstr,
-+#else
-+ src,
-+ fs->target,
-+ fstype,
-+ optstr,
-+#endif
- &n);
- xrc = rc;
-
-@@ -136,6 +155,16 @@ static int mnt_parse_mountinfo_line(stru
- unsigned int maj, min;
- char *fstype = NULL, *src = NULL, *p;
-
-+#ifndef HAVE_SCANF_MS_MODIFIER
-+ size_t len = strlen(s) + 1;
-+ fs->root = malloc(len);
-+ fs->target = malloc(len);
-+ fs->vfs_optstr = malloc(len);
-+ fs->fs_optstr = malloc(len);
-+ fstype = malloc(len);
-+ src = malloc(len);
-+#endif
-+
- rc = sscanf(s, "%u " /* (1) id */
- "%u " /* (2) parent */
- "%u:%u " /* (3) maj:min */
-@@ -147,9 +176,15 @@ static int mnt_parse_mountinfo_line(stru
- &fs->id,
- &fs->parent,
- &maj, &min,
-+#ifdef HAVE_SCANF_MS_MODIFIER
- &fs->root,
- &fs->target,
- &fs->vfs_optstr,
-+#else
-+ fs->root,
-+ fs->target,
-+ fs->vfs_optstr,
-+#endif
- &end);
-
- if (rc >= 7 && end > 0)
-@@ -167,9 +202,15 @@ static int mnt_parse_mountinfo_line(stru
- UL_SCNsA" " /* (9) source */
- UL_SCNsA, /* (10) fs options (fs specific) */
-
-+#ifdef HAVE_SCANF_MS_MODIFIER
- &fstype,
- &src,
- &fs->fs_optstr);
-+#else
-+ fstype,
-+ src,
-+ fs->fs_optstr);
-+#endif
-
- if (rc >= 10) {
- fs->flags |= MNT_FS_KERNEL;
diff --git a/package/system/utils/util-linux/patches/002-fix-endianess.patch b/package/system/utils/util-linux/patches/002-fix-endianess.patch
deleted file mode 100644
index 4c59932cda..0000000000
--- a/package/system/utils/util-linux/patches/002-fix-endianess.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Index: util-linux-2.21.2/libblkid/src/superblocks/swap.c
-===================================================================
---- util-linux-2.21.2.orig/libblkid/src/superblocks/swap.c 2012-05-15 13:51:45.814410455 +0200
-+++ util-linux-2.21.2/libblkid/src/superblocks/swap.c 2013-06-12 23:23:03.270742199 +0200
-@@ -48,7 +48,7 @@
-
- /* SWAPSPACE2 - check for wrong version or zeroed pagecount */
- if (strcmp(version, "2") == 0 &&
-- (hdr->version != 1 || hdr->lastpage == 0))
-+ ((hdr->version != 1 && swab32(hdr->version) != 1) || hdr->lastpage == 0))
- return -1;
-
- /* arbitrary sanity check.. is there any garbage down there? */
diff --git a/package/system/utils/xfsprogs/Makefile b/package/system/utils/xfsprogs/Makefile
deleted file mode 100644
index a7a865a0eb..0000000000
--- a/package/system/utils/xfsprogs/Makefile
+++ /dev/null
@@ -1,87 +0,0 @@
-#
-# Copyright (C) 2006-2012 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:=xfsprogs
-PKG_RELEASE:=1
-PKG_VERSION:=3.1.7
-PKG_SOURCE_URL:=ftp://oss.sgi.com/projects/xfs/previous/
-PKG_MD5SUM:=049cf9873794ea49d0bb3f12d45748a4
-
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_INSTALL:=1
-PKG_FIXUP:=autoreconf
-
-include $(INCLUDE_DIR)/package.mk
-include $(INCLUDE_DIR)/nls.mk
-
-define Package/xfsprogs/default
- SECTION:=utils
- CATEGORY:=Utilities
- DEPENDS:=+libuuid +libpthread +librt
- URL:=http://oss.sgi.com/projects/xfs
-endef
-
-define Package/xfs-mkfs
-$(call Package/xfsprogs/default)
- TITLE:=Utility for creating XFS filesystems
-endef
-
-define Package/xfs-fsck
-$(call Package/xfsprogs/default)
- TITLE:=Utilities for checking and repairing XFS filesystems
-endef
-
-define Package/xfs-growfs
-$(call Package/xfsprogs/default)
- TITLE:=Utility for increasing the size of XFS filesystems
-endef
-
-CONFIGURE_ARGS += \
- --enable-gettext=no \
- --enable-lib64=no
-
-TARGET_CFLAGS += \
- -I$(STAGING_DIR)/usr/include \
- -D_LARGEFILE64_SOURCE \
- -D_FILE_OFFSET_BITS=64 \
- -D_GNU_SOURCE
-
-MAKE_FLAGS += \
- DEBUG= Q= \
- PCFLAGS="-Wall" \
- PKG_PLATFORM=linux \
- ENABLE_GETTEXT=no \
- prefix=$(PKG_INSTALL_DIR)/usr \
- exec_prefix=$(PKG_INSTALL_DIR)/usr \
- PKG_SBIN_DIR=$(PKG_INSTALL_DIR)/usr/sbin \
- PKG_ROOT_SBIN_DIR=$(PKG_INSTALL_DIR)/sbin \
- PKG_MAN_DIR=$(PKG_INSTALL_DIR)/usr/man \
- PKG_LOCALE_DIR=$(PKG_INSTALL_DIR)/usr/share/locale \
- PKG_ROOT_LIB_DIR=$(PKG_INSTALL_DIR)/lib \
- PKG_DOC_DIR=$(PKG_INSTALL_DIR)/usr/share/doc/xfsprogs
-
-define Package/xfs-mkfs/install
- mkdir -p $(1)/sbin
- $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/mkfs.xfs $(1)/sbin
-endef
-
-define Package/xfs-fsck/install
- mkdir -p $(1)/sbin
- $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/xfs_repair $(1)/sbin
- $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xfs_db $(1)/sbin
-endef
-
-define Package/xfs-growfs/install
- mkdir -p $(1)/sbin
- $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xfs_growfs $(1)/sbin
-endef
-
-$(eval $(call BuildPackage,xfs-mkfs))
-$(eval $(call BuildPackage,xfs-fsck))
-$(eval $(call BuildPackage,xfs-growfs))
diff --git a/package/system/utils/xfsprogs/patches/001-automake-compat.patch b/package/system/utils/xfsprogs/patches/001-automake-compat.patch
deleted file mode 100644
index 3003d6d210..0000000000
--- a/package/system/utils/xfsprogs/patches/001-automake-compat.patch
+++ /dev/null
@@ -1,84 +0,0 @@
-commit 2222aa77e11b959e0e5a0ded3482e56799593bc2
-Author: Jens Muecke <jens@nons.de>
-Date: Thu Jan 26 00:34:15 2012 +0100
-
- 001-automake-compat
-
-diff --git a/configure.in b/configure.in
-index 664c0e9..d91b6ec 100644
---- a/configure.in
-+++ b/configure.in
-@@ -2,7 +2,8 @@ AC_INIT(include/libxfs.h)
- AC_PREREQ(2.50)
- AC_CONFIG_AUX_DIR([.])
- AC_CONFIG_MACRO_DIR([m4])
--AC_CONFIG_HEADER(include/platform_defs.h)
-+# Put a dummy here (http://www.mail-archive.com/automake@gnu.org/msg09241.html)
-+AC_CONFIG_HEADERS([doesnotexist.h include/platform_defs.h])
- AC_PREFIX_DEFAULT(/usr)
-
- AC_PROG_LIBTOOL
-diff --git a/include/builddefs.in b/include/builddefs.in
-index 81ebfcd..5a4a0e8 100644
---- a/include/builddefs.in
-+++ b/include/builddefs.in
-@@ -20,6 +20,8 @@
- ifndef _BUILDDEFS_INCLUDED_
- _BUILDDEFS_INCLUDED_ = 1
-
-+SHELL = @SHELL@
-+
- DEBUG = @debug_build@
- OPTIMIZER = @opt_build@
- MALLOCLIB = @malloc_lib@
-diff --git a/m4/package_types.m4 b/m4/package_types.m4
-index 0a0e087..66a136a 100644
---- a/m4/package_types.m4
-+++ b/m4/package_types.m4
-@@ -9,7 +9,7 @@ AC_DEFUN([AC_TYPE_PSINT],
- #include <stddef.h>
- ], [
- __psint_t psint;
-- ], AC_DEFINE(HAVE___PSINT_T) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
-+ ], AC_DEFINE([HAVE___PSINT_T], [1], [Define if __psint_t exists]) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
- ])
-
- #
-@@ -23,7 +23,7 @@ AC_DEFUN([AC_TYPE_PSUNSIGNED],
- #include <stddef.h>
- ], [
- __psunsigned_t psuint;
-- ], AC_DEFINE(HAVE___PSUNSIGNED_T) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
-+ ], AC_DEFINE([HAVE___PSUNSIGNED_T], [1], [Define if __psunsigned_t exists]) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
- ])
-
- #
-@@ -37,7 +37,7 @@ AC_DEFUN([AC_TYPE_U32],
- #include <stddef.h>
- ], [
- __u32 u32;
-- ], AC_DEFINE(HAVE___U32) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
-+ ], AC_DEFINE([HAVE___U32], [1], [Define if __u32 exists]) AC_MSG_RESULT(yes) , AC_MSG_RESULT(no))
- ])
-
- #
-@@ -50,15 +50,15 @@ AC_DEFUN([AC_SIZEOF_POINTERS_AND_LONG],
- AC_CHECK_SIZEOF(long, 4)
- AC_CHECK_SIZEOF(char *, 4)
- if test $ac_cv_sizeof_long -eq 4 -o $ac_cv_sizeof_long -eq 0; then
-- AC_DEFINE(HAVE_32BIT_LONG)
-+ AC_DEFINE([HAVE_32BIT_LONG], [1], [Define if long is 32bit])
- fi
- if test $ac_cv_sizeof_long -eq 8; then
-- AC_DEFINE(HAVE_64BIT_LONG)
-+ AC_DEFINE([HAVE_64BIT_LONG], [1], [Define if long is 64bit])
- fi
- if test $ac_cv_sizeof_char_p -eq 4 -o $ac_cv_sizeof_char_p -eq 0; then
-- AC_DEFINE(HAVE_32BIT_PTR)
-+ AC_DEFINE([HAVE_32BIT_PTR], [1], [Define if char* is 32bit])
- fi
- if test $ac_cv_sizeof_char_p -eq 8; then
-- AC_DEFINE(HAVE_64BIT_PTR)
-+ AC_DEFINE([HAVE_64BIT_PTR], [1], [Define if char* is 64bit])
- fi
- ])
diff --git a/package/system/utils/xfsprogs/patches/100-no_aio.patch b/package/system/utils/xfsprogs/patches/100-no_aio.patch
deleted file mode 100644
index 30d36b4da8..0000000000
--- a/package/system/utils/xfsprogs/patches/100-no_aio.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-commit e72b7bd12fdef06c3494b919376bfe886aa8bb4d
-Author: Jens Muecke <jens@nons.de>
-Date: Thu Jan 26 00:35:43 2012 +0100
-
- 100-no_aio
-
-diff --git a/configure.in b/configure.in
-index d91b6ec..8dc8b4a 100644
---- a/configure.in
-+++ b/configure.in
-@@ -92,8 +92,8 @@ AC_PACKAGE_GLOBALS(xfsprogs)
- AC_PACKAGE_UTILITIES(xfsprogs)
- AC_MULTILIB($enable_lib64)
-
--AC_PACKAGE_NEED_AIO_H
--AC_PACKAGE_NEED_LIO_LISTIO
-+librt="-lrt"
-+AC_SUBST(librt)
-
- AC_PACKAGE_NEED_UUID_H
- AC_PACKAGE_NEED_UUIDCOMPARE
diff --git a/package/system/utils/xfsprogs/patches/110-uclibc_no_ustat.patch b/package/system/utils/xfsprogs/patches/110-uclibc_no_ustat.patch
deleted file mode 100644
index c46e8025cd..0000000000
--- a/package/system/utils/xfsprogs/patches/110-uclibc_no_ustat.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-commit 7b1d0a98e779170232c0a81b4749ab934ec67a7e
-Author: Jens Muecke <jens@nons.de>
-Date: Thu Jan 26 00:36:42 2012 +0100
-
- 110-uclibc_no_ustat
-
-diff --git a/libxfs/linux.c b/libxfs/linux.c
-index 2e07d54..6a6c905 100644
---- a/libxfs/linux.c
-+++ b/libxfs/linux.c
-@@ -21,7 +21,9 @@
- #include <mntent.h>
- #include <sys/stat.h>
- #undef ustat
-+#ifndef __UCLIBC__
- #include <sys/ustat.h>
-+#endif
- #include <sys/mount.h>
- #include <sys/ioctl.h>
- #include <sys/sysinfo.h>
-@@ -49,6 +51,7 @@ static int max_block_alignment;
- int
- platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose)
- {
-+#ifndef __UCLIBC__
- /* Pad ust; pre-2.6.28 linux copies out too much in 32bit compat mode */
- struct ustat ust[2];
- struct stat64 st;
-@@ -68,6 +71,7 @@ platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose)
- progname, name);
- return 1;
- }
-+#endif
- return 0;
- }
-
diff --git a/package/system/utils/xfsprogs/patches/120-portability.patch b/package/system/utils/xfsprogs/patches/120-portability.patch
deleted file mode 100644
index 1e9b533654..0000000000
--- a/package/system/utils/xfsprogs/patches/120-portability.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-commit d2aef8b3967e53fe58178f5af50fef488ee0faed
-Author: Jens Muecke <jens@nons.de>
-Date: Thu Jan 26 00:37:52 2012 +0100
-
- 120-portability
-
-diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
-index c01e0b9..2e2f320 100644
---- a/copy/xfs_copy.c
-+++ b/copy/xfs_copy.c
-@@ -463,6 +463,15 @@ read_ag_header(int fd, xfs_agnumber_t agno, wbuf *buf, ag_header_t *ag,
- }
-
-
-+static void sig_mask(int type)
-+{
-+ sigset_t mask;
-+ sigemptyset(&mask);
-+ sigaddset(&mask, SIGCHLD);
-+ sigprocmask(type, &mask, NULL);
-+}
-+
-+
- void
- write_wbuf(void)
- {
-@@ -478,9 +487,9 @@ write_wbuf(void)
- if (target[i].state != INACTIVE)
- pthread_mutex_unlock(&targ[i].wait); /* wake up */
-
-- sigrelse(SIGCHLD);
-+ sig_mask(SIG_UNBLOCK);
- pthread_mutex_lock(&mainwait);
-- sighold(SIGCHLD);
-+ sig_mask(SIG_BLOCK);
- }
-
-
-@@ -847,7 +856,7 @@ main(int argc, char **argv)
- /* set up sigchild signal handler */
-
- signal(SIGCHLD, handler);
-- sighold(SIGCHLD);
-+ sig_mask(SIG_BLOCK);
-
- /* make children */
-
diff --git a/package/system/utils/xfsprogs/patches/130-uclibc_no_xattr.patch b/package/system/utils/xfsprogs/patches/130-uclibc_no_xattr.patch
deleted file mode 100644
index b1ecda71e5..0000000000
--- a/package/system/utils/xfsprogs/patches/130-uclibc_no_xattr.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-commit 10d6058b24f18cb31889154f830b191849f45106
-Author: Jens Muecke <jens@nons.de>
-Date: Thu Jan 26 00:38:27 2012 +0100
-
- 130-uclibc_no_xattr
-
-diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
-index 40c2e6f..4f54059 100644
---- a/fsr/xfs_fsr.c
-+++ b/fsr/xfs_fsr.c
-@@ -35,7 +35,9 @@
- #include <sys/wait.h>
- #include <sys/vfs.h>
- #include <sys/statvfs.h>
-+#ifndef __UCLIBC__
- #include <sys/xattr.h>
-+#endif
-
-
- #ifndef XFS_XFLAG_NODEFRAG
-@@ -990,6 +992,7 @@ fsr_setup_attr_fork(
- int tfd,
- xfs_bstat_t *bstatp)
- {
-+#ifndef __UCLIBC__
- struct stat64 tstatbuf;
- int i;
- int last_forkoff = 0;
-@@ -1108,6 +1111,7 @@ fsr_setup_attr_fork(
- out:
- if (dflag)
- fsrprintf(_("set temp attr\n"));
-+#endif
- return 0;
- }
-
diff --git a/package/system/utils/xfsprogs/patches/140-no_po.patch b/package/system/utils/xfsprogs/patches/140-no_po.patch
deleted file mode 100644
index f915a9cf27..0000000000
--- a/package/system/utils/xfsprogs/patches/140-no_po.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-diff -urN xfsprogs-3.1.7/Makefile xfsprogs-3.1.7.new/Makefile
---- xfsprogs-3.1.7/Makefile 2011-11-18 00:30:24.000000000 +0100
-+++ xfsprogs-3.1.7.new/Makefile 2012-04-20 14:15:48.641722955 +0200
-@@ -41,7 +41,7 @@
-
- LIB_SUBDIRS = libxfs libxlog libxcmd libhandle libdisk
- TOOL_SUBDIRS = copy db estimate fsck fsr growfs io logprint mkfs quota \
-- mdrestore repair rtcp m4 man doc po debian
-+ mdrestore repair rtcp m4 man doc debian
-
- SUBDIRS = include $(LIB_SUBDIRS) $(TOOL_SUBDIRS)
-
-@@ -135,7 +135,6 @@
- $(Q)$(MAKE) $(MAKEOPTS) -C . $@
- else
- $(Q)$(MAKE) $(MAKEOPTS) $(SRCDIR)
-- $(Q)$(MAKE) $(MAKEOPTS) -C po
- $(Q)$(MAKE) $(MAKEOPTS) source-link
- $(Q)cd $(SRCDIR) && dpkg-buildpackage
- endif
diff --git a/package/system/w1-gpio-custom/Makefile b/package/system/w1-gpio-custom/Makefile
deleted file mode 100644
index bf50d1a50f..0000000000
--- a/package/system/w1-gpio-custom/Makefile
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# Copyright (C) 2008-2012 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:=w1-gpio-custom
-PKG_RELEASE:=3
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/w1-gpio-custom
- SUBMENU:=W1 support
- TITLE:=Custom GPIO-based 1-wire device
- DEPENDS:=kmod-w1 +kmod-w1-master-gpio
- FILES:=$(PKG_BUILD_DIR)/w1-gpio-custom.ko
- KCONFIG:=
-endef
-
-define KernelPackage/w1-gpio-custom/description
- Kernel module to register a custom w1-gpio platform device.
-endef
-
-EXTRA_KCONFIG:= \
- CONFIG_W1_MASTER_GPIO_CUSTOM=m
-
-EXTRA_CFLAGS:= \
- $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
- $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG))))
-
-MAKE_OPTS:= \
- ARCH="$(LINUX_KARCH)" \
- CROSS_COMPILE="$(TARGET_CROSS)" \
- SUBDIRS="$(PKG_BUILD_DIR)" \
- EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
- $(EXTRA_KCONFIG)
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
- $(CP) ./src/* $(PKG_BUILD_DIR)/
-endef
-
-define Build/Compile
- $(MAKE) -C "$(LINUX_DIR)" \
- $(MAKE_OPTS) \
- modules
-endef
-
-$(eval $(call KernelPackage,w1-gpio-custom))
-
diff --git a/package/system/w1-gpio-custom/src/Kconfig b/package/system/w1-gpio-custom/src/Kconfig
deleted file mode 100644
index 74b9226c5c..0000000000
--- a/package/system/w1-gpio-custom/src/Kconfig
+++ /dev/null
@@ -1,4 +0,0 @@
-config W1_MASTER_GPIO_CUSTOM
- tristate "Custom GPIO-based W1 driver"
- depends on GENERIC_GPIO
- select W1_GPIO \ No newline at end of file
diff --git a/package/system/w1-gpio-custom/src/Makefile b/package/system/w1-gpio-custom/src/Makefile
deleted file mode 100644
index 6a527432c1..0000000000
--- a/package/system/w1-gpio-custom/src/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-${CONFIG_W1_MASTER_GPIO_CUSTOM} += w1-gpio-custom.o \ No newline at end of file
diff --git a/package/system/w1-gpio-custom/src/w1-gpio-custom.c b/package/system/w1-gpio-custom/src/w1-gpio-custom.c
deleted file mode 100644
index 96cfcabc61..0000000000
--- a/package/system/w1-gpio-custom/src/w1-gpio-custom.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Custom GPIO-based W1 driver
- *
- * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
- * Copyright (C) 2008 Bifferos <bifferos at yahoo.co.uk>
- *
- * 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.
- *
- * ---------------------------------------------------------------------------
- *
- * The behaviour of this driver can be altered by setting some parameters
- * from the insmod command line.
- *
- * The following parameters are adjustable:
- *
- * bus0 These four arguments must be arrays of
- * bus1 3 unsigned integers as follows:
- * bus2
- * bus3 <id>,<pin>,<od>
- *
- * where:
- *
- * <id> ID to used as device_id for the corresponding bus (required)
- * <sda> GPIO pin ID of data pin (required)
- * <od> Pin is configured as open drain.
- *
- * See include/w1-gpio.h for more information about the parameters.
- *
- * If this driver is built into the kernel, you can use the following kernel
- * command line parameters, with the same values as the corresponding module
- * parameters listed above:
- *
- * w1-gpio-custom.bus0
- * w1-gpio-custom.bus1
- * w1-gpio-custom.bus2
- * w1-gpio-custom.bus3
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-
-#include <linux/w1-gpio.h>
-
-#define DRV_NAME "w1-gpio-custom"
-#define DRV_DESC "Custom GPIO-based W1 driver"
-#define DRV_VERSION "0.1.1"
-
-#define PFX DRV_NAME ": "
-
-#define BUS_PARAM_ID 0
-#define BUS_PARAM_PIN 1
-#define BUS_PARAM_OD 2
-
-#define BUS_PARAM_REQUIRED 3
-#define BUS_PARAM_COUNT 3
-#define BUS_COUNT_MAX 4
-
-static unsigned int bus0[BUS_PARAM_COUNT] __initdata;
-static unsigned int bus1[BUS_PARAM_COUNT] __initdata;
-static unsigned int bus2[BUS_PARAM_COUNT] __initdata;
-static unsigned int bus3[BUS_PARAM_COUNT] __initdata;
-
-static unsigned int bus_nump[BUS_COUNT_MAX] __initdata;
-
-#define BUS_PARM_DESC " config -> id,pin,od"
-
-module_param_array(bus0, uint, &bus_nump[0], 0);
-MODULE_PARM_DESC(bus0, "bus0" BUS_PARM_DESC);
-module_param_array(bus1, uint, &bus_nump[1], 0);
-MODULE_PARM_DESC(bus1, "bus1" BUS_PARM_DESC);
-module_param_array(bus2, uint, &bus_nump[2], 0);
-MODULE_PARM_DESC(bus2, "bus2" BUS_PARM_DESC);
-module_param_array(bus3, uint, &bus_nump[3], 0);
-MODULE_PARM_DESC(bus3, "bus3" BUS_PARM_DESC);
-
-static struct platform_device *devices[BUS_COUNT_MAX];
-static unsigned int nr_devices;
-
-static void w1_gpio_custom_cleanup(void)
-{
- int i;
-
- for (i = 0; i < nr_devices; i++)
- if (devices[i])
- platform_device_put(devices[i]);
-}
-
-static int __init w1_gpio_custom_add_one(unsigned int id, unsigned int *params)
-{
- struct platform_device *pdev;
- struct w1_gpio_platform_data pdata;
- int err;
-
- if (!bus_nump[id])
- return 0;
-
- if (bus_nump[id] < BUS_PARAM_REQUIRED) {
- printk(KERN_ERR PFX "not enough parameters for bus%d\n", id);
- err = -EINVAL;
- goto err;
- }
-
- pdev = platform_device_alloc("w1-gpio", params[BUS_PARAM_ID]);
- if (!pdev) {
- err = -ENOMEM;
- goto err;
- }
-
- pdata.pin = params[BUS_PARAM_PIN];
- pdata.is_open_drain = params[BUS_PARAM_OD] ? 1:0;
- pdata.enable_external_pullup = NULL;
-
- err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
- if (err)
- goto err_put;
-
- err = platform_device_add(pdev);
- if (err)
- goto err_put;
-
- devices[nr_devices++] = pdev;
- return 0;
-
- err_put:
- platform_device_put(pdev);
- err:
- return err;
-}
-
-static int __init w1_gpio_custom_probe(void)
-{
- int err;
-
- nr_devices = 0;
- printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
-
- err = w1_gpio_custom_add_one(0, bus0);
- if (err) goto err;
-
- err = w1_gpio_custom_add_one(1, bus1);
- if (err) goto err;
-
- err = w1_gpio_custom_add_one(2, bus2);
- if (err) goto err;
-
- err = w1_gpio_custom_add_one(3, bus3);
- if (err) goto err;
-
- if (!nr_devices) {
- printk(KERN_ERR PFX "no bus parameter(s) specified\n");
- err = -ENODEV;
- goto err;
- }
-
- return 0;
-
-err:
- w1_gpio_custom_cleanup();
- return err;
-}
-
-#ifdef MODULE
-static int __init w1_gpio_custom_init(void)
-{
- return w1_gpio_custom_probe();
-}
-module_init(w1_gpio_custom_init);
-
-static void __exit w1_gpio_custom_exit(void)
-{
- w1_gpio_custom_cleanup();
-}
-module_exit(w1_gpio_custom_exit);
-#else
-subsys_initcall(w1_gpio_custom_probe);
-#endif /* MODULE*/
-
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("Bifferos <bifferos at yahoo.co.uk >");
-MODULE_DESCRIPTION(DRV_DESC);
-MODULE_VERSION(DRV_VERSION);
diff --git a/package/system/wrt55agv2-spidevs/Makefile b/package/system/wrt55agv2-spidevs/Makefile
deleted file mode 100644
index 236c9a3be3..0000000000
--- a/package/system/wrt55agv2-spidevs/Makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# Copyright (C) 2008 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-include $(INCLUDE_DIR)/kernel.mk
-
-PKG_NAME:=wrt55agv2-spidevs
-PKG_RELEASE:=1
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/wrt55agv2-spidevs
- SUBMENU:=Other modules
- TITLE:=WRT55AG v2 SPI devices support
- DEPENDS:=@TARGET_atheros +kmod-spi-gpio-old +kmod-spi-ks8995
- FILES:=$(PKG_BUILD_DIR)/wrt55agv2_spidevs.ko
-endef
-
-define KernelPackage/wrt55agv2-spidevs/description
- Kernel module for the SPI devices on the WRT55AG v2 board.
-endef
-
-EXTRA_KCONFIG:= \
- CONFIG_WRT55AGV2_SPIDEVS=m
-
-EXTRA_CFLAGS:= \
- $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
- $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
-
-MAKE_OPTS:= \
- ARCH="$(LINUX_KARCH)" \
- CROSS_COMPILE="$(TARGET_CROSS)" \
- SUBDIRS="$(PKG_BUILD_DIR)" \
- EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
- LINUXINCLUDE="-I$(LINUX_DIR)/include -I$(LINUX_DIR)/arch/mips/include -include generated/autoconf.h" \
- $(EXTRA_KCONFIG)
-
-define Build/Prepare
- mkdir -p $(PKG_BUILD_DIR)
- $(CP) ./src/* $(PKG_BUILD_DIR)/
-endef
-
-define Build/Compile
- $(MAKE) -C "$(LINUX_DIR)" \
- $(MAKE_OPTS) \
- modules
-endef
-
-$(eval $(call KernelPackage,wrt55agv2-spidevs))
diff --git a/package/system/wrt55agv2-spidevs/src/Kconfig b/package/system/wrt55agv2-spidevs/src/Kconfig
deleted file mode 100644
index 75e8242be7..0000000000
--- a/package/system/wrt55agv2-spidevs/src/Kconfig
+++ /dev/null
@@ -1,3 +0,0 @@
-config WRT55AGV2_SPIDEVS
- tristate "SPI device support for the WRT55AG v2 board"
- depends on SPI && MIPS_ATHEROS
diff --git a/package/system/wrt55agv2-spidevs/src/Makefile b/package/system/wrt55agv2-spidevs/src/Makefile
deleted file mode 100644
index 7f2ddb4e58..0000000000
--- a/package/system/wrt55agv2-spidevs/src/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-${CONFIG_WRT55AGV2_SPIDEVS} += wrt55agv2_spidevs.o \ No newline at end of file
diff --git a/package/system/wrt55agv2-spidevs/src/wrt55agv2_spidevs.c b/package/system/wrt55agv2-spidevs/src/wrt55agv2_spidevs.c
deleted file mode 100644
index dfb7f6abe7..0000000000
--- a/package/system/wrt55agv2-spidevs/src/wrt55agv2_spidevs.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * SPI driver for the Linksys WRT55AG v2 board.
- *
- * Copyright (C) 2008 Gabor Juhos <juhosg at openwrt.org>
- *
- * This file was based on the mmc_over_gpio driver:
- * Copyright 2008 Michael Buesch <mb@bu3sch.de>
- *
- * 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/platform_device.h>
-#include <linux/spi/spi_gpio_old.h>
-#include <linux/module.h>
-
-#define DRV_NAME "wrt55agv2-spidevs"
-#define DRV_DESC "SPI driver for the WRT55AG v2 board"
-#define DRV_VERSION "0.1.0"
-#define PFX DRV_NAME ": "
-
-#define GPIO_PIN_MISO 1
-#define GPIO_PIN_CS 2
-#define GPIO_PIN_CLK 3
-#define GPIO_PIN_MOSI 4
-
-static struct platform_device *spi_gpio_dev;
-
-static int __init boardinfo_setup(struct spi_board_info *bi,
- struct spi_master *master, void *data)
-{
-
- strlcpy(bi->modalias, "spi-ks8995", sizeof(bi->modalias));
-
- bi->max_speed_hz = 5000000 /* Hz */;
- bi->bus_num = master->bus_num;
- bi->mode = SPI_MODE_0;
-
- return 0;
-}
-
-static int __init wrt55agv2_spidevs_init(void)
-{
- struct spi_gpio_platform_data pdata;
- int err;
-
- spi_gpio_dev = platform_device_alloc("spi-gpio", 0);
- if (!spi_gpio_dev) {
- printk(KERN_ERR PFX "no memory for spi-gpio device\n");
- return -ENOMEM;
- }
-
- memset(&pdata, 0, sizeof(pdata));
- pdata.pin_miso = GPIO_PIN_MISO;
- pdata.pin_cs = GPIO_PIN_CS;
- pdata.pin_clk = GPIO_PIN_CLK;
- pdata.pin_mosi = GPIO_PIN_MOSI;
- pdata.cs_activelow = 1;
- pdata.no_spi_delay = 1;
- pdata.boardinfo_setup = boardinfo_setup;
- pdata.boardinfo_setup_data = NULL;
-
- err = platform_device_add_data(spi_gpio_dev, &pdata, sizeof(pdata));
- if (err)
- goto err_free_dev;
-
- err = platform_device_register(spi_gpio_dev);
- if (err) {
- printk(KERN_ERR PFX "unable to register device\n");
- goto err_free_pdata;
- }
-
- return 0;
-
-err_free_pdata:
- kfree(spi_gpio_dev->dev.platform_data);
- spi_gpio_dev->dev.platform_data = NULL;
-
-err_free_dev:
- platform_device_put(spi_gpio_dev);
- return err;
-}
-
-static void __exit wrt55agv2_spidevs_cleanup(void)
-{
- if (!spi_gpio_dev)
- return;
-
- platform_device_unregister(spi_gpio_dev);
-
- kfree(spi_gpio_dev->dev.platform_data);
- spi_gpio_dev->dev.platform_data = NULL;
- platform_device_put(spi_gpio_dev);
-}
-
-static int __init wrt55agv2_spidevs_modinit(void)
-{
- printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
- return wrt55agv2_spidevs_init();
-}
-module_init(wrt55agv2_spidevs_modinit);
-
-static void __exit wrt55agv2_spidevs_modexit(void)
-{
- wrt55agv2_spidevs_cleanup();
-}
-module_exit(wrt55agv2_spidevs_modexit);
-
-MODULE_DESCRIPTION(DRV_DESC);
-MODULE_VERSION(DRV_VERSION);
-MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
-MODULE_LICENSE("GPL v2");
-
diff --git a/package/system/zram-swap/Makefile b/package/system/zram-swap/Makefile
new file mode 100644
index 0000000000..bded5f3808
--- /dev/null
+++ b/package/system/zram-swap/Makefile
@@ -0,0 +1,46 @@
+#
+# 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:=zram-swap
+PKG_VERSION:=1
+PKG_RELEASE:=2
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/zram-swap
+ SECTION:=utils
+ CATEGORY:=Base system
+ DEPENDS:=+kmod-zram +!(BUSYBOX_CONFIG_MKSWAP&&BUSYBOX_CONFIG_SWAPONOFF):swap-utils
+ TITLE:=ZRAM swap scripts
+ PKGARCH:=all
+endef
+
+define Package/zram-swap/description
+ A script to activate swaping on a compressed zram partition. This
+ could be used to increase the available memory, by using compressed
+ memory.
+endef
+
+define Build/Prepare
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/zram-swap/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/zram.init $(1)/etc/init.d/zram
+endef
+
+$(eval $(call BuildPackage,zram-swap))
diff --git a/package/system/zram-swap/files/zram.init b/package/system/zram-swap/files/zram.init
new file mode 100644
index 0000000000..23de915c8f
--- /dev/null
+++ b/package/system/zram-swap/files/zram.init
@@ -0,0 +1,123 @@
+#!/bin/sh /etc/rc.common
+
+START=15
+
+ram_size()
+{
+ local line
+
+ while read line; do case "$line" in MemTotal:*) set $line; echo "$2"; break ;; esac; done </proc/meminfo
+}
+
+zram_size() # in megabytes
+{
+ local zram_size="$( uci -q get system.@system[0].zram_size_mb )"
+ local ram_size="$( ram_size )"
+
+ if [ -z "$zram_size" ]; then
+ # e.g. 6mb for 16mb-routers or 61mb for 128mb-routers
+ echo $(( $ram_size / 2048 ))
+ else
+ echo "$zram_size"
+ fi
+}
+
+zram_applicable()
+{
+ local zram_dev="$1"
+
+ grep -sq ^"$zram_dev " /proc/swaps && {
+ logger -s -t zram_applicable -p daemon.notice "[OK] '$zram_dev' already active"
+ return 1
+ }
+
+ [ -e "$zram_dev" ] || {
+ logger -s -t zram_applicable -p daemon.crit "[ERROR] device '$zram_dev' not found"
+ return 1
+ }
+
+ which mkswap >/dev/null || {
+ logger -s -t zram_applicable -p daemon.err "[ERROR] 'mkswap' not installed"
+ return 1
+ }
+
+ which swapon >/dev/null || {
+ logger -s -t zram_applicable -p daemon.err "[ERROR] 'swapon' not installed"
+ return 1
+ }
+
+ which swapoff >/dev/null || {
+ logger -s -t zram_applicable -p daemon.err "[ERROR] 'swapoff' not installed"
+ return 1
+ }
+}
+
+zram_dev()
+{
+ local core="$1"
+
+ echo "/dev/zram${core:-0}"
+}
+
+zram_reset()
+{
+ local dev="$1"
+ local message="$2"
+ local proc_entry="/sys/block/$( basename "$dev" )/reset"
+
+ logger -s -t zram_reset -p daemon.debug "$message via $proc_entry"
+ echo "1" >"$proc_entry"
+}
+
+list_cpu_idx()
+{
+ local line i=0
+
+ while read line; do {
+ case "$line" in
+ [Pp]rocessor*)
+ echo $i
+ i=$(( $i + 1 ))
+ ;;
+ esac
+ } done <"/proc/cpuinfo"
+}
+
+start()
+{
+ # http://shmilyxbq-compcache.googlecode.com/hg/README
+ # if >1 cpu_core, reinit kmodule with e.g. num_devices=4
+
+ local zram_size="$( zram_size )"
+ local zram_dev core
+
+ for core in $( list_cpu_idx ); do {
+ zram_dev="$( zram_dev "$core" )"
+ zram_applicable "$zram_dev" || return 1
+
+ logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)"
+
+ zram_reset "$zram_dev" "enforcing defaults"
+ echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename $zram_dev )/disksize"
+ mkswap "$zram_dev"
+ swapon "$zram_dev"
+ } done
+}
+
+stop()
+{
+ local zram_dev proc_entry
+
+ for core in $( list_cpu_idx ); do {
+ zram_dev="$( zram_dev "$core" )"
+ proc_entry="/sys/block/$( basename "$zram_dev" )/reset"
+
+ grep -sq ^"$zram_dev " /proc/swaps && {
+ logger -s -t zram_stop -p daemon.debug "deactivate swap $zram_dev"
+ swapoff "$zram_dev"
+ }
+
+ zram_reset "$zram_dev" "claiming memory back"
+ } done
+}
+