Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Pull networking fixes from David Miller:
"A lot of Thanksgiving turkey leftovers accumulated, here goes:

1) Fix bluetooth l2cap_chan object leak, from Johan Hedberg.

2) IDs for some new iwlwifi chips, from Oren Givon.

3) Fix rtlwifi lockups on boot, from Larry Finger.

4) Fix memory leak in fm10k, from Stephen Hemminger.

5) We have a route leak in the ipv6 tunnel infrastructure, fix from
Paolo Abeni.

6) Fix buffer pointer handling in arm64 bpf JIT,f rom Zi Shen Lim.

7) Wrong lockdep annotations in tcp md5 support, fix from Eric
Dumazet.

8) Work around some middle boxes which prevent proper handling of TCP
Fast Open, from Yuchung Cheng.

9) TCP repair can do huge kmalloc() requests, build paged SKBs
instead. From Eric Dumazet.

10) Fix msg_controllen overflow in scm_detach_fds, from Daniel
Borkmann.

11) Fix device leaks on ipmr table destruction in ipv4 and ipv6, from
Nikolay Aleksandrov.

12) Fix use after free in epoll with AF_UNIX sockets, from Rainer
Weikusat.

13) Fix double free in VRF code, from Nikolay Aleksandrov.

14) Fix skb leaks on socket receive queue in tipc, from Ying Xue.

15) Fix ifup/ifdown crach in xgene driver, from Iyappan Subramanian.

16) Fix clearing of persistent array maps in bpf, from Daniel
Borkmann.

17) In TCP, for the cross-SYN case, we don't initialize tp->copied_seq
early enough. From Eric Dumazet.

18) Fix out of bounds accesses in bpf array implementation when
updating elements, from Daniel Borkmann.

19) Fill gaps in RCU protection of np->opt in ipv6 stack, from Eric
Dumazet.

20) When dumping proxy neigh entries, we have to accomodate NULL
device pointers properly, from Konstantin Khlebnikov.

21) SCTP doesn't release all ipv6 socket resources properly, fix from
Eric Dumazet.

22) Prevent underflows of sch->q.qlen for multiqueue packet
schedulers, also from Eric Dumazet.

23) Fix MAC and unicast list handling in bnxt_en driver, from Jeffrey
Huang and Michael Chan.

24) Don't actively scan radar channels, from Antonio Quartulli"

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (110 commits)
net: phy: reset only targeted phy
bnxt_en: Setup uc_list mac filters after resetting the chip.
bnxt_en: enforce proper storing of MAC address
bnxt_en: Fixed incorrect implementation of ndo_set_mac_address
net: lpc_eth: remove irq > NR_IRQS check from probe()
net_sched: fix qdisc_tree_decrease_qlen() races
openvswitch: fix hangup on vxlan/gre/geneve device deletion
ipv4: igmp: Allow removing groups from a removed interface
ipv6: sctp: implement sctp_v6_destroy_sock()
arm64: bpf: add 'store immediate' instruction
ipv6: kill sk_dst_lock
ipv6: sctp: add rcu protection around np->opt
net/neighbour: fix crash at dumping device-agnostic proxy entries
sctp: use GFP_USER for user-controlled kmalloc
sctp: convert sack_needed and sack_generation to bits
ipv6: add complete rcu protection around np->opt
bpf: fix allocation warnings in bpf maps and integer overflow
mvebu: dts: enable IP checksum with jumbo frames for Armada 38x on Port0
net: mvneta: enable setting custom TX IP checksum limit
net: mvneta: fix error path for building skb
...

+3198 -652
+6
Documentation/devicetree/bindings/net/marvell-armada-370-neta.txt
··· 8 8 - phy-mode: See ethernet.txt file in the same directory 9 9 - clocks: a pointer to the reference clock for this device. 10 10 11 + Optional properties: 12 + - tx-csum-limit: maximum mtu supported by port that allow TX checksum. 13 + Value is presented in bytes. If not used, by default 1600B is set for 14 + "marvell,armada-370-neta" and 9800B for others. 15 + 11 16 Example: 12 17 13 18 ethernet@d0070000 { ··· 20 15 reg = <0xd0070000 0x2500>; 21 16 interrupts = <8>; 22 17 clocks = <&gate_clk 4>; 18 + tx-csum-limit = <9800> 23 19 status = "okay"; 24 20 phy = <&phy0>; 25 21 phy-mode = "rgmii-id";
+3 -3
MAINTAINERS
··· 1847 1847 F: drivers/net/wireless/ath/ath6kl/ 1848 1848 1849 1849 WILOCITY WIL6210 WIRELESS DRIVER 1850 - M: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com> 1850 + M: Maya Erez <qca_merez@qca.qualcomm.com> 1851 1851 L: linux-wireless@vger.kernel.org 1852 1852 L: wil6210@qca.qualcomm.com 1853 1853 S: Supported ··· 10903 10903 F: drivers/media/tuners/tua9001* 10904 10904 10905 10905 TULIP NETWORK DRIVERS 10906 - M: Grant Grundler <grundler@parisc-linux.org> 10907 10906 L: netdev@vger.kernel.org 10908 - S: Maintained 10907 + L: linux-parisc@vger.kernel.org 10908 + S: Orphan 10909 10909 F: drivers/net/ethernet/dec/tulip/ 10910 10910 10911 10911 TUN/TAP driver
+1
arch/arm/boot/dts/armada-38x.dtsi
··· 498 498 reg = <0x70000 0x4000>; 499 499 interrupts-extended = <&mpic 8>; 500 500 clocks = <&gateclk 4>; 501 + tx-csum-limit = <9800>; 501 502 status = "disabled"; 502 503 }; 503 504
+32 -15
arch/arm64/net/bpf_jit_comp.c
··· 139 139 /* Stack must be multiples of 16B */ 140 140 #define STACK_ALIGN(sz) (((sz) + 15) & ~15) 141 141 142 + #define _STACK_SIZE \ 143 + (MAX_BPF_STACK \ 144 + + 4 /* extra for skb_copy_bits buffer */) 145 + 146 + #define STACK_SIZE STACK_ALIGN(_STACK_SIZE) 147 + 142 148 static void build_prologue(struct jit_ctx *ctx) 143 149 { 144 150 const u8 r6 = bpf2a64[BPF_REG_6]; ··· 156 150 const u8 rx = bpf2a64[BPF_REG_X]; 157 151 const u8 tmp1 = bpf2a64[TMP_REG_1]; 158 152 const u8 tmp2 = bpf2a64[TMP_REG_2]; 159 - int stack_size = MAX_BPF_STACK; 160 - 161 - stack_size += 4; /* extra for skb_copy_bits buffer */ 162 - stack_size = STACK_ALIGN(stack_size); 163 153 164 154 /* 165 155 * BPF prog stack layout ··· 167 165 * | ... | callee saved registers 168 166 * +-----+ 169 167 * | | x25/x26 170 - * BPF fp register => -80:+-----+ 168 + * BPF fp register => -80:+-----+ <= (BPF_FP) 171 169 * | | 172 170 * | ... | BPF prog stack 173 171 * | | 174 - * | | 175 - * current A64_SP => +-----+ 172 + * +-----+ <= (BPF_FP - MAX_BPF_STACK) 173 + * |RSVD | JIT scratchpad 174 + * current A64_SP => +-----+ <= (BPF_FP - STACK_SIZE) 176 175 * | | 177 176 * | ... | Function call stack 178 177 * | | ··· 199 196 emit(A64_MOV(1, fp, A64_SP), ctx); 200 197 201 198 /* Set up function call stack */ 202 - emit(A64_SUB_I(1, A64_SP, A64_SP, stack_size), ctx); 199 + emit(A64_SUB_I(1, A64_SP, A64_SP, STACK_SIZE), ctx); 203 200 204 201 /* Clear registers A and X */ 205 202 emit_a64_mov_i64(ra, 0, ctx); ··· 216 213 const u8 fp = bpf2a64[BPF_REG_FP]; 217 214 const u8 tmp1 = bpf2a64[TMP_REG_1]; 218 215 const u8 tmp2 = bpf2a64[TMP_REG_2]; 219 - int stack_size = MAX_BPF_STACK; 220 - 221 - stack_size += 4; /* extra for skb_copy_bits buffer */ 222 - stack_size = STACK_ALIGN(stack_size); 223 216 224 217 /* We're done with BPF stack */ 225 - emit(A64_ADD_I(1, A64_SP, A64_SP, stack_size), ctx); 218 + emit(A64_ADD_I(1, A64_SP, A64_SP, STACK_SIZE), ctx); 226 219 227 220 /* Restore fs (x25) and x26 */ 228 221 emit(A64_POP(fp, A64_R(26), A64_SP), ctx); ··· 590 591 case BPF_ST | BPF_MEM | BPF_H: 591 592 case BPF_ST | BPF_MEM | BPF_B: 592 593 case BPF_ST | BPF_MEM | BPF_DW: 593 - goto notyet; 594 + /* Load imm to a register then store it */ 595 + ctx->tmp_used = 1; 596 + emit_a64_mov_i(1, tmp2, off, ctx); 597 + emit_a64_mov_i(1, tmp, imm, ctx); 598 + switch (BPF_SIZE(code)) { 599 + case BPF_W: 600 + emit(A64_STR32(tmp, dst, tmp2), ctx); 601 + break; 602 + case BPF_H: 603 + emit(A64_STRH(tmp, dst, tmp2), ctx); 604 + break; 605 + case BPF_B: 606 + emit(A64_STRB(tmp, dst, tmp2), ctx); 607 + break; 608 + case BPF_DW: 609 + emit(A64_STR64(tmp, dst, tmp2), ctx); 610 + break; 611 + } 612 + break; 594 613 595 614 /* STX: *(size *)(dst + off) = src */ 596 615 case BPF_STX | BPF_MEM | BPF_W: ··· 675 658 return -EINVAL; 676 659 } 677 660 emit_a64_mov_i64(r3, size, ctx); 678 - emit(A64_ADD_I(1, r4, fp, MAX_BPF_STACK), ctx); 661 + emit(A64_SUB_I(1, r4, fp, STACK_SIZE), ctx); 679 662 emit_a64_mov_i64(r5, (unsigned long)bpf_load_pointer, ctx); 680 663 emit(A64_PUSH(A64_FP, A64_LR, A64_SP), ctx); 681 664 emit(A64_MOV(1, A64_FP, A64_SP), ctx);
+2 -2
crypto/algif_aead.c
··· 125 125 if (flags & MSG_DONTWAIT) 126 126 return -EAGAIN; 127 127 128 - set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 128 + sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); 129 129 130 130 for (;;) { 131 131 if (signal_pending(current)) ··· 139 139 } 140 140 finish_wait(sk_sleep(sk), &wait); 141 141 142 - clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 142 + sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); 143 143 144 144 return err; 145 145 }
+3 -3
crypto/algif_skcipher.c
··· 212 212 if (flags & MSG_DONTWAIT) 213 213 return -EAGAIN; 214 214 215 - set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 215 + sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); 216 216 217 217 for (;;) { 218 218 if (signal_pending(current)) ··· 258 258 return -EAGAIN; 259 259 } 260 260 261 - set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 261 + sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); 262 262 263 263 for (;;) { 264 264 if (signal_pending(current)) ··· 272 272 } 273 273 finish_wait(sk_sleep(sk), &wait); 274 274 275 - clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 275 + sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); 276 276 277 277 return err; 278 278 }
+1 -1
drivers/isdn/hisax/config.c
··· 1896 1896 ptr--; 1897 1897 *ptr++ = '\n'; 1898 1898 *ptr = 0; 1899 - HiSax_putstatus(cs, NULL, "%s", cs->dlog); 1899 + HiSax_putstatus(cs, NULL, cs->dlog); 1900 1900 } else 1901 1901 HiSax_putstatus(cs, "LogEcho: ", 1902 1902 "warning Frame too big (%d)",
+1 -1
drivers/isdn/hisax/hfc_pci.c
··· 901 901 ptr--; 902 902 *ptr++ = '\n'; 903 903 *ptr = 0; 904 - HiSax_putstatus(cs, NULL, "%s", cs->dlog); 904 + HiSax_putstatus(cs, NULL, cs->dlog); 905 905 } else 906 906 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3); 907 907 }
+1 -1
drivers/isdn/hisax/hfc_sx.c
··· 674 674 ptr--; 675 675 *ptr++ = '\n'; 676 676 *ptr = 0; 677 - HiSax_putstatus(cs, NULL, "%s", cs->dlog); 677 + HiSax_putstatus(cs, NULL, cs->dlog); 678 678 } else 679 679 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len); 680 680 }
+3 -3
drivers/isdn/hisax/q931.c
··· 1179 1179 dp--; 1180 1180 *dp++ = '\n'; 1181 1181 *dp = 0; 1182 - HiSax_putstatus(cs, NULL, "%s", cs->dlog); 1182 + HiSax_putstatus(cs, NULL, cs->dlog); 1183 1183 } else 1184 1184 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size); 1185 1185 } ··· 1246 1246 } 1247 1247 if (finish) { 1248 1248 *dp = 0; 1249 - HiSax_putstatus(cs, NULL, "%s", cs->dlog); 1249 + HiSax_putstatus(cs, NULL, cs->dlog); 1250 1250 return; 1251 1251 } 1252 1252 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */ ··· 1509 1509 dp += sprintf(dp, "Unknown protocol %x!", buf[0]); 1510 1510 } 1511 1511 *dp = 0; 1512 - HiSax_putstatus(cs, NULL, "%s", cs->dlog); 1512 + HiSax_putstatus(cs, NULL, cs->dlog); 1513 1513 }
-2
drivers/net/can/bfin_can.c
··· 501 501 cf->data[2] |= CAN_ERR_PROT_FORM; 502 502 else if (status & SER) 503 503 cf->data[2] |= CAN_ERR_PROT_STUFF; 504 - else 505 - cf->data[2] |= CAN_ERR_PROT_UNSPEC; 506 504 } 507 505 508 506 priv->can.state = state;
+2 -5
drivers/net/can/c_can/c_can.c
··· 962 962 * type of the last error to occur on the CAN bus 963 963 */ 964 964 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; 965 - cf->data[2] |= CAN_ERR_PROT_UNSPEC; 966 965 967 966 switch (lec_type) { 968 967 case LEC_STUFF_ERROR: ··· 974 975 break; 975 976 case LEC_ACK_ERROR: 976 977 netdev_dbg(dev, "ack error\n"); 977 - cf->data[3] |= (CAN_ERR_PROT_LOC_ACK | 978 - CAN_ERR_PROT_LOC_ACK_DEL); 978 + cf->data[3] = CAN_ERR_PROT_LOC_ACK; 979 979 break; 980 980 case LEC_BIT1_ERROR: 981 981 netdev_dbg(dev, "bit1 error\n"); ··· 986 988 break; 987 989 case LEC_CRC_ERROR: 988 990 netdev_dbg(dev, "CRC error\n"); 989 - cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ | 990 - CAN_ERR_PROT_LOC_CRC_DEL); 991 + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; 991 992 break; 992 993 default: 993 994 break;
+1 -1
drivers/net/can/cc770/cc770.c
··· 578 578 cf->data[2] |= CAN_ERR_PROT_BIT0; 579 579 break; 580 580 case STAT_LEC_CRC: 581 - cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ; 581 + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; 582 582 break; 583 583 } 584 584 }
+2 -2
drivers/net/can/flexcan.c
··· 535 535 if (reg_esr & FLEXCAN_ESR_ACK_ERR) { 536 536 netdev_dbg(dev, "ACK_ERR irq\n"); 537 537 cf->can_id |= CAN_ERR_ACK; 538 - cf->data[3] |= CAN_ERR_PROT_LOC_ACK; 538 + cf->data[3] = CAN_ERR_PROT_LOC_ACK; 539 539 tx_errors = 1; 540 540 } 541 541 if (reg_esr & FLEXCAN_ESR_CRC_ERR) { 542 542 netdev_dbg(dev, "CRC_ERR irq\n"); 543 543 cf->data[2] |= CAN_ERR_PROT_BIT; 544 - cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ; 544 + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; 545 545 rx_errors = 1; 546 546 } 547 547 if (reg_esr & FLEXCAN_ESR_FRM_ERR) {
-1
drivers/net/can/janz-ican3.c
··· 1096 1096 cf->data[2] |= CAN_ERR_PROT_STUFF; 1097 1097 break; 1098 1098 default: 1099 - cf->data[2] |= CAN_ERR_PROT_UNSPEC; 1100 1099 cf->data[3] = ecc & ECC_SEG; 1101 1100 break; 1102 1101 }
+2 -5
drivers/net/can/m_can/m_can.c
··· 487 487 * type of the last error to occur on the CAN bus 488 488 */ 489 489 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; 490 - cf->data[2] |= CAN_ERR_PROT_UNSPEC; 491 490 492 491 switch (lec_type) { 493 492 case LEC_STUFF_ERROR: ··· 499 500 break; 500 501 case LEC_ACK_ERROR: 501 502 netdev_dbg(dev, "ack error\n"); 502 - cf->data[3] |= (CAN_ERR_PROT_LOC_ACK | 503 - CAN_ERR_PROT_LOC_ACK_DEL); 503 + cf->data[3] = CAN_ERR_PROT_LOC_ACK; 504 504 break; 505 505 case LEC_BIT1_ERROR: 506 506 netdev_dbg(dev, "bit1 error\n"); ··· 511 513 break; 512 514 case LEC_CRC_ERROR: 513 515 netdev_dbg(dev, "CRC error\n"); 514 - cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ | 515 - CAN_ERR_PROT_LOC_CRC_DEL); 516 + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; 516 517 break; 517 518 default: 518 519 break;
+1 -2
drivers/net/can/pch_can.c
··· 559 559 stats->rx_errors++; 560 560 break; 561 561 case PCH_CRC_ERR: 562 - cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ | 563 - CAN_ERR_PROT_LOC_CRC_DEL; 562 + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; 564 563 priv->can.can_stats.bus_error++; 565 564 stats->rx_errors++; 566 565 break;
+5 -6
drivers/net/can/rcar_can.c
··· 241 241 u8 ecsr; 242 242 243 243 netdev_dbg(priv->ndev, "Bus error interrupt:\n"); 244 - if (skb) { 244 + if (skb) 245 245 cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT; 246 - cf->data[2] = CAN_ERR_PROT_UNSPEC; 247 - } 246 + 248 247 ecsr = readb(&priv->regs->ecsr); 249 248 if (ecsr & RCAR_CAN_ECSR_ADEF) { 250 249 netdev_dbg(priv->ndev, "ACK Delimiter Error\n"); 251 250 tx_errors++; 252 251 writeb(~RCAR_CAN_ECSR_ADEF, &priv->regs->ecsr); 253 252 if (skb) 254 - cf->data[3] |= CAN_ERR_PROT_LOC_ACK_DEL; 253 + cf->data[3] = CAN_ERR_PROT_LOC_ACK_DEL; 255 254 } 256 255 if (ecsr & RCAR_CAN_ECSR_BE0F) { 257 256 netdev_dbg(priv->ndev, "Bit Error (dominant)\n"); ··· 271 272 rx_errors++; 272 273 writeb(~RCAR_CAN_ECSR_CEF, &priv->regs->ecsr); 273 274 if (skb) 274 - cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ; 275 + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; 275 276 } 276 277 if (ecsr & RCAR_CAN_ECSR_AEF) { 277 278 netdev_dbg(priv->ndev, "ACK Error\n"); ··· 279 280 writeb(~RCAR_CAN_ECSR_AEF, &priv->regs->ecsr); 280 281 if (skb) { 281 282 cf->can_id |= CAN_ERR_ACK; 282 - cf->data[3] |= CAN_ERR_PROT_LOC_ACK; 283 + cf->data[3] = CAN_ERR_PROT_LOC_ACK; 283 284 } 284 285 } 285 286 if (ecsr & RCAR_CAN_ECSR_FEF) {
+3 -1
drivers/net/can/sja1000/sja1000.c
··· 218 218 priv->write_reg(priv, SJA1000_RXERR, 0x0); 219 219 priv->read_reg(priv, SJA1000_ECC); 220 220 221 + /* clear interrupt flags */ 222 + priv->read_reg(priv, SJA1000_IR); 223 + 221 224 /* leave reset mode */ 222 225 set_normal_mode(dev); 223 226 } ··· 449 446 cf->data[2] |= CAN_ERR_PROT_STUFF; 450 447 break; 451 448 default: 452 - cf->data[2] |= CAN_ERR_PROT_UNSPEC; 453 449 cf->data[3] = ecc & ECC_SEG; 454 450 break; 455 451 }
-1
drivers/net/can/sun4i_can.c
··· 575 575 cf->data[2] |= CAN_ERR_PROT_STUFF; 576 576 break; 577 577 default: 578 - cf->data[2] |= CAN_ERR_PROT_UNSPEC; 579 578 cf->data[3] = (ecc & SUN4I_STA_ERR_SEG_CODE) 580 579 >> 16; 581 580 break;
+2 -5
drivers/net/can/ti_hecc.c
··· 722 722 if (err_status & HECC_BUS_ERROR) { 723 723 ++priv->can.can_stats.bus_error; 724 724 cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT; 725 - cf->data[2] |= CAN_ERR_PROT_UNSPEC; 726 725 if (err_status & HECC_CANES_FE) { 727 726 hecc_set_bit(priv, HECC_CANES, HECC_CANES_FE); 728 727 cf->data[2] |= CAN_ERR_PROT_FORM; ··· 736 737 } 737 738 if (err_status & HECC_CANES_CRCE) { 738 739 hecc_set_bit(priv, HECC_CANES, HECC_CANES_CRCE); 739 - cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ | 740 - CAN_ERR_PROT_LOC_CRC_DEL; 740 + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; 741 741 } 742 742 if (err_status & HECC_CANES_ACKE) { 743 743 hecc_set_bit(priv, HECC_CANES, HECC_CANES_ACKE); 744 - cf->data[3] |= CAN_ERR_PROT_LOC_ACK | 745 - CAN_ERR_PROT_LOC_ACK_DEL; 744 + cf->data[3] = CAN_ERR_PROT_LOC_ACK; 746 745 } 747 746 } 748 747
-1
drivers/net/can/usb/ems_usb.c
··· 377 377 cf->data[2] |= CAN_ERR_PROT_STUFF; 378 378 break; 379 379 default: 380 - cf->data[2] |= CAN_ERR_PROT_UNSPEC; 381 380 cf->data[3] = ecc & SJA1000_ECC_SEG; 382 381 break; 383 382 }
-1
drivers/net/can/usb/esd_usb2.c
··· 282 282 cf->data[2] |= CAN_ERR_PROT_STUFF; 283 283 break; 284 284 default: 285 - cf->data[2] |= CAN_ERR_PROT_UNSPEC; 286 285 cf->data[3] = ecc & SJA1000_ECC_SEG; 287 286 break; 288 287 }
+2 -3
drivers/net/can/usb/kvaser_usb.c
··· 944 944 cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT; 945 945 946 946 if (es->leaf.error_factor & M16C_EF_ACKE) 947 - cf->data[3] |= (CAN_ERR_PROT_LOC_ACK); 947 + cf->data[3] = CAN_ERR_PROT_LOC_ACK; 948 948 if (es->leaf.error_factor & M16C_EF_CRCE) 949 - cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ | 950 - CAN_ERR_PROT_LOC_CRC_DEL); 949 + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; 951 950 if (es->leaf.error_factor & M16C_EF_FORME) 952 951 cf->data[2] |= CAN_ERR_PROT_FORM; 953 952 if (es->leaf.error_factor & M16C_EF_STFE)
+1 -3
drivers/net/can/usb/usb_8dev.c
··· 401 401 tx_errors = 1; 402 402 break; 403 403 case USB_8DEV_STATUSMSG_CRC: 404 - cf->data[2] |= CAN_ERR_PROT_UNSPEC; 405 - cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ | 406 - CAN_ERR_PROT_LOC_CRC_DEL; 404 + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; 407 405 rx_errors = 1; 408 406 break; 409 407 case USB_8DEV_STATUSMSG_BIT0:
+3 -6
drivers/net/can/xilinx_can.c
··· 608 608 609 609 /* Check for error interrupt */ 610 610 if (isr & XCAN_IXR_ERROR_MASK) { 611 - if (skb) { 611 + if (skb) 612 612 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; 613 - cf->data[2] |= CAN_ERR_PROT_UNSPEC; 614 - } 615 613 616 614 /* Check for Ack error interrupt */ 617 615 if (err_status & XCAN_ESR_ACKER_MASK) { 618 616 stats->tx_errors++; 619 617 if (skb) { 620 618 cf->can_id |= CAN_ERR_ACK; 621 - cf->data[3] |= CAN_ERR_PROT_LOC_ACK; 619 + cf->data[3] = CAN_ERR_PROT_LOC_ACK; 622 620 } 623 621 } 624 622 ··· 652 654 stats->rx_errors++; 653 655 if (skb) { 654 656 cf->can_id |= CAN_ERR_PROT; 655 - cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ | 656 - CAN_ERR_PROT_LOC_CRC_DEL; 657 + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; 657 658 } 658 659 } 659 660 priv->can.can_stats.bus_error++;
+1
drivers/net/ethernet/Kconfig
··· 29 29 source "drivers/net/ethernet/apple/Kconfig" 30 30 source "drivers/net/ethernet/arc/Kconfig" 31 31 source "drivers/net/ethernet/atheros/Kconfig" 32 + source "drivers/net/ethernet/aurora/Kconfig" 32 33 source "drivers/net/ethernet/cadence/Kconfig" 33 34 source "drivers/net/ethernet/adi/Kconfig" 34 35 source "drivers/net/ethernet/broadcom/Kconfig"
+1
drivers/net/ethernet/Makefile
··· 15 15 obj-$(CONFIG_NET_VENDOR_APPLE) += apple/ 16 16 obj-$(CONFIG_NET_VENDOR_ARC) += arc/ 17 17 obj-$(CONFIG_NET_VENDOR_ATHEROS) += atheros/ 18 + obj-$(CONFIG_NET_VENDOR_AURORA) += aurora/ 18 19 obj-$(CONFIG_NET_CADENCE) += cadence/ 19 20 obj-$(CONFIG_NET_BFIN) += adi/ 20 21 obj-$(CONFIG_NET_VENDOR_BROADCOM) += broadcom/
+19 -16
drivers/net/ethernet/apm/xgene/xgene_enet_main.c
··· 450 450 return NETDEV_TX_OK; 451 451 } 452 452 453 - pdata->ring_ops->wr_cmd(tx_ring, count); 454 453 skb_tx_timestamp(skb); 455 454 456 455 pdata->stats.tx_packets++; 457 456 pdata->stats.tx_bytes += skb->len; 458 457 458 + pdata->ring_ops->wr_cmd(tx_ring, count); 459 459 return NETDEV_TX_OK; 460 460 } 461 461 ··· 688 688 mac_ops->tx_enable(pdata); 689 689 mac_ops->rx_enable(pdata); 690 690 691 + xgene_enet_napi_enable(pdata); 691 692 ret = xgene_enet_register_irq(ndev); 692 693 if (ret) 693 694 return ret; 694 - xgene_enet_napi_enable(pdata); 695 695 696 696 if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) 697 697 phy_start(pdata->phy_dev); ··· 715 715 else 716 716 cancel_delayed_work_sync(&pdata->link_work); 717 717 718 - xgene_enet_napi_disable(pdata); 719 - xgene_enet_free_irq(ndev); 720 - xgene_enet_process_ring(pdata->rx_ring, -1); 721 - 722 718 mac_ops->tx_disable(pdata); 723 719 mac_ops->rx_disable(pdata); 720 + 721 + xgene_enet_free_irq(ndev); 722 + xgene_enet_napi_disable(pdata); 723 + xgene_enet_process_ring(pdata->rx_ring, -1); 724 724 725 725 return 0; 726 726 } ··· 1474 1474 } 1475 1475 ndev->hw_features = ndev->features; 1476 1476 1477 - ret = register_netdev(ndev); 1478 - if (ret) { 1479 - netdev_err(ndev, "Failed to register netdev\n"); 1480 - goto err; 1481 - } 1482 - 1483 1477 ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64)); 1484 1478 if (ret) { 1485 1479 netdev_err(ndev, "No usable DMA configuration\n"); 1480 + goto err; 1481 + } 1482 + 1483 + ret = register_netdev(ndev); 1484 + if (ret) { 1485 + netdev_err(ndev, "Failed to register netdev\n"); 1486 1486 goto err; 1487 1487 } 1488 1488 ··· 1490 1490 if (ret) 1491 1491 goto err; 1492 1492 1493 - xgene_enet_napi_add(pdata); 1494 1493 mac_ops = pdata->mac_ops; 1495 - if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) 1494 + if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) { 1496 1495 ret = xgene_enet_mdio_config(pdata); 1497 - else 1496 + if (ret) 1497 + goto err; 1498 + } else { 1498 1499 INIT_DELAYED_WORK(&pdata->link_work, mac_ops->link_state); 1500 + } 1499 1501 1500 - return ret; 1502 + xgene_enet_napi_add(pdata); 1503 + return 0; 1501 1504 err: 1502 1505 unregister_netdev(ndev); 1503 1506 free_netdev(ndev);
+2
drivers/net/ethernet/atheros/alx/main.c
··· 1534 1534 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, 1535 1535 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2200), 1536 1536 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, 1537 + { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2400), 1538 + .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, 1537 1539 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8162), 1538 1540 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, 1539 1541 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8171) },
+1
drivers/net/ethernet/atheros/alx/reg.h
··· 37 37 38 38 #define ALX_DEV_ID_AR8161 0x1091 39 39 #define ALX_DEV_ID_E2200 0xe091 40 + #define ALX_DEV_ID_E2400 0xe0a1 40 41 #define ALX_DEV_ID_AR8162 0x1090 41 42 #define ALX_DEV_ID_AR8171 0x10A1 42 43 #define ALX_DEV_ID_AR8172 0x10A0
+20
drivers/net/ethernet/aurora/Kconfig
··· 1 + config NET_VENDOR_AURORA 2 + bool "Aurora VLSI devices" 3 + help 4 + If you have a network (Ethernet) device belonging to this class, 5 + say Y. 6 + 7 + Note that the answer to this question doesn't directly affect the 8 + kernel: saying N will just cause the configurator to skip all 9 + questions about Aurora devices. If you say Y, you will be asked 10 + for your specific device in the following questions. 11 + 12 + if NET_VENDOR_AURORA 13 + 14 + config AURORA_NB8800 15 + tristate "Aurora AU-NB8800 support" 16 + select PHYLIB 17 + help 18 + Support for the AU-NB8800 gigabit Ethernet controller. 19 + 20 + endif
+1
drivers/net/ethernet/aurora/Makefile
··· 1 + obj-$(CONFIG_AURORA_NB8800) += nb8800.o
+1552
drivers/net/ethernet/aurora/nb8800.c
··· 1 + /* 2 + * Copyright (C) 2015 Mans Rullgard <mans@mansr.com> 3 + * 4 + * Mostly rewritten, based on driver from Sigma Designs. Original 5 + * copyright notice below. 6 + * 7 + * 8 + * Driver for tangox SMP864x/SMP865x/SMP867x/SMP868x builtin Ethernet Mac. 9 + * 10 + * Copyright (C) 2005 Maxime Bizon <mbizon@freebox.fr> 11 + * 12 + * This program is free software; you can redistribute it and/or modify 13 + * it under the terms of the GNU General Public License as published by 14 + * the Free Software Foundation; either version 2 of the License, or 15 + * (at your option) any later version. 16 + * 17 + * This program is distributed in the hope that it will be useful, 18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 + * GNU General Public License for more details. 21 + */ 22 + 23 + #include <linux/module.h> 24 + #include <linux/etherdevice.h> 25 + #include <linux/delay.h> 26 + #include <linux/ethtool.h> 27 + #include <linux/interrupt.h> 28 + #include <linux/platform_device.h> 29 + #include <linux/of_device.h> 30 + #include <linux/of_mdio.h> 31 + #include <linux/of_net.h> 32 + #include <linux/dma-mapping.h> 33 + #include <linux/phy.h> 34 + #include <linux/cache.h> 35 + #include <linux/jiffies.h> 36 + #include <linux/io.h> 37 + #include <linux/iopoll.h> 38 + #include <asm/barrier.h> 39 + 40 + #include "nb8800.h" 41 + 42 + static void nb8800_tx_done(struct net_device *dev); 43 + static int nb8800_dma_stop(struct net_device *dev); 44 + 45 + static inline u8 nb8800_readb(struct nb8800_priv *priv, int reg) 46 + { 47 + return readb_relaxed(priv->base + reg); 48 + } 49 + 50 + static inline u32 nb8800_readl(struct nb8800_priv *priv, int reg) 51 + { 52 + return readl_relaxed(priv->base + reg); 53 + } 54 + 55 + static inline void nb8800_writeb(struct nb8800_priv *priv, int reg, u8 val) 56 + { 57 + writeb_relaxed(val, priv->base + reg); 58 + } 59 + 60 + static inline void nb8800_writew(struct nb8800_priv *priv, int reg, u16 val) 61 + { 62 + writew_relaxed(val, priv->base + reg); 63 + } 64 + 65 + static inline void nb8800_writel(struct nb8800_priv *priv, int reg, u32 val) 66 + { 67 + writel_relaxed(val, priv->base + reg); 68 + } 69 + 70 + static inline void nb8800_maskb(struct nb8800_priv *priv, int reg, 71 + u32 mask, u32 val) 72 + { 73 + u32 old = nb8800_readb(priv, reg); 74 + u32 new = (old & ~mask) | (val & mask); 75 + 76 + if (new != old) 77 + nb8800_writeb(priv, reg, new); 78 + } 79 + 80 + static inline void nb8800_maskl(struct nb8800_priv *priv, int reg, 81 + u32 mask, u32 val) 82 + { 83 + u32 old = nb8800_readl(priv, reg); 84 + u32 new = (old & ~mask) | (val & mask); 85 + 86 + if (new != old) 87 + nb8800_writel(priv, reg, new); 88 + } 89 + 90 + static inline void nb8800_modb(struct nb8800_priv *priv, int reg, u8 bits, 91 + bool set) 92 + { 93 + nb8800_maskb(priv, reg, bits, set ? bits : 0); 94 + } 95 + 96 + static inline void nb8800_setb(struct nb8800_priv *priv, int reg, u8 bits) 97 + { 98 + nb8800_maskb(priv, reg, bits, bits); 99 + } 100 + 101 + static inline void nb8800_clearb(struct nb8800_priv *priv, int reg, u8 bits) 102 + { 103 + nb8800_maskb(priv, reg, bits, 0); 104 + } 105 + 106 + static inline void nb8800_modl(struct nb8800_priv *priv, int reg, u32 bits, 107 + bool set) 108 + { 109 + nb8800_maskl(priv, reg, bits, set ? bits : 0); 110 + } 111 + 112 + static inline void nb8800_setl(struct nb8800_priv *priv, int reg, u32 bits) 113 + { 114 + nb8800_maskl(priv, reg, bits, bits); 115 + } 116 + 117 + static inline void nb8800_clearl(struct nb8800_priv *priv, int reg, u32 bits) 118 + { 119 + nb8800_maskl(priv, reg, bits, 0); 120 + } 121 + 122 + static int nb8800_mdio_wait(struct mii_bus *bus) 123 + { 124 + struct nb8800_priv *priv = bus->priv; 125 + u32 val; 126 + 127 + return readl_poll_timeout_atomic(priv->base + NB8800_MDIO_CMD, 128 + val, !(val & MDIO_CMD_GO), 1, 1000); 129 + } 130 + 131 + static int nb8800_mdio_cmd(struct mii_bus *bus, u32 cmd) 132 + { 133 + struct nb8800_priv *priv = bus->priv; 134 + int err; 135 + 136 + err = nb8800_mdio_wait(bus); 137 + if (err) 138 + return err; 139 + 140 + nb8800_writel(priv, NB8800_MDIO_CMD, cmd); 141 + udelay(10); 142 + nb8800_writel(priv, NB8800_MDIO_CMD, cmd | MDIO_CMD_GO); 143 + 144 + return nb8800_mdio_wait(bus); 145 + } 146 + 147 + static int nb8800_mdio_read(struct mii_bus *bus, int phy_id, int reg) 148 + { 149 + struct nb8800_priv *priv = bus->priv; 150 + u32 val; 151 + int err; 152 + 153 + err = nb8800_mdio_cmd(bus, MDIO_CMD_ADDR(phy_id) | MDIO_CMD_REG(reg)); 154 + if (err) 155 + return err; 156 + 157 + val = nb8800_readl(priv, NB8800_MDIO_STS); 158 + if (val & MDIO_STS_ERR) 159 + return 0xffff; 160 + 161 + return val & 0xffff; 162 + } 163 + 164 + static int nb8800_mdio_write(struct mii_bus *bus, int phy_id, int reg, u16 val) 165 + { 166 + u32 cmd = MDIO_CMD_ADDR(phy_id) | MDIO_CMD_REG(reg) | 167 + MDIO_CMD_DATA(val) | MDIO_CMD_WR; 168 + 169 + return nb8800_mdio_cmd(bus, cmd); 170 + } 171 + 172 + static void nb8800_mac_tx(struct net_device *dev, bool enable) 173 + { 174 + struct nb8800_priv *priv = netdev_priv(dev); 175 + 176 + while (nb8800_readl(priv, NB8800_TXC_CR) & TCR_EN) 177 + cpu_relax(); 178 + 179 + nb8800_modb(priv, NB8800_TX_CTL1, TX_EN, enable); 180 + } 181 + 182 + static void nb8800_mac_rx(struct net_device *dev, bool enable) 183 + { 184 + nb8800_modb(netdev_priv(dev), NB8800_RX_CTL, RX_EN, enable); 185 + } 186 + 187 + static void nb8800_mac_af(struct net_device *dev, bool enable) 188 + { 189 + nb8800_modb(netdev_priv(dev), NB8800_RX_CTL, RX_AF_EN, enable); 190 + } 191 + 192 + static void nb8800_start_rx(struct net_device *dev) 193 + { 194 + nb8800_setl(netdev_priv(dev), NB8800_RXC_CR, RCR_EN); 195 + } 196 + 197 + static int nb8800_alloc_rx(struct net_device *dev, unsigned int i, bool napi) 198 + { 199 + struct nb8800_priv *priv = netdev_priv(dev); 200 + struct nb8800_rx_desc *rxd = &priv->rx_descs[i]; 201 + struct nb8800_rx_buf *rxb = &priv->rx_bufs[i]; 202 + int size = L1_CACHE_ALIGN(RX_BUF_SIZE); 203 + dma_addr_t dma_addr; 204 + struct page *page; 205 + unsigned long offset; 206 + void *data; 207 + 208 + data = napi ? napi_alloc_frag(size) : netdev_alloc_frag(size); 209 + if (!data) 210 + return -ENOMEM; 211 + 212 + page = virt_to_head_page(data); 213 + offset = data - page_address(page); 214 + 215 + dma_addr = dma_map_page(&dev->dev, page, offset, RX_BUF_SIZE, 216 + DMA_FROM_DEVICE); 217 + 218 + if (dma_mapping_error(&dev->dev, dma_addr)) { 219 + skb_free_frag(data); 220 + return -ENOMEM; 221 + } 222 + 223 + rxb->page = page; 224 + rxb->offset = offset; 225 + rxd->desc.s_addr = dma_addr; 226 + 227 + return 0; 228 + } 229 + 230 + static void nb8800_receive(struct net_device *dev, unsigned int i, 231 + unsigned int len) 232 + { 233 + struct nb8800_priv *priv = netdev_priv(dev); 234 + struct nb8800_rx_desc *rxd = &priv->rx_descs[i]; 235 + struct page *page = priv->rx_bufs[i].page; 236 + int offset = priv->rx_bufs[i].offset; 237 + void *data = page_address(page) + offset; 238 + dma_addr_t dma = rxd->desc.s_addr; 239 + struct sk_buff *skb; 240 + unsigned int size; 241 + int err; 242 + 243 + size = len <= RX_COPYBREAK ? len : RX_COPYHDR; 244 + 245 + skb = napi_alloc_skb(&priv->napi, size); 246 + if (!skb) { 247 + netdev_err(dev, "rx skb allocation failed\n"); 248 + dev->stats.rx_dropped++; 249 + return; 250 + } 251 + 252 + if (len <= RX_COPYBREAK) { 253 + dma_sync_single_for_cpu(&dev->dev, dma, len, DMA_FROM_DEVICE); 254 + memcpy(skb_put(skb, len), data, len); 255 + dma_sync_single_for_device(&dev->dev, dma, len, 256 + DMA_FROM_DEVICE); 257 + } else { 258 + err = nb8800_alloc_rx(dev, i, true); 259 + if (err) { 260 + netdev_err(dev, "rx buffer allocation failed\n"); 261 + dev->stats.rx_dropped++; 262 + return; 263 + } 264 + 265 + dma_unmap_page(&dev->dev, dma, RX_BUF_SIZE, DMA_FROM_DEVICE); 266 + memcpy(skb_put(skb, RX_COPYHDR), data, RX_COPYHDR); 267 + skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, 268 + offset + RX_COPYHDR, len - RX_COPYHDR, 269 + RX_BUF_SIZE); 270 + } 271 + 272 + skb->protocol = eth_type_trans(skb, dev); 273 + napi_gro_receive(&priv->napi, skb); 274 + } 275 + 276 + static void nb8800_rx_error(struct net_device *dev, u32 report) 277 + { 278 + if (report & RX_LENGTH_ERR) 279 + dev->stats.rx_length_errors++; 280 + 281 + if (report & RX_FCS_ERR) 282 + dev->stats.rx_crc_errors++; 283 + 284 + if (report & RX_FIFO_OVERRUN) 285 + dev->stats.rx_fifo_errors++; 286 + 287 + if (report & RX_ALIGNMENT_ERROR) 288 + dev->stats.rx_frame_errors++; 289 + 290 + dev->stats.rx_errors++; 291 + } 292 + 293 + static int nb8800_poll(struct napi_struct *napi, int budget) 294 + { 295 + struct net_device *dev = napi->dev; 296 + struct nb8800_priv *priv = netdev_priv(dev); 297 + struct nb8800_rx_desc *rxd; 298 + unsigned int last = priv->rx_eoc; 299 + unsigned int next; 300 + int work = 0; 301 + 302 + nb8800_tx_done(dev); 303 + 304 + again: 305 + while (work < budget) { 306 + struct nb8800_rx_buf *rxb; 307 + unsigned int len; 308 + 309 + next = (last + 1) % RX_DESC_COUNT; 310 + 311 + rxb = &priv->rx_bufs[next]; 312 + rxd = &priv->rx_descs[next]; 313 + 314 + if (!rxd->report) 315 + break; 316 + 317 + len = RX_BYTES_TRANSFERRED(rxd->report); 318 + 319 + if (IS_RX_ERROR(rxd->report)) 320 + nb8800_rx_error(dev, rxd->report); 321 + else 322 + nb8800_receive(dev, next, len); 323 + 324 + dev->stats.rx_packets++; 325 + dev->stats.rx_bytes += len; 326 + 327 + if (rxd->report & RX_MULTICAST_PKT) 328 + dev->stats.multicast++; 329 + 330 + rxd->report = 0; 331 + last = next; 332 + work++; 333 + } 334 + 335 + if (work) { 336 + priv->rx_descs[last].desc.config |= DESC_EOC; 337 + wmb(); /* ensure new EOC is written before clearing old */ 338 + priv->rx_descs[priv->rx_eoc].desc.config &= ~DESC_EOC; 339 + priv->rx_eoc = last; 340 + nb8800_start_rx(dev); 341 + } 342 + 343 + if (work < budget) { 344 + nb8800_writel(priv, NB8800_RX_ITR, priv->rx_itr_irq); 345 + 346 + /* If a packet arrived after we last checked but 347 + * before writing RX_ITR, the interrupt will be 348 + * delayed, so we retrieve it now. 349 + */ 350 + if (priv->rx_descs[next].report) 351 + goto again; 352 + 353 + napi_complete_done(napi, work); 354 + } 355 + 356 + return work; 357 + } 358 + 359 + static void __nb8800_tx_dma_start(struct net_device *dev) 360 + { 361 + struct nb8800_priv *priv = netdev_priv(dev); 362 + struct nb8800_tx_buf *txb; 363 + u32 txc_cr; 364 + 365 + txb = &priv->tx_bufs[priv->tx_queue]; 366 + if (!txb->ready) 367 + return; 368 + 369 + txc_cr = nb8800_readl(priv, NB8800_TXC_CR); 370 + if (txc_cr & TCR_EN) 371 + return; 372 + 373 + nb8800_writel(priv, NB8800_TX_DESC_ADDR, txb->dma_desc); 374 + wmb(); /* ensure desc addr is written before starting DMA */ 375 + nb8800_writel(priv, NB8800_TXC_CR, txc_cr | TCR_EN); 376 + 377 + priv->tx_queue = (priv->tx_queue + txb->chain_len) % TX_DESC_COUNT; 378 + } 379 + 380 + static void nb8800_tx_dma_start(struct net_device *dev) 381 + { 382 + struct nb8800_priv *priv = netdev_priv(dev); 383 + 384 + spin_lock_irq(&priv->tx_lock); 385 + __nb8800_tx_dma_start(dev); 386 + spin_unlock_irq(&priv->tx_lock); 387 + } 388 + 389 + static void nb8800_tx_dma_start_irq(struct net_device *dev) 390 + { 391 + struct nb8800_priv *priv = netdev_priv(dev); 392 + 393 + spin_lock(&priv->tx_lock); 394 + __nb8800_tx_dma_start(dev); 395 + spin_unlock(&priv->tx_lock); 396 + } 397 + 398 + static int nb8800_xmit(struct sk_buff *skb, struct net_device *dev) 399 + { 400 + struct nb8800_priv *priv = netdev_priv(dev); 401 + struct nb8800_tx_desc *txd; 402 + struct nb8800_tx_buf *txb; 403 + struct nb8800_dma_desc *desc; 404 + dma_addr_t dma_addr; 405 + unsigned int dma_len; 406 + unsigned int align; 407 + unsigned int next; 408 + 409 + if (atomic_read(&priv->tx_free) <= NB8800_DESC_LOW) { 410 + netif_stop_queue(dev); 411 + return NETDEV_TX_BUSY; 412 + } 413 + 414 + align = (8 - (uintptr_t)skb->data) & 7; 415 + 416 + dma_len = skb->len - align; 417 + dma_addr = dma_map_single(&dev->dev, skb->data + align, 418 + dma_len, DMA_TO_DEVICE); 419 + 420 + if (dma_mapping_error(&dev->dev, dma_addr)) { 421 + netdev_err(dev, "tx dma mapping error\n"); 422 + kfree_skb(skb); 423 + dev->stats.tx_dropped++; 424 + return NETDEV_TX_OK; 425 + } 426 + 427 + if (atomic_dec_return(&priv->tx_free) <= NB8800_DESC_LOW) { 428 + netif_stop_queue(dev); 429 + skb->xmit_more = 0; 430 + } 431 + 432 + next = priv->tx_next; 433 + txb = &priv->tx_bufs[next]; 434 + txd = &priv->tx_descs[next]; 435 + desc = &txd->desc[0]; 436 + 437 + next = (next + 1) % TX_DESC_COUNT; 438 + 439 + if (align) { 440 + memcpy(txd->buf, skb->data, align); 441 + 442 + desc->s_addr = 443 + txb->dma_desc + offsetof(struct nb8800_tx_desc, buf); 444 + desc->n_addr = txb->dma_desc + sizeof(txd->desc[0]); 445 + desc->config = DESC_BTS(2) | DESC_DS | align; 446 + 447 + desc++; 448 + } 449 + 450 + desc->s_addr = dma_addr; 451 + desc->n_addr = priv->tx_bufs[next].dma_desc; 452 + desc->config = DESC_BTS(2) | DESC_DS | DESC_EOF | dma_len; 453 + 454 + if (!skb->xmit_more) 455 + desc->config |= DESC_EOC; 456 + 457 + txb->skb = skb; 458 + txb->dma_addr = dma_addr; 459 + txb->dma_len = dma_len; 460 + 461 + if (!priv->tx_chain) { 462 + txb->chain_len = 1; 463 + priv->tx_chain = txb; 464 + } else { 465 + priv->tx_chain->chain_len++; 466 + } 467 + 468 + netdev_sent_queue(dev, skb->len); 469 + 470 + priv->tx_next = next; 471 + 472 + if (!skb->xmit_more) { 473 + smp_wmb(); 474 + priv->tx_chain->ready = true; 475 + priv->tx_chain = NULL; 476 + nb8800_tx_dma_start(dev); 477 + } 478 + 479 + return NETDEV_TX_OK; 480 + } 481 + 482 + static void nb8800_tx_error(struct net_device *dev, u32 report) 483 + { 484 + if (report & TX_LATE_COLLISION) 485 + dev->stats.collisions++; 486 + 487 + if (report & TX_PACKET_DROPPED) 488 + dev->stats.tx_dropped++; 489 + 490 + if (report & TX_FIFO_UNDERRUN) 491 + dev->stats.tx_fifo_errors++; 492 + 493 + dev->stats.tx_errors++; 494 + } 495 + 496 + static void nb8800_tx_done(struct net_device *dev) 497 + { 498 + struct nb8800_priv *priv = netdev_priv(dev); 499 + unsigned int limit = priv->tx_next; 500 + unsigned int done = priv->tx_done; 501 + unsigned int packets = 0; 502 + unsigned int len = 0; 503 + 504 + while (done != limit) { 505 + struct nb8800_tx_desc *txd = &priv->tx_descs[done]; 506 + struct nb8800_tx_buf *txb = &priv->tx_bufs[done]; 507 + struct sk_buff *skb; 508 + 509 + if (!txd->report) 510 + break; 511 + 512 + skb = txb->skb; 513 + len += skb->len; 514 + 515 + dma_unmap_single(&dev->dev, txb->dma_addr, txb->dma_len, 516 + DMA_TO_DEVICE); 517 + 518 + if (IS_TX_ERROR(txd->report)) { 519 + nb8800_tx_error(dev, txd->report); 520 + kfree_skb(skb); 521 + } else { 522 + consume_skb(skb); 523 + } 524 + 525 + dev->stats.tx_packets++; 526 + dev->stats.tx_bytes += TX_BYTES_TRANSFERRED(txd->report); 527 + dev->stats.collisions += TX_EARLY_COLLISIONS(txd->report); 528 + 529 + txb->skb = NULL; 530 + txb->ready = false; 531 + txd->report = 0; 532 + 533 + done = (done + 1) % TX_DESC_COUNT; 534 + packets++; 535 + } 536 + 537 + if (packets) { 538 + smp_mb__before_atomic(); 539 + atomic_add(packets, &priv->tx_free); 540 + netdev_completed_queue(dev, packets, len); 541 + netif_wake_queue(dev); 542 + priv->tx_done = done; 543 + } 544 + } 545 + 546 + static irqreturn_t nb8800_irq(int irq, void *dev_id) 547 + { 548 + struct net_device *dev = dev_id; 549 + struct nb8800_priv *priv = netdev_priv(dev); 550 + irqreturn_t ret = IRQ_NONE; 551 + u32 val; 552 + 553 + /* tx interrupt */ 554 + val = nb8800_readl(priv, NB8800_TXC_SR); 555 + if (val) { 556 + nb8800_writel(priv, NB8800_TXC_SR, val); 557 + 558 + if (val & TSR_DI) 559 + nb8800_tx_dma_start_irq(dev); 560 + 561 + if (val & TSR_TI) 562 + napi_schedule_irqoff(&priv->napi); 563 + 564 + if (unlikely(val & TSR_DE)) 565 + netdev_err(dev, "TX DMA error\n"); 566 + 567 + /* should never happen with automatic status retrieval */ 568 + if (unlikely(val & TSR_TO)) 569 + netdev_err(dev, "TX Status FIFO overflow\n"); 570 + 571 + ret = IRQ_HANDLED; 572 + } 573 + 574 + /* rx interrupt */ 575 + val = nb8800_readl(priv, NB8800_RXC_SR); 576 + if (val) { 577 + nb8800_writel(priv, NB8800_RXC_SR, val); 578 + 579 + if (likely(val & (RSR_RI | RSR_DI))) { 580 + nb8800_writel(priv, NB8800_RX_ITR, priv->rx_itr_poll); 581 + napi_schedule_irqoff(&priv->napi); 582 + } 583 + 584 + if (unlikely(val & RSR_DE)) 585 + netdev_err(dev, "RX DMA error\n"); 586 + 587 + /* should never happen with automatic status retrieval */ 588 + if (unlikely(val & RSR_RO)) 589 + netdev_err(dev, "RX Status FIFO overflow\n"); 590 + 591 + ret = IRQ_HANDLED; 592 + } 593 + 594 + return ret; 595 + } 596 + 597 + static void nb8800_mac_config(struct net_device *dev) 598 + { 599 + struct nb8800_priv *priv = netdev_priv(dev); 600 + bool gigabit = priv->speed == SPEED_1000; 601 + u32 mac_mode_mask = RGMII_MODE | HALF_DUPLEX | GMAC_MODE; 602 + u32 mac_mode = 0; 603 + u32 slot_time; 604 + u32 phy_clk; 605 + u32 ict; 606 + 607 + if (!priv->duplex) 608 + mac_mode |= HALF_DUPLEX; 609 + 610 + if (gigabit) { 611 + if (priv->phy_mode == PHY_INTERFACE_MODE_RGMII) 612 + mac_mode |= RGMII_MODE; 613 + 614 + mac_mode |= GMAC_MODE; 615 + phy_clk = 125000000; 616 + 617 + /* Should be 512 but register is only 8 bits */ 618 + slot_time = 255; 619 + } else { 620 + phy_clk = 25000000; 621 + slot_time = 128; 622 + } 623 + 624 + ict = DIV_ROUND_UP(phy_clk, clk_get_rate(priv->clk)); 625 + 626 + nb8800_writeb(priv, NB8800_IC_THRESHOLD, ict); 627 + nb8800_writeb(priv, NB8800_SLOT_TIME, slot_time); 628 + nb8800_maskb(priv, NB8800_MAC_MODE, mac_mode_mask, mac_mode); 629 + } 630 + 631 + static void nb8800_pause_config(struct net_device *dev) 632 + { 633 + struct nb8800_priv *priv = netdev_priv(dev); 634 + struct phy_device *phydev = priv->phydev; 635 + u32 rxcr; 636 + 637 + if (priv->pause_aneg) { 638 + if (!phydev || !phydev->link) 639 + return; 640 + 641 + priv->pause_rx = phydev->pause; 642 + priv->pause_tx = phydev->pause ^ phydev->asym_pause; 643 + } 644 + 645 + nb8800_modb(priv, NB8800_RX_CTL, RX_PAUSE_EN, priv->pause_rx); 646 + 647 + rxcr = nb8800_readl(priv, NB8800_RXC_CR); 648 + if (!!(rxcr & RCR_FL) == priv->pause_tx) 649 + return; 650 + 651 + if (netif_running(dev)) { 652 + napi_disable(&priv->napi); 653 + netif_tx_lock_bh(dev); 654 + nb8800_dma_stop(dev); 655 + nb8800_modl(priv, NB8800_RXC_CR, RCR_FL, priv->pause_tx); 656 + nb8800_start_rx(dev); 657 + netif_tx_unlock_bh(dev); 658 + napi_enable(&priv->napi); 659 + } else { 660 + nb8800_modl(priv, NB8800_RXC_CR, RCR_FL, priv->pause_tx); 661 + } 662 + } 663 + 664 + static void nb8800_link_reconfigure(struct net_device *dev) 665 + { 666 + struct nb8800_priv *priv = netdev_priv(dev); 667 + struct phy_device *phydev = priv->phydev; 668 + int change = 0; 669 + 670 + if (phydev->link) { 671 + if (phydev->speed != priv->speed) { 672 + priv->speed = phydev->speed; 673 + change = 1; 674 + } 675 + 676 + if (phydev->duplex != priv->duplex) { 677 + priv->duplex = phydev->duplex; 678 + change = 1; 679 + } 680 + 681 + if (change) 682 + nb8800_mac_config(dev); 683 + 684 + nb8800_pause_config(dev); 685 + } 686 + 687 + if (phydev->link != priv->link) { 688 + priv->link = phydev->link; 689 + change = 1; 690 + } 691 + 692 + if (change) 693 + phy_print_status(priv->phydev); 694 + } 695 + 696 + static void nb8800_update_mac_addr(struct net_device *dev) 697 + { 698 + struct nb8800_priv *priv = netdev_priv(dev); 699 + int i; 700 + 701 + for (i = 0; i < ETH_ALEN; i++) 702 + nb8800_writeb(priv, NB8800_SRC_ADDR(i), dev->dev_addr[i]); 703 + 704 + for (i = 0; i < ETH_ALEN; i++) 705 + nb8800_writeb(priv, NB8800_UC_ADDR(i), dev->dev_addr[i]); 706 + } 707 + 708 + static int nb8800_set_mac_address(struct net_device *dev, void *addr) 709 + { 710 + struct sockaddr *sock = addr; 711 + 712 + if (netif_running(dev)) 713 + return -EBUSY; 714 + 715 + ether_addr_copy(dev->dev_addr, sock->sa_data); 716 + nb8800_update_mac_addr(dev); 717 + 718 + return 0; 719 + } 720 + 721 + static void nb8800_mc_init(struct net_device *dev, int val) 722 + { 723 + struct nb8800_priv *priv = netdev_priv(dev); 724 + 725 + nb8800_writeb(priv, NB8800_MC_INIT, val); 726 + readb_poll_timeout_atomic(priv->base + NB8800_MC_INIT, val, !val, 727 + 1, 1000); 728 + } 729 + 730 + static void nb8800_set_rx_mode(struct net_device *dev) 731 + { 732 + struct nb8800_priv *priv = netdev_priv(dev); 733 + struct netdev_hw_addr *ha; 734 + int i; 735 + 736 + if (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) { 737 + nb8800_mac_af(dev, false); 738 + return; 739 + } 740 + 741 + nb8800_mac_af(dev, true); 742 + nb8800_mc_init(dev, 0); 743 + 744 + netdev_for_each_mc_addr(ha, dev) { 745 + for (i = 0; i < ETH_ALEN; i++) 746 + nb8800_writeb(priv, NB8800_MC_ADDR(i), ha->addr[i]); 747 + 748 + nb8800_mc_init(dev, 0xff); 749 + } 750 + } 751 + 752 + #define RX_DESC_SIZE (RX_DESC_COUNT * sizeof(struct nb8800_rx_desc)) 753 + #define TX_DESC_SIZE (TX_DESC_COUNT * sizeof(struct nb8800_tx_desc)) 754 + 755 + static void nb8800_dma_free(struct net_device *dev) 756 + { 757 + struct nb8800_priv *priv = netdev_priv(dev); 758 + unsigned int i; 759 + 760 + if (priv->rx_bufs) { 761 + for (i = 0; i < RX_DESC_COUNT; i++) 762 + if (priv->rx_bufs[i].page) 763 + put_page(priv->rx_bufs[i].page); 764 + 765 + kfree(priv->rx_bufs); 766 + priv->rx_bufs = NULL; 767 + } 768 + 769 + if (priv->tx_bufs) { 770 + for (i = 0; i < TX_DESC_COUNT; i++) 771 + kfree_skb(priv->tx_bufs[i].skb); 772 + 773 + kfree(priv->tx_bufs); 774 + priv->tx_bufs = NULL; 775 + } 776 + 777 + if (priv->rx_descs) { 778 + dma_free_coherent(dev->dev.parent, RX_DESC_SIZE, priv->rx_descs, 779 + priv->rx_desc_dma); 780 + priv->rx_descs = NULL; 781 + } 782 + 783 + if (priv->tx_descs) { 784 + dma_free_coherent(dev->dev.parent, TX_DESC_SIZE, priv->tx_descs, 785 + priv->tx_desc_dma); 786 + priv->tx_descs = NULL; 787 + } 788 + } 789 + 790 + static void nb8800_dma_reset(struct net_device *dev) 791 + { 792 + struct nb8800_priv *priv = netdev_priv(dev); 793 + struct nb8800_rx_desc *rxd; 794 + struct nb8800_tx_desc *txd; 795 + unsigned int i; 796 + 797 + for (i = 0; i < RX_DESC_COUNT; i++) { 798 + dma_addr_t rx_dma = priv->rx_desc_dma + i * sizeof(*rxd); 799 + 800 + rxd = &priv->rx_descs[i]; 801 + rxd->desc.n_addr = rx_dma + sizeof(*rxd); 802 + rxd->desc.r_addr = 803 + rx_dma + offsetof(struct nb8800_rx_desc, report); 804 + rxd->desc.config = priv->rx_dma_config; 805 + rxd->report = 0; 806 + } 807 + 808 + rxd->desc.n_addr = priv->rx_desc_dma; 809 + rxd->desc.config |= DESC_EOC; 810 + 811 + priv->rx_eoc = RX_DESC_COUNT - 1; 812 + 813 + for (i = 0; i < TX_DESC_COUNT; i++) { 814 + struct nb8800_tx_buf *txb = &priv->tx_bufs[i]; 815 + dma_addr_t r_dma = txb->dma_desc + 816 + offsetof(struct nb8800_tx_desc, report); 817 + 818 + txd = &priv->tx_descs[i]; 819 + txd->desc[0].r_addr = r_dma; 820 + txd->desc[1].r_addr = r_dma; 821 + txd->report = 0; 822 + } 823 + 824 + priv->tx_next = 0; 825 + priv->tx_queue = 0; 826 + priv->tx_done = 0; 827 + atomic_set(&priv->tx_free, TX_DESC_COUNT); 828 + 829 + nb8800_writel(priv, NB8800_RX_DESC_ADDR, priv->rx_desc_dma); 830 + 831 + wmb(); /* ensure all setup is written before starting */ 832 + } 833 + 834 + static int nb8800_dma_init(struct net_device *dev) 835 + { 836 + struct nb8800_priv *priv = netdev_priv(dev); 837 + unsigned int n_rx = RX_DESC_COUNT; 838 + unsigned int n_tx = TX_DESC_COUNT; 839 + unsigned int i; 840 + int err; 841 + 842 + priv->rx_descs = dma_alloc_coherent(dev->dev.parent, RX_DESC_SIZE, 843 + &priv->rx_desc_dma, GFP_KERNEL); 844 + if (!priv->rx_descs) 845 + goto err_out; 846 + 847 + priv->rx_bufs = kcalloc(n_rx, sizeof(*priv->rx_bufs), GFP_KERNEL); 848 + if (!priv->rx_bufs) 849 + goto err_out; 850 + 851 + for (i = 0; i < n_rx; i++) { 852 + err = nb8800_alloc_rx(dev, i, false); 853 + if (err) 854 + goto err_out; 855 + } 856 + 857 + priv->tx_descs = dma_alloc_coherent(dev->dev.parent, TX_DESC_SIZE, 858 + &priv->tx_desc_dma, GFP_KERNEL); 859 + if (!priv->tx_descs) 860 + goto err_out; 861 + 862 + priv->tx_bufs = kcalloc(n_tx, sizeof(*priv->tx_bufs), GFP_KERNEL); 863 + if (!priv->tx_bufs) 864 + goto err_out; 865 + 866 + for (i = 0; i < n_tx; i++) 867 + priv->tx_bufs[i].dma_desc = 868 + priv->tx_desc_dma + i * sizeof(struct nb8800_tx_desc); 869 + 870 + nb8800_dma_reset(dev); 871 + 872 + return 0; 873 + 874 + err_out: 875 + nb8800_dma_free(dev); 876 + 877 + return -ENOMEM; 878 + } 879 + 880 + static int nb8800_dma_stop(struct net_device *dev) 881 + { 882 + struct nb8800_priv *priv = netdev_priv(dev); 883 + struct nb8800_tx_buf *txb = &priv->tx_bufs[0]; 884 + struct nb8800_tx_desc *txd = &priv->tx_descs[0]; 885 + int retry = 5; 886 + u32 txcr; 887 + u32 rxcr; 888 + int err; 889 + unsigned int i; 890 + 891 + /* wait for tx to finish */ 892 + err = readl_poll_timeout_atomic(priv->base + NB8800_TXC_CR, txcr, 893 + !(txcr & TCR_EN) && 894 + priv->tx_done == priv->tx_next, 895 + 1000, 1000000); 896 + if (err) 897 + return err; 898 + 899 + /* The rx DMA only stops if it reaches the end of chain. 900 + * To make this happen, we set the EOC flag on all rx 901 + * descriptors, put the device in loopback mode, and send 902 + * a few dummy frames. The interrupt handler will ignore 903 + * these since NAPI is disabled and no real frames are in 904 + * the tx queue. 905 + */ 906 + 907 + for (i = 0; i < RX_DESC_COUNT; i++) 908 + priv->rx_descs[i].desc.config |= DESC_EOC; 909 + 910 + txd->desc[0].s_addr = 911 + txb->dma_desc + offsetof(struct nb8800_tx_desc, buf); 912 + txd->desc[0].config = DESC_BTS(2) | DESC_DS | DESC_EOF | DESC_EOC | 8; 913 + memset(txd->buf, 0, sizeof(txd->buf)); 914 + 915 + nb8800_mac_af(dev, false); 916 + nb8800_setb(priv, NB8800_MAC_MODE, LOOPBACK_EN); 917 + 918 + do { 919 + nb8800_writel(priv, NB8800_TX_DESC_ADDR, txb->dma_desc); 920 + wmb(); 921 + nb8800_writel(priv, NB8800_TXC_CR, txcr | TCR_EN); 922 + 923 + err = readl_poll_timeout_atomic(priv->base + NB8800_RXC_CR, 924 + rxcr, !(rxcr & RCR_EN), 925 + 1000, 100000); 926 + } while (err && --retry); 927 + 928 + nb8800_mac_af(dev, true); 929 + nb8800_clearb(priv, NB8800_MAC_MODE, LOOPBACK_EN); 930 + nb8800_dma_reset(dev); 931 + 932 + return retry ? 0 : -ETIMEDOUT; 933 + } 934 + 935 + static void nb8800_pause_adv(struct net_device *dev) 936 + { 937 + struct nb8800_priv *priv = netdev_priv(dev); 938 + u32 adv = 0; 939 + 940 + if (!priv->phydev) 941 + return; 942 + 943 + if (priv->pause_rx) 944 + adv |= ADVERTISED_Pause | ADVERTISED_Asym_Pause; 945 + if (priv->pause_tx) 946 + adv ^= ADVERTISED_Asym_Pause; 947 + 948 + priv->phydev->supported |= adv; 949 + priv->phydev->advertising |= adv; 950 + } 951 + 952 + static int nb8800_open(struct net_device *dev) 953 + { 954 + struct nb8800_priv *priv = netdev_priv(dev); 955 + int err; 956 + 957 + /* clear any pending interrupts */ 958 + nb8800_writel(priv, NB8800_RXC_SR, 0xf); 959 + nb8800_writel(priv, NB8800_TXC_SR, 0xf); 960 + 961 + err = nb8800_dma_init(dev); 962 + if (err) 963 + return err; 964 + 965 + err = request_irq(dev->irq, nb8800_irq, 0, dev_name(&dev->dev), dev); 966 + if (err) 967 + goto err_free_dma; 968 + 969 + nb8800_mac_rx(dev, true); 970 + nb8800_mac_tx(dev, true); 971 + 972 + priv->phydev = of_phy_connect(dev, priv->phy_node, 973 + nb8800_link_reconfigure, 0, 974 + priv->phy_mode); 975 + if (!priv->phydev) 976 + goto err_free_irq; 977 + 978 + nb8800_pause_adv(dev); 979 + 980 + netdev_reset_queue(dev); 981 + napi_enable(&priv->napi); 982 + netif_start_queue(dev); 983 + 984 + nb8800_start_rx(dev); 985 + phy_start(priv->phydev); 986 + 987 + return 0; 988 + 989 + err_free_irq: 990 + free_irq(dev->irq, dev); 991 + err_free_dma: 992 + nb8800_dma_free(dev); 993 + 994 + return err; 995 + } 996 + 997 + static int nb8800_stop(struct net_device *dev) 998 + { 999 + struct nb8800_priv *priv = netdev_priv(dev); 1000 + 1001 + phy_stop(priv->phydev); 1002 + 1003 + netif_stop_queue(dev); 1004 + napi_disable(&priv->napi); 1005 + 1006 + nb8800_dma_stop(dev); 1007 + nb8800_mac_rx(dev, false); 1008 + nb8800_mac_tx(dev, false); 1009 + 1010 + phy_disconnect(priv->phydev); 1011 + priv->phydev = NULL; 1012 + 1013 + free_irq(dev->irq, dev); 1014 + 1015 + nb8800_dma_free(dev); 1016 + 1017 + return 0; 1018 + } 1019 + 1020 + static int nb8800_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1021 + { 1022 + struct nb8800_priv *priv = netdev_priv(dev); 1023 + 1024 + return phy_mii_ioctl(priv->phydev, rq, cmd); 1025 + } 1026 + 1027 + static const struct net_device_ops nb8800_netdev_ops = { 1028 + .ndo_open = nb8800_open, 1029 + .ndo_stop = nb8800_stop, 1030 + .ndo_start_xmit = nb8800_xmit, 1031 + .ndo_set_mac_address = nb8800_set_mac_address, 1032 + .ndo_set_rx_mode = nb8800_set_rx_mode, 1033 + .ndo_do_ioctl = nb8800_ioctl, 1034 + .ndo_change_mtu = eth_change_mtu, 1035 + .ndo_validate_addr = eth_validate_addr, 1036 + }; 1037 + 1038 + static int nb8800_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 1039 + { 1040 + struct nb8800_priv *priv = netdev_priv(dev); 1041 + 1042 + if (!priv->phydev) 1043 + return -ENODEV; 1044 + 1045 + return phy_ethtool_gset(priv->phydev, cmd); 1046 + } 1047 + 1048 + static int nb8800_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 1049 + { 1050 + struct nb8800_priv *priv = netdev_priv(dev); 1051 + 1052 + if (!priv->phydev) 1053 + return -ENODEV; 1054 + 1055 + return phy_ethtool_sset(priv->phydev, cmd); 1056 + } 1057 + 1058 + static int nb8800_nway_reset(struct net_device *dev) 1059 + { 1060 + struct nb8800_priv *priv = netdev_priv(dev); 1061 + 1062 + if (!priv->phydev) 1063 + return -ENODEV; 1064 + 1065 + return genphy_restart_aneg(priv->phydev); 1066 + } 1067 + 1068 + static void nb8800_get_pauseparam(struct net_device *dev, 1069 + struct ethtool_pauseparam *pp) 1070 + { 1071 + struct nb8800_priv *priv = netdev_priv(dev); 1072 + 1073 + pp->autoneg = priv->pause_aneg; 1074 + pp->rx_pause = priv->pause_rx; 1075 + pp->tx_pause = priv->pause_tx; 1076 + } 1077 + 1078 + static int nb8800_set_pauseparam(struct net_device *dev, 1079 + struct ethtool_pauseparam *pp) 1080 + { 1081 + struct nb8800_priv *priv = netdev_priv(dev); 1082 + 1083 + priv->pause_aneg = pp->autoneg; 1084 + priv->pause_rx = pp->rx_pause; 1085 + priv->pause_tx = pp->tx_pause; 1086 + 1087 + nb8800_pause_adv(dev); 1088 + 1089 + if (!priv->pause_aneg) 1090 + nb8800_pause_config(dev); 1091 + else if (priv->phydev) 1092 + phy_start_aneg(priv->phydev); 1093 + 1094 + return 0; 1095 + } 1096 + 1097 + static const char nb8800_stats_names[][ETH_GSTRING_LEN] = { 1098 + "rx_bytes_ok", 1099 + "rx_frames_ok", 1100 + "rx_undersize_frames", 1101 + "rx_fragment_frames", 1102 + "rx_64_byte_frames", 1103 + "rx_127_byte_frames", 1104 + "rx_255_byte_frames", 1105 + "rx_511_byte_frames", 1106 + "rx_1023_byte_frames", 1107 + "rx_max_size_frames", 1108 + "rx_oversize_frames", 1109 + "rx_bad_fcs_frames", 1110 + "rx_broadcast_frames", 1111 + "rx_multicast_frames", 1112 + "rx_control_frames", 1113 + "rx_pause_frames", 1114 + "rx_unsup_control_frames", 1115 + "rx_align_error_frames", 1116 + "rx_overrun_frames", 1117 + "rx_jabber_frames", 1118 + "rx_bytes", 1119 + "rx_frames", 1120 + 1121 + "tx_bytes_ok", 1122 + "tx_frames_ok", 1123 + "tx_64_byte_frames", 1124 + "tx_127_byte_frames", 1125 + "tx_255_byte_frames", 1126 + "tx_511_byte_frames", 1127 + "tx_1023_byte_frames", 1128 + "tx_max_size_frames", 1129 + "tx_oversize_frames", 1130 + "tx_broadcast_frames", 1131 + "tx_multicast_frames", 1132 + "tx_control_frames", 1133 + "tx_pause_frames", 1134 + "tx_underrun_frames", 1135 + "tx_single_collision_frames", 1136 + "tx_multi_collision_frames", 1137 + "tx_deferred_collision_frames", 1138 + "tx_late_collision_frames", 1139 + "tx_excessive_collision_frames", 1140 + "tx_bytes", 1141 + "tx_frames", 1142 + "tx_collisions", 1143 + }; 1144 + 1145 + #define NB8800_NUM_STATS ARRAY_SIZE(nb8800_stats_names) 1146 + 1147 + static int nb8800_get_sset_count(struct net_device *dev, int sset) 1148 + { 1149 + if (sset == ETH_SS_STATS) 1150 + return NB8800_NUM_STATS; 1151 + 1152 + return -EOPNOTSUPP; 1153 + } 1154 + 1155 + static void nb8800_get_strings(struct net_device *dev, u32 sset, u8 *buf) 1156 + { 1157 + if (sset == ETH_SS_STATS) 1158 + memcpy(buf, &nb8800_stats_names, sizeof(nb8800_stats_names)); 1159 + } 1160 + 1161 + static u32 nb8800_read_stat(struct net_device *dev, int index) 1162 + { 1163 + struct nb8800_priv *priv = netdev_priv(dev); 1164 + 1165 + nb8800_writeb(priv, NB8800_STAT_INDEX, index); 1166 + 1167 + return nb8800_readl(priv, NB8800_STAT_DATA); 1168 + } 1169 + 1170 + static void nb8800_get_ethtool_stats(struct net_device *dev, 1171 + struct ethtool_stats *estats, u64 *st) 1172 + { 1173 + unsigned int i; 1174 + u32 rx, tx; 1175 + 1176 + for (i = 0; i < NB8800_NUM_STATS / 2; i++) { 1177 + rx = nb8800_read_stat(dev, i); 1178 + tx = nb8800_read_stat(dev, i | 0x80); 1179 + st[i] = rx; 1180 + st[i + NB8800_NUM_STATS / 2] = tx; 1181 + } 1182 + } 1183 + 1184 + static const struct ethtool_ops nb8800_ethtool_ops = { 1185 + .get_settings = nb8800_get_settings, 1186 + .set_settings = nb8800_set_settings, 1187 + .nway_reset = nb8800_nway_reset, 1188 + .get_link = ethtool_op_get_link, 1189 + .get_pauseparam = nb8800_get_pauseparam, 1190 + .set_pauseparam = nb8800_set_pauseparam, 1191 + .get_sset_count = nb8800_get_sset_count, 1192 + .get_strings = nb8800_get_strings, 1193 + .get_ethtool_stats = nb8800_get_ethtool_stats, 1194 + }; 1195 + 1196 + static int nb8800_hw_init(struct net_device *dev) 1197 + { 1198 + struct nb8800_priv *priv = netdev_priv(dev); 1199 + u32 val; 1200 + 1201 + val = TX_RETRY_EN | TX_PAD_EN | TX_APPEND_FCS; 1202 + nb8800_writeb(priv, NB8800_TX_CTL1, val); 1203 + 1204 + /* Collision retry count */ 1205 + nb8800_writeb(priv, NB8800_TX_CTL2, 5); 1206 + 1207 + val = RX_PAD_STRIP | RX_AF_EN; 1208 + nb8800_writeb(priv, NB8800_RX_CTL, val); 1209 + 1210 + /* Chosen by fair dice roll */ 1211 + nb8800_writeb(priv, NB8800_RANDOM_SEED, 4); 1212 + 1213 + /* TX cycles per deferral period */ 1214 + nb8800_writeb(priv, NB8800_TX_SDP, 12); 1215 + 1216 + /* The following three threshold values have been 1217 + * experimentally determined for good results. 1218 + */ 1219 + 1220 + /* RX/TX FIFO threshold for partial empty (64-bit entries) */ 1221 + nb8800_writeb(priv, NB8800_PE_THRESHOLD, 0); 1222 + 1223 + /* RX/TX FIFO threshold for partial full (64-bit entries) */ 1224 + nb8800_writeb(priv, NB8800_PF_THRESHOLD, 255); 1225 + 1226 + /* Buffer size for transmit (64-bit entries) */ 1227 + nb8800_writeb(priv, NB8800_TX_BUFSIZE, 64); 1228 + 1229 + /* Configure tx DMA */ 1230 + 1231 + val = nb8800_readl(priv, NB8800_TXC_CR); 1232 + val &= TCR_LE; /* keep endian setting */ 1233 + val |= TCR_DM; /* DMA descriptor mode */ 1234 + val |= TCR_RS; /* automatically store tx status */ 1235 + val |= TCR_DIE; /* interrupt on DMA chain completion */ 1236 + val |= TCR_TFI(7); /* interrupt after 7 frames transmitted */ 1237 + val |= TCR_BTS(2); /* 32-byte bus transaction size */ 1238 + nb8800_writel(priv, NB8800_TXC_CR, val); 1239 + 1240 + /* TX complete interrupt after 10 ms or 7 frames (see above) */ 1241 + val = clk_get_rate(priv->clk) / 100; 1242 + nb8800_writel(priv, NB8800_TX_ITR, val); 1243 + 1244 + /* Configure rx DMA */ 1245 + 1246 + val = nb8800_readl(priv, NB8800_RXC_CR); 1247 + val &= RCR_LE; /* keep endian setting */ 1248 + val |= RCR_DM; /* DMA descriptor mode */ 1249 + val |= RCR_RS; /* automatically store rx status */ 1250 + val |= RCR_DIE; /* interrupt at end of DMA chain */ 1251 + val |= RCR_RFI(7); /* interrupt after 7 frames received */ 1252 + val |= RCR_BTS(2); /* 32-byte bus transaction size */ 1253 + nb8800_writel(priv, NB8800_RXC_CR, val); 1254 + 1255 + /* The rx interrupt can fire before the DMA has completed 1256 + * unless a small delay is added. 50 us is hopefully enough. 1257 + */ 1258 + priv->rx_itr_irq = clk_get_rate(priv->clk) / 20000; 1259 + 1260 + /* In NAPI poll mode we want to disable interrupts, but the 1261 + * hardware does not permit this. Delay 10 ms instead. 1262 + */ 1263 + priv->rx_itr_poll = clk_get_rate(priv->clk) / 100; 1264 + 1265 + nb8800_writel(priv, NB8800_RX_ITR, priv->rx_itr_irq); 1266 + 1267 + priv->rx_dma_config = RX_BUF_SIZE | DESC_BTS(2) | DESC_DS | DESC_EOF; 1268 + 1269 + /* Flow control settings */ 1270 + 1271 + /* Pause time of 0.1 ms */ 1272 + val = 100000 / 512; 1273 + nb8800_writeb(priv, NB8800_PQ1, val >> 8); 1274 + nb8800_writeb(priv, NB8800_PQ2, val & 0xff); 1275 + 1276 + /* Auto-negotiate by default */ 1277 + priv->pause_aneg = true; 1278 + priv->pause_rx = true; 1279 + priv->pause_tx = true; 1280 + 1281 + nb8800_mc_init(dev, 0); 1282 + 1283 + return 0; 1284 + } 1285 + 1286 + static int nb8800_tangox_init(struct net_device *dev) 1287 + { 1288 + struct nb8800_priv *priv = netdev_priv(dev); 1289 + u32 pad_mode = PAD_MODE_MII; 1290 + 1291 + switch (priv->phy_mode) { 1292 + case PHY_INTERFACE_MODE_MII: 1293 + case PHY_INTERFACE_MODE_GMII: 1294 + pad_mode = PAD_MODE_MII; 1295 + break; 1296 + 1297 + case PHY_INTERFACE_MODE_RGMII: 1298 + pad_mode = PAD_MODE_RGMII; 1299 + break; 1300 + 1301 + case PHY_INTERFACE_MODE_RGMII_TXID: 1302 + pad_mode = PAD_MODE_RGMII | PAD_MODE_GTX_CLK_DELAY; 1303 + break; 1304 + 1305 + default: 1306 + dev_err(dev->dev.parent, "unsupported phy mode %s\n", 1307 + phy_modes(priv->phy_mode)); 1308 + return -EINVAL; 1309 + } 1310 + 1311 + nb8800_writeb(priv, NB8800_TANGOX_PAD_MODE, pad_mode); 1312 + 1313 + return 0; 1314 + } 1315 + 1316 + static int nb8800_tangox_reset(struct net_device *dev) 1317 + { 1318 + struct nb8800_priv *priv = netdev_priv(dev); 1319 + int clk_div; 1320 + 1321 + nb8800_writeb(priv, NB8800_TANGOX_RESET, 0); 1322 + usleep_range(1000, 10000); 1323 + nb8800_writeb(priv, NB8800_TANGOX_RESET, 1); 1324 + 1325 + wmb(); /* ensure reset is cleared before proceeding */ 1326 + 1327 + clk_div = DIV_ROUND_UP(clk_get_rate(priv->clk), 2 * MAX_MDC_CLOCK); 1328 + nb8800_writew(priv, NB8800_TANGOX_MDIO_CLKDIV, clk_div); 1329 + 1330 + return 0; 1331 + } 1332 + 1333 + static const struct nb8800_ops nb8800_tangox_ops = { 1334 + .init = nb8800_tangox_init, 1335 + .reset = nb8800_tangox_reset, 1336 + }; 1337 + 1338 + static int nb8800_tango4_init(struct net_device *dev) 1339 + { 1340 + struct nb8800_priv *priv = netdev_priv(dev); 1341 + int err; 1342 + 1343 + err = nb8800_tangox_init(dev); 1344 + if (err) 1345 + return err; 1346 + 1347 + /* On tango4 interrupt on DMA completion per frame works and gives 1348 + * better performance despite generating more rx interrupts. 1349 + */ 1350 + 1351 + /* Disable unnecessary interrupt on rx completion */ 1352 + nb8800_clearl(priv, NB8800_RXC_CR, RCR_RFI(7)); 1353 + 1354 + /* Request interrupt on descriptor DMA completion */ 1355 + priv->rx_dma_config |= DESC_ID; 1356 + 1357 + return 0; 1358 + } 1359 + 1360 + static const struct nb8800_ops nb8800_tango4_ops = { 1361 + .init = nb8800_tango4_init, 1362 + .reset = nb8800_tangox_reset, 1363 + }; 1364 + 1365 + static const struct of_device_id nb8800_dt_ids[] = { 1366 + { 1367 + .compatible = "aurora,nb8800", 1368 + }, 1369 + { 1370 + .compatible = "sigma,smp8642-ethernet", 1371 + .data = &nb8800_tangox_ops, 1372 + }, 1373 + { 1374 + .compatible = "sigma,smp8734-ethernet", 1375 + .data = &nb8800_tango4_ops, 1376 + }, 1377 + { } 1378 + }; 1379 + 1380 + static int nb8800_probe(struct platform_device *pdev) 1381 + { 1382 + const struct of_device_id *match; 1383 + const struct nb8800_ops *ops = NULL; 1384 + struct nb8800_priv *priv; 1385 + struct resource *res; 1386 + struct net_device *dev; 1387 + struct mii_bus *bus; 1388 + const unsigned char *mac; 1389 + void __iomem *base; 1390 + int irq; 1391 + int ret; 1392 + 1393 + match = of_match_device(nb8800_dt_ids, &pdev->dev); 1394 + if (match) 1395 + ops = match->data; 1396 + 1397 + irq = platform_get_irq(pdev, 0); 1398 + if (irq <= 0) { 1399 + dev_err(&pdev->dev, "No IRQ\n"); 1400 + return -EINVAL; 1401 + } 1402 + 1403 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1404 + base = devm_ioremap_resource(&pdev->dev, res); 1405 + if (IS_ERR(base)) 1406 + return PTR_ERR(base); 1407 + 1408 + dev_dbg(&pdev->dev, "AU-NB8800 Ethernet at %pa\n", &res->start); 1409 + 1410 + dev = alloc_etherdev(sizeof(*priv)); 1411 + if (!dev) 1412 + return -ENOMEM; 1413 + 1414 + platform_set_drvdata(pdev, dev); 1415 + SET_NETDEV_DEV(dev, &pdev->dev); 1416 + 1417 + priv = netdev_priv(dev); 1418 + priv->base = base; 1419 + 1420 + priv->phy_mode = of_get_phy_mode(pdev->dev.of_node); 1421 + if (priv->phy_mode < 0) 1422 + priv->phy_mode = PHY_INTERFACE_MODE_RGMII; 1423 + 1424 + priv->clk = devm_clk_get(&pdev->dev, NULL); 1425 + if (IS_ERR(priv->clk)) { 1426 + dev_err(&pdev->dev, "failed to get clock\n"); 1427 + ret = PTR_ERR(priv->clk); 1428 + goto err_free_dev; 1429 + } 1430 + 1431 + ret = clk_prepare_enable(priv->clk); 1432 + if (ret) 1433 + goto err_free_dev; 1434 + 1435 + spin_lock_init(&priv->tx_lock); 1436 + 1437 + if (ops && ops->reset) { 1438 + ret = ops->reset(dev); 1439 + if (ret) 1440 + goto err_free_dev; 1441 + } 1442 + 1443 + bus = devm_mdiobus_alloc(&pdev->dev); 1444 + if (!bus) { 1445 + ret = -ENOMEM; 1446 + goto err_disable_clk; 1447 + } 1448 + 1449 + bus->name = "nb8800-mii"; 1450 + bus->read = nb8800_mdio_read; 1451 + bus->write = nb8800_mdio_write; 1452 + bus->parent = &pdev->dev; 1453 + snprintf(bus->id, MII_BUS_ID_SIZE, "%lx.nb8800-mii", 1454 + (unsigned long)res->start); 1455 + bus->priv = priv; 1456 + 1457 + ret = of_mdiobus_register(bus, pdev->dev.of_node); 1458 + if (ret) { 1459 + dev_err(&pdev->dev, "failed to register MII bus\n"); 1460 + goto err_disable_clk; 1461 + } 1462 + 1463 + priv->phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0); 1464 + if (!priv->phy_node) { 1465 + dev_err(&pdev->dev, "no PHY specified\n"); 1466 + ret = -ENODEV; 1467 + goto err_free_bus; 1468 + } 1469 + 1470 + priv->mii_bus = bus; 1471 + 1472 + ret = nb8800_hw_init(dev); 1473 + if (ret) 1474 + goto err_free_bus; 1475 + 1476 + if (ops && ops->init) { 1477 + ret = ops->init(dev); 1478 + if (ret) 1479 + goto err_free_bus; 1480 + } 1481 + 1482 + dev->netdev_ops = &nb8800_netdev_ops; 1483 + dev->ethtool_ops = &nb8800_ethtool_ops; 1484 + dev->flags |= IFF_MULTICAST; 1485 + dev->irq = irq; 1486 + 1487 + mac = of_get_mac_address(pdev->dev.of_node); 1488 + if (mac) 1489 + ether_addr_copy(dev->dev_addr, mac); 1490 + 1491 + if (!is_valid_ether_addr(dev->dev_addr)) 1492 + eth_hw_addr_random(dev); 1493 + 1494 + nb8800_update_mac_addr(dev); 1495 + 1496 + netif_carrier_off(dev); 1497 + 1498 + ret = register_netdev(dev); 1499 + if (ret) { 1500 + netdev_err(dev, "failed to register netdev\n"); 1501 + goto err_free_dma; 1502 + } 1503 + 1504 + netif_napi_add(dev, &priv->napi, nb8800_poll, NAPI_POLL_WEIGHT); 1505 + 1506 + netdev_info(dev, "MAC address %pM\n", dev->dev_addr); 1507 + 1508 + return 0; 1509 + 1510 + err_free_dma: 1511 + nb8800_dma_free(dev); 1512 + err_free_bus: 1513 + mdiobus_unregister(bus); 1514 + err_disable_clk: 1515 + clk_disable_unprepare(priv->clk); 1516 + err_free_dev: 1517 + free_netdev(dev); 1518 + 1519 + return ret; 1520 + } 1521 + 1522 + static int nb8800_remove(struct platform_device *pdev) 1523 + { 1524 + struct net_device *ndev = platform_get_drvdata(pdev); 1525 + struct nb8800_priv *priv = netdev_priv(ndev); 1526 + 1527 + unregister_netdev(ndev); 1528 + 1529 + mdiobus_unregister(priv->mii_bus); 1530 + 1531 + clk_disable_unprepare(priv->clk); 1532 + 1533 + nb8800_dma_free(ndev); 1534 + free_netdev(ndev); 1535 + 1536 + return 0; 1537 + } 1538 + 1539 + static struct platform_driver nb8800_driver = { 1540 + .driver = { 1541 + .name = "nb8800", 1542 + .of_match_table = nb8800_dt_ids, 1543 + }, 1544 + .probe = nb8800_probe, 1545 + .remove = nb8800_remove, 1546 + }; 1547 + 1548 + module_platform_driver(nb8800_driver); 1549 + 1550 + MODULE_DESCRIPTION("Aurora AU-NB8800 Ethernet driver"); 1551 + MODULE_AUTHOR("Mans Rullgard <mans@mansr.com>"); 1552 + MODULE_LICENSE("GPL");
+316
drivers/net/ethernet/aurora/nb8800.h
··· 1 + #ifndef _NB8800_H_ 2 + #define _NB8800_H_ 3 + 4 + #include <linux/types.h> 5 + #include <linux/skbuff.h> 6 + #include <linux/phy.h> 7 + #include <linux/clk.h> 8 + #include <linux/bitops.h> 9 + 10 + #define RX_DESC_COUNT 256 11 + #define TX_DESC_COUNT 256 12 + 13 + #define NB8800_DESC_LOW 4 14 + 15 + #define RX_BUF_SIZE 1552 16 + 17 + #define RX_COPYBREAK 256 18 + #define RX_COPYHDR 128 19 + 20 + #define MAX_MDC_CLOCK 2500000 21 + 22 + /* Stargate Solutions SSN8800 core registers */ 23 + #define NB8800_TX_CTL1 0x000 24 + #define TX_TPD BIT(5) 25 + #define TX_APPEND_FCS BIT(4) 26 + #define TX_PAD_EN BIT(3) 27 + #define TX_RETRY_EN BIT(2) 28 + #define TX_EN BIT(0) 29 + 30 + #define NB8800_TX_CTL2 0x001 31 + 32 + #define NB8800_RX_CTL 0x004 33 + #define RX_BC_DISABLE BIT(7) 34 + #define RX_RUNT BIT(6) 35 + #define RX_AF_EN BIT(5) 36 + #define RX_PAUSE_EN BIT(3) 37 + #define RX_SEND_CRC BIT(2) 38 + #define RX_PAD_STRIP BIT(1) 39 + #define RX_EN BIT(0) 40 + 41 + #define NB8800_RANDOM_SEED 0x008 42 + #define NB8800_TX_SDP 0x14 43 + #define NB8800_TX_TPDP1 0x18 44 + #define NB8800_TX_TPDP2 0x19 45 + #define NB8800_SLOT_TIME 0x1c 46 + 47 + #define NB8800_MDIO_CMD 0x020 48 + #define MDIO_CMD_GO BIT(31) 49 + #define MDIO_CMD_WR BIT(26) 50 + #define MDIO_CMD_ADDR(x) ((x) << 21) 51 + #define MDIO_CMD_REG(x) ((x) << 16) 52 + #define MDIO_CMD_DATA(x) ((x) << 0) 53 + 54 + #define NB8800_MDIO_STS 0x024 55 + #define MDIO_STS_ERR BIT(31) 56 + 57 + #define NB8800_MC_ADDR(i) (0x028 + (i)) 58 + #define NB8800_MC_INIT 0x02e 59 + #define NB8800_UC_ADDR(i) (0x03c + (i)) 60 + 61 + #define NB8800_MAC_MODE 0x044 62 + #define RGMII_MODE BIT(7) 63 + #define HALF_DUPLEX BIT(4) 64 + #define BURST_EN BIT(3) 65 + #define LOOPBACK_EN BIT(2) 66 + #define GMAC_MODE BIT(0) 67 + 68 + #define NB8800_IC_THRESHOLD 0x050 69 + #define NB8800_PE_THRESHOLD 0x051 70 + #define NB8800_PF_THRESHOLD 0x052 71 + #define NB8800_TX_BUFSIZE 0x054 72 + #define NB8800_FIFO_CTL 0x056 73 + #define NB8800_PQ1 0x060 74 + #define NB8800_PQ2 0x061 75 + #define NB8800_SRC_ADDR(i) (0x06a + (i)) 76 + #define NB8800_STAT_DATA 0x078 77 + #define NB8800_STAT_INDEX 0x07c 78 + #define NB8800_STAT_CLEAR 0x07d 79 + 80 + #define NB8800_SLEEP_MODE 0x07e 81 + #define SLEEP_MODE BIT(0) 82 + 83 + #define NB8800_WAKEUP 0x07f 84 + #define WAKEUP BIT(0) 85 + 86 + /* Aurora NB8800 host interface registers */ 87 + #define NB8800_TXC_CR 0x100 88 + #define TCR_LK BIT(12) 89 + #define TCR_DS BIT(11) 90 + #define TCR_BTS(x) (((x) & 0x7) << 8) 91 + #define TCR_DIE BIT(7) 92 + #define TCR_TFI(x) (((x) & 0x7) << 4) 93 + #define TCR_LE BIT(3) 94 + #define TCR_RS BIT(2) 95 + #define TCR_DM BIT(1) 96 + #define TCR_EN BIT(0) 97 + 98 + #define NB8800_TXC_SR 0x104 99 + #define TSR_DE BIT(3) 100 + #define TSR_DI BIT(2) 101 + #define TSR_TO BIT(1) 102 + #define TSR_TI BIT(0) 103 + 104 + #define NB8800_TX_SAR 0x108 105 + #define NB8800_TX_DESC_ADDR 0x10c 106 + 107 + #define NB8800_TX_REPORT_ADDR 0x110 108 + #define TX_BYTES_TRANSFERRED(x) (((x) >> 16) & 0xffff) 109 + #define TX_FIRST_DEFERRAL BIT(7) 110 + #define TX_EARLY_COLLISIONS(x) (((x) >> 3) & 0xf) 111 + #define TX_LATE_COLLISION BIT(2) 112 + #define TX_PACKET_DROPPED BIT(1) 113 + #define TX_FIFO_UNDERRUN BIT(0) 114 + #define IS_TX_ERROR(r) ((r) & 0x07) 115 + 116 + #define NB8800_TX_FIFO_SR 0x114 117 + #define NB8800_TX_ITR 0x118 118 + 119 + #define NB8800_RXC_CR 0x200 120 + #define RCR_FL BIT(13) 121 + #define RCR_LK BIT(12) 122 + #define RCR_DS BIT(11) 123 + #define RCR_BTS(x) (((x) & 7) << 8) 124 + #define RCR_DIE BIT(7) 125 + #define RCR_RFI(x) (((x) & 7) << 4) 126 + #define RCR_LE BIT(3) 127 + #define RCR_RS BIT(2) 128 + #define RCR_DM BIT(1) 129 + #define RCR_EN BIT(0) 130 + 131 + #define NB8800_RXC_SR 0x204 132 + #define RSR_DE BIT(3) 133 + #define RSR_DI BIT(2) 134 + #define RSR_RO BIT(1) 135 + #define RSR_RI BIT(0) 136 + 137 + #define NB8800_RX_SAR 0x208 138 + #define NB8800_RX_DESC_ADDR 0x20c 139 + 140 + #define NB8800_RX_REPORT_ADDR 0x210 141 + #define RX_BYTES_TRANSFERRED(x) (((x) >> 16) & 0xFFFF) 142 + #define RX_MULTICAST_PKT BIT(9) 143 + #define RX_BROADCAST_PKT BIT(8) 144 + #define RX_LENGTH_ERR BIT(7) 145 + #define RX_FCS_ERR BIT(6) 146 + #define RX_RUNT_PKT BIT(5) 147 + #define RX_FIFO_OVERRUN BIT(4) 148 + #define RX_LATE_COLLISION BIT(3) 149 + #define RX_ALIGNMENT_ERROR BIT(2) 150 + #define RX_ERROR_MASK 0xfc 151 + #define IS_RX_ERROR(r) ((r) & RX_ERROR_MASK) 152 + 153 + #define NB8800_RX_FIFO_SR 0x214 154 + #define NB8800_RX_ITR 0x218 155 + 156 + /* Sigma Designs SMP86xx additional registers */ 157 + #define NB8800_TANGOX_PAD_MODE 0x400 158 + #define PAD_MODE_MASK 0x7 159 + #define PAD_MODE_MII 0x0 160 + #define PAD_MODE_RGMII 0x1 161 + #define PAD_MODE_GTX_CLK_INV BIT(3) 162 + #define PAD_MODE_GTX_CLK_DELAY BIT(4) 163 + 164 + #define NB8800_TANGOX_MDIO_CLKDIV 0x420 165 + #define NB8800_TANGOX_RESET 0x424 166 + 167 + /* Hardware DMA descriptor */ 168 + struct nb8800_dma_desc { 169 + u32 s_addr; /* start address */ 170 + u32 n_addr; /* next descriptor address */ 171 + u32 r_addr; /* report address */ 172 + u32 config; 173 + } __aligned(8); 174 + 175 + #define DESC_ID BIT(23) 176 + #define DESC_EOC BIT(22) 177 + #define DESC_EOF BIT(21) 178 + #define DESC_LK BIT(20) 179 + #define DESC_DS BIT(19) 180 + #define DESC_BTS(x) (((x) & 0x7) << 16) 181 + 182 + /* DMA descriptor and associated data for rx. 183 + * Allocated from coherent memory. 184 + */ 185 + struct nb8800_rx_desc { 186 + /* DMA descriptor */ 187 + struct nb8800_dma_desc desc; 188 + 189 + /* Status report filled in by hardware */ 190 + u32 report; 191 + }; 192 + 193 + /* Address of buffer on rx ring */ 194 + struct nb8800_rx_buf { 195 + struct page *page; 196 + unsigned long offset; 197 + }; 198 + 199 + /* DMA descriptors and associated data for tx. 200 + * Allocated from coherent memory. 201 + */ 202 + struct nb8800_tx_desc { 203 + /* DMA descriptor. The second descriptor is used if packet 204 + * data is unaligned. 205 + */ 206 + struct nb8800_dma_desc desc[2]; 207 + 208 + /* Status report filled in by hardware */ 209 + u32 report; 210 + 211 + /* Bounce buffer for initial unaligned part of packet */ 212 + u8 buf[8] __aligned(8); 213 + }; 214 + 215 + /* Packet in tx queue */ 216 + struct nb8800_tx_buf { 217 + /* Currently queued skb */ 218 + struct sk_buff *skb; 219 + 220 + /* DMA address of the first descriptor */ 221 + dma_addr_t dma_desc; 222 + 223 + /* DMA address of packet data */ 224 + dma_addr_t dma_addr; 225 + 226 + /* Length of DMA mapping, less than skb->len if alignment 227 + * buffer is used. 228 + */ 229 + unsigned int dma_len; 230 + 231 + /* Number of packets in chain starting here */ 232 + unsigned int chain_len; 233 + 234 + /* Packet chain ready to be submitted to hardware */ 235 + bool ready; 236 + }; 237 + 238 + struct nb8800_priv { 239 + struct napi_struct napi; 240 + 241 + void __iomem *base; 242 + 243 + /* RX DMA descriptors */ 244 + struct nb8800_rx_desc *rx_descs; 245 + 246 + /* RX buffers referenced by DMA descriptors */ 247 + struct nb8800_rx_buf *rx_bufs; 248 + 249 + /* Current end of chain */ 250 + u32 rx_eoc; 251 + 252 + /* Value for rx interrupt time register in NAPI interrupt mode */ 253 + u32 rx_itr_irq; 254 + 255 + /* Value for rx interrupt time register in NAPI poll mode */ 256 + u32 rx_itr_poll; 257 + 258 + /* Value for config field of rx DMA descriptors */ 259 + u32 rx_dma_config; 260 + 261 + /* TX DMA descriptors */ 262 + struct nb8800_tx_desc *tx_descs; 263 + 264 + /* TX packet queue */ 265 + struct nb8800_tx_buf *tx_bufs; 266 + 267 + /* Number of free tx queue entries */ 268 + atomic_t tx_free; 269 + 270 + /* First free tx queue entry */ 271 + u32 tx_next; 272 + 273 + /* Next buffer to transmit */ 274 + u32 tx_queue; 275 + 276 + /* Start of current packet chain */ 277 + struct nb8800_tx_buf *tx_chain; 278 + 279 + /* Next buffer to reclaim */ 280 + u32 tx_done; 281 + 282 + /* Lock for DMA activation */ 283 + spinlock_t tx_lock; 284 + 285 + struct mii_bus *mii_bus; 286 + struct device_node *phy_node; 287 + struct phy_device *phydev; 288 + 289 + /* PHY connection type from DT */ 290 + int phy_mode; 291 + 292 + /* Current link status */ 293 + int speed; 294 + int duplex; 295 + int link; 296 + 297 + /* Pause settings */ 298 + bool pause_aneg; 299 + bool pause_rx; 300 + bool pause_tx; 301 + 302 + /* DMA base address of rx descriptors, see rx_descs above */ 303 + dma_addr_t rx_desc_dma; 304 + 305 + /* DMA base address of tx descriptors, see tx_descs above */ 306 + dma_addr_t tx_desc_dma; 307 + 308 + struct clk *clk; 309 + }; 310 + 311 + struct nb8800_ops { 312 + int (*init)(struct net_device *dev); 313 + int (*reset)(struct net_device *dev); 314 + }; 315 + 316 + #endif /* _NB8800_H_ */
+2 -2
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
··· 10139 10139 DP(BNX2X_MSG_SP, "Invalid vxlan port\n"); 10140 10140 return; 10141 10141 } 10142 - bp->vxlan_dst_port--; 10143 - if (bp->vxlan_dst_port) 10142 + bp->vxlan_dst_port_count--; 10143 + if (bp->vxlan_dst_port_count) 10144 10144 return; 10145 10145 10146 10146 if (netif_running(bp->dev)) {
+32 -14
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 3625 3625 pf->fw_fid = le16_to_cpu(resp->fid); 3626 3626 pf->port_id = le16_to_cpu(resp->port_id); 3627 3627 memcpy(pf->mac_addr, resp->perm_mac_address, ETH_ALEN); 3628 + memcpy(bp->dev->dev_addr, pf->mac_addr, ETH_ALEN); 3628 3629 pf->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx); 3629 3630 pf->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings); 3630 3631 pf->max_tx_rings = le16_to_cpu(resp->max_tx_rings); ··· 3649 3648 3650 3649 vf->fw_fid = le16_to_cpu(resp->fid); 3651 3650 memcpy(vf->mac_addr, resp->perm_mac_address, ETH_ALEN); 3652 - if (!is_valid_ether_addr(vf->mac_addr)) 3653 - random_ether_addr(vf->mac_addr); 3651 + if (is_valid_ether_addr(vf->mac_addr)) 3652 + /* overwrite netdev dev_adr with admin VF MAC */ 3653 + memcpy(bp->dev->dev_addr, vf->mac_addr, ETH_ALEN); 3654 + else 3655 + random_ether_addr(bp->dev->dev_addr); 3654 3656 3655 3657 vf->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx); 3656 3658 vf->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings); ··· 3884 3880 #endif 3885 3881 } 3886 3882 3883 + static int bnxt_cfg_rx_mode(struct bnxt *); 3884 + 3887 3885 static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init) 3888 3886 { 3889 3887 int rc = 0; ··· 3952 3946 bp->vnic_info[0].rx_mask |= 3953 3947 CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; 3954 3948 3955 - rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, 0); 3956 - if (rc) { 3957 - netdev_err(bp->dev, "HWRM cfa l2 rx mask failure rc: %x\n", rc); 3949 + rc = bnxt_cfg_rx_mode(bp); 3950 + if (rc) 3958 3951 goto err_out; 3959 - } 3960 3952 3961 3953 rc = bnxt_hwrm_set_coal(bp); 3962 3954 if (rc) ··· 4869 4865 } 4870 4866 } 4871 4867 4872 - static void bnxt_cfg_rx_mode(struct bnxt *bp) 4868 + static int bnxt_cfg_rx_mode(struct bnxt *bp) 4873 4869 { 4874 4870 struct net_device *dev = bp->dev; 4875 4871 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; ··· 4918 4914 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", 4919 4915 rc); 4920 4916 vnic->uc_filter_count = i; 4917 + return rc; 4921 4918 } 4922 4919 } 4923 4920 ··· 4927 4922 if (rc) 4928 4923 netdev_err(bp->dev, "HWRM cfa l2 rx mask failure rc: %x\n", 4929 4924 rc); 4925 + 4926 + return rc; 4930 4927 } 4931 4928 4932 4929 static netdev_features_t bnxt_fix_features(struct net_device *dev, ··· 5219 5212 static int bnxt_change_mac_addr(struct net_device *dev, void *p) 5220 5213 { 5221 5214 struct sockaddr *addr = p; 5215 + struct bnxt *bp = netdev_priv(dev); 5216 + int rc = 0; 5222 5217 5223 5218 if (!is_valid_ether_addr(addr->sa_data)) 5224 5219 return -EADDRNOTAVAIL; 5225 5220 5226 - memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); 5221 + #ifdef CONFIG_BNXT_SRIOV 5222 + if (BNXT_VF(bp) && is_valid_ether_addr(bp->vf.mac_addr)) 5223 + return -EADDRNOTAVAIL; 5224 + #endif 5227 5225 5228 - return 0; 5226 + if (ether_addr_equal(addr->sa_data, dev->dev_addr)) 5227 + return 0; 5228 + 5229 + memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); 5230 + if (netif_running(dev)) { 5231 + bnxt_close_nic(bp, false, false); 5232 + rc = bnxt_open_nic(bp, false, false); 5233 + } 5234 + 5235 + return rc; 5229 5236 } 5230 5237 5231 5238 /* rtnl_lock held */ ··· 5707 5686 bnxt_set_tpa_flags(bp); 5708 5687 bnxt_set_ring_params(bp); 5709 5688 dflt_rings = netif_get_num_default_rss_queues(); 5710 - if (BNXT_PF(bp)) { 5711 - memcpy(dev->dev_addr, bp->pf.mac_addr, ETH_ALEN); 5689 + if (BNXT_PF(bp)) 5712 5690 bp->pf.max_irqs = max_irqs; 5713 - } else { 5714 5691 #if defined(CONFIG_BNXT_SRIOV) 5715 - memcpy(dev->dev_addr, bp->vf.mac_addr, ETH_ALEN); 5692 + else 5716 5693 bp->vf.max_irqs = max_irqs; 5717 5694 #endif 5718 - } 5719 5695 bnxt_get_max_rings(bp, &max_rx_rings, &max_tx_rings); 5720 5696 bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings); 5721 5697 bp->tx_nr_rings_per_tc = min_t(int, dflt_rings, max_tx_rings);
+3 -4
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
··· 804 804 if (!is_valid_ether_addr(resp->perm_mac_address)) 805 805 goto update_vf_mac_exit; 806 806 807 - if (ether_addr_equal(resp->perm_mac_address, bp->vf.mac_addr)) 808 - goto update_vf_mac_exit; 809 - 810 - memcpy(bp->vf.mac_addr, resp->perm_mac_address, ETH_ALEN); 807 + if (!ether_addr_equal(resp->perm_mac_address, bp->vf.mac_addr)) 808 + memcpy(bp->vf.mac_addr, resp->perm_mac_address, ETH_ALEN); 809 + /* overwrite netdev dev_adr with admin VF MAC */ 811 810 memcpy(bp->dev->dev_addr, bp->vf.mac_addr, ETH_ALEN); 812 811 update_vf_mac_exit: 813 812 mutex_unlock(&bp->hwrm_cmd_lock);
+4
drivers/net/ethernet/cadence/macb.c
··· 1682 1682 macb_set_hwaddr(bp); 1683 1683 1684 1684 config = macb_mdc_clk_div(bp); 1685 + if (bp->phy_interface == PHY_INTERFACE_MODE_SGMII) 1686 + config |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL); 1685 1687 config |= MACB_BF(RBOF, NET_IP_ALIGN); /* Make eth data aligned */ 1686 1688 config |= MACB_BIT(PAE); /* PAuse Enable */ 1687 1689 config |= MACB_BIT(DRFCS); /* Discard Rx FCS */ ··· 2418 2416 /* Set MII management clock divider */ 2419 2417 val = macb_mdc_clk_div(bp); 2420 2418 val |= macb_dbw(bp); 2419 + if (bp->phy_interface == PHY_INTERFACE_MODE_SGMII) 2420 + val |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL); 2421 2421 macb_writel(bp, NCFGR, val); 2422 2422 2423 2423 return 0;
+5
drivers/net/ethernet/cadence/macb.h
··· 215 215 /* GEM specific NCFGR bitfields. */ 216 216 #define GEM_GBE_OFFSET 10 /* Gigabit mode enable */ 217 217 #define GEM_GBE_SIZE 1 218 + #define GEM_PCSSEL_OFFSET 11 219 + #define GEM_PCSSEL_SIZE 1 218 220 #define GEM_CLK_OFFSET 18 /* MDC clock division */ 219 221 #define GEM_CLK_SIZE 3 220 222 #define GEM_DBW_OFFSET 21 /* Data bus width */ 221 223 #define GEM_DBW_SIZE 2 222 224 #define GEM_RXCOEN_OFFSET 24 223 225 #define GEM_RXCOEN_SIZE 1 226 + #define GEM_SGMIIEN_OFFSET 27 227 + #define GEM_SGMIIEN_SIZE 1 228 + 224 229 225 230 /* Constants for data bus width. */ 226 231 #define GEM_DBW32 0 /* 32 bit AMBA AHB data bus width */
+2 -3
drivers/net/ethernet/cavium/thunder/nic.h
··· 120 120 * Calculated for SCLK of 700Mhz 121 121 * value written should be a 1/16th of what is expected 122 122 * 123 - * 1 tick per 0.05usec = value of 2.2 124 - * This 10% would be covered in CQ timer thresh value 123 + * 1 tick per 0.025usec 125 124 */ 126 - #define NICPF_CLK_PER_INT_TICK 2 125 + #define NICPF_CLK_PER_INT_TICK 1 127 126 128 127 /* Time to wait before we decide that a SQ is stuck. 129 128 *
+20 -3
drivers/net/ethernet/cavium/thunder/nic_main.c
··· 37 37 #define NIC_GET_BGX_FROM_VF_LMAC_MAP(map) ((map >> 4) & 0xF) 38 38 #define NIC_GET_LMAC_FROM_VF_LMAC_MAP(map) (map & 0xF) 39 39 u8 vf_lmac_map[MAX_LMAC]; 40 + u8 lmac_cnt; 40 41 struct delayed_work dwork; 41 42 struct workqueue_struct *check_link; 42 43 u8 link[MAX_LMAC]; ··· 280 279 u64 lmac_credit; 281 280 282 281 nic->num_vf_en = 0; 282 + nic->lmac_cnt = 0; 283 283 284 284 for (bgx = 0; bgx < NIC_MAX_BGX; bgx++) { 285 285 if (!(bgx_map & (1 << bgx))) ··· 290 288 nic->vf_lmac_map[next_bgx_lmac++] = 291 289 NIC_SET_VF_LMAC_MAP(bgx, lmac); 292 290 nic->num_vf_en += lmac_cnt; 291 + nic->lmac_cnt += lmac_cnt; 293 292 294 293 /* Program LMAC credits */ 295 294 lmac_credit = (1ull << 1); /* channel credit enable */ ··· 718 715 case NIC_MBOX_MSG_CFG_DONE: 719 716 /* Last message of VF config msg sequence */ 720 717 nic->vf_enabled[vf] = true; 718 + if (vf >= nic->lmac_cnt) 719 + goto unlock; 720 + 721 + bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); 722 + lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); 723 + 724 + bgx_lmac_rx_tx_enable(nic->node, bgx, lmac, true); 721 725 goto unlock; 722 726 case NIC_MBOX_MSG_SHUTDOWN: 723 727 /* First msg in VF teardown sequence */ ··· 732 722 if (vf >= nic->num_vf_en) 733 723 nic->sqs_used[vf - nic->num_vf_en] = false; 734 724 nic->pqs_vf[vf] = 0; 725 + 726 + if (vf >= nic->lmac_cnt) 727 + break; 728 + 729 + bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); 730 + lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); 731 + 732 + bgx_lmac_rx_tx_enable(nic->node, bgx, lmac, false); 735 733 break; 736 734 case NIC_MBOX_MSG_ALLOC_SQS: 737 735 nic_alloc_sqs(nic, &mbx.sqs_alloc); ··· 958 940 959 941 mbx.link_status.msg = NIC_MBOX_MSG_BGX_LINK_CHANGE; 960 942 961 - for (vf = 0; vf < nic->num_vf_en; vf++) { 943 + for (vf = 0; vf < nic->lmac_cnt; vf++) { 962 944 /* Poll only if VF is UP */ 963 945 if (!nic->vf_enabled[vf]) 964 946 continue; ··· 1092 1074 1093 1075 if (nic->check_link) { 1094 1076 /* Destroy work Queue */ 1095 - cancel_delayed_work(&nic->dwork); 1096 - flush_workqueue(nic->check_link); 1077 + cancel_delayed_work_sync(&nic->dwork); 1097 1078 destroy_workqueue(nic->check_link); 1098 1079 } 1099 1080
+15 -1
drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c
··· 112 112 113 113 cmd->supported = 0; 114 114 cmd->transceiver = XCVR_EXTERNAL; 115 + 116 + if (!nic->link_up) { 117 + cmd->duplex = DUPLEX_UNKNOWN; 118 + ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN); 119 + return 0; 120 + } 121 + 115 122 if (nic->speed <= 1000) { 116 123 cmd->port = PORT_MII; 117 124 cmd->autoneg = AUTONEG_ENABLE; ··· 130 123 ethtool_cmd_speed_set(cmd, nic->speed); 131 124 132 125 return 0; 126 + } 127 + 128 + static u32 nicvf_get_link(struct net_device *netdev) 129 + { 130 + struct nicvf *nic = netdev_priv(netdev); 131 + 132 + return nic->link_up; 133 133 } 134 134 135 135 static void nicvf_get_drvinfo(struct net_device *netdev, ··· 674 660 675 661 static const struct ethtool_ops nicvf_ethtool_ops = { 676 662 .get_settings = nicvf_get_settings, 677 - .get_link = ethtool_op_get_link, 663 + .get_link = nicvf_get_link, 678 664 .get_drvinfo = nicvf_get_drvinfo, 679 665 .get_msglevel = nicvf_get_msglevel, 680 666 .set_msglevel = nicvf_set_msglevel,
+1 -3
drivers/net/ethernet/cavium/thunder/nicvf_main.c
··· 1057 1057 1058 1058 netif_carrier_off(netdev); 1059 1059 netif_tx_stop_all_queues(nic->netdev); 1060 + nic->link_up = false; 1060 1061 1061 1062 /* Teardown secondary qsets first */ 1062 1063 if (!nic->sqs_mode) { ··· 1211 1210 1212 1211 nic->drv_stats.txq_stop = 0; 1213 1212 nic->drv_stats.txq_wake = 0; 1214 - 1215 - netif_carrier_on(netdev); 1216 - netif_tx_start_all_queues(netdev); 1217 1213 1218 1214 return 0; 1219 1215 cleanup:
+1 -1
drivers/net/ethernet/cavium/thunder/nicvf_queues.c
··· 592 592 /* Set threshold value for interrupt generation */ 593 593 nicvf_queue_reg_write(nic, NIC_QSET_CQ_0_7_THRESH, qidx, cq->thresh); 594 594 nicvf_queue_reg_write(nic, NIC_QSET_CQ_0_7_CFG2, 595 - qidx, nic->cq_coalesce_usecs); 595 + qidx, CMP_QUEUE_TIMER_THRESH); 596 596 } 597 597 598 598 /* Configures transmit queue */
+1 -1
drivers/net/ethernet/cavium/thunder/nicvf_queues.h
··· 76 76 #define CMP_QSIZE CMP_QUEUE_SIZE2 77 77 #define CMP_QUEUE_LEN (1ULL << (CMP_QSIZE + 10)) 78 78 #define CMP_QUEUE_CQE_THRESH 0 79 - #define CMP_QUEUE_TIMER_THRESH 220 /* 10usec */ 79 + #define CMP_QUEUE_TIMER_THRESH 80 /* ~2usec */ 80 80 81 81 #define RBDR_SIZE RBDR_SIZE0 82 82 #define RCV_BUF_COUNT (1ULL << (RBDR_SIZE + 13))
+24 -4
drivers/net/ethernet/cavium/thunder/thunder_bgx.c
··· 186 186 } 187 187 EXPORT_SYMBOL(bgx_set_lmac_mac); 188 188 189 + void bgx_lmac_rx_tx_enable(int node, int bgx_idx, int lmacid, bool enable) 190 + { 191 + struct bgx *bgx = bgx_vnic[(node * MAX_BGX_PER_CN88XX) + bgx_idx]; 192 + u64 cfg; 193 + 194 + if (!bgx) 195 + return; 196 + 197 + cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG); 198 + if (enable) 199 + cfg |= CMR_PKT_RX_EN | CMR_PKT_TX_EN; 200 + else 201 + cfg &= ~(CMR_PKT_RX_EN | CMR_PKT_TX_EN); 202 + bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg); 203 + } 204 + EXPORT_SYMBOL(bgx_lmac_rx_tx_enable); 205 + 189 206 static void bgx_sgmii_change_link_state(struct lmac *lmac) 190 207 { 191 208 struct bgx *bgx = lmac->bgx; ··· 629 612 lmac->last_duplex = 1; 630 613 } else { 631 614 lmac->link_up = 0; 615 + lmac->last_speed = SPEED_UNKNOWN; 616 + lmac->last_duplex = DUPLEX_UNKNOWN; 632 617 } 633 618 634 619 if (lmac->last_link != lmac->link_up) { ··· 673 654 } 674 655 675 656 /* Enable lmac */ 676 - bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, 677 - CMR_EN | CMR_PKT_RX_EN | CMR_PKT_TX_EN); 657 + bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, CMR_EN); 678 658 679 659 /* Restore default cfg, incase low level firmware changed it */ 680 660 bgx_reg_write(bgx, lmacid, BGX_CMRX_RX_DMAC_CTL, 0x03); ··· 713 695 lmac = &bgx->lmac[lmacid]; 714 696 if (lmac->check_link) { 715 697 /* Destroy work queue */ 716 - cancel_delayed_work(&lmac->dwork); 717 - flush_workqueue(lmac->check_link); 698 + cancel_delayed_work_sync(&lmac->dwork); 718 699 destroy_workqueue(lmac->check_link); 719 700 } 720 701 ··· 1025 1008 struct device *dev = &pdev->dev; 1026 1009 struct bgx *bgx = NULL; 1027 1010 u8 lmac; 1011 + 1012 + /* Load octeon mdio driver */ 1013 + octeon_mdiobus_force_mod_depencency(); 1028 1014 1029 1015 bgx = devm_kzalloc(dev, sizeof(*bgx), GFP_KERNEL); 1030 1016 if (!bgx)
+2
drivers/net/ethernet/cavium/thunder/thunder_bgx.h
··· 182 182 #define BCAST_ACCEPT 1 183 183 #define CAM_ACCEPT 1 184 184 185 + void octeon_mdiobus_force_mod_depencency(void); 186 + void bgx_lmac_rx_tx_enable(int node, int bgx_idx, int lmacid, bool enable); 185 187 void bgx_add_dmac_addr(u64 dmac, int node, int bgx_idx, int lmac); 186 188 unsigned bgx_get_map(int node); 187 189 int bgx_get_lmac_count(int node, int bgx);
+7 -2
drivers/net/ethernet/dec/tulip/tulip_core.c
··· 98 98 #elif defined(__mips__) 99 99 static int csr0 = 0x00200000 | 0x4000; 100 100 #else 101 - #warning Processor architecture undefined! 102 - static int csr0 = 0x00A00000 | 0x4800; 101 + static int csr0; 103 102 #endif 104 103 105 104 /* Operational parameters that usually are not changed. */ ··· 1980 1981 #ifdef MODULE 1981 1982 pr_info("%s", version); 1982 1983 #endif 1984 + 1985 + if (!csr0) { 1986 + pr_warn("tulip: unknown CPU architecture, using default csr0\n"); 1987 + /* default to 8 longword cache line alignment */ 1988 + csr0 = 0x00A00000 | 0x4800; 1989 + } 1983 1990 1984 1991 /* copy module parms into globals */ 1985 1992 tulip_rx_copybreak = rx_copybreak;
+1 -1
drivers/net/ethernet/dec/tulip/winbond-840.c
··· 907 907 #elif defined(CONFIG_SPARC) || defined (CONFIG_PARISC) || defined(CONFIG_ARM) 908 908 i |= 0x4800; 909 909 #else 910 - #warning Processor architecture undefined 910 + dev_warn(&dev->dev, "unknown CPU architecture, using default csr0 setting\n"); 911 911 i |= 0x4800; 912 912 #endif 913 913 iowrite32(i, ioaddr + PCIBusCfg);
+2 -1
drivers/net/ethernet/freescale/Kconfig
··· 7 7 default y 8 8 depends on FSL_SOC || QUICC_ENGINE || CPM1 || CPM2 || PPC_MPC512x || \ 9 9 M523x || M527x || M5272 || M528x || M520x || M532x || \ 10 - ARCH_MXC || ARCH_MXS || (PPC_MPC52xx && PPC_BESTCOMM) 10 + ARCH_MXC || ARCH_MXS || (PPC_MPC52xx && PPC_BESTCOMM) || \ 11 + ARCH_LAYERSCAPE 11 12 ---help--- 12 13 If you have a network (Ethernet) card belonging to this class, say Y. 13 14
+3 -3
drivers/net/ethernet/freescale/gianfar.c
··· 647 647 if (model && strcasecmp(model, "FEC")) { 648 648 gfar_irq(grp, RX)->irq = irq_of_parse_and_map(np, 1); 649 649 gfar_irq(grp, ER)->irq = irq_of_parse_and_map(np, 2); 650 - if (gfar_irq(grp, TX)->irq == NO_IRQ || 651 - gfar_irq(grp, RX)->irq == NO_IRQ || 652 - gfar_irq(grp, ER)->irq == NO_IRQ) 650 + if (!gfar_irq(grp, TX)->irq || 651 + !gfar_irq(grp, RX)->irq || 652 + !gfar_irq(grp, ER)->irq) 653 653 return -EINVAL; 654 654 } 655 655
+1 -1
drivers/net/ethernet/freescale/gianfar_ptp.c
··· 467 467 468 468 etsects->irq = platform_get_irq(dev, 0); 469 469 470 - if (etsects->irq == NO_IRQ) { 470 + if (etsects->irq < 0) { 471 471 pr_err("irq not in device tree\n"); 472 472 goto no_node; 473 473 }
+3 -1
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
··· 627 627 628 628 /* verify the skb head is not shared */ 629 629 err = skb_cow_head(skb, 0); 630 - if (err) 630 + if (err) { 631 + dev_kfree_skb(skb); 631 632 return NETDEV_TX_OK; 633 + } 632 634 633 635 /* locate vlan header */ 634 636 vhdr = (struct vlan_hdr *)(skb->data + ETH_HLEN);
+27 -6
drivers/net/ethernet/marvell/mvneta.c
··· 36 36 37 37 /* Registers */ 38 38 #define MVNETA_RXQ_CONFIG_REG(q) (0x1400 + ((q) << 2)) 39 - #define MVNETA_RXQ_HW_BUF_ALLOC BIT(1) 39 + #define MVNETA_RXQ_HW_BUF_ALLOC BIT(0) 40 40 #define MVNETA_RXQ_PKT_OFFSET_ALL_MASK (0xf << 8) 41 41 #define MVNETA_RXQ_PKT_OFFSET_MASK(offs) ((offs) << 8) 42 42 #define MVNETA_RXQ_THRESHOLD_REG(q) (0x14c0 + ((q) << 2)) ··· 62 62 #define MVNETA_WIN_SIZE(w) (0x2204 + ((w) << 3)) 63 63 #define MVNETA_WIN_REMAP(w) (0x2280 + ((w) << 2)) 64 64 #define MVNETA_BASE_ADDR_ENABLE 0x2290 65 + #define MVNETA_ACCESS_PROTECT_ENABLE 0x2294 65 66 #define MVNETA_PORT_CONFIG 0x2400 66 67 #define MVNETA_UNI_PROMISC_MODE BIT(0) 67 68 #define MVNETA_DEF_RXQ(q) ((q) << 1) ··· 160 159 161 160 #define MVNETA_INTR_ENABLE 0x25b8 162 161 #define MVNETA_TXQ_INTR_ENABLE_ALL_MASK 0x0000ff00 163 - #define MVNETA_RXQ_INTR_ENABLE_ALL_MASK 0xff000000 // note: neta says it's 0x000000FF 162 + #define MVNETA_RXQ_INTR_ENABLE_ALL_MASK 0x000000ff 164 163 165 164 #define MVNETA_RXQ_CMD 0x2680 166 165 #define MVNETA_RXQ_DISABLE_SHIFT 8 ··· 243 242 #define MVNETA_VLAN_TAG_LEN 4 244 243 245 244 #define MVNETA_CPU_D_CACHE_LINE_SIZE 32 245 + #define MVNETA_TX_CSUM_DEF_SIZE 1600 246 246 #define MVNETA_TX_CSUM_MAX_SIZE 9800 247 247 #define MVNETA_ACC_MODE_EXT 1 248 248 ··· 1581 1579 } 1582 1580 1583 1581 skb = build_skb(data, pp->frag_size > PAGE_SIZE ? 0 : pp->frag_size); 1584 - if (!skb) 1585 - goto err_drop_frame; 1586 1582 1583 + /* After refill old buffer has to be unmapped regardless 1584 + * the skb is successfully built or not. 1585 + */ 1587 1586 dma_unmap_single(dev->dev.parent, phys_addr, 1588 1587 MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE); 1588 + 1589 + if (!skb) 1590 + goto err_drop_frame; 1589 1591 1590 1592 rcvd_pkts++; 1591 1593 rcvd_bytes += rx_bytes; ··· 3197 3191 } 3198 3192 3199 3193 mvreg_write(pp, MVNETA_BASE_ADDR_ENABLE, win_enable); 3194 + mvreg_write(pp, MVNETA_ACCESS_PROTECT_ENABLE, win_protect); 3200 3195 } 3201 3196 3202 3197 /* Power up the port */ ··· 3257 3250 char hw_mac_addr[ETH_ALEN]; 3258 3251 const char *mac_from; 3259 3252 const char *managed; 3253 + int tx_csum_limit; 3260 3254 int phy_mode; 3261 3255 int err; 3262 3256 int cpu; ··· 3358 3350 } 3359 3351 } 3360 3352 3361 - if (of_device_is_compatible(dn, "marvell,armada-370-neta")) 3362 - pp->tx_csum_limit = 1600; 3353 + if (!of_property_read_u32(dn, "tx-csum-limit", &tx_csum_limit)) { 3354 + if (tx_csum_limit < 0 || 3355 + tx_csum_limit > MVNETA_TX_CSUM_MAX_SIZE) { 3356 + tx_csum_limit = MVNETA_TX_CSUM_DEF_SIZE; 3357 + dev_info(&pdev->dev, 3358 + "Wrong TX csum limit in DT, set to %dB\n", 3359 + MVNETA_TX_CSUM_DEF_SIZE); 3360 + } 3361 + } else if (of_device_is_compatible(dn, "marvell,armada-370-neta")) { 3362 + tx_csum_limit = MVNETA_TX_CSUM_DEF_SIZE; 3363 + } else { 3364 + tx_csum_limit = MVNETA_TX_CSUM_MAX_SIZE; 3365 + } 3366 + 3367 + pp->tx_csum_limit = tx_csum_limit; 3363 3368 3364 3369 pp->tx_ring_size = MVNETA_MAX_TXD; 3365 3370 pp->rx_ring_size = MVNETA_MAX_RXD;
+1 -1
drivers/net/ethernet/nxp/lpc_eth.c
··· 1326 1326 /* Get platform resources */ 1327 1327 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1328 1328 irq = platform_get_irq(pdev, 0); 1329 - if ((!res) || (irq < 0) || (irq >= NR_IRQS)) { 1329 + if (!res || irq < 0) { 1330 1330 dev_err(&pdev->dev, "error getting resources.\n"); 1331 1331 ret = -ENXIO; 1332 1332 goto err_exit;
+4 -2
drivers/net/ethernet/renesas/ravb_main.c
··· 1225 1225 /* Device init */ 1226 1226 error = ravb_dmac_init(ndev); 1227 1227 if (error) 1228 - goto out_free_irq; 1228 + goto out_free_irq2; 1229 1229 ravb_emac_init(ndev); 1230 1230 1231 1231 /* Initialise PTP Clock driver */ ··· 1243 1243 out_ptp_stop: 1244 1244 /* Stop PTP Clock driver */ 1245 1245 ravb_ptp_stop(ndev); 1246 + out_free_irq2: 1247 + if (priv->chip_id == RCAR_GEN3) 1248 + free_irq(priv->emac_irq, ndev); 1246 1249 out_free_irq: 1247 1250 free_irq(ndev->irq, ndev); 1248 - free_irq(priv->emac_irq, ndev); 1249 1251 out_napi_off: 1250 1252 napi_disable(&priv->napi[RAVB_NC]); 1251 1253 napi_disable(&priv->napi[RAVB_BE]);
+7 -6
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
··· 299 299 if (IS_PHY_IF_MODE_GBIT(dwmac->interface)) { 300 300 const char *rs; 301 301 302 + dwmac->tx_retime_src = TX_RETIME_SRC_CLKGEN; 303 + 302 304 err = of_property_read_string(np, "st,tx-retime-src", &rs); 303 305 if (err < 0) { 304 306 dev_warn(dev, "Use internal clock source\n"); 305 - dwmac->tx_retime_src = TX_RETIME_SRC_CLKGEN; 306 - } else if (!strcasecmp(rs, "clk_125")) { 307 - dwmac->tx_retime_src = TX_RETIME_SRC_CLK_125; 308 - } else if (!strcasecmp(rs, "txclk")) { 309 - dwmac->tx_retime_src = TX_RETIME_SRC_TXCLK; 307 + } else { 308 + if (!strcasecmp(rs, "clk_125")) 309 + dwmac->tx_retime_src = TX_RETIME_SRC_CLK_125; 310 + else if (!strcasecmp(rs, "txclk")) 311 + dwmac->tx_retime_src = TX_RETIME_SRC_TXCLK; 310 312 } 311 - 312 313 dwmac->speed = SPEED_1000; 313 314 } 314 315
+8 -1
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 185 185 priv->clk_csr = STMMAC_CSR_100_150M; 186 186 else if ((clk_rate >= CSR_F_150M) && (clk_rate < CSR_F_250M)) 187 187 priv->clk_csr = STMMAC_CSR_150_250M; 188 - else if ((clk_rate >= CSR_F_250M) && (clk_rate < CSR_F_300M)) 188 + else if ((clk_rate >= CSR_F_250M) && (clk_rate <= CSR_F_300M)) 189 189 priv->clk_csr = STMMAC_CSR_250_300M; 190 190 } 191 191 } ··· 2232 2232 2233 2233 frame_len = priv->hw->desc->get_rx_frame_len(p, coe); 2234 2234 2235 + /* check if frame_len fits the preallocated memory */ 2236 + if (frame_len > priv->dma_buf_sz) { 2237 + priv->dev->stats.rx_length_errors++; 2238 + break; 2239 + } 2240 + 2235 2241 /* ACS is set; GMAC core strips PAD/FCS for IEEE 802.3 2236 2242 * Type frames (LLC/LLC-SNAP) 2237 2243 */ ··· 3108 3102 init_dma_desc_rings(ndev, GFP_ATOMIC); 3109 3103 stmmac_hw_setup(ndev, false); 3110 3104 stmmac_init_tx_coalesce(priv); 3105 + stmmac_set_rx_mode(ndev); 3111 3106 3112 3107 napi_enable(&priv->napi); 3113 3108
+13 -15
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
··· 138 138 139 139 #ifdef CONFIG_OF 140 140 if (priv->device->of_node) { 141 - int reset_gpio, active_low; 142 141 143 142 if (data->reset_gpio < 0) { 144 143 struct device_node *np = priv->device->of_node; ··· 153 154 "snps,reset-active-low"); 154 155 of_property_read_u32_array(np, 155 156 "snps,reset-delays-us", data->delays, 3); 157 + 158 + if (gpio_request(data->reset_gpio, "mdio-reset")) 159 + return 0; 156 160 } 157 161 158 - reset_gpio = data->reset_gpio; 159 - active_low = data->active_low; 162 + gpio_direction_output(data->reset_gpio, 163 + data->active_low ? 1 : 0); 164 + if (data->delays[0]) 165 + msleep(DIV_ROUND_UP(data->delays[0], 1000)); 160 166 161 - if (!gpio_request(reset_gpio, "mdio-reset")) { 162 - gpio_direction_output(reset_gpio, active_low ? 1 : 0); 163 - if (data->delays[0]) 164 - msleep(DIV_ROUND_UP(data->delays[0], 1000)); 167 + gpio_set_value(data->reset_gpio, data->active_low ? 0 : 1); 168 + if (data->delays[1]) 169 + msleep(DIV_ROUND_UP(data->delays[1], 1000)); 165 170 166 - gpio_set_value(reset_gpio, active_low ? 0 : 1); 167 - if (data->delays[1]) 168 - msleep(DIV_ROUND_UP(data->delays[1], 1000)); 169 - 170 - gpio_set_value(reset_gpio, active_low ? 1 : 0); 171 - if (data->delays[2]) 172 - msleep(DIV_ROUND_UP(data->delays[2], 1000)); 173 - } 171 + gpio_set_value(data->reset_gpio, data->active_low ? 1 : 0); 172 + if (data->delays[2]) 173 + msleep(DIV_ROUND_UP(data->delays[2], 1000)); 174 174 } 175 175 #endif 176 176
+3
drivers/net/ethernet/ti/cpsw-common.c
··· 78 78 79 79 int ti_cm_get_macid(struct device *dev, int slave, u8 *mac_addr) 80 80 { 81 + if (of_machine_is_compatible("ti,dm8148")) 82 + return cpsw_am33xx_cm_get_macid(dev, 0x630, slave, mac_addr); 83 + 81 84 if (of_machine_is_compatible("ti,am33xx")) 82 85 return cpsw_am33xx_cm_get_macid(dev, 0x630, slave, mac_addr); 83 86
+2 -2
drivers/net/macvtap.c
··· 498 498 wait_queue_head_t *wqueue; 499 499 500 500 if (!sock_writeable(sk) || 501 - !test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags)) 501 + !test_and_clear_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags)) 502 502 return; 503 503 504 504 wqueue = sk_sleep(sk); ··· 585 585 mask |= POLLIN | POLLRDNORM; 586 586 587 587 if (sock_writeable(&q->sk) || 588 - (!test_and_set_bit(SOCK_ASYNC_NOSPACE, &q->sock.flags) && 588 + (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock.flags) && 589 589 sock_writeable(&q->sk))) 590 590 mask |= POLLOUT | POLLWRNORM; 591 591
+1 -1
drivers/net/phy/broadcom.c
··· 614 614 { PHY_ID_BCM5461, 0xfffffff0 }, 615 615 { PHY_ID_BCM54616S, 0xfffffff0 }, 616 616 { PHY_ID_BCM5464, 0xfffffff0 }, 617 - { PHY_ID_BCM5482, 0xfffffff0 }, 617 + { PHY_ID_BCM5481, 0xfffffff0 }, 618 618 { PHY_ID_BCM5482, 0xfffffff0 }, 619 619 { PHY_ID_BCM50610, 0xfffffff0 }, 620 620 { PHY_ID_BCM50610M, 0xfffffff0 },
+2 -1
drivers/net/phy/phy.c
··· 448 448 mdiobus_write(phydev->bus, mii_data->phy_id, 449 449 mii_data->reg_num, val); 450 450 451 - if (mii_data->reg_num == MII_BMCR && 451 + if (mii_data->phy_id == phydev->addr && 452 + mii_data->reg_num == MII_BMCR && 452 453 val & BMCR_RESET) 453 454 return phy_init_hw(phydev); 454 455
+2 -2
drivers/net/tun.c
··· 1040 1040 mask |= POLLIN | POLLRDNORM; 1041 1041 1042 1042 if (sock_writeable(sk) || 1043 - (!test_and_set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags) && 1043 + (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags) && 1044 1044 sock_writeable(sk))) 1045 1045 mask |= POLLOUT | POLLWRNORM; 1046 1046 ··· 1488 1488 if (!sock_writeable(sk)) 1489 1489 return; 1490 1490 1491 - if (!test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags)) 1491 + if (!test_and_clear_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags)) 1492 1492 return; 1493 1493 1494 1494 wqueue = sk_sleep(sk);
+4 -4
drivers/net/usb/cdc_ncm.c
··· 691 691 692 692 int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting, int drvflags) 693 693 { 694 - const struct usb_cdc_union_desc *union_desc = NULL; 695 694 struct cdc_ncm_ctx *ctx; 696 695 struct usb_driver *driver; 697 696 u8 *buf; ··· 724 725 /* parse through descriptors associated with control interface */ 725 726 cdc_parse_cdc_header(&hdr, intf, buf, len); 726 727 727 - ctx->data = usb_ifnum_to_if(dev->udev, 728 - hdr.usb_cdc_union_desc->bSlaveInterface0); 728 + if (hdr.usb_cdc_union_desc) 729 + ctx->data = usb_ifnum_to_if(dev->udev, 730 + hdr.usb_cdc_union_desc->bSlaveInterface0); 729 731 ctx->ether_desc = hdr.usb_cdc_ether_desc; 730 732 ctx->func_desc = hdr.usb_cdc_ncm_desc; 731 733 ctx->mbim_desc = hdr.usb_cdc_mbim_desc; 732 734 ctx->mbim_extended_desc = hdr.usb_cdc_mbim_extended_desc; 733 735 734 736 /* some buggy devices have an IAD but no CDC Union */ 735 - if (!union_desc && intf->intf_assoc && intf->intf_assoc->bInterfaceCount == 2) { 737 + if (!hdr.usb_cdc_union_desc && intf->intf_assoc && intf->intf_assoc->bInterfaceCount == 2) { 736 738 ctx->data = usb_ifnum_to_if(dev->udev, intf->cur_altsetting->desc.bInterfaceNumber + 1); 737 739 dev_dbg(&intf->dev, "CDC Union missing - got slave from IAD\n"); 738 740 }
+1
drivers/net/usb/qmi_wwan.c
··· 725 725 {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ 726 726 {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ 727 727 {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */ 728 + {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ 728 729 {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */ 729 730 {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */ 730 731 {QMI_FIXED_INTF(0x0b3c, 0xc002, 4)}, /* Olivetti Olicard 140 */
+60 -11
drivers/net/vmxnet3/vmxnet3_drv.c
··· 587 587 &adapter->pdev->dev, 588 588 rbi->skb->data, rbi->len, 589 589 PCI_DMA_FROMDEVICE); 590 + if (dma_mapping_error(&adapter->pdev->dev, 591 + rbi->dma_addr)) { 592 + dev_kfree_skb_any(rbi->skb); 593 + rq->stats.rx_buf_alloc_failure++; 594 + break; 595 + } 590 596 } else { 591 597 /* rx buffer skipped by the device */ 592 598 } ··· 611 605 &adapter->pdev->dev, 612 606 rbi->page, 0, PAGE_SIZE, 613 607 PCI_DMA_FROMDEVICE); 608 + if (dma_mapping_error(&adapter->pdev->dev, 609 + rbi->dma_addr)) { 610 + put_page(rbi->page); 611 + rq->stats.rx_buf_alloc_failure++; 612 + break; 613 + } 614 614 } else { 615 615 /* rx buffers skipped by the device */ 616 616 } 617 617 val = VMXNET3_RXD_BTYPE_BODY << VMXNET3_RXD_BTYPE_SHIFT; 618 618 } 619 619 620 - BUG_ON(rbi->dma_addr == 0); 621 620 gd->rxd.addr = cpu_to_le64(rbi->dma_addr); 622 621 gd->dword[2] = cpu_to_le32((!ring->gen << VMXNET3_RXD_GEN_SHIFT) 623 622 | val | rbi->len); ··· 666 655 } 667 656 668 657 669 - static void 658 + static int 670 659 vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx *ctx, 671 660 struct vmxnet3_tx_queue *tq, struct pci_dev *pdev, 672 661 struct vmxnet3_adapter *adapter) ··· 726 715 tbi->dma_addr = dma_map_single(&adapter->pdev->dev, 727 716 skb->data + buf_offset, buf_size, 728 717 PCI_DMA_TODEVICE); 718 + if (dma_mapping_error(&adapter->pdev->dev, tbi->dma_addr)) 719 + return -EFAULT; 729 720 730 721 tbi->len = buf_size; 731 722 ··· 768 755 tbi->dma_addr = skb_frag_dma_map(&adapter->pdev->dev, frag, 769 756 buf_offset, buf_size, 770 757 DMA_TO_DEVICE); 758 + if (dma_mapping_error(&adapter->pdev->dev, tbi->dma_addr)) 759 + return -EFAULT; 771 760 772 761 tbi->len = buf_size; 773 762 ··· 797 782 /* set the last buf_info for the pkt */ 798 783 tbi->skb = skb; 799 784 tbi->sop_idx = ctx->sop_txd - tq->tx_ring.base; 785 + 786 + return 0; 800 787 } 801 788 802 789 ··· 1037 1020 } 1038 1021 1039 1022 /* fill tx descs related to addr & len */ 1040 - vmxnet3_map_pkt(skb, &ctx, tq, adapter->pdev, adapter); 1023 + if (vmxnet3_map_pkt(skb, &ctx, tq, adapter->pdev, adapter)) 1024 + goto unlock_drop_pkt; 1041 1025 1042 1026 /* setup the EOP desc */ 1043 1027 ctx.eop_txd->dword[3] = cpu_to_le32(VMXNET3_TXD_CQ | VMXNET3_TXD_EOP); ··· 1249 1231 struct vmxnet3_rx_buf_info *rbi; 1250 1232 struct sk_buff *skb, *new_skb = NULL; 1251 1233 struct page *new_page = NULL; 1234 + dma_addr_t new_dma_addr; 1252 1235 int num_to_alloc; 1253 1236 struct Vmxnet3_RxDesc *rxd; 1254 1237 u32 idx, ring_idx; ··· 1306 1287 skip_page_frags = true; 1307 1288 goto rcd_done; 1308 1289 } 1290 + new_dma_addr = dma_map_single(&adapter->pdev->dev, 1291 + new_skb->data, rbi->len, 1292 + PCI_DMA_FROMDEVICE); 1293 + if (dma_mapping_error(&adapter->pdev->dev, 1294 + new_dma_addr)) { 1295 + dev_kfree_skb(new_skb); 1296 + /* Skb allocation failed, do not handover this 1297 + * skb to stack. Reuse it. Drop the existing pkt 1298 + */ 1299 + rq->stats.rx_buf_alloc_failure++; 1300 + ctx->skb = NULL; 1301 + rq->stats.drop_total++; 1302 + skip_page_frags = true; 1303 + goto rcd_done; 1304 + } 1309 1305 1310 1306 dma_unmap_single(&adapter->pdev->dev, rbi->dma_addr, 1311 1307 rbi->len, ··· 1337 1303 1338 1304 /* Immediate refill */ 1339 1305 rbi->skb = new_skb; 1340 - rbi->dma_addr = dma_map_single(&adapter->pdev->dev, 1341 - rbi->skb->data, rbi->len, 1342 - PCI_DMA_FROMDEVICE); 1306 + rbi->dma_addr = new_dma_addr; 1343 1307 rxd->addr = cpu_to_le64(rbi->dma_addr); 1344 1308 rxd->len = rbi->len; 1345 1309 if (adapter->version == 2 && ··· 1380 1348 skip_page_frags = true; 1381 1349 goto rcd_done; 1382 1350 } 1351 + new_dma_addr = dma_map_page(&adapter->pdev->dev 1352 + , rbi->page, 1353 + 0, PAGE_SIZE, 1354 + PCI_DMA_FROMDEVICE); 1355 + if (dma_mapping_error(&adapter->pdev->dev, 1356 + new_dma_addr)) { 1357 + put_page(new_page); 1358 + rq->stats.rx_buf_alloc_failure++; 1359 + dev_kfree_skb(ctx->skb); 1360 + ctx->skb = NULL; 1361 + skip_page_frags = true; 1362 + goto rcd_done; 1363 + } 1383 1364 1384 1365 dma_unmap_page(&adapter->pdev->dev, 1385 1366 rbi->dma_addr, rbi->len, ··· 1402 1357 1403 1358 /* Immediate refill */ 1404 1359 rbi->page = new_page; 1405 - rbi->dma_addr = dma_map_page(&adapter->pdev->dev 1406 - , rbi->page, 1407 - 0, PAGE_SIZE, 1408 - PCI_DMA_FROMDEVICE); 1360 + rbi->dma_addr = new_dma_addr; 1409 1361 rxd->addr = cpu_to_le64(rbi->dma_addr); 1410 1362 rxd->len = rbi->len; 1411 1363 } ··· 2209 2167 PCI_DMA_TODEVICE); 2210 2168 } 2211 2169 2212 - if (new_table_pa) { 2170 + if (!dma_mapping_error(&adapter->pdev->dev, 2171 + new_table_pa)) { 2213 2172 new_mode |= VMXNET3_RXM_MCAST; 2214 2173 rxConf->mfTablePA = cpu_to_le64(new_table_pa); 2215 2174 } else { ··· 3118 3075 adapter->adapter_pa = dma_map_single(&adapter->pdev->dev, adapter, 3119 3076 sizeof(struct vmxnet3_adapter), 3120 3077 PCI_DMA_TODEVICE); 3078 + if (dma_mapping_error(&adapter->pdev->dev, adapter->adapter_pa)) { 3079 + dev_err(&pdev->dev, "Failed to map dma\n"); 3080 + err = -EFAULT; 3081 + goto err_dma_map; 3082 + } 3121 3083 adapter->shared = dma_alloc_coherent( 3122 3084 &adapter->pdev->dev, 3123 3085 sizeof(struct Vmxnet3_DriverShared), ··· 3281 3233 err_alloc_shared: 3282 3234 dma_unmap_single(&adapter->pdev->dev, adapter->adapter_pa, 3283 3235 sizeof(struct vmxnet3_adapter), PCI_DMA_TODEVICE); 3236 + err_dma_map: 3284 3237 free_netdev(netdev); 3285 3238 return err; 3286 3239 }
+1 -10
drivers/net/vrf.c
··· 907 907 struct nlattr *tb[], struct nlattr *data[]) 908 908 { 909 909 struct net_vrf *vrf = netdev_priv(dev); 910 - int err; 911 910 912 911 if (!data || !data[IFLA_VRF_TABLE]) 913 912 return -EINVAL; ··· 915 916 916 917 dev->priv_flags |= IFF_L3MDEV_MASTER; 917 918 918 - err = register_netdevice(dev); 919 - if (err < 0) 920 - goto out_fail; 921 - 922 - return 0; 923 - 924 - out_fail: 925 - free_netdev(dev); 926 - return err; 919 + return register_netdevice(dev); 927 920 } 928 921 929 922 static size_t vrf_nl_getsize(const struct net_device *dev)
+5 -5
drivers/net/wan/hdlc_fr.c
··· 1075 1075 1076 1076 used = pvc_is_used(pvc); 1077 1077 1078 - if (type == ARPHRD_ETHER) { 1078 + if (type == ARPHRD_ETHER) 1079 1079 dev = alloc_netdev(0, "pvceth%d", NET_NAME_UNKNOWN, 1080 1080 ether_setup); 1081 - dev->priv_flags &= ~IFF_TX_SKB_SHARING; 1082 - } else 1081 + else 1083 1082 dev = alloc_netdev(0, "pvc%d", NET_NAME_UNKNOWN, pvc_setup); 1084 1083 1085 1084 if (!dev) { ··· 1087 1088 return -ENOBUFS; 1088 1089 } 1089 1090 1090 - if (type == ARPHRD_ETHER) 1091 + if (type == ARPHRD_ETHER) { 1092 + dev->priv_flags &= ~IFF_TX_SKB_SHARING; 1091 1093 eth_hw_addr_random(dev); 1092 - else { 1094 + } else { 1093 1095 *(__be16*)dev->dev_addr = htons(dlci); 1094 1096 dlci_to_q922(dev->broadcast, dlci); 1095 1097 }
+1 -5
drivers/net/wan/x25_asy.c
··· 549 549 550 550 static int x25_asy_open_tty(struct tty_struct *tty) 551 551 { 552 - struct x25_asy *sl = tty->disc_data; 552 + struct x25_asy *sl; 553 553 int err; 554 554 555 555 if (tty->ops->write == NULL) 556 556 return -EOPNOTSUPP; 557 - 558 - /* First make sure we're not already connected. */ 559 - if (sl && sl->magic == X25_ASY_MAGIC) 560 - return -EEXIST; 561 557 562 558 /* OK. Find a free X.25 channel to use. */ 563 559 sl = x25_asy_alloc();
+47 -2
drivers/net/wireless/ath/ath10k/core.c
··· 51 51 static const struct ath10k_hw_params ath10k_hw_params_list[] = { 52 52 { 53 53 .id = QCA988X_HW_2_0_VERSION, 54 + .dev_id = QCA988X_2_0_DEVICE_ID, 54 55 .name = "qca988x hw2.0", 55 56 .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR, 56 57 .uart_pin = 7, ··· 70 69 }, 71 70 { 72 71 .id = QCA6174_HW_2_1_VERSION, 72 + .dev_id = QCA6164_2_1_DEVICE_ID, 73 + .name = "qca6164 hw2.1", 74 + .patch_load_addr = QCA6174_HW_2_1_PATCH_LOAD_ADDR, 75 + .uart_pin = 6, 76 + .otp_exe_param = 0, 77 + .channel_counters_freq_hz = 88000, 78 + .max_probe_resp_desc_thres = 0, 79 + .fw = { 80 + .dir = QCA6174_HW_2_1_FW_DIR, 81 + .fw = QCA6174_HW_2_1_FW_FILE, 82 + .otp = QCA6174_HW_2_1_OTP_FILE, 83 + .board = QCA6174_HW_2_1_BOARD_DATA_FILE, 84 + .board_size = QCA6174_BOARD_DATA_SZ, 85 + .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ, 86 + }, 87 + }, 88 + { 89 + .id = QCA6174_HW_2_1_VERSION, 90 + .dev_id = QCA6174_2_1_DEVICE_ID, 73 91 .name = "qca6174 hw2.1", 74 92 .patch_load_addr = QCA6174_HW_2_1_PATCH_LOAD_ADDR, 75 93 .uart_pin = 6, ··· 106 86 }, 107 87 { 108 88 .id = QCA6174_HW_3_0_VERSION, 89 + .dev_id = QCA6174_2_1_DEVICE_ID, 109 90 .name = "qca6174 hw3.0", 110 91 .patch_load_addr = QCA6174_HW_3_0_PATCH_LOAD_ADDR, 111 92 .uart_pin = 6, ··· 124 103 }, 125 104 { 126 105 .id = QCA6174_HW_3_2_VERSION, 106 + .dev_id = QCA6174_2_1_DEVICE_ID, 127 107 .name = "qca6174 hw3.2", 128 108 .patch_load_addr = QCA6174_HW_3_0_PATCH_LOAD_ADDR, 129 109 .uart_pin = 6, ··· 143 121 }, 144 122 { 145 123 .id = QCA99X0_HW_2_0_DEV_VERSION, 124 + .dev_id = QCA99X0_2_0_DEVICE_ID, 146 125 .name = "qca99x0 hw2.0", 147 126 .patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR, 148 127 .uart_pin = 7, ··· 162 139 }, 163 140 { 164 141 .id = QCA9377_HW_1_0_DEV_VERSION, 142 + .dev_id = QCA9377_1_0_DEVICE_ID, 165 143 .name = "qca9377 hw1.0", 166 144 .patch_load_addr = QCA9377_HW_1_0_PATCH_LOAD_ADDR, 167 - .uart_pin = 7, 145 + .uart_pin = 6, 168 146 .otp_exe_param = 0, 147 + .channel_counters_freq_hz = 88000, 148 + .max_probe_resp_desc_thres = 0, 149 + .fw = { 150 + .dir = QCA9377_HW_1_0_FW_DIR, 151 + .fw = QCA9377_HW_1_0_FW_FILE, 152 + .otp = QCA9377_HW_1_0_OTP_FILE, 153 + .board = QCA9377_HW_1_0_BOARD_DATA_FILE, 154 + .board_size = QCA9377_BOARD_DATA_SZ, 155 + .board_ext_size = QCA9377_BOARD_EXT_DATA_SZ, 156 + }, 157 + }, 158 + { 159 + .id = QCA9377_HW_1_1_DEV_VERSION, 160 + .dev_id = QCA9377_1_0_DEVICE_ID, 161 + .name = "qca9377 hw1.1", 162 + .patch_load_addr = QCA9377_HW_1_0_PATCH_LOAD_ADDR, 163 + .uart_pin = 6, 164 + .otp_exe_param = 0, 165 + .channel_counters_freq_hz = 88000, 166 + .max_probe_resp_desc_thres = 0, 169 167 .fw = { 170 168 .dir = QCA9377_HW_1_0_FW_DIR, 171 169 .fw = QCA9377_HW_1_0_FW_FILE, ··· 1307 1263 for (i = 0; i < ARRAY_SIZE(ath10k_hw_params_list); i++) { 1308 1264 hw_params = &ath10k_hw_params_list[i]; 1309 1265 1310 - if (hw_params->id == ar->target_version) 1266 + if (hw_params->id == ar->target_version && 1267 + hw_params->dev_id == ar->dev_id) 1311 1268 break; 1312 1269 } 1313 1270
+1
drivers/net/wireless/ath/ath10k/core.h
··· 636 636 637 637 struct ath10k_hw_params { 638 638 u32 id; 639 + u16 dev_id; 639 640 const char *name; 640 641 u32 patch_load_addr; 641 642 int uart_pin;
+15 -2
drivers/net/wireless/ath/ath10k/hw.h
··· 22 22 23 23 #define ATH10K_FW_DIR "ath10k" 24 24 25 + #define QCA988X_2_0_DEVICE_ID (0x003c) 26 + #define QCA6164_2_1_DEVICE_ID (0x0041) 27 + #define QCA6174_2_1_DEVICE_ID (0x003e) 28 + #define QCA99X0_2_0_DEVICE_ID (0x0040) 29 + #define QCA9377_1_0_DEVICE_ID (0x0042) 30 + 25 31 /* QCA988X 1.0 definitions (unsupported) */ 26 32 #define QCA988X_HW_1_0_CHIP_ID_REV 0x0 27 33 ··· 48 42 #define QCA6174_HW_3_0_VERSION 0x05020000 49 43 #define QCA6174_HW_3_2_VERSION 0x05030000 50 44 45 + /* QCA9377 target BMI version signatures */ 46 + #define QCA9377_HW_1_0_DEV_VERSION 0x05020000 47 + #define QCA9377_HW_1_1_DEV_VERSION 0x05020001 48 + 51 49 enum qca6174_pci_rev { 52 50 QCA6174_PCI_REV_1_1 = 0x11, 53 51 QCA6174_PCI_REV_1_3 = 0x13, ··· 68 58 QCA6174_HW_3_0_CHIP_ID_REV = 8, 69 59 QCA6174_HW_3_1_CHIP_ID_REV = 9, 70 60 QCA6174_HW_3_2_CHIP_ID_REV = 10, 61 + }; 62 + 63 + enum qca9377_chip_id_rev { 64 + QCA9377_HW_1_0_CHIP_ID_REV = 0x0, 65 + QCA9377_HW_1_1_CHIP_ID_REV = 0x1, 71 66 }; 72 67 73 68 #define QCA6174_HW_2_1_FW_DIR "ath10k/QCA6174/hw2.1" ··· 100 85 #define QCA99X0_HW_2_0_PATCH_LOAD_ADDR 0x1234 101 86 102 87 /* QCA9377 1.0 definitions */ 103 - #define QCA9377_HW_1_0_DEV_VERSION 0x05020001 104 - #define QCA9377_HW_1_0_CHIP_ID_REV 0x1 105 88 #define QCA9377_HW_1_0_FW_DIR ATH10K_FW_DIR "/QCA9377/hw1.0" 106 89 #define QCA9377_HW_1_0_FW_FILE "firmware.bin" 107 90 #define QCA9377_HW_1_0_OTP_FILE "otp.bin"
+1 -1
drivers/net/wireless/ath/ath10k/mac.c
··· 4225 4225 4226 4226 static u32 get_nss_from_chainmask(u16 chain_mask) 4227 4227 { 4228 - if ((chain_mask & 0x15) == 0x15) 4228 + if ((chain_mask & 0xf) == 0xf) 4229 4229 return 4; 4230 4230 else if ((chain_mask & 0x7) == 0x7) 4231 4231 return 3;
+43 -10
drivers/net/wireless/ath/ath10k/pci.c
··· 57 57 #define ATH10K_PCI_TARGET_WAIT 3000 58 58 #define ATH10K_PCI_NUM_WARM_RESET_ATTEMPTS 3 59 59 60 - #define QCA988X_2_0_DEVICE_ID (0x003c) 61 - #define QCA6164_2_1_DEVICE_ID (0x0041) 62 - #define QCA6174_2_1_DEVICE_ID (0x003e) 63 - #define QCA99X0_2_0_DEVICE_ID (0x0040) 64 - #define QCA9377_1_0_DEVICE_ID (0x0042) 65 - 66 60 static const struct pci_device_id ath10k_pci_id_table[] = { 67 61 { PCI_VDEVICE(ATHEROS, QCA988X_2_0_DEVICE_ID) }, /* PCI-E QCA988X V2 */ 68 62 { PCI_VDEVICE(ATHEROS, QCA6164_2_1_DEVICE_ID) }, /* PCI-E QCA6164 V2.1 */ ··· 86 92 { QCA6174_2_1_DEVICE_ID, QCA6174_HW_3_2_CHIP_ID_REV }, 87 93 88 94 { QCA99X0_2_0_DEVICE_ID, QCA99X0_HW_2_0_CHIP_ID_REV }, 95 + 89 96 { QCA9377_1_0_DEVICE_ID, QCA9377_HW_1_0_CHIP_ID_REV }, 97 + { QCA9377_1_0_DEVICE_ID, QCA9377_HW_1_1_CHIP_ID_REV }, 90 98 }; 91 99 92 100 static void ath10k_pci_buffer_cleanup(struct ath10k *ar); ··· 107 111 static void ath10k_pci_htc_rx_cb(struct ath10k_ce_pipe *ce_state); 108 112 static void ath10k_pci_htt_tx_cb(struct ath10k_ce_pipe *ce_state); 109 113 static void ath10k_pci_htt_rx_cb(struct ath10k_ce_pipe *ce_state); 114 + static void ath10k_pci_htt_htc_rx_cb(struct ath10k_ce_pipe *ce_state); 110 115 111 - static const struct ce_attr host_ce_config_wlan[] = { 116 + static struct ce_attr host_ce_config_wlan[] = { 112 117 /* CE0: host->target HTC control and raw streams */ 113 118 { 114 119 .flags = CE_ATTR_FLAGS, ··· 125 128 .src_nentries = 0, 126 129 .src_sz_max = 2048, 127 130 .dest_nentries = 512, 128 - .recv_cb = ath10k_pci_htc_rx_cb, 131 + .recv_cb = ath10k_pci_htt_htc_rx_cb, 129 132 }, 130 133 131 134 /* CE2: target->host WMI */ ··· 214 217 }; 215 218 216 219 /* Target firmware's Copy Engine configuration. */ 217 - static const struct ce_pipe_config target_ce_config_wlan[] = { 220 + static struct ce_pipe_config target_ce_config_wlan[] = { 218 221 /* CE0: host->target HTC control and raw streams */ 219 222 { 220 223 .pipenum = __cpu_to_le32(0), ··· 327 330 * This table is derived from the CE_PCI TABLE, above. 328 331 * It is passed to the Target at startup for use by firmware. 329 332 */ 330 - static const struct service_to_pipe target_service_to_ce_map_wlan[] = { 333 + static struct service_to_pipe target_service_to_ce_map_wlan[] = { 331 334 { 332 335 __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VO), 333 336 __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ ··· 1205 1208 ath10k_pci_process_rx_cb(ce_state, ath10k_htc_rx_completion_handler); 1206 1209 } 1207 1210 1211 + static void ath10k_pci_htt_htc_rx_cb(struct ath10k_ce_pipe *ce_state) 1212 + { 1213 + /* CE4 polling needs to be done whenever CE pipe which transports 1214 + * HTT Rx (target->host) is processed. 1215 + */ 1216 + ath10k_ce_per_engine_service(ce_state->ar, 4); 1217 + 1218 + ath10k_pci_process_rx_cb(ce_state, ath10k_htc_rx_completion_handler); 1219 + } 1220 + 1208 1221 /* Called by lower (CE) layer when a send to HTT Target completes. */ 1209 1222 static void ath10k_pci_htt_tx_cb(struct ath10k_ce_pipe *ce_state) 1210 1223 { ··· 2032 2025 } 2033 2026 2034 2027 return 0; 2028 + } 2029 + 2030 + static void ath10k_pci_override_ce_config(struct ath10k *ar) 2031 + { 2032 + struct ce_attr *attr; 2033 + struct ce_pipe_config *config; 2034 + 2035 + /* For QCA6174 we're overriding the Copy Engine 5 configuration, 2036 + * since it is currently used for other feature. 2037 + */ 2038 + 2039 + /* Override Host's Copy Engine 5 configuration */ 2040 + attr = &host_ce_config_wlan[5]; 2041 + attr->src_sz_max = 0; 2042 + attr->dest_nentries = 0; 2043 + 2044 + /* Override Target firmware's Copy Engine configuration */ 2045 + config = &target_ce_config_wlan[5]; 2046 + config->pipedir = __cpu_to_le32(PIPEDIR_OUT); 2047 + config->nbytes_max = __cpu_to_le32(2048); 2048 + 2049 + /* Map from service/endpoint to Copy Engine */ 2050 + target_service_to_ce_map_wlan[15].pipenum = __cpu_to_le32(1); 2035 2051 } 2036 2052 2037 2053 static int ath10k_pci_alloc_pipes(struct ath10k *ar) ··· 3049 3019 ath10k_err(ar, "failed to claim device: %d\n", ret); 3050 3020 goto err_core_destroy; 3051 3021 } 3022 + 3023 + if (QCA_REV_6174(ar)) 3024 + ath10k_pci_override_ce_config(ar); 3052 3025 3053 3026 ret = ath10k_pci_alloc_pipes(ar); 3054 3027 if (ret) {
+1 -1
drivers/net/wireless/iwlwifi/iwl-7000.c
··· 69 69 #include "iwl-agn-hw.h" 70 70 71 71 /* Highest firmware API version supported */ 72 - #define IWL7260_UCODE_API_MAX 17 72 + #define IWL7260_UCODE_API_MAX 19 73 73 74 74 /* Oldest version we won't warn about */ 75 75 #define IWL7260_UCODE_API_OK 13
+1 -1
drivers/net/wireless/iwlwifi/iwl-8000.c
··· 69 69 #include "iwl-agn-hw.h" 70 70 71 71 /* Highest firmware API version supported */ 72 - #define IWL8000_UCODE_API_MAX 17 72 + #define IWL8000_UCODE_API_MAX 19 73 73 74 74 /* Oldest version we won't warn about */ 75 75 #define IWL8000_UCODE_API_OK 13
+2 -6
drivers/net/wireless/iwlwifi/mvm/d3.c
··· 309 309 * to transmit packets to the AP, i.e. the PTK. 310 310 */ 311 311 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { 312 - key->hw_key_idx = 0; 313 312 mvm->ptk_ivlen = key->iv_len; 314 313 mvm->ptk_icvlen = key->icv_len; 314 + ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 0); 315 315 } else { 316 316 /* 317 317 * firmware only supports TSC/RSC for a single key, ··· 319 319 * with new ones -- this relies on mac80211 doing 320 320 * list_add_tail(). 321 321 */ 322 - key->hw_key_idx = 1; 323 322 mvm->gtk_ivlen = key->iv_len; 324 323 mvm->gtk_icvlen = key->icv_len; 324 + ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 1); 325 325 } 326 326 327 - ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, true); 328 327 data->error = ret != 0; 329 328 out_unlock: 330 329 mutex_unlock(&mvm->mutex); ··· 770 771 * back to the runtime firmware image. 771 772 */ 772 773 set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); 773 - 774 - /* We reprogram keys and shouldn't allocate new key indices */ 775 - memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); 776 774 777 775 mvm->ptk_ivlen = 0; 778 776 mvm->ptk_icvlen = 0;
+8 -3
drivers/net/wireless/iwlwifi/mvm/mac80211.c
··· 2941 2941 { 2942 2942 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 2943 2943 int ret; 2944 + u8 key_offset; 2944 2945 2945 2946 if (iwlwifi_mod_params.sw_crypto) { 2946 2947 IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n"); ··· 3007 3006 break; 3008 3007 } 3009 3008 3009 + /* in HW restart reuse the index, otherwise request a new one */ 3010 + if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) 3011 + key_offset = key->hw_key_idx; 3012 + else 3013 + key_offset = STA_KEY_IDX_INVALID; 3014 + 3010 3015 IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n"); 3011 - ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 3012 - test_bit(IWL_MVM_STATUS_IN_HW_RESTART, 3013 - &mvm->status)); 3016 + ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, key_offset); 3014 3017 if (ret) { 3015 3018 IWL_WARN(mvm, "set key failed\n"); 3016 3019 /*
+47 -41
drivers/net/wireless/iwlwifi/mvm/sta.c
··· 1201 1201 return max_offs; 1202 1202 } 1203 1203 1204 - static u8 iwl_mvm_get_key_sta_id(struct ieee80211_vif *vif, 1204 + static u8 iwl_mvm_get_key_sta_id(struct iwl_mvm *mvm, 1205 + struct ieee80211_vif *vif, 1205 1206 struct ieee80211_sta *sta) 1206 1207 { 1207 1208 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); ··· 1219 1218 * station ID, then use AP's station ID. 1220 1219 */ 1221 1220 if (vif->type == NL80211_IFTYPE_STATION && 1222 - mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) 1223 - return mvmvif->ap_sta_id; 1221 + mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) { 1222 + u8 sta_id = mvmvif->ap_sta_id; 1223 + 1224 + sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id], 1225 + lockdep_is_held(&mvm->mutex)); 1226 + /* 1227 + * It is possible that the 'sta' parameter is NULL, 1228 + * for example when a GTK is removed - the sta_id will then 1229 + * be the AP ID, and no station was passed by mac80211. 1230 + */ 1231 + if (IS_ERR_OR_NULL(sta)) 1232 + return IWL_MVM_STATION_COUNT; 1233 + 1234 + return sta_id; 1235 + } 1224 1236 1225 1237 return IWL_MVM_STATION_COUNT; 1226 1238 } ··· 1241 1227 static int iwl_mvm_send_sta_key(struct iwl_mvm *mvm, 1242 1228 struct iwl_mvm_sta *mvm_sta, 1243 1229 struct ieee80211_key_conf *keyconf, bool mcast, 1244 - u32 tkip_iv32, u16 *tkip_p1k, u32 cmd_flags) 1230 + u32 tkip_iv32, u16 *tkip_p1k, u32 cmd_flags, 1231 + u8 key_offset) 1245 1232 { 1246 1233 struct iwl_mvm_add_sta_key_cmd cmd = {}; 1247 1234 __le16 key_flags; ··· 1284 1269 if (mcast) 1285 1270 key_flags |= cpu_to_le16(STA_KEY_MULTICAST); 1286 1271 1287 - cmd.key_offset = keyconf->hw_key_idx; 1272 + cmd.key_offset = key_offset; 1288 1273 cmd.key_flags = key_flags; 1289 1274 cmd.sta_id = sta_id; 1290 1275 ··· 1375 1360 struct ieee80211_vif *vif, 1376 1361 struct ieee80211_sta *sta, 1377 1362 struct ieee80211_key_conf *keyconf, 1363 + u8 key_offset, 1378 1364 bool mcast) 1379 1365 { 1380 1366 struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); ··· 1391 1375 ieee80211_get_key_rx_seq(keyconf, 0, &seq); 1392 1376 ieee80211_get_tkip_rx_p1k(keyconf, addr, seq.tkip.iv32, p1k); 1393 1377 ret = iwl_mvm_send_sta_key(mvm, mvm_sta, keyconf, mcast, 1394 - seq.tkip.iv32, p1k, 0); 1378 + seq.tkip.iv32, p1k, 0, key_offset); 1395 1379 break; 1396 1380 case WLAN_CIPHER_SUITE_CCMP: 1397 1381 case WLAN_CIPHER_SUITE_WEP40: 1398 1382 case WLAN_CIPHER_SUITE_WEP104: 1399 1383 ret = iwl_mvm_send_sta_key(mvm, mvm_sta, keyconf, mcast, 1400 - 0, NULL, 0); 1384 + 0, NULL, 0, key_offset); 1401 1385 break; 1402 1386 default: 1403 1387 ret = iwl_mvm_send_sta_key(mvm, mvm_sta, keyconf, mcast, 1404 - 0, NULL, 0); 1388 + 0, NULL, 0, key_offset); 1405 1389 } 1406 1390 1407 1391 return ret; ··· 1449 1433 struct ieee80211_vif *vif, 1450 1434 struct ieee80211_sta *sta, 1451 1435 struct ieee80211_key_conf *keyconf, 1452 - bool have_key_offset) 1436 + u8 key_offset) 1453 1437 { 1454 1438 bool mcast = !(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE); 1455 1439 u8 sta_id; ··· 1459 1443 lockdep_assert_held(&mvm->mutex); 1460 1444 1461 1445 /* Get the station id from the mvm local station table */ 1462 - sta_id = iwl_mvm_get_key_sta_id(vif, sta); 1446 + sta_id = iwl_mvm_get_key_sta_id(mvm, vif, sta); 1463 1447 if (sta_id == IWL_MVM_STATION_COUNT) { 1464 1448 IWL_ERR(mvm, "Failed to find station id\n"); 1465 1449 return -EINVAL; ··· 1486 1470 if (WARN_ON_ONCE(iwl_mvm_sta_from_mac80211(sta)->vif != vif)) 1487 1471 return -EINVAL; 1488 1472 1489 - if (!have_key_offset) { 1490 - /* 1491 - * The D3 firmware hardcodes the PTK offset to 0, so we have to 1492 - * configure it there. As a result, this workaround exists to 1493 - * let the caller set the key offset (hw_key_idx), see d3.c. 1494 - */ 1495 - keyconf->hw_key_idx = iwl_mvm_set_fw_key_idx(mvm); 1496 - if (keyconf->hw_key_idx == STA_KEY_IDX_INVALID) 1473 + /* If the key_offset is not pre-assigned, we need to find a 1474 + * new offset to use. In normal cases, the offset is not 1475 + * pre-assigned, but during HW_RESTART we want to reuse the 1476 + * same indices, so we pass them when this function is called. 1477 + * 1478 + * In D3 entry, we need to hardcoded the indices (because the 1479 + * firmware hardcodes the PTK offset to 0). In this case, we 1480 + * need to make sure we don't overwrite the hw_key_idx in the 1481 + * keyconf structure, because otherwise we cannot configure 1482 + * the original ones back when resuming. 1483 + */ 1484 + if (key_offset == STA_KEY_IDX_INVALID) { 1485 + key_offset = iwl_mvm_set_fw_key_idx(mvm); 1486 + if (key_offset == STA_KEY_IDX_INVALID) 1497 1487 return -ENOSPC; 1488 + keyconf->hw_key_idx = key_offset; 1498 1489 } 1499 1490 1500 - ret = __iwl_mvm_set_sta_key(mvm, vif, sta, keyconf, mcast); 1491 + ret = __iwl_mvm_set_sta_key(mvm, vif, sta, keyconf, key_offset, mcast); 1501 1492 if (ret) { 1502 1493 __clear_bit(keyconf->hw_key_idx, mvm->fw_key_table); 1503 1494 goto end; ··· 1518 1495 */ 1519 1496 if (keyconf->cipher == WLAN_CIPHER_SUITE_WEP40 || 1520 1497 keyconf->cipher == WLAN_CIPHER_SUITE_WEP104) { 1521 - ret = __iwl_mvm_set_sta_key(mvm, vif, sta, keyconf, !mcast); 1498 + ret = __iwl_mvm_set_sta_key(mvm, vif, sta, keyconf, 1499 + key_offset, !mcast); 1522 1500 if (ret) { 1523 1501 __clear_bit(keyconf->hw_key_idx, mvm->fw_key_table); 1524 1502 __iwl_mvm_remove_sta_key(mvm, sta_id, keyconf, mcast); ··· 1545 1521 lockdep_assert_held(&mvm->mutex); 1546 1522 1547 1523 /* Get the station id from the mvm local station table */ 1548 - sta_id = iwl_mvm_get_key_sta_id(vif, sta); 1524 + sta_id = iwl_mvm_get_key_sta_id(mvm, vif, sta); 1549 1525 1550 1526 IWL_DEBUG_WEP(mvm, "mvm remove dynamic key: idx=%d sta=%d\n", 1551 1527 keyconf->keyidx, sta_id); ··· 1571 1547 return 0; 1572 1548 } 1573 1549 1574 - /* 1575 - * It is possible that the 'sta' parameter is NULL, and thus 1576 - * there is a need to retrieve the sta from the local station table, 1577 - * for example when a GTK is removed (where the sta_id will then be 1578 - * the AP ID, and no station was passed by mac80211.) 1579 - */ 1580 - if (!sta) { 1581 - sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id], 1582 - lockdep_is_held(&mvm->mutex)); 1583 - if (!sta) { 1584 - IWL_ERR(mvm, "Invalid station id\n"); 1585 - return -EINVAL; 1586 - } 1587 - } 1588 - 1589 - if (WARN_ON_ONCE(iwl_mvm_sta_from_mac80211(sta)->vif != vif)) 1590 - return -EINVAL; 1591 - 1592 1550 ret = __iwl_mvm_remove_sta_key(mvm, sta_id, keyconf, mcast); 1593 1551 if (ret) 1594 1552 return ret; ··· 1590 1584 u16 *phase1key) 1591 1585 { 1592 1586 struct iwl_mvm_sta *mvm_sta; 1593 - u8 sta_id = iwl_mvm_get_key_sta_id(vif, sta); 1587 + u8 sta_id = iwl_mvm_get_key_sta_id(mvm, vif, sta); 1594 1588 bool mcast = !(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE); 1595 1589 1596 1590 if (WARN_ON_ONCE(sta_id == IWL_MVM_STATION_COUNT)) ··· 1608 1602 1609 1603 mvm_sta = iwl_mvm_sta_from_mac80211(sta); 1610 1604 iwl_mvm_send_sta_key(mvm, mvm_sta, keyconf, mcast, 1611 - iv32, phase1key, CMD_ASYNC); 1605 + iv32, phase1key, CMD_ASYNC, keyconf->hw_key_idx); 1612 1606 rcu_read_unlock(); 1613 1607 } 1614 1608
+2 -2
drivers/net/wireless/iwlwifi/mvm/sta.h
··· 365 365 int iwl_mvm_set_sta_key(struct iwl_mvm *mvm, 366 366 struct ieee80211_vif *vif, 367 367 struct ieee80211_sta *sta, 368 - struct ieee80211_key_conf *key, 369 - bool have_key_offset); 368 + struct ieee80211_key_conf *keyconf, 369 + u8 key_offset); 370 370 int iwl_mvm_remove_sta_key(struct iwl_mvm *mvm, 371 371 struct ieee80211_vif *vif, 372 372 struct ieee80211_sta *sta,
+18 -1
drivers/net/wireless/iwlwifi/pcie/drv.c
··· 423 423 /* 8000 Series */ 424 424 {IWL_PCI_DEVICE(0x24F3, 0x0010, iwl8260_2ac_cfg)}, 425 425 {IWL_PCI_DEVICE(0x24F3, 0x1010, iwl8260_2ac_cfg)}, 426 + {IWL_PCI_DEVICE(0x24F3, 0x0130, iwl8260_2ac_cfg)}, 427 + {IWL_PCI_DEVICE(0x24F3, 0x1130, iwl8260_2ac_cfg)}, 428 + {IWL_PCI_DEVICE(0x24F3, 0x0132, iwl8260_2ac_cfg)}, 429 + {IWL_PCI_DEVICE(0x24F3, 0x1132, iwl8260_2ac_cfg)}, 426 430 {IWL_PCI_DEVICE(0x24F3, 0x0110, iwl8260_2ac_cfg)}, 431 + {IWL_PCI_DEVICE(0x24F3, 0x01F0, iwl8260_2ac_cfg)}, 432 + {IWL_PCI_DEVICE(0x24F3, 0x0012, iwl8260_2ac_cfg)}, 433 + {IWL_PCI_DEVICE(0x24F3, 0x1012, iwl8260_2ac_cfg)}, 427 434 {IWL_PCI_DEVICE(0x24F3, 0x1110, iwl8260_2ac_cfg)}, 428 435 {IWL_PCI_DEVICE(0x24F3, 0x0050, iwl8260_2ac_cfg)}, 429 436 {IWL_PCI_DEVICE(0x24F3, 0x0250, iwl8260_2ac_cfg)}, 430 437 {IWL_PCI_DEVICE(0x24F3, 0x1050, iwl8260_2ac_cfg)}, 431 438 {IWL_PCI_DEVICE(0x24F3, 0x0150, iwl8260_2ac_cfg)}, 439 + {IWL_PCI_DEVICE(0x24F3, 0x1150, iwl8260_2ac_cfg)}, 432 440 {IWL_PCI_DEVICE(0x24F4, 0x0030, iwl8260_2ac_cfg)}, 433 - {IWL_PCI_DEVICE(0x24F4, 0x1130, iwl8260_2ac_cfg)}, 434 441 {IWL_PCI_DEVICE(0x24F4, 0x1030, iwl8260_2ac_cfg)}, 435 442 {IWL_PCI_DEVICE(0x24F3, 0xC010, iwl8260_2ac_cfg)}, 436 443 {IWL_PCI_DEVICE(0x24F3, 0xC110, iwl8260_2ac_cfg)}, ··· 445 438 {IWL_PCI_DEVICE(0x24F3, 0xC050, iwl8260_2ac_cfg)}, 446 439 {IWL_PCI_DEVICE(0x24F3, 0xD050, iwl8260_2ac_cfg)}, 447 440 {IWL_PCI_DEVICE(0x24F3, 0x8010, iwl8260_2ac_cfg)}, 441 + {IWL_PCI_DEVICE(0x24F3, 0x8110, iwl8260_2ac_cfg)}, 448 442 {IWL_PCI_DEVICE(0x24F3, 0x9010, iwl8260_2ac_cfg)}, 443 + {IWL_PCI_DEVICE(0x24F3, 0x9110, iwl8260_2ac_cfg)}, 449 444 {IWL_PCI_DEVICE(0x24F4, 0x8030, iwl8260_2ac_cfg)}, 450 445 {IWL_PCI_DEVICE(0x24F4, 0x9030, iwl8260_2ac_cfg)}, 446 + {IWL_PCI_DEVICE(0x24F3, 0x8130, iwl8260_2ac_cfg)}, 447 + {IWL_PCI_DEVICE(0x24F3, 0x9130, iwl8260_2ac_cfg)}, 448 + {IWL_PCI_DEVICE(0x24F3, 0x8132, iwl8260_2ac_cfg)}, 449 + {IWL_PCI_DEVICE(0x24F3, 0x9132, iwl8260_2ac_cfg)}, 451 450 {IWL_PCI_DEVICE(0x24F3, 0x8050, iwl8260_2ac_cfg)}, 451 + {IWL_PCI_DEVICE(0x24F3, 0x8150, iwl8260_2ac_cfg)}, 452 452 {IWL_PCI_DEVICE(0x24F3, 0x9050, iwl8260_2ac_cfg)}, 453 + {IWL_PCI_DEVICE(0x24F3, 0x9150, iwl8260_2ac_cfg)}, 453 454 {IWL_PCI_DEVICE(0x24F3, 0x0004, iwl8260_2n_cfg)}, 455 + {IWL_PCI_DEVICE(0x24F3, 0x0044, iwl8260_2n_cfg)}, 454 456 {IWL_PCI_DEVICE(0x24F5, 0x0010, iwl4165_2ac_cfg)}, 455 457 {IWL_PCI_DEVICE(0x24F6, 0x0030, iwl4165_2ac_cfg)}, 456 458 {IWL_PCI_DEVICE(0x24F3, 0x0810, iwl8260_2ac_cfg)}, 457 459 {IWL_PCI_DEVICE(0x24F3, 0x0910, iwl8260_2ac_cfg)}, 458 460 {IWL_PCI_DEVICE(0x24F3, 0x0850, iwl8260_2ac_cfg)}, 459 461 {IWL_PCI_DEVICE(0x24F3, 0x0950, iwl8260_2ac_cfg)}, 462 + {IWL_PCI_DEVICE(0x24F3, 0x0930, iwl8260_2ac_cfg)}, 460 463 #endif /* CONFIG_IWLMVM */ 461 464 462 465 {0}
+1 -1
drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
··· 2272 2272 struct rtl_priv *rtlpriv = rtl_priv(hw); 2273 2273 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 2274 2274 2275 - if (!rtlpci->int_clear) 2275 + if (rtlpci->int_clear) 2276 2276 rtl8821ae_clear_interrupt(hw);/*clear it here first*/ 2277 2277 2278 2278 rtl_write_dword(rtlpriv, REG_HIMR, rtlpci->irq_mask[0] & 0xFFFFFFFF);
+1 -1
drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c
··· 448 448 MODULE_PARM_DESC(msi, "Set to 1 to use MSI interrupts mode (default 1)\n"); 449 449 MODULE_PARM_DESC(debug, "Set debug level (0-5) (default 0)"); 450 450 MODULE_PARM_DESC(disable_watchdog, "Set to 1 to disable the watchdog (default 0)\n"); 451 - MODULE_PARM_DESC(int_clear, "Set to 1 to disable interrupt clear before set (default 0)\n"); 451 + MODULE_PARM_DESC(int_clear, "Set to 0 to disable interrupt clear before set (default 1)\n"); 452 452 453 453 static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume); 454 454
+2 -2
fs/dlm/lowcomms.c
··· 421 421 422 422 if (test_and_clear_bit(CF_APP_LIMITED, &con->flags)) { 423 423 con->sock->sk->sk_write_pending--; 424 - clear_bit(SOCK_ASYNC_NOSPACE, &con->sock->flags); 424 + clear_bit(SOCKWQ_ASYNC_NOSPACE, &con->sock->flags); 425 425 } 426 426 427 427 if (!test_and_set_bit(CF_WRITE_PENDING, &con->flags)) ··· 1448 1448 msg_flags); 1449 1449 if (ret == -EAGAIN || ret == 0) { 1450 1450 if (ret == -EAGAIN && 1451 - test_bit(SOCK_ASYNC_NOSPACE, &con->sock->flags) && 1451 + test_bit(SOCKWQ_ASYNC_NOSPACE, &con->sock->flags) && 1452 1452 !test_and_set_bit(CF_APP_LIMITED, &con->flags)) { 1453 1453 /* Notify TCP that we're limited by the 1454 1454 * application window size.
+4 -1
include/linux/bpf.h
··· 40 40 struct user_struct *user; 41 41 const struct bpf_map_ops *ops; 42 42 struct work_struct work; 43 + atomic_t usercnt; 43 44 }; 44 45 45 46 struct bpf_map_type_list { ··· 168 167 void bpf_prog_put(struct bpf_prog *prog); 169 168 void bpf_prog_put_rcu(struct bpf_prog *prog); 170 169 171 - struct bpf_map *bpf_map_get(u32 ufd); 170 + struct bpf_map *bpf_map_get_with_uref(u32 ufd); 172 171 struct bpf_map *__bpf_map_get(struct fd f); 172 + void bpf_map_inc(struct bpf_map *map, bool uref); 173 + void bpf_map_put_with_uref(struct bpf_map *map); 173 174 void bpf_map_put(struct bpf_map *map); 174 175 175 176 extern int sysctl_unprivileged_bpf_disabled;
+1 -1
include/linux/dns_resolver.h
··· 27 27 #ifdef __KERNEL__ 28 28 29 29 extern int dns_query(const char *type, const char *name, size_t namelen, 30 - const char *options, char **_result, time_t *_expiry); 30 + const char *options, char **_result, time64_t *_expiry); 31 31 32 32 #endif /* KERNEL */ 33 33
+1 -1
include/linux/ipv6.h
··· 227 227 struct ipv6_ac_socklist *ipv6_ac_list; 228 228 struct ipv6_fl_socklist __rcu *ipv6_fl_list; 229 229 230 - struct ipv6_txoptions *opt; 230 + struct ipv6_txoptions __rcu *opt; 231 231 struct sk_buff *pktoptions; 232 232 struct sk_buff *rxpmtu; 233 233 struct inet6_cork cork;
+9 -4
include/linux/net.h
··· 34 34 struct file; 35 35 struct net; 36 36 37 - #define SOCK_ASYNC_NOSPACE 0 38 - #define SOCK_ASYNC_WAITDATA 1 37 + /* Historically, SOCKWQ_ASYNC_NOSPACE & SOCKWQ_ASYNC_WAITDATA were located 38 + * in sock->flags, but moved into sk->sk_wq->flags to be RCU protected. 39 + * Eventually all flags will be in sk->sk_wq_flags. 40 + */ 41 + #define SOCKWQ_ASYNC_NOSPACE 0 42 + #define SOCKWQ_ASYNC_WAITDATA 1 39 43 #define SOCK_NOSPACE 2 40 44 #define SOCK_PASSCRED 3 41 45 #define SOCK_PASSSEC 4 ··· 93 89 /* Note: wait MUST be first field of socket_wq */ 94 90 wait_queue_head_t wait; 95 91 struct fasync_struct *fasync_list; 92 + unsigned long flags; /* %SOCKWQ_ASYNC_NOSPACE, etc */ 96 93 struct rcu_head rcu; 97 94 } ____cacheline_aligned_in_smp; 98 95 ··· 101 96 * struct socket - general BSD socket 102 97 * @state: socket state (%SS_CONNECTED, etc) 103 98 * @type: socket type (%SOCK_STREAM, etc) 104 - * @flags: socket flags (%SOCK_ASYNC_NOSPACE, etc) 99 + * @flags: socket flags (%SOCK_NOSPACE, etc) 105 100 * @ops: protocol specific socket operations 106 101 * @file: File back pointer for gc 107 102 * @sk: internal networking protocol agnostic socket representation ··· 207 202 SOCK_WAKE_URG, 208 203 }; 209 204 210 - int sock_wake_async(struct socket *sk, int how, int band); 205 + int sock_wake_async(struct socket_wq *sk_wq, int how, int band); 211 206 int sock_register(const struct net_proto_family *fam); 212 207 void sock_unregister(int family); 213 208 int __sock_create(struct net *net, int family, int type, int proto,
+2 -1
include/linux/netdevice.h
··· 1398 1398 * @dma: DMA channel 1399 1399 * @mtu: Interface MTU value 1400 1400 * @type: Interface hardware type 1401 - * @hard_header_len: Hardware header length 1401 + * @hard_header_len: Hardware header length, which means that this is the 1402 + * minimum size of a packet. 1402 1403 * 1403 1404 * @needed_headroom: Extra headroom the hardware may need, but not in all 1404 1405 * cases can this be guaranteed
+1
include/net/af_unix.h
··· 62 62 #define UNIX_GC_CANDIDATE 0 63 63 #define UNIX_GC_MAYBE_CYCLE 1 64 64 struct socket_wq peer_wq; 65 + wait_queue_t peer_wake; 65 66 }; 66 67 67 68 static inline struct unix_sock *unix_sk(const struct sock *sk)
+4 -13
include/net/ip6_route.h
··· 133 133 /* 134 134 * Store a destination cache entry in a socket 135 135 */ 136 - static inline void __ip6_dst_store(struct sock *sk, struct dst_entry *dst, 137 - const struct in6_addr *daddr, 138 - const struct in6_addr *saddr) 136 + static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst, 137 + const struct in6_addr *daddr, 138 + const struct in6_addr *saddr) 139 139 { 140 140 struct ipv6_pinfo *np = inet6_sk(sk); 141 - struct rt6_info *rt = (struct rt6_info *) dst; 142 141 142 + np->dst_cookie = rt6_get_cookie((struct rt6_info *)dst); 143 143 sk_setup_caps(sk, dst); 144 144 np->daddr_cache = daddr; 145 145 #ifdef CONFIG_IPV6_SUBTREES 146 146 np->saddr_cache = saddr; 147 147 #endif 148 - np->dst_cookie = rt6_get_cookie(rt); 149 - } 150 - 151 - static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst, 152 - struct in6_addr *daddr, struct in6_addr *saddr) 153 - { 154 - spin_lock(&sk->sk_dst_lock); 155 - __ip6_dst_store(sk, dst, daddr, saddr); 156 - spin_unlock(&sk->sk_dst_lock); 157 148 } 158 149 159 150 static inline bool ipv6_unicast_destination(const struct sk_buff *skb)
+21 -1
include/net/ipv6.h
··· 205 205 */ 206 206 207 207 struct ipv6_txoptions { 208 + atomic_t refcnt; 208 209 /* Length of this structure */ 209 210 int tot_len; 210 211 ··· 218 217 struct ipv6_opt_hdr *dst0opt; 219 218 struct ipv6_rt_hdr *srcrt; /* Routing Header */ 220 219 struct ipv6_opt_hdr *dst1opt; 221 - 220 + struct rcu_head rcu; 222 221 /* Option buffer, as read by IPV6_PKTOPTIONS, starts here. */ 223 222 }; 224 223 ··· 252 251 struct ip6_flowlabel *fl; 253 252 struct rcu_head rcu; 254 253 }; 254 + 255 + static inline struct ipv6_txoptions *txopt_get(const struct ipv6_pinfo *np) 256 + { 257 + struct ipv6_txoptions *opt; 258 + 259 + rcu_read_lock(); 260 + opt = rcu_dereference(np->opt); 261 + if (opt && !atomic_inc_not_zero(&opt->refcnt)) 262 + opt = NULL; 263 + rcu_read_unlock(); 264 + return opt; 265 + } 266 + 267 + static inline void txopt_put(struct ipv6_txoptions *opt) 268 + { 269 + if (opt && atomic_dec_and_test(&opt->refcnt)) 270 + kfree_rcu(opt, rcu); 271 + } 255 272 256 273 struct ip6_flowlabel *fl6_sock_lookup(struct sock *sk, __be32 label); 257 274 struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions *opt_space, ··· 509 490 u32 user; 510 491 const struct in6_addr *src; 511 492 const struct in6_addr *dst; 493 + int iif; 512 494 u8 ecn; 513 495 }; 514 496
+4 -2
include/net/mac80211.h
··· 2003 2003 * it shouldn't be set. 2004 2004 * 2005 2005 * @max_tx_aggregation_subframes: maximum number of subframes in an 2006 - * aggregate an HT driver will transmit, used by the peer as a 2007 - * hint to size its reorder buffer. 2006 + * aggregate an HT driver will transmit. Though ADDBA will advertise 2007 + * a constant value of 64 as some older APs can crash if the window 2008 + * size is smaller (an example is LinkSys WRT120N with FW v1.0.07 2009 + * build 002 Jun 18 2012). 2008 2010 * 2009 2011 * @offchannel_tx_hw_queue: HW queue ID to use for offchannel TX 2010 2012 * (if %IEEE80211_HW_QUEUE_CONTROL is set)
+1 -2
include/net/ndisc.h
··· 181 181 int ndisc_rcv(struct sk_buff *skb); 182 182 183 183 void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit, 184 - const struct in6_addr *daddr, const struct in6_addr *saddr, 185 - struct sk_buff *oskb); 184 + const struct in6_addr *daddr, const struct in6_addr *saddr); 186 185 187 186 void ndisc_send_rs(struct net_device *dev, 188 187 const struct in6_addr *saddr, const struct in6_addr *daddr);
+3
include/net/sch_generic.h
··· 61 61 */ 62 62 #define TCQ_F_WARN_NONWC (1 << 16) 63 63 #define TCQ_F_CPUSTATS 0x20 /* run using percpu statistics */ 64 + #define TCQ_F_NOPARENT 0x40 /* root of its hierarchy : 65 + * qdisc_tree_decrease_qlen() should stop. 66 + */ 64 67 u32 limit; 65 68 const struct Qdisc_ops *ops; 66 69 struct qdisc_size_table __rcu *stab;
+8 -8
include/net/sctp/structs.h
··· 775 775 hb_sent:1, 776 776 777 777 /* Is the Path MTU update pending on this tranport */ 778 - pmtu_pending:1; 778 + pmtu_pending:1, 779 779 780 - /* Has this transport moved the ctsn since we last sacked */ 781 - __u32 sack_generation; 780 + /* Has this transport moved the ctsn since we last sacked */ 781 + sack_generation:1; 782 782 u32 dst_cookie; 783 783 784 784 struct flowi fl; ··· 1482 1482 prsctp_capable:1, /* Can peer do PR-SCTP? */ 1483 1483 auth_capable:1; /* Is peer doing SCTP-AUTH? */ 1484 1484 1485 - /* Ack State : This flag indicates if the next received 1485 + /* sack_needed : This flag indicates if the next received 1486 1486 * : packet is to be responded to with a 1487 - * : SACK. This is initializedto 0. When a packet 1488 - * : is received it is incremented. If this value 1487 + * : SACK. This is initialized to 0. When a packet 1488 + * : is received sack_cnt is incremented. If this value 1489 1489 * : reaches 2 or more, a SACK is sent and the 1490 1490 * : value is reset to 0. Note: This is used only 1491 1491 * : when no DATA chunks are received out of 1492 1492 * : order. When DATA chunks are out of order, 1493 1493 * : SACK's are not delayed (see Section 6). 1494 1494 */ 1495 - __u8 sack_needed; /* Do we need to sack the peer? */ 1495 + __u8 sack_needed:1, /* Do we need to sack the peer? */ 1496 + sack_generation:1; 1496 1497 __u32 sack_cnt; 1497 - __u32 sack_generation; 1498 1498 1499 1499 __u32 adaptation_ind; /* Adaptation Code point. */ 1500 1500
+25 -7
include/net/sock.h
··· 254 254 * @sk_wq: sock wait queue and async head 255 255 * @sk_rx_dst: receive input route used by early demux 256 256 * @sk_dst_cache: destination cache 257 - * @sk_dst_lock: destination cache lock 258 257 * @sk_policy: flow policy 259 258 * @sk_receive_queue: incoming packets 260 259 * @sk_wmem_alloc: transmit queue bytes committed ··· 383 384 int sk_rcvbuf; 384 385 385 386 struct sk_filter __rcu *sk_filter; 386 - struct socket_wq __rcu *sk_wq; 387 - 387 + union { 388 + struct socket_wq __rcu *sk_wq; 389 + struct socket_wq *sk_wq_raw; 390 + }; 388 391 #ifdef CONFIG_XFRM 389 392 struct xfrm_policy *sk_policy[2]; 390 393 #endif 391 394 struct dst_entry *sk_rx_dst; 392 395 struct dst_entry __rcu *sk_dst_cache; 393 - spinlock_t sk_dst_lock; 396 + /* Note: 32bit hole on 64bit arches */ 394 397 atomic_t sk_wmem_alloc; 395 398 atomic_t sk_omem_alloc; 396 399 int sk_sndbuf; ··· 2006 2005 return amt; 2007 2006 } 2008 2007 2009 - static inline void sk_wake_async(struct sock *sk, int how, int band) 2008 + /* Note: 2009 + * We use sk->sk_wq_raw, from contexts knowing this 2010 + * pointer is not NULL and cannot disappear/change. 2011 + */ 2012 + static inline void sk_set_bit(int nr, struct sock *sk) 2010 2013 { 2011 - if (sock_flag(sk, SOCK_FASYNC)) 2012 - sock_wake_async(sk->sk_socket, how, band); 2014 + set_bit(nr, &sk->sk_wq_raw->flags); 2015 + } 2016 + 2017 + static inline void sk_clear_bit(int nr, struct sock *sk) 2018 + { 2019 + clear_bit(nr, &sk->sk_wq_raw->flags); 2020 + } 2021 + 2022 + static inline void sk_wake_async(const struct sock *sk, int how, int band) 2023 + { 2024 + if (sock_flag(sk, SOCK_FASYNC)) { 2025 + rcu_read_lock(); 2026 + sock_wake_async(rcu_dereference(sk->sk_wq), how, band); 2027 + rcu_read_unlock(); 2028 + } 2013 2029 } 2014 2030 2015 2031 /* Since sk_{r,w}mem_alloc sums skb->truesize, even a small frame might
+8 -2
kernel/bpf/arraymap.c
··· 28 28 attr->value_size == 0) 29 29 return ERR_PTR(-EINVAL); 30 30 31 + if (attr->value_size >= 1 << (KMALLOC_SHIFT_MAX - 1)) 32 + /* if value_size is bigger, the user space won't be able to 33 + * access the elements. 34 + */ 35 + return ERR_PTR(-E2BIG); 36 + 31 37 elem_size = round_up(attr->value_size, 8); 32 38 33 39 /* check round_up into zero and u32 overflow */ 34 40 if (elem_size == 0 || 35 - attr->max_entries > (U32_MAX - sizeof(*array)) / elem_size) 41 + attr->max_entries > (U32_MAX - PAGE_SIZE - sizeof(*array)) / elem_size) 36 42 return ERR_PTR(-ENOMEM); 37 43 38 44 array_size = sizeof(*array) + attr->max_entries * elem_size; ··· 111 105 /* all elements already exist */ 112 106 return -EEXIST; 113 107 114 - memcpy(array->value + array->elem_size * index, value, array->elem_size); 108 + memcpy(array->value + array->elem_size * index, value, map->value_size); 115 109 return 0; 116 110 } 117 111
+25 -9
kernel/bpf/hashtab.c
··· 64 64 */ 65 65 goto free_htab; 66 66 67 - err = -ENOMEM; 67 + if (htab->map.value_size >= (1 << (KMALLOC_SHIFT_MAX - 1)) - 68 + MAX_BPF_STACK - sizeof(struct htab_elem)) 69 + /* if value_size is bigger, the user space won't be able to 70 + * access the elements via bpf syscall. This check also makes 71 + * sure that the elem_size doesn't overflow and it's 72 + * kmalloc-able later in htab_map_update_elem() 73 + */ 74 + goto free_htab; 75 + 76 + htab->elem_size = sizeof(struct htab_elem) + 77 + round_up(htab->map.key_size, 8) + 78 + htab->map.value_size; 79 + 68 80 /* prevent zero size kmalloc and check for u32 overflow */ 69 81 if (htab->n_buckets == 0 || 70 82 htab->n_buckets > U32_MAX / sizeof(struct hlist_head)) 71 83 goto free_htab; 72 84 85 + if ((u64) htab->n_buckets * sizeof(struct hlist_head) + 86 + (u64) htab->elem_size * htab->map.max_entries >= 87 + U32_MAX - PAGE_SIZE) 88 + /* make sure page count doesn't overflow */ 89 + goto free_htab; 90 + 91 + htab->map.pages = round_up(htab->n_buckets * sizeof(struct hlist_head) + 92 + htab->elem_size * htab->map.max_entries, 93 + PAGE_SIZE) >> PAGE_SHIFT; 94 + 95 + err = -ENOMEM; 73 96 htab->buckets = kmalloc_array(htab->n_buckets, sizeof(struct hlist_head), 74 97 GFP_USER | __GFP_NOWARN); 75 98 ··· 108 85 raw_spin_lock_init(&htab->lock); 109 86 htab->count = 0; 110 87 111 - htab->elem_size = sizeof(struct htab_elem) + 112 - round_up(htab->map.key_size, 8) + 113 - htab->map.value_size; 114 - 115 - htab->map.pages = round_up(htab->n_buckets * sizeof(struct hlist_head) + 116 - htab->elem_size * htab->map.max_entries, 117 - PAGE_SIZE) >> PAGE_SHIFT; 118 88 return &htab->map; 119 89 120 90 free_htab: ··· 238 222 WARN_ON_ONCE(!rcu_read_lock_held()); 239 223 240 224 /* allocate new element outside of lock */ 241 - l_new = kmalloc(htab->elem_size, GFP_ATOMIC); 225 + l_new = kmalloc(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN); 242 226 if (!l_new) 243 227 return -ENOMEM; 244 228
+3 -3
kernel/bpf/inode.c
··· 34 34 atomic_inc(&((struct bpf_prog *)raw)->aux->refcnt); 35 35 break; 36 36 case BPF_TYPE_MAP: 37 - atomic_inc(&((struct bpf_map *)raw)->refcnt); 37 + bpf_map_inc(raw, true); 38 38 break; 39 39 default: 40 40 WARN_ON_ONCE(1); ··· 51 51 bpf_prog_put(raw); 52 52 break; 53 53 case BPF_TYPE_MAP: 54 - bpf_map_put(raw); 54 + bpf_map_put_with_uref(raw); 55 55 break; 56 56 default: 57 57 WARN_ON_ONCE(1); ··· 64 64 void *raw; 65 65 66 66 *type = BPF_TYPE_MAP; 67 - raw = bpf_map_get(ufd); 67 + raw = bpf_map_get_with_uref(ufd); 68 68 if (IS_ERR(raw)) { 69 69 *type = BPF_TYPE_PROG; 70 70 raw = bpf_prog_get(ufd);
+27 -13
kernel/bpf/syscall.c
··· 82 82 map->ops->map_free(map); 83 83 } 84 84 85 + static void bpf_map_put_uref(struct bpf_map *map) 86 + { 87 + if (atomic_dec_and_test(&map->usercnt)) { 88 + if (map->map_type == BPF_MAP_TYPE_PROG_ARRAY) 89 + bpf_fd_array_map_clear(map); 90 + } 91 + } 92 + 85 93 /* decrement map refcnt and schedule it for freeing via workqueue 86 94 * (unrelying map implementation ops->map_free() might sleep) 87 95 */ ··· 101 93 } 102 94 } 103 95 96 + void bpf_map_put_with_uref(struct bpf_map *map) 97 + { 98 + bpf_map_put_uref(map); 99 + bpf_map_put(map); 100 + } 101 + 104 102 static int bpf_map_release(struct inode *inode, struct file *filp) 105 103 { 106 - struct bpf_map *map = filp->private_data; 107 - 108 - if (map->map_type == BPF_MAP_TYPE_PROG_ARRAY) 109 - /* prog_array stores refcnt-ed bpf_prog pointers 110 - * release them all when user space closes prog_array_fd 111 - */ 112 - bpf_fd_array_map_clear(map); 113 - 114 - bpf_map_put(map); 104 + bpf_map_put_with_uref(filp->private_data); 115 105 return 0; 116 106 } 117 107 ··· 148 142 return PTR_ERR(map); 149 143 150 144 atomic_set(&map->refcnt, 1); 145 + atomic_set(&map->usercnt, 1); 151 146 152 147 err = bpf_map_charge_memlock(map); 153 148 if (err) ··· 181 174 return f.file->private_data; 182 175 } 183 176 184 - struct bpf_map *bpf_map_get(u32 ufd) 177 + void bpf_map_inc(struct bpf_map *map, bool uref) 178 + { 179 + atomic_inc(&map->refcnt); 180 + if (uref) 181 + atomic_inc(&map->usercnt); 182 + } 183 + 184 + struct bpf_map *bpf_map_get_with_uref(u32 ufd) 185 185 { 186 186 struct fd f = fdget(ufd); 187 187 struct bpf_map *map; ··· 197 183 if (IS_ERR(map)) 198 184 return map; 199 185 200 - atomic_inc(&map->refcnt); 186 + bpf_map_inc(map, true); 201 187 fdput(f); 202 188 203 189 return map; ··· 240 226 goto free_key; 241 227 242 228 err = -ENOMEM; 243 - value = kmalloc(map->value_size, GFP_USER); 229 + value = kmalloc(map->value_size, GFP_USER | __GFP_NOWARN); 244 230 if (!value) 245 231 goto free_key; 246 232 ··· 299 285 goto free_key; 300 286 301 287 err = -ENOMEM; 302 - value = kmalloc(map->value_size, GFP_USER); 288 + value = kmalloc(map->value_size, GFP_USER | __GFP_NOWARN); 303 289 if (!value) 304 290 goto free_key; 305 291
+1 -2
kernel/bpf/verifier.c
··· 2021 2021 * will be used by the valid program until it's unloaded 2022 2022 * and all maps are released in free_bpf_prog_info() 2023 2023 */ 2024 - atomic_inc(&map->refcnt); 2025 - 2024 + bpf_map_inc(map, false); 2026 2025 fdput(f); 2027 2026 next_insn: 2028 2027 insn++;
+3 -3
net/bluetooth/af_bluetooth.c
··· 271 271 if (signal_pending(current) || !timeo) 272 272 break; 273 273 274 - set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 274 + sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); 275 275 release_sock(sk); 276 276 timeo = schedule_timeout(timeo); 277 277 lock_sock(sk); 278 - clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 278 + sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); 279 279 } 280 280 281 281 __set_current_state(TASK_RUNNING); ··· 441 441 if (!test_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags) && sock_writeable(sk)) 442 442 mask |= POLLOUT | POLLWRNORM | POLLWRBAND; 443 443 else 444 - set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 444 + sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); 445 445 446 446 return mask; 447 447 }
+6 -1
net/bluetooth/smp.c
··· 3027 3027 3028 3028 BT_DBG("chan %p", chan); 3029 3029 3030 + /* No need to call l2cap_chan_hold() here since we already own 3031 + * the reference taken in smp_new_conn_cb(). This is just the 3032 + * first time that we tie it to a specific pointer. The code in 3033 + * l2cap_core.c ensures that there's no risk this function wont 3034 + * get called if smp_new_conn_cb was previously called. 3035 + */ 3030 3036 conn->smp = chan; 3031 - l2cap_chan_hold(chan); 3032 3037 3033 3038 if (hcon->type == ACL_LINK && test_bit(HCI_CONN_ENCRYPT, &hcon->flags)) 3034 3039 bredr_pairing(chan);
+2 -2
net/caif/caif_socket.c
··· 323 323 !timeo) 324 324 break; 325 325 326 - set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 326 + sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); 327 327 release_sock(sk); 328 328 timeo = schedule_timeout(timeo); 329 329 lock_sock(sk); ··· 331 331 if (sock_flag(sk, SOCK_DEAD)) 332 332 break; 333 333 334 - clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 334 + sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); 335 335 } 336 336 337 337 finish_wait(sk_sleep(sk), &wait);
+1 -1
net/core/datagram.c
··· 785 785 if (sock_writeable(sk)) 786 786 mask |= POLLOUT | POLLWRNORM | POLLWRBAND; 787 787 else 788 - set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 788 + sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); 789 789 790 790 return mask; 791 791 }
+2 -2
net/core/neighbour.c
··· 2215 2215 ndm->ndm_pad2 = 0; 2216 2216 ndm->ndm_flags = pn->flags | NTF_PROXY; 2217 2217 ndm->ndm_type = RTN_UNICAST; 2218 - ndm->ndm_ifindex = pn->dev->ifindex; 2218 + ndm->ndm_ifindex = pn->dev ? pn->dev->ifindex : 0; 2219 2219 ndm->ndm_state = NUD_NONE; 2220 2220 2221 2221 if (nla_put(skb, NDA_DST, tbl->key_len, pn->key)) ··· 2333 2333 if (h > s_h) 2334 2334 s_idx = 0; 2335 2335 for (n = tbl->phash_buckets[h], idx = 0; n; n = n->next) { 2336 - if (dev_net(n->dev) != net) 2336 + if (pneigh_net(n) != net) 2337 2337 continue; 2338 2338 if (idx < s_idx) 2339 2339 goto next;
+21 -11
net/core/netclassid_cgroup.c
··· 56 56 kfree(css_cls_state(css)); 57 57 } 58 58 59 - static int update_classid(const void *v, struct file *file, unsigned n) 59 + static int update_classid_sock(const void *v, struct file *file, unsigned n) 60 60 { 61 61 int err; 62 62 struct socket *sock = sock_from_file(file, &err); ··· 67 67 return 0; 68 68 } 69 69 70 + static void update_classid(struct cgroup_subsys_state *css, void *v) 71 + { 72 + struct css_task_iter it; 73 + struct task_struct *p; 74 + 75 + css_task_iter_start(css, &it); 76 + while ((p = css_task_iter_next(&it))) { 77 + task_lock(p); 78 + iterate_fd(p->files, 0, update_classid_sock, v); 79 + task_unlock(p); 80 + } 81 + css_task_iter_end(&it); 82 + } 83 + 70 84 static void cgrp_attach(struct cgroup_subsys_state *css, 71 85 struct cgroup_taskset *tset) 72 86 { 73 - struct cgroup_cls_state *cs = css_cls_state(css); 74 - void *v = (void *)(unsigned long)cs->classid; 75 - struct task_struct *p; 76 - 77 - cgroup_taskset_for_each(p, tset) { 78 - task_lock(p); 79 - iterate_fd(p->files, 0, update_classid, v); 80 - task_unlock(p); 81 - } 87 + update_classid(css, 88 + (void *)(unsigned long)css_cls_state(css)->classid); 82 89 } 83 90 84 91 static u64 read_classid(struct cgroup_subsys_state *css, struct cftype *cft) ··· 96 89 static int write_classid(struct cgroup_subsys_state *css, struct cftype *cft, 97 90 u64 value) 98 91 { 99 - css_cls_state(css)->classid = (u32) value; 92 + struct cgroup_cls_state *cs = css_cls_state(css); 100 93 94 + cs->classid = (u32)value; 95 + 96 + update_classid(css, (void *)(unsigned long)cs->classid); 101 97 return 0; 102 98 } 103 99
+2
net/core/scm.c
··· 305 305 err = put_user(cmlen, &cm->cmsg_len); 306 306 if (!err) { 307 307 cmlen = CMSG_SPACE(i*sizeof(int)); 308 + if (msg->msg_controllen < cmlen) 309 + cmlen = msg->msg_controllen; 308 310 msg->msg_control += cmlen; 309 311 msg->msg_controllen -= cmlen; 310 312 }
+5 -7
net/core/sock.c
··· 1530 1530 skb_queue_head_init(&newsk->sk_receive_queue); 1531 1531 skb_queue_head_init(&newsk->sk_write_queue); 1532 1532 1533 - spin_lock_init(&newsk->sk_dst_lock); 1534 1533 rwlock_init(&newsk->sk_callback_lock); 1535 1534 lockdep_set_class_and_name(&newsk->sk_callback_lock, 1536 1535 af_callback_keys + newsk->sk_family, ··· 1606 1607 { 1607 1608 u32 max_segs = 1; 1608 1609 1609 - __sk_dst_set(sk, dst); 1610 + sk_dst_set(sk, dst); 1610 1611 sk->sk_route_caps = dst->dev->features; 1611 1612 if (sk->sk_route_caps & NETIF_F_GSO) 1612 1613 sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE; ··· 1814 1815 { 1815 1816 DEFINE_WAIT(wait); 1816 1817 1817 - clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 1818 + sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk); 1818 1819 for (;;) { 1819 1820 if (!timeo) 1820 1821 break; ··· 1860 1861 if (sk_wmem_alloc_get(sk) < sk->sk_sndbuf) 1861 1862 break; 1862 1863 1863 - set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 1864 + sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); 1864 1865 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); 1865 1866 err = -EAGAIN; 1866 1867 if (!timeo) ··· 2047 2048 DEFINE_WAIT(wait); 2048 2049 2049 2050 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); 2050 - set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 2051 + sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); 2051 2052 rc = sk_wait_event(sk, timeo, skb_peek_tail(&sk->sk_receive_queue) != skb); 2052 - clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 2053 + sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); 2053 2054 finish_wait(sk_sleep(sk), &wait); 2054 2055 return rc; 2055 2056 } ··· 2387 2388 } else 2388 2389 sk->sk_wq = NULL; 2389 2390 2390 - spin_lock_init(&sk->sk_dst_lock); 2391 2391 rwlock_init(&sk->sk_callback_lock); 2392 2392 lockdep_set_class_and_name(&sk->sk_callback_lock, 2393 2393 af_callback_keys + sk->sk_family,
+3 -3
net/core/stream.c
··· 39 39 wake_up_interruptible_poll(&wq->wait, POLLOUT | 40 40 POLLWRNORM | POLLWRBAND); 41 41 if (wq && wq->fasync_list && !(sk->sk_shutdown & SEND_SHUTDOWN)) 42 - sock_wake_async(sock, SOCK_WAKE_SPACE, POLL_OUT); 42 + sock_wake_async(wq, SOCK_WAKE_SPACE, POLL_OUT); 43 43 rcu_read_unlock(); 44 44 } 45 45 } ··· 126 126 current_timeo = vm_wait = (prandom_u32() % (HZ / 5)) + 2; 127 127 128 128 while (1) { 129 - set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 129 + sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); 130 130 131 131 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); 132 132 ··· 139 139 } 140 140 if (signal_pending(current)) 141 141 goto do_interrupted; 142 - clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 142 + sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk); 143 143 if (sk_stream_memory_free(sk) && !vm_wait) 144 144 break; 145 145
+23 -14
net/dccp/ipv6.c
··· 202 202 security_req_classify_flow(req, flowi6_to_flowi(&fl6)); 203 203 204 204 205 - final_p = fl6_update_dst(&fl6, np->opt, &final); 205 + rcu_read_lock(); 206 + final_p = fl6_update_dst(&fl6, rcu_dereference(np->opt), &final); 207 + rcu_read_unlock(); 206 208 207 209 dst = ip6_dst_lookup_flow(sk, &fl6, final_p); 208 210 if (IS_ERR(dst)) { ··· 221 219 &ireq->ir_v6_loc_addr, 222 220 &ireq->ir_v6_rmt_addr); 223 221 fl6.daddr = ireq->ir_v6_rmt_addr; 224 - err = ip6_xmit(sk, skb, &fl6, np->opt, np->tclass); 222 + rcu_read_lock(); 223 + err = ip6_xmit(sk, skb, &fl6, rcu_dereference(np->opt), 224 + np->tclass); 225 + rcu_read_unlock(); 225 226 err = net_xmit_eval(err); 226 227 } 227 228 ··· 392 387 struct inet_request_sock *ireq = inet_rsk(req); 393 388 struct ipv6_pinfo *newnp; 394 389 const struct ipv6_pinfo *np = inet6_sk(sk); 390 + struct ipv6_txoptions *opt; 395 391 struct inet_sock *newinet; 396 392 struct dccp6_sock *newdp6; 397 393 struct sock *newsk; ··· 459 453 * comment in that function for the gory details. -acme 460 454 */ 461 455 462 - __ip6_dst_store(newsk, dst, NULL, NULL); 456 + ip6_dst_store(newsk, dst, NULL, NULL); 463 457 newsk->sk_route_caps = dst->dev->features & ~(NETIF_F_IP_CSUM | 464 458 NETIF_F_TSO); 465 459 newdp6 = (struct dccp6_sock *)newsk; ··· 494 488 * Yes, keeping reference count would be much more clever, but we make 495 489 * one more one thing there: reattach optmem to newsk. 496 490 */ 497 - if (np->opt != NULL) 498 - newnp->opt = ipv6_dup_options(newsk, np->opt); 499 - 491 + opt = rcu_dereference(np->opt); 492 + if (opt) { 493 + opt = ipv6_dup_options(newsk, opt); 494 + RCU_INIT_POINTER(newnp->opt, opt); 495 + } 500 496 inet_csk(newsk)->icsk_ext_hdr_len = 0; 501 - if (newnp->opt != NULL) 502 - inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen + 503 - newnp->opt->opt_flen); 497 + if (opt) 498 + inet_csk(newsk)->icsk_ext_hdr_len = opt->opt_nflen + 499 + opt->opt_flen; 504 500 505 501 dccp_sync_mss(newsk, dst_mtu(dst)); 506 502 ··· 765 757 struct ipv6_pinfo *np = inet6_sk(sk); 766 758 struct dccp_sock *dp = dccp_sk(sk); 767 759 struct in6_addr *saddr = NULL, *final_p, final; 760 + struct ipv6_txoptions *opt; 768 761 struct flowi6 fl6; 769 762 struct dst_entry *dst; 770 763 int addr_type; ··· 865 856 fl6.fl6_sport = inet->inet_sport; 866 857 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); 867 858 868 - final_p = fl6_update_dst(&fl6, np->opt, &final); 859 + opt = rcu_dereference_protected(np->opt, sock_owned_by_user(sk)); 860 + final_p = fl6_update_dst(&fl6, opt, &final); 869 861 870 862 dst = ip6_dst_lookup_flow(sk, &fl6, final_p); 871 863 if (IS_ERR(dst)) { ··· 883 873 np->saddr = *saddr; 884 874 inet->inet_rcv_saddr = LOOPBACK4_IPV6; 885 875 886 - __ip6_dst_store(sk, dst, NULL, NULL); 876 + ip6_dst_store(sk, dst, NULL, NULL); 887 877 888 878 icsk->icsk_ext_hdr_len = 0; 889 - if (np->opt != NULL) 890 - icsk->icsk_ext_hdr_len = (np->opt->opt_flen + 891 - np->opt->opt_nflen); 879 + if (opt) 880 + icsk->icsk_ext_hdr_len = opt->opt_flen + opt->opt_nflen; 892 881 893 882 inet->inet_dport = usin->sin6_port; 894 883
+1 -2
net/dccp/proto.c
··· 339 339 if (sk_stream_is_writeable(sk)) { 340 340 mask |= POLLOUT | POLLWRNORM; 341 341 } else { /* send SIGIO later */ 342 - set_bit(SOCK_ASYNC_NOSPACE, 343 - &sk->sk_socket->flags); 342 + sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); 344 343 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); 345 344 346 345 /* Race breaker. If space is freed after
+4 -4
net/decnet/af_decnet.c
··· 1747 1747 } 1748 1748 1749 1749 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); 1750 - set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 1750 + sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); 1751 1751 sk_wait_event(sk, &timeo, dn_data_ready(sk, queue, flags, target)); 1752 - clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 1752 + sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); 1753 1753 finish_wait(sk_sleep(sk), &wait); 1754 1754 } 1755 1755 ··· 2004 2004 } 2005 2005 2006 2006 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); 2007 - set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 2007 + sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); 2008 2008 sk_wait_event(sk, &timeo, 2009 2009 !dn_queue_too_long(scp, queue, flags)); 2010 - clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 2010 + sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); 2011 2011 finish_wait(sk_sleep(sk), &wait); 2012 2012 continue; 2013 2013 }
+1 -1
net/dns_resolver/dns_query.c
··· 67 67 * Returns the size of the result on success, -ve error code otherwise. 68 68 */ 69 69 int dns_query(const char *type, const char *name, size_t namelen, 70 - const char *options, char **_result, time_t *_expiry) 70 + const char *options, char **_result, time64_t *_expiry) 71 71 { 72 72 struct key *rkey; 73 73 const struct user_key_payload *upayload;
+1 -1
net/hsr/hsr_device.c
··· 312 312 return; 313 313 314 314 out: 315 - WARN_ON_ONCE("HSR: Could not send supervision frame\n"); 315 + WARN_ONCE(1, "HSR: Could not send supervision frame\n"); 316 316 kfree_skb(skb); 317 317 } 318 318
+3 -2
net/ipv4/igmp.c
··· 2126 2126 ASSERT_RTNL(); 2127 2127 2128 2128 in_dev = ip_mc_find_dev(net, imr); 2129 - if (!in_dev) { 2129 + if (!imr->imr_ifindex && !imr->imr_address.s_addr && !in_dev) { 2130 2130 ret = -ENODEV; 2131 2131 goto out; 2132 2132 } ··· 2147 2147 2148 2148 *imlp = iml->next_rcu; 2149 2149 2150 - ip_mc_dec_group(in_dev, group); 2150 + if (in_dev) 2151 + ip_mc_dec_group(in_dev, group); 2151 2152 2152 2153 /* decrease mem now to avoid the memleak warning */ 2153 2154 atomic_sub(sizeof(*iml), &sk->sk_omem_alloc);
+8 -15
net/ipv4/ipmr.c
··· 134 134 struct mfc_cache *c, struct rtmsg *rtm); 135 135 static void mroute_netlink_event(struct mr_table *mrt, struct mfc_cache *mfc, 136 136 int cmd); 137 - static void mroute_clean_tables(struct mr_table *mrt); 137 + static void mroute_clean_tables(struct mr_table *mrt, bool all); 138 138 static void ipmr_expire_process(unsigned long arg); 139 139 140 140 #ifdef CONFIG_IP_MROUTE_MULTIPLE_TABLES ··· 350 350 static void ipmr_free_table(struct mr_table *mrt) 351 351 { 352 352 del_timer_sync(&mrt->ipmr_expire_timer); 353 - mroute_clean_tables(mrt); 353 + mroute_clean_tables(mrt, true); 354 354 kfree(mrt); 355 355 } 356 356 ··· 441 441 return dev; 442 442 443 443 failure: 444 - /* allow the register to be completed before unregistering. */ 445 - rtnl_unlock(); 446 - rtnl_lock(); 447 - 448 444 unregister_netdevice(dev); 449 445 return NULL; 450 446 } ··· 536 540 return dev; 537 541 538 542 failure: 539 - /* allow the register to be completed before unregistering. */ 540 - rtnl_unlock(); 541 - rtnl_lock(); 542 - 543 543 unregister_netdevice(dev); 544 544 return NULL; 545 545 } ··· 1200 1208 * Close the multicast socket, and clear the vif tables etc 1201 1209 */ 1202 1210 1203 - static void mroute_clean_tables(struct mr_table *mrt) 1211 + static void mroute_clean_tables(struct mr_table *mrt, bool all) 1204 1212 { 1205 1213 int i; 1206 1214 LIST_HEAD(list); ··· 1209 1217 /* Shut down all active vif entries */ 1210 1218 1211 1219 for (i = 0; i < mrt->maxvif; i++) { 1212 - if (!(mrt->vif_table[i].flags & VIFF_STATIC)) 1213 - vif_delete(mrt, i, 0, &list); 1220 + if (!all && (mrt->vif_table[i].flags & VIFF_STATIC)) 1221 + continue; 1222 + vif_delete(mrt, i, 0, &list); 1214 1223 } 1215 1224 unregister_netdevice_many(&list); 1216 1225 ··· 1219 1226 1220 1227 for (i = 0; i < MFC_LINES; i++) { 1221 1228 list_for_each_entry_safe(c, next, &mrt->mfc_cache_array[i], list) { 1222 - if (c->mfc_flags & MFC_STATIC) 1229 + if (!all && (c->mfc_flags & MFC_STATIC)) 1223 1230 continue; 1224 1231 list_del_rcu(&c->list); 1225 1232 mroute_netlink_event(mrt, c, RTM_DELROUTE); ··· 1254 1261 NETCONFA_IFINDEX_ALL, 1255 1262 net->ipv4.devconf_all); 1256 1263 RCU_INIT_POINTER(mrt->mroute_sk, NULL); 1257 - mroute_clean_tables(mrt); 1264 + mroute_clean_tables(mrt, false); 1258 1265 } 1259 1266 } 1260 1267 rtnl_unlock();
+3 -4
net/ipv4/tcp.c
··· 517 517 if (sk_stream_is_writeable(sk)) { 518 518 mask |= POLLOUT | POLLWRNORM; 519 519 } else { /* send SIGIO later */ 520 - set_bit(SOCK_ASYNC_NOSPACE, 521 - &sk->sk_socket->flags); 520 + sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); 522 521 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); 523 522 524 523 /* Race breaker. If space is freed after ··· 905 906 goto out_err; 906 907 } 907 908 908 - clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 909 + sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk); 909 910 910 911 mss_now = tcp_send_mss(sk, &size_goal, flags); 911 912 copied = 0; ··· 1133 1134 } 1134 1135 1135 1136 /* This should be in poll */ 1136 - clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 1137 + sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk); 1137 1138 1138 1139 mss_now = tcp_send_mss(sk, &size_goal, flags); 1139 1140
+20 -3
net/ipv4/tcp_input.c
··· 4481 4481 int tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size) 4482 4482 { 4483 4483 struct sk_buff *skb; 4484 + int err = -ENOMEM; 4485 + int data_len = 0; 4484 4486 bool fragstolen; 4485 4487 4486 4488 if (size == 0) 4487 4489 return 0; 4488 4490 4489 - skb = alloc_skb(size, sk->sk_allocation); 4491 + if (size > PAGE_SIZE) { 4492 + int npages = min_t(size_t, size >> PAGE_SHIFT, MAX_SKB_FRAGS); 4493 + 4494 + data_len = npages << PAGE_SHIFT; 4495 + size = data_len + (size & ~PAGE_MASK); 4496 + } 4497 + skb = alloc_skb_with_frags(size - data_len, data_len, 4498 + PAGE_ALLOC_COSTLY_ORDER, 4499 + &err, sk->sk_allocation); 4490 4500 if (!skb) 4491 4501 goto err; 4502 + 4503 + skb_put(skb, size - data_len); 4504 + skb->data_len = data_len; 4505 + skb->len = size; 4492 4506 4493 4507 if (tcp_try_rmem_schedule(sk, skb, skb->truesize)) 4494 4508 goto err_free; 4495 4509 4496 - if (memcpy_from_msg(skb_put(skb, size), msg, size)) 4510 + err = skb_copy_datagram_from_iter(skb, 0, &msg->msg_iter, size); 4511 + if (err) 4497 4512 goto err_free; 4498 4513 4499 4514 TCP_SKB_CB(skb)->seq = tcp_sk(sk)->rcv_nxt; ··· 4524 4509 err_free: 4525 4510 kfree_skb(skb); 4526 4511 err: 4527 - return -ENOMEM; 4512 + return err; 4513 + 4528 4514 } 4529 4515 4530 4516 static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) ··· 5683 5667 } 5684 5668 5685 5669 tp->rcv_nxt = TCP_SKB_CB(skb)->seq + 1; 5670 + tp->copied_seq = tp->rcv_nxt; 5686 5671 tp->rcv_wup = TCP_SKB_CB(skb)->seq + 1; 5687 5672 5688 5673 /* RFC1323: The window in SYN & SYN/ACK segments is
+2 -1
net/ipv4/tcp_ipv4.c
··· 921 921 } 922 922 923 923 md5sig = rcu_dereference_protected(tp->md5sig_info, 924 - sock_owned_by_user(sk)); 924 + sock_owned_by_user(sk) || 925 + lockdep_is_held(&sk->sk_lock.slock)); 925 926 if (!md5sig) { 926 927 md5sig = kmalloc(sizeof(*md5sig), gfp); 927 928 if (!md5sig)
+13 -1
net/ipv4/tcp_timer.c
··· 168 168 dst_negative_advice(sk); 169 169 if (tp->syn_fastopen || tp->syn_data) 170 170 tcp_fastopen_cache_set(sk, 0, NULL, true, 0); 171 - if (tp->syn_data) 171 + if (tp->syn_data && icsk->icsk_retransmits == 1) 172 172 NET_INC_STATS_BH(sock_net(sk), 173 173 LINUX_MIB_TCPFASTOPENACTIVEFAIL); 174 174 } ··· 176 176 syn_set = true; 177 177 } else { 178 178 if (retransmits_timed_out(sk, sysctl_tcp_retries1, 0, 0)) { 179 + /* Some middle-boxes may black-hole Fast Open _after_ 180 + * the handshake. Therefore we conservatively disable 181 + * Fast Open on this path on recurring timeouts with 182 + * few or zero bytes acked after Fast Open. 183 + */ 184 + if (tp->syn_data_acked && 185 + tp->bytes_acked <= tp->rx_opt.mss_clamp) { 186 + tcp_fastopen_cache_set(sk, 0, NULL, true, 0); 187 + if (icsk->icsk_retransmits == sysctl_tcp_retries1) 188 + NET_INC_STATS_BH(sock_net(sk), 189 + LINUX_MIB_TCPFASTOPENACTIVEFAIL); 190 + } 179 191 /* Black hole detection */ 180 192 tcp_mtu_probing(icsk, sk); 181 193
-1
net/ipv4/udp.c
··· 100 100 #include <linux/slab.h> 101 101 #include <net/tcp_states.h> 102 102 #include <linux/skbuff.h> 103 - #include <linux/netdevice.h> 104 103 #include <linux/proc_fs.h> 105 104 #include <linux/seq_file.h> 106 105 #include <net/net_namespace.h>
+1 -1
net/ipv6/addrconf.c
··· 3642 3642 3643 3643 /* send a neighbour solicitation for our addr */ 3644 3644 addrconf_addr_solict_mult(&ifp->addr, &mcaddr); 3645 - ndisc_send_ns(ifp->idev->dev, &ifp->addr, &mcaddr, &in6addr_any, NULL); 3645 + ndisc_send_ns(ifp->idev->dev, &ifp->addr, &mcaddr, &in6addr_any); 3646 3646 out: 3647 3647 in6_ifa_put(ifp); 3648 3648 rtnl_unlock();
+10 -5
net/ipv6/af_inet6.c
··· 428 428 429 429 /* Free tx options */ 430 430 431 - opt = xchg(&np->opt, NULL); 432 - if (opt) 433 - sock_kfree_s(sk, opt, opt->tot_len); 431 + opt = xchg((__force struct ipv6_txoptions **)&np->opt, NULL); 432 + if (opt) { 433 + atomic_sub(opt->tot_len, &sk->sk_omem_alloc); 434 + txopt_put(opt); 435 + } 434 436 } 435 437 EXPORT_SYMBOL_GPL(inet6_destroy_sock); 436 438 ··· 661 659 fl6.fl6_sport = inet->inet_sport; 662 660 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); 663 661 664 - final_p = fl6_update_dst(&fl6, np->opt, &final); 662 + rcu_read_lock(); 663 + final_p = fl6_update_dst(&fl6, rcu_dereference(np->opt), 664 + &final); 665 + rcu_read_unlock(); 665 666 666 667 dst = ip6_dst_lookup_flow(sk, &fl6, final_p); 667 668 if (IS_ERR(dst)) { ··· 673 668 return PTR_ERR(dst); 674 669 } 675 670 676 - __ip6_dst_store(sk, dst, NULL, NULL); 671 + ip6_dst_store(sk, dst, NULL, NULL); 677 672 } 678 673 679 674 return 0;
+3 -1
net/ipv6/datagram.c
··· 167 167 168 168 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); 169 169 170 - opt = flowlabel ? flowlabel->opt : np->opt; 170 + rcu_read_lock(); 171 + opt = flowlabel ? flowlabel->opt : rcu_dereference(np->opt); 171 172 final_p = fl6_update_dst(&fl6, opt, &final); 173 + rcu_read_unlock(); 172 174 173 175 dst = ip6_dst_lookup_flow(sk, &fl6, final_p); 174 176 err = 0;
+2 -1
net/ipv6/exthdrs.c
··· 727 727 *((char **)&opt2->dst1opt) += dif; 728 728 if (opt2->srcrt) 729 729 *((char **)&opt2->srcrt) += dif; 730 + atomic_set(&opt2->refcnt, 1); 730 731 } 731 732 return opt2; 732 733 } ··· 791 790 return ERR_PTR(-ENOBUFS); 792 791 793 792 memset(opt2, 0, tot_len); 794 - 793 + atomic_set(&opt2->refcnt, 1); 795 794 opt2->tot_len = tot_len; 796 795 p = (char *)(opt2 + 1); 797 796
-14
net/ipv6/icmp.c
··· 834 834 security_sk_classify_flow(sk, flowi6_to_flowi(fl6)); 835 835 } 836 836 837 - /* 838 - * Special lock-class for __icmpv6_sk: 839 - */ 840 - static struct lock_class_key icmpv6_socket_sk_dst_lock_key; 841 - 842 837 static int __net_init icmpv6_sk_init(struct net *net) 843 838 { 844 839 struct sock *sk; ··· 854 859 } 855 860 856 861 net->ipv6.icmp_sk[i] = sk; 857 - 858 - /* 859 - * Split off their lock-class, because sk->sk_dst_lock 860 - * gets used from softirqs, which is safe for 861 - * __icmpv6_sk (because those never get directly used 862 - * via userspace syscalls), but unsafe for normal sockets. 863 - */ 864 - lockdep_set_class(&sk->sk_dst_lock, 865 - &icmpv6_socket_sk_dst_lock_key); 866 862 867 863 /* Enough space for 2 64K ICMP packets, including 868 864 * sk_buff struct overhead.
+9 -12
net/ipv6/inet6_connection_sock.c
··· 78 78 memset(fl6, 0, sizeof(*fl6)); 79 79 fl6->flowi6_proto = proto; 80 80 fl6->daddr = ireq->ir_v6_rmt_addr; 81 - final_p = fl6_update_dst(fl6, np->opt, &final); 81 + rcu_read_lock(); 82 + final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &final); 83 + rcu_read_unlock(); 82 84 fl6->saddr = ireq->ir_v6_loc_addr; 83 85 fl6->flowi6_oif = ireq->ir_iif; 84 86 fl6->flowi6_mark = ireq->ir_mark; ··· 111 109 EXPORT_SYMBOL_GPL(inet6_csk_addr2sockaddr); 112 110 113 111 static inline 114 - void __inet6_csk_dst_store(struct sock *sk, struct dst_entry *dst, 115 - const struct in6_addr *daddr, 116 - const struct in6_addr *saddr) 117 - { 118 - __ip6_dst_store(sk, dst, daddr, saddr); 119 - } 120 - 121 - static inline 122 112 struct dst_entry *__inet6_csk_dst_check(struct sock *sk, u32 cookie) 123 113 { 124 114 return __sk_dst_check(sk, cookie); ··· 136 142 fl6->fl6_dport = inet->inet_dport; 137 143 security_sk_classify_flow(sk, flowi6_to_flowi(fl6)); 138 144 139 - final_p = fl6_update_dst(fl6, np->opt, &final); 145 + rcu_read_lock(); 146 + final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &final); 147 + rcu_read_unlock(); 140 148 141 149 dst = __inet6_csk_dst_check(sk, np->dst_cookie); 142 150 if (!dst) { 143 151 dst = ip6_dst_lookup_flow(sk, fl6, final_p); 144 152 145 153 if (!IS_ERR(dst)) 146 - __inet6_csk_dst_store(sk, dst, NULL, NULL); 154 + ip6_dst_store(sk, dst, NULL, NULL); 147 155 } 148 156 return dst; 149 157 } ··· 171 175 /* Restore final destination back after routing done */ 172 176 fl6.daddr = sk->sk_v6_daddr; 173 177 174 - res = ip6_xmit(sk, skb, &fl6, np->opt, np->tclass); 178 + res = ip6_xmit(sk, skb, &fl6, rcu_dereference(np->opt), 179 + np->tclass); 175 180 rcu_read_unlock(); 176 181 return res; 177 182 }
+1 -1
net/ipv6/ip6_tunnel.c
··· 177 177 int i; 178 178 179 179 for_each_possible_cpu(i) 180 - ip6_tnl_per_cpu_dst_set(raw_cpu_ptr(t->dst_cache), NULL); 180 + ip6_tnl_per_cpu_dst_set(per_cpu_ptr(t->dst_cache, i), NULL); 181 181 } 182 182 EXPORT_SYMBOL_GPL(ip6_tnl_dst_reset); 183 183
+8 -11
net/ipv6/ip6mr.c
··· 118 118 int cmd); 119 119 static int ip6mr_rtm_dumproute(struct sk_buff *skb, 120 120 struct netlink_callback *cb); 121 - static void mroute_clean_tables(struct mr6_table *mrt); 121 + static void mroute_clean_tables(struct mr6_table *mrt, bool all); 122 122 static void ipmr_expire_process(unsigned long arg); 123 123 124 124 #ifdef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES ··· 334 334 static void ip6mr_free_table(struct mr6_table *mrt) 335 335 { 336 336 del_timer_sync(&mrt->ipmr_expire_timer); 337 - mroute_clean_tables(mrt); 337 + mroute_clean_tables(mrt, true); 338 338 kfree(mrt); 339 339 } 340 340 ··· 765 765 return dev; 766 766 767 767 failure: 768 - /* allow the register to be completed before unregistering. */ 769 - rtnl_unlock(); 770 - rtnl_lock(); 771 - 772 768 unregister_netdevice(dev); 773 769 return NULL; 774 770 } ··· 1538 1542 * Close the multicast socket, and clear the vif tables etc 1539 1543 */ 1540 1544 1541 - static void mroute_clean_tables(struct mr6_table *mrt) 1545 + static void mroute_clean_tables(struct mr6_table *mrt, bool all) 1542 1546 { 1543 1547 int i; 1544 1548 LIST_HEAD(list); ··· 1548 1552 * Shut down all active vif entries 1549 1553 */ 1550 1554 for (i = 0; i < mrt->maxvif; i++) { 1551 - if (!(mrt->vif6_table[i].flags & VIFF_STATIC)) 1552 - mif6_delete(mrt, i, &list); 1555 + if (!all && (mrt->vif6_table[i].flags & VIFF_STATIC)) 1556 + continue; 1557 + mif6_delete(mrt, i, &list); 1553 1558 } 1554 1559 unregister_netdevice_many(&list); 1555 1560 ··· 1559 1562 */ 1560 1563 for (i = 0; i < MFC6_LINES; i++) { 1561 1564 list_for_each_entry_safe(c, next, &mrt->mfc6_cache_array[i], list) { 1562 - if (c->mfc_flags & MFC_STATIC) 1565 + if (!all && (c->mfc_flags & MFC_STATIC)) 1563 1566 continue; 1564 1567 write_lock_bh(&mrt_lock); 1565 1568 list_del(&c->list); ··· 1622 1625 net->ipv6.devconf_all); 1623 1626 write_unlock_bh(&mrt_lock); 1624 1627 1625 - mroute_clean_tables(mrt); 1628 + mroute_clean_tables(mrt, false); 1626 1629 err = 0; 1627 1630 break; 1628 1631 }
+22 -11
net/ipv6/ipv6_sockglue.c
··· 111 111 icsk->icsk_sync_mss(sk, icsk->icsk_pmtu_cookie); 112 112 } 113 113 } 114 - opt = xchg(&inet6_sk(sk)->opt, opt); 114 + opt = xchg((__force struct ipv6_txoptions **)&inet6_sk(sk)->opt, 115 + opt); 115 116 sk_dst_reset(sk); 116 117 117 118 return opt; ··· 232 231 sk->sk_socket->ops = &inet_dgram_ops; 233 232 sk->sk_family = PF_INET; 234 233 } 235 - opt = xchg(&np->opt, NULL); 236 - if (opt) 237 - sock_kfree_s(sk, opt, opt->tot_len); 234 + opt = xchg((__force struct ipv6_txoptions **)&np->opt, 235 + NULL); 236 + if (opt) { 237 + atomic_sub(opt->tot_len, &sk->sk_omem_alloc); 238 + txopt_put(opt); 239 + } 238 240 pktopt = xchg(&np->pktoptions, NULL); 239 241 kfree_skb(pktopt); 240 242 ··· 407 403 if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW)) 408 404 break; 409 405 410 - opt = ipv6_renew_options(sk, np->opt, optname, 406 + opt = rcu_dereference_protected(np->opt, sock_owned_by_user(sk)); 407 + opt = ipv6_renew_options(sk, opt, optname, 411 408 (struct ipv6_opt_hdr __user *)optval, 412 409 optlen); 413 410 if (IS_ERR(opt)) { ··· 437 432 retv = 0; 438 433 opt = ipv6_update_options(sk, opt); 439 434 sticky_done: 440 - if (opt) 441 - sock_kfree_s(sk, opt, opt->tot_len); 435 + if (opt) { 436 + atomic_sub(opt->tot_len, &sk->sk_omem_alloc); 437 + txopt_put(opt); 438 + } 442 439 break; 443 440 } 444 441 ··· 493 486 break; 494 487 495 488 memset(opt, 0, sizeof(*opt)); 489 + atomic_set(&opt->refcnt, 1); 496 490 opt->tot_len = sizeof(*opt) + optlen; 497 491 retv = -EFAULT; 498 492 if (copy_from_user(opt+1, optval, optlen)) ··· 510 502 retv = 0; 511 503 opt = ipv6_update_options(sk, opt); 512 504 done: 513 - if (opt) 514 - sock_kfree_s(sk, opt, opt->tot_len); 505 + if (opt) { 506 + atomic_sub(opt->tot_len, &sk->sk_omem_alloc); 507 + txopt_put(opt); 508 + } 515 509 break; 516 510 } 517 511 case IPV6_UNICAST_HOPS: ··· 1120 1110 case IPV6_RTHDR: 1121 1111 case IPV6_DSTOPTS: 1122 1112 { 1113 + struct ipv6_txoptions *opt; 1123 1114 1124 1115 lock_sock(sk); 1125 - len = ipv6_getsockopt_sticky(sk, np->opt, 1126 - optname, optval, len); 1116 + opt = rcu_dereference_protected(np->opt, sock_owned_by_user(sk)); 1117 + len = ipv6_getsockopt_sticky(sk, opt, optname, optval, len); 1127 1118 release_sock(sk); 1128 1119 /* check if ipv6_getsockopt_sticky() returns err code */ 1129 1120 if (len < 0)
+3 -7
net/ipv6/ndisc.c
··· 556 556 } 557 557 558 558 void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit, 559 - const struct in6_addr *daddr, const struct in6_addr *saddr, 560 - struct sk_buff *oskb) 559 + const struct in6_addr *daddr, const struct in6_addr *saddr) 561 560 { 562 561 struct sk_buff *skb; 563 562 struct in6_addr addr_buf; ··· 591 592 if (inc_opt) 592 593 ndisc_fill_addr_option(skb, ND_OPT_SOURCE_LL_ADDR, 593 594 dev->dev_addr); 594 - 595 - if (!(dev->priv_flags & IFF_XMIT_DST_RELEASE) && oskb) 596 - skb_dst_copy(skb, oskb); 597 595 598 596 ndisc_send_skb(skb, daddr, saddr); 599 597 } ··· 678 682 "%s: trying to ucast probe in NUD_INVALID: %pI6\n", 679 683 __func__, target); 680 684 } 681 - ndisc_send_ns(dev, target, target, saddr, skb); 685 + ndisc_send_ns(dev, target, target, saddr); 682 686 } else if ((probes -= NEIGH_VAR(neigh->parms, APP_PROBES)) < 0) { 683 687 neigh_app_ns(neigh); 684 688 } else { 685 689 addrconf_addr_solict_mult(target, &mcaddr); 686 - ndisc_send_ns(dev, target, &mcaddr, saddr, skb); 690 + ndisc_send_ns(dev, target, &mcaddr, saddr); 687 691 } 688 692 } 689 693
+3 -2
net/ipv6/netfilter/nf_conntrack_reasm.c
··· 190 190 /* Creation primitives. */ 191 191 static inline struct frag_queue *fq_find(struct net *net, __be32 id, 192 192 u32 user, struct in6_addr *src, 193 - struct in6_addr *dst, u8 ecn) 193 + struct in6_addr *dst, int iif, u8 ecn) 194 194 { 195 195 struct inet_frag_queue *q; 196 196 struct ip6_create_arg arg; ··· 200 200 arg.user = user; 201 201 arg.src = src; 202 202 arg.dst = dst; 203 + arg.iif = iif; 203 204 arg.ecn = ecn; 204 205 205 206 local_bh_disable(); ··· 602 601 fhdr = (struct frag_hdr *)skb_transport_header(clone); 603 602 604 603 fq = fq_find(net, fhdr->identification, user, &hdr->saddr, &hdr->daddr, 605 - ip6_frag_ecn(hdr)); 604 + skb->dev ? skb->dev->ifindex : 0, ip6_frag_ecn(hdr)); 606 605 if (fq == NULL) { 607 606 pr_debug("Can't find and can't create new queue\n"); 608 607 goto ret_orig;
+6 -2
net/ipv6/raw.c
··· 733 733 734 734 static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) 735 735 { 736 + struct ipv6_txoptions *opt_to_free = NULL; 736 737 struct ipv6_txoptions opt_space; 737 738 DECLARE_SOCKADDR(struct sockaddr_in6 *, sin6, msg->msg_name); 738 739 struct in6_addr *daddr, *final_p, final; ··· 840 839 if (!(opt->opt_nflen|opt->opt_flen)) 841 840 opt = NULL; 842 841 } 843 - if (!opt) 844 - opt = np->opt; 842 + if (!opt) { 843 + opt = txopt_get(np); 844 + opt_to_free = opt; 845 + } 845 846 if (flowlabel) 846 847 opt = fl6_merge_options(&opt_space, flowlabel, opt); 847 848 opt = ipv6_fixup_options(&opt_space, opt); ··· 909 906 dst_release(dst); 910 907 out: 911 908 fl6_sock_release(flowlabel); 909 + txopt_put(opt_to_free); 912 910 return err < 0 ? err : len; 913 911 do_confirm: 914 912 dst_confirm(dst);
+7 -3
net/ipv6/reassembly.c
··· 108 108 return fq->id == arg->id && 109 109 fq->user == arg->user && 110 110 ipv6_addr_equal(&fq->saddr, arg->src) && 111 - ipv6_addr_equal(&fq->daddr, arg->dst); 111 + ipv6_addr_equal(&fq->daddr, arg->dst) && 112 + (arg->iif == fq->iif || 113 + !(ipv6_addr_type(arg->dst) & (IPV6_ADDR_MULTICAST | 114 + IPV6_ADDR_LINKLOCAL))); 112 115 } 113 116 EXPORT_SYMBOL(ip6_frag_match); 114 117 ··· 183 180 184 181 static struct frag_queue * 185 182 fq_find(struct net *net, __be32 id, const struct in6_addr *src, 186 - const struct in6_addr *dst, u8 ecn) 183 + const struct in6_addr *dst, int iif, u8 ecn) 187 184 { 188 185 struct inet_frag_queue *q; 189 186 struct ip6_create_arg arg; ··· 193 190 arg.user = IP6_DEFRAG_LOCAL_DELIVER; 194 191 arg.src = src; 195 192 arg.dst = dst; 193 + arg.iif = iif; 196 194 arg.ecn = ecn; 197 195 198 196 hash = inet6_hash_frag(id, src, dst); ··· 555 551 } 556 552 557 553 fq = fq_find(net, fhdr->identification, &hdr->saddr, &hdr->daddr, 558 - ip6_frag_ecn(hdr)); 554 + skb->dev ? skb->dev->ifindex : 0, ip6_frag_ecn(hdr)); 559 555 if (fq) { 560 556 int ret; 561 557
+1 -1
net/ipv6/route.c
··· 523 523 container_of(w, struct __rt6_probe_work, work); 524 524 525 525 addrconf_addr_solict_mult(&work->target, &mcaddr); 526 - ndisc_send_ns(work->dev, &work->target, &mcaddr, NULL, NULL); 526 + ndisc_send_ns(work->dev, &work->target, &mcaddr, NULL); 527 527 dev_put(work->dev); 528 528 kfree(work); 529 529 }
+1 -1
net/ipv6/syncookies.c
··· 222 222 memset(&fl6, 0, sizeof(fl6)); 223 223 fl6.flowi6_proto = IPPROTO_TCP; 224 224 fl6.daddr = ireq->ir_v6_rmt_addr; 225 - final_p = fl6_update_dst(&fl6, np->opt, &final); 225 + final_p = fl6_update_dst(&fl6, rcu_dereference(np->opt), &final); 226 226 fl6.saddr = ireq->ir_v6_loc_addr; 227 227 fl6.flowi6_oif = sk->sk_bound_dev_if; 228 228 fl6.flowi6_mark = ireq->ir_mark;
+19 -13
net/ipv6/tcp_ipv6.c
··· 120 120 struct ipv6_pinfo *np = inet6_sk(sk); 121 121 struct tcp_sock *tp = tcp_sk(sk); 122 122 struct in6_addr *saddr = NULL, *final_p, final; 123 + struct ipv6_txoptions *opt; 123 124 struct flowi6 fl6; 124 125 struct dst_entry *dst; 125 126 int addr_type; ··· 236 235 fl6.fl6_dport = usin->sin6_port; 237 236 fl6.fl6_sport = inet->inet_sport; 238 237 239 - final_p = fl6_update_dst(&fl6, np->opt, &final); 238 + opt = rcu_dereference_protected(np->opt, sock_owned_by_user(sk)); 239 + final_p = fl6_update_dst(&fl6, opt, &final); 240 240 241 241 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); 242 242 ··· 257 255 inet->inet_rcv_saddr = LOOPBACK4_IPV6; 258 256 259 257 sk->sk_gso_type = SKB_GSO_TCPV6; 260 - __ip6_dst_store(sk, dst, NULL, NULL); 258 + ip6_dst_store(sk, dst, NULL, NULL); 261 259 262 260 if (tcp_death_row.sysctl_tw_recycle && 263 261 !tp->rx_opt.ts_recent_stamp && ··· 265 263 tcp_fetch_timewait_stamp(sk, dst); 266 264 267 265 icsk->icsk_ext_hdr_len = 0; 268 - if (np->opt) 269 - icsk->icsk_ext_hdr_len = (np->opt->opt_flen + 270 - np->opt->opt_nflen); 266 + if (opt) 267 + icsk->icsk_ext_hdr_len = opt->opt_flen + 268 + opt->opt_nflen; 271 269 272 270 tp->rx_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr); 273 271 ··· 463 461 if (np->repflow && ireq->pktopts) 464 462 fl6->flowlabel = ip6_flowlabel(ipv6_hdr(ireq->pktopts)); 465 463 466 - err = ip6_xmit(sk, skb, fl6, np->opt, np->tclass); 464 + err = ip6_xmit(sk, skb, fl6, rcu_dereference(np->opt), 465 + np->tclass); 467 466 err = net_xmit_eval(err); 468 467 } 469 468 ··· 975 972 struct inet_request_sock *ireq; 976 973 struct ipv6_pinfo *newnp; 977 974 const struct ipv6_pinfo *np = inet6_sk(sk); 975 + struct ipv6_txoptions *opt; 978 976 struct tcp6_sock *newtcp6sk; 979 977 struct inet_sock *newinet; 980 978 struct tcp_sock *newtp; ··· 1060 1056 */ 1061 1057 1062 1058 newsk->sk_gso_type = SKB_GSO_TCPV6; 1063 - __ip6_dst_store(newsk, dst, NULL, NULL); 1059 + ip6_dst_store(newsk, dst, NULL, NULL); 1064 1060 inet6_sk_rx_dst_set(newsk, skb); 1065 1061 1066 1062 newtcp6sk = (struct tcp6_sock *)newsk; ··· 1102 1098 but we make one more one thing there: reattach optmem 1103 1099 to newsk. 1104 1100 */ 1105 - if (np->opt) 1106 - newnp->opt = ipv6_dup_options(newsk, np->opt); 1107 - 1101 + opt = rcu_dereference(np->opt); 1102 + if (opt) { 1103 + opt = ipv6_dup_options(newsk, opt); 1104 + RCU_INIT_POINTER(newnp->opt, opt); 1105 + } 1108 1106 inet_csk(newsk)->icsk_ext_hdr_len = 0; 1109 - if (newnp->opt) 1110 - inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen + 1111 - newnp->opt->opt_flen); 1107 + if (opt) 1108 + inet_csk(newsk)->icsk_ext_hdr_len = opt->opt_nflen + 1109 + opt->opt_flen; 1112 1110 1113 1111 tcp_ca_openreq_child(newsk, dst); 1114 1112
+6 -2
net/ipv6/udp.c
··· 1110 1110 DECLARE_SOCKADDR(struct sockaddr_in6 *, sin6, msg->msg_name); 1111 1111 struct in6_addr *daddr, *final_p, final; 1112 1112 struct ipv6_txoptions *opt = NULL; 1113 + struct ipv6_txoptions *opt_to_free = NULL; 1113 1114 struct ip6_flowlabel *flowlabel = NULL; 1114 1115 struct flowi6 fl6; 1115 1116 struct dst_entry *dst; ··· 1264 1263 opt = NULL; 1265 1264 connected = 0; 1266 1265 } 1267 - if (!opt) 1268 - opt = np->opt; 1266 + if (!opt) { 1267 + opt = txopt_get(np); 1268 + opt_to_free = opt; 1269 + } 1269 1270 if (flowlabel) 1270 1271 opt = fl6_merge_options(&opt_space, flowlabel, opt); 1271 1272 opt = ipv6_fixup_options(&opt_space, opt); ··· 1376 1373 out: 1377 1374 dst_release(dst); 1378 1375 fl6_sock_release(flowlabel); 1376 + txopt_put(opt_to_free); 1379 1377 if (!err) 1380 1378 return len; 1381 1379 /*
+1 -1
net/iucv/af_iucv.c
··· 1483 1483 if (sock_writeable(sk) && iucv_below_msglim(sk)) 1484 1484 mask |= POLLOUT | POLLWRNORM | POLLWRBAND; 1485 1485 else 1486 - set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 1486 + sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); 1487 1487 1488 1488 return mask; 1489 1489 }
+6 -2
net/l2tp/l2tp_ip6.c
··· 486 486 DECLARE_SOCKADDR(struct sockaddr_l2tpip6 *, lsa, msg->msg_name); 487 487 struct in6_addr *daddr, *final_p, final; 488 488 struct ipv6_pinfo *np = inet6_sk(sk); 489 + struct ipv6_txoptions *opt_to_free = NULL; 489 490 struct ipv6_txoptions *opt = NULL; 490 491 struct ip6_flowlabel *flowlabel = NULL; 491 492 struct dst_entry *dst = NULL; ··· 576 575 opt = NULL; 577 576 } 578 577 579 - if (opt == NULL) 580 - opt = np->opt; 578 + if (!opt) { 579 + opt = txopt_get(np); 580 + opt_to_free = opt; 581 + } 581 582 if (flowlabel) 582 583 opt = fl6_merge_options(&opt_space, flowlabel, opt); 583 584 opt = ipv6_fixup_options(&opt_space, opt); ··· 634 631 dst_release(dst); 635 632 out: 636 633 fl6_sock_release(flowlabel); 634 + txopt_put(opt_to_free); 637 635 638 636 return err < 0 ? err : len; 639 637
+2 -1
net/mac80211/agg-tx.c
··· 500 500 /* send AddBA request */ 501 501 ieee80211_send_addba_request(sdata, sta->sta.addr, tid, 502 502 tid_tx->dialog_token, start_seq_num, 503 - local->hw.max_tx_aggregation_subframes, 503 + IEEE80211_MAX_AMPDU_BUF, 504 504 tid_tx->timeout); 505 505 } 506 506 ··· 926 926 amsdu = capab & IEEE80211_ADDBA_PARAM_AMSDU_MASK; 927 927 tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; 928 928 buf_size = (capab & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) >> 6; 929 + buf_size = min(buf_size, local->hw.max_tx_aggregation_subframes); 929 930 930 931 mutex_lock(&sta->ampdu_mlme.mtx); 931 932
+6 -2
net/mac80211/cfg.c
··· 3454 3454 goto out_unlock; 3455 3455 } 3456 3456 } else { 3457 - /* for cookie below */ 3458 - ack_skb = skb; 3457 + /* Assign a dummy non-zero cookie, it's not sent to 3458 + * userspace in this case but we rely on its value 3459 + * internally in the need_offchan case to distinguish 3460 + * mgmt-tx from remain-on-channel. 3461 + */ 3462 + *cookie = 0xffffffff; 3459 3463 } 3460 3464 3461 3465 if (!need_offchan) {
+3 -2
net/mac80211/iface.c
··· 76 76 void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata, 77 77 bool update_bss) 78 78 { 79 - if (__ieee80211_recalc_txpower(sdata) || update_bss) 79 + if (__ieee80211_recalc_txpower(sdata) || 80 + (update_bss && ieee80211_sdata_running(sdata))) 80 81 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_TXPOWER); 81 82 } 82 83 ··· 1862 1861 unregister_netdevice(sdata->dev); 1863 1862 } else { 1864 1863 cfg80211_unregister_wdev(&sdata->wdev); 1864 + ieee80211_teardown_sdata(sdata); 1865 1865 kfree(sdata); 1866 1866 } 1867 1867 } ··· 1872 1870 if (WARN_ON_ONCE(!test_bit(SDATA_STATE_RUNNING, &sdata->state))) 1873 1871 return; 1874 1872 ieee80211_do_stop(sdata, true); 1875 - ieee80211_teardown_sdata(sdata); 1876 1873 } 1877 1874 1878 1875 void ieee80211_remove_interfaces(struct ieee80211_local *local)
+1 -2
net/mac80211/main.c
··· 541 541 NL80211_FEATURE_HT_IBSS | 542 542 NL80211_FEATURE_VIF_TXPOWER | 543 543 NL80211_FEATURE_MAC_ON_CREATE | 544 - NL80211_FEATURE_USERSPACE_MPM | 545 - NL80211_FEATURE_FULL_AP_CLIENT_STATE; 544 + NL80211_FEATURE_USERSPACE_MPM; 546 545 547 546 if (!ops->hw_scan) 548 547 wiphy->features |= NL80211_FEATURE_LOW_PRIORITY_SCAN |
+4 -4
net/mac80211/mesh_pathtbl.c
··· 779 779 static void mesh_path_node_reclaim(struct rcu_head *rp) 780 780 { 781 781 struct mpath_node *node = container_of(rp, struct mpath_node, rcu); 782 - struct ieee80211_sub_if_data *sdata = node->mpath->sdata; 783 782 784 783 del_timer_sync(&node->mpath->timer); 785 - atomic_dec(&sdata->u.mesh.mpaths); 786 784 kfree(node->mpath); 787 785 kfree(node); 788 786 } ··· 788 790 /* needs to be called with the corresponding hashwlock taken */ 789 791 static void __mesh_path_del(struct mesh_table *tbl, struct mpath_node *node) 790 792 { 791 - struct mesh_path *mpath; 792 - mpath = node->mpath; 793 + struct mesh_path *mpath = node->mpath; 794 + struct ieee80211_sub_if_data *sdata = node->mpath->sdata; 795 + 793 796 spin_lock(&mpath->state_lock); 794 797 mpath->flags |= MESH_PATH_RESOLVING; 795 798 if (mpath->is_gate) ··· 798 799 hlist_del_rcu(&node->list); 799 800 call_rcu(&node->rcu, mesh_path_node_reclaim); 800 801 spin_unlock(&mpath->state_lock); 802 + atomic_dec(&sdata->u.mesh.mpaths); 801 803 atomic_dec(&tbl->entries); 802 804 } 803 805
+5 -4
net/mac80211/scan.c
··· 597 597 /* We need to ensure power level is at max for scanning. */ 598 598 ieee80211_hw_config(local, 0); 599 599 600 - if ((req->channels[0]->flags & 601 - IEEE80211_CHAN_NO_IR) || 600 + if ((req->channels[0]->flags & (IEEE80211_CHAN_NO_IR | 601 + IEEE80211_CHAN_RADAR)) || 602 602 !req->n_ssids) { 603 603 next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; 604 604 } else { ··· 645 645 * TODO: channel switching also consumes quite some time, 646 646 * add that delay as well to get a better estimation 647 647 */ 648 - if (chan->flags & IEEE80211_CHAN_NO_IR) 648 + if (chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR)) 649 649 return IEEE80211_PASSIVE_CHANNEL_TIME; 650 650 return IEEE80211_PROBE_DELAY + IEEE80211_CHANNEL_TIME; 651 651 } ··· 777 777 * 778 778 * In any case, it is not necessary for a passive scan. 779 779 */ 780 - if (chan->flags & IEEE80211_CHAN_NO_IR || !scan_req->n_ssids) { 780 + if ((chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR)) || 781 + !scan_req->n_ssids) { 781 782 *next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; 782 783 local->next_scan_state = SCAN_DECISION; 783 784 return;
+1 -1
net/nfc/llcp_sock.c
··· 572 572 if (sock_writeable(sk) && sk->sk_state == LLCP_CONNECTED) 573 573 mask |= POLLOUT | POLLWRNORM | POLLWRBAND; 574 574 else 575 - set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 575 + sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); 576 576 577 577 pr_debug("mask 0x%x\n", mask); 578 578
+1 -1
net/openvswitch/dp_notify.c
··· 58 58 struct hlist_node *n; 59 59 60 60 hlist_for_each_entry_safe(vport, n, &dp->ports[i], dp_hash_node) { 61 - if (vport->ops->type != OVS_VPORT_TYPE_NETDEV) 61 + if (vport->ops->type == OVS_VPORT_TYPE_INTERNAL) 62 62 continue; 63 63 64 64 if (!(vport->dev->priv_flags & IFF_OVS_DATAPATH))
-1
net/openvswitch/vport-geneve.c
··· 117 117 .destroy = ovs_netdev_tunnel_destroy, 118 118 .get_options = geneve_get_options, 119 119 .send = dev_queue_xmit, 120 - .owner = THIS_MODULE, 121 120 }; 122 121 123 122 static int __init ovs_geneve_tnl_init(void)
-1
net/openvswitch/vport-gre.c
··· 89 89 .create = gre_create, 90 90 .send = dev_queue_xmit, 91 91 .destroy = ovs_netdev_tunnel_destroy, 92 - .owner = THIS_MODULE, 93 92 }; 94 93 95 94 static int __init ovs_gre_tnl_init(void)
+6 -2
net/openvswitch/vport-netdev.c
··· 180 180 if (vport->dev->priv_flags & IFF_OVS_DATAPATH) 181 181 ovs_netdev_detach_dev(vport); 182 182 183 - /* Early release so we can unregister the device */ 183 + /* We can be invoked by both explicit vport deletion and 184 + * underlying netdev deregistration; delete the link only 185 + * if it's not already shutting down. 186 + */ 187 + if (vport->dev->reg_state == NETREG_REGISTERED) 188 + rtnl_delete_link(vport->dev); 184 189 dev_put(vport->dev); 185 - rtnl_delete_link(vport->dev); 186 190 vport->dev = NULL; 187 191 rtnl_unlock(); 188 192
+4 -4
net/openvswitch/vport.c
··· 71 71 return &dev_table[hash & (VPORT_HASH_BUCKETS - 1)]; 72 72 } 73 73 74 - int ovs_vport_ops_register(struct vport_ops *ops) 74 + int __ovs_vport_ops_register(struct vport_ops *ops) 75 75 { 76 76 int err = -EEXIST; 77 77 struct vport_ops *o; ··· 87 87 ovs_unlock(); 88 88 return err; 89 89 } 90 - EXPORT_SYMBOL_GPL(ovs_vport_ops_register); 90 + EXPORT_SYMBOL_GPL(__ovs_vport_ops_register); 91 91 92 92 void ovs_vport_ops_unregister(struct vport_ops *ops) 93 93 { ··· 256 256 * 257 257 * @vport: vport to delete. 258 258 * 259 - * Detaches @vport from its datapath and destroys it. It is possible to fail 260 - * for reasons such as lack of memory. ovs_mutex must be held. 259 + * Detaches @vport from its datapath and destroys it. ovs_mutex must 260 + * be held. 261 261 */ 262 262 void ovs_vport_del(struct vport *vport) 263 263 {
+7 -1
net/openvswitch/vport.h
··· 196 196 return vport->dev->name; 197 197 } 198 198 199 - int ovs_vport_ops_register(struct vport_ops *ops); 199 + int __ovs_vport_ops_register(struct vport_ops *ops); 200 + #define ovs_vport_ops_register(ops) \ 201 + ({ \ 202 + (ops)->owner = THIS_MODULE; \ 203 + __ovs_vport_ops_register(ops); \ 204 + }) 205 + 200 206 void ovs_vport_ops_unregister(struct vport_ops *ops); 201 207 202 208 static inline struct rtable *ovs_tunnel_route_lookup(struct net *net,
+2 -2
net/packet/af_packet.c
··· 2329 2329 static bool ll_header_truncated(const struct net_device *dev, int len) 2330 2330 { 2331 2331 /* net device doesn't like empty head */ 2332 - if (unlikely(len <= dev->hard_header_len)) { 2333 - net_warn_ratelimited("%s: packet size is too short (%d <= %d)\n", 2332 + if (unlikely(len < dev->hard_header_len)) { 2333 + net_warn_ratelimited("%s: packet size is too short (%d < %d)\n", 2334 2334 current->comm, len, dev->hard_header_len); 2335 2335 return true; 2336 2336 }
-6
net/rds/connection.c
··· 186 186 } 187 187 } 188 188 189 - if (trans == NULL) { 190 - kmem_cache_free(rds_conn_slab, conn); 191 - conn = ERR_PTR(-ENODEV); 192 - goto out; 193 - } 194 - 195 189 conn->c_trans = trans; 196 190 197 191 ret = trans->conn_alloc(conn, gfp);
+3 -1
net/rds/send.c
··· 1013 1013 release_sock(sk); 1014 1014 } 1015 1015 1016 - /* racing with another thread binding seems ok here */ 1016 + lock_sock(sk); 1017 1017 if (daddr == 0 || rs->rs_bound_addr == 0) { 1018 + release_sock(sk); 1018 1019 ret = -ENOTCONN; /* XXX not a great errno */ 1019 1020 goto out; 1020 1021 } 1022 + release_sock(sk); 1021 1023 1022 1024 if (payload_len > rds_sk_sndbuf(rs)) { 1023 1025 ret = -EMSGSIZE;
+3 -1
net/rxrpc/ar-ack.c
··· 723 723 724 724 if ((call->state == RXRPC_CALL_CLIENT_AWAIT_REPLY || 725 725 call->state == RXRPC_CALL_SERVER_AWAIT_ACK) && 726 - hard > tx) 726 + hard > tx) { 727 + call->acks_hard = tx; 727 728 goto all_acked; 729 + } 728 730 729 731 smp_rmb(); 730 732 rxrpc_rotate_tx_window(call, hard - 1);
+1 -1
net/rxrpc/ar-output.c
··· 531 531 timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT); 532 532 533 533 /* this should be in poll */ 534 - clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 534 + sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk); 535 535 536 536 if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN)) 537 537 return -EPIPE;
+18 -9
net/sched/sch_api.c
··· 253 253 } 254 254 255 255 /* We know handle. Find qdisc among all qdisc's attached to device 256 - (root qdisc, all its children, children of children etc.) 256 + * (root qdisc, all its children, children of children etc.) 257 + * Note: caller either uses rtnl or rcu_read_lock() 257 258 */ 258 259 259 260 static struct Qdisc *qdisc_match_from_root(struct Qdisc *root, u32 handle) ··· 265 264 root->handle == handle) 266 265 return root; 267 266 268 - list_for_each_entry(q, &root->list, list) { 267 + list_for_each_entry_rcu(q, &root->list, list) { 269 268 if (q->handle == handle) 270 269 return q; 271 270 } ··· 278 277 struct Qdisc *root = qdisc_dev(q)->qdisc; 279 278 280 279 WARN_ON_ONCE(root == &noop_qdisc); 281 - list_add_tail(&q->list, &root->list); 280 + ASSERT_RTNL(); 281 + list_add_tail_rcu(&q->list, &root->list); 282 282 } 283 283 } 284 284 EXPORT_SYMBOL(qdisc_list_add); 285 285 286 286 void qdisc_list_del(struct Qdisc *q) 287 287 { 288 - if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) 289 - list_del(&q->list); 288 + if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) { 289 + ASSERT_RTNL(); 290 + list_del_rcu(&q->list); 291 + } 290 292 } 291 293 EXPORT_SYMBOL(qdisc_list_del); 292 294 ··· 754 750 if (n == 0) 755 751 return; 756 752 drops = max_t(int, n, 0); 753 + rcu_read_lock(); 757 754 while ((parentid = sch->parent)) { 758 755 if (TC_H_MAJ(parentid) == TC_H_MAJ(TC_H_INGRESS)) 759 - return; 756 + break; 760 757 758 + if (sch->flags & TCQ_F_NOPARENT) 759 + break; 760 + /* TODO: perform the search on a per txq basis */ 761 761 sch = qdisc_lookup(qdisc_dev(sch), TC_H_MAJ(parentid)); 762 762 if (sch == NULL) { 763 - WARN_ON(parentid != TC_H_ROOT); 764 - return; 763 + WARN_ON_ONCE(parentid != TC_H_ROOT); 764 + break; 765 765 } 766 766 cops = sch->ops->cl_ops; 767 767 if (cops->qlen_notify) { ··· 776 768 sch->q.qlen -= n; 777 769 __qdisc_qstats_drop(sch, drops); 778 770 } 771 + rcu_read_unlock(); 779 772 } 780 773 EXPORT_SYMBOL(qdisc_tree_decrease_qlen); 781 774 ··· 950 941 } 951 942 lockdep_set_class(qdisc_lock(sch), &qdisc_tx_lock); 952 943 if (!netif_is_multiqueue(dev)) 953 - sch->flags |= TCQ_F_ONETXQUEUE; 944 + sch->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; 954 945 } 955 946 956 947 sch->handle = handle;
+1 -1
net/sched/sch_generic.c
··· 737 737 return; 738 738 } 739 739 if (!netif_is_multiqueue(dev)) 740 - qdisc->flags |= TCQ_F_ONETXQUEUE; 740 + qdisc->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; 741 741 dev_queue->qdisc_sleeping = qdisc; 742 742 } 743 743
+2 -2
net/sched/sch_mq.c
··· 63 63 if (qdisc == NULL) 64 64 goto err; 65 65 priv->qdiscs[ntx] = qdisc; 66 - qdisc->flags |= TCQ_F_ONETXQUEUE; 66 + qdisc->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; 67 67 } 68 68 69 69 sch->flags |= TCQ_F_MQROOT; ··· 156 156 157 157 *old = dev_graft_qdisc(dev_queue, new); 158 158 if (new) 159 - new->flags |= TCQ_F_ONETXQUEUE; 159 + new->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; 160 160 if (dev->flags & IFF_UP) 161 161 dev_activate(dev); 162 162 return 0;
+2 -2
net/sched/sch_mqprio.c
··· 132 132 goto err; 133 133 } 134 134 priv->qdiscs[i] = qdisc; 135 - qdisc->flags |= TCQ_F_ONETXQUEUE; 135 + qdisc->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; 136 136 } 137 137 138 138 /* If the mqprio options indicate that hardware should own ··· 209 209 *old = dev_graft_qdisc(dev_queue, new); 210 210 211 211 if (new) 212 - new->flags |= TCQ_F_ONETXQUEUE; 212 + new->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; 213 213 214 214 if (dev->flags & IFF_UP) 215 215 dev_activate(dev);
+10 -3
net/sctp/ipv6.c
··· 209 209 struct sock *sk = skb->sk; 210 210 struct ipv6_pinfo *np = inet6_sk(sk); 211 211 struct flowi6 *fl6 = &transport->fl.u.ip6; 212 + int res; 212 213 213 214 pr_debug("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n", __func__, skb, 214 215 skb->len, &fl6->saddr, &fl6->daddr); ··· 221 220 222 221 SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS); 223 222 224 - return ip6_xmit(sk, skb, fl6, np->opt, np->tclass); 223 + rcu_read_lock(); 224 + res = ip6_xmit(sk, skb, fl6, rcu_dereference(np->opt), np->tclass); 225 + rcu_read_unlock(); 226 + return res; 225 227 } 226 228 227 229 /* Returns the dst cache entry for the given source and destination ip ··· 266 262 pr_debug("src=%pI6 - ", &fl6->saddr); 267 263 } 268 264 269 - final_p = fl6_update_dst(fl6, np->opt, &final); 265 + rcu_read_lock(); 266 + final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &final); 267 + rcu_read_unlock(); 268 + 270 269 dst = ip6_dst_lookup_flow(sk, fl6, final_p); 271 270 if (!asoc || saddr) 272 271 goto out; ··· 328 321 if (baddr) { 329 322 fl6->saddr = baddr->v6.sin6_addr; 330 323 fl6->fl6_sport = baddr->v6.sin6_port; 331 - final_p = fl6_update_dst(fl6, np->opt, &final); 324 + final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &final); 332 325 dst = ip6_dst_lookup_flow(sk, fl6, final_p); 333 326 } 334 327
+25 -14
net/sctp/socket.c
··· 972 972 return -EFAULT; 973 973 974 974 /* Alloc space for the address array in kernel memory. */ 975 - kaddrs = kmalloc(addrs_size, GFP_KERNEL); 975 + kaddrs = kmalloc(addrs_size, GFP_USER | __GFP_NOWARN); 976 976 if (unlikely(!kaddrs)) 977 977 return -ENOMEM; 978 978 ··· 4928 4928 to = optval + offsetof(struct sctp_getaddrs, addrs); 4929 4929 space_left = len - offsetof(struct sctp_getaddrs, addrs); 4930 4930 4931 - addrs = kmalloc(space_left, GFP_KERNEL); 4931 + addrs = kmalloc(space_left, GFP_USER | __GFP_NOWARN); 4932 4932 if (!addrs) 4933 4933 return -ENOMEM; 4934 4934 ··· 6458 6458 if (sctp_writeable(sk)) { 6459 6459 mask |= POLLOUT | POLLWRNORM; 6460 6460 } else { 6461 - set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 6461 + sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); 6462 6462 /* 6463 6463 * Since the socket is not locked, the buffer 6464 6464 * might be made available after the writeable check and ··· 6801 6801 static void __sctp_write_space(struct sctp_association *asoc) 6802 6802 { 6803 6803 struct sock *sk = asoc->base.sk; 6804 - struct socket *sock = sk->sk_socket; 6805 6804 6806 - if ((sctp_wspace(asoc) > 0) && sock) { 6807 - if (waitqueue_active(&asoc->wait)) 6808 - wake_up_interruptible(&asoc->wait); 6805 + if (sctp_wspace(asoc) <= 0) 6806 + return; 6809 6807 6810 - if (sctp_writeable(sk)) { 6811 - wait_queue_head_t *wq = sk_sleep(sk); 6808 + if (waitqueue_active(&asoc->wait)) 6809 + wake_up_interruptible(&asoc->wait); 6812 6810 6813 - if (wq && waitqueue_active(wq)) 6814 - wake_up_interruptible(wq); 6811 + if (sctp_writeable(sk)) { 6812 + struct socket_wq *wq; 6813 + 6814 + rcu_read_lock(); 6815 + wq = rcu_dereference(sk->sk_wq); 6816 + if (wq) { 6817 + if (waitqueue_active(&wq->wait)) 6818 + wake_up_interruptible(&wq->wait); 6815 6819 6816 6820 /* Note that we try to include the Async I/O support 6817 6821 * here by modeling from the current TCP/UDP code. 6818 6822 * We have not tested with it yet. 6819 6823 */ 6820 6824 if (!(sk->sk_shutdown & SEND_SHUTDOWN)) 6821 - sock_wake_async(sock, 6822 - SOCK_WAKE_SPACE, POLL_OUT); 6825 + sock_wake_async(wq, SOCK_WAKE_SPACE, POLL_OUT); 6823 6826 } 6827 + rcu_read_unlock(); 6824 6828 } 6825 6829 } 6826 6830 ··· 7379 7375 7380 7376 #if IS_ENABLED(CONFIG_IPV6) 7381 7377 7378 + #include <net/transp_v6.h> 7379 + static void sctp_v6_destroy_sock(struct sock *sk) 7380 + { 7381 + sctp_destroy_sock(sk); 7382 + inet6_destroy_sock(sk); 7383 + } 7384 + 7382 7385 struct proto sctpv6_prot = { 7383 7386 .name = "SCTPv6", 7384 7387 .owner = THIS_MODULE, ··· 7395 7384 .accept = sctp_accept, 7396 7385 .ioctl = sctp_ioctl, 7397 7386 .init = sctp_init_sock, 7398 - .destroy = sctp_destroy_sock, 7387 + .destroy = sctp_v6_destroy_sock, 7399 7388 .shutdown = sctp_shutdown, 7400 7389 .setsockopt = sctp_setsockopt, 7401 7390 .getsockopt = sctp_getsockopt,
+7 -14
net/socket.c
··· 1056 1056 return 0; 1057 1057 } 1058 1058 1059 - /* This function may be called only under socket lock or callback_lock or rcu_lock */ 1059 + /* This function may be called only under rcu_lock */ 1060 1060 1061 - int sock_wake_async(struct socket *sock, int how, int band) 1061 + int sock_wake_async(struct socket_wq *wq, int how, int band) 1062 1062 { 1063 - struct socket_wq *wq; 1063 + if (!wq || !wq->fasync_list) 1064 + return -1; 1064 1065 1065 - if (!sock) 1066 - return -1; 1067 - rcu_read_lock(); 1068 - wq = rcu_dereference(sock->wq); 1069 - if (!wq || !wq->fasync_list) { 1070 - rcu_read_unlock(); 1071 - return -1; 1072 - } 1073 1066 switch (how) { 1074 1067 case SOCK_WAKE_WAITD: 1075 - if (test_bit(SOCK_ASYNC_WAITDATA, &sock->flags)) 1068 + if (test_bit(SOCKWQ_ASYNC_WAITDATA, &wq->flags)) 1076 1069 break; 1077 1070 goto call_kill; 1078 1071 case SOCK_WAKE_SPACE: 1079 - if (!test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags)) 1072 + if (!test_and_clear_bit(SOCKWQ_ASYNC_NOSPACE, &wq->flags)) 1080 1073 break; 1081 1074 /* fall through */ 1082 1075 case SOCK_WAKE_IO: ··· 1079 1086 case SOCK_WAKE_URG: 1080 1087 kill_fasync(&wq->fasync_list, SIGURG, band); 1081 1088 } 1082 - rcu_read_unlock(); 1089 + 1083 1090 return 0; 1084 1091 } 1085 1092 EXPORT_SYMBOL(sock_wake_async);
+7 -7
net/sunrpc/xprtsock.c
··· 398 398 if (unlikely(!sock)) 399 399 return -ENOTSOCK; 400 400 401 - clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags); 401 + clear_bit(SOCKWQ_ASYNC_NOSPACE, &sock->flags); 402 402 if (base != 0) { 403 403 addr = NULL; 404 404 addrlen = 0; ··· 442 442 struct sock_xprt *transport = container_of(task->tk_rqstp->rq_xprt, struct sock_xprt, xprt); 443 443 444 444 transport->inet->sk_write_pending--; 445 - clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags); 445 + clear_bit(SOCKWQ_ASYNC_NOSPACE, &transport->sock->flags); 446 446 } 447 447 448 448 /** ··· 467 467 468 468 /* Don't race with disconnect */ 469 469 if (xprt_connected(xprt)) { 470 - if (test_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags)) { 470 + if (test_bit(SOCKWQ_ASYNC_NOSPACE, &transport->sock->flags)) { 471 471 /* 472 472 * Notify TCP that we're limited by the application 473 473 * window size ··· 478 478 xprt_wait_for_buffer_space(task, xs_nospace_callback); 479 479 } 480 480 } else { 481 - clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags); 481 + clear_bit(SOCKWQ_ASYNC_NOSPACE, &transport->sock->flags); 482 482 ret = -ENOTCONN; 483 483 } 484 484 ··· 626 626 case -EPERM: 627 627 /* When the server has died, an ICMP port unreachable message 628 628 * prompts ECONNREFUSED. */ 629 - clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags); 629 + clear_bit(SOCKWQ_ASYNC_NOSPACE, &transport->sock->flags); 630 630 } 631 631 632 632 return status; ··· 715 715 case -EADDRINUSE: 716 716 case -ENOBUFS: 717 717 case -EPIPE: 718 - clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags); 718 + clear_bit(SOCKWQ_ASYNC_NOSPACE, &transport->sock->flags); 719 719 } 720 720 721 721 return status; ··· 1618 1618 1619 1619 if (unlikely(!(xprt = xprt_from_sock(sk)))) 1620 1620 return; 1621 - if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0) 1621 + if (test_and_clear_bit(SOCKWQ_ASYNC_NOSPACE, &sock->flags) == 0) 1622 1622 return; 1623 1623 1624 1624 xprt_write_space(xprt);
+2
net/tipc/link.c
··· 191 191 192 192 snd_l->ackers++; 193 193 rcv_l->acked = snd_l->snd_nxt - 1; 194 + snd_l->state = LINK_ESTABLISHED; 194 195 tipc_link_build_bc_init_msg(uc_l, xmitq); 195 196 } 196 197 ··· 207 206 rcv_l->state = LINK_RESET; 208 207 if (!snd_l->ackers) { 209 208 tipc_link_reset(snd_l); 209 + snd_l->state = LINK_RESET; 210 210 __skb_queue_purge(xmitq); 211 211 } 212 212 }
+7 -3
net/tipc/socket.c
··· 105 105 static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb); 106 106 static void tipc_data_ready(struct sock *sk); 107 107 static void tipc_write_space(struct sock *sk); 108 + static void tipc_sock_destruct(struct sock *sk); 108 109 static int tipc_release(struct socket *sock); 109 110 static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags); 110 111 static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p); ··· 382 381 sk->sk_rcvbuf = sysctl_tipc_rmem[1]; 383 382 sk->sk_data_ready = tipc_data_ready; 384 383 sk->sk_write_space = tipc_write_space; 384 + sk->sk_destruct = tipc_sock_destruct; 385 385 tsk->conn_timeout = CONN_TIMEOUT_DEFAULT; 386 386 tsk->sent_unacked = 0; 387 387 atomic_set(&tsk->dupl_rcvcnt, 0); ··· 471 469 tipc_node_xmit_skb(net, skb, dnode, tsk->portid); 472 470 tipc_node_remove_conn(net, dnode, tsk->portid); 473 471 } 474 - 475 - /* Discard any remaining (connection-based) messages in receive queue */ 476 - __skb_queue_purge(&sk->sk_receive_queue); 477 472 478 473 /* Reject any messages that accumulated in backlog queue */ 479 474 sock->state = SS_DISCONNECTING; ··· 1512 1513 wake_up_interruptible_sync_poll(&wq->wait, POLLIN | 1513 1514 POLLRDNORM | POLLRDBAND); 1514 1515 rcu_read_unlock(); 1516 + } 1517 + 1518 + static void tipc_sock_destruct(struct sock *sk) 1519 + { 1520 + __skb_queue_purge(&sk->sk_receive_queue); 1515 1521 } 1516 1522 1517 1523 /**
+5 -2
net/tipc/udp_media.c
··· 158 158 struct udp_media_addr *src = (struct udp_media_addr *)&b->addr.value; 159 159 struct rtable *rt; 160 160 161 - if (skb_headroom(skb) < UDP_MIN_HEADROOM) 162 - pskb_expand_head(skb, UDP_MIN_HEADROOM, 0, GFP_ATOMIC); 161 + if (skb_headroom(skb) < UDP_MIN_HEADROOM) { 162 + err = pskb_expand_head(skb, UDP_MIN_HEADROOM, 0, GFP_ATOMIC); 163 + if (err) 164 + goto tx_error; 165 + } 163 166 164 167 skb_set_inner_protocol(skb, htons(ETH_P_TIPC)); 165 168 ub = rcu_dereference_rtnl(b->media_ptr);
+231 -37
net/unix/af_unix.c
··· 326 326 return s; 327 327 } 328 328 329 + /* Support code for asymmetrically connected dgram sockets 330 + * 331 + * If a datagram socket is connected to a socket not itself connected 332 + * to the first socket (eg, /dev/log), clients may only enqueue more 333 + * messages if the present receive queue of the server socket is not 334 + * "too large". This means there's a second writeability condition 335 + * poll and sendmsg need to test. The dgram recv code will do a wake 336 + * up on the peer_wait wait queue of a socket upon reception of a 337 + * datagram which needs to be propagated to sleeping would-be writers 338 + * since these might not have sent anything so far. This can't be 339 + * accomplished via poll_wait because the lifetime of the server 340 + * socket might be less than that of its clients if these break their 341 + * association with it or if the server socket is closed while clients 342 + * are still connected to it and there's no way to inform "a polling 343 + * implementation" that it should let go of a certain wait queue 344 + * 345 + * In order to propagate a wake up, a wait_queue_t of the client 346 + * socket is enqueued on the peer_wait queue of the server socket 347 + * whose wake function does a wake_up on the ordinary client socket 348 + * wait queue. This connection is established whenever a write (or 349 + * poll for write) hit the flow control condition and broken when the 350 + * association to the server socket is dissolved or after a wake up 351 + * was relayed. 352 + */ 353 + 354 + static int unix_dgram_peer_wake_relay(wait_queue_t *q, unsigned mode, int flags, 355 + void *key) 356 + { 357 + struct unix_sock *u; 358 + wait_queue_head_t *u_sleep; 359 + 360 + u = container_of(q, struct unix_sock, peer_wake); 361 + 362 + __remove_wait_queue(&unix_sk(u->peer_wake.private)->peer_wait, 363 + q); 364 + u->peer_wake.private = NULL; 365 + 366 + /* relaying can only happen while the wq still exists */ 367 + u_sleep = sk_sleep(&u->sk); 368 + if (u_sleep) 369 + wake_up_interruptible_poll(u_sleep, key); 370 + 371 + return 0; 372 + } 373 + 374 + static int unix_dgram_peer_wake_connect(struct sock *sk, struct sock *other) 375 + { 376 + struct unix_sock *u, *u_other; 377 + int rc; 378 + 379 + u = unix_sk(sk); 380 + u_other = unix_sk(other); 381 + rc = 0; 382 + spin_lock(&u_other->peer_wait.lock); 383 + 384 + if (!u->peer_wake.private) { 385 + u->peer_wake.private = other; 386 + __add_wait_queue(&u_other->peer_wait, &u->peer_wake); 387 + 388 + rc = 1; 389 + } 390 + 391 + spin_unlock(&u_other->peer_wait.lock); 392 + return rc; 393 + } 394 + 395 + static void unix_dgram_peer_wake_disconnect(struct sock *sk, 396 + struct sock *other) 397 + { 398 + struct unix_sock *u, *u_other; 399 + 400 + u = unix_sk(sk); 401 + u_other = unix_sk(other); 402 + spin_lock(&u_other->peer_wait.lock); 403 + 404 + if (u->peer_wake.private == other) { 405 + __remove_wait_queue(&u_other->peer_wait, &u->peer_wake); 406 + u->peer_wake.private = NULL; 407 + } 408 + 409 + spin_unlock(&u_other->peer_wait.lock); 410 + } 411 + 412 + static void unix_dgram_peer_wake_disconnect_wakeup(struct sock *sk, 413 + struct sock *other) 414 + { 415 + unix_dgram_peer_wake_disconnect(sk, other); 416 + wake_up_interruptible_poll(sk_sleep(sk), 417 + POLLOUT | 418 + POLLWRNORM | 419 + POLLWRBAND); 420 + } 421 + 422 + /* preconditions: 423 + * - unix_peer(sk) == other 424 + * - association is stable 425 + */ 426 + static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other) 427 + { 428 + int connected; 429 + 430 + connected = unix_dgram_peer_wake_connect(sk, other); 431 + 432 + if (unix_recvq_full(other)) 433 + return 1; 434 + 435 + if (connected) 436 + unix_dgram_peer_wake_disconnect(sk, other); 437 + 438 + return 0; 439 + } 440 + 329 441 static int unix_writable(const struct sock *sk) 330 442 { 331 443 return sk->sk_state != TCP_LISTEN && ··· 543 431 skpair->sk_state_change(skpair); 544 432 sk_wake_async(skpair, SOCK_WAKE_WAITD, POLL_HUP); 545 433 } 434 + 435 + unix_dgram_peer_wake_disconnect(sk, skpair); 546 436 sock_put(skpair); /* It may now die */ 547 437 unix_peer(sk) = NULL; 548 438 } ··· 780 666 INIT_LIST_HEAD(&u->link); 781 667 mutex_init(&u->readlock); /* single task reading lock */ 782 668 init_waitqueue_head(&u->peer_wait); 669 + init_waitqueue_func_entry(&u->peer_wake, unix_dgram_peer_wake_relay); 783 670 unix_insert_socket(unix_sockets_unbound(sk), sk); 784 671 out: 785 672 if (sk == NULL) ··· 1148 1033 if (unix_peer(sk)) { 1149 1034 struct sock *old_peer = unix_peer(sk); 1150 1035 unix_peer(sk) = other; 1036 + unix_dgram_peer_wake_disconnect_wakeup(sk, old_peer); 1037 + 1151 1038 unix_state_double_unlock(sk, other); 1152 1039 1153 1040 if (other != old_peer) ··· 1551 1434 return err; 1552 1435 } 1553 1436 1437 + static bool unix_passcred_enabled(const struct socket *sock, 1438 + const struct sock *other) 1439 + { 1440 + return test_bit(SOCK_PASSCRED, &sock->flags) || 1441 + !other->sk_socket || 1442 + test_bit(SOCK_PASSCRED, &other->sk_socket->flags); 1443 + } 1444 + 1554 1445 /* 1555 1446 * Some apps rely on write() giving SCM_CREDENTIALS 1556 1447 * We include credentials if source or destination socket ··· 1569 1444 { 1570 1445 if (UNIXCB(skb).pid) 1571 1446 return; 1572 - if (test_bit(SOCK_PASSCRED, &sock->flags) || 1573 - !other->sk_socket || 1574 - test_bit(SOCK_PASSCRED, &other->sk_socket->flags)) { 1447 + if (unix_passcred_enabled(sock, other)) { 1575 1448 UNIXCB(skb).pid = get_pid(task_tgid(current)); 1576 1449 current_uid_gid(&UNIXCB(skb).uid, &UNIXCB(skb).gid); 1577 1450 } 1451 + } 1452 + 1453 + static int maybe_init_creds(struct scm_cookie *scm, 1454 + struct socket *socket, 1455 + const struct sock *other) 1456 + { 1457 + int err; 1458 + struct msghdr msg = { .msg_controllen = 0 }; 1459 + 1460 + err = scm_send(socket, &msg, scm, false); 1461 + if (err) 1462 + return err; 1463 + 1464 + if (unix_passcred_enabled(socket, other)) { 1465 + scm->pid = get_pid(task_tgid(current)); 1466 + current_uid_gid(&scm->creds.uid, &scm->creds.gid); 1467 + } 1468 + return err; 1469 + } 1470 + 1471 + static bool unix_skb_scm_eq(struct sk_buff *skb, 1472 + struct scm_cookie *scm) 1473 + { 1474 + const struct unix_skb_parms *u = &UNIXCB(skb); 1475 + 1476 + return u->pid == scm->pid && 1477 + uid_eq(u->uid, scm->creds.uid) && 1478 + gid_eq(u->gid, scm->creds.gid) && 1479 + unix_secdata_eq(scm, skb); 1578 1480 } 1579 1481 1580 1482 /* ··· 1624 1472 struct scm_cookie scm; 1625 1473 int max_level; 1626 1474 int data_len = 0; 1475 + int sk_locked; 1627 1476 1628 1477 wait_for_unix_gc(); 1629 1478 err = scm_send(sock, msg, &scm, false); ··· 1703 1550 goto out_free; 1704 1551 } 1705 1552 1553 + sk_locked = 0; 1706 1554 unix_state_lock(other); 1555 + restart_locked: 1707 1556 err = -EPERM; 1708 1557 if (!unix_may_send(sk, other)) 1709 1558 goto out_unlock; 1710 1559 1711 - if (sock_flag(other, SOCK_DEAD)) { 1560 + if (unlikely(sock_flag(other, SOCK_DEAD))) { 1712 1561 /* 1713 1562 * Check with 1003.1g - what should 1714 1563 * datagram error ··· 1718 1563 unix_state_unlock(other); 1719 1564 sock_put(other); 1720 1565 1566 + if (!sk_locked) 1567 + unix_state_lock(sk); 1568 + 1721 1569 err = 0; 1722 - unix_state_lock(sk); 1723 1570 if (unix_peer(sk) == other) { 1724 1571 unix_peer(sk) = NULL; 1572 + unix_dgram_peer_wake_disconnect_wakeup(sk, other); 1573 + 1725 1574 unix_state_unlock(sk); 1726 1575 1727 1576 unix_dgram_disconnected(sk, other); ··· 1751 1592 goto out_unlock; 1752 1593 } 1753 1594 1754 - if (unix_peer(other) != sk && unix_recvq_full(other)) { 1755 - if (!timeo) { 1595 + if (unlikely(unix_peer(other) != sk && unix_recvq_full(other))) { 1596 + if (timeo) { 1597 + timeo = unix_wait_for_peer(other, timeo); 1598 + 1599 + err = sock_intr_errno(timeo); 1600 + if (signal_pending(current)) 1601 + goto out_free; 1602 + 1603 + goto restart; 1604 + } 1605 + 1606 + if (!sk_locked) { 1607 + unix_state_unlock(other); 1608 + unix_state_double_lock(sk, other); 1609 + } 1610 + 1611 + if (unix_peer(sk) != other || 1612 + unix_dgram_peer_wake_me(sk, other)) { 1756 1613 err = -EAGAIN; 1614 + sk_locked = 1; 1757 1615 goto out_unlock; 1758 1616 } 1759 1617 1760 - timeo = unix_wait_for_peer(other, timeo); 1761 - 1762 - err = sock_intr_errno(timeo); 1763 - if (signal_pending(current)) 1764 - goto out_free; 1765 - 1766 - goto restart; 1618 + if (!sk_locked) { 1619 + sk_locked = 1; 1620 + goto restart_locked; 1621 + } 1767 1622 } 1623 + 1624 + if (unlikely(sk_locked)) 1625 + unix_state_unlock(sk); 1768 1626 1769 1627 if (sock_flag(other, SOCK_RCVTSTAMP)) 1770 1628 __net_timestamp(skb); ··· 1796 1620 return len; 1797 1621 1798 1622 out_unlock: 1623 + if (sk_locked) 1624 + unix_state_unlock(sk); 1799 1625 unix_state_unlock(other); 1800 1626 out_free: 1801 1627 kfree_skb(skb); ··· 1919 1741 static ssize_t unix_stream_sendpage(struct socket *socket, struct page *page, 1920 1742 int offset, size_t size, int flags) 1921 1743 { 1922 - int err = 0; 1923 - bool send_sigpipe = true; 1744 + int err; 1745 + bool send_sigpipe = false; 1746 + bool init_scm = true; 1747 + struct scm_cookie scm; 1924 1748 struct sock *other, *sk = socket->sk; 1925 1749 struct sk_buff *skb, *newskb = NULL, *tail = NULL; 1926 1750 ··· 1940 1760 newskb = sock_alloc_send_pskb(sk, 0, 0, flags & MSG_DONTWAIT, 1941 1761 &err, 0); 1942 1762 if (!newskb) 1943 - return err; 1763 + goto err; 1944 1764 } 1945 1765 1946 1766 /* we must acquire readlock as we modify already present ··· 1949 1769 err = mutex_lock_interruptible(&unix_sk(other)->readlock); 1950 1770 if (err) { 1951 1771 err = flags & MSG_DONTWAIT ? -EAGAIN : -ERESTARTSYS; 1952 - send_sigpipe = false; 1953 1772 goto err; 1954 1773 } 1955 1774 1956 1775 if (sk->sk_shutdown & SEND_SHUTDOWN) { 1957 1776 err = -EPIPE; 1777 + send_sigpipe = true; 1958 1778 goto err_unlock; 1959 1779 } 1960 1780 ··· 1963 1783 if (sock_flag(other, SOCK_DEAD) || 1964 1784 other->sk_shutdown & RCV_SHUTDOWN) { 1965 1785 err = -EPIPE; 1786 + send_sigpipe = true; 1966 1787 goto err_state_unlock; 1788 + } 1789 + 1790 + if (init_scm) { 1791 + err = maybe_init_creds(&scm, socket, other); 1792 + if (err) 1793 + goto err_state_unlock; 1794 + init_scm = false; 1967 1795 } 1968 1796 1969 1797 skb = skb_peek_tail(&other->sk_receive_queue); 1970 1798 if (tail && tail == skb) { 1971 1799 skb = newskb; 1972 - } else if (!skb) { 1973 - if (newskb) 1800 + } else if (!skb || !unix_skb_scm_eq(skb, &scm)) { 1801 + if (newskb) { 1974 1802 skb = newskb; 1975 - else 1803 + } else { 1804 + tail = skb; 1976 1805 goto alloc_skb; 1806 + } 1977 1807 } else if (newskb) { 1978 1808 /* this is fast path, we don't necessarily need to 1979 1809 * call to kfree_skb even though with newskb == NULL ··· 2004 1814 atomic_add(size, &sk->sk_wmem_alloc); 2005 1815 2006 1816 if (newskb) { 1817 + err = unix_scm_to_skb(&scm, skb, false); 1818 + if (err) 1819 + goto err_state_unlock; 2007 1820 spin_lock(&other->sk_receive_queue.lock); 2008 1821 __skb_queue_tail(&other->sk_receive_queue, newskb); 2009 1822 spin_unlock(&other->sk_receive_queue.lock); ··· 2016 1823 mutex_unlock(&unix_sk(other)->readlock); 2017 1824 2018 1825 other->sk_data_ready(other); 2019 - 1826 + scm_destroy(&scm); 2020 1827 return size; 2021 1828 2022 1829 err_state_unlock: ··· 2027 1834 kfree_skb(newskb); 2028 1835 if (send_sigpipe && !(flags & MSG_NOSIGNAL)) 2029 1836 send_sig(SIGPIPE, current, 0); 1837 + if (!init_scm) 1838 + scm_destroy(&scm); 2030 1839 return err; 2031 1840 } 2032 1841 ··· 2191 1996 !timeo) 2192 1997 break; 2193 1998 2194 - set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 1999 + sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); 2195 2000 unix_state_unlock(sk); 2196 2001 timeo = freezable_schedule_timeout(timeo); 2197 2002 unix_state_lock(sk); ··· 2199 2004 if (sock_flag(sk, SOCK_DEAD)) 2200 2005 break; 2201 2006 2202 - clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); 2007 + sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); 2203 2008 } 2204 2009 2205 2010 finish_wait(sk_sleep(sk), &wait); ··· 2332 2137 2333 2138 if (check_creds) { 2334 2139 /* Never glue messages from different writers */ 2335 - if ((UNIXCB(skb).pid != scm.pid) || 2336 - !uid_eq(UNIXCB(skb).uid, scm.creds.uid) || 2337 - !gid_eq(UNIXCB(skb).gid, scm.creds.gid) || 2338 - !unix_secdata_eq(&scm, skb)) 2140 + if (!unix_skb_scm_eq(skb, &scm)) 2339 2141 break; 2340 2142 } else if (test_bit(SOCK_PASSCRED, &sock->flags)) { 2341 2143 /* Copy credentials */ ··· 2668 2476 return mask; 2669 2477 2670 2478 writable = unix_writable(sk); 2671 - other = unix_peer_get(sk); 2672 - if (other) { 2673 - if (unix_peer(other) != sk) { 2674 - sock_poll_wait(file, &unix_sk(other)->peer_wait, wait); 2675 - if (unix_recvq_full(other)) 2676 - writable = 0; 2677 - } 2678 - sock_put(other); 2479 + if (writable) { 2480 + unix_state_lock(sk); 2481 + 2482 + other = unix_peer(sk); 2483 + if (other && unix_peer(other) != sk && 2484 + unix_recvq_full(other) && 2485 + unix_dgram_peer_wake_me(sk, other)) 2486 + writable = 0; 2487 + 2488 + unix_state_unlock(sk); 2679 2489 } 2680 2490 2681 2491 if (writable) 2682 2492 mask |= POLLOUT | POLLWRNORM | POLLWRBAND; 2683 2493 else 2684 - set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 2494 + sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); 2685 2495 2686 2496 return mask; 2687 2497 }