Skip to content

ibv_init_ah_from_wc()

Contents

0.00 avg. rating (0% score) - 0 votes
int ibv_init_ah_from_wc(struct ibv_context *context, uint8_t port_num,
                        struct ibv_wc *wc, struct ibv_grh *grh,
                        struct ibv_ah_attr *ah_attr);

Description

ibv_init_ah_from_wc() initializes the Address Handle (AH) attribute structure using A Work Completion and a Global Routing Header (GRH) buffer.

ibv_init_ah_from_wc() is used in order to fill the AH attributes structure, and then create it using ibv_create_ah(). This is useful when one wishes to send back a response to the sender of a message that was received by an Unreliable Datagram (UD) QP. The wc is the Work Completion of that message that was polled from the CQ using ibv_poll_cq(). This Work Completion must be successful and belongs to a unicast message.

grh is the buffer that (may) contain the GRH of the received message (the first 40 bytes of the Receive Request buffer that was posted to the Receive Queue to specify where the message will be saved).

Parameters

Name Direction Description
context in RDMA device context that was returned from ibv_open_device(), on which the received message arrived
port_num in The port number on which the received message arrived
wc in The Work Completion that was read using ibv_poll_cq()
grh in The GRH buffer of the incoming message to a UD QP. This value is ignored unless the work completion indicates that the GRH is valid
ah_attr out A structure of the Address Handle attributes that will be filled

Return Values

Value Description
0 On success
-1 On failure. This verb can fail if the DGID in the GRH isn't found in port's port_num GID table

Examples

Create an AH and destroy it (this example assumes that the variable port was declared and holds the port number, wc holds a successful Work Completion of a unicast message and grh_buf holds the GRH of the incoming message):

struct ibv_context *context;
struct ibv_pd *pd;
struct ibv_ah *ah;
struct ibv_wc wc;
struct ibv_ah_attr ah_attr;
int ret;
 
ret = ibv_init_ah_from_wc(context, port,
                          &wc, grh_buf,
                          &ah_attr);
if (ret) {
	fprintf(stderr, "Error, ibv_init_ah_from_wc() failed\n");
	return -1;
}
 
ah = ibv_create_ah(pd, &ah_attr);
if (!ah) {
	fprintf(stderr, "Error, ibv_create_ah() failed\n");
	return -1;
}
 
if (ibv_destroy_ah(ah)) {
	fprintf(stderr, "Error, ibv_destroy_ah() failed\n");
	return -1;
}

FAQs

Can I fill the AH attributes structure using any Work Completion?

No. There are few limitations to a Work Completion that can be used when calling ibv_init_ah_from_wc():

  • The status of that Work Completion must be IBV_WC_SUCCESS, otherwise most of the attributes of this Work Completion are invalid
  • The Work Completion must be of a unicast message rather than a multicast message
  • If IBV_WC_GRH is set in wc_flags, i.e. the incoming message has a GRH, grh  must be provided

Share Our Posts

Share this post through social bookmarks.

  • Delicious
  • Digg
  • Newsvine
  • RSS
  • StumbleUpon
  • Technorati

Comments

Tell us what do you think.

There are no comments on this entry.

Add a Comment

This comment will be moderated; answer may be provided within 14 days.

Time limit is exhausted. Please reload CAPTCHA.