[ofw] [PATCH] ND Provider: fix service ID byte ordering
Hefty, Sean
sean.hefty at intel.com
Fri Feb 11 15:50:03 PST 2011
> Index: core/al/kernel/al_ndi_cm.c
> ===================================================================
> --- core/al/kernel/al_ndi_cm.c (revision 3095)
> +++ core/al/kernel/al_ndi_cm.c (working copy)
> @@ -1072,7 +1072,9 @@ __ndi_fill_cm_req(
>
> memset( p_cm_req, 0, sizeof(*p_cm_req) );
>
> - p_cm_req->service_id = IB_REQ_CM_RDMA_SID_PREFIX | (p_req->prot <<
> 16) | p_req->dst_port;
> + p_cm_req->service_id = IB_REQ_CM_RDMA_SID_PREFIX |
> + ((UINT64)p_req->prot) << 40 |
> + ((UINT64)p_req->dst_port) << 48;
IMO, it's clearer and more maintainable to define values and perform operations in host order, with swapping done at the end..
> +/*
> + * The prefix and mask are defined in network order.
> + */
> +#define IB_REQ_CM_RDMA_SID_PREFIX 0x0000000100000000I64
> +#define IB_REQ_CM_RDMA_SID_PREFIX_MASK 0x000000FFFFFFFFFFI64
..but if you want to define a value in network order, use something like:
#define VAL htonX(1234)
which is self documenting. The compiler should be able to remove the actual computation.
- Sean
More information about the ofw
mailing list