Skip to content

Commit b3da86d

Browse files
wp9006kuba-moo
authored andcommitted
net: stmmac: fix rx queue priority assignment
The driver should ensure that same priority is not mapped to multiple rx queues. From DesignWare Cores Ethernet Quality-of-Service Databook, section 17.1.29 MAC_RxQ_Ctrl2: "[...]The software must ensure that the content of this field is mutually exclusive to the PSRQ fields for other queues, that is, the same priority is not mapped to multiple Rx queues[...]" Previously rx_queue_priority() function was: - clearing all priorities from a queue - adding new priorities to that queue After this patch it will: - first assign new priorities to a queue - then remove those priorities from all other queues - keep other priorities previously assigned to that queue Fixes: a8f5102 ("net: stmmac: TX and RX queue priority configuration") Fixes: 2142754 ("net: stmmac: Add MAC related callbacks for XGMAC2") Signed-off-by: Piotr Wejman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c644920 commit b3da86d

File tree

2 files changed

+62
-16
lines changed

2 files changed

+62
-16
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,41 @@ static void dwmac4_rx_queue_priority(struct mac_device_info *hw,
9292
u32 prio, u32 queue)
9393
{
9494
void __iomem *ioaddr = hw->pcsr;
95-
u32 base_register;
96-
u32 value;
95+
u32 clear_mask = 0;
96+
u32 ctrl2, ctrl3;
97+
int i;
9798

98-
base_register = (queue < 4) ? GMAC_RXQ_CTRL2 : GMAC_RXQ_CTRL3;
99-
if (queue >= 4)
100-
queue -= 4;
99+
ctrl2 = readl(ioaddr + GMAC_RXQ_CTRL2);
100+
ctrl3 = readl(ioaddr + GMAC_RXQ_CTRL3);
101101

102-
value = readl(ioaddr + base_register);
102+
/* The software must ensure that the same priority
103+
* is not mapped to multiple Rx queues
104+
*/
105+
for (i = 0; i < 4; i++)
106+
clear_mask |= ((prio << GMAC_RXQCTRL_PSRQX_SHIFT(i)) &
107+
GMAC_RXQCTRL_PSRQX_MASK(i));
108+
109+
ctrl2 &= ~clear_mask;
110+
ctrl3 &= ~clear_mask;
111+
112+
/* First assign new priorities to a queue, then
113+
* clear them from others queues
114+
*/
115+
if (queue < 4) {
116+
ctrl2 |= (prio << GMAC_RXQCTRL_PSRQX_SHIFT(queue)) &
117+
GMAC_RXQCTRL_PSRQX_MASK(queue);
103118

104-
value &= ~GMAC_RXQCTRL_PSRQX_MASK(queue);
105-
value |= (prio << GMAC_RXQCTRL_PSRQX_SHIFT(queue)) &
119+
writel(ctrl2, ioaddr + GMAC_RXQ_CTRL2);
120+
writel(ctrl3, ioaddr + GMAC_RXQ_CTRL3);
121+
} else {
122+
queue -= 4;
123+
124+
ctrl3 |= (prio << GMAC_RXQCTRL_PSRQX_SHIFT(queue)) &
106125
GMAC_RXQCTRL_PSRQX_MASK(queue);
107-
writel(value, ioaddr + base_register);
126+
127+
writel(ctrl3, ioaddr + GMAC_RXQ_CTRL3);
128+
writel(ctrl2, ioaddr + GMAC_RXQ_CTRL2);
129+
}
108130
}
109131

110132
static void dwmac4_tx_queue_priority(struct mac_device_info *hw,

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,41 @@ static void dwxgmac2_rx_queue_prio(struct mac_device_info *hw, u32 prio,
105105
u32 queue)
106106
{
107107
void __iomem *ioaddr = hw->pcsr;
108-
u32 value, reg;
108+
u32 clear_mask = 0;
109+
u32 ctrl2, ctrl3;
110+
int i;
109111

110-
reg = (queue < 4) ? XGMAC_RXQ_CTRL2 : XGMAC_RXQ_CTRL3;
111-
if (queue >= 4)
112+
ctrl2 = readl(ioaddr + XGMAC_RXQ_CTRL2);
113+
ctrl3 = readl(ioaddr + XGMAC_RXQ_CTRL3);
114+
115+
/* The software must ensure that the same priority
116+
* is not mapped to multiple Rx queues
117+
*/
118+
for (i = 0; i < 4; i++)
119+
clear_mask |= ((prio << XGMAC_PSRQ_SHIFT(i)) &
120+
XGMAC_PSRQ(i));
121+
122+
ctrl2 &= ~clear_mask;
123+
ctrl3 &= ~clear_mask;
124+
125+
/* First assign new priorities to a queue, then
126+
* clear them from others queues
127+
*/
128+
if (queue < 4) {
129+
ctrl2 |= (prio << XGMAC_PSRQ_SHIFT(queue)) &
130+
XGMAC_PSRQ(queue);
131+
132+
writel(ctrl2, ioaddr + XGMAC_RXQ_CTRL2);
133+
writel(ctrl3, ioaddr + XGMAC_RXQ_CTRL3);
134+
} else {
112135
queue -= 4;
113136

114-
value = readl(ioaddr + reg);
115-
value &= ~XGMAC_PSRQ(queue);
116-
value |= (prio << XGMAC_PSRQ_SHIFT(queue)) & XGMAC_PSRQ(queue);
137+
ctrl3 |= (prio << XGMAC_PSRQ_SHIFT(queue)) &
138+
XGMAC_PSRQ(queue);
117139

118-
writel(value, ioaddr + reg);
140+
writel(ctrl3, ioaddr + XGMAC_RXQ_CTRL3);
141+
writel(ctrl2, ioaddr + XGMAC_RXQ_CTRL2);
142+
}
119143
}
120144

121145
static void dwxgmac2_tx_queue_prio(struct mac_device_info *hw, u32 prio,

0 commit comments

Comments
 (0)