[ofa-general] [infiniband-diags] [PATCH] [1/5] libibnetdisc cleanup patches

Al Chu chu11 at llnl.gov
Tue Jul 7 15:24:26 PDT 2009


Make api more consistent by removing convenience pointer from
ibnd_node_t and requiring ibnd_fabric_t passed to all functions (in this
case ibnd_update_node).

Al

-- 
Albert Chu
chu11 at llnl.gov
Computer Scientist
High Performance Systems Division
Lawrence Livermore National Laboratory
-------------- next part --------------
>From a6f7c6bea7f3549bb0bd24a4304f9dc3aa4b73ac Mon Sep 17 00:00:00 2001
From: Albert Chu <chu11 at llnl.gov>
Date: Tue, 7 Jul 2009 09:57:26 -0700
Subject: [PATCH] Make api more consistent by removing convenience pointer from ibnd_node_t and requiring ibnd_fabric_t passed to all functions (in this case ibnd_update_node).

Signed-off-by: Albert Chu <chu11 at llnl.gov>
Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
---
 .../libibnetdisc/include/infiniband/ibnetdisc.h    |    3 +--
 infiniband-diags/libibnetdisc/src/chassis.c        |    7 +++----
 infiniband-diags/libibnetdisc/src/ibnetdisc.c      |    5 ++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
index c7d293c..5f07805 100644
--- a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
+++ b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
@@ -47,7 +47,6 @@ struct port; /* forward declare */
  */
 typedef struct node {
 	struct node *next; /* all node list in fabric */
-	struct ib_fabric *fabric; /* the fabric node belongs to */
 
 	ib_portid_t path_portid; /* path from "from_node" */
 	int dist; /* num of hops from "from_node" */
@@ -161,7 +160,7 @@ MAD_EXPORT void ibnd_destroy_fabric(ibnd_fabric_t *fabric);
  */
 MAD_EXPORT ibnd_node_t *ibnd_find_node_guid(ibnd_fabric_t *fabric, uint64_t guid);
 MAD_EXPORT ibnd_node_t *ibnd_find_node_dr(ibnd_fabric_t *fabric, char *dr_str);
-MAD_EXPORT ibnd_node_t *ibnd_update_node(ibnd_node_t *node);
+MAD_EXPORT ibnd_node_t *ibnd_update_node(ibnd_fabric_t *fabric, ibnd_node_t *node);
 
 typedef void (*ibnd_iter_node_func_t)(ibnd_node_t *node, void *user_data);
 MAD_EXPORT void         ibnd_iter_nodes(ibnd_fabric_t *fabric,
diff --git a/infiniband-diags/libibnetdisc/src/chassis.c b/infiniband-diags/libibnetdisc/src/chassis.c
index dbb0abe..78aee1f 100644
--- a/infiniband-diags/libibnetdisc/src/chassis.c
+++ b/infiniband-diags/libibnetdisc/src/chassis.c
@@ -197,9 +197,8 @@ static uint64_t get_chassisguid(ibnd_node_t *node)
 		return sysimgguid;
 }
 
-static ibnd_chassis_t *find_chassisguid(ibnd_node_t *node)
+static ibnd_chassis_t *find_chassisguid(struct ibnd_fabric *f, ibnd_node_t *node)
 {
-	struct ibnd_fabric *f = CONV_FABRIC_INTERNAL(node->fabric);
 	ibnd_chassis_t *current;
 	uint64_t chguid;
 
@@ -790,7 +789,7 @@ ibnd_chassis_t *group_nodes(struct ibnd_fabric *fabric)
 			if (mad_get_field(node->node.info, 0, IB_NODE_VENDORID_F) == VTR_VENDOR_ID)
 				continue;
 			if (mad_get_field64(node->node.info, 0, IB_NODE_SYSTEM_GUID_F)) {
-				chassis = find_chassisguid((ibnd_node_t *)node);
+				chassis = find_chassisguid(fabric, (ibnd_node_t *)node);
 				if (chassis)
 					chassis->nodecount++;
 				else {
@@ -811,7 +810,7 @@ ibnd_chassis_t *group_nodes(struct ibnd_fabric *fabric)
 			if (mad_get_field(node->node.info, 0, IB_NODE_VENDORID_F) == VTR_VENDOR_ID)
 				continue;
 			if (mad_get_field64(node->node.info, 0, IB_NODE_SYSTEM_GUID_F)) {
-				chassis = find_chassisguid((ibnd_node_t *)node);
+				chassis = find_chassisguid(fabric, (ibnd_node_t *)node);
 				if (chassis && chassis->nodecount > 1) {
 					if (!chassis->chassisnum)
 						chassis->chassisnum = ++chassisnum;
diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
index baea98e..b640bc1 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
@@ -245,12 +245,12 @@ ibnd_find_node_guid(ibnd_fabric_t *fabric, uint64_t guid)
 }
 
 ibnd_node_t *
-ibnd_update_node(ibnd_node_t *node)
+ibnd_update_node(ibnd_fabric_t *fabric, ibnd_node_t *node)
 {
 	char portinfo_port0[IB_SMP_DATA_SIZE];
 	void *nd = node->nodedesc;
 	int p = 0;
-	struct ibnd_fabric *f = CONV_FABRIC_INTERNAL(node->fabric);
+	struct ibnd_fabric *f = CONV_FABRIC_INTERNAL(fabric);
 	struct ibnd_node *n = CONV_NODE_INTERNAL(node);
 
 	if (query_node_info(f, n, &(n->node.path_portid)))
@@ -377,7 +377,6 @@ create_node(struct ibnd_fabric *fabric, struct ibnd_node *temp, ib_portid_t *pat
 	memcpy(node, temp, sizeof(*node));
 	node->node.dist = dist;
 	node->node.path_portid = *path;
-	node->node.fabric = (ibnd_fabric_t *)fabric;
 
 	add_to_nodeguid_hash(node, fabric->nodestbl);
 
-- 
1.5.4.5



More information about the general mailing list