OneCore⢠Storage SDK Release 11.2
User Space iSCSI Target RAMD Driver (Uspace ocs_iscsi_ramd)
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
ocs_scsi_tgt.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011-2015, Emulex
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
7
*
8
* 1. Redistributions of source code must retain the above copyright notice,
9
* this list of conditions and the following disclaimer.
10
*
11
* 2. Redistributions in binary form must reproduce the above copyright notice,
12
* this list of conditions and the following disclaimer in the documentation
13
* and/or other materials provided with the distribution.
14
*
15
* 3. Neither the name of the copyright holder nor the names of its contributors
16
* may be used to endorse or promote products derived from this software
17
* without specific prior written permission.
18
*
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
* POSSIBILITY OF SUCH DAMAGE.
30
*
31
*/
32
33
/**
34
* @file
35
* Declares the target specific structures required by the base driver
36
*/
37
38
#if !defined(__OCS_SCSI_TGT_H__)
39
#define __OCS_SCSI_TGT_H__
40
41
#define OCS_INCLUDE_RAMD
42
43
#include "
ocs_scsi.h
"
44
#include "
ocs_ramdisc.h
"
45
#include "
ocs_ramd_thread.h
"
46
47
/**
48
* @brief target private ocs structure
49
*/
50
51
typedef
struct
{
52
uint32_t
max_sge
;
53
uint32_t
max_sgl
;
54
55
/*
56
* Variables used to send task set full. We are using a high watermark
57
* method to send task set full. We will reserve a fixed number of IOs
58
* per initiator plus a fudge factor. Once we reach this number,
59
* then the target will start sending task set full/busy responses.
60
*/
61
ocs_atomic_t
initiator_count
;
/**< count of initiators */
62
uint32_t
enable_task_set_full
;
/**< enable generation of task set full */
63
ocs_atomic_t
io_high_watermark
;
/**< used to send task set full */
64
ocs_atomic_t
watermark_hit
;
/**< used to track how often IO pool almost empty */
65
int32_t
watermark_min
;
/**< lower limit for watermark */
66
int32_t
watermark_max
;
/**< upper limit for watermark */
67
68
/* RAM disk */
69
uint8_t
use_global_ramd
;
/**< flag to allocate globally or on sport */
70
ocs_ramdisc_t
**
rdisc
;
/**< pointer to array of ramdisc instances, one per LUN */
71
uint32_t
rdisc_count
;
/**< count of ramdisc instances */
72
73
ocs_list_t
port_rdisc_head
;
74
}
ocs_scsi_tgt_t
;
75
76
/**
77
* @brief target private domain structure
78
*/
79
80
typedef
struct
{
81
/* ocs_ramd decls */
82
;
83
}
ocs_scsi_tgt_domain_t
;
84
85
/**
86
* @brief target private sport structure
87
*/
88
89
typedef
struct
{
90
/* ocs_ramd decls - Used when allocating ramdisk on sport instead of globally */
91
ocs_ramdisc_t
**
rdisc
;
/**< pointer to array of ramdisc instances, one per LUN */
92
uint32_t
rdisc_count
;
/**< count of ramdisc instances */
93
}
ocs_scsi_tgt_sport_t
;
94
95
/**
96
* @brief ocs_ramdisc_ua_t represents a single UNIT ATTENTION condition
97
*/
98
99
typedef
struct
ocs_ramdisc_ua_s {
100
uint8_t
asc
;
101
uint8_t
ascq
;
102
ocs_list_link_t
link
;
103
}
ocs_ramdisc_ua_t
;
104
105
/**
106
* @brief ocs_ramdisc_ua_t is a collection of UNIT ATTENTION conditions
107
*
108
* SAM 5.14 refers to this as a "queue of unit attention conditions of
109
* unspecified order" but there's no reason it needs to be
110
* a queue. In this implementation it will be a list
111
*/
112
typedef
struct
ocs_ramdisc_ua_queue_s {
113
ocs_lock_t
ua_queue_lock
;
114
uint32_t
num_entries
;
115
ocs_list_t
entry_list
;
116
}
ocs_ramdisc_ua_queue_t
;
117
118
119
/**
120
* @brief target private node structure
121
*
122
* This structure holds information that relates to a node (I_T nexus)
123
* that is owned and used by the target.
124
*
125
* ua_queues is a dynamically allocated list of ocs_ramdisc_ua_queue_t
126
* The list is allocated by ocs_scsi_new_initiator when a new initiator
127
* is discovered. There is a one ua_queue for each LUN
128
*/
129
130
typedef
struct
{
131
uint32_t
num_ua_queues
;
132
ocs_ramdisc_ua_queue_t
*
ua_queues
;
133
}
ocs_scsi_tgt_node_t
;
134
135
/**
136
* @brief target private IO structure
137
*/
138
139
typedef
struct
{
140
/* save input arguments */
141
uint32_t
flags
;
/**< flags */
142
ocs_dma_t *
first_burst_buffers
;
/**< array of DMA first burst buffers */
143
void
*
pcmd
;
/**< pointer to scsi_cmd_table_t */
144
uint8_t
has_first_burst
;
/**< flag indicating that command has first burst */
145
uint8_t cdb[
OCS_SCSI_MAX_CDB_LEN
];
/**< CDB */
146
uint32_t
cdb_len
;
/**< length of CDB */
147
148
uint64_t
io_lba
;
/**< The starting LBA */
149
uint32_t
first_burst_bytes
;
/**< Number of bytes in first burst */
150
ocs_scsi_dif_info_t
dif_info
;
/**< DIF information */
151
152
uint8_t
mode_select_opcode
;
/**< Mode select command opcode */
153
154
/* Deferred status send when waiting for first burst to complete*/
155
uint8_t send_task_set_full:1,
/**< if TRUE, then send task set full status after first burst */
156
send_check_cond:1;
/**< if TRUE, then send check condition response after first burst */
157
uint8_t
send_sense_key
;
/**< response sense key if send_check_cond */
158
uint8_t
send_asc
;
/**< response asc if send_check_cond */
159
uint8_t
send_ascq
;
/**< response ascq if send_check_cond */
160
161
/* target server */
162
uint32_t
lun
;
/**< LUN */
163
ocs_ramdisc_t
*
ramdisc
;
/**< Pointer to ramdisc object */
164
uint8_t
lun_is_valid
;
/**< flag indicating that the LUN value is valid */
165
166
uint8_t
is_read
;
/**< flag to identify reads */
167
168
/* Block command variables */
169
uint32_t
io_block_count
;
/**< request IO size in blocks */
170
uint32_t
acc_block_count
;
/**< accumulated block count, updated after successful dataphase */
171
uint64_t
cur_lba
;
/**< current dataphase LBA */
172
uint32_t
cur_block_count
;
/**< current dataphase block count */
173
uint32_t sgl_phys:1;
/**< if set, then build phys SGL (data+DIF) */
174
175
ocs_dma_t
payload
;
/**< payload for commands that need it */
176
uint8_t
supress_auto_response
;
/**< disable auto response if true */
177
178
/* Values saved from the CDB for the FORMAT UNIT commands */
179
uint8_t
fmtpinfo
;
/**< FMTPINFO value */
180
181
/* Values saved from the CDB for the WRITE SAME commands */
182
uint8_t
pbdata
;
/**< PBDATA flag */
183
uint8_t
lbdata
;
/**< LBDATA flag */
184
uint8_t
wrprotect
;
/**< WRPROTECT value */
185
uint32_t
num_blocks
;
/**< NUMBER OF LOCICAL BLOCKS value */
186
187
/* Abort Task */
188
ocs_io_t *
tmfio
;
/**< Pointer to the TMF IO object for an abort task */
189
190
ocs_lock_t
sm_lock
;
/**< SM lock, to serialize execution while in multi-threaded environment */
191
ocs_sm_ctx_t
sm
;
/**< SCSI ramdisc I/O state machine context */
192
uint8_t
current_state
;
/**< current state of IO state machine */
193
194
ocs_ramd_thread_t
*
thr
;
195
}
ocs_scsi_tgt_io_t
;
196
197
#endif
/* __OCS_SCSI_TGT_H__ */
ocs_scsi.h
ocs_scsi_tgt_io_t::pbdata
uint8_t pbdata
Definition:
ocs_scsi_tgt.h:182
ocs_scsi_tgt_io_t::mode_select_opcode
uint8_t mode_select_opcode
Definition:
ocs_scsi_tgt.h:152
ocs_scsi_tgt_io_t::wrprotect
uint8_t wrprotect
Definition:
ocs_scsi_tgt.h:184
ocs_scsi_tgt_io_t
target private IO structure
Definition:
ocs_scsi_tgt.h:139
ocs_scsi_tgt_io_t::lun
uint32_t lun
Definition:
ocs_scsi_tgt.h:162
ocs_scsi_tgt_t
target private ocs structure
Definition:
ocs_scsi_tgt.h:51
ocs_ramdisc_ua_t::asc
uint8_t asc
Definition:
ocs_scsi_tgt.h:100
ocs_list_link_t
ocs_list_t ocs_list_link_t
Definition:
ocs_list.h:84
ocs_scsi_tgt_io_t::lbdata
uint8_t lbdata
Definition:
ocs_scsi_tgt.h:183
ocs_ramdisc_ua_t::link
ocs_list_link_t link
Definition:
ocs_scsi_tgt.h:102
ocs_scsi_tgt_node_t::num_ua_queues
uint32_t num_ua_queues
Definition:
ocs_scsi_tgt.h:131
ocs_scsi_tgt_io_t::acc_block_count
uint32_t acc_block_count
Definition:
ocs_scsi_tgt.h:170
ocs_scsi_dif_info_t
T10 DIF information passed to the transport.
Definition:
ocs_scsi.h:229
ocs_scsi_tgt_t::watermark_max
int32_t watermark_max
Definition:
ocs_scsi_tgt.h:66
ocs_scsi_tgt_io_t::send_ascq
uint8_t send_ascq
Definition:
ocs_scsi_tgt.h:159
ocs_scsi_tgt_node_t
target private node structure
Definition:
ocs_scsi_tgt.h:130
ocs_scsi_tgt_t::rdisc
ocs_ramdisc_t ** rdisc
Definition:
ocs_scsi_tgt.h:70
ocs_ramdisc_ua_queue_t
ocs_ramdisc_ua_t is a collection of UNIT ATTENTION conditions
Definition:
ocs_scsi_tgt.h:112
ocs_scsi_tgt_io_t::io_block_count
uint32_t io_block_count
Definition:
ocs_scsi_tgt.h:169
ocs_scsi_tgt_domain_t
target private domain structure
Definition:
ocs_scsi_tgt.h:80
ocs_ramdisc_ua_t::ascq
uint8_t ascq
Definition:
ocs_scsi_tgt.h:101
ocs_scsi_tgt_io_t::is_read
uint8_t is_read
Definition:
ocs_scsi_tgt.h:166
ocs_scsi_tgt_sport_t
target private sport structure
Definition:
ocs_scsi_tgt.h:89
ocs_scsi_tgt_io_t::tmfio
ocs_io_t * tmfio
Definition:
ocs_scsi_tgt.h:188
ocs_scsi_tgt_t::rdisc_count
uint32_t rdisc_count
Definition:
ocs_scsi_tgt.h:71
ocs_scsi_tgt_io_t::send_asc
uint8_t send_asc
Definition:
ocs_scsi_tgt.h:158
ocs_scsi_tgt_io_t::thr
ocs_ramd_thread_t * thr
Definition:
ocs_scsi_tgt.h:194
ocs_scsi_tgt_io_t::has_first_burst
uint8_t has_first_burst
Definition:
ocs_scsi_tgt.h:144
OCS_SCSI_MAX_CDB_LEN
#define OCS_SCSI_MAX_CDB_LEN
Definition:
ocs_scsi.h:62
ocs_ramdisc_t
ramdisc instance structure
Definition:
ocs_ramdisc.h:88
ocs_scsi_tgt_t::enable_task_set_full
uint32_t enable_task_set_full
Definition:
ocs_scsi_tgt.h:62
ocs_scsi_tgt_t::max_sgl
uint32_t max_sgl
Definition:
ocs_scsi_tgt.h:53
ocs_scsi_tgt_io_t::current_state
uint8_t current_state
Definition:
ocs_scsi_tgt.h:192
ocs_scsi_tgt_io_t::send_sense_key
uint8_t send_sense_key
Definition:
ocs_scsi_tgt.h:157
ocs_scsi_tgt_io_t::flags
uint32_t flags
Definition:
ocs_scsi_tgt.h:141
ocs_scsi_tgt_io_t::fmtpinfo
uint8_t fmtpinfo
Definition:
ocs_scsi_tgt.h:179
ocs_scsi_tgt_io_t::ramdisc
ocs_ramdisc_t * ramdisc
Definition:
ocs_scsi_tgt.h:163
ocs_ramdisc_ua_queue_t::ua_queue_lock
ocs_lock_t ua_queue_lock
Definition:
ocs_scsi_tgt.h:113
ocs_scsi_tgt_io_t::cdb_len
uint32_t cdb_len
Definition:
ocs_scsi_tgt.h:146
ocs_ramdisc_ua_queue_t::entry_list
ocs_list_t entry_list
Definition:
ocs_scsi_tgt.h:115
ocs_scsi_tgt_node_t::ua_queues
ocs_ramdisc_ua_queue_t * ua_queues
Definition:
ocs_scsi_tgt.h:132
ocs_ramdisc_ua_queue_t::num_entries
uint32_t num_entries
Definition:
ocs_scsi_tgt.h:114
ocs_scsi_tgt_io_t::cur_block_count
uint32_t cur_block_count
Definition:
ocs_scsi_tgt.h:172
ocs_ramd_thread_t
Definition:
ocs_ramd_thread.h:87
ocs_scsi_tgt_io_t::lun_is_valid
uint8_t lun_is_valid
Definition:
ocs_scsi_tgt.h:164
ocs_scsi_tgt_t::use_global_ramd
uint8_t use_global_ramd
Definition:
ocs_scsi_tgt.h:69
ocs_scsi_tgt_io_t::sm
ocs_sm_ctx_t sm
Definition:
ocs_scsi_tgt.h:191
ocs_ramd_thread.h
ocs_scsi_tgt_io_t::dif_info
ocs_scsi_dif_info_t dif_info
Definition:
ocs_scsi_tgt.h:150
ocs_scsi_tgt_sport_t::rdisc
ocs_ramdisc_t ** rdisc
Definition:
ocs_scsi_tgt.h:91
ocs_scsi_tgt_io_t::num_blocks
uint32_t num_blocks
Definition:
ocs_scsi_tgt.h:185
ocs_scsi_tgt_io_t::sm_lock
ocs_lock_t sm_lock
Definition:
ocs_scsi_tgt.h:190
ocs_scsi_tgt_sport_t::rdisc_count
uint32_t rdisc_count
Definition:
ocs_scsi_tgt.h:92
ocs_scsi_tgt_io_t::pcmd
void * pcmd
Definition:
ocs_scsi_tgt.h:143
ocs_ramdisc.h
ocs_scsi_tgt_io_t::payload
ocs_dma_t payload
Definition:
ocs_scsi_tgt.h:175
ocs_scsi_tgt_t::max_sge
uint32_t max_sge
Definition:
ocs_scsi_tgt.h:52
ocs_scsi_tgt_t::watermark_hit
ocs_atomic_t watermark_hit
Definition:
ocs_scsi_tgt.h:64
ocs_scsi_tgt_io_t::cur_lba
uint64_t cur_lba
Definition:
ocs_scsi_tgt.h:171
ocs_scsi_tgt_io_t::first_burst_buffers
ocs_dma_t * first_burst_buffers
Definition:
ocs_scsi_tgt.h:142
ocs_ramdisc_ua_t
ocs_ramdisc_ua_t represents a single UNIT ATTENTION condition
Definition:
ocs_scsi_tgt.h:99
ocs_scsi_tgt_io_t::supress_auto_response
uint8_t supress_auto_response
Definition:
ocs_scsi_tgt.h:176
ocs_scsi_tgt_t::io_high_watermark
ocs_atomic_t io_high_watermark
Definition:
ocs_scsi_tgt.h:63
ocs_scsi_tgt_t::initiator_count
ocs_atomic_t initiator_count
Definition:
ocs_scsi_tgt.h:61
ocs_scsi_tgt_t::port_rdisc_head
ocs_list_t port_rdisc_head
Definition:
ocs_scsi_tgt.h:73
ocs_scsi_tgt_io_t::io_lba
uint64_t io_lba
Definition:
ocs_scsi_tgt.h:148
ocs_scsi_tgt_io_t::first_burst_bytes
uint32_t first_burst_bytes
Definition:
ocs_scsi_tgt.h:149
ocs_scsi_tgt_t::watermark_min
int32_t watermark_min
Definition:
ocs_scsi_tgt.h:65
common
ocs_ramd
ocs_scsi_tgt.h