From patchwork Thu Apr 4 11:10:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 2391961 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E0FA03FD1A for ; Thu, 4 Apr 2013 11:10:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757407Ab3DDLK2 (ORCPT ); Thu, 4 Apr 2013 07:10:28 -0400 Received: from mail-bk0-f42.google.com ([209.85.214.42]:50666 "EHLO mail-bk0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757405Ab3DDLK2 (ORCPT ); Thu, 4 Apr 2013 07:10:28 -0400 Received: by mail-bk0-f42.google.com with SMTP id jc3so1438799bkc.1 for ; Thu, 04 Apr 2013 04:10:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=3RdVJ76hNBkYK0js4nzGWexeykrt60OZn1Z5f0DnfpU=; b=Ofv+Nsi5YF7/BhyCYyBILTVUCW+3wzMtAFarr+56DqGT35LFVs6y8VdLGKpf0w1KZn ItGYcZ1yv97DLWCV/usLD0u6MeMlEMr8rLwT26/9Dzlnm2zpHzyxbZ3Kdb7ujWjlzOe3 XOx8y1CRCLMuqXPtip8c5wgRC8mYk5XFV6I83lso5b5XGlraCcT992UcRnJM9hwG1uFE 76LPsKVb7U7jP8xQPaQsI+RlHXwdiXZ+mXGXhM7GVZJAaP1kH/7NdYBbjbs5alDSu3za 02+WpPdK8xqJ3Fr0IqemddNCV0gkWeJGnKZcydGhTsUj0dS3IrSS4u+sE7/dO7q5UVy7 pdLA== X-Received: by 10.204.239.197 with SMTP id kx5mr3994812bkb.71.1365073825953; Thu, 04 Apr 2013 04:10:25 -0700 (PDT) Received: from [192.168.1.102] (c-71-234-225-85.hsd1.ct.comcast.net. [71.234.225.85]) by mx.google.com with ESMTPS id cr6sm5642270bkb.2.2013.04.04.04.10.24 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Apr 2013 04:10:25 -0700 (PDT) Message-ID: <515D5F9F.5080301@dev.mellanox.co.il> Date: Thu, 04 Apr 2013 07:10:23 -0400 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "linux-rdma (linux-rdma@vger.kernel.org)" Subject: [PATCH opensm] Setup SM port GUID in subnet object as soon as it is known X-Gm-Message-State: ALoCoQnJyysaT/ui0KhOHCmw8nVu8eAJvo9txCrNs39E9BEB0LcojWAzEmgZM0p8EVoV1Cztf2sL Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org rather than wait for local NodeInfo response This allows plugin to know SM port GUID at construct() time Signed-off-by: Hal Rosenstock --- -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/opensm/osm_opensm.h b/include/opensm/osm_opensm.h index 3c8bc59..4750505 100644 --- a/include/opensm/osm_opensm.h +++ b/include/opensm/osm_opensm.h @@ -219,8 +219,10 @@ typedef struct osm_opensm { osm_congestion_control_t cc; cl_qlist_t plugin_list; osm_db_t db; + boolean_t mad_pool_constructed; osm_mad_pool_t mad_pool; osm_vendor_t *p_vendor; + boolean_t vl15_constructed; osm_vl15_t vl15; osm_log_t log; cl_dispatcher_t disp; @@ -313,6 +315,34 @@ void osm_opensm_construct(IN osm_opensm_t * p_osm); * SM object, osm_opensm_init, osm_opensm_destroy *********/ +/****f* OpenSM: OpenSM/osm_opensm_construct_finish +* NAME +* osm_opensm_construct_finish +* +* DESCRIPTION +* The osm_opensm_construct_finish function completes +* the second phase of constucting an OpenSM object. +* +* SYNOPSIS +*/ +void osm_opensm_construct_finish(IN osm_opensm_t * p_osm); +/* +* PARAMETERS +* p_osm +* [in] Pointer to a OpenSM object to construct. +* +* RETURN VALUE +* This function does not return a value. +* +* NOTES +* Calling osm_opensm_construct/osm_construct_finish is a prerequisite +* to calling any other method except osm_opensm_init/osm_opensm_init_finish. +* +* SEE ALSO +* SM object, osm_opensm_init, osm_opensm_construct_finish, +* osm_opensm_destroy, osm_opensm_destroy_finish +*********/ + /****f* OpenSM: OpenSM/osm_opensm_destroy * NAME * osm_opensm_destroy @@ -342,6 +372,36 @@ void osm_opensm_destroy(IN osm_opensm_t * p_osm); * SM object, osm_opensm_construct, osm_opensm_init *********/ +/****f* OpenSM: OpenSM/osm_opensm_destroy_finish +* NAME +* osm_opensm_destroy_finish +* +* DESCRIPTION +* The osm_opensm_destroy_finish function handles the second phase +* of destroying an SM, releasing all resources. +* +* SYNOPSIS +*/ +void osm_opensm_destroy_finish(IN osm_opensm_t * p_osm); +/* +* PARAMETERS +* p_osm +* [in] Pointer to a OpenSM object to destroy. +* +* RETURN VALUE +* This function does not return a value. +* +* NOTES +* Performs second phase of any necessary cleanup of the specified OpenSM object. +* Further operations should not be attempted on the destroyed object. +* This function should only be called after a call to +* osm_opensm_construct_finish or osm_opensm_init_finish. +* +* SEE ALSO +* SM object, osm_opensm_construct, osm_opensm_construct_finish, +* osm_opensm_init, osm_opensm_init_finish +*********/ + /****f* OpenSM: OpenSM/osm_opensm_init * NAME * osm_opensm_init @@ -371,6 +431,37 @@ ib_api_status_t osm_opensm_init(IN osm_opensm_t * p_osm, * SM object, osm_opensm_construct, osm_opensm_destroy *********/ +/****f* OpenSM: OpenSM/osm_opensm_init_finish +* NAME +* osm_opensm_init_finish +* +* DESCRIPTION +* The osm_opensm_init_finish function performs the second phase +* of initialization of an OpenSM object. +* +* SYNOPSIS +*/ +ib_api_status_t osm_opensm_init_finish(IN osm_opensm_t * p_osm, + IN const osm_subn_opt_t * p_opt); +/* +* PARAMETERS +* p_osm +* [in] Pointer to an osm_opensm_t object to initialize. +* +* p_opt +* [in] Pointer to the subnet options structure. +* +* RETURN VALUES +* IB_SUCCESS if the OpenSM object was initialized successfully. +* +* NOTES +* Allows calling other OpenSM methods. +* +* SEE ALSO +* SM object, osm_opensm_construct, osm_opensm_construct_finish, +* osm_opensm_destroy, osm_opensm_destroy_finish +*********/ + /****f* OpenSM: OpenSM/osm_opensm_sweep * NAME * osm_opensm_sweep diff --git a/opensm/main.c b/opensm/main.c index 92b1c03..9349d79 100644 --- a/opensm/main.c +++ b/opensm/main.c @@ -1193,7 +1193,16 @@ int main(int argc, char *argv[]) opt.guid = get_port_guid(&osm, opt.guid); if (opt.guid == 0) - goto Exit; + goto Exit2; + + status = osm_opensm_init_finish(&osm, &opt); + if (status != IB_SUCCESS) { + const char *err_str = ib_get_err_str(status); + if (err_str == NULL) + err_str = "Unknown Error Type"; + printf("\nError from osm_opensm_init_finish: %s.\n", err_str); + goto Exit2; + } status = osm_opensm_bind(&osm, opt.guid); if (status != IB_SUCCESS) { @@ -1237,6 +1246,8 @@ int main(int argc, char *argv[]) Exit: osm_opensm_destroy(&osm); +Exit2: + osm_opensm_destroy_finish(&osm); complib_exit(); remove_pidfile(); diff --git a/opensm/osm_opensm.c b/opensm/osm_opensm.c index 0909a36..06a5af2 100644 --- a/opensm/osm_opensm.c +++ b/opensm/osm_opensm.c @@ -243,12 +243,18 @@ void osm_opensm_construct(IN osm_opensm_t * p_osm) memset(p_osm, 0, sizeof(*p_osm)); p_osm->osm_version = OSM_VERSION; osm_subn_construct(&p_osm->subn); + osm_db_construct(&p_osm->db); + osm_log_construct(&p_osm->log); +} + +void osm_opensm_construct_finish(IN osm_opensm_t * p_osm) +{ osm_sm_construct(&p_osm->sm); osm_sa_construct(&p_osm->sa); - osm_db_construct(&p_osm->db); osm_mad_pool_construct(&p_osm->mad_pool); + p_osm->mad_pool_constructed = TRUE; osm_vl15_construct(&p_osm->vl15); - osm_log_construct(&p_osm->log); + p_osm->vl15_constructed = TRUE; } static void destroy_routing_engines(osm_opensm_t *osm) @@ -324,9 +330,17 @@ void osm_opensm_destroy(IN osm_opensm_t * p_osm) osm_perfmgr_destroy(&p_osm->perfmgr); #endif /* ENABLE_OSM_PERF_MGR */ osm_congestion_control_destroy(&p_osm->cc); +} + +void osm_opensm_destroy_finish(IN osm_opensm_t * p_osm) +{ osm_db_destroy(&p_osm->db); - osm_vl15_destroy(&p_osm->vl15, &p_osm->mad_pool); - osm_mad_pool_destroy(&p_osm->mad_pool); + if (p_osm->vl15_constructed && p_osm->mad_pool_constructed) + osm_vl15_destroy(&p_osm->vl15, &p_osm->mad_pool); + if (p_osm->mad_pool_constructed) + osm_mad_pool_destroy(&p_osm->mad_pool); + p_osm->vl15_constructed = FALSE; + p_osm->mad_pool_constructed = FALSE; osm_vendor_delete(&p_osm->p_vendor); osm_subn_destroy(&p_osm->subn); cl_disp_destroy(&p_osm->disp); @@ -336,8 +350,8 @@ void osm_opensm_destroy(IN osm_opensm_t * p_osm) #else cl_event_destroy(&p_osm->stats.event); #endif - close_node_name_map(p_osm->node_name_map); - + if (p_osm->node_name_map) + close_node_name_map(p_osm->node_name_map); cl_plock_destroy(&p_osm->lock); osm_log_destroy(&p_osm->log); @@ -427,10 +441,22 @@ ib_api_status_t osm_opensm_init(IN osm_opensm_t * p_osm, p_osm->p_vendor = osm_vendor_new(&p_osm->log, p_opt->transaction_timeout); - if (p_osm->p_vendor == NULL) { + if (p_osm->p_vendor == NULL) status = IB_INSUFFICIENT_RESOURCES; - goto Exit; - } + +Exit: + OSM_LOG(&p_osm->log, OSM_LOG_FUNCS, "]\n"); /* Format Waived */ + return status; +} + +ib_api_status_t osm_opensm_init_finish(IN osm_opensm_t * p_osm, + IN const osm_subn_opt_t * p_opt) +{ + ib_api_status_t status; + + osm_opensm_construct_finish(p_osm); + + p_osm->subn.sm_port_guid = p_opt->guid; status = osm_mad_pool_init(&p_osm->mad_pool); if (status != IB_SUCCESS)