Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Toke Høiland-Jørgensen and committed by
Paolo Abeni
ebc65a87 bc0ce2ba

+78 -1
+78 -1
net/sched/sch_cake.c
··· 67 67 #include <linux/if_vlan.h> 68 68 #include <net/gso.h> 69 69 #include <net/pkt_sched.h> 70 + #include <net/sch_priv.h> 70 71 #include <net/pkt_cls.h> 71 72 #include <net/tcp.h> 72 73 #include <net/flow_dissector.h> ··· 3158 3157 }; 3159 3158 MODULE_ALIAS_NET_SCH("cake"); 3160 3159 3160 + struct cake_mq_sched { 3161 + struct mq_sched mq_priv; /* must be first */ 3162 + }; 3163 + 3164 + static void cake_mq_destroy(struct Qdisc *sch) 3165 + { 3166 + mq_destroy_common(sch); 3167 + } 3168 + 3169 + static int cake_mq_init(struct Qdisc *sch, struct nlattr *opt, 3170 + struct netlink_ext_ack *extack) 3171 + { 3172 + int ret; 3173 + 3174 + ret = mq_init_common(sch, opt, extack, &cake_qdisc_ops); 3175 + if (ret) 3176 + return ret; 3177 + 3178 + return 0; 3179 + } 3180 + 3181 + static int cake_mq_dump(struct Qdisc *sch, struct sk_buff *skb) 3182 + { 3183 + mq_dump_common(sch, skb); 3184 + return 0; 3185 + } 3186 + 3187 + static int cake_mq_change(struct Qdisc *sch, struct nlattr *opt, 3188 + struct netlink_ext_ack *extack) 3189 + { 3190 + return -EOPNOTSUPP; 3191 + } 3192 + 3193 + static int cake_mq_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new, 3194 + struct Qdisc **old, struct netlink_ext_ack *extack) 3195 + { 3196 + NL_SET_ERR_MSG(extack, "can't replace cake_mq sub-qdiscs"); 3197 + return -EOPNOTSUPP; 3198 + } 3199 + 3200 + static const struct Qdisc_class_ops cake_mq_class_ops = { 3201 + .select_queue = mq_select_queue, 3202 + .graft = cake_mq_graft, 3203 + .leaf = mq_leaf, 3204 + .find = mq_find, 3205 + .walk = mq_walk, 3206 + .dump = mq_dump_class, 3207 + .dump_stats = mq_dump_class_stats, 3208 + }; 3209 + 3210 + static struct Qdisc_ops cake_mq_qdisc_ops __read_mostly = { 3211 + .cl_ops = &cake_mq_class_ops, 3212 + .id = "cake_mq", 3213 + .priv_size = sizeof(struct cake_mq_sched), 3214 + .init = cake_mq_init, 3215 + .destroy = cake_mq_destroy, 3216 + .attach = mq_attach, 3217 + .change = cake_mq_change, 3218 + .change_real_num_tx = mq_change_real_num_tx, 3219 + .dump = cake_mq_dump, 3220 + .owner = THIS_MODULE, 3221 + }; 3222 + MODULE_ALIAS_NET_SCH("cake_mq"); 3223 + 3161 3224 static int __init cake_module_init(void) 3162 3225 { 3163 - return register_qdisc(&cake_qdisc_ops); 3226 + int ret; 3227 + 3228 + ret = register_qdisc(&cake_qdisc_ops); 3229 + if (ret) 3230 + return ret; 3231 + 3232 + ret = register_qdisc(&cake_mq_qdisc_ops); 3233 + if (ret) 3234 + unregister_qdisc(&cake_qdisc_ops); 3235 + 3236 + return ret; 3164 3237 } 3165 3238 3166 3239 static void __exit cake_module_exit(void) 3167 3240 { 3168 3241 unregister_qdisc(&cake_qdisc_ops); 3242 + unregister_qdisc(&cake_mq_qdisc_ops); 3169 3243 } 3170 3244 3171 3245 module_init(cake_module_init) ··· 3248 3172 MODULE_AUTHOR("Jonathan Morton"); 3249 3173 MODULE_LICENSE("Dual BSD/GPL"); 3250 3174 MODULE_DESCRIPTION("The CAKE shaper."); 3175 + MODULE_IMPORT_NS("NET_SCHED_INTERNAL");