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

Pull networking fixes from Paolo Abeni:
"Notably this includes fixes for a few regressions spotted very
recently. No known outstanding ones.

Current release - regressions:

- core: avoid CFI problems with sock priv helpers

- xsk: bring back busy polling support

- netpoll: ensure skb_pool list is always initialized

Current release - new code bugs:

- core: make page_pool_ref_netmem work with net iovs

- ipv4: route: fix drop reason being overridden in
ip_route_input_slow

- udp: make rehash4 independent in udp_lib_rehash()

Previous releases - regressions:

- bpf: fix bpf_sk_select_reuseport() memory leak

- openvswitch: fix lockup on tx to unregistering netdev with carrier

- mptcp: be sure to send ack when mptcp-level window re-opens

- eth:
- bnxt: always recalculate features after XDP clearing, fix
null-deref
- mlx5: fix sub-function add port error handling
- fec: handle page_pool_dev_alloc_pages error

Previous releases - always broken:

- vsock: some fixes due to transport de-assignment

- eth:
- ice: fix E825 initialization
- mlx5e: fix inversion dependency warning while enabling IPsec
tunnel
- gtp: destroy device along with udp socket's netns dismantle.
- xilinx: axienet: Fix IRQ coalescing packet count overflow"

* tag 'net-6.13-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (44 commits)
netdev: avoid CFI problems with sock priv helpers
net/mlx5e: Always start IPsec sequence number from 1
net/mlx5e: Rely on reqid in IPsec tunnel mode
net/mlx5e: Fix inversion dependency warning while enabling IPsec tunnel
net/mlx5: Clear port select structure when fail to create
net/mlx5: SF, Fix add port error handling
net/mlx5: Fix a lockdep warning as part of the write combining test
net/mlx5: Fix RDMA TX steering prio
net: make page_pool_ref_netmem work with net iovs
net: ethernet: xgbe: re-add aneg to supported features in PHY quirks
net: pcs: xpcs: actively unset DW_VR_MII_DIG_CTRL1_2G5_EN for 1G SGMII
net: pcs: xpcs: fix DW_VR_MII_DIG_CTRL1_2G5_EN bit being set for 1G SGMII w/o inband
selftests: net: Adapt ethtool mq tests to fix in qdisc graft
net: fec: handle page_pool_dev_alloc_pages error
net: netpoll: ensure skb_pool list is always initialized
net: xilinx: axienet: Fix IRQ coalescing packet count overflow
nfp: bpf: prevent integer overflow in nfp_bpf_event_output()
selftests: mptcp: avoid spurious errors on disconnect
mptcp: fix spurious wake-up on under memory pressure
mptcp: be sure to send ack when mptcp-level window re-opens
...

+553 -400
+2 -17
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
··· 923 923 924 924 static bool xgbe_phy_finisar_phy_quirks(struct xgbe_prv_data *pdata) 925 925 { 926 - __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, }; 927 926 struct xgbe_phy_data *phy_data = pdata->phy_data; 928 927 unsigned int phy_id = phy_data->phydev->phy_id; 929 928 ··· 944 945 phy_write(phy_data->phydev, 0x04, 0x0d01); 945 946 phy_write(phy_data->phydev, 0x00, 0x9140); 946 947 947 - linkmode_set_bit_array(phy_10_100_features_array, 948 - ARRAY_SIZE(phy_10_100_features_array), 949 - supported); 950 - linkmode_set_bit_array(phy_gbit_features_array, 951 - ARRAY_SIZE(phy_gbit_features_array), 952 - supported); 953 - 954 - linkmode_copy(phy_data->phydev->supported, supported); 948 + linkmode_copy(phy_data->phydev->supported, PHY_GBIT_FEATURES); 955 949 956 950 phy_support_asym_pause(phy_data->phydev); 957 951 ··· 956 964 957 965 static bool xgbe_phy_belfuse_phy_quirks(struct xgbe_prv_data *pdata) 958 966 { 959 - __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, }; 960 967 struct xgbe_phy_data *phy_data = pdata->phy_data; 961 968 struct xgbe_sfp_eeprom *sfp_eeprom = &phy_data->sfp_eeprom; 962 969 unsigned int phy_id = phy_data->phydev->phy_id; ··· 1019 1028 reg = phy_read(phy_data->phydev, 0x00); 1020 1029 phy_write(phy_data->phydev, 0x00, reg & ~0x00800); 1021 1030 1022 - linkmode_set_bit_array(phy_10_100_features_array, 1023 - ARRAY_SIZE(phy_10_100_features_array), 1024 - supported); 1025 - linkmode_set_bit_array(phy_gbit_features_array, 1026 - ARRAY_SIZE(phy_gbit_features_array), 1027 - supported); 1028 - linkmode_copy(phy_data->phydev->supported, supported); 1031 + linkmode_copy(phy_data->phydev->supported, PHY_GBIT_FEATURES); 1029 1032 phy_support_asym_pause(phy_data->phydev); 1030 1033 1031 1034 netif_dbg(pdata, drv, pdata->netdev,
+20 -5
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 4708 4708 /* Changing allocation mode of RX rings. 4709 4709 * TODO: Update when extending xdp_rxq_info to support allocation modes. 4710 4710 */ 4711 - int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode) 4711 + static void __bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode) 4712 4712 { 4713 4713 struct net_device *dev = bp->dev; 4714 4714 ··· 4729 4729 bp->rx_skb_func = bnxt_rx_page_skb; 4730 4730 } 4731 4731 bp->rx_dir = DMA_BIDIRECTIONAL; 4732 - /* Disable LRO or GRO_HW */ 4733 - netdev_update_features(dev); 4734 4732 } else { 4735 4733 dev->max_mtu = bp->max_mtu; 4736 4734 bp->flags &= ~BNXT_FLAG_RX_PAGE_MODE; 4737 4735 bp->rx_dir = DMA_FROM_DEVICE; 4738 4736 bp->rx_skb_func = bnxt_rx_skb; 4739 4737 } 4740 - return 0; 4738 + } 4739 + 4740 + void bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode) 4741 + { 4742 + __bnxt_set_rx_skb_mode(bp, page_mode); 4743 + 4744 + if (!page_mode) { 4745 + int rx, tx; 4746 + 4747 + bnxt_get_max_rings(bp, &rx, &tx, true); 4748 + if (rx > 1) { 4749 + bp->flags &= ~BNXT_FLAG_NO_AGG_RINGS; 4750 + bp->dev->hw_features |= NETIF_F_LRO; 4751 + } 4752 + } 4753 + 4754 + /* Update LRO and GRO_HW availability */ 4755 + netdev_update_features(bp->dev); 4741 4756 } 4742 4757 4743 4758 static void bnxt_free_vnic_attributes(struct bnxt *bp) ··· 16229 16214 if (bp->max_fltr < BNXT_MAX_FLTR) 16230 16215 bp->max_fltr = BNXT_MAX_FLTR; 16231 16216 bnxt_init_l2_fltr_tbl(bp); 16232 - bnxt_set_rx_skb_mode(bp, false); 16217 + __bnxt_set_rx_skb_mode(bp, false); 16233 16218 bnxt_set_tpa_flags(bp); 16234 16219 bnxt_set_ring_params(bp); 16235 16220 bnxt_rdma_aux_device_init(bp);
+1 -1
drivers/net/ethernet/broadcom/bnxt/bnxt.h
··· 2846 2846 bool bnxt_bs_trace_avail(struct bnxt *bp, u16 type); 2847 2847 void bnxt_set_tpa_flags(struct bnxt *bp); 2848 2848 void bnxt_set_ring_params(struct bnxt *); 2849 - int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode); 2849 + void bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode); 2850 2850 void bnxt_insert_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr); 2851 2851 void bnxt_del_one_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr); 2852 2852 int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp, unsigned long *bmap,
-7
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
··· 422 422 bnxt_set_rx_skb_mode(bp, true); 423 423 xdp_features_set_redirect_target(dev, true); 424 424 } else { 425 - int rx, tx; 426 - 427 425 xdp_features_clear_redirect_target(dev); 428 426 bnxt_set_rx_skb_mode(bp, false); 429 - bnxt_get_max_rings(bp, &rx, &tx, true); 430 - if (rx > 1) { 431 - bp->flags &= ~BNXT_FLAG_NO_AGG_RINGS; 432 - bp->dev->hw_features |= NETIF_F_LRO; 433 - } 434 427 } 435 428 bp->tx_nr_rings_xdp = tx_xdp; 436 429 bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc + tx_xdp;
+14 -5
drivers/net/ethernet/freescale/fec_main.c
··· 1591 1591 fec_enet_tx_queue(ndev, i, budget); 1592 1592 } 1593 1593 1594 - static void fec_enet_update_cbd(struct fec_enet_priv_rx_q *rxq, 1594 + static int fec_enet_update_cbd(struct fec_enet_priv_rx_q *rxq, 1595 1595 struct bufdesc *bdp, int index) 1596 1596 { 1597 1597 struct page *new_page; 1598 1598 dma_addr_t phys_addr; 1599 1599 1600 1600 new_page = page_pool_dev_alloc_pages(rxq->page_pool); 1601 - WARN_ON(!new_page); 1602 - rxq->rx_skb_info[index].page = new_page; 1601 + if (unlikely(!new_page)) 1602 + return -ENOMEM; 1603 1603 1604 + rxq->rx_skb_info[index].page = new_page; 1604 1605 rxq->rx_skb_info[index].offset = FEC_ENET_XDP_HEADROOM; 1605 1606 phys_addr = page_pool_get_dma_addr(new_page) + FEC_ENET_XDP_HEADROOM; 1606 1607 bdp->cbd_bufaddr = cpu_to_fec32(phys_addr); 1608 + 1609 + return 0; 1607 1610 } 1608 1611 1609 1612 static u32 ··· 1701 1698 int cpu = smp_processor_id(); 1702 1699 struct xdp_buff xdp; 1703 1700 struct page *page; 1701 + __fec32 cbd_bufaddr; 1704 1702 u32 sub_len = 4; 1705 1703 1706 1704 #if !defined(CONFIG_M5272) ··· 1770 1766 1771 1767 index = fec_enet_get_bd_index(bdp, &rxq->bd); 1772 1768 page = rxq->rx_skb_info[index].page; 1769 + cbd_bufaddr = bdp->cbd_bufaddr; 1770 + if (fec_enet_update_cbd(rxq, bdp, index)) { 1771 + ndev->stats.rx_dropped++; 1772 + goto rx_processing_done; 1773 + } 1774 + 1773 1775 dma_sync_single_for_cpu(&fep->pdev->dev, 1774 - fec32_to_cpu(bdp->cbd_bufaddr), 1776 + fec32_to_cpu(cbd_bufaddr), 1775 1777 pkt_len, 1776 1778 DMA_FROM_DEVICE); 1777 1779 prefetch(page_address(page)); 1778 - fec_enet_update_cbd(rxq, bdp, index); 1779 1780 1780 1781 if (xdp_prog) { 1781 1782 xdp_buff_clear_frags_flag(&xdp);
+1
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
··· 1665 1665 #define ICE_AQC_PORT_OPT_MAX_LANE_25G 5 1666 1666 #define ICE_AQC_PORT_OPT_MAX_LANE_50G 6 1667 1667 #define ICE_AQC_PORT_OPT_MAX_LANE_100G 7 1668 + #define ICE_AQC_PORT_OPT_MAX_LANE_200G 8 1668 1669 1669 1670 u8 global_scid[2]; 1670 1671 u8 phy_scid[2];
+51
drivers/net/ethernet/intel/ice/ice_common.c
··· 4096 4096 } 4097 4097 4098 4098 /** 4099 + * ice_get_phy_lane_number - Get PHY lane number for current adapter 4100 + * @hw: pointer to the hw struct 4101 + * 4102 + * Return: PHY lane number on success, negative error code otherwise. 4103 + */ 4104 + int ice_get_phy_lane_number(struct ice_hw *hw) 4105 + { 4106 + struct ice_aqc_get_port_options_elem *options; 4107 + unsigned int lport = 0; 4108 + unsigned int lane; 4109 + int err; 4110 + 4111 + options = kcalloc(ICE_AQC_PORT_OPT_MAX, sizeof(*options), GFP_KERNEL); 4112 + if (!options) 4113 + return -ENOMEM; 4114 + 4115 + for (lane = 0; lane < ICE_MAX_PORT_PER_PCI_DEV; lane++) { 4116 + u8 options_count = ICE_AQC_PORT_OPT_MAX; 4117 + u8 speed, active_idx, pending_idx; 4118 + bool active_valid, pending_valid; 4119 + 4120 + err = ice_aq_get_port_options(hw, options, &options_count, lane, 4121 + true, &active_idx, &active_valid, 4122 + &pending_idx, &pending_valid); 4123 + if (err) 4124 + goto err; 4125 + 4126 + if (!active_valid) 4127 + continue; 4128 + 4129 + speed = options[active_idx].max_lane_speed; 4130 + /* If we don't get speed for this lane, it's unoccupied */ 4131 + if (speed > ICE_AQC_PORT_OPT_MAX_LANE_200G) 4132 + continue; 4133 + 4134 + if (hw->pf_id == lport) { 4135 + kfree(options); 4136 + return lane; 4137 + } 4138 + 4139 + lport++; 4140 + } 4141 + 4142 + /* PHY lane not found */ 4143 + err = -ENXIO; 4144 + err: 4145 + kfree(options); 4146 + return err; 4147 + } 4148 + 4149 + /** 4099 4150 * ice_aq_sff_eeprom 4100 4151 * @hw: pointer to the HW struct 4101 4152 * @lport: bits [7:0] = logical port, bit [8] = logical port valid
+1
drivers/net/ethernet/intel/ice/ice_common.h
··· 193 193 int 194 194 ice_aq_set_port_option(struct ice_hw *hw, u8 lport, u8 lport_valid, 195 195 u8 new_option); 196 + int ice_get_phy_lane_number(struct ice_hw *hw); 196 197 int 197 198 ice_aq_sff_eeprom(struct ice_hw *hw, u16 lport, u8 bus_addr, 198 199 u16 mem_addr, u8 page, u8 set_page, u8 *data, u8 length,
+3 -3
drivers/net/ethernet/intel/ice/ice_main.c
··· 1144 1144 if (link_up == old_link && link_speed == old_link_speed) 1145 1145 return 0; 1146 1146 1147 - ice_ptp_link_change(pf, pf->hw.pf_id, link_up); 1147 + ice_ptp_link_change(pf, link_up); 1148 1148 1149 1149 if (ice_is_dcb_active(pf)) { 1150 1150 if (test_bit(ICE_FLAG_DCB_ENA, pf->flags)) ··· 6790 6790 ice_print_link_msg(vsi, true); 6791 6791 netif_tx_start_all_queues(vsi->netdev); 6792 6792 netif_carrier_on(vsi->netdev); 6793 - ice_ptp_link_change(pf, pf->hw.pf_id, true); 6793 + ice_ptp_link_change(pf, true); 6794 6794 } 6795 6795 6796 6796 /* Perform an initial read of the statistics registers now to ··· 7260 7260 7261 7261 if (vsi->netdev) { 7262 7262 vlan_err = ice_vsi_del_vlan_zero(vsi); 7263 - ice_ptp_link_change(vsi->back, vsi->back->hw.pf_id, false); 7263 + ice_ptp_link_change(vsi->back, false); 7264 7264 netif_carrier_off(vsi->netdev); 7265 7265 netif_tx_disable(vsi->netdev); 7266 7266 }
+9 -14
drivers/net/ethernet/intel/ice/ice_ptp.c
··· 1388 1388 /** 1389 1389 * ice_ptp_link_change - Reconfigure PTP after link status change 1390 1390 * @pf: Board private structure 1391 - * @port: Port for which the PHY start is set 1392 1391 * @linkup: Link is up or down 1393 1392 */ 1394 - void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup) 1393 + void ice_ptp_link_change(struct ice_pf *pf, bool linkup) 1395 1394 { 1396 1395 struct ice_ptp_port *ptp_port; 1397 1396 struct ice_hw *hw = &pf->hw; ··· 1398 1399 if (pf->ptp.state != ICE_PTP_READY) 1399 1400 return; 1400 1401 1401 - if (WARN_ON_ONCE(port >= hw->ptp.num_lports)) 1402 - return; 1403 - 1404 1402 ptp_port = &pf->ptp.port; 1405 - if (ice_is_e825c(hw) && hw->ptp.is_2x50g_muxed_topo) 1406 - port *= 2; 1407 - if (WARN_ON_ONCE(ptp_port->port_num != port)) 1408 - return; 1409 1403 1410 1404 /* Update cached link status for this port immediately */ 1411 1405 ptp_port->link_up = linkup; ··· 3156 3164 { 3157 3165 struct ice_ptp *ptp = &pf->ptp; 3158 3166 struct ice_hw *hw = &pf->hw; 3159 - int err; 3167 + int lane_num, err; 3160 3168 3161 3169 ptp->state = ICE_PTP_INITIALIZING; 3162 3170 3171 + lane_num = ice_get_phy_lane_number(hw); 3172 + if (lane_num < 0) { 3173 + err = lane_num; 3174 + goto err_exit; 3175 + } 3176 + 3177 + ptp->port.port_num = (u8)lane_num; 3163 3178 ice_ptp_init_hw(hw); 3164 3179 3165 3180 ice_ptp_init_tx_interrupt_mode(pf); ··· 3186 3187 err = ice_ptp_setup_pf(pf); 3187 3188 if (err) 3188 3189 goto err_exit; 3189 - 3190 - ptp->port.port_num = hw->pf_id; 3191 - if (ice_is_e825c(hw) && hw->ptp.is_2x50g_muxed_topo) 3192 - ptp->port.port_num = hw->pf_id * 2; 3193 3190 3194 3191 err = ice_ptp_init_port(pf, &ptp->port); 3195 3192 if (err)
+2 -2
drivers/net/ethernet/intel/ice/ice_ptp.h
··· 310 310 enum ice_reset_req reset_type); 311 311 void ice_ptp_init(struct ice_pf *pf); 312 312 void ice_ptp_release(struct ice_pf *pf); 313 - void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup); 313 + void ice_ptp_link_change(struct ice_pf *pf, bool linkup); 314 314 #else /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */ 315 315 static inline int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr) 316 316 { ··· 358 358 } 359 359 static inline void ice_ptp_init(struct ice_pf *pf) { } 360 360 static inline void ice_ptp_release(struct ice_pf *pf) { } 361 - static inline void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup) 361 + static inline void ice_ptp_link_change(struct ice_pf *pf, bool linkup) 362 362 { 363 363 } 364 364
+1 -1
drivers/net/ethernet/intel/ice/ice_ptp_consts.h
··· 131 131 .rx_offset = { 132 132 .serdes = 0xffffeb27, /* -10.42424 */ 133 133 .no_fec = 0xffffcccd, /* -25.6 */ 134 - .fc = 0xfffe0014, /* -255.96 */ 134 + .fc = 0xfffc557b, /* -469.26 */ 135 135 .sfd = 0x4a4, /* 2.32 */ 136 136 .bs_ds = 0x32 /* 0.0969697 */ 137 137 }
+141 -122
drivers/net/ethernet/intel/ice/ice_ptp_hw.c
··· 901 901 */ 902 902 903 903 /** 904 + * ice_ptp_get_dest_dev_e825 - get destination PHY for given port number 905 + * @hw: pointer to the HW struct 906 + * @port: destination port 907 + * 908 + * Return: destination sideband queue PHY device. 909 + */ 910 + static enum ice_sbq_msg_dev ice_ptp_get_dest_dev_e825(struct ice_hw *hw, 911 + u8 port) 912 + { 913 + /* On a single complex E825, PHY 0 is always destination device phy_0 914 + * and PHY 1 is phy_0_peer. 915 + */ 916 + if (port >= hw->ptp.ports_per_phy) 917 + return eth56g_phy_1; 918 + else 919 + return eth56g_phy_0; 920 + } 921 + 922 + /** 904 923 * ice_write_phy_eth56g - Write a PHY port register 905 924 * @hw: pointer to the HW struct 906 - * @phy_idx: PHY index 925 + * @port: destination port 907 926 * @addr: PHY register address 908 927 * @val: Value to write 909 928 * 910 929 * Return: 0 on success, other error codes when failed to write to PHY 911 930 */ 912 - static int ice_write_phy_eth56g(struct ice_hw *hw, u8 phy_idx, u32 addr, 913 - u32 val) 931 + static int ice_write_phy_eth56g(struct ice_hw *hw, u8 port, u32 addr, u32 val) 914 932 { 915 - struct ice_sbq_msg_input phy_msg; 933 + struct ice_sbq_msg_input msg = { 934 + .dest_dev = ice_ptp_get_dest_dev_e825(hw, port), 935 + .opcode = ice_sbq_msg_wr, 936 + .msg_addr_low = lower_16_bits(addr), 937 + .msg_addr_high = upper_16_bits(addr), 938 + .data = val 939 + }; 916 940 int err; 917 941 918 - phy_msg.opcode = ice_sbq_msg_wr; 919 - 920 - phy_msg.msg_addr_low = lower_16_bits(addr); 921 - phy_msg.msg_addr_high = upper_16_bits(addr); 922 - 923 - phy_msg.data = val; 924 - phy_msg.dest_dev = hw->ptp.phy.eth56g.phy_addr[phy_idx]; 925 - 926 - err = ice_sbq_rw_reg(hw, &phy_msg, ICE_AQ_FLAG_RD); 927 - 942 + err = ice_sbq_rw_reg(hw, &msg, ICE_AQ_FLAG_RD); 928 943 if (err) 929 944 ice_debug(hw, ICE_DBG_PTP, "PTP failed to send msg to phy %d\n", 930 945 err); ··· 950 935 /** 951 936 * ice_read_phy_eth56g - Read a PHY port register 952 937 * @hw: pointer to the HW struct 953 - * @phy_idx: PHY index 938 + * @port: destination port 954 939 * @addr: PHY register address 955 940 * @val: Value to write 956 941 * 957 942 * Return: 0 on success, other error codes when failed to read from PHY 958 943 */ 959 - static int ice_read_phy_eth56g(struct ice_hw *hw, u8 phy_idx, u32 addr, 960 - u32 *val) 944 + static int ice_read_phy_eth56g(struct ice_hw *hw, u8 port, u32 addr, u32 *val) 961 945 { 962 - struct ice_sbq_msg_input phy_msg; 946 + struct ice_sbq_msg_input msg = { 947 + .dest_dev = ice_ptp_get_dest_dev_e825(hw, port), 948 + .opcode = ice_sbq_msg_rd, 949 + .msg_addr_low = lower_16_bits(addr), 950 + .msg_addr_high = upper_16_bits(addr) 951 + }; 963 952 int err; 964 953 965 - phy_msg.opcode = ice_sbq_msg_rd; 966 - 967 - phy_msg.msg_addr_low = lower_16_bits(addr); 968 - phy_msg.msg_addr_high = upper_16_bits(addr); 969 - 970 - phy_msg.data = 0; 971 - phy_msg.dest_dev = hw->ptp.phy.eth56g.phy_addr[phy_idx]; 972 - 973 - err = ice_sbq_rw_reg(hw, &phy_msg, ICE_AQ_FLAG_RD); 974 - if (err) { 954 + err = ice_sbq_rw_reg(hw, &msg, ICE_AQ_FLAG_RD); 955 + if (err) 975 956 ice_debug(hw, ICE_DBG_PTP, "PTP failed to send msg to phy %d\n", 976 957 err); 977 - return err; 978 - } 958 + else 959 + *val = msg.data; 979 960 980 - *val = phy_msg.data; 981 - 982 - return 0; 961 + return err; 983 962 } 984 963 985 964 /** 986 965 * ice_phy_res_address_eth56g - Calculate a PHY port register address 987 - * @port: Port number to be written 966 + * @hw: pointer to the HW struct 967 + * @lane: Lane number to be written 988 968 * @res_type: resource type (register/memory) 989 969 * @offset: Offset from PHY port register base 990 970 * @addr: The result address ··· 988 978 * * %0 - success 989 979 * * %EINVAL - invalid port number or resource type 990 980 */ 991 - static int ice_phy_res_address_eth56g(u8 port, enum eth56g_res_type res_type, 992 - u32 offset, u32 *addr) 981 + static int ice_phy_res_address_eth56g(struct ice_hw *hw, u8 lane, 982 + enum eth56g_res_type res_type, 983 + u32 offset, 984 + u32 *addr) 993 985 { 994 - u8 lane = port % ICE_PORTS_PER_QUAD; 995 - u8 phy = ICE_GET_QUAD_NUM(port); 996 - 997 986 if (res_type >= NUM_ETH56G_PHY_RES) 998 987 return -EINVAL; 999 988 1000 - *addr = eth56g_phy_res[res_type].base[phy] + 989 + /* Lanes 4..7 are in fact 0..3 on a second PHY */ 990 + lane %= hw->ptp.ports_per_phy; 991 + *addr = eth56g_phy_res[res_type].base[0] + 1001 992 lane * eth56g_phy_res[res_type].step + offset; 993 + 1002 994 return 0; 1003 995 } 1004 996 ··· 1020 1008 static int ice_write_port_eth56g(struct ice_hw *hw, u8 port, u32 offset, 1021 1009 u32 val, enum eth56g_res_type res_type) 1022 1010 { 1023 - u8 phy_port = port % hw->ptp.ports_per_phy; 1024 - u8 phy_idx = port / hw->ptp.ports_per_phy; 1025 1011 u32 addr; 1026 1012 int err; 1027 1013 1028 1014 if (port >= hw->ptp.num_lports) 1029 1015 return -EINVAL; 1030 1016 1031 - err = ice_phy_res_address_eth56g(phy_port, res_type, offset, &addr); 1017 + err = ice_phy_res_address_eth56g(hw, port, res_type, offset, &addr); 1032 1018 if (err) 1033 1019 return err; 1034 1020 1035 - return ice_write_phy_eth56g(hw, phy_idx, addr, val); 1021 + return ice_write_phy_eth56g(hw, port, addr, val); 1036 1022 } 1037 1023 1038 1024 /** ··· 1049 1039 static int ice_read_port_eth56g(struct ice_hw *hw, u8 port, u32 offset, 1050 1040 u32 *val, enum eth56g_res_type res_type) 1051 1041 { 1052 - u8 phy_port = port % hw->ptp.ports_per_phy; 1053 - u8 phy_idx = port / hw->ptp.ports_per_phy; 1054 1042 u32 addr; 1055 1043 int err; 1056 1044 1057 1045 if (port >= hw->ptp.num_lports) 1058 1046 return -EINVAL; 1059 1047 1060 - err = ice_phy_res_address_eth56g(phy_port, res_type, offset, &addr); 1048 + err = ice_phy_res_address_eth56g(hw, port, res_type, offset, &addr); 1061 1049 if (err) 1062 1050 return err; 1063 1051 1064 - return ice_read_phy_eth56g(hw, phy_idx, addr, val); 1052 + return ice_read_phy_eth56g(hw, port, addr, val); 1065 1053 } 1066 1054 1067 1055 /** ··· 1206 1198 u32 val) 1207 1199 { 1208 1200 return ice_write_port_eth56g(hw, port, offset, val, ETH56G_PHY_MEM_PTP); 1201 + } 1202 + 1203 + /** 1204 + * ice_write_quad_ptp_reg_eth56g - Write a PHY quad register 1205 + * @hw: pointer to the HW struct 1206 + * @offset: PHY register offset 1207 + * @port: Port number 1208 + * @val: Value to write 1209 + * 1210 + * Return: 1211 + * * %0 - success 1212 + * * %EIO - invalid port number or resource type 1213 + * * %other - failed to write to PHY 1214 + */ 1215 + static int ice_write_quad_ptp_reg_eth56g(struct ice_hw *hw, u8 port, 1216 + u32 offset, u32 val) 1217 + { 1218 + u32 addr; 1219 + 1220 + if (port >= hw->ptp.num_lports) 1221 + return -EIO; 1222 + 1223 + addr = eth56g_phy_res[ETH56G_PHY_REG_PTP].base[0] + offset; 1224 + 1225 + return ice_write_phy_eth56g(hw, port, addr, val); 1226 + } 1227 + 1228 + /** 1229 + * ice_read_quad_ptp_reg_eth56g - Read a PHY quad register 1230 + * @hw: pointer to the HW struct 1231 + * @offset: PHY register offset 1232 + * @port: Port number 1233 + * @val: Value to read 1234 + * 1235 + * Return: 1236 + * * %0 - success 1237 + * * %EIO - invalid port number or resource type 1238 + * * %other - failed to read from PHY 1239 + */ 1240 + static int ice_read_quad_ptp_reg_eth56g(struct ice_hw *hw, u8 port, 1241 + u32 offset, u32 *val) 1242 + { 1243 + u32 addr; 1244 + 1245 + if (port >= hw->ptp.num_lports) 1246 + return -EIO; 1247 + 1248 + addr = eth56g_phy_res[ETH56G_PHY_REG_PTP].base[0] + offset; 1249 + 1250 + return ice_read_phy_eth56g(hw, port, addr, val); 1209 1251 } 1210 1252 1211 1253 /** ··· 1977 1919 */ 1978 1920 static int ice_phy_cfg_parpcs_eth56g(struct ice_hw *hw, u8 port) 1979 1921 { 1980 - u8 port_blk = port & ~(ICE_PORTS_PER_QUAD - 1); 1981 1922 u32 val; 1982 1923 int err; 1983 1924 ··· 1991 1934 switch (ice_phy_get_speed_eth56g(&hw->port_info->phy.link_info)) { 1992 1935 case ICE_ETH56G_LNK_SPD_1G: 1993 1936 case ICE_ETH56G_LNK_SPD_2_5G: 1994 - err = ice_read_ptp_reg_eth56g(hw, port_blk, 1995 - PHY_GPCS_CONFIG_REG0, &val); 1937 + err = ice_read_quad_ptp_reg_eth56g(hw, port, 1938 + PHY_GPCS_CONFIG_REG0, &val); 1996 1939 if (err) { 1997 1940 ice_debug(hw, ICE_DBG_PTP, "Failed to read PHY_GPCS_CONFIG_REG0, status: %d", 1998 1941 err); ··· 2003 1946 val |= FIELD_PREP(PHY_GPCS_CONFIG_REG0_TX_THR_M, 2004 1947 ICE_ETH56G_NOMINAL_TX_THRESH); 2005 1948 2006 - err = ice_write_ptp_reg_eth56g(hw, port_blk, 2007 - PHY_GPCS_CONFIG_REG0, val); 1949 + err = ice_write_quad_ptp_reg_eth56g(hw, port, 1950 + PHY_GPCS_CONFIG_REG0, val); 2008 1951 if (err) { 2009 1952 ice_debug(hw, ICE_DBG_PTP, "Failed to write PHY_GPCS_CONFIG_REG0, status: %d", 2010 1953 err); ··· 2045 1988 */ 2046 1989 int ice_phy_cfg_ptp_1step_eth56g(struct ice_hw *hw, u8 port) 2047 1990 { 2048 - u8 port_blk = port & ~(ICE_PORTS_PER_QUAD - 1); 2049 - u8 blk_port = port & (ICE_PORTS_PER_QUAD - 1); 1991 + u8 quad_lane = port % ICE_PORTS_PER_QUAD; 1992 + u32 addr, val, peer_delay; 2050 1993 bool enable, sfd_ena; 2051 - u32 val, peer_delay; 2052 1994 int err; 2053 1995 2054 1996 enable = hw->ptp.phy.eth56g.onestep_ena; 2055 1997 peer_delay = hw->ptp.phy.eth56g.peer_delay; 2056 1998 sfd_ena = hw->ptp.phy.eth56g.sfd_ena; 2057 1999 2058 - /* PHY_PTP_1STEP_CONFIG */ 2059 - err = ice_read_ptp_reg_eth56g(hw, port_blk, PHY_PTP_1STEP_CONFIG, &val); 2000 + addr = PHY_PTP_1STEP_CONFIG; 2001 + err = ice_read_quad_ptp_reg_eth56g(hw, port, addr, &val); 2060 2002 if (err) 2061 2003 return err; 2062 2004 2063 2005 if (enable) 2064 - val |= blk_port; 2006 + val |= BIT(quad_lane); 2065 2007 else 2066 - val &= ~blk_port; 2008 + val &= ~BIT(quad_lane); 2067 2009 2068 2010 val &= ~(PHY_PTP_1STEP_T1S_UP64_M | PHY_PTP_1STEP_T1S_DELTA_M); 2069 2011 2070 - err = ice_write_ptp_reg_eth56g(hw, port_blk, PHY_PTP_1STEP_CONFIG, val); 2012 + err = ice_write_quad_ptp_reg_eth56g(hw, port, addr, val); 2071 2013 if (err) 2072 2014 return err; 2073 2015 2074 - /* PHY_PTP_1STEP_PEER_DELAY */ 2016 + addr = PHY_PTP_1STEP_PEER_DELAY(quad_lane); 2075 2017 val = FIELD_PREP(PHY_PTP_1STEP_PD_DELAY_M, peer_delay); 2076 2018 if (peer_delay) 2077 2019 val |= PHY_PTP_1STEP_PD_ADD_PD_M; 2078 2020 val |= PHY_PTP_1STEP_PD_DLY_V_M; 2079 - err = ice_write_ptp_reg_eth56g(hw, port_blk, 2080 - PHY_PTP_1STEP_PEER_DELAY(blk_port), val); 2021 + err = ice_write_quad_ptp_reg_eth56g(hw, port, addr, val); 2081 2022 if (err) 2082 2023 return err; 2083 2024 2084 2025 val &= ~PHY_PTP_1STEP_PD_DLY_V_M; 2085 - err = ice_write_ptp_reg_eth56g(hw, port_blk, 2086 - PHY_PTP_1STEP_PEER_DELAY(blk_port), val); 2026 + err = ice_write_quad_ptp_reg_eth56g(hw, port, addr, val); 2087 2027 if (err) 2088 2028 return err; 2089 2029 2090 - /* PHY_MAC_XIF_MODE */ 2091 - err = ice_read_mac_reg_eth56g(hw, port, PHY_MAC_XIF_MODE, &val); 2030 + addr = PHY_MAC_XIF_MODE; 2031 + err = ice_read_mac_reg_eth56g(hw, port, addr, &val); 2092 2032 if (err) 2093 2033 return err; 2094 2034 ··· 2105 2051 FIELD_PREP(PHY_MAC_XIF_TS_BIN_MODE_M, enable) | 2106 2052 FIELD_PREP(PHY_MAC_XIF_TS_SFD_ENA_M, sfd_ena); 2107 2053 2108 - return ice_write_mac_reg_eth56g(hw, port, PHY_MAC_XIF_MODE, val); 2054 + return ice_write_mac_reg_eth56g(hw, port, addr, val); 2109 2055 } 2110 2056 2111 2057 /** ··· 2147 2093 bool fc, bool rs, 2148 2094 enum ice_eth56g_link_spd spd) 2149 2095 { 2150 - u8 port_offset = port & (ICE_PORTS_PER_QUAD - 1); 2151 - u8 port_blk = port & ~(ICE_PORTS_PER_QUAD - 1); 2152 2096 u32 bitslip; 2153 2097 int err; 2154 2098 2155 2099 if (!bs || rs) 2156 2100 return 0; 2157 2101 2158 - if (spd == ICE_ETH56G_LNK_SPD_1G || spd == ICE_ETH56G_LNK_SPD_2_5G) 2102 + if (spd == ICE_ETH56G_LNK_SPD_1G || spd == ICE_ETH56G_LNK_SPD_2_5G) { 2159 2103 err = ice_read_gpcs_reg_eth56g(hw, port, PHY_GPCS_BITSLIP, 2160 2104 &bitslip); 2161 - else 2162 - err = ice_read_ptp_reg_eth56g(hw, port_blk, 2163 - PHY_REG_SD_BIT_SLIP(port_offset), 2164 - &bitslip); 2105 + } else { 2106 + u8 quad_lane = port % ICE_PORTS_PER_QUAD; 2107 + u32 addr; 2108 + 2109 + addr = PHY_REG_SD_BIT_SLIP(quad_lane); 2110 + err = ice_read_quad_ptp_reg_eth56g(hw, port, addr, &bitslip); 2111 + } 2165 2112 if (err) 2166 2113 return 0; 2167 2114 ··· 2722 2667 } 2723 2668 2724 2669 /** 2725 - * ice_is_muxed_topo - detect breakout 2x50G topology for E825C 2726 - * @hw: pointer to the HW struct 2727 - * 2728 - * Return: true if it's 2x50 breakout topology, false otherwise 2729 - */ 2730 - static bool ice_is_muxed_topo(struct ice_hw *hw) 2731 - { 2732 - u8 link_topo; 2733 - bool mux; 2734 - u32 val; 2735 - 2736 - val = rd32(hw, GLGEN_SWITCH_MODE_CONFIG); 2737 - mux = FIELD_GET(GLGEN_SWITCH_MODE_CONFIG_25X4_QUAD_M, val); 2738 - val = rd32(hw, GLGEN_MAC_LINK_TOPO); 2739 - link_topo = FIELD_GET(GLGEN_MAC_LINK_TOPO_LINK_TOPO_M, val); 2740 - 2741 - return (mux && link_topo == ICE_LINK_TOPO_UP_TO_2_LINKS); 2742 - } 2743 - 2744 - /** 2745 - * ice_ptp_init_phy_e825c - initialize PHY parameters 2670 + * ice_ptp_init_phy_e825 - initialize PHY parameters 2746 2671 * @hw: pointer to the HW struct 2747 2672 */ 2748 - static void ice_ptp_init_phy_e825c(struct ice_hw *hw) 2673 + static void ice_ptp_init_phy_e825(struct ice_hw *hw) 2749 2674 { 2750 2675 struct ice_ptp_hw *ptp = &hw->ptp; 2751 2676 struct ice_eth56g_params *params; 2752 - u8 phy; 2677 + u32 phy_rev; 2678 + int err; 2753 2679 2754 2680 ptp->phy_model = ICE_PHY_ETH56G; 2755 2681 params = &ptp->phy.eth56g; 2756 2682 params->onestep_ena = false; 2757 2683 params->peer_delay = 0; 2758 2684 params->sfd_ena = false; 2759 - params->phy_addr[0] = eth56g_phy_0; 2760 - params->phy_addr[1] = eth56g_phy_1; 2761 2685 params->num_phys = 2; 2762 2686 ptp->ports_per_phy = 4; 2763 2687 ptp->num_lports = params->num_phys * ptp->ports_per_phy; 2764 2688 2765 2689 ice_sb_access_ena_eth56g(hw, true); 2766 - for (phy = 0; phy < params->num_phys; phy++) { 2767 - u32 phy_rev; 2768 - int err; 2769 - 2770 - err = ice_read_phy_eth56g(hw, phy, PHY_REG_REVISION, &phy_rev); 2771 - if (err || phy_rev != PHY_REVISION_ETH56G) { 2772 - ptp->phy_model = ICE_PHY_UNSUP; 2773 - return; 2774 - } 2775 - } 2776 - 2777 - ptp->is_2x50g_muxed_topo = ice_is_muxed_topo(hw); 2690 + err = ice_read_phy_eth56g(hw, hw->pf_id, PHY_REG_REVISION, &phy_rev); 2691 + if (err || phy_rev != PHY_REVISION_ETH56G) 2692 + ptp->phy_model = ICE_PHY_UNSUP; 2778 2693 } 2779 2694 2780 2695 /* E822 family functions ··· 2763 2738 struct ice_sbq_msg_input *msg, u8 port, 2764 2739 u16 offset) 2765 2740 { 2766 - int phy_port, phy, quadtype; 2741 + int phy_port, quadtype; 2767 2742 2768 2743 phy_port = port % hw->ptp.ports_per_phy; 2769 - phy = port / hw->ptp.ports_per_phy; 2770 2744 quadtype = ICE_GET_QUAD_NUM(port) % 2771 2745 ICE_GET_QUAD_NUM(hw->ptp.ports_per_phy); 2772 2746 ··· 2777 2753 msg->msg_addr_high = P_Q1_H(P_4_BASE + offset, phy_port); 2778 2754 } 2779 2755 2780 - if (phy == 0) 2781 - msg->dest_dev = rmn_0; 2782 - else if (phy == 1) 2783 - msg->dest_dev = rmn_1; 2784 - else 2785 - msg->dest_dev = rmn_2; 2756 + msg->dest_dev = rmn_0; 2786 2757 } 2787 2758 2788 2759 /** ··· 5497 5478 else if (ice_is_e810(hw)) 5498 5479 ice_ptp_init_phy_e810(ptp); 5499 5480 else if (ice_is_e825c(hw)) 5500 - ice_ptp_init_phy_e825c(hw); 5481 + ice_ptp_init_phy_e825(hw); 5501 5482 else 5502 5483 ptp->phy_model = ICE_PHY_UNSUP; 5503 5484 }
-2
drivers/net/ethernet/intel/ice/ice_type.h
··· 850 850 851 851 struct ice_eth56g_params { 852 852 u8 num_phys; 853 - u8 phy_addr[2]; 854 853 bool onestep_ena; 855 854 bool sfd_ena; 856 855 u32 peer_delay; ··· 880 881 union ice_phy_params phy; 881 882 u8 num_lports; 882 883 u8 ports_per_phy; 883 - bool is_2x50g_muxed_topo; 884 884 }; 885 885 886 886 /* Port hardware description */
+12 -10
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
··· 724 724 /* check esn */ 725 725 if (x->props.flags & XFRM_STATE_ESN) 726 726 mlx5e_ipsec_update_esn_state(sa_entry); 727 + else 728 + /* According to RFC4303, section "3.3.3. Sequence Number Generation", 729 + * the first packet sent using a given SA will contain a sequence 730 + * number of 1. 731 + */ 732 + sa_entry->esn_state.esn = 1; 727 733 728 734 mlx5e_ipsec_build_accel_xfrm_attrs(sa_entry, &sa_entry->attrs); 729 735 ··· 774 768 MLX5_IPSEC_RESCHED); 775 769 776 770 if (x->xso.type == XFRM_DEV_OFFLOAD_PACKET && 777 - x->props.mode == XFRM_MODE_TUNNEL) 778 - xa_set_mark(&ipsec->sadb, sa_entry->ipsec_obj_id, 779 - MLX5E_IPSEC_TUNNEL_SA); 771 + x->props.mode == XFRM_MODE_TUNNEL) { 772 + xa_lock_bh(&ipsec->sadb); 773 + __xa_set_mark(&ipsec->sadb, sa_entry->ipsec_obj_id, 774 + MLX5E_IPSEC_TUNNEL_SA); 775 + xa_unlock_bh(&ipsec->sadb); 776 + } 780 777 781 778 out: 782 779 x->xso.offload_handle = (unsigned long)sa_entry; ··· 806 797 static void mlx5e_xfrm_del_state(struct xfrm_state *x) 807 798 { 808 799 struct mlx5e_ipsec_sa_entry *sa_entry = to_ipsec_sa_entry(x); 809 - struct mlx5_accel_esp_xfrm_attrs *attrs = &sa_entry->attrs; 810 800 struct mlx5e_ipsec *ipsec = sa_entry->ipsec; 811 801 struct mlx5e_ipsec_sa_entry *old; 812 802 ··· 814 806 815 807 old = xa_erase_bh(&ipsec->sadb, sa_entry->ipsec_obj_id); 816 808 WARN_ON(old != sa_entry); 817 - 818 - if (attrs->mode == XFRM_MODE_TUNNEL && 819 - attrs->type == XFRM_DEV_OFFLOAD_PACKET) 820 - /* Make sure that no ARP requests are running in parallel */ 821 - flush_workqueue(ipsec->wq); 822 - 823 809 } 824 810 825 811 static void mlx5e_xfrm_free_state(struct xfrm_state *x)
+5 -7
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
··· 1718 1718 goto err_alloc; 1719 1719 } 1720 1720 1721 - if (attrs->family == AF_INET) 1722 - setup_fte_addr4(spec, &attrs->saddr.a4, &attrs->daddr.a4); 1723 - else 1724 - setup_fte_addr6(spec, attrs->saddr.a6, attrs->daddr.a6); 1725 - 1726 1721 setup_fte_no_frags(spec); 1727 1722 setup_fte_upper_proto_match(spec, &attrs->upspec); 1728 1723 1729 1724 switch (attrs->type) { 1730 1725 case XFRM_DEV_OFFLOAD_CRYPTO: 1726 + if (attrs->family == AF_INET) 1727 + setup_fte_addr4(spec, &attrs->saddr.a4, &attrs->daddr.a4); 1728 + else 1729 + setup_fte_addr6(spec, attrs->saddr.a6, attrs->daddr.a6); 1731 1730 setup_fte_spi(spec, attrs->spi, false); 1732 1731 setup_fte_esp(spec); 1733 1732 setup_fte_reg_a(spec); 1734 1733 break; 1735 1734 case XFRM_DEV_OFFLOAD_PACKET: 1736 - if (attrs->reqid) 1737 - setup_fte_reg_c4(spec, attrs->reqid); 1735 + setup_fte_reg_c4(spec, attrs->reqid); 1738 1736 err = setup_pkt_reformat(ipsec, attrs, &flow_act); 1739 1737 if (err) 1740 1738 goto err_pkt_reformat;
+8 -3
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c
··· 91 91 EXPORT_SYMBOL_GPL(mlx5_ipsec_device_caps); 92 92 93 93 static void mlx5e_ipsec_packet_setup(void *obj, u32 pdn, 94 - struct mlx5_accel_esp_xfrm_attrs *attrs) 94 + struct mlx5e_ipsec_sa_entry *sa_entry) 95 95 { 96 + struct mlx5_accel_esp_xfrm_attrs *attrs = &sa_entry->attrs; 96 97 void *aso_ctx; 97 98 98 99 aso_ctx = MLX5_ADDR_OF(ipsec_obj, obj, ipsec_aso); ··· 121 120 * active. 122 121 */ 123 122 MLX5_SET(ipsec_obj, obj, aso_return_reg, MLX5_IPSEC_ASO_REG_C_4_5); 124 - if (attrs->dir == XFRM_DEV_OFFLOAD_OUT) 123 + if (attrs->dir == XFRM_DEV_OFFLOAD_OUT) { 125 124 MLX5_SET(ipsec_aso, aso_ctx, mode, MLX5_IPSEC_ASO_INC_SN); 125 + if (!attrs->replay_esn.trigger) 126 + MLX5_SET(ipsec_aso, aso_ctx, mode_parameter, 127 + sa_entry->esn_state.esn); 128 + } 126 129 127 130 if (attrs->lft.hard_packet_limit != XFRM_INF) { 128 131 MLX5_SET(ipsec_aso, aso_ctx, remove_flow_pkt_cnt, ··· 180 175 181 176 res = &mdev->mlx5e_res.hw_objs; 182 177 if (attrs->type == XFRM_DEV_OFFLOAD_PACKET) 183 - mlx5e_ipsec_packet_setup(obj, res->pdn, attrs); 178 + mlx5e_ipsec_packet_setup(obj, res->pdn, sa_entry); 184 179 185 180 err = mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out)); 186 181 if (!err)
+1
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
··· 2709 2709 break; 2710 2710 case MLX5_FLOW_NAMESPACE_RDMA_TX: 2711 2711 root_ns = steering->rdma_tx_root_ns; 2712 + prio = RDMA_TX_BYPASS_PRIO; 2712 2713 break; 2713 2714 case MLX5_FLOW_NAMESPACE_RDMA_RX_COUNTERS: 2714 2715 root_ns = steering->rdma_rx_root_ns;
+3 -1
drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
··· 530 530 set_tt_map(port_sel, hash_type); 531 531 err = mlx5_lag_create_definers(ldev, hash_type, ports); 532 532 if (err) 533 - return err; 533 + goto clear_port_sel; 534 534 535 535 if (port_sel->tunnel) { 536 536 err = mlx5_lag_create_inner_ttc_table(ldev); ··· 549 549 mlx5_destroy_ttc_table(port_sel->inner.ttc); 550 550 destroy_definers: 551 551 mlx5_lag_destroy_definers(ldev); 552 + clear_port_sel: 553 + memset(port_sel, 0, sizeof(*port_sel)); 552 554 return err; 553 555 } 554 556
+1
drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c
··· 257 257 return 0; 258 258 259 259 esw_err: 260 + mlx5_sf_function_id_erase(table, sf); 260 261 mlx5_sf_free(table, sf); 261 262 return err; 262 263 }
+12 -12
drivers/net/ethernet/mellanox/mlx5/core/wc.c
··· 382 382 383 383 bool mlx5_wc_support_get(struct mlx5_core_dev *mdev) 384 384 { 385 + struct mutex *wc_state_lock = &mdev->wc_state_lock; 385 386 struct mlx5_core_dev *parent = NULL; 386 387 387 388 if (!MLX5_CAP_GEN(mdev, bf)) { ··· 401 400 */ 402 401 goto out; 403 402 404 - mutex_lock(&mdev->wc_state_lock); 403 + #ifdef CONFIG_MLX5_SF 404 + if (mlx5_core_is_sf(mdev)) { 405 + parent = mdev->priv.parent_mdev; 406 + wc_state_lock = &parent->wc_state_lock; 407 + } 408 + #endif 409 + 410 + mutex_lock(wc_state_lock); 405 411 406 412 if (mdev->wc_state != MLX5_WC_STATE_UNINITIALIZED) 407 413 goto unlock; 408 414 409 - #ifdef CONFIG_MLX5_SF 410 - if (mlx5_core_is_sf(mdev)) 411 - parent = mdev->priv.parent_mdev; 412 - #endif 413 - 414 415 if (parent) { 415 - mutex_lock(&parent->wc_state_lock); 416 - 417 416 mlx5_core_test_wc(parent); 418 417 419 418 mlx5_core_dbg(mdev, "parent set wc_state=%d\n", 420 419 parent->wc_state); 421 420 mdev->wc_state = parent->wc_state; 422 421 423 - mutex_unlock(&parent->wc_state_lock); 422 + } else { 423 + mlx5_core_test_wc(mdev); 424 424 } 425 425 426 - mlx5_core_test_wc(mdev); 427 - 428 426 unlock: 429 - mutex_unlock(&mdev->wc_state_lock); 427 + mutex_unlock(wc_state_lock); 430 428 out: 431 429 mlx5_core_dbg(mdev, "wc_state=%d\n", mdev->wc_state); 432 430
+2 -2
drivers/net/ethernet/microsoft/mana/gdma_main.c
··· 1656 1656 1657 1657 static void __exit mana_driver_exit(void) 1658 1658 { 1659 - debugfs_remove(mana_debugfs_root); 1660 - 1661 1659 pci_unregister_driver(&mana_driver); 1660 + 1661 + debugfs_remove(mana_debugfs_root); 1662 1662 } 1663 1663 1664 1664 module_init(mana_driver_init);
+2 -1
drivers/net/ethernet/netronome/nfp/bpf/offload.c
··· 458 458 map_id_full = be64_to_cpu(cbe->map_ptr); 459 459 map_id = map_id_full; 460 460 461 - if (len < sizeof(struct cmsg_bpf_event) + pkt_size + data_size) 461 + if (size_add(pkt_size, data_size) > INT_MAX || 462 + len < sizeof(struct cmsg_bpf_event) + pkt_size + data_size) 462 463 return -EINVAL; 463 464 if (cbe->hdr.ver != NFP_CCM_ABI_VERSION) 464 465 return -EINVAL;
-44
drivers/net/ethernet/realtek/r8169_main.c
··· 16 16 #include <linux/clk.h> 17 17 #include <linux/delay.h> 18 18 #include <linux/ethtool.h> 19 - #include <linux/hwmon.h> 20 19 #include <linux/phy.h> 21 20 #include <linux/if_vlan.h> 22 21 #include <linux/in.h> ··· 5346 5347 return false; 5347 5348 } 5348 5349 5349 - static umode_t r8169_hwmon_is_visible(const void *drvdata, 5350 - enum hwmon_sensor_types type, 5351 - u32 attr, int channel) 5352 - { 5353 - return 0444; 5354 - } 5355 - 5356 - static int r8169_hwmon_read(struct device *dev, enum hwmon_sensor_types type, 5357 - u32 attr, int channel, long *val) 5358 - { 5359 - struct rtl8169_private *tp = dev_get_drvdata(dev); 5360 - int val_raw; 5361 - 5362 - val_raw = phy_read_paged(tp->phydev, 0xbd8, 0x12) & 0x3ff; 5363 - if (val_raw >= 512) 5364 - val_raw -= 1024; 5365 - 5366 - *val = 1000 * val_raw / 2; 5367 - 5368 - return 0; 5369 - } 5370 - 5371 - static const struct hwmon_ops r8169_hwmon_ops = { 5372 - .is_visible = r8169_hwmon_is_visible, 5373 - .read = r8169_hwmon_read, 5374 - }; 5375 - 5376 - static const struct hwmon_channel_info * const r8169_hwmon_info[] = { 5377 - HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), 5378 - NULL 5379 - }; 5380 - 5381 - static const struct hwmon_chip_info r8169_hwmon_chip_info = { 5382 - .ops = &r8169_hwmon_ops, 5383 - .info = r8169_hwmon_info, 5384 - }; 5385 - 5386 5350 static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 5387 5351 { 5388 5352 struct rtl8169_private *tp; ··· 5525 5563 if (rc) 5526 5564 return rc; 5527 5565 5528 - /* The temperature sensor is available from RTl8125B */ 5529 - if (IS_REACHABLE(CONFIG_HWMON) && tp->mac_version >= RTL_GIGA_MAC_VER_63) 5530 - /* ignore errors */ 5531 - devm_hwmon_device_register_with_info(&pdev->dev, "nic_temp", tp, 5532 - &r8169_hwmon_chip_info, 5533 - NULL); 5534 5566 rc = register_netdev(dev); 5535 5567 if (rc) 5536 5568 return rc;
+1
drivers/net/ethernet/renesas/ravb_main.c
··· 2763 2763 .net_features = NETIF_F_RXCSUM, 2764 2764 .stats_len = ARRAY_SIZE(ravb_gstrings_stats), 2765 2765 .tccr_mask = TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3, 2766 + .tx_max_frame_size = SZ_2K, 2766 2767 .rx_max_frame_size = SZ_2K, 2767 2768 .rx_buffer_size = SZ_2K + 2768 2769 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)),
+7 -7
drivers/net/ethernet/ti/cpsw_ale.c
··· 127 127 128 128 static inline int cpsw_ale_get_field(u32 *ale_entry, u32 start, u32 bits) 129 129 { 130 - int idx, idx2; 130 + int idx, idx2, index; 131 131 u32 hi_val = 0; 132 132 133 133 idx = start / 32; 134 134 idx2 = (start + bits - 1) / 32; 135 135 /* Check if bits to be fetched exceed a word */ 136 136 if (idx != idx2) { 137 - idx2 = 2 - idx2; /* flip */ 138 - hi_val = ale_entry[idx2] << ((idx2 * 32) - start); 137 + index = 2 - idx2; /* flip */ 138 + hi_val = ale_entry[index] << ((idx2 * 32) - start); 139 139 } 140 140 start -= idx * 32; 141 141 idx = 2 - idx; /* flip */ ··· 145 145 static inline void cpsw_ale_set_field(u32 *ale_entry, u32 start, u32 bits, 146 146 u32 value) 147 147 { 148 - int idx, idx2; 148 + int idx, idx2, index; 149 149 150 150 value &= BITMASK(bits); 151 151 idx = start / 32; 152 152 idx2 = (start + bits - 1) / 32; 153 153 /* Check if bits to be set exceed a word */ 154 154 if (idx != idx2) { 155 - idx2 = 2 - idx2; /* flip */ 156 - ale_entry[idx2] &= ~(BITMASK(bits + start - (idx2 * 32))); 157 - ale_entry[idx2] |= (value >> ((idx2 * 32) - start)); 155 + index = 2 - idx2; /* flip */ 156 + ale_entry[index] &= ~(BITMASK(bits + start - (idx2 * 32))); 157 + ale_entry[index] |= (value >> ((idx2 * 32) - start)); 158 158 } 159 159 start -= idx * 32; 160 160 idx = 2 - idx; /* flip */
+6
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
··· 2056 2056 return -EBUSY; 2057 2057 } 2058 2058 2059 + if (ecoalesce->rx_max_coalesced_frames > 255 || 2060 + ecoalesce->tx_max_coalesced_frames > 255) { 2061 + NL_SET_ERR_MSG(extack, "frames must be less than 256"); 2062 + return -EINVAL; 2063 + } 2064 + 2059 2065 if (ecoalesce->rx_max_coalesced_frames) 2060 2066 lp->coalesce_count_rx = ecoalesce->rx_max_coalesced_frames; 2061 2067 if (ecoalesce->rx_coalesce_usecs)
+17 -9
drivers/net/gtp.c
··· 1524 1524 goto out_encap; 1525 1525 } 1526 1526 1527 - gn = net_generic(dev_net(dev), gtp_net_id); 1528 - list_add_rcu(&gtp->list, &gn->gtp_dev_list); 1527 + gn = net_generic(src_net, gtp_net_id); 1528 + list_add(&gtp->list, &gn->gtp_dev_list); 1529 1529 dev->priv_destructor = gtp_destructor; 1530 1530 1531 1531 netdev_dbg(dev, "registered new GTP interface\n"); ··· 1551 1551 hlist_for_each_entry_safe(pctx, next, &gtp->tid_hash[i], hlist_tid) 1552 1552 pdp_context_delete(pctx); 1553 1553 1554 - list_del_rcu(&gtp->list); 1554 + list_del(&gtp->list); 1555 1555 unregister_netdevice_queue(dev, head); 1556 1556 } 1557 1557 ··· 2271 2271 struct gtp_dev *last_gtp = (struct gtp_dev *)cb->args[2], *gtp; 2272 2272 int i, j, bucket = cb->args[0], skip = cb->args[1]; 2273 2273 struct net *net = sock_net(skb->sk); 2274 + struct net_device *dev; 2274 2275 struct pdp_ctx *pctx; 2275 - struct gtp_net *gn; 2276 - 2277 - gn = net_generic(net, gtp_net_id); 2278 2276 2279 2277 if (cb->args[4]) 2280 2278 return 0; 2281 2279 2282 2280 rcu_read_lock(); 2283 - list_for_each_entry_rcu(gtp, &gn->gtp_dev_list, list) { 2281 + for_each_netdev_rcu(net, dev) { 2282 + if (dev->rtnl_link_ops != &gtp_link_ops) 2283 + continue; 2284 + 2285 + gtp = netdev_priv(dev); 2286 + 2284 2287 if (last_gtp && last_gtp != gtp) 2285 2288 continue; 2286 2289 else ··· 2478 2475 2479 2476 list_for_each_entry(net, net_list, exit_list) { 2480 2477 struct gtp_net *gn = net_generic(net, gtp_net_id); 2481 - struct gtp_dev *gtp; 2478 + struct gtp_dev *gtp, *gtp_next; 2479 + struct net_device *dev; 2482 2480 2483 - list_for_each_entry(gtp, &gn->gtp_dev_list, list) 2481 + for_each_netdev(net, dev) 2482 + if (dev->rtnl_link_ops == &gtp_link_ops) 2483 + gtp_dellink(dev, dev_to_kill); 2484 + 2485 + list_for_each_entry_safe(gtp, gtp_next, &gn->gtp_dev_list, list) 2484 2486 gtp_dellink(gtp->dev, dev_to_kill); 2485 2487 } 2486 2488 }
+3 -1
drivers/net/pcs/pcs-xpcs.c
··· 684 684 if (ret < 0) 685 685 return ret; 686 686 687 - mask = DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW; 687 + val = 0; 688 + mask = DW_VR_MII_DIG_CTRL1_2G5_EN | DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW; 689 + 688 690 if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) 689 691 val = DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW; 690 692
+10 -5
drivers/net/pfcp.c
··· 206 206 goto exit_del_pfcp_sock; 207 207 } 208 208 209 - pn = net_generic(dev_net(dev), pfcp_net_id); 210 - list_add_rcu(&pfcp->list, &pn->pfcp_dev_list); 209 + pn = net_generic(net, pfcp_net_id); 210 + list_add(&pfcp->list, &pn->pfcp_dev_list); 211 211 212 212 netdev_dbg(dev, "registered new PFCP interface\n"); 213 213 ··· 224 224 { 225 225 struct pfcp_dev *pfcp = netdev_priv(dev); 226 226 227 - list_del_rcu(&pfcp->list); 227 + list_del(&pfcp->list); 228 228 unregister_netdevice_queue(dev, head); 229 229 } 230 230 ··· 247 247 static void __net_exit pfcp_net_exit(struct net *net) 248 248 { 249 249 struct pfcp_net *pn = net_generic(net, pfcp_net_id); 250 - struct pfcp_dev *pfcp; 250 + struct pfcp_dev *pfcp, *pfcp_next; 251 + struct net_device *dev; 251 252 LIST_HEAD(list); 252 253 253 254 rtnl_lock(); 254 - list_for_each_entry(pfcp, &pn->pfcp_dev_list, list) 255 + for_each_netdev(net, dev) 256 + if (dev->rtnl_link_ops == &pfcp_link_ops) 257 + pfcp_dellink(dev, &list); 258 + 259 + list_for_each_entry_safe(pfcp, pfcp_next, &pn->pfcp_dev_list, list) 255 260 pfcp_dellink(pfcp->dev, &list); 256 261 257 262 unregister_netdevice_many(&list);
-8
include/net/busy_poll.h
··· 174 174 #endif 175 175 } 176 176 177 - static inline void sk_mark_napi_id_once_xdp(struct sock *sk, 178 - const struct xdp_buff *xdp) 179 - { 180 - #ifdef CONFIG_NET_RX_BUSY_POLL 181 - __sk_mark_napi_id_once(sk, xdp->rxq->napi_id); 182 - #endif 183 - } 184 - 185 177 #endif /* _LINUX_NET_BUSY_POLL_H */
+1 -1
include/net/page_pool/helpers.h
··· 294 294 295 295 static inline void page_pool_ref_netmem(netmem_ref netmem) 296 296 { 297 - atomic_long_inc(&netmem_to_page(netmem)->pp_ref_count); 297 + atomic_long_inc(netmem_get_pp_ref_count_ref(netmem)); 298 298 } 299 299 300 300 static inline void page_pool_ref_page(struct page *page)
-1
include/net/xdp.h
··· 62 62 u32 queue_index; 63 63 u32 reg_state; 64 64 struct xdp_mem_info mem; 65 - unsigned int napi_id; 66 65 u32 frag_size; 67 66 } ____cacheline_aligned; /* perf critical, avoid false-sharing */ 68 67
-14
include/net/xdp_sock_drv.h
··· 59 59 xp_fill_cb(pool, desc); 60 60 } 61 61 62 - static inline unsigned int xsk_pool_get_napi_id(struct xsk_buff_pool *pool) 63 - { 64 - #ifdef CONFIG_NET_RX_BUSY_POLL 65 - return pool->heads[0].xdp.rxq->napi_id; 66 - #else 67 - return 0; 68 - #endif 69 - } 70 - 71 62 static inline void xsk_pool_dma_unmap(struct xsk_buff_pool *pool, 72 63 unsigned long attrs) 73 64 { ··· 295 304 static inline void xsk_pool_fill_cb(struct xsk_buff_pool *pool, 296 305 struct xsk_cb_desc *desc) 297 306 { 298 - } 299 - 300 - static inline unsigned int xsk_pool_get_napi_id(struct xsk_buff_pool *pool) 301 - { 302 - return 0; 303 307 } 304 308 305 309 static inline void xsk_pool_dma_unmap(struct xsk_buff_pool *pool,
+18 -12
net/core/filter.c
··· 11251 11251 bool is_sockarray = map->map_type == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY; 11252 11252 struct sock_reuseport *reuse; 11253 11253 struct sock *selected_sk; 11254 + int err; 11254 11255 11255 11256 selected_sk = map->ops->map_lookup_elem(map, key); 11256 11257 if (!selected_sk) ··· 11259 11258 11260 11259 reuse = rcu_dereference(selected_sk->sk_reuseport_cb); 11261 11260 if (!reuse) { 11262 - /* Lookup in sock_map can return TCP ESTABLISHED sockets. */ 11263 - if (sk_is_refcounted(selected_sk)) 11264 - sock_put(selected_sk); 11265 - 11266 11261 /* reuseport_array has only sk with non NULL sk_reuseport_cb. 11267 11262 * The only (!reuse) case here is - the sk has already been 11268 11263 * unhashed (e.g. by close()), so treat it as -ENOENT. ··· 11266 11269 * Other maps (e.g. sock_map) do not provide this guarantee and 11267 11270 * the sk may never be in the reuseport group to begin with. 11268 11271 */ 11269 - return is_sockarray ? -ENOENT : -EINVAL; 11272 + err = is_sockarray ? -ENOENT : -EINVAL; 11273 + goto error; 11270 11274 } 11271 11275 11272 11276 if (unlikely(reuse->reuseport_id != reuse_kern->reuseport_id)) { 11273 11277 struct sock *sk = reuse_kern->sk; 11274 11278 11275 - if (sk->sk_protocol != selected_sk->sk_protocol) 11276 - return -EPROTOTYPE; 11277 - else if (sk->sk_family != selected_sk->sk_family) 11278 - return -EAFNOSUPPORT; 11279 - 11280 - /* Catch all. Likely bound to a different sockaddr. */ 11281 - return -EBADFD; 11279 + if (sk->sk_protocol != selected_sk->sk_protocol) { 11280 + err = -EPROTOTYPE; 11281 + } else if (sk->sk_family != selected_sk->sk_family) { 11282 + err = -EAFNOSUPPORT; 11283 + } else { 11284 + /* Catch all. Likely bound to a different sockaddr. */ 11285 + err = -EBADFD; 11286 + } 11287 + goto error; 11282 11288 } 11283 11289 11284 11290 reuse_kern->selected_sk = selected_sk; 11285 11291 11286 11292 return 0; 11293 + error: 11294 + /* Lookup in sock_map can return TCP ESTABLISHED sockets. */ 11295 + if (sk_is_refcounted(selected_sk)) 11296 + sock_put(selected_sk); 11297 + 11298 + return err; 11287 11299 } 11288 11300 11289 11301 static const struct bpf_func_proto sk_select_reuseport_proto = {
+12 -2
net/core/netdev-genl-gen.c
··· 197 197 [NETDEV_NLGRP_PAGE_POOL] = { "page-pool", }, 198 198 }; 199 199 200 + static void __netdev_nl_sock_priv_init(void *priv) 201 + { 202 + netdev_nl_sock_priv_init(priv); 203 + } 204 + 205 + static void __netdev_nl_sock_priv_destroy(void *priv) 206 + { 207 + netdev_nl_sock_priv_destroy(priv); 208 + } 209 + 200 210 struct genl_family netdev_nl_family __ro_after_init = { 201 211 .name = NETDEV_FAMILY_NAME, 202 212 .version = NETDEV_FAMILY_VERSION, ··· 218 208 .mcgrps = netdev_nl_mcgrps, 219 209 .n_mcgrps = ARRAY_SIZE(netdev_nl_mcgrps), 220 210 .sock_priv_size = sizeof(struct list_head), 221 - .sock_priv_init = (void *)netdev_nl_sock_priv_init, 222 - .sock_priv_destroy = (void *)netdev_nl_sock_priv_destroy, 211 + .sock_priv_init = __netdev_nl_sock_priv_init, 212 + .sock_priv_destroy = __netdev_nl_sock_priv_destroy, 223 213 };
+5 -5
net/core/netpoll.c
··· 627 627 const struct net_device_ops *ops; 628 628 int err; 629 629 630 + skb_queue_head_init(&np->skb_pool); 631 + 630 632 if (ndev->priv_flags & IFF_DISABLE_NETPOLL) { 631 633 np_err(np, "%s doesn't support polling, aborting\n", 632 634 ndev->name); ··· 664 662 strscpy(np->dev_name, ndev->name, IFNAMSIZ); 665 663 npinfo->netpoll = np; 666 664 665 + /* fill up the skb queue */ 666 + refill_skbs(np); 667 + 667 668 /* last thing to do is link it to the net device structure */ 668 669 rcu_assign_pointer(ndev->npinfo, npinfo); 669 670 ··· 685 680 bool ip_overwritten = false; 686 681 struct in_device *in_dev; 687 682 int err; 688 - 689 - skb_queue_head_init(&np->skb_pool); 690 683 691 684 rtnl_lock(); 692 685 if (np->dev_name[0]) { ··· 784 781 #endif 785 782 } 786 783 } 787 - 788 - /* fill up the skb queue */ 789 - refill_skbs(np); 790 784 791 785 err = __netpoll_setup(np, ndev); 792 786 if (err)
+3 -3
net/core/pktgen.c
··· 851 851 unsigned long weight; 852 852 unsigned long size; 853 853 854 + if (pkt_dev->n_imix_entries >= MAX_IMIX_ENTRIES) 855 + return -E2BIG; 856 + 854 857 len = num_arg(&buffer[i], max_digits, &size); 855 858 if (len < 0) 856 859 return len; ··· 883 880 884 881 i++; 885 882 pkt_dev->n_imix_entries++; 886 - 887 - if (pkt_dev->n_imix_entries > MAX_IMIX_ENTRIES) 888 - return -E2BIG; 889 883 } while (c == ' '); 890 884 891 885 return i;
-1
net/core/xdp.c
··· 186 186 xdp_rxq_info_init(xdp_rxq); 187 187 xdp_rxq->dev = dev; 188 188 xdp_rxq->queue_index = queue_index; 189 - xdp_rxq->napi_id = napi_id; 190 189 xdp_rxq->frag_size = frag_size; 191 190 192 191 xdp_rxq->reg_state = REG_STATE_REGISTERED;
+1
net/ipv4/route.c
··· 2445 2445 net_warn_ratelimited("martian destination %pI4 from %pI4, dev %s\n", 2446 2446 &daddr, &saddr, dev->name); 2447 2447 #endif 2448 + goto out; 2448 2449 2449 2450 e_nobufs: 2450 2451 reason = SKB_DROP_REASON_NOMEM;
+27 -19
net/ipv4/udp.c
··· 533 533 return NULL; 534 534 } 535 535 536 - /* In hash4, rehash can happen in connect(), where hash4_cnt keeps unchanged. */ 536 + /* udp_rehash4() only checks hslot4, and hash4_cnt is not processed. */ 537 537 static void udp_rehash4(struct udp_table *udptable, struct sock *sk, 538 538 u16 newhash4) 539 539 { ··· 582 582 struct net *net = sock_net(sk); 583 583 struct udp_table *udptable; 584 584 585 - /* Connected udp socket can re-connect to another remote address, 586 - * so rehash4 is needed. 585 + /* Connected udp socket can re-connect to another remote address, which 586 + * will be handled by rehash. Thus no need to redo hash4 here. 587 587 */ 588 - udptable = net->ipv4.udp_table; 589 - if (udp_hashed4(sk)) { 590 - udp_rehash4(udptable, sk, hash); 588 + if (udp_hashed4(sk)) 591 589 return; 592 - } 593 590 591 + udptable = net->ipv4.udp_table; 594 592 hslot = udp_hashslot(udptable, net, udp_sk(sk)->udp_port_hash); 595 593 hslot2 = udp_hashslot2(udptable, udp_sk(sk)->udp_portaddr_hash); 596 594 hslot4 = udp_hashslot4(udptable, hash); ··· 2171 2173 struct udp_table *udptable = udp_get_table_prot(sk); 2172 2174 struct udp_hslot *hslot, *hslot2, *nhslot2; 2173 2175 2176 + hslot = udp_hashslot(udptable, sock_net(sk), 2177 + udp_sk(sk)->udp_port_hash); 2174 2178 hslot2 = udp_hashslot2(udptable, udp_sk(sk)->udp_portaddr_hash); 2175 2179 nhslot2 = udp_hashslot2(udptable, newhash); 2176 2180 udp_sk(sk)->udp_portaddr_hash = newhash; 2177 2181 2178 2182 if (hslot2 != nhslot2 || 2179 2183 rcu_access_pointer(sk->sk_reuseport_cb)) { 2180 - hslot = udp_hashslot(udptable, sock_net(sk), 2181 - udp_sk(sk)->udp_port_hash); 2182 2184 /* we must lock primary chain too */ 2183 2185 spin_lock_bh(&hslot->lock); 2184 2186 if (rcu_access_pointer(sk->sk_reuseport_cb)) ··· 2197 2199 spin_unlock(&nhslot2->lock); 2198 2200 } 2199 2201 2200 - if (udp_hashed4(sk)) { 2201 - udp_rehash4(udptable, sk, newhash4); 2202 + spin_unlock_bh(&hslot->lock); 2203 + } 2202 2204 2203 - if (hslot2 != nhslot2) { 2204 - spin_lock(&hslot2->lock); 2205 - udp_hash4_dec(hslot2); 2206 - spin_unlock(&hslot2->lock); 2205 + /* Now process hash4 if necessary: 2206 + * (1) update hslot4; 2207 + * (2) update hslot2->hash4_cnt. 2208 + * Note that hslot2/hslot4 should be checked separately, as 2209 + * either of them may change with the other unchanged. 2210 + */ 2211 + if (udp_hashed4(sk)) { 2212 + spin_lock_bh(&hslot->lock); 2207 2213 2208 - spin_lock(&nhslot2->lock); 2209 - udp_hash4_inc(nhslot2); 2210 - spin_unlock(&nhslot2->lock); 2211 - } 2214 + udp_rehash4(udptable, sk, newhash4); 2215 + if (hslot2 != nhslot2) { 2216 + spin_lock(&hslot2->lock); 2217 + udp_hash4_dec(hslot2); 2218 + spin_unlock(&hslot2->lock); 2219 + 2220 + spin_lock(&nhslot2->lock); 2221 + udp_hash4_inc(nhslot2); 2222 + spin_unlock(&nhslot2->lock); 2212 2223 } 2224 + 2213 2225 spin_unlock_bh(&hslot->lock); 2214 2226 } 2215 2227 }
+4 -2
net/mptcp/options.c
··· 607 607 } 608 608 opts->ext_copy.use_ack = 1; 609 609 opts->suboptions = OPTION_MPTCP_DSS; 610 - WRITE_ONCE(msk->old_wspace, __mptcp_space((struct sock *)msk)); 611 610 612 611 /* Add kind/length/subtype/flag overhead if mapping is not populated */ 613 612 if (dss_size == 0) ··· 1287 1288 } 1288 1289 MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDCONFLICT); 1289 1290 } 1290 - return; 1291 + goto update_wspace; 1291 1292 } 1292 1293 1293 1294 if (rcv_wnd_new != rcv_wnd_old) { ··· 1312 1313 th->window = htons(new_win); 1313 1314 MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDSHARED); 1314 1315 } 1316 + 1317 + update_wspace: 1318 + WRITE_ONCE(msk->old_wspace, tp->rcv_wnd); 1315 1319 } 1316 1320 1317 1321 __sum16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum sum)
+7 -2
net/mptcp/protocol.h
··· 760 760 761 761 static inline bool mptcp_epollin_ready(const struct sock *sk) 762 762 { 763 + u64 data_avail = mptcp_data_avail(mptcp_sk(sk)); 764 + 765 + if (!data_avail) 766 + return false; 767 + 763 768 /* mptcp doesn't have to deal with small skbs in the receive queue, 764 - * at it can always coalesce them 769 + * as it can always coalesce them 765 770 */ 766 - return (mptcp_data_avail(mptcp_sk(sk)) >= sk->sk_rcvlowat) || 771 + return (data_avail >= sk->sk_rcvlowat) || 767 772 (mem_cgroup_sockets_enabled && sk->sk_memcg && 768 773 mem_cgroup_under_socket_pressure(sk->sk_memcg)) || 769 774 READ_ONCE(tcp_memory_pressure);
+2
net/ncsi/internal.h
··· 289 289 ncsi_dev_state_config_sp = 0x0301, 290 290 ncsi_dev_state_config_cis, 291 291 ncsi_dev_state_config_oem_gma, 292 + ncsi_dev_state_config_apply_mac, 292 293 ncsi_dev_state_config_clear_vids, 293 294 ncsi_dev_state_config_svf, 294 295 ncsi_dev_state_config_ev, ··· 323 322 #define NCSI_DEV_RESHUFFLE 4 324 323 #define NCSI_DEV_RESET 8 /* Reset state of NC */ 325 324 unsigned int gma_flag; /* OEM GMA flag */ 325 + struct sockaddr pending_mac; /* MAC address received from GMA */ 326 326 spinlock_t lock; /* Protect the NCSI device */ 327 327 unsigned int package_probe_id;/* Current ID during probe */ 328 328 unsigned int package_num; /* Number of packages */
+14 -2
net/ncsi/ncsi-manage.c
··· 1038 1038 : ncsi_dev_state_config_clear_vids; 1039 1039 break; 1040 1040 case ncsi_dev_state_config_oem_gma: 1041 - nd->state = ncsi_dev_state_config_clear_vids; 1041 + nd->state = ncsi_dev_state_config_apply_mac; 1042 1042 1043 1043 nca.package = np->id; 1044 1044 nca.channel = nc->id; ··· 1050 1050 nca.type = NCSI_PKT_CMD_OEM; 1051 1051 ret = ncsi_gma_handler(&nca, nc->version.mf_id); 1052 1052 } 1053 - if (ret < 0) 1053 + if (ret < 0) { 1054 + nd->state = ncsi_dev_state_config_clear_vids; 1054 1055 schedule_work(&ndp->work); 1056 + } 1055 1057 1056 1058 break; 1059 + case ncsi_dev_state_config_apply_mac: 1060 + rtnl_lock(); 1061 + ret = dev_set_mac_address(dev, &ndp->pending_mac, NULL); 1062 + rtnl_unlock(); 1063 + if (ret < 0) 1064 + netdev_warn(dev, "NCSI: 'Writing MAC address to device failed\n"); 1065 + 1066 + nd->state = ncsi_dev_state_config_clear_vids; 1067 + 1068 + fallthrough; 1057 1069 case ncsi_dev_state_config_clear_vids: 1058 1070 case ncsi_dev_state_config_svf: 1059 1071 case ncsi_dev_state_config_ev:
+6 -13
net/ncsi/ncsi-rsp.c
··· 628 628 static int ncsi_rsp_handler_oem_gma(struct ncsi_request *nr, int mfr_id) 629 629 { 630 630 struct ncsi_dev_priv *ndp = nr->ndp; 631 + struct sockaddr *saddr = &ndp->pending_mac; 631 632 struct net_device *ndev = ndp->ndev.dev; 632 633 struct ncsi_rsp_oem_pkt *rsp; 633 - struct sockaddr saddr; 634 634 u32 mac_addr_off = 0; 635 - int ret = 0; 636 635 637 636 /* Get the response header */ 638 637 rsp = (struct ncsi_rsp_oem_pkt *)skb_network_header(nr->rsp); 639 638 640 - saddr.sa_family = ndev->type; 641 639 ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; 642 640 if (mfr_id == NCSI_OEM_MFR_BCM_ID) 643 641 mac_addr_off = BCM_MAC_ADDR_OFFSET; ··· 644 646 else if (mfr_id == NCSI_OEM_MFR_INTEL_ID) 645 647 mac_addr_off = INTEL_MAC_ADDR_OFFSET; 646 648 647 - memcpy(saddr.sa_data, &rsp->data[mac_addr_off], ETH_ALEN); 649 + saddr->sa_family = ndev->type; 650 + memcpy(saddr->sa_data, &rsp->data[mac_addr_off], ETH_ALEN); 648 651 if (mfr_id == NCSI_OEM_MFR_BCM_ID || mfr_id == NCSI_OEM_MFR_INTEL_ID) 649 - eth_addr_inc((u8 *)saddr.sa_data); 650 - if (!is_valid_ether_addr((const u8 *)saddr.sa_data)) 652 + eth_addr_inc((u8 *)saddr->sa_data); 653 + if (!is_valid_ether_addr((const u8 *)saddr->sa_data)) 651 654 return -ENXIO; 652 655 653 656 /* Set the flag for GMA command which should only be called once */ 654 657 ndp->gma_flag = 1; 655 658 656 - rtnl_lock(); 657 - ret = dev_set_mac_address(ndev, &saddr, NULL); 658 - rtnl_unlock(); 659 - if (ret < 0) 660 - netdev_warn(ndev, "NCSI: 'Writing mac address to device failed\n"); 661 - 662 - return ret; 659 + return 0; 663 660 } 664 661 665 662 /* Response handler for Mellanox card */
+3 -1
net/openvswitch/actions.c
··· 934 934 { 935 935 struct vport *vport = ovs_vport_rcu(dp, out_port); 936 936 937 - if (likely(vport && netif_carrier_ok(vport->dev))) { 937 + if (likely(vport && 938 + netif_running(vport->dev) && 939 + netif_carrier_ok(vport->dev))) { 938 940 u16 mru = OVS_CB(skb)->mru; 939 941 u32 cutlen = OVS_CB(skb)->cutlen; 940 942
+18
net/vmw_vsock/af_vsock.c
··· 491 491 */ 492 492 vsk->transport->release(vsk); 493 493 vsock_deassign_transport(vsk); 494 + 495 + /* transport's release() and destruct() can touch some socket 496 + * state, since we are reassigning the socket to a new transport 497 + * during vsock_connect(), let's reset these fields to have a 498 + * clean state. 499 + */ 500 + sock_reset_flag(sk, SOCK_DONE); 501 + sk->sk_state = TCP_CLOSE; 502 + vsk->peer_shutdown = 0; 494 503 } 495 504 496 505 /* We increase the module refcnt to prevent the transport unloading ··· 879 870 880 871 s64 vsock_stream_has_data(struct vsock_sock *vsk) 881 872 { 873 + if (WARN_ON(!vsk->transport)) 874 + return 0; 875 + 882 876 return vsk->transport->stream_has_data(vsk); 883 877 } 884 878 EXPORT_SYMBOL_GPL(vsock_stream_has_data); ··· 889 877 s64 vsock_connectible_has_data(struct vsock_sock *vsk) 890 878 { 891 879 struct sock *sk = sk_vsock(vsk); 880 + 881 + if (WARN_ON(!vsk->transport)) 882 + return 0; 892 883 893 884 if (sk->sk_type == SOCK_SEQPACKET) 894 885 return vsk->transport->seqpacket_has_data(vsk); ··· 902 887 903 888 s64 vsock_stream_has_space(struct vsock_sock *vsk) 904 889 { 890 + if (WARN_ON(!vsk->transport)) 891 + return 0; 892 + 905 893 return vsk->transport->stream_has_space(vsk); 906 894 } 907 895 EXPORT_SYMBOL_GPL(vsock_stream_has_space);
+27 -11
net/vmw_vsock/virtio_transport_common.c
··· 26 26 /* Threshold for detecting small packets to copy */ 27 27 #define GOOD_COPY_LEN 128 28 28 29 + static void virtio_transport_cancel_close_work(struct vsock_sock *vsk, 30 + bool cancel_timeout); 31 + 29 32 static const struct virtio_transport * 30 33 virtio_transport_get_ops(struct vsock_sock *vsk) 31 34 { ··· 1112 1109 { 1113 1110 struct virtio_vsock_sock *vvs = vsk->trans; 1114 1111 1112 + virtio_transport_cancel_close_work(vsk, true); 1113 + 1115 1114 kfree(vvs); 1116 1115 vsk->trans = NULL; 1117 1116 } ··· 1209 1204 } 1210 1205 } 1211 1206 1207 + static void virtio_transport_cancel_close_work(struct vsock_sock *vsk, 1208 + bool cancel_timeout) 1209 + { 1210 + struct sock *sk = sk_vsock(vsk); 1211 + 1212 + if (vsk->close_work_scheduled && 1213 + (!cancel_timeout || cancel_delayed_work(&vsk->close_work))) { 1214 + vsk->close_work_scheduled = false; 1215 + 1216 + virtio_transport_remove_sock(vsk); 1217 + 1218 + /* Release refcnt obtained when we scheduled the timeout */ 1219 + sock_put(sk); 1220 + } 1221 + } 1222 + 1212 1223 static void virtio_transport_do_close(struct vsock_sock *vsk, 1213 1224 bool cancel_timeout) 1214 1225 { ··· 1236 1215 sk->sk_state = TCP_CLOSING; 1237 1216 sk->sk_state_change(sk); 1238 1217 1239 - if (vsk->close_work_scheduled && 1240 - (!cancel_timeout || cancel_delayed_work(&vsk->close_work))) { 1241 - vsk->close_work_scheduled = false; 1242 - 1243 - virtio_transport_remove_sock(vsk); 1244 - 1245 - /* Release refcnt obtained when we scheduled the timeout */ 1246 - sock_put(sk); 1247 - } 1218 + virtio_transport_cancel_close_work(vsk, cancel_timeout); 1248 1219 } 1249 1220 1250 1221 static void virtio_transport_close_timeout(struct work_struct *work) ··· 1641 1628 1642 1629 lock_sock(sk); 1643 1630 1644 - /* Check if sk has been closed before lock_sock */ 1645 - if (sock_flag(sk, SOCK_DONE)) { 1631 + /* Check if sk has been closed or assigned to another transport before 1632 + * lock_sock (note: listener sockets are not assigned to any transport) 1633 + */ 1634 + if (sock_flag(sk, SOCK_DONE) || 1635 + (sk->sk_state != TCP_LISTEN && vsk->transport != &t->transport)) { 1646 1636 (void)virtio_transport_reset_no_sock(t, skb); 1647 1637 release_sock(sk); 1648 1638 sock_put(sk);
+9
net/vmw_vsock/vsock_bpf.c
··· 77 77 size_t len, int flags, int *addr_len) 78 78 { 79 79 struct sk_psock *psock; 80 + struct vsock_sock *vsk; 80 81 int copied; 81 82 82 83 psock = sk_psock_get(sk); ··· 85 84 return __vsock_recvmsg(sk, msg, len, flags); 86 85 87 86 lock_sock(sk); 87 + vsk = vsock_sk(sk); 88 + 89 + if (!vsk->transport) { 90 + copied = -ENODEV; 91 + goto out; 92 + } 93 + 88 94 if (vsock_has_data(sk, psock) && sk_psock_queue_empty(psock)) { 89 95 release_sock(sk); 90 96 sk_psock_put(sk, psock); ··· 116 108 copied = sk_msg_recvmsg(sk, psock, msg, len, flags); 117 109 } 118 110 111 + out: 119 112 release_sock(sk); 120 113 sk_psock_put(sk, psock); 121 114
+9 -5
net/xdp/xsk.c
··· 322 322 return -ENOSPC; 323 323 } 324 324 325 - sk_mark_napi_id_once_xdp(&xs->sk, xdp); 326 325 return 0; 327 326 } 328 327 ··· 907 908 if (unlikely(!xs->tx)) 908 909 return -ENOBUFS; 909 910 910 - if (sk_can_busy_loop(sk)) { 911 - if (xs->zc) 912 - __sk_mark_napi_id_once(sk, xsk_pool_get_napi_id(xs->pool)); 911 + if (sk_can_busy_loop(sk)) 913 912 sk_busy_loop(sk, 1); /* only support non-blocking sockets */ 914 - } 915 913 916 914 if (xs->zc && xsk_no_wakeup(sk)) 917 915 return 0; ··· 1293 1297 xs->sg = !!(xs->umem->flags & XDP_UMEM_SG_FLAG); 1294 1298 xs->queue_id = qid; 1295 1299 xp_add_xsk(xs->pool, xs); 1300 + 1301 + if (xs->zc && qid < dev->real_num_rx_queues) { 1302 + struct netdev_rx_queue *rxq; 1303 + 1304 + rxq = __netif_get_rx_queue(dev, qid); 1305 + if (rxq->napi) 1306 + __sk_mark_napi_id_once(sk, rxq->napi->napi_id); 1307 + } 1296 1308 1297 1309 out_unlock: 1298 1310 if (err) {
+13 -3
tools/net/ynl/ynl-gen-c.py
··· 2384 2384 if not kernel_can_gen_family_struct(family): 2385 2385 return 2386 2386 2387 + if 'sock-priv' in family.kernel_family: 2388 + # Generate "trampolines" to make CFI happy 2389 + cw.write_func("static void", f"__{family.c_name}_nl_sock_priv_init", 2390 + [f"{family.c_name}_nl_sock_priv_init(priv);"], 2391 + ["void *priv"]) 2392 + cw.nl() 2393 + cw.write_func("static void", f"__{family.c_name}_nl_sock_priv_destroy", 2394 + [f"{family.c_name}_nl_sock_priv_destroy(priv);"], 2395 + ["void *priv"]) 2396 + cw.nl() 2397 + 2387 2398 cw.block_start(f"struct genl_family {family.ident_name}_nl_family __ro_after_init =") 2388 2399 cw.p('.name\t\t= ' + family.fam_key + ',') 2389 2400 cw.p('.version\t= ' + family.ver_key + ',') ··· 2412 2401 cw.p(f'.n_mcgrps\t= ARRAY_SIZE({family.c_name}_nl_mcgrps),') 2413 2402 if 'sock-priv' in family.kernel_family: 2414 2403 cw.p(f'.sock_priv_size\t= sizeof({family.kernel_family["sock-priv"]}),') 2415 - # Force cast here, actual helpers take pointer to the real type. 2416 - cw.p(f'.sock_priv_init\t= (void *){family.c_name}_nl_sock_priv_init,') 2417 - cw.p(f'.sock_priv_destroy = (void *){family.c_name}_nl_sock_priv_destroy,') 2404 + cw.p(f'.sock_priv_init\t= __{family.c_name}_nl_sock_priv_init,') 2405 + cw.p(f'.sock_priv_destroy = __{family.c_name}_nl_sock_priv_destroy,') 2418 2406 cw.block_end(';') 2419 2407 2420 2408
+6 -3
tools/testing/selftests/drivers/net/netdevsim/tc-mq-visibility.sh
··· 58 58 ethtool -L $NDEV combined 4 59 59 n_child_assert 4 "One real queue, rest default" 60 60 61 - # Graft some 62 - tcq replace parent 100:1 handle 204: 63 - n_child_assert 3 "Grafted" 61 + # Remove real one 62 + tcq del parent 100:4 handle 204: 63 + 64 + # Replace default with pfifo 65 + tcq replace parent 100:1 handle 205: pfifo limit 1000 66 + n_child_assert 3 "Deleting real one, replacing default one with pfifo" 64 67 65 68 ethtool -L $NDEV combined 1 66 69 n_child_assert 1 "Grafted, one"
+32 -11
tools/testing/selftests/net/mptcp/mptcp_connect.c
··· 25 25 #include <sys/types.h> 26 26 #include <sys/mman.h> 27 27 28 + #include <arpa/inet.h> 29 + 28 30 #include <netdb.h> 29 31 #include <netinet/in.h> 30 32 ··· 1213 1211 exit(1); 1214 1212 } 1215 1213 1216 - void xdisconnect(int fd, int addrlen) 1214 + void xdisconnect(int fd) 1217 1215 { 1218 - struct sockaddr_storage empty; 1216 + socklen_t addrlen = sizeof(struct sockaddr_storage); 1217 + struct sockaddr_storage addr, empty; 1219 1218 int msec_sleep = 10; 1220 - int queued = 1; 1221 - int i; 1219 + void *raw_addr; 1220 + int i, cmdlen; 1221 + char cmd[128]; 1222 + 1223 + /* get the local address and convert it to string */ 1224 + if (getsockname(fd, (struct sockaddr *)&addr, &addrlen) < 0) 1225 + xerror("getsockname"); 1226 + 1227 + if (addr.ss_family == AF_INET) 1228 + raw_addr = &(((struct sockaddr_in *)&addr)->sin_addr); 1229 + else if (addr.ss_family == AF_INET6) 1230 + raw_addr = &(((struct sockaddr_in6 *)&addr)->sin6_addr); 1231 + else 1232 + xerror("bad family"); 1233 + 1234 + strcpy(cmd, "ss -M | grep -q "); 1235 + cmdlen = strlen(cmd); 1236 + if (!inet_ntop(addr.ss_family, raw_addr, &cmd[cmdlen], 1237 + sizeof(cmd) - cmdlen)) 1238 + xerror("inet_ntop"); 1222 1239 1223 1240 shutdown(fd, SHUT_WR); 1224 1241 1225 - /* while until the pending data is completely flushed, the later 1242 + /* 1243 + * wait until the pending data is completely flushed and all 1244 + * the MPTCP sockets reached the closed status. 1226 1245 * disconnect will bypass/ignore/drop any pending data. 1227 1246 */ 1228 1247 for (i = 0; ; i += msec_sleep) { 1229 - if (ioctl(fd, SIOCOUTQ, &queued) < 0) 1230 - xerror("can't query out socket queue: %d", errno); 1231 - 1232 - if (!queued) 1248 + /* closed socket are not listed by 'ss' */ 1249 + if (system(cmd) != 0) 1233 1250 break; 1234 1251 1235 1252 if (i > poll_timeout) ··· 1302 1281 return ret; 1303 1282 1304 1283 if (cfg_truncate > 0) { 1305 - xdisconnect(fd, peer->ai_addrlen); 1284 + xdisconnect(fd); 1306 1285 } else if (--cfg_repeat > 0) { 1307 - xdisconnect(fd, peer->ai_addrlen); 1286 + xdisconnect(fd); 1308 1287 1309 1288 /* the socket could be unblocking at this point, we need the 1310 1289 * connect to be blocking