public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Vladimir Oltean <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>
Subject: Re: [PATCH net-next v2 02/10] lib: packing: adjust definitions and implementation for arbitrary buffer lengths
Date: Thu, 3 Oct 2024 18:05:10 +0300	[thread overview]
Message-ID: <20241003150510.w2yhj5ox2tnqdjst@skbuf> (raw)
In-Reply-To: <20241002-packing-kunit-tests-and-split-pack-unpack-v2-2-8373e551eae3@intel.com>

On Wed, Oct 02, 2024 at 02:51:51PM -0700, Jacob Keller wrote:
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> 
> Jacob Keller has a use case for packing() in the intel/ice networking
> driver, but it cannot be used as-is.
> 
> Simply put, the API quirks for LSW32_IS_FIRST and LITTLE_ENDIAN are
> naively implemented with the undocumented assumption that the buffer
> length must be a multiple of 4. All calculations of group offsets and
> offsets of bytes within groups assume that this is the case. But in the
> ice case, this does not hold true. For example, packing into a buffer
> of 22 bytes would yield wrong results, but pretending it was a 24 byte
> buffer would work.
> 
> Rather than requiring such hacks, and leaving a big question mark when
> it comes to discontinuities in the accessible bit fields of such buffer,
> we should extend the packing API to support this use case.
> 
> It turns out that we can keep the design in terms of groups of 4 bytes,
> but also make it work if the total length is not a multiple of 4.
> Just like before, imagine the buffer as a big number, and its most
> significant bytes (the ones that would make up to a multiple of 4) are
> missing. Thus, with a big endian (no quirks) interpretation of the
> buffer, those most significant bytes would be absent from the beginning
> of the buffer, and with a LSW32_IS_FIRST interpretation, they would be
> absent from the end of the buffer. The LITTLE_ENDIAN quirk, in the
> packing() API world, only affects byte ordering within groups of 4.
> Thus, it does not change which bytes are missing. Only the significance
> of the remaining bytes within the (smaller) group.
> 
> No change intended for buffer sizes which are multiples of 4. Tested
> with the sja1105 driver and with downstream unit tests.
> 
> Link: https://lore.kernel.org/netdev/a0338310-e66c-497c-bc1f-a597e50aa3ff@intel.com/
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Tested-by: Jacob Keller <jacob.e.keller@intel.com>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

  reply	other threads:[~2024-10-03 15:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-02 21:51 [PATCH net-next v2 00/10] packing: various improvements and KUnit tests Jacob Keller
2024-10-02 21:51 ` [PATCH net-next v2 01/10] lib: packing: refuse operating on bit indices which exceed size of buffer Jacob Keller
2024-10-03 15:02   ` Vladimir Oltean
2024-10-02 21:51 ` [PATCH net-next v2 02/10] lib: packing: adjust definitions and implementation for arbitrary buffer lengths Jacob Keller
2024-10-03 15:05   ` Vladimir Oltean [this message]
2024-10-02 21:51 ` [PATCH net-next v2 03/10] lib: packing: remove kernel-doc from header file Jacob Keller
2024-10-03 15:05   ` Vladimir Oltean
2024-10-02 21:51 ` [PATCH net-next v2 04/10] lib: packing: add pack() and unpack() wrappers over packing() Jacob Keller
2024-10-03 15:13   ` Vladimir Oltean
2024-10-02 21:51 ` [PATCH net-next v2 05/10] lib: packing: duplicate pack() and unpack() implementations Jacob Keller
2024-10-03 15:11   ` Vladimir Oltean
2024-10-02 21:51 ` [PATCH net-next v2 06/10] lib: packing: add KUnit tests adapted from selftests Jacob Keller
2024-10-03 15:18   ` Vladimir Oltean
2024-10-02 21:51 ` [PATCH net-next v2 07/10] lib: packing: add additional KUnit tests Jacob Keller
2024-10-03 15:21   ` Vladimir Oltean
2024-10-02 21:51 ` [PATCH net-next v2 08/10] lib: packing: fix QUIRK_MSB_ON_THE_RIGHT behavior Jacob Keller
2024-10-03 15:22   ` Vladimir Oltean
2024-10-02 21:51 ` [PATCH net-next v2 09/10] lib: packing: use BITS_PER_BYTE instead of 8 Jacob Keller
2024-10-03 15:23   ` Vladimir Oltean
2024-10-02 21:51 ` [PATCH net-next v2 10/10] lib: packing: use GENMASK() for box_mask Jacob Keller
2024-10-03 23:10 ` [PATCH net-next v2 00/10] packing: various improvements and KUnit tests patchwork-bot+netdevbpf

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=20241003150510.w2yhj5ox2tnqdjst@skbuf \
    --to=vladimir.oltean@nxp.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=jacob.e.keller@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=przemyslaw.kitszel@intel.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