From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Or Har-Toov <ohartoov@nvidia.com>,
linux-rdma@vger.kernel.org, Maher Sanalla <msanalla@nvidia.com>
Subject: Re: [PATCH rdma-next v1 1/2] IB/mad: Add state machine to MAD layer
Date: Sun, 19 Jan 2025 10:26:24 +0200 [thread overview]
Message-ID: <20250119082624.GA21007@unreal> (raw)
In-Reply-To: <20250114194208.GF5556@nvidia.com>
On Tue, Jan 14, 2025 at 03:42:08PM -0400, Jason Gunthorpe wrote:
> On Tue, Jan 07, 2025 at 04:02:12PM +0200, Leon Romanovsky wrote:
> > +static void handle_send_state(struct ib_mad_send_wr_private *mad_send_wr,
> > + struct ib_mad_agent_private *mad_agent_priv)
> > +{
> > + if (!mad_send_wr->state) {
>
> What is this doing? state is an enum, what is !state supposed to be? 0
> is not a valid value in the enum.
>
> > @@ -1118,15 +1209,12 @@ int ib_post_send_mad(struct ib_mad_send_buf *send_buf,
> > mad_send_wr->max_retries = send_buf->retries;
> > mad_send_wr->retries_left = send_buf->retries;
> > send_buf->retries = 0;
> > - /* Reference for work request to QP + response */
> > - mad_send_wr->refcount = 1 + (mad_send_wr->timeout > 0);
> > - mad_send_wr->status = IB_WC_SUCCESS;
> > + mad_send_wr->state = 0;
>
> Same, enums should not be assigned to constants. If you want another
> state you need another IB_MAD_STATE value and use it here and above.
Sure, will change.
>
> > +#define EXPECT_MAD_STATE(mad_send_wr, expected_state) \
> > + { \
> > + if (IS_ENABLED(CONFIG_LOCKDEP)) \
> > + WARN_ON(mad_send_wr->state != expected_state); \
> > + }
> > +#define EXPECT_MAD_STATE3(mad_send_wr, expected_state1, expected_state2, \
> > + expected_state3) \
> > + { \
> > + if (IS_ENABLED(CONFIG_LOCKDEP)) \
> > + WARN_ON(mad_send_wr->state != expected_state1 && \
> > + mad_send_wr->state != expected_state2 && \
> > + mad_send_wr->state != expected_state3); \
> > + }
> > +#define NOT_EXPECT_MAD_STATE(mad_send_wr, wrong_state) \
> > + { \
> > + if (IS_ENABLED(CONFIG_LOCKDEP)) \
> > + WARN_ON(mad_send_wr->state == wrong_state); \
> > + }
>
> These could all be static inlines, otherwise at least
> mad_send_wr->state needs brackets (mad_send_wr)->state
I don't think that it is worth to have functions here.
Thanks
>
> Jason
next prev parent reply other threads:[~2025-01-19 8:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 14:02 [PATCH rdma-next v1 0/2] IB/mad: Add Flow Control for Solicited MADs Leon Romanovsky
2025-01-07 14:02 ` [PATCH rdma-next v1 1/2] IB/mad: Add state machine to MAD layer Leon Romanovsky
2025-01-14 19:42 ` Jason Gunthorpe
2025-01-19 8:26 ` Leon Romanovsky [this message]
2025-01-20 13:47 ` Jason Gunthorpe
2025-01-07 14:02 ` [PATCH rdma-next v1 2/2] IB/mad: Add flow control for solicited MADs 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=20250119082624.GA21007@unreal \
--to=leon@kernel.org \
--cc=jgg@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
--cc=msanalla@nvidia.com \
--cc=ohartoov@nvidia.com \
/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;
as well as URLs for NNTP newsgroup(s).