net: sched: add an offload dump helper
Qdisc dump 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>
This commit is contained in:
Родитель
80b6265c0f
Коммит
b592843c67
|
@ -579,6 +579,18 @@ void qdisc_put(struct Qdisc *qdisc);
|
||||||
void qdisc_put_unlocked(struct Qdisc *qdisc);
|
void qdisc_put_unlocked(struct Qdisc *qdisc);
|
||||||
void qdisc_tree_reduce_backlog(struct Qdisc *qdisc, unsigned int n,
|
void qdisc_tree_reduce_backlog(struct Qdisc *qdisc, unsigned int n,
|
||||||
unsigned int len);
|
unsigned int len);
|
||||||
|
#ifdef CONFIG_NET_SCHED
|
||||||
|
int qdisc_offload_dump_helper(struct Qdisc *q, enum tc_setup_type type,
|
||||||
|
void *type_data);
|
||||||
|
#else
|
||||||
|
static inline int
|
||||||
|
qdisc_offload_dump_helper(struct Qdisc *q, enum tc_setup_type type,
|
||||||
|
void *type_data)
|
||||||
|
{
|
||||||
|
q->flags &= ~TCQ_F_OFFLOADED;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
|
struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
|
||||||
const struct Qdisc_ops *ops,
|
const struct Qdisc_ops *ops,
|
||||||
struct netlink_ext_ack *extack);
|
struct netlink_ext_ack *extack);
|
||||||
|
|
|
@ -810,6 +810,27 @@ void qdisc_tree_reduce_backlog(struct Qdisc *sch, unsigned int n,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(qdisc_tree_reduce_backlog);
|
EXPORT_SYMBOL(qdisc_tree_reduce_backlog);
|
||||||
|
|
||||||
|
int qdisc_offload_dump_helper(struct Qdisc *sch, enum tc_setup_type type,
|
||||||
|
void *type_data)
|
||||||
|
{
|
||||||
|
struct net_device *dev = qdisc_dev(sch);
|
||||||
|
int err;
|
||||||
|
|
||||||
|
sch->flags &= ~TCQ_F_OFFLOADED;
|
||||||
|
if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err = dev->netdev_ops->ndo_setup_tc(dev, type, type_data);
|
||||||
|
if (err == -EOPNOTSUPP)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!err)
|
||||||
|
sch->flags |= TCQ_F_OFFLOADED;
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(qdisc_offload_dump_helper);
|
||||||
|
|
||||||
static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,
|
static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,
|
||||||
u32 portid, u32 seq, u16 flags, int event)
|
u32 portid, u32 seq, u16 flags, int event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -251,7 +251,6 @@ static int prio_init(struct Qdisc *sch, struct nlattr *opt,
|
||||||
|
|
||||||
static int prio_dump_offload(struct Qdisc *sch)
|
static int prio_dump_offload(struct Qdisc *sch)
|
||||||
{
|
{
|
||||||
struct net_device *dev = qdisc_dev(sch);
|
|
||||||
struct tc_prio_qopt_offload hw_stats = {
|
struct tc_prio_qopt_offload hw_stats = {
|
||||||
.command = TC_PRIO_STATS,
|
.command = TC_PRIO_STATS,
|
||||||
.handle = sch->handle,
|
.handle = sch->handle,
|
||||||
|
@ -263,21 +262,8 @@ static int prio_dump_offload(struct Qdisc *sch)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int err;
|
|
||||||
|
|
||||||
sch->flags &= ~TCQ_F_OFFLOADED;
|
return qdisc_offload_dump_helper(sch, TC_SETUP_QDISC_PRIO, &hw_stats);
|
||||||
if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_PRIO,
|
|
||||||
&hw_stats);
|
|
||||||
if (err == -EOPNOTSUPP)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!err)
|
|
||||||
sch->flags |= TCQ_F_OFFLOADED;
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int prio_dump(struct Qdisc *sch, struct sk_buff *skb)
|
static int prio_dump(struct Qdisc *sch, struct sk_buff *skb)
|
||||||
|
|
|
@ -281,7 +281,6 @@ static int red_init(struct Qdisc *sch, struct nlattr *opt,
|
||||||
|
|
||||||
static int red_dump_offload_stats(struct Qdisc *sch, struct tc_red_qopt *opt)
|
static int red_dump_offload_stats(struct Qdisc *sch, struct tc_red_qopt *opt)
|
||||||
{
|
{
|
||||||
struct net_device *dev = qdisc_dev(sch);
|
|
||||||
struct tc_red_qopt_offload hw_stats = {
|
struct tc_red_qopt_offload hw_stats = {
|
||||||
.command = TC_RED_STATS,
|
.command = TC_RED_STATS,
|
||||||
.handle = sch->handle,
|
.handle = sch->handle,
|
||||||
|
@ -291,22 +290,8 @@ static int red_dump_offload_stats(struct Qdisc *sch, struct tc_red_qopt *opt)
|
||||||
.stats.qstats = &sch->qstats,
|
.stats.qstats = &sch->qstats,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
int err;
|
|
||||||
|
|
||||||
sch->flags &= ~TCQ_F_OFFLOADED;
|
return qdisc_offload_dump_helper(sch, TC_SETUP_QDISC_RED, &hw_stats);
|
||||||
|
|
||||||
if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_RED,
|
|
||||||
&hw_stats);
|
|
||||||
if (err == -EOPNOTSUPP)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!err)
|
|
||||||
sch->flags |= TCQ_F_OFFLOADED;
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
|
static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче