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 --- a/drivers/net/ethernet/marvell/mvneta.c
24 +++ b/drivers/net/ethernet/marvell/mvneta.c
25 @@ -498,7 +498,6 @@ struct mvneta_port {
31 phy_interface_t phy_interface;
32 struct device_node *dn;
33 @@ -4955,13 +4954,12 @@ static void mvneta_clear_rx_prio_map(str
34 mvreg_write(pp, MVNETA_VLAN_PRIO_TO_RXQ, 0);
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)
42 + u32 val = mvreg_read(pp, MVNETA_VLAN_PRIO_TO_RXQ);
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);
49 mvreg_write(pp, MVNETA_VLAN_PRIO_TO_RXQ, val);
51 @@ -4970,8 +4968,8 @@ static int mvneta_setup_mqprio(struct ne
52 struct tc_mqprio_qopt_offload *mqprio)
54 struct mvneta_port *pp = netdev_priv(dev);
59 if (mqprio->qopt.hw != TC_MQPRIO_HW_OFFLOAD_TCS)
61 @@ -4981,21 +4979,28 @@ static int mvneta_setup_mqprio(struct ne
62 if (num_tc > rxq_number)
65 + mvneta_clear_rx_prio_map(pp);
68 - mvneta_clear_rx_prio_map(pp);
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);
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]);
82 + for (rxq = mqprio->qopt.offset[tc];
83 + rxq < mqprio->qopt.count[tc] + mqprio->qopt.offset[tc];
85 + if (rxq >= rxq_number)
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);