mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Horatiu Vultur' <horatiu.vultur@microchip.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"richardcochran@gmail.com" <richardcochran@gmail.com>,
	"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>
Subject: RE: [PATCH net-next 2/2] net: lan966x: Stop using packing library
Date: Mon, 13 Mar 2023 17:04:11 +0000	[thread overview]
Message-ID: <cad1c4aac9ae4047b8ed29b181c908fd@AcuMS.aculab.com> (raw)
In-Reply-To: <20230312202424.1495439-3-horatiu.vultur@microchip.com>

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.

	David

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


  reply	other threads:[~2023-03-13 17:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-12 20:24 [PATCH net-next 0/2] net: lan966x: Improve TX/RX of frames from/to CPU Horatiu Vultur
2023-03-12 20:24 ` [PATCH net-next 1/2] net: lan966x: Don't read RX timestamp if not needed Horatiu Vultur
2023-03-12 20:24 ` [PATCH net-next 2/2] net: lan966x: Stop using packing library Horatiu Vultur
2023-03-13 17:04   ` David Laight [this message]
2023-03-13 22:18     ` Jakub Kicinski
2023-03-15 13:33     ` 'Horatiu Vultur'

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=cad1c4aac9ae4047b8ed29b181c908fd@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.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

all inboxes | Powered by JetHome®