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

Configure Feed

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

Merge tag 'net-6.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Pull networking fixes from Paolo Abeni:
"Including fixes from CAN, WiFi and netfilter.

We have still a comple of regressions open due to the recent
drivers locking refactor. The patches are in-flight, but not
ready yet.

Current release - regressions:

- core: lock netdevices during dev_shutdown

- sch_htb: make htb_deactivate() idempotent

- eth: virtio-net: don't re-enable refill work too early

Current release - new code bugs:

- eth: icssg-prueth: fix kernel panic during concurrent Tx queue
access

Previous releases - regressions:

- gre: fix again IPv6 link-local address generation.

- eth: b53: fix learning on VLAN unaware bridges

Previous releases - always broken:

- wifi: fix out-of-bounds access during multi-link element
defragmentation

- can:
- initialize spin lock on device probe
- fix order of unregistration calls

- openvswitch: fix unsafe attribute parsing in output_userspace()

- eth:
- virtio-net: fix total qstat values
- mtk_eth_soc: reset all TX queues on DMA free
- fbnic: firmware IPC mailbox fixes"

* tag 'net-6.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (55 commits)
virtio-net: fix total qstat values
net: export a helper for adding up queue stats
fbnic: Do not allow mailbox to toggle to ready outside fbnic_mbx_poll_tx_ready
fbnic: Pull fbnic_fw_xmit_cap_msg use out of interrupt context
fbnic: Improve responsiveness of fbnic_mbx_poll_tx_ready
fbnic: Cleanup handling of completions
fbnic: Actually flush_tx instead of stalling out
fbnic: Add additional handling of IRQs
fbnic: Gate AXI read/write enabling on FW mailbox
fbnic: Fix initialization of mailbox descriptor rings
net: dsa: b53: do not set learning and unicast/multicast on up
net: dsa: b53: fix learning on VLAN unaware bridges
net: dsa: b53: fix toggling vlan_filtering
net: dsa: b53: do not program vlans when vlan filtering is off
net: dsa: b53: do not allow to configure VLAN 0
net: dsa: b53: always rejoin default untagged VLAN on bridge leave
net: dsa: b53: fix VLAN ID for untagged vlan on bridge leave
net: dsa: b53: fix flushing old pvid VLAN on pvid change
net: dsa: b53: fix clearing PVID of a port
net: dsa: b53: keep CPU port always tagged again
...

+1056 -436
+90 -7
Documentation/devicetree/bindings/net/ethernet-controller.yaml
··· 74 74 - rev-rmii 75 75 - moca 76 76 77 - # RX and TX delays are added by the MAC when required 77 + # RX and TX delays are provided by the PCB. See below 78 78 - rgmii 79 79 80 - # RGMII with internal RX and TX delays provided by the PHY, 81 - # the MAC should not add the RX or TX delays in this case 80 + # RX and TX delays are not provided by the PCB. This is the most 81 + # frequent case. See below 82 82 - rgmii-id 83 83 84 - # RGMII with internal RX delay provided by the PHY, the MAC 85 - # should not add an RX delay in this case 84 + # TX delay is provided by the PCB. See below 86 85 - rgmii-rxid 87 86 88 - # RGMII with internal TX delay provided by the PHY, the MAC 89 - # should not add an TX delay in this case 87 + # RX delay is provided by the PCB. See below 90 88 - rgmii-txid 91 89 - rtbi 92 90 - smii ··· 284 286 285 287 additionalProperties: true 286 288 289 + # Informative 290 + # =========== 291 + # 292 + # 'phy-modes' & 'phy-connection-type' properties 'rgmii', 'rgmii-id', 293 + # 'rgmii-rxid', and 'rgmii-txid' are frequently used wrongly by 294 + # developers. This informative section clarifies their usage. 295 + # 296 + # The RGMII specification requires a 2ns delay between the data and 297 + # clock signals on the RGMII bus. How this delay is implemented is not 298 + # specified. 299 + # 300 + # One option is to make the clock traces on the PCB longer than the 301 + # data traces. A sufficiently difference in length can provide the 2ns 302 + # delay. If both the RX and TX delays are implemented in this manner, 303 + # 'rgmii' should be used, so indicating the PCB adds the delays. 304 + # 305 + # If the PCB does not add these delays via extra long traces, 306 + # 'rgmii-id' should be used. Here, 'id' refers to 'internal delay', 307 + # where either the MAC or PHY adds the delay. 308 + # 309 + # If only one of the two delays are implemented via extra long clock 310 + # lines, either 'rgmii-rxid' or 'rgmii-txid' should be used, 311 + # indicating the MAC or PHY should implement one of the delays 312 + # internally, while the PCB implements the other delay. 313 + # 314 + # Device Tree describes hardware, and in this case, it describes the 315 + # PCB between the MAC and the PHY, if the PCB implements delays or 316 + # not. 317 + # 318 + # In practice, very few PCBs make use of extra long clock lines. Hence 319 + # any RGMII phy mode other than 'rgmii-id' is probably wrong, and is 320 + # unlikely to be accepted during review without details provided in 321 + # the commit description and comments in the .dts file. 322 + # 323 + # When the PCB does not implement the delays, the MAC or PHY must. As 324 + # such, this is software configuration, and so not described in Device 325 + # Tree. 326 + # 327 + # The following describes how Linux implements the configuration of 328 + # the MAC and PHY to add these delays when the PCB does not. As stated 329 + # above, developers often get this wrong, and the aim of this section 330 + # is reduce the frequency of these errors by Linux developers. Other 331 + # users of the Device Tree may implement it differently, and still be 332 + # consistent with both the normative and informative description 333 + # above. 334 + # 335 + # By default in Linux, when using phylib/phylink, the MAC is expected 336 + # to read the 'phy-mode' from Device Tree, not implement any delays, 337 + # and pass the value to the PHY. The PHY will then implement delays as 338 + # specified by the 'phy-mode'. The PHY should always be reconfigured 339 + # to implement the needed delays, replacing any setting performed by 340 + # strapping or the bootloader, etc. 341 + # 342 + # Experience to date is that all PHYs which implement RGMII also 343 + # implement the ability to add or not add the needed delays. Hence 344 + # this default is expected to work in all cases. Ignoring this default 345 + # is likely to be questioned by Reviews, and require a strong argument 346 + # to be accepted. 347 + # 348 + # There are a small number of cases where the MAC has hard coded 349 + # delays which cannot be disabled. The 'phy-mode' only describes the 350 + # PCB. The inability to disable the delays in the MAC does not change 351 + # the meaning of 'phy-mode'. It does however mean that a 'phy-mode' of 352 + # 'rgmii' is now invalid, it cannot be supported, since both the PCB 353 + # and the MAC and PHY adding delays cannot result in a functional 354 + # link. Thus the MAC should report a fatal error for any modes which 355 + # cannot be supported. When the MAC implements the delay, it must 356 + # ensure that the PHY does not also implement the same delay. So it 357 + # must modify the phy-mode it passes to the PHY, removing the delay it 358 + # has added. Failure to remove the delay will result in a 359 + # non-functioning link. 360 + # 361 + # Sometimes there is a need to fine tune the delays. Often the MAC or 362 + # PHY can perform this fine tuning. In the MAC node, the Device Tree 363 + # properties 'rx-internal-delay-ps' and 'tx-internal-delay-ps' should 364 + # be used to indicate fine tuning performed by the MAC. The values 365 + # expected here are small. A value of 2000ps, i.e 2ns, and a phy-mode 366 + # of 'rgmii' will not be accepted by Reviewers. 367 + # 368 + # If the PHY is to perform fine tuning, the properties 369 + # 'rx-internal-delay-ps' and 'tx-internal-delay-ps' in the PHY node 370 + # should be used. When the PHY is implementing delays, e.g. 'rgmii-id' 371 + # these properties should have a value near to 2000ps. If the PCB is 372 + # implementing delays, e.g. 'rgmii', a small value can be used to fine 373 + # tune the delay added by the PCB. 287 374 ...
+2 -1
drivers/net/can/m_can/m_can.c
··· 2379 2379 SET_NETDEV_DEV(net_dev, dev); 2380 2380 2381 2381 m_can_of_parse_mram(class_dev, mram_config_vals); 2382 + spin_lock_init(&class_dev->tx_handling_spinlock); 2382 2383 out: 2383 2384 return class_dev; 2384 2385 } ··· 2463 2462 2464 2463 void m_can_class_unregister(struct m_can_classdev *cdev) 2465 2464 { 2465 + unregister_candev(cdev->net); 2466 2466 if (cdev->is_peripheral) 2467 2467 can_rx_offload_del(&cdev->offload); 2468 - unregister_candev(cdev->net); 2469 2468 } 2470 2469 EXPORT_SYMBOL_GPL(m_can_class_unregister); 2471 2470
+1 -1
drivers/net/can/rockchip/rockchip_canfd-core.c
··· 937 937 struct rkcanfd_priv *priv = platform_get_drvdata(pdev); 938 938 struct net_device *ndev = priv->ndev; 939 939 940 - can_rx_offload_del(&priv->offload); 941 940 rkcanfd_unregister(priv); 941 + can_rx_offload_del(&priv->offload); 942 942 free_candev(ndev); 943 943 } 944 944
+33 -9
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
··· 75 75 .brp_inc = 1, 76 76 }; 77 77 78 + /* The datasheet of the mcp2518fd (DS20006027B) specifies a range of 79 + * [-64,63] for TDCO, indicating a relative TDCO. 80 + * 81 + * Manual tests have shown, that using a relative TDCO configuration 82 + * results in bus off, while an absolute configuration works. 83 + * 84 + * For TDCO use the max value (63) from the data sheet, but 0 as the 85 + * minimum. 86 + */ 87 + static const struct can_tdc_const mcp251xfd_tdc_const = { 88 + .tdcv_min = 0, 89 + .tdcv_max = 63, 90 + .tdco_min = 0, 91 + .tdco_max = 63, 92 + .tdcf_min = 0, 93 + .tdcf_max = 0, 94 + }; 95 + 78 96 static const char *__mcp251xfd_get_model_str(enum mcp251xfd_model model) 79 97 { 80 98 switch (model) { ··· 528 510 { 529 511 const struct can_bittiming *bt = &priv->can.bittiming; 530 512 const struct can_bittiming *dbt = &priv->can.data_bittiming; 531 - u32 val = 0; 532 - s8 tdco; 513 + u32 tdcmod, val = 0; 533 514 int err; 534 515 535 516 /* CAN Control Register ··· 592 575 return err; 593 576 594 577 /* Transmitter Delay Compensation */ 595 - tdco = clamp_t(int, dbt->brp * (dbt->prop_seg + dbt->phase_seg1), 596 - -64, 63); 597 - val = FIELD_PREP(MCP251XFD_REG_TDC_TDCMOD_MASK, 598 - MCP251XFD_REG_TDC_TDCMOD_AUTO) | 599 - FIELD_PREP(MCP251XFD_REG_TDC_TDCO_MASK, tdco); 578 + if (priv->can.ctrlmode & CAN_CTRLMODE_TDC_AUTO) 579 + tdcmod = MCP251XFD_REG_TDC_TDCMOD_AUTO; 580 + else if (priv->can.ctrlmode & CAN_CTRLMODE_TDC_MANUAL) 581 + tdcmod = MCP251XFD_REG_TDC_TDCMOD_MANUAL; 582 + else 583 + tdcmod = MCP251XFD_REG_TDC_TDCMOD_DISABLED; 584 + 585 + val = FIELD_PREP(MCP251XFD_REG_TDC_TDCMOD_MASK, tdcmod) | 586 + FIELD_PREP(MCP251XFD_REG_TDC_TDCV_MASK, priv->can.tdc.tdcv) | 587 + FIELD_PREP(MCP251XFD_REG_TDC_TDCO_MASK, priv->can.tdc.tdco); 600 588 601 589 return regmap_write(priv->map_reg, MCP251XFD_REG_TDC, val); 602 590 } ··· 2105 2083 priv->can.do_get_berr_counter = mcp251xfd_get_berr_counter; 2106 2084 priv->can.bittiming_const = &mcp251xfd_bittiming_const; 2107 2085 priv->can.data_bittiming_const = &mcp251xfd_data_bittiming_const; 2086 + priv->can.tdc_const = &mcp251xfd_tdc_const; 2108 2087 priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | 2109 2088 CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_BERR_REPORTING | 2110 2089 CAN_CTRLMODE_FD | CAN_CTRLMODE_FD_NON_ISO | 2111 - CAN_CTRLMODE_CC_LEN8_DLC; 2090 + CAN_CTRLMODE_CC_LEN8_DLC | CAN_CTRLMODE_TDC_AUTO | 2091 + CAN_CTRLMODE_TDC_MANUAL; 2112 2092 set_bit(MCP251XFD_FLAGS_DOWN, priv->flags); 2113 2093 priv->ndev = ndev; 2114 2094 priv->spi = spi; ··· 2198 2174 struct mcp251xfd_priv *priv = spi_get_drvdata(spi); 2199 2175 struct net_device *ndev = priv->ndev; 2200 2176 2201 - can_rx_offload_del(&priv->offload); 2202 2177 mcp251xfd_unregister(priv); 2178 + can_rx_offload_del(&priv->offload); 2203 2179 spi->max_speed_hz = priv->spi_max_speed_hz_orig; 2204 2180 free_candev(ndev); 2205 2181 }
+153 -60
drivers/net/dsa/b53/b53_common.c
··· 373 373 b53_read8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL5, &vc5); 374 374 } 375 375 376 + vc1 &= ~VC1_RX_MCST_FWD_EN; 377 + 376 378 if (enable) { 377 379 vc0 |= VC0_VLAN_EN | VC0_VID_CHK_EN | VC0_VID_HASH_VID; 378 - vc1 |= VC1_RX_MCST_UNTAG_EN | VC1_RX_MCST_FWD_EN; 380 + vc1 |= VC1_RX_MCST_UNTAG_EN; 379 381 vc4 &= ~VC4_ING_VID_CHECK_MASK; 380 382 if (enable_filtering) { 381 383 vc4 |= VC4_ING_VID_VIO_DROP << VC4_ING_VID_CHECK_S; 382 384 vc5 |= VC5_DROP_VTABLE_MISS; 383 385 } else { 384 - vc4 |= VC4_ING_VID_VIO_FWD << VC4_ING_VID_CHECK_S; 386 + vc4 |= VC4_NO_ING_VID_CHK << VC4_ING_VID_CHECK_S; 385 387 vc5 &= ~VC5_DROP_VTABLE_MISS; 386 388 } 387 389 ··· 395 393 396 394 } else { 397 395 vc0 &= ~(VC0_VLAN_EN | VC0_VID_CHK_EN | VC0_VID_HASH_VID); 398 - vc1 &= ~(VC1_RX_MCST_UNTAG_EN | VC1_RX_MCST_FWD_EN); 396 + vc1 &= ~VC1_RX_MCST_UNTAG_EN; 399 397 vc4 &= ~VC4_ING_VID_CHECK_MASK; 400 398 vc5 &= ~VC5_DROP_VTABLE_MISS; 401 399 ··· 578 576 b53_write16(dev, B53_EEE_PAGE, B53_EEE_EN_CTRL, reg); 579 577 } 580 578 579 + int b53_setup_port(struct dsa_switch *ds, int port) 580 + { 581 + struct b53_device *dev = ds->priv; 582 + 583 + b53_port_set_ucast_flood(dev, port, true); 584 + b53_port_set_mcast_flood(dev, port, true); 585 + b53_port_set_learning(dev, port, false); 586 + 587 + return 0; 588 + } 589 + EXPORT_SYMBOL(b53_setup_port); 590 + 581 591 int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy) 582 592 { 583 593 struct b53_device *dev = ds->priv; ··· 601 587 return 0; 602 588 603 589 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; 604 - 605 - b53_port_set_ucast_flood(dev, port, true); 606 - b53_port_set_mcast_flood(dev, port, true); 607 - b53_port_set_learning(dev, port, false); 608 590 609 591 if (dev->ops->irq_enable) 610 592 ret = dev->ops->irq_enable(dev, port); ··· 732 722 b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), port_ctrl); 733 723 734 724 b53_brcm_hdr_setup(dev->ds, port); 735 - 736 - b53_port_set_ucast_flood(dev, port, true); 737 - b53_port_set_mcast_flood(dev, port, true); 738 - b53_port_set_learning(dev, port, false); 739 725 } 740 726 741 727 static void b53_enable_mib(struct b53_device *dev) ··· 767 761 return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port); 768 762 } 769 763 764 + static bool b53_vlan_port_may_join_untagged(struct dsa_switch *ds, int port) 765 + { 766 + struct b53_device *dev = ds->priv; 767 + struct dsa_port *dp; 768 + 769 + if (!dev->vlan_filtering) 770 + return true; 771 + 772 + dp = dsa_to_port(ds, port); 773 + 774 + if (dsa_port_is_cpu(dp)) 775 + return true; 776 + 777 + return dp->bridge == NULL; 778 + } 779 + 770 780 int b53_configure_vlan(struct dsa_switch *ds) 771 781 { 772 782 struct b53_device *dev = ds->priv; ··· 801 779 b53_do_vlan_op(dev, VTA_CMD_CLEAR); 802 780 } 803 781 804 - b53_enable_vlan(dev, -1, dev->vlan_enabled, ds->vlan_filtering); 782 + b53_enable_vlan(dev, -1, dev->vlan_enabled, dev->vlan_filtering); 805 783 806 784 /* Create an untagged VLAN entry for the default PVID in case 807 785 * CONFIG_VLAN_8021Q is disabled and there are no calls to ··· 809 787 * entry. Do this only when the tagging protocol is not 810 788 * DSA_TAG_PROTO_NONE 811 789 */ 790 + v = &dev->vlans[def_vid]; 812 791 b53_for_each_port(dev, i) { 813 - v = &dev->vlans[def_vid]; 814 - v->members |= BIT(i); 815 - if (!b53_vlan_port_needs_forced_tagged(ds, i)) 816 - v->untag = v->members; 817 - b53_write16(dev, B53_VLAN_PAGE, 818 - B53_VLAN_PORT_DEF_TAG(i), def_vid); 819 - } 820 - 821 - /* Upon initial call we have not set-up any VLANs, but upon 822 - * system resume, we need to restore all VLAN entries. 823 - */ 824 - for (vid = def_vid; vid < dev->num_vlans; vid++) { 825 - v = &dev->vlans[vid]; 826 - 827 - if (!v->members) 792 + if (!b53_vlan_port_may_join_untagged(ds, i)) 828 793 continue; 829 794 830 - b53_set_vlan_entry(dev, vid, v); 831 - b53_fast_age_vlan(dev, vid); 795 + vl.members |= BIT(i); 796 + if (!b53_vlan_port_needs_forced_tagged(ds, i)) 797 + vl.untag = vl.members; 798 + b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(i), 799 + def_vid); 800 + } 801 + b53_set_vlan_entry(dev, def_vid, &vl); 802 + 803 + if (dev->vlan_filtering) { 804 + /* Upon initial call we have not set-up any VLANs, but upon 805 + * system resume, we need to restore all VLAN entries. 806 + */ 807 + for (vid = def_vid + 1; vid < dev->num_vlans; vid++) { 808 + v = &dev->vlans[vid]; 809 + 810 + if (!v->members) 811 + continue; 812 + 813 + b53_set_vlan_entry(dev, vid, v); 814 + b53_fast_age_vlan(dev, vid); 815 + } 816 + 817 + b53_for_each_port(dev, i) { 818 + if (!dsa_is_cpu_port(ds, i)) 819 + b53_write16(dev, B53_VLAN_PAGE, 820 + B53_VLAN_PORT_DEF_TAG(i), 821 + dev->ports[i].pvid); 822 + } 832 823 } 833 824 834 825 return 0; ··· 1160 1125 static int b53_setup(struct dsa_switch *ds) 1161 1126 { 1162 1127 struct b53_device *dev = ds->priv; 1128 + struct b53_vlan *vl; 1163 1129 unsigned int port; 1130 + u16 pvid; 1164 1131 int ret; 1165 1132 1166 1133 /* Request bridge PVID untagged when DSA_TAG_PROTO_NONE is set ··· 1170 1133 */ 1171 1134 ds->untag_bridge_pvid = dev->tag_protocol == DSA_TAG_PROTO_NONE; 1172 1135 1136 + /* The switch does not tell us the original VLAN for untagged 1137 + * packets, so keep the CPU port always tagged. 1138 + */ 1139 + ds->untag_vlan_aware_bridge_pvid = true; 1140 + 1173 1141 ret = b53_reset_switch(dev); 1174 1142 if (ret) { 1175 1143 dev_err(ds->dev, "failed to reset switch\n"); 1176 1144 return ret; 1145 + } 1146 + 1147 + /* setup default vlan for filtering mode */ 1148 + pvid = b53_default_pvid(dev); 1149 + vl = &dev->vlans[pvid]; 1150 + b53_for_each_port(dev, port) { 1151 + vl->members |= BIT(port); 1152 + if (!b53_vlan_port_needs_forced_tagged(ds, port)) 1153 + vl->untag |= BIT(port); 1177 1154 } 1178 1155 1179 1156 b53_reset_mib(dev); ··· 1543 1492 { 1544 1493 struct b53_device *dev = ds->priv; 1545 1494 1546 - b53_enable_vlan(dev, port, dev->vlan_enabled, vlan_filtering); 1495 + if (dev->vlan_filtering != vlan_filtering) { 1496 + dev->vlan_filtering = vlan_filtering; 1497 + b53_apply_config(dev); 1498 + } 1547 1499 1548 1500 return 0; 1549 1501 } ··· 1571 1517 if (vlan->vid >= dev->num_vlans) 1572 1518 return -ERANGE; 1573 1519 1574 - b53_enable_vlan(dev, port, true, ds->vlan_filtering); 1520 + b53_enable_vlan(dev, port, true, dev->vlan_filtering); 1575 1521 1576 1522 return 0; 1577 1523 } ··· 1584 1530 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; 1585 1531 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; 1586 1532 struct b53_vlan *vl; 1533 + u16 old_pvid, new_pvid; 1587 1534 int err; 1588 1535 1589 1536 err = b53_vlan_prepare(ds, port, vlan); 1590 1537 if (err) 1591 1538 return err; 1592 1539 1540 + if (vlan->vid == 0) 1541 + return 0; 1542 + 1543 + old_pvid = dev->ports[port].pvid; 1544 + if (pvid) 1545 + new_pvid = vlan->vid; 1546 + else if (!pvid && vlan->vid == old_pvid) 1547 + new_pvid = b53_default_pvid(dev); 1548 + else 1549 + new_pvid = old_pvid; 1550 + dev->ports[port].pvid = new_pvid; 1551 + 1593 1552 vl = &dev->vlans[vlan->vid]; 1594 1553 1595 - b53_get_vlan_entry(dev, vlan->vid, vl); 1596 - 1597 - if (vlan->vid == 0 && vlan->vid == b53_default_pvid(dev)) 1598 - untagged = true; 1554 + if (dsa_is_cpu_port(ds, port)) 1555 + untagged = false; 1599 1556 1600 1557 vl->members |= BIT(port); 1601 1558 if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port)) ··· 1614 1549 else 1615 1550 vl->untag &= ~BIT(port); 1616 1551 1552 + if (!dev->vlan_filtering) 1553 + return 0; 1554 + 1617 1555 b53_set_vlan_entry(dev, vlan->vid, vl); 1618 1556 b53_fast_age_vlan(dev, vlan->vid); 1619 1557 1620 - if (pvid && !dsa_is_cpu_port(ds, port)) { 1558 + if (!dsa_is_cpu_port(ds, port) && new_pvid != old_pvid) { 1621 1559 b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), 1622 - vlan->vid); 1623 - b53_fast_age_vlan(dev, vlan->vid); 1560 + new_pvid); 1561 + b53_fast_age_vlan(dev, old_pvid); 1624 1562 } 1625 1563 1626 1564 return 0; ··· 1638 1570 struct b53_vlan *vl; 1639 1571 u16 pvid; 1640 1572 1641 - b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), &pvid); 1573 + if (vlan->vid == 0) 1574 + return 0; 1575 + 1576 + pvid = dev->ports[port].pvid; 1642 1577 1643 1578 vl = &dev->vlans[vlan->vid]; 1644 - 1645 - b53_get_vlan_entry(dev, vlan->vid, vl); 1646 1579 1647 1580 vl->members &= ~BIT(port); 1648 1581 1649 1582 if (pvid == vlan->vid) 1650 1583 pvid = b53_default_pvid(dev); 1584 + dev->ports[port].pvid = pvid; 1651 1585 1652 1586 if (untagged && !b53_vlan_port_needs_forced_tagged(ds, port)) 1653 1587 vl->untag &= ~(BIT(port)); 1588 + 1589 + if (!dev->vlan_filtering) 1590 + return 0; 1654 1591 1655 1592 b53_set_vlan_entry(dev, vlan->vid, vl); 1656 1593 b53_fast_age_vlan(dev, vlan->vid); ··· 1989 1916 bool *tx_fwd_offload, struct netlink_ext_ack *extack) 1990 1917 { 1991 1918 struct b53_device *dev = ds->priv; 1919 + struct b53_vlan *vl; 1992 1920 s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; 1993 - u16 pvlan, reg; 1921 + u16 pvlan, reg, pvid; 1994 1922 unsigned int i; 1995 1923 1996 1924 /* On 7278, port 7 which connects to the ASP should only receive ··· 2000 1926 if (dev->chip_id == BCM7278_DEVICE_ID && port == 7) 2001 1927 return -EINVAL; 2002 1928 2003 - /* Make this port leave the all VLANs join since we will have proper 2004 - * VLAN entries from now on 2005 - */ 2006 - if (is58xx(dev)) { 2007 - b53_read16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, &reg); 2008 - reg &= ~BIT(port); 2009 - if ((reg & BIT(cpu_port)) == BIT(cpu_port)) 2010 - reg &= ~BIT(cpu_port); 2011 - b53_write16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, reg); 1929 + pvid = b53_default_pvid(dev); 1930 + vl = &dev->vlans[pvid]; 1931 + 1932 + if (dev->vlan_filtering) { 1933 + /* Make this port leave the all VLANs join since we will have 1934 + * proper VLAN entries from now on 1935 + */ 1936 + if (is58xx(dev)) { 1937 + b53_read16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, 1938 + &reg); 1939 + reg &= ~BIT(port); 1940 + if ((reg & BIT(cpu_port)) == BIT(cpu_port)) 1941 + reg &= ~BIT(cpu_port); 1942 + b53_write16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, 1943 + reg); 1944 + } 1945 + 1946 + b53_get_vlan_entry(dev, pvid, vl); 1947 + vl->members &= ~BIT(port); 1948 + if (vl->members == BIT(cpu_port)) 1949 + vl->members &= ~BIT(cpu_port); 1950 + vl->untag = vl->members; 1951 + b53_set_vlan_entry(dev, pvid, vl); 2012 1952 } 2013 1953 2014 1954 b53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), &pvlan); ··· 2055 1967 void b53_br_leave(struct dsa_switch *ds, int port, struct dsa_bridge bridge) 2056 1968 { 2057 1969 struct b53_device *dev = ds->priv; 2058 - struct b53_vlan *vl = &dev->vlans[0]; 1970 + struct b53_vlan *vl; 2059 1971 s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; 2060 1972 unsigned int i; 2061 1973 u16 pvlan, reg, pvid; ··· 2081 1993 dev->ports[port].vlan_ctl_mask = pvlan; 2082 1994 2083 1995 pvid = b53_default_pvid(dev); 1996 + vl = &dev->vlans[pvid]; 2084 1997 2085 - /* Make this port join all VLANs without VLAN entries */ 2086 - if (is58xx(dev)) { 2087 - b53_read16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, &reg); 2088 - reg |= BIT(port); 2089 - if (!(reg & BIT(cpu_port))) 2090 - reg |= BIT(cpu_port); 2091 - b53_write16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, reg); 2092 - } else { 1998 + if (dev->vlan_filtering) { 1999 + /* Make this port join all VLANs without VLAN entries */ 2000 + if (is58xx(dev)) { 2001 + b53_read16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, &reg); 2002 + reg |= BIT(port); 2003 + if (!(reg & BIT(cpu_port))) 2004 + reg |= BIT(cpu_port); 2005 + b53_write16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN, reg); 2006 + } 2007 + 2093 2008 b53_get_vlan_entry(dev, pvid, vl); 2094 2009 vl->members |= BIT(port) | BIT(cpu_port); 2095 2010 vl->untag |= BIT(port) | BIT(cpu_port); ··· 2391 2300 .phy_read = b53_phy_read16, 2392 2301 .phy_write = b53_phy_write16, 2393 2302 .phylink_get_caps = b53_phylink_get_caps, 2303 + .port_setup = b53_setup_port, 2394 2304 .port_enable = b53_enable_port, 2395 2305 .port_disable = b53_disable_port, 2396 2306 .support_eee = b53_support_eee, ··· 2849 2757 ds->ops = &b53_switch_ops; 2850 2758 ds->phylink_mac_ops = &b53_phylink_mac_ops; 2851 2759 dev->vlan_enabled = true; 2760 + dev->vlan_filtering = false; 2852 2761 /* Let DSA handle the case were multiple bridges span the same switch 2853 2762 * device and different VLAN awareness settings are requested, which 2854 2763 * would be breaking filtering semantics for any of the other bridge
+3
drivers/net/dsa/b53/b53_priv.h
··· 96 96 97 97 struct b53_port { 98 98 u16 vlan_ctl_mask; 99 + u16 pvid; 99 100 struct ethtool_keee eee; 100 101 }; 101 102 ··· 148 147 unsigned int num_vlans; 149 148 struct b53_vlan *vlans; 150 149 bool vlan_enabled; 150 + bool vlan_filtering; 151 151 unsigned int num_ports; 152 152 struct b53_port *ports; 153 153 ··· 384 382 enum dsa_tag_protocol mprot); 385 383 void b53_mirror_del(struct dsa_switch *ds, int port, 386 384 struct dsa_mall_mirror_tc_entry *mirror); 385 + int b53_setup_port(struct dsa_switch *ds, int port); 387 386 int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy); 388 387 void b53_disable_port(struct dsa_switch *ds, int port); 389 388 void b53_brcm_hdr_setup(struct dsa_switch *ds, int port);
+1
drivers/net/dsa/bcm_sf2.c
··· 1230 1230 .resume = bcm_sf2_sw_resume, 1231 1231 .get_wol = bcm_sf2_sw_get_wol, 1232 1232 .set_wol = bcm_sf2_sw_set_wol, 1233 + .port_setup = b53_setup_port, 1233 1234 .port_enable = bcm_sf2_port_setup, 1234 1235 .port_disable = bcm_sf2_port_disable, 1235 1236 .support_eee = b53_support_eee,
+6 -4
drivers/net/ethernet/airoha/airoha_npu.c
··· 104 104 u8 xpon_hal_api; 105 105 u8 wan_xsi; 106 106 u8 ct_joyme4; 107 - int ppe_type; 108 - int wan_mode; 109 - int wan_sel; 107 + u8 max_packet; 108 + u8 rsv[3]; 109 + u32 ppe_type; 110 + u32 wan_mode; 111 + u32 wan_sel; 110 112 } init_info; 111 113 struct { 112 - int func_id; 114 + u32 func_id; 113 115 u32 size; 114 116 u32 data; 115 117 } set_info;
+18 -29
drivers/net/ethernet/intel/ice/ice_adapter.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 // SPDX-FileCopyrightText: Copyright Red Hat 3 3 4 - #include <linux/bitfield.h> 5 4 #include <linux/cleanup.h> 6 5 #include <linux/mutex.h> 7 6 #include <linux/pci.h> ··· 13 14 static DEFINE_XARRAY(ice_adapters); 14 15 static DEFINE_MUTEX(ice_adapters_mutex); 15 16 16 - /* PCI bus number is 8 bits. Slot is 5 bits. Domain can have the rest. */ 17 - #define INDEX_FIELD_DOMAIN GENMASK(BITS_PER_LONG - 1, 13) 18 - #define INDEX_FIELD_DEV GENMASK(31, 16) 19 - #define INDEX_FIELD_BUS GENMASK(12, 5) 20 - #define INDEX_FIELD_SLOT GENMASK(4, 0) 21 - 22 - static unsigned long ice_adapter_index(const struct pci_dev *pdev) 17 + static unsigned long ice_adapter_index(u64 dsn) 23 18 { 24 - unsigned int domain = pci_domain_nr(pdev->bus); 25 - 26 - WARN_ON(domain > FIELD_MAX(INDEX_FIELD_DOMAIN)); 27 - 28 - switch (pdev->device) { 29 - case ICE_DEV_ID_E825C_BACKPLANE: 30 - case ICE_DEV_ID_E825C_QSFP: 31 - case ICE_DEV_ID_E825C_SFP: 32 - case ICE_DEV_ID_E825C_SGMII: 33 - return FIELD_PREP(INDEX_FIELD_DEV, pdev->device); 34 - default: 35 - return FIELD_PREP(INDEX_FIELD_DOMAIN, domain) | 36 - FIELD_PREP(INDEX_FIELD_BUS, pdev->bus->number) | 37 - FIELD_PREP(INDEX_FIELD_SLOT, PCI_SLOT(pdev->devfn)); 38 - } 19 + #if BITS_PER_LONG == 64 20 + return dsn; 21 + #else 22 + return (u32)dsn ^ (u32)(dsn >> 32); 23 + #endif 39 24 } 40 25 41 - static struct ice_adapter *ice_adapter_new(void) 26 + static struct ice_adapter *ice_adapter_new(u64 dsn) 42 27 { 43 28 struct ice_adapter *adapter; 44 29 ··· 30 47 if (!adapter) 31 48 return NULL; 32 49 50 + adapter->device_serial_number = dsn; 33 51 spin_lock_init(&adapter->ptp_gltsyn_time_lock); 34 52 refcount_set(&adapter->refcount, 1); 35 53 ··· 61 77 * Return: Pointer to ice_adapter on success. 62 78 * ERR_PTR() on error. -ENOMEM is the only possible error. 63 79 */ 64 - struct ice_adapter *ice_adapter_get(const struct pci_dev *pdev) 80 + struct ice_adapter *ice_adapter_get(struct pci_dev *pdev) 65 81 { 66 - unsigned long index = ice_adapter_index(pdev); 82 + u64 dsn = pci_get_dsn(pdev); 67 83 struct ice_adapter *adapter; 84 + unsigned long index; 68 85 int err; 69 86 87 + index = ice_adapter_index(dsn); 70 88 scoped_guard(mutex, &ice_adapters_mutex) { 71 89 err = xa_insert(&ice_adapters, index, NULL, GFP_KERNEL); 72 90 if (err == -EBUSY) { 73 91 adapter = xa_load(&ice_adapters, index); 74 92 refcount_inc(&adapter->refcount); 93 + WARN_ON_ONCE(adapter->device_serial_number != dsn); 75 94 return adapter; 76 95 } 77 96 if (err) 78 97 return ERR_PTR(err); 79 98 80 - adapter = ice_adapter_new(); 99 + adapter = ice_adapter_new(dsn); 81 100 if (!adapter) 82 101 return ERR_PTR(-ENOMEM); 83 102 xa_store(&ice_adapters, index, adapter, GFP_KERNEL); ··· 97 110 * 98 111 * Context: Process, may sleep. 99 112 */ 100 - void ice_adapter_put(const struct pci_dev *pdev) 113 + void ice_adapter_put(struct pci_dev *pdev) 101 114 { 102 - unsigned long index = ice_adapter_index(pdev); 115 + u64 dsn = pci_get_dsn(pdev); 103 116 struct ice_adapter *adapter; 117 + unsigned long index; 104 118 119 + index = ice_adapter_index(dsn); 105 120 scoped_guard(mutex, &ice_adapters_mutex) { 106 121 adapter = xa_load(&ice_adapters, index); 107 122 if (WARN_ON(!adapter))
+4 -2
drivers/net/ethernet/intel/ice/ice_adapter.h
··· 32 32 * @refcount: Reference count. struct ice_pf objects hold the references. 33 33 * @ctrl_pf: Control PF of the adapter 34 34 * @ports: Ports list 35 + * @device_serial_number: DSN cached for collision detection on 32bit systems 35 36 */ 36 37 struct ice_adapter { 37 38 refcount_t refcount; ··· 41 40 42 41 struct ice_pf *ctrl_pf; 43 42 struct ice_port_list ports; 43 + u64 device_serial_number; 44 44 }; 45 45 46 - struct ice_adapter *ice_adapter_get(const struct pci_dev *pdev); 47 - void ice_adapter_put(const struct pci_dev *pdev); 46 + struct ice_adapter *ice_adapter_get(struct pci_dev *pdev); 47 + void ice_adapter_put(struct pci_dev *pdev); 48 48 49 49 #endif /* _ICE_ADAPTER_H */
+12 -7
drivers/net/ethernet/mediatek/mtk_eth_soc.c
··· 3186 3186 static void mtk_dma_free(struct mtk_eth *eth) 3187 3187 { 3188 3188 const struct mtk_soc_data *soc = eth->soc; 3189 - int i; 3189 + int i, j, txqs = 1; 3190 3190 3191 - for (i = 0; i < MTK_MAX_DEVS; i++) 3192 - if (eth->netdev[i]) 3193 - netdev_reset_queue(eth->netdev[i]); 3191 + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) 3192 + txqs = MTK_QDMA_NUM_QUEUES; 3193 + 3194 + for (i = 0; i < MTK_MAX_DEVS; i++) { 3195 + if (!eth->netdev[i]) 3196 + continue; 3197 + 3198 + for (j = 0; j < txqs; j++) 3199 + netdev_tx_reset_subqueue(eth->netdev[i], j); 3200 + } 3201 + 3194 3202 if (!MTK_HAS_CAPS(soc->caps, MTK_SRAM) && eth->scratch_ring) { 3195 3203 dma_free_coherent(eth->dma_dev, 3196 3204 MTK_QDMA_RING_SIZE * soc->tx.desc_size, ··· 3473 3465 } 3474 3466 mtk_gdm_config(eth, target_mac->id, gdm_config); 3475 3467 } 3476 - /* Reset and enable PSE */ 3477 - mtk_w32(eth, RST_GL_PSE, MTK_RST_GL); 3478 - mtk_w32(eth, 0, MTK_RST_GL); 3479 3468 3480 3469 napi_enable(&eth->tx_napi); 3481 3470 napi_enable(&eth->rx_napi);
+4 -4
drivers/net/ethernet/meta/fbnic/fbnic.h
··· 154 154 void fbnic_devlink_register(struct fbnic_dev *fbd); 155 155 void fbnic_devlink_unregister(struct fbnic_dev *fbd); 156 156 157 - int fbnic_fw_enable_mbx(struct fbnic_dev *fbd); 158 - void fbnic_fw_disable_mbx(struct fbnic_dev *fbd); 157 + int fbnic_fw_request_mbx(struct fbnic_dev *fbd); 158 + void fbnic_fw_free_mbx(struct fbnic_dev *fbd); 159 159 160 160 void fbnic_hwmon_register(struct fbnic_dev *fbd); 161 161 void fbnic_hwmon_unregister(struct fbnic_dev *fbd); 162 162 163 - int fbnic_pcs_irq_enable(struct fbnic_dev *fbd); 164 - void fbnic_pcs_irq_disable(struct fbnic_dev *fbd); 163 + int fbnic_pcs_request_irq(struct fbnic_dev *fbd); 164 + void fbnic_pcs_free_irq(struct fbnic_dev *fbd); 165 165 166 166 void fbnic_napi_name_irqs(struct fbnic_dev *fbd); 167 167 int fbnic_napi_request_irq(struct fbnic_dev *fbd,
+2
drivers/net/ethernet/meta/fbnic/fbnic_csr.h
··· 796 796 /* PUL User Registers */ 797 797 #define FBNIC_CSR_START_PUL_USER 0x31000 /* CSR section delimiter */ 798 798 #define FBNIC_PUL_OB_TLP_HDR_AW_CFG 0x3103d /* 0xc40f4 */ 799 + #define FBNIC_PUL_OB_TLP_HDR_AW_CFG_FLUSH CSR_BIT(19) 799 800 #define FBNIC_PUL_OB_TLP_HDR_AW_CFG_BME CSR_BIT(18) 800 801 #define FBNIC_PUL_OB_TLP_HDR_AR_CFG 0x3103e /* 0xc40f8 */ 802 + #define FBNIC_PUL_OB_TLP_HDR_AR_CFG_FLUSH CSR_BIT(19) 801 803 #define FBNIC_PUL_OB_TLP_HDR_AR_CFG_BME CSR_BIT(18) 802 804 #define FBNIC_PUL_USER_OB_RD_TLP_CNT_31_0 \ 803 805 0x3106e /* 0xc41b8 */
+119 -78
drivers/net/ethernet/meta/fbnic/fbnic_fw.c
··· 17 17 { 18 18 u32 desc_offset = FBNIC_IPC_MBX(mbx_idx, desc_idx); 19 19 20 + /* Write the upper 32b and then the lower 32b. Doing this the 21 + * FW can then read lower, upper, lower to verify that the state 22 + * of the descriptor wasn't changed mid-transaction. 23 + */ 20 24 fw_wr32(fbd, desc_offset + 1, upper_32_bits(desc)); 21 25 fw_wrfl(fbd); 22 26 fw_wr32(fbd, desc_offset, lower_32_bits(desc)); 27 + } 28 + 29 + static void __fbnic_mbx_invalidate_desc(struct fbnic_dev *fbd, int mbx_idx, 30 + int desc_idx, u32 desc) 31 + { 32 + u32 desc_offset = FBNIC_IPC_MBX(mbx_idx, desc_idx); 33 + 34 + /* For initialization we write the lower 32b of the descriptor first. 35 + * This way we can set the state to mark it invalid before we clear the 36 + * upper 32b. 37 + */ 38 + fw_wr32(fbd, desc_offset, desc); 39 + fw_wrfl(fbd); 40 + fw_wr32(fbd, desc_offset + 1, 0); 23 41 } 24 42 25 43 static u64 __fbnic_mbx_rd_desc(struct fbnic_dev *fbd, int mbx_idx, int desc_idx) ··· 51 33 return desc; 52 34 } 53 35 54 - static void fbnic_mbx_init_desc_ring(struct fbnic_dev *fbd, int mbx_idx) 36 + static void fbnic_mbx_reset_desc_ring(struct fbnic_dev *fbd, int mbx_idx) 55 37 { 56 38 int desc_idx; 39 + 40 + /* Disable DMA transactions from the device, 41 + * and flush any transactions triggered during cleaning 42 + */ 43 + switch (mbx_idx) { 44 + case FBNIC_IPC_MBX_RX_IDX: 45 + wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AW_CFG, 46 + FBNIC_PUL_OB_TLP_HDR_AW_CFG_FLUSH); 47 + break; 48 + case FBNIC_IPC_MBX_TX_IDX: 49 + wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AR_CFG, 50 + FBNIC_PUL_OB_TLP_HDR_AR_CFG_FLUSH); 51 + break; 52 + } 53 + 54 + wrfl(fbd); 57 55 58 56 /* Initialize first descriptor to all 0s. Doing this gives us a 59 57 * solid stop for the firmware to hit when it is done looping 60 58 * through the ring. 61 59 */ 62 - __fbnic_mbx_wr_desc(fbd, mbx_idx, 0, 0); 63 - 64 - fw_wrfl(fbd); 60 + __fbnic_mbx_invalidate_desc(fbd, mbx_idx, 0, 0); 65 61 66 62 /* We then fill the rest of the ring starting at the end and moving 67 63 * back toward descriptor 0 with skip descriptors that have no 68 64 * length nor address, and tell the firmware that they can skip 69 65 * them and just move past them to the one we initialized to 0. 70 66 */ 71 - for (desc_idx = FBNIC_IPC_MBX_DESC_LEN; --desc_idx;) { 72 - __fbnic_mbx_wr_desc(fbd, mbx_idx, desc_idx, 73 - FBNIC_IPC_MBX_DESC_FW_CMPL | 74 - FBNIC_IPC_MBX_DESC_HOST_CMPL); 75 - fw_wrfl(fbd); 76 - } 67 + for (desc_idx = FBNIC_IPC_MBX_DESC_LEN; --desc_idx;) 68 + __fbnic_mbx_invalidate_desc(fbd, mbx_idx, desc_idx, 69 + FBNIC_IPC_MBX_DESC_FW_CMPL | 70 + FBNIC_IPC_MBX_DESC_HOST_CMPL); 77 71 } 78 72 79 73 void fbnic_mbx_init(struct fbnic_dev *fbd) ··· 106 76 wr32(fbd, FBNIC_INTR_CLEAR(0), 1u << FBNIC_FW_MSIX_ENTRY); 107 77 108 78 for (i = 0; i < FBNIC_IPC_MBX_INDICES; i++) 109 - fbnic_mbx_init_desc_ring(fbd, i); 79 + fbnic_mbx_reset_desc_ring(fbd, i); 110 80 } 111 81 112 82 static int fbnic_mbx_map_msg(struct fbnic_dev *fbd, int mbx_idx, ··· 171 141 { 172 142 int i; 173 143 174 - fbnic_mbx_init_desc_ring(fbd, mbx_idx); 144 + fbnic_mbx_reset_desc_ring(fbd, mbx_idx); 175 145 176 146 for (i = FBNIC_IPC_MBX_DESC_LEN; i--;) 177 147 fbnic_mbx_unmap_and_free_msg(fbd, mbx_idx, i); ··· 352 322 return err; 353 323 } 354 324 355 - /** 356 - * fbnic_fw_xmit_cap_msg - Allocate and populate a FW capabilities message 357 - * @fbd: FBNIC device structure 358 - * 359 - * Return: NULL on failure to allocate, error pointer on error, or pointer 360 - * to new TLV test message. 361 - * 362 - * Sends a single TLV header indicating the host wants the firmware to 363 - * confirm the capabilities and version. 364 - **/ 365 - static int fbnic_fw_xmit_cap_msg(struct fbnic_dev *fbd) 366 - { 367 - int err = fbnic_fw_xmit_simple_msg(fbd, FBNIC_TLV_MSG_ID_HOST_CAP_REQ); 368 - 369 - /* Return 0 if we are not calling this on ASIC */ 370 - return (err == -EOPNOTSUPP) ? 0 : err; 371 - } 372 - 373 - static void fbnic_mbx_postinit_desc_ring(struct fbnic_dev *fbd, int mbx_idx) 325 + static void fbnic_mbx_init_desc_ring(struct fbnic_dev *fbd, int mbx_idx) 374 326 { 375 327 struct fbnic_fw_mbx *mbx = &fbd->mbx[mbx_idx]; 376 - 377 - /* This is a one time init, so just exit if it is completed */ 378 - if (mbx->ready) 379 - return; 380 328 381 329 mbx->ready = true; 382 330 383 331 switch (mbx_idx) { 384 332 case FBNIC_IPC_MBX_RX_IDX: 333 + /* Enable DMA writes from the device */ 334 + wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AW_CFG, 335 + FBNIC_PUL_OB_TLP_HDR_AW_CFG_BME); 336 + 385 337 /* Make sure we have a page for the FW to write to */ 386 338 fbnic_mbx_alloc_rx_msgs(fbd); 387 339 break; 388 340 case FBNIC_IPC_MBX_TX_IDX: 389 - /* Force version to 1 if we successfully requested an update 390 - * from the firmware. This should be overwritten once we get 391 - * the actual version from the firmware in the capabilities 392 - * request message. 393 - */ 394 - if (!fbnic_fw_xmit_cap_msg(fbd) && 395 - !fbd->fw_cap.running.mgmt.version) 396 - fbd->fw_cap.running.mgmt.version = 1; 341 + /* Enable DMA reads from the device */ 342 + wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AR_CFG, 343 + FBNIC_PUL_OB_TLP_HDR_AR_CFG_BME); 397 344 break; 398 345 } 399 346 } 400 347 401 - static void fbnic_mbx_postinit(struct fbnic_dev *fbd) 348 + static bool fbnic_mbx_event(struct fbnic_dev *fbd) 402 349 { 403 - int i; 404 - 405 - /* We only need to do this on the first interrupt following init. 350 + /* We only need to do this on the first interrupt following reset. 406 351 * this primes the mailbox so that we will have cleared all the 407 352 * skip descriptors. 408 353 */ 409 354 if (!(rd32(fbd, FBNIC_INTR_STATUS(0)) & (1u << FBNIC_FW_MSIX_ENTRY))) 410 - return; 355 + return false; 411 356 412 357 wr32(fbd, FBNIC_INTR_CLEAR(0), 1u << FBNIC_FW_MSIX_ENTRY); 413 358 414 - for (i = 0; i < FBNIC_IPC_MBX_INDICES; i++) 415 - fbnic_mbx_postinit_desc_ring(fbd, i); 359 + return true; 416 360 } 417 361 418 362 /** ··· 863 859 864 860 void fbnic_mbx_poll(struct fbnic_dev *fbd) 865 861 { 866 - fbnic_mbx_postinit(fbd); 862 + fbnic_mbx_event(fbd); 867 863 868 864 fbnic_mbx_process_tx_msgs(fbd); 869 865 fbnic_mbx_process_rx_msgs(fbd); ··· 871 867 872 868 int fbnic_mbx_poll_tx_ready(struct fbnic_dev *fbd) 873 869 { 874 - struct fbnic_fw_mbx *tx_mbx; 875 - int attempts = 50; 870 + unsigned long timeout = jiffies + 10 * HZ + 1; 871 + int err, i; 876 872 877 - /* Immediate fail if BAR4 isn't there */ 878 - if (!fbnic_fw_present(fbd)) 879 - return -ENODEV; 873 + do { 874 + if (!time_is_after_jiffies(timeout)) 875 + return -ETIMEDOUT; 880 876 881 - tx_mbx = &fbd->mbx[FBNIC_IPC_MBX_TX_IDX]; 882 - while (!tx_mbx->ready && --attempts) { 883 877 /* Force the firmware to trigger an interrupt response to 884 878 * avoid the mailbox getting stuck closed if the interrupt 885 879 * is reset. 886 880 */ 887 - fbnic_mbx_init_desc_ring(fbd, FBNIC_IPC_MBX_TX_IDX); 881 + fbnic_mbx_reset_desc_ring(fbd, FBNIC_IPC_MBX_TX_IDX); 888 882 889 - msleep(200); 883 + /* Immediate fail if BAR4 went away */ 884 + if (!fbnic_fw_present(fbd)) 885 + return -ENODEV; 890 886 891 - fbnic_mbx_poll(fbd); 887 + msleep(20); 888 + } while (!fbnic_mbx_event(fbd)); 889 + 890 + /* FW has shown signs of life. Enable DMA and start Tx/Rx */ 891 + for (i = 0; i < FBNIC_IPC_MBX_INDICES; i++) 892 + fbnic_mbx_init_desc_ring(fbd, i); 893 + 894 + /* Request an update from the firmware. This should overwrite 895 + * mgmt.version once we get the actual version from the firmware 896 + * in the capabilities request message. 897 + */ 898 + err = fbnic_fw_xmit_simple_msg(fbd, FBNIC_TLV_MSG_ID_HOST_CAP_REQ); 899 + if (err) 900 + goto clean_mbx; 901 + 902 + /* Use "1" to indicate we entered the state waiting for a response */ 903 + fbd->fw_cap.running.mgmt.version = 1; 904 + 905 + return 0; 906 + clean_mbx: 907 + /* Cleanup Rx buffers and disable mailbox */ 908 + fbnic_mbx_clean(fbd); 909 + return err; 910 + } 911 + 912 + static void __fbnic_fw_evict_cmpl(struct fbnic_fw_completion *cmpl_data) 913 + { 914 + cmpl_data->result = -EPIPE; 915 + complete(&cmpl_data->done); 916 + } 917 + 918 + static void fbnic_mbx_evict_all_cmpl(struct fbnic_dev *fbd) 919 + { 920 + if (fbd->cmpl_data) { 921 + __fbnic_fw_evict_cmpl(fbd->cmpl_data); 922 + fbd->cmpl_data = NULL; 892 923 } 893 - 894 - return attempts ? 0 : -ETIMEDOUT; 895 924 } 896 925 897 926 void fbnic_mbx_flush_tx(struct fbnic_dev *fbd) 898 927 { 928 + unsigned long timeout = jiffies + 10 * HZ + 1; 899 929 struct fbnic_fw_mbx *tx_mbx; 900 - int attempts = 50; 901 - u8 count = 0; 902 - 903 - /* Nothing to do if there is no mailbox */ 904 - if (!fbnic_fw_present(fbd)) 905 - return; 930 + u8 tail; 906 931 907 932 /* Record current Rx stats */ 908 933 tx_mbx = &fbd->mbx[FBNIC_IPC_MBX_TX_IDX]; 909 934 910 - /* Nothing to do if mailbox never got to ready */ 911 - if (!tx_mbx->ready) 912 - return; 935 + spin_lock_irq(&fbd->fw_tx_lock); 936 + 937 + /* Clear ready to prevent any further attempts to transmit */ 938 + tx_mbx->ready = false; 939 + 940 + /* Read tail to determine the last tail state for the ring */ 941 + tail = tx_mbx->tail; 942 + 943 + /* Flush any completions as we are no longer processing Rx */ 944 + fbnic_mbx_evict_all_cmpl(fbd); 945 + 946 + spin_unlock_irq(&fbd->fw_tx_lock); 913 947 914 948 /* Give firmware time to process packet, 915 - * we will wait up to 10 seconds which is 50 waits of 200ms. 949 + * we will wait up to 10 seconds which is 500 waits of 20ms. 916 950 */ 917 951 do { 918 952 u8 head = tx_mbx->head; 919 953 920 - if (head == tx_mbx->tail) 954 + /* Tx ring is empty once head == tail */ 955 + if (head == tail) 921 956 break; 922 957 923 - msleep(200); 958 + msleep(20); 924 959 fbnic_mbx_process_tx_msgs(fbd); 925 - 926 - count += (tx_mbx->head - head) % FBNIC_IPC_MBX_DESC_LEN; 927 - } while (count < FBNIC_IPC_MBX_DESC_LEN && --attempts); 960 + } while (time_is_after_jiffies(timeout)); 928 961 } 929 962 930 963 void fbnic_get_fw_ver_commit_str(struct fbnic_dev *fbd, char *fw_version,
+99 -49
drivers/net/ethernet/meta/fbnic/fbnic_irq.c
··· 19 19 return IRQ_HANDLED; 20 20 } 21 21 22 - /** 23 - * fbnic_fw_enable_mbx - Configure and initialize Firmware Mailbox 24 - * @fbd: Pointer to device to initialize 25 - * 26 - * This function will initialize the firmware mailbox rings, enable the IRQ 27 - * and initialize the communication between the Firmware and the host. The 28 - * firmware is expected to respond to the initialization by sending an 29 - * interrupt essentially notifying the host that it has seen the 30 - * initialization and is now synced up. 31 - * 32 - * Return: non-zero on failure. 33 - **/ 34 - int fbnic_fw_enable_mbx(struct fbnic_dev *fbd) 22 + static int __fbnic_fw_enable_mbx(struct fbnic_dev *fbd, int vector) 35 23 { 36 - u32 vector = fbd->fw_msix_vector; 37 24 int err; 38 - 39 - /* Request the IRQ for FW Mailbox vector. */ 40 - err = request_threaded_irq(vector, NULL, &fbnic_fw_msix_intr, 41 - IRQF_ONESHOT, dev_name(fbd->dev), fbd); 42 - if (err) 43 - return err; 44 25 45 26 /* Initialize mailbox and attempt to poll it into ready state */ 46 27 fbnic_mbx_init(fbd); 47 28 err = fbnic_mbx_poll_tx_ready(fbd); 48 29 if (err) { 49 30 dev_warn(fbd->dev, "FW mailbox did not enter ready state\n"); 50 - free_irq(vector, fbd); 51 31 return err; 52 32 } 53 33 54 - /* Enable interrupts */ 34 + /* Enable interrupt and unmask the vector */ 35 + enable_irq(vector); 55 36 fbnic_wr32(fbd, FBNIC_INTR_MASK_CLEAR(0), 1u << FBNIC_FW_MSIX_ENTRY); 56 37 57 38 return 0; 58 39 } 59 40 60 41 /** 61 - * fbnic_fw_disable_mbx - Disable mailbox and place it in standby state 62 - * @fbd: Pointer to device to disable 42 + * fbnic_fw_request_mbx - Configure and initialize Firmware Mailbox 43 + * @fbd: Pointer to device to initialize 63 44 * 64 - * This function will disable the mailbox interrupt, free any messages still 65 - * in the mailbox and place it into a standby state. The firmware is 66 - * expected to see the update and assume that the host is in the reset state. 45 + * This function will allocate the IRQ and then reinitialize the mailbox 46 + * starting communication between the host and firmware. 47 + * 48 + * Return: non-zero on failure. 67 49 **/ 68 - void fbnic_fw_disable_mbx(struct fbnic_dev *fbd) 50 + int fbnic_fw_request_mbx(struct fbnic_dev *fbd) 69 51 { 70 - /* Disable interrupt and free vector */ 71 - fbnic_wr32(fbd, FBNIC_INTR_MASK_SET(0), 1u << FBNIC_FW_MSIX_ENTRY); 52 + struct pci_dev *pdev = to_pci_dev(fbd->dev); 53 + int vector, err; 72 54 73 - /* Free the vector */ 74 - free_irq(fbd->fw_msix_vector, fbd); 55 + WARN_ON(fbd->fw_msix_vector); 56 + 57 + vector = pci_irq_vector(pdev, FBNIC_FW_MSIX_ENTRY); 58 + if (vector < 0) 59 + return vector; 60 + 61 + /* Request the IRQ for FW Mailbox vector. */ 62 + err = request_threaded_irq(vector, NULL, &fbnic_fw_msix_intr, 63 + IRQF_ONESHOT | IRQF_NO_AUTOEN, 64 + dev_name(fbd->dev), fbd); 65 + if (err) 66 + return err; 67 + 68 + /* Initialize mailbox and attempt to poll it into ready state */ 69 + err = __fbnic_fw_enable_mbx(fbd, vector); 70 + if (err) 71 + free_irq(vector, fbd); 72 + 73 + fbd->fw_msix_vector = vector; 74 + 75 + return err; 76 + } 77 + 78 + /** 79 + * fbnic_fw_disable_mbx - Temporarily place mailbox in standby state 80 + * @fbd: Pointer to device 81 + * 82 + * Shutdown the mailbox by notifying the firmware to stop sending us logs, mask 83 + * and synchronize the IRQ, and then clean up the rings. 84 + **/ 85 + static void fbnic_fw_disable_mbx(struct fbnic_dev *fbd) 86 + { 87 + /* Disable interrupt and synchronize the IRQ */ 88 + disable_irq(fbd->fw_msix_vector); 89 + 90 + /* Mask the vector */ 91 + fbnic_wr32(fbd, FBNIC_INTR_MASK_SET(0), 1u << FBNIC_FW_MSIX_ENTRY); 75 92 76 93 /* Make sure disabling logs message is sent, must be done here to 77 94 * avoid risk of completing without a running interrupt. 78 95 */ 79 96 fbnic_mbx_flush_tx(fbd); 80 - 81 - /* Reset the mailboxes to the initialized state */ 82 97 fbnic_mbx_clean(fbd); 98 + } 99 + 100 + /** 101 + * fbnic_fw_free_mbx - Disable mailbox and place it in standby state 102 + * @fbd: Pointer to device to disable 103 + * 104 + * This function will disable the mailbox interrupt, free any messages still 105 + * in the mailbox and place it into a disabled state. The firmware is 106 + * expected to see the update and assume that the host is in the reset state. 107 + **/ 108 + void fbnic_fw_free_mbx(struct fbnic_dev *fbd) 109 + { 110 + /* Vector has already been freed */ 111 + if (!fbd->fw_msix_vector) 112 + return; 113 + 114 + fbnic_fw_disable_mbx(fbd); 115 + 116 + /* Free the vector */ 117 + free_irq(fbd->fw_msix_vector, fbd); 118 + fbd->fw_msix_vector = 0; 83 119 } 84 120 85 121 static irqreturn_t fbnic_pcs_msix_intr(int __always_unused irq, void *data) ··· 137 101 } 138 102 139 103 /** 140 - * fbnic_pcs_irq_enable - Configure the MAC to enable it to advertise link 104 + * fbnic_pcs_request_irq - Configure the PCS to enable it to advertise link 141 105 * @fbd: Pointer to device to initialize 142 106 * 143 107 * This function provides basic bringup for the MAC/PCS IRQ. For now the IRQ ··· 145 109 * 146 110 * Return: non-zero on failure. 147 111 **/ 148 - int fbnic_pcs_irq_enable(struct fbnic_dev *fbd) 112 + int fbnic_pcs_request_irq(struct fbnic_dev *fbd) 149 113 { 150 - u32 vector = fbd->pcs_msix_vector; 151 - int err; 114 + struct pci_dev *pdev = to_pci_dev(fbd->dev); 115 + int vector, err; 152 116 153 - /* Request the IRQ for MAC link vector. 154 - * Map MAC cause to it, and unmask it 117 + WARN_ON(fbd->pcs_msix_vector); 118 + 119 + vector = pci_irq_vector(pdev, FBNIC_PCS_MSIX_ENTRY); 120 + if (vector < 0) 121 + return vector; 122 + 123 + /* Request the IRQ for PCS link vector. 124 + * Map PCS cause to it, and unmask it 155 125 */ 156 126 err = request_irq(vector, &fbnic_pcs_msix_intr, 0, 157 127 fbd->netdev->name, fbd); 158 128 if (err) 159 129 return err; 160 130 131 + /* Map and enable interrupt, unmask vector after link is configured */ 161 132 fbnic_wr32(fbd, FBNIC_INTR_MSIX_CTRL(FBNIC_INTR_MSIX_CTRL_PCS_IDX), 162 133 FBNIC_PCS_MSIX_ENTRY | FBNIC_INTR_MSIX_CTRL_ENABLE); 134 + 135 + fbd->pcs_msix_vector = vector; 163 136 164 137 return 0; 165 138 } 166 139 167 140 /** 168 - * fbnic_pcs_irq_disable - Teardown the MAC IRQ to prepare for stopping 141 + * fbnic_pcs_free_irq - Teardown the PCS IRQ to prepare for stopping 169 142 * @fbd: Pointer to device that is stopping 170 143 * 171 - * This function undoes the work done in fbnic_pcs_irq_enable and prepares 144 + * This function undoes the work done in fbnic_pcs_request_irq and prepares 172 145 * the device to no longer receive traffic on the host interface. 173 146 **/ 174 - void fbnic_pcs_irq_disable(struct fbnic_dev *fbd) 147 + void fbnic_pcs_free_irq(struct fbnic_dev *fbd) 175 148 { 149 + /* Vector has already been freed */ 150 + if (!fbd->pcs_msix_vector) 151 + return; 152 + 176 153 /* Disable interrupt */ 177 154 fbnic_wr32(fbd, FBNIC_INTR_MSIX_CTRL(FBNIC_INTR_MSIX_CTRL_PCS_IDX), 178 155 FBNIC_PCS_MSIX_ENTRY); 156 + fbnic_wrfl(fbd); 157 + 158 + /* Synchronize IRQ to prevent race that would unmask vector */ 159 + synchronize_irq(fbd->pcs_msix_vector); 160 + 161 + /* Mask the vector */ 179 162 fbnic_wr32(fbd, FBNIC_INTR_MASK_SET(0), 1u << FBNIC_PCS_MSIX_ENTRY); 180 163 181 164 /* Free the vector */ 182 165 free_irq(fbd->pcs_msix_vector, fbd); 166 + fbd->pcs_msix_vector = 0; 183 167 } 184 168 185 169 void fbnic_synchronize_irq(struct fbnic_dev *fbd, int nr) ··· 282 226 { 283 227 struct pci_dev *pdev = to_pci_dev(fbd->dev); 284 228 285 - fbd->pcs_msix_vector = 0; 286 - fbd->fw_msix_vector = 0; 287 - 288 229 fbd->num_irqs = 0; 289 230 290 231 pci_free_irq_vectors(pdev); ··· 306 253 num_irqs, wanted_irqs); 307 254 308 255 fbd->num_irqs = num_irqs; 309 - 310 - fbd->pcs_msix_vector = pci_irq_vector(pdev, FBNIC_PCS_MSIX_ENTRY); 311 - fbd->fw_msix_vector = pci_irq_vector(pdev, FBNIC_FW_MSIX_ENTRY); 312 256 313 257 return 0; 314 258 }
-6
drivers/net/ethernet/meta/fbnic/fbnic_mac.c
··· 79 79 fbnic_init_readrq(fbd, FBNIC_QM_RNI_RBP_CTL, cls, readrq); 80 80 fbnic_init_mps(fbd, FBNIC_QM_RNI_RDE_CTL, cls, mps); 81 81 fbnic_init_mps(fbd, FBNIC_QM_RNI_RCM_CTL, cls, mps); 82 - 83 - /* Enable XALI AR/AW outbound */ 84 - wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AW_CFG, 85 - FBNIC_PUL_OB_TLP_HDR_AW_CFG_BME); 86 - wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AR_CFG, 87 - FBNIC_PUL_OB_TLP_HDR_AR_CFG_BME); 88 82 } 89 83 90 84 static void fbnic_mac_init_qm(struct fbnic_dev *fbd)
+3 -2
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
··· 44 44 if (err) 45 45 goto time_stop; 46 46 47 - err = fbnic_pcs_irq_enable(fbd); 47 + err = fbnic_pcs_request_irq(fbd); 48 48 if (err) 49 49 goto time_stop; 50 + 50 51 /* Pull the BMC config and initialize the RPC */ 51 52 fbnic_bmc_rpc_init(fbd); 52 53 fbnic_rss_reinit(fbd, fbn); ··· 83 82 struct fbnic_net *fbn = netdev_priv(netdev); 84 83 85 84 fbnic_down(fbn); 86 - fbnic_pcs_irq_disable(fbn->fbd); 85 + fbnic_pcs_free_irq(fbn->fbd); 87 86 88 87 fbnic_time_stop(fbn); 89 88 fbnic_fw_xmit_ownership_msg(fbn->fbd, false);
+7 -7
drivers/net/ethernet/meta/fbnic/fbnic_pci.c
··· 283 283 goto free_irqs; 284 284 } 285 285 286 - err = fbnic_fw_enable_mbx(fbd); 286 + err = fbnic_fw_request_mbx(fbd); 287 287 if (err) { 288 288 dev_err(&pdev->dev, 289 289 "Firmware mailbox initialization failure\n"); ··· 363 363 fbnic_hwmon_unregister(fbd); 364 364 fbnic_dbg_fbd_exit(fbd); 365 365 fbnic_devlink_unregister(fbd); 366 - fbnic_fw_disable_mbx(fbd); 366 + fbnic_fw_free_mbx(fbd); 367 367 fbnic_free_irqs(fbd); 368 368 369 369 fbnic_devlink_free(fbd); ··· 387 387 rtnl_unlock(); 388 388 389 389 null_uc_addr: 390 - fbnic_fw_disable_mbx(fbd); 390 + fbnic_fw_free_mbx(fbd); 391 391 392 392 /* Free the IRQs so they aren't trying to occupy sleeping CPUs */ 393 393 fbnic_free_irqs(fbd); ··· 420 420 fbd->mac->init_regs(fbd); 421 421 422 422 /* Re-enable mailbox */ 423 - err = fbnic_fw_enable_mbx(fbd); 423 + err = fbnic_fw_request_mbx(fbd); 424 424 if (err) 425 425 goto err_free_irqs; 426 426 ··· 438 438 if (netif_running(netdev)) { 439 439 err = __fbnic_open(fbn); 440 440 if (err) 441 - goto err_disable_mbx; 441 + goto err_free_mbx; 442 442 } 443 443 444 444 rtnl_unlock(); 445 445 446 446 return 0; 447 - err_disable_mbx: 447 + err_free_mbx: 448 448 rtnl_unlock(); 449 - fbnic_fw_disable_mbx(fbd); 449 + fbnic_fw_free_mbx(fbd); 450 450 err_free_irqs: 451 451 fbnic_free_irqs(fbd); 452 452 err_invalidate_uc_addr:
+13 -2
drivers/net/ethernet/ti/icssg/icssg_common.c
··· 187 187 xdp_return_frame(xdpf); 188 188 break; 189 189 default: 190 - netdev_err(ndev, "tx_complete: invalid swdata type %d\n", swdata->type); 191 190 prueth_xmit_free(tx_chn, desc_tx); 192 191 ndev->stats.tx_dropped++; 193 192 continue; ··· 566 567 { 567 568 struct cppi5_host_desc_t *first_desc; 568 569 struct net_device *ndev = emac->ndev; 570 + struct netdev_queue *netif_txq; 569 571 struct prueth_tx_chn *tx_chn; 570 572 dma_addr_t desc_dma, buf_dma; 571 573 struct prueth_swdata *swdata; ··· 620 620 swdata->data.xdpf = xdpf; 621 621 } 622 622 623 + /* Report BQL before sending the packet */ 624 + netif_txq = netdev_get_tx_queue(ndev, tx_chn->id); 625 + netdev_tx_sent_queue(netif_txq, xdpf->len); 626 + 623 627 cppi5_hdesc_set_pktlen(first_desc, xdpf->len); 624 628 desc_dma = k3_cppi_desc_pool_virt2dma(tx_chn->desc_pool, first_desc); 625 629 626 630 ret = k3_udma_glue_push_tx_chn(tx_chn->tx_chn, first_desc, desc_dma); 627 631 if (ret) { 628 632 netdev_err(ndev, "xdp tx: push failed: %d\n", ret); 633 + netdev_tx_completed_queue(netif_txq, 1, xdpf->len); 629 634 goto drop_free_descs; 630 635 } 631 636 ··· 655 650 struct page *page, u32 *len) 656 651 { 657 652 struct net_device *ndev = emac->ndev; 653 + struct netdev_queue *netif_txq; 654 + int cpu = smp_processor_id(); 658 655 struct bpf_prog *xdp_prog; 659 656 struct xdp_frame *xdpf; 660 657 u32 pkt_len = *len; ··· 676 669 goto drop; 677 670 } 678 671 679 - q_idx = smp_processor_id() % emac->tx_ch_num; 672 + q_idx = cpu % emac->tx_ch_num; 673 + netif_txq = netdev_get_tx_queue(ndev, q_idx); 674 + __netif_tx_lock(netif_txq, cpu); 680 675 result = emac_xmit_xdp_frame(emac, xdpf, page, q_idx); 676 + __netif_tx_unlock(netif_txq); 681 677 if (result == ICSSG_XDP_CONSUMED) { 682 678 ndev->stats.tx_dropped++; 683 679 goto drop; ··· 989 979 ret = k3_udma_glue_push_tx_chn(tx_chn->tx_chn, first_desc, desc_dma); 990 980 if (ret) { 991 981 netdev_err(ndev, "tx: push failed: %d\n", ret); 982 + netdev_tx_completed_queue(netif_txq, 1, pkt_len); 992 983 goto drop_free_descs; 993 984 } 994 985
+10 -6
drivers/net/ethernet/ti/icssg/icssg_prueth.c
··· 1075 1075 { 1076 1076 struct prueth_emac *emac = netdev_priv(dev); 1077 1077 struct net_device *ndev = emac->ndev; 1078 + struct netdev_queue *netif_txq; 1079 + int cpu = smp_processor_id(); 1078 1080 struct xdp_frame *xdpf; 1079 1081 unsigned int q_idx; 1080 1082 int nxmit = 0; 1081 1083 u32 err; 1082 1084 int i; 1083 1085 1084 - q_idx = smp_processor_id() % emac->tx_ch_num; 1086 + q_idx = cpu % emac->tx_ch_num; 1087 + netif_txq = netdev_get_tx_queue(ndev, q_idx); 1085 1088 1086 1089 if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK)) 1087 1090 return -EINVAL; 1088 1091 1092 + __netif_tx_lock(netif_txq, cpu); 1089 1093 for (i = 0; i < n; i++) { 1090 1094 xdpf = frames[i]; 1091 1095 err = emac_xmit_xdp_frame(emac, xdpf, NULL, q_idx); ··· 1099 1095 } 1100 1096 nxmit++; 1101 1097 } 1098 + __netif_tx_unlock(netif_txq); 1102 1099 1103 1100 return nxmit; 1104 1101 } ··· 1114 1109 static int emac_xdp_setup(struct prueth_emac *emac, struct netdev_bpf *bpf) 1115 1110 { 1116 1111 struct bpf_prog *prog = bpf->prog; 1117 - xdp_features_t val; 1118 - 1119 - val = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | 1120 - NETDEV_XDP_ACT_NDO_XMIT; 1121 - xdp_set_features_flag(emac->ndev, val); 1122 1112 1123 1113 if (!emac->xdpi.prog && !prog) 1124 1114 return 0; ··· 1291 1291 ndev->hw_features = NETIF_F_SG; 1292 1292 ndev->features = ndev->hw_features | NETIF_F_HW_VLAN_CTAG_FILTER; 1293 1293 ndev->hw_features |= NETIF_PRUETH_HSR_OFFLOAD_FEATURES; 1294 + xdp_set_features_flag(ndev, 1295 + NETDEV_XDP_ACT_BASIC | 1296 + NETDEV_XDP_ACT_REDIRECT | 1297 + NETDEV_XDP_ACT_NDO_XMIT); 1294 1298 1295 1299 netif_napi_add(ndev, &emac->napi_rx, icssg_napi_rx_poll); 1296 1300 hrtimer_setup(&emac->rx_hrtimer, &emac_rx_timer_callback, CLOCK_MONOTONIC,
+18 -5
drivers/net/virtio_net.c
··· 3383 3383 bool refill) 3384 3384 { 3385 3385 bool running = netif_running(vi->dev); 3386 + bool schedule_refill = false; 3386 3387 3387 3388 if (refill && !try_fill_recv(vi, rq, GFP_KERNEL)) 3388 - schedule_delayed_work(&vi->refill, 0); 3389 - 3389 + schedule_refill = true; 3390 3390 if (running) 3391 3391 virtnet_napi_enable(rq); 3392 + 3393 + if (schedule_refill) 3394 + schedule_delayed_work(&vi->refill, 0); 3392 3395 } 3393 3396 3394 3397 static void virtnet_rx_resume_all(struct virtnet_info *vi) ··· 3731 3728 succ: 3732 3729 vi->curr_queue_pairs = queue_pairs; 3733 3730 /* virtnet_open() will refill when device is going to up. */ 3734 - if (dev->flags & IFF_UP) 3731 + spin_lock_bh(&vi->refill_lock); 3732 + if (dev->flags & IFF_UP && vi->refill_enabled) 3735 3733 schedule_delayed_work(&vi->refill, 0); 3734 + spin_unlock_bh(&vi->refill_lock); 3736 3735 3737 3736 return 0; 3738 3737 } ··· 5678 5673 5679 5674 if (vi->device_stats_cap & VIRTIO_NET_STATS_TYPE_TX_SPEED) 5680 5675 tx->hw_drop_ratelimits = 0; 5676 + 5677 + netdev_stat_queue_sum(dev, 5678 + dev->real_num_rx_queues, vi->max_queue_pairs, rx, 5679 + dev->real_num_tx_queues, vi->max_queue_pairs, tx); 5681 5680 } 5682 5681 5683 5682 static const struct netdev_stat_ops virtnet_stat_ops = { ··· 5894 5885 5895 5886 hdr_dma = virtqueue_dma_map_single_attrs(sq->vq, &xsk_hdr, vi->hdr_len, 5896 5887 DMA_TO_DEVICE, 0); 5897 - if (virtqueue_dma_mapping_error(sq->vq, hdr_dma)) 5898 - return -ENOMEM; 5888 + if (virtqueue_dma_mapping_error(sq->vq, hdr_dma)) { 5889 + err = -ENOMEM; 5890 + goto err_free_buffs; 5891 + } 5899 5892 5900 5893 err = xsk_pool_dma_map(pool, dma_dev, 0); 5901 5894 if (err) ··· 5925 5914 err_xsk_map: 5926 5915 virtqueue_dma_unmap_single_attrs(rq->vq, hdr_dma, vi->hdr_len, 5927 5916 DMA_TO_DEVICE, 0); 5917 + err_free_buffs: 5918 + kvfree(rq->xsk_buffs); 5928 5919 return err; 5929 5920 } 5930 5921
+2
drivers/net/wireless/intel/iwlwifi/pcie/drv.c
··· 588 588 IWL_DEV_INFO(0x7A70, 0x1692, iwlax411_2ax_cfg_so_gf4_a0, iwl_ax411_killer_1690i_name), 589 589 IWL_DEV_INFO(0x7AF0, 0x1691, iwlax411_2ax_cfg_so_gf4_a0, iwl_ax411_killer_1690s_name), 590 590 IWL_DEV_INFO(0x7AF0, 0x1692, iwlax411_2ax_cfg_so_gf4_a0, iwl_ax411_killer_1690i_name), 591 + IWL_DEV_INFO(0x7F70, 0x1691, iwlax411_2ax_cfg_so_gf4_a0, iwl_ax411_killer_1690s_name), 592 + IWL_DEV_INFO(0x7F70, 0x1692, iwlax411_2ax_cfg_so_gf4_a0, iwl_ax411_killer_1690i_name), 591 593 592 594 IWL_DEV_INFO(0x271C, 0x0214, iwl9260_2ac_cfg, iwl9260_1_name), 593 595 IWL_DEV_INFO(0x7E40, 0x1691, iwl_cfg_ma, iwl_ax411_killer_1690s_name),
+1 -1
include/linux/ieee80211.h
··· 1526 1526 struct { 1527 1527 u8 action_code; 1528 1528 u8 dialog_token; 1529 - u8 status_code; 1529 + __le16 status_code; 1530 1530 u8 variable[]; 1531 1531 } __packed ttlm_res; 1532 1532 struct {
+1
include/linux/netdevice.h
··· 4972 4972 4973 4973 /* Functions used for secondary unicast and multicast support */ 4974 4974 void dev_set_rx_mode(struct net_device *dev); 4975 + int netif_set_promiscuity(struct net_device *dev, int inc); 4975 4976 int dev_set_promiscuity(struct net_device *dev, int inc); 4976 4977 int netif_set_allmulti(struct net_device *dev, int inc, bool notify); 4977 4978 int dev_set_allmulti(struct net_device *dev, int inc);
+6
include/net/netdev_queues.h
··· 103 103 struct netdev_queue_stats_tx *tx); 104 104 }; 105 105 106 + void netdev_stat_queue_sum(struct net_device *netdev, 107 + int rx_start, int rx_end, 108 + struct netdev_queue_stats_rx *rx_sum, 109 + int tx_start, int tx_end, 110 + struct netdev_queue_stats_tx *tx_sum); 111 + 106 112 /** 107 113 * struct netdev_queue_mgmt_ops - netdev ops for queue management 108 114 *
+3
include/uapi/linux/bpf.h
··· 4968 4968 * the netns switch takes place from ingress to ingress without 4969 4969 * going through the CPU's backlog queue. 4970 4970 * 4971 + * *skb*\ **->mark** and *skb*\ **->tstamp** are not cleared during 4972 + * the netns switch. 4973 + * 4971 4974 * The *flags* argument is reserved and must be 0. The helper is 4972 4975 * currently only supported for tc BPF program types at the 4973 4976 * ingress hook and for veth and netkit target device types. The
+91 -60
net/can/gw.c
··· 130 130 u32 handled_frames; 131 131 u32 dropped_frames; 132 132 u32 deleted_frames; 133 - struct cf_mod mod; 133 + struct cf_mod __rcu *cf_mod; 134 134 union { 135 135 /* CAN frame data source */ 136 136 struct net_device *dev; ··· 459 459 struct cgw_job *gwj = (struct cgw_job *)data; 460 460 struct canfd_frame *cf; 461 461 struct sk_buff *nskb; 462 + struct cf_mod *mod; 462 463 int modidx = 0; 463 464 464 465 /* process strictly Classic CAN or CAN FD frames */ ··· 507 506 * When there is at least one modification function activated, 508 507 * we need to copy the skb as we want to modify skb->data. 509 508 */ 510 - if (gwj->mod.modfunc[0]) 509 + mod = rcu_dereference(gwj->cf_mod); 510 + if (mod->modfunc[0]) 511 511 nskb = skb_copy(skb, GFP_ATOMIC); 512 512 else 513 513 nskb = skb_clone(skb, GFP_ATOMIC); ··· 531 529 cf = (struct canfd_frame *)nskb->data; 532 530 533 531 /* perform preprocessed modification functions if there are any */ 534 - while (modidx < MAX_MODFUNCTIONS && gwj->mod.modfunc[modidx]) 535 - (*gwj->mod.modfunc[modidx++])(cf, &gwj->mod); 532 + while (modidx < MAX_MODFUNCTIONS && mod->modfunc[modidx]) 533 + (*mod->modfunc[modidx++])(cf, mod); 536 534 537 535 /* Has the CAN frame been modified? */ 538 536 if (modidx) { ··· 548 546 } 549 547 550 548 /* check for checksum updates */ 551 - if (gwj->mod.csumfunc.crc8) 552 - (*gwj->mod.csumfunc.crc8)(cf, &gwj->mod.csum.crc8); 549 + if (mod->csumfunc.crc8) 550 + (*mod->csumfunc.crc8)(cf, &mod->csum.crc8); 553 551 554 - if (gwj->mod.csumfunc.xor) 555 - (*gwj->mod.csumfunc.xor)(cf, &gwj->mod.csum.xor); 552 + if (mod->csumfunc.xor) 553 + (*mod->csumfunc.xor)(cf, &mod->csum.xor); 556 554 } 557 555 558 556 /* clear the skb timestamp if not configured the other way */ ··· 583 581 { 584 582 struct cgw_job *gwj = container_of(rcu_head, struct cgw_job, rcu); 585 583 584 + /* cgw_job::cf_mod is always accessed from the same cgw_job object within 585 + * the same RCU read section. Once cgw_job is scheduled for removal, 586 + * cf_mod can also be removed without mandating an additional grace period. 587 + */ 588 + kfree(rcu_access_pointer(gwj->cf_mod)); 586 589 kmem_cache_free(cgw_cache, gwj); 590 + } 591 + 592 + /* Return cgw_job::cf_mod with RTNL protected section */ 593 + static struct cf_mod *cgw_job_cf_mod(struct cgw_job *gwj) 594 + { 595 + return rcu_dereference_protected(gwj->cf_mod, rtnl_is_locked()); 587 596 } 588 597 589 598 static int cgw_notifier(struct notifier_block *nb, ··· 629 616 { 630 617 struct rtcanmsg *rtcan; 631 618 struct nlmsghdr *nlh; 619 + struct cf_mod *mod; 632 620 633 621 nlh = nlmsg_put(skb, pid, seq, type, sizeof(*rtcan), flags); 634 622 if (!nlh) ··· 664 650 goto cancel; 665 651 } 666 652 653 + mod = cgw_job_cf_mod(gwj); 667 654 if (gwj->flags & CGW_FLAGS_CAN_FD) { 668 655 struct cgw_fdframe_mod mb; 669 656 670 - if (gwj->mod.modtype.and) { 671 - memcpy(&mb.cf, &gwj->mod.modframe.and, sizeof(mb.cf)); 672 - mb.modtype = gwj->mod.modtype.and; 657 + if (mod->modtype.and) { 658 + memcpy(&mb.cf, &mod->modframe.and, sizeof(mb.cf)); 659 + mb.modtype = mod->modtype.and; 673 660 if (nla_put(skb, CGW_FDMOD_AND, sizeof(mb), &mb) < 0) 674 661 goto cancel; 675 662 } 676 663 677 - if (gwj->mod.modtype.or) { 678 - memcpy(&mb.cf, &gwj->mod.modframe.or, sizeof(mb.cf)); 679 - mb.modtype = gwj->mod.modtype.or; 664 + if (mod->modtype.or) { 665 + memcpy(&mb.cf, &mod->modframe.or, sizeof(mb.cf)); 666 + mb.modtype = mod->modtype.or; 680 667 if (nla_put(skb, CGW_FDMOD_OR, sizeof(mb), &mb) < 0) 681 668 goto cancel; 682 669 } 683 670 684 - if (gwj->mod.modtype.xor) { 685 - memcpy(&mb.cf, &gwj->mod.modframe.xor, sizeof(mb.cf)); 686 - mb.modtype = gwj->mod.modtype.xor; 671 + if (mod->modtype.xor) { 672 + memcpy(&mb.cf, &mod->modframe.xor, sizeof(mb.cf)); 673 + mb.modtype = mod->modtype.xor; 687 674 if (nla_put(skb, CGW_FDMOD_XOR, sizeof(mb), &mb) < 0) 688 675 goto cancel; 689 676 } 690 677 691 - if (gwj->mod.modtype.set) { 692 - memcpy(&mb.cf, &gwj->mod.modframe.set, sizeof(mb.cf)); 693 - mb.modtype = gwj->mod.modtype.set; 678 + if (mod->modtype.set) { 679 + memcpy(&mb.cf, &mod->modframe.set, sizeof(mb.cf)); 680 + mb.modtype = mod->modtype.set; 694 681 if (nla_put(skb, CGW_FDMOD_SET, sizeof(mb), &mb) < 0) 695 682 goto cancel; 696 683 } 697 684 } else { 698 685 struct cgw_frame_mod mb; 699 686 700 - if (gwj->mod.modtype.and) { 701 - memcpy(&mb.cf, &gwj->mod.modframe.and, sizeof(mb.cf)); 702 - mb.modtype = gwj->mod.modtype.and; 687 + if (mod->modtype.and) { 688 + memcpy(&mb.cf, &mod->modframe.and, sizeof(mb.cf)); 689 + mb.modtype = mod->modtype.and; 703 690 if (nla_put(skb, CGW_MOD_AND, sizeof(mb), &mb) < 0) 704 691 goto cancel; 705 692 } 706 693 707 - if (gwj->mod.modtype.or) { 708 - memcpy(&mb.cf, &gwj->mod.modframe.or, sizeof(mb.cf)); 709 - mb.modtype = gwj->mod.modtype.or; 694 + if (mod->modtype.or) { 695 + memcpy(&mb.cf, &mod->modframe.or, sizeof(mb.cf)); 696 + mb.modtype = mod->modtype.or; 710 697 if (nla_put(skb, CGW_MOD_OR, sizeof(mb), &mb) < 0) 711 698 goto cancel; 712 699 } 713 700 714 - if (gwj->mod.modtype.xor) { 715 - memcpy(&mb.cf, &gwj->mod.modframe.xor, sizeof(mb.cf)); 716 - mb.modtype = gwj->mod.modtype.xor; 701 + if (mod->modtype.xor) { 702 + memcpy(&mb.cf, &mod->modframe.xor, sizeof(mb.cf)); 703 + mb.modtype = mod->modtype.xor; 717 704 if (nla_put(skb, CGW_MOD_XOR, sizeof(mb), &mb) < 0) 718 705 goto cancel; 719 706 } 720 707 721 - if (gwj->mod.modtype.set) { 722 - memcpy(&mb.cf, &gwj->mod.modframe.set, sizeof(mb.cf)); 723 - mb.modtype = gwj->mod.modtype.set; 708 + if (mod->modtype.set) { 709 + memcpy(&mb.cf, &mod->modframe.set, sizeof(mb.cf)); 710 + mb.modtype = mod->modtype.set; 724 711 if (nla_put(skb, CGW_MOD_SET, sizeof(mb), &mb) < 0) 725 712 goto cancel; 726 713 } 727 714 } 728 715 729 - if (gwj->mod.uid) { 730 - if (nla_put_u32(skb, CGW_MOD_UID, gwj->mod.uid) < 0) 716 + if (mod->uid) { 717 + if (nla_put_u32(skb, CGW_MOD_UID, mod->uid) < 0) 731 718 goto cancel; 732 719 } 733 720 734 - if (gwj->mod.csumfunc.crc8) { 721 + if (mod->csumfunc.crc8) { 735 722 if (nla_put(skb, CGW_CS_CRC8, CGW_CS_CRC8_LEN, 736 - &gwj->mod.csum.crc8) < 0) 723 + &mod->csum.crc8) < 0) 737 724 goto cancel; 738 725 } 739 726 740 - if (gwj->mod.csumfunc.xor) { 727 + if (mod->csumfunc.xor) { 741 728 if (nla_put(skb, CGW_CS_XOR, CGW_CS_XOR_LEN, 742 - &gwj->mod.csum.xor) < 0) 729 + &mod->csum.xor) < 0) 743 730 goto cancel; 744 731 } 745 732 ··· 1074 1059 struct net *net = sock_net(skb->sk); 1075 1060 struct rtcanmsg *r; 1076 1061 struct cgw_job *gwj; 1077 - struct cf_mod mod; 1062 + struct cf_mod *mod; 1078 1063 struct can_can_gw ccgw; 1079 1064 u8 limhops = 0; 1080 1065 int err = 0; ··· 1093 1078 if (r->gwtype != CGW_TYPE_CAN_CAN) 1094 1079 return -EINVAL; 1095 1080 1096 - err = cgw_parse_attr(nlh, &mod, CGW_TYPE_CAN_CAN, &ccgw, &limhops); 1097 - if (err < 0) 1098 - return err; 1081 + mod = kmalloc(sizeof(*mod), GFP_KERNEL); 1082 + if (!mod) 1083 + return -ENOMEM; 1099 1084 1100 - if (mod.uid) { 1085 + err = cgw_parse_attr(nlh, mod, CGW_TYPE_CAN_CAN, &ccgw, &limhops); 1086 + if (err < 0) 1087 + goto out_free_cf; 1088 + 1089 + if (mod->uid) { 1101 1090 ASSERT_RTNL(); 1102 1091 1103 1092 /* check for updating an existing job with identical uid */ 1104 1093 hlist_for_each_entry(gwj, &net->can.cgw_list, list) { 1105 - if (gwj->mod.uid != mod.uid) 1094 + struct cf_mod *old_cf; 1095 + 1096 + old_cf = cgw_job_cf_mod(gwj); 1097 + if (old_cf->uid != mod->uid) 1106 1098 continue; 1107 1099 1108 1100 /* interfaces & filters must be identical */ 1109 - if (memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw))) 1110 - return -EINVAL; 1101 + if (memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw))) { 1102 + err = -EINVAL; 1103 + goto out_free_cf; 1104 + } 1111 1105 1112 - /* update modifications with disabled softirq & quit */ 1113 - local_bh_disable(); 1114 - memcpy(&gwj->mod, &mod, sizeof(mod)); 1115 - local_bh_enable(); 1106 + rcu_assign_pointer(gwj->cf_mod, mod); 1107 + kfree_rcu_mightsleep(old_cf); 1116 1108 return 0; 1117 1109 } 1118 1110 } 1119 1111 1120 1112 /* ifindex == 0 is not allowed for job creation */ 1121 - if (!ccgw.src_idx || !ccgw.dst_idx) 1122 - return -ENODEV; 1113 + if (!ccgw.src_idx || !ccgw.dst_idx) { 1114 + err = -ENODEV; 1115 + goto out_free_cf; 1116 + } 1123 1117 1124 1118 gwj = kmem_cache_alloc(cgw_cache, GFP_KERNEL); 1125 - if (!gwj) 1126 - return -ENOMEM; 1119 + if (!gwj) { 1120 + err = -ENOMEM; 1121 + goto out_free_cf; 1122 + } 1127 1123 1128 1124 gwj->handled_frames = 0; 1129 1125 gwj->dropped_frames = 0; ··· 1144 1118 gwj->limit_hops = limhops; 1145 1119 1146 1120 /* insert already parsed information */ 1147 - memcpy(&gwj->mod, &mod, sizeof(mod)); 1121 + RCU_INIT_POINTER(gwj->cf_mod, mod); 1148 1122 memcpy(&gwj->ccgw, &ccgw, sizeof(ccgw)); 1149 1123 1150 1124 err = -ENODEV; ··· 1178 1152 if (!err) 1179 1153 hlist_add_head_rcu(&gwj->list, &net->can.cgw_list); 1180 1154 out: 1181 - if (err) 1155 + if (err) { 1182 1156 kmem_cache_free(cgw_cache, gwj); 1183 - 1157 + out_free_cf: 1158 + kfree(mod); 1159 + } 1184 1160 return err; 1185 1161 } 1186 1162 ··· 1242 1214 1243 1215 /* remove only the first matching entry */ 1244 1216 hlist_for_each_entry_safe(gwj, nx, &net->can.cgw_list, list) { 1217 + struct cf_mod *cf_mod; 1218 + 1245 1219 if (gwj->flags != r->flags) 1246 1220 continue; 1247 1221 1248 1222 if (gwj->limit_hops != limhops) 1249 1223 continue; 1250 1224 1225 + cf_mod = cgw_job_cf_mod(gwj); 1251 1226 /* we have a match when uid is enabled and identical */ 1252 - if (gwj->mod.uid || mod.uid) { 1253 - if (gwj->mod.uid != mod.uid) 1227 + if (cf_mod->uid || mod.uid) { 1228 + if (cf_mod->uid != mod.uid) 1254 1229 continue; 1255 1230 } else { 1256 1231 /* no uid => check for identical modifications */ 1257 - if (memcmp(&gwj->mod, &mod, sizeof(mod))) 1232 + if (memcmp(cf_mod, &mod, sizeof(mod))) 1258 1233 continue; 1259 1234 } 1260 1235
+4 -14
net/core/dev.c
··· 9193 9193 return 0; 9194 9194 } 9195 9195 9196 - /** 9197 - * dev_set_promiscuity - update promiscuity count on a device 9198 - * @dev: device 9199 - * @inc: modifier 9200 - * 9201 - * Add or remove promiscuity from a device. While the count in the device 9202 - * remains above zero the interface remains promiscuous. Once it hits zero 9203 - * the device reverts back to normal filtering operation. A negative inc 9204 - * value is used to drop promiscuity on the device. 9205 - * Return 0 if successful or a negative errno code on error. 9206 - */ 9207 - int dev_set_promiscuity(struct net_device *dev, int inc) 9196 + int netif_set_promiscuity(struct net_device *dev, int inc) 9208 9197 { 9209 9198 unsigned int old_flags = dev->flags; 9210 9199 int err; ··· 9205 9216 dev_set_rx_mode(dev); 9206 9217 return err; 9207 9218 } 9208 - EXPORT_SYMBOL(dev_set_promiscuity); 9209 9219 9210 9220 int netif_set_allmulti(struct net_device *dev, int inc, bool notify) 9211 9221 { ··· 11954 11966 struct sk_buff *skb = NULL; 11955 11967 11956 11968 /* Shutdown queueing discipline. */ 11969 + netdev_lock_ops(dev); 11957 11970 dev_shutdown(dev); 11958 11971 dev_tcx_uninstall(dev); 11959 - netdev_lock_ops(dev); 11960 11972 dev_xdp_uninstall(dev); 11961 11973 dev_memory_provider_uninstall(dev); 11962 11974 netdev_unlock_ops(dev); ··· 12149 12161 synchronize_net(); 12150 12162 12151 12163 /* Shutdown queueing discipline. */ 12164 + netdev_lock_ops(dev); 12152 12165 dev_shutdown(dev); 12166 + netdev_unlock_ops(dev); 12153 12167 12154 12168 /* Notify protocols, that we are about to destroy 12155 12169 * this device. They should clean all the things.
+23
net/core/dev_api.c
··· 268 268 EXPORT_SYMBOL(dev_disable_lro); 269 269 270 270 /** 271 + * dev_set_promiscuity() - update promiscuity count on a device 272 + * @dev: device 273 + * @inc: modifier 274 + * 275 + * Add or remove promiscuity from a device. While the count in the device 276 + * remains above zero the interface remains promiscuous. Once it hits zero 277 + * the device reverts back to normal filtering operation. A negative inc 278 + * value is used to drop promiscuity on the device. 279 + * Return 0 if successful or a negative errno code on error. 280 + */ 281 + int dev_set_promiscuity(struct net_device *dev, int inc) 282 + { 283 + int ret; 284 + 285 + netdev_lock_ops(dev); 286 + ret = netif_set_promiscuity(dev, inc); 287 + netdev_unlock_ops(dev); 288 + 289 + return ret; 290 + } 291 + EXPORT_SYMBOL(dev_set_promiscuity); 292 + 293 + /** 271 294 * dev_set_allmulti() - update allmulti count on a device 272 295 * @dev: device 273 296 * @inc: modifier
+1
net/core/filter.c
··· 2509 2509 goto out_drop; 2510 2510 skb->dev = dev; 2511 2511 dev_sw_netstats_rx_add(dev, skb->len); 2512 + skb_scrub_packet(skb, false); 2512 2513 return -EAGAIN; 2513 2514 } 2514 2515 return flags & BPF_F_NEIGH ?
+50 -19
net/core/netdev-genl.c
··· 708 708 return 0; 709 709 } 710 710 711 + /** 712 + * netdev_stat_queue_sum() - add up queue stats from range of queues 713 + * @netdev: net_device 714 + * @rx_start: index of the first Rx queue to query 715 + * @rx_end: index after the last Rx queue (first *not* to query) 716 + * @rx_sum: output Rx stats, should be already initialized 717 + * @tx_start: index of the first Tx queue to query 718 + * @tx_end: index after the last Tx queue (first *not* to query) 719 + * @tx_sum: output Tx stats, should be already initialized 720 + * 721 + * Add stats from [start, end) range of queue IDs to *x_sum structs. 722 + * The sum structs must be already initialized. Usually this 723 + * helper is invoked from the .get_base_stats callbacks of drivers 724 + * to account for stats of disabled queues. In that case the ranges 725 + * are usually [netdev->real_num_*x_queues, netdev->num_*x_queues). 726 + */ 727 + void netdev_stat_queue_sum(struct net_device *netdev, 728 + int rx_start, int rx_end, 729 + struct netdev_queue_stats_rx *rx_sum, 730 + int tx_start, int tx_end, 731 + struct netdev_queue_stats_tx *tx_sum) 732 + { 733 + const struct netdev_stat_ops *ops; 734 + struct netdev_queue_stats_rx rx; 735 + struct netdev_queue_stats_tx tx; 736 + int i; 737 + 738 + ops = netdev->stat_ops; 739 + 740 + for (i = rx_start; i < rx_end; i++) { 741 + memset(&rx, 0xff, sizeof(rx)); 742 + if (ops->get_queue_stats_rx) 743 + ops->get_queue_stats_rx(netdev, i, &rx); 744 + netdev_nl_stats_add(rx_sum, &rx, sizeof(rx)); 745 + } 746 + for (i = tx_start; i < tx_end; i++) { 747 + memset(&tx, 0xff, sizeof(tx)); 748 + if (ops->get_queue_stats_tx) 749 + ops->get_queue_stats_tx(netdev, i, &tx); 750 + netdev_nl_stats_add(tx_sum, &tx, sizeof(tx)); 751 + } 752 + } 753 + EXPORT_SYMBOL(netdev_stat_queue_sum); 754 + 711 755 static int 712 756 netdev_nl_stats_by_netdev(struct net_device *netdev, struct sk_buff *rsp, 713 757 const struct genl_info *info) 714 758 { 715 - struct netdev_queue_stats_rx rx_sum, rx; 716 - struct netdev_queue_stats_tx tx_sum, tx; 717 - const struct netdev_stat_ops *ops; 759 + struct netdev_queue_stats_rx rx_sum; 760 + struct netdev_queue_stats_tx tx_sum; 718 761 void *hdr; 719 - int i; 720 762 721 - ops = netdev->stat_ops; 722 763 /* Netdev can't guarantee any complete counters */ 723 - if (!ops->get_base_stats) 764 + if (!netdev->stat_ops->get_base_stats) 724 765 return 0; 725 766 726 767 memset(&rx_sum, 0xff, sizeof(rx_sum)); 727 768 memset(&tx_sum, 0xff, sizeof(tx_sum)); 728 769 729 - ops->get_base_stats(netdev, &rx_sum, &tx_sum); 770 + netdev->stat_ops->get_base_stats(netdev, &rx_sum, &tx_sum); 730 771 731 772 /* The op was there, but nothing reported, don't bother */ 732 773 if (!memchr_inv(&rx_sum, 0xff, sizeof(rx_sum)) && ··· 780 739 if (nla_put_u32(rsp, NETDEV_A_QSTATS_IFINDEX, netdev->ifindex)) 781 740 goto nla_put_failure; 782 741 783 - for (i = 0; i < netdev->real_num_rx_queues; i++) { 784 - memset(&rx, 0xff, sizeof(rx)); 785 - if (ops->get_queue_stats_rx) 786 - ops->get_queue_stats_rx(netdev, i, &rx); 787 - netdev_nl_stats_add(&rx_sum, &rx, sizeof(rx)); 788 - } 789 - for (i = 0; i < netdev->real_num_tx_queues; i++) { 790 - memset(&tx, 0xff, sizeof(tx)); 791 - if (ops->get_queue_stats_tx) 792 - ops->get_queue_stats_tx(netdev, i, &tx); 793 - netdev_nl_stats_add(&tx_sum, &tx, sizeof(tx)); 794 - } 742 + netdev_stat_queue_sum(netdev, 0, netdev->real_num_rx_queues, &rx_sum, 743 + 0, netdev->real_num_tx_queues, &tx_sum); 795 744 796 745 if (netdev_nl_stats_write_rx(rsp, &rx_sum) || 797 746 netdev_nl_stats_write_tx(rsp, &tx_sum))
+9 -6
net/ipv6/addrconf.c
··· 3214 3214 struct in6_addr addr; 3215 3215 struct net_device *dev; 3216 3216 struct net *net = dev_net(idev->dev); 3217 - int scope, plen, offset = 0; 3217 + int scope, plen; 3218 3218 u32 pflags = 0; 3219 3219 3220 3220 ASSERT_RTNL(); 3221 3221 3222 3222 memset(&addr, 0, sizeof(struct in6_addr)); 3223 - /* in case of IP6GRE the dev_addr is an IPv6 and therefore we use only the last 4 bytes */ 3224 - if (idev->dev->addr_len == sizeof(struct in6_addr)) 3225 - offset = sizeof(struct in6_addr) - 4; 3226 - memcpy(&addr.s6_addr32[3], idev->dev->dev_addr + offset, 4); 3223 + memcpy(&addr.s6_addr32[3], idev->dev->dev_addr, 4); 3227 3224 3228 3225 if (!(idev->dev->flags & IFF_POINTOPOINT) && idev->dev->type == ARPHRD_SIT) { 3229 3226 scope = IPV6_ADDR_COMPATv4; ··· 3531 3534 return; 3532 3535 } 3533 3536 3534 - if (dev->type == ARPHRD_ETHER) { 3537 + /* Generate the IPv6 link-local address using addrconf_addr_gen(), 3538 + * unless we have an IPv4 GRE device not bound to an IP address and 3539 + * which is in EUI64 mode (as __ipv6_isatap_ifid() would fail in this 3540 + * case). Such devices fall back to add_v4_addrs() instead. 3541 + */ 3542 + if (!(dev->type == ARPHRD_IPGRE && *(__be32 *)dev->dev_addr == 0 && 3543 + idev->cnf.addr_gen_mode == IN6_ADDR_GEN_MODE_EUI64)) { 3535 3544 addrconf_addr_gen(idev, true); 3536 3545 return; 3537 3546 }
+6 -6
net/mac80211/mlme.c
··· 7675 7675 int hdr_len = offsetofend(struct ieee80211_mgmt, u.action.u.ttlm_res); 7676 7676 int ttlm_max_len = 2 + 1 + sizeof(struct ieee80211_ttlm_elem) + 1 + 7677 7677 2 * 2 * IEEE80211_TTLM_NUM_TIDS; 7678 + u16 status_code; 7678 7679 7679 7680 skb = dev_alloc_skb(local->tx_headroom + hdr_len + ttlm_max_len); 7680 7681 if (!skb) ··· 7698 7697 WARN_ON(1); 7699 7698 fallthrough; 7700 7699 case NEG_TTLM_RES_REJECT: 7701 - mgmt->u.action.u.ttlm_res.status_code = 7702 - WLAN_STATUS_DENIED_TID_TO_LINK_MAPPING; 7700 + status_code = WLAN_STATUS_DENIED_TID_TO_LINK_MAPPING; 7703 7701 break; 7704 7702 case NEG_TTLM_RES_ACCEPT: 7705 - mgmt->u.action.u.ttlm_res.status_code = WLAN_STATUS_SUCCESS; 7703 + status_code = WLAN_STATUS_SUCCESS; 7706 7704 break; 7707 7705 case NEG_TTLM_RES_SUGGEST_PREFERRED: 7708 - mgmt->u.action.u.ttlm_res.status_code = 7709 - WLAN_STATUS_PREF_TID_TO_LINK_MAPPING_SUGGESTED; 7706 + status_code = WLAN_STATUS_PREF_TID_TO_LINK_MAPPING_SUGGESTED; 7710 7707 ieee80211_neg_ttlm_add_suggested_map(skb, neg_ttlm); 7711 7708 break; 7712 7709 } 7713 7710 7711 + mgmt->u.action.u.ttlm_res.status_code = cpu_to_le16(status_code); 7714 7712 ieee80211_tx_skb(sdata, skb); 7715 7713 } 7716 7714 ··· 7875 7875 * This can be better implemented in the future, to handle request 7876 7876 * rejections. 7877 7877 */ 7878 - if (mgmt->u.action.u.ttlm_res.status_code != WLAN_STATUS_SUCCESS) 7878 + if (le16_to_cpu(mgmt->u.action.u.ttlm_res.status_code) != WLAN_STATUS_SUCCESS) 7879 7879 __ieee80211_disconnect(sdata); 7880 7880 } 7881 7881
+1 -1
net/netfilter/ipset/ip_set_hash_gen.h
··· 64 64 #define ahash_sizeof_regions(htable_bits) \ 65 65 (ahash_numof_locks(htable_bits) * sizeof(struct ip_set_region)) 66 66 #define ahash_region(n, htable_bits) \ 67 - ((n) % ahash_numof_locks(htable_bits)) 67 + ((n) / jhash_size(HTABLE_REGION_BITS)) 68 68 #define ahash_bucket_start(h, htable_bits) \ 69 69 ((htable_bits) < HTABLE_REGION_BITS ? 0 \ 70 70 : (h) * jhash_size(HTABLE_REGION_BITS))
+8 -19
net/netfilter/ipvs/ip_vs_xmit.c
··· 119 119 return false; 120 120 } 121 121 122 - /* Get route to daddr, update *saddr, optionally bind route to saddr */ 122 + /* Get route to daddr, optionally bind route to saddr */ 123 123 static struct rtable *do_output_route4(struct net *net, __be32 daddr, 124 - int rt_mode, __be32 *saddr) 124 + int rt_mode, __be32 *ret_saddr) 125 125 { 126 126 struct flowi4 fl4; 127 127 struct rtable *rt; 128 - bool loop = false; 129 128 130 129 memset(&fl4, 0, sizeof(fl4)); 131 130 fl4.daddr = daddr; ··· 134 135 retry: 135 136 rt = ip_route_output_key(net, &fl4); 136 137 if (IS_ERR(rt)) { 137 - /* Invalid saddr ? */ 138 - if (PTR_ERR(rt) == -EINVAL && *saddr && 139 - rt_mode & IP_VS_RT_MODE_CONNECT && !loop) { 140 - *saddr = 0; 141 - flowi4_update_output(&fl4, 0, daddr, 0); 142 - goto retry; 143 - } 144 138 IP_VS_DBG_RL("ip_route_output error, dest: %pI4\n", &daddr); 145 139 return NULL; 146 - } else if (!*saddr && rt_mode & IP_VS_RT_MODE_CONNECT && fl4.saddr) { 140 + } 141 + if (rt_mode & IP_VS_RT_MODE_CONNECT && fl4.saddr) { 147 142 ip_rt_put(rt); 148 - *saddr = fl4.saddr; 149 143 flowi4_update_output(&fl4, 0, daddr, fl4.saddr); 150 - loop = true; 144 + rt_mode = 0; 151 145 goto retry; 152 146 } 153 - *saddr = fl4.saddr; 147 + if (ret_saddr) 148 + *ret_saddr = fl4.saddr; 154 149 return rt; 155 150 } 156 151 ··· 337 344 if (ret_saddr) 338 345 *ret_saddr = dest_dst->dst_saddr.ip; 339 346 } else { 340 - __be32 saddr = htonl(INADDR_ANY); 341 - 342 347 noref = 0; 343 348 344 349 /* For such unconfigured boxes avoid many route lookups 345 350 * for performance reasons because we do not remember saddr 346 351 */ 347 352 rt_mode &= ~IP_VS_RT_MODE_CONNECT; 348 - rt = do_output_route4(net, daddr, rt_mode, &saddr); 353 + rt = do_output_route4(net, daddr, rt_mode, ret_saddr); 349 354 if (!rt) 350 355 goto err_unreach; 351 - if (ret_saddr) 352 - *ret_saddr = saddr; 353 356 } 354 357 355 358 local = (rt->rt_flags & RTCF_LOCAL) ? 1 : 0;
+1 -2
net/openvswitch/actions.c
··· 975 975 upcall.cmd = OVS_PACKET_CMD_ACTION; 976 976 upcall.mru = OVS_CB(skb)->mru; 977 977 978 - for (a = nla_data(attr), rem = nla_len(attr); rem > 0; 979 - a = nla_next(a, &rem)) { 978 + nla_for_each_nested(a, attr, rem) { 980 979 switch (nla_type(a)) { 981 980 case OVS_USERSPACE_ATTR_USERDATA: 982 981 upcall.userdata = a;
+6 -9
net/sched/sch_htb.c
··· 348 348 */ 349 349 static inline void htb_next_rb_node(struct rb_node **n) 350 350 { 351 - *n = rb_next(*n); 351 + if (*n) 352 + *n = rb_next(*n); 352 353 } 353 354 354 355 /** ··· 610 609 */ 611 610 static inline void htb_deactivate(struct htb_sched *q, struct htb_class *cl) 612 611 { 613 - WARN_ON(!cl->prio_activity); 614 - 612 + if (!cl->prio_activity) 613 + return; 615 614 htb_deactivate_prios(q, cl); 616 615 cl->prio_activity = 0; 617 616 } ··· 1486 1485 { 1487 1486 struct htb_class *cl = (struct htb_class *)arg; 1488 1487 1489 - if (!cl->prio_activity) 1490 - return; 1491 1488 htb_deactivate(qdisc_priv(sch), cl); 1492 1489 } 1493 1490 ··· 1739 1740 if (cl->parent) 1740 1741 cl->parent->children--; 1741 1742 1742 - if (cl->prio_activity) 1743 - htb_deactivate(q, cl); 1743 + htb_deactivate(q, cl); 1744 1744 1745 1745 if (cl->cmode != HTB_CAN_SEND) 1746 1746 htb_safe_rb_erase(&cl->pq_node, ··· 1947 1949 /* turn parent into inner node */ 1948 1950 qdisc_purge_queue(parent->leaf.q); 1949 1951 parent_qdisc = parent->leaf.q; 1950 - if (parent->prio_activity) 1951 - htb_deactivate(q, parent); 1952 + htb_deactivate(q, parent); 1952 1953 1953 1954 /* remove from evt list because of level change */ 1954 1955 if (parent->cmode != HTB_CAN_SEND) {
+1 -1
net/wireless/scan.c
··· 2681 2681 /* Required length for first defragmentation */ 2682 2682 buf_len = mle->datalen - 1; 2683 2683 for_each_element(elem, mle->data + mle->datalen, 2684 - ielen - sizeof(*mle) + mle->datalen) { 2684 + ie + ielen - mle->data - mle->datalen) { 2685 2685 if (elem->id != WLAN_EID_FRAGMENT) 2686 2686 break; 2687 2687
+3
tools/include/uapi/linux/bpf.h
··· 4968 4968 * the netns switch takes place from ingress to ingress without 4969 4969 * going through the CPU's backlog queue. 4970 4970 * 4971 + * *skb*\ **->mark** and *skb*\ **->tstamp** are not cleared during 4972 + * the netns switch. 4973 + * 4971 4974 * The *flags* argument is reserved and must be 0. The helper is 4972 4975 * currently only supported for tc BPF program types at the 4973 4976 * ingress hook and for veth and netkit target device types. The
+1 -1
tools/net/ynl/lib/ynl.c
··· 364 364 "Invalid attribute (binary %s)", policy->name); 365 365 return -1; 366 366 case YNL_PT_NUL_STR: 367 - if ((!policy->len || len <= policy->len) && !data[len - 1]) 367 + if (len && (!policy->len || len <= policy->len) && !data[len - 1]) 368 368 break; 369 369 yerr(yarg->ys, YNL_ERROR_ATTR_INVALID, 370 370 "Invalid attribute (string %s)", policy->name);
+27 -18
tools/testing/selftests/drivers/net/ping.py
··· 9 9 from lib.py import bkg, cmd, wait_port_listen, rand_port 10 10 from lib.py import defer, ethtool, ip 11 11 12 - remote_ifname="" 13 12 no_sleep=False 14 13 15 14 def _test_v4(cfg) -> None: 16 - cfg.require_ipver("4") 15 + if not cfg.addr_v["4"]: 16 + return 17 17 18 18 cmd("ping -c 1 -W0.5 " + cfg.remote_addr_v["4"]) 19 19 cmd("ping -c 1 -W0.5 " + cfg.addr_v["4"], host=cfg.remote) ··· 21 21 cmd("ping -s 65000 -c 1 -W0.5 " + cfg.addr_v["4"], host=cfg.remote) 22 22 23 23 def _test_v6(cfg) -> None: 24 - cfg.require_ipver("6") 24 + if not cfg.addr_v["6"]: 25 + return 25 26 26 27 cmd("ping -c 1 -W5 " + cfg.remote_addr_v["6"]) 27 28 cmd("ping -c 1 -W5 " + cfg.addr_v["6"], host=cfg.remote) ··· 58 57 59 58 def _set_xdp_generic_sb_on(cfg) -> None: 60 59 prog = cfg.net_lib_dir / "xdp_dummy.bpf.o" 61 - cmd(f"ip link set dev {remote_ifname} mtu 1500", shell=True, host=cfg.remote) 60 + cmd(f"ip link set dev {cfg.remote_ifname} mtu 1500", shell=True, host=cfg.remote) 62 61 cmd(f"ip link set dev {cfg.ifname} mtu 1500 xdpgeneric obj {prog} sec xdp", shell=True) 63 62 defer(cmd, f"ip link set dev {cfg.ifname} xdpgeneric off") 64 63 ··· 67 66 68 67 def _set_xdp_generic_mb_on(cfg) -> None: 69 68 prog = cfg.net_lib_dir / "xdp_dummy.bpf.o" 70 - cmd(f"ip link set dev {remote_ifname} mtu 9000", shell=True, host=cfg.remote) 71 - defer(ip, f"link set dev {remote_ifname} mtu 1500", host=cfg.remote) 69 + cmd(f"ip link set dev {cfg.remote_ifname} mtu 9000", shell=True, host=cfg.remote) 70 + defer(ip, f"link set dev {cfg.remote_ifname} mtu 1500", host=cfg.remote) 72 71 ip("link set dev %s mtu 9000 xdpgeneric obj %s sec xdp.frags" % (cfg.ifname, prog)) 73 72 defer(ip, f"link set dev {cfg.ifname} mtu 1500 xdpgeneric off") 74 73 ··· 77 76 78 77 def _set_xdp_native_sb_on(cfg) -> None: 79 78 prog = cfg.net_lib_dir / "xdp_dummy.bpf.o" 80 - cmd(f"ip link set dev {remote_ifname} mtu 1500", shell=True, host=cfg.remote) 79 + cmd(f"ip link set dev {cfg.remote_ifname} mtu 1500", shell=True, host=cfg.remote) 81 80 cmd(f"ip -j link set dev {cfg.ifname} mtu 1500 xdp obj {prog} sec xdp", shell=True) 82 81 defer(ip, f"link set dev {cfg.ifname} mtu 1500 xdp off") 83 82 xdp_info = ip("-d link show %s" % (cfg.ifname), json=True)[0] ··· 94 93 95 94 def _set_xdp_native_mb_on(cfg) -> None: 96 95 prog = cfg.net_lib_dir / "xdp_dummy.bpf.o" 97 - cmd(f"ip link set dev {remote_ifname} mtu 9000", shell=True, host=cfg.remote) 98 - defer(ip, f"link set dev {remote_ifname} mtu 1500", host=cfg.remote) 96 + cmd(f"ip link set dev {cfg.remote_ifname} mtu 9000", shell=True, host=cfg.remote) 97 + defer(ip, f"link set dev {cfg.remote_ifname} mtu 1500", host=cfg.remote) 99 98 try: 100 99 cmd(f"ip link set dev {cfg.ifname} mtu 9000 xdp obj {prog} sec xdp.frags", shell=True) 101 100 defer(ip, f"link set dev {cfg.ifname} mtu 1500 xdp off") ··· 113 112 except Exception as e: 114 113 raise KsftSkipEx('device does not support offloaded XDP') 115 114 defer(ip, f"link set dev {cfg.ifname} xdpoffload off") 116 - cmd(f"ip link set dev {remote_ifname} mtu 1500", shell=True, host=cfg.remote) 115 + cmd(f"ip link set dev {cfg.remote_ifname} mtu 1500", shell=True, host=cfg.remote) 117 116 118 117 if no_sleep != True: 119 118 time.sleep(10) 120 119 121 120 def get_interface_info(cfg) -> None: 122 - global remote_ifname 123 121 global no_sleep 124 122 125 - remote_info = cmd(f"ip -4 -o addr show to {cfg.remote_addr_v['4']} | awk '{{print $2}}'", shell=True, host=cfg.remote).stdout 126 - remote_ifname = remote_info.rstrip('\n') 127 - if remote_ifname == "": 123 + if cfg.remote_ifname == "": 128 124 raise KsftFailEx('Can not get remote interface') 129 125 local_info = ip("-d link show %s" % (cfg.ifname), json=True)[0] 130 126 if 'parentbus' in local_info and local_info['parentbus'] == "netdevsim": ··· 134 136 cmd(f"ip link set dev {cfg.ifname} xdp off ", shell=True) 135 137 cmd(f"ip link set dev {cfg.ifname} xdpgeneric off ", shell=True) 136 138 cmd(f"ip link set dev {cfg.ifname} xdpoffload off", shell=True) 137 - cmd(f"ip link set dev {remote_ifname} mtu 1500", shell=True, host=cfg.remote) 139 + cmd(f"ip link set dev {cfg.remote_ifname} mtu 1500", shell=True, host=cfg.remote) 138 140 139 - def test_default(cfg, netnl) -> None: 141 + def test_default_v4(cfg, netnl) -> None: 142 + cfg.require_ipver("4") 143 + 140 144 _set_offload_checksum(cfg, netnl, "off") 141 145 _test_v4(cfg) 142 - _test_v6(cfg) 143 146 _test_tcp(cfg) 144 147 _set_offload_checksum(cfg, netnl, "on") 145 148 _test_v4(cfg) 149 + _test_tcp(cfg) 150 + 151 + def test_default_v6(cfg, netnl) -> None: 152 + cfg.require_ipver("6") 153 + 154 + _set_offload_checksum(cfg, netnl, "off") 155 + _test_v6(cfg) 156 + _test_tcp(cfg) 157 + _set_offload_checksum(cfg, netnl, "on") 146 158 _test_v6(cfg) 147 159 _test_tcp(cfg) 148 160 ··· 210 202 with NetDrvEpEnv(__file__) as cfg: 211 203 get_interface_info(cfg) 212 204 set_interface_init(cfg) 213 - ksft_run([test_default, 205 + ksft_run([test_default_v4, 206 + test_default_v6, 214 207 test_xdp_generic_sb, 215 208 test_xdp_generic_mb, 216 209 test_xdp_native_sb,
+1
tools/testing/selftests/net/Makefile
··· 31 31 TEST_PROGS += ioam6.sh 32 32 TEST_PROGS += gro.sh 33 33 TEST_PROGS += gre_gso.sh 34 + TEST_PROGS += gre_ipv6_lladdr.sh 34 35 TEST_PROGS += cmsg_so_mark.sh 35 36 TEST_PROGS += cmsg_so_priority.sh 36 37 TEST_PROGS += test_so_rcv.sh
+177
tools/testing/selftests/net/gre_ipv6_lladdr.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + source ./lib.sh 5 + 6 + PAUSE_ON_FAIL="no" 7 + 8 + # The trap function handler 9 + # 10 + exit_cleanup_all() 11 + { 12 + cleanup_all_ns 13 + 14 + exit "${EXIT_STATUS}" 15 + } 16 + 17 + # Add fake IPv4 and IPv6 networks on the loopback device, to be used as 18 + # underlay by future GRE devices. 19 + # 20 + setup_basenet() 21 + { 22 + ip -netns "${NS0}" link set dev lo up 23 + ip -netns "${NS0}" address add dev lo 192.0.2.10/24 24 + ip -netns "${NS0}" address add dev lo 2001:db8::10/64 nodad 25 + } 26 + 27 + # Check if network device has an IPv6 link-local address assigned. 28 + # 29 + # Parameters: 30 + # 31 + # * $1: The network device to test 32 + # * $2: An extra regular expression that should be matched (to verify the 33 + # presence of extra attributes) 34 + # * $3: The expected return code from grep (to allow checking the absence of 35 + # a link-local address) 36 + # * $4: The user visible name for the scenario being tested 37 + # 38 + check_ipv6_ll_addr() 39 + { 40 + local DEV="$1" 41 + local EXTRA_MATCH="$2" 42 + local XRET="$3" 43 + local MSG="$4" 44 + 45 + RET=0 46 + set +e 47 + ip -netns "${NS0}" -6 address show dev "${DEV}" scope link | grep "fe80::" | grep -q "${EXTRA_MATCH}" 48 + check_err_fail "${XRET}" $? "" 49 + log_test "${MSG}" 50 + set -e 51 + } 52 + 53 + # Create a GRE device and verify that it gets an IPv6 link-local address as 54 + # expected. 55 + # 56 + # Parameters: 57 + # 58 + # * $1: The device type (gre, ip6gre, gretap or ip6gretap) 59 + # * $2: The local underlay IP address (can be an IPv4, an IPv6 or "any") 60 + # * $3: The remote underlay IP address (can be an IPv4, an IPv6 or "any") 61 + # * $4: The IPv6 interface identifier generation mode to use for the GRE 62 + # device (eui64, none, stable-privacy or random). 63 + # 64 + test_gre_device() 65 + { 66 + local GRE_TYPE="$1" 67 + local LOCAL_IP="$2" 68 + local REMOTE_IP="$3" 69 + local MODE="$4" 70 + local ADDR_GEN_MODE 71 + local MATCH_REGEXP 72 + local MSG 73 + 74 + ip link add netns "${NS0}" name gretest type "${GRE_TYPE}" local "${LOCAL_IP}" remote "${REMOTE_IP}" 75 + 76 + case "${MODE}" in 77 + "eui64") 78 + ADDR_GEN_MODE=0 79 + MATCH_REGEXP="" 80 + MSG="${GRE_TYPE}, mode: 0 (EUI64), ${LOCAL_IP} -> ${REMOTE_IP}" 81 + XRET=0 82 + ;; 83 + "none") 84 + ADDR_GEN_MODE=1 85 + MATCH_REGEXP="" 86 + MSG="${GRE_TYPE}, mode: 1 (none), ${LOCAL_IP} -> ${REMOTE_IP}" 87 + XRET=1 # No link-local address should be generated 88 + ;; 89 + "stable-privacy") 90 + ADDR_GEN_MODE=2 91 + MATCH_REGEXP="stable-privacy" 92 + MSG="${GRE_TYPE}, mode: 2 (stable privacy), ${LOCAL_IP} -> ${REMOTE_IP}" 93 + XRET=0 94 + # Initialise stable_secret (required for stable-privacy mode) 95 + ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.stable_secret="2001:db8::abcd" 96 + ;; 97 + "random") 98 + ADDR_GEN_MODE=3 99 + MATCH_REGEXP="stable-privacy" 100 + MSG="${GRE_TYPE}, mode: 3 (random), ${LOCAL_IP} -> ${REMOTE_IP}" 101 + XRET=0 102 + ;; 103 + esac 104 + 105 + # Check that IPv6 link-local address is generated when device goes up 106 + ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.addr_gen_mode="${ADDR_GEN_MODE}" 107 + ip -netns "${NS0}" link set dev gretest up 108 + check_ipv6_ll_addr gretest "${MATCH_REGEXP}" "${XRET}" "config: ${MSG}" 109 + 110 + # Now disable link-local address generation 111 + ip -netns "${NS0}" link set dev gretest down 112 + ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.addr_gen_mode=1 113 + ip -netns "${NS0}" link set dev gretest up 114 + 115 + # Check that link-local address generation works when re-enabled while 116 + # the device is already up 117 + ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.addr_gen_mode="${ADDR_GEN_MODE}" 118 + check_ipv6_ll_addr gretest "${MATCH_REGEXP}" "${XRET}" "update: ${MSG}" 119 + 120 + ip -netns "${NS0}" link del dev gretest 121 + } 122 + 123 + test_gre4() 124 + { 125 + local GRE_TYPE 126 + local MODE 127 + 128 + for GRE_TYPE in "gre" "gretap"; do 129 + printf "\n####\nTesting IPv6 link-local address generation on ${GRE_TYPE} devices\n####\n\n" 130 + 131 + for MODE in "eui64" "none" "stable-privacy" "random"; do 132 + test_gre_device "${GRE_TYPE}" 192.0.2.10 192.0.2.11 "${MODE}" 133 + test_gre_device "${GRE_TYPE}" any 192.0.2.11 "${MODE}" 134 + test_gre_device "${GRE_TYPE}" 192.0.2.10 any "${MODE}" 135 + done 136 + done 137 + } 138 + 139 + test_gre6() 140 + { 141 + local GRE_TYPE 142 + local MODE 143 + 144 + for GRE_TYPE in "ip6gre" "ip6gretap"; do 145 + printf "\n####\nTesting IPv6 link-local address generation on ${GRE_TYPE} devices\n####\n\n" 146 + 147 + for MODE in "eui64" "none" "stable-privacy" "random"; do 148 + test_gre_device "${GRE_TYPE}" 2001:db8::10 2001:db8::11 "${MODE}" 149 + test_gre_device "${GRE_TYPE}" any 2001:db8::11 "${MODE}" 150 + test_gre_device "${GRE_TYPE}" 2001:db8::10 any "${MODE}" 151 + done 152 + done 153 + } 154 + 155 + usage() 156 + { 157 + echo "Usage: $0 [-p]" 158 + exit 1 159 + } 160 + 161 + while getopts :p o 162 + do 163 + case $o in 164 + p) PAUSE_ON_FAIL="yes";; 165 + *) usage;; 166 + esac 167 + done 168 + 169 + setup_ns NS0 170 + 171 + set -e 172 + trap exit_cleanup_all EXIT 173 + 174 + setup_basenet 175 + 176 + test_gre4 177 + test_gre6
+35
tools/testing/selftests/tc-testing/tc-tests/infra/qdiscs.json
··· 538 538 "$TC qdisc del dev $DUMMY handle 1:0 root", 539 539 "$IP addr del 10.10.10.10/24 dev $DUMMY || true" 540 540 ] 541 + }, 542 + { 543 + "id": "62c4", 544 + "name": "Test HTB with FQ_CODEL - basic functionality", 545 + "category": [ 546 + "qdisc", 547 + "htb", 548 + "fq_codel" 549 + ], 550 + "plugins": { 551 + "requires": [ 552 + "nsPlugin", 553 + "scapyPlugin" 554 + ] 555 + }, 556 + "setup": [ 557 + "$TC qdisc add dev $DEV1 root handle 1: htb default 11", 558 + "$TC class add dev $DEV1 parent 1: classid 1:1 htb rate 10kbit", 559 + "$TC class add dev $DEV1 parent 1:1 classid 1:11 htb rate 10kbit prio 0 quantum 1486", 560 + "$TC qdisc add dev $DEV1 parent 1:11 fq_codel quantum 300 noecn", 561 + "sleep 0.5" 562 + ], 563 + "scapy": { 564 + "iface": "$DEV0", 565 + "count": 5, 566 + "packet": "Ether()/IP(dst='10.10.10.1', src='10.10.10.10')/TCP(sport=12345, dport=80)" 567 + }, 568 + "cmdUnderTest": "$TC -s qdisc show dev $DEV1", 569 + "expExitCode": "0", 570 + "verifyCmd": "$TC -s qdisc show dev $DEV1 | grep -A 5 'qdisc fq_codel'", 571 + "matchPattern": "Sent [0-9]+ bytes [0-9]+ pkt", 572 + "matchCount": "1", 573 + "teardown": [ 574 + "$TC qdisc del dev $DEV1 handle 1: root" 575 + ] 541 576 } 542 577 ]