Skip to content

Commit 3774216

Browse files
Petri Gyntherdavem330
authored andcommitted
net: bcmgenet: fix Tx ring priority programming
GENET MAC has three Tx ring priority registers: - GENET_x_TDMA_PRIORITY0 for queues 0-5 - GENET_x_TDMA_PRIORITY1 for queues 6-11 - GENET_x_TDMA_PRIORITY2 for queues 12-16 Fix bcmgenet_init_multiq() to program them correctly. Signed-off-by: Petri Gynther <pgynther@google.com> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fd2ef0b commit 3774216

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

drivers/net/ethernet/broadcom/genet/bcmgenet.c

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ enum dma_reg {
191191
DMA_STATUS,
192192
DMA_SCB_BURST_SIZE,
193193
DMA_ARB_CTRL,
194-
DMA_PRIORITY,
195-
DMA_RING_PRIORITY,
194+
DMA_PRIORITY_0,
195+
DMA_PRIORITY_1,
196+
DMA_PRIORITY_2,
196197
};
197198

198199
static const u8 bcmgenet_dma_regs_v3plus[] = {
@@ -201,8 +202,9 @@ static const u8 bcmgenet_dma_regs_v3plus[] = {
201202
[DMA_STATUS] = 0x08,
202203
[DMA_SCB_BURST_SIZE] = 0x0C,
203204
[DMA_ARB_CTRL] = 0x2C,
204-
[DMA_PRIORITY] = 0x30,
205-
[DMA_RING_PRIORITY] = 0x38,
205+
[DMA_PRIORITY_0] = 0x30,
206+
[DMA_PRIORITY_1] = 0x34,
207+
[DMA_PRIORITY_2] = 0x38,
206208
};
207209

208210
static const u8 bcmgenet_dma_regs_v2[] = {
@@ -211,17 +213,19 @@ static const u8 bcmgenet_dma_regs_v2[] = {
211213
[DMA_STATUS] = 0x08,
212214
[DMA_SCB_BURST_SIZE] = 0x0C,
213215
[DMA_ARB_CTRL] = 0x30,
214-
[DMA_PRIORITY] = 0x34,
215-
[DMA_RING_PRIORITY] = 0x3C,
216+
[DMA_PRIORITY_0] = 0x34,
217+
[DMA_PRIORITY_1] = 0x38,
218+
[DMA_PRIORITY_2] = 0x3C,
216219
};
217220

218221
static const u8 bcmgenet_dma_regs_v1[] = {
219222
[DMA_CTRL] = 0x00,
220223
[DMA_STATUS] = 0x04,
221224
[DMA_SCB_BURST_SIZE] = 0x0C,
222225
[DMA_ARB_CTRL] = 0x30,
223-
[DMA_PRIORITY] = 0x34,
224-
[DMA_RING_PRIORITY] = 0x3C,
226+
[DMA_PRIORITY_0] = 0x34,
227+
[DMA_PRIORITY_1] = 0x38,
228+
[DMA_PRIORITY_2] = 0x3C,
225229
};
226230

227231
/* Set at runtime once bcmgenet version is known */
@@ -1696,7 +1700,8 @@ static void bcmgenet_init_multiq(struct net_device *dev)
16961700
{
16971701
struct bcmgenet_priv *priv = netdev_priv(dev);
16981702
unsigned int i, dma_enable;
1699-
u32 reg, dma_ctrl, ring_cfg = 0, dma_priority = 0;
1703+
u32 reg, dma_ctrl, ring_cfg = 0;
1704+
u32 dma_priority[3] = {0, 0, 0};
17001705

17011706
if (!netif_is_multiqueue(dev)) {
17021707
netdev_warn(dev, "called with non multi queue aware HW\n");
@@ -1721,22 +1726,25 @@ static void bcmgenet_init_multiq(struct net_device *dev)
17211726

17221727
/* Configure ring as descriptor ring and setup priority */
17231728
ring_cfg |= 1 << i;
1724-
dma_priority |= ((GENET_Q0_PRIORITY + i) <<
1725-
(GENET_MAX_MQ_CNT + 1) * i);
17261729
dma_ctrl |= 1 << (i + DMA_RING_BUF_EN_SHIFT);
1730+
1731+
dma_priority[DMA_PRIO_REG_INDEX(i)] |=
1732+
((GENET_Q0_PRIORITY + i) << DMA_PRIO_REG_SHIFT(i));
17271733
}
17281734

1735+
/* Set ring 16 priority and program the hardware registers */
1736+
dma_priority[DMA_PRIO_REG_INDEX(DESC_INDEX)] |=
1737+
((GENET_Q0_PRIORITY + priv->hw_params->tx_queues) <<
1738+
DMA_PRIO_REG_SHIFT(DESC_INDEX));
1739+
bcmgenet_tdma_writel(priv, dma_priority[0], DMA_PRIORITY_0);
1740+
bcmgenet_tdma_writel(priv, dma_priority[1], DMA_PRIORITY_1);
1741+
bcmgenet_tdma_writel(priv, dma_priority[2], DMA_PRIORITY_2);
1742+
17291743
/* Enable rings */
17301744
reg = bcmgenet_tdma_readl(priv, DMA_RING_CFG);
17311745
reg |= ring_cfg;
17321746
bcmgenet_tdma_writel(priv, reg, DMA_RING_CFG);
17331747

1734-
/* Use configured rings priority and set ring #16 priority */
1735-
reg = bcmgenet_tdma_readl(priv, DMA_RING_PRIORITY);
1736-
reg |= ((GENET_Q0_PRIORITY + priv->hw_params->tx_queues) << 20);
1737-
reg |= dma_priority;
1738-
bcmgenet_tdma_writel(priv, reg, DMA_PRIORITY);
1739-
17401748
/* Configure ring as descriptor ring and re-enable DMA if enabled */
17411749
reg = bcmgenet_tdma_readl(priv, DMA_CTRL);
17421750
reg |= dma_ctrl;

drivers/net/ethernet/broadcom/genet/bcmgenet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@ struct bcmgenet_mib_counters {
401401
#define DMA_ARBITER_MODE_MASK 0x03
402402
#define DMA_RING_BUF_PRIORITY_MASK 0x1F
403403
#define DMA_RING_BUF_PRIORITY_SHIFT 5
404+
#define DMA_PRIO_REG_INDEX(q) ((q) / 6)
405+
#define DMA_PRIO_REG_SHIFT(q) (((q) % 6) * DMA_RING_BUF_PRIORITY_SHIFT)
404406
#define DMA_RATE_ADJ_MASK 0xFF
405407

406408
/* Tx/Rx Dma Descriptor common bits*/

0 commit comments

Comments
 (0)