On Sun, 21 Dec 2008 17:27:08 +0200
Sasha Khapyorsky <sas...@voltaire.com> wrote:

> On 16:20 Thu 11 Dec     , Ira Weiny wrote:
> > 
> 
> [snip...]
> 
> > diff --git a/infiniband-diags/libibnetdisc/test/iblinkinfotest.c 
> > b/infiniband-diags/libibnetdisc/test/iblinkinfotest.c
> > new file mode 100644
> > index 0000000..6e63f4a
> > --- /dev/null
> > +++ b/infiniband-diags/libibnetdisc/test/iblinkinfotest.c
> > @@ -0,0 +1,395 @@
> > +/*
> > + * Copyright (c) 2004-2007 Voltaire Inc.  All rights reserved.
> > + * Copyright (c) 2007 Xsigo Systems Inc.  All rights reserved.
> > + * Copyright (c) 2008 Lawrence Livermore National Lab.  All rights 
> > reserved.
> > + *
> > + * This software is available to you under a choice of one of two
> > + * licenses.  You may choose to be licensed under the terms of the GNU
> > + * General Public License (GPL) Version 2, available from the file
> > + * COPYING in the main directory of this source tree, or the
> > + * OpenIB.org BSD license below:
> > + *
> > + *     Redistribution and use in source and binary forms, with or
> > + *     without modification, are permitted provided that the following
> > + *     conditions are met:
> > + *
> > + *      - Redistributions of source code must retain the above
> > + *        copyright notice, this list of conditions and the following
> > + *        disclaimer.
> > + *
> > + *      - Redistributions in binary form must reproduce the above
> > + *        copyright notice, this list of conditions and the following
> > + *        disclaimer in the documentation and/or other materials
> > + *        provided with the distribution.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> > + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> > + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> > + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
> > + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
> > + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
> > + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> > + * SOFTWARE.
> > + *
> > + */
> > +
> > +#if HAVE_CONFIG_H
> > +#  include <config.h>
> > +#endif /* HAVE_CONFIG_H */
> > +
> > +#define _GNU_SOURCE
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +#include <unistd.h>
> > +#include <stdarg.h>
> > +#include <time.h>
> > +#include <string.h>
> > +#include <getopt.h>
> > +#include <errno.h>
> > +#include <inttypes.h>
> > +
> > +#include <infiniband/complib/cl_nodenamemap.h>
> > +#include <infiniband/ibnetdisc.h>
> > +
> > +char *argv0 = "iblinkinfotest";
> > +static FILE *f;
> > +
> > +static char *node_name_map_file = NULL;
> > +static nn_map_t *node_name_map = NULL;
> > +
> > +static int timeout_ms = 500;
> > +
> > +static int debug = 0;
> > +#define    DEBUG(str, args...) \
> > +   if (debug) fprintf(stderr, str, ##args)
> > +
> > +static int down_links_only = 0;
> > +static int line_mode = 0;
> > +static int add_sw_settings = 0;
> > +static int print_port_guids = 0;
> > +
> > +static unsigned int
> > +get_max(unsigned int num)
> > +{
> > +   unsigned int v = num; // 32-bit word to find the log base 2 of
> > +   unsigned r = 0; // r will be lg(v)
> > +
> > +   while (v >>= 1) // unroll for more speed...
> > +   {
> > +           r++;
> > +   }
> > +
> > +   return (1 << r);
> > +}
> > +
> > +void
> > +get_msg(char *width_msg, char *speed_msg, int msg_size, ibnd_port_t *port)
> > +{
> > +   int max_speed = 0;
> > +
> > +   int max_width = get_max(port->info.link_width_supported
> > +                           & port->remoteport->info.link_width_supported);
> > +   if ((max_width & port->info.link_width_active) == 0) {
> > +           // we are not at the max supported width
> > +           // print what we could be at.
> > +           snprintf(width_msg, msg_size, "Could be %s",
> > +                   ibnd_linkwidth_str(max_width));
> > +   }
> > +
> > +   max_speed = get_max(port->info.link_speed_supported
> > +                           & port->remoteport->info.link_speed_supported);
> > +   if ((max_speed & port->info.link_speed_active) == 0) {
> > +           // we are not at the max supported speed
> > +           // print what we could be at.
> > +           snprintf(speed_msg, msg_size, "Could be %s",
> > +                   ibnd_linkspeed_str(max_speed, 1));
> > +   }
> > +}
> > +
> > +void
> > +print_port(ibnd_node_t *node, ibnd_port_t *port)
> > +{
> > +   char remote_guid_str[256];
> > +   char remote_str[256];
> > +   char link_str[256];
> > +   char width_msg[256];
> > +   char speed_msg[256];
> > +   char ext_port_str[256];
> > +
> > +   if (!port)
> > +           return;
> > +
> > +   remote_guid_str[0] = '\0';
> > +   remote_str[0] = '\0';
> > +   link_str[0] = '\0';
> > +   width_msg[0] = '\0';
> > +   speed_msg[0] = '\0';
> > +
> > +   if (port->remoteport) {
> > +           char  remote_name_buf[256];
> > +           strncpy(remote_name_buf, port->remoteport->node->nodedesc, 256);
> > +
> > +           if (port->remoteport->ext_portnum)
> > +                   snprintf(ext_port_str, 256, "%d", 
> > port->remoteport->ext_portnum);
> > +           else
> > +                   ext_port_str[0] = '\0';
> > +
> > +           get_msg(width_msg, speed_msg, 256, port);
> > +           if (line_mode) {
> > +                   if (print_port_guids) {
> > +                           snprintf(remote_guid_str, 256,
> > +                                   "0x%016lx ",
> > +                                   port->remoteport->guid);
> 
> Here and below, printing uint64_t as %lx generates warning on 32-bit
> machine. I would suggest to use portable string macros - PRIx64.
> 

Fixed,
Ira

_______________________________________________
general mailing list
general@lists.openfabrics.org
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to