diff options
author | Bryan O'Sullivan <bos@pathscale.com> | 2006-05-23 14:32:30 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-05-23 16:27:06 -0400 |
commit | b228b43c491c53d1838e06f47a7470db9f84d899 (patch) | |
tree | 3dc567452c12e13ed89d6c12563558cd9407d48c /drivers/infiniband/hw | |
parent | ebac3800e5652063aa9491ef7fb4d57e089eb385 (diff) |
IB/ipath: don't modify QP if changes fail
Make sure modify_qp won't modify the QP if any of the changes failed.
Signed-off-by: Bryan O'Sullivan <bos@pathscale.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_qp.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c index 18890716db1e..b26146c16588 100644 --- a/drivers/infiniband/hw/ipath/ipath_qp.c +++ b/drivers/infiniband/hw/ipath/ipath_qp.c | |||
@@ -427,6 +427,7 @@ static void ipath_error_qp(struct ipath_qp *qp) | |||
427 | int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, | 427 | int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, |
428 | int attr_mask) | 428 | int attr_mask) |
429 | { | 429 | { |
430 | struct ipath_ibdev *dev = to_idev(ibqp->device); | ||
430 | struct ipath_qp *qp = to_iqp(ibqp); | 431 | struct ipath_qp *qp = to_iqp(ibqp); |
431 | enum ib_qp_state cur_state, new_state; | 432 | enum ib_qp_state cur_state, new_state; |
432 | unsigned long flags; | 433 | unsigned long flags; |
@@ -443,6 +444,19 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, | |||
443 | attr_mask)) | 444 | attr_mask)) |
444 | goto inval; | 445 | goto inval; |
445 | 446 | ||
447 | if (attr_mask & IB_QP_AV) | ||
448 | if (attr->ah_attr.dlid == 0 || | ||
449 | attr->ah_attr.dlid >= IPS_MULTICAST_LID_BASE) | ||
450 | goto inval; | ||
451 | |||
452 | if (attr_mask & IB_QP_PKEY_INDEX) | ||
453 | if (attr->pkey_index >= ipath_layer_get_npkeys(dev->dd)) | ||
454 | goto inval; | ||
455 | |||
456 | if (attr_mask & IB_QP_MIN_RNR_TIMER) | ||
457 | if (attr->min_rnr_timer > 31) | ||
458 | goto inval; | ||
459 | |||
446 | switch (new_state) { | 460 | switch (new_state) { |
447 | case IB_QPS_RESET: | 461 | case IB_QPS_RESET: |
448 | ipath_reset_qp(qp); | 462 | ipath_reset_qp(qp); |
@@ -457,13 +471,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, | |||
457 | 471 | ||
458 | } | 472 | } |
459 | 473 | ||
460 | if (attr_mask & IB_QP_PKEY_INDEX) { | 474 | if (attr_mask & IB_QP_PKEY_INDEX) |
461 | struct ipath_ibdev *dev = to_idev(ibqp->device); | ||
462 | |||
463 | if (attr->pkey_index >= ipath_layer_get_npkeys(dev->dd)) | ||
464 | goto inval; | ||
465 | qp->s_pkey_index = attr->pkey_index; | 475 | qp->s_pkey_index = attr->pkey_index; |
466 | } | ||
467 | 476 | ||
468 | if (attr_mask & IB_QP_DEST_QPN) | 477 | if (attr_mask & IB_QP_DEST_QPN) |
469 | qp->remote_qpn = attr->dest_qp_num; | 478 | qp->remote_qpn = attr->dest_qp_num; |
@@ -479,12 +488,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, | |||
479 | if (attr_mask & IB_QP_ACCESS_FLAGS) | 488 | if (attr_mask & IB_QP_ACCESS_FLAGS) |
480 | qp->qp_access_flags = attr->qp_access_flags; | 489 | qp->qp_access_flags = attr->qp_access_flags; |
481 | 490 | ||
482 | if (attr_mask & IB_QP_AV) { | 491 | if (attr_mask & IB_QP_AV) |
483 | if (attr->ah_attr.dlid == 0 || | ||
484 | attr->ah_attr.dlid >= IPS_MULTICAST_LID_BASE) | ||
485 | goto inval; | ||
486 | qp->remote_ah_attr = attr->ah_attr; | 492 | qp->remote_ah_attr = attr->ah_attr; |
487 | } | ||
488 | 493 | ||
489 | if (attr_mask & IB_QP_PATH_MTU) | 494 | if (attr_mask & IB_QP_PATH_MTU) |
490 | qp->path_mtu = attr->path_mtu; | 495 | qp->path_mtu = attr->path_mtu; |
@@ -499,11 +504,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, | |||
499 | qp->s_rnr_retry_cnt = qp->s_rnr_retry; | 504 | qp->s_rnr_retry_cnt = qp->s_rnr_retry; |
500 | } | 505 | } |
501 | 506 | ||
502 | if (attr_mask & IB_QP_MIN_RNR_TIMER) { | 507 | if (attr_mask & IB_QP_MIN_RNR_TIMER) |
503 | if (attr->min_rnr_timer > 31) | ||
504 | goto inval; | ||
505 | qp->s_min_rnr_timer = attr->min_rnr_timer; | 508 | qp->s_min_rnr_timer = attr->min_rnr_timer; |
506 | } | ||
507 | 509 | ||
508 | if (attr_mask & IB_QP_QKEY) | 510 | if (attr_mask & IB_QP_QKEY) |
509 | qp->qkey = attr->qkey; | 511 | qp->qkey = attr->qkey; |