Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_io.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  * OCS linux driver IO declarations
36  */
37 
38 #if !defined(__OCS_IO_H__)
39 #define __OCS_IO_H__
40 
41 #define io_error_log(io, fmt, ...) \
42  do { \
43  if (OCS_LOG_ENABLE_IO_ERRORS(io->ocs)) \
44  ocs_log_warn(io->ocs, fmt, ##__VA_ARGS__); \
45  } while (0)
46 
47 
48 struct ocs_io_s {
49 
50  ocs_t *ocs; /**< pointer back to ocs */
51  uint32_t instance_index; /**< unique instance index value */
52  const char *display_name; /**< display name */
53  ocs_node_t *node; /**< pointer to node */
54  ocs_list_link_t io_alloc_link; /**< (io_pool->io_free_list) free list link */
55  uint32_t init_task_tag; /**< initiator task tag (OX_ID) for back-end and SCSI logging */
56  uint32_t tgt_task_tag; /**< target task tag (RX_ID) - for back-end and SCSI logging */
57  uint32_t hw_tag; /**< HW layer unique IO id - for back-end and SCSI logging */
58  uint32_t tag; /**< unique IO identifier */
59  ocs_scsi_sgl_t *sgl; /**< SGL */
60  uint32_t sgl_allocated; /**< Number of allocated SGEs */
61  uint32_t sgl_count; /**< Number of SGEs in this SGL */
62  ocs_scsi_ini_io_t ini_io; /**< backend initiator private IO data */
63  ocs_scsi_tgt_io_t tgt_io; /**< backend target private IO data */
64  uint32_t exp_xfer_len; /**< expected data transfer length, based on FC or iSCSI header */
66  ocs_ref_t ref; /**< refcount object - Always initialised to 1. Not used */
67  ocs_list_link_t tmf_abort_link; /**< list to store list of IOs to which
68  abort ABORT_IO_NO_RESP evt needs to be posted */
69  bool tmf_abort; /**< True when io marked for tmf abort */
70 
71  /* Declarations private to HAL/SLI */
72 
73  /* Declarations private to iSCSI Transport */
74  void *dslab_item; /**< pointer back to dslab allocation object */
75  ocs_hal_io_t *hio; /**< HAL IO context */
76 
78  uint64_t iscsi_lun;
79  uint32_t data_sn;
80  uint32_t cmd_sn;
81  uint32_t r2tsn;
82 
83  uint32_t cmd_tgt:1, /**< True if this is a Target command */
84  cmd_ini:1, /**< True if this is an Initiator command */
85  on_abort_list:1; /**< True if on aborted_io list */
86  uint8_t bhs[48]; /**< iSCSI BHS for hal io send call */
87  ocs_hal_io_param_t iparam; /**< iparams for hal io send call */
88  ocs_hal_dif_info_t hal_dif; /**< HAL formatted DIF parameters */
89  ocs_hal_io_type_e io_type; /**< HAL IO type */
90  void *hal_cb; /**< saved HAL callback */
91  ocs_list_link_t io_pending_link;/**< link list link pending */
92 
93  uint32_t hal_io_size;
94  uint32_t scsi_mem_offset;
96  uint32_t scsi_wire_offset;
98  void *scsi_io_cb;
102 
103 
104  /* Declarations shared with back-ends */
105  ocs_list_link_t link; /**< linked list link */
106 
107  uint32_t auto_resp:1,
108  is_read:1, /** for calculating dataSN for the response */
109  ppdu:1;
110  ocs_dma_t sensebuf; /**< SCSI Response sense buffer (t) */
111  uint32_t timeout; /** IO timeout in seconds */
112  uint8_t trecv_wqe_timer; /**< Timeout value in seconds for treceive wqe> */
113 
114  /* SCSI API target and initiator IO structures */
115 };
116 
117 /**
118  * @brief Test if IO object is busy
119  *
120  * Return True if IO object is busy. Busy is defined as the IO object not being on
121  * the free list (io->io_alloc_link not being on any list)
122  *
123  * @param io Pointer to IO object
124  *
125  * @return returns True if IO is busy
126  */
127 
128 static inline int32_t
129 ocs_io_busy(ocs_io_t *io)
130 {
131  return !ocs_list_on_list(&io->io_alloc_link);
132 }
133 
134 typedef struct ocs_io_pool_s ocs_io_pool_t;
135 
136 extern ocs_io_pool_t *ocs_io_pool_create(ocs_t *ocs, uint32_t num_io, uint32_t num_sgl);
137 extern int32_t ocs_io_pool_free(ocs_io_pool_t *io_pool);
138 extern uint32_t ocs_io_pool_allocated(ocs_io_pool_t *io_pool);
139 extern ocs_io_t *ocs_io_get_instance(ocs_t *ocs, uint32_t instance_idx);
140 
141 extern ocs_io_t *ocs_io_pool_io_alloc(ocs_io_pool_t *io_pool);
142 extern void ocs_io_pool_io_free(ocs_io_pool_t *io_pool, ocs_io_t *io);
143 extern ocs_io_t *ocs_io_find(ocs_t *ocs, ocs_node_t *node, uint32_t ox_id);
144 extern void ocs_ddump_io(ocs_textbuf_t *textbuf, ocs_io_t *io);
145 
146 #endif // __OCS_IO_H__
147 
148 /* vim: set noexpandtab textwidth=120: */
uint32_t scsi_mem_offset
Definition: ocs_io.h:94
target private IO structure
Definition: ocs_scsi_tgt.h:139
uint32_t scsi_wire_offset
Definition: ocs_io.h:96
uint32_t cmd_ini
Definition: ocs_io.h:83
static int32_t ocs_io_busy(ocs_io_t *io)
Test if IO object is busy.
Definition: ocs_io.h:129
static int32_t ocs_list_on_list(ocs_list_link_t *link)
Test if object is on a list.
Definition: ocs_list.h:460
uint32_t cmd_tgt
Definition: ocs_io.h:83
ocs_list_t ocs_list_link_t
Definition: ocs_list.h:84
ocs_io_pool_t * ocs_io_pool_create(ocs_t *ocs, uint32_t num_io, uint32_t num_sgl)
Create a pool of IO objects.
Definition: ocs_io.c:90
uint32_t on_abort_list
Definition: ocs_io.h:83
ocs_io_t * ocs_io_pool_io_alloc(ocs_io_pool_t *io_pool)
Allocate an object used to track an IO.
Definition: ocs_io.c:242
ocs_list_link_t tmf_abort_link
Definition: ocs_io.h:67
uint32_t sgl_allocated
Definition: ocs_io.h:60
ocs_hal_io_param_t iparam
Definition: ocs_io.h:87
T10 DIF information passed to the transport.
Definition: ocs_hal.h:201
uint32_t scsi_wire_xfer_size
Definition: ocs_io.h:97
ocs_list_link_t link
Definition: ocs_io.h:105
const char * display_name
Definition: ocs_io.h:52
uint32_t instance_index
Definition: ocs_io.h:51
ocs_hal_dif_info_t hal_dif
Definition: ocs_io.h:88
ocs_dma_t unassisted_payload
Definition: ocs_io.h:101
generic scatter-gather list structure
Definition: ocs_scsi.h:218
uint32_t sgl_count
Definition: ocs_io.h:61
defines the parameters for an IO based on the IO type.
Definition: ocs_hal.h:501
uint32_t exp_xfer_len
Definition: ocs_io.h:64
uint8_t trecv_wqe_timer
Definition: ocs_io.h:112
ocs_list_link_t io_pending_link
Definition: ocs_io.h:91
uint32_t r2tsn
Definition: ocs_io.h:81
void * hal_cb
Definition: ocs_io.h:90
uint32_t tag
Definition: ocs_io.h:58
ocs_node_t * node
Definition: ocs_io.h:53
ocs_hal_io_type_e
enum identifying IO types.
Definition: ocs_hal.h:227
void ocs_io_pool_io_free(ocs_io_pool_t *io_pool, ocs_io_t *io)
Free an object used to track an IO.
Definition: ocs_io.c:272
uint32_t data_sn
Definition: ocs_io.h:79
uint32_t ocs_io_pool_allocated(ocs_io_pool_t *io_pool)
Definition: ocs_io.c:220
uint8_t bhs[48]
Definition: ocs_io.h:86
ocs_scsi_ini_io_t ini_io
Definition: ocs_io.h:62
uint32_t is_read
Definition: ocs_io.h:107
ocs_list_link_t io_alloc_link
Definition: ocs_io.h:54
ocs_io_t * ocs_io_get_instance(ocs_t *ocs, uint32_t index)
return pointer to IO object given instance index
Definition: ocs_io.c:301
void * scsi_io_cb
Definition: ocs_io.h:98
uint32_t hal_io_size
Definition: ocs_io.h:93
HAL IO object.
Definition: ocs_hal.h:471
ocs_hal_io_t * hio
Definition: ocs_io.h:75
bool tmf_abort
Definition: ocs_io.h:69
ocs_scsi_tgt_io_t tgt_io
Definition: ocs_io.h:63
ocs_hal_io_type_e io_type
Definition: ocs_io.h:89
ocs_scsi_sgl_t * sgl
Definition: ocs_io.h:59
ocs_ref_t ref
Definition: ocs_io.h:66
void ocs_ddump_io(ocs_textbuf_t *textbuf, ocs_io_t *io)
generate IO context ddump data
Definition: ocs_io.c:330
uint32_t nop_abort_counter
Definition: ocs_io.h:77
uint32_t hw_tag
Definition: ocs_io.h:57
void * unassisted_cb
Definition: ocs_io.h:100
uint32_t tgt_task_tag
Definition: ocs_io.h:56
int32_t ocs_io_pool_free(ocs_io_pool_t *io_pool)
Free IO objects pool.
Definition: ocs_io.c:181
void * dslab_item
Definition: ocs_io.h:74
void * scsi_io_cb_arg
Definition: ocs_io.h:99
uint32_t scsi_mem_xfer_size
Definition: ocs_io.h:95
ocs_dma_t sensebuf
Definition: ocs_io.h:110
ocs_t * ocs
Definition: ocs_io.c:70
ocs_io_t * ocs_io_find(ocs_t *ocs, ocs_node_t *node, uint32_t ox_id)
IO pool.
Definition: ocs_io.c:69
uint32_t auto_resp
Definition: ocs_io.h:107
uint32_t init_task_tag
Definition: ocs_io.h:55
uint32_t ppdu
Definition: ocs_io.h:107
ocs_mgmt_functions_t * mgmt_functions
Definition: ocs_io.h:65
ocs_t * ocs
Definition: ocs_io.h:50
uint32_t timeout
Definition: ocs_io.h:111
uint64_t iscsi_lun
Definition: ocs_io.h:78
uint32_t cmd_sn
Definition: ocs_io.h:80