|
Packit Service |
3470d1 |
/* A query application for OPA SA records similar to opasaquery
|
|
Packit Service |
3470d1 |
* bundled in IFS distribution
|
|
Packit Service |
3470d1 |
*
|
|
Packit Service |
3470d1 |
*/
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
// core API
|
|
Packit Service |
3470d1 |
#include <opamgt/opamgt.h>
|
|
Packit Service |
3470d1 |
// extensions for SA queries
|
|
Packit Service |
3470d1 |
#include <opamgt/opamgt_sa.h>
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
#include <getopt.h>
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
void Usage()
|
|
Packit Service |
3470d1 |
{
|
|
Packit Service |
3470d1 |
fprintf(stdout, "Usage: saquery [-v] [-h hfi] [-p port] [-t ms] [-b oob_host] [-l lid] -o type \n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " or\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " saquery --help\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " --help - produce full help text\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, "\n");
|
|
Packit Service |
3470d1 |
fprintf(stderr, " -v/--verbose - verbose output\n");
|
|
Packit Service |
3470d1 |
fprintf(stderr, " -h/--hfi hfi - hfi, numbered 1..n, 0= -p port will be a system wide\n");
|
|
Packit Service |
3470d1 |
fprintf(stderr, " port num (default is 0)\n");
|
|
Packit Service |
3470d1 |
fprintf(stderr, " -p/--port port - port, numbered 1..n, 0=1st active (default is 1st\n");
|
|
Packit Service |
3470d1 |
fprintf(stderr, " active)\n");
|
|
Packit Service |
3470d1 |
fprintf(stderr, " -t/--timeout - timeout in ms\n");
|
|
Packit Service |
3470d1 |
fprintf(stderr, " -l/--lid - filter query results for specific lid\n");
|
|
Packit Service |
3470d1 |
fprintf(stderr, " -g/--guid - filter query results for specific guid\n");
|
|
Packit Service |
3470d1 |
fprintf(stderr, " -b oob_host - perform out of band query. For this example, oob_host\n");
|
|
Packit Service |
3470d1 |
fprintf(stderr, " should have format hostname[:port] or a.b.c.d[:port]\n");
|
|
Packit Service |
3470d1 |
fprintf(stderr, " -o/--output type - output type\n");
|
|
Packit Service |
3470d1 |
fprintf(stderr, " -x local_gid - local gid for out-of-band queryies that need a local gid\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, "type: (default is node)\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " classportinfo - classportinfo of the SA\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " systemguid - list of system image guids\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " nodeguid - list of node guids\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " portguid - list of port guids\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " lid - list of lids\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " desc - list of node descriptions/names\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " path - list of path records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " node - list of node records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " portinfo - list of port info records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " sminfo - list of SM info records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " swinfo - list of switch info records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " link - list of link records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " scsc - list of SC to SC mapping table records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " slsc - list of SL to SC mapping table records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " scsl - list of SC to SL mapping table records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " scvlt - list of SC to VLt table records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " scvlr - list of SC to VLr table records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " scvlnt - list of SC to VLnt table records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " vlarb - list of VL arbitration table records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " pkey - list of P-Key table records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " service - list of service records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " mcmember - list of multicast member records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " inform - list of inform info records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " linfdb - list of switch linear FDB records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " mcfdb - list of switch multicast FDB records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " trace - list of trace records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " vfinfo - list of vFabrics\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " fabricinfo - summary of fabric devices\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " quarantine - list of quarantined nodes\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " conginfo - list of Congestion Info Records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " swcongset - list of Switch Congestion Settings\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " swportcong - list of Switch Port Congestion Settings\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " hficongset - list of HFI Congestion Settings\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " hficongcon - list of HFI Congesting Control Settings\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " bfrctrl - list of buffer control tables\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout ," cableinfo - list of Cable Info records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout ," portgroup - list of AR Port Group records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout ," portgroupfdb - list of AR Port Group FWD records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout ," dglist - list of Device Group Names\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout ," dgmember - list of Device Group records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout ," dtree - list of Device Tree records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout ," swcost - list of switch cost records\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, "\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, "Usage examples:\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " saquery -o desc\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " saquery -o portinfo\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " saquery -o sminfo\n");
|
|
Packit Service |
3470d1 |
fprintf(stdout, " saquery -o pkey\n");
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
exit(0);
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
// command line options
|
|
Packit Service |
3470d1 |
struct option options[] = {
|
|
Packit Service |
3470d1 |
{ "verbose", required_argument, NULL, 'v' },
|
|
Packit Service |
3470d1 |
{ "hfi", required_argument, NULL, 'h' },
|
|
Packit Service |
3470d1 |
{ "port", required_argument, NULL, 'p' },
|
|
Packit Service |
3470d1 |
{ "timeout", required_argument, NULL, 't' },
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
// input types (small subset)
|
|
Packit Service |
3470d1 |
{ "lid", required_argument, NULL, 'l' },
|
|
Packit Service |
3470d1 |
{ "guid", required_argument, NULL, 'g' },
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
// output type
|
|
Packit Service |
3470d1 |
{ "output", required_argument, NULL, 'o' },
|
|
Packit Service |
3470d1 |
{ "help", no_argument, NULL, '$' }, // use an invalid option character
|
|
Packit Service |
3470d1 |
{ 0 }
|
|
Packit Service |
3470d1 |
};
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
int main(int argc, char ** argv)
|
|
Packit Service |
3470d1 |
{
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
OMGT_STATUS_T status = OMGT_STATUS_SUCCESS;
|
|
Packit Service |
3470d1 |
int exitcode = 0;
|
|
Packit Service |
3470d1 |
struct omgt_port * port = NULL;
|
|
Packit Service |
3470d1 |
int num_records = 0;
|
|
Packit Service |
3470d1 |
int c, index, debug = 0;
|
|
Packit Service |
3470d1 |
int sa_service_state = OMGT_SERVICE_STATE_UNKNOWN;
|
|
Packit Service |
3470d1 |
void *sa_records = NULL;
|
|
Packit Service |
3470d1 |
omgt_sa_selector_t selector;
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
char * type = "node";
|
|
Packit Service |
3470d1 |
int hfi_num = 1;
|
|
Packit Service |
3470d1 |
int port_num = 1;
|
|
Packit Service |
3470d1 |
int ms_timeout = OMGT_DEF_TIMEOUT_MS;
|
|
Packit Service |
3470d1 |
uint32_t lid = 0;
|
|
Packit Service |
3470d1 |
uint64_t guid = 0;
|
|
Packit Service |
3470d1 |
uint64_t local_prefix = 0;
|
|
Packit Service |
3470d1 |
char *tmp = NULL, *gid = NULL;
|
|
Packit Service |
3470d1 |
uint64_t local_guid = 0;
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
char * oob_addr = NULL;
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
//default to requesting all records
|
|
Packit Service |
3470d1 |
selector.InputType = InputTypeNoInput;
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
while (-1 != (c = getopt_long(argc, argv, "h:p:t:o:l:b:g:x:v$", options, &index))){
|
|
Packit Service |
3470d1 |
switch (c)
|
|
Packit Service |
3470d1 |
{
|
|
Packit Service |
3470d1 |
case '$':
|
|
Packit Service |
3470d1 |
Usage();
|
|
Packit Service |
3470d1 |
break;
|
|
Packit Service |
3470d1 |
case 'h': // hfi to issue query from
|
|
Packit Service |
3470d1 |
hfi_num = strtol(optarg, NULL, 0);
|
|
Packit Service |
3470d1 |
break;
|
|
Packit Service |
3470d1 |
case 'p': // port to issue query from
|
|
Packit Service |
3470d1 |
port_num = strtol(optarg, NULL, 0);
|
|
Packit Service |
3470d1 |
break;
|
|
Packit Service |
3470d1 |
case 't':
|
|
Packit Service |
3470d1 |
ms_timeout = strtol(optarg, NULL, 0);
|
|
Packit Service |
3470d1 |
break;
|
|
Packit Service |
3470d1 |
case 'o': // select output record desired
|
|
Packit Service |
3470d1 |
type = optarg;
|
|
Packit Service |
3470d1 |
break;
|
|
Packit Service |
3470d1 |
case 'l':
|
|
Packit Service |
3470d1 |
selector.InputType = InputTypeLid;
|
|
Packit Service |
3470d1 |
lid = strtoul(optarg, NULL, 0);
|
|
Packit Service |
3470d1 |
break;
|
|
Packit Service |
3470d1 |
case 'g':
|
|
Packit Service |
3470d1 |
selector.InputType = InputTypePortGuid;
|
|
Packit Service |
3470d1 |
guid = strtoul(optarg, NULL, 0);
|
|
Packit Service |
3470d1 |
break;
|
|
Packit Service |
3470d1 |
case 'x':
|
|
Packit Service |
3470d1 |
gid = optarg;
|
|
Packit Service |
3470d1 |
if (gid[0] == '0' && gid[1] == 'x') gid += 2;
|
|
Packit Service |
3470d1 |
local_prefix = strtoul(gid, &tmp, 16);
|
|
Packit Service |
3470d1 |
local_guid = strtoul(++tmp, NULL, 16);
|
|
Packit Service |
3470d1 |
break;
|
|
Packit Service |
3470d1 |
case 'b':
|
|
Packit Service |
3470d1 |
oob_addr = optarg;
|
|
Packit Service |
3470d1 |
break;
|
|
Packit Service |
3470d1 |
case 'v':
|
|
Packit Service |
3470d1 |
debug = 1;
|
|
Packit Service |
3470d1 |
break;
|
|
Packit Service |
3470d1 |
default:
|
|
Packit Service |
3470d1 |
fprintf(stderr, "opasaquery: Invalid option -%c\n", c);
|
|
Packit Service |
3470d1 |
Usage();
|
|
Packit Service |
3470d1 |
break;
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
// create a session
|
|
Packit Service |
3470d1 |
struct omgt_params session_params = {
|
|
Packit Service |
3470d1 |
.debug_file = debug ? stderr : NULL,
|
|
Packit Service |
3470d1 |
.error_file = stderr
|
|
Packit Service |
3470d1 |
};
|
|
Packit Service |
3470d1 |
if (oob_addr){
|
|
Packit Service |
3470d1 |
tmp = strchr(oob_addr, ':');
|
|
Packit Service |
3470d1 |
if (tmp) *tmp = 0;
|
|
Packit Service |
3470d1 |
struct omgt_oob_input oob_input = {
|
|
Packit Service |
3470d1 |
/* host can be specified by name or as either IPv4 of IPv6
|
|
Packit Service |
3470d1 |
* but this example only considers IPv4 for simplicity*/
|
|
Packit Service |
3470d1 |
.host = oob_addr,
|
|
Packit Service |
3470d1 |
.port = (tmp ? strtol(++tmp, NULL, 0) : 3245)
|
|
Packit Service |
3470d1 |
};
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
status = omgt_oob_connect(&port, &oob_input, &session_params);
|
|
Packit Service |
3470d1 |
} else {
|
|
Packit Service |
3470d1 |
status = omgt_open_port_by_num(&port, hfi_num, port_num, &session_params);
|
|
Packit Service |
3470d1 |
(void)omgt_port_get_port_guid(port, &local_guid);
|
|
Packit Service |
3470d1 |
(void)omgt_port_get_port_prefix(port, &local_prefix);
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
/* (Optional) Check if the SA Service is Operational
|
|
Packit Service |
3470d1 |
* All SA queries will do an initial sa service state check if not already
|
|
Packit Service |
3470d1 |
* operational, so this is more of a verbose sanity check.
|
|
Packit Service |
3470d1 |
*/
|
|
Packit Service |
3470d1 |
if (status == OMGT_STATUS_SUCCESS) {
|
|
Packit Service |
3470d1 |
status = omgt_port_get_sa_service_state(port, &sa_service_state, OMGT_REFRESH_SERVICE_ANY_STATE);
|
|
Packit Service |
3470d1 |
if (status == OMGT_STATUS_SUCCESS) {
|
|
Packit Service |
3470d1 |
if (sa_service_state != OMGT_SERVICE_STATE_OPERATIONAL) {
|
|
Packit Service |
3470d1 |
fprintf(stderr, "failed to connect, SA service state is Not Operational: %s (%d)\n",
|
|
Packit Service |
3470d1 |
omgt_service_state_totext(sa_service_state), sa_service_state);
|
|
Packit Service |
3470d1 |
exitcode = 1;
|
|
Packit Service |
3470d1 |
goto fail2;
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
} else {
|
|
Packit Service |
3470d1 |
fprintf(stderr, "failed to get and refresh SA service state: %s (%u)\n",
|
|
Packit Service |
3470d1 |
omgt_status_totext(status), status);
|
|
Packit Service |
3470d1 |
exitcode = 1;
|
|
Packit Service |
3470d1 |
goto fail2;
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
if (OMGT_STATUS_SUCCESS != status){
|
|
Packit Service |
3470d1 |
fprintf(stderr, "failed to open port: %s (%u)\n",
|
|
Packit Service |
3470d1 |
omgt_status_totext(status), status);
|
|
Packit Service |
3470d1 |
exitcode=1;
|
|
Packit Service |
3470d1 |
goto fail1;
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
/* Set timeout for SA operation */
|
|
Packit Service |
3470d1 |
omgt_set_timeout(port, ms_timeout);
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
/* Perform the requested operation.
|
|
Packit Service |
3470d1 |
* Some records are are not always supported,
|
|
Packit Service |
3470d1 |
* and in those cases an additional omgt_sa_get_classportinfo
|
|
Packit Service |
3470d1 |
* call must be performed to determine the management capabilities
|
|
Packit Service |
3470d1 |
*/
|
|
Packit Service |
3470d1 |
if (!strcmp(type, "node")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types:
|
|
Packit Service |
3470d1 |
* NoInput, Lid, PortGuid, NodeGuid, SystemImageGuid, NodeType, NodeDesc
|
|
Packit Service |
3470d1 |
*/
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypePortGuid) selector.InputValue.NodeRecord.NodeGUID = guid;
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.NodeRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_node_records(port, &selector, &num_records, (STL_NODE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "portinfo")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.PortInfoRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_portinfo_records(port, &selector, &num_records, (STL_PORTINFO_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "systemguid")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types:
|
|
Packit Service |
3470d1 |
* NoInput, NodeType, SystemImageGuid, NodeGuid, PortGuid, Lid, NodeDesc
|
|
Packit Service |
3470d1 |
*/
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypePortGuid) selector.InputValue.NodeRecord.NodeGUID = guid;
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.NodeRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_sysimageguid_records(port, &selector, &num_records, (uint64_t **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "nodeguid")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types:
|
|
Packit Service |
3470d1 |
* NoInput, NodeType, SystemImageGuid, NodeGuid, PortGuid, Lid, NodeDesc
|
|
Packit Service |
3470d1 |
*/
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypePortGuid) selector.InputValue.NodeRecord.NodeGUID = guid;
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.NodeRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_nodeguid_records(port, &selector, &num_records, (uint64_t **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "portguid")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types:
|
|
Packit Service |
3470d1 |
* NoInput, NodeType, SystemImageGuid, NodeGuid, PortGuid, Lid, NodeDesc
|
|
Packit Service |
3470d1 |
*/
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypePortGuid) selector.InputValue.NodeRecord.NodeGUID = guid;
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.NodeRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_portguid_records(port, &selector, &num_records, (uint64_t **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "classportinfo")){
|
|
Packit Service |
3470d1 |
/*Valid Input Types: NoInput*/
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_classportinfo_records(port, &selector, &num_records, (STL_CLASS_PORT_INFO **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "lid")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types:
|
|
Packit Service |
3470d1 |
* NoInput, NodeType, SystemImageGuid, NodeGuid, PortGuid, Lid, NodeDesc
|
|
Packit Service |
3470d1 |
*/
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypePortGuid) selector.InputValue.NodeRecord.NodeGUID = guid;
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.NodeRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_lid_records(port, &selector, &num_records, (uint32 **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "desc")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types:
|
|
Packit Service |
3470d1 |
* NoInput, NodeType, SystemImageGuid, NodeGuid, PortGuid, Lid, NodeDesc
|
|
Packit Service |
3470d1 |
*/
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypePortGuid) selector.InputValue.NodeRecord.NodeGUID = guid;
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.NodeRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_nodedesc_records(port, &selector, &num_records, (STL_NODE_DESCRIPTION **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "path")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types:
|
|
Packit Service |
3470d1 |
* NoInput, PortGuid, PortGid, PortGuidPair, GidPair, PathRecord,
|
|
Packit Service |
3470d1 |
* Lid, PKey, SL, ServiceId
|
|
Packit Service |
3470d1 |
*
|
|
Packit Service |
3470d1 |
* SourceGid is not treated as an InputType but is ALWAYS required when querying path/trace records
|
|
Packit Service |
3470d1 |
*/
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypePortGuid) {
|
|
Packit Service |
3470d1 |
selector.InputValue.IbPathRecord.PortGuid.DestPortGuid = guid;
|
|
Packit Service |
3470d1 |
selector.InputValue.IbPathRecord.PortGuid.SourcePortGuid = local_guid;
|
|
Packit Service |
3470d1 |
selector.InputValue.IbPathRecord.PortGuid.SharedSubnetPrefix = local_prefix;
|
|
Packit Service |
3470d1 |
} else if (selector.InputType == InputTypeLid) {
|
|
Packit Service |
3470d1 |
selector.InputValue.IbPathRecord.Lid.DLid = lid;
|
|
Packit Service |
3470d1 |
selector.InputValue.IbPathRecord.Lid.SourceGid.Type.Global.InterfaceID = local_guid;
|
|
Packit Service |
3470d1 |
selector.InputValue.IbPathRecord.Lid.SourceGid.Type.Global.SubnetPrefix = local_prefix;
|
|
Packit Service |
3470d1 |
} else {
|
|
Packit Service |
3470d1 |
selector.InputValue.IbPathRecord.SourceGid.Type.Global.InterfaceID = local_guid;
|
|
Packit Service |
3470d1 |
selector.InputValue.IbPathRecord.SourceGid.Type.Global.SubnetPrefix = local_prefix;
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_ib_path_records(port, &selector, &num_records, (IB_PATH_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "sminfo")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput */
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_sminfo_records(port, &selector, &num_records, (STL_SMINFO_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "link")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.LinkRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_link_records(port, &selector, &num_records, (STL_LINK_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "service")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, PortGid */
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_service_records(port, &selector, &num_records, (IB_SERVICE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "mcmember")){
|
|
Packit Service |
3470d1 |
// must check if SA supports these records
|
|
Packit Service |
3470d1 |
omgt_sa_selector_t pre_select = {.InputType = InputTypeNoInput};
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_classportinfo_records(port, &pre_select, &num_records, (STL_CLASS_PORT_INFO **)&sa_records);
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
if (OMGT_STATUS_SUCCESS != status || num_records != 1){
|
|
Packit Service |
3470d1 |
fprintf(stderr, "Failed to determine SA capabilities for mcmember query\n");
|
|
Packit Service |
3470d1 |
goto fail2;
|
|
Packit Service |
3470d1 |
}else if (! (((STL_CLASS_PORT_INFO **)&sa_records)[0]->CapMask & STL_SA_CAPABILITY_MULTICAST_SUPPORT )){
|
|
Packit Service |
3470d1 |
fprintf(stderr, "mcmember records not supported by SA\n");
|
|
Packit Service |
3470d1 |
goto fail2;
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.IbMcMemberRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_ib_mcmember_records(port, &selector, &num_records, (IB_MCMEMBER_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "inform")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, PortGid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.StlInformInfoRecord.SubscriberLID = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_informinfo_records(port, &selector, &num_records, (STL_INFORM_INFO_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "trace")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: PathRecord, PortGuid, GidPair, PortGid */
|
|
Packit Service |
3470d1 |
/* SourceGid is not treated as an InputType but is ALWAYS required when querying path/trace records */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypePortGuid) {
|
|
Packit Service |
3470d1 |
selector.InputValue.TraceRecord.PortGuid.DestPortGuid = guid;
|
|
Packit Service |
3470d1 |
selector.InputValue.TraceRecord.PortGuid.SourcePortGuid = local_guid;
|
|
Packit Service |
3470d1 |
selector.InputValue.TraceRecord.PortGuid.SharedSubnetPrefix = local_prefix;
|
|
Packit Service |
3470d1 |
} else if (selector.InputType == InputTypeLid) {
|
|
Packit Service |
3470d1 |
selector.InputValue.TraceRecord.Lid.DLid = lid;
|
|
Packit Service |
3470d1 |
selector.InputValue.TraceRecord.Lid.SourceGid.Type.Global.InterfaceID = local_guid;
|
|
Packit Service |
3470d1 |
selector.InputValue.TraceRecord.Lid.SourceGid.Type.Global.SubnetPrefix = local_prefix;
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_trace_records(port, &selector, &num_records, (STL_TRACE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "scsc")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.ScScTableRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_scsc_table_records(port, &selector, &num_records, (STL_SC_MAPPING_TABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "slsc")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.SlScTableRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_slsc_table_records(port, &selector, &num_records, (STL_SL2SC_MAPPING_TABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "scsl")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.ScSlTableRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_scsl_table_records(port, &selector, &num_records, (STL_SC2SL_MAPPING_TABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "scvlt")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.ScVlxTableRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_scvlt_table_records(port, &selector, &num_records, (STL_SC2PVL_T_MAPPING_TABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "scvlr")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.ScVlxTableRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_scvlr_table_records(port, &selector, &num_records, (STL_SC2PVL_R_MAPPING_TABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "scvlnt")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.ScVlxTableRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_scvlnt_table_records(port, &selector, &num_records, (STL_SC2PVL_NT_MAPPING_TABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "swinfo")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.SwitchInfoRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_switchinfo_records(port, &selector, &num_records, (STL_SWITCHINFO_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "linfdb")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid*/
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.LinFdbTableRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_lfdb_records(port, &selector, &num_records, (STL_LINEAR_FORWARDING_TABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "mcfdb")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.McFdbTableRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_mcfdb_records(port, &selector, &num_records, (STL_MULTICAST_FORWARDING_TABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "vlarb")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.VlArbTableRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_vlarb_records(port, &selector, &num_records, (STL_VLARBTABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "pkey")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.PKeyTableRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_pkey_table_records(port, &selector, &num_records, (STL_P_KEY_TABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "vfinfo")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types:
|
|
Packit Service |
3470d1 |
* NoInput, PKey, SL, ServiceID, McGid, Index, NodeDesc
|
|
Packit Service |
3470d1 |
*/
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_vfinfo_records(port, &selector, &num_records, (STL_VFINFO_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "fabricinfo")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput */
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_fabric_info_records(port, &selector, &num_records, (STL_FABRICINFO_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "quarantine")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput */
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_quarantinenode_records(port, &selector, &num_records, (STL_QUARANTINED_NODE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "conginfo")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.CongInfoRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_conginfo_records(port, &selector, &num_records, (STL_CONGESTION_INFO_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "swcongset")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.SwCongRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_swcong_records(port, &selector, &num_records, (STL_SWITCH_CONGESTION_SETTING_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "swportcong")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.SwPortCongRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_swportcong_records(port, &selector, &num_records, (STL_SWITCH_PORT_CONGESTION_SETTING_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "hficongset")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.HFICongRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_hficong_records(port, &selector, &num_records, (STL_HFI_CONGESTION_SETTING_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "hficongcon")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.HFICongCtrlRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_hficongctrl_records(port, &selector, &num_records, (STL_HFI_CONGESTION_CONTROL_TABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "bfrctrl")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.BufCtrlTableRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_buffctrl_records(port, &selector, &num_records, (STL_BUFFER_CONTROL_TABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "cableinfo")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.CableInfoRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_cableinfo_records(port, &selector, &num_records, (STL_CABLE_INFO_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "portgroup")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.PortGroupRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_portgroup_records(port, &selector, &num_records, (STL_PORT_GROUP_TABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "portgroupfdb")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.PortGroupFwdRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_portgroupfwd_records(port, &selector, &num_records, (STL_PORT_GROUP_FORWARDING_TABLE_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "dglist")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput */
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_devicegroupname_records(port, &selector, &num_records, (STL_DEVICE_GROUP_NAME_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "dgmember")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid, PortGuid, NodeDesc, DeviceGroup */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.DgGrpMemberRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypePortGuid) selector.InputValue.DgGrpMemberRecord.Guid = guid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_devicegroupmember_records(port, &selector, &num_records, (STL_DEVICE_GROUP_MEMBER_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "dtree")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.DgTreeMemberRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_devicetreemember_records(port, &selector, &num_records, (STL_DEVICE_TREE_MEMBER_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
} else if (!strcmp(type, "swcost")){
|
|
Packit Service |
3470d1 |
/* Valid Input Types: NoInput, Lid */
|
|
Packit Service |
3470d1 |
if (selector.InputType == InputTypeLid) selector.InputValue.SwitchCostRecord.Lid = lid;
|
|
Packit Service |
3470d1 |
status = omgt_sa_get_switchcost_records(port, &selector, &num_records, (STL_SWITCH_COST_RECORD **)&sa_records);
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
if (OMGT_STATUS_SUCCESS != status) {
|
|
Packit Service |
3470d1 |
fprintf(stderr, "failed to execute query. MadStatus=0x%x\n", omgt_get_sa_mad_status(port));
|
|
Packit Service |
3470d1 |
exitcode = 2;
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
/* Not used in oob mode */
|
|
Packit Service |
3470d1 |
if (!oob_addr) {
|
|
Packit Service |
3470d1 |
/* Check if failure was related to SA service state */
|
|
Packit Service |
3470d1 |
status = omgt_port_get_sa_service_state(port, &sa_service_state, OMGT_REFRESH_SERVICE_NOP);
|
|
Packit Service |
3470d1 |
if (status == OMGT_STATUS_SUCCESS) {
|
|
Packit Service |
3470d1 |
if (sa_service_state != OMGT_SERVICE_STATE_OPERATIONAL) {
|
|
Packit Service |
3470d1 |
fprintf(stderr, "SA service state is Not Operational: %s (%d)\n",
|
|
Packit Service |
3470d1 |
omgt_service_state_totext(sa_service_state), sa_service_state);
|
|
Packit Service |
3470d1 |
exitcode = 1;
|
|
Packit Service |
3470d1 |
goto fail2;
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
} else {
|
|
Packit Service |
3470d1 |
fprintf(stderr, "failed to get SA service state: %s (%u)\n",
|
|
Packit Service |
3470d1 |
omgt_status_totext(status), status);
|
|
Packit Service |
3470d1 |
exitcode = 1;
|
|
Packit Service |
3470d1 |
goto fail2;
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
} else {
|
|
Packit Service |
3470d1 |
printf("Number of records returned: %d\n", num_records);
|
|
Packit Service |
3470d1 |
}
|
|
Packit Service |
3470d1 |
|
|
Packit Service |
3470d1 |
fail2:
|
|
Packit Service |
3470d1 |
// free our result buffer...
|
|
Packit Service |
3470d1 |
if (sa_records) omgt_sa_free_records(sa_records);
|
|
Packit Service |
3470d1 |
// ...and close our session
|
|
Packit Service |
3470d1 |
omgt_close_port(port);
|
|
Packit Service |
3470d1 |
fail1:
|
|
Packit Service |
3470d1 |
return exitcode;
|
|
Packit Service |
3470d1 |
}
|