public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Matan Barak <matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
	dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH libibverbs V3 3/3] Add ibv_query_port_ex support
Date: Mon, 12 May 2014 10:43:23 -0600	[thread overview]
Message-ID: <20140512164323.GA20666@obsidianresearch.com> (raw)
In-Reply-To: <5370BCF2.7050107-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

On Mon, May 12, 2014 at 03:22:10PM +0300, Matan Barak wrote:

> >Anonymous struct/union is a C11 feature and GNU extension. I don't
> >think is appropriate for a user library to rely on. We cannot assume
> >the user is has a compiler in C11 mode.
> >
> >The cannonical layout should be:
> >
> >struct ibv_port_attr_ex {
> >    uint64_t comp_mask;
> >    struct ibv_port_attr	port_attr;
> >    // New stuff goes here
> >}
> >
> 
> It's not mandatory, but I think it could prevent future breakages
> and inconsistencies. Anyway, anonymous unions are supported in icc
> 9.2+, clang 3.1+ and of course gcc. However, I'll remove this in the
> next version of this series.

Many compilers support C11, but if the user chooses to compile with,
say, -std=c99 then the feature goes away. System level headers should
never require the user to use a specific -std.

You can also inline the legacy port_attr into the struct, which might
be the best option here.

> >It is fine to use comp_mask to indicate all the fields, no need for
> >the weird mask1, lets not over complicate things for users.
> 
> I don't think that's the right thing to do. According to my
> understanding, the prefix of the extension verb is fully compatible
> with the old structure.

This is not necessary in this case, it is convient that the old
structure exist within the extended structure so that it is easy for
the wrapper to call an old function without having to munge the
function pointers, but that copy can be in any place.

> Afterwards, comp_mask has a bit for every new field. mask1 is a new
> field that indicates which of the "old" values the user is
> interested in. If we want to be strict with the extension verbs
> definition, lets keep it all the way.

comp_mask has bits for fields, that is all it does, the distinction
between 'new' and 'old' is meaningless at this point. Just inline the
bits in comp_mask.

Generally, it would be smart to limit the number of comp_mask bits
used so we don't run out in the future, so in general, a new extension
can omit bits for fields that exist when the extension is introduced.

However, in this case there is a functional purpose to having the
fields have bits, so you should just go ahead and include them
directly.

Adding more masks is just going to be confusing to users. Remember,
there is no static type checking, so the user has to know that
IBV_QUERY_PORT_EX_LINK_LAYER is associated with mask1, while
IBV_QUERY_PORT_EX_ATTR_MASK1 is somehow associated with comp_mask -
and they sure do look similar, and it is counter-intuitive compared to
other cases in the library.

BTW, before I forget, the patch that introduces the API must also
include a man page for it.

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

  parent reply	other threads:[~2014-05-12 16:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08  6:51 [PATCH libibverbs V3 0/3] Add support for UD QPs under RoCE IP addressing Or Gerlitz
     [not found] ` <1399531883-30599-1-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-05-08  6:51   ` [PATCH libibverbs V3 1/3] Add ibv_port_cap_flags Or Gerlitz
2014-05-08  6:51   ` [PATCH libibverbs V3 2/3] Use neighbour lookup for RoCE UD QPs Eth L2 resolution Or Gerlitz
     [not found]     ` <1399531883-30599-3-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-05-08 19:29       ` Jason Gunthorpe
2014-05-08  6:51   ` [PATCH libibverbs V3 3/3] Add ibv_query_port_ex support Or Gerlitz
     [not found]     ` <1399531883-30599-4-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-05-08 19:09       ` Jason Gunthorpe
     [not found]         ` <20140508190951.GB25849-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2014-05-08 19:40           ` Christoph Lameter
     [not found]             ` <alpine.DEB.2.10.1405081439370.26267-gkYfJU5Cukgdnm+yROfE0A@public.gmane.org>
2014-05-08 19:47               ` Jason Gunthorpe
2014-05-09 14:01           ` Roland Dreier
     [not found]             ` <CAL1RGDUiBtOaYKZVR3ghOZzG6J0p5EV5o4FTTW0E43mHz-BaVQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-09 18:10               ` Jason Gunthorpe
     [not found]                 ` <20140509181043.GC18257-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2014-05-09 18:20                   ` Roland Dreier
     [not found]                     ` <CAL1RGDVmeTKz1TXGLP+h4t9ffuaVeBCkWKPC2AuFyygcNweRWg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-09 18:39                       ` Hefty, Sean
2014-05-09 18:40                       ` Jason Gunthorpe
2014-05-11 12:35                   ` Or Gerlitz
     [not found]                     ` <536F6EAC.8020109-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-05-12  6:35                       ` Jason Gunthorpe
2014-05-12 12:22           ` Matan Barak
     [not found]             ` <5370BCF2.7050107-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-05-12 16:43               ` Jason Gunthorpe [this message]
     [not found]                 ` <20140512164323.GA20666-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2014-05-12 21:57                   ` Roland Dreier
     [not found]                     ` <CAL1RGDXYwPHrS7dSWg0ojyiPG7TF1Y0800q801kWvMxoyn3c8g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-13 13:18                       ` Doug Ledford
     [not found]                     ` <23840589.5954.1399987081862.JavaMail."DougLedford"@Phenom>
2014-05-13 20:02                       ` Jason Gunthorpe

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=20140512164323.GA20666@obsidianresearch.com \
    --to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=yishaih-VPRAkNaXOzVWk0Htik3J/w@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox