public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagig-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
To: Yann Droneaud <ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>,
	Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Anna Schumaker
	<Anna.Schumaker-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org>,
	Steve Wise
	<swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>,
	Chuck Lever <chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	Bart Van Assche
	<bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>,
	Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Chien Yen <chien.yen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH v2 1/2] IB/core, cma: Nice log-friendly string helpers
Date: Mon, 11 May 2015 17:50:09 +0300	[thread overview]
Message-ID: <5550C1A1.4060503@dev.mellanox.co.il> (raw)
In-Reply-To: <1431355084.25060.36.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>

On 5/11/2015 5:38 PM, Yann Droneaud wrote:
> Hi,
>
> Le lundi 11 mai 2015 à 17:10 +0300, Sagi Grimberg a écrit :
>> 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.
>>
>> Signed-off-by: Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
>> ---
>>   drivers/infiniband/core/cma.c   |   26 ++++++++++++++++
>>   drivers/infiniband/core/verbs.c |   61 +++++++++++++++++++++++++++++++++++++++
>>   include/rdma/ib_verbs.h         |    4 ++
>>   include/rdma/rdma_cm.h          |    2 +
>>   4 files changed, 93 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
>> index d570030..fb5a815 100644
>> --- a/drivers/infiniband/core/cma.c
>> +++ b/drivers/infiniband/core/cma.c
>> @@ -65,6 +65,32 @@ MODULE_LICENSE("Dual BSD/GPL");
>>   #define CMA_CM_MRA_SETTING (IB_CM_MRA_FLAG_DELAY | 24)
>>   #define CMA_IBOE_PACKET_LIFETIME 18
>>
>> +static const char *cma_events[] = {
>
> Go for .rodata:
>
> 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",
>> +};
>> +
>> +__attribute_const__ const char *rdma_event_msg(enum rdma_cm_event_type event)
>
> __attribute_const__ is useless here.

Yeh.. either that or const, I'll remove it...

>
>> +{
>> +	return (unsigned)event < ARRAY_SIZE(cma_events) ?
>> +			cma_events[(unsigned)event] : "UNRECOGNIZED_EVENT";
>
> You could be a bit more paranoid here:
>
>            size_t index = event;
>
>            return (index < ARRAY_SIZE(cmd_events) && cma_events[index]) ?
> 			cma_events[index] : "UNRECOGNIZED_EVENT";
>

I'm fine with that too...
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-05-11 14:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-11 14:10 Generic logging helpers Sagi Grimberg
     [not found] ` <1431353456-3862-1-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-05-11 14:10   ` [PATCH v2 1/2] IB/core, cma: Nice log-friendly string helpers Sagi Grimberg
     [not found]     ` <1431353456-3862-2-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-05-11 14:38       ` Yann Droneaud
     [not found]         ` <1431355084.25060.36.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
2015-05-11 14:50           ` Sagi Grimberg [this message]
     [not found]             ` <5550C1A1.4060503-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-05-11 15:21               ` Yann Droneaud
2015-05-11 14:10   ` [PATCH v2 2/2] ulps: Align several ULPs to use core/rdma_cm logging helpers Sagi Grimberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5550C1A1.4060503@dev.mellanox.co.il \
    --to=sagig-ldsdmyg8hgv8yrgs2mwiifqbs+8scbdb@public.gmane.org \
    --cc=Anna.Schumaker-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org \
    --cc=bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org \
    --cc=chien.yen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org \
    --cc=ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox