The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=9b4585afd31384573fcebd156d0e4af32bcddf9e
commit 9b4585afd31384573fcebd156d0e4af32bcddf9e Author: Nick Price <[email protected]> AuthorDate: 2026-07-19 16:41:37 +0000 Commit: Adrian Chadd <[email protected]> CommitDate: 2026-07-19 16:41:37 +0000 aq(4): honor the kernel RSS policy and add a TX traffic-class helper Align RX steering with the kernel RSS framework and factor out the active-traffic-class count. RSS key and indirection table: on an options RSS kernel the stack owns a canonical hash key and a hash-to-bucket indirection table binding each bucket to a CPU. aq programmed a random arc4rand() key and a plain i % rss_qs table, so the hash it stamped in iri_flowid and the queue it steered a flow to did not match the CPU the stack chose -- defeating RSS affinity. Under #ifdef RSS take the key from rss_getkey() and each entry from rss_get_indirection_to_bucket(), as e1000/ixgbe/ixl do; the non-RSS build keeps the random key and round-robin table. RSS hash-type policy: drop the private hw.aq.enable_rss_udp knob (RDTUN, default on) and add aq_rss_hashconfig(), which under options RSS returns rss_gethashconfig() and otherwise the same UDP-off default. UDP 4-tuple hashing scatters a fragmented datagram's pieces across queues because only the first fragment carries the L4 ports, so it is now off by default and re-enabled the standard way, via net.inet.rss.udp_4tuple, matching ix/ixl/mlx5. On Atlantic 1 the UDP-off action stays the existing L3L4 flow-filter workaround; only its policy source changes. TX traffic-class helper: factor the active-TC count (one per active 8-ring group, capped at HW_ATL_B0_TCS_MAX) out of aq_hw_qos_set() into aq_hw_active_tcs(), so there is a single definition of the policy; the Atlantic 2 RSS redirection table reuses it. Reviewed by: adrian Differential Revision: https://reviews.freebsd.org/D58137 --- sys/dev/aq/aq_hw.c | 14 ++++++++++++-- sys/dev/aq/aq_hw.h | 1 + sys/dev/aq/aq_main.c | 36 +++++++++++++++++++++++------------- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/sys/dev/aq/aq_hw.c b/sys/dev/aq/aq_hw.c index 1ad9d2e15ed7..e610f8b27ba7 100644 --- a/sys/dev/aq/aq_hw.c +++ b/sys/dev/aq/aq_hw.c @@ -46,6 +46,7 @@ #define AQ_HW_FW_SM_RAM 0x2U #define AQ_CFG_FW_MIN_VER_EXPECTED 0x01050006U +static uint32_t aq_hw_active_tcs(struct aq_hw *hw); int aq_hw_err_from_flags(struct aq_hw *hw) @@ -406,8 +407,7 @@ aq_hw_qos_set(struct aq_hw *hw) tps_tx_pkt_shed_data_arb_mode_set(hw, 0U); /* One TC per active 8-ring group; share the buffer across them. */ - n_tcs = howmany(hw->tx_rings_count, HW_ATL_B0_RINGS_PER_TC); - n_tcs = MIN(MAX(n_tcs, 1U), HW_ATL_B0_TCS_MAX); + n_tcs = aq_hw_active_tcs(hw); buff_size = AQ_HW_TXBUF_MAX / n_tcs; for (tc = 0; tc < n_tcs; tc++) { @@ -442,6 +442,16 @@ aq_hw_qos_set(struct aq_hw *hw) return (err); } +/* Tx traffic classes currently provisioned (one per active 8-ring group). */ +static uint32_t +aq_hw_active_tcs(struct aq_hw *hw) +{ + uint32_t n = howmany(MAX(hw->tx_rings_count, 1U), + HW_ATL_B0_RINGS_PER_TC); + + return (MIN(n, HW_ATL_B0_TCS_MAX)); +} + static int aq_hw_offload_set(struct aq_hw *hw) { diff --git a/sys/dev/aq/aq_hw.h b/sys/dev/aq/aq_hw.h index 339c7cb7bea0..0619910d012c 100644 --- a/sys/dev/aq/aq_hw.h +++ b/sys/dev/aq/aq_hw.h @@ -370,5 +370,6 @@ int aq_hw_rss_hash_set(struct aq_hw *hw, uint8_t rss_key[HW_ATL_RSS_HASHKEY_SIZE int aq_hw_rss_hash_get(struct aq_hw *hw, uint8_t rss_key[HW_ATL_RSS_HASHKEY_SIZE]); int aq_hw_rss_set(struct aq_hw *hw, uint8_t rss_table[HW_ATL_RSS_INDIRECTION_TABLE_MAX]); int aq_hw_udp_rss_enable(struct aq_hw *hw, bool enable); +u_int aq_rss_hashconfig(void); #endif // _AQ_HW_H_ diff --git a/sys/dev/aq/aq_main.c b/sys/dev/aq/aq_main.c index 5d2d9061c548..4c06447b55d3 100644 --- a/sys/dev/aq/aq_main.c +++ b/sys/dev/aq/aq_main.c @@ -286,15 +286,18 @@ static struct if_shared_ctx aq_sctx_init = { .isc_ntxd_default = {PAGE_SIZE / sizeof(volatile union aq_txc_desc) * 4}, }; -/* - * TUNEABLE PARAMETERS: - */ - -static SYSCTL_NODE(_hw, OID_AUTO, aq, CTLFLAG_RD, 0, "Atlantic driver parameters"); -/* UDP Receive-Side Scaling */ -static int aq_enable_rss_udp = 1; -SYSCTL_INT(_hw_aq, OID_AUTO, enable_rss_udp, CTLFLAG_RDTUN, &aq_enable_rss_udp, - 0, "Enable Receive-Side Scaling (RSS) for UDP"); +/* RSS hash types; honor the kernel policy (UDP 4-tuple off by default). */ +u_int +aq_rss_hashconfig(void) +{ +#ifdef RSS + return (rss_gethashconfig()); +#else + return (RSS_HASHTYPE_RSS_IPV4 | RSS_HASHTYPE_RSS_TCP_IPV4 | + RSS_HASHTYPE_RSS_IPV6 | RSS_HASHTYPE_RSS_TCP_IPV6 | + RSS_HASHTYPE_RSS_IPV6_EX | RSS_HASHTYPE_RSS_TCP_IPV6_EX); +#endif +} /* @@ -450,11 +453,16 @@ aq_if_attach_post(if_ctx_t ctx) aq_add_stats_sysctls(softc); /* RSS */ - arc4rand(softc->rss_key, HW_ATL_RSS_HASHKEY_SIZE, 0); uint32_t rss_qs = MIN(softc->rx_rings_count, HW_ATL_RSS_INDIRECTION_QUEUES_MAX); - for (int i = nitems(softc->rss_table); i--;){ +#ifdef RSS + rss_getkey(softc->rss_key); + for (int i = nitems(softc->rss_table); i--;) + softc->rss_table[i] = rss_get_indirection_to_bucket(i) % rss_qs; +#else + arc4rand(softc->rss_key, HW_ATL_RSS_HASHKEY_SIZE, 0); + for (int i = nitems(softc->rss_table); i--;) softc->rss_table[i] = i % rss_qs; - } +#endif exit: AQ_DBG_EXIT(rc); return (rc); @@ -738,7 +746,9 @@ aq_if_init(if_ctx_t ctx) aq_if_enable_intr(ctx); aq_hw_rss_hash_set(&softc->hw, softc->rss_key); aq_hw_rss_set(&softc->hw, softc->rss_table); - aq_hw_udp_rss_enable(hw, aq_enable_rss_udp); + aq_hw_udp_rss_enable(hw, (aq_rss_hashconfig() & + (RSS_HASHTYPE_RSS_UDP_IPV4 | RSS_HASHTYPE_RSS_UDP_IPV6 | + RSS_HASHTYPE_RSS_UDP_IPV6_EX)) != 0); aq_hw_set_link_speed(hw, hw->link_rate); /* iflib does not replay filter state after init; aq_hw_init() clears it. */
