summaryrefslogtreecommitdiffhomepage
path: root/system-linux.c
diff options
context:
space:
mode:
authorJohn Crispin <john@phrozen.org>2017-08-22 09:10:58 +0200
committerJohn Crispin <john@phrozen.org>2017-08-22 09:10:58 +0200
commitb5731bfbabaf7aab0fc47143bd6ad0b12cc3df0a (patch)
tree747743efa83dc28a6b3b73bda992ad970786af48 /system-linux.c
parent2a29d1a8d45f164e9a3fda31264bf70b8f90d9ad (diff)
allow setting rps/xps defualt values via uci
Signed-off-by: John Crispin <john@phrozen.org>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/system-linux.c b/system-linux.c
index 02faa32..0bf071e 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -1388,7 +1388,7 @@ system_if_get_settings(struct device *dev, struct device_settings *s)
}
static void
-system_if_set_rps_xps_val(const char *path, int val)
+system_if_set_rps_xps_val(const char *path, char *fmt, int val)
{
char val_buf[8];
glob_t gl;
@@ -1397,7 +1397,7 @@ system_if_set_rps_xps_val(const char *path, int val)
if (glob(path, 0, NULL, &gl))
return;
- snprintf(val_buf, sizeof(val_buf), "%x", val);
+ snprintf(val_buf, sizeof(val_buf), fmt, val);
for (i = 0; i < gl.gl_pathc; i++)
system_set_sysctl(gl.gl_pathv[i], val_buf);
@@ -1408,17 +1408,23 @@ static void
system_if_apply_rps_xps(struct device *dev, struct device_settings *s)
{
long n_cpus = sysconf(_SC_NPROCESSORS_ONLN);
- int val;
+ int val, rps_val, rps_flow_cnt, xps_val;
if (n_cpus < 2)
return;
val = (1 << n_cpus) - 1;
+ rps_val = s->rps_val ? s->rps_val : val;
snprintf(dev_buf, sizeof(dev_buf), "/sys/class/net/%s/queues/*/rps_cpus", dev->ifname);
- system_if_set_rps_xps_val(dev_buf, s->rps ? val : 0);
+ system_if_set_rps_xps_val(dev_buf, "%x", s->rps ? rps_val : 0);
+
+ rps_flow_cnt = s->rps_flow_cnt ? s->rps_flow_cnt : 0;
+ snprintf(dev_buf, sizeof(dev_buf), "/sys/class/net/%s/queues/*/rps_flow_cnt", dev->ifname);
+ system_if_set_rps_xps_val(dev_buf, "%d", s->rps ? rps_flow_cnt : 0);
+ xps_val = s->xps_val ? s->xps_val : val;
snprintf(dev_buf, sizeof(dev_buf), "/sys/class/net/%s/queues/*/xps_cpus", dev->ifname);
- system_if_set_rps_xps_val(dev_buf, s->xps ? val : 0);
+ system_if_set_rps_xps_val(dev_buf, "%x", s->xps ? xps_val : 0);
}
void