summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2024-04-24 19:23:11 +0200
committerFelix Fietkau <nbd@nbd.name>2024-04-26 06:31:27 +0200
commit7ebcf2fb9c5db8b75666761f5e767c91abb1f437 (patch)
tree7ef92a29dc2d4c4afd72c5fae89b693f7b3e86c7
parentc4d394c6cc0facba94fda5f1cc886edaf342be3a (diff)
downloadopenwrt-7ebcf2fb9c5db8b75666761f5e767c91abb1f437.tar.gz
openwrt-7ebcf2fb9c5db8b75666761f5e767c91abb1f437.tar.bz2
openwrt-7ebcf2fb9c5db8b75666761f5e767c91abb1f437.zip
netifd: add flow steering mode to the packet steering script
This allows directing processing of locally received packets to the CPUs of the tasks receiving them Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rwxr-xr-xpackage/network/config/netifd/files/etc/init.d/packet_steering4
-rwxr-xr-xpackage/network/config/netifd/files/usr/libexec/network/packet-steering.uc14
2 files changed, 16 insertions, 2 deletions
diff --git a/package/network/config/netifd/files/etc/init.d/packet_steering b/package/network/config/netifd/files/etc/init.d/packet_steering
index d6f6afc2e1..ff4a39073b 100755
--- a/package/network/config/netifd/files/etc/init.d/packet_steering
+++ b/package/network/config/netifd/files/etc/init.d/packet_steering
@@ -15,9 +15,11 @@ service_triggers() {
reload_service() {
packet_steering="$(uci get "network.@globals[0].packet_steering")"
+ steering_flows="$(uci get "network.@globals[0].steering_flows")"
+ [ "$steering_flows" -gt 0 ] && opts="-l $steering_flows"
if [ -e "/usr/libexec/platform/packet-steering.sh" ]; then
/usr/libexec/platform/packet-steering.sh "$packet_steering"
else
- /usr/libexec/network/packet-steering.uc "$packet_steering"
+ /usr/libexec/network/packet-steering.uc $opts "$packet_steering"
fi
}
diff --git a/package/network/config/netifd/files/usr/libexec/network/packet-steering.uc b/package/network/config/netifd/files/usr/libexec/network/packet-steering.uc
index 025532c1c1..a578e28879 100755
--- a/package/network/config/netifd/files/usr/libexec/network/packet-steering.uc
+++ b/package/network/config/netifd/files/usr/libexec/network/packet-steering.uc
@@ -10,8 +10,10 @@ let debug = 0, do_nothing = 0;
let disable;
let cpus;
let all_cpus;
+let local_flows = 0;
-for (let arg in ARGV) {
+while (length(ARGV) > 0) {
+ let arg = shift(ARGV);
switch (arg) {
case "-d":
debug++;
@@ -25,6 +27,9 @@ for (let arg in ARGV) {
case '2':
all_cpus = true;
break;
+ case '-l':
+ local_flows = +shift(ARGV);
+ break;
}
}
@@ -71,6 +76,13 @@ function set_netdev_cpu(dev, cpu) {
if (!do_nothing)
writefile(queue, `${val}`);
}
+ queues = glob(`/sys/class/net/${dev}/queues/rx-*/rps_flow_cnt`);
+ for (let queue in queues) {
+ if (debug || do_nothing)
+ warn(`echo ${local_flows} > ${queue}\n`);
+ if (!do_nothing)
+ writefile(queue, `${local_flows}`);
+ }
}
function task_device_match(name, device)