From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: "Hefty, Sean" <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Jason Gunthorpe
<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>,
"Dalessandro,
Dennis"
<dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org"
<dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"Hiatt, Don" <don.hiatt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"Marciniszyn,
Mike" <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH for-next 5/8] IB/core: Use __be32 for LIDs in opa_is_extended_lid
Date: Wed, 4 Oct 2017 20:23:23 +0300 [thread overview]
Message-ID: <20171004172323.GH25829@mtr-leonro.local> (raw)
In-Reply-To: <20171003180735.GE25829-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1896 bytes --]
On Tue, Oct 03, 2017 at 09:07:35PM +0300, Leon Romanovsky wrote:
> On Tue, Oct 03, 2017 at 05:05:06PM +0000, Hefty, Sean wrote:
> > > > > > if ((be32_to_cpu(dlid) >=
> > > > > > be16_to_cpu(IB_MULTICAST_LID_BASE)) ||
> > > > > > (be32_to_cpu(slid) >=
> > > > > > be16_to_cpu(IB_MULTICAST_LID_BASE)))
> > > > >
> > > > > You can drop be32_to_cpu and be16_to_cpu now.
> > > > > The dlid is __be32 and IB_MULTICAST_LID_BASE is __be16. The direct
> > > > > comparison will work.
> > > >
> > > > It won't order properly for >=, the swap is still needed...
> > >
> > > Jason,
> > > Do you have reference for that?
> > >
> > > I tried to find any information about comparison of values from one
> > > endianess on machine with another endianess and didn't find anything
> > > relevant.
> >
> > The bytes are out of order, so the comparisons won't work.
>
> I understand it for the "manual" comparison (C-like arrays), but does it apply
> for the compiler-aware comparison? Both these variables are marked as
> __be32 for the compiler.
OK, I finally found time to test my question and you and Jason are right.
Thank you for your time.
For curious readers, the snippet below, tested on x86:
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index bcc4c2db81d0..234105716120 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -4754,6 +4754,15 @@ static int __init mlx5_ib_init(void)
{
int err;
+ uint32_t u1 = 0x2233;
+ uint32_t u2 = 0x4411;
+
+ __be32 b1 = cpu_to_be32(u1);
+ __be32 b2 = cpu_to_be32(u2);
+
+ printk(KERN_ERR "test: u1 %s u1\n", (u1 < u2 ) ? "<":">");
+ printk(KERN_ERR "test: b1 %s b1\n", (b1 < b2 ) ? "<":">");
+
mlx5_ib_odp_init();
err = mlx5_register_interface(&mlx5_ib_interface);
and the result:
[ 6.566979] test: u1 < u1
[ 6.567147] test: b1 > b1
Thanks
>
> Thanks
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-10-04 17:23 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-02 18:03 [PATCH for-next 0/8] IB/hfi1, core, rdmavt: Driver fixes for 10/2/2017 Dennis Dalessandro
2017-10-02 18:03 ` Dennis Dalessandro
[not found] ` <20171002180204.31117.12254.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-10-02 18:04 ` [PATCH for-next 1/8] IB/hfi1: Add parsing for platform configuration format version 4 Dennis Dalessandro
2017-10-02 18:04 ` [PATCH for-next 2/8] IB/hfi1: Fix output trace issues from 16B change Dennis Dalessandro
2017-10-02 18:04 ` [PATCH for-next 4/8] IB/hfi1: Prevent LNI out of sync by resetting host interface version Dennis Dalessandro
2017-10-02 18:04 ` [PATCH for-next 5/8] IB/core: Use __be32 for LIDs in opa_is_extended_lid Dennis Dalessandro
[not found] ` <20171002180431.31117.33069.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-10-03 6:16 ` Leon Romanovsky
[not found] ` <20171003061657.GA13648-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-10-03 16:00 ` Jason Gunthorpe
[not found] ` <20171003160059.GB30753-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-10-03 17:01 ` Leon Romanovsky
[not found] ` <20171003170140.GD25829-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-10-03 17:05 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A82373AB19A6C6-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2017-10-03 18:07 ` Leon Romanovsky
[not found] ` <20171003180735.GE25829-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-10-04 17:23 ` Leon Romanovsky [this message]
2017-10-02 18:04 ` [PATCH for-next 6/8] IB/rdmavt: Correct issues with read-mostly and send size cache lines Dennis Dalessandro
2017-10-02 18:04 ` [PATCH for-next 7/8] IB/core: Do not warn on lid conversions for OPA Dennis Dalessandro
[not found] ` <20171002180446.31117.56786.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-10-03 6:24 ` Leon Romanovsky
2017-10-02 18:04 ` [PATCH for-next 8/8] IB/hfi1: " Dennis Dalessandro
[not found] ` <20171002180453.31117.53379.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-10-03 6:25 ` Leon Romanovsky
2017-10-04 19:44 ` [PATCH for-next 0/8] IB/hfi1, core, rdmavt: Driver fixes for 10/2/2017 Doug Ledford
2017-10-04 19:44 ` Doug Ledford
[not found] ` <1507146261.46071.8.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-10-05 1:22 ` Dennis Dalessandro
2017-10-05 1:22 ` Dennis Dalessandro
2017-10-05 7:04 ` Leon Romanovsky
2017-10-05 10:44 ` Dennis Dalessandro
[not found] ` <8601bdaa-53cc-e41f-95e6-483af90848b7-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-10-05 13:22 ` Doug Ledford
2017-10-05 13:22 ` Doug Ledford
2017-10-02 18:04 ` [PATCH for-next 3/8] IB/hfi1: Fix incorrect available receive user context count Dennis Dalessandro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171004172323.GH25829@mtr-leonro.local \
--to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=don.hiatt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.