From patchwork Tue Sep 7 20:55:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 162231 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o87KrUgI014705 for ; Tue, 7 Sep 2010 20:53:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757185Ab0IGUxZ (ORCPT ); Tue, 7 Sep 2010 16:53:25 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:52358 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756993Ab0IGUxY (ORCPT ); Tue, 7 Sep 2010 16:53:24 -0400 Received: by fxm16 with SMTP id 16so303288fxm.19 for ; Tue, 07 Sep 2010 13:53:22 -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:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=HFRUJRxfM4N58hfhfSZwGgLufjRopQUayu5taWnI5/o=; b=HvOTtsC2kWTgIu/W5lPppDqKgcWNXc+xmXisdPvaYAmrtA0uhDjg3pnlr9pAAVGVk4 evZnnt6+jwPIVhf7Ea5lLH895JOZkOpCdwDu1G7IRzjoUSCmsP8VKirxs66pqTjQ3mwl DgVoAQLMKpknu60VYLJ/KlSpJ3+fko8iYkRnA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=CXP7jwHpFA9NuUsPS2zYbk9eWl2ZcnBLSXVMD318iHoTcBuR8bkvcGN+L1NWZ2v7gK Y4F/VZ4vi6JZ/rAhZ4uUAUUYXL924uxGt1tQFyOwDIa0Y/+RNwdE804AHH/M4G2cwJ/+ ksX7/hdmM+2SnT8ypDH84ye2+lzKrEXlWj8e4= Received: by 10.223.116.196 with SMTP id n4mr46607faq.75.1283892801633; Tue, 07 Sep 2010 13:53:21 -0700 (PDT) Received: from me.localdomain (bzq-79-176-25-173.red.bezeqint.net [79.176.25.173]) by mx.google.com with ESMTPS id a6sm3114435faa.44.2010.09.07.13.53.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 07 Sep 2010 13:53:21 -0700 (PDT) Received: by me.localdomain (Postfix, from userid 1000) id 8E0C011EA5; Tue, 7 Sep 2010 23:55:27 +0300 (IDT) Date: Tue, 7 Sep 2010 23:55:27 +0300 From: Sasha Khapyorsky To: Linux RDMA Cc: kliteyn@dev.mellanox.co.il Subject: [PATCH] opensm/sa: simplify osm_mcmr_rcv_find_or_create_new_mgrp() function call Message-ID: <20100907205527.GR11502@me> References: <4C865139.7010705@mellanox.co.il> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4C865139.7010705@mellanox.co.il> 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 07 Sep 2010 20:53:31 +0000 (UTC) diff --git a/opensm/include/opensm/osm_sa.h b/opensm/include/opensm/osm_sa.h index d516310..7c1061d 100644 --- a/opensm/include/opensm/osm_sa.h +++ b/opensm/include/opensm/osm_sa.h @@ -472,22 +472,21 @@ int osm_sa_db_file_load(struct osm_opensm *p_osm); * SYNOPSIS */ -ib_api_status_t -osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa, IN ib_net64_t comp_mask, - IN ib_member_rec_t * p_recvd_mcmember_rec, - OUT osm_mgrp_t ** pp_mgrp); +osm_mgrp_t *osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa, + IN ib_net64_t comp_mask, + IN ib_member_rec_t * + p_recvd_mcmember_rec); /* * PARAMETERS * p_sa * [in] Pointer to an osm_sa_t object. +* comp_mask +* [in] SA query component mask * p_recvd_mcmember_rec * [in] Received Multicast member record * -* pp_mgrp -* [out] pointer the osm_mgrp_t object -* * RETURN VALUES -* IB_SUCCESS, IB_ERROR +* The pointer to MC group object found or created, NULL in case of errors * *********/ diff --git a/opensm/opensm/osm_prtn.c b/opensm/opensm/osm_prtn.c index 4b087a4..6a23c76 100644 --- a/opensm/opensm/osm_prtn.c +++ b/opensm/opensm/osm_prtn.c @@ -174,9 +174,8 @@ ib_api_status_t osm_prtn_add_mcgroup(osm_log_t * p_log, osm_subn_t * p_subn, ib_member_rec_t mc_rec; ib_net64_t comp_mask; ib_net16_t pkey; - osm_mgrp_t *p_mgrp = NULL; + osm_mgrp_t *mgrp; osm_sa_t *p_sa = &p_subn->p_osm->sa; - ib_api_status_t status = IB_SUCCESS; uint8_t hop_limit; pkey = p->pkey | cl_hton16(0x8000); @@ -197,24 +196,25 @@ ib_api_status_t osm_prtn_add_mcgroup(osm_log_t * p_log, osm_subn_t * p_subn, mc_rec.pkt_life = p_subn->opt.subnet_timeout; mc_rec.sl_flow_hop = ib_member_set_sl_flow_hop(p->sl, 0, hop_limit); /* Scope in MCMemberRecord (if present) needs to be consistent with MGID */ - mc_rec.scope_state = ib_member_set_scope_state(scope, IB_MC_REC_STATE_FULL_MEMBER); + mc_rec.scope_state = + ib_member_set_scope_state(scope, IB_MC_REC_STATE_FULL_MEMBER); ib_mgid_set_scope(&mc_rec.mgid, scope); /* don't update rate, mtu */ comp_mask = IB_MCR_COMPMASK_MTU | IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_RATE | IB_MCR_COMPMASK_RATE_SEL; - status = osm_mcmr_rcv_find_or_create_new_mgrp(p_sa, comp_mask, &mc_rec, - &p_mgrp); - if (!p_mgrp || status != IB_SUCCESS) + mgrp = osm_mcmr_rcv_find_or_create_new_mgrp(p_sa, comp_mask, &mc_rec); + if (!mgrp) { OSM_LOG(p_log, OSM_LOG_ERROR, "Failed to create MC group with pkey 0x%04x\n", cl_ntoh16(pkey)); - if (p_mgrp) { - p_mgrp->well_known = TRUE; - p->mgrp = p_mgrp; + return IB_ERROR; } - return status; + mgrp->well_known = TRUE; + p->mgrp = mgrp; + + return IB_SUCCESS; } static uint16_t generate_pkey(osm_subn_t * p_subn) diff --git a/opensm/opensm/osm_sa.c b/opensm/opensm/osm_sa.c index ef9872d..812e435 100644 --- a/opensm/opensm/osm_sa.c +++ b/opensm/opensm/osm_sa.c @@ -741,10 +741,10 @@ static osm_mgrp_t *load_mcgroup(osm_opensm_t * p_osm, ib_net16_t mlid, comp_mask = IB_MCR_COMPMASK_MTU | IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_RATE | IB_MCR_COMPMASK_RATE_SEL; - if (osm_mcmr_rcv_find_or_create_new_mgrp(&p_osm->sa, - comp_mask, p_mcm_rec, - &p_mgrp) != IB_SUCCESS || - !p_mgrp || p_mgrp->mlid != mlid) { + if (!(p_mgrp = osm_mcmr_rcv_find_or_create_new_mgrp(&p_osm->sa, + comp_mask, + p_mcm_rec)) || + p_mgrp->mlid != mlid) { OSM_LOG(&p_osm->log, OSM_LOG_ERROR, "cannot create MC group with mlid 0x%04x and mgid " "0x%016" PRIx64 ":0x%016" PRIx64 "\n", cl_ntoh16(mlid), diff --git a/opensm/opensm/osm_sa_mcmember_record.c b/opensm/opensm/osm_sa_mcmember_record.c index 93c2767..b2318ec 100644 --- a/opensm/opensm/osm_sa_mcmember_record.c +++ b/opensm/opensm/osm_sa_mcmember_record.c @@ -868,21 +868,20 @@ Exit: /********************************************************************** Call this function to find or create a new mgrp. **********************************************************************/ -ib_api_status_t osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa, - IN ib_net64_t comp_mask, - IN ib_member_rec_t * - p_recvd_mcmember_rec, - OUT osm_mgrp_t ** pp_mgrp) +osm_mgrp_t *osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa, + IN ib_net64_t comp_mask, + IN ib_member_rec_t * + p_recvd_mcmember_rec) { osm_mgrp_t *mgrp; if ((mgrp = osm_get_mgrp_by_mgid(sa->p_subn, - &p_recvd_mcmember_rec->mgid))) { - *pp_mgrp = mgrp; - return IB_SUCCESS; - } - return mcmr_rcv_create_new_mgrp(sa, comp_mask, p_recvd_mcmember_rec, - NULL, pp_mgrp); + &p_recvd_mcmember_rec->mgid))) + return mgrp; + if (mcmr_rcv_create_new_mgrp(sa, comp_mask, p_recvd_mcmember_rec, NULL, + &mgrp) == IB_SUCCESS) + return mgrp; + return NULL; } /*********************************************************************