On Thu, 23 Jun 2022 14:39:00 +0200 Morten Brørup <m...@smartsharesystems.com> wrote:
> + /* if buffer is unaligned, keeping it byte order independent */ > + if (unlikely(unaligned)) { > + uint16_t first = 0; > + if (unlikely(len == 0)) > + return 0; Why is length == 0 unique to unaligned case? > + ((unsigned char *)&first)[1] = *(const unsigned char *)buf; Use a proper union instead of casting to avoid aliasing warnings. > + bsum += first; > + buf = RTE_PTR_ADD(buf, 1); > + len--; > + } Many CPU's (such as x86) won't care about alignment and therefore the extra code to handle this is not worth doing. Perhaps DPDK needs a macro (like Linux kernel) for efficient unaligned access. In Linux kernel it is CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS