[openib-general] Re: [PATCH] [2/2] change QP state to SQE
Roland Dreier
roland at topspin.com
Fri Nov 12 20:21:39 PST 2004
OK, here's a patch that adds support for "Current QP state" in the
modify QP verb. Does this look OK?
Thanks,
Roland
Index: infiniband/include/ib_verbs.h
===================================================================
--- infiniband/include/ib_verbs.h (revision 1223)
+++ infiniband/include/ib_verbs.h (working copy)
@@ -421,7 +421,8 @@
enum ib_qp_attr_mask {
IB_QP_STATE = 1,
- IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<1),
+ IB_QP_CUR_STATE = (1<<1),
+ IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2),
IB_QP_ACCESS_FLAGS = (1<<3),
IB_QP_PKEY_INDEX = (1<<4),
IB_QP_PORT = (1<<5),
@@ -460,6 +461,7 @@
struct ib_qp_attr {
enum ib_qp_state qp_state;
+ enum ib_qp_state cur_qp_state;
enum ib_mtu path_mtu;
enum ib_mig_state path_mig_state;
u32 qkey;
Index: infiniband/hw/mthca/mthca_qp.c
===================================================================
--- infiniband/hw/mthca/mthca_qp.c (revision 1223)
+++ infiniband/hw/mthca/mthca_qp.c (working copy)
@@ -394,13 +394,16 @@
[MLX] = IB_QP_SQ_PSN,
},
.opt_param = {
- [UD] = IB_QP_QKEY,
- [RC] = (IB_QP_ALT_PATH |
+ [UD] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ [RC] = (IB_QP_CUR_STATE |
+ IB_QP_ALT_PATH |
IB_QP_ACCESS_FLAGS |
IB_QP_PKEY_INDEX |
IB_QP_MIN_RNR_TIMER |
IB_QP_PATH_MIG_STATE),
- [MLX] = IB_QP_QKEY,
+ [MLX] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
}
}
},
@@ -410,12 +413,14 @@
[IB_QPS_RTS] = {
.trans = MTHCA_TRANS_RTS2RTS,
.opt_param = {
- [UD] = IB_QP_QKEY,
+ [UD] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
[RC] = (IB_QP_ACCESS_FLAGS |
IB_QP_ALT_PATH |
IB_QP_PATH_MIG_STATE |
IB_QP_MIN_RNR_TIMER),
- [MLX] = IB_QP_QKEY,
+ [MLX] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
}
},
[IB_QPS_SQD] = {
@@ -427,9 +432,36 @@
[IB_QPS_ERR] = { .trans = MTHCA_TRANS_ANY2ERR },
[IB_QPS_RTS] = {
.trans = MTHCA_TRANS_SQD2RTS,
+ .opt_param = {
+ [UD] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ [RC] = (IB_QP_CUR_STATE |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_MIN_RNR_TIMER |
+ IB_QP_PATH_MIG_STATE),
+ [MLX] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ }
},
[IB_QPS_SQD] = {
.trans = MTHCA_TRANS_SQD2SQD,
+ .opt_param = {
+ [UD] = (IB_QP_PKEY_INDEX |
+ IB_QP_QKEY),
+ [RC] = (IB_QP_TIMEOUT |
+ IB_QP_RETRY_CNT |
+ IB_QP_RNR_RETRY |
+ IB_QP_MAX_QP_RD_ATOMIC |
+ IB_QP_CUR_STATE |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_PKEY_INDEX |
+ IB_QP_MIN_RNR_TIMER |
+ IB_QP_PATH_MIG_STATE),
+ [MLX] = (IB_QP_PKEY_INDEX |
+ IB_QP_QKEY),
+ }
}
},
[IB_QPS_SQE] = {
@@ -437,6 +469,14 @@
[IB_QPS_ERR] = { .trans = MTHCA_TRANS_ANY2ERR },
[IB_QPS_RTS] = {
.trans = MTHCA_TRANS_SQERR2RTS,
+ .opt_param = {
+ [UD] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ [RC] = (IB_QP_CUR_STATE |
+ IB_QP_MIN_RNR_TIMER),
+ [MLX] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ }
}
},
[IB_QPS_ERR] = {
@@ -490,9 +530,19 @@
u8 status;
int err;
- spin_lock_irq(&qp->lock);
- cur_state = qp->state;
- spin_unlock_irq(&qp->lock);
+ if (attr_mask & IB_QP_CUR_STATE) {
+ if (attr->cur_qp_state != IB_QPS_RTR &&
+ attr->cur_qp_state != IB_QPS_RTS &&
+ attr->cur_qp_state != IB_QPS_SQD &&
+ attr->cur_qp_state != IB_QPS_SQE)
+ return -EINVAL;
+ else
+ cur_state = attr->cur_qp_state;
+ } else {
+ spin_lock_irq(&qp->lock);
+ cur_state = qp->state;
+ spin_unlock_irq(&qp->lock);
+ }
if (attr_mask & IB_QP_STATE) {
if (attr->qp_state < 0 || attr->qp_state > IB_QPS_ERR)
More information about the general
mailing list