diff options
author | Jakub Kicinski <jakub.kicinski@netronome.com> | 2018-11-07 20:33:37 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-11-08 19:19:48 -0500 |
commit | bfaee9113f30abfa1f77ecb5e4a6f53a9d4c690c (patch) | |
tree | b395ad6193d47fcd3f868607d48eece07a6d4ef6 /net/sched/sch_api.c | |
parent | 58f8927399eac8f2ac3c7289a2856b8b5516ba30 (diff) |
net: sched: add an offload graft helper
Qdisc graft operation of offload-capable qdiscs performs a few
extra steps which are identical among all the qdiscs. Add
a helper to share this code.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: John Hurley <john.hurley@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_api.c')
-rw-r--r-- | net/sched/sch_api.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index e534825d3d3a..4b3af41cc1d7 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c | |||
@@ -831,6 +831,35 @@ int qdisc_offload_dump_helper(struct Qdisc *sch, enum tc_setup_type type, | |||
831 | } | 831 | } |
832 | EXPORT_SYMBOL(qdisc_offload_dump_helper); | 832 | EXPORT_SYMBOL(qdisc_offload_dump_helper); |
833 | 833 | ||
834 | void qdisc_offload_graft_helper(struct net_device *dev, struct Qdisc *sch, | ||
835 | struct Qdisc *new, struct Qdisc *old, | ||
836 | enum tc_setup_type type, void *type_data, | ||
837 | struct netlink_ext_ack *extack) | ||
838 | { | ||
839 | bool any_qdisc_is_offloaded; | ||
840 | int err; | ||
841 | |||
842 | if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc) | ||
843 | return; | ||
844 | |||
845 | err = dev->netdev_ops->ndo_setup_tc(dev, type, type_data); | ||
846 | |||
847 | /* Don't report error if the graft is part of destroy operation. */ | ||
848 | if (!err || !new || new == &noop_qdisc) | ||
849 | return; | ||
850 | |||
851 | /* Don't report error if the parent, the old child and the new | ||
852 | * one are not offloaded. | ||
853 | */ | ||
854 | any_qdisc_is_offloaded = new->flags & TCQ_F_OFFLOADED; | ||
855 | any_qdisc_is_offloaded |= sch && sch->flags & TCQ_F_OFFLOADED; | ||
856 | any_qdisc_is_offloaded |= old && old->flags & TCQ_F_OFFLOADED; | ||
857 | |||
858 | if (any_qdisc_is_offloaded) | ||
859 | NL_SET_ERR_MSG(extack, "Offloading graft operation failed."); | ||
860 | } | ||
861 | EXPORT_SYMBOL(qdisc_offload_graft_helper); | ||
862 | |||
834 | static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid, | 863 | static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid, |
835 | u32 portid, u32 seq, u16 flags, int event) | 864 | u32 portid, u32 seq, u16 flags, int event) |
836 | { | 865 | { |