From: sashiko-bot@kernel.org
To: "Meghana Malladi" <m-malladi@ti.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v2 2/2] net: ti: icssg-prueth: Add ethtool RX flow classification support
Date: Fri, 04 Dec 2026 12:44:46 +0000 [thread overview]
Message-ID: <sashiko-outbox-249831@kernel.org> (raw)
In-Reply-To: <20261203121447.2605779-3-m-malladi@ti.com>
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 <m-malladi@ti.com>
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/net/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 = 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 = 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 — it would steal all
> + * host traffic away from classifier 0.
> + */
> + val = 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 = 0, so RX_CLASS_OR_EN evaluates (BC || DA_P || FT3) rather than
((BC || DA_P) && FT3). Installing any rule targeting queue n >= 1 therefore
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 = emac->prueth;
> + struct regmap *miig_rt = prueth->miig_rt;
> + int slice = 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 = &info->fs;
> + struct prueth *prueth = emac->prueth;
> + struct regmap *miig_rt = prueth->miig_rt;
> + int slice = prueth_emac_slice(emac);
> + struct icssg_rxnfc_rule *rule;
> + int ft3_slot;
> + int ret;
> +
> + if (slice < 0)
> + return -EINVAL;
> +
> + /* Validate rule parameters */
> + ret = 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 != RX_CLS_LOC_ANY) {
> + if (fs->location >= ICSSG_NUM_FT3_SLOTS ||
> + BIT(fs->location) & ICSSG_FT3_RESERVED_SLOTS ||
> + (emac->prueth->is_hsr_offload_mode &&
> + fs->location == 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=0: just count active rules */
> + count++;
> + continue;
> + }
> + if (count >= rule_locs_capacity) {
> + ret = -EMSGSIZE;
> + break;
> + }
> + rule_locs[count++] = 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 = NULL whenever userspace supplies
info.rule_cnt == 0 to ETHTOOL_GRXCLSRLALL. Bypassing the capacity check 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 *ndev,
> {
> struct prueth_emac *emac = netdev_priv(ndev);
>
> - ch->max_rx = 1;
> + ch->max_rx = ICSSG_MAX_RFLOWS;
> ch->max_tx = 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 = true, so all flows
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 = 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 = PRUETH_MAX_RX_FLOWS_SR1 (4) for
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 = 1).
Returning 1 when emac->is_sr1 is set would keep ETHTOOL_GRXRINGS consistent.
[ ... ]
> + case ETHTOOL_GRXCLSRLALL: {
> + u32 rule_cnt = 0;
> +
> + info->data = ICSSG_NUM_FT3_SLOTS | RX_CLS_LOC_SPECIAL;
> + ret = icssg_rxnfc_rule_get_all(emac, rule_locs,
> + info->rule_cnt, &rule_cnt);
> + info->rule_cnt = 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/ethernet/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 = 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 = 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/net/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 = 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 = PRUETH_MAX_RX_FLOWS_SR1 (4) before
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
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203121447.2605779-1-m-malladi@ti.com?part=2
next prev parent reply other threads:[~2026-12-04 12:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 12:14 [PATCH net-next v2 0/2] net: ti: icssg: Multi-flow RX and ethtool RX flow classification Meghana Malladi
2026-12-03 12:14 ` [PATCH net-next v2 1/2] net: ti: icssg-prueth: Add multi-flow RX support with per-flow NAPI Meghana Malladi
2026-12-04 12:44 ` sashiko-bot
2026-12-04 13:25 ` netdev-bot+sashiko
2026-12-03 12:14 ` [PATCH net-next v2 2/2] net: ti: icssg-prueth: Add ethtool RX flow classification support Meghana Malladi
2026-12-04 12:44 ` sashiko-bot [this message]
2026-12-04 13:25 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-249831@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=m-malladi@ti.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox