components/open-fabrics/libibverbs/patches/base.patch
branchs11-update
changeset 2532 5b3dc1c8b85e
parent 2448 c1b40b77a1ae
child 2550 02b339f70efd
equal deleted inserted replaced
2531:86ae973f1705 2532:5b3dc1c8b85e
   170  .I device\fR.
   170  .I device\fR.
   171  .SH "RETURN VALUE"
   171  .SH "RETURN VALUE"
   172  .B ibv_get_device_guid()
   172  .B ibv_get_device_guid()
   173 diff -r -u /tmp/846623/libibverbs-1.1.4/man/ibv_post_send.3 libibverbs-1.1.4/man/ibv_post_send.3
   173 diff -r -u /tmp/846623/libibverbs-1.1.4/man/ibv_post_send.3 libibverbs-1.1.4/man/ibv_post_send.3
   174 --- /tmp/846623/libibverbs-1.1.4/man/ibv_post_send.3	Thu Mar 10 06:58:20 2011
   174 --- /tmp/846623/libibverbs-1.1.4/man/ibv_post_send.3	Thu Mar 10 06:58:20 2011
   175 +++ libibverbs-1.1.4/man/ibv_post_send.3	Wed Dec  5 15:44:51 2012
   175 +++ libibverbs-1.1.4/man/ibv_post_send.3	Thu Dec  6 13:50:27 2012
   176 @@ -91,14 +91,17 @@
   176 @@ -91,14 +91,17 @@
   177  The attribute send_flags describes the properties of the \s-1WR\s0. It is either 0 or the bitwise \s-1OR\s0 of one or more of the following flags:
   177  The attribute send_flags describes the properties of the \s-1WR\s0. It is either 0 or the bitwise \s-1OR\s0 of one or more of the following flags:
   178  .PP
   178  .PP
   179  .TP
   179  .TP
   180 -.B IBV_SEND_FENCE \fR Set the fence indicator.  Valid only for QPs with Transport Service Type \fBIBV_QPT_RC
   180 -.B IBV_SEND_FENCE \fR Set the fence indicator.  Valid only for QPs with Transport Service Type \fBIBV_QPT_RC
   218 -waits for the next async event of the RDMA device context
   218 -waits for the next async event of the RDMA device context
   219 +waits for the next async event of the InfiniBand device context
   219 +waits for the next async event of the InfiniBand device context
   220  .I context
   220  .I context
   221  and returns it through the pointer
   221  and returns it through the pointer
   222  .I event\fR,
   222  .I event\fR,
       
   223 @@ -29,6 +29,8 @@
       
   224  struct ibv_qp  *qp;             /* QP that got the event */
       
   225  struct ibv_srq *srq;            /* SRQ that got the event */
       
   226  int             port_num;       /* port number that got the event */
       
   227 +uint32_t        xrc_qp_num;     /* XRC QP that got the event */
       
   228 +union ibv_gid   gid;            /* list of guids that got the event */
       
   229  .in -8
       
   230  } element;
       
   231  enum ibv_event_type     event_type;     /* type of the event */
       
   232 @@ -86,6 +88,16 @@
       
   233  .TP
       
   234  .B IBV_EVENT_DEVICE_FATAL \fR CA is in FATAL state
       
   235  .PP
       
   236 +.I Subnet events:
       
   237 +.TP
       
   238 +.B IBV_SM_EVENT_MCG_CREATED \fR notification of MCG creation
       
   239 +.TP
       
   240 +.B IBV_SM_EVENT_MCG_DELETED \fR notification of MCG deletion
       
   241 +.TP
       
   242 +.B IBV_SM_EVENT_GID_AVAIL \fR notification of GID available events
       
   243 +.TP
       
   244 +.B IBV_SM_EVENT_GID_UNAVAIL \fR notification of GID unavailable events
       
   245 +.PP
       
   246  .B ibv_ack_async_event()
       
   247  acknowledge the async event
       
   248  .I event\fR.
   223 diff -r -u /tmp/846623/libibverbs-1.1.4/man/ibv_get_device_list.3 libibverbs-1.1.4/man/ibv_get_device_list.3
   249 diff -r -u /tmp/846623/libibverbs-1.1.4/man/ibv_get_device_list.3 libibverbs-1.1.4/man/ibv_get_device_list.3
   224 --- /tmp/846623/libibverbs-1.1.4/man/ibv_get_device_list.3	Thu Mar 10 04:51:46 2011
   250 --- /tmp/846623/libibverbs-1.1.4/man/ibv_get_device_list.3	Thu Mar 10 04:51:46 2011
   225 +++ libibverbs-1.1.4/man/ibv_get_device_list.3	Mon Mar 28 03:11:46 2011
   251 +++ libibverbs-1.1.4/man/ibv_get_device_list.3	Mon Mar 28 03:11:46 2011
   226 @@ -2,7 +2,7 @@
   252 @@ -2,7 +2,7 @@
   227  .\"
   253  .\"
   275  .nf
   301  .nf
   276  .B #include <infiniband/verbs.h>
   302  .B #include <infiniband/verbs.h>
   277 diff -r -u /tmp/846623/libibverbs-1.1.4/man/ibv_asyncwatch.1 libibverbs-1.1.4/man/ibv_asyncwatch.1
   303 diff -r -u /tmp/846623/libibverbs-1.1.4/man/ibv_asyncwatch.1 libibverbs-1.1.4/man/ibv_asyncwatch.1
   278 --- /tmp/846623/libibverbs-1.1.4/man/ibv_asyncwatch.1	Thu Mar 10 04:51:46 2011
   304 --- /tmp/846623/libibverbs-1.1.4/man/ibv_asyncwatch.1	Thu Mar 10 04:51:46 2011
   279 +++ libibverbs-1.1.4/man/ibv_asyncwatch.1	Mon Mar 28 03:11:45 2011
   305 +++ libibverbs-1.1.4/man/ibv_asyncwatch.1	Mon Mar 28 03:11:45 2011
   280 @@ -8,7 +8,7 @@
   306 @@ -1,16 +1,78 @@
   281  
   307 -.TH IBV_ASYNCWATCH 1 "August 30, 2005" "libibverbs" "USER COMMANDS"
       
   308 +'\" te
       
   309 +.TH IBV_ASYNCWATCH 1 "August 8, 2012" "libibverbs" "USER COMMANDS"
       
   310  
       
   311  .SH NAME
       
   312  ibv_asyncwatch \- display asynchronous events
       
   313  
       
   314  .SH SYNOPSIS
       
   315 -.B ibv_asyncwatch
       
   316 -
       
   317 +.sp
       
   318 +.nf
       
   319 +\fIibv_asyncwatch\fR [\-G | \-M] [\-s[<guid>]] [\-p port]
       
   320 +\fIibv_asyncwactch\fR \-s
       
   321 +\fIibv_asyncwatch\fR \-G \-s
       
   322 +\fIibv_asyncwatch\fR \-M \-s
       
   323 +\fIibv_asyncwatch\fR \-G [\-p port] \-s<guid1>,<guid2>,...
       
   324 +\fIibv_asyncwatch\fR \-M [\-p port] \-s<mgid1>,<mgid2>,...
       
   325 +.fi
       
   326 +.sp
   282  .SH DESCRIPTION
   327  .SH DESCRIPTION
   283  .PP
   328  .PP
   284 -Display asynchronous events forwarded to userspace for an RDMA device.
   329 -Display asynchronous events forwarded to userspace for an RDMA device.
   285 +Display asynchronous events forwarded to userspace for an InfiniBand device.
   330 +Display asynchronous events forwarded to userspace for an InfiniBand device.
   286  
   331 +SM events can be monitored using the '-s' option, which optionally
   287  .SH AUTHORS
   332 +takes a remote port GUID, or list of remote port GUIDS separated by ','.
   288  .TP
   333 +If '-s' is specified with no argument then all remote nodes reachable
       
   334 +form device 0 are monitored, otherwise only the specified remote
       
   335 +nodes are monitored. The following SM events are monitored using
       
   336 +the '-s' option: 
       
   337  
       
   338 -.SH AUTHORS
       
   339 -.TP
       
   340 -Roland Dreier
       
   341 -.RI < [email protected] >
       
   342 +    IBV_SM_EVENT_MCG_CREATED
       
   343 +         An MCG specified by the "mgid" has been created
       
   344 +         on this subnet.
       
   345 +
       
   346 +    IBV_SM_EVENT_MCG_DELETED
       
   347 +         The MCG specified by the "mgid" has been deleted
       
   348 +         on this subnet.
       
   349 +
       
   350 +    IBV_SM_EVENT_GID_AVAIL
       
   351 +         The GID specified by the "guid" is available
       
   352 +         on this subnet.
       
   353 +
       
   354 +    IBV_SM_EVENT_GID_UNAVAIL
       
   355 +         The GID specified by the "guid" is no longer
       
   356 +         available on this subnet.
       
   357 +
       
   358 +.SH OPTIONS
       
   359 +.pp
       
   360 +\-G               Monitor SM event for Unicast GIDs
       
   361 +.sp
       
   362 +.pp
       
   363 +\-M               Monitor SM event for Multicast GIDs
       
   364 +.pp
       
   365 +\-s<GUID>         Takes as an optional argument a comma separated list of remote port GUIDs if \-G is specified or Multicast GIDs if \-M is specified.
       
   366 +.sp
       
   367 +.PP
       
   368 +\-p <port>        use the specified ca_port.
       
   369 +.sp
       
   370 +.pp
       
   371 +.SH EXAMPLES
       
   372 +.PP
       
   373 +To monitor event=IBV_SM_EVENT_ALL
       
   374 +.sp
       
   375 +ibv_asyncwatch -s
       
   376 +.sp
       
   377 +To monitor event=IBV_SM_EVENT_UGID_ALL
       
   378 +.sp
       
   379 +ibv_asyncwatch -G -s
       
   380 +.sp
       
   381 +To monitor event=IBV_SM_EVENT_MGID_ALL
       
   382 +.sp
       
   383 +ibv_asyncwatch -M -s
       
   384 +.sp
       
   385 +To monitor event=IBV_SM_EVENT_UGID
       
   386 +.sp
       
   387 +ibv_asyncwatch -G -s0x0021280001a0e4d9,0x0021280001a0e4da
       
   388 +.sp
       
   389 +To monitor event=IBV_SM_EVENT_MGID
       
   390 +.sp
       
   391 +ibv_asyncwatch -M -s0xff12:4001:ffff::c:2238
       
   392 +.sp
   289 diff -r -u /tmp/846623/libibverbs-1.1.4/man/ibv_open_device.3 libibverbs-1.1.4/man/ibv_open_device.3
   393 diff -r -u /tmp/846623/libibverbs-1.1.4/man/ibv_open_device.3 libibverbs-1.1.4/man/ibv_open_device.3
   290 --- /tmp/846623/libibverbs-1.1.4/man/ibv_open_device.3	Thu Mar 10 04:51:46 2011
   394 --- /tmp/846623/libibverbs-1.1.4/man/ibv_open_device.3	Thu Mar 10 04:51:46 2011
   291 +++ libibverbs-1.1.4/man/ibv_open_device.3	Mon Mar 28 03:11:46 2011
   395 +++ libibverbs-1.1.4/man/ibv_open_device.3	Mon Mar 28 03:11:46 2011
   292 @@ -2,7 +2,7 @@
   396 @@ -2,7 +2,7 @@
   293  .\"
   397  .\"
   471 +
   575 +
   472 +#else
   576 +#else
   473  	char name[24];
   577  	char name[24];
   474  	char attr[8];
   578  	char attr[8];
   475  	uint16_t val;
   579  	uint16_t val;
   476 @@ -133,6 +151,7 @@
   580 @@ -133,9 +151,142 @@
   477  
   581  
   478  	*pkey = htons(val);
   582  	*pkey = htons(val);
   479  	return 0;
   583  	return 0;
   480 +#endif
   584 +#endif
   481  }
   585  }
   482  default_symver(__ibv_query_pkey, ibv_query_pkey);
   586  default_symver(__ibv_query_pkey, ibv_query_pkey);
   483  
   587  
   484 @@ -148,6 +167,27 @@
   588 +int ibv_register_sm_events(struct ibv_context *context,
       
   589 +    ibv_sm_event_type_t event, uint_t gid_num, union ibv_gid *gids)
       
   590 +{
       
   591 +	struct ibv_reg_sm_event		*cmd;
       
   592 +	int				rc, cmd_size, data_size;
       
   593 +	void				*data_p;
       
   594 +
       
   595 +	if (((gid_num > 0) && (gids == NULL)) ||
       
   596 +	   ((gid_num == 0) && (gids != NULL))) {
       
   597 +		errno = EINVAL;
       
   598 +		return (-1);
       
   599 +	}
       
   600 +
       
   601 +	if ((event != IBV_SM_EVENT_UGID) && (event != IBV_SM_EVENT_UGID_ALL) &&
       
   602 +	    (event != IBV_SM_EVENT_MGID) && (event != IBV_SM_EVENT_MGID_ALL) &&
       
   603 +	    (event != IBV_SM_EVENT_ALL)) {
       
   604 +		errno = EINVAL;
       
   605 +		return (-1);
       
   606 +	}
       
   607 +
       
   608 +	if (((event == IBV_SM_EVENT_UGID) || (event == IBV_SM_EVENT_MGID)) &&
       
   609 +	    (gid_num == 0)) {
       
   610 +		errno = EINVAL;
       
   611 +		return (-1);
       
   612 +	}
       
   613 +
       
   614 +	if (((event == IBV_SM_EVENT_UGID_ALL) ||
       
   615 +	    (event == IBV_SM_EVENT_MGID_ALL) || (event == IBV_SM_EVENT_ALL)) &&
       
   616 +	    (gid_num != 0)) {
       
   617 +		errno = EINVAL;
       
   618 +		return (-1);
       
   619 +	}
       
   620 +
       
   621 +	data_size = gid_num * (sizeof (union ibv_gid));
       
   622 +	cmd_size = (sizeof (struct ibv_reg_sm_event)) + data_size;
       
   623 +	data_p = (void *)gids;
       
   624 +	cmd  = alloca(cmd_size);
       
   625 +	cmd->data_num = gid_num;
       
   626 +
       
   627 +	IBV_INIT_CMD(cmd, cmd_size, REG_SM_EVENT);
       
   628 +
       
   629 +	cmd->events = event;
       
   630 +	if (gid_num > 0)
       
   631 +		memcpy(cmd->driver_data, data_p, data_size);
       
   632 +
       
   633 +	rc = write(context->cmd_fd, cmd, cmd_size);
       
   634 +	if (rc < 0) {
       
   635 +		errno = -rc;
       
   636 +		rc = -1;
       
   637 +	}
       
   638 +
       
   639 +	return (rc);
       
   640 +}
       
   641 +
       
   642 +int ibv_unregister_sm_events(struct ibv_context *context,
       
   643 +    ibv_sm_event_type_t event, uint_t gid_num, union ibv_gid *gids)
       
   644 +{
       
   645 +	struct ibv_unreg_sm_event	*cmd;
       
   646 +	int				rc, cmd_size, data_size;
       
   647 +	void				*data_p;
       
   648 +
       
   649 +	if (((gid_num > 0) && (gids == NULL)) ||
       
   650 +	   ((gid_num == 0) && (gids != NULL))) {
       
   651 +		errno = EINVAL;
       
   652 +		return (-1);
       
   653 +	}
       
   654 +
       
   655 +	if ((event != IBV_SM_EVENT_UGID) && (event != IBV_SM_EVENT_UGID_ALL) &&
       
   656 +	    (event != IBV_SM_EVENT_MGID) && (event != IBV_SM_EVENT_MGID_ALL) &&
       
   657 +	    (event != IBV_SM_EVENT_ALL)) {
       
   658 +		errno = EINVAL;
       
   659 +		return (-1);
       
   660 +	}
       
   661 +
       
   662 +	if (((event == IBV_SM_EVENT_UGID) || (event == IBV_SM_EVENT_MGID)) &&
       
   663 +	    (gid_num == 0)) {
       
   664 +		errno = EINVAL;
       
   665 +		return (-1);
       
   666 +	}
       
   667 +
       
   668 +	if (((event == IBV_SM_EVENT_UGID_ALL) ||
       
   669 +	    (event == IBV_SM_EVENT_MGID_ALL) || (event == IBV_SM_EVENT_ALL)) &&
       
   670 +	    (gid_num != 0)) {
       
   671 +		errno = EINVAL;
       
   672 +		return (-1);
       
   673 +	}
       
   674 +
       
   675 +	data_size = gid_num*(sizeof (union ibv_gid));
       
   676 +	cmd_size = (sizeof (struct ibv_unreg_sm_event)) + data_size;
       
   677 +	data_p = (void *)gids;
       
   678 +	cmd  = alloca(cmd_size);
       
   679 +	cmd->data_num = gid_num;
       
   680 +
       
   681 +	IBV_INIT_CMD(cmd, cmd_size, UNREG_SM_EVENT);
       
   682 +
       
   683 +	cmd->events = event;
       
   684 +	if (gid_num > 0)
       
   685 +		memcpy(cmd->driver_data, data_p, data_size);
       
   686 +
       
   687 +	rc = write(context->cmd_fd, cmd, cmd_size);
       
   688 +	if (rc < 0) {
       
   689 +		errno = -rc;
       
   690 +		rc = -1;
       
   691 +	}
       
   692 +
       
   693 +	return (rc);
       
   694 +}
       
   695 +
       
   696 +int ibv_gid_reachable(struct ibv_context *context,
       
   697 +    uint_t port, union ibv_gid *gid_p, int timeout)
       
   698 +{
       
   699 +	struct ibv_gid_reachable	*cmd;
       
   700 +	int				rc;
       
   701 +
       
   702 +	cmd = alloca((sizeof (struct ibv_gid_reachable)));
       
   703 +	cmd->port_num = port;
       
   704 +	cmd->timeout = timeout;
       
   705 +
       
   706 +	IBV_INIT_CMD(cmd, sizeof (struct ibv_gid_reachable),
       
   707 +	    GID_REACHABLE);
       
   708 +
       
   709 +	memcpy(cmd->gid, gid_p, sizeof (*gid_p));
       
   710 +
       
   711 +	rc = write(context->cmd_fd, cmd, sizeof(struct ibv_gid_reachable));
       
   712 +	if (rc < 0) {
       
   713 +		errno = -rc;
       
   714 +		rc = -1;
       
   715 +	}
       
   716 +
       
   717 +	return (rc);
       
   718 +}
       
   719 +
       
   720  struct ibv_pd *__ibv_alloc_pd(struct ibv_context *context)
       
   721  {
       
   722  	struct ibv_pd *pd;
       
   723 @@ -148,6 +299,27 @@
   485  }
   724  }
   486  default_symver(__ibv_alloc_pd, ibv_alloc_pd);
   725  default_symver(__ibv_alloc_pd, ibv_alloc_pd);
   487  
   726  
   488 +struct ibv_shpd *__ibv_alloc_shpd(struct ibv_pd *pd, uint64_t share_key, struct ibv_shpd *shpd)
   727 +struct ibv_shpd *__ibv_alloc_shpd(struct ibv_pd *pd, uint64_t share_key, struct ibv_shpd *shpd)
   489 +{
   728 +{
   507 +default_symver(__ibv_share_pd, ibv_share_pd);
   746 +default_symver(__ibv_share_pd, ibv_share_pd);
   508 +
   747 +
   509  int __ibv_dealloc_pd(struct ibv_pd *pd)
   748  int __ibv_dealloc_pd(struct ibv_pd *pd)
   510  {
   749  {
   511  	return pd->context->ops.dealloc_pd(pd);
   750  	return pd->context->ops.dealloc_pd(pd);
   512 @@ -175,6 +215,27 @@
   751 @@ -175,6 +347,27 @@
   513  }
   752  }
   514  default_symver(__ibv_reg_mr, ibv_reg_mr);
   753  default_symver(__ibv_reg_mr, ibv_reg_mr);
   515  
   754  
   516 +struct ibv_mr *__ibv_reg_mr_relaxed(struct ibv_pd *pd, void *addr,
   755 +struct ibv_mr *__ibv_reg_mr_relaxed(struct ibv_pd *pd, void *addr,
   517 +			    size_t length, int access)
   756 +			    size_t length, int access)
   535 +default_symver(__ibv_reg_mr_relaxed, ibv_reg_mr_relaxed);
   774 +default_symver(__ibv_reg_mr_relaxed, ibv_reg_mr_relaxed);
   536 +
   775 +
   537  int __ibv_dereg_mr(struct ibv_mr *mr)
   776  int __ibv_dereg_mr(struct ibv_mr *mr)
   538  {
   777  {
   539  	int ret;
   778  	int ret;
   540 @@ -189,6 +250,26 @@
   779 @@ -189,6 +382,26 @@
   541  }
   780  }
   542  default_symver(__ibv_dereg_mr, ibv_dereg_mr);
   781  default_symver(__ibv_dereg_mr, ibv_dereg_mr);
   543  
   782  
   544 +int __ibv_dereg_mr_relaxed(struct ibv_mr *mr)
   783 +int __ibv_dereg_mr_relaxed(struct ibv_mr *mr)
   545 +{
   784 +{
   562 +default_symver(__ibv_flush_relaxed_mr, ibv_flush_relaxed_mr);
   801 +default_symver(__ibv_flush_relaxed_mr, ibv_flush_relaxed_mr);
   563 +
   802 +
   564  static struct ibv_comp_channel *ibv_create_comp_channel_v2(struct ibv_context *context)
   803  static struct ibv_comp_channel *ibv_create_comp_channel_v2(struct ibv_context *context)
   565  {
   804  {
   566  	struct ibv_abi_compat_v2 *t = context->abi_compat;
   805  	struct ibv_abi_compat_v2 *t = context->abi_compat;
   567 @@ -212,6 +293,10 @@
   806 @@ -212,6 +425,10 @@
   568  	struct ibv_comp_channel            *channel;
   807  	struct ibv_comp_channel            *channel;
   569  	struct ibv_create_comp_channel      cmd;
   808  	struct ibv_create_comp_channel      cmd;
   570  	struct ibv_create_comp_channel_resp resp;
   809  	struct ibv_create_comp_channel_resp resp;
   571 +#if defined(__SVR4) && defined(__sun)
   810 +#if defined(__SVR4) && defined(__sun)
   572 +	int		event_fd;
   811 +	int		event_fd;
   573 +	struct stat	fstat_buf;
   812 +	struct stat	fstat_buf;
   574 +#endif
   813 +#endif
   575  
   814  
   576  	if (abi_ver <= 2)
   815  	if (abi_ver <= 2)
   577  		return ibv_create_comp_channel_v2(context);
   816  		return ibv_create_comp_channel_v2(context);
   578 @@ -221,7 +306,23 @@
   817 @@ -221,7 +438,23 @@
   579  		return NULL;
   818  		return NULL;
   580  
   819  
   581  	IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_COMP_CHANNEL, &resp, sizeof resp);
   820  	IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_COMP_CHANNEL, &resp, sizeof resp);
   582 +#if defined(__SVR4) && defined(__sun)
   821 +#if defined(__SVR4) && defined(__sun)
   583 +	event_fd = open("/dev/infiniband/ofs/uverbs:event", O_RDWR);
   822 +	event_fd = open("/dev/infiniband/ofs/uverbs:event", O_RDWR);
   597 +		close(event_fd);
   836 +		close(event_fd);
   598 +#endif
   837 +#endif
   599  		free(channel);
   838  		free(channel);
   600  		return NULL;
   839  		return NULL;
   601  	}
   840  	}
   602 @@ -228,6 +329,9 @@
   841 @@ -228,6 +461,9 @@
   603  
   842  
   604  	VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
   843  	VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
   605  
   844  
   606 +#if defined(__SVR4) && defined(__sun)
   845 +#if defined(__SVR4) && defined(__sun)
   607 +	resp.fd = event_fd;
   846 +	resp.fd = event_fd;
   675 +	}
   914 +	}
   676 +#endif
   915 +#endif
   677  	close(async_fd);
   916  	close(async_fd);
   678  	close(cmd_fd);
   917  	close(cmd_fd);
   679  	if (abi_ver <= 2)
   918  	if (abi_ver <= 2)
       
   919 @@ -214,6 +249,15 @@
       
   920  		case IBV_EVENT_SRQ_LIMIT_REACHED:
       
   921  			event->element.srq = (void *) (uintptr_t) ev.element;
       
   922  			break;
       
   923 +		case IBV_EVENT_GID_AVAIL:
       
   924 +		case IBV_EVENT_GID_UNAVAIL:
       
   925 +		case IBV_EVENT_MCG_CREATED:
       
   926 +		case IBV_EVENT_MCG_DELETED:
       
   927 +			event->element.gid.global.subnet_prefix
       
   928 +			    = ev.subnet_prefix;
       
   929 +                        event->element.gid.global.interface_id
       
   930 +			    = ev.interface_id;
       
   931 +			break;
       
   932  		default:
       
   933  			event->element.port_num = ev.element;
       
   934  			break;
   680 diff -r -u /tmp/846623/libibverbs-1.1.4/src/ibverbs.h libibverbs-1.1.4/src/ibverbs.h
   935 diff -r -u /tmp/846623/libibverbs-1.1.4/src/ibverbs.h libibverbs-1.1.4/src/ibverbs.h
   681 --- /tmp/846623/libibverbs-1.1.4/src/ibverbs.h	Wed Sep 16 04:27:22 2009
   936 --- /tmp/846623/libibverbs-1.1.4/src/ibverbs.h	Wed Sep 16 04:27:22 2009
   682 +++ libibverbs-1.1.4/src/ibverbs.h	Fri Feb 11 04:02:31 2011
   937 +++ libibverbs-1.1.4/src/ibverbs.h	Fri Feb 11 04:02:31 2011
   683 @@ -52,7 +52,12 @@
   938 @@ -52,7 +52,12 @@
   684  #  define VALGRIND_MAKE_MEM_DEFINED(addr, len)
   939  #  define VALGRIND_MAKE_MEM_DEFINED(addr, len)
   695  #define INIT		__attribute__((constructor))
   950  #define INIT		__attribute__((constructor))
   696  #define FINI		__attribute__((destructor))
   951  #define FINI		__attribute__((destructor))
   697 diff -r -u /tmp/846623/libibverbs-1.1.4/src/libibverbs.map libibverbs-1.1.4/src/libibverbs.map
   952 diff -r -u /tmp/846623/libibverbs-1.1.4/src/libibverbs.map libibverbs-1.1.4/src/libibverbs.map
   698 --- /tmp/846623/libibverbs-1.1.4/src/libibverbs.map	Thu Mar 10 06:58:21 2011
   953 --- /tmp/846623/libibverbs-1.1.4/src/libibverbs.map	Thu Mar 10 06:58:21 2011
   699 +++ libibverbs-1.1.4/src/libibverbs.map	Mon Mar 28 13:44:44 2011
   954 +++ libibverbs-1.1.4/src/libibverbs.map	Mon Mar 28 13:44:44 2011
   700 @@ -13,9 +13,14 @@
   955 @@ -12,10 +12,18 @@
       
   956  		ibv_query_port;
   701  		ibv_query_gid;
   957  		ibv_query_gid;
   702  		ibv_query_pkey;
   958  		ibv_query_pkey;
       
   959 +		ibv_register_sm_events;
       
   960 +		ibv_unregister_sm_events;
       
   961 +		ibv__gid_reachable;
   703  		ibv_alloc_pd;
   962  		ibv_alloc_pd;
   704 +		ibv_alloc_shpd;
   963 +		ibv_alloc_shpd;
   705 +		ibv_share_pd;
   964 +		ibv_share_pd;
   706  		ibv_dealloc_pd;
   965  		ibv_dealloc_pd;
   707  		ibv_reg_mr;
   966  		ibv_reg_mr;
   710 +		ibv_dereg_mr_relaxed;
   969 +		ibv_dereg_mr_relaxed;
   711 +		ibv_flush_relaxed_mr;
   970 +		ibv_flush_relaxed_mr;
   712  		ibv_create_comp_channel;
   971  		ibv_create_comp_channel;
   713  		ibv_destroy_comp_channel;
   972  		ibv_destroy_comp_channel;
   714  		ibv_create_cq;
   973  		ibv_create_cq;
   715 @@ -41,9 +46,14 @@
   974 @@ -41,9 +49,14 @@
   716  		ibv_cmd_query_gid;
   975  		ibv_cmd_query_gid;
   717  		ibv_cmd_query_pkey;
   976  		ibv_cmd_query_pkey;
   718  		ibv_cmd_alloc_pd;
   977  		ibv_cmd_alloc_pd;
   719 +		ibv_cmd_alloc_shpd;
   978 +		ibv_cmd_alloc_shpd;
   720 +		ibv_cmd_share_pd;
   979 +		ibv_cmd_share_pd;
   725 +		ibv_cmd_dereg_mr_relaxed;
   984 +		ibv_cmd_dereg_mr_relaxed;
   726 +		ibv_cmd_flush_relaxed_mr;
   985 +		ibv_cmd_flush_relaxed_mr;
   727  		ibv_cmd_create_cq;
   986  		ibv_cmd_create_cq;
   728  		ibv_cmd_poll_cq;
   987  		ibv_cmd_poll_cq;
   729  		ibv_cmd_req_notify_cq;
   988  		ibv_cmd_req_notify_cq;
   730 @@ -71,6 +81,7 @@
   989 @@ -71,6 +84,7 @@
   731  		mult_to_ibv_rate;
   990  		mult_to_ibv_rate;
   732  		ibv_get_sysfs_path;
   991  		ibv_get_sysfs_path;
   733  		ibv_read_sysfs_file;
   992  		ibv_read_sysfs_file;
   734 +		sol_get_cpu_info;
   993 +		sol_get_cpu_info;
   735  
   994  
  1101  
  1360  
  1102  static void add_device(struct ibv_device *dev,
  1361  static void add_device(struct ibv_device *dev,
  1103 diff -r -u /tmp/846623/libibverbs-1.1.4/src/enum_strs.c libibverbs-1.1.4/src/enum_strs.c
  1362 diff -r -u /tmp/846623/libibverbs-1.1.4/src/enum_strs.c libibverbs-1.1.4/src/enum_strs.c
  1104 --- /tmp/846623/libibverbs-1.1.4/src/enum_strs.c	Wed Sep 16 04:27:22 2009
  1363 --- /tmp/846623/libibverbs-1.1.4/src/enum_strs.c	Wed Sep 16 04:27:22 2009
  1105 +++ libibverbs-1.1.4/src/enum_strs.c	Tue Mar 20 16:27:45 2012
  1364 +++ libibverbs-1.1.4/src/enum_strs.c	Tue Mar 20 16:27:45 2012
  1106 @@ -85,6 +85,7 @@
  1365 @@ -85,9 +85,14 @@
  1107  		[IBV_EVENT_SRQ_LIMIT_REACHED]	= "SRQ limit reached",
  1366  		[IBV_EVENT_SRQ_LIMIT_REACHED]	= "SRQ limit reached",
  1108  		[IBV_EVENT_QP_LAST_WQE_REACHED]	= "last WQE reached",
  1367  		[IBV_EVENT_QP_LAST_WQE_REACHED]	= "last WQE reached",
  1109  		[IBV_EVENT_CLIENT_REREGISTER]	= "client reregistration",
  1368  		[IBV_EVENT_CLIENT_REREGISTER]	= "client reregistration",
  1110 +		[IBV_EVENT_GID_CHANGE]		= "GID change",
  1369 +		[IBV_EVENT_GID_CHANGE]		= "GID change",
       
  1370 +		[IBV_EVENT_MCG_CREATED]		= "MCG created",
       
  1371 +		[IBV_EVENT_MCG_DELETED]		= "MCG deleted",
       
  1372 +		[IBV_EVENT_GID_AVAIL]		= "GID available",
       
  1373 +		[IBV_EVENT_GID_UNAVAIL]		= "GID unavailable",
  1111  	};
  1374  	};
  1112  
  1375  
  1113  	if (event < IBV_EVENT_CQ_ERR || event > IBV_EVENT_CLIENT_REREGISTER)
  1376 -	if (event < IBV_EVENT_CQ_ERR || event > IBV_EVENT_CLIENT_REREGISTER)
       
  1377 +	if (event < IBV_EVENT_CQ_ERR || event > IBV_EVENT_GID_UNAVAIL)
       
  1378  		return "unknown";
       
  1379  
       
  1380  	return event_type_str[event];
  1114 diff -r -u /tmp/846623/libibverbs-1.1.4/src/sysfs.c libibverbs-1.1.4/src/sysfs.c
  1381 diff -r -u /tmp/846623/libibverbs-1.1.4/src/sysfs.c libibverbs-1.1.4/src/sysfs.c
  1115 --- /tmp/846623/libibverbs-1.1.4/src/sysfs.c	Wed Sep 16 04:27:22 2009
  1382 --- /tmp/846623/libibverbs-1.1.4/src/sysfs.c	Wed Sep 16 04:27:22 2009
  1116 +++ libibverbs-1.1.4/src/sysfs.c	Fri Feb 11 04:02:33 2011
  1383 +++ libibverbs-1.1.4/src/sysfs.c	Fri Feb 11 04:02:33 2011
  1117 @@ -44,6 +44,10 @@
  1384 @@ -44,6 +44,10 @@
  1118  
  1385  
  1275 +#include <infiniband/ofa_solaris.h>
  1542 +#include <infiniband/ofa_solaris.h>
  1276 +#endif
  1543 +#endif
  1277  
  1544  
  1278  /*
  1545  /*
  1279   * This file must be kept in sync with the kernel's version of
  1546   * This file must be kept in sync with the kernel's version of
  1280 @@ -94,6 +98,11 @@
  1547 @@ -94,6 +98,14 @@
  1281  	IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP,
  1548  	IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP,
  1282  	IB_USER_VERBS_CMD_REG_XRC_RCV_QP,
  1549  	IB_USER_VERBS_CMD_REG_XRC_RCV_QP,
  1283  	IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP,
  1550  	IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP,
  1284 +	IB_USER_VERBS_CMD_REG_MR_RELAXED,
  1551 +	IB_USER_VERBS_CMD_REG_MR_RELAXED,
  1285 +	IB_USER_VERBS_CMD_DEREG_MR_RELAXED,
  1552 +	IB_USER_VERBS_CMD_DEREG_MR_RELAXED,
  1286 +	IB_USER_VERBS_CMD_FLUSH_RELAXED_MR,
  1553 +	IB_USER_VERBS_CMD_FLUSH_RELAXED_MR,
  1287 +	IB_USER_VERBS_CMD_ALLOC_SHPD,
  1554 +	IB_USER_VERBS_CMD_ALLOC_SHPD,
  1288 +	IB_USER_VERBS_CMD_SHARE_PD
  1555 +	IB_USER_VERBS_CMD_SHARE_PD,
       
  1556 +	IB_USER_VERBS_CMD_REG_SM_EVENT,
       
  1557 +	IB_USER_VERBS_CMD_UNREG_SM_EVENT,
       
  1558 +	IB_USER_VERBS_CMD_GID_REACHABLE
  1289  };
  1559  };
  1290  
  1560  
  1291  /*
  1561  /*
  1292 @@ -160,6 +169,7 @@
  1562 @@ -111,6 +123,8 @@
       
  1563  	__u64 element;
       
  1564  	__u32 event_type;
       
  1565  	__u32 reserved;
       
  1566 +	__u64 subnet_prefix;
       
  1567 +	__u64 interface_id;
       
  1568  };
       
  1569  
       
  1570  struct ibv_comp_event {
       
  1571 @@ -160,6 +174,7 @@
  1293  struct ibv_query_device_resp {
  1572  struct ibv_query_device_resp {
  1294  	__u64 fw_ver;
  1573  	__u64 fw_ver;
  1295  	__u64 node_guid;
  1574  	__u64 node_guid;
  1296 +	__u64 node_guid_external;
  1575 +	__u64 node_guid_external;
  1297  	__u64 sys_image_guid;
  1576  	__u64 sys_image_guid;
  1298  	__u64 max_mr_size;
  1577  	__u64 max_mr_size;
  1299  	__u64 page_size_cap;
  1578  	__u64 page_size_cap;
  1300 @@ -243,10 +253,57 @@
  1579 @@ -235,6 +250,34 @@
       
  1580  	__u8  reserved[2];
       
  1581  };
       
  1582  
       
  1583 +struct ibv_reg_sm_event {
       
  1584 +	__u32 command;
       
  1585 +	__u16 in_words;
       
  1586 +	__u16 out_words;
       
  1587 +	__u32 events;
       
  1588 +	__u32 data_num;
       
  1589 +	__u64 driver_data[0];
       
  1590 +};
       
  1591 +
       
  1592 +struct ibv_unreg_sm_event {
       
  1593 +	__u32 command;
       
  1594 +	__u16 in_words;
       
  1595 +	__u16 out_words;
       
  1596 +	__u32 events;
       
  1597 +	__u32 data_num;
       
  1598 +	__u64 driver_data[0];
       
  1599 +};
       
  1600 +
       
  1601 +struct ibv_gid_reachable {
       
  1602 +	__u32 command;
       
  1603 +	__u16 in_words;
       
  1604 +	__u16 out_words;
       
  1605 +	__u32 timeout;
       
  1606 +	__u8  port_num;
       
  1607 +	__u8  reserved[3];
       
  1608 +	__u8  gid[16];
       
  1609 +};
       
  1610 +
       
  1611  struct ibv_alloc_pd {
       
  1612  	__u32 command;
       
  1613  	__u16 in_words;
       
  1614 @@ -243,10 +286,57 @@
  1301  	__u64 driver_data[0];
  1615  	__u64 driver_data[0];
  1302  };
  1616  };
  1303  
  1617  
  1304 +#if defined(__SVR4) && defined(__sun)
  1618 +#if defined(__SVR4) && defined(__sun)
  1305 +/*
  1619 +/*
  1353 +};
  1667 +};
  1354 +
  1668 +
  1355  struct ibv_dealloc_pd {
  1669  struct ibv_dealloc_pd {
  1356  	__u32 command;
  1670  	__u32 command;
  1357  	__u16 in_words;
  1671  	__u16 in_words;
  1358 @@ -280,6 +337,13 @@
  1672 @@ -280,6 +370,13 @@
  1359  	__u32 mr_handle;
  1673  	__u32 mr_handle;
  1360  };
  1674  };
  1361  
  1675  
  1362 +struct ibv_flush_relaxed_mr {
  1676 +struct ibv_flush_relaxed_mr {
  1363 +	__u32 command;
  1677 +	__u32 command;
  1367 +};
  1681 +};
  1368 +
  1682 +
  1369  struct ibv_create_comp_channel {
  1683  struct ibv_create_comp_channel {
  1370  	__u32 command;
  1684  	__u32 command;
  1371  	__u16 in_words;
  1685  	__u16 in_words;
  1372 @@ -304,10 +368,25 @@
  1686 @@ -304,10 +401,25 @@
  1373  	__u64 driver_data[0];
  1687  	__u64 driver_data[0];
  1374  };
  1688  };
  1375  
  1689  
  1376 +#if defined(__SVR4) && defined(__sun)
  1690 +#if defined(__SVR4) && defined(__sun)
  1377 +/*
  1691 +/*
  1393 +};
  1707 +};
  1394 +#endif
  1708 +#endif
  1395  
  1709  
  1396  struct ibv_kern_wc {
  1710  struct ibv_kern_wc {
  1397  	__u64  wr_id;
  1711  	__u64  wr_id;
  1398 @@ -363,7 +442,11 @@
  1712 @@ -363,7 +475,11 @@
  1399  struct ibv_resize_cq_resp {
  1713  struct ibv_resize_cq_resp {
  1400  	__u32 cqe;
  1714  	__u32 cqe;
  1401  	__u32 reserved;
  1715  	__u32 reserved;
  1402 +#if defined(__SVR4) && defined(__sun)
  1716 +#if defined(__SVR4) && defined(__sun)
  1403 +        ofuv_cq_drv_data_out_t   drv_out;
  1717 +        ofuv_cq_drv_data_out_t   drv_out;
  1405  	__u64 driver_data[0];
  1719  	__u64 driver_data[0];
  1406 +#endif
  1720 +#endif
  1407  };
  1721  };
  1408  
  1722  
  1409  struct ibv_destroy_cq {
  1723  struct ibv_destroy_cq {
  1410 @@ -460,6 +543,14 @@
  1724 @@ -460,6 +576,14 @@
  1411  	__u64 driver_data[0];
  1725  	__u64 driver_data[0];
  1412  };
  1726  };
  1413  
  1727  
  1414 +#if defined(__SVR4) && defined(__sun)
  1728 +#if defined(__SVR4) && defined(__sun)
  1415 +/*
  1729 +/*
  1420 +typedef __u64 ofuv_qp_drv_data_out_t[SOL_UVERBS_QP_DATA_OUT_SIZE];
  1734 +typedef __u64 ofuv_qp_drv_data_out_t[SOL_UVERBS_QP_DATA_OUT_SIZE];
  1421 +
  1735 +
  1422  struct ibv_create_qp_resp {
  1736  struct ibv_create_qp_resp {
  1423  	__u32 qp_handle;
  1737  	__u32 qp_handle;
  1424  	__u32 qpn;
  1738  	__u32 qpn;
  1425 @@ -469,7 +560,20 @@
  1739 @@ -469,7 +593,20 @@
  1426  	__u32 max_recv_sge;
  1740  	__u32 max_recv_sge;
  1427  	__u32 max_inline_data;
  1741  	__u32 max_inline_data;
  1428  	__u32 reserved;
  1742  	__u32 reserved;
  1429 +	ofuv_qp_drv_data_out_t drv_out;
  1743 +	ofuv_qp_drv_data_out_t drv_out;
  1430  };
  1744  };
  1441 +};
  1755 +};
  1442 +#endif
  1756 +#endif
  1443  
  1757  
  1444  struct ibv_qp_dest {
  1758  struct ibv_qp_dest {
  1445  	__u8  dgid[16];
  1759  	__u8  dgid[16];
  1446 @@ -817,12 +921,29 @@
  1760 @@ -817,12 +954,29 @@
  1447  	__u64 driver_data[0];
  1761  	__u64 driver_data[0];
  1448  };
  1762  };
  1449  
  1763  
  1450 +#if defined(__SVR4) && defined(__sun)
  1764 +#if defined(__SVR4) && defined(__sun)
  1451 +/*
  1765 +/*
  1471 +};
  1785 +};
  1472 +#endif
  1786 +#endif
  1473  
  1787  
  1474  struct ibv_modify_srq {
  1788  struct ibv_modify_srq {
  1475  	__u32 command;
  1789  	__u32 command;
  1476 @@ -946,6 +1067,11 @@
  1790 @@ -946,6 +1100,14 @@
  1477  	IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP_V2 = -1,
  1791  	IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP_V2 = -1,
  1478  	IB_USER_VERBS_CMD_REG_XRC_RCV_QP_V2 = -1,
  1792  	IB_USER_VERBS_CMD_REG_XRC_RCV_QP_V2 = -1,
  1479  	IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP_V2 = -1,
  1793  	IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP_V2 = -1,
  1480 +	IB_USER_VERBS_CMD_REG_MR_RELAXED_V2 = -1,
  1794 +	IB_USER_VERBS_CMD_REG_MR_RELAXED_V2 = -1,
  1481 +	IB_USER_VERBS_CMD_DEREG_MR_RELAXED_V2 = -1,
  1795 +	IB_USER_VERBS_CMD_DEREG_MR_RELAXED_V2 = -1,
  1482 +	IB_USER_VERBS_CMD_FLUSH_RELAXED_MR_V2 = -1,
  1796 +	IB_USER_VERBS_CMD_FLUSH_RELAXED_MR_V2 = -1,
  1483 +  	IB_USER_VERBS_CMD_ALLOC_SHPD_V2 = -1,
  1797 +  	IB_USER_VERBS_CMD_ALLOC_SHPD_V2 = -1,
  1484 +  	IB_USER_VERBS_CMD_SHARE_PD_V2 = -1,
  1798 +  	IB_USER_VERBS_CMD_SHARE_PD_V2 = -1,
       
  1799 +	IB_USER_VERBS_CMD_REG_SM_EVENT_V2 = -1,
       
  1800 +	IB_USER_VERBS_CMD_UNREG_SM_EVENT_V2 = -1,
       
  1801 +	IB_USER_VERBS_CMD_GID_REACHABLE_V2 = -1,
  1485  };
  1802  };
  1486  
  1803  
  1487  struct ibv_destroy_cq_v1 {
  1804  struct ibv_destroy_cq_v1 {
  1488 diff -r -u /tmp/846623/libibverbs-1.1.4/include/infiniband/driver.h libibverbs-1.1.4/include/infiniband/driver.h
  1805 diff -r -u /tmp/846623/libibverbs-1.1.4/include/infiniband/driver.h libibverbs-1.1.4/include/infiniband/driver.h
  1489 --- /tmp/846623/libibverbs-1.1.4/include/infiniband/driver.h	Thu Feb  3 01:53:17 2011
  1806 --- /tmp/846623/libibverbs-1.1.4/include/infiniband/driver.h	Thu Feb  3 01:53:17 2011
  1549  	uint64_t		node_guid;
  1866  	uint64_t		node_guid;
  1550 +	uint64_t		node_guid_external;
  1867 +	uint64_t		node_guid_external;
  1551  	uint64_t		sys_image_guid;
  1868  	uint64_t		sys_image_guid;
  1552  	uint64_t		max_mr_size;
  1869  	uint64_t		max_mr_size;
  1553  	uint64_t		page_size_cap;
  1870  	uint64_t		page_size_cap;
  1554 @@ -297,7 +301,8 @@
  1871 @@ -212,6 +216,10 @@
       
  1872  	IBV_EVENT_QP_LAST_WQE_REACHED,
       
  1873  	IBV_EVENT_CLIENT_REREGISTER,
       
  1874  	IBV_EVENT_GID_CHANGE,
       
  1875 +	IBV_EVENT_MCG_CREATED,
       
  1876 +	IBV_EVENT_MCG_DELETED,
       
  1877 +	IBV_EVENT_GID_AVAIL,
       
  1878 +	IBV_EVENT_GID_UNAVAIL,
       
  1879  };
       
  1880  
       
  1881  enum ibv_event_flags {
       
  1882 @@ -225,10 +233,20 @@
       
  1883  		struct ibv_srq *srq;
       
  1884  		int		port_num;
       
  1885  		uint32_t	xrc_qp_num;
       
  1886 +		union ibv_gid	gid;
       
  1887  	} element;
       
  1888  	enum ibv_event_type	event_type;
       
  1889  };
       
  1890  
       
  1891 +typedef enum ibv_sm_event_type_e {
       
  1892 +	IBV_SM_EVENT_MGID	= 1,
       
  1893 +	IBV_SM_EVENT_MGID_ALL	= 1 << 2,
       
  1894 +	IBV_SM_EVENT_UGID	= 1 << 3,
       
  1895 +	IBV_SM_EVENT_UGID_ALL	= 1 << 4,
       
  1896 +        IBV_SM_EVENT_ALL	= 1 << 5
       
  1897 +
       
  1898 +} ibv_sm_event_type_t;
       
  1899 +
       
  1900  enum ibv_wc_status {
       
  1901  	IBV_WC_SUCCESS,
       
  1902  	IBV_WC_LOC_LEN_ERR,
       
  1903 @@ -297,7 +315,8 @@
  1555  	IBV_ACCESS_REMOTE_WRITE		= (1<<1),
  1904  	IBV_ACCESS_REMOTE_WRITE		= (1<<1),
  1556  	IBV_ACCESS_REMOTE_READ		= (1<<2),
  1905  	IBV_ACCESS_REMOTE_READ		= (1<<2),
  1557  	IBV_ACCESS_REMOTE_ATOMIC	= (1<<3),
  1906  	IBV_ACCESS_REMOTE_ATOMIC	= (1<<3),
  1558 -	IBV_ACCESS_MW_BIND		= (1<<4)
  1907 -	IBV_ACCESS_MW_BIND		= (1<<4)
  1559 +	IBV_ACCESS_MW_BIND		= (1<<4),
  1908 +	IBV_ACCESS_MW_BIND		= (1<<4),
  1560 +	IBV_ACCESS_SO			= (1<<5)	/* Strong Order */
  1909 +	IBV_ACCESS_SO			= (1<<5)	/* Strong Order */
  1561  };
  1910  };
  1562  
  1911  
  1563  struct ibv_pd {
  1912  struct ibv_pd {
  1564 @@ -305,6 +310,10 @@
  1913 @@ -305,6 +324,10 @@
  1565  	uint32_t		handle;
  1914  	uint32_t		handle;
  1566  };
  1915  };
  1567  
  1916  
  1568 +struct ibv_shpd {
  1917 +struct ibv_shpd {
  1569 +	uint32_t		handle;
  1918 +	uint32_t		handle;
  1570 +};
  1919 +};
  1571 +
  1920 +
  1572  enum ibv_rereg_mr_flags {
  1921  enum ibv_rereg_mr_flags {
  1573  	IBV_REREG_MR_CHANGE_TRANSLATION	= (1 << 0),
  1922  	IBV_REREG_MR_CHANGE_TRANSLATION	= (1 << 0),
  1574  	IBV_REREG_MR_CHANGE_PD		= (1 << 1),
  1923  	IBV_REREG_MR_CHANGE_PD		= (1 << 1),
  1575 @@ -425,6 +434,14 @@
  1924 @@ -425,6 +448,14 @@
  1576  	uint32_t		max_inline_data;
  1925  	uint32_t		max_inline_data;
  1577  };
  1926  };
  1578  
  1927  
  1579 +#if defined(__SVR4) && defined(__sun)
  1928 +#if defined(__SVR4) && defined(__sun)
  1580 +/*
  1929 +/*
  1585 +#endif
  1934 +#endif
  1586 +
  1935 +
  1587  struct ibv_qp_init_attr {
  1936  struct ibv_qp_init_attr {
  1588  	void		       *qp_context;
  1937  	void		       *qp_context;
  1589  	struct ibv_cq	       *send_cq;
  1938  	struct ibv_cq	       *send_cq;
  1590 @@ -743,6 +760,12 @@
  1939 @@ -743,6 +774,12 @@
  1591  	int			(*detach_mcast)(struct ibv_qp *qp, const union ibv_gid *gid,
  1940  	int			(*detach_mcast)(struct ibv_qp *qp, const union ibv_gid *gid,
  1592  						uint16_t lid);
  1941  						uint16_t lid);
  1593  	void			(*async_event)(struct ibv_async_event *event);
  1942  	void			(*async_event)(struct ibv_async_event *event);
  1594 +	struct ibv_mr *		(*reg_mr_relaxed)(struct ibv_pd *pd, void *addr, size_t length,
  1943 +	struct ibv_mr *		(*reg_mr_relaxed)(struct ibv_pd *pd, void *addr, size_t length,
  1595 +					  int access);
  1944 +					  int access);
  1598 +	struct ibv_shpd *	(*alloc_shpd)(struct ibv_pd *pd, uint64_t share_key, struct ibv_shpd *shpd);
  1947 +	struct ibv_shpd *	(*alloc_shpd)(struct ibv_pd *pd, uint64_t share_key, struct ibv_shpd *shpd);
  1599 +	struct ibv_pd *		(*share_pd)(struct ibv_context *context, struct ibv_shpd *shpd, uint64_t share_key);
  1948 +	struct ibv_pd *		(*share_pd)(struct ibv_context *context, struct ibv_shpd *shpd, uint64_t share_key);
  1600  };
  1949  };
  1601  
  1950  
  1602  struct ibv_context {
  1951  struct ibv_context {
  1603 @@ -749,6 +772,13 @@
  1952 @@ -749,6 +786,13 @@
  1604  	struct ibv_device      *device;
  1953  	struct ibv_device      *device;
  1605  	struct ibv_context_ops	ops;
  1954  	struct ibv_context_ops	ops;
  1606  	int			cmd_fd;
  1955  	int			cmd_fd;
  1607 +#if defined(__SVR4) && defined(__sun)
  1956 +#if defined(__SVR4) && defined(__sun)
  1608 +	/*
  1957 +	/*
  1612 +	int			mmap_fd;
  1961 +	int			mmap_fd;
  1613 +#endif
  1962 +#endif
  1614  	int			async_fd;
  1963  	int			async_fd;
  1615  	int			num_comp_vectors;
  1964  	int			num_comp_vectors;
  1616  	pthread_mutex_t		mutex;
  1965  	pthread_mutex_t		mutex;
  1617 @@ -797,6 +827,11 @@
  1966 @@ -797,6 +841,11 @@
  1618  uint64_t ibv_get_device_guid(struct ibv_device *device);
  1967  uint64_t ibv_get_device_guid(struct ibv_device *device);
  1619  
  1968  
  1620  /**
  1969  /**
  1621 + * ibv_get_device_guid_external - Return device's node external GUID
  1970 + * ibv_get_device_guid_external - Return device's node external GUID
  1622 + */
  1971 + */
  1624 +
  1973 +
  1625 +/**
  1974 +/**
  1626   * ibv_open_device - Initialize device for use
  1975   * ibv_open_device - Initialize device for use
  1627   */
  1976   */
  1628  struct ibv_context *ibv_open_device(struct ibv_device *device);
  1977  struct ibv_context *ibv_open_device(struct ibv_device *device);
  1629 @@ -858,6 +893,20 @@
  1978 @@ -853,11 +902,44 @@
       
  1979  		   int index, uint16_t *pkey);
       
  1980  
       
  1981  /**
       
  1982 + * ibv_register_sm_events - Register subnet event for GID change
       
  1983 + */
       
  1984 +int ibv_register_sm_events(struct ibv_context *context,
       
  1985 +    ibv_sm_event_type_t event, uint_t gid_num, union ibv_gid *gids);
       
  1986 +
       
  1987 +/**
       
  1988 + * ibv_unregister_sm_events - Unregister subnet event for GID change
       
  1989 + */
       
  1990 +int ibv_unregister_sm_events(struct ibv_context *context,
       
  1991 +    ibv_sm_event_type_t event, uint_t gid_num, union ibv_gid *gids);
       
  1992 +
       
  1993 +/**
       
  1994 + * ibv_gid_reachable - To contact subnet agent for GID status; reachable or
       
  1995 + * not reachable
       
  1996 + */
       
  1997 +int ibv_gid_reachable(struct ibv_context *context,
       
  1998 +    uint port, union ibv_gid *gid_p, int timeout);
       
  1999 +
       
  2000 +/**
       
  2001   * ibv_alloc_pd - Allocate a protection domain
       
  2002   */
  1630  struct ibv_pd *ibv_alloc_pd(struct ibv_context *context);
  2003  struct ibv_pd *ibv_alloc_pd(struct ibv_context *context);
  1631  
  2004  
  1632  /**
  2005  /**
  1633 + * ibv_alloc_shpd - Mark given protection domain as shareable & return shpd structure
  2006 + * ibv_alloc_shpd - Mark given protection domain as shareable & return shpd structure
  1634 + *                  that identify it.
  2007 + *                  that identify it.
  1645 +
  2018 +
  1646 +/**
  2019 +/**
  1647   * ibv_dealloc_pd - Free a protection domain
  2020   * ibv_dealloc_pd - Free a protection domain
  1648   */
  2021   */
  1649  int ibv_dealloc_pd(struct ibv_pd *pd);
  2022  int ibv_dealloc_pd(struct ibv_pd *pd);
  1650 @@ -869,11 +918,27 @@
  2023 @@ -869,11 +951,27 @@
  1651  			  size_t length, int access);
  2024  			  size_t length, int access);
  1652  
  2025  
  1653  /**
  2026  /**
  1654 + * ibv_reg_mr_relaxed - Register a memory region using FMR
  2027 + * ibv_reg_mr_relaxed - Register a memory region using FMR
  1655 + */
  2028 + */
  1793  @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT device_list.o -MD -MP -MF $(DEPDIR)/device_list.Tpo -c -o device_list.o `test -f 'examples/device_list.c' || echo '$(srcdir)/'`examples/device_list.c
  2166  @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT device_list.o -MD -MP -MF $(DEPDIR)/device_list.Tpo -c -o device_list.o `test -f 'examples/device_list.c' || echo '$(srcdir)/'`examples/device_list.c
  1794  @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/device_list.Tpo $(DEPDIR)/device_list.Po
  2167  @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/device_list.Tpo $(DEPDIR)/device_list.Po
  1795 diff -r -u /tmp/846623/libibverbs-1.1.4/examples/asyncwatch.c libibverbs-1.1.4/examples/asyncwatch.c
  2168 diff -r -u /tmp/846623/libibverbs-1.1.4/examples/asyncwatch.c libibverbs-1.1.4/examples/asyncwatch.c
  1796 --- /tmp/846623/libibverbs-1.1.4/examples/asyncwatch.c	Thu Mar 10 06:58:21 2011
  2169 --- /tmp/846623/libibverbs-1.1.4/examples/asyncwatch.c	Thu Mar 10 06:58:21 2011
  1797 +++ libibverbs-1.1.4/examples/asyncwatch.c	Fri Feb 11 04:02:18 2011
  2170 +++ libibverbs-1.1.4/examples/asyncwatch.c	Fri Feb 11 04:02:18 2011
  1798 @@ -35,8 +35,10 @@
  2171 @@ -35,11 +35,72 @@
  1799  #endif /* HAVE_CONFIG_H */
  2172  #endif /* HAVE_CONFIG_H */
  1800  
  2173  
  1801  #include <stdio.h>
  2174  #include <stdio.h>
       
  2175 +#include <stdlib.h>
       
  2176 +#include <ctype.h>
       
  2177 +#include <getopt.h>
       
  2178 +#include <signal.h>
       
  2179 +#include <string.h>
       
  2180 +#include <strings.h>
  1802 +#if !(defined(__SVR4) && defined(__sun))
  2181 +#if !(defined(__SVR4) && defined(__sun))
  1803  #include <endian.h>
  2182  #include <endian.h>
  1804  #include <byteswap.h>
  2183  #include <byteswap.h>
  1805 +#endif
  2184 +#endif
  1806  
  2185  
  1807  #include <infiniband/verbs.h>
  2186  #include <infiniband/verbs.h>
  1808  
  2187  
       
  2188 +#define IS_PORT_EVENT(event)				\
       
  2189 +	((event == IBV_EVENT_PORT_ACTIVE) ||		\
       
  2190 +	(event == IBV_EVENT_PORT_ERR ) ||		\
       
  2191 +	(event == IBV_EVENT_LID_CHANGE) ||		\
       
  2192 +	(event == IBV_EVENT_PKEY_CHANGE) ||		\
       
  2193 +	(event == IBV_EVENT_SM_CHANGE) ||		\
       
  2194 +	(event == IBV_EVENT_GID_CHANGE) ||		\
       
  2195 +	(event == IBV_EVENT_CLIENT_REREGISTER))
       
  2196 +
       
  2197 +#define IS_SM_EVENT(event)				\
       
  2198 +	((event == IBV_EVENT_MCG_CREATED) ||		\
       
  2199 +	(event == IBV_EVENT_MCG_DELETED) ||		\
       
  2200 +	(event == IBV_EVENT_GID_AVAIL) ||		\
       
  2201 +	(event == IBV_EVENT_GID_UNAVAIL))
       
  2202 +
       
  2203 +#define IS_QP_EVENT(event)				\
       
  2204 +	((event == IBV_EVENT_CQ_ERR) ||			\
       
  2205 +	(event == IBV_EVENT_QP_FATAL) ||		\
       
  2206 +	(event == IBV_EVENT_QP_REQ_ERR) ||		\
       
  2207 +	(event == IBV_EVENT_COMM_EST) ||		\
       
  2208 +	(event == IBV_EVENT_SQ_DRAINED) ||		\
       
  2209 +	(event == IBV_EVENT_PATH_MIG) ||		\
       
  2210 +	(event == IBV_EVENT_PATH_MIG_ERR) ||		\
       
  2211 +	(event == IBV_EVENT_QP_LAST_WQE_REACHED) ||	\
       
  2212 +	(event == IBV_EVENT_QP_ACCESS_ERR))
       
  2213 +
       
  2214 +#define IS_CQ_EVENT(event)				\
       
  2215 +	(event == IBV_EVENT_CQ_ERR)
       
  2216 +
       
  2217 +#define IS_SRQ_EVENT(event)				\
       
  2218 +	((event == IBV_EVENT_SRQ_ERR) ||		\
       
  2219 +	(event == IBV_EVENT_SRQ_LIMIT_REACHED))
       
  2220 +
       
  2221 +#define IS_CA_EVENT(event)				\
       
  2222 +	(event == IBV_EVENT_DEVICE_FATAL)
       
  2223 +
       
  2224 +
       
  2225 +struct ibv_device	**dev_list;
       
  2226 +struct ibv_context	*context;
       
  2227 +struct ibv_async_event	event;
       
  2228 +union ibv_gid		*gids = NULL;
       
  2229 +uint_t			num_gids = 0;
       
  2230 +ibv_sm_event_type_t	events;
       
  2231 +
       
  2232 +static struct option long_options[] = {
       
  2233 +    {"sm",		0, 0, 's'},
       
  2234 +    {"GUID",		0, 0, 'G'},
       
  2235 +    {"MCG",		0, 0, 'M'},
       
  2236 +    {"port",		1, 0, 'p'},
       
  2237 +    {0, 0, 0, 0}
       
  2238 +};
       
  2239 +
       
  2240 +
       
  2241  static const char *event_name_str(enum ibv_event_type event_type)
       
  2242  {
       
  2243  	switch (event_type) {
       
  2244 @@ -59,7 +120,14 @@
       
  2245  		return "IBV_EVENT_CLIENT_REREGISTER";
       
  2246  	case IBV_EVENT_GID_CHANGE:
       
  2247  		return "IBV_EVENT_GID_CHANGE";
       
  2248 -
       
  2249 +	case IBV_EVENT_MCG_CREATED:
       
  2250 +		return "IBV_EVENT_MCG_CREATED";
       
  2251 +	case IBV_EVENT_MCG_DELETED:
       
  2252 +		return "IBV_EVENT_MCG_DELETED";
       
  2253 +	case IBV_EVENT_GID_AVAIL:
       
  2254 +		return "IBV_EVENT_GID_AVAIL";
       
  2255 +	case IBV_EVENT_GID_UNAVAIL:
       
  2256 +		return "IBV_EVENT_GID_UNAVAIL";
       
  2257  	case IBV_EVENT_CQ_ERR:
       
  2258  	case IBV_EVENT_QP_FATAL:
       
  2259  	case IBV_EVENT_QP_REQ_ERR:
       
  2260 @@ -76,15 +144,173 @@
       
  2261  	}
       
  2262  }
       
  2263  
       
  2264 -int main(int argc, char *argv[])
       
  2265 +static void catch_signal(int sig_num)
       
  2266  {
       
  2267 -	struct ibv_device **dev_list;
       
  2268 -	struct ibv_context *context;
       
  2269 -	struct ibv_async_event event;
       
  2270 +	ibv_unregister_sm_events(context, events, num_gids, gids);
       
  2271 +	if (gids)
       
  2272 +		free(gids);
       
  2273 +	ibv_close_device(context);
       
  2274 +	(void) ibv_free_device_list(dev_list);
       
  2275 +	exit (0);
       
  2276 +}
       
  2277  
       
  2278 -	/* Force line-buffering in case stdout is redirected */
       
  2279 -	setvbuf(stdout, NULL, _IOLBF, 0);
       
  2280 +static void usage(const char *argv0)
       
  2281 +{
       
  2282 +	printf("Usage:\n");
       
  2283 +	printf("\n");
       
  2284 +	printf("Options:\n");
       
  2285 +	printf("[ -s, --sm<gid> ]\t\tsm event\n");
       
  2286 +	printf("[ -M, --M ]\t\t\tsm event for MGID (multicast)\n");
       
  2287 +	printf("[ -G, --G ]\t\t\tsm event for UGID (unicast)\n");
       
  2288 +	printf("[ -p, --port=<port> ]\t\t(default 1)\n");
       
  2289 +	printf("\nExamples;\n");
       
  2290 +	printf("ibv_asyncwatch -s\t\t# monitor event=IBV_SM_EVENT_ALL\n");
       
  2291 +	printf("ibv_asyncwatch -G -s\t\t# monitor event="
       
  2292 +	    "IBV_SM_EVENT_UGID_ALL\n");
       
  2293 +	printf("ibv_asyncwatch -M -s\t\t# monitor event="
       
  2294 +	    "IBV_SM_EVENT_MGID_ALL\n");
       
  2295 +	printf("ibv_asyncwatch -G -s0x0021280001a0e4d9,0x0021280001a0e4da\n");
       
  2296 +	printf("\t\t\t\t# monitor event=IBV_SM_EVENT_UGID\n");
       
  2297 +	printf("ibv_asyncwatch -M -s0xff12:4001:ffff::c:2238,");
       
  2298 +	printf("0xff12:ffff::38:220c\n");
       
  2299 +	printf("\t\t\t\t# monitor event=IBV_SM_EVENT_MGID\n");
       
  2300 +}
       
  2301  
       
  2302 +
       
  2303 +uint_t get_gids(char *argptr, uint64_t subnet_prefix)
       
  2304 +{
       
  2305 +	char		*curr, *next;
       
  2306 +	char		*guid_str_p1, *guid_str_p2 = NULL;
       
  2307 +	int		i = 0;
       
  2308 +	int		data_num;
       
  2309 +
       
  2310 +	for (curr = argptr; curr; curr = next, i++) {
       
  2311 +		next = strchr(curr, ',');
       
  2312 +		if (next)
       
  2313 +			next++;
       
  2314 +        }
       
  2315 +	data_num = i;
       
  2316 +	if (data_num == 0)
       
  2317 +		return (0);
       
  2318 +
       
  2319 +	gids = (union ibv_gid *)calloc(data_num, sizeof (union ibv_gid));
       
  2320 +	guid_str_p1 = malloc(strlen(argptr));
       
  2321 +	strncpy(guid_str_p1, argptr, strlen(argptr));
       
  2322 +
       
  2323 +	i = 0;
       
  2324 +	guid_str_p2 = strtok(guid_str_p1, (const char *)",");
       
  2325 +	while (guid_str_p2 != NULL) {
       
  2326 +		gids[i].global.subnet_prefix = subnet_prefix;
       
  2327 +		gids[i].global.interface_id =
       
  2328 +		    htonll((uint64_t)strtoull(guid_str_p2, 0, 0));
       
  2329 +		i++;
       
  2330 +		guid_str_p2 = strtok(NULL, (const char *)",");
       
  2331 +	}
       
  2332 +	free (guid_str_p1);
       
  2333 +	return (data_num);
       
  2334 +}
       
  2335 +
       
  2336 +void process_one_mcg_gid(union ibv_gid *gid, char *mcg_str)
       
  2337 +{
       
  2338 +	char		*token, *token_p, half_token[3];
       
  2339 +	uint8_t		mcg_gid[16];
       
  2340 +	int		i, j = 0, num_data = -1;
       
  2341 +	char		*curr, *next;
       
  2342 +
       
  2343 +	/* find out how many two-byte data from command line input */
       
  2344 +	for (curr = mcg_str; curr; curr = next, num_data++) {
       
  2345 +		next = strchr(curr, ':');
       
  2346 +		if (next)
       
  2347 +			next++;
       
  2348 +        }
       
  2349 +
       
  2350 +	if (num_data > 8) {
       
  2351 +		fprintf(stderr, "Invalid MGID input format: %s\n", mcg_str);
       
  2352 +		exit (-1);
       
  2353 +	}
       
  2354 +
       
  2355 +	curr = mcg_str + 2;	/* Skip past 0x */
       
  2356 +	while ((token = strsep(&curr, ":")) != NULL && j < 15) {
       
  2357 +		if (strncmp(token, "\0", 1) == 0) {
       
  2358 +			/* We have :: in the input */
       
  2359 +			for (i = 0; i < 8 - num_data; i++) {
       
  2360 +				mcg_gid[j++] = 0;
       
  2361 +				mcg_gid[j++] = 0;
       
  2362 +			}
       
  2363 +		} else {
       
  2364 +			if (strlen(token) < 3) {
       
  2365 +				mcg_gid[j++] = 0;
       
  2366 +				mcg_gid[j++] =
       
  2367 +				    (uint8_t)strtoll(token, NULL, 16);
       
  2368 +			} else {
       
  2369 +				memset(half_token, 0, 3);
       
  2370 +				token_p = token;
       
  2371 +				if (strlen(token) == 3) {
       
  2372 +					strncpy(half_token, token, 1);
       
  2373 +					token_p += 1;
       
  2374 +				} else {
       
  2375 +					strncpy(half_token, token, 2);
       
  2376 +					token_p += 2;
       
  2377 +				}
       
  2378 +				mcg_gid[j++] = (uint8_t)strtol(half_token,
       
  2379 +				    NULL, 16);
       
  2380 +
       
  2381 +				mcg_gid[j++] = (uint8_t)strtol(token_p,
       
  2382 +				    NULL, 16);
       
  2383 +			}
       
  2384 +		}
       
  2385 +	}
       
  2386 +
       
  2387 +	memcpy(gid->raw, mcg_gid, 16);
       
  2388 +}
       
  2389 +
       
  2390 +uint_t get_mcgs(char *argptr, uint64_t subnet_prefix)
       
  2391 +{
       
  2392 +	char            *curr, *next;
       
  2393 +	char		*mcg_str_p1, *mcg_str_p2 = NULL;
       
  2394 +	int		i = 0;
       
  2395 +	int		data_num;
       
  2396 +
       
  2397 +	for (curr = argptr; curr; curr = next, i++) {
       
  2398 +		next = strchr(curr, ',');
       
  2399 +		if (next)
       
  2400 +			next++;
       
  2401 +        }
       
  2402 +	data_num = i;
       
  2403 +	if (data_num == 0)
       
  2404 +		return (0);
       
  2405 +
       
  2406 +	gids = (union ibv_gid *)calloc(data_num, sizeof (union ibv_gid));
       
  2407 +	mcg_str_p1 = malloc(strlen(argptr));
       
  2408 +	strncpy(mcg_str_p1, argptr, strlen(argptr));
       
  2409 +
       
  2410 +	i = 0;
       
  2411 +	mcg_str_p2 = strtok(mcg_str_p1, (const char *)",");
       
  2412 +	while (mcg_str_p2 != NULL) {
       
  2413 +		if (strncmp(mcg_str_p2, "0xff", 4) != 0) {
       
  2414 +			fprintf(stderr, "Invalid MGID input format: %s\n",
       
  2415 +			    mcg_str_p2);
       
  2416 +			exit (-1);
       
  2417 +		}
       
  2418 +		process_one_mcg_gid(&gids[i], mcg_str_p2);
       
  2419 +		i++;
       
  2420 +		mcg_str_p2 = strtok(NULL, (const char *)",");
       
  2421 +	}
       
  2422 +	free(mcg_str_p1);
       
  2423 +	return (data_num);
       
  2424 +}
       
  2425 +
       
  2426 +int main(int argc, char *argv[])
       
  2427 +{
       
  2428 +	int		c;
       
  2429 +	int		ret;
       
  2430 +	uint_t		port = 1;	/* default */
       
  2431 +	uint_t		do_sm_event_register = 0;
       
  2432 +	union ibv_gid	sgid;
       
  2433 +	uint64_t	subnet_prefix = 0ULL;
       
  2434 +	int		mcgflag = 0;
       
  2435 +	int		guidflag = 0;
       
  2436 +
       
  2437  	dev_list = ibv_get_device_list(NULL);
       
  2438  	if (!dev_list) {
       
  2439  		perror("Failed to get IB devices list");
       
  2440 @@ -103,19 +329,111 @@
       
  2441  		return 1;
       
  2442  	}
       
  2443  
       
  2444 -	printf("%s: async event FD %d\n",
       
  2445 +	printf("\n%s: async event FD %d\n\n",
       
  2446  	       ibv_get_device_name(*dev_list), context->async_fd);
       
  2447  
       
  2448 +	ibv_query_gid(context, port, 0, &sgid);
       
  2449 +	subnet_prefix = sgid.global.subnet_prefix;
       
  2450 +
       
  2451 +	while ((c = getopt_long(argc, argv, "p:GMs::t:", long_options, NULL))
       
  2452 +	    != -1) {
       
  2453 +		switch(c) {
       
  2454 +			case 'G':
       
  2455 +				guidflag = 1;
       
  2456 +				break;
       
  2457 +			case 'M':
       
  2458 +				mcgflag = 1;
       
  2459 +				break;
       
  2460 +			case 's':
       
  2461 +				do_sm_event_register = 1;
       
  2462 +				if (mcgflag == 1)
       
  2463 +					num_gids =
       
  2464 +					    get_mcgs(optarg, subnet_prefix);
       
  2465 +				else
       
  2466 +					num_gids =
       
  2467 +					    get_gids(optarg, subnet_prefix);
       
  2468 +				break;
       
  2469 +			case 'p':
       
  2470 +				port = strtol(optarg, NULL, 0);
       
  2471 +				ibv_query_gid(context, port, 0, &sgid);
       
  2472 +				subnet_prefix = sgid.global.subnet_prefix;
       
  2473 +				break;
       
  2474 +			default:
       
  2475 +				usage(argv[0]);
       
  2476 +				return 1;
       
  2477 +		}
       
  2478 +	}
       
  2479 +
       
  2480 +	/* Force line-buffering in case stdout is redirected */
       
  2481 +	setvbuf(stdout, NULL, _IOLBF, 0);
       
  2482 +
       
  2483 +	if (num_gids) {
       
  2484 +		if (mcgflag)
       
  2485 +			events = IBV_SM_EVENT_MGID;
       
  2486 +		else
       
  2487 +			events = IBV_SM_EVENT_UGID;
       
  2488 +	} else {
       
  2489 +		if (mcgflag && guidflag)
       
  2490 +			events = IBV_SM_EVENT_ALL;
       
  2491 +		else if (mcgflag)
       
  2492 +			events = IBV_SM_EVENT_MGID_ALL;
       
  2493 +		else if (guidflag)
       
  2494 +			events = IBV_SM_EVENT_UGID_ALL;
       
  2495 +		else
       
  2496 +			events = IBV_SM_EVENT_ALL;
       
  2497 +	}
       
  2498 +
       
  2499 +	if (do_sm_event_register)
       
  2500 +		ret = ibv_register_sm_events(context, events, num_gids, gids);
       
  2501 +
       
  2502 +	(void) signal(SIGINT, catch_signal);
       
  2503 +
       
  2504  	while (1) {
       
  2505  		if (ibv_get_async_event(context, &event))
       
  2506  			return 1;
       
  2507  
       
  2508 -		printf("  event_type %s (%d), port %d\n",
       
  2509 -		       event_name_str(event.event_type),
       
  2510 -		       event.event_type, event.element.port_num);
       
  2511 +		if (IS_PORT_EVENT(event.event_type))
       
  2512 +			printf("Event: %s (%d), port %d\n",
       
  2513 +			    event_name_str(event.event_type),
       
  2514 +			    event.event_type, event.element.port_num);
       
  2515 +		else if (IS_SM_EVENT(event.event_type))
       
  2516 +			printf("Event: %s (%d), gid " \
       
  2517 +			    "%02x%02x:%02x%02x:%02x%02x:%02x%02x:"\
       
  2518 +			    "%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
       
  2519 +			    event_name_str(event.event_type), event.event_type,
       
  2520 +			    event.element.gid.raw[0], event.element.gid.raw[1],
       
  2521 +			    event.element.gid.raw[2], event.element.gid.raw[3],
       
  2522 +			    event.element.gid.raw[4], event.element.gid.raw[5],
       
  2523 +			    event.element.gid.raw[6], event.element.gid.raw[7],
       
  2524 +			    event.element.gid.raw[8], event.element.gid.raw[9],
       
  2525 +			    event.element.gid.raw[10],
       
  2526 +			    event.element.gid.raw[11],
       
  2527 +			    event.element.gid.raw[12],
       
  2528 +			    event.element.gid.raw[13],
       
  2529 +			    event.element.gid.raw[14],
       
  2530 +			    event.element.gid.raw[15]);
       
  2531 +		else if (IS_QP_EVENT(event.event_type))
       
  2532 +			printf("Event: %s (%d) QPN %d\n",
       
  2533 +			    event_name_str(event.event_type), event.event_type,
       
  2534 +			    event.element.qp->qp_num);
       
  2535 +		else if (IS_CQ_EVENT(event.event_type))
       
  2536 +			printf("Event: %s (%d) CQE %d\n",
       
  2537 +			    event_name_str(event.event_type), event.event_type,
       
  2538 +			    event.element.cq->cqe);
       
  2539 +		else if (IS_SRQ_EVENT(event.event_type))
       
  2540 +			printf("Event: %s (%d) SRQ %d\n",
       
  2541 +			    event_name_str(event.event_type), event.event_type,
       
  2542 +			    event.element.srq->handle);
       
  2543 +		else
       
  2544 +			printf("Event: %s (%d)\n",
       
  2545 +			    event_name_str(event.event_type), event.event_type);
       
  2546  
       
  2547  		ibv_ack_async_event(&event);
       
  2548 -	}
       
  2549  
       
  2550 +		if (event.event_type == IBV_EVENT_GID_AVAIL) {
       
  2551 +			ret = ibv_gid_reachable(context, port,
       
  2552 +			    &event.element.gid, 0);
       
  2553 +		}
       
  2554 +	}
       
  2555  	return 0;
       
  2556  }
  1809 diff -r -u /tmp/846623/libibverbs-1.1.4/examples/srq_pingpong.c libibverbs-1.1.4/examples/srq_pingpong.c
  2557 diff -r -u /tmp/846623/libibverbs-1.1.4/examples/srq_pingpong.c libibverbs-1.1.4/examples/srq_pingpong.c
  1810 --- /tmp/846623/libibverbs-1.1.4/examples/srq_pingpong.c	Thu Mar 10 06:58:21 2011
  2558 --- /tmp/846623/libibverbs-1.1.4/examples/srq_pingpong.c	Thu Mar 10 06:58:21 2011
  1811 +++ libibverbs-1.1.4/examples/srq_pingpong.c	Wed Jun  8 09:46:34 2011
  2559 +++ libibverbs-1.1.4/examples/srq_pingpong.c	Wed Jun  8 09:46:34 2011
  1812 @@ -171,6 +171,12 @@
  2560 @@ -171,6 +171,12 @@
  1813  		return NULL;
  2561  		return NULL;