aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-09-24 00:55:26 -0400
committerDavid S. Miller <davem@davemloft.net>2018-09-24 00:55:26 -0400
commit841dfa43788a309d353b3b7a81c85ed8d3eac130 (patch)
tree45219d6edd985eda79fb0410017df520546c4ec1
parent16fdf8ba98391650ce4bc4f3f71629d8a413bc21 (diff)
parent765cdc209cb89fb81215310a066cd0a3018ffef7 (diff)
Merge branch 'netpoll-avoid-capture-effects-for-NAPI-drivers'
Eric Dumazet says: ==================== netpoll: avoid capture effects for NAPI drivers As diagnosed by Song Liu, ndo_poll_controller() can be very dangerous on loaded hosts, since the cpu calling ndo_poll_controller() might steal all NAPI contexts (for all RX/TX queues of the NIC). This capture, showing one ksoftirqd eating all cycles can last for unlimited amount of time, since one cpu is generally not able to drain all the queues under load. It seems that all networking drivers that do use NAPI for their TX completions, should not provide a ndo_poll_controller() : Most NAPI drivers have netpoll support already handled in core networking stack, since netpoll_poll_dev() uses poll_napi(dev) to iterate through registered NAPI contexts for a device. This patch series take care of the first round, we will handle other drivers in future rounds. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/bonding/bond_main.c11
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c16
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.c18
-rw-r--r--drivers/net/ethernet/intel/fm10k/fm10k.h3
-rw-r--r--drivers/net/ethernet/intel/fm10k/fm10k_netdev.c3
-rw-r--r--drivers/net/ethernet/intel/fm10k/fm10k_pci.c22
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40evf_main.c26
-rw-r--r--drivers/net/ethernet/intel/ice/ice_main.c27
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c30
-rw-r--r--drivers/net/ethernet/intel/ixgb/ixgb_main.c25
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c25
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c21
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c20
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c19
-rw-r--r--drivers/net/ethernet/netronome/nfp/nfp_net_common.c18
-rw-r--r--drivers/net/tun.c43
-rw-r--r--include/linux/netpoll.h5
-rw-r--r--net/core/netpoll.c19
18 files changed, 12 insertions, 339 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index a764a83f99da..0d87e11e7f1d 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -971,16 +971,13 @@ static void bond_poll_controller(struct net_device *bond_dev)
971 struct slave *slave = NULL; 971 struct slave *slave = NULL;
972 struct list_head *iter; 972 struct list_head *iter;
973 struct ad_info ad_info; 973 struct ad_info ad_info;
974 struct netpoll_info *ni;
975 const struct net_device_ops *ops;
976 974
977 if (BOND_MODE(bond) == BOND_MODE_8023AD) 975 if (BOND_MODE(bond) == BOND_MODE_8023AD)
978 if (bond_3ad_get_active_agg_info(bond, &ad_info)) 976 if (bond_3ad_get_active_agg_info(bond, &ad_info))
979 return; 977 return;
980 978
981 bond_for_each_slave_rcu(bond, slave, iter) { 979 bond_for_each_slave_rcu(bond, slave, iter) {
982 ops = slave->dev->netdev_ops; 980 if (!bond_slave_is_up(slave))
983 if (!bond_slave_is_up(slave) || !ops->ndo_poll_controller)
984 continue; 981 continue;
985 982
986 if (BOND_MODE(bond) == BOND_MODE_8023AD) { 983 if (BOND_MODE(bond) == BOND_MODE_8023AD) {
@@ -992,11 +989,7 @@ static void bond_poll_controller(struct net_device *bond_dev)
992 continue; 989 continue;
993 } 990 }
994 991
995 ni = rcu_dereference_bh(slave->dev->npinfo); 992 netpoll_poll_dev(slave->dev);
996 if (down_trylock(&ni->dev_lock))
997 continue;
998 ops->ndo_poll_controller(slave->dev);
999 up(&ni->dev_lock);
1000 } 993 }
1001} 994}
1002 995
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 71362b7f6040..fcc2328bb0d9 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -12894,19 +12894,6 @@ static int bnx2x_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
12894 } 12894 }
12895} 12895}
12896 12896
12897#ifdef CONFIG_NET_POLL_CONTROLLER
12898static void poll_bnx2x(struct net_device *dev)
12899{
12900 struct bnx2x *bp = netdev_priv(dev);
12901 int i;
12902
12903 for_each_eth_queue(bp, i) {
12904 struct bnx2x_fastpath *fp = &bp->fp[i];
12905 napi_schedule(&bnx2x_fp(bp, fp->index, napi));
12906 }
12907}
12908#endif
12909
12910static int bnx2x_validate_addr(struct net_device *dev) 12897static int bnx2x_validate_addr(struct net_device *dev)
12911{ 12898{
12912 struct bnx2x *bp = netdev_priv(dev); 12899 struct bnx2x *bp = netdev_priv(dev);
@@ -13113,9 +13100,6 @@ static const struct net_device_ops bnx2x_netdev_ops = {
13113 .ndo_tx_timeout = bnx2x_tx_timeout, 13100 .ndo_tx_timeout = bnx2x_tx_timeout,
13114 .ndo_vlan_rx_add_vid = bnx2x_vlan_rx_add_vid, 13101 .ndo_vlan_rx_add_vid = bnx2x_vlan_rx_add_vid,
13115 .ndo_vlan_rx_kill_vid = bnx2x_vlan_rx_kill_vid, 13102 .ndo_vlan_rx_kill_vid = bnx2x_vlan_rx_kill_vid,
13116#ifdef CONFIG_NET_POLL_CONTROLLER
13117 .ndo_poll_controller = poll_bnx2x,
13118#endif
13119 .ndo_setup_tc = __bnx2x_setup_tc, 13103 .ndo_setup_tc = __bnx2x_setup_tc,
13120#ifdef CONFIG_BNX2X_SRIOV 13104#ifdef CONFIG_BNX2X_SRIOV
13121 .ndo_set_vf_mac = bnx2x_set_vf_mac, 13105 .ndo_set_vf_mac = bnx2x_set_vf_mac,
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 177587f9c3f1..61957b0bbd8c 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7672,21 +7672,6 @@ static void bnxt_tx_timeout(struct net_device *dev)
7672 bnxt_queue_sp_work(bp); 7672 bnxt_queue_sp_work(bp);
7673} 7673}
7674 7674
7675#ifdef CONFIG_NET_POLL_CONTROLLER
7676static void bnxt_poll_controller(struct net_device *dev)
7677{
7678 struct bnxt *bp = netdev_priv(dev);
7679 int i;
7680
7681 /* Only process tx rings/combined rings in netpoll mode. */
7682 for (i = 0; i < bp->tx_nr_rings; i++) {
7683 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];
7684
7685 napi_schedule(&txr->bnapi->napi);
7686 }
7687}
7688#endif
7689
7690static void bnxt_timer(struct timer_list *t) 7675static void bnxt_timer(struct timer_list *t)
7691{ 7676{
7692 struct bnxt *bp = from_timer(bp, t, timer); 7677 struct bnxt *bp = from_timer(bp, t, timer);
@@ -8520,9 +8505,6 @@ static const struct net_device_ops bnxt_netdev_ops = {
8520 .ndo_set_vf_spoofchk = bnxt_set_vf_spoofchk, 8505 .ndo_set_vf_spoofchk = bnxt_set_vf_spoofchk,
8521 .ndo_set_vf_trust = bnxt_set_vf_trust, 8506 .ndo_set_vf_trust = bnxt_set_vf_trust,
8522#endif 8507#endif
8523#ifdef CONFIG_NET_POLL_CONTROLLER
8524 .ndo_poll_controller = bnxt_poll_controller,
8525#endif
8526 .ndo_setup_tc = bnxt_setup_tc, 8508 .ndo_setup_tc = bnxt_setup_tc,
8527#ifdef CONFIG_RFS_ACCEL 8509#ifdef CONFIG_RFS_ACCEL
8528 .ndo_rx_flow_steer = bnxt_rx_flow_steer, 8510 .ndo_rx_flow_steer = bnxt_rx_flow_steer,
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k.h b/drivers/net/ethernet/intel/fm10k/fm10k.h
index a903a0ba45e1..7d42582ed48d 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k.h
+++ b/drivers/net/ethernet/intel/fm10k/fm10k.h
@@ -504,9 +504,6 @@ void fm10k_update_stats(struct fm10k_intfc *interface);
504void fm10k_service_event_schedule(struct fm10k_intfc *interface); 504void fm10k_service_event_schedule(struct fm10k_intfc *interface);
505void fm10k_macvlan_schedule(struct fm10k_intfc *interface); 505void fm10k_macvlan_schedule(struct fm10k_intfc *interface);
506void fm10k_update_rx_drop_en(struct fm10k_intfc *interface); 506void fm10k_update_rx_drop_en(struct fm10k_intfc *interface);
507#ifdef CONFIG_NET_POLL_CONTROLLER
508void fm10k_netpoll(struct net_device *netdev);
509#endif
510 507
511/* Netdev */ 508/* Netdev */
512struct net_device *fm10k_alloc_netdev(const struct fm10k_info *info); 509struct net_device *fm10k_alloc_netdev(const struct fm10k_info *info);
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
index 929f538d28bc..538a8467f434 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
@@ -1648,9 +1648,6 @@ static const struct net_device_ops fm10k_netdev_ops = {
1648 .ndo_udp_tunnel_del = fm10k_udp_tunnel_del, 1648 .ndo_udp_tunnel_del = fm10k_udp_tunnel_del,
1649 .ndo_dfwd_add_station = fm10k_dfwd_add_station, 1649 .ndo_dfwd_add_station = fm10k_dfwd_add_station,
1650 .ndo_dfwd_del_station = fm10k_dfwd_del_station, 1650 .ndo_dfwd_del_station = fm10k_dfwd_del_station,
1651#ifdef CONFIG_NET_POLL_CONTROLLER
1652 .ndo_poll_controller = fm10k_netpoll,
1653#endif
1654 .ndo_features_check = fm10k_features_check, 1651 .ndo_features_check = fm10k_features_check,
1655}; 1652};
1656 1653
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
index 15071e4adb98..c859ababeed5 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
@@ -1210,28 +1210,6 @@ static irqreturn_t fm10k_msix_mbx_vf(int __always_unused irq, void *data)
1210 return IRQ_HANDLED; 1210 return IRQ_HANDLED;
1211} 1211}
1212 1212
1213#ifdef CONFIG_NET_POLL_CONTROLLER
1214/**
1215 * fm10k_netpoll - A Polling 'interrupt' handler
1216 * @netdev: network interface device structure
1217 *
1218 * This is used by netconsole to send skbs without having to re-enable
1219 * interrupts. It's not called while the normal interrupt routine is executing.
1220 **/
1221void fm10k_netpoll(struct net_device *netdev)
1222{
1223 struct fm10k_intfc *interface = netdev_priv(netdev);
1224 int i;
1225
1226 /* if interface is down do nothing */
1227 if (test_bit(__FM10K_DOWN, interface->state))
1228 return;
1229
1230 for (i = 0; i < interface->num_q_vectors; i++)
1231 fm10k_msix_clean_rings(0, interface->q_vector[i]);
1232}
1233
1234#endif
1235#define FM10K_ERR_MSG(type) case (type): error = #type; break 1213#define FM10K_ERR_MSG(type) case (type): error = #type; break
1236static void fm10k_handle_fault(struct fm10k_intfc *interface, int type, 1214static void fm10k_handle_fault(struct fm10k_intfc *interface, int type,
1237 struct fm10k_fault *fault) 1215 struct fm10k_fault *fault)
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index 5906c1c1d19d..fef6d892ed4c 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -396,29 +396,6 @@ static void i40evf_map_rings_to_vectors(struct i40evf_adapter *adapter)
396 adapter->aq_required |= I40EVF_FLAG_AQ_MAP_VECTORS; 396 adapter->aq_required |= I40EVF_FLAG_AQ_MAP_VECTORS;
397} 397}
398 398
399#ifdef CONFIG_NET_POLL_CONTROLLER
400/**
401 * i40evf_netpoll - A Polling 'interrupt' handler
402 * @netdev: network interface device structure
403 *
404 * This is used by netconsole to send skbs without having to re-enable
405 * interrupts. It's not called while the normal interrupt routine is executing.
406 **/
407static void i40evf_netpoll(struct net_device *netdev)
408{
409 struct i40evf_adapter *adapter = netdev_priv(netdev);
410 int q_vectors = adapter->num_msix_vectors - NONQ_VECS;
411 int i;
412
413 /* if interface is down do nothing */
414 if (test_bit(__I40E_VSI_DOWN, adapter->vsi.state))
415 return;
416
417 for (i = 0; i < q_vectors; i++)
418 i40evf_msix_clean_rings(0, &adapter->q_vectors[i]);
419}
420
421#endif
422/** 399/**
423 * i40evf_irq_affinity_notify - Callback for affinity changes 400 * i40evf_irq_affinity_notify - Callback for affinity changes
424 * @notify: context as to what irq was changed 401 * @notify: context as to what irq was changed
@@ -3229,9 +3206,6 @@ static const struct net_device_ops i40evf_netdev_ops = {
3229 .ndo_features_check = i40evf_features_check, 3206 .ndo_features_check = i40evf_features_check,
3230 .ndo_fix_features = i40evf_fix_features, 3207 .ndo_fix_features = i40evf_fix_features,
3231 .ndo_set_features = i40evf_set_features, 3208 .ndo_set_features = i40evf_set_features,
3232#ifdef CONFIG_NET_POLL_CONTROLLER
3233 .ndo_poll_controller = i40evf_netpoll,
3234#endif
3235 .ndo_setup_tc = i40evf_setup_tc, 3209 .ndo_setup_tc = i40evf_setup_tc,
3236}; 3210};
3237 3211
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index f1e80eed2fd6..3f047bb43348 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -4806,30 +4806,6 @@ void ice_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
4806 stats->rx_length_errors = vsi_stats->rx_length_errors; 4806 stats->rx_length_errors = vsi_stats->rx_length_errors;
4807} 4807}
4808 4808
4809#ifdef CONFIG_NET_POLL_CONTROLLER
4810/**
4811 * ice_netpoll - polling "interrupt" handler
4812 * @netdev: network interface device structure
4813 *
4814 * Used by netconsole to send skbs without having to re-enable interrupts.
4815 * This is not called in the normal interrupt path.
4816 */
4817static void ice_netpoll(struct net_device *netdev)
4818{
4819 struct ice_netdev_priv *np = netdev_priv(netdev);
4820 struct ice_vsi *vsi = np->vsi;
4821 struct ice_pf *pf = vsi->back;
4822 int i;
4823
4824 if (test_bit(__ICE_DOWN, vsi->state) ||
4825 !test_bit(ICE_FLAG_MSIX_ENA, pf->flags))
4826 return;
4827
4828 for (i = 0; i < vsi->num_q_vectors; i++)
4829 ice_msix_clean_rings(0, vsi->q_vectors[i]);
4830}
4831#endif /* CONFIG_NET_POLL_CONTROLLER */
4832
4833/** 4809/**
4834 * ice_napi_disable_all - Disable NAPI for all q_vectors in the VSI 4810 * ice_napi_disable_all - Disable NAPI for all q_vectors in the VSI
4835 * @vsi: VSI having NAPI disabled 4811 * @vsi: VSI having NAPI disabled
@@ -5497,9 +5473,6 @@ static const struct net_device_ops ice_netdev_ops = {
5497 .ndo_validate_addr = eth_validate_addr, 5473 .ndo_validate_addr = eth_validate_addr,
5498 .ndo_change_mtu = ice_change_mtu, 5474 .ndo_change_mtu = ice_change_mtu,
5499 .ndo_get_stats64 = ice_get_stats64, 5475 .ndo_get_stats64 = ice_get_stats64,
5500#ifdef CONFIG_NET_POLL_CONTROLLER
5501 .ndo_poll_controller = ice_netpoll,
5502#endif /* CONFIG_NET_POLL_CONTROLLER */
5503 .ndo_vlan_rx_add_vid = ice_vlan_rx_add_vid, 5476 .ndo_vlan_rx_add_vid = ice_vlan_rx_add_vid,
5504 .ndo_vlan_rx_kill_vid = ice_vlan_rx_kill_vid, 5477 .ndo_vlan_rx_kill_vid = ice_vlan_rx_kill_vid,
5505 .ndo_set_features = ice_set_features, 5478 .ndo_set_features = ice_set_features,
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index a32c576c1e65..0796cef96fa3 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -205,10 +205,6 @@ static struct notifier_block dca_notifier = {
205 .priority = 0 205 .priority = 0
206}; 206};
207#endif 207#endif
208#ifdef CONFIG_NET_POLL_CONTROLLER
209/* for netdump / net console */
210static void igb_netpoll(struct net_device *);
211#endif
212#ifdef CONFIG_PCI_IOV 208#ifdef CONFIG_PCI_IOV
213static unsigned int max_vfs; 209static unsigned int max_vfs;
214module_param(max_vfs, uint, 0); 210module_param(max_vfs, uint, 0);
@@ -2881,9 +2877,6 @@ static const struct net_device_ops igb_netdev_ops = {
2881 .ndo_set_vf_spoofchk = igb_ndo_set_vf_spoofchk, 2877 .ndo_set_vf_spoofchk = igb_ndo_set_vf_spoofchk,
2882 .ndo_set_vf_trust = igb_ndo_set_vf_trust, 2878 .ndo_set_vf_trust = igb_ndo_set_vf_trust,
2883 .ndo_get_vf_config = igb_ndo_get_vf_config, 2879 .ndo_get_vf_config = igb_ndo_get_vf_config,
2884#ifdef CONFIG_NET_POLL_CONTROLLER
2885 .ndo_poll_controller = igb_netpoll,
2886#endif
2887 .ndo_fix_features = igb_fix_features, 2880 .ndo_fix_features = igb_fix_features,
2888 .ndo_set_features = igb_set_features, 2881 .ndo_set_features = igb_set_features,
2889 .ndo_fdb_add = igb_ndo_fdb_add, 2882 .ndo_fdb_add = igb_ndo_fdb_add,
@@ -9053,29 +9046,6 @@ static int igb_pci_sriov_configure(struct pci_dev *dev, int num_vfs)
9053 return 0; 9046 return 0;
9054} 9047}
9055 9048
9056#ifdef CONFIG_NET_POLL_CONTROLLER
9057/* Polling 'interrupt' - used by things like netconsole to send skbs
9058 * without having to re-enable interrupts. It's not called while
9059 * the interrupt routine is executing.
9060 */
9061static void igb_netpoll(struct net_device *netdev)
9062{
9063 struct igb_adapter *adapter = netdev_priv(netdev);
9064 struct e1000_hw *hw = &adapter->hw;
9065 struct igb_q_vector *q_vector;
9066 int i;
9067
9068 for (i = 0; i < adapter->num_q_vectors; i++) {
9069 q_vector = adapter->q_vector[i];
9070 if (adapter->flags & IGB_FLAG_HAS_MSIX)
9071 wr32(E1000_EIMC, q_vector->eims_value);
9072 else
9073 igb_irq_disable(adapter);
9074 napi_schedule(&q_vector->napi);
9075 }
9076}
9077#endif /* CONFIG_NET_POLL_CONTROLLER */
9078
9079/** 9049/**
9080 * igb_io_error_detected - called when PCI error is detected 9050 * igb_io_error_detected - called when PCI error is detected
9081 * @pdev: Pointer to PCI device 9051 * @pdev: Pointer to PCI device
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
index d3e72d0f66ef..7722153c4ac2 100644
--- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c
+++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
@@ -81,11 +81,6 @@ static int ixgb_vlan_rx_kill_vid(struct net_device *netdev,
81 __be16 proto, u16 vid); 81 __be16 proto, u16 vid);
82static void ixgb_restore_vlan(struct ixgb_adapter *adapter); 82static void ixgb_restore_vlan(struct ixgb_adapter *adapter);
83 83
84#ifdef CONFIG_NET_POLL_CONTROLLER
85/* for netdump / net console */
86static void ixgb_netpoll(struct net_device *dev);
87#endif
88
89static pci_ers_result_t ixgb_io_error_detected (struct pci_dev *pdev, 84static pci_ers_result_t ixgb_io_error_detected (struct pci_dev *pdev,
90 enum pci_channel_state state); 85 enum pci_channel_state state);
91static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev); 86static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev);
@@ -348,9 +343,6 @@ static const struct net_device_ops ixgb_netdev_ops = {
348 .ndo_tx_timeout = ixgb_tx_timeout, 343 .ndo_tx_timeout = ixgb_tx_timeout,
349 .ndo_vlan_rx_add_vid = ixgb_vlan_rx_add_vid, 344 .ndo_vlan_rx_add_vid = ixgb_vlan_rx_add_vid,
350 .ndo_vlan_rx_kill_vid = ixgb_vlan_rx_kill_vid, 345 .ndo_vlan_rx_kill_vid = ixgb_vlan_rx_kill_vid,
351#ifdef CONFIG_NET_POLL_CONTROLLER
352 .ndo_poll_controller = ixgb_netpoll,
353#endif
354 .ndo_fix_features = ixgb_fix_features, 346 .ndo_fix_features = ixgb_fix_features,
355 .ndo_set_features = ixgb_set_features, 347 .ndo_set_features = ixgb_set_features,
356}; 348};
@@ -2195,23 +2187,6 @@ ixgb_restore_vlan(struct ixgb_adapter *adapter)
2195 ixgb_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), vid); 2187 ixgb_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), vid);
2196} 2188}
2197 2189
2198#ifdef CONFIG_NET_POLL_CONTROLLER
2199/*
2200 * Polling 'interrupt' - used by things like netconsole to send skbs
2201 * without having to re-enable interrupts. It's not called while
2202 * the interrupt routine is executing.
2203 */
2204
2205static void ixgb_netpoll(struct net_device *dev)
2206{
2207 struct ixgb_adapter *adapter = netdev_priv(dev);
2208
2209 disable_irq(adapter->pdev->irq);
2210 ixgb_intr(adapter->pdev->irq, dev);
2211 enable_irq(adapter->pdev->irq);
2212}
2213#endif
2214
2215/** 2190/**
2216 * ixgb_io_error_detected - called when PCI error is detected 2191 * ixgb_io_error_detected - called when PCI error is detected
2217 * @pdev: pointer to pci device with error 2192 * @pdev: pointer to pci device with error
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 9a23d33a47ed..f27d73a7bf16 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -8768,28 +8768,6 @@ static int ixgbe_del_sanmac_netdev(struct net_device *dev)
8768 return err; 8768 return err;
8769} 8769}
8770 8770
8771#ifdef CONFIG_NET_POLL_CONTROLLER
8772/*
8773 * Polling 'interrupt' - used by things like netconsole to send skbs
8774 * without having to re-enable interrupts. It's not called while
8775 * the interrupt routine is executing.
8776 */
8777static void ixgbe_netpoll(struct net_device *netdev)
8778{
8779 struct ixgbe_adapter *adapter = netdev_priv(netdev);
8780 int i;
8781
8782 /* if interface is down do nothing */
8783 if (test_bit(__IXGBE_DOWN, &adapter->state))
8784 return;
8785
8786 /* loop through and schedule all active queues */
8787 for (i = 0; i < adapter->num_q_vectors; i++)
8788 ixgbe_msix_clean_rings(0, adapter->q_vector[i]);
8789}
8790
8791#endif
8792
8793static void ixgbe_get_ring_stats64(struct rtnl_link_stats64 *stats, 8771static void ixgbe_get_ring_stats64(struct rtnl_link_stats64 *stats,
8794 struct ixgbe_ring *ring) 8772 struct ixgbe_ring *ring)
8795{ 8773{
@@ -10251,9 +10229,6 @@ static const struct net_device_ops ixgbe_netdev_ops = {
10251 .ndo_get_vf_config = ixgbe_ndo_get_vf_config, 10229 .ndo_get_vf_config = ixgbe_ndo_get_vf_config,
10252 .ndo_get_stats64 = ixgbe_get_stats64, 10230 .ndo_get_stats64 = ixgbe_get_stats64,
10253 .ndo_setup_tc = __ixgbe_setup_tc, 10231 .ndo_setup_tc = __ixgbe_setup_tc,
10254#ifdef CONFIG_NET_POLL_CONTROLLER
10255 .ndo_poll_controller = ixgbe_netpoll,
10256#endif
10257#ifdef IXGBE_FCOE 10232#ifdef IXGBE_FCOE
10258 .ndo_select_queue = ixgbe_select_queue, 10233 .ndo_select_queue = ixgbe_select_queue,
10259 .ndo_fcoe_ddp_setup = ixgbe_fcoe_ddp_get, 10234 .ndo_fcoe_ddp_setup = ixgbe_fcoe_ddp_get,
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index d86446d202d5..5a228582423b 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -4233,24 +4233,6 @@ static int ixgbevf_change_mtu(struct net_device *netdev, int new_mtu)
4233 return 0; 4233 return 0;
4234} 4234}
4235 4235
4236#ifdef CONFIG_NET_POLL_CONTROLLER
4237/* Polling 'interrupt' - used by things like netconsole to send skbs
4238 * without having to re-enable interrupts. It's not called while
4239 * the interrupt routine is executing.
4240 */
4241static void ixgbevf_netpoll(struct net_device *netdev)
4242{
4243 struct ixgbevf_adapter *adapter = netdev_priv(netdev);
4244 int i;
4245
4246 /* if interface is down do nothing */
4247 if (test_bit(__IXGBEVF_DOWN, &adapter->state))
4248 return;
4249 for (i = 0; i < adapter->num_rx_queues; i++)
4250 ixgbevf_msix_clean_rings(0, adapter->q_vector[i]);
4251}
4252#endif /* CONFIG_NET_POLL_CONTROLLER */
4253
4254static int ixgbevf_suspend(struct pci_dev *pdev, pm_message_t state) 4236static int ixgbevf_suspend(struct pci_dev *pdev, pm_message_t state)
4255{ 4237{
4256 struct net_device *netdev = pci_get_drvdata(pdev); 4238 struct net_device *netdev = pci_get_drvdata(pdev);
@@ -4482,9 +4464,6 @@ static const struct net_device_ops ixgbevf_netdev_ops = {
4482 .ndo_tx_timeout = ixgbevf_tx_timeout, 4464 .ndo_tx_timeout = ixgbevf_tx_timeout,
4483 .ndo_vlan_rx_add_vid = ixgbevf_vlan_rx_add_vid, 4465 .ndo_vlan_rx_add_vid = ixgbevf_vlan_rx_add_vid,
4484 .ndo_vlan_rx_kill_vid = ixgbevf_vlan_rx_kill_vid, 4466 .ndo_vlan_rx_kill_vid = ixgbevf_vlan_rx_kill_vid,
4485#ifdef CONFIG_NET_POLL_CONTROLLER
4486 .ndo_poll_controller = ixgbevf_netpoll,
4487#endif
4488 .ndo_features_check = ixgbevf_features_check, 4467 .ndo_features_check = ixgbevf_features_check,
4489 .ndo_bpf = ixgbevf_xdp, 4468 .ndo_bpf = ixgbevf_xdp,
4490}; 4469};
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 6785661d1a72..fe49384eba48 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -1286,20 +1286,6 @@ out:
1286 mutex_unlock(&mdev->state_lock); 1286 mutex_unlock(&mdev->state_lock);
1287} 1287}
1288 1288
1289#ifdef CONFIG_NET_POLL_CONTROLLER
1290static void mlx4_en_netpoll(struct net_device *dev)
1291{
1292 struct mlx4_en_priv *priv = netdev_priv(dev);
1293 struct mlx4_en_cq *cq;
1294 int i;
1295
1296 for (i = 0; i < priv->tx_ring_num[TX]; i++) {
1297 cq = priv->tx_cq[TX][i];
1298 napi_schedule(&cq->napi);
1299 }
1300}
1301#endif
1302
1303static int mlx4_en_set_rss_steer_rules(struct mlx4_en_priv *priv) 1289static int mlx4_en_set_rss_steer_rules(struct mlx4_en_priv *priv)
1304{ 1290{
1305 u64 reg_id; 1291 u64 reg_id;
@@ -2946,9 +2932,6 @@ static const struct net_device_ops mlx4_netdev_ops = {
2946 .ndo_tx_timeout = mlx4_en_tx_timeout, 2932 .ndo_tx_timeout = mlx4_en_tx_timeout,
2947 .ndo_vlan_rx_add_vid = mlx4_en_vlan_rx_add_vid, 2933 .ndo_vlan_rx_add_vid = mlx4_en_vlan_rx_add_vid,
2948 .ndo_vlan_rx_kill_vid = mlx4_en_vlan_rx_kill_vid, 2934 .ndo_vlan_rx_kill_vid = mlx4_en_vlan_rx_kill_vid,
2949#ifdef CONFIG_NET_POLL_CONTROLLER
2950 .ndo_poll_controller = mlx4_en_netpoll,
2951#endif
2952 .ndo_set_features = mlx4_en_set_features, 2935 .ndo_set_features = mlx4_en_set_features,
2953 .ndo_fix_features = mlx4_en_fix_features, 2936 .ndo_fix_features = mlx4_en_fix_features,
2954 .ndo_setup_tc = __mlx4_en_setup_tc, 2937 .ndo_setup_tc = __mlx4_en_setup_tc,
@@ -2983,9 +2966,6 @@ static const struct net_device_ops mlx4_netdev_ops_master = {
2983 .ndo_set_vf_link_state = mlx4_en_set_vf_link_state, 2966 .ndo_set_vf_link_state = mlx4_en_set_vf_link_state,
2984 .ndo_get_vf_stats = mlx4_en_get_vf_stats, 2967 .ndo_get_vf_stats = mlx4_en_get_vf_stats,
2985 .ndo_get_vf_config = mlx4_en_get_vf_config, 2968 .ndo_get_vf_config = mlx4_en_get_vf_config,
2986#ifdef CONFIG_NET_POLL_CONTROLLER
2987 .ndo_poll_controller = mlx4_en_netpoll,
2988#endif
2989 .ndo_set_features = mlx4_en_set_features, 2969 .ndo_set_features = mlx4_en_set_features,
2990 .ndo_fix_features = mlx4_en_fix_features, 2970 .ndo_fix_features = mlx4_en_fix_features,
2991 .ndo_setup_tc = __mlx4_en_setup_tc, 2971 .ndo_setup_tc = __mlx4_en_setup_tc,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 5a7939e70190..54118b77dc1f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -4315,22 +4315,6 @@ static int mlx5e_xdp(struct net_device *dev, struct netdev_bpf *xdp)
4315 } 4315 }
4316} 4316}
4317 4317
4318#ifdef CONFIG_NET_POLL_CONTROLLER
4319/* Fake "interrupt" called by netpoll (eg netconsole) to send skbs without
4320 * reenabling interrupts.
4321 */
4322static void mlx5e_netpoll(struct net_device *dev)
4323{
4324 struct mlx5e_priv *priv = netdev_priv(dev);
4325 struct mlx5e_channels *chs = &priv->channels;
4326
4327 int i;
4328
4329 for (i = 0; i < chs->num; i++)
4330 napi_schedule(&chs->c[i]->napi);
4331}
4332#endif
4333
4334static const struct net_device_ops mlx5e_netdev_ops = { 4318static const struct net_device_ops mlx5e_netdev_ops = {
4335 .ndo_open = mlx5e_open, 4319 .ndo_open = mlx5e_open,
4336 .ndo_stop = mlx5e_close, 4320 .ndo_stop = mlx5e_close,
@@ -4356,9 +4340,6 @@ static const struct net_device_ops mlx5e_netdev_ops = {
4356#ifdef CONFIG_MLX5_EN_ARFS 4340#ifdef CONFIG_MLX5_EN_ARFS
4357 .ndo_rx_flow_steer = mlx5e_rx_flow_steer, 4341 .ndo_rx_flow_steer = mlx5e_rx_flow_steer,
4358#endif 4342#endif
4359#ifdef CONFIG_NET_POLL_CONTROLLER
4360 .ndo_poll_controller = mlx5e_netpoll,
4361#endif
4362#ifdef CONFIG_MLX5_ESWITCH 4343#ifdef CONFIG_MLX5_ESWITCH
4363 /* SRIOV E-Switch NDOs */ 4344 /* SRIOV E-Switch NDOs */
4364 .ndo_set_vf_mac = mlx5e_set_vf_mac, 4345 .ndo_set_vf_mac = mlx5e_set_vf_mac,
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 253bdaef1505..8ed38fd5a852 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -3146,21 +3146,6 @@ nfp_net_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid)
3146 return nfp_net_reconfig_mbox(nn, NFP_NET_CFG_MBOX_CMD_CTAG_FILTER_KILL); 3146 return nfp_net_reconfig_mbox(nn, NFP_NET_CFG_MBOX_CMD_CTAG_FILTER_KILL);
3147} 3147}
3148 3148
3149#ifdef CONFIG_NET_POLL_CONTROLLER
3150static void nfp_net_netpoll(struct net_device *netdev)
3151{
3152 struct nfp_net *nn = netdev_priv(netdev);
3153 int i;
3154
3155 /* nfp_net's NAPIs are statically allocated so even if there is a race
3156 * with reconfig path this will simply try to schedule some disabled
3157 * NAPI instances.
3158 */
3159 for (i = 0; i < nn->dp.num_stack_tx_rings; i++)
3160 napi_schedule_irqoff(&nn->r_vecs[i].napi);
3161}
3162#endif
3163
3164static void nfp_net_stat64(struct net_device *netdev, 3149static void nfp_net_stat64(struct net_device *netdev,
3165 struct rtnl_link_stats64 *stats) 3150 struct rtnl_link_stats64 *stats)
3166{ 3151{
@@ -3519,9 +3504,6 @@ const struct net_device_ops nfp_net_netdev_ops = {
3519 .ndo_get_stats64 = nfp_net_stat64, 3504 .ndo_get_stats64 = nfp_net_stat64,
3520 .ndo_vlan_rx_add_vid = nfp_net_vlan_rx_add_vid, 3505 .ndo_vlan_rx_add_vid = nfp_net_vlan_rx_add_vid,
3521 .ndo_vlan_rx_kill_vid = nfp_net_vlan_rx_kill_vid, 3506 .ndo_vlan_rx_kill_vid = nfp_net_vlan_rx_kill_vid,
3522#ifdef CONFIG_NET_POLL_CONTROLLER
3523 .ndo_poll_controller = nfp_net_netpoll,
3524#endif
3525 .ndo_set_vf_mac = nfp_app_set_vf_mac, 3507 .ndo_set_vf_mac = nfp_app_set_vf_mac,
3526 .ndo_set_vf_vlan = nfp_app_set_vf_vlan, 3508 .ndo_set_vf_vlan = nfp_app_set_vf_vlan,
3527 .ndo_set_vf_spoofchk = nfp_app_set_vf_spoofchk, 3509 .ndo_set_vf_spoofchk = nfp_app_set_vf_spoofchk,
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index ebd07ad82431..e2648b5a3861 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1153,43 +1153,6 @@ static netdev_features_t tun_net_fix_features(struct net_device *dev,
1153 1153
1154 return (features & tun->set_features) | (features & ~TUN_USER_FEATURES); 1154 return (features & tun->set_features) | (features & ~TUN_USER_FEATURES);
1155} 1155}
1156#ifdef CONFIG_NET_POLL_CONTROLLER
1157static void tun_poll_controller(struct net_device *dev)
1158{
1159 /*
1160 * Tun only receives frames when:
1161 * 1) the char device endpoint gets data from user space
1162 * 2) the tun socket gets a sendmsg call from user space
1163 * If NAPI is not enabled, since both of those are synchronous
1164 * operations, we are guaranteed never to have pending data when we poll
1165 * for it so there is nothing to do here but return.
1166 * We need this though so netpoll recognizes us as an interface that
1167 * supports polling, which enables bridge devices in virt setups to
1168 * still use netconsole
1169 * If NAPI is enabled, however, we need to schedule polling for all
1170 * queues unless we are using napi_gro_frags(), which we call in
1171 * process context and not in NAPI context.
1172 */
1173 struct tun_struct *tun = netdev_priv(dev);
1174
1175 if (tun->flags & IFF_NAPI) {
1176 struct tun_file *tfile;
1177 int i;
1178
1179 if (tun_napi_frags_enabled(tun))
1180 return;
1181
1182 rcu_read_lock();
1183 for (i = 0; i < tun->numqueues; i++) {
1184 tfile = rcu_dereference(tun->tfiles[i]);
1185 if (tfile->napi_enabled)
1186 napi_schedule(&tfile->napi);
1187 }
1188 rcu_read_unlock();
1189 }
1190 return;
1191}
1192#endif
1193 1156
1194static void tun_set_headroom(struct net_device *dev, int new_hr) 1157static void tun_set_headroom(struct net_device *dev, int new_hr)
1195{ 1158{
@@ -1283,9 +1246,6 @@ static const struct net_device_ops tun_netdev_ops = {
1283 .ndo_start_xmit = tun_net_xmit, 1246 .ndo_start_xmit = tun_net_xmit,
1284 .ndo_fix_features = tun_net_fix_features, 1247 .ndo_fix_features = tun_net_fix_features,
1285 .ndo_select_queue = tun_select_queue, 1248 .ndo_select_queue = tun_select_queue,
1286#ifdef CONFIG_NET_POLL_CONTROLLER
1287 .ndo_poll_controller = tun_poll_controller,
1288#endif
1289 .ndo_set_rx_headroom = tun_set_headroom, 1249 .ndo_set_rx_headroom = tun_set_headroom,
1290 .ndo_get_stats64 = tun_net_get_stats64, 1250 .ndo_get_stats64 = tun_net_get_stats64,
1291}; 1251};
@@ -1365,9 +1325,6 @@ static const struct net_device_ops tap_netdev_ops = {
1365 .ndo_set_mac_address = eth_mac_addr, 1325 .ndo_set_mac_address = eth_mac_addr,
1366 .ndo_validate_addr = eth_validate_addr, 1326 .ndo_validate_addr = eth_validate_addr,
1367 .ndo_select_queue = tun_select_queue, 1327 .ndo_select_queue = tun_select_queue,
1368#ifdef CONFIG_NET_POLL_CONTROLLER
1369 .ndo_poll_controller = tun_poll_controller,
1370#endif
1371 .ndo_features_check = passthru_features_check, 1328 .ndo_features_check = passthru_features_check,
1372 .ndo_set_rx_headroom = tun_set_headroom, 1329 .ndo_set_rx_headroom = tun_set_headroom,
1373 .ndo_get_stats64 = tun_net_get_stats64, 1330 .ndo_get_stats64 = tun_net_get_stats64,
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index 67662d01130a..3ef82d3a78db 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -49,8 +49,9 @@ struct netpoll_info {
49}; 49};
50 50
51#ifdef CONFIG_NETPOLL 51#ifdef CONFIG_NETPOLL
52extern void netpoll_poll_disable(struct net_device *dev); 52void netpoll_poll_dev(struct net_device *dev);
53extern void netpoll_poll_enable(struct net_device *dev); 53void netpoll_poll_disable(struct net_device *dev);
54void netpoll_poll_enable(struct net_device *dev);
54#else 55#else
55static inline void netpoll_poll_disable(struct net_device *dev) { return; } 56static inline void netpoll_poll_disable(struct net_device *dev) { return; }
56static inline void netpoll_poll_enable(struct net_device *dev) { return; } 57static inline void netpoll_poll_enable(struct net_device *dev) { return; }
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 57557a6a950c..3219a2932463 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -187,16 +187,16 @@ static void poll_napi(struct net_device *dev)
187 } 187 }
188} 188}
189 189
190static void netpoll_poll_dev(struct net_device *dev) 190void netpoll_poll_dev(struct net_device *dev)
191{ 191{
192 const struct net_device_ops *ops;
193 struct netpoll_info *ni = rcu_dereference_bh(dev->npinfo); 192 struct netpoll_info *ni = rcu_dereference_bh(dev->npinfo);
193 const struct net_device_ops *ops;
194 194
195 /* Don't do any rx activity if the dev_lock mutex is held 195 /* Don't do any rx activity if the dev_lock mutex is held
196 * the dev_open/close paths use this to block netpoll activity 196 * the dev_open/close paths use this to block netpoll activity
197 * while changing device state 197 * while changing device state
198 */ 198 */
199 if (down_trylock(&ni->dev_lock)) 199 if (!ni || down_trylock(&ni->dev_lock))
200 return; 200 return;
201 201
202 if (!netif_running(dev)) { 202 if (!netif_running(dev)) {
@@ -205,13 +205,8 @@ static void netpoll_poll_dev(struct net_device *dev)
205 } 205 }
206 206
207 ops = dev->netdev_ops; 207 ops = dev->netdev_ops;
208 if (!ops->ndo_poll_controller) { 208 if (ops->ndo_poll_controller)
209 up(&ni->dev_lock); 209 ops->ndo_poll_controller(dev);
210 return;
211 }
212
213 /* Process pending work on NIC */
214 ops->ndo_poll_controller(dev);
215 210
216 poll_napi(dev); 211 poll_napi(dev);
217 212
@@ -219,6 +214,7 @@ static void netpoll_poll_dev(struct net_device *dev)
219 214
220 zap_completion_queue(); 215 zap_completion_queue();
221} 216}
217EXPORT_SYMBOL(netpoll_poll_dev);
222 218
223void netpoll_poll_disable(struct net_device *dev) 219void netpoll_poll_disable(struct net_device *dev)
224{ 220{
@@ -613,8 +609,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)
613 strlcpy(np->dev_name, ndev->name, IFNAMSIZ); 609 strlcpy(np->dev_name, ndev->name, IFNAMSIZ);
614 INIT_WORK(&np->cleanup_work, netpoll_async_cleanup); 610 INIT_WORK(&np->cleanup_work, netpoll_async_cleanup);
615 611
616 if ((ndev->priv_flags & IFF_DISABLE_NETPOLL) || 612 if (ndev->priv_flags & IFF_DISABLE_NETPOLL) {
617 !ndev->netdev_ops->ndo_poll_controller) {
618 np_err(np, "%s doesn't support polling, aborting\n", 613 np_err(np, "%s doesn't support polling, aborting\n",
619 np->dev_name); 614 np->dev_name);
620 err = -ENOTSUPP; 615 err = -ENOTSUPP;