[ofa-general] Re: [PATCH 2/10] infiniband-diags: Convert ibaddr to "new" ibmad interface
Sasha Khapyorsky
sashak at voltaire.com
Sun Mar 1 00:08:04 PST 2009
On 19:05 Thu 19 Feb , Ira Weiny wrote:
> From 1ead0cdb05b159dbd3a89d2030870fc7326ec84d Mon Sep 17 00:00:00 2001
> From: Ira Weiny <weiny2 at llnl.gov>
> Date: Thu, 19 Feb 2009 14:47:05 -0800
> Subject: [PATCH] infiniband-diags: Convert ibaddr to "new" ibmad interface
>
>
> Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
> ---
> infiniband-diags/src/ibaddr.c | 17 ++++++++++++-----
> infiniband-diags/src/ibdiag_common.c | 3 ++-
> 2 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/infiniband-diags/src/ibaddr.c b/infiniband-diags/src/ibaddr.c
> index 9098699..bb22be9 100644
> --- a/infiniband-diags/src/ibaddr.c
> +++ b/infiniband-diags/src/ibaddr.c
> @@ -45,6 +45,8 @@
>
> #include "ibdiag_common.h"
>
> +struct ibmad_port *srcport;
> +
> static int
> ib_resolve_addr(ib_portid_t *portid, int portnum, int show_lid, int show_gid)
> {
> @@ -55,10 +57,10 @@ ib_resolve_addr(ib_portid_t *portid, int portnum, int show_lid, int show_gid)
> ibmad_gid_t gid;
> int lmc;
>
> - if (!smp_query(nodeinfo, portid, IB_ATTR_NODE_INFO, 0, 0))
> + if (!smp_query_via(nodeinfo, portid, IB_ATTR_NODE_INFO, 0, 0, srcport))
> return -1;
>
> - if (!smp_query(portinfo, portid, IB_ATTR_PORT_INFO, portnum, 0))
> + if (!smp_query_via(portinfo, portid, IB_ATTR_PORT_INFO, portnum, 0, srcport))
> return -1;
>
> mad_decode_field(portinfo, IB_PORT_LID_F, &portid->lid);
> @@ -137,17 +139,22 @@ int main(int argc, char **argv)
> if (!show_lid && !show_gid)
> show_lid = show_gid = 1;
>
> - madrpc_init(ibd_ca, ibd_ca_port, mgmt_classes, 3);
> + srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
> + if (!srcport)
> + IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
Here and in almost all other infiniband-diags patches:
madrpc_init() in case of failures calls IBPANIC() which prints error
message and calls exit(). Unlike this mad_rpc_open_port() sets errno and
returns NULL, IBERROR() just prints error message - the program will
continue execution...
>
> if (argc) {
> - if (ib_resolve_portid_str(&portid, argv[0], ibd_dest_type, ibd_sm_id) < 0)
> + if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
> + ibd_sm_id, srcport) < 0)
> IBERROR("can't resolve destination port %s", argv[0]);
> } else {
> - if (ib_resolve_self(&portid, &port, 0) < 0)
> + if (ib_resolve_self_via(&portid, &port, 0, srcport) < 0)
> IBERROR("can't resolve self port %s", argv[0]);
> }
>
> if (ib_resolve_addr(&portid, port, show_lid, show_gid) < 0)
> IBERROR("can't resolve requested address");
> +
> + mad_rpc_close_port(srcport);
> exit(0);
> }
> diff --git a/infiniband-diags/src/ibdiag_common.c b/infiniband-diags/src/ibdiag_common.c
> index 5f2472d..609df69 100644
> --- a/infiniband-diags/src/ibdiag_common.c
> +++ b/infiniband-diags/src/ibdiag_common.c
> @@ -179,7 +179,8 @@ static int process_opt(int ch, char *optarg)
> ibd_timeout = val;
> break;
> case 's':
> - if (ib_resolve_portid_str(&sm_portid, optarg, IB_DEST_LID, 0) < 0)
> + if (ib_resolve_portid_str_via(&sm_portid, optarg, IB_DEST_LID,
> + 0, NULL) < 0)
This may be not correct (not introduced by those patches) - then host is
connected to multiple subnets we need to resolve SM LID on requested
one, eg. using srcport...
Sasha
> IBERROR("cannot resolve SM destination port %s", optarg);
> ibd_sm_id = &sm_portid;
> break;
> --
> 1.5.4.5
>
More information about the general
mailing list