Merge all __get_mgrp_by_mlid() instances into single
osm_get_mgrp_by_mlid() function.

Signed-off-by: Sasha Khapyorsky <[EMAIL PROTECTED]>
---
 opensm/include/opensm/osm_subnet.h     |   29 +++++++++++++++++++++++++++++
 opensm/opensm/osm_drop_mgr.c           |    2 +-
 opensm/opensm/osm_mcast_mgr.c          |   10 +---------
 opensm/opensm/osm_qos_policy.c         |    2 +-
 opensm/opensm/osm_sa.c                 |    2 +-
 opensm/opensm/osm_sa_mcmember_record.c |   17 ++++-------------
 opensm/opensm/osm_sa_path_record.c     |   10 +---------
 opensm/opensm/osm_sm.c                 |    4 ++--
 8 files changed, 40 insertions(+), 36 deletions(-)

diff --git a/opensm/include/opensm/osm_subnet.h 
b/opensm/include/opensm/osm_subnet.h
index 6924b40..b4f130e 100644
--- a/opensm/include/opensm/osm_subnet.h
+++ b/opensm/include/opensm/osm_subnet.h
@@ -721,6 +721,7 @@ struct osm_log;
 struct osm_switch;
 struct osm_physp;
 struct osm_port;
+struct osm_mgrp;
 
 /****f* OpenSM: Helper/osm_get_gid_by_mad_addr
 * NAME
@@ -917,6 +918,34 @@ struct osm_port *osm_get_port_by_guid(IN osm_subn_t const 
*p_subn,
 *      osm_port_t
 *********/
 
+/****f* OpenSM: Subnet/osm_get_mgrp_by_mlid
+* NAME
+*      osm_get_mgrp_by_mlid
+*
+* DESCRIPTION
+*      The looks for the given multicast group in the subnet table by mlid.
+*      NOTE: this code is not thread safe. Need to grab the lock before
+*      calling it.
+*
+* SYNOPSIS
+*/
+static inline
+struct osm_mgrp *osm_get_mgrp_by_mlid(osm_subn_t const *p_subn, ib_net16_t 
mlid)
+{
+       return p_subn->mgroups[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO];
+}
+/*
+* PARAMETERS
+*      p_subn
+*              [in] Pointer to an osm_subn_t object
+*
+*      mlid
+*              [in] The multicast group mlid in network order
+*
+* RETURN VALUES
+*      The multicast group structure pointer if found. NULL otherwise.
+*********/
+
 /****f* OpenSM: Helper/osm_get_physp_by_mad_addr
 * NAME
 *      osm_get_physp_by_mad_addr
diff --git a/opensm/opensm/osm_drop_mgr.c b/opensm/opensm/osm_drop_mgr.c
index 5ebb2d5..2d8d6e9 100644
--- a/opensm/opensm/osm_drop_mgr.c
+++ b/opensm/opensm/osm_drop_mgr.c
@@ -207,7 +207,7 @@ static void __osm_drop_mgr_remove_port(osm_sm_t * sm, IN 
osm_port_t * p_port)
 
        p_mcm = (osm_mcm_info_t *) cl_qlist_remove_head(&p_port->mcm_list);
        while (p_mcm != (osm_mcm_info_t *) cl_qlist_end(&p_port->mcm_list)) {
-               p_mgrp = sm->p_subn->mgroups[cl_ntoh16(p_mcm->mlid) - 
IB_LID_MCAST_START_HO];
+               p_mgrp = osm_get_mgrp_by_mlid(sm->p_subn, p_mcm->mlid);
                if (p_mgrp) {
                        osm_mgrp_remove_port(sm->p_subn, sm->p_log,
                                             p_mgrp, p_port->guid);
diff --git a/opensm/opensm/osm_mcast_mgr.c b/opensm/opensm/osm_mcast_mgr.c
index 111e411..ac45cf3 100644
--- a/opensm/opensm/osm_mcast_mgr.c
+++ b/opensm/opensm/osm_mcast_mgr.c
@@ -1229,14 +1229,6 @@ osm_signal_t osm_mcast_mgr_process(osm_sm_t * sm)
 }
 
 /**********************************************************************
- **********************************************************************/
-static
-osm_mgrp_t *__get_mgrp_by_mlid(osm_sm_t * sm, IN ib_net16_t const mlid)
-{
-       return(sm->p_subn->mgroups[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO]);
-}
-
-/**********************************************************************
   This is the function that is invoked during idle time to handle the
   process request for mcast groups where join/leave/delete was required.
  **********************************************************************/
@@ -1270,7 +1262,7 @@ osm_signal_t osm_mcast_mgr_process_mgroups(osm_sm_t * sm)
 
                /* since we delayed the execution we prefer to pass the
                   mlid as the mgrp identifier and then find it or abort */
-               p_mgrp = __get_mgrp_by_mlid(sm, mlid);
+               p_mgrp = osm_get_mgrp_by_mlid(sm->p_subn, mlid);
                if (!p_mgrp)
                        continue;
 
diff --git a/opensm/opensm/osm_qos_policy.c b/opensm/opensm/osm_qos_policy.c
index 223aba6..ecc38b3 100644
--- a/opensm/opensm/osm_qos_policy.c
+++ b/opensm/opensm/osm_qos_policy.c
@@ -793,7 +793,7 @@ static void __qos_policy_validate_pkey(
        if (!p_prtn->mlid)
                return;
 
-       p_mgrp = p_qos_policy->p_subn->mgroups[cl_ntoh16(p_prtn->mlid) - 
IB_LID_MCAST_START_HO];
+       p_mgrp = osm_get_mgrp_by_mlid(p_qos_policy->p_subn, p_prtn->mlid);
        if (!p_mgrp) {
                OSM_LOG(&p_qos_policy->p_subn->p_osm->log, OSM_LOG_ERROR,
                        "ERR AC16: MCast group for partition with "
diff --git a/opensm/opensm/osm_sa.c b/opensm/opensm/osm_sa.c
index 45e0d22..355e1c2 100644
--- a/opensm/opensm/osm_sa.c
+++ b/opensm/opensm/osm_sa.c
@@ -740,7 +740,7 @@ static osm_mgrp_t *load_mcgroup(osm_opensm_t * p_osm, 
ib_net16_t mlid,
 
        cl_plock_excl_acquire(&p_osm->lock);
 
-       p_mgrp = p_osm->subn.mgroups[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO];
+       p_mgrp = osm_get_mgrp_by_mlid(&p_osm->subn, mlid);
        if (p_mgrp) {
                if (!memcmp(&p_mgrp->mcmember_rec.mgid, &p_mcm_rec->mgid,
                            sizeof(ib_gid_t))) {
diff --git a/opensm/opensm/osm_sa_mcmember_record.c 
b/opensm/opensm/osm_sa_mcmember_record.c
index 231f482..3b41d03 100644
--- a/opensm/opensm/osm_sa_mcmember_record.c
+++ b/opensm/opensm/osm_sa_mcmember_record.c
@@ -91,15 +91,6 @@ typedef struct osm_sa_mcmr_search_ctxt {
        boolean_t trusted_req;
 } osm_sa_mcmr_search_ctxt_t;
 
-/**********************************************************************
- Look for a MGRP in the mgroups by mlid
-**********************************************************************/
-static osm_mgrp_t *__get_mgrp_by_mlid(IN osm_sa_t * sa,
-                                     IN ib_net16_t const mlid)
-{
-       return(sa->p_subn->mgroups[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO]);
-}
-
 /*********************************************************************
  Copy certain fields between two mcmember records
  used during the process of join request to copy data from the mgrp
@@ -140,7 +131,7 @@ static ib_net16_t __get_new_mlid(osm_sa_t *sa, ib_net16_t 
requested_mlid)
 
        if (requested_mlid && cl_ntoh16(requested_mlid) >= IB_LID_MCAST_START_HO
            && cl_ntoh16(requested_mlid) <= p_subn->max_multicast_lid_ho
-           && !p_subn->mgroups[cl_ntoh16(requested_mlid) - 
IB_LID_MCAST_START_HO])
+           && !osm_get_mgrp_by_mlid(p_subn, requested_mlid))
                return requested_mlid;
 
        max = p_subn->max_multicast_lid_ho - IB_LID_MCAST_START_HO + 1;
@@ -162,7 +153,7 @@ static ib_net16_t __get_new_mlid(osm_sa_t *sa, ib_net16_t 
requested_mlid)
 **********************************************************************/
 static void __cleanup_mgrp(IN osm_sa_t * sa, IN ib_net16_t const mlid)
 {
-       osm_mgrp_t *p_mgrp = __get_mgrp_by_mlid(sa, mlid);
+       osm_mgrp_t *p_mgrp = osm_get_mgrp_by_mlid(sa->p_subn, mlid);
 
        /* Remove MGRP only if osm_mcm_port_t count is 0 and
           not a well known group */
@@ -953,7 +944,7 @@ osm_mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa,
        /* since we might have an old group by that mlid
           one whose deletion was delayed for an idle time
           we need to deallocate it first */
-       p_prev_mgrp = sa->p_subn->mgroups[cl_ntoh16(mlid) - 
IB_LID_MCAST_START_HO];
+       p_prev_mgrp = osm_get_mgrp_by_mlid(sa->p_subn, mlid);
        if (p_prev_mgrp) {
                OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
                        "Found previous group for mlid:0x%04x - "
@@ -1480,7 +1471,7 @@ __osm_mcmr_rcv_join_mgrp(IN osm_sa_t * sa,
                CL_PLOCK_EXCL_ACQUIRE(sa->p_lock);
 
                /* the request for routing failed so we need to remove the port 
*/
-               p_mgrp = __get_mgrp_by_mlid(sa, mlid);
+               p_mgrp = osm_get_mgrp_by_mlid(sa->p_subn, mlid);
                if (p_mgrp != NULL) {
                        osm_mgrp_remove_port(sa->p_subn,
                                             sa->p_log,
diff --git a/opensm/opensm/osm_sa_path_record.c 
b/opensm/opensm/osm_sa_path_record.c
index a38fb60..9af8a4f 100644
--- a/opensm/opensm/osm_sa_path_record.c
+++ b/opensm/opensm/osm_sa_path_record.c
@@ -1470,14 +1470,6 @@ __osm_pr_rcv_process_pair(IN osm_sa_t * sa,
 
 /**********************************************************************
  **********************************************************************/
-static osm_mgrp_t *__get_mgrp_by_mlid(IN osm_sa_t * sa,
-                                     IN ib_net16_t const mlid)
-{
-       return(sa->p_subn->mgroups[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO]);
-}
-
-/**********************************************************************
- **********************************************************************/
 static void
 __osm_pr_get_mgrp(IN osm_sa_t * sa,
                  IN const osm_madw_t * const p_madw, OUT osm_mgrp_t ** pp_mgrp)
@@ -1520,7 +1512,7 @@ __osm_pr_get_mgrp(IN osm_sa_t * sa,
                                goto Exit;
                        }
                } else {
-                       *pp_mgrp = __get_mgrp_by_mlid(sa, p_pr->dlid);
+                       *pp_mgrp = osm_get_mgrp_by_mlid(sa->p_subn, p_pr->dlid);
                        if (*pp_mgrp == NULL)
                                OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F11: "
                                        "No MC group found for PathRecord "
diff --git a/opensm/opensm/osm_sm.c b/opensm/opensm/osm_sm.c
index e677fa0..3548935 100644
--- a/opensm/opensm/osm_sm.c
+++ b/opensm/opensm/osm_sm.c
@@ -525,7 +525,7 @@ osm_sm_mcgrp_join(IN osm_sm_t * const p_sm,
        /*
         * If this multicast group does not already exist, create it.
         */
-       p_mgrp = p_sm->p_subn->mgroups[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO];
+       p_mgrp = osm_get_mgrp_by_mlid(p_sm->p_subn, mlid);
        if (!p_mgrp) {
                OSM_LOG(p_sm->p_log, OSM_LOG_VERBOSE,
                        "Creating group, MLID 0x%X\n", cl_ntoh16(mlid));
@@ -628,7 +628,7 @@ osm_sm_mcgrp_leave(IN osm_sm_t * const p_sm,
        /*
         * Get the multicast group object for this group.
         */
-       p_mgrp = p_sm->p_subn->mgroups[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO];
+       p_mgrp = osm_get_mgrp_by_mlid(p_sm->p_subn, mlid);
        if (!p_mgrp) {
                CL_PLOCK_RELEASE(p_sm->p_lock);
                OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 2E08: "
-- 
1.5.5.1.178.g1f811

_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to