All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>
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: Tue, 14 Jan 2025 15:42:08 -0400	[thread overview]
Message-ID: <20250114194208.GF5556@nvidia.com> (raw)
In-Reply-To: <bf1d3e6c5eceb452a4fa4f6d08ea6b5220ab5cc9.1736258116.git.leonro@nvidia.com>

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.

> +#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

Jason

  reply	other threads:[~2025-01-14 19:42 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 [this message]
2025-01-19  8:26     ` Leon Romanovsky
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=20250114194208.GF5556@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=leon@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.