From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
To: David Laight <David.Laight-ZS65k/vG3HxXrIkS9f7CXA@public.gmane.org>
Cc: 'Stephen Hemminger'
<stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>,
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Dennis Dalessandro
<dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Jason Gunthorpe
<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>,
Jiri Pirko <jiri-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Ariel Almog <ariela-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Linux Netdev <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH v4 iproute2 2/7] rdma: Add dev object
Date: Tue, 15 Aug 2017 20:46:54 +0300 [thread overview]
Message-ID: <20170815174653.GX24282@mtr-leonro.local> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DD005613D-VkEWCZq2GCInGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1944 bytes --]
On Tue, Aug 15, 2017 at 05:00:54PM +0000, David Laight wrote:
> From: Leon Romanovsky
> > Sent: 15 August 2017 17:47
> > On Tue, Aug 15, 2017 at 04:23:11PM +0000, David Laight wrote:
> > > From: Stephen Hemminger
> > > > Sent: 15 August 2017 17:12
> > > > On Tue, 15 Aug 2017 16:00:15 +0300
> > > > Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> wrote:
> > > >
> > > > > +
> > > > > +static const char *dev_caps_to_str(uint32_t idx)
> > > > > +{
> > > > > + uint64_t cap = 1 << idx;
> > > > > +
> > > > > + switch (cap) {
> > > > > + case RDMA_DEV_RESIZE_MAX_WR: return "RESIZE_MAX_WR";
> > > > > + case RDMA_DEV_BAD_PKEY_CNTR: return "BAD_PKEY_CNTR";
> > > ...
> > > > > + case RDMA_DEV_RAW_SCATTER_FCS: return "RAW_SCATTER_FCS";
> > > > > + case RDMA_DEV_RDMA_NETDEV_OPA_VNIC: return "RDMA_NETDEV_OPA_VNIC";
> > > > > + default: return "UNKNOWN";
> > > > > + }
> > > >
> > > > Could this be a table in future versions?
> > >
> > > Potentially you could define the constants using some pre-processor
> > > 'magic' that would create the table for you.
> > > Something like (but not compiled):
> > >
> > > #define RDMA_DEV_FLAGS(x) \
> > > x(RESIZE_MAX_WR, 0) \
> > > x(BAD_PKEY_CNTR, 1) \
> > > (continue for all the bits)
> > >
> > > #define RDMA_DEV_ENUM(name, bit_no) RDMA_DEV_##name = BIT(bit_no),
> > > enum {RDMA_DEV_FLAGS(RDMA_DEV_ENUM)};
> > > #undef RDMA_DEV_ENUM
> > >
> > > #define RDMA_DEV_NAMES(name, bit_no) [bit_no] = #name,
> > > static const char rdma_dev_names[] = {RDMA_DEV_FLAGS(RDMA_DEV_NAMES)};
> I missed the #undef
> > >
> >
> > David,
> >
> > How should I handle "uknown" fields without names?
>
> The function that accesses rdma_dev_names[] checks ARRAY_SIZE()
> and for a NULL pointer.
Thanks, I'll definitely try it.
>
> WRT the other comment, the spare pointers consume far less space than
> the code for your switch statement.
I don't think that space is matter for this tool.
>
> David
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-08-15 17:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-15 13:00 [PATCH v4 iproute2 0/7] RDMAtool Leon Romanovsky
2017-08-15 13:00 ` [PATCH v4 iproute2 1/7] rdma: Add basic infrastructure for RDMA tool Leon Romanovsky
2017-08-15 23:54 ` Stephen Hemminger
2017-08-16 5:32 ` Leon Romanovsky
2017-08-15 13:00 ` [PATCH v4 iproute2 3/7] rdma: Add link object Leon Romanovsky
[not found] ` <20170815130020.29509-1-leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-08-15 13:00 ` [PATCH v4 iproute2 2/7] rdma: Add dev object Leon Romanovsky
2017-08-15 16:12 ` Stephen Hemminger
2017-08-15 16:23 ` David Laight
[not found] ` <063D6719AE5E284EB5DD2968C1650D6DD005604E-VkEWCZq2GCInGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2017-08-15 16:47 ` Leon Romanovsky
2017-08-15 17:00 ` David Laight
[not found] ` <063D6719AE5E284EB5DD2968C1650D6DD005613D-VkEWCZq2GCInGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2017-08-15 17:46 ` Leon Romanovsky [this message]
2017-08-15 16:43 ` Leon Romanovsky
2017-08-15 13:00 ` [PATCH v4 iproute2 4/7] rdma: Add initial manual for the tool Leon Romanovsky
2017-08-15 13:00 ` [PATCH v4 iproute2 5/7] rdma: Add json and pretty outputs Leon Romanovsky
2017-08-15 13:00 ` [PATCH v4 iproute2 6/7] rdma: Implement json output for dev object Leon Romanovsky
2017-08-15 13:00 ` [PATCH v4 iproute2 7/7] rdma: Add json output to link object Leon Romanovsky
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=20170815174653.GX24282@mtr-leonro.local \
--to=leonro-vpraknaxozvwk0htik3j/w@public.gmane.org \
--cc=David.Laight-ZS65k/vG3HxXrIkS9f7CXA@public.gmane.org \
--cc=ariela-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
--cc=jiri-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@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