aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <john@phrozen.org>2017-08-09 06:09:32 -0400
committerDavid S. Miller <davem@davemloft.net>2017-08-10 01:45:36 -0400
commit6427dc1da51dfc47d65caf86e45e8338d1a3905c (patch)
tree3ae2136d010d2f8fd32eea439511d645269767aa
parent0c07ce7f1a4c2f64bc9c8a67397010772a78647a (diff)
net-next: mediatek: bring up QDMA RX ring 0
This patch is in preparation for adding HW flow and QoS offloading. For those features to work, the driver needs to bring up the first QDMA RX ring. This ring is used by the PPE offloading HW. Signed-off-by: John Crisp in <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mediatek/mtk_eth_soc.c36
-rw-r--r--drivers/net/ethernet/mediatek/mtk_eth_soc.h3
2 files changed, 29 insertions, 10 deletions
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index acf2b3b8009c..5e81a7263654 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1285,9 +1285,19 @@ static void mtk_tx_clean(struct mtk_eth *eth)
1285 1285
1286static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag) 1286static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag)
1287{ 1287{
1288 struct mtk_rx_ring *ring = &eth->rx_ring[ring_no]; 1288 struct mtk_rx_ring *ring;
1289 int rx_data_len, rx_dma_size; 1289 int rx_data_len, rx_dma_size;
1290 int i; 1290 int i;
1291 u32 offset = 0;
1292
1293 if (rx_flag == MTK_RX_FLAGS_QDMA) {
1294 if (ring_no)
1295 return -EINVAL;
1296 ring = &eth->rx_ring_qdma;
1297 offset = 0x1000;
1298 } else {
1299 ring = &eth->rx_ring[ring_no];
1300 }
1291 1301
1292 if (rx_flag == MTK_RX_FLAGS_HWLRO) { 1302 if (rx_flag == MTK_RX_FLAGS_HWLRO) {
1293 rx_data_len = MTK_MAX_LRO_RX_LENGTH; 1303 rx_data_len = MTK_MAX_LRO_RX_LENGTH;
@@ -1337,17 +1347,16 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag)
1337 */ 1347 */
1338 wmb(); 1348 wmb();
1339 1349
1340 mtk_w32(eth, ring->phys, MTK_PRX_BASE_PTR_CFG(ring_no)); 1350 mtk_w32(eth, ring->phys, MTK_PRX_BASE_PTR_CFG(ring_no) + offset);
1341 mtk_w32(eth, rx_dma_size, MTK_PRX_MAX_CNT_CFG(ring_no)); 1351 mtk_w32(eth, rx_dma_size, MTK_PRX_MAX_CNT_CFG(ring_no) + offset);
1342 mtk_w32(eth, ring->calc_idx, ring->crx_idx_reg); 1352 mtk_w32(eth, ring->calc_idx, ring->crx_idx_reg + offset);
1343 mtk_w32(eth, MTK_PST_DRX_IDX_CFG(ring_no), MTK_PDMA_RST_IDX); 1353 mtk_w32(eth, MTK_PST_DRX_IDX_CFG(ring_no), MTK_PDMA_RST_IDX + offset);
1344 1354
1345 return 0; 1355 return 0;
1346} 1356}
1347 1357
1348static void mtk_rx_clean(struct mtk_eth *eth, int ring_no) 1358static void mtk_rx_clean(struct mtk_eth *eth, struct mtk_rx_ring *ring)
1349{ 1359{
1350 struct mtk_rx_ring *ring = &eth->rx_ring[ring_no];
1351 int i; 1360 int i;
1352 1361
1353 if (ring->data && ring->dma) { 1362 if (ring->data && ring->dma) {
@@ -1673,6 +1682,10 @@ static int mtk_dma_init(struct mtk_eth *eth)
1673 if (err) 1682 if (err)
1674 return err; 1683 return err;
1675 1684
1685 err = mtk_rx_alloc(eth, 0, MTK_RX_FLAGS_QDMA);
1686 if (err)
1687 return err;
1688
1676 err = mtk_rx_alloc(eth, 0, MTK_RX_FLAGS_NORMAL); 1689 err = mtk_rx_alloc(eth, 0, MTK_RX_FLAGS_NORMAL);
1677 if (err) 1690 if (err)
1678 return err; 1691 return err;
@@ -1712,12 +1725,13 @@ static void mtk_dma_free(struct mtk_eth *eth)
1712 eth->phy_scratch_ring = 0; 1725 eth->phy_scratch_ring = 0;
1713 } 1726 }
1714 mtk_tx_clean(eth); 1727 mtk_tx_clean(eth);
1715 mtk_rx_clean(eth, 0); 1728 mtk_rx_clean(eth, &eth->rx_ring[0]);
1729 mtk_rx_clean(eth, &eth->rx_ring_qdma);
1716 1730
1717 if (eth->hwlro) { 1731 if (eth->hwlro) {
1718 mtk_hwlro_rx_uninit(eth); 1732 mtk_hwlro_rx_uninit(eth);
1719 for (i = 1; i < MTK_MAX_RX_RING_NUM; i++) 1733 for (i = 1; i < MTK_MAX_RX_RING_NUM; i++)
1720 mtk_rx_clean(eth, i); 1734 mtk_rx_clean(eth, &eth->rx_ring[i]);
1721 } 1735 }
1722 1736
1723 kfree(eth->scratch_head); 1737 kfree(eth->scratch_head);
@@ -1784,7 +1798,9 @@ static int mtk_start_dma(struct mtk_eth *eth)
1784 1798
1785 mtk_w32(eth, 1799 mtk_w32(eth,
1786 MTK_TX_WB_DDONE | MTK_TX_DMA_EN | 1800 MTK_TX_WB_DDONE | MTK_TX_DMA_EN |
1787 MTK_DMA_SIZE_16DWORDS | MTK_NDP_CO_PRO, 1801 MTK_DMA_SIZE_16DWORDS | MTK_NDP_CO_PRO |
1802 MTK_RX_DMA_EN | MTK_RX_2B_OFFSET |
1803 MTK_RX_BT_32DWORDS,
1788 MTK_QDMA_GLO_CFG); 1804 MTK_QDMA_GLO_CFG);
1789 1805
1790 mtk_w32(eth, 1806 mtk_w32(eth,
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index 940517af8039..3d3c24a28112 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -532,6 +532,7 @@ struct mtk_tx_ring {
532enum mtk_rx_flags { 532enum mtk_rx_flags {
533 MTK_RX_FLAGS_NORMAL = 0, 533 MTK_RX_FLAGS_NORMAL = 0,
534 MTK_RX_FLAGS_HWLRO, 534 MTK_RX_FLAGS_HWLRO,
535 MTK_RX_FLAGS_QDMA,
535}; 536};
536 537
537/* struct mtk_rx_ring - This struct holds info describing a RX ring 538/* struct mtk_rx_ring - This struct holds info describing a RX ring
@@ -601,6 +602,7 @@ struct mtk_soc_data {
601 * @dma_refcnt: track how many netdevs are using the DMA engine 602 * @dma_refcnt: track how many netdevs are using the DMA engine
602 * @tx_ring: Pointer to the memory holding info about the TX ring 603 * @tx_ring: Pointer to the memory holding info about the TX ring
603 * @rx_ring: Pointer to the memory holding info about the RX ring 604 * @rx_ring: Pointer to the memory holding info about the RX ring
605 * @rx_ring_qdma: Pointer to the memory holding info about the QDMA RX ring
604 * @tx_napi: The TX NAPI struct 606 * @tx_napi: The TX NAPI struct
605 * @rx_napi: The RX NAPI struct 607 * @rx_napi: The RX NAPI struct
606 * @scratch_ring: Newer SoCs need memory for a second HW managed TX ring 608 * @scratch_ring: Newer SoCs need memory for a second HW managed TX ring
@@ -633,6 +635,7 @@ struct mtk_eth {
633 atomic_t dma_refcnt; 635 atomic_t dma_refcnt;
634 struct mtk_tx_ring tx_ring; 636 struct mtk_tx_ring tx_ring;
635 struct mtk_rx_ring rx_ring[MTK_MAX_RX_RING_NUM]; 637 struct mtk_rx_ring rx_ring[MTK_MAX_RX_RING_NUM];
638 struct mtk_rx_ring rx_ring_qdma;
636 struct napi_struct tx_napi; 639 struct napi_struct tx_napi;
637 struct napi_struct rx_napi; 640 struct napi_struct rx_napi;
638 struct mtk_tx_dma *scratch_ring; 641 struct mtk_tx_dma *scratch_ring;