Skip to content

ibv_modify_srq()

Contents

5.00 avg. rating (97% score) - 1 vote
int ibv_modify_srq(struct ibv_srq *srq,
                   struct ibv_srq_attr *srq_attr,
                   enum ibv_srq_attr_mask srq_attr_mask);

Description

ibv_modify_srq() modifies the attributes of a Shared Receive Queue.

struct ibv_srq_attr describes the attributes of the Shared Receive Queue.

struct ibv_srq_attr {
        uint32_t                max_wr;
        uint32_t                max_sge;
        uint32_t                srq_limit;
};

Here is the full description of struct ibv_srq_attr:

max_wr The maximum number of outstanding Work Requests that can be posted to this Shared Receive Queue. Value can be [1..dev_cap.max_srq_wr]
max_sge The maximum number of scatter/gather elements in any Work Request that can be posted to this Shared Receive Queue. Value can be [1..dev_cap.max_srq_sge]
srq_limit The value that the SRQ will be armed with. When the number of outstanding WRs in the SRQ drops below this limit, the affiliated asynchronous event IBV_EVENT_SRQ_LIMIT_REACHED will be generated. Value can be [0..number of WR that can be posted to the SRQ]. 0 means that the SRQ limit event won’t be generated (since the number of outstanding WRs in the SRQ can’t be negative).

srq_attr_mask specifies the SRQ attributes to be modified. It is either 0 or the bitwise OR of one or more of the following flags:

IBV_SRQ_MAX_WR Resize the SRQ: The fields srq_attr->max_wr and srq_attr->max_sge are being used. Resizing an SRQ is possible only if the device supports this operation (IBV_DEVICE_SRQ_RESIZE is set in dev_cap.device_cap_flags).
IBV_SRQ_LIMIT Set the SRQ limit value. The field srq_attr->srq_limit is being used.

The suggested way to use the SRQ limit event mechanism is:
1) Create the SRQ
2) Post WRs to that SRQ (before or after QPs have been associated with it)
3) Arm the SRQ limit to a non-zero value that is less than the number of posted WRs
4) When the number of outstanding WRs in the SRQ will drop below the limit, the asynchronous event IBV_EVENT_SRQ_LIMIT_REACHED will be generated. When this happens, one should perform the following:

a) Acknowledge the asynchronous event
b) Goto 2) (i.e. post more WRs to the SRQ and set the SRQ limit)

If an SRQ limit is being set to a value, which is greater than the current number of outstanding WRs in the SRQ, an SRQ limit event will be generated immediately.

Parameters

Name Direction Description
srq in SRQ that was returned from ibv_create_srq()
srq_attr in/out Requested attributes to be modified in the Shared Receive Queue. If the SRQ is being resized, it will hold the actual attributes of the SRQ
srq_attr_mask in Mask of the SRQ attributes to be modified

Return Values

Value Description
0 On success
errno On failure and no change will be made to the SRQ
EINVAL Invalid value provided in max_wr, in max_sge or in srq_limit
ENOMEM Not enough resources to complete this operation
ENOSYS Shared Receive Queue modification isn’t supported by this RDMA device

Examples

1) Resize an SRQ:

struct ibv_srq *srq;
struct ibv_srq_attr srq_attr;
 
memset(&srq_attr, 0, sizeof(srq_attr));
 
srq_attr.max_wr  = 10;
srq_attr.max_sge = 1;
 
if (ibv_modify_srq(srq, &srq_attr, IBV_SRQ_MAX_WR)) {
	fprintf(stderr, "Error, ibv_modify_srq() failed when resizing an SRQ\n");
	return -1;
}

2) Set a limit event to an SRQ:

struct ibv_srq *srq;
struct ibv_srq_attr srq_attr;
 
memset(&srq_attr, 0, sizeof(srq_attr));
 
srq_attr.srq_limit = 10;
 
if (ibv_modify_srq(srq, &srq_attr, IBV_SRQ_LIMIT)) {
	fprintf(stderr, "Error, ibv_modify_srq() failed when arming an SRQ\n");
	return -1;
}

FAQs

ibv_modify_srq() failed, what are the attributes of that SRQ now?

Exactly the same as before calling ibv_modify_srq(), no change was made to the SRQ.

I armed the SRQ with the value X. Can I change this value to Y?

Yes, you can. Just call ibv_modify_srq() with a different SRQ limit value.

Share Our Posts

Share this post through social bookmarks.

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

Comments

Tell us what do you think.

  1. Qian says: September 11, 2013

    Last paragraph of section "description":
    If an SRQ limit is being set to a value, which is less than the current number of outstanding WRs in the SRQ, an SRQ limit event will be generated immediately.

    should it be "greater than....."

    • Dotan Barak says: September 12, 2013

      Hi Qian.

      Yes, of course it should be "greater than"
      :)

      I've fixed the post.

      Thanks for noticing it and sharing this info with me
      Dotan

Add a Comment

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

Time limit is exhausted. Please reload CAPTCHA.