mirror of
https://github.com/SCST-project/scst.git
synced 2026-09-20 15:04:19 +00:00
ib_srpt: Merged from trunk (svn merge -r2072:2459 https://scst.svn.sourceforge.net/svnroot/scst/trunk/srpt).
git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.0.0.x@2468 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
+601
-793
File diff suppressed because it is too large
Load Diff
+88
-104
@@ -74,7 +74,7 @@ enum {
|
||||
SRP_RDMA_WRITE_FROM_IOC = 0x20,
|
||||
|
||||
/*
|
||||
* srp_login_cmd::req_flags bitmasks. See also table 9 in the SRP r16a
|
||||
* srp_login_cmd.req_flags bitmasks. See also table 9 in the SRP r16a
|
||||
* document.
|
||||
*/
|
||||
SRP_MTCH_ACTION = 0x03, /* MULTI-CHANNEL ACTION */
|
||||
@@ -83,14 +83,14 @@ enum {
|
||||
SRP_AESOLNT = 0x40, /* asynchronous event solicited notification */
|
||||
|
||||
/*
|
||||
* srp_cmd::sol_nt / srp_tsk_mgmt::sol_not bitmasks. See also tables
|
||||
* srp_cmd.sol_nt / srp_tsk_mgmt.sol_not bitmasks. See also tables
|
||||
* 18 and 20 in the T10 r16a document.
|
||||
*/
|
||||
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
|
||||
* srp_rsp.sol_not / srp_t_logout.sol_not bitmasks. See also tables
|
||||
* 16 and 22 in the T10 r16a document.
|
||||
*/
|
||||
SRP_SOLNT = 0x01, /* SOLNT = solicited notification */
|
||||
@@ -120,45 +120,24 @@ enum {
|
||||
DEFAULT_SRPT_SRQ_SIZE = 4095,
|
||||
MAX_SRPT_SRQ_SIZE = 65535,
|
||||
|
||||
MIN_MAX_MESSAGE_SIZE = 996,
|
||||
DEFAULT_MAX_MESSAGE_SIZE
|
||||
MIN_MAX_REQ_SIZE = 996,
|
||||
DEFAULT_MAX_REQ_SIZE
|
||||
= sizeof(struct srp_cmd)/*48*/
|
||||
+ sizeof(struct srp_indirect_buf)/*20*/
|
||||
+ 128 * sizeof(struct srp_direct_buf)/*16*/,
|
||||
|
||||
MIN_MAX_RSP_SIZE = sizeof(struct srp_rsp)/*36*/ + 4,
|
||||
DEFAULT_MAX_RSP_SIZE = 256, /* leaves 220 bytes for sense data */
|
||||
|
||||
DEFAULT_MAX_RDMA_SIZE = 65536,
|
||||
|
||||
/*
|
||||
* Number of I/O contexts to be allocated for sending back requests
|
||||
* from the target to the initiator. Must be a power of two.
|
||||
*/
|
||||
TTI_IOCTX_COUNT = 2,
|
||||
TTI_IOCTX_MASK = TTI_IOCTX_COUNT - 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* @SRPT_OP_TTI: wr_id flag for marking requests sent by the target to the
|
||||
* initiator.
|
||||
* @SRPT_OP_RECV: wr_id flag for marking receive operations.
|
||||
*/
|
||||
enum {
|
||||
SRPT_OP_TTI = (1 << 30),
|
||||
SRPT_OP_RECV = (1 << 31),
|
||||
|
||||
SRPT_OP_FLAGS = SRPT_OP_TTI | SRPT_OP_RECV,
|
||||
};
|
||||
|
||||
/*
|
||||
* SRP_CRED_REQ information unit, as defined in section 6.10 of the T10 SRP
|
||||
* r16a document.
|
||||
*/
|
||||
struct srp_cred_req {
|
||||
u8 opcode;
|
||||
u8 sol_not;
|
||||
u8 reserved[2];
|
||||
__be32 req_lim_delta;
|
||||
__be64 tag;
|
||||
};
|
||||
static inline u64 encode_wr_id(u8 opcode, u32 idx)
|
||||
{ return ((u64)opcode << 32) | idx; }
|
||||
static inline u8 opcode_from_wr_id(u64 wr_id)
|
||||
{ return wr_id >> 32; }
|
||||
static inline u32 idx_from_wr_id(u64 wr_id)
|
||||
{ return (u32)wr_id; }
|
||||
|
||||
struct rdma_iu {
|
||||
u64 raddr;
|
||||
@@ -169,7 +148,7 @@ struct rdma_iu {
|
||||
};
|
||||
|
||||
/**
|
||||
* enum srpt_command_state - SCSI command states managed by SRPT.
|
||||
* enum srpt_command_state - SCSI command state managed by SRPT.
|
||||
* @SRPT_STATE_NEW: New command arrived and is being processed.
|
||||
* @SRPT_STATE_NEED_DATA: Processing a write or bidir command and waiting
|
||||
* for data arrival.
|
||||
@@ -191,45 +170,60 @@ enum srpt_command_state {
|
||||
};
|
||||
|
||||
/**
|
||||
* struct srpt_ioctx - SRPT-private data associated with a struct scst_cmd.
|
||||
* @index: Index of the I/O context in ioctx_ring.
|
||||
* @buf: Pointer to the message transferred via this I/O context.
|
||||
* @dma: DMA address of buf.
|
||||
* @wait_list: Node for insertion in srpt_rdma_ch::cmd_wait_list.
|
||||
* @state: I/O context state. See also enum srpt_command_state.
|
||||
* struct srpt_ioctx - Shared SRPT I/O context information.
|
||||
* @buf: Pointer to the buffer.
|
||||
* @dma: DMA address of the buffer.
|
||||
* @index: Index of the I/O context in its ioctx_ring array.
|
||||
*/
|
||||
struct srpt_ioctx {
|
||||
int index;
|
||||
void *buf;
|
||||
dma_addr_t dma;
|
||||
struct rdma_iu *rdma_ius;
|
||||
struct srp_direct_buf *rbufs;
|
||||
struct srp_direct_buf single_rbuf;
|
||||
struct list_head wait_list;
|
||||
int mapped_sg_count;
|
||||
u16 n_rdma_ius;
|
||||
u8 n_rdma;
|
||||
u8 n_rbuf;
|
||||
void *buf;
|
||||
dma_addr_t dma;
|
||||
uint32_t index;
|
||||
};
|
||||
|
||||
u64 wr_id;
|
||||
enum ib_wc_status status;
|
||||
enum ib_wc_opcode opcode;
|
||||
struct srpt_rdma_ch *ch;
|
||||
struct scst_cmd *scmnd;
|
||||
scst_data_direction dir;
|
||||
atomic_t state;
|
||||
/**
|
||||
* struct srpt_recv_ioctx - SRPT receive I/O context.
|
||||
* @ioctx: See above.
|
||||
* @wait_list: Node for insertion in srpt_rdma_ch.cmd_wait_list.
|
||||
*/
|
||||
struct srpt_recv_ioctx {
|
||||
struct srpt_ioctx ioctx;
|
||||
struct list_head wait_list;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
struct srpt_send_ioctx {
|
||||
struct srpt_ioctx ioctx;
|
||||
struct srpt_rdma_ch *ch;
|
||||
struct rdma_iu *rdma_ius;
|
||||
struct srp_direct_buf *rbufs;
|
||||
struct srp_direct_buf single_rbuf;
|
||||
struct scatterlist *sg;
|
||||
struct list_head free_list;
|
||||
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;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct srpt_mgmt_ioctx - SCST management command context information.
|
||||
* @ioctx: SRPT I/O context associated with the management command.
|
||||
* @ch: RDMA channel over which the management command has been received.
|
||||
* @tag: SCSI tag of the management command.
|
||||
*/
|
||||
struct srpt_mgmt_ioctx {
|
||||
struct srpt_ioctx *ioctx;
|
||||
struct srpt_rdma_ch *ch;
|
||||
u64 tag;
|
||||
struct srpt_send_ioctx *ioctx;
|
||||
u64 tag;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -259,51 +253,41 @@ enum rdma_ch_state {
|
||||
* @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 or
|
||||
* SRP_CRED_REQ.
|
||||
* @req_lim_delta: req_lim_delta to be sent in the next SRP_RSP.
|
||||
* @req_lim_waiter_count: number of threads waiting on req_lim_wait.
|
||||
* @req_lim_compl: completion variable that is signalled every time req_lim
|
||||
* has been incremented.
|
||||
* by the initiator without having received a response.
|
||||
* @state: channel state. See also enum rdma_ch_state.
|
||||
* @list: node for insertion in the srpt_device::rch_list list.
|
||||
* @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.
|
||||
* @tti_head: Index of first element of tti_ioctx that is not in use.
|
||||
* @tti_tail: Index of first element of tti_ioctx that is in use.
|
||||
* @tti_ioctx: Circular buffer with I/O contexts for sending requests from
|
||||
* target to initiator.
|
||||
* @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.
|
||||
*/
|
||||
struct srpt_rdma_ch {
|
||||
wait_queue_head_t wait_queue;
|
||||
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;
|
||||
atomic_t sq_wr_avail;
|
||||
struct srpt_port *sport;
|
||||
u8 i_port_id[16];
|
||||
u8 t_port_id[16];
|
||||
int max_ti_iu_len;
|
||||
atomic_t supports_cred_req;
|
||||
atomic_t req_lim;
|
||||
atomic_t req_lim_delta;
|
||||
atomic_t req_lim_waiter_count;
|
||||
struct completion req_lim_compl;
|
||||
atomic_t state;
|
||||
struct list_head list;
|
||||
struct list_head cmd_wait_list;
|
||||
int tti_head;
|
||||
int tti_tail;
|
||||
struct srpt_ioctx *tti_ioctx[TTI_IOCTX_COUNT];
|
||||
wait_queue_head_t wait_queue;
|
||||
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;
|
||||
atomic_t sq_wr_avail;
|
||||
struct srpt_port *sport;
|
||||
u8 i_port_id[16];
|
||||
u8 t_port_id[16];
|
||||
int max_ti_iu_len;
|
||||
atomic_t req_lim;
|
||||
spinlock_t spinlock;
|
||||
struct list_head free_list;
|
||||
struct srpt_send_ioctx **ioctx_ring;
|
||||
struct ib_wc wc[16];
|
||||
atomic_t state;
|
||||
struct list_head list;
|
||||
struct list_head cmd_wait_list;
|
||||
|
||||
struct scst_session *scst_sess;
|
||||
u8 sess_name[36];
|
||||
struct scst_session *scst_sess;
|
||||
u8 sess_name[36];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -334,9 +318,9 @@ struct srpt_port {
|
||||
* @srq: Per-HCA SRQ (shared receive queue).
|
||||
* @cm_id: connection identifier.
|
||||
* @dev_attr: attributes of the InfiniBand device as obtained during the
|
||||
* ib_client::add() callback.
|
||||
* ib_client.add() callback.
|
||||
* @ioctx_ring: Per-HCA I/O context ring.
|
||||
* @rch_list: per-device channel list -- see also srpt_rdma_ch::list.
|
||||
* @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.
|
||||
@@ -352,13 +336,13 @@ struct srpt_device {
|
||||
struct ib_cm_id *cm_id;
|
||||
struct ib_device_attr dev_attr;
|
||||
int srq_size;
|
||||
struct srpt_ioctx **ioctx_ring;
|
||||
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;
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
|
||||
struct class_device class_dev;
|
||||
struct class_device dev;
|
||||
#else
|
||||
struct device dev;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user