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/netdev/net

Pull networking fixes from David Miller:

1) BPF sample build fixes from Björn Töpel

2) Fix powerpc bpf tail call implementation, from Eric Dumazet.

3) DCCP leaks jiffies on the wire, fix also from Eric Dumazet.

4) Fix crash in ebtables when using dnat target, from Florian Westphal.

5) Fix port disable handling whne removing bcm_sf2 driver, from Florian
Fainelli.

6) Fix kTLS sk_msg trim on fallback to copy mode, from Jakub Kicinski.

7) Various KCSAN fixes all over the networking, from Eric Dumazet.

8) Memory leaks in mlx5 driver, from Alex Vesker.

9) SMC interface refcounting fix, from Ursula Braun.

10) TSO descriptor handling fixes in stmmac driver, from Jose Abreu.

11) Add a TX lock to synchonize the kTLS TX path properly with crypto
operations. From Jakub Kicinski.

12) Sock refcount during shutdown fix in vsock/virtio code, from Stefano
Garzarella.

13) Infinite loop in Intel ice driver, from Colin Ian King.

* git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (108 commits)
ixgbe: need_wakeup flag might not be set for Tx
i40e: need_wakeup flag might not be set for Tx
igb/igc: use ktime accessors for skb->tstamp
i40e: Fix for ethtool -m issue on X722 NIC
iavf: initialize ITRN registers with correct values
ice: fix potential infinite loop because loop counter being too small
qede: fix NULL pointer deref in __qede_remove()
net: fix data-race in neigh_event_send()
vsock/virtio: fix sock refcnt holding during the shutdown
net: ethernet: octeon_mgmt: Account for second possible VLAN header
mac80211: fix station inactive_time shortly after boot
net/fq_impl: Switch to kvmalloc() for memory allocation
mac80211: fix ieee80211_txq_setup_flows() failure path
ipv4: Fix table id reference in fib_sync_down_addr
ipv6: fixes rt6_probe() and fib6_nh->last_probe init
net: hns: Fix the stray netpoll locks causing deadlock in NAPI path
net: usb: qmi_wwan: add support for DW5821e with eSIM support
CDC-NCM: handle incomplete transfer of MTU
nfc: netlink: fix double device reference drop
NFC: st21nfca: fix double free
...

+1096 -486
+4
Documentation/networking/tls-offload.rst
··· 436 436 encryption. 437 437 * ``tx_tls_ooo`` - number of TX packets which were part of a TLS stream 438 438 but did not arrive in the expected order. 439 + * ``tx_tls_skip_no_sync_data`` - number of TX packets which were part of 440 + a TLS stream and arrived out-of-order, but skipped the HW offload routine 441 + and went to the regular transmit flow as they were retransmissions of the 442 + connection handshake. 439 443 * ``tx_tls_drop_no_sync_data`` - number of TX packets which were part of 440 444 a TLS stream dropped, because they arrived out of order and associated 441 445 record could not be found.
+1
MAINTAINERS
··· 3053 3053 R: Martin KaFai Lau <kafai@fb.com> 3054 3054 R: Song Liu <songliubraving@fb.com> 3055 3055 R: Yonghong Song <yhs@fb.com> 3056 + R: Andrii Nakryiko <andriin@fb.com> 3056 3057 L: netdev@vger.kernel.org 3057 3058 L: bpf@vger.kernel.org 3058 3059 T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git
+13
arch/powerpc/net/bpf_jit_comp64.c
··· 1142 1142 } 1143 1143 1144 1144 /* 1145 + * If we have seen a tail call, we need a second pass. 1146 + * This is because bpf_jit_emit_common_epilogue() is called 1147 + * from bpf_jit_emit_tail_call() with a not yet stable ctx->seen. 1148 + */ 1149 + if (cgctx.seen & SEEN_TAILCALL) { 1150 + cgctx.idx = 0; 1151 + if (bpf_jit_build_body(fp, 0, &cgctx, addrs, false)) { 1152 + fp = org_fp; 1153 + goto out_addrs; 1154 + } 1155 + } 1156 + 1157 + /* 1145 1158 * Pretend to build prologue, given the features we've seen. This will 1146 1159 * update ctgtx.idx as it pretends to output instructions, then we can 1147 1160 * calculate total size from idx.
+22 -22
drivers/net/bonding/bond_main.c
··· 2083 2083 ignore_updelay = !rcu_dereference(bond->curr_active_slave); 2084 2084 2085 2085 bond_for_each_slave_rcu(bond, slave, iter) { 2086 - slave->new_link = BOND_LINK_NOCHANGE; 2087 - slave->link_new_state = slave->link; 2086 + bond_propose_link_state(slave, BOND_LINK_NOCHANGE); 2088 2087 2089 2088 link_state = bond_check_dev_link(bond, slave->dev, 0); 2090 2089 ··· 2117 2118 } 2118 2119 2119 2120 if (slave->delay <= 0) { 2120 - slave->new_link = BOND_LINK_DOWN; 2121 + bond_propose_link_state(slave, BOND_LINK_DOWN); 2121 2122 commit++; 2122 2123 continue; 2123 2124 } ··· 2154 2155 slave->delay = 0; 2155 2156 2156 2157 if (slave->delay <= 0) { 2157 - slave->new_link = BOND_LINK_UP; 2158 + bond_propose_link_state(slave, BOND_LINK_UP); 2158 2159 commit++; 2159 2160 ignore_updelay = false; 2160 2161 continue; ··· 2192 2193 struct slave *slave, *primary; 2193 2194 2194 2195 bond_for_each_slave(bond, slave, iter) { 2195 - switch (slave->new_link) { 2196 + switch (slave->link_new_state) { 2196 2197 case BOND_LINK_NOCHANGE: 2197 2198 /* For 802.3ad mode, check current slave speed and 2198 2199 * duplex again in case its port was disabled after ··· 2264 2265 2265 2266 default: 2266 2267 slave_err(bond->dev, slave->dev, "invalid new link %d on slave\n", 2267 - slave->new_link); 2268 - slave->new_link = BOND_LINK_NOCHANGE; 2268 + slave->link_new_state); 2269 + bond_propose_link_state(slave, BOND_LINK_NOCHANGE); 2269 2270 2270 2271 continue; 2271 2272 } ··· 2673 2674 bond_for_each_slave_rcu(bond, slave, iter) { 2674 2675 unsigned long trans_start = dev_trans_start(slave->dev); 2675 2676 2676 - slave->new_link = BOND_LINK_NOCHANGE; 2677 + bond_propose_link_state(slave, BOND_LINK_NOCHANGE); 2677 2678 2678 2679 if (slave->link != BOND_LINK_UP) { 2679 2680 if (bond_time_in_interval(bond, trans_start, 1) && 2680 2681 bond_time_in_interval(bond, slave->last_rx, 1)) { 2681 2682 2682 - slave->new_link = BOND_LINK_UP; 2683 + bond_propose_link_state(slave, BOND_LINK_UP); 2683 2684 slave_state_changed = 1; 2684 2685 2685 2686 /* primary_slave has no meaning in round-robin ··· 2704 2705 if (!bond_time_in_interval(bond, trans_start, 2) || 2705 2706 !bond_time_in_interval(bond, slave->last_rx, 2)) { 2706 2707 2707 - slave->new_link = BOND_LINK_DOWN; 2708 + bond_propose_link_state(slave, BOND_LINK_DOWN); 2708 2709 slave_state_changed = 1; 2709 2710 2710 2711 if (slave->link_failure_count < UINT_MAX) ··· 2735 2736 goto re_arm; 2736 2737 2737 2738 bond_for_each_slave(bond, slave, iter) { 2738 - if (slave->new_link != BOND_LINK_NOCHANGE) 2739 - slave->link = slave->new_link; 2739 + if (slave->link_new_state != BOND_LINK_NOCHANGE) 2740 + slave->link = slave->link_new_state; 2740 2741 } 2741 2742 2742 2743 if (slave_state_changed) { ··· 2759 2760 } 2760 2761 2761 2762 /* Called to inspect slaves for active-backup mode ARP monitor link state 2762 - * changes. Sets new_link in slaves to specify what action should take 2763 - * place for the slave. Returns 0 if no changes are found, >0 if changes 2764 - * to link states must be committed. 2763 + * changes. Sets proposed link state in slaves to specify what action 2764 + * should take place for the slave. Returns 0 if no changes are found, >0 2765 + * if changes to link states must be committed. 2765 2766 * 2766 2767 * Called with rcu_read_lock held. 2767 2768 */ ··· 2773 2774 int commit = 0; 2774 2775 2775 2776 bond_for_each_slave_rcu(bond, slave, iter) { 2776 - slave->new_link = BOND_LINK_NOCHANGE; 2777 + bond_propose_link_state(slave, BOND_LINK_NOCHANGE); 2777 2778 last_rx = slave_last_rx(bond, slave); 2778 2779 2779 2780 if (slave->link != BOND_LINK_UP) { 2780 2781 if (bond_time_in_interval(bond, last_rx, 1)) { 2781 - slave->new_link = BOND_LINK_UP; 2782 + bond_propose_link_state(slave, BOND_LINK_UP); 2782 2783 commit++; 2783 2784 } 2784 2785 continue; ··· 2806 2807 if (!bond_is_active_slave(slave) && 2807 2808 !rcu_access_pointer(bond->current_arp_slave) && 2808 2809 !bond_time_in_interval(bond, last_rx, 3)) { 2809 - slave->new_link = BOND_LINK_DOWN; 2810 + bond_propose_link_state(slave, BOND_LINK_DOWN); 2810 2811 commit++; 2811 2812 } 2812 2813 ··· 2819 2820 if (bond_is_active_slave(slave) && 2820 2821 (!bond_time_in_interval(bond, trans_start, 2) || 2821 2822 !bond_time_in_interval(bond, last_rx, 2))) { 2822 - slave->new_link = BOND_LINK_DOWN; 2823 + bond_propose_link_state(slave, BOND_LINK_DOWN); 2823 2824 commit++; 2824 2825 } 2825 2826 } ··· 2839 2840 struct slave *slave; 2840 2841 2841 2842 bond_for_each_slave(bond, slave, iter) { 2842 - switch (slave->new_link) { 2843 + switch (slave->link_new_state) { 2843 2844 case BOND_LINK_NOCHANGE: 2844 2845 continue; 2845 2846 ··· 2889 2890 continue; 2890 2891 2891 2892 default: 2892 - slave_err(bond->dev, slave->dev, "impossible: new_link %d on slave\n", 2893 - slave->new_link); 2893 + slave_err(bond->dev, slave->dev, 2894 + "impossible: link_new_state %d on slave\n", 2895 + slave->link_new_state); 2894 2896 continue; 2895 2897 } 2896 2898
+64 -7
drivers/net/can/c_can/c_can.c
··· 52 52 #define CONTROL_EX_PDR BIT(8) 53 53 54 54 /* control register */ 55 + #define CONTROL_SWR BIT(15) 55 56 #define CONTROL_TEST BIT(7) 56 57 #define CONTROL_CCE BIT(6) 57 58 #define CONTROL_DISABLE_AR BIT(5) ··· 97 96 #define BTR_TSEG1_MASK (0xf << BTR_TSEG1_SHIFT) 98 97 #define BTR_TSEG2_SHIFT 12 99 98 #define BTR_TSEG2_MASK (0x7 << BTR_TSEG2_SHIFT) 99 + 100 + /* interrupt register */ 101 + #define INT_STS_PENDING 0x8000 100 102 101 103 /* brp extension register */ 102 104 #define BRP_EXT_BRPE_MASK 0x0f ··· 573 569 IF_MCONT_RCV_EOB); 574 570 } 575 571 572 + static int c_can_software_reset(struct net_device *dev) 573 + { 574 + struct c_can_priv *priv = netdev_priv(dev); 575 + int retry = 0; 576 + 577 + if (priv->type != BOSCH_D_CAN) 578 + return 0; 579 + 580 + priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_SWR | CONTROL_INIT); 581 + while (priv->read_reg(priv, C_CAN_CTRL_REG) & CONTROL_SWR) { 582 + msleep(20); 583 + if (retry++ > 100) { 584 + netdev_err(dev, "CCTRL: software reset failed\n"); 585 + return -EIO; 586 + } 587 + } 588 + 589 + return 0; 590 + } 591 + 576 592 /* 577 593 * Configure C_CAN chip: 578 594 * - enable/disable auto-retransmission ··· 602 578 static int c_can_chip_config(struct net_device *dev) 603 579 { 604 580 struct c_can_priv *priv = netdev_priv(dev); 581 + int err; 582 + 583 + err = c_can_software_reset(dev); 584 + if (err) 585 + return err; 605 586 606 587 /* enable automatic retransmission */ 607 588 priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_ENABLE_AR); ··· 915 886 struct can_berr_counter bec; 916 887 917 888 switch (error_type) { 889 + case C_CAN_NO_ERROR: 890 + priv->can.state = CAN_STATE_ERROR_ACTIVE; 891 + break; 918 892 case C_CAN_ERROR_WARNING: 919 893 /* error warning state */ 920 894 priv->can.can_stats.error_warning++; ··· 948 916 ERR_CNT_RP_SHIFT; 949 917 950 918 switch (error_type) { 919 + case C_CAN_NO_ERROR: 920 + /* error warning state */ 921 + cf->can_id |= CAN_ERR_CRTL; 922 + cf->data[1] = CAN_ERR_CRTL_ACTIVE; 923 + cf->data[6] = bec.txerr; 924 + cf->data[7] = bec.rxerr; 925 + break; 951 926 case C_CAN_ERROR_WARNING: 952 927 /* error warning state */ 953 928 cf->can_id |= CAN_ERR_CRTL; ··· 1068 1029 u16 curr, last = priv->last_status; 1069 1030 int work_done = 0; 1070 1031 1071 - priv->last_status = curr = priv->read_reg(priv, C_CAN_STS_REG); 1072 - /* Ack status on C_CAN. D_CAN is self clearing */ 1073 - if (priv->type != BOSCH_D_CAN) 1074 - priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED); 1032 + /* Only read the status register if a status interrupt was pending */ 1033 + if (atomic_xchg(&priv->sie_pending, 0)) { 1034 + priv->last_status = curr = priv->read_reg(priv, C_CAN_STS_REG); 1035 + /* Ack status on C_CAN. D_CAN is self clearing */ 1036 + if (priv->type != BOSCH_D_CAN) 1037 + priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED); 1038 + } else { 1039 + /* no change detected ... */ 1040 + curr = last; 1041 + } 1075 1042 1076 1043 /* handle state changes */ 1077 1044 if ((curr & STATUS_EWARN) && (!(last & STATUS_EWARN))) { ··· 1099 1054 /* handle bus recovery events */ 1100 1055 if ((!(curr & STATUS_BOFF)) && (last & STATUS_BOFF)) { 1101 1056 netdev_dbg(dev, "left bus off state\n"); 1102 - priv->can.state = CAN_STATE_ERROR_ACTIVE; 1057 + work_done += c_can_handle_state_change(dev, C_CAN_ERROR_PASSIVE); 1103 1058 } 1059 + 1104 1060 if ((!(curr & STATUS_EPASS)) && (last & STATUS_EPASS)) { 1105 1061 netdev_dbg(dev, "left error passive state\n"); 1106 - priv->can.state = CAN_STATE_ERROR_ACTIVE; 1062 + work_done += c_can_handle_state_change(dev, C_CAN_ERROR_WARNING); 1063 + } 1064 + 1065 + if ((!(curr & STATUS_EWARN)) && (last & STATUS_EWARN)) { 1066 + netdev_dbg(dev, "left error warning state\n"); 1067 + work_done += c_can_handle_state_change(dev, C_CAN_NO_ERROR); 1107 1068 } 1108 1069 1109 1070 /* handle lec errors on the bus */ ··· 1134 1083 { 1135 1084 struct net_device *dev = (struct net_device *)dev_id; 1136 1085 struct c_can_priv *priv = netdev_priv(dev); 1086 + int reg_int; 1137 1087 1138 - if (!priv->read_reg(priv, C_CAN_INT_REG)) 1088 + reg_int = priv->read_reg(priv, C_CAN_INT_REG); 1089 + if (!reg_int) 1139 1090 return IRQ_NONE; 1091 + 1092 + /* save for later use */ 1093 + if (reg_int & INT_STS_PENDING) 1094 + atomic_set(&priv->sie_pending, 1); 1140 1095 1141 1096 /* disable all interrupts and schedule the NAPI */ 1142 1097 c_can_irq_control(priv, false);
+1
drivers/net/can/c_can/c_can.h
··· 198 198 struct net_device *dev; 199 199 struct device *device; 200 200 atomic_t tx_active; 201 + atomic_t sie_pending; 201 202 unsigned long tx_dir; 202 203 int last_status; 203 204 u16 (*read_reg) (const struct c_can_priv *priv, enum reg index);
+1
drivers/net/can/dev.c
··· 848 848 return; 849 849 850 850 ret = of_property_read_u32(dn, "max-bitrate", &priv->bitrate_max); 851 + of_node_put(dn); 851 852 if ((ret && ret != -EINVAL) || (!ret && !priv->bitrate_max)) 852 853 netdev_warn(dev, "Invalid value for transceiver max bitrate. Ignoring bitrate limit.\n"); 853 854 }
+9 -2
drivers/net/can/flexcan.c
··· 677 677 struct can_frame *cf; 678 678 bool rx_errors = false, tx_errors = false; 679 679 u32 timestamp; 680 + int err; 680 681 681 682 timestamp = priv->read(&regs->timer) << 16; 682 683 ··· 726 725 if (tx_errors) 727 726 dev->stats.tx_errors++; 728 727 729 - can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); 728 + err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); 729 + if (err) 730 + dev->stats.rx_fifo_errors++; 730 731 } 731 732 732 733 static void flexcan_irq_state(struct net_device *dev, u32 reg_esr) ··· 741 738 int flt; 742 739 struct can_berr_counter bec; 743 740 u32 timestamp; 741 + int err; 744 742 745 743 timestamp = priv->read(&regs->timer) << 16; 746 744 ··· 773 769 if (unlikely(new_state == CAN_STATE_BUS_OFF)) 774 770 can_bus_off(dev); 775 771 776 - can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); 772 + err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); 773 + if (err) 774 + dev->stats.rx_fifo_errors++; 777 775 } 778 776 779 777 static inline struct flexcan_priv *rx_offload_to_priv(struct can_rx_offload *offload) ··· 1194 1188 reg_mecr = priv->read(&regs->mecr); 1195 1189 reg_mecr &= ~FLEXCAN_MECR_ECRWRDIS; 1196 1190 priv->write(reg_mecr, &regs->mecr); 1191 + reg_mecr |= FLEXCAN_MECR_ECCDIS; 1197 1192 reg_mecr &= ~(FLEXCAN_MECR_NCEFAFRZ | FLEXCAN_MECR_HANCEI_MSK | 1198 1193 FLEXCAN_MECR_FANCEI_MSK); 1199 1194 priv->write(reg_mecr, &regs->mecr);
+85 -17
drivers/net/can/rx-offload.c
··· 107 107 return cb_b->timestamp - cb_a->timestamp; 108 108 } 109 109 110 - static struct sk_buff *can_rx_offload_offload_one(struct can_rx_offload *offload, unsigned int n) 110 + /** 111 + * can_rx_offload_offload_one() - Read one CAN frame from HW 112 + * @offload: pointer to rx_offload context 113 + * @n: number of mailbox to read 114 + * 115 + * The task of this function is to read a CAN frame from mailbox @n 116 + * from the device and return the mailbox's content as a struct 117 + * sk_buff. 118 + * 119 + * If the struct can_rx_offload::skb_queue exceeds the maximal queue 120 + * length (struct can_rx_offload::skb_queue_len_max) or no skb can be 121 + * allocated, the mailbox contents is discarded by reading it into an 122 + * overflow buffer. This way the mailbox is marked as free by the 123 + * driver. 124 + * 125 + * Return: A pointer to skb containing the CAN frame on success. 126 + * 127 + * NULL if the mailbox @n is empty. 128 + * 129 + * ERR_PTR() in case of an error 130 + */ 131 + static struct sk_buff * 132 + can_rx_offload_offload_one(struct can_rx_offload *offload, unsigned int n) 111 133 { 112 - struct sk_buff *skb = NULL; 134 + struct sk_buff *skb = NULL, *skb_error = NULL; 113 135 struct can_rx_offload_cb *cb; 114 136 struct can_frame *cf; 115 137 int ret; 116 138 117 - /* If queue is full or skb not available, read to discard mailbox */ 118 - if (likely(skb_queue_len(&offload->skb_queue) <= 119 - offload->skb_queue_len_max)) 139 + if (likely(skb_queue_len(&offload->skb_queue) < 140 + offload->skb_queue_len_max)) { 120 141 skb = alloc_can_skb(offload->dev, &cf); 142 + if (unlikely(!skb)) 143 + skb_error = ERR_PTR(-ENOMEM); /* skb alloc failed */ 144 + } else { 145 + skb_error = ERR_PTR(-ENOBUFS); /* skb_queue is full */ 146 + } 121 147 122 - if (!skb) { 148 + /* If queue is full or skb not available, drop by reading into 149 + * overflow buffer. 150 + */ 151 + if (unlikely(skb_error)) { 123 152 struct can_frame cf_overflow; 124 153 u32 timestamp; 125 154 126 155 ret = offload->mailbox_read(offload, &cf_overflow, 127 156 &timestamp, n); 128 - if (ret) 129 - offload->dev->stats.rx_dropped++; 130 157 131 - return NULL; 158 + /* Mailbox was empty. */ 159 + if (unlikely(!ret)) 160 + return NULL; 161 + 162 + /* Mailbox has been read and we're dropping it or 163 + * there was a problem reading the mailbox. 164 + * 165 + * Increment error counters in any case. 166 + */ 167 + offload->dev->stats.rx_dropped++; 168 + offload->dev->stats.rx_fifo_errors++; 169 + 170 + /* There was a problem reading the mailbox, propagate 171 + * error value. 172 + */ 173 + if (unlikely(ret < 0)) 174 + return ERR_PTR(ret); 175 + 176 + return skb_error; 132 177 } 133 178 134 179 cb = can_rx_offload_get_cb(skb); 135 180 ret = offload->mailbox_read(offload, cf, &cb->timestamp, n); 136 - if (!ret) { 181 + 182 + /* Mailbox was empty. */ 183 + if (unlikely(!ret)) { 137 184 kfree_skb(skb); 138 185 return NULL; 139 186 } 140 187 188 + /* There was a problem reading the mailbox, propagate error value. */ 189 + if (unlikely(ret < 0)) { 190 + kfree_skb(skb); 191 + 192 + offload->dev->stats.rx_dropped++; 193 + offload->dev->stats.rx_fifo_errors++; 194 + 195 + return ERR_PTR(ret); 196 + } 197 + 198 + /* Mailbox was read. */ 141 199 return skb; 142 200 } 143 201 ··· 215 157 continue; 216 158 217 159 skb = can_rx_offload_offload_one(offload, i); 218 - if (!skb) 219 - break; 160 + if (IS_ERR_OR_NULL(skb)) 161 + continue; 220 162 221 163 __skb_queue_add_sort(&skb_queue, skb, can_rx_offload_compare); 222 164 } ··· 246 188 struct sk_buff *skb; 247 189 int received = 0; 248 190 249 - while ((skb = can_rx_offload_offload_one(offload, 0))) { 191 + while (1) { 192 + skb = can_rx_offload_offload_one(offload, 0); 193 + if (IS_ERR(skb)) 194 + continue; 195 + if (!skb) 196 + break; 197 + 250 198 skb_queue_tail(&offload->skb_queue, skb); 251 199 received++; 252 200 } ··· 271 207 unsigned long flags; 272 208 273 209 if (skb_queue_len(&offload->skb_queue) > 274 - offload->skb_queue_len_max) 275 - return -ENOMEM; 210 + offload->skb_queue_len_max) { 211 + kfree_skb(skb); 212 + return -ENOBUFS; 213 + } 276 214 277 215 cb = can_rx_offload_get_cb(skb); 278 216 cb->timestamp = timestamp; ··· 316 250 struct sk_buff *skb) 317 251 { 318 252 if (skb_queue_len(&offload->skb_queue) > 319 - offload->skb_queue_len_max) 320 - return -ENOMEM; 253 + offload->skb_queue_len_max) { 254 + kfree_skb(skb); 255 + return -ENOBUFS; 256 + } 321 257 322 258 skb_queue_tail(&offload->skb_queue, skb); 323 259 can_rx_offload_schedule(offload);
+1 -1
drivers/net/can/spi/mcp251x.c
··· 717 717 if (priv->after_suspend) { 718 718 mcp251x_hw_reset(spi); 719 719 mcp251x_setup(net, spi); 720 + priv->force_quit = 0; 720 721 if (priv->after_suspend & AFTER_SUSPEND_RESTART) { 721 722 mcp251x_set_normal_mode(spi); 722 723 } else if (priv->after_suspend & AFTER_SUSPEND_UP) { ··· 729 728 mcp251x_hw_sleep(spi); 730 729 } 731 730 priv->after_suspend = 0; 732 - priv->force_quit = 0; 733 731 } 734 732 735 733 if (priv->restart_tx) {
+150 -86
drivers/net/can/ti_hecc.c
··· 73 73 */ 74 74 #define HECC_MAX_RX_MBOX (HECC_MAX_MAILBOXES - HECC_MAX_TX_MBOX) 75 75 #define HECC_RX_FIRST_MBOX (HECC_MAX_MAILBOXES - 1) 76 + #define HECC_RX_LAST_MBOX (HECC_MAX_TX_MBOX) 76 77 77 78 /* TI HECC module registers */ 78 79 #define HECC_CANME 0x0 /* Mailbox enable */ ··· 83 82 #define HECC_CANTA 0x10 /* Transmission acknowledge */ 84 83 #define HECC_CANAA 0x14 /* Abort acknowledge */ 85 84 #define HECC_CANRMP 0x18 /* Receive message pending */ 86 - #define HECC_CANRML 0x1C /* Remote message lost */ 85 + #define HECC_CANRML 0x1C /* Receive message lost */ 87 86 #define HECC_CANRFP 0x20 /* Remote frame pending */ 88 87 #define HECC_CANGAM 0x24 /* SECC only:Global acceptance mask */ 89 88 #define HECC_CANMC 0x28 /* Master control */ ··· 150 149 #define HECC_BUS_ERROR (HECC_CANES_FE | HECC_CANES_BE |\ 151 150 HECC_CANES_CRCE | HECC_CANES_SE |\ 152 151 HECC_CANES_ACKE) 152 + #define HECC_CANES_FLAGS (HECC_BUS_ERROR | HECC_CANES_BO |\ 153 + HECC_CANES_EP | HECC_CANES_EW) 153 154 154 155 #define HECC_CANMCF_RTR BIT(4) /* Remote transmit request */ 155 156 ··· 385 382 hecc_set_bit(priv, HECC_CANMIM, mbx_mask); 386 383 } 387 384 388 - /* Prevent message over-write & Enable interrupts */ 389 - hecc_write(priv, HECC_CANOPC, HECC_SET_REG); 385 + /* Enable tx interrupts */ 386 + hecc_set_bit(priv, HECC_CANMIM, BIT(HECC_MAX_TX_MBOX) - 1); 387 + 388 + /* Prevent message over-write to create a rx fifo, but not for 389 + * the lowest priority mailbox, since that allows detecting 390 + * overflows instead of the hardware silently dropping the 391 + * messages. 392 + */ 393 + mbx_mask = ~BIT(HECC_RX_LAST_MBOX); 394 + hecc_write(priv, HECC_CANOPC, mbx_mask); 395 + 396 + /* Enable interrupts */ 390 397 if (priv->use_hecc1int) { 391 398 hecc_write(priv, HECC_CANMIL, HECC_SET_REG); 392 399 hecc_write(priv, HECC_CANGIM, HECC_CANGIM_DEF_MASK | ··· 412 399 static void ti_hecc_stop(struct net_device *ndev) 413 400 { 414 401 struct ti_hecc_priv *priv = netdev_priv(ndev); 402 + 403 + /* Disable the CPK; stop sending, erroring and acking */ 404 + hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_CCR); 415 405 416 406 /* Disable interrupts and disable mailboxes */ 417 407 hecc_write(priv, HECC_CANGIM, 0); ··· 524 508 hecc_set_bit(priv, HECC_CANME, mbx_mask); 525 509 spin_unlock_irqrestore(&priv->mbx_lock, flags); 526 510 527 - hecc_clear_bit(priv, HECC_CANMD, mbx_mask); 528 - hecc_set_bit(priv, HECC_CANMIM, mbx_mask); 529 511 hecc_write(priv, HECC_CANTRS, mbx_mask); 530 512 531 513 return NETDEV_TX_OK; ··· 540 526 u32 *timestamp, unsigned int mbxno) 541 527 { 542 528 struct ti_hecc_priv *priv = rx_offload_to_priv(offload); 543 - u32 data; 529 + u32 data, mbx_mask; 530 + int ret = 1; 544 531 532 + mbx_mask = BIT(mbxno); 545 533 data = hecc_read_mbx(priv, mbxno, HECC_CANMID); 546 534 if (data & HECC_CANMID_IDE) 547 535 cf->can_id = (data & CAN_EFF_MASK) | CAN_EFF_FLAG; ··· 564 548 565 549 *timestamp = hecc_read_stamp(priv, mbxno); 566 550 567 - return 1; 551 + /* Check for FIFO overrun. 552 + * 553 + * All but the last RX mailbox have activated overwrite 554 + * protection. So skip check for overrun, if we're not 555 + * handling the last RX mailbox. 556 + * 557 + * As the overwrite protection for the last RX mailbox is 558 + * disabled, the CAN core might update while we're reading 559 + * it. This means the skb might be inconsistent. 560 + * 561 + * Return an error to let rx-offload discard this CAN frame. 562 + */ 563 + if (unlikely(mbxno == HECC_RX_LAST_MBOX && 564 + hecc_read(priv, HECC_CANRML) & mbx_mask)) 565 + ret = -ENOBUFS; 566 + 567 + hecc_write(priv, HECC_CANRMP, mbx_mask); 568 + 569 + return ret; 568 570 } 569 571 570 572 static int ti_hecc_error(struct net_device *ndev, int int_status, ··· 592 558 struct can_frame *cf; 593 559 struct sk_buff *skb; 594 560 u32 timestamp; 595 - 596 - /* propagate the error condition to the can stack */ 597 - skb = alloc_can_err_skb(ndev, &cf); 598 - if (!skb) { 599 - if (printk_ratelimit()) 600 - netdev_err(priv->ndev, 601 - "%s: alloc_can_err_skb() failed\n", 602 - __func__); 603 - return -ENOMEM; 604 - } 605 - 606 - if (int_status & HECC_CANGIF_WLIF) { /* warning level int */ 607 - if ((int_status & HECC_CANGIF_BOIF) == 0) { 608 - priv->can.state = CAN_STATE_ERROR_WARNING; 609 - ++priv->can.can_stats.error_warning; 610 - cf->can_id |= CAN_ERR_CRTL; 611 - if (hecc_read(priv, HECC_CANTEC) > 96) 612 - cf->data[1] |= CAN_ERR_CRTL_TX_WARNING; 613 - if (hecc_read(priv, HECC_CANREC) > 96) 614 - cf->data[1] |= CAN_ERR_CRTL_RX_WARNING; 615 - } 616 - hecc_set_bit(priv, HECC_CANES, HECC_CANES_EW); 617 - netdev_dbg(priv->ndev, "Error Warning interrupt\n"); 618 - hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR); 619 - } 620 - 621 - if (int_status & HECC_CANGIF_EPIF) { /* error passive int */ 622 - if ((int_status & HECC_CANGIF_BOIF) == 0) { 623 - priv->can.state = CAN_STATE_ERROR_PASSIVE; 624 - ++priv->can.can_stats.error_passive; 625 - cf->can_id |= CAN_ERR_CRTL; 626 - if (hecc_read(priv, HECC_CANTEC) > 127) 627 - cf->data[1] |= CAN_ERR_CRTL_TX_PASSIVE; 628 - if (hecc_read(priv, HECC_CANREC) > 127) 629 - cf->data[1] |= CAN_ERR_CRTL_RX_PASSIVE; 630 - } 631 - hecc_set_bit(priv, HECC_CANES, HECC_CANES_EP); 632 - netdev_dbg(priv->ndev, "Error passive interrupt\n"); 633 - hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR); 634 - } 635 - 636 - /* Need to check busoff condition in error status register too to 637 - * ensure warning interrupts don't hog the system 638 - */ 639 - if ((int_status & HECC_CANGIF_BOIF) || (err_status & HECC_CANES_BO)) { 640 - priv->can.state = CAN_STATE_BUS_OFF; 641 - cf->can_id |= CAN_ERR_BUSOFF; 642 - hecc_set_bit(priv, HECC_CANES, HECC_CANES_BO); 643 - hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR); 644 - /* Disable all interrupts in bus-off to avoid int hog */ 645 - hecc_write(priv, HECC_CANGIM, 0); 646 - ++priv->can.can_stats.bus_off; 647 - can_bus_off(ndev); 648 - } 561 + int err; 649 562 650 563 if (err_status & HECC_BUS_ERROR) { 564 + /* propagate the error condition to the can stack */ 565 + skb = alloc_can_err_skb(ndev, &cf); 566 + if (!skb) { 567 + if (net_ratelimit()) 568 + netdev_err(priv->ndev, 569 + "%s: alloc_can_err_skb() failed\n", 570 + __func__); 571 + return -ENOMEM; 572 + } 573 + 651 574 ++priv->can.can_stats.bus_error; 652 575 cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT; 653 - if (err_status & HECC_CANES_FE) { 654 - hecc_set_bit(priv, HECC_CANES, HECC_CANES_FE); 576 + if (err_status & HECC_CANES_FE) 655 577 cf->data[2] |= CAN_ERR_PROT_FORM; 656 - } 657 - if (err_status & HECC_CANES_BE) { 658 - hecc_set_bit(priv, HECC_CANES, HECC_CANES_BE); 578 + if (err_status & HECC_CANES_BE) 659 579 cf->data[2] |= CAN_ERR_PROT_BIT; 660 - } 661 - if (err_status & HECC_CANES_SE) { 662 - hecc_set_bit(priv, HECC_CANES, HECC_CANES_SE); 580 + if (err_status & HECC_CANES_SE) 663 581 cf->data[2] |= CAN_ERR_PROT_STUFF; 664 - } 665 - if (err_status & HECC_CANES_CRCE) { 666 - hecc_set_bit(priv, HECC_CANES, HECC_CANES_CRCE); 582 + if (err_status & HECC_CANES_CRCE) 667 583 cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; 668 - } 669 - if (err_status & HECC_CANES_ACKE) { 670 - hecc_set_bit(priv, HECC_CANES, HECC_CANES_ACKE); 584 + if (err_status & HECC_CANES_ACKE) 671 585 cf->data[3] = CAN_ERR_PROT_LOC_ACK; 672 - } 586 + 587 + timestamp = hecc_read(priv, HECC_CANLNT); 588 + err = can_rx_offload_queue_sorted(&priv->offload, skb, 589 + timestamp); 590 + if (err) 591 + ndev->stats.rx_fifo_errors++; 592 + } 593 + 594 + hecc_write(priv, HECC_CANES, HECC_CANES_FLAGS); 595 + 596 + return 0; 597 + } 598 + 599 + static void ti_hecc_change_state(struct net_device *ndev, 600 + enum can_state rx_state, 601 + enum can_state tx_state) 602 + { 603 + struct ti_hecc_priv *priv = netdev_priv(ndev); 604 + struct can_frame *cf; 605 + struct sk_buff *skb; 606 + u32 timestamp; 607 + int err; 608 + 609 + skb = alloc_can_err_skb(priv->ndev, &cf); 610 + if (unlikely(!skb)) { 611 + priv->can.state = max(tx_state, rx_state); 612 + return; 613 + } 614 + 615 + can_change_state(priv->ndev, cf, tx_state, rx_state); 616 + 617 + if (max(tx_state, rx_state) != CAN_STATE_BUS_OFF) { 618 + cf->data[6] = hecc_read(priv, HECC_CANTEC); 619 + cf->data[7] = hecc_read(priv, HECC_CANREC); 673 620 } 674 621 675 622 timestamp = hecc_read(priv, HECC_CANLNT); 676 - can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); 677 - 678 - return 0; 623 + err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp); 624 + if (err) 625 + ndev->stats.rx_fifo_errors++; 679 626 } 680 627 681 628 static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id) ··· 666 651 struct net_device_stats *stats = &ndev->stats; 667 652 u32 mbxno, mbx_mask, int_status, err_status, stamp; 668 653 unsigned long flags, rx_pending; 654 + u32 handled = 0; 669 655 670 656 int_status = hecc_read(priv, 671 657 priv->use_hecc1int ? ··· 676 660 return IRQ_NONE; 677 661 678 662 err_status = hecc_read(priv, HECC_CANES); 679 - if (err_status & (HECC_BUS_ERROR | HECC_CANES_BO | 680 - HECC_CANES_EP | HECC_CANES_EW)) 663 + if (unlikely(err_status & HECC_CANES_FLAGS)) 681 664 ti_hecc_error(ndev, int_status, err_status); 665 + 666 + if (unlikely(int_status & HECC_CANGIM_DEF_MASK)) { 667 + enum can_state rx_state, tx_state; 668 + u32 rec = hecc_read(priv, HECC_CANREC); 669 + u32 tec = hecc_read(priv, HECC_CANTEC); 670 + 671 + if (int_status & HECC_CANGIF_WLIF) { 672 + handled |= HECC_CANGIF_WLIF; 673 + rx_state = rec >= tec ? CAN_STATE_ERROR_WARNING : 0; 674 + tx_state = rec <= tec ? CAN_STATE_ERROR_WARNING : 0; 675 + netdev_dbg(priv->ndev, "Error Warning interrupt\n"); 676 + ti_hecc_change_state(ndev, rx_state, tx_state); 677 + } 678 + 679 + if (int_status & HECC_CANGIF_EPIF) { 680 + handled |= HECC_CANGIF_EPIF; 681 + rx_state = rec >= tec ? CAN_STATE_ERROR_PASSIVE : 0; 682 + tx_state = rec <= tec ? CAN_STATE_ERROR_PASSIVE : 0; 683 + netdev_dbg(priv->ndev, "Error passive interrupt\n"); 684 + ti_hecc_change_state(ndev, rx_state, tx_state); 685 + } 686 + 687 + if (int_status & HECC_CANGIF_BOIF) { 688 + handled |= HECC_CANGIF_BOIF; 689 + rx_state = CAN_STATE_BUS_OFF; 690 + tx_state = CAN_STATE_BUS_OFF; 691 + netdev_dbg(priv->ndev, "Bus off interrupt\n"); 692 + 693 + /* Disable all interrupts */ 694 + hecc_write(priv, HECC_CANGIM, 0); 695 + can_bus_off(ndev); 696 + ti_hecc_change_state(ndev, rx_state, tx_state); 697 + } 698 + } else if (unlikely(priv->can.state != CAN_STATE_ERROR_ACTIVE)) { 699 + enum can_state new_state, tx_state, rx_state; 700 + u32 rec = hecc_read(priv, HECC_CANREC); 701 + u32 tec = hecc_read(priv, HECC_CANTEC); 702 + 703 + if (rec >= 128 || tec >= 128) 704 + new_state = CAN_STATE_ERROR_PASSIVE; 705 + else if (rec >= 96 || tec >= 96) 706 + new_state = CAN_STATE_ERROR_WARNING; 707 + else 708 + new_state = CAN_STATE_ERROR_ACTIVE; 709 + 710 + if (new_state < priv->can.state) { 711 + rx_state = rec >= tec ? new_state : 0; 712 + tx_state = rec <= tec ? new_state : 0; 713 + ti_hecc_change_state(ndev, rx_state, tx_state); 714 + } 715 + } 682 716 683 717 if (int_status & HECC_CANGIF_GMIF) { 684 718 while (priv->tx_tail - priv->tx_head > 0) { ··· 736 670 mbx_mask = BIT(mbxno); 737 671 if (!(mbx_mask & hecc_read(priv, HECC_CANTA))) 738 672 break; 739 - hecc_clear_bit(priv, HECC_CANMIM, mbx_mask); 740 673 hecc_write(priv, HECC_CANTA, mbx_mask); 741 674 spin_lock_irqsave(&priv->mbx_lock, flags); 742 675 hecc_clear_bit(priv, HECC_CANME, mbx_mask); ··· 760 695 while ((rx_pending = hecc_read(priv, HECC_CANRMP))) { 761 696 can_rx_offload_irq_offload_timestamp(&priv->offload, 762 697 rx_pending); 763 - hecc_write(priv, HECC_CANRMP, rx_pending); 764 698 } 765 699 } 766 700 767 701 /* clear all interrupt conditions - read back to avoid spurious ints */ 768 702 if (priv->use_hecc1int) { 769 - hecc_write(priv, HECC_CANGIF1, HECC_SET_REG); 703 + hecc_write(priv, HECC_CANGIF1, handled); 770 704 int_status = hecc_read(priv, HECC_CANGIF1); 771 705 } else { 772 - hecc_write(priv, HECC_CANGIF0, HECC_SET_REG); 706 + hecc_write(priv, HECC_CANGIF0, handled); 773 707 int_status = hecc_read(priv, HECC_CANGIF0); 774 708 } 775 709 ··· 941 877 942 878 priv->offload.mailbox_read = ti_hecc_mailbox_read; 943 879 priv->offload.mb_first = HECC_RX_FIRST_MBOX; 944 - priv->offload.mb_last = HECC_MAX_TX_MBOX; 880 + priv->offload.mb_last = HECC_RX_LAST_MBOX; 945 881 err = can_rx_offload_add_timestamp(ndev, &priv->offload); 946 882 if (err) { 947 883 dev_err(&pdev->dev, "can_rx_offload_add_timestamp() failed\n");
+1
drivers/net/can/usb/gs_usb.c
··· 623 623 rc); 624 624 625 625 usb_unanchor_urb(urb); 626 + usb_free_urb(urb); 626 627 break; 627 628 } 628 629
+1 -2
drivers/net/can/usb/mcba_usb.c
··· 876 876 netdev_info(priv->netdev, "device disconnected\n"); 877 877 878 878 unregister_candev(priv->netdev); 879 - free_candev(priv->netdev); 880 - 881 879 mcba_urb_unlink(priv); 880 + free_candev(priv->netdev); 882 881 } 883 882 884 883 static struct usb_driver mcba_usb_driver = {
+22 -10
drivers/net/can/usb/peak_usb/pcan_usb.c
··· 100 100 u8 *end; 101 101 u8 rec_cnt; 102 102 u8 rec_idx; 103 - u8 rec_data_idx; 103 + u8 rec_ts_idx; 104 104 struct net_device *netdev; 105 105 struct pcan_usb *pdev; 106 106 }; ··· 436 436 } 437 437 if ((n & PCAN_USB_ERROR_BUS_LIGHT) == 0) { 438 438 /* no error (back to active state) */ 439 - mc->pdev->dev.can.state = CAN_STATE_ERROR_ACTIVE; 440 - return 0; 439 + new_state = CAN_STATE_ERROR_ACTIVE; 440 + break; 441 441 } 442 442 break; 443 443 ··· 460 460 } 461 461 462 462 if ((n & PCAN_USB_ERROR_BUS_HEAVY) == 0) { 463 - /* no error (back to active state) */ 464 - mc->pdev->dev.can.state = CAN_STATE_ERROR_ACTIVE; 465 - return 0; 463 + /* no error (back to warning state) */ 464 + new_state = CAN_STATE_ERROR_WARNING; 465 + break; 466 466 } 467 467 break; 468 468 ··· 499 499 cf->data[1] |= CAN_ERR_CRTL_TX_WARNING | 500 500 CAN_ERR_CRTL_RX_WARNING; 501 501 mc->pdev->dev.can.can_stats.error_warning++; 502 + break; 503 + 504 + case CAN_STATE_ERROR_ACTIVE: 505 + cf->can_id |= CAN_ERR_CRTL; 506 + cf->data[1] = CAN_ERR_CRTL_ACTIVE; 502 507 break; 503 508 504 509 default: ··· 552 547 mc->ptr += PCAN_USB_CMD_ARGS; 553 548 554 549 if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) { 555 - int err = pcan_usb_decode_ts(mc, !mc->rec_idx); 550 + int err = pcan_usb_decode_ts(mc, !mc->rec_ts_idx); 556 551 557 552 if (err) 558 553 return err; 554 + 555 + /* Next packet in the buffer will have a timestamp on a single 556 + * byte 557 + */ 558 + mc->rec_ts_idx++; 559 559 } 560 560 561 561 switch (f) { ··· 642 632 643 633 cf->can_dlc = get_can_dlc(rec_len); 644 634 645 - /* first data packet timestamp is a word */ 646 - if (pcan_usb_decode_ts(mc, !mc->rec_data_idx)) 635 + /* Only first packet timestamp is a word */ 636 + if (pcan_usb_decode_ts(mc, !mc->rec_ts_idx)) 647 637 goto decode_failed; 638 + 639 + /* Next packet in the buffer will have a timestamp on a single byte */ 640 + mc->rec_ts_idx++; 648 641 649 642 /* read data */ 650 643 memset(cf->data, 0x0, sizeof(cf->data)); ··· 701 688 /* handle normal can frames here */ 702 689 } else { 703 690 err = pcan_usb_decode_data(&mc, sl); 704 - mc.rec_data_idx++; 705 691 } 706 692 } 707 693
+1 -1
drivers/net/can/usb/peak_usb/pcan_usb_core.c
··· 750 750 dev = netdev_priv(netdev); 751 751 752 752 /* allocate a buffer large enough to send commands */ 753 - dev->cmd_buf = kmalloc(PCAN_USB_MAX_CMD_LEN, GFP_KERNEL); 753 + dev->cmd_buf = kzalloc(PCAN_USB_MAX_CMD_LEN, GFP_KERNEL); 754 754 if (!dev->cmd_buf) { 755 755 err = -ENOMEM; 756 756 goto lbl_free_candev;
+1 -2
drivers/net/can/usb/usb_8dev.c
··· 996 996 netdev_info(priv->netdev, "device disconnected\n"); 997 997 998 998 unregister_netdev(priv->netdev); 999 - free_candev(priv->netdev); 1000 - 1001 999 unlink_all_urbs(priv); 1000 + free_candev(priv->netdev); 1002 1001 } 1003 1002 1004 1003 }
-1
drivers/net/can/xilinx_can.c
··· 1599 1599 1600 1600 static const struct xcan_devtype_data xcan_axi_data = { 1601 1601 .cantype = XAXI_CAN, 1602 - .flags = XCAN_FLAG_TXFEMP, 1603 1602 .bittiming_const = &xcan_bittiming_const, 1604 1603 .btr_ts2_shift = XCAN_BTR_TS2_SHIFT, 1605 1604 .btr_sjw_shift = XCAN_BTR_SJW_SHIFT,
+2 -2
drivers/net/dsa/bcm_sf2.c
··· 1215 1215 struct bcm_sf2_priv *priv = platform_get_drvdata(pdev); 1216 1216 1217 1217 priv->wol_ports_mask = 0; 1218 + /* Disable interrupts */ 1219 + bcm_sf2_intr_disable(priv); 1218 1220 dsa_unregister_switch(priv->dev->ds); 1219 1221 bcm_sf2_cfp_exit(priv->dev->ds); 1220 - /* Disable all ports and interrupts */ 1221 - bcm_sf2_sw_suspend(priv->dev->ds); 1222 1222 bcm_sf2_mdio_unregister(priv); 1223 1223 1224 1224 return 0;
+15 -20
drivers/net/ethernet/broadcom/genet/bcmgenet.c
··· 1996 1996 1997 1997 /* issue soft reset with (rg)mii loopback to ensure a stable rxclk */ 1998 1998 bcmgenet_umac_writel(priv, CMD_SW_RESET | CMD_LCL_LOOP_EN, UMAC_CMD); 1999 - udelay(2); 2000 - bcmgenet_umac_writel(priv, 0, UMAC_CMD); 2001 1999 } 2002 2000 2003 2001 static void bcmgenet_intr_disable(struct bcmgenet_priv *priv) ··· 2612 2614 spin_unlock_irq(&priv->lock); 2613 2615 2614 2616 if (status & UMAC_IRQ_PHY_DET_R && 2615 - priv->dev->phydev->autoneg != AUTONEG_ENABLE) 2617 + priv->dev->phydev->autoneg != AUTONEG_ENABLE) { 2616 2618 phy_init_hw(priv->dev->phydev); 2619 + genphy_config_aneg(priv->dev->phydev); 2620 + } 2617 2621 2618 2622 /* Link UP/DOWN event */ 2619 2623 if (status & UMAC_IRQ_LINK_EVENT) ··· 2879 2879 if (priv->internal_phy) 2880 2880 bcmgenet_power_up(priv, GENET_POWER_PASSIVE); 2881 2881 2882 - ret = bcmgenet_mii_connect(dev); 2883 - if (ret) { 2884 - netdev_err(dev, "failed to connect to PHY\n"); 2885 - goto err_clk_disable; 2886 - } 2887 - 2888 2882 /* take MAC out of reset */ 2889 2883 bcmgenet_umac_reset(priv); 2890 2884 ··· 2887 2893 /* Make sure we reflect the value of CRC_CMD_FWD */ 2888 2894 reg = bcmgenet_umac_readl(priv, UMAC_CMD); 2889 2895 priv->crc_fwd_en = !!(reg & CMD_CRC_FWD); 2890 - 2891 - ret = bcmgenet_mii_config(dev, true); 2892 - if (ret) { 2893 - netdev_err(dev, "unsupported PHY\n"); 2894 - goto err_disconnect_phy; 2895 - } 2896 2896 2897 2897 bcmgenet_set_hw_addr(priv, dev->dev_addr); 2898 2898 ··· 2903 2915 ret = bcmgenet_init_dma(priv); 2904 2916 if (ret) { 2905 2917 netdev_err(dev, "failed to initialize DMA\n"); 2906 - goto err_disconnect_phy; 2918 + goto err_clk_disable; 2907 2919 } 2908 2920 2909 2921 /* Always enable ring 16 - descriptor ring */ ··· 2926 2938 goto err_irq0; 2927 2939 } 2928 2940 2941 + ret = bcmgenet_mii_probe(dev); 2942 + if (ret) { 2943 + netdev_err(dev, "failed to connect to PHY\n"); 2944 + goto err_irq1; 2945 + } 2946 + 2929 2947 bcmgenet_netif_start(dev); 2930 2948 2931 2949 netif_tx_start_all_queues(dev); 2932 2950 2933 2951 return 0; 2934 2952 2953 + err_irq1: 2954 + free_irq(priv->irq1, priv); 2935 2955 err_irq0: 2936 2956 free_irq(priv->irq0, priv); 2937 2957 err_fini_dma: 2938 2958 bcmgenet_dma_teardown(priv); 2939 2959 bcmgenet_fini_dma(priv); 2940 - err_disconnect_phy: 2941 - phy_disconnect(dev->phydev); 2942 2960 err_clk_disable: 2943 2961 if (priv->internal_phy) 2944 2962 bcmgenet_power_down(priv, GENET_POWER_PASSIVE); ··· 3625 3631 if (priv->internal_phy) 3626 3632 bcmgenet_power_up(priv, GENET_POWER_PASSIVE); 3627 3633 3628 - phy_init_hw(dev->phydev); 3629 - 3630 3634 bcmgenet_umac_reset(priv); 3631 3635 3632 3636 init_umac(priv); ··· 3633 3641 if (priv->wolopts) 3634 3642 clk_disable_unprepare(priv->clk_wol); 3635 3643 3644 + phy_init_hw(dev->phydev); 3645 + 3636 3646 /* Speed settings must be restored */ 3647 + genphy_config_aneg(dev->phydev); 3637 3648 bcmgenet_mii_config(priv->dev, false); 3638 3649 3639 3650 bcmgenet_set_hw_addr(priv, dev->dev_addr);
+1 -1
drivers/net/ethernet/broadcom/genet/bcmgenet.h
··· 720 720 721 721 /* MDIO routines */ 722 722 int bcmgenet_mii_init(struct net_device *dev); 723 - int bcmgenet_mii_connect(struct net_device *dev); 724 723 int bcmgenet_mii_config(struct net_device *dev, bool init); 724 + int bcmgenet_mii_probe(struct net_device *dev); 725 725 void bcmgenet_mii_exit(struct net_device *dev); 726 726 void bcmgenet_phy_power_set(struct net_device *dev, bool enable); 727 727 void bcmgenet_mii_setup(struct net_device *dev);
+95 -52
drivers/net/ethernet/broadcom/genet/bcmmii.c
··· 173 173 bcmgenet_fixed_phy_link_update); 174 174 } 175 175 176 - int bcmgenet_mii_connect(struct net_device *dev) 177 - { 178 - struct bcmgenet_priv *priv = netdev_priv(dev); 179 - struct device_node *dn = priv->pdev->dev.of_node; 180 - struct phy_device *phydev; 181 - u32 phy_flags = 0; 182 - int ret; 183 - 184 - /* Communicate the integrated PHY revision */ 185 - if (priv->internal_phy) 186 - phy_flags = priv->gphy_rev; 187 - 188 - /* Initialize link state variables that bcmgenet_mii_setup() uses */ 189 - priv->old_link = -1; 190 - priv->old_speed = -1; 191 - priv->old_duplex = -1; 192 - priv->old_pause = -1; 193 - 194 - if (dn) { 195 - phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup, 196 - phy_flags, priv->phy_interface); 197 - if (!phydev) { 198 - pr_err("could not attach to PHY\n"); 199 - return -ENODEV; 200 - } 201 - } else { 202 - phydev = dev->phydev; 203 - phydev->dev_flags = phy_flags; 204 - 205 - ret = phy_connect_direct(dev, phydev, bcmgenet_mii_setup, 206 - priv->phy_interface); 207 - if (ret) { 208 - pr_err("could not attach to PHY\n"); 209 - return -ENODEV; 210 - } 211 - } 212 - 213 - return 0; 214 - } 215 - 216 176 int bcmgenet_mii_config(struct net_device *dev, bool init) 217 177 { 218 178 struct bcmgenet_priv *priv = netdev_priv(dev); ··· 181 221 const char *phy_name = NULL; 182 222 u32 id_mode_dis = 0; 183 223 u32 port_ctrl; 224 + int bmcr = -1; 225 + int ret; 184 226 u32 reg; 227 + 228 + /* MAC clocking workaround during reset of umac state machines */ 229 + reg = bcmgenet_umac_readl(priv, UMAC_CMD); 230 + if (reg & CMD_SW_RESET) { 231 + /* An MII PHY must be isolated to prevent TXC contention */ 232 + if (priv->phy_interface == PHY_INTERFACE_MODE_MII) { 233 + ret = phy_read(phydev, MII_BMCR); 234 + if (ret >= 0) { 235 + bmcr = ret; 236 + ret = phy_write(phydev, MII_BMCR, 237 + bmcr | BMCR_ISOLATE); 238 + } 239 + if (ret) { 240 + netdev_err(dev, "failed to isolate PHY\n"); 241 + return ret; 242 + } 243 + } 244 + /* Switch MAC clocking to RGMII generated clock */ 245 + bcmgenet_sys_writel(priv, PORT_MODE_EXT_GPHY, SYS_PORT_CTRL); 246 + /* Ensure 5 clks with Rx disabled 247 + * followed by 5 clks with Reset asserted 248 + */ 249 + udelay(4); 250 + reg &= ~(CMD_SW_RESET | CMD_LCL_LOOP_EN); 251 + bcmgenet_umac_writel(priv, reg, UMAC_CMD); 252 + /* Ensure 5 more clocks before Rx is enabled */ 253 + udelay(2); 254 + } 185 255 186 256 priv->ext_phy = !priv->internal_phy && 187 257 (priv->phy_interface != PHY_INTERFACE_MODE_MOCA); ··· 244 254 phy_set_max_speed(phydev, SPEED_100); 245 255 bcmgenet_sys_writel(priv, 246 256 PORT_MODE_EXT_EPHY, SYS_PORT_CTRL); 257 + /* Restore the MII PHY after isolation */ 258 + if (bmcr >= 0) 259 + phy_write(phydev, MII_BMCR, bmcr); 247 260 break; 248 261 249 262 case PHY_INTERFACE_MODE_REVMII: ··· 299 306 bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL); 300 307 } 301 308 302 - if (init) { 303 - linkmode_copy(phydev->advertising, phydev->supported); 304 - 305 - /* The internal PHY has its link interrupts routed to the 306 - * Ethernet MAC ISRs. On GENETv5 there is a hardware issue 307 - * that prevents the signaling of link UP interrupts when 308 - * the link operates at 10Mbps, so fallback to polling for 309 - * those versions of GENET. 310 - */ 311 - if (priv->internal_phy && !GENET_IS_V5(priv)) 312 - phydev->irq = PHY_IGNORE_INTERRUPT; 313 - 309 + if (init) 314 310 dev_info(kdev, "configuring instance for %s\n", phy_name); 311 + 312 + return 0; 313 + } 314 + 315 + int bcmgenet_mii_probe(struct net_device *dev) 316 + { 317 + struct bcmgenet_priv *priv = netdev_priv(dev); 318 + struct device_node *dn = priv->pdev->dev.of_node; 319 + struct phy_device *phydev; 320 + u32 phy_flags = 0; 321 + int ret; 322 + 323 + /* Communicate the integrated PHY revision */ 324 + if (priv->internal_phy) 325 + phy_flags = priv->gphy_rev; 326 + 327 + /* Initialize link state variables that bcmgenet_mii_setup() uses */ 328 + priv->old_link = -1; 329 + priv->old_speed = -1; 330 + priv->old_duplex = -1; 331 + priv->old_pause = -1; 332 + 333 + if (dn) { 334 + phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup, 335 + phy_flags, priv->phy_interface); 336 + if (!phydev) { 337 + pr_err("could not attach to PHY\n"); 338 + return -ENODEV; 339 + } 340 + } else { 341 + phydev = dev->phydev; 342 + phydev->dev_flags = phy_flags; 343 + 344 + ret = phy_connect_direct(dev, phydev, bcmgenet_mii_setup, 345 + priv->phy_interface); 346 + if (ret) { 347 + pr_err("could not attach to PHY\n"); 348 + return -ENODEV; 349 + } 315 350 } 351 + 352 + /* Configure port multiplexer based on what the probed PHY device since 353 + * reading the 'max-speed' property determines the maximum supported 354 + * PHY speed which is needed for bcmgenet_mii_config() to configure 355 + * things appropriately. 356 + */ 357 + ret = bcmgenet_mii_config(dev, true); 358 + if (ret) { 359 + phy_disconnect(dev->phydev); 360 + return ret; 361 + } 362 + 363 + linkmode_copy(phydev->advertising, phydev->supported); 364 + 365 + /* The internal PHY has its link interrupts routed to the 366 + * Ethernet MAC ISRs. On GENETv5 there is a hardware issue 367 + * that prevents the signaling of link UP interrupts when 368 + * the link operates at 10Mbps, so fallback to polling for 369 + * those versions of GENET. 370 + */ 371 + if (priv->internal_phy && !GENET_IS_V5(priv)) 372 + dev->phydev->irq = PHY_IGNORE_INTERRUPT; 316 373 317 374 return 0; 318 375 }
+1 -1
drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
··· 1499 1499 netdev->ethtool_ops = &octeon_mgmt_ethtool_ops; 1500 1500 1501 1501 netdev->min_mtu = 64 - OCTEON_MGMT_RX_HEADROOM; 1502 - netdev->max_mtu = 16383 - OCTEON_MGMT_RX_HEADROOM; 1502 + netdev->max_mtu = 16383 - OCTEON_MGMT_RX_HEADROOM - VLAN_HLEN; 1503 1503 1504 1504 mac = of_get_mac_address(pdev->dev.of_node); 1505 1505
+2
drivers/net/ethernet/freescale/fec_main.c
··· 3645 3645 regulator_disable(fep->reg_phy); 3646 3646 pm_runtime_put(&pdev->dev); 3647 3647 pm_runtime_disable(&pdev->dev); 3648 + clk_disable_unprepare(fep->clk_ahb); 3649 + clk_disable_unprepare(fep->clk_ipg); 3648 3650 if (of_phy_is_fixed_link(np)) 3649 3651 of_phy_deregister_fixed_link(np); 3650 3652 of_node_put(fep->phy_node);
-1
drivers/net/ethernet/hisilicon/hns/hnae.c
··· 199 199 200 200 ring->q = q; 201 201 ring->flags = flags; 202 - spin_lock_init(&ring->lock); 203 202 ring->coal_param = q->handle->coal_param; 204 203 assert(!ring->desc && !ring->desc_cb && !ring->desc_dma_addr); 205 204
-3
drivers/net/ethernet/hisilicon/hns/hnae.h
··· 274 274 /* statistic */ 275 275 struct ring_stats stats; 276 276 277 - /* ring lock for poll one */ 278 - spinlock_t lock; 279 - 280 277 dma_addr_t desc_dma_addr; 281 278 u32 buf_size; /* size for hnae_desc->addr, preset by AE */ 282 279 u16 desc_num; /* total number of desc */
+1 -21
drivers/net/ethernet/hisilicon/hns/hns_enet.c
··· 943 943 return u > c ? (h > c && h <= u) : (h > c || h <= u); 944 944 } 945 945 946 - /* netif_tx_lock will turn down the performance, set only when necessary */ 947 - #ifdef CONFIG_NET_POLL_CONTROLLER 948 - #define NETIF_TX_LOCK(ring) spin_lock(&(ring)->lock) 949 - #define NETIF_TX_UNLOCK(ring) spin_unlock(&(ring)->lock) 950 - #else 951 - #define NETIF_TX_LOCK(ring) 952 - #define NETIF_TX_UNLOCK(ring) 953 - #endif 954 - 955 946 /* reclaim all desc in one budget 956 947 * return error or number of desc left 957 948 */ ··· 956 965 int head; 957 966 int bytes, pkts; 958 967 959 - NETIF_TX_LOCK(ring); 960 - 961 968 head = readl_relaxed(ring->io_base + RCB_REG_HEAD); 962 969 rmb(); /* make sure head is ready before touch any data */ 963 970 964 - if (is_ring_empty(ring) || head == ring->next_to_clean) { 965 - NETIF_TX_UNLOCK(ring); 971 + if (is_ring_empty(ring) || head == ring->next_to_clean) 966 972 return 0; /* no data to poll */ 967 - } 968 973 969 974 if (!is_valid_clean_head(ring, head)) { 970 975 netdev_err(ndev, "wrong head (%d, %d-%d)\n", head, 971 976 ring->next_to_use, ring->next_to_clean); 972 977 ring->stats.io_err_cnt++; 973 - NETIF_TX_UNLOCK(ring); 974 978 return -EIO; 975 979 } 976 980 ··· 979 993 /* update tx ring statistics. */ 980 994 ring->stats.tx_pkts += pkts; 981 995 ring->stats.tx_bytes += bytes; 982 - 983 - NETIF_TX_UNLOCK(ring); 984 996 985 997 dev_queue = netdev_get_tx_queue(ndev, ring_data->queue_index); 986 998 netdev_tx_completed_queue(dev_queue, pkts, bytes); ··· 1039 1055 int head; 1040 1056 int bytes, pkts; 1041 1057 1042 - NETIF_TX_LOCK(ring); 1043 - 1044 1058 head = ring->next_to_use; /* ntu :soft setted ring position*/ 1045 1059 bytes = 0; 1046 1060 pkts = 0; 1047 1061 while (head != ring->next_to_clean) 1048 1062 hns_nic_reclaim_one_desc(ring, &bytes, &pkts); 1049 - 1050 - NETIF_TX_UNLOCK(ring); 1051 1063 1052 1064 dev_queue = netdev_get_tx_queue(ndev, ring_data->queue_index); 1053 1065 netdev_tx_reset_queue(dev_queue);
+1 -1
drivers/net/ethernet/hisilicon/hns3/hnae3.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 // Copyright (c) 2016-2017 Hisilicon Limited. 3 3 4 4 #ifndef __HNAE3_H
+1 -1
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 // Copyright (c) 2016-2017 Hisilicon Limited. 3 3 4 4 #ifndef __HNS3_ENET_H
+1 -1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 // Copyright (c) 2016-2017 Hisilicon Limited. 3 3 4 4 #ifndef __HCLGE_CMD_H
+1 -1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 // Copyright (c) 2016-2017 Hisilicon Limited. 3 3 4 4 #ifndef __HCLGE_DCB_H__
+17 -1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
··· 3587 3587 { 3588 3588 struct hclge_pf_rst_done_cmd *req; 3589 3589 struct hclge_desc desc; 3590 + int ret; 3590 3591 3591 3592 req = (struct hclge_pf_rst_done_cmd *)desc.data; 3592 3593 hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_PF_RST_DONE, false); 3593 3594 req->pf_rst_done |= HCLGE_PF_RESET_DONE_BIT; 3594 3595 3595 - return hclge_cmd_send(&hdev->hw, &desc, 1); 3596 + ret = hclge_cmd_send(&hdev->hw, &desc, 1); 3597 + /* To be compatible with the old firmware, which does not support 3598 + * command HCLGE_OPC_PF_RST_DONE, just print a warning and 3599 + * return success 3600 + */ 3601 + if (ret == -EOPNOTSUPP) { 3602 + dev_warn(&hdev->pdev->dev, 3603 + "current firmware does not support command(0x%x)!\n", 3604 + HCLGE_OPC_PF_RST_DONE); 3605 + return 0; 3606 + } else if (ret) { 3607 + dev_err(&hdev->pdev->dev, "assert PF reset done fail %d!\n", 3608 + ret); 3609 + } 3610 + 3611 + return ret; 3596 3612 } 3597 3613 3598 3614 static int hclge_reset_prepare_up(struct hclge_dev *hdev)
+1 -1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 // Copyright (c) 2016-2017 Hisilicon Limited. 3 3 4 4 #ifndef __HCLGE_MAIN_H
+1 -1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 // Copyright (c) 2016-2017 Hisilicon Limited. 3 3 4 4 #ifndef __HCLGE_MDIO_H
+1 -1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 // Copyright (c) 2016-2017 Hisilicon Limited. 3 3 4 4 #ifndef __HCLGE_TM_H
+2
drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
··· 20 20 21 21 /* API version 1.7 implements additional link and PHY-specific APIs */ 22 22 #define I40E_MINOR_VER_GET_LINK_INFO_XL710 0x0007 23 + /* API version 1.9 for X722 implements additional link and PHY-specific APIs */ 24 + #define I40E_MINOR_VER_GET_LINK_INFO_X722 0x0009 23 25 /* API version 1.6 for X722 devices adds ability to stop FW LLDP agent */ 24 26 #define I40E_MINOR_VER_FW_LLDP_STOPPABLE_X722 0x0006 25 27
+2 -1
drivers/net/ethernet/intel/i40e/i40e_common.c
··· 1876 1876 hw->aq.fw_min_ver < 40)) && hw_link_info->phy_type == 0xE) 1877 1877 hw_link_info->phy_type = I40E_PHY_TYPE_10GBASE_SFPP_CU; 1878 1878 1879 - if (hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE) { 1879 + if (hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE && 1880 + hw->mac.type != I40E_MAC_X722) { 1880 1881 __le32 tmp; 1881 1882 1882 1883 memcpy(&tmp, resp->link_type, sizeof(tmp));
+2 -8
drivers/net/ethernet/intel/i40e/i40e_xsk.c
··· 689 689 i40e_xdp_ring_update_tail(xdp_ring); 690 690 691 691 xsk_umem_consume_tx_done(xdp_ring->xsk_umem); 692 - if (xsk_umem_uses_need_wakeup(xdp_ring->xsk_umem)) 693 - xsk_clear_tx_need_wakeup(xdp_ring->xsk_umem); 694 692 } 695 693 696 694 return !!budget && work_done; ··· 767 769 i40e_update_tx_stats(tx_ring, completed_frames, total_bytes); 768 770 769 771 out_xmit: 770 - if (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem)) { 771 - if (tx_ring->next_to_clean == tx_ring->next_to_use) 772 - xsk_set_tx_need_wakeup(tx_ring->xsk_umem); 773 - else 774 - xsk_clear_tx_need_wakeup(tx_ring->xsk_umem); 775 - } 772 + if (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem)) 773 + xsk_set_tx_need_wakeup(tx_ring->xsk_umem); 776 774 777 775 xmit_done = i40e_xmit_zc(tx_ring, budget); 778 776
+2 -2
drivers/net/ethernet/intel/iavf/iavf_main.c
··· 314 314 q_vector->rx.target_itr = ITR_TO_REG(rx_ring->itr_setting); 315 315 q_vector->ring_mask |= BIT(r_idx); 316 316 wr32(hw, IAVF_VFINT_ITRN1(IAVF_RX_ITR, q_vector->reg_idx), 317 - q_vector->rx.current_itr); 317 + q_vector->rx.current_itr >> 1); 318 318 q_vector->rx.current_itr = q_vector->rx.target_itr; 319 319 } 320 320 ··· 340 340 q_vector->tx.target_itr = ITR_TO_REG(tx_ring->itr_setting); 341 341 q_vector->num_ringpairs++; 342 342 wr32(hw, IAVF_VFINT_ITRN1(IAVF_TX_ITR, q_vector->reg_idx), 343 - q_vector->tx.target_itr); 343 + q_vector->tx.target_itr >> 1); 344 344 q_vector->tx.current_itr = q_vector->tx.target_itr; 345 345 } 346 346
+1 -1
drivers/net/ethernet/intel/ice/ice_sched.c
··· 1036 1036 struct ice_aqc_query_txsched_res_resp *buf; 1037 1037 enum ice_status status = 0; 1038 1038 __le16 max_sibl; 1039 - u8 i; 1039 + u16 i; 1040 1040 1041 1041 if (hw->layer_info) 1042 1042 return status;
+2 -2
drivers/net/ethernet/intel/igb/igb_main.c
··· 5675 5675 * should have been handled by the upper layers. 5676 5676 */ 5677 5677 if (tx_ring->launchtime_enable) { 5678 - ts = ns_to_timespec64(first->skb->tstamp); 5679 - first->skb->tstamp = 0; 5678 + ts = ktime_to_timespec64(first->skb->tstamp); 5679 + first->skb->tstamp = ktime_set(0, 0); 5680 5680 context_desc->seqnum_seed = cpu_to_le32(ts.tv_nsec / 32); 5681 5681 } else { 5682 5682 context_desc->seqnum_seed = 0;
+2 -2
drivers/net/ethernet/intel/igc/igc_main.c
··· 824 824 * should have been handled by the upper layers. 825 825 */ 826 826 if (tx_ring->launchtime_enable) { 827 - ts = ns_to_timespec64(first->skb->tstamp); 828 - first->skb->tstamp = 0; 827 + ts = ktime_to_timespec64(first->skb->tstamp); 828 + first->skb->tstamp = ktime_set(0, 0); 829 829 context_desc->launch_time = cpu_to_le32(ts.tv_nsec / 32); 830 830 } else { 831 831 context_desc->launch_time = 0;
+2 -8
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
··· 622 622 if (tx_desc) { 623 623 ixgbe_xdp_ring_update_tail(xdp_ring); 624 624 xsk_umem_consume_tx_done(xdp_ring->xsk_umem); 625 - if (xsk_umem_uses_need_wakeup(xdp_ring->xsk_umem)) 626 - xsk_clear_tx_need_wakeup(xdp_ring->xsk_umem); 627 625 } 628 626 629 627 return !!budget && work_done; ··· 689 691 if (xsk_frames) 690 692 xsk_umem_complete_tx(umem, xsk_frames); 691 693 692 - if (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem)) { 693 - if (tx_ring->next_to_clean == tx_ring->next_to_use) 694 - xsk_set_tx_need_wakeup(tx_ring->xsk_umem); 695 - else 696 - xsk_clear_tx_need_wakeup(tx_ring->xsk_umem); 697 - } 694 + if (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem)) 695 + xsk_set_tx_need_wakeup(tx_ring->xsk_umem); 698 696 699 697 return ixgbe_xmit_zc(tx_ring, q_vector->tx.work_limit); 700 698 }
+1 -2
drivers/net/ethernet/mellanox/mlx4/main.c
··· 514 514 dev->caps.max_rq_desc_sz = dev_cap->max_rq_desc_sz; 515 515 /* 516 516 * Subtract 1 from the limit because we need to allocate a 517 - * spare CQE so the HCA HW can tell the difference between an 518 - * empty CQ and a full CQ. 517 + * spare CQE to enable resizing the CQ. 519 518 */ 520 519 dev->caps.max_cqes = dev_cap->max_cq_sz - 1; 521 520 dev->caps.reserved_cqs = dev_cap->reserved_cqs;
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
··· 1079 1079 MLX5_CAP_GEN(dev, max_flow_counter_15_0); 1080 1080 fdb_max = 1 << MLX5_CAP_ESW_FLOWTABLE_FDB(dev, log_max_ft_size); 1081 1081 1082 - esw_debug(dev, "Create offloads FDB table, min (max esw size(2^%d), max counters(%d), groups(%d), max flow table size(2^%d))\n", 1082 + esw_debug(dev, "Create offloads FDB table, min (max esw size(2^%d), max counters(%d), groups(%d), max flow table size(%d))\n", 1083 1083 MLX5_CAP_ESW_FLOWTABLE_FDB(dev, log_max_ft_size), 1084 1084 max_flow_counter, ESW_OFFLOADS_NUM_GROUPS, 1085 1085 fdb_max);
+2 -1
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
··· 183 183 u32 port_mask, port_value; 184 184 185 185 if (MLX5_CAP_ESW_FLOWTABLE(esw->dev, flow_source)) 186 - return spec->flow_context.flow_source == MLX5_VPORT_UPLINK; 186 + return spec->flow_context.flow_source == 187 + MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK; 187 188 188 189 port_mask = MLX5_GET(fte_match_param, spec->match_criteria, 189 190 misc_parameters.source_port);
+1
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
··· 1577 1577 break; 1578 1578 case DR_ACTION_TYP_MODIFY_HDR: 1579 1579 mlx5dr_icm_free_chunk(action->rewrite.chunk); 1580 + kfree(action->rewrite.data); 1580 1581 refcount_dec(&action->rewrite.dmn->refcount); 1581 1582 break; 1582 1583 default:
+2
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c
··· 1096 1096 if (htbl) 1097 1097 mlx5dr_htbl_put(htbl); 1098 1098 1099 + kfree(hw_ste_arr); 1100 + 1099 1101 return 0; 1100 1102 1101 1103 free_ste:
+5 -4
drivers/net/ethernet/mscc/ocelot.c
··· 1680 1680 struct ocelot_port *ocelot_port = netdev_priv(dev); 1681 1681 int err = 0; 1682 1682 1683 - if (!ocelot_netdevice_dev_check(dev)) 1684 - return 0; 1685 - 1686 1683 switch (event) { 1687 1684 case NETDEV_CHANGEUPPER: 1688 1685 if (netif_is_bridge_master(info->upper_dev)) { ··· 1716 1719 struct net_device *dev = netdev_notifier_info_to_dev(ptr); 1717 1720 int ret = 0; 1718 1721 1722 + if (!ocelot_netdevice_dev_check(dev)) 1723 + return 0; 1724 + 1719 1725 if (event == NETDEV_PRECHANGEUPPER && 1720 1726 netif_is_lag_master(info->upper_dev)) { 1721 1727 struct netdev_lag_upper_info *lag_upper_info = info->upper_info; 1722 1728 struct netlink_ext_ack *extack; 1723 1729 1724 - if (lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) { 1730 + if (lag_upper_info && 1731 + lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) { 1725 1732 extack = netdev_notifier_info_to_extack(&info->info); 1726 1733 NL_SET_ERR_MSG_MOD(extack, "LAG device using unsupported Tx type"); 1727 1734
+1 -1
drivers/net/ethernet/mscc/ocelot.h
··· 523 523 #define ocelot_write_rix(ocelot, val, reg, ri) __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri)) 524 524 #define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0) 525 525 526 - void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 mask, 526 + void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg, 527 527 u32 offset); 528 528 #define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) 529 529 #define ocelot_rmw_gix(ocelot, val, m, reg, gi) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi))
+10 -2
drivers/net/ethernet/qlogic/qede/qede_main.c
··· 1208 1208 static void __qede_remove(struct pci_dev *pdev, enum qede_remove_mode mode) 1209 1209 { 1210 1210 struct net_device *ndev = pci_get_drvdata(pdev); 1211 - struct qede_dev *edev = netdev_priv(ndev); 1212 - struct qed_dev *cdev = edev->cdev; 1211 + struct qede_dev *edev; 1212 + struct qed_dev *cdev; 1213 + 1214 + if (!ndev) { 1215 + dev_info(&pdev->dev, "Device has already been removed\n"); 1216 + return; 1217 + } 1218 + 1219 + edev = netdev_priv(ndev); 1220 + cdev = edev->cdev; 1213 1221 1214 1222 DP_INFO(edev, "Starting qede_remove\n"); 1215 1223
+2 -2
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
··· 57 57 if (port->nr_rmnet_devs) 58 58 return -EINVAL; 59 59 60 - kfree(port); 61 - 62 60 netdev_rx_handler_unregister(real_dev); 61 + 62 + kfree(port); 63 63 64 64 /* release reference on real_dev */ 65 65 dev_put(real_dev);
+3
drivers/net/ethernet/realtek/r8169_main.c
··· 916 916 917 917 static int r8168g_mdio_read(struct rtl8169_private *tp, int reg) 918 918 { 919 + if (reg == 0x1f) 920 + return tp->ocp_base == OCP_STD_PHY_BASE ? 0 : tp->ocp_base >> 4; 921 + 919 922 if (tp->ocp_base != OCP_STD_PHY_BASE) 920 923 reg -= 0x10; 921 924
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
··· 432 432 * bits used depends on the hardware configuration 433 433 * selected at core configuration time. 434 434 */ 435 - int bit_nr = bitrev32(~crc32_le(~0, ha->addr, 435 + u32 bit_nr = bitrev32(~crc32_le(~0, ha->addr, 436 436 ETH_ALEN)) >> (32 - mcbitslog2); 437 437 /* The most significant bit determines the register to 438 438 * use (H/L) while the other 5 bits determine the bit
+2 -1
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
··· 224 224 writel(low_credit, ioaddr + XGMAC_MTL_TCx_LOCREDIT(queue)); 225 225 226 226 value = readl(ioaddr + XGMAC_MTL_TCx_ETS_CONTROL(queue)); 227 + value &= ~XGMAC_TSA; 227 228 value |= XGMAC_CC | XGMAC_CBS; 228 229 writel(value, ioaddr + XGMAC_MTL_TCx_ETS_CONTROL(queue)); 229 230 } ··· 464 463 value |= XGMAC_FILTER_HMC; 465 464 466 465 netdev_for_each_mc_addr(ha, dev) { 467 - int nr = (bitrev32(~crc32_le(~0, ha->addr, 6)) >> 466 + u32 nr = (bitrev32(~crc32_le(~0, ha->addr, 6)) >> 468 467 (32 - mcbitslog2)); 469 468 mc_filter[nr >> 5] |= (1 << (nr & 0x1F)); 470 469 }
+2 -1
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
··· 288 288 289 289 static int dwxgmac2_get_rx_header_len(struct dma_desc *p, unsigned int *len) 290 290 { 291 - *len = le32_to_cpu(p->des2) & XGMAC_RDES2_HL; 291 + if (le32_to_cpu(p->des3) & XGMAC_RDES3_L34T) 292 + *len = le32_to_cpu(p->des2) & XGMAC_RDES2_HL; 292 293 return 0; 293 294 } 294 295
+3 -1
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
··· 369 369 dma_cap->eee = (hw_cap & XGMAC_HWFEAT_EEESEL) >> 13; 370 370 dma_cap->atime_stamp = (hw_cap & XGMAC_HWFEAT_TSSEL) >> 12; 371 371 dma_cap->av = (hw_cap & XGMAC_HWFEAT_AVSEL) >> 11; 372 - dma_cap->av &= !(hw_cap & XGMAC_HWFEAT_RAVSEL) >> 10; 372 + dma_cap->av &= !((hw_cap & XGMAC_HWFEAT_RAVSEL) >> 10); 373 373 dma_cap->arpoffsel = (hw_cap & XGMAC_HWFEAT_ARPOFFSEL) >> 9; 374 374 dma_cap->rmon = (hw_cap & XGMAC_HWFEAT_MMCSEL) >> 8; 375 375 dma_cap->pmt_magic_frame = (hw_cap & XGMAC_HWFEAT_MGKSEL) >> 7; ··· 470 470 static void dwxgmac2_qmode(void __iomem *ioaddr, u32 channel, u8 qmode) 471 471 { 472 472 u32 value = readl(ioaddr + XGMAC_MTL_TXQ_OPMODE(channel)); 473 + u32 flow = readl(ioaddr + XGMAC_RX_FLOW_CTRL); 473 474 474 475 value &= ~XGMAC_TXQEN; 475 476 if (qmode != MTL_QUEUE_AVB) { ··· 478 477 writel(0, ioaddr + XGMAC_MTL_TCx_ETS_CONTROL(channel)); 479 478 } else { 480 479 value |= 0x1 << XGMAC_TXQEN_SHIFT; 480 + writel(flow & (~XGMAC_RFE), ioaddr + XGMAC_RX_FLOW_CTRL); 481 481 } 482 482 483 483 writel(value, ioaddr + XGMAC_MTL_TXQ_OPMODE(channel));
+4 -2
drivers/net/ethernet/stmicro/stmmac/mmc_core.c
··· 176 176 #define MMC_XGMAC_RX_PKT_SMD_ERR 0x22c 177 177 #define MMC_XGMAC_RX_PKT_ASSEMBLY_OK 0x230 178 178 #define MMC_XGMAC_RX_FPE_FRAG 0x234 179 + #define MMC_XGMAC_RX_IPC_INTR_MASK 0x25c 179 180 180 181 static void dwmac_mmc_ctrl(void __iomem *mmcaddr, unsigned int mode) 181 182 { ··· 334 333 335 334 static void dwxgmac_mmc_intr_all_mask(void __iomem *mmcaddr) 336 335 { 337 - writel(MMC_DEFAULT_MASK, mmcaddr + MMC_RX_INTR_MASK); 338 - writel(MMC_DEFAULT_MASK, mmcaddr + MMC_TX_INTR_MASK); 336 + writel(0x0, mmcaddr + MMC_RX_INTR_MASK); 337 + writel(0x0, mmcaddr + MMC_TX_INTR_MASK); 338 + writel(MMC_DEFAULT_MASK, mmcaddr + MMC_XGMAC_RX_IPC_INTR_MASK); 339 339 } 340 340 341 341 static void dwxgmac_read_mmc_reg(void __iomem *addr, u32 reg, u32 *dest)
+38 -32
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 2996 2996 stmmac_set_desc_addr(priv, first, des); 2997 2997 tmp_pay_len = pay_len; 2998 2998 des += proto_hdr_len; 2999 + pay_len = 0; 2999 3000 } 3000 3001 3001 3002 stmmac_tso_allocator(priv, des, tmp_pay_len, (nfrags == 0), queue); ··· 3024 3023 /* Only the last descriptor gets to point to the skb. */ 3025 3024 tx_q->tx_skbuff[tx_q->cur_tx] = skb; 3026 3025 3026 + /* Manage tx mitigation */ 3027 + tx_q->tx_count_frames += nfrags + 1; 3028 + if (likely(priv->tx_coal_frames > tx_q->tx_count_frames) && 3029 + !((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && 3030 + priv->hwts_tx_en)) { 3031 + stmmac_tx_timer_arm(priv, queue); 3032 + } else { 3033 + desc = &tx_q->dma_tx[tx_q->cur_tx]; 3034 + tx_q->tx_count_frames = 0; 3035 + stmmac_set_tx_ic(priv, desc); 3036 + priv->xstats.tx_set_ic_bit++; 3037 + } 3038 + 3027 3039 /* We've used all descriptors we need for this skb, however, 3028 3040 * advance cur_tx so that it references a fresh descriptor. 3029 3041 * ndo_start_xmit will fill this descriptor the next time it's ··· 3053 3039 dev->stats.tx_bytes += skb->len; 3054 3040 priv->xstats.tx_tso_frames++; 3055 3041 priv->xstats.tx_tso_nfrags += nfrags; 3056 - 3057 - /* Manage tx mitigation */ 3058 - tx_q->tx_count_frames += nfrags + 1; 3059 - if (likely(priv->tx_coal_frames > tx_q->tx_count_frames) && 3060 - !(priv->synopsys_id >= DWMAC_CORE_4_00 && 3061 - (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && 3062 - priv->hwts_tx_en)) { 3063 - stmmac_tx_timer_arm(priv, queue); 3064 - } else { 3065 - tx_q->tx_count_frames = 0; 3066 - stmmac_set_tx_ic(priv, desc); 3067 - priv->xstats.tx_set_ic_bit++; 3068 - } 3069 3042 3070 3043 if (priv->sarc_type) 3071 3044 stmmac_set_desc_sarc(priv, first, priv->sarc_type); ··· 3225 3224 /* Only the last descriptor gets to point to the skb. */ 3226 3225 tx_q->tx_skbuff[entry] = skb; 3227 3226 3227 + /* According to the coalesce parameter the IC bit for the latest 3228 + * segment is reset and the timer re-started to clean the tx status. 3229 + * This approach takes care about the fragments: desc is the first 3230 + * element in case of no SG. 3231 + */ 3232 + tx_q->tx_count_frames += nfrags + 1; 3233 + if (likely(priv->tx_coal_frames > tx_q->tx_count_frames) && 3234 + !((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && 3235 + priv->hwts_tx_en)) { 3236 + stmmac_tx_timer_arm(priv, queue); 3237 + } else { 3238 + if (likely(priv->extend_desc)) 3239 + desc = &tx_q->dma_etx[entry].basic; 3240 + else 3241 + desc = &tx_q->dma_tx[entry]; 3242 + 3243 + tx_q->tx_count_frames = 0; 3244 + stmmac_set_tx_ic(priv, desc); 3245 + priv->xstats.tx_set_ic_bit++; 3246 + } 3247 + 3228 3248 /* We've used all descriptors we need for this skb, however, 3229 3249 * advance cur_tx so that it references a fresh descriptor. 3230 3250 * ndo_start_xmit will fill this descriptor the next time it's ··· 3280 3258 } 3281 3259 3282 3260 dev->stats.tx_bytes += skb->len; 3283 - 3284 - /* According to the coalesce parameter the IC bit for the latest 3285 - * segment is reset and the timer re-started to clean the tx status. 3286 - * This approach takes care about the fragments: desc is the first 3287 - * element in case of no SG. 3288 - */ 3289 - tx_q->tx_count_frames += nfrags + 1; 3290 - if (likely(priv->tx_coal_frames > tx_q->tx_count_frames) && 3291 - !(priv->synopsys_id >= DWMAC_CORE_4_00 && 3292 - (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && 3293 - priv->hwts_tx_en)) { 3294 - stmmac_tx_timer_arm(priv, queue); 3295 - } else { 3296 - tx_q->tx_count_frames = 0; 3297 - stmmac_set_tx_ic(priv, desc); 3298 - priv->xstats.tx_set_ic_bit++; 3299 - } 3300 3261 3301 3262 if (priv->sarc_type) 3302 3263 stmmac_set_desc_sarc(priv, first, priv->sarc_type); ··· 3511 3506 if (unlikely(status & dma_own)) 3512 3507 break; 3513 3508 3514 - count++; 3515 - 3516 3509 rx_q->cur_rx = STMMAC_GET_ENTRY(rx_q->cur_rx, DMA_RX_SIZE); 3517 3510 next_entry = rx_q->cur_rx; 3518 3511 ··· 3537 3534 goto read_again; 3538 3535 if (unlikely(error)) { 3539 3536 dev_kfree_skb(skb); 3537 + count++; 3540 3538 continue; 3541 3539 } 3542 3540 ··· 3577 3573 skb = napi_alloc_skb(&ch->rx_napi, len); 3578 3574 if (!skb) { 3579 3575 priv->dev->stats.rx_dropped++; 3576 + count++; 3580 3577 continue; 3581 3578 } 3582 3579 ··· 3643 3638 3644 3639 priv->dev->stats.rx_packets++; 3645 3640 priv->dev->stats.rx_bytes += len; 3641 + count++; 3646 3642 } 3647 3643 3648 3644 if (status & rx_not_ls) {
+94 -40
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
··· 6 6 * Author: Jose Abreu <joabreu@synopsys.com> 7 7 */ 8 8 9 + #include <linux/bitrev.h> 9 10 #include <linux/completion.h> 11 + #include <linux/crc32.h> 10 12 #include <linux/ethtool.h> 11 13 #include <linux/ip.h> 12 14 #include <linux/phy.h> ··· 487 485 return -EOPNOTSUPP; 488 486 } 489 487 488 + static bool stmmac_hash_check(struct stmmac_priv *priv, unsigned char *addr) 489 + { 490 + int mc_offset = 32 - priv->hw->mcast_bits_log2; 491 + struct netdev_hw_addr *ha; 492 + u32 hash, hash_nr; 493 + 494 + /* First compute the hash for desired addr */ 495 + hash = bitrev32(~crc32_le(~0, addr, 6)) >> mc_offset; 496 + hash_nr = hash >> 5; 497 + hash = 1 << (hash & 0x1f); 498 + 499 + /* Now, check if it collides with any existing one */ 500 + netdev_for_each_mc_addr(ha, priv->dev) { 501 + u32 nr = bitrev32(~crc32_le(~0, ha->addr, ETH_ALEN)) >> mc_offset; 502 + if (((nr >> 5) == hash_nr) && ((1 << (nr & 0x1f)) == hash)) 503 + return false; 504 + } 505 + 506 + /* No collisions, address is good to go */ 507 + return true; 508 + } 509 + 510 + static bool stmmac_perfect_check(struct stmmac_priv *priv, unsigned char *addr) 511 + { 512 + struct netdev_hw_addr *ha; 513 + 514 + /* Check if it collides with any existing one */ 515 + netdev_for_each_uc_addr(ha, priv->dev) { 516 + if (!memcmp(ha->addr, addr, ETH_ALEN)) 517 + return false; 518 + } 519 + 520 + /* No collisions, address is good to go */ 521 + return true; 522 + } 523 + 490 524 static int stmmac_test_hfilt(struct stmmac_priv *priv) 491 525 { 492 - unsigned char gd_addr[ETH_ALEN] = {0x01, 0xee, 0xdd, 0xcc, 0xbb, 0xaa}; 493 - unsigned char bd_addr[ETH_ALEN] = {0x01, 0x01, 0x02, 0x03, 0x04, 0x05}; 526 + unsigned char gd_addr[ETH_ALEN] = {0xf1, 0xee, 0xdd, 0xcc, 0xbb, 0xaa}; 527 + unsigned char bd_addr[ETH_ALEN] = {0xf1, 0xff, 0xff, 0xff, 0xff, 0xff}; 494 528 struct stmmac_packet_attrs attr = { }; 495 - int ret; 529 + int ret, tries = 256; 496 530 497 531 ret = stmmac_filter_check(priv); 498 532 if (ret) 499 533 return ret; 500 534 501 535 if (netdev_mc_count(priv->dev) >= priv->hw->multicast_filter_bins) 536 + return -EOPNOTSUPP; 537 + 538 + while (--tries) { 539 + /* We only need to check the bd_addr for collisions */ 540 + bd_addr[ETH_ALEN - 1] = tries; 541 + if (stmmac_hash_check(priv, bd_addr)) 542 + break; 543 + } 544 + 545 + if (!tries) 502 546 return -EOPNOTSUPP; 503 547 504 548 ret = dev_mc_add(priv->dev, gd_addr); ··· 571 523 572 524 static int stmmac_test_pfilt(struct stmmac_priv *priv) 573 525 { 574 - unsigned char gd_addr[ETH_ALEN] = {0x00, 0x01, 0x44, 0x55, 0x66, 0x77}; 575 - unsigned char bd_addr[ETH_ALEN] = {0x08, 0x00, 0x22, 0x33, 0x44, 0x55}; 526 + unsigned char gd_addr[ETH_ALEN] = {0xf0, 0x01, 0x44, 0x55, 0x66, 0x77}; 527 + unsigned char bd_addr[ETH_ALEN] = {0xf0, 0xff, 0xff, 0xff, 0xff, 0xff}; 576 528 struct stmmac_packet_attrs attr = { }; 577 - int ret; 529 + int ret, tries = 256; 578 530 579 531 if (stmmac_filter_check(priv)) 532 + return -EOPNOTSUPP; 533 + if (netdev_uc_count(priv->dev) >= priv->hw->unicast_filter_entries) 534 + return -EOPNOTSUPP; 535 + 536 + while (--tries) { 537 + /* We only need to check the bd_addr for collisions */ 538 + bd_addr[ETH_ALEN - 1] = tries; 539 + if (stmmac_perfect_check(priv, bd_addr)) 540 + break; 541 + } 542 + 543 + if (!tries) 580 544 return -EOPNOTSUPP; 581 545 582 546 ret = dev_uc_add(priv->dev, gd_addr); ··· 613 553 return ret; 614 554 } 615 555 616 - static int stmmac_dummy_sync(struct net_device *netdev, const u8 *addr) 617 - { 618 - return 0; 619 - } 620 - 621 - static void stmmac_test_set_rx_mode(struct net_device *netdev) 622 - { 623 - /* As we are in test mode of ethtool we already own the rtnl lock 624 - * so no address will change from user. We can just call the 625 - * ndo_set_rx_mode() callback directly */ 626 - if (netdev->netdev_ops->ndo_set_rx_mode) 627 - netdev->netdev_ops->ndo_set_rx_mode(netdev); 628 - } 629 - 630 556 static int stmmac_test_mcfilt(struct stmmac_priv *priv) 631 557 { 632 - unsigned char uc_addr[ETH_ALEN] = {0x00, 0x01, 0x44, 0x55, 0x66, 0x77}; 633 - unsigned char mc_addr[ETH_ALEN] = {0x01, 0x01, 0x44, 0x55, 0x66, 0x77}; 558 + unsigned char uc_addr[ETH_ALEN] = {0xf0, 0xff, 0xff, 0xff, 0xff, 0xff}; 559 + unsigned char mc_addr[ETH_ALEN] = {0xf1, 0xff, 0xff, 0xff, 0xff, 0xff}; 634 560 struct stmmac_packet_attrs attr = { }; 635 - int ret; 561 + int ret, tries = 256; 636 562 637 563 if (stmmac_filter_check(priv)) 638 564 return -EOPNOTSUPP; 639 - if (!priv->hw->multicast_filter_bins) 565 + if (netdev_uc_count(priv->dev) >= priv->hw->unicast_filter_entries) 640 566 return -EOPNOTSUPP; 641 567 642 - /* Remove all MC addresses */ 643 - __dev_mc_unsync(priv->dev, NULL); 644 - stmmac_test_set_rx_mode(priv->dev); 568 + while (--tries) { 569 + /* We only need to check the mc_addr for collisions */ 570 + mc_addr[ETH_ALEN - 1] = tries; 571 + if (stmmac_hash_check(priv, mc_addr)) 572 + break; 573 + } 574 + 575 + if (!tries) 576 + return -EOPNOTSUPP; 645 577 646 578 ret = dev_uc_add(priv->dev, uc_addr); 647 579 if (ret) 648 - goto cleanup; 580 + return ret; 649 581 650 582 attr.dst = uc_addr; 651 583 ··· 654 602 655 603 cleanup: 656 604 dev_uc_del(priv->dev, uc_addr); 657 - __dev_mc_sync(priv->dev, stmmac_dummy_sync, NULL); 658 - stmmac_test_set_rx_mode(priv->dev); 659 605 return ret; 660 606 } 661 607 662 608 static int stmmac_test_ucfilt(struct stmmac_priv *priv) 663 609 { 664 - unsigned char uc_addr[ETH_ALEN] = {0x00, 0x01, 0x44, 0x55, 0x66, 0x77}; 665 - unsigned char mc_addr[ETH_ALEN] = {0x01, 0x01, 0x44, 0x55, 0x66, 0x77}; 610 + unsigned char uc_addr[ETH_ALEN] = {0xf0, 0xff, 0xff, 0xff, 0xff, 0xff}; 611 + unsigned char mc_addr[ETH_ALEN] = {0xf1, 0xff, 0xff, 0xff, 0xff, 0xff}; 666 612 struct stmmac_packet_attrs attr = { }; 667 - int ret; 613 + int ret, tries = 256; 668 614 669 615 if (stmmac_filter_check(priv)) 670 616 return -EOPNOTSUPP; 671 - if (!priv->hw->multicast_filter_bins) 617 + if (netdev_mc_count(priv->dev) >= priv->hw->multicast_filter_bins) 672 618 return -EOPNOTSUPP; 673 619 674 - /* Remove all UC addresses */ 675 - __dev_uc_unsync(priv->dev, NULL); 676 - stmmac_test_set_rx_mode(priv->dev); 620 + while (--tries) { 621 + /* We only need to check the uc_addr for collisions */ 622 + uc_addr[ETH_ALEN - 1] = tries; 623 + if (stmmac_perfect_check(priv, uc_addr)) 624 + break; 625 + } 626 + 627 + if (!tries) 628 + return -EOPNOTSUPP; 677 629 678 630 ret = dev_mc_add(priv->dev, mc_addr); 679 631 if (ret) 680 - goto cleanup; 632 + return ret; 681 633 682 634 attr.dst = mc_addr; 683 635 ··· 698 642 699 643 cleanup: 700 644 dev_mc_del(priv->dev, mc_addr); 701 - __dev_uc_sync(priv->dev, stmmac_dummy_sync, NULL); 702 - stmmac_test_set_rx_mode(priv->dev); 703 645 return ret; 704 646 } 705 647
+3 -3
drivers/net/usb/cdc_ncm.c
··· 578 578 /* read current mtu value from device */ 579 579 err = usbnet_read_cmd(dev, USB_CDC_GET_MAX_DATAGRAM_SIZE, 580 580 USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE, 581 - 0, iface_no, &max_datagram_size, 2); 582 - if (err < 0) { 581 + 0, iface_no, &max_datagram_size, sizeof(max_datagram_size)); 582 + if (err < sizeof(max_datagram_size)) { 583 583 dev_dbg(&dev->intf->dev, "GET_MAX_DATAGRAM_SIZE failed\n"); 584 584 goto out; 585 585 } ··· 590 590 max_datagram_size = cpu_to_le16(ctx->max_datagram_size); 591 591 err = usbnet_write_cmd(dev, USB_CDC_SET_MAX_DATAGRAM_SIZE, 592 592 USB_TYPE_CLASS | USB_DIR_OUT | USB_RECIP_INTERFACE, 593 - 0, iface_no, &max_datagram_size, 2); 593 + 0, iface_no, &max_datagram_size, sizeof(max_datagram_size)); 594 594 if (err < 0) 595 595 dev_dbg(&dev->intf->dev, "SET_MAX_DATAGRAM_SIZE failed\n"); 596 596
+1
drivers/net/usb/qmi_wwan.c
··· 1362 1362 {QMI_FIXED_INTF(0x413c, 0x81b6, 8)}, /* Dell Wireless 5811e */ 1363 1363 {QMI_FIXED_INTF(0x413c, 0x81b6, 10)}, /* Dell Wireless 5811e */ 1364 1364 {QMI_FIXED_INTF(0x413c, 0x81d7, 0)}, /* Dell Wireless 5821e */ 1365 + {QMI_FIXED_INTF(0x413c, 0x81e0, 0)}, /* Dell Wireless 5821e with eSIM support*/ 1365 1366 {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */ 1366 1367 {QMI_FIXED_INTF(0x03f0, 0x9d1d, 1)}, /* HP lt4120 Snapdragon X5 LTE */ 1367 1368 {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */
+1 -1
drivers/nfc/fdp/i2c.c
··· 259 259 *fw_vsc_cfg, len); 260 260 261 261 if (r) { 262 - devm_kfree(dev, fw_vsc_cfg); 262 + devm_kfree(dev, *fw_vsc_cfg); 263 263 goto vsc_read_err; 264 264 } 265 265 } else {
+1
drivers/nfc/st21nfca/core.c
··· 708 708 NFC_PROTO_FELICA_MASK; 709 709 } else { 710 710 kfree_skb(nfcid_skb); 711 + nfcid_skb = NULL; 711 712 /* P2P in type A */ 712 713 r = nfc_hci_get_param(hdev, ST21NFCA_RF_READER_F_GATE, 713 714 ST21NFCA_RF_READER_F_NFCID1,
+2 -2
include/linux/bpf.h
··· 656 656 void bpf_map_put(struct bpf_map *map); 657 657 int bpf_map_charge_memlock(struct bpf_map *map, u32 pages); 658 658 void bpf_map_uncharge_memlock(struct bpf_map *map, u32 pages); 659 - int bpf_map_charge_init(struct bpf_map_memory *mem, size_t size); 659 + int bpf_map_charge_init(struct bpf_map_memory *mem, u64 size); 660 660 void bpf_map_charge_finish(struct bpf_map_memory *mem); 661 661 void bpf_map_charge_move(struct bpf_map_memory *dst, 662 662 struct bpf_map_memory *src); 663 - void *bpf_map_area_alloc(size_t size, int numa_node); 663 + void *bpf_map_area_alloc(u64 size, int numa_node); 664 664 void bpf_map_area_free(void *base); 665 665 void bpf_map_init_from_attr(struct bpf_map *map, union bpf_attr *attr); 666 666
+6 -3
include/linux/skmsg.h
··· 139 139 } 140 140 } 141 141 142 + static inline u32 sk_msg_iter_dist(u32 start, u32 end) 143 + { 144 + return end >= start ? end - start : end + (MAX_MSG_FRAGS - start); 145 + } 146 + 142 147 #define sk_msg_iter_var_prev(var) \ 143 148 do { \ 144 149 if (var == 0) \ ··· 203 198 if (sk_msg_full(msg)) 204 199 return MAX_MSG_FRAGS; 205 200 206 - return msg->sg.end >= msg->sg.start ? 207 - msg->sg.end - msg->sg.start : 208 - msg->sg.end + (MAX_MSG_FRAGS - msg->sg.start); 201 + return sk_msg_iter_dist(msg->sg.start, msg->sg.end); 209 202 } 210 203 211 204 static inline struct scatterlist *sk_msg_elem(struct sk_msg *msg, int which)
+1 -2
include/net/bonding.h
··· 159 159 unsigned long target_last_arp_rx[BOND_MAX_ARP_TARGETS]; 160 160 s8 link; /* one of BOND_LINK_XXXX */ 161 161 s8 link_new_state; /* one of BOND_LINK_XXXX */ 162 - s8 new_link; 163 162 u8 backup:1, /* indicates backup slave. Value corresponds with 164 163 BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ 165 164 inactive:1, /* indicates inactive slave */ ··· 548 549 549 550 static inline void bond_commit_link_state(struct slave *slave, bool notify) 550 551 { 551 - if (slave->link == slave->link_new_state) 552 + if (slave->link_new_state == BOND_LINK_NOCHANGE) 552 553 return; 553 554 554 555 slave->link = slave->link_new_state;
+2 -2
include/net/fq_impl.h
··· 313 313 fq->limit = 8192; 314 314 fq->memory_limit = 16 << 20; /* 16 MBytes */ 315 315 316 - fq->flows = kcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL); 316 + fq->flows = kvcalloc(fq->flows_cnt, sizeof(fq->flows[0]), GFP_KERNEL); 317 317 if (!fq->flows) 318 318 return -ENOMEM; 319 319 ··· 331 331 for (i = 0; i < fq->flows_cnt; i++) 332 332 fq_flow_reset(fq, &fq->flows[i], free_func); 333 333 334 - kfree(fq->flows); 334 + kvfree(fq->flows); 335 335 fq->flows = NULL; 336 336 } 337 337
+2 -2
include/net/neighbour.h
··· 439 439 { 440 440 unsigned long now = jiffies; 441 441 442 - if (neigh->used != now) 443 - neigh->used = now; 442 + if (READ_ONCE(neigh->used) != now) 443 + WRITE_ONCE(neigh->used, now); 444 444 if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE))) 445 445 return __neigh_event_send(neigh, skb); 446 446 return 0;
+2 -1
include/net/netfilter/nf_tables.h
··· 820 820 */ 821 821 struct nft_expr { 822 822 const struct nft_expr_ops *ops; 823 - unsigned char data[]; 823 + unsigned char data[] 824 + __attribute__((aligned(__alignof__(u64)))); 824 825 }; 825 826 826 827 static inline void *nft_expr_priv(const struct nft_expr *expr)
+4
include/net/sch_generic.h
··· 15 15 #include <linux/mutex.h> 16 16 #include <linux/rwsem.h> 17 17 #include <linux/atomic.h> 18 + #include <linux/hashtable.h> 18 19 #include <net/gen_stats.h> 19 20 #include <net/rtnetlink.h> 20 21 #include <net/flow_offload.h> ··· 363 362 bool deleting; 364 363 refcount_t refcnt; 365 364 struct rcu_head rcu; 365 + struct hlist_node destroy_ht_node; 366 366 }; 367 367 368 368 struct qdisc_skb_cb { ··· 416 414 struct list_head filter_chain_list; 417 415 } chain0; 418 416 struct rcu_head rcu; 417 + DECLARE_HASHTABLE(proto_destroy_ht, 7); 418 + struct mutex proto_destroy_lock; /* Lock for proto_destroy hashtable. */ 419 419 }; 420 420 421 421 #ifdef CONFIG_PROVE_LOCKING
+2 -2
include/net/sock.h
··· 2342 2342 2343 2343 return kt; 2344 2344 #else 2345 - return sk->sk_stamp; 2345 + return READ_ONCE(sk->sk_stamp); 2346 2346 #endif 2347 2347 } 2348 2348 ··· 2353 2353 sk->sk_stamp = kt; 2354 2354 write_sequnlock(&sk->sk_stamp_seq); 2355 2355 #else 2356 - sk->sk_stamp = kt; 2356 + WRITE_ONCE(sk->sk_stamp, kt); 2357 2357 #endif 2358 2358 } 2359 2359
+5
include/net/tls.h
··· 40 40 #include <linux/socket.h> 41 41 #include <linux/tcp.h> 42 42 #include <linux/skmsg.h> 43 + #include <linux/mutex.h> 43 44 #include <linux/netdevice.h> 44 45 #include <linux/rcupdate.h> 45 46 ··· 270 269 271 270 bool in_tcp_sendpages; 272 271 bool pending_open_record_frags; 272 + 273 + struct mutex tx_lock; /* protects partially_sent_* fields and 274 + * per-type TX fields 275 + */ 273 276 unsigned long flags; 274 277 275 278 /* cache cold stuff */
+1 -1
include/uapi/linux/can.h
··· 1 - /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ 1 + /* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */ 2 2 /* 3 3 * linux/can.h 4 4 *
+1 -1
include/uapi/linux/can/bcm.h
··· 1 - /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ 1 + /* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */ 2 2 /* 3 3 * linux/can/bcm.h 4 4 *
+1 -1
include/uapi/linux/can/error.h
··· 1 - /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ 1 + /* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */ 2 2 /* 3 3 * linux/can/error.h 4 4 *
+1 -1
include/uapi/linux/can/gw.h
··· 1 - /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ 1 + /* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */ 2 2 /* 3 3 * linux/can/gw.h 4 4 *
+1 -1
include/uapi/linux/can/j1939.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 1 + /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ 2 2 /* 3 3 * j1939.h 4 4 *
+1 -1
include/uapi/linux/can/netlink.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 1 + /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ 2 2 /* 3 3 * linux/can/netlink.h 4 4 *
+1 -1
include/uapi/linux/can/raw.h
··· 1 - /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ 1 + /* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */ 2 2 /* 3 3 * linux/can/raw.h 4 4 *
+1 -1
include/uapi/linux/can/vxcan.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 1 + /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ 2 2 #ifndef _UAPI_CAN_VXCAN_H 3 3 #define _UAPI_CAN_VXCAN_H 4 4
+2 -2
kernel/bpf/cgroup.c
··· 1311 1311 return false; 1312 1312 1313 1313 switch (off) { 1314 - case offsetof(struct bpf_sysctl, write): 1314 + case bpf_ctx_range(struct bpf_sysctl, write): 1315 1315 if (type != BPF_READ) 1316 1316 return false; 1317 1317 bpf_ctx_record_field_size(info, size_default); 1318 1318 return bpf_ctx_narrow_access_ok(off, size, size_default); 1319 - case offsetof(struct bpf_sysctl, file_pos): 1319 + case bpf_ctx_range(struct bpf_sysctl, file_pos): 1320 1320 if (type == BPF_READ) { 1321 1321 bpf_ctx_record_field_size(info, size_default); 1322 1322 return bpf_ctx_narrow_access_ok(off, size, size_default);
+5 -2
kernel/bpf/syscall.c
··· 126 126 return map; 127 127 } 128 128 129 - void *bpf_map_area_alloc(size_t size, int numa_node) 129 + void *bpf_map_area_alloc(u64 size, int numa_node) 130 130 { 131 131 /* We really just want to fail instead of triggering OOM killer 132 132 * under memory pressure, therefore we set __GFP_NORETRY to kmalloc, ··· 140 140 141 141 const gfp_t flags = __GFP_NOWARN | __GFP_ZERO; 142 142 void *area; 143 + 144 + if (size >= SIZE_MAX) 145 + return NULL; 143 146 144 147 if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { 145 148 area = kmalloc_node(size, GFP_USER | __GFP_NORETRY | flags, ··· 200 197 atomic_long_sub(pages, &user->locked_vm); 201 198 } 202 199 203 - int bpf_map_charge_init(struct bpf_map_memory *mem, size_t size) 200 + int bpf_map_charge_init(struct bpf_map_memory *mem, u64 size) 204 201 { 205 202 u32 pages = round_up(size, PAGE_SIZE) >> PAGE_SHIFT; 206 203 struct user_struct *user;
+15 -4
net/bridge/netfilter/ebt_dnat.c
··· 20 20 ebt_dnat_tg(struct sk_buff *skb, const struct xt_action_param *par) 21 21 { 22 22 const struct ebt_nat_info *info = par->targinfo; 23 - struct net_device *dev; 24 23 25 24 if (skb_ensure_writable(skb, ETH_ALEN)) 26 25 return EBT_DROP; ··· 32 33 else 33 34 skb->pkt_type = PACKET_MULTICAST; 34 35 } else { 35 - if (xt_hooknum(par) != NF_BR_BROUTING) 36 - dev = br_port_get_rcu(xt_in(par))->br->dev; 37 - else 36 + const struct net_device *dev; 37 + 38 + switch (xt_hooknum(par)) { 39 + case NF_BR_BROUTING: 38 40 dev = xt_in(par); 41 + break; 42 + case NF_BR_PRE_ROUTING: 43 + dev = br_port_get_rcu(xt_in(par))->br->dev; 44 + break; 45 + default: 46 + dev = NULL; 47 + break; 48 + } 49 + 50 + if (!dev) /* NF_BR_LOCAL_OUT */ 51 + return info->target; 39 52 40 53 if (ether_addr_equal(info->mac, dev->dev_addr)) 41 54 skb->pkt_type = PACKET_HOST;
+7 -2
net/can/j1939/socket.c
··· 580 580 j1939_netdev_stop(priv); 581 581 } 582 582 583 + kfree(jsk->filters); 583 584 sock_orphan(sk); 584 585 sock->sk = NULL; 585 586 ··· 910 909 memset(serr, 0, sizeof(*serr)); 911 910 switch (type) { 912 911 case J1939_ERRQUEUE_ACK: 913 - if (!(sk->sk_tsflags & SOF_TIMESTAMPING_TX_ACK)) 912 + if (!(sk->sk_tsflags & SOF_TIMESTAMPING_TX_ACK)) { 913 + kfree_skb(skb); 914 914 return; 915 + } 915 916 916 917 serr->ee.ee_errno = ENOMSG; 917 918 serr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING; ··· 921 918 state = "ACK"; 922 919 break; 923 920 case J1939_ERRQUEUE_SCHED: 924 - if (!(sk->sk_tsflags & SOF_TIMESTAMPING_TX_SCHED)) 921 + if (!(sk->sk_tsflags & SOF_TIMESTAMPING_TX_SCHED)) { 922 + kfree_skb(skb); 925 923 return; 924 + } 926 925 927 926 serr->ee.ee_errno = ENOMSG; 928 927 serr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING;
+19 -1
net/can/j1939/transport.c
··· 1273 1273 static void 1274 1274 j1939_xtp_rx_eoma_one(struct j1939_session *session, struct sk_buff *skb) 1275 1275 { 1276 + struct j1939_sk_buff_cb *skcb = j1939_skb_to_cb(skb); 1277 + const u8 *dat; 1278 + int len; 1279 + 1276 1280 if (j1939_xtp_rx_cmd_bad_pgn(session, skb)) 1277 1281 return; 1282 + 1283 + dat = skb->data; 1284 + 1285 + if (skcb->addr.type == J1939_ETP) 1286 + len = j1939_etp_ctl_to_size(dat); 1287 + else 1288 + len = j1939_tp_ctl_to_size(dat); 1289 + 1290 + if (session->total_message_size != len) { 1291 + netdev_warn_once(session->priv->ndev, 1292 + "%s: 0x%p: Incorrect size. Expected: %i; got: %i.\n", 1293 + __func__, session, session->total_message_size, 1294 + len); 1295 + } 1278 1296 1279 1297 netdev_dbg(session->priv->ndev, "%s: 0x%p\n", __func__, session); 1280 1298 ··· 1450 1432 skcb = j1939_skb_to_cb(skb); 1451 1433 memcpy(skcb, rel_skcb, sizeof(*skcb)); 1452 1434 1453 - session = j1939_session_new(priv, skb, skb->len); 1435 + session = j1939_session_new(priv, skb, size); 1454 1436 if (!session) { 1455 1437 kfree_skb(skb); 1456 1438 return NULL;
+15 -5
net/core/skmsg.c
··· 270 270 271 271 msg->sg.data[i].length -= trim; 272 272 sk_mem_uncharge(sk, trim); 273 + /* Adjust copybreak if it falls into the trimmed part of last buf */ 274 + if (msg->sg.curr == i && msg->sg.copybreak > msg->sg.data[i].length) 275 + msg->sg.copybreak = msg->sg.data[i].length; 273 276 out: 274 - /* If we trim data before curr pointer update copybreak and current 275 - * so that any future copy operations start at new copy location. 277 + sk_msg_iter_var_next(i); 278 + msg->sg.end = i; 279 + 280 + /* If we trim data a full sg elem before curr pointer update 281 + * copybreak and current so that any future copy operations 282 + * start at new copy location. 276 283 * However trimed data that has not yet been used in a copy op 277 284 * does not require an update. 278 285 */ 279 - if (msg->sg.curr >= i) { 286 + if (!msg->sg.size) { 287 + msg->sg.curr = msg->sg.start; 288 + msg->sg.copybreak = 0; 289 + } else if (sk_msg_iter_dist(msg->sg.start, msg->sg.curr) >= 290 + sk_msg_iter_dist(msg->sg.start, msg->sg.end)) { 291 + sk_msg_iter_var_prev(i); 280 292 msg->sg.curr = i; 281 293 msg->sg.copybreak = msg->sg.data[i].length; 282 294 } 283 - sk_msg_iter_var_next(i); 284 - msg->sg.end = i; 285 295 } 286 296 EXPORT_SYMBOL_GPL(sk_msg_trim); 287 297
+1 -1
net/dccp/ipv4.c
··· 416 416 RCU_INIT_POINTER(newinet->inet_opt, rcu_dereference(ireq->ireq_opt)); 417 417 newinet->mc_index = inet_iif(skb); 418 418 newinet->mc_ttl = ip_hdr(skb)->ttl; 419 - newinet->inet_id = jiffies; 419 + newinet->inet_id = prandom_u32(); 420 420 421 421 if (dst == NULL && (dst = inet_csk_route_child_sock(sk, newsk, req)) == NULL) 422 422 goto put_and_exit;
+1 -1
net/ipv4/fib_semantics.c
··· 1814 1814 int ret = 0; 1815 1815 unsigned int hash = fib_laddr_hashfn(local); 1816 1816 struct hlist_head *head = &fib_info_laddrhash[hash]; 1817 + int tb_id = l3mdev_fib_table(dev) ? : RT_TABLE_MAIN; 1817 1818 struct net *net = dev_net(dev); 1818 - int tb_id = l3mdev_fib_table(dev); 1819 1819 struct fib_info *fi; 1820 1820 1821 1821 if (!fib_info_laddrhash || local == 0)
+10 -3
net/ipv6/route.c
··· 621 621 { 622 622 struct __rt6_probe_work *work = NULL; 623 623 const struct in6_addr *nh_gw; 624 + unsigned long last_probe; 624 625 struct neighbour *neigh; 625 626 struct net_device *dev; 626 627 struct inet6_dev *idev; ··· 640 639 nh_gw = &fib6_nh->fib_nh_gw6; 641 640 dev = fib6_nh->fib_nh_dev; 642 641 rcu_read_lock_bh(); 642 + last_probe = READ_ONCE(fib6_nh->last_probe); 643 643 idev = __in6_dev_get(dev); 644 644 neigh = __ipv6_neigh_lookup_noref(dev, nh_gw); 645 645 if (neigh) { ··· 656 654 __neigh_set_probe_once(neigh); 657 655 } 658 656 write_unlock(&neigh->lock); 659 - } else if (time_after(jiffies, fib6_nh->last_probe + 657 + } else if (time_after(jiffies, last_probe + 660 658 idev->cnf.rtr_probe_interval)) { 661 659 work = kmalloc(sizeof(*work), GFP_ATOMIC); 662 660 } 663 661 664 - if (work) { 665 - fib6_nh->last_probe = jiffies; 662 + if (!work || cmpxchg(&fib6_nh->last_probe, 663 + last_probe, jiffies) != last_probe) { 664 + kfree(work); 665 + } else { 666 666 INIT_WORK(&work->work, rt6_probe_deferred); 667 667 work->target = *nh_gw; 668 668 dev_hold(dev); ··· 3387 3383 int err; 3388 3384 3389 3385 fib6_nh->fib_nh_family = AF_INET6; 3386 + #ifdef CONFIG_IPV6_ROUTER_PREF 3387 + fib6_nh->last_probe = jiffies; 3388 + #endif 3390 3389 3391 3390 err = -ENODEV; 3392 3391 if (cfg->fc_ifindex) {
+1 -1
net/mac80211/main.c
··· 1292 1292 ieee80211_remove_interfaces(local); 1293 1293 fail_rate: 1294 1294 rtnl_unlock(); 1295 - ieee80211_led_exit(local); 1296 1295 fail_flows: 1296 + ieee80211_led_exit(local); 1297 1297 destroy_workqueue(local->workqueue); 1298 1298 fail_workqueue: 1299 1299 wiphy_unregister(local->hw.wiphy);
+2 -1
net/mac80211/sta_info.c
··· 2457 2457 { 2458 2458 struct ieee80211_sta_rx_stats *stats = sta_get_last_rx_stats(sta); 2459 2459 2460 - if (time_after(stats->last_rx, sta->status_stats.last_ack)) 2460 + if (!sta->status_stats.last_ack || 2461 + time_after(stats->last_rx, sta->status_stats.last_ack)) 2461 2462 return stats->last_rx; 2462 2463 return sta->status_stats.last_ack; 2463 2464 }
+33 -16
net/netfilter/ipset/ip_set_core.c
··· 296 296 297 297 if (unlikely(!flag_nested(nla))) 298 298 return -IPSET_ERR_PROTOCOL; 299 - if (nla_parse_nested_deprecated(tb, IPSET_ATTR_IPADDR_MAX, nla, ipaddr_policy, NULL)) 299 + if (nla_parse_nested(tb, IPSET_ATTR_IPADDR_MAX, nla, 300 + ipaddr_policy, NULL)) 300 301 return -IPSET_ERR_PROTOCOL; 301 302 if (unlikely(!ip_set_attr_netorder(tb, IPSET_ATTR_IPADDR_IPV4))) 302 303 return -IPSET_ERR_PROTOCOL; ··· 315 314 if (unlikely(!flag_nested(nla))) 316 315 return -IPSET_ERR_PROTOCOL; 317 316 318 - if (nla_parse_nested_deprecated(tb, IPSET_ATTR_IPADDR_MAX, nla, ipaddr_policy, NULL)) 317 + if (nla_parse_nested(tb, IPSET_ATTR_IPADDR_MAX, nla, 318 + ipaddr_policy, NULL)) 319 319 return -IPSET_ERR_PROTOCOL; 320 320 if (unlikely(!ip_set_attr_netorder(tb, IPSET_ATTR_IPADDR_IPV6))) 321 321 return -IPSET_ERR_PROTOCOL; ··· 936 934 937 935 /* Without holding any locks, create private part. */ 938 936 if (attr[IPSET_ATTR_DATA] && 939 - nla_parse_nested_deprecated(tb, IPSET_ATTR_CREATE_MAX, attr[IPSET_ATTR_DATA], set->type->create_policy, NULL)) { 937 + nla_parse_nested(tb, IPSET_ATTR_CREATE_MAX, attr[IPSET_ATTR_DATA], 938 + set->type->create_policy, NULL)) { 940 939 ret = -IPSET_ERR_PROTOCOL; 941 940 goto put_out; 942 941 } ··· 1284 1281 } 1285 1282 } 1286 1283 1284 + static const struct nla_policy 1285 + ip_set_dump_policy[IPSET_ATTR_CMD_MAX + 1] = { 1286 + [IPSET_ATTR_PROTOCOL] = { .type = NLA_U8 }, 1287 + [IPSET_ATTR_SETNAME] = { .type = NLA_NUL_STRING, 1288 + .len = IPSET_MAXNAMELEN - 1 }, 1289 + [IPSET_ATTR_FLAGS] = { .type = NLA_U32 }, 1290 + }; 1291 + 1287 1292 static int 1288 1293 dump_init(struct netlink_callback *cb, struct ip_set_net *inst) 1289 1294 { ··· 1303 1292 ip_set_id_t index; 1304 1293 int ret; 1305 1294 1306 - ret = nla_parse_deprecated(cda, IPSET_ATTR_CMD_MAX, attr, 1307 - nlh->nlmsg_len - min_len, 1308 - ip_set_setname_policy, NULL); 1295 + ret = nla_parse(cda, IPSET_ATTR_CMD_MAX, attr, 1296 + nlh->nlmsg_len - min_len, 1297 + ip_set_dump_policy, NULL); 1309 1298 if (ret) 1310 1299 return ret; 1311 1300 ··· 1554 1543 memcpy(&errmsg->msg, nlh, nlh->nlmsg_len); 1555 1544 cmdattr = (void *)&errmsg->msg + min_len; 1556 1545 1557 - ret = nla_parse_deprecated(cda, IPSET_ATTR_CMD_MAX, cmdattr, 1558 - nlh->nlmsg_len - min_len, 1559 - ip_set_adt_policy, NULL); 1546 + ret = nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr, 1547 + nlh->nlmsg_len - min_len, ip_set_adt_policy, 1548 + NULL); 1560 1549 1561 1550 if (ret) { 1562 1551 nlmsg_free(skb2); ··· 1607 1596 1608 1597 use_lineno = !!attr[IPSET_ATTR_LINENO]; 1609 1598 if (attr[IPSET_ATTR_DATA]) { 1610 - if (nla_parse_nested_deprecated(tb, IPSET_ATTR_ADT_MAX, attr[IPSET_ATTR_DATA], set->type->adt_policy, NULL)) 1599 + if (nla_parse_nested(tb, IPSET_ATTR_ADT_MAX, 1600 + attr[IPSET_ATTR_DATA], 1601 + set->type->adt_policy, NULL)) 1611 1602 return -IPSET_ERR_PROTOCOL; 1612 1603 ret = call_ad(ctnl, skb, set, tb, adt, flags, 1613 1604 use_lineno); ··· 1619 1606 nla_for_each_nested(nla, attr[IPSET_ATTR_ADT], nla_rem) { 1620 1607 if (nla_type(nla) != IPSET_ATTR_DATA || 1621 1608 !flag_nested(nla) || 1622 - nla_parse_nested_deprecated(tb, IPSET_ATTR_ADT_MAX, nla, set->type->adt_policy, NULL)) 1609 + nla_parse_nested(tb, IPSET_ATTR_ADT_MAX, nla, 1610 + set->type->adt_policy, NULL)) 1623 1611 return -IPSET_ERR_PROTOCOL; 1624 1612 ret = call_ad(ctnl, skb, set, tb, adt, 1625 1613 flags, use_lineno); ··· 1669 1655 if (!set) 1670 1656 return -ENOENT; 1671 1657 1672 - if (nla_parse_nested_deprecated(tb, IPSET_ATTR_ADT_MAX, attr[IPSET_ATTR_DATA], set->type->adt_policy, NULL)) 1658 + if (nla_parse_nested(tb, IPSET_ATTR_ADT_MAX, attr[IPSET_ATTR_DATA], 1659 + set->type->adt_policy, NULL)) 1673 1660 return -IPSET_ERR_PROTOCOL; 1674 1661 1675 1662 rcu_read_lock_bh(); ··· 1976 1961 [IPSET_CMD_LIST] = { 1977 1962 .call = ip_set_dump, 1978 1963 .attr_count = IPSET_ATTR_CMD_MAX, 1979 - .policy = ip_set_setname_policy, 1964 + .policy = ip_set_dump_policy, 1980 1965 }, 1981 1966 [IPSET_CMD_SAVE] = { 1982 1967 .call = ip_set_dump, ··· 2084 2069 } 2085 2070 2086 2071 req_version->version = IPSET_PROTOCOL; 2087 - ret = copy_to_user(user, req_version, 2088 - sizeof(struct ip_set_req_version)); 2072 + if (copy_to_user(user, req_version, 2073 + sizeof(struct ip_set_req_version))) 2074 + ret = -EFAULT; 2089 2075 goto done; 2090 2076 } 2091 2077 case IP_SET_OP_GET_BYNAME: { ··· 2145 2129 } /* end of switch(op) */ 2146 2130 2147 2131 copy: 2148 - ret = copy_to_user(user, data, copylen); 2132 + if (copy_to_user(user, data, copylen)) 2133 + ret = -EFAULT; 2149 2134 2150 2135 done: 2151 2136 vfree(data);
+1 -1
net/netfilter/ipset/ip_set_hash_ipmac.c
··· 209 209 (skb_mac_header(skb) + ETH_HLEN) > skb->data) 210 210 return -EINVAL; 211 211 212 - if (opt->flags & IPSET_DIM_ONE_SRC) 212 + if (opt->flags & IPSET_DIM_TWO_SRC) 213 213 ether_addr_copy(e.ether, eth_hdr(skb)->h_source); 214 214 else 215 215 ether_addr_copy(e.ether, eth_hdr(skb)->h_dest);
+1
net/netfilter/ipset/ip_set_hash_net.c
··· 368 368 [IPSET_ATTR_IP_TO] = { .type = NLA_NESTED }, 369 369 [IPSET_ATTR_CIDR] = { .type = NLA_U8 }, 370 370 [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 }, 371 + [IPSET_ATTR_LINENO] = { .type = NLA_U32 }, 371 372 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 }, 372 373 [IPSET_ATTR_BYTES] = { .type = NLA_U64 }, 373 374 [IPSET_ATTR_PACKETS] = { .type = NLA_U64 },
+1
net/netfilter/ipset/ip_set_hash_netnet.c
··· 476 476 [IPSET_ATTR_CIDR] = { .type = NLA_U8 }, 477 477 [IPSET_ATTR_CIDR2] = { .type = NLA_U8 }, 478 478 [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 }, 479 + [IPSET_ATTR_LINENO] = { .type = NLA_U32 }, 479 480 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 }, 480 481 [IPSET_ATTR_BYTES] = { .type = NLA_U64 }, 481 482 [IPSET_ATTR_PACKETS] = { .type = NLA_U64 },
+3 -4
net/netfilter/nf_tables_api.c
··· 1922 1922 if (nlh->nlmsg_flags & NLM_F_REPLACE) 1923 1923 return -EOPNOTSUPP; 1924 1924 1925 + flags |= chain->flags & NFT_BASE_CHAIN; 1925 1926 return nf_tables_updchain(&ctx, genmask, policy, flags); 1926 1927 } 1927 1928 ··· 5144 5143 struct nft_trans *trans; 5145 5144 int err; 5146 5145 5147 - if (!obj->ops->update) 5148 - return -EOPNOTSUPP; 5149 - 5150 5146 trans = nft_trans_alloc(ctx, NFT_MSG_NEWOBJ, 5151 5147 sizeof(struct nft_trans_obj)); 5152 5148 if (!trans) ··· 6497 6499 obj = nft_trans_obj(trans); 6498 6500 newobj = nft_trans_obj_newobj(trans); 6499 6501 6500 - obj->ops->update(obj, newobj); 6502 + if (obj->ops->update) 6503 + obj->ops->update(obj, newobj); 6501 6504 6502 6505 kfree(newobj); 6503 6506 }
+2 -1
net/netfilter/nf_tables_offload.c
··· 334 334 335 335 switch (trans->msg_type) { 336 336 case NFT_MSG_NEWCHAIN: 337 - if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD)) 337 + if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD) || 338 + nft_trans_chain_update(trans)) 338 339 continue; 339 340 340 341 policy = nft_trans_chain_policy(trans);
+3 -2
net/netfilter/nft_bitwise.c
··· 134 134 const struct nft_expr *expr) 135 135 { 136 136 const struct nft_bitwise *priv = nft_expr_priv(expr); 137 + struct nft_offload_reg *reg = &ctx->regs[priv->dreg]; 137 138 138 139 if (memcmp(&priv->xor, &zero, sizeof(priv->xor)) || 139 - priv->sreg != priv->dreg) 140 + priv->sreg != priv->dreg || priv->len != reg->len) 140 141 return -EOPNOTSUPP; 141 142 142 - memcpy(&ctx->regs[priv->dreg].mask, &priv->mask, sizeof(priv->mask)); 143 + memcpy(&reg->mask, &priv->mask, sizeof(priv->mask)); 143 144 144 145 return 0; 145 146 }
+1 -1
net/netfilter/nft_cmp.c
··· 116 116 u8 *mask = (u8 *)&flow->match.mask; 117 117 u8 *key = (u8 *)&flow->match.key; 118 118 119 - if (priv->op != NFT_CMP_EQ) 119 + if (priv->op != NFT_CMP_EQ || reg->len != priv->len) 120 120 return -EOPNOTSUPP; 121 121 122 122 memcpy(key + reg->offset, &priv->data, priv->len);
-2
net/nfc/netlink.c
··· 1099 1099 1100 1100 local = nfc_llcp_find_local(dev); 1101 1101 if (!local) { 1102 - nfc_put_device(dev); 1103 1102 rc = -ENODEV; 1104 1103 goto exit; 1105 1104 } ··· 1158 1159 1159 1160 local = nfc_llcp_find_local(dev); 1160 1161 if (!local) { 1161 - nfc_put_device(dev); 1162 1162 rc = -ENODEV; 1163 1163 goto exit; 1164 1164 }
+79 -4
net/sched/cls_api.c
··· 21 21 #include <linux/slab.h> 22 22 #include <linux/idr.h> 23 23 #include <linux/rhashtable.h> 24 + #include <linux/jhash.h> 24 25 #include <net/net_namespace.h> 25 26 #include <net/sock.h> 26 27 #include <net/netlink.h> ··· 47 46 48 47 /* Protects list of registered TC modules. It is pure SMP lock. */ 49 48 static DEFINE_RWLOCK(cls_mod_lock); 49 + 50 + static u32 destroy_obj_hashfn(const struct tcf_proto *tp) 51 + { 52 + return jhash_3words(tp->chain->index, tp->prio, 53 + (__force __u32)tp->protocol, 0); 54 + } 55 + 56 + static void tcf_proto_signal_destroying(struct tcf_chain *chain, 57 + struct tcf_proto *tp) 58 + { 59 + struct tcf_block *block = chain->block; 60 + 61 + mutex_lock(&block->proto_destroy_lock); 62 + hash_add_rcu(block->proto_destroy_ht, &tp->destroy_ht_node, 63 + destroy_obj_hashfn(tp)); 64 + mutex_unlock(&block->proto_destroy_lock); 65 + } 66 + 67 + static bool tcf_proto_cmp(const struct tcf_proto *tp1, 68 + const struct tcf_proto *tp2) 69 + { 70 + return tp1->chain->index == tp2->chain->index && 71 + tp1->prio == tp2->prio && 72 + tp1->protocol == tp2->protocol; 73 + } 74 + 75 + static bool tcf_proto_exists_destroying(struct tcf_chain *chain, 76 + struct tcf_proto *tp) 77 + { 78 + u32 hash = destroy_obj_hashfn(tp); 79 + struct tcf_proto *iter; 80 + bool found = false; 81 + 82 + rcu_read_lock(); 83 + hash_for_each_possible_rcu(chain->block->proto_destroy_ht, iter, 84 + destroy_ht_node, hash) { 85 + if (tcf_proto_cmp(tp, iter)) { 86 + found = true; 87 + break; 88 + } 89 + } 90 + rcu_read_unlock(); 91 + 92 + return found; 93 + } 94 + 95 + static void 96 + tcf_proto_signal_destroyed(struct tcf_chain *chain, struct tcf_proto *tp) 97 + { 98 + struct tcf_block *block = chain->block; 99 + 100 + mutex_lock(&block->proto_destroy_lock); 101 + if (hash_hashed(&tp->destroy_ht_node)) 102 + hash_del_rcu(&tp->destroy_ht_node); 103 + mutex_unlock(&block->proto_destroy_lock); 104 + } 50 105 51 106 /* Find classifier type by string name */ 52 107 ··· 291 234 static void tcf_chain_put(struct tcf_chain *chain); 292 235 293 236 static void tcf_proto_destroy(struct tcf_proto *tp, bool rtnl_held, 294 - struct netlink_ext_ack *extack) 237 + bool sig_destroy, struct netlink_ext_ack *extack) 295 238 { 296 239 tp->ops->destroy(tp, rtnl_held, extack); 240 + if (sig_destroy) 241 + tcf_proto_signal_destroyed(tp->chain, tp); 297 242 tcf_chain_put(tp->chain); 298 243 module_put(tp->ops->owner); 299 244 kfree_rcu(tp, rcu); ··· 305 246 struct netlink_ext_ack *extack) 306 247 { 307 248 if (refcount_dec_and_test(&tp->refcnt)) 308 - tcf_proto_destroy(tp, rtnl_held, extack); 249 + tcf_proto_destroy(tp, rtnl_held, true, extack); 309 250 } 310 251 311 252 static int walker_check_empty(struct tcf_proto *tp, void *fh, ··· 429 370 static void tcf_block_destroy(struct tcf_block *block) 430 371 { 431 372 mutex_destroy(&block->lock); 373 + mutex_destroy(&block->proto_destroy_lock); 432 374 kfree_rcu(block, rcu); 433 375 } 434 376 ··· 604 544 struct tcf_proto *tp, *tp_next; 605 545 606 546 mutex_lock(&chain->filter_chain_lock); 547 + tp = tcf_chain_dereference(chain->filter_chain, chain); 548 + while (tp) { 549 + tp_next = rcu_dereference_protected(tp->next, 1); 550 + tcf_proto_signal_destroying(chain, tp); 551 + tp = tp_next; 552 + } 607 553 tp = tcf_chain_dereference(chain->filter_chain, chain); 608 554 RCU_INIT_POINTER(chain->filter_chain, NULL); 609 555 tcf_chain0_head_change(chain, NULL); ··· 910 844 return ERR_PTR(-ENOMEM); 911 845 } 912 846 mutex_init(&block->lock); 847 + mutex_init(&block->proto_destroy_lock); 913 848 init_rwsem(&block->cb_lock); 914 849 flow_block_init(&block->flow_block); 915 850 INIT_LIST_HEAD(&block->chain_list); ··· 1688 1621 1689 1622 mutex_lock(&chain->filter_chain_lock); 1690 1623 1624 + if (tcf_proto_exists_destroying(chain, tp_new)) { 1625 + mutex_unlock(&chain->filter_chain_lock); 1626 + tcf_proto_destroy(tp_new, rtnl_held, false, NULL); 1627 + return ERR_PTR(-EAGAIN); 1628 + } 1629 + 1691 1630 tp = tcf_chain_tp_find(chain, &chain_info, 1692 1631 protocol, prio, false); 1693 1632 if (!tp) ··· 1701 1628 mutex_unlock(&chain->filter_chain_lock); 1702 1629 1703 1630 if (tp) { 1704 - tcf_proto_destroy(tp_new, rtnl_held, NULL); 1631 + tcf_proto_destroy(tp_new, rtnl_held, false, NULL); 1705 1632 tp_new = tp; 1706 1633 } else if (err) { 1707 - tcf_proto_destroy(tp_new, rtnl_held, NULL); 1634 + tcf_proto_destroy(tp_new, rtnl_held, false, NULL); 1708 1635 tp_new = ERR_PTR(err); 1709 1636 } 1710 1637 ··· 1742 1669 return; 1743 1670 } 1744 1671 1672 + tcf_proto_signal_destroying(chain, tp); 1745 1673 next = tcf_chain_dereference(chain_info.next, chain); 1746 1674 if (tp == chain->filter_chain) 1747 1675 tcf_chain0_head_change(chain, next); ··· 2262 2188 err = -EINVAL; 2263 2189 goto errout_locked; 2264 2190 } else if (t->tcm_handle == 0) { 2191 + tcf_proto_signal_destroying(chain, tp); 2265 2192 tcf_chain_tp_remove(chain, &chain_info, tp); 2266 2193 mutex_unlock(&chain->filter_chain_lock); 2267 2194
+3 -2
net/sched/sch_taprio.c
··· 1224 1224 goto done; 1225 1225 } 1226 1226 1227 - taprio_offload_config_changed(q); 1228 - 1229 1227 done: 1230 1228 taprio_offload_free(offload); 1231 1229 ··· 1503 1505 call_rcu(&admin->rcu, taprio_free_sched_cb); 1504 1506 1505 1507 spin_unlock_irqrestore(&q->current_entry_lock, flags); 1508 + 1509 + if (FULL_OFFLOAD_IS_ENABLED(taprio_flags)) 1510 + taprio_offload_config_changed(q); 1506 1511 } 1507 1512 1508 1513 new_admin = NULL;
-2
net/smc/smc_pnet.c
··· 376 376 return 0; 377 377 378 378 error: 379 - if (pnetelem->ndev) 380 - dev_put(pnetelem->ndev); 381 379 return rc; 382 380 } 383 381
+9 -1
net/tls/tls_device.c
··· 523 523 int tls_device_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) 524 524 { 525 525 unsigned char record_type = TLS_RECORD_TYPE_DATA; 526 + struct tls_context *tls_ctx = tls_get_ctx(sk); 526 527 int rc; 527 528 529 + mutex_lock(&tls_ctx->tx_lock); 528 530 lock_sock(sk); 529 531 530 532 if (unlikely(msg->msg_controllen)) { ··· 540 538 541 539 out: 542 540 release_sock(sk); 541 + mutex_unlock(&tls_ctx->tx_lock); 543 542 return rc; 544 543 } 545 544 546 545 int tls_device_sendpage(struct sock *sk, struct page *page, 547 546 int offset, size_t size, int flags) 548 547 { 548 + struct tls_context *tls_ctx = tls_get_ctx(sk); 549 549 struct iov_iter msg_iter; 550 550 char *kaddr = kmap(page); 551 551 struct kvec iov; ··· 556 552 if (flags & MSG_SENDPAGE_NOTLAST) 557 553 flags |= MSG_MORE; 558 554 555 + mutex_lock(&tls_ctx->tx_lock); 559 556 lock_sock(sk); 560 557 561 558 if (flags & MSG_OOB) { ··· 573 568 574 569 out: 575 570 release_sock(sk); 571 + mutex_unlock(&tls_ctx->tx_lock); 576 572 return rc; 577 573 } 578 574 ··· 629 623 630 624 void tls_device_write_space(struct sock *sk, struct tls_context *ctx) 631 625 { 632 - if (!sk->sk_write_pending && tls_is_partially_sent_record(ctx)) { 626 + if (tls_is_partially_sent_record(ctx)) { 633 627 gfp_t sk_allocation = sk->sk_allocation; 628 + 629 + WARN_ON_ONCE(sk->sk_write_pending); 634 630 635 631 sk->sk_allocation = GFP_ATOMIC; 636 632 tls_push_partial_record(sk, ctx,
+2
net/tls/tls_main.c
··· 267 267 268 268 memzero_explicit(&ctx->crypto_send, sizeof(ctx->crypto_send)); 269 269 memzero_explicit(&ctx->crypto_recv, sizeof(ctx->crypto_recv)); 270 + mutex_destroy(&ctx->tx_lock); 270 271 271 272 if (sk) 272 273 kfree_rcu(ctx, rcu); ··· 613 612 if (!ctx) 614 613 return NULL; 615 614 615 + mutex_init(&ctx->tx_lock); 616 616 rcu_assign_pointer(icsk->icsk_ulp_data, ctx); 617 617 ctx->sk_proto = sk->sk_prot; 618 618 return ctx;
+10 -20
net/tls/tls_sw.c
··· 897 897 if (msg->msg_flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL)) 898 898 return -ENOTSUPP; 899 899 900 + mutex_lock(&tls_ctx->tx_lock); 900 901 lock_sock(sk); 901 - 902 - /* Wait till there is any pending write on socket */ 903 - if (unlikely(sk->sk_write_pending)) { 904 - ret = wait_on_pending_writer(sk, &timeo); 905 - if (unlikely(ret)) 906 - goto send_end; 907 - } 908 902 909 903 if (unlikely(msg->msg_controllen)) { 910 904 ret = tls_proccess_cmsg(sk, msg, &record_type); ··· 1085 1091 ret = sk_stream_error(sk, msg->msg_flags, ret); 1086 1092 1087 1093 release_sock(sk); 1094 + mutex_unlock(&tls_ctx->tx_lock); 1088 1095 return copied ? copied : ret; 1089 1096 } 1090 1097 ··· 1108 1113 1109 1114 eor = !(flags & (MSG_MORE | MSG_SENDPAGE_NOTLAST)); 1110 1115 sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk); 1111 - 1112 - /* Wait till there is any pending write on socket */ 1113 - if (unlikely(sk->sk_write_pending)) { 1114 - ret = wait_on_pending_writer(sk, &timeo); 1115 - if (unlikely(ret)) 1116 - goto sendpage_end; 1117 - } 1118 1116 1119 1117 /* Call the sk_stream functions to manage the sndbuf mem. */ 1120 1118 while (size > 0) { ··· 1207 1219 int tls_sw_sendpage(struct sock *sk, struct page *page, 1208 1220 int offset, size_t size, int flags) 1209 1221 { 1222 + struct tls_context *tls_ctx = tls_get_ctx(sk); 1210 1223 int ret; 1211 1224 1212 1225 if (flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | 1213 1226 MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY)) 1214 1227 return -ENOTSUPP; 1215 1228 1229 + mutex_lock(&tls_ctx->tx_lock); 1216 1230 lock_sock(sk); 1217 1231 ret = tls_sw_do_sendpage(sk, page, offset, size, flags); 1218 1232 release_sock(sk); 1233 + mutex_unlock(&tls_ctx->tx_lock); 1219 1234 return ret; 1220 1235 } 1221 1236 ··· 2161 2170 2162 2171 if (!test_and_clear_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask)) 2163 2172 return; 2173 + mutex_lock(&tls_ctx->tx_lock); 2164 2174 lock_sock(sk); 2165 2175 tls_tx_records(sk, -1); 2166 2176 release_sock(sk); 2177 + mutex_unlock(&tls_ctx->tx_lock); 2167 2178 } 2168 2179 2169 2180 void tls_sw_write_space(struct sock *sk, struct tls_context *ctx) ··· 2173 2180 struct tls_sw_context_tx *tx_ctx = tls_sw_ctx_tx(ctx); 2174 2181 2175 2182 /* Schedule the transmission if tx list is ready */ 2176 - if (is_tx_ready(tx_ctx) && !sk->sk_write_pending) { 2177 - /* Schedule the transmission */ 2178 - if (!test_and_set_bit(BIT_TX_SCHEDULED, 2179 - &tx_ctx->tx_bitmask)) 2180 - schedule_delayed_work(&tx_ctx->tx_work.work, 0); 2181 - } 2183 + if (is_tx_ready(tx_ctx) && 2184 + !test_and_set_bit(BIT_TX_SCHEDULED, &tx_ctx->tx_bitmask)) 2185 + schedule_delayed_work(&tx_ctx->tx_work.work, 0); 2182 2186 } 2183 2187 2184 2188 void tls_sw_strparser_arm(struct sock *sk, struct tls_context *tls_ctx)
+5 -3
net/vmw_vsock/virtio_transport_common.c
··· 947 947 if (le32_to_cpu(pkt->hdr.flags) & VIRTIO_VSOCK_SHUTDOWN_SEND) 948 948 vsk->peer_shutdown |= SEND_SHUTDOWN; 949 949 if (vsk->peer_shutdown == SHUTDOWN_MASK && 950 - vsock_stream_has_data(vsk) <= 0) { 951 - sock_set_flag(sk, SOCK_DONE); 952 - sk->sk_state = TCP_CLOSING; 950 + vsock_stream_has_data(vsk) <= 0 && 951 + !sock_flag(sk, SOCK_DONE)) { 952 + (void)virtio_transport_reset(vsk, NULL); 953 + 954 + virtio_transport_do_close(vsk, true); 953 955 } 954 956 if (le32_to_cpu(pkt->hdr.flags)) 955 957 sk->sk_state_change(sk);
+1
samples/bpf/Makefile
··· 176 176 KBUILD_HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/ 177 177 KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include 178 178 KBUILD_HOSTCFLAGS += -I$(srctree)/tools/perf 179 + KBUILD_HOSTCFLAGS += -DHAVE_ATTR_TEST=0 179 180 180 181 HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable 181 182
+4 -2
tools/perf/perf-sys.h
··· 15 15 void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, 16 16 int fd, int group_fd, unsigned long flags); 17 17 18 - #define HAVE_ATTR_TEST 18 + #ifndef HAVE_ATTR_TEST 19 + #define HAVE_ATTR_TEST 1 20 + #endif 19 21 20 22 static inline int 21 23 sys_perf_event_open(struct perf_event_attr *attr, ··· 29 27 fd = syscall(__NR_perf_event_open, attr, pid, cpu, 30 28 group_fd, flags); 31 29 32 - #ifdef HAVE_ATTR_TEST 30 + #if HAVE_ATTR_TEST 33 31 if (unlikely(test_attr__enabled)) 34 32 test_attr__open(attr, pid, cpu, fd, group_fd, flags); 35 33 #endif
+7 -1
tools/testing/selftests/bpf/test_sysctl.c
··· 161 161 .descr = "ctx:file_pos sysctl:read read ok narrow", 162 162 .insns = { 163 163 /* If (file_pos == X) */ 164 + #if __BYTE_ORDER == __LITTLE_ENDIAN 164 165 BPF_LDX_MEM(BPF_B, BPF_REG_7, BPF_REG_1, 165 166 offsetof(struct bpf_sysctl, file_pos)), 166 - BPF_JMP_IMM(BPF_JNE, BPF_REG_7, 0, 2), 167 + #else 168 + BPF_LDX_MEM(BPF_B, BPF_REG_7, BPF_REG_1, 169 + offsetof(struct bpf_sysctl, file_pos) + 3), 170 + #endif 171 + BPF_JMP_IMM(BPF_JNE, BPF_REG_7, 4, 2), 167 172 168 173 /* return ALLOW; */ 169 174 BPF_MOV64_IMM(BPF_REG_0, 1), ··· 181 176 .attach_type = BPF_CGROUP_SYSCTL, 182 177 .sysctl = "kernel/ostype", 183 178 .open_flags = O_RDONLY, 179 + .seek = 4, 184 180 .result = SUCCESS, 185 181 }, 186 182 {
+108
tools/testing/selftests/net/tls.c
··· 898 898 } 899 899 } 900 900 901 + static void 902 + test_mutliproc(struct __test_metadata *_metadata, struct _test_data_tls *self, 903 + bool sendpg, unsigned int n_readers, unsigned int n_writers) 904 + { 905 + const unsigned int n_children = n_readers + n_writers; 906 + const size_t data = 6 * 1000 * 1000; 907 + const size_t file_sz = data / 100; 908 + size_t read_bias, write_bias; 909 + int i, fd, child_id; 910 + char buf[file_sz]; 911 + pid_t pid; 912 + 913 + /* Only allow multiples for simplicity */ 914 + ASSERT_EQ(!(n_readers % n_writers) || !(n_writers % n_readers), true); 915 + read_bias = n_writers / n_readers ?: 1; 916 + write_bias = n_readers / n_writers ?: 1; 917 + 918 + /* prep a file to send */ 919 + fd = open("/tmp/", O_TMPFILE | O_RDWR, 0600); 920 + ASSERT_GE(fd, 0); 921 + 922 + memset(buf, 0xac, file_sz); 923 + ASSERT_EQ(write(fd, buf, file_sz), file_sz); 924 + 925 + /* spawn children */ 926 + for (child_id = 0; child_id < n_children; child_id++) { 927 + pid = fork(); 928 + ASSERT_NE(pid, -1); 929 + if (!pid) 930 + break; 931 + } 932 + 933 + /* parent waits for all children */ 934 + if (pid) { 935 + for (i = 0; i < n_children; i++) { 936 + int status; 937 + 938 + wait(&status); 939 + EXPECT_EQ(status, 0); 940 + } 941 + 942 + return; 943 + } 944 + 945 + /* Split threads for reading and writing */ 946 + if (child_id < n_readers) { 947 + size_t left = data * read_bias; 948 + char rb[8001]; 949 + 950 + while (left) { 951 + int res; 952 + 953 + res = recv(self->cfd, rb, 954 + left > sizeof(rb) ? sizeof(rb) : left, 0); 955 + 956 + EXPECT_GE(res, 0); 957 + left -= res; 958 + } 959 + } else { 960 + size_t left = data * write_bias; 961 + 962 + while (left) { 963 + int res; 964 + 965 + ASSERT_EQ(lseek(fd, 0, SEEK_SET), 0); 966 + if (sendpg) 967 + res = sendfile(self->fd, fd, NULL, 968 + left > file_sz ? file_sz : left); 969 + else 970 + res = send(self->fd, buf, 971 + left > file_sz ? file_sz : left, 0); 972 + 973 + EXPECT_GE(res, 0); 974 + left -= res; 975 + } 976 + } 977 + } 978 + 979 + TEST_F(tls, mutliproc_even) 980 + { 981 + test_mutliproc(_metadata, self, false, 6, 6); 982 + } 983 + 984 + TEST_F(tls, mutliproc_readers) 985 + { 986 + test_mutliproc(_metadata, self, false, 4, 12); 987 + } 988 + 989 + TEST_F(tls, mutliproc_writers) 990 + { 991 + test_mutliproc(_metadata, self, false, 10, 2); 992 + } 993 + 994 + TEST_F(tls, mutliproc_sendpage_even) 995 + { 996 + test_mutliproc(_metadata, self, true, 6, 6); 997 + } 998 + 999 + TEST_F(tls, mutliproc_sendpage_readers) 1000 + { 1001 + test_mutliproc(_metadata, self, true, 4, 12); 1002 + } 1003 + 1004 + TEST_F(tls, mutliproc_sendpage_writers) 1005 + { 1006 + test_mutliproc(_metadata, self, true, 10, 2); 1007 + } 1008 + 901 1009 TEST_F(tls, control_msg) 902 1010 { 903 1011 if (self->notls)