Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/raeth #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package/mtk-wifi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ define Package/mtk-wifi/install
$(CP) $(PKG_BUILD_DIR)/ap_client $(1)/sbin/
$(INSTALL_DIR) $(1)/lib/modules/$(LINUX_VERSION)/
$(CP) ./wifi_ko/mt_wifi.ko $(1)/lib/modules/$(LINUX_VERSION)/mt_wifi.ko
$(CP) ./eth_ko/raeth.ko $(1)/lib/modules/$(LINUX_VERSION)/raeth.ko
$(CP) ./files/* $(1)/
endef

Expand Down
Binary file added package/mtk-wifi/eth_ko/raeth.ko
Binary file not shown.
1 change: 1 addition & 0 deletions package/mtk-wifi/files/etc/modules.d/52-mt7628
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
raeth
mt_wifi
7 changes: 4 additions & 3 deletions package/network/config/netifd/files/etc/init.d/network
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ init_switch() {
}

start_service() {
init_switch

procd_open_instance
procd_set_param command /sbin/netifd
procd_set_param respawn
Expand All @@ -27,9 +25,10 @@ start_service() {
}

reload_service() {
init_switch
ubus call network reload
/sbin/wifi reload_legacy
sleep 3
init_switch
}

stop() {
Expand Down Expand Up @@ -144,6 +143,8 @@ restart() {
trap '' TERM
stop "$@"
start "$@"
sleep 3
init_switch
}

shutdown() {
Expand Down
56 changes: 56 additions & 0 deletions package/switch/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#
# Copyright (C) 2010-2013 hua.shao@mediatek.com
#
# MTK Property Software.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=switch
PKG_RELEASE:=1

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
PKG_KCONFIG:=RALINK_MT7620 RALINK_MT7621 RALINK_MT7628 RALINK_MT7688
PKG_CONFIG_DEPENDS:=$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),CONFIG_$(c)))


include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/kernel.mk

define Package/switch
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Command to config switch
SUBMENU:=Applications
endef

define Package/switch/description
An program to config switch.
endef

define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef

TARGET_CFLAGS += \
-DCONFIG_RALINK_MT7628 \
-I$(LINUX_DIR)/include \
-I$(LINUX_DIR)/drivers/net/raeth \
$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),-DCONFIG_$(c)=$(CONFIG_$(c))))

MAKE_FLAGS += \
$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),CONFIG_$(c)=$(CONFIG_$(c))))

define Build/Configure
endef

define Package/switch/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_DIR) $(1)/lib/network
$(INSTALL_BIN) $(PKG_BUILD_DIR)/switch $(1)/usr/bin
$(INSTALL_BIN) ./files/switch-7628.sh $(1)/lib/network/switch.sh
endef


$(eval $(call BuildPackage,switch))
97 changes: 97 additions & 0 deletions package/switch/files/switch-7628.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!bin/sh
restoreEsw()
{
switch reg w 14 5555
switch reg w 40 1001
switch reg w 44 1001
switch reg w 48 1001
switch reg w 4c 1
switch reg w 50 2001
switch reg w 70 ffffffff
switch reg w 98 7f7f
switch reg w e4 7f

#clear mac table if vlan configuration changed
switch clear
}
configEsw()
{
switch reg w 14 405555
switch reg w 50 2001
switch reg w 98 7f3f
if [ "$CONFIG_RAETH_SPECIAL_TAG" == "y" ]; then
switch reg w e4 40043f
else
switch reg w e4 3f
fi

if [ "$1" = "LLLLW" ]; then
if [ "$CONFIG_RAETH_SPECIAL_TAG" == "y" ]; then
switch reg w 40 7007
switch reg w 44 7007
switch reg w 48 7008
switch reg w 70 48444241
switch reg w 74 50ef6050
else
switch reg w 40 1001
switch reg w 44 1001
switch reg w 48 1002
switch reg w 70 ffff506f
fi
elif [ "$1" = "WLLLL" ]; then
if [ "$CONFIG_RAETH_SPECIAL_TAG" == "y" ]; then
switch reg w 40 7008
switch reg w 44 7007
switch reg w 48 7007
switch reg w 70 48444241
switch reg w 74 41fe6050
else
switch reg w 40 1002
switch reg w 44 1001
switch reg w 48 1001
switch reg w 70 ffff417e
fi
elif [ "$1" = "W1234" ]; then
switch reg w 40 1005
switch reg w 44 3002
switch reg w 48 1004
switch reg w 70 50484442
switch reg w 74 ffffff41
elif [ "$1" = "12345" ]; then
switch reg w 40 2001
switch reg w 44 4003
switch reg w 48 1005
switch reg w 70 48444241
switch reg w 74 ffffff50
elif [ "$1" = "GW" ]; then
switch reg w 40 1001
switch reg w 44 1001
switch reg w 48 2001
switch reg w 70 ffff605f
elif [ "$1" = "G01234" ]; then
switch reg w 40 2001
switch reg w 44 4003
switch reg w 48 6005
switch reg w 70 48444241
switch reg w 74 ffff6050
fi

#clear mac table if vlan configuration changed
switch clear
}

setup_switch()
{
has_vlan=`uci -q get network.wan.ifname`

restoreEsw

if [ ! -z $has_vlan ]; then
configEsw WLLLL
fi
}

reset_switch()
{
restoreEsw
}
180 changes: 180 additions & 0 deletions package/switch/files/switch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
#!/bin/sh

restore6855Esw()
{
echo "restore GSW to dump switch mode"
#port matrix mode
switch reg w 2004 ff0000 #port0
switch reg w 2104 ff0000 #port1
switch reg w 2204 ff0000 #port2
switch reg w 2304 ff0000 #port3
switch reg w 2404 ff0000 #port4
switch reg w 2504 ff0000 #port5
switch reg w 2604 ff0000 #port6
switch reg w 2704 ff0000 #port7

#LAN/WAN ports as transparent mode
switch reg w 2010 810000c0 #port0
switch reg w 2110 810000c0 #port1
switch reg w 2210 810000c0 #port2
switch reg w 2310 810000c0 #port3
switch reg w 2410 810000c0 #port4
switch reg w 2510 810000c0 #port5
switch reg w 2610 810000c0 #port6
switch reg w 2710 810000c0 #port7

#clear mac table if vlan configuration changed
switch clear
}

config6855Esw()
{
#LAN/WAN ports as security mode
switch reg w 2004 ff0003 #port0
switch reg w 2104 ff0003 #port1
switch reg w 2204 ff0003 #port2
switch reg w 2304 ff0003 #port3
switch reg w 2404 ff0003 #port4
switch reg w 2504 ff0003 #port5
#LAN/WAN ports as transparent port
switch reg w 2010 810000c0 #port0
switch reg w 2110 810000c0 #port1
switch reg w 2210 810000c0 #port2
switch reg w 2310 810000c0 #port3
switch reg w 2410 810000c0 #port4
switch reg w 2510 810000c0 #port5
#set CPU/P7 port as user port
switch reg w 2610 81000000 #port6
switch reg w 2710 81000000 #port7

switch reg w 2604 20ff0003 #port6, Egress VLAN Tag Attribution=tagged
switch reg w 2704 20ff0003 #port7, Egress VLAN Tag Attribution=tagged
if [ "$CONFIG_RAETH_SPECIAL_TAG" == "y" ]; then
echo "Special Tag Enabled"
switch reg w 2610 81000020 #port6

else
echo "Special Tag Disabled"
switch reg w 2610 81000000 #port6
fi

if [ "$1" = "LLLLW" ]; then
if [ "$CONFIG_RAETH_SPECIAL_TAG" == "y" ]; then
#set PVID
switch reg w 2014 10007 #port0
switch reg w 2114 10007 #port1
switch reg w 2214 10007 #port2
switch reg w 2314 10007 #port3
switch reg w 2414 10008 #port4
switch reg w 2514 10007 #port5
#VLAN member port
switch vlan set 0 1 10000011
switch vlan set 1 2 01000011
switch vlan set 2 3 00100011
switch vlan set 3 4 00010011
switch vlan set 4 5 00001011
switch vlan set 5 6 00000111
switch vlan set 6 7 11110111
switch vlan set 7 8 00001011
else
#set PVID
switch reg w 2014 10001 #port0
switch reg w 2114 10001 #port1
switch reg w 2214 10001 #port2
switch reg w 2314 10001 #port3
switch reg w 2414 10002 #port4
switch reg w 2514 10001 #port5
#VLAN member port
switch vlan set 0 1 11110111
switch vlan set 1 2 00001011
fi
elif [ "$1" = "WLLLL" ]; then
if [ "$CONFIG_RAETH_SPECIAL_TAG" == "y" ]; then
#set PVID
switch reg w 2014 10008 #port0
switch reg w 2114 10007 #port1
switch reg w 2214 10007 #port2
switch reg w 2314 10007 #port3
switch reg w 2414 10007 #port4
switch reg w 2514 10007 #port5
#VLAN member port
switch vlan set 4 5 10000011
switch vlan set 0 1 01000011
switch vlan set 1 2 00100011
switch vlan set 2 3 00010011
switch vlan set 3 4 00001011
switch vlan set 5 6 00000111
switch vlan set 6 7 01111111
switch vlan set 7 8 10000011
else
#set PVID
switch reg w 2014 10002 #port0
switch reg w 2114 10001 #port1
switch reg w 2214 10001 #port2
switch reg w 2314 10001 #port3
switch reg w 2414 10001 #port4
switch reg w 2514 10001 #port5
#VLAN member port
switch vlan set 0 1 01111111
switch vlan set 1 2 10000011
fi
elif [ "$1" = "W1234" ]; then
echo "W1234"
#set PVID
switch reg w 2014 10005 #port0
switch reg w 2114 10001 #port1
switch reg w 2214 10002 #port2
switch reg w 2314 10003 #port3
switch reg w 2414 10004 #port4
switch reg w 2514 10006 #port5
#VLAN member port
switch vlan set 4 5 10000011
switch vlan set 0 1 01000011
switch vlan set 1 2 00100011
switch vlan set 2 3 00010011
switch vlan set 3 4 00001011
switch vlan set 5 6 00000111
elif [ "$1" = "12345" ]; then
echo "12345"
#set PVID
switch reg w 2014 10001 #port0
switch reg w 2114 10002 #port1
switch reg w 2214 10003 #port2
switch reg w 2314 10004 #port3
switch reg w 2414 10005 #port4
switch reg w 2514 10006 #port5
#VLAN member port
switch vlan set 0 1 10000011
switch vlan set 1 2 01000011
switch vlan set 2 3 00100011
switch vlan set 3 4 00010011
switch vlan set 4 5 00001011
switch vlan set 5 6 00000111
elif [ "$1" = "GW" ]; then
echo "GW"
#set PVID
switch reg w 2014 10001 #port0
switch reg w 2114 10001 #port1
switch reg w 2214 10001 #port2
switch reg w 2314 10001 #port3
switch reg w 2414 10001 #port4
switch reg w 2514 10002 #port5
#VLAN member port
switch vlan set 0 1 11111011
switch vlan set 1 2 00000111
fi

#clear mac table if vlan configuration changed
switch clear
}

# work for 7620 and 7621
setup_switch()
{
config6855Esw LLLLW
}

reset_switch()
{
restore6855Esw
}
Loading