idm_impl.h revision a668b114487acbb725f522170849c39f8e844673
/*
* 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 _IDM_IMPL_H_
#define _IDM_IMPL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/socket_impl.h>
/*
* IDM lock order:
*
* idm_taskid_table_lock, idm_task_t.idt_mutex
*/
#define CF_LOGIN_READY 0x00000001
#define CF_INITIAL_LOGIN 0x00000002
#define CF_ERROR 0x80000000
typedef enum {
CONN_TYPE_INI = 1,
/*
* Watchdog interval in seconds
*/
#define IDM_WD_INTERVAL 5
/*
* Timeout period before the client "keepalive" callback is invoked in
* seconds if the connection is idle.
*/
#define IDM_TRANSPORT_KEEPALIVE_IDLE_TIMEOUT 20
/*
* Timeout period before a TRANSPORT_FAIL event is generated in seconds
* if the connection is idle.
*/
#define IDM_TRANSPORT_FAIL_IDLE_TIMEOUT 30
/*
* IDM reference count structure. Audit code is shamelessly adapted
* from CIFS server.
*/
#define REFCNT_AUDIT_STACK_DEPTH 16
#define REFCNT_AUDIT_BUF_MAX_REC 16
typedef struct {
int anr_depth;
typedef struct {
int anb_index;
int anb_max_index;
#define REFCNT_AUDIT(_rf_) { \
\
}
struct idm_refcnt_s;
typedef void (idm_refcnt_cb_t)(void *ref_obj);
typedef enum {
typedef struct idm_refcnt_s {
int ir_refcnt;
void *ir_referenced_obj;
} idm_refcnt_t;
/*
* connection parameters - These parameters would be populated at
* connection create, or during key-value negotiation at login
*/
typedef struct idm_conn_params_s {
typedef struct idm_svc_s {
int is_online;
/* transport-specific service components */
void *is_so_svc;
void *is_iser_svc;
} idm_svc_t;
typedef struct idm_conn_s {
void *ic_handle;
/*
* the target_name, initiator_name, initiator session
* identifier and target session identifying handle
* are only used for target connections.
*/
int ic_pdu_events;
int ic_transport_hdrlen;
void *ic_transport_private;
/*
* Save client callback to interpose idm callback
*/
} idm_conn_t;
#define IDM_CONN_HEADER_DIGEST 0x00000001
#define IDM_CONN_DATA_DIGEST 0x00000002
#define IDM_CONN_USE_SCOREBOARD 0x00000004
/*
* An IDM target task can transfer data using multiple buffers. The task
* will maintain a list of buffers, and each buffer will contain the relative
* offset of the transfer and a pointer to the next buffer in the list.
*
* Note on client private data:
* idt_private is intended to be a pointer to some sort of client-
* specific state.
*
* idt_client_handle is a more generic client-private piece of data that can
* be used by the client for the express purpose of task lookup. The driving
* use case for this is for the client to store the initiator task tag for
* a given task so that it may be more easily retrieved for task management.
*
* The key take away here is that clients should never call
* idm_task_find_by_handle in the performance path.
*
* An initiator will require only one buffer per task, the offset will be 0.
*/
typedef struct idm_task_s {
/* connection type is in idt_ic->ic_conn_type */
void *idt_private; /* Client private data */
/*
* Statistics
*/
int idt_tx_to_ini_start;
int idt_tx_to_ini_done;
int idt_rx_from_ini_done;
int idt_tx_bytes; /* IDM_CONN_USE_SCOREBOARD */
int idt_rx_bytes; /* IDM_CONN_USE_SCOREBOARD */
/*
* Transport header, which describes this tasks remote tagged buffer
*/
int idt_transport_hdrlen;
void *idt_transport_hdr;
} idm_task_t;
#define IDM_TASKIDS_MAX 16384
/* Protect with task mutex */
typedef struct idm_buf_s {
/*
* Note: idm_tx_link *must* be the second element in the list for
* proper TX PDU ordering.
*/
void *idb_buf; /* data */
/*
* DataPDUInOrder=Yes, so to track that the PDUs in a sequence are sent
* in continuously increasing address order, check that offsets for a
* single buffer xfer are in order.
*/
void *idb_buf_private; /* transport-specific buf handle */
void *idb_reg_private; /* transport-specific reg handle */
void *idb_bufptr; /* transport-specific bcopy pointer */
void *idb_cb_arg; /* Client private data */
} idm_buf_t;
typedef enum {
typedef struct idm_bufpat_s {
void *bufpat_idb;
} idm_bufpat_t;
#define PDU_MAX_IOVLEN 12
typedef struct idm_pdu_s {
/*
* Internal - Order is vital. idm_tx_link *must* be the second
* element in this structure for proper TX PDU ordering.
*/
/* Transport header */
void *isp_transport_hdr;
void *isp_transport_private;
/*
* isp_data is used for sending SCSI status, NOP, text, scsi and
* non-scsi data. Data is received using isp_iov and isp_iovlen
* to support data over multiple buffers.
*/
void *isp_private;
/*
* The following four elements are only used in
* idm_sorecv_scsidata() currently.
*/
int isp_iovlen;
/* Implementation data for idm_pdu_alloc and sorx PDU cache */
} idm_pdu_t;
/*
* This "generic" object is used when removing an item from the ic_tx_list
* in order to determine whether it's an idm_pdu_t or an idm_buf_t
*/
typedef struct {
/*
* idm_tx_link *must* be the second element in this structure.
*/
} idm_tx_obj_t;
#define IDM_PDU_OPCODE(PDU) \
#define IDM_PDU_ALLOC 0x00000001
#define IDM_PDU_ADDL_HDR 0x00000002
#define IDM_PDU_ADDL_DATA 0x00000004
#define IDM_PDU_LOGIN_TX 0x00000008
#define BIDI_AHS_LENGTH 5
#define IDM_SORX_CACHE_AHSLEN \
(((OSD_EXT_CDB_AHSLEN + 3) + \
/*
* ID pool
*/
typedef struct idm_idpool {
} idm_idpool_t;
/*
* Global IDM state structure
*/
typedef struct {
int idm_tgt_conn_count;
} idm_global_t;
int
void
int
void
void
void
void
void
void
idm_conn_t **ic_result);
uint32_t idm_cid_alloc(void);
#ifdef __cplusplus
}
#endif
#endif /* _IDM_IMPL_H_ */