gen2_basic - handle auto path migration properly

Signed-off by: Robert Walsh <robert.walsh@qlogic.com>

diff -rNu a/gen2_basic/test_qp.c b/gen2_basic/test_qp.c
--- a/gen2_basic/test_qp.c	2006-09-13 19:15:59.829006000 -0700
+++ b/gen2_basic/test_qp.c	2006-08-14 14:16:57.911621000 -0700
@@ -586,6 +586,7 @@
 }
 
 void cleanup_mask(
+	IN	struct ibv_device_attr *device_attr,
 	IN	enum ibv_qp_type qp_type,
 	IN OUT	int* mask)
 {
@@ -607,6 +608,8 @@
 		*mask &= ~IBV_QP_MAX_DEST_RD_ATOMIC;
 		*mask &= ~IBV_QP_MAX_QP_RD_ATOMIC;
 	}
+	if (!(device_attr->device_cap_flags & IBV_DEVICE_AUTO_PATH_MIG))
+		*mask &= ~IBV_QP_ALT_PATH;
 }
 
 int my_query_qp(
@@ -774,7 +777,7 @@
 	case REQUIRED_ATTR:
 		mask |= test_vector[idx].required_attr;
 
-		cleanup_mask(qp_type, &mask);
+		cleanup_mask(device_attr, qp_type, &mask);
 		mask &= ~IBV_QP_PATH_MIG_STATE; 
 
 		if (test_vector[idx].to == IBV_QPS_SQD && test_vector[idx].from == IBV_QPS_SQD && qp_type != IBV_QPT_RC)
@@ -798,8 +801,8 @@
 			temp_mask = test_vector[idx].optional_attr;
 			mask = test_vector[idx].required_attr | test_vector[idx].optional_attr;
 		}
-		cleanup_mask(qp_type, &mask);
-		cleanup_mask(qp_type, &temp_mask);
+		cleanup_mask(device_attr, qp_type, &mask);
+		cleanup_mask(device_attr, qp_type, &temp_mask);
 
 		for (i = 1; i <= 20; ++i) {
 			if ((1 << i) & temp_mask) {
@@ -820,7 +823,7 @@
 	
 	case NOT_ALL_REQUIRED:
 		mask = test_vector[idx].required_attr;
-		cleanup_mask(qp_type, &mask);
+		cleanup_mask(device_attr, qp_type, &mask);
 
 		for (i = 1; i <= 20; ++i) {
 			if ((1 << i) & mask) {
@@ -835,7 +838,7 @@
 		break;
 	case NOT_ALL_OPTIONAL:
 		mask = test_vector[idx].required_attr | test_vector[idx].optional_attr;
-		cleanup_mask(qp_type, &mask);
+		cleanup_mask(device_attr, qp_type, &mask);
 
 		if (test_vector[idx].to == IBV_QPS_SQD && test_vector[idx].from == IBV_QPS_SQD && qp_type != IBV_QPT_RC)
 			mask &= ~IBV_QP_PORT;
@@ -855,7 +858,7 @@
 		break;
 	case INVALID_ATTR:
 		mask = test_vector[idx].required_attr | test_vector[idx].optional_attr;
-		cleanup_mask(qp_type, &mask);
+		cleanup_mask(device_attr, qp_type, &mask);
 
 		mask = get_random_mask(rand_gen, mask);
 
@@ -1420,7 +1422,7 @@
 
 					for (j = 1; j < 20; ++j) {
 						int mask = test_vector[i].optional_attr;
-						cleanup_mask(qp_type, &mask);
+						cleanup_mask(&device_attr, qp_type, &mask);
 						if ((1 << j) & mask) {
 							get_qp_cap(rand_gen, 1, &device_attr, &attr.cap);
 
@@ -1540,7 +1542,7 @@
 				mask = IBV_QP_STATE | IBV_QP_TIMEOUT | IBV_QP_RETRY_CNT | IBV_QP_RNR_RETRY | 
 					IBV_QP_SQ_PSN | IBV_QP_MAX_QP_RD_ATOMIC | IBV_QP_PATH_MIG_STATE;
 
-				cleanup_mask(qp_type, &mask);
+				cleanup_mask(&device_attr, qp_type, &mask);
 
 				qp_attr.path_mig_state = IBV_MIG_REARM;
 
@@ -1556,7 +1558,7 @@
 
 				mask = IBV_QP_STATE | IBV_QP_PATH_MIG_STATE;
 
-				cleanup_mask(qp_type, &mask);
+				cleanup_mask(&device_attr, qp_type, &mask);
 
 				qp_attr.path_mig_state = IBV_MIG_REARM;
 
@@ -1584,7 +1586,7 @@
 
 				mask = IBV_QP_STATE | IBV_QP_PATH_MIG_STATE;
 
-				cleanup_mask(qp_type, &mask);
+				cleanup_mask(&device_attr, qp_type, &mask);
 
 				qp_attr.path_mig_state = IBV_MIG_REARM;
 
