remove rps/xps configuration support
authorFelix Fietkau <nbd@nbd.name>
Mon, 26 Feb 2018 11:21:00 +0000 (12:21 +0100)
committerFelix Fietkau <nbd@nbd.name>
Mon, 26 Feb 2018 11:27:09 +0000 (12:27 +0100)
It is overly complex, yet does not cover common scenarios very well.
It will be replaced with a simpler shell script that provides a better
default policy

Signed-off-by: Felix Fietkau <nbd@nbd.name>
config.c
device.c
device.h
system-linux.c

index 21791afa685fe63c7f9bcbc6bb4056d59ebc3941..536b7d3fa6073c21375aadfdd4e323a41ecb1e99 100644 (file)
--- a/config.c
+++ b/config.c
@@ -289,18 +289,6 @@ config_init_rules(void)
 
        iprule_update_complete();
 }
-static int
-config_parse_global_ps_val(struct uci_section *globals, const char *option)
-{
-       const char *val = uci_lookup_option_string(
-                       uci_ctx, globals, option);
-       int ret = 0;
-
-       if (val)
-               ret = strtol(val, 0, 10);
-
-       return ret;
-}
 
 static void
 config_init_globals(void)
@@ -313,15 +301,6 @@ config_init_globals(void)
        const char *ula_prefix = uci_lookup_option_string(
                        uci_ctx, globals, "ula_prefix");
        interface_ip_set_ula_prefix(ula_prefix);
-
-       const char *default_ps = uci_lookup_option_string(
-                       uci_ctx, globals, "default_ps");
-
-       if (default_ps)
-               device_set_default_ps(strcmp(default_ps, "1") ? false : true,
-                       config_parse_global_ps_val(globals, "default_xps_val"),
-                       config_parse_global_ps_val(globals, "default_rps_val"),
-                       config_parse_global_ps_val(globals, "default_rps_flow_cnt"));
 }
 
 static void
index a851037f16415442cf4853d2f18914abf91e52ca..ad470c929793b0ca4a8f3215cc85fdd2f014b53b 100644 (file)
--- a/device.c
+++ b/device.c
 
 static struct list_head devtypes = LIST_HEAD_INIT(devtypes);
 static struct avl_tree devices;
-static bool default_ps = true;
-static int default_rps_val;
-static int default_rps_flow_cnt;
-static int default_xps_val;
 
 static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = {
        [DEV_ATTR_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING },
@@ -52,8 +48,6 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = {
        [DEV_ATTR_MLDVERSION] = { .name = "mldversion", .type = BLOBMSG_TYPE_INT32 },
        [DEV_ATTR_NEIGHREACHABLETIME] = { .name = "neighreachabletime", .type = BLOBMSG_TYPE_INT32 },
        [DEV_ATTR_NEIGHGCSTALETIME] = { .name = "neighgcstaletime", .type = BLOBMSG_TYPE_INT32 },
-       [DEV_ATTR_RPS] = { .name = "rps", .type = BLOBMSG_TYPE_BOOL },
-       [DEV_ATTR_XPS] = { .name = "xps", .type = BLOBMSG_TYPE_BOOL },
        [DEV_ATTR_DADTRANSMITS] = { .name = "dadtransmits", .type = BLOBMSG_TYPE_INT32 },
        [DEV_ATTR_MULTICAST_TO_UNICAST] = { .name = "multicast_to_unicast", .type = BLOBMSG_TYPE_BOOL },
        [DEV_ATTR_MULTICAST_ROUTER] = { .name = "multicast_router", .type = BLOBMSG_TYPE_INT32 },
@@ -325,20 +319,6 @@ device_init_settings(struct device *dev, struct blob_attr **tb)
                s->flags |= DEV_OPT_NEIGHLOCKTIME;
        }
 
-       if ((cur = tb[DEV_ATTR_RPS])) {
-               s->rps = blobmsg_get_bool(cur);
-               s->flags |= DEV_OPT_RPS;
-       }
-       else
-               s->rps = default_ps;
-
-       if ((cur = tb[DEV_ATTR_XPS])) {
-               s->xps = blobmsg_get_bool(cur);
-               s->flags |= DEV_OPT_XPS;
-       }
-       else
-               s->xps = default_ps;
-
        if ((cur = tb[DEV_ATTR_DADTRANSMITS])) {
                s->dadtransmits = blobmsg_get_u32(cur);
                s->flags |= DEV_OPT_DADTRANSMITS;
@@ -515,8 +495,6 @@ int device_init(struct device *dev, struct device_type *type, const char *ifname
 
        system_if_clear_state(dev);
        device_check_state(dev);
-       dev->settings.rps = default_ps;
-       dev->settings.xps = default_ps;
 
        return 0;
 }
@@ -914,48 +892,6 @@ device_reset_old(void)
        }
 }
 
-void
-device_set_default_ps(bool state, int xps, int rps, int rps_flow_cnt)
-{
-       struct device *dev;
-
-       if ((state == default_ps) && (default_rps_val == rps) &&
-           (default_xps_val == xps) && (default_rps_flow_cnt == rps_flow_cnt))
-               return;
-
-       default_ps = state;
-       default_rps_val = rps;
-       default_rps_flow_cnt = rps_flow_cnt;
-       default_xps_val = xps;
-
-       avl_for_each_element(&devices, dev, avl) {
-               struct device_settings *s = &dev->settings;
-               unsigned int apply_mask = 0;
-
-               if (!(s->flags & DEV_OPT_RPS)) {
-                       s->rps = default_ps;
-                       s->rps_val = default_rps_val;
-                       s->rps_flow_cnt = default_rps_flow_cnt;
-                       apply_mask |= DEV_OPT_RPS;
-               }
-
-               if (!(s->flags & DEV_OPT_XPS)) {
-                       s->xps = default_ps;
-                       s->xps_val = default_xps_val;
-                       apply_mask |= DEV_OPT_XPS;
-               }
-
-               if (!apply_mask)
-                       continue;
-
-               if (!(dev->external || (dev->present && dev->active)) ||
-                               dev->config_pending)
-                       continue;
-
-               system_if_apply_settings(dev, s, apply_mask);
-       }
-}
-
 struct device *
 device_create(const char *name, struct device_type *type,
              struct blob_attr *config)
index 07f1dbd71a0e2c15935046b30ee0982efb303238..dc45967eb95db2a85654e6e9781ec602fdf887f6 100644 (file)
--- a/device.h
+++ b/device.h
@@ -40,8 +40,6 @@ enum {
        DEV_ATTR_IGMPVERSION,
        DEV_ATTR_MLDVERSION,
        DEV_ATTR_NEIGHREACHABLETIME,
-       DEV_ATTR_RPS,
-       DEV_ATTR_XPS,
        DEV_ATTR_DADTRANSMITS,
        DEV_ATTR_MULTICAST_TO_UNICAST,
        DEV_ATTR_MULTICAST_ROUTER,
@@ -92,8 +90,7 @@ enum {
        DEV_OPT_IGMPVERSION             = (1 << 7),
        DEV_OPT_MLDVERSION              = (1 << 8),
        DEV_OPT_NEIGHREACHABLETIME      = (1 << 9),
-       DEV_OPT_RPS                     = (1 << 10),
-       DEV_OPT_XPS                     = (1 << 11),
+       /* 2 bit hole */
        DEV_OPT_MTU6                    = (1 << 12),
        DEV_OPT_DADTRANSMITS            = (1 << 13),
        DEV_OPT_MULTICAST_TO_UNICAST    = (1 << 14),
@@ -163,11 +160,6 @@ struct device_settings {
        unsigned int neigh4gcstaletime;
        unsigned int neigh6gcstaletime;
        int neigh4locktime;
-       bool rps;
-       int rps_val;
-       int rps_flow_cnt;
-       bool xps;
-       int xps_val;
        unsigned int dadtransmits;
        bool multicast_to_unicast;
        unsigned int multicast_router;
@@ -254,7 +246,6 @@ device_apply_config(struct device *dev, struct device_type *type,
 
 void device_reset_config(void);
 void device_reset_old(void);
-void device_set_default_ps(bool state, int xps, int rps, int rps_flow_cnt);
 
 void device_init_virtual(struct device *dev, struct device_type *type, const char *name);
 int device_init(struct device *dev, struct device_type *type, const char *ifname);
index 0277886e17a56d6fb4f65397b19dbe3cbb6bf64b..4f3b9b06c2f1feca20792c9bbc63f201a8fc0499 100644 (file)
@@ -1411,46 +1411,6 @@ system_if_get_settings(struct device *dev, struct device_settings *s)
        }
 }
 
-static void
-system_if_set_rps_xps_val(const char *path, char *fmt, int val)
-{
-       char val_buf[8];
-       glob_t gl;
-       int i;
-
-       if (glob(path, 0, NULL, &gl))
-               return;
-
-       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);
-
-       globfree(&gl);
-}
-
-static void
-system_if_apply_rps_xps(struct device *dev, struct device_settings *s)
-{
-       long n_cpus = sysconf(_SC_NPROCESSORS_ONLN);
-       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, "%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, "%x", s->xps ? xps_val : 0);
-}
-
 void
 system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned int apply_mask)
 {
@@ -1526,8 +1486,6 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned
        }
        if (s->flags & DEV_OPT_SENDREDIRECTS & apply_mask)
                system_set_sendredirects(dev, s->sendredirects ? "1" : "0");
-
-       system_if_apply_rps_xps(dev, s);
 }
 
 int system_if_up(struct device *dev)