[ofa-general] Re: [PATCH 1/6] [ib-diag] ibnetdiscover: add support for WinOF

Sasha Khapyorsky sashak at voltaire.com
Thu Feb 26 02:05:21 PST 2009


Hi Sean,

On 17:46 Wed 18 Feb     , Sean Hefty wrote:
> Mainly fixing datatypes to avoid type mismatches.
> 
> Signed-off-by: Sean Hefty <sean.hefty at intel.com>
> ---
> Also attaching patch in case my mailer wraps the lines.
> 
>  infiniband-diags/src/grouping.c      |   28 ++++++++++++++--------------
>  infiniband-diags/src/ibnetdiscover.c |    8 ++++----
>  2 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/infiniband-diags/src/grouping.c b/infiniband-diags/src/grouping.c
> index 0ea139f..0266af4 100644
> --- a/infiniband-diags/src/grouping.c
> +++ b/infiniband-diags/src/grouping.c
> @@ -265,20 +265,20 @@ int is_chassis_switch(Node *node)
>  }
>  
>  /* these structs help find Line (Anafa) slot number while using spine portnum */
> -int line_slot_2_sfb4[25]        = { 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4 };
> -int anafa_line_slot_2_sfb4[25]  = { 0, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2 };
> -int line_slot_2_sfb12[25]       = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10, 10, 11, 11, 12, 12 };
> -int anafa_line_slot_2_sfb12[25] = { 0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 };
> +char line_slot_2_sfb4[25]        = { 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4 };
> +char anafa_line_slot_2_sfb4[25]  = { 0, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2 };
> +char line_slot_2_sfb12[25]       = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10, 10, 11, 11, 12, 12 };
> +char anafa_line_slot_2_sfb12[25] = { 0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 };
>  
>  /* IPR FCR modules connectivity while using sFB4 port as reference */
> -int ipr_slot_2_sfb4_port[25]    = { 0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1 };
> +char ipr_slot_2_sfb4_port[25]    = { 0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1 };
>  
>  /* these structs help find Spine (Anafa) slot number while using spine portnum */
> -int spine12_slot_2_slb[25]      = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
> -int anafa_spine12_slot_2_slb[25]= { 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
> -int spine4_slot_2_slb[25]       = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
> -int anafa_spine4_slot_2_slb[25] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
> -/*	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 };
> */
> +char spine12_slot_2_slb[25]      = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
> +char anafa_spine12_slot_2_slb[25]= { 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
> +char spine4_slot_2_slb[25]       = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
> +char anafa_spine4_slot_2_slb[25] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
> +/* 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 void get_sfb_slot(Node *node, Port *lineport)
>  {
> @@ -309,7 +309,7 @@ static void get_sfb_slot(Node *node, Port *lineport)
>  static void get_router_slot(Node *node, Port *spineport)
>  {
>  	ChassisRecord *ch = node->chrecord;
> -	int guessnum = 0;
> +	uint64_t guessnum = 0;
>  
>  	if (!ch) {
>  		if (!(node->chrecord = calloc(1, sizeof(ChassisRecord))))
> @@ -460,7 +460,7 @@ static void insert_line_router(Node *node, ChassisList *chassislist)
>  		return;		/* already filled slot */
>  
>  	chassislist->linenode[i] = node;
> -	node->chrecord->chassisnum = chassislist->chassisnum;
> +	node->chrecord->chassisnum = (unsigned char) chassislist->chassisnum;
>  }
>  
>  static void insert_spine(Node *node, ChassisList *chassislist)
> @@ -471,7 +471,7 @@ static void insert_spine(Node *node, ChassisList *chassislist)
>  		return;		/* already filled slot */
>  
>  	chassislist->spinenode[i] = node;
> -	node->chrecord->chassisnum = chassislist->chassisnum;
> +	node->chrecord->chassisnum = (unsigned char) chassislist->chassisnum;

Wouldn't it be better to try to fix data definitions and minimize such
and similar castings? For instance could slightly modified patch like
below compile cleanly in WinOF environment (I cannot test, sorry)?

Sasha


>From 8e8556ba011dab628723736aa32191f54cca4cb5 Mon Sep 17 00:00:00 2001
From: Sean Hefty <sean.hefty at intel.com>
Date: Wed, 18 Feb 2009 17:46:05 -0800
Subject: [PATCH] ibnetdiscover: add support for WinOF

Mainly fixing datatypes to avoid type mismatches.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 infiniband-diags/include/grouping.h  |    6 +++---
 infiniband-diags/src/grouping.c      |   22 +++++++++++-----------
 infiniband-diags/src/ibnetdiscover.c |    8 ++++----
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/infiniband-diags/include/grouping.h b/infiniband-diags/include/grouping.h
index e54efef..811e372 100644
--- a/infiniband-diags/include/grouping.h
+++ b/infiniband-diags/include/grouping.h
@@ -48,9 +48,9 @@ typedef struct AllChassisList AllChassisList;
 struct ChassisList {
 	ChassisList *next;
 	uint64_t chassisguid;
-	int chassisnum;
-	int chassistype;
-	int nodecount;		/* used for grouping by SystemImageGUID */
+	unsigned char chassisnum;
+	unsigned char chassistype;
+	unsigned int nodecount;	  /* used for grouping by SystemImageGUID */
 	Node *spinenode[SPINES_MAX_NUM + 1];
 	Node *linenode[LINES_MAX_NUM + 1];
 };
diff --git a/infiniband-diags/src/grouping.c b/infiniband-diags/src/grouping.c
index 0ea139f..048efc7 100644
--- a/infiniband-diags/src/grouping.c
+++ b/infiniband-diags/src/grouping.c
@@ -265,20 +265,20 @@ int is_chassis_switch(Node *node)
 }
 
 /* these structs help find Line (Anafa) slot number while using spine portnum */
-int line_slot_2_sfb4[25]        = { 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4 };
-int anafa_line_slot_2_sfb4[25]  = { 0, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2 };
-int line_slot_2_sfb12[25]       = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10, 10, 11, 11, 12, 12 };
-int anafa_line_slot_2_sfb12[25] = { 0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 };
+char line_slot_2_sfb4[25]        = { 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4 };
+char anafa_line_slot_2_sfb4[25]  = { 0, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2 };
+char line_slot_2_sfb12[25]       = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10, 10, 11, 11, 12, 12 };
+char anafa_line_slot_2_sfb12[25] = { 0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 };
 
 /* IPR FCR modules connectivity while using sFB4 port as reference */
-int ipr_slot_2_sfb4_port[25]    = { 0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1 };
+char ipr_slot_2_sfb4_port[25]    = { 0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1 };
 
 /* these structs help find Spine (Anafa) slot number while using spine portnum */
-int spine12_slot_2_slb[25]      = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-int anafa_spine12_slot_2_slb[25]= { 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-int spine4_slot_2_slb[25]       = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-int anafa_spine4_slot_2_slb[25] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-/*	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 }; */
+char spine12_slot_2_slb[25]      = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+char anafa_spine12_slot_2_slb[25]= { 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+char spine4_slot_2_slb[25]       = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+char anafa_spine4_slot_2_slb[25] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+/* 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 void get_sfb_slot(Node *node, Port *lineport)
 {
@@ -309,7 +309,7 @@ static void get_sfb_slot(Node *node, Port *lineport)
 static void get_router_slot(Node *node, Port *spineport)
 {
 	ChassisRecord *ch = node->chrecord;
-	int guessnum = 0;
+	uint64_t guessnum = 0;
 
 	if (!ch) {
 		if (!(node->chrecord = calloc(1, sizeof(ChassisRecord))))
diff --git a/infiniband-diags/src/ibnetdiscover.c b/infiniband-diags/src/ibnetdiscover.c
index 948a79d..6946fd7 100644
--- a/infiniband-diags/src/ibnetdiscover.c
+++ b/infiniband-diags/src/ibnetdiscover.c
@@ -47,7 +47,7 @@
 
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
-#include <infiniband/complib/cl_nodenamemap.h>
+#include <complib/cl_nodenamemap.h>
 
 #include "ibnetdiscover.h"
 #include "grouping.h"
@@ -215,7 +215,7 @@ extend_dpath(ib_dr_path_t *path, int nextport)
 	++path->cnt;
 	if (path->cnt > maxhops_discovered)
 		maxhops_discovered = path->cnt;
-	path->p[path->cnt] = nextport;
+	path->p[path->cnt] = (uint8_t) nextport;
 	return path->cnt;
 }
 
@@ -515,7 +515,7 @@ out_ids(Node *node, int group, char *chname)
 }
 
 uint64_t
-out_chassis(int chassisnum)
+out_chassis(unsigned char chassisnum)
 {
 	uint64_t guid;
 
@@ -967,7 +967,7 @@ int main(int argc, char **argv)
 		{ "Router_list", 'R', 0, NULL, "list of connected routers" },
 		{ "node-name-map", 1, 1, "<file>", "node name map file" },
 		{ "ports", 'p', 0, NULL, "obtain a ports report" },
-		{ }
+		{ 0 }
 	};
 	char usage_args[] = "[topology-file]";
 
-- 
1.6.1.2.319.gbd9e




More information about the general mailing list