[ofa-general] [PATCH] opensm: use mgrp pointer as osm_sm_mcgrp_join/leave() parameter

Sasha Khapyorsky sashak at voltaire.com
Sun Sep 6 08:49:31 PDT 2009


Use mgrp pointer to multicast group instead of mlid as parameter for
osm_sm_mcgrp_join/leave() functions. This simplifies the current
implementation, makes those functions MLID independent and in this way
helps to implement MGID to MLID compression.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/include/opensm/osm_sm.h         |   13 ++++---
 opensm/opensm/osm_sa_mcmember_record.c |    8 +---
 opensm/opensm/osm_sm.c                 |   57 ++++++-------------------------
 3 files changed, 20 insertions(+), 58 deletions(-)

diff --git a/opensm/include/opensm/osm_sm.h b/opensm/include/opensm/osm_sm.h
index 152ecd7..0914a95 100644
--- a/opensm/include/opensm/osm_sm.h
+++ b/opensm/include/opensm/osm_sm.h
@@ -61,6 +61,7 @@
 #include <opensm/osm_port.h>
 #include <opensm/osm_db.h>
 #include <opensm/osm_remote_sm.h>
+#include <opensm/osm_multicast.h>
 
 #ifdef __cplusplus
 #  define BEGIN_C_DECLS extern "C" {
@@ -538,15 +539,15 @@ osm_resp_send(IN osm_sm_t * sm,
 */
 ib_api_status_t
 osm_sm_mcgrp_join(IN osm_sm_t * const p_sm,
-		  IN const ib_net16_t mlid,
+		  IN osm_mgrp_t *mgrp,
 		  IN const ib_net64_t port_guid);
 /*
 * PARAMETERS
 *	p_sm
 *		[in] Pointer to an osm_sm_t object.
 *
-*	mlid
-*		[in] Multicast LID
+*	mgrp
+*		[in] Pointer to multicast group to join
 *
 *	port_guid
 *		[in] Port GUID to add to the group.
@@ -572,14 +573,14 @@ osm_sm_mcgrp_join(IN osm_sm_t * const p_sm,
 */
 ib_api_status_t
 osm_sm_mcgrp_leave(IN osm_sm_t * const p_sm,
-		   IN const ib_net16_t mlid, IN const ib_net64_t port_guid);
+		   IN osm_mgrp_t *mgrp, IN const ib_net64_t port_guid);
 /*
 * PARAMETERS
 *	p_sm
 *		[in] Pointer to an osm_sm_t object.
 *
-*	mlid
-*		[in] Multicast LID
+*	mgrp
+*		[in] Poniter to multicast group to leave
 *
 *	port_guid
 *		[in] Port GUID to remove from the group.
diff --git a/opensm/opensm/osm_sa_mcmember_record.c b/opensm/opensm/osm_sa_mcmember_record.c
index a9e0a3b..7f2bc34 100644
--- a/opensm/opensm/osm_sa_mcmember_record.c
+++ b/opensm/opensm/osm_sa_mcmember_record.c
@@ -1010,7 +1010,6 @@ static void mcmr_rcv_leave_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
 	ib_sa_mad_t *p_sa_mad;
 	ib_member_rec_t *p_recvd_mcmember_rec;
 	ib_member_rec_t mcmember_rec;
-	ib_net16_t mlid;
 	ib_net64_t portguid;
 	osm_mcm_port_t *p_mcm_port;
 	int removed;
@@ -1041,7 +1040,6 @@ static void mcmr_rcv_leave_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
 		goto Exit;
 	}
 
-	mlid = p_mgrp->mlid;
 	portguid = p_recvd_mcmember_rec->port_gid.unicast.interface_id;
 
 	/* check validity of the delete request o15-0.1.14 */
@@ -1074,7 +1072,7 @@ static void mcmr_rcv_leave_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
 	CL_PLOCK_RELEASE(sa->p_lock);
 
 	/* we can leave if port was deleted from MCG */
-	if (removed && osm_sm_mcgrp_leave(sa->sm, mlid, portguid))
+	if (removed && osm_sm_mcgrp_leave(sa->sm, p_mgrp, portguid))
 		OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B09: "
 			"osm_sm_mcgrp_leave failed\n");
 
@@ -1094,7 +1092,6 @@ static void mcmr_rcv_join_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
 	ib_sa_mad_t *p_sa_mad;
 	ib_member_rec_t *p_recvd_mcmember_rec;
 	ib_member_rec_t mcmember_rec;
-	ib_net16_t mlid;
 	osm_mcm_port_t *p_mcmr_port;
 	ib_net64_t portguid;
 	osm_port_t *p_port;
@@ -1217,7 +1214,6 @@ static void mcmr_rcv_join_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
 		is_new_group = 0;
 
 	CL_ASSERT(p_mgrp);
-	mlid = p_mgrp->mlid;
 
 	/*
 	 * o15-0.2.4: If SA supports UD multicast, then SA shall cause an
@@ -1302,7 +1298,7 @@ static void mcmr_rcv_join_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
 	CL_PLOCK_RELEASE(sa->p_lock);
 
 	/* do the actual routing (actually schedule the update) */
-	status = osm_sm_mcgrp_join(sa->sm, mlid,
+	status = osm_sm_mcgrp_join(sa->sm, p_mgrp,
 				   p_recvd_mcmember_rec->port_gid.unicast.
 				   interface_id);
 
diff --git a/opensm/opensm/osm_sm.c b/opensm/opensm/osm_sm.c
index 2794775..50aee91 100644
--- a/opensm/opensm/osm_sm.c
+++ b/opensm/opensm/osm_sm.c
@@ -467,10 +467,9 @@ static ib_api_status_t sm_mgrp_process(IN osm_sm_t * p_sm,
 
 /**********************************************************************
  **********************************************************************/
-ib_api_status_t osm_sm_mcgrp_join(IN osm_sm_t * p_sm, IN const ib_net16_t mlid,
+ib_api_status_t osm_sm_mcgrp_join(IN osm_sm_t * p_sm, IN osm_mgrp_t *mgrp,
 				  IN const ib_net64_t port_guid)
 {
-	osm_mgrp_t *p_mgrp;
 	osm_port_t *p_port;
 	ib_api_status_t status = IB_SUCCESS;
 	osm_mcm_info_t *p_mcm;
@@ -479,7 +478,7 @@ ib_api_status_t osm_sm_mcgrp_join(IN osm_sm_t * p_sm, IN const ib_net16_t mlid,
 
 	OSM_LOG(p_sm->p_log, OSM_LOG_VERBOSE,
 		"Port 0x%016" PRIx64 " joining MLID 0x%X\n",
-		cl_ntoh64(port_guid), cl_ntoh16(mlid));
+		cl_ntoh64(port_guid), cl_ntoh16(mgrp->mlid));
 
 	/*
 	 * Acquire the port object for the port joining this group.
@@ -495,51 +494,32 @@ ib_api_status_t osm_sm_mcgrp_join(IN osm_sm_t * p_sm, IN const ib_net16_t mlid,
 	}
 
 	/*
-	 * If this multicast group does not already exist, create it.
-	 */
-	p_mgrp = osm_get_mgrp_by_mlid(p_sm->p_subn, mlid);
-	if (!p_mgrp || !osm_mgrp_is_guid(p_mgrp, port_guid)) {
-		/*
-		 * The group removed or the port is not a
-		 * member of the group, then fail immediately.
-		 * This can happen since the spinlock is released briefly
-		 * before the SA calls this function.
-		 */
-		OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 2E12: "
-			"MC group with mlid 0x%x doesn't exist or "
-			"port 0x%016" PRIx64 " is not in the group.\n",
-			cl_ntoh16(mlid), cl_ntoh64(port_guid));
-		status = IB_NOT_FOUND;
-		goto Exit;
-	}
-
-	/*
 	 * Check if the object (according to mlid) already exists on this port.
 	 * If it does - then no need to update it again, and no need to
 	 * create the mc tree again. Just goto Exit.
 	 */
 	p_mcm = (osm_mcm_info_t *) cl_qlist_head(&p_port->mcm_list);
 	while (p_mcm != (osm_mcm_info_t *) cl_qlist_end(&p_port->mcm_list)) {
-		if (p_mcm->mgrp->mlid == mlid) {
+		if (p_mcm->mgrp == mgrp) {
 			OSM_LOG(p_sm->p_log, OSM_LOG_DEBUG,
 				"Found mlid object for Port:"
 				"0x%016" PRIx64 " lid:0x%X\n",
-				cl_ntoh64(port_guid), cl_ntoh16(mlid));
+				cl_ntoh64(port_guid), cl_ntoh16(mgrp->mlid));
 			goto Exit;
 		}
 		p_mcm = (osm_mcm_info_t *) cl_qlist_next(&p_mcm->list_item);
 	}
 
-	status = osm_port_add_mgrp(p_port, p_mgrp);
+	status = osm_port_add_mgrp(p_port, mgrp);
 	if (status != IB_SUCCESS) {
 		OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 2E03: "
 			"Unable to associate port 0x%" PRIx64 " to mlid 0x%X\n",
 			cl_ntoh64(osm_port_get_guid(p_port)),
-			cl_ntoh16(osm_mgrp_get_mlid(p_mgrp)));
+			cl_ntoh16(osm_mgrp_get_mlid(mgrp)));
 		goto Exit;
 	}
 
-	status = sm_mgrp_process(p_sm, p_mgrp);
+	status = sm_mgrp_process(p_sm, mgrp);
 Exit:
 	CL_PLOCK_RELEASE(p_sm->p_lock);
 	OSM_LOG_EXIT(p_sm->p_log);
@@ -549,10 +529,9 @@ Exit:
 
 /**********************************************************************
  **********************************************************************/
-ib_api_status_t osm_sm_mcgrp_leave(IN osm_sm_t * p_sm, IN const ib_net16_t mlid,
+ib_api_status_t osm_sm_mcgrp_leave(IN osm_sm_t * p_sm, IN osm_mgrp_t *mgrp,
 				   IN const ib_net64_t port_guid)
 {
-	osm_mgrp_t *p_mgrp;
 	osm_port_t *p_port;
 	ib_api_status_t status;
 
@@ -560,7 +539,7 @@ ib_api_status_t osm_sm_mcgrp_leave(IN osm_sm_t * p_sm, IN const ib_net16_t mlid,
 
 	OSM_LOG(p_sm->p_log, OSM_LOG_VERBOSE,
 		"Port 0x%" PRIx64 " leaving MLID 0x%X\n",
-		cl_ntoh64(port_guid), cl_ntoh16(mlid));
+		cl_ntoh64(port_guid), cl_ntoh16(mgrp->mlid));
 
 	/*
 	 * Acquire the port object for the port leaving this group.
@@ -576,23 +555,9 @@ ib_api_status_t osm_sm_mcgrp_leave(IN osm_sm_t * p_sm, IN const ib_net16_t mlid,
 		goto Exit;
 	}
 
-	/*
-	 * Get the multicast group object for this group.
-	 */
-	p_mgrp = osm_get_mgrp_by_mlid(p_sm->p_subn, mlid);
-	if (!p_mgrp) {
-		OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 2E08: "
-			"No multicast group for MLID 0x%X\n", cl_ntoh16(mlid));
-		status = IB_INVALID_PARAMETER;
-		goto Exit;
-	}
-
-	/*
-	 * Walk the list of ports in the group, and remove the appropriate one.
-	 */
-	osm_port_remove_mgrp(p_port, p_mgrp);
+	osm_port_remove_mgrp(p_port, mgrp);
 
-	status = sm_mgrp_process(p_sm, p_mgrp);
+	status = sm_mgrp_process(p_sm, mgrp);
 Exit:
 	CL_PLOCK_RELEASE(p_sm->p_lock);
 	OSM_LOG_EXIT(p_sm->p_log);
-- 
1.6.4.2




More information about the general mailing list