mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
46 lines
1.1 KiB
Bash
Executable file
46 lines
1.1 KiB
Bash
Executable file
#!/bin/sh
|
|
# Common shaper library
|
|
|
|
# UCI 'shaper' section handler.
|
|
# It will verify shaper configuration sanity and then invoke
|
|
# hardware-specific functions
|
|
handle_shaper() {
|
|
sid="$1" #queue section ID
|
|
|
|
config_get is_enable "$sid" "enable" 1
|
|
# no need to configure disabled queues
|
|
if [ "${is_enable}" == "0" ] ; then
|
|
return
|
|
fi
|
|
|
|
|
|
config_get ifname "$sid" "ifname"
|
|
# if ifname is empty that is good enough to break
|
|
if [ -z "$ifname" ] ; then
|
|
return
|
|
fi
|
|
|
|
config_get rate "$sid" "rate"
|
|
# Convert the rate from bps to kbps.
|
|
if [ -z "${rate}" ] || [ "${rate}" -lt 1000 ] ; then
|
|
return
|
|
fi
|
|
|
|
rate=$((rate / 1000))
|
|
config_get bs "$sid" "burst_size"
|
|
|
|
hw_shaper_set "$ifname" add "$rate" "$bs"
|
|
}
|
|
|
|
# Configure shaper based on options saved to UCI tree 'qos.shaper'
|
|
configure_shaper() {
|
|
# Delete existing shaper
|
|
for intf in $(db get hw.board.ethernetPortOrder); do
|
|
hw_shaper_set "$intf" del
|
|
done
|
|
|
|
# Load UCI file
|
|
config_load qos
|
|
# Processing shaper section(s)
|
|
config_foreach handle_shaper shaper
|
|
}
|