[ofa-general] Re: [PATCH 1/5] libibnetdisc: make all fields of ibnd_node_t public

Sasha Khapyorsky sashak at voltaire.com
Sun Aug 16 03:39:02 PDT 2009


On 20:42 Thu 13 Aug     , Ira Weiny wrote:
> 

It would be really nice to have a commit message (in addition to
subject) for each patch. Cover email ([PATH 0/N]) is not saved in
change history.

> From: Ira Weiny <weiny2 at llnl.gov>
> Date: Tue, 11 Aug 2009 15:15:21 -0700
> Subject: [PATCH] libibnetdisc: make all fields of ibnd_node_t public
> 
> 
> Signed-off-by: Ira Weiny <weiny2 at llnl.gov>

Applied. Thanks.

Sasha

> ---
>  .../libibnetdisc/include/infiniband/ibnetdisc.h    |   12 +-
>  infiniband-diags/libibnetdisc/src/chassis.c        |  147 ++++++++---------
>  infiniband-diags/libibnetdisc/src/ibnetdisc.c      |  173 ++++++++++----------
>  infiniband-diags/libibnetdisc/src/internal.h       |   22 +--
>  4 files changed, 166 insertions(+), 188 deletions(-)
> 
> diff --git a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
> index 121709d..e7f5f6a 100644
> --- a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
> +++ b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
> @@ -45,8 +45,8 @@ struct port;			/* forward declare */
>  /** =========================================================================
>   * Node
>   */
> -typedef struct node {
> -	struct node *next;	/* all node list in fabric */
> +typedef struct ibnd_node {
> +	struct ibnd_node *next;	/* all node list in fabric */
>  
>  	ib_portid_t path_portid;	/* path from "from_node" */
>  	int dist;		/* num of hops from "from_node" */
> @@ -72,12 +72,18 @@ typedef struct node {
>  				   items MAY BE NULL!  (ie 0 == switches only) */
>  
>  	/* chassis info */
> -	struct node *next_chassis_node;	/* next node in ibnd_chassis_t->nodes */
> +	struct ibnd_node *next_chassis_node;	/* next node in ibnd_chassis_t->nodes */
>  	struct chassis *chassis;	/* if != NULL the chassis this node belongs to */
>  	unsigned char ch_type;
>  	unsigned char ch_anafanum;
>  	unsigned char ch_slotnum;
>  	unsigned char ch_slot;
> +
> +	/* internal use only */
> +	unsigned char ch_found;
> +	struct ibnd_node *htnext;	/* hash table list */
> +	struct ibnd_node *dnext;	/* nodesdist next */
> +	struct ibnd_node *type_next;	/* next based on type */
>  } ibnd_node_t;
>  
>  /** =========================================================================
> diff --git a/infiniband-diags/libibnetdisc/src/chassis.c b/infiniband-diags/libibnetdisc/src/chassis.c
> index 120b4b6..0dd259a 100644
> --- a/infiniband-diags/libibnetdisc/src/chassis.c
> +++ b/infiniband-diags/libibnetdisc/src/chassis.c
> @@ -239,68 +239,68 @@ uint64_t ibnd_get_chassis_guid(ibnd_fabric_t * fabric, unsigned char chassisnum)
>  		return 0;
>  }
>  
> -static int is_router(struct ibnd_node *n)
> +static int is_router(ibnd_node_t * n)
>  {
> -	uint32_t devid = mad_get_field(n->node.info, 0, IB_NODE_DEVID_F);
> +	uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
>  	return (devid == VTR_DEVID_IB_FC_ROUTER ||
>  		devid == VTR_DEVID_IB_IP_ROUTER);
>  }
>  
> -static int is_spine_9096(struct ibnd_node *n)
> +static int is_spine_9096(ibnd_node_t * n)
>  {
> -	uint32_t devid = mad_get_field(n->node.info, 0, IB_NODE_DEVID_F);
> +	uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
>  	return (devid == VTR_DEVID_SFB4 || devid == VTR_DEVID_SFB4_DDR);
>  }
>  
> -static int is_spine_9288(struct ibnd_node *n)
> +static int is_spine_9288(ibnd_node_t * n)
>  {
> -	uint32_t devid = mad_get_field(n->node.info, 0, IB_NODE_DEVID_F);
> +	uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
>  	return (devid == VTR_DEVID_SFB12 || devid == VTR_DEVID_SFB12_DDR);
>  }
>  
> -static int is_spine_2004(struct ibnd_node *n)
> +static int is_spine_2004(ibnd_node_t * n)
>  {
> -	uint32_t devid = mad_get_field(n->node.info, 0, IB_NODE_DEVID_F);
> +	uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
>  	return (devid == VTR_DEVID_SFB2004);
>  }
>  
> -static int is_spine_2012(struct ibnd_node *n)
> +static int is_spine_2012(ibnd_node_t * n)
>  {
> -	uint32_t devid = mad_get_field(n->node.info, 0, IB_NODE_DEVID_F);
> +	uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
>  	return (devid == VTR_DEVID_SFB2012);
>  }
>  
> -static int is_spine(struct ibnd_node *n)
> +static int is_spine(ibnd_node_t * n)
>  {
>  	return (is_spine_9096(n) || is_spine_9288(n) ||
>  		is_spine_2004(n) || is_spine_2012(n));
>  }
>  
> -static int is_line_24(struct ibnd_node *n)
> +static int is_line_24(ibnd_node_t * n)
>  {
> -	uint32_t devid = mad_get_field(n->node.info, 0, IB_NODE_DEVID_F);
> -	return (devid == VTR_DEVID_SLB24 || devid == VTR_DEVID_SLB24_DDR ||
> -		devid == VTR_DEVID_SRB2004);
> +	uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
> +	return (devid == VTR_DEVID_SLB24 ||
> +		devid == VTR_DEVID_SLB24_DDR || devid == VTR_DEVID_SRB2004);
>  }
>  
> -static int is_line_8(struct ibnd_node *n)
> +static int is_line_8(ibnd_node_t * n)
>  {
> -	uint32_t devid = mad_get_field(n->node.info, 0, IB_NODE_DEVID_F);
> +	uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
>  	return (devid == VTR_DEVID_SLB8);
>  }
>  
> -static int is_line_2024(struct ibnd_node *n)
> +static int is_line_2024(ibnd_node_t * n)
>  {
> -	uint32_t devid = mad_get_field(n->node.info, 0, IB_NODE_DEVID_F);
> +	uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
>  	return (devid == VTR_DEVID_SLB2024);
>  }
>  
> -static int is_line(struct ibnd_node *n)
> +static int is_line(ibnd_node_t * n)
>  {
>  	return (is_line_24(n) || is_line_8(n) || is_line_2024(n));
>  }
>  
> -int is_chassis_switch(struct ibnd_node *n)
> +int is_chassis_switch(ibnd_node_t * n)
>  {
>  	return (is_spine(n) || is_line(n));
>  }
> @@ -349,7 +349,7 @@ char anafa_spine4_slot_2_slb[25] = {
>  
>  /*	reference                     { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; */
>  
> -static int get_sfb_slot(struct ibnd_node *node, ibnd_port_t * lineport)
> +static int get_sfb_slot(ibnd_node_t * node, ibnd_port_t * lineport)
>  {
>  	ibnd_node_t *n = (ibnd_node_t *) node;
>  
> @@ -372,25 +372,24 @@ static int get_sfb_slot(struct ibnd_node *node, ibnd_port_t * lineport)
>  		n->ch_anafanum = anafa_spine4_slot_2_slb[lineport->portnum];
>  	} else {
>  		IBND_ERROR("Unexpected node found: guid 0x%016" PRIx64,
> -			   node->node.guid);
> +			   node->guid);
>  		return (-1);
>  	}
>  	return (0);
>  }
>  
> -static int get_router_slot(struct ibnd_node *node, ibnd_port_t * spineport)
> +static int get_router_slot(ibnd_node_t * n, ibnd_port_t * spineport)
>  {
> -	ibnd_node_t *n = (ibnd_node_t *) node;
>  	uint64_t guessnum = 0;
>  
> -	node->ch_found = 1;
> +	n->ch_found = 1;
>  
>  	n->ch_slot = SRBD_CS;
> -	if (is_spine_9096(CONV_NODE_INTERNAL(spineport->node))) {
> +	if (is_spine_9096(spineport->node)) {
>  		n->ch_type = ISR9096_CT;
>  		n->ch_slotnum = line_slot_2_sfb4[spineport->portnum];
>  		n->ch_anafanum = ipr_slot_2_sfb4_port[spineport->portnum];
> -	} else if (is_spine_9288(CONV_NODE_INTERNAL(spineport->node))) {
> +	} else if (is_spine_9288(spineport->node)) {
>  		n->ch_type = ISR9288_CT;
>  		n->ch_slotnum = line_slot_2_sfb12[spineport->portnum];
>  		/* this is a smart guess based on nodeguids order on sFB-12 module */
> @@ -399,7 +398,7 @@ static int get_router_slot(struct ibnd_node *node, ibnd_port_t * spineport)
>  		/* module 2 <--> remote anafa 2 */
>  		/* module 3 <--> remote anafa 1 */
>  		n->ch_anafanum = (guessnum == 3 ? 1 : (guessnum == 1 ? 3 : 2));
> -	} else if (is_spine_2012(CONV_NODE_INTERNAL(spineport->node))) {
> +	} else if (is_spine_2012(spineport->node)) {
>  		n->ch_type = ISR2012_CT;
>  		n->ch_slotnum = line_slot_2_sfb12[spineport->portnum];
>  		/* this is a smart guess based on nodeguids order on sFB-12 module */
> @@ -408,7 +407,7 @@ static int get_router_slot(struct ibnd_node *node, ibnd_port_t * spineport)
>  		// module 2 <--> remote anafa 2
>  		// module 3 <--> remote anafa 1
>  		n->ch_anafanum = (guessnum == 3 ? 1 : (guessnum == 1 ? 3 : 2));
> -	} else if (is_spine_2004(CONV_NODE_INTERNAL(spineport->node))) {
> +	} else if (is_spine_2004(spineport->node)) {
>  		n->ch_type = ISR2004_CT;
>  		n->ch_slotnum = line_slot_2_sfb4[spineport->portnum];
>  		n->ch_anafanum = ipr_slot_2_sfb4_port[spineport->portnum];
> @@ -423,19 +422,19 @@ static int get_router_slot(struct ibnd_node *node, ibnd_port_t * spineport)
>  static int get_slb_slot(ibnd_node_t * n, ibnd_port_t * spineport)
>  {
>  	n->ch_slot = LINE_CS;
> -	if (is_spine_9096(CONV_NODE_INTERNAL(spineport->node))) {
> +	if (is_spine_9096(spineport->node)) {
>  		n->ch_type = ISR9096_CT;
>  		n->ch_slotnum = line_slot_2_sfb4[spineport->portnum];
>  		n->ch_anafanum = anafa_line_slot_2_sfb4[spineport->portnum];
> -	} else if (is_spine_9288(CONV_NODE_INTERNAL(spineport->node))) {
> +	} else if (is_spine_9288(spineport->node)) {
>  		n->ch_type = ISR9288_CT;
>  		n->ch_slotnum = line_slot_2_sfb12[spineport->portnum];
>  		n->ch_anafanum = anafa_line_slot_2_sfb12[spineport->portnum];
> -	} else if (is_spine_2012(CONV_NODE_INTERNAL(spineport->node))) {
> +	} else if (is_spine_2012(spineport->node)) {
>  		n->ch_type = ISR2012_CT;
>  		n->ch_slotnum = line_slot_2_sfb12[spineport->portnum];
>  		n->ch_anafanum = anafa_line_slot_2_sfb12[spineport->portnum];
> -	} else if (is_spine_2004(CONV_NODE_INTERNAL(spineport->node))) {
> +	} else if (is_spine_2004(spineport->node)) {
>  		n->ch_type = ISR2004_CT;
>  		n->ch_slotnum = line_slot_2_sfb4[spineport->portnum];
>  		n->ch_anafanum = anafa_line_slot_2_sfb4[spineport->portnum];
> @@ -454,12 +453,11 @@ static void voltaire_portmap(ibnd_port_t * port);
>  	It could be optimized so, but time overhead is very small
>  	and its only diag.util
>  */
> -static int fill_voltaire_chassis_record(struct ibnd_node *node)
> +static int fill_voltaire_chassis_record(ibnd_node_t * node)
>  {
> -	ibnd_node_t *n = (ibnd_node_t *) node;
>  	int p = 0;
>  	ibnd_port_t *port;
> -	struct ibnd_node *remnode = 0;
> +	ibnd_node_t *remnode = 0;
>  
>  	if (node->ch_found)	/* somehow this node has already been passed */
>  		return (0);
> @@ -470,25 +468,23 @@ static int fill_voltaire_chassis_record(struct ibnd_node *node)
>  	/* in such case node->ports is actually a requested port... */
>  	if (is_router(node)) {
>  		/* find the remote node */
> -		for (p = 1; p <= node->node.numports; p++) {
> -			port = node->node.ports[p];
> -			if (port &&
> -			    is_spine(CONV_NODE_INTERNAL
> -				     (port->remoteport->node)))
> +		for (p = 1; p <= node->numports; p++) {
> +			port = node->ports[p];
> +			if (port && is_spine(port->remoteport->node))
>  				get_router_slot(node, port->remoteport);
>  		}
>  	} else if (is_spine(node)) {
> -		for (p = 1; p <= node->node.numports; p++) {
> -			port = node->node.ports[p];
> +		for (p = 1; p <= node->numports; p++) {
> +			port = node->ports[p];
>  			if (!port || !port->remoteport)
>  				continue;
> -			remnode = CONV_NODE_INTERNAL(port->remoteport->node);
> -			if (remnode->node.type != IB_NODE_SWITCH) {
> +			remnode = port->remoteport->node;
> +			if (remnode->type != IB_NODE_SWITCH) {
>  				if (!remnode->ch_found)
>  					get_router_slot(remnode, port);
>  				continue;
>  			}
> -			if (!n->ch_type)
> +			if (!node->ch_type)
>  				/* we assume here that remoteport belongs to line */
>  				if (get_sfb_slot(node, port->remoteport))
>  					return (-1);
> @@ -497,20 +493,20 @@ static int fill_voltaire_chassis_record(struct ibnd_node *node)
>  		}
>  
>  	} else if (is_line(node)) {
> -		for (p = 1; p <= node->node.numports; p++) {
> -			port = node->node.ports[p];
> +		for (p = 1; p <= node->numports; p++) {
> +			port = node->ports[p];
>  			if (!port || port->portnum > 12 || !port->remoteport)
>  				continue;
>  			/* we assume here that remoteport belongs to spine */
> -			if (get_slb_slot(n, port->remoteport))
> +			if (get_slb_slot(node, port->remoteport))
>  				return (-1);
>  			break;
>  		}
>  	}
>  
>  	/* for each port of this node, map external ports */
> -	for (p = 1; p <= node->node.numports; p++) {
> -		port = node->node.ports[p];
> +	for (p = 1; p <= node->numports; p++) {
> +		port = node->ports[p];
>  		if (!port)
>  			continue;
>  		voltaire_portmap(port);
> @@ -534,8 +530,7 @@ static int get_spine_index(ibnd_node_t * node)
>  {
>  	int retval;
>  
> -	if (is_spine_9288(CONV_NODE_INTERNAL(node))
> -	    || is_spine_2012(CONV_NODE_INTERNAL(node)))
> +	if (is_spine_9288(node) || is_spine_2012(node))
>  		retval = 3 * (node->ch_slotnum - 1) + node->ch_anafanum;
>  	else
>  		retval = node->ch_slotnum;
> @@ -586,7 +581,7 @@ static int pass_on_lines_catch_spines(ibnd_chassis_t * chassis)
>  	for (i = 1; i <= LINES_MAX_NUM; i++) {
>  		node = chassis->linenode[i];
>  
> -		if (!(node && is_line(CONV_NODE_INTERNAL(node))))
> +		if (!(node && is_line(node)))
>  			continue;	/* empty slot or router */
>  
>  		for (p = 1; p <= node->numports; p++) {
> @@ -596,7 +591,7 @@ static int pass_on_lines_catch_spines(ibnd_chassis_t * chassis)
>  
>  			remnode = port->remoteport->node;
>  
> -			if (!CONV_NODE_INTERNAL(remnode)->ch_found)
> +			if (!remnode->ch_found)
>  				continue;	/* some error - spine not initialized ? FIXME */
>  			if (insert_spine(remnode, chassis))
>  				return (-1);
> @@ -621,7 +616,7 @@ static int pass_on_spines_catch_lines(ibnd_chassis_t * chassis)
>  				continue;
>  			remnode = port->remoteport->node;
>  
> -			if (!CONV_NODE_INTERNAL(remnode)->ch_found)
> +			if (!remnode->ch_found)
>  				continue;	/* some error - line/router not initialized ? FIXME */
>  			if (insert_line_router(remnode, chassis))
>  				return (-1);
> @@ -655,10 +650,10 @@ static void pass_on_spines_interpolate_chguid(ibnd_chassis_t * chassis)
>  	in that chassis
>  	chassis structure = structure of one standalone chassis
>  */
> -static int build_chassis(struct ibnd_node *node, ibnd_chassis_t * chassis)
> +static int build_chassis(ibnd_node_t * node, ibnd_chassis_t * chassis)
>  {
>  	int p = 0;
> -	struct ibnd_node *remnode = 0;
> +	ibnd_node_t *remnode = 0;
>  	ibnd_port_t *port = 0;
>  
>  	/* we get here with node = chassis_spine */
> @@ -666,16 +661,16 @@ static int build_chassis(struct ibnd_node *node, ibnd_chassis_t * chassis)
>  		return (-1);
>  
>  	/* loop: pass on all ports of node */
> -	for (p = 1; p <= node->node.numports; p++) {
> -		port = node->node.ports[p];
> +	for (p = 1; p <= node->numports; p++) {
> +		port = node->ports[p];
>  		if (!port || !port->remoteport)
>  			continue;
> -		remnode = CONV_NODE_INTERNAL(port->remoteport->node);
> +		remnode = port->remoteport->node;
>  
>  		if (!remnode->ch_found)
>  			continue;	/* some error - line or router not initialized ? FIXME */
>  
> -		insert_line_router(&(remnode->node), chassis);
> +		insert_line_router(remnode, chassis);
>  	}
>  
>  	if (pass_on_lines_catch_spines(chassis))
> @@ -764,13 +759,11 @@ int int2ext_map_slb2024[2][25] = {
>  /* map internal ports to external ports if appropriate */
>  static void voltaire_portmap(ibnd_port_t * port)
>  {
> -	struct ibnd_node *n = CONV_NODE_INTERNAL(port->node);
>  	int portnum = port->portnum;
>  	int chipnum = 0;
>  	ibnd_node_t *node = port->node;
>  
> -	if (!n->ch_found || !is_line(CONV_NODE_INTERNAL(node))
> -	    || (portnum < 13 || portnum > 24)) {
> +	if (!node->ch_found || !is_line(node) || (portnum < 13 || portnum > 24)) {
>  		port->ext_portnum = 0;
>  		return;
>  	}
> @@ -782,9 +775,9 @@ static void voltaire_portmap(ibnd_port_t * port)
>  
>  	chipnum = port->node->ch_anafanum - 1;
>  
> -	if (is_line_24(CONV_NODE_INTERNAL(node)))
> +	if (is_line_24(node))
>  		port->ext_portnum = int2ext_map_slb24[chipnum][portnum];
> -	else if (is_line_2024(CONV_NODE_INTERNAL(node)))
> +	else if (is_line_2024(node))
>  		port->ext_portnum = int2ext_map_slb2024[chipnum][portnum];
>  	else
>  		port->ext_portnum = int2ext_map_slb8[chipnum][portnum];
> @@ -828,7 +821,7 @@ static void add_node_to_chassis(ibnd_chassis_t * chassis, ibnd_node_t * node)
>  */
>  int group_nodes(struct ibnd_fabric *fabric)
>  {
> -	struct ibnd_node *node;
> +	ibnd_node_t *node;
>  	int dist;
>  	int chassisnum = 0;
>  	ibnd_chassis_t *chassis;
> @@ -842,7 +835,7 @@ int group_nodes(struct ibnd_fabric *fabric)
>  	/* not very efficient but clear code so... */
>  	for (dist = 0; dist <= fabric->fabric.maxhops_discovered; dist++) {
>  		for (node = fabric->nodesdist[dist]; node; node = node->dnext) {
> -			if (mad_get_field(node->node.info, 0,
> +			if (mad_get_field(node->info, 0,
>  					  IB_NODE_VENDORID_F) == VTR_VENDOR_ID)
>  				if (fill_voltaire_chassis_record(node))
>  					return (-1);
> @@ -853,13 +846,11 @@ int group_nodes(struct ibnd_fabric *fabric)
>  	/* algorithm: catch spine and find all surrounding nodes */
>  	for (dist = 0; dist <= fabric->fabric.maxhops_discovered; dist++) {
>  		for (node = fabric->nodesdist[dist]; node; node = node->dnext) {
> -			if (mad_get_field(node->node.info, 0,
> +			if (mad_get_field(node->info, 0,
>  					  IB_NODE_VENDORID_F) != VTR_VENDOR_ID)
>  				continue;
> -			//if (!node->node.chrecord || node->node.chrecord->chassisnum || !is_spine(node))
>  			if (!node->ch_found
> -			    || (node->node.chassis
> -				&& node->node.chassis->chassisnum)
> +			    || (node->chassis && node->chassis->chassisnum)
>  			    || !is_spine(node))
>  				continue;
>  			if (add_chassis(fabric))
> @@ -874,10 +865,10 @@ int group_nodes(struct ibnd_fabric *fabric)
>  	/* grouped by common SystemImageGUID */
>  	for (dist = 0; dist <= fabric->fabric.maxhops_discovered; dist++) {
>  		for (node = fabric->nodesdist[dist]; node; node = node->dnext) {
> -			if (mad_get_field(node->node.info, 0,
> +			if (mad_get_field(node->info, 0,
>  					  IB_NODE_VENDORID_F) == VTR_VENDOR_ID)
>  				continue;
> -			if (mad_get_field64(node->node.info, 0,
> +			if (mad_get_field64(node->info, 0,
>  					    IB_NODE_SYSTEM_GUID_F)) {
>  				chassis =
>  				    find_chassisguid(fabric,
> @@ -901,10 +892,10 @@ int group_nodes(struct ibnd_fabric *fabric)
>  	/* (defined as chassis->nodecount > 1) */
>  	for (dist = 0; dist <= MAXHOPS;) {
>  		for (node = fabric->nodesdist[dist]; node; node = node->dnext) {
> -			if (mad_get_field(node->node.info, 0,
> +			if (mad_get_field(node->info, 0,
>  					  IB_NODE_VENDORID_F) == VTR_VENDOR_ID)
>  				continue;
> -			if (mad_get_field64(node->node.info, 0,
> +			if (mad_get_field64(node->info, 0,
>  					    IB_NODE_SYSTEM_GUID_F)) {
>  				chassis =
>  				    find_chassisguid(fabric,
> diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
> index b33be8d..b883d4a 100644
> --- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
> +++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
> @@ -98,18 +98,17 @@ static int get_port_info(struct ibmad_port *ibmad_port,
>   * Returns -1 if error.
>   */
>  static int query_node_info(struct ibmad_port *ibmad_port,
> -			   struct ibnd_fabric *fabric, struct ibnd_node *node,
> +			   struct ibnd_fabric *fabric, ibnd_node_t * node,
>  			   ib_portid_t * portid)
>  {
> -	if (!smp_query_via(&(node->node.info), portid, IB_ATTR_NODE_INFO, 0, 0,
> +	if (!smp_query_via(&(node->info), portid, IB_ATTR_NODE_INFO, 0, 0,
>  			   ibmad_port))
>  		return -1;
>  
>  	/* decode just a couple of fields for quicker reference. */
> -	mad_decode_field(node->node.info, IB_NODE_GUID_F, &(node->node.guid));
> -	mad_decode_field(node->node.info, IB_NODE_TYPE_F, &(node->node.type));
> -	mad_decode_field(node->node.info, IB_NODE_NPORTS_F,
> -			 &(node->node.numports));
> +	mad_decode_field(node->info, IB_NODE_GUID_F, &(node->guid));
> +	mad_decode_field(node->info, IB_NODE_TYPE_F, &(node->type));
> +	mad_decode_field(node->info, IB_NODE_NPORTS_F, &(node->numports));
>  
>  	return (0);
>  }
> @@ -118,15 +117,14 @@ static int query_node_info(struct ibmad_port *ibmad_port,
>   * Returns 0 if non switch node is found, 1 if switch is found, -1 if error.
>   */
>  static int query_node(struct ibmad_port *ibmad_port, struct ibnd_fabric *fabric,
> -		      struct ibnd_node *inode, struct ibnd_port *iport,
> +		      ibnd_node_t * node, struct ibnd_port *iport,
>  		      ib_portid_t * portid)
>  {
>  	int rc = 0;
> -	ibnd_node_t *node = &(inode->node);
>  	ibnd_port_t *port = &(iport->port);
> -	void *nd = inode->node.nodedesc;
> +	void *nd = node->nodedesc;
>  
> -	if ((rc = query_node_info(ibmad_port, fabric, inode, portid)) != 0)
> +	if ((rc = query_node_info(ibmad_port, fabric, node, portid)) != 0)
>  		return rc;
>  
>  	port->portnum = mad_get_field(node->info, 0, IB_NODE_LOCAL_PORT_F);
> @@ -204,30 +202,30 @@ static int extend_dpath(struct ibmad_port *ibmad_port, struct ibnd_fabric *f,
>  }
>  
>  static void dump_endnode(ib_portid_t * path, char *prompt,
> -			 struct ibnd_node *node, struct ibnd_port *port)
> +			 ibnd_node_t * node, struct ibnd_port *port)
>  {
>  	char type[64];
>  	if (!show_progress)
>  		return;
>  
> -	mad_dump_node_type(type, 64, &(node->node.type), sizeof(int));
> -
> -	printf("%s -> %s %s {%016" PRIx64 "} portnum %d base lid %d-%d\"%s\"\n",
> -	       portid2str(path), prompt, type, node->node.guid,
> -	       node->node.type == IB_NODE_SWITCH ? 0 : port->port.portnum,
> -	       port->port.base_lid,
> -	       port->port.base_lid + (1 << port->port.lmc) - 1,
> -	       node->node.nodedesc);
> +	mad_dump_node_type(type, 64, &(node->type), sizeof(int)),
> +	    printf("%s -> %s %s {%016" PRIx64
> +		   "} portnum %d base lid %d-%d\"%s\"\n", portid2str(path),
> +		   prompt, type, node->guid,
> +		   node->type == IB_NODE_SWITCH ? 0 : port->port.portnum,
> +		   port->port.base_lid,
> +		   port->port.base_lid + (1 << port->port.lmc) - 1,
> +		   node->nodedesc);
>  }
>  
> -static struct ibnd_node *find_existing_node(struct ibnd_fabric *fabric,
> -					    struct ibnd_node *new)
> +static ibnd_node_t *find_existing_node(struct ibnd_fabric *fabric,
> +				       ibnd_node_t * new)
>  {
> -	int hash = HASHGUID(new->node.guid) % HTSZ;
> -	struct ibnd_node *node;
> +	int hash = HASHGUID(new->guid) % HTSZ;
> +	ibnd_node_t *node;
>  
>  	for (node = fabric->nodestbl[hash]; node; node = node->htnext)
> -		if (node->node.guid == new->node.guid)
> +		if (node->guid == new->guid)
>  			return node;
>  
>  	return NULL;
> @@ -237,7 +235,7 @@ ibnd_node_t *ibnd_find_node_guid(ibnd_fabric_t * fabric, uint64_t guid)
>  {
>  	struct ibnd_fabric *f = CONV_FABRIC_INTERNAL(fabric);
>  	int hash = HASHGUID(guid) % HTSZ;
> -	struct ibnd_node *node;
> +	ibnd_node_t *node;
>  
>  	if (!fabric) {
>  		IBND_DEBUG("fabric parameter NULL\n");
> @@ -245,7 +243,7 @@ ibnd_node_t *ibnd_find_node_guid(ibnd_fabric_t * fabric, uint64_t guid)
>  	}
>  
>  	for (node = f->nodestbl[hash]; node; node = node->htnext)
> -		if (node->node.guid == guid)
> +		if (node->guid == guid)
>  			return (ibnd_node_t *) node;
>  
>  	return NULL;
> @@ -273,7 +271,6 @@ ibnd_node_t *ibnd_update_node(struct ibmad_port * ibmad_port,
>  	void *nd = node->nodedesc;
>  	int p = 0;
>  	struct ibnd_fabric *f = CONV_FABRIC_INTERNAL(fabric);
> -	struct ibnd_node *n = CONV_NODE_INTERNAL(node);
>  
>  	if (_check_ibmad_port(ibmad_port) < 0)
>  		return (NULL);
> @@ -288,36 +285,36 @@ ibnd_node_t *ibnd_update_node(struct ibmad_port * ibmad_port,
>  		return (NULL);
>  	}
>  
> -	if (query_node_info(ibmad_port, f, n, &(n->node.path_portid)))
> +	if (query_node_info(ibmad_port, f, node, &(node->path_portid)))
>  		return (NULL);
>  
> -	if (!smp_query_via(nd, &(n->node.path_portid), IB_ATTR_NODE_DESC, 0, 0,
> +	if (!smp_query_via(nd, &(node->path_portid), IB_ATTR_NODE_DESC, 0, 0,
>  			   ibmad_port))
>  		return (NULL);
>  
>  	/* update all the port info's */
> -	for (p = 1; p >= n->node.numports; p++) {
> -		get_port_info(ibmad_port, f,
> -			      CONV_PORT_INTERNAL(n->node.ports[p]), p,
> -			      &(n->node.path_portid));
> +	for (p = 1; p >= node->numports; p++) {
> +		get_port_info(ibmad_port, f, CONV_PORT_INTERNAL(node->ports[p]),
> +			      p, &(node->path_portid));
>  	}
>  
> -	if (n->node.type != IB_NODE_SWITCH)
> +	if (node->type != IB_NODE_SWITCH)
>  		goto done;
>  
> -	if (!smp_query_via(portinfo_port0, &(n->node.path_portid),
> -			   IB_ATTR_PORT_INFO, 0, 0, ibmad_port))
> +	if (!smp_query_via
> +	    (portinfo_port0, &(node->path_portid), IB_ATTR_PORT_INFO, 0, 0,
> +	     ibmad_port))
>  		return (NULL);
>  
> -	n->node.smalid = mad_get_field(portinfo_port0, 0, IB_PORT_LID_F);
> -	n->node.smalmc = mad_get_field(portinfo_port0, 0, IB_PORT_LMC_F);
> +	node->smalid = mad_get_field(portinfo_port0, 0, IB_PORT_LID_F);
> +	node->smalmc = mad_get_field(portinfo_port0, 0, IB_PORT_LMC_F);
>  
> -	if (!smp_query_via(node->switchinfo, &(n->node.path_portid),
> +	if (!smp_query_via(node->switchinfo, &(node->path_portid),
>  			   IB_ATTR_SWITCH_INFO, 0, 0, ibmad_port))
>  		node->smaenhsp0 = 0;	/* assume base SP0 */
>  	else
>  		mad_decode_field(node->switchinfo, IB_SW_ENHANCED_PORT0_F,
> -				 &n->node.smaenhsp0);
> +				 &node->smaenhsp0);
>  
>  done:
>  	return (node);
> @@ -358,10 +355,9 @@ ibnd_node_t *ibnd_find_node_dr(ibnd_fabric_t * fabric, char *dr_str)
>  	return (rc);
>  }
>  
> -static void add_to_nodeguid_hash(struct ibnd_node *node,
> -				 struct ibnd_node *hash[])
> +static void add_to_nodeguid_hash(ibnd_node_t * node, ibnd_node_t * hash[])
>  {
> -	int hash_idx = HASHGUID(node->node.guid) % HTSZ;
> +	int hash_idx = HASHGUID(node->guid) % HTSZ;
>  
>  	node->htnext = hash[hash_idx];
>  	hash[hash_idx] = node;
> @@ -376,9 +372,9 @@ static void add_to_portguid_hash(struct ibnd_port *port,
>  	hash[hash_idx] = port;
>  }
>  
> -static void add_to_type_list(struct ibnd_node *node, struct ibnd_fabric *fabric)
> +static void add_to_type_list(ibnd_node_t * node, struct ibnd_fabric *fabric)
>  {
> -	switch (node->node.type) {
> +	switch (node->type) {
>  	case IB_NODE_CA:
>  		node->type_next = fabric->ch_adapters;
>  		fabric->ch_adapters = node;
> @@ -394,21 +390,21 @@ static void add_to_type_list(struct ibnd_node *node, struct ibnd_fabric *fabric)
>  	}
>  }
>  
> -static void add_to_nodedist(struct ibnd_node *node, struct ibnd_fabric *fabric)
> +static void add_to_nodedist(ibnd_node_t * node, struct ibnd_fabric *fabric)
>  {
> -	int dist = node->node.dist;
> -	if (node->node.type != IB_NODE_SWITCH)
> +	int dist = node->dist;
> +	if (node->type != IB_NODE_SWITCH)
>  		dist = MAXHOPS;	/* special Ca list */
>  
>  	node->dnext = fabric->nodesdist[dist];
>  	fabric->nodesdist[dist] = node;
>  }
>  
> -static struct ibnd_node *create_node(struct ibnd_fabric *fabric,
> -				     struct ibnd_node *temp, ib_portid_t * path,
> -				     int dist)
> +static ibnd_node_t *create_node(struct ibnd_fabric *fabric,
> +				ibnd_node_t * temp, ib_portid_t * path,
> +				int dist)
>  {
> -	struct ibnd_node *node;
> +	ibnd_node_t *node;
>  
>  	node = malloc(sizeof(*node));
>  	if (!node) {
> @@ -417,13 +413,13 @@ static struct ibnd_node *create_node(struct ibnd_fabric *fabric,
>  	}
>  
>  	memcpy(node, temp, sizeof(*node));
> -	node->node.dist = dist;
> -	node->node.path_portid = *path;
> +	node->dist = dist;
> +	node->path_portid = *path;
>  
>  	add_to_nodeguid_hash(node, fabric->nodestbl);
>  
>  	/* add this to the all nodes list */
> -	node->node.next = fabric->fabric.nodes;
> +	node->next = fabric->fabric.nodes;
>  	fabric->fabric.nodes = (ibnd_node_t *) node;
>  
>  	add_to_type_list(node, fabric);
> @@ -432,26 +428,24 @@ static struct ibnd_node *create_node(struct ibnd_fabric *fabric,
>  	return node;
>  }
>  
> -static struct ibnd_port *find_existing_port_node(struct ibnd_node *node,
> +static struct ibnd_port *find_existing_port_node(ibnd_node_t * node,
>  						 struct ibnd_port *port)
>  {
> -	if (port->port.portnum > node->node.numports
> -	    || node->node.ports == NULL)
> +	if (port->port.portnum > node->numports || node->ports == NULL)
>  		return (NULL);
>  
> -	return (CONV_PORT_INTERNAL(node->node.ports[port->port.portnum]));
> +	return (CONV_PORT_INTERNAL(node->ports[port->port.portnum]));
>  }
>  
>  static struct ibnd_port *add_port_to_node(struct ibnd_fabric *fabric,
> -					  struct ibnd_node *node,
> +					  ibnd_node_t * node,
>  					  struct ibnd_port *temp)
>  {
>  	struct ibnd_port *port;
>  
> -	if (node->node.ports == NULL) {
> -		node->node.ports =
> -		    calloc(sizeof(*node->node.ports), node->node.numports + 1);
> -		if (!node->node.ports) {
> +	if (node->ports == NULL) {
> +		node->ports = calloc(sizeof(*node->ports), node->numports + 1);
> +		if (!node->ports) {
>  			IBND_ERROR("Failed to allocate the ports array\n");
>  			return (NULL);
>  		}
> @@ -467,20 +461,19 @@ static struct ibnd_port *add_port_to_node(struct ibnd_fabric *fabric,
>  	port->port.node = (ibnd_node_t *) node;
>  	port->port.ext_portnum = 0;
>  
> -	node->node.ports[temp->port.portnum] = (ibnd_port_t *) port;
> +	node->ports[temp->port.portnum] = (ibnd_port_t *) port;
>  
>  	add_to_portguid_hash(port, fabric->portstbl);
>  	return port;
>  }
>  
> -static void link_ports(struct ibnd_node *node, struct ibnd_port *port,
> -		       struct ibnd_node *remotenode,
> -		       struct ibnd_port *remoteport)
> +static void link_ports(ibnd_node_t * node, struct ibnd_port *port,
> +		       ibnd_node_t * remotenode, struct ibnd_port *remoteport)
>  {
>  	IBND_DEBUG("linking: 0x%" PRIx64 " %p->%p:%u and 0x%" PRIx64
> -		   " %p->%p:%u\n", node->node.guid, node, port,
> -		   port->port.portnum, remotenode->node.guid, remotenode,
> -		   remoteport, remoteport->port.portnum);
> +		   " %p->%p:%u\n", node->guid, node, port, port->port.portnum,
> +		   remotenode->guid, remotenode, remoteport,
> +		   remoteport->port.portnum);
>  	if (port->port.remoteport)
>  		port->port.remoteport->remoteport = NULL;
>  	if (remoteport->port.remoteport)
> @@ -490,14 +483,14 @@ static void link_ports(struct ibnd_node *node, struct ibnd_port *port,
>  }
>  
>  static int get_remote_node(struct ibmad_port *ibmad_port,
> -			   struct ibnd_fabric *fabric, struct ibnd_node *node,
> +			   struct ibnd_fabric *fabric, ibnd_node_t * node,
>  			   struct ibnd_port *port, ib_portid_t * path,
>  			   int portnum, int dist)
>  {
>  	int rc = 0;
> -	struct ibnd_node node_buf;
> +	ibnd_node_t node_buf;
>  	struct ibnd_port port_buf;
> -	struct ibnd_node *remotenode, *oldnode;
> +	ibnd_node_t *remotenode, *oldnode;
>  	struct ibnd_port *remoteport, *oldport;
>  
>  	memset(&node_buf, 0, sizeof(node_buf));
> @@ -554,9 +547,9 @@ ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port * ibmad_port,
>  	int rc = 0;
>  	struct ibnd_fabric *fabric = NULL;
>  	ib_portid_t my_portid = { 0 };
> -	struct ibnd_node node_buf;
> +	ibnd_node_t node_buf;
>  	struct ibnd_port port_buf;
> -	struct ibnd_node *node;
> +	ibnd_node_t *node;
>  	struct ibnd_port *port;
>  	int i;
>  	int dist = 0;
> @@ -605,7 +598,7 @@ ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port * ibmad_port,
>  		goto error;
>  
>  	rc = get_remote_node(ibmad_port, fabric, node, port, from,
> -			     mad_get_field(node->node.info, 0,
> +			     mad_get_field(node->info, 0,
>  					   IB_NODE_LOCAL_PORT_F), 0);
>  	if (rc < 0)
>  		goto error;
> @@ -616,13 +609,13 @@ ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port * ibmad_port,
>  
>  		for (node = fabric->nodesdist[dist]; node; node = node->dnext) {
>  
> -			path = &node->node.path_portid;
> +			path = &node->path_portid;
>  
>  			IBND_DEBUG("dist %d node %p\n", dist, node);
>  			dump_endnode(path, "processing", node, port);
>  
> -			for (i = 1; i <= node->node.numports; i++) {
> -				if (i == mad_get_field(node->node.info, 0,
> +			for (i = 1; i <= node->numports; i++) {
> +				if (i == mad_get_field(node->info, 0,
>  						       IB_NODE_LOCAL_PORT_F))
>  					continue;
>  
> @@ -644,9 +637,9 @@ ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port * ibmad_port,
>  					goto error;
>  
>  				/* If switch, set port GUID to node port GUID */
> -				if (node->node.type == IB_NODE_SWITCH) {
> +				if (node->type == IB_NODE_SWITCH) {
>  					port->port.guid =
> -					    mad_get_field64(node->node.info, 0,
> +					    mad_get_field64(node->info, 0,
>  							    IB_NODE_PORT_GUID_F);
>  				}
>  
> @@ -666,14 +659,14 @@ error:
>  	return (NULL);
>  }
>  
> -static void destroy_node(struct ibnd_node *node)
> +static void destroy_node(ibnd_node_t * node)
>  {
>  	int p = 0;
>  
> -	for (p = 0; p <= node->node.numports; p++) {
> -		free(node->node.ports[p]);
> +	for (p = 0; p <= node->numports; p++) {
> +		free(node->ports[p]);
>  	}
> -	free(node->node.ports);
> +	free(node->ports);
>  	free(node);
>  }
>  
> @@ -681,8 +674,8 @@ void ibnd_destroy_fabric(ibnd_fabric_t * fabric)
>  {
>  	struct ibnd_fabric *f = CONV_FABRIC_INTERNAL(fabric);
>  	int dist = 0;
> -	struct ibnd_node *node = NULL;
> -	struct ibnd_node *next = NULL;
> +	ibnd_node_t *node = NULL;
> +	ibnd_node_t *next = NULL;
>  	ibnd_chassis_t *ch, *ch_next;
>  
>  	if (!fabric)
> @@ -747,8 +740,8 @@ void ibnd_iter_nodes_type(ibnd_fabric_t * fabric, ibnd_iter_node_func_t func,
>  			  int node_type, void *user_data)
>  {
>  	struct ibnd_fabric *f = CONV_FABRIC_INTERNAL(fabric);
> -	struct ibnd_node *list = NULL;
> -	struct ibnd_node *cur = NULL;
> +	ibnd_node_t *list = NULL;
> +	ibnd_node_t *cur = NULL;
>  
>  	if (!fabric) {
>  		IBND_DEBUG("fabric parameter NULL\n");
> diff --git a/infiniband-diags/libibnetdisc/src/internal.h b/infiniband-diags/libibnetdisc/src/internal.h
> index 38555a0..449bd70 100644
> --- a/infiniband-diags/libibnetdisc/src/internal.h
> +++ b/infiniband-diags/libibnetdisc/src/internal.h
> @@ -49,18 +49,6 @@
>  #define	IBND_ERROR(fmt, ...) \
>  		fprintf(stderr, "%s:%u; " fmt, __FILE__, __LINE__, ## __VA_ARGS__)
>  
> -struct ibnd_node {
> -	/* This member MUST BE FIRST */
> -	ibnd_node_t node;
> -
> -	/* internal use only */
> -	unsigned char ch_found;
> -	struct ibnd_node *htnext;	/* hash table list */
> -	struct ibnd_node *dnext;	/* nodesdist next */
> -	struct ibnd_node *type_next;	/* next based on type */
> -};
> -#define CONV_NODE_INTERNAL(node) ((struct ibnd_node *)node)
> -
>  struct ibnd_port {
>  	/* This member MUST BE FIRST */
>  	ibnd_port_t port;
> @@ -79,15 +67,15 @@ struct ibnd_fabric {
>  	ibnd_fabric_t fabric;
>  
>  	/* internal use only */
> -	struct ibnd_node *nodestbl[HTSZ];
> +	ibnd_node_t *nodestbl[HTSZ];
>  	struct ibnd_port *portstbl[HTSZ];
> -	struct ibnd_node *nodesdist[MAXHOPS + 1];
> +	ibnd_node_t *nodesdist[MAXHOPS + 1];
>  	ibnd_chassis_t *first_chassis;
>  	ibnd_chassis_t *current_chassis;
>  	ibnd_chassis_t *last_chassis;
> -	struct ibnd_node *switches;
> -	struct ibnd_node *ch_adapters;
> -	struct ibnd_node *routers;
> +	ibnd_node_t *switches;
> +	ibnd_node_t *ch_adapters;
> +	ibnd_node_t *routers;
>  	ib_portid_t selfportid;
>  };
>  #define CONV_FABRIC_INTERNAL(fabric) ((struct ibnd_fabric *)fabric)
> -- 
> 1.5.4.5
> 



More information about the general mailing list