From: Jakub Kicinski <kuba@kernel.org>
To: cedric.jehasse@luminex.be
Cc: Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com,
edumazet@google.com, davem@davemloft.net, pabeni@redhat.com,
linux@armlinux.org.uk, linux-kernel@vger.kernel.org
Subject: Re: [net-next,v4] net: dsa: mv88e6xxx: Add partial support for TCAM entries
Date: Thu, 26 Feb 2026 19:55:37 -0800 [thread overview]
Message-ID: <20260227035537.2630823-1-kuba@kernel.org> (raw)
In-Reply-To: <20260225-net-next-mv88e6xxx-tcam-v4-1-117f600e41d7@luminex.be>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: dsa: mv88e6xxx: Add partial support for TCAM entries
This patch adds partial Ternary Content Addressable Memory (TCAM)
support for the mv88e6390 and mv88e6393 family of switches. The
implementation introduces matching on IP addresses/protocol with the
ability to trap matched frames to the CPU.
> diff --git a/drivers/net/dsa/mv88e6xxx/tcam.c b/drivers/net/dsa/mv88e6xxx/tcam.c
> new file mode 100644
> index 000000000000..f56cc7e0c00f
> --- /dev/null
> +++ b/drivers/net/dsa/mv88e6xxx/tcam.c
[ ... ]
> +/* insert tcam entry in ordered list and move existing entries if necessary */
> +static int mv88e6xxx_tcam_insert_entry(struct mv88e6xxx_chip *chip,
> + struct mv88e6xxx_tcam_entry *entry)
> +{
> + struct mv88e6xxx_tcam_entry *elem;
> + struct list_head *hpos;
> + int err;
> +
> + list_for_each_prev(hpos, &chip->tcam.entries) {
> + u8 move_idx;
> +
> + elem = list_entry(hpos, struct mv88e6xxx_tcam_entry, list);
> + if (entry->prio >= elem->prio)
> + break;
> +
> + move_idx = elem->hw_idx + 1;
> +
> + err = mv88e6xxx_tcam_flush_entry(chip, move_idx);
> + if (err)
> + return err;
> +
> + err = chip->info->ops->tcam_ops->entry_add(chip, elem,
> + move_idx);
> + if (err)
> + return err;
> +
> + elem->hw_idx = move_idx;
> + }
If entry_add() fails after some entries have already been moved to new
hardware positions with their hw_idx updated, doesn't the function return
without rolling back those partial moves?
The software list would then have some entries pointing to their new
positions while the gap for the new entry is only partially created.
This could leave the TCAM in an inconsistent state for subsequent
operations.
Is there error handling to ensure the TCAM state remains consistent when
insertion partially succeeds?
[ ... ]
> diff --git a/drivers/net/dsa/mv88e6xxx/tcflower.c b/drivers/net/dsa/mv88e6xxx/tcflower.c
> new file mode 100644
> index 000000000000..05b289463834
> --- /dev/null
> +++ b/drivers/net/dsa/mv88e6xxx/tcflower.c
> @@ -0,0 +1,164 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Marvell 88E6xxx Switch flower support
> + *
> + * Copyright (c) 2026 Luminex Network Intelligence
> + */
> +
> +#include "chip.h"
> +#include "tcflower.h"
> +#include "tcam.h"
> +
> +#define MV88E6XXX_ETHTYPE_OFFSET 16
> +#define MV88E6XXX_IP_PROTO_OFFSET 27
> +#define MV88E6XXX_IPV4_SRC_OFFSET 30
> +#define MV88E6XXX_IPV4_DST_OFFSET 34
> +
> +static int mv88e6xx_flower_parse_key(struct mv88e6xxx_chip *chip,
> + struct netlink_ext_ack *extack,
> + struct flow_cls_offload *cls,
> + struct mv88e6xxx_tcam_key *key)
> +{
> + struct flow_rule *rule = flow_cls_offload_flow_rule(cls);
> + struct flow_dissector *dissector = rule->match.dissector;
> + u16 addr_type = 0;
> +
> + if (dissector->used_keys &
> + ~(BIT_ULL(FLOW_DISSECTOR_KEY_BASIC) |
> + BIT_ULL(FLOW_DISSECTOR_KEY_CONTROL) |
> + BIT_ULL(FLOW_DISSECTOR_KEY_IPV4_ADDRS) |
> + BIT_ULL(FLOW_DISSECTOR_KEY_IPV6_ADDRS))) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Unsupported keys used");
> + return -EOPNOTSUPP;
> + }
FLOW_DISSECTOR_KEY_IPV6_ADDRS is included in the allowed keys bitmask,
but there is no code below to parse IPv6 addresses into the TCAM key.
If a user creates a tc flower rule with IPv6 addresses, the rule passes
this validation check but the addresses are never programmed into the
TCAM. This would cause the hardware entry to match broader traffic than
intended.
Looking at the code further down:
> + if (addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) {
> + struct flow_match_ipv4_addrs match;
> +
> + flow_rule_match_ipv4_addrs(cls->rule, &match);
> + mv88e6xxx_tcam_match_set(key, MV88E6XXX_IPV4_SRC_OFFSET,
> + match.key->src,
> + match.mask->src);
> + mv88e6xxx_tcam_match_set(key, MV88E6XXX_IPV4_DST_OFFSET,
> + match.key->dst,
> + match.mask->dst);
> + } else {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Unsupported address type");
> + return -EOPNOTSUPP;
> + }
The check at line 68-72 rejects non-IPv4 address types, but the IPv6 key
is still in the allowed keys bitmask at line 30. This creates a confusing
situation where IPv6 is both 'allowed' and 'unsupported'.
Should FLOW_DISSECTOR_KEY_IPV6_ADDRS be removed from the allowed keys
until IPv6 parsing is implemented?
--
pw-bot: cr
next prev parent reply other threads:[~2026-02-27 3:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 13:37 [PATCH net-next v4] net: dsa: mv88e6xxx: Add partial support for TCAM entries Cedric Jehasse via B4 Relay
2026-02-27 3:55 ` Jakub Kicinski [this message]
2026-02-27 9:44 ` [net-next,v4] " Cedric Jehasse
2026-02-28 1:28 ` Jakub Kicinski
2026-03-02 13:36 ` Cedric Jehasse
2026-03-03 0:13 ` Jakub Kicinski
2026-02-27 14:06 ` Andrew Lunn
2026-02-27 23:55 ` Jakub Kicinski
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=20260227035537.2630823-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew@lunn.ch \
--cc=cedric.jehasse@luminex.be \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
/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