From patchwork Fri May 20 19:50:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 804712 X-Patchwork-Delegate: alexne@voltaire.com 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 p4KJnt4N001499 for ; Fri, 20 May 2011 19:50:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935699Ab1ETTuV (ORCPT ); Fri, 20 May 2011 15:50:21 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:32862 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933066Ab1ETTuU (ORCPT ); Fri, 20 May 2011 15:50:20 -0400 Received: by mail-wy0-f174.google.com with SMTP id 21so2968601wya.19 for ; Fri, 20 May 2011 12:50:18 -0700 (PDT) Received: by 10.227.10.67 with SMTP id o3mr25135wbo.26.1305921017749; Fri, 20 May 2011 12:50:17 -0700 (PDT) Received: from [192.168.1.103] (c-71-192-10-85.hsd1.ma.comcast.net [71.192.10.85]) by mx.google.com with ESMTPS id y29sm2493742wbd.4.2011.05.20.12.50.15 (version=SSLv3 cipher=OTHER); Fri, 20 May 2011 12:50:16 -0700 (PDT) Message-ID: <4DD6C5F6.8020301@dev.mellanox.co.il> Date: Fri, 20 May 2011 15:50:14 -0400 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: Alex Netes CC: "linux-rdma@vger.kernel.org" Subject: [PATCHv2 3/13] opensm: Dump/load SA GUIDInfoRecords 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.6 (demeter1.kernel.org [140.211.167.41]); Fri, 20 May 2011 19:50:21 +0000 (UTC) into port alias guid table Signed-off-by: Hal Rosenstock --- Changes since v1: In osm_sa.c:load_guidinfo, change continue to break opensm/osm_sa.c | 146 ++++++++++++++++++++++++++++++++++++++- opensm/osm_sa_guidinfo_record.c | 8 ++- 2 files changed, 150 insertions(+), 4 deletions(-) diff --git a/opensm/osm_sa.c b/opensm/osm_sa.c index bbd1a56..1a53de3 100644 --- a/opensm/osm_sa.c +++ b/opensm/osm_sa.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved. - * Copyright (c) 2002-2009 Mellanox Technologies LTD. All rights reserved. + * Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved. * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved. * @@ -680,6 +680,40 @@ static void sa_dump_one_service(cl_list_item_t * p_list_item, void *cxt) p_svcr->modified_time, p_svcr->lease_period); } +static void sa_dump_one_port_guidinfo(cl_map_item_t * p_map_item, void *cxt) +{ + FILE *file = ((struct opensm_dump_context *)cxt)->file; + osm_port_t *p_port = (osm_port_t *) p_map_item; + uint32_t max_block; + int block_num; + + if (!p_port->p_physp->p_guids) + return; + + max_block = (p_port->p_physp->port_info.guid_cap + GUID_TABLE_MAX_ENTRIES - 1) / + GUID_TABLE_MAX_ENTRIES; + + for (block_num = 0; block_num < max_block; block_num++) { + fprintf(file, "GUIDInfo Record:" + " base_guid=0x%016" PRIx64 " lid=0x%04x block_num=0x%x" + " guid0=0x%016" PRIx64 " guid1=0x%016" PRIx64 + " guid2=0x%016" PRIx64 " guid3=0x%016" PRIx64 + " guid4=0x%016" PRIx64 " guid5=0x%016" PRIx64 + " guid6=0x%016" PRIx64 " guid7=0x%016" PRIx64 + "\n\n", + cl_ntoh64((*p_port->p_physp->p_guids)[0]), + cl_ntoh16(osm_port_get_base_lid(p_port)), block_num, + cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES]), + cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 1]), + cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 2]), + cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 3]), + cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 4]), + cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 5]), + cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 6]), + cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 7])); + } +} + static void sa_dump_all_sa(osm_opensm_t * p_osm, FILE * file) { struct opensm_dump_context dump_context; @@ -687,8 +721,11 @@ static void sa_dump_all_sa(osm_opensm_t * p_osm, FILE * file) dump_context.p_osm = p_osm; dump_context.file = file; - OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "Dump multicast\n"); + OSM_LOG(&p_osm->log, OSM_LOG_ERROR /* DEBUG */, "Dump guidinfo\n"); cl_plock_acquire(&p_osm->lock); + cl_qmap_apply_func(&p_osm->subn.port_guid_tbl, + sa_dump_one_port_guidinfo, &dump_context); + OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "Dump multicast\n"); for (p_mgrp = (osm_mgrp_t *) cl_fmap_head(&p_osm->subn.mgrp_mgid_tbl); p_mgrp != (osm_mgrp_t *) cl_fmap_end(&p_osm->subn.mgrp_mgid_tbl); p_mgrp = (osm_mgrp_t *) cl_fmap_next(&p_mgrp->map_item)) @@ -834,6 +871,81 @@ _out: return ret; } +static int load_guidinfo(osm_opensm_t * p_osm, ib_net64_t base_guid, + ib_guidinfo_record_t *gir) +{ + osm_port_t *p_port; + uint32_t max_block; + int i, ret = 0; + osm_alias_guid_t *p_alias_guid, *p_alias_guid_check; + + cl_plock_excl_acquire(&p_osm->lock); + + p_port = osm_get_port_by_guid(&p_osm->subn, base_guid); + if (!p_port) + goto _out; + + if (!p_port->p_physp->p_guids) { + max_block = (p_port->p_physp->port_info.guid_cap + GUID_TABLE_MAX_ENTRIES - 1) / + GUID_TABLE_MAX_ENTRIES; + p_port->p_physp->p_guids = calloc(max_block * GUID_TABLE_MAX_ENTRIES, + sizeof(ib_net64_t)); + if (!p_port->p_physp->p_guids) { + OSM_LOG(&p_osm->log, OSM_LOG_ERROR, + "cannot allocate GUID table for port " + "GUID 0x%" PRIx64 "\n", + cl_ntoh64(p_port->p_physp->port_guid)); + goto _out; + } + } + + for (i = 0; i < GUID_TABLE_MAX_ENTRIES; i++) { + if (!gir->guid_info.guid[i]) + continue; + /* skip block 0 index 0 */ + if (gir->block_num == 0 && i == 0) + continue; + if (gir->block_num * GUID_TABLE_MAX_ENTRIES + i > + p_port->p_physp->port_info.guid_cap) + break; + + p_alias_guid = osm_alias_guid_new(gir->guid_info.guid[i], + p_port); + if (!p_alias_guid) { + OSM_LOG(&p_osm->log, OSM_LOG_ERROR, + "Alias guid %d memory allocation failed" + " for port GUID 0x%" PRIx64 "\n", + gir->block_num * GUID_TABLE_MAX_ENTRIES + i, + cl_ntoh64(p_port->p_physp->port_guid)); + goto _out; + } + + p_alias_guid_check = + (osm_alias_guid_t *) cl_qmap_insert(&p_osm->subn.alias_port_guid_tbl, + p_alias_guid->alias_guid, + &p_alias_guid->map_item); + if (p_alias_guid_check != p_alias_guid) { + /* alias GUID is a duplicate */ + OSM_LOG(&p_osm->log, OSM_LOG_ERROR, + "Duplicate alias port GUID 0x%" PRIx64 + " index %d base port GUID 0x%" PRIx64 "\n", + cl_ntoh64(p_alias_guid->alias_guid), + gir->block_num * GUID_TABLE_MAX_ENTRIES + i, + cl_ntoh64(p_alias_guid->p_base_port->guid)); + osm_alias_guid_delete(&p_alias_guid); + goto _out; + } + } + + memcpy(&(*p_port->p_physp->p_guids)[gir->block_num * GUID_TABLE_MAX_ENTRIES], + &gir->guid_info, sizeof(ib_guid_info_t)); + +_out: + cl_plock_release(&p_osm->lock); + + return ret; +} + #define UNPACK_FUNC(name,x) \ static int unpack_##name##x(char *p, uint##x##_t *val_ptr) \ { \ @@ -1107,6 +1219,36 @@ int osm_sa_db_file_load(osm_opensm_t * p_osm) if (load_infr(p_osm, &i_rec, &rep_addr)) rereg_clients = 1; + } else if (!strncmp(p, "GUIDInfo Record:", 16)) { + ib_guidinfo_record_t gi_rec; + ib_net64_t base_guid; + + p_mgrp = NULL; + memset(&gi_rec, 0, sizeof(gi_rec)); + + PARSE_AHEAD(p, net64, " base_guid=0x", &base_guid); + PARSE_AHEAD(p, net16, " lid=0x", &gi_rec.lid); + PARSE_AHEAD(p, net8, " block_num=0x", + &gi_rec.block_num); + PARSE_AHEAD(p, net64, " guid0=0x", + &gi_rec.guid_info.guid[0]); + PARSE_AHEAD(p, net64, " guid1=0x", + &gi_rec.guid_info.guid[1]); + PARSE_AHEAD(p, net64, " guid2=0x", + &gi_rec.guid_info.guid[2]); + PARSE_AHEAD(p, net64, " guid3=0x", + &gi_rec.guid_info.guid[3]); + PARSE_AHEAD(p, net64, " guid4=0x", + &gi_rec.guid_info.guid[4]); + PARSE_AHEAD(p, net64, " guid5=0x", + &gi_rec.guid_info.guid[5]); + PARSE_AHEAD(p, net64, " guid6=0x", + &gi_rec.guid_info.guid[6]); + PARSE_AHEAD(p, net64, " guid7=0x", + &gi_rec.guid_info.guid[7]); + + if (load_guidinfo(p_osm, base_guid, &gi_rec)) + rereg_clients = 1; } } diff --git a/opensm/osm_sa_guidinfo_record.c b/opensm/osm_sa_guidinfo_record.c index 039040b..08f4b2c 100644 --- a/opensm/osm_sa_guidinfo_record.c +++ b/opensm/osm_sa_guidinfo_record.c @@ -449,8 +449,10 @@ static void del_guidinfo(IN osm_sa_t *sa, IN osm_madw_t *p_madw, } } - if (dirty) + if (dirty) { guidinfo_set(sa, p_port, block_num); + sa->dirty = TRUE; + } memcpy(&p_rcvd_rec->guid_info, &((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES]), @@ -634,8 +636,10 @@ add_alias_guid: } } - if (dirty) + if (dirty) { guidinfo_set(sa, p_port, block_num); + sa->dirty = TRUE; + } memcpy(&p_rcvd_rec->guid_info, &((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES]),