From patchwork Sat Sep 19 16:58:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 48771 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8JGukCU027116 for ; Sat, 19 Sep 2009 16:56:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753111AbZISQ4l (ORCPT ); Sat, 19 Sep 2009 12:56:41 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753247AbZISQ4l (ORCPT ); Sat, 19 Sep 2009 12:56:41 -0400 Received: from ey-out-2122.google.com ([74.125.78.25]:54903 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753111AbZISQ4k (ORCPT ); Sat, 19 Sep 2009 12:56:40 -0400 Received: by ey-out-2122.google.com with SMTP id d26so181278eyd.19 for ; Sat, 19 Sep 2009 09:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:received:date:from:to :cc:subject:message-id:mime-version:content-type:content-disposition :user-agent; bh=A7gAgRf9CIbBoxxyfMbRJyDJTLB8/FkZ2VjSMzO0gUo=; b=S4dOsXQMG1Q+71wg5vZw797th908wtQ1wMLgeBnSYu9ee0H26nLgZVcG0r3DcxNFl6 gDJ3wTOLX+tSnVG4BmtJS2wdAVWtxE80Wkkg2LGbvnTvn7RpdSZxwrLjqyha0eODVaj/ XgC8waNdT5eMLq/O+HlMX4NtBhdvB0JTo3dgM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=r4FvIN1qw0thAssi1XjWUrA67Mbgyj6z+bBotZL3/q380oCZ0VwbudCnF8tOVBNRX8 1z151ovaF0sMp0BVkIc+jCJQeHOOnjPmZit6ROfZxe7apH8rVLsMW/QdBddYAieeBLxz VXp2wCa7eeY3U6y1d2PDd/hCERbPIQ1jl5os8= Received: by 10.211.147.10 with SMTP id z10mr883350ebn.28.1253379403235; Sat, 19 Sep 2009 09:56:43 -0700 (PDT) Received: from me.localdomain (85.64.35.106.dynamic.barak-online.net [85.64.35.106]) by mx.google.com with ESMTPS id 28sm393843eye.6.2009.09.19.09.56.39 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 19 Sep 2009 09:56:40 -0700 (PDT) Received: by me.localdomain (Postfix, from userid 1000) id C14C0417DC; Sat, 19 Sep 2009 19:58:17 +0300 (IDT) Date: Sat, 19 Sep 2009 19:58:17 +0300 From: Sasha Khapyorsky To: OpenIB , linux-rdma Cc: Eli Dorfman , Slava Strebkov Subject: [PATCH] opensm/multicast: improve function prototypes Message-ID: <20090919165817.GC13667@me> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Improve some function prototypes: - osm_mgrp_new() will get MCMember record now. - osm_mgrp_is_port_present() is replaced by cleaner osm_mgrp_get_mcm_port() helper. Signed-off-by: Sasha Khapyorsky --- opensm/include/opensm/osm_multicast.h | 25 ++++++++++--------------- opensm/opensm/osm_multicast.c | 32 ++++++++++---------------------- opensm/opensm/osm_sa_mcmember_record.c | 26 +++++++++++--------------- 3 files changed, 31 insertions(+), 52 deletions(-) diff --git a/opensm/include/opensm/osm_multicast.h b/opensm/include/opensm/osm_multicast.h index 32bcb78..15d7e78 100644 --- a/opensm/include/opensm/osm_multicast.h +++ b/opensm/include/opensm/osm_multicast.h @@ -142,12 +142,15 @@ typedef struct osm_mgrp { * * SYNOPSIS */ -osm_mgrp_t *osm_mgrp_new(IN const ib_net16_t mlid); +osm_mgrp_t *osm_mgrp_new(IN const ib_net16_t mlid, IN ib_member_rec_t * mcmr); /* * PARAMETERS * mlid * [in] Multicast LID for this multicast group. * +* mcmr +* [in] MCMember Record for this multicast group. +* * RETURN VALUES * IB_SUCCESS if initialization was successful. * @@ -309,20 +312,17 @@ osm_mcm_port_t *osm_mgrp_add_port(osm_subn_t *subn, osm_log_t *log, * SEE ALSO *********/ -/****f* OpenSM: Multicast Group/osm_mgrp_is_port_present +/****f* OpenSM: Multicast Group/osm_mgrp_get_mcm_port * NAME -* osm_mgrp_is_port_present +* osm_mgrp_get_mcm_port * * DESCRIPTION -* checks a port from the multicast group. +* finds a port in the multicast group. * * SYNOPSIS */ - -boolean_t -osm_mgrp_is_port_present(IN const osm_mgrp_t * const p_mgrp, - IN const ib_net64_t port_guid, - OUT osm_mcm_port_t ** const pp_mcm_port); +osm_mcm_port_t *osm_mgrp_get_mcm_port(IN const osm_mgrp_t * const p_mgrp, + IN const ib_net64_t port_guid); /* * PARAMETERS * p_mgrp @@ -331,13 +331,8 @@ osm_mgrp_is_port_present(IN const osm_mgrp_t * const p_mgrp, * port_guid * [in] Port guid of the departing port. * -* pp_mcm_port -* [out] Pointer to a pointer to osm_mcm_port_t -* Updated to the member on success or NULLed -* * RETURN VALUES -* TRUE if port present -* FALSE if port is not present. +* Pointer to the mcm port object when present or NULL otherwise. * * NOTES * diff --git a/opensm/opensm/osm_multicast.c b/opensm/opensm/osm_multicast.c index 5a10003..a674514 100644 --- a/opensm/opensm/osm_multicast.c +++ b/opensm/opensm/osm_multicast.c @@ -75,9 +75,7 @@ void osm_mgrp_delete(IN osm_mgrp_t * p_mgrp) free(p_mgrp); } -/********************************************************************** - **********************************************************************/ -osm_mgrp_t *osm_mgrp_new(IN const ib_net16_t mlid) +osm_mgrp_t *osm_mgrp_new(IN const ib_net16_t mlid, IN ib_member_rec_t * mcmr) { osm_mgrp_t *p_mgrp; @@ -88,10 +86,13 @@ osm_mgrp_t *osm_mgrp_new(IN const ib_net16_t mlid) memset(p_mgrp, 0, sizeof(*p_mgrp)); cl_qmap_init(&p_mgrp->mcm_port_tbl); p_mgrp->mlid = mlid; + p_mgrp->mcmember_rec = *mcmr; return p_mgrp; } +/********************************************************************** + **********************************************************************/ void osm_mgrp_cleanup(osm_subn_t * subn, osm_mgrp_t * mgrp) { osm_mcm_port_t *mcm_port; @@ -207,8 +208,6 @@ osm_mcm_port_t *osm_mgrp_add_port(IN osm_subn_t * subn, osm_log_t * log, return mcm_port; } -/********************************************************************** - **********************************************************************/ void osm_mgrp_remove_port(osm_subn_t * subn, osm_log_t * log, osm_mgrp_t * mgrp, osm_mcm_port_t * mcm_port, ib_member_rec_t *mcmr) { @@ -277,22 +276,11 @@ void osm_mgrp_delete_port(osm_subn_t * subn, osm_log_t * log, osm_mgrp_t * mgrp, /********************************************************************** **********************************************************************/ -boolean_t osm_mgrp_is_port_present(IN const osm_mgrp_t * p_mgrp, - IN const ib_net64_t port_guid, - OUT osm_mcm_port_t ** const pp_mcm_port) +osm_mcm_port_t *osm_mgrp_get_mcm_port(IN const osm_mgrp_t * p_mgrp, + IN const ib_net64_t port_guid) { - cl_map_item_t *p_map_item; - - CL_ASSERT(p_mgrp); - - p_map_item = cl_qmap_get(&p_mgrp->mcm_port_tbl, port_guid); - - if (p_map_item != cl_qmap_end(&p_mgrp->mcm_port_tbl)) { - if (pp_mcm_port) - *pp_mcm_port = (osm_mcm_port_t *) p_map_item; - return TRUE; - } - if (pp_mcm_port) - *pp_mcm_port = NULL; - return FALSE; + cl_map_item_t *item = cl_qmap_get(&p_mgrp->mcm_port_tbl, port_guid); + if (item != cl_qmap_end(&p_mgrp->mcm_port_tbl)) + return (osm_mcm_port_t *)item; + return NULL; } diff --git a/opensm/opensm/osm_sa_mcmember_record.c b/opensm/opensm/osm_sa_mcmember_record.c index 8f7816b..f581663 100644 --- a/opensm/opensm/osm_sa_mcmember_record.c +++ b/opensm/opensm/osm_sa_mcmember_record.c @@ -340,10 +340,10 @@ static boolean_t validate_modify(IN osm_sa_t * sa, IN osm_mgrp_t * p_mgrp, portguid = p_recvd_mcmember_rec->port_gid.unicast.interface_id; - *pp_mcm_port = NULL; + *pp_mcm_port = osm_mgrp_get_mcm_port(p_mgrp, portguid); /* o15-0.2.1: If this is a new port being added - nothing to check */ - if (!osm_mgrp_is_port_present(p_mgrp, portguid, pp_mcm_port)) { + if (!*pp_mcm_port) { OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "This is a new port in the MC group\n"); return TRUE; @@ -428,10 +428,10 @@ static boolean_t validate_delete(IN osm_sa_t * sa, IN osm_mgrp_t * p_mgrp, portguid = p_recvd_mcmember_rec->port_gid.unicast.interface_id; - *pp_mcm_port = NULL; + *pp_mcm_port = osm_mgrp_get_mcm_port(p_mgrp, portguid); /* 1 */ - if (!osm_mgrp_is_port_present(p_mgrp, portguid, pp_mcm_port)) { + if (!*pp_mcm_port) { OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Failed to find the port in the MC group\n"); return FALSE; @@ -812,7 +812,8 @@ ib_api_status_t osm_mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa, } /* create a new MC Group */ - *pp_mgrp = osm_mgrp_new(mlid); + mcm_rec.mlid = mlid; + *pp_mgrp = osm_mgrp_new(mlid, &mcm_rec); if (*pp_mgrp == NULL) { OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B08: " "osm_mgrp_new failed\n"); @@ -821,10 +822,6 @@ ib_api_status_t osm_mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa, goto Exit; } - /* Initialize the mgrp */ - (*pp_mgrp)->mcmember_rec = mcm_rec; - (*pp_mgrp)->mcmember_rec.mlid = mlid; - /* the mcmember_record should have mtu_sel, rate_sel, and pkt_lifetime_sel = 2 */ (*pp_mgrp)->mcmember_rec.mtu &= 0x3f; (*pp_mgrp)->mcmember_rec.mtu |= 2 << 6; /* exactly */ @@ -1307,13 +1304,12 @@ static void mcmr_by_comp_mask(osm_sa_t * sa, const ib_member_rec_t * p_rcvd_rec, /* so did we get the PortGUID mask */ if (IB_MCR_COMPMASK_PORT_GID & comp_mask) { /* try to find this port */ - if (osm_mgrp_is_port_present(p_mgrp, portguid, &p_mcm_port)) { - scope_state = p_mcm_port->scope_state; - memcpy(&port_gid, &(p_mcm_port->port_gid), - sizeof(ib_gid_t)); - proxy_join = p_mcm_port->proxy_join; - } else /* port not in group */ + p_mcm_port = osm_mgrp_get_mcm_port(p_mgrp, portguid); + if (!p_mcm_port) /* port not in group */ goto Exit; + scope_state = p_mcm_port->scope_state; + memcpy(&port_gid, &(p_mcm_port->port_gid), sizeof(ib_gid_t)); + proxy_join = p_mcm_port->proxy_join; } else /* point to the group information */ scope_state = p_mgrp->mcmember_rec.scope_state;