[openwrt/openwrt] netifd: add a packet steering mode matching the old script
LEDE Commits
lede-commits at lists.infradead.org
Thu Apr 25 21:38:06 PDT 2024
nbd pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/c4d394c6cc0facba94fda5f1cc886edaf342be3a
commit c4d394c6cc0facba94fda5f1cc886edaf342be3a
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Wed Apr 24 19:16:05 2024 +0200
netifd: add a packet steering mode matching the old script
This spreads packet processing across all cores
Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
.../files/usr/libexec/network/packet-steering.uc | 23 ++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
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 72f96024d8..025532c1c1 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
@@ -9,6 +9,7 @@ let eth_bias = 2.0;
let debug = 0, do_nothing = 0;
let disable;
let cpus;
+let all_cpus;
for (let arg in ARGV) {
switch (arg) {
@@ -21,6 +22,9 @@ for (let arg in ARGV) {
case '0':
disable = true;
break;
+ case '2':
+ all_cpus = true;
+ break;
}
}
@@ -46,9 +50,19 @@ function set_task_cpu(pid, cpu) {
system(`taskset -p -c ${cpu} ${pid}`);
}
+function cpu_mask(cpu)
+{
+ let mask;
+ if (cpu < 0)
+ mask = (1 << length(cpus)) - 1;
+ else
+ mask = (1 << int(cpu));
+ return sprintf("%x", mask);
+}
+
function set_netdev_cpu(dev, cpu) {
let queues = glob(`/sys/class/net/${dev}/queues/rx-*/rps_cpus`);
- let val = sprintf("%x", (1 << int(cpu)));
+ let val = cpu_mask(cpu);
if (disable)
val = 0;
for (let queue in queues) {
@@ -173,7 +187,12 @@ function assign_dev_cpu(dev) {
}
if (length(dev.netdev) > 0) {
- let cpu = dev.rx_cpu = get_next_cpu(rx_weight, dev.napi_cpu);
+ let cpu;
+ if (all_cpus)
+ cpu = -1;
+ else
+ cpu = get_next_cpu(rx_weight, dev.napi_cpu);
+ dev.rx_cpu = cpu;
for (let netdev in dev.netdev)
set_netdev_cpu(netdev, cpu);
}
More information about the lede-commits
mailing list