net/sched: sch_cake: Add cake_mq qdisc for using cake on mq devices

Add a cake_mq qdisc which installs cake instances on each hardware
queue on a multi-queue device.

This is just a copy of sch_mq that installs cake instead of the default
qdisc on each queue. Subsequent commits will add sharing of the config
between cake instances, as well as a multi-queue aware shaper algorithm.

Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://patch.msgid.link/20260109-mq-cake-sub-qdisc-v8-3-8d613fece5d8@redhat.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Toke Høiland-Jørgensen
2026-01-09 14:15:32 +01:00
committed by Paolo Abeni
parent bc0ce2bad3
commit ebc65a873e

View File

@@ -67,6 +67,7 @@
#include <linux/if_vlan.h>
#include <net/gso.h>
#include <net/pkt_sched.h>
#include <net/sch_priv.h>
#include <net/pkt_cls.h>
#include <net/tcp.h>
#include <net/flow_dissector.h>
@@ -3157,14 +3158,89 @@ static struct Qdisc_ops cake_qdisc_ops __read_mostly = {
};
MODULE_ALIAS_NET_SCH("cake");
struct cake_mq_sched {
struct mq_sched mq_priv; /* must be first */
};
static void cake_mq_destroy(struct Qdisc *sch)
{
mq_destroy_common(sch);
}
static int cake_mq_init(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
int ret;
ret = mq_init_common(sch, opt, extack, &cake_qdisc_ops);
if (ret)
return ret;
return 0;
}
static int cake_mq_dump(struct Qdisc *sch, struct sk_buff *skb)
{
mq_dump_common(sch, skb);
return 0;
}
static int cake_mq_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
return -EOPNOTSUPP;
}
static int cake_mq_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new,
struct Qdisc **old, struct netlink_ext_ack *extack)
{
NL_SET_ERR_MSG(extack, "can't replace cake_mq sub-qdiscs");
return -EOPNOTSUPP;
}
static const struct Qdisc_class_ops cake_mq_class_ops = {
.select_queue = mq_select_queue,
.graft = cake_mq_graft,
.leaf = mq_leaf,
.find = mq_find,
.walk = mq_walk,
.dump = mq_dump_class,
.dump_stats = mq_dump_class_stats,
};
static struct Qdisc_ops cake_mq_qdisc_ops __read_mostly = {
.cl_ops = &cake_mq_class_ops,
.id = "cake_mq",
.priv_size = sizeof(struct cake_mq_sched),
.init = cake_mq_init,
.destroy = cake_mq_destroy,
.attach = mq_attach,
.change = cake_mq_change,
.change_real_num_tx = mq_change_real_num_tx,
.dump = cake_mq_dump,
.owner = THIS_MODULE,
};
MODULE_ALIAS_NET_SCH("cake_mq");
static int __init cake_module_init(void)
{
return register_qdisc(&cake_qdisc_ops);
int ret;
ret = register_qdisc(&cake_qdisc_ops);
if (ret)
return ret;
ret = register_qdisc(&cake_mq_qdisc_ops);
if (ret)
unregister_qdisc(&cake_qdisc_ops);
return ret;
}
static void __exit cake_module_exit(void)
{
unregister_qdisc(&cake_qdisc_ops);
unregister_qdisc(&cake_mq_qdisc_ops);
}
module_init(cake_module_init)
@@ -3172,3 +3248,4 @@ module_exit(cake_module_exit)
MODULE_AUTHOR("Jonathan Morton");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_DESCRIPTION("The CAKE shaper.");
MODULE_IMPORT_NS("NET_SCHED_INTERNAL");