Re: [PATCH] ibnetdiscover: add '-f' flag to show full information (ports' speed and width).

Hal Rosenstock
2010-08-26T11:17:58Z

On Thu, Aug 26, 2010 at 3:43 AM, Doron Shoham <dorons-smomgflXvOZWk0Htik3J/w@public.gmane.org> wrote:
> add '-f' flag to show full information (ports' speed and witdh).
> mainly to work with ibsim (using links real speed and width).

Just a couple of (output formatting) nits below...

> Signed-off-by: Doron Shoham <dorons-smomgflXvOZWk0Htik3J/w@public.gmane.org>
> ---
>  infiniband-diags/src/ibnetdiscover.c |   16 ++++++++++++++--
>  1 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/infiniband-diags/src/ibnetdiscover.c b/infiniband-diags/src/ibnetdiscover.c
> index f20058c..df9e5a6 100644
> --- a/infiniband-diags/src/ibnetdiscover.c
> +++ b/infiniband-diags/src/ibnetdiscover.c
> @@ -77,6 +77,7 @@ static char *diff_cache_file = NULL;
>  static unsigned diffcheck_flags = DIFF_FLAG_DEFAULT;
>
>  static int report_max_hops = 0;
> +static int full_info;
>
>  /**
>  * Define our own conversion functions to maintain compatibility with the old
> @@ -357,13 +358,16 @@ void out_switch_port(ibnd_port_t * port, int group, char *out_prefix)
>                ext_port_str ? ext_port_str : "");
>        if (port->remoteport->node->type != IB_NODE_SWITCH)
>                fprintf(f, "(%" PRIx64 ") ", port->remoteport->guid);
> -       fprintf(f, "\t\t# \"%s\" lid %d %s%s",
> +       fprintf(f, "\t\t# \"%s\" lid %d %s%s ",

I'd leave this alone and move the space below.

>                rem_nodename,
>                port->remoteport->node->type == IB_NODE_SWITCH ?
>                port->remoteport->node->smalid :
>                port->remoteport->base_lid,
>                dump_linkwidth_compat(iwidth), dump_linkspeed_compat(ispeed));
>
> +       if (full_info)
> +               fprintf(f, "s=%d w=%d", ispeed, iwidth);
> +

I'd move the space here before s=

>        if (ibnd_is_xsigo_tca(port->remoteport->guid))
>                fprintf(f, " slot %d", port->portnum);
>        else if (ibnd_is_xsigo_hca(port->remoteport->guid))
> @@ -397,13 +401,17 @@ void out_ca_port(ibnd_port_t * port, int group, char *out_prefix)
>                                       port->remoteport->node->guid,
>                                       port->remoteport->node->nodedesc);
>
> -       fprintf(f, "\t\t# lid %d lmc %d \"%s\" lid %d %s%s\n",
> +       fprintf(f, "\t\t# lid %d lmc %d \"%s\" lid %d %s%s ",

Ditto,

>                port->base_lid, port->lmc, rem_nodename,
>                port->remoteport->node->type == IB_NODE_SWITCH ?
>                port->remoteport->node->smalid :
>                port->remoteport->base_lid,
>                dump_linkwidth_compat(iwidth), dump_linkspeed_compat(ispeed));
>
> +       if (full_info)
> +               fprintf(f, "s=%d w=%d", ispeed, iwidth);

Ditto.

-- Hal

> +       fprintf(f, "\n");
> +
>        free(rem_nodename);
>  }
>
> @@ -926,6 +934,9 @@ static int process_opt(void *context, int ch, char *optarg)
>        case 's':
>                cfg->show_progress = 1;
>                break;
> +       case 'f':
> +               full_info = 1;
> +               break;
>        case 'l':
>                list = LIST_CA_NODE | LIST_SWITCH_NODE | LIST_ROUTER_NODE;
>                break;
> @@ -964,6 +975,7 @@ int main(int argc, char **argv)
>        ibnd_fabric_t *diff_fabric = NULL;
>
>        const struct ibdiag_opt opts[] = {
> +               {"full", 'f', 0, NULL, "show full information (ports' speed and witdh)"},
>                {"show", 's', 0, NULL, "show more information"},
>                {"list", 'l', 0, NULL, "list of connected nodes"},
>                {"grouping", 'g', 0, NULL, "show grouping"},
> --
> 1.5.4