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: <20230315133327.akf4lkdxt67eh3nd@soft-dev3-1>
Date:   Wed, 15 Mar 2023 14:33:27 +0100
From:   'Horatiu Vultur' <horatiu.vultur@...rochip.com>
To:     David Laight <David.Laight@...lab.com>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "edumazet@...gle.com" <edumazet@...gle.com>,
        "kuba@...nel.org" <kuba@...nel.org>,
        "pabeni@...hat.com" <pabeni@...hat.com>,
        "richardcochran@...il.com" <richardcochran@...il.com>,
        "UNGLinuxDriver@...rochip.com" <UNGLinuxDriver@...rochip.com>
Subject: Re: [PATCH net-next 2/2] net: lan966x: Stop using packing library

The 03/13/2023 17:04, David Laight wrote:
> 
> From: Horatiu Vultur
> > Sent: 12 March 2023 20:24
> >
> > When a frame is injected from CPU, it is required to create an IFH(Inter
> > frame header) which sits in front of the frame that is transmitted.
> > This IFH, contains different fields like destination port, to bypass the
> > analyzer, priotity, etc. Lan966x it is using packing library to set and
> > get the fields of this IFH. But this seems to be an expensive
> > operations.
> > If this is changed with a simpler implementation, the RX will be
> > improved with ~5Mbit while on the TX is a much bigger improvement as it
> > is required to set more fields. Below are the numbers for TX.
> ...
> > +static void lan966x_ifh_set(u8 *ifh, size_t val, size_t pos, size_t length)
> > +{
> > +     u32 v = 0;
> > +
> > +     for (int i = 0; i < length ; i++) {
> > +             int j = pos + i;
> > +             int k = j % 8;
> > +
> > +             if (i == 0 || k == 0)
> > +                     v = ifh[IFH_LEN_BYTES - (j / 8) - 1];
> > +
> > +             if (val & (1 << i))
> > +                     v |= (1 << k);
> > +
> > +             if (i == (length - 1) || k == 7)
> > +                     ifh[IFH_LEN_BYTES - (j / 8) - 1] = v;
> > +     }
> > +}
> > +
> 
> It has to be possible to do much better that that.
> Given  that 'pos' and 'length' are always constants it looks like
> each call should reduce to (something like):
>         ifh[k] |= val << n;
>         ifk[k + 1] |= val >> (8 - n);
>         ...
> It might be that the compiler manages to do this, but I doubt it.

Thanks for the review. I will update this in the next version.

Do you think it is worth updating the code in lan966x_ifh_get to use
byte access and not to read each bit individually?
As there is no much improvement on the RX side that is using lan966x_ifh_get.

> 
>         David
> 
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
> 

-- 
/Horatiu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ