Jiri Pirko <[email protected]> writes:
[...]
> +static void red_unoffload(struct Qdisc *sch)
> +{
> + struct net_device *dev = qdisc_dev(sch);
> + struct tc_red_qopt_offload opt = {
> + .handle = sch->handle,
> + .command = TC_RED_DESTROY,
> + .parent = sch->parent,
> + };
> +
> + if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc)
> + return;
> +
> + dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_RED, &opt);
> +}
> +
> @@ -162,6 +179,28 @@ static const struct nla_policy red_policy[TCA_RED_MAX +
> 1] = {
> [TCA_RED_MAX_P] = { .type = NLA_U32 },
> };
>
> +static int red_offload(struct Qdisc *sch)
> +{
> + struct red_sched_data *q = qdisc_priv(sch);
> + struct net_device *dev = qdisc_dev(sch);
> + struct tc_red_qopt_offload opt = {
> + .handle = sch->handle,
> + .command = TC_RED_REPLACE,
> + .parent = sch->parent,
> + .set = {
> + .min = q->parms.qth_min >> q->parms.Wlog,
> + .max = q->parms.qth_max >> q->parms.Wlog,
> + .probability = q->parms.max_P,
> + .is_ecn = red_use_ecn(q),
> + },
> + };
> +
> + if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc)
> + return -EOPNOTSUPP;
> +
> + return dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_RED, &opt);
> +}
> +
[...]
Can't red_unoffload() and red_offload() be unified in a single API? For
example, red_offload(struct Qdisc *sch, bool enable) ?