RE: [PATCH 8/9] Remove most checks of __BYTE_ORDER

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> For a long time now endian.h has defined sane fixed with conversion
> macros, so lets just use them instead of rolling our own.
> 
> Also, htonll is defined in this source tree under infiniband/arch.h,
> so all users of that macro can just use the header.
> 
> Someday we should also get rid of all the endless wrappers..
> 
> Signed-off-by: Jason Gunthorpe <jgunthorpe@xxxxxxxxxxxxxxxxxxxx>
> ---
>  ibacm/linux/osd.h                    |  8 +-------
>  libcxgb3/src/cxio_wr.h               | 10 +++-------
>  libcxgb4/src/t4.h                    | 11 ++++-------
>  libi40iw/src/i40iw_umain.h           | 18 ++----------------
>  libibumad/src/sysfs.c                |  8 +-------
>  libibverbs/include/infiniband/arch.h | 15 ++++++---------
>  libnes/src/nes_umain.h               | 17 ++---------------
>  libocrdma/src/ocrdma_verbs.c         | 32 ++++----------------------------
>  librdmacm/examples/common.h          | 11 +++--------
>  librdmacm/src/cma.h                  |  9 +--------
>  srp_daemon/srp_daemon/srp_daemon.h   | 17 +----------------
>  11 files changed, 28 insertions(+), 128 deletions(-)
> 

<snip>

> diff --git a/libcxgb3/src/cxio_wr.h b/libcxgb3/src/cxio_wr.h
> index ece06bd0568c..e24c7fed7d76 100644
> --- a/libcxgb3/src/cxio_wr.h
> +++ b/libcxgb3/src/cxio_wr.h
> @@ -50,13 +50,9 @@
>  #define Q_COUNT(rptr,wptr) ((wptr)-(rptr))
>  #define Q_PTR2IDX(ptr,size_log2) (ptr & ((1UL<<size_log2)-1))
> 
> -#if __BYTE_ORDER == __LITTLE_ENDIAN
> -#  define cpu_to_pci32(val) ((val))
> -#elif __BYTE_ORDER == __BIG_ENDIAN
> -#  define cpu_to_pci32(val) (__bswap_32((val)))
> -#else
> -#  error __BYTE_ORDER not defined
> -#endif
> +/* Generally speaking, PCI systems auto-byteswap on PCI accesses, so this is
> +   probably wrong */
> +#define cpu_to_pci32(val) htole32(val)
> 

If this was wrong, then nothing would work.  So I think you should remove the
comment.

>  #define RING_DOORBELL(doorbell, QPID) { \
>  	*doorbell = cpu_to_pci32(QPID); \

See RING_DOORBELL() is used in the .c files

> diff --git a/libcxgb4/src/t4.h b/libcxgb4/src/t4.h
> index e8c5cf66cb14..e519cc4087e6 100644
> --- a/libcxgb4/src/t4.h
> +++ b/libcxgb4/src/t4.h
> @@ -62,13 +62,10 @@
>  #define unlikely
>  #define ROUND_UP(x, n) (((x) + (n) - 1u) & ~((n) - 1u))
>  #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
> -#if __BYTE_ORDER == __LITTLE_ENDIAN
> -#  define cpu_to_pci32(val) ((val))
> -#elif __BYTE_ORDER == __BIG_ENDIAN
> -#  define cpu_to_pci32(val) (__bswap_32((val)))
> -#else
> -#  error __BYTE_ORDER not defined
> -#endif
> +
> +/* Generally speaking, PCI systems auto-byteswap on PCI accesses, so this is
> +   probably wrong */
> +#define cpu_to_pci32(val) htole32(val)
> 

Ditto.

>  #define writel(v, a) do { *((volatile u32 *)(a)) = cpu_to_pci32(v); } while
(0)
>

Ditto.


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux