Skip to contentSkip to conversation

opensm/osm_sa_mcmember_record.c: move mgid allocation code

PATCH New Sasha Khapyorsky 2 participants 12 messages Nov 13, 2009 – Dec 1, 2009 2 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opensm/osm_sa_mcmember_record.c: move mgid allocation code

Move new MGID allocation code into separate function build_new_mgid().

---
 opensm/opensm/osm_sa_mcmember_record.c |   68 +++++++++++++++++++-------------
 1 files changed, 40 insertions(+), 28 deletions(-)
opensm/opensm/osm_sa_mcmember_record.c +40 -28
index 357e6ab..f6a9ead 100644
@@ -712,19 +712,45 @@ static boolean_t mgrp_request_is_realizable(IN osm_sa_t * sa,
 	return TRUE;
 }
 
+static unsigned build_new_mgid(osm_sa_t * sa, ib_net64_t comp_mask,
+			       ib_member_rec_t * mcmr)
+{
+	ib_gid_t *mgid = &mcmr->mgid;
+	uint8_t scope;
+
+	/* use the given scope state only if requested! */
+	if (comp_mask & IB_MCR_COMPMASK_SCOPE)
+		ib_member_get_scope_state(mcmr->scope_state, &scope, NULL);
+	else
+	/* to guarantee no collision with other subnets use local scope! */
+		scope = IB_MC_SCOPE_LINK_LOCAL;
+
+	mgid->raw[0] = 0xff;
+	mgid->raw[1] = 0x10 | scope;
+	mgid->raw[2] = 0xa0;
+	mgid->raw[3] = 0x1b;
+
+	/* HACK: use the SA port gid to make it globally unique */
+	memcpy(&mgid->raw[4], &sa->p_subn->opt.subnet_prefix, sizeof(uint64_t));
+
+	/* HACK: how do we get a unique number - use the mlid twice */
+	memcpy(&mgid->raw[10], &mcmr->mlid, sizeof(uint16_t));
+	memcpy(&mgid->raw[12], &mcmr->mlid, sizeof(uint16_t));
+
+	return 1;
+}
+
 /**********************************************************************
  Call this function to create a new mgrp.
 **********************************************************************/
 static ib_api_status_t mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa,
 						IN ib_net64_t comp_mask,
 						IN const ib_member_rec_t *
-						const p_recvd_mcmember_rec,
+						p_recvd_mcmember_rec,
 						IN const osm_physp_t * p_physp,
 						OUT osm_mgrp_t ** pp_mgrp)
 {
 	ib_net16_t mlid;
-	uint8_t scope;
-	ib_gid_t *p_mgid;
 	ib_api_status_t status = IB_SUCCESS;
 	ib_member_rec_t mcm_rec = *p_recvd_mcmember_rec;	/* copy for modifications */
 
@@ -743,37 +769,24 @@ static ib_api_status_t mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa,
 		goto Exit;
 	}
 
-	OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
-		"Obtained new mlid 0x%X\n", cl_ntoh16(mlid));
+	OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Obtained new mlid 0x%X\n",
+		cl_ntoh16(mlid));
 
+	mcm_rec.mlid = mlid;
 	/* we need to create the new MGID if it was not defined */
 	if (!ib_gid_is_notzero(&p_recvd_mcmember_rec->mgid)) {
 		/* create a new MGID */
 		char gid_str[INET6_ADDRSTRLEN];
 
-		/* use the given scope state only if requested! */
-		if (comp_mask & IB_MCR_COMPMASK_SCOPE)
-			ib_member_get_scope_state(p_recvd_mcmember_rec->
-						  scope_state, &scope, NULL);
-		else
-			/* to guarantee no collision with other subnets use local scope! */
-			scope = IB_MC_SCOPE_LINK_LOCAL;
-
-		p_mgid = &(mcm_rec.mgid);
-		p_mgid->raw[0] = 0xFF;
-		p_mgid->raw[1] = 0x10 | scope;
-		p_mgid->raw[2] = 0xA0;
-		p_mgid->raw[3] = 0x1B;
-
-		/* HACK: use the SA port gid to make it globally unique */
-		memcpy((&p_mgid->raw[4]),
-		       &sa->p_subn->opt.subnet_prefix, sizeof(uint64_t));
-
-		/* HACK: how do we get a unique number - use the mlid twice */
-		memcpy(&p_mgid->raw[10], &mlid, sizeof(uint16_t));
-		memcpy(&p_mgid->raw[12], &mlid, sizeof(uint16_t));
+		if (!build_new_mgid(sa, comp_mask, &mcm_rec)) {
+			OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B23: "
+				"cannot allocate unique MGID value\n");
+			free_mlid(sa, mlid);
+			status = IB_SA_MAD_STATUS_NO_RESOURCES;
+			goto Exit;
+		}
 		OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Allocated new MGID:%s\n",
-			inet_ntop(AF_INET6, p_mgid->raw, gid_str,
+			inet_ntop(AF_INET6, mcm_rec.mgid.raw, gid_str,
 				  sizeof gid_str));
 	} else if (!validate_requested_mgid(sa, &mcm_rec)) {
 		/* a specific MGID was requested so validate the resulting MGID */
@@ -795,7 +808,6 @@ static ib_api_status_t mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa,
 	}
 
 	/* create a new MC Group */
-	mcm_rec.mlid = mlid;
 	*pp_mgrp = osm_mgrp_new(sa->p_subn, mlid, &mcm_rec);
 	if (*pp_mgrp == NULL) {
 		OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B08: "
Signature · 6 lines
1.6.5.2

--
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
#1 lore raw

PATCH 1/1 opensm/osm_sa_member_record.c: mlid independent MGID generator

If we are going to do many MGID to single MLID compression we cannot use MLID value for unique MGID generation.

Instead use static counter and also add querying for potentially existing multicast group with same MGID value (with 1000 attempts limit).

---
 opensm/opensm/osm_sa_mcmember_record.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
opensm/opensm/osm_sa_mcmember_record.c +9 -4
index f6a9ead..c6856fc 100644
@@ -715,8 +715,10 @@ static boolean_t mgrp_request_is_realizable(IN osm_sa_t * sa,
 static unsigned build_new_mgid(osm_sa_t * sa, ib_net64_t comp_mask,
 			       ib_member_rec_t * mcmr)
 {
+	static uint32_t uniq_count;
 	ib_gid_t *mgid = &mcmr->mgid;
 	uint8_t scope;
+	unsigned i;
 
 	/* use the given scope state only if requested! */
 	if (comp_mask & IB_MCR_COMPMASK_SCOPE)
@@ -733,11 +735,14 @@ static unsigned build_new_mgid(osm_sa_t * sa, ib_net64_t comp_mask,
 	/* HACK: use the SA port gid to make it globally unique */
 	memcpy(&mgid->raw[4], &sa->p_subn->opt.subnet_prefix, sizeof(uint64_t));
 
-	/* HACK: how do we get a unique number - use the mlid twice */
-	memcpy(&mgid->raw[10], &mcmr->mlid, sizeof(uint16_t));
-	memcpy(&mgid->raw[12], &mcmr->mlid, sizeof(uint16_t));
+	for (i = 0; i < 1000; i++) {
+		memcpy(&mgid->raw[10], &uniq_count, 4);
+		uniq_count++;
+		if (!osm_get_mgrp_by_mgid(sa, mgid))
+			return 1;
+	}
 
-	return 1;
+	return 0;
 }
 
 /**********************************************************************
Signature · 6 lines
1.6.5.2

--
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
#2 lore raw

PATCH 1/1 osm_sa_mcmember_record.c: pass MCM Record data to mlid allocator

Pass whole MCMember Record request data to get_new_mlid() function. We need this for MGID compression implementation, so that for mlid value selection all MCMember join request parameters (including MGID value) could be used as mgid to mlid mapping trigger (signature checks or so).

Respectively move mlid allocation call to be after a point where all MCMember Record fields are already generated (MGID in particular) and after request validation.

---
 opensm/opensm/osm_sa_mcmember_record.c |   36 +++++++++++++------------------
 1 files changed, 15 insertions(+), 21 deletions(-)
opensm/opensm/osm_sa_mcmember_record.c +15 -21
index 85f0ca2..27675b6 100644
@@ -114,9 +114,10 @@ static void free_mlid(IN osm_sa_t * sa, IN uint16_t mlid)
 /*********************************************************************
  Get a new unused mlid by scanning all the used ones in the subnet.
 **********************************************************************/
-static ib_net16_t get_new_mlid(osm_sa_t * sa, ib_net16_t requested_mlid)
+static ib_net16_t get_new_mlid(osm_sa_t * sa, ib_member_rec_t * mcmr)
 {
 	osm_subn_t *p_subn = sa->p_subn;
+	ib_net16_t requested_mlid = mcmr->mlid;
 	unsigned i, max;
 
 	if (requested_mlid && cl_ntoh16(requested_mlid) >= IB_LID_MCAST_START_HO
@@ -761,23 +762,6 @@ static ib_api_status_t mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa,
 
 	OSM_LOG_ENTER(sa->p_log);
 
-	/*
-	   we allocate a new mlid number before we might use it
-	   for MGID ...
-	 */
-	mlid = get_new_mlid(sa, mcm_rec.mlid);
-	if (mlid == 0) {
-		OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B19: "
-			"get_new_mlid failed request mlid 0x%04x\n",
-			cl_ntoh16(mcm_rec.mlid));
-		status = IB_SA_MAD_STATUS_NO_RESOURCES;
-		goto Exit;
-	}
-
-	OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Obtained new mlid 0x%X\n",
-		cl_ntoh16(mlid));
-
-	mcm_rec.mlid = mlid;
 	/* we need to create the new MGID if it was not defined */
 	if (!ib_gid_is_notzero(&p_recvd_mcmember_rec->mgid)) {
 		/* create a new MGID */
@@ -786,7 +770,6 @@ static ib_api_status_t mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa,
 		if (!build_new_mgid(sa, comp_mask, &mcm_rec)) {
 			OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B23: "
 				"cannot allocate unique MGID value\n");
-			free_mlid(sa, mlid);
 			status = IB_SA_MAD_STATUS_NO_RESOURCES;
 			goto Exit;
 		}
@@ -797,7 +780,6 @@ static ib_api_status_t mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa,
 		/* a specific MGID was requested so validate the resulting MGID */
 		OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B22: "
 			"Invalid requested MGID\n");
-		free_mlid(sa, mlid);
 		status = IB_SA_MAD_STATUS_REQ_INVALID;
 		goto Exit;
 	}
@@ -807,11 +789,23 @@ static ib_api_status_t mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa,
 	    FALSE) {
 		OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B26: "
 			"Requested MGRP parameters are not realizable\n");
-		free_mlid(sa, mlid);
 		status = IB_SA_MAD_STATUS_REQ_INVALID;
 		goto Exit;
 	}
 
+	mlid = get_new_mlid(sa, &mcm_rec);
+	if (mlid == 0) {
+		OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B19: "
+			"get_new_mlid failed request mlid 0x%04x\n",
+			cl_ntoh16(mcm_rec.mlid));
+		status = IB_SA_MAD_STATUS_NO_RESOURCES;
+		goto Exit;
+	}
+
+	OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Obtained new mlid 0x%X\n",
+		cl_ntoh16(mlid));
+
+	mcm_rec.mlid = mlid;
 	/* create a new MC Group */
 	*pp_mgrp = osm_mgrp_new(sa->p_subn, mlid, &mcm_rec);
 	if (*pp_mgrp == NULL) {
Signature · 6 lines
1.6.5.2

--
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
#3 lore raw

PATCH 1/1 complib/cl_fleximap: add cl_fmap_match() function

Add cl_fmap_match() function - it is similar for cl_fmap_get() (getting fleximap item by key) with difference that instead of using the map's default comparison routine custom compare function can be passed there as a parameter.

This can be useful for matching map item by a key pattern.

---

This function is used in IPv6 SNM MGID compression patch.

 opensm/complib/cl_map.c              |   14 ++++++++++--
 opensm/complib/libosmcomp.map        |    1 +
 opensm/include/complib/cl_fleximap.h |   36 ++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 3 deletions(-)
opensm/complib/cl_map.c +11 -3
index d851bf8..f5fb1f3 100644
@@ -1144,8 +1144,9 @@ void cl_fmap_init(IN cl_fmap_t * const p_map, IN cl_pfn_fmap_cmp_t pfn_compare)
 	cl_fmap_remove_all(p_map);
 }
 
-cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map,
-			    IN const void *const p_key)
+cl_fmap_item_t *cl_fmap_match(IN const cl_fmap_t * const p_map,
+			      IN const void *const p_key,
+			      IN cl_pfn_fmap_cmp_t pfn_compare)
 {
 	cl_fmap_item_t *p_item;
 	int cmp;
@@ -1156,7 +1157,8 @@ cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map,
 	p_item = __cl_fmap_root(p_map);
 
 	while (p_item != &p_map->nil) {
-		cmp = p_map->pfn_compare(p_key, p_item->p_key);
+		cmp = pfn_compare ? pfn_compare(p_key, p_item->p_key) :
+			p_map->pfn_compare(p_key, p_item->p_key);
 
 		if (!cmp)
 			break;	/* just right */
@@ -1170,6 +1172,12 @@ cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map,
 	return (p_item);
 }
 
+cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map,
+			    IN const void *const p_key)
+{
+	return cl_fmap_match(p_map, p_key, p_map->pfn_compare);
+}
+
 cl_fmap_item_t *cl_fmap_get_next(IN const cl_fmap_t * const p_map,
 				 IN const void *const p_key)
 {
opensm/complib/libosmcomp.map +1 -0
index 788eb2a..52410cc 100644
@@ -66,6 +66,7 @@ OSMCOMP_2.3 {
 		cl_map_merge;
 		cl_map_delta;
 		cl_fmap_init;
+		cl_fmap_match;
 		cl_fmap_get;
 		cl_fmap_get_next;
 		cl_fmap_apply_func;
opensm/include/complib/cl_fleximap.h +36 -0
index ec008cf..b74040f 100644
@@ -619,6 +619,42 @@ cl_fmap_item_t *cl_fmap_insert(IN cl_fmap_t * const p_map,
 *	Flexi Map, cl_fmap_remove, cl_fmap_item_t
 *********/
 
+/****f* Component Library: Flexi Map/cl_fmap_match
+* NAME
+*	cl_fmap_get
+*
+* DESCRIPTION
+*	The cl_fmap_match function returns the map item matching a key.
+*
+* SYNOPSIS
+*/
+cl_fmap_item_t *cl_fmap_match(IN const cl_fmap_t * const p_map,
+			      IN const void *const p_key,
+			      IN cl_pfn_fmap_cmp_t pfn_compare);
+/*
+* PARAMETERS
+*	p_map
+*		[in] Pointer to a cl_fmap_t structure from which to retrieve the
+*		item with the specified key.
+*
+*	p_key
+*		[in] Pointer to a key value used to search for the desired map item.
+*
+*	pfn_compare
+*		[in] Pointer to a compare function to invoke to compare the
+*		keys of items in the map. Passing NULL here makes such call
+*		to be equivalent to using cl_fmap_get().
+*
+* RETURN VALUES
+*	Pointer to the map item matching the desired key value.
+*
+*	Pointer to the map end if there was no item matching the desired key
+*	value stored in the flexi map.
+*
+* SEE ALSO
+*	Flexi Map, cl_fmap_remove, cl_fmap_get
+*********/
+
 /****f* Component Library: Flexi Map/cl_fmap_get
 * NAME
 *	cl_fmap_get
Signature · 6 lines
1.6.5.2

--
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
#4 lore raw

RFC PATCH 1/1 opensm: compress IPV6 SNM groups to use a single MLID

This is rework of previously used IPv6 SNM groups compression workaround using newly proposed "many MGID to single MLID" mapping infrastructure.

Unlike previous solution where all IPv6 Solicited node multicast (SNM) requests were collapsed into a single multicast group in OpenSM, now each IPv6 SNM group is represented as a separate multicast group and all groups sharing same P_Key and scope values use a same MLID value.

The compression method itself should be faster now because MLID sharing criteria (matching IPv6 SNM MGID signature) is performed only once when multicast group is created (and not each time when get MC group by MGID lookup was performed).

This solution should be fully IBA complaint.

As before this feature is switched on by using 'consolidate_ipv6_snm_req' command line or/and configuration option.

---
 opensm/opensm/osm_sa_mcmember_record.c |   68 ++++++++++++++++++-------------
 1 files changed, 39 insertions(+), 29 deletions(-)
opensm/opensm/osm_sa_mcmember_record.c +39 -29
index 27675b6..58c5736 100644
@@ -114,6 +114,35 @@ static void free_mlid(IN osm_sa_t * sa, IN uint16_t mlid)
 /*********************************************************************
  Get a new unused mlid by scanning all the used ones in the subnet.
 **********************************************************************/
+/* Special Case IPv6 Solicited Node Multicast (SNM) addresses */
+/* 0xff1Z601bXXXX0000 : 0x00000001ffYYYYYY */
+/* Where Z is the scope, XXXX is the P_Key, and
+ * YYYYYY is the last 24 bits of the port guid */
+#define PREFIX_MASK CL_HTON64(0xff10ffff0000ffffULL)
+#define PREFIX_SIGNATURE CL_HTON64(0xff10601b00000000ULL)
+#define INT_ID_MASK CL_HTON64(0xfffffff1ff000000ULL)
+#define INT_ID_SIGNATURE CL_HTON64(0x00000001ff000000ULL)
+
+static int compare_ipv6_snm_mgids(const void *m1, const void *m2)
+{
+	return memcmp(m1, m2, sizeof(ib_gid_t) - 6);
+}
+
+static ib_net16_t find_ipv6_snm_mlid(osm_subn_t *subn, ib_gid_t *mgid)
+{
+	osm_mgrp_t *m = (osm_mgrp_t *)cl_fmap_match(&subn->mgrp_mgid_tbl, mgid,
+						    compare_ipv6_snm_mgids);
+	if (m != (osm_mgrp_t *)cl_fmap_end(&subn->mgrp_mgid_tbl))
+		return m->mlid;
+	return 0;
+}
+
+static unsigned match_ipv6_snm_mgid(ib_gid_t * mgid)
+{
+	return ((mgid->unicast.prefix & PREFIX_MASK) == PREFIX_SIGNATURE &&
+		(mgid->unicast.interface_id & INT_ID_MASK) == INT_ID_SIGNATURE);
+}
+
 static ib_net16_t get_new_mlid(osm_sa_t * sa, ib_member_rec_t * mcmr)
 {
 	osm_subn_t *p_subn = sa->p_subn;
@@ -125,6 +154,16 @@ static ib_net16_t get_new_mlid(osm_sa_t * sa, ib_member_rec_t * mcmr)
 	    && !osm_get_mbox_by_mlid(p_subn, requested_mlid))
 		return requested_mlid;
 
+	if (sa->p_subn->opt.consolidate_ipv6_snm_req
+	    && match_ipv6_snm_mgid(&mcmr->mgid)
+	    && (requested_mlid = find_ipv6_snm_mlid(sa->p_subn, &mcmr->mgid))) {
+		char str[INET6_ADDRSTRLEN];
+		OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+			"Special Case Solicited Node Mcast Join for MGID %s\n",
+			inet_ntop(AF_INET6, mcmr->mgid.raw, str, sizeof(str)));
+		return requested_mlid;
+	}
+
 	max = p_subn->max_mcast_lid_ho - IB_LID_MCAST_START_HO + 1;
 	for (i = 0; i < max; i++)
 		if (!sa->p_subn->mboxes[i])
@@ -829,39 +868,10 @@ Exit:
 	return status;
 }
 
-#define PREFIX_MASK CL_HTON64(0xff10ffff0000ffffULL)
-#define PREFIX_SIGNATURE CL_HTON64(0xff10601b00000000ULL)
-#define INT_ID_MASK CL_HTON64(0xfffffff1ff000000ULL)
-#define INT_ID_SIGNATURE CL_HTON64(0x00000001ff000000ULL)
-
-/* Special Case IPv6 Solicited Node Multicast (SNM) addresses */
-/* 0xff1Z601bXXXX0000 : 0x00000001ffYYYYYY */
-/* Where Z is the scope, XXXX is the P_Key, and
- * YYYYYY is the last 24 bits of the port guid */
-static unsigned match_and_update_ipv6_snm_mgid(ib_gid_t * mgid)
-{
-	if ((mgid->unicast.prefix & PREFIX_MASK) == PREFIX_SIGNATURE &&
-	    (mgid->unicast.interface_id & INT_ID_MASK) == INT_ID_SIGNATURE) {
-		mgid->unicast.prefix &= PREFIX_MASK;
-		mgid->unicast.interface_id &= INT_ID_MASK;
-		return 1;
-	}
-	return 0;
-}
-
 osm_mgrp_t *osm_get_mgrp_by_mgid(IN osm_sa_t * sa, IN ib_gid_t * p_mgid)
 {
 	osm_mgrp_t *mg;
 
-	if (sa->p_subn->opt.consolidate_ipv6_snm_req &&
-	    match_and_update_ipv6_snm_mgid(p_mgid)) {
-		char gid_str[INET6_ADDRSTRLEN];
-		OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
-			"Special Case Solicited Node Mcast Join for MGID %s\n",
-			inet_ntop(AF_INET6, p_mgid->raw, gid_str,
-				  sizeof gid_str));
-	}
-
 	mg = (osm_mgrp_t *)cl_fmap_get(&sa->p_subn->mgrp_mgid_tbl, p_mgid);
 	if (mg != (osm_mgrp_t *)cl_fmap_end(&sa->p_subn->mgrp_mgid_tbl))
 		return mg;
Signature · 6 lines
1.6.5.2

--
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
#5 lore raw

Re: [PATCH RFC] opensm: compress IPV6 SNM groups to use a single MLID

Quoted 8 lines · Sasha Khapyorsky

This is rework of previously used IPv6 SNM groups compression workaround using newly proposed "many MGID to single MLID" mapping infrastructure.

Unlike previous solution where all IPv6 Solicited node multicast (SNM) requests were collapsed into a single multicast group in OpenSM, now each IPv6 SNM group is represented as a separate multicast group and all groups sharing same P_Key and scope values use a same MLID value.

Shouldn't this also ensure groups sharing MLIDs have the same MTU, rate, and packet lifetime ?

Quoted 6 lines

The compression method itself should be faster now because MLID sharing criteria (matching IPv6 SNM MGID signature) is performed only once when multicast group is created (and not each time when get MC group by MGID lookup was performed).

This solution should be fully IBA complaint.

Why the should qualification ?

Shouldn't the IBA compliant issues fixed be documented here ?

-- Hal

Quoted 106 lines

As before this feature is switched on by using 'consolidate_ipv6_snm_req' command line or/and configuration option.

---
 opensm/opensm/osm_sa_mcmember_record.c |   68 ++++++++++++++++++-------------

 1 files changed, 39 insertions(+), 29 deletions(-)
opensm/opensm/osm_sa_mcmember_record.c +0 -0
index 27675b6..58c5736 100644
@@ -114,6 +114,35 @@ static void free_mlid(IN osm_sa_t * sa, IN uint16_t mlid)
  /*********************************************************************

 Get a new unused mlid by scanning all the used ones in the subnet. **********************************************************************/

opensm/opensm/osm_sa_mcmember_record.c +29 -0
+/* Special Case IPv6 Solicited Node Multicast (SNM) addresses */
+/* 0xff1Z601bXXXX0000 : 0x00000001ffYYYYYY */
+/* Where Z is the scope, XXXX is the P_Key, and
+ * YYYYYY is the last 24 bits of the port guid */
+#define PREFIX_MASK CL_HTON64(0xff10ffff0000ffffULL)
+#define PREFIX_SIGNATURE CL_HTON64(0xff10601b00000000ULL)
+#define INT_ID_MASK CL_HTON64(0xfffffff1ff000000ULL)
+#define INT_ID_SIGNATURE CL_HTON64(0x00000001ff000000ULL)
+
+static int compare_ipv6_snm_mgids(const void *m1, const void *m2)
+{
+       return memcmp(m1, m2, sizeof(ib_gid_t) - 6);
+}
+
+static ib_net16_t find_ipv6_snm_mlid(osm_subn_t *subn, ib_gid_t *mgid)
+{
+       osm_mgrp_t *m = (osm_mgrp_t *)cl_fmap_match(&subn->mgrp_mgid_tbl, mgid,
+                                                   compare_ipv6_snm_mgids);
+       if (m != (osm_mgrp_t *)cl_fmap_end(&subn->mgrp_mgid_tbl))
+               return m->mlid;
+       return 0;
+}
+
+static unsigned match_ipv6_snm_mgid(ib_gid_t * mgid)
+{
+       return ((mgid->unicast.prefix & PREFIX_MASK) == PREFIX_SIGNATURE &&
+               (mgid->unicast.interface_id & INT_ID_MASK) == INT_ID_SIGNATURE);
+}
+

 static ib_net16_t get_new_mlid(osm_sa_t * sa, ib_member_rec_t * mcmr) {
       osm_subn_t *p_subn = sa->p_subn;

opensm/opensm/osm_sa_mcmember_record.c +10 -30
@@ -125,6 +154,16 @@ static ib_net16_t get_new_mlid(osm_sa_t * sa, ib_member_rec_t * mcmr)
            && !osm_get_mbox_by_mlid(p_subn, requested_mlid))
                return requested_mlid;
 
+       if (sa->p_subn->opt.consolidate_ipv6_snm_req
+           && match_ipv6_snm_mgid(&mcmr->mgid)
+           && (requested_mlid = find_ipv6_snm_mlid(sa->p_subn, &mcmr->mgid))) {
+               char str[INET6_ADDRSTRLEN];
+               OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+                       "Special Case Solicited Node Mcast Join for MGID %s\n",
+                       inet_ntop(AF_INET6, mcmr->mgid.raw, str, sizeof(str)));
+               return requested_mlid;
+       }
+
        max = p_subn->max_mcast_lid_ho - IB_LID_MCAST_START_HO + 1;
        for (i = 0; i < max; i++)
                if (!sa->p_subn->mboxes[i])
@@ -829,39 +868,10 @@ Exit:
        return status;
  }
 
-#define PREFIX_MASK CL_HTON64(0xff10ffff0000ffffULL)
-#define PREFIX_SIGNATURE CL_HTON64(0xff10601b00000000ULL)
-#define INT_ID_MASK CL_HTON64(0xfffffff1ff000000ULL)
-#define INT_ID_SIGNATURE CL_HTON64(0x00000001ff000000ULL)
-
-/* Special Case IPv6 Solicited Node Multicast (SNM) addresses */
-/* 0xff1Z601bXXXX0000 : 0x00000001ffYYYYYY */
-/* Where Z is the scope, XXXX is the P_Key, and
- * YYYYYY is the last 24 bits of the port guid */
-static unsigned match_and_update_ipv6_snm_mgid(ib_gid_t * mgid)
-{
-       if ((mgid->unicast.prefix & PREFIX_MASK) == PREFIX_SIGNATURE &&
-           (mgid->unicast.interface_id & INT_ID_MASK) == INT_ID_SIGNATURE) {
-               mgid->unicast.prefix &= PREFIX_MASK;
-               mgid->unicast.interface_id &= INT_ID_MASK;
-               return 1;
-       }
-       return 0;
-}
-
  osm_mgrp_t *osm_get_mgrp_by_mgid(IN osm_sa_t * sa, IN ib_gid_t * p_mgid)
  {
        osm_mgrp_t *mg;
 
-       if (sa->p_subn->opt.consolidate_ipv6_snm_req &&
-           match_and_update_ipv6_snm_mgid(p_mgid)) {
-               char gid_str[INET6_ADDRSTRLEN];
-               OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
-                       "Special Case Solicited Node Mcast Join for MGID %s\n",
-                       inet_ntop(AF_INET6, p_mgid->raw, gid_str,
-                                 sizeof gid_str));
-       }
-
        mg = (osm_mgrp_t *)cl_fmap_get(&sa->p_subn->mgrp_mgid_tbl, p_mgid);
        if (mg != (osm_mgrp_t *)cl_fmap_end(&sa->p_subn->mgrp_mgid_tbl))
                return mg;
--
Quoted 3 lines

1.6.5.2

--
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

A message that is not in the archive (sent off-list or not yet received): f0e08f230911160735i69ad3671m9a2667900b933e13-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#7 lore raw

Re: [PATCH RFC] opensm: compress IPV6 SNM groups to use a single MLID

Quoted 8 lines · Hal Rosenstock
Quoted 5 lines

Unlike previous solution where all IPv6 Solicited node multicast (SNM) requests were collapsed into a single multicast group in OpenSM, now each IPv6 SNM group is represented as a separate multicast group and all groups sharing same P_Key and scope values use a same MLID value.

Shouldn't this also ensure groups sharing MLIDs have the same MTU, rate, and packet lifetime ?

For IPv6 SNM it was never implemented, so my rework meets an original plan.

And in general it is an interesting question. Do we really need to care about those parameters while doing MGID to MLID compression? SA will reply properly MGID "based" queries, an "extra" packets will be dropped anyway, likely sooner is better, no?

Quoted 3 lines
Quoted 1 line

This solution should be fully IBA complaint.

Why the should qualification ?

Only due to insufficient testing, etc..

Quoted 1 line

Shouldn't the IBA compliant issues fixed be documented here ?

Yes, but I cannot find where. The only needed change I found is in the usage message and man page, but there is nothing about IBA compliance.

Sasha
--
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

#8 lore raw

PATCH 1/1 opensm: IPv6 SNM update for man page and usage

Update changed functionality of IPv6 SNM consolidation option in OpenSM man page and the usage message.

---
 opensm/man/opensm.8.in |    4 ++--
 opensm/opensm/main.c   |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
opensm/man/opensm.8.in +2 -2
index bd8ab4e..0baee7d 100644
@@ -342,8 +342,8 @@ Specify the sweep time for the performance manager in seconds
 effect if --enable-perfmgr was specified at configure time.
 .TP
 .BI --consolidate_ipv6_snm_req
-Consolidate IPv6 Solicited Node Multicast group join requests into one
-multicast group per MGID PKey.
+Use shared MLID for IPv6 Solicited Node Multicast groups per MGID scope
+and P_Key.
 .TP
 \fB\-v\fR, \fB\-\-verbose\fR
 This option increases the log verbosity level.
opensm/opensm/main.c +2 -2
index 18efde1..fc002d8 100644
@@ -322,8 +322,8 @@ static void show_usage(void)
 	       "          queries for off-subnet DGIDs.  Default file is:\n"
 	       "              " OSM_DEFAULT_PREFIX_ROUTES_FILE "\n\n");
 	printf("--consolidate_ipv6_snm_req\n"
-	       "          Consolidate IPv6 Solicited Node Multicast group joins\n"
-	       "          into 1 IB multicast group.\n\n");
+	       "          Use shared MLID for IPv6 Solicited Node Multicast groups\n"
+	       "          per MGID scope and P_Key.\n\n");
 	printf("--verbose, -v\n"
 	       "          This option increases the log verbosity level.\n"
 	       "          The -v option may be specified multiple times\n"
Signature · 6 lines
1.6.5.3

--
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
#9 lore raw

Re: [PATCH RFC] opensm: compress IPV6 SNM groups to use a single MLID

In reply to Sasha Khapyorsky
Quoted 7 lines · Sasha Khapyorsky
Quoted 6 lines · Hal Rosenstock
Quoted 5 lines

Unlike previous solution where all IPv6 Solicited node multicast (SNM) requests were collapsed into a single multicast group in OpenSM, now each IPv6 SNM group is represented as a separate multicast group and all groups sharing same P_Key and scope values use a same MLID value.

Quoted 5 lines
Quoted 2 lines

Shouldn't this also ensure groups sharing MLIDs have the same MTU, rate, and packet lifetime ?

For IPv6 SNM it was never implemented, so my rework meets an original plan.

Yes, it is same as original implementation in that regard but there was little alternative with the approach taken. Now there is but from your comments below it seems you are unclear this is needed.

Quoted 4 lines

And in general it is an interesting question. Do we really need to care about those parameters while doing MGID to MLID compression? SA will reply properly MGID "based" queries, an "extra" packets will be dropped anyway, likely sooner is better, no?

Not sure what you mean by "extra packets dropped anyway, likely sooner is better".

The multicast tree (MLID) has one rate, MTU, etc. so these parameters should be enforced on multicast groups (MGIDs) overlaid on the same MLID.

Quoted 10 lines
Quoted 3 lines
Quoted 1 line

This solution should be fully IBA complaint.

Why the should qualification ?

Only due to insufficient testing, etc..

Quoted 1 line

Shouldn't the IBA compliant issues fixed be documented here ?

Yes, but I cannot find where. The only needed change I found is in the usage message and man page, but there is nothing about IBA compliance.

I was saying to add it to the patch description so it would be documented properly. How can it be added now ?

-- Hal

Quoted 2 lines

Sasha

--
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

A message that is not in the archive (sent off-list or not yet received): f0e08f230911301148t8d573c7lf1f67972b5438b72-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#11 lore raw

Re: [PATCH RFC] opensm: compress IPV6 SNM groups to use a single MLID

Quoted 4 lines · Hal Rosenstock

The multicast tree (MLID) has one rate, MTU, etc. so these parameters should be enforced on multicast groups (MGIDs) overlaid on the same MLID.

Assuming that Multicast groups (MGIDs) are consistent in terms of rate, MTU and packet life time parameters. Why should we share this over MLID implementing MGID to MLID compression?

Sharing P_Key helps to prevent P_Key violation traps, but what should be a reason for rate, MTU and packet life time?

Sasha
--
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

#12 lore raw

Re: [PATCH RFC] opensm: compress IPV6 SNM groups to use a single MLID

Quoted 11 lines · Sasha Khapyorsky
Quoted 4 lines · Hal Rosenstock

The multicast tree (MLID) has one rate, MTU, etc. so these parameters should be enforced on multicast groups (MGIDs) overlaid on the same MLID.

Assuming that Multicast groups (MGIDs) are consistent in terms of rate, MTU and packet life time parameters. Why should we share this over MLID implementing MGID to MLID compression?

Sharing P_Key helps to prevent P_Key violation traps,

Actually, that's a simplification not strictly required. One example where that is the case is if there is no PKey enforcement in the subnet.

Quoted 1 line

but what should be a reason for rate, MTU and packet life time?

As with any path (which in this case is the multicast tree), there is a rate, MTU, and packet life time. As one example, if the tree does not support the MTU, then MTU discards can occur. There are other more subtle things that occur based on rate mismatches (overagressive transmitters). These should be precluded rather than allowed (and then having to debug the resulting issues).

-- Hal

Quoted 3 lines

Sasha

--
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

#13 lore raw

Re: [PATCH] complib/cl_fleximap: add cl_fmap_match() function

In reply to Sasha Khapyorsky
Quoted 74 lines · Sasha Khapyorsky

Add cl_fmap_match() function - it is similar for cl_fmap_get() (getting fleximap item by key) with difference that instead of using the map's default comparison routine custom compare function can be passed there as a parameter.

This can be useful for matching map item by a key pattern.

---

This function is used in IPv6 SNM MGID compression patch.

 opensm/complib/cl_map.c              |   14 ++++++++++-- opensm/complib/libosmcomp.map        |    1 + opensm/include/complib/cl_fleximap.h |   36 ++++++++++++++++++++++++++++++++++

 3 files changed, 48 insertions(+), 3 deletions(-)
opensm/complib/cl_map.c +5 -3
index d851bf8..f5fb1f3 100644
@@ -1144,8 +1144,9 @@ void cl_fmap_init(IN cl_fmap_t * const p_map, IN cl_pfn_fmap_cmp_t pfn_compare)
        cl_fmap_remove_all(p_map);
  }
 
-cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map,
-                           IN const void *const p_key)
+cl_fmap_item_t *cl_fmap_match(IN const cl_fmap_t * const p_map,
+                             IN const void *const p_key,
+                             IN cl_pfn_fmap_cmp_t pfn_compare)
  {
        cl_fmap_item_t *p_item;
        int cmp;
@@ -1156,7 +1157,8 @@ cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map,
        p_item = __cl_fmap_root(p_map);
 
        while (p_item != &p_map->nil) {
-               cmp = p_map->pfn_compare(p_key, p_item->p_key);
+               cmp = pfn_compare ? pfn_compare(p_key, p_item->p_key) :
+                       p_map->pfn_compare(p_key, p_item->p_key);
 
                if (!cmp)

                       break;  /* just right */

opensm/complib/cl_map.c +6 -0
@@ -1170,6 +1172,12 @@ cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map,
        return (p_item);
  }
 
+cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map,
+                           IN const void *const p_key)
+{
+       return cl_fmap_match(p_map, p_key, p_map->pfn_compare);
+}
+
  cl_fmap_item_t *cl_fmap_get_next(IN const cl_fmap_t * const p_map,
                                 IN const void *const p_key)
  {
opensm/complib/libosmcomp.map +1 -0
index 788eb2a..52410cc 100644
@@ -66,6 +66,7 @@ OSMCOMP_2.3 {
                cl_map_merge;
                cl_map_delta;
                cl_fmap_init;
+               cl_fmap_match;
                cl_fmap_get;
                cl_fmap_get_next;
                cl_fmap_apply_func;
opensm/include/complib/cl_fleximap.h +0 -0
index ec008cf..b74040f 100644

opensm/include/complib/cl_fleximap.h cl_fmap_item_t *cl_fmap_insert(IN cl_fmap_t * const p_map, · line 624

Quoted 6 lines
opensm/include/complib/cl_fleximap.h +3 -0
@@ -619,6 +619,42 @@ cl_fmap_item_t *cl_fmap_insert(IN cl_fmap_t * const p_map,
  *      Flexi Map, cl_fmap_remove, cl_fmap_item_t
  *********/
 
+/****f* Component Library: Flexi Map/cl_fmap_match
+* NAME
+*      cl_fmap_get

typo: cl_fmap_match

Quoted 37 lines
opensm/include/complib/cl_fleximap.h +33 -1
+*
+* DESCRIPTION
+*      The cl_fmap_match function returns the map item matching a key.
+*
+* SYNOPSIS
+*/
+cl_fmap_item_t *cl_fmap_match(IN const cl_fmap_t * const p_map,
+                             IN const void *const p_key,
+                             IN cl_pfn_fmap_cmp_t pfn_compare);
+/*
+* PARAMETERS
+*      p_map
+*              [in] Pointer to a cl_fmap_t structure from which to retrieve the
+*              item with the specified key.
+*
+*      p_key
+*              [in] Pointer to a key value used to search for the desired map item.
+*
+*      pfn_compare
+*              [in] Pointer to a compare function to invoke to compare the
+*              keys of items in the map. Passing NULL here makes such call
+*              to be equivalent to using cl_fmap_get().
+*
+* RETURN VALUES
+*      Pointer to the map item matching the desired key value.
+*
+*      Pointer to the map end if there was no item matching the desired key
+*      value stored in the flexi map.
+*
+* SEE ALSO
+*      Flexi Map, cl_fmap_remove, cl_fmap_get
+*********/
+
  /****f* Component Library: Flexi Map/cl_fmap_get
  * NAME
  *      cl_fmap_get
--
Quoted 3 lines

1.6.5.2

--
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