linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steen Hegelund <steen.hegelund@microchip.com>
To: Casper Andersson <casper.casan@gmail.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	<UNGLinuxDriver@microchip.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	"Wan Jiabing" <wanjiabing@vivo.com>,
	Nathan Huckleberry <nhuck@google.com>,
	<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH net-next v2 7/9] net: microchip: sparx5: Writing rules to the IS2 VCAP
Date: Thu, 20 Oct 2022 11:24:40 +0200	[thread overview]
Message-ID: <85b3993eae5e82860f366c112342527f2018243f.camel@microchip.com> (raw)
In-Reply-To: <20221020074806.ys7lyfkn7f7zpkcp@wse-c0155>

Hi Casper,

On Thu, 2022-10-20 at 09:48 +0200, Casper Andersson wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On 2022-10-19 13:42, Steen Hegelund wrote:
> > +static void vcap_iter_skip_tg(struct vcap_stream_iter *itr)
> > +{
> > +     /* Compensate the field offset for preceding typegroups */
> > +     while (itr->tg->width && itr->offset >= itr->tg->offset) {
> > +             itr->offset += itr->tg->width;
> > +             itr->tg++; /* next typegroup */
> > +     }
> > +}
> 
> It was not immediately obvious to me why it should stop iterating when
> tg->width is zero. But after some digging I saw that the tg iterators
> always ends with an empty element (all bits zero, and therefore width is
> zero). Could this be made clearer? Or maybe this is something common
> that I'm just not used to seeing.

Yes the empty element is just a list terminator, and it just makes the iteration simpler than using
a count which would have been stored in a separate location.
I could add a comment here to clarify this.

> 
> > +static void vcap_encode_bit(u32 *stream, struct vcap_stream_iter *itr, bool val)
> > +{
> > +     /* When intersected by a type group field, stream the type group bits
> > +      * before continuing with the value bit
> > +      */
> > +     while (itr->tg->width &&
> > +            itr->offset >= itr->tg->offset &&
> > +            itr->offset < itr->tg->offset + itr->tg->width) {
> > +             int tg_bitpos = itr->tg->offset - itr->offset;
> > +
> > +             vcap_set_bit(stream, itr, (itr->tg->value >> tg_bitpos) & 0x1);
> > +             itr->offset++;
> > +             vcap_iter_update(itr);
> > +     }
> 
> Same as above.

Yes it also checks for the list terminator.

> 
> > +static void vcap_encode_typegroups(u32 *stream, int sw_width,
> > +                                const struct vcap_typegroup *tg,
> > +                                bool mask)
> > +{
> > +     struct vcap_stream_iter iter;
> > +     int idx;
> > +
> > +     /* Mask bits must be set to zeros (inverted later when writing to the
> > +      * mask cache register), so that the mask typegroup bits consist of
> > +      * match-1 or match-0, or both
> > +      */
> > +     vcap_iter_set(&iter, sw_width, tg, 0);
> > +     while (iter.tg->width) {
> > +             /* Set position to current typegroup bit */
> > +             iter.offset = iter.tg->offset;
> > +             vcap_iter_update(&iter);
> > +             for (idx = 0; idx < iter.tg->width; idx++) {
> > +                     /* Iterate over current typegroup bits. Mask typegroup
> > +                      * bits are always set
> > +                      */
> > +                     if (mask)
> > +                             vcap_set_bit(stream, &iter, 0x1);
> > +                     else
> > +                             vcap_set_bit(stream, &iter,
> > +                                          (iter.tg->value >> idx) & 0x1);
> > +                     iter.offset++;
> > +                     vcap_iter_update(&iter);
> > +             }
> > +             iter.tg++; /* next typegroup */
> > +     }
> 
> Same as above.
Yes same procedure here.

> 
> Tested on Microchip PCB135 switch.
> 
> Tested-by: Casper Andersson <casper.casan@gmail.com>
> Reviewed-by: Casper Andersson <casper.casan@gmail.com>
> 
> Best Regards,
> Casper

Thanks again for the review and the target testing.

BR
Steen


  reply	other threads:[~2022-10-20  9:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19 11:42 [PATCH net-next v2 0/9] Add support for Sparx5 IS2 VCAP Steen Hegelund
2022-10-19 11:42 ` [PATCH net-next v2 1/9] net: microchip: sparx5: Adding initial VCAP API support Steen Hegelund
2022-10-19 11:42 ` [PATCH net-next v2 2/9] net: microchip: sparx5: Adding IS2 VCAP model to VCAP API Steen Hegelund
2022-10-19 11:42 ` [PATCH net-next v2 3/9] net: microchip: sparx5: Adding IS2 VCAP register interface Steen Hegelund
2022-10-19 11:42 ` [PATCH net-next v2 4/9] net: microchip: sparx5: Adding initial tc flower support for VCAP API Steen Hegelund
2022-10-20  7:31   ` Casper Andersson
2022-10-20  9:08     ` Steen Hegelund
2022-10-19 11:42 ` [PATCH net-next v2 5/9] net: microchip: sparx5: Adding port keyset config and callback interface Steen Hegelund
2022-10-20  7:33   ` Casper Andersson
2022-10-20  9:10     ` Steen Hegelund
2022-10-19 11:42 ` [PATCH net-next v2 6/9] net: microchip: sparx5: Adding basic rule management in VCAP API Steen Hegelund
2022-10-20  7:41   ` Casper Andersson
2022-10-20  9:18     ` Steen Hegelund
2022-10-19 11:42 ` [PATCH net-next v2 7/9] net: microchip: sparx5: Writing rules to the IS2 VCAP Steen Hegelund
2022-10-20  7:48   ` Casper Andersson
2022-10-20  9:24     ` Steen Hegelund [this message]
2022-10-19 11:42 ` [PATCH net-next v2 8/9] net: microchip: sparx5: Adding KUNIT test VCAP model Steen Hegelund
2022-10-19 11:42 ` [PATCH net-next v2 9/9] net: microchip: sparx5: Adding KUNIT test for the VCAP API Steen Hegelund

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=85b3993eae5e82860f366c112342527f2018243f.camel@microchip.com \
    --to=steen.hegelund@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=casper.casan@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nhuck@google.com \
    --cc=pabeni@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=wanjiabing@vivo.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;
as well as URLs for NNTP newsgroup(s).