[openib-general] [PATCH] mthca: add alternate path support

Michael S. Tsirkin mst at mellanox.co.il
Thu Jan 5 05:44:45 PST 2006


mthca: add alternate path support.

Signed-off-by: Dotan Barak <dotanb at mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: last_stable/drivers/infiniband/hw/mthca/mthca_qp.c
===================================================================
--- last_stable.orig/drivers/infiniband/hw/mthca/mthca_qp.c	2006-01-05 15:23:18.000000000 +0200
+++ last_stable/drivers/infiniband/hw/mthca/mthca_qp.c	2006-01-05 15:23:43.000000000 +0200
@@ -547,6 +547,24 @@
 	return cpu_to_be32(hw_access_flags);
 }
 
+static void mthca_ah_set(struct ib_ah_attr *ah, struct mthca_qp_path *mthca_ah)
+{
+	mthca_ah->g_mylmc = ah->src_path_bits & 0x7f;
+	mthca_ah->rlid = cpu_to_be16(ah->dlid);
+	mthca_ah->static_rate = !!ah->static_rate;
+	if (ah->ah_flags & IB_AH_GRH) {
+		mthca_ah->g_mylmc |= 1 << 7;
+		mthca_ah->mgid_index = ah->grh.sgid_index;
+		mthca_ah->hop_limit = ah->grh.hop_limit;
+		mthca_ah->sl_tclass_flowlabel = 
+			cpu_to_be32((ah->sl << 28) |
+				(ah->grh.traffic_class << 20) | 
+				(ah->grh.flow_label));
+		memcpy(mthca_ah->rgid, ah->grh.dgid.raw, 16);
+	} else
+		mthca_ah->sl_tclass_flowlabel = cpu_to_be32(ah->sl << 28);
+}
+
 int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
 {
 	struct mthca_dev *dev = to_mdev(ibqp->device);
@@ -710,28 +728,14 @@
 	}
 
 	if (attr_mask & IB_QP_RNR_RETRY) {
-		qp_context->pri_path.rnr_retry = attr->rnr_retry << 5;
-		qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RNR_RETRY);
+		qp_context->alt_path.rnr_retry = qp_context->pri_path.rnr_retry =
+			attr->rnr_retry << 5;
+		qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RNR_RETRY | 
+							MTHCA_QP_OPTPAR_ALT_RNR_RETRY);
 	}
 
 	if (attr_mask & IB_QP_AV) {
-		qp_context->pri_path.g_mylmc     = attr->ah_attr.src_path_bits & 0x7f;
-		qp_context->pri_path.rlid        = cpu_to_be16(attr->ah_attr.dlid);
-		qp_context->pri_path.static_rate = !!attr->ah_attr.static_rate;
-		if (attr->ah_attr.ah_flags & IB_AH_GRH) {
-			qp_context->pri_path.g_mylmc |= 1 << 7;
-			qp_context->pri_path.mgid_index = attr->ah_attr.grh.sgid_index;
-			qp_context->pri_path.hop_limit = attr->ah_attr.grh.hop_limit;
-			qp_context->pri_path.sl_tclass_flowlabel =
-				cpu_to_be32((attr->ah_attr.sl << 28)                |
-					    (attr->ah_attr.grh.traffic_class << 20) |
-					    (attr->ah_attr.grh.flow_label));
-			memcpy(qp_context->pri_path.rgid,
-			       attr->ah_attr.grh.dgid.raw, 16);
-		} else {
-			qp_context->pri_path.sl_tclass_flowlabel =
-				cpu_to_be32(attr->ah_attr.sl << 28);
-		}
+		mthca_ah_set(&attr->ah_attr, &qp_context->pri_path);
 		qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PRIMARY_ADDR_PATH);
 	}
 
@@ -740,7 +744,20 @@
 		qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_ACK_TIMEOUT);
 	}
 
-	/* XXX alt_path */
+	/* alt_path */
+	if (attr_mask & IB_QP_ALT_PATH) {
+		if (attr->alt_port_num == 0 || attr->alt_port_num > dev->limits.num_ports) {
+			mthca_dbg(dev, "Alternate port number (%u) is invalid\n", 
+				attr->alt_port_num);
+			return -EINVAL;
+		}
+
+		mthca_ah_set(&attr->alt_ah_attr, &qp_context->alt_path);
+		qp_context->alt_path.port_pkey |= cpu_to_be32(attr->alt_pkey_index | 
+							      attr->alt_port_num << 24);
+		qp_context->alt_path.ackto = attr->alt_timeout << 3;
+		qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_ALT_ADDR_PATH);
+	}
 
 	/* leave rdd as 0 */
 	qp_context->pd         = cpu_to_be32(to_mpd(ibqp->pd)->pd_num);

-- 
MST



More information about the general mailing list