From: Alex Netes <alexne-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
To: Goldwyn Rodrigues <rgoldwyn-l3A5Bk7waGM@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] opensm: Get correct guid in case of multiple ports
Date: Wed, 11 Jan 2012 14:10:05 +0200 [thread overview]
Message-ID: <20120111121005.GB2254@calypso> (raw)
In-Reply-To: <20111005183610.GA18253-DN/iB9hNKqpUanf73oPxOg@public.gmane.org>
Hi Goldwyn,
On 13:36 Wed 05 Oct , Goldwyn Rodrigues wrote:
>
> In case of multiple ports and running in daemon mode, the active port is not selected because opt.guid is set to INVALID_GUID in main() but the check in get_port_guid is done against zero:
> if (port_guid == 0) {
opt.guid is set to 0 by default.
opt.guid is set to INVALID_GUID if a user used "-g WRONG_GUID" command line
option when executing the SM. In that case, when SM runs not in daemon mode,
SM prompts the user to choose available port GUID out of available range.
In case when SM runs in daemon mode, it can't prompt the user so it just exits.
>
> On second thoughts, passing port_guid is worthless because this function is called only when no guid is supplied at the command prompt. So, removed the port_guid parameter from the function altogether.
>
> If not in daemon mode, it would show the list of ports as intended.
>
> Also added error message if no ports are found.
>
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn-l3A5Bk7waGM@public.gmane.org>
>
> diff --git a/opensm/main.c b/opensm/main.c
> index 51c8291..a236859 100644
> --- a/opensm/main.c
> +++ b/opensm/main.c
> @@ -403,7 +403,7 @@ static void show_usage(void)
> exit(2);
> }
>
> -static ib_net64_t get_port_guid(IN osm_opensm_t * p_osm, uint64_t port_guid)
> +static ib_net64_t get_port_guid(IN osm_opensm_t *p_osm)
> {
> ib_port_attr_t attr_array[MAX_LOCAL_IBPORTS];
> uint32_t num_ports = MAX_LOCAL_IBPORTS;
> @@ -436,21 +436,19 @@ static ib_net64_t get_port_guid(IN osm_opensm_t * p_osm, uint64_t port_guid)
> cl_hton64(attr_array[0].port_guid));
> return attr_array[0].port_guid;
> }
> - /* If port_guid is 0 - use the first connected port */
> - if (port_guid == 0) {
> + /* If in daemon mode autoselect first available port */
> + if (p_osm->subn.opt.daemon) {
> for (i = 0; i < num_ports; i++)
> if (attr_array[i].link_state > IB_LINK_DOWN)
> break;
> + /* No port found which is available */
> if (i == num_ports)
> - i = 0;
> + return 0;
> printf("Using default GUID 0x%" PRIx64 "\n",
> cl_hton64(attr_array[i].port_guid));
> return attr_array[i].port_guid;
> }
>
> - if (p_osm->subn.opt.daemon)
> - return 0;
> -
> /* More than one possible port - list all ports and let the user
> * to choose. */
> while (1) {
> @@ -1106,10 +1104,12 @@ int main(int argc, char *argv[])
> then get a port GUID value with which to bind.
> */
> if (opt.guid == 0 || cl_hton64(opt.guid) == CL_HTON64(INVALID_GUID))
> - opt.guid = get_port_guid(&osm, opt.guid);
> + opt.guid = get_port_guid(&osm);
>
> - if (opt.guid == 0)
> + if (opt.guid == 0) {
> + printf("\nError: No available ports\n");
> goto Exit;
> + }
>
> status = osm_opensm_bind(&osm, opt.guid);
> if (status != IB_SUCCESS) {
>
> --
> Goldwyn
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
-- Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-01-11 12:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-05 18:36 [PATCH] opensm: Get correct guid in case of multiple ports Goldwyn Rodrigues
[not found] ` <20111005183610.GA18253-DN/iB9hNKqpUanf73oPxOg@public.gmane.org>
2012-01-11 12:10 ` Alex Netes [this message]
2012-01-11 16:02 ` Goldwyn Rodrigues
[not found] ` <20120111160231.GA3498-DN/iB9hNKqpUanf73oPxOg@public.gmane.org>
2012-01-12 17:23 ` Alex Netes
2012-01-12 18:45 ` Goldwyn Rodrigues
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120111121005.GB2254@calypso \
--to=alexne-vpraknaxozvwk0htik3j/w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=rgoldwyn-l3A5Bk7waGM@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox