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 tag 'net-6.15-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Pull networking fixes from Paolo Abeni:
"This is somewhat larger than what I hoped for, with a few PRs from
subsystems and follow-ups for the recent netdev locking changes,
anyhow there are no known pending regressions.

Including fixes from bluetooth, ipsec and CAN.

Current release - regressions:

- eth: team: grab team lock during team_change_rx_flags

- eth: bnxt_en: fix netdev locking in ULP IRQ functions

Current release - new code bugs:

- xfrm: ipcomp: fix truesize computation on receive

- eth: airoha: fix page recycling in airoha_qdma_rx_process()

Previous releases - regressions:

- sched: hfsc: fix qlen accounting bug when using peek in
hfsc_enqueue()

- mr: consolidate the ipmr_can_free_table() checks.

- bridge: netfilter: fix forwarding of fragmented packets

- xsk: bring back busy polling support in XDP_COPY

- can:
- add missing rcu read protection for procfs content
- kvaser_pciefd: force IRQ edge in case of nested IRQ

Previous releases - always broken:

- xfrm: espintcp: remove encap socket caching to avoid reference leak

- bluetooth: use skb_pull to avoid unsafe access in QCA dump handling

- eth: idpf:
- fix null-ptr-deref in idpf_features_check
- fix idpf_vport_splitq_napi_poll()

- eth: hibmcge: fix wrong ndo.open() after reset fail issue"

* tag 'net-6.15-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (40 commits)
octeontx2-af: Fix APR entry mapping based on APR_LMT_CFG
octeontx2-af: Set LMT_ENA bit for APR table entries
net/tipc: fix slab-use-after-free Read in tipc_aead_encrypt_done
octeontx2-pf: Avoid adding dcbnl_ops for LBK and SDP vf
selftests/tc-testing: Add an HFSC qlen accounting test
sch_hfsc: Fix qlen accounting bug when using peek in hfsc_enqueue()
idpf: fix idpf_vport_splitq_napi_poll()
net: hibmcge: fix wrong ndo.open() after reset fail issue.
net: hibmcge: fix incorrect statistics update issue
xsk: Bring back busy polling support in XDP_COPY
can: slcan: allow reception of short error messages
net: lan743x: Restore SGMII CTRL register on resume
bnxt_en: Fix netdev locking in ULP IRQ functions
MAINTAINERS: Drop myself to reviewer for ravb driver
net: dwmac-sun8i: Use parsed internal PHY address instead of 1
net: ethernet: ti: am65-cpsw: Lower random mac address error print to info
can: kvaser_pciefd: Continue parsing DMA buf after dropped RX
can: kvaser_pciefd: Fix echo_skb race
can: kvaser_pciefd: Force IRQ edge in case of nested IRQ
idpf: fix null-ptr-deref in idpf_features_check
...

+453 -408
+1 -1
Documentation/devicetree/bindings/net/can/microchip,mcp2510.yaml
··· 1 1 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 2 %YAML 1.2 3 3 --- 4 - $id: http://devicetree.org/schemas/can/microchip,mcp2510.yaml# 4 + $id: http://devicetree.org/schemas/net/can/microchip,mcp2510.yaml# 5 5 $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: Microchip MCP251X stand-alone CAN controller
+1 -1
MAINTAINERS
··· 20613 20613 F: drivers/i2c/busses/i2c-emev2.c 20614 20614 20615 20615 RENESAS ETHERNET AVB DRIVER 20616 - M: Paul Barker <paul.barker.ct@bp.renesas.com> 20617 20616 M: Niklas Söderlund <niklas.soderlund@ragnatech.se> 20617 + R: Paul Barker <paul@pbarker.dev> 20618 20618 L: netdev@vger.kernel.org 20619 20619 L: linux-renesas-soc@vger.kernel.org 20620 20620 S: Maintained
+40 -58
drivers/bluetooth/btusb.c
··· 3014 3014 static int handle_dump_pkt_qca(struct hci_dev *hdev, struct sk_buff *skb) 3015 3015 { 3016 3016 int ret = 0; 3017 + unsigned int skip = 0; 3017 3018 u8 pkt_type; 3018 - u8 *sk_ptr; 3019 - unsigned int sk_len; 3020 3019 u16 seqno; 3021 3020 u32 dump_size; 3022 3021 ··· 3024 3025 struct usb_device *udev = btdata->udev; 3025 3026 3026 3027 pkt_type = hci_skb_pkt_type(skb); 3027 - sk_ptr = skb->data; 3028 - sk_len = skb->len; 3028 + skip = sizeof(struct hci_event_hdr); 3029 + if (pkt_type == HCI_ACLDATA_PKT) 3030 + skip += sizeof(struct hci_acl_hdr); 3029 3031 3030 - if (pkt_type == HCI_ACLDATA_PKT) { 3031 - sk_ptr += HCI_ACL_HDR_SIZE; 3032 - sk_len -= HCI_ACL_HDR_SIZE; 3033 - } 3032 + skb_pull(skb, skip); 3033 + dump_hdr = (struct qca_dump_hdr *)skb->data; 3034 3034 3035 - sk_ptr += HCI_EVENT_HDR_SIZE; 3036 - sk_len -= HCI_EVENT_HDR_SIZE; 3037 - 3038 - dump_hdr = (struct qca_dump_hdr *)sk_ptr; 3039 3035 seqno = le16_to_cpu(dump_hdr->seqno); 3040 3036 if (seqno == 0) { 3041 3037 set_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags); ··· 3050 3056 3051 3057 btdata->qca_dump.ram_dump_size = dump_size; 3052 3058 btdata->qca_dump.ram_dump_seqno = 0; 3053 - sk_ptr += offsetof(struct qca_dump_hdr, data0); 3054 - sk_len -= offsetof(struct qca_dump_hdr, data0); 3059 + 3060 + skb_pull(skb, offsetof(struct qca_dump_hdr, data0)); 3055 3061 3056 3062 usb_disable_autosuspend(udev); 3057 3063 bt_dev_info(hdev, "%s memdump size(%u)\n", 3058 3064 (pkt_type == HCI_ACLDATA_PKT) ? "ACL" : "event", 3059 3065 dump_size); 3060 3066 } else { 3061 - sk_ptr += offsetof(struct qca_dump_hdr, data); 3062 - sk_len -= offsetof(struct qca_dump_hdr, data); 3067 + skb_pull(skb, offsetof(struct qca_dump_hdr, data)); 3063 3068 } 3064 3069 3065 3070 if (!btdata->qca_dump.ram_dump_size) { ··· 3078 3085 return ret; 3079 3086 } 3080 3087 3081 - skb_pull(skb, skb->len - sk_len); 3082 3088 hci_devcd_append(hdev, skb); 3083 3089 btdata->qca_dump.ram_dump_seqno++; 3084 3090 if (seqno == QCA_LAST_SEQUENCE_NUM) { ··· 3105 3113 /* Return: true if the ACL packet is a dump packet, false otherwise. */ 3106 3114 static bool acl_pkt_is_dump_qca(struct hci_dev *hdev, struct sk_buff *skb) 3107 3115 { 3108 - u8 *sk_ptr; 3109 - unsigned int sk_len; 3110 - 3111 3116 struct hci_event_hdr *event_hdr; 3112 3117 struct hci_acl_hdr *acl_hdr; 3113 3118 struct qca_dump_hdr *dump_hdr; 3119 + struct sk_buff *clone = skb_clone(skb, GFP_ATOMIC); 3120 + bool is_dump = false; 3114 3121 3115 - sk_ptr = skb->data; 3116 - sk_len = skb->len; 3117 - 3118 - acl_hdr = hci_acl_hdr(skb); 3119 - if (le16_to_cpu(acl_hdr->handle) != QCA_MEMDUMP_ACL_HANDLE) 3122 + if (!clone) 3120 3123 return false; 3121 3124 3122 - sk_ptr += HCI_ACL_HDR_SIZE; 3123 - sk_len -= HCI_ACL_HDR_SIZE; 3124 - event_hdr = (struct hci_event_hdr *)sk_ptr; 3125 + acl_hdr = skb_pull_data(clone, sizeof(*acl_hdr)); 3126 + if (!acl_hdr || (le16_to_cpu(acl_hdr->handle) != QCA_MEMDUMP_ACL_HANDLE)) 3127 + goto out; 3125 3128 3126 - if ((event_hdr->evt != HCI_VENDOR_PKT) || 3127 - (event_hdr->plen != (sk_len - HCI_EVENT_HDR_SIZE))) 3128 - return false; 3129 + event_hdr = skb_pull_data(clone, sizeof(*event_hdr)); 3130 + if (!event_hdr || (event_hdr->evt != HCI_VENDOR_PKT)) 3131 + goto out; 3129 3132 3130 - sk_ptr += HCI_EVENT_HDR_SIZE; 3131 - sk_len -= HCI_EVENT_HDR_SIZE; 3133 + dump_hdr = skb_pull_data(clone, sizeof(*dump_hdr)); 3134 + if (!dump_hdr || (dump_hdr->vse_class != QCA_MEMDUMP_VSE_CLASS) || 3135 + (dump_hdr->msg_type != QCA_MEMDUMP_MSG_TYPE)) 3136 + goto out; 3132 3137 3133 - dump_hdr = (struct qca_dump_hdr *)sk_ptr; 3134 - if ((sk_len < offsetof(struct qca_dump_hdr, data)) || 3135 - (dump_hdr->vse_class != QCA_MEMDUMP_VSE_CLASS) || 3136 - (dump_hdr->msg_type != QCA_MEMDUMP_MSG_TYPE)) 3137 - return false; 3138 - 3139 - return true; 3138 + is_dump = true; 3139 + out: 3140 + consume_skb(clone); 3141 + return is_dump; 3140 3142 } 3141 3143 3142 3144 /* Return: true if the event packet is a dump packet, false otherwise. */ 3143 3145 static bool evt_pkt_is_dump_qca(struct hci_dev *hdev, struct sk_buff *skb) 3144 3146 { 3145 - u8 *sk_ptr; 3146 - unsigned int sk_len; 3147 - 3148 3147 struct hci_event_hdr *event_hdr; 3149 3148 struct qca_dump_hdr *dump_hdr; 3149 + struct sk_buff *clone = skb_clone(skb, GFP_ATOMIC); 3150 + bool is_dump = false; 3150 3151 3151 - sk_ptr = skb->data; 3152 - sk_len = skb->len; 3153 - 3154 - event_hdr = hci_event_hdr(skb); 3155 - 3156 - if ((event_hdr->evt != HCI_VENDOR_PKT) 3157 - || (event_hdr->plen != (sk_len - HCI_EVENT_HDR_SIZE))) 3152 + if (!clone) 3158 3153 return false; 3159 3154 3160 - sk_ptr += HCI_EVENT_HDR_SIZE; 3161 - sk_len -= HCI_EVENT_HDR_SIZE; 3155 + event_hdr = skb_pull_data(clone, sizeof(*event_hdr)); 3156 + if (!event_hdr || (event_hdr->evt != HCI_VENDOR_PKT)) 3157 + goto out; 3162 3158 3163 - dump_hdr = (struct qca_dump_hdr *)sk_ptr; 3164 - if ((sk_len < offsetof(struct qca_dump_hdr, data)) || 3165 - (dump_hdr->vse_class != QCA_MEMDUMP_VSE_CLASS) || 3166 - (dump_hdr->msg_type != QCA_MEMDUMP_MSG_TYPE)) 3167 - return false; 3159 + dump_hdr = skb_pull_data(clone, sizeof(*dump_hdr)); 3160 + if (!dump_hdr || (dump_hdr->vse_class != QCA_MEMDUMP_VSE_CLASS) || 3161 + (dump_hdr->msg_type != QCA_MEMDUMP_MSG_TYPE)) 3162 + goto out; 3168 3163 3169 - return true; 3164 + is_dump = true; 3165 + out: 3166 + consume_skb(clone); 3167 + return is_dump; 3170 3168 } 3171 3169 3172 3170 static int btusb_recv_acl_qca(struct hci_dev *hdev, struct sk_buff *skb)
+103 -81
drivers/net/can/kvaser_pciefd.c
··· 16 16 #include <linux/netdevice.h> 17 17 #include <linux/pci.h> 18 18 #include <linux/timer.h> 19 + #include <net/netdev_queues.h> 19 20 20 21 MODULE_LICENSE("Dual BSD/GPL"); 21 22 MODULE_AUTHOR("Kvaser AB <support@kvaser.com>"); ··· 411 410 void __iomem *reg_base; 412 411 struct can_berr_counter bec; 413 412 u8 cmd_seq; 413 + u8 tx_max_count; 414 + u8 tx_idx; 415 + u8 ack_idx; 414 416 int err_rep_cnt; 415 - int echo_idx; 417 + unsigned int completed_tx_pkts; 418 + unsigned int completed_tx_bytes; 416 419 spinlock_t lock; /* Locks sensitive registers (e.g. MODE) */ 417 - spinlock_t echo_lock; /* Locks the message echo buffer */ 418 420 struct timer_list bec_poll_timer; 419 421 struct completion start_comp, flush_comp; 420 422 }; ··· 718 714 int ret; 719 715 struct kvaser_pciefd_can *can = netdev_priv(netdev); 720 716 717 + can->tx_idx = 0; 718 + can->ack_idx = 0; 719 + 721 720 ret = open_candev(netdev); 722 721 if (ret) 723 722 return ret; ··· 752 745 timer_delete(&can->bec_poll_timer); 753 746 } 754 747 can->can.state = CAN_STATE_STOPPED; 748 + netdev_reset_queue(netdev); 755 749 close_candev(netdev); 756 750 757 751 return ret; 758 752 } 759 753 754 + static unsigned int kvaser_pciefd_tx_avail(const struct kvaser_pciefd_can *can) 755 + { 756 + return can->tx_max_count - (READ_ONCE(can->tx_idx) - READ_ONCE(can->ack_idx)); 757 + } 758 + 760 759 static int kvaser_pciefd_prepare_tx_packet(struct kvaser_pciefd_tx_packet *p, 761 - struct kvaser_pciefd_can *can, 760 + struct can_priv *can, u8 seq, 762 761 struct sk_buff *skb) 763 762 { 764 763 struct canfd_frame *cf = (struct canfd_frame *)skb->data; 765 764 int packet_size; 766 - int seq = can->echo_idx; 767 765 768 766 memset(p, 0, sizeof(*p)); 769 - if (can->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT) 767 + if (can->ctrlmode & CAN_CTRLMODE_ONE_SHOT) 770 768 p->header[1] |= KVASER_PCIEFD_TPACKET_SMS; 771 769 772 770 if (cf->can_id & CAN_RTR_FLAG) ··· 794 782 } else { 795 783 p->header[1] |= 796 784 FIELD_PREP(KVASER_PCIEFD_RPACKET_DLC_MASK, 797 - can_get_cc_dlc((struct can_frame *)cf, can->can.ctrlmode)); 785 + can_get_cc_dlc((struct can_frame *)cf, can->ctrlmode)); 798 786 } 799 787 800 788 p->header[1] |= FIELD_PREP(KVASER_PCIEFD_PACKET_SEQ_MASK, seq); ··· 809 797 struct net_device *netdev) 810 798 { 811 799 struct kvaser_pciefd_can *can = netdev_priv(netdev); 812 - unsigned long irq_flags; 813 800 struct kvaser_pciefd_tx_packet packet; 801 + unsigned int seq = can->tx_idx & (can->can.echo_skb_max - 1); 802 + unsigned int frame_len; 814 803 int nr_words; 815 - u8 count; 816 804 817 805 if (can_dev_dropped_skb(netdev, skb)) 818 806 return NETDEV_TX_OK; 807 + if (!netif_subqueue_maybe_stop(netdev, 0, kvaser_pciefd_tx_avail(can), 1, 1)) 808 + return NETDEV_TX_BUSY; 819 809 820 - nr_words = kvaser_pciefd_prepare_tx_packet(&packet, can, skb); 810 + nr_words = kvaser_pciefd_prepare_tx_packet(&packet, &can->can, seq, skb); 821 811 822 - spin_lock_irqsave(&can->echo_lock, irq_flags); 823 812 /* Prepare and save echo skb in internal slot */ 824 - can_put_echo_skb(skb, netdev, can->echo_idx, 0); 825 - 826 - /* Move echo index to the next slot */ 827 - can->echo_idx = (can->echo_idx + 1) % can->can.echo_skb_max; 813 + WRITE_ONCE(can->can.echo_skb[seq], NULL); 814 + frame_len = can_skb_get_frame_len(skb); 815 + can_put_echo_skb(skb, netdev, seq, frame_len); 816 + netdev_sent_queue(netdev, frame_len); 817 + WRITE_ONCE(can->tx_idx, can->tx_idx + 1); 828 818 829 819 /* Write header to fifo */ 830 820 iowrite32(packet.header[0], ··· 850 836 KVASER_PCIEFD_KCAN_FIFO_LAST_REG); 851 837 } 852 838 853 - count = FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_CURRENT_MASK, 854 - ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG)); 855 - /* No room for a new message, stop the queue until at least one 856 - * successful transmit 857 - */ 858 - if (count >= can->can.echo_skb_max || can->can.echo_skb[can->echo_idx]) 859 - netif_stop_queue(netdev); 860 - spin_unlock_irqrestore(&can->echo_lock, irq_flags); 839 + netif_subqueue_maybe_stop(netdev, 0, kvaser_pciefd_tx_avail(can), 1, 1); 861 840 862 841 return NETDEV_TX_OK; 863 842 } ··· 977 970 can->kv_pcie = pcie; 978 971 can->cmd_seq = 0; 979 972 can->err_rep_cnt = 0; 973 + can->completed_tx_pkts = 0; 974 + can->completed_tx_bytes = 0; 980 975 can->bec.txerr = 0; 981 976 can->bec.rxerr = 0; 982 977 ··· 992 983 tx_nr_packets_max = 993 984 FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_MAX_MASK, 994 985 ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG)); 986 + can->tx_max_count = min(KVASER_PCIEFD_CAN_TX_MAX_COUNT, tx_nr_packets_max - 1); 995 987 996 988 can->can.clock.freq = pcie->freq; 997 - can->can.echo_skb_max = min(KVASER_PCIEFD_CAN_TX_MAX_COUNT, tx_nr_packets_max - 1); 998 - can->echo_idx = 0; 999 - spin_lock_init(&can->echo_lock); 989 + can->can.echo_skb_max = roundup_pow_of_two(can->tx_max_count); 1000 990 spin_lock_init(&can->lock); 1001 991 1002 992 can->can.bittiming_const = &kvaser_pciefd_bittiming_const; ··· 1209 1201 skb = alloc_canfd_skb(priv->dev, &cf); 1210 1202 if (!skb) { 1211 1203 priv->dev->stats.rx_dropped++; 1212 - return -ENOMEM; 1204 + return 0; 1213 1205 } 1214 1206 1215 1207 cf->len = can_fd_dlc2len(dlc); ··· 1221 1213 skb = alloc_can_skb(priv->dev, (struct can_frame **)&cf); 1222 1214 if (!skb) { 1223 1215 priv->dev->stats.rx_dropped++; 1224 - return -ENOMEM; 1216 + return 0; 1225 1217 } 1226 1218 can_frame_set_cc_len((struct can_frame *)cf, dlc, priv->ctrlmode); 1227 1219 } ··· 1239 1231 priv->dev->stats.rx_packets++; 1240 1232 kvaser_pciefd_set_skb_timestamp(pcie, skb, p->timestamp); 1241 1233 1242 - return netif_rx(skb); 1234 + netif_rx(skb); 1235 + 1236 + return 0; 1243 1237 } 1244 1238 1245 1239 static void kvaser_pciefd_change_state(struct kvaser_pciefd_can *can, ··· 1520 1510 netdev_dbg(can->can.dev, "Packet was flushed\n"); 1521 1511 } else { 1522 1512 int echo_idx = FIELD_GET(KVASER_PCIEFD_PACKET_SEQ_MASK, p->header[0]); 1523 - int len; 1524 - u8 count; 1513 + unsigned int len, frame_len = 0; 1525 1514 struct sk_buff *skb; 1526 1515 1516 + if (echo_idx != (can->ack_idx & (can->can.echo_skb_max - 1))) 1517 + return 0; 1527 1518 skb = can->can.echo_skb[echo_idx]; 1528 - if (skb) 1529 - kvaser_pciefd_set_skb_timestamp(pcie, skb, p->timestamp); 1530 - len = can_get_echo_skb(can->can.dev, echo_idx, NULL); 1531 - count = FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_CURRENT_MASK, 1532 - ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG)); 1519 + if (!skb) 1520 + return 0; 1521 + kvaser_pciefd_set_skb_timestamp(pcie, skb, p->timestamp); 1522 + len = can_get_echo_skb(can->can.dev, echo_idx, &frame_len); 1533 1523 1534 - if (count < can->can.echo_skb_max && netif_queue_stopped(can->can.dev)) 1535 - netif_wake_queue(can->can.dev); 1524 + /* Pairs with barrier in kvaser_pciefd_start_xmit() */ 1525 + smp_store_release(&can->ack_idx, can->ack_idx + 1); 1526 + can->completed_tx_pkts++; 1527 + can->completed_tx_bytes += frame_len; 1536 1528 1537 1529 if (!one_shot_fail) { 1538 1530 can->can.dev->stats.tx_bytes += len; ··· 1650 1638 { 1651 1639 int pos = 0; 1652 1640 int res = 0; 1641 + unsigned int i; 1653 1642 1654 1643 do { 1655 1644 res = kvaser_pciefd_read_packet(pcie, &pos, dma_buf); 1656 1645 } while (!res && pos > 0 && pos < KVASER_PCIEFD_DMA_SIZE); 1657 1646 1647 + /* Report ACKs in this buffer to BQL en masse for correct periods */ 1648 + for (i = 0; i < pcie->nr_channels; ++i) { 1649 + struct kvaser_pciefd_can *can = pcie->can[i]; 1650 + 1651 + if (!can->completed_tx_pkts) 1652 + continue; 1653 + netif_subqueue_completed_wake(can->can.dev, 0, 1654 + can->completed_tx_pkts, 1655 + can->completed_tx_bytes, 1656 + kvaser_pciefd_tx_avail(can), 1); 1657 + can->completed_tx_pkts = 0; 1658 + can->completed_tx_bytes = 0; 1659 + } 1660 + 1658 1661 return res; 1659 1662 } 1660 1663 1661 - static u32 kvaser_pciefd_receive_irq(struct kvaser_pciefd *pcie) 1664 + static void kvaser_pciefd_receive_irq(struct kvaser_pciefd *pcie) 1662 1665 { 1666 + void __iomem *srb_cmd_reg = KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_CMD_REG; 1663 1667 u32 irq = ioread32(KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_IRQ_REG); 1664 1668 1665 - if (irq & KVASER_PCIEFD_SRB_IRQ_DPD0) 1666 - kvaser_pciefd_read_buffer(pcie, 0); 1669 + iowrite32(irq, KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_IRQ_REG); 1667 1670 1668 - if (irq & KVASER_PCIEFD_SRB_IRQ_DPD1) 1671 + if (irq & KVASER_PCIEFD_SRB_IRQ_DPD0) { 1672 + kvaser_pciefd_read_buffer(pcie, 0); 1673 + iowrite32(KVASER_PCIEFD_SRB_CMD_RDB0, srb_cmd_reg); /* Rearm buffer */ 1674 + } 1675 + 1676 + if (irq & KVASER_PCIEFD_SRB_IRQ_DPD1) { 1669 1677 kvaser_pciefd_read_buffer(pcie, 1); 1678 + iowrite32(KVASER_PCIEFD_SRB_CMD_RDB1, srb_cmd_reg); /* Rearm buffer */ 1679 + } 1670 1680 1671 1681 if (unlikely(irq & KVASER_PCIEFD_SRB_IRQ_DOF0 || 1672 1682 irq & KVASER_PCIEFD_SRB_IRQ_DOF1 || 1673 1683 irq & KVASER_PCIEFD_SRB_IRQ_DUF0 || 1674 1684 irq & KVASER_PCIEFD_SRB_IRQ_DUF1)) 1675 1685 dev_err(&pcie->pci->dev, "DMA IRQ error 0x%08X\n", irq); 1676 - 1677 - iowrite32(irq, KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_IRQ_REG); 1678 - return irq; 1679 1686 } 1680 1687 1681 1688 static void kvaser_pciefd_transmit_irq(struct kvaser_pciefd_can *can) ··· 1722 1691 struct kvaser_pciefd *pcie = (struct kvaser_pciefd *)dev; 1723 1692 const struct kvaser_pciefd_irq_mask *irq_mask = pcie->driver_data->irq_mask; 1724 1693 u32 pci_irq = ioread32(KVASER_PCIEFD_PCI_IRQ_ADDR(pcie)); 1725 - u32 srb_irq = 0; 1726 - u32 srb_release = 0; 1727 1694 int i; 1728 1695 1729 1696 if (!(pci_irq & irq_mask->all)) 1730 1697 return IRQ_NONE; 1731 1698 1699 + iowrite32(0, KVASER_PCIEFD_PCI_IEN_ADDR(pcie)); 1700 + 1732 1701 if (pci_irq & irq_mask->kcan_rx0) 1733 - srb_irq = kvaser_pciefd_receive_irq(pcie); 1702 + kvaser_pciefd_receive_irq(pcie); 1734 1703 1735 1704 for (i = 0; i < pcie->nr_channels; i++) { 1736 1705 if (pci_irq & irq_mask->kcan_tx[i]) 1737 1706 kvaser_pciefd_transmit_irq(pcie->can[i]); 1738 1707 } 1739 1708 1740 - if (srb_irq & KVASER_PCIEFD_SRB_IRQ_DPD0) 1741 - srb_release |= KVASER_PCIEFD_SRB_CMD_RDB0; 1742 - 1743 - if (srb_irq & KVASER_PCIEFD_SRB_IRQ_DPD1) 1744 - srb_release |= KVASER_PCIEFD_SRB_CMD_RDB1; 1745 - 1746 - if (srb_release) 1747 - iowrite32(srb_release, KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_CMD_REG); 1709 + iowrite32(irq_mask->all, KVASER_PCIEFD_PCI_IEN_ADDR(pcie)); 1748 1710 1749 1711 return IRQ_HANDLED; 1750 1712 } ··· 1757 1733 } 1758 1734 } 1759 1735 1736 + static void kvaser_pciefd_disable_irq_srcs(struct kvaser_pciefd *pcie) 1737 + { 1738 + unsigned int i; 1739 + 1740 + /* Masking PCI_IRQ is insufficient as running ISR will unmask it */ 1741 + iowrite32(0, KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_IEN_REG); 1742 + for (i = 0; i < pcie->nr_channels; ++i) 1743 + iowrite32(0, pcie->can[i]->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); 1744 + } 1745 + 1760 1746 static int kvaser_pciefd_probe(struct pci_dev *pdev, 1761 1747 const struct pci_device_id *id) 1762 1748 { 1763 1749 int ret; 1764 1750 struct kvaser_pciefd *pcie; 1765 1751 const struct kvaser_pciefd_irq_mask *irq_mask; 1766 - void __iomem *irq_en_base; 1767 1752 1768 1753 pcie = devm_kzalloc(&pdev->dev, sizeof(*pcie), GFP_KERNEL); 1769 1754 if (!pcie) ··· 1838 1805 KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_IEN_REG); 1839 1806 1840 1807 /* Enable PCI interrupts */ 1841 - irq_en_base = KVASER_PCIEFD_PCI_IEN_ADDR(pcie); 1842 - iowrite32(irq_mask->all, irq_en_base); 1808 + iowrite32(irq_mask->all, KVASER_PCIEFD_PCI_IEN_ADDR(pcie)); 1843 1809 /* Ready the DMA buffers */ 1844 1810 iowrite32(KVASER_PCIEFD_SRB_CMD_RDB0, 1845 1811 KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_CMD_REG); ··· 1852 1820 return 0; 1853 1821 1854 1822 err_free_irq: 1855 - /* Disable PCI interrupts */ 1856 - iowrite32(0, irq_en_base); 1823 + kvaser_pciefd_disable_irq_srcs(pcie); 1857 1824 free_irq(pcie->pci->irq, pcie); 1858 1825 1859 1826 err_pci_free_irq_vectors: ··· 1875 1844 return ret; 1876 1845 } 1877 1846 1878 - static void kvaser_pciefd_remove_all_ctrls(struct kvaser_pciefd *pcie) 1879 - { 1880 - int i; 1881 - 1882 - for (i = 0; i < pcie->nr_channels; i++) { 1883 - struct kvaser_pciefd_can *can = pcie->can[i]; 1884 - 1885 - if (can) { 1886 - iowrite32(0, can->reg_base + KVASER_PCIEFD_KCAN_IEN_REG); 1887 - unregister_candev(can->can.dev); 1888 - timer_delete(&can->bec_poll_timer); 1889 - kvaser_pciefd_pwm_stop(can); 1890 - free_candev(can->can.dev); 1891 - } 1892 - } 1893 - } 1894 - 1895 1847 static void kvaser_pciefd_remove(struct pci_dev *pdev) 1896 1848 { 1897 1849 struct kvaser_pciefd *pcie = pci_get_drvdata(pdev); 1850 + unsigned int i; 1898 1851 1899 - kvaser_pciefd_remove_all_ctrls(pcie); 1852 + for (i = 0; i < pcie->nr_channels; ++i) { 1853 + struct kvaser_pciefd_can *can = pcie->can[i]; 1900 1854 1901 - /* Disable interrupts */ 1902 - iowrite32(0, KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_CTRL_REG); 1903 - iowrite32(0, KVASER_PCIEFD_PCI_IEN_ADDR(pcie)); 1855 + unregister_candev(can->can.dev); 1856 + timer_delete(&can->bec_poll_timer); 1857 + kvaser_pciefd_pwm_stop(can); 1858 + } 1904 1859 1860 + kvaser_pciefd_disable_irq_srcs(pcie); 1905 1861 free_irq(pcie->pci->irq, pcie); 1906 1862 pci_free_irq_vectors(pcie->pci); 1863 + 1864 + for (i = 0; i < pcie->nr_channels; ++i) 1865 + free_candev(pcie->can[i]->can.dev); 1866 + 1907 1867 pci_iounmap(pdev, pcie->reg_base); 1908 1868 pci_release_regions(pdev); 1909 1869 pci_disable_device(pdev);
+20 -6
drivers/net/can/slcan/slcan-core.c
··· 71 71 #define SLCAN_CMD_LEN 1 72 72 #define SLCAN_SFF_ID_LEN 3 73 73 #define SLCAN_EFF_ID_LEN 8 74 + #define SLCAN_DATA_LENGTH_LEN 1 75 + #define SLCAN_ERROR_LEN 1 74 76 #define SLCAN_STATE_LEN 1 75 77 #define SLCAN_STATE_BE_RXCNT_LEN 3 76 78 #define SLCAN_STATE_BE_TXCNT_LEN 3 77 - #define SLCAN_STATE_FRAME_LEN (1 + SLCAN_CMD_LEN + \ 78 - SLCAN_STATE_BE_RXCNT_LEN + \ 79 - SLCAN_STATE_BE_TXCNT_LEN) 79 + #define SLCAN_STATE_MSG_LEN (SLCAN_CMD_LEN + \ 80 + SLCAN_STATE_LEN + \ 81 + SLCAN_STATE_BE_RXCNT_LEN + \ 82 + SLCAN_STATE_BE_TXCNT_LEN) 83 + #define SLCAN_ERROR_MSG_LEN_MIN (SLCAN_CMD_LEN + \ 84 + SLCAN_ERROR_LEN + \ 85 + SLCAN_DATA_LENGTH_LEN) 86 + #define SLCAN_FRAME_MSG_LEN_MIN (SLCAN_CMD_LEN + \ 87 + SLCAN_SFF_ID_LEN + \ 88 + SLCAN_DATA_LENGTH_LEN) 80 89 struct slcan { 81 90 struct can_priv can; 82 91 ··· 184 175 int i, tmp; 185 176 u32 tmpid; 186 177 char *cmd = sl->rbuff; 178 + 179 + if (sl->rcount < SLCAN_FRAME_MSG_LEN_MIN) 180 + return; 187 181 188 182 skb = alloc_can_skb(sl->dev, &cf); 189 183 if (unlikely(!skb)) { ··· 293 281 return; 294 282 } 295 283 296 - if (state == sl->can.state || sl->rcount < SLCAN_STATE_FRAME_LEN) 284 + if (state == sl->can.state || sl->rcount != SLCAN_STATE_MSG_LEN) 297 285 return; 298 286 299 287 cmd += SLCAN_STATE_BE_RXCNT_LEN + SLCAN_CMD_LEN + 1; ··· 339 327 char *cmd = sl->rbuff; 340 328 bool rx_errors = false, tx_errors = false, rx_over_errors = false; 341 329 int i, len; 330 + 331 + if (sl->rcount < SLCAN_ERROR_MSG_LEN_MIN) 332 + return; 342 333 343 334 /* get len from sanitized ASCII value */ 344 335 len = cmd[1]; ··· 471 456 static void slcan_unesc(struct slcan *sl, unsigned char s) 472 457 { 473 458 if ((s == '\r') || (s == '\a')) { /* CR or BEL ends the pdu */ 474 - if (!test_and_clear_bit(SLF_ERROR, &sl->flags) && 475 - sl->rcount > 4) 459 + if (!test_and_clear_bit(SLF_ERROR, &sl->flags)) 476 460 slcan_bump(sl); 477 461 478 462 sl->rcount = 0;
+9 -13
drivers/net/ethernet/airoha/airoha_eth.c
··· 614 614 struct airoha_queue_entry *e = &q->entry[q->tail]; 615 615 struct airoha_qdma_desc *desc = &q->desc[q->tail]; 616 616 u32 hash, reason, msg1 = le32_to_cpu(desc->msg1); 617 - dma_addr_t dma_addr = le32_to_cpu(desc->addr); 618 617 struct page *page = virt_to_head_page(e->buf); 619 618 u32 desc_ctrl = le32_to_cpu(desc->ctrl); 620 619 struct airoha_gdm_port *port; ··· 622 623 if (!(desc_ctrl & QDMA_DESC_DONE_MASK)) 623 624 break; 624 625 625 - if (!dma_addr) 626 - break; 627 - 628 - len = FIELD_GET(QDMA_DESC_LEN_MASK, desc_ctrl); 629 - if (!len) 630 - break; 631 - 632 626 q->tail = (q->tail + 1) % q->ndesc; 633 627 q->queued--; 634 628 635 - dma_sync_single_for_cpu(eth->dev, dma_addr, 629 + dma_sync_single_for_cpu(eth->dev, e->dma_addr, 636 630 SKB_WITH_OVERHEAD(q->buf_size), dir); 637 631 632 + len = FIELD_GET(QDMA_DESC_LEN_MASK, desc_ctrl); 638 633 data_len = q->skb ? q->buf_size 639 634 : SKB_WITH_OVERHEAD(q->buf_size); 640 - if (data_len < len) 635 + if (!len || data_len < len) 641 636 goto free_frag; 642 637 643 638 p = airoha_qdma_get_gdm_port(eth, desc); ··· 694 701 q->skb = NULL; 695 702 continue; 696 703 free_frag: 697 - page_pool_put_full_page(q->page_pool, page, true); 698 - dev_kfree_skb(q->skb); 699 - q->skb = NULL; 704 + if (q->skb) { 705 + dev_kfree_skb(q->skb); 706 + q->skb = NULL; 707 + } else { 708 + page_pool_put_full_page(q->page_pool, page, true); 709 + } 700 710 } 701 711 airoha_qdma_fill_rx_queue(q); 702 712
+3 -6
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
··· 20 20 #include <asm/byteorder.h> 21 21 #include <linux/bitmap.h> 22 22 #include <linux/auxiliary_bus.h> 23 + #include <net/netdev_lock.h> 23 24 24 25 #include "bnxt_hsi.h" 25 26 #include "bnxt.h" ··· 310 309 if (!ulp->msix_requested) 311 310 return; 312 311 313 - netdev_lock(bp->dev); 314 - ops = rcu_dereference(ulp->ulp_ops); 312 + ops = netdev_lock_dereference(ulp->ulp_ops, bp->dev); 315 313 if (!ops || !ops->ulp_irq_stop) 316 314 return; 317 315 if (test_bit(BNXT_STATE_FW_RESET_DET, &bp->state)) 318 316 reset = true; 319 317 ops->ulp_irq_stop(ulp->handle, reset); 320 - netdev_unlock(bp->dev); 321 318 } 322 319 } 323 320 ··· 334 335 if (!ulp->msix_requested) 335 336 return; 336 337 337 - netdev_lock(bp->dev); 338 - ops = rcu_dereference(ulp->ulp_ops); 338 + ops = netdev_lock_dereference(ulp->ulp_ops, bp->dev); 339 339 if (!ops || !ops->ulp_irq_restart) 340 340 return; 341 341 ··· 346 348 bnxt_fill_msix_vecs(bp, ent); 347 349 } 348 350 ops->ulp_irq_restart(ulp->handle, ent); 349 - netdev_unlock(bp->dev); 350 351 kfree(ent); 351 352 } 352 353 }
+8 -8
drivers/net/ethernet/hisilicon/hibmcge/hbg_err.c
··· 61 61 return -EBUSY; 62 62 } 63 63 64 + netif_device_detach(priv->netdev); 65 + 64 66 priv->reset_type = type; 65 67 set_bit(HBG_NIC_STATE_RESETTING, &priv->state); 66 68 clear_bit(HBG_NIC_STATE_RESET_FAIL, &priv->state); ··· 93 91 return ret; 94 92 } 95 93 94 + netif_device_attach(priv->netdev); 95 + 96 96 dev_info(&priv->pdev->dev, "reset done\n"); 97 97 return ret; 98 98 } ··· 121 117 if (running) 122 118 dev_close(priv->netdev); 123 119 124 - hbg_reset(priv); 125 - 126 - /* in hbg_pci_err_detected(), we will detach first, 127 - * so we need to attach before open 128 - */ 129 - if (!netif_device_present(priv->netdev)) 130 - netif_device_attach(priv->netdev); 120 + if (hbg_reset(priv)) 121 + goto err_unlock; 131 122 132 123 if (running) 133 124 dev_open(priv->netdev, NULL); 125 + 126 + err_unlock: 134 127 rtnl_unlock(); 135 128 } 136 129 ··· 161 160 pci_save_state(pdev); 162 161 163 162 hbg_err_reset(priv); 164 - netif_device_attach(netdev); 165 163 return PCI_ERS_RESULT_RECOVERED; 166 164 } 167 165
+3
drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.c
··· 317 317 const struct hbg_ethtool_stats *stats; 318 318 u32 i; 319 319 320 + if (test_bit(HBG_NIC_STATE_RESETTING, &priv->state)) 321 + return; 322 + 320 323 for (i = 0; i < info_len; i++) { 321 324 stats = &info[i]; 322 325 if (!stats->reg)
+6
drivers/net/ethernet/intel/ice/ice_lag.c
··· 1321 1321 */ 1322 1322 if (!primary_lag) { 1323 1323 lag->primary = true; 1324 + if (!ice_is_switchdev_running(lag->pf)) 1325 + return; 1326 + 1324 1327 /* Configure primary's SWID to be shared */ 1325 1328 ice_lag_primary_swid(lag, true); 1326 1329 primary_lag = lag; 1327 1330 } else { 1328 1331 u16 swid; 1332 + 1333 + if (!ice_is_switchdev_running(primary_lag->pf)) 1334 + return; 1329 1335 1330 1336 swid = primary_lag->pf->hw.port_info->sw_id; 1331 1337 ice_lag_set_swid(swid, lag, true);
-1
drivers/net/ethernet/intel/ice/ice_virtchnl.c
··· 4275 4275 } 4276 4276 4277 4277 ice_vfhw_mac_add(vf, &al->list[i]); 4278 - vf->num_mac++; 4279 4278 break; 4280 4279 } 4281 4280
+2
drivers/net/ethernet/intel/idpf/idpf.h
··· 143 143 * @vport_id: Vport identifier 144 144 * @link_speed_mbps: Link speed in mbps 145 145 * @vport_idx: Relative vport index 146 + * @max_tx_hdr_size: Max header length hardware can support 146 147 * @state: See enum idpf_vport_state 147 148 * @netstats: Packet and byte stats 148 149 * @stats_lock: Lock to protect stats update ··· 154 153 u32 vport_id; 155 154 u32 link_speed_mbps; 156 155 u16 vport_idx; 156 + u16 max_tx_hdr_size; 157 157 enum idpf_vport_state state; 158 158 struct rtnl_link_stats64 netstats; 159 159 spinlock_t stats_lock;
+6 -4
drivers/net/ethernet/intel/idpf/idpf_lib.c
··· 723 723 np->vport = vport; 724 724 np->vport_idx = vport->idx; 725 725 np->vport_id = vport->vport_id; 726 + np->max_tx_hdr_size = idpf_get_max_tx_hdr_size(adapter); 726 727 vport->netdev = netdev; 727 728 728 729 return idpf_init_mac_addr(vport, netdev); ··· 741 740 np->adapter = adapter; 742 741 np->vport_idx = vport->idx; 743 742 np->vport_id = vport->vport_id; 743 + np->max_tx_hdr_size = idpf_get_max_tx_hdr_size(adapter); 744 744 745 745 spin_lock_init(&np->stats_lock); 746 746 ··· 2205 2203 struct net_device *netdev, 2206 2204 netdev_features_t features) 2207 2205 { 2208 - struct idpf_vport *vport = idpf_netdev_to_vport(netdev); 2209 - struct idpf_adapter *adapter = vport->adapter; 2206 + struct idpf_netdev_priv *np = netdev_priv(netdev); 2207 + u16 max_tx_hdr_size = np->max_tx_hdr_size; 2210 2208 size_t len; 2211 2209 2212 2210 /* No point in doing any of this if neither checksum nor GSO are ··· 2229 2227 goto unsupported; 2230 2228 2231 2229 len = skb_network_header_len(skb); 2232 - if (unlikely(len > idpf_get_max_tx_hdr_size(adapter))) 2230 + if (unlikely(len > max_tx_hdr_size)) 2233 2231 goto unsupported; 2234 2232 2235 2233 if (!skb->encapsulation) ··· 2242 2240 2243 2241 /* IPLEN can support at most 127 dwords */ 2244 2242 len = skb_inner_network_header_len(skb); 2245 - if (unlikely(len > idpf_get_max_tx_hdr_size(adapter))) 2243 + if (unlikely(len > max_tx_hdr_size)) 2246 2244 goto unsupported; 2247 2245 2248 2246 /* No need to validate L4LEN as TCP is the only protocol with a
+9 -9
drivers/net/ethernet/intel/idpf/idpf_txrx.c
··· 4025 4025 return budget; 4026 4026 } 4027 4027 4028 + /* Switch to poll mode in the tear-down path after sending disable 4029 + * queues virtchnl message, as the interrupts will be disabled after 4030 + * that. 4031 + */ 4032 + if (unlikely(q_vector->num_txq && idpf_queue_has(POLL_MODE, 4033 + q_vector->tx[0]))) 4034 + return budget; 4035 + 4028 4036 work_done = min_t(int, work_done, budget - 1); 4029 4037 4030 4038 /* Exit the polling mode, but don't re-enable interrupts if stack might ··· 4043 4035 else 4044 4036 idpf_vport_intr_set_wb_on_itr(q_vector); 4045 4037 4046 - /* Switch to poll mode in the tear-down path after sending disable 4047 - * queues virtchnl message, as the interrupts will be disabled after 4048 - * that 4049 - */ 4050 - if (unlikely(q_vector->num_txq && idpf_queue_has(POLL_MODE, 4051 - q_vector->tx[0]))) 4052 - return budget; 4053 - else 4054 - return work_done; 4038 + return work_done; 4055 4039 } 4056 4040 4057 4041 /**
+19 -5
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c
··· 13 13 /* RVU LMTST */ 14 14 #define LMT_TBL_OP_READ 0 15 15 #define LMT_TBL_OP_WRITE 1 16 - #define LMT_MAP_TABLE_SIZE (128 * 1024) 17 16 #define LMT_MAPTBL_ENTRY_SIZE 16 17 + #define LMT_MAX_VFS 256 18 + 19 + #define LMT_MAP_ENTRY_ENA BIT_ULL(20) 20 + #define LMT_MAP_ENTRY_LINES GENMASK_ULL(18, 16) 18 21 19 22 /* Function to perform operations (read/write) on lmtst map table */ 20 23 static int lmtst_map_table_ops(struct rvu *rvu, u32 index, u64 *val, 21 24 int lmt_tbl_op) 22 25 { 23 26 void __iomem *lmt_map_base; 24 - u64 tbl_base; 27 + u64 tbl_base, cfg; 28 + int pfs, vfs; 25 29 26 30 tbl_base = rvu_read64(rvu, BLKADDR_APR, APR_AF_LMT_MAP_BASE); 31 + cfg = rvu_read64(rvu, BLKADDR_APR, APR_AF_LMT_CFG); 32 + vfs = 1 << (cfg & 0xF); 33 + pfs = 1 << ((cfg >> 4) & 0x7); 27 34 28 - lmt_map_base = ioremap_wc(tbl_base, LMT_MAP_TABLE_SIZE); 35 + lmt_map_base = ioremap_wc(tbl_base, pfs * vfs * LMT_MAPTBL_ENTRY_SIZE); 29 36 if (!lmt_map_base) { 30 37 dev_err(rvu->dev, "Failed to setup lmt map table mapping!!\n"); 31 38 return -ENOMEM; ··· 42 35 *val = readq(lmt_map_base + index); 43 36 } else { 44 37 writeq((*val), (lmt_map_base + index)); 38 + 39 + cfg = FIELD_PREP(LMT_MAP_ENTRY_ENA, 0x1); 40 + /* 2048 LMTLINES */ 41 + cfg |= FIELD_PREP(LMT_MAP_ENTRY_LINES, 0x6); 42 + 43 + writeq(cfg, (lmt_map_base + (index + 8))); 44 + 45 45 /* Flushing the AP interceptor cache to make APR_LMT_MAP_ENTRY_S 46 46 * changes effective. Write 1 for flush and read is being used as a 47 47 * barrier and sets up a data dependency. Write to 0 after a write ··· 66 52 #define LMT_MAP_TBL_W1_OFF 8 67 53 static u32 rvu_get_lmtst_tbl_index(struct rvu *rvu, u16 pcifunc) 68 54 { 69 - return ((rvu_get_pf(pcifunc) * rvu->hw->total_vfs) + 55 + return ((rvu_get_pf(pcifunc) * LMT_MAX_VFS) + 70 56 (pcifunc & RVU_PFVF_FUNC_MASK)) * LMT_MAPTBL_ENTRY_SIZE; 71 57 } 72 58 ··· 83 69 84 70 mutex_lock(&rvu->rsrc_lock); 85 71 rvu_write64(rvu, BLKADDR_RVUM, RVU_AF_SMMU_ADDR_REQ, iova); 86 - pf = rvu_get_pf(pcifunc) & 0x1F; 72 + pf = rvu_get_pf(pcifunc) & RVU_PFVF_PF_MASK; 87 73 val = BIT_ULL(63) | BIT_ULL(14) | BIT_ULL(13) | pf << 8 | 88 74 ((pcifunc & RVU_PFVF_FUNC_MASK) & 0xFF); 89 75 rvu_write64(rvu, BLKADDR_RVUM, RVU_AF_SMMU_TXN_REQ, val);
+8 -3
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
··· 553 553 u64 lmt_addr, val, tbl_base; 554 554 int pf, vf, num_vfs, hw_vfs; 555 555 void __iomem *lmt_map_base; 556 + int apr_pfs, apr_vfs; 556 557 int buf_size = 10240; 557 558 size_t off = 0; 558 559 int index = 0; ··· 569 568 return -ENOMEM; 570 569 571 570 tbl_base = rvu_read64(rvu, BLKADDR_APR, APR_AF_LMT_MAP_BASE); 571 + val = rvu_read64(rvu, BLKADDR_APR, APR_AF_LMT_CFG); 572 + apr_vfs = 1 << (val & 0xF); 573 + apr_pfs = 1 << ((val >> 4) & 0x7); 572 574 573 - lmt_map_base = ioremap_wc(tbl_base, 128 * 1024); 575 + lmt_map_base = ioremap_wc(tbl_base, apr_pfs * apr_vfs * 576 + LMT_MAPTBL_ENTRY_SIZE); 574 577 if (!lmt_map_base) { 575 578 dev_err(rvu->dev, "Failed to setup lmt map table mapping!!\n"); 576 579 kfree(buf); ··· 596 591 off += scnprintf(&buf[off], buf_size - 1 - off, "PF%d \t\t\t", 597 592 pf); 598 593 599 - index = pf * rvu->hw->total_vfs * LMT_MAPTBL_ENTRY_SIZE; 594 + index = pf * apr_vfs * LMT_MAPTBL_ENTRY_SIZE; 600 595 off += scnprintf(&buf[off], buf_size - 1 - off, " 0x%llx\t\t", 601 596 (tbl_base + index)); 602 597 lmt_addr = readq(lmt_map_base + index); ··· 609 604 /* Reading num of VFs per PF */ 610 605 rvu_get_pf_numvfs(rvu, pf, &num_vfs, &hw_vfs); 611 606 for (vf = 0; vf < num_vfs; vf++) { 612 - index = (pf * rvu->hw->total_vfs * 16) + 607 + index = (pf * apr_vfs * LMT_MAPTBL_ENTRY_SIZE) + 613 608 ((vf + 1) * LMT_MAPTBL_ENTRY_SIZE); 614 609 off += scnprintf(&buf[off], buf_size - 1 - off, 615 610 "PF%d:VF%d \t\t", pf, vf);
+6 -3
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
··· 729 729 } 730 730 731 731 #ifdef CONFIG_DCB 732 - err = otx2_dcbnl_set_ops(netdev); 733 - if (err) 734 - goto err_free_zc_bmap; 732 + /* Priority flow control is not supported for LBK and SDP vf(s) */ 733 + if (!(is_otx2_lbkvf(vf->pdev) || is_otx2_sdp_rep(vf->pdev))) { 734 + err = otx2_dcbnl_set_ops(netdev); 735 + if (err) 736 + goto err_free_zc_bmap; 737 + } 735 738 #endif 736 739 otx2_qos_init(vf, qos_txqs); 737 740
+10 -9
drivers/net/ethernet/microchip/lan743x_main.c
··· 3495 3495 struct pci_dev *pdev) 3496 3496 { 3497 3497 struct lan743x_tx *tx; 3498 + u32 sgmii_ctl; 3498 3499 int index; 3499 3500 int ret; 3500 3501 ··· 3508 3507 spin_lock_init(&adapter->eth_syslock_spinlock); 3509 3508 mutex_init(&adapter->sgmii_rw_lock); 3510 3509 pci11x1x_set_rfe_rd_fifo_threshold(adapter); 3510 + sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL); 3511 + if (adapter->is_sgmii_en) { 3512 + sgmii_ctl |= SGMII_CTL_SGMII_ENABLE_; 3513 + sgmii_ctl &= ~SGMII_CTL_SGMII_POWER_DN_; 3514 + } else { 3515 + sgmii_ctl &= ~SGMII_CTL_SGMII_ENABLE_; 3516 + sgmii_ctl |= SGMII_CTL_SGMII_POWER_DN_; 3517 + } 3518 + lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl); 3511 3519 } else { 3512 3520 adapter->max_tx_channels = LAN743X_MAX_TX_CHANNELS; 3513 3521 adapter->used_tx_channels = LAN743X_USED_TX_CHANNELS; ··· 3568 3558 3569 3559 static int lan743x_mdiobus_init(struct lan743x_adapter *adapter) 3570 3560 { 3571 - u32 sgmii_ctl; 3572 3561 int ret; 3573 3562 3574 3563 adapter->mdiobus = devm_mdiobus_alloc(&adapter->pdev->dev); ··· 3579 3570 adapter->mdiobus->priv = (void *)adapter; 3580 3571 if (adapter->is_pci11x1x) { 3581 3572 if (adapter->is_sgmii_en) { 3582 - sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL); 3583 - sgmii_ctl |= SGMII_CTL_SGMII_ENABLE_; 3584 - sgmii_ctl &= ~SGMII_CTL_SGMII_POWER_DN_; 3585 - lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl); 3586 3573 netif_dbg(adapter, drv, adapter->netdev, 3587 3574 "SGMII operation\n"); 3588 3575 adapter->mdiobus->read = lan743x_mdiobus_read_c22; ··· 3589 3584 netif_dbg(adapter, drv, adapter->netdev, 3590 3585 "lan743x-mdiobus-c45\n"); 3591 3586 } else { 3592 - sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL); 3593 - sgmii_ctl &= ~SGMII_CTL_SGMII_ENABLE_; 3594 - sgmii_ctl |= SGMII_CTL_SGMII_POWER_DN_; 3595 - lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl); 3596 3587 netif_dbg(adapter, drv, adapter->netdev, 3597 3588 "RGMII operation\n"); 3598 3589 // Only C22 support when RGMII I/F
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
··· 964 964 /* of_mdio_parse_addr returns a valid (0 ~ 31) PHY 965 965 * address. No need to mask it again. 966 966 */ 967 - reg |= 1 << H3_EPHY_ADDR_SHIFT; 967 + reg |= ret << H3_EPHY_ADDR_SHIFT; 968 968 } else { 969 969 /* For SoCs without internal PHY the PHY selection bit should be 970 970 * set to 0 (external PHY).
+1 -1
drivers/net/ethernet/ti/am65-cpsw-nuss.c
··· 2685 2685 port->slave.mac_addr); 2686 2686 if (!is_valid_ether_addr(port->slave.mac_addr)) { 2687 2687 eth_random_addr(port->slave.mac_addr); 2688 - dev_err(dev, "Use random MAC address\n"); 2688 + dev_info(dev, "Use random MAC address\n"); 2689 2689 } 2690 2690 } 2691 2691
+3 -3
drivers/net/team/team_core.c
··· 1778 1778 struct team_port *port; 1779 1779 int inc; 1780 1780 1781 - rcu_read_lock(); 1782 - list_for_each_entry_rcu(port, &team->port_list, list) { 1781 + mutex_lock(&team->lock); 1782 + list_for_each_entry(port, &team->port_list, list) { 1783 1783 if (change & IFF_PROMISC) { 1784 1784 inc = dev->flags & IFF_PROMISC ? 1 : -1; 1785 1785 dev_set_promiscuity(port->dev, inc); ··· 1789 1789 dev_set_allmulti(port->dev, inc); 1790 1790 } 1791 1791 } 1792 - rcu_read_unlock(); 1792 + mutex_unlock(&team->lock); 1793 1793 } 1794 1794 1795 1795 static void team_set_rx_mode(struct net_device *dev)
+3 -2
drivers/net/vmxnet3/vmxnet3_drv.c
··· 3607 3607 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 3608 3608 int err = 0; 3609 3609 3610 - WRITE_ONCE(netdev->mtu, new_mtu); 3611 - 3612 3610 /* 3613 3611 * Reset_work may be in the middle of resetting the device, wait for its 3614 3612 * completion. ··· 3620 3622 3621 3623 /* we need to re-create the rx queue based on the new mtu */ 3622 3624 vmxnet3_rq_destroy_all(adapter); 3625 + WRITE_ONCE(netdev->mtu, new_mtu); 3623 3626 vmxnet3_adjust_rx_ring_size(adapter); 3624 3627 err = vmxnet3_rq_create_all(adapter); 3625 3628 if (err) { ··· 3637 3638 "Closing it\n", err); 3638 3639 goto out; 3639 3640 } 3641 + } else { 3642 + WRITE_ONCE(netdev->mtu, new_mtu); 3640 3643 } 3641 3644 3642 3645 out:
+17 -7
drivers/ptp/ptp_ocp.c
··· 315 315 #define OCP_BOARD_ID_LEN 13 316 316 #define OCP_SERIAL_LEN 6 317 317 #define OCP_SMA_NUM 4 318 + #define OCP_SIGNAL_NUM 4 319 + #define OCP_FREQ_NUM 4 318 320 319 321 enum { 320 322 PORT_GNSS, ··· 344 342 struct dcf_master_reg __iomem *dcf_out; 345 343 struct dcf_slave_reg __iomem *dcf_in; 346 344 struct tod_reg __iomem *nmea_out; 347 - struct frequency_reg __iomem *freq_in[4]; 348 - struct ptp_ocp_ext_src *signal_out[4]; 345 + struct frequency_reg __iomem *freq_in[OCP_FREQ_NUM]; 346 + struct ptp_ocp_ext_src *signal_out[OCP_SIGNAL_NUM]; 349 347 struct ptp_ocp_ext_src *pps; 350 348 struct ptp_ocp_ext_src *ts0; 351 349 struct ptp_ocp_ext_src *ts1; ··· 380 378 u32 utc_tai_offset; 381 379 u32 ts_window_adjust; 382 380 u64 fw_cap; 383 - struct ptp_ocp_signal signal[4]; 381 + struct ptp_ocp_signal signal[OCP_SIGNAL_NUM]; 384 382 struct ptp_ocp_sma_connector sma[OCP_SMA_NUM]; 385 383 const struct ocp_sma_op *sma_op; 386 384 struct dpll_device *dpll; 385 + int signals_nr; 386 + int freq_in_nr; 387 387 }; 388 388 389 389 #define OCP_REQ_TIMESTAMP BIT(0) ··· 2701 2697 bp->eeprom_map = fb_eeprom_map; 2702 2698 bp->fw_version = ioread32(&bp->image->version); 2703 2699 bp->sma_op = &ocp_fb_sma_op; 2700 + bp->signals_nr = 4; 2701 + bp->freq_in_nr = 4; 2704 2702 2705 2703 ptp_ocp_fb_set_version(bp); 2706 2704 ··· 2868 2862 bp->fw_version = ioread32(&bp->reg->version); 2869 2863 bp->fw_tag = 2; 2870 2864 bp->sma_op = &ocp_art_sma_op; 2865 + bp->signals_nr = 4; 2866 + bp->freq_in_nr = 4; 2871 2867 2872 2868 /* Enable MAC serial port during initialisation */ 2873 2869 iowrite32(1, &bp->board_config->mro50_serial_activate); ··· 2896 2888 bp->flash_start = 0xA00000; 2897 2889 bp->eeprom_map = fb_eeprom_map; 2898 2890 bp->sma_op = &ocp_adva_sma_op; 2891 + bp->signals_nr = 2; 2892 + bp->freq_in_nr = 2; 2899 2893 2900 2894 version = ioread32(&bp->image->version); 2901 2895 /* if lower 16 bits are empty, this is the fw loader. */ ··· 4018 4008 { 4019 4009 struct signal_reg __iomem *reg = bp->signal_out[nr]->mem; 4020 4010 struct ptp_ocp_signal *signal = &bp->signal[nr]; 4021 - char label[8]; 4011 + char label[16]; 4022 4012 bool on; 4023 4013 u32 val; 4024 4014 ··· 4041 4031 _frequency_summary_show(struct seq_file *s, int nr, 4042 4032 struct frequency_reg __iomem *reg) 4043 4033 { 4044 - char label[8]; 4034 + char label[16]; 4045 4035 bool on; 4046 4036 u32 val; 4047 4037 ··· 4185 4175 } 4186 4176 4187 4177 if (bp->fw_cap & OCP_CAP_SIGNAL) 4188 - for (i = 0; i < 4; i++) 4178 + for (i = 0; i < bp->signals_nr; i++) 4189 4179 _signal_summary_show(s, bp, i); 4190 4180 4191 4181 if (bp->fw_cap & OCP_CAP_FREQ) 4192 - for (i = 0; i < 4; i++) 4182 + for (i = 0; i < bp->freq_in_nr; i++) 4193 4183 _frequency_summary_show(s, i, bp->freq_in[i]); 4194 4184 4195 4185 if (bp->irig_out) {
+5
include/linux/mroute_base.h
··· 262 262 int mroute_reg_vif_num; 263 263 }; 264 264 265 + static inline bool mr_can_free_table(struct net *net) 266 + { 267 + return !check_net(net) || !net_initialized(net); 268 + } 269 + 265 270 #ifdef CONFIG_IP_MROUTE_COMMON 266 271 void vif_device_init(struct vif_device *v, 267 272 struct net_device *dev,
+3
include/net/netdev_lock.h
··· 98 98 &qdisc_xmit_lock_key); \ 99 99 } 100 100 101 + #define netdev_lock_dereference(p, dev) \ 102 + rcu_dereference_protected(p, lockdep_is_held(&(dev)->lock)) 103 + 101 104 int netdev_debug_event(struct notifier_block *nb, unsigned long event, 102 105 void *ptr); 103 106
-1
include/net/xfrm.h
··· 236 236 237 237 /* Data for encapsulator */ 238 238 struct xfrm_encap_tmpl *encap; 239 - struct sock __rcu *encap_sk; 240 239 241 240 /* NAT keepalive */ 242 241 u32 nat_keepalive_interval; /* seconds */
+8 -7
net/bluetooth/l2cap_core.c
··· 1411 1411 sizeof(req), &req); 1412 1412 } 1413 1413 1414 - static bool l2cap_check_enc_key_size(struct hci_conn *hcon) 1414 + static bool l2cap_check_enc_key_size(struct hci_conn *hcon, 1415 + struct l2cap_chan *chan) 1415 1416 { 1416 1417 /* The minimum encryption key size needs to be enforced by the 1417 1418 * host stack before establishing any L2CAP connections. The ··· 1426 1425 int min_key_size = hcon->hdev->min_enc_key_size; 1427 1426 1428 1427 /* On FIPS security level, key size must be 16 bytes */ 1429 - if (hcon->sec_level == BT_SECURITY_FIPS) 1428 + if (chan->sec_level == BT_SECURITY_FIPS) 1430 1429 min_key_size = 16; 1431 1430 1432 1431 return (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags) || ··· 1454 1453 !__l2cap_no_conn_pending(chan)) 1455 1454 return; 1456 1455 1457 - if (l2cap_check_enc_key_size(conn->hcon)) 1456 + if (l2cap_check_enc_key_size(conn->hcon, chan)) 1458 1457 l2cap_start_connection(chan); 1459 1458 else 1460 1459 __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); ··· 1529 1528 continue; 1530 1529 } 1531 1530 1532 - if (l2cap_check_enc_key_size(conn->hcon)) 1531 + if (l2cap_check_enc_key_size(conn->hcon, chan)) 1533 1532 l2cap_start_connection(chan); 1534 1533 else 1535 1534 l2cap_chan_close(chan, ECONNREFUSED); ··· 3993 3992 /* Check if the ACL is secure enough (if not SDP) */ 3994 3993 if (psm != cpu_to_le16(L2CAP_PSM_SDP) && 3995 3994 (!hci_conn_check_link_mode(conn->hcon) || 3996 - !l2cap_check_enc_key_size(conn->hcon))) { 3995 + !l2cap_check_enc_key_size(conn->hcon, pchan))) { 3997 3996 conn->disc_reason = HCI_ERROR_AUTH_FAILURE; 3998 3997 result = L2CAP_CR_SEC_BLOCK; 3999 3998 goto response; ··· 7353 7352 } 7354 7353 7355 7354 if (chan->state == BT_CONNECT) { 7356 - if (!status && l2cap_check_enc_key_size(hcon)) 7355 + if (!status && l2cap_check_enc_key_size(hcon, chan)) 7357 7356 l2cap_start_connection(chan); 7358 7357 else 7359 7358 __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); ··· 7363 7362 struct l2cap_conn_rsp rsp; 7364 7363 __u16 res, stat; 7365 7364 7366 - if (!status && l2cap_check_enc_key_size(hcon)) { 7365 + if (!status && l2cap_check_enc_key_size(hcon, chan)) { 7367 7366 if (test_bit(FLAG_DEFER_SETUP, &chan->flags)) { 7368 7367 res = L2CAP_CR_PEND; 7369 7368 stat = L2CAP_CS_AUTHOR_PEND;
+2 -5
net/bridge/br_nf_core.c
··· 65 65 * ipt_REJECT needs it. Future netfilter modules might 66 66 * require us to fill additional fields. 67 67 */ 68 - static const u32 br_dst_default_metrics[RTAX_MAX] = { 69 - [RTAX_MTU - 1] = 1500, 70 - }; 71 - 72 68 void br_netfilter_rtable_init(struct net_bridge *br) 73 69 { 74 70 struct rtable *rt = &br->fake_rtable; 75 71 76 72 rcuref_init(&rt->dst.__rcuref, 1); 77 73 rt->dst.dev = br->dev; 78 - dst_init_metrics(&rt->dst, br_dst_default_metrics, true); 74 + dst_init_metrics(&rt->dst, br->metrics, false); 75 + dst_metric_set(&rt->dst, RTAX_MTU, br->dev->mtu); 79 76 rt->dst.flags = DST_NOXFRM | DST_FAKE_RTABLE; 80 77 rt->dst.ops = &fake_dst_ops; 81 78 }
+1
net/bridge/br_private.h
··· 505 505 struct rtable fake_rtable; 506 506 struct rt6_info fake_rt6_info; 507 507 }; 508 + u32 metrics[RTAX_MAX]; 508 509 #endif 509 510 u16 group_fwd_mask; 510 511 u16 group_fwd_mask_required;
+54 -25
net/can/bcm.c
··· 58 58 #include <linux/can/skb.h> 59 59 #include <linux/can/bcm.h> 60 60 #include <linux/slab.h> 61 + #include <linux/spinlock.h> 61 62 #include <net/sock.h> 62 63 #include <net/net_namespace.h> 63 64 ··· 123 122 struct canfd_frame last_sframe; 124 123 struct sock *sk; 125 124 struct net_device *rx_reg_dev; 125 + spinlock_t bcm_tx_lock; /* protect currframe/count in runtime updates */ 126 126 }; 127 127 128 128 struct bcm_sock { ··· 219 217 seq_printf(m, " / bound %s", bcm_proc_getifname(net, ifname, bo->ifindex)); 220 218 seq_printf(m, " <<<\n"); 221 219 222 - list_for_each_entry(op, &bo->rx_ops, list) { 220 + rcu_read_lock(); 221 + 222 + list_for_each_entry_rcu(op, &bo->rx_ops, list) { 223 223 224 224 unsigned long reduction; 225 225 ··· 277 273 seq_printf(m, "# sent %ld\n", op->frames_abs); 278 274 } 279 275 seq_putc(m, '\n'); 276 + 277 + rcu_read_unlock(); 278 + 280 279 return 0; 281 280 } 282 281 #endif /* CONFIG_PROC_FS */ ··· 292 285 { 293 286 struct sk_buff *skb; 294 287 struct net_device *dev; 295 - struct canfd_frame *cf = op->frames + op->cfsiz * op->currframe; 288 + struct canfd_frame *cf; 296 289 int err; 297 290 298 291 /* no target device? => exit */ 299 292 if (!op->ifindex) 300 293 return; 294 + 295 + /* read currframe under lock protection */ 296 + spin_lock_bh(&op->bcm_tx_lock); 297 + cf = op->frames + op->cfsiz * op->currframe; 298 + spin_unlock_bh(&op->bcm_tx_lock); 301 299 302 300 dev = dev_get_by_index(sock_net(op->sk), op->ifindex); 303 301 if (!dev) { ··· 324 312 skb->dev = dev; 325 313 can_skb_set_owner(skb, op->sk); 326 314 err = can_send(skb, 1); 315 + 316 + /* update currframe and count under lock protection */ 317 + spin_lock_bh(&op->bcm_tx_lock); 318 + 327 319 if (!err) 328 320 op->frames_abs++; 329 321 ··· 336 320 /* reached last frame? */ 337 321 if (op->currframe >= op->nframes) 338 322 op->currframe = 0; 323 + 324 + if (op->count > 0) 325 + op->count--; 326 + 327 + spin_unlock_bh(&op->bcm_tx_lock); 339 328 out: 340 329 dev_put(dev); 341 330 } ··· 451 430 struct bcm_msg_head msg_head; 452 431 453 432 if (op->kt_ival1 && (op->count > 0)) { 454 - op->count--; 433 + bcm_can_tx(op); 455 434 if (!op->count && (op->flags & TX_COUNTEVT)) { 456 435 457 436 /* create notification to user */ ··· 466 445 467 446 bcm_send_to_user(op, &msg_head, NULL, 0); 468 447 } 469 - bcm_can_tx(op); 470 448 471 449 } else if (op->kt_ival2) { 472 450 bcm_can_tx(op); ··· 863 843 REGMASK(op->can_id), 864 844 bcm_rx_handler, op); 865 845 866 - list_del(&op->list); 846 + list_del_rcu(&op->list); 867 847 bcm_remove_op(op); 868 848 return 1; /* done */ 869 849 } ··· 883 863 list_for_each_entry_safe(op, n, ops, list) { 884 864 if ((op->can_id == mh->can_id) && (op->ifindex == ifindex) && 885 865 (op->flags & CAN_FD_FRAME) == (mh->flags & CAN_FD_FRAME)) { 886 - list_del(&op->list); 866 + list_del_rcu(&op->list); 887 867 bcm_remove_op(op); 888 868 return 1; /* done */ 889 869 } ··· 976 956 } 977 957 op->flags = msg_head->flags; 978 958 959 + /* only lock for unlikely count/nframes/currframe changes */ 960 + if (op->nframes != msg_head->nframes || 961 + op->flags & TX_RESET_MULTI_IDX || 962 + op->flags & SETTIMER) { 963 + 964 + spin_lock_bh(&op->bcm_tx_lock); 965 + 966 + if (op->nframes != msg_head->nframes || 967 + op->flags & TX_RESET_MULTI_IDX) { 968 + /* potentially update changed nframes */ 969 + op->nframes = msg_head->nframes; 970 + /* restart multiple frame transmission */ 971 + op->currframe = 0; 972 + } 973 + 974 + if (op->flags & SETTIMER) 975 + op->count = msg_head->count; 976 + 977 + spin_unlock_bh(&op->bcm_tx_lock); 978 + } 979 + 979 980 } else { 980 981 /* insert new BCM operation for the given can_id */ 981 982 ··· 1004 963 if (!op) 1005 964 return -ENOMEM; 1006 965 966 + spin_lock_init(&op->bcm_tx_lock); 1007 967 op->can_id = msg_head->can_id; 1008 968 op->cfsiz = CFSIZ(msg_head->flags); 1009 969 op->flags = msg_head->flags; 970 + op->nframes = msg_head->nframes; 971 + 972 + if (op->flags & SETTIMER) 973 + op->count = msg_head->count; 1010 974 1011 975 /* create array for CAN frames and copy the data */ 1012 976 if (msg_head->nframes > 1) { ··· 1069 1023 1070 1024 } /* if ((op = bcm_find_op(&bo->tx_ops, msg_head->can_id, ifindex))) */ 1071 1025 1072 - if (op->nframes != msg_head->nframes) { 1073 - op->nframes = msg_head->nframes; 1074 - /* start multiple frame transmission with index 0 */ 1075 - op->currframe = 0; 1076 - } 1077 - 1078 - /* check flags */ 1079 - 1080 - if (op->flags & TX_RESET_MULTI_IDX) { 1081 - /* start multiple frame transmission with index 0 */ 1082 - op->currframe = 0; 1083 - } 1084 - 1085 1026 if (op->flags & SETTIMER) { 1086 1027 /* set timer values */ 1087 - op->count = msg_head->count; 1088 1028 op->ival1 = msg_head->ival1; 1089 1029 op->ival2 = msg_head->ival2; 1090 1030 op->kt_ival1 = bcm_timeval_to_ktime(msg_head->ival1); ··· 1087 1055 op->flags |= TX_ANNOUNCE; 1088 1056 } 1089 1057 1090 - if (op->flags & TX_ANNOUNCE) { 1058 + if (op->flags & TX_ANNOUNCE) 1091 1059 bcm_can_tx(op); 1092 - if (op->count) 1093 - op->count--; 1094 - } 1095 1060 1096 1061 if (op->flags & STARTTIMER) 1097 1062 bcm_tx_start_timer(op); ··· 1301 1272 bcm_rx_handler, op, "bcm", sk); 1302 1273 if (err) { 1303 1274 /* this bcm rx op is broken -> remove it */ 1304 - list_del(&op->list); 1275 + list_del_rcu(&op->list); 1305 1276 bcm_remove_op(op); 1306 1277 return err; 1307 1278 }
+15 -4
net/dsa/tag_ksz.c
··· 140 140 141 141 static struct sk_buff *ksz8795_rcv(struct sk_buff *skb, struct net_device *dev) 142 142 { 143 - u8 *tag = skb_tail_pointer(skb) - KSZ_EGRESS_TAG_LEN; 143 + u8 *tag; 144 + 145 + if (skb_linearize(skb)) 146 + return NULL; 147 + 148 + tag = skb_tail_pointer(skb) - KSZ_EGRESS_TAG_LEN; 144 149 145 150 return ksz_common_rcv(skb, dev, tag[0] & KSZ8795_TAIL_TAG_EG_PORT_M, 146 151 KSZ_EGRESS_TAG_LEN); ··· 316 311 317 312 static struct sk_buff *ksz9477_rcv(struct sk_buff *skb, struct net_device *dev) 318 313 { 319 - /* Tag decoding */ 320 - u8 *tag = skb_tail_pointer(skb) - KSZ_EGRESS_TAG_LEN; 321 - unsigned int port = tag[0] & KSZ9477_TAIL_TAG_EG_PORT_M; 322 314 unsigned int len = KSZ_EGRESS_TAG_LEN; 315 + unsigned int port; 316 + u8 *tag; 317 + 318 + if (skb_linearize(skb)) 319 + return NULL; 320 + 321 + /* Tag decoding */ 322 + tag = skb_tail_pointer(skb) - KSZ_EGRESS_TAG_LEN; 323 + port = tag[0] & KSZ9477_TAIL_TAG_EG_PORT_M; 323 324 324 325 /* Extra 4-bytes PTP timestamp */ 325 326 if (tag[0] & KSZ9477_PTP_TAG_INDICATION) {
+7 -46
net/ipv4/esp4.c
··· 120 120 } 121 121 122 122 #ifdef CONFIG_INET_ESPINTCP 123 - struct esp_tcp_sk { 124 - struct sock *sk; 125 - struct rcu_head rcu; 126 - }; 127 - 128 - static void esp_free_tcp_sk(struct rcu_head *head) 129 - { 130 - struct esp_tcp_sk *esk = container_of(head, struct esp_tcp_sk, rcu); 131 - 132 - sock_put(esk->sk); 133 - kfree(esk); 134 - } 135 - 136 123 static struct sock *esp_find_tcp_sk(struct xfrm_state *x) 137 124 { 138 125 struct xfrm_encap_tmpl *encap = x->encap; 139 126 struct net *net = xs_net(x); 140 - struct esp_tcp_sk *esk; 141 127 __be16 sport, dport; 142 - struct sock *nsk; 143 128 struct sock *sk; 144 - 145 - sk = rcu_dereference(x->encap_sk); 146 - if (sk && sk->sk_state == TCP_ESTABLISHED) 147 - return sk; 148 129 149 130 spin_lock_bh(&x->lock); 150 131 sport = encap->encap_sport; 151 132 dport = encap->encap_dport; 152 - nsk = rcu_dereference_protected(x->encap_sk, 153 - lockdep_is_held(&x->lock)); 154 - if (sk && sk == nsk) { 155 - esk = kmalloc(sizeof(*esk), GFP_ATOMIC); 156 - if (!esk) { 157 - spin_unlock_bh(&x->lock); 158 - return ERR_PTR(-ENOMEM); 159 - } 160 - RCU_INIT_POINTER(x->encap_sk, NULL); 161 - esk->sk = sk; 162 - call_rcu(&esk->rcu, esp_free_tcp_sk); 163 - } 164 133 spin_unlock_bh(&x->lock); 165 134 166 135 sk = inet_lookup_established(net, net->ipv4.tcp_death_row.hashinfo, x->id.daddr.a4, ··· 141 172 sock_put(sk); 142 173 return ERR_PTR(-EINVAL); 143 174 } 144 - 145 - spin_lock_bh(&x->lock); 146 - nsk = rcu_dereference_protected(x->encap_sk, 147 - lockdep_is_held(&x->lock)); 148 - if (encap->encap_sport != sport || 149 - encap->encap_dport != dport) { 150 - sock_put(sk); 151 - sk = nsk ?: ERR_PTR(-EREMCHG); 152 - } else if (sk == nsk) { 153 - sock_put(sk); 154 - } else { 155 - rcu_assign_pointer(x->encap_sk, sk); 156 - } 157 - spin_unlock_bh(&x->lock); 158 175 159 176 return sk; 160 177 } ··· 154 199 155 200 sk = esp_find_tcp_sk(x); 156 201 err = PTR_ERR_OR_ZERO(sk); 157 - if (err) 202 + if (err) { 203 + kfree_skb(skb); 158 204 goto out; 205 + } 159 206 160 207 bh_lock_sock(sk); 161 208 if (sock_owned_by_user(sk)) ··· 165 208 else 166 209 err = espintcp_push_skb(sk, skb); 167 210 bh_unlock_sock(sk); 211 + 212 + sock_put(sk); 168 213 169 214 out: 170 215 rcu_read_unlock(); ··· 350 391 351 392 if (IS_ERR(sk)) 352 393 return ERR_CAST(sk); 394 + 395 + sock_put(sk); 353 396 354 397 *lenp = htons(len); 355 398 esph = (struct ip_esp_hdr *)(lenp + 1);
+1 -11
net/ipv4/ipmr.c
··· 120 120 lockdep_rtnl_is_held() || \ 121 121 list_empty(&net->ipv4.mr_tables)) 122 122 123 - static bool ipmr_can_free_table(struct net *net) 124 - { 125 - return !check_net(net) || !net_initialized(net); 126 - } 127 - 128 123 static struct mr_table *ipmr_mr_table_iter(struct net *net, 129 124 struct mr_table *mrt) 130 125 { ··· 312 317 #define ipmr_for_each_table(mrt, net) \ 313 318 for (mrt = net->ipv4.mrt; mrt; mrt = NULL) 314 319 315 - static bool ipmr_can_free_table(struct net *net) 316 - { 317 - return !check_net(net); 318 - } 319 - 320 320 static struct mr_table *ipmr_mr_table_iter(struct net *net, 321 321 struct mr_table *mrt) 322 322 { ··· 427 437 { 428 438 struct net *net = read_pnet(&mrt->net); 429 439 430 - WARN_ON_ONCE(!ipmr_can_free_table(net)); 440 + WARN_ON_ONCE(!mr_can_free_table(net)); 431 441 432 442 timer_shutdown_sync(&mrt->ipmr_expire_timer); 433 443 mroute_clean_tables(mrt, MRT_FLUSH_VIFS | MRT_FLUSH_VIFS_STATIC |
+10 -8
net/ipv4/xfrm4_input.c
··· 182 182 int offset = skb_gro_offset(skb); 183 183 const struct net_offload *ops; 184 184 struct sk_buff *pp = NULL; 185 - int ret; 185 + int len, dlen; 186 + __u8 *udpdata; 187 + __be32 *udpdata32; 186 188 187 - offset = offset - sizeof(struct udphdr); 188 - 189 - if (!pskb_pull(skb, offset)) 189 + len = skb->len - offset; 190 + dlen = offset + min(len, 8); 191 + udpdata = skb_gro_header(skb, dlen, offset); 192 + udpdata32 = (__be32 *)udpdata; 193 + if (unlikely(!udpdata)) 190 194 return NULL; 191 195 192 196 rcu_read_lock(); ··· 198 194 if (!ops || !ops->callbacks.gro_receive) 199 195 goto out; 200 196 201 - ret = __xfrm4_udp_encap_rcv(sk, skb, false); 202 - if (ret) 197 + /* check if it is a keepalive or IKE packet */ 198 + if (len <= sizeof(struct ip_esp_hdr) || udpdata32[0] == 0) 203 199 goto out; 204 200 205 - skb_push(skb, offset); 206 201 NAPI_GRO_CB(skb)->proto = IPPROTO_UDP; 207 202 208 203 pp = call_gro_receive(ops->callbacks.gro_receive, head, skb); ··· 211 208 212 209 out: 213 210 rcu_read_unlock(); 214 - skb_push(skb, offset); 215 211 NAPI_GRO_CB(skb)->same_flow = 0; 216 212 NAPI_GRO_CB(skb)->flush = 1; 217 213
+7 -46
net/ipv6/esp6.c
··· 137 137 } 138 138 139 139 #ifdef CONFIG_INET6_ESPINTCP 140 - struct esp_tcp_sk { 141 - struct sock *sk; 142 - struct rcu_head rcu; 143 - }; 144 - 145 - static void esp_free_tcp_sk(struct rcu_head *head) 146 - { 147 - struct esp_tcp_sk *esk = container_of(head, struct esp_tcp_sk, rcu); 148 - 149 - sock_put(esk->sk); 150 - kfree(esk); 151 - } 152 - 153 140 static struct sock *esp6_find_tcp_sk(struct xfrm_state *x) 154 141 { 155 142 struct xfrm_encap_tmpl *encap = x->encap; 156 143 struct net *net = xs_net(x); 157 - struct esp_tcp_sk *esk; 158 144 __be16 sport, dport; 159 - struct sock *nsk; 160 145 struct sock *sk; 161 - 162 - sk = rcu_dereference(x->encap_sk); 163 - if (sk && sk->sk_state == TCP_ESTABLISHED) 164 - return sk; 165 146 166 147 spin_lock_bh(&x->lock); 167 148 sport = encap->encap_sport; 168 149 dport = encap->encap_dport; 169 - nsk = rcu_dereference_protected(x->encap_sk, 170 - lockdep_is_held(&x->lock)); 171 - if (sk && sk == nsk) { 172 - esk = kmalloc(sizeof(*esk), GFP_ATOMIC); 173 - if (!esk) { 174 - spin_unlock_bh(&x->lock); 175 - return ERR_PTR(-ENOMEM); 176 - } 177 - RCU_INIT_POINTER(x->encap_sk, NULL); 178 - esk->sk = sk; 179 - call_rcu(&esk->rcu, esp_free_tcp_sk); 180 - } 181 150 spin_unlock_bh(&x->lock); 182 151 183 152 sk = __inet6_lookup_established(net, net->ipv4.tcp_death_row.hashinfo, &x->id.daddr.in6, ··· 158 189 sock_put(sk); 159 190 return ERR_PTR(-EINVAL); 160 191 } 161 - 162 - spin_lock_bh(&x->lock); 163 - nsk = rcu_dereference_protected(x->encap_sk, 164 - lockdep_is_held(&x->lock)); 165 - if (encap->encap_sport != sport || 166 - encap->encap_dport != dport) { 167 - sock_put(sk); 168 - sk = nsk ?: ERR_PTR(-EREMCHG); 169 - } else if (sk == nsk) { 170 - sock_put(sk); 171 - } else { 172 - rcu_assign_pointer(x->encap_sk, sk); 173 - } 174 - spin_unlock_bh(&x->lock); 175 192 176 193 return sk; 177 194 } ··· 171 216 172 217 sk = esp6_find_tcp_sk(x); 173 218 err = PTR_ERR_OR_ZERO(sk); 174 - if (err) 219 + if (err) { 220 + kfree_skb(skb); 175 221 goto out; 222 + } 176 223 177 224 bh_lock_sock(sk); 178 225 if (sock_owned_by_user(sk)) ··· 182 225 else 183 226 err = espintcp_push_skb(sk, skb); 184 227 bh_unlock_sock(sk); 228 + 229 + sock_put(sk); 185 230 186 231 out: 187 232 rcu_read_unlock(); ··· 380 421 381 422 if (IS_ERR(sk)) 382 423 return ERR_CAST(sk); 424 + 425 + sock_put(sk); 383 426 384 427 *lenp = htons(len); 385 428 esph = (struct ip_esp_hdr *)(lenp + 1);
+1 -11
net/ipv6/ip6mr.c
··· 108 108 lockdep_rtnl_is_held() || \ 109 109 list_empty(&net->ipv6.mr6_tables)) 110 110 111 - static bool ip6mr_can_free_table(struct net *net) 112 - { 113 - return !check_net(net) || !net_initialized(net); 114 - } 115 - 116 111 static struct mr_table *ip6mr_mr_table_iter(struct net *net, 117 112 struct mr_table *mrt) 118 113 { ··· 301 306 #define ip6mr_for_each_table(mrt, net) \ 302 307 for (mrt = net->ipv6.mrt6; mrt; mrt = NULL) 303 308 304 - static bool ip6mr_can_free_table(struct net *net) 305 - { 306 - return !check_net(net); 307 - } 308 - 309 309 static struct mr_table *ip6mr_mr_table_iter(struct net *net, 310 310 struct mr_table *mrt) 311 311 { ··· 406 416 { 407 417 struct net *net = read_pnet(&mrt->net); 408 418 409 - WARN_ON_ONCE(!ip6mr_can_free_table(net)); 419 + WARN_ON_ONCE(!mr_can_free_table(net)); 410 420 411 421 timer_shutdown_sync(&mrt->ipmr_expire_timer); 412 422 mroute_clean_tables(mrt, MRT6_FLUSH_MIFS | MRT6_FLUSH_MIFS_STATIC |
+10 -8
net/ipv6/xfrm6_input.c
··· 179 179 int offset = skb_gro_offset(skb); 180 180 const struct net_offload *ops; 181 181 struct sk_buff *pp = NULL; 182 - int ret; 182 + int len, dlen; 183 + __u8 *udpdata; 184 + __be32 *udpdata32; 183 185 184 186 if (skb->protocol == htons(ETH_P_IP)) 185 187 return xfrm4_gro_udp_encap_rcv(sk, head, skb); 186 188 187 - offset = offset - sizeof(struct udphdr); 188 - 189 - if (!pskb_pull(skb, offset)) 189 + len = skb->len - offset; 190 + dlen = offset + min(len, 8); 191 + udpdata = skb_gro_header(skb, dlen, offset); 192 + udpdata32 = (__be32 *)udpdata; 193 + if (unlikely(!udpdata)) 190 194 return NULL; 191 195 192 196 rcu_read_lock(); ··· 198 194 if (!ops || !ops->callbacks.gro_receive) 199 195 goto out; 200 196 201 - ret = __xfrm6_udp_encap_rcv(sk, skb, false); 202 - if (ret) 197 + /* check if it is a keepalive or IKE packet */ 198 + if (len <= sizeof(struct ip_esp_hdr) || udpdata32[0] == 0) 203 199 goto out; 204 200 205 - skb_push(skb, offset); 206 201 NAPI_GRO_CB(skb)->proto = IPPROTO_UDP; 207 202 208 203 pp = call_gro_receive(ops->callbacks.gro_receive, head, skb); ··· 211 208 212 209 out: 213 210 rcu_read_unlock(); 214 - skb_push(skb, offset); 215 211 NAPI_GRO_CB(skb)->same_flow = 0; 216 212 NAPI_GRO_CB(skb)->flush = 1; 217 213
+4 -4
net/llc/af_llc.c
··· 887 887 if (sk->sk_type != SOCK_STREAM) 888 888 goto copy_uaddr; 889 889 890 + /* Partial read */ 891 + if (used + offset < skb_len) 892 + continue; 893 + 890 894 if (!(flags & MSG_PEEK)) { 891 895 skb_unlink(skb, &sk->sk_receive_queue); 892 896 kfree_skb(skb); 893 897 *seq = 0; 894 898 } 895 - 896 - /* Partial read */ 897 - if (used + offset < skb_len) 898 - continue; 899 899 } while (len > 0); 900 900 901 901 out:
+3 -3
net/sched/sch_hfsc.c
··· 1569 1569 return err; 1570 1570 } 1571 1571 1572 + sch->qstats.backlog += len; 1573 + sch->q.qlen++; 1574 + 1572 1575 if (first && !cl->cl_nactive) { 1573 1576 if (cl->cl_flags & HFSC_RSC) 1574 1577 init_ed(cl, len); ··· 1586 1583 cl->qdisc->ops->peek(cl->qdisc); 1587 1584 1588 1585 } 1589 - 1590 - sch->qstats.backlog += len; 1591 - sch->q.qlen++; 1592 1586 1593 1587 return NET_XMIT_SUCCESS; 1594 1588 }
+5
net/tipc/crypto.c
··· 817 817 goto exit; 818 818 } 819 819 820 + /* Get net to avoid freed tipc_crypto when delete namespace */ 821 + get_net(aead->crypto->net); 822 + 820 823 /* Now, do encrypt */ 821 824 rc = crypto_aead_encrypt(req); 822 825 if (rc == -EINPROGRESS || rc == -EBUSY) 823 826 return rc; 824 827 825 828 tipc_bearer_put(b); 829 + put_net(aead->crypto->net); 826 830 827 831 exit: 828 832 kfree(ctx); ··· 864 860 kfree(tx_ctx); 865 861 tipc_bearer_put(b); 866 862 tipc_aead_put(aead); 863 + put_net(net); 867 864 } 868 865 869 866 /**
+1 -1
net/xdp/xsk.c
··· 1304 1304 xs->queue_id = qid; 1305 1305 xp_add_xsk(xs->pool, xs); 1306 1306 1307 - if (xs->zc && qid < dev->real_num_rx_queues) { 1307 + if (qid < dev->real_num_rx_queues) { 1308 1308 struct netdev_rx_queue *rxq; 1309 1309 1310 1310 rxq = __netif_get_rx_queue(dev, qid);
+3 -1
net/xfrm/espintcp.c
··· 171 171 struct espintcp_ctx *ctx = espintcp_getctx(sk); 172 172 173 173 if (skb_queue_len(&ctx->out_queue) >= 174 - READ_ONCE(net_hotdata.max_backlog)) 174 + READ_ONCE(net_hotdata.max_backlog)) { 175 + kfree_skb(skb); 175 176 return -ENOBUFS; 177 + } 176 178 177 179 __skb_queue_tail(&ctx->out_queue, skb); 178 180
+1 -2
net/xfrm/xfrm_ipcomp.c
··· 48 48 { 49 49 struct acomp_req *req = ipcomp_cb(skb)->req; 50 50 struct ipcomp_req_extra *extra; 51 - const int plen = skb->data_len; 52 51 struct scatterlist *dsg; 53 52 int len, dlen; 54 53 ··· 63 64 64 65 /* Only update truesize on input. */ 65 66 if (!hlen) 66 - skb->truesize += dlen - plen; 67 + skb->truesize += dlen; 67 68 skb->data_len = dlen; 68 69 skb->len += dlen; 69 70
+3
net/xfrm/xfrm_policy.c
··· 1581 1581 struct xfrm_policy *delpol; 1582 1582 struct hlist_head *chain; 1583 1583 1584 + /* Sanitize mark before store */ 1585 + policy->mark.v &= policy->mark.m; 1586 + 1584 1587 spin_lock_bh(&net->xfrm.xfrm_policy_lock); 1585 1588 chain = policy_hash_bysel(net, &policy->selector, policy->family, dir); 1586 1589 if (chain)
+3 -3
net/xfrm/xfrm_state.c
··· 838 838 xfrm_nat_keepalive_state_updated(x); 839 839 spin_unlock(&net->xfrm.xfrm_state_lock); 840 840 841 - if (x->encap_sk) 842 - sock_put(rcu_dereference_raw(x->encap_sk)); 843 - 844 841 xfrm_dev_state_delete(x); 845 842 846 843 /* All xfrm_state objects are created by xfrm_state_alloc. ··· 1717 1720 unsigned int h; 1718 1721 1719 1722 list_add(&x->km.all, &net->xfrm.state_all); 1723 + 1724 + /* Sanitize mark before store */ 1725 + x->mark.v &= x->mark.m; 1720 1726 1721 1727 h = xfrm_dst_hash(net, &x->id.daddr, &x->props.saddr, 1722 1728 x->props.reqid, x->props.family);
+27
tools/testing/selftests/tc-testing/tc-tests/infra/qdiscs.json
··· 573 573 "teardown": [ 574 574 "$TC qdisc del dev $DEV1 handle 1: root" 575 575 ] 576 + }, 577 + { 578 + "id": "831d", 579 + "name": "Test HFSC qlen accounting with DRR/NETEM/BLACKHOLE chain", 580 + "category": ["qdisc", "hfsc", "drr", "netem", "blackhole"], 581 + "plugins": { "requires": ["nsPlugin", "scapyPlugin"] }, 582 + "setup": [ 583 + "$IP link set dev $DEV1 up || true", 584 + "$TC qdisc add dev $DEV1 root handle 1: drr", 585 + "$TC filter add dev $DEV1 parent 1: basic classid 1:1", 586 + "$TC class add dev $DEV1 parent 1: classid 1:1 drr", 587 + "$TC qdisc add dev $DEV1 parent 1:1 handle 2: hfsc def 1", 588 + "$TC class add dev $DEV1 parent 2: classid 2:1 hfsc rt m1 8 d 1 m2 0", 589 + "$TC qdisc add dev $DEV1 parent 2:1 handle 3: netem", 590 + "$TC qdisc add dev $DEV1 parent 3:1 handle 4: blackhole" 591 + ], 592 + "scapy": { 593 + "iface": "$DEV0", 594 + "count": 5, 595 + "packet": "Ether()/IP(dst='10.10.10.1', src='10.10.10.10')/ICMP()" 596 + }, 597 + "cmdUnderTest": "$TC -s qdisc show dev $DEV1", 598 + "expExitCode": "0", 599 + "verifyCmd": "$TC -s qdisc show dev $DEV1", 600 + "matchPattern": "qdisc hfsc", 601 + "matchCount": "1", 602 + "teardown": ["$TC qdisc del dev $DEV1 root handle 1: drr"] 576 603 } 577 604 ]