[ofa-general] Re: [PATCH v2] Add enum strings and *_str functions for enums

Ira Weiny weiny2 at llnl.gov
Mon Jun 16 10:24:30 PDT 2008


On Mon, 16 Jun 2008 17:05:40 +0300
Jack Morgenstein <jackm at dev.mellanox.co.il> wrote:

> On Saturday 19 April 2008 00:54, Roland Dreier wrote:
> > Thanks, I added a man page and changed things a little and committed the
> > following:
> > 
> > commit 1c0b7ac0a6bbbe4d246ef4cf50ae31bde4929ba3
> > Author: Ira Weiny <weiny2 at llnl.gov>
> > Date:   Tue Apr 15 13:35:48 2008 -0700
> > 
> >     Add functions to convert enum values to strings
> >     
> >     Add ibv_xxx_str() functions to convert node type, port state, event
> >     type and wc status enum values to strings.
> >     
> >     Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
> >     Signed-off-by: Roland Dreier <rolandd at cisco.com>
> > 
> >  
> The change below (in the output format of the port state string)
> is causing us problems (with all sorts of scripts based upon ibv_devinfo).
> This only surfaced now because we're only just now bringing up the OFED 1.4 tree
> based upon the current libibverbs and kernel 2.6.26.
> 
> Unfortunately, I missed this change when you posted it to the list in April.
> 
> I assume that the only reason for the change below, aside from adding the defer state, was cosmetic.
> Is it possible to change the output strings so that for previously defined port states,
> the output remains what it was previously?

Yes it was just cosmetic.  I have no attachment to what the strings are, just
that they are provided by the lib to be used by other ULP's such as MPI.

> 
> (I don't see this as any different from other userspace library backwards-compatibility issues,
> the change breaks existing scripts).
> 

<snip>

Sorry, I did not intend to break anything.  I completely forgot that
ibv_devinfo was a widely used tool.

Patch included below

Ira


>From 5a624c6ee75d34dfa29580a71eb26c9f2a9990fb Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Mon, 16 Jun 2008 10:20:22 -0700
Subject: [PATCH] src/enum_strs.c: revert strings for port state to fix script problems.


Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
 src/enum_strs.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/enum_strs.c b/src/enum_strs.c
index c57feaa..97f1081 100644
--- a/src/enum_strs.c
+++ b/src/enum_strs.c
@@ -51,15 +51,15 @@ const char *ibv_port_state_str(enum ibv_port_state port_state)
 {
 	static const char *const port_state_str[] = {
 		[IBV_PORT_NOP]		= "no state change (NOP)",
-		[IBV_PORT_DOWN]		= "down",
-		[IBV_PORT_INIT]		= "init",
-		[IBV_PORT_ARMED]	= "armed",
-		[IBV_PORT_ACTIVE]	= "active",
-		[IBV_PORT_ACTIVE_DEFER]	= "active defer"
+		[IBV_PORT_DOWN]		= "PORT_DOWN",
+		[IBV_PORT_INIT]		= "PORT_INIT",
+		[IBV_PORT_ARMED]	= "PORT_ARMED",
+		[IBV_PORT_ACTIVE]	= "PORT_ACTIVE",
+		[IBV_PORT_ACTIVE_DEFER]	= "PORT_ACTIVE_DEFER"
 	};
 
 	if (port_state < IBV_PORT_NOP || port_state > IBV_PORT_ACTIVE_DEFER)
-		return "unknown";
+		return "invalid state";
 
 	return port_state_str[port_state];
 }
-- 
1.5.1




More information about the general mailing list