summaryrefslogtreecommitdiff
path: root/net/sched/sch_mqprio_lib.c
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2023-02-04 15:53:02 +0200
committerDavid S. Miller <davem@davemloft.net>2023-02-06 10:06:44 +0000
commit9dd6ad674cc74a62cc85de6e02cb29d47e9c4eb5 (patch)
treee193209fedbbf8e51baf1dbf7f9165c74a0cc61e /net/sched/sch_mqprio_lib.c
parent1dfe086dd7efb36d3d619a90782c6ca186a1bae9 (diff)
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>
Diffstat (limited to 'net/sched/sch_mqprio_lib.c')
-rw-r--r--net/sched/sch_mqprio_lib.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/net/sched/sch_mqprio_lib.c b/net/sched/sch_mqprio_lib.c
index e782b412a000..c58a533b8ec5 100644
--- a/net/sched/sch_mqprio_lib.c
+++ b/net/sched/sch_mqprio_lib.c
@@ -100,4 +100,18 @@ int mqprio_validate_qopt(struct net_device *dev, struct tc_mqprio_qopt *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");