History

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 ...

Linus Torvalds committed 11 years ago

Commit 110bc762 parents 6c9d370 01d460d102 files · +1838 −645Browse files

Unified · Split

102 files
  1. MAINTAINERS +7 −7
  2. arch/arm/net/bpf_jit_32.c +39 −3
  3. arch/x86/net/bpf_jit_comp.c +28 −0
  4. drivers/bluetooth/bt3c_cs.c +0 −3
  5. drivers/bluetooth/btbcm.c +79 −69
  6. drivers/bluetooth/btbcm.h +6 −0
  7. drivers/bluetooth/btusb.c +401 −2
  8. drivers/bluetooth/hci_ath.c +63 −35
  9. drivers/net/can/xilinx_can.c +4 −3
  10. drivers/net/dsa/mv88e6xxx.c +3 −0
  11. drivers/net/ethernet/amd/Kconfig +1 −0
  12. drivers/net/ethernet/apm/xgene/Kconfig +1 −0
  13. drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +5 −5
  14. drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +7 −2
  15. drivers/net/ethernet/cadence/macb.c +10 −1
  16. drivers/net/ethernet/intel/e1000e/e1000.h +1 −0
  17. drivers/net/ethernet/intel/fm10k/fm10k_main.c +2 −2
  18. drivers/net/ethernet/intel/igb/igb_main.c +3 −1
  19. drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +1 −1
  20. drivers/net/ethernet/mellanox/mlx4/en_port.c +1 −1
  21. drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +7 −7
  22. drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c +2 −2
  23. drivers/net/ethernet/qualcomm/qca_spi.c +2 −2
  24. drivers/net/ethernet/realtek/r8169.c +2 −2
  25. drivers/net/ethernet/smsc/smc91x.c +12 −8
  26. drivers/net/ethernet/smsc/smsc911x.c +6 −6
  27. drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 −0
  28. drivers/net/ethernet/xilinx/ll_temac_main.c +2 −2
  29. drivers/net/hyperv/netvsc.c +2 −7
  30. drivers/net/ieee802154/at86rf230.c +206 −184
  31. drivers/net/macvlan.c +15 −0
  32. drivers/net/phy/Kconfig +1 −0
  33. drivers/net/phy/mdio-gpio.c +4 −1
  34. drivers/net/phy/micrel.c +2 −1
  35. drivers/net/ppp/pppoe.c +4 −0
  36. drivers/net/usb/r8152.c +1 −0
  37. drivers/net/usb/usbnet.c +2 −2
  38. drivers/net/wireless/ath/ath9k/xmit.c +25 −27
  39. drivers/net/wireless/iwlwifi/iwl-fw-file.h +2 −0
  40. drivers/net/wireless/iwlwifi/iwl-trans.h +27 −14
  41. drivers/net/wireless/iwlwifi/mvm/d3.c +1 −1
  42. drivers/net/wireless/iwlwifi/mvm/fw-api-power.h +34 −0
  43. drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h +2 −42
  44. drivers/net/wireless/iwlwifi/mvm/fw-api.h +0 −13
  45. drivers/net/wireless/iwlwifi/mvm/fw.c +21 −33
  46. drivers/net/wireless/iwlwifi/mvm/mac80211.c +23 −3
  47. drivers/net/wireless/iwlwifi/mvm/mvm.h +0 −1
  48. drivers/net/wireless/iwlwifi/mvm/ops.c +10 −0
  49. drivers/net/wireless/iwlwifi/mvm/rx.c +5 −0
  50. drivers/net/wireless/iwlwifi/mvm/scan.c +1 −1
  51. drivers/net/wireless/iwlwifi/pcie/trans.c +9 −8
  52. drivers/net/wireless/rtlwifi/usb.c +1 −1
  53. include/linux/netdevice.h +0 −3
  54. include/linux/tcp.h +8 −0
  55. include/net/cfg802154.h +2 −0
  56. include/net/codel.h +7 −3
  57. include/net/mac80211.h +2 −0
  58. include/net/mac802154.h +92 −2
  59. include/net/tcp.h +5 −2
  60. include/uapi/linux/inet_diag.h +4 −0
  61. include/uapi/linux/mpls.h +10 −0
  62. include/uapi/linux/tcp.h +3 −0
  63. net/bluetooth/hci_core.c +2 −1
  64. net/core/dev.c +1 −1
  65. net/core/net_namespace.c +1 −1
  66. net/core/sock.c +1 −1
  67. net/ieee802154/Makefile +3 −1
  68. net/ieee802154/nl-phy.c +4 −1
  69. net/ieee802154/nl802154.c +1 −1
  70. net/ieee802154/rdev-ops.h +72 −13
  71. net/ieee802154/trace.c +7 −0
  72. net/ieee802154/trace.h +247 −0
  73. net/ipv4/inet_diag.c +5 −3
  74. net/ipv4/tcp.c +27 −1
  75. net/ipv4/tcp_dctcp.c +10 −10
  76. net/ipv4/tcp_fastopen.c +1 −0
  77. net/ipv4/tcp_illinois.c +11 −10
  78. net/ipv4/tcp_input.c +26 −10
  79. net/ipv4/tcp_vegas.c +10 −9
  80. net/ipv4/tcp_vegas.h +2 −1
  81. net/ipv4/tcp_westwood.c +8 −7
  82. net/ipv6/ip6_output.c +31 −8
  83. net/ipv6/route.c +3 −2
  84. net/mac80211/iface.c +7 −5
  85. net/mac80211/sta_info.c +18 −1
  86. net/mac802154/cfg.c +6 −3
  87. net/mac802154/ieee802154_i.h +2 −1
  88. net/mac802154/iface.c +3 −2
  89. net/mac802154/llsec.c +2 −2
  90. net/mac802154/main.c +5 −2
  91. net/mpls/af_mpls.c +9 −9
  92. net/mpls/internal.h +0 −10
  93. net/netlink/af_netlink.c +0 −1
  94. net/packet/af_packet.c +6 −3
  95. net/rds/connection.c +15 −2
  96. net/rds/ib_cm.c +11 −2
  97. net/rds/tcp_connect.c +1 −0
  98. net/rds/tcp_listen.c +46 −0
  99. net/sched/cls_api.c +3 −4
  100. net/sched/sch_codel.c +1 −1
  101. net/sched/sch_fq_codel.c +1 −1
  102. net/sched/sch_gred.c +2 −2
MAINTAINERS+7−7
@@ -4377,11 +4377,10 @@ F: fs/gfs2/ · 4376 unmodified lines
43774377 F: include/uapi/linux/gfs2_ondisk.h
43784378
43794379 GIGASET ISDN DRIVERS
4380−M: Hansjoerg Lipp <hjlipp@web.de>
4381−M: Tilman Schmidt <tilman@imap.cc>
4380+M: Paul Bolle <pebolle@tiscali.nl>
43824381 L: gigaset307x-common@lists.sourceforge.net
43834382 W: http://gigaset307x.sourceforge.net/
4384−S: Maintained
4383+S: Odd Fixes
43854384 F: Documentation/isdn/README.gigaset
43864385 F: drivers/isdn/gigaset/
43874386 F: include/uapi/linux/gigaset_dev.h
@@ -8827,10 +8826,11 @@ W: http://www.emulex.com · 4439 unmodified lines
88278826 S: Supported
88288827 F: drivers/scsi/be2iscsi/
88298828
8830−SERVER ENGINES 10Gbps NIC - BladeEngine 2 DRIVER
8831−M: Sathya Perla <sathya.perla@emulex.com>
8832−M: Subbu Seetharaman <subbu.seetharaman@emulex.com>
8833−M: Ajit Khaparde <ajit.khaparde@emulex.com>
8829+Emulex 10Gbps NIC BE2, BE3-R, Lancer, Skyhawk-R DRIVER
8830+M: Sathya Perla <sathya.perla@avagotech.com>
8831+M: Ajit Khaparde <ajit.khaparde@avagotech.com>
8832+M: Padmanabh Ratnakar <padmanabh.ratnakar@avagotech.com>
8833+M: Sriharsha Basavapatna <sriharsha.basavapatna@avagotech.com>
88348834 L: netdev@vger.kernel.org
88358835 W: http://www.emulex.com
88368836 S: Supported
arch/arm/net/bpf_jit_32.c+39−3
@@ -54,6 +54,7 @@ · 53 unmodified lines
5454 #define SEEN_DATA (1 << (BPF_MEMWORDS + 3))
5555
5656 #define FLAG_NEED_X_RESET (1 << 0)
57+#define FLAG_IMM_OVERFLOW (1 << 1)
5758
5859 struct jit_ctx {
5960 const struct bpf_prog *skf;
@@ -293,6 +294,15 @@ static u16 imm_offset(u32 k, struct jit_ctx *ctx) · 233 unmodified lines
293294 /* PC in ARM mode == address of the instruction + 8 */
294295 imm = offset - (8 + ctx->idx * 4);
295296
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+
296306 return imm;
297307 }
298308
@@ -449,10 +459,21 @@ static inline void emit_udiv(u8 rd, u8 rm, u8 rn, struct jit_ctx *ctx) · 150 unmodified lines
449459 return;
450460 }
451461 #endif
452− if (rm != ARM_R0)
453− emit(ARM_MOV_R(ARM_R0, rm), ctx);
462+
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+ */
454473 if (rn != ARM_R1)
455474 emit(ARM_MOV_R(ARM_R1, rn), ctx);
475+ if (rm != ARM_R0)
476+ emit(ARM_MOV_R(ARM_R0, rm), ctx);
456477
457478 ctx->seen |= SEEN_CALL;
458479 emit_mov_i(ARM_R3, (u32)jit_udiv, ctx);
@@ -855,6 +876,14 @@ b_epilogue: · 396 unmodified lines
855876 default:
856877 return -1;
857878 }
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;
858887 }
859888
860889 /* compute offsets only during the first pass */
@@ -917,7 +946,14 @@ void bpf_jit_compile(struct bpf_prog *fp) · 56 unmodified lines
917946 ctx.idx = 0;
918947
919948 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+ }
921957 build_epilogue(&ctx);
922958
923959 flush_icache_range((u32)ctx.target, (u32)(ctx.target + ctx.idx));
arch/x86/net/bpf_jit_comp.c+28−0
@@ -559,6 +559,13 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image, · 558 unmodified lines
559559 if (is_ereg(dst_reg))
560560 EMIT1(0x41);
561561 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));
562569 break;
563570 case 32:
564571 /* 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, · 12 unmodified lines
577584 break;
578585
579586 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+ }
580608 break;
581609
582610 /* ST: *(u8*)(dst_reg + off) = imm */
drivers/bluetooth/bt3c_cs.c+0−3
@@ -227,7 +227,6 @@ static void bt3c_receive(struct bt3c_info *info) · 226 unmodified lines
227227 iobase = info->p_dev->resource[0]->start;
228228
229229 avail = bt3c_read(iobase, 0x7006);
230− //printk("bt3c_cs: receiving %d bytes\n", avail);
231230
232231 bt3c_address(iobase, 0x7480);
233232 while (size < avail) {
@@ -250,7 +249,6 @@ static void bt3c_receive(struct bt3c_info *info) · 16 unmodified lines
250249
251250 bt_cb(info->rx_skb)->pkt_type = inb(iobase + DATA_L);
252251 inb(iobase + DATA_H);
253− //printk("bt3c: PACKET_TYPE=%02x\n", bt_cb(info->rx_skb)->pkt_type);
254252
255253 switch (bt_cb(info->rx_skb)->pkt_type) {
256254
@@ -364,7 +362,6 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst) · 107 unmodified lines
364362 if (stat & 0x0001)
365363 bt3c_receive(info);
366364 if (stat & 0x0002) {
367− //BT_ERR("Ack (stat=0x%04x)", stat);
368365 clear_bit(XMIT_SENDING, &(info->tx_state));
369366 bt3c_write_wakeup(info);
370367 }
drivers/bluetooth/btbcm.c+79−69
@@ -95,6 +95,78 @@ int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) · 94 unmodified lines
9595 }
9696 EXPORT_SYMBOL_GPL(btbcm_set_bdaddr);
9797
98+int 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+
164+done:
165+ release_firmware(fw);
166+ return err;
167+}
168+EXPORT_SYMBOL(btbcm_patchram);
169+
98170 static int btbcm_reset(struct hci_dev *hdev)
99171 {
100172 struct sk_buff *skb;
@@ -198,12 +270,8 @@ static const struct { · 97 unmodified lines
198270
199271 int btbcm_setup_patchram(struct hci_dev *hdev)
200272 {
201− const struct hci_command_hdr *cmd;
202− const struct firmware *fw;
203− const u8 *fw_ptr;
204− size_t fw_size;
205273 char fw_name[64];
206− u16 opcode, subver, rev, pid, vid;
274+ u16 subver, rev, pid, vid;
207275 const char *hw_name = NULL;
208276 struct sk_buff *skb;
209277 struct hci_rp_read_local_version *ver;
@@ -273,74 +341,19 @@ int btbcm_setup_patchram(struct hci_dev *hdev) · 63 unmodified lines
273341 hw_name ? : "BCM", (subver & 0x7000) >> 13,
274342 (subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff);
275343
276− err = request_firmware(&fw, fw_name, &hdev->dev);
277− if (err < 0) {
278− BT_INFO("%s: BCM: patch %s not found", hdev->name, fw_name);
344+ err = btbcm_patchram(hdev, fw_name);
345+ if (err == -ENOENT)
279346 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− }
311347
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−
332−reset:
333348 /* Reset */
334349 err = btbcm_reset(hdev);
335350 if (err)
336− goto done;
351+ return err;
337352
338353 /* Read Local Version Info */
339354 skb = btbcm_read_local_version(hdev);
340− if (IS_ERR(skb)) {
341− err = PTR_ERR(skb);
342− goto done;
343− }
355+ if (IS_ERR(skb))
356+ return PTR_ERR(skb);
344357
345358 ver = (struct hci_rp_read_local_version *)skb->data;
346359 rev = le16_to_cpu(ver->hci_rev);
@@ -355,10 +368,7 @@ reset: · 8 unmodified lines
355368
356369 set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
357370
358−done:
359− release_firmware(fw);
360−
361− return err;
371+ return 0;
362372 }
363373 EXPORT_SYMBOL_GPL(btbcm_setup_patchram);
364374
drivers/bluetooth/btbcm.h+6−0
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525
2626 int btbcm_check_bdaddr(struct hci_dev *hdev);
2727 int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
28+int btbcm_patchram(struct hci_dev *hdev, const char *firmware);
2829
2930 int btbcm_setup_patchram(struct hci_dev *hdev);
3031 int 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) · 10 unmodified lines
4142 return -EOPNOTSUPP;
4243 }
4344
45+static inline int btbcm_patchram(struct hci_dev *hdev, const char *firmware)
46+{
47+ return -EOPNOTSUPP;
48+}
49+
4450 static inline int btbcm_setup_patchram(struct hci_dev *hdev)
4551 {
4652 return 0;
drivers/bluetooth/btusb.c+401−2
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #include <linux/module.h>
2525 #include <linux/usb.h>
2626 #include <linux/firmware.h>
27+#include <asm/unaligned.h>
2728
2829 #include <net/bluetooth/bluetooth.h>
2930 #include <net/bluetooth/hci_core.h>
@@ -57,6 +58,7 @@ static struct usb_driver btusb_driver; · 27 unmodified lines
5758 #define BTUSB_AMP 0x4000
5859 #define BTUSB_QCA_ROME 0x8000
5960 #define BTUSB_BCM_APPLE 0x10000
61+#define BTUSB_REALTEK 0x20000
6062
6163 static const struct usb_device_id btusb_table[] = {
6264 /* Generic Bluetooth USB device */
@@ -288,6 +290,28 @@ static const struct usb_device_id blacklist_table[] = { · 225 unmodified lines
288290 { USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01),
289291 .driver_info = BTUSB_IGNORE },
290292
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+
291315 { } /* Terminating entry */
292316 };
293317
@@ -892,7 +916,7 @@ static int btusb_open(struct hci_dev *hdev) · 598 unmodified lines
892916 */
893917 if (data->setup_on_usb) {
894918 err = data->setup_on_usb(hdev);
895− if (err <0)
919+ if (err < 0)
896920 return err;
897921 }
898922
@@ -1345,6 +1369,378 @@ static int btusb_setup_csr(struct hci_dev *hdev) · 446 unmodified lines
13451369 return ret;
13461370 }
13471371
1372+#define RTL_FRAG_LEN 252
1373+
1374+struct rtl_download_cmd {
1375+ __u8 index;
1376+ __u8 data[RTL_FRAG_LEN];
1377+} __packed;
1378+
1379+struct rtl_download_response {
1380+ __u8 status;
1381+ __u8 index;
1382+} __packed;
1383+
1384+struct rtl_rom_version_evt {
1385+ __u8 status;
1386+ __u8 version;
1387+} __packed;
1388+
1389+struct 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+
1402+static 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+
1434+static 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+
1576+static 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+
1631+out:
1632+ kfree(dl_cmd);
1633+ return ret;
1634+}
1635+
1636+static 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+
1666+out:
1667+ release_firmware(fw);
1668+ return ret;
1669+}
1670+
1671+static 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+
1696+out:
1697+ release_firmware(fw);
1698+ return ret;
1699+}
1700+
1701+static 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+
13481744 static const struct firmware *btusb_setup_intel_get_fw(struct hci_dev *hdev,
13491745 struct intel_version *ver)
13501746 {
@@ -2577,7 +2973,7 @@ static int btusb_setup_qca(struct hci_dev *hdev) · 1226 unmodified lines
25772973 int i, err;
25782974
25792975 err = btusb_qca_send_vendor_req(hdev, QCA_GET_TARGET_VERSION, &ver,
2580− sizeof(ver));
2976+ sizeof(ver));
25812977 if (err < 0)
25822978 return err;
25832979
@@ -2776,6 +3172,9 @@ static int btusb_probe(struct usb_interface *intf, · 192 unmodified lines
27763172 hdev->set_bdaddr = btusb_set_bdaddr_ath3012;
27773173 }
27783174
3175+ if (id->driver_info & BTUSB_REALTEK)
3176+ hdev->setup = btusb_setup_realtek;
3177+
27793178 if (id->driver_info & BTUSB_AMP) {
27803179 /* AMP controllers do not support SCO packets */
27813180 data->isoc = NULL;
drivers/bluetooth/hci_ath.c+63−35
@@ -95,7 +95,6 @@ static void ath_hci_uart_work(struct work_struct *work) · 94 unmodified lines
9595 hci_uart_tx_wakeup(hu);
9696 }
9797
98−/* Initialize protocol */
9998 static int ath_open(struct hci_uart *hu)
10099 {
101100 struct ath_struct *ath;
@@ -116,8 +115,7 @@ static int ath_open(struct hci_uart *hu) · 14 unmodified lines
116115 return 0;
117116 }
118117
119−/* Flush protocol data */
120−static int ath_flush(struct hci_uart *hu)
118+static int ath_close(struct hci_uart *hu)
121119 {
122120 struct ath_struct *ath = hu->priv;
123121
@@ -125,11 +123,17 @@ static int ath_flush(struct hci_uart *hu) · 1 unmodified line
125123
126124 skb_queue_purge(&ath->txq);
127125
126+ kfree_skb(ath->rx_skb);
127+
128+ cancel_work_sync(&ath->ctxtsw);
129+
130+ hu->priv = NULL;
131+ kfree(ath);
132+
128133 return 0;
129134 }
130135
131−/* Close protocol */
132−static int ath_close(struct hci_uart *hu)
136+static int ath_flush(struct hci_uart *hu)
133137 {
134138 struct ath_struct *ath = hu->priv;
135139
@@ -137,19 +141,65 @@ static int ath_close(struct hci_uart *hu) · 1 unmodified line
137141
138142 skb_queue_purge(&ath->txq);
139143
140− kfree_skb(ath->rx_skb);
144+ return 0;
145+}
141146
142− cancel_work_sync(&ath->ctxtsw);
147+static 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);
143167
144− hu->priv = NULL;
145− kfree(ath);
168+ return 0;
169+}
170+
171+static int ath_setup(struct hci_uart *hu)
172+{
173+ BT_DBG("hu %p", hu);
174+
175+ hu->hdev->set_bdaddr = ath_set_bdaddr;
146176
147177 return 0;
148178 }
149179
180+static 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+
186+static 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+
150201 #define HCI_OP_ATH_SLEEP 0xFC04
151202
152−/* Enqueue frame for transmittion */
153203 static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb)
154204 {
155205 struct ath_struct *ath = hu->priv;
@@ -159,8 +209,7 @@ static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb) · 3 unmodified lines
159209 return 0;
160210 }
161211
162− /*
163− * Update power management enable flag with parameters of
212+ /* Update power management enable flag with parameters of
164213 * HCI sleep enable vendor specific HCI command.
165214 */
166215 if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) {
@@ -190,37 +239,16 @@ static struct sk_buff *ath_dequeue(struct hci_uart *hu) · 23 unmodified lines
190239 return skb_dequeue(&ath->txq);
191240 }
192241
193−static 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 */
200−static 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−
215242 static const struct hci_uart_proto athp = {
216243 .id = HCI_UART_ATH3K,
217244 .name = "ATH3K",
218245 .open = ath_open,
219246 .close = ath_close,
247+ .flush = ath_flush,
248+ .setup = ath_setup,
220249 .recv = ath_recv,
221250 .enqueue = ath_enqueue,
222251 .dequeue = ath_dequeue,
223− .flush = ath_flush,
224252 };
225253
226254 int __init ath_init(void)
drivers/net/can/xilinx_can.c+4−3
@@ -509,10 +509,11 @@ static int xcan_rx(struct net_device *ndev) · 508 unmodified lines
509509 cf->can_id |= CAN_RTR_FLAG;
510510 }
511511
512− if (!(id_xcan & XCAN_IDR_SRR_MASK)) {
513− data[0] = priv->read_reg(priv, XCAN_RXFIFO_DW1_OFFSET);
514− data[1] = priv->read_reg(priv, XCAN_RXFIFO_DW2_OFFSET);
512+ /* DW1/DW2 must always be read to remove message from RXFIFO */
513+ data[0] = priv->read_reg(priv, XCAN_RXFIFO_DW1_OFFSET);
514+ data[1] = priv->read_reg(priv, XCAN_RXFIFO_DW2_OFFSET);
515515
516+ if (!(cf->can_id & CAN_RTR_FLAG)) {
516517 /* Change Xilinx CAN data format to socketCAN data format */
517518 if (cf->can_dlc > 0)
518519 *(__be32 *)(cf->data) = cpu_to_be32(data[0]);
drivers/net/dsa/mv88e6xxx.c+3−0
@@ -1469,6 +1469,9 @@ static void __exit mv88e6xxx_cleanup(void) · 1468 unmodified lines
14691469 #if IS_ENABLED(CONFIG_NET_DSA_MV88E6171)
14701470 unregister_switch_driver(&mv88e6171_switch_driver);
14711471 #endif
1472+#if IS_ENABLED(CONFIG_NET_DSA_MV88E6352)
1473+ unregister_switch_driver(&mv88e6352_switch_driver);
1474+#endif
14721475 #if IS_ENABLED(CONFIG_NET_DSA_MV88E6123_61_65)
14731476 unregister_switch_driver(&mv88e6123_61_65_switch_driver);
14741477 #endif
drivers/net/ethernet/amd/Kconfig+1−0
@@ -180,6 +180,7 @@ config SUNLANCE · 179 unmodified lines
180180 config AMD_XGBE
181181 tristate "AMD 10GbE Ethernet driver"
182182 depends on (OF_NET || ACPI) && HAS_IOMEM && HAS_DMA
183+ depends on ARM64 || COMPILE_TEST
183184 select PHYLIB
184185 select AMD_XGBE_PHY
185186 select BITREVERSE
drivers/net/ethernet/apm/xgene/Kconfig+1−0
@@ -1,6 +1,7 @@
11 config NET_XGENE
22 tristate "APM X-Gene SoC Ethernet Driver"
33 depends on HAS_DMA
4+ depends on ARCH_XGENE || COMPILE_TEST
45 select PHYLIB
56 help
67 This is the Ethernet driver for the on-chip ethernet interface on the
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c+5−5
@@ -4786,6 +4786,11 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu) · 4785 unmodified lines
47864786 {
47874787 struct bnx2x *bp = netdev_priv(dev);
47884788
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+
47894794 if (bp->recovery_state != BNX2X_RECOVERY_DONE) {
47904795 BNX2X_ERR("Can't perform change MTU during parity recovery\n");
47914796 return -EAGAIN;
@@ -4938,11 +4943,6 @@ int bnx2x_resume(struct pci_dev *pdev) · 146 unmodified lines
49384943 }
49394944 bp = netdev_priv(dev);
49404945
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−
49464946 if (bp->recovery_state != BNX2X_RECOVERY_DONE) {
49474947 BNX2X_ERR("Handling parity error recovery. Try again later\n");
49484948 return -EAGAIN;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c+7−2
@@ -13371,8 +13371,13 @@ static int bnx2x_init_one(struct pci_dev *pdev, · 13370 unmodified lines
1337113371 /* Management FW 'remembers' living interfaces. Allow it some time
1337213372 * to forget previously living interfaces, allowing a proper re-load.
1337313373 */
13374− if (is_kdump_kernel())
13375− msleep(5000);
13374+ if (is_kdump_kernel()) {
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+ }
1337613381
1337713382 /* An estimated maximum supported CoS number according to the chip
1337813383 * version.
drivers/net/ethernet/cadence/macb.c+10−1
@@ -981,7 +981,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) · 980 unmodified lines
981981 struct macb_queue *queue = dev_id;
982982 struct macb *bp = queue->bp;
983983 struct net_device *dev = bp->dev;
984− u32 status;
984+ u32 status, ctrl;
985985
986986 status = queue_readl(queue, ISR);
987987
@@ -1037,6 +1037,15 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) · 49 unmodified lines
10371037 * add that if/when we get our hands on a full-blown MII PHY.
10381038 */
10391039
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+
10401049 if (status & MACB_BIT(ISR_ROVR)) {
10411050 /* We missed at least one packet */
10421051 if (macb_is_gem(bp))
drivers/net/ethernet/intel/e1000e/e1000.h+1−0
@@ -40,6 +40,7 @@ · 39 unmodified lines
4040 #include <linux/ptp_classify.h>
4141 #include <linux/mii.h>
4242 #include <linux/mdio.h>
43+#include <linux/pm_qos.h>
4344 #include "hw.h"
4445
4546 struct e1000_info;
drivers/net/ethernet/intel/fm10k/fm10k_main.c+2−2
@@ -610,7 +610,7 @@ static bool fm10k_clean_rx_irq(struct fm10k_q_vector *q_vector, · 609 unmodified lines
610610 unsigned int total_bytes = 0, total_packets = 0;
611611 u16 cleaned_count = fm10k_desc_unused(rx_ring);
612612
613− do {
613+ while (likely(total_packets < budget)) {
614614 union fm10k_rx_desc *rx_desc;
615615
616616 /* 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, · 42 unmodified lines
659659
660660 /* update budget accounting */
661661 total_packets++;
662− } while (likely(total_packets < budget));
662+ }
663663
664664 /* place incomplete frames back on ring for completion */
665665 rx_ring->skb = skb;
drivers/net/ethernet/intel/igb/igb_main.c+3−1
@@ -1036,7 +1036,7 @@ static void igb_reset_q_vector(struct igb_adapter *adapter, int v_idx) · 1035 unmodified lines
10361036 adapter->tx_ring[q_vector->tx.ring->queue_index] = NULL;
10371037
10381038 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;
10401040
10411041 netif_napi_del(&q_vector->napi);
10421042
@@ -1207,6 +1207,8 @@ static int igb_alloc_q_vector(struct igb_adapter *adapter, · 164 unmodified lines
12071207 q_vector = adapter->q_vector[v_idx];
12081208 if (!q_vector)
12091209 q_vector = kzalloc(size, GFP_KERNEL);
1210+ else
1211+ memset(q_vector, 0, size);
12101212 if (!q_vector)
12111213 return -ENOMEM;
12121214
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c+1−1
@@ -3612,7 +3612,7 @@ static int ixgbevf_xmit_frame(struct sk_buff *skb, struct net_device *netdev) · 3611 unmodified lines
36123612 u8 *dst_mac = skb_header_pointer(skb, 0, 0, NULL);
36133613
36143614 if (!dst_mac || is_link_local_ether_addr(dst_mac)) {
3615− dev_kfree_skb(skb);
3615+ dev_kfree_skb_any(skb);
36163616 return NETDEV_TX_OK;
36173617 }
36183618
drivers/net/ethernet/mellanox/mlx4/en_port.c+1−1
@@ -139,7 +139,7 @@ static unsigned long en_stats_adder(__be64 *start, __be64 *next, int num) · 138 unmodified lines
139139 int i;
140140 int offset = next - start;
141141
142− for (i = 0; i <= num; i++) {
142+ for (i = 0; i < num; i++) {
143143 ret += be64_to_cpu(*curr);
144144 curr += offset;
145145 }
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c+7−7
@@ -2845,7 +2845,7 @@ int mlx4_SW2HW_EQ_wrapper(struct mlx4_dev *dev, int slave, · 2844 unmodified lines
28452845 {
28462846 int err;
28472847 int eqn = vhcr->in_modifier;
2848− int res_id = (slave << 8) | eqn;
2848+ int res_id = (slave << 10) | eqn;
28492849 struct mlx4_eq_context *eqc = inbox->buf;
28502850 int mtt_base = eq_get_mtt_addr(eqc) / dev->caps.mtt_entry_sz;
28512851 int mtt_size = eq_get_mtt_size(eqc);
@@ -3051,7 +3051,7 @@ int mlx4_HW2SW_EQ_wrapper(struct mlx4_dev *dev, int slave, · 199 unmodified lines
30513051 struct mlx4_cmd_info *cmd)
30523052 {
30533053 int eqn = vhcr->in_modifier;
3054− int res_id = eqn | (slave << 8);
3054+ int res_id = eqn | (slave << 10);
30553055 struct res_eq *eq;
30563056 int err;
30573057
@@ -3108,7 +3108,7 @@ int mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe) · 50 unmodified lines
31083108 return 0;
31093109
31103110 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;
31123112 err = get_res(dev, slave, res_id, RES_EQ, &req);
31133113 if (err)
31143114 goto unlock;
@@ -3131,7 +3131,7 @@ int mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe) · 16 unmodified lines
31313131
31323132 memcpy(mailbox->buf, (u8 *) eqe, 28);
31333133
3134− in_modifier = (slave & 0xff) | ((event_eq->eqn & 0xff) << 16);
3134+ in_modifier = (slave & 0xff) | ((event_eq->eqn & 0x3ff) << 16);
31353135
31363136 err = mlx4_cmd(dev, mailbox->dma, in_modifier, 0,
31373137 MLX4_CMD_GEN_EQE, MLX4_CMD_TIME_CLASS_B,
@@ -3157,7 +3157,7 @@ int mlx4_QUERY_EQ_wrapper(struct mlx4_dev *dev, int slave, · 19 unmodified lines
31573157 struct mlx4_cmd_info *cmd)
31583158 {
31593159 int eqn = vhcr->in_modifier;
3160− int res_id = eqn | (slave << 8);
3160+ int res_id = eqn | (slave << 10);
31613161 struct res_eq *eq;
31623162 int err;
31633163
@@ -4714,13 +4714,13 @@ static void rem_slave_eqs(struct mlx4_dev *dev, int slave) · 1550 unmodified lines
47144714 break;
47154715
47164716 case RES_EQ_HW:
4717− err = mlx4_cmd(dev, slave, eqn & 0xff,
4717+ err = mlx4_cmd(dev, slave, eqn & 0x3ff,
47184718 1, MLX4_CMD_HW2SW_EQ,
47194719 MLX4_CMD_TIME_CLASS_A,
47204720 MLX4_CMD_NATIVE);
47214721 if (err)
47224722 mlx4_dbg(dev, "rem_slave_eqs: failed to move slave %d eqs %d to SW ownership\n",
4723− slave, eqn);
4723+ slave, eqn & 0x3ff);
47244724 atomic_dec(&eq->mtt->ref_count);
47254725 state = RES_EQ_RESERVED;
47264726 break;
drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c+2−2
@@ -1764,7 +1764,7 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter) · 1763 unmodified lines
17641764 int done = 0;
17651765 struct nx_host_tx_ring *tx_ring = adapter->tx_ring;
17661766
1767− if (!spin_trylock(&adapter->tx_clean_lock))
1767+ if (!spin_trylock_bh(&adapter->tx_clean_lock))
17681768 return 1;
17691769
17701770 sw_consumer = tx_ring->sw_consumer;
@@ -1819,7 +1819,7 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter) · 48 unmodified lines
18191819 */
18201820 hw_consumer = le32_to_cpu(*(tx_ring->hw_consumer));
18211821 done = (sw_consumer == hw_consumer);
1822− spin_unlock(&adapter->tx_clean_lock);
1822+ spin_unlock_bh(&adapter->tx_clean_lock);
18231823
18241824 return done;
18251825 }
drivers/net/ethernet/qualcomm/qca_spi.c+2−2
@@ -912,6 +912,8 @@ qca_spi_probe(struct spi_device *spi_device) · 911 unmodified lines
912912 qca->spi_dev = spi_device;
913913 qca->legacy_mode = legacy_mode;
914914
915+ spi_set_drvdata(spi_device, qcaspi_devs);
916+
915917 mac = of_get_mac_address(spi_device->dev.of_node);
916918
917919 if (mac)
@@ -944,8 +946,6 @@ qca_spi_probe(struct spi_device *spi_device) · 26 unmodified lines
944946 return -EFAULT;
945947 }
946948
947− spi_set_drvdata(spi_device, qcaspi_devs);
948−
949949 qcaspi_init_device_debugfs(qca);
950950
951951 return 0;
drivers/net/ethernet/realtek/r8169.c+2−2
@@ -6884,7 +6884,7 @@ static void r8169_csum_workaround(struct rtl8169_private *tp, · 6883 unmodified lines
68846884 rtl8169_start_xmit(nskb, tp->dev);
68856885 } while (segs);
68866886
6887− dev_kfree_skb(skb);
6887+ dev_consume_skb_any(skb);
68886888 } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
68896889 if (skb_checksum_help(skb) < 0)
68906890 goto drop;
@@ -6896,7 +6896,7 @@ static void r8169_csum_workaround(struct rtl8169_private *tp, · 5 unmodified lines
68966896 drop:
68976897 stats = &tp->dev->stats;
68986898 stats->tx_dropped++;
6899− dev_kfree_skb(skb);
6899+ dev_kfree_skb_any(skb);
69006900 }
69016901 }
69026902
drivers/net/ethernet/smsc/smc91x.c+12−8
@@ -2238,9 +2238,10 @@ static int smc_drv_probe(struct platform_device *pdev) · 2237 unmodified lines
22382238 const struct of_device_id *match = NULL;
22392239 struct smc_local *lp;
22402240 struct net_device *ndev;
2241− struct resource *res, *ires;
2241+ struct resource *res;
22422242 unsigned int __iomem *addr;
22432243 unsigned long irq_flags = SMC_IRQ_FLAGS;
2244+ unsigned long irq_resflags;
22442245 int ret;
22452246
22462247 ndev = alloc_etherdev(sizeof(struct smc_local));
@@ -2332,16 +2333,19 @@ static int smc_drv_probe(struct platform_device *pdev) · 85 unmodified lines
23322333 goto out_free_netdev;
23332334 }
23342335
2335− ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
2336− if (!ires) {
2336+ ndev->irq = platform_get_irq(pdev, 0);
2337+ if (ndev->irq <= 0) {
23372338 ret = -ENODEV;
23382339 goto out_release_io;
23392340 }
2340−
2341− ndev->irq = ires->start;
2342−
2343− if (irq_flags == -1 || ires->flags & IRQF_TRIGGER_MASK)
2344− irq_flags = ires->flags & IRQF_TRIGGER_MASK;
2341+ /*
2342+ * If this platform does not specify any special irqflags, or if
2343+ * the resource supplies a trigger, override the irqflags with
2344+ * the trigger flags from the resource.
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;
23452349
23462350 ret = smc_request_attrib(pdev, ndev);
23472351 if (ret)
drivers/net/ethernet/smsc/smsc911x.c+6−6
@@ -2418,9 +2418,9 @@ static int smsc911x_drv_probe(struct platform_device *pdev) · 2417 unmodified lines
24182418 struct net_device *dev;
24192419 struct smsc911x_data *pdata;
24202420 struct smsc911x_platform_config *config = dev_get_platdata(&pdev->dev);
2421− struct resource *res, *irq_res;
2421+ struct resource *res;
24222422 unsigned int intcfg = 0;
2423− int res_size, irq_flags;
2423+ int res_size, irq, irq_flags;
24242424 int retval;
24252425
24262426 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
@@ -2434,8 +2434,8 @@ static int smsc911x_drv_probe(struct platform_device *pdev) · 7 unmodified lines
24342434 }
24352435 res_size = resource_size(res);
24362436
2437− irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
2438− if (!irq_res) {
2437+ irq = platform_get_irq(pdev, 0);
2438+ if (irq <= 0) {
24392439 pr_warn("Could not allocate irq resource\n");
24402440 retval = -ENODEV;
24412441 goto out_0;
@@ -2455,8 +2455,8 @@ static int smsc911x_drv_probe(struct platform_device *pdev) · 13 unmodified lines
24552455 SET_NETDEV_DEV(dev, &pdev->dev);
24562456
24572457 pdata = netdev_priv(dev);
2458− dev->irq = irq_res->start;
2459− irq_flags = irq_res->flags & IRQF_TRIGGER_MASK;
2458+ dev->irq = irq;
2459+ irq_flags = irq_get_trigger_type(irq);
24602460 pdata->ioaddr = ioremap_nocache(res->start, res_size);
24612461
24622462 pdata->dev = dev;
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c+1−0
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 *******************************************************************************/
2424
2525 #include <linux/platform_device.h>
26+#include <linux/module.h>
2627 #include <linux/io.h>
2728 #include <linux/of.h>
2829 #include <linux/of_net.h>
drivers/net/ethernet/xilinx/ll_temac_main.c+2−2
@@ -707,8 +707,8 @@ static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) · 706 unmodified lines
707707
708708 cur_p->app0 |= STS_CTRL_APP0_SOP;
709709 cur_p->len = skb_headlen(skb);
710− cur_p->phys = dma_map_single(ndev->dev.parent, skb->data, skb->len,
711− DMA_TO_DEVICE);
710+ cur_p->phys = dma_map_single(ndev->dev.parent, skb->data,
711+ skb_headlen(skb), DMA_TO_DEVICE);
712712 cur_p->app4 = (unsigned long)skb;
713713
714714 for (ii = 0; ii < num_frag; ii++) {
drivers/net/hyperv/netvsc.c+2−7
@@ -826,7 +826,6 @@ int netvsc_send(struct hv_device *device, · 825 unmodified lines
826826 u16 q_idx = packet->q_idx;
827827 u32 pktlen = packet->total_data_buflen, msd_len = 0;
828828 unsigned int section_index = NETVSC_INVALID_INDEX;
829− struct sk_buff *skb = NULL;
830829 unsigned long flag;
831830 struct multi_send_data *msdp;
832831 struct hv_netvsc_packet *msd_send = NULL, *cur_send = NULL;
@@ -924,12 +923,8 @@ int netvsc_send(struct hv_device *device, · 91 unmodified lines
924923 if (cur_send)
925924 ret = netvsc_send_pkt(cur_send, net_device);
926925
927− if (ret != 0) {
928− if (section_index != NETVSC_INVALID_INDEX)
929− netvsc_free_send_slot(net_device, section_index);
930− } else if (skb) {
931− dev_kfree_skb_any(skb);
932− }
926+ if (ret != 0 && section_index != NETVSC_INVALID_INDEX)
927+ netvsc_free_send_slot(net_device, section_index);
933928
934929 return ret;
935930 }
drivers/net/ieee802154/at86rf230.c+206−184
@@ -85,6 +85,7 @@ struct at86rf230_local { · 84 unmodified lines
8585 struct ieee802154_hw *hw;
8686 struct at86rf2xx_chip_data *data;
8787 struct regmap *regmap;
88+ int slp_tr;
8889
8990 struct completion state_complete;
9091 struct at86rf230_state_change state;
@@ -95,163 +96,164 @@ struct at86rf230_local { · 4 unmodified lines
9596 unsigned long cal_timeout;
9697 s8 max_frame_retries;
9798 bool is_tx;
99+ bool is_tx_from_off;
98100 u8 tx_retry;
99101 struct sk_buff *tx_skb;
100102 struct at86rf230_state_change tx;
101103 };
102104
103−#define RG_TRX_STATUS (0x01)
104−#define SR_TRX_STATUS 0x01, 0x1f, 0
105−#define SR_RESERVED_01_3 0x01, 0x20, 5
106−#define SR_CCA_STATUS 0x01, 0x40, 6
107−#define SR_CCA_DONE 0x01, 0x80, 7
108−#define RG_TRX_STATE (0x02)
109−#define SR_TRX_CMD 0x02, 0x1f, 0
110−#define SR_TRAC_STATUS 0x02, 0xe0, 5
111−#define RG_TRX_CTRL_0 (0x03)
112−#define SR_CLKM_CTRL 0x03, 0x07, 0
113−#define SR_CLKM_SHA_SEL 0x03, 0x08, 3
114−#define SR_PAD_IO_CLKM 0x03, 0x30, 4
115−#define SR_PAD_IO 0x03, 0xc0, 6
116−#define RG_TRX_CTRL_1 (0x04)
117−#define SR_IRQ_POLARITY 0x04, 0x01, 0
118−#define SR_IRQ_MASK_MODE 0x04, 0x02, 1
119−#define SR_SPI_CMD_MODE 0x04, 0x0c, 2
120−#define SR_RX_BL_CTRL 0x04, 0x10, 4
121−#define SR_TX_AUTO_CRC_ON 0x04, 0x20, 5
122−#define SR_IRQ_2_EXT_EN 0x04, 0x40, 6
123−#define SR_PA_EXT_EN 0x04, 0x80, 7
124−#define RG_PHY_TX_PWR (0x05)
125−#define SR_TX_PWR 0x05, 0x0f, 0
126−#define SR_PA_LT 0x05, 0x30, 4
127−#define SR_PA_BUF_LT 0x05, 0xc0, 6
128−#define RG_PHY_RSSI (0x06)
129−#define SR_RSSI 0x06, 0x1f, 0
130−#define SR_RND_VALUE 0x06, 0x60, 5
131−#define SR_RX_CRC_VALID 0x06, 0x80, 7
132−#define RG_PHY_ED_LEVEL (0x07)
133−#define SR_ED_LEVEL 0x07, 0xff, 0
134−#define RG_PHY_CC_CCA (0x08)
135−#define SR_CHANNEL 0x08, 0x1f, 0
136−#define SR_CCA_MODE 0x08, 0x60, 5
137−#define SR_CCA_REQUEST 0x08, 0x80, 7
138−#define RG_CCA_THRES (0x09)
139−#define SR_CCA_ED_THRES 0x09, 0x0f, 0
140−#define SR_RESERVED_09_1 0x09, 0xf0, 4
141−#define RG_RX_CTRL (0x0a)
142−#define SR_PDT_THRES 0x0a, 0x0f, 0
143−#define SR_RESERVED_0a_1 0x0a, 0xf0, 4
144−#define RG_SFD_VALUE (0x0b)
145−#define SR_SFD_VALUE 0x0b, 0xff, 0
146−#define RG_TRX_CTRL_2 (0x0c)
147−#define SR_OQPSK_DATA_RATE 0x0c, 0x03, 0
148−#define SR_SUB_MODE 0x0c, 0x04, 2
149−#define SR_BPSK_QPSK 0x0c, 0x08, 3
150−#define SR_OQPSK_SUB1_RC_EN 0x0c, 0x10, 4
151−#define SR_RESERVED_0c_5 0x0c, 0x60, 5
152−#define SR_RX_SAFE_MODE 0x0c, 0x80, 7
153−#define RG_ANT_DIV (0x0d)
154−#define SR_ANT_CTRL 0x0d, 0x03, 0
155−#define SR_ANT_EXT_SW_EN 0x0d, 0x04, 2
156−#define SR_ANT_DIV_EN 0x0d, 0x08, 3
157−#define SR_RESERVED_0d_2 0x0d, 0x70, 4
158−#define SR_ANT_SEL 0x0d, 0x80, 7
159−#define RG_IRQ_MASK (0x0e)
160−#define SR_IRQ_MASK 0x0e, 0xff, 0
161−#define RG_IRQ_STATUS (0x0f)
162−#define SR_IRQ_0_PLL_LOCK 0x0f, 0x01, 0
163−#define SR_IRQ_1_PLL_UNLOCK 0x0f, 0x02, 1
164−#define SR_IRQ_2_RX_START 0x0f, 0x04, 2
165−#define SR_IRQ_3_TRX_END 0x0f, 0x08, 3
166−#define SR_IRQ_4_CCA_ED_DONE 0x0f, 0x10, 4
167−#define SR_IRQ_5_AMI 0x0f, 0x20, 5
168−#define SR_IRQ_6_TRX_UR 0x0f, 0x40, 6
169−#define SR_IRQ_7_BAT_LOW 0x0f, 0x80, 7
170−#define RG_VREG_CTRL (0x10)
171−#define SR_RESERVED_10_6 0x10, 0x03, 0
172−#define SR_DVDD_OK 0x10, 0x04, 2
173−#define SR_DVREG_EXT 0x10, 0x08, 3
174−#define SR_RESERVED_10_3 0x10, 0x30, 4
175−#define SR_AVDD_OK 0x10, 0x40, 6
176−#define SR_AVREG_EXT 0x10, 0x80, 7
177−#define RG_BATMON (0x11)
178−#define SR_BATMON_VTH 0x11, 0x0f, 0
179−#define SR_BATMON_HR 0x11, 0x10, 4
180−#define SR_BATMON_OK 0x11, 0x20, 5
181−#define SR_RESERVED_11_1 0x11, 0xc0, 6
182−#define RG_XOSC_CTRL (0x12)
183−#define SR_XTAL_TRIM 0x12, 0x0f, 0
184−#define SR_XTAL_MODE 0x12, 0xf0, 4
185−#define RG_RX_SYN (0x15)
186−#define SR_RX_PDT_LEVEL 0x15, 0x0f, 0
187−#define SR_RESERVED_15_2 0x15, 0x70, 4
188−#define SR_RX_PDT_DIS 0x15, 0x80, 7
189−#define RG_XAH_CTRL_1 (0x17)
190−#define SR_RESERVED_17_8 0x17, 0x01, 0
191−#define SR_AACK_PROM_MODE 0x17, 0x02, 1
192−#define SR_AACK_ACK_TIME 0x17, 0x04, 2
193−#define SR_RESERVED_17_5 0x17, 0x08, 3
194−#define SR_AACK_UPLD_RES_FT 0x17, 0x10, 4
195−#define SR_AACK_FLTR_RES_FT 0x17, 0x20, 5
196−#define SR_CSMA_LBT_MODE 0x17, 0x40, 6
197−#define SR_RESERVED_17_1 0x17, 0x80, 7
198−#define RG_FTN_CTRL (0x18)
199−#define SR_RESERVED_18_2 0x18, 0x7f, 0
200−#define SR_FTN_START 0x18, 0x80, 7
201−#define RG_PLL_CF (0x1a)
202−#define SR_RESERVED_1a_2 0x1a, 0x7f, 0
203−#define SR_PLL_CF_START 0x1a, 0x80, 7
204−#define RG_PLL_DCU (0x1b)
205−#define SR_RESERVED_1b_3 0x1b, 0x3f, 0
206−#define SR_RESERVED_1b_2 0x1b, 0x40, 6
207−#define SR_PLL_DCU_START 0x1b, 0x80, 7
208−#define RG_PART_NUM (0x1c)
209−#define SR_PART_NUM 0x1c, 0xff, 0
210−#define RG_VERSION_NUM (0x1d)
211−#define SR_VERSION_NUM 0x1d, 0xff, 0
212−#define RG_MAN_ID_0 (0x1e)
213−#define SR_MAN_ID_0 0x1e, 0xff, 0
214−#define RG_MAN_ID_1 (0x1f)
215−#define SR_MAN_ID_1 0x1f, 0xff, 0
216−#define RG_SHORT_ADDR_0 (0x20)
217−#define SR_SHORT_ADDR_0 0x20, 0xff, 0
218−#define RG_SHORT_ADDR_1 (0x21)
219−#define SR_SHORT_ADDR_1 0x21, 0xff, 0
220−#define RG_PAN_ID_0 (0x22)
221−#define SR_PAN_ID_0 0x22, 0xff, 0
222−#define RG_PAN_ID_1 (0x23)
223−#define SR_PAN_ID_1 0x23, 0xff, 0
224−#define RG_IEEE_ADDR_0 (0x24)
225−#define SR_IEEE_ADDR_0 0x24, 0xff, 0
226−#define RG_IEEE_ADDR_1 (0x25)
227−#define SR_IEEE_ADDR_1 0x25, 0xff, 0
228−#define RG_IEEE_ADDR_2 (0x26)
229−#define SR_IEEE_ADDR_2 0x26, 0xff, 0
230−#define RG_IEEE_ADDR_3 (0x27)
231−#define SR_IEEE_ADDR_3 0x27, 0xff, 0
232−#define RG_IEEE_ADDR_4 (0x28)
233−#define SR_IEEE_ADDR_4 0x28, 0xff, 0
234−#define RG_IEEE_ADDR_5 (0x29)
235−#define SR_IEEE_ADDR_5 0x29, 0xff, 0
236−#define RG_IEEE_ADDR_6 (0x2a)
237−#define SR_IEEE_ADDR_6 0x2a, 0xff, 0
238−#define RG_IEEE_ADDR_7 (0x2b)
239−#define SR_IEEE_ADDR_7 0x2b, 0xff, 0
240−#define RG_XAH_CTRL_0 (0x2c)
241−#define SR_SLOTTED_OPERATION 0x2c, 0x01, 0
242−#define SR_MAX_CSMA_RETRIES 0x2c, 0x0e, 1
243−#define SR_MAX_FRAME_RETRIES 0x2c, 0xf0, 4
244−#define RG_CSMA_SEED_0 (0x2d)
245−#define SR_CSMA_SEED_0 0x2d, 0xff, 0
246−#define RG_CSMA_SEED_1 (0x2e)
247−#define SR_CSMA_SEED_1 0x2e, 0x07, 0
248−#define SR_AACK_I_AM_COORD 0x2e, 0x08, 3
249−#define SR_AACK_DIS_ACK 0x2e, 0x10, 4
250−#define SR_AACK_SET_PD 0x2e, 0x20, 5
251−#define SR_AACK_FVN_MODE 0x2e, 0xc0, 6
252−#define RG_CSMA_BE (0x2f)
253−#define SR_MIN_BE 0x2f, 0x0f, 0
254−#define SR_MAX_BE 0x2f, 0xf0, 4
105+#define RG_TRX_STATUS (0x01)
106+#define SR_TRX_STATUS 0x01, 0x1f, 0
107+#define SR_RESERVED_01_3 0x01, 0x20, 5
108+#define SR_CCA_STATUS 0x01, 0x40, 6
109+#define SR_CCA_DONE 0x01, 0x80, 7
110+#define RG_TRX_STATE (0x02)
111+#define SR_TRX_CMD 0x02, 0x1f, 0
112+#define SR_TRAC_STATUS 0x02, 0xe0, 5
113+#define RG_TRX_CTRL_0 (0x03)
114+#define SR_CLKM_CTRL 0x03, 0x07, 0
115+#define SR_CLKM_SHA_SEL 0x03, 0x08, 3
116+#define SR_PAD_IO_CLKM 0x03, 0x30, 4
117+#define SR_PAD_IO 0x03, 0xc0, 6
118+#define RG_TRX_CTRL_1 (0x04)
119+#define SR_IRQ_POLARITY 0x04, 0x01, 0
120+#define SR_IRQ_MASK_MODE 0x04, 0x02, 1
121+#define SR_SPI_CMD_MODE 0x04, 0x0c, 2
122+#define SR_RX_BL_CTRL 0x04, 0x10, 4
123+#define SR_TX_AUTO_CRC_ON 0x04, 0x20, 5
124+#define SR_IRQ_2_EXT_EN 0x04, 0x40, 6
125+#define SR_PA_EXT_EN 0x04, 0x80, 7
126+#define RG_PHY_TX_PWR (0x05)
127+#define SR_TX_PWR 0x05, 0x0f, 0
128+#define SR_PA_LT 0x05, 0x30, 4
129+#define SR_PA_BUF_LT 0x05, 0xc0, 6
130+#define RG_PHY_RSSI (0x06)
131+#define SR_RSSI 0x06, 0x1f, 0
132+#define SR_RND_VALUE 0x06, 0x60, 5
133+#define SR_RX_CRC_VALID 0x06, 0x80, 7
134+#define RG_PHY_ED_LEVEL (0x07)
135+#define SR_ED_LEVEL 0x07, 0xff, 0
136+#define RG_PHY_CC_CCA (0x08)
137+#define SR_CHANNEL 0x08, 0x1f, 0
138+#define SR_CCA_MODE 0x08, 0x60, 5
139+#define SR_CCA_REQUEST 0x08, 0x80, 7
140+#define RG_CCA_THRES (0x09)
141+#define SR_CCA_ED_THRES 0x09, 0x0f, 0
142+#define SR_RESERVED_09_1 0x09, 0xf0, 4
143+#define RG_RX_CTRL (0x0a)
144+#define SR_PDT_THRES 0x0a, 0x0f, 0
145+#define SR_RESERVED_0a_1 0x0a, 0xf0, 4
146+#define RG_SFD_VALUE (0x0b)
147+#define SR_SFD_VALUE 0x0b, 0xff, 0
148+#define RG_TRX_CTRL_2 (0x0c)
149+#define SR_OQPSK_DATA_RATE 0x0c, 0x03, 0
150+#define SR_SUB_MODE 0x0c, 0x04, 2
151+#define SR_BPSK_QPSK 0x0c, 0x08, 3
152+#define SR_OQPSK_SUB1_RC_EN 0x0c, 0x10, 4
153+#define SR_RESERVED_0c_5 0x0c, 0x60, 5
154+#define SR_RX_SAFE_MODE 0x0c, 0x80, 7
155+#define RG_ANT_DIV (0x0d)
156+#define SR_ANT_CTRL 0x0d, 0x03, 0
157+#define SR_ANT_EXT_SW_EN 0x0d, 0x04, 2
158+#define SR_ANT_DIV_EN 0x0d, 0x08, 3
159+#define SR_RESERVED_0d_2 0x0d, 0x70, 4
160+#define SR_ANT_SEL 0x0d, 0x80, 7
161+#define RG_IRQ_MASK (0x0e)
162+#define SR_IRQ_MASK 0x0e, 0xff, 0
163+#define RG_IRQ_STATUS (0x0f)
164+#define SR_IRQ_0_PLL_LOCK 0x0f, 0x01, 0
165+#define SR_IRQ_1_PLL_UNLOCK 0x0f, 0x02, 1
166+#define SR_IRQ_2_RX_START 0x0f, 0x04, 2
167+#define SR_IRQ_3_TRX_END 0x0f, 0x08, 3
168+#define SR_IRQ_4_CCA_ED_DONE 0x0f, 0x10, 4
169+#define SR_IRQ_5_AMI 0x0f, 0x20, 5
170+#define SR_IRQ_6_TRX_UR 0x0f, 0x40, 6
171+#define SR_IRQ_7_BAT_LOW 0x0f, 0x80, 7
172+#define RG_VREG_CTRL (0x10)
173+#define SR_RESERVED_10_6 0x10, 0x03, 0
174+#define SR_DVDD_OK 0x10, 0x04, 2
175+#define SR_DVREG_EXT 0x10, 0x08, 3
176+#define SR_RESERVED_10_3 0x10, 0x30, 4
177+#define SR_AVDD_OK 0x10, 0x40, 6
178+#define SR_AVREG_EXT 0x10, 0x80, 7
179+#define RG_BATMON (0x11)
180+#define SR_BATMON_VTH 0x11, 0x0f, 0
181+#define SR_BATMON_HR 0x11, 0x10, 4
182+#define SR_BATMON_OK 0x11, 0x20, 5
183+#define SR_RESERVED_11_1 0x11, 0xc0, 6
184+#define RG_XOSC_CTRL (0x12)
185+#define SR_XTAL_TRIM 0x12, 0x0f, 0
186+#define SR_XTAL_MODE 0x12, 0xf0, 4
187+#define RG_RX_SYN (0x15)
188+#define SR_RX_PDT_LEVEL 0x15, 0x0f, 0
189+#define SR_RESERVED_15_2 0x15, 0x70, 4
190+#define SR_RX_PDT_DIS 0x15, 0x80, 7
191+#define RG_XAH_CTRL_1 (0x17)
192+#define SR_RESERVED_17_8 0x17, 0x01, 0
193+#define SR_AACK_PROM_MODE 0x17, 0x02, 1
194+#define SR_AACK_ACK_TIME 0x17, 0x04, 2
195+#define SR_RESERVED_17_5 0x17, 0x08, 3
196+#define SR_AACK_UPLD_RES_FT 0x17, 0x10, 4
197+#define SR_AACK_FLTR_RES_FT 0x17, 0x20, 5
198+#define SR_CSMA_LBT_MODE 0x17, 0x40, 6
199+#define SR_RESERVED_17_1 0x17, 0x80, 7
200+#define RG_FTN_CTRL (0x18)
201+#define SR_RESERVED_18_2 0x18, 0x7f, 0
202+#define SR_FTN_START 0x18, 0x80, 7
203+#define RG_PLL_CF (0x1a)
204+#define SR_RESERVED_1a_2 0x1a, 0x7f, 0
205+#define SR_PLL_CF_START 0x1a, 0x80, 7
206+#define RG_PLL_DCU (0x1b)
207+#define SR_RESERVED_1b_3 0x1b, 0x3f, 0
208+#define SR_RESERVED_1b_2 0x1b, 0x40, 6
209+#define SR_PLL_DCU_START 0x1b, 0x80, 7
210+#define RG_PART_NUM (0x1c)
211+#define SR_PART_NUM 0x1c, 0xff, 0
212+#define RG_VERSION_NUM (0x1d)
213+#define SR_VERSION_NUM 0x1d, 0xff, 0
214+#define RG_MAN_ID_0 (0x1e)
215+#define SR_MAN_ID_0 0x1e, 0xff, 0
216+#define RG_MAN_ID_1 (0x1f)
217+#define SR_MAN_ID_1 0x1f, 0xff, 0
218+#define RG_SHORT_ADDR_0 (0x20)
219+#define SR_SHORT_ADDR_0 0x20, 0xff, 0
220+#define RG_SHORT_ADDR_1 (0x21)
221+#define SR_SHORT_ADDR_1 0x21, 0xff, 0
222+#define RG_PAN_ID_0 (0x22)
223+#define SR_PAN_ID_0 0x22, 0xff, 0
224+#define RG_PAN_ID_1 (0x23)
225+#define SR_PAN_ID_1 0x23, 0xff, 0
226+#define RG_IEEE_ADDR_0 (0x24)
227+#define SR_IEEE_ADDR_0 0x24, 0xff, 0
228+#define RG_IEEE_ADDR_1 (0x25)
229+#define SR_IEEE_ADDR_1 0x25, 0xff, 0
230+#define RG_IEEE_ADDR_2 (0x26)
231+#define SR_IEEE_ADDR_2 0x26, 0xff, 0
232+#define RG_IEEE_ADDR_3 (0x27)
233+#define SR_IEEE_ADDR_3 0x27, 0xff, 0
234+#define RG_IEEE_ADDR_4 (0x28)
235+#define SR_IEEE_ADDR_4 0x28, 0xff, 0
236+#define RG_IEEE_ADDR_5 (0x29)
237+#define SR_IEEE_ADDR_5 0x29, 0xff, 0
238+#define RG_IEEE_ADDR_6 (0x2a)
239+#define SR_IEEE_ADDR_6 0x2a, 0xff, 0
240+#define RG_IEEE_ADDR_7 (0x2b)
241+#define SR_IEEE_ADDR_7 0x2b, 0xff, 0
242+#define RG_XAH_CTRL_0 (0x2c)
243+#define SR_SLOTTED_OPERATION 0x2c, 0x01, 0
244+#define SR_MAX_CSMA_RETRIES 0x2c, 0x0e, 1
245+#define SR_MAX_FRAME_RETRIES 0x2c, 0xf0, 4
246+#define RG_CSMA_SEED_0 (0x2d)
247+#define SR_CSMA_SEED_0 0x2d, 0xff, 0
248+#define RG_CSMA_SEED_1 (0x2e)
249+#define SR_CSMA_SEED_1 0x2e, 0x07, 0
250+#define SR_AACK_I_AM_COORD 0x2e, 0x08, 3
251+#define SR_AACK_DIS_ACK 0x2e, 0x10, 4
252+#define SR_AACK_SET_PD 0x2e, 0x20, 5
253+#define SR_AACK_FVN_MODE 0x2e, 0xc0, 6
254+#define RG_CSMA_BE (0x2f)
255+#define SR_MIN_BE 0x2f, 0x0f, 0
256+#define SR_MAX_BE 0x2f, 0xf0, 4
255257
256258 #define CMD_REG 0x80
257259 #define CMD_REG_MASK 0x3f
@@ -292,6 +294,8 @@ struct at86rf230_local { · 34 unmodified lines
292294 #define STATE_BUSY_RX_AACK_NOCLK 0x1E
293295 #define STATE_TRANSITION_IN_PROGRESS 0x1F
294296
297+#define TRX_STATE_MASK (0x1F)
298+
295299 #define AT86RF2XX_NUMREGS 0x3F
296300
297301 static void
@@ -336,6 +340,14 @@ at86rf230_write_subreg(struct at86rf230_local *lp, · 38 unmodified lines
336340 return regmap_update_bits(lp->regmap, addr, mask, data << shift);
337341 }
338342
343+static inline void
344+at86rf230_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+
339351 static bool
340352 at86rf230_reg_writeable(struct device *dev, unsigned int reg)
341353 {
@@ -509,7 +521,7 @@ at86rf230_async_state_assert(void *context) · 167 unmodified lines
509521 struct at86rf230_state_change *ctx = context;
510522 struct at86rf230_local *lp = ctx->lp;
511523 const u8 *buf = ctx->buf;
512− const u8 trx_state = buf[1] & 0x1f;
524+ const u8 trx_state = buf[1] & TRX_STATE_MASK;
513525
514526 /* Assert state change */
515527 if (trx_state != ctx->to_state) {
@@ -609,11 +621,17 @@ at86rf230_async_state_delay(void *context) · 93 unmodified lines
609621 switch (ctx->to_state) {
610622 case STATE_RX_AACK_ON:
611623 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;
612629 goto change;
630+ case STATE_TX_ARET_ON:
613631 case STATE_TX_ON:
614632 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
616− * calibration, we need to reset the timeout for the
633+ /* state change from TRX_OFF to TX_ON or ARET_ON to do
634+ * a calibration, we need to reset the timeout for the
617635 * next one.
618636 */
619637 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
@@ -667,7 +685,7 @@ at86rf230_async_state_change_start(void *context) · 47 unmodified lines
667685 struct at86rf230_state_change *ctx = context;
668686 struct at86rf230_local *lp = ctx->lp;
669687 u8 *buf = ctx->buf;
670− const u8 trx_state = buf[1] & 0x1f;
688+ const u8 trx_state = buf[1] & TRX_STATE_MASK;
671689 int rc;
672690
673691 /* Check for "possible" STATE_TRANSITION_IN_PROGRESS */
@@ -772,16 +790,6 @@ at86rf230_tx_on(void *context) · 98 unmodified lines
772790 at86rf230_tx_complete, true);
773791 }
774792
775−static void
776−at86rf230_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−
785793 static void
786794 at86rf230_tx_trac_check(void *context)
787795 {
@@ -791,12 +799,12 @@ at86rf230_tx_trac_check(void *context) · 3 unmodified lines
791799 const u8 trac = (buf[1] & 0xe0) >> 5;
792800
793801 /* 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
795− * state to TX_ON.
802+ * to STATE_FORCE_TRX_OFF then STATE_RX_AACK_ON to recover the
803+ * transceiver.
796804 */
797805 if (trac)
798806 at86rf230_async_state_change(lp, ctx, STATE_FORCE_TRX_OFF,
799− at86rf230_tx_trac_error, true);
807+ at86rf230_tx_on, true);
800808 else
801809 at86rf230_tx_on(context);
802810 }
@@ -941,13 +949,18 @@ at86rf230_write_frame_complete(void *context) · 138 unmodified lines
941949 u8 *buf = ctx->buf;
942950 int rc;
943951
944− buf[0] = (RG_TRX_STATE & CMD_REG_MASK) | CMD_REG | CMD_WRITE;
945− buf[1] = STATE_BUSY_TX;
946952 ctx->trx.len = 2;
947− ctx->msg.complete = NULL;
948− rc = spi_async(lp->spi, &ctx->msg);
949− if (rc)
950− at86rf230_async_error(lp, ctx, rc);
953+
954+ if (gpio_is_valid(lp->slp_tr)) {
955+ at86rf230_slp_tr_rising_edge(lp);
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+ }
951964 }
952965
953966 static void
@@ -993,12 +1006,21 @@ at86rf230_xmit_start(void *context) · 39 unmodified lines
9931006 * are in STATE_TX_ON. The pfad differs here, so we change
9941007 * the complete handler.
9951008 */
996− if (lp->tx_aret)
997− at86rf230_async_state_change(lp, ctx, STATE_TX_ON,
998− at86rf230_xmit_tx_on, false);
999− else
1009+ if (lp->tx_aret) {
1010+ if (lp->is_tx_from_off) {
1011+ lp->is_tx_from_off = false;
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 {
10001021 at86rf230_async_state_change(lp, ctx, STATE_TX_ON,
10011022 at86rf230_write_frame, false);
1023+ }
10021024 }
10031025
10041026 static int
@@ -1017,11 +1039,13 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) · 12 unmodified lines
10171039 * to TX_ON, the lp->cal_timeout should be reinit by state_delay
10181040 * function then to start in the next 5 minutes.
10191041 */
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;
10211044 at86rf230_async_state_change(lp, ctx, STATE_TRX_OFF,
10221045 at86rf230_xmit_start, false);
1023− else
1046+ } else {
10241047 at86rf230_xmit_start(ctx);
1048+ }
10251049
10261050 return 0;
10271051 }
@@ -1037,9 +1061,6 @@ at86rf230_ed(struct ieee802154_hw *hw, u8 *level) · 9 unmodified lines
10371061 static int
10381062 at86rf230_start(struct ieee802154_hw *hw)
10391063 {
1040− struct at86rf230_local *lp = hw->priv;
1041−
1042− lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
10431064 return at86rf230_sync_state_change(hw->priv, STATE_RX_AACK_ON);
10441065 }
10451066
@@ -1673,6 +1694,7 @@ static int at86rf230_probe(struct spi_device *spi) · 627 unmodified lines
16731694 lp = hw->priv;
16741695 lp->hw = hw;
16751696 lp->spi = spi;
1697+ lp->slp_tr = slp_tr;
16761698 hw->parent = &spi->dev;
16771699 hw->vif_data_size = sizeof(*lp);
16781700 ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
drivers/net/macvlan.c+15−0
@@ -599,10 +599,18 @@ static int macvlan_open(struct net_device *dev) · 598 unmodified lines
599599 goto del_unicast;
600600 }
601601
602+ if (dev->flags & IFF_PROMISC) {
603+ err = dev_set_promiscuity(lowerdev, 1);
604+ if (err < 0)
605+ goto clear_multi;
606+ }
607+
602608 hash_add:
603609 macvlan_hash_add(vlan);
604610 return 0;
605611
612+clear_multi:
613+ dev_set_allmulti(lowerdev, -1);
606614 del_unicast:
607615 dev_uc_del(lowerdev, dev->dev_addr);
608616 out:
@@ -638,6 +646,9 @@ static int macvlan_stop(struct net_device *dev) · 29 unmodified lines
638646 if (dev->flags & IFF_ALLMULTI)
639647 dev_set_allmulti(lowerdev, -1);
640648
649+ if (dev->flags & IFF_PROMISC)
650+ dev_set_promiscuity(lowerdev, -1);
651+
641652 dev_uc_del(lowerdev, dev->dev_addr);
642653
643654 hash_del:
@@ -696,6 +707,10 @@ static void macvlan_change_rx_flags(struct net_device *dev, int change) · 52 unmodified lines
696707 if (dev->flags & IFF_UP) {
697708 if (change & IFF_ALLMULTI)
698709 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+
699714 }
700715 }
701716
drivers/net/phy/Kconfig+1−0
@@ -27,6 +27,7 @@ config AMD_PHY · 26 unmodified lines
2727 config AMD_XGBE_PHY
2828 tristate "Driver for the AMD 10GbE (amd-xgbe) PHYs"
2929 depends on (OF || ACPI) && HAS_IOMEM
30+ depends on ARM64 || COMPILE_TEST
3031 ---help---
3132 Currently supports the AMD 10GbE PHY
3233
drivers/net/phy/mdio-gpio.c+4−1
@@ -168,7 +168,10 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev, · 167 unmodified lines
168168 if (!new_bus->irq[i])
169169 new_bus->irq[i] = PHY_POLL;
170170
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);
172175
173176 if (devm_gpio_request(dev, bitbang->mdc, "mdc"))
174177 goto out_free_bus;
drivers/net/phy/micrel.c+2−1
@@ -548,7 +548,8 @@ static int kszphy_probe(struct phy_device *phydev) · 547 unmodified lines
548548 }
549549
550550 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)) {
552553 unsigned long rate = clk_get_rate(clk);
553554 bool rmii_ref_clk_sel_25_mhz;
554555
drivers/net/ppp/pppoe.c+4−0
@@ -465,6 +465,10 @@ static void pppoe_unbind_sock_work(struct work_struct *work) · 464 unmodified lines
465465 struct sock *sk = sk_pppox(po);
466466
467467 lock_sock(sk);
468+ if (po->pppoe_dev) {
469+ dev_put(po->pppoe_dev);
470+ po->pppoe_dev = NULL;
471+ }
468472 pppox_unbind_sock(sk);
469473 release_sock(sk);
470474 sock_put(sk);
drivers/net/usb/r8152.c+1−0
@@ -4116,6 +4116,7 @@ static struct usb_device_id rtl8152_table[] = { · 4115 unmodified lines
41164116 {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)},
41174117 {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)},
41184118 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205)},
4119+ {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)},
41194120 {}
41204121 };
41214122
drivers/net/usb/usbnet.c+2−2
@@ -1285,7 +1285,7 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, · 1284 unmodified lines
12851285 struct net_device *net)
12861286 {
12871287 struct usbnet *dev = netdev_priv(net);
1288− int length;
1288+ unsigned int length;
12891289 struct urb *urb = NULL;
12901290 struct skb_data *entry;
12911291 struct driver_info *info = dev->driver_info;
@@ -1413,7 +1413,7 @@ not_drop: · 121 unmodified lines
14131413 }
14141414 } else
14151415 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);
14171417 #ifdef CONFIG_PM
14181418 deferred:
14191419 #endif
drivers/net/wireless/ath/ath9k/xmit.c+25−27
@@ -1103,28 +1103,14 @@ static u8 ath_get_rate_txpower(struct ath_softc *sc, struct ath_buf *bf, · 1102 unmodified lines
11031103 struct sk_buff *skb;
11041104 struct ath_frame_info *fi;
11051105 struct ieee80211_tx_info *info;
1106− struct ieee80211_vif *vif;
11071106 struct ath_hw *ah = sc->sc_ah;
11081107
11091108 if (sc->tx99_state || !ah->tpc_enabled)
11101109 return MAX_RATE_POWER;
11111110
11121111 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−
11271112 fi = get_frame_info(skb);
1113+ info = IEEE80211_SKB_CB(skb);
11281114
11291115 if (!AR_SREV_9300_20_OR_LATER(ah)) {
11301116 int txpower = fi->tx_power;
@@ -1161,25 +1147,26 @@ static u8 ath_get_rate_txpower(struct ath_softc *sc, struct ath_buf *bf, · 30 unmodified lines
11611147 txpower -= 2;
11621148
11631149 txpower = max(txpower, 0);
1164− max_power = min_t(u8, ah->tx_power[rateidx],
1165− 2 * vif->bss_conf.txpower);
1166− max_power = min_t(u8, max_power, txpower);
1150+ max_power = min_t(u8, ah->tx_power[rateidx], txpower);
1151+
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;
11671158 } else if (!bf->bf_state.bfs_paprd) {
11681159 if (rateidx < 8 && (info->flags & IEEE80211_TX_CTL_STBC))
11691160 max_power = min_t(u8, ah->tx_power_stbc[rateidx],
1170− 2 * vif->bss_conf.txpower);
1161+ fi->tx_power);
11711162 else
11721163 max_power = min_t(u8, ah->tx_power[rateidx],
1173− 2 * vif->bss_conf.txpower);
1174− max_power = min(max_power, fi->tx_power);
1164+ fi->tx_power);
11751165 } else {
11761166 max_power = ah->paprd_training_power;
11771167 }
1178−out:
1179− /* XXX: clamp minimum TX power at 1 for AR9160 since if 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;
1168+
1169+ return max_power;
11831170 }
11841171
11851172 static 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, · 943 unmodified lines
21292116 struct ath_node *an = NULL;
21302117 enum ath9k_key_type keytype;
21312118 bool short_preamble = false;
2119+ u8 txpower;
21322120
21332121 /*
21342122 * 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, · 10 unmodified lines
21452133 if (sta)
21462134 an = (struct ath_node *) sta->drv_priv;
21472135
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+
21482146 memset(fi, 0, sizeof(*fi));
21492147 fi->txq = -1;
21502148 if (hw_key)
@@ -2155,7 +2153,7 @@ static void setup_frame_info(struct ieee80211_hw *hw, · 4 unmodified lines
21552153 fi->keyix = ATH9K_TXKEYIX_INVALID;
21562154 fi->keytype = keytype;
21572155 fi->framelen = framelen;
2158− fi->tx_power = MAX_RATE_POWER;
2156+ fi->tx_power = txpower;
21592157
21602158 if (!rate)
21612159 return;
drivers/net/wireless/iwlwifi/iwl-fw-file.h+2−0
@@ -244,6 +244,7 @@ enum iwl_ucode_tlv_flag { · 243 unmodified lines
244244 * longer than the passive one, which is essential for fragmented scan.
245245 * @IWL_UCODE_TLV_API_WIFI_MCC_UPDATE: ucode supports MCC updates with source.
246246 * 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.
247248 * @IWL_UCODE_TLV_API_BASIC_DWELL: use only basic dwell time in scan command,
248249 * regardless of the band or the number of the probes. FW will calculate
249250 * the actual dwell time.
@@ -260,6 +261,7 @@ enum iwl_ucode_tlv_api { · 10 unmodified lines
260261 IWL_UCODE_TLV_API_FRAGMENTED_SCAN = BIT(8),
261262 IWL_UCODE_TLV_API_WIFI_MCC_UPDATE = BIT(9),
262263 IWL_UCODE_TLV_API_HDC_PHASE_0 = BIT(10),
264+ IWL_UCODE_TLV_API_TX_POWER_DEV = BIT(11),
263265 IWL_UCODE_TLV_API_BASIC_DWELL = BIT(13),
264266 IWL_UCODE_TLV_API_SCD_CFG = BIT(15),
265267 IWL_UCODE_TLV_API_SINGLE_SCAN_EBS = BIT(16),
drivers/net/wireless/iwlwifi/iwl-trans.h+27−14
@@ -6,7 +6,7 @@ · 5 unmodified lines
66 * GPL LICENSE SUMMARY
77 *
88 * 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
1010 *
1111 * This program is free software; you can redistribute it and/or modify
1212 * it under the terms of version 2 of the GNU General Public License as
@@ -32,7 +32,7 @@ · 19 unmodified lines
3232 * BSD LICENSE
3333 *
3434 * 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
3636 * All rights reserved.
3737 *
3838 * Redistribution and use in source and binary forms, with or without
@@ -421,8 +421,9 @@ struct iwl_trans_txq_scd_cfg { · 382 unmodified lines
421421 *
422422 * All the handlers MUST be implemented
423423 *
424− * @start_hw: starts the HW- from that point on, the HW can send interrupts
425− * May sleep
424+ * @start_hw: starts the HW. If low_power is true, the NIC needs to be taken
425+ * out of a low power state. From that point on, the HW can send
426+ * interrupts. May sleep.
426427 * @op_mode_leave: Turn off the HW RF kill indication if on
427428 * May sleep
428429 * @start_fw: allocates and inits all the resources for the transport
@@ -432,10 +433,11 @@ struct iwl_trans_txq_scd_cfg { · 3 unmodified lines
432433 * the SCD base address in SRAM, then provide it here, or 0 otherwise.
433434 * May sleep
434435 * @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− * issue interrupt if the HW RF kill is triggered. This callback must do
437− * the right thing and not crash even if start_hw() was called but not
438− * start_fw(). May sleep
436+ * the HW. If low_power is true, the NIC will be put in low power state.
437+ * From that point on, the HW will be stopped but will still issue an
438+ * interrupt if the HW RF kill switch is triggered.
439+ * This callback must do the right thing and not crash even if %start_hw()
440+ * was called but not &start_fw(). May sleep.
439441 * @d3_suspend: put the device into the correct mode for WoWLAN during
440442 * suspend. This is optional, if not implemented WoWLAN will not be
441443 * supported. This callback may sleep.
@@ -491,14 +493,14 @@ struct iwl_trans_txq_scd_cfg { · 49 unmodified lines
491493 */
492494 struct iwl_trans_ops {
493495
494− int (*start_hw)(struct iwl_trans *iwl_trans);
496+ int (*start_hw)(struct iwl_trans *iwl_trans, bool low_power);
495497 void (*op_mode_leave)(struct iwl_trans *iwl_trans);
496498 int (*start_fw)(struct iwl_trans *trans, const struct fw_img *fw,
497499 bool run_in_rfkill);
498500 int (*update_sf)(struct iwl_trans *trans,
499501 struct iwl_sf_region *st_fwrd_space);
500502 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);
502504
503505 void (*d3_suspend)(struct iwl_trans *trans, bool test);
504506 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, · 147 unmodified lines
652654 trans->ops->configure(trans, trans_cfg);
653655 }
654656
655−static inline int iwl_trans_start_hw(struct iwl_trans *trans)
657+static inline int _iwl_trans_start_hw(struct iwl_trans *trans, bool low_power)
656658 {
657659 might_sleep();
658660
659− return trans->ops->start_hw(trans);
661+ return trans->ops->start_hw(trans, low_power);
662+}
663+
664+static inline int iwl_trans_start_hw(struct iwl_trans *trans)
665+{
666+ return trans->ops->start_hw(trans, true);
660667 }
661668
662669 static 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, · 40 unmodified lines
703710 return 0;
704711 }
705712
706−static inline void iwl_trans_stop_device(struct iwl_trans *trans)
713+static inline void _iwl_trans_stop_device(struct iwl_trans *trans,
714+ bool low_power)
707715 {
708716 might_sleep();
709717
710− trans->ops->stop_device(trans);
718+ trans->ops->stop_device(trans, low_power);
711719
712720 trans->state = IWL_TRANS_NO_FW;
713721 }
714722
723+static inline void iwl_trans_stop_device(struct iwl_trans *trans)
724+{
725+ _iwl_trans_stop_device(trans, true);
726+}
727+
715728 static inline void iwl_trans_d3_suspend(struct iwl_trans *trans, bool test)
716729 {
717730 might_sleep();
drivers/net/wireless/iwlwifi/mvm/d3.c+1−1
@@ -1726,7 +1726,7 @@ iwl_mvm_netdetect_query_results(struct iwl_mvm *mvm, · 1725 unmodified lines
17261726 results->matched_profiles = le32_to_cpu(query->matched_profiles);
17271727 memcpy(results->matches, query->matches, sizeof(results->matches));
17281728
1729−#ifdef CPTCFG_IWLWIFI_DEBUGFS
1729+#ifdef CONFIG_IWLWIFI_DEBUGFS
17301730 mvm->last_netdetect_scans = le32_to_cpu(query->n_scans_done);
17311731 #endif
17321732
drivers/net/wireless/iwlwifi/mvm/fw-api-power.h+34−0
@@ -297,6 +297,40 @@ struct iwl_uapsd_misbehaving_ap_notif { · 296 unmodified lines
297297 u8 reserved[3];
298298 } __packed;
299299
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+ */
307+struct 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+ */
323+struct 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+
300334 /**
301335 * struct iwl_beacon_filter_cmd
302336 * REPLY_BEACON_FILTERING_CMD = 0xd2 (command)
drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h+2−42
@@ -122,46 +122,6 @@ enum iwl_scan_complete_status { · 121 unmodified lines
122122 SCAN_COMP_STATUS_ERR_ALLOC_TE = 0x0C,
123123 };
124124
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− */
135−struct 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− */
155−struct 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−
165125 /* scan offload */
166126 #define IWL_SCAN_MAX_BLACKLIST_LEN 64
167127 #define IWL_SCAN_SHORT_BLACKLIST_LEN 16
@@ -554,7 +514,7 @@ struct iwl_scan_req_unified_lmac { · 386 unmodified lines
554514 } __packed;
555515
556516 /**
557− * struct iwl_lmac_scan_results_notif - scan results for one channel -
517+ * struct iwl_scan_results_notif - scan results for one channel -
558518 * SCAN_RESULT_NTF_API_S_VER_3
559519 * @channel: which channel the results are from
560520 * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
@@ -562,7 +522,7 @@ struct iwl_scan_req_unified_lmac { · 1 unmodified line
562522 * @num_probe_not_sent: # of request that weren't sent due to not enough time
563523 * @duration: duration spent in channel, in usecs
564524 */
565−struct iwl_lmac_scan_results_notif {
525+struct iwl_scan_results_notif {
566526 u8 channel;
567527 u8 band;
568528 u8 probe_status;
drivers/net/wireless/iwlwifi/mvm/fw-api.h+0−13
@@ -281,19 +281,6 @@ struct iwl_tx_ant_cfg_cmd { · 280 unmodified lines
281281 __le32 valid;
282282 } __packed;
283283
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− */
291−struct 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−
297284 /*
298285 * Calibration control struct.
299286 * Sent as part of the phy configuration command.
drivers/net/wireless/iwlwifi/mvm/fw.c+21−33
@@ -6,7 +6,7 @@ · 5 unmodified lines
66 * GPL LICENSE SUMMARY
77 *
88 * 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
1010 *
1111 * This program is free software; you can redistribute it and/or modify
1212 * it under the terms of version 2 of the GNU General Public License as
@@ -32,7 +32,7 @@ · 19 unmodified lines
3232 * BSD LICENSE
3333 *
3434 * 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
3636 * All rights reserved.
3737 *
3838 * 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) · 283 unmodified lines
322322
323323 lockdep_assert_held(&mvm->mutex);
324324
325− if (WARN_ON_ONCE(mvm->init_ucode_complete || mvm->calibrating))
325+ if (WARN_ON_ONCE(mvm->calibrating))
326326 return 0;
327327
328328 iwl_init_notification_wait(&mvm->notif_wait,
@@ -396,8 +396,6 @@ int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) · 67 unmodified lines
396396 */
397397 ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait,
398398 MVM_UCODE_CALIB_TIMEOUT);
399− if (!ret)
400− mvm->init_ucode_complete = true;
401399
402400 if (ret && iwl_mvm_is_radio_killed(mvm)) {
403401 IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n");
@@ -494,15 +492,6 @@ int iwl_mvm_fw_dbg_collect_desc(struct iwl_mvm *mvm, · 90 unmodified lines
494492
495493 mvm->fw_dump_desc = desc;
496494
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−
506495 queue_delayed_work(system_wq, &mvm->fw_dump_wk, delay);
507496
508497 return 0;
@@ -658,25 +647,24 @@ int iwl_mvm_up(struct iwl_mvm *mvm) · 149 unmodified lines
658647 * module loading, load init ucode now
659648 * (for example, if we were in RFKILL)
660649 */
661− if (!mvm->init_ucode_complete) {
662− ret = iwl_run_init_mvm_ucode(mvm, false);
663− if (ret && !iwlmvm_mod_params.init_dbg) {
664− IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret);
665− /* this can't happen */
666− if (WARN_ON(ret > 0))
667− ret = -ERFKILL;
668− goto error;
669− }
670− if (!iwlmvm_mod_params.init_dbg) {
671− /*
672− * should stop and start HW since that INIT
673− * image just loaded
674− */
675− iwl_trans_stop_device(mvm->trans);
676− ret = iwl_trans_start_hw(mvm->trans);
677− if (ret)
678− return ret;
679− }
650+ ret = iwl_run_init_mvm_ucode(mvm, false);
651+ if (ret && !iwlmvm_mod_params.init_dbg) {
652+ IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret);
653+ /* this can't happen */
654+ if (WARN_ON(ret > 0))
655+ ret = -ERFKILL;
656+ goto error;
657+ }
658+ if (!iwlmvm_mod_params.init_dbg) {
659+ /*
660+ * Stop and start the transport without entering low power
661+ * mode. This will save the state of other components on the
662+ * device that are triggered by the INIT firwmare (MFUART).
663+ */
664+ _iwl_trans_stop_device(mvm->trans, false);
665+ _iwl_trans_start_hw(mvm->trans, false);
666+ if (ret)
667+ return ret;
680668 }
681669
682670 if (iwlmvm_mod_params.init_dbg)
drivers/net/wireless/iwlwifi/mvm/mac80211.c+23−3
@@ -1322,7 +1322,7 @@ static void iwl_mvm_restart_complete(struct iwl_mvm *mvm) · 1321 unmodified lines
13221322
13231323 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
13241324 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);
13261326 if (ret)
13271327 IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n",
13281328 ret);
@@ -1471,8 +1471,8 @@ static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm) · 142 unmodified lines
14711471 return NULL;
14721472 }
14731473
1474−static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1475− s8 tx_power)
1474+static int iwl_mvm_set_tx_power_old(struct iwl_mvm *mvm,
1475+ struct ieee80211_vif *vif, s8 tx_power)
14761476 {
14771477 /* FW is in charge of regulatory enforcement */
14781478 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, · 6 unmodified lines
14851485 &reduce_txpwr_cmd);
14861486 }
14871487
1488+static 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+
14881508 static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
14891509 struct ieee80211_vif *vif)
14901510 {
drivers/net/wireless/iwlwifi/mvm/mvm.h+0−1
@@ -603,7 +603,6 @@ struct iwl_mvm { · 602 unmodified lines
603603
604604 enum iwl_ucode_type cur_ucode;
605605 bool ucode_loaded;
606− bool init_ucode_complete;
607606 bool calibrating;
608607 u32 error_event_table;
609608 u32 log_event_table;
drivers/net/wireless/iwlwifi/mvm/ops.c+10−0
@@ -865,6 +865,16 @@ static void iwl_mvm_fw_error_dump_wk(struct work_struct *work) · 864 unmodified lines
865865 return;
866866
867867 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+
868878 iwl_mvm_fw_error_dump(mvm);
869879
870880 /* start recording again if the firmware is not crashed */
drivers/net/wireless/iwlwifi/mvm/rx.c+5−0
@@ -478,6 +478,11 @@ static void iwl_mvm_stat_iterator(void *_data, u8 *mac, · 477 unmodified lines
478478 if (vif->type != NL80211_IFTYPE_STATION)
479479 return;
480480
481+ if (sig == 0) {
482+ IWL_DEBUG_RX(mvm, "RSSI is 0 - skip signal based decision\n");
483+ return;
484+ }
485+
481486 mvmvif->bf_data.ave_beacon_signal = sig;
482487
483488 /* BT Coex */
drivers/net/wireless/iwlwifi/mvm/scan.c+1−1
@@ -319,7 +319,7 @@ int iwl_mvm_rx_scan_offload_iter_complete_notif(struct iwl_mvm *mvm, · 318 unmodified lines
319319 struct iwl_device_cmd *cmd)
320320 {
321321 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;
323323
324324 IWL_DEBUG_SCAN(mvm,
325325 "Scan offload iteration complete: status=0x%x scanned channels=%d\n",
drivers/net/wireless/iwlwifi/pcie/trans.c+9−8
@@ -5,8 +5,8 @@ · 4 unmodified lines
55 *
66 * GPL LICENSE SUMMARY
77 *
8− * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
9− * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
8+ * Copyright(c) 2007 - 2015 Intel Corporation. All rights reserved.
9+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
1010 *
1111 * This program is free software; you can redistribute it and/or modify
1212 * it under the terms of version 2 of the GNU General Public License as
@@ -31,8 +31,8 @@ · 18 unmodified lines
3131 *
3232 * BSD LICENSE
3333 *
34− * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
35− * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
34+ * Copyright(c) 2005 - 2015 Intel Corporation. All rights reserved.
35+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
3636 * All rights reserved.
3737 *
3838 * 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) · 65 unmodified lines
104104 static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans)
105105 {
106106 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
107− struct page *page;
107+ struct page *page = NULL;
108108 dma_addr_t phys;
109109 u32 size;
110110 u8 power;
@@ -131,6 +131,7 @@ static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans) · 20 unmodified lines
131131 DMA_FROM_DEVICE);
132132 if (dma_mapping_error(trans->dev, phys)) {
133133 __free_pages(page, order);
134+ page = NULL;
134135 continue;
135136 }
136137 IWL_INFO(trans,
@@ -1020,7 +1021,7 @@ static void iwl_trans_pcie_fw_alive(struct iwl_trans *trans, u32 scd_addr) · 883 unmodified lines
10201021 iwl_pcie_tx_start(trans, scd_addr);
10211022 }
10221023
1023−static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
1024+static void iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power)
10241025 {
10251026 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
10261027 bool hw_rfkill, was_hw_rfkill;
@@ -1115,7 +1116,7 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) · 88 unmodified lines
11151116 void iwl_trans_pcie_rf_kill(struct iwl_trans *trans, bool state)
11161117 {
11171118 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);
11191120 }
11201121
11211122 static 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, · 78 unmodified lines
12001201 return 0;
12011202 }
12021203
1203−static int iwl_trans_pcie_start_hw(struct iwl_trans *trans)
1204+static int iwl_trans_pcie_start_hw(struct iwl_trans *trans, bool low_power)
12041205 {
12051206 bool hw_rfkill;
12061207 int err;
drivers/net/wireless/rtlwifi/usb.c+1−1
@@ -126,7 +126,7 @@ static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request, · 125 unmodified lines
126126
127127 do {
128128 status = usb_control_msg(udev, pipe, request, reqtype, value,
129− index, pdata, len, 0); /*max. timeout*/
129+ index, pdata, len, 1000);
130130 if (status < 0) {
131131 /* firmware download is checksumed, don't retry */
132132 if ((value >= FW_8192C_START_ADDRESS &&
include/linux/netdevice.h+0−3
@@ -25,7 +25,6 @@ · 24 unmodified lines
2525 #ifndef _LINUX_NETDEVICE_H
2626 #define _LINUX_NETDEVICE_H
2727
28−#include <linux/pm_qos.h>
2928 #include <linux/timer.h>
3029 #include <linux/bug.h>
3130 #include <linux/delay.h>
@@ -1499,8 +1498,6 @@ enum netdev_priv_flags { · 1467 unmodified lines
14991498 *
15001499 * @qdisc_tx_busylock: XXX: need comments on this one
15011500 *
1502− * @pm_qos_req: Power Management QoS object
1503− *
15041501 * FIXME: cleanup struct net_device such that network protocol info
15051502 * moves out.
15061503 */
include/linux/tcp.h+8−0
@@ -145,11 +145,19 @@ struct tcp_sock { · 144 unmodified lines
145145 * read the code and the spec side by side (and laugh ...)
146146 * See RFC793 and RFC1122. The RFC writes these in capitals.
147147 */
148+ u64 bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived
149+ * sum(delta(rcv_nxt)), or how many bytes
150+ * were acked.
151+ */
148152 u32 rcv_nxt; /* What we want to receive next */
149153 u32 copied_seq; /* Head of yet unread data */
150154 u32 rcv_wup; /* rcv_nxt on last window update sent */
151155 u32 snd_nxt; /* Next sequence we send */
152156
157+ u64 bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked
158+ * sum(delta(snd_una)), or how many bytes
159+ * were acked.
160+ */
153161 u32 snd_una; /* First byte we want an ack for */
154162 u32 snd_sml; /* Last byte of the most recently transmitted small packet */
155163 u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */
include/net/cfg802154.h+2−0
@@ -30,11 +30,13 @@ struct wpan_phy_cca; · 29 unmodified lines
3030 struct cfg802154_ops {
3131 struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
3232 const char *name,
33+ unsigned char name_assign_type,
3334 int type);
3435 void (*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
3536 struct net_device *dev);
3637 int (*add_virtual_intf)(struct wpan_phy *wpan_phy,
3738 const char *name,
39+ unsigned char name_assign_type,
3840 enum nl802154_iftype type,
3941 __le64 extended_addr);
4042 int (*del_virtual_intf)(struct wpan_phy *wpan_phy,
include/net/codel.h+7−3
@@ -120,11 +120,13 @@ static inline u32 codel_time_to_us(codel_time_t val) · 119 unmodified lines
120120 * struct codel_params - contains codel parameters
121121 * @target: target queue size (in time units)
122122 * @interval: width of moving time window
123+ * @mtu: device mtu, or minimal queue backlog in bytes.
123124 * @ecn: is Explicit Congestion Notification enabled
124125 */
125126 struct codel_params {
126127 codel_time_t target;
127128 codel_time_t interval;
129+ u32 mtu;
128130 bool ecn;
129131 };
130132
@@ -166,10 +168,12 @@ struct codel_stats { · 35 unmodified lines
166168 u32 ecn_mark;
167169 };
168170
169−static void codel_params_init(struct codel_params *params)
171+static void codel_params_init(struct codel_params *params,
172+ const struct Qdisc *sch)
170173 {
171174 params->interval = MS2TIME(100);
172175 params->target = MS2TIME(5);
176+ params->mtu = psched_mtu(qdisc_dev(sch));
173177 params->ecn = false;
174178 }
175179
@@ -180,7 +184,7 @@ static void codel_vars_init(struct codel_vars *vars) · 4 unmodified lines
180184
181185 static void codel_stats_init(struct codel_stats *stats)
182186 {
183− stats->maxpacket = 256;
187+ stats->maxpacket = 0;
184188 }
185189
186190 /*
@@ -234,7 +238,7 @@ static bool codel_should_drop(const struct sk_buff *skb, · 47 unmodified lines
234238 stats->maxpacket = qdisc_pkt_len(skb);
235239
236240 if (codel_time_before(vars->ldelay, params->target) ||
237− sch->qstats.backlog <= stats->maxpacket) {
241+ sch->qstats.backlog <= params->mtu) {
238242 /* went below - stay below for at least interval */
239243 vars->first_above_time = 0;
240244 return false;
include/net/mac80211.h+2−0
@@ -1666,6 +1666,8 @@ struct ieee80211_tx_control { · 1665 unmodified lines
16661666 * @sta: station table entry, %NULL for per-vif queue
16671667 * @tid: the TID for this queue (unused for per-vif queue)
16681668 * @ac: the AC for this queue
1669+ * @drv_priv: data area for driver use, will always be aligned to
1670+ * sizeof(void *).
16691671 *
16701672 * The driver can obtain packets from this queue by calling
16711673 * ieee80211_tx_dequeue().
include/net/mac802154.h+92−2
@@ -247,19 +247,109 @@ static inline void ieee802154_le64_to_be64(void *be64_dst, const void *le64_src) · 246 unmodified lines
247247 __put_unaligned_memmove64(swab64p(le64_src), be64_dst);
248248 }
249249
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+ */
251264 struct ieee802154_hw *
252265 ieee802154_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+ */
253276 void 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+ */
254289 int 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+ */
255299 void ieee802154_unregister_hw(struct ieee802154_hw *hw);
256300
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+ */
257316 void 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+ */
258328 void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb,
259329 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+ */
261336 void 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+ */
262344 void 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+ */
263353 void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb,
264354 bool ifs_handling);
265355
include/net/tcp.h+5−2
@@ -576,7 +576,7 @@ static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize) · 575 unmodified lines
576576 }
577577
578578 /* tcp.c */
579−void tcp_get_info(const struct sock *, struct tcp_info *);
579+void tcp_get_info(struct sock *, struct tcp_info *);
580580
581581 /* Read 'sendfile()'-style from a TCP socket */
582582 typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *,
@@ -804,6 +804,8 @@ enum tcp_ca_ack_event_flags { · 221 unmodified lines
804804 /* Requires ECN/ECT set on all packets */
805805 #define TCP_CONG_NEEDS_ECN 0x2
806806
807+union tcp_cc_info;
808+
807809 struct tcp_congestion_ops {
808810 struct list_head list;
809811 u32 key;
@@ -829,7 +831,8 @@ struct tcp_congestion_ops { · 19 unmodified lines
829831 /* hook for packet ack accounting (optional) */
830832 void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us);
831833 /* 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);
833836
834837 char name[TCP_CA_NAME_MAX];
835838 struct module *owner;
include/uapi/linux/inet_diag.h+4−0
@@ -143,4 +143,8 @@ struct tcp_dctcp_info { · 142 unmodified lines
143143 __u32 dctcp_ab_tot;
144144 };
145145
146+union tcp_cc_info {
147+ struct tcpvegas_info vegas;
148+ struct tcp_dctcp_info dctcp;
149+};
146150 #endif /* _UAPI_INET_DIAG_H_ */
include/uapi/linux/mpls.h+10−0
@@ -31,4 +31,14 @@ struct mpls_label { · 30 unmodified lines
3131 #define MPLS_LS_TTL_MASK 0x000000FF
3232 #define MPLS_LS_TTL_SHIFT 0
3333
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+
3444 #endif /* _UAPI_MPLS_H */
include/uapi/linux/tcp.h+3−0
@@ -112,6 +112,7 @@ enum { · 111 unmodified lines
112112 #define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */
113113 #define TCP_TIMESTAMP 24
114114 #define TCP_NOTSENT_LOWAT 25 /* limit number of unsent bytes in write queue */
115+#define TCP_CC_INFO 26 /* Get Congestion Control (optional) info */
115116
116117 struct tcp_repair_opt {
117118 __u32 opt_code;
@@ -189,6 +190,8 @@ struct tcp_info { · 71 unmodified lines
189190
190191 __u64 tcpi_pacing_rate;
191192 __u64 tcpi_max_pacing_rate;
193+ __u64 tcpi_bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked */
194+ __u64 tcpi_bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived */
192195 };
193196
194197 /* for TCP_MD5SIG socket option */
net/bluetooth/hci_core.c+2−1
@@ -1557,7 +1557,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) · 1556 unmodified lines
15571557 {
15581558 BT_DBG("%s %p", hdev->name, hdev);
15591559
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)) {
15611562 /* Execute vendor specific shutdown routine */
15621563 if (hdev->shutdown)
15631564 hdev->shutdown(hdev);
net/core/dev.c+1−1
@@ -5209,7 +5209,7 @@ static int __netdev_upper_dev_link(struct net_device *dev, · 5208 unmodified lines
52095209 if (__netdev_find_adj(upper_dev, dev, &upper_dev->all_adj_list.upper))
52105210 return -EBUSY;
52115211
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))
52135213 return -EEXIST;
52145214
52155215 if (master && netdev_master_upper_dev_get(dev))
net/core/net_namespace.c+1−1
@@ -601,7 +601,7 @@ static int rtnl_net_getid(struct sk_buff *skb, struct nlmsghdr *nlh) · 600 unmodified lines
601601 }
602602
603603 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);
605605 if (err < 0)
606606 goto err_out;
607607
net/core/sock.c+1−1
@@ -1474,8 +1474,8 @@ void sk_release_kernel(struct sock *sk) · 1473 unmodified lines
14741474 return;
14751475
14761476 sock_hold(sk);
1477− sock_net_set(sk, get_net(&init_net));
14781477 sock_release(sk->sk_socket);
1478+ sock_net_set(sk, get_net(&init_net));
14791479 sock_put(sk);
14801480 }
14811481 EXPORT_SYMBOL(sk_release_kernel);
net/ieee802154/Makefile+3−1
@@ -3,7 +3,9 @@ obj-$(CONFIG_IEEE802154_SOCKET) += ieee802154_socket.o · 2 unmodified lines
33 obj-y += 6lowpan/
44
55 ieee802154-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
77 ieee802154_socket-y := socket.o
88
9+CFLAGS_trace.o := -I$(src)
10+
911 ccflags-y += -D__CHECK_ENDIAN__
net/ieee802154/nl-phy.c+4−1
@@ -175,6 +175,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) · 174 unmodified lines
175175 int rc = -ENOBUFS;
176176 struct net_device *dev;
177177 int type = __IEEE802154_DEV_INVALID;
178+ unsigned char name_assign_type;
178179
179180 pr_debug("%s\n", __func__);
180181
@@ -190,8 +191,10 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) · 9 unmodified lines
190191 if (devname[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1]
191192 != '\0')
192193 return -EINVAL; /* phy name should be null-terminated */
194+ name_assign_type = NET_NAME_USER;
193195 } else {
194196 devname = "wpan%d";
197+ name_assign_type = NET_NAME_ENUM;
195198 }
196199
197200 if (strlen(devname) >= IFNAMSIZ)
@@ -221,7 +224,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) · 23 unmodified lines
221224 }
222225
223226 dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname,
224− type);
227+ name_assign_type, type);
225228 if (IS_ERR(dev)) {
226229 rc = PTR_ERR(dev);
227230 goto nla_put_failure;
net/ieee802154/nl802154.c+1−1
@@ -589,7 +589,7 @@ static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info) · 588 unmodified lines
589589
590590 return rdev_add_virtual_intf(rdev,
591591 nla_data(info->attrs[NL802154_ATTR_IFNAME]),
592− type, extended_addr);
592+ NET_NAME_USER, type, extended_addr);
593593 }
594594
595595 static int nl802154_del_interface(struct sk_buff *skb, struct genl_info *info)
net/ieee802154/rdev-ops.h+72−13
@@ -4,13 +4,16 @@ · 3 unmodified lines
44 #include <net/cfg802154.h>
55
66 #include "core.h"
7+#include "trace.h"
78
89 static inline struct net_device *
910 rdev_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)
1114 {
1215 return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name,
13− type);
16+ name_assign_type, type);
1417 }
1518
1619 static inline void
@@ -22,75 +25,131 @@ rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev, · 5 unmodified lines
2225
2326 static inline int
2427 rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name,
28+ unsigned char name_assign_type,
2529 enum nl802154_iftype type, __le64 extended_addr)
2630 {
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,
2834 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;
2940 }
3041
3142 static inline int
3243 rdev_del_virtual_intf(struct cfg802154_registered_device *rdev,
3344 struct wpan_dev *wpan_dev)
3445 {
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;
3652 }
3753
3854 static inline int
3955 rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel)
4056 {
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;
4263 }
4364
4465 static inline int
4566 rdev_set_cca_mode(struct cfg802154_registered_device *rdev,
4667 const struct wpan_phy_cca *cca)
4768 {
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;
4975 }
5076
5177 static inline int
5278 rdev_set_pan_id(struct cfg802154_registered_device *rdev,
5379 struct wpan_dev *wpan_dev, __le16 pan_id)
5480 {
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;
5687 }
5788
5889 static inline int
5990 rdev_set_short_addr(struct cfg802154_registered_device *rdev,
6091 struct wpan_dev *wpan_dev, __le16 short_addr)
6192 {
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;
6399 }
64100
65101 static inline int
66102 rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev,
67103 struct wpan_dev *wpan_dev, u8 min_be, u8 max_be)
68104 {
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,
70108 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;
71113 }
72114
73115 static inline int
74116 rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev,
75117 struct wpan_dev *wpan_dev, u8 max_csma_backoffs)
76118 {
77− return rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev,
78− max_csma_backoffs);
119+ int ret;
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;
79127 }
80128
81129 static inline int
82130 rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev,
83131 struct wpan_dev *wpan_dev, s8 max_frame_retries)
84132 {
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,
86136 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;
87141 }
88142
89143 static inline int
90144 rdev_set_lbt_mode(struct cfg802154_registered_device *rdev,
91145 struct wpan_dev *wpan_dev, bool mode)
92146 {
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;
94153 }
95154
96155 #endif /* __CFG802154_RDEV_OPS */
net/ieee802154/trace.c+7−0
@@ -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
net/ieee802154/trace.h+247−0
@@ -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+
43+TRACE_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+
64+TRACE_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+
79+TRACE_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+
96+TRACE_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+
111+DECLARE_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+
130+DEFINE_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+
136+DEFINE_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+
145+TRACE_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+
167+TRACE_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+
187+TRACE_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+
207+TRACE_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+
226+TRACE_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>
net/ipv4/inet_diag.c+5−3
@@ -224,14 +224,16 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, · 223 unmodified lines
224224 handler->idiag_get_info(sk, r, info);
225225
226226 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;
228230
229231 rcu_read_lock();
230232 ca_ops = READ_ONCE(icsk->icsk_ca_ops);
231233 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);
233235 rcu_read_unlock();
234− if (err < 0)
236+ if (sz && nla_put(skb, attr, sz, &info) < 0)
235237 goto errout;
236238 }
237239
net/ipv4/tcp.c+27−1
@@ -252,6 +252,7 @@ · 251 unmodified lines
252252 #include <linux/types.h>
253253 #include <linux/fcntl.h>
254254 #include <linux/poll.h>
255+#include <linux/inet_diag.h>
255256 #include <linux/init.h>
256257 #include <linux/fs.h>
257258 #include <linux/skbuff.h>
@@ -2592,7 +2593,7 @@ EXPORT_SYMBOL(compat_tcp_setsockopt); · 2334 unmodified lines
25922593 #endif
25932594
25942595 /* Return information about state of tcp endpoint in API format. */
2595−void tcp_get_info(const struct sock *sk, struct tcp_info *info)
2596+void tcp_get_info(struct sock *sk, struct tcp_info *info)
25962597 {
25972598 const struct tcp_sock *tp = tcp_sk(sk);
25982599 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) · 64 unmodified lines
26632664
26642665 rate = READ_ONCE(sk->sk_max_pacing_rate);
26652666 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);
26662672 }
26672673 EXPORT_SYMBOL_GPL(tcp_get_info);
26682674
@@ -2734,6 +2740,26 @@ static int do_tcp_getsockopt(struct sock *sk, int level, · 65 unmodified lines
27342740 return -EFAULT;
27352741 return 0;
27362742 }
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+ }
27372763 case TCP_QUICKACK:
27382764 val = !icsk->icsk_ack.pingpong;
27392765 break;
net/ipv4/tcp_dctcp.c+10−10
@@ -277,7 +277,8 @@ static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev) · 276 unmodified lines
277277 }
278278 }
279279
280−static int dctcp_get_info(struct sock *sk, u32 ext, struct sk_buff *skb)
280+static size_t dctcp_get_info(struct sock *sk, u32 ext, int *attr,
281+ union tcp_cc_info *info)
281282 {
282283 const struct dctcp *ca = inet_csk_ca(sk);
283284
@@ -286,18 +287,17 @@ static int dctcp_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) · 2 unmodified lines
286287 */
287288 if (ext & (1 << (INET_DIAG_DCTCPINFO - 1)) ||
288289 ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
289− struct tcp_dctcp_info info;
290−
291− memset(&info, 0, sizeof(info));
290+ memset(info, 0, sizeof(struct tcp_dctcp_info));
292291 if (inet_csk(sk)->icsk_ca_ops != &dctcp_reno) {
293− info.dctcp_enabled = 1;
294− info.dctcp_ce_state = (u16) ca->ce_state;
295− info.dctcp_alpha = ca->dctcp_alpha;
296− info.dctcp_ab_ecn = ca->acked_bytes_ecn;
297− info.dctcp_ab_tot = ca->acked_bytes_total;
292+ info->dctcp.dctcp_enabled = 1;
293+ info->dctcp.dctcp_ce_state = (u16) ca->ce_state;
294+ info->dctcp.dctcp_alpha = ca->dctcp_alpha;
295+ info->dctcp.dctcp_ab_ecn = ca->acked_bytes_ecn;
296+ info->dctcp.dctcp_ab_tot = ca->acked_bytes_total;
298297 }
299298
300− return nla_put(skb, INET_DIAG_DCTCPINFO, sizeof(info), &info);
299+ *attr = INET_DIAG_DCTCPINFO;
300+ return sizeof(*info);
301301 }
302302 return 0;
303303 }
net/ipv4/tcp_fastopen.c+1−0
@@ -206,6 +206,7 @@ static bool tcp_fastopen_create_child(struct sock *sk, · 205 unmodified lines
206206 skb_set_owner_r(skb2, child);
207207 __skb_queue_tail(&child->sk_receive_queue, skb2);
208208 tp->syn_data_acked = 1;
209+ tp->bytes_received = end_seq - TCP_SKB_CB(skb)->seq - 1;
209210 } else {
210211 end_seq = TCP_SKB_CB(skb)->seq + 1;
211212 }
net/ipv4/tcp_illinois.c+11−10
@@ -300,24 +300,25 @@ static u32 tcp_illinois_ssthresh(struct sock *sk) · 299 unmodified lines
300300 }
301301
302302 /* Extract info for Tcp socket info provided via netlink. */
303−static int tcp_illinois_info(struct sock *sk, u32 ext, struct sk_buff *skb)
303+static size_t tcp_illinois_info(struct sock *sk, u32 ext, int *attr,
304+ union tcp_cc_info *info)
304305 {
305306 const struct illinois *ca = inet_csk_ca(sk);
306307
307308 if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
308− struct tcpvegas_info info = {
309− .tcpv_enabled = 1,
310− .tcpv_rttcnt = ca->cnt_rtt,
311− .tcpv_minrtt = ca->base_rtt,
312− };
309+ info->vegas.tcpv_enabled = 1;
310+ info->vegas.tcpv_rttcnt = ca->cnt_rtt;
311+ info->vegas.tcpv_minrtt = ca->base_rtt;
312+ info->vegas.tcpv_rtt = 0;
313313
314− if (info.tcpv_rttcnt > 0) {
314+ if (info->vegas.tcpv_rttcnt > 0) {
315315 u64 t = ca->sum_rtt;
316316
317− do_div(t, info.tcpv_rttcnt);
318− info.tcpv_rtt = t;
317+ do_div(t, info->vegas.tcpv_rttcnt);
318+ info->vegas.tcpv_rtt = t;
319319 }
320− return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info);
320+ *attr = INET_DIAG_VEGASINFO;
321+ return sizeof(struct tcpvegas_info);
321322 }
322323 return 0;
323324 }
net/ipv4/tcp_input.c+26−10
@@ -1820,14 +1820,12 @@ advance_sp: · 1819 unmodified lines
18201820 for (j = 0; j < used_sacks; j++)
18211821 tp->recv_sack_cache[i++] = sp[j];
18221822
1823− tcp_mark_lost_retrans(sk);
1824−
1825− tcp_verify_left_out(tp);
1826−
18271823 if ((state.reord < tp->fackets_out) &&
18281824 ((inet_csk(sk)->icsk_ca_state != TCP_CA_Loss) || tp->undo_marker))
18291825 tcp_update_reordering(sk, tp->fackets_out - state.reord, 0);
18301826
1827+ tcp_mark_lost_retrans(sk);
1828+ tcp_verify_left_out(tp);
18311829 out:
18321830
18331831 #if FASTRETRANS_DEBUG > 0
@@ -3280,6 +3278,24 @@ static inline bool tcp_may_update_window(const struct tcp_sock *tp, · 1446 unmodified lines
32803278 (ack_seq == tp->snd_wl1 && nwin > tp->snd_wnd);
32813279 }
32823280
3281+/* If we update tp->snd_una, also update tp->bytes_acked */
3282+static 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 */
3291+static 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+
32833299 /* Update our send window.
32843300 *
32853301 * 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 · 29 unmodified lines
33153331 }
33163332 }
33173333
3318− tp->snd_una = ack;
3334+ tcp_snd_una_update(tp, ack);
33193335
33203336 return flag;
33213337 }
@@ -3497,7 +3513,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) · 175 unmodified lines
34973513 * Note, we use the fact that SND.UNA>=SND.WL2.
34983514 */
34993515 tcp_update_wl(tp, ack_seq);
3500− tp->snd_una = ack;
3516+ tcp_snd_una_update(tp, ack);
35013517 flag |= FLAG_WIN_UPDATE;
35023518
35033519 tcp_in_ack_event(sk, CA_ACK_WIN_UPDATE);
@@ -4236,7 +4252,7 @@ static void tcp_ofo_queue(struct sock *sk) · 732 unmodified lines
42364252
42374253 tail = skb_peek_tail(&sk->sk_receive_queue);
42384254 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);
42404256 if (!eaten)
42414257 __skb_queue_tail(&sk->sk_receive_queue, skb);
42424258 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 · 161 unmodified lines
44044420 __skb_pull(skb, hdrlen);
44054421 eaten = (tail &&
44064422 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);
44084424 if (!eaten) {
44094425 __skb_queue_tail(&sk->sk_receive_queue, skb);
44104426 skb_set_owner_r(skb, sk);
@@ -4497,7 +4513,7 @@ queue_and_out: · 86 unmodified lines
44974513
44984514 eaten = tcp_queue_rcv(sk, skb, 0, &fragstolen);
44994515 }
4500− tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
4516+ tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
45014517 if (skb->len)
45024518 tcp_event_data_recv(sk, skb);
45034519 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
@@ -5245,7 +5261,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb, · 741 unmodified lines
52455261 tcp_rcv_rtt_measure_ts(sk, skb);
52465262
52475263 __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);
52495265 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITSTOUSER);
52505266 eaten = 1;
52515267 }
net/ipv4/tcp_vegas.c+10−9
@@ -286,18 +286,19 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 acked) · 285 unmodified lines
286286 }
287287
288288 /* Extract info for Tcp socket info provided via netlink. */
289−int tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb)
289+size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr,
290+ union tcp_cc_info *info)
290291 {
291292 const struct vegas *ca = inet_csk_ca(sk);
293+
292294 if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
293− struct tcpvegas_info info = {
294− .tcpv_enabled = ca->doing_vegas_now,
295− .tcpv_rttcnt = ca->cntRTT,
296− .tcpv_rtt = ca->baseRTT,
297− .tcpv_minrtt = ca->minRTT,
298− };
299−
300− return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info);
295+ info->vegas.tcpv_enabled = ca->doing_vegas_now,
296+ info->vegas.tcpv_rttcnt = ca->cntRTT,
297+ info->vegas.tcpv_rtt = ca->baseRTT,
298+ info->vegas.tcpv_minrtt = ca->minRTT,
299+
300+ *attr = INET_DIAG_VEGASINFO;
301+ return sizeof(struct tcpvegas_info);
301302 }
302303 return 0;
303304 }
net/ipv4/tcp_vegas.h+2−1
@@ -19,6 +19,7 @@ void tcp_vegas_init(struct sock *sk); · 18 unmodified lines
1919 void tcp_vegas_state(struct sock *sk, u8 ca_state);
2020 void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us);
2121 void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event);
22−int tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb);
22+size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr,
23+ union tcp_cc_info *info);
2324
2425 #endif /* __TCP_VEGAS_H */
net/ipv4/tcp_westwood.c+8−7
@@ -256,18 +256,19 @@ static void tcp_westwood_event(struct sock *sk, enum tcp_ca_event event) · 255 unmodified lines
256256 }
257257
258258 /* Extract info for Tcp socket info provided via netlink. */
259−static int tcp_westwood_info(struct sock *sk, u32 ext, struct sk_buff *skb)
259+static size_t tcp_westwood_info(struct sock *sk, u32 ext, int *attr,
260+ union tcp_cc_info *info)
260261 {
261262 const struct westwood *ca = inet_csk_ca(sk);
262263
263264 if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
264− struct tcpvegas_info info = {
265− .tcpv_enabled = 1,
266− .tcpv_rtt = jiffies_to_usecs(ca->rtt),
267− .tcpv_minrtt = jiffies_to_usecs(ca->rtt_min),
268− };
265+ info->vegas.tcpv_enabled = 1;
266+ info->vegas.tcpv_rttcnt = 0;
267+ info->vegas.tcpv_rtt = jiffies_to_usecs(ca->rtt),
268+ info->vegas.tcpv_minrtt = jiffies_to_usecs(ca->rtt_min),
269269
270− return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info);
270+ *attr = INET_DIAG_VEGASINFO;
271+ return sizeof(struct tcpvegas_info);
271272 }
272273 return 0;
273274 }
net/ipv6/ip6_output.c+31−8
@@ -886,22 +886,45 @@ static int ip6_dst_lookup_tail(struct sock *sk, · 885 unmodified lines
886886 #endif
887887 int err;
888888
889− if (!*dst)
890− *dst = ip6_route_output(net, sk, fl6);
891−
892− err = (*dst)->error;
893− if (err)
894− goto out_err_release;
889+ /* The correct way to handle this would be to do
890+ * ip6_route_get_saddr, and then ip6_route_output; however,
891+ * the route-specific preferred source forces the
892+ * ip6_route_output call _before_ ip6_route_get_saddr.
893+ *
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;
895901
896− if (ipv6_addr_any(&fl6->saddr)) {
897− struct rt6_info *rt = (struct rt6_info *) *dst;
902+ if (!had_dst)
903+ *dst = ip6_route_output(net, sk, fl6);
904+ rt = (*dst)->error ? NULL : (struct rt6_info *)*dst;
898905 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
899906 sk ? inet6_sk(sk)->srcprefs : 0,
900907 &fl6->saddr);
901908 if (err)
902909 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+ }
903919 }
904920
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+
905928 #ifdef CONFIG_IPV6_OPTIMISTIC_DAD
906929 /*
907930 * Here if the dst entry we've looked up
net/ipv6/route.c+3−2
@@ -2245,9 +2245,10 @@ int ip6_route_get_saddr(struct net *net, · 2244 unmodified lines
22452245 unsigned int prefs,
22462246 struct in6_addr *saddr)
22472247 {
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;
22492250 int err = 0;
2250− if (rt->rt6i_prefsrc.plen)
2251+ if (rt && rt->rt6i_prefsrc.plen)
22512252 *saddr = rt->rt6i_prefsrc.addr;
22522253 else
22532254 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
net/mac80211/iface.c+7−5
@@ -819,13 +819,15 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, · 818 unmodified lines
819819 * (because if we remove a STA after ops->remove_interface()
820820 * the driver will have removed the vif info already!)
821821 *
822− * This is relevant only in WDS mode, in all other modes we've
823− * already removed all stations when disconnecting or similar,
824− * so warn otherwise.
822+ * In WDS mode a station must exist here and be flushed, for
823+ * AP_VLANs stations may exist since there's nothing else that
824+ * would have removed them, but in other modes there shouldn't
825+ * be any stations.
825826 */
826827 flushed = sta_info_flush(sdata);
827− WARN_ON_ONCE((sdata->vif.type != NL80211_IFTYPE_WDS && flushed > 0) ||
828− (sdata->vif.type == NL80211_IFTYPE_WDS && flushed != 1));
828+ WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
829+ ((sdata->vif.type != NL80211_IFTYPE_WDS && flushed > 0) ||
830+ (sdata->vif.type == NL80211_IFTYPE_WDS && flushed != 1)));
829831
830832 /* don't count this interface for promisc/allmulti while it is down */
831833 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
net/mac80211/sta_info.c+18−1
@@ -66,6 +66,7 @@ · 65 unmodified lines
6666
6767 static const struct rhashtable_params sta_rht_params = {
6868 .nelem_hint = 3, /* start small */
69+ .automatic_shrinking = true,
6970 .head_offset = offsetof(struct sta_info, hash_node),
7071 .key_offset = offsetof(struct sta_info, sta.addr),
7172 .key_len = ETH_ALEN,
@@ -157,8 +158,24 @@ struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata, · 85 unmodified lines
157158 const u8 *addr)
158159 {
159160 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);
160167
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;
162179 }
163180
164181 /*
net/mac802154/cfg.c+6−3
@@ -22,13 +22,14 @@ · 21 unmodified lines
2222
2323 static struct net_device *
2424 ieee802154_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)
2627 {
2728 struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
2829 struct net_device *dev;
2930
3031 rtnl_lock();
31− dev = ieee802154_if_add(local, name, type,
32+ dev = ieee802154_if_add(local, name, name_assign_type, type,
3233 cpu_to_le64(0x0000000000000000ULL));
3334 rtnl_unlock();
3435
@@ -45,12 +46,14 @@ static void ieee802154_del_iface_deprecated(struct wpan_phy *wpan_phy, · 10 unmodified lines
4546
4647 static int
4748 ieee802154_add_iface(struct wpan_phy *phy, const char *name,
49+ unsigned char name_assign_type,
4850 enum nl802154_iftype type, __le64 extended_addr)
4951 {
5052 struct ieee802154_local *local = wpan_phy_priv(phy);
5153 struct net_device *err;
5254
53− err = ieee802154_if_add(local, name, type, extended_addr);
55+ err = ieee802154_if_add(local, name, name_assign_type, type,
56+ extended_addr);
5457 return PTR_ERR_OR_ZERO(err);
5558 }
5659
net/mac802154/ieee802154_i.h+2−1
@@ -182,7 +182,8 @@ void ieee802154_iface_exit(void); · 181 unmodified lines
182182 void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata);
183183 struct net_device *
184184 ieee802154_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);
186187 void ieee802154_remove_interfaces(struct ieee802154_local *local);
187188
188189 #endif /* __IEEE802154_I_H */
net/mac802154/iface.c+3−2
@@ -522,7 +522,8 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata, · 521 unmodified lines
522522
523523 struct net_device *
524524 ieee802154_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)
526527 {
527528 struct net_device *ndev = NULL;
528529 struct ieee802154_sub_if_data *sdata = NULL;
@@ -531,7 +532,7 @@ ieee802154_if_add(struct ieee802154_local *local, const char *name, · 2 unmodified lines
531532 ASSERT_RTNL();
532533
533534 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);
535536 if (!ndev)
536537 return ERR_PTR(-ENOMEM);
537538
net/mac802154/llsec.c+2−2
@@ -134,7 +134,7 @@ llsec_key_alloc(const struct ieee802154_llsec_key *template) · 133 unmodified lines
134134 for (i = 0; i < ARRAY_SIZE(key->tfm); i++) {
135135 key->tfm[i] = crypto_alloc_aead("ccm(aes)", 0,
136136 CRYPTO_ALG_ASYNC);
137− if (!key->tfm[i])
137+ if (IS_ERR(key->tfm[i]))
138138 goto err_tfm;
139139 if (crypto_aead_setkey(key->tfm[i], template->key,
140140 IEEE802154_LLSEC_KEY_SIZE))
@@ -144,7 +144,7 @@ llsec_key_alloc(const struct ieee802154_llsec_key *template) · 3 unmodified lines
144144 }
145145
146146 key->tfm0 = crypto_alloc_blkcipher("ctr(aes)", 0, CRYPTO_ALG_ASYNC);
147− if (!key->tfm0)
147+ if (IS_ERR(key->tfm0))
148148 goto err_tfm;
149149
150150 if (crypto_blkcipher_setkey(key->tfm0, template->key,
net/mac802154/main.c+5−2
@@ -161,18 +161,21 @@ int ieee802154_register_hw(struct ieee802154_hw *hw) · 160 unmodified lines
161161
162162 rtnl_lock();
163163
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,
165166 cpu_to_le64(0x0000000000000000ULL));
166167 if (IS_ERR(dev)) {
167168 rtnl_unlock();
168169 rc = PTR_ERR(dev);
169− goto out_wq;
170+ goto out_phy;
170171 }
171172
172173 rtnl_unlock();
173174
174175 return 0;
175176
177+out_phy:
178+ wpan_phy_unregister(local->phy);
176179 out_wq:
177180 destroy_workqueue(local->workqueue);
178181 out:
net/mpls/af_mpls.c+9−9
@@ -647,7 +647,7 @@ int nla_get_labels(const struct nlattr *nla, · 646 unmodified lines
647647 return -EINVAL;
648648
649649 switch (dec.label) {
650− case LABEL_IMPLICIT_NULL:
650+ case MPLS_LABEL_IMPLNULL:
651651 /* RFC3032: This is a label that an LSR may
652652 * assign and distribute, but which never
653653 * actually appears in the encapsulation.
@@ -935,7 +935,7 @@ static int resize_platform_label_table(struct net *net, size_t limit) · 281 unmodified lines
935935 }
936936
937937 /* In case the predefined labels need to be populated */
938− if (limit > LABEL_IPV4_EXPLICIT_NULL) {
938+ if (limit > MPLS_LABEL_IPV4NULL) {
939939 struct net_device *lo = net->loopback_dev;
940940 rt0 = mpls_rt_alloc(lo->addr_len);
941941 if (!rt0)
@@ -945,7 +945,7 @@ static int resize_platform_label_table(struct net *net, size_t limit) · 3 unmodified lines
945945 rt0->rt_via_table = NEIGH_LINK_TABLE;
946946 memcpy(rt0->rt_via, lo->dev_addr, lo->addr_len);
947947 }
948− if (limit > LABEL_IPV6_EXPLICIT_NULL) {
948+ if (limit > MPLS_LABEL_IPV6NULL) {
949949 struct net_device *lo = net->loopback_dev;
950950 rt2 = mpls_rt_alloc(lo->addr_len);
951951 if (!rt2)
@@ -973,15 +973,15 @@ static int resize_platform_label_table(struct net *net, size_t limit) · 21 unmodified lines
973973 memcpy(labels, old, cp_size);
974974
975975 /* If needed set the predefined labels */
976− if ((old_limit <= LABEL_IPV6_EXPLICIT_NULL) &&
977− (limit > LABEL_IPV6_EXPLICIT_NULL)) {
978− RCU_INIT_POINTER(labels[LABEL_IPV6_EXPLICIT_NULL], rt2);
976+ if ((old_limit <= MPLS_LABEL_IPV6NULL) &&
977+ (limit > MPLS_LABEL_IPV6NULL)) {
978+ RCU_INIT_POINTER(labels[MPLS_LABEL_IPV6NULL], rt2);
979979 rt2 = NULL;
980980 }
981981
982− if ((old_limit <= LABEL_IPV4_EXPLICIT_NULL) &&
983− (limit > LABEL_IPV4_EXPLICIT_NULL)) {
984− RCU_INIT_POINTER(labels[LABEL_IPV4_EXPLICIT_NULL], rt0);
982+ if ((old_limit <= MPLS_LABEL_IPV4NULL) &&
983+ (limit > MPLS_LABEL_IPV4NULL)) {
984+ RCU_INIT_POINTER(labels[MPLS_LABEL_IPV4NULL], rt0);
985985 rt0 = NULL;
986986 }
987987
net/mpls/internal.h+0−10
@@ -1,16 +1,6 @@
11 #ifndef MPLS_INTERNAL_H
22 #define MPLS_INTERNAL_H
33
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−
144 struct mpls_shim_hdr {
155 __be32 label_stack_entry;
166 };
net/netlink/af_netlink.c+0−1
@@ -3139,7 +3139,6 @@ static const struct rhashtable_params netlink_rhashtable_params = { · 3138 unmodified lines
31393139 .key_len = netlink_compare_arg_len,
31403140 .obj_hashfn = netlink_hash,
31413141 .obj_cmpfn = netlink_compare,
3142− .max_size = 65536,
31433142 .automatic_shrinking = true,
31443143 };
31453144
net/packet/af_packet.c+6−3
@@ -2311,11 +2311,14 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg) · 2310 unmodified lines
23112311 tlen = dev->needed_tailroom;
23122312 skb = sock_alloc_send_skb(&po->sk,
23132313 hlen + tlen + sizeof(struct sockaddr_ll),
2314− 0, &err);
2314+ !need_wait, &err);
23152315
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;
23172320 goto out_status;
2318−
2321+ }
23192322 tp_len = tpacket_fill_skb(po, skb, ph, dev, size_max, proto,
23202323 addr, hlen);
23212324 if (tp_len > dev->mtu + dev->hard_header_len) {
net/rds/connection.c+15−2
@@ -126,7 +126,10 @@ static struct rds_connection *__rds_conn_create(__be32 laddr, __be32 faddr, · 125 unmodified lines
126126 struct rds_transport *loop_trans;
127127 unsigned long flags;
128128 int ret;
129+ struct rds_transport *otrans = trans;
129130
131+ if (!is_outgoing && otrans->t_type == RDS_TRANS_TCP)
132+ goto new_conn;
130133 rcu_read_lock();
131134 conn = rds_conn_lookup(head, laddr, faddr, trans);
132135 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, · 9 unmodified lines
142145 if (conn)
143146 goto out;
144147
148+new_conn:
145149 conn = kmem_cache_zalloc(rds_conn_slab, gfp);
146150 if (!conn) {
147151 conn = ERR_PTR(-ENOMEM);
@@ -230,13 +234,22 @@ static struct rds_connection *__rds_conn_create(__be32 laddr, __be32 faddr, · 82 unmodified lines
230234 /* Creating normal conn */
231235 struct rds_connection *found;
232236
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);
234241 if (found) {
235242 trans->conn_free(conn->c_transport_data);
236243 kmem_cache_free(rds_conn_slab, conn);
237244 conn = found;
238245 } 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+ }
240253 rds_cong_add_conn(conn);
241254 rds_conn_count++;
242255 }
net/rds/ib_cm.c+11−2
@@ -183,8 +183,17 @@ void rds_ib_cm_connect_complete(struct rds_connection *conn, struct rdma_cm_even · 182 unmodified lines
183183
184184 /* If the peer gave us the last packet it saw, process this as if
185185 * we had received a regular ACK. */
186− if (dp && dp->dp_ack_seq)
187− rds_send_drop_acked(conn, be64_to_cpu(dp->dp_ack_seq), NULL);
186+ if (dp) {
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+ }
188197
189198 rds_connect_complete(conn);
190199 }
net/rds/tcp_connect.c+1−0
@@ -62,6 +62,7 @@ void rds_tcp_state_change(struct sock *sk) · 61 unmodified lines
6262 case TCP_ESTABLISHED:
6363 rds_connect_complete(conn);
6464 break;
65+ case TCP_CLOSE_WAIT:
6566 case TCP_CLOSE:
6667 rds_conn_drop(conn);
6768 default:
net/rds/tcp_listen.c+46−0
@@ -45,12 +45,45 @@ static void rds_tcp_accept_worker(struct work_struct *work); · 44 unmodified lines
4545 static DECLARE_WORK(rds_tcp_listen_work, rds_tcp_accept_worker);
4646 static struct socket *rds_tcp_listen_sock;
4747
48+static 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));
76+bail:
77+ return ret;
78+}
79+
4880 static int rds_tcp_accept_one(struct socket *sock)
4981 {
5082 struct socket *new_sock = NULL;
5183 struct rds_connection *conn;
5284 int ret;
5385 struct inet_sock *inet;
86+ struct rds_tcp_connection *rs_tcp;
5487
5588 ret = sock_create_lite(sock->sk->sk_family, sock->sk->sk_type,
5689 sock->sk->sk_protocol, &new_sock);
@@ -63,6 +96,10 @@ static int rds_tcp_accept_one(struct socket *sock) · 6 unmodified lines
6396 if (ret < 0)
6497 goto out;
6598
99+ ret = rds_tcp_keepalive(new_sock);
100+ if (ret < 0)
101+ goto out;
102+
66103 rds_tcp_tune(new_sock);
67104
68105 inet = inet_sk(new_sock->sk);
@@ -77,6 +114,15 @@ static int rds_tcp_accept_one(struct socket *sock) · 8 unmodified lines
77114 ret = PTR_ERR(conn);
78115 goto out;
79116 }
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);
80126
81127 /*
82128 * see the comment above rds_queue_delayed_reconnect()
net/sched/cls_api.c+3−4
@@ -308,12 +308,11 @@ replay: · 307 unmodified lines
308308 case RTM_DELTFILTER:
309309 err = tp->ops->delete(tp, fh);
310310 if (err == 0) {
311− tfilter_notify(net, skb, n, tp, fh, RTM_DELTFILTER);
312− if (tcf_destroy(tp, false)) {
313− struct tcf_proto *next = rtnl_dereference(tp->next);
311+ struct tcf_proto *next = rtnl_dereference(tp->next);
314312
313+ tfilter_notify(net, skb, n, tp, fh, RTM_DELTFILTER);
314+ if (tcf_destroy(tp, false))
315315 RCU_INIT_POINTER(*back, next);
316− }
317316 }
318317 goto errout;
319318 case RTM_GETTFILTER:
net/sched/sch_codel.c+1−1
@@ -164,7 +164,7 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt) · 163 unmodified lines
164164
165165 sch->limit = DEFAULT_CODEL_LIMIT;
166166
167− codel_params_init(&q->params);
167+ codel_params_init(&q->params, sch);
168168 codel_vars_init(&q->vars);
169169 codel_stats_init(&q->stats);
170170
net/sched/sch_fq_codel.c+1−1
@@ -391,7 +391,7 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt) · 390 unmodified lines
391391 q->perturbation = prandom_u32();
392392 INIT_LIST_HEAD(&q->new_flows);
393393 INIT_LIST_HEAD(&q->old_flows);
394− codel_params_init(&q->cparams);
394+ codel_params_init(&q->cparams, sch);
395395 codel_stats_init(&q->cstats);
396396 q->cparams.ecn = true;
397397
net/sched/sch_gred.c+2−2
@@ -229,7 +229,7 @@ static int gred_enqueue(struct sk_buff *skb, struct Qdisc *sch) · 228 unmodified lines
229229 break;
230230 }
231231
232− if (q->backlog + qdisc_pkt_len(skb) <= q->limit) {
232+ if (gred_backlog(t, q, sch) + qdisc_pkt_len(skb) <= q->limit) {
233233 q->backlog += qdisc_pkt_len(skb);
234234 return qdisc_enqueue_tail(skb, sch);
235235 }
@@ -553,7 +553,7 @@ static int gred_dump(struct Qdisc *sch, struct sk_buff *skb) · 317 unmodified lines
553553
554554 opt.limit = q->limit;
555555 opt.DP = q->DP;
556− opt.backlog = q->backlog;
556+ opt.backlog = gred_backlog(table, q, sch);
557557 opt.prio = q->prio;
558558 opt.qth_min = q->parms.qth_min >> q->parms.Wlog;
559559 opt.qth_max = q->parms.qth_max >> q->parms.Wlog;