srpt_impl.h revision 1bdd6c0e3710e91cb1f31aa78de33cb638494480
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SRPT_IMPL_H_
#define _SRPT_IMPL_H_
/*
* Prototypes and data structures for the SRP Target Port Provider.
*/
#include <stmf.h>
#include <stmf_ioctl.h>
#include <portif.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Specifically, SEND_MSG_SIZE and SEND_MSG_DEPTH.
*/
enum {
SRPT_DEFAULT_IOC_SRQ_SIZE = 4096,
SRPT_DEFAULT_SEND_MSG_DEPTH = 128,
SRPT_DEFAULT_MAX_RDMA_SIZE = 65536,
SRPT_MIN_T_I_IU_LEN = 52,
SRPT_EUI_ID_LEN = 20,
SRPT_RECV_WC_POLL_SIZE = 16,
SRPT_SEND_WC_POLL_SIZE = 16,
SRPT_MAX_OUT_IO_PER_CMD = 16,
SRPT_FENCE_SEND = 1,
};
struct srpt_target_port_s;
/*
* SRP Session - represents a SCSI I_T_Nexus.
*
* Sessions map 1 or more initiator logins to a specific I/O
* Controller SCSI Target Port. Targets create sessions
* at initiator login and release when no longer referenced
* by a login.
*/
typedef struct srpt_session_s {
/*
* ADVANCED FEATURE, NOT YET SUPPORTED.
* In multi-channel mode, multiple RDMA communication
* channels may reference the same SCSI session. When
* a channel releases its reference to the SCSI session,
* it should have no tasks associated with the session.
*
* If multi-channel is implemented, add a channel list
* to this object instead of tracking it on the target.
*
* Will also need a session state & mode. Mode is to
* track if the session is MULTI or SINGLE channel.
*/
struct srpt_target_port_s *ss_tgt;
/*
* SRP Initiator and target identifiers are 128-bit.
*
* The specification defines the initiator to be 64-bits of
* ID extension and 64 bits of GUID, but these are really
* just a recommendation. Generally the extension is used
* to create unique I_T_Nexus from the same initiator and
* target. Initiators are inconsistent on the GUID they
* use, some use the HCA Node, some the HCA port.
*
* The specification defines the target to be 64-bits of
* service ID followed by 64-bits of I/O Controller GUID.
* In the case where there is a single default target
* service, they will be the same (our default).
*/
/* So we can see the full 128-bit initiator login from stmfadm */
/*
* Send work request types.
*/
typedef enum srpt_swqe_type_e {
SRPT_SWQE_TYPE_DATA = 1,
typedef struct srpt_swqe_s {
void *sw_addr;
} srpt_swqe_t;
/*
* SRP Channel - the RDMA communications channel associated with
* a specific SRP login.
*/
typedef enum srpt_channel_state_e {
typedef struct srpt_channel_s {
struct srpt_target_port_s *ch_tgt;
/*
* Map IB send WQE request IDs to the
* apporpriate operation type (for errors).
*/
/*
* SRP Information Unit (IU). Each IU structure contains
* the buffer for the IU itself (received over the RC
* channel), and all of the context required by the target
* to process this request represented by the IU.
* Available IU structures are managed on the I/O Controller
* shared receive queue.
*/
enum {
};
typedef struct srpt_iu_s {
/*
* The buffer for the IU itself. When unused (a
* reference count of zero), this buffer is posted
* on the I/O Controllers SRPT SRQ.
*/
void *iu_buf;
struct srpt_ioc_s *iu_ioc;
/*
* The following are reset for each IU request
* processed by this buffer.
*/
} srpt_iu_t;
/*
* SRP SCSI Target Port. By default each HCA creates a single
* SCSI Target Port based on the associated I/O Controller
* (HCA) node GUID and made available through each physical
* hardware port of the I/O Controller.
*/
typedef enum srpt_target_state_e {
typedef struct srpt_hw_port_s {
typedef struct srpt_target_port_s {
struct srpt_ioc_s *tp_ioc;
/*
* We are using a simple list for channels right now, we
* probably should switch this over to the AVL
* implementation eventually (but lookups are not done
* in the data path so this is not urgent).
*/
/*
* A list of active sessions. Session lifetime is
* determined by having active channels, but track
* them here for easier determination to when a
* target can truly be offlined, and as a step toward
* being session-focused rather than channel-focused.
* If we ever truly support multi-channel, move the
* channels to be part of the session object.
*
* Sessions should remain on this list until they
* are deregistered from STMF. This allows the target
* to properly track when it can consider itself 'offline'.
*/
/*
* SRP Target hardware device. A SRP Target hardware device
* is an IB HCA. All ports of the HCA comprise a single
* I/O Controller that is registered with the IB Device
* Managment Agent.
*/
typedef struct srpt_ioc_s {
/*
* By default each HCA is a single SRP.T10 service based on
* the HCA GUID. We have implemented the target here as a
* pointer to facilitate moving to a list of targets if
* appropriate down the road.
*/
/*
* Each HCA registers a single I/O Controller with the
* IB Device Management Agent.
*/
/*
* The I/O Controller pool of IU resources allocated
* at controller creation.
*/
void *ioc_iu_bufs; /* iu buffer space */
/*
* Each I/O Controller has it's own data buffer
* vmem arena. Pool is created at controller creation,
* and expanded as required. This keeps IB memory
* registrations to a minimum in the data path.
*/
struct srpt_vmem_pool_s *ioc_dbuf_pool;
} srpt_ioc_t;
/*
* Memory regions
*/
typedef struct srpt_mr_s {
} srpt_mr_t;
/*
* SRP Target vmem arena definition
*/
typedef struct srpt_vmem_pool_s {
/*
* SRP port provider data buffer, allocated and freed
* via calls to the IOC datastore.
*/
typedef struct srpt_ds_dbuf_s {
/*
* SRP Target service state
*/
typedef enum {
typedef struct {
/*
* SRP Target protocol driver context data structure, maintaining
* the global state of the protocol.
*/
typedef struct srpt_ctxt_s {
/*
* SRP Target I/O Controllers. Each IBT HCA represents an
* I/O Controller. Must hold rwlock as a writer to update.
*/
/* Back-end COMSTAR port provider interface. */
/* IBDMA entry points */
} srpt_ctxt_t;
typedef struct srpt_iu_data_s {
union {
} rx_iu;
extern srpt_ctxt_t *srpt_ctxt;
/*
* For Non recoverable or Major Errors
*/
#define SRPT_LOG_L0 0
/*
* For additional information on Non recoverable errors and
* warnings/informational message for sys-admin types.
*/
#define SRPT_LOG_L1 1
/*
* debug only
* for more verbose trace than L1, for e.g. recoverable errors,
* or intersting trace
*/
#define SRPT_LOG_L2 2
/*
* debug only
* for more verbose trace than L2, for e.g. printing function entries....
*/
#define SRPT_LOG_L3 3
/*
* debug only
* for more verbose trace than L3, for e.g. printing minor function entries...
*/
#define SRPT_LOG_L4 4
/*
* srpt_errlevel can be set in the debugger to enable additional logging.
* The default log level is L2 for debug builds, otherwise L1.
*/
#ifdef DEBUG
#define SRPT_LOG_DEFAULT_LEVEL SRPT_LOG_L2
#else
#define SRPT_LOG_DEFAULT_LEVEL SRPT_LOG_L1
#endif
extern uint_t srpt_errlevel;
}
#ifdef DEBUG
}
}
#else
#define SRPT_DPRINTF_L3 0 &&
#define SRPT_DPRINTF_L4 0 &&
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SRPT_IMPL_H_ */