Skip to content

SQM and Shaping

Julius Bairaktaris edited this page Jun 21, 2026 · 2 revisions

SQM and Shaping

NSS-accelerated traffic shaping: the kernel/iproute2 pieces, the nss-edma.qos SQM script, and the firmware shaping behaviors that were verified at the firmware level (including the ones that contradict folklore).

Components

  • Kernel patches 0968/0969 (openwrt tree): uapi pkt_cls additions and qdisc support (ifb, sch_api, sch_generic, sk_buff field). ⚠ 0969 adds a bitfield to struct sk_buff: any change to that patch requires wiping the target build_dir and staging_dir so every kmod is rebuilt against the new layout.
  • kmod-qca-nss-drv-qdisc / kmod-qca-nss-drv-igs (feed): the NSS qdiscs (nsstbl, nssfq_codel, …) and the act_nssmirred ingress action. Built with NSS_QDISC_PPE_ENABLE=n — PPE shaper mode and NSS-bridge qdisc attach need qca-ssdk and bridge-mgr, neither of which exists here; the firmware accel mode (accel_mode 0) used for everything below is unaffected.
  • iproute2 patches (openwrt tree): tc parsers for the NSS qdiscs and the nssmirred action.
  • sqm-scripts-nss (feed): ships exactly one queue setup script, nss-edma.qos — flat nsstbl (rate) → nssfq_codel (AQM), egress on the WAN device, ingress via act_nssmirred into an ifb.

Hard rules (violations kill the box or the shaper)

  1. A leaf-less NSS qdisc kills ALL egress on the device, including ARP. Every NSS qdisc setup must pass set_default on a leaf. nss-edma.qos does this unconditionally, by construction.
  2. The firmware refuses shaper nodes on pppoe-wan (node-init timeout; non-destructive but the shaper never comes up). Attach shaping to the physical/ifb interfaces. SQM configured on the logical wan lands on the right netdev by construction.
  3. Boot safety: the script refuses to modprobe the NSS qdisc modules unless qca_nss_drv is already loaded — an SQM config enabled at boot must not drag the firmware up on an unarmed system (that would kill all wired RX; see Runtime Operation). The sqm hotplug then simply retries after the NSS stack is up.

Verified firmware behaviors

  • The 12.5 firmware does not ECN-mark from CoDel. The host plumbing exists end to end (uapi, nss_codel.c, fw ACKs the codel_param.ecn config and exposes an ecn_mark stat), but under forced-ECT(0) traffic and ~1150 CoDel drops, ecn_mark stayed 0. QCA's tc parser rejecting ecn for CoDel is honest. nss-edma.qos ignores the SQM ECN setting with one log line.
  • Queue limit must respect the buffer pools. Firmware queue buffering is roughly 2× the configured limit; on the MEDIUM profile (pbuf pools 9984 + 1736) the script caps the auto queue limit at 2048 packets.
  • Flow-hash quality degrades on encapsulated WANs. nssfq_codel flow dissection over PPPoE/VLAN encapsulation shows a ~27 % new-flow ratio versus ~3 % on a plain ethernet port — per-flow fairness is weaker on a PPPoE WAN; CoDel delay control is unaffected.

sqm-scripts integration gotchas

Two things conspire to leave the shaper down at boot on a PPPoE WAN:

  1. sqm-scripts' hotplug matches on the netdev ($DEVICE, e.g. pppoe-wan), so a uci section keyed interface='wan' never fires from hotplug alone — the bring-up must run /etc/init.d/sqm restart explicitly.
  2. nss-edma.qos's check_addr aborts with no IP on wan (proto=pppoe) if the WAN has no L3 address yet. A sqm restart issued straight after ifup wan loses this race — PPPoE negotiation (PADI…IPCP, plus DHCPv6-PD) outlasts a fixed sleep — and the shaper silently never attaches (no nsstbl on the WAN device → full line rate, no bufferbloat control).

The bring-up therefore waits for pppoe-wan to actually carry an address before starting SQM, then retries sqm restart until nsstbl is attached to the WAN netdev (see Runtime Operation). Verify with tc qdisc show dev <wan> | grep nsstbl.

The SQM section must also be a real per-WAN queue section with download/upload rates — a rate-less section attaches qdiscs that shape nothing and just adds a spurious second start at boot. Provision exactly one queue section for the WAN.

Validated configuration and results

AX3600 on a 300/150 PPPoE line, sqm rates 285000/142500 kbit, nss-edma.qos:

  • 258.6 Mbit/s goodput through the 285 Mbit ingress shaper.
  • RTT under full load 16 ms avg / 31 ms max versus 20/49 idle — i.e. zero bufferbloat (re-validated with correctly-routed probes on both IPv4 and IPv6).
  • CPU ~99.1 % idle during shaped saturation.
  • Shaper authority confirmed: nsstbl overlimits in the tens of thousands while fq_codel (host side) saw single-digit drops — the firmware shaper, not the host, is in charge.
  • A deliberately tight 50/25 test config shaped to 45.2/22.8 Mbit — authority again with the expected overhead margin.
  • sqm stop tears down cleanly; reboot with SQM enabled boots safely on the host stack (the guard logs "refusing to load NSS qdisc modules" and wired RX stays alive).

Clone this wiki locally