On Thu, Aug 10, 2017 at 02:04:25PM -0400, Don Hiatt wrote: > Add two helper functions (ib_lid_cpu16(), ib_lid_be16()) to > convert 32 bit lids to 16 bits. > > Signed-off-by: Don Hiatt <don.hiatt@xxxxxxxxx> > Reviewed-by: Dennis Dalessandro <dennis.dalessandro@xxxxxxxxx> > --- > include/rdma/ib_verbs.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h > index a7d6990..3875ea5d 100644 > --- a/include/rdma/ib_verbs.h > +++ b/include/rdma/ib_verbs.h > @@ -3710,4 +3710,16 @@ static inline enum rdma_ah_attr_type rdma_ah_find_type(struct ib_device *dev, > else > return RDMA_AH_ATTR_TYPE_IB; > } > + > +/* Return lid in 16bit CPU encoding */ > +static inline u16 ib_lid_cpu16(u32 lid) > +{ > + return (u16)lid; > +} > + > +/* Return lid in 16bit BE encoding */ > +static inline u16 ib_lid_be16(u32 lid) > +{ > + return cpu_to_be16((u16)lid); > +} Please add comments to these functions, with the description when and why we are doing this conversion, and I think that it is worth to add here WARN_ON_ONCE(lid && 0xFFFF0000) to catch possible bad flows. > #endif /* IB_VERBS_H */ > -- > 1.8.3.1 > > -- > 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
Attachment:
signature.asc
Description: PGP signature