Commit 65545ea2 authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

net: sched: sch_red: Split init and change callbacks

In the following patches, RED will get two qevents. The implementation will
be clearer if the callback for change is not a pure subset of the callback
for init. Split the two and promote attribute parsing to the callbacks
themselves from the common code, because it will be handy there.
Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3625750f
...@@ -215,12 +215,11 @@ static const struct nla_policy red_policy[TCA_RED_MAX + 1] = { ...@@ -215,12 +215,11 @@ static const struct nla_policy red_policy[TCA_RED_MAX + 1] = {
[TCA_RED_FLAGS] = NLA_POLICY_BITFIELD32(TC_RED_SUPPORTED_FLAGS), [TCA_RED_FLAGS] = NLA_POLICY_BITFIELD32(TC_RED_SUPPORTED_FLAGS),
}; };
static int red_change(struct Qdisc *sch, struct nlattr *opt, static int __red_change(struct Qdisc *sch, struct nlattr **tb,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct Qdisc *old_child = NULL, *child = NULL; struct Qdisc *old_child = NULL, *child = NULL;
struct red_sched_data *q = qdisc_priv(sch); struct red_sched_data *q = qdisc_priv(sch);
struct nlattr *tb[TCA_RED_MAX + 1];
struct nla_bitfield32 flags_bf; struct nla_bitfield32 flags_bf;
struct tc_red_qopt *ctl; struct tc_red_qopt *ctl;
unsigned char userbits; unsigned char userbits;
...@@ -228,14 +227,6 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt, ...@@ -228,14 +227,6 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt,
int err; int err;
u32 max_P; u32 max_P;
if (opt == NULL)
return -EINVAL;
err = nla_parse_nested_deprecated(tb, TCA_RED_MAX, opt, red_policy,
NULL);
if (err < 0)
return err;
if (tb[TCA_RED_PARMS] == NULL || if (tb[TCA_RED_PARMS] == NULL ||
tb[TCA_RED_STAB] == NULL) tb[TCA_RED_STAB] == NULL)
return -EINVAL; return -EINVAL;
...@@ -323,11 +314,38 @@ static int red_init(struct Qdisc *sch, struct nlattr *opt, ...@@ -323,11 +314,38 @@ static int red_init(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct red_sched_data *q = qdisc_priv(sch); struct red_sched_data *q = qdisc_priv(sch);
struct nlattr *tb[TCA_RED_MAX + 1];
int err;
if (!opt)
return -EINVAL;
err = nla_parse_nested_deprecated(tb, TCA_RED_MAX, opt, red_policy,
extack);
if (err < 0)
return err;
q->qdisc = &noop_qdisc; q->qdisc = &noop_qdisc;
q->sch = sch; q->sch = sch;
timer_setup(&q->adapt_timer, red_adaptative_timer, 0); timer_setup(&q->adapt_timer, red_adaptative_timer, 0);
return red_change(sch, opt, extack); return __red_change(sch, tb, extack);
}
static int red_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct nlattr *tb[TCA_RED_MAX + 1];
int err;
if (!opt)
return -EINVAL;
err = nla_parse_nested_deprecated(tb, TCA_RED_MAX, opt, red_policy,
extack);
if (err < 0)
return err;
return __red_change(sch, tb, extack);
} }
static int red_dump_offload_stats(struct Qdisc *sch) static int red_dump_offload_stats(struct Qdisc *sch)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment