Pull networking fixes from Jakub Kicinski: "Mostly driver fixes. Current release - regressions: - Revert "net: Add a second bind table hashed by port and address", needs more work - amd-xgbe: use platform_irq_count(), static setup of IRQ resources had been removed from DT core - dts: at91: ksz9477_evb: add phy-mode to fix port/phy validation Current release - new code bugs: - hns3: modify the ring param print info Previous releases - always broken: - axienet: make the 64b addressable DMA depends on 64b architectures - iavf: fix issue with MAC address of VF shown as zero - ice: fix PTP TX timestamp offset calculation - usb: ax88179_178a needs FLAG_SEND_ZLP Misc: - document some net.sctp.* sysctls" * tag 'net-5.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (31 commits) net: axienet: add missing error return code in axienet_probe() Revert "net: Add a second bind table hashed by port and address" net: ax25: Fix deadlock caused by skb_recv_datagram in ax25_recvmsg net: usb: ax88179_178a needs FLAG_SEND_ZLP MAINTAINERS: add include/dt-bindings/net to NETWORKING DRIVERS ARM: dts: at91: ksz9477_evb: fix port/phy validation net: bgmac: Fix an erroneous kfree() in bgmac_remove() ice: Fix memory corruption in VF driver ice: Fix queue config fail handling ice: Sync VLAN filtering features for DVM ice: Fix PTP TX timestamp offset calculation mlxsw: spectrum_cnt: Reorder counter pools docs: networking: phy: Fix a typo amd-xgbe: Use platform_irq_count() octeontx2-vf: Add support for adaptive interrupt coalescing xilinx: Fix build on x86. net: axienet: Use iowrite64 to write all 64b descriptor pointers net: axienet: make the 64b addresable DMA depends on 64b archectures net: hns3: fix tm port shapping of fibre port is incorrect after driver initialization net: hns3: fix PF rss size initialization bug ...
Unified · Split
| @@ -2925,6 +2925,43 @@ plpmtud_probe_interval - INTEGER · 2924 unmodified lines | |||
| 2925 | 2925 | ||
| 2926 | Default: 0 | 2926 | Default: 0 |
| 2927 | 2927 | ||
| 2928 | reconf_enable - BOOLEAN | ||
| 2929 | Enable or disable extension of Stream Reconfiguration functionality | ||
| 2930 | specified in RFC6525. This extension provides the ability to "reset" | ||
| 2931 | a stream, and it includes the Parameters of "Outgoing/Incoming SSN | ||
| 2932 | Reset", "SSN/TSN Reset" and "Add Outgoing/Incoming Streams". | ||
| 2933 | |||
| 2934 | - 1: Enable extension. | ||
| 2935 | - 0: Disable extension. | ||
| 2936 | |||
| 2937 | Default: 0 | ||
| 2938 | |||
| 2939 | intl_enable - BOOLEAN | ||
| 2940 | Enable or disable extension of User Message Interleaving functionality | ||
| 2941 | specified in RFC8260. This extension allows the interleaving of user | ||
| 2942 | messages sent on different streams. With this feature enabled, I-DATA | ||
| 2943 | chunk will replace DATA chunk to carry user messages if also supported | ||
| 2944 | by the peer. Note that to use this feature, one needs to set this option | ||
| 2945 | to 1 and also needs to set socket options SCTP_FRAGMENT_INTERLEAVE to 2 | ||
| 2946 | and SCTP_INTERLEAVING_SUPPORTED to 1. | ||
| 2947 | |||
| 2948 | - 1: Enable extension. | ||
| 2949 | - 0: Disable extension. | ||
| 2950 | |||
| 2951 | Default: 0 | ||
| 2952 | |||
| 2953 | ecn_enable - BOOLEAN | ||
| 2954 | Control use of Explicit Congestion Notification (ECN) by SCTP. | ||
| 2955 | Like in TCP, ECN is used only when both ends of the SCTP connection | ||
| 2956 | indicate support for it. This feature is useful in avoiding losses | ||
| 2957 | due to congestion by allowing supporting routers to signal congestion | ||
| 2958 | before having to drop packets. | ||
| 2959 | |||
| 2960 | 1: Enable ecn. | ||
| 2961 | 0: Disable ecn. | ||
| 2962 | |||
| 2963 | Default: 1 | ||
| 2964 | |||
| 2928 | 2965 | ||
| 2929 | ``/proc/sys/net/core/*`` | 2966 | ``/proc/sys/net/core/*`` |
| 2930 | ======================== | 2967 | ======================== |
| @@ -104,7 +104,7 @@ Whenever possible, use the PHY side RGMII delay for these reasons: · 103 unmodified lines | |||
| 104 | 104 | ||
| 105 | * PHY device drivers in PHYLIB being reusable by nature, being able to | 105 | * PHY device drivers in PHYLIB being reusable by nature, being able to |
| 106 | configure correctly a specified delay enables more designs with similar delay | 106 | configure correctly a specified delay enables more designs with similar delay |
| 107 | requirements to be operate correctly | 107 | requirements to be operated correctly |
| 108 | 108 | ||
| 109 | For cases where the PHY is not capable of providing this delay, but the | 109 | For cases where the PHY is not capable of providing this delay, but the |
| 110 | Ethernet MAC driver is capable of doing so, the correct phy_interface_t value | 110 | Ethernet MAC driver is capable of doing so, the correct phy_interface_t value |
| @@ -13800,6 +13800,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git · 13799 unmodified lines | |||
| 13800 | F: Documentation/devicetree/bindings/net/ | 13800 | F: Documentation/devicetree/bindings/net/ |
| 13801 | F: drivers/connector/ | 13801 | F: drivers/connector/ |
| 13802 | F: drivers/net/ | 13802 | F: drivers/net/ |
| 13803 | F: include/dt-bindings/net/ | ||
| 13803 | F: include/linux/etherdevice.h | 13804 | F: include/linux/etherdevice.h |
| 13804 | F: include/linux/fcdevice.h | 13805 | F: include/linux/fcdevice.h |
| 13805 | F: include/linux/fddidevice.h | 13806 | F: include/linux/fddidevice.h |
| @@ -120,26 +120,31 @@ · 119 unmodified lines | |||
| 120 | port@0 { | 120 | port@0 { |
| 121 | reg = <0>; | 121 | reg = <0>; |
| 122 | label = "lan1"; | 122 | label = "lan1"; |
| 123 | phy-mode = "internal"; | ||
| 123 | }; | 124 | }; |
| 124 | 125 | ||
| 125 | port@1 { | 126 | port@1 { |
| 126 | reg = <1>; | 127 | reg = <1>; |
| 127 | label = "lan2"; | 128 | label = "lan2"; |
| 129 | phy-mode = "internal"; | ||
| 128 | }; | 130 | }; |
| 129 | 131 | ||
| 130 | port@2 { | 132 | port@2 { |
| 131 | reg = <2>; | 133 | reg = <2>; |
| 132 | label = "lan3"; | 134 | label = "lan3"; |
| 135 | phy-mode = "internal"; | ||
| 133 | }; | 136 | }; |
| 134 | 137 | ||
| 135 | port@3 { | 138 | port@3 { |
| 136 | reg = <3>; | 139 | reg = <3>; |
| 137 | label = "lan4"; | 140 | label = "lan4"; |
| 141 | phy-mode = "internal"; | ||
| 138 | }; | 142 | }; |
| 139 | 143 | ||
| 140 | port@4 { | 144 | port@4 { |
| 141 | reg = <4>; | 145 | reg = <4>; |
| 142 | label = "lan5"; | 146 | label = "lan5"; |
| 147 | phy-mode = "internal"; | ||
| 143 | }; | 148 | }; |
| 144 | 149 | ||
| 145 | port@5 { | 150 | port@5 { |
| @@ -338,7 +338,7 @@ static int xgbe_platform_probe(struct platform_device *pdev) · 337 unmodified lines | |||
| 338 | * the PHY resources listed last | 338 | * the PHY resources listed last |
| 339 | */ | 339 | */ |
| 340 | phy_memnum = xgbe_resource_count(pdev, IORESOURCE_MEM) - 3; | 340 | phy_memnum = xgbe_resource_count(pdev, IORESOURCE_MEM) - 3; |
| 341 | phy_irqnum = xgbe_resource_count(pdev, IORESOURCE_IRQ) - 1; | 341 | phy_irqnum = platform_irq_count(pdev) - 1; |
| 342 | dma_irqnum = 1; | 342 | dma_irqnum = 1; |
| 343 | dma_irqend = phy_irqnum; | 343 | dma_irqend = phy_irqnum; |
| 344 | } else { | 344 | } else { |
| @@ -348,7 +348,7 @@ static int xgbe_platform_probe(struct platform_device *pdev) · 3 unmodified lines | |||
| 348 | phy_memnum = 0; | 348 | phy_memnum = 0; |
| 349 | phy_irqnum = 0; | 349 | phy_irqnum = 0; |
| 350 | dma_irqnum = 1; | 350 | dma_irqnum = 1; |
| 351 | dma_irqend = xgbe_resource_count(pdev, IORESOURCE_IRQ); | 351 | dma_irqend = platform_irq_count(pdev); |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | /* Obtain the mmio areas for the device */ | 354 | /* Obtain the mmio areas for the device */ |
| @@ -332,7 +332,6 @@ static void bgmac_remove(struct bcma_device *core) · 331 unmodified lines | |||
| 332 | bcma_mdio_mii_unregister(bgmac->mii_bus); | 332 | bcma_mdio_mii_unregister(bgmac->mii_bus); |
| 333 | bgmac_enet_remove(bgmac); | 333 | bgmac_enet_remove(bgmac); |
| 334 | bcma_set_drvdata(core, NULL); | 334 | bcma_set_drvdata(core, NULL); |
| 335 | kfree(bgmac); | ||
| 336 | } | 335 | } |
| 337 | 336 | ||
| 338 | static struct bcma_driver bgmac_bcma_driver = { | 337 | static struct bcma_driver bgmac_bcma_driver = { |
| @@ -769,6 +769,7 @@ struct hnae3_tc_info { · 768 unmodified lines | |||
| 769 | u8 prio_tc[HNAE3_MAX_USER_PRIO]; /* TC indexed by prio */ | 769 | u8 prio_tc[HNAE3_MAX_USER_PRIO]; /* TC indexed by prio */ |
| 770 | u16 tqp_count[HNAE3_MAX_TC]; | 770 | u16 tqp_count[HNAE3_MAX_TC]; |
| 771 | u16 tqp_offset[HNAE3_MAX_TC]; | 771 | u16 tqp_offset[HNAE3_MAX_TC]; |
| 772 | u8 max_tc; /* Total number of TCs */ | ||
| 772 | u8 num_tc; /* Total number of enabled TCs */ | 773 | u8 num_tc; /* Total number of enabled TCs */ |
| 773 | bool mqprio_active; | 774 | bool mqprio_active; |
| 774 | }; | 775 | }; |
| @@ -1129,7 +1129,7 @@ hns3_is_ringparam_changed(struct net_device *ndev, · 1128 unmodified lines | |||
| 1129 | if (old_ringparam->tx_desc_num == new_ringparam->tx_desc_num && | 1129 | if (old_ringparam->tx_desc_num == new_ringparam->tx_desc_num && |
| 1130 | old_ringparam->rx_desc_num == new_ringparam->rx_desc_num && | 1130 | old_ringparam->rx_desc_num == new_ringparam->rx_desc_num && |
| 1131 | old_ringparam->rx_buf_len == new_ringparam->rx_buf_len) { | 1131 | old_ringparam->rx_buf_len == new_ringparam->rx_buf_len) { |
| 1132 | netdev_info(ndev, "ringparam not changed\n"); | 1132 | netdev_info(ndev, "descriptor number and rx buffer length not changed\n"); |
| 1133 | return false; | 1133 | return false; |
| 1134 | } | 1134 | } |
| 1135 | 1135 | ||
| @@ -3268,7 +3268,7 @@ static int hclge_tp_port_init(struct hclge_dev *hdev) · 3267 unmodified lines | |||
| 3268 | static int hclge_update_port_info(struct hclge_dev *hdev) | 3268 | static int hclge_update_port_info(struct hclge_dev *hdev) |
| 3269 | { | 3269 | { |
| 3270 | struct hclge_mac *mac = &hdev->hw.mac; | 3270 | struct hclge_mac *mac = &hdev->hw.mac; |
| 3271 | int speed = HCLGE_MAC_SPEED_UNKNOWN; | 3271 | int speed; |
| 3272 | int ret; | 3272 | int ret; |
| 3273 | 3273 | ||
| 3274 | /* get the port info from SFP cmd if not copper port */ | 3274 | /* get the port info from SFP cmd if not copper port */ |
| @@ -3279,10 +3279,13 @@ static int hclge_update_port_info(struct hclge_dev *hdev) · 4 unmodified lines | |||
| 3279 | if (!hdev->support_sfp_query) | 3279 | if (!hdev->support_sfp_query) |
| 3280 | return 0; | 3280 | return 0; |
| 3281 | 3281 | ||
| 3282 | if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) | 3282 | if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) { |
| 3283 | speed = mac->speed; | ||
| 3283 | ret = hclge_get_sfp_info(hdev, mac); | 3284 | ret = hclge_get_sfp_info(hdev, mac); |
| 3284 | else | 3285 | } else { |
| 3286 | speed = HCLGE_MAC_SPEED_UNKNOWN; | ||
| 3285 | ret = hclge_get_sfp_speed(hdev, &speed); | 3287 | ret = hclge_get_sfp_speed(hdev, &speed); |
| 3288 | } | ||
| 3286 | 3289 | ||
| 3287 | if (ret == -EOPNOTSUPP) { | 3290 | if (ret == -EOPNOTSUPP) { |
| 3288 | hdev->support_sfp_query = false; | 3291 | hdev->support_sfp_query = false; |
| @@ -3294,6 +3297,8 @@ static int hclge_update_port_info(struct hclge_dev *hdev) · 5 unmodified lines | |||
| 3294 | if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) { | 3297 | if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) { |
| 3295 | if (mac->speed_type == QUERY_ACTIVE_SPEED) { | 3298 | if (mac->speed_type == QUERY_ACTIVE_SPEED) { |
| 3296 | hclge_update_port_capability(hdev, mac); | 3299 | hclge_update_port_capability(hdev, mac); |
| 3300 | if (mac->speed != speed) | ||
| 3301 | (void)hclge_tm_port_shaper_cfg(hdev); | ||
| 3297 | return 0; | 3302 | return 0; |
| 3298 | } | 3303 | } |
| 3299 | return hclge_cfg_mac_speed_dup(hdev, mac->speed, | 3304 | return hclge_cfg_mac_speed_dup(hdev, mac->speed, |
| @@ -3376,6 +3381,12 @@ static int hclge_set_vf_link_state(struct hnae3_handle *handle, int vf, · 76 unmodified lines | |||
| 3376 | link_state_old = vport->vf_info.link_state; | 3381 | link_state_old = vport->vf_info.link_state; |
| 3377 | vport->vf_info.link_state = link_state; | 3382 | vport->vf_info.link_state = link_state; |
| 3378 | 3383 | ||
| 3384 | /* return success directly if the VF is unalive, VF will | ||
| 3385 | * query link state itself when it starts work. | ||
| 3386 | */ | ||
| 3387 | if (!test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) | ||
| 3388 | return 0; | ||
| 3389 | |||
| 3379 | ret = hclge_push_vf_link_status(vport); | 3390 | ret = hclge_push_vf_link_status(vport); |
| 3380 | if (ret) { | 3391 | if (ret) { |
| 3381 | vport->vf_info.link_state = link_state_old; | 3392 | vport->vf_info.link_state = link_state_old; |
| @@ -10117,6 +10128,7 @@ static int hclge_modify_port_base_vlan_tag(struct hclge_vport *vport, · 6735 unmodified lines | |||
| 10117 | if (ret) | 10128 | if (ret) |
| 10118 | return ret; | 10129 | return ret; |
| 10119 | 10130 | ||
| 10131 | vport->port_base_vlan_cfg.tbl_sta = false; | ||
| 10120 | /* remove old VLAN tag */ | 10132 | /* remove old VLAN tag */ |
| 10121 | if (old_info->vlan_tag == 0) | 10133 | if (old_info->vlan_tag == 0) |
| 10122 | ret = hclge_set_vf_vlan_common(hdev, vport->vport_id, | 10134 | ret = hclge_set_vf_vlan_common(hdev, vport->vport_id, |
| @@ -282,8 +282,8 @@ static int hclge_tm_pg_to_pri_map_cfg(struct hclge_dev *hdev, · 281 unmodified lines | |||
| 282 | return hclge_cmd_send(&hdev->hw, &desc, 1); | 282 | return hclge_cmd_send(&hdev->hw, &desc, 1); |
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | static int hclge_tm_qs_to_pri_map_cfg(struct hclge_dev *hdev, | 285 | static int hclge_tm_qs_to_pri_map_cfg(struct hclge_dev *hdev, u16 qs_id, u8 pri, |
| 286 | u16 qs_id, u8 pri) | 286 | bool link_vld) |
| 287 | { | 287 | { |
| 288 | struct hclge_qs_to_pri_link_cmd *map; | 288 | struct hclge_qs_to_pri_link_cmd *map; |
| 289 | struct hclge_desc desc; | 289 | struct hclge_desc desc; |
| @@ -294,7 +294,7 @@ static int hclge_tm_qs_to_pri_map_cfg(struct hclge_dev *hdev, · 4 unmodified lines | |||
| 294 | 294 | ||
| 295 | map->qs_id = cpu_to_le16(qs_id); | 295 | map->qs_id = cpu_to_le16(qs_id); |
| 296 | map->priority = pri; | 296 | map->priority = pri; |
| 297 | map->link_vld = HCLGE_TM_QS_PRI_LINK_VLD_MSK; | 297 | map->link_vld = link_vld ? HCLGE_TM_QS_PRI_LINK_VLD_MSK : 0; |
| 298 | 298 | ||
| 299 | return hclge_cmd_send(&hdev->hw, &desc, 1); | 299 | return hclge_cmd_send(&hdev->hw, &desc, 1); |
| 300 | } | 300 | } |
| @@ -420,7 +420,7 @@ static int hclge_tm_pg_shapping_cfg(struct hclge_dev *hdev, · 119 unmodified lines | |||
| 420 | return hclge_cmd_send(&hdev->hw, &desc, 1); | 420 | return hclge_cmd_send(&hdev->hw, &desc, 1); |
| 421 | } | 421 | } |
| 422 | 422 | ||
| 423 | static int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev) | 423 | int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev) |
| 424 | { | 424 | { |
| 425 | struct hclge_port_shapping_cmd *shap_cfg_cmd; | 425 | struct hclge_port_shapping_cmd *shap_cfg_cmd; |
| 426 | struct hclge_shaper_ir_para ir_para; | 426 | struct hclge_shaper_ir_para ir_para; |
| @@ -642,11 +642,13 @@ static void hclge_tm_update_kinfo_rss_size(struct hclge_vport *vport) · 215 unmodified lines | |||
| 642 | * one tc for VF for simplicity. VF's vport_id is non zero. | 642 | * one tc for VF for simplicity. VF's vport_id is non zero. |
| 643 | */ | 643 | */ |
| 644 | if (vport->vport_id) { | 644 | if (vport->vport_id) { |
| 645 | kinfo->tc_info.max_tc = 1; | ||
| 645 | kinfo->tc_info.num_tc = 1; | 646 | kinfo->tc_info.num_tc = 1; |
| 646 | vport->qs_offset = HNAE3_MAX_TC + | 647 | vport->qs_offset = HNAE3_MAX_TC + |
| 647 | vport->vport_id - HCLGE_VF_VPORT_START_NUM; | 648 | vport->vport_id - HCLGE_VF_VPORT_START_NUM; |
| 648 | vport_max_rss_size = hdev->vf_rss_size_max; | 649 | vport_max_rss_size = hdev->vf_rss_size_max; |
| 649 | } else { | 650 | } else { |
| 651 | kinfo->tc_info.max_tc = hdev->tc_max; | ||
| 650 | kinfo->tc_info.num_tc = | 652 | kinfo->tc_info.num_tc = |
| 651 | min_t(u16, vport->alloc_tqps, hdev->tm_info.num_tc); | 653 | min_t(u16, vport->alloc_tqps, hdev->tm_info.num_tc); |
| 652 | vport->qs_offset = 0; | 654 | vport->qs_offset = 0; |
| @@ -679,7 +681,9 @@ static void hclge_tm_vport_tc_info_update(struct hclge_vport *vport) · 26 unmodified lines | |||
| 679 | kinfo->num_tqps = hclge_vport_get_tqp_num(vport); | 681 | kinfo->num_tqps = hclge_vport_get_tqp_num(vport); |
| 680 | vport->dwrr = 100; /* 100 percent as init */ | 682 | vport->dwrr = 100; /* 100 percent as init */ |
| 681 | vport->bw_limit = hdev->tm_info.pg_info[0].bw_limit; | 683 | vport->bw_limit = hdev->tm_info.pg_info[0].bw_limit; |
| 682 | hdev->rss_cfg.rss_size = kinfo->rss_size; | 684 | |
| 685 | if (vport->vport_id == PF_VPORT_ID) | ||
| 686 | hdev->rss_cfg.rss_size = kinfo->rss_size; | ||
| 683 | 687 | ||
| 684 | /* when enable mqprio, the tc_info has been updated. */ | 688 | /* when enable mqprio, the tc_info has been updated. */ |
| 685 | if (kinfo->tc_info.mqprio_active) | 689 | if (kinfo->tc_info.mqprio_active) |
| @@ -714,14 +718,22 @@ static void hclge_tm_vport_info_update(struct hclge_dev *hdev) · 28 unmodified lines | |||
| 714 | 718 | ||
| 715 | static void hclge_tm_tc_info_init(struct hclge_dev *hdev) | 719 | static void hclge_tm_tc_info_init(struct hclge_dev *hdev) |
| 716 | { | 720 | { |
| 717 | u8 i; | 721 | u8 i, tc_sch_mode; |
| 722 | u32 bw_limit; | ||
| 723 | |||
| 724 | for (i = 0; i < hdev->tc_max; i++) { | ||
| 725 | if (i < hdev->tm_info.num_tc) { | ||
| 726 | tc_sch_mode = HCLGE_SCH_MODE_DWRR; | ||
| 727 | bw_limit = hdev->tm_info.pg_info[0].bw_limit; | ||
| 728 | } else { | ||
| 729 | tc_sch_mode = HCLGE_SCH_MODE_SP; | ||
| 730 | bw_limit = 0; | ||
| 731 | } | ||
| 718 | 732 | ||
| 719 | for (i = 0; i < hdev->tm_info.num_tc; i++) { | ||
| 720 | hdev->tm_info.tc_info[i].tc_id = i; | 733 | hdev->tm_info.tc_info[i].tc_id = i; |
| 721 | hdev->tm_info.tc_info[i].tc_sch_mode = HCLGE_SCH_MODE_DWRR; | 734 | hdev->tm_info.tc_info[i].tc_sch_mode = tc_sch_mode; |
| 722 | hdev->tm_info.tc_info[i].pgid = 0; | 735 | hdev->tm_info.tc_info[i].pgid = 0; |
| 723 | hdev->tm_info.tc_info[i].bw_limit = | 736 | hdev->tm_info.tc_info[i].bw_limit = bw_limit; |
| 724 | hdev->tm_info.pg_info[0].bw_limit; | ||
| 725 | } | 737 | } |
| 726 | 738 | ||
| 727 | for (i = 0; i < HNAE3_MAX_USER_PRIO; i++) | 739 | for (i = 0; i < HNAE3_MAX_USER_PRIO; i++) |
| @@ -926,10 +938,13 @@ static int hclge_tm_pri_q_qs_cfg_tc_base(struct hclge_dev *hdev) · 198 unmodified lines | |||
| 926 | for (k = 0; k < hdev->num_alloc_vport; k++) { | 938 | for (k = 0; k < hdev->num_alloc_vport; k++) { |
| 927 | struct hnae3_knic_private_info *kinfo = &vport[k].nic.kinfo; | 939 | struct hnae3_knic_private_info *kinfo = &vport[k].nic.kinfo; |
| 928 | 940 | ||
| 929 | for (i = 0; i < kinfo->tc_info.num_tc; i++) { | 941 | for (i = 0; i < kinfo->tc_info.max_tc; i++) { |
| 942 | u8 pri = i < kinfo->tc_info.num_tc ? i : 0; | ||
| 943 | bool link_vld = i < kinfo->tc_info.num_tc; | ||
| 944 | |||
| 930 | ret = hclge_tm_qs_to_pri_map_cfg(hdev, | 945 | ret = hclge_tm_qs_to_pri_map_cfg(hdev, |
| 931 | vport[k].qs_offset + i, | 946 | vport[k].qs_offset + i, |
| 932 | i); | 947 | pri, link_vld); |
| 933 | if (ret) | 948 | if (ret) |
| 934 | return ret; | 949 | return ret; |
| 935 | } | 950 | } |
| @@ -949,7 +964,7 @@ static int hclge_tm_pri_q_qs_cfg_vnet_base(struct hclge_dev *hdev) · 13 unmodified lines | |||
| 949 | for (i = 0; i < HNAE3_MAX_TC; i++) { | 964 | for (i = 0; i < HNAE3_MAX_TC; i++) { |
| 950 | ret = hclge_tm_qs_to_pri_map_cfg(hdev, | 965 | ret = hclge_tm_qs_to_pri_map_cfg(hdev, |
| 951 | vport[k].qs_offset + i, | 966 | vport[k].qs_offset + i, |
| 952 | k); | 967 | k, true); |
| 953 | if (ret) | 968 | if (ret) |
| 954 | return ret; | 969 | return ret; |
| 955 | } | 970 | } |
| @@ -989,33 +1004,39 @@ static int hclge_tm_pri_tc_base_shaper_cfg(struct hclge_dev *hdev) · 33 unmodified lines | |||
| 989 | { | 1004 | { |
| 990 | u32 max_tm_rate = hdev->ae_dev->dev_specs.max_tm_rate; | 1005 | u32 max_tm_rate = hdev->ae_dev->dev_specs.max_tm_rate; |
| 991 | struct hclge_shaper_ir_para ir_para; | 1006 | struct hclge_shaper_ir_para ir_para; |
| 992 | u32 shaper_para; | 1007 | u32 shaper_para_c, shaper_para_p; |
| 993 | int ret; | 1008 | int ret; |
| 994 | u32 i; | 1009 | u32 i; |
| 995 | 1010 | ||
| 996 | for (i = 0; i < hdev->tm_info.num_tc; i++) { | 1011 | for (i = 0; i < hdev->tc_max; i++) { |
| 997 | u32 rate = hdev->tm_info.tc_info[i].bw_limit; | 1012 | u32 rate = hdev->tm_info.tc_info[i].bw_limit; |
| 998 | 1013 | ||
| 999 | ret = hclge_shaper_para_calc(rate, HCLGE_SHAPER_LVL_PRI, | 1014 | if (rate) { |
| 1000 | &ir_para, max_tm_rate); | 1015 | ret = hclge_shaper_para_calc(rate, HCLGE_SHAPER_LVL_PRI, |
| 1001 | if (ret) | 1016 | &ir_para, max_tm_rate); |
| 1002 | return ret; | 1017 | if (ret) |
| 1018 | return ret; | ||
| 1019 | |||
| 1020 | shaper_para_c = hclge_tm_get_shapping_para(0, 0, 0, | ||
| 1021 | HCLGE_SHAPER_BS_U_DEF, | ||
| 1022 | HCLGE_SHAPER_BS_S_DEF); | ||
| 1023 | shaper_para_p = hclge_tm_get_shapping_para(ir_para.ir_b, | ||
| 1024 | ir_para.ir_u, | ||
| 1025 | ir_para.ir_s, | ||
| 1026 | HCLGE_SHAPER_BS_U_DEF, | ||
| 1027 | HCLGE_SHAPER_BS_S_DEF); | ||
| 1028 | } else { | ||
| 1029 | shaper_para_c = 0; | ||
| 1030 | shaper_para_p = 0; | ||
| 1031 | } | ||
| 1003 | 1032 | ||
| 1004 | shaper_para = hclge_tm_get_shapping_para(0, 0, 0, | ||
| 1005 | HCLGE_SHAPER_BS_U_DEF, | ||
| 1006 | HCLGE_SHAPER_BS_S_DEF); | ||
| 1007 | ret = hclge_tm_pri_shapping_cfg(hdev, HCLGE_TM_SHAP_C_BUCKET, i, | 1033 | ret = hclge_tm_pri_shapping_cfg(hdev, HCLGE_TM_SHAP_C_BUCKET, i, |
| 1008 | shaper_para, rate); | 1034 | shaper_para_c, rate); |
| 1009 | if (ret) | 1035 | if (ret) |
| 1010 | return ret; | 1036 | return ret; |
| 1011 | 1037 | ||
| 1012 | shaper_para = hclge_tm_get_shapping_para(ir_para.ir_b, | ||
| 1013 | ir_para.ir_u, | ||
| 1014 | ir_para.ir_s, | ||
| 1015 | HCLGE_SHAPER_BS_U_DEF, | ||
| 1016 | HCLGE_SHAPER_BS_S_DEF); | ||
| 1017 | ret = hclge_tm_pri_shapping_cfg(hdev, HCLGE_TM_SHAP_P_BUCKET, i, | 1038 | ret = hclge_tm_pri_shapping_cfg(hdev, HCLGE_TM_SHAP_P_BUCKET, i, |
| 1018 | shaper_para, rate); | 1039 | shaper_para_p, rate); |
| 1019 | if (ret) | 1040 | if (ret) |
| 1020 | return ret; | 1041 | return ret; |
| 1021 | } | 1042 | } |
| @@ -1125,7 +1146,7 @@ static int hclge_tm_pri_tc_base_dwrr_cfg(struct hclge_dev *hdev) · 103 unmodified lines | |||
| 1125 | int ret; | 1146 | int ret; |
| 1126 | u32 i, k; | 1147 | u32 i, k; |
| 1127 | 1148 | ||
| 1128 | for (i = 0; i < hdev->tm_info.num_tc; i++) { | 1149 | for (i = 0; i < hdev->tc_max; i++) { |
| 1129 | pg_info = | 1150 | pg_info = |
| 1130 | &hdev->tm_info.pg_info[hdev->tm_info.tc_info[i].pgid]; | 1151 | &hdev->tm_info.pg_info[hdev->tm_info.tc_info[i].pgid]; |
| 1131 | dwrr = pg_info->tc_dwrr[i]; | 1152 | dwrr = pg_info->tc_dwrr[i]; |
| @@ -1135,9 +1156,15 @@ static int hclge_tm_pri_tc_base_dwrr_cfg(struct hclge_dev *hdev) · 3 unmodified lines | |||
| 1135 | return ret; | 1156 | return ret; |
| 1136 | 1157 | ||
| 1137 | for (k = 0; k < hdev->num_alloc_vport; k++) { | 1158 | for (k = 0; k < hdev->num_alloc_vport; k++) { |
| 1159 | struct hnae3_knic_private_info *kinfo = &vport[k].nic.kinfo; | ||
| 1160 | |||
| 1161 | if (i >= kinfo->tc_info.max_tc) | ||
| 1162 | continue; | ||
| 1163 | |||
| 1164 | dwrr = i < kinfo->tc_info.num_tc ? vport[k].dwrr : 0; | ||
| 1138 | ret = hclge_tm_qs_weight_cfg( | 1165 | ret = hclge_tm_qs_weight_cfg( |
| 1139 | hdev, vport[k].qs_offset + i, | 1166 | hdev, vport[k].qs_offset + i, |
| 1140 | vport[k].dwrr); | 1167 | dwrr); |
| 1141 | if (ret) | 1168 | if (ret) |
| 1142 | return ret; | 1169 | return ret; |
| 1143 | } | 1170 | } |
| @@ -1303,6 +1330,7 @@ static int hclge_tm_schd_mode_tc_base_cfg(struct hclge_dev *hdev, u8 pri_id) · 159 unmodified lines | |||
| 1303 | { | 1330 | { |
| 1304 | struct hclge_vport *vport = hdev->vport; | 1331 | struct hclge_vport *vport = hdev->vport; |
| 1305 | int ret; | 1332 | int ret; |
| 1333 | u8 mode; | ||
| 1306 | u16 i; | 1334 | u16 i; |
| 1307 | 1335 | ||
| 1308 | ret = hclge_tm_pri_schd_mode_cfg(hdev, pri_id); | 1336 | ret = hclge_tm_pri_schd_mode_cfg(hdev, pri_id); |
| @@ -1310,9 +1338,16 @@ static int hclge_tm_schd_mode_tc_base_cfg(struct hclge_dev *hdev, u8 pri_id) · 1 unmodified line | |||
| 1310 | return ret; | 1338 | return ret; |
| 1311 | 1339 | ||
| 1312 | for (i = 0; i < hdev->num_alloc_vport; i++) { | 1340 | for (i = 0; i < hdev->num_alloc_vport; i++) { |
| 1341 | struct hnae3_knic_private_info *kinfo = &vport[i].nic.kinfo; | ||
| 1342 | |||
| 1343 | if (pri_id >= kinfo->tc_info.max_tc) | ||
| 1344 | continue; | ||
| 1345 | |||
| 1346 | mode = pri_id < kinfo->tc_info.num_tc ? HCLGE_SCH_MODE_DWRR : | ||
| 1347 | HCLGE_SCH_MODE_SP; | ||
| 1313 | ret = hclge_tm_qs_schd_mode_cfg(hdev, | 1348 | ret = hclge_tm_qs_schd_mode_cfg(hdev, |
| 1314 | vport[i].qs_offset + pri_id, | 1349 | vport[i].qs_offset + pri_id, |
| 1315 | HCLGE_SCH_MODE_DWRR); | 1350 | mode); |
| 1316 | if (ret) | 1351 | if (ret) |
| 1317 | return ret; | 1352 | return ret; |
| 1318 | } | 1353 | } |
| @@ -1353,7 +1388,7 @@ static int hclge_tm_lvl34_schd_mode_cfg(struct hclge_dev *hdev) · 34 unmodified lines | |||
| 1353 | u8 i; | 1388 | u8 i; |
| 1354 | 1389 | ||
| 1355 | if (hdev->tx_sch_mode == HCLGE_FLAG_TC_BASE_SCH_MODE) { | 1390 | if (hdev->tx_sch_mode == HCLGE_FLAG_TC_BASE_SCH_MODE) { |
| 1356 | for (i = 0; i < hdev->tm_info.num_tc; i++) { | 1391 | for (i = 0; i < hdev->tc_max; i++) { |
| 1357 | ret = hclge_tm_schd_mode_tc_base_cfg(hdev, i); | 1392 | ret = hclge_tm_schd_mode_tc_base_cfg(hdev, i); |
| 1358 | if (ret) | 1393 | if (ret) |
| 1359 | return ret; | 1394 | return ret; |
| @@ -237,6 +237,7 @@ int hclge_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr); · 236 unmodified lines | |||
| 237 | void hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats); | 237 | void hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats); |
| 238 | void hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats); | 238 | void hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats); |
| 239 | int hclge_tm_qs_shaper_cfg(struct hclge_vport *vport, int max_tx_rate); | 239 | int hclge_tm_qs_shaper_cfg(struct hclge_vport *vport, int max_tx_rate); |
| 240 | int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev); | ||
| 240 | int hclge_tm_get_qset_num(struct hclge_dev *hdev, u16 *qset_num); | 241 | int hclge_tm_get_qset_num(struct hclge_dev *hdev, u16 *qset_num); |
| 241 | int hclge_tm_get_pri_num(struct hclge_dev *hdev, u8 *pri_num); | 242 | int hclge_tm_get_pri_num(struct hclge_dev *hdev, u8 *pri_num); |
| 242 | int hclge_tm_get_qset_map_pri(struct hclge_dev *hdev, u16 qset_id, u8 *priority, | 243 | int hclge_tm_get_qset_map_pri(struct hclge_dev *hdev, u16 qset_id, u8 *priority, |
| @@ -2586,15 +2586,16 @@ static void i40e_diag_test(struct net_device *netdev, · 2585 unmodified lines | |||
| 2586 | 2586 | ||
| 2587 | set_bit(__I40E_TESTING, pf->state); | 2587 | set_bit(__I40E_TESTING, pf->state); |
| 2588 | 2588 | ||
| 2589 | if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || | ||
| 2590 | test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) { | ||
| 2591 | dev_warn(&pf->pdev->dev, | ||
| 2592 | "Cannot start offline testing when PF is in reset state.\n"); | ||
| 2593 | goto skip_ol_tests; | ||
| 2594 | } | ||
| 2595 | |||
| 2589 | if (i40e_active_vfs(pf) || i40e_active_vmdqs(pf)) { | 2596 | if (i40e_active_vfs(pf) || i40e_active_vmdqs(pf)) { |
| 2590 | dev_warn(&pf->pdev->dev, | 2597 | dev_warn(&pf->pdev->dev, |
| 2591 | "Please take active VFs and Netqueues offline and restart the adapter before running NIC diagnostics\n"); | 2598 | "Please take active VFs and Netqueues offline and restart the adapter before running NIC diagnostics\n"); |
| 2592 | data[I40E_ETH_TEST_REG] = 1; | ||
| 2593 | data[I40E_ETH_TEST_EEPROM] = 1; | ||
| 2594 | data[I40E_ETH_TEST_INTR] = 1; | ||
| 2595 | data[I40E_ETH_TEST_LINK] = 1; | ||
| 2596 | eth_test->flags |= ETH_TEST_FL_FAILED; | ||
| 2597 | clear_bit(__I40E_TESTING, pf->state); | ||
| 2598 | goto skip_ol_tests; | 2599 | goto skip_ol_tests; |
| 2599 | } | 2600 | } |
| 2600 | 2601 | ||
| @@ -2641,9 +2642,17 @@ static void i40e_diag_test(struct net_device *netdev, · 40 unmodified lines | |||
| 2641 | data[I40E_ETH_TEST_INTR] = 0; | 2642 | data[I40E_ETH_TEST_INTR] = 0; |
| 2642 | } | 2643 | } |
| 2643 | 2644 | ||
| 2644 | skip_ol_tests: | ||
| 2645 | |||
| 2646 | netif_info(pf, drv, netdev, "testing finished\n"); | 2645 | netif_info(pf, drv, netdev, "testing finished\n"); |
| 2646 | return; | ||
| 2647 | |||
| 2648 | skip_ol_tests: | ||
| 2649 | data[I40E_ETH_TEST_REG] = 1; | ||
| 2650 | data[I40E_ETH_TEST_EEPROM] = 1; | ||
| 2651 | data[I40E_ETH_TEST_INTR] = 1; | ||
| 2652 | data[I40E_ETH_TEST_LINK] = 1; | ||
| 2653 | eth_test->flags |= ETH_TEST_FL_FAILED; | ||
| 2654 | clear_bit(__I40E_TESTING, pf->state); | ||
| 2655 | netif_info(pf, drv, netdev, "testing failed\n"); | ||
| 2647 | } | 2656 | } |
| 2648 | 2657 | ||
| 2649 | static void i40e_get_wol(struct net_device *netdev, | 2658 | static void i40e_get_wol(struct net_device *netdev, |
| @@ -8542,6 +8542,11 @@ static int i40e_configure_clsflower(struct i40e_vsi *vsi, · 8541 unmodified lines | |||
| 8542 | return -EOPNOTSUPP; | 8542 | return -EOPNOTSUPP; |
| 8543 | } | 8543 | } |
| 8544 | 8544 | ||
| 8545 | if (!tc) { | ||
| 8546 | dev_err(&pf->pdev->dev, "Unable to add filter because of invalid destination"); | ||
| 8547 | return -EINVAL; | ||
| 8548 | } | ||
| 8549 | |||
| 8545 | if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || | 8550 | if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) || |
| 8546 | test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) | 8551 | test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) |
| 8547 | return -EBUSY; | 8552 | return -EBUSY; |
| @@ -2282,7 +2282,7 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg) · 2281 unmodified lines | |||
| 2282 | } | 2282 | } |
| 2283 | 2283 | ||
| 2284 | if (vf->adq_enabled) { | 2284 | if (vf->adq_enabled) { |
| 2285 | for (i = 0; i < I40E_MAX_VF_VSI; i++) | 2285 | for (i = 0; i < vf->num_tc; i++) |
| 2286 | num_qps_all += vf->ch[i].num_qps; | 2286 | num_qps_all += vf->ch[i].num_qps; |
| 2287 | if (num_qps_all != qci->num_queue_pairs) { | 2287 | if (num_qps_all != qci->num_queue_pairs) { |
| 2288 | aq_ret = I40E_ERR_PARAM; | 2288 | aq_ret = I40E_ERR_PARAM; |
| @@ -984,7 +984,7 @@ struct iavf_mac_filter *iavf_add_filter(struct iavf_adapter *adapter, · 983 unmodified lines | |||
| 984 | list_add_tail(&f->list, &adapter->mac_filter_list); | 984 | list_add_tail(&f->list, &adapter->mac_filter_list); |
| 985 | f->add = true; | 985 | f->add = true; |
| 986 | f->is_new_mac = true; | 986 | f->is_new_mac = true; |
| 987 | f->is_primary = false; | 987 | f->is_primary = ether_addr_equal(macaddr, adapter->hw.mac.addr); |
| 988 | adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER; | 988 | adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER; |
| 989 | } else { | 989 | } else { |
| 990 | f->remove = false; | 990 | f->remove = false; |
| @@ -5763,25 +5763,38 @@ static netdev_features_t · 5762 unmodified lines | |||
| 5763 | ice_fix_features(struct net_device *netdev, netdev_features_t features) | 5763 | ice_fix_features(struct net_device *netdev, netdev_features_t features) |
| 5764 | { | 5764 | { |
| 5765 | struct ice_netdev_priv *np = netdev_priv(netdev); | 5765 | struct ice_netdev_priv *np = netdev_priv(netdev); |
| 5766 | netdev_features_t supported_vlan_filtering; | 5766 | netdev_features_t req_vlan_fltr, cur_vlan_fltr; |
| 5767 | netdev_features_t requested_vlan_filtering; | 5767 | bool cur_ctag, cur_stag, req_ctag, req_stag; |
| 5768 | struct ice_vsi *vsi = np->vsi; | 5768 | |
| 5769 | 5769 | cur_vlan_fltr = netdev->features & NETIF_VLAN_FILTERING_FEATURES; | |
| 5770 | requested_vlan_filtering = features & NETIF_VLAN_FILTERING_FEATURES; | 5770 | cur_ctag = cur_vlan_fltr & NETIF_F_HW_VLAN_CTAG_FILTER; |
| 5771 | 5771 | cur_stag = cur_vlan_fltr & NETIF_F_HW_VLAN_STAG_FILTER; | |
| 5772 | /* make sure supported_vlan_filtering works for both SVM and DVM */ | 5772 | |
| 5773 | supported_vlan_filtering = NETIF_F_HW_VLAN_CTAG_FILTER; | 5773 | req_vlan_fltr = features & NETIF_VLAN_FILTERING_FEATURES; |
| 5774 | if (ice_is_dvm_ena(&vsi->back->hw)) | 5774 | req_ctag = req_vlan_fltr & NETIF_F_HW_VLAN_CTAG_FILTER; |
| 5775 | supported_vlan_filtering |= NETIF_F_HW_VLAN_STAG_FILTER; | 5775 | req_stag = req_vlan_fltr & NETIF_F_HW_VLAN_STAG_FILTER; |
| 5776 | 5776 | ||
| 5777 | if (requested_vlan_filtering && | 5777 | if (req_vlan_fltr != cur_vlan_fltr) { |
| 5778 | requested_vlan_filtering != supported_vlan_filtering) { | 5778 | if (ice_is_dvm_ena(&np->vsi->back->hw)) { |
| 5779 | if (requested_vlan_filtering & NETIF_F_HW_VLAN_CTAG_FILTER) { | 5779 | if (req_ctag && req_stag) { |
| 5780 | netdev_warn(netdev, "cannot support requested VLAN filtering settings, enabling all supported VLAN filtering settings\n"); | 5780 | features |= NETIF_VLAN_FILTERING_FEATURES; |
| 5781 | features |= supported_vlan_filtering; | 5781 | } else if (!req_ctag && !req_stag) { |
| 5782 | features &= ~NETIF_VLAN_FILTERING_FEATURES; | ||
| 5783 | } else if ((!cur_ctag && req_ctag && !cur_stag) || | ||
| 5784 | (!cur_stag && req_stag && !cur_ctag)) { | ||
| 5785 | features |= NETIF_VLAN_FILTERING_FEATURES; | ||
| 5786 | netdev_warn(netdev, "802.1Q and 802.1ad VLAN filtering must be either both on or both off. VLAN filtering has been enabled for both types.\n"); | ||
| 5787 | } else if ((cur_ctag && !req_ctag && cur_stag) || | ||
| 5788 | (cur_stag && !req_stag && cur_ctag)) { | ||
| 5789 | features &= ~NETIF_VLAN_FILTERING_FEATURES; | ||
| 5790 | netdev_warn(netdev, "802.1Q and 802.1ad VLAN filtering must be either both on or both off. VLAN filtering has been disabled for both types.\n"); | ||
| 5791 | } | ||
| 5782 | } else { | 5792 | } else { |
| 5783 | netdev_warn(netdev, "cannot support requested VLAN filtering settings, clearing all supported VLAN filtering settings\n"); | 5793 | if (req_vlan_fltr & NETIF_F_HW_VLAN_STAG_FILTER) |
| 5784 | features &= ~supported_vlan_filtering; | 5794 | netdev_warn(netdev, "cannot support requested 802.1ad filtering setting in SVM mode\n"); |
| 5795 | |||
| 5796 | if (req_vlan_fltr & NETIF_F_HW_VLAN_CTAG_FILTER) | ||
| 5797 | features |= NETIF_F_HW_VLAN_CTAG_FILTER; | ||
| 5785 | } | 5798 | } |
| 5786 | } | 5799 | } |
| 5787 | 5800 | ||
| @@ -2271,7 +2271,7 @@ static int · 2270 unmodified lines | |||
| 2271 | ice_ptp_init_tx_e822(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port) | 2271 | ice_ptp_init_tx_e822(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port) |
| 2272 | { | 2272 | { |
| 2273 | tx->quad = port / ICE_PORTS_PER_QUAD; | 2273 | tx->quad = port / ICE_PORTS_PER_QUAD; |
| 2274 | tx->quad_offset = tx->quad * INDEX_PER_PORT; | 2274 | tx->quad_offset = (port % ICE_PORTS_PER_QUAD) * INDEX_PER_PORT; |
| 2275 | tx->len = INDEX_PER_PORT; | 2275 | tx->len = INDEX_PER_PORT; |
| 2276 | 2276 | ||
| 2277 | return ice_ptp_alloc_tx_tracker(tx); | 2277 | return ice_ptp_alloc_tx_tracker(tx); |
| @@ -49,6 +49,37 @@ struct ice_perout_channel { · 48 unmodified lines | |||
| 49 | * To allow multiple ports to access the shared register block independently, | 49 | * To allow multiple ports to access the shared register block independently, |
| 50 | * the blocks are split up so that indexes are assigned to each port based on | 50 | * the blocks are split up so that indexes are assigned to each port based on |
| 51 | * hardware logical port number. | 51 | * hardware logical port number. |
| 52 | * | ||
| 53 | * The timestamp blocks are handled differently for E810- and E822-based | ||
| 54 | * devices. In E810 devices, each port has its own block of timestamps, while in | ||
| 55 | * E822 there is a need to logically break the block of registers into smaller | ||
| 56 | * chunks based on the port number to avoid collisions. | ||
| 57 | * | ||
| 58 | * Example for port 5 in E810: | ||
| 59 | * +--------+--------+--------+--------+--------+--------+--------+--------+ | ||
| 60 | * |register|register|register|register|register|register|register|register| | ||
| 61 | * | block | block | block | block | block | block | block | block | | ||
| 62 | * | for | for | for | for | for | for | for | for | | ||
| 63 | * | port 0 | port 1 | port 2 | port 3 | port 4 | port 5 | port 6 | port 7 | | ||
| 64 | * +--------+--------+--------+--------+--------+--------+--------+--------+ | ||
| 65 | * ^^ | ||
| 66 | * || | ||
| 67 | * |--- quad offset is always 0 | ||
| 68 | * ---- quad number | ||
| 69 | * | ||
| 70 | * Example for port 5 in E822: | ||
| 71 | * +-----------------------------+-----------------------------+ | ||
| 72 | * | register block for quad 0 | register block for quad 1 | | ||
| 73 | * |+------+------+------+------+|+------+------+------+------+| | ||
| 74 | * ||port 0|port 1|port 2|port 3|||port 0|port 1|port 2|port 3|| | ||
| 75 | * |+------+------+------+------+|+------+------+------+------+| | ||
| 76 | * +-----------------------------+-------^---------------------+ | ||
| 77 | * ^ | | ||
| 78 | * | --- quad offset* | ||
| 79 | * ---- quad number | ||
| 80 | * | ||
| 81 | * * PHY port 5 is port 1 in quad 1 | ||
| 82 | * | ||
| 52 | */ | 83 | */ |
| 53 | 84 | ||
| 54 | /** | 85 | /** |
| @@ -504,6 +504,11 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags) · 503 unmodified lines | |||
| 504 | } | 504 | } |
| 505 | 505 | ||
| 506 | if (ice_is_vf_disabled(vf)) { | 506 | if (ice_is_vf_disabled(vf)) { |
| 507 | vsi = ice_get_vf_vsi(vf); | ||
| 508 | if (WARN_ON(!vsi)) | ||
| 509 | return -EINVAL; | ||
| 510 | ice_vsi_stop_lan_tx_rings(vsi, ICE_NO_RESET, vf->vf_id); | ||
| 511 | ice_vsi_stop_all_rx_rings(vsi); | ||
| 507 | dev_dbg(dev, "VF is already disabled, there is no need for resetting it, telling VM, all is fine %d\n", | 512 | dev_dbg(dev, "VF is already disabled, there is no need for resetting it, telling VM, all is fine %d\n", |
| 508 | vf->vf_id); | 513 | vf->vf_id); |
| 509 | return 0; | 514 | return 0; |
| @@ -1569,35 +1569,27 @@ error_param: · 1568 unmodified lines | |||
| 1569 | */ | 1569 | */ |
| 1570 | static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) | 1570 | static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) |
| 1571 | { | 1571 | { |
| 1572 | enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS; | ||
| 1573 | struct virtchnl_vsi_queue_config_info *qci = | 1572 | struct virtchnl_vsi_queue_config_info *qci = |
| 1574 | (struct virtchnl_vsi_queue_config_info *)msg; | 1573 | (struct virtchnl_vsi_queue_config_info *)msg; |
| 1575 | struct virtchnl_queue_pair_info *qpi; | 1574 | struct virtchnl_queue_pair_info *qpi; |
| 1576 | struct ice_pf *pf = vf->pf; | 1575 | struct ice_pf *pf = vf->pf; |
| 1577 | struct ice_vsi *vsi; | 1576 | struct ice_vsi *vsi; |
| 1578 | int i, q_idx; | 1577 | int i = -1, q_idx; |
| 1579 | 1578 | ||
| 1580 | if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) { | 1579 | if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) |
| 1581 | v_ret = VIRTCHNL_STATUS_ERR_PARAM; | ||
| 1582 | goto error_param; | 1580 | goto error_param; |
| 1583 | } | ||
| 1584 | 1581 | ||
| 1585 | if (!ice_vc_isvalid_vsi_id(vf, qci->vsi_id)) { | 1582 | if (!ice_vc_isvalid_vsi_id(vf, qci->vsi_id)) |
| 1586 | v_ret = VIRTCHNL_STATUS_ERR_PARAM; | ||
| 1587 | goto error_param; | 1583 | goto error_param; |
| 1588 | } | ||
| 1589 | 1584 | ||
| 1590 | vsi = ice_get_vf_vsi(vf); | 1585 | vsi = ice_get_vf_vsi(vf); |
| 1591 | if (!vsi) { | 1586 | if (!vsi) |
| 1592 | v_ret = VIRTCHNL_STATUS_ERR_PARAM; | ||
| 1593 | goto error_param; | 1587 | goto error_param; |
| 1594 | } | ||
| 1595 | 1588 | ||
| 1596 | if (qci->num_queue_pairs > ICE_MAX_RSS_QS_PER_VF || | 1589 | if (qci->num_queue_pairs > ICE_MAX_RSS_QS_PER_VF || |
| 1597 | qci->num_queue_pairs > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) { | 1590 | qci->num_queue_pairs > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) { |
| 1598 | dev_err(ice_pf_to_dev(pf), "VF-%d requesting more than supported number of queues: %d\n", | 1591 | dev_err(ice_pf_to_dev(pf), "VF-%d requesting more than supported number of queues: %d\n", |
| 1599 | vf->vf_id, min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)); | 1592 | vf->vf_id, min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)); |
| 1600 | v_ret = VIRTCHNL_STATUS_ERR_PARAM; | ||
| 1601 | goto error_param; | 1593 | goto error_param; |
| 1602 | } | 1594 | } |
| 1603 | 1595 | ||
| @@ -1610,7 +1602,6 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · 6 unmodified lines | |||
| 1610 | !ice_vc_isvalid_ring_len(qpi->txq.ring_len) || | 1602 | !ice_vc_isvalid_ring_len(qpi->txq.ring_len) || |
| 1611 | !ice_vc_isvalid_ring_len(qpi->rxq.ring_len) || | 1603 | !ice_vc_isvalid_ring_len(qpi->rxq.ring_len) || |
| 1612 | !ice_vc_isvalid_q_id(vf, qci->vsi_id, qpi->txq.queue_id)) { | 1604 | !ice_vc_isvalid_q_id(vf, qci->vsi_id, qpi->txq.queue_id)) { |
| 1613 | v_ret = VIRTCHNL_STATUS_ERR_PARAM; | ||
| 1614 | goto error_param; | 1605 | goto error_param; |
| 1615 | } | 1606 | } |
| 1616 | 1607 | ||
| @@ -1620,7 +1611,6 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · 3 unmodified lines | |||
| 1620 | * for selected "vsi" | 1611 | * for selected "vsi" |
| 1621 | */ | 1612 | */ |
| 1622 | if (q_idx >= vsi->alloc_txq || q_idx >= vsi->alloc_rxq) { | 1613 | if (q_idx >= vsi->alloc_txq || q_idx >= vsi->alloc_rxq) { |
| 1623 | v_ret = VIRTCHNL_STATUS_ERR_PARAM; | ||
| 1624 | goto error_param; | 1614 | goto error_param; |
| 1625 | } | 1615 | } |
| 1626 | 1616 | ||
| @@ -1630,14 +1620,13 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · 3 unmodified lines | |||
| 1630 | vsi->tx_rings[i]->count = qpi->txq.ring_len; | 1620 | vsi->tx_rings[i]->count = qpi->txq.ring_len; |
| 1631 | 1621 | ||
| 1632 | /* Disable any existing queue first */ | 1622 | /* Disable any existing queue first */ |
| 1633 | if (ice_vf_vsi_dis_single_txq(vf, vsi, q_idx)) { | 1623 | if (ice_vf_vsi_dis_single_txq(vf, vsi, q_idx)) |
| 1634 | v_ret = VIRTCHNL_STATUS_ERR_PARAM; | ||
| 1635 | goto error_param; | 1624 | goto error_param; |
| 1636 | } | ||
| 1637 | 1625 | ||
| 1638 | /* Configure a queue with the requested settings */ | 1626 | /* Configure a queue with the requested settings */ |
| 1639 | if (ice_vsi_cfg_single_txq(vsi, vsi->tx_rings, q_idx)) { | 1627 | if (ice_vsi_cfg_single_txq(vsi, vsi->tx_rings, q_idx)) { |
| 1640 | v_ret = VIRTCHNL_STATUS_ERR_PARAM; | 1628 | dev_warn(ice_pf_to_dev(pf), "VF-%d failed to configure TX queue %d\n", |
| 1629 | vf->vf_id, i); | ||
| 1641 | goto error_param; | 1630 | goto error_param; |
| 1642 | } | 1631 | } |
| 1643 | } | 1632 | } |
| @@ -1651,17 +1640,13 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · 7 unmodified lines | |||
| 1651 | 1640 | ||
| 1652 | if (qpi->rxq.databuffer_size != 0 && | 1641 | if (qpi->rxq.databuffer_size != 0 && |
| 1653 | (qpi->rxq.databuffer_size > ((16 * 1024) - 128) || | 1642 | (qpi->rxq.databuffer_size > ((16 * 1024) - 128) || |
| 1654 | qpi->rxq.databuffer_size < 1024)) { | 1643 | qpi->rxq.databuffer_size < 1024)) |
| 1655 | v_ret = VIRTCHNL_STATUS_ERR_PARAM; | ||
| 1656 | goto error_param; | 1644 | goto error_param; |
| 1657 | } | ||
| 1658 | vsi->rx_buf_len = qpi->rxq.databuffer_size; | 1645 | vsi->rx_buf_len = qpi->rxq.databuffer_size; |
| 1659 | vsi->rx_rings[i]->rx_buf_len = vsi->rx_buf_len; | 1646 | vsi->rx_rings[i]->rx_buf_len = vsi->rx_buf_len; |
| 1660 | if (qpi->rxq.max_pkt_size > max_frame_size || | 1647 | if (qpi->rxq.max_pkt_size > max_frame_size || |
| 1661 | qpi->rxq.max_pkt_size < 64) { | 1648 | qpi->rxq.max_pkt_size < 64) |
| 1662 | v_ret = VIRTCHNL_STATUS_ERR_PARAM; | ||
| 1663 | goto error_param; | 1649 | goto error_param; |
| 1664 | } | ||
| 1665 | 1650 | ||
| 1666 | vsi->max_frame = qpi->rxq.max_pkt_size; | 1651 | vsi->max_frame = qpi->rxq.max_pkt_size; |
| 1667 | /* add space for the port VLAN since the VF driver is | 1652 | /* add space for the port VLAN since the VF driver is |
| @@ -1672,16 +1657,30 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) · 4 unmodified lines | |||
| 1672 | vsi->max_frame += VLAN_HLEN; | 1657 | vsi->max_frame += VLAN_HLEN; |
| 1673 | 1658 | ||
| 1674 | if (ice_vsi_cfg_single_rxq(vsi, q_idx)) { | 1659 | if (ice_vsi_cfg_single_rxq(vsi, q_idx)) { |
| 1675 | v_ret = VIRTCHNL_STATUS_ERR_PARAM; | 1660 | dev_warn(ice_pf_to_dev(pf), "VF-%d failed to configure RX queue %d\n", |
| 1661 | vf->vf_id, i); | ||
| 1676 | goto error_param; | 1662 | goto error_param; |
| 1677 | } | 1663 | } |
| 1678 | } | 1664 | } |
| 1679 | } | 1665 | } |
| 1680 | 1666 | ||
| 1667 | /* send the response to the VF */ | ||
| 1668 | return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES, | ||
| 1669 | VIRTCHNL_STATUS_SUCCESS, NULL, 0); | ||
| 1681 | error_param: | 1670 | error_param: |
| 1671 | /* disable whatever we can */ | ||
| 1672 | for (; i >= 0; i--) { | ||
| 1673 | if (ice_vsi_ctrl_one_rx_ring(vsi, false, i, true)) | ||
| 1674 | dev_err(ice_pf_to_dev(pf), "VF-%d could not disable RX queue %d\n", | ||
| 1675 | vf->vf_id, i); | ||
| 1676 | if (ice_vf_vsi_dis_single_txq(vf, vsi, i)) | ||
| 1677 | dev_err(ice_pf_to_dev(pf), "VF-%d could not disable TX queue %d\n", | ||
| 1678 | vf->vf_id, i); | ||
| 1679 | } | ||
| 1680 | |||
| 1682 | /* send the response to the VF */ | 1681 | /* send the response to the VF */ |
| 1683 | return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES, v_ret, | 1682 | return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES, |
| 1684 | NULL, 0); | 1683 | VIRTCHNL_STATUS_ERR_PARAM, NULL, 0); |
| 1685 | } | 1684 | } |
| 1686 | 1685 | ||
| 1687 | /** | 1686 | /** |
| @@ -1390,7 +1390,8 @@ static int otx2vf_get_link_ksettings(struct net_device *netdev, · 1389 unmodified lines | |||
| 1390 | 1390 | ||
| 1391 | static const struct ethtool_ops otx2vf_ethtool_ops = { | 1391 | static const struct ethtool_ops otx2vf_ethtool_ops = { |
| 1392 | .supported_coalesce_params = ETHTOOL_COALESCE_USECS | | 1392 | .supported_coalesce_params = ETHTOOL_COALESCE_USECS | |
| 1393 | ETHTOOL_COALESCE_MAX_FRAMES, | 1393 | ETHTOOL_COALESCE_MAX_FRAMES | |
| 1394 | ETHTOOL_COALESCE_USE_ADAPTIVE, | ||
| 1394 | .supported_ring_params = ETHTOOL_RING_USE_RX_BUF_LEN | | 1395 | .supported_ring_params = ETHTOOL_RING_USE_RX_BUF_LEN | |
| 1395 | ETHTOOL_RING_USE_CQE_SIZE, | 1396 | ETHTOOL_RING_USE_CQE_SIZE, |
| 1396 | .get_link = otx2_get_link, | 1397 | .get_link = otx2_get_link, |
| @@ -8,8 +8,8 @@ · 7 unmodified lines | |||
| 8 | #include "spectrum.h" | 8 | #include "spectrum.h" |
| 9 | 9 | ||
| 10 | enum mlxsw_sp_counter_sub_pool_id { | 10 | enum mlxsw_sp_counter_sub_pool_id { |
| 11 | MLXSW_SP_COUNTER_SUB_POOL_FLOW, | ||
| 12 | MLXSW_SP_COUNTER_SUB_POOL_RIF, | 11 | MLXSW_SP_COUNTER_SUB_POOL_RIF, |
| 12 | MLXSW_SP_COUNTER_SUB_POOL_FLOW, | ||
| 13 | }; | 13 | }; |
| 14 | 14 | ||
| 15 | int mlxsw_sp_counter_alloc(struct mlxsw_sp *mlxsw_sp, | 15 | int mlxsw_sp_counter_alloc(struct mlxsw_sp *mlxsw_sp, |
| @@ -547,6 +547,57 @@ static inline void axienet_iow(struct axienet_local *lp, off_t offset, · 546 unmodified lines | |||
| 547 | iowrite32(value, lp->regs + offset); | 547 | iowrite32(value, lp->regs + offset); |
| 548 | } | 548 | } |
| 549 | 549 | ||
| 550 | /** | ||
| 551 | * axienet_dma_out32 - Memory mapped Axi DMA register write. | ||
| 552 | * @lp: Pointer to axienet local structure | ||
| 553 | * @reg: Address offset from the base address of the Axi DMA core | ||
| 554 | * @value: Value to be written into the Axi DMA register | ||
| 555 | * | ||
| 556 | * This function writes the desired value into the corresponding Axi DMA | ||
| 557 | * register. | ||
| 558 | */ | ||
| 559 | |||
| 560 | static inline void axienet_dma_out32(struct axienet_local *lp, | ||
| 561 | off_t reg, u32 value) | ||
| 562 | { | ||
| 563 | iowrite32(value, lp->dma_regs + reg); | ||
| 564 | } | ||
| 565 | |||
| 566 | #if defined(CONFIG_64BIT) && defined(iowrite64) | ||
| 567 | /** | ||
| 568 | * axienet_dma_out64 - Memory mapped Axi DMA register write. | ||
| 569 | * @lp: Pointer to axienet local structure | ||
| 570 | * @reg: Address offset from the base address of the Axi DMA core | ||
| 571 | * @value: Value to be written into the Axi DMA register | ||
| 572 | * | ||
| 573 | * This function writes the desired value into the corresponding Axi DMA | ||
| 574 | * register. | ||
| 575 | */ | ||
| 576 | static inline void axienet_dma_out64(struct axienet_local *lp, | ||
| 577 | off_t reg, u64 value) | ||
| 578 | { | ||
| 579 | iowrite64(value, lp->dma_regs + reg); | ||
| 580 | } | ||
| 581 | |||
| 582 | static inline void axienet_dma_out_addr(struct axienet_local *lp, off_t reg, | ||
| 583 | dma_addr_t addr) | ||
| 584 | { | ||
| 585 | if (lp->features & XAE_FEATURE_DMA_64BIT) | ||
| 586 | axienet_dma_out64(lp, reg, addr); | ||
| 587 | else | ||
| 588 | axienet_dma_out32(lp, reg, lower_32_bits(addr)); | ||
| 589 | } | ||
| 590 | |||
| 591 | #else /* CONFIG_64BIT */ | ||
| 592 | |||
| 593 | static inline void axienet_dma_out_addr(struct axienet_local *lp, off_t reg, | ||
| 594 | dma_addr_t addr) | ||
| 595 | { | ||
| 596 | axienet_dma_out32(lp, reg, lower_32_bits(addr)); | ||
| 597 | } | ||
| 598 | |||
| 599 | #endif /* CONFIG_64BIT */ | ||
| 600 | |||
| 550 | /* Function prototypes visible in xilinx_axienet_mdio.c for other files */ | 601 | /* Function prototypes visible in xilinx_axienet_mdio.c for other files */ |
| 551 | int axienet_mdio_enable(struct axienet_local *lp); | 602 | int axienet_mdio_enable(struct axienet_local *lp); |
| 552 | void axienet_mdio_disable(struct axienet_local *lp); | 603 | void axienet_mdio_disable(struct axienet_local *lp); |
| @@ -133,30 +133,6 @@ static inline u32 axienet_dma_in32(struct axienet_local *lp, off_t reg) · 132 unmodified lines | |||
| 133 | return ioread32(lp->dma_regs + reg); | 133 | return ioread32(lp->dma_regs + reg); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | /** | ||
| 137 | * axienet_dma_out32 - Memory mapped Axi DMA register write. | ||
| 138 | * @lp: Pointer to axienet local structure | ||
| 139 | * @reg: Address offset from the base address of the Axi DMA core | ||
| 140 | * @value: Value to be written into the Axi DMA register | ||
| 141 | * | ||
| 142 | * This function writes the desired value into the corresponding Axi DMA | ||
| 143 | * register. | ||
| 144 | */ | ||
| 145 | static inline void axienet_dma_out32(struct axienet_local *lp, | ||
| 146 | off_t reg, u32 value) | ||
| 147 | { | ||
| 148 | iowrite32(value, lp->dma_regs + reg); | ||
| 149 | } | ||
| 150 | |||
| 151 | static void axienet_dma_out_addr(struct axienet_local *lp, off_t reg, | ||
| 152 | dma_addr_t addr) | ||
| 153 | { | ||
| 154 | axienet_dma_out32(lp, reg, lower_32_bits(addr)); | ||
| 155 | |||
| 156 | if (lp->features & XAE_FEATURE_DMA_64BIT) | ||
| 157 | axienet_dma_out32(lp, reg + 4, upper_32_bits(addr)); | ||
| 158 | } | ||
| 159 | |||
| 160 | static void desc_set_phys_addr(struct axienet_local *lp, dma_addr_t addr, | 136 | static void desc_set_phys_addr(struct axienet_local *lp, dma_addr_t addr, |
| 161 | struct axidma_bd *desc) | 137 | struct axidma_bd *desc) |
| 162 | { | 138 | { |
| @@ -2061,6 +2037,11 @@ static int axienet_probe(struct platform_device *pdev) · 1898 unmodified lines | |||
| 2061 | iowrite32(0x0, desc); | 2037 | iowrite32(0x0, desc); |
| 2062 | } | 2038 | } |
| 2063 | } | 2039 | } |
| 2040 | if (!IS_ENABLED(CONFIG_64BIT) && lp->features & XAE_FEATURE_DMA_64BIT) { | ||
| 2041 | dev_err(&pdev->dev, "64-bit addressable DMA is not compatible with 32-bit archecture\n"); | ||
| 2042 | ret = -EINVAL; | ||
| 2043 | goto cleanup_clk; | ||
| 2044 | } | ||
| 2064 | 2045 | ||
| 2065 | ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(addr_width)); | 2046 | ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(addr_width)); |
| 2066 | if (ret) { | 2047 | if (ret) { |
| @@ -1750,7 +1750,7 @@ static const struct driver_info ax88179_info = { · 1749 unmodified lines | |||
| 1750 | .link_reset = ax88179_link_reset, | 1750 | .link_reset = ax88179_link_reset, |
| 1751 | .reset = ax88179_reset, | 1751 | .reset = ax88179_reset, |
| 1752 | .stop = ax88179_stop, | 1752 | .stop = ax88179_stop, |
| 1753 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1753 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, |
| 1754 | .rx_fixup = ax88179_rx_fixup, | 1754 | .rx_fixup = ax88179_rx_fixup, |
| 1755 | .tx_fixup = ax88179_tx_fixup, | 1755 | .tx_fixup = ax88179_tx_fixup, |
| 1756 | }; | 1756 | }; |
| @@ -1763,7 +1763,7 @@ static const struct driver_info ax88178a_info = { · 6 unmodified lines | |||
| 1763 | .link_reset = ax88179_link_reset, | 1763 | .link_reset = ax88179_link_reset, |
| 1764 | .reset = ax88179_reset, | 1764 | .reset = ax88179_reset, |
| 1765 | .stop = ax88179_stop, | 1765 | .stop = ax88179_stop, |
| 1766 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1766 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, |
| 1767 | .rx_fixup = ax88179_rx_fixup, | 1767 | .rx_fixup = ax88179_rx_fixup, |
| 1768 | .tx_fixup = ax88179_tx_fixup, | 1768 | .tx_fixup = ax88179_tx_fixup, |
| 1769 | }; | 1769 | }; |
| @@ -1776,7 +1776,7 @@ static const struct driver_info cypress_GX3_info = { · 6 unmodified lines | |||
| 1776 | .link_reset = ax88179_link_reset, | 1776 | .link_reset = ax88179_link_reset, |
| 1777 | .reset = ax88179_reset, | 1777 | .reset = ax88179_reset, |
| 1778 | .stop = ax88179_stop, | 1778 | .stop = ax88179_stop, |
| 1779 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1779 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, |
| 1780 | .rx_fixup = ax88179_rx_fixup, | 1780 | .rx_fixup = ax88179_rx_fixup, |
| 1781 | .tx_fixup = ax88179_tx_fixup, | 1781 | .tx_fixup = ax88179_tx_fixup, |
| 1782 | }; | 1782 | }; |
| @@ -1789,7 +1789,7 @@ static const struct driver_info dlink_dub1312_info = { · 6 unmodified lines | |||
| 1789 | .link_reset = ax88179_link_reset, | 1789 | .link_reset = ax88179_link_reset, |
| 1790 | .reset = ax88179_reset, | 1790 | .reset = ax88179_reset, |
| 1791 | .stop = ax88179_stop, | 1791 | .stop = ax88179_stop, |
| 1792 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1792 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, |
| 1793 | .rx_fixup = ax88179_rx_fixup, | 1793 | .rx_fixup = ax88179_rx_fixup, |
| 1794 | .tx_fixup = ax88179_tx_fixup, | 1794 | .tx_fixup = ax88179_tx_fixup, |
| 1795 | }; | 1795 | }; |
| @@ -1802,7 +1802,7 @@ static const struct driver_info sitecom_info = { · 6 unmodified lines | |||
| 1802 | .link_reset = ax88179_link_reset, | 1802 | .link_reset = ax88179_link_reset, |
| 1803 | .reset = ax88179_reset, | 1803 | .reset = ax88179_reset, |
| 1804 | .stop = ax88179_stop, | 1804 | .stop = ax88179_stop, |
| 1805 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1805 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, |
| 1806 | .rx_fixup = ax88179_rx_fixup, | 1806 | .rx_fixup = ax88179_rx_fixup, |
| 1807 | .tx_fixup = ax88179_tx_fixup, | 1807 | .tx_fixup = ax88179_tx_fixup, |
| 1808 | }; | 1808 | }; |
| @@ -1815,7 +1815,7 @@ static const struct driver_info samsung_info = { · 6 unmodified lines | |||
| 1815 | .link_reset = ax88179_link_reset, | 1815 | .link_reset = ax88179_link_reset, |
| 1816 | .reset = ax88179_reset, | 1816 | .reset = ax88179_reset, |
| 1817 | .stop = ax88179_stop, | 1817 | .stop = ax88179_stop, |
| 1818 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1818 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, |
| 1819 | .rx_fixup = ax88179_rx_fixup, | 1819 | .rx_fixup = ax88179_rx_fixup, |
| 1820 | .tx_fixup = ax88179_tx_fixup, | 1820 | .tx_fixup = ax88179_tx_fixup, |
| 1821 | }; | 1821 | }; |
| @@ -1828,7 +1828,7 @@ static const struct driver_info lenovo_info = { · 6 unmodified lines | |||
| 1828 | .link_reset = ax88179_link_reset, | 1828 | .link_reset = ax88179_link_reset, |
| 1829 | .reset = ax88179_reset, | 1829 | .reset = ax88179_reset, |
| 1830 | .stop = ax88179_stop, | 1830 | .stop = ax88179_stop, |
| 1831 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1831 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, |
| 1832 | .rx_fixup = ax88179_rx_fixup, | 1832 | .rx_fixup = ax88179_rx_fixup, |
| 1833 | .tx_fixup = ax88179_tx_fixup, | 1833 | .tx_fixup = ax88179_tx_fixup, |
| 1834 | }; | 1834 | }; |
| @@ -1841,7 +1841,7 @@ static const struct driver_info belkin_info = { · 6 unmodified lines | |||
| 1841 | .link_reset = ax88179_link_reset, | 1841 | .link_reset = ax88179_link_reset, |
| 1842 | .reset = ax88179_reset, | 1842 | .reset = ax88179_reset, |
| 1843 | .stop = ax88179_stop, | 1843 | .stop = ax88179_stop, |
| 1844 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1844 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, |
| 1845 | .rx_fixup = ax88179_rx_fixup, | 1845 | .rx_fixup = ax88179_rx_fixup, |
| 1846 | .tx_fixup = ax88179_tx_fixup, | 1846 | .tx_fixup = ax88179_tx_fixup, |
| 1847 | }; | 1847 | }; |
| @@ -1854,7 +1854,7 @@ static const struct driver_info toshiba_info = { · 6 unmodified lines | |||
| 1854 | .link_reset = ax88179_link_reset, | 1854 | .link_reset = ax88179_link_reset, |
| 1855 | .reset = ax88179_reset, | 1855 | .reset = ax88179_reset, |
| 1856 | .stop = ax88179_stop, | 1856 | .stop = ax88179_stop, |
| 1857 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1857 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, |
| 1858 | .rx_fixup = ax88179_rx_fixup, | 1858 | .rx_fixup = ax88179_rx_fixup, |
| 1859 | .tx_fixup = ax88179_tx_fixup, | 1859 | .tx_fixup = ax88179_tx_fixup, |
| 1860 | }; | 1860 | }; |
| @@ -1867,7 +1867,7 @@ static const struct driver_info mct_info = { · 6 unmodified lines | |||
| 1867 | .link_reset = ax88179_link_reset, | 1867 | .link_reset = ax88179_link_reset, |
| 1868 | .reset = ax88179_reset, | 1868 | .reset = ax88179_reset, |
| 1869 | .stop = ax88179_stop, | 1869 | .stop = ax88179_stop, |
| 1870 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1870 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, |
| 1871 | .rx_fixup = ax88179_rx_fixup, | 1871 | .rx_fixup = ax88179_rx_fixup, |
| 1872 | .tx_fixup = ax88179_tx_fixup, | 1872 | .tx_fixup = ax88179_tx_fixup, |
| 1873 | }; | 1873 | }; |
| @@ -1880,7 +1880,7 @@ static const struct driver_info at_umc2000_info = { · 6 unmodified lines | |||
| 1880 | .link_reset = ax88179_link_reset, | 1880 | .link_reset = ax88179_link_reset, |
| 1881 | .reset = ax88179_reset, | 1881 | .reset = ax88179_reset, |
| 1882 | .stop = ax88179_stop, | 1882 | .stop = ax88179_stop, |
| 1883 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1883 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, |
| 1884 | .rx_fixup = ax88179_rx_fixup, | 1884 | .rx_fixup = ax88179_rx_fixup, |
| 1885 | .tx_fixup = ax88179_tx_fixup, | 1885 | .tx_fixup = ax88179_tx_fixup, |
| 1886 | }; | 1886 | }; |
| @@ -1893,7 +1893,7 @@ static const struct driver_info at_umc200_info = { · 6 unmodified lines | |||
| 1893 | .link_reset = ax88179_link_reset, | 1893 | .link_reset = ax88179_link_reset, |
| 1894 | .reset = ax88179_reset, | 1894 | .reset = ax88179_reset, |
| 1895 | .stop = ax88179_stop, | 1895 | .stop = ax88179_stop, |
| 1896 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1896 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, |
| 1897 | .rx_fixup = ax88179_rx_fixup, | 1897 | .rx_fixup = ax88179_rx_fixup, |
| 1898 | .tx_fixup = ax88179_tx_fixup, | 1898 | .tx_fixup = ax88179_tx_fixup, |
| 1899 | }; | 1899 | }; |
| @@ -1906,7 +1906,7 @@ static const struct driver_info at_umc2000sp_info = { · 6 unmodified lines | |||
| 1906 | .link_reset = ax88179_link_reset, | 1906 | .link_reset = ax88179_link_reset, |
| 1907 | .reset = ax88179_reset, | 1907 | .reset = ax88179_reset, |
| 1908 | .stop = ax88179_stop, | 1908 | .stop = ax88179_stop, |
| 1909 | .flags = FLAG_ETHER | FLAG_FRAMING_AX, | 1909 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, |
| 1910 | .rx_fixup = ax88179_rx_fixup, | 1910 | .rx_fixup = ax88179_rx_fixup, |
| 1911 | .tx_fixup = ax88179_tx_fixup, | 1911 | .tx_fixup = ax88179_tx_fixup, |
| 1912 | }; | 1912 | }; |
| @@ -25,7 +25,6 @@ · 24 unmodified lines | |||
| 25 | #undef INET_CSK_CLEAR_TIMERS | 25 | #undef INET_CSK_CLEAR_TIMERS |
| 26 | 26 | ||
| 27 | struct inet_bind_bucket; | 27 | struct inet_bind_bucket; |
| 28 | struct inet_bind2_bucket; | ||
| 29 | struct tcp_congestion_ops; | 28 | struct tcp_congestion_ops; |
| 30 | 29 | ||
| 31 | /* | 30 | /* |
| @@ -58,7 +57,6 @@ struct inet_connection_sock_af_ops { · 26 unmodified lines | |||
| 58 | * | 57 | * |
| 59 | * @icsk_accept_queue: FIFO of established children | 58 | * @icsk_accept_queue: FIFO of established children |
| 60 | * @icsk_bind_hash: Bind node | 59 | * @icsk_bind_hash: Bind node |
| 61 | * @icsk_bind2_hash: Bind node in the bhash2 table | ||
| 62 | * @icsk_timeout: Timeout | 60 | * @icsk_timeout: Timeout |
| 63 | * @icsk_retransmit_timer: Resend (no ack) | 61 | * @icsk_retransmit_timer: Resend (no ack) |
| 64 | * @icsk_rto: Retransmit timeout | 62 | * @icsk_rto: Retransmit timeout |
| @@ -85,7 +83,6 @@ struct inet_connection_sock { · 20 unmodified lines | |||
| 85 | struct inet_sock icsk_inet; | 83 | struct inet_sock icsk_inet; |
| 86 | struct request_sock_queue icsk_accept_queue; | 84 | struct request_sock_queue icsk_accept_queue; |
| 87 | struct inet_bind_bucket *icsk_bind_hash; | 85 | struct inet_bind_bucket *icsk_bind_hash; |
| 88 | struct inet_bind2_bucket *icsk_bind2_hash; | ||
| 89 | unsigned long icsk_timeout; | 86 | unsigned long icsk_timeout; |
| 90 | struct timer_list icsk_retransmit_timer; | 87 | struct timer_list icsk_retransmit_timer; |
| 91 | struct timer_list icsk_delack_timer; | 88 | struct timer_list icsk_delack_timer; |
| @@ -90,32 +90,11 @@ struct inet_bind_bucket { · 89 unmodified lines | |||
| 90 | struct hlist_head owners; | 90 | struct hlist_head owners; |
| 91 | }; | 91 | }; |
| 92 | 92 | ||
| 93 | struct inet_bind2_bucket { | ||
| 94 | possible_net_t ib_net; | ||
| 95 | int l3mdev; | ||
| 96 | unsigned short port; | ||
| 97 | union { | ||
| 98 | #if IS_ENABLED(CONFIG_IPV6) | ||
| 99 | struct in6_addr v6_rcv_saddr; | ||
| 100 | #endif | ||
| 101 | __be32 rcv_saddr; | ||
| 102 | }; | ||
| 103 | /* Node in the inet2_bind_hashbucket chain */ | ||
| 104 | struct hlist_node node; | ||
| 105 | /* List of sockets hashed to this bucket */ | ||
| 106 | struct hlist_head owners; | ||
| 107 | }; | ||
| 108 | |||
| 109 | static inline struct net *ib_net(struct inet_bind_bucket *ib) | 93 | static inline struct net *ib_net(struct inet_bind_bucket *ib) |
| 110 | { | 94 | { |
| 111 | return read_pnet(&ib->ib_net); | 95 | return read_pnet(&ib->ib_net); |
| 112 | } | 96 | } |
| 113 | 97 | ||
| 114 | static inline struct net *ib2_net(struct inet_bind2_bucket *ib) | ||
| 115 | { | ||
| 116 | return read_pnet(&ib->ib_net); | ||
| 117 | } | ||
| 118 | |||
| 119 | #define inet_bind_bucket_for_each(tb, head) \ | 98 | #define inet_bind_bucket_for_each(tb, head) \ |
| 120 | hlist_for_each_entry(tb, head, node) | 99 | hlist_for_each_entry(tb, head, node) |
| 121 | 100 | ||
| @@ -124,15 +103,6 @@ struct inet_bind_hashbucket { · 2 unmodified lines | |||
| 124 | struct hlist_head chain; | 103 | struct hlist_head chain; |
| 125 | }; | 104 | }; |
| 126 | 105 | ||
| 127 | /* This is synchronized using the inet_bind_hashbucket's spinlock. | ||
| 128 | * Instead of having separate spinlocks, the inet_bind2_hashbucket can share | ||
| 129 | * the inet_bind_hashbucket's given that in every case where the bhash2 table | ||
| 130 | * is useful, a lookup in the bhash table also occurs. | ||
| 131 | */ | ||
| 132 | struct inet_bind2_hashbucket { | ||
| 133 | struct hlist_head chain; | ||
| 134 | }; | ||
| 135 | |||
| 136 | /* Sockets can be hashed in established or listening table. | 106 | /* Sockets can be hashed in established or listening table. |
| 137 | * We must use different 'nulls' end-of-chain value for all hash buckets : | 107 | * We must use different 'nulls' end-of-chain value for all hash buckets : |
| 138 | * A socket might transition from ESTABLISH to LISTEN state without | 108 | * A socket might transition from ESTABLISH to LISTEN state without |
| @@ -164,12 +134,6 @@ struct inet_hashinfo { · 25 unmodified lines | |||
| 164 | */ | 134 | */ |
| 165 | struct kmem_cache *bind_bucket_cachep; | 135 | struct kmem_cache *bind_bucket_cachep; |
| 166 | struct inet_bind_hashbucket *bhash; | 136 | struct inet_bind_hashbucket *bhash; |
| 167 | /* The 2nd binding table hashed by port and address. | ||
| 168 | * This is used primarily for expediting the resolution of bind | ||
| 169 | * conflicts. | ||
| 170 | */ | ||
| 171 | struct kmem_cache *bind2_bucket_cachep; | ||
| 172 | struct inet_bind2_hashbucket *bhash2; | ||
| 173 | unsigned int bhash_size; | 137 | unsigned int bhash_size; |
| 174 | 138 | ||
| 175 | /* The 2nd listener table hashed by local port and address */ | 139 | /* The 2nd listener table hashed by local port and address */ |
| @@ -229,36 +193,6 @@ inet_bind_bucket_create(struct kmem_cache *cachep, struct net *net, · 53 unmodified lines | |||
| 229 | void inet_bind_bucket_destroy(struct kmem_cache *cachep, | 193 | void inet_bind_bucket_destroy(struct kmem_cache *cachep, |
| 230 | struct inet_bind_bucket *tb); | 194 | struct inet_bind_bucket *tb); |
| 231 | 195 | ||
| 232 | static inline bool check_bind_bucket_match(struct inet_bind_bucket *tb, | ||
| 233 | struct net *net, | ||
| 234 | const unsigned short port, | ||
| 235 | int l3mdev) | ||
| 236 | { | ||
| 237 | return net_eq(ib_net(tb), net) && tb->port == port && | ||
| 238 | tb->l3mdev == l3mdev; | ||
| 239 | } | ||
| 240 | |||
| 241 | struct inet_bind2_bucket * | ||
| 242 | inet_bind2_bucket_create(struct kmem_cache *cachep, struct net *net, | ||
| 243 | struct inet_bind2_hashbucket *head, | ||
| 244 | const unsigned short port, int l3mdev, | ||
| 245 | const struct sock *sk); | ||
| 246 | |||
| 247 | void inet_bind2_bucket_destroy(struct kmem_cache *cachep, | ||
| 248 | struct inet_bind2_bucket *tb); | ||
| 249 | |||
| 250 | struct inet_bind2_bucket * | ||
| 251 | inet_bind2_bucket_find(struct inet_hashinfo *hinfo, struct net *net, | ||
| 252 | const unsigned short port, int l3mdev, | ||
| 253 | struct sock *sk, | ||
| 254 | struct inet_bind2_hashbucket **head); | ||
| 255 | |||
| 256 | bool check_bind2_bucket_match_nulladdr(struct inet_bind2_bucket *tb, | ||
| 257 | struct net *net, | ||
| 258 | const unsigned short port, | ||
| 259 | int l3mdev, | ||
| 260 | const struct sock *sk); | ||
| 261 | |||
| 262 | static inline u32 inet_bhashfn(const struct net *net, const __u16 lport, | 196 | static inline u32 inet_bhashfn(const struct net *net, const __u16 lport, |
| 263 | const u32 bhash_size) | 197 | const u32 bhash_size) |
| 264 | { | 198 | { |
| @@ -266,7 +200,7 @@ static inline u32 inet_bhashfn(const struct net *net, const __u16 lport, · 1 unmodified line | |||
| 266 | } | 200 | } |
| 267 | 201 | ||
| 268 | void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb, | 202 | void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb, |
| 269 | struct inet_bind2_bucket *tb2, const unsigned short snum); | 203 | const unsigned short snum); |
| 270 | 204 | ||
| 271 | /* Caller must disable local BH processing. */ | 205 | /* Caller must disable local BH processing. */ |
| 272 | int __inet_inherit_port(const struct sock *sk, struct sock *child); | 206 | int __inet_inherit_port(const struct sock *sk, struct sock *child); |
| @@ -348,7 +348,6 @@ struct sk_filter; · 347 unmodified lines | |||
| 348 | * @sk_txtime_report_errors: set report errors mode for SO_TXTIME | 348 | * @sk_txtime_report_errors: set report errors mode for SO_TXTIME |
| 349 | * @sk_txtime_unused: unused txtime flags | 349 | * @sk_txtime_unused: unused txtime flags |
| 350 | * @ns_tracker: tracker for netns reference | 350 | * @ns_tracker: tracker for netns reference |
| 351 | * @sk_bind2_node: bind node in the bhash2 table | ||
| 352 | */ | 351 | */ |
| 353 | struct sock { | 352 | struct sock { |
| 354 | /* | 353 | /* |
| @@ -538,7 +537,6 @@ struct sock { · 183 unmodified lines | |||
| 538 | #endif | 537 | #endif |
| 539 | struct rcu_head sk_rcu; | 538 | struct rcu_head sk_rcu; |
| 540 | netns_tracker ns_tracker; | 539 | netns_tracker ns_tracker; |
| 541 | struct hlist_node sk_bind2_node; | ||
| 542 | }; | 540 | }; |
| 543 | 541 | ||
| 544 | enum sk_pacing { | 542 | enum sk_pacing { |
| @@ -819,16 +817,6 @@ static inline void sk_add_bind_node(struct sock *sk, · 274 unmodified lines | |||
| 819 | hlist_add_head(&sk->sk_bind_node, list); | 817 | hlist_add_head(&sk->sk_bind_node, list); |
| 820 | } | 818 | } |
| 821 | 819 | ||
| 822 | static inline void __sk_del_bind2_node(struct sock *sk) | ||
| 823 | { | ||
| 824 | __hlist_del(&sk->sk_bind2_node); | ||
| 825 | } | ||
| 826 | |||
| 827 | static inline void sk_add_bind2_node(struct sock *sk, struct hlist_head *list) | ||
| 828 | { | ||
| 829 | hlist_add_head(&sk->sk_bind2_node, list); | ||
| 830 | } | ||
| 831 | |||
| 832 | #define sk_for_each(__sk, list) \ | 820 | #define sk_for_each(__sk, list) \ |
| 833 | hlist_for_each_entry(__sk, list, sk_node) | 821 | hlist_for_each_entry(__sk, list, sk_node) |
| 834 | #define sk_for_each_rcu(__sk, list) \ | 822 | #define sk_for_each_rcu(__sk, list) \ |
| @@ -846,8 +834,6 @@ static inline void sk_add_bind2_node(struct sock *sk, struct hlist_head *list) · 11 unmodified lines | |||
| 846 | hlist_for_each_entry_safe(__sk, tmp, list, sk_node) | 834 | hlist_for_each_entry_safe(__sk, tmp, list, sk_node) |
| 847 | #define sk_for_each_bound(__sk, list) \ | 835 | #define sk_for_each_bound(__sk, list) \ |
| 848 | hlist_for_each_entry(__sk, list, sk_bind_node) | 836 | hlist_for_each_entry(__sk, list, sk_bind_node) |
| 849 | #define sk_for_each_bound_bhash2(__sk, list) \ | ||
| 850 | hlist_for_each_entry(__sk, list, sk_bind2_node) | ||
| 851 | 837 | ||
| 852 | /** | 838 | /** |
| 853 | * sk_for_each_entry_offset_rcu - iterate over a list at a given struct offset | 839 | * sk_for_each_entry_offset_rcu - iterate over a list at a given struct offset |
| @@ -1661,9 +1661,12 @@ static int ax25_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, · 1660 unmodified lines | |||
| 1661 | int flags) | 1661 | int flags) |
| 1662 | { | 1662 | { |
| 1663 | struct sock *sk = sock->sk; | 1663 | struct sock *sk = sock->sk; |
| 1664 | struct sk_buff *skb; | 1664 | struct sk_buff *skb, *last; |
| 1665 | struct sk_buff_head *sk_queue; | ||
| 1665 | int copied; | 1666 | int copied; |
| 1666 | int err = 0; | 1667 | int err = 0; |
| 1668 | int off = 0; | ||
| 1669 | long timeo; | ||
| 1667 | 1670 | ||
| 1668 | lock_sock(sk); | 1671 | lock_sock(sk); |
| 1669 | /* | 1672 | /* |
| @@ -1675,10 +1678,29 @@ static int ax25_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, · 5 unmodified lines | |||
| 1675 | goto out; | 1678 | goto out; |
| 1676 | } | 1679 | } |
| 1677 | 1680 | ||
| 1678 | /* Now we can treat all alike */ | 1681 | /* We need support for non-blocking reads. */ |
| 1679 | skb = skb_recv_datagram(sk, flags, &err); | 1682 | sk_queue = &sk->sk_receive_queue; |
| 1680 | if (skb == NULL) | 1683 | skb = __skb_try_recv_datagram(sk, sk_queue, flags, &off, &err, &last); |
| 1681 | goto out; | 1684 | /* If no packet is available, release_sock(sk) and try again. */ |
| 1685 | if (!skb) { | ||
| 1686 | if (err != -EAGAIN) | ||
| 1687 | goto out; | ||
| 1688 | release_sock(sk); | ||
| 1689 | timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); | ||
| 1690 | while (timeo && !__skb_wait_for_more_packets(sk, sk_queue, &err, | ||
| 1691 | &timeo, last)) { | ||
| 1692 | skb = __skb_try_recv_datagram(sk, sk_queue, flags, &off, | ||
| 1693 | &err, &last); | ||
| 1694 | if (skb) | ||
| 1695 | break; | ||
| 1696 | |||
| 1697 | if (err != -EAGAIN) | ||
| 1698 | goto done; | ||
| 1699 | } | ||
| 1700 | if (!skb) | ||
| 1701 | goto done; | ||
| 1702 | lock_sock(sk); | ||
| 1703 | } | ||
| 1682 | 1704 | ||
| 1683 | if (!sk_to_ax25(sk)->pidincl) | 1705 | if (!sk_to_ax25(sk)->pidincl) |
| 1684 | skb_pull(skb, 1); /* Remove PID */ | 1706 | skb_pull(skb, 1); /* Remove PID */ |
| @@ -1725,6 +1747,7 @@ static int ax25_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, · 40 unmodified lines | |||
| 1725 | out: | 1747 | out: |
| 1726 | release_sock(sk); | 1748 | release_sock(sk); |
| 1727 | 1749 | ||
| 1750 | done: | ||
| 1728 | return err; | 1751 | return err; |
| 1729 | } | 1752 | } |
| 1730 | 1753 | ||
| @@ -1120,12 +1120,6 @@ static int __init dccp_init(void) · 1119 unmodified lines | |||
| 1120 | SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT, NULL); | 1120 | SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT, NULL); |
| 1121 | if (!dccp_hashinfo.bind_bucket_cachep) | 1121 | if (!dccp_hashinfo.bind_bucket_cachep) |
| 1122 | goto out_free_hashinfo2; | 1122 | goto out_free_hashinfo2; |
| 1123 | dccp_hashinfo.bind2_bucket_cachep = | ||
| 1124 | kmem_cache_create("dccp_bind2_bucket", | ||
| 1125 | sizeof(struct inet_bind2_bucket), 0, | ||
| 1126 | SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT, NULL); | ||
| 1127 | if (!dccp_hashinfo.bind2_bucket_cachep) | ||
| 1128 | goto out_free_bind_bucket_cachep; | ||
| 1129 | 1123 | ||
| 1130 | /* | 1124 | /* |
| 1131 | * Size and allocate the main established and bind bucket | 1125 | * Size and allocate the main established and bind bucket |
| @@ -1156,7 +1150,7 @@ static int __init dccp_init(void) · 24 unmodified lines | |||
| 1156 | 1150 | ||
| 1157 | if (!dccp_hashinfo.ehash) { | 1151 | if (!dccp_hashinfo.ehash) { |
| 1158 | DCCP_CRIT("Failed to allocate DCCP established hash table"); | 1152 | DCCP_CRIT("Failed to allocate DCCP established hash table"); |
| 1159 | goto out_free_bind2_bucket_cachep; | 1153 | goto out_free_bind_bucket_cachep; |
| 1160 | } | 1154 | } |
| 1161 | 1155 | ||
| 1162 | for (i = 0; i <= dccp_hashinfo.ehash_mask; i++) | 1156 | for (i = 0; i <= dccp_hashinfo.ehash_mask; i++) |
| @@ -1182,23 +1176,14 @@ static int __init dccp_init(void) · 19 unmodified lines | |||
| 1182 | goto out_free_dccp_locks; | 1176 | goto out_free_dccp_locks; |
| 1183 | } | 1177 | } |
| 1184 | 1178 | ||
| 1185 | dccp_hashinfo.bhash2 = (struct inet_bind2_hashbucket *) | ||
| 1186 | __get_free_pages(GFP_ATOMIC | __GFP_NOWARN, bhash_order); | ||
| 1187 | |||
| 1188 | if (!dccp_hashinfo.bhash2) { | ||
| 1189 | DCCP_CRIT("Failed to allocate DCCP bind2 hash table"); | ||
| 1190 | goto out_free_dccp_bhash; | ||
| 1191 | } | ||
| 1192 | |||
| 1193 | for (i = 0; i < dccp_hashinfo.bhash_size; i++) { | 1179 | for (i = 0; i < dccp_hashinfo.bhash_size; i++) { |
| 1194 | spin_lock_init(&dccp_hashinfo.bhash[i].lock); | 1180 | spin_lock_init(&dccp_hashinfo.bhash[i].lock); |
| 1195 | INIT_HLIST_HEAD(&dccp_hashinfo.bhash[i].chain); | 1181 | INIT_HLIST_HEAD(&dccp_hashinfo.bhash[i].chain); |
| 1196 | INIT_HLIST_HEAD(&dccp_hashinfo.bhash2[i].chain); | ||
| 1197 | } | 1182 | } |
| 1198 | 1183 | ||
| 1199 | rc = dccp_mib_init(); | 1184 | rc = dccp_mib_init(); |
| 1200 | if (rc) | 1185 | if (rc) |
| 1201 | goto out_free_dccp_bhash2; | 1186 | goto out_free_dccp_bhash; |
| 1202 | 1187 | ||
| 1203 | rc = dccp_ackvec_init(); | 1188 | rc = dccp_ackvec_init(); |
| 1204 | if (rc) | 1189 | if (rc) |
| @@ -1222,38 +1207,30 @@ out_ackvec_exit: · 17 unmodified lines | |||
| 1222 | dccp_ackvec_exit(); | 1207 | dccp_ackvec_exit(); |
| 1223 | out_free_dccp_mib: | 1208 | out_free_dccp_mib: |
| 1224 | dccp_mib_exit(); | 1209 | dccp_mib_exit(); |
| 1225 | out_free_dccp_bhash2: | ||
| 1226 | free_pages((unsigned long)dccp_hashinfo.bhash2, bhash_order); | ||
| 1227 | out_free_dccp_bhash: | 1210 | out_free_dccp_bhash: |
| 1228 | free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order); | 1211 | free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order); |
| 1229 | out_free_dccp_locks: | 1212 | out_free_dccp_locks: |
| 1230 | inet_ehash_locks_free(&dccp_hashinfo); | 1213 | inet_ehash_locks_free(&dccp_hashinfo); |
| 1231 | out_free_dccp_ehash: | 1214 | out_free_dccp_ehash: |
| 1232 | free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order); | 1215 | free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order); |
| 1233 | out_free_bind2_bucket_cachep: | ||
| 1234 | kmem_cache_destroy(dccp_hashinfo.bind2_bucket_cachep); | ||
| 1235 | out_free_bind_bucket_cachep: | 1216 | out_free_bind_bucket_cachep: |
| 1236 | kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep); | 1217 | kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep); |
| 1237 | out_free_hashinfo2: | 1218 | out_free_hashinfo2: |
| 1238 | inet_hashinfo2_free_mod(&dccp_hashinfo); | 1219 | inet_hashinfo2_free_mod(&dccp_hashinfo); |
| 1239 | out_fail: | 1220 | out_fail: |
| 1240 | dccp_hashinfo.bhash = NULL; | 1221 | dccp_hashinfo.bhash = NULL; |
| 1241 | dccp_hashinfo.bhash2 = NULL; | ||
| 1242 | dccp_hashinfo.ehash = NULL; | 1222 | dccp_hashinfo.ehash = NULL; |
| 1243 | dccp_hashinfo.bind_bucket_cachep = NULL; | 1223 | dccp_hashinfo.bind_bucket_cachep = NULL; |
| 1244 | dccp_hashinfo.bind2_bucket_cachep = NULL; | ||
| 1245 | return rc; | 1224 | return rc; |
| 1246 | } | 1225 | } |
| 1247 | 1226 | ||
| 1248 | static void __exit dccp_fini(void) | 1227 | static void __exit dccp_fini(void) |
| 1249 | { | 1228 | { |
| 1250 | int bhash_order = get_order(dccp_hashinfo.bhash_size * | ||
| 1251 | sizeof(struct inet_bind_hashbucket)); | ||
| 1252 | |||
| 1253 | ccid_cleanup_builtins(); | 1229 | ccid_cleanup_builtins(); |
| 1254 | dccp_mib_exit(); | 1230 | dccp_mib_exit(); |
| 1255 | free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order); | 1231 | free_pages((unsigned long)dccp_hashinfo.bhash, |
| 1256 | free_pages((unsigned long)dccp_hashinfo.bhash2, bhash_order); | 1232 | get_order(dccp_hashinfo.bhash_size * |
| 1233 | sizeof(struct inet_bind_hashbucket))); | ||
| 1257 | free_pages((unsigned long)dccp_hashinfo.ehash, | 1234 | free_pages((unsigned long)dccp_hashinfo.ehash, |
| 1258 | get_order((dccp_hashinfo.ehash_mask + 1) * | 1235 | get_order((dccp_hashinfo.ehash_mask + 1) * |
| 1259 | sizeof(struct inet_ehash_bucket))); | 1236 | sizeof(struct inet_ehash_bucket))); |
| @@ -117,32 +117,6 @@ bool inet_rcv_saddr_any(const struct sock *sk) · 116 unmodified lines | |||
| 117 | return !sk->sk_rcv_saddr; | 117 | return !sk->sk_rcv_saddr; |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | static bool use_bhash2_on_bind(const struct sock *sk) | ||
| 121 | { | ||
| 122 | #if IS_ENABLED(CONFIG_IPV6) | ||
| 123 | int addr_type; | ||
| 124 | |||
| 125 | if (sk->sk_family == AF_INET6) { | ||
| 126 | addr_type = ipv6_addr_type(&sk->sk_v6_rcv_saddr); | ||
| 127 | return addr_type != IPV6_ADDR_ANY && | ||
| 128 | addr_type != IPV6_ADDR_MAPPED; | ||
| 129 | } | ||
| 130 | #endif | ||
| 131 | return sk->sk_rcv_saddr != htonl(INADDR_ANY); | ||
| 132 | } | ||
| 133 | |||
| 134 | static u32 get_bhash2_nulladdr_hash(const struct sock *sk, struct net *net, | ||
| 135 | int port) | ||
| 136 | { | ||
| 137 | #if IS_ENABLED(CONFIG_IPV6) | ||
| 138 | struct in6_addr nulladdr = {}; | ||
| 139 | |||
| 140 | if (sk->sk_family == AF_INET6) | ||
| 141 | return ipv6_portaddr_hash(net, &nulladdr, port); | ||
| 142 | #endif | ||
| 143 | return ipv4_portaddr_hash(net, 0, port); | ||
| 144 | } | ||
| 145 | |||
| 146 | void inet_get_local_port_range(struct net *net, int *low, int *high) | 120 | void inet_get_local_port_range(struct net *net, int *low, int *high) |
| 147 | { | 121 | { |
| 148 | unsigned int seq; | 122 | unsigned int seq; |
| @@ -156,71 +130,16 @@ void inet_get_local_port_range(struct net *net, int *low, int *high) · 7 unmodified lines | |||
| 156 | } | 130 | } |
| 157 | EXPORT_SYMBOL(inet_get_local_port_range); | 131 | EXPORT_SYMBOL(inet_get_local_port_range); |
| 158 | 132 | ||
| 159 | static bool bind_conflict_exist(const struct sock *sk, struct sock *sk2, | 133 | static int inet_csk_bind_conflict(const struct sock *sk, |
| 160 | kuid_t sk_uid, bool relax, | 134 | const struct inet_bind_bucket *tb, |
| 161 | bool reuseport_cb_ok, bool reuseport_ok) | ||
| 162 | { | ||
| 163 | int bound_dev_if2; | ||
| 164 | |||
| 165 | if (sk == sk2) | ||
| 166 | return false; | ||
| 167 | |||
| 168 | bound_dev_if2 = READ_ONCE(sk2->sk_bound_dev_if); | ||
| 169 | |||
| 170 | if (!sk->sk_bound_dev_if || !bound_dev_if2 || | ||
| 171 | sk->sk_bound_dev_if == bound_dev_if2) { | ||
| 172 | if (sk->sk_reuse && sk2->sk_reuse && | ||
| 173 | sk2->sk_state != TCP_LISTEN) { | ||
| 174 | if (!relax || (!reuseport_ok && sk->sk_reuseport && | ||
| 175 | sk2->sk_reuseport && reuseport_cb_ok && | ||
| 176 | (sk2->sk_state == TCP_TIME_WAIT || | ||
| 177 | uid_eq(sk_uid, sock_i_uid(sk2))))) | ||
| 178 | return true; | ||
| 179 | } else if (!reuseport_ok || !sk->sk_reuseport || | ||
| 180 | !sk2->sk_reuseport || !reuseport_cb_ok || | ||
| 181 | (sk2->sk_state != TCP_TIME_WAIT && | ||
| 182 | !uid_eq(sk_uid, sock_i_uid(sk2)))) { | ||
| 183 | return true; | ||
| 184 | } | ||
| 185 | } | ||
| 186 | return false; | ||
| 187 | } | ||
| 188 | |||
| 189 | static bool check_bhash2_conflict(const struct sock *sk, | ||
| 190 | struct inet_bind2_bucket *tb2, kuid_t sk_uid, | ||
| 191 | bool relax, bool reuseport_cb_ok, | ||
| 192 | bool reuseport_ok) | ||
| 193 | { | ||
| 194 | struct sock *sk2; | ||
| 195 | |||
| 196 | sk_for_each_bound_bhash2(sk2, &tb2->owners) { | ||
| 197 | if (sk->sk_family == AF_INET && ipv6_only_sock(sk2)) | ||
| 198 | continue; | ||
| 199 | |||
| 200 | if (bind_conflict_exist(sk, sk2, sk_uid, relax, | ||
| 201 | reuseport_cb_ok, reuseport_ok)) | ||
| 202 | return true; | ||
| 203 | } | ||
| 204 | return false; | ||
| 205 | } | ||
| 206 | |||
| 207 | /* This should be called only when the corresponding inet_bind_bucket spinlock | ||
| 208 | * is held | ||
| 209 | */ | ||
| 210 | static int inet_csk_bind_conflict(const struct sock *sk, int port, | ||
| 211 | struct inet_bind_bucket *tb, | ||
| 212 | struct inet_bind2_bucket *tb2, /* may be null */ | ||
| 213 | bool relax, bool reuseport_ok) | 135 | bool relax, bool reuseport_ok) |
| 214 | { | 136 | { |
| 215 | struct inet_hashinfo *hinfo = sk->sk_prot->h.hashinfo; | ||
| 216 | kuid_t uid = sock_i_uid((struct sock *)sk); | ||
| 217 | struct sock_reuseport *reuseport_cb; | ||
| 218 | struct inet_bind2_hashbucket *head2; | ||
| 219 | bool reuseport_cb_ok; | ||
| 220 | struct sock *sk2; | 137 | struct sock *sk2; |
| 221 | struct net *net; | 138 | bool reuseport_cb_ok; |
| 222 | int l3mdev; | 139 | bool reuse = sk->sk_reuse; |
| 223 | u32 hash; | 140 | bool reuseport = !!sk->sk_reuseport; |
| 141 | struct sock_reuseport *reuseport_cb; | ||
| 142 | kuid_t uid = sock_i_uid((struct sock *)sk); | ||
| 224 | 143 | ||
| 225 | rcu_read_lock(); | 144 | rcu_read_lock(); |
| 226 | reuseport_cb = rcu_dereference(sk->sk_reuseport_cb); | 145 | reuseport_cb = rcu_dereference(sk->sk_reuseport_cb); |
| @@ -231,42 +150,40 @@ static int inet_csk_bind_conflict(const struct sock *sk, int port, · 4 unmodified lines | |||
| 231 | /* | 150 | /* |
| 232 | * Unlike other sk lookup places we do not check | 151 | * Unlike other sk lookup places we do not check |
| 233 | * for sk_net here, since _all_ the socks listed | 152 | * for sk_net here, since _all_ the socks listed |
| 234 | * in tb->owners and tb2->owners list belong | 153 | * in tb->owners list belong to the same net - the |
| 235 | * to the same net | 154 | * one this bucket belongs to. |
| 236 | */ | 155 | */ |
| 237 | 156 | ||
| 238 | if (!use_bhash2_on_bind(sk)) { | 157 | sk_for_each_bound(sk2, &tb->owners) { |
| 239 | sk_for_each_bound(sk2, &tb->owners) | 158 | int bound_dev_if2; |
| 240 | if (bind_conflict_exist(sk, sk2, uid, relax, | ||
| 241 | reuseport_cb_ok, reuseport_ok) && | ||
| 242 | inet_rcv_saddr_equal(sk, sk2, true)) | ||
| 243 | return true; | ||
| 244 | 159 | ||
| 245 | return false; | 160 | if (sk == sk2) |
| 161 | continue; | ||
| 162 | bound_dev_if2 = READ_ONCE(sk2->sk_bound_dev_if); | ||
| 163 | if ((!sk->sk_bound_dev_if || | ||
| 164 | !bound_dev_if2 || | ||
| 165 | sk->sk_bound_dev_if == bound_dev_if2)) { | ||
| 166 | if (reuse && sk2->sk_reuse && | ||
| 167 | sk2->sk_state != TCP_LISTEN) { | ||
| 168 | if ((!relax || | ||
| 169 | (!reuseport_ok && | ||
| 170 | reuseport && sk2->sk_reuseport && | ||
| 171 | reuseport_cb_ok && | ||
| 172 | (sk2->sk_state == TCP_TIME_WAIT || | ||
| 173 | uid_eq(uid, sock_i_uid(sk2))))) && | ||
| 174 | inet_rcv_saddr_equal(sk, sk2, true)) | ||
| 175 | break; | ||
| 176 | } else if (!reuseport_ok || | ||
| 177 | !reuseport || !sk2->sk_reuseport || | ||
| 178 | !reuseport_cb_ok || | ||
| 179 | (sk2->sk_state != TCP_TIME_WAIT && | ||
| 180 | !uid_eq(uid, sock_i_uid(sk2)))) { | ||
| 181 | if (inet_rcv_saddr_equal(sk, sk2, true)) | ||
| 182 | break; | ||
| 183 | } | ||
| 184 | } | ||
| 246 | } | 185 | } |
| 247 | 186 | return sk2 != NULL; | |
| 248 | if (tb2 && check_bhash2_conflict(sk, tb2, uid, relax, reuseport_cb_ok, | ||
| 249 | reuseport_ok)) | ||
| 250 | return true; | ||
| 251 | |||
| 252 | net = sock_net(sk); | ||
| 253 | |||
| 254 | /* check there's no conflict with an existing IPV6_ADDR_ANY (if ipv6) or | ||
| 255 | * INADDR_ANY (if ipv4) socket. | ||
| 256 | */ | ||
| 257 | hash = get_bhash2_nulladdr_hash(sk, net, port); | ||
| 258 | head2 = &hinfo->bhash2[hash & (hinfo->bhash_size - 1)]; | ||
| 259 | |||
| 260 | l3mdev = inet_sk_bound_l3mdev(sk); | ||
| 261 | inet_bind_bucket_for_each(tb2, &head2->chain) | ||
| 262 | if (check_bind2_bucket_match_nulladdr(tb2, net, port, l3mdev, sk)) | ||
| 263 | break; | ||
| 264 | |||
| 265 | if (tb2 && check_bhash2_conflict(sk, tb2, uid, relax, reuseport_cb_ok, | ||
| 266 | reuseport_ok)) | ||
| 267 | return true; | ||
| 268 | |||
| 269 | return false; | ||
| 270 | } | 187 | } |
| 271 | 188 | ||
| 272 | /* | 189 | /* |
| @@ -274,20 +191,16 @@ static int inet_csk_bind_conflict(const struct sock *sk, int port, · 1 unmodified line | |||
| 274 | * inet_bind_hashbucket lock held. | 191 | * inet_bind_hashbucket lock held. |
| 275 | */ | 192 | */ |
| 276 | static struct inet_bind_hashbucket * | 193 | static struct inet_bind_hashbucket * |
| 277 | inet_csk_find_open_port(struct sock *sk, struct inet_bind_bucket **tb_ret, | 194 | inet_csk_find_open_port(struct sock *sk, struct inet_bind_bucket **tb_ret, int *port_ret) |
| 278 | struct inet_bind2_bucket **tb2_ret, | ||
| 279 | struct inet_bind2_hashbucket **head2_ret, int *port_ret) | ||
| 280 | { | 195 | { |
| 281 | struct inet_hashinfo *hinfo = sk->sk_prot->h.hashinfo; | 196 | struct inet_hashinfo *hinfo = sk->sk_prot->h.hashinfo; |
| 282 | struct inet_bind2_hashbucket *head2; | 197 | int port = 0; |
| 283 | struct inet_bind_hashbucket *head; | 198 | struct inet_bind_hashbucket *head; |
| 284 | struct net *net = sock_net(sk); | 199 | struct net *net = sock_net(sk); |
| 200 | bool relax = false; | ||
| 285 | int i, low, high, attempt_half; | 201 | int i, low, high, attempt_half; |
| 286 | struct inet_bind2_bucket *tb2; | ||
| 287 | struct inet_bind_bucket *tb; | 202 | struct inet_bind_bucket *tb; |
| 288 | u32 remaining, offset; | 203 | u32 remaining, offset; |
| 289 | bool relax = false; | ||
| 290 | int port = 0; | ||
| 291 | int l3mdev; | 204 | int l3mdev; |
| 292 | 205 | ||
| 293 | l3mdev = inet_sk_bound_l3mdev(sk); | 206 | l3mdev = inet_sk_bound_l3mdev(sk); |
| @@ -326,12 +239,10 @@ other_parity_scan: · 32 unmodified lines | |||
| 326 | head = &hinfo->bhash[inet_bhashfn(net, port, | 239 | head = &hinfo->bhash[inet_bhashfn(net, port, |
| 327 | hinfo->bhash_size)]; | 240 | hinfo->bhash_size)]; |
| 328 | spin_lock_bh(&head->lock); | 241 | spin_lock_bh(&head->lock); |
| 329 | tb2 = inet_bind2_bucket_find(hinfo, net, port, l3mdev, sk, | ||
| 330 | &head2); | ||
| 331 | inet_bind_bucket_for_each(tb, &head->chain) | 242 | inet_bind_bucket_for_each(tb, &head->chain) |
| 332 | if (check_bind_bucket_match(tb, net, port, l3mdev)) { | 243 | if (net_eq(ib_net(tb), net) && tb->l3mdev == l3mdev && |
| 333 | if (!inet_csk_bind_conflict(sk, port, tb, tb2, | 244 | tb->port == port) { |
| 334 | relax, false)) | 245 | if (!inet_csk_bind_conflict(sk, tb, relax, false)) |
| 335 | goto success; | 246 | goto success; |
| 336 | goto next_port; | 247 | goto next_port; |
| 337 | } | 248 | } |
| @@ -361,8 +272,6 @@ next_port: · 23 unmodified lines | |||
| 361 | success: | 272 | success: |
| 362 | *port_ret = port; | 273 | *port_ret = port; |
| 363 | *tb_ret = tb; | 274 | *tb_ret = tb; |
| 364 | *tb2_ret = tb2; | ||
| 365 | *head2_ret = head2; | ||
| 366 | return head; | 275 | return head; |
| 367 | } | 276 | } |
| 368 | 277 | ||
| @@ -458,81 +367,54 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum) · 89 unmodified lines | |||
| 458 | { | 367 | { |
| 459 | bool reuse = sk->sk_reuse && sk->sk_state != TCP_LISTEN; | 368 | bool reuse = sk->sk_reuse && sk->sk_state != TCP_LISTEN; |
| 460 | struct inet_hashinfo *hinfo = sk->sk_prot->h.hashinfo; | 369 | struct inet_hashinfo *hinfo = sk->sk_prot->h.hashinfo; |
| 461 | bool bhash_created = false, bhash2_created = false; | 370 | int ret = 1, port = snum; |
| 462 | struct inet_bind2_bucket *tb2 = NULL; | ||
| 463 | struct inet_bind2_hashbucket *head2; | ||
| 464 | struct inet_bind_bucket *tb = NULL; | ||
| 465 | struct inet_bind_hashbucket *head; | 371 | struct inet_bind_hashbucket *head; |
| 466 | struct net *net = sock_net(sk); | 372 | struct net *net = sock_net(sk); |
| 467 | int ret = 1, port = snum; | 373 | struct inet_bind_bucket *tb = NULL; |
| 468 | bool found_port = false; | ||
| 469 | int l3mdev; | 374 | int l3mdev; |
| 470 | 375 | ||
| 471 | l3mdev = inet_sk_bound_l3mdev(sk); | 376 | l3mdev = inet_sk_bound_l3mdev(sk); |
| 472 | 377 | ||
| 473 | if (!port) { | 378 | if (!port) { |
| 474 | head = inet_csk_find_open_port(sk, &tb, &tb2, &head2, &port); | 379 | head = inet_csk_find_open_port(sk, &tb, &port); |
| 475 | if (!head) | 380 | if (!head) |
| 476 | return ret; | 381 | return ret; |
| 477 | if (tb && tb2) | ||
| 478 | goto success; | ||
| 479 | found_port = true; | ||
| 480 | } else { | ||
| 481 | head = &hinfo->bhash[inet_bhashfn(net, port, | ||
| 482 | hinfo->bhash_size)]; | ||
| 483 | spin_lock_bh(&head->lock); | ||
| 484 | inet_bind_bucket_for_each(tb, &head->chain) | ||
| 485 | if (check_bind_bucket_match(tb, net, port, l3mdev)) | ||
| 486 | break; | ||
| 487 | |||
| 488 | tb2 = inet_bind2_bucket_find(hinfo, net, port, l3mdev, sk, | ||
| 489 | &head2); | ||
| 490 | } | ||
| 491 | |||
| 492 | if (!tb) { | ||
| 493 | tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep, net, | ||
| 494 | head, port, l3mdev); | ||
| 495 | if (!tb) | 382 | if (!tb) |
| 496 | goto fail_unlock; | 383 | goto tb_not_found; |
| 497 | bhash_created = true; | 384 | goto success; |
| 498 | } | ||
| 499 | |||
| 500 | if (!tb2) { | ||
| 501 | tb2 = inet_bind2_bucket_create(hinfo->bind2_bucket_cachep, | ||
| 502 | net, head2, port, l3mdev, sk); | ||
| 503 | if (!tb2) | ||
| 504 | goto fail_unlock; | ||
| 505 | bhash2_created = true; | ||
| 506 | } | 385 | } |
| 507 | 386 | head = &hinfo->bhash[inet_bhashfn(net, port, | |
| 508 | /* If we had to find an open port, we already checked for conflicts */ | 387 | hinfo->bhash_size)]; |
| 509 | if (!found_port && !hlist_empty(&tb->owners)) { | 388 | spin_lock_bh(&head->lock); |
| 389 | inet_bind_bucket_for_each(tb, &head->chain) | ||
| 390 | if (net_eq(ib_net(tb), net) && tb->l3mdev == l3mdev && | ||
| 391 | tb->port == port) | ||
| 392 | goto tb_found; | ||
| 393 | tb_not_found: | ||
| 394 | tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep, | ||
| 395 | net, head, port, l3mdev); | ||
| 396 | if (!tb) | ||
| 397 | goto fail_unlock; | ||
| 398 | tb_found: | ||
| 399 | if (!hlist_empty(&tb->owners)) { | ||
| 510 | if (sk->sk_reuse == SK_FORCE_REUSE) | 400 | if (sk->sk_reuse == SK_FORCE_REUSE) |
| 511 | goto success; | 401 | goto success; |
| 512 | 402 | ||
| 513 | if ((tb->fastreuse > 0 && reuse) || | 403 | if ((tb->fastreuse > 0 && reuse) || |
| 514 | sk_reuseport_match(tb, sk)) | 404 | sk_reuseport_match(tb, sk)) |
| 515 | goto success; | 405 | goto success; |
| 516 | if (inet_csk_bind_conflict(sk, port, tb, tb2, true, true)) | 406 | if (inet_csk_bind_conflict(sk, tb, true, true)) |
| 517 | goto fail_unlock; | 407 | goto fail_unlock; |
| 518 | } | 408 | } |
| 519 | success: | 409 | success: |
| 520 | inet_csk_update_fastreuse(tb, sk); | 410 | inet_csk_update_fastreuse(tb, sk); |
| 521 | 411 | ||
| 522 | if (!inet_csk(sk)->icsk_bind_hash) | 412 | if (!inet_csk(sk)->icsk_bind_hash) |
| 523 | inet_bind_hash(sk, tb, tb2, port); | 413 | inet_bind_hash(sk, tb, port); |
| 524 | WARN_ON(inet_csk(sk)->icsk_bind_hash != tb); | 414 | WARN_ON(inet_csk(sk)->icsk_bind_hash != tb); |
| 525 | WARN_ON(inet_csk(sk)->icsk_bind2_hash != tb2); | ||
| 526 | ret = 0; | 415 | ret = 0; |
| 527 | 416 | ||
| 528 | fail_unlock: | 417 | fail_unlock: |
| 529 | if (ret) { | ||
| 530 | if (bhash_created) | ||
| 531 | inet_bind_bucket_destroy(hinfo->bind_bucket_cachep, tb); | ||
| 532 | if (bhash2_created) | ||
| 533 | inet_bind2_bucket_destroy(hinfo->bind2_bucket_cachep, | ||
| 534 | tb2); | ||
| 535 | } | ||
| 536 | spin_unlock_bh(&head->lock); | 418 | spin_unlock_bh(&head->lock); |
| 537 | return ret; | 419 | return ret; |
| 538 | } | 420 | } |
| @@ -1079,7 +961,6 @@ struct sock *inet_csk_clone_lock(const struct sock *sk, · 540 unmodified lines | |||
| 1079 | 961 | ||
| 1080 | inet_sk_set_state(newsk, TCP_SYN_RECV); | 962 | inet_sk_set_state(newsk, TCP_SYN_RECV); |
| 1081 | newicsk->icsk_bind_hash = NULL; | 963 | newicsk->icsk_bind_hash = NULL; |
| 1082 | newicsk->icsk_bind2_hash = NULL; | ||
| 1083 | 964 | ||
| 1084 | inet_sk(newsk)->inet_dport = inet_rsk(req)->ir_rmt_port; | 965 | inet_sk(newsk)->inet_dport = inet_rsk(req)->ir_rmt_port; |
| 1085 | inet_sk(newsk)->inet_num = inet_rsk(req)->ir_num; | 966 | inet_sk(newsk)->inet_num = inet_rsk(req)->ir_num; |
| @@ -81,41 +81,6 @@ struct inet_bind_bucket *inet_bind_bucket_create(struct kmem_cache *cachep, · 80 unmodified lines | |||
| 81 | return tb; | 81 | return tb; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | struct inet_bind2_bucket *inet_bind2_bucket_create(struct kmem_cache *cachep, | ||
| 85 | struct net *net, | ||
| 86 | struct inet_bind2_hashbucket *head, | ||
| 87 | const unsigned short port, | ||
| 88 | int l3mdev, | ||
| 89 | const struct sock *sk) | ||
| 90 | { | ||
| 91 | struct inet_bind2_bucket *tb = kmem_cache_alloc(cachep, GFP_ATOMIC); | ||
| 92 | |||
| 93 | if (tb) { | ||
| 94 | write_pnet(&tb->ib_net, net); | ||
| 95 | tb->l3mdev = l3mdev; | ||
| 96 | tb->port = port; | ||
| 97 | #if IS_ENABLED(CONFIG_IPV6) | ||
| 98 | if (sk->sk_family == AF_INET6) | ||
| 99 | tb->v6_rcv_saddr = sk->sk_v6_rcv_saddr; | ||
| 100 | else | ||
| 101 | #endif | ||
| 102 | tb->rcv_saddr = sk->sk_rcv_saddr; | ||
| 103 | INIT_HLIST_HEAD(&tb->owners); | ||
| 104 | hlist_add_head(&tb->node, &head->chain); | ||
| 105 | } | ||
| 106 | return tb; | ||
| 107 | } | ||
| 108 | |||
| 109 | static bool bind2_bucket_addr_match(struct inet_bind2_bucket *tb2, struct sock *sk) | ||
| 110 | { | ||
| 111 | #if IS_ENABLED(CONFIG_IPV6) | ||
| 112 | if (sk->sk_family == AF_INET6) | ||
| 113 | return ipv6_addr_equal(&tb2->v6_rcv_saddr, | ||
| 114 | &sk->sk_v6_rcv_saddr); | ||
| 115 | #endif | ||
| 116 | return tb2->rcv_saddr == sk->sk_rcv_saddr; | ||
| 117 | } | ||
| 118 | |||
| 119 | /* | 84 | /* |
| 120 | * Caller must hold hashbucket lock for this tb with local BH disabled | 85 | * Caller must hold hashbucket lock for this tb with local BH disabled |
| 121 | */ | 86 | */ |
| @@ -127,25 +92,12 @@ void inet_bind_bucket_destroy(struct kmem_cache *cachep, struct inet_bind_bucket · 5 unmodified lines | |||
| 127 | } | 92 | } |
| 128 | } | 93 | } |
| 129 | 94 | ||
| 130 | /* Caller must hold the lock for the corresponding hashbucket in the bhash table | ||
| 131 | * with local BH disabled | ||
| 132 | */ | ||
| 133 | void inet_bind2_bucket_destroy(struct kmem_cache *cachep, struct inet_bind2_bucket *tb) | ||
| 134 | { | ||
| 135 | if (hlist_empty(&tb->owners)) { | ||
| 136 | __hlist_del(&tb->node); | ||
| 137 | kmem_cache_free(cachep, tb); | ||
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb, | 95 | void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb, |
| 142 | struct inet_bind2_bucket *tb2, const unsigned short snum) | 96 | const unsigned short snum) |
| 143 | { | 97 | { |
| 144 | inet_sk(sk)->inet_num = snum; | 98 | inet_sk(sk)->inet_num = snum; |
| 145 | sk_add_bind_node(sk, &tb->owners); | 99 | sk_add_bind_node(sk, &tb->owners); |
| 146 | inet_csk(sk)->icsk_bind_hash = tb; | 100 | inet_csk(sk)->icsk_bind_hash = tb; |
| 147 | sk_add_bind2_node(sk, &tb2->owners); | ||
| 148 | inet_csk(sk)->icsk_bind2_hash = tb2; | ||
| 149 | } | 101 | } |
| 150 | 102 | ||
| 151 | /* | 103 | /* |
| @@ -157,7 +109,6 @@ static void __inet_put_port(struct sock *sk) · 5 unmodified lines | |||
| 157 | const int bhash = inet_bhashfn(sock_net(sk), inet_sk(sk)->inet_num, | 109 | const int bhash = inet_bhashfn(sock_net(sk), inet_sk(sk)->inet_num, |
| 158 | hashinfo->bhash_size); | 110 | hashinfo->bhash_size); |
| 159 | struct inet_bind_hashbucket *head = &hashinfo->bhash[bhash]; | 111 | struct inet_bind_hashbucket *head = &hashinfo->bhash[bhash]; |
| 160 | struct inet_bind2_bucket *tb2; | ||
| 161 | struct inet_bind_bucket *tb; | 112 | struct inet_bind_bucket *tb; |
| 162 | 113 | ||
| 163 | spin_lock(&head->lock); | 114 | spin_lock(&head->lock); |
| @@ -166,13 +117,6 @@ static void __inet_put_port(struct sock *sk) · 2 unmodified lines | |||
| 166 | inet_csk(sk)->icsk_bind_hash = NULL; | 117 | inet_csk(sk)->icsk_bind_hash = NULL; |
| 167 | inet_sk(sk)->inet_num = 0; | 118 | inet_sk(sk)->inet_num = 0; |
| 168 | inet_bind_bucket_destroy(hashinfo->bind_bucket_cachep, tb); | 119 | inet_bind_bucket_destroy(hashinfo->bind_bucket_cachep, tb); |
| 169 | |||
| 170 | if (inet_csk(sk)->icsk_bind2_hash) { | ||
| 171 | tb2 = inet_csk(sk)->icsk_bind2_hash; | ||
| 172 | __sk_del_bind2_node(sk); | ||
| 173 | inet_csk(sk)->icsk_bind2_hash = NULL; | ||
| 174 | inet_bind2_bucket_destroy(hashinfo->bind2_bucket_cachep, tb2); | ||
| 175 | } | ||
| 176 | spin_unlock(&head->lock); | 120 | spin_unlock(&head->lock); |
| 177 | } | 121 | } |
| 178 | 122 | ||
| @@ -189,19 +133,14 @@ int __inet_inherit_port(const struct sock *sk, struct sock *child) · 10 unmodified lines | |||
| 189 | struct inet_hashinfo *table = sk->sk_prot->h.hashinfo; | 133 | struct inet_hashinfo *table = sk->sk_prot->h.hashinfo; |
| 190 | unsigned short port = inet_sk(child)->inet_num; | 134 | unsigned short port = inet_sk(child)->inet_num; |
| 191 | const int bhash = inet_bhashfn(sock_net(sk), port, | 135 | const int bhash = inet_bhashfn(sock_net(sk), port, |
| 192 | table->bhash_size); | 136 | table->bhash_size); |
| 193 | struct inet_bind_hashbucket *head = &table->bhash[bhash]; | 137 | struct inet_bind_hashbucket *head = &table->bhash[bhash]; |
| 194 | struct inet_bind2_hashbucket *head_bhash2; | ||
| 195 | bool created_inet_bind_bucket = false; | ||
| 196 | struct net *net = sock_net(sk); | ||
| 197 | struct inet_bind2_bucket *tb2; | ||
| 198 | struct inet_bind_bucket *tb; | 138 | struct inet_bind_bucket *tb; |
| 199 | int l3mdev; | 139 | int l3mdev; |
| 200 | 140 | ||
| 201 | spin_lock(&head->lock); | 141 | spin_lock(&head->lock); |
| 202 | tb = inet_csk(sk)->icsk_bind_hash; | 142 | tb = inet_csk(sk)->icsk_bind_hash; |
| 203 | tb2 = inet_csk(sk)->icsk_bind2_hash; | 143 | if (unlikely(!tb)) { |
| 204 | if (unlikely(!tb || !tb2)) { | ||
| 205 | spin_unlock(&head->lock); | 144 | spin_unlock(&head->lock); |
| 206 | return -ENOENT; | 145 | return -ENOENT; |
| 207 | } | 146 | } |
| @@ -214,45 +153,25 @@ int __inet_inherit_port(const struct sock *sk, struct sock *child) · 6 unmodified lines | |||
| 214 | * as that of the child socket. We have to look up or | 153 | * as that of the child socket. We have to look up or |
| 215 | * create a new bind bucket for the child here. */ | 154 | * create a new bind bucket for the child here. */ |
| 216 | inet_bind_bucket_for_each(tb, &head->chain) { | 155 | inet_bind_bucket_for_each(tb, &head->chain) { |
| 217 | if (check_bind_bucket_match(tb, net, port, l3mdev)) | 156 | if (net_eq(ib_net(tb), sock_net(sk)) && |
| 157 | tb->l3mdev == l3mdev && tb->port == port) | ||
| 218 | break; | 158 | break; |
| 219 | } | 159 | } |
| 220 | if (!tb) { | 160 | if (!tb) { |
| 221 | tb = inet_bind_bucket_create(table->bind_bucket_cachep, | 161 | tb = inet_bind_bucket_create(table->bind_bucket_cachep, |
| 222 | net, head, port, l3mdev); | 162 | sock_net(sk), head, port, |
| 163 | l3mdev); | ||
| 223 | if (!tb) { | 164 | if (!tb) { |
| 224 | spin_unlock(&head->lock); | 165 | spin_unlock(&head->lock); |
| 225 | return -ENOMEM; | 166 | return -ENOMEM; |
| 226 | } | 167 | } |
| 227 | created_inet_bind_bucket = true; | ||
| 228 | } | 168 | } |
| 229 | inet_csk_update_fastreuse(tb, child); | 169 | inet_csk_update_fastreuse(tb, child); |
| 230 | |||
| 231 | goto bhash2_find; | ||
| 232 | } else if (!bind2_bucket_addr_match(tb2, child)) { | ||
| 233 | l3mdev = inet_sk_bound_l3mdev(sk); | ||
| 234 | |||
| 235 | bhash2_find: | ||
| 236 | tb2 = inet_bind2_bucket_find(table, net, port, l3mdev, child, | ||
| 237 | &head_bhash2); | ||
| 238 | if (!tb2) { | ||
| 239 | tb2 = inet_bind2_bucket_create(table->bind2_bucket_cachep, | ||
| 240 | net, head_bhash2, port, | ||
| 241 | l3mdev, child); | ||
| 242 | if (!tb2) | ||
| 243 | goto error; | ||
| 244 | } | ||
| 245 | } | 170 | } |
| 246 | inet_bind_hash(child, tb, tb2, port); | 171 | inet_bind_hash(child, tb, port); |
| 247 | spin_unlock(&head->lock); | 172 | spin_unlock(&head->lock); |
| 248 | 173 | ||
| 249 | return 0; | 174 | return 0; |
| 250 | |||
| 251 | error: | ||
| 252 | if (created_inet_bind_bucket) | ||
| 253 | inet_bind_bucket_destroy(table->bind_bucket_cachep, tb); | ||
| 254 | spin_unlock(&head->lock); | ||
| 255 | return -ENOMEM; | ||
| 256 | } | 175 | } |
| 257 | EXPORT_SYMBOL_GPL(__inet_inherit_port); | 176 | EXPORT_SYMBOL_GPL(__inet_inherit_port); |
| 258 | 177 | ||
| @@ -756,76 +675,6 @@ void inet_unhash(struct sock *sk) · 497 unmodified lines | |||
| 756 | } | 675 | } |
| 757 | EXPORT_SYMBOL_GPL(inet_unhash); | 676 | EXPORT_SYMBOL_GPL(inet_unhash); |
| 758 | 677 | ||
| 759 | static bool check_bind2_bucket_match(struct inet_bind2_bucket *tb, | ||
| 760 | struct net *net, unsigned short port, | ||
| 761 | int l3mdev, struct sock *sk) | ||
| 762 | { | ||
| 763 | #if IS_ENABLED(CONFIG_IPV6) | ||
| 764 | if (sk->sk_family == AF_INET6) | ||
| 765 | return net_eq(ib2_net(tb), net) && tb->port == port && | ||
| 766 | tb->l3mdev == l3mdev && | ||
| 767 | ipv6_addr_equal(&tb->v6_rcv_saddr, &sk->sk_v6_rcv_saddr); | ||
| 768 | else | ||
| 769 | #endif | ||
| 770 | return net_eq(ib2_net(tb), net) && tb->port == port && | ||
| 771 | tb->l3mdev == l3mdev && tb->rcv_saddr == sk->sk_rcv_saddr; | ||
| 772 | } | ||
| 773 | |||
| 774 | bool check_bind2_bucket_match_nulladdr(struct inet_bind2_bucket *tb, | ||
| 775 | struct net *net, const unsigned short port, | ||
| 776 | int l3mdev, const struct sock *sk) | ||
| 777 | { | ||
| 778 | #if IS_ENABLED(CONFIG_IPV6) | ||
| 779 | struct in6_addr nulladdr = {}; | ||
| 780 | |||
| 781 | if (sk->sk_family == AF_INET6) | ||
| 782 | return net_eq(ib2_net(tb), net) && tb->port == port && | ||
| 783 | tb->l3mdev == l3mdev && | ||
| 784 | ipv6_addr_equal(&tb->v6_rcv_saddr, &nulladdr); | ||
| 785 | else | ||
| 786 | #endif | ||
| 787 | return net_eq(ib2_net(tb), net) && tb->port == port && | ||
| 788 | tb->l3mdev == l3mdev && tb->rcv_saddr == 0; | ||
| 789 | } | ||
| 790 | |||
| 791 | static struct inet_bind2_hashbucket * | ||
| 792 | inet_bhashfn_portaddr(struct inet_hashinfo *hinfo, const struct sock *sk, | ||
| 793 | const struct net *net, unsigned short port) | ||
| 794 | { | ||
| 795 | u32 hash; | ||
| 796 | |||
| 797 | #if IS_ENABLED(CONFIG_IPV6) | ||
| 798 | if (sk->sk_family == AF_INET6) | ||
| 799 | hash = ipv6_portaddr_hash(net, &sk->sk_v6_rcv_saddr, port); | ||
| 800 | else | ||
| 801 | #endif | ||
| 802 | hash = ipv4_portaddr_hash(net, sk->sk_rcv_saddr, port); | ||
| 803 | return &hinfo->bhash2[hash & (hinfo->bhash_size - 1)]; | ||
| 804 | } | ||
| 805 | |||
| 806 | /* This should only be called when the spinlock for the socket's corresponding | ||
| 807 | * bind_hashbucket is held | ||
| 808 | */ | ||
| 809 | struct inet_bind2_bucket * | ||
| 810 | inet_bind2_bucket_find(struct inet_hashinfo *hinfo, struct net *net, | ||
| 811 | const unsigned short port, int l3mdev, struct sock *sk, | ||
| 812 | struct inet_bind2_hashbucket **head) | ||
| 813 | { | ||
| 814 | struct inet_bind2_bucket *bhash2 = NULL; | ||
| 815 | struct inet_bind2_hashbucket *h; | ||
| 816 | |||
| 817 | h = inet_bhashfn_portaddr(hinfo, sk, net, port); | ||
| 818 | inet_bind_bucket_for_each(bhash2, &h->chain) { | ||
| 819 | if (check_bind2_bucket_match(bhash2, net, port, l3mdev, sk)) | ||
| 820 | break; | ||
| 821 | } | ||
| 822 | |||
| 823 | if (head) | ||
| 824 | *head = h; | ||
| 825 | |||
| 826 | return bhash2; | ||
| 827 | } | ||
| 828 | |||
| 829 | /* RFC 6056 3.3.4. Algorithm 4: Double-Hash Port Selection Algorithm | 678 | /* RFC 6056 3.3.4. Algorithm 4: Double-Hash Port Selection Algorithm |
| 830 | * Note that we use 32bit integers (vs RFC 'short integers') | 679 | * Note that we use 32bit integers (vs RFC 'short integers') |
| 831 | * because 2^16 is not a multiple of num_ephemeral and this | 680 | * because 2^16 is not a multiple of num_ephemeral and this |
| @@ -846,13 +695,10 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row, · 14 unmodified lines | |||
| 846 | { | 695 | { |
| 847 | struct inet_hashinfo *hinfo = death_row->hashinfo; | 696 | struct inet_hashinfo *hinfo = death_row->hashinfo; |
| 848 | struct inet_timewait_sock *tw = NULL; | 697 | struct inet_timewait_sock *tw = NULL; |
| 849 | struct inet_bind2_hashbucket *head2; | ||
| 850 | struct inet_bind_hashbucket *head; | 698 | struct inet_bind_hashbucket *head; |
| 851 | int port = inet_sk(sk)->inet_num; | 699 | int port = inet_sk(sk)->inet_num; |
| 852 | struct net *net = sock_net(sk); | 700 | struct net *net = sock_net(sk); |
| 853 | struct inet_bind2_bucket *tb2; | ||
| 854 | struct inet_bind_bucket *tb; | 701 | struct inet_bind_bucket *tb; |
| 855 | bool tb_created = false; | ||
| 856 | u32 remaining, offset; | 702 | u32 remaining, offset; |
| 857 | int ret, i, low, high; | 703 | int ret, i, low, high; |
| 858 | int l3mdev; | 704 | int l3mdev; |
| @@ -909,7 +755,8 @@ other_parity_scan: · 50 unmodified lines | |||
| 909 | * the established check is already unique enough. | 755 | * the established check is already unique enough. |
| 910 | */ | 756 | */ |
| 911 | inet_bind_bucket_for_each(tb, &head->chain) { | 757 | inet_bind_bucket_for_each(tb, &head->chain) { |
| 912 | if (check_bind_bucket_match(tb, net, port, l3mdev)) { | 758 | if (net_eq(ib_net(tb), net) && tb->l3mdev == l3mdev && |
| 759 | tb->port == port) { | ||
| 913 | if (tb->fastreuse >= 0 || | 760 | if (tb->fastreuse >= 0 || |
| 914 | tb->fastreuseport >= 0) | 761 | tb->fastreuseport >= 0) |
| 915 | goto next_port; | 762 | goto next_port; |
| @@ -927,7 +774,6 @@ other_parity_scan: · 11 unmodified lines | |||
| 927 | spin_unlock_bh(&head->lock); | 774 | spin_unlock_bh(&head->lock); |
| 928 | return -ENOMEM; | 775 | return -ENOMEM; |
| 929 | } | 776 | } |
| 930 | tb_created = true; | ||
| 931 | tb->fastreuse = -1; | 777 | tb->fastreuse = -1; |
| 932 | tb->fastreuseport = -1; | 778 | tb->fastreuseport = -1; |
| 933 | goto ok; | 779 | goto ok; |
| @@ -943,17 +789,6 @@ next_port: · 9 unmodified lines | |||
| 943 | return -EADDRNOTAVAIL; | 789 | return -EADDRNOTAVAIL; |
| 944 | 790 | ||
| 945 | ok: | 791 | ok: |
| 946 | /* Find the corresponding tb2 bucket since we need to | ||
| 947 | * add the socket to the bhash2 table as well | ||
| 948 | */ | ||
| 949 | tb2 = inet_bind2_bucket_find(hinfo, net, port, l3mdev, sk, &head2); | ||
| 950 | if (!tb2) { | ||
| 951 | tb2 = inet_bind2_bucket_create(hinfo->bind2_bucket_cachep, net, | ||
| 952 | head2, port, l3mdev, sk); | ||
| 953 | if (!tb2) | ||
| 954 | goto error; | ||
| 955 | } | ||
| 956 | |||
| 957 | /* Here we want to add a little bit of randomness to the next source | 792 | /* Here we want to add a little bit of randomness to the next source |
| 958 | * port that will be chosen. We use a max() with a random here so that | 793 | * port that will be chosen. We use a max() with a random here so that |
| 959 | * on low contention the randomness is maximal and on high contention | 794 | * on low contention the randomness is maximal and on high contention |
| @@ -963,7 +798,7 @@ ok: · 3 unmodified lines | |||
| 963 | WRITE_ONCE(table_perturb[index], READ_ONCE(table_perturb[index]) + i + 2); | 798 | WRITE_ONCE(table_perturb[index], READ_ONCE(table_perturb[index]) + i + 2); |
| 964 | 799 | ||
| 965 | /* Head lock still held and bh's disabled */ | 800 | /* Head lock still held and bh's disabled */ |
| 966 | inet_bind_hash(sk, tb, tb2, port); | 801 | inet_bind_hash(sk, tb, port); |
| 967 | if (sk_unhashed(sk)) { | 802 | if (sk_unhashed(sk)) { |
| 968 | inet_sk(sk)->inet_sport = htons(port); | 803 | inet_sk(sk)->inet_sport = htons(port); |
| 969 | inet_ehash_nolisten(sk, (struct sock *)tw, NULL); | 804 | inet_ehash_nolisten(sk, (struct sock *)tw, NULL); |
| @@ -975,12 +810,6 @@ ok: · 5 unmodified lines | |||
| 975 | inet_twsk_deschedule_put(tw); | 810 | inet_twsk_deschedule_put(tw); |
| 976 | local_bh_enable(); | 811 | local_bh_enable(); |
| 977 | return 0; | 812 | return 0; |
| 978 | |||
| 979 | error: | ||
| 980 | if (tb_created) | ||
| 981 | inet_bind_bucket_destroy(hinfo->bind_bucket_cachep, tb); | ||
| 982 | spin_unlock_bh(&head->lock); | ||
| 983 | return -ENOMEM; | ||
| 984 | } | 813 | } |
| 985 | 814 | ||
| 986 | /* | 815 | /* |
| @@ -4604,12 +4604,6 @@ void __init tcp_init(void) · 4603 unmodified lines | |||
| 4604 | SLAB_HWCACHE_ALIGN | SLAB_PANIC | | 4604 | SLAB_HWCACHE_ALIGN | SLAB_PANIC | |
| 4605 | SLAB_ACCOUNT, | 4605 | SLAB_ACCOUNT, |
| 4606 | NULL); | 4606 | NULL); |
| 4607 | tcp_hashinfo.bind2_bucket_cachep = | ||
| 4608 | kmem_cache_create("tcp_bind2_bucket", | ||
| 4609 | sizeof(struct inet_bind2_bucket), 0, | ||
| 4610 | SLAB_HWCACHE_ALIGN | SLAB_PANIC | | ||
| 4611 | SLAB_ACCOUNT, | ||
| 4612 | NULL); | ||
| 4613 | 4607 | ||
| 4614 | /* Size and allocate the main established and bind bucket | 4608 | /* Size and allocate the main established and bind bucket |
| 4615 | * hash tables. | 4609 | * hash tables. |
| @@ -4632,9 +4626,8 @@ void __init tcp_init(void) · 16 unmodified lines | |||
| 4632 | if (inet_ehash_locks_alloc(&tcp_hashinfo)) | 4626 | if (inet_ehash_locks_alloc(&tcp_hashinfo)) |
| 4633 | panic("TCP: failed to alloc ehash_locks"); | 4627 | panic("TCP: failed to alloc ehash_locks"); |
| 4634 | tcp_hashinfo.bhash = | 4628 | tcp_hashinfo.bhash = |
| 4635 | alloc_large_system_hash("TCP bind bhash tables", | 4629 | alloc_large_system_hash("TCP bind", |
| 4636 | sizeof(struct inet_bind_hashbucket) + | 4630 | sizeof(struct inet_bind_hashbucket), |
| 4637 | sizeof(struct inet_bind2_hashbucket), | ||
| 4638 | tcp_hashinfo.ehash_mask + 1, | 4631 | tcp_hashinfo.ehash_mask + 1, |
| 4639 | 17, /* one slot per 128 KB of memory */ | 4632 | 17, /* one slot per 128 KB of memory */ |
| 4640 | 0, | 4633 | 0, |
| @@ -4643,12 +4636,9 @@ void __init tcp_init(void) · 2 unmodified lines | |||
| 4643 | 0, | 4636 | 0, |
| 4644 | 64 * 1024); | 4637 | 64 * 1024); |
| 4645 | tcp_hashinfo.bhash_size = 1U << tcp_hashinfo.bhash_size; | 4638 | tcp_hashinfo.bhash_size = 1U << tcp_hashinfo.bhash_size; |
| 4646 | tcp_hashinfo.bhash2 = | ||
| 4647 | (struct inet_bind2_hashbucket *)(tcp_hashinfo.bhash + tcp_hashinfo.bhash_size); | ||
| 4648 | for (i = 0; i < tcp_hashinfo.bhash_size; i++) { | 4639 | for (i = 0; i < tcp_hashinfo.bhash_size; i++) { |
| 4649 | spin_lock_init(&tcp_hashinfo.bhash[i].lock); | 4640 | spin_lock_init(&tcp_hashinfo.bhash[i].lock); |
| 4650 | INIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain); | 4641 | INIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain); |
| 4651 | INIT_HLIST_HEAD(&tcp_hashinfo.bhash2[i].chain); | ||
| 4652 | } | 4642 | } |
| 4653 | 4643 | ||
| 4654 | 4644 | ||
| @@ -37,4 +37,3 @@ gro · 36 unmodified lines | |||
| 37 | ioam6_parser | 37 | ioam6_parser |
| 38 | toeplitz | 38 | toeplitz |
| 39 | cmsg_sender | 39 | cmsg_sender |
| 40 | bind_bhash_test | ||
| @@ -59,7 +59,6 @@ TEST_GEN_FILES += toeplitz · 58 unmodified lines | |||
| 59 | TEST_GEN_FILES += cmsg_sender | 59 | TEST_GEN_FILES += cmsg_sender |
| 60 | TEST_GEN_FILES += stress_reuseport_listen | 60 | TEST_GEN_FILES += stress_reuseport_listen |
| 61 | TEST_PROGS += test_vxlan_vnifiltering.sh | 61 | TEST_PROGS += test_vxlan_vnifiltering.sh |
| 62 | TEST_GEN_FILES += bind_bhash_test | ||
| 63 | 62 | ||
| 64 | TEST_FILES := settings | 63 | TEST_FILES := settings |
| 65 | 64 | ||
| @@ -70,5 +69,4 @@ include bpf/Makefile · 4 unmodified lines | |||
| 70 | 69 | ||
| 71 | $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma | 70 | $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma |
| 72 | $(OUTPUT)/tcp_mmap: LDLIBS += -lpthread | 71 | $(OUTPUT)/tcp_mmap: LDLIBS += -lpthread |
| 73 | $(OUTPUT)/bind_bhash_test: LDLIBS += -lpthread | ||
| 74 | $(OUTPUT)/tcp_inq: LDLIBS += -lpthread | 72 | $(OUTPUT)/tcp_inq: LDLIBS += -lpthread |
| @@ -1,119 +0,0 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | /* | ||
| 3 | * This times how long it takes to bind to a port when the port already | ||
| 4 | * has multiple sockets in its bhash table. | ||
| 5 | * | ||
| 6 | * In the setup(), we populate the port's bhash table with | ||
| 7 | * MAX_THREADS * MAX_CONNECTIONS number of entries. | ||
| 8 | */ | ||
| 9 | |||
| 10 | #include <unistd.h> | ||
| 11 | #include <stdio.h> | ||
| 12 | #include <netdb.h> | ||
| 13 | #include <pthread.h> | ||
| 14 | |||
| 15 | #define MAX_THREADS 600 | ||
| 16 | #define MAX_CONNECTIONS 40 | ||
| 17 | |||
| 18 | static const char *bind_addr = "::1"; | ||
| 19 | static const char *port; | ||
| 20 | |||
| 21 | static int fd_array[MAX_THREADS][MAX_CONNECTIONS]; | ||
| 22 | |||
| 23 | static int bind_socket(int opt, const char *addr) | ||
| 24 | { | ||
| 25 | struct addrinfo *res, hint = {}; | ||
| 26 | int sock_fd, reuse = 1, err; | ||
| 27 | |||
| 28 | sock_fd = socket(AF_INET6, SOCK_STREAM, 0); | ||
| 29 | if (sock_fd < 0) { | ||
| 30 | perror("socket fd err"); | ||
| 31 | return -1; | ||
| 32 | } | ||
| 33 | |||
| 34 | hint.ai_family = AF_INET6; | ||
| 35 | hint.ai_socktype = SOCK_STREAM; | ||
| 36 | |||
| 37 | err = getaddrinfo(addr, port, &hint, &res); | ||
| 38 | if (err) { | ||
| 39 | perror("getaddrinfo failed"); | ||
| 40 | return -1; | ||
| 41 | } | ||
| 42 | |||
| 43 | if (opt) { | ||
| 44 | err = setsockopt(sock_fd, SOL_SOCKET, opt, &reuse, sizeof(reuse)); | ||
| 45 | if (err) { | ||
| 46 | perror("setsockopt failed"); | ||
| 47 | return -1; | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 51 | err = bind(sock_fd, res->ai_addr, res->ai_addrlen); | ||
| 52 | if (err) { | ||
| 53 | perror("failed to bind to port"); | ||
| 54 | return -1; | ||
| 55 | } | ||
| 56 | |||
| 57 | return sock_fd; | ||
| 58 | } | ||
| 59 | |||
| 60 | static void *setup(void *arg) | ||
| 61 | { | ||
| 62 | int sock_fd, i; | ||
| 63 | int *array = (int *)arg; | ||
| 64 | |||
| 65 | for (i = 0; i < MAX_CONNECTIONS; i++) { | ||
| 66 | sock_fd = bind_socket(SO_REUSEADDR | SO_REUSEPORT, bind_addr); | ||
| 67 | if (sock_fd < 0) | ||
| 68 | return NULL; | ||
| 69 | array[i] = sock_fd; | ||
| 70 | } | ||
| 71 | |||
| 72 | return NULL; | ||
| 73 | } | ||
| 74 | |||
| 75 | int main(int argc, const char *argv[]) | ||
| 76 | { | ||
| 77 | int listener_fd, sock_fd, i, j; | ||
| 78 | pthread_t tid[MAX_THREADS]; | ||
| 79 | clock_t begin, end; | ||
| 80 | |||
| 81 | if (argc != 2) { | ||
| 82 | printf("Usage: listener <port>\n"); | ||
| 83 | return -1; | ||
| 84 | } | ||
| 85 | |||
| 86 | port = argv[1]; | ||
| 87 | |||
| 88 | listener_fd = bind_socket(SO_REUSEADDR | SO_REUSEPORT, bind_addr); | ||
| 89 | if (listen(listener_fd, 100) < 0) { | ||
| 90 | perror("listen failed"); | ||
| 91 | return -1; | ||
| 92 | } | ||
| 93 | |||
| 94 | /* Set up threads to populate the bhash table entry for the port */ | ||
| 95 | for (i = 0; i < MAX_THREADS; i++) | ||
| 96 | pthread_create(&tid[i], NULL, setup, fd_array[i]); | ||
| 97 | |||
| 98 | for (i = 0; i < MAX_THREADS; i++) | ||
| 99 | pthread_join(tid[i], NULL); | ||
| 100 | |||
| 101 | begin = clock(); | ||
| 102 | |||
| 103 | /* Bind to the same port on a different address */ | ||
| 104 | sock_fd = bind_socket(0, "2001:0db8:0:f101::1"); | ||
| 105 | |||
| 106 | end = clock(); | ||
| 107 | |||
| 108 | printf("time spent = %f\n", (double)(end - begin) / CLOCKS_PER_SEC); | ||
| 109 | |||
| 110 | /* clean up */ | ||
| 111 | close(sock_fd); | ||
| 112 | close(listener_fd); | ||
| 113 | for (i = 0; i < MAX_THREADS; i++) { | ||
| 114 | for (j = 0; i < MAX_THREADS; i++) | ||
| 115 | close(fd_array[i][j]); | ||
| 116 | } | ||
| 117 | |||
| 118 | return 0; | ||
| 119 | } | ||