[openib-general] [PATCH 1/2] Resize CQ
Krishna Kumar
krkumar at us.ibm.com
Wed Nov 3 17:44:01 PST 2004
This is after incorporating feedback from Sean. Compiles cleanly.
Thanks,
- KK
diff -ruNp 1/mad.c 2/mad.c
--- 1/mad.c 2004-11-03 16:03:25.000000000 -0800
+++ 2/mad.c 2004-11-03 17:37:31.000000000 -0800
@@ -1692,6 +1692,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)
@@ -1715,15 +1723,18 @@ 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)) {
+ /*
+ * Driver should have modified the cap max_* fields
+ * if it increased the qp send/recv size.
+ */
+ 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;
}
@@ -1747,6 +1758,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 */
@@ -1797,11 +1809,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 size of QP[0,1] 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