]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net/sched: query offload capabilities through ndo_setup_tc()
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 28 Sep 2022 09:51:57 +0000 (12:51 +0300)
committerJakub Kicinski <kuba@kernel.org>
Fri, 30 Sep 2022 01:52:01 +0000 (18:52 -0700)
When adding optional new features to Qdisc offloads, existing drivers
must reject the new configuration until they are coded up to act on it.

Since modifying all drivers in lockstep with the changes in the Qdisc
can create problems of its own, it would be nice if there existed an
automatic opt-in mechanism for offloading optional features.

Jakub proposes that we multiplex one more kind of call through
ndo_setup_tc(): one where the driver populates a Qdisc-specific
capability structure.

First user will be taprio in further changes. Here we are introducing
the definitions for the base functionality.

Link: https://patchwork.kernel.org/project/netdevbpf/patch/20220923163310.3192733-3-vladimir.oltean@nxp.com/
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Co-developed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/netdevice.h
include/net/pkt_sched.h
include/net/sch_generic.h
net/sched/sch_api.c

index 64c3a5864969ea8a4508740c64e6f61a94ae0012..eddf8ee270e74364926cf31b2fa56bb07f4a03d9 100644 (file)
@@ -940,6 +940,7 @@ struct net_device_path_ctx {
 };
 
 enum tc_setup_type {
+       TC_QUERY_CAPS,
        TC_SETUP_QDISC_MQPRIO,
        TC_SETUP_CLSU32,
        TC_SETUP_CLSFLOWER,
index 2ff80cd04c5ca87d4d4624cb8b5f6479fd469a65..34600292fdfba78e22d85fa878cc3847ff7a32e4 100644 (file)
@@ -141,6 +141,11 @@ static inline struct net *qdisc_net(struct Qdisc *q)
        return dev_net(q->dev_queue->dev);
 }
 
+struct tc_query_caps_base {
+       enum tc_setup_type type;
+       void *caps;
+};
+
 struct tc_cbs_qopt_offload {
        u8 enable;
        s32 queue;
index 32819299937d117f64ba74dd7e389cc4aa0849a3..d5517719af4ef22282f0a15b132f8e8a07ae4179 100644 (file)
@@ -677,6 +677,9 @@ qdisc_offload_graft_helper(struct net_device *dev, struct Qdisc *sch,
 {
 }
 #endif
+void qdisc_offload_query_caps(struct net_device *dev,
+                             enum tc_setup_type type,
+                             void *caps, size_t caps_len);
 struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
                          const struct Qdisc_ops *ops,
                          struct netlink_ext_ack *extack);
index db1569fac57c7305767e2fc0b3c29beb8c911565..7c15f1f3da1770e74aa80eaf89a06a3122d5db59 100644 (file)
@@ -868,6 +868,23 @@ void qdisc_offload_graft_helper(struct net_device *dev, struct Qdisc *sch,
 }
 EXPORT_SYMBOL(qdisc_offload_graft_helper);
 
+void qdisc_offload_query_caps(struct net_device *dev,
+                             enum tc_setup_type type,
+                             void *caps, size_t caps_len)
+{
+       const struct net_device_ops *ops = dev->netdev_ops;
+       struct tc_query_caps_base base = {
+               .type = type,
+               .caps = caps,
+       };
+
+       memset(caps, 0, caps_len);
+
+       if (ops->ndo_setup_tc)
+               ops->ndo_setup_tc(dev, TC_QUERY_CAPS, &base);
+}
+EXPORT_SYMBOL(qdisc_offload_query_caps);
+
 static void qdisc_offload_graft_root(struct net_device *dev,
                                     struct Qdisc *new, struct Qdisc *old,
                                     struct netlink_ext_ack *extack)