mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 17:25:38 +00:00
a636ba5e86
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> Link: https://patch.msgid.link/20241002-packing-kunit-tests-and-split-pack-unpack-v2-2-8373e551eae3@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> |
||
---|---|---|
.. | ||
irq | ||
wrappers | ||
asm-annotations.rst | ||
assoc_array.rst | ||
boot-time-mm.rst | ||
cachetlb.rst | ||
circular-buffers.rst | ||
cleanup.rst | ||
cpu_hotplug.rst | ||
debug-objects.rst | ||
debugging-via-ohci1394.rst | ||
dma-api-howto.rst | ||
dma-api.rst | ||
dma-attributes.rst | ||
dma-isa-lpc.rst | ||
entry.rst | ||
errseq.rst | ||
floating-point.rst | ||
folio_queue.rst | ||
genalloc.rst | ||
generic-radix-tree.rst | ||
genericirq.rst | ||
gfp_mask-from-fs-io.rst | ||
idr.rst | ||
index.rst | ||
kernel-api.rst | ||
kobject.rst | ||
kref.rst | ||
librs.rst | ||
local_ops.rst | ||
maple_tree.rst | ||
memory-allocation.rst | ||
memory-hotplug.rst | ||
mm-api.rst | ||
netlink.rst | ||
packing.rst | ||
padata.rst | ||
pin_user_pages.rst | ||
printk-basics.rst | ||
printk-formats.rst | ||
printk-index.rst | ||
protection-keys.rst | ||
rbtree.rst | ||
refcount-vs-atomic.rst | ||
swiotlb.rst | ||
symbol-namespaces.rst | ||
this_cpu_ops.rst | ||
timekeeping.rst | ||
tracepoint.rst | ||
unaligned-memory-access.rst | ||
union_find.rst | ||
watch_queue.rst | ||
workqueue.rst | ||
xarray.rst |