From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388287; b=ALRUKy4DGm7HkmIS1C3LDVj9kPosXyp7ThAHbitqCRhQs8igOrd8Kl6lFEgXYS9/KG5V VwUQA7lYsi2bt5Vw2WfSFUUeUj8H6fs3yJ4tu3r89uKFt7YeYkcGUa51UedzkWHXmJ4YN vaNRTrT6GsGNi5+7TbaKgZpZNC+6qE/IcrjAh25q9B37PyTLPKP5B4Dbk8bTi5U5dJ4MY xAP7UomhagN5jeHvl/CeOuDTRqWMoVJErPs/L0bBCqB3IsvZZe4OCgYOkipu5g5buMcdI pkE/URCwnaEHrF1KuhpNO3PGkYMOtY2AI/xKQzVzO0k9WAX/hc09KDbTnJDngaVkdEA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388287; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=+XShaFrEgDwm3gah8ns5hOaYzZhd8JatsuGFOsSV7MU=; b=zReqQ6RrRJJ9C/9K6qBM6md8ORwebZ3n/V/q+lxag09fhx7d5vTaPg4T37OG24lhxPfc 3F6HJNJzpkBM/itKN6kN10qhcLj1+UHisCdnWc5reDUG0fk1/f7xgxkMEhYvkzn3SvUXC PtTPzfWX9+6SmVUrvUUBb38S2qlE093r/B0gE1v8ByoVOBXQTmFUp5zbAXf8t4jgFsV2X Fr7F+TmxU6E+2FDxXYOZGK7zQEsndN8uxPYI3WF1T326bCLShJ/IDoamux9WOHz7WTmJN xyV1z+COUygFLpePjCNyEyBurczSfpWL7ttADSL1CWLq6p3V5JnpOmKAe8qYx3sXEKQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dHMJREuS; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97F7C606A338 for ; Fri, 4 Dec 2026 12:44:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dHMJREuS Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CD191F00936; Fri, 4 Dec 2026 12:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796388287; bh=+XShaFrEgDwm3gah8ns5hOaYzZhd8JatsuGFOsSV7MU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=dHMJREuSxqjfLKSZ6BRyPRJRa5/eQ/QUYVoIo3wR1hQtJ+W3W8MZVoMCzNkaLL3B3 YE8G3ACL8bI3AtoulDef6E4rPeJqoRZBUQEDpIO9YNfzM/3drlGmb74YW5JRZAEXjs RuqEEscF0IhsLaKezkIo/ZORak11fvLtuH1c+o1Anss8hjMPa1VJyIkJwDg3X7KQ2Z 1MuP/GrQvm1QNjshpltKDERNeDoXC7x7QP5d+eb1V1Zcrf1k3cY8QcY3QtTfnGl1pN WypCyn4zIwgASM83mzPkdKZhWijOR7OLa8oa75ptH6j5qI8V7PGf2BUVW2lTtFqBEo yLqNi/wdZS+jA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next v2 2/2] net: ti: icssg-prueth: Add ethtool RX flow classification support Reply-To: sashiko-reviews@lists.linux.dev To: "Meghana Malladi" Cc: bpf@vger.kernel.org In-Reply-To: <20261203121447.2605779-3-m-malladi@ti.com> References: <20261203121447.2605779-1-m-malladi@ti.com> <20261203121447.2605779-3-m-malladi@ti.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 12:44:46 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 13 potential issues to consider: - [High] net: ti: icssg: BC|DA_P in OR_EN steals host traffic in classifiers 1..N - [High] net: ti: icssg-prueth: uncapped multi-flow breaks AM654 shared RX FDQ - [High] net: ti: icssg-prueth: live-channel XSK teardown in prueth_xsk_pool_enable() - [High] net: ti: icssg-prueth: NULL deref of emac->xsk_queues in SR1.0 emac_ndo_open() - [Medium] net: ti: icssg: icssg_rxnfc_rule_restore() restores slot 9 in HSR mode - [Medium] net: ti: icssg: parent commit calls undefined icssg_rxnfc_rule_* helpers - [Medium] net: ti: icssg: big-endian EtherType bug in icssg_ft3_program_filter() - [Medium] net: ti: icssg-prueth: ETHTOOL_GRXCLSRLALL sets RX_CLS_LOC_SPECIAL in data - [Medium] net: ti: icssg-prueth: icssg_rxnfc_rule_get_all() misses EMSGSIZE on empty buf - [Medium] net: ti: icssg-prueth: unbalanced enable_irq() from stale flow->irq_disabled - [Medium] net: ti: icssg-prueth: leak of RX NAPIs and IRQs in SR1.0 emac_ndo_open() - [Low] net: ti: icssg: guard(mutex) used in >20-line functions in icssg_classifier.c - [Low] net: ti: icssg-prueth: emac_get_rx_ring_count() reports 4 rings on SR1 -- commit 41a5974310fc852a53e14b269769284ab4fbcb14 Author: Meghana Malladi net: ti: icssg-prueth: Add ethtool RX flow classification support This commit adds ethtool get_rxnfc/set_rxnfc and get_rx_ring_count support for the TI ICSSG PRUeth driver, using FT3 hardware filters and RX classifier OR tables to steer packets by EtherType to specific RX flows. > diff --git a/drivers/net/ethernet/ti/icssg/icssg_classifier.c b/drivers/n= et/ethernet/ti/icssg/icssg_classifier.c > index 87a8577093dbb..cf664e93d5c3d 100644 > --- a/drivers/net/ethernet/ti/icssg/icssg_classifier.c > +++ b/drivers/net/ethernet/ti/icssg/icssg_classifier.c [ ... ] > + regmap_write(miig_rt, FT3_N_REG(slice, slot, FT3_T), > + (__force u32)ether_type); [Severity: Medium] Does casting __be16 ether_type directly to u32 break EtherType matching on big-endian kernels? regmap_write() takes a CPU-order value, so FT3_T expects the wire bytes swapped into host order (as icssg_ft3_hsr_configurations() does with FT3_PTP_PATTERN =3D 0xF788 for PTP 0x88F7). On big-endian ARM64 (ARCH_K3), (__force u32)ether_type writes 0x88F7 instead of 0xF788 and inverts the pattern. Using swab16(be16_to_cpu(ether_type)) works on both endiannesses without a __force cast. [ ... ] > + } else if (or_table[n]) { > + /* Classifiers 1..N with active rules: add BC|DA_P so > + * only host-addressed frames are steered. > + */ > + val =3D RX_CLASS_FT_BC | RX_CLASS_FT_DA_P | or_table[n]; > + } else { > + /* Classifiers 1..N with no rules: clear entirely. > + * Must not leave BC|DA_P here =E2=80=94 it would steal all > + * host traffic away from classifier 0. > + */ > + val =3D 0; > + } > + regmap_write(miig_rt, RX_CLASS_N_REG(slice, n, RX_CLASS_OR_EN), val); [Severity: High] Doesn't setting RX_CLASS_FT_BC | RX_CLASS_FT_DA_P in RX_CLASS_OR_EN for classifiers 1..N steal all host broadcast and unicast traffic away from classifier 0? icssg_class_disable() leaves classifiers 1..15 in RX_CLASS_SEL_TYPE_OR mode with AND_EN =3D 0, so RX_CLASS_OR_EN evaluates (BC || DA_P || FT3) rather t= han ((BC || DA_P) && FT3). Installing any rule targeting queue n >=3D 1 theref= ore steers every broadcast and host-unicast frame to queue n regardless of EtherType, while still accepting foreign-MAC frames matching the FT3 slot. [ ... ] > +/* Initialize RX flow classification */ > +void icssg_rxnfc_rule_init(struct prueth_emac *emac) [Severity: Medium] Does the preceding commit "net: ti: icssg-prueth: Add multi-flow RX support with per-flow NAPI" fail to link because it calls icssg_rxnfc_rule_init(), icssg_rxnfc_rule_restore(), and icssg_rxnfc_rule_cleanup() before this commit defines them? Moving those declarations and call sites into this commit would keep the series bisectable. [ ... ] > +void icssg_rxnfc_rule_restore(struct prueth_emac *emac) > +{ > + struct prueth *prueth =3D emac->prueth; > + struct regmap *miig_rt =3D prueth->miig_rt; > + int slice =3D prueth_emac_slice(emac); > + struct icssg_rxnfc_rule *rule; > + > + if (slice < 0) > + return; > + > + guard(mutex)(&emac->rxnfc.rxnfc_lock); > + > + list_for_each_entry(rule, &emac->rxnfc.rules, list) > + icssg_ft3_program_filter(miig_rt, slice, rule->ft3_slot, rule); > + > + icssg_rxnfc_classifier_update(emac); > +} [Severity: Medium] Can icssg_rxnfc_rule_restore() reprogram a pre-existing rule into FT3 slot 9 after HSR offload mode is enabled? Slot 9 is only reserved in allocate_ft3_slot() and icssg_rxnfc_rule_add() when is_hsr_offload_mode is already true. If a user installs a rule in slot 9 in EMAC mode and later transitions to HSR offload via prueth_hsr_port_link() -> icssg_change_mode() -> prueth_emac_restart(), prueth_emac_common_start() configures classifier 10 with RX_CLASS_OR_DUP_PTP (bit 9 set) and icssg_rxnfc_rule_restore() then restores slot 9, causing that rule's EtherType to falsely trigger classifier 10. [ ... ] > +/* Add a new RX flow classification rule */ > +int icssg_rxnfc_rule_add(struct prueth_emac *emac, struct ethtool_rxnfc = *info) > +{ > + struct ethtool_rx_flow_spec *fs =3D &info->fs; > + struct prueth *prueth =3D emac->prueth; > + struct regmap *miig_rt =3D prueth->miig_rt; > + int slice =3D prueth_emac_slice(emac); > + struct icssg_rxnfc_rule *rule; > + int ft3_slot; > + int ret; > + > + if (slice < 0) > + return -EINVAL; > + > + /* Validate rule parameters */ > + ret =3D validate_rule(emac, fs); > + if (ret) > + return ret; > + > + /* Validate explicit location: reject special specifiers, out-of-range > + * values, and the reserved slot 14 used by HSR/PRP. > + * Bound against ICSSG_NUM_FT3_SLOTS (16), not ICSSG_RXNFC_MAX_RULES > + * (15), so that slot 15 is reachable as an explicit location. > + */ > + if (fs->location !=3D RX_CLS_LOC_ANY) { > + if (fs->location >=3D ICSSG_NUM_FT3_SLOTS || > + BIT(fs->location) & ICSSG_FT3_RESERVED_SLOTS || > + (emac->prueth->is_hsr_offload_mode && > + fs->location =3D=3D FT3_HSR_OR_SLOT)) > + return -EINVAL; > + } > + > + guard(mutex)(&emac->rxnfc.rxnfc_lock); [Severity: Low] As reported by Simon Horman on v1 [1], Documentation/process/maintainer-netdev.rst discourages guard() in functions longer than 20 lines and prefers normal lock/unlock or scoped_guard(). icssg_rxnfc_rule_cleanup(), icssg_rxnfc_rule_add(), icssg_rxnfc_rule_del(), and icssg_rxnfc_rule_get_all() all exceed 20 lines and still use guard(mutex). [ ... ] > + list_for_each_entry(rule, &emac->rxnfc.rules, list) { > + if (!rule_locs) { > + /* Caller passed rule_cnt=3D0: just count active rules */ > + count++; > + continue; > + } > + if (count >=3D rule_locs_capacity) { > + ret =3D -EMSGSIZE; > + break; > + } > + rule_locs[count++] =3D rule->location; > + } [Severity: Medium] Should icssg_rxnfc_rule_get_all() return -EMSGSIZE when rule_locs is NULL and active rules exist? ethtool_get_rxnfc() passes rule_buf =3D NULL whenever userspace supplies info.rule_cnt =3D=3D 0 to ETHTOOL_GRXCLSRLALL. Bypassing the capacity chec= k on !rule_locs returns 0 with a non-zero info->rule_cnt even though no rule locations were written to userspace. > diff --git a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c b/drivers/net/= ethernet/ti/icssg/icssg_ethtool.c > index b715af21d23ac..b74e1a9706e40 100644 > --- a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c > +++ b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c [ ... ] > @@ -159,15 +160,17 @@ static void emac_get_channels(struct net_device *nd= ev, > { > struct prueth_emac *emac =3D netdev_priv(ndev); > =20 > - ch->max_rx =3D 1; > + ch->max_rx =3D ICSSG_MAX_RFLOWS; > ch->max_tx =3D PRUETH_MAX_TX_QUEUES; [Severity: High] In commit "net: ti: icssg-prueth: Add multi-flow RX support with per-flow NAPI", does emac_get_channels() still advertise ICSSG_MAX_RFLOWS on AM654 SR2.0 even though AM654 multi-flow is broken and deferred? On AM654 (UDMAP), k3_udma_glue sets rx_chn->single_fdq =3D true, so all flo= ws share a single 512-entry FDQ ring. Configuring rx_flow_num > 1 overflows the shared FDQ on open when flow 1 pushes descriptors after flow 0 fills it, leaks pages or destroys flows[i].pg_pool prematurely during prueth_create_rxqs() unwind and prueth_destroy_rxqs() teardown, and recycles pages against the wrong flow's page_pool in emac_rx_packet(). Should max_rx be capped to 1 on AM654 until shared-FDQ support is implemented? [ ... ] > +static u32 emac_get_rx_ring_count(struct net_device *ndev) > +{ > + struct prueth_emac *emac =3D netdev_priv(ndev); > + > + return emac->rx_flow_num; > +} [Severity: Low] Does emac_get_rx_ring_count() report 4 RX rings instead of 1 on AM654 SR1.0? icssg_prueth_sr1.c sets emac->rx_flow_num =3D PRUETH_MAX_RX_FLOWS_SR1 (4) f= or internal UDMA flow allocation, even though SR1 only allocates 1 netdev RX queue and enables 1 data flow (and emac_get_channels() reports max_rx =3D 1= ). Returning 1 when emac->is_sr1 is set would keep ETHTOOL_GRXRINGS consistent. [ ... ] > + case ETHTOOL_GRXCLSRLALL: { > + u32 rule_cnt =3D 0; > + > + info->data =3D ICSSG_NUM_FT3_SLOTS | RX_CLS_LOC_SPECIAL; > + ret =3D icssg_rxnfc_rule_get_all(emac, rule_locs, > + info->rule_cnt, &rule_cnt); > + info->rule_cnt =3D rule_cnt; > + break; > + } [Severity: Medium] Should RX_CLS_LOC_SPECIAL be omitted from info->data in the ETHTOOL_GRXCLSRLALL case? Per struct ethtool_rxnfc in include/uapi/linux/ethtool.h, RX_CLS_LOC_SPECIAL is only ORed into data for ETHTOOL_GRXCLSRLCNT. ETHTOOL_GRXCLSRLALL must return only the rule table size (ICSSG_NUM_FT3_SLOTS), otherwise userspace sees 0x80000010 instead of 16. > diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/e= thernet/ti/icssg/icssg_prueth.c > index 9bb67e185a3ea..ecd42abe9a3f9 100644 > --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c > +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c [ ... ] > + napi_enable(&flow->napi_rx); > + /* Re-enable IRQ now that NAPI is live. IRQ may have been left > + * disabled by hrtimer coalescing or a previous destroy_rxq. > + */ > + if (flow->irq_disabled) { > + flow->irq_disabled =3D false; > + enable_irq(flow->irq); > + } [Severity: Medium] In commit "net: ti: icssg-prueth: Add multi-flow RX support with per-flow NAPI", can a stale flow->irq_disabled trigger an unbalanced enable_irq() warning on reopen? If emac_ndo_stop() runs while RX coalescing has flow->rx_hrtimer armed (leaving flow->irq_disabled true), neither prueth_destroy_rxq() nor prueth_ndev_del_rx_napi() clears flow->irq_disabled, and prueth_init_rx_chns() does not reset it on the next emac_ndo_open(). Because request_irq() in prueth_ndev_add_rx_napi() enables the IRQ at depth 0, prueth_create_rxq() then calls enable_irq() on an already-enabled IRQ. [ ... ] > if (netif_running(emac->ndev)) { > /* stop packets from wire for graceful teardown */ > ret =3D icssg_set_port_state(emac, ICSSG_EMAC_PORT_DISABLE); > - if (ret) > + if (ret) { > + xsk_pool_dma_unmap(pool, PRUETH_RX_DMA_ATTR); > return ret; > - prueth_destroy_rxq(emac); > + } > + prueth_destroy_rxq(emac, queue_id); > } [Severity: High] In commit "net: ti: icssg-prueth: Add multi-flow RX support with per-flow NAPI", do prueth_xsk_pool_enable() and prueth_xsk_pool_disable() tear down a single RX flow while the shared UDMA RX channel is still enabled? prueth_destroy_rxq() resets the flow and destroys flow->pg_pool (or unmaps the XSK pool in prueth_xsk_pool_disable()) without calling k3_udma_glue_disable_rx_chn(). Because the live UDMA channel may still hold prefetched FDQ descriptors, this risks DMA use-after-free, page leaks, or page_pool_destroy() stalls when attaching or detaching AF_XDP zero-copy on a running interface. > diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c b/drivers/n= et/ethernet/ti/icssg/icssg_prueth_sr1.c > index 21a14b3bc889b..c166977b424ef 100644 > --- a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c > +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c [ ... ] > + emac->rx_flow_num =3D PRUETH_MAX_RX_FLOWS_SR1; > + > + /* Clear XSK state on open: any pool bound while interface was down > + * is no longer valid. User must re-enable AF_XDP after bringing > + * the interface up. > + */ > + bitmap_zero(emac->xsk_queues, PRUETH_MAX_RX_FLOWS); [Severity: High] In commit "net: ti: icssg-prueth: Add multi-flow RX support with per-flow NAPI", does this bitmap_zero() cause a NULL pointer dereference whenever an SR1.0 interface is opened? Unlike icssg_prueth.c, prueth_netdev_init() in icssg_prueth_sr1.c never allocates emac->xsk_queues, so the pointer is always NULL. [ ... ] > free_rx_irq: > - free_irq(emac->rx_chns.irq[rx_flow], emac); > + prueth_ndev_del_rx_napi(emac, 1); [Severity: Medium] In commit "net: ti: icssg-prueth: Add multi-flow RX support with per-flow NAPI", does this error-unwind path leak 3 of the 4 RX NAPIs and IRQs on SR1.0? emac_ndo_open() sets emac->rx_flow_num =3D PRUETH_MAX_RX_FLOWS_SR1 (4) befo= re calling prueth_ndev_add_rx_napi(), which registers 4 NAPIs and 4 IRQs. Passing 1 instead of PRUETH_MAX_RX_FLOWS_SR1 (as emac_ndo_stop() does) leaks flows 1..3 if a later open step fails, leaving stale NAPI entries on ndev->napi_list and stale IRQ handlers. [1] https://lore.kernel.org/r/20261125113634.GT31322@horms.kernel.org --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203121447.2605= 779-1-m-malladi@ti.com?part=3D2