Skip to content

ibv_create_ah_from_wc()

0.00 avg. rating (0% score) - 0 votes
struct ibv_ah *ibv_create_ah_from_wc(struct ibv_pd *pd, struct ibv_wc *wc,
				     struct ibv_grh *grh, uint8_t port_num);

Description

ibv_create_ah_from_wc() creates an Address Handle (AH) using a Work Completion and a Global Routing Header (GRH) buffer.

ibv_create_ah_from_wc() is used in order to create an 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
pd in Protection Domain that was returned from ibv_alloc_pd() associated with the RDMA device context 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
port_num in The port number on which the received message arrived

Return Values

Value Description
AH A pointer to the newly allocated Address Handle
NULL On failure, errno indicates the failure reason:

EINVAL Invalid pd or invalid value provided in attr
ENOMEM Not enough resources to complete this operation

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_pd *pd;
struct ibv_ah *ah;
struct ibv_wc wc;
int ret;
 
ah = ibv_create_ah_from_wc(pd, &wc, grh_buf,
                            port);
if (!ah) {
	fprintf(stderr, "Error, ibv_create_ah_from_wc() 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

Fill in the form and submit.

Time limit is exhausted. Please reload CAPTCHA.