Re: [PATCH libibverbs V2] Add new verb: uv_query_port_max_datagram()

2013-08-27 Thread Jeff Squyres (jsquyres)
Bump.  This is V2 of the patch, which removes the ABI issue: libibverbs 
directly calls the command in the kernel (without going through the provider 
plugin).

On Aug 21, 2013, at 5:22 PM, Jeff Squyres jsquy...@cisco.com wrote:

 Per lengthy discussion on the linux-rdma list, add a new verb to get
 max datagram size (in bytes) since the methods for retrieving MTU
 values are limited to a finite enum set, and are difficult to change
 for backwards compatibility reasons.  
 
 Also add corresponding command: uv_cmd_query_port_max_datagram().
 Since this is a new verb, there was no need to add a _V2 enum for the
 command macro, which required adding a UB_INIT_CMD_RESP() macro.
 
 If the kernel does not support the new QUERY_PORT_MAX_DATAGRAM
 command, fall back to returning the int-ized MTU enum from
 ibv_cmd_query_port().
 
 Note that the name for this verb was chosen with the following
 rationale:
 
 * After discussion with Roland, use the prefix uv instead of ibv,
  since this verb is generic to both Ethernet, InfiniBand, and
  whatever other transports are underneath.
 * query was used (vs. get) because it invokes a command (vs. a
  struct lookup)
 
 If the community likes this approach, I'll send the corresponding
 kernel patch.
 
 Difference from V1 
 ==
 Do not add this verb to the devops struct (because that would break ABI).
 Instead, just have uv_query_port_max_datagram() directly invoke 
 uv_cmd_query_port_max_datagram().
 
 Signed-off-by: Jeff Squyres jsquy...@cisco.com
 ---
 Makefile.am  |  3 +-
 examples/devinfo.c   |  7 +
 include/infiniband/driver.h  |  4 +++
 include/infiniband/kern-abi.h| 17 +++-
 include/infiniband/verbs.h   |  6 
 man/uv_query_port_max_datagram.3 | 59 
 src/cmd.c| 54 
 src/ibverbs.h|  8 ++
 src/libibverbs.map   |  2 ++
 src/verbs.c  | 13 +
 10 files changed, 171 insertions(+), 2 deletions(-)
 create mode 100644 man/uv_query_port_max_datagram.3
 
 diff --git a/Makefile.am b/Makefile.am
 index 40e83be..51fe5d5 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -54,7 +54,8 @@ man_MANS = man/ibv_asyncwatch.1 man/ibv_devices.1 
 man/ibv_devinfo.1 \
 man/ibv_post_srq_recv.3 man/ibv_query_device.3 man/ibv_query_gid.3
 \
 man/ibv_query_pkey.3 man/ibv_query_port.3 man/ibv_query_qp.3  \
 man/ibv_query_srq.3 man/ibv_rate_to_mult.3 man/ibv_reg_mr.3   
 \
 -man/ibv_req_notify_cq.3 man/ibv_resize_cq.3 man/ibv_rate_to_mbps.3
 +man/ibv_req_notify_cq.3 man/ibv_resize_cq.3 man/ibv_rate_to_mbps.3   
 \
 +man/uv_query_port_max_datagram.3
 
 DEBIAN = debian/changelog debian/compat debian/control debian/copyright \
 debian/ibverbs-utils.install debian/libibverbs1.install \
 diff --git a/examples/devinfo.c b/examples/devinfo.c
 index ff078e4..f51620b 100644
 --- a/examples/devinfo.c
 +++ b/examples/devinfo.c
 @@ -209,6 +209,7 @@ static int print_hca_cap(struct ibv_device *ib_dev, 
 uint8_t ib_port)
   struct ibv_port_attr port_attr;
   int rc = 0;
   uint8_t port;
 + uint32_t max_datagram;
   char buf[256];
 
   ctx = ibv_open_device(ib_dev);
 @@ -298,6 +299,11 @@ static int print_hca_cap(struct ibv_device *ib_dev, 
 uint8_t ib_port)
   fprintf(stderr, Failed to query port %u props\n, 
 port);
   goto cleanup;
   }
 + rc = uv_query_port_max_datagram(ctx, port, max_datagram);
 + if (rc) {
 + fprintf(stderr, Failed to query port %u max datagram 
 size\n, port);
 + goto cleanup;
 + }
   printf(\t\tport:\t%d\n, port);
   printf(\t\t\tstate:\t\t\t%s (%d)\n,
  port_state_str(port_attr.state), port_attr.state);
 @@ -305,6 +311,7 @@ static int print_hca_cap(struct ibv_device *ib_dev, 
 uint8_t ib_port)
  mtu_str(port_attr.max_mtu), port_attr.max_mtu);
   printf(\t\t\tactive_mtu:\t\t%s (%d)\n,
  mtu_str(port_attr.active_mtu), port_attr.active_mtu);
 + printf(\t\t\tmax_datagram_size:\t%u\n, max_datagram);
   printf(\t\t\tsm_lid:\t\t\t%d\n, port_attr.sm_lid);
   printf(\t\t\tport_lid:\t\t%d\n, port_attr.lid);
   printf(\t\t\tport_lmc:\t\t0x%02x\n, port_attr.lmc);
 diff --git a/include/infiniband/driver.h b/include/infiniband/driver.h
 index 9a81416..6e1236c 100644
 --- a/include/infiniband/driver.h
 +++ b/include/infiniband/driver.h
 @@ -67,6 +67,10 @@ int ibv_cmd_query_device(struct ibv_context *context,
 int ibv_cmd_query_port(struct ibv_context *context, uint8_t port_num,
  struct ibv_port_attr *port_attr,
  struct ibv_query_port *cmd, size_t cmd_size);
 +int 

[PATCH libibverbs V2] Add new verb: uv_query_port_max_datagram()

2013-08-21 Thread Jeff Squyres
Per lengthy discussion on the linux-rdma list, add a new verb to get
max datagram size (in bytes) since the methods for retrieving MTU
values are limited to a finite enum set, and are difficult to change
for backwards compatibility reasons.  

Also add corresponding command: uv_cmd_query_port_max_datagram().
Since this is a new verb, there was no need to add a _V2 enum for the
command macro, which required adding a UB_INIT_CMD_RESP() macro.

If the kernel does not support the new QUERY_PORT_MAX_DATAGRAM
command, fall back to returning the int-ized MTU enum from
ibv_cmd_query_port().

Note that the name for this verb was chosen with the following
rationale:

* After discussion with Roland, use the prefix uv instead of ibv,
  since this verb is generic to both Ethernet, InfiniBand, and
  whatever other transports are underneath.
* query was used (vs. get) because it invokes a command (vs. a
  struct lookup)

If the community likes this approach, I'll send the corresponding
kernel patch.

Difference from V1 
==
Do not add this verb to the devops struct (because that would break ABI).
Instead, just have uv_query_port_max_datagram() directly invoke 
uv_cmd_query_port_max_datagram().

Signed-off-by: Jeff Squyres jsquy...@cisco.com
---
 Makefile.am  |  3 +-
 examples/devinfo.c   |  7 +
 include/infiniband/driver.h  |  4 +++
 include/infiniband/kern-abi.h| 17 +++-
 include/infiniband/verbs.h   |  6 
 man/uv_query_port_max_datagram.3 | 59 
 src/cmd.c| 54 
 src/ibverbs.h|  8 ++
 src/libibverbs.map   |  2 ++
 src/verbs.c  | 13 +
 10 files changed, 171 insertions(+), 2 deletions(-)
 create mode 100644 man/uv_query_port_max_datagram.3

diff --git a/Makefile.am b/Makefile.am
index 40e83be..51fe5d5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,7 +54,8 @@ man_MANS = man/ibv_asyncwatch.1 man/ibv_devices.1 
man/ibv_devinfo.1   \
 man/ibv_post_srq_recv.3 man/ibv_query_device.3 man/ibv_query_gid.3 \
 man/ibv_query_pkey.3 man/ibv_query_port.3 man/ibv_query_qp.3   \
 man/ibv_query_srq.3 man/ibv_rate_to_mult.3 man/ibv_reg_mr.3
\
-man/ibv_req_notify_cq.3 man/ibv_resize_cq.3 man/ibv_rate_to_mbps.3
+man/ibv_req_notify_cq.3 man/ibv_resize_cq.3 man/ibv_rate_to_mbps.3 \
+man/uv_query_port_max_datagram.3
 
 DEBIAN = debian/changelog debian/compat debian/control debian/copyright \
 debian/ibverbs-utils.install debian/libibverbs1.install \
diff --git a/examples/devinfo.c b/examples/devinfo.c
index ff078e4..f51620b 100644
--- a/examples/devinfo.c
+++ b/examples/devinfo.c
@@ -209,6 +209,7 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t 
ib_port)
struct ibv_port_attr port_attr;
int rc = 0;
uint8_t port;
+   uint32_t max_datagram;
char buf[256];
 
ctx = ibv_open_device(ib_dev);
@@ -298,6 +299,11 @@ static int print_hca_cap(struct ibv_device *ib_dev, 
uint8_t ib_port)
fprintf(stderr, Failed to query port %u props\n, 
port);
goto cleanup;
}
+   rc = uv_query_port_max_datagram(ctx, port, max_datagram);
+   if (rc) {
+   fprintf(stderr, Failed to query port %u max datagram 
size\n, port);
+   goto cleanup;
+   }
printf(\t\tport:\t%d\n, port);
printf(\t\t\tstate:\t\t\t%s (%d)\n,
   port_state_str(port_attr.state), port_attr.state);
@@ -305,6 +311,7 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t 
ib_port)
   mtu_str(port_attr.max_mtu), port_attr.max_mtu);
printf(\t\t\tactive_mtu:\t\t%s (%d)\n,
   mtu_str(port_attr.active_mtu), port_attr.active_mtu);
+   printf(\t\t\tmax_datagram_size:\t%u\n, max_datagram);
printf(\t\t\tsm_lid:\t\t\t%d\n, port_attr.sm_lid);
printf(\t\t\tport_lid:\t\t%d\n, port_attr.lid);
printf(\t\t\tport_lmc:\t\t0x%02x\n, port_attr.lmc);
diff --git a/include/infiniband/driver.h b/include/infiniband/driver.h
index 9a81416..6e1236c 100644
--- a/include/infiniband/driver.h
+++ b/include/infiniband/driver.h
@@ -67,6 +67,10 @@ int ibv_cmd_query_device(struct ibv_context *context,
 int ibv_cmd_query_port(struct ibv_context *context, uint8_t port_num,
   struct ibv_port_attr *port_attr,
   struct ibv_query_port *cmd, size_t cmd_size);
+int uv_cmd_query_port_max_datagram(struct ibv_context *context, uint8_t 
port_num,
+  uint32_t *max_datagram,
+  struct uv_query_port_max_datagram *cmd,
+  size_t cmd_size);
 int ibv_cmd_query_gid(struct