Re: [PATCH rdma-core 06/11] libbnxtre: convert cpu to le all over the place

Jason Gunthorpe
2017-01-29T23:09:45Z

On Sat, Jan 28, 2017 at 05:13:37PM -0500, Devesh Sharma wrote:

> +/* Memory byte order conversion functions. */
> +#if __BYTE_ORDER == __BIG_ENDIAN

No reason for this ifdef

> +static inline int bnxt_re_host_to_le64(uint64_t *src, int bytes)
> +{
> + int qwords, indx;
> +
> + if (!bytes || bytes < 8)
> + return -EINVAL;
> +
> + qwords = bytes / sizeof(uint64_t);
> + for (indx = 0; indx < qwords; indx++) {
> + if (*(src + indx))
> + *(src + indx) = htole64(*(src + indx));
> + }
> +
> + return qwords;
> +}
> +
> +static inline int bnxt_re_le64_to_host(uint64_t *src, int bytes)
> +{
> + int qwords, indx;
> +
> + if (!bytes || bytes < 8)
> + return -EINVAL;
> +
> + qwords = bytes / sizeof(uint64_t);
> + for (indx = 0; indx < qwords; indx++) {
> + if (*(src + indx))
> + *(src + indx) = le64toh(*(src + indx));
> + }
> +
> + return qwords;
> +}
> +#else
> +static inline int bnxt_re_host_to_le64(uint64_t *src, int bytes)
> +{
> + return 0;
> +}
> +
> +static inline int bnxt_re_le64_to_host(uint64_t *src, int bytes)
> +{
> + return 0;
> +}

And your alts look broken anyhow. Just use the first version, gcc will
optimize it properly..

Jason