ath25: switch default kernel to 5.15
[openwrt/openwrt.git] / target / linux / mvebu / patches-5.10 / 704-net-next-ethernet-marvell-mvnetaMQPrioQueue.patch
1 From e9f7099d0730341b24c057acbf545dd019581db6 Mon Sep 17 00:00:00 2001
2 From: Maxime Chevallier <maxime.chevallier@bootlin.com>
3 Date: Fri, 26 Nov 2021 12:20:55 +0100
4 Subject: net: mvneta: Allow having more than one queue per TC
5
6 The current mqprio implementation assumed that we are only using one
7 queue per TC. Use the offset and count parameters to allow using
8 multiple queues per TC. In that case, the controller will use a standard
9 round-robin algorithm to pick queues assigned to the same TC, with the
10 same priority.
11
12 This only applies to VLAN priorities in ingress traffic, each TC
13 corresponding to a vlan priority.
14
15 Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 ---
18 drivers/net/ethernet/marvell/mvneta.c | 35 ++++++++++++++++++++---------------
19 1 file changed, 20 insertions(+), 15 deletions(-)
20
21 (limited to 'drivers/net/ethernet/marvell/mvneta.c')
22
23 --- a/drivers/net/ethernet/marvell/mvneta.c
24 +++ b/drivers/net/ethernet/marvell/mvneta.c
25 @@ -493,7 +493,6 @@ struct mvneta_port {
26 u8 mcast_count[256];
27 u16 tx_ring_size;
28 u16 rx_ring_size;
29 - u8 prio_tc_map[8];
30
31 phy_interface_t phy_interface;
32 struct device_node *dn;
33 @@ -4922,13 +4921,12 @@ static void mvneta_clear_rx_prio_map(str
34 mvreg_write(pp, MVNETA_VLAN_PRIO_TO_RXQ, 0);
35 }
36
37 -static void mvneta_setup_rx_prio_map(struct mvneta_port *pp)
38 +static void mvneta_map_vlan_prio_to_rxq(struct mvneta_port *pp, u8 pri, u8 rxq)
39 {
40 - u32 val = 0;
41 - int i;
42 + u32 val = mvreg_read(pp, MVNETA_VLAN_PRIO_TO_RXQ);
43
44 - for (i = 0; i < rxq_number; i++)
45 - val |= MVNETA_VLAN_PRIO_RXQ_MAP(i, pp->prio_tc_map[i]);
46 + val &= ~MVNETA_VLAN_PRIO_RXQ_MAP(pri, 0x7);
47 + val |= MVNETA_VLAN_PRIO_RXQ_MAP(pri, rxq);
48
49 mvreg_write(pp, MVNETA_VLAN_PRIO_TO_RXQ, val);
50 }
51 @@ -4937,8 +4935,8 @@ static int mvneta_setup_mqprio(struct ne
52 struct tc_mqprio_qopt_offload *mqprio)
53 {
54 struct mvneta_port *pp = netdev_priv(dev);
55 + int rxq, tc;
56 u8 num_tc;
57 - int i;
58
59 if (mqprio->qopt.hw != TC_MQPRIO_HW_OFFLOAD_TCS)
60 return 0;
61 @@ -4948,21 +4946,28 @@ static int mvneta_setup_mqprio(struct ne
62 if (num_tc > rxq_number)
63 return -EINVAL;
64
65 + mvneta_clear_rx_prio_map(pp);
66 +
67 if (!num_tc) {
68 - mvneta_clear_rx_prio_map(pp);
69 netdev_reset_tc(dev);
70 return 0;
71 }
72
73 - memcpy(pp->prio_tc_map, mqprio->qopt.prio_tc_map,
74 - sizeof(pp->prio_tc_map));
75 + netdev_set_num_tc(dev, mqprio->qopt.num_tc);
76
77 - mvneta_setup_rx_prio_map(pp);
78 + for (tc = 0; tc < mqprio->qopt.num_tc; tc++) {
79 + netdev_set_tc_queue(dev, tc, mqprio->qopt.count[tc],
80 + mqprio->qopt.offset[tc]);
81 +
82 + for (rxq = mqprio->qopt.offset[tc];
83 + rxq < mqprio->qopt.count[tc] + mqprio->qopt.offset[tc];
84 + rxq++) {
85 + if (rxq >= rxq_number)
86 + return -EINVAL;
87
88 - netdev_set_num_tc(dev, mqprio->qopt.num_tc);
89 - for (i = 0; i < mqprio->qopt.num_tc; i++)
90 - netdev_set_tc_queue(dev, i, mqprio->qopt.count[i],
91 - mqprio->qopt.offset[i]);
92 + mvneta_map_vlan_prio_to_rxq(pp, tc, rxq);
93 + }
94 + }
95
96 return 0;
97 }