[openib-general] [PATCH] OpenSM/osm_console.c: Add resweep and status commands
Hal Rosenstock
halr at voltaire.com
Mon Jan 8 05:47:48 PST 2007
OpenSM/osm_console.c: Add resweep and status commands
Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
Signed-off-by: Hal Rosenstock <halr at voltaire.com>
diff --git a/osm/opensm/osm_console.c b/osm/opensm/osm_console.c
index 8d770aa..8157f90 100644
--- a/osm/opensm/osm_console.c
+++ b/osm/opensm/osm_console.c
@@ -84,6 +84,20 @@ static void help_quit(FILE *out, int det
static void help_loglevel(FILE *out, int detail)
{
fprintf(out, "loglevel [<log-level>]\n");
+ if (detail) {
+ fprintf(out, " log-level is OR'ed from the following\n");
+ fprintf(out, " OSM_LOG_NONE 0x%02X\n", OSM_LOG_NONE);
+ fprintf(out, " OSM_LOG_ERROR 0x%02X\n", OSM_LOG_ERROR);
+ fprintf(out, " OSM_LOG_INFO 0x%02X\n", OSM_LOG_INFO);
+ fprintf(out, " OSM_LOG_VERBOSE 0x%02X\n", OSM_LOG_VERBOSE);
+ fprintf(out, " OSM_LOG_DEBUG 0x%02X\n", OSM_LOG_DEBUG);
+ fprintf(out, " OSM_LOG_FUNCS 0x%02X\n", OSM_LOG_FUNCS);
+ fprintf(out, " OSM_LOG_FRAMES 0x%02X\n", OSM_LOG_FRAMES);
+ fprintf(out, " OSM_LOG_ROUTING 0x%02X\n", OSM_LOG_ROUTING);
+ fprintf(out, " OSM_LOG_SYS 0x%02X\n", OSM_LOG_SYS);
+ fprintf(out, "\n");
+ fprintf(out, " OSM_LOG_DEFAULT_LEVEL 0x%02X\n", OSM_LOG_DEFAULT_LEVEL);
+ }
}
static void help_priority(FILE *out, int detail)
@@ -91,6 +105,16 @@ static void help_priority(FILE *out, int
fprintf(out, "priority [<sm-priority>]\n");
}
+static void help_resweep(FILE *out, int detail)
+{
+ fprintf(out, "resweep [heavy|light]\n");
+}
+
+static void help_status(FILE *out, int detail)
+{
+ fprintf(out, "status\n");
+}
+
/* more help routines go here */
static void help_parse(char **p_last, osm_opensm_t *p_osm, FILE *out)
@@ -164,6 +188,99 @@ static void priority_parse(char **p_last
}
}
+static char *sm_state_str(int state)
+{
+ switch (state)
+ {
+ case IB_SMINFO_STATE_INIT:
+ return ("Init");
+ case IB_SMINFO_STATE_DISCOVERING:
+ return ("Discovering");
+ case IB_SMINFO_STATE_STANDBY:
+ return ("Standby");
+ case IB_SMINFO_STATE_NOTACTIVE:
+ return ("Not Active");
+ case IB_SMINFO_STATE_MASTER:
+ return ("Master");
+ }
+ return ("UNKNOWN");
+}
+
+static char *sa_state_str(osm_sa_state_t state)
+{
+ switch (state)
+ {
+ case OSM_SA_STATE_INIT:
+ return ("Init");
+ case OSM_SA_STATE_READY:
+ return ("Ready");
+ }
+ return ("UNKNOWN");
+}
+
+static void status_parse(char **p_last, osm_opensm_t *p_osm, FILE *out)
+{
+ fprintf(out, " SM State : %s\n",
+ sm_state_str(p_osm->subn.sm_state));
+ fprintf(out, " SA State : %s\n",
+ sa_state_str(p_osm->sa.state));
+ fprintf(out, " MAD stats\n"
+ " ---------\n"
+ " QP0 MADS outstanding : %d\n"
+ " QP0 MADS outstanding (on wire) : %d\n"
+ " QP0 MADS rcvd : %d\n"
+ " QP0 MADS sent : %d\n"
+ " QP0 unicasts sent : %d\n"
+ " QP1 MADS outstanding : %d\n"
+ " QP1 MADS rcvd : %d\n"
+ " QP1 MADS sent : %d\n"
+ ,
+ p_osm->stats.qp0_mads_outstanding,
+ p_osm->stats.qp0_mads_outstanding_on_wire,
+ p_osm->stats.qp0_mads_rcvd,
+ p_osm->stats.qp0_mads_sent,
+ p_osm->stats.qp0_unicasts_sent,
+ p_osm->stats.qp1_mads_outstanding,
+ p_osm->stats.qp1_mads_rcvd,
+ p_osm->stats.qp1_mads_sent
+ );
+ fprintf(out, " Subnet flags\n"
+ " ------------\n"
+ " Ignore existing lfts : %d\n"
+ " Subnet Init errors : %d\n"
+ " In sweep hop 0 : %d\n"
+ " Moved to master state : %d\n"
+ " First time master sweep : %d\n"
+ " Coming out of standby : %d\n"
+ ,
+ p_osm->subn.ignore_existing_lfts,
+ p_osm->subn.subnet_initialization_error,
+ p_osm->subn.in_sweep_hop_0,
+ p_osm->subn.moved_to_master_state,
+ p_osm->subn.first_time_master_sweep,
+ p_osm->subn.coming_out_of_standby
+ );
+ fprintf(out, "\n");
+}
+
+static void resweep_parse(char **p_last, osm_opensm_t *p_osm, FILE *out)
+{
+ char *p_cmd;
+
+ p_cmd = next_token(p_last);
+ if (!p_cmd ||
+ (strcmp(p_cmd, "heavy") != 0 &&
+ strcmp(p_cmd, "light") != 0)) {
+ fprintf(out, "Invalid resweep command\n");
+ help_resweep(out, 1);
+ } else {
+ if (strcmp(p_cmd, "heavy") == 0) {
+ p_osm->subn.force_immediate_heavy_sweep = TRUE;
+ }
+ osm_opensm_sweep( p_osm );
+ }
+}
+
/* This is public to be able to close it on exit */
void osm_console_close_socket(osm_opensm_t *p_osm)
{
@@ -190,6 +307,8 @@ static const struct command console_cmds
{ "quit", &help_quit, &quit_parse},
{ "loglevel", &help_loglevel, &loglevel_parse},
{ "priority", &help_priority, &priority_parse},
+ { "resweep", &help_resweep, &resweep_parse},
+ { "status", &help_status, &status_parse},
{ NULL, NULL, NULL} /* end of array */
};
More information about the general
mailing list