2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004, 2005, Voltaire, Inc. All rights reserved.
|
2005-07-27 11:45:37 -07:00
|
|
|
* Copyright (c) 2005 Intel Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
|
2009-09-07 08:28:48 -07:00
|
|
|
* Copyright (c) 2009 HNR Consulting. All rights reserved.
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
|
|
|
* This software is available to you under a choice of one of two
|
|
|
|
* licenses. You may choose to be licensed under the terms of the GNU
|
|
|
|
* General Public License (GPL) Version 2, available from the file
|
|
|
|
* COPYING in the main directory of this source tree, or the
|
|
|
|
* OpenIB.org BSD license below:
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or
|
|
|
|
* without modification, are permitted provided that the following
|
|
|
|
* conditions are met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer.
|
|
|
|
*
|
|
|
|
* - Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials
|
|
|
|
* provided with the distribution.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __IB_MAD_PRIV_H__
|
|
|
|
#define __IB_MAD_PRIV_H__
|
|
|
|
|
2006-05-12 14:57:52 -07:00
|
|
|
#include <linux/completion.h>
|
2006-09-23 16:44:16 +01:00
|
|
|
#include <linux/err.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/workqueue.h>
|
2005-08-25 13:40:04 -07:00
|
|
|
#include <rdma/ib_mad.h>
|
|
|
|
#include <rdma/ib_smi.h>
|
2015-06-06 14:38:34 -04:00
|
|
|
#include <rdma/opa_smi.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
#define IB_MAD_QPS_CORE 2 /* Always QP0 and QP1 as a minimum */
|
|
|
|
|
|
|
|
/* QP and CQ parameters */
|
|
|
|
#define IB_MAD_QP_SEND_SIZE 128
|
|
|
|
#define IB_MAD_QP_RECV_SIZE 512
|
2009-09-07 08:28:48 -07:00
|
|
|
#define IB_MAD_QP_MIN_SIZE 64
|
|
|
|
#define IB_MAD_QP_MAX_SIZE 8192
|
2005-04-16 15:20:36 -07:00
|
|
|
#define IB_MAD_SEND_REQ_MAX_SG 2
|
|
|
|
#define IB_MAD_RECV_REQ_MAX_SG 1
|
|
|
|
|
|
|
|
#define IB_MAD_SEND_Q_PSN 0
|
|
|
|
|
|
|
|
/* Registration table sizes */
|
|
|
|
#define MAX_MGMT_CLASS 80
|
2015-06-06 14:38:33 -04:00
|
|
|
#define MAX_MGMT_VERSION 0x83
|
2005-04-16 15:20:36 -07:00
|
|
|
#define MAX_MGMT_OUI 8
|
|
|
|
#define MAX_MGMT_VENDOR_RANGE2 (IB_MGMT_CLASS_VENDOR_RANGE2_END - \
|
|
|
|
IB_MGMT_CLASS_VENDOR_RANGE2_START + 1)
|
|
|
|
|
|
|
|
struct ib_mad_list_head {
|
|
|
|
struct list_head list;
|
2016-01-05 22:46:12 -08:00
|
|
|
struct ib_cqe cqe;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ib_mad_queue *mad_queue;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ib_mad_private_header {
|
|
|
|
struct ib_mad_list_head mad_list;
|
|
|
|
struct ib_mad_recv_wc recv_wc;
|
2005-04-16 15:26:08 -07:00
|
|
|
struct ib_wc wc;
|
2006-12-12 14:28:30 -08:00
|
|
|
u64 mapping;
|
2019-02-25 08:52:30 +02:00
|
|
|
} __packed;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
struct ib_mad_private {
|
|
|
|
struct ib_mad_private_header header;
|
2015-06-06 14:38:30 -04:00
|
|
|
size_t mad_size;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ib_grh grh;
|
2020-02-12 19:04:25 -06:00
|
|
|
u8 mad[];
|
2019-02-25 08:52:30 +02:00
|
|
|
} __packed;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-03-03 21:54:13 -08:00
|
|
|
struct ib_rmpp_segment {
|
|
|
|
struct list_head list;
|
|
|
|
u32 num;
|
2020-02-12 19:04:25 -06:00
|
|
|
u8 data[];
|
2006-03-03 21:54:13 -08:00
|
|
|
};
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ib_mad_agent_private {
|
|
|
|
struct ib_mad_agent agent;
|
|
|
|
struct ib_mad_reg_req *reg_req;
|
|
|
|
struct ib_mad_qp_info *qp_info;
|
|
|
|
|
|
|
|
spinlock_t lock;
|
|
|
|
struct list_head send_list;
|
2025-06-30 13:16:43 +03:00
|
|
|
unsigned int sol_fc_send_count;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct list_head wait_list;
|
2025-06-30 13:16:43 +03:00
|
|
|
unsigned int sol_fc_wait_count;
|
2006-11-22 14:57:56 +00:00
|
|
|
struct delayed_work timed_work;
|
2005-04-16 15:20:36 -07:00
|
|
|
unsigned long timeout;
|
|
|
|
struct list_head local_list;
|
|
|
|
struct work_struct local_work;
|
2005-07-27 11:45:37 -07:00
|
|
|
struct list_head rmpp_list;
|
2025-06-30 13:16:43 +03:00
|
|
|
unsigned int sol_fc_max;
|
|
|
|
struct list_head backlog_list;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2020-06-21 13:47:37 +03:00
|
|
|
refcount_t refcount;
|
2018-06-13 05:34:03 -07:00
|
|
|
union {
|
|
|
|
struct completion comp;
|
|
|
|
struct rcu_head rcu;
|
|
|
|
};
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ib_mad_snoop_private {
|
|
|
|
struct ib_mad_agent agent;
|
|
|
|
struct ib_mad_qp_info *qp_info;
|
|
|
|
int snoop_index;
|
|
|
|
int mad_snoop_flags;
|
2006-05-12 14:57:52 -07:00
|
|
|
struct completion comp;
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
IB/mad: Add state machine to MAD layer
Replace the use of refcount, timeout and status with a 'state'
field to track the status of MADs send work requests (WRs).
The state machine better represents the stages in the MAD lifecycle,
specifically indicating whether the MAD is waiting for a completion,
waiting for a response, was canceld or is done.
The existing refcount only takes two values:
1 : MAD is waiting either for completion or for response.
2 : MAD is waiting for both response and completion. Also when a
response was received before a completion notification.
The status field represents if the MAD was canceled at some point
in the flow.
The timeout is used to represent if a response was received.
The current state transitions are not clearly visible, and developers
needs to infer the state from the refcount's, timeout's or status's
value, which is error-prone and difficult to follow.
Thus, replace with a state machine as the following:
- 'IB_MAD_STATE_INIT': MAD is in the making and is not yet in any list
- 'IB_MAD_STATE_SEND_START': MAD was sent to the QP and is waiting for
completion notification in send list
- 'IB_MAD_STATE_WAIT_RESP': MAD send completed successfully, waiting for
a response in wait list
- 'IB_MAD_STATE_EARLY_RESP': Response came early, before send
completion notification, MAD is in the send list
- 'IB_MAD_STATE_CANCELED': MAD was canceled while in send or wait list
- 'IB_MAD_STATE_DONE': MAD processing completed, MAD is in no list
Adding the state machine also make it possible to remove the double
call for ib_mad_complete_send_wr in case of an early response and the
use of a done list in case of a regular response.
While at it, define a helper to clear error MADs which will handle
freeing MADs that timed out or have been cancelled.
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Signed-off-by: Vlad Dumitrescu <vdumitrescu@nvidia.com>
Link: https://patch.msgid.link/48e6ae8689dc7bb8b4ba6e5ec562e1b018db88a8.1751278420.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2025-06-30 13:16:42 +03:00
|
|
|
enum ib_mad_state {
|
|
|
|
/* MAD is in the making and is not yet in any list */
|
|
|
|
IB_MAD_STATE_INIT,
|
2025-06-30 13:16:43 +03:00
|
|
|
/* MAD is in backlog list */
|
|
|
|
IB_MAD_STATE_QUEUED,
|
IB/mad: Add state machine to MAD layer
Replace the use of refcount, timeout and status with a 'state'
field to track the status of MADs send work requests (WRs).
The state machine better represents the stages in the MAD lifecycle,
specifically indicating whether the MAD is waiting for a completion,
waiting for a response, was canceld or is done.
The existing refcount only takes two values:
1 : MAD is waiting either for completion or for response.
2 : MAD is waiting for both response and completion. Also when a
response was received before a completion notification.
The status field represents if the MAD was canceled at some point
in the flow.
The timeout is used to represent if a response was received.
The current state transitions are not clearly visible, and developers
needs to infer the state from the refcount's, timeout's or status's
value, which is error-prone and difficult to follow.
Thus, replace with a state machine as the following:
- 'IB_MAD_STATE_INIT': MAD is in the making and is not yet in any list
- 'IB_MAD_STATE_SEND_START': MAD was sent to the QP and is waiting for
completion notification in send list
- 'IB_MAD_STATE_WAIT_RESP': MAD send completed successfully, waiting for
a response in wait list
- 'IB_MAD_STATE_EARLY_RESP': Response came early, before send
completion notification, MAD is in the send list
- 'IB_MAD_STATE_CANCELED': MAD was canceled while in send or wait list
- 'IB_MAD_STATE_DONE': MAD processing completed, MAD is in no list
Adding the state machine also make it possible to remove the double
call for ib_mad_complete_send_wr in case of an early response and the
use of a done list in case of a regular response.
While at it, define a helper to clear error MADs which will handle
freeing MADs that timed out or have been cancelled.
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Signed-off-by: Vlad Dumitrescu <vdumitrescu@nvidia.com>
Link: https://patch.msgid.link/48e6ae8689dc7bb8b4ba6e5ec562e1b018db88a8.1751278420.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2025-06-30 13:16:42 +03:00
|
|
|
/*
|
|
|
|
* MAD was sent to the QP and is waiting for completion
|
|
|
|
* notification in send list.
|
|
|
|
*/
|
|
|
|
IB_MAD_STATE_SEND_START,
|
|
|
|
/*
|
|
|
|
* MAD send completed successfully, waiting for a response
|
|
|
|
* in wait list.
|
|
|
|
*/
|
|
|
|
IB_MAD_STATE_WAIT_RESP,
|
|
|
|
/*
|
|
|
|
* Response came early, before send completion notification,
|
|
|
|
* in send list.
|
|
|
|
*/
|
|
|
|
IB_MAD_STATE_EARLY_RESP,
|
|
|
|
/* MAD was canceled while in wait or send list */
|
|
|
|
IB_MAD_STATE_CANCELED,
|
|
|
|
/* MAD processing completed, MAD in no list */
|
|
|
|
IB_MAD_STATE_DONE
|
|
|
|
};
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ib_mad_send_wr_private {
|
|
|
|
struct ib_mad_list_head mad_list;
|
|
|
|
struct list_head agent_list;
|
2005-07-27 11:45:25 -07:00
|
|
|
struct ib_mad_agent_private *mad_agent_priv;
|
2005-10-25 10:51:39 -07:00
|
|
|
struct ib_mad_send_buf send_buf;
|
2006-12-12 14:28:30 -08:00
|
|
|
u64 header_mapping;
|
|
|
|
u64 payload_mapping;
|
2015-10-08 09:16:33 +01:00
|
|
|
struct ib_ud_wr send_wr;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
|
2005-08-13 21:05:57 -07:00
|
|
|
__be64 tid;
|
2005-04-16 15:20:36 -07:00
|
|
|
unsigned long timeout;
|
2007-11-27 00:11:04 -08:00
|
|
|
int max_retries;
|
|
|
|
int retries_left;
|
2005-04-16 15:20:36 -07:00
|
|
|
int retry;
|
2005-07-27 11:45:37 -07:00
|
|
|
|
|
|
|
/* RMPP control */
|
2006-03-03 21:54:13 -08:00
|
|
|
struct list_head rmpp_list;
|
|
|
|
struct ib_rmpp_segment *last_ack_seg;
|
|
|
|
struct ib_rmpp_segment *cur_seg;
|
2005-07-27 11:45:37 -07:00
|
|
|
int last_ack;
|
|
|
|
int seg_num;
|
|
|
|
int newwin;
|
|
|
|
int pad;
|
IB/mad: Add state machine to MAD layer
Replace the use of refcount, timeout and status with a 'state'
field to track the status of MADs send work requests (WRs).
The state machine better represents the stages in the MAD lifecycle,
specifically indicating whether the MAD is waiting for a completion,
waiting for a response, was canceld or is done.
The existing refcount only takes two values:
1 : MAD is waiting either for completion or for response.
2 : MAD is waiting for both response and completion. Also when a
response was received before a completion notification.
The status field represents if the MAD was canceled at some point
in the flow.
The timeout is used to represent if a response was received.
The current state transitions are not clearly visible, and developers
needs to infer the state from the refcount's, timeout's or status's
value, which is error-prone and difficult to follow.
Thus, replace with a state machine as the following:
- 'IB_MAD_STATE_INIT': MAD is in the making and is not yet in any list
- 'IB_MAD_STATE_SEND_START': MAD was sent to the QP and is waiting for
completion notification in send list
- 'IB_MAD_STATE_WAIT_RESP': MAD send completed successfully, waiting for
a response in wait list
- 'IB_MAD_STATE_EARLY_RESP': Response came early, before send
completion notification, MAD is in the send list
- 'IB_MAD_STATE_CANCELED': MAD was canceled while in send or wait list
- 'IB_MAD_STATE_DONE': MAD processing completed, MAD is in no list
Adding the state machine also make it possible to remove the double
call for ib_mad_complete_send_wr in case of an early response and the
use of a done list in case of a regular response.
While at it, define a helper to clear error MADs which will handle
freeing MADs that timed out or have been cancelled.
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Signed-off-by: Vlad Dumitrescu <vdumitrescu@nvidia.com>
Link: https://patch.msgid.link/48e6ae8689dc7bb8b4ba6e5ec562e1b018db88a8.1751278420.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2025-06-30 13:16:42 +03:00
|
|
|
|
|
|
|
enum ib_mad_state state;
|
2025-06-30 13:16:43 +03:00
|
|
|
|
|
|
|
/* Solicited MAD flow control */
|
|
|
|
bool is_solicited_fc;
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
IB/mad: Add state machine to MAD layer
Replace the use of refcount, timeout and status with a 'state'
field to track the status of MADs send work requests (WRs).
The state machine better represents the stages in the MAD lifecycle,
specifically indicating whether the MAD is waiting for a completion,
waiting for a response, was canceld or is done.
The existing refcount only takes two values:
1 : MAD is waiting either for completion or for response.
2 : MAD is waiting for both response and completion. Also when a
response was received before a completion notification.
The status field represents if the MAD was canceled at some point
in the flow.
The timeout is used to represent if a response was received.
The current state transitions are not clearly visible, and developers
needs to infer the state from the refcount's, timeout's or status's
value, which is error-prone and difficult to follow.
Thus, replace with a state machine as the following:
- 'IB_MAD_STATE_INIT': MAD is in the making and is not yet in any list
- 'IB_MAD_STATE_SEND_START': MAD was sent to the QP and is waiting for
completion notification in send list
- 'IB_MAD_STATE_WAIT_RESP': MAD send completed successfully, waiting for
a response in wait list
- 'IB_MAD_STATE_EARLY_RESP': Response came early, before send
completion notification, MAD is in the send list
- 'IB_MAD_STATE_CANCELED': MAD was canceled while in send or wait list
- 'IB_MAD_STATE_DONE': MAD processing completed, MAD is in no list
Adding the state machine also make it possible to remove the double
call for ib_mad_complete_send_wr in case of an early response and the
use of a done list in case of a regular response.
While at it, define a helper to clear error MADs which will handle
freeing MADs that timed out or have been cancelled.
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Signed-off-by: Vlad Dumitrescu <vdumitrescu@nvidia.com>
Link: https://patch.msgid.link/48e6ae8689dc7bb8b4ba6e5ec562e1b018db88a8.1751278420.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2025-06-30 13:16:42 +03:00
|
|
|
static inline void expect_mad_state(struct ib_mad_send_wr_private *mad_send_wr,
|
|
|
|
enum ib_mad_state expected_state)
|
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_LOCKDEP))
|
|
|
|
WARN_ON(mad_send_wr->state != expected_state);
|
|
|
|
}
|
|
|
|
|
2025-06-30 13:16:43 +03:00
|
|
|
static inline void expect_mad_state2(struct ib_mad_send_wr_private *mad_send_wr,
|
|
|
|
enum ib_mad_state expected_state1,
|
|
|
|
enum ib_mad_state expected_state2)
|
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_LOCKDEP))
|
|
|
|
WARN_ON(mad_send_wr->state != expected_state1 &&
|
|
|
|
mad_send_wr->state != expected_state2);
|
|
|
|
}
|
|
|
|
|
IB/mad: Add state machine to MAD layer
Replace the use of refcount, timeout and status with a 'state'
field to track the status of MADs send work requests (WRs).
The state machine better represents the stages in the MAD lifecycle,
specifically indicating whether the MAD is waiting for a completion,
waiting for a response, was canceld or is done.
The existing refcount only takes two values:
1 : MAD is waiting either for completion or for response.
2 : MAD is waiting for both response and completion. Also when a
response was received before a completion notification.
The status field represents if the MAD was canceled at some point
in the flow.
The timeout is used to represent if a response was received.
The current state transitions are not clearly visible, and developers
needs to infer the state from the refcount's, timeout's or status's
value, which is error-prone and difficult to follow.
Thus, replace with a state machine as the following:
- 'IB_MAD_STATE_INIT': MAD is in the making and is not yet in any list
- 'IB_MAD_STATE_SEND_START': MAD was sent to the QP and is waiting for
completion notification in send list
- 'IB_MAD_STATE_WAIT_RESP': MAD send completed successfully, waiting for
a response in wait list
- 'IB_MAD_STATE_EARLY_RESP': Response came early, before send
completion notification, MAD is in the send list
- 'IB_MAD_STATE_CANCELED': MAD was canceled while in send or wait list
- 'IB_MAD_STATE_DONE': MAD processing completed, MAD is in no list
Adding the state machine also make it possible to remove the double
call for ib_mad_complete_send_wr in case of an early response and the
use of a done list in case of a regular response.
While at it, define a helper to clear error MADs which will handle
freeing MADs that timed out or have been cancelled.
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Signed-off-by: Vlad Dumitrescu <vdumitrescu@nvidia.com>
Link: https://patch.msgid.link/48e6ae8689dc7bb8b4ba6e5ec562e1b018db88a8.1751278420.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2025-06-30 13:16:42 +03:00
|
|
|
static inline void expect_mad_state3(struct ib_mad_send_wr_private *mad_send_wr,
|
|
|
|
enum ib_mad_state expected_state1,
|
|
|
|
enum ib_mad_state expected_state2,
|
|
|
|
enum ib_mad_state 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
not_expect_mad_state(struct ib_mad_send_wr_private *mad_send_wr,
|
|
|
|
enum ib_mad_state wrong_state)
|
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_LOCKDEP))
|
|
|
|
WARN_ON(mad_send_wr->state == wrong_state);
|
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ib_mad_local_private {
|
|
|
|
struct list_head completion_list;
|
|
|
|
struct ib_mad_private *mad_priv;
|
|
|
|
struct ib_mad_agent_private *recv_mad_agent;
|
2005-10-25 10:51:39 -07:00
|
|
|
struct ib_mad_send_wr_private *mad_send_wr;
|
2015-06-10 16:16:48 -04:00
|
|
|
size_t return_wc_byte_len;
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ib_mad_mgmt_method_table {
|
|
|
|
struct ib_mad_agent_private *agent[IB_MGMT_MAX_METHODS];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ib_mad_mgmt_class_table {
|
|
|
|
struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_CLASS];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ib_mad_mgmt_vendor_class {
|
|
|
|
u8 oui[MAX_MGMT_OUI][3];
|
|
|
|
struct ib_mad_mgmt_method_table *method_table[MAX_MGMT_OUI];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ib_mad_mgmt_vendor_class_table {
|
|
|
|
struct ib_mad_mgmt_vendor_class *vendor_class[MAX_MGMT_VENDOR_RANGE2];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ib_mad_mgmt_version_table {
|
|
|
|
struct ib_mad_mgmt_class_table *class;
|
|
|
|
struct ib_mad_mgmt_vendor_class_table *vendor;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ib_mad_queue {
|
|
|
|
spinlock_t lock;
|
|
|
|
struct list_head list;
|
|
|
|
int count;
|
|
|
|
int max_active;
|
|
|
|
struct ib_mad_qp_info *qp_info;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ib_mad_qp_info {
|
|
|
|
struct ib_mad_port_private *port_priv;
|
|
|
|
struct ib_qp *qp;
|
|
|
|
struct ib_mad_queue send_queue;
|
|
|
|
struct ib_mad_queue recv_queue;
|
|
|
|
struct list_head overflow_list;
|
|
|
|
spinlock_t snoop_lock;
|
|
|
|
struct ib_mad_snoop_private **snoop_table;
|
|
|
|
int snoop_table_size;
|
|
|
|
atomic_t snoop_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ib_mad_port_private {
|
|
|
|
struct list_head port_list;
|
|
|
|
struct ib_device *device;
|
|
|
|
int port_num;
|
|
|
|
struct ib_cq *cq;
|
|
|
|
struct ib_pd *pd;
|
|
|
|
|
|
|
|
spinlock_t reg_lock;
|
|
|
|
struct ib_mad_mgmt_version_table version[MAX_MGMT_VERSION];
|
|
|
|
struct workqueue_struct *wq;
|
|
|
|
struct ib_mad_qp_info qp_info[IB_MAD_QPS_CORE];
|
|
|
|
};
|
|
|
|
|
2005-07-27 11:45:37 -07:00
|
|
|
int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr);
|
|
|
|
|
|
|
|
struct ib_mad_send_wr_private *
|
2015-05-08 14:27:24 -04:00
|
|
|
ib_find_send_mad(const struct ib_mad_agent_private *mad_agent_priv,
|
|
|
|
const struct ib_mad_recv_wc *mad_recv_wc);
|
2005-07-27 11:45:37 -07:00
|
|
|
|
|
|
|
void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,
|
|
|
|
struct ib_mad_send_wc *mad_send_wc);
|
|
|
|
|
|
|
|
void ib_mark_mad_done(struct ib_mad_send_wr_private *mad_send_wr);
|
|
|
|
|
|
|
|
void ib_reset_mad_timeout(struct ib_mad_send_wr_private *mad_send_wr,
|
2018-10-11 17:30:05 +03:00
|
|
|
unsigned long timeout_ms);
|
2005-07-27 11:45:37 -07:00
|
|
|
|
IB/mad: Add state machine to MAD layer
Replace the use of refcount, timeout and status with a 'state'
field to track the status of MADs send work requests (WRs).
The state machine better represents the stages in the MAD lifecycle,
specifically indicating whether the MAD is waiting for a completion,
waiting for a response, was canceld or is done.
The existing refcount only takes two values:
1 : MAD is waiting either for completion or for response.
2 : MAD is waiting for both response and completion. Also when a
response was received before a completion notification.
The status field represents if the MAD was canceled at some point
in the flow.
The timeout is used to represent if a response was received.
The current state transitions are not clearly visible, and developers
needs to infer the state from the refcount's, timeout's or status's
value, which is error-prone and difficult to follow.
Thus, replace with a state machine as the following:
- 'IB_MAD_STATE_INIT': MAD is in the making and is not yet in any list
- 'IB_MAD_STATE_SEND_START': MAD was sent to the QP and is waiting for
completion notification in send list
- 'IB_MAD_STATE_WAIT_RESP': MAD send completed successfully, waiting for
a response in wait list
- 'IB_MAD_STATE_EARLY_RESP': Response came early, before send
completion notification, MAD is in the send list
- 'IB_MAD_STATE_CANCELED': MAD was canceled while in send or wait list
- 'IB_MAD_STATE_DONE': MAD processing completed, MAD is in no list
Adding the state machine also make it possible to remove the double
call for ib_mad_complete_send_wr in case of an early response and the
use of a done list in case of a regular response.
While at it, define a helper to clear error MADs which will handle
freeing MADs that timed out or have been cancelled.
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Signed-off-by: Vlad Dumitrescu <vdumitrescu@nvidia.com>
Link: https://patch.msgid.link/48e6ae8689dc7bb8b4ba6e5ec562e1b018db88a8.1751278420.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2025-06-30 13:16:42 +03:00
|
|
|
void change_mad_state(struct ib_mad_send_wr_private *mad_send_wr,
|
|
|
|
enum ib_mad_state new_state);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif /* __IB_MAD_PRIV_H__ */
|