aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetri Gynther <pgynther@google.com>2014-10-07 12:30:01 -0400
committerDavid S. Miller <davem@davemloft.net>2014-10-07 13:08:43 -0400
commit377421662a1739de5ccb71220a0b10a300addbd8 (patch)
tree78d161cb1e788649bc9c329c4cc61a6c3db30c8e
parentfd2ef0ba3071c92ac6272ab22ea3f2b16d88a4eb (diff)
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>
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.c42
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.h2
2 files changed, 27 insertions, 17 deletions
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index e0a6238a74b4..fff2634b6f34 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -191,8 +191,9 @@ enum dma_reg {
191 DMA_STATUS, 191 DMA_STATUS,
192 DMA_SCB_BURST_SIZE, 192 DMA_SCB_BURST_SIZE,
193 DMA_ARB_CTRL, 193 DMA_ARB_CTRL,
194 DMA_PRIORITY, 194 DMA_PRIORITY_0,
195 DMA_RING_PRIORITY, 195 DMA_PRIORITY_1,
196 DMA_PRIORITY_2,
196}; 197};
197 198
198static const u8 bcmgenet_dma_regs_v3plus[] = { 199static const u8 bcmgenet_dma_regs_v3plus[] = {
@@ -201,8 +202,9 @@ static const u8 bcmgenet_dma_regs_v3plus[] = {
201 [DMA_STATUS] = 0x08, 202 [DMA_STATUS] = 0x08,
202 [DMA_SCB_BURST_SIZE] = 0x0C, 203 [DMA_SCB_BURST_SIZE] = 0x0C,
203 [DMA_ARB_CTRL] = 0x2C, 204 [DMA_ARB_CTRL] = 0x2C,
204 [DMA_PRIORITY] = 0x30, 205 [DMA_PRIORITY_0] = 0x30,
205 [DMA_RING_PRIORITY] = 0x38, 206 [DMA_PRIORITY_1] = 0x34,
207 [DMA_PRIORITY_2] = 0x38,
206}; 208};
207 209
208static const u8 bcmgenet_dma_regs_v2[] = { 210static const u8 bcmgenet_dma_regs_v2[] = {
@@ -211,8 +213,9 @@ static const u8 bcmgenet_dma_regs_v2[] = {
211 [DMA_STATUS] = 0x08, 213 [DMA_STATUS] = 0x08,
212 [DMA_SCB_BURST_SIZE] = 0x0C, 214 [DMA_SCB_BURST_SIZE] = 0x0C,
213 [DMA_ARB_CTRL] = 0x30, 215 [DMA_ARB_CTRL] = 0x30,
214 [DMA_PRIORITY] = 0x34, 216 [DMA_PRIORITY_0] = 0x34,
215 [DMA_RING_PRIORITY] = 0x3C, 217 [DMA_PRIORITY_1] = 0x38,
218 [DMA_PRIORITY_2] = 0x3C,
216}; 219};
217 220
218static const u8 bcmgenet_dma_regs_v1[] = { 221static const u8 bcmgenet_dma_regs_v1[] = {
@@ -220,8 +223,9 @@ static const u8 bcmgenet_dma_regs_v1[] = {
220 [DMA_STATUS] = 0x04, 223 [DMA_STATUS] = 0x04,
221 [DMA_SCB_BURST_SIZE] = 0x0C, 224 [DMA_SCB_BURST_SIZE] = 0x0C,
222 [DMA_ARB_CTRL] = 0x30, 225 [DMA_ARB_CTRL] = 0x30,
223 [DMA_PRIORITY] = 0x34, 226 [DMA_PRIORITY_0] = 0x34,
224 [DMA_RING_PRIORITY] = 0x3C, 227 [DMA_PRIORITY_1] = 0x38,
228 [DMA_PRIORITY_2] = 0x3C,
225}; 229};
226 230
227/* Set at runtime once bcmgenet version is known */ 231/* Set at runtime once bcmgenet version is known */
@@ -1696,7 +1700,8 @@ static void bcmgenet_init_multiq(struct net_device *dev)
1696{ 1700{
1697 struct bcmgenet_priv *priv = netdev_priv(dev); 1701 struct bcmgenet_priv *priv = netdev_priv(dev);
1698 unsigned int i, dma_enable; 1702 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};
1700 1705
1701 if (!netif_is_multiqueue(dev)) { 1706 if (!netif_is_multiqueue(dev)) {
1702 netdev_warn(dev, "called with non multi queue aware HW\n"); 1707 netdev_warn(dev, "called with non multi queue aware HW\n");
@@ -1721,22 +1726,25 @@ static void bcmgenet_init_multiq(struct net_device *dev)
1721 1726
1722 /* Configure ring as descriptor ring and setup priority */ 1727 /* Configure ring as descriptor ring and setup priority */
1723 ring_cfg |= 1 << i; 1728 ring_cfg |= 1 << i;
1724 dma_priority |= ((GENET_Q0_PRIORITY + i) <<
1725 (GENET_MAX_MQ_CNT + 1) * i);
1726 dma_ctrl |= 1 << (i + DMA_RING_BUF_EN_SHIFT); 1729 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));
1727 } 1733 }
1728 1734
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
1729 /* Enable rings */ 1743 /* Enable rings */
1730 reg = bcmgenet_tdma_readl(priv, DMA_RING_CFG); 1744 reg = bcmgenet_tdma_readl(priv, DMA_RING_CFG);
1731 reg |= ring_cfg; 1745 reg |= ring_cfg;
1732 bcmgenet_tdma_writel(priv, reg, DMA_RING_CFG); 1746 bcmgenet_tdma_writel(priv, reg, DMA_RING_CFG);
1733 1747
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
1740 /* Configure ring as descriptor ring and re-enable DMA if enabled */ 1748 /* Configure ring as descriptor ring and re-enable DMA if enabled */
1741 reg = bcmgenet_tdma_readl(priv, DMA_CTRL); 1749 reg = bcmgenet_tdma_readl(priv, DMA_CTRL);
1742 reg |= dma_ctrl; 1750 reg |= dma_ctrl;
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
index 321b1db8c14b..dbf524ea3b19 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
@@ -401,6 +401,8 @@ struct bcmgenet_mib_counters {
401#define DMA_ARBITER_MODE_MASK 0x03 401#define DMA_ARBITER_MODE_MASK 0x03
402#define DMA_RING_BUF_PRIORITY_MASK 0x1F 402#define DMA_RING_BUF_PRIORITY_MASK 0x1F
403#define DMA_RING_BUF_PRIORITY_SHIFT 5 403#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)
404#define DMA_RATE_ADJ_MASK 0xFF 406#define DMA_RATE_ADJ_MASK 0xFF
405 407
406/* Tx/Rx Dma Descriptor common bits*/ 408/* Tx/Rx Dma Descriptor common bits*/