netifd: add flow steering mode to the packet steering script
[openwrt/openwrt.git] / package / network / config / netifd / files / usr / libexec / network / packet-steering.uc
index 025532c1c1e7ebe136c21e5669adfd663ea75e09..a578e288791d7d4a3d5bb44a222614af227b419f 100755 (executable)
@@ -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)