Skip to content

Commit a0daae1

Browse files
joabreudavem330
authored andcommitted
net: stmmac: Disable flow ctrl for RX AVB queues and really enable TX AVB queues
Flow control must be disabled for AVB enabled queues and TX AVB queues must be enabled by setting BIT(2) of TXQEN. Correct this by passing the queue mode to DMA callbacks and by checking in these functions wether we are in AVB performing the necessary adjustments. Signed-off-by: Jose Abreu <[email protected]> Cc: David S. Miller <[email protected]> Cc: Joao Pinto <[email protected]> Cc: Giuseppe Cavallaro <[email protected]> Cc: Alexandre Torgue <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 52a7623 commit a0daae1

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

drivers/net/ethernet/stmicro/stmmac/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,9 @@ struct stmmac_dma_ops {
442442
void (*dma_mode)(void __iomem *ioaddr, int txmode, int rxmode,
443443
int rxfifosz);
444444
void (*dma_rx_mode)(void __iomem *ioaddr, int mode, u32 channel,
445-
int fifosz);
445+
int fifosz, u8 qmode);
446446
void (*dma_tx_mode)(void __iomem *ioaddr, int mode, u32 channel,
447-
int fifosz);
447+
int fifosz, u8 qmode);
448448
/* To track extra statistic (if supported) */
449449
void (*dma_diagnostic_fr) (void *data, struct stmmac_extra_stats *x,
450450
void __iomem *ioaddr);

drivers/net/ethernet/stmicro/stmmac/dwmac4.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ enum power_event {
225225
#define MTL_CHAN_RX_DEBUG(x) (MTL_CHANX_BASE_ADDR(x) + 0x38)
226226

227227
#define MTL_OP_MODE_RSF BIT(5)
228+
#define MTL_OP_MODE_TXQEN_MASK GENMASK(3, 2)
229+
#define MTL_OP_MODE_TXQEN_AV BIT(2)
228230
#define MTL_OP_MODE_TXQEN BIT(3)
229231
#define MTL_OP_MODE_TSF BIT(1)
230232

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static void dwmac4_rx_watchdog(void __iomem *ioaddr, u32 riwt, u32 number_chan)
191191
}
192192

193193
static void dwmac4_dma_rx_chan_op_mode(void __iomem *ioaddr, int mode,
194-
u32 channel, int fifosz)
194+
u32 channel, int fifosz, u8 qmode)
195195
{
196196
unsigned int rqs = fifosz / 256 - 1;
197197
u32 mtl_rx_op, mtl_rx_int;
@@ -218,8 +218,10 @@ static void dwmac4_dma_rx_chan_op_mode(void __iomem *ioaddr, int mode,
218218
mtl_rx_op &= ~MTL_OP_MODE_RQS_MASK;
219219
mtl_rx_op |= rqs << MTL_OP_MODE_RQS_SHIFT;
220220

221-
/* enable flow control only if each channel gets 4 KiB or more FIFO */
222-
if (fifosz >= 4096) {
221+
/* Enable flow control only if each channel gets 4 KiB or more FIFO and
222+
* only if channel is not an AVB channel.
223+
*/
224+
if ((fifosz >= 4096) && (qmode != MTL_QUEUE_AVB)) {
223225
unsigned int rfd, rfa;
224226

225227
mtl_rx_op |= MTL_OP_MODE_EHFC;
@@ -271,7 +273,7 @@ static void dwmac4_dma_rx_chan_op_mode(void __iomem *ioaddr, int mode,
271273
}
272274

273275
static void dwmac4_dma_tx_chan_op_mode(void __iomem *ioaddr, int mode,
274-
u32 channel, int fifosz)
276+
u32 channel, int fifosz, u8 qmode)
275277
{
276278
u32 mtl_tx_op = readl(ioaddr + MTL_CHAN_TX_OP_MODE(channel));
277279
unsigned int tqs = fifosz / 256 - 1;
@@ -311,7 +313,11 @@ static void dwmac4_dma_tx_chan_op_mode(void __iomem *ioaddr, int mode,
311313
* reflect the available fifo size per queue (total fifo size / number
312314
* of enabled queues).
313315
*/
314-
mtl_tx_op |= MTL_OP_MODE_TXQEN;
316+
mtl_tx_op &= ~MTL_OP_MODE_TXQEN_MASK;
317+
if (qmode != MTL_QUEUE_AVB)
318+
mtl_tx_op |= MTL_OP_MODE_TXQEN;
319+
else
320+
mtl_tx_op |= MTL_OP_MODE_TXQEN_AV;
315321
mtl_tx_op &= ~MTL_OP_MODE_TQS_MASK;
316322
mtl_tx_op |= tqs << MTL_OP_MODE_TQS_SHIFT;
317323

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,7 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
17541754
u32 txmode = 0;
17551755
u32 rxmode = 0;
17561756
u32 chan = 0;
1757+
u8 qmode = 0;
17571758

17581759
if (rxfifosz == 0)
17591760
rxfifosz = priv->dma_cap.rx_fifo_size;
@@ -1785,13 +1786,19 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
17851786

17861787
/* configure all channels */
17871788
if (priv->synopsys_id >= DWMAC_CORE_4_00) {
1788-
for (chan = 0; chan < rx_channels_count; chan++)
1789+
for (chan = 0; chan < rx_channels_count; chan++) {
1790+
qmode = priv->plat->rx_queues_cfg[chan].mode_to_use;
1791+
17891792
priv->hw->dma->dma_rx_mode(priv->ioaddr, rxmode, chan,
1790-
rxfifosz);
1793+
rxfifosz, qmode);
1794+
}
1795+
1796+
for (chan = 0; chan < tx_channels_count; chan++) {
1797+
qmode = priv->plat->tx_queues_cfg[chan].mode_to_use;
17911798

1792-
for (chan = 0; chan < tx_channels_count; chan++)
17931799
priv->hw->dma->dma_tx_mode(priv->ioaddr, txmode, chan,
1794-
txfifosz);
1800+
txfifosz, qmode);
1801+
}
17951802
} else {
17961803
priv->hw->dma->dma_mode(priv->ioaddr, txmode, rxmode,
17971804
rxfifosz);
@@ -1954,6 +1961,8 @@ static void stmmac_tx_err(struct stmmac_priv *priv, u32 chan)
19541961
static void stmmac_set_dma_operation_mode(struct stmmac_priv *priv, u32 txmode,
19551962
u32 rxmode, u32 chan)
19561963
{
1964+
u8 rxqmode = priv->plat->rx_queues_cfg[chan].mode_to_use;
1965+
u8 txqmode = priv->plat->tx_queues_cfg[chan].mode_to_use;
19571966
u32 rx_channels_count = priv->plat->rx_queues_to_use;
19581967
u32 tx_channels_count = priv->plat->tx_queues_to_use;
19591968
int rxfifosz = priv->plat->rx_fifo_size;
@@ -1970,9 +1979,9 @@ static void stmmac_set_dma_operation_mode(struct stmmac_priv *priv, u32 txmode,
19701979

19711980
if (priv->synopsys_id >= DWMAC_CORE_4_00) {
19721981
priv->hw->dma->dma_rx_mode(priv->ioaddr, rxmode, chan,
1973-
rxfifosz);
1982+
rxfifosz, rxqmode);
19741983
priv->hw->dma->dma_tx_mode(priv->ioaddr, txmode, chan,
1975-
txfifosz);
1984+
txfifosz, txqmode);
19761985
} else {
19771986
priv->hw->dma->dma_mode(priv->ioaddr, txmode, rxmode,
19781987
rxfifosz);

0 commit comments

Comments
 (0)