This commit is contained in:
padavanonly 2024-01-15 17:19:15 +08:00
parent 9d436fa553
commit 56f31b1e02
24 changed files with 403 additions and 121 deletions

View File

@ -1,70 +1,94 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:64
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:87
msgid "Comment"
msgstr ""
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:28
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:40
msgid "Download speed (Mbit/s)"
msgstr ""
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:18
#: applications/luci-app-eqos/root/usr/share/luci/menu.d/luci-app-eqos.json:3
msgid "EQoS"
msgstr ""
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:24
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:43
msgid "Enable"
msgstr ""
msgid "Load balance"
msgstr ""
msgid "Please set a different gateway hop for each network interface before filling in the network interface name. Fill in PPPOE-WAN for dialing and eth1 for DHCP. Leaving it blank to disable it.Please use commas as interface name separators. Example: pppoe-wan,eth1"
msgstr ""
msgid "Enabling fair queue will automatically perform hardware offloading and forwarding for small packets, P2P downloads, and web browsing. After enabling, the maximum number available for IP speed limit will be limited to 25."
msgstr ""
#: applications/luci-app-eqos/root/usr/share/rpcd/acl.d/luci-app-eqos.json:3
msgid "Grant UCI access for luci-app-eqos"
msgstr ""
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:46
msgid "IPV4 address"
msgstr ""
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:19
msgid "Network speed control service."
msgstr ""
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:38
msgid "Speed limit and route choose based on IP address(using unique comment less than 32 will enable hardware QOS)"
msgstr ""
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:29
msgid "Total download bandwidth."
msgstr ""
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:34
msgid "Total upload bandwidth."
msgstr ""
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:33
msgid "Upload speed (Mbit/s)"
msgstr ""
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:56
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:79
msgid "Download speed (kbit/s)"
msgstr ""
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:60
msgid "Upload speed (kbit/s)"
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:18
#: package/mtk/applications/luci-app-eqos-mtk/root/usr/share/luci/menu.d/luci-app-eqos.json:3
msgid "EQoS"
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:23
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:57
msgid "Enable"
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:36
msgid ""
"Enabling fair queue will automatically perform hardware offloading and "
"forwarding for small packets, P2P downloads, and web browsing. After "
"enabling, the maximum number available for IP speed limit will be limited to "
"25."
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/root/usr/share/rpcd/acl.d/luci-app-eqos.json:3
msgid "Grant UCI access for luci-app-eqos"
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:60
msgid "IPV4 address"
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:71
msgid "IPV6 host"
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:31
msgid "IPV6Enable"
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:91
msgid "InterfaceName(start from 0)"
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:27
msgid "Load balance"
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:19
msgid "Network speed control service.(Compatiable with Mediatek HNAT)"
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:28
msgid ""
"Please set a different gateway hop for each network interface before filling "
"in the network interface name. Fill in PPPOE-WAN for dialing and eth1 for "
"DHCP. Leaving it blank to disable it.Please use commas as interface name "
"separators. Example: pppoe-wan,eth1"
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:35
msgid "SMART_HWQOS"
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:52
msgid ""
"Speed limit and route choose based on IP address(using unique comment less "
"than 32 will enable hardware QOS)"
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:41
msgid "Total download bandwidth."
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:46
msgid "Total upload bandwidth."
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:45
msgid "Upload speed (Mbit/s)"
msgstr ""
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:83
msgid "Upload speed (kbit/s)"
msgstr ""

View File

@ -2008,8 +2008,8 @@ return view.extend({
s.handleRemove = function(section_id, radioNet, ev) {
var radioName = radioNet.getWifiDeviceName();
var hwtype = uci.get('wireless', radioName, 'type');
if (hwtype == 'mtwifi')
var ifmode = radioNet.getMode();
if (hwtype == 'mtwifi' && ifmode == 'ap')
{
var wifi_sections = uci.sections('wireless', 'wifi-iface');
var mbssid_num = 0;

View File

@ -244,8 +244,21 @@ return view.extend({
o.rmempty = false;
o.value(1);
o.value(2);
o.default = 1;
o.default = 2;
o.depends('fastpath_mh_eth_hnat', '1');
o = s.option(form.ListValue, 'fastpath_mh_eth_hnat_ppe_entrynum', _('Number of HNAT PPE Entry'),
_('Apply this setting after reboot.'));
o.rmempty = false;
o.value(32768);
o.value(16384);
o.value(8192);
o.value(4096);
o.value(2048);
o.value(1024);
o.default = 16384;
o.depends('fastpath_mh_eth_hnat', '1');
o = s.option(form.ListValue, 'fullcone', _('Full cone NAT'),
_('Full cone NAT (NAT1) can improve gaming performance effectively.'));

View File

@ -197,3 +197,7 @@ msgstr "HNAT PPE数量"
msgid "Bind Entrys"
msgstr "已绑定连接数"
msgid "Number of HNAT PPE Entry"
msgstr "HNAT PPE条目数量"

View File

@ -22,7 +22,7 @@ if [ -e "/lib/modules/$kernel_ver/mtkhnat.ko" ]; then
uci -q set "turboacc.config.fastpath_mh_eth_hnat_bind_rate"="30"
local mem="$(awk '/^MemTotal:/ {print $2}' /proc/meminfo)"
if [ "$mem" -gt 262144 ]; then
uci -q set "turboacc.config.fastpath_mh_eth_hnat_ppenum"="2"
uci -q set "turboacc.config.fastpath_mh_eth_hnat_ppeentrynum"="32768"
fi
elif [ -e "/lib/modules/$kernel_ver/fast-classifier.ko" ]; then
uci -q set "turboacc.config.fastpath"="fast_classifier"

View File

@ -170,7 +170,7 @@ function handleConfig(ev) {
arglist = [
[ui.Select, _('Default Protocol'), {'ipv4': _('ipv4'), 'ipv6': _('ipv6')}, {}, ''],
[ui.Select, _('Default Refresh Interval'), {'-1': _('Disabled'), '2': _('2 seconds'), '5': _('5 seconds'), '10': _('10 seconds'), '30': _('30 seconds')}, {sort: ['-1', '2', '5', '10', '30']}, ''],
[ui.Select, _('Default Refresh Interval'), {'-1': _('Disabled'), '3': _('3 seconds'), '5': _('5 seconds'), '10': _('10 seconds'), '30': _('30 seconds')}, {sort: ['-1', '3', '5', '10', '30']}, ''],
[ui.Dropdown, _('Default Columns'), columns, {multiple: true, sort: false, custom_placeholder: '', dropdown_items: 3}, ''],
[ui.Checkbox, _('Show Zeros'), {value_enabled: true, value_disabled: false}, ''],
[ui.Checkbox, _('Transfer Speed in Bits'), {value_enabled: true, value_disabled: false}, ''],
@ -601,7 +601,7 @@ return view.extend({
'change': clickToSelectInterval.bind(this, settings, labelUpdating)
}, initOption({
'-1': _('Disabled'),
'2': _('2 seconds'),
'3': _('3 seconds'),
'5': _('5 seconds'),
'10': _('10 seconds'),
'30': _('30 seconds')

View File

@ -8,8 +8,8 @@ msgstr "10秒"
#: htdocs/luci-static/resources/view/wrtbwmon/details.js:177
#: htdocs/luci-static/resources/view/wrtbwmon/details.js:609
msgid "2 seconds"
msgstr "2秒"
msgid "3 seconds"
msgstr "3秒"
#: htdocs/luci-static/resources/view/wrtbwmon/details.js:177
#: htdocs/luci-static/resources/view/wrtbwmon/details.js:612

View File

@ -0,0 +1,30 @@
#
# This is free software, licensed under the GNU General Public License v2.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=mtk-smp
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
define Package/mtk-smp
SECTION:=MTK Properties
CATEGORY:=MTK Properties
TITLE:=Setup mtk smp settings
SUBMENU:=Applications
endef
define Build/Compile
endef
define Package/mtk-smp/install
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/smp.sh $(1)/sbin/
$(INSTALL_BIN) ./files/mtk_smp.init $(1)/etc/init.d/mtk_smp
endef
$(eval $(call BuildPackage,mtk-smp))

View File

@ -0,0 +1,8 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
start_service() {
/sbin/smp.sh
}

View File

@ -34,6 +34,7 @@ MT7986_whnat()
PCIe0=
eth_tx=229
eth_rx0=230
usb=205
if [ -d "/proc/warp_ctrl/warp0" ]; then
wifi1_irq=237
wifi2_irq=237
@ -51,7 +52,7 @@ MT7986_whnat()
if [ "$num_of_wifi" = "0" ]; then
CPU0_AFFINITY="$eth_rx0"
CPU1_AFFINITY="$eth_tx"
CPU2_AFFINITY=""
CPU2_AFFINITY="$usb"
CPU3_AFFINITY=""
CPU0_RPS=""
@ -61,7 +62,7 @@ MT7986_whnat()
elif [ "$num_of_wifi" = "1" ]; then
CPU0_AFFINITY="$eth_rx0"
CPU1_AFFINITY="$eth_tx"
CPU2_AFFINITY=""
CPU2_AFFINITY="$usb"
CPU3_AFFINITY="$wifi1_irq"
CPU0_RPS=" $wifi1 $wifi1_apcli0"
@ -71,7 +72,7 @@ MT7986_whnat()
elif [ "$num_of_wifi" = "2" ]; then
CPU0_AFFINITY="$eth_rx0"
CPU1_AFFINITY="$eth_tx"
CPU2_AFFINITY=""
CPU2_AFFINITY="$usb"
CPU3_AFFINITY="$wifi1_irq $wifi2_irq"
CPU0_RPS=" $wifi1 $wifi2 $wifi1_apcli0 $wifi2_apcli0"
@ -81,7 +82,7 @@ MT7986_whnat()
elif [ "$num_of_wifi" = "3" ]; then
CPU0_AFFINITY="$eth_tx $eth_rx0"
CPU1_AFFINITY="$wifi1_irq $wifi2_irq"
CPU2_AFFINITY="$PCIe0 $wifi3_irq"
CPU2_AFFINITY="$PCIe0 $wifi3_irq $usb"
CPU3_AFFINITY=""
CPU0_RPS=""
@ -203,13 +204,14 @@ MT7986_dbdc1()
MT7981_whnat()
{
num_of_wifi=$1
storage=$2
is_usbnet=$2
DEFAULT_RPS=0
#Physical IRQ# setting
PCIe0=
eth_tx=229
eth_rx0=230
usb=205
if [ -d "/proc/warp_ctrl/warp0" ]; then
wifi1_irq=237
wifi2_irq=237
@ -226,25 +228,26 @@ MT7981_whnat()
dbg "[MT7981_whnat]"
if [ "$num_of_wifi" = "0" ]; then
CPU0_AFFINITY="$eth_rx0"
CPU1_AFFINITY="$eth_tx"
CPU1_AFFINITY="$eth_tx $usb"
CPU0_RPS=""
CPU1_RPS="$ethif1 $ethif2"
elif [ "$num_of_wifi" = "1" ]; then
CPU0_AFFINITY="$eth_tx $eth_rx0"
CPU1_AFFINITY="$wifi1_irq"
CPU1_AFFINITY="$wifi1_irq $usb"
CPU0_RPS="$ethif1 $ethif2 $wifi1 $wifi1_apcli0"
CPU1_RPS=" $wifi1 $wifi1_apcli0"
elif [ "$num_of_wifi" = "2" ]; then
CPU0_AFFINITY="$eth_tx $eth_rx0"
CPU1_AFFINITY="$wifi1_irq $wifi2_irq"
CPU1_AFFINITY="$wifi1_irq $wifi2_irq $usb"
CPU0_RPS="$ethif1 $ethif2 $wifi1 $wifi2 $wifi1_apcli0 $wifi2_apcli0"
CPU1_RPS=" $wifi1 $wifi2 $wifi1_apcli0 $wifi2_apcli0"
[ "$is_usbnet" = "1" ] && CPU1_RPS="$wifi1_apcli0 $wifi2_apcli0"
elif [ "$num_of_wifi" = "3" ]; then
CPU0_AFFINITY="$eth_tx $eth_rx0"
CPU1_AFFINITY="$PCIe0 $wifi1_irq $wifi2_irq $wifi3_irq"
CPU1_AFFINITY="$PCIe0 $wifi1_irq $wifi2_irq $wifi3_irq $usb"
CPU0_RPS="$ethif1 $ethif2 $wifi1 $wifi2 $wifi3 $wifi1_apcli0 $wifi2_apcli0 $wifi3_apcli0"
CPU1_RPS=" $wifi1 $wifi2 $wifi3 $wifi1_apcli0 $wifi2_apcli0 $wifi3_apcli0"
@ -667,6 +670,24 @@ scan_wifi_num()
dbg "# NUM_OF_WIFI=$NUM_OF_WIFI band(s)"
}
scan_usbnet()
{
for dev in /sys/class/net/*; do
[ -d "$dev" ] || continue
dev_name=$(basename $dev)
dev_prefix="${dev_name%%[0-9]*}"
if [ "$dev_prefix" = "usb" ] || [ "$dev_prefix" = "wwan" ]; then
IS_USBNET=1
return
fi
done
}
get_usbnet()
{
echo $IS_USBNET
}
get_wifi_num()
{
echo $NUM_OF_WIFI
@ -707,17 +728,19 @@ setup_model()
board=$(board_name)
num_of_wifi=$(get_wifi_num)
mt_whnat_en=$(module_exist "mt_whnat")
usbnet=$(get_usbnet)
logger -t "mtk_smp" "board=${board}, wifi_num=${num_of_wifi}, cpu_num=${NUM_OF_CPU}, usbnet=${usbnet}"
case $board in
xiaomi,redmi-router-ax6000* |\
bananapi,bpi-r3mini* |\
netcore,n60 |\
ruijie,rg-x60-pro*|\
glinet,gl-mt6000|\
jdcloud,re-cp-03 |\
tplink,tl-xdr608* |\
*7986*)
MT7986_whnat $num_of_wifi
MT7986_whnat $num_of_wifi $usbnet
;;
*mt3000* |\
glinet,x3000-emmc |\
@ -735,7 +758,7 @@ setup_model()
konka,komi-a31 |\
nradio,wt9103 |\
*7981*)
MT7981_whnat $num_of_wifi
MT7981_whnat $num_of_wifi $usbnet
;;
*)
if [ "$NUM_OF_CPU" = "4" ]; then
@ -827,7 +850,7 @@ set_smp_affinity()
cpu_bit=$((2 ** $num))
virq=$(get_virtual_irq $i)
dbg2 "irq p2v $i --> $virq"
if [ ! -z $virq ]; then
if [ ! -z $virq ] && [ -d /proc/irq/$virq ]; then
dbg "echo $cpu_bit > /proc/irq/$virq/smp_affinity"
echo $cpu_bit > /proc/irq/$virq/smp_affinity
fi
@ -870,6 +893,8 @@ RPS_IF_LIST="" # setup by getEthIfName/getWiFiIfName/every model
get_eth_if_name
get_wifi_if_name # It will add all wifi interfaces into $RPS_IF_LIST
dbg2 "# default RPS_IF_LIST=$RPS_IF_LIST"
IS_USBNET=0
scan_usbnet
setup_model
set_rps_cpu_bitmap
set_rps_cpus $DEFAULT_RPS

View File

@ -41,7 +41,6 @@ echo 0 > /proc/sys/net/bridge/bridge-nf-filter-vlan-tagged
echo 0 > /proc/sys/net/bridge/bridge-nf-pass-vlan-input-dev
echo 1035876 >/proc/sys/net/core/rmem_max
echo 1035876 >/proc/sys/net/core/wmem_max
if [ ! -d $hqos_path ]; then
modprobe mtkhnat
if [ "$?" != "0" ]; then

View File

@ -38,9 +38,9 @@ define Package/mtwifi-cfg/install
$(INSTALL_BIN) ./files/mtwifi-cfg/mtwifi_defs.lua $(1)/usr/lib/lua/
$(INSTALL_BIN) ./files/mtwifi-cfg/mtwifi_utils.lua $(1)/usr/lib/lua/
$(INSTALL_BIN) ./files/l1util/l1util $(1)/sbin/
$(LN) l1util $(1)/sbin/l1dat
$(INSTALL_BIN) ./files/l1util/l1dat_parser.lua $(1)/usr/lib/lua/
$(INSTALL_DATA) ./files/hotplug/10-mtwifi-detect $(1)/etc/hotplug.d/net/
$(INSTALL_BIN) ./files/wapp/100-startwapp $(1)/etc/hotplug.d/iface/
$(INSTALL_BIN) ./files/wapp/startwapp.sh $(1)/sbin/
$(INSTALL_BIN) ./files/wapp/bs20 $(1)/sbin/

View File

@ -98,6 +98,36 @@ function l1dat_parser.l1_ifname_to_datpath(ifname)
return devs[ridx][ifname] and devs[ridx][ifname].profile_path
end
function l1dat_parser.l1_ifname_to_zone(ifname)
if not ifname then return end
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
if not devs then return end
local ridx = l1dat_parser.IF_RINDEX
return devs[ridx][ifname] and devs[ridx][ifname].nvram_zone
end
function l1dat_parser.l1_zone_to_ifname(zone)
if not zone then return end
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
if not devs then return end
local zone_dev
for _, dev in pairs(devs[l1dat_parser.DEV_RINDEX]) do
if dev.nvram_zone == zone then
zone_dev = dev
end
end
if not zone_dev then
return nil
else
return zone_dev.main_ifname, zone_dev.ext_ifname, zone_dev.apcli_ifname, zone_dev.wds_ifname, zone_dev.mesh_ifname
end
end
-- input: L1 profile path.
-- output A table, devs, contains
-- 1. devs[%d] = table of each INDEX# in the L1 profile

View File

@ -21,6 +21,10 @@ if not l1dat then
return
end
function show_usage()
print("Usage: l1util list | get <dev> <prop> | idx2if <idx> | if2zone <ifname> | if2dat <ifname> | zone2if <zone> | if2dbdcidx <ifname>")
end
function show_devs()
local ret = ""
for k, _ in pairs(l1dat.devname_ridx) do
@ -46,11 +50,82 @@ local action = {
["get"] = function(dev, prop)
get_dev_prop(dev, prop)
end
end,
["if2zone"] = function(ifname)
if not ifname then return end
local zone = l1parser.l1_ifname_to_zone(ifname) or ""
print(zone);
end,
["if2dat"] = function(ifname)
if not ifname then return end
local dat_path = l1parser.l1_ifname_to_datpath(ifname) or ""
print(dat_path)
end,
["zone2if"] = function(zone)
if not zone then return end
local main_if, ext_if, apcli, wds, mesh = l1parser.l1_zone_to_ifname(zone)
if main_if then
print(main_if.." "..ext_if.." "..apcli.." "..wds.." "..mesh)
end
end,
["idx2if"] = function(idx)
if not idx then return end
idx = tonumber(idx)
local band_num = l1parser.MAX_NUM_DBDC_BAND
local dbdc_if
local count = 0
for k, v in pairs(l1dat) do
-- check if last dbdc exists
dbdc_if = l1parser.token_get(v.main_ifname, band_num, nil)
if dbdc_if then
count = count + band_num;
else
count = count + 1
end
if not dbdc_if and count == idx then
print(v.main_ifname)
break
end
if count >= idx then -- dbdc case
local token_num = band_num - ( count - idx )
print(l1parser.token_get(v.main_ifname, token_num, nil))
break
end
end
end,
["if2dbdcidx"] = function(ifname)
if not ifname then return end
local ridx = l1parser.IF_RINDEX
if not l1dat[ridx][ifname] then return end
print(l1dat[ridx][ifname]["subidx"] or "0")
end,
}
if #arg == 1 then
if #arg == 0 then
show_usage()
elseif #arg == 1 then
action[arg[1]]()
elseif #arg == 2 then
action[arg[1]](arg[2])
elseif #arg == 3 then
action[arg[1]](arg[2], arg[3])
end

View File

@ -0,0 +1,14 @@
#!/bin/sh
NPROCS="$(grep -c "^processor.*:" /proc/cpuinfo)"
[ "$NPROCS" -gt 1 ] || exit
IFNAME_PREFIX="${INTERFACE%%[0-9]*}"
if [ "${IFNAME_PREFIX}" = "usb" ] || [ "${IFNAME_PREFIX}" = "wwan" ]; then
if [ "$ACTION" = add ]; then
# set usb/wwan rps to cpu0
echo 1 > /sys/class/net/${INTERFACE}/queues/rx-0/rps_cpus
fi
[ -f /etc/init.d/mtk_smp ] && /etc/init.d/mtk_smp restart
fi

View File

@ -1,14 +0,0 @@
[ ifup = "$ACTION" ] && {
[ -n "$DEVICE" ] && {
if [ "$INTERFACE" == "lan" ]; then
if [ -f /usr/sbin/ethtool ]; then
ifname=eth0
lan_ip=`uci -q get network.lan.ipaddr`
ethdrv=`ethtool -i $ifname | grep mtk_soc_eth`
[ -n "$ethdrv" ] && {
ethtool -N $ifname flow-type tcp4 dst-ip $lan_ip loc 0
}
fi
fi
}
}

View File

@ -1,7 +1,8 @@
do_setup_ppenum() {
if [ -f "/etc/modules.d/20-mediatek_hnat" ]; then
PPE_NUM="$(uci -q get turboacc.config.fastpath_mh_eth_hnat_ppenum)"
echo "mtkhnat ppe_cnt=${PPE_NUM:-1}" > /etc/modules.d/20-mediatek_hnat
PPE_ENTRYNUM="$(uci -q get turboacc.config.fastpath_mh_eth_hnat_ppe_entrynum)"
echo "mtkhnat DEF_ETRY_NUM=${PPE_ENTRYNUM:-32768} ppe_cnt=${PPE_NUM:-1}" > /etc/modules.d/20-mediatek_hnat
fi
}

View File

@ -1079,7 +1079,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,
if (HNAT_SKB_CB2(skb)->magic == 0x78681415) {
if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
txd4 &= ~(0xf << TX_DMA_FPORT_SHIFT_V2);
txd4 |= 0x4 << TX_DMA_FPORT_SHIFT_V2;
txd4 |= 0x3 << TX_DMA_FPORT_SHIFT_V2;
} else {
txd4 &= ~(0x7 << TX_DMA_FPORT_SHIFT);
txd4 |= 0x4 << TX_DMA_FPORT_SHIFT;
@ -1411,7 +1411,9 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
mac = (trxd.rxd4 & RX_DMA_SPECIAL_TAG) ?
0 : RX_DMA_GET_SPORT(trxd.rxd4) - 1;
}
if (mac ==4) mac = 0;
if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
!eth->netdev[mac]))
goto release_desc;
@ -2584,7 +2586,7 @@ static int mtk_start_dma(struct mtk_eth *eth)
MTK_NDP_CO_PRO | MTK_MUTLI_CNT |
MTK_RESV_BUF | MTK_WCOMP_EN |
MTK_DMAD_WR_WDONE | MTK_CHK_DDONE_EN |
MTK_RX_2B_OFFSET , MTK_QDMA_GLO_CFG);
MTK_RX_2B_OFFSET | MTK_PKT_RX_WDONE, MTK_QDMA_GLO_CFG);
}
else
mtk_w32(eth,

View File

@ -586,7 +586,7 @@
/* Mac control registers */
#define MTK_MAC_MCR(x) (0x10100 + (x * 0x100))
#define MAC_MCR_MAX_RX_1536 BIT(24)
#define MAC_MCR_IPG_CFG (BIT(18) | BIT(16) | BIT(12))
#define MAC_MCR_IPG_CFG (BIT(18) | BIT(16))
#define MAC_MCR_FORCE_MODE BIT(15)
#define MAC_MCR_TX_EN BIT(14)
#define MAC_MCR_RX_EN BIT(13)

View File

@ -45,6 +45,10 @@ EXPORT_SYMBOL(ppe_dev_unregister_hook);
static int ppe_cnt = 1;
module_param(ppe_cnt, int, 0);
static int DEF_ETRY_NUM = 32768;
static int DEF_ETRY_NUM_CFG = TABLE_32K;
module_param(DEF_ETRY_NUM, int, 0);
static void hnat_sma_build_entry(struct timer_list *t)
{
int i;
@ -677,6 +681,29 @@ static int hnat_probe(struct platform_device *pdev)
struct extdev_entry *ext_entry;
const struct of_device_id *match;
switch (DEF_ETRY_NUM) {
case 32768:
DEF_ETRY_NUM_CFG = TABLE_32K;
break;
case 16384:
DEF_ETRY_NUM_CFG = TABLE_16K;
break;
case 8192:
DEF_ETRY_NUM_CFG = TABLE_8K;
break;
case 4096:
DEF_ETRY_NUM_CFG = TABLE_4K;
break;
case 2048:
DEF_ETRY_NUM_CFG = TABLE_2K;
break;
case 1024:
DEF_ETRY_NUM_CFG = TABLE_1K;
break;
default:
break;
}
hnat_priv = devm_kzalloc(&pdev->dev, sizeof(struct mtk_hnat), GFP_KERNEL);
if (!hnat_priv)
return -ENOMEM;
@ -762,7 +789,7 @@ static int hnat_probe(struct platform_device *pdev)
err = hnat_init_debugfs(hnat_priv);
if (err)
return err;
index = 0;
prop = of_find_property(np, "ext-devices", NULL);
for (name = of_prop_next_string(prop, NULL); name;
name = of_prop_next_string(prop, name), index++) {
@ -774,10 +801,25 @@ static int hnat_probe(struct platform_device *pdev)
strncpy(ext_entry->name, (char *)name, IFNAMSIZ - 1);
ext_if_add(ext_entry);
}
index = 0;
prop = of_find_property(np, "ext-devices-prefix", NULL);
for (name = of_prop_next_string(prop, NULL); name;
name = of_prop_next_string(prop, name), index++) {
ext_entry = kzalloc(sizeof(*ext_entry), GFP_KERNEL);
if (!ext_entry) {
err = -ENOMEM;
goto err_out1;
}
strncpy(ext_entry->name_prefix, (char *)name, IFNAMSIZ - 1);
ext_if_add(ext_entry);
}
for (i = 0; i < MAX_EXT_DEVS && hnat_priv->ext_if[i]; i++) {
ext_entry = hnat_priv->ext_if[i];
dev_info(&pdev->dev, "ext devices = %s\n", ext_entry->name);
dev_info(&pdev->dev, "ext devices = %s, prefix = %s\n", ext_entry->name, ext_entry->name_prefix);
}
hnat_priv->lvid = 1;

View File

@ -596,9 +596,9 @@ struct foe_entry {
/* If user wants to change default FOE entry number, both DEF_ETRY_NUM and
* DEF_ETRY_NUM_CFG need to be modified.
*/
#define DEF_ETRY_NUM 32768
/* #define DEF_ETRY_NUM 32768 */
/* feasible values : 32768, 16384, 8192, 4096, 2048, 1024 */
#define DEF_ETRY_NUM_CFG TABLE_32K
/* #define DEF_ETRY_NUM_CFG TABLE_32K */
/* corresponding values : TABLE_32K, TABLE_16K, TABLE_8K, TABLE_4K, TABLE_2K,
* TABLE_1K
*/
@ -690,6 +690,7 @@ struct mtk_hnat {
struct extdev_entry {
char name[IFNAMSIZ];
char name_prefix[IFNAMSIZ];
struct net_device *dev;
};
@ -857,10 +858,10 @@ enum FoeIpAct {
((!strncmp((dev)->name, hnat_priv->wan, strlen(hnat_priv->wan))) || ((!strncmp((dev)->name, "macvlan", 7)) && \
(hnat_priv->macvlan_support)))
#define IS_LAN(dev) (!strncmp(dev->name, LAN_DEV_NAME, strlen(LAN_DEV_NAME)))
#define IS_BR(dev) ((!strncmp(dev->name, "br", 2)) || (!strncmp(dev->name, "ra", 2)) || (!strncmp(dev->name, "eth", 3)))
#define IS_BR(dev) (!strncmp(dev->name, "br", 2))
#define IS_WHNAT(dev) \
((hnat_priv->data->whnat && \
(get_wifi_hook_if_index_from_dev(dev) != 0)) ? 1 : 0)
(get_wifi_hook_if_index_from_dev(dev) != 0)) ? 1 : 0 )
#define IS_EXT(dev) ((get_index_from_dev(dev) != 0) ? 1 : 0)
#define IS_PPD(dev) (!strcmp(dev->name, hnat_priv->ppd))
#define IS_IPV4_HNAPT(x) (((x)->bfib1.pkt_type == IPV4_HNAPT) ? 1 : 0)

View File

@ -1732,8 +1732,8 @@ static int hnat_ext_show(struct seq_file *m, void *private)
for (i = 0; i < MAX_EXT_DEVS && hnat_priv->ext_if[i]; i++) {
ext_entry = hnat_priv->ext_if[i];
if (ext_entry->dev)
seq_printf(m, "ext devices [%d] = %s (dev=%p, ifindex=%d)\n",
i, ext_entry->name, ext_entry->dev,
seq_printf(m, "ext devices [%d] = %s, prefix = %s (dev=%p, ifindex=%d)\n",
i, ext_entry->name, ext_entry->name_prefix, ext_entry->dev,
ext_entry->dev->ifindex);
}

View File

@ -76,7 +76,10 @@ static inline int find_extif_from_devname(const char *name)
for (i = 0; i < MAX_EXT_DEVS && hnat_priv->ext_if[i]; i++) {
ext_entry = hnat_priv->ext_if[i];
if (!strcmp(name, ext_entry->name))
if (strlen(ext_entry->name) && !strcmp(name, ext_entry->name))
return 1;
if (strlen(ext_entry->name_prefix) && !strncmp(name, ext_entry->name_prefix, strlen(ext_entry->name_prefix)))
return 1;
}
return 0;
@ -128,7 +131,10 @@ static inline int extif_set_dev(struct net_device *dev)
for (i = 0; i < MAX_EXT_DEVS && hnat_priv->ext_if[i]; i++) {
ext_entry = hnat_priv->ext_if[i];
if (!strcmp(dev->name, ext_entry->name) && !ext_entry->dev) {
if (((strlen(ext_entry->name) && !strcmp(dev->name, ext_entry->name))
|| (strlen(ext_entry->name_prefix) && !strncmp(dev->name, ext_entry->name_prefix, strlen(ext_entry->name_prefix))))
&& !ext_entry->dev)
{
dev_hold(dev);
ext_entry->dev = dev;
pr_info("%s(%s)\n", __func__, dev->name);
@ -400,9 +406,7 @@ unsigned int do_hnat_ext_to_ge(struct sk_buff *skb, const struct net_device *in,
}
/*set where we come from*/
skb->vlan_proto = htons(ETH_P_8021Q);
skb->vlan_tci =
(VLAN_CFI_MASK | (in->ifindex & VLAN_VID_MASK));
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), in->ifindex & VLAN_VID_MASK);
trace_printk(
"%s: vlan_prot=0x%x, vlan_tci=%x, in->name=%s, skb->dev->name=%s\n",
__func__, ntohs(skb->vlan_proto), skb->vlan_tci,
@ -433,13 +437,16 @@ unsigned int do_hnat_ext_to_ge2(struct sk_buff *skb, const char *func)
skb->dev = dev;
skb->vlan_proto = 0;
skb->vlan_tci = 0;
__vlan_hwaccel_clear_tag(skb);
if (ntohs(eth->h_proto) == ETH_P_8021Q) {
skb = skb_vlan_untag(skb);
if (unlikely(!skb))
return -1;
}
trace_printk(
"%s: vlan_prot=0x%x, vlan_tci=%x, skb->dev->name=%s\n",
__func__, ntohs(skb->vlan_proto), skb->vlan_tci,skb->dev->name);
if (IS_BOND_MODE &&
(((hnat_priv->data->version == MTK_HNAT_V4) &&
(skb_hnat_entry(skb) != 0x7fff)) ||
@ -873,6 +880,11 @@ mtk_hnat_ipv6_nf_pre_routing(void *priv, struct sk_buff *skb,
if (!skb)
goto drop;
if ((!IS_WHNAT(state->in)) && (IS_EXT(state->in)) && (IS_SPACE_AVAILABLE_HEAD(skb))) {
skb_hnat_alg(skb) = 0;
skb_hnat_magic_tag(skb) = HNAT_MAGIC_TAG;
}
if (!is_magic_tag_valid(skb))
return NF_ACCEPT;
@ -940,6 +952,11 @@ mtk_hnat_ipv4_nf_pre_routing(void *priv, struct sk_buff *skb,
if (!skb)
goto drop;
if ((!IS_WHNAT(state->in)) && (IS_EXT(state->in)) && (IS_SPACE_AVAILABLE_HEAD(skb))) {
skb_hnat_alg(skb) = 0;
skb_hnat_magic_tag(skb) = HNAT_MAGIC_TAG;
}
if (!is_magic_tag_valid(skb))
return NF_ACCEPT;
@ -999,9 +1016,15 @@ mtk_hnat_br_nf_local_in(void *priv, struct sk_buff *skb,
if (!skb)
goto drop;
if ((!IS_WHNAT(state->in)) && (IS_EXT(state->in)) && (IS_SPACE_AVAILABLE_HEAD(skb))) {
skb_hnat_alg(skb) = 0;
skb_hnat_magic_tag(skb) = HNAT_MAGIC_TAG;
}
if (!is_magic_tag_valid(skb))
return NF_ACCEPT;
if (IS_HQOS_MODE && hnat_priv->data->whnat) {
veth = (struct vlan_ethhdr *)skb_mac_header(skb);
@ -1011,12 +1034,13 @@ mtk_hnat_br_nf_local_in(void *priv, struct sk_buff *skb,
skb_hnat_reason(skb) = HIT_BIND_FORCE_TO_CPU;
}
}
if (!HAS_HQOS_MAGIC_TAG(skb) && !is_ppe_support_type(skb)) {
hnat_set_head_frags(state, skb, 1, hnat_set_alg);
return NF_ACCEPT;
}
if (skb_hnat_iface(skb) != FOE_MAGIC_EXT)
hnat_set_head_frags(state, skb, -1, hnat_set_iif);
pre_routing_print(skb, state->in, state->out, __func__);
@ -1026,7 +1050,7 @@ mtk_hnat_br_nf_local_in(void *priv, struct sk_buff *skb,
if (skb_hnat_reason(skb) == dbg_cpu_reason)
foe_dump_pkt(skb);
}
/* packets from external devices -> xxx ,step 1 , learning stage & bound stage*/
if ((skb_hnat_iface(skb) == FOE_MAGIC_EXT) && !is_from_extge(skb) &&
!is_multicast_ether_addr(eth_hdr(skb)->h_dest)) {
@ -1675,7 +1699,7 @@ static unsigned int skb_to_hnat_info(struct sk_buff *skb,
gmac = (IS_GMAC1_MODE) ? NR_GMAC1_PORT : NR_GMAC2_PORT;
}
} else if (IS_EXT(dev) && (FROM_GE_PPD(skb) || FROM_GE_LAN(skb) ||
FROM_GE_WAN(skb) || FROM_GE_VIRTUAL(skb) || FROM_WED(skb))) {
FROM_GE_WAN(skb) || FROM_GE_VIRTUAL(skb) || FROM_WED(skb) || FROM_EXT(skb))) {
if (!hnat_priv->data->whnat && IS_GMAC1_MODE) {
entry.bfib1.vpm = 1;
entry.bfib1.vlan_layer = 1;
@ -2174,7 +2198,11 @@ static unsigned int mtk_hnat_nf_post_routing(
if (!IS_LAN(out) && !IS_WAN(out) && !IS_EXT(out))
return 0;
if (!IS_WHNAT(out) && IS_EXT(out) && FROM_WED(skb))
return 0;
trace_printk("[%s] case hit, %x-->%s, reason=%x\n", __func__,
skb_hnat_iface(skb), out->name, skb_hnat_reason(skb));
@ -2353,7 +2381,7 @@ mtk_pong_hqos_handler(void *priv, struct sk_buff *skb,
if (!skb)
goto drop;
if (!is_magic_tag_valid(skb))
return NF_ACCEPT;
@ -2402,7 +2430,7 @@ mtk_hnat_br_nf_local_out(void *priv, struct sk_buff *skb,
goto drop;
post_routing_print(skb, state->in, state->out, __func__);
if (!mtk_hnat_nf_post_routing(skb, state->out, 0, __func__))
return NF_ACCEPT;

View File

@ -82,7 +82,7 @@ struct hnat_desc {
#define skb_hnat_ppe(skb) \
(((skb_hnat_sport(skb) == NR_GMAC2_PORT) && (CFG_PPE_NUM >= 2)) ? 1 : 0)
#define do_ext2ge_fast_try(dev, skb) \
((skb_hnat_iface(skb) == FOE_MAGIC_EXT) && !is_from_extge(skb))
(IS_EXT(dev) && !is_from_extge(skb))
#define set_from_extge(skb) (HNAT_SKB_CB2(skb)->magic = 0x78786688)
#define clr_from_extge(skb) (HNAT_SKB_CB2(skb)->magic = 0x0)
#define set_to_ppe(skb) (HNAT_SKB_CB2(skb)->magic = 0x78681415)