aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-06-15 05:09:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-06-15 05:09:47 -0400
commita090bd4ff8387c409732a8e059fbf264ea0bdd56 (patch)
tree12e799ce6da48774c74a0e05766d316243408645
parent54ed0f71f0a0cbf3218e2503a50364f178b1e855 (diff)
parent640f93cc6ea7327588be3cc0849d1342aac0393a (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) The netlink attribute passed in to dev_set_alias() is not necessarily NULL terminated, don't use strlcpy() on it. From Alexander Potapenko. 2) Fix implementation of atomics in arm64 bpf JIT, from Daniel Borkmann. 3) Correct the release of netdevs and driver private data in certain circumstances. 4) Sanitize netlink message length properly in decnet, from Mateusz Jurczyk. 5) Don't leak kernel data in rtnl_fill_vfinfo() netlink blobs. From Yuval Mintz. 6) Hash secret is never initialized in ipv6 ILA translation code, from Arnd Bergmann. I guess those clang warnings about unused inline functions are useful for something! 7) Fix endian selection in bpf_endian.h, from Daniel Borkmann. 8) Sanitize sockaddr length before dereferncing any fields in AF_UNIX and CAIF. From Mateusz Jurczyk. 9) Fix timestamping for GMAC3 chips in stmmac driver, from Mario Molitor. 10) Do not leak netdev on dev_alloc_name() errors in mac80211, from Johannes Berg. 11) Fix locking in sctp_for_each_endpoint(), from Xin Long. 12) Fix wrong memset size on 32-bit in snmp6, from Christian Perle. 13) Fix use after free in ip_mc_clear_src(), from WANG Cong. 14) Fix regressions caused by ICMP rate limiting changes in 4.11, from Jesper Dangaard Brouer. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (91 commits) i40e: Fix a sleep-in-atomic bug net: don't global ICMP rate limit packets originating from loopback net/act_pedit: fix an error code net: update undefined ->ndo_change_mtu() comment net_sched: move tcf_lock down after gen_replace_estimator() caif: Add sockaddr length check before accessing sa_family in connect handler qed: fix dump of context data qmi_wwan: new Telewell and Sierra device IDs net: phy: Fix MDIO_THUNDER dependencies netconsole: Remove duplicate "netconsole: " logging prefix igmp: acquire pmc lock for ip_mc_clear_src() r8152: give the device version net: rps: fix uninitialized symbol warning mac80211: don't send SMPS action frame in AP mode when not needed mac80211/wpa: use constant time memory comparison for MACs mac80211: set bss_info data before configuring the channel mac80211: remove 5/10 MHz rate code from station MLME mac80211: Fix incorrect condition when checking rx timestamp mac80211: don't look at the PM bit of BAR frames i40e: fix handling of HW ATR eviction ...
-rw-r--r--Documentation/networking/scaling.txt2
-rw-r--r--arch/arm64/net/bpf_jit_comp.c7
-rw-r--r--drivers/hsi/clients/ssi_protocol.c2
-rw-r--r--drivers/net/bonding/bond_3ad.c27
-rw-r--r--drivers/net/bonding/bond_main.c6
-rw-r--r--drivers/net/caif/caif_hsi.c2
-rw-r--r--drivers/net/caif/caif_serial.c2
-rw-r--r--drivers/net/caif/caif_spi.c2
-rw-r--r--drivers/net/caif/caif_virtio.c2
-rw-r--r--drivers/net/can/dev.c3
-rw-r--r--drivers/net/can/peak_canfd/peak_canfd.c2
-rw-r--r--drivers/net/can/slcan.c7
-rw-r--r--drivers/net/can/usb/gs_usb.c2
-rw-r--r--drivers/net/can/usb/peak_usb/pcan_usb_core.c4
-rw-r--r--drivers/net/can/vcan.c4
-rw-r--r--drivers/net/can/vxcan.c4
-rw-r--r--drivers/net/dummy.c4
-rw-r--r--drivers/net/ethernet/amazon/ena/ena_com.c35
-rw-r--r--drivers/net/ethernet/amazon/ena/ena_ethtool.c2
-rw-r--r--drivers/net/ethernet/amazon/ena/ena_netdev.c179
-rw-r--r--drivers/net/ethernet/amazon/ena/ena_netdev.h18
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h3
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c19
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c15
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h1
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c2
-rw-r--r--drivers/net/ethernet/ibm/emac/core.c67
-rw-r--r--drivers/net/ethernet/ibm/ibmvnic.c6
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e.h1
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_ethtool.c4
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c7
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_txrx.c4
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c2
-rw-r--r--drivers/net/ethernet/marvell/mvpp2.c76
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h8
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c45
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_stats.h11
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_core.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/health.c11
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c6
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_debug.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c11
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c25
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h3
-rw-r--r--drivers/net/geneve.c2
-rw-r--r--drivers/net/gtp.c2
-rw-r--r--drivers/net/hamradio/6pack.c2
-rw-r--r--drivers/net/hamradio/bpqether.c2
-rw-r--r--drivers/net/hyperv/hyperv_net.h5
-rw-r--r--drivers/net/hyperv/netvsc_drv.c54
-rw-r--r--drivers/net/hyperv/rndis_filter.c30
-rw-r--r--drivers/net/ifb.c4
-rw-r--r--drivers/net/ipvlan/ipvlan_main.c2
-rw-r--r--drivers/net/loopback.c4
-rw-r--r--drivers/net/macsec.c4
-rw-r--r--drivers/net/macvlan.c2
-rw-r--r--drivers/net/netconsole.c2
-rw-r--r--drivers/net/nlmon.c2
-rw-r--r--drivers/net/phy/Kconfig1
-rw-r--r--drivers/net/phy/phy.c2
-rw-r--r--drivers/net/slip/slip.c7
-rw-r--r--drivers/net/team/team.c4
-rw-r--r--drivers/net/tun.c4
-rw-r--r--drivers/net/usb/cdc-phonet.c2
-rw-r--r--drivers/net/usb/qmi_wwan.c6
-rw-r--r--drivers/net/usb/r8152.c2
-rw-r--r--drivers/net/veth.c4
-rw-r--r--drivers/net/vrf.c38
-rw-r--r--drivers/net/vsockmon.c2
-rw-r--r--drivers/net/vxlan.c2
-rw-r--r--drivers/net/wan/dlci.c2
-rw-r--r--drivers/net/wan/hdlc_fr.c2
-rw-r--r--drivers/net/wan/lapbether.c2
-rw-r--r--drivers/net/wireless/ath/ath6kl/main.c2
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c1
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c3
-rw-r--r--drivers/net/wireless/intersil/hostap/hostap_main.c2
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c2
-rw-r--r--drivers/net/wireless/marvell/mwifiex/main.c2
-rw-r--r--drivers/s390/net/netiucv.c4
-rw-r--r--drivers/staging/rtl8188eu/os_dep/mon.c2
-rw-r--r--drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c3
-rw-r--r--drivers/staging/rtl8723bs/os_dep/os_intfs.c2
-rw-r--r--drivers/usb/gadget/function/f_phonet.c2
-rw-r--r--include/linux/netdevice.h15
-rw-r--r--include/uapi/linux/ethtool.h6
-rw-r--r--include/uapi/linux/openvswitch.h1
-rw-r--r--net/8021q/vlan_dev.c4
-rw-r--r--net/batman-adv/distributed-arp-table.c5
-rw-r--r--net/batman-adv/routing.c2
-rw-r--r--net/batman-adv/soft-interface.c5
-rw-r--r--net/bluetooth/6lowpan.c2
-rw-r--r--net/bridge/br_device.c2
-rw-r--r--net/caif/caif_socket.c4
-rw-r--r--net/caif/cfpkt_skbuff.c6
-rw-r--r--net/caif/chnl_net.c4
-rw-r--r--net/can/af_can.c3
-rw-r--r--net/core/dev.c42
-rw-r--r--net/core/dst.c14
-rw-r--r--net/core/rtnetlink.c3
-rw-r--r--net/decnet/netfilter/dn_rtmsg.c4
-rw-r--r--net/hsr/hsr_device.c4
-rw-r--r--net/hsr/hsr_forward.c3
-rw-r--r--net/hsr/hsr_framereg.c9
-rw-r--r--net/hsr/hsr_framereg.h2
-rw-r--r--net/ieee802154/6lowpan/core.c2
-rw-r--r--net/ipv4/icmp.c8
-rw-r--r--net/ipv4/igmp.c21
-rw-r--r--net/ipv4/ip_tunnel.c4
-rw-r--r--net/ipv4/ipmr.c34
-rw-r--r--net/ipv6/icmp.c2
-rw-r--r--net/ipv6/ila/ila_xlat.c1
-rw-r--r--net/ipv6/ip6_gre.c9
-rw-r--r--net/ipv6/ip6_tunnel.c8
-rw-r--r--net/ipv6/ip6_vti.c8
-rw-r--r--net/ipv6/ip6mr.c2
-rw-r--r--net/ipv6/proc.c2
-rw-r--r--net/ipv6/route.c1
-rw-r--r--net/ipv6/sit.c6
-rw-r--r--net/irda/irlan/irlan_eth.c2
-rw-r--r--net/l2tp/l2tp_eth.c15
-rw-r--r--net/mac80211/cfg.c2
-rw-r--r--net/mac80211/ieee80211_i.h2
-rw-r--r--net/mac80211/iface.c7
-rw-r--r--net/mac80211/mlme.c62
-rw-r--r--net/mac80211/rx.c6
-rw-r--r--net/mac80211/wpa.c9
-rw-r--r--net/mac802154/iface.c7
-rw-r--r--net/openvswitch/vport-internal_dev.c4
-rw-r--r--net/phonet/pep-gprs.c2
-rw-r--r--net/sched/act_pedit.c4
-rw-r--r--net/sched/act_police.c8
-rw-r--r--net/sctp/socket.c4
-rw-r--r--net/tipc/msg.c2
-rw-r--r--net/unix/af_unix.c7
-rw-r--r--tools/testing/selftests/bpf/bpf_endian.h41
136 files changed, 810 insertions, 491 deletions
diff --git a/Documentation/networking/scaling.txt b/Documentation/networking/scaling.txt
index 59f4db2a0c85..f55639d71d35 100644
--- a/Documentation/networking/scaling.txt
+++ b/Documentation/networking/scaling.txt
@@ -122,7 +122,7 @@ associated flow of the packet. The hash is either provided by hardware
122or will be computed in the stack. Capable hardware can pass the hash in 122or will be computed in the stack. Capable hardware can pass the hash in
123the receive descriptor for the packet; this would usually be the same 123the receive descriptor for the packet; this would usually be the same
124hash used for RSS (e.g. computed Toeplitz hash). The hash is saved in 124hash used for RSS (e.g. computed Toeplitz hash). The hash is saved in
125skb->rx_hash and can be used elsewhere in the stack as a hash of the 125skb->hash and can be used elsewhere in the stack as a hash of the
126packet’s flow. 126packet’s flow.
127 127
128Each receive hardware queue has an associated list of CPUs to which 128Each receive hardware queue has an associated list of CPUs to which
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 71f930501ade..c870d6f01ac2 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -36,6 +36,7 @@ int bpf_jit_enable __read_mostly;
36#define TMP_REG_1 (MAX_BPF_JIT_REG + 0) 36#define TMP_REG_1 (MAX_BPF_JIT_REG + 0)
37#define TMP_REG_2 (MAX_BPF_JIT_REG + 1) 37#define TMP_REG_2 (MAX_BPF_JIT_REG + 1)
38#define TCALL_CNT (MAX_BPF_JIT_REG + 2) 38#define TCALL_CNT (MAX_BPF_JIT_REG + 2)
39#define TMP_REG_3 (MAX_BPF_JIT_REG + 3)
39 40
40/* Map BPF registers to A64 registers */ 41/* Map BPF registers to A64 registers */
41static const int bpf2a64[] = { 42static const int bpf2a64[] = {
@@ -57,6 +58,7 @@ static const int bpf2a64[] = {
57 /* temporary registers for internal BPF JIT */ 58 /* temporary registers for internal BPF JIT */
58 [TMP_REG_1] = A64_R(10), 59 [TMP_REG_1] = A64_R(10),
59 [TMP_REG_2] = A64_R(11), 60 [TMP_REG_2] = A64_R(11),
61 [TMP_REG_3] = A64_R(12),
60 /* tail_call_cnt */ 62 /* tail_call_cnt */
61 [TCALL_CNT] = A64_R(26), 63 [TCALL_CNT] = A64_R(26),
62 /* temporary register for blinding constants */ 64 /* temporary register for blinding constants */
@@ -319,6 +321,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
319 const u8 src = bpf2a64[insn->src_reg]; 321 const u8 src = bpf2a64[insn->src_reg];
320 const u8 tmp = bpf2a64[TMP_REG_1]; 322 const u8 tmp = bpf2a64[TMP_REG_1];
321 const u8 tmp2 = bpf2a64[TMP_REG_2]; 323 const u8 tmp2 = bpf2a64[TMP_REG_2];
324 const u8 tmp3 = bpf2a64[TMP_REG_3];
322 const s16 off = insn->off; 325 const s16 off = insn->off;
323 const s32 imm = insn->imm; 326 const s32 imm = insn->imm;
324 const int i = insn - ctx->prog->insnsi; 327 const int i = insn - ctx->prog->insnsi;
@@ -689,10 +692,10 @@ emit_cond_jmp:
689 emit(A64_PRFM(tmp, PST, L1, STRM), ctx); 692 emit(A64_PRFM(tmp, PST, L1, STRM), ctx);
690 emit(A64_LDXR(isdw, tmp2, tmp), ctx); 693 emit(A64_LDXR(isdw, tmp2, tmp), ctx);
691 emit(A64_ADD(isdw, tmp2, tmp2, src), ctx); 694 emit(A64_ADD(isdw, tmp2, tmp2, src), ctx);
692 emit(A64_STXR(isdw, tmp2, tmp, tmp2), ctx); 695 emit(A64_STXR(isdw, tmp2, tmp, tmp3), ctx);
693 jmp_offset = -3; 696 jmp_offset = -3;
694 check_imm19(jmp_offset); 697 check_imm19(jmp_offset);
695 emit(A64_CBNZ(0, tmp2, jmp_offset), ctx); 698 emit(A64_CBNZ(0, tmp3, jmp_offset), ctx);
696 break; 699 break;
697 700
698 /* R0 = ntohx(*(size *)(((struct sk_buff *)R6)->data + imm)) */ 701 /* R0 = ntohx(*(size *)(((struct sk_buff *)R6)->data + imm)) */
diff --git a/drivers/hsi/clients/ssi_protocol.c b/drivers/hsi/clients/ssi_protocol.c
index 26b05106f0d3..93d28c0ec8bf 100644
--- a/drivers/hsi/clients/ssi_protocol.c
+++ b/drivers/hsi/clients/ssi_protocol.c
@@ -1066,7 +1066,7 @@ static void ssip_pn_setup(struct net_device *dev)
1066 dev->addr_len = 1; 1066 dev->addr_len = 1;
1067 dev->tx_queue_len = SSIP_TXQUEUE_LEN; 1067 dev->tx_queue_len = SSIP_TXQUEUE_LEN;
1068 1068
1069 dev->destructor = free_netdev; 1069 dev->needs_free_netdev = true;
1070 dev->header_ops = &phonet_header_ops; 1070 dev->header_ops = &phonet_header_ops;
1071} 1071}
1072 1072
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index b44a6aeb346d..e5386ab706ec 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -90,10 +90,13 @@ enum ad_link_speed_type {
90 AD_LINK_SPEED_100MBPS, 90 AD_LINK_SPEED_100MBPS,
91 AD_LINK_SPEED_1000MBPS, 91 AD_LINK_SPEED_1000MBPS,
92 AD_LINK_SPEED_2500MBPS, 92 AD_LINK_SPEED_2500MBPS,
93 AD_LINK_SPEED_5000MBPS,
93 AD_LINK_SPEED_10000MBPS, 94 AD_LINK_SPEED_10000MBPS,
95 AD_LINK_SPEED_14000MBPS,
94 AD_LINK_SPEED_20000MBPS, 96 AD_LINK_SPEED_20000MBPS,
95 AD_LINK_SPEED_25000MBPS, 97 AD_LINK_SPEED_25000MBPS,
96 AD_LINK_SPEED_40000MBPS, 98 AD_LINK_SPEED_40000MBPS,
99 AD_LINK_SPEED_50000MBPS,
97 AD_LINK_SPEED_56000MBPS, 100 AD_LINK_SPEED_56000MBPS,
98 AD_LINK_SPEED_100000MBPS, 101 AD_LINK_SPEED_100000MBPS,
99}; 102};
@@ -259,10 +262,13 @@ static inline int __check_agg_selection_timer(struct port *port)
259 * %AD_LINK_SPEED_100MBPS, 262 * %AD_LINK_SPEED_100MBPS,
260 * %AD_LINK_SPEED_1000MBPS, 263 * %AD_LINK_SPEED_1000MBPS,
261 * %AD_LINK_SPEED_2500MBPS, 264 * %AD_LINK_SPEED_2500MBPS,
265 * %AD_LINK_SPEED_5000MBPS,
262 * %AD_LINK_SPEED_10000MBPS 266 * %AD_LINK_SPEED_10000MBPS
267 * %AD_LINK_SPEED_14000MBPS,
263 * %AD_LINK_SPEED_20000MBPS 268 * %AD_LINK_SPEED_20000MBPS
264 * %AD_LINK_SPEED_25000MBPS 269 * %AD_LINK_SPEED_25000MBPS
265 * %AD_LINK_SPEED_40000MBPS 270 * %AD_LINK_SPEED_40000MBPS
271 * %AD_LINK_SPEED_50000MBPS
266 * %AD_LINK_SPEED_56000MBPS 272 * %AD_LINK_SPEED_56000MBPS
267 * %AD_LINK_SPEED_100000MBPS 273 * %AD_LINK_SPEED_100000MBPS
268 */ 274 */
@@ -296,10 +302,18 @@ static u16 __get_link_speed(struct port *port)
296 speed = AD_LINK_SPEED_2500MBPS; 302 speed = AD_LINK_SPEED_2500MBPS;
297 break; 303 break;
298 304
305 case SPEED_5000:
306 speed = AD_LINK_SPEED_5000MBPS;
307 break;
308
299 case SPEED_10000: 309 case SPEED_10000:
300 speed = AD_LINK_SPEED_10000MBPS; 310 speed = AD_LINK_SPEED_10000MBPS;
301 break; 311 break;
302 312
313 case SPEED_14000:
314 speed = AD_LINK_SPEED_14000MBPS;
315 break;
316
303 case SPEED_20000: 317 case SPEED_20000:
304 speed = AD_LINK_SPEED_20000MBPS; 318 speed = AD_LINK_SPEED_20000MBPS;
305 break; 319 break;
@@ -312,6 +326,10 @@ static u16 __get_link_speed(struct port *port)
312 speed = AD_LINK_SPEED_40000MBPS; 326 speed = AD_LINK_SPEED_40000MBPS;
313 break; 327 break;
314 328
329 case SPEED_50000:
330 speed = AD_LINK_SPEED_50000MBPS;
331 break;
332
315 case SPEED_56000: 333 case SPEED_56000:
316 speed = AD_LINK_SPEED_56000MBPS; 334 speed = AD_LINK_SPEED_56000MBPS;
317 break; 335 break;
@@ -707,9 +725,15 @@ static u32 __get_agg_bandwidth(struct aggregator *aggregator)
707 case AD_LINK_SPEED_2500MBPS: 725 case AD_LINK_SPEED_2500MBPS:
708 bandwidth = nports * 2500; 726 bandwidth = nports * 2500;
709 break; 727 break;
728 case AD_LINK_SPEED_5000MBPS:
729 bandwidth = nports * 5000;
730 break;
710 case AD_LINK_SPEED_10000MBPS: 731 case AD_LINK_SPEED_10000MBPS:
711 bandwidth = nports * 10000; 732 bandwidth = nports * 10000;
712 break; 733 break;
734 case AD_LINK_SPEED_14000MBPS:
735 bandwidth = nports * 14000;
736 break;
713 case AD_LINK_SPEED_20000MBPS: 737 case AD_LINK_SPEED_20000MBPS:
714 bandwidth = nports * 20000; 738 bandwidth = nports * 20000;
715 break; 739 break;
@@ -719,6 +743,9 @@ static u32 __get_agg_bandwidth(struct aggregator *aggregator)
719 case AD_LINK_SPEED_40000MBPS: 743 case AD_LINK_SPEED_40000MBPS:
720 bandwidth = nports * 40000; 744 bandwidth = nports * 40000;
721 break; 745 break;
746 case AD_LINK_SPEED_50000MBPS:
747 bandwidth = nports * 50000;
748 break;
722 case AD_LINK_SPEED_56000MBPS: 749 case AD_LINK_SPEED_56000MBPS:
723 bandwidth = nports * 56000; 750 bandwidth = nports * 56000;
724 break; 751 break;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 2359478b977f..8ab6bdbe1682 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4192,7 +4192,6 @@ static void bond_destructor(struct net_device *bond_dev)
4192 struct bonding *bond = netdev_priv(bond_dev); 4192 struct bonding *bond = netdev_priv(bond_dev);
4193 if (bond->wq) 4193 if (bond->wq)
4194 destroy_workqueue(bond->wq); 4194 destroy_workqueue(bond->wq);
4195 free_netdev(bond_dev);
4196} 4195}
4197 4196
4198void bond_setup(struct net_device *bond_dev) 4197void bond_setup(struct net_device *bond_dev)
@@ -4212,7 +4211,8 @@ void bond_setup(struct net_device *bond_dev)
4212 bond_dev->netdev_ops = &bond_netdev_ops; 4211 bond_dev->netdev_ops = &bond_netdev_ops;
4213 bond_dev->ethtool_ops = &bond_ethtool_ops; 4212 bond_dev->ethtool_ops = &bond_ethtool_ops;
4214 4213
4215 bond_dev->destructor = bond_destructor; 4214 bond_dev->needs_free_netdev = true;
4215 bond_dev->priv_destructor = bond_destructor;
4216 4216
4217 SET_NETDEV_DEVTYPE(bond_dev, &bond_type); 4217 SET_NETDEV_DEVTYPE(bond_dev, &bond_type);
4218 4218
@@ -4736,7 +4736,7 @@ int bond_create(struct net *net, const char *name)
4736 4736
4737 rtnl_unlock(); 4737 rtnl_unlock();
4738 if (res < 0) 4738 if (res < 0)
4739 bond_destructor(bond_dev); 4739 free_netdev(bond_dev);
4740 return res; 4740 return res;
4741} 4741}
4742 4742
diff --git a/drivers/net/caif/caif_hsi.c b/drivers/net/caif/caif_hsi.c
index ddabce759456..71a7c3b44fdd 100644
--- a/drivers/net/caif/caif_hsi.c
+++ b/drivers/net/caif/caif_hsi.c
@@ -1121,7 +1121,7 @@ static void cfhsi_setup(struct net_device *dev)
1121 dev->flags = IFF_POINTOPOINT | IFF_NOARP; 1121 dev->flags = IFF_POINTOPOINT | IFF_NOARP;
1122 dev->mtu = CFHSI_MAX_CAIF_FRAME_SZ; 1122 dev->mtu = CFHSI_MAX_CAIF_FRAME_SZ;
1123 dev->priv_flags |= IFF_NO_QUEUE; 1123 dev->priv_flags |= IFF_NO_QUEUE;
1124 dev->destructor = free_netdev; 1124 dev->needs_free_netdev = true;
1125 dev->netdev_ops = &cfhsi_netdevops; 1125 dev->netdev_ops = &cfhsi_netdevops;
1126 for (i = 0; i < CFHSI_PRIO_LAST; ++i) 1126 for (i = 0; i < CFHSI_PRIO_LAST; ++i)
1127 skb_queue_head_init(&cfhsi->qhead[i]); 1127 skb_queue_head_init(&cfhsi->qhead[i]);
diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
index c2dea4916e5d..76e1d3545105 100644
--- a/drivers/net/caif/caif_serial.c
+++ b/drivers/net/caif/caif_serial.c
@@ -428,7 +428,7 @@ static void caifdev_setup(struct net_device *dev)
428 dev->flags = IFF_POINTOPOINT | IFF_NOARP; 428 dev->flags = IFF_POINTOPOINT | IFF_NOARP;
429 dev->mtu = CAIF_MAX_MTU; 429 dev->mtu = CAIF_MAX_MTU;
430 dev->priv_flags |= IFF_NO_QUEUE; 430 dev->priv_flags |= IFF_NO_QUEUE;
431 dev->destructor = free_netdev; 431 dev->needs_free_netdev = true;
432 skb_queue_head_init(&serdev->head); 432 skb_queue_head_init(&serdev->head);
433 serdev->common.link_select = CAIF_LINK_LOW_LATENCY; 433 serdev->common.link_select = CAIF_LINK_LOW_LATENCY;
434 serdev->common.use_frag = true; 434 serdev->common.use_frag = true;
diff --git a/drivers/net/caif/caif_spi.c b/drivers/net/caif/caif_spi.c
index 3a529fbe539f..fc21afe852b9 100644
--- a/drivers/net/caif/caif_spi.c
+++ b/drivers/net/caif/caif_spi.c
@@ -712,7 +712,7 @@ static void cfspi_setup(struct net_device *dev)
712 dev->flags = IFF_NOARP | IFF_POINTOPOINT; 712 dev->flags = IFF_NOARP | IFF_POINTOPOINT;
713 dev->priv_flags |= IFF_NO_QUEUE; 713 dev->priv_flags |= IFF_NO_QUEUE;
714 dev->mtu = SPI_MAX_PAYLOAD_SIZE; 714 dev->mtu = SPI_MAX_PAYLOAD_SIZE;
715 dev->destructor = free_netdev; 715 dev->needs_free_netdev = true;
716 skb_queue_head_init(&cfspi->qhead); 716 skb_queue_head_init(&cfspi->qhead);
717 skb_queue_head_init(&cfspi->chead); 717 skb_queue_head_init(&cfspi->chead);
718 cfspi->cfdev.link_select = CAIF_LINK_HIGH_BANDW; 718 cfspi->cfdev.link_select = CAIF_LINK_HIGH_BANDW;
diff --git a/drivers/net/caif/caif_virtio.c b/drivers/net/caif/caif_virtio.c
index 6122768c8644..1794ea0420b7 100644
--- a/drivers/net/caif/caif_virtio.c
+++ b/drivers/net/caif/caif_virtio.c
@@ -617,7 +617,7 @@ static void cfv_netdev_setup(struct net_device *netdev)
617 netdev->tx_queue_len = 100; 617 netdev->tx_queue_len = 100;
618 netdev->flags = IFF_POINTOPOINT | IFF_NOARP; 618 netdev->flags = IFF_POINTOPOINT | IFF_NOARP;
619 netdev->mtu = CFV_DEF_MTU_SIZE; 619 netdev->mtu = CFV_DEF_MTU_SIZE;
620 netdev->destructor = free_netdev; 620 netdev->needs_free_netdev = true;
621} 621}
622 622
623/* Create debugfs counters for the device */ 623/* Create debugfs counters for the device */
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 611d16a7061d..ae4ed03dc642 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -391,6 +391,9 @@ void can_change_state(struct net_device *dev, struct can_frame *cf,
391 can_update_state_error_stats(dev, new_state); 391 can_update_state_error_stats(dev, new_state);
392 priv->state = new_state; 392 priv->state = new_state;
393 393
394 if (!cf)
395 return;
396
394 if (unlikely(new_state == CAN_STATE_BUS_OFF)) { 397 if (unlikely(new_state == CAN_STATE_BUS_OFF)) {
395 cf->can_id |= CAN_ERR_BUSOFF; 398 cf->can_id |= CAN_ERR_BUSOFF;
396 return; 399 return;
diff --git a/drivers/net/can/peak_canfd/peak_canfd.c b/drivers/net/can/peak_canfd/peak_canfd.c
index 0d57be5ea97b..85268be0c913 100644
--- a/drivers/net/can/peak_canfd/peak_canfd.c
+++ b/drivers/net/can/peak_canfd/peak_canfd.c
@@ -489,7 +489,7 @@ int peak_canfd_handle_msgs_list(struct peak_canfd_priv *priv,
489 struct pucan_rx_msg *msg_list, int msg_count) 489 struct pucan_rx_msg *msg_list, int msg_count)
490{ 490{
491 void *msg_ptr = msg_list; 491 void *msg_ptr = msg_list;
492 int i, msg_size; 492 int i, msg_size = 0;
493 493
494 for (i = 0; i < msg_count; i++) { 494 for (i = 0; i < msg_count; i++) {
495 msg_size = peak_canfd_handle_msg(priv, msg_ptr); 495 msg_size = peak_canfd_handle_msg(priv, msg_ptr);
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index eb7173713bbc..6a6e896e52fa 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -417,7 +417,7 @@ static int slc_open(struct net_device *dev)
417static void slc_free_netdev(struct net_device *dev) 417static void slc_free_netdev(struct net_device *dev)
418{ 418{
419 int i = dev->base_addr; 419 int i = dev->base_addr;
420 free_netdev(dev); 420
421 slcan_devs[i] = NULL; 421 slcan_devs[i] = NULL;
422} 422}
423 423
@@ -436,7 +436,8 @@ static const struct net_device_ops slc_netdev_ops = {
436static void slc_setup(struct net_device *dev) 436static void slc_setup(struct net_device *dev)
437{ 437{
438 dev->netdev_ops = &slc_netdev_ops; 438 dev->netdev_ops = &slc_netdev_ops;
439 dev->destructor = slc_free_netdev; 439 dev->needs_free_netdev = true;
440 dev->priv_destructor = slc_free_netdev;
440 441
441 dev->hard_header_len = 0; 442 dev->hard_header_len = 0;
442 dev->addr_len = 0; 443 dev->addr_len = 0;
@@ -761,8 +762,6 @@ static void __exit slcan_exit(void)
761 if (sl->tty) { 762 if (sl->tty) {
762 printk(KERN_ERR "%s: tty discipline still running\n", 763 printk(KERN_ERR "%s: tty discipline still running\n",
763 dev->name); 764 dev->name);
764 /* Intentionally leak the control block. */
765 dev->destructor = NULL;
766 } 765 }
767 766
768 unregister_netdev(dev); 767 unregister_netdev(dev);
diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index eecee7f8dfb7..afcc1312dbaf 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -265,6 +265,8 @@ static int gs_cmd_reset(struct gs_usb *gsusb, struct gs_can *gsdev)
265 sizeof(*dm), 265 sizeof(*dm),
266 1000); 266 1000);
267 267
268 kfree(dm);
269
268 return rc; 270 return rc;
269} 271}
270 272
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
index 57913dbbae0a..1ca76e03e965 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -908,8 +908,6 @@ static int peak_usb_probe(struct usb_interface *intf,
908 const struct peak_usb_adapter *peak_usb_adapter = NULL; 908 const struct peak_usb_adapter *peak_usb_adapter = NULL;
909 int i, err = -ENOMEM; 909 int i, err = -ENOMEM;
910 910
911 usb_dev = interface_to_usbdev(intf);
912
913 /* get corresponding PCAN-USB adapter */ 911 /* get corresponding PCAN-USB adapter */
914 for (i = 0; i < ARRAY_SIZE(peak_usb_adapters_list); i++) 912 for (i = 0; i < ARRAY_SIZE(peak_usb_adapters_list); i++)
915 if (peak_usb_adapters_list[i]->device_id == usb_id_product) { 913 if (peak_usb_adapters_list[i]->device_id == usb_id_product) {
@@ -920,7 +918,7 @@ static int peak_usb_probe(struct usb_interface *intf,
920 if (!peak_usb_adapter) { 918 if (!peak_usb_adapter) {
921 /* should never come except device_id bad usage in this file */ 919 /* should never come except device_id bad usage in this file */
922 pr_err("%s: didn't find device id. 0x%x in devices list\n", 920 pr_err("%s: didn't find device id. 0x%x in devices list\n",
923 PCAN_USB_DRIVER_NAME, usb_dev->descriptor.idProduct); 921 PCAN_USB_DRIVER_NAME, usb_id_product);
924 return -ENODEV; 922 return -ENODEV;
925 } 923 }
926 924
diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
index facca33d53e9..a8cb33264ff1 100644
--- a/drivers/net/can/vcan.c
+++ b/drivers/net/can/vcan.c
@@ -152,7 +152,7 @@ static const struct net_device_ops vcan_netdev_ops = {
152static void vcan_setup(struct net_device *dev) 152static void vcan_setup(struct net_device *dev)
153{ 153{
154 dev->type = ARPHRD_CAN; 154 dev->type = ARPHRD_CAN;
155 dev->mtu = CAN_MTU; 155 dev->mtu = CANFD_MTU;
156 dev->hard_header_len = 0; 156 dev->hard_header_len = 0;
157 dev->addr_len = 0; 157 dev->addr_len = 0;
158 dev->tx_queue_len = 0; 158 dev->tx_queue_len = 0;
@@ -163,7 +163,7 @@ static void vcan_setup(struct net_device *dev)
163 dev->flags |= IFF_ECHO; 163 dev->flags |= IFF_ECHO;
164 164
165 dev->netdev_ops = &vcan_netdev_ops; 165 dev->netdev_ops = &vcan_netdev_ops;
166 dev->destructor = free_netdev; 166 dev->needs_free_netdev = true;
167} 167}
168 168
169static struct rtnl_link_ops vcan_link_ops __read_mostly = { 169static struct rtnl_link_ops vcan_link_ops __read_mostly = {
diff --git a/drivers/net/can/vxcan.c b/drivers/net/can/vxcan.c
index 7fbb24795681..cfe889e8f172 100644
--- a/drivers/net/can/vxcan.c
+++ b/drivers/net/can/vxcan.c
@@ -150,13 +150,13 @@ static const struct net_device_ops vxcan_netdev_ops = {
150static void vxcan_setup(struct net_device *dev) 150static void vxcan_setup(struct net_device *dev)
151{ 151{
152 dev->type = ARPHRD_CAN; 152 dev->type = ARPHRD_CAN;
153 dev->mtu = CAN_MTU; 153 dev->mtu = CANFD_MTU;
154 dev->hard_header_len = 0; 154 dev->hard_header_len = 0;
155 dev->addr_len = 0; 155 dev->addr_len = 0;
156 dev->tx_queue_len = 0; 156 dev->tx_queue_len = 0;
157 dev->flags = (IFF_NOARP|IFF_ECHO); 157 dev->flags = (IFF_NOARP|IFF_ECHO);
158 dev->netdev_ops = &vxcan_netdev_ops; 158 dev->netdev_ops = &vxcan_netdev_ops;
159 dev->destructor = free_netdev; 159 dev->needs_free_netdev = true;
160} 160}
161 161
162/* forward declaration for rtnl_create_link() */ 162/* forward declaration for rtnl_create_link() */
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index 149244aac20a..9905b52fe293 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -328,7 +328,6 @@ static void dummy_free_netdev(struct net_device *dev)
328 struct dummy_priv *priv = netdev_priv(dev); 328 struct dummy_priv *priv = netdev_priv(dev);
329 329
330 kfree(priv->vfinfo); 330 kfree(priv->vfinfo);
331 free_netdev(dev);
332} 331}
333 332
334static void dummy_setup(struct net_device *dev) 333static void dummy_setup(struct net_device *dev)
@@ -338,7 +337,8 @@ static void dummy_setup(struct net_device *dev)
338 /* Initialize the device structure. */ 337 /* Initialize the device structure. */
339 dev->netdev_ops = &dummy_netdev_ops; 338 dev->netdev_ops = &dummy_netdev_ops;
340 dev->ethtool_ops = &dummy_ethtool_ops; 339 dev->ethtool_ops = &dummy_ethtool_ops;
341 dev->destructor = dummy_free_netdev; 340 dev->needs_free_netdev = true;
341 dev->priv_destructor = dummy_free_netdev;
342 342
343 /* Fill in device structure with ethernet-generic values. */ 343 /* Fill in device structure with ethernet-generic values. */
344 dev->flags |= IFF_NOARP; 344 dev->flags |= IFF_NOARP;
diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c
index 08d11cede9c9..f5b237e0bd60 100644
--- a/drivers/net/ethernet/amazon/ena/ena_com.c
+++ b/drivers/net/ethernet/amazon/ena/ena_com.c
@@ -61,6 +61,8 @@
61 61
62#define ENA_MMIO_READ_TIMEOUT 0xFFFFFFFF 62#define ENA_MMIO_READ_TIMEOUT 0xFFFFFFFF
63 63
64#define ENA_REGS_ADMIN_INTR_MASK 1
65
64/*****************************************************************************/ 66/*****************************************************************************/
65/*****************************************************************************/ 67/*****************************************************************************/
66/*****************************************************************************/ 68/*****************************************************************************/
@@ -232,11 +234,9 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
232 tail_masked = admin_queue->sq.tail & queue_size_mask; 234 tail_masked = admin_queue->sq.tail & queue_size_mask;
233 235
234 /* In case of queue FULL */ 236 /* In case of queue FULL */
235 cnt = admin_queue->sq.tail - admin_queue->sq.head; 237 cnt = atomic_read(&admin_queue->outstanding_cmds);
236 if (cnt >= admin_queue->q_depth) { 238 if (cnt >= admin_queue->q_depth) {
237 pr_debug("admin queue is FULL (tail %d head %d depth: %d)\n", 239 pr_debug("admin queue is full.\n");
238 admin_queue->sq.tail, admin_queue->sq.head,
239 admin_queue->q_depth);
240 admin_queue->stats.out_of_space++; 240 admin_queue->stats.out_of_space++;
241 return ERR_PTR(-ENOSPC); 241 return ERR_PTR(-ENOSPC);
242 } 242 }
@@ -508,15 +508,20 @@ static int ena_com_comp_status_to_errno(u8 comp_status)
508static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_ctx, 508static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_ctx,
509 struct ena_com_admin_queue *admin_queue) 509 struct ena_com_admin_queue *admin_queue)
510{ 510{
511 unsigned long flags; 511 unsigned long flags, timeout;
512 u32 start_time;
513 int ret; 512 int ret;
514 513
515 start_time = ((u32)jiffies_to_usecs(jiffies)); 514 timeout = jiffies + ADMIN_CMD_TIMEOUT_US;
515
516 while (1) {
517 spin_lock_irqsave(&admin_queue->q_lock, flags);
518 ena_com_handle_admin_completion(admin_queue);
519 spin_unlock_irqrestore(&admin_queue->q_lock, flags);
520
521 if (comp_ctx->status != ENA_CMD_SUBMITTED)
522 break;
516 523
517 while (comp_ctx->status == ENA_CMD_SUBMITTED) { 524 if (time_is_before_jiffies(timeout)) {
518 if ((((u32)jiffies_to_usecs(jiffies)) - start_time) >
519 ADMIN_CMD_TIMEOUT_US) {
520 pr_err("Wait for completion (polling) timeout\n"); 525 pr_err("Wait for completion (polling) timeout\n");
521 /* ENA didn't have any completion */ 526 /* ENA didn't have any completion */
522 spin_lock_irqsave(&admin_queue->q_lock, flags); 527 spin_lock_irqsave(&admin_queue->q_lock, flags);
@@ -528,10 +533,6 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
528 goto err; 533 goto err;
529 } 534 }
530 535
531 spin_lock_irqsave(&admin_queue->q_lock, flags);
532 ena_com_handle_admin_completion(admin_queue);
533 spin_unlock_irqrestore(&admin_queue->q_lock, flags);
534
535 msleep(100); 536 msleep(100);
536 } 537 }
537 538
@@ -1455,6 +1456,12 @@ void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
1455 1456
1456void ena_com_set_admin_polling_mode(struct ena_com_dev *ena_dev, bool polling) 1457void ena_com_set_admin_polling_mode(struct ena_com_dev *ena_dev, bool polling)
1457{ 1458{
1459 u32 mask_value = 0;
1460
1461 if (polling)
1462 mask_value = ENA_REGS_ADMIN_INTR_MASK;
1463
1464 writel(mask_value, ena_dev->reg_bar + ENA_REGS_INTR_MASK_OFF);
1458 ena_dev->admin_queue.polling = polling; 1465 ena_dev->admin_queue.polling = polling;
1459} 1466}
1460 1467
diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
index 67b2338f8fb3..3ee55e2fd694 100644
--- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c
+++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
@@ -80,7 +80,6 @@ static const struct ena_stats ena_stats_tx_strings[] = {
80 ENA_STAT_TX_ENTRY(tx_poll), 80 ENA_STAT_TX_ENTRY(tx_poll),
81 ENA_STAT_TX_ENTRY(doorbells), 81 ENA_STAT_TX_ENTRY(doorbells),
82 ENA_STAT_TX_ENTRY(prepare_ctx_err), 82 ENA_STAT_TX_ENTRY(prepare_ctx_err),
83 ENA_STAT_TX_ENTRY(missing_tx_comp),
84 ENA_STAT_TX_ENTRY(bad_req_id), 83 ENA_STAT_TX_ENTRY(bad_req_id),
85}; 84};
86 85
@@ -94,6 +93,7 @@ static const struct ena_stats ena_stats_rx_strings[] = {
94 ENA_STAT_RX_ENTRY(dma_mapping_err), 93 ENA_STAT_RX_ENTRY(dma_mapping_err),
95 ENA_STAT_RX_ENTRY(bad_desc_num), 94 ENA_STAT_RX_ENTRY(bad_desc_num),
96 ENA_STAT_RX_ENTRY(rx_copybreak_pkt), 95 ENA_STAT_RX_ENTRY(rx_copybreak_pkt),
96 ENA_STAT_RX_ENTRY(empty_rx_ring),
97}; 97};
98 98
99static const struct ena_stats ena_stats_ena_com_strings[] = { 99static const struct ena_stats ena_stats_ena_com_strings[] = {
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 7c1214d78855..4f16ed38bcf3 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -190,6 +190,7 @@ static void ena_init_io_rings(struct ena_adapter *adapter)
190 rxr->sgl_size = adapter->max_rx_sgl_size; 190 rxr->sgl_size = adapter->max_rx_sgl_size;
191 rxr->smoothed_interval = 191 rxr->smoothed_interval =
192 ena_com_get_nonadaptive_moderation_interval_rx(ena_dev); 192 ena_com_get_nonadaptive_moderation_interval_rx(ena_dev);
193 rxr->empty_rx_queue = 0;
193 } 194 }
194} 195}
195 196
@@ -1078,6 +1079,26 @@ inline void ena_adjust_intr_moderation(struct ena_ring *rx_ring,
1078 rx_ring->per_napi_bytes = 0; 1079 rx_ring->per_napi_bytes = 0;
1079} 1080}
1080 1081
1082static inline void ena_unmask_interrupt(struct ena_ring *tx_ring,
1083 struct ena_ring *rx_ring)
1084{
1085 struct ena_eth_io_intr_reg intr_reg;
1086
1087 /* Update intr register: rx intr delay,
1088 * tx intr delay and interrupt unmask
1089 */
1090 ena_com_update_intr_reg(&intr_reg,
1091 rx_ring->smoothed_interval,
1092 tx_ring->smoothed_interval,
1093 true);
1094
1095 /* It is a shared MSI-X.
1096 * Tx and Rx CQ have pointer to it.
1097 * So we use one of them to reach the intr reg
1098 */
1099 ena_com_unmask_intr(rx_ring->ena_com_io_cq, &intr_reg);
1100}
1101
1081static inline void ena_update_ring_numa_node(struct ena_ring *tx_ring, 1102static inline void ena_update_ring_numa_node(struct ena_ring *tx_ring,
1082 struct ena_ring *rx_ring) 1103 struct ena_ring *rx_ring)
1083{ 1104{
@@ -1108,7 +1129,6 @@ static int ena_io_poll(struct napi_struct *napi, int budget)
1108{ 1129{
1109 struct ena_napi *ena_napi = container_of(napi, struct ena_napi, napi); 1130 struct ena_napi *ena_napi = container_of(napi, struct ena_napi, napi);
1110 struct ena_ring *tx_ring, *rx_ring; 1131 struct ena_ring *tx_ring, *rx_ring;
1111 struct ena_eth_io_intr_reg intr_reg;
1112 1132
1113 u32 tx_work_done; 1133 u32 tx_work_done;
1114 u32 rx_work_done; 1134 u32 rx_work_done;
@@ -1149,22 +1169,9 @@ static int ena_io_poll(struct napi_struct *napi, int budget)
1149 if (ena_com_get_adaptive_moderation_enabled(rx_ring->ena_dev)) 1169 if (ena_com_get_adaptive_moderation_enabled(rx_ring->ena_dev))
1150 ena_adjust_intr_moderation(rx_ring, tx_ring); 1170 ena_adjust_intr_moderation(rx_ring, tx_ring);
1151 1171
1152 /* Update intr register: rx intr delay, 1172 ena_unmask_interrupt(tx_ring, rx_ring);
1153 * tx intr delay and interrupt unmask
1154 */
1155 ena_com_update_intr_reg(&intr_reg,
1156 rx_ring->smoothed_interval,
1157 tx_ring->smoothed_interval,
1158 true);
1159
1160 /* It is a shared MSI-X.
1161 * Tx and Rx CQ have pointer to it.
1162 * So we use one of them to reach the intr reg
1163 */
1164 ena_com_unmask_intr(rx_ring->ena_com_io_cq, &intr_reg);
1165 } 1173 }
1166 1174
1167
1168 ena_update_ring_numa_node(tx_ring, rx_ring); 1175 ena_update_ring_numa_node(tx_ring, rx_ring);
1169 1176
1170 ret = rx_work_done; 1177 ret = rx_work_done;
@@ -1485,6 +1492,11 @@ static int ena_up_complete(struct ena_adapter *adapter)
1485 1492
1486 ena_napi_enable_all(adapter); 1493 ena_napi_enable_all(adapter);
1487 1494
1495 /* Enable completion queues interrupt */
1496 for (i = 0; i < adapter->num_queues; i++)
1497 ena_unmask_interrupt(&adapter->tx_ring[i],
1498 &adapter->rx_ring[i]);
1499
1488 /* schedule napi in case we had pending packets 1500 /* schedule napi in case we had pending packets
1489 * from the last time we disable napi 1501 * from the last time we disable napi
1490 */ 1502 */
@@ -1532,6 +1544,7 @@ static int ena_create_io_tx_queue(struct ena_adapter *adapter, int qid)
1532 "Failed to get TX queue handlers. TX queue num %d rc: %d\n", 1544 "Failed to get TX queue handlers. TX queue num %d rc: %d\n",
1533 qid, rc); 1545 qid, rc);
1534 ena_com_destroy_io_queue(ena_dev, ena_qid); 1546 ena_com_destroy_io_queue(ena_dev, ena_qid);
1547 return rc;
1535 } 1548 }
1536 1549
1537 ena_com_update_numa_node(tx_ring->ena_com_io_cq, ctx.numa_node); 1550 ena_com_update_numa_node(tx_ring->ena_com_io_cq, ctx.numa_node);
@@ -1596,6 +1609,7 @@ static int ena_create_io_rx_queue(struct ena_adapter *adapter, int qid)
1596 "Failed to get RX queue handlers. RX queue num %d rc: %d\n", 1609 "Failed to get RX queue handlers. RX queue num %d rc: %d\n",
1597 qid, rc); 1610 qid, rc);
1598 ena_com_destroy_io_queue(ena_dev, ena_qid); 1611 ena_com_destroy_io_queue(ena_dev, ena_qid);
1612 return rc;
1599 } 1613 }
1600 1614
1601 ena_com_update_numa_node(rx_ring->ena_com_io_cq, ctx.numa_node); 1615 ena_com_update_numa_node(rx_ring->ena_com_io_cq, ctx.numa_node);
@@ -1981,6 +1995,7 @@ static netdev_tx_t ena_start_xmit(struct sk_buff *skb, struct net_device *dev)
1981 1995
1982 tx_info->tx_descs = nb_hw_desc; 1996 tx_info->tx_descs = nb_hw_desc;
1983 tx_info->last_jiffies = jiffies; 1997 tx_info->last_jiffies = jiffies;
1998 tx_info->print_once = 0;
1984 1999
1985 tx_ring->next_to_use = ENA_TX_RING_IDX_NEXT(next_to_use, 2000 tx_ring->next_to_use = ENA_TX_RING_IDX_NEXT(next_to_use,
1986 tx_ring->ring_size); 2001 tx_ring->ring_size);
@@ -2550,13 +2565,44 @@ err:
2550 "Reset attempt failed. Can not reset the device\n"); 2565 "Reset attempt failed. Can not reset the device\n");
2551} 2566}
2552 2567
2553static void check_for_missing_tx_completions(struct ena_adapter *adapter) 2568static int check_missing_comp_in_queue(struct ena_adapter *adapter,
2569 struct ena_ring *tx_ring)
2554{ 2570{
2555 struct ena_tx_buffer *tx_buf; 2571 struct ena_tx_buffer *tx_buf;
2556 unsigned long last_jiffies; 2572 unsigned long last_jiffies;
2573 u32 missed_tx = 0;
2574 int i;
2575
2576 for (i = 0; i < tx_ring->ring_size; i++) {
2577 tx_buf = &tx_ring->tx_buffer_info[i];
2578 last_jiffies = tx_buf->last_jiffies;
2579 if (unlikely(last_jiffies &&
2580 time_is_before_jiffies(last_jiffies + TX_TIMEOUT))) {
2581 if (!tx_buf->print_once)
2582 netif_notice(adapter, tx_err, adapter->netdev,
2583 "Found a Tx that wasn't completed on time, qid %d, index %d.\n",
2584 tx_ring->qid, i);
2585
2586 tx_buf->print_once = 1;
2587 missed_tx++;
2588
2589 if (unlikely(missed_tx > MAX_NUM_OF_TIMEOUTED_PACKETS)) {
2590 netif_err(adapter, tx_err, adapter->netdev,
2591 "The number of lost tx completions is above the threshold (%d > %d). Reset the device\n",
2592 missed_tx, MAX_NUM_OF_TIMEOUTED_PACKETS);
2593 set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
2594 return -EIO;
2595 }
2596 }
2597 }
2598
2599 return 0;
2600}
2601
2602static void check_for_missing_tx_completions(struct ena_adapter *adapter)
2603{
2557 struct ena_ring *tx_ring; 2604 struct ena_ring *tx_ring;
2558 int i, j, budget; 2605 int i, budget, rc;
2559 u32 missed_tx;
2560 2606
2561 /* Make sure the driver doesn't turn the device in other process */ 2607 /* Make sure the driver doesn't turn the device in other process */
2562 smp_rmb(); 2608 smp_rmb();
@@ -2572,31 +2618,9 @@ static void check_for_missing_tx_completions(struct ena_adapter *adapter)
2572 for (i = adapter->last_monitored_tx_qid; i < adapter->num_queues; i++) { 2618 for (i = adapter->last_monitored_tx_qid; i < adapter->num_queues; i++) {
2573 tx_ring = &adapter->tx_ring[i]; 2619 tx_ring = &adapter->tx_ring[i];
2574 2620
2575 for (j = 0; j < tx_ring->ring_size; j++) { 2621 rc = check_missing_comp_in_queue(adapter, tx_ring);
2576 tx_buf = &tx_ring->tx_buffer_info[j]; 2622 if (unlikely(rc))
2577 last_jiffies = tx_buf->last_jiffies; 2623 return;
2578 if (unlikely(last_jiffies && time_is_before_jiffies(last_jiffies + TX_TIMEOUT))) {
2579 netif_notice(adapter, tx_err, adapter->netdev,
2580 "Found a Tx that wasn't completed on time, qid %d, index %d.\n",
2581 tx_ring->qid, j);
2582
2583 u64_stats_update_begin(&tx_ring->syncp);
2584 missed_tx = tx_ring->tx_stats.missing_tx_comp++;
2585 u64_stats_update_end(&tx_ring->syncp);
2586
2587 /* Clear last jiffies so the lost buffer won't
2588 * be counted twice.
2589 */
2590 tx_buf->last_jiffies = 0;
2591
2592 if (unlikely(missed_tx > MAX_NUM_OF_TIMEOUTED_PACKETS)) {
2593 netif_err(adapter, tx_err, adapter->netdev,
2594 "The number of lost tx completion is above the threshold (%d > %d). Reset the device\n",
2595 missed_tx, MAX_NUM_OF_TIMEOUTED_PACKETS);
2596 set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
2597 }
2598 }
2599 }
2600 2624
2601 budget--; 2625 budget--;
2602 if (!budget) 2626 if (!budget)
@@ -2606,6 +2630,58 @@ static void check_for_missing_tx_completions(struct ena_adapter *adapter)
2606 adapter->last_monitored_tx_qid = i % adapter->num_queues; 2630 adapter->last_monitored_tx_qid = i % adapter->num_queues;
2607} 2631}
2608 2632
2633/* trigger napi schedule after 2 consecutive detections */
2634#define EMPTY_RX_REFILL 2
2635/* For the rare case where the device runs out of Rx descriptors and the
2636 * napi handler failed to refill new Rx descriptors (due to a lack of memory
2637 * for example).
2638 * This case will lead to a deadlock:
2639 * The device won't send interrupts since all the new Rx packets will be dropped
2640 * The napi handler won't allocate new Rx descriptors so the device will be
2641 * able to send new packets.
2642 *
2643 * This scenario can happen when the kernel's vm.min_free_kbytes is too small.
2644 * It is recommended to have at least 512MB, with a minimum of 128MB for
2645 * constrained environment).
2646 *
2647 * When such a situation is detected - Reschedule napi
2648 */
2649static void check_for_empty_rx_ring(struct ena_adapter *adapter)
2650{
2651 struct ena_ring *rx_ring;
2652 int i, refill_required;
2653
2654 if (!test_bit(ENA_FLAG_DEV_UP, &adapter->flags))
2655 return;
2656
2657 if (test_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags))
2658 return;
2659
2660 for (i = 0; i < adapter->num_queues; i++) {
2661 rx_ring = &adapter->rx_ring[i];
2662
2663 refill_required =
2664 ena_com_sq_empty_space(rx_ring->ena_com_io_sq);
2665 if (unlikely(refill_required == (rx_ring->ring_size - 1))) {
2666 rx_ring->empty_rx_queue++;
2667
2668 if (rx_ring->empty_rx_queue >= EMPTY_RX_REFILL) {
2669 u64_stats_update_begin(&rx_ring->syncp);
2670 rx_ring->rx_stats.empty_rx_ring++;
2671 u64_stats_update_end(&rx_ring->syncp);
2672
2673 netif_err(adapter, drv, adapter->netdev,
2674 "trigger refill for ring %d\n", i);
2675
2676 napi_schedule(rx_ring->napi);
2677 rx_ring->empty_rx_queue = 0;
2678 }
2679 } else {
2680 rx_ring->empty_rx_queue = 0;
2681 }
2682 }
2683}
2684
2609/* Check for keep alive expiration */ 2685/* Check for keep alive expiration */
2610static void check_for_missing_keep_alive(struct ena_adapter *adapter) 2686static void check_for_missing_keep_alive(struct ena_adapter *adapter)
2611{ 2687{
@@ -2660,6 +2736,8 @@ static void ena_timer_service(unsigned long data)
2660 2736
2661 check_for_missing_tx_completions(adapter); 2737 check_for_missing_tx_completions(adapter);
2662 2738
2739 check_for_empty_rx_ring(adapter);
2740
2663 if (debug_area) 2741 if (debug_area)
2664 ena_dump_stats_to_buf(adapter, debug_area); 2742 ena_dump_stats_to_buf(adapter, debug_area);
2665 2743
@@ -2840,6 +2918,11 @@ static void ena_release_bars(struct ena_com_dev *ena_dev, struct pci_dev *pdev)
2840{ 2918{
2841 int release_bars; 2919 int release_bars;
2842 2920
2921 if (ena_dev->mem_bar)
2922 devm_iounmap(&pdev->dev, ena_dev->mem_bar);
2923
2924 devm_iounmap(&pdev->dev, ena_dev->reg_bar);
2925
2843 release_bars = pci_select_bars(pdev, IORESOURCE_MEM) & ENA_BAR_MASK; 2926 release_bars = pci_select_bars(pdev, IORESOURCE_MEM) & ENA_BAR_MASK;
2844 pci_release_selected_regions(pdev, release_bars); 2927 pci_release_selected_regions(pdev, release_bars);
2845} 2928}
@@ -2927,8 +3010,9 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2927 goto err_free_ena_dev; 3010 goto err_free_ena_dev;
2928 } 3011 }
2929 3012
2930 ena_dev->reg_bar = ioremap(pci_resource_start(pdev, ENA_REG_BAR), 3013 ena_dev->reg_bar = devm_ioremap(&pdev->dev,
2931 pci_resource_len(pdev, ENA_REG_BAR)); 3014 pci_resource_start(pdev, ENA_REG_BAR),
3015 pci_resource_len(pdev, ENA_REG_BAR));
2932 if (!ena_dev->reg_bar) { 3016 if (!ena_dev->reg_bar) {
2933 dev_err(&pdev->dev, "failed to remap regs bar\n"); 3017 dev_err(&pdev->dev, "failed to remap regs bar\n");
2934 rc = -EFAULT; 3018 rc = -EFAULT;
@@ -2948,8 +3032,9 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2948 ena_set_push_mode(pdev, ena_dev, &get_feat_ctx); 3032 ena_set_push_mode(pdev, ena_dev, &get_feat_ctx);
2949 3033
2950 if (ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_DEV) { 3034 if (ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_DEV) {
2951 ena_dev->mem_bar = ioremap_wc(pci_resource_start(pdev, ENA_MEM_BAR), 3035 ena_dev->mem_bar = devm_ioremap_wc(&pdev->dev,
2952 pci_resource_len(pdev, ENA_MEM_BAR)); 3036 pci_resource_start(pdev, ENA_MEM_BAR),
3037 pci_resource_len(pdev, ENA_MEM_BAR));
2953 if (!ena_dev->mem_bar) { 3038 if (!ena_dev->mem_bar) {
2954 rc = -EFAULT; 3039 rc = -EFAULT;
2955 goto err_device_destroy; 3040 goto err_device_destroy;
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h
index 0e22bce6239d..a4d3d5e21068 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.h
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h
@@ -45,7 +45,7 @@
45 45
46#define DRV_MODULE_VER_MAJOR 1 46#define DRV_MODULE_VER_MAJOR 1
47#define DRV_MODULE_VER_MINOR 1 47#define DRV_MODULE_VER_MINOR 1
48#define DRV_MODULE_VER_SUBMINOR 2 48#define DRV_MODULE_VER_SUBMINOR 7
49 49
50#define DRV_MODULE_NAME "ena" 50#define DRV_MODULE_NAME "ena"
51#ifndef DRV_MODULE_VERSION 51#ifndef DRV_MODULE_VERSION
@@ -146,7 +146,18 @@ struct ena_tx_buffer {
146 u32 tx_descs; 146 u32 tx_descs;
147 /* num of buffers used by this skb */ 147 /* num of buffers used by this skb */
148 u32 num_of_bufs; 148 u32 num_of_bufs;
149 /* Save the last jiffies to detect missing tx packets */ 149
150 /* Used for detect missing tx packets to limit the number of prints */
151 u32 print_once;
152 /* Save the last jiffies to detect missing tx packets
153 *
154 * sets to non zero value on ena_start_xmit and set to zero on
155 * napi and timer_Service_routine.
156 *
157 * while this value is not protected by lock,
158 * a given packet is not expected to be handled by ena_start_xmit
159 * and by napi/timer_service at the same time.
160 */
150 unsigned long last_jiffies; 161 unsigned long last_jiffies;
151 struct ena_com_buf bufs[ENA_PKT_MAX_BUFS]; 162 struct ena_com_buf bufs[ENA_PKT_MAX_BUFS];
152} ____cacheline_aligned; 163} ____cacheline_aligned;
@@ -170,7 +181,6 @@ struct ena_stats_tx {
170 u64 napi_comp; 181 u64 napi_comp;
171 u64 tx_poll; 182 u64 tx_poll;
172 u64 doorbells; 183 u64 doorbells;
173 u64 missing_tx_comp;
174 u64 bad_req_id; 184 u64 bad_req_id;
175}; 185};
176 186
@@ -184,6 +194,7 @@ struct ena_stats_rx {
184 u64 dma_mapping_err; 194 u64 dma_mapping_err;
185 u64 bad_desc_num; 195 u64 bad_desc_num;
186 u64 rx_copybreak_pkt; 196 u64 rx_copybreak_pkt;
197 u64 empty_rx_ring;
187}; 198};
188 199
189struct ena_ring { 200struct ena_ring {
@@ -231,6 +242,7 @@ struct ena_ring {
231 struct ena_stats_tx tx_stats; 242 struct ena_stats_tx tx_stats;
232 struct ena_stats_rx rx_stats; 243 struct ena_stats_rx rx_stats;
233 }; 244 };
245 int empty_rx_queue;
234} ____cacheline_aligned; 246} ____cacheline_aligned;
235 247
236struct ena_stats_dev { 248struct ena_stats_dev {
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
index b8e3d88f0879..a66aee51ab5b 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
@@ -193,9 +193,6 @@ int hw_atl_utils_hw_get_regs(struct aq_hw_s *self,
193 struct aq_hw_caps_s *aq_hw_caps, 193 struct aq_hw_caps_s *aq_hw_caps,
194 u32 *regs_buff); 194 u32 *regs_buff);
195 195
196int hw_atl_utils_hw_get_settings(struct aq_hw_s *self,
197 struct ethtool_cmd *cmd);
198
199int hw_atl_utils_hw_set_power(struct aq_hw_s *self, 196int hw_atl_utils_hw_set_power(struct aq_hw_s *self,
200 unsigned int power_state); 197 unsigned int power_state);
201 198
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 5f49334dcad5..f619c4cac51f 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -3883,15 +3883,26 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
3883 /* when transmitting in a vf, start bd must hold the ethertype 3883 /* when transmitting in a vf, start bd must hold the ethertype
3884 * for fw to enforce it 3884 * for fw to enforce it
3885 */ 3885 */
3886 u16 vlan_tci = 0;
3886#ifndef BNX2X_STOP_ON_ERROR 3887#ifndef BNX2X_STOP_ON_ERROR
3887 if (IS_VF(bp)) 3888 if (IS_VF(bp)) {
3888#endif 3889#endif
3889 tx_start_bd->vlan_or_ethertype = 3890 /* Still need to consider inband vlan for enforced */
3890 cpu_to_le16(ntohs(eth->h_proto)); 3891 if (__vlan_get_tag(skb, &vlan_tci)) {
3892 tx_start_bd->vlan_or_ethertype =
3893 cpu_to_le16(ntohs(eth->h_proto));
3894 } else {
3895 tx_start_bd->bd_flags.as_bitfield |=
3896 (X_ETH_INBAND_VLAN <<
3897 ETH_TX_BD_FLAGS_VLAN_MODE_SHIFT);
3898 tx_start_bd->vlan_or_ethertype =
3899 cpu_to_le16(vlan_tci);
3900 }
3891#ifndef BNX2X_STOP_ON_ERROR 3901#ifndef BNX2X_STOP_ON_ERROR
3892 else 3902 } else {
3893 /* used by FW for packet accounting */ 3903 /* used by FW for packet accounting */
3894 tx_start_bd->vlan_or_ethertype = cpu_to_le16(pkt_prod); 3904 tx_start_bd->vlan_or_ethertype = cpu_to_le16(pkt_prod);
3905 }
3895#endif 3906#endif
3896 } 3907 }
3897 3908
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
index bdfd53b46bc5..9ca994d0bab6 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
@@ -901,6 +901,8 @@ static void bnx2x_vf_flr(struct bnx2x *bp, struct bnx2x_virtf *vf)
901 /* release VF resources */ 901 /* release VF resources */
902 bnx2x_vf_free_resc(bp, vf); 902 bnx2x_vf_free_resc(bp, vf);
903 903
904 vf->malicious = false;
905
904 /* re-open the mailbox */ 906 /* re-open the mailbox */
905 bnx2x_vf_enable_mbx(bp, vf->abs_vfid); 907 bnx2x_vf_enable_mbx(bp, vf->abs_vfid);
906 return; 908 return;
@@ -1822,9 +1824,11 @@ get_vf:
1822 vf->abs_vfid, qidx); 1824 vf->abs_vfid, qidx);
1823 bnx2x_vf_handle_rss_update_eqe(bp, vf); 1825 bnx2x_vf_handle_rss_update_eqe(bp, vf);
1824 case EVENT_RING_OPCODE_VF_FLR: 1826 case EVENT_RING_OPCODE_VF_FLR:
1825 case EVENT_RING_OPCODE_MALICIOUS_VF:
1826 /* Do nothing for now */ 1827 /* Do nothing for now */
1827 return 0; 1828 return 0;
1829 case EVENT_RING_OPCODE_MALICIOUS_VF:
1830 vf->malicious = true;
1831 return 0;
1828 } 1832 }
1829 1833
1830 return 0; 1834 return 0;
@@ -1905,6 +1909,13 @@ void bnx2x_iov_adjust_stats_req(struct bnx2x *bp)
1905 continue; 1909 continue;
1906 } 1910 }
1907 1911
1912 if (vf->malicious) {
1913 DP_AND((BNX2X_MSG_IOV | BNX2X_MSG_STATS),
1914 "vf %d malicious so no stats for it\n",
1915 vf->abs_vfid);
1916 continue;
1917 }
1918
1908 DP_AND((BNX2X_MSG_IOV | BNX2X_MSG_STATS), 1919 DP_AND((BNX2X_MSG_IOV | BNX2X_MSG_STATS),
1909 "add addresses for vf %d\n", vf->abs_vfid); 1920 "add addresses for vf %d\n", vf->abs_vfid);
1910 for_each_vfq(vf, j) { 1921 for_each_vfq(vf, j) {
@@ -3042,7 +3053,7 @@ void bnx2x_vf_pci_dealloc(struct bnx2x *bp)
3042{ 3053{
3043 BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->vf2pf_mbox_mapping, 3054 BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->vf2pf_mbox_mapping,
3044 sizeof(struct bnx2x_vf_mbx_msg)); 3055 sizeof(struct bnx2x_vf_mbx_msg));
3045 BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->pf2vf_bulletin_mapping, 3056 BNX2X_PCI_FREE(bp->pf2vf_bulletin, bp->pf2vf_bulletin_mapping,
3046 sizeof(union pf_vf_bulletin)); 3057 sizeof(union pf_vf_bulletin));
3047} 3058}
3048 3059
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
index 888d0b6632e8..53466f6cebab 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
@@ -141,6 +141,7 @@ struct bnx2x_virtf {
141#define VF_RESET 3 /* VF FLR'd, pending cleanup */ 141#define VF_RESET 3 /* VF FLR'd, pending cleanup */
142 142
143 bool flr_clnup_stage; /* true during flr cleanup */ 143 bool flr_clnup_stage; /* true during flr cleanup */
144 bool malicious; /* true if FW indicated so, until FLR */
144 145
145 /* dma */ 146 /* dma */
146 dma_addr_t fw_stat_map; 147 dma_addr_t fw_stat_map;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 77ed2f628f9c..ea1bfcf1870a 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4525,7 +4525,7 @@ static void dummy_setup(struct net_device *dev)
4525 /* Initialize the device structure. */ 4525 /* Initialize the device structure. */
4526 dev->netdev_ops = &cxgb4_mgmt_netdev_ops; 4526 dev->netdev_ops = &cxgb4_mgmt_netdev_ops;
4527 dev->ethtool_ops = &cxgb4_mgmt_ethtool_ops; 4527 dev->ethtool_ops = &cxgb4_mgmt_ethtool_ops;
4528 dev->destructor = free_netdev; 4528 dev->needs_free_netdev = true;
4529} 4529}
4530 4530
4531static int config_mgmt_dev(struct pci_dev *pdev) 4531static int config_mgmt_dev(struct pci_dev *pdev)
diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index 508923f39ccf..259e69a52ec5 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -343,6 +343,7 @@ static int emac_reset(struct emac_instance *dev)
343{ 343{
344 struct emac_regs __iomem *p = dev->emacp; 344 struct emac_regs __iomem *p = dev->emacp;
345 int n = 20; 345 int n = 20;
346 bool __maybe_unused try_internal_clock = false;
346 347
347 DBG(dev, "reset" NL); 348 DBG(dev, "reset" NL);
348 349
@@ -355,6 +356,7 @@ static int emac_reset(struct emac_instance *dev)
355 } 356 }
356 357
357#ifdef CONFIG_PPC_DCR_NATIVE 358#ifdef CONFIG_PPC_DCR_NATIVE
359do_retry:
358 /* 360 /*
359 * PPC460EX/GT Embedded Processor Advanced User's Manual 361 * PPC460EX/GT Embedded Processor Advanced User's Manual
360 * section 28.10.1 Mode Register 0 (EMACx_MR0) states: 362 * section 28.10.1 Mode Register 0 (EMACx_MR0) states:
@@ -362,10 +364,19 @@ static int emac_reset(struct emac_instance *dev)
362 * of the EMAC. If none is present, select the internal clock 364 * of the EMAC. If none is present, select the internal clock
363 * (SDR0_ETH_CFG[EMACx_PHY_CLK] = 1). 365 * (SDR0_ETH_CFG[EMACx_PHY_CLK] = 1).
364 * After a soft reset, select the external clock. 366 * After a soft reset, select the external clock.
367 *
368 * The AR8035-A PHY Meraki MR24 does not provide a TX Clk if the
369 * ethernet cable is not attached. This causes the reset to timeout
370 * and the PHY detection code in emac_init_phy() is unable to
371 * communicate and detect the AR8035-A PHY. As a result, the emac
372 * driver bails out early and the user has no ethernet.
373 * In order to stay compatible with existing configurations, the
374 * driver will temporarily switch to the internal clock, after
375 * the first reset fails.
365 */ 376 */
366 if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX)) { 377 if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX)) {
367 if (dev->phy_address == 0xffffffff && 378 if (try_internal_clock || (dev->phy_address == 0xffffffff &&
368 dev->phy_map == 0xffffffff) { 379 dev->phy_map == 0xffffffff)) {
369 /* No PHY: select internal loop clock before reset */ 380 /* No PHY: select internal loop clock before reset */
370 dcri_clrset(SDR0, SDR0_ETH_CFG, 381 dcri_clrset(SDR0, SDR0_ETH_CFG,
371 0, SDR0_ETH_CFG_ECS << dev->cell_index); 382 0, SDR0_ETH_CFG_ECS << dev->cell_index);
@@ -383,8 +394,15 @@ static int emac_reset(struct emac_instance *dev)
383 394
384#ifdef CONFIG_PPC_DCR_NATIVE 395#ifdef CONFIG_PPC_DCR_NATIVE
385 if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX)) { 396 if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX)) {
386 if (dev->phy_address == 0xffffffff && 397 if (!n && !try_internal_clock) {
387 dev->phy_map == 0xffffffff) { 398 /* first attempt has timed out. */
399 n = 20;
400 try_internal_clock = true;
401 goto do_retry;
402 }
403
404 if (try_internal_clock || (dev->phy_address == 0xffffffff &&
405 dev->phy_map == 0xffffffff)) {
388 /* No PHY: restore external clock source after reset */ 406 /* No PHY: restore external clock source after reset */
389 dcri_clrset(SDR0, SDR0_ETH_CFG, 407 dcri_clrset(SDR0, SDR0_ETH_CFG,
390 SDR0_ETH_CFG_ECS << dev->cell_index, 0); 408 SDR0_ETH_CFG_ECS << dev->cell_index, 0);
@@ -2460,20 +2478,24 @@ static int emac_mii_bus_reset(struct mii_bus *bus)
2460 return emac_reset(dev); 2478 return emac_reset(dev);
2461} 2479}
2462 2480
2481static int emac_mdio_phy_start_aneg(struct mii_phy *phy,
2482 struct phy_device *phy_dev)
2483{
2484 phy_dev->autoneg = phy->autoneg;
2485 phy_dev->speed = phy->speed;
2486 phy_dev->duplex = phy->duplex;
2487 phy_dev->advertising = phy->advertising;
2488 return phy_start_aneg(phy_dev);
2489}
2490
2463static int emac_mdio_setup_aneg(struct mii_phy *phy, u32 advertise) 2491static int emac_mdio_setup_aneg(struct mii_phy *phy, u32 advertise)
2464{ 2492{
2465 struct net_device *ndev = phy->dev; 2493 struct net_device *ndev = phy->dev;
2466 struct emac_instance *dev = netdev_priv(ndev); 2494 struct emac_instance *dev = netdev_priv(ndev);
2467 2495
2468 dev->phy.autoneg = AUTONEG_ENABLE;
2469 dev->phy.speed = SPEED_1000;
2470 dev->phy.duplex = DUPLEX_FULL;
2471 dev->phy.advertising = advertise;
2472 phy->autoneg = AUTONEG_ENABLE; 2496 phy->autoneg = AUTONEG_ENABLE;
2473 phy->speed = dev->phy.speed;
2474 phy->duplex = dev->phy.duplex;
2475 phy->advertising = advertise; 2497 phy->advertising = advertise;
2476 return phy_start_aneg(dev->phy_dev); 2498 return emac_mdio_phy_start_aneg(phy, dev->phy_dev);
2477} 2499}
2478 2500
2479static int emac_mdio_setup_forced(struct mii_phy *phy, int speed, int fd) 2501static int emac_mdio_setup_forced(struct mii_phy *phy, int speed, int fd)
@@ -2481,13 +2503,10 @@ static int emac_mdio_setup_forced(struct mii_phy *phy, int speed, int fd)
2481 struct net_device *ndev = phy->dev; 2503 struct net_device *ndev = phy->dev;
2482 struct emac_instance *dev = netdev_priv(ndev); 2504 struct emac_instance *dev = netdev_priv(ndev);
2483 2505
2484 dev->phy.autoneg = AUTONEG_DISABLE;
2485 dev->phy.speed = speed;
2486 dev->phy.duplex = fd;
2487 phy->autoneg = AUTONEG_DISABLE; 2506 phy->autoneg = AUTONEG_DISABLE;
2488 phy->speed = speed; 2507 phy->speed = speed;
2489 phy->duplex = fd; 2508 phy->duplex = fd;
2490 return phy_start_aneg(dev->phy_dev); 2509 return emac_mdio_phy_start_aneg(phy, dev->phy_dev);
2491} 2510}
2492 2511
2493static int emac_mdio_poll_link(struct mii_phy *phy) 2512static int emac_mdio_poll_link(struct mii_phy *phy)
@@ -2509,16 +2528,17 @@ static int emac_mdio_read_link(struct mii_phy *phy)
2509{ 2528{
2510 struct net_device *ndev = phy->dev; 2529 struct net_device *ndev = phy->dev;
2511 struct emac_instance *dev = netdev_priv(ndev); 2530 struct emac_instance *dev = netdev_priv(ndev);
2531 struct phy_device *phy_dev = dev->phy_dev;
2512 int res; 2532 int res;
2513 2533
2514 res = phy_read_status(dev->phy_dev); 2534 res = phy_read_status(phy_dev);
2515 if (res) 2535 if (res)
2516 return res; 2536 return res;
2517 2537
2518 dev->phy.speed = phy->speed; 2538 phy->speed = phy_dev->speed;
2519 dev->phy.duplex = phy->duplex; 2539 phy->duplex = phy_dev->duplex;
2520 dev->phy.pause = phy->pause; 2540 phy->pause = phy_dev->pause;
2521 dev->phy.asym_pause = phy->asym_pause; 2541 phy->asym_pause = phy_dev->asym_pause;
2522 return 0; 2542 return 0;
2523} 2543}
2524 2544
@@ -2528,13 +2548,6 @@ static int emac_mdio_init_phy(struct mii_phy *phy)
2528 struct emac_instance *dev = netdev_priv(ndev); 2548 struct emac_instance *dev = netdev_priv(ndev);
2529 2549
2530 phy_start(dev->phy_dev); 2550 phy_start(dev->phy_dev);
2531 dev->phy.autoneg = phy->autoneg;
2532 dev->phy.speed = phy->speed;
2533 dev->phy.duplex = phy->duplex;
2534 dev->phy.advertising = phy->advertising;
2535 dev->phy.pause = phy->pause;
2536 dev->phy.asym_pause = phy->asym_pause;
2537
2538 return phy_init_hw(dev->phy_dev); 2551 return phy_init_hw(dev->phy_dev);
2539} 2552}
2540 2553
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index a93757c255f7..c0fbeb387db4 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1468,6 +1468,11 @@ static void ibmvnic_netpoll_controller(struct net_device *dev)
1468} 1468}
1469#endif 1469#endif
1470 1470
1471static int ibmvnic_change_mtu(struct net_device *netdev, int new_mtu)
1472{
1473 return -EOPNOTSUPP;
1474}
1475
1471static const struct net_device_ops ibmvnic_netdev_ops = { 1476static const struct net_device_ops ibmvnic_netdev_ops = {
1472 .ndo_open = ibmvnic_open, 1477 .ndo_open = ibmvnic_open,
1473 .ndo_stop = ibmvnic_close, 1478 .ndo_stop = ibmvnic_close,
@@ -1479,6 +1484,7 @@ static const struct net_device_ops ibmvnic_netdev_ops = {
1479#ifdef CONFIG_NET_POLL_CONTROLLER 1484#ifdef CONFIG_NET_POLL_CONTROLLER
1480 .ndo_poll_controller = ibmvnic_netpoll_controller, 1485 .ndo_poll_controller = ibmvnic_netpoll_controller,
1481#endif 1486#endif
1487 .ndo_change_mtu = ibmvnic_change_mtu,
1482}; 1488};
1483 1489
1484/* ethtool functions */ 1490/* ethtool functions */
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index cdde3cc28fb5..44d9610f7a15 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -399,6 +399,7 @@ struct i40e_pf {
399#define I40E_FLAG_RX_CSUM_ENABLED BIT_ULL(1) 399#define I40E_FLAG_RX_CSUM_ENABLED BIT_ULL(1)
400#define I40E_FLAG_MSI_ENABLED BIT_ULL(2) 400#define I40E_FLAG_MSI_ENABLED BIT_ULL(2)
401#define I40E_FLAG_MSIX_ENABLED BIT_ULL(3) 401#define I40E_FLAG_MSIX_ENABLED BIT_ULL(3)
402#define I40E_FLAG_HW_ATR_EVICT_ENABLED BIT_ULL(4)
402#define I40E_FLAG_RSS_ENABLED BIT_ULL(6) 403#define I40E_FLAG_RSS_ENABLED BIT_ULL(6)
403#define I40E_FLAG_VMDQ_ENABLED BIT_ULL(7) 404#define I40E_FLAG_VMDQ_ENABLED BIT_ULL(7)
404#define I40E_FLAG_IWARP_ENABLED BIT_ULL(10) 405#define I40E_FLAG_IWARP_ENABLED BIT_ULL(10)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 7a8eb486b9ea..894c8e57ba00 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -224,7 +224,7 @@ static const struct i40e_priv_flags i40e_gstrings_priv_flags[] = {
224 I40E_PRIV_FLAG("LinkPolling", I40E_FLAG_LINK_POLLING_ENABLED, 0), 224 I40E_PRIV_FLAG("LinkPolling", I40E_FLAG_LINK_POLLING_ENABLED, 0),
225 I40E_PRIV_FLAG("flow-director-atr", I40E_FLAG_FD_ATR_ENABLED, 0), 225 I40E_PRIV_FLAG("flow-director-atr", I40E_FLAG_FD_ATR_ENABLED, 0),
226 I40E_PRIV_FLAG("veb-stats", I40E_FLAG_VEB_STATS_ENABLED, 0), 226 I40E_PRIV_FLAG("veb-stats", I40E_FLAG_VEB_STATS_ENABLED, 0),
227 I40E_PRIV_FLAG("hw-atr-eviction", I40E_FLAG_HW_ATR_EVICT_CAPABLE, 0), 227 I40E_PRIV_FLAG("hw-atr-eviction", I40E_FLAG_HW_ATR_EVICT_ENABLED, 0),
228 I40E_PRIV_FLAG("legacy-rx", I40E_FLAG_LEGACY_RX, 0), 228 I40E_PRIV_FLAG("legacy-rx", I40E_FLAG_LEGACY_RX, 0),
229}; 229};
230 230
@@ -4092,7 +4092,7 @@ flags_complete:
4092 4092
4093 /* Only allow ATR evict on hardware that is capable of handling it */ 4093 /* Only allow ATR evict on hardware that is capable of handling it */
4094 if (pf->flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE) 4094 if (pf->flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE)
4095 pf->flags &= ~I40E_FLAG_HW_ATR_EVICT_CAPABLE; 4095 pf->flags &= ~I40E_FLAG_HW_ATR_EVICT_ENABLED;
4096 4096
4097 if (changed_flags & I40E_FLAG_TRUE_PROMISC_SUPPORT) { 4097 if (changed_flags & I40E_FLAG_TRUE_PROMISC_SUPPORT) {
4098 u16 sw_flags = 0, valid_flags = 0; 4098 u16 sw_flags = 0, valid_flags = 0;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 150caf6ca2b4..a7a4b28b4144 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -8821,11 +8821,12 @@ static int i40e_sw_init(struct i40e_pf *pf)
8821 (pf->hw.aq.api_min_ver > 4))) { 8821 (pf->hw.aq.api_min_ver > 4))) {
8822 /* Supported in FW API version higher than 1.4 */ 8822 /* Supported in FW API version higher than 1.4 */
8823 pf->flags |= I40E_FLAG_GENEVE_OFFLOAD_CAPABLE; 8823 pf->flags |= I40E_FLAG_GENEVE_OFFLOAD_CAPABLE;
8824 pf->flags = I40E_FLAG_HW_ATR_EVICT_CAPABLE;
8825 } else {
8826 pf->flags = I40E_FLAG_HW_ATR_EVICT_CAPABLE;
8827 } 8824 }
8828 8825
8826 /* Enable HW ATR eviction if possible */
8827 if (pf->flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE)
8828 pf->flags |= I40E_FLAG_HW_ATR_EVICT_ENABLED;
8829
8829 pf->eeprom_version = 0xDEAD; 8830 pf->eeprom_version = 0xDEAD;
8830 pf->lan_veb = I40E_NO_VEB; 8831 pf->lan_veb = I40E_NO_VEB;
8831 pf->lan_vsi = I40E_NO_VSI; 8832 pf->lan_vsi = I40E_NO_VSI;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index cd894f4023b1..77115c25d96f 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -2341,7 +2341,7 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb,
2341 /* Due to lack of space, no more new filters can be programmed */ 2341 /* Due to lack of space, no more new filters can be programmed */
2342 if (th->syn && (pf->flags & I40E_FLAG_FD_ATR_AUTO_DISABLED)) 2342 if (th->syn && (pf->flags & I40E_FLAG_FD_ATR_AUTO_DISABLED))
2343 return; 2343 return;
2344 if (pf->flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE) { 2344 if (pf->flags & I40E_FLAG_HW_ATR_EVICT_ENABLED) {
2345 /* HW ATR eviction will take care of removing filters on FIN 2345 /* HW ATR eviction will take care of removing filters on FIN
2346 * and RST packets. 2346 * and RST packets.
2347 */ 2347 */
@@ -2403,7 +2403,7 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb,
2403 I40E_TXD_FLTR_QW1_CNTINDEX_SHIFT) & 2403 I40E_TXD_FLTR_QW1_CNTINDEX_SHIFT) &
2404 I40E_TXD_FLTR_QW1_CNTINDEX_MASK; 2404 I40E_TXD_FLTR_QW1_CNTINDEX_MASK;
2405 2405
2406 if (pf->flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE) 2406 if (pf->flags & I40E_FLAG_HW_ATR_EVICT_ENABLED)
2407 dtype_cmd |= I40E_TXD_FLTR_QW1_ATR_MASK; 2407 dtype_cmd |= I40E_TXD_FLTR_QW1_ATR_MASK;
2408 2408
2409 fdir_desc->qindex_flex_ptype_vsi = cpu_to_le32(flex_ptype); 2409 fdir_desc->qindex_flex_ptype_vsi = cpu_to_le32(flex_ptype);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 95c23fbaa211..0fb38ca78900 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -3017,10 +3017,12 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,
3017 VLAN_VID_MASK)); 3017 VLAN_VID_MASK));
3018 } 3018 }
3019 3019
3020 spin_unlock_bh(&vsi->mac_filter_hash_lock);
3020 if (vlan_id || qos) 3021 if (vlan_id || qos)
3021 ret = i40e_vsi_add_pvid(vsi, vlanprio); 3022 ret = i40e_vsi_add_pvid(vsi, vlanprio);
3022 else 3023 else
3023 i40e_vsi_remove_pvid(vsi); 3024 i40e_vsi_remove_pvid(vsi);
3025 spin_lock_bh(&vsi->mac_filter_hash_lock);
3024 3026
3025 if (vlan_id) { 3027 if (vlan_id) {
3026 dev_info(&pf->pdev->dev, "Setting VLAN %d, QOS 0x%x on VF %d\n", 3028 dev_info(&pf->pdev->dev, "Setting VLAN %d, QOS 0x%x on VF %d\n",
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 9b875d776b29..33c901622ed5 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -3719,7 +3719,7 @@ static void mvpp2_bm_bufs_get_addrs(struct device *dev, struct mvpp2 *priv,
3719 dma_addr_t *dma_addr, 3719 dma_addr_t *dma_addr,
3720 phys_addr_t *phys_addr) 3720 phys_addr_t *phys_addr)
3721{ 3721{
3722 int cpu = smp_processor_id(); 3722 int cpu = get_cpu();
3723 3723
3724 *dma_addr = mvpp2_percpu_read(priv, cpu, 3724 *dma_addr = mvpp2_percpu_read(priv, cpu,
3725 MVPP2_BM_PHY_ALLOC_REG(bm_pool->id)); 3725 MVPP2_BM_PHY_ALLOC_REG(bm_pool->id));
@@ -3740,6 +3740,8 @@ static void mvpp2_bm_bufs_get_addrs(struct device *dev, struct mvpp2 *priv,
3740 if (sizeof(phys_addr_t) == 8) 3740 if (sizeof(phys_addr_t) == 8)
3741 *phys_addr |= (u64)phys_addr_highbits << 32; 3741 *phys_addr |= (u64)phys_addr_highbits << 32;
3742 } 3742 }
3743
3744 put_cpu();
3743} 3745}
3744 3746
3745/* Free all buffers from the pool */ 3747/* Free all buffers from the pool */
@@ -3920,18 +3922,12 @@ static inline u32 mvpp2_bm_cookie_pool_set(u32 cookie, int pool)
3920 return bm; 3922 return bm;
3921} 3923}
3922 3924
3923/* Get pool number from a BM cookie */
3924static inline int mvpp2_bm_cookie_pool_get(unsigned long cookie)
3925{
3926 return (cookie >> MVPP2_BM_COOKIE_POOL_OFFS) & 0xFF;
3927}
3928
3929/* Release buffer to BM */ 3925/* Release buffer to BM */
3930static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool, 3926static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool,
3931 dma_addr_t buf_dma_addr, 3927 dma_addr_t buf_dma_addr,
3932 phys_addr_t buf_phys_addr) 3928 phys_addr_t buf_phys_addr)
3933{ 3929{
3934 int cpu = smp_processor_id(); 3930 int cpu = get_cpu();
3935 3931
3936 if (port->priv->hw_version == MVPP22) { 3932 if (port->priv->hw_version == MVPP22) {
3937 u32 val = 0; 3933 u32 val = 0;
@@ -3958,15 +3954,15 @@ static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool,
3958 MVPP2_BM_VIRT_RLS_REG, buf_phys_addr); 3954 MVPP2_BM_VIRT_RLS_REG, buf_phys_addr);
3959 mvpp2_percpu_write(port->priv, cpu, 3955 mvpp2_percpu_write(port->priv, cpu,
3960 MVPP2_BM_PHY_RLS_REG(pool), buf_dma_addr); 3956 MVPP2_BM_PHY_RLS_REG(pool), buf_dma_addr);
3957
3958 put_cpu();
3961} 3959}
3962 3960
3963/* Refill BM pool */ 3961/* Refill BM pool */
3964static void mvpp2_pool_refill(struct mvpp2_port *port, u32 bm, 3962static void mvpp2_pool_refill(struct mvpp2_port *port, int pool,
3965 dma_addr_t dma_addr, 3963 dma_addr_t dma_addr,
3966 phys_addr_t phys_addr) 3964 phys_addr_t phys_addr)
3967{ 3965{
3968 int pool = mvpp2_bm_cookie_pool_get(bm);
3969
3970 mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr); 3966 mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr);
3971} 3967}
3972 3968
@@ -4186,8 +4182,6 @@ static void mvpp22_port_mii_set(struct mvpp2_port *port)
4186{ 4182{
4187 u32 val; 4183 u32 val;
4188 4184
4189 return;
4190
4191 /* Only GOP port 0 has an XLG MAC */ 4185 /* Only GOP port 0 has an XLG MAC */
4192 if (port->gop_id == 0) { 4186 if (port->gop_id == 0) {
4193 val = readl(port->base + MVPP22_XLG_CTRL3_REG); 4187 val = readl(port->base + MVPP22_XLG_CTRL3_REG);
@@ -4515,21 +4509,6 @@ static void mvpp2_rxq_offset_set(struct mvpp2_port *port,
4515 mvpp2_write(port->priv, MVPP2_RXQ_CONFIG_REG(prxq), val); 4509 mvpp2_write(port->priv, MVPP2_RXQ_CONFIG_REG(prxq), val);
4516} 4510}
4517 4511
4518/* Obtain BM cookie information from descriptor */
4519static u32 mvpp2_bm_cookie_build(struct mvpp2_port *port,
4520 struct mvpp2_rx_desc *rx_desc)
4521{
4522 int cpu = smp_processor_id();
4523 int pool;
4524
4525 pool = (mvpp2_rxdesc_status_get(port, rx_desc) &
4526 MVPP2_RXD_BM_POOL_ID_MASK) >>
4527 MVPP2_RXD_BM_POOL_ID_OFFS;
4528
4529 return ((pool & 0xFF) << MVPP2_BM_COOKIE_POOL_OFFS) |
4530 ((cpu & 0xFF) << MVPP2_BM_COOKIE_CPU_OFFS);
4531}
4532
4533/* Tx descriptors helper methods */ 4512/* Tx descriptors helper methods */
4534 4513
4535/* Get pointer to next Tx descriptor to be processed (send) by HW */ 4514/* Get pointer to next Tx descriptor to be processed (send) by HW */
@@ -4757,7 +4736,7 @@ static void mvpp2_txp_max_tx_size_set(struct mvpp2_port *port)
4757static void mvpp2_rx_pkts_coal_set(struct mvpp2_port *port, 4736static void mvpp2_rx_pkts_coal_set(struct mvpp2_port *port,
4758 struct mvpp2_rx_queue *rxq) 4737 struct mvpp2_rx_queue *rxq)
4759{ 4738{
4760 int cpu = smp_processor_id(); 4739 int cpu = get_cpu();
4761 4740
4762 if (rxq->pkts_coal > MVPP2_OCCUPIED_THRESH_MASK) 4741 if (rxq->pkts_coal > MVPP2_OCCUPIED_THRESH_MASK)
4763 rxq->pkts_coal = MVPP2_OCCUPIED_THRESH_MASK; 4742 rxq->pkts_coal = MVPP2_OCCUPIED_THRESH_MASK;
@@ -4765,6 +4744,8 @@ static void mvpp2_rx_pkts_coal_set(struct mvpp2_port *port,
4765 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_NUM_REG, rxq->id); 4744 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_NUM_REG, rxq->id);
4766 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_THRESH_REG, 4745 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_THRESH_REG,
4767 rxq->pkts_coal); 4746 rxq->pkts_coal);
4747
4748 put_cpu();
4768} 4749}
4769 4750
4770static u32 mvpp2_usec_to_cycles(u32 usec, unsigned long clk_hz) 4751static u32 mvpp2_usec_to_cycles(u32 usec, unsigned long clk_hz)
@@ -4945,7 +4926,7 @@ static int mvpp2_rxq_init(struct mvpp2_port *port,
4945 mvpp2_write(port->priv, MVPP2_RXQ_STATUS_REG(rxq->id), 0); 4926 mvpp2_write(port->priv, MVPP2_RXQ_STATUS_REG(rxq->id), 0);
4946 4927
4947 /* Set Rx descriptors queue starting address - indirect access */ 4928 /* Set Rx descriptors queue starting address - indirect access */
4948 cpu = smp_processor_id(); 4929 cpu = get_cpu();
4949 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_NUM_REG, rxq->id); 4930 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_NUM_REG, rxq->id);
4950 if (port->priv->hw_version == MVPP21) 4931 if (port->priv->hw_version == MVPP21)
4951 rxq_dma = rxq->descs_dma; 4932 rxq_dma = rxq->descs_dma;
@@ -4954,6 +4935,7 @@ static int mvpp2_rxq_init(struct mvpp2_port *port,
4954 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_ADDR_REG, rxq_dma); 4935 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_ADDR_REG, rxq_dma);
4955 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_SIZE_REG, rxq->size); 4936 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_SIZE_REG, rxq->size);
4956 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_INDEX_REG, 0); 4937 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_INDEX_REG, 0);
4938 put_cpu();
4957 4939
4958 /* Set Offset */ 4940 /* Set Offset */
4959 mvpp2_rxq_offset_set(port, rxq->id, NET_SKB_PAD); 4941 mvpp2_rxq_offset_set(port, rxq->id, NET_SKB_PAD);
@@ -4980,9 +4962,13 @@ static void mvpp2_rxq_drop_pkts(struct mvpp2_port *port,
4980 4962
4981 for (i = 0; i < rx_received; i++) { 4963 for (i = 0; i < rx_received; i++) {
4982 struct mvpp2_rx_desc *rx_desc = mvpp2_rxq_next_desc_get(rxq); 4964 struct mvpp2_rx_desc *rx_desc = mvpp2_rxq_next_desc_get(rxq);
4983 u32 bm = mvpp2_bm_cookie_build(port, rx_desc); 4965 u32 status = mvpp2_rxdesc_status_get(port, rx_desc);
4966 int pool;
4967
4968 pool = (status & MVPP2_RXD_BM_POOL_ID_MASK) >>
4969 MVPP2_RXD_BM_POOL_ID_OFFS;
4984 4970
4985 mvpp2_pool_refill(port, bm, 4971 mvpp2_pool_refill(port, pool,
4986 mvpp2_rxdesc_dma_addr_get(port, rx_desc), 4972 mvpp2_rxdesc_dma_addr_get(port, rx_desc),
4987 mvpp2_rxdesc_cookie_get(port, rx_desc)); 4973 mvpp2_rxdesc_cookie_get(port, rx_desc));
4988 } 4974 }
@@ -5012,10 +4998,11 @@ static void mvpp2_rxq_deinit(struct mvpp2_port *port,
5012 * free descriptor number 4998 * free descriptor number
5013 */ 4999 */
5014 mvpp2_write(port->priv, MVPP2_RXQ_STATUS_REG(rxq->id), 0); 5000 mvpp2_write(port->priv, MVPP2_RXQ_STATUS_REG(rxq->id), 0);
5015 cpu = smp_processor_id(); 5001 cpu = get_cpu();
5016 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_NUM_REG, rxq->id); 5002 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_NUM_REG, rxq->id);
5017 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_ADDR_REG, 0); 5003 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_ADDR_REG, 0);
5018 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_SIZE_REG, 0); 5004 mvpp2_percpu_write(port->priv, cpu, MVPP2_RXQ_DESC_SIZE_REG, 0);
5005 put_cpu();
5019} 5006}
5020 5007
5021/* Create and initialize a Tx queue */ 5008/* Create and initialize a Tx queue */
@@ -5038,7 +5025,7 @@ static int mvpp2_txq_init(struct mvpp2_port *port,
5038 txq->last_desc = txq->size - 1; 5025 txq->last_desc = txq->size - 1;
5039 5026
5040 /* Set Tx descriptors queue starting address - indirect access */ 5027 /* Set Tx descriptors queue starting address - indirect access */
5041 cpu = smp_processor_id(); 5028 cpu = get_cpu();
5042 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_NUM_REG, txq->id); 5029 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_NUM_REG, txq->id);
5043 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_DESC_ADDR_REG, 5030 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_DESC_ADDR_REG,
5044 txq->descs_dma); 5031 txq->descs_dma);
@@ -5063,6 +5050,7 @@ static int mvpp2_txq_init(struct mvpp2_port *port,
5063 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_PREF_BUF_REG, 5050 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_PREF_BUF_REG,
5064 MVPP2_PREF_BUF_PTR(desc) | MVPP2_PREF_BUF_SIZE_16 | 5051 MVPP2_PREF_BUF_PTR(desc) | MVPP2_PREF_BUF_SIZE_16 |
5065 MVPP2_PREF_BUF_THRESH(desc_per_txq / 2)); 5052 MVPP2_PREF_BUF_THRESH(desc_per_txq / 2));
5053 put_cpu();
5066 5054
5067 /* WRR / EJP configuration - indirect access */ 5055 /* WRR / EJP configuration - indirect access */
5068 tx_port_num = mvpp2_egress_port(port); 5056 tx_port_num = mvpp2_egress_port(port);
@@ -5133,10 +5121,11 @@ static void mvpp2_txq_deinit(struct mvpp2_port *port,
5133 mvpp2_write(port->priv, MVPP2_TXQ_SCHED_TOKEN_CNTR_REG(txq->id), 0); 5121 mvpp2_write(port->priv, MVPP2_TXQ_SCHED_TOKEN_CNTR_REG(txq->id), 0);
5134 5122
5135 /* Set Tx descriptors queue starting address and size */ 5123 /* Set Tx descriptors queue starting address and size */
5136 cpu = smp_processor_id(); 5124 cpu = get_cpu();
5137 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_NUM_REG, txq->id); 5125 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_NUM_REG, txq->id);
5138 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_DESC_ADDR_REG, 0); 5126 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_DESC_ADDR_REG, 0);
5139 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_DESC_SIZE_REG, 0); 5127 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_DESC_SIZE_REG, 0);
5128 put_cpu();
5140} 5129}
5141 5130
5142/* Cleanup Tx ports */ 5131/* Cleanup Tx ports */
@@ -5146,7 +5135,7 @@ static void mvpp2_txq_clean(struct mvpp2_port *port, struct mvpp2_tx_queue *txq)
5146 int delay, pending, cpu; 5135 int delay, pending, cpu;
5147 u32 val; 5136 u32 val;
5148 5137
5149 cpu = smp_processor_id(); 5138 cpu = get_cpu();
5150 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_NUM_REG, txq->id); 5139 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_NUM_REG, txq->id);
5151 val = mvpp2_percpu_read(port->priv, cpu, MVPP2_TXQ_PREF_BUF_REG); 5140 val = mvpp2_percpu_read(port->priv, cpu, MVPP2_TXQ_PREF_BUF_REG);
5152 val |= MVPP2_TXQ_DRAIN_EN_MASK; 5141 val |= MVPP2_TXQ_DRAIN_EN_MASK;
@@ -5173,6 +5162,7 @@ static void mvpp2_txq_clean(struct mvpp2_port *port, struct mvpp2_tx_queue *txq)
5173 5162
5174 val &= ~MVPP2_TXQ_DRAIN_EN_MASK; 5163 val &= ~MVPP2_TXQ_DRAIN_EN_MASK;
5175 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_PREF_BUF_REG, val); 5164 mvpp2_percpu_write(port->priv, cpu, MVPP2_TXQ_PREF_BUF_REG, val);
5165 put_cpu();
5176 5166
5177 for_each_present_cpu(cpu) { 5167 for_each_present_cpu(cpu) {
5178 txq_pcpu = per_cpu_ptr(txq->pcpu, cpu); 5168 txq_pcpu = per_cpu_ptr(txq->pcpu, cpu);
@@ -5420,7 +5410,7 @@ static void mvpp2_rx_csum(struct mvpp2_port *port, u32 status,
5420 5410
5421/* Reuse skb if possible, or allocate a new skb and add it to BM pool */ 5411/* Reuse skb if possible, or allocate a new skb and add it to BM pool */
5422static int mvpp2_rx_refill(struct mvpp2_port *port, 5412static int mvpp2_rx_refill(struct mvpp2_port *port,
5423 struct mvpp2_bm_pool *bm_pool, u32 bm) 5413 struct mvpp2_bm_pool *bm_pool, int pool)
5424{ 5414{
5425 dma_addr_t dma_addr; 5415 dma_addr_t dma_addr;
5426 phys_addr_t phys_addr; 5416 phys_addr_t phys_addr;
@@ -5432,7 +5422,7 @@ static int mvpp2_rx_refill(struct mvpp2_port *port,
5432 if (!buf) 5422 if (!buf)
5433 return -ENOMEM; 5423 return -ENOMEM;
5434 5424
5435 mvpp2_pool_refill(port, bm, dma_addr, phys_addr); 5425 mvpp2_pool_refill(port, pool, dma_addr, phys_addr);
5436 5426
5437 return 0; 5427 return 0;
5438} 5428}
@@ -5490,7 +5480,7 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo,
5490 unsigned int frag_size; 5480 unsigned int frag_size;
5491 dma_addr_t dma_addr; 5481 dma_addr_t dma_addr;
5492 phys_addr_t phys_addr; 5482 phys_addr_t phys_addr;
5493 u32 bm, rx_status; 5483 u32 rx_status;
5494 int pool, rx_bytes, err; 5484 int pool, rx_bytes, err;
5495 void *data; 5485 void *data;
5496 5486
@@ -5502,8 +5492,8 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo,
5502 phys_addr = mvpp2_rxdesc_cookie_get(port, rx_desc); 5492 phys_addr = mvpp2_rxdesc_cookie_get(port, rx_desc);
5503 data = (void *)phys_to_virt(phys_addr); 5493 data = (void *)phys_to_virt(phys_addr);
5504 5494
5505 bm = mvpp2_bm_cookie_build(port, rx_desc); 5495 pool = (rx_status & MVPP2_RXD_BM_POOL_ID_MASK) >>
5506 pool = mvpp2_bm_cookie_pool_get(bm); 5496 MVPP2_RXD_BM_POOL_ID_OFFS;
5507 bm_pool = &port->priv->bm_pools[pool]; 5497 bm_pool = &port->priv->bm_pools[pool];
5508 5498
5509 /* In case of an error, release the requested buffer pointer 5499 /* In case of an error, release the requested buffer pointer
@@ -5516,7 +5506,7 @@ err_drop_frame:
5516 dev->stats.rx_errors++; 5506 dev->stats.rx_errors++;
5517 mvpp2_rx_error(port, rx_desc); 5507 mvpp2_rx_error(port, rx_desc);
5518 /* Return the buffer to the pool */ 5508 /* Return the buffer to the pool */
5519 mvpp2_pool_refill(port, bm, dma_addr, phys_addr); 5509 mvpp2_pool_refill(port, pool, dma_addr, phys_addr);
5520 continue; 5510 continue;
5521 } 5511 }
5522 5512
@@ -5531,7 +5521,7 @@ err_drop_frame:
5531 goto err_drop_frame; 5521 goto err_drop_frame;
5532 } 5522 }
5533 5523
5534 err = mvpp2_rx_refill(port, bm_pool, bm); 5524 err = mvpp2_rx_refill(port, bm_pool, pool);
5535 if (err) { 5525 if (err) {
5536 netdev_err(port->dev, "failed to refill BM pools\n"); 5526 netdev_err(port->dev, "failed to refill BM pools\n");
5537 goto err_drop_frame; 5527 goto err_drop_frame;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 2fd044b23875..944fc1742464 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -458,13 +458,15 @@ struct mlx5e_mpw_info {
458 458
459struct mlx5e_rx_am_stats { 459struct mlx5e_rx_am_stats {
460 int ppms; /* packets per msec */ 460 int ppms; /* packets per msec */
461 int bpms; /* bytes per msec */
461 int epms; /* events per msec */ 462 int epms; /* events per msec */
462}; 463};
463 464
464struct mlx5e_rx_am_sample { 465struct mlx5e_rx_am_sample {
465 ktime_t time; 466 ktime_t time;
466 unsigned int pkt_ctr; 467 u32 pkt_ctr;
467 u16 event_ctr; 468 u32 byte_ctr;
469 u16 event_ctr;
468}; 470};
469 471
470struct mlx5e_rx_am { /* Adaptive Moderation */ 472struct mlx5e_rx_am { /* Adaptive Moderation */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
index 02dd3a95ed8f..acf32fe952cd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
@@ -183,28 +183,27 @@ static void mlx5e_am_exit_parking(struct mlx5e_rx_am *am)
183 mlx5e_am_step(am); 183 mlx5e_am_step(am);
184} 184}
185 185
186#define IS_SIGNIFICANT_DIFF(val, ref) \
187 (((100 * abs((val) - (ref))) / (ref)) > 10) /* more than 10% difference */
188
186static int mlx5e_am_stats_compare(struct mlx5e_rx_am_stats *curr, 189static int mlx5e_am_stats_compare(struct mlx5e_rx_am_stats *curr,
187 struct mlx5e_rx_am_stats *prev) 190 struct mlx5e_rx_am_stats *prev)
188{ 191{
189 int diff; 192 if (!prev->bpms)
190 193 return curr->bpms ? MLX5E_AM_STATS_BETTER :
191 if (!prev->ppms)
192 return curr->ppms ? MLX5E_AM_STATS_BETTER :
193 MLX5E_AM_STATS_SAME; 194 MLX5E_AM_STATS_SAME;
194 195
195 diff = curr->ppms - prev->ppms; 196 if (IS_SIGNIFICANT_DIFF(curr->bpms, prev->bpms))
196 if (((100 * abs(diff)) / prev->ppms) > 10) /* more than 10% diff */ 197 return (curr->bpms > prev->bpms) ? MLX5E_AM_STATS_BETTER :
197 return (diff > 0) ? MLX5E_AM_STATS_BETTER : 198 MLX5E_AM_STATS_WORSE;
198 MLX5E_AM_STATS_WORSE;
199 199
200 if (!prev->epms) 200 if (IS_SIGNIFICANT_DIFF(curr->ppms, prev->ppms))
201 return curr->epms ? MLX5E_AM_STATS_WORSE : 201 return (curr->ppms > prev->ppms) ? MLX5E_AM_STATS_BETTER :
202 MLX5E_AM_STATS_SAME; 202 MLX5E_AM_STATS_WORSE;
203 203
204 diff = curr->epms - prev->epms; 204 if (IS_SIGNIFICANT_DIFF(curr->epms, prev->epms))
205 if (((100 * abs(diff)) / prev->epms) > 10) /* more than 10% diff */ 205 return (curr->epms < prev->epms) ? MLX5E_AM_STATS_BETTER :
206 return (diff < 0) ? MLX5E_AM_STATS_BETTER : 206 MLX5E_AM_STATS_WORSE;
207 MLX5E_AM_STATS_WORSE;
208 207
209 return MLX5E_AM_STATS_SAME; 208 return MLX5E_AM_STATS_SAME;
210} 209}
@@ -266,10 +265,13 @@ static void mlx5e_am_sample(struct mlx5e_rq *rq,
266{ 265{
267 s->time = ktime_get(); 266 s->time = ktime_get();
268 s->pkt_ctr = rq->stats.packets; 267 s->pkt_ctr = rq->stats.packets;
268 s->byte_ctr = rq->stats.bytes;
269 s->event_ctr = rq->cq.event_ctr; 269 s->event_ctr = rq->cq.event_ctr;
270} 270}
271 271
272#define MLX5E_AM_NEVENTS 64 272#define MLX5E_AM_NEVENTS 64
273#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
274#define BIT_GAP(bits, end, start) ((((end) - (start)) + BIT_ULL(bits)) & (BIT_ULL(bits) - 1))
273 275
274static void mlx5e_am_calc_stats(struct mlx5e_rx_am_sample *start, 276static void mlx5e_am_calc_stats(struct mlx5e_rx_am_sample *start,
275 struct mlx5e_rx_am_sample *end, 277 struct mlx5e_rx_am_sample *end,
@@ -277,13 +279,17 @@ static void mlx5e_am_calc_stats(struct mlx5e_rx_am_sample *start,
277{ 279{
278 /* u32 holds up to 71 minutes, should be enough */ 280 /* u32 holds up to 71 minutes, should be enough */
279 u32 delta_us = ktime_us_delta(end->time, start->time); 281 u32 delta_us = ktime_us_delta(end->time, start->time);
280 unsigned int npkts = end->pkt_ctr - start->pkt_ctr; 282 u32 npkts = BIT_GAP(BITS_PER_TYPE(u32), end->pkt_ctr, start->pkt_ctr);
283 u32 nbytes = BIT_GAP(BITS_PER_TYPE(u32), end->byte_ctr,
284 start->byte_ctr);
281 285
282 if (!delta_us) 286 if (!delta_us)
283 return; 287 return;
284 288
285 curr_stats->ppms = (npkts * USEC_PER_MSEC) / delta_us; 289 curr_stats->ppms = DIV_ROUND_UP(npkts * USEC_PER_MSEC, delta_us);
286 curr_stats->epms = (MLX5E_AM_NEVENTS * USEC_PER_MSEC) / delta_us; 290 curr_stats->bpms = DIV_ROUND_UP(nbytes * USEC_PER_MSEC, delta_us);
291 curr_stats->epms = DIV_ROUND_UP(MLX5E_AM_NEVENTS * USEC_PER_MSEC,
292 delta_us);
287} 293}
288 294
289void mlx5e_rx_am_work(struct work_struct *work) 295void mlx5e_rx_am_work(struct work_struct *work)
@@ -308,7 +314,8 @@ void mlx5e_rx_am(struct mlx5e_rq *rq)
308 314
309 switch (am->state) { 315 switch (am->state) {
310 case MLX5E_AM_MEASURE_IN_PROGRESS: 316 case MLX5E_AM_MEASURE_IN_PROGRESS:
311 nevents = rq->cq.event_ctr - am->start_sample.event_ctr; 317 nevents = BIT_GAP(BITS_PER_TYPE(u16), rq->cq.event_ctr,
318 am->start_sample.event_ctr);
312 if (nevents < MLX5E_AM_NEVENTS) 319 if (nevents < MLX5E_AM_NEVENTS)
313 break; 320 break;
314 mlx5e_am_sample(rq, &end_sample); 321 mlx5e_am_sample(rq, &end_sample);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index 53e4992d6511..f81c3aa60b46 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -417,20 +417,13 @@ struct mlx5e_stats {
417}; 417};
418 418
419static const struct counter_desc mlx5e_pme_status_desc[] = { 419static const struct counter_desc mlx5e_pme_status_desc[] = {
420 { "module_plug", 0 },
421 { "module_unplug", 8 }, 420 { "module_unplug", 8 },
422}; 421};
423 422
424static const struct counter_desc mlx5e_pme_error_desc[] = { 423static const struct counter_desc mlx5e_pme_error_desc[] = {
425 { "module_pwr_budget_exd", 0 }, /* power budget exceed */ 424 { "module_bus_stuck", 16 }, /* bus stuck (I2C or data shorted) */
426 { "module_long_range", 8 }, /* long range for non MLNX cable */ 425 { "module_high_temp", 48 }, /* high temperature */
427 { "module_bus_stuck", 16 }, /* bus stuck (I2C or data shorted) */
428 { "module_no_eeprom", 24 }, /* no eeprom/retry time out */
429 { "module_enforce_part", 32 }, /* enforce part number list */
430 { "module_unknown_id", 40 }, /* unknown identifier */
431 { "module_high_temp", 48 }, /* high temperature */
432 { "module_bad_shorted", 56 }, /* bad or shorted cable/module */ 426 { "module_bad_shorted", 56 }, /* bad or shorted cable/module */
433 { "module_unknown_status", 64 },
434}; 427};
435 428
436#endif /* __MLX5_EN_STATS_H__ */ 429#endif /* __MLX5_EN_STATS_H__ */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 0e487e8ca634..8f5125ccd8d4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -862,7 +862,7 @@ struct mlx5_flow_table *mlx5_create_vport_flow_table(struct mlx5_flow_namespace
862 ft_attr.level = level; 862 ft_attr.level = level;
863 ft_attr.prio = prio; 863 ft_attr.prio = prio;
864 864
865 return __mlx5_create_flow_table(ns, &ft_attr, FS_FT_OP_MOD_NORMAL, 0); 865 return __mlx5_create_flow_table(ns, &ft_attr, FS_FT_OP_MOD_NORMAL, vport);
866} 866}
867 867
868struct mlx5_flow_table* 868struct mlx5_flow_table*
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index 44f59b1d6f0f..f27f84ffbc85 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -275,10 +275,8 @@ static void poll_health(unsigned long data)
275 struct mlx5_core_health *health = &dev->priv.health; 275 struct mlx5_core_health *health = &dev->priv.health;
276 u32 count; 276 u32 count;
277 277
278 if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) { 278 if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)
279 mod_timer(&health->timer, get_next_poll_jiffies()); 279 goto out;
280 return;
281 }
282 280
283 count = ioread32be(health->health_counter); 281 count = ioread32be(health->health_counter);
284 if (count == health->prev) 282 if (count == health->prev)
@@ -290,8 +288,6 @@ static void poll_health(unsigned long data)
290 if (health->miss_counter == MAX_MISSES) { 288 if (health->miss_counter == MAX_MISSES) {
291 dev_err(&dev->pdev->dev, "device's health compromised - reached miss count\n"); 289 dev_err(&dev->pdev->dev, "device's health compromised - reached miss count\n");
292 print_health_info(dev); 290 print_health_info(dev);
293 } else {
294 mod_timer(&health->timer, get_next_poll_jiffies());
295 } 291 }
296 292
297 if (in_fatal(dev) && !health->sick) { 293 if (in_fatal(dev) && !health->sick) {
@@ -305,6 +301,9 @@ static void poll_health(unsigned long data)
305 "new health works are not permitted at this stage\n"); 301 "new health works are not permitted at this stage\n");
306 spin_unlock(&health->wq_lock); 302 spin_unlock(&health->wq_lock);
307 } 303 }
304
305out:
306 mod_timer(&health->timer, get_next_poll_jiffies());
308} 307}
309 308
310void mlx5_start_health_poll(struct mlx5_core_dev *dev) 309void mlx5_start_health_poll(struct mlx5_core_dev *dev)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index af945edfee19..4f577a5abf88 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -537,8 +537,10 @@ static int handle_hca_cap(struct mlx5_core_dev *dev)
537 /* disable cmdif checksum */ 537 /* disable cmdif checksum */
538 MLX5_SET(cmd_hca_cap, set_hca_cap, cmdif_checksum, 0); 538 MLX5_SET(cmd_hca_cap, set_hca_cap, cmdif_checksum, 0);
539 539
540 /* If the HCA supports 4K UARs use it */ 540 /* Enable 4K UAR only when HCA supports it and page size is bigger
541 if (MLX5_CAP_GEN_MAX(dev, uar_4k)) 541 * than 4K.
542 */
543 if (MLX5_CAP_GEN_MAX(dev, uar_4k) && PAGE_SIZE > 4096)
542 MLX5_SET(cmd_hca_cap, set_hca_cap, uar_4k, 1); 544 MLX5_SET(cmd_hca_cap, set_hca_cap, uar_4k, 1);
543 545
544 MLX5_SET(cmd_hca_cap, set_hca_cap, log_uar_page_sz, PAGE_SHIFT - 12); 546 MLX5_SET(cmd_hca_cap, set_hca_cap, log_uar_page_sz, PAGE_SHIFT - 12);
diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c b/drivers/net/ethernet/qlogic/qed/qed_debug.c
index 483241b4b05d..a672f6a860dc 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_debug.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c
@@ -2956,7 +2956,7 @@ static u32 qed_grc_dump_ctx_data(struct qed_hwfn *p_hwfn,
2956 qed_wr(p_hwfn, 2956 qed_wr(p_hwfn,
2957 p_ptt, 2957 p_ptt,
2958 s_storm_defs[storm_id].cm_ctx_wr_addr, 2958 s_storm_defs[storm_id].cm_ctx_wr_addr,
2959 BIT(9) | lid); 2959 (i << 9) | lid);
2960 *(dump_buf + offset) = qed_rd(p_hwfn, 2960 *(dump_buf + offset) = qed_rd(p_hwfn,
2961 p_ptt, 2961 p_ptt,
2962 rd_reg_addr); 2962 rd_reg_addr);
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
index aa6476439aee..e0ef02f9503b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
@@ -214,13 +214,13 @@ static int dwmac4_wrback_get_tx_timestamp_status(struct dma_desc *p)
214{ 214{
215 /* Context type from W/B descriptor must be zero */ 215 /* Context type from W/B descriptor must be zero */
216 if (le32_to_cpu(p->des3) & TDES3_CONTEXT_TYPE) 216 if (le32_to_cpu(p->des3) & TDES3_CONTEXT_TYPE)
217 return -EINVAL; 217 return 0;
218 218
219 /* Tx Timestamp Status is 1 so des0 and des1'll have valid values */ 219 /* Tx Timestamp Status is 1 so des0 and des1'll have valid values */
220 if (le32_to_cpu(p->des3) & TDES3_TIMESTAMP_STATUS) 220 if (le32_to_cpu(p->des3) & TDES3_TIMESTAMP_STATUS)
221 return 0; 221 return 1;
222 222
223 return 1; 223 return 0;
224} 224}
225 225
226static inline u64 dwmac4_get_timestamp(void *desc, u32 ats) 226static inline u64 dwmac4_get_timestamp(void *desc, u32 ats)
@@ -282,7 +282,10 @@ static int dwmac4_wrback_get_rx_timestamp_status(void *desc, u32 ats)
282 } 282 }
283 } 283 }
284exit: 284exit:
285 return ret; 285 if (likely(ret == 0))
286 return 1;
287
288 return 0;
286} 289}
287 290
288static void dwmac4_rd_init_rx_desc(struct dma_desc *p, int disable_rx_ic, 291static void dwmac4_rd_init_rx_desc(struct dma_desc *p, int disable_rx_ic,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 12236daf7bb6..d16d11bfc046 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -434,14 +434,14 @@ static void stmmac_get_tx_hwtstamp(struct stmmac_priv *priv,
434 return; 434 return;
435 435
436 /* check tx tstamp status */ 436 /* check tx tstamp status */
437 if (!priv->hw->desc->get_tx_timestamp_status(p)) { 437 if (priv->hw->desc->get_tx_timestamp_status(p)) {
438 /* get the valid tstamp */ 438 /* get the valid tstamp */
439 ns = priv->hw->desc->get_timestamp(p, priv->adv_ts); 439 ns = priv->hw->desc->get_timestamp(p, priv->adv_ts);
440 440
441 memset(&shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps)); 441 memset(&shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps));
442 shhwtstamp.hwtstamp = ns_to_ktime(ns); 442 shhwtstamp.hwtstamp = ns_to_ktime(ns);
443 443
444 netdev_info(priv->dev, "get valid TX hw timestamp %llu\n", ns); 444 netdev_dbg(priv->dev, "get valid TX hw timestamp %llu\n", ns);
445 /* pass tstamp to stack */ 445 /* pass tstamp to stack */
446 skb_tstamp_tx(skb, &shhwtstamp); 446 skb_tstamp_tx(skb, &shhwtstamp);
447 } 447 }
@@ -468,19 +468,19 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p,
468 return; 468 return;
469 469
470 /* Check if timestamp is available */ 470 /* Check if timestamp is available */
471 if (!priv->hw->desc->get_rx_timestamp_status(p, priv->adv_ts)) { 471 if (priv->hw->desc->get_rx_timestamp_status(p, priv->adv_ts)) {
472 /* For GMAC4, the valid timestamp is from CTX next desc. */ 472 /* For GMAC4, the valid timestamp is from CTX next desc. */
473 if (priv->plat->has_gmac4) 473 if (priv->plat->has_gmac4)
474 ns = priv->hw->desc->get_timestamp(np, priv->adv_ts); 474 ns = priv->hw->desc->get_timestamp(np, priv->adv_ts);
475 else 475 else
476 ns = priv->hw->desc->get_timestamp(p, priv->adv_ts); 476 ns = priv->hw->desc->get_timestamp(p, priv->adv_ts);
477 477
478 netdev_info(priv->dev, "get valid RX hw timestamp %llu\n", ns); 478 netdev_dbg(priv->dev, "get valid RX hw timestamp %llu\n", ns);
479 shhwtstamp = skb_hwtstamps(skb); 479 shhwtstamp = skb_hwtstamps(skb);
480 memset(shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps)); 480 memset(shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps));
481 shhwtstamp->hwtstamp = ns_to_ktime(ns); 481 shhwtstamp->hwtstamp = ns_to_ktime(ns);
482 } else { 482 } else {
483 netdev_err(priv->dev, "cannot get RX hw timestamp\n"); 483 netdev_dbg(priv->dev, "cannot get RX hw timestamp\n");
484 } 484 }
485} 485}
486 486
@@ -546,7 +546,10 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
546 /* PTP v1, UDP, any kind of event packet */ 546 /* PTP v1, UDP, any kind of event packet */
547 config.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT; 547 config.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
548 /* take time stamp for all event messages */ 548 /* take time stamp for all event messages */
549 snap_type_sel = PTP_TCR_SNAPTYPSEL_1; 549 if (priv->plat->has_gmac4)
550 snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1;
551 else
552 snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
550 553
551 ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA; 554 ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA;
552 ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA; 555 ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA;
@@ -578,7 +581,10 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
578 config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT; 581 config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
579 ptp_v2 = PTP_TCR_TSVER2ENA; 582 ptp_v2 = PTP_TCR_TSVER2ENA;
580 /* take time stamp for all event messages */ 583 /* take time stamp for all event messages */
581 snap_type_sel = PTP_TCR_SNAPTYPSEL_1; 584 if (priv->plat->has_gmac4)
585 snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1;
586 else
587 snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
582 588
583 ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA; 589 ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA;
584 ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA; 590 ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA;
@@ -612,7 +618,10 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
612 config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; 618 config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
613 ptp_v2 = PTP_TCR_TSVER2ENA; 619 ptp_v2 = PTP_TCR_TSVER2ENA;
614 /* take time stamp for all event messages */ 620 /* take time stamp for all event messages */
615 snap_type_sel = PTP_TCR_SNAPTYPSEL_1; 621 if (priv->plat->has_gmac4)
622 snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1;
623 else
624 snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
616 625
617 ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA; 626 ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA;
618 ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA; 627 ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h
index 48fb72fc423c..f4b31d69f60e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h
@@ -59,7 +59,8 @@
59/* Enable Snapshot for Messages Relevant to Master */ 59/* Enable Snapshot for Messages Relevant to Master */
60#define PTP_TCR_TSMSTRENA BIT(15) 60#define PTP_TCR_TSMSTRENA BIT(15)
61/* Select PTP packets for Taking Snapshots */ 61/* Select PTP packets for Taking Snapshots */
62#define PTP_TCR_SNAPTYPSEL_1 GENMASK(17, 16) 62#define PTP_TCR_SNAPTYPSEL_1 BIT(16)
63#define PTP_GMAC4_TCR_SNAPTYPSEL_1 GENMASK(17, 16)
63/* Enable MAC address for PTP Frame Filtering */ 64/* Enable MAC address for PTP Frame Filtering */
64#define PTP_TCR_TSENMACADDR BIT(18) 65#define PTP_TCR_TSENMACADDR BIT(18)
65 66
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 6ebb0f559a42..199459bd6961 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -1007,7 +1007,7 @@ static void geneve_setup(struct net_device *dev)
1007 1007
1008 dev->netdev_ops = &geneve_netdev_ops; 1008 dev->netdev_ops = &geneve_netdev_ops;
1009 dev->ethtool_ops = &geneve_ethtool_ops; 1009 dev->ethtool_ops = &geneve_ethtool_ops;
1010 dev->destructor = free_netdev; 1010 dev->needs_free_netdev = true;
1011 1011
1012 SET_NETDEV_DEVTYPE(dev, &geneve_type); 1012 SET_NETDEV_DEVTYPE(dev, &geneve_type);
1013 1013
diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 7b652bb7ebe4..ca110cd2a4e4 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -611,7 +611,7 @@ static const struct net_device_ops gtp_netdev_ops = {
611static void gtp_link_setup(struct net_device *dev) 611static void gtp_link_setup(struct net_device *dev)
612{ 612{
613 dev->netdev_ops = &gtp_netdev_ops; 613 dev->netdev_ops = &gtp_netdev_ops;
614 dev->destructor = free_netdev; 614 dev->needs_free_netdev = true;
615 615
616 dev->hard_header_len = 0; 616 dev->hard_header_len = 0;
617 dev->addr_len = 0; 617 dev->addr_len = 0;
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 922bf440e9f1..021a8ec411ab 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -311,7 +311,7 @@ static void sp_setup(struct net_device *dev)
311{ 311{
312 /* Finish setting up the DEVICE info. */ 312 /* Finish setting up the DEVICE info. */
313 dev->netdev_ops = &sp_netdev_ops; 313 dev->netdev_ops = &sp_netdev_ops;
314 dev->destructor = free_netdev; 314 dev->needs_free_netdev = true;
315 dev->mtu = SIXP_MTU; 315 dev->mtu = SIXP_MTU;
316 dev->hard_header_len = AX25_MAX_HEADER_LEN; 316 dev->hard_header_len = AX25_MAX_HEADER_LEN;
317 dev->header_ops = &ax25_header_ops; 317 dev->header_ops = &ax25_header_ops;
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index f62e7f325cf9..78a6414c5fd9 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -476,7 +476,7 @@ static const struct net_device_ops bpq_netdev_ops = {
476static void bpq_setup(struct net_device *dev) 476static void bpq_setup(struct net_device *dev)
477{ 477{
478 dev->netdev_ops = &bpq_netdev_ops; 478 dev->netdev_ops = &bpq_netdev_ops;
479 dev->destructor = free_netdev; 479 dev->needs_free_netdev = true;
480 480
481 memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN); 481 memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
482 memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN); 482 memcpy(dev->dev_addr, &ax25_defaddr, AX25_ADDR_LEN);
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 262b2ea576a3..6066f1bcaf2d 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -171,6 +171,8 @@ struct rndis_device {
171 spinlock_t request_lock; 171 spinlock_t request_lock;
172 struct list_head req_list; 172 struct list_head req_list;
173 173
174 struct work_struct mcast_work;
175
174 u8 hw_mac_adr[ETH_ALEN]; 176 u8 hw_mac_adr[ETH_ALEN];
175 u8 rss_key[NETVSC_HASH_KEYLEN]; 177 u8 rss_key[NETVSC_HASH_KEYLEN];
176 u16 ind_table[ITAB_NUM]; 178 u16 ind_table[ITAB_NUM];
@@ -201,6 +203,7 @@ int rndis_filter_open(struct netvsc_device *nvdev);
201int rndis_filter_close(struct netvsc_device *nvdev); 203int rndis_filter_close(struct netvsc_device *nvdev);
202int rndis_filter_device_add(struct hv_device *dev, 204int rndis_filter_device_add(struct hv_device *dev,
203 struct netvsc_device_info *info); 205 struct netvsc_device_info *info);
206void rndis_filter_update(struct netvsc_device *nvdev);
204void rndis_filter_device_remove(struct hv_device *dev, 207void rndis_filter_device_remove(struct hv_device *dev,
205 struct netvsc_device *nvdev); 208 struct netvsc_device *nvdev);
206int rndis_filter_set_rss_param(struct rndis_device *rdev, 209int rndis_filter_set_rss_param(struct rndis_device *rdev,
@@ -211,7 +214,6 @@ int rndis_filter_receive(struct net_device *ndev,
211 struct vmbus_channel *channel, 214 struct vmbus_channel *channel,
212 void *data, u32 buflen); 215 void *data, u32 buflen);
213 216
214int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);
215int rndis_filter_set_device_mac(struct net_device *ndev, char *mac); 217int rndis_filter_set_device_mac(struct net_device *ndev, char *mac);
216 218
217void netvsc_switch_datapath(struct net_device *nv_dev, bool vf); 219void netvsc_switch_datapath(struct net_device *nv_dev, bool vf);
@@ -696,7 +698,6 @@ struct net_device_context {
696 /* list protection */ 698 /* list protection */
697 spinlock_t lock; 699 spinlock_t lock;
698 700
699 struct work_struct work;
700 u32 msg_enable; /* debug level */ 701 u32 msg_enable; /* debug level */
701 702
702 u32 tx_checksum_mask; 703 u32 tx_checksum_mask;
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 4421a6d00375..82d6c022ca85 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -56,37 +56,12 @@ static int debug = -1;
56module_param(debug, int, S_IRUGO); 56module_param(debug, int, S_IRUGO);
57MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); 57MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
58 58
59static void do_set_multicast(struct work_struct *w)
60{
61 struct net_device_context *ndevctx =
62 container_of(w, struct net_device_context, work);
63 struct hv_device *device_obj = ndevctx->device_ctx;
64 struct net_device *ndev = hv_get_drvdata(device_obj);
65 struct netvsc_device *nvdev = rcu_dereference(ndevctx->nvdev);
66 struct rndis_device *rdev;
67
68 if (!nvdev)
69 return;
70
71 rdev = nvdev->extension;
72 if (rdev == NULL)
73 return;
74
75 if (ndev->flags & IFF_PROMISC)
76 rndis_filter_set_packet_filter(rdev,
77 NDIS_PACKET_TYPE_PROMISCUOUS);
78 else
79 rndis_filter_set_packet_filter(rdev,
80 NDIS_PACKET_TYPE_BROADCAST |
81 NDIS_PACKET_TYPE_ALL_MULTICAST |
82 NDIS_PACKET_TYPE_DIRECTED);
83}
84
85static void netvsc_set_multicast_list(struct net_device *net) 59static void netvsc_set_multicast_list(struct net_device *net)
86{ 60{
87 struct net_device_context *net_device_ctx = netdev_priv(net); 61 struct net_device_context *net_device_ctx = netdev_priv(net);
62 struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev);
88 63
89 schedule_work(&net_device_ctx->work); 64 rndis_filter_update(nvdev);
90} 65}
91 66
92static int netvsc_open(struct net_device *net) 67static int netvsc_open(struct net_device *net)
@@ -123,8 +98,6 @@ static int netvsc_close(struct net_device *net)
123 98
124 netif_tx_disable(net); 99 netif_tx_disable(net);
125 100
126 /* Make sure netvsc_set_multicast_list doesn't re-enable filter! */
127 cancel_work_sync(&net_device_ctx->work);
128 ret = rndis_filter_close(nvdev); 101 ret = rndis_filter_close(nvdev);
129 if (ret != 0) { 102 if (ret != 0) {
130 netdev_err(net, "unable to close device (ret %d).\n", ret); 103 netdev_err(net, "unable to close device (ret %d).\n", ret);
@@ -1028,7 +1001,7 @@ static const struct {
1028static int netvsc_get_sset_count(struct net_device *dev, int string_set) 1001static int netvsc_get_sset_count(struct net_device *dev, int string_set)
1029{ 1002{
1030 struct net_device_context *ndc = netdev_priv(dev); 1003 struct net_device_context *ndc = netdev_priv(dev);
1031 struct netvsc_device *nvdev = rcu_dereference(ndc->nvdev); 1004 struct netvsc_device *nvdev = rtnl_dereference(ndc->nvdev);
1032 1005
1033 if (!nvdev) 1006 if (!nvdev)
1034 return -ENODEV; 1007 return -ENODEV;
@@ -1158,11 +1131,22 @@ netvsc_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
1158} 1131}
1159 1132
1160#ifdef CONFIG_NET_POLL_CONTROLLER 1133#ifdef CONFIG_NET_POLL_CONTROLLER
1161static void netvsc_poll_controller(struct net_device *net) 1134static void netvsc_poll_controller(struct net_device *dev)
1162{ 1135{
1163 /* As netvsc_start_xmit() works synchronous we don't have to 1136 struct net_device_context *ndc = netdev_priv(dev);
1164 * trigger anything here. 1137 struct netvsc_device *ndev;
1165 */ 1138 int i;
1139
1140 rcu_read_lock();
1141 ndev = rcu_dereference(ndc->nvdev);
1142 if (ndev) {
1143 for (i = 0; i < ndev->num_chn; i++) {
1144 struct netvsc_channel *nvchan = &ndev->chan_table[i];
1145
1146 napi_schedule(&nvchan->napi);
1147 }
1148 }
1149 rcu_read_unlock();
1166} 1150}
1167#endif 1151#endif
1168 1152
@@ -1552,7 +1536,6 @@ static int netvsc_probe(struct hv_device *dev,
1552 hv_set_drvdata(dev, net); 1536 hv_set_drvdata(dev, net);
1553 1537
1554 INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change); 1538 INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change);
1555 INIT_WORK(&net_device_ctx->work, do_set_multicast);
1556 1539
1557 spin_lock_init(&net_device_ctx->lock); 1540 spin_lock_init(&net_device_ctx->lock);
1558 INIT_LIST_HEAD(&net_device_ctx->reconfig_events); 1541 INIT_LIST_HEAD(&net_device_ctx->reconfig_events);
@@ -1622,7 +1605,6 @@ static int netvsc_remove(struct hv_device *dev)
1622 netif_device_detach(net); 1605 netif_device_detach(net);
1623 1606
1624 cancel_delayed_work_sync(&ndev_ctx->dwork); 1607 cancel_delayed_work_sync(&ndev_ctx->dwork);
1625 cancel_work_sync(&ndev_ctx->work);
1626 1608
1627 /* 1609 /*
1628 * Call to the vsc driver to let it know that the device is being 1610 * Call to the vsc driver to let it know that the device is being
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index f9d5b0b8209a..cb79cd081f42 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -31,6 +31,7 @@
31 31
32#include "hyperv_net.h" 32#include "hyperv_net.h"
33 33
34static void rndis_set_multicast(struct work_struct *w);
34 35
35#define RNDIS_EXT_LEN PAGE_SIZE 36#define RNDIS_EXT_LEN PAGE_SIZE
36struct rndis_request { 37struct rndis_request {
@@ -76,6 +77,7 @@ static struct rndis_device *get_rndis_device(void)
76 spin_lock_init(&device->request_lock); 77 spin_lock_init(&device->request_lock);
77 78
78 INIT_LIST_HEAD(&device->req_list); 79 INIT_LIST_HEAD(&device->req_list);
80 INIT_WORK(&device->mcast_work, rndis_set_multicast);
79 81
80 device->state = RNDIS_DEV_UNINITIALIZED; 82 device->state = RNDIS_DEV_UNINITIALIZED;
81 83
@@ -815,7 +817,8 @@ static int rndis_filter_query_link_speed(struct rndis_device *dev)
815 return ret; 817 return ret;
816} 818}
817 819
818int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter) 820static int rndis_filter_set_packet_filter(struct rndis_device *dev,
821 u32 new_filter)
819{ 822{
820 struct rndis_request *request; 823 struct rndis_request *request;
821 struct rndis_set_request *set; 824 struct rndis_set_request *set;
@@ -846,6 +849,28 @@ int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter)
846 return ret; 849 return ret;
847} 850}
848 851
852static void rndis_set_multicast(struct work_struct *w)
853{
854 struct rndis_device *rdev
855 = container_of(w, struct rndis_device, mcast_work);
856
857 if (rdev->ndev->flags & IFF_PROMISC)
858 rndis_filter_set_packet_filter(rdev,
859 NDIS_PACKET_TYPE_PROMISCUOUS);
860 else
861 rndis_filter_set_packet_filter(rdev,
862 NDIS_PACKET_TYPE_BROADCAST |
863 NDIS_PACKET_TYPE_ALL_MULTICAST |
864 NDIS_PACKET_TYPE_DIRECTED);
865}
866
867void rndis_filter_update(struct netvsc_device *nvdev)
868{
869 struct rndis_device *rdev = nvdev->extension;
870
871 schedule_work(&rdev->mcast_work);
872}
873
849static int rndis_filter_init_device(struct rndis_device *dev) 874static int rndis_filter_init_device(struct rndis_device *dev)
850{ 875{
851 struct rndis_request *request; 876 struct rndis_request *request;
@@ -973,6 +998,9 @@ static int rndis_filter_close_device(struct rndis_device *dev)
973 if (dev->state != RNDIS_DEV_DATAINITIALIZED) 998 if (dev->state != RNDIS_DEV_DATAINITIALIZED)
974 return 0; 999 return 0;
975 1000
1001 /* Make sure rndis_set_multicast doesn't re-enable filter! */
1002 cancel_work_sync(&dev->mcast_work);
1003
976 ret = rndis_filter_set_packet_filter(dev, 0); 1004 ret = rndis_filter_set_packet_filter(dev, 0);
977 if (ret == -ENODEV) 1005 if (ret == -ENODEV)
978 ret = 0; 1006 ret = 0;
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 312fce7302d3..144ea5ae8ab4 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -207,7 +207,6 @@ static void ifb_dev_free(struct net_device *dev)
207 __skb_queue_purge(&txp->tq); 207 __skb_queue_purge(&txp->tq);
208 } 208 }
209 kfree(dp->tx_private); 209 kfree(dp->tx_private);
210 free_netdev(dev);
211} 210}
212 211
213static void ifb_setup(struct net_device *dev) 212static void ifb_setup(struct net_device *dev)
@@ -230,7 +229,8 @@ static void ifb_setup(struct net_device *dev)
230 dev->priv_flags &= ~IFF_TX_SKB_SHARING; 229 dev->priv_flags &= ~IFF_TX_SKB_SHARING;
231 netif_keep_dst(dev); 230 netif_keep_dst(dev);
232 eth_hw_addr_random(dev); 231 eth_hw_addr_random(dev);
233 dev->destructor = ifb_dev_free; 232 dev->needs_free_netdev = true;
233 dev->priv_destructor = ifb_dev_free;
234} 234}
235 235
236static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev) 236static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev)
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 618ed88fad0f..7c7680c8f0e3 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -632,7 +632,7 @@ void ipvlan_link_setup(struct net_device *dev)
632 dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); 632 dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
633 dev->priv_flags |= IFF_UNICAST_FLT | IFF_NO_QUEUE; 633 dev->priv_flags |= IFF_UNICAST_FLT | IFF_NO_QUEUE;
634 dev->netdev_ops = &ipvlan_netdev_ops; 634 dev->netdev_ops = &ipvlan_netdev_ops;
635 dev->destructor = free_netdev; 635 dev->needs_free_netdev = true;
636 dev->header_ops = &ipvlan_header_ops; 636 dev->header_ops = &ipvlan_header_ops;
637 dev->ethtool_ops = &ipvlan_ethtool_ops; 637 dev->ethtool_ops = &ipvlan_ethtool_ops;
638} 638}
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 224f65cb576b..30612497643c 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -159,7 +159,6 @@ static void loopback_dev_free(struct net_device *dev)
159{ 159{
160 dev_net(dev)->loopback_dev = NULL; 160 dev_net(dev)->loopback_dev = NULL;
161 free_percpu(dev->lstats); 161 free_percpu(dev->lstats);
162 free_netdev(dev);
163} 162}
164 163
165static const struct net_device_ops loopback_ops = { 164static const struct net_device_ops loopback_ops = {
@@ -196,7 +195,8 @@ static void loopback_setup(struct net_device *dev)
196 dev->ethtool_ops = &loopback_ethtool_ops; 195 dev->ethtool_ops = &loopback_ethtool_ops;
197 dev->header_ops = &eth_header_ops; 196 dev->header_ops = &eth_header_ops;
198 dev->netdev_ops = &loopback_ops; 197 dev->netdev_ops = &loopback_ops;
199 dev->destructor = loopback_dev_free; 198 dev->needs_free_netdev = true;
199 dev->priv_destructor = loopback_dev_free;
200} 200}
201 201
202/* Setup and register the loopback device. */ 202/* Setup and register the loopback device. */
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index cdc347be68f2..79411675f0e6 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -2996,7 +2996,6 @@ static void macsec_free_netdev(struct net_device *dev)
2996 free_percpu(macsec->secy.tx_sc.stats); 2996 free_percpu(macsec->secy.tx_sc.stats);
2997 2997
2998 dev_put(real_dev); 2998 dev_put(real_dev);
2999 free_netdev(dev);
3000} 2999}
3001 3000
3002static void macsec_setup(struct net_device *dev) 3001static void macsec_setup(struct net_device *dev)
@@ -3006,7 +3005,8 @@ static void macsec_setup(struct net_device *dev)
3006 dev->max_mtu = ETH_MAX_MTU; 3005 dev->max_mtu = ETH_MAX_MTU;
3007 dev->priv_flags |= IFF_NO_QUEUE; 3006 dev->priv_flags |= IFF_NO_QUEUE;
3008 dev->netdev_ops = &macsec_netdev_ops; 3007 dev->netdev_ops = &macsec_netdev_ops;
3009 dev->destructor = macsec_free_netdev; 3008 dev->needs_free_netdev = true;
3009 dev->priv_destructor = macsec_free_netdev;
3010 SET_NETDEV_DEVTYPE(dev, &macsec_type); 3010 SET_NETDEV_DEVTYPE(dev, &macsec_type);
3011 3011
3012 eth_zero_addr(dev->broadcast); 3012 eth_zero_addr(dev->broadcast);
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 346ad2ff3998..67bf7ebae5c6 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -1092,7 +1092,7 @@ void macvlan_common_setup(struct net_device *dev)
1092 netif_keep_dst(dev); 1092 netif_keep_dst(dev);
1093 dev->priv_flags |= IFF_UNICAST_FLT; 1093 dev->priv_flags |= IFF_UNICAST_FLT;
1094 dev->netdev_ops = &macvlan_netdev_ops; 1094 dev->netdev_ops = &macvlan_netdev_ops;
1095 dev->destructor = free_netdev; 1095 dev->needs_free_netdev = true;
1096 dev->header_ops = &macvlan_hard_header_ops; 1096 dev->header_ops = &macvlan_hard_header_ops;
1097 dev->ethtool_ops = &macvlan_ethtool_ops; 1097 dev->ethtool_ops = &macvlan_ethtool_ops;
1098} 1098}
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 06ee6395117f..0e27920c2b6b 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -358,7 +358,7 @@ static ssize_t enabled_store(struct config_item *item,
358 if (err) 358 if (err)
359 goto out_unlock; 359 goto out_unlock;
360 360
361 pr_info("netconsole: network logging started\n"); 361 pr_info("network logging started\n");
362 } else { /* false */ 362 } else { /* false */
363 /* We need to disable the netconsole before cleaning it up 363 /* We need to disable the netconsole before cleaning it up
364 * otherwise we might end up in write_msg() with 364 * otherwise we might end up in write_msg() with
diff --git a/drivers/net/nlmon.c b/drivers/net/nlmon.c
index b91603835d26..c4b3362da4a2 100644
--- a/drivers/net/nlmon.c
+++ b/drivers/net/nlmon.c
@@ -113,7 +113,7 @@ static void nlmon_setup(struct net_device *dev)
113 113
114 dev->netdev_ops = &nlmon_ops; 114 dev->netdev_ops = &nlmon_ops;
115 dev->ethtool_ops = &nlmon_ethtool_ops; 115 dev->ethtool_ops = &nlmon_ethtool_ops;
116 dev->destructor = free_netdev; 116 dev->needs_free_netdev = true;
117 117
118 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | 118 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST |
119 NETIF_F_HIGHDMA | NETIF_F_LLTX; 119 NETIF_F_HIGHDMA | NETIF_F_LLTX;
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index c360dd6ead22..3ab6c58d4be6 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -127,6 +127,7 @@ config MDIO_THUNDER
127 tristate "ThunderX SOCs MDIO buses" 127 tristate "ThunderX SOCs MDIO buses"
128 depends on 64BIT 128 depends on 64BIT
129 depends on PCI 129 depends on PCI
130 depends on !(MDIO_DEVICE=y && PHYLIB=m)
130 select MDIO_CAVIUM 131 select MDIO_CAVIUM
131 help 132 help
132 This driver supports the MDIO interfaces found on Cavium 133 This driver supports the MDIO interfaces found on Cavium
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 7524caa0f29d..eebb0e1c70ff 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -54,6 +54,8 @@ static const char *phy_speed_to_str(int speed)
54 return "5Gbps"; 54 return "5Gbps";
55 case SPEED_10000: 55 case SPEED_10000:
56 return "10Gbps"; 56 return "10Gbps";
57 case SPEED_14000:
58 return "14Gbps";
57 case SPEED_20000: 59 case SPEED_20000:
58 return "20Gbps"; 60 return "20Gbps";
59 case SPEED_25000: 61 case SPEED_25000:
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index 1da31dc47f86..74b907206aa7 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -629,7 +629,7 @@ static void sl_uninit(struct net_device *dev)
629static void sl_free_netdev(struct net_device *dev) 629static void sl_free_netdev(struct net_device *dev)
630{ 630{
631 int i = dev->base_addr; 631 int i = dev->base_addr;
632 free_netdev(dev); 632
633 slip_devs[i] = NULL; 633 slip_devs[i] = NULL;
634} 634}
635 635
@@ -651,7 +651,8 @@ static const struct net_device_ops sl_netdev_ops = {
651static void sl_setup(struct net_device *dev) 651static void sl_setup(struct net_device *dev)
652{ 652{
653 dev->netdev_ops = &sl_netdev_ops; 653 dev->netdev_ops = &sl_netdev_ops;
654 dev->destructor = sl_free_netdev; 654 dev->needs_free_netdev = true;
655 dev->priv_destructor = sl_free_netdev;
655 656
656 dev->hard_header_len = 0; 657 dev->hard_header_len = 0;
657 dev->addr_len = 0; 658 dev->addr_len = 0;
@@ -1369,8 +1370,6 @@ static void __exit slip_exit(void)
1369 if (sl->tty) { 1370 if (sl->tty) {
1370 printk(KERN_ERR "%s: tty discipline still running\n", 1371 printk(KERN_ERR "%s: tty discipline still running\n",
1371 dev->name); 1372 dev->name);
1372 /* Intentionally leak the control block. */
1373 dev->destructor = NULL;
1374 } 1373 }
1375 1374
1376 unregister_netdev(dev); 1375 unregister_netdev(dev);
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 6c5d5ef46f75..fba8c136aa7c 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1643,7 +1643,6 @@ static void team_destructor(struct net_device *dev)
1643 struct team *team = netdev_priv(dev); 1643 struct team *team = netdev_priv(dev);
1644 1644
1645 free_percpu(team->pcpu_stats); 1645 free_percpu(team->pcpu_stats);
1646 free_netdev(dev);
1647} 1646}
1648 1647
1649static int team_open(struct net_device *dev) 1648static int team_open(struct net_device *dev)
@@ -2079,7 +2078,8 @@ static void team_setup(struct net_device *dev)
2079 2078
2080 dev->netdev_ops = &team_netdev_ops; 2079 dev->netdev_ops = &team_netdev_ops;
2081 dev->ethtool_ops = &team_ethtool_ops; 2080 dev->ethtool_ops = &team_ethtool_ops;
2082 dev->destructor = team_destructor; 2081 dev->needs_free_netdev = true;
2082 dev->priv_destructor = team_destructor;
2083 dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); 2083 dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
2084 dev->priv_flags |= IFF_NO_QUEUE; 2084 dev->priv_flags |= IFF_NO_QUEUE;
2085 dev->priv_flags |= IFF_TEAM; 2085 dev->priv_flags |= IFF_TEAM;
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index bbd707b9ef7a..9ee7d4275640 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1560,7 +1560,6 @@ static void tun_free_netdev(struct net_device *dev)
1560 free_percpu(tun->pcpu_stats); 1560 free_percpu(tun->pcpu_stats);
1561 tun_flow_uninit(tun); 1561 tun_flow_uninit(tun);
1562 security_tun_dev_free_security(tun->security); 1562 security_tun_dev_free_security(tun->security);
1563 free_netdev(dev);
1564} 1563}
1565 1564
1566static void tun_setup(struct net_device *dev) 1565static void tun_setup(struct net_device *dev)
@@ -1571,7 +1570,8 @@ static void tun_setup(struct net_device *dev)
1571 tun->group = INVALID_GID; 1570 tun->group = INVALID_GID;
1572 1571
1573 dev->ethtool_ops = &tun_ethtool_ops; 1572 dev->ethtool_ops = &tun_ethtool_ops;
1574 dev->destructor = tun_free_netdev; 1573 dev->needs_free_netdev = true;
1574 dev->priv_destructor = tun_free_netdev;
1575 /* We prefer our own queue length */ 1575 /* We prefer our own queue length */
1576 dev->tx_queue_len = TUN_READQ_SIZE; 1576 dev->tx_queue_len = TUN_READQ_SIZE;
1577} 1577}
diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c
index eb52de8205f0..c7a350bbaaa7 100644
--- a/drivers/net/usb/cdc-phonet.c
+++ b/drivers/net/usb/cdc-phonet.c
@@ -298,7 +298,7 @@ static void usbpn_setup(struct net_device *dev)
298 dev->addr_len = 1; 298 dev->addr_len = 1;
299 dev->tx_queue_len = 3; 299 dev->tx_queue_len = 3;
300 300
301 dev->destructor = free_netdev; 301 dev->needs_free_netdev = true;
302} 302}
303 303
304/* 304/*
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 8f923a147fa9..32a22f4e8356 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -123,7 +123,7 @@ static void qmimux_setup(struct net_device *dev)
123 dev->addr_len = 0; 123 dev->addr_len = 0;
124 dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; 124 dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
125 dev->netdev_ops = &qmimux_netdev_ops; 125 dev->netdev_ops = &qmimux_netdev_ops;
126 dev->destructor = free_netdev; 126 dev->needs_free_netdev = true;
127} 127}
128 128
129static struct net_device *qmimux_find_dev(struct usbnet *dev, u8 mux_id) 129static struct net_device *qmimux_find_dev(struct usbnet *dev, u8 mux_id)
@@ -1192,6 +1192,8 @@ static const struct usb_device_id products[] = {
1192 {QMI_FIXED_INTF(0x1199, 0x9056, 8)}, /* Sierra Wireless Modem */ 1192 {QMI_FIXED_INTF(0x1199, 0x9056, 8)}, /* Sierra Wireless Modem */
1193 {QMI_FIXED_INTF(0x1199, 0x9057, 8)}, 1193 {QMI_FIXED_INTF(0x1199, 0x9057, 8)},
1194 {QMI_FIXED_INTF(0x1199, 0x9061, 8)}, /* Sierra Wireless Modem */ 1194 {QMI_FIXED_INTF(0x1199, 0x9061, 8)}, /* Sierra Wireless Modem */
1195 {QMI_FIXED_INTF(0x1199, 0x9063, 8)}, /* Sierra Wireless EM7305 */
1196 {QMI_FIXED_INTF(0x1199, 0x9063, 10)}, /* Sierra Wireless EM7305 */
1195 {QMI_FIXED_INTF(0x1199, 0x9071, 8)}, /* Sierra Wireless MC74xx */ 1197 {QMI_FIXED_INTF(0x1199, 0x9071, 8)}, /* Sierra Wireless MC74xx */
1196 {QMI_FIXED_INTF(0x1199, 0x9071, 10)}, /* Sierra Wireless MC74xx */ 1198 {QMI_FIXED_INTF(0x1199, 0x9071, 10)}, /* Sierra Wireless MC74xx */
1197 {QMI_FIXED_INTF(0x1199, 0x9079, 8)}, /* Sierra Wireless EM74xx */ 1199 {QMI_FIXED_INTF(0x1199, 0x9079, 8)}, /* Sierra Wireless EM74xx */
@@ -1206,6 +1208,8 @@ static const struct usb_device_id products[] = {
1206 {QMI_FIXED_INTF(0x1bc7, 0x1100, 3)}, /* Telit ME910 */ 1208 {QMI_FIXED_INTF(0x1bc7, 0x1100, 3)}, /* Telit ME910 */
1207 {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ 1209 {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */
1208 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */ 1210 {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */
1211 {QMI_FIXED_INTF(0x1c9e, 0x9801, 3)}, /* Telewell TW-3G HSPA+ */
1212 {QMI_FIXED_INTF(0x1c9e, 0x9803, 4)}, /* Telewell TW-3G HSPA+ */
1209 {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ 1213 {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */
1210 {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */ 1214 {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */
1211 {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */ 1215 {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index ddc62cb69be8..1a419a45e2a2 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -4368,6 +4368,8 @@ static u8 rtl_get_version(struct usb_interface *intf)
4368 break; 4368 break;
4369 } 4369 }
4370 4370
4371 dev_dbg(&intf->dev, "Detected version 0x%04x\n", version);
4372
4371 return version; 4373 return version;
4372} 4374}
4373 4375
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 38f0f03a29c8..0156fe8cac17 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -222,7 +222,6 @@ static int veth_dev_init(struct net_device *dev)
222static void veth_dev_free(struct net_device *dev) 222static void veth_dev_free(struct net_device *dev)
223{ 223{
224 free_percpu(dev->vstats); 224 free_percpu(dev->vstats);
225 free_netdev(dev);
226} 225}
227 226
228#ifdef CONFIG_NET_POLL_CONTROLLER 227#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -317,7 +316,8 @@ static void veth_setup(struct net_device *dev)
317 NETIF_F_HW_VLAN_STAG_TX | 316 NETIF_F_HW_VLAN_STAG_TX |
318 NETIF_F_HW_VLAN_CTAG_RX | 317 NETIF_F_HW_VLAN_CTAG_RX |
319 NETIF_F_HW_VLAN_STAG_RX); 318 NETIF_F_HW_VLAN_STAG_RX);
320 dev->destructor = veth_dev_free; 319 dev->needs_free_netdev = true;
320 dev->priv_destructor = veth_dev_free;
321 dev->max_mtu = ETH_MAX_MTU; 321 dev->max_mtu = ETH_MAX_MTU;
322 322
323 dev->hw_features = VETH_FEATURES; 323 dev->hw_features = VETH_FEATURES;
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index db882493875c..022c0b5f9844 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -36,12 +36,14 @@
36#include <net/addrconf.h> 36#include <net/addrconf.h>
37#include <net/l3mdev.h> 37#include <net/l3mdev.h>
38#include <net/fib_rules.h> 38#include <net/fib_rules.h>
39#include <net/netns/generic.h>
39 40
40#define DRV_NAME "vrf" 41#define DRV_NAME "vrf"
41#define DRV_VERSION "1.0" 42#define DRV_VERSION "1.0"
42 43
43#define FIB_RULE_PREF 1000 /* default preference for FIB rules */ 44#define FIB_RULE_PREF 1000 /* default preference for FIB rules */
44static bool add_fib_rules = true; 45
46static unsigned int vrf_net_id;
45 47
46struct net_vrf { 48struct net_vrf {
47 struct rtable __rcu *rth; 49 struct rtable __rcu *rth;
@@ -1348,7 +1350,7 @@ static void vrf_setup(struct net_device *dev)
1348 dev->netdev_ops = &vrf_netdev_ops; 1350 dev->netdev_ops = &vrf_netdev_ops;
1349 dev->l3mdev_ops = &vrf_l3mdev_ops; 1351 dev->l3mdev_ops = &vrf_l3mdev_ops;
1350 dev->ethtool_ops = &vrf_ethtool_ops; 1352 dev->ethtool_ops = &vrf_ethtool_ops;
1351 dev->destructor = free_netdev; 1353 dev->needs_free_netdev = true;
1352 1354
1353 /* Fill in device structure with ethernet-generic values. */ 1355 /* Fill in device structure with ethernet-generic values. */
1354 eth_hw_addr_random(dev); 1356 eth_hw_addr_random(dev);
@@ -1394,6 +1396,8 @@ static int vrf_newlink(struct net *src_net, struct net_device *dev,
1394 struct nlattr *tb[], struct nlattr *data[]) 1396 struct nlattr *tb[], struct nlattr *data[])
1395{ 1397{
1396 struct net_vrf *vrf = netdev_priv(dev); 1398 struct net_vrf *vrf = netdev_priv(dev);
1399 bool *add_fib_rules;
1400 struct net *net;
1397 int err; 1401 int err;
1398 1402
1399 if (!data || !data[IFLA_VRF_TABLE]) 1403 if (!data || !data[IFLA_VRF_TABLE])
@@ -1409,13 +1413,15 @@ static int vrf_newlink(struct net *src_net, struct net_device *dev,
1409 if (err) 1413 if (err)
1410 goto out; 1414 goto out;
1411 1415
1412 if (add_fib_rules) { 1416 net = dev_net(dev);
1417 add_fib_rules = net_generic(net, vrf_net_id);
1418 if (*add_fib_rules) {
1413 err = vrf_add_fib_rules(dev); 1419 err = vrf_add_fib_rules(dev);
1414 if (err) { 1420 if (err) {
1415 unregister_netdevice(dev); 1421 unregister_netdevice(dev);
1416 goto out; 1422 goto out;
1417 } 1423 }
1418 add_fib_rules = false; 1424 *add_fib_rules = false;
1419 } 1425 }
1420 1426
1421out: 1427out:
@@ -1498,16 +1504,38 @@ static struct notifier_block vrf_notifier_block __read_mostly = {
1498 .notifier_call = vrf_device_event, 1504 .notifier_call = vrf_device_event,
1499}; 1505};
1500 1506
1507/* Initialize per network namespace state */
1508static int __net_init vrf_netns_init(struct net *net)
1509{
1510 bool *add_fib_rules = net_generic(net, vrf_net_id);
1511
1512 *add_fib_rules = true;
1513
1514 return 0;
1515}
1516
1517static struct pernet_operations vrf_net_ops __net_initdata = {
1518 .init = vrf_netns_init,
1519 .id = &vrf_net_id,
1520 .size = sizeof(bool),
1521};
1522
1501static int __init vrf_init_module(void) 1523static int __init vrf_init_module(void)
1502{ 1524{
1503 int rc; 1525 int rc;
1504 1526
1505 register_netdevice_notifier(&vrf_notifier_block); 1527 register_netdevice_notifier(&vrf_notifier_block);
1506 1528
1507 rc = rtnl_link_register(&vrf_link_ops); 1529 rc = register_pernet_subsys(&vrf_net_ops);
1508 if (rc < 0) 1530 if (rc < 0)
1509 goto error; 1531 goto error;
1510 1532
1533 rc = rtnl_link_register(&vrf_link_ops);
1534 if (rc < 0) {
1535 unregister_pernet_subsys(&vrf_net_ops);
1536 goto error;
1537 }
1538
1511 return 0; 1539 return 0;
1512 1540
1513error: 1541error:
diff --git a/drivers/net/vsockmon.c b/drivers/net/vsockmon.c
index 7f0136f2dd9d..c28bdce14fd5 100644
--- a/drivers/net/vsockmon.c
+++ b/drivers/net/vsockmon.c
@@ -135,7 +135,7 @@ static void vsockmon_setup(struct net_device *dev)
135 135
136 dev->netdev_ops = &vsockmon_ops; 136 dev->netdev_ops = &vsockmon_ops;
137 dev->ethtool_ops = &vsockmon_ethtool_ops; 137 dev->ethtool_ops = &vsockmon_ethtool_ops;
138 dev->destructor = free_netdev; 138 dev->needs_free_netdev = true;
139 139
140 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | 140 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST |
141 NETIF_F_HIGHDMA | NETIF_F_LLTX; 141 NETIF_F_HIGHDMA | NETIF_F_LLTX;
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index a6b5052c1d36..5fa798a5c9a6 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2611,7 +2611,7 @@ static void vxlan_setup(struct net_device *dev)
2611 eth_hw_addr_random(dev); 2611 eth_hw_addr_random(dev);
2612 ether_setup(dev); 2612 ether_setup(dev);
2613 2613
2614 dev->destructor = free_netdev; 2614 dev->needs_free_netdev = true;
2615 SET_NETDEV_DEVTYPE(dev, &vxlan_type); 2615 SET_NETDEV_DEVTYPE(dev, &vxlan_type);
2616 2616
2617 dev->features |= NETIF_F_LLTX; 2617 dev->features |= NETIF_F_LLTX;
diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c
index 65ee2a6f248c..a0d76f70c428 100644
--- a/drivers/net/wan/dlci.c
+++ b/drivers/net/wan/dlci.c
@@ -475,7 +475,7 @@ static void dlci_setup(struct net_device *dev)
475 dev->flags = 0; 475 dev->flags = 0;
476 dev->header_ops = &dlci_header_ops; 476 dev->header_ops = &dlci_header_ops;
477 dev->netdev_ops = &dlci_netdev_ops; 477 dev->netdev_ops = &dlci_netdev_ops;
478 dev->destructor = free_netdev; 478 dev->needs_free_netdev = true;
479 479
480 dlp->receive = dlci_receive; 480 dlp->receive = dlci_receive;
481 481
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index eb915281197e..78596e42a3f3 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -1106,7 +1106,7 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
1106 return -EIO; 1106 return -EIO;
1107 } 1107 }
1108 1108
1109 dev->destructor = free_netdev; 1109 dev->needs_free_netdev = true;
1110 *get_dev_p(pvc, type) = dev; 1110 *get_dev_p(pvc, type) = dev;
1111 if (!used) { 1111 if (!used) {
1112 state(hdlc)->dce_changed = 1; 1112 state(hdlc)->dce_changed = 1;
diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index 9df9ed62beff..63f749078a1f 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -306,7 +306,7 @@ static const struct net_device_ops lapbeth_netdev_ops = {
306static void lapbeth_setup(struct net_device *dev) 306static void lapbeth_setup(struct net_device *dev)
307{ 307{
308 dev->netdev_ops = &lapbeth_netdev_ops; 308 dev->netdev_ops = &lapbeth_netdev_ops;
309 dev->destructor = free_netdev; 309 dev->needs_free_netdev = true;
310 dev->type = ARPHRD_X25; 310 dev->type = ARPHRD_X25;
311 dev->hard_header_len = 3; 311 dev->hard_header_len = 3;
312 dev->mtu = 1000; 312 dev->mtu = 1000;
diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c
index 91ee542de3d7..b90c77ef792e 100644
--- a/drivers/net/wireless/ath/ath6kl/main.c
+++ b/drivers/net/wireless/ath/ath6kl/main.c
@@ -1287,7 +1287,7 @@ void init_netdev(struct net_device *dev)
1287 struct ath6kl *ar = ath6kl_priv(dev); 1287 struct ath6kl *ar = ath6kl_priv(dev);
1288 1288
1289 dev->netdev_ops = &ath6kl_netdev_ops; 1289 dev->netdev_ops = &ath6kl_netdev_ops;
1290 dev->destructor = free_netdev; 1290 dev->needs_free_netdev = true;
1291 dev->watchdog_timeo = ATH6KL_TX_TIMEOUT; 1291 dev->watchdog_timeo = ATH6KL_TX_TIMEOUT;
1292 1292
1293 dev->needed_headroom = ETH_HLEN; 1293 dev->needed_headroom = ETH_HLEN;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index cd1d6730eab7..617199c0e5a0 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -5225,7 +5225,6 @@ void brcmf_cfg80211_free_netdev(struct net_device *ndev)
5225 5225
5226 if (vif) 5226 if (vif)
5227 brcmf_free_vif(vif); 5227 brcmf_free_vif(vif);
5228 free_netdev(ndev);
5229} 5228}
5230 5229
5231static bool brcmf_is_linkup(const struct brcmf_event_msg *e) 5230static bool brcmf_is_linkup(const struct brcmf_event_msg *e)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index a3d82368f1a9..511d190c6cca 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -624,7 +624,8 @@ struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bsscfgidx, s32 ifidx,
624 if (!ndev) 624 if (!ndev)
625 return ERR_PTR(-ENOMEM); 625 return ERR_PTR(-ENOMEM);
626 626
627 ndev->destructor = brcmf_cfg80211_free_netdev; 627 ndev->needs_free_netdev = true;
628 ndev->priv_destructor = brcmf_cfg80211_free_netdev;
628 ifp = netdev_priv(ndev); 629 ifp = netdev_priv(ndev);
629 ifp->ndev = ndev; 630 ifp->ndev = ndev;
630 /* store mapping ifidx to bsscfgidx */ 631 /* store mapping ifidx to bsscfgidx */
diff --git a/drivers/net/wireless/intersil/hostap/hostap_main.c b/drivers/net/wireless/intersil/hostap/hostap_main.c
index 544fc09dcb62..1372b20f931e 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_main.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_main.c
@@ -73,7 +73,7 @@ struct net_device * hostap_add_interface(struct local_info *local,
73 dev->mem_end = mdev->mem_end; 73 dev->mem_end = mdev->mem_end;
74 74
75 hostap_setup_dev(dev, local, type); 75 hostap_setup_dev(dev, local, type);
76 dev->destructor = free_netdev; 76 dev->needs_free_netdev = true;
77 77
78 sprintf(dev->name, "%s%s", prefix, name); 78 sprintf(dev->name, "%s%s", prefix, name);
79 if (!rtnl_locked) 79 if (!rtnl_locked)
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 002b25cff5b6..c854a557998b 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2861,7 +2861,7 @@ static const struct net_device_ops hwsim_netdev_ops = {
2861static void hwsim_mon_setup(struct net_device *dev) 2861static void hwsim_mon_setup(struct net_device *dev)
2862{ 2862{
2863 dev->netdev_ops = &hwsim_netdev_ops; 2863 dev->netdev_ops = &hwsim_netdev_ops;
2864 dev->destructor = free_netdev; 2864 dev->needs_free_netdev = true;
2865 ether_setup(dev); 2865 ether_setup(dev);
2866 dev->priv_flags |= IFF_NO_QUEUE; 2866 dev->priv_flags |= IFF_NO_QUEUE;
2867 dev->type = ARPHRD_IEEE80211_RADIOTAP; 2867 dev->type = ARPHRD_IEEE80211_RADIOTAP;
diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c
index dd87b9ff64c3..39b6b5e3f6e0 100644
--- a/drivers/net/wireless/marvell/mwifiex/main.c
+++ b/drivers/net/wireless/marvell/mwifiex/main.c
@@ -1280,7 +1280,7 @@ void mwifiex_init_priv_params(struct mwifiex_private *priv,
1280 struct net_device *dev) 1280 struct net_device *dev)
1281{ 1281{
1282 dev->netdev_ops = &mwifiex_netdev_ops; 1282 dev->netdev_ops = &mwifiex_netdev_ops;
1283 dev->destructor = free_netdev; 1283 dev->needs_free_netdev = true;
1284 /* Initialize private structure */ 1284 /* Initialize private structure */
1285 priv->current_key_index = 0; 1285 priv->current_key_index = 0;
1286 priv->media_connected = false; 1286 priv->media_connected = false;
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index dba94b486f05..fa732bd86729 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -1954,7 +1954,6 @@ static void netiucv_free_netdevice(struct net_device *dev)
1954 privptr->conn = NULL; privptr->fsm = NULL; 1954 privptr->conn = NULL; privptr->fsm = NULL;
1955 /* privptr gets freed by free_netdev() */ 1955 /* privptr gets freed by free_netdev() */
1956 } 1956 }
1957 free_netdev(dev);
1958} 1957}
1959 1958
1960/** 1959/**
@@ -1972,7 +1971,8 @@ static void netiucv_setup_netdevice(struct net_device *dev)
1972 dev->mtu = NETIUCV_MTU_DEFAULT; 1971 dev->mtu = NETIUCV_MTU_DEFAULT;
1973 dev->min_mtu = 576; 1972 dev->min_mtu = 576;
1974 dev->max_mtu = NETIUCV_MTU_MAX; 1973 dev->max_mtu = NETIUCV_MTU_MAX;
1975 dev->destructor = netiucv_free_netdevice; 1974 dev->needs_free_netdev = true;
1975 dev->priv_destructor = netiucv_free_netdevice;
1976 dev->hard_header_len = NETIUCV_HDRLEN; 1976 dev->hard_header_len = NETIUCV_HDRLEN;
1977 dev->addr_len = 0; 1977 dev->addr_len = 0;
1978 dev->type = ARPHRD_SLIP; 1978 dev->type = ARPHRD_SLIP;
diff --git a/drivers/staging/rtl8188eu/os_dep/mon.c b/drivers/staging/rtl8188eu/os_dep/mon.c
index cfe37eb026d6..859d0d6051cd 100644
--- a/drivers/staging/rtl8188eu/os_dep/mon.c
+++ b/drivers/staging/rtl8188eu/os_dep/mon.c
@@ -152,7 +152,7 @@ static const struct net_device_ops mon_netdev_ops = {
152static void mon_setup(struct net_device *dev) 152static void mon_setup(struct net_device *dev)
153{ 153{
154 dev->netdev_ops = &mon_netdev_ops; 154 dev->netdev_ops = &mon_netdev_ops;
155 dev->destructor = free_netdev; 155 dev->needs_free_netdev = true;
156 ether_setup(dev); 156 ether_setup(dev);
157 dev->priv_flags |= IFF_NO_QUEUE; 157 dev->priv_flags |= IFF_NO_QUEUE;
158 dev->type = ARPHRD_IEEE80211; 158 dev->type = ARPHRD_IEEE80211;
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 36c3189fc4b7..bd4352fe2de3 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -2667,7 +2667,8 @@ static int rtw_cfg80211_add_monitor_if (struct adapter *padapter, char *name, st
2667 mon_ndev->type = ARPHRD_IEEE80211_RADIOTAP; 2667 mon_ndev->type = ARPHRD_IEEE80211_RADIOTAP;
2668 strncpy(mon_ndev->name, name, IFNAMSIZ); 2668 strncpy(mon_ndev->name, name, IFNAMSIZ);
2669 mon_ndev->name[IFNAMSIZ - 1] = 0; 2669 mon_ndev->name[IFNAMSIZ - 1] = 0;
2670 mon_ndev->destructor = rtw_ndev_destructor; 2670 mon_ndev->needs_free_netdev = true;
2671 mon_ndev->priv_destructor = rtw_ndev_destructor;
2671 2672
2672 mon_ndev->netdev_ops = &rtw_cfg80211_monitor_if_ops; 2673 mon_ndev->netdev_ops = &rtw_cfg80211_monitor_if_ops;
2673 2674
diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index f83cfc76505c..021589913681 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -1207,8 +1207,6 @@ void rtw_ndev_destructor(struct net_device *ndev)
1207 1207
1208 if (ndev->ieee80211_ptr) 1208 if (ndev->ieee80211_ptr)
1209 kfree((u8 *)ndev->ieee80211_ptr); 1209 kfree((u8 *)ndev->ieee80211_ptr);
1210
1211 free_netdev(ndev);
1212} 1210}
1213 1211
1214void rtw_dev_unload(struct adapter *padapter) 1212void rtw_dev_unload(struct adapter *padapter)
diff --git a/drivers/usb/gadget/function/f_phonet.c b/drivers/usb/gadget/function/f_phonet.c
index b4058f0000e4..6a1ce6a55158 100644
--- a/drivers/usb/gadget/function/f_phonet.c
+++ b/drivers/usb/gadget/function/f_phonet.c
@@ -281,7 +281,7 @@ static void pn_net_setup(struct net_device *dev)
281 dev->tx_queue_len = 1; 281 dev->tx_queue_len = 1;
282 282
283 dev->netdev_ops = &pn_netdev_ops; 283 dev->netdev_ops = &pn_netdev_ops;
284 dev->destructor = free_netdev; 284 dev->needs_free_netdev = true;
285 dev->header_ops = &phonet_header_ops; 285 dev->header_ops = &phonet_header_ops;
286} 286}
287 287
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 3f39d27decf4..4ed952c17fc7 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -914,8 +914,7 @@ struct xfrmdev_ops {
914 * 914 *
915 * int (*ndo_change_mtu)(struct net_device *dev, int new_mtu); 915 * int (*ndo_change_mtu)(struct net_device *dev, int new_mtu);
916 * Called when a user wants to change the Maximum Transfer Unit 916 * Called when a user wants to change the Maximum Transfer Unit
917 * of a device. If not defined, any request to change MTU will 917 * of a device.
918 * will return an error.
919 * 918 *
920 * void (*ndo_tx_timeout)(struct net_device *dev); 919 * void (*ndo_tx_timeout)(struct net_device *dev);
921 * Callback used when the transmitter has not made any progress 920 * Callback used when the transmitter has not made any progress
@@ -1596,8 +1595,8 @@ enum netdev_priv_flags {
1596 * @rtnl_link_state: This enum represents the phases of creating 1595 * @rtnl_link_state: This enum represents the phases of creating
1597 * a new link 1596 * a new link
1598 * 1597 *
1599 * @destructor: Called from unregister, 1598 * @needs_free_netdev: Should unregister perform free_netdev?
1600 * can be used to call free_netdev 1599 * @priv_destructor: Called from unregister
1601 * @npinfo: XXX: need comments on this one 1600 * @npinfo: XXX: need comments on this one
1602 * @nd_net: Network namespace this network device is inside 1601 * @nd_net: Network namespace this network device is inside
1603 * 1602 *
@@ -1858,7 +1857,8 @@ struct net_device {
1858 RTNL_LINK_INITIALIZING, 1857 RTNL_LINK_INITIALIZING,
1859 } rtnl_link_state:16; 1858 } rtnl_link_state:16;
1860 1859
1861 void (*destructor)(struct net_device *dev); 1860 bool needs_free_netdev;
1861 void (*priv_destructor)(struct net_device *dev);
1862 1862
1863#ifdef CONFIG_NETPOLL 1863#ifdef CONFIG_NETPOLL
1864 struct netpoll_info __rcu *npinfo; 1864 struct netpoll_info __rcu *npinfo;
@@ -4261,6 +4261,11 @@ static inline const char *netdev_name(const struct net_device *dev)
4261 return dev->name; 4261 return dev->name;
4262} 4262}
4263 4263
4264static inline bool netdev_unregistering(const struct net_device *dev)
4265{
4266 return dev->reg_state == NETREG_UNREGISTERING;
4267}
4268
4264static inline const char *netdev_reg_state(const struct net_device *dev) 4269static inline const char *netdev_reg_state(const struct net_device *dev)
4265{ 4270{
4266 switch (dev->reg_state) { 4271 switch (dev->reg_state) {
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index d179d7767f51..7d4a594d5d58 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -1486,8 +1486,10 @@ enum ethtool_link_mode_bit_indices {
1486 * it was forced up into this mode or autonegotiated. 1486 * it was forced up into this mode or autonegotiated.
1487 */ 1487 */
1488 1488
1489/* The forced speed, in units of 1Mb. All values 0 to INT_MAX are legal. */ 1489/* The forced speed, in units of 1Mb. All values 0 to INT_MAX are legal.
1490/* Update drivers/net/phy/phy.c:phy_speed_to_str() when adding new values */ 1490 * Update drivers/net/phy/phy.c:phy_speed_to_str() and
1491 * drivers/net/bonding/bond_3ad.c:__get_link_speed() when adding new values.
1492 */
1491#define SPEED_10 10 1493#define SPEED_10 10
1492#define SPEED_100 100 1494#define SPEED_100 100
1493#define SPEED_1000 1000 1495#define SPEED_1000 1000
diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index 61b7d36dfe34..156ee4cab82e 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -343,6 +343,7 @@ enum ovs_key_attr {
343#define OVS_KEY_ATTR_MAX (__OVS_KEY_ATTR_MAX - 1) 343#define OVS_KEY_ATTR_MAX (__OVS_KEY_ATTR_MAX - 1)
344 344
345enum ovs_tunnel_key_attr { 345enum ovs_tunnel_key_attr {
346 /* OVS_TUNNEL_KEY_ATTR_NONE, standard nl API requires this attribute! */
346 OVS_TUNNEL_KEY_ATTR_ID, /* be64 Tunnel ID */ 347 OVS_TUNNEL_KEY_ATTR_ID, /* be64 Tunnel ID */
347 OVS_TUNNEL_KEY_ATTR_IPV4_SRC, /* be32 src IP address. */ 348 OVS_TUNNEL_KEY_ATTR_IPV4_SRC, /* be32 src IP address. */
348 OVS_TUNNEL_KEY_ATTR_IPV4_DST, /* be32 dst IP address. */ 349 OVS_TUNNEL_KEY_ATTR_IPV4_DST, /* be32 dst IP address. */
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 953b6728bd00..abc5f400fc71 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -813,7 +813,6 @@ static void vlan_dev_free(struct net_device *dev)
813 813
814 free_percpu(vlan->vlan_pcpu_stats); 814 free_percpu(vlan->vlan_pcpu_stats);
815 vlan->vlan_pcpu_stats = NULL; 815 vlan->vlan_pcpu_stats = NULL;
816 free_netdev(dev);
817} 816}
818 817
819void vlan_setup(struct net_device *dev) 818void vlan_setup(struct net_device *dev)
@@ -826,7 +825,8 @@ void vlan_setup(struct net_device *dev)
826 netif_keep_dst(dev); 825 netif_keep_dst(dev);
827 826
828 dev->netdev_ops = &vlan_netdev_ops; 827 dev->netdev_ops = &vlan_netdev_ops;
829 dev->destructor = vlan_dev_free; 828 dev->needs_free_netdev = true;
829 dev->priv_destructor = vlan_dev_free;
830 dev->ethtool_ops = &vlan_ethtool_ops; 830 dev->ethtool_ops = &vlan_ethtool_ops;
831 831
832 dev->min_mtu = 0; 832 dev->min_mtu = 0;
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 013e970eff39..000ca2f113ab 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -1064,8 +1064,9 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
1064 1064
1065 skb_new->protocol = eth_type_trans(skb_new, soft_iface); 1065 skb_new->protocol = eth_type_trans(skb_new, soft_iface);
1066 1066
1067 soft_iface->stats.rx_packets++; 1067 batadv_inc_counter(bat_priv, BATADV_CNT_RX);
1068 soft_iface->stats.rx_bytes += skb->len + ETH_HLEN + hdr_size; 1068 batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES,
1069 skb->len + ETH_HLEN + hdr_size);
1069 1070
1070 netif_rx(skb_new); 1071 netif_rx(skb_new);
1071 batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n"); 1072 batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n");
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index e1ebe14ee2a6..ae9f4d37d34f 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -987,7 +987,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
987 batadv_dbg(BATADV_DBG_BLA, bat_priv, 987 batadv_dbg(BATADV_DBG_BLA, bat_priv,
988 "recv_unicast_packet(): Dropped unicast pkt received from another backbone gw %pM.\n", 988 "recv_unicast_packet(): Dropped unicast pkt received from another backbone gw %pM.\n",
989 orig_addr_gw); 989 orig_addr_gw);
990 return NET_RX_DROP; 990 goto free_skb;
991 } 991 }
992 } 992 }
993 993
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index b25789abf7b9..10f7edfb176e 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -1034,8 +1034,6 @@ static void batadv_softif_free(struct net_device *dev)
1034 * netdev and its private data (bat_priv) 1034 * netdev and its private data (bat_priv)
1035 */ 1035 */
1036 rcu_barrier(); 1036 rcu_barrier();
1037
1038 free_netdev(dev);
1039} 1037}
1040 1038
1041/** 1039/**
@@ -1047,7 +1045,8 @@ static void batadv_softif_init_early(struct net_device *dev)
1047 ether_setup(dev); 1045 ether_setup(dev);
1048 1046
1049 dev->netdev_ops = &batadv_netdev_ops; 1047 dev->netdev_ops = &batadv_netdev_ops;
1050 dev->destructor = batadv_softif_free; 1048 dev->needs_free_netdev = true;
1049 dev->priv_destructor = batadv_softif_free;
1051 dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_NETNS_LOCAL; 1050 dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_NETNS_LOCAL;
1052 dev->priv_flags |= IFF_NO_QUEUE; 1051 dev->priv_flags |= IFF_NO_QUEUE;
1053 1052
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 608959989f8e..ab3b654b05cc 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -598,7 +598,7 @@ static void netdev_setup(struct net_device *dev)
598 598
599 dev->netdev_ops = &netdev_ops; 599 dev->netdev_ops = &netdev_ops;
600 dev->header_ops = &header_ops; 600 dev->header_ops = &header_ops;
601 dev->destructor = free_netdev; 601 dev->needs_free_netdev = true;
602} 602}
603 603
604static struct device_type bt_type = { 604static struct device_type bt_type = {
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 430b53e7d941..f0f3447e8aa4 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -379,7 +379,7 @@ void br_dev_setup(struct net_device *dev)
379 ether_setup(dev); 379 ether_setup(dev);
380 380
381 dev->netdev_ops = &br_netdev_ops; 381 dev->netdev_ops = &br_netdev_ops;
382 dev->destructor = free_netdev; 382 dev->needs_free_netdev = true;
383 dev->ethtool_ops = &br_ethtool_ops; 383 dev->ethtool_ops = &br_ethtool_ops;
384 SET_NETDEV_DEVTYPE(dev, &br_type); 384 SET_NETDEV_DEVTYPE(dev, &br_type);
385 dev->priv_flags = IFF_EBRIDGE | IFF_NO_QUEUE; 385 dev->priv_flags = IFF_EBRIDGE | IFF_NO_QUEUE;
diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
index adcad344c843..21f18ea2fce4 100644
--- a/net/caif/caif_socket.c
+++ b/net/caif/caif_socket.c
@@ -754,6 +754,10 @@ static int caif_connect(struct socket *sock, struct sockaddr *uaddr,
754 754
755 lock_sock(sk); 755 lock_sock(sk);
756 756
757 err = -EINVAL;
758 if (addr_len < offsetofend(struct sockaddr, sa_family))
759 goto out;
760
757 err = -EAFNOSUPPORT; 761 err = -EAFNOSUPPORT;
758 if (uaddr->sa_family != AF_CAIF) 762 if (uaddr->sa_family != AF_CAIF)
759 goto out; 763 goto out;
diff --git a/net/caif/cfpkt_skbuff.c b/net/caif/cfpkt_skbuff.c
index 59ce1fcc220c..71b6ab240dea 100644
--- a/net/caif/cfpkt_skbuff.c
+++ b/net/caif/cfpkt_skbuff.c
@@ -81,11 +81,7 @@ static struct cfpkt *cfpkt_create_pfx(u16 len, u16 pfx)
81{ 81{
82 struct sk_buff *skb; 82 struct sk_buff *skb;
83 83
84 if (likely(in_interrupt())) 84 skb = alloc_skb(len + pfx, GFP_ATOMIC);
85 skb = alloc_skb(len + pfx, GFP_ATOMIC);
86 else
87 skb = alloc_skb(len + pfx, GFP_KERNEL);
88
89 if (unlikely(skb == NULL)) 85 if (unlikely(skb == NULL))
90 return NULL; 86 return NULL;
91 87
diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
index 1816fc9f1ee7..fe3c53efb949 100644
--- a/net/caif/chnl_net.c
+++ b/net/caif/chnl_net.c
@@ -392,14 +392,14 @@ static void chnl_net_destructor(struct net_device *dev)
392{ 392{
393 struct chnl_net *priv = netdev_priv(dev); 393 struct chnl_net *priv = netdev_priv(dev);
394 caif_free_client(&priv->chnl); 394 caif_free_client(&priv->chnl);
395 free_netdev(dev);
396} 395}
397 396
398static void ipcaif_net_setup(struct net_device *dev) 397static void ipcaif_net_setup(struct net_device *dev)
399{ 398{
400 struct chnl_net *priv; 399 struct chnl_net *priv;
401 dev->netdev_ops = &netdev_ops; 400 dev->netdev_ops = &netdev_ops;
402 dev->destructor = chnl_net_destructor; 401 dev->needs_free_netdev = true;
402 dev->priv_destructor = chnl_net_destructor;
403 dev->flags |= IFF_NOARP; 403 dev->flags |= IFF_NOARP;
404 dev->flags |= IFF_POINTOPOINT; 404 dev->flags |= IFF_POINTOPOINT;
405 dev->mtu = GPRS_PDP_MTU; 405 dev->mtu = GPRS_PDP_MTU;
diff --git a/net/can/af_can.c b/net/can/af_can.c
index b6406fe33c76..88edac0f3e36 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -872,8 +872,7 @@ static int can_notifier(struct notifier_block *nb, unsigned long msg,
872 872
873static int can_pernet_init(struct net *net) 873static int can_pernet_init(struct net *net)
874{ 874{
875 net->can.can_rcvlists_lock = 875 spin_lock_init(&net->can.can_rcvlists_lock);
876 __SPIN_LOCK_UNLOCKED(net->can.can_rcvlists_lock);
877 net->can.can_rx_alldev_list = 876 net->can.can_rx_alldev_list =
878 kzalloc(sizeof(struct dev_rcv_lists), GFP_KERNEL); 877 kzalloc(sizeof(struct dev_rcv_lists), GFP_KERNEL);
879 878
diff --git a/net/core/dev.c b/net/core/dev.c
index fca407b4a6ea..6d60149287a1 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1253,8 +1253,9 @@ int dev_set_alias(struct net_device *dev, const char *alias, size_t len)
1253 if (!new_ifalias) 1253 if (!new_ifalias)
1254 return -ENOMEM; 1254 return -ENOMEM;
1255 dev->ifalias = new_ifalias; 1255 dev->ifalias = new_ifalias;
1256 memcpy(dev->ifalias, alias, len);
1257 dev->ifalias[len] = 0;
1256 1258
1257 strlcpy(dev->ifalias, alias, len+1);
1258 return len; 1259 return len;
1259} 1260}
1260 1261
@@ -4948,6 +4949,19 @@ __sum16 __skb_gro_checksum_complete(struct sk_buff *skb)
4948} 4949}
4949EXPORT_SYMBOL(__skb_gro_checksum_complete); 4950EXPORT_SYMBOL(__skb_gro_checksum_complete);
4950 4951
4952static void net_rps_send_ipi(struct softnet_data *remsd)
4953{
4954#ifdef CONFIG_RPS
4955 while (remsd) {
4956 struct softnet_data *next = remsd->rps_ipi_next;
4957
4958 if (cpu_online(remsd->cpu))
4959 smp_call_function_single_async(remsd->cpu, &remsd->csd);
4960 remsd = next;
4961 }
4962#endif
4963}
4964
4951/* 4965/*
4952 * net_rps_action_and_irq_enable sends any pending IPI's for rps. 4966 * net_rps_action_and_irq_enable sends any pending IPI's for rps.
4953 * Note: called with local irq disabled, but exits with local irq enabled. 4967 * Note: called with local irq disabled, but exits with local irq enabled.
@@ -4963,14 +4977,7 @@ static void net_rps_action_and_irq_enable(struct softnet_data *sd)
4963 local_irq_enable(); 4977 local_irq_enable();
4964 4978
4965 /* Send pending IPI's to kick RPS processing on remote cpus. */ 4979 /* Send pending IPI's to kick RPS processing on remote cpus. */
4966 while (remsd) { 4980 net_rps_send_ipi(remsd);
4967 struct softnet_data *next = remsd->rps_ipi_next;
4968
4969 if (cpu_online(remsd->cpu))
4970 smp_call_function_single_async(remsd->cpu,
4971 &remsd->csd);
4972 remsd = next;
4973 }
4974 } else 4981 } else
4975#endif 4982#endif
4976 local_irq_enable(); 4983 local_irq_enable();
@@ -7501,6 +7508,8 @@ out:
7501err_uninit: 7508err_uninit:
7502 if (dev->netdev_ops->ndo_uninit) 7509 if (dev->netdev_ops->ndo_uninit)
7503 dev->netdev_ops->ndo_uninit(dev); 7510 dev->netdev_ops->ndo_uninit(dev);
7511 if (dev->priv_destructor)
7512 dev->priv_destructor(dev);
7504 goto out; 7513 goto out;
7505} 7514}
7506EXPORT_SYMBOL(register_netdevice); 7515EXPORT_SYMBOL(register_netdevice);
@@ -7708,8 +7717,10 @@ void netdev_run_todo(void)
7708 WARN_ON(rcu_access_pointer(dev->ip6_ptr)); 7717 WARN_ON(rcu_access_pointer(dev->ip6_ptr));
7709 WARN_ON(dev->dn_ptr); 7718 WARN_ON(dev->dn_ptr);
7710 7719
7711 if (dev->destructor) 7720 if (dev->priv_destructor)
7712 dev->destructor(dev); 7721 dev->priv_destructor(dev);
7722 if (dev->needs_free_netdev)
7723 free_netdev(dev);
7713 7724
7714 /* Report a network device has been unregistered */ 7725 /* Report a network device has been unregistered */
7715 rtnl_lock(); 7726 rtnl_lock();
@@ -8192,7 +8203,7 @@ static int dev_cpu_dead(unsigned int oldcpu)
8192 struct sk_buff **list_skb; 8203 struct sk_buff **list_skb;
8193 struct sk_buff *skb; 8204 struct sk_buff *skb;
8194 unsigned int cpu; 8205 unsigned int cpu;
8195 struct softnet_data *sd, *oldsd; 8206 struct softnet_data *sd, *oldsd, *remsd = NULL;
8196 8207
8197 local_irq_disable(); 8208 local_irq_disable();
8198 cpu = smp_processor_id(); 8209 cpu = smp_processor_id();
@@ -8233,6 +8244,13 @@ static int dev_cpu_dead(unsigned int oldcpu)
8233 raise_softirq_irqoff(NET_TX_SOFTIRQ); 8244 raise_softirq_irqoff(NET_TX_SOFTIRQ);
8234 local_irq_enable(); 8245 local_irq_enable();
8235 8246
8247#ifdef CONFIG_RPS
8248 remsd = oldsd->rps_ipi_list;
8249 oldsd->rps_ipi_list = NULL;
8250#endif
8251 /* send out pending IPI's on offline CPU */
8252 net_rps_send_ipi(remsd);
8253
8236 /* Process offline CPU's input_pkt_queue */ 8254 /* Process offline CPU's input_pkt_queue */
8237 while ((skb = __skb_dequeue(&oldsd->process_queue))) { 8255 while ((skb = __skb_dequeue(&oldsd->process_queue))) {
8238 netif_rx_ni(skb); 8256 netif_rx_ni(skb);
diff --git a/net/core/dst.c b/net/core/dst.c
index 6192f11beec9..13ba4a090c41 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -469,6 +469,20 @@ static int dst_dev_event(struct notifier_block *this, unsigned long event,
469 spin_lock_bh(&dst_garbage.lock); 469 spin_lock_bh(&dst_garbage.lock);
470 dst = dst_garbage.list; 470 dst = dst_garbage.list;
471 dst_garbage.list = NULL; 471 dst_garbage.list = NULL;
472 /* The code in dst_ifdown places a hold on the loopback device.
473 * If the gc entry processing is set to expire after a lengthy
474 * interval, this hold can cause netdev_wait_allrefs() to hang
475 * out and wait for a long time -- until the the loopback
476 * interface is released. If we're really unlucky, it'll emit
477 * pr_emerg messages to console too. Reset the interval here,
478 * so dst cleanups occur in a more timely fashion.
479 */
480 if (dst_garbage.timer_inc > DST_GC_INC) {
481 dst_garbage.timer_inc = DST_GC_INC;
482 dst_garbage.timer_expires = DST_GC_MIN;
483 mod_delayed_work(system_wq, &dst_gc_work,
484 dst_garbage.timer_expires);
485 }
472 spin_unlock_bh(&dst_garbage.lock); 486 spin_unlock_bh(&dst_garbage.lock);
473 487
474 if (last) 488 if (last)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 9e2c0a7cb325..5e61456f6bc7 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1124,6 +1124,8 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,
1124 struct ifla_vf_mac vf_mac; 1124 struct ifla_vf_mac vf_mac;
1125 struct ifla_vf_info ivi; 1125 struct ifla_vf_info ivi;
1126 1126
1127 memset(&ivi, 0, sizeof(ivi));
1128
1127 /* Not all SR-IOV capable drivers support the 1129 /* Not all SR-IOV capable drivers support the
1128 * spoofcheck and "RSS query enable" query. Preset to 1130 * spoofcheck and "RSS query enable" query. Preset to
1129 * -1 so the user space tool can detect that the driver 1131 * -1 so the user space tool can detect that the driver
@@ -1132,7 +1134,6 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,
1132 ivi.spoofchk = -1; 1134 ivi.spoofchk = -1;
1133 ivi.rss_query_en = -1; 1135 ivi.rss_query_en = -1;
1134 ivi.trusted = -1; 1136 ivi.trusted = -1;
1135 memset(ivi.mac, 0, sizeof(ivi.mac));
1136 /* The default value for VF link state is "auto" 1137 /* The default value for VF link state is "auto"
1137 * IFLA_VF_LINK_STATE_AUTO which equals zero 1138 * IFLA_VF_LINK_STATE_AUTO which equals zero
1138 */ 1139 */
diff --git a/net/decnet/netfilter/dn_rtmsg.c b/net/decnet/netfilter/dn_rtmsg.c
index 1ed81ac6dd1a..aa8ffecc46a4 100644
--- a/net/decnet/netfilter/dn_rtmsg.c
+++ b/net/decnet/netfilter/dn_rtmsg.c
@@ -102,7 +102,9 @@ static inline void dnrmg_receive_user_skb(struct sk_buff *skb)
102{ 102{
103 struct nlmsghdr *nlh = nlmsg_hdr(skb); 103 struct nlmsghdr *nlh = nlmsg_hdr(skb);
104 104
105 if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len) 105 if (skb->len < sizeof(*nlh) ||
106 nlh->nlmsg_len < sizeof(*nlh) ||
107 skb->len < nlh->nlmsg_len)
106 return; 108 return;
107 109
108 if (!netlink_capable(skb, CAP_NET_ADMIN)) 110 if (!netlink_capable(skb, CAP_NET_ADMIN))
diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
index c73160fb11e7..0a0a392dc2bd 100644
--- a/net/hsr/hsr_device.c
+++ b/net/hsr/hsr_device.c
@@ -378,7 +378,6 @@ static void hsr_dev_destroy(struct net_device *hsr_dev)
378 del_timer_sync(&hsr->announce_timer); 378 del_timer_sync(&hsr->announce_timer);
379 379
380 synchronize_rcu(); 380 synchronize_rcu();
381 free_netdev(hsr_dev);
382} 381}
383 382
384static const struct net_device_ops hsr_device_ops = { 383static const struct net_device_ops hsr_device_ops = {
@@ -404,7 +403,8 @@ void hsr_dev_setup(struct net_device *dev)
404 SET_NETDEV_DEVTYPE(dev, &hsr_type); 403 SET_NETDEV_DEVTYPE(dev, &hsr_type);
405 dev->priv_flags |= IFF_NO_QUEUE; 404 dev->priv_flags |= IFF_NO_QUEUE;
406 405
407 dev->destructor = hsr_dev_destroy; 406 dev->needs_free_netdev = true;
407 dev->priv_destructor = hsr_dev_destroy;
408 408
409 dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | 409 dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA |
410 NETIF_F_GSO_MASK | NETIF_F_HW_CSUM | 410 NETIF_F_GSO_MASK | NETIF_F_HW_CSUM |
diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
index 4ebe2aa3e7d3..04b5450c5a55 100644
--- a/net/hsr/hsr_forward.c
+++ b/net/hsr/hsr_forward.c
@@ -324,8 +324,7 @@ static int hsr_fill_frame_info(struct hsr_frame_info *frame,
324 unsigned long irqflags; 324 unsigned long irqflags;
325 325
326 frame->is_supervision = is_supervision_frame(port->hsr, skb); 326 frame->is_supervision = is_supervision_frame(port->hsr, skb);
327 frame->node_src = hsr_get_node(&port->hsr->node_db, skb, 327 frame->node_src = hsr_get_node(port, skb, frame->is_supervision);
328 frame->is_supervision);
329 if (frame->node_src == NULL) 328 if (frame->node_src == NULL)
330 return -1; /* Unknown node and !is_supervision, or no mem */ 329 return -1; /* Unknown node and !is_supervision, or no mem */
331 330
diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
index 7ea925816f79..284a9b820df8 100644
--- a/net/hsr/hsr_framereg.c
+++ b/net/hsr/hsr_framereg.c
@@ -158,9 +158,10 @@ struct hsr_node *hsr_add_node(struct list_head *node_db, unsigned char addr[],
158 158
159/* Get the hsr_node from which 'skb' was sent. 159/* Get the hsr_node from which 'skb' was sent.
160 */ 160 */
161struct hsr_node *hsr_get_node(struct list_head *node_db, struct sk_buff *skb, 161struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,
162 bool is_sup) 162 bool is_sup)
163{ 163{
164 struct list_head *node_db = &port->hsr->node_db;
164 struct hsr_node *node; 165 struct hsr_node *node;
165 struct ethhdr *ethhdr; 166 struct ethhdr *ethhdr;
166 u16 seq_out; 167 u16 seq_out;
@@ -186,7 +187,11 @@ struct hsr_node *hsr_get_node(struct list_head *node_db, struct sk_buff *skb,
186 */ 187 */
187 seq_out = hsr_get_skb_sequence_nr(skb) - 1; 188 seq_out = hsr_get_skb_sequence_nr(skb) - 1;
188 } else { 189 } else {
189 WARN_ONCE(1, "%s: Non-HSR frame\n", __func__); 190 /* this is called also for frames from master port and
191 * so warn only for non master ports
192 */
193 if (port->type != HSR_PT_MASTER)
194 WARN_ONCE(1, "%s: Non-HSR frame\n", __func__);
190 seq_out = HSR_SEQNR_START; 195 seq_out = HSR_SEQNR_START;
191 } 196 }
192 197
diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h
index 438b40f98f5a..4e04f0e868e9 100644
--- a/net/hsr/hsr_framereg.h
+++ b/net/hsr/hsr_framereg.h
@@ -18,7 +18,7 @@ struct hsr_node;
18 18
19struct hsr_node *hsr_add_node(struct list_head *node_db, unsigned char addr[], 19struct hsr_node *hsr_add_node(struct list_head *node_db, unsigned char addr[],
20 u16 seq_out); 20 u16 seq_out);
21struct hsr_node *hsr_get_node(struct list_head *node_db, struct sk_buff *skb, 21struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,
22 bool is_sup); 22 bool is_sup);
23void hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr, 23void hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr,
24 struct hsr_port *port); 24 struct hsr_port *port);
diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
index d7efbf0dad20..0a866f332290 100644
--- a/net/ieee802154/6lowpan/core.c
+++ b/net/ieee802154/6lowpan/core.c
@@ -107,7 +107,7 @@ static void lowpan_setup(struct net_device *ldev)
107 107
108 ldev->netdev_ops = &lowpan_netdev_ops; 108 ldev->netdev_ops = &lowpan_netdev_ops;
109 ldev->header_ops = &lowpan_header_ops; 109 ldev->header_ops = &lowpan_header_ops;
110 ldev->destructor = free_netdev; 110 ldev->needs_free_netdev = true;
111 ldev->features |= NETIF_F_NETNS_LOCAL; 111 ldev->features |= NETIF_F_NETNS_LOCAL;
112} 112}
113 113
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 43318b5f5647..9144fa7df2ad 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -657,8 +657,12 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
657 /* Needed by both icmp_global_allow and icmp_xmit_lock */ 657 /* Needed by both icmp_global_allow and icmp_xmit_lock */
658 local_bh_disable(); 658 local_bh_disable();
659 659
660 /* Check global sysctl_icmp_msgs_per_sec ratelimit */ 660 /* Check global sysctl_icmp_msgs_per_sec ratelimit, unless
661 if (!icmpv4_global_allow(net, type, code)) 661 * incoming dev is loopback. If outgoing dev change to not be
662 * loopback, then peer ratelimit still work (in icmpv4_xrlim_allow)
663 */
664 if (!(skb_in->dev && (skb_in->dev->flags&IFF_LOOPBACK)) &&
665 !icmpv4_global_allow(net, type, code))
662 goto out_bh_enable; 666 goto out_bh_enable;
663 667
664 sk = icmp_xmit_lock(net); 668 sk = icmp_xmit_lock(net);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 44fd86de2823..8f6b5bbcbf69 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -2071,21 +2071,26 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
2071 2071
2072static void ip_mc_clear_src(struct ip_mc_list *pmc) 2072static void ip_mc_clear_src(struct ip_mc_list *pmc)
2073{ 2073{
2074 struct ip_sf_list *psf, *nextpsf; 2074 struct ip_sf_list *psf, *nextpsf, *tomb, *sources;
2075 2075
2076 for (psf = pmc->tomb; psf; psf = nextpsf) { 2076 spin_lock_bh(&pmc->lock);
2077 tomb = pmc->tomb;
2078 pmc->tomb = NULL;
2079 sources = pmc->sources;
2080 pmc->sources = NULL;
2081 pmc->sfmode = MCAST_EXCLUDE;
2082 pmc->sfcount[MCAST_INCLUDE] = 0;
2083 pmc->sfcount[MCAST_EXCLUDE] = 1;
2084 spin_unlock_bh(&pmc->lock);
2085
2086 for (psf = tomb; psf; psf = nextpsf) {
2077 nextpsf = psf->sf_next; 2087 nextpsf = psf->sf_next;
2078 kfree(psf); 2088 kfree(psf);
2079 } 2089 }
2080 pmc->tomb = NULL; 2090 for (psf = sources; psf; psf = nextpsf) {
2081 for (psf = pmc->sources; psf; psf = nextpsf) {
2082 nextpsf = psf->sf_next; 2091 nextpsf = psf->sf_next;
2083 kfree(psf); 2092 kfree(psf);
2084 } 2093 }
2085 pmc->sources = NULL;
2086 pmc->sfmode = MCAST_EXCLUDE;
2087 pmc->sfcount[MCAST_INCLUDE] = 0;
2088 pmc->sfcount[MCAST_EXCLUDE] = 1;
2089} 2094}
2090 2095
2091/* Join a multicast group 2096/* Join a multicast group
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index b878ecbc0608..b436d0775631 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -967,7 +967,6 @@ static void ip_tunnel_dev_free(struct net_device *dev)
967 gro_cells_destroy(&tunnel->gro_cells); 967 gro_cells_destroy(&tunnel->gro_cells);
968 dst_cache_destroy(&tunnel->dst_cache); 968 dst_cache_destroy(&tunnel->dst_cache);
969 free_percpu(dev->tstats); 969 free_percpu(dev->tstats);
970 free_netdev(dev);
971} 970}
972 971
973void ip_tunnel_dellink(struct net_device *dev, struct list_head *head) 972void ip_tunnel_dellink(struct net_device *dev, struct list_head *head)
@@ -1155,7 +1154,8 @@ int ip_tunnel_init(struct net_device *dev)
1155 struct iphdr *iph = &tunnel->parms.iph; 1154 struct iphdr *iph = &tunnel->parms.iph;
1156 int err; 1155 int err;
1157 1156
1158 dev->destructor = ip_tunnel_dev_free; 1157 dev->needs_free_netdev = true;
1158 dev->priv_destructor = ip_tunnel_dev_free;
1159 dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); 1159 dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
1160 if (!dev->tstats) 1160 if (!dev->tstats)
1161 return -ENOMEM; 1161 return -ENOMEM;
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 551de4d023a8..8ae425cad818 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -101,8 +101,8 @@ static struct mr_table *ipmr_new_table(struct net *net, u32 id);
101static void ipmr_free_table(struct mr_table *mrt); 101static void ipmr_free_table(struct mr_table *mrt);
102 102
103static void ip_mr_forward(struct net *net, struct mr_table *mrt, 103static void ip_mr_forward(struct net *net, struct mr_table *mrt,
104 struct sk_buff *skb, struct mfc_cache *cache, 104 struct net_device *dev, struct sk_buff *skb,
105 int local); 105 struct mfc_cache *cache, int local);
106static int ipmr_cache_report(struct mr_table *mrt, 106static int ipmr_cache_report(struct mr_table *mrt,
107 struct sk_buff *pkt, vifi_t vifi, int assert); 107 struct sk_buff *pkt, vifi_t vifi, int assert);
108static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, 108static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb,
@@ -501,7 +501,7 @@ static void reg_vif_setup(struct net_device *dev)
501 dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr) - 8; 501 dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr) - 8;
502 dev->flags = IFF_NOARP; 502 dev->flags = IFF_NOARP;
503 dev->netdev_ops = &reg_vif_netdev_ops; 503 dev->netdev_ops = &reg_vif_netdev_ops;
504 dev->destructor = free_netdev; 504 dev->needs_free_netdev = true;
505 dev->features |= NETIF_F_NETNS_LOCAL; 505 dev->features |= NETIF_F_NETNS_LOCAL;
506} 506}
507 507
@@ -988,7 +988,7 @@ static void ipmr_cache_resolve(struct net *net, struct mr_table *mrt,
988 988
989 rtnl_unicast(skb, net, NETLINK_CB(skb).portid); 989 rtnl_unicast(skb, net, NETLINK_CB(skb).portid);
990 } else { 990 } else {
991 ip_mr_forward(net, mrt, skb, c, 0); 991 ip_mr_forward(net, mrt, skb->dev, skb, c, 0);
992 } 992 }
993 } 993 }
994} 994}
@@ -1073,7 +1073,7 @@ static int ipmr_cache_report(struct mr_table *mrt,
1073 1073
1074/* Queue a packet for resolution. It gets locked cache entry! */ 1074/* Queue a packet for resolution. It gets locked cache entry! */
1075static int ipmr_cache_unresolved(struct mr_table *mrt, vifi_t vifi, 1075static int ipmr_cache_unresolved(struct mr_table *mrt, vifi_t vifi,
1076 struct sk_buff *skb) 1076 struct sk_buff *skb, struct net_device *dev)
1077{ 1077{
1078 const struct iphdr *iph = ip_hdr(skb); 1078 const struct iphdr *iph = ip_hdr(skb);
1079 struct mfc_cache *c; 1079 struct mfc_cache *c;
@@ -1130,6 +1130,10 @@ static int ipmr_cache_unresolved(struct mr_table *mrt, vifi_t vifi,
1130 kfree_skb(skb); 1130 kfree_skb(skb);
1131 err = -ENOBUFS; 1131 err = -ENOBUFS;
1132 } else { 1132 } else {
1133 if (dev) {
1134 skb->dev = dev;
1135 skb->skb_iif = dev->ifindex;
1136 }
1133 skb_queue_tail(&c->mfc_un.unres.unresolved, skb); 1137 skb_queue_tail(&c->mfc_un.unres.unresolved, skb);
1134 err = 0; 1138 err = 0;
1135 } 1139 }
@@ -1828,10 +1832,10 @@ static int ipmr_find_vif(struct mr_table *mrt, struct net_device *dev)
1828 1832
1829/* "local" means that we should preserve one skb (for local delivery) */ 1833/* "local" means that we should preserve one skb (for local delivery) */
1830static void ip_mr_forward(struct net *net, struct mr_table *mrt, 1834static void ip_mr_forward(struct net *net, struct mr_table *mrt,
1831 struct sk_buff *skb, struct mfc_cache *cache, 1835 struct net_device *dev, struct sk_buff *skb,
1832 int local) 1836 struct mfc_cache *cache, int local)
1833{ 1837{
1834 int true_vifi = ipmr_find_vif(mrt, skb->dev); 1838 int true_vifi = ipmr_find_vif(mrt, dev);
1835 int psend = -1; 1839 int psend = -1;
1836 int vif, ct; 1840 int vif, ct;
1837 1841
@@ -1853,13 +1857,7 @@ static void ip_mr_forward(struct net *net, struct mr_table *mrt,
1853 } 1857 }
1854 1858
1855 /* Wrong interface: drop packet and (maybe) send PIM assert. */ 1859 /* Wrong interface: drop packet and (maybe) send PIM assert. */
1856 if (mrt->vif_table[vif].dev != skb->dev) { 1860 if (mrt->vif_table[vif].dev != dev) {
1857 struct net_device *mdev;
1858
1859 mdev = l3mdev_master_dev_rcu(mrt->vif_table[vif].dev);
1860 if (mdev == skb->dev)
1861 goto forward;
1862
1863 if (rt_is_output_route(skb_rtable(skb))) { 1861 if (rt_is_output_route(skb_rtable(skb))) {
1864 /* It is our own packet, looped back. 1862 /* It is our own packet, looped back.
1865 * Very complicated situation... 1863 * Very complicated situation...
@@ -2053,7 +2051,7 @@ int ip_mr_input(struct sk_buff *skb)
2053 read_lock(&mrt_lock); 2051 read_lock(&mrt_lock);
2054 vif = ipmr_find_vif(mrt, dev); 2052 vif = ipmr_find_vif(mrt, dev);
2055 if (vif >= 0) { 2053 if (vif >= 0) {
2056 int err2 = ipmr_cache_unresolved(mrt, vif, skb); 2054 int err2 = ipmr_cache_unresolved(mrt, vif, skb, dev);
2057 read_unlock(&mrt_lock); 2055 read_unlock(&mrt_lock);
2058 2056
2059 return err2; 2057 return err2;
@@ -2064,7 +2062,7 @@ int ip_mr_input(struct sk_buff *skb)
2064 } 2062 }
2065 2063
2066 read_lock(&mrt_lock); 2064 read_lock(&mrt_lock);
2067 ip_mr_forward(net, mrt, skb, cache, local); 2065 ip_mr_forward(net, mrt, dev, skb, cache, local);
2068 read_unlock(&mrt_lock); 2066 read_unlock(&mrt_lock);
2069 2067
2070 if (local) 2068 if (local)
@@ -2238,7 +2236,7 @@ int ipmr_get_route(struct net *net, struct sk_buff *skb,
2238 iph->saddr = saddr; 2236 iph->saddr = saddr;
2239 iph->daddr = daddr; 2237 iph->daddr = daddr;
2240 iph->version = 0; 2238 iph->version = 0;
2241 err = ipmr_cache_unresolved(mrt, vif, skb2); 2239 err = ipmr_cache_unresolved(mrt, vif, skb2, dev);
2242 read_unlock(&mrt_lock); 2240 read_unlock(&mrt_lock);
2243 rcu_read_unlock(); 2241 rcu_read_unlock();
2244 return err; 2242 return err;
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 230b5aac9f03..8d7b113958b1 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -491,7 +491,7 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
491 local_bh_disable(); 491 local_bh_disable();
492 492
493 /* Check global sysctl_icmp_msgs_per_sec ratelimit */ 493 /* Check global sysctl_icmp_msgs_per_sec ratelimit */
494 if (!icmpv6_global_allow(type)) 494 if (!(skb->dev->flags&IFF_LOOPBACK) && !icmpv6_global_allow(type))
495 goto out_bh_enable; 495 goto out_bh_enable;
496 496
497 mip6_addr_swap(skb); 497 mip6_addr_swap(skb);
diff --git a/net/ipv6/ila/ila_xlat.c b/net/ipv6/ila/ila_xlat.c
index 2fd5ca151dcf..77f7f8c7d93d 100644
--- a/net/ipv6/ila/ila_xlat.c
+++ b/net/ipv6/ila/ila_xlat.c
@@ -62,6 +62,7 @@ static inline u32 ila_locator_hash(struct ila_locator loc)
62{ 62{
63 u32 *v = (u32 *)loc.v32; 63 u32 *v = (u32 *)loc.v32;
64 64
65 __ila_hash_secret_init();
65 return jhash_2words(v[0], v[1], hashrnd); 66 return jhash_2words(v[0], v[1], hashrnd);
66} 67}
67 68
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 0c5b4caa1949..64eea3962733 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -991,13 +991,13 @@ static void ip6gre_dev_free(struct net_device *dev)
991 991
992 dst_cache_destroy(&t->dst_cache); 992 dst_cache_destroy(&t->dst_cache);
993 free_percpu(dev->tstats); 993 free_percpu(dev->tstats);
994 free_netdev(dev);
995} 994}
996 995
997static void ip6gre_tunnel_setup(struct net_device *dev) 996static void ip6gre_tunnel_setup(struct net_device *dev)
998{ 997{
999 dev->netdev_ops = &ip6gre_netdev_ops; 998 dev->netdev_ops = &ip6gre_netdev_ops;
1000 dev->destructor = ip6gre_dev_free; 999 dev->needs_free_netdev = true;
1000 dev->priv_destructor = ip6gre_dev_free;
1001 1001
1002 dev->type = ARPHRD_IP6GRE; 1002 dev->type = ARPHRD_IP6GRE;
1003 1003
@@ -1148,7 +1148,7 @@ static int __net_init ip6gre_init_net(struct net *net)
1148 return 0; 1148 return 0;
1149 1149
1150err_reg_dev: 1150err_reg_dev:
1151 ip6gre_dev_free(ign->fb_tunnel_dev); 1151 free_netdev(ign->fb_tunnel_dev);
1152err_alloc_dev: 1152err_alloc_dev:
1153 return err; 1153 return err;
1154} 1154}
@@ -1300,7 +1300,8 @@ static void ip6gre_tap_setup(struct net_device *dev)
1300 ether_setup(dev); 1300 ether_setup(dev);
1301 1301
1302 dev->netdev_ops = &ip6gre_tap_netdev_ops; 1302 dev->netdev_ops = &ip6gre_tap_netdev_ops;
1303 dev->destructor = ip6gre_dev_free; 1303 dev->needs_free_netdev = true;
1304 dev->priv_destructor = ip6gre_dev_free;
1304 1305
1305 dev->features |= NETIF_F_NETNS_LOCAL; 1306 dev->features |= NETIF_F_NETNS_LOCAL;
1306 dev->priv_flags &= ~IFF_TX_SKB_SHARING; 1307 dev->priv_flags &= ~IFF_TX_SKB_SHARING;
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 9b37f9747fc6..c3581973f5d7 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -254,7 +254,6 @@ static void ip6_dev_free(struct net_device *dev)
254 gro_cells_destroy(&t->gro_cells); 254 gro_cells_destroy(&t->gro_cells);
255 dst_cache_destroy(&t->dst_cache); 255 dst_cache_destroy(&t->dst_cache);
256 free_percpu(dev->tstats); 256 free_percpu(dev->tstats);
257 free_netdev(dev);
258} 257}
259 258
260static int ip6_tnl_create2(struct net_device *dev) 259static int ip6_tnl_create2(struct net_device *dev)
@@ -322,7 +321,7 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
322 return t; 321 return t;
323 322
324failed_free: 323failed_free:
325 ip6_dev_free(dev); 324 free_netdev(dev);
326failed: 325failed:
327 return ERR_PTR(err); 326 return ERR_PTR(err);
328} 327}
@@ -1777,7 +1776,8 @@ static const struct net_device_ops ip6_tnl_netdev_ops = {
1777static void ip6_tnl_dev_setup(struct net_device *dev) 1776static void ip6_tnl_dev_setup(struct net_device *dev)
1778{ 1777{
1779 dev->netdev_ops = &ip6_tnl_netdev_ops; 1778 dev->netdev_ops = &ip6_tnl_netdev_ops;
1780 dev->destructor = ip6_dev_free; 1779 dev->needs_free_netdev = true;
1780 dev->priv_destructor = ip6_dev_free;
1781 1781
1782 dev->type = ARPHRD_TUNNEL6; 1782 dev->type = ARPHRD_TUNNEL6;
1783 dev->flags |= IFF_NOARP; 1783 dev->flags |= IFF_NOARP;
@@ -2224,7 +2224,7 @@ static int __net_init ip6_tnl_init_net(struct net *net)
2224 return 0; 2224 return 0;
2225 2225
2226err_register: 2226err_register:
2227 ip6_dev_free(ip6n->fb_tnl_dev); 2227 free_netdev(ip6n->fb_tnl_dev);
2228err_alloc_dev: 2228err_alloc_dev:
2229 return err; 2229 return err;
2230} 2230}
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index d67ef56454b2..837ea1eefe7f 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -180,7 +180,6 @@ vti6_tnl_unlink(struct vti6_net *ip6n, struct ip6_tnl *t)
180static void vti6_dev_free(struct net_device *dev) 180static void vti6_dev_free(struct net_device *dev)
181{ 181{
182 free_percpu(dev->tstats); 182 free_percpu(dev->tstats);
183 free_netdev(dev);
184} 183}
185 184
186static int vti6_tnl_create2(struct net_device *dev) 185static int vti6_tnl_create2(struct net_device *dev)
@@ -235,7 +234,7 @@ static struct ip6_tnl *vti6_tnl_create(struct net *net, struct __ip6_tnl_parm *p
235 return t; 234 return t;
236 235
237failed_free: 236failed_free:
238 vti6_dev_free(dev); 237 free_netdev(dev);
239failed: 238failed:
240 return NULL; 239 return NULL;
241} 240}
@@ -842,7 +841,8 @@ static const struct net_device_ops vti6_netdev_ops = {
842static void vti6_dev_setup(struct net_device *dev) 841static void vti6_dev_setup(struct net_device *dev)
843{ 842{
844 dev->netdev_ops = &vti6_netdev_ops; 843 dev->netdev_ops = &vti6_netdev_ops;
845 dev->destructor = vti6_dev_free; 844 dev->needs_free_netdev = true;
845 dev->priv_destructor = vti6_dev_free;
846 846
847 dev->type = ARPHRD_TUNNEL6; 847 dev->type = ARPHRD_TUNNEL6;
848 dev->hard_header_len = LL_MAX_HEADER + sizeof(struct ipv6hdr); 848 dev->hard_header_len = LL_MAX_HEADER + sizeof(struct ipv6hdr);
@@ -1100,7 +1100,7 @@ static int __net_init vti6_init_net(struct net *net)
1100 return 0; 1100 return 0;
1101 1101
1102err_register: 1102err_register:
1103 vti6_dev_free(ip6n->fb_tnl_dev); 1103 free_netdev(ip6n->fb_tnl_dev);
1104err_alloc_dev: 1104err_alloc_dev:
1105 return err; 1105 return err;
1106} 1106}
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 374997d26488..2ecb39b943b5 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -733,7 +733,7 @@ static void reg_vif_setup(struct net_device *dev)
733 dev->mtu = 1500 - sizeof(struct ipv6hdr) - 8; 733 dev->mtu = 1500 - sizeof(struct ipv6hdr) - 8;
734 dev->flags = IFF_NOARP; 734 dev->flags = IFF_NOARP;
735 dev->netdev_ops = &reg_vif_netdev_ops; 735 dev->netdev_ops = &reg_vif_netdev_ops;
736 dev->destructor = free_netdev; 736 dev->needs_free_netdev = true;
737 dev->features |= NETIF_F_NETNS_LOCAL; 737 dev->features |= NETIF_F_NETNS_LOCAL;
738} 738}
739 739
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index cc8e3ae9ca73..e88bcb8ff0fd 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -219,7 +219,7 @@ static void snmp6_seq_show_item64(struct seq_file *seq, void __percpu *mib,
219 u64 buff64[SNMP_MIB_MAX]; 219 u64 buff64[SNMP_MIB_MAX];
220 int i; 220 int i;
221 221
222 memset(buff64, 0, sizeof(unsigned long) * SNMP_MIB_MAX); 222 memset(buff64, 0, sizeof(u64) * SNMP_MIB_MAX);
223 223
224 snmp_get_cpu_field64_batch(buff64, itemlist, mib, syncpoff); 224 snmp_get_cpu_field64_batch(buff64, itemlist, mib, syncpoff);
225 for (i = 0; itemlist[i].name; i++) 225 for (i = 0; itemlist[i].name; i++)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index dc61b0b5e64e..7cebd954d5bb 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2804,6 +2804,7 @@ static int fib6_ifdown(struct rt6_info *rt, void *arg)
2804 if ((rt->dst.dev == dev || !dev) && 2804 if ((rt->dst.dev == dev || !dev) &&
2805 rt != adn->net->ipv6.ip6_null_entry && 2805 rt != adn->net->ipv6.ip6_null_entry &&
2806 (rt->rt6i_nsiblings == 0 || 2806 (rt->rt6i_nsiblings == 0 ||
2807 (dev && netdev_unregistering(dev)) ||
2807 !rt->rt6i_idev->cnf.ignore_routes_with_linkdown)) 2808 !rt->rt6i_idev->cnf.ignore_routes_with_linkdown))
2808 return -1; 2809 return -1;
2809 2810
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 61e5902f0687..2378503577b0 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -265,7 +265,7 @@ static struct ip_tunnel *ipip6_tunnel_locate(struct net *net,
265 return nt; 265 return nt;
266 266
267failed_free: 267failed_free:
268 ipip6_dev_free(dev); 268 free_netdev(dev);
269failed: 269failed:
270 return NULL; 270 return NULL;
271} 271}
@@ -1336,7 +1336,6 @@ static void ipip6_dev_free(struct net_device *dev)
1336 1336
1337 dst_cache_destroy(&tunnel->dst_cache); 1337 dst_cache_destroy(&tunnel->dst_cache);
1338 free_percpu(dev->tstats); 1338 free_percpu(dev->tstats);
1339 free_netdev(dev);
1340} 1339}
1341 1340
1342#define SIT_FEATURES (NETIF_F_SG | \ 1341#define SIT_FEATURES (NETIF_F_SG | \
@@ -1351,7 +1350,8 @@ static void ipip6_tunnel_setup(struct net_device *dev)
1351 int t_hlen = tunnel->hlen + sizeof(struct iphdr); 1350 int t_hlen = tunnel->hlen + sizeof(struct iphdr);
1352 1351
1353 dev->netdev_ops = &ipip6_netdev_ops; 1352 dev->netdev_ops = &ipip6_netdev_ops;
1354 dev->destructor = ipip6_dev_free; 1353 dev->needs_free_netdev = true;
1354 dev->priv_destructor = ipip6_dev_free;
1355 1355
1356 dev->type = ARPHRD_SIT; 1356 dev->type = ARPHRD_SIT;
1357 dev->hard_header_len = LL_MAX_HEADER + t_hlen; 1357 dev->hard_header_len = LL_MAX_HEADER + t_hlen;
diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c
index 74d09f91709e..3be852808a9d 100644
--- a/net/irda/irlan/irlan_eth.c
+++ b/net/irda/irlan/irlan_eth.c
@@ -65,7 +65,7 @@ static void irlan_eth_setup(struct net_device *dev)
65 ether_setup(dev); 65 ether_setup(dev);
66 66
67 dev->netdev_ops = &irlan_eth_netdev_ops; 67 dev->netdev_ops = &irlan_eth_netdev_ops;
68 dev->destructor = free_netdev; 68 dev->needs_free_netdev = true;
69 dev->min_mtu = 0; 69 dev->min_mtu = 0;
70 dev->max_mtu = ETH_MAX_MTU; 70 dev->max_mtu = ETH_MAX_MTU;
71 71
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index 8b21af7321b9..4de2ec94b08c 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -114,12 +114,13 @@ static void l2tp_eth_get_stats64(struct net_device *dev,
114{ 114{
115 struct l2tp_eth *priv = netdev_priv(dev); 115 struct l2tp_eth *priv = netdev_priv(dev);
116 116
117 stats->tx_bytes = atomic_long_read(&priv->tx_bytes); 117 stats->tx_bytes = (unsigned long) atomic_long_read(&priv->tx_bytes);
118 stats->tx_packets = atomic_long_read(&priv->tx_packets); 118 stats->tx_packets = (unsigned long) atomic_long_read(&priv->tx_packets);
119 stats->tx_dropped = atomic_long_read(&priv->tx_dropped); 119 stats->tx_dropped = (unsigned long) atomic_long_read(&priv->tx_dropped);
120 stats->rx_bytes = atomic_long_read(&priv->rx_bytes); 120 stats->rx_bytes = (unsigned long) atomic_long_read(&priv->rx_bytes);
121 stats->rx_packets = atomic_long_read(&priv->rx_packets); 121 stats->rx_packets = (unsigned long) atomic_long_read(&priv->rx_packets);
122 stats->rx_errors = atomic_long_read(&priv->rx_errors); 122 stats->rx_errors = (unsigned long) atomic_long_read(&priv->rx_errors);
123
123} 124}
124 125
125static const struct net_device_ops l2tp_eth_netdev_ops = { 126static const struct net_device_ops l2tp_eth_netdev_ops = {
@@ -141,7 +142,7 @@ static void l2tp_eth_dev_setup(struct net_device *dev)
141 dev->priv_flags &= ~IFF_TX_SKB_SHARING; 142 dev->priv_flags &= ~IFF_TX_SKB_SHARING;
142 dev->features |= NETIF_F_LLTX; 143 dev->features |= NETIF_F_LLTX;
143 dev->netdev_ops = &l2tp_eth_netdev_ops; 144 dev->netdev_ops = &l2tp_eth_netdev_ops;
144 dev->destructor = free_netdev; 145 dev->needs_free_netdev = true;
145} 146}
146 147
147static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, int data_len) 148static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, int data_len)
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 6c2e6060cd54..4a388fe8c2d1 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -902,6 +902,8 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
902 default: 902 default:
903 return -EINVAL; 903 return -EINVAL;
904 } 904 }
905 sdata->u.ap.req_smps = sdata->smps_mode;
906
905 sdata->needed_rx_chains = sdata->local->rx_chains; 907 sdata->needed_rx_chains = sdata->local->rx_chains;
906 908
907 sdata->vif.bss_conf.beacon_int = params->beacon_interval; 909 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 665501ac358f..5e002f62c235 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1531,7 +1531,7 @@ ieee80211_have_rx_timestamp(struct ieee80211_rx_status *status)
1531 return true; 1531 return true;
1532 /* can't handle non-legacy preamble yet */ 1532 /* can't handle non-legacy preamble yet */
1533 if (status->flag & RX_FLAG_MACTIME_PLCP_START && 1533 if (status->flag & RX_FLAG_MACTIME_PLCP_START &&
1534 status->encoding != RX_ENC_LEGACY) 1534 status->encoding == RX_ENC_LEGACY)
1535 return true; 1535 return true;
1536 return false; 1536 return false;
1537} 1537}
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 8fae1a72e6a7..f5f50150ba1c 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1213,7 +1213,6 @@ static const struct net_device_ops ieee80211_monitorif_ops = {
1213static void ieee80211_if_free(struct net_device *dev) 1213static void ieee80211_if_free(struct net_device *dev)
1214{ 1214{
1215 free_percpu(dev->tstats); 1215 free_percpu(dev->tstats);
1216 free_netdev(dev);
1217} 1216}
1218 1217
1219static void ieee80211_if_setup(struct net_device *dev) 1218static void ieee80211_if_setup(struct net_device *dev)
@@ -1221,7 +1220,8 @@ static void ieee80211_if_setup(struct net_device *dev)
1221 ether_setup(dev); 1220 ether_setup(dev);
1222 dev->priv_flags &= ~IFF_TX_SKB_SHARING; 1221 dev->priv_flags &= ~IFF_TX_SKB_SHARING;
1223 dev->netdev_ops = &ieee80211_dataif_ops; 1222 dev->netdev_ops = &ieee80211_dataif_ops;
1224 dev->destructor = ieee80211_if_free; 1223 dev->needs_free_netdev = true;
1224 dev->priv_destructor = ieee80211_if_free;
1225} 1225}
1226 1226
1227static void ieee80211_if_setup_no_queue(struct net_device *dev) 1227static void ieee80211_if_setup_no_queue(struct net_device *dev)
@@ -1816,6 +1816,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
1816 ret = dev_alloc_name(ndev, ndev->name); 1816 ret = dev_alloc_name(ndev, ndev->name);
1817 if (ret < 0) { 1817 if (ret < 0) {
1818 ieee80211_if_free(ndev); 1818 ieee80211_if_free(ndev);
1819 free_netdev(ndev);
1819 return ret; 1820 return ret;
1820 } 1821 }
1821 1822
@@ -1905,7 +1906,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
1905 1906
1906 ret = register_netdevice(ndev); 1907 ret = register_netdevice(ndev);
1907 if (ret) { 1908 if (ret) {
1908 ieee80211_if_free(ndev); 1909 free_netdev(ndev);
1909 return ret; 1910 return ret;
1910 } 1911 }
1911 } 1912 }
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 0ea9712bd99e..cc8e6ea1b27e 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -601,7 +601,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
601 struct ieee80211_supported_band *sband; 601 struct ieee80211_supported_band *sband;
602 struct ieee80211_chanctx_conf *chanctx_conf; 602 struct ieee80211_chanctx_conf *chanctx_conf;
603 struct ieee80211_channel *chan; 603 struct ieee80211_channel *chan;
604 u32 rate_flags, rates = 0; 604 u32 rates = 0;
605 605
606 sdata_assert_lock(sdata); 606 sdata_assert_lock(sdata);
607 607
@@ -612,7 +612,6 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
612 return; 612 return;
613 } 613 }
614 chan = chanctx_conf->def.chan; 614 chan = chanctx_conf->def.chan;
615 rate_flags = ieee80211_chandef_rate_flags(&chanctx_conf->def);
616 rcu_read_unlock(); 615 rcu_read_unlock();
617 sband = local->hw.wiphy->bands[chan->band]; 616 sband = local->hw.wiphy->bands[chan->band];
618 shift = ieee80211_vif_get_shift(&sdata->vif); 617 shift = ieee80211_vif_get_shift(&sdata->vif);
@@ -636,9 +635,6 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
636 */ 635 */
637 rates_len = 0; 636 rates_len = 0;
638 for (i = 0; i < sband->n_bitrates; i++) { 637 for (i = 0; i < sband->n_bitrates; i++) {
639 if ((rate_flags & sband->bitrates[i].flags)
640 != rate_flags)
641 continue;
642 rates |= BIT(i); 638 rates |= BIT(i);
643 rates_len++; 639 rates_len++;
644 } 640 }
@@ -2818,7 +2814,7 @@ static void ieee80211_get_rates(struct ieee80211_supported_band *sband,
2818 u32 *rates, u32 *basic_rates, 2814 u32 *rates, u32 *basic_rates,
2819 bool *have_higher_than_11mbit, 2815 bool *have_higher_than_11mbit,
2820 int *min_rate, int *min_rate_index, 2816 int *min_rate, int *min_rate_index,
2821 int shift, u32 rate_flags) 2817 int shift)
2822{ 2818{
2823 int i, j; 2819 int i, j;
2824 2820
@@ -2846,8 +2842,6 @@ static void ieee80211_get_rates(struct ieee80211_supported_band *sband,
2846 int brate; 2842 int brate;
2847 2843
2848 br = &sband->bitrates[j]; 2844 br = &sband->bitrates[j];
2849 if ((rate_flags & br->flags) != rate_flags)
2850 continue;
2851 2845
2852 brate = DIV_ROUND_UP(br->bitrate, (1 << shift) * 5); 2846 brate = DIV_ROUND_UP(br->bitrate, (1 << shift) * 5);
2853 if (brate == rate) { 2847 if (brate == rate) {
@@ -4398,40 +4392,32 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
4398 return -ENOMEM; 4392 return -ENOMEM;
4399 } 4393 }
4400 4394
4401 if (new_sta || override) { 4395 /*
4402 err = ieee80211_prep_channel(sdata, cbss); 4396 * Set up the information for the new channel before setting the
4403 if (err) { 4397 * new channel. We can't - completely race-free - change the basic
4404 if (new_sta) 4398 * rates bitmap and the channel (sband) that it refers to, but if
4405 sta_info_free(local, new_sta); 4399 * we set it up before we at least avoid calling into the driver's
4406 return -EINVAL; 4400 * bss_info_changed() method with invalid information (since we do
4407 } 4401 * call that from changing the channel - only for IDLE and perhaps
4408 } 4402 * some others, but ...).
4409 4403 *
4404 * So to avoid that, just set up all the new information before the
4405 * channel, but tell the driver to apply it only afterwards, since
4406 * it might need the new channel for that.
4407 */
4410 if (new_sta) { 4408 if (new_sta) {
4411 u32 rates = 0, basic_rates = 0; 4409 u32 rates = 0, basic_rates = 0;
4412 bool have_higher_than_11mbit; 4410 bool have_higher_than_11mbit;
4413 int min_rate = INT_MAX, min_rate_index = -1; 4411 int min_rate = INT_MAX, min_rate_index = -1;
4414 struct ieee80211_chanctx_conf *chanctx_conf;
4415 const struct cfg80211_bss_ies *ies; 4412 const struct cfg80211_bss_ies *ies;
4416 int shift = ieee80211_vif_get_shift(&sdata->vif); 4413 int shift = ieee80211_vif_get_shift(&sdata->vif);
4417 u32 rate_flags;
4418
4419 rcu_read_lock();
4420 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
4421 if (WARN_ON(!chanctx_conf)) {
4422 rcu_read_unlock();
4423 sta_info_free(local, new_sta);
4424 return -EINVAL;
4425 }
4426 rate_flags = ieee80211_chandef_rate_flags(&chanctx_conf->def);
4427 rcu_read_unlock();
4428 4414
4429 ieee80211_get_rates(sband, bss->supp_rates, 4415 ieee80211_get_rates(sband, bss->supp_rates,
4430 bss->supp_rates_len, 4416 bss->supp_rates_len,
4431 &rates, &basic_rates, 4417 &rates, &basic_rates,
4432 &have_higher_than_11mbit, 4418 &have_higher_than_11mbit,
4433 &min_rate, &min_rate_index, 4419 &min_rate, &min_rate_index,
4434 shift, rate_flags); 4420 shift);
4435 4421
4436 /* 4422 /*
4437 * This used to be a workaround for basic rates missing 4423 * This used to be a workaround for basic rates missing
@@ -4489,8 +4475,22 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
4489 sdata->vif.bss_conf.sync_dtim_count = 0; 4475 sdata->vif.bss_conf.sync_dtim_count = 0;
4490 } 4476 }
4491 rcu_read_unlock(); 4477 rcu_read_unlock();
4478 }
4492 4479
4493 /* tell driver about BSSID, basic rates and timing */ 4480 if (new_sta || override) {
4481 err = ieee80211_prep_channel(sdata, cbss);
4482 if (err) {
4483 if (new_sta)
4484 sta_info_free(local, new_sta);
4485 return -EINVAL;
4486 }
4487 }
4488
4489 if (new_sta) {
4490 /*
4491 * tell driver about BSSID, basic rates and timing
4492 * this was set up above, before setting the channel
4493 */
4494 ieee80211_bss_info_change_notify(sdata, 4494 ieee80211_bss_info_change_notify(sdata,
4495 BSS_CHANGED_BSSID | BSS_CHANGED_BASIC_RATES | 4495 BSS_CHANGED_BSSID | BSS_CHANGED_BASIC_RATES |
4496 BSS_CHANGED_BEACON_INT); 4496 BSS_CHANGED_BEACON_INT);
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 1f75280ba26c..3674fe3d67dc 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1613,12 +1613,16 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
1613 */ 1613 */
1614 if (!ieee80211_hw_check(&sta->local->hw, AP_LINK_PS) && 1614 if (!ieee80211_hw_check(&sta->local->hw, AP_LINK_PS) &&
1615 !ieee80211_has_morefrags(hdr->frame_control) && 1615 !ieee80211_has_morefrags(hdr->frame_control) &&
1616 !ieee80211_is_back_req(hdr->frame_control) &&
1616 !(status->rx_flags & IEEE80211_RX_DEFERRED_RELEASE) && 1617 !(status->rx_flags & IEEE80211_RX_DEFERRED_RELEASE) &&
1617 (rx->sdata->vif.type == NL80211_IFTYPE_AP || 1618 (rx->sdata->vif.type == NL80211_IFTYPE_AP ||
1618 rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) && 1619 rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
1619 /* PM bit is only checked in frames where it isn't reserved, 1620 /*
1621 * PM bit is only checked in frames where it isn't reserved,
1620 * in AP mode it's reserved in non-bufferable management frames 1622 * in AP mode it's reserved in non-bufferable management frames
1621 * (cf. IEEE 802.11-2012 8.2.4.1.7 Power Management field) 1623 * (cf. IEEE 802.11-2012 8.2.4.1.7 Power Management field)
1624 * BAR frames should be ignored as specified in
1625 * IEEE 802.11-2012 10.2.1.2.
1622 */ 1626 */
1623 (!ieee80211_is_mgmt(hdr->frame_control) || 1627 (!ieee80211_is_mgmt(hdr->frame_control) ||
1624 ieee80211_is_bufferable_mmpdu(hdr->frame_control))) { 1628 ieee80211_is_bufferable_mmpdu(hdr->frame_control))) {
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index c1ef22df865f..cc19614ff4e6 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -17,6 +17,7 @@
17#include <asm/unaligned.h> 17#include <asm/unaligned.h>
18#include <net/mac80211.h> 18#include <net/mac80211.h>
19#include <crypto/aes.h> 19#include <crypto/aes.h>
20#include <crypto/algapi.h>
20 21
21#include "ieee80211_i.h" 22#include "ieee80211_i.h"
22#include "michael.h" 23#include "michael.h"
@@ -153,7 +154,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
153 data_len = skb->len - hdrlen - MICHAEL_MIC_LEN; 154 data_len = skb->len - hdrlen - MICHAEL_MIC_LEN;
154 key = &rx->key->conf.key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY]; 155 key = &rx->key->conf.key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY];
155 michael_mic(key, hdr, data, data_len, mic); 156 michael_mic(key, hdr, data, data_len, mic);
156 if (memcmp(mic, data + data_len, MICHAEL_MIC_LEN) != 0) 157 if (crypto_memneq(mic, data + data_len, MICHAEL_MIC_LEN))
157 goto mic_fail; 158 goto mic_fail;
158 159
159 /* remove Michael MIC from payload */ 160 /* remove Michael MIC from payload */
@@ -1048,7 +1049,7 @@ ieee80211_crypto_aes_cmac_decrypt(struct ieee80211_rx_data *rx)
1048 bip_aad(skb, aad); 1049 bip_aad(skb, aad);
1049 ieee80211_aes_cmac(key->u.aes_cmac.tfm, aad, 1050 ieee80211_aes_cmac(key->u.aes_cmac.tfm, aad,
1050 skb->data + 24, skb->len - 24, mic); 1051 skb->data + 24, skb->len - 24, mic);
1051 if (memcmp(mic, mmie->mic, sizeof(mmie->mic)) != 0) { 1052 if (crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) {
1052 key->u.aes_cmac.icverrors++; 1053 key->u.aes_cmac.icverrors++;
1053 return RX_DROP_UNUSABLE; 1054 return RX_DROP_UNUSABLE;
1054 } 1055 }
@@ -1098,7 +1099,7 @@ ieee80211_crypto_aes_cmac_256_decrypt(struct ieee80211_rx_data *rx)
1098 bip_aad(skb, aad); 1099 bip_aad(skb, aad);
1099 ieee80211_aes_cmac_256(key->u.aes_cmac.tfm, aad, 1100 ieee80211_aes_cmac_256(key->u.aes_cmac.tfm, aad,
1100 skb->data + 24, skb->len - 24, mic); 1101 skb->data + 24, skb->len - 24, mic);
1101 if (memcmp(mic, mmie->mic, sizeof(mmie->mic)) != 0) { 1102 if (crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) {
1102 key->u.aes_cmac.icverrors++; 1103 key->u.aes_cmac.icverrors++;
1103 return RX_DROP_UNUSABLE; 1104 return RX_DROP_UNUSABLE;
1104 } 1105 }
@@ -1202,7 +1203,7 @@ ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx)
1202 if (ieee80211_aes_gmac(key->u.aes_gmac.tfm, aad, nonce, 1203 if (ieee80211_aes_gmac(key->u.aes_gmac.tfm, aad, nonce,
1203 skb->data + 24, skb->len - 24, 1204 skb->data + 24, skb->len - 24,
1204 mic) < 0 || 1205 mic) < 0 ||
1205 memcmp(mic, mmie->mic, sizeof(mmie->mic)) != 0) { 1206 crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) {
1206 key->u.aes_gmac.icverrors++; 1207 key->u.aes_gmac.icverrors++;
1207 return RX_DROP_UNUSABLE; 1208 return RX_DROP_UNUSABLE;
1208 } 1209 }
diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
index 06019dba4b10..bd88a9b80773 100644
--- a/net/mac802154/iface.c
+++ b/net/mac802154/iface.c
@@ -526,8 +526,6 @@ static void mac802154_wpan_free(struct net_device *dev)
526 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); 526 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
527 527
528 mac802154_llsec_destroy(&sdata->sec); 528 mac802154_llsec_destroy(&sdata->sec);
529
530 free_netdev(dev);
531} 529}
532 530
533static void ieee802154_if_setup(struct net_device *dev) 531static void ieee802154_if_setup(struct net_device *dev)
@@ -593,7 +591,8 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata,
593 sdata->dev->dev_addr); 591 sdata->dev->dev_addr);
594 592
595 sdata->dev->header_ops = &mac802154_header_ops; 593 sdata->dev->header_ops = &mac802154_header_ops;
596 sdata->dev->destructor = mac802154_wpan_free; 594 sdata->dev->needs_free_netdev = true;
595 sdata->dev->priv_destructor = mac802154_wpan_free;
597 sdata->dev->netdev_ops = &mac802154_wpan_ops; 596 sdata->dev->netdev_ops = &mac802154_wpan_ops;
598 sdata->dev->ml_priv = &mac802154_mlme_wpan; 597 sdata->dev->ml_priv = &mac802154_mlme_wpan;
599 wpan_dev->promiscuous_mode = false; 598 wpan_dev->promiscuous_mode = false;
@@ -608,7 +607,7 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata,
608 607
609 break; 608 break;
610 case NL802154_IFTYPE_MONITOR: 609 case NL802154_IFTYPE_MONITOR:
611 sdata->dev->destructor = free_netdev; 610 sdata->dev->needs_free_netdev = true;
612 sdata->dev->netdev_ops = &mac802154_monitor_ops; 611 sdata->dev->netdev_ops = &mac802154_monitor_ops;
613 wpan_dev->promiscuous_mode = true; 612 wpan_dev->promiscuous_mode = true;
614 break; 613 break;
diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c
index 89193a634da4..04a3128adcf0 100644
--- a/net/openvswitch/vport-internal_dev.c
+++ b/net/openvswitch/vport-internal_dev.c
@@ -94,7 +94,6 @@ static void internal_dev_destructor(struct net_device *dev)
94 struct vport *vport = ovs_internal_dev_get_vport(dev); 94 struct vport *vport = ovs_internal_dev_get_vport(dev);
95 95
96 ovs_vport_free(vport); 96 ovs_vport_free(vport);
97 free_netdev(dev);
98} 97}
99 98
100static void 99static void
@@ -156,7 +155,8 @@ static void do_setup(struct net_device *netdev)
156 netdev->priv_flags &= ~IFF_TX_SKB_SHARING; 155 netdev->priv_flags &= ~IFF_TX_SKB_SHARING;
157 netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_OPENVSWITCH | 156 netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_OPENVSWITCH |
158 IFF_PHONY_HEADROOM | IFF_NO_QUEUE; 157 IFF_PHONY_HEADROOM | IFF_NO_QUEUE;
159 netdev->destructor = internal_dev_destructor; 158 netdev->needs_free_netdev = true;
159 netdev->priv_destructor = internal_dev_destructor;
160 netdev->ethtool_ops = &internal_dev_ethtool_ops; 160 netdev->ethtool_ops = &internal_dev_ethtool_ops;
161 netdev->rtnl_link_ops = &internal_dev_link_ops; 161 netdev->rtnl_link_ops = &internal_dev_link_ops;
162 162
diff --git a/net/phonet/pep-gprs.c b/net/phonet/pep-gprs.c
index 21c28b51be94..2c9337946e30 100644
--- a/net/phonet/pep-gprs.c
+++ b/net/phonet/pep-gprs.c
@@ -236,7 +236,7 @@ static void gprs_setup(struct net_device *dev)
236 dev->tx_queue_len = 10; 236 dev->tx_queue_len = 10;
237 237
238 dev->netdev_ops = &gprs_netdev_ops; 238 dev->netdev_ops = &gprs_netdev_ops;
239 dev->destructor = free_netdev; 239 dev->needs_free_netdev = true;
240} 240}
241 241
242/* 242/*
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
index 164b5ac094be..7dc5892671c8 100644
--- a/net/sched/act_pedit.c
+++ b/net/sched/act_pedit.c
@@ -94,8 +94,10 @@ static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
94 k++; 94 k++;
95 } 95 }
96 96
97 if (n) 97 if (n) {
98 err = -EINVAL;
98 goto err_out; 99 goto err_out;
100 }
99 101
100 return keys_ex; 102 return keys_ex;
101 103
diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index f42008b29311..b062bc80c7cb 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -132,21 +132,21 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla,
132 } 132 }
133 } 133 }
134 134
135 spin_lock_bh(&police->tcf_lock);
136 if (est) { 135 if (est) {
137 err = gen_replace_estimator(&police->tcf_bstats, NULL, 136 err = gen_replace_estimator(&police->tcf_bstats, NULL,
138 &police->tcf_rate_est, 137 &police->tcf_rate_est,
139 &police->tcf_lock, 138 &police->tcf_lock,
140 NULL, est); 139 NULL, est);
141 if (err) 140 if (err)
142 goto failure_unlock; 141 goto failure;
143 } else if (tb[TCA_POLICE_AVRATE] && 142 } else if (tb[TCA_POLICE_AVRATE] &&
144 (ret == ACT_P_CREATED || 143 (ret == ACT_P_CREATED ||
145 !gen_estimator_active(&police->tcf_rate_est))) { 144 !gen_estimator_active(&police->tcf_rate_est))) {
146 err = -EINVAL; 145 err = -EINVAL;
147 goto failure_unlock; 146 goto failure;
148 } 147 }
149 148
149 spin_lock_bh(&police->tcf_lock);
150 /* No failure allowed after this point */ 150 /* No failure allowed after this point */
151 police->tcfp_mtu = parm->mtu; 151 police->tcfp_mtu = parm->mtu;
152 if (police->tcfp_mtu == 0) { 152 if (police->tcfp_mtu == 0) {
@@ -192,8 +192,6 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla,
192 192
193 return ret; 193 return ret;
194 194
195failure_unlock:
196 spin_unlock_bh(&police->tcf_lock);
197failure: 195failure:
198 qdisc_put_rtab(P_tab); 196 qdisc_put_rtab(P_tab);
199 qdisc_put_rtab(R_tab); 197 qdisc_put_rtab(R_tab);
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index f16c8d97b7f3..30aa0a529215 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4622,13 +4622,13 @@ int sctp_for_each_endpoint(int (*cb)(struct sctp_endpoint *, void *),
4622 4622
4623 for (head = sctp_ep_hashtable; hash < sctp_ep_hashsize; 4623 for (head = sctp_ep_hashtable; hash < sctp_ep_hashsize;
4624 hash++, head++) { 4624 hash++, head++) {
4625 read_lock(&head->lock); 4625 read_lock_bh(&head->lock);
4626 sctp_for_each_hentry(epb, &head->chain) { 4626 sctp_for_each_hentry(epb, &head->chain) {
4627 err = cb(sctp_ep(epb), p); 4627 err = cb(sctp_ep(epb), p);
4628 if (err) 4628 if (err)
4629 break; 4629 break;
4630 } 4630 }
4631 read_unlock(&head->lock); 4631 read_unlock_bh(&head->lock);
4632 } 4632 }
4633 4633
4634 return err; 4634 return err;
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index 312ef7de57d7..ab3087687a32 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -508,7 +508,7 @@ bool tipc_msg_reverse(u32 own_node, struct sk_buff **skb, int err)
508 } 508 }
509 509
510 if (skb_cloned(_skb) && 510 if (skb_cloned(_skb) &&
511 pskb_expand_head(_skb, BUF_HEADROOM, BUF_TAILROOM, GFP_KERNEL)) 511 pskb_expand_head(_skb, BUF_HEADROOM, BUF_TAILROOM, GFP_ATOMIC))
512 goto exit; 512 goto exit;
513 513
514 /* Now reverse the concerned fields */ 514 /* Now reverse the concerned fields */
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 6a7fe7660551..1a0c961f4ffe 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -999,7 +999,8 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
999 struct path path = { }; 999 struct path path = { };
1000 1000
1001 err = -EINVAL; 1001 err = -EINVAL;
1002 if (sunaddr->sun_family != AF_UNIX) 1002 if (addr_len < offsetofend(struct sockaddr_un, sun_family) ||
1003 sunaddr->sun_family != AF_UNIX)
1003 goto out; 1004 goto out;
1004 1005
1005 if (addr_len == sizeof(short)) { 1006 if (addr_len == sizeof(short)) {
@@ -1110,6 +1111,10 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
1110 unsigned int hash; 1111 unsigned int hash;
1111 int err; 1112 int err;
1112 1113
1114 err = -EINVAL;
1115 if (alen < offsetofend(struct sockaddr, sa_family))
1116 goto out;
1117
1113 if (addr->sa_family != AF_UNSPEC) { 1118 if (addr->sa_family != AF_UNSPEC) {
1114 err = unix_mkname(sunaddr, alen, &hash); 1119 err = unix_mkname(sunaddr, alen, &hash);
1115 if (err < 0) 1120 if (err < 0)
diff --git a/tools/testing/selftests/bpf/bpf_endian.h b/tools/testing/selftests/bpf/bpf_endian.h
index 19d0604f8694..487cbfb89beb 100644
--- a/tools/testing/selftests/bpf/bpf_endian.h
+++ b/tools/testing/selftests/bpf/bpf_endian.h
@@ -1,23 +1,42 @@
1#ifndef __BPF_ENDIAN__ 1#ifndef __BPF_ENDIAN__
2#define __BPF_ENDIAN__ 2#define __BPF_ENDIAN__
3 3
4#include <asm/byteorder.h> 4#include <linux/swab.h>
5 5
6#if __BYTE_ORDER == __LITTLE_ENDIAN 6/* LLVM's BPF target selects the endianness of the CPU
7# define __bpf_ntohs(x) __builtin_bswap16(x) 7 * it compiles on, or the user specifies (bpfel/bpfeb),
8# define __bpf_htons(x) __builtin_bswap16(x) 8 * respectively. The used __BYTE_ORDER__ is defined by
9#elif __BYTE_ORDER == __BIG_ENDIAN 9 * the compiler, we cannot rely on __BYTE_ORDER from
10# define __bpf_ntohs(x) (x) 10 * libc headers, since it doesn't reflect the actual
11# define __bpf_htons(x) (x) 11 * requested byte order.
12 *
13 * Note, LLVM's BPF target has different __builtin_bswapX()
14 * semantics. It does map to BPF_ALU | BPF_END | BPF_TO_BE
15 * in bpfel and bpfeb case, which means below, that we map
16 * to cpu_to_be16(). We could use it unconditionally in BPF
17 * case, but better not rely on it, so that this header here
18 * can be used from application and BPF program side, which
19 * use different targets.
20 */
21#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
22# define __bpf_ntohs(x) __builtin_bswap16(x)
23# define __bpf_htons(x) __builtin_bswap16(x)
24# define __bpf_constant_ntohs(x) ___constant_swab16(x)
25# define __bpf_constant_htons(x) ___constant_swab16(x)
26#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
27# define __bpf_ntohs(x) (x)
28# define __bpf_htons(x) (x)
29# define __bpf_constant_ntohs(x) (x)
30# define __bpf_constant_htons(x) (x)
12#else 31#else
13# error "Fix your __BYTE_ORDER?!" 32# error "Fix your compiler's __BYTE_ORDER__?!"
14#endif 33#endif
15 34
16#define bpf_htons(x) \ 35#define bpf_htons(x) \
17 (__builtin_constant_p(x) ? \ 36 (__builtin_constant_p(x) ? \
18 __constant_htons(x) : __bpf_htons(x)) 37 __bpf_constant_htons(x) : __bpf_htons(x))
19#define bpf_ntohs(x) \ 38#define bpf_ntohs(x) \
20 (__builtin_constant_p(x) ? \ 39 (__builtin_constant_p(x) ? \
21 __constant_ntohs(x) : __bpf_ntohs(x)) 40 __bpf_constant_ntohs(x) : __bpf_ntohs(x))
22 41
23#endif 42#endif /* __BPF_ENDIAN__ */