From: Jason Gunthorpe <jgg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
To: Devesh Sharma <devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Cc: linux-rdma <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Benjamin Drung
<benjamin.drung-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>,
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Yishai Hadas
<yishaih-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>,
Steve Wise
<swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>,
Mike Marciniszyn
<mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Dennis Dalessandro
<dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Lijun Ou <oulijun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
"Wei Hu(Xavier)"
<xavier.huwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
Tatyana Nikolova
<Tatyana.E.Nikolova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Vladimir Sokolovsky
<vlad-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Ram Amrani <Ram.Amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>,
Ariel Elior <Ariel.Elior-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>,
Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>,
Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Nicolas Morey-Chaisemartin
<NMoreyChaisemartin-IBi9RG/b67k@public.gmane.org>,
Alexey Brodkin <abrodkin-HKixBCOQz3hWk0Htik3J/w@public.gmane.org>,
Bar
Subject: Re: [PATCH 1/8] verbs: Always allocate a verbs_context
Date: Thu, 11 Jan 2018 10:54:22 -0700 [thread overview]
Message-ID: <20180111175422.GG30208@mellanox.com> (raw)
In-Reply-To: <CANjDDBgmueZ3fiRJsHEb+p5+H5gX8-7z0NbJShc2bk8yXrh+pg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Thu, Jan 11, 2018 at 11:14:33PM +0530, Devesh Sharma wrote:
> On Wed, Jan 10, 2018 at 11:04 PM, Jason Gunthorpe <jgg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> wrote:
> > On Wed, Jan 10, 2018 at 11:16:20AM +0530, Devesh Sharma wrote:
> >
> >> > +/*
> >> > + * Allocate and initialize a context structure. This is called to create the
> >> > + * driver wrapper, and context_offset is the number of bytes into the wrapper
> >> > + * structure where the verbs_context starts.
> >> > + */
> >> > +void *_verbs_init_and_alloc_context(struct ibv_device *device, int cmd_fd,
> >> > + size_t alloc_size,
> >> > + struct verbs_context *context_offset)
> >> > +{
> >> > + void *drv_context;
> >> > + struct verbs_context *context;
> >> > +
> >> > + drv_context = calloc(1, alloc_size);
> >> > + if (!drv_context) {
> >> > + errno = ENOMEM;
> >> > + close(cmd_fd);
> >> > + return NULL;
> >> > + }
> >> > +
> >> > + context = (struct verbs_context *)((uint8_t *)drv_context +
> >> > + (uintptr_t)context_offset);
> >>
> >> A wrapper macro would do better here?
> > Thing is, this is the only place that does this calculation and it is
> > intimately tied to the definition of the
> > verbs_init_and_alloc_context() macro, so it really is unique and
> > special to this function.
>
> If that is the case I don't mind leaving this as it is, may be it
> would look better from code readability point of view if we wrap it.
Maybe I should just embrace the Pointer-Arith gcc extension:
context = drv_context + (uintptr_t)context_offset;
Have to check first how prevalent it is already in the code.
Jason
--
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
next prev parent reply other threads:[~2018-01-11 17:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-08 21:26 [PATCH rdma-core 0/8] Revise provider initialization Jason Gunthorpe
[not found] ` <20180108212632.5183-1-jgg-uk2M96/98Pc@public.gmane.org>
2018-01-08 21:26 ` [PATCH 1/8] verbs: Always allocate a verbs_context Jason Gunthorpe
[not found] ` <20180108212632.5183-2-jgg-uk2M96/98Pc@public.gmane.org>
2018-01-10 5:46 ` Devesh Sharma
[not found] ` <CANjDDBjCUtdVcQBze0PVjC5EaXj5BGTQ5tcn6VcuG0P7auuxoA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-01-10 17:34 ` Jason Gunthorpe
[not found] ` <20180110173427.GE4776-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2018-01-11 17:44 ` Devesh Sharma
[not found] ` <CANjDDBgmueZ3fiRJsHEb+p5+H5gX8-7z0NbJShc2bk8yXrh+pg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-01-11 17:54 ` Jason Gunthorpe [this message]
[not found] ` <20180111175422.GG30208-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2018-01-12 11:08 ` Devesh Sharma
2018-01-08 21:26 ` [PATCH 2/8] bnxt_re: Convert from init_context to alloc_context Jason Gunthorpe
[not found] ` <20180108212632.5183-3-jgg-uk2M96/98Pc@public.gmane.org>
2018-01-10 5:53 ` Devesh Sharma
[not found] ` <CANjDDBjwmtO2aOtY5NCObrU_VJVmHjw=fdJOk_VvfZx+8+4Ejw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-01-10 17:36 ` Jason Gunthorpe
2018-01-08 21:26 ` [PATCH 3/8] mlx4: " Jason Gunthorpe
2018-01-08 21:26 ` [PATCH 4/8] mlx5: " Jason Gunthorpe
2018-01-08 21:26 ` [PATCH 5/8] verbs: Remove init_context/uninit_context Jason Gunthorpe
[not found] ` <20180108212632.5183-6-jgg-uk2M96/98Pc@public.gmane.org>
2018-01-10 5:59 ` Devesh Sharma
2018-01-08 21:26 ` [PATCH 6/8] verbs: Provide a default implementation for every verbs op Jason Gunthorpe
2018-01-08 21:26 ` [PATCH 7/8] verbs: Convert all providers to use verbs_set_ops Jason Gunthorpe
2018-01-08 21:26 ` [PATCH 8/8] verbs: Remove tests for NULL ops Jason Gunthorpe
2018-01-10 22:05 ` [PATCH rdma-core 0/8] Revise provider initialization Steve Wise
2018-01-10 22:06 ` Steve Wise
2018-01-10 22:27 ` Jason Gunthorpe
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=20180111175422.GG30208@mellanox.com \
--to=jgg-vpraknaxozvwk0htik3j/w@public.gmane.org \
--cc=Ariel.Elior-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org \
--cc=NMoreyChaisemartin-IBi9RG/b67k@public.gmane.org \
--cc=Ram.Amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org \
--cc=Tatyana.E.Nikolova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=abrodkin-HKixBCOQz3hWk0Htik3J/w@public.gmane.org \
--cc=aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org \
--cc=benjamin.drung-EIkl63zCoXaH+58JC4qpiA@public.gmane.org \
--cc=dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=oulijun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org \
--cc=vlad-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=xavier.huwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=yishaih-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@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