Re: [PATCH v5 1/6] IB/core, cma: Nice log-friendly string helpers

Sagi Grimberg
2015-05-12T13:33:51Z

On 5/12/2015 3:59 PM, Or Gerlitz wrote:
> On Tue, May 12, 2015 at 3:05 PM, Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> wrote:
>> Some of us keep revisiting the code to decode enumerations that
>> appear in out logs. Let's borrow the nice logging helpers that
>> exists in xprtrdma and rds for CMA events, IB events and WC statuses.
>
> [...]
>
>> +static const char * const cma_events[] = {
>> + [RDMA_CM_EVENT_ADDR_RESOLVED] = "ADDR_RESOLVED",
>> + [RDMA_CM_EVENT_ADDR_ERROR] = "ADDR_ERROR",
>> + [RDMA_CM_EVENT_ROUTE_RESOLVED] = "ROUTE_RESOLVED",
>> + [RDMA_CM_EVENT_ROUTE_ERROR] = "ROUTE_ERROR",
>> + [RDMA_CM_EVENT_CONNECT_REQUEST] = "CONNECT_REQUEST",
>> + [RDMA_CM_EVENT_CONNECT_RESPONSE]= "CONNECT_RESPONSE",
>> + [RDMA_CM_EVENT_CONNECT_ERROR] = "CONNECT_ERROR",
>> + [RDMA_CM_EVENT_UNREACHABLE] = "UNREACHABLE",
>> + [RDMA_CM_EVENT_REJECTED] = "REJECTED",
>> + [RDMA_CM_EVENT_ESTABLISHED] = "ESTABLISHED",
>> + [RDMA_CM_EVENT_DISCONNECTED] = "DISCONNECTED",
>> + [RDMA_CM_EVENT_DEVICE_REMOVAL] = "DEVICE_REMOVAL",
>> + [RDMA_CM_EVENT_MULTICAST_JOIN] = "MULTICAST_JOIN",
>> + [RDMA_CM_EVENT_MULTICAST_ERROR] = "MULTICAST_ERROR",
>> + [RDMA_CM_EVENT_ADDR_CHANGE] = "ADDR_CHANGE",
>> + [RDMA_CM_EVENT_TIMEWAIT_EXIT] = "TIMEWAIT_EXIT",
>> +};
>
> Sagi,
>
> My vote goes to using easy-to-digest human-readable non-capital
> letters strings here and
> elsewhere (IB events, etc), as done today by the NFS code and
> generally by errno based
> helpers such as strerror, e.g
>
> "address resolved"
> "address error"
> "route resolved"
>
> Will be happy to hear what others think

Let's do that before I post v6...