Blame osmtest/main.c

Packit 13e616
/*
Packit 13e616
 * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
Packit 13e616
 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
Packit 13e616
 * Copyright (c) 2009 HNR Consulting. All rights reserved.
Packit 13e616
 *
Packit 13e616
 * This software is available to you under a choice of one of two
Packit 13e616
 * licenses.  You may choose to be licensed under the terms of the GNU
Packit 13e616
 * General Public License (GPL) Version 2, available from the file
Packit 13e616
 * COPYING in the main directory of this source tree, or the
Packit 13e616
 * OpenIB.org BSD license below:
Packit 13e616
 *
Packit 13e616
 *     Redistribution and use in source and binary forms, with or
Packit 13e616
 *     without modification, are permitted provided that the following
Packit 13e616
 *     conditions are met:
Packit 13e616
 *
Packit 13e616
 *      - Redistributions of source code must retain the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer.
Packit 13e616
 *
Packit 13e616
 *      - Redistributions in binary form must reproduce the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer in the documentation and/or other materials
Packit 13e616
 *        provided with the distribution.
Packit 13e616
 *
Packit 13e616
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit 13e616
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit 13e616
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Packit 13e616
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
Packit 13e616
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
Packit 13e616
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit 13e616
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit 13e616
 * SOFTWARE.
Packit 13e616
 *
Packit 13e616
 */
Packit 13e616
Packit 13e616
/*
Packit 13e616
 * Abstract:
Packit 13e616
 * 	Command line interface for osmtest.
Packit 13e616
 *
Packit 13e616
 */
Packit 13e616
Packit 13e616
#include <stdio.h>
Packit 13e616
#include <stdlib.h>
Packit 13e616
#include <getopt.h>
Packit 13e616
#include <complib/cl_debug.h>
Packit 13e616
#include "osmtest.h"
Packit 13e616
Packit 13e616
/********************************************************************
Packit 13e616
       D E F I N E    G L O B A L    V A R I A B L E S
Packit 13e616
*********************************************************************/
Packit 13e616
Packit 13e616
/*
Packit 13e616
	This is the global osmtest object.
Packit 13e616
	One osmtest object is required per subnet.
Packit 13e616
	Future versions could support multiple subents by
Packit 13e616
	instantiating more than one osmtest object.
Packit 13e616
*/
Packit 13e616
#define MAX_LOCAL_IBPORTS 64
Packit 13e616
#define OSMT_DEFAULT_RETRY_COUNT 3
Packit 13e616
#define OSMT_DEFAULT_TRANS_TIMEOUT_MILLISEC 1000
Packit 13e616
#define OSMT_DEFAULT_TRAP_WAIT_TIMEOUT_SEC 10
Packit 13e616
#define INVALID_GUID (0xFFFFFFFFFFFFFFFFULL)
Packit 13e616
Packit 13e616
static boolean_t osmt_is_debug(void)
Packit 13e616
{
Packit 13e616
#if defined( _DEBUG_ )
Packit 13e616
	return TRUE;
Packit 13e616
#else
Packit 13e616
	return FALSE;
Packit 13e616
#endif				/* defined( _DEBUG_ ) */
Packit 13e616
}
Packit 13e616
Packit 13e616
static void show_usage(void)
Packit 13e616
{
Packit 13e616
	printf
Packit 13e616
	    ("\n------- osmtest - Usage and options ----------------------\n");
Packit 13e616
	printf("Usage:	  osmtest [options]\n");
Packit 13e616
	printf("Options:\n");
Packit 13e616
	printf("-f <c|a|v|s|e|f|m|q|t>\n"
Packit 13e616
	       "--flow <c|a|v|s|e|f|m|q|t>\n"
Packit 13e616
	       "          This option directs osmtest to run a specific flow:\n"
Packit 13e616
	       "          FLOW  DESCRIPTION\n"
Packit 13e616
	       "          c = create an inventory file with all nodes, ports and paths\n"
Packit 13e616
	       "          a = run all validation tests (expecting an input inventory)\n"
Packit 13e616
	       "          v = only validate the given inventory file\n"
Packit 13e616
	       "          s = run service registration, deregistration, and lease test\n"
Packit 13e616
	       "          e = run event forwarding test\n"
Packit 13e616
	       "          f = flood the SA with queries according to the stress mode\n"
Packit 13e616
	       "          m = multicast flow\n"
Packit 13e616
	       "          q = QoS info: dump VLArb and SLtoVL tables\n"
Packit 13e616
	       "          t = run trap 64/65 flow (this flow requires running of external tool)\n"
Packit 13e616
	       "          (default is all flows except QoS)\n\n");
Packit 13e616
Packit 13e616
	printf("-w <trap_wait_time>\n"
Packit 13e616
	       "--wait <trap_wait_time>\n"
Packit 13e616
	       "          This option specifies the wait time for trap 64/65 in seconds\n"
Packit 13e616
	       "          It is used only when running -f t - the trap 64/65 flow\n"
Packit 13e616
	       "          (default to 10 sec)\n\n");
Packit 13e616
	printf("-d <number>\n"
Packit 13e616
	       "--debug <number>\n"
Packit 13e616
	       "          This option specifies a debug option\n"
Packit 13e616
	       "          These options are not normally needed\n"
Packit 13e616
	       "          The number following -d selects the debug\n"
Packit 13e616
	       "          option to enable as follows:\n"
Packit 13e616
	       "          OPT   Description\n"
Packit 13e616
	       "          ---    -----------------\n"
Packit 13e616
	       "          -d0  - Unused.\n"
Packit 13e616
	       "          -d1  - Do not scan/compare path records.\n"
Packit 13e616
	       "          -d2  - Force log flushing after each log message.\n"
Packit 13e616
	       "          -d4  - Use full world path record queries.\n"
Packit 13e616
	       "          Without -d, no debug options are enabled\n\n");
Packit 13e616
	printf("-m <LID in hex>\n"
Packit 13e616
	       "--max_lid <LID in hex>\n"
Packit 13e616
	       "          This option specifies the maximal LID number to be searched\n"
Packit 13e616
	       "          for during inventory file build (default to 100)\n\n");
Packit 13e616
	printf("-g <GUID in hex>\n"
Packit 13e616
	       "--guid <GUID in hex>\n"
Packit 13e616
	       "          This option specifies the local port GUID value\n"
Packit 13e616
	       "          with which osmtest should bind.  osmtest may be\n"
Packit 13e616
	       "          bound to 1 port at a time\n\n");
Packit 13e616
	printf("-p \n"
Packit 13e616
	       "--port\n"
Packit 13e616
	       "          This option displays a menu of possible local port GUID values\n"
Packit 13e616
	       "          with which osmtest could bind\n\n");
Packit 13e616
	printf("-h\n"
Packit 13e616
	       "--help\n" "          Display this usage info then exit\n\n");
Packit 13e616
	printf("-i <filename>\n"
Packit 13e616
	       "--inventory <filename>\n"
Packit 13e616
	       "          This option specifies the name of the inventory file\n"
Packit 13e616
	       "          Normally, osmtest expects to find an inventory file,\n"
Packit 13e616
	       "          which osmtest uses to validate real-time information\n"
Packit 13e616
	       "          received from the SA during testing\n"
Packit 13e616
	       "          If -i is not specified, osmtest defaults to the file\n"
Packit 13e616
	       "          'osmtest.dat'\n"
Packit 13e616
	       "          See -c option for related information\n\n");
Packit 13e616
	printf("-s\n"
Packit 13e616
	       "--stress\n"
Packit 13e616
	       "          This option runs the specified stress test instead\n"
Packit 13e616
	       "          of the normal test suite\n"
Packit 13e616
	       "          Stress test options are as follows:\n"
Packit 13e616
	       "          OPT    Description\n"
Packit 13e616
	       "          ---    -----------------\n"
Packit 13e616
	       "          -s1  - Single-MAD (RMPP) response SA queries\n"
Packit 13e616
	       "          -s2  - Multi-MAD (RMPP) response SA queries\n"
Packit 13e616
	       "          -s3  - Multi-MAD (RMPP) Path Record SA queries\n"
Packit 13e616
	       "          -s4  - Single-MAD (non RMPP) get Path Record SA queries\n"
Packit 13e616
	       "          Without -s, stress testing is not performed\n\n");
Packit 13e616
	printf("-G\n"
Packit 13e616
	       "--grh\n"
Packit 13e616
	       "          sends all SA queries with GRH with exception of\n"
Packit 13e616
	       "	  GetMulti MultiPathRecord\n\n");
Packit 13e616
	printf("-M\n"
Packit 13e616
	       "--Multicast_Mode\n"
Packit 13e616
	       "          This option specify length of Multicast test:\n"
Packit 13e616
	       "          OPT    Description\n"
Packit 13e616
	       "          ---    -----------------\n"
Packit 13e616
	       "          -M1  - Short Multicast Flow (default) - single mode\n"
Packit 13e616
	       "          -M2  - Short Multicast Flow - multiple mode\n"
Packit 13e616
	       "          -M3  - Long Multicast Flow - single mode\n"
Packit 13e616
	       "          -M4  - Long Multicast Flow - multiple mode\n"
Packit 13e616
	       " Single mode - Osmtest is tested alone, with no other\n"
Packit 13e616
	       "   apps that interact with OpenSM MC\n"
Packit 13e616
	       " Multiple mode - Could be run with other apps using MC with\n"
Packit 13e616
	       "   OpenSM."
Packit 13e616
	       " Without -M, default flow testing is performed\n\n");
Packit 13e616
Packit 13e616
	printf("-t <milliseconds>\n"
Packit 13e616
	       "          This option specifies the time in milliseconds\n"
Packit 13e616
	       "          used for transaction timeouts\n"
Packit 13e616
	       "          Specifying -t 0 disables timeouts\n"
Packit 13e616
	       "          Without -t, osmtest defaults to a timeout value of\n"
Packit 13e616
	       "          1 second\n\n");
Packit 13e616
	printf("-l\n"
Packit 13e616
	       "--log_file\n"
Packit 13e616
	       "          This option defines the log to be the given file\n"
Packit 13e616
	       "          By default the log goes to stdout\n\n");
Packit 13e616
	printf("-v\n"
Packit 13e616
	       "          This option increases the log verbosity level\n"
Packit 13e616
	       "          The -v option may be specified multiple times\n"
Packit 13e616
	       "          to further increase the verbosity level\n"
Packit 13e616
	       "          See the -vf option for more information about.\n"
Packit 13e616
	       "          log verbosity\n\n");
Packit 13e616
	printf("-V\n"
Packit 13e616
	       "          This option sets the maximum verbosity level and\n"
Packit 13e616
	       "          forces log flushing\n"
Packit 13e616
	       "          The -V is equivalent to '-vf 0xFF -d 2'\n"
Packit 13e616
	       "          See the -vf option for more information about.\n"
Packit 13e616
	       "          log verbosity\n\n");
Packit 13e616
	printf("-vf <flags>\n"
Packit 13e616
	       "          This option sets the log verbosity level\n"
Packit 13e616
	       "          A flags field must follow the -vf option\n"
Packit 13e616
	       "          A bit set/clear in the flags enables/disables a\n"
Packit 13e616
	       "          specific log level as follows:\n"
Packit 13e616
	       "          BIT    LOG LEVEL ENABLED\n"
Packit 13e616
	       "          ----   -----------------\n"
Packit 13e616
	       "          0x01 - ERROR (error messages)\n"
Packit 13e616
	       "          0x02 - INFO (basic messages, low volume)\n"
Packit 13e616
	       "          0x04 - VERBOSE (interesting stuff, moderate volume)\n"
Packit 13e616
	       "          0x08 - DEBUG (diagnostic, high volume)\n"
Packit 13e616
	       "          0x10 - FUNCS (function entry/exit, very high volume)\n"
Packit 13e616
	       "          0x20 - FRAMES (dumps all SMP and GMP frames)\n"
Packit 13e616
	       "          0x40 - currently unused\n"
Packit 13e616
	       "          0x80 - currently unused\n"
Packit 13e616
	       "          Without -vf, osmtest defaults to ERROR + INFO (0x3)\n"
Packit 13e616
	       "          Specifying -vf 0 disables all messages\n"
Packit 13e616
	       "          Specifying -vf 0xFF enables all messages (see -V)\n"
Packit 13e616
	       "          High verbosity levels may require increasing\n"
Packit 13e616
	       "          the transaction timeout with the -t option\n\n");
Packit 13e616
}
Packit 13e616
Packit 13e616
static void print_all_guids(IN osmtest_t * p_osmt)
Packit 13e616
{
Packit 13e616
	ib_api_status_t status;
Packit 13e616
	uint32_t num_ports = MAX_LOCAL_IBPORTS;
Packit 13e616
	ib_port_attr_t attr_array[MAX_LOCAL_IBPORTS] = { {0} };
Packit 13e616
	uint32_t i;
Packit 13e616
Packit 13e616
	/*
Packit 13e616
	   Call the transport layer for a list of local port
Packit 13e616
	   GUID values.
Packit 13e616
	 */
Packit 13e616
	status =
Packit 13e616
	    osm_vendor_get_all_port_attr(p_osmt->p_vendor, attr_array,
Packit 13e616
					 &num_ports);
Packit 13e616
	if (status != IB_SUCCESS) {
Packit 13e616
		printf("\nError from osm_vendor_get_all_port_attr (%x)\n",
Packit 13e616
		       status);
Packit 13e616
		return;
Packit 13e616
	}
Packit 13e616
Packit 13e616
	printf("\nListing GUIDs:\n");
Packit 13e616
	for (i = 0; i < num_ports; i++)
Packit 13e616
		printf("Port %i: 0x%" PRIx64 "\n", i,
Packit 13e616
		       cl_hton64(attr_array[i].port_guid));
Packit 13e616
}
Packit 13e616
Packit 13e616
static ib_net64_t get_port_guid(IN osmtest_t * p_osmt, uint64_t port_guid)
Packit 13e616
{
Packit 13e616
	ib_api_status_t status;
Packit 13e616
	uint32_t num_ports = MAX_LOCAL_IBPORTS;
Packit 13e616
	ib_port_attr_t attr_array[MAX_LOCAL_IBPORTS] = { {0} };
Packit 13e616
	uint32_t i;
Packit 13e616
Packit 13e616
	/*
Packit 13e616
	   Call the transport layer for a list of local port
Packit 13e616
	   GUID values.
Packit 13e616
	 */
Packit 13e616
/* "local ports" is(?) phys, shouldn't this exclude port 0 then ? */
Packit 13e616
	status =
Packit 13e616
	    osm_vendor_get_all_port_attr(p_osmt->p_vendor, attr_array,
Packit 13e616
					 &num_ports);
Packit 13e616
	if (status != IB_SUCCESS) {
Packit 13e616
		printf("\nError from osm_vendor_get_all_port_attr (%x)\n",
Packit 13e616
		       status);
Packit 13e616
		return (0);
Packit 13e616
	}
Packit 13e616
Packit 13e616
	if (num_ports == 1) {
Packit 13e616
		printf("using default guid 0x%" PRIx64 "\n",
Packit 13e616
		       cl_hton64(attr_array[0].port_guid));
Packit 13e616
		return (attr_array[0].port_guid);
Packit 13e616
	}
Packit 13e616
Packit 13e616
	for (i = 0; i < num_ports; i++) {
Packit 13e616
		if (attr_array[i].port_guid == port_guid ||
Packit 13e616
		    (!port_guid && attr_array[i].link_state > IB_LINK_DOWN))
Packit 13e616
			return attr_array[i].port_guid;
Packit 13e616
	}
Packit 13e616
Packit 13e616
	return 0;
Packit 13e616
}
Packit 13e616
Packit 13e616
int main(int argc, char *argv[])
Packit 13e616
{
Packit 13e616
	static osmtest_t osm_test;
Packit 13e616
	osmtest_opt_t opt = { 0 };
Packit 13e616
	ib_net64_t guid = 0;
Packit 13e616
	uint16_t max_lid = 100;
Packit 13e616
	ib_api_status_t status;
Packit 13e616
	uint32_t log_flags = OSM_LOG_ERROR | OSM_LOG_INFO;
Packit 13e616
	int32_t vendor_debug = 0;
Packit 13e616
	char flow_name[64];
Packit 13e616
	int next_option;
Packit 13e616
	const char *const short_option = "f:l:m:M:d:g:s:t:i:pcvGVh";
Packit 13e616
Packit 13e616
	/*
Packit 13e616
	 * In the array below, the 2nd parameter specified the number
Packit 13e616
	 * of arguments as follows:
Packit 13e616
	 * 0: no arguments
Packit 13e616
	 * 1: argument
Packit 13e616
	 * 2: optional
Packit 13e616
	 */
Packit 13e616
	const struct option long_option[] = {
Packit 13e616
		{"create", 0, NULL, 'c'},
Packit 13e616
		{"debug", 1, NULL, 'd'},
Packit 13e616
		{"flow", 1, NULL, 'f'},
Packit 13e616
		{"wait", 1, NULL, 'w'},
Packit 13e616
		{"inventory", 1, NULL, 'i'},
Packit 13e616
		{"max_lid", 1, NULL, 'm'},
Packit 13e616
		{"guid", 1, NULL, 'g'},
Packit 13e616
		{"port", 0, NULL, 'p'},
Packit 13e616
		{"help", 0, NULL, 'h'},
Packit 13e616
		{"stress", 1, NULL, 's'},
Packit 13e616
		{"grh", 0, NULL, 'G'},
Packit 13e616
		{"Multicast_Mode", 1, NULL, 'M'},
Packit 13e616
		{"timeout", 1, NULL, 't'},
Packit 13e616
		{"verbose", 0, NULL, 'v'},
Packit 13e616
		{"log_file", 1, NULL, 'l'},
Packit 13e616
		{"vf", 1, NULL, 'x'},
Packit 13e616
		{"V", 0, NULL, 'V'},
Packit 13e616
Packit 13e616
		{NULL, 0, NULL, 0}	/* Required at end of array */
Packit 13e616
	};
Packit 13e616
Packit 13e616
	/* Make sure that the opensm, complib and osmtest were compiled using
Packit 13e616
	   same modes (debug/free) */
Packit 13e616
	if (osm_is_debug() != cl_is_debug() || osm_is_debug() != osmt_is_debug()
Packit 13e616
	    || osmt_is_debug() != cl_is_debug()) {
Packit 13e616
		fprintf(stderr,
Packit 13e616
			"-E- OpenSM, Complib and OsmTest were compiled using different modes\n");
Packit 13e616
		fprintf(stderr,
Packit 13e616
			"-E- OpenSM debug:%d Complib debug:%d OsmTest debug:%d \n",
Packit 13e616
			osm_is_debug(), cl_is_debug(), osmt_is_debug());
Packit 13e616
		exit(1);
Packit 13e616
	}
Packit 13e616
Packit 13e616
	opt.transaction_timeout = OSMT_DEFAULT_TRANS_TIMEOUT_MILLISEC;
Packit 13e616
	opt.wait_time = OSMT_DEFAULT_TRAP_WAIT_TIMEOUT_SEC;
Packit 13e616
	opt.retry_count = OSMT_DEFAULT_RETRY_COUNT;
Packit 13e616
	opt.force_log_flush = FALSE;
Packit 13e616
	opt.stress = 0;
Packit 13e616
	opt.log_file = NULL;
Packit 13e616
	opt.create = FALSE;
Packit 13e616
	opt.mmode = 1;
Packit 13e616
	opt.ignore_path_records = FALSE;	/*  Do path Records too */
Packit 13e616
	opt.full_world_path_recs = FALSE;
Packit 13e616
	opt.flow = OSMT_FLOW_ALL;	/*  run all validation tests */
Packit 13e616
	opt.with_grh = FALSE;
Packit 13e616
	strcpy(flow_name, "All Validations");
Packit 13e616
	strcpy(opt.file_name, "osmtest.dat");
Packit 13e616
Packit 13e616
	printf("\nCommand Line Arguments\n");
Packit 13e616
	do {
Packit 13e616
		next_option = getopt_long_only(argc, argv, short_option,
Packit 13e616
					       long_option, NULL);
Packit 13e616
		switch (next_option) {
Packit 13e616
		case 'c':
Packit 13e616
			/*
Packit 13e616
			 * Create the inventory file.
Packit 13e616
			 */
Packit 13e616
			opt.create = TRUE;
Packit 13e616
			printf("\tCreating inventory file\n");
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 'i':
Packit 13e616
			/*
Packit 13e616
			 * Specifies inventory file name.
Packit 13e616
			 */
Packit 13e616
			if (strlen(optarg) > OSMTEST_FILE_PATH_MAX)
Packit 13e616
				printf
Packit 13e616
				    ("\nError: path name too long (ignored)\n");
Packit 13e616
			else
Packit 13e616
				strcpy(opt.file_name, optarg);
Packit 13e616
Packit 13e616
			printf("\tFile = %s\n", opt.file_name);
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 'f':
Packit 13e616
			/*
Packit 13e616
			 * Specifies Flow.
Packit 13e616
			 */
Packit 13e616
			if (strlen(optarg) > OSMTEST_FILE_PATH_MAX)
Packit 13e616
				printf
Packit 13e616
				    ("\nError: path name too long (ignored)\n");
Packit 13e616
			else
Packit 13e616
				strcpy(flow_name, optarg);
Packit 13e616
Packit 13e616
			if (!strcmp("c", optarg)) {
Packit 13e616
				strcpy(flow_name, "Create Inventory");
Packit 13e616
				opt.flow = OSMT_FLOW_CREATE_INVENTORY;
Packit 13e616
			} else if (!strcmp("v", optarg)) {
Packit 13e616
				strcpy(flow_name, "Validate Inventory");
Packit 13e616
				opt.flow = OSMT_FLOW_VALIDATE_INVENTORY;
Packit 13e616
			} else if (!strcmp("s", optarg)) {
Packit 13e616
				strcpy(flow_name, "Services Registration");
Packit 13e616
				opt.flow = OSMT_FLOW_SERVICE_REGISTRATION;
Packit 13e616
			} else if (!strcmp("e", optarg)) {
Packit 13e616
				strcpy(flow_name, "Event Forwarding");
Packit 13e616
				opt.flow = OSMT_FLOW_EVENT_FORWARDING;
Packit 13e616
			} else if (!strcmp("f", optarg)) {
Packit 13e616
				strcpy(flow_name, "Stress SA");
Packit 13e616
				opt.flow = OSMT_FLOW_STRESS_SA;
Packit 13e616
			} else if (!strcmp("m", optarg)) {
Packit 13e616
				strcpy(flow_name, "Multicast");
Packit 13e616
				opt.flow = OSMT_FLOW_MULTICAST;
Packit 13e616
			} else if (!strcmp("q", optarg)) {
Packit 13e616
				strcpy(flow_name, "QoS: VLArb and SLtoVL");
Packit 13e616
				opt.flow = OSMT_FLOW_QOS;
Packit 13e616
			} else if (!strcmp("t", optarg)) {
Packit 13e616
				strcpy(flow_name, "Trap 64/65");
Packit 13e616
				opt.flow = OSMT_FLOW_TRAP;
Packit 13e616
			} else if (!strcmp("a", optarg)) {
Packit 13e616
				strcpy(flow_name, "All Validations");
Packit 13e616
				opt.flow = OSMT_FLOW_ALL;
Packit 13e616
			} else {
Packit 13e616
				printf("\nError: unknown flow %s\n", flow_name);
Packit 13e616
				exit(2);
Packit 13e616
			}
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 'w':
Packit 13e616
			/*
Packit 13e616
			 * Specifies trap 64/65 wait time
Packit 13e616
			 */
Packit 13e616
			CL_ASSERT(strtol(optarg, NULL, 0) < 0x100);
Packit 13e616
			opt.wait_time = (uint8_t) strtol(optarg, NULL, 0);
Packit 13e616
			printf("\tTrap 64/65 wait time = %d\n", opt.wait_time);
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 'm':
Packit 13e616
			/*
Packit 13e616
			 * Specifies the max LID to search for during exploration.
Packit 13e616
			 */
Packit 13e616
			max_lid = (uint16_t) atoi(optarg);
Packit 13e616
			printf("\tMAX-LID %u\n", max_lid);
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 'g':
Packit 13e616
			/*
Packit 13e616
			 * Specifies port guid with which to bind.
Packit 13e616
			 */
Packit 13e616
			guid = cl_hton64(strtoull(optarg, NULL, 16));
Packit 13e616
			printf(" Guid <0x%" PRIx64 ">\n", cl_hton64(guid));
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 'p':
Packit 13e616
			/*
Packit 13e616
			 * Display current port guids
Packit 13e616
			 */
Packit 13e616
			guid = INVALID_GUID;
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 't':
Packit 13e616
			/*
Packit 13e616
			 * Specifies transaction timeout.
Packit 13e616
			 */
Packit 13e616
			opt.transaction_timeout = strtol(optarg, NULL, 0);
Packit 13e616
			printf("\tTransaction timeout = %d\n",
Packit 13e616
			       opt.transaction_timeout);
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 'l':
Packit 13e616
			opt.log_file = optarg;
Packit 13e616
			printf("\tLog File: %s\n", opt.log_file);
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 'v':
Packit 13e616
			/*
Packit 13e616
			 * Increases log verbosity.
Packit 13e616
			 */
Packit 13e616
			log_flags = (log_flags << 1) | 1;
Packit 13e616
			printf("\tVerbose option -v (log flags = 0x%X)\n",
Packit 13e616
			       log_flags);
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 'V':
Packit 13e616
			/*
Packit 13e616
			 * Specifies maximum log verbosity.
Packit 13e616
			 */
Packit 13e616
			log_flags = 0xFFFFFFFF;
Packit 13e616
			opt.force_log_flush = TRUE;
Packit 13e616
			printf("\tEnabling maximum log verbosity\n");
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 's':
Packit 13e616
			/*
Packit 13e616
			 * Perform stress test.
Packit 13e616
			 */
Packit 13e616
			opt.stress = strtol(optarg, NULL, 0);
Packit 13e616
			printf("\tStress test enabled: ");
Packit 13e616
			switch (opt.stress) {
Packit 13e616
			case 1:
Packit 13e616
				printf("Small SA queries\n");
Packit 13e616
				break;
Packit 13e616
			case 2:
Packit 13e616
				printf("Large SA queries\n");
Packit 13e616
				break;
Packit 13e616
			case 3:
Packit 13e616
				printf("Large Path Record SA queries\n");
Packit 13e616
				break;
Packit 13e616
			case 4:
Packit 13e616
				printf("SA Get Path Record queries\n");
Packit 13e616
				break;
Packit 13e616
			default:
Packit 13e616
				printf("Unknown value %u (ignored)\n",
Packit 13e616
				       opt.stress);
Packit 13e616
				opt.stress = 0;
Packit 13e616
				break;
Packit 13e616
			}
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 'M':
Packit 13e616
			/*
Packit 13e616
			 * Perform multicast test.
Packit 13e616
			 */
Packit 13e616
			opt.mmode = strtol(optarg, NULL, 0);
Packit 13e616
			printf("\tMulticast test enabled: ");
Packit 13e616
			switch (opt.mmode) {
Packit 13e616
			case 1:
Packit 13e616
				printf
Packit 13e616
				    ("Short MC Flow - single mode (default)\n");
Packit 13e616
				break;
Packit 13e616
			case 2:
Packit 13e616
				printf("Short MC Flow - multiple mode\n");
Packit 13e616
				break;
Packit 13e616
			case 3:
Packit 13e616
				printf("Long MC Flow - single mode\n");
Packit 13e616
				break;
Packit 13e616
			case 4:
Packit 13e616
				printf("Long MC Flow - multiple mode\n");
Packit 13e616
				break;
Packit 13e616
			default:
Packit 13e616
				printf("Unknown value %u (ignored)\n",
Packit 13e616
				       opt.stress);
Packit 13e616
				opt.mmode = 0;
Packit 13e616
				break;
Packit 13e616
			}
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 'd':
Packit 13e616
			/*
Packit 13e616
			 * Debug Options
Packit 13e616
			 */
Packit 13e616
			printf("\tDebug Option: ");
Packit 13e616
			switch (strtol(optarg, NULL, 0)) {
Packit 13e616
			case 1:
Packit 13e616
				printf("Ignore Path Records\n");
Packit 13e616
				opt.ignore_path_records = TRUE;
Packit 13e616
				break;
Packit 13e616
			case 2:
Packit 13e616
				printf("Force Log Flush\n");
Packit 13e616
				opt.force_log_flush = TRUE;
Packit 13e616
				break;
Packit 13e616
			case 4:
Packit 13e616
				printf("Use Full World Path Record Queries\n");
Packit 13e616
				opt.full_world_path_recs = TRUE;
Packit 13e616
				break;
Packit 13e616
			case 3:
Packit 13e616
				/* Used to be memory tracking */
Packit 13e616
			default:
Packit 13e616
				printf("Unknown value %ld (ignored)\n",
Packit 13e616
				       strtol(optarg, NULL, 0));
Packit 13e616
				break;
Packit 13e616
			}
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		case 'h':
Packit 13e616
			show_usage();
Packit 13e616
			return 0;
Packit 13e616
Packit 13e616
		case 'x':
Packit 13e616
			log_flags = strtol(optarg, NULL, 0);
Packit 13e616
			printf("\tVerbose option -vf (log flags = 0x%X)\n",
Packit 13e616
			       log_flags);
Packit 13e616
			break;
Packit 13e616
		case 'G':
Packit 13e616
			opt.with_grh = TRUE;
Packit 13e616
			break;
Packit 13e616
		case -1:
Packit 13e616
			printf("Done with args\n");
Packit 13e616
			break;
Packit 13e616
Packit 13e616
		default:	/* something wrong */
Packit 13e616
			abort();
Packit 13e616
		}
Packit 13e616
Packit 13e616
	}
Packit 13e616
	while (next_option != -1);
Packit 13e616
Packit 13e616
	printf("\tFlow = %s\n", flow_name);
Packit 13e616
Packit 13e616
	if (vendor_debug)
Packit 13e616
		osm_vendor_set_debug(osm_test.p_vendor, vendor_debug);
Packit 13e616
Packit 13e616
	if (complib_init_v2() != CL_SUCCESS) {
Packit 13e616
		printf("\ncomplib_init_v2 failed\n");
Packit 13e616
		status = IB_ERROR;
Packit 13e616
		goto Exit;
Packit 13e616
	}
Packit 13e616
Packit 13e616
	status = osmtest_init(&osm_test, &opt, (osm_log_level_t) log_flags);
Packit 13e616
	if (status != IB_SUCCESS) {
Packit 13e616
		printf("\nError from osmtest_init: %s\n",
Packit 13e616
		       ib_get_err_str(status));
Packit 13e616
		goto Exit;
Packit 13e616
	}
Packit 13e616
	if (cl_hton64(guid) == cl_hton64(INVALID_GUID)) {
Packit 13e616
		print_all_guids(&osm_test);
Packit 13e616
		complib_exit();
Packit 13e616
		return (status);
Packit 13e616
	}
Packit 13e616
Packit 13e616
	/*
Packit 13e616
	   If the user didn't specify a GUID on the command line,
Packit 13e616
	   then get a port GUID value with which to bind.
Packit 13e616
	 */
Packit 13e616
	if (guid == 0 && !(guid = get_port_guid(&osm_test, guid))) {
Packit 13e616
		printf("\nError: port guid 0x%" PRIx64 " not found\n", guid);
Packit 13e616
		goto Exit;
Packit 13e616
	}
Packit 13e616
Packit 13e616
	/*
Packit 13e616
	 * Guid may be zero going into this function if the user
Packit 13e616
	 * hasn't specified a binding port on the command line.
Packit 13e616
	 */
Packit 13e616
	status = osmtest_bind(&osm_test, max_lid, guid);
Packit 13e616
	if (status != IB_SUCCESS)
Packit 13e616
		exit(status);
Packit 13e616
Packit 13e616
	status = osmtest_run(&osm_test);
Packit 13e616
	if (status != IB_SUCCESS) {
Packit 13e616
		printf("OSMTEST: TEST \"%s\" FAIL\n", flow_name);
Packit 13e616
	} else {
Packit 13e616
		printf("OSMTEST: TEST \"%s\" PASS\n", flow_name);
Packit 13e616
	}
Packit 13e616
	osmtest_destroy(&osm_test);
Packit 13e616
Packit 13e616
	complib_exit();
Packit 13e616
Packit 13e616
Exit:
Packit 13e616
	return (status);
Packit 13e616
}