Message ID | 1360079337-8173-2-git-send-email-ogerlitz@mellanox.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
> The hash function introduced in commit b63b70d877 "IPoIB: Use a private hash > table for path lookup in xmit path" was designd to use the 3 octets of the > IPoIB HW address that holds the remote QPN. However, this currently isn't > the case under little endian machines as the code there uses the flags part > (octet[0]) and not the last octet of the QPN (octet[3]), fix that. > > The fix caused a checkpatch warning on line over 80 characters, to > solve that changed the name of the temp variable that holds the daddr. > > Signed-off-by: Shlomo Pongratz <shlomop@mellanox.com> > Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> > --- > drivers/infiniband/ulp/ipoib/ipoib_main.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c > b/drivers/infiniband/ulp/ipoib/ipoib_main.c > index 6fdc9e7..e459fa7 100644 > --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c > +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c > @@ -844,10 +844,10 @@ static u32 ipoib_addr_hash(struct ipoib_neigh_hash *htbl, > u8 *daddr) > * different subnets. > */ > /* qpn octets[1:4) & port GUID octets[12:20) */ > - u32 *daddr_32 = (u32 *) daddr; > + u32 *d32 = (u32 *)daddr; > u32 hv; > > - hv = jhash_3words(daddr_32[3], daddr_32[4], 0xFFFFFF & daddr_32[0], 0); > + hv = jhash_3words(d32[3], d32[4], cpu_to_be32(0xFFFFFF) & d32[0], 0); Should d32 be declared as __be32 *? -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 2/11/2013 9:46 PM, Hefty, Sean wrote: >> --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c >> >+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c >> >@@ -844,10 +844,10 @@ static u32 ipoib_addr_hash(struct ipoib_neigh_hash *htbl, >> >u8 *daddr) >> > * different subnets. >> > */ >> > /* qpn octets[1:4) & port GUID octets[12:20) */ >> >- u32 *daddr_32 = (u32 *) daddr; >> >+ u32 *d32 = (u32 *)daddr; >> > u32 hv; >> > >> >- hv = jhash_3words(daddr_32[3], daddr_32[4], 0xFFFFFF & daddr_32[0], 0); >> >+ hv = jhash_3words(d32[3], d32[4], cpu_to_be32(0xFFFFFF) & d32[0], 0); > Should d32 be declared as __be32 *? Hi Sean, The IPoIB destination address is indeed in big endian format and normally the pointer to it should be of type __be32. However in this case I just want to feed it into the hash function without the flags part. defining d32 as __be32* will make the code a bit ugly as I'll need to cast 3 of "jhash_3words" functions arguments. That is, __be32 *d32; .... hv = jhash_3words((__force u32) d32[3], (__force u32) d32[4], (__force u32)(cpu_to_be32(0xFFFFFF) & d32[0]), 0); Best regards, S.P. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> On 2/11/2013 9:46 PM, Hefty, Sean wrote: > >> --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c > >> >+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c > >> >@@ -844,10 +844,10 @@ static u32 ipoib_addr_hash(struct ipoib_neigh_hash > *htbl, > >> >u8 *daddr) > >> > * different subnets. > >> > */ > >> > /* qpn octets[1:4) & port GUID octets[12:20) */ > >> >- u32 *daddr_32 = (u32 *) daddr; > >> >+ u32 *d32 = (u32 *)daddr; > >> > u32 hv; > >> > > >> >- hv = jhash_3words(daddr_32[3], daddr_32[4], 0xFFFFFF & daddr_32[0], 0); > >> >+ hv = jhash_3words(d32[3], d32[4], cpu_to_be32(0xFFFFFF) & d32[0], 0); > > Should d32 be declared as __be32 *? > Hi Sean, > > The IPoIB destination address is indeed in big endian format and > normally the pointer to it should be of type __be32. > However in this case I just want to feed it into the hash function > without the flags part. > defining d32 as __be32* will make the code a bit ugly as I'll need to > cast 3 of "jhash_3words" functions arguments. > That is, > > __be32 *d32; > .... > > hv = jhash_3words((__force u32) d32[3], (__force u32) d32[4], (__force > u32)(cpu_to_be32(0xFFFFFF) & d32[0]), 0); Have you run the V2 patch through sparse? -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 12/02/2013 18:33, Hefty, Sean wrote:
> Have you run the V2 patch through sparse?
oops, I see now that the V2 patches introduced some sparse warnings,
will fix for V3, thanks for spotting that over.
Or.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Feb 12, 2013 at 04:47:41PM +0200, Shlomo Pongratz wrote: > On 2/11/2013 9:46 PM, Hefty, Sean wrote: > >>>+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c > >>>@@ -844,10 +844,10 @@ static u32 ipoib_addr_hash(struct ipoib_neigh_hash *htbl, > >>>u8 *daddr) > >>> * different subnets. > >>> */ > >>> /* qpn octets[1:4) & port GUID octets[12:20) */ > >>>- u32 *daddr_32 = (u32 *) daddr; > >>>+ u32 *d32 = (u32 *)daddr; > >>> u32 hv; > >>> > >>>- hv = jhash_3words(daddr_32[3], daddr_32[4], 0xFFFFFF & daddr_32[0], 0); > >>>+ hv = jhash_3words(d32[3], d32[4], cpu_to_be32(0xFFFFFF) & d32[0], 0); > >Should d32 be declared as __be32 *? > Hi Sean, > > The IPoIB destination address is indeed in big endian format and > normally the pointer to it should be of type __be32. > However in this case I just want to feed it into the hash function > without the flags part. > defining d32 as __be32* will make the code a bit ugly as I'll need > to cast 3 of "jhash_3words" functions arguments. > That is, > > __be32 *d32; > .... > > hv = jhash_3words((__force u32) d32[3], (__force u32) d32[4], > (__force u32)(cpu_to_be32(0xFFFFFF) & d32[0]), 0); Not sure what your hv is used for, but be aware that it is going to have a different value on big and little endian systems.. This is why the (__force u32) is somewhat desirable, because you are explicitly, and deliberately ignoring the effect of endianness at that point in the code. Jason -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 6fdc9e7..e459fa7 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -844,10 +844,10 @@ static u32 ipoib_addr_hash(struct ipoib_neigh_hash *htbl, u8 *daddr) * different subnets. */ /* qpn octets[1:4) & port GUID octets[12:20) */ - u32 *daddr_32 = (u32 *) daddr; + u32 *d32 = (u32 *)daddr; u32 hv; - hv = jhash_3words(daddr_32[3], daddr_32[4], 0xFFFFFF & daddr_32[0], 0); + hv = jhash_3words(d32[3], d32[4], cpu_to_be32(0xFFFFFF) & d32[0], 0); return hv & htbl->mask; }