Here's a first stab at the changes to the API in <ib_verbs.h> required
to support shared receive queues (SRQs).  SRQs are described in
version 1.2 of the IBA spec; specifically, sections 10.2.9 and 11.2.3
describe the semantics and verbs interface.

I did diverge from the spec in that instead of a single "Post Receive
Request" verb, there are separate ib_post_recv() and
ib_post_srq_recv() functions.  This avoids complications from having a
polymorphic function that takes either a QP or an SRQ, and matches the
interface Mellanox used in VAPI.

Any comments?

Thanks,
  Roland

--- infiniband/include/ib_verbs.h       (revision 2631)
+++ infiniband/include/ib_verbs.h       (working copy)
@@ -261,6 +261,7 @@ struct ib_event {
        union {
                struct ib_cq    *cq;
                struct ib_qp    *qp;
+               struct ib_srq   *srq;
                u8              port_num;
        } element;
        enum ib_event_type      event;
@@ -381,6 +382,17 @@ enum ib_cq_notify {
        IB_CQ_NEXT_COMP
 };
 
+enum ib_srq_attr_mask {
+       IB_SRQ_MAX_WR   = 1 << 0,
+       IB_SRQ_LIMIT    = 1 << 1,
+};
+
+struct ib_srq_attr {
+       u32     max_wr;
+       u32     max_sge;
+       u32     srq_limit;
+};
+
 struct ib_qp_cap {
        u32     max_send_wr;
        u32     max_recv_wr;
@@ -818,6 +830,17 @@ struct ib_device {
        int                        (*query_ah)(struct ib_ah *ah,
                                               struct ib_ah_attr *ah_attr);
        int                        (*destroy_ah)(struct ib_ah *ah);
+       struct ib_srq *            (*create_srq)(struct ib_pd *pd,
+                                                struct ib_srq_attr *srq_attr);
+       int                        (*modify_srq)(struct ib_srp *srq,
+                                                struct ib_srp_attr *srq_attr,
+                                                enum ib_srq_attr_mask 
srq_attr_mask);
+       int                        (*query_srq)(struct ib_srq *srq,
+                                               struct ib_srq_attr *srq_attr);
+       int                        (*destroy_srq)(struct ib_srq *srq);
+       int                        (*post_srq_recv)(struct ib_srq *srq,
+                                                   struct ib_recv_wr *recv_wr,
+                                                   struct ib_recv_wr 
**bad_recv_wr);
        struct ib_qp *             (*create_qp)(struct ib_pd *pd,
                                                struct ib_qp_init_attr 
*qp_init_attr,
                                                const void __user *udata, int 
udatalen);
@@ -1021,6 +1044,68 @@ int ib_query_ah(struct ib_ah *ah, struct
 int ib_destroy_ah(struct ib_ah *ah);
 
 /**
+ * ib_create_srq - Creates a SRQ associated with the specified protection
+ *   domain.
+ * @pd: The protection domain associated with the SRQ.
+ * @srq_attr: A list of initial attributes required to create the SRQ.
+ *
+ * srq_attr->max_wr and srq_attr->max_sge are read the determine the
+ * requested size of the SRQ, and set to the actual values allocated
+ * on return.  If ib_create_srq() succeeds, then max_wr and max_sge
+ * will always be at least as large as the requested values.
+ */
+struct ib_srq *ib_create_srq(struct ib_pd *pd,
+                            struct ib_srq_attr *srq_attr);
+
+/**
+ * ib_modify_srq - Modifies the attributes for the specified SRQ and then
+ *   transitions the SRQ to the given state.
+ * @srq: The SRQ to modify.
+ * @srq_attr: On input, specifies the SRQ attributes to modify.  On output,
+ *   the current values of selected SRQ attributes are returned.
+ * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ
+ *   are being modified.
+ *
+ * The mask may contain IB_SRQ_MAX_WR to resize the SRQ and/or
+ * IB_SRQ_LIMIT to set the SRQ's limit and request notification when
+ * the number of receives queued drops below the limit.
+ */
+int ib_modify_srq(struct ib_srq *srq,
+                 struct ib_srq_attr *srq_attr,
+                 enum ib_srq_attr_mask srq_attr_mask);
+
+/**
+ * ib_query_srq - Returns the attribute list and current values for the
+ *   specified SRQ.
+ * @srq: The SRQ to query.
+ * @srq_attr: The attributes of the specified SRQ.
+ */
+int ib_query_srq(struct ib_srq *srq,
+               struct ib_srq_attr *srq_attr,
+               int srq_attr_mask,
+               struct ib_srq_init_attr *srq_init_attr);
+
+/**
+ * ib_destroy_srq - Destroys the specified SRQ.
+ * @srq: The SRQ to destroy.
+ */
+int ib_destroy_srq(struct ib_srq *srq);
+
+/**
+ * ib_post_srq_recv - Posts a list of work requests to the specified SRQ.
+ * @srq: The SRQ to post the work request on.
+ * @recv_wr: A list of work requests to post on the receive queue.
+ * @bad_recv_wr: On an immediate failure, this parameter will reference
+ *   the work request that failed to be posted on the QP.
+ */
+static inline int ib_post_srq_recv(struct ib_srq *srq,
+                                  struct ib_recv_wr *recv_wr,
+                                  struct ib_recv_wr **bad_recv_wr)
+{
+       return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr);
+}
+
+/**
  * ib_create_qp - Creates a QP associated with the specified protection
  *   domain.
  * @pd: The protection domain associated with the QP.
_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to