<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16640" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2>Index:
D:/Windows/MLNX_WINOF/ulp/opensm/user/osmtest/main.c</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2>===================================================================</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>---
D:/Windows/MLNX_WINOF/ulp/opensm/user/osmtest/main.c (revision
3519)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>+++
D:/Windows/MLNX_WINOF/ulp/opensm/user/osmtest/main.c (revision
3520)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>@@ -75,6 +75,140 @@</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2> <BR> /**********************************************************************<BR>
**********************************************************************/<BR>+ib_net64_t<BR>+get_port_guid(<BR>+
IN osmtest_t *p_osm, uint64_t port_guid,<BR>+ IN boolean_t
is_service)<BR>+{<BR>+ uint32_t i;<BR>+ uint32_t choice =
0;<BR>+ char junk[128];<BR>+ boolean_t done_flag = FALSE;<BR>+
ib_api_status_t status;<BR>+ uint32_t num_ports =
GUID_ARRAY_SIZE;<BR>+ ib_port_attr_t
attr_array[GUID_ARRAY_SIZE];<BR>+ <BR>+ /*<BR>+
Call the transport layer for a list of local port<BR>+ GUID
values.<BR>+ */<BR>+ status = osm_vendor_get_all_port_attr(
p_osm->p_vendor, attr_array, &num_ports );<BR>+ if( status !=
IB_SUCCESS )<BR>+ {<BR>+ printf( "\nError from
osm_vendor_get_all_port_attr (%x)\n", status);<BR>+ return( 0
);<BR>+ }<BR>+<BR>+ /* if num_ports is 0 - return 0 */<BR>+
if( num_ports == 0 )<BR>+ {<BR>+ printf( "\nNo local
ports detected!\n" );<BR>+ return( 0 );<BR>+
}<BR>+ /* If num_ports is 1, then there is only one possible port to use.
Use it. */<BR>+ if ( num_ports == 1 )<BR>+ {<BR>+
printf("Using default GUID 0x%" PRIx64 "\n",
cl_hton64(attr_array[0].port_guid));<BR>+ return(
attr_array[0].port_guid );<BR>+ }<BR>+<BR>+#if defined (
OSM_VENDOR_INTF_OPENIB )<BR>+ /* If port_guid is 0, and this is gen2 - use
the default port whose info is in attr_array[0] */<BR>+ if ( port_guid ==
0 )<BR>+ {<BR>+ printf("Using default GUID 0x%" PRIx64
"\n", cl_hton64(attr_array[0].port_guid));<BR>+ return(
attr_array[0].port_guid );<BR>+ }<BR>+#endif /* OSM_VENDOR_INTF_OPENIB
*/<BR>+<BR>+ /* If port_guid is 0, and we are in windows - find the first
port with link_state != DOWN and<BR>+ use it as default
port. */<BR>+ if ( port_guid == 0 )<BR>+ {<BR>+
for ( i = 0; i < num_ports; i++ )<BR>+
{<BR>+ if (attr_array[i].link_state >
IB_LINK_DOWN)<BR>+
{<BR>+ /* Use this port
*/<BR>+ printf("Using default guid
0x%" PRIx64 "\n",
cl_hton64(attr_array[i].port_guid));<BR>+
return( attr_array[i].port_guid );<BR>+
}<BR>+ }<BR>+ /* If we are running as a
service, and all ports are down we return the
<BR>+ first port (we can't open a window, as
a service)*/<BR>+ if (is_service)
{<BR>+ return(
attr_array[0].port_guid );<BR>+ }<BR>+
}<BR>+<BR>+ /* More than one possible port - list all ports and let the
user to choose. */<BR>+ while( done_flag == FALSE )<BR>+
{<BR>+ printf( "\nChoose a local port number with which to
bind:\n\n" );<BR>+ /* If this is gen2 code - then port 0 has
details of the default port used. <BR>+ no
need to print it.<BR>+ If this is not gen2
code - need to print details of all ports. */<BR>+#if defined (
OSM_VENDOR_INTF_OPENIB )<BR>+ for( i = 1; i < num_ports;
i++ )<BR>+ {<BR>+ printf("\t%u:
GUID = 0x%8" PRIx64 ", lid = 0x%04X, state =
%s\n",<BR>+
i, cl_ntoh64( attr_array[i].port_guid
),<BR>+
attr_array[i].lid,<BR>+
ib_get_port_state_str( attr_array[i].link_state ) );<BR>+
}<BR>+ printf( "\nEnter choice (1-%u): ", i-1 );<BR>+#
else<BR>+ for( i = 0; i < num_ports; i++
)<BR>+ {<BR>+
/*<BR>+ Print the index + 1 since by
convention, port numbers<BR>+ start
with 1 on host channel adapters.<BR>+
*/<BR>+<BR>+ printf("\t%u: GUID = 0x%8" PRIx64 ",
lid = 0x%04X, state =
%s\n",<BR>+
i+1, cl_ntoh64( attr_array[i].port_guid
),<BR>+
attr_array[i].lid,<BR>+
ib_get_port_state_str( attr_array[i].link_state ) );<BR>+
}<BR>+ printf( "\nEnter choice (1-%u): ", i );<BR>+#endif /*
OSM_VENDOR_INTF_OPENIB */<BR>+<BR>+ fflush( stdout
);<BR>+ if (scanf( "%u", &choice ))<BR>+
{<BR>+ /* If gen2 code - choice can be between 1
to num_ports-1<BR>+ if not gen2
code - choice can be between 1 to num_ports */<BR>+#if defined (
OSM_VENDOR_INTF_OPENIB )<BR>+ if( choice >=
num_ports )<BR>+# else<BR>+ if( choice >
num_ports || choice < 1 )<BR>+#endif /* OSM_VENDOR_INTF_OPENIB
*/<BR>+
{<BR>+ printf("\nError: Lame
choice!\n");<BR>+ fflush( stdin
);<BR>+ }<BR>+
else<BR>+
{<BR>+ done_flag =
TRUE;<BR>+ }<BR>+
}<BR>+ else<BR>+
{<BR>+ /* get rid of the junk in the selection
line */<BR>+ scanf( "%s", junk
);<BR>+ printf("\nError: Lame choice!\n");
<BR>+ fflush( stdin );<BR>+
}<BR>+ }<BR>+#if defined ( OSM_VENDOR_INTF_OPENIB )<BR>+
printf("Choice guid=0x%8" PRIx64 "\n", cl_ntoh64( attr_array[choice].port_guid
)); <BR>+ return(
attr_array[choice].port_guid );<BR>+# else<BR>+ return( attr_array[choice
- 1].port_guid );<BR>+#endif /* OSM_VENDOR_INTF_OPENIB
*/<BR>+}<BR>+/**********************************************************************<BR>+
**********************************************************************/<BR> void
show_usage(void);<BR> <BR> void<BR>@@ -513,9 +647,19 @@</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2> }<BR> <BR> /*<BR>+ If the
user didn't specify a GUID on the command line,<BR>+ then get
a port GUID value with which to bind.<BR>+ */<BR>+ if (guid == 0
&& !(guid = get_port_guid(&osm_test, guid,1)))
{<BR>+ printf("\nError: port guid 0x%" PRIx64 " not found\n",
guid);<BR>+ goto Exit;<BR>+ }<BR>+<BR>+ /*<BR>
* Guid may be zero going into this function if the user<BR> * hasn't
specified a binding port on the command line.<BR> */<BR>+
<BR> status = osmtest_bind( &osm_test, (uint16_t)max_lid, guid
);<BR> if (status != IB_SUCCESS)
exit(status);<BR></FONT></DIV></BODY></HTML>