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
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
12 This only applies to VLAN priorities in ingress traffic, each TC
13 corresponding to a vlan priority.
15 Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
18 drivers/net/ethernet/marvell/mvneta.c | 35 ++++++++++++++++++++---------------
19 1 file changed, 20 insertions(+), 15 deletions(-)
21 (limited to 'drivers/net/ethernet/marvell/mvneta.c')
23 diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
24 index d3ce87e69d2a8..aba452e8abfe6 100644
25 --- a/drivers/net/ethernet/marvell/mvneta.c
26 +++ b/drivers/net/ethernet/marvell/mvneta.c
27 @@ -493,7 +493,6 @@ struct mvneta_port {
33 phy_interface_t phy_interface;
34 struct device_node *dn;
35 @@ -4897,13 +4896,12 @@ static void mvneta_clear_rx_prio_map(struct mvneta_port *pp)
36 mvreg_write(pp, MVNETA_VLAN_PRIO_TO_RXQ, 0);
39 -static void mvneta_setup_rx_prio_map(struct mvneta_port *pp)
40 +static void mvneta_map_vlan_prio_to_rxq(struct mvneta_port *pp, u8 pri, u8 rxq)
44 + u32 val = mvreg_read(pp, MVNETA_VLAN_PRIO_TO_RXQ);
46 - for (i = 0; i < rxq_number; i++)
47 - val |= MVNETA_VLAN_PRIO_RXQ_MAP(i, pp->prio_tc_map[i]);
48 + val &= ~MVNETA_VLAN_PRIO_RXQ_MAP(pri, 0x7);
49 + val |= MVNETA_VLAN_PRIO_RXQ_MAP(pri, rxq);
51 mvreg_write(pp, MVNETA_VLAN_PRIO_TO_RXQ, val);
53 @@ -4912,8 +4910,8 @@ static int mvneta_setup_mqprio(struct net_device *dev,
54 struct tc_mqprio_qopt_offload *mqprio)
56 struct mvneta_port *pp = netdev_priv(dev);
61 if (mqprio->qopt.hw != TC_MQPRIO_HW_OFFLOAD_TCS)
63 @@ -4923,21 +4921,28 @@ static int mvneta_setup_mqprio(struct net_device *dev,
64 if (num_tc > rxq_number)
67 + mvneta_clear_rx_prio_map(pp);
70 - mvneta_clear_rx_prio_map(pp);
75 - memcpy(pp->prio_tc_map, mqprio->qopt.prio_tc_map,
76 - sizeof(pp->prio_tc_map));
77 + netdev_set_num_tc(dev, mqprio->qopt.num_tc);
79 + for (tc = 0; tc < mqprio->qopt.num_tc; tc++) {
80 + netdev_set_tc_queue(dev, tc, mqprio->qopt.count[tc],
81 + mqprio->qopt.offset[tc]);
83 - mvneta_setup_rx_prio_map(pp);
84 + for (rxq = mqprio->qopt.offset[tc];
85 + rxq < mqprio->qopt.count[tc] + mqprio->qopt.offset[tc];
87 + if (rxq >= rxq_number)
90 - netdev_set_num_tc(dev, mqprio->qopt.num_tc);
91 - for (i = 0; i < mqprio->qopt.num_tc; i++)
92 - netdev_set_tc_queue(dev, i, mqprio->qopt.count[i],
93 - mqprio->qopt.offset[i]);
94 + mvneta_map_vlan_prio_to_rxq(pp, tc, rxq);