Commit 890d8d23 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

net: sched: gred: add basic Qdisc offload

Add basic offload for the GRED Qdisc.  Inform the drivers any
time Qdisc or virtual queue configuration changes.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarJohn Hurley <john.hurley@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 184ec856
...@@ -846,6 +846,7 @@ enum tc_setup_type { ...@@ -846,6 +846,7 @@ enum tc_setup_type {
TC_SETUP_QDISC_MQ, TC_SETUP_QDISC_MQ,
TC_SETUP_QDISC_ETF, TC_SETUP_QDISC_ETF,
TC_SETUP_ROOT_QDISC, TC_SETUP_ROOT_QDISC,
TC_SETUP_QDISC_GRED,
}; };
/* These structures hold the attributes of bpf state that are being passed /* These structures hold the attributes of bpf state that are being passed
......
...@@ -868,6 +868,42 @@ struct tc_red_qopt_offload { ...@@ -868,6 +868,42 @@ struct tc_red_qopt_offload {
}; };
}; };
enum tc_gred_command {
TC_GRED_REPLACE,
TC_GRED_DESTROY,
};
struct tc_gred_vq_qopt_offload_params {
bool present;
u32 limit;
u32 prio;
u32 min;
u32 max;
bool is_ecn;
bool is_harddrop;
u32 probability;
/* Only need backlog, see struct tc_prio_qopt_offload_params */
u32 *backlog;
};
struct tc_gred_qopt_offload_params {
bool grio_on;
bool wred_on;
unsigned int dp_cnt;
unsigned int dp_def;
struct gnet_stats_queue *qstats;
struct tc_gred_vq_qopt_offload_params tab[MAX_DPs];
};
struct tc_gred_qopt_offload {
enum tc_gred_command command;
u32 handle;
u32 parent;
union {
struct tc_gred_qopt_offload_params set;
};
};
enum tc_prio_command { enum tc_prio_command {
TC_PRIO_REPLACE, TC_PRIO_REPLACE,
TC_PRIO_DESTROY, TC_PRIO_DESTROY,
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <net/pkt_cls.h>
#include <net/pkt_sched.h> #include <net/pkt_sched.h>
#include <net/red.h> #include <net/red.h>
...@@ -311,6 +312,48 @@ static void gred_reset(struct Qdisc *sch) ...@@ -311,6 +312,48 @@ static void gred_reset(struct Qdisc *sch)
} }
} }
static void gred_offload(struct Qdisc *sch, enum tc_gred_command command)
{
struct gred_sched *table = qdisc_priv(sch);
struct net_device *dev = qdisc_dev(sch);
struct tc_gred_qopt_offload opt = {
.command = command,
.handle = sch->handle,
.parent = sch->parent,
};
if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc)
return;
if (command == TC_GRED_REPLACE) {
unsigned int i;
opt.set.grio_on = gred_rio_mode(table);
opt.set.wred_on = gred_wred_mode(table);
opt.set.dp_cnt = table->DPs;
opt.set.dp_def = table->def;
for (i = 0; i < table->DPs; i++) {
struct gred_sched_data *q = table->tab[i];
if (!q)
continue;
opt.set.tab[i].present = true;
opt.set.tab[i].limit = q->limit;
opt.set.tab[i].prio = q->prio;
opt.set.tab[i].min = q->parms.qth_min >> q->parms.Wlog;
opt.set.tab[i].max = q->parms.qth_max >> q->parms.Wlog;
opt.set.tab[i].is_ecn = gred_use_ecn(q);
opt.set.tab[i].is_harddrop = gred_use_harddrop(q);
opt.set.tab[i].probability = q->parms.max_P;
opt.set.tab[i].backlog = &q->backlog;
}
opt.set.qstats = &sch->qstats;
}
dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_GRED, &opt);
}
static inline void gred_destroy_vq(struct gred_sched_data *q) static inline void gred_destroy_vq(struct gred_sched_data *q)
{ {
kfree(q); kfree(q);
...@@ -385,6 +428,7 @@ static int gred_change_table_def(struct Qdisc *sch, struct nlattr *dps, ...@@ -385,6 +428,7 @@ static int gred_change_table_def(struct Qdisc *sch, struct nlattr *dps,
} }
} }
gred_offload(sch, TC_GRED_REPLACE);
return 0; return 0;
} }
...@@ -630,6 +674,8 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt, ...@@ -630,6 +674,8 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt,
sch_tree_unlock(sch); sch_tree_unlock(sch);
kfree(prealloc); kfree(prealloc);
gred_offload(sch, TC_GRED_REPLACE);
return 0; return 0;
err_unlock_free: err_unlock_free:
...@@ -815,6 +861,7 @@ static void gred_destroy(struct Qdisc *sch) ...@@ -815,6 +861,7 @@ static void gred_destroy(struct Qdisc *sch)
if (table->tab[i]) if (table->tab[i])
gred_destroy_vq(table->tab[i]); gred_destroy_vq(table->tab[i]);
} }
gred_offload(sch, TC_GRED_DESTROY);
} }
static struct Qdisc_ops gred_qdisc_ops __read_mostly = { static struct Qdisc_ops gred_qdisc_ops __read_mostly = {
......
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