[ofa-general] [PATCH 1/3] Consolidate the 2 __get_mgrp_by_mgid functions into one global function which actually takes a mgid and returns a mgrp.
Ira Weiny
weiny2 at llnl.gov
Mon Jan 14 11:45:27 PST 2008
>From 18869ffce87b6b3fa906d300b793b881ce37fb9e Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Sun, 13 Jan 2008 15:28:34 -0800
Subject: [PATCH] Consolidate the 2 __get_mgrp_by_mgid functions into one global function which
actually takes a mgid and returns a mgrp.
Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
opensm/include/opensm/osm_sa.h | 5 +
opensm/opensm/osm_sa_mcmember_record.c | 137 +++++++++++++++----------------
opensm/opensm/osm_sa_path_record.c | 74 +-----------------
3 files changed, 72 insertions(+), 144 deletions(-)
diff --git a/opensm/include/opensm/osm_sa.h b/opensm/include/opensm/osm_sa.h
index 82ca1dc..751bc96 100644
--- a/opensm/include/opensm/osm_sa.h
+++ b/opensm/include/opensm/osm_sa.h
@@ -469,5 +469,10 @@ osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa,
*
*********/
+ib_api_status_t
+osm_get_mgrp_by_mgid(IN osm_sa_t * sa,
+ IN ib_gid_t *p_mgid,
+ OUT osm_mgrp_t ** pp_mgrp);
+
END_C_DECLS
#endif /* _OSM_SA_H_ */
diff --git a/opensm/opensm/osm_sa_mcmember_record.c b/opensm/opensm/osm_sa_mcmember_record.c
index 8eb97ad..bd1f42b 100644
--- a/opensm/opensm/osm_sa_mcmember_record.c
+++ b/opensm/opensm/osm_sa_mcmember_record.c
@@ -96,49 +96,6 @@ typedef struct osm_sa_mcmr_search_ctxt {
} osm_sa_mcmr_search_ctxt_t;
/**********************************************************************
- A search function that compares the given mgrp with the search context
- if there is a match by mgid the p_mgrp is copied to the search context
- p_mgrp component
-
- Inputs:
- p_map_item - which is part of a mgrp object
- context - points to the osm_sa_mcmr_search_ctxt_t including the mgid
- looked for and the result p_mgrp
-**********************************************************************/
-static void
-__search_mgrp_by_mgid(IN cl_map_item_t * const p_map_item, IN void *context)
-{
- osm_mgrp_t *p_mgrp = (osm_mgrp_t *) p_map_item;
- osm_sa_mcmr_search_ctxt_t *p_ctxt =
- (osm_sa_mcmr_search_ctxt_t *) context;
- const ib_member_rec_t *p_recvd_mcmember_rec;
- osm_sa_t *sa;
-
- p_recvd_mcmember_rec = p_ctxt->p_mcmember_rec;
- sa = p_ctxt->sa;
-
- /* ignore groups marked for deletion */
- if (p_mgrp->to_be_deleted)
- return;
-
- /* compare entire MGID so different scope will not sneak in for
- the same MGID */
- if (memcmp(&p_mgrp->mcmember_rec.mgid,
- &p_recvd_mcmember_rec->mgid, sizeof(ib_gid_t)))
- return;
-
- if (p_ctxt->p_mgrp) {
- osm_log(sa->p_log, OSM_LOG_ERROR,
- "__search_mgrp_by_mgid: ERR 1B03: "
- "Multiple MC groups for same MGID\n");
- return;
- }
-
- p_ctxt->p_mgrp = p_mgrp;
-
-}
-
-/**********************************************************************
Look for a MGRP in the mgrp_mlid_tbl by mlid
**********************************************************************/
static osm_mgrp_t *__get_mgrp_by_mlid(IN osm_sa_t * sa,
@@ -154,31 +111,6 @@ static osm_mgrp_t *__get_mgrp_by_mlid(IN osm_sa_t * sa,
}
-/**********************************************************************
-Look for a MGRP in the mgrp_mlid_tbl by mgid
-***********************************************************************/
-static ib_api_status_t
-__get_mgrp_by_mgid(IN osm_sa_t * sa,
- IN ib_member_rec_t * p_recvd_mcmember_rec,
- OUT osm_mgrp_t ** pp_mgrp)
-{
- osm_sa_mcmr_search_ctxt_t mcmr_search_context;
-
- mcmr_search_context.p_mcmember_rec = p_recvd_mcmember_rec;
- mcmr_search_context.sa = sa;
- mcmr_search_context.p_mgrp = NULL;
-
- cl_qmap_apply_func(&sa->p_subn->mgrp_mlid_tbl,
- __search_mgrp_by_mgid, &mcmr_search_context);
-
- if (mcmr_search_context.p_mgrp == NULL) {
- return IB_NOT_FOUND;
- }
-
- *pp_mgrp = mcmr_search_context.p_mgrp;
- return IB_SUCCESS;
-}
-
/*********************************************************************
Copy certain fields between two mcmember records
used during the process of join request to copy data from the mgrp to the
@@ -1208,6 +1140,69 @@ osm_mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa,
}
+
+typedef struct osm_sa_pr_mcmr_search_ctxt {
+ ib_gid_t *p_mgid;
+ osm_mgrp_t *p_mgrp;
+ osm_sa_t *sa;
+} osm_sa_pr_mcmr_search_ctxt_t;
+
+/**********************************************************************
+ *********************************************************************/
+static void
+__search_mgrp_by_mgid(IN cl_map_item_t * const p_map_item, IN void *context)
+{
+ osm_mgrp_t *p_mgrp = (osm_mgrp_t *) p_map_item;
+ osm_sa_pr_mcmr_search_ctxt_t *p_ctxt =
+ (osm_sa_pr_mcmr_search_ctxt_t *) context;
+ const ib_gid_t *p_recvd_mgid;
+ osm_sa_t *sa;
+ /* uint32_t i; */
+
+ p_recvd_mgid = p_ctxt->p_mgid;
+ sa = p_ctxt->sa;
+
+ /* ignore groups marked for deletion */
+ if (p_mgrp->to_be_deleted)
+ return;
+
+ /* compare entire MGID so different scope will not sneak in for
+ the same MGID */
+ if (memcmp(&p_mgrp->mcmember_rec.mgid, p_recvd_mgid, sizeof(ib_gid_t)))
+ return;
+
+ if (p_ctxt->p_mgrp) {
+ osm_log(sa->p_log, OSM_LOG_ERROR,
+ "__search_mgrp_by_mgid: ERR 1F08: "
+ "Multiple MC groups for same MGID\n");
+ return;
+ }
+ p_ctxt->p_mgrp = p_mgrp;
+}
+
+/**********************************************************************
+ **********************************************************************/
+ib_api_status_t
+osm_get_mgrp_by_mgid(IN osm_sa_t *sa,
+ IN ib_gid_t *p_mgid,
+ OUT osm_mgrp_t **pp_mgrp)
+{
+ osm_sa_pr_mcmr_search_ctxt_t mcmr_search_context;
+
+ mcmr_search_context.p_mgid = p_mgid;
+ mcmr_search_context.sa = sa;
+ mcmr_search_context.p_mgrp = NULL;
+
+ cl_qmap_apply_func(&sa->p_subn->mgrp_mlid_tbl,
+ __search_mgrp_by_mgid, &mcmr_search_context);
+
+ if (mcmr_search_context.p_mgrp == NULL)
+ return IB_NOT_FOUND;
+
+ *pp_mgrp = mcmr_search_context.p_mgrp;
+ return IB_SUCCESS;
+}
+
/**********************************************************************
Call this function to find or create a new mgrp.
**********************************************************************/
@@ -1220,7 +1215,7 @@ osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa,
{
ib_api_status_t status;
- status = __get_mgrp_by_mgid(sa, p_recvd_mcmember_rec, pp_mgrp);
+ status = osm_get_mgrp_by_mgid(sa, &p_recvd_mcmember_rec->mgid, pp_mgrp);
if (status == IB_SUCCESS)
return status;
return osm_mcmr_rcv_create_new_mgrp(sa, comp_mask,
@@ -1264,7 +1259,7 @@ __osm_mcmr_rcv_leave_mgrp(IN osm_sa_t * sa,
}
CL_PLOCK_EXCL_ACQUIRE(sa->p_lock);
- status = __get_mgrp_by_mgid(sa, p_recvd_mcmember_rec, &p_mgrp);
+ status = osm_get_mgrp_by_mgid(sa, &p_recvd_mcmember_rec->mgid, &p_mgrp);
if (status == IB_SUCCESS) {
mlid = p_mgrp->mlid;
portguid = p_recvd_mcmember_rec->port_gid.unicast.interface_id;
@@ -1440,7 +1435,7 @@ __osm_mcmr_rcv_join_mgrp(IN osm_sa_t * sa,
&join_state);
/* do we need to create a new group? */
- status = __get_mgrp_by_mgid(sa, p_recvd_mcmember_rec, &p_mgrp);
+ status = osm_get_mgrp_by_mgid(sa, &p_recvd_mcmember_rec->mgid, &p_mgrp);
if ((status == IB_NOT_FOUND) || p_mgrp->to_be_deleted) {
/* check for JoinState.FullMember = 1 o15.0.1.9 */
if ((join_state & 0x01) != 0x01) {
diff --git a/opensm/opensm/osm_sa_path_record.c b/opensm/opensm/osm_sa_path_record.c
index 749a936..816e8e2 100644
--- a/opensm/opensm/osm_sa_path_record.c
+++ b/opensm/opensm/osm_sa_path_record.c
@@ -88,12 +88,6 @@ typedef struct _osm_path_parms {
boolean_t reversible;
} osm_path_parms_t;
-typedef struct osm_sa_pr_mcmr_search_ctxt {
- ib_gid_t *p_mgid;
- osm_mgrp_t *p_mgrp;
- osm_sa_t *sa;
-} osm_sa_pr_mcmr_search_ctxt_t;
-
static const ib_gid_t zero_gid = { {0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
@@ -1516,72 +1510,6 @@ __osm_pr_rcv_process_pair(IN osm_sa_t * sa,
}
/**********************************************************************
- *********************************************************************/
-static void
-__search_mgrp_by_mgid(IN cl_map_item_t * const p_map_item, IN void *context)
-{
- osm_mgrp_t *p_mgrp = (osm_mgrp_t *) p_map_item;
- osm_sa_pr_mcmr_search_ctxt_t *p_ctxt =
- (osm_sa_pr_mcmr_search_ctxt_t *) context;
- const ib_gid_t *p_recvd_mgid;
- osm_sa_t *sa;
- /* uint32_t i; */
-
- p_recvd_mgid = p_ctxt->p_mgid;
- sa = p_ctxt->sa;
-
- /* ignore groups marked for deletion */
- if (p_mgrp->to_be_deleted)
- return;
-
- /* compare entire MGID so different scope will not sneak in for
- the same MGID */
- if (memcmp(&p_mgrp->mcmember_rec.mgid, p_recvd_mgid, sizeof(ib_gid_t)))
- return;
-
-#if 0
- for (i = 0;
- i < sizeof(p_mgrp->mcmember_rec.mgid.multicast.raw_group_id);
- i++) {
- if (p_mgrp->mcmember_rec.mgid.multicast.raw_group_id[i] !=
- p_recvd_mgid->mgid.multicast.raw_group_id[i])
- return;
- }
-#endif
-
- if (p_ctxt->p_mgrp) {
- osm_log(sa->p_log, OSM_LOG_ERROR,
- "__search_mgrp_by_mgid: ERR 1F08: "
- "Multiple MC groups for same MGID\n");
- return;
- }
- p_ctxt->p_mgrp = p_mgrp;
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__get_mgrp_by_mgid(IN osm_sa_t * sa,
- IN ib_path_rec_t * p_recvd_path_rec,
- OUT osm_mgrp_t ** pp_mgrp)
-{
- osm_sa_pr_mcmr_search_ctxt_t mcmr_search_context;
-
- mcmr_search_context.p_mgid = &p_recvd_path_rec->dgid;
- mcmr_search_context.sa = sa;
- mcmr_search_context.p_mgrp = NULL;
-
- cl_qmap_apply_func(&sa->p_subn->mgrp_mlid_tbl,
- __search_mgrp_by_mgid, &mcmr_search_context);
-
- if (mcmr_search_context.p_mgrp == NULL)
- return IB_NOT_FOUND;
-
- *pp_mgrp = mcmr_search_context.p_mgrp;
- return IB_SUCCESS;
-}
-
-/**********************************************************************
**********************************************************************/
static osm_mgrp_t *__get_mgrp_by_mlid(IN osm_sa_t * sa,
IN ib_net16_t const mlid)
@@ -1615,7 +1543,7 @@ __osm_pr_get_mgrp(IN osm_sa_t * sa,
comp_mask = p_sa_mad->comp_mask;
if (comp_mask & IB_PR_COMPMASK_DGID) {
- status = __get_mgrp_by_mgid(sa, p_pr, pp_mgrp);
+ status = osm_get_mgrp_by_mgid(sa, &p_pr->dgid, pp_mgrp);
if (status != IB_SUCCESS) {
osm_log(sa->p_log, OSM_LOG_ERROR,
"__osm_pr_get_mgrp: ERR 1F09: "
--
1.5.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Consolidate-the-2-__get_mgrp_by_mgid-functions-into.patch
Type: application/octet-stream
Size: 10252 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20080114/3be89a93/attachment.obj>
More information about the general
mailing list