From patchwork Thu Jun 17 17:30:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 106717 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5HHWEvN022811 for ; Thu, 17 Jun 2010 17:32:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760508Ab0FQRcN (ORCPT ); Thu, 17 Jun 2010 13:32:13 -0400 Received: from qmta09.westchester.pa.mail.comcast.net ([76.96.62.96]:58146 "EHLO qmta09.westchester.pa.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760498Ab0FQRcM (ORCPT ); Thu, 17 Jun 2010 13:32:12 -0400 Received: from omta08.westchester.pa.mail.comcast.net ([76.96.62.12]) by qmta09.westchester.pa.mail.comcast.net with comcast id WyaG1e0030Fqzac595YCZ5; Thu, 17 Jun 2010 17:32:12 +0000 Received: from hal.comcast.net ([75.69.247.31]) by omta08.westchester.pa.mail.comcast.net with comcast id X5YB1e00C0hNrtn3U5YBpr; Thu, 17 Jun 2010 17:32:12 +0000 Received: from hal.comcast.net (localhost.localdomain [127.0.0.1]) by hal.comcast.net (8.14.3/8.14.3) with ESMTP id o5HHVHc9017288; Thu, 17 Jun 2010 13:31:22 -0400 Received: (from hnrose@localhost) by hal.comcast.net (8.14.3/8.14.3/Submit) id o5HHUiHo017253; Thu, 17 Jun 2010 13:30:44 -0400 Date: Thu, 17 Jun 2010 13:30:44 -0400 From: Hal Rosenstock To: sashak@voltaire.com Cc: linux-rdma@vger.kernel.org Subject: [PATCHv4 2/2][RESEND] opensm/osm_console.c: Add dump and clear redir perfmgr command support Message-ID: <20100617173044.GB17245@comcast.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) 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 (demeter.kernel.org [140.211.167.41]); Thu, 17 Jun 2010 17:32:53 +0000 (UTC) diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c index 49b0ae0..764235a 100644 --- a/opensm/opensm/osm_console.c +++ b/opensm/opensm/osm_console.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2005-2009 Voltaire, Inc. All rights reserved. - * Copyright (c) 2009 HNR Consulting. All rights reserved. + * Copyright (c) 2009,2010 HNR Consulting. All rights reserved. * Copyright (c) 2010 Mellanox Technologies LTD. All rights reserved. * * This software is available to you under a choice of one of two @@ -232,7 +232,7 @@ static void help_update_desc(FILE *out, int detail) static void help_perfmgr(FILE * out, int detail) { fprintf(out, - "perfmgr [enable|disable|clear_counters|dump_counters|print_counters|sweep_time[seconds]]\n"); + "perfmgr [enable|disable|clear_counters|dump_counters|print_counters|dump_redir|clear_redir|sweep_time[seconds]]\n"); if (detail) { fprintf(out, "perfmgr -- print the performance manager state\n"); @@ -246,6 +246,10 @@ static void help_perfmgr(FILE * out, int detail) " [dump_counters [mach]] -- dump the counters (optionally in [mach]ine readable format)\n"); fprintf(out, " [print_counters ] -- print the counters for the specified node\n"); + fprintf(out, + " [dump_redir []] -- dump the redirection table\n"); + fprintf(out, + " [clear_redir []] -- clear the redirection table\n"); } } #endif /* ENABLE_OSM_PERF_MGR */ @@ -1180,6 +1184,152 @@ static void update_desc_parse(char **p_last, osm_opensm_t * p_osm, FILE * out) } #ifdef ENABLE_OSM_PERF_MGR +static monitored_node_t *find_node_by_name(osm_opensm_t * p_osm, + char *nodename) +{ + cl_map_item_t *item; + monitored_node_t *node; + + item = cl_qmap_head(&p_osm->perfmgr.monitored_map); + while (item != cl_qmap_end(&p_osm->perfmgr.monitored_map)) { + node = (monitored_node_t *)item; + if (strcmp(node->name, nodename) == 0) + return node; + item = cl_qmap_next(item); + } + + return NULL; +} + +static monitored_node_t *find_node_by_guid(osm_opensm_t * p_osm, + uint64_t guid) +{ + cl_map_item_t *node; + + node = cl_qmap_get(&p_osm->perfmgr.monitored_map, guid); + if (node != cl_qmap_end(&p_osm->perfmgr.monitored_map)) + return (monitored_node_t *)node; + + return NULL; +} + +static void dump_redir_entry(monitored_node_t *p_mon_node, FILE * out) +{ + int port, redir; + + /* only display monitored nodes with redirection info */ + redir = 0; + for (port = (p_mon_node->esp0) ? 0 : 1; + port < p_mon_node->num_ports; port++) { + if (p_mon_node->port[port].redirection) { + if (!redir) { + fprintf(out, " Node GUID ESP0 Name\n"); + fprintf(out, " --------- ---- ----\n"); + fprintf(out, " 0x%" PRIx64 " %d %s\n", + p_mon_node->guid, p_mon_node->esp0, + p_mon_node->name); + fprintf(out, "\n Port Valid LIDs PKey QP PKey Index\n"); + fprintf(out, " ---- ----- ---- ---- -- ----------\n"); + redir = 1; + } + fprintf(out, " %d %d %u->%u 0x%x 0x%x %d\n", + port, p_mon_node->port[port].valid, + cl_ntoh16(p_mon_node->port[port].orig_lid), + cl_ntoh16(p_mon_node->port[port].lid), + cl_ntoh16(p_mon_node->port[port].pkey), + cl_ntoh32(p_mon_node->port[port].qp), + p_mon_node->port[port].pkey_ix); + } + } + if (redir) + fprintf(out, "\n"); +} + +static void dump_redir(osm_opensm_t * p_osm, char *nodename, FILE * out) +{ + monitored_node_t *p_mon_node; + uint64_t guid; + + if (!p_osm->subn.opt.perfmgr_redir) + fprintf(out, "Perfmgr redirection not enabled\n"); + + fprintf(out, "\nRedirection Table\n"); + fprintf(out, "-----------------\n"); + cl_plock_acquire(&p_osm->lock); + if (nodename) { + guid = strtoull(nodename, NULL, 0); + if (guid == 0 && errno) + p_mon_node = find_node_by_name(p_osm, nodename); + else + p_mon_node = find_node_by_guid(p_osm, guid); + if (p_mon_node) + dump_redir_entry(p_mon_node, out); + else { + if (guid == 0 && errno) + fprintf(out, "Node %s not found...\n", nodename); + else + fprintf(out, "Node 0x%" PRIx64 " not found...\n", guid); + } + } else { + p_mon_node = (monitored_node_t *) cl_qmap_head(&p_osm->perfmgr.monitored_map); + while (p_mon_node != (monitored_node_t *) cl_qmap_end(&p_osm->perfmgr.monitored_map)) { + dump_redir_entry(p_mon_node, out); + p_mon_node = (monitored_node_t *) cl_qmap_next((const cl_map_item_t *)p_mon_node); + } + } + cl_plock_release(&p_osm->lock); +} + +static void clear_redir_entry(monitored_node_t *p_mon_node) +{ + int port; + ib_net16_t orig_lid; + + for (port = (p_mon_node->esp0) ? 0 : 1; + port < p_mon_node->num_ports; port++) { + if (p_mon_node->port[port].redirection) { + orig_lid = p_mon_node->port[port].orig_lid; + memset(&p_mon_node->port[port], 0, + sizeof(monitored_port_t)); + p_mon_node->port[port].valid = TRUE; + p_mon_node->port[port].orig_lid = orig_lid; + } + } +} + +static void clear_redir(osm_opensm_t * p_osm, char *nodename, FILE * out) +{ + monitored_node_t *p_mon_node; + uint64_t guid; + + if (!p_osm->subn.opt.perfmgr_redir) + fprintf(out, "Perfmgr redirection not enabled\n"); + + cl_plock_acquire(&p_osm->lock); + if (nodename) { + guid = strtoull(nodename, NULL, 0); + if (guid == 0 && errno) + p_mon_node = find_node_by_name(p_osm, nodename); + else + p_mon_node = find_node_by_guid(p_osm, guid); + if (p_mon_node) + clear_redir_entry(p_mon_node); + else { + if (guid == 0 && errno) + fprintf(out, "Node %s not found...\n", nodename); + else + fprintf(out, "Node 0x%" PRIx64 " not found...\n", guid); + } + } else { + p_mon_node = (monitored_node_t *) cl_qmap_head(&p_osm->perfmgr.monitored_map); + while (p_mon_node != (monitored_node_t *) cl_qmap_end(&p_osm->perfmgr.monitored_map)) { + clear_redir_entry(p_mon_node); + p_mon_node = (monitored_node_t *) cl_qmap_next((const cl_map_item_t *)p_mon_node); + } + } + cl_plock_release(&p_osm->lock); +} + static void perfmgr_parse(char **p_last, osm_opensm_t * p_osm, FILE * out) { char *p_cmd; @@ -1212,6 +1362,12 @@ static void perfmgr_parse(char **p_last, osm_opensm_t * p_osm, FILE * out) fprintf(out, "print_counters requires a node name or node GUID to be specified\n"); } + } else if (strcmp(p_cmd, "dump_redir") == 0) { + p_cmd = name_token(p_last); + dump_redir(p_osm, p_cmd, out); + } else if (strcmp(p_cmd, "clear_redir") == 0) { + p_cmd = name_token(p_last); + clear_redir(p_osm, p_cmd, out); } else if (strcmp(p_cmd, "sweep_time") == 0) { p_cmd = next_token(p_last); if (p_cmd) {