diff options
author | Petri Gynther <pgynther@google.com> | 2015-03-25 15:35:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-27 17:26:15 -0400 |
commit | 3ab113399b633bacb500a903d2f96f25ded2226c (patch) | |
tree | 1839afd7a798bf9ef73ceeb56eb2de3adbf2abd8 /drivers/net/ethernet/broadcom | |
parent | e2aadb4aa9fe4619a78dd925a4756535e9bf3d74 (diff) |
net: bcmgenet: rework Rx 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 | 68 |
1 files changed, 45 insertions, 23 deletions
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 367006dcc70d..dc3b1faf6bbd 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c | |||
@@ -1544,6 +1544,25 @@ next: | |||
1544 | return rxpktprocessed; | 1544 | return rxpktprocessed; |
1545 | } | 1545 | } |
1546 | 1546 | ||
1547 | /* Rx NAPI polling method */ | ||
1548 | static int bcmgenet_rx_poll(struct napi_struct *napi, int budget) | ||
1549 | { | ||
1550 | struct bcmgenet_priv *priv = container_of(napi, | ||
1551 | struct bcmgenet_priv, napi); | ||
1552 | unsigned int work_done; | ||
1553 | |||
1554 | work_done = bcmgenet_desc_rx(priv, DESC_INDEX, budget); | ||
1555 | |||
1556 | if (work_done < budget) { | ||
1557 | napi_complete(napi); | ||
1558 | bcmgenet_intrl2_0_writel(priv, UMAC_IRQ_RXDMA_BDONE | | ||
1559 | UMAC_IRQ_RXDMA_PDONE, | ||
1560 | INTRL2_CPU_MASK_CLEAR); | ||
1561 | } | ||
1562 | |||
1563 | return work_done; | ||
1564 | } | ||
1565 | |||
1547 | /* Assign skb to RX DMA descriptor. */ | 1566 | /* Assign skb to RX DMA descriptor. */ |
1548 | static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv, | 1567 | static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv, |
1549 | struct bcmgenet_rx_ring *ring) | 1568 | struct bcmgenet_rx_ring *ring) |
@@ -1951,6 +1970,26 @@ static void bcmgenet_init_tx_queues(struct net_device *dev) | |||
1951 | bcmgenet_tdma_writel(priv, dma_ctrl, DMA_CTRL); | 1970 | bcmgenet_tdma_writel(priv, dma_ctrl, DMA_CTRL); |
1952 | } | 1971 | } |
1953 | 1972 | ||
1973 | static void bcmgenet_init_rx_napi(struct bcmgenet_priv *priv) | ||
1974 | { | ||
1975 | netif_napi_add(priv->dev, &priv->napi, bcmgenet_rx_poll, 64); | ||
1976 | } | ||
1977 | |||
1978 | static void bcmgenet_enable_rx_napi(struct bcmgenet_priv *priv) | ||
1979 | { | ||
1980 | napi_enable(&priv->napi); | ||
1981 | } | ||
1982 | |||
1983 | static void bcmgenet_disable_rx_napi(struct bcmgenet_priv *priv) | ||
1984 | { | ||
1985 | napi_disable(&priv->napi); | ||
1986 | } | ||
1987 | |||
1988 | static void bcmgenet_fini_rx_napi(struct bcmgenet_priv *priv) | ||
1989 | { | ||
1990 | netif_napi_del(&priv->napi); | ||
1991 | } | ||
1992 | |||
1954 | /* Initialize Rx queues | 1993 | /* Initialize Rx queues |
1955 | * | 1994 | * |
1956 | * Queues 0-15 are priority queues. Hardware Filtering Block (HFB) can be | 1995 | * Queues 0-15 are priority queues. Hardware Filtering Block (HFB) can be |
@@ -2000,6 +2039,9 @@ static int bcmgenet_init_rx_queues(struct net_device *dev) | |||
2000 | ring_cfg |= (1 << DESC_INDEX); | 2039 | ring_cfg |= (1 << DESC_INDEX); |
2001 | dma_ctrl |= (1 << (DESC_INDEX + DMA_RING_BUF_EN_SHIFT)); | 2040 | dma_ctrl |= (1 << (DESC_INDEX + DMA_RING_BUF_EN_SHIFT)); |
2002 | 2041 | ||
2042 | /* Initialize Rx NAPI */ | ||
2043 | bcmgenet_init_rx_napi(priv); | ||
2044 | |||
2003 | /* Enable rings */ | 2045 | /* Enable rings */ |
2004 | bcmgenet_rdma_writel(priv, ring_cfg, DMA_RING_CFG); | 2046 | bcmgenet_rdma_writel(priv, ring_cfg, DMA_RING_CFG); |
2005 | 2047 | ||
@@ -2083,6 +2125,7 @@ static void __bcmgenet_fini_dma(struct bcmgenet_priv *priv) | |||
2083 | 2125 | ||
2084 | static void bcmgenet_fini_dma(struct bcmgenet_priv *priv) | 2126 | static void bcmgenet_fini_dma(struct bcmgenet_priv *priv) |
2085 | { | 2127 | { |
2128 | bcmgenet_fini_rx_napi(priv); | ||
2086 | bcmgenet_fini_tx_napi(priv); | 2129 | bcmgenet_fini_tx_napi(priv); |
2087 | 2130 | ||
2088 | __bcmgenet_fini_dma(priv); | 2131 | __bcmgenet_fini_dma(priv); |
@@ -2147,25 +2190,6 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *priv) | |||
2147 | return 0; | 2190 | return 0; |
2148 | } | 2191 | } |
2149 | 2192 | ||
2150 | /* NAPI polling method*/ | ||
2151 | static int bcmgenet_poll(struct napi_struct *napi, int budget) | ||
2152 | { | ||
2153 | struct bcmgenet_priv *priv = container_of(napi, | ||
2154 | struct bcmgenet_priv, napi); | ||
2155 | unsigned int work_done; | ||
2156 | |||
2157 | work_done = bcmgenet_desc_rx(priv, DESC_INDEX, budget); | ||
2158 | |||
2159 | if (work_done < budget) { | ||
2160 | napi_complete(napi); | ||
2161 | bcmgenet_intrl2_0_writel(priv, UMAC_IRQ_RXDMA_BDONE | | ||
2162 | UMAC_IRQ_RXDMA_PDONE, | ||
2163 | INTRL2_CPU_MASK_CLEAR); | ||
2164 | } | ||
2165 | |||
2166 | return work_done; | ||
2167 | } | ||
2168 | |||
2169 | /* Interrupt bottom half */ | 2193 | /* Interrupt bottom half */ |
2170 | static void bcmgenet_irq_task(struct work_struct *work) | 2194 | static void bcmgenet_irq_task(struct work_struct *work) |
2171 | { | 2195 | { |
@@ -2507,7 +2531,7 @@ static void bcmgenet_netif_start(struct net_device *dev) | |||
2507 | struct bcmgenet_priv *priv = netdev_priv(dev); | 2531 | struct bcmgenet_priv *priv = netdev_priv(dev); |
2508 | 2532 | ||
2509 | /* Start the network engine */ | 2533 | /* Start the network engine */ |
2510 | napi_enable(&priv->napi); | 2534 | bcmgenet_enable_rx_napi(priv); |
2511 | bcmgenet_enable_tx_napi(priv); | 2535 | bcmgenet_enable_tx_napi(priv); |
2512 | 2536 | ||
2513 | umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, true); | 2537 | umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, true); |
@@ -2613,10 +2637,9 @@ static void bcmgenet_netif_stop(struct net_device *dev) | |||
2613 | struct bcmgenet_priv *priv = netdev_priv(dev); | 2637 | struct bcmgenet_priv *priv = netdev_priv(dev); |
2614 | 2638 | ||
2615 | netif_tx_stop_all_queues(dev); | 2639 | netif_tx_stop_all_queues(dev); |
2616 | napi_disable(&priv->napi); | ||
2617 | phy_stop(priv->phydev); | 2640 | phy_stop(priv->phydev); |
2618 | |||
2619 | bcmgenet_intr_disable(priv); | 2641 | bcmgenet_intr_disable(priv); |
2642 | bcmgenet_disable_rx_napi(priv); | ||
2620 | bcmgenet_disable_tx_napi(priv); | 2643 | bcmgenet_disable_tx_napi(priv); |
2621 | 2644 | ||
2622 | /* Wait for pending work items to complete. Since interrupts are | 2645 | /* Wait for pending work items to complete. Since interrupts are |
@@ -3018,7 +3041,6 @@ static int bcmgenet_probe(struct platform_device *pdev) | |||
3018 | dev->watchdog_timeo = 2 * HZ; | 3041 | dev->watchdog_timeo = 2 * HZ; |
3019 | dev->ethtool_ops = &bcmgenet_ethtool_ops; | 3042 | dev->ethtool_ops = &bcmgenet_ethtool_ops; |
3020 | dev->netdev_ops = &bcmgenet_netdev_ops; | 3043 | dev->netdev_ops = &bcmgenet_netdev_ops; |
3021 | netif_napi_add(dev, &priv->napi, bcmgenet_poll, 64); | ||
3022 | 3044 | ||
3023 | priv->msg_enable = netif_msg_init(-1, GENET_MSG_DEFAULT); | 3045 | priv->msg_enable = netif_msg_init(-1, GENET_MSG_DEFAULT); |
3024 | 3046 | ||