[ofa-general] Re: [PATCH OpenSM 1/3] Added io_guid_file options and variables in the different structures and functions.

Sasha Khapyorsky sashak at voltaire.com
Sat Feb 7 10:37:01 PST 2009


On 14:43 Thu 18 Dec     , Nicolas Morey Chaisemartin wrote:
>
> Signed-off-by: Nicolas Morey-Chaisemartin 
> <nicolas.morey-chaisemartin at ext.bull.net>
> ---
>  opensm/include/opensm/osm_subnet.h |    5 ++
>  opensm/opensm/main.c               |   13 ++++++
>  opensm/opensm/osm_subnet.c         |    9 ++++
>  opensm/opensm/osm_ucast_ftree.c    |   81 
> ++++++++++++++++++++++++++++++++----
>  4 files changed, 100 insertions(+), 8 deletions(-)

> diff --git a/opensm/include/opensm/osm_subnet.h b/opensm/include/opensm/osm_subnet.h
> index fe456d5..3f3d919 100644
> --- a/opensm/include/opensm/osm_subnet.h
> +++ b/opensm/include/opensm/osm_subnet.h
> @@ -190,6 +190,7 @@ typedef struct osm_subn_opt {
>  	char *lfts_file;
>  	char *root_guid_file;
>  	char *cn_guid_file;
> +	char *io_guid_file;
>  	char *ids_guid_file;
>  	char *guid_routing_order_file;
>  	char *sa_db_file;
> @@ -382,6 +383,10 @@ typedef struct osm_subn_opt {
>  *		Name of the file that contains list of compute node guids that
>  *		will be used by fat-tree routing (provided by User)
>  *
> +*	io_guid_file
> +*		Name of the file that contains list of I/O node guids that
> +*		will be used by fat-tree routing (provided by User)
> +*
>  *	ids_guid_file
>  *		Name of the file that contains list of ids which should be
>  *		used by Up/Down algorithm instead of node GUIDs
> diff --git a/opensm/opensm/main.c b/opensm/opensm/main.c
> index 999e92f..3c1bcf2 100644
> --- a/opensm/opensm/main.c
> +++ b/opensm/opensm/main.c
> @@ -207,6 +207,9 @@ static void show_usage(void)
>  	printf("--cn_guid_file, -u <path to file>\n"
>  	       "          Set the compute nodes for the Fat-Tree routing algorithm\n"
>  	       "          to the guids provided in the given file (one to a line)\n\n");
> +	printf("--io_guid_file, -G <path to file>\n"
> +	       "          Set the I/O nodes for the Fat-Tree routing algorithm\n"
> +	       "          to the guids provided in the given file (one to a line)\n\n");
>  	printf("--ids_guid_file, -m <path to file>\n"
>  	       "          Name of the map file with set of the IDs which will be used\n"
>  	       "          by Up/Down routing algorithm instead of node GUIDs\n"
> @@ -570,6 +573,7 @@ int main(int argc, char *argv[])
>  		{"sadb_file", 1, NULL, 'S'},
>  		{"root_guid_file", 1, NULL, 'a'},
>  		{"cn_guid_file", 1, NULL, 'u'},
> +		{"io_guid_file", 1, NULL, 'G'},

"G:" should be added to short_options too.

>  		{"ids_guid_file", 1, NULL, 'm'},
>  		{"guid_routing_order_file", 1, NULL, 'X'},
>  		{"stay_on_fatal", 0, NULL, 'y'},
> @@ -880,6 +884,15 @@ int main(int argc, char *argv[])
>  			       opt.cn_guid_file);
>  			break;
>  
> +		case 'G':
> +			/*
> +			   Specifies I/O node guids file
> +			 */
> +			opt.io_guid_file = optarg;
> +			printf(" I/O Node Guid File: %s\n",
> +			       opt.io_guid_file);
> +			break;
> +
>  		case 'm':
>  			/* Specifies ids guid file */
>  			opt.ids_guid_file = optarg;
> diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
> index 9136021..5bfb6ae 100644
> --- a/opensm/opensm/osm_subnet.c
> +++ b/opensm/opensm/osm_subnet.c
> @@ -410,6 +410,7 @@ void osm_subn_set_default_opt(IN osm_subn_opt_t * const p_opt)
>  	p_opt->lfts_file = NULL;
>  	p_opt->root_guid_file = NULL;
>  	p_opt->cn_guid_file = NULL;
> +	p_opt->io_guid_file = NULL;
>  	p_opt->ids_guid_file = NULL;
>  	p_opt->guid_routing_order_file = NULL;
>  	p_opt->sa_db_file = NULL;
> @@ -1163,6 +1164,9 @@ int osm_subn_parse_conf_file(char *file_name, osm_subn_opt_t * const p_opts)
>  		opts_unpack_charp("cn_guid_file",
>  				  p_key, p_val, &p_opts->cn_guid_file);
>  
> +		opts_unpack_charp("io_guid_file",
> +				  p_key, p_val, &p_opts->io_guid_file);
> +
>  		opts_unpack_charp("ids_guid_file",
>  				  p_key, p_val, &p_opts->ids_guid_file);
>  
> @@ -1465,6 +1469,11 @@ int osm_subn_output_conf(FILE *out, IN osm_subn_opt_t *const p_opts)
>  		p_opts->cn_guid_file ? p_opts->cn_guid_file : null_str);
>  
>  	fprintf(out,
> +		"# The file holding the fat-tree I/O node guids\n"
> +		"# One guid in each line\nio_guid_file %s\n\n",
> +		p_opts->io_guid_file ? p_opts->io_guid_file : null_str);
> +
> +	fprintf(out,
>  		"# The file holding the node ids which will be used by"
>  		" Up/Down algorithm instead\n# of GUIDs (one guid and"
>  		" id in each line)\nids_guid_file %s\n\n",
> diff --git a/opensm/opensm/osm_ucast_ftree.c b/opensm/opensm/osm_ucast_ftree.c
> index b7da20b..c24c517 100644
> --- a/opensm/opensm/osm_ucast_ftree.c
> +++ b/opensm/opensm/osm_ucast_ftree.c
> @@ -155,6 +155,7 @@ typedef struct ftree_port_group_t_ {
>  	ftree_hca_or_sw remote_hca_or_sw;	/* pointer to remote hca/switch */
>  	cl_ptr_vector_t ports;	/* vector of ports to the same lid */
>  	boolean_t is_cn;	/* whether this port is a compute node */
> +	boolean_t is_io;	/* whether this port is an I/O node */
>  	uint32_t counter_down;	/* number of allocated routs downwards */
>  } ftree_port_group_t;
>  
> @@ -205,6 +206,7 @@ typedef struct ftree_fabric_t_ {
>  	cl_qmap_t sw_by_tuple_tbl;
>  	cl_qlist_t root_guid_list;
>  	cl_qmap_t cn_guid_tbl;
> +	cl_qmap_t io_guid_tbl;
>  	unsigned cn_num;
>  	uint8_t leaf_switch_rank;
>  	uint8_t max_switch_rank;
> @@ -392,7 +394,8 @@ __osm_ftree_port_group_create(IN ib_net16_t base_lid,
>  			      IN ib_net64_t remote_node_guid,
>  			      IN uint8_t remote_node_type,
>  			      IN void *p_remote_hca_or_sw,
> -			      IN boolean_t is_cn)
> +			      IN boolean_t is_cn,
> +			      IN boolean_t is_io)
>  {
>  	ftree_port_group_t *p_group =
>  	    (ftree_port_group_t *) malloc(sizeof(ftree_port_group_t));
> @@ -440,6 +443,7 @@ __osm_ftree_port_group_create(IN ib_net16_t base_lid,
>  	cl_ptr_vector_init(&p_group->ports, 0,	/* min size */
>  			   8);	/* grow size */
>  	p_group->is_cn = is_cn;
> +	p_group->is_io = is_io;
>  	return p_group;
>  }				/* __osm_ftree_port_group_create() */
>  
> @@ -705,7 +709,7 @@ __osm_ftree_sw_add_port(IN ftree_sw_t * p_sw,
>  							remote_node_guid,
>  							remote_node_type,
>  							p_remote_hca_or_sw,
> -							FALSE);
> +							     FALSE,FALSE);

Please don't break indentation.

Also here and in another places space after ',' is needed (you can look
at opensm/doc/opensm-coding-style.txt and use opensm/opensm/osm_indent to
get an idea about desired formatting style).

>  		CL_ASSERT(p_group);
>  
>  		if (direction == FTREE_DIRECTION_UP)
> @@ -836,7 +840,8 @@ __osm_ftree_hca_add_port(IN ftree_hca_t * p_hca,
>  			 IN ib_net64_t remote_port_guid,
>  			 IN ib_net64_t remote_node_guid,
>  			 IN uint8_t remote_node_type,
> -			 IN void *p_remote_hca_or_sw, IN boolean_t is_cn)
> +			 IN void *p_remote_hca_or_sw, IN boolean_t is_cn,
> +			 IN boolean_t is_io)
>  {
>  	ftree_port_group_t *p_group;
>  
> @@ -859,7 +864,7 @@ __osm_ftree_hca_add_port(IN ftree_hca_t * p_hca,
>  							remote_node_guid,
>  							remote_node_type,
>  							p_remote_hca_or_sw,
> -							is_cn);
> +							is_cn,is_io);
>  		p_hca->up_port_groups[p_hca->up_port_groups_num++] = p_group;
>  	}
>  	__osm_ftree_port_group_add_port(p_group, port_num, remote_port_num);
> @@ -885,6 +890,7 @@ static ftree_fabric_t *__osm_ftree_fabric_create()
>  	cl_qmap_init(&p_ftree->sw_tbl);
>  	cl_qmap_init(&p_ftree->sw_by_tuple_tbl);
>  	cl_qmap_init(&p_ftree->cn_guid_tbl);
> +	cl_qmap_init(&p_ftree->io_guid_tbl);
>  
>  	cl_qlist_init(&p_ftree->root_guid_list);
>  
> @@ -953,6 +959,18 @@ static void __osm_ftree_fabric_clear(ftree_fabric_t * p_ftree)
>  	}
>  	cl_qmap_remove_all(&p_ftree->cn_guid_tbl);
>  
> +	/* remove all the elements of io_guid_tbl */
> +	p_next_guid_element =
> +	    (name_map_item_t *) cl_qmap_head(&p_ftree->io_guid_tbl);
> +	while (p_next_guid_element !=
> +	       (name_map_item_t *) cl_qmap_end(&p_ftree->io_guid_tbl)) {
> +		p_guid_element = p_next_guid_element;
> +		p_next_guid_element =
> +		    (name_map_item_t *) cl_qmap_next(&p_guid_element->item);
> +		free(p_guid_element);
> +	}
> +	cl_qmap_remove_all(&p_ftree->io_guid_tbl);
> +
>  	/* remove all the elements of root_guid_list */
>  	while (!cl_is_qlist_empty(&p_ftree->root_guid_list))
>  		free(cl_qlist_remove_head(&p_ftree->root_guid_list));
> @@ -1347,6 +1365,14 @@ static inline boolean_t __osm_ftree_fabric_cns_provided(IN ftree_fabric_t *
>  
>  /***************************************************/
>  
> +static inline boolean_t __osm_ftree_fabric_ios_provided(IN ftree_fabric_t *
> +							p_ftree)
> +{
> +	return (p_ftree->p_osm->subn.opt.io_guid_file != NULL);
> +}
> +
> +/***************************************************/
> +
>  static int __osm_ftree_fabric_mark_leaf_switches(IN ftree_fabric_t * p_ftree)
>  {
>  	ftree_sw_t *p_sw;
> @@ -2816,6 +2842,7 @@ __osm_ftree_fabric_construct_hca_ports(IN ftree_fabric_t * p_ftree,
>  	uint8_t i;
>  	uint8_t remote_port_num;
>  	boolean_t is_cn = FALSE;
> +	boolean_t is_io = FALSE;
>  	int res = 0;
>  
>  	for (i = 0; i < osm_node_get_num_physp(p_node); i++) {
> @@ -2893,9 +2920,27 @@ __osm_ftree_fabric_construct_hca_ports(IN ftree_fabric_t * p_ftree,
>  				"Marking CN port GUID 0x%016" PRIx64 "\n",
>  				cl_ntoh64(osm_physp_get_port_guid(p_osm_port)));
>  		} else {
> -			OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
> -				"Marking non-CN port GUID 0x%016" PRIx64 "\n",
> -				cl_ntoh64(osm_physp_get_port_guid(p_osm_port)));
> +		       if (__osm_ftree_fabric_ios_provided(p_ftree)) {

		} else if (...) {
			....

> +			       name_map_item_t *p_elem =
> +				  (name_map_item_t *) cl_qmap_get(&p_ftree->
> +								      io_guid_tbl,
> +								      cl_ntoh64(osm_physp_get_port_guid
> +										  (p_osm_port)));
> +				if (p_elem !=
> +				    (name_map_item_t *) cl_qmap_end(&p_ftree->
> +									 io_guid_tbl))
> +				    is_io = TRUE;
> +
> +
> +				OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
> +					 "Marking I/O port GUID 0x%016" PRIx64 "\n",
> +					 cl_ntoh64(osm_physp_get_port_guid(p_osm_port)));
> +
> +			} else {
> +			       OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
> +					 "Marking non-CN port GUID 0x%016" PRIx64 "\n",
> +					 cl_ntoh64(osm_physp_get_port_guid(p_osm_port)));
> +			}
>  		}
>  
>  		__osm_ftree_hca_add_port(p_hca,	/* local ftree_hca object */
> @@ -2908,7 +2953,7 @@ __osm_ftree_fabric_construct_hca_ports(IN ftree_fabric_t * p_ftree,
>  					 remote_node_guid,	/* remote node guid */
>  					 remote_node_type,	/* remote node type */
>  					 (void *)p_remote_sw,	/* remote ftree_hca/sw object */
> -					 is_cn);	/* whether this port is compute node */
> +					    is_cn,is_io);	/* whether this port is compute node */
>  	}
>  
>  Exit:
> @@ -3399,6 +3444,26 @@ static int __osm_ftree_fabric_read_guid_files(IN ftree_fabric_t * p_ftree)
>  		}
>  	}
>  
> +
> +	if (__osm_ftree_fabric_ios_provided(p_ftree)) {
> +		OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
> +			"Fetching I/O nodes from file %s\n",
> +			p_ftree->p_osm->subn.opt.io_guid_file);
> +
> +		if (parse_node_map(p_ftree->p_osm->subn.opt.io_guid_file,
> +				   add_guid_item_to_map,
> +				   &p_ftree->io_guid_tbl)) {
> +			status = -1;
> +			goto Exit;
> +		}
> +
> +		if (!cl_qmap_count(&p_ftree->io_guid_tbl)) {
> +			OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB23: "
> +				"I/O node guids file has no valid guids\n");
> +			status = -1;
> +			goto Exit;
> +		}

Should empty io_guids file be an error (I don't know)?

Sasha

> +	}
>  Exit:
>  	OSM_LOG_EXIT(&p_ftree->p_osm->log);
>  	return status;
> 




More information about the general mailing list