| 1 |
/* |
| 2 |
* Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved. |
| 3 |
* |
| 4 |
* This Software is licensed under one of the following licenses: |
| 5 |
* |
| 6 |
* 1) under the terms of the "Common Public License 1.0" a copy of which is |
| 7 |
* in the file LICENSE.txt in the root directory. The license is also |
| 8 |
* available from the Open Source Initiative, see |
| 9 |
* http://www.opensource.org/licenses/cpl.php. |
| 10 |
* |
| 11 |
* 2) under the terms of the "The BSD License" a copy of which is in the file |
| 12 |
* LICENSE2.txt in the root directory. The license is also available from |
| 13 |
* the Open Source Initiative, see |
| 14 |
* http://www.opensource.org/licenses/bsd-license.php. |
| 15 |
* |
| 16 |
* 3) under the terms of the "GNU General Public License (GPL) Version 2" a |
| 17 |
* copy of which is in the file LICENSE3.txt in the root directory. The |
| 18 |
* license is also available from the Open Source Initiative, see |
| 19 |
* http://www.opensource.org/licenses/gpl-license.php. |
| 20 |
* |
| 21 |
* Licensee has the right to choose one of the above licenses. |
| 22 |
* |
| 23 |
* Redistributions of source code must retain the above copyright |
| 24 |
* notice and one of the license notices. |
| 25 |
* |
| 26 |
* Redistributions in binary form must reproduce both the above copyright |
| 27 |
* notice, one of the license notices in the documentation |
| 28 |
* and/or other materials provided with the distribution. |
| 29 |
*/ |
| 30 |
|
| 31 |
#include "dapl_proto.h" |
| 32 |
|
| 33 |
/* --------------------------------------------------- */ |
| 34 |
void DT_Limit_Cmd_Init(Limit_Cmd_t * cmd) |
| 35 |
{ |
| 36 |
memset((void *)cmd, 0, sizeof(Limit_Cmd_t)); |
| 37 |
cmd->ReliabilityLevel = DAT_QOS_BEST_EFFORT; |
| 38 |
cmd->width = 1; |
| 39 |
cmd->maximum = 1000; |
| 40 |
cmd->port = SERVER_PORT_NUMBER; |
| 41 |
} |
| 42 |
|
| 43 |
/* --------------------------------------------------- */ |
| 44 |
bool |
| 45 |
DT_Limit_Cmd_Parse(Limit_Cmd_t * cmd, |
| 46 |
int my_argc, char **my_argv, mygetopt_t * opts) |
| 47 |
{ |
| 48 |
int c; |
| 49 |
int i; |
| 50 |
|
| 51 |
for (;;) { |
| 52 |
c = DT_mygetopt_r(my_argc, my_argv, "dm:w:D:R:n:", opts); |
| 53 |
if (c == EOF) { |
| 54 |
break; |
| 55 |
} |
| 56 |
switch (c) { |
| 57 |
case 'D': /* device name */ |
| 58 |
{ |
| 59 |
strcpy(cmd->device_name, opts->optarg); |
| 60 |
break; |
| 61 |
} |
| 62 |
case 'R': /* Service Reliability Level */ |
| 63 |
{ |
| 64 |
cmd->ReliabilityLevel = |
| 65 |
DT_ParseQoS(opts->optarg); |
| 66 |
break; |
| 67 |
} |
| 68 |
case 'd': /* print debug messages */ |
| 69 |
{ |
| 70 |
DT_dapltest_debug++; |
| 71 |
cmd->debug = true; |
| 72 |
break; |
| 73 |
} |
| 74 |
case 'm': /* maximum for exhaustion testing */ |
| 75 |
{ |
| 76 |
unsigned int len = |
| 77 |
strspn(opts->optarg, "0123456789"); |
| 78 |
|
| 79 |
if (len == 0 || len != strlen(opts->optarg)) { |
| 80 |
DT_Mdep_printf |
| 81 |
("Syntax Error -m<maximum> option\n"); |
| 82 |
DT_Limit_Cmd_Usage(); |
| 83 |
return (false); |
| 84 |
} |
| 85 |
cmd->maximum = atol(opts->optarg); |
| 86 |
break; |
| 87 |
} |
| 88 |
case 'w': /* width (number of {ia,evd,ep,...} sets) */ |
| 89 |
{ |
| 90 |
unsigned int len = |
| 91 |
strspn(opts->optarg, "0123456789"); |
| 92 |
|
| 93 |
if (len == 0 || len != strlen(opts->optarg)) { |
| 94 |
DT_Mdep_printf |
| 95 |
("Syntax Error -w<width> option\n"); |
| 96 |
DT_Limit_Cmd_Usage(); |
| 97 |
return (false); |
| 98 |
} |
| 99 |
cmd->width = atol(opts->optarg); |
| 100 |
break; |
| 101 |
} |
| 102 |
case 'n': |
| 103 |
{ |
| 104 |
cmd->port = atoi(opts->optarg); |
| 105 |
break; |
| 106 |
} |
| 107 |
case '?': |
| 108 |
default: |
| 109 |
{ |
| 110 |
DT_Mdep_printf |
| 111 |
("Invalid Limit Test Parameter: %c\n", c); |
| 112 |
DT_Limit_Cmd_Usage(); |
| 113 |
return (false); |
| 114 |
} |
| 115 |
} |
| 116 |
} |
| 117 |
if (cmd->device_name[0] == '\0') { |
| 118 |
if (!DT_Mdep_GetDefaultDeviceName(cmd->device_name)) { |
| 119 |
DT_Mdep_printf("can't get default device name\n"); |
| 120 |
DT_Limit_Cmd_Usage(); |
| 121 |
return (false); |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
/* |
| 126 |
* by default: test all limit tests |
| 127 |
* otherwise: parse the remaining limit test arguments |
| 128 |
*/ |
| 129 |
if (opts->optind == my_argc) { |
| 130 |
for (i = 0; i < LIM_NUM_TESTS; i++) { |
| 131 |
cmd->Test_List[i] = 1; |
| 132 |
} |
| 133 |
} else { |
| 134 |
for (i = opts->optind; i < my_argc; i++) { |
| 135 |
|
| 136 |
if (strcmp(my_argv[i], "limit_ia") == 0) { |
| 137 |
cmd->Test_List[LIM_IA] = 1; |
| 138 |
continue; |
| 139 |
} |
| 140 |
if (strcmp(my_argv[i], "limit_pz") == 0) { |
| 141 |
cmd->Test_List[LIM_PZ] = 1; |
| 142 |
continue; |
| 143 |
} |
| 144 |
#ifndef __KDAPLTEST__ |
| 145 |
if (strcmp(my_argv[i], "limit_cno") == 0) { |
| 146 |
cmd->Test_List[LIM_CNO] = 1; |
| 147 |
continue; |
| 148 |
} |
| 149 |
#endif |
| 150 |
if (strcmp(my_argv[i], "limit_evd") == 0) { |
| 151 |
cmd->Test_List[LIM_EVD] = 1; |
| 152 |
continue; |
| 153 |
} |
| 154 |
if (strcmp(my_argv[i], "limit_ep") == 0) { |
| 155 |
cmd->Test_List[LIM_EP] = 1; |
| 156 |
continue; |
| 157 |
} |
| 158 |
if (strcmp(my_argv[i], "limit_rsp") == 0) { |
| 159 |
cmd->Test_List[LIM_RSP] = 1; |
| 160 |
continue; |
| 161 |
} |
| 162 |
if (strcmp(my_argv[i], "limit_psp") == 0) { |
| 163 |
cmd->Test_List[LIM_PSP] = 1; |
| 164 |
continue; |
| 165 |
} |
| 166 |
if (strcmp(my_argv[i], "limit_lmr") == 0) { |
| 167 |
cmd->Test_List[LIM_LMR] = 1; |
| 168 |
continue; |
| 169 |
} |
| 170 |
if (strcmp(my_argv[i], "limit_rpost") == 0) { |
| 171 |
cmd->Test_List[LIM_RPOST] = 1; |
| 172 |
continue; |
| 173 |
} |
| 174 |
if (strcmp(my_argv[i], "limit_size_lmr") == 0) { |
| 175 |
cmd->Test_List[LIM_SIZE_LMR] = 1; |
| 176 |
continue; |
| 177 |
} |
| 178 |
|
| 179 |
DT_Mdep_printf("Cannot find this limit test: %s\n", |
| 180 |
my_argv[i]); |
| 181 |
DT_Limit_Cmd_Usage(); |
| 182 |
return (false); |
| 183 |
|
| 184 |
} /* end foreach remaining argv */ |
| 185 |
} |
| 186 |
|
| 187 |
return (true); |
| 188 |
} |
| 189 |
|
| 190 |
/* --------------------------------------------------- */ |
| 191 |
void DT_Limit_Cmd_Usage(void) |
| 192 |
{ |
| 193 |
DT_Mdep_printf("USAGE: ---- LIMIT TEST ----\n"); |
| 194 |
DT_Mdep_printf("USAGE: dapltest -T L\n"); |
| 195 |
DT_Mdep_printf("USAGE: [-D <device Name>]\n"); |
| 196 |
DT_Mdep_printf("USAGE: [-n <server port number>]\n"); |
| 197 |
DT_Mdep_printf("USAGE: [-d] : debug (zero)\n"); |
| 198 |
DT_Mdep_printf("USAGE: [-w <width_of_resource_sets>]\n"); |
| 199 |
DT_Mdep_printf("USAGE: [-m <maximum_for_exhaustion_tests>]\n"); |
| 200 |
DT_Mdep_printf("USAGE: (1000 - Default)\n"); |
| 201 |
DT_Mdep_printf("USAGE: [-R <service reliability>]\n"); |
| 202 |
DT_Mdep_printf("USAGE: (BE == QOS_BEST_EFFORT - Default)\n"); |
| 203 |
DT_Mdep_printf("USAGE: (HT == QOS_HIGH_THROUGHPUT)\n"); |
| 204 |
DT_Mdep_printf("USAGE: (LL == QOS_LOW_LATENCY)\n"); |
| 205 |
DT_Mdep_printf("USAGE: (EC == QOS_ECONOMY)\n"); |
| 206 |
DT_Mdep_printf("USAGE: (PM == QOS_PREMIUM)\n"); |
| 207 |
DT_Mdep_printf("USAGE: [limit_ia [limit_pz] [limit_evd] ... ]\n"); |
| 208 |
DT_Mdep_printf("NOTE: If test is not specified, do all the limit tests\n"); |
| 209 |
DT_Mdep_printf("NOTE: Else, just do the specified tests\n"); |
| 210 |
DT_Mdep_printf("NOTE: Each test is separated by space, the test can be:\n"); |
| 211 |
DT_Mdep_printf("NOTE: [limit_ia] test max num of open IAs\n"); |
| 212 |
DT_Mdep_printf("NOTE: [limit_pz] test max num of PZs\n"); |
| 213 |
#ifndef __KDAPLTEST__ |
| 214 |
DT_Mdep_printf("NOTE: [limit_cno] test max num of CNOs\n"); |
| 215 |
#endif |
| 216 |
DT_Mdep_printf("NOTE: [limit_evd] test max num of EVDs\n"); |
| 217 |
DT_Mdep_printf("NOTE: [limit_rsp] test max num of RSPs\n"); |
| 218 |
DT_Mdep_printf("NOTE: [limit_psp] test max num of PSPs\n"); |
| 219 |
DT_Mdep_printf("NOTE: [limit_ep] test max num of EPs\n"); |
| 220 |
DT_Mdep_printf("NOTE: [limit_lmr] test max num of LMRs\n"); |
| 221 |
DT_Mdep_printf("NOTE: [limit_rpost] test max num of recvs posted\n"); |
| 222 |
DT_Mdep_printf("NOTE: [limit_size_lmr] test max size of LMR\n"); |
| 223 |
} |