Re: [net-next,v4] net: dsa: mv88e6xxx: Add partial support for TCAM entries
From: Andrew Lunn
Date: Fri Feb 27 2026 - 09:34:19 EST
> > +/* 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?
Can we get replies to previous versions of the patch series included
into the context that the AI is using to perform reviews? This has
been explained once as being safe.
Andrew