From patchwork Wed Jul 11 18:48:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 1184881 X-Patchwork-Delegate: alexne@voltaire.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 6091ADF25A for ; Wed, 11 Jul 2012 18:48:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755108Ab2GKSsQ (ORCPT ); Wed, 11 Jul 2012 14:48:16 -0400 Received: from nspiron-1.llnl.gov ([128.115.41.81]:62585 "EHLO nspiron-1.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752101Ab2GKSsQ (ORCPT ); Wed, 11 Jul 2012 14:48:16 -0400 X-Attachments: Received: from eris.llnl.gov (HELO trebuchet.chaos) ([128.115.7.7]) by nspiron-1.llnl.gov with SMTP; 11 Jul 2012 11:48:15 -0700 Date: Wed, 11 Jul 2012 11:48:14 -0700 From: Ira Weiny To: Alex Netes Cc: "linux-rdma@vger.kernel.org" Subject: [PATCH V2 07/10] opensm/console; add port option to perfmgr print_counters Message-Id: <20120711114814.a6646c91bdfd014d362418cc@llnl.gov> X-Mailer: Sylpheed 3.2.0 (GTK+ 2.18.9; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Changes since V1: My rebase got cross wired for the console help message. Fix this. Signed-off-by: Ira Weiny --- include/opensm/osm_perfmgr.h | 3 ++- include/opensm/osm_perfmgr_db.h | 6 ++++-- opensm/osm_console.c | 13 ++++++++++--- opensm/osm_perfmgr.c | 7 ++++--- opensm/osm_perfmgr_db.c | 33 +++++++++++++++++++++++---------- 5 files changed, 43 insertions(+), 19 deletions(-) diff --git a/include/opensm/osm_perfmgr.h b/include/opensm/osm_perfmgr.h index d9a3102..68cf7f3 100644 --- a/include/opensm/osm_perfmgr.h +++ b/include/opensm/osm_perfmgr.h @@ -245,7 +245,8 @@ inline static unsigned osm_perfmgr_delete_inactive(osm_perfmgr_t * pm) void osm_perfmgr_clear_counters(osm_perfmgr_t * p_perfmgr); void osm_perfmgr_dump_counters(osm_perfmgr_t * p_perfmgr, perfmgr_db_dump_t dump_type); -void osm_perfmgr_print_counters(osm_perfmgr_t *pm, char *nodename, FILE *fp); +void osm_perfmgr_print_counters(osm_perfmgr_t *pm, char *nodename, FILE *fp, + char *port); ib_api_status_t osm_perfmgr_bind(osm_perfmgr_t * p_perfmgr, ib_net64_t port_guid); diff --git a/include/opensm/osm_perfmgr_db.h b/include/opensm/osm_perfmgr_db.h index d1e9049..d6c8feb 100644 --- a/include/opensm/osm_perfmgr_db.h +++ b/include/opensm/osm_perfmgr_db.h @@ -191,8 +191,10 @@ void perfmgr_db_clear_counters(perfmgr_db_t * db); perfmgr_db_err_t perfmgr_db_dump(perfmgr_db_t * db, char *file, perfmgr_db_dump_t dump_type); void perfmgr_db_print_all(perfmgr_db_t * db, FILE *fp); -void perfmgr_db_print_by_name(perfmgr_db_t * db, char *nodename, FILE *fp); -void perfmgr_db_print_by_guid(perfmgr_db_t * db, uint64_t guid, FILE *fp); +void perfmgr_db_print_by_name(perfmgr_db_t * db, char *nodename, FILE *fp, + char *port); +void perfmgr_db_print_by_guid(perfmgr_db_t * db, uint64_t guid, FILE *fp, + char *port); /** ========================================================================= * helper functions to fill in the various db objects from wire objects diff --git a/opensm/osm_console.c b/opensm/osm_console.c index 8e09b69..b6d7d31 100644 --- a/opensm/osm_console.c +++ b/opensm/osm_console.c @@ -252,8 +252,8 @@ static void help_perfmgr(FILE * out, int detail) fprintf(out, " [dump_counters [mach]] -- dump the counters (optionally in [mach]ine readable format)\n"); fprintf(out, - " [print_counters []] -- print the internal counters\n" - " Optionaly limit output by name or guid\n"); + " [print_counters [][:]] -- print the internal counters\n" + " Optionaly limit output by name, guid, or port\n"); fprintf(out, " [dump_redir []] -- dump the redirection table\n"); fprintf(out, @@ -1468,8 +1468,15 @@ static void perfmgr_parse(char **p_last, osm_opensm_t * p_osm, FILE * out) } else if (strcmp(p_cmd, "print_counters") == 0) { char *port = NULL; p_cmd = name_token(p_last); + if (p_cmd) { + port = strchr(p_cmd, ':'); + if (port) { + *port = '\0'; + port++; + } + } osm_perfmgr_print_counters(&p_osm->perfmgr, p_cmd, - out); + out, port); } else if (strcmp(p_cmd, "dump_redir") == 0) { p_cmd = name_token(p_last); dump_redir(p_osm, p_cmd, out); diff --git a/opensm/osm_perfmgr.c b/opensm/osm_perfmgr.c index 840af39..456c163 100644 --- a/opensm/osm_perfmgr.c +++ b/opensm/osm_perfmgr.c @@ -1436,15 +1436,16 @@ void osm_perfmgr_dump_counters(osm_perfmgr_t * pm, perfmgr_db_dump_t dump_type) /******************************************************************* * Print the DB information to the fp specified *******************************************************************/ -void osm_perfmgr_print_counters(osm_perfmgr_t * pm, char *nodename, FILE * fp) +void osm_perfmgr_print_counters(osm_perfmgr_t * pm, char *nodename, FILE * fp, + char *port) { if (nodename) { char *end = NULL; uint64_t guid = strtoull(nodename, &end, 0); if (nodename + strlen(nodename) != end) - perfmgr_db_print_by_name(pm->db, nodename, fp); + perfmgr_db_print_by_name(pm->db, nodename, fp, port); else - perfmgr_db_print_by_guid(pm->db, guid, fp); + perfmgr_db_print_by_guid(pm->db, guid, fp, port); } else perfmgr_db_print_all(pm->db, fp); } diff --git a/opensm/osm_perfmgr_db.c b/opensm/osm_perfmgr_db.c index 6c8ef9a..6f9c1ab 100644 --- a/opensm/osm_perfmgr_db.c +++ b/opensm/osm_perfmgr_db.c @@ -702,12 +702,23 @@ static void dump_node_mr(db_node_t * node, FILE * fp) /********************************************************************** * Output a human readable output of the port counters **********************************************************************/ -static void dump_node_hr(db_node_t * node, FILE * fp) -{ - int i = 0; - +static void dump_node_hr(db_node_t * node, FILE * fp, char *port) +{ + int i = (node->esp0) ? 0 : 1; + int num_ports = node->num_ports; + + if (port) { + char *end = NULL; + int p = strtoul(port, &end, 0); + if (port + strlen(port) == end && p >= i && p < num_ports) { + i = p; + num_ports = p+1; + } else { + fprintf(fp, "Warning: \"%s\" is not a valid port\n", port); + } + } fprintf(fp, "\n"); - for (i = (node->esp0) ? 0 : 1; i < node->num_ports; i++) { + for (/* set above */; i < num_ports; i++) { char *since = ctime(&node->ports[i].last_reset); if (!node->ports[i].valid) @@ -782,7 +793,7 @@ static void db_dump(cl_map_item_t * const p_map_item, void *context) break; case PERFMGR_EVENT_DB_DUMP_HR: default: - dump_node_hr(node, fp); + dump_node_hr(node, fp, NULL); break; } } @@ -800,7 +811,7 @@ perfmgr_db_print_all(perfmgr_db_t * db, FILE *fp) item = cl_qmap_head(&db->pc_data); while (item != cl_qmap_end(&db->pc_data)) { node = (db_node_t *)item; - dump_node_hr(node, fp); + dump_node_hr(node, fp, NULL); item = cl_qmap_next(item); } cl_plock_release(&db->lock); @@ -810,7 +821,8 @@ perfmgr_db_print_all(perfmgr_db_t * db, FILE *fp) * print node data to fp **********************************************************************/ void -perfmgr_db_print_by_name(perfmgr_db_t * db, char *nodename, FILE *fp) +perfmgr_db_print_by_name(perfmgr_db_t * db, char *nodename, FILE *fp, + char *port) { cl_map_item_t *item; db_node_t *node; @@ -822,7 +834,7 @@ perfmgr_db_print_by_name(perfmgr_db_t * db, char *nodename, FILE *fp) while (item != cl_qmap_end(&db->pc_data)) { node = (db_node_t *)item; if (strcmp(node->node_name, nodename) == 0) { - dump_node_hr(node, fp); + dump_node_hr(node, fp, port); goto done; } item = cl_qmap_next(item); @@ -837,7 +849,8 @@ done: * print node data to fp **********************************************************************/ void -perfmgr_db_print_by_guid(perfmgr_db_t * db, uint64_t nodeguid, FILE *fp) +perfmgr_db_print_by_guid(perfmgr_db_t * db, uint64_t nodeguid, FILE *fp, + char *port) { cl_map_item_t *node; @@ -845,7 +858,7 @@ perfmgr_db_print_by_guid(perfmgr_db_t * db, uint64_t nodeguid, FILE *fp) node = cl_qmap_get(&db->pc_data, nodeguid); if (node != cl_qmap_end(&db->pc_data)) - dump_node_hr((db_node_t *)node, fp); + dump_node_hr((db_node_t *)node, fp, port); else fprintf(fp, "Node 0x%" PRIx64 " not found...\n", nodeguid);