Skip to contentSkip to conversation

osmtest: Handle other than default subnet prefix

PATCH New Hal Rosenstock 1 participant 1 message Oct 7, 2013 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 osmtest: Handle other than default subnet prefix

---

include/iba/ib_types.h +1 -0
index 24bad76..86fa07b 100644
@@ -213,6 +213,7 @@ BEGIN_C_DECLS
 * SOURCE
 */
 #define IB_DEFAULT_SUBNET_PREFIX			(CL_HTON64(0xFE80000000000000ULL))
+#define IB_DEFAULT_SUBNET_PREFIX_HO			(0xFE80000000000000ULL)
 /**********/
 /****d* IBA Base: Constants/IB_NODE_NUM_PORTS_MAX
 * NAME
libvendor/osm_vendor_ibumad.c +5 -0
index ee14f5b..5f8d207 100644
@@ -656,6 +656,11 @@ osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
 							cl_hton16(ca.ports[j]->pkeys[k]);
 				}
 				attr->num_pkeys = ca.ports[j]->pkeys_size;
+				if (attr->num_gids && attr->p_gid_table) {
+					attr->p_gid_table[0].unicast.prefix = cl_hton64(ca.ports[j]->gid_prefix);
+					attr->p_gid_table[0].unicast.interface_id = cl_hton64(ca.ports[j]->port_guid);
+					attr->num_gids = 1;
+				}
 				attr++;
 				if (attr - p_attr_array > *p_num_ports) {
 					done = 1;
opensm/main.c +2 -0
index 3f10e4f..d3a3730 100644
@@ -435,6 +435,8 @@ static ib_net64_t get_port_guid(IN osm_opensm_t * p_osm, uint64_t port_guid)
 	for (i = 0; i < num_ports; i++) {
 		attr_array[i].num_pkeys = 0;
 		attr_array[i].p_pkey_table = NULL;
+		attr_array[i].num_gids = 0;
+		attr_array[i].p_gid_table = NULL;
 	}
 
 	/* Call the transport layer for a list of local port GUID values */
osmtest/include/osmtest.h +1 -0
index 4a7f0a3..f63ea74 100644
@@ -128,6 +128,7 @@ typedef struct _osmtest {
 
 	osmtest_opt_t opt;
 	ib_port_attr_t local_port;
+	ib_gid_t local_port_gid;
 	subnet_t exp_subn;
 	cl_qpool_t node_pool;
 	cl_qpool_t port_pool;
osmtest/osmt_multicast.c +1 -1
index ac8d1b2..93b04a2 100644
@@ -378,7 +378,7 @@ void osmt_init_mc_query_rec(IN osmtest_t * const p_osmt,
 	       sizeof(p_osmt->local_port.port_guid));
 
 	/*  use our own subnet prefix: */
-	p_mc_req->port_gid.unicast.prefix = CL_HTON64(0xFE80000000000000ULL);
+	p_mc_req->port_gid.unicast.prefix = cl_hton64(p_osmt->local_port_gid.unicast.prefix);
 
 	/*  ib_net32_t  qkey; */
 	/*  ib_net16_t  mlid; - we keep it zero for upper level to decide. */
osmtest/osmt_service.c +3 -3
index a37c946..961c904 100644
@@ -85,7 +85,7 @@ osmt_register_service(IN osmtest_t * const p_osmt,
 	/* set the new service record fields */
 	svc_rec.service_id = service_id;
 	svc_rec.service_pkey = service_pkey;
-	svc_rec.service_gid.unicast.prefix = 0;
+	svc_rec.service_gid.unicast.prefix = p_osmt->local_port_gid.unicast.prefix;
 	svc_rec.service_gid.unicast.interface_id = p_osmt->local_port.port_guid;
 	svc_rec.service_lease = service_lease;
 	memset(&svc_rec.service_key, 0, 16 * sizeof(uint8_t));
@@ -188,7 +188,7 @@ osmt_register_service_with_full_key(IN osmtest_t * const p_osmt,
 	/* set the new service record fields */
 	svc_rec.service_id = service_id;
 	svc_rec.service_pkey = service_pkey;
-	svc_rec.service_gid.unicast.prefix = 0;
+	svc_rec.service_gid.unicast.prefix = p_osmt->local_port_gid.unicast.prefix;
 	svc_rec.service_gid.unicast.interface_id = p_osmt->local_port.port_guid;
 	svc_rec.service_lease = service_lease;
 	memset(&svc_rec.service_key, 0, 16 * sizeof(uint8_t));
@@ -312,7 +312,7 @@ osmt_register_service_with_data(IN osmtest_t * const p_osmt,
 	/* set the new service record fields */
 	svc_rec.service_id = service_id;
 	svc_rec.service_pkey = service_pkey;
-	svc_rec.service_gid.unicast.prefix = 0;
+	svc_rec.service_gid.unicast.prefix = p_osmt->local_port_gid.unicast.prefix;
 	svc_rec.service_gid.unicast.interface_id = p_osmt->local_port.port_guid;
 	svc_rec.service_lease = service_lease;
 	memset(&svc_rec.service_key, 0, 16 * sizeof(uint8_t));
osmtest/osmtest.c +18 -1
index c3d4a4f..11baa98 100644
@@ -7206,9 +7206,16 @@ osmtest_bind(IN osmtest_t * p_osmt,
 	ib_api_status_t status;
 	uint32_t num_ports = MAX_LOCAL_IBPORTS;
 	ib_port_attr_t attr_array[MAX_LOCAL_IBPORTS] = { {0} };
+	ib_gid_t gid[MAX_LOCAL_IBPORTS];
+	int i;
 
 	OSM_LOG_ENTER(&p_osmt->log);
 
+	for (i = 0; i < MAX_LOCAL_IBPORTS; i++) {
+		attr_array[i].num_gids = 1;
+		attr_array[i].p_gid_table = &gid[i];
+	}
+
 	/*
 	 * Call the transport layer for a list of local port
 	 * GUID values.
@@ -7255,7 +7262,17 @@ osmtest_bind(IN osmtest_t * p_osmt,
 	 * Copy the port info for the selected port.
 	 */
 	memcpy(&p_osmt->local_port, &attr_array[port_index],
-	       sizeof(p_osmt->local_port));
+	       sizeof(p_osmt->local_port) - sizeof(p_osmt->local_port.p_gid_table));
+	if (p_osmt->local_port.num_gids) {
+		p_osmt->local_port_gid.unicast.prefix = p_osmt->local_port.p_gid_table[0].unicast.prefix;
+		p_osmt->local_port_gid.unicast.interface_id = p_osmt->local_port.p_gid_table[0].unicast.interface_id;
+	} else {
+		p_osmt->local_port_gid.unicast.prefix = IB_DEFAULT_SUBNET_PREFIX_HO;
+		p_osmt->local_port_gid.unicast.interface_id = attr_array[port_index].port_guid;
+		p_osmt->local_port.p_gid_table = NULL;
+	}
+	p_osmt->local_port.num_gids = 1;
+	p_osmt->local_port.p_gid_table = &p_osmt->local_port_gid;
 
 	/* bind to the SA */
 	OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html