[openib-general] [PATCH 1/2] [RFC] Implement resize of CQ
Krishna Kumar
krkumar at us.ibm.com
Wed Nov 3 13:23:32 PST 2004
Hi,
I am not sure if this is a good idea, but since I am new to this area,
here it goes :-)
Section 11.2.6.3, C11-16 states that resize of qp must be permitted.
In the patch I am submitting, I don't understand why so many parameters
are expected by driver/verbs. I thought the qp_handle and ib_qp_attr is
enough, atleast according to the spec.
Along with this, I am going to submit another patch to catch "catastrophic"
errors in return value of the resize operation. This is due to the need
to check for 2 special cases : "CQ overrun" and "CQ inaccessible". For
these two errors, I think the queues should be deallocated and error
returned. This is in the second patch. I am not sure of the error numbers,
I guessed it from mthca_eq.c and could be wrong here.
Thanks,
- KK
diff -ruNp 1/mad.c 2/mad.c
--- 1/mad.c 2004-11-03 11:32:14.000000000 -0800
+++ 2/mad.c 2004-11-03 13:15:49.000000000 -0800
@@ -1629,6 +1629,14 @@ static void init_mad_queue(struct ib_mad
INIT_LIST_HEAD(&mad_queue->list);
}
+/*
+ * Allocate one mad QP.
+ *
+ * If the return indicates success, the value returned is the new size
+ * of the queue pair that got created.
+ *
+ * Return > 0 on success and -(ERRNO) on failure. Zero should never happen.
+ */
static int create_mad_qp(struct ib_mad_port_private *port_priv,
struct ib_mad_qp_info *qp_info,
enum ib_qp_type qp_type)
@@ -1652,15 +1660,23 @@ static int create_mad_qp(struct ib_mad_p
qp_init_attr.qp_type = qp_type;
qp_init_attr.port_num = port_priv->port_num;
qp_info->qp = ib_create_qp(port_priv->pd, &qp_init_attr);
- if (IS_ERR(qp_info->qp)) {
- printk(KERN_ERR PFX "Couldn't create ib_mad QP%d\n",
- get_spl_qp_index(qp_type));
+ if (!IS_ERR(qp_info->qp)) {
+ struct ib_qp_attr qp_attr;
+
+ ret = ib_query_qp(qp_info->qp, &qp_attr, 0, &qp_init_attr);
+ if (ret < 0) {
+ /*
+ * For any error, use the same size we used to
+ * create the queue.
+ */
+ ret = qp_init_attr.cap.max_send_wr +
+ qp_init_attr.cap.max_recv_wr;
+ }
+ } else {
ret = PTR_ERR(qp_info->qp);
- goto error;
+ printk(KERN_ERR PFX "Couldn't create ib_mad QP%d err:%d\n",
+ get_spl_qp_index(qp_type), ret);
}
- return 0;
-
-error:
return ret;
}
@@ -1682,6 +1698,7 @@ static int ib_mad_port_open(struct ib_de
.size = (unsigned long) high_memory - PAGE_OFFSET
};
struct ib_mad_port_private *port_priv;
+ int total_qp_size;
unsigned long flags;
/* First, check if port already open at MAD layer */
@@ -1731,11 +1748,25 @@ static int ib_mad_port_open(struct ib_de
}
ret = create_mad_qp(port_priv, &port_priv->qp_info[0], IB_QPT_SMI);
- if (ret)
+ if (ret <= 0)
goto error6;
+ total_qp_size = ret;
+
ret = create_mad_qp(port_priv, &port_priv->qp_info[1], IB_QPT_GSI);
- if (ret)
+ if (ret <= 0)
goto error7;
+ total_qp_size += ret;
+
+ /* Resize if the total QP[0,1] size is greater than CQ size. */
+ if (total_qp_size > cq_size) {
+ printk(KERN_DEBUG PFX "ib_mad_port_open: increasing size of "
+ "CQ from %d to %d\n", cq_size, total_qp_size);
+ if ((ret = ib_resize_cq(port_priv->cq, total_qp_size)) < 0) {
+ printk(KERN_DEBUG PFX "Couldn't increase CQ size - "
+ "err:%d\n", ret);
+ /* continue, not an error */
+ }
+ }
spin_lock_init(&port_priv->reg_lock);
INIT_LIST_HEAD(&port_priv->agent_list);
More information about the general
mailing list