mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
Update WAN ingress ratelimit with generic method.
Instead of using the MAC to do ratelimting we use the Frame Engine, this has the the benefit of being a more universal solution and will work with PON without the need of implement APIs for using the MAC to do ingress ratelimiting. This also works fine when the integrated switch is used as the wan.
This commit is contained in:
parent
22aa3ff065
commit
daf54622d8
1 changed files with 21 additions and 19 deletions
|
|
@ -6,18 +6,17 @@ readonly ETHWAN="$(jsonfilter -i /etc/board.json -e @.network.wan.device)"
|
|||
readonly LANPORTS="$(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.lan.device | xargs)"
|
||||
readonly OFFSET=32
|
||||
|
||||
get_wan_type_idx() {
|
||||
case "$(cat "/proc/tc3162/${ETHWAN}_switch_hsgmii_lan")" in
|
||||
pon) echo "3" ;;
|
||||
usb) echo "2" ;;
|
||||
pcie0) echo "0" ;;
|
||||
pcie1) echo "1" ;;
|
||||
eth) echo "4" ;;
|
||||
*) echo "-1" ;;
|
||||
esac
|
||||
get_wan_port_idx() {
|
||||
local reg="$(cat /proc/tc3162/fe_reg | grep -E '^FE_WAN_PORT' | awk '{print $4}')"
|
||||
local port
|
||||
|
||||
reg=$((reg))
|
||||
port=$((reg & 0x1f))
|
||||
|
||||
echo "$port"
|
||||
}
|
||||
|
||||
readonly WAN_TYPE_IDX="$(get_wan_type_idx)"
|
||||
readonly WAN_TYPE_PORT="$(get_wan_port_idx)"
|
||||
|
||||
errmsg() {
|
||||
echo "$@" >&2
|
||||
|
|
@ -68,20 +67,23 @@ hw_intf_init() {
|
|||
|
||||
set_wan_ingress_rate() {
|
||||
local ingress_rate="$1"
|
||||
local pkt_type
|
||||
local wanchannel="$(cat /proc/tc3162/eth_portmap | head -n1)"
|
||||
|
||||
ingress_rate=$((ingress_rate))
|
||||
wanchannel=$((wanchannel))
|
||||
|
||||
rm -rf "/tmp/qos/wan_ingress_shape_speed"
|
||||
|
||||
if [ "$wanchannel" = "-1" ]; then
|
||||
[ "$WAN_TYPE_IDX" = "-1" -o -z "$ingress_rate" ] && return
|
||||
|
||||
echo "$ingress_rate" > "/tmp/qos/wan_ingress_shape_speed"
|
||||
|
||||
for pkt_type in $(seq 0 3); do
|
||||
echo "$WAN_TYPE_IDX $pkt_type $ingress_rate 0" > "/proc/tc3162/${ETHWAN}_ratelimit"
|
||||
done
|
||||
echo "6 0 $ingress_rate 0 $WAN_TYPE_PORT" > "/proc/tc3162/fe_ratelimit"
|
||||
else
|
||||
# Both directions needs to be cleard for this to work as expected.
|
||||
/userfs/bin/switchmgr port ratectl "$wanchannel" 0 0
|
||||
/userfs/bin/switchmgr port ratectl "$wanchannel" 1 0
|
||||
/userfs/bin/switchmgr port ratectl "$wanchannel" 0 "$ingress_rate"
|
||||
fi
|
||||
|
||||
echo "$ingress_rate" > "/tmp/qos/wan_ingress_shape_speed"
|
||||
}
|
||||
|
||||
set_wan_egress_rate() {
|
||||
|
|
@ -128,7 +130,7 @@ hw_init_all() {
|
|||
/userfs/bin/qdmamgr_wan set general_rx_trtcm config "$tsid" disable byte slow disable byte fast
|
||||
done
|
||||
|
||||
# set_wan_ingress_rate "0" - Not needed
|
||||
# set_wan_ingress_rate "0" - Not needed, done in policer.sh
|
||||
set_wan_egress_rate "0" "0"
|
||||
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue