net/sched: refactor mqprio qopt reconstruction to a library function
The taprio qdisc will need to reconstruct a struct tc_mqprio_qopt from netdev settings once more in a future patch, but this code was already written twice, once in taprio and once in mqprio. Refactor the code to a helper in the common mqprio library. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
1dfe086dd7
commit
9dd6ad674c
|
@ -406,7 +406,7 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb)
|
||||||
struct nlattr *nla = (struct nlattr *)skb_tail_pointer(skb);
|
struct nlattr *nla = (struct nlattr *)skb_tail_pointer(skb);
|
||||||
struct tc_mqprio_qopt opt = { 0 };
|
struct tc_mqprio_qopt opt = { 0 };
|
||||||
struct Qdisc *qdisc;
|
struct Qdisc *qdisc;
|
||||||
unsigned int ntx, tc;
|
unsigned int ntx;
|
||||||
|
|
||||||
sch->q.qlen = 0;
|
sch->q.qlen = 0;
|
||||||
gnet_stats_basic_sync_init(&sch->bstats);
|
gnet_stats_basic_sync_init(&sch->bstats);
|
||||||
|
@ -430,15 +430,9 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb)
|
||||||
spin_unlock_bh(qdisc_lock(qdisc));
|
spin_unlock_bh(qdisc_lock(qdisc));
|
||||||
}
|
}
|
||||||
|
|
||||||
opt.num_tc = netdev_get_num_tc(dev);
|
mqprio_qopt_reconstruct(dev, &opt);
|
||||||
memcpy(opt.prio_tc_map, dev->prio_tc_map, sizeof(opt.prio_tc_map));
|
|
||||||
opt.hw = priv->hw_offload;
|
opt.hw = priv->hw_offload;
|
||||||
|
|
||||||
for (tc = 0; tc < netdev_get_num_tc(dev); tc++) {
|
|
||||||
opt.count[tc] = dev->tc_to_txq[tc].count;
|
|
||||||
opt.offset[tc] = dev->tc_to_txq[tc].offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
|
if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
|
||||||
goto nla_put_failure;
|
goto nla_put_failure;
|
||||||
|
|
||||||
|
|
|
@ -100,4 +100,18 @@ int mqprio_validate_qopt(struct net_device *dev, struct tc_mqprio_qopt *qopt,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(mqprio_validate_qopt);
|
EXPORT_SYMBOL_GPL(mqprio_validate_qopt);
|
||||||
|
|
||||||
|
void mqprio_qopt_reconstruct(struct net_device *dev, struct tc_mqprio_qopt *qopt)
|
||||||
|
{
|
||||||
|
int tc, num_tc = netdev_get_num_tc(dev);
|
||||||
|
|
||||||
|
qopt->num_tc = num_tc;
|
||||||
|
memcpy(qopt->prio_tc_map, dev->prio_tc_map, sizeof(qopt->prio_tc_map));
|
||||||
|
|
||||||
|
for (tc = 0; tc < num_tc; tc++) {
|
||||||
|
qopt->count[tc] = dev->tc_to_txq[tc].count;
|
||||||
|
qopt->offset[tc] = dev->tc_to_txq[tc].offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(mqprio_qopt_reconstruct);
|
||||||
|
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
|
|
@ -12,5 +12,7 @@ int mqprio_validate_qopt(struct net_device *dev, struct tc_mqprio_qopt *qopt,
|
||||||
bool validate_queue_counts,
|
bool validate_queue_counts,
|
||||||
bool allow_overlapping_txqs,
|
bool allow_overlapping_txqs,
|
||||||
struct netlink_ext_ack *extack);
|
struct netlink_ext_ack *extack);
|
||||||
|
void mqprio_qopt_reconstruct(struct net_device *dev,
|
||||||
|
struct tc_mqprio_qopt *qopt);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1948,18 +1948,11 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb)
|
||||||
struct sched_gate_list *oper, *admin;
|
struct sched_gate_list *oper, *admin;
|
||||||
struct tc_mqprio_qopt opt = { 0 };
|
struct tc_mqprio_qopt opt = { 0 };
|
||||||
struct nlattr *nest, *sched_nest;
|
struct nlattr *nest, *sched_nest;
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
oper = rtnl_dereference(q->oper_sched);
|
oper = rtnl_dereference(q->oper_sched);
|
||||||
admin = rtnl_dereference(q->admin_sched);
|
admin = rtnl_dereference(q->admin_sched);
|
||||||
|
|
||||||
opt.num_tc = netdev_get_num_tc(dev);
|
mqprio_qopt_reconstruct(dev, &opt);
|
||||||
memcpy(opt.prio_tc_map, dev->prio_tc_map, sizeof(opt.prio_tc_map));
|
|
||||||
|
|
||||||
for (i = 0; i < netdev_get_num_tc(dev); i++) {
|
|
||||||
opt.count[i] = dev->tc_to_txq[i].count;
|
|
||||||
opt.offset[i] = dev->tc_to_txq[i].offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
nest = nla_nest_start_noflag(skb, TCA_OPTIONS);
|
nest = nla_nest_start_noflag(skb, TCA_OPTIONS);
|
||||||
if (!nest)
|
if (!nest)
|
||||||
|
|
Loading…
Reference in New Issue