gen2_basic - fix is_global settings for AH attributes

For valid address handles, the is_global field of the AH attribute should
not be a random number if the dlid is a multicast LID.

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

diff -rNu a/gen2_basic/main.h b/gen2_basic/main.h
--- a/gen2_basic/main.h	2006-01-08 10:59:26.320271000 -0800
+++ b/gen2_basic/main.h	2006-09-13 18:41:24.169155000 -0700
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2006 QLogic Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -102,6 +103,10 @@
 	IN	int valid_value,
 	IN	struct VL_random_t *rand_gen);
 
+uint8_t get_is_global(
+	IN	struct VL_random_t *rand_gen,
+	IN	uint16_t dlid);
+
 int my_modify_qp(
 	IN	struct VL_random_t *rand_gen,
 	IN	struct ibv_qp *qp,
diff -rNu a/gen2_basic/test_av.c b/gen2_basic/test_av.c
--- a/gen2_basic/test_av.c	2006-07-26 17:46:51.707754000 -0700
+++ b/gen2_basic/test_av.c	2006-08-14 14:16:43.790758000 -0700
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2006 QLogic Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -71,6 +72,16 @@
     return static_rate;
 }
 
+uint8_t get_is_global(
+	IN	struct VL_random_t *rand_gen,
+	IN	uint16_t dlid)
+{
+	if (dlid >= 0xC000 && dlid < 0xFFFF)
+		return 1;
+
+	return VL_random(rand_gen, 2);
+}
+
 /* ibv_create_ah ibv_destroy_ah */
 int av_1(
 	IN      struct config_t *config,
@@ -105,7 +116,6 @@
 	{
 		struct ibv_ah 		*av = NULL;
 		struct ibv_ah_attr av_attr  = {
-			.is_global     = VL_random(rand_gen, 2),
 			.dlid          = VL_range(rand_gen, 1, 0xffff),
 			.sl            = VL_range(rand_gen, 0, 15),
 			.src_path_bits = VL_range(rand_gen, 0, 0x8f),
@@ -117,6 +127,7 @@
 				.hop_limit = VL_range(rand_gen, 1, 0xff),
 			}
 		};
+		av_attr.is_global = get_is_global(rand_gen, av_attr.dlid);
 		av = ibv_create_ah(pd, &av_attr);
 		CHECK_PTR("ibv_create_ah", av, goto cleanup);
 	
@@ -130,7 +141,6 @@
 	{
 		struct ibv_ah 		*av = NULL;
 		struct ibv_ah_attr av_attr  = {
-			.is_global     = VL_random(rand_gen, 2),
 			.dlid          = VL_range(rand_gen, 1, 0xffff),
 			.sl            = VL_range(rand_gen, 0, 15),
 			.src_path_bits = VL_range(rand_gen, 0, 0x8f),
@@ -142,6 +152,7 @@
 				.hop_limit = VL_range(rand_gen, 1, 0xff),
 			}
 		};
+		av_attr.is_global = get_is_global(rand_gen, av_attr.dlid);
 		av = ibv_create_ah(pd, &av_attr);
 		if (av != NULL) {
 			FAILED;
@@ -152,7 +163,6 @@
 	{
 		struct ibv_ah 		*av = NULL;
 		struct ibv_ah_attr av_attr  = {
-			.is_global     = VL_random(rand_gen, 2),
 			.dlid          = VL_range(rand_gen, 1, 0xffff),
 			.sl            = VL_range(rand_gen, 0, 15),
 			.src_path_bits = VL_range(rand_gen, 0, 0x8f),
@@ -164,6 +174,7 @@
 				.hop_limit = VL_range(rand_gen, 1, 0xff),
 			}
 		};
+		av_attr.is_global = get_is_global(rand_gen, av_attr.dlid);
 		av = ibv_create_ah(pd, &av_attr);
 		if (av != NULL) {
 			FAILED;
@@ -174,7 +185,6 @@
 	{
 		struct ibv_ah 		*av = NULL;
 		struct ibv_ah_attr av_attr  = {
-			.is_global     = VL_random(rand_gen, 2),
 			.dlid          = VL_range(rand_gen, 1, 0xffff),
 			.sl            = VL_range(rand_gen, 0, 15),
 			.src_path_bits = VL_range(rand_gen, 0, 0x8f),
@@ -186,6 +196,7 @@
 				.hop_limit = VL_range(rand_gen, 1, 0xff),
 			}
 		};
+		av_attr.is_global = get_is_global(rand_gen, av_attr.dlid);
 		av = ibv_create_ah(pd, &av_attr);
 		if (av != NULL) {
 			FAILED;
@@ -199,7 +210,6 @@
 	{
 		struct ibv_ah 		*av = NULL;
 		struct ibv_ah_attr av_attr  = {
-			.is_global     = VL_random(rand_gen, 2),
 			.dlid          = 0,
 			.sl            = VL_range(rand_gen, 0, 15),
 			.src_path_bits = VL_range(rand_gen, 0, 0x8f),
@@ -211,6 +221,7 @@
 				.hop_limit = VL_range(rand_gen, 1, 0xff),
 			}
 		};
+		av_attr.is_global = get_is_global(rand_gen, av_attr.dlid);
 		av = ibv_create_ah(pd, &av_attr);
 		if (av != NULL) {
 			FAILED;
@@ -286,7 +297,6 @@
 
 	for (i = 0; i < device_attr.max_ah; ++i) {
 		struct ibv_ah_attr av_attr  = {
-			.is_global     = VL_random(rand_gen, 2),
 			.dlid          = VL_range(rand_gen, 1, 0xffff),
 			.sl            = VL_range(rand_gen, 0, 15),
 			.src_path_bits = VL_range(rand_gen, 0, 0x8f),
@@ -298,12 +308,12 @@
 				.hop_limit = VL_range(rand_gen, 1, 0xff),
 			}
 		};
+		av_attr.is_global = get_is_global(rand_gen, av_attr.dlid);
 		av[i] = ibv_create_ah(pd, &av_attr);
 		CHECK_PTR("ibv_create_ah", av[i], goto cleanup);
 	}
 	{
 		struct ibv_ah_attr av_attr  = {
-			.is_global     = VL_random(rand_gen, 2),
 			.dlid          = VL_range(rand_gen, 1, 0xffff),
 			.sl            = VL_range(rand_gen, 0, 15),
 			.src_path_bits = VL_range(rand_gen, 0, 0x8f),
@@ -315,6 +325,7 @@
 				.hop_limit = VL_range(rand_gen, 1, 0xff),
 			}
 		};
+		av_attr.is_global = get_is_global(rand_gen, av_attr.dlid);
 		av[device_attr.max_ah] = ibv_create_ah(pd, &av_attr);
 		if (av[device_attr.max_ah]) {
 			FAILED;
@@ -324,6 +335,8 @@
 	}
 	PASSED;
 
+	test_result = 0;
+
 cleanup:
 	WAIT_CLEANUP;
 
diff -rNu a/gen2_basic/test_poll_post.c b/gen2_basic/test_poll_post.c
--- a/gen2_basic/test_poll_post.c	2006-07-26 17:46:51.753706000 -0700
+++ b/gen2_basic/test_poll_post.c	2006-08-14 14:17:03.705821000 -0700
@@ -280,7 +281,6 @@
 
 	{
 		struct ibv_ah_attr av_attr  = {
-			.is_global     = VL_random(rand_gen, 2),
 			.dlid          = VL_range(rand_gen, 1, 0xffff),
 			.sl            = VL_range(rand_gen, 0, 15),
 			.src_path_bits = VL_range(rand_gen, 0, 0x8f),
@@ -292,6 +292,7 @@
 				.hop_limit = VL_range(rand_gen, 1, 0xff),
 			}
 		};
+		av_attr.is_global = get_is_global(rand_gen, av_attr.dlid);
 		av = ibv_create_ah(pd, &av_attr);
 		CHECK_PTR("ibv_create_ah", av, goto cleanup);
 	}
