All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Cedric Jehasse <cedric.jehasse@luminex.be>
Cc: "edumazet@google.com" <edumazet@google.com>,
	"andrew@lunn.ch" <andrew@lunn.ch>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"olteanv@gmail.com" <olteanv@gmail.com>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>
Subject: Re: [net-next,v3] net: dsa: mv88e6xxx: Add partial support for TCAM entries
Date: Thu, 26 Feb 2026 12:49:17 +0000	[thread overview]
Message-ID: <aaBBTbABte38y2RA@horms.kernel.org> (raw)
In-Reply-To: <PR3P194MB1505D8407EC0DB476D6A1CD1EA75A@PR3P194MB1505.EURP194.PROD.OUTLOOK.COM>

On Wed, Feb 25, 2026 at 01:06:26PM +0000, Cedric Jehasse wrote:
> Hi,
> 
> >> diff --git a/drivers/net/dsa/mv88e6xxx/tcam.c b/drivers/net/dsa/mv88e6xxx/tcam.c
> >> new file mode 100644
> >> index 000000000000..ed02c8798200
> >> --- /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, leaving the TCAM in an
> >inconsistent state for subsequent operations.
> 
> I don't think this is an issue. For entries that are successfully moved the
> hw_idx points to the new index. And for entries that haven't successfully
> moved it's still pointing to the old index. Hence the hw_idx field for every
> list entry should still point to the correct TCAM index. There will be a gap
> in the TCAM entries in the hardware, but that's not an issue.
> If moving an existing entry returns an error. The rollback moving of entries
> is as likely to return an error, and potentially leave the TCAM in an
> inconsistent state.

Thanks, for the clarification.
That makes sense to me.

      reply	other threads:[~2026-02-26 12:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24  9:24 [PATCH net-next v3] net: dsa: mv88e6xxx: Add partial support for TCAM entries Cedric Jehasse
2026-02-24  9:24 ` Cedric Jehasse via B4 Relay
2026-02-25 10:25 ` [net-next,v3] " Simon Horman
2026-02-25 13:06   ` Cedric Jehasse
2026-02-26 12:49     ` Simon Horman [this message]

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=aaBBTbABte38y2RA@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=cedric.jehasse@luminex.be \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.