public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Jeff Squyres <jsquyres-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] libibverbs: Allow arbitrary int values for MTU
Date: Tue, 18 Jun 2013 12:49:28 -0600	[thread overview]
Message-ID: <20130618184928.GE2204@obsidianresearch.com> (raw)
In-Reply-To: <1371502807-17026-1-git-send-email-jsquyres-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>

On Mon, Jun 17, 2013 at 02:00:07PM -0700, Jeff Squyres wrote:
> Keep IBV_MTU_* enums values as they are, but pass MTU values around as
> int's.  This is an ABI-compatible change; legacy applications will use
> the enum values, but newer applications can use an int for values that
> do not currently exist in the enum set (e.g., 1500, 9000).
> 
> (if people like the idea of this patch, I will send the corresponding
> kernel patch)
> 
> Signed-off-by: Jeff Squyres <jsquyres-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
>  examples/devinfo.c         | 11 +++++++++--
>  examples/pingpong.c        | 12 ------------
>  examples/pingpong.h        |  1 -
>  examples/rc_pingpong.c     |  8 ++++----
>  examples/srq_pingpong.c    |  8 ++++----
>  examples/uc_pingpong.c     |  8 ++++----
>  examples/ud_pingpong.c     |  2 +-
>  include/infiniband/verbs.h | 20 +++++++++++++++++---
>  man/ibv_modify_qp.3        |  2 +-
>  man/ibv_query_port.3       |  4 ++--
>  man/ibv_query_qp.3         |  2 +-
>  src/libibverbs.map         |  3 +++
>  src/verbs.c                | 24 ++++++++++++++++++++++++
>  13 files changed, 70 insertions(+), 35 deletions(-)
> 
> diff --git a/examples/devinfo.c b/examples/devinfo.c
> index ff078e4..b856c82 100644
> +++ b/examples/devinfo.c
> @@ -111,15 +111,22 @@ static const char *atomic_cap_str(enum ibv_atomic_cap atom_cap)
>  	}
>  }
>  
> -static const char *mtu_str(enum ibv_mtu max_mtu)
> +static const char *mtu_str(int max_mtu)

This is simpler:

{
	static char str[16];
	snprintf(str, sizeof(str), "%d", ibv_mtu_to_num(max_mtu));
        return str;
}

You may want to replace 'enum ibv_mtu' with 'ibv_mtu_t' to make it
more clear that it is not an integer.

> -	enum ibv_mtu		 mtu = IBV_MTU_1024;
> +	int			 mtu = 1024;

No, you must keep using IBV_MTU_1024 for all cases requesting a 1024
byte MTU, new libraries will accept both, old libraries will only
accept IBV_MTU_1024, so we must stick with IBV_MTU_1024 in
applications.

So:

int			 mtu = num_to_ibv_mtu(1024);

> -			mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0));
> +			mtu = strtol(optarg, NULL, 0);
>  			if (mtu < 0) {
>  				usage(argv[0]);
>  				return 1;

Same deal, add 'mtu =  num_to_ibv_mtu(mtu);'

Same two comments repeated many times.
  
> +/**
> + * ibv_num_to_mtu - If an MTU enum value for "num" is available,
> + * return it (e.g., 1024 -> IBV_MTU_1024).  Otherwise, return num
> + * (e.g., 1500 -> 1500).
> + */
> +int num_to_ibv_mtu(int num);

Probably should be ibv_num_to_mtu() to keep with the naming pattern..

> +
> +/**
> + * ibv_mtu_to_num - Return the numeric value of a symbolic enum
> + * ibv_mtu name (e.g., IBV_MTU_1024 -> 1024).  If a non-symbolic enum
> + * value is passed, just return the same value (e.g., 1500 -> 1500).
> + */
> +int ibv_mtu_to_num(int mtu);

These should be static inlines, not externs. There is a desire to not
add new symbols to libibverbs.

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:[~2013-06-18 18:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-17 21:00 [PATCH] libibverbs: Allow arbitrary int values for MTU Jeff Squyres
     [not found] ` <1371502807-17026-1-git-send-email-jsquyres-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
2013-06-18 18:49   ` Jason Gunthorpe [this message]
     [not found]     ` <20130618184928.GE2204-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2013-06-20 13:48       ` Jeff Squyres (jsquyres)
     [not found]         ` <EF66BBEB19BADC41AC8CCF5F684F07FC4F6939C5-nsZYYkk5h5QQ2GdVW7+PtKBKnGwkPULj@public.gmane.org>
2013-06-20 17:09           ` Hefty, Sean
     [not found]             ` <1828884A29C6694DAF28B7E6B8A823736FD358BC-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2013-06-20 20:02               ` Jeff Squyres (jsquyres)
2013-06-20 20:40       ` Doug Ledford
     [not found]         ` <51C368D4.7020603-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-06-20 20:50           ` Jeff Squyres (jsquyres)
  -- strict thread matches above, loose matches on Subject: below --
2013-07-01 14:23 Jeff Squyres

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=20130618184928.GE2204@obsidianresearch.com \
    --to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
    --cc=jsquyres-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@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