Skip to content

Patch mac80211 to give correct skb sizes for 4addr wds frames - fixes… - #17

Closed
grozzie2 wants to merge 1 commit into
openwrt:masterfrom
grozzie2:master
Closed

grozzie2 wants to merge 1 commit into
openwrt:masterfrom
grozzie2:master

Conversation

@grozzie2

Copy link
Copy Markdown

… stp on wds bridges

net/wireless/util.c at line 512 sets length for the skb, then promptly removes 80211 header data, leaving length incorrect, which is caught by llc processing later, preventing stp frames from being processed.

This corrects the h_proto value so frames will be processed with stp information over wds 4addr type bridges.

@yeryomin

Copy link
Copy Markdown

Could you be consistent with kernel style and put spaces around minus sign?
Thanks!

@grozzie2

Copy link
Copy Markdown
Author

The patch has become more or less redundant at this point. Felix reformatted and sent upstream, the fix is now in mainline.

@blogic blogic closed this Nov 7, 2017
sdelafond referenced this pull request in untangle/openwrt Oct 15, 2020
nquest pushed a commit to nquest/openwrt that referenced this pull request Sep 29, 2022
ddb65536 added a commit to ddb65536/openwrt that referenced this pull request Jun 11, 2024
OpenFi 5Pro is a DualBand Travel Router, based on MT7621A.

Specification:
- Type             : Travel Wi-Fi Router(built-in Type-C Power Cable)
- Size             : 63 x 93 x 24mm
- Power            : Internal Type-C Cable PD/DC 5V@2A
- SoC              : MediaTek MT7621A
- RAM              : DDR3 512 MB
- Flash            : SPI-NOR 64MB (W25Q512)
- WLAN             : 2.4/5GHz 2T2R (MediaTek MT7603e/MT7613)
- Ethernet         : 2x 10/100/1000Mbps
- USB              : 1 x USB 2.0
- SDHCI            : 1 x TF Slot (Max 512GB)
- LEDs             : 3 x LEDs  (GPIO openwrt#16 openwrt#17 openwrt#14)
- Button           : 1 x Reset (GPIO#18),  1 x WPS (GPIO#13)
- UART             : 1 x UART for Debug, 115200 8N1 (Pinout: GND TX RX 3.3V)
- UART 2           : 1xUART2  (Pinout: GND TX2 RX2 3.3V )

How to upgrade image in uboot

1. press reset button when boot for 5sec.
2. access 192.168.21.1 in web ui.
3. select image and upload

Signed-off-by: Sven Huang <[email protected]>
Ansuel pushed a commit to Ansuel/openwrt that referenced this pull request Jul 19, 2024
chozian pushed a commit to chozian/openwrt that referenced this pull request Oct 13, 2024
MayorBug pushed a commit to MayorBug/openwrt that referenced this pull request Oct 4, 2026
mac80211: ath11k: fix the 6.18 mesh build and four NSS bugs
haddad2inc added a commit to haddad2inc/openwrt that referenced this pull request Oct 11, 2026
Add 835-leds-trigger-netdev-add-byte-rate-threshold-mode.patch
(pending-6.18, 8xx = other drivers, next to 834-ledtrig-libata).

The netdev trigger blinks per packet counted by the netdev. On a DSA user
port that is blind in both directions at once: hardware-forwarded traffic
is not counted at all, while background broadcast and management noise is
counted and makes the LED flicker on an otherwise idle link. The result is
an LED that sits still on a port carrying 80+ Mbit/s and twitches on a port
carrying nothing.

Add a rate_threshold attribute in KiB/s. When non-zero the trigger drives
the LED from the interface byte rate instead, blinking on a 50..150 ms
ladder above the threshold and staying solid on link (or off without
carrier) below it. Writing 0 restores the classic per-packet behaviour, so
the attribute is reversible at runtime.

Design points a reviewer will ask about:

  * The rate is measured over the interval between two observed counter
    changes, not over a fixed window. A driver that refreshes its counters
    in bursts - a cached switch MIB, for instance - would otherwise dump a
    whole accumulation period into the first fixed window after the
    refresh, reporting a rate several times too high and then zero until
    the next refresh. Measuring between changes makes the trigger
    independent of the provider's refresh interval, and the last measured
    rate is held until the counter has been silent for twice the interval
    it was measured over (capped at 10 s). A decreasing counter re-anchors
    the measurement instead of reporting an enormous unsigned difference.
  * The measured rate is smoothed the way field-accepted userspace activity
    daemons do it - immediate attack at or above the threshold, a slow rise
    and a quick release below it - and when the counter goes silent the
    blink fades out quadratically from the last peak over 20 s, with the
    ladder step only ever slowing during the fade.
  * The blink is re-armed only when the ladder step changes, because
    led_blink_set() restarts the software blink timer and truncates the
    phase in progress, which shows up as an irregular cadence. For the same
    reason set_baseline_state() now clears the armed step and schedules the
    work whenever a rate threshold is set: it runs after every netdev
    notifier event and every mode or device_name write, both of which
    cancel the work first, and it only rescheduled the work when a tx/rx
    bit was set. Without this, rate mode stopped for good on a link-only
    LED after a carrier change, and with tx/rx set the LED stayed solid
    under load because the freshly computed step still equalled the armed
    one.
  * rate mode ignores the tx/rx mode bits on purpose - requiring them would
    restore the blindness that motivates the attribute, because on the
    ports where byte-rate mode is useful the packet counters do not see the
    flow. Side effect, measured rather than assumed: LEDs configured
    link=1 tx=0 rx=0 also blink in rate mode. Gating on (tx | rx) is a
    one-line change if that is preferred.
  * div_u64() is used for the rate so 32-bit architectures link without
    __udivdi3/__aeabi_uldivmod, and the store rejects hw_control LEDs with
    -EINVAL: a hardware-offloaded trigger cannot be rate-gated in software.

Measured on a COMFAST CF-WA350 (QCA9563 + QCA8337, ath79/generic, kernel
6.18.55). The board has six GPIO LEDs in its device tree (green:lan,
red:wan, blue:wlan-5ghz, blue:ext-wan, blue:ext-wlan2g, blue:ext-lan); four
of them are on the netdev trigger and are the ones measured here, the other
two are phy throughput LEDs and are not affected by this attribute.
offloaded=0 on all four, i.e. the software path of the trigger is what
runs: idle with a 94 KiB/s max wire rate over 15 s -> 0 blinks on all four
while the same link flickers in tx/rx mode; intermittent 2.4-8.0 MiB/s
download -> blink density 3.75/s in the windows whose measured rate was
above the threshold vs 1.88 in the windows below it; threshold swept over
an impossible, the test and a low value under the same load -> 0 / 38 / 39
blinks, which is the single-variable causality check; and 25 of 25 sampled
blinks matched the ladder step predicted from the measured rate.

Upstream: intended for linux-leds.

Tested on COMFAST CF-WA350 (QCA9563 + QCA8337N), OpenWrt master baf6e53,
image run openwrt#17 (build-cf-wa350-full): link-flap under load re-arms rate mode
on all four netdev LEDs (VERDICT-LINKFLAP: PASS), no regression on the S2 battery.

Signed-off-by: Salah Ahmed <[email protected]>
haddad2inc added a commit to haddad2inc/openwrt that referenced this pull request Oct 11, 2026
Add 835-leds-trigger-netdev-add-byte-rate-threshold-mode.patch
(pending-6.18, 8xx = other drivers, next to 834-ledtrig-libata).

The netdev trigger blinks per packet counted by the netdev. On a DSA user
port that is blind in both directions at once: hardware-forwarded traffic
is not counted at all, while background broadcast and management noise is
counted and makes the LED flicker on an otherwise idle link. The result is
an LED that sits still on a port carrying 80+ Mbit/s and twitches on a port
carrying nothing.

Add a rate_threshold attribute in KiB/s. When non-zero the trigger drives
the LED from the interface byte rate instead, blinking on a 50..150 ms
ladder above the threshold and staying solid on link (or off without
carrier) below it. Writing 0 restores the classic per-packet behaviour, so
the attribute is reversible at runtime.

Design points a reviewer will ask about:

  * The rate is measured over the interval between two observed counter
    changes, not over a fixed window. A driver that refreshes its counters
    in bursts - a cached switch MIB, for instance - would otherwise dump a
    whole accumulation period into the first fixed window after the
    refresh, reporting a rate several times too high and then zero until
    the next refresh. Measuring between changes makes the trigger
    independent of the provider's refresh interval, and the last measured
    rate is held until the counter has been silent for twice the interval
    it was measured over (capped at 10 s). A decreasing counter re-anchors
    the measurement instead of reporting an enormous unsigned difference.
  * The measured rate is smoothed the way field-accepted userspace activity
    daemons do it - immediate attack at or above the threshold, a slow rise
    and a quick release below it - and when the counter goes silent the
    blink fades out quadratically from the last peak over 20 s, with the
    ladder step only ever slowing during the fade.
  * The blink is re-armed only when the ladder step changes, because
    led_blink_set() restarts the software blink timer and truncates the
    phase in progress, which shows up as an irregular cadence. For the same
    reason set_baseline_state() now clears the armed step and schedules the
    work whenever a rate threshold is set: it runs after every netdev
    notifier event and every mode or device_name write, both of which
    cancel the work first, and it only rescheduled the work when a tx/rx
    bit was set. Without this, rate mode stopped for good on a link-only
    LED after a carrier change, and with tx/rx set the LED stayed solid
    under load because the freshly computed step still equalled the armed
    one.
  * rate mode ignores the tx/rx mode bits on purpose - requiring them would
    restore the blindness that motivates the attribute, because on the
    ports where byte-rate mode is useful the packet counters do not see the
    flow. Side effect, measured rather than assumed: LEDs configured
    link=1 tx=0 rx=0 also blink in rate mode. Gating on (tx | rx) is a
    one-line change if that is preferred.
  * div_u64() is used for the rate so 32-bit architectures link without
    __udivdi3/__aeabi_uldivmod, and the store rejects hw_control LEDs with
    -EINVAL: a hardware-offloaded trigger cannot be rate-gated in software.

Measured on a COMFAST CF-WA350 (QCA9563 + QCA8337, ath79/generic, kernel
6.18.55). The board has six GPIO LEDs in its device tree (green:lan,
red:wan, blue:wlan-5ghz, blue:ext-wan, blue:ext-wlan2g, blue:ext-lan); four
of them are on the netdev trigger and are the ones measured here, the other
two are phy throughput LEDs and are not affected by this attribute.
offloaded=0 on all four, i.e. the software path of the trigger is what
runs: idle with a 94 KiB/s max wire rate over 15 s -> 0 blinks on all four
while the same link flickers in tx/rx mode; intermittent 2.4-8.0 MiB/s
download -> blink density 3.75/s in the windows whose measured rate was
above the threshold vs 1.88 in the windows below it; threshold swept over
an impossible, the test and a low value under the same load -> 0 / 38 / 39
blinks, which is the single-variable causality check; and 25 of 25 sampled
blinks matched the ladder step predicted from the measured rate.

Upstream: intended for linux-leds.

Tested on COMFAST CF-WA350 (QCA9563 + QCA8337N), OpenWrt master baf6e53,
image run openwrt#17 (build-cf-wa350-full): link-flap under load re-arms rate mode
on all four netdev LEDs (VERDICT-LINKFLAP: PASS), no regression on the S2 battery.

Signed-off-by: Salah Ahmed <[email protected]>
ShorterKing added a commit to ShorterKing/openwrt that referenced this pull request Nov 25, 2026
The Nokia G-140W-C is a GPON ONT with four gigabit LAN ports and
dual-band Wi-Fi, which ISPs in India such as ACT Fibernet and Tata Play
Fiber supply.

Hardware:
 - SoC: EcoNet EN7526G (EN751221 family), MIPS 34Kc, 2 threads, 900 MHz
 - RAM: 512 MiB DDR3 (Linux can use the first 0x1b800000 bytes)
 - Flash: 256 MiB SPI-NAND (Winbond W25M02GV or Toshiba TC58CVG1S3H)
   with the vendor BMT
 - Ethernet: 4x 1 GbE on ports 1-4 of the MT7530 module in the SoC,
   linked over TRGMII to the on-die switch
 - Wi-Fi 2.4 GHz: MT7592 (mt7603), 2x2 802.11n, on PCIe RC0
 - Wi-Fi 5 GHz: MT7612E (mt76x2), 2x2 802.11ac, on PCIe RC1
 - USB: 2 ports (xHCI)
 - LEDs: power, PON, LOS, Internet, phone and USB on GPIOs; 2.4 GHz
   WLAN on the MT7592 LED pin
 - Buttons: reset (GPIO 0), LED on/off (GPIO 5)
 - Serial: 3-pin header at the board edge next to the USB ports. From
   the pin marked with an arrow: TX, RX, GND. 3.3 V, 115200 8N1
 - Power: 12 V DC, 1.5 A

Not supported: GPON and VoIP (closed vendor drivers).

MAC addresses, from the base address at 0x3e in the "ri" partition
(the value the stock ritool reports as MACAddress):
 - LAN: base
 - WAN: base + 1
 - 2.4 GHz: base + 9
 - 5 GHz: base + 0xd

The flash layout and bootloader match the Nokia G-240G-E. OpenWrt goes
into firmware slot A ("tclinux"): a 4 MiB TRX kernel followed by UBI.
Stock stays in slot B, and en75_chboot switches between them. LAN4 is
the WAN port.

Unlike on the G-240G-E, the bootloader loads its second stage (the
"bootram", with the bldr> prompt) from the slot it boots: an LZMA blob
after the kernel and rootfs in the slot's TRX, whose length is in the
TRX header. Without it the bootloader crashes and only falls back to
the other slot after nine failed boots. The bootram is Nokia's code, so
the image doesn't carry it: sysupgrade copies it from the router, from
slot A or else from the stock firmware in slot B, puts it at 0x3e0000
after the kernel and updates the TRX header to match. The image check
fails if no bootram can be found.

The bootloader also counts boots in the "flag" partition and switches
to the other slot when the count reaches nine. Stock clears it once it
has booted, and an init script does the same for OpenWrt.

The Wi-Fi calibration, a 512-byte EEPROM table per radio, exists only
as two files in the stock settings, on the UBIFS volume of the "config"
partition; the radios' efuses are nearly empty. sysupgrade copies the
tables into a static UBI volume, "calibration", next to the root
filesystem, and the device tree passes them to mt76 as NVMEM cells. To
read them it attaches the stock UBI, which is read-only in the device
tree, and mounts it read-only. The volume has to exist before
rootfs_data, which takes all the free space: if it is missing,
rootfs_data is removed first, since nand_do_upgrade recreates it.

Slot A has no BMT remapping. With it, a read error in old stock data
makes the BMT driver remap the block, and the bootloader redoes such a
remap on every boot once UBI has erased the replacement block, wiping
UBI data. Test images had remapped blocks 36-58 of the reference unit
that way, so UBI starts at block 59.

GRO is off on the switch ports by default. econet-eth has no checksum or
scatter-gather offload, so the CPU would split and checksum every merged
packet again before forwarding it: downloads through the device ran at
97 Mbit/s with GRO and 111 Mbit/s without.

Installation, over the serial console:
 1. Connect a PC to LAN1, LAN2 or LAN3 and leave LAN4 (WAN) unplugged.
 2. Power on the router and press any key within 1 second to get the
    bldr> prompt. On some ISP units the prompt is password-protected,
    and the ISP has to provide the password.
 3. Run "xmdm 80020000 <image size in hex>" and send
    openwrt-econet-en751221-nokia_g140w-c-initramfs-kernel.bin with
    XMODEM-CRC right away (it takes about 18 minutes), then run
    "jump 80020000".
 4. OpenWrt comes up at 192.168.1.1. Back up the partitions, for
    example with "cat /dev/mtdN" over SSH.
 5. Copy openwrt-econet-en751221-nokia_g140w-c-squashfs-sysupgrade.bin
    to /tmp and run "sysupgrade -n" with it. Before writing, it copies
    the bootram and the Wi-Fi calibration from the router and selects
    slot A with en75_chboot.
There is no factory image, since slot A needs the bootram, which only
the router has.

Reverting to stock: "en75_chboot factory; reboot" boots the stock
firmware from slot B with its old settings. To return, boot the
initramfs image as above and run "en75_chboot openwrt" and power-cycle,
or run sysupgrade again.

Tested on two G-140W-C units. With the DSA support from the commits
before this one, from a RAM-booted image (an earlier version of it on
the first unit):
 - first unit: a client on LAN1 and LAN4 as WAN with DHCP, the WAN
   LEDs, routing a 100 Mbit/s line at full speed, and 50 reloads of the
   switch drivers, each followed by a clean TRGMII link
 - second unit: a client on LAN1 and LAN4 as WAN with DHCP, TCP from
   the device to the client at 177 Mbit/s, and 10 reloads of the switch
   drivers with all TRGMII lanes calibrated each time and no CRC errors
   or drops on the CPU port
The full-speed routing needs the RX alignment change in econet_eth PR
openwrt#17: without it, emulated unaligned header accesses limit routing to
about 60 Mbit/s.

The second unit then ran it installed in slot A, with econet_eth PR openwrt#17,
512 RX descriptors and the interrupt fix from OpenWrt PR openwrt#26744 on top,
after a sysupgrade -n from the earlier setup below: it booted from flash
with the same TRGMII calibration and routed for an hour with no new
kernel warnings and no CRC errors or drops on the CPU port.

Before that, with the same device support on an earlier switch driver
setup, installed in slot A: Wi-Fi on both bands, both USB ports (storage
and Android tethering), booting from flash with settings kept across
reboots and the boot count cleared on each boot, sysupgrade of the
installed system with settings kept, switching to stock with en75_chboot
factory and back, and a sysupgrade from the RAM-booted initramfs that
created the calibration volume, after which both radios used the same
calibration as with the tables in the device tree. On the second unit,
which had never run OpenWrt, that install went the same way from its
stock firmware in slot A.

Signed-off-by: Akshat Singh <[email protected]>
ShorterKing added a commit to ShorterKing/openwrt that referenced this pull request Nov 25, 2026
The Nokia G-140W-C is a GPON ONT with four gigabit LAN ports and
dual-band Wi-Fi, which ISPs in India such as ACT Fibernet and Tata Play
Fiber supply.

Hardware:
 - SoC: EcoNet EN7526G (EN751221 family), MIPS 34Kc, 2 threads, 900 MHz
 - RAM: 512 MiB DDR3 (Linux can use the first 0x1b800000 bytes)
 - Flash: 256 MiB SPI-NAND (Winbond W25M02GV or Toshiba TC58CVG1S3H)
   with the vendor BMT
 - Ethernet: 4x 1 GbE on ports 1-4 of the MT7530 module in the SoC,
   linked over TRGMII to the on-die switch
 - Wi-Fi 2.4 GHz: MT7592 (mt7603), 2x2 802.11n, on PCIe RC0
 - Wi-Fi 5 GHz: MT7612E (mt76x2), 2x2 802.11ac, on PCIe RC1
 - USB: 2 ports (xHCI)
 - LEDs: power, PON, LOS, Internet, phone and USB on GPIOs; 2.4 GHz
   WLAN on the MT7592 LED pin
 - Buttons: reset (GPIO 0), LED on/off (GPIO 5)
 - Serial: 3-pin header at the board edge next to the USB ports. From
   the pin marked with an arrow: TX, RX, GND. 3.3 V, 115200 8N1
 - Power: 12 V DC, 1.5 A

Not supported: GPON and VoIP (closed vendor drivers).

MAC addresses, from the base address at 0x3e in the "ri" partition
(the value the stock ritool reports as MACAddress):
 - LAN: base
 - WAN: base + 1
 - 2.4 GHz: base + 9
 - 5 GHz: base + 0xd

The flash layout and bootloader match the Nokia G-240G-E. OpenWrt goes
into firmware slot A ("tclinux"): a 4 MiB TRX kernel followed by UBI.
Stock stays in slot B, and en75_chboot switches between them. LAN4 is
the WAN port.

Unlike on the G-240G-E, the bootloader loads its second stage (the
"bootram", with the bldr> prompt) from the slot it boots: an LZMA blob
after the kernel and rootfs in the slot's TRX, whose length is in the
TRX header. Without it the bootloader crashes and only falls back to
the other slot after nine failed boots. The bootram is Nokia's code, so
the image doesn't carry it: sysupgrade copies it from the router, from
slot A or else from the stock firmware in slot B, puts it at 0x3e0000
after the kernel and updates the TRX header to match. The image check
fails if no bootram can be found.

The bootloader also counts boots in the "flag" partition and switches
to the other slot when the count reaches nine. Stock clears it once it
has booted, and an init script does the same for OpenWrt.

The Wi-Fi calibration, a 512-byte EEPROM table per radio, exists only
as two files in the stock settings, on the UBIFS volume of the "config"
partition; the radios' efuses are nearly empty. sysupgrade copies the
tables into a static UBI volume, "calibration", next to the root
filesystem, and the device tree passes them to mt76 as NVMEM cells. To
read them it attaches the stock UBI, which is read-only in the device
tree, and mounts it read-only. The volume has to exist before
rootfs_data, which takes all the free space: if it is missing,
rootfs_data is removed first, since nand_do_upgrade recreates it.

Slot A has no BMT remapping. With it, a read error in old stock data
makes the BMT driver remap the block, and the bootloader redoes such a
remap on every boot once UBI has erased the replacement block, wiping
UBI data. Test images had remapped blocks 36-58 of the reference unit
that way, so UBI starts at block 59.

GRO is off on the switch ports by default. econet-eth has no checksum or
scatter-gather offload, so the CPU would split and checksum every merged
packet again before forwarding it: downloads through the device ran at
97 Mbit/s with GRO and 111 Mbit/s without.

Installation, over the serial console:
 1. Connect a PC to LAN1, LAN2 or LAN3 and leave LAN4 (WAN) unplugged.
 2. Power on the router and press any key within 1 second to get the
    bldr> prompt. On some ISP units the prompt is password-protected,
    and the ISP has to provide the password.
 3. Run "xmdm 80020000 <image size in hex>" and send
    openwrt-econet-en751221-nokia_g140w-c-initramfs-kernel.bin with
    XMODEM-CRC right away (it takes about 18 minutes), then run
    "jump 80020000".
 4. OpenWrt comes up at 192.168.1.1. Back up the partitions, for
    example with "cat /dev/mtdN" over SSH.
 5. Copy openwrt-econet-en751221-nokia_g140w-c-squashfs-sysupgrade.bin
    to /tmp and run "sysupgrade -n" with it. Before writing, it copies
    the bootram and the Wi-Fi calibration from the router and selects
    slot A with en75_chboot.
There is no factory image, since slot A needs the bootram, which only
the router has.

Reverting to stock: "en75_chboot factory; reboot" boots the stock
firmware from slot B with its old settings. To return, boot the
initramfs image as above and run "en75_chboot openwrt" and power-cycle,
or run sysupgrade again.

Tested on two G-140W-C units. With the DSA support from the commits
before this one, from a RAM-booted image (an earlier version of it on
the first unit):
 - first unit: a client on LAN1 and LAN4 as WAN with DHCP, the WAN
   LEDs, routing a 100 Mbit/s line at full speed, and 50 reloads of the
   switch drivers, each followed by a clean TRGMII link
 - second unit: a client on LAN1 and LAN4 as WAN with DHCP, TCP from
   the device to the client at 177 Mbit/s, and 10 reloads of the switch
   drivers with all TRGMII lanes calibrated each time and no CRC errors
   or drops on the CPU port
The full-speed routing needs the RX alignment change in econet_eth PR
openwrt#17: without it, emulated unaligned header accesses limit routing to
about 60 Mbit/s.

The second unit then ran it installed in slot A, with econet_eth PR openwrt#17,
512 RX descriptors and the interrupt fix from OpenWrt PR openwrt#26744 on top,
after a sysupgrade -n from the earlier setup below: it booted from flash
with the same TRGMII calibration and routed for an hour with no new
kernel warnings and no CRC errors or drops on the CPU port.

Before that, with the same device support on an earlier switch driver
setup, installed in slot A: Wi-Fi on both bands, both USB ports (storage
and Android tethering), booting from flash with settings kept across
reboots and the boot count cleared on each boot, sysupgrade of the
installed system with settings kept, switching to stock with en75_chboot
factory and back, and a sysupgrade from the RAM-booted initramfs that
created the calibration volume, after which both radios used the same
calibration as with the tables in the device tree. On the second unit,
which had never run OpenWrt, that install went the same way from its
stock firmware in slot A.

Signed-off-by: Akshat Singh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants