[openib-general] [PATCH] OpenSM - add guid to opensm opts

Yael Kalka yael at mellanox.co.il
Mon Mar 13 03:56:56 PST 2006


Hi Hal,

The following patch adds the port guid that the SM is running on to
the opensm.opts file, and for that to the subnet opts as well.
This enables to define the port to run the SM from through the
configuration file as well as through the command line. 
Still, the priority is always to the command line arguments over
the opensm.opts definitions.

Thanks,
Yael

Signed-off-by:  Yael Kalka <yael at mellanox.co.il>

Index: include/opensm/osm_subnet.h
===================================================================
--- include/opensm/osm_subnet.h	(revision 5768)
+++ include/opensm/osm_subnet.h	(working copy)
@@ -192,6 +192,7 @@ typedef enum _osm_testability_modes
 */
 typedef struct _osm_subn_opt
 {
+  ib_net64_t               guid;
   ib_net64_t					m_key;
   ib_net64_t               sm_key;
   ib_net64_t					subnet_prefix;
@@ -243,6 +244,9 @@ typedef struct _osm_subn_opt
 /*
 * FIELDS
 *
+*	guid
+*		The port guid that the SM is binding to.
+*
 *	m_key
 *		M_Key value sent to all ports qualifing all Set(PortInfo).
 *
Index: opensm/osm_subnet.c
===================================================================
--- opensm/osm_subnet.c	(revision 5768)
+++ opensm/osm_subnet.c	(working copy)
@@ -407,6 +407,7 @@ osm_subn_set_default_opt(
   IN osm_subn_opt_t* const p_opt )
 {
   cl_memclr(p_opt, sizeof(osm_subn_opt_t));
+  p_opt->guid = 0;
   p_opt->m_key = OSM_DEFAULT_M_KEY;
   p_opt->sm_key = OSM_DEFAULT_SM_KEY;
   p_opt->subnet_prefix = IB_DEFAULT_SUBNET_PREFIX;
@@ -647,6 +648,9 @@ osm_subn_parse_conf_file(
       p_val = strtok_r(NULL, " \t\n", &p_last);
       
       __osm_subn_opts_unpack_net64(
+        "guid", p_key, p_val, &p_opts->guid);
+
+      __osm_subn_opts_unpack_net64(
         "m_key", p_key, p_val, &p_opts->m_key);
   
       __osm_subn_opts_unpack_net64(
@@ -813,6 +817,8 @@ osm_subn_write_conf_file(
   fprintf( 
     opts_file,
     "#\n# DEVICE ATTRIBUTES OPTIONS\n#\n"
+    "# The port GUID on which the OpenSM is running from.\n"
+    "guid 0x%016" PRIx64 "\n\n"
     "# M_Key value sent to all ports qualifing all Set(PortInfo).\n"
     "m_key 0x%016" PRIx64 "\n\n"
     "# The lease period used for the M_Key on this subnet in [msec]\n"
@@ -844,6 +850,7 @@ osm_subn_write_conf_file(
     "local_phy_errors_threshold 0x%02x\n\n"
     "# Threshold of credits over-run errors for sending Trap 129\n"
     "overrun_errors_threshold 0x%02x\n\n",
+    cl_ntoh64(p_opts->guid),
     cl_ntoh64(p_opts->m_key),
     cl_ntoh16(p_opts->m_key_lease_period),
     cl_ntoh64(p_opts->sm_key),
Index: opensm/main.c
===================================================================
--- opensm/main.c	(revision 5768)
+++ opensm/main.c	(working copy)
@@ -500,7 +500,6 @@ main(
   char*                 argv[] )
 {
   osm_subn_opt_t        opt;
-  ib_net64_t            guid = 0;
   ib_net64_t            sm_key = 0;
   ib_api_status_t       status;
   uint32_t              log_flags = OSM_LOG_DEFAULT_LEVEL;
@@ -612,14 +611,14 @@ main(
       /*
         Specifies port guid with which to bind.
       */
-      guid = cl_hton64( strtoull( optarg, NULL, 16 ));
-      if (!guid)
+      opt.guid = cl_hton64( strtoull( optarg, NULL, 16 ));
+      if (!opt.guid)
       {
         /* If guid is 0 - need to display the guid list */
-        guid = INVALID_GUID;
+        opt.guid = INVALID_GUID;
       }
       else
-        printf(" Guid <0x%"PRIx64">\n", cl_hton64( guid ));
+        printf(" Guid <0x%"PRIx64">\n", cl_hton64( opt.guid ));
       break;
 
     case 's':
@@ -809,9 +808,6 @@ main(
   if (vendor_debug)
     osm_vendor_set_debug( osm.p_vendor, vendor_debug );
 
-  if ( cache_options == TRUE )
-    osm_subn_write_conf_file( &opt );
-
   block_signals();
 
   status = osm_opensm_init( &osm, &opt );
@@ -834,17 +830,20 @@ main(
     If the user didn't specify a GUID on the command line,
     then get a port GUID value with which to bind.
   */
-  if( guid == 0 || cl_hton64(guid) == CL_HTON64(INVALID_GUID))
-    guid = get_port_guid( &osm, guid );
+  if( opt.guid == 0 || cl_hton64(opt.guid) == CL_HTON64(INVALID_GUID))
+    opt.guid = get_port_guid( &osm, opt.guid );
 
-  if ( guid == 0 )
+  if ( opt.guid == 0 )
   {
     printf( "Error: Could not get port guid\n" );
     status = IB_ERROR;
     goto Exit;
   }
 
-  status = osm_opensm_bind( &osm, guid );
+  if ( cache_options == TRUE )
+    osm_subn_write_conf_file( &opt );
+
+  status = osm_opensm_bind( &osm, opt.guid );
   if( status != IB_SUCCESS )
   {
     printf( "\nError from osm_opensm_bind (0x%X)\n", status );




More information about the general mailing list