RDMA/hns: Only assign dest_qp if IB_QP_DEST_QPN bit is set
authorLijun Ou <oulijun@huawei.com>
Fri, 29 Sep 2017 15:10:10 +0000 (23:10 +0800)
committerDoug Ledford <dledford@redhat.com>
Fri, 29 Sep 2017 16:09:21 +0000 (12:09 -0400)
Only when the IB_QP_DEST_QPN flag of attr_mask is set is it valid to
assign the dest_qp_num into the dest_qp field of qp context.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Shaobo Xu <xushaobo2@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/hns/hns_roce_hw_v1.c

index 93010a5..55e6daa 100644 (file)
@@ -2888,10 +2888,11 @@ static int hns_roce_v1_m_qp(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
                               QP_CONTEXT_QPC_BYTES_32_RESPONDER_RESOURCES_S,
                               ilog2((unsigned int)attr->max_dest_rd_atomic));
 
-               roce_set_field(context->qpc_bytes_36,
-                              QP_CONTEXT_QPC_BYTES_36_DEST_QP_M,
-                              QP_CONTEXT_QPC_BYTES_36_DEST_QP_S,
-                              attr->dest_qp_num);
+               if (attr_mask & IB_QP_DEST_QPN)
+                       roce_set_field(context->qpc_bytes_36,
+                                      QP_CONTEXT_QPC_BYTES_36_DEST_QP_M,
+                                      QP_CONTEXT_QPC_BYTES_36_DEST_QP_S,
+                                      attr->dest_qp_num);
 
                /* Configure GID index */
                port_num = rdma_ah_get_port_num(&attr->ah_attr);