...as required by IB Spec, C10-29.
Signed-off-by: Joachim Fenkes <fenkes@de.ibm.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
        };
        u32 qp_type;
        enum ehca_ext_qp_type ext_type;
+       enum ib_qp_state state;
        struct ipz_queue ipz_squeue;
        struct ipz_queue ipz_rqueue;
        struct h_galpas galpas;
 
        spin_lock_init(&my_qp->spinlock_r);
        my_qp->qp_type = qp_type;
        my_qp->ext_type = parms.ext_type;
+       my_qp->state = IB_QPS_RESET;
 
        if (init_attr->recv_cq)
                my_qp->recv_cq =
        if (attr_mask & IB_QP_QKEY)
                my_qp->qkey = attr->qkey;
 
+       my_qp->state = qp_new_state;
+
 modify_qp_exit2:
        if (squeue_locked) { /* this means: sqe -> rts */
                spin_unlock_irqrestore(&my_qp->spinlock_s, flags);
 
        int ret = 0;
        unsigned long flags;
 
+       if (unlikely(my_qp->state != IB_QPS_RTS)) {
+               ehca_err(qp->device, "QP not in RTS state  qpn=%x", qp->qp_num);
+               return -EINVAL;
+       }
+
        /* LOCK the QUEUE */
        spin_lock_irqsave(&my_qp->spinlock_s, flags);