[ofa-general] Re: [PATCH] infiniband-diags/smpquery: usage improvement

Ira Weiny weiny2 at llnl.gov
Mon Jan 26 09:34:49 PST 2009


This will break some of the internal scripts we have here which use "nodeinfo".

I don't have an objection to all this option changing, but we need to make it
clear that many options have changed throughout all the diags.

Ira


On Mon, 26 Jan 2009 11:14:19 +0200
Sasha Khapyorsky <sashak at voltaire.com> wrote:

> 
> This makes usage of smpquery operations more user friendly - similar to
> saquery each operation now has a shorter alias, string matching is case
> insensitive and abbreviations are allowed for both operation name and
> alias. And it is how this looks:
> 
> Usage: smpquery [options] <op> <dest dr_path|lid|guid> [op params]
> 
> Supported operations (and aliases, case insensitive):
>   NodeInfo (NI) <addr>
>   NodeDesc (ND) <addr>
>   PortInfo (PI) <addr> [<portnum>]
>   SwitchInfo (SI) <addr>
>   PKeyTable (PKeys) <addr> [<portnum>]
>   SL2VLTable (SL2VL) <addr> [<portnum>]
>   VLArbitration (VLArb) <addr> [<portnum>]
>   GUIDInfo (GI) <addr>
> 
> Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
> ---
>  infiniband-diags/src/smpquery.c |   32 +++++++++++++++++---------------
>  1 files changed, 17 insertions(+), 15 deletions(-)
> 
> diff --git a/infiniband-diags/src/smpquery.c b/infiniband-diags/src/smpquery.c
> index 7dcf888..44280e1 100644
> --- a/infiniband-diags/src/smpquery.c
> +++ b/infiniband-diags/src/smpquery.c
> @@ -54,7 +54,7 @@
>  typedef char *(op_fn_t)(ib_portid_t *dest, char **argv, int argc);
>  
>  typedef struct match_rec {
> -	char *name;
> +	const char *name, *alias;
>  	op_fn_t *fn;
>  	unsigned opt_portnum;
>  } match_rec_t;
> @@ -63,14 +63,14 @@ static op_fn_t	node_desc, node_info, port_info, switch_info, pkey_table,
>  	sl2vl_table, vlarb_table, guid_info;
>  
>  static const match_rec_t match_tbl[] = {
> -	{ "nodeinfo", node_info },
> -	{ "nodedesc", node_desc },
> -	{ "portinfo", port_info, 1 },
> -	{ "switchinfo", switch_info },
> -	{ "pkeys", pkey_table, 1 },
> -	{ "sl2vl", sl2vl_table, 1 },
> -	{ "vlarb", vlarb_table, 1 },
> -	{ "guids", guid_info },
> +	{ "NodeInfo", "NI", node_info },
> +	{ "NodeDesc", "ND", node_desc },
> +	{ "PortInfo", "PI", port_info, 1 },
> +	{ "SwitchInfo", "SI", switch_info },
> +	{ "PKeyTable", "PKeys", pkey_table, 1 },
> +	{ "SL2VLTable", "SL2VL", sl2vl_table, 1 },
> +	{ "VLArbitration", "VLArb", vlarb_table, 1 },
> +	{ "GUIDInfo", "GI", guid_info },
>  	{0}
>  };
>  
> @@ -373,14 +373,15 @@ guid_info(ib_portid_t *dest, char **argv, int argc)
>  	return 0;
>  }
>  
> -static op_fn_t *
> -match_op(char *name)
> +static op_fn_t *match_op(char *name)
>  {
>  	const match_rec_t *r;
> +	unsigned len = strlen(name);
>  	for (r = match_tbl; r->name; r++)
> -		if (!strcmp(r->name, name))
> +		if (!strncasecmp(r->name, name, len) ||
> +		    (r->alias && !strncasecmp(r->alias, name, len)))
>  			return r->fn;
> -	return 0;
> +	return NULL;
>  }
>  
>  static int process_opt(void *context, int ch, char *optarg)
> @@ -422,10 +423,11 @@ int main(int argc, char **argv)
>  	};
>  
>  	n = sprintf(usage_args, "<op> <dest dr_path|lid|guid> [op params]\n"
> -		    "\nSupported ops:\n");
> +		    "\nSupported ops (and aliases, case insensitive):\n");
>  	for (r = match_tbl ; r->name ; r++) {
>  		n += snprintf(usage_args + n, sizeof(usage_args) - n,
> -			      "  %s <addr>%s\n", r->name,
> +			      "  %s (%s) <addr>%s\n", r->name,
> +			      r->alias ? r->alias : "",
>  			      r->opt_portnum ? " [<portnum>]" : "");
>  		if (n >= sizeof(usage_args))
>  			exit(-1);
> -- 
> 1.6.0.4.766.g6fc4a
> 



More information about the general mailing list