[dpdk-dev] [PATCH 01/38] eal: add support for 24 40 and 48 bit operations
Avi Kivity
avi at scylladb.com
Mon Oct 2 12:16:16 CEST 2017
On 06/16/2017 08:40 AM, Shreyansh Jain wrote:
> From: Hemant Agrawal <hemant.agrawal at nxp.com>
>
> Bit Swap and LE<=>BE conversions for 23, 40 and 48 bit width
>
> Signed-off-by: Hemant Agrawal <hemant.agrawal at nxp.com>
> ---
> .../common/include/generic/rte_byteorder.h | 78 ++++++++++++++++++++++
> 1 file changed, 78 insertions(+)
>
> diff --git a/lib/librte_eal/common/include/generic/rte_byteorder.h b/lib/librte_eal/common/include/generic/rte_byteorder.h
> index e00bccb..8903ff6 100644
> --- a/lib/librte_eal/common/include/generic/rte_byteorder.h
> +++ b/lib/librte_eal/common/include/generic/rte_byteorder.h
> @@ -122,6 +122,84 @@ rte_constant_bswap64(uint64_t x)
> ((x & 0xff00000000000000ULL) >> 56);
> }
>
> +/*
> + * An internal function to swap bytes of a 48-bit value.
> + */
> +static inline uint64_t
> +rte_constant_bswap48(uint64_t x)
> +{
> + return ((x & 0x0000000000ffULL) << 40) |
> + ((x & 0x00000000ff00ULL) << 24) |
> + ((x & 0x000000ff0000ULL) << 8) |
> + ((x & 0x0000ff000000ULL) >> 8) |
> + ((x & 0x00ff00000000ULL) >> 24) |
> + ((x & 0xff0000000000ULL) >> 40);
> +}
> +
Won't something like bswap64(x << 16) be much more efficient? Two
instructions for the non-constant case, compared to 15-20 here.
More information about the dev
mailing list