From patchwork Thu Mar 7 12:47:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 2231461 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B6C93DF223 for ; Thu, 7 Mar 2013 12:48:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752783Ab3CGMsD (ORCPT ); Thu, 7 Mar 2013 07:48:03 -0500 Received: from mail-ee0-f44.google.com ([74.125.83.44]:38281 "EHLO mail-ee0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751787Ab3CGMsA (ORCPT ); Thu, 7 Mar 2013 07:48:00 -0500 Received: by mail-ee0-f44.google.com with SMTP id l10so259251eei.17 for ; Thu, 07 Mar 2013 04:47:59 -0800 (PST) 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:cc :subject:content-type:content-transfer-encoding:x-gm-message-state; bh=T5d/10IaErfJ2zR7xfTrwk7fuLkWltnHwRBZWleATq0=; b=YaesR3OvPgPQRti3YpFuoSYy3TCq2SAR5f968iSDExm913svbyrPoqMzFHEcuA4hIh T5eVKLFeuPHFSk9b/7Ckp/l/vTFAarna0dj4Hx4NVcoZjx1Y0hlGUIMvt3HP5A6NZS7D cv5OWBDt9RUIHl+0pEbSNHonffmd1ytHh/nfamcT1GcuX5AbcQ5gQd/xRkhXTFQl3WBX 7F7Iql3FxobUtO8D5dz2hTi7S6h1vSDGoLYa44haiCKTUkC2j09B3ztlgXhxWPyEXqJu 7aHL/oHhaBElokUJSjDLrkii/ARxITE6rJYV/zmzOcEzHRsvnVV++AD09JWEUV6vFE0T pxOA== X-Received: by 10.14.179.5 with SMTP id g5mr93410122eem.41.1362660478858; Thu, 07 Mar 2013 04:47:58 -0800 (PST) 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 u44sm2064148eel.7.2013.03.07.04.47.57 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Mar 2013 04:47:58 -0800 (PST) Message-ID: <51388C7B.6090007@dev.mellanox.co.il> Date: Thu, 07 Mar 2013 07:47:55 -0500 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)" CC: Dan Ben-Yosef Subject: [PATCH 1/3] opensm/osmtest.c: half_world_query when creating, inventory file X-Gm-Message-State: ALoCoQnztPqcnxCFC300l5yZvwA7vC37D8p6SJMplfSLCKsZ64fv/ltZXkiLtUhZS9L8vUw+ms8y Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org When osmtest needs to create path records for inventory file, it will do n half-world queries (instead of full world query) where n is the number of end ports which was previously determined. Signed-off-by: Dan Ben Yosef --- osmtest/osmtest.c | 130 ++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 104 insertions(+), 26 deletions(-) diff --git a/osmtest/osmtest.c b/osmtest/osmtest.c index 36b9dc8..5dbf0db 100644 --- a/osmtest/osmtest.c +++ b/osmtest/osmtest.c @@ -832,6 +832,69 @@ Exit: } static ib_api_status_t +osmtest_get_path_rec_by_half_world_query(IN osmtest_t * const p_osmt, + IN ib_net64_t sguid, + IN osmtest_req_context_t * p_context) +{ + cl_status_t status = IB_SUCCESS; + osmv_query_req_t req; + osmv_user_query_t user; + ib_path_rec_t record; + + OSM_LOG_ENTER(&p_osmt->log); + + memset(&req, 0, sizeof(req)); + memset(p_context, 0, sizeof(*p_context)); + memset(&record, 0, sizeof(record)); + memset(&user, 0, sizeof(user)); + + ib_gid_set_default(&(record.sgid), sguid); + record.num_path = 0x01; + + p_context->p_osmt = p_osmt; + user.comp_mask = (IB_PR_COMPMASK_SGID | IB_PR_COMPMASK_NUMBPATH); + user.attr_id = IB_MAD_ATTR_PATH_RECORD; + user.p_attr = &record; + + req.query_type = OSMV_QUERY_USER_DEFINED; + req.timeout_ms = p_osmt->opt.transaction_timeout; + req.retry_cnt = p_osmt->opt.retry_count; + req.flags = OSM_SA_FLAGS_SYNC; + req.query_context = p_context; + req.pfn_query_cb = osmtest_query_res_cb; + req.p_query_input = &user; + req.sm_key = 0; + + status = osmv_query_sa(p_osmt->h_bind, &req); + if (status != IB_SUCCESS) { + OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0063: " + "ib_query failed (%s)\n", ib_get_err_str(status)); + goto Exit; + } + + status = (*p_context).result.status; + + if (status != IB_SUCCESS) { + OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0066: " + "ib_query failed (%s)\n", ib_get_err_str(status)); + + if (status == IB_REMOTE_ERROR) { + OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, + "Remote error = %s\n", + ib_get_mad_status_str(osm_madw_get_mad_ptr + ((*p_context).result. + p_result_madw))); + } + goto Exit; + } + +Exit: + + OSM_LOG_EXIT(&p_osmt->log); + return (status); +} + +static ib_api_status_t osmtest_get_path_rec_by_guid_pair(IN osmtest_t * const p_osmt, IN ib_net64_t sguid, IN ib_net64_t dguid, @@ -2028,6 +2091,7 @@ osmtest_write_all_node_recs(IN osmtest_t * const p_osmt, IN FILE * fh) cl_status_t status; size_t num_recs; int result; + node_t *p_guid_node; OSM_LOG_ENTER(&p_osmt->log); @@ -2065,6 +2129,16 @@ osmtest_write_all_node_recs(IN osmtest_t * const p_osmt, IN FILE * fh) p_rec = osmv_get_query_node_rec(context.result.p_result_madw, i); osmtest_write_node_info(p_osmt, fh, p_rec); + + /* create a subnet object */ + p_guid_node = node_new(); + CL_ASSERT(p_node != NULL); + + /* copy the info to the subnet node object */ + p_guid_node->rec = *p_rec; + cl_qmap_insert(&p_osmt->exp_subn.node_guid_tbl, + p_guid_node->rec.node_info.port_guid, + &p_guid_node->map_item); } Exit: @@ -2156,33 +2230,16 @@ osmtest_write_all_path_recs(IN osmtest_t * const p_osmt, IN FILE * fh) osmtest_req_context_t context; const ib_path_rec_t *p_rec; uint32_t i; - cl_status_t status; + cl_status_t status = CL_SUCCESS; size_t num_recs; int result; + node_t *p_dst_node; + cl_qmap_t *p_tbl; OSM_LOG_ENTER(&p_osmt->log); - memset(&context, 0, sizeof(context)); - - /* - * Do a blocking query for all PathRecords in the subnet. - */ - status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PATH_RECORD, - sizeof(*p_rec), &context); - - if (status != IB_SUCCESS) { - OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0025: " - "osmtest_get_all_recs failed (%s)\n", - ib_get_err_str(status)); - goto Exit; - } - - /* - * Write the received records out to the file. - */ - num_recs = context.result.result_cnt; - - OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs); + p_tbl = &p_osmt->exp_subn.node_guid_tbl; + p_dst_node = (node_t *) cl_qmap_head(p_tbl); result = fprintf(fh, "#\n" "# Path Records\n" "#\n"); if (result < 0) { @@ -2192,10 +2249,31 @@ osmtest_write_all_path_recs(IN osmtest_t * const p_osmt, IN FILE * fh) goto Exit; } - for (i = 0; i < num_recs; i++) { - p_rec = - osmv_get_query_path_rec(context.result.p_result_madw, i); - osmtest_write_path_info(p_osmt, fh, p_rec); + while (p_dst_node != (node_t *) cl_qmap_end(p_tbl)) { + + OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,"Source : lid = 0x%d type = %d\n", + cl_ntoh16(p_dst_node->rec.lid), + p_dst_node->rec.node_info.node_type); + + status = osmtest_get_path_rec_by_half_world_query(p_osmt, p_dst_node->rec.node_info.port_guid, &context); + if (status != IB_SUCCESS) { + OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0025: " + "osmtest_get_all_path_recs failed (%s)\n", + ib_get_err_str(status)); + goto Exit; + } + /* + * Write the received records out to the file. + */ + num_recs = context.result.result_cnt; + OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs); + + for (i = 0; i < num_recs; i++) { + p_rec = + osmv_get_query_path_rec(context.result.p_result_madw, i); + osmtest_write_path_info(p_osmt, fh, p_rec); + } + p_dst_node = (node_t *) cl_qmap_next(&p_dst_node->map_item); } Exit: