diff options
author | Petri Gynther <pgynther@google.com> | 2015-03-25 15:35:14 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-27 17:26:14 -0400 |
commit | e2aadb4aa9fe4619a78dd925a4756535e9bf3d74 (patch) | |
tree | e5ec665f54ec9cd25d3c107ea0d9470978266046 /drivers/net/ethernet/broadcom | |
parent | b2e97eca88f07d1a4dae691ad8d751ba1de15645 (diff) |
net: bcmgenet: rework Tx NAPI code
Introduce new bcmgenet functions to handle the NAPI calls to:
netif_napi_add()
napi_enable()
napi_disable()
netif_napi_del()
Signed-off-by: Petri Gynther <pgynther@google.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/broadcom')
-rw-r--r-- | drivers/net/ethernet/broadcom/genet/bcmgenet.c | 80 |
1 files changed, 62 insertions, 18 deletions
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 68873beba760..367006dcc70d 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c | |||
@@ -1733,7 +1733,6 @@ static void bcmgenet_init_tx_ring(struct bcmgenet_priv *priv, | |||
1733 | 1733 | ||
1734 | spin_lock_init(&ring->lock); | 1734 | spin_lock_init(&ring->lock); |
1735 | ring->priv = priv; | 1735 | ring->priv = priv; |
1736 | netif_napi_add(priv->dev, &ring->napi, bcmgenet_tx_poll, 64); | ||
1737 | ring->index = index; | 1736 | ring->index = index; |
1738 | if (index == DESC_INDEX) { | 1737 | if (index == DESC_INDEX) { |
1739 | ring->queue = 0; | 1738 | ring->queue = 0; |
@@ -1777,17 +1776,6 @@ static void bcmgenet_init_tx_ring(struct bcmgenet_priv *priv, | |||
1777 | TDMA_WRITE_PTR); | 1776 | TDMA_WRITE_PTR); |
1778 | bcmgenet_tdma_ring_writel(priv, index, end_ptr * words_per_bd - 1, | 1777 | bcmgenet_tdma_ring_writel(priv, index, end_ptr * words_per_bd - 1, |
1779 | DMA_END_ADDR); | 1778 | DMA_END_ADDR); |
1780 | |||
1781 | napi_enable(&ring->napi); | ||
1782 | } | ||
1783 | |||
1784 | static void bcmgenet_fini_tx_ring(struct bcmgenet_priv *priv, | ||
1785 | unsigned int index) | ||
1786 | { | ||
1787 | struct bcmgenet_tx_ring *ring = &priv->tx_rings[index]; | ||
1788 | |||
1789 | napi_disable(&ring->napi); | ||
1790 | netif_napi_del(&ring->napi); | ||
1791 | } | 1779 | } |
1792 | 1780 | ||
1793 | /* Initialize a RDMA ring */ | 1781 | /* Initialize a RDMA ring */ |
@@ -1835,6 +1823,62 @@ static int bcmgenet_init_rx_ring(struct bcmgenet_priv *priv, | |||
1835 | return ret; | 1823 | return ret; |
1836 | } | 1824 | } |
1837 | 1825 | ||
1826 | static void bcmgenet_init_tx_napi(struct bcmgenet_priv *priv) | ||
1827 | { | ||
1828 | unsigned int i; | ||
1829 | struct bcmgenet_tx_ring *ring; | ||
1830 | |||
1831 | for (i = 0; i < priv->hw_params->tx_queues; ++i) { | ||
1832 | ring = &priv->tx_rings[i]; | ||
1833 | netif_napi_add(priv->dev, &ring->napi, bcmgenet_tx_poll, 64); | ||
1834 | } | ||
1835 | |||
1836 | ring = &priv->tx_rings[DESC_INDEX]; | ||
1837 | netif_napi_add(priv->dev, &ring->napi, bcmgenet_tx_poll, 64); | ||
1838 | } | ||
1839 | |||
1840 | static void bcmgenet_enable_tx_napi(struct bcmgenet_priv *priv) | ||
1841 | { | ||
1842 | unsigned int i; | ||
1843 | struct bcmgenet_tx_ring *ring; | ||
1844 | |||
1845 | for (i = 0; i < priv->hw_params->tx_queues; ++i) { | ||
1846 | ring = &priv->tx_rings[i]; | ||
1847 | napi_enable(&ring->napi); | ||
1848 | } | ||
1849 | |||
1850 | ring = &priv->tx_rings[DESC_INDEX]; | ||
1851 | napi_enable(&ring->napi); | ||
1852 | } | ||
1853 | |||
1854 | static void bcmgenet_disable_tx_napi(struct bcmgenet_priv *priv) | ||
1855 | { | ||
1856 | unsigned int i; | ||
1857 | struct bcmgenet_tx_ring *ring; | ||
1858 | |||
1859 | for (i = 0; i < priv->hw_params->tx_queues; ++i) { | ||
1860 | ring = &priv->tx_rings[i]; | ||
1861 | napi_disable(&ring->napi); | ||
1862 | } | ||
1863 | |||
1864 | ring = &priv->tx_rings[DESC_INDEX]; | ||
1865 | napi_disable(&ring->napi); | ||
1866 | } | ||
1867 | |||
1868 | static void bcmgenet_fini_tx_napi(struct bcmgenet_priv *priv) | ||
1869 | { | ||
1870 | unsigned int i; | ||
1871 | struct bcmgenet_tx_ring *ring; | ||
1872 | |||
1873 | for (i = 0; i < priv->hw_params->tx_queues; ++i) { | ||
1874 | ring = &priv->tx_rings[i]; | ||
1875 | netif_napi_del(&ring->napi); | ||
1876 | } | ||
1877 | |||
1878 | ring = &priv->tx_rings[DESC_INDEX]; | ||
1879 | netif_napi_del(&ring->napi); | ||
1880 | } | ||
1881 | |||
1838 | /* Initialize Tx queues | 1882 | /* Initialize Tx queues |
1839 | * | 1883 | * |
1840 | * Queues 0-3 are priority-based, each one has 32 descriptors, | 1884 | * Queues 0-3 are priority-based, each one has 32 descriptors, |
@@ -1895,6 +1939,9 @@ static void bcmgenet_init_tx_queues(struct net_device *dev) | |||
1895 | bcmgenet_tdma_writel(priv, dma_priority[1], DMA_PRIORITY_1); | 1939 | bcmgenet_tdma_writel(priv, dma_priority[1], DMA_PRIORITY_1); |
1896 | bcmgenet_tdma_writel(priv, dma_priority[2], DMA_PRIORITY_2); | 1940 | bcmgenet_tdma_writel(priv, dma_priority[2], DMA_PRIORITY_2); |
1897 | 1941 | ||
1942 | /* Initialize Tx NAPI */ | ||
1943 | bcmgenet_init_tx_napi(priv); | ||
1944 | |||
1898 | /* Enable Tx queues */ | 1945 | /* Enable Tx queues */ |
1899 | bcmgenet_tdma_writel(priv, ring_cfg, DMA_RING_CFG); | 1946 | bcmgenet_tdma_writel(priv, ring_cfg, DMA_RING_CFG); |
1900 | 1947 | ||
@@ -2036,12 +2083,7 @@ static void __bcmgenet_fini_dma(struct bcmgenet_priv *priv) | |||
2036 | 2083 | ||
2037 | static void bcmgenet_fini_dma(struct bcmgenet_priv *priv) | 2084 | static void bcmgenet_fini_dma(struct bcmgenet_priv *priv) |
2038 | { | 2085 | { |
2039 | int i; | 2086 | bcmgenet_fini_tx_napi(priv); |
2040 | |||
2041 | bcmgenet_fini_tx_ring(priv, DESC_INDEX); | ||
2042 | |||
2043 | for (i = 0; i < priv->hw_params->tx_queues; i++) | ||
2044 | bcmgenet_fini_tx_ring(priv, i); | ||
2045 | 2087 | ||
2046 | __bcmgenet_fini_dma(priv); | 2088 | __bcmgenet_fini_dma(priv); |
2047 | } | 2089 | } |
@@ -2466,6 +2508,7 @@ static void bcmgenet_netif_start(struct net_device *dev) | |||
2466 | 2508 | ||
2467 | /* Start the network engine */ | 2509 | /* Start the network engine */ |
2468 | napi_enable(&priv->napi); | 2510 | napi_enable(&priv->napi); |
2511 | bcmgenet_enable_tx_napi(priv); | ||
2469 | 2512 | ||
2470 | umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, true); | 2513 | umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, true); |
2471 | 2514 | ||
@@ -2574,6 +2617,7 @@ static void bcmgenet_netif_stop(struct net_device *dev) | |||
2574 | phy_stop(priv->phydev); | 2617 | phy_stop(priv->phydev); |
2575 | 2618 | ||
2576 | bcmgenet_intr_disable(priv); | 2619 | bcmgenet_intr_disable(priv); |
2620 | bcmgenet_disable_tx_napi(priv); | ||
2577 | 2621 | ||
2578 | /* Wait for pending work items to complete. Since interrupts are | 2622 | /* Wait for pending work items to complete. Since interrupts are |
2579 | * disabled no new work will be scheduled. | 2623 | * disabled no new work will be scheduled. |