[ofa-general] Re: Stringify ibv_event_type

Michael S. Tsirkin mst at dev.mellanox.co.il
Thu Jun 21 11:55:33 PDT 2007


> Quoting Jeff Squyres <jsquyres at cisco.com>:
> Subject: Stringify ibv_event_type
> 
> Could a function to stringify the ibv_event_type enum can be added to  
> libibverbs?  It could be similar to the event_name_str() function in  
> libibverbs/examples/asyncwatch.c:
> 
> -----
> static const char *event_name_str(enum ibv_event_type event_type)
> {
>         switch (event_type) {
>         case IBV_EVENT_DEVICE_FATAL:
>                 return "IBV_EVENT_DEVICE_FATAL";
> ...etc.
> -----
> 
> Rationale: if multiple client apps (such as the OF-based MPI  
> implementations) start using the asynch events and there is no  
> central function for string-ifying the event enum, they'll all end up  
> doing the translation themselves when printing out error messages.   
> It's not a huge amount of code, but it does seem kinda odd to make  
> everyone replicate essentially the same stuff.  Additionally, the  
> available enum values may grow over time, forcing client apps to  
> figure out which ones are available and adjust their event_name_str()  
> equivalent as appropriate.  Hiding the possibility of change down in  
> libibverbs seems appropriate.

I have no strong opinion either way, but I do wonder why do you find this useful?

Asyncwatch is just an example: it does not actually *do anything* on an event,
so it calls printf. But, is it likely that enduser really needs to see
IBV_EVENT_CLIENT_REREGISTER? Printing out the numerc value seems
sufficient for debug.

-- 
MST



More information about the general mailing list