lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1c317ed5e3f70b403206e6fdb181c1d0573e8b17.camel@microchip.com>
Date:   Mon, 13 Feb 2023 16:46:59 +0100
From:   Steen Hegelund <steen.hegelund@...rochip.com>
To:     Dan Carpenter <error27@...il.com>
CC:     "David S . Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        <UNGLinuxDriver@...rochip.com>,
        Randy Dunlap <rdunlap@...radead.org>,
        Casper Andersson <casper.casan@...il.com>,
        "Russell King" <rmk+kernel@...linux.org.uk>,
        Wan Jiabing <wanjiabing@...o.com>,
        "Nathan Huckleberry" <nhuck@...gle.com>,
        <linux-kernel@...r.kernel.org>, <netdev@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        "Daniel Machon" <daniel.machon@...rochip.com>,
        Horatiu Vultur <horatiu.vultur@...rochip.com>,
        Lars Povlsen <lars.povlsen@...rochip.com>,
        Michael Walle <michael@...le.cc>
Subject: Re: [PATCH net-next 04/10] net: microchip: sparx5: Use chain ids
 without offsets when enabling rules

Hi Dan,

On Mon, 2023-02-13 at 18:13 +0300, Dan Carpenter wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the
> content is safe
> 
> On Mon, Feb 13, 2023 at 06:07:21PM +0300, Dan Carpenter wrote:
> > On Mon, Feb 13, 2023 at 01:48:50PM +0100, Steen Hegelund wrote:
> > > Hi Dan,
> > > 
> > > On Mon, 2023-02-13 at 14:05 +0300, Dan Carpenter wrote:
> > > > EXTERNAL EMAIL: Do not click links or open attachments unless you know
> > > > the
> > > > content is safe
> > > > 
> > > > On Mon, Feb 13, 2023 at 10:24:20AM +0100, Steen Hegelund wrote:
> > > > > diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c
> > > > > b/drivers/net/ethernet/microchip/vcap/vcap_api.c
> > > > > index 68e04d47f6fd..9ca0cb855c3c 100644
> > > > > --- a/drivers/net/ethernet/microchip/vcap/vcap_api.c
> > > > > +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c
> > > > > @@ -1568,6 +1568,18 @@ static int vcap_write_counter(struct
> > > > > vcap_rule_internal *ri,
> > > > >       return 0;
> > > > >  }
> > > > > 
> > > > > +/* Return the chain id rounded down to nearest lookup */
> > > > > +static int vcap_round_down_chain(int cid)
> > > > > +{
> > > > > +     return cid - (cid % VCAP_CID_LOOKUP_SIZE);
> > > > > +}
> > > > > +
> > > > > +/* Return the chain id rounded up to nearest lookup */
> > > > > +static int vcap_round_up_chain(int cid)
> > > > > +{
> > > > > +     return vcap_round_down_chain(cid + VCAP_CID_LOOKUP_SIZE);
> > > > 
> > > > Just use the round_up/down() macros.
> > > 
> > > The only round up/down macros that I am aware of are:
> > > 
> > >  * round_up - round up to next specified power of 2
> > >  * round_down - round down to next specified power of 2
> > > 
> > > And I cannot use these as the VCAP_CID_LOOKUP_SIZE is not a power of 2.
> > > 
> > > Did I miss something here?
> > > 
> > 
> > Oh wow.  I didn't realize they needed to be a power of 2.  Sorry!
> 
> The correct macros are roundup/down().  Those don't have the power of
> two requirement.

Yep - You are right, these are a bit further down in the math.h file, and I
never noticed them before :-)

I will update my code to use these instead.

> 
> regards,
> dan carpenter
> 

Thanks for the investigation!

BR
Steen

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ