ib_srpt: Eliminate srpt_rdma_ch.processing_compl.

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@3515 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2011-06-02 14:35:14 +00:00
parent 1bbda55d42
commit 177a6c915e
2 changed files with 424 additions and 329 deletions
+336 -269
View File
File diff suppressed because it is too large Load Diff
+88 -60
View File
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2006 - 2009 Mellanox Technology Inc. All rights reserved.
* Copyright (C) 2009 - 2010 Bart Van Assche <bvanassche@acm.org>
* Copyright (C) 2009 - 2011 Bart Van Assche <bvanassche@acm.org>.
*
* 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
@@ -38,24 +38,21 @@
#include <linux/version.h>
#include <linux/types.h>
#include <linux/list.h>
#include <linux/wait.h>
#include <rdma/ib_verbs.h>
#include <rdma/ib_sa.h>
#include <rdma/ib_cm.h>
#include <scsi/srp.h>
#if defined(INSIDE_KERNEL_TREE)
#include <scst/scst.h>
#else
#include <scst.h>
#endif
#include "ib_dm_mad.h"
/*
* The prefix the ServiceName field must start with in the device management
* ServiceEntries attribute pair. See also the SRP r16a document.
* ServiceEntries attribute pair. See also the SRP specification.
*/
#define SRP_SERVICE_NAME_PREFIX "SRP.T10:"
@@ -63,7 +60,7 @@ enum {
/*
* SRP IOControllerProfile attributes for SRP target ports that have
* not been defined in <scsi/srp.h>. Source: section B.7, table B.7
* in the SRP r16a document.
* in the SRP specification.
*/
SRP_PROTOCOL = 0x0108,
SRP_PROTOCOL_VERSION = 0x0001,
@@ -84,23 +81,23 @@ enum {
/*
* srp_cmd.sol_nt / srp_tsk_mgmt.sol_not bitmasks. See also tables
* 18 and 20 in the T10 r16a document.
* 18 and 20 in the SRP specification.
*/
SRP_SCSOLNT = 0x02, /* SCSOLNT = successful solicited notification */
SRP_UCSOLNT = 0x04, /* UCSOLNT = unsuccessful solicited notification */
/*
* srp_rsp.sol_not / srp_t_logout.sol_not bitmasks. See also tables
* 16 and 22 in the T10 r16a document.
* 16 and 22 in the SRP specification.
*/
SRP_SOLNT = 0x01, /* SOLNT = solicited notification */
/* See also table 24 in the T10 r16a document. */
/* See also table 24 in the SRP specification. */
SRP_TSK_MGMT_SUCCESS = 0x00,
SRP_TSK_MGMT_FUNC_NOT_SUPP = 0x04,
SRP_TSK_MGMT_FAILED = 0x05,
/* See also table 21 in the T10 r16a document. */
/* See also table 21 in the SRP specification. */
SRP_CMD_SIMPLE_Q = 0x0,
SRP_CMD_HEAD_OF_Q = 0x1,
SRP_CMD_ORDERED_Q = 0x2,
@@ -163,18 +160,20 @@ struct rdma_iu {
* @SRPT_STATE_DATA_IN: Data for the write or bidir command arrived and is
* being processed.
* @SRPT_STATE_CMD_RSP_SENT: SRP_RSP for SRP_CMD has been sent.
* @SRPT_STATE_MGMT: Processing a SCSI task management command.
* @SRPT_STATE_MGMT_RSP_SENT: SRP_RSP for SRP_TSK_MGMT has been sent.
* @SRPT_STATE_DONE: Command processing finished successfully, command
* processing has been aborted or command processing
* failed.
*/
enum srpt_command_state {
SRPT_STATE_NEW = 0,
SRPT_STATE_NEED_DATA = 1,
SRPT_STATE_DATA_IN = 2,
SRPT_STATE_CMD_RSP_SENT = 3,
SRPT_STATE_MGMT_RSP_SENT = 4,
SRPT_STATE_DONE = 5,
SRPT_STATE_NEW = 0,
SRPT_STATE_NEED_DATA = 1,
SRPT_STATE_DATA_IN = 2,
SRPT_STATE_CMD_RSP_SENT = 3,
SRPT_STATE_MGMT = 4,
SRPT_STATE_MGMT_RSP_SENT = 5,
SRPT_STATE_DONE = 6,
};
/**
@@ -202,8 +201,21 @@ struct srpt_recv_ioctx {
/**
* struct srpt_send_ioctx - SRPT send I/O context.
* @ioctx: See above.
* @free_list: Allows to make this struct an entry in srpt_rdma_ch.free_list.
* @state: I/O context state. See also enum srpt_command_state.
* @ch: Channel pointer.
* @rdma_ius: Array with information about the RDMA mapping.
* @rbufs: Pointer to SRP data buffer array.
* @single_rbuf: SRP data buffer if the command has only a single buffer.
* @sg: Pointer to sg-list associated with this I/O context.
* @spinlock: Protects 'state'.
* @state: I/O context state.
* @scmd: SCST command data structure.
* @dir:
* @free_list: Node in srpt_rdma_ch.free_list.
* @sg_cnt: SG-list size.
* @mapped_sg_count: ib_dma_map_sg() return value.
* @n_rdma_ius: Number of elements in the rdma_ius array.
* @n_rdma:
* @n_rbuf: Number of data buffers in the received SRP command.
*/
struct srpt_send_ioctx {
struct srpt_ioctx ioctx;
@@ -213,15 +225,15 @@ struct srpt_send_ioctx {
struct srp_direct_buf single_rbuf;
struct scatterlist *sg;
struct list_head free_list;
spinlock_t spinlock;
enum srpt_command_state state;
struct scst_cmd *scmnd;
scst_data_direction dir;
int sg_cnt;
int mapped_sg_count;
u16 n_rdma_ius;
u8 n_rdma;
u8 n_rbuf;
struct scst_cmd *scmnd;
scst_data_direction dir;
atomic_t state;
};
/**
@@ -236,11 +248,20 @@ struct srpt_mgmt_ioctx {
/**
* enum rdma_ch_state - SRP channel state.
* @CH_CONNECTING: QP is in RTR state; waiting for RTU.
* @CH_LIVE: QP is in RTS state.
* @CH_DISCONNECTING: DREQ has been received and waiting for DREP or DREQ has
* been sent and waiting for DREP or channel is being closed
* for another reason.
* @CH_DRAINING: QP is in ERR state; waiting for last WQE event.
* @CH_RELEASING: Last WQE event has been received; releasing resources.
*/
enum rdma_ch_state {
RDMA_CHANNEL_CONNECTING,
RDMA_CHANNEL_LIVE,
RDMA_CHANNEL_DISCONNECTING
CH_CONNECTING,
CH_LIVE,
CH_DISCONNECTING,
CH_DRAINING,
CH_RELEASING
};
/**
@@ -248,36 +269,38 @@ enum rdma_ch_state {
* @thread: Kernel thread that processes the IB queues associated with
* the channel.
* @cm_id: IB CM ID associated with the channel.
* @rq_size: IB receive queue size.
* @processing_compl: whether or not an IB completion is being processed.
* @qp: IB queue pair used for communicating over this channel.
* @sq_wr_avail: number of work requests available in the send queue.
* @cq: IB completion queue for this channel.
* @rq_size: IB receive queue size.
* @sq_wr_avail: number of work requests available in the send queue.
* @sport: pointer to the information of the HCA port used by this
* channel.
* @i_port_id: 128-bit initiator port identifier copied from SRP_LOGIN_REQ.
* @t_port_id: 128-bit target port identifier copied from SRP_LOGIN_REQ.
* @max_ti_iu_len: maximum target-to-initiator information unit length.
* @supports_cred_req: whether or not the initiator supports SRP_CRED_REQ.
* @req_lim: request limit: maximum number of requests that may be sent
* by the initiator without having received a response.
* @req_lim_delta:
* @spinlock: Protects free_list.
* @free_list: Head of list with free send I/O contexts.
* @ioctx_ring:
* @wc:
* @state: channel state. See also enum rdma_ch_state.
* @list: node for insertion in the srpt_device.rch_list list.
* @cmd_wait_list: list of SCST commands that arrived before the RTU event. This
* list contains struct srpt_ioctx elements and is protected
* against concurrent modification by the cm_id spinlock.
* @spinlock: Protects free_list.
* @free_list: Head of list with free send I/O contexts.
* @scst_sess: SCST session information associated with this SRP channel.
* @sess_name: SCST session name.
* @release_work:
* @release_done:
*/
struct srpt_rdma_ch {
struct task_struct *thread;
struct ib_cm_id *cm_id;
struct ib_qp *qp;
int rq_size;
atomic_t processing_compl;
struct ib_cq *cq;
int rq_size;
atomic_t sq_wr_avail;
struct srpt_port *sport;
u8 i_port_id[16];
@@ -289,12 +312,14 @@ struct srpt_rdma_ch {
struct list_head free_list;
struct srpt_send_ioctx **ioctx_ring;
struct ib_wc wc[16];
atomic_t state;
enum rdma_ch_state state;
struct list_head list;
struct list_head cmd_wait_list;
struct scst_session *scst_sess;
u8 sess_name[36];
struct work_struct release_work;
struct completion *release_done;
};
/**
@@ -319,44 +344,47 @@ struct srpt_port {
/**
* struct srpt_device - Information associated by SRPT with a single HCA.
* @device: backpointer to the struct ib_device managed by the IB core.
* @device: Backpointer to the struct ib_device managed by the IB core.
* @pd: IB protection domain.
* @mr: L_Key (local key) with write access to all local memory.
* @srq: Per-HCA SRQ (shared receive queue).
* @cm_id: connection identifier.
* @dev_attr: attributes of the InfiniBand device as obtained during the
* @cm_id: Connection identifier.
* @dev_attr: Attributes of the InfiniBand device as obtained during the
* ib_client.add() callback.
* @ioctx_ring: Per-HCA I/O context ring.
* @rch_list: per-device channel list -- see also srpt_rdma_ch.list.
* @spinlock: protects rch_list.
* @srpt_port: information about the ports owned by this HCA.
* @event_handler: per-HCA asynchronous IB event handler.
* @dev: per-port srpt-<portname> device instance.
* @srq_size: SRQ size.
* @ioctx_ring: Per-HCA SRQ.
* @rch_list: Per-device channel list -- see also srpt_rdma_ch.list.
* @ch_releaseQ: Enables waiting for removal from rch_list.
* @spinlock: Protects rch_list.
* @port: Information about the ports owned by this HCA.
* @event_handler: Per-HCA asynchronous IB event handler.
* @dev: Per-port srpt-<portname> device instance.
* @scst_tgt: SCST target information associated with this HCA.
* @enabled: Whether or not this SCST target is enabled.
*/
struct srpt_device {
struct ib_device *device;
struct ib_pd *pd;
struct ib_mr *mr;
struct ib_srq *srq;
struct ib_cm_id *cm_id;
struct ib_device_attr dev_attr;
int srq_size;
struct srpt_recv_ioctx **ioctx_ring;
struct list_head rch_list;
spinlock_t spinlock;
struct srpt_port port[2];
struct ib_event_handler event_handler;
struct ib_device *device;
struct ib_pd *pd;
struct ib_mr *mr;
struct ib_srq *srq;
struct ib_cm_id *cm_id;
struct ib_device_attr dev_attr;
int srq_size;
struct srpt_recv_ioctx **ioctx_ring;
struct list_head rch_list;
wait_queue_head_t ch_releaseQ;
spinlock_t spinlock;
struct srpt_port port[2];
struct ib_event_handler event_handler;
#ifdef CONFIG_SCST_PROC
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
struct class_device dev;
struct class_device dev;
#else
struct device dev;
struct device dev;
#endif
#endif /*CONFIG_SCST_PROC*/
struct scst_tgt *scst_tgt;
bool enabled;
struct scst_tgt *scst_tgt;
bool enabled;
};
#endif /* IB_SRPT_H */