aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-05-13 00:10:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-05-13 00:10:38 -0400
commit110bc76729d448fdbcb5cdb63b83d9fd65ce5e26 (patch)
treeb25599bb5e186303ea9c18715a09a0c3278603af
parent6c9d370c16aad97cfc6de68666634eaabac2b048 (diff)
parent01d460dd70adc858e15307332832183c622bee50 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Handle max TX power properly wrt VIFs and the MAC in iwlwifi, from Avri Altman. 2) Use the correct FW API for scan completions in iwlwifi, from Avraham Stern. 3) FW monitor in iwlwifi accidently uses unmapped memory, fix from Liad Kaufman. 4) rhashtable conversion of mac80211 station table was buggy, the virtual interface was not taken into account. Fix from Johannes Berg. 5) Fix deadlock in rtlwifi by not using a zero timeout for usb_control_msg(), from Larry Finger. 6) Update reordering state before calculating loss detection, from Yuchung Cheng. 7) Fix off by one in bluetooth firmward parsing, from Dan Carpenter. 8) Fix extended frame handling in xiling_can driver, from Jeppe Ledet-Pedersen. 9) Fix CODEL packet scheduler behavior in the presence of TSO packets, from Eric Dumazet. 10) Fix NAPI budget testing in fm10k driver, from Alexander Duyck. 11) macvlan needs to propagate promisc settings down the the lower device, from Vlad Yasevich. 12) igb driver can oops when changing number of rings, from Toshiaki Makita. 13) Source specific default routes not handled properly in ipv6, from Markus Stenberg. 14) Use after free in tc_ctl_tfilter(), from WANG Cong. 15) Use softirq spinlocking in netxen driver, from Tony Camuso. 16) Two ARM bpf JIT fixes from Nicolas Schichan. 17) Handle MSG_DONTWAIT properly in ring based AF_PACKET sends, from Mathias Kretschmer. 18) Fix x86 bpf JIT implementation of FROM_{BE16,LE16,LE32}, from Alexei Starovoitov. 19) ll_temac driver DMA maps TX packet header with incorrect length, fix from Michal Simek. 20) We removed pm_qos bits from netdevice.h, but some indirect references remained. Kill them. From David Ahern. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (90 commits) net: Remove remaining remnants of pm_qos from netdevice.h e1000e: Add pm_qos header net: phy: micrel: Fix regression in kszphy_probe net: ll_temac: Fix DMA map size bug x86: bpf_jit: fix FROM_BE16 and FROM_LE16/32 instructions netns: return RTM_NEWNSID instead of RTM_GETNSID on a get Update be2net maintainers' email addresses net_sched: gred: use correct backlog value in WRED mode pppoe: drop pppoe device in pppoe_unbind_sock_work net: qca_spi: Fix possible race during probe net: mdio-gpio: Allow for unspecified bus id af_packet / TX_RING not fully non-blocking (w/ MSG_DONTWAIT). bnx2x: limit fw delay in kdump to 5s after boot ARM: net: delegate filter to kernel interpreter when imm_offset() return value can't fit into 12bits. ARM: net fix emit_udiv() for BPF_ALU | BPF_DIV | BPF_K intruction. mpls: Change reserved label names to be consistent with netbsd usbnet: avoid integer overflow in start_xmit netxen_nic: use spin_[un]lock_bh around tx_clean_lock (2) net: xgene_enet: Set hardware dependency net: amd-xgbe: Add hardware dependency ...
-rw-r--r--MAINTAINERS14
-rw-r--r--arch/arm/net/bpf_jit_32.c42
-rw-r--r--arch/x86/net/bpf_jit_comp.c28
-rw-r--r--drivers/bluetooth/bt3c_cs.c3
-rw-r--r--drivers/bluetooth/btbcm.c148
-rw-r--r--drivers/bluetooth/btbcm.h6
-rw-r--r--drivers/bluetooth/btusb.c403
-rw-r--r--drivers/bluetooth/hci_ath.c98
-rw-r--r--drivers/net/can/xilinx_can.c7
-rw-r--r--drivers/net/dsa/mv88e6xxx.c3
-rw-r--r--drivers/net/ethernet/amd/Kconfig1
-rw-r--r--drivers/net/ethernet/apm/xgene/Kconfig1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c10
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c9
-rw-r--r--drivers/net/ethernet/cadence/macb.c11
-rw-r--r--drivers/net/ethernet/intel/e1000e/e1000.h1
-rw-r--r--drivers/net/ethernet/intel/fm10k/fm10k_main.c4
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c4
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_port.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c14
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c4
-rw-r--r--drivers/net/ethernet/qualcomm/qca_spi.c4
-rw-r--r--drivers/net/ethernet/realtek/r8169.c4
-rw-r--r--drivers/net/ethernet/smsc/smc91x.c20
-rw-r--r--drivers/net/ethernet/smsc/smsc911x.c12
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c1
-rw-r--r--drivers/net/ethernet/xilinx/ll_temac_main.c4
-rw-r--r--drivers/net/hyperv/netvsc.c9
-rw-r--r--drivers/net/ieee802154/at86rf230.c390
-rw-r--r--drivers/net/macvlan.c15
-rw-r--r--drivers/net/phy/Kconfig1
-rw-r--r--drivers/net/phy/mdio-gpio.c5
-rw-r--r--drivers/net/phy/micrel.c3
-rw-r--r--drivers/net/ppp/pppoe.c4
-rw-r--r--drivers/net/usb/r8152.c1
-rw-r--r--drivers/net/usb/usbnet.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c52
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-fw-file.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.h41
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/d3.c2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/fw-api-power.h34
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h44
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/fw-api.h13
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/fw.c54
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mac80211.c26
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mvm.h1
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/ops.c10
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/rx.c5
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/scan.c2
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c17
-rw-r--r--drivers/net/wireless/rtlwifi/usb.c2
-rw-r--r--include/linux/netdevice.h3
-rw-r--r--include/linux/tcp.h8
-rw-r--r--include/net/cfg802154.h2
-rw-r--r--include/net/codel.h10
-rw-r--r--include/net/mac80211.h2
-rw-r--r--include/net/mac802154.h94
-rw-r--r--include/net/tcp.h7
-rw-r--r--include/uapi/linux/inet_diag.h4
-rw-r--r--include/uapi/linux/mpls.h10
-rw-r--r--include/uapi/linux/tcp.h3
-rw-r--r--net/bluetooth/hci_core.c3
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/net_namespace.c2
-rw-r--r--net/core/sock.c2
-rw-r--r--net/ieee802154/Makefile4
-rw-r--r--net/ieee802154/nl-phy.c5
-rw-r--r--net/ieee802154/nl802154.c2
-rw-r--r--net/ieee802154/rdev-ops.h85
-rw-r--r--net/ieee802154/trace.c7
-rw-r--r--net/ieee802154/trace.h247
-rw-r--r--net/ipv4/inet_diag.c8
-rw-r--r--net/ipv4/tcp.c28
-rw-r--r--net/ipv4/tcp_dctcp.c20
-rw-r--r--net/ipv4/tcp_fastopen.c1
-rw-r--r--net/ipv4/tcp_illinois.c21
-rw-r--r--net/ipv4/tcp_input.c36
-rw-r--r--net/ipv4/tcp_vegas.c19
-rw-r--r--net/ipv4/tcp_vegas.h3
-rw-r--r--net/ipv4/tcp_westwood.c15
-rw-r--r--net/ipv6/ip6_output.c39
-rw-r--r--net/ipv6/route.c5
-rw-r--r--net/mac80211/iface.c12
-rw-r--r--net/mac80211/sta_info.c19
-rw-r--r--net/mac802154/cfg.c9
-rw-r--r--net/mac802154/ieee802154_i.h3
-rw-r--r--net/mac802154/iface.c5
-rw-r--r--net/mac802154/llsec.c4
-rw-r--r--net/mac802154/main.c7
-rw-r--r--net/mpls/af_mpls.c18
-rw-r--r--net/mpls/internal.h10
-rw-r--r--net/netlink/af_netlink.c1
-rw-r--r--net/packet/af_packet.c9
-rw-r--r--net/rds/connection.c17
-rw-r--r--net/rds/ib_cm.c13
-rw-r--r--net/rds/tcp_connect.c1
-rw-r--r--net/rds/tcp_listen.c46
-rw-r--r--net/sched/cls_api.c7
-rw-r--r--net/sched/sch_codel.c2
-rw-r--r--net/sched/sch_fq_codel.c2
-rw-r--r--net/sched/sch_gred.c4
102 files changed, 1838 insertions, 645 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 06c0fd52bbfd..5d87ccbee19b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4377,11 +4377,10 @@ F: fs/gfs2/
4377F: include/uapi/linux/gfs2_ondisk.h 4377F: include/uapi/linux/gfs2_ondisk.h
4378 4378
4379GIGASET ISDN DRIVERS 4379GIGASET ISDN DRIVERS
4380M: Hansjoerg Lipp <hjlipp@web.de> 4380M: Paul Bolle <pebolle@tiscali.nl>
4381M: Tilman Schmidt <tilman@imap.cc>
4382L: gigaset307x-common@lists.sourceforge.net 4381L: gigaset307x-common@lists.sourceforge.net
4383W: http://gigaset307x.sourceforge.net/ 4382W: http://gigaset307x.sourceforge.net/
4384S: Maintained 4383S: Odd Fixes
4385F: Documentation/isdn/README.gigaset 4384F: Documentation/isdn/README.gigaset
4386F: drivers/isdn/gigaset/ 4385F: drivers/isdn/gigaset/
4387F: include/uapi/linux/gigaset_dev.h 4386F: include/uapi/linux/gigaset_dev.h
@@ -8827,10 +8826,11 @@ W: http://www.emulex.com
8827S: Supported 8826S: Supported
8828F: drivers/scsi/be2iscsi/ 8827F: drivers/scsi/be2iscsi/
8829 8828
8830SERVER ENGINES 10Gbps NIC - BladeEngine 2 DRIVER 8829Emulex 10Gbps NIC BE2, BE3-R, Lancer, Skyhawk-R DRIVER
8831M: Sathya Perla <sathya.perla@emulex.com> 8830M: Sathya Perla <sathya.perla@avagotech.com>
8832M: Subbu Seetharaman <subbu.seetharaman@emulex.com> 8831M: Ajit Khaparde <ajit.khaparde@avagotech.com>
8833M: Ajit Khaparde <ajit.khaparde@emulex.com> 8832M: Padmanabh Ratnakar <padmanabh.ratnakar@avagotech.com>
8833M: Sriharsha Basavapatna <sriharsha.basavapatna@avagotech.com>
8834L: netdev@vger.kernel.org 8834L: netdev@vger.kernel.org
8835W: http://www.emulex.com 8835W: http://www.emulex.com
8836S: Supported 8836S: Supported
diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
index e1268f905026..e0e23582c8b4 100644
--- a/arch/arm/net/bpf_jit_32.c
+++ b/arch/arm/net/bpf_jit_32.c
@@ -54,6 +54,7 @@
54#define SEEN_DATA (1 << (BPF_MEMWORDS + 3)) 54#define SEEN_DATA (1 << (BPF_MEMWORDS + 3))
55 55
56#define FLAG_NEED_X_RESET (1 << 0) 56#define FLAG_NEED_X_RESET (1 << 0)
57#define FLAG_IMM_OVERFLOW (1 << 1)
57 58
58struct jit_ctx { 59struct jit_ctx {
59 const struct bpf_prog *skf; 60 const struct bpf_prog *skf;
@@ -293,6 +294,15 @@ static u16 imm_offset(u32 k, struct jit_ctx *ctx)
293 /* PC in ARM mode == address of the instruction + 8 */ 294 /* PC in ARM mode == address of the instruction + 8 */
294 imm = offset - (8 + ctx->idx * 4); 295 imm = offset - (8 + ctx->idx * 4);
295 296
297 if (imm & ~0xfff) {
298 /*
299 * literal pool is too far, signal it into flags. we
300 * can only detect it on the second pass unfortunately.
301 */
302 ctx->flags |= FLAG_IMM_OVERFLOW;
303 return 0;
304 }
305
296 return imm; 306 return imm;
297} 307}
298 308
@@ -449,10 +459,21 @@ static inline void emit_udiv(u8 rd, u8 rm, u8 rn, struct jit_ctx *ctx)
449 return; 459 return;
450 } 460 }
451#endif 461#endif
452 if (rm != ARM_R0) 462
453 emit(ARM_MOV_R(ARM_R0, rm), ctx); 463 /*
464 * For BPF_ALU | BPF_DIV | BPF_K instructions, rm is ARM_R4
465 * (r_A) and rn is ARM_R0 (r_scratch) so load rn first into
466 * ARM_R1 to avoid accidentally overwriting ARM_R0 with rm
467 * before using it as a source for ARM_R1.
468 *
469 * For BPF_ALU | BPF_DIV | BPF_X rm is ARM_R4 (r_A) and rn is
470 * ARM_R5 (r_X) so there is no particular register overlap
471 * issues.
472 */
454 if (rn != ARM_R1) 473 if (rn != ARM_R1)
455 emit(ARM_MOV_R(ARM_R1, rn), ctx); 474 emit(ARM_MOV_R(ARM_R1, rn), ctx);
475 if (rm != ARM_R0)
476 emit(ARM_MOV_R(ARM_R0, rm), ctx);
456 477
457 ctx->seen |= SEEN_CALL; 478 ctx->seen |= SEEN_CALL;
458 emit_mov_i(ARM_R3, (u32)jit_udiv, ctx); 479 emit_mov_i(ARM_R3, (u32)jit_udiv, ctx);
@@ -855,6 +876,14 @@ b_epilogue:
855 default: 876 default:
856 return -1; 877 return -1;
857 } 878 }
879
880 if (ctx->flags & FLAG_IMM_OVERFLOW)
881 /*
882 * this instruction generated an overflow when
883 * trying to access the literal pool, so
884 * delegate this filter to the kernel interpreter.
885 */
886 return -1;
858 } 887 }
859 888
860 /* compute offsets only during the first pass */ 889 /* compute offsets only during the first pass */
@@ -917,7 +946,14 @@ void bpf_jit_compile(struct bpf_prog *fp)
917 ctx.idx = 0; 946 ctx.idx = 0;
918 947
919 build_prologue(&ctx); 948 build_prologue(&ctx);
920 build_body(&ctx); 949 if (build_body(&ctx) < 0) {
950#if __LINUX_ARM_ARCH__ < 7
951 if (ctx.imm_count)
952 kfree(ctx.imms);
953#endif
954 bpf_jit_binary_free(header);
955 goto out;
956 }
921 build_epilogue(&ctx); 957 build_epilogue(&ctx);
922 958
923 flush_icache_range((u32)ctx.target, (u32)(ctx.target + ctx.idx)); 959 flush_icache_range((u32)ctx.target, (u32)(ctx.target + ctx.idx));
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 987514396c1e..99f76103c6b7 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -559,6 +559,13 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,
559 if (is_ereg(dst_reg)) 559 if (is_ereg(dst_reg))
560 EMIT1(0x41); 560 EMIT1(0x41);
561 EMIT3(0xC1, add_1reg(0xC8, dst_reg), 8); 561 EMIT3(0xC1, add_1reg(0xC8, dst_reg), 8);
562
563 /* emit 'movzwl eax, ax' */
564 if (is_ereg(dst_reg))
565 EMIT3(0x45, 0x0F, 0xB7);
566 else
567 EMIT2(0x0F, 0xB7);
568 EMIT1(add_2reg(0xC0, dst_reg, dst_reg));
562 break; 569 break;
563 case 32: 570 case 32:
564 /* emit 'bswap eax' to swap lower 4 bytes */ 571 /* emit 'bswap eax' to swap lower 4 bytes */
@@ -577,6 +584,27 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,
577 break; 584 break;
578 585
579 case BPF_ALU | BPF_END | BPF_FROM_LE: 586 case BPF_ALU | BPF_END | BPF_FROM_LE:
587 switch (imm32) {
588 case 16:
589 /* emit 'movzwl eax, ax' to zero extend 16-bit
590 * into 64 bit
591 */
592 if (is_ereg(dst_reg))
593 EMIT3(0x45, 0x0F, 0xB7);
594 else
595 EMIT2(0x0F, 0xB7);
596 EMIT1(add_2reg(0xC0, dst_reg, dst_reg));
597 break;
598 case 32:
599 /* emit 'mov eax, eax' to clear upper 32-bits */
600 if (is_ereg(dst_reg))
601 EMIT1(0x45);
602 EMIT2(0x89, add_2reg(0xC0, dst_reg, dst_reg));
603 break;
604 case 64:
605 /* nop */
606 break;
607 }
580 break; 608 break;
581 609
582 /* ST: *(u8*)(dst_reg + off) = imm */ 610 /* ST: *(u8*)(dst_reg + off) = imm */
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 4f7e8d400bc0..6de97b3871b0 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -227,7 +227,6 @@ static void bt3c_receive(struct bt3c_info *info)
227 iobase = info->p_dev->resource[0]->start; 227 iobase = info->p_dev->resource[0]->start;
228 228
229 avail = bt3c_read(iobase, 0x7006); 229 avail = bt3c_read(iobase, 0x7006);
230 //printk("bt3c_cs: receiving %d bytes\n", avail);
231 230
232 bt3c_address(iobase, 0x7480); 231 bt3c_address(iobase, 0x7480);
233 while (size < avail) { 232 while (size < avail) {
@@ -250,7 +249,6 @@ static void bt3c_receive(struct bt3c_info *info)
250 249
251 bt_cb(info->rx_skb)->pkt_type = inb(iobase + DATA_L); 250 bt_cb(info->rx_skb)->pkt_type = inb(iobase + DATA_L);
252 inb(iobase + DATA_H); 251 inb(iobase + DATA_H);
253 //printk("bt3c: PACKET_TYPE=%02x\n", bt_cb(info->rx_skb)->pkt_type);
254 252
255 switch (bt_cb(info->rx_skb)->pkt_type) { 253 switch (bt_cb(info->rx_skb)->pkt_type) {
256 254
@@ -364,7 +362,6 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst)
364 if (stat & 0x0001) 362 if (stat & 0x0001)
365 bt3c_receive(info); 363 bt3c_receive(info);
366 if (stat & 0x0002) { 364 if (stat & 0x0002) {
367 //BT_ERR("Ack (stat=0x%04x)", stat);
368 clear_bit(XMIT_SENDING, &(info->tx_state)); 365 clear_bit(XMIT_SENDING, &(info->tx_state));
369 bt3c_write_wakeup(info); 366 bt3c_write_wakeup(info);
370 } 367 }
diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index d0741f3ed7ec..4bba86677adc 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -95,6 +95,78 @@ int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
95} 95}
96EXPORT_SYMBOL_GPL(btbcm_set_bdaddr); 96EXPORT_SYMBOL_GPL(btbcm_set_bdaddr);
97 97
98int btbcm_patchram(struct hci_dev *hdev, const char *firmware)
99{
100 const struct hci_command_hdr *cmd;
101 const struct firmware *fw;
102 const u8 *fw_ptr;
103 size_t fw_size;
104 struct sk_buff *skb;
105 u16 opcode;
106 int err;
107
108 err = request_firmware(&fw, firmware, &hdev->dev);
109 if (err < 0) {
110 BT_INFO("%s: BCM: Patch %s not found", hdev->name, firmware);
111 return err;
112 }
113
114 /* Start Download */
115 skb = __hci_cmd_sync(hdev, 0xfc2e, 0, NULL, HCI_INIT_TIMEOUT);
116 if (IS_ERR(skb)) {
117 err = PTR_ERR(skb);
118 BT_ERR("%s: BCM: Download Minidrv command failed (%d)",
119 hdev->name, err);
120 goto done;
121 }
122 kfree_skb(skb);
123
124 /* 50 msec delay after Download Minidrv completes */
125 msleep(50);
126
127 fw_ptr = fw->data;
128 fw_size = fw->size;
129
130 while (fw_size >= sizeof(*cmd)) {
131 const u8 *cmd_param;
132
133 cmd = (struct hci_command_hdr *)fw_ptr;
134 fw_ptr += sizeof(*cmd);
135 fw_size -= sizeof(*cmd);
136
137 if (fw_size < cmd->plen) {
138 BT_ERR("%s: BCM: Patch %s is corrupted", hdev->name,
139 firmware);
140 err = -EINVAL;
141 goto done;
142 }
143
144 cmd_param = fw_ptr;
145 fw_ptr += cmd->plen;
146 fw_size -= cmd->plen;
147
148 opcode = le16_to_cpu(cmd->opcode);
149
150 skb = __hci_cmd_sync(hdev, opcode, cmd->plen, cmd_param,
151 HCI_INIT_TIMEOUT);
152 if (IS_ERR(skb)) {
153 err = PTR_ERR(skb);
154 BT_ERR("%s: BCM: Patch command %04x failed (%d)",
155 hdev->name, opcode, err);
156 goto done;
157 }
158 kfree_skb(skb);
159 }
160
161 /* 250 msec delay after Launch Ram completes */
162 msleep(250);
163
164done:
165 release_firmware(fw);
166 return err;
167}
168EXPORT_SYMBOL(btbcm_patchram);
169
98static int btbcm_reset(struct hci_dev *hdev) 170static int btbcm_reset(struct hci_dev *hdev)
99{ 171{
100 struct sk_buff *skb; 172 struct sk_buff *skb;
@@ -198,12 +270,8 @@ static const struct {
198 270
199int btbcm_setup_patchram(struct hci_dev *hdev) 271int btbcm_setup_patchram(struct hci_dev *hdev)
200{ 272{
201 const struct hci_command_hdr *cmd;
202 const struct firmware *fw;
203 const u8 *fw_ptr;
204 size_t fw_size;
205 char fw_name[64]; 273 char fw_name[64];
206 u16 opcode, subver, rev, pid, vid; 274 u16 subver, rev, pid, vid;
207 const char *hw_name = NULL; 275 const char *hw_name = NULL;
208 struct sk_buff *skb; 276 struct sk_buff *skb;
209 struct hci_rp_read_local_version *ver; 277 struct hci_rp_read_local_version *ver;
@@ -273,74 +341,19 @@ int btbcm_setup_patchram(struct hci_dev *hdev)
273 hw_name ? : "BCM", (subver & 0x7000) >> 13, 341 hw_name ? : "BCM", (subver & 0x7000) >> 13,
274 (subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff); 342 (subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff);
275 343
276 err = request_firmware(&fw, fw_name, &hdev->dev); 344 err = btbcm_patchram(hdev, fw_name);
277 if (err < 0) { 345 if (err == -ENOENT)
278 BT_INFO("%s: BCM: patch %s not found", hdev->name, fw_name);
279 return 0; 346 return 0;
280 }
281
282 /* Start Download */
283 skb = __hci_cmd_sync(hdev, 0xfc2e, 0, NULL, HCI_INIT_TIMEOUT);
284 if (IS_ERR(skb)) {
285 err = PTR_ERR(skb);
286 BT_ERR("%s: BCM: Download Minidrv command failed (%d)",
287 hdev->name, err);
288 goto reset;
289 }
290 kfree_skb(skb);
291
292 /* 50 msec delay after Download Minidrv completes */
293 msleep(50);
294
295 fw_ptr = fw->data;
296 fw_size = fw->size;
297
298 while (fw_size >= sizeof(*cmd)) {
299 const u8 *cmd_param;
300
301 cmd = (struct hci_command_hdr *)fw_ptr;
302 fw_ptr += sizeof(*cmd);
303 fw_size -= sizeof(*cmd);
304
305 if (fw_size < cmd->plen) {
306 BT_ERR("%s: BCM: patch %s is corrupted", hdev->name,
307 fw_name);
308 err = -EINVAL;
309 goto reset;
310 }
311 347
312 cmd_param = fw_ptr;
313 fw_ptr += cmd->plen;
314 fw_size -= cmd->plen;
315
316 opcode = le16_to_cpu(cmd->opcode);
317
318 skb = __hci_cmd_sync(hdev, opcode, cmd->plen, cmd_param,
319 HCI_INIT_TIMEOUT);
320 if (IS_ERR(skb)) {
321 err = PTR_ERR(skb);
322 BT_ERR("%s: BCM: patch command %04x failed (%d)",
323 hdev->name, opcode, err);
324 goto reset;
325 }
326 kfree_skb(skb);
327 }
328
329 /* 250 msec delay after Launch Ram completes */
330 msleep(250);
331
332reset:
333 /* Reset */ 348 /* Reset */
334 err = btbcm_reset(hdev); 349 err = btbcm_reset(hdev);
335 if (err) 350 if (err)
336 goto done; 351 return err;
337 352
338 /* Read Local Version Info */ 353 /* Read Local Version Info */
339 skb = btbcm_read_local_version(hdev); 354 skb = btbcm_read_local_version(hdev);
340 if (IS_ERR(skb)) { 355 if (IS_ERR(skb))
341 err = PTR_ERR(skb); 356 return PTR_ERR(skb);
342 goto done;
343 }
344 357
345 ver = (struct hci_rp_read_local_version *)skb->data; 358 ver = (struct hci_rp_read_local_version *)skb->data;
346 rev = le16_to_cpu(ver->hci_rev); 359 rev = le16_to_cpu(ver->hci_rev);
@@ -355,10 +368,7 @@ reset:
355 368
356 set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); 369 set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
357 370
358done: 371 return 0;
359 release_firmware(fw);
360
361 return err;
362} 372}
363EXPORT_SYMBOL_GPL(btbcm_setup_patchram); 373EXPORT_SYMBOL_GPL(btbcm_setup_patchram);
364 374
diff --git a/drivers/bluetooth/btbcm.h b/drivers/bluetooth/btbcm.h
index 34268ae3eb46..eb6ab5f9483d 100644
--- a/drivers/bluetooth/btbcm.h
+++ b/drivers/bluetooth/btbcm.h
@@ -25,6 +25,7 @@
25 25
26int btbcm_check_bdaddr(struct hci_dev *hdev); 26int btbcm_check_bdaddr(struct hci_dev *hdev);
27int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); 27int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
28int btbcm_patchram(struct hci_dev *hdev, const char *firmware);
28 29
29int btbcm_setup_patchram(struct hci_dev *hdev); 30int btbcm_setup_patchram(struct hci_dev *hdev);
30int btbcm_setup_apple(struct hci_dev *hdev); 31int btbcm_setup_apple(struct hci_dev *hdev);
@@ -41,6 +42,11 @@ static inline int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
41 return -EOPNOTSUPP; 42 return -EOPNOTSUPP;
42} 43}
43 44
45static inline int btbcm_patchram(struct hci_dev *hdev, const char *firmware)
46{
47 return -EOPNOTSUPP;
48}
49
44static inline int btbcm_setup_patchram(struct hci_dev *hdev) 50static inline int btbcm_setup_patchram(struct hci_dev *hdev)
45{ 51{
46 return 0; 52 return 0;
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index de7b236eeae7..d21f3b4176d3 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -24,6 +24,7 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/firmware.h> 26#include <linux/firmware.h>
27#include <asm/unaligned.h>
27 28
28#include <net/bluetooth/bluetooth.h> 29#include <net/bluetooth/bluetooth.h>
29#include <net/bluetooth/hci_core.h> 30#include <net/bluetooth/hci_core.h>
@@ -57,6 +58,7 @@ static struct usb_driver btusb_driver;
57#define BTUSB_AMP 0x4000 58#define BTUSB_AMP 0x4000
58#define BTUSB_QCA_ROME 0x8000 59#define BTUSB_QCA_ROME 0x8000
59#define BTUSB_BCM_APPLE 0x10000 60#define BTUSB_BCM_APPLE 0x10000
61#define BTUSB_REALTEK 0x20000
60 62
61static const struct usb_device_id btusb_table[] = { 63static const struct usb_device_id btusb_table[] = {
62 /* Generic Bluetooth USB device */ 64 /* Generic Bluetooth USB device */
@@ -288,6 +290,28 @@ static const struct usb_device_id blacklist_table[] = {
288 { USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01), 290 { USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01),
289 .driver_info = BTUSB_IGNORE }, 291 .driver_info = BTUSB_IGNORE },
290 292
293 /* Realtek Bluetooth devices */
294 { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01),
295 .driver_info = BTUSB_REALTEK },
296
297 /* Additional Realtek 8723AE Bluetooth devices */
298 { USB_DEVICE(0x0930, 0x021d), .driver_info = BTUSB_REALTEK },
299 { USB_DEVICE(0x13d3, 0x3394), .driver_info = BTUSB_REALTEK },
300
301 /* Additional Realtek 8723BE Bluetooth devices */
302 { USB_DEVICE(0x0489, 0xe085), .driver_info = BTUSB_REALTEK },
303 { USB_DEVICE(0x0489, 0xe08b), .driver_info = BTUSB_REALTEK },
304 { USB_DEVICE(0x13d3, 0x3410), .driver_info = BTUSB_REALTEK },
305 { USB_DEVICE(0x13d3, 0x3416), .driver_info = BTUSB_REALTEK },
306 { USB_DEVICE(0x13d3, 0x3459), .driver_info = BTUSB_REALTEK },
307
308 /* Additional Realtek 8821AE Bluetooth devices */
309 { USB_DEVICE(0x0b05, 0x17dc), .driver_info = BTUSB_REALTEK },
310 { USB_DEVICE(0x13d3, 0x3414), .driver_info = BTUSB_REALTEK },
311 { USB_DEVICE(0x13d3, 0x3458), .driver_info = BTUSB_REALTEK },
312 { USB_DEVICE(0x13d3, 0x3461), .driver_info = BTUSB_REALTEK },
313 { USB_DEVICE(0x13d3, 0x3462), .driver_info = BTUSB_REALTEK },
314
291 { } /* Terminating entry */ 315 { } /* Terminating entry */
292}; 316};
293 317
@@ -892,7 +916,7 @@ static int btusb_open(struct hci_dev *hdev)
892 */ 916 */
893 if (data->setup_on_usb) { 917 if (data->setup_on_usb) {
894 err = data->setup_on_usb(hdev); 918 err = data->setup_on_usb(hdev);
895 if (err <0) 919 if (err < 0)
896 return err; 920 return err;
897 } 921 }
898 922
@@ -1345,6 +1369,378 @@ static int btusb_setup_csr(struct hci_dev *hdev)
1345 return ret; 1369 return ret;
1346} 1370}
1347 1371
1372#define RTL_FRAG_LEN 252
1373
1374struct rtl_download_cmd {
1375 __u8 index;
1376 __u8 data[RTL_FRAG_LEN];
1377} __packed;
1378
1379struct rtl_download_response {
1380 __u8 status;
1381 __u8 index;
1382} __packed;
1383
1384struct rtl_rom_version_evt {
1385 __u8 status;
1386 __u8 version;
1387} __packed;
1388
1389struct rtl_epatch_header {
1390 __u8 signature[8];
1391 __le32 fw_version;
1392 __le16 num_patches;
1393} __packed;
1394
1395#define RTL_EPATCH_SIGNATURE "Realtech"
1396#define RTL_ROM_LMP_3499 0x3499
1397#define RTL_ROM_LMP_8723A 0x1200
1398#define RTL_ROM_LMP_8723B 0x8723
1399#define RTL_ROM_LMP_8821A 0x8821
1400#define RTL_ROM_LMP_8761A 0x8761
1401
1402static int rtl_read_rom_version(struct hci_dev *hdev, u8 *version)
1403{
1404 struct rtl_rom_version_evt *rom_version;
1405 struct sk_buff *skb;
1406 int ret;
1407
1408 /* Read RTL ROM version command */
1409 skb = __hci_cmd_sync(hdev, 0xfc6d, 0, NULL, HCI_INIT_TIMEOUT);
1410 if (IS_ERR(skb)) {
1411 BT_ERR("%s: Read ROM version failed (%ld)",
1412 hdev->name, PTR_ERR(skb));
1413 return PTR_ERR(skb);
1414 }
1415
1416 if (skb->len != sizeof(*rom_version)) {
1417 BT_ERR("%s: RTL version event length mismatch", hdev->name);
1418 kfree_skb(skb);
1419 return -EIO;
1420 }
1421
1422 rom_version = (struct rtl_rom_version_evt *)skb->data;
1423 BT_INFO("%s: rom_version status=%x version=%x",
1424 hdev->name, rom_version->status, rom_version->version);
1425
1426 ret = rom_version->status;
1427 if (ret == 0)
1428 *version = rom_version->version;
1429
1430 kfree_skb(skb);
1431 return ret;
1432}
1433
1434static int rtl8723b_parse_firmware(struct hci_dev *hdev, u16 lmp_subver,
1435 const struct firmware *fw,
1436 unsigned char **_buf)
1437{
1438 const u8 extension_sig[] = { 0x51, 0x04, 0xfd, 0x77 };
1439 struct rtl_epatch_header *epatch_info;
1440 unsigned char *buf;
1441 int i, ret, len;
1442 size_t min_size;
1443 u8 opcode, length, data, rom_version = 0;
1444 int project_id = -1;
1445 const unsigned char *fwptr, *chip_id_base;
1446 const unsigned char *patch_length_base, *patch_offset_base;
1447 u32 patch_offset = 0;
1448 u16 patch_length, num_patches;
1449 const u16 project_id_to_lmp_subver[] = {
1450 RTL_ROM_LMP_8723A,
1451 RTL_ROM_LMP_8723B,
1452 RTL_ROM_LMP_8821A,
1453 RTL_ROM_LMP_8761A
1454 };
1455
1456 ret = rtl_read_rom_version(hdev, &rom_version);
1457 if (ret)
1458 return -bt_to_errno(ret);
1459
1460 min_size = sizeof(struct rtl_epatch_header) + sizeof(extension_sig) + 3;
1461 if (fw->size < min_size)
1462 return -EINVAL;
1463
1464 fwptr = fw->data + fw->size - sizeof(extension_sig);
1465 if (memcmp(fwptr, extension_sig, sizeof(extension_sig)) != 0) {
1466 BT_ERR("%s: extension section signature mismatch", hdev->name);
1467 return -EINVAL;
1468 }
1469
1470 /* Loop from the end of the firmware parsing instructions, until
1471 * we find an instruction that identifies the "project ID" for the
1472 * hardware supported by this firwmare file.
1473 * Once we have that, we double-check that that project_id is suitable
1474 * for the hardware we are working with.
1475 */
1476 while (fwptr >= fw->data + (sizeof(struct rtl_epatch_header) + 3)) {
1477 opcode = *--fwptr;
1478 length = *--fwptr;
1479 data = *--fwptr;
1480
1481 BT_DBG("check op=%x len=%x data=%x", opcode, length, data);
1482
1483 if (opcode == 0xff) /* EOF */
1484 break;
1485
1486 if (length == 0) {
1487 BT_ERR("%s: found instruction with length 0",
1488 hdev->name);
1489 return -EINVAL;
1490 }
1491
1492 if (opcode == 0 && length == 1) {
1493 project_id = data;
1494 break;
1495 }
1496
1497 fwptr -= length;
1498 }
1499
1500 if (project_id < 0) {
1501 BT_ERR("%s: failed to find version instruction", hdev->name);
1502 return -EINVAL;
1503 }
1504
1505 if (project_id >= ARRAY_SIZE(project_id_to_lmp_subver)) {
1506 BT_ERR("%s: unknown project id %d", hdev->name, project_id);
1507 return -EINVAL;
1508 }
1509
1510 if (lmp_subver != project_id_to_lmp_subver[project_id]) {
1511 BT_ERR("%s: firmware is for %x but this is a %x", hdev->name,
1512 project_id_to_lmp_subver[project_id], lmp_subver);
1513 return -EINVAL;
1514 }
1515
1516 epatch_info = (struct rtl_epatch_header *)fw->data;
1517 if (memcmp(epatch_info->signature, RTL_EPATCH_SIGNATURE, 8) != 0) {
1518 BT_ERR("%s: bad EPATCH signature", hdev->name);
1519 return -EINVAL;
1520 }
1521
1522 num_patches = le16_to_cpu(epatch_info->num_patches);
1523 BT_DBG("fw_version=%x, num_patches=%d",
1524 le32_to_cpu(epatch_info->fw_version), num_patches);
1525
1526 /* After the rtl_epatch_header there is a funky patch metadata section.
1527 * Assuming 2 patches, the layout is:
1528 * ChipID1 ChipID2 PatchLength1 PatchLength2 PatchOffset1 PatchOffset2
1529 *
1530 * Find the right patch for this chip.
1531 */
1532 min_size += 8 * num_patches;
1533 if (fw->size < min_size)
1534 return -EINVAL;
1535
1536 chip_id_base = fw->data + sizeof(struct rtl_epatch_header);
1537 patch_length_base = chip_id_base + (sizeof(u16) * num_patches);
1538 patch_offset_base = patch_length_base + (sizeof(u16) * num_patches);
1539 for (i = 0; i < num_patches; i++) {
1540 u16 chip_id = get_unaligned_le16(chip_id_base +
1541 (i * sizeof(u16)));
1542 if (chip_id == rom_version + 1) {
1543 patch_length = get_unaligned_le16(patch_length_base +
1544 (i * sizeof(u16)));
1545 patch_offset = get_unaligned_le32(patch_offset_base +
1546 (i * sizeof(u32)));
1547 break;
1548 }
1549 }
1550
1551 if (!patch_offset) {
1552 BT_ERR("%s: didn't find patch for chip id %d",
1553 hdev->name, rom_version);
1554 return -EINVAL;
1555 }
1556
1557 BT_DBG("length=%x offset=%x index %d", patch_length, patch_offset, i);
1558 min_size = patch_offset + patch_length;
1559 if (fw->size < min_size)
1560 return -EINVAL;
1561
1562 /* Copy the firmware into a new buffer and write the version at
1563 * the end.
1564 */
1565 len = patch_length;
1566 buf = kmemdup(fw->data + patch_offset, patch_length, GFP_KERNEL);
1567 if (!buf)
1568 return -ENOMEM;
1569
1570 memcpy(buf + patch_length - 4, &epatch_info->fw_version, 4);
1571
1572 *_buf = buf;
1573 return len;
1574}
1575
1576static int rtl_download_firmware(struct hci_dev *hdev,
1577 const unsigned char *data, int fw_len)
1578{
1579 struct rtl_download_cmd *dl_cmd;
1580 int frag_num = fw_len / RTL_FRAG_LEN + 1;
1581 int frag_len = RTL_FRAG_LEN;
1582 int ret = 0;
1583 int i;
1584
1585 dl_cmd = kmalloc(sizeof(struct rtl_download_cmd), GFP_KERNEL);
1586 if (!dl_cmd)
1587 return -ENOMEM;
1588
1589 for (i = 0; i < frag_num; i++) {
1590 struct rtl_download_response *dl_resp;
1591 struct sk_buff *skb;
1592
1593 BT_DBG("download fw (%d/%d)", i, frag_num);
1594
1595 dl_cmd->index = i;
1596 if (i == (frag_num - 1)) {
1597 dl_cmd->index |= 0x80; /* data end */
1598 frag_len = fw_len % RTL_FRAG_LEN;
1599 }
1600 memcpy(dl_cmd->data, data, frag_len);
1601
1602 /* Send download command */
1603 skb = __hci_cmd_sync(hdev, 0xfc20, frag_len + 1, dl_cmd,
1604 HCI_INIT_TIMEOUT);
1605 if (IS_ERR(skb)) {
1606 BT_ERR("%s: download fw command failed (%ld)",
1607 hdev->name, PTR_ERR(skb));
1608 ret = -PTR_ERR(skb);
1609 goto out;
1610 }
1611
1612 if (skb->len != sizeof(*dl_resp)) {
1613 BT_ERR("%s: download fw event length mismatch",
1614 hdev->name);
1615 kfree_skb(skb);
1616 ret = -EIO;
1617 goto out;
1618 }
1619
1620 dl_resp = (struct rtl_download_response *)skb->data;
1621 if (dl_resp->status != 0) {
1622 kfree_skb(skb);
1623 ret = bt_to_errno(dl_resp->status);
1624 goto out;
1625 }
1626
1627 kfree_skb(skb);
1628 data += RTL_FRAG_LEN;
1629 }
1630
1631out:
1632 kfree(dl_cmd);
1633 return ret;
1634}
1635
1636static int btusb_setup_rtl8723a(struct hci_dev *hdev)
1637{
1638 struct btusb_data *data = dev_get_drvdata(&hdev->dev);
1639 struct usb_device *udev = interface_to_usbdev(data->intf);
1640 const struct firmware *fw;
1641 int ret;
1642
1643 BT_INFO("%s: rtl: loading rtl_bt/rtl8723a_fw.bin", hdev->name);
1644 ret = request_firmware(&fw, "rtl_bt/rtl8723a_fw.bin", &udev->dev);
1645 if (ret < 0) {
1646 BT_ERR("%s: Failed to load rtl_bt/rtl8723a_fw.bin", hdev->name);
1647 return ret;
1648 }
1649
1650 if (fw->size < 8) {
1651 ret = -EINVAL;
1652 goto out;
1653 }
1654
1655 /* Check that the firmware doesn't have the epatch signature
1656 * (which is only for RTL8723B and newer).
1657 */
1658 if (!memcmp(fw->data, RTL_EPATCH_SIGNATURE, 8)) {
1659 BT_ERR("%s: unexpected EPATCH signature!", hdev->name);
1660 ret = -EINVAL;
1661 goto out;
1662 }
1663
1664 ret = rtl_download_firmware(hdev, fw->data, fw->size);
1665
1666out:
1667 release_firmware(fw);
1668 return ret;
1669}
1670
1671static int btusb_setup_rtl8723b(struct hci_dev *hdev, u16 lmp_subver,
1672 const char *fw_name)
1673{
1674 struct btusb_data *data = dev_get_drvdata(&hdev->dev);
1675 struct usb_device *udev = interface_to_usbdev(data->intf);
1676 unsigned char *fw_data = NULL;
1677 const struct firmware *fw;
1678 int ret;
1679
1680 BT_INFO("%s: rtl: loading %s", hdev->name, fw_name);
1681 ret = request_firmware(&fw, fw_name, &udev->dev);
1682 if (ret < 0) {
1683 BT_ERR("%s: Failed to load %s", hdev->name, fw_name);
1684 return ret;
1685 }
1686
1687 ret = rtl8723b_parse_firmware(hdev, lmp_subver, fw, &fw_data);
1688 if (ret < 0)
1689 goto out;
1690
1691 ret = rtl_download_firmware(hdev, fw_data, ret);
1692 kfree(fw_data);
1693 if (ret < 0)
1694 goto out;
1695
1696out:
1697 release_firmware(fw);
1698 return ret;
1699}
1700
1701static int btusb_setup_realtek(struct hci_dev *hdev)
1702{
1703 struct sk_buff *skb;
1704 struct hci_rp_read_local_version *resp;
1705 u16 lmp_subver;
1706
1707 skb = btusb_read_local_version(hdev);
1708 if (IS_ERR(skb))
1709 return -PTR_ERR(skb);
1710
1711 resp = (struct hci_rp_read_local_version *)skb->data;
1712 BT_INFO("%s: rtl: examining hci_ver=%02x hci_rev=%04x lmp_ver=%02x "
1713 "lmp_subver=%04x", hdev->name, resp->hci_ver, resp->hci_rev,
1714 resp->lmp_ver, resp->lmp_subver);
1715
1716 lmp_subver = le16_to_cpu(resp->lmp_subver);
1717 kfree_skb(skb);
1718
1719 /* Match a set of subver values that correspond to stock firmware,
1720 * which is not compatible with standard btusb.
1721 * If matched, upload an alternative firmware that does conform to
1722 * standard btusb. Once that firmware is uploaded, the subver changes
1723 * to a different value.
1724 */
1725 switch (lmp_subver) {
1726 case RTL_ROM_LMP_8723A:
1727 case RTL_ROM_LMP_3499:
1728 return btusb_setup_rtl8723a(hdev);
1729 case RTL_ROM_LMP_8723B:
1730 return btusb_setup_rtl8723b(hdev, lmp_subver,
1731 "rtl_bt/rtl8723b_fw.bin");
1732 case RTL_ROM_LMP_8821A:
1733 return btusb_setup_rtl8723b(hdev, lmp_subver,
1734 "rtl_bt/rtl8821a_fw.bin");
1735 case RTL_ROM_LMP_8761A:
1736 return btusb_setup_rtl8723b(hdev, lmp_subver,
1737 "rtl_bt/rtl8761a_fw.bin");
1738 default:
1739 BT_INFO("rtl: assuming no firmware upload needed.");
1740 return 0;
1741 }
1742}
1743
1348static const struct firmware *btusb_setup_intel_get_fw(struct hci_dev *hdev, 1744static const struct firmware *btusb_setup_intel_get_fw(struct hci_dev *hdev,
1349 struct intel_version *ver) 1745 struct intel_version *ver)
1350{ 1746{
@@ -2577,7 +2973,7 @@ static int btusb_setup_qca(struct hci_dev *hdev)
2577 int i, err; 2973 int i, err;
2578 2974
2579 err = btusb_qca_send_vendor_req(hdev, QCA_GET_TARGET_VERSION, &ver, 2975 err = btusb_qca_send_vendor_req(hdev, QCA_GET_TARGET_VERSION, &ver,
2580 sizeof(ver)); 2976 sizeof(ver));
2581 if (err < 0) 2977 if (err < 0)
2582 return err; 2978 return err;
2583 2979
@@ -2776,6 +3172,9 @@ static int btusb_probe(struct usb_interface *intf,
2776 hdev->set_bdaddr = btusb_set_bdaddr_ath3012; 3172 hdev->set_bdaddr = btusb_set_bdaddr_ath3012;
2777 } 3173 }
2778 3174
3175 if (id->driver_info & BTUSB_REALTEK)
3176 hdev->setup = btusb_setup_realtek;
3177
2779 if (id->driver_info & BTUSB_AMP) { 3178 if (id->driver_info & BTUSB_AMP) {
2780 /* AMP controllers do not support SCO packets */ 3179 /* AMP controllers do not support SCO packets */
2781 data->isoc = NULL; 3180 data->isoc = NULL;
diff --git a/drivers/bluetooth/hci_ath.c b/drivers/bluetooth/hci_ath.c
index 1b3f8647ea2f..ec8fa0e0f036 100644
--- a/drivers/bluetooth/hci_ath.c
+++ b/drivers/bluetooth/hci_ath.c
@@ -95,7 +95,6 @@ static void ath_hci_uart_work(struct work_struct *work)
95 hci_uart_tx_wakeup(hu); 95 hci_uart_tx_wakeup(hu);
96} 96}
97 97
98/* Initialize protocol */
99static int ath_open(struct hci_uart *hu) 98static int ath_open(struct hci_uart *hu)
100{ 99{
101 struct ath_struct *ath; 100 struct ath_struct *ath;
@@ -116,8 +115,7 @@ static int ath_open(struct hci_uart *hu)
116 return 0; 115 return 0;
117} 116}
118 117
119/* Flush protocol data */ 118static int ath_close(struct hci_uart *hu)
120static int ath_flush(struct hci_uart *hu)
121{ 119{
122 struct ath_struct *ath = hu->priv; 120 struct ath_struct *ath = hu->priv;
123 121
@@ -125,11 +123,17 @@ static int ath_flush(struct hci_uart *hu)
125 123
126 skb_queue_purge(&ath->txq); 124 skb_queue_purge(&ath->txq);
127 125
126 kfree_skb(ath->rx_skb);
127
128 cancel_work_sync(&ath->ctxtsw);
129
130 hu->priv = NULL;
131 kfree(ath);
132
128 return 0; 133 return 0;
129} 134}
130 135
131/* Close protocol */ 136static int ath_flush(struct hci_uart *hu)
132static int ath_close(struct hci_uart *hu)
133{ 137{
134 struct ath_struct *ath = hu->priv; 138 struct ath_struct *ath = hu->priv;
135 139
@@ -137,19 +141,65 @@ static int ath_close(struct hci_uart *hu)
137 141
138 skb_queue_purge(&ath->txq); 142 skb_queue_purge(&ath->txq);
139 143
140 kfree_skb(ath->rx_skb); 144 return 0;
145}
141 146
142 cancel_work_sync(&ath->ctxtsw); 147static int ath_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
148{
149 struct sk_buff *skb;
150 u8 buf[10];
151 int err;
152
153 buf[0] = 0x01;
154 buf[1] = 0x01;
155 buf[2] = 0x00;
156 buf[3] = sizeof(bdaddr_t);
157 memcpy(buf + 4, bdaddr, sizeof(bdaddr_t));
158
159 skb = __hci_cmd_sync(hdev, 0xfc0b, sizeof(buf), buf, HCI_INIT_TIMEOUT);
160 if (IS_ERR(skb)) {
161 err = PTR_ERR(skb);
162 BT_ERR("%s: Change address command failed (%d)",
163 hdev->name, err);
164 return err;
165 }
166 kfree_skb(skb);
143 167
144 hu->priv = NULL; 168 return 0;
145 kfree(ath); 169}
170
171static int ath_setup(struct hci_uart *hu)
172{
173 BT_DBG("hu %p", hu);
174
175 hu->hdev->set_bdaddr = ath_set_bdaddr;
146 176
147 return 0; 177 return 0;
148} 178}
149 179
180static const struct h4_recv_pkt ath_recv_pkts[] = {
181 { H4_RECV_ACL, .recv = hci_recv_frame },
182 { H4_RECV_SCO, .recv = hci_recv_frame },
183 { H4_RECV_EVENT, .recv = hci_recv_frame },
184};
185
186static int ath_recv(struct hci_uart *hu, const void *data, int count)
187{
188 struct ath_struct *ath = hu->priv;
189
190 ath->rx_skb = h4_recv_buf(hu->hdev, ath->rx_skb, data, count,
191 ath_recv_pkts, ARRAY_SIZE(ath_recv_pkts));
192 if (IS_ERR(ath->rx_skb)) {
193 int err = PTR_ERR(ath->rx_skb);
194 BT_ERR("%s: Frame reassembly failed (%d)", hu->hdev->name, err);
195 return err;
196 }
197
198 return count;
199}
200
150#define HCI_OP_ATH_SLEEP 0xFC04 201#define HCI_OP_ATH_SLEEP 0xFC04
151 202
152/* Enqueue frame for transmittion */
153static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb) 203static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb)
154{ 204{
155 struct ath_struct *ath = hu->priv; 205 struct ath_struct *ath = hu->priv;
@@ -159,8 +209,7 @@ static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb)
159 return 0; 209 return 0;
160 } 210 }
161 211
162 /* 212 /* Update power management enable flag with parameters of
163 * Update power management enable flag with parameters of
164 * HCI sleep enable vendor specific HCI command. 213 * HCI sleep enable vendor specific HCI command.
165 */ 214 */
166 if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) { 215 if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) {
@@ -190,37 +239,16 @@ static struct sk_buff *ath_dequeue(struct hci_uart *hu)
190 return skb_dequeue(&ath->txq); 239 return skb_dequeue(&ath->txq);
191} 240}
192 241
193static const struct h4_recv_pkt ath_recv_pkts[] = {
194 { H4_RECV_ACL, .recv = hci_recv_frame },
195 { H4_RECV_SCO, .recv = hci_recv_frame },
196 { H4_RECV_EVENT, .recv = hci_recv_frame },
197};
198
199/* Recv data */
200static int ath_recv(struct hci_uart *hu, const void *data, int count)
201{
202 struct ath_struct *ath = hu->priv;
203
204 ath->rx_skb = h4_recv_buf(hu->hdev, ath->rx_skb, data, count,
205 ath_recv_pkts, ARRAY_SIZE(ath_recv_pkts));
206 if (IS_ERR(ath->rx_skb)) {
207 int err = PTR_ERR(ath->rx_skb);
208 BT_ERR("%s: Frame reassembly failed (%d)", hu->hdev->name, err);
209 return err;
210 }
211
212 return count;
213}
214
215static const struct hci_uart_proto athp = { 242static const struct hci_uart_proto athp = {
216 .id = HCI_UART_ATH3K, 243 .id = HCI_UART_ATH3K,
217 .name = "ATH3K", 244 .name = "ATH3K",
218 .open = ath_open, 245 .open = ath_open,
219 .close = ath_close, 246 .close = ath_close,
247 .flush = ath_flush,
248 .setup = ath_setup,
220 .recv = ath_recv, 249 .recv = ath_recv,
221 .enqueue = ath_enqueue, 250 .enqueue = ath_enqueue,
222 .dequeue = ath_dequeue, 251 .dequeue = ath_dequeue,
223 .flush = ath_flush,
224}; 252};
225 253
226int __init ath_init(void) 254int __init ath_init(void)
diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index 6bddfe062b51..fc55e8e0351d 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -509,10 +509,11 @@ static int xcan_rx(struct net_device *ndev)
509 cf->can_id |= CAN_RTR_FLAG; 509 cf->can_id |= CAN_RTR_FLAG;
510 } 510 }
511 511
512 if (!(id_xcan & XCAN_IDR_SRR_MASK)) { 512 /* DW1/DW2 must always be read to remove message from RXFIFO */
513 data[0] = priv->read_reg(priv, XCAN_RXFIFO_DW1_OFFSET); 513 data[0] = priv->read_reg(priv, XCAN_RXFIFO_DW1_OFFSET);
514 data[1] = priv->read_reg(priv, XCAN_RXFIFO_DW2_OFFSET); 514 data[1] = priv->read_reg(priv, XCAN_RXFIFO_DW2_OFFSET);
515 515
516 if (!(cf->can_id & CAN_RTR_FLAG)) {
516 /* Change Xilinx CAN data format to socketCAN data format */ 517 /* Change Xilinx CAN data format to socketCAN data format */
517 if (cf->can_dlc > 0) 518 if (cf->can_dlc > 0)
518 *(__be32 *)(cf->data) = cpu_to_be32(data[0]); 519 *(__be32 *)(cf->data) = cpu_to_be32(data[0]);
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index af639ab4c55b..cf309aa92802 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1469,6 +1469,9 @@ static void __exit mv88e6xxx_cleanup(void)
1469#if IS_ENABLED(CONFIG_NET_DSA_MV88E6171) 1469#if IS_ENABLED(CONFIG_NET_DSA_MV88E6171)
1470 unregister_switch_driver(&mv88e6171_switch_driver); 1470 unregister_switch_driver(&mv88e6171_switch_driver);
1471#endif 1471#endif
1472#if IS_ENABLED(CONFIG_NET_DSA_MV88E6352)
1473 unregister_switch_driver(&mv88e6352_switch_driver);
1474#endif
1472#if IS_ENABLED(CONFIG_NET_DSA_MV88E6123_61_65) 1475#if IS_ENABLED(CONFIG_NET_DSA_MV88E6123_61_65)
1473 unregister_switch_driver(&mv88e6123_61_65_switch_driver); 1476 unregister_switch_driver(&mv88e6123_61_65_switch_driver);
1474#endif 1477#endif
diff --git a/drivers/net/ethernet/amd/Kconfig b/drivers/net/ethernet/amd/Kconfig
index 089c269637b7..426916036151 100644
--- a/drivers/net/ethernet/amd/Kconfig
+++ b/drivers/net/ethernet/amd/Kconfig
@@ -180,6 +180,7 @@ config SUNLANCE
180config AMD_XGBE 180config AMD_XGBE
181 tristate "AMD 10GbE Ethernet driver" 181 tristate "AMD 10GbE Ethernet driver"
182 depends on (OF_NET || ACPI) && HAS_IOMEM && HAS_DMA 182 depends on (OF_NET || ACPI) && HAS_IOMEM && HAS_DMA
183 depends on ARM64 || COMPILE_TEST
183 select PHYLIB 184 select PHYLIB
184 select AMD_XGBE_PHY 185 select AMD_XGBE_PHY
185 select BITREVERSE 186 select BITREVERSE
diff --git a/drivers/net/ethernet/apm/xgene/Kconfig b/drivers/net/ethernet/apm/xgene/Kconfig
index f4054d242f3c..19e38afbc5ee 100644
--- a/drivers/net/ethernet/apm/xgene/Kconfig
+++ b/drivers/net/ethernet/apm/xgene/Kconfig
@@ -1,6 +1,7 @@
1config NET_XGENE 1config NET_XGENE
2 tristate "APM X-Gene SoC Ethernet Driver" 2 tristate "APM X-Gene SoC Ethernet Driver"
3 depends on HAS_DMA 3 depends on HAS_DMA
4 depends on ARCH_XGENE || COMPILE_TEST
4 select PHYLIB 5 select PHYLIB
5 help 6 help
6 This is the Ethernet driver for the on-chip ethernet interface on the 7 This is the Ethernet driver for the on-chip ethernet interface on the
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index a8bb8f664d3d..ec56a9b65dc3 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -4786,6 +4786,11 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu)
4786{ 4786{
4787 struct bnx2x *bp = netdev_priv(dev); 4787 struct bnx2x *bp = netdev_priv(dev);
4788 4788
4789 if (pci_num_vf(bp->pdev)) {
4790 DP(BNX2X_MSG_IOV, "VFs are enabled, can not change MTU\n");
4791 return -EPERM;
4792 }
4793
4789 if (bp->recovery_state != BNX2X_RECOVERY_DONE) { 4794 if (bp->recovery_state != BNX2X_RECOVERY_DONE) {
4790 BNX2X_ERR("Can't perform change MTU during parity recovery\n"); 4795 BNX2X_ERR("Can't perform change MTU during parity recovery\n");
4791 return -EAGAIN; 4796 return -EAGAIN;
@@ -4938,11 +4943,6 @@ int bnx2x_resume(struct pci_dev *pdev)
4938 } 4943 }
4939 bp = netdev_priv(dev); 4944 bp = netdev_priv(dev);
4940 4945
4941 if (pci_num_vf(bp->pdev)) {
4942 DP(BNX2X_MSG_IOV, "VFs are enabled, can not change MTU\n");
4943 return -EPERM;
4944 }
4945
4946 if (bp->recovery_state != BNX2X_RECOVERY_DONE) { 4946 if (bp->recovery_state != BNX2X_RECOVERY_DONE) {
4947 BNX2X_ERR("Handling parity error recovery. Try again later\n"); 4947 BNX2X_ERR("Handling parity error recovery. Try again later\n");
4948 return -EAGAIN; 4948 return -EAGAIN;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 556dcc162a62..fd52ce95127e 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -13371,8 +13371,13 @@ static int bnx2x_init_one(struct pci_dev *pdev,
13371 /* Management FW 'remembers' living interfaces. Allow it some time 13371 /* Management FW 'remembers' living interfaces. Allow it some time
13372 * to forget previously living interfaces, allowing a proper re-load. 13372 * to forget previously living interfaces, allowing a proper re-load.
13373 */ 13373 */
13374 if (is_kdump_kernel()) 13374 if (is_kdump_kernel()) {
13375 msleep(5000); 13375 ktime_t now = ktime_get_boottime();
13376 ktime_t fw_ready_time = ktime_set(5, 0);
13377
13378 if (ktime_before(now, fw_ready_time))
13379 msleep(ktime_ms_delta(fw_ready_time, now));
13380 }
13376 13381
13377 /* An estimated maximum supported CoS number according to the chip 13382 /* An estimated maximum supported CoS number according to the chip
13378 * version. 13383 * version.
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 4104d49f005d..61aa570aad9a 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -981,7 +981,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
981 struct macb_queue *queue = dev_id; 981 struct macb_queue *queue = dev_id;
982 struct macb *bp = queue->bp; 982 struct macb *bp = queue->bp;
983 struct net_device *dev = bp->dev; 983 struct net_device *dev = bp->dev;
984 u32 status; 984 u32 status, ctrl;
985 985
986 status = queue_readl(queue, ISR); 986 status = queue_readl(queue, ISR);
987 987
@@ -1037,6 +1037,15 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
1037 * add that if/when we get our hands on a full-blown MII PHY. 1037 * add that if/when we get our hands on a full-blown MII PHY.
1038 */ 1038 */
1039 1039
1040 if (status & MACB_BIT(RXUBR)) {
1041 ctrl = macb_readl(bp, NCR);
1042 macb_writel(bp, NCR, ctrl & ~MACB_BIT(RE));
1043 macb_writel(bp, NCR, ctrl | MACB_BIT(RE));
1044
1045 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
1046 macb_writel(bp, ISR, MACB_BIT(RXUBR));
1047 }
1048
1040 if (status & MACB_BIT(ISR_ROVR)) { 1049 if (status & MACB_BIT(ISR_ROVR)) {
1041 /* We missed at least one packet */ 1050 /* We missed at least one packet */
1042 if (macb_is_gem(bp)) 1051 if (macb_is_gem(bp))
diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h
index 5d9ceb17b4cb..0abc942c966e 100644
--- a/drivers/net/ethernet/intel/e1000e/e1000.h
+++ b/drivers/net/ethernet/intel/e1000e/e1000.h
@@ -40,6 +40,7 @@
40#include <linux/ptp_classify.h> 40#include <linux/ptp_classify.h>
41#include <linux/mii.h> 41#include <linux/mii.h>
42#include <linux/mdio.h> 42#include <linux/mdio.h>
43#include <linux/pm_qos.h>
43#include "hw.h" 44#include "hw.h"
44 45
45struct e1000_info; 46struct e1000_info;
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
index 1b0661e3573b..c754b2027281 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
@@ -610,7 +610,7 @@ static bool fm10k_clean_rx_irq(struct fm10k_q_vector *q_vector,
610 unsigned int total_bytes = 0, total_packets = 0; 610 unsigned int total_bytes = 0, total_packets = 0;
611 u16 cleaned_count = fm10k_desc_unused(rx_ring); 611 u16 cleaned_count = fm10k_desc_unused(rx_ring);
612 612
613 do { 613 while (likely(total_packets < budget)) {
614 union fm10k_rx_desc *rx_desc; 614 union fm10k_rx_desc *rx_desc;
615 615
616 /* return some buffers to hardware, one at a time is too slow */ 616 /* return some buffers to hardware, one at a time is too slow */
@@ -659,7 +659,7 @@ static bool fm10k_clean_rx_irq(struct fm10k_q_vector *q_vector,
659 659
660 /* update budget accounting */ 660 /* update budget accounting */
661 total_packets++; 661 total_packets++;
662 } while (likely(total_packets < budget)); 662 }
663 663
664 /* place incomplete frames back on ring for completion */ 664 /* place incomplete frames back on ring for completion */
665 rx_ring->skb = skb; 665 rx_ring->skb = skb;
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 8457d0306e3a..a0a9b1fcb5e8 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -1036,7 +1036,7 @@ static void igb_reset_q_vector(struct igb_adapter *adapter, int v_idx)
1036 adapter->tx_ring[q_vector->tx.ring->queue_index] = NULL; 1036 adapter->tx_ring[q_vector->tx.ring->queue_index] = NULL;
1037 1037
1038 if (q_vector->rx.ring) 1038 if (q_vector->rx.ring)
1039 adapter->tx_ring[q_vector->rx.ring->queue_index] = NULL; 1039 adapter->rx_ring[q_vector->rx.ring->queue_index] = NULL;
1040 1040
1041 netif_napi_del(&q_vector->napi); 1041 netif_napi_del(&q_vector->napi);
1042 1042
@@ -1207,6 +1207,8 @@ static int igb_alloc_q_vector(struct igb_adapter *adapter,
1207 q_vector = adapter->q_vector[v_idx]; 1207 q_vector = adapter->q_vector[v_idx];
1208 if (!q_vector) 1208 if (!q_vector)
1209 q_vector = kzalloc(size, GFP_KERNEL); 1209 q_vector = kzalloc(size, GFP_KERNEL);
1210 else
1211 memset(q_vector, 0, size);
1210 if (!q_vector) 1212 if (!q_vector)
1211 return -ENOMEM; 1213 return -ENOMEM;
1212 1214
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index a16d267fbce4..e71cdde9cb01 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -3612,7 +3612,7 @@ static int ixgbevf_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3612 u8 *dst_mac = skb_header_pointer(skb, 0, 0, NULL); 3612 u8 *dst_mac = skb_header_pointer(skb, 0, 0, NULL);
3613 3613
3614 if (!dst_mac || is_link_local_ether_addr(dst_mac)) { 3614 if (!dst_mac || is_link_local_ether_addr(dst_mac)) {
3615 dev_kfree_skb(skb); 3615 dev_kfree_skb_any(skb);
3616 return NETDEV_TX_OK; 3616 return NETDEV_TX_OK;
3617 } 3617 }
3618 3618
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_port.c b/drivers/net/ethernet/mellanox/mlx4/en_port.c
index 54f0e5ab2e55..0a56f010c846 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_port.c
@@ -139,7 +139,7 @@ static unsigned long en_stats_adder(__be64 *start, __be64 *next, int num)
139 int i; 139 int i;
140 int offset = next - start; 140 int offset = next - start;
141 141
142 for (i = 0; i <= num; i++) { 142 for (i = 0; i < num; i++) {
143 ret += be64_to_cpu(*curr); 143 ret += be64_to_cpu(*curr);
144 curr += offset; 144 curr += offset;
145 } 145 }
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index c7f28bf4b8e2..92fce1b98558 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -2845,7 +2845,7 @@ int mlx4_SW2HW_EQ_wrapper(struct mlx4_dev *dev, int slave,
2845{ 2845{
2846 int err; 2846 int err;
2847 int eqn = vhcr->in_modifier; 2847 int eqn = vhcr->in_modifier;
2848 int res_id = (slave << 8) | eqn; 2848 int res_id = (slave << 10) | eqn;
2849 struct mlx4_eq_context *eqc = inbox->buf; 2849 struct mlx4_eq_context *eqc = inbox->buf;
2850 int mtt_base = eq_get_mtt_addr(eqc) / dev->caps.mtt_entry_sz; 2850 int mtt_base = eq_get_mtt_addr(eqc) / dev->caps.mtt_entry_sz;
2851 int mtt_size = eq_get_mtt_size(eqc); 2851 int mtt_size = eq_get_mtt_size(eqc);
@@ -3051,7 +3051,7 @@ int mlx4_HW2SW_EQ_wrapper(struct mlx4_dev *dev, int slave,
3051 struct mlx4_cmd_info *cmd) 3051 struct mlx4_cmd_info *cmd)
3052{ 3052{
3053 int eqn = vhcr->in_modifier; 3053 int eqn = vhcr->in_modifier;
3054 int res_id = eqn | (slave << 8); 3054 int res_id = eqn | (slave << 10);
3055 struct res_eq *eq; 3055 struct res_eq *eq;
3056 int err; 3056 int err;
3057 3057
@@ -3108,7 +3108,7 @@ int mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe)
3108 return 0; 3108 return 0;
3109 3109
3110 mutex_lock(&priv->mfunc.master.gen_eqe_mutex[slave]); 3110 mutex_lock(&priv->mfunc.master.gen_eqe_mutex[slave]);
3111 res_id = (slave << 8) | event_eq->eqn; 3111 res_id = (slave << 10) | event_eq->eqn;
3112 err = get_res(dev, slave, res_id, RES_EQ, &req); 3112 err = get_res(dev, slave, res_id, RES_EQ, &req);
3113 if (err) 3113 if (err)
3114 goto unlock; 3114 goto unlock;
@@ -3131,7 +3131,7 @@ int mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe)
3131 3131
3132 memcpy(mailbox->buf, (u8 *) eqe, 28); 3132 memcpy(mailbox->buf, (u8 *) eqe, 28);
3133 3133
3134 in_modifier = (slave & 0xff) | ((event_eq->eqn & 0xff) << 16); 3134 in_modifier = (slave & 0xff) | ((event_eq->eqn & 0x3ff) << 16);
3135 3135
3136 err = mlx4_cmd(dev, mailbox->dma, in_modifier, 0, 3136 err = mlx4_cmd(dev, mailbox->dma, in_modifier, 0,
3137 MLX4_CMD_GEN_EQE, MLX4_CMD_TIME_CLASS_B, 3137 MLX4_CMD_GEN_EQE, MLX4_CMD_TIME_CLASS_B,
@@ -3157,7 +3157,7 @@ int mlx4_QUERY_EQ_wrapper(struct mlx4_dev *dev, int slave,
3157 struct mlx4_cmd_info *cmd) 3157 struct mlx4_cmd_info *cmd)
3158{ 3158{
3159 int eqn = vhcr->in_modifier; 3159 int eqn = vhcr->in_modifier;
3160 int res_id = eqn | (slave << 8); 3160 int res_id = eqn | (slave << 10);
3161 struct res_eq *eq; 3161 struct res_eq *eq;
3162 int err; 3162 int err;
3163 3163
@@ -4714,13 +4714,13 @@ static void rem_slave_eqs(struct mlx4_dev *dev, int slave)
4714 break; 4714 break;
4715 4715
4716 case RES_EQ_HW: 4716 case RES_EQ_HW:
4717 err = mlx4_cmd(dev, slave, eqn & 0xff, 4717 err = mlx4_cmd(dev, slave, eqn & 0x3ff,
4718 1, MLX4_CMD_HW2SW_EQ, 4718 1, MLX4_CMD_HW2SW_EQ,
4719 MLX4_CMD_TIME_CLASS_A, 4719 MLX4_CMD_TIME_CLASS_A,
4720 MLX4_CMD_NATIVE); 4720 MLX4_CMD_NATIVE);
4721 if (err) 4721 if (err)
4722 mlx4_dbg(dev, "rem_slave_eqs: failed to move slave %d eqs %d to SW ownership\n", 4722 mlx4_dbg(dev, "rem_slave_eqs: failed to move slave %d eqs %d to SW ownership\n",
4723 slave, eqn); 4723 slave, eqn & 0x3ff);
4724 atomic_dec(&eq->mtt->ref_count); 4724 atomic_dec(&eq->mtt->ref_count);
4725 state = RES_EQ_RESERVED; 4725 state = RES_EQ_RESERVED;
4726 break; 4726 break;
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
index 8da7c3faf817..7b43a3b4abdc 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
@@ -1764,7 +1764,7 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter)
1764 int done = 0; 1764 int done = 0;
1765 struct nx_host_tx_ring *tx_ring = adapter->tx_ring; 1765 struct nx_host_tx_ring *tx_ring = adapter->tx_ring;
1766 1766
1767 if (!spin_trylock(&adapter->tx_clean_lock)) 1767 if (!spin_trylock_bh(&adapter->tx_clean_lock))
1768 return 1; 1768 return 1;
1769 1769
1770 sw_consumer = tx_ring->sw_consumer; 1770 sw_consumer = tx_ring->sw_consumer;
@@ -1819,7 +1819,7 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter)
1819 */ 1819 */
1820 hw_consumer = le32_to_cpu(*(tx_ring->hw_consumer)); 1820 hw_consumer = le32_to_cpu(*(tx_ring->hw_consumer));
1821 done = (sw_consumer == hw_consumer); 1821 done = (sw_consumer == hw_consumer);
1822 spin_unlock(&adapter->tx_clean_lock); 1822 spin_unlock_bh(&adapter->tx_clean_lock);
1823 1823
1824 return done; 1824 return done;
1825} 1825}
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index f66641d961e3..6af028d5f9bc 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -912,6 +912,8 @@ qca_spi_probe(struct spi_device *spi_device)
912 qca->spi_dev = spi_device; 912 qca->spi_dev = spi_device;
913 qca->legacy_mode = legacy_mode; 913 qca->legacy_mode = legacy_mode;
914 914
915 spi_set_drvdata(spi_device, qcaspi_devs);
916
915 mac = of_get_mac_address(spi_device->dev.of_node); 917 mac = of_get_mac_address(spi_device->dev.of_node);
916 918
917 if (mac) 919 if (mac)
@@ -944,8 +946,6 @@ qca_spi_probe(struct spi_device *spi_device)
944 return -EFAULT; 946 return -EFAULT;
945 } 947 }
946 948
947 spi_set_drvdata(spi_device, qcaspi_devs);
948
949 qcaspi_init_device_debugfs(qca); 949 qcaspi_init_device_debugfs(qca);
950 950
951 return 0; 951 return 0;
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index c70ab40d8698..3df51faf18ae 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -6884,7 +6884,7 @@ static void r8169_csum_workaround(struct rtl8169_private *tp,
6884 rtl8169_start_xmit(nskb, tp->dev); 6884 rtl8169_start_xmit(nskb, tp->dev);
6885 } while (segs); 6885 } while (segs);
6886 6886
6887 dev_kfree_skb(skb); 6887 dev_consume_skb_any(skb);
6888 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { 6888 } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
6889 if (skb_checksum_help(skb) < 0) 6889 if (skb_checksum_help(skb) < 0)
6890 goto drop; 6890 goto drop;
@@ -6896,7 +6896,7 @@ static void r8169_csum_workaround(struct rtl8169_private *tp,
6896drop: 6896drop:
6897 stats = &tp->dev->stats; 6897 stats = &tp->dev->stats;
6898 stats->tx_dropped++; 6898 stats->tx_dropped++;
6899 dev_kfree_skb(skb); 6899 dev_kfree_skb_any(skb);
6900 } 6900 }
6901} 6901}
6902 6902
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 14b363a25c02..630f0b7800e4 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2238,9 +2238,10 @@ static int smc_drv_probe(struct platform_device *pdev)
2238 const struct of_device_id *match = NULL; 2238 const struct of_device_id *match = NULL;
2239 struct smc_local *lp; 2239 struct smc_local *lp;
2240 struct net_device *ndev; 2240 struct net_device *ndev;
2241 struct resource *res, *ires; 2241 struct resource *res;
2242 unsigned int __iomem *addr; 2242 unsigned int __iomem *addr;
2243 unsigned long irq_flags = SMC_IRQ_FLAGS; 2243 unsigned long irq_flags = SMC_IRQ_FLAGS;
2244 unsigned long irq_resflags;
2244 int ret; 2245 int ret;
2245 2246
2246 ndev = alloc_etherdev(sizeof(struct smc_local)); 2247 ndev = alloc_etherdev(sizeof(struct smc_local));
@@ -2332,16 +2333,19 @@ static int smc_drv_probe(struct platform_device *pdev)
2332 goto out_free_netdev; 2333 goto out_free_netdev;
2333 } 2334 }
2334 2335
2335 ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 2336 ndev->irq = platform_get_irq(pdev, 0);
2336 if (!ires) { 2337 if (ndev->irq <= 0) {
2337 ret = -ENODEV; 2338 ret = -ENODEV;
2338 goto out_release_io; 2339 goto out_release_io;
2339 } 2340 }
2340 2341 /*
2341 ndev->irq = ires->start; 2342 * If this platform does not specify any special irqflags, or if
2342 2343 * the resource supplies a trigger, override the irqflags with
2343 if (irq_flags == -1 || ires->flags & IRQF_TRIGGER_MASK) 2344 * the trigger flags from the resource.
2344 irq_flags = ires->flags & IRQF_TRIGGER_MASK; 2345 */
2346 irq_resflags = irqd_get_trigger_type(irq_get_irq_data(ndev->irq));
2347 if (irq_flags == -1 || irq_resflags & IRQF_TRIGGER_MASK)
2348 irq_flags = irq_resflags & IRQF_TRIGGER_MASK;
2345 2349
2346 ret = smc_request_attrib(pdev, ndev); 2350 ret = smc_request_attrib(pdev, ndev);
2347 if (ret) 2351 if (ret)
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 41047c9143d0..959aeeade0c9 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -2418,9 +2418,9 @@ static int smsc911x_drv_probe(struct platform_device *pdev)
2418 struct net_device *dev; 2418 struct net_device *dev;
2419 struct smsc911x_data *pdata; 2419 struct smsc911x_data *pdata;
2420 struct smsc911x_platform_config *config = dev_get_platdata(&pdev->dev); 2420 struct smsc911x_platform_config *config = dev_get_platdata(&pdev->dev);
2421 struct resource *res, *irq_res; 2421 struct resource *res;
2422 unsigned int intcfg = 0; 2422 unsigned int intcfg = 0;
2423 int res_size, irq_flags; 2423 int res_size, irq, irq_flags;
2424 int retval; 2424 int retval;
2425 2425
2426 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 2426 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
@@ -2434,8 +2434,8 @@ static int smsc911x_drv_probe(struct platform_device *pdev)
2434 } 2434 }
2435 res_size = resource_size(res); 2435 res_size = resource_size(res);
2436 2436
2437 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 2437 irq = platform_get_irq(pdev, 0);
2438 if (!irq_res) { 2438 if (irq <= 0) {
2439 pr_warn("Could not allocate irq resource\n"); 2439 pr_warn("Could not allocate irq resource\n");
2440 retval = -ENODEV; 2440 retval = -ENODEV;
2441 goto out_0; 2441 goto out_0;
@@ -2455,8 +2455,8 @@ static int smsc911x_drv_probe(struct platform_device *pdev)
2455 SET_NETDEV_DEV(dev, &pdev->dev); 2455 SET_NETDEV_DEV(dev, &pdev->dev);
2456 2456
2457 pdata = netdev_priv(dev); 2457 pdata = netdev_priv(dev);
2458 dev->irq = irq_res->start; 2458 dev->irq = irq;
2459 irq_flags = irq_res->flags & IRQF_TRIGGER_MASK; 2459 irq_flags = irq_get_trigger_type(irq);
2460 pdata->ioaddr = ioremap_nocache(res->start, res_size); 2460 pdata->ioaddr = ioremap_nocache(res->start, res_size);
2461 2461
2462 pdata->dev = dev; 2462 pdata->dev = dev;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 705bbdf93940..68aec5c460db 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -23,6 +23,7 @@
23*******************************************************************************/ 23*******************************************************************************/
24 24
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/module.h>
26#include <linux/io.h> 27#include <linux/io.h>
27#include <linux/of.h> 28#include <linux/of.h>
28#include <linux/of_net.h> 29#include <linux/of_net.h>
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index 690a4c36b316..af2694dc6f90 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -707,8 +707,8 @@ static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
707 707
708 cur_p->app0 |= STS_CTRL_APP0_SOP; 708 cur_p->app0 |= STS_CTRL_APP0_SOP;
709 cur_p->len = skb_headlen(skb); 709 cur_p->len = skb_headlen(skb);
710 cur_p->phys = dma_map_single(ndev->dev.parent, skb->data, skb->len, 710 cur_p->phys = dma_map_single(ndev->dev.parent, skb->data,
711 DMA_TO_DEVICE); 711 skb_headlen(skb), DMA_TO_DEVICE);
712 cur_p->app4 = (unsigned long)skb; 712 cur_p->app4 = (unsigned long)skb;
713 713
714 for (ii = 0; ii < num_frag; ii++) { 714 for (ii = 0; ii < num_frag; ii++) {
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 2d9ef533cc48..ea091bc5ff09 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -826,7 +826,6 @@ int netvsc_send(struct hv_device *device,
826 u16 q_idx = packet->q_idx; 826 u16 q_idx = packet->q_idx;
827 u32 pktlen = packet->total_data_buflen, msd_len = 0; 827 u32 pktlen = packet->total_data_buflen, msd_len = 0;
828 unsigned int section_index = NETVSC_INVALID_INDEX; 828 unsigned int section_index = NETVSC_INVALID_INDEX;
829 struct sk_buff *skb = NULL;
830 unsigned long flag; 829 unsigned long flag;
831 struct multi_send_data *msdp; 830 struct multi_send_data *msdp;
832 struct hv_netvsc_packet *msd_send = NULL, *cur_send = NULL; 831 struct hv_netvsc_packet *msd_send = NULL, *cur_send = NULL;
@@ -924,12 +923,8 @@ int netvsc_send(struct hv_device *device,
924 if (cur_send) 923 if (cur_send)
925 ret = netvsc_send_pkt(cur_send, net_device); 924 ret = netvsc_send_pkt(cur_send, net_device);
926 925
927 if (ret != 0) { 926 if (ret != 0 && section_index != NETVSC_INVALID_INDEX)
928 if (section_index != NETVSC_INVALID_INDEX) 927 netvsc_free_send_slot(net_device, section_index);
929 netvsc_free_send_slot(net_device, section_index);
930 } else if (skb) {
931 dev_kfree_skb_any(skb);
932 }
933 928
934 return ret; 929 return ret;
935} 930}
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 38026650c038..67d00fbc2e0e 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -85,6 +85,7 @@ struct at86rf230_local {
85 struct ieee802154_hw *hw; 85 struct ieee802154_hw *hw;
86 struct at86rf2xx_chip_data *data; 86 struct at86rf2xx_chip_data *data;
87 struct regmap *regmap; 87 struct regmap *regmap;
88 int slp_tr;
88 89
89 struct completion state_complete; 90 struct completion state_complete;
90 struct at86rf230_state_change state; 91 struct at86rf230_state_change state;
@@ -95,163 +96,164 @@ struct at86rf230_local {
95 unsigned long cal_timeout; 96 unsigned long cal_timeout;
96 s8 max_frame_retries; 97 s8 max_frame_retries;
97 bool is_tx; 98 bool is_tx;
99 bool is_tx_from_off;
98 u8 tx_retry; 100 u8 tx_retry;
99 struct sk_buff *tx_skb; 101 struct sk_buff *tx_skb;
100 struct at86rf230_state_change tx; 102 struct at86rf230_state_change tx;
101}; 103};
102 104
103#define RG_TRX_STATUS (0x01) 105#define RG_TRX_STATUS (0x01)
104#define SR_TRX_STATUS 0x01, 0x1f, 0 106#define SR_TRX_STATUS 0x01, 0x1f, 0
105#define SR_RESERVED_01_3 0x01, 0x20, 5 107#define SR_RESERVED_01_3 0x01, 0x20, 5
106#define SR_CCA_STATUS 0x01, 0x40, 6 108#define SR_CCA_STATUS 0x01, 0x40, 6
107#define SR_CCA_DONE 0x01, 0x80, 7 109#define SR_CCA_DONE 0x01, 0x80, 7
108#define RG_TRX_STATE (0x02) 110#define RG_TRX_STATE (0x02)
109#define SR_TRX_CMD 0x02, 0x1f, 0 111#define SR_TRX_CMD 0x02, 0x1f, 0
110#define SR_TRAC_STATUS 0x02, 0xe0, 5 112#define SR_TRAC_STATUS 0x02, 0xe0, 5
111#define RG_TRX_CTRL_0 (0x03) 113#define RG_TRX_CTRL_0 (0x03)
112#define SR_CLKM_CTRL 0x03, 0x07, 0 114#define SR_CLKM_CTRL 0x03, 0x07, 0
113#define SR_CLKM_SHA_SEL 0x03, 0x08, 3 115#define SR_CLKM_SHA_SEL 0x03, 0x08, 3
114#define SR_PAD_IO_CLKM 0x03, 0x30, 4 116#define SR_PAD_IO_CLKM 0x03, 0x30, 4
115#define SR_PAD_IO 0x03, 0xc0, 6 117#define SR_PAD_IO 0x03, 0xc0, 6
116#define RG_TRX_CTRL_1 (0x04) 118#define RG_TRX_CTRL_1 (0x04)
117#define SR_IRQ_POLARITY 0x04, 0x01, 0 119#define SR_IRQ_POLARITY 0x04, 0x01, 0
118#define SR_IRQ_MASK_MODE 0x04, 0x02, 1 120#define SR_IRQ_MASK_MODE 0x04, 0x02, 1
119#define SR_SPI_CMD_MODE 0x04, 0x0c, 2 121#define SR_SPI_CMD_MODE 0x04, 0x0c, 2
120#define SR_RX_BL_CTRL 0x04, 0x10, 4 122#define SR_RX_BL_CTRL 0x04, 0x10, 4
121#define SR_TX_AUTO_CRC_ON 0x04, 0x20, 5 123#define SR_TX_AUTO_CRC_ON 0x04, 0x20, 5
122#define SR_IRQ_2_EXT_EN 0x04, 0x40, 6 124#define SR_IRQ_2_EXT_EN 0x04, 0x40, 6
123#define SR_PA_EXT_EN 0x04, 0x80, 7 125#define SR_PA_EXT_EN 0x04, 0x80, 7
124#define RG_PHY_TX_PWR (0x05) 126#define RG_PHY_TX_PWR (0x05)
125#define SR_TX_PWR 0x05, 0x0f, 0 127#define SR_TX_PWR 0x05, 0x0f, 0
126#define SR_PA_LT 0x05, 0x30, 4 128#define SR_PA_LT 0x05, 0x30, 4
127#define SR_PA_BUF_LT 0x05, 0xc0, 6 129#define SR_PA_BUF_LT 0x05, 0xc0, 6
128#define RG_PHY_RSSI (0x06) 130#define RG_PHY_RSSI (0x06)
129#define SR_RSSI 0x06, 0x1f, 0 131#define SR_RSSI 0x06, 0x1f, 0
130#define SR_RND_VALUE 0x06, 0x60, 5 132#define SR_RND_VALUE 0x06, 0x60, 5
131#define SR_RX_CRC_VALID 0x06, 0x80, 7 133#define SR_RX_CRC_VALID 0x06, 0x80, 7
132#define RG_PHY_ED_LEVEL (0x07) 134#define RG_PHY_ED_LEVEL (0x07)
133#define SR_ED_LEVEL 0x07, 0xff, 0 135#define SR_ED_LEVEL 0x07, 0xff, 0
134#define RG_PHY_CC_CCA (0x08) 136#define RG_PHY_CC_CCA (0x08)
135#define SR_CHANNEL 0x08, 0x1f, 0 137#define SR_CHANNEL 0x08, 0x1f, 0
136#define SR_CCA_MODE 0x08, 0x60, 5 138#define SR_CCA_MODE 0x08, 0x60, 5
137#define SR_CCA_REQUEST 0x08, 0x80, 7 139#define SR_CCA_REQUEST 0x08, 0x80, 7
138#define RG_CCA_THRES (0x09) 140#define RG_CCA_THRES (0x09)
139#define SR_CCA_ED_THRES 0x09, 0x0f, 0 141#define SR_CCA_ED_THRES 0x09, 0x0f, 0
140#define SR_RESERVED_09_1 0x09, 0xf0, 4 142#define SR_RESERVED_09_1 0x09, 0xf0, 4
141#define RG_RX_CTRL (0x0a) 143#define RG_RX_CTRL (0x0a)
142#define SR_PDT_THRES 0x0a, 0x0f, 0 144#define SR_PDT_THRES 0x0a, 0x0f, 0
143#define SR_RESERVED_0a_1 0x0a, 0xf0, 4 145#define SR_RESERVED_0a_1 0x0a, 0xf0, 4
144#define RG_SFD_VALUE (0x0b) 146#define RG_SFD_VALUE (0x0b)
145#define SR_SFD_VALUE 0x0b, 0xff, 0 147#define SR_SFD_VALUE 0x0b, 0xff, 0
146#define RG_TRX_CTRL_2 (0x0c) 148#define RG_TRX_CTRL_2 (0x0c)
147#define SR_OQPSK_DATA_RATE 0x0c, 0x03, 0 149#define SR_OQPSK_DATA_RATE 0x0c, 0x03, 0
148#define SR_SUB_MODE 0x0c, 0x04, 2 150#define SR_SUB_MODE 0x0c, 0x04, 2
149#define SR_BPSK_QPSK 0x0c, 0x08, 3 151#define SR_BPSK_QPSK 0x0c, 0x08, 3
150#define SR_OQPSK_SUB1_RC_EN 0x0c, 0x10, 4 152#define SR_OQPSK_SUB1_RC_EN 0x0c, 0x10, 4
151#define SR_RESERVED_0c_5 0x0c, 0x60, 5 153#define SR_RESERVED_0c_5 0x0c, 0x60, 5
152#define SR_RX_SAFE_MODE 0x0c, 0x80, 7 154#define SR_RX_SAFE_MODE 0x0c, 0x80, 7
153#define RG_ANT_DIV (0x0d) 155#define RG_ANT_DIV (0x0d)
154#define SR_ANT_CTRL 0x0d, 0x03, 0 156#define SR_ANT_CTRL 0x0d, 0x03, 0
155#define SR_ANT_EXT_SW_EN 0x0d, 0x04, 2 157#define SR_ANT_EXT_SW_EN 0x0d, 0x04, 2
156#define SR_ANT_DIV_EN 0x0d, 0x08, 3 158#define SR_ANT_DIV_EN 0x0d, 0x08, 3
157#define SR_RESERVED_0d_2 0x0d, 0x70, 4 159#define SR_RESERVED_0d_2 0x0d, 0x70, 4
158#define SR_ANT_SEL 0x0d, 0x80, 7 160#define SR_ANT_SEL 0x0d, 0x80, 7
159#define RG_IRQ_MASK (0x0e) 161#define RG_IRQ_MASK (0x0e)
160#define SR_IRQ_MASK 0x0e, 0xff, 0 162#define SR_IRQ_MASK 0x0e, 0xff, 0
161#define RG_IRQ_STATUS (0x0f) 163#define RG_IRQ_STATUS (0x0f)
162#define SR_IRQ_0_PLL_LOCK 0x0f, 0x01, 0 164#define SR_IRQ_0_PLL_LOCK 0x0f, 0x01, 0
163#define SR_IRQ_1_PLL_UNLOCK 0x0f, 0x02, 1 165#define SR_IRQ_1_PLL_UNLOCK 0x0f, 0x02, 1
164#define SR_IRQ_2_RX_START 0x0f, 0x04, 2 166#define SR_IRQ_2_RX_START 0x0f, 0x04, 2
165#define SR_IRQ_3_TRX_END 0x0f, 0x08, 3 167#define SR_IRQ_3_TRX_END 0x0f, 0x08, 3
166#define SR_IRQ_4_CCA_ED_DONE 0x0f, 0x10, 4 168#define SR_IRQ_4_CCA_ED_DONE 0x0f, 0x10, 4
167#define SR_IRQ_5_AMI 0x0f, 0x20, 5 169#define SR_IRQ_5_AMI 0x0f, 0x20, 5
168#define SR_IRQ_6_TRX_UR 0x0f, 0x40, 6 170#define SR_IRQ_6_TRX_UR 0x0f, 0x40, 6
169#define SR_IRQ_7_BAT_LOW 0x0f, 0x80, 7 171#define SR_IRQ_7_BAT_LOW 0x0f, 0x80, 7
170#define RG_VREG_CTRL (0x10) 172#define RG_VREG_CTRL (0x10)
171#define SR_RESERVED_10_6 0x10, 0x03, 0 173#define SR_RESERVED_10_6 0x10, 0x03, 0
172#define SR_DVDD_OK 0x10, 0x04, 2 174#define SR_DVDD_OK 0x10, 0x04, 2
173#define SR_DVREG_EXT 0x10, 0x08, 3 175#define SR_DVREG_EXT 0x10, 0x08, 3
174#define SR_RESERVED_10_3 0x10, 0x30, 4 176#define SR_RESERVED_10_3 0x10, 0x30, 4
175#define SR_AVDD_OK 0x10, 0x40, 6 177#define SR_AVDD_OK 0x10, 0x40, 6
176#define SR_AVREG_EXT 0x10, 0x80, 7 178#define SR_AVREG_EXT 0x10, 0x80, 7
177#define RG_BATMON (0x11) 179#define RG_BATMON (0x11)
178#define SR_BATMON_VTH 0x11, 0x0f, 0 180#define SR_BATMON_VTH 0x11, 0x0f, 0
179#define SR_BATMON_HR 0x11, 0x10, 4 181#define SR_BATMON_HR 0x11, 0x10, 4
180#define SR_BATMON_OK 0x11, 0x20, 5 182#define SR_BATMON_OK 0x11, 0x20, 5
181#define SR_RESERVED_11_1 0x11, 0xc0, 6 183#define SR_RESERVED_11_1 0x11, 0xc0, 6
182#define RG_XOSC_CTRL (0x12) 184#define RG_XOSC_CTRL (0x12)
183#define SR_XTAL_TRIM 0x12, 0x0f, 0 185#define SR_XTAL_TRIM 0x12, 0x0f, 0
184#define SR_XTAL_MODE 0x12, 0xf0, 4 186#define SR_XTAL_MODE 0x12, 0xf0, 4
185#define RG_RX_SYN (0x15) 187#define RG_RX_SYN (0x15)
186#define SR_RX_PDT_LEVEL 0x15, 0x0f, 0 188#define SR_RX_PDT_LEVEL 0x15, 0x0f, 0
187#define SR_RESERVED_15_2 0x15, 0x70, 4 189#define SR_RESERVED_15_2 0x15, 0x70, 4
188#define SR_RX_PDT_DIS 0x15, 0x80, 7 190#define SR_RX_PDT_DIS 0x15, 0x80, 7
189#define RG_XAH_CTRL_1 (0x17) 191#define RG_XAH_CTRL_1 (0x17)
190#define SR_RESERVED_17_8 0x17, 0x01, 0 192#define SR_RESERVED_17_8 0x17, 0x01, 0
191#define SR_AACK_PROM_MODE 0x17, 0x02, 1 193#define SR_AACK_PROM_MODE 0x17, 0x02, 1
192#define SR_AACK_ACK_TIME 0x17, 0x04, 2 194#define SR_AACK_ACK_TIME 0x17, 0x04, 2
193#define SR_RESERVED_17_5 0x17, 0x08, 3 195#define SR_RESERVED_17_5 0x17, 0x08, 3
194#define SR_AACK_UPLD_RES_FT 0x17, 0x10, 4 196#define SR_AACK_UPLD_RES_FT 0x17, 0x10, 4
195#define SR_AACK_FLTR_RES_FT 0x17, 0x20, 5 197#define SR_AACK_FLTR_RES_FT 0x17, 0x20, 5
196#define SR_CSMA_LBT_MODE 0x17, 0x40, 6 198#define SR_CSMA_LBT_MODE 0x17, 0x40, 6
197#define SR_RESERVED_17_1 0x17, 0x80, 7 199#define SR_RESERVED_17_1 0x17, 0x80, 7
198#define RG_FTN_CTRL (0x18) 200#define RG_FTN_CTRL (0x18)
199#define SR_RESERVED_18_2 0x18, 0x7f, 0 201#define SR_RESERVED_18_2 0x18, 0x7f, 0
200#define SR_FTN_START 0x18, 0x80, 7 202#define SR_FTN_START 0x18, 0x80, 7
201#define RG_PLL_CF (0x1a) 203#define RG_PLL_CF (0x1a)
202#define SR_RESERVED_1a_2 0x1a, 0x7f, 0 204#define SR_RESERVED_1a_2 0x1a, 0x7f, 0
203#define SR_PLL_CF_START 0x1a, 0x80, 7 205#define SR_PLL_CF_START 0x1a, 0x80, 7
204#define RG_PLL_DCU (0x1b) 206#define RG_PLL_DCU (0x1b)
205#define SR_RESERVED_1b_3 0x1b, 0x3f, 0 207#define SR_RESERVED_1b_3 0x1b, 0x3f, 0
206#define SR_RESERVED_1b_2 0x1b, 0x40, 6 208#define SR_RESERVED_1b_2 0x1b, 0x40, 6
207#define SR_PLL_DCU_START 0x1b, 0x80, 7 209#define SR_PLL_DCU_START 0x1b, 0x80, 7
208#define RG_PART_NUM (0x1c) 210#define RG_PART_NUM (0x1c)
209#define SR_PART_NUM 0x1c, 0xff, 0 211#define SR_PART_NUM 0x1c, 0xff, 0
210#define RG_VERSION_NUM (0x1d) 212#define RG_VERSION_NUM (0x1d)
211#define SR_VERSION_NUM 0x1d, 0xff, 0 213#define SR_VERSION_NUM 0x1d, 0xff, 0
212#define RG_MAN_ID_0 (0x1e) 214#define RG_MAN_ID_0 (0x1e)
213#define SR_MAN_ID_0 0x1e, 0xff, 0 215#define SR_MAN_ID_0 0x1e, 0xff, 0
214#define RG_MAN_ID_1 (0x1f) 216#define RG_MAN_ID_1 (0x1f)
215#define SR_MAN_ID_1 0x1f, 0xff, 0 217#define SR_MAN_ID_1 0x1f, 0xff, 0
216#define RG_SHORT_ADDR_0 (0x20) 218#define RG_SHORT_ADDR_0 (0x20)
217#define SR_SHORT_ADDR_0 0x20, 0xff, 0 219#define SR_SHORT_ADDR_0 0x20, 0xff, 0
218#define RG_SHORT_ADDR_1 (0x21) 220#define RG_SHORT_ADDR_1 (0x21)
219#define SR_SHORT_ADDR_1 0x21, 0xff, 0 221#define SR_SHORT_ADDR_1 0x21, 0xff, 0
220#define RG_PAN_ID_0 (0x22) 222#define RG_PAN_ID_0 (0x22)
221#define SR_PAN_ID_0 0x22, 0xff, 0 223#define SR_PAN_ID_0 0x22, 0xff, 0
222#define RG_PAN_ID_1 (0x23) 224#define RG_PAN_ID_1 (0x23)
223#define SR_PAN_ID_1 0x23, 0xff, 0 225#define SR_PAN_ID_1 0x23, 0xff, 0
224#define RG_IEEE_ADDR_0 (0x24) 226#define RG_IEEE_ADDR_0 (0x24)
225#define SR_IEEE_ADDR_0 0x24, 0xff, 0 227#define SR_IEEE_ADDR_0 0x24, 0xff, 0
226#define RG_IEEE_ADDR_1 (0x25) 228#define RG_IEEE_ADDR_1 (0x25)
227#define SR_IEEE_ADDR_1 0x25, 0xff, 0 229#define SR_IEEE_ADDR_1 0x25, 0xff, 0
228#define RG_IEEE_ADDR_2 (0x26) 230#define RG_IEEE_ADDR_2 (0x26)
229#define SR_IEEE_ADDR_2 0x26, 0xff, 0 231#define SR_IEEE_ADDR_2 0x26, 0xff, 0
230#define RG_IEEE_ADDR_3 (0x27) 232#define RG_IEEE_ADDR_3 (0x27)
231#define SR_IEEE_ADDR_3 0x27, 0xff, 0 233#define SR_IEEE_ADDR_3 0x27, 0xff, 0
232#define RG_IEEE_ADDR_4 (0x28) 234#define RG_IEEE_ADDR_4 (0x28)
233#define SR_IEEE_ADDR_4 0x28, 0xff, 0 235#define SR_IEEE_ADDR_4 0x28, 0xff, 0
234#define RG_IEEE_ADDR_5 (0x29) 236#define RG_IEEE_ADDR_5 (0x29)
235#define SR_IEEE_ADDR_5 0x29, 0xff, 0 237#define SR_IEEE_ADDR_5 0x29, 0xff, 0
236#define RG_IEEE_ADDR_6 (0x2a) 238#define RG_IEEE_ADDR_6 (0x2a)
237#define SR_IEEE_ADDR_6 0x2a, 0xff, 0 239#define SR_IEEE_ADDR_6 0x2a, 0xff, 0
238#define RG_IEEE_ADDR_7 (0x2b) 240#define RG_IEEE_ADDR_7 (0x2b)
239#define SR_IEEE_ADDR_7 0x2b, 0xff, 0 241#define SR_IEEE_ADDR_7 0x2b, 0xff, 0
240#define RG_XAH_CTRL_0 (0x2c) 242#define RG_XAH_CTRL_0 (0x2c)
241#define SR_SLOTTED_OPERATION 0x2c, 0x01, 0 243#define SR_SLOTTED_OPERATION 0x2c, 0x01, 0
242#define SR_MAX_CSMA_RETRIES 0x2c, 0x0e, 1 244#define SR_MAX_CSMA_RETRIES 0x2c, 0x0e, 1
243#define SR_MAX_FRAME_RETRIES 0x2c, 0xf0, 4 245#define SR_MAX_FRAME_RETRIES 0x2c, 0xf0, 4
244#define RG_CSMA_SEED_0 (0x2d) 246#define RG_CSMA_SEED_0 (0x2d)
245#define SR_CSMA_SEED_0 0x2d, 0xff, 0 247#define SR_CSMA_SEED_0 0x2d, 0xff, 0
246#define RG_CSMA_SEED_1 (0x2e) 248#define RG_CSMA_SEED_1 (0x2e)
247#define SR_CSMA_SEED_1 0x2e, 0x07, 0 249#define SR_CSMA_SEED_1 0x2e, 0x07, 0
248#define SR_AACK_I_AM_COORD 0x2e, 0x08, 3 250#define SR_AACK_I_AM_COORD 0x2e, 0x08, 3
249#define SR_AACK_DIS_ACK 0x2e, 0x10, 4 251#define SR_AACK_DIS_ACK 0x2e, 0x10, 4
250#define SR_AACK_SET_PD 0x2e, 0x20, 5 252#define SR_AACK_SET_PD 0x2e, 0x20, 5
251#define SR_AACK_FVN_MODE 0x2e, 0xc0, 6 253#define SR_AACK_FVN_MODE 0x2e, 0xc0, 6
252#define RG_CSMA_BE (0x2f) 254#define RG_CSMA_BE (0x2f)
253#define SR_MIN_BE 0x2f, 0x0f, 0 255#define SR_MIN_BE 0x2f, 0x0f, 0
254#define SR_MAX_BE 0x2f, 0xf0, 4 256#define SR_MAX_BE 0x2f, 0xf0, 4
255 257
256#define CMD_REG 0x80 258#define CMD_REG 0x80
257#define CMD_REG_MASK 0x3f 259#define CMD_REG_MASK 0x3f
@@ -292,6 +294,8 @@ struct at86rf230_local {
292#define STATE_BUSY_RX_AACK_NOCLK 0x1E 294#define STATE_BUSY_RX_AACK_NOCLK 0x1E
293#define STATE_TRANSITION_IN_PROGRESS 0x1F 295#define STATE_TRANSITION_IN_PROGRESS 0x1F
294 296
297#define TRX_STATE_MASK (0x1F)
298
295#define AT86RF2XX_NUMREGS 0x3F 299#define AT86RF2XX_NUMREGS 0x3F
296 300
297static void 301static void
@@ -336,6 +340,14 @@ at86rf230_write_subreg(struct at86rf230_local *lp,
336 return regmap_update_bits(lp->regmap, addr, mask, data << shift); 340 return regmap_update_bits(lp->regmap, addr, mask, data << shift);
337} 341}
338 342
343static inline void
344at86rf230_slp_tr_rising_edge(struct at86rf230_local *lp)
345{
346 gpio_set_value(lp->slp_tr, 1);
347 udelay(1);
348 gpio_set_value(lp->slp_tr, 0);
349}
350
339static bool 351static bool
340at86rf230_reg_writeable(struct device *dev, unsigned int reg) 352at86rf230_reg_writeable(struct device *dev, unsigned int reg)
341{ 353{
@@ -509,7 +521,7 @@ at86rf230_async_state_assert(void *context)
509 struct at86rf230_state_change *ctx = context; 521 struct at86rf230_state_change *ctx = context;
510 struct at86rf230_local *lp = ctx->lp; 522 struct at86rf230_local *lp = ctx->lp;
511 const u8 *buf = ctx->buf; 523 const u8 *buf = ctx->buf;
512 const u8 trx_state = buf[1] & 0x1f; 524 const u8 trx_state = buf[1] & TRX_STATE_MASK;
513 525
514 /* Assert state change */ 526 /* Assert state change */
515 if (trx_state != ctx->to_state) { 527 if (trx_state != ctx->to_state) {
@@ -609,11 +621,17 @@ at86rf230_async_state_delay(void *context)
609 switch (ctx->to_state) { 621 switch (ctx->to_state) {
610 case STATE_RX_AACK_ON: 622 case STATE_RX_AACK_ON:
611 tim = ktime_set(0, c->t_off_to_aack * NSEC_PER_USEC); 623 tim = ktime_set(0, c->t_off_to_aack * NSEC_PER_USEC);
624 /* state change from TRX_OFF to RX_AACK_ON to do a
625 * calibration, we need to reset the timeout for the
626 * next one.
627 */
628 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
612 goto change; 629 goto change;
630 case STATE_TX_ARET_ON:
613 case STATE_TX_ON: 631 case STATE_TX_ON:
614 tim = ktime_set(0, c->t_off_to_tx_on * NSEC_PER_USEC); 632 tim = ktime_set(0, c->t_off_to_tx_on * NSEC_PER_USEC);
615 /* state change from TRX_OFF to TX_ON to do a 633 /* state change from TRX_OFF to TX_ON or ARET_ON to do
616 * calibration, we need to reset the timeout for the 634 * a calibration, we need to reset the timeout for the
617 * next one. 635 * next one.
618 */ 636 */
619 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT; 637 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
@@ -667,7 +685,7 @@ at86rf230_async_state_change_start(void *context)
667 struct at86rf230_state_change *ctx = context; 685 struct at86rf230_state_change *ctx = context;
668 struct at86rf230_local *lp = ctx->lp; 686 struct at86rf230_local *lp = ctx->lp;
669 u8 *buf = ctx->buf; 687 u8 *buf = ctx->buf;
670 const u8 trx_state = buf[1] & 0x1f; 688 const u8 trx_state = buf[1] & TRX_STATE_MASK;
671 int rc; 689 int rc;
672 690
673 /* Check for "possible" STATE_TRANSITION_IN_PROGRESS */ 691 /* Check for "possible" STATE_TRANSITION_IN_PROGRESS */
@@ -773,16 +791,6 @@ at86rf230_tx_on(void *context)
773} 791}
774 792
775static void 793static void
776at86rf230_tx_trac_error(void *context)
777{
778 struct at86rf230_state_change *ctx = context;
779 struct at86rf230_local *lp = ctx->lp;
780
781 at86rf230_async_state_change(lp, ctx, STATE_TX_ON,
782 at86rf230_tx_on, true);
783}
784
785static void
786at86rf230_tx_trac_check(void *context) 794at86rf230_tx_trac_check(void *context)
787{ 795{
788 struct at86rf230_state_change *ctx = context; 796 struct at86rf230_state_change *ctx = context;
@@ -791,12 +799,12 @@ at86rf230_tx_trac_check(void *context)
791 const u8 trac = (buf[1] & 0xe0) >> 5; 799 const u8 trac = (buf[1] & 0xe0) >> 5;
792 800
793 /* If trac status is different than zero we need to do a state change 801 /* If trac status is different than zero we need to do a state change
794 * to STATE_FORCE_TRX_OFF then STATE_TX_ON to recover the transceiver 802 * to STATE_FORCE_TRX_OFF then STATE_RX_AACK_ON to recover the
795 * state to TX_ON. 803 * transceiver.
796 */ 804 */
797 if (trac) 805 if (trac)
798 at86rf230_async_state_change(lp, ctx, STATE_FORCE_TRX_OFF, 806 at86rf230_async_state_change(lp, ctx, STATE_FORCE_TRX_OFF,
799 at86rf230_tx_trac_error, true); 807 at86rf230_tx_on, true);
800 else 808 else
801 at86rf230_tx_on(context); 809 at86rf230_tx_on(context);
802} 810}
@@ -941,13 +949,18 @@ at86rf230_write_frame_complete(void *context)
941 u8 *buf = ctx->buf; 949 u8 *buf = ctx->buf;
942 int rc; 950 int rc;
943 951
944 buf[0] = (RG_TRX_STATE & CMD_REG_MASK) | CMD_REG | CMD_WRITE;
945 buf[1] = STATE_BUSY_TX;
946 ctx->trx.len = 2; 952 ctx->trx.len = 2;
947 ctx->msg.complete = NULL; 953
948 rc = spi_async(lp->spi, &ctx->msg); 954 if (gpio_is_valid(lp->slp_tr)) {
949 if (rc) 955 at86rf230_slp_tr_rising_edge(lp);
950 at86rf230_async_error(lp, ctx, rc); 956 } else {
957 buf[0] = (RG_TRX_STATE & CMD_REG_MASK) | CMD_REG | CMD_WRITE;
958 buf[1] = STATE_BUSY_TX;
959 ctx->msg.complete = NULL;
960 rc = spi_async(lp->spi, &ctx->msg);
961 if (rc)
962 at86rf230_async_error(lp, ctx, rc);
963 }
951} 964}
952 965
953static void 966static void
@@ -993,12 +1006,21 @@ at86rf230_xmit_start(void *context)
993 * are in STATE_TX_ON. The pfad differs here, so we change 1006 * are in STATE_TX_ON. The pfad differs here, so we change
994 * the complete handler. 1007 * the complete handler.
995 */ 1008 */
996 if (lp->tx_aret) 1009 if (lp->tx_aret) {
997 at86rf230_async_state_change(lp, ctx, STATE_TX_ON, 1010 if (lp->is_tx_from_off) {
998 at86rf230_xmit_tx_on, false); 1011 lp->is_tx_from_off = false;
999 else 1012 at86rf230_async_state_change(lp, ctx, STATE_TX_ARET_ON,
1013 at86rf230_xmit_tx_on,
1014 false);
1015 } else {
1016 at86rf230_async_state_change(lp, ctx, STATE_TX_ON,
1017 at86rf230_xmit_tx_on,
1018 false);
1019 }
1020 } else {
1000 at86rf230_async_state_change(lp, ctx, STATE_TX_ON, 1021 at86rf230_async_state_change(lp, ctx, STATE_TX_ON,
1001 at86rf230_write_frame, false); 1022 at86rf230_write_frame, false);
1023 }
1002} 1024}
1003 1025
1004static int 1026static int
@@ -1017,11 +1039,13 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
1017 * to TX_ON, the lp->cal_timeout should be reinit by state_delay 1039 * to TX_ON, the lp->cal_timeout should be reinit by state_delay
1018 * function then to start in the next 5 minutes. 1040 * function then to start in the next 5 minutes.
1019 */ 1041 */
1020 if (time_is_before_jiffies(lp->cal_timeout)) 1042 if (time_is_before_jiffies(lp->cal_timeout)) {
1043 lp->is_tx_from_off = true;
1021 at86rf230_async_state_change(lp, ctx, STATE_TRX_OFF, 1044 at86rf230_async_state_change(lp, ctx, STATE_TRX_OFF,
1022 at86rf230_xmit_start, false); 1045 at86rf230_xmit_start, false);
1023 else 1046 } else {
1024 at86rf230_xmit_start(ctx); 1047 at86rf230_xmit_start(ctx);
1048 }
1025 1049
1026 return 0; 1050 return 0;
1027} 1051}
@@ -1037,9 +1061,6 @@ at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
1037static int 1061static int
1038at86rf230_start(struct ieee802154_hw *hw) 1062at86rf230_start(struct ieee802154_hw *hw)
1039{ 1063{
1040 struct at86rf230_local *lp = hw->priv;
1041
1042 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
1043 return at86rf230_sync_state_change(hw->priv, STATE_RX_AACK_ON); 1064 return at86rf230_sync_state_change(hw->priv, STATE_RX_AACK_ON);
1044} 1065}
1045 1066
@@ -1673,6 +1694,7 @@ static int at86rf230_probe(struct spi_device *spi)
1673 lp = hw->priv; 1694 lp = hw->priv;
1674 lp->hw = hw; 1695 lp->hw = hw;
1675 lp->spi = spi; 1696 lp->spi = spi;
1697 lp->slp_tr = slp_tr;
1676 hw->parent = &spi->dev; 1698 hw->parent = &spi->dev;
1677 hw->vif_data_size = sizeof(*lp); 1699 hw->vif_data_size = sizeof(*lp);
1678 ieee802154_random_extended_addr(&hw->phy->perm_extended_addr); 1700 ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index b227a13f6473..9f59f17dc317 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -599,10 +599,18 @@ static int macvlan_open(struct net_device *dev)
599 goto del_unicast; 599 goto del_unicast;
600 } 600 }
601 601
602 if (dev->flags & IFF_PROMISC) {
603 err = dev_set_promiscuity(lowerdev, 1);
604 if (err < 0)
605 goto clear_multi;
606 }
607
602hash_add: 608hash_add:
603 macvlan_hash_add(vlan); 609 macvlan_hash_add(vlan);
604 return 0; 610 return 0;
605 611
612clear_multi:
613 dev_set_allmulti(lowerdev, -1);
606del_unicast: 614del_unicast:
607 dev_uc_del(lowerdev, dev->dev_addr); 615 dev_uc_del(lowerdev, dev->dev_addr);
608out: 616out:
@@ -638,6 +646,9 @@ static int macvlan_stop(struct net_device *dev)
638 if (dev->flags & IFF_ALLMULTI) 646 if (dev->flags & IFF_ALLMULTI)
639 dev_set_allmulti(lowerdev, -1); 647 dev_set_allmulti(lowerdev, -1);
640 648
649 if (dev->flags & IFF_PROMISC)
650 dev_set_promiscuity(lowerdev, -1);
651
641 dev_uc_del(lowerdev, dev->dev_addr); 652 dev_uc_del(lowerdev, dev->dev_addr);
642 653
643hash_del: 654hash_del:
@@ -696,6 +707,10 @@ static void macvlan_change_rx_flags(struct net_device *dev, int change)
696 if (dev->flags & IFF_UP) { 707 if (dev->flags & IFF_UP) {
697 if (change & IFF_ALLMULTI) 708 if (change & IFF_ALLMULTI)
698 dev_set_allmulti(lowerdev, dev->flags & IFF_ALLMULTI ? 1 : -1); 709 dev_set_allmulti(lowerdev, dev->flags & IFF_ALLMULTI ? 1 : -1);
710 if (change & IFF_PROMISC)
711 dev_set_promiscuity(lowerdev,
712 dev->flags & IFF_PROMISC ? 1 : -1);
713
699 } 714 }
700} 715}
701 716
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 8fadaa14b9f0..70641d2c0429 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -27,6 +27,7 @@ config AMD_PHY
27config AMD_XGBE_PHY 27config AMD_XGBE_PHY
28 tristate "Driver for the AMD 10GbE (amd-xgbe) PHYs" 28 tristate "Driver for the AMD 10GbE (amd-xgbe) PHYs"
29 depends on (OF || ACPI) && HAS_IOMEM 29 depends on (OF || ACPI) && HAS_IOMEM
30 depends on ARM64 || COMPILE_TEST
30 ---help--- 31 ---help---
31 Currently supports the AMD 10GbE PHY 32 Currently supports the AMD 10GbE PHY
32 33
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index c9cb486c753d..53d18150f4e2 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -168,7 +168,10 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
168 if (!new_bus->irq[i]) 168 if (!new_bus->irq[i])
169 new_bus->irq[i] = PHY_POLL; 169 new_bus->irq[i] = PHY_POLL;
170 170
171 snprintf(new_bus->id, MII_BUS_ID_SIZE, "gpio-%x", bus_id); 171 if (bus_id != -1)
172 snprintf(new_bus->id, MII_BUS_ID_SIZE, "gpio-%x", bus_id);
173 else
174 strncpy(new_bus->id, "gpio", MII_BUS_ID_SIZE);
172 175
173 if (devm_gpio_request(dev, bitbang->mdc, "mdc")) 176 if (devm_gpio_request(dev, bitbang->mdc, "mdc"))
174 goto out_free_bus; 177 goto out_free_bus;
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 1190fd8f0088..ebdc357c5131 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -548,7 +548,8 @@ static int kszphy_probe(struct phy_device *phydev)
548 } 548 }
549 549
550 clk = devm_clk_get(&phydev->dev, "rmii-ref"); 550 clk = devm_clk_get(&phydev->dev, "rmii-ref");
551 if (!IS_ERR(clk)) { 551 /* NOTE: clk may be NULL if building without CONFIG_HAVE_CLK */
552 if (!IS_ERR_OR_NULL(clk)) {
552 unsigned long rate = clk_get_rate(clk); 553 unsigned long rate = clk_get_rate(clk);
553 bool rmii_ref_clk_sel_25_mhz; 554 bool rmii_ref_clk_sel_25_mhz;
554 555
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index aa1dd926623a..b62a5e3a1c65 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -465,6 +465,10 @@ static void pppoe_unbind_sock_work(struct work_struct *work)
465 struct sock *sk = sk_pppox(po); 465 struct sock *sk = sk_pppox(po);
466 466
467 lock_sock(sk); 467 lock_sock(sk);
468 if (po->pppoe_dev) {
469 dev_put(po->pppoe_dev);
470 po->pppoe_dev = NULL;
471 }
468 pppox_unbind_sock(sk); 472 pppox_unbind_sock(sk);
469 release_sock(sk); 473 release_sock(sk);
470 sock_put(sk); 474 sock_put(sk);
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index ac4d03b328b1..aafa1a1898e4 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -4116,6 +4116,7 @@ static struct usb_device_id rtl8152_table[] = {
4116 {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)}, 4116 {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)},
4117 {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)}, 4117 {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)},
4118 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205)}, 4118 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205)},
4119 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)},
4119 {} 4120 {}
4120}; 4121};
4121 4122
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 733f4feb2ef3..3c86b107275a 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1285,7 +1285,7 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
1285 struct net_device *net) 1285 struct net_device *net)
1286{ 1286{
1287 struct usbnet *dev = netdev_priv(net); 1287 struct usbnet *dev = netdev_priv(net);
1288 int length; 1288 unsigned int length;
1289 struct urb *urb = NULL; 1289 struct urb *urb = NULL;
1290 struct skb_data *entry; 1290 struct skb_data *entry;
1291 struct driver_info *info = dev->driver_info; 1291 struct driver_info *info = dev->driver_info;
@@ -1413,7 +1413,7 @@ not_drop:
1413 } 1413 }
1414 } else 1414 } else
1415 netif_dbg(dev, tx_queued, dev->net, 1415 netif_dbg(dev, tx_queued, dev->net,
1416 "> tx, len %d, type 0x%x\n", length, skb->protocol); 1416 "> tx, len %u, type 0x%x\n", length, skb->protocol);
1417#ifdef CONFIG_PM 1417#ifdef CONFIG_PM
1418deferred: 1418deferred:
1419#endif 1419#endif
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 0acd079ba96b..3ad79bb4f2c2 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1103,28 +1103,14 @@ static u8 ath_get_rate_txpower(struct ath_softc *sc, struct ath_buf *bf,
1103 struct sk_buff *skb; 1103 struct sk_buff *skb;
1104 struct ath_frame_info *fi; 1104 struct ath_frame_info *fi;
1105 struct ieee80211_tx_info *info; 1105 struct ieee80211_tx_info *info;
1106 struct ieee80211_vif *vif;
1107 struct ath_hw *ah = sc->sc_ah; 1106 struct ath_hw *ah = sc->sc_ah;
1108 1107
1109 if (sc->tx99_state || !ah->tpc_enabled) 1108 if (sc->tx99_state || !ah->tpc_enabled)
1110 return MAX_RATE_POWER; 1109 return MAX_RATE_POWER;
1111 1110
1112 skb = bf->bf_mpdu; 1111 skb = bf->bf_mpdu;
1113 info = IEEE80211_SKB_CB(skb);
1114 vif = info->control.vif;
1115
1116 if (!vif) {
1117 max_power = sc->cur_chan->cur_txpower;
1118 goto out;
1119 }
1120
1121 if (vif->bss_conf.txpower_type != NL80211_TX_POWER_LIMITED) {
1122 max_power = min_t(u8, sc->cur_chan->cur_txpower,
1123 2 * vif->bss_conf.txpower);
1124 goto out;
1125 }
1126
1127 fi = get_frame_info(skb); 1112 fi = get_frame_info(skb);
1113 info = IEEE80211_SKB_CB(skb);
1128 1114
1129 if (!AR_SREV_9300_20_OR_LATER(ah)) { 1115 if (!AR_SREV_9300_20_OR_LATER(ah)) {
1130 int txpower = fi->tx_power; 1116 int txpower = fi->tx_power;
@@ -1161,25 +1147,26 @@ static u8 ath_get_rate_txpower(struct ath_softc *sc, struct ath_buf *bf,
1161 txpower -= 2; 1147 txpower -= 2;
1162 1148
1163 txpower = max(txpower, 0); 1149 txpower = max(txpower, 0);
1164 max_power = min_t(u8, ah->tx_power[rateidx], 1150 max_power = min_t(u8, ah->tx_power[rateidx], txpower);
1165 2 * vif->bss_conf.txpower); 1151
1166 max_power = min_t(u8, max_power, txpower); 1152 /* XXX: clamp minimum TX power at 1 for AR9160 since if
1153 * max_power is set to 0, frames are transmitted at max
1154 * TX power
1155 */
1156 if (!max_power && !AR_SREV_9280_20_OR_LATER(ah))
1157 max_power = 1;
1167 } else if (!bf->bf_state.bfs_paprd) { 1158 } else if (!bf->bf_state.bfs_paprd) {
1168 if (rateidx < 8 && (info->flags & IEEE80211_TX_CTL_STBC)) 1159 if (rateidx < 8 && (info->flags & IEEE80211_TX_CTL_STBC))
1169 max_power = min_t(u8, ah->tx_power_stbc[rateidx], 1160 max_power = min_t(u8, ah->tx_power_stbc[rateidx],
1170 2 * vif->bss_conf.txpower); 1161 fi->tx_power);
1171 else 1162 else
1172 max_power = min_t(u8, ah->tx_power[rateidx], 1163 max_power = min_t(u8, ah->tx_power[rateidx],
1173 2 * vif->bss_conf.txpower); 1164 fi->tx_power);
1174 max_power = min(max_power, fi->tx_power);
1175 } else { 1165 } else {
1176 max_power = ah->paprd_training_power; 1166 max_power = ah->paprd_training_power;
1177 } 1167 }
1178out: 1168
1179 /* XXX: clamp minimum TX power at 1 for AR9160 since if max_power 1169 return max_power;
1180 * is set to 0, frames are transmitted at max TX power
1181 */
1182 return (!max_power && !AR_SREV_9280_20_OR_LATER(ah)) ? 1 : max_power;
1183} 1170}
1184 1171
1185static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf, 1172static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf,
@@ -2129,6 +2116,7 @@ static void setup_frame_info(struct ieee80211_hw *hw,
2129 struct ath_node *an = NULL; 2116 struct ath_node *an = NULL;
2130 enum ath9k_key_type keytype; 2117 enum ath9k_key_type keytype;
2131 bool short_preamble = false; 2118 bool short_preamble = false;
2119 u8 txpower;
2132 2120
2133 /* 2121 /*
2134 * We check if Short Preamble is needed for the CTS rate by 2122 * We check if Short Preamble is needed for the CTS rate by
@@ -2145,6 +2133,16 @@ static void setup_frame_info(struct ieee80211_hw *hw,
2145 if (sta) 2133 if (sta)
2146 an = (struct ath_node *) sta->drv_priv; 2134 an = (struct ath_node *) sta->drv_priv;
2147 2135
2136 if (tx_info->control.vif) {
2137 struct ieee80211_vif *vif = tx_info->control.vif;
2138
2139 txpower = 2 * vif->bss_conf.txpower;
2140 } else {
2141 struct ath_softc *sc = hw->priv;
2142
2143 txpower = sc->cur_chan->cur_txpower;
2144 }
2145
2148 memset(fi, 0, sizeof(*fi)); 2146 memset(fi, 0, sizeof(*fi));
2149 fi->txq = -1; 2147 fi->txq = -1;
2150 if (hw_key) 2148 if (hw_key)
@@ -2155,7 +2153,7 @@ static void setup_frame_info(struct ieee80211_hw *hw,
2155 fi->keyix = ATH9K_TXKEYIX_INVALID; 2153 fi->keyix = ATH9K_TXKEYIX_INVALID;
2156 fi->keytype = keytype; 2154 fi->keytype = keytype;
2157 fi->framelen = framelen; 2155 fi->framelen = framelen;
2158 fi->tx_power = MAX_RATE_POWER; 2156 fi->tx_power = txpower;
2159 2157
2160 if (!rate) 2158 if (!rate)
2161 return; 2159 return;
diff --git a/drivers/net/wireless/iwlwifi/iwl-fw-file.h b/drivers/net/wireless/iwlwifi/iwl-fw-file.h
index bfdf3faa6c47..62db2e5e45eb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-fw-file.h
+++ b/drivers/net/wireless/iwlwifi/iwl-fw-file.h
@@ -244,6 +244,7 @@ enum iwl_ucode_tlv_flag {
244 * longer than the passive one, which is essential for fragmented scan. 244 * longer than the passive one, which is essential for fragmented scan.
245 * @IWL_UCODE_TLV_API_WIFI_MCC_UPDATE: ucode supports MCC updates with source. 245 * @IWL_UCODE_TLV_API_WIFI_MCC_UPDATE: ucode supports MCC updates with source.
246 * IWL_UCODE_TLV_API_HDC_PHASE_0: ucode supports finer configuration of LTR 246 * IWL_UCODE_TLV_API_HDC_PHASE_0: ucode supports finer configuration of LTR
247 * @IWL_UCODE_TLV_API_TX_POWER_DEV: new API for tx power.
247 * @IWL_UCODE_TLV_API_BASIC_DWELL: use only basic dwell time in scan command, 248 * @IWL_UCODE_TLV_API_BASIC_DWELL: use only basic dwell time in scan command,
248 * regardless of the band or the number of the probes. FW will calculate 249 * regardless of the band or the number of the probes. FW will calculate
249 * the actual dwell time. 250 * the actual dwell time.
@@ -260,6 +261,7 @@ enum iwl_ucode_tlv_api {
260 IWL_UCODE_TLV_API_FRAGMENTED_SCAN = BIT(8), 261 IWL_UCODE_TLV_API_FRAGMENTED_SCAN = BIT(8),
261 IWL_UCODE_TLV_API_WIFI_MCC_UPDATE = BIT(9), 262 IWL_UCODE_TLV_API_WIFI_MCC_UPDATE = BIT(9),
262 IWL_UCODE_TLV_API_HDC_PHASE_0 = BIT(10), 263 IWL_UCODE_TLV_API_HDC_PHASE_0 = BIT(10),
264 IWL_UCODE_TLV_API_TX_POWER_DEV = BIT(11),
263 IWL_UCODE_TLV_API_BASIC_DWELL = BIT(13), 265 IWL_UCODE_TLV_API_BASIC_DWELL = BIT(13),
264 IWL_UCODE_TLV_API_SCD_CFG = BIT(15), 266 IWL_UCODE_TLV_API_SCD_CFG = BIT(15),
265 IWL_UCODE_TLV_API_SINGLE_SCAN_EBS = BIT(16), 267 IWL_UCODE_TLV_API_SINGLE_SCAN_EBS = BIT(16),
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h
index 6dfed1259260..56254a837214 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.h
@@ -6,7 +6,7 @@
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved. 8 * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH 9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as 12 * it under the terms of version 2 of the GNU General Public License as
@@ -32,7 +32,7 @@
32 * BSD LICENSE 32 * BSD LICENSE
33 * 33 *
34 * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved. 34 * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
35 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH 35 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
36 * All rights reserved. 36 * All rights reserved.
37 * 37 *
38 * Redistribution and use in source and binary forms, with or without 38 * Redistribution and use in source and binary forms, with or without
@@ -421,8 +421,9 @@ struct iwl_trans_txq_scd_cfg {
421 * 421 *
422 * All the handlers MUST be implemented 422 * All the handlers MUST be implemented
423 * 423 *
424 * @start_hw: starts the HW- from that point on, the HW can send interrupts 424 * @start_hw: starts the HW. If low_power is true, the NIC needs to be taken
425 * May sleep 425 * out of a low power state. From that point on, the HW can send
426 * interrupts. May sleep.
426 * @op_mode_leave: Turn off the HW RF kill indication if on 427 * @op_mode_leave: Turn off the HW RF kill indication if on
427 * May sleep 428 * May sleep
428 * @start_fw: allocates and inits all the resources for the transport 429 * @start_fw: allocates and inits all the resources for the transport
@@ -432,10 +433,11 @@ struct iwl_trans_txq_scd_cfg {
432 * the SCD base address in SRAM, then provide it here, or 0 otherwise. 433 * the SCD base address in SRAM, then provide it here, or 0 otherwise.
433 * May sleep 434 * May sleep
434 * @stop_device: stops the whole device (embedded CPU put to reset) and stops 435 * @stop_device: stops the whole device (embedded CPU put to reset) and stops
435 * the HW. From that point on, the HW will be in low power but will still 436 * the HW. If low_power is true, the NIC will be put in low power state.
436 * issue interrupt if the HW RF kill is triggered. This callback must do 437 * From that point on, the HW will be stopped but will still issue an
437 * the right thing and not crash even if start_hw() was called but not 438 * interrupt if the HW RF kill switch is triggered.
438 * start_fw(). May sleep 439 * This callback must do the right thing and not crash even if %start_hw()
440 * was called but not &start_fw(). May sleep.
439 * @d3_suspend: put the device into the correct mode for WoWLAN during 441 * @d3_suspend: put the device into the correct mode for WoWLAN during
440 * suspend. This is optional, if not implemented WoWLAN will not be 442 * suspend. This is optional, if not implemented WoWLAN will not be
441 * supported. This callback may sleep. 443 * supported. This callback may sleep.
@@ -491,14 +493,14 @@ struct iwl_trans_txq_scd_cfg {
491 */ 493 */
492struct iwl_trans_ops { 494struct iwl_trans_ops {
493 495
494 int (*start_hw)(struct iwl_trans *iwl_trans); 496 int (*start_hw)(struct iwl_trans *iwl_trans, bool low_power);
495 void (*op_mode_leave)(struct iwl_trans *iwl_trans); 497 void (*op_mode_leave)(struct iwl_trans *iwl_trans);
496 int (*start_fw)(struct iwl_trans *trans, const struct fw_img *fw, 498 int (*start_fw)(struct iwl_trans *trans, const struct fw_img *fw,
497 bool run_in_rfkill); 499 bool run_in_rfkill);
498 int (*update_sf)(struct iwl_trans *trans, 500 int (*update_sf)(struct iwl_trans *trans,
499 struct iwl_sf_region *st_fwrd_space); 501 struct iwl_sf_region *st_fwrd_space);
500 void (*fw_alive)(struct iwl_trans *trans, u32 scd_addr); 502 void (*fw_alive)(struct iwl_trans *trans, u32 scd_addr);
501 void (*stop_device)(struct iwl_trans *trans); 503 void (*stop_device)(struct iwl_trans *trans, bool low_power);
502 504
503 void (*d3_suspend)(struct iwl_trans *trans, bool test); 505 void (*d3_suspend)(struct iwl_trans *trans, bool test);
504 int (*d3_resume)(struct iwl_trans *trans, enum iwl_d3_status *status, 506 int (*d3_resume)(struct iwl_trans *trans, enum iwl_d3_status *status,
@@ -652,11 +654,16 @@ static inline void iwl_trans_configure(struct iwl_trans *trans,
652 trans->ops->configure(trans, trans_cfg); 654 trans->ops->configure(trans, trans_cfg);
653} 655}
654 656
655static inline int iwl_trans_start_hw(struct iwl_trans *trans) 657static inline int _iwl_trans_start_hw(struct iwl_trans *trans, bool low_power)
656{ 658{
657 might_sleep(); 659 might_sleep();
658 660
659 return trans->ops->start_hw(trans); 661 return trans->ops->start_hw(trans, low_power);
662}
663
664static inline int iwl_trans_start_hw(struct iwl_trans *trans)
665{
666 return trans->ops->start_hw(trans, true);
660} 667}
661 668
662static inline void iwl_trans_op_mode_leave(struct iwl_trans *trans) 669static inline void iwl_trans_op_mode_leave(struct iwl_trans *trans)
@@ -703,15 +710,21 @@ static inline int iwl_trans_update_sf(struct iwl_trans *trans,
703 return 0; 710 return 0;
704} 711}
705 712
706static inline void iwl_trans_stop_device(struct iwl_trans *trans) 713static inline void _iwl_trans_stop_device(struct iwl_trans *trans,
714 bool low_power)
707{ 715{
708 might_sleep(); 716 might_sleep();
709 717
710 trans->ops->stop_device(trans); 718 trans->ops->stop_device(trans, low_power);
711 719
712 trans->state = IWL_TRANS_NO_FW; 720 trans->state = IWL_TRANS_NO_FW;
713} 721}
714 722
723static inline void iwl_trans_stop_device(struct iwl_trans *trans)
724{
725 _iwl_trans_stop_device(trans, true);
726}
727
715static inline void iwl_trans_d3_suspend(struct iwl_trans *trans, bool test) 728static inline void iwl_trans_d3_suspend(struct iwl_trans *trans, bool test)
716{ 729{
717 might_sleep(); 730 might_sleep();
diff --git a/drivers/net/wireless/iwlwifi/mvm/d3.c b/drivers/net/wireless/iwlwifi/mvm/d3.c
index a6c48c7b1e16..1b1b2bf26819 100644
--- a/drivers/net/wireless/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/iwlwifi/mvm/d3.c
@@ -1726,7 +1726,7 @@ iwl_mvm_netdetect_query_results(struct iwl_mvm *mvm,
1726 results->matched_profiles = le32_to_cpu(query->matched_profiles); 1726 results->matched_profiles = le32_to_cpu(query->matched_profiles);
1727 memcpy(results->matches, query->matches, sizeof(results->matches)); 1727 memcpy(results->matches, query->matches, sizeof(results->matches));
1728 1728
1729#ifdef CPTCFG_IWLWIFI_DEBUGFS 1729#ifdef CONFIG_IWLWIFI_DEBUGFS
1730 mvm->last_netdetect_scans = le32_to_cpu(query->n_scans_done); 1730 mvm->last_netdetect_scans = le32_to_cpu(query->n_scans_done);
1731#endif 1731#endif
1732 1732
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h b/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h
index 4fc0938b3fb6..b1baa33cc19b 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h
@@ -298,6 +298,40 @@ struct iwl_uapsd_misbehaving_ap_notif {
298} __packed; 298} __packed;
299 299
300/** 300/**
301 * struct iwl_reduce_tx_power_cmd - TX power reduction command
302 * REDUCE_TX_POWER_CMD = 0x9f
303 * @flags: (reserved for future implementation)
304 * @mac_context_id: id of the mac ctx for which we are reducing TX power.
305 * @pwr_restriction: TX power restriction in dBms.
306 */
307struct iwl_reduce_tx_power_cmd {
308 u8 flags;
309 u8 mac_context_id;
310 __le16 pwr_restriction;
311} __packed; /* TX_REDUCED_POWER_API_S_VER_1 */
312
313/**
314 * struct iwl_dev_tx_power_cmd - TX power reduction command
315 * REDUCE_TX_POWER_CMD = 0x9f
316 * @set_mode: 0 - MAC tx power, 1 - device tx power
317 * @mac_context_id: id of the mac ctx for which we are reducing TX power.
318 * @pwr_restriction: TX power restriction in 1/8 dBms.
319 * @dev_24: device TX power restriction in 1/8 dBms
320 * @dev_52_low: device TX power restriction upper band - low
321 * @dev_52_high: device TX power restriction upper band - high
322 */
323struct iwl_dev_tx_power_cmd {
324 __le32 set_mode;
325 __le32 mac_context_id;
326 __le16 pwr_restriction;
327 __le16 dev_24;
328 __le16 dev_52_low;
329 __le16 dev_52_high;
330} __packed; /* TX_REDUCED_POWER_API_S_VER_2 */
331
332#define IWL_DEV_MAX_TX_POWER 0x7FFF
333
334/**
301 * struct iwl_beacon_filter_cmd 335 * struct iwl_beacon_filter_cmd
302 * REPLY_BEACON_FILTERING_CMD = 0xd2 (command) 336 * REPLY_BEACON_FILTERING_CMD = 0xd2 (command)
303 * @id_and_color: MAC contex identifier 337 * @id_and_color: MAC contex identifier
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
index 4f81dcf57a73..d6cced47d561 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
@@ -122,46 +122,6 @@ enum iwl_scan_complete_status {
122 SCAN_COMP_STATUS_ERR_ALLOC_TE = 0x0C, 122 SCAN_COMP_STATUS_ERR_ALLOC_TE = 0x0C,
123}; 123};
124 124
125/**
126 * struct iwl_scan_results_notif - scan results for one channel
127 * ( SCAN_RESULTS_NOTIFICATION = 0x83 )
128 * @channel: which channel the results are from
129 * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
130 * @probe_status: SCAN_PROBE_STATUS_*, indicates success of probe request
131 * @num_probe_not_sent: # of request that weren't sent due to not enough time
132 * @duration: duration spent in channel, in usecs
133 * @statistics: statistics gathered for this channel
134 */
135struct iwl_scan_results_notif {
136 u8 channel;
137 u8 band;
138 u8 probe_status;
139 u8 num_probe_not_sent;
140 __le32 duration;
141 __le32 statistics[SCAN_RESULTS_STATISTICS];
142} __packed; /* SCAN_RESULT_NTF_API_S_VER_2 */
143
144/**
145 * struct iwl_scan_complete_notif - notifies end of scanning (all channels)
146 * ( SCAN_COMPLETE_NOTIFICATION = 0x84 )
147 * @scanned_channels: number of channels scanned (and number of valid results)
148 * @status: one of SCAN_COMP_STATUS_*
149 * @bt_status: BT on/off status
150 * @last_channel: last channel that was scanned
151 * @tsf_low: TSF timer (lower half) in usecs
152 * @tsf_high: TSF timer (higher half) in usecs
153 * @results: array of scan results, only "scanned_channels" of them are valid
154 */
155struct iwl_scan_complete_notif {
156 u8 scanned_channels;
157 u8 status;
158 u8 bt_status;
159 u8 last_channel;
160 __le32 tsf_low;
161 __le32 tsf_high;
162 struct iwl_scan_results_notif results[];
163} __packed; /* SCAN_COMPLETE_NTF_API_S_VER_2 */
164
165/* scan offload */ 125/* scan offload */
166#define IWL_SCAN_MAX_BLACKLIST_LEN 64 126#define IWL_SCAN_MAX_BLACKLIST_LEN 64
167#define IWL_SCAN_SHORT_BLACKLIST_LEN 16 127#define IWL_SCAN_SHORT_BLACKLIST_LEN 16
@@ -554,7 +514,7 @@ struct iwl_scan_req_unified_lmac {
554} __packed; 514} __packed;
555 515
556/** 516/**
557 * struct iwl_lmac_scan_results_notif - scan results for one channel - 517 * struct iwl_scan_results_notif - scan results for one channel -
558 * SCAN_RESULT_NTF_API_S_VER_3 518 * SCAN_RESULT_NTF_API_S_VER_3
559 * @channel: which channel the results are from 519 * @channel: which channel the results are from
560 * @band: 0 for 5.2 GHz, 1 for 2.4 GHz 520 * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
@@ -562,7 +522,7 @@ struct iwl_scan_req_unified_lmac {
562 * @num_probe_not_sent: # of request that weren't sent due to not enough time 522 * @num_probe_not_sent: # of request that weren't sent due to not enough time
563 * @duration: duration spent in channel, in usecs 523 * @duration: duration spent in channel, in usecs
564 */ 524 */
565struct iwl_lmac_scan_results_notif { 525struct iwl_scan_results_notif {
566 u8 channel; 526 u8 channel;
567 u8 band; 527 u8 band;
568 u8 probe_status; 528 u8 probe_status;
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api.h b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
index aab68cbae754..01b1da6ad359 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
@@ -281,19 +281,6 @@ struct iwl_tx_ant_cfg_cmd {
281 __le32 valid; 281 __le32 valid;
282} __packed; 282} __packed;
283 283
284/**
285 * struct iwl_reduce_tx_power_cmd - TX power reduction command
286 * REDUCE_TX_POWER_CMD = 0x9f
287 * @flags: (reserved for future implementation)
288 * @mac_context_id: id of the mac ctx for which we are reducing TX power.
289 * @pwr_restriction: TX power restriction in dBms.
290 */
291struct iwl_reduce_tx_power_cmd {
292 u8 flags;
293 u8 mac_context_id;
294 __le16 pwr_restriction;
295} __packed; /* TX_REDUCED_POWER_API_S_VER_1 */
296
297/* 284/*
298 * Calibration control struct. 285 * Calibration control struct.
299 * Sent as part of the phy configuration command. 286 * Sent as part of the phy configuration command.
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw.c b/drivers/net/wireless/iwlwifi/mvm/fw.c
index bc5eac4960e1..df869633f4dd 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/iwlwifi/mvm/fw.c
@@ -6,7 +6,7 @@
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH 9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as 12 * it under the terms of version 2 of the GNU General Public License as
@@ -32,7 +32,7 @@
32 * BSD LICENSE 32 * BSD LICENSE
33 * 33 *
34 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 34 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
35 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH 35 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
36 * All rights reserved. 36 * All rights reserved.
37 * 37 *
38 * Redistribution and use in source and binary forms, with or without 38 * Redistribution and use in source and binary forms, with or without
@@ -322,7 +322,7 @@ int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
322 322
323 lockdep_assert_held(&mvm->mutex); 323 lockdep_assert_held(&mvm->mutex);
324 324
325 if (WARN_ON_ONCE(mvm->init_ucode_complete || mvm->calibrating)) 325 if (WARN_ON_ONCE(mvm->calibrating))
326 return 0; 326 return 0;
327 327
328 iwl_init_notification_wait(&mvm->notif_wait, 328 iwl_init_notification_wait(&mvm->notif_wait,
@@ -396,8 +396,6 @@ int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
396 */ 396 */
397 ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait, 397 ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait,
398 MVM_UCODE_CALIB_TIMEOUT); 398 MVM_UCODE_CALIB_TIMEOUT);
399 if (!ret)
400 mvm->init_ucode_complete = true;
401 399
402 if (ret && iwl_mvm_is_radio_killed(mvm)) { 400 if (ret && iwl_mvm_is_radio_killed(mvm)) {
403 IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n"); 401 IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n");
@@ -494,15 +492,6 @@ int iwl_mvm_fw_dbg_collect_desc(struct iwl_mvm *mvm,
494 492
495 mvm->fw_dump_desc = desc; 493 mvm->fw_dump_desc = desc;
496 494
497 /* stop recording */
498 if (mvm->cfg->device_family == IWL_DEVICE_FAMILY_7000) {
499 iwl_set_bits_prph(mvm->trans, MON_BUFF_SAMPLE_CTL, 0x100);
500 } else {
501 iwl_write_prph(mvm->trans, DBGC_IN_SAMPLE, 0);
502 /* wait before we collect the data till the DBGC stop */
503 udelay(100);
504 }
505
506 queue_delayed_work(system_wq, &mvm->fw_dump_wk, delay); 495 queue_delayed_work(system_wq, &mvm->fw_dump_wk, delay);
507 496
508 return 0; 497 return 0;
@@ -658,25 +647,24 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
658 * module loading, load init ucode now 647 * module loading, load init ucode now
659 * (for example, if we were in RFKILL) 648 * (for example, if we were in RFKILL)
660 */ 649 */
661 if (!mvm->init_ucode_complete) { 650 ret = iwl_run_init_mvm_ucode(mvm, false);
662 ret = iwl_run_init_mvm_ucode(mvm, false); 651 if (ret && !iwlmvm_mod_params.init_dbg) {
663 if (ret && !iwlmvm_mod_params.init_dbg) { 652 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret);
664 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret); 653 /* this can't happen */
665 /* this can't happen */ 654 if (WARN_ON(ret > 0))
666 if (WARN_ON(ret > 0)) 655 ret = -ERFKILL;
667 ret = -ERFKILL; 656 goto error;
668 goto error; 657 }
669 } 658 if (!iwlmvm_mod_params.init_dbg) {
670 if (!iwlmvm_mod_params.init_dbg) { 659 /*
671 /* 660 * Stop and start the transport without entering low power
672 * should stop and start HW since that INIT 661 * mode. This will save the state of other components on the
673 * image just loaded 662 * device that are triggered by the INIT firwmare (MFUART).
674 */ 663 */
675 iwl_trans_stop_device(mvm->trans); 664 _iwl_trans_stop_device(mvm->trans, false);
676 ret = iwl_trans_start_hw(mvm->trans); 665 _iwl_trans_start_hw(mvm->trans, false);
677 if (ret) 666 if (ret)
678 return ret; 667 return ret;
679 }
680 } 668 }
681 669
682 if (iwlmvm_mod_params.init_dbg) 670 if (iwlmvm_mod_params.init_dbg)
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index 84555170b6f7..40265b9c66ae 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -1322,7 +1322,7 @@ static void iwl_mvm_restart_complete(struct iwl_mvm *mvm)
1322 1322
1323 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); 1323 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
1324 iwl_mvm_d0i3_enable_tx(mvm, NULL); 1324 iwl_mvm_d0i3_enable_tx(mvm, NULL);
1325 ret = iwl_mvm_update_quotas(mvm, false, NULL); 1325 ret = iwl_mvm_update_quotas(mvm, true, NULL);
1326 if (ret) 1326 if (ret)
1327 IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n", 1327 IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n",
1328 ret); 1328 ret);
@@ -1471,8 +1471,8 @@ static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm)
1471 return NULL; 1471 return NULL;
1472} 1472}
1473 1473
1474static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1474static int iwl_mvm_set_tx_power_old(struct iwl_mvm *mvm,
1475 s8 tx_power) 1475 struct ieee80211_vif *vif, s8 tx_power)
1476{ 1476{
1477 /* FW is in charge of regulatory enforcement */ 1477 /* FW is in charge of regulatory enforcement */
1478 struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd = { 1478 struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd = {
@@ -1485,6 +1485,26 @@ static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1485 &reduce_txpwr_cmd); 1485 &reduce_txpwr_cmd);
1486} 1486}
1487 1487
1488static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1489 s16 tx_power)
1490{
1491 struct iwl_dev_tx_power_cmd cmd = {
1492 .set_mode = 0,
1493 .mac_context_id =
1494 cpu_to_le32(iwl_mvm_vif_from_mac80211(vif)->id),
1495 .pwr_restriction = cpu_to_le16(8 * tx_power),
1496 };
1497
1498 if (!(mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_TX_POWER_DEV))
1499 return iwl_mvm_set_tx_power_old(mvm, vif, tx_power);
1500
1501 if (tx_power == IWL_DEFAULT_MAX_TX_POWER)
1502 cmd.pwr_restriction = cpu_to_le16(IWL_DEV_MAX_TX_POWER);
1503
1504 return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0,
1505 sizeof(cmd), &cmd);
1506}
1507
1488static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, 1508static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
1489 struct ieee80211_vif *vif) 1509 struct ieee80211_vif *vif)
1490{ 1510{
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index d5522a161242..cf70f681d1ac 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -603,7 +603,6 @@ struct iwl_mvm {
603 603
604 enum iwl_ucode_type cur_ucode; 604 enum iwl_ucode_type cur_ucode;
605 bool ucode_loaded; 605 bool ucode_loaded;
606 bool init_ucode_complete;
607 bool calibrating; 606 bool calibrating;
608 u32 error_event_table; 607 u32 error_event_table;
609 u32 log_event_table; 608 u32 log_event_table;
diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c
index a08b03d58d4b..1c66297d82c0 100644
--- a/drivers/net/wireless/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/iwlwifi/mvm/ops.c
@@ -865,6 +865,16 @@ static void iwl_mvm_fw_error_dump_wk(struct work_struct *work)
865 return; 865 return;
866 866
867 mutex_lock(&mvm->mutex); 867 mutex_lock(&mvm->mutex);
868
869 /* stop recording */
870 if (mvm->cfg->device_family == IWL_DEVICE_FAMILY_7000) {
871 iwl_set_bits_prph(mvm->trans, MON_BUFF_SAMPLE_CTL, 0x100);
872 } else {
873 iwl_write_prph(mvm->trans, DBGC_IN_SAMPLE, 0);
874 /* wait before we collect the data till the DBGC stop */
875 udelay(100);
876 }
877
868 iwl_mvm_fw_error_dump(mvm); 878 iwl_mvm_fw_error_dump(mvm);
869 879
870 /* start recording again if the firmware is not crashed */ 880 /* start recording again if the firmware is not crashed */
diff --git a/drivers/net/wireless/iwlwifi/mvm/rx.c b/drivers/net/wireless/iwlwifi/mvm/rx.c
index 78ec7db64ba5..d6314ddf57b5 100644
--- a/drivers/net/wireless/iwlwifi/mvm/rx.c
+++ b/drivers/net/wireless/iwlwifi/mvm/rx.c
@@ -478,6 +478,11 @@ static void iwl_mvm_stat_iterator(void *_data, u8 *mac,
478 if (vif->type != NL80211_IFTYPE_STATION) 478 if (vif->type != NL80211_IFTYPE_STATION)
479 return; 479 return;
480 480
481 if (sig == 0) {
482 IWL_DEBUG_RX(mvm, "RSSI is 0 - skip signal based decision\n");
483 return;
484 }
485
481 mvmvif->bf_data.ave_beacon_signal = sig; 486 mvmvif->bf_data.ave_beacon_signal = sig;
482 487
483 /* BT Coex */ 488 /* BT Coex */
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 74e1c86289dc..1075a213bd6a 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -319,7 +319,7 @@ int iwl_mvm_rx_scan_offload_iter_complete_notif(struct iwl_mvm *mvm,
319 struct iwl_device_cmd *cmd) 319 struct iwl_device_cmd *cmd)
320{ 320{
321 struct iwl_rx_packet *pkt = rxb_addr(rxb); 321 struct iwl_rx_packet *pkt = rxb_addr(rxb);
322 struct iwl_scan_complete_notif *notif = (void *)pkt->data; 322 struct iwl_lmac_scan_complete_notif *notif = (void *)pkt->data;
323 323
324 IWL_DEBUG_SCAN(mvm, 324 IWL_DEBUG_SCAN(mvm,
325 "Scan offload iteration complete: status=0x%x scanned channels=%d\n", 325 "Scan offload iteration complete: status=0x%x scanned channels=%d\n",
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index 2de8fbfe4edf..47bbf573fdc8 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -5,8 +5,8 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved. 8 * Copyright(c) 2007 - 2015 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH 9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as 12 * it under the terms of version 2 of the GNU General Public License as
@@ -31,8 +31,8 @@
31 * 31 *
32 * BSD LICENSE 32 * BSD LICENSE
33 * 33 *
34 * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved. 34 * Copyright(c) 2005 - 2015 Intel Corporation. All rights reserved.
35 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH 35 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
36 * All rights reserved. 36 * All rights reserved.
37 * 37 *
38 * Redistribution and use in source and binary forms, with or without 38 * Redistribution and use in source and binary forms, with or without
@@ -104,7 +104,7 @@ static void iwl_pcie_free_fw_monitor(struct iwl_trans *trans)
104static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans) 104static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans)
105{ 105{
106 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 106 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
107 struct page *page; 107 struct page *page = NULL;
108 dma_addr_t phys; 108 dma_addr_t phys;
109 u32 size; 109 u32 size;
110 u8 power; 110 u8 power;
@@ -131,6 +131,7 @@ static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans)
131 DMA_FROM_DEVICE); 131 DMA_FROM_DEVICE);
132 if (dma_mapping_error(trans->dev, phys)) { 132 if (dma_mapping_error(trans->dev, phys)) {
133 __free_pages(page, order); 133 __free_pages(page, order);
134 page = NULL;
134 continue; 135 continue;
135 } 136 }
136 IWL_INFO(trans, 137 IWL_INFO(trans,
@@ -1020,7 +1021,7 @@ static void iwl_trans_pcie_fw_alive(struct iwl_trans *trans, u32 scd_addr)
1020 iwl_pcie_tx_start(trans, scd_addr); 1021 iwl_pcie_tx_start(trans, scd_addr);
1021} 1022}
1022 1023
1023static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) 1024static void iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power)
1024{ 1025{
1025 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1026 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1026 bool hw_rfkill, was_hw_rfkill; 1027 bool hw_rfkill, was_hw_rfkill;
@@ -1115,7 +1116,7 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
1115void iwl_trans_pcie_rf_kill(struct iwl_trans *trans, bool state) 1116void iwl_trans_pcie_rf_kill(struct iwl_trans *trans, bool state)
1116{ 1117{
1117 if (iwl_op_mode_hw_rf_kill(trans->op_mode, state)) 1118 if (iwl_op_mode_hw_rf_kill(trans->op_mode, state))
1118 iwl_trans_pcie_stop_device(trans); 1119 iwl_trans_pcie_stop_device(trans, true);
1119} 1120}
1120 1121
1121static void iwl_trans_pcie_d3_suspend(struct iwl_trans *trans, bool test) 1122static void iwl_trans_pcie_d3_suspend(struct iwl_trans *trans, bool test)
@@ -1200,7 +1201,7 @@ static int iwl_trans_pcie_d3_resume(struct iwl_trans *trans,
1200 return 0; 1201 return 0;
1201} 1202}
1202 1203
1203static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) 1204static int iwl_trans_pcie_start_hw(struct iwl_trans *trans, bool low_power)
1204{ 1205{
1205 bool hw_rfkill; 1206 bool hw_rfkill;
1206 int err; 1207 int err;
diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index f0188c83c79f..2721cf89fb16 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -126,7 +126,7 @@ static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request,
126 126
127 do { 127 do {
128 status = usb_control_msg(udev, pipe, request, reqtype, value, 128 status = usb_control_msg(udev, pipe, request, reqtype, value,
129 index, pdata, len, 0); /*max. timeout*/ 129 index, pdata, len, 1000);
130 if (status < 0) { 130 if (status < 0) {
131 /* firmware download is checksumed, don't retry */ 131 /* firmware download is checksumed, don't retry */
132 if ((value >= FW_8192C_START_ADDRESS && 132 if ((value >= FW_8192C_START_ADDRESS &&
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 1899c74a7127..05b9a694e213 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -25,7 +25,6 @@
25#ifndef _LINUX_NETDEVICE_H 25#ifndef _LINUX_NETDEVICE_H
26#define _LINUX_NETDEVICE_H 26#define _LINUX_NETDEVICE_H
27 27
28#include <linux/pm_qos.h>
29#include <linux/timer.h> 28#include <linux/timer.h>
30#include <linux/bug.h> 29#include <linux/bug.h>
31#include <linux/delay.h> 30#include <linux/delay.h>
@@ -1499,8 +1498,6 @@ enum netdev_priv_flags {
1499 * 1498 *
1500 * @qdisc_tx_busylock: XXX: need comments on this one 1499 * @qdisc_tx_busylock: XXX: need comments on this one
1501 * 1500 *
1502 * @pm_qos_req: Power Management QoS object
1503 *
1504 * FIXME: cleanup struct net_device such that network protocol info 1501 * FIXME: cleanup struct net_device such that network protocol info
1505 * moves out. 1502 * moves out.
1506 */ 1503 */
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 0caa3a2d4106..3b2911502a8c 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -145,11 +145,19 @@ struct tcp_sock {
145 * read the code and the spec side by side (and laugh ...) 145 * read the code and the spec side by side (and laugh ...)
146 * See RFC793 and RFC1122. The RFC writes these in capitals. 146 * See RFC793 and RFC1122. The RFC writes these in capitals.
147 */ 147 */
148 u64 bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived
149 * sum(delta(rcv_nxt)), or how many bytes
150 * were acked.
151 */
148 u32 rcv_nxt; /* What we want to receive next */ 152 u32 rcv_nxt; /* What we want to receive next */
149 u32 copied_seq; /* Head of yet unread data */ 153 u32 copied_seq; /* Head of yet unread data */
150 u32 rcv_wup; /* rcv_nxt on last window update sent */ 154 u32 rcv_wup; /* rcv_nxt on last window update sent */
151 u32 snd_nxt; /* Next sequence we send */ 155 u32 snd_nxt; /* Next sequence we send */
152 156
157 u64 bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked
158 * sum(delta(snd_una)), or how many bytes
159 * were acked.
160 */
153 u32 snd_una; /* First byte we want an ack for */ 161 u32 snd_una; /* First byte we want an ack for */
154 u32 snd_sml; /* Last byte of the most recently transmitted small packet */ 162 u32 snd_sml; /* Last byte of the most recently transmitted small packet */
155 u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */ 163 u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index eeda67652766..6ea16c84293b 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -30,11 +30,13 @@ struct wpan_phy_cca;
30struct cfg802154_ops { 30struct cfg802154_ops {
31 struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy, 31 struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
32 const char *name, 32 const char *name,
33 unsigned char name_assign_type,
33 int type); 34 int type);
34 void (*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy, 35 void (*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
35 struct net_device *dev); 36 struct net_device *dev);
36 int (*add_virtual_intf)(struct wpan_phy *wpan_phy, 37 int (*add_virtual_intf)(struct wpan_phy *wpan_phy,
37 const char *name, 38 const char *name,
39 unsigned char name_assign_type,
38 enum nl802154_iftype type, 40 enum nl802154_iftype type,
39 __le64 extended_addr); 41 __le64 extended_addr);
40 int (*del_virtual_intf)(struct wpan_phy *wpan_phy, 42 int (*del_virtual_intf)(struct wpan_phy *wpan_phy,
diff --git a/include/net/codel.h b/include/net/codel.h
index aeee28081245..1e18005f7f65 100644
--- a/include/net/codel.h
+++ b/include/net/codel.h
@@ -120,11 +120,13 @@ static inline u32 codel_time_to_us(codel_time_t val)
120 * struct codel_params - contains codel parameters 120 * struct codel_params - contains codel parameters
121 * @target: target queue size (in time units) 121 * @target: target queue size (in time units)
122 * @interval: width of moving time window 122 * @interval: width of moving time window
123 * @mtu: device mtu, or minimal queue backlog in bytes.
123 * @ecn: is Explicit Congestion Notification enabled 124 * @ecn: is Explicit Congestion Notification enabled
124 */ 125 */
125struct codel_params { 126struct codel_params {
126 codel_time_t target; 127 codel_time_t target;
127 codel_time_t interval; 128 codel_time_t interval;
129 u32 mtu;
128 bool ecn; 130 bool ecn;
129}; 131};
130 132
@@ -166,10 +168,12 @@ struct codel_stats {
166 u32 ecn_mark; 168 u32 ecn_mark;
167}; 169};
168 170
169static void codel_params_init(struct codel_params *params) 171static void codel_params_init(struct codel_params *params,
172 const struct Qdisc *sch)
170{ 173{
171 params->interval = MS2TIME(100); 174 params->interval = MS2TIME(100);
172 params->target = MS2TIME(5); 175 params->target = MS2TIME(5);
176 params->mtu = psched_mtu(qdisc_dev(sch));
173 params->ecn = false; 177 params->ecn = false;
174} 178}
175 179
@@ -180,7 +184,7 @@ static void codel_vars_init(struct codel_vars *vars)
180 184
181static void codel_stats_init(struct codel_stats *stats) 185static void codel_stats_init(struct codel_stats *stats)
182{ 186{
183 stats->maxpacket = 256; 187 stats->maxpacket = 0;
184} 188}
185 189
186/* 190/*
@@ -234,7 +238,7 @@ static bool codel_should_drop(const struct sk_buff *skb,
234 stats->maxpacket = qdisc_pkt_len(skb); 238 stats->maxpacket = qdisc_pkt_len(skb);
235 239
236 if (codel_time_before(vars->ldelay, params->target) || 240 if (codel_time_before(vars->ldelay, params->target) ||
237 sch->qstats.backlog <= stats->maxpacket) { 241 sch->qstats.backlog <= params->mtu) {
238 /* went below - stay below for at least interval */ 242 /* went below - stay below for at least interval */
239 vars->first_above_time = 0; 243 vars->first_above_time = 0;
240 return false; 244 return false;
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index b4bef1152c05..8e3668b44c29 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1666,6 +1666,8 @@ struct ieee80211_tx_control {
1666 * @sta: station table entry, %NULL for per-vif queue 1666 * @sta: station table entry, %NULL for per-vif queue
1667 * @tid: the TID for this queue (unused for per-vif queue) 1667 * @tid: the TID for this queue (unused for per-vif queue)
1668 * @ac: the AC for this queue 1668 * @ac: the AC for this queue
1669 * @drv_priv: data area for driver use, will always be aligned to
1670 * sizeof(void *).
1669 * 1671 *
1670 * The driver can obtain packets from this queue by calling 1672 * The driver can obtain packets from this queue by calling
1671 * ieee80211_tx_dequeue(). 1673 * ieee80211_tx_dequeue().
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index e18e7fd43f47..7df28a4c23f9 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -247,19 +247,109 @@ static inline void ieee802154_le64_to_be64(void *be64_dst, const void *le64_src)
247 __put_unaligned_memmove64(swab64p(le64_src), be64_dst); 247 __put_unaligned_memmove64(swab64p(le64_src), be64_dst);
248} 248}
249 249
250/* Basic interface to register ieee802154 device */ 250/**
251 * ieee802154_alloc_hw - Allocate a new hardware device
252 *
253 * This must be called once for each hardware device. The returned pointer
254 * must be used to refer to this device when calling other functions.
255 * mac802154 allocates a private data area for the driver pointed to by
256 * @priv in &struct ieee802154_hw, the size of this area is given as
257 * @priv_data_len.
258 *
259 * @priv_data_len: length of private data
260 * @ops: callbacks for this device
261 *
262 * Return: A pointer to the new hardware device, or %NULL on error.
263 */
251struct ieee802154_hw * 264struct ieee802154_hw *
252ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops); 265ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops);
266
267/**
268 * ieee802154_free_hw - free hardware descriptor
269 *
270 * This function frees everything that was allocated, including the
271 * private data for the driver. You must call ieee802154_unregister_hw()
272 * before calling this function.
273 *
274 * @hw: the hardware to free
275 */
253void ieee802154_free_hw(struct ieee802154_hw *hw); 276void ieee802154_free_hw(struct ieee802154_hw *hw);
277
278/**
279 * ieee802154_register_hw - Register hardware device
280 *
281 * You must call this function before any other functions in
282 * mac802154. Note that before a hardware can be registered, you
283 * need to fill the contained wpan_phy's information.
284 *
285 * @hw: the device to register as returned by ieee802154_alloc_hw()
286 *
287 * Return: 0 on success. An error code otherwise.
288 */
254int ieee802154_register_hw(struct ieee802154_hw *hw); 289int ieee802154_register_hw(struct ieee802154_hw *hw);
290
291/**
292 * ieee802154_unregister_hw - Unregister a hardware device
293 *
294 * This function instructs mac802154 to free allocated resources
295 * and unregister netdevices from the networking subsystem.
296 *
297 * @hw: the hardware to unregister
298 */
255void ieee802154_unregister_hw(struct ieee802154_hw *hw); 299void ieee802154_unregister_hw(struct ieee802154_hw *hw);
256 300
301/**
302 * ieee802154_rx - receive frame
303 *
304 * Use this function to hand received frames to mac802154. The receive
305 * buffer in @skb must start with an IEEE 802.15.4 header. In case of a
306 * paged @skb is used, the driver is recommended to put the ieee802154
307 * header of the frame on the linear part of the @skb to avoid memory
308 * allocation and/or memcpy by the stack.
309 *
310 * This function may not be called in IRQ context. Calls to this function
311 * for a single hardware must be synchronized against each other.
312 *
313 * @hw: the hardware this frame came in on
314 * @skb: the buffer to receive, owned by mac802154 after this call
315 */
257void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb); 316void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb);
317
318/**
319 * ieee802154_rx_irqsafe - receive frame
320 *
321 * Like ieee802154_rx() but can be called in IRQ context
322 * (internally defers to a tasklet.)
323 *
324 * @hw: the hardware this frame came in on
325 * @skb: the buffer to receive, owned by mac802154 after this call
326 * @lqi: link quality indicator
327 */
258void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, 328void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb,
259 u8 lqi); 329 u8 lqi);
260 330/**
331 * ieee802154_wake_queue - wake ieee802154 queue
332 * @hw: pointer as obtained from ieee802154_alloc_hw().
333 *
334 * Drivers should use this function instead of netif_wake_queue.
335 */
261void ieee802154_wake_queue(struct ieee802154_hw *hw); 336void ieee802154_wake_queue(struct ieee802154_hw *hw);
337
338/**
339 * ieee802154_stop_queue - stop ieee802154 queue
340 * @hw: pointer as obtained from ieee802154_alloc_hw().
341 *
342 * Drivers should use this function instead of netif_stop_queue.
343 */
262void ieee802154_stop_queue(struct ieee802154_hw *hw); 344void ieee802154_stop_queue(struct ieee802154_hw *hw);
345
346/**
347 * ieee802154_xmit_complete - frame transmission complete
348 *
349 * @hw: pointer as obtained from ieee802154_alloc_hw().
350 * @skb: buffer for transmission
351 * @ifs_handling: indicate interframe space handling
352 */
263void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb, 353void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb,
264 bool ifs_handling); 354 bool ifs_handling);
265 355
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 051dc5c2802d..6d204f3f9df8 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -576,7 +576,7 @@ static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize)
576} 576}
577 577
578/* tcp.c */ 578/* tcp.c */
579void tcp_get_info(const struct sock *, struct tcp_info *); 579void tcp_get_info(struct sock *, struct tcp_info *);
580 580
581/* Read 'sendfile()'-style from a TCP socket */ 581/* Read 'sendfile()'-style from a TCP socket */
582typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *, 582typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *,
@@ -804,6 +804,8 @@ enum tcp_ca_ack_event_flags {
804/* Requires ECN/ECT set on all packets */ 804/* Requires ECN/ECT set on all packets */
805#define TCP_CONG_NEEDS_ECN 0x2 805#define TCP_CONG_NEEDS_ECN 0x2
806 806
807union tcp_cc_info;
808
807struct tcp_congestion_ops { 809struct tcp_congestion_ops {
808 struct list_head list; 810 struct list_head list;
809 u32 key; 811 u32 key;
@@ -829,7 +831,8 @@ struct tcp_congestion_ops {
829 /* hook for packet ack accounting (optional) */ 831 /* hook for packet ack accounting (optional) */
830 void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us); 832 void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us);
831 /* get info for inet_diag (optional) */ 833 /* get info for inet_diag (optional) */
832 int (*get_info)(struct sock *sk, u32 ext, struct sk_buff *skb); 834 size_t (*get_info)(struct sock *sk, u32 ext, int *attr,
835 union tcp_cc_info *info);
833 836
834 char name[TCP_CA_NAME_MAX]; 837 char name[TCP_CA_NAME_MAX];
835 struct module *owner; 838 struct module *owner;
diff --git a/include/uapi/linux/inet_diag.h b/include/uapi/linux/inet_diag.h
index d65c0a09efd3..c7093c75bdd6 100644
--- a/include/uapi/linux/inet_diag.h
+++ b/include/uapi/linux/inet_diag.h
@@ -143,4 +143,8 @@ struct tcp_dctcp_info {
143 __u32 dctcp_ab_tot; 143 __u32 dctcp_ab_tot;
144}; 144};
145 145
146union tcp_cc_info {
147 struct tcpvegas_info vegas;
148 struct tcp_dctcp_info dctcp;
149};
146#endif /* _UAPI_INET_DIAG_H_ */ 150#endif /* _UAPI_INET_DIAG_H_ */
diff --git a/include/uapi/linux/mpls.h b/include/uapi/linux/mpls.h
index bc9abfe88c9a..139d4dd1cab8 100644
--- a/include/uapi/linux/mpls.h
+++ b/include/uapi/linux/mpls.h
@@ -31,4 +31,14 @@ struct mpls_label {
31#define MPLS_LS_TTL_MASK 0x000000FF 31#define MPLS_LS_TTL_MASK 0x000000FF
32#define MPLS_LS_TTL_SHIFT 0 32#define MPLS_LS_TTL_SHIFT 0
33 33
34/* Reserved labels */
35#define MPLS_LABEL_IPV4NULL 0 /* RFC3032 */
36#define MPLS_LABEL_RTALERT 1 /* RFC3032 */
37#define MPLS_LABEL_IPV6NULL 2 /* RFC3032 */
38#define MPLS_LABEL_IMPLNULL 3 /* RFC3032 */
39#define MPLS_LABEL_ENTROPY 7 /* RFC6790 */
40#define MPLS_LABEL_GAL 13 /* RFC5586 */
41#define MPLS_LABEL_OAMALERT 14 /* RFC3429 */
42#define MPLS_LABEL_EXTENSION 15 /* RFC7274 */
43
34#endif /* _UAPI_MPLS_H */ 44#endif /* _UAPI_MPLS_H */
diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
index 3b9718328d8b..faa72f4fa547 100644
--- a/include/uapi/linux/tcp.h
+++ b/include/uapi/linux/tcp.h
@@ -112,6 +112,7 @@ enum {
112#define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */ 112#define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */
113#define TCP_TIMESTAMP 24 113#define TCP_TIMESTAMP 24
114#define TCP_NOTSENT_LOWAT 25 /* limit number of unsent bytes in write queue */ 114#define TCP_NOTSENT_LOWAT 25 /* limit number of unsent bytes in write queue */
115#define TCP_CC_INFO 26 /* Get Congestion Control (optional) info */
115 116
116struct tcp_repair_opt { 117struct tcp_repair_opt {
117 __u32 opt_code; 118 __u32 opt_code;
@@ -189,6 +190,8 @@ struct tcp_info {
189 190
190 __u64 tcpi_pacing_rate; 191 __u64 tcpi_pacing_rate;
191 __u64 tcpi_max_pacing_rate; 192 __u64 tcpi_max_pacing_rate;
193 __u64 tcpi_bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked */
194 __u64 tcpi_bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived */
192}; 195};
193 196
194/* for TCP_MD5SIG socket option */ 197/* for TCP_MD5SIG socket option */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 476709bd068a..4663c3dad3f5 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1557,7 +1557,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
1557{ 1557{
1558 BT_DBG("%s %p", hdev->name, hdev); 1558 BT_DBG("%s %p", hdev->name, hdev);
1559 1559
1560 if (!hci_dev_test_flag(hdev, HCI_UNREGISTER)) { 1560 if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) &&
1561 test_bit(HCI_UP, &hdev->flags)) {
1561 /* Execute vendor specific shutdown routine */ 1562 /* Execute vendor specific shutdown routine */
1562 if (hdev->shutdown) 1563 if (hdev->shutdown)
1563 hdev->shutdown(hdev); 1564 hdev->shutdown(hdev);
diff --git a/net/core/dev.c b/net/core/dev.c
index c7ba0388f1be..2c1c67fad64d 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5209,7 +5209,7 @@ static int __netdev_upper_dev_link(struct net_device *dev,
5209 if (__netdev_find_adj(upper_dev, dev, &upper_dev->all_adj_list.upper)) 5209 if (__netdev_find_adj(upper_dev, dev, &upper_dev->all_adj_list.upper))
5210 return -EBUSY; 5210 return -EBUSY;
5211 5211
5212 if (__netdev_find_adj(dev, upper_dev, &dev->all_adj_list.upper)) 5212 if (__netdev_find_adj(dev, upper_dev, &dev->adj_list.upper))
5213 return -EEXIST; 5213 return -EEXIST;
5214 5214
5215 if (master && netdev_master_upper_dev_get(dev)) 5215 if (master && netdev_master_upper_dev_get(dev))
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 78fc04ad36fc..572af0011997 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -601,7 +601,7 @@ static int rtnl_net_getid(struct sk_buff *skb, struct nlmsghdr *nlh)
601 } 601 }
602 602
603 err = rtnl_net_fill(msg, NETLINK_CB(skb).portid, nlh->nlmsg_seq, 0, 603 err = rtnl_net_fill(msg, NETLINK_CB(skb).portid, nlh->nlmsg_seq, 0,
604 RTM_GETNSID, net, peer, -1); 604 RTM_NEWNSID, net, peer, -1);
605 if (err < 0) 605 if (err < 0)
606 goto err_out; 606 goto err_out;
607 607
diff --git a/net/core/sock.c b/net/core/sock.c
index e891bcf325ca..292f42228bfb 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1474,8 +1474,8 @@ void sk_release_kernel(struct sock *sk)
1474 return; 1474 return;
1475 1475
1476 sock_hold(sk); 1476 sock_hold(sk);
1477 sock_net_set(sk, get_net(&init_net));
1478 sock_release(sk->sk_socket); 1477 sock_release(sk->sk_socket);
1478 sock_net_set(sk, get_net(&init_net));
1479 sock_put(sk); 1479 sock_put(sk);
1480} 1480}
1481EXPORT_SYMBOL(sk_release_kernel); 1481EXPORT_SYMBOL(sk_release_kernel);
diff --git a/net/ieee802154/Makefile b/net/ieee802154/Makefile
index 05dab2957cd4..4adfd4d5471b 100644
--- a/net/ieee802154/Makefile
+++ b/net/ieee802154/Makefile
@@ -3,7 +3,9 @@ obj-$(CONFIG_IEEE802154_SOCKET) += ieee802154_socket.o
3obj-y += 6lowpan/ 3obj-y += 6lowpan/
4 4
5ieee802154-y := netlink.o nl-mac.o nl-phy.o nl_policy.o core.o \ 5ieee802154-y := netlink.o nl-mac.o nl-phy.o nl_policy.o core.o \
6 header_ops.o sysfs.o nl802154.o 6 header_ops.o sysfs.o nl802154.o trace.o
7ieee802154_socket-y := socket.o 7ieee802154_socket-y := socket.o
8 8
9CFLAGS_trace.o := -I$(src)
10
9ccflags-y += -D__CHECK_ENDIAN__ 11ccflags-y += -D__CHECK_ENDIAN__
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index 1b9d25f6e898..346c6665d25e 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -175,6 +175,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
175 int rc = -ENOBUFS; 175 int rc = -ENOBUFS;
176 struct net_device *dev; 176 struct net_device *dev;
177 int type = __IEEE802154_DEV_INVALID; 177 int type = __IEEE802154_DEV_INVALID;
178 unsigned char name_assign_type;
178 179
179 pr_debug("%s\n", __func__); 180 pr_debug("%s\n", __func__);
180 181
@@ -190,8 +191,10 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
190 if (devname[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1] 191 if (devname[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1]
191 != '\0') 192 != '\0')
192 return -EINVAL; /* phy name should be null-terminated */ 193 return -EINVAL; /* phy name should be null-terminated */
194 name_assign_type = NET_NAME_USER;
193 } else { 195 } else {
194 devname = "wpan%d"; 196 devname = "wpan%d";
197 name_assign_type = NET_NAME_ENUM;
195 } 198 }
196 199
197 if (strlen(devname) >= IFNAMSIZ) 200 if (strlen(devname) >= IFNAMSIZ)
@@ -221,7 +224,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
221 } 224 }
222 225
223 dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname, 226 dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname,
224 type); 227 name_assign_type, type);
225 if (IS_ERR(dev)) { 228 if (IS_ERR(dev)) {
226 rc = PTR_ERR(dev); 229 rc = PTR_ERR(dev);
227 goto nla_put_failure; 230 goto nla_put_failure;
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index a4daf91b8d0a..f3c12f6a4a39 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -589,7 +589,7 @@ static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info)
589 589
590 return rdev_add_virtual_intf(rdev, 590 return rdev_add_virtual_intf(rdev,
591 nla_data(info->attrs[NL802154_ATTR_IFNAME]), 591 nla_data(info->attrs[NL802154_ATTR_IFNAME]),
592 type, extended_addr); 592 NET_NAME_USER, type, extended_addr);
593} 593}
594 594
595static int nl802154_del_interface(struct sk_buff *skb, struct genl_info *info) 595static int nl802154_del_interface(struct sk_buff *skb, struct genl_info *info)
diff --git a/net/ieee802154/rdev-ops.h b/net/ieee802154/rdev-ops.h
index 7c46732fad2b..7b5a9dd94fe5 100644
--- a/net/ieee802154/rdev-ops.h
+++ b/net/ieee802154/rdev-ops.h
@@ -4,13 +4,16 @@
4#include <net/cfg802154.h> 4#include <net/cfg802154.h>
5 5
6#include "core.h" 6#include "core.h"
7#include "trace.h"
7 8
8static inline struct net_device * 9static inline struct net_device *
9rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev, 10rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
10 const char *name, int type) 11 const char *name,
12 unsigned char name_assign_type,
13 int type)
11{ 14{
12 return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name, 15 return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name,
13 type); 16 name_assign_type, type);
14} 17}
15 18
16static inline void 19static inline void
@@ -22,75 +25,131 @@ rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
22 25
23static inline int 26static inline int
24rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name, 27rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name,
28 unsigned char name_assign_type,
25 enum nl802154_iftype type, __le64 extended_addr) 29 enum nl802154_iftype type, __le64 extended_addr)
26{ 30{
27 return rdev->ops->add_virtual_intf(&rdev->wpan_phy, name, type, 31 int ret;
32
33 trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type,
28 extended_addr); 34 extended_addr);
35 ret = rdev->ops->add_virtual_intf(&rdev->wpan_phy, name,
36 name_assign_type, type,
37 extended_addr);
38 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
39 return ret;
29} 40}
30 41
31static inline int 42static inline int
32rdev_del_virtual_intf(struct cfg802154_registered_device *rdev, 43rdev_del_virtual_intf(struct cfg802154_registered_device *rdev,
33 struct wpan_dev *wpan_dev) 44 struct wpan_dev *wpan_dev)
34{ 45{
35 return rdev->ops->del_virtual_intf(&rdev->wpan_phy, wpan_dev); 46 int ret;
47
48 trace_802154_rdev_del_virtual_intf(&rdev->wpan_phy, wpan_dev);
49 ret = rdev->ops->del_virtual_intf(&rdev->wpan_phy, wpan_dev);
50 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
51 return ret;
36} 52}
37 53
38static inline int 54static inline int
39rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel) 55rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel)
40{ 56{
41 return rdev->ops->set_channel(&rdev->wpan_phy, page, channel); 57 int ret;
58
59 trace_802154_rdev_set_channel(&rdev->wpan_phy, page, channel);
60 ret = rdev->ops->set_channel(&rdev->wpan_phy, page, channel);
61 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
62 return ret;
42} 63}
43 64
44static inline int 65static inline int
45rdev_set_cca_mode(struct cfg802154_registered_device *rdev, 66rdev_set_cca_mode(struct cfg802154_registered_device *rdev,
46 const struct wpan_phy_cca *cca) 67 const struct wpan_phy_cca *cca)
47{ 68{
48 return rdev->ops->set_cca_mode(&rdev->wpan_phy, cca); 69 int ret;
70
71 trace_802154_rdev_set_cca_mode(&rdev->wpan_phy, cca);
72 ret = rdev->ops->set_cca_mode(&rdev->wpan_phy, cca);
73 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
74 return ret;
49} 75}
50 76
51static inline int 77static inline int
52rdev_set_pan_id(struct cfg802154_registered_device *rdev, 78rdev_set_pan_id(struct cfg802154_registered_device *rdev,
53 struct wpan_dev *wpan_dev, __le16 pan_id) 79 struct wpan_dev *wpan_dev, __le16 pan_id)
54{ 80{
55 return rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id); 81 int ret;
82
83 trace_802154_rdev_set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
84 ret = rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
85 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
86 return ret;
56} 87}
57 88
58static inline int 89static inline int
59rdev_set_short_addr(struct cfg802154_registered_device *rdev, 90rdev_set_short_addr(struct cfg802154_registered_device *rdev,
60 struct wpan_dev *wpan_dev, __le16 short_addr) 91 struct wpan_dev *wpan_dev, __le16 short_addr)
61{ 92{
62 return rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr); 93 int ret;
94
95 trace_802154_rdev_set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
96 ret = rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
97 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
98 return ret;
63} 99}
64 100
65static inline int 101static inline int
66rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev, 102rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev,
67 struct wpan_dev *wpan_dev, u8 min_be, u8 max_be) 103 struct wpan_dev *wpan_dev, u8 min_be, u8 max_be)
68{ 104{
69 return rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev, 105 int ret;
106
107 trace_802154_rdev_set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
70 min_be, max_be); 108 min_be, max_be);
109 ret = rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
110 min_be, max_be);
111 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
112 return ret;
71} 113}
72 114
73static inline int 115static inline int
74rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev, 116rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev,
75 struct wpan_dev *wpan_dev, u8 max_csma_backoffs) 117 struct wpan_dev *wpan_dev, u8 max_csma_backoffs)
76{ 118{
77 return rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev, 119 int ret;
78 max_csma_backoffs); 120
121 trace_802154_rdev_set_csma_backoffs(&rdev->wpan_phy, wpan_dev,
122 max_csma_backoffs);
123 ret = rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev,
124 max_csma_backoffs);
125 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
126 return ret;
79} 127}
80 128
81static inline int 129static inline int
82rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev, 130rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev,
83 struct wpan_dev *wpan_dev, s8 max_frame_retries) 131 struct wpan_dev *wpan_dev, s8 max_frame_retries)
84{ 132{
85 return rdev->ops->set_max_frame_retries(&rdev->wpan_phy, wpan_dev, 133 int ret;
134
135 trace_802154_rdev_set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
86 max_frame_retries); 136 max_frame_retries);
137 ret = rdev->ops->set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
138 max_frame_retries);
139 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
140 return ret;
87} 141}
88 142
89static inline int 143static inline int
90rdev_set_lbt_mode(struct cfg802154_registered_device *rdev, 144rdev_set_lbt_mode(struct cfg802154_registered_device *rdev,
91 struct wpan_dev *wpan_dev, bool mode) 145 struct wpan_dev *wpan_dev, bool mode)
92{ 146{
93 return rdev->ops->set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode); 147 int ret;
148
149 trace_802154_rdev_set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
150 ret = rdev->ops->set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
151 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
152 return ret;
94} 153}
95 154
96#endif /* __CFG802154_RDEV_OPS */ 155#endif /* __CFG802154_RDEV_OPS */
diff --git a/net/ieee802154/trace.c b/net/ieee802154/trace.c
new file mode 100644
index 000000000000..95f997fad755
--- /dev/null
+++ b/net/ieee802154/trace.c
@@ -0,0 +1,7 @@
1#include <linux/module.h>
2
3#ifndef __CHECKER__
4#define CREATE_TRACE_POINTS
5#include "trace.h"
6
7#endif
diff --git a/net/ieee802154/trace.h b/net/ieee802154/trace.h
new file mode 100644
index 000000000000..5ac25eb6ed17
--- /dev/null
+++ b/net/ieee802154/trace.h
@@ -0,0 +1,247 @@
1/* Based on net/wireless/tracing.h */
2
3#undef TRACE_SYSTEM
4#define TRACE_SYSTEM cfg802154
5
6#if !defined(__RDEV_CFG802154_OPS_TRACE) || defined(TRACE_HEADER_MULTI_READ)
7#define __RDEV_CFG802154_OPS_TRACE
8
9#include <linux/tracepoint.h>
10
11#include <net/cfg802154.h>
12
13#define MAXNAME 32
14#define WPAN_PHY_ENTRY __array(char, wpan_phy_name, MAXNAME)
15#define WPAN_PHY_ASSIGN strlcpy(__entry->wpan_phy_name, \
16 wpan_phy_name(wpan_phy), \
17 MAXNAME)
18#define WPAN_PHY_PR_FMT "%s"
19#define WPAN_PHY_PR_ARG __entry->wpan_phy_name
20
21#define WPAN_DEV_ENTRY __field(u32, identifier)
22#define WPAN_DEV_ASSIGN (__entry->identifier) = (!IS_ERR_OR_NULL(wpan_dev) \
23 ? wpan_dev->identifier : 0)
24#define WPAN_DEV_PR_FMT "wpan_dev(%u)"
25#define WPAN_DEV_PR_ARG (__entry->identifier)
26
27#define WPAN_CCA_ENTRY __field(enum nl802154_cca_modes, cca_mode) \
28 __field(enum nl802154_cca_opts, cca_opt)
29#define WPAN_CCA_ASSIGN \
30 do { \
31 (__entry->cca_mode) = cca->mode; \
32 (__entry->cca_opt) = cca->opt; \
33 } while (0)
34#define WPAN_CCA_PR_FMT "cca_mode: %d, cca_opt: %d"
35#define WPAN_CCA_PR_ARG __entry->cca_mode, __entry->cca_opt
36
37#define BOOL_TO_STR(bo) (bo) ? "true" : "false"
38
39/*************************************************************
40 * rdev->ops traces *
41 *************************************************************/
42
43TRACE_EVENT(802154_rdev_add_virtual_intf,
44 TP_PROTO(struct wpan_phy *wpan_phy, char *name,
45 enum nl802154_iftype type, __le64 extended_addr),
46 TP_ARGS(wpan_phy, name, type, extended_addr),
47 TP_STRUCT__entry(
48 WPAN_PHY_ENTRY
49 __string(vir_intf_name, name ? name : "<noname>")
50 __field(enum nl802154_iftype, type)
51 __field(__le64, extended_addr)
52 ),
53 TP_fast_assign(
54 WPAN_PHY_ASSIGN;
55 __assign_str(vir_intf_name, name ? name : "<noname>");
56 __entry->type = type;
57 __entry->extended_addr = extended_addr;
58 ),
59 TP_printk(WPAN_PHY_PR_FMT ", virtual intf name: %s, type: %d, ea %llx",
60 WPAN_PHY_PR_ARG, __get_str(vir_intf_name), __entry->type,
61 __le64_to_cpu(__entry->extended_addr))
62);
63
64TRACE_EVENT(802154_rdev_del_virtual_intf,
65 TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev),
66 TP_ARGS(wpan_phy, wpan_dev),
67 TP_STRUCT__entry(
68 WPAN_PHY_ENTRY
69 WPAN_DEV_ENTRY
70 ),
71 TP_fast_assign(
72 WPAN_PHY_ASSIGN;
73 WPAN_DEV_ASSIGN;
74 ),
75 TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT, WPAN_PHY_PR_ARG,
76 WPAN_DEV_PR_ARG)
77);
78
79TRACE_EVENT(802154_rdev_set_channel,
80 TP_PROTO(struct wpan_phy *wpan_phy, u8 page, u8 channel),
81 TP_ARGS(wpan_phy, page, channel),
82 TP_STRUCT__entry(
83 WPAN_PHY_ENTRY
84 __field(u8, page)
85 __field(u8, channel)
86 ),
87 TP_fast_assign(
88 WPAN_PHY_ASSIGN;
89 __entry->page = page;
90 __entry->channel = channel;
91 ),
92 TP_printk(WPAN_PHY_PR_FMT ", page: %d, channel: %d", WPAN_PHY_PR_ARG,
93 __entry->page, __entry->channel)
94);
95
96TRACE_EVENT(802154_rdev_set_cca_mode,
97 TP_PROTO(struct wpan_phy *wpan_phy, const struct wpan_phy_cca *cca),
98 TP_ARGS(wpan_phy, cca),
99 TP_STRUCT__entry(
100 WPAN_PHY_ENTRY
101 WPAN_CCA_ENTRY
102 ),
103 TP_fast_assign(
104 WPAN_PHY_ASSIGN;
105 WPAN_CCA_ASSIGN;
106 ),
107 TP_printk(WPAN_PHY_PR_FMT ", " WPAN_CCA_PR_FMT, WPAN_PHY_PR_ARG,
108 WPAN_CCA_PR_ARG)
109);
110
111DECLARE_EVENT_CLASS(802154_le16_template,
112 TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
113 __le16 le16arg),
114 TP_ARGS(wpan_phy, wpan_dev, le16arg),
115 TP_STRUCT__entry(
116 WPAN_PHY_ENTRY
117 WPAN_DEV_ENTRY
118 __field(__le16, le16arg)
119 ),
120 TP_fast_assign(
121 WPAN_PHY_ASSIGN;
122 WPAN_DEV_ASSIGN;
123 __entry->le16arg = le16arg;
124 ),
125 TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", pan id: 0x%04x",
126 WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG,
127 __le16_to_cpu(__entry->le16arg))
128);
129
130DEFINE_EVENT(802154_le16_template, 802154_rdev_set_pan_id,
131 TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
132 __le16 le16arg),
133 TP_ARGS(wpan_phy, wpan_dev, le16arg)
134);
135
136DEFINE_EVENT_PRINT(802154_le16_template, 802154_rdev_set_short_addr,
137 TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
138 __le16 le16arg),
139 TP_ARGS(wpan_phy, wpan_dev, le16arg),
140 TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", sa: 0x%04x",
141 WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG,
142 __le16_to_cpu(__entry->le16arg))
143);
144
145TRACE_EVENT(802154_rdev_set_backoff_exponent,
146 TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
147 u8 min_be, u8 max_be),
148 TP_ARGS(wpan_phy, wpan_dev, min_be, max_be),
149 TP_STRUCT__entry(
150 WPAN_PHY_ENTRY
151 WPAN_DEV_ENTRY
152 __field(u8, min_be)
153 __field(u8, max_be)
154 ),
155 TP_fast_assign(
156 WPAN_PHY_ASSIGN;
157 WPAN_DEV_ASSIGN;
158 __entry->min_be = min_be;
159 __entry->max_be = max_be;
160 ),
161
162 TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
163 ", min be: %d, max_be: %d", WPAN_PHY_PR_ARG,
164 WPAN_DEV_PR_ARG, __entry->min_be, __entry->max_be)
165);
166
167TRACE_EVENT(802154_rdev_set_csma_backoffs,
168 TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
169 u8 max_csma_backoffs),
170 TP_ARGS(wpan_phy, wpan_dev, max_csma_backoffs),
171 TP_STRUCT__entry(
172 WPAN_PHY_ENTRY
173 WPAN_DEV_ENTRY
174 __field(u8, max_csma_backoffs)
175 ),
176 TP_fast_assign(
177 WPAN_PHY_ASSIGN;
178 WPAN_DEV_ASSIGN;
179 __entry->max_csma_backoffs = max_csma_backoffs;
180 ),
181
182 TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
183 ", max csma backoffs: %d", WPAN_PHY_PR_ARG,
184 WPAN_DEV_PR_ARG, __entry->max_csma_backoffs)
185);
186
187TRACE_EVENT(802154_rdev_set_max_frame_retries,
188 TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
189 s8 max_frame_retries),
190 TP_ARGS(wpan_phy, wpan_dev, max_frame_retries),
191 TP_STRUCT__entry(
192 WPAN_PHY_ENTRY
193 WPAN_DEV_ENTRY
194 __field(s8, max_frame_retries)
195 ),
196 TP_fast_assign(
197 WPAN_PHY_ASSIGN;
198 WPAN_DEV_ASSIGN;
199 __entry->max_frame_retries = max_frame_retries;
200 ),
201
202 TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
203 ", max frame retries: %d", WPAN_PHY_PR_ARG,
204 WPAN_DEV_PR_ARG, __entry->max_frame_retries)
205);
206
207TRACE_EVENT(802154_rdev_set_lbt_mode,
208 TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
209 bool mode),
210 TP_ARGS(wpan_phy, wpan_dev, mode),
211 TP_STRUCT__entry(
212 WPAN_PHY_ENTRY
213 WPAN_DEV_ENTRY
214 __field(bool, mode)
215 ),
216 TP_fast_assign(
217 WPAN_PHY_ASSIGN;
218 WPAN_DEV_ASSIGN;
219 __entry->mode = mode;
220 ),
221 TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
222 ", lbt mode: %s", WPAN_PHY_PR_ARG,
223 WPAN_DEV_PR_ARG, BOOL_TO_STR(__entry->mode))
224);
225
226TRACE_EVENT(802154_rdev_return_int,
227 TP_PROTO(struct wpan_phy *wpan_phy, int ret),
228 TP_ARGS(wpan_phy, ret),
229 TP_STRUCT__entry(
230 WPAN_PHY_ENTRY
231 __field(int, ret)
232 ),
233 TP_fast_assign(
234 WPAN_PHY_ASSIGN;
235 __entry->ret = ret;
236 ),
237 TP_printk(WPAN_PHY_PR_FMT ", returned: %d", WPAN_PHY_PR_ARG,
238 __entry->ret)
239);
240
241#endif /* !__RDEV_CFG802154_OPS_TRACE || TRACE_HEADER_MULTI_READ */
242
243#undef TRACE_INCLUDE_PATH
244#define TRACE_INCLUDE_PATH .
245#undef TRACE_INCLUDE_FILE
246#define TRACE_INCLUDE_FILE trace
247#include <trace/define_trace.h>
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index bb77ebdae3b3..4d32262c7502 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -224,14 +224,16 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
224 handler->idiag_get_info(sk, r, info); 224 handler->idiag_get_info(sk, r, info);
225 225
226 if (sk->sk_state < TCP_TIME_WAIT) { 226 if (sk->sk_state < TCP_TIME_WAIT) {
227 int err = 0; 227 union tcp_cc_info info;
228 size_t sz = 0;
229 int attr;
228 230
229 rcu_read_lock(); 231 rcu_read_lock();
230 ca_ops = READ_ONCE(icsk->icsk_ca_ops); 232 ca_ops = READ_ONCE(icsk->icsk_ca_ops);
231 if (ca_ops && ca_ops->get_info) 233 if (ca_ops && ca_ops->get_info)
232 err = ca_ops->get_info(sk, ext, skb); 234 sz = ca_ops->get_info(sk, ext, &attr, &info);
233 rcu_read_unlock(); 235 rcu_read_unlock();
234 if (err < 0) 236 if (sz && nla_put(skb, attr, sz, &info) < 0)
235 goto errout; 237 goto errout;
236 } 238 }
237 239
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 8c5cd9efebbc..46efa03d2b11 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -252,6 +252,7 @@
252#include <linux/types.h> 252#include <linux/types.h>
253#include <linux/fcntl.h> 253#include <linux/fcntl.h>
254#include <linux/poll.h> 254#include <linux/poll.h>
255#include <linux/inet_diag.h>
255#include <linux/init.h> 256#include <linux/init.h>
256#include <linux/fs.h> 257#include <linux/fs.h>
257#include <linux/skbuff.h> 258#include <linux/skbuff.h>
@@ -2592,7 +2593,7 @@ EXPORT_SYMBOL(compat_tcp_setsockopt);
2592#endif 2593#endif
2593 2594
2594/* Return information about state of tcp endpoint in API format. */ 2595/* Return information about state of tcp endpoint in API format. */
2595void tcp_get_info(const struct sock *sk, struct tcp_info *info) 2596void tcp_get_info(struct sock *sk, struct tcp_info *info)
2596{ 2597{
2597 const struct tcp_sock *tp = tcp_sk(sk); 2598 const struct tcp_sock *tp = tcp_sk(sk);
2598 const struct inet_connection_sock *icsk = inet_csk(sk); 2599 const struct inet_connection_sock *icsk = inet_csk(sk);
@@ -2663,6 +2664,11 @@ void tcp_get_info(const struct sock *sk, struct tcp_info *info)
2663 2664
2664 rate = READ_ONCE(sk->sk_max_pacing_rate); 2665 rate = READ_ONCE(sk->sk_max_pacing_rate);
2665 info->tcpi_max_pacing_rate = rate != ~0U ? rate : ~0ULL; 2666 info->tcpi_max_pacing_rate = rate != ~0U ? rate : ~0ULL;
2667
2668 spin_lock_bh(&sk->sk_lock.slock);
2669 info->tcpi_bytes_acked = tp->bytes_acked;
2670 info->tcpi_bytes_received = tp->bytes_received;
2671 spin_unlock_bh(&sk->sk_lock.slock);
2666} 2672}
2667EXPORT_SYMBOL_GPL(tcp_get_info); 2673EXPORT_SYMBOL_GPL(tcp_get_info);
2668 2674
@@ -2734,6 +2740,26 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
2734 return -EFAULT; 2740 return -EFAULT;
2735 return 0; 2741 return 0;
2736 } 2742 }
2743 case TCP_CC_INFO: {
2744 const struct tcp_congestion_ops *ca_ops;
2745 union tcp_cc_info info;
2746 size_t sz = 0;
2747 int attr;
2748
2749 if (get_user(len, optlen))
2750 return -EFAULT;
2751
2752 ca_ops = icsk->icsk_ca_ops;
2753 if (ca_ops && ca_ops->get_info)
2754 sz = ca_ops->get_info(sk, ~0U, &attr, &info);
2755
2756 len = min_t(unsigned int, len, sz);
2757 if (put_user(len, optlen))
2758 return -EFAULT;
2759 if (copy_to_user(optval, &info, len))
2760 return -EFAULT;
2761 return 0;
2762 }
2737 case TCP_QUICKACK: 2763 case TCP_QUICKACK:
2738 val = !icsk->icsk_ack.pingpong; 2764 val = !icsk->icsk_ack.pingpong;
2739 break; 2765 break;
diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c
index 4376016f7fa5..4c41c1287197 100644
--- a/net/ipv4/tcp_dctcp.c
+++ b/net/ipv4/tcp_dctcp.c
@@ -277,7 +277,8 @@ static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev)
277 } 277 }
278} 278}
279 279
280static int dctcp_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) 280static size_t dctcp_get_info(struct sock *sk, u32 ext, int *attr,
281 union tcp_cc_info *info)
281{ 282{
282 const struct dctcp *ca = inet_csk_ca(sk); 283 const struct dctcp *ca = inet_csk_ca(sk);
283 284
@@ -286,18 +287,17 @@ static int dctcp_get_info(struct sock *sk, u32 ext, struct sk_buff *skb)
286 */ 287 */
287 if (ext & (1 << (INET_DIAG_DCTCPINFO - 1)) || 288 if (ext & (1 << (INET_DIAG_DCTCPINFO - 1)) ||
288 ext & (1 << (INET_DIAG_VEGASINFO - 1))) { 289 ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
289 struct tcp_dctcp_info info; 290 memset(info, 0, sizeof(struct tcp_dctcp_info));
290
291 memset(&info, 0, sizeof(info));
292 if (inet_csk(sk)->icsk_ca_ops != &dctcp_reno) { 291 if (inet_csk(sk)->icsk_ca_ops != &dctcp_reno) {
293 info.dctcp_enabled = 1; 292 info->dctcp.dctcp_enabled = 1;
294 info.dctcp_ce_state = (u16) ca->ce_state; 293 info->dctcp.dctcp_ce_state = (u16) ca->ce_state;
295 info.dctcp_alpha = ca->dctcp_alpha; 294 info->dctcp.dctcp_alpha = ca->dctcp_alpha;
296 info.dctcp_ab_ecn = ca->acked_bytes_ecn; 295 info->dctcp.dctcp_ab_ecn = ca->acked_bytes_ecn;
297 info.dctcp_ab_tot = ca->acked_bytes_total; 296 info->dctcp.dctcp_ab_tot = ca->acked_bytes_total;
298 } 297 }
299 298
300 return nla_put(skb, INET_DIAG_DCTCPINFO, sizeof(info), &info); 299 *attr = INET_DIAG_DCTCPINFO;
300 return sizeof(*info);
301 } 301 }
302 return 0; 302 return 0;
303} 303}
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index e3d87aca6be8..3c673d5e6cff 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -206,6 +206,7 @@ static bool tcp_fastopen_create_child(struct sock *sk,
206 skb_set_owner_r(skb2, child); 206 skb_set_owner_r(skb2, child);
207 __skb_queue_tail(&child->sk_receive_queue, skb2); 207 __skb_queue_tail(&child->sk_receive_queue, skb2);
208 tp->syn_data_acked = 1; 208 tp->syn_data_acked = 1;
209 tp->bytes_received = end_seq - TCP_SKB_CB(skb)->seq - 1;
209 } else { 210 } else {
210 end_seq = TCP_SKB_CB(skb)->seq + 1; 211 end_seq = TCP_SKB_CB(skb)->seq + 1;
211 } 212 }
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
index 67476f085e48..f71002e4db0b 100644
--- a/net/ipv4/tcp_illinois.c
+++ b/net/ipv4/tcp_illinois.c
@@ -300,24 +300,25 @@ static u32 tcp_illinois_ssthresh(struct sock *sk)
300} 300}
301 301
302/* Extract info for Tcp socket info provided via netlink. */ 302/* Extract info for Tcp socket info provided via netlink. */
303static int tcp_illinois_info(struct sock *sk, u32 ext, struct sk_buff *skb) 303static size_t tcp_illinois_info(struct sock *sk, u32 ext, int *attr,
304 union tcp_cc_info *info)
304{ 305{
305 const struct illinois *ca = inet_csk_ca(sk); 306 const struct illinois *ca = inet_csk_ca(sk);
306 307
307 if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { 308 if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
308 struct tcpvegas_info info = { 309 info->vegas.tcpv_enabled = 1;
309 .tcpv_enabled = 1, 310 info->vegas.tcpv_rttcnt = ca->cnt_rtt;
310 .tcpv_rttcnt = ca->cnt_rtt, 311 info->vegas.tcpv_minrtt = ca->base_rtt;
311 .tcpv_minrtt = ca->base_rtt, 312 info->vegas.tcpv_rtt = 0;
312 };
313 313
314 if (info.tcpv_rttcnt > 0) { 314 if (info->vegas.tcpv_rttcnt > 0) {
315 u64 t = ca->sum_rtt; 315 u64 t = ca->sum_rtt;
316 316
317 do_div(t, info.tcpv_rttcnt); 317 do_div(t, info->vegas.tcpv_rttcnt);
318 info.tcpv_rtt = t; 318 info->vegas.tcpv_rtt = t;
319 } 319 }
320 return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); 320 *attr = INET_DIAG_VEGASINFO;
321 return sizeof(struct tcpvegas_info);
321 } 322 }
322 return 0; 323 return 0;
323} 324}
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 3a4d9b34bed4..bc790ea9960f 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -1820,14 +1820,12 @@ advance_sp:
1820 for (j = 0; j < used_sacks; j++) 1820 for (j = 0; j < used_sacks; j++)
1821 tp->recv_sack_cache[i++] = sp[j]; 1821 tp->recv_sack_cache[i++] = sp[j];
1822 1822
1823 tcp_mark_lost_retrans(sk);
1824
1825 tcp_verify_left_out(tp);
1826
1827 if ((state.reord < tp->fackets_out) && 1823 if ((state.reord < tp->fackets_out) &&
1828 ((inet_csk(sk)->icsk_ca_state != TCP_CA_Loss) || tp->undo_marker)) 1824 ((inet_csk(sk)->icsk_ca_state != TCP_CA_Loss) || tp->undo_marker))
1829 tcp_update_reordering(sk, tp->fackets_out - state.reord, 0); 1825 tcp_update_reordering(sk, tp->fackets_out - state.reord, 0);
1830 1826
1827 tcp_mark_lost_retrans(sk);
1828 tcp_verify_left_out(tp);
1831out: 1829out:
1832 1830
1833#if FASTRETRANS_DEBUG > 0 1831#if FASTRETRANS_DEBUG > 0
@@ -3280,6 +3278,24 @@ static inline bool tcp_may_update_window(const struct tcp_sock *tp,
3280 (ack_seq == tp->snd_wl1 && nwin > tp->snd_wnd); 3278 (ack_seq == tp->snd_wl1 && nwin > tp->snd_wnd);
3281} 3279}
3282 3280
3281/* If we update tp->snd_una, also update tp->bytes_acked */
3282static void tcp_snd_una_update(struct tcp_sock *tp, u32 ack)
3283{
3284 u32 delta = ack - tp->snd_una;
3285
3286 tp->bytes_acked += delta;
3287 tp->snd_una = ack;
3288}
3289
3290/* If we update tp->rcv_nxt, also update tp->bytes_received */
3291static void tcp_rcv_nxt_update(struct tcp_sock *tp, u32 seq)
3292{
3293 u32 delta = seq - tp->rcv_nxt;
3294
3295 tp->bytes_received += delta;
3296 tp->rcv_nxt = seq;
3297}
3298
3283/* Update our send window. 3299/* Update our send window.
3284 * 3300 *
3285 * Window update algorithm, described in RFC793/RFC1122 (used in linux-2.2 3301 * Window update algorithm, described in RFC793/RFC1122 (used in linux-2.2
@@ -3315,7 +3331,7 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32
3315 } 3331 }
3316 } 3332 }
3317 3333
3318 tp->snd_una = ack; 3334 tcp_snd_una_update(tp, ack);
3319 3335
3320 return flag; 3336 return flag;
3321} 3337}
@@ -3497,7 +3513,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
3497 * Note, we use the fact that SND.UNA>=SND.WL2. 3513 * Note, we use the fact that SND.UNA>=SND.WL2.
3498 */ 3514 */
3499 tcp_update_wl(tp, ack_seq); 3515 tcp_update_wl(tp, ack_seq);
3500 tp->snd_una = ack; 3516 tcp_snd_una_update(tp, ack);
3501 flag |= FLAG_WIN_UPDATE; 3517 flag |= FLAG_WIN_UPDATE;
3502 3518
3503 tcp_in_ack_event(sk, CA_ACK_WIN_UPDATE); 3519 tcp_in_ack_event(sk, CA_ACK_WIN_UPDATE);
@@ -4236,7 +4252,7 @@ static void tcp_ofo_queue(struct sock *sk)
4236 4252
4237 tail = skb_peek_tail(&sk->sk_receive_queue); 4253 tail = skb_peek_tail(&sk->sk_receive_queue);
4238 eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen); 4254 eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen);
4239 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; 4255 tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
4240 if (!eaten) 4256 if (!eaten)
4241 __skb_queue_tail(&sk->sk_receive_queue, skb); 4257 __skb_queue_tail(&sk->sk_receive_queue, skb);
4242 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) 4258 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
@@ -4404,7 +4420,7 @@ static int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb, int
4404 __skb_pull(skb, hdrlen); 4420 __skb_pull(skb, hdrlen);
4405 eaten = (tail && 4421 eaten = (tail &&
4406 tcp_try_coalesce(sk, tail, skb, fragstolen)) ? 1 : 0; 4422 tcp_try_coalesce(sk, tail, skb, fragstolen)) ? 1 : 0;
4407 tcp_sk(sk)->rcv_nxt = TCP_SKB_CB(skb)->end_seq; 4423 tcp_rcv_nxt_update(tcp_sk(sk), TCP_SKB_CB(skb)->end_seq);
4408 if (!eaten) { 4424 if (!eaten) {
4409 __skb_queue_tail(&sk->sk_receive_queue, skb); 4425 __skb_queue_tail(&sk->sk_receive_queue, skb);
4410 skb_set_owner_r(skb, sk); 4426 skb_set_owner_r(skb, sk);
@@ -4497,7 +4513,7 @@ queue_and_out:
4497 4513
4498 eaten = tcp_queue_rcv(sk, skb, 0, &fragstolen); 4514 eaten = tcp_queue_rcv(sk, skb, 0, &fragstolen);
4499 } 4515 }
4500 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; 4516 tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
4501 if (skb->len) 4517 if (skb->len)
4502 tcp_event_data_recv(sk, skb); 4518 tcp_event_data_recv(sk, skb);
4503 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) 4519 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
@@ -5245,7 +5261,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
5245 tcp_rcv_rtt_measure_ts(sk, skb); 5261 tcp_rcv_rtt_measure_ts(sk, skb);
5246 5262
5247 __skb_pull(skb, tcp_header_len); 5263 __skb_pull(skb, tcp_header_len);
5248 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; 5264 tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
5249 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITSTOUSER); 5265 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITSTOUSER);
5250 eaten = 1; 5266 eaten = 1;
5251 } 5267 }
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
index c71a1b8f7bde..a6cea1d5e20d 100644
--- a/net/ipv4/tcp_vegas.c
+++ b/net/ipv4/tcp_vegas.c
@@ -286,18 +286,19 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 acked)
286} 286}
287 287
288/* Extract info for Tcp socket info provided via netlink. */ 288/* Extract info for Tcp socket info provided via netlink. */
289int tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) 289size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr,
290 union tcp_cc_info *info)
290{ 291{
291 const struct vegas *ca = inet_csk_ca(sk); 292 const struct vegas *ca = inet_csk_ca(sk);
293
292 if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { 294 if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
293 struct tcpvegas_info info = { 295 info->vegas.tcpv_enabled = ca->doing_vegas_now,
294 .tcpv_enabled = ca->doing_vegas_now, 296 info->vegas.tcpv_rttcnt = ca->cntRTT,
295 .tcpv_rttcnt = ca->cntRTT, 297 info->vegas.tcpv_rtt = ca->baseRTT,
296 .tcpv_rtt = ca->baseRTT, 298 info->vegas.tcpv_minrtt = ca->minRTT,
297 .tcpv_minrtt = ca->minRTT, 299
298 }; 300 *attr = INET_DIAG_VEGASINFO;
299 301 return sizeof(struct tcpvegas_info);
300 return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info);
301 } 302 }
302 return 0; 303 return 0;
303} 304}
diff --git a/net/ipv4/tcp_vegas.h b/net/ipv4/tcp_vegas.h
index e8a6b33cc61d..ef9da5306c68 100644
--- a/net/ipv4/tcp_vegas.h
+++ b/net/ipv4/tcp_vegas.h
@@ -19,6 +19,7 @@ void tcp_vegas_init(struct sock *sk);
19void tcp_vegas_state(struct sock *sk, u8 ca_state); 19void tcp_vegas_state(struct sock *sk, u8 ca_state);
20void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us); 20void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us);
21void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event); 21void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event);
22int tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb); 22size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr,
23 union tcp_cc_info *info);
23 24
24#endif /* __TCP_VEGAS_H */ 25#endif /* __TCP_VEGAS_H */
diff --git a/net/ipv4/tcp_westwood.c b/net/ipv4/tcp_westwood.c
index b3c57cceb990..c10732e39837 100644
--- a/net/ipv4/tcp_westwood.c
+++ b/net/ipv4/tcp_westwood.c
@@ -256,18 +256,19 @@ static void tcp_westwood_event(struct sock *sk, enum tcp_ca_event event)
256} 256}
257 257
258/* Extract info for Tcp socket info provided via netlink. */ 258/* Extract info for Tcp socket info provided via netlink. */
259static int tcp_westwood_info(struct sock *sk, u32 ext, struct sk_buff *skb) 259static size_t tcp_westwood_info(struct sock *sk, u32 ext, int *attr,
260 union tcp_cc_info *info)
260{ 261{
261 const struct westwood *ca = inet_csk_ca(sk); 262 const struct westwood *ca = inet_csk_ca(sk);
262 263
263 if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { 264 if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
264 struct tcpvegas_info info = { 265 info->vegas.tcpv_enabled = 1;
265 .tcpv_enabled = 1, 266 info->vegas.tcpv_rttcnt = 0;
266 .tcpv_rtt = jiffies_to_usecs(ca->rtt), 267 info->vegas.tcpv_rtt = jiffies_to_usecs(ca->rtt),
267 .tcpv_minrtt = jiffies_to_usecs(ca->rtt_min), 268 info->vegas.tcpv_minrtt = jiffies_to_usecs(ca->rtt_min),
268 };
269 269
270 return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); 270 *attr = INET_DIAG_VEGASINFO;
271 return sizeof(struct tcpvegas_info);
271 } 272 }
272 return 0; 273 return 0;
273} 274}
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 7fde1f265c90..c21777565c58 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -886,22 +886,45 @@ static int ip6_dst_lookup_tail(struct sock *sk,
886#endif 886#endif
887 int err; 887 int err;
888 888
889 if (!*dst) 889 /* The correct way to handle this would be to do
890 *dst = ip6_route_output(net, sk, fl6); 890 * ip6_route_get_saddr, and then ip6_route_output; however,
891 891 * the route-specific preferred source forces the
892 err = (*dst)->error; 892 * ip6_route_output call _before_ ip6_route_get_saddr.
893 if (err) 893 *
894 goto out_err_release; 894 * In source specific routing (no src=any default route),
895 * ip6_route_output will fail given src=any saddr, though, so
896 * that's why we try it again later.
897 */
898 if (ipv6_addr_any(&fl6->saddr) && (!*dst || !(*dst)->error)) {
899 struct rt6_info *rt;
900 bool had_dst = *dst != NULL;
895 901
896 if (ipv6_addr_any(&fl6->saddr)) { 902 if (!had_dst)
897 struct rt6_info *rt = (struct rt6_info *) *dst; 903 *dst = ip6_route_output(net, sk, fl6);
904 rt = (*dst)->error ? NULL : (struct rt6_info *)*dst;
898 err = ip6_route_get_saddr(net, rt, &fl6->daddr, 905 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
899 sk ? inet6_sk(sk)->srcprefs : 0, 906 sk ? inet6_sk(sk)->srcprefs : 0,
900 &fl6->saddr); 907 &fl6->saddr);
901 if (err) 908 if (err)
902 goto out_err_release; 909 goto out_err_release;
910
911 /* If we had an erroneous initial result, pretend it
912 * never existed and let the SA-enabled version take
913 * over.
914 */
915 if (!had_dst && (*dst)->error) {
916 dst_release(*dst);
917 *dst = NULL;
918 }
903 } 919 }
904 920
921 if (!*dst)
922 *dst = ip6_route_output(net, sk, fl6);
923
924 err = (*dst)->error;
925 if (err)
926 goto out_err_release;
927
905#ifdef CONFIG_IPV6_OPTIMISTIC_DAD 928#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
906 /* 929 /*
907 * Here if the dst entry we've looked up 930 * Here if the dst entry we've looked up
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 5c48293ff062..d3588885f097 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2245,9 +2245,10 @@ int ip6_route_get_saddr(struct net *net,
2245 unsigned int prefs, 2245 unsigned int prefs,
2246 struct in6_addr *saddr) 2246 struct in6_addr *saddr)
2247{ 2247{
2248 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry *)rt); 2248 struct inet6_dev *idev =
2249 rt ? ip6_dst_idev((struct dst_entry *)rt) : NULL;
2249 int err = 0; 2250 int err = 0;
2250 if (rt->rt6i_prefsrc.plen) 2251 if (rt && rt->rt6i_prefsrc.plen)
2251 *saddr = rt->rt6i_prefsrc.addr; 2252 *saddr = rt->rt6i_prefsrc.addr;
2252 else 2253 else
2253 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL, 2254 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index b4ac596a7cb7..bab5c63c0bad 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -819,13 +819,15 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
819 * (because if we remove a STA after ops->remove_interface() 819 * (because if we remove a STA after ops->remove_interface()
820 * the driver will have removed the vif info already!) 820 * the driver will have removed the vif info already!)
821 * 821 *
822 * This is relevant only in WDS mode, in all other modes we've 822 * In WDS mode a station must exist here and be flushed, for
823 * already removed all stations when disconnecting or similar, 823 * AP_VLANs stations may exist since there's nothing else that
824 * so warn otherwise. 824 * would have removed them, but in other modes there shouldn't
825 * be any stations.
825 */ 826 */
826 flushed = sta_info_flush(sdata); 827 flushed = sta_info_flush(sdata);
827 WARN_ON_ONCE((sdata->vif.type != NL80211_IFTYPE_WDS && flushed > 0) || 828 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
828 (sdata->vif.type == NL80211_IFTYPE_WDS && flushed != 1)); 829 ((sdata->vif.type != NL80211_IFTYPE_WDS && flushed > 0) ||
830 (sdata->vif.type == NL80211_IFTYPE_WDS && flushed != 1)));
829 831
830 /* don't count this interface for promisc/allmulti while it is down */ 832 /* don't count this interface for promisc/allmulti while it is down */
831 if (sdata->flags & IEEE80211_SDATA_ALLMULTI) 833 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 12971b71d0fa..2880f2ae99ab 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -66,6 +66,7 @@
66 66
67static const struct rhashtable_params sta_rht_params = { 67static const struct rhashtable_params sta_rht_params = {
68 .nelem_hint = 3, /* start small */ 68 .nelem_hint = 3, /* start small */
69 .automatic_shrinking = true,
69 .head_offset = offsetof(struct sta_info, hash_node), 70 .head_offset = offsetof(struct sta_info, hash_node),
70 .key_offset = offsetof(struct sta_info, sta.addr), 71 .key_offset = offsetof(struct sta_info, sta.addr),
71 .key_len = ETH_ALEN, 72 .key_len = ETH_ALEN,
@@ -157,8 +158,24 @@ struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata,
157 const u8 *addr) 158 const u8 *addr)
158{ 159{
159 struct ieee80211_local *local = sdata->local; 160 struct ieee80211_local *local = sdata->local;
161 struct sta_info *sta;
162 struct rhash_head *tmp;
163 const struct bucket_table *tbl;
164
165 rcu_read_lock();
166 tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash);
160 167
161 return rhashtable_lookup_fast(&local->sta_hash, addr, sta_rht_params); 168 for_each_sta_info(local, tbl, addr, sta, tmp) {
169 if (sta->sdata == sdata) {
170 rcu_read_unlock();
171 /* this is safe as the caller must already hold
172 * another rcu read section or the mutex
173 */
174 return sta;
175 }
176 }
177 rcu_read_unlock();
178 return NULL;
162} 179}
163 180
164/* 181/*
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index 5d9f68c75e5f..70be9c799f8a 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -22,13 +22,14 @@
22 22
23static struct net_device * 23static struct net_device *
24ieee802154_add_iface_deprecated(struct wpan_phy *wpan_phy, 24ieee802154_add_iface_deprecated(struct wpan_phy *wpan_phy,
25 const char *name, int type) 25 const char *name,
26 unsigned char name_assign_type, int type)
26{ 27{
27 struct ieee802154_local *local = wpan_phy_priv(wpan_phy); 28 struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
28 struct net_device *dev; 29 struct net_device *dev;
29 30
30 rtnl_lock(); 31 rtnl_lock();
31 dev = ieee802154_if_add(local, name, type, 32 dev = ieee802154_if_add(local, name, name_assign_type, type,
32 cpu_to_le64(0x0000000000000000ULL)); 33 cpu_to_le64(0x0000000000000000ULL));
33 rtnl_unlock(); 34 rtnl_unlock();
34 35
@@ -45,12 +46,14 @@ static void ieee802154_del_iface_deprecated(struct wpan_phy *wpan_phy,
45 46
46static int 47static int
47ieee802154_add_iface(struct wpan_phy *phy, const char *name, 48ieee802154_add_iface(struct wpan_phy *phy, const char *name,
49 unsigned char name_assign_type,
48 enum nl802154_iftype type, __le64 extended_addr) 50 enum nl802154_iftype type, __le64 extended_addr)
49{ 51{
50 struct ieee802154_local *local = wpan_phy_priv(phy); 52 struct ieee802154_local *local = wpan_phy_priv(phy);
51 struct net_device *err; 53 struct net_device *err;
52 54
53 err = ieee802154_if_add(local, name, type, extended_addr); 55 err = ieee802154_if_add(local, name, name_assign_type, type,
56 extended_addr);
54 return PTR_ERR_OR_ZERO(err); 57 return PTR_ERR_OR_ZERO(err);
55} 58}
56 59
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index bebd70ffc7a3..127ba18386fc 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -182,7 +182,8 @@ void ieee802154_iface_exit(void);
182void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata); 182void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata);
183struct net_device * 183struct net_device *
184ieee802154_if_add(struct ieee802154_local *local, const char *name, 184ieee802154_if_add(struct ieee802154_local *local, const char *name,
185 enum nl802154_iftype type, __le64 extended_addr); 185 unsigned char name_assign_type, enum nl802154_iftype type,
186 __le64 extended_addr);
186void ieee802154_remove_interfaces(struct ieee802154_local *local); 187void ieee802154_remove_interfaces(struct ieee802154_local *local);
187 188
188#endif /* __IEEE802154_I_H */ 189#endif /* __IEEE802154_I_H */
diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
index 38b56f9d9386..91b75abbd1a1 100644
--- a/net/mac802154/iface.c
+++ b/net/mac802154/iface.c
@@ -522,7 +522,8 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata,
522 522
523struct net_device * 523struct net_device *
524ieee802154_if_add(struct ieee802154_local *local, const char *name, 524ieee802154_if_add(struct ieee802154_local *local, const char *name,
525 enum nl802154_iftype type, __le64 extended_addr) 525 unsigned char name_assign_type, enum nl802154_iftype type,
526 __le64 extended_addr)
526{ 527{
527 struct net_device *ndev = NULL; 528 struct net_device *ndev = NULL;
528 struct ieee802154_sub_if_data *sdata = NULL; 529 struct ieee802154_sub_if_data *sdata = NULL;
@@ -531,7 +532,7 @@ ieee802154_if_add(struct ieee802154_local *local, const char *name,
531 ASSERT_RTNL(); 532 ASSERT_RTNL();
532 533
533 ndev = alloc_netdev(sizeof(*sdata) + local->hw.vif_data_size, name, 534 ndev = alloc_netdev(sizeof(*sdata) + local->hw.vif_data_size, name,
534 NET_NAME_UNKNOWN, ieee802154_if_setup); 535 name_assign_type, ieee802154_if_setup);
535 if (!ndev) 536 if (!ndev)
536 return ERR_PTR(-ENOMEM); 537 return ERR_PTR(-ENOMEM);
537 538
diff --git a/net/mac802154/llsec.c b/net/mac802154/llsec.c
index dcf73958133a..5b2be12832e6 100644
--- a/net/mac802154/llsec.c
+++ b/net/mac802154/llsec.c
@@ -134,7 +134,7 @@ llsec_key_alloc(const struct ieee802154_llsec_key *template)
134 for (i = 0; i < ARRAY_SIZE(key->tfm); i++) { 134 for (i = 0; i < ARRAY_SIZE(key->tfm); i++) {
135 key->tfm[i] = crypto_alloc_aead("ccm(aes)", 0, 135 key->tfm[i] = crypto_alloc_aead("ccm(aes)", 0,
136 CRYPTO_ALG_ASYNC); 136 CRYPTO_ALG_ASYNC);
137 if (!key->tfm[i]) 137 if (IS_ERR(key->tfm[i]))
138 goto err_tfm; 138 goto err_tfm;
139 if (crypto_aead_setkey(key->tfm[i], template->key, 139 if (crypto_aead_setkey(key->tfm[i], template->key,
140 IEEE802154_LLSEC_KEY_SIZE)) 140 IEEE802154_LLSEC_KEY_SIZE))
@@ -144,7 +144,7 @@ llsec_key_alloc(const struct ieee802154_llsec_key *template)
144 } 144 }
145 145
146 key->tfm0 = crypto_alloc_blkcipher("ctr(aes)", 0, CRYPTO_ALG_ASYNC); 146 key->tfm0 = crypto_alloc_blkcipher("ctr(aes)", 0, CRYPTO_ALG_ASYNC);
147 if (!key->tfm0) 147 if (IS_ERR(key->tfm0))
148 goto err_tfm; 148 goto err_tfm;
149 149
150 if (crypto_blkcipher_setkey(key->tfm0, template->key, 150 if (crypto_blkcipher_setkey(key->tfm0, template->key,
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 8500378c8318..08cb32dc8fd3 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -161,18 +161,21 @@ int ieee802154_register_hw(struct ieee802154_hw *hw)
161 161
162 rtnl_lock(); 162 rtnl_lock();
163 163
164 dev = ieee802154_if_add(local, "wpan%d", NL802154_IFTYPE_NODE, 164 dev = ieee802154_if_add(local, "wpan%d", NET_NAME_ENUM,
165 NL802154_IFTYPE_NODE,
165 cpu_to_le64(0x0000000000000000ULL)); 166 cpu_to_le64(0x0000000000000000ULL));
166 if (IS_ERR(dev)) { 167 if (IS_ERR(dev)) {
167 rtnl_unlock(); 168 rtnl_unlock();
168 rc = PTR_ERR(dev); 169 rc = PTR_ERR(dev);
169 goto out_wq; 170 goto out_phy;
170 } 171 }
171 172
172 rtnl_unlock(); 173 rtnl_unlock();
173 174
174 return 0; 175 return 0;
175 176
177out_phy:
178 wpan_phy_unregister(local->phy);
176out_wq: 179out_wq:
177 destroy_workqueue(local->workqueue); 180 destroy_workqueue(local->workqueue);
178out: 181out:
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 954810c76a86..7b3f732269e4 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -647,7 +647,7 @@ int nla_get_labels(const struct nlattr *nla,
647 return -EINVAL; 647 return -EINVAL;
648 648
649 switch (dec.label) { 649 switch (dec.label) {
650 case LABEL_IMPLICIT_NULL: 650 case MPLS_LABEL_IMPLNULL:
651 /* RFC3032: This is a label that an LSR may 651 /* RFC3032: This is a label that an LSR may
652 * assign and distribute, but which never 652 * assign and distribute, but which never
653 * actually appears in the encapsulation. 653 * actually appears in the encapsulation.
@@ -935,7 +935,7 @@ static int resize_platform_label_table(struct net *net, size_t limit)
935 } 935 }
936 936
937 /* In case the predefined labels need to be populated */ 937 /* In case the predefined labels need to be populated */
938 if (limit > LABEL_IPV4_EXPLICIT_NULL) { 938 if (limit > MPLS_LABEL_IPV4NULL) {
939 struct net_device *lo = net->loopback_dev; 939 struct net_device *lo = net->loopback_dev;
940 rt0 = mpls_rt_alloc(lo->addr_len); 940 rt0 = mpls_rt_alloc(lo->addr_len);
941 if (!rt0) 941 if (!rt0)
@@ -945,7 +945,7 @@ static int resize_platform_label_table(struct net *net, size_t limit)
945 rt0->rt_via_table = NEIGH_LINK_TABLE; 945 rt0->rt_via_table = NEIGH_LINK_TABLE;
946 memcpy(rt0->rt_via, lo->dev_addr, lo->addr_len); 946 memcpy(rt0->rt_via, lo->dev_addr, lo->addr_len);
947 } 947 }
948 if (limit > LABEL_IPV6_EXPLICIT_NULL) { 948 if (limit > MPLS_LABEL_IPV6NULL) {
949 struct net_device *lo = net->loopback_dev; 949 struct net_device *lo = net->loopback_dev;
950 rt2 = mpls_rt_alloc(lo->addr_len); 950 rt2 = mpls_rt_alloc(lo->addr_len);
951 if (!rt2) 951 if (!rt2)
@@ -973,15 +973,15 @@ static int resize_platform_label_table(struct net *net, size_t limit)
973 memcpy(labels, old, cp_size); 973 memcpy(labels, old, cp_size);
974 974
975 /* If needed set the predefined labels */ 975 /* If needed set the predefined labels */
976 if ((old_limit <= LABEL_IPV6_EXPLICIT_NULL) && 976 if ((old_limit <= MPLS_LABEL_IPV6NULL) &&
977 (limit > LABEL_IPV6_EXPLICIT_NULL)) { 977 (limit > MPLS_LABEL_IPV6NULL)) {
978 RCU_INIT_POINTER(labels[LABEL_IPV6_EXPLICIT_NULL], rt2); 978 RCU_INIT_POINTER(labels[MPLS_LABEL_IPV6NULL], rt2);
979 rt2 = NULL; 979 rt2 = NULL;
980 } 980 }
981 981
982 if ((old_limit <= LABEL_IPV4_EXPLICIT_NULL) && 982 if ((old_limit <= MPLS_LABEL_IPV4NULL) &&
983 (limit > LABEL_IPV4_EXPLICIT_NULL)) { 983 (limit > MPLS_LABEL_IPV4NULL)) {
984 RCU_INIT_POINTER(labels[LABEL_IPV4_EXPLICIT_NULL], rt0); 984 RCU_INIT_POINTER(labels[MPLS_LABEL_IPV4NULL], rt0);
985 rt0 = NULL; 985 rt0 = NULL;
986 } 986 }
987 987
diff --git a/net/mpls/internal.h b/net/mpls/internal.h
index 693877d69606..b064c345042c 100644
--- a/net/mpls/internal.h
+++ b/net/mpls/internal.h
@@ -1,16 +1,6 @@
1#ifndef MPLS_INTERNAL_H 1#ifndef MPLS_INTERNAL_H
2#define MPLS_INTERNAL_H 2#define MPLS_INTERNAL_H
3 3
4#define LABEL_IPV4_EXPLICIT_NULL 0 /* RFC3032 */
5#define LABEL_ROUTER_ALERT_LABEL 1 /* RFC3032 */
6#define LABEL_IPV6_EXPLICIT_NULL 2 /* RFC3032 */
7#define LABEL_IMPLICIT_NULL 3 /* RFC3032 */
8#define LABEL_ENTROPY_INDICATOR 7 /* RFC6790 */
9#define LABEL_GAL 13 /* RFC5586 */
10#define LABEL_OAM_ALERT 14 /* RFC3429 */
11#define LABEL_EXTENSION 15 /* RFC7274 */
12
13
14struct mpls_shim_hdr { 4struct mpls_shim_hdr {
15 __be32 label_stack_entry; 5 __be32 label_stack_entry;
16}; 6};
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index ec4adbdcb9b4..daa0b818174b 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -3139,7 +3139,6 @@ static const struct rhashtable_params netlink_rhashtable_params = {
3139 .key_len = netlink_compare_arg_len, 3139 .key_len = netlink_compare_arg_len,
3140 .obj_hashfn = netlink_hash, 3140 .obj_hashfn = netlink_hash,
3141 .obj_cmpfn = netlink_compare, 3141 .obj_cmpfn = netlink_compare,
3142 .max_size = 65536,
3143 .automatic_shrinking = true, 3142 .automatic_shrinking = true,
3144}; 3143};
3145 3144
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 5102c3cc4eec..b5989c6ee551 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2311,11 +2311,14 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
2311 tlen = dev->needed_tailroom; 2311 tlen = dev->needed_tailroom;
2312 skb = sock_alloc_send_skb(&po->sk, 2312 skb = sock_alloc_send_skb(&po->sk,
2313 hlen + tlen + sizeof(struct sockaddr_ll), 2313 hlen + tlen + sizeof(struct sockaddr_ll),
2314 0, &err); 2314 !need_wait, &err);
2315 2315
2316 if (unlikely(skb == NULL)) 2316 if (unlikely(skb == NULL)) {
2317 /* we assume the socket was initially writeable ... */
2318 if (likely(len_sum > 0))
2319 err = len_sum;
2317 goto out_status; 2320 goto out_status;
2318 2321 }
2319 tp_len = tpacket_fill_skb(po, skb, ph, dev, size_max, proto, 2322 tp_len = tpacket_fill_skb(po, skb, ph, dev, size_max, proto,
2320 addr, hlen); 2323 addr, hlen);
2321 if (tp_len > dev->mtu + dev->hard_header_len) { 2324 if (tp_len > dev->mtu + dev->hard_header_len) {
diff --git a/net/rds/connection.c b/net/rds/connection.c
index 14f041398ca1..da6da57e5f36 100644
--- a/net/rds/connection.c
+++ b/net/rds/connection.c
@@ -126,7 +126,10 @@ static struct rds_connection *__rds_conn_create(__be32 laddr, __be32 faddr,
126 struct rds_transport *loop_trans; 126 struct rds_transport *loop_trans;
127 unsigned long flags; 127 unsigned long flags;
128 int ret; 128 int ret;
129 struct rds_transport *otrans = trans;
129 130
131 if (!is_outgoing && otrans->t_type == RDS_TRANS_TCP)
132 goto new_conn;
130 rcu_read_lock(); 133 rcu_read_lock();
131 conn = rds_conn_lookup(head, laddr, faddr, trans); 134 conn = rds_conn_lookup(head, laddr, faddr, trans);
132 if (conn && conn->c_loopback && conn->c_trans != &rds_loop_transport && 135 if (conn && conn->c_loopback && conn->c_trans != &rds_loop_transport &&
@@ -142,6 +145,7 @@ static struct rds_connection *__rds_conn_create(__be32 laddr, __be32 faddr,
142 if (conn) 145 if (conn)
143 goto out; 146 goto out;
144 147
148new_conn:
145 conn = kmem_cache_zalloc(rds_conn_slab, gfp); 149 conn = kmem_cache_zalloc(rds_conn_slab, gfp);
146 if (!conn) { 150 if (!conn) {
147 conn = ERR_PTR(-ENOMEM); 151 conn = ERR_PTR(-ENOMEM);
@@ -230,13 +234,22 @@ static struct rds_connection *__rds_conn_create(__be32 laddr, __be32 faddr,
230 /* Creating normal conn */ 234 /* Creating normal conn */
231 struct rds_connection *found; 235 struct rds_connection *found;
232 236
233 found = rds_conn_lookup(head, laddr, faddr, trans); 237 if (!is_outgoing && otrans->t_type == RDS_TRANS_TCP)
238 found = NULL;
239 else
240 found = rds_conn_lookup(head, laddr, faddr, trans);
234 if (found) { 241 if (found) {
235 trans->conn_free(conn->c_transport_data); 242 trans->conn_free(conn->c_transport_data);
236 kmem_cache_free(rds_conn_slab, conn); 243 kmem_cache_free(rds_conn_slab, conn);
237 conn = found; 244 conn = found;
238 } else { 245 } else {
239 hlist_add_head_rcu(&conn->c_hash_node, head); 246 if ((is_outgoing && otrans->t_type == RDS_TRANS_TCP) ||
247 (otrans->t_type != RDS_TRANS_TCP)) {
248 /* Only the active side should be added to
249 * reconnect list for TCP.
250 */
251 hlist_add_head_rcu(&conn->c_hash_node, head);
252 }
240 rds_cong_add_conn(conn); 253 rds_cong_add_conn(conn);
241 rds_conn_count++; 254 rds_conn_count++;
242 } 255 }
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 31b74f5e61ad..8a09ee7db3c1 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -183,8 +183,17 @@ void rds_ib_cm_connect_complete(struct rds_connection *conn, struct rdma_cm_even
183 183
184 /* If the peer gave us the last packet it saw, process this as if 184 /* If the peer gave us the last packet it saw, process this as if
185 * we had received a regular ACK. */ 185 * we had received a regular ACK. */
186 if (dp && dp->dp_ack_seq) 186 if (dp) {
187 rds_send_drop_acked(conn, be64_to_cpu(dp->dp_ack_seq), NULL); 187 /* dp structure start is not guaranteed to be 8 bytes aligned.
188 * Since dp_ack_seq is 64-bit extended load operations can be
189 * used so go through get_unaligned to avoid unaligned errors.
190 */
191 __be64 dp_ack_seq = get_unaligned(&dp->dp_ack_seq);
192
193 if (dp_ack_seq)
194 rds_send_drop_acked(conn, be64_to_cpu(dp_ack_seq),
195 NULL);
196 }
188 197
189 rds_connect_complete(conn); 198 rds_connect_complete(conn);
190} 199}
diff --git a/net/rds/tcp_connect.c b/net/rds/tcp_connect.c
index f9f564a6c960..973109c7b8e8 100644
--- a/net/rds/tcp_connect.c
+++ b/net/rds/tcp_connect.c
@@ -62,6 +62,7 @@ void rds_tcp_state_change(struct sock *sk)
62 case TCP_ESTABLISHED: 62 case TCP_ESTABLISHED:
63 rds_connect_complete(conn); 63 rds_connect_complete(conn);
64 break; 64 break;
65 case TCP_CLOSE_WAIT:
65 case TCP_CLOSE: 66 case TCP_CLOSE:
66 rds_conn_drop(conn); 67 rds_conn_drop(conn);
67 default: 68 default:
diff --git a/net/rds/tcp_listen.c b/net/rds/tcp_listen.c
index 23ab4dcd1d9f..0da49e34495f 100644
--- a/net/rds/tcp_listen.c
+++ b/net/rds/tcp_listen.c
@@ -45,12 +45,45 @@ static void rds_tcp_accept_worker(struct work_struct *work);
45static DECLARE_WORK(rds_tcp_listen_work, rds_tcp_accept_worker); 45static DECLARE_WORK(rds_tcp_listen_work, rds_tcp_accept_worker);
46static struct socket *rds_tcp_listen_sock; 46static struct socket *rds_tcp_listen_sock;
47 47
48static int rds_tcp_keepalive(struct socket *sock)
49{
50 /* values below based on xs_udp_default_timeout */
51 int keepidle = 5; /* send a probe 'keepidle' secs after last data */
52 int keepcnt = 5; /* number of unack'ed probes before declaring dead */
53 int keepalive = 1;
54 int ret = 0;
55
56 ret = kernel_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
57 (char *)&keepalive, sizeof(keepalive));
58 if (ret < 0)
59 goto bail;
60
61 ret = kernel_setsockopt(sock, IPPROTO_TCP, TCP_KEEPCNT,
62 (char *)&keepcnt, sizeof(keepcnt));
63 if (ret < 0)
64 goto bail;
65
66 ret = kernel_setsockopt(sock, IPPROTO_TCP, TCP_KEEPIDLE,
67 (char *)&keepidle, sizeof(keepidle));
68 if (ret < 0)
69 goto bail;
70
71 /* KEEPINTVL is the interval between successive probes. We follow
72 * the model in xs_tcp_finish_connecting() and re-use keepidle.
73 */
74 ret = kernel_setsockopt(sock, IPPROTO_TCP, TCP_KEEPINTVL,
75 (char *)&keepidle, sizeof(keepidle));
76bail:
77 return ret;
78}
79
48static int rds_tcp_accept_one(struct socket *sock) 80static int rds_tcp_accept_one(struct socket *sock)
49{ 81{
50 struct socket *new_sock = NULL; 82 struct socket *new_sock = NULL;
51 struct rds_connection *conn; 83 struct rds_connection *conn;
52 int ret; 84 int ret;
53 struct inet_sock *inet; 85 struct inet_sock *inet;
86 struct rds_tcp_connection *rs_tcp;
54 87
55 ret = sock_create_lite(sock->sk->sk_family, sock->sk->sk_type, 88 ret = sock_create_lite(sock->sk->sk_family, sock->sk->sk_type,
56 sock->sk->sk_protocol, &new_sock); 89 sock->sk->sk_protocol, &new_sock);
@@ -63,6 +96,10 @@ static int rds_tcp_accept_one(struct socket *sock)
63 if (ret < 0) 96 if (ret < 0)
64 goto out; 97 goto out;
65 98
99 ret = rds_tcp_keepalive(new_sock);
100 if (ret < 0)
101 goto out;
102
66 rds_tcp_tune(new_sock); 103 rds_tcp_tune(new_sock);
67 104
68 inet = inet_sk(new_sock->sk); 105 inet = inet_sk(new_sock->sk);
@@ -77,6 +114,15 @@ static int rds_tcp_accept_one(struct socket *sock)
77 ret = PTR_ERR(conn); 114 ret = PTR_ERR(conn);
78 goto out; 115 goto out;
79 } 116 }
117 /* An incoming SYN request came in, and TCP just accepted it.
118 * We always create a new conn for listen side of TCP, and do not
119 * add it to the c_hash_list.
120 *
121 * If the client reboots, this conn will need to be cleaned up.
122 * rds_tcp_state_change() will do that cleanup
123 */
124 rs_tcp = (struct rds_tcp_connection *)conn->c_transport_data;
125 WARN_ON(!rs_tcp || rs_tcp->t_sock);
80 126
81 /* 127 /*
82 * see the comment above rds_queue_delayed_reconnect() 128 * see the comment above rds_queue_delayed_reconnect()
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 8b0470e418dc..b6ef9a04de06 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -308,12 +308,11 @@ replay:
308 case RTM_DELTFILTER: 308 case RTM_DELTFILTER:
309 err = tp->ops->delete(tp, fh); 309 err = tp->ops->delete(tp, fh);
310 if (err == 0) { 310 if (err == 0) {
311 tfilter_notify(net, skb, n, tp, fh, RTM_DELTFILTER); 311 struct tcf_proto *next = rtnl_dereference(tp->next);
312 if (tcf_destroy(tp, false)) {
313 struct tcf_proto *next = rtnl_dereference(tp->next);
314 312
313 tfilter_notify(net, skb, n, tp, fh, RTM_DELTFILTER);
314 if (tcf_destroy(tp, false))
315 RCU_INIT_POINTER(*back, next); 315 RCU_INIT_POINTER(*back, next);
316 }
317 } 316 }
318 goto errout; 317 goto errout;
319 case RTM_GETTFILTER: 318 case RTM_GETTFILTER:
diff --git a/net/sched/sch_codel.c b/net/sched/sch_codel.c
index de28f8e968e8..7a0bdb16ac92 100644
--- a/net/sched/sch_codel.c
+++ b/net/sched/sch_codel.c
@@ -164,7 +164,7 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt)
164 164
165 sch->limit = DEFAULT_CODEL_LIMIT; 165 sch->limit = DEFAULT_CODEL_LIMIT;
166 166
167 codel_params_init(&q->params); 167 codel_params_init(&q->params, sch);
168 codel_vars_init(&q->vars); 168 codel_vars_init(&q->vars);
169 codel_stats_init(&q->stats); 169 codel_stats_init(&q->stats);
170 170
diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
index 1e52decb7b59..c244c45b78d7 100644
--- a/net/sched/sch_fq_codel.c
+++ b/net/sched/sch_fq_codel.c
@@ -391,7 +391,7 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt)
391 q->perturbation = prandom_u32(); 391 q->perturbation = prandom_u32();
392 INIT_LIST_HEAD(&q->new_flows); 392 INIT_LIST_HEAD(&q->new_flows);
393 INIT_LIST_HEAD(&q->old_flows); 393 INIT_LIST_HEAD(&q->old_flows);
394 codel_params_init(&q->cparams); 394 codel_params_init(&q->cparams, sch);
395 codel_stats_init(&q->cstats); 395 codel_stats_init(&q->cstats);
396 q->cparams.ecn = true; 396 q->cparams.ecn = true;
397 397
diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
index a4ca4517cdc8..634529e0ce6b 100644
--- a/net/sched/sch_gred.c
+++ b/net/sched/sch_gred.c
@@ -229,7 +229,7 @@ static int gred_enqueue(struct sk_buff *skb, struct Qdisc *sch)
229 break; 229 break;
230 } 230 }
231 231
232 if (q->backlog + qdisc_pkt_len(skb) <= q->limit) { 232 if (gred_backlog(t, q, sch) + qdisc_pkt_len(skb) <= q->limit) {
233 q->backlog += qdisc_pkt_len(skb); 233 q->backlog += qdisc_pkt_len(skb);
234 return qdisc_enqueue_tail(skb, sch); 234 return qdisc_enqueue_tail(skb, sch);
235 } 235 }
@@ -553,7 +553,7 @@ static int gred_dump(struct Qdisc *sch, struct sk_buff *skb)
553 553
554 opt.limit = q->limit; 554 opt.limit = q->limit;
555 opt.DP = q->DP; 555 opt.DP = q->DP;
556 opt.backlog = q->backlog; 556 opt.backlog = gred_backlog(table, q, sch);
557 opt.prio = q->prio; 557 opt.prio = q->prio;
558 opt.qth_min = q->parms.qth_min >> q->parms.Wlog; 558 opt.qth_min = q->parms.qth_min >> q->parms.Wlog;
559 opt.qth_max = q->parms.qth_max >> q->parms.Wlog; 559 opt.qth_max = q->parms.qth_max >> q->parms.Wlog;