diff options
author | Eric Dumazet <edumazet@google.com> | 2015-11-18 09:31:00 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-11-18 16:17:41 -0500 |
commit | d64b5e85bfe2fe4c790abcbd16d9ae32391ddd7e (patch) | |
tree | 3b15f27d6adbc7fbc1ed4dc605c30a577b50c1c6 | |
parent | 93f93a4404159ecf7e9148f5ad0718ec702ac4cb (diff) |
net: add netif_tx_napi_add()
netif_tx_napi_add() is a variant of netif_napi_add()
It should be used by drivers that use a napi structure
to exclusively poll TX.
We do not want to add this kind of napi in napi_hash[] in following
patches, adding generic busy polling to all NAPI drivers.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/broadcom/bcmsysport.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 | ||||
-rw-r--r-- | drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/freescale/gianfar.c | 4 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/en_cq.c | 4 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | 4 | ||||
-rw-r--r-- | drivers/net/ethernet/rocker/rocker.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/ti/cpsw.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/ti/netcp_core.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/ath/wil6210/netdev.c | 2 | ||||
-rw-r--r-- | include/linux/netdevice.h | 23 | ||||
-rw-r--r-- | net/core/dev.c | 3 |
12 files changed, 38 insertions, 16 deletions
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index 858106352ce9..993c780bdfab 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c | |||
@@ -1216,7 +1216,7 @@ static int bcm_sysport_init_tx_ring(struct bcm_sysport_priv *priv, | |||
1216 | /* Initialize SW view of the ring */ | 1216 | /* Initialize SW view of the ring */ |
1217 | spin_lock_init(&ring->lock); | 1217 | spin_lock_init(&ring->lock); |
1218 | ring->priv = priv; | 1218 | ring->priv = priv; |
1219 | netif_napi_add(priv->netdev, &ring->napi, bcm_sysport_tx_poll, 64); | 1219 | netif_tx_napi_add(priv->netdev, &ring->napi, bcm_sysport_tx_poll, 64); |
1220 | ring->index = index; | 1220 | ring->index = index; |
1221 | ring->size = size; | 1221 | ring->size = size; |
1222 | ring->alloc_size = ring->size; | 1222 | ring->alloc_size = ring->size; |
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 17f017ab4dac..b15a60d787c7 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c | |||
@@ -2041,11 +2041,11 @@ static void bcmgenet_init_tx_napi(struct bcmgenet_priv *priv) | |||
2041 | 2041 | ||
2042 | for (i = 0; i < priv->hw_params->tx_queues; ++i) { | 2042 | for (i = 0; i < priv->hw_params->tx_queues; ++i) { |
2043 | ring = &priv->tx_rings[i]; | 2043 | ring = &priv->tx_rings[i]; |
2044 | netif_napi_add(priv->dev, &ring->napi, bcmgenet_tx_poll, 64); | 2044 | netif_tx_napi_add(priv->dev, &ring->napi, bcmgenet_tx_poll, 64); |
2045 | } | 2045 | } |
2046 | 2046 | ||
2047 | ring = &priv->tx_rings[DESC_INDEX]; | 2047 | ring = &priv->tx_rings[DESC_INDEX]; |
2048 | netif_napi_add(priv->dev, &ring->napi, bcmgenet_tx_poll, 64); | 2048 | netif_tx_napi_add(priv->dev, &ring->napi, bcmgenet_tx_poll, 64); |
2049 | } | 2049 | } |
2050 | 2050 | ||
2051 | static void bcmgenet_enable_tx_napi(struct bcmgenet_priv *priv) | 2051 | static void bcmgenet_enable_tx_napi(struct bcmgenet_priv *priv) |
diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c index cf8e54652df9..48a9c176e0d1 100644 --- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | |||
@@ -1050,7 +1050,7 @@ static int fs_enet_probe(struct platform_device *ofdev) | |||
1050 | ndev->netdev_ops = &fs_enet_netdev_ops; | 1050 | ndev->netdev_ops = &fs_enet_netdev_ops; |
1051 | ndev->watchdog_timeo = 2 * HZ; | 1051 | ndev->watchdog_timeo = 2 * HZ; |
1052 | netif_napi_add(ndev, &fep->napi, fs_enet_rx_napi, fpi->napi_weight); | 1052 | netif_napi_add(ndev, &fep->napi, fs_enet_rx_napi, fpi->napi_weight); |
1053 | netif_napi_add(ndev, &fep->napi_tx, fs_enet_tx_napi, 2); | 1053 | netif_tx_napi_add(ndev, &fep->napi_tx, fs_enet_tx_napi, 2); |
1054 | 1054 | ||
1055 | ndev->ethtool_ops = &fs_ethtool_ops; | 1055 | ndev->ethtool_ops = &fs_ethtool_ops; |
1056 | 1056 | ||
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 3e6b9b437497..c8bc43e99a35 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c | |||
@@ -1347,12 +1347,12 @@ static int gfar_probe(struct platform_device *ofdev) | |||
1347 | if (priv->poll_mode == GFAR_SQ_POLLING) { | 1347 | if (priv->poll_mode == GFAR_SQ_POLLING) { |
1348 | netif_napi_add(dev, &priv->gfargrp[i].napi_rx, | 1348 | netif_napi_add(dev, &priv->gfargrp[i].napi_rx, |
1349 | gfar_poll_rx_sq, GFAR_DEV_WEIGHT); | 1349 | gfar_poll_rx_sq, GFAR_DEV_WEIGHT); |
1350 | netif_napi_add(dev, &priv->gfargrp[i].napi_tx, | 1350 | netif_tx_napi_add(dev, &priv->gfargrp[i].napi_tx, |
1351 | gfar_poll_tx_sq, 2); | 1351 | gfar_poll_tx_sq, 2); |
1352 | } else { | 1352 | } else { |
1353 | netif_napi_add(dev, &priv->gfargrp[i].napi_rx, | 1353 | netif_napi_add(dev, &priv->gfargrp[i].napi_rx, |
1354 | gfar_poll_rx, GFAR_DEV_WEIGHT); | 1354 | gfar_poll_rx, GFAR_DEV_WEIGHT); |
1355 | netif_napi_add(dev, &priv->gfargrp[i].napi_tx, | 1355 | netif_tx_napi_add(dev, &priv->gfargrp[i].napi_tx, |
1356 | gfar_poll_tx, 2); | 1356 | gfar_poll_tx, 2); |
1357 | } | 1357 | } |
1358 | } | 1358 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_cq.c b/drivers/net/ethernet/mellanox/mlx4/en_cq.c index eb8a4988de63..3a6176fea78d 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_cq.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_cq.c | |||
@@ -156,8 +156,8 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, | |||
156 | cq->mcq.event = mlx4_en_cq_event; | 156 | cq->mcq.event = mlx4_en_cq_event; |
157 | 157 | ||
158 | if (cq->is_tx) { | 158 | if (cq->is_tx) { |
159 | netif_napi_add(cq->dev, &cq->napi, mlx4_en_poll_tx_cq, | 159 | netif_tx_napi_add(cq->dev, &cq->napi, mlx4_en_poll_tx_cq, |
160 | NAPI_POLL_WEIGHT); | 160 | NAPI_POLL_WEIGHT); |
161 | } else { | 161 | } else { |
162 | netif_napi_add(cq->dev, &cq->napi, mlx4_en_poll_rx_cq, 64); | 162 | netif_napi_add(cq->dev, &cq->napi, mlx4_en_poll_rx_cq, 64); |
163 | napi_hash_add(&cq->napi); | 163 | napi_hash_add(&cq->napi); |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c index d4b5085a21fa..7bd6f25b4625 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | |||
@@ -1604,7 +1604,7 @@ int qlcnic_82xx_napi_add(struct qlcnic_adapter *adapter, | |||
1604 | if (qlcnic_check_multi_tx(adapter) && !adapter->ahw->diag_test) { | 1604 | if (qlcnic_check_multi_tx(adapter) && !adapter->ahw->diag_test) { |
1605 | for (ring = 0; ring < adapter->drv_tx_rings; ring++) { | 1605 | for (ring = 0; ring < adapter->drv_tx_rings; ring++) { |
1606 | tx_ring = &adapter->tx_ring[ring]; | 1606 | tx_ring = &adapter->tx_ring[ring]; |
1607 | netif_napi_add(netdev, &tx_ring->napi, qlcnic_tx_poll, | 1607 | netif_tx_napi_add(netdev, &tx_ring->napi, qlcnic_tx_poll, |
1608 | NAPI_POLL_WEIGHT); | 1608 | NAPI_POLL_WEIGHT); |
1609 | } | 1609 | } |
1610 | } | 1610 | } |
@@ -2135,7 +2135,7 @@ int qlcnic_83xx_napi_add(struct qlcnic_adapter *adapter, | |||
2135 | !(adapter->flags & QLCNIC_TX_INTR_SHARED)) { | 2135 | !(adapter->flags & QLCNIC_TX_INTR_SHARED)) { |
2136 | for (ring = 0; ring < adapter->drv_tx_rings; ring++) { | 2136 | for (ring = 0; ring < adapter->drv_tx_rings; ring++) { |
2137 | tx_ring = &adapter->tx_ring[ring]; | 2137 | tx_ring = &adapter->tx_ring[ring]; |
2138 | netif_napi_add(netdev, &tx_ring->napi, | 2138 | netif_tx_napi_add(netdev, &tx_ring->napi, |
2139 | qlcnic_83xx_msix_tx_poll, | 2139 | qlcnic_83xx_msix_tx_poll, |
2140 | NAPI_POLL_WEIGHT); | 2140 | NAPI_POLL_WEIGHT); |
2141 | } | 2141 | } |
diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c index e9f2349e98bc..a4ab71d43e4e 100644 --- a/drivers/net/ethernet/rocker/rocker.c +++ b/drivers/net/ethernet/rocker/rocker.c | |||
@@ -4998,7 +4998,7 @@ static int rocker_probe_port(struct rocker *rocker, unsigned int port_number) | |||
4998 | dev->netdev_ops = &rocker_port_netdev_ops; | 4998 | dev->netdev_ops = &rocker_port_netdev_ops; |
4999 | dev->ethtool_ops = &rocker_port_ethtool_ops; | 4999 | dev->ethtool_ops = &rocker_port_ethtool_ops; |
5000 | dev->switchdev_ops = &rocker_port_switchdev_ops; | 5000 | dev->switchdev_ops = &rocker_port_switchdev_ops; |
5001 | netif_napi_add(dev, &rocker_port->napi_tx, rocker_port_poll_tx, | 5001 | netif_tx_napi_add(dev, &rocker_port->napi_tx, rocker_port_poll_tx, |
5002 | NAPI_POLL_WEIGHT); | 5002 | NAPI_POLL_WEIGHT); |
5003 | netif_napi_add(dev, &rocker_port->napi_rx, rocker_port_poll_rx, | 5003 | netif_napi_add(dev, &rocker_port->napi_rx, rocker_port_poll_rx, |
5004 | NAPI_POLL_WEIGHT); | 5004 | NAPI_POLL_WEIGHT); |
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 48b92c9de12a..15322c08de80 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c | |||
@@ -2469,7 +2469,7 @@ static int cpsw_probe(struct platform_device *pdev) | |||
2469 | ndev->netdev_ops = &cpsw_netdev_ops; | 2469 | ndev->netdev_ops = &cpsw_netdev_ops; |
2470 | ndev->ethtool_ops = &cpsw_ethtool_ops; | 2470 | ndev->ethtool_ops = &cpsw_ethtool_ops; |
2471 | netif_napi_add(ndev, &priv->napi_rx, cpsw_rx_poll, CPSW_POLL_WEIGHT); | 2471 | netif_napi_add(ndev, &priv->napi_rx, cpsw_rx_poll, CPSW_POLL_WEIGHT); |
2472 | netif_napi_add(ndev, &priv->napi_tx, cpsw_tx_poll, CPSW_POLL_WEIGHT); | 2472 | netif_tx_napi_add(ndev, &priv->napi_tx, cpsw_tx_poll, CPSW_POLL_WEIGHT); |
2473 | 2473 | ||
2474 | /* register the network device */ | 2474 | /* register the network device */ |
2475 | SET_NETDEV_DEV(ndev, &pdev->dev); | 2475 | SET_NETDEV_DEV(ndev, &pdev->dev); |
diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c index 37b9b39192ec..e5e20e734f21 100644 --- a/drivers/net/ethernet/ti/netcp_core.c +++ b/drivers/net/ethernet/ti/netcp_core.c | |||
@@ -1990,7 +1990,7 @@ static int netcp_create_interface(struct netcp_device *netcp_device, | |||
1990 | 1990 | ||
1991 | /* NAPI register */ | 1991 | /* NAPI register */ |
1992 | netif_napi_add(ndev, &netcp->rx_napi, netcp_rx_poll, NETCP_NAPI_WEIGHT); | 1992 | netif_napi_add(ndev, &netcp->rx_napi, netcp_rx_poll, NETCP_NAPI_WEIGHT); |
1993 | netif_napi_add(ndev, &netcp->tx_napi, netcp_tx_poll, NETCP_NAPI_WEIGHT); | 1993 | netif_tx_napi_add(ndev, &netcp->tx_napi, netcp_tx_poll, NETCP_NAPI_WEIGHT); |
1994 | 1994 | ||
1995 | /* Register the network device */ | 1995 | /* Register the network device */ |
1996 | ndev->dev_id = 0; | 1996 | ndev->dev_id = 0; |
diff --git a/drivers/net/wireless/ath/wil6210/netdev.c b/drivers/net/wireless/ath/wil6210/netdev.c index e3b3c8fb4605..56aaa2d4fb0e 100644 --- a/drivers/net/wireless/ath/wil6210/netdev.c +++ b/drivers/net/wireless/ath/wil6210/netdev.c | |||
@@ -183,7 +183,7 @@ void *wil_if_alloc(struct device *dev) | |||
183 | 183 | ||
184 | netif_napi_add(ndev, &wil->napi_rx, wil6210_netdev_poll_rx, | 184 | netif_napi_add(ndev, &wil->napi_rx, wil6210_netdev_poll_rx, |
185 | WIL6210_NAPI_BUDGET); | 185 | WIL6210_NAPI_BUDGET); |
186 | netif_napi_add(ndev, &wil->napi_tx, wil6210_netdev_poll_tx, | 186 | netif_tx_napi_add(ndev, &wil->napi_tx, wil6210_netdev_poll_tx, |
187 | WIL6210_NAPI_BUDGET); | 187 | WIL6210_NAPI_BUDGET); |
188 | 188 | ||
189 | netif_tx_stop_all_queues(ndev); | 189 | netif_tx_stop_all_queues(ndev); |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 2020a89df12b..838935d1cdbb 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -326,7 +326,8 @@ enum { | |||
326 | NAPI_STATE_SCHED, /* Poll is scheduled */ | 326 | NAPI_STATE_SCHED, /* Poll is scheduled */ |
327 | NAPI_STATE_DISABLE, /* Disable pending */ | 327 | NAPI_STATE_DISABLE, /* Disable pending */ |
328 | NAPI_STATE_NPSVC, /* Netpoll - don't dequeue from poll_list */ | 328 | NAPI_STATE_NPSVC, /* Netpoll - don't dequeue from poll_list */ |
329 | NAPI_STATE_HASHED, /* In NAPI hash */ | 329 | NAPI_STATE_HASHED, /* In NAPI hash (busy polling possible) */ |
330 | NAPI_STATE_NO_BUSY_POLL,/* Do not add in napi_hash, no busy polling */ | ||
330 | }; | 331 | }; |
331 | 332 | ||
332 | enum gro_result { | 333 | enum gro_result { |
@@ -1939,6 +1940,26 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi, | |||
1939 | int (*poll)(struct napi_struct *, int), int weight); | 1940 | int (*poll)(struct napi_struct *, int), int weight); |
1940 | 1941 | ||
1941 | /** | 1942 | /** |
1943 | * netif_tx_napi_add - initialize a napi context | ||
1944 | * @dev: network device | ||
1945 | * @napi: napi context | ||
1946 | * @poll: polling function | ||
1947 | * @weight: default weight | ||
1948 | * | ||
1949 | * This variant of netif_napi_add() should be used from drivers using NAPI | ||
1950 | * to exclusively poll a TX queue. | ||
1951 | * This will avoid we add it into napi_hash[], thus polluting this hash table. | ||
1952 | */ | ||
1953 | static inline void netif_tx_napi_add(struct net_device *dev, | ||
1954 | struct napi_struct *napi, | ||
1955 | int (*poll)(struct napi_struct *, int), | ||
1956 | int weight) | ||
1957 | { | ||
1958 | set_bit(NAPI_STATE_NO_BUSY_POLL, &napi->state); | ||
1959 | netif_napi_add(dev, napi, poll, weight); | ||
1960 | } | ||
1961 | |||
1962 | /** | ||
1942 | * netif_napi_del - remove a napi context | 1963 | * netif_napi_del - remove a napi context |
1943 | * @napi: napi context | 1964 | * @napi: napi context |
1944 | * | 1965 | * |
diff --git a/net/core/dev.c b/net/core/dev.c index 83b48747928c..ff58a8bc5e3c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -4737,7 +4737,8 @@ EXPORT_SYMBOL(sk_busy_loop); | |||
4737 | 4737 | ||
4738 | void napi_hash_add(struct napi_struct *napi) | 4738 | void napi_hash_add(struct napi_struct *napi) |
4739 | { | 4739 | { |
4740 | if (test_and_set_bit(NAPI_STATE_HASHED, &napi->state)) | 4740 | if (test_bit(NAPI_STATE_NO_BUSY_POLL, &napi->state) || |
4741 | test_and_set_bit(NAPI_STATE_HASHED, &napi->state)) | ||
4741 | return; | 4742 | return; |
4742 | 4743 | ||
4743 | spin_lock(&napi_hash_lock); | 4744 | spin_lock(&napi_hash_lock); |