Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_drv_iscsi.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 common include file
36  */
37 
38 
39 #if !defined(__OCS_DRV_ISCSI_H__)
40 #define __OCS_DRV_ISCSI_H__
41 
42 #define OCS_INCLUDE_ISCSI
43 
44 #include "ocs_os.h"
45 #include "ocs_debug.h"
46 #include "ocs_iscsi_config.h"
47 
48 #include "ocs_common.h"
49 #include "ocs_hal.h"
50 #include "ocs_io.h"
51 #include "ocs_pm.h"
52 #include "ocs_iscsi_api.h"
53 #include "ocs_iscsi.h"
54 #include "ocs_ioctl.h"
55 #include "ocs_elxu.h"
56 
57 #define OCS_MAX_SPORTS 32
58 
59 /**
60  * @brief A structure used to contain all data related to an adapter for this driver.
61  */
62 struct ocs_s {
63 
64  ocs_os_t ocs_os;
66  ocs_rlock_t lock; /*>> Device wide lock */
67  ocs_list_t domain_list; /*>> linked list of virtual fabric objects */
68  ocs_io_pool_t *io_pool; /**< pointer to IO pool */
69  ocs_ramlog_t *ramlog;
74  ocs_xport_t *xport; /*>> Pointer to transport object */
75  bool enable_ini;
76  bool enable_tgt;
77  int ctrlmask;
78  int logmask;
79  uint32_t max_isr_time_msec; /*>> Maximum ISR time */
80  char *hal_war_version;
81  ocs_pm_context_t pm_context; /*<< power management context */
85  ocs_err_injection_e err_injection; /**< for error injection testing */
86  uint32_t cmd_err_inject; /**< specific cmd to inject error into */
87  time_t delay_value_msec; /**< for injecting delays */
88 
89  uint32_t instance_index;
90 
91  uint16_t pci_vendor;
92  uint16_t pci_device;
93  uint16_t pci_subsystem_vendor;
94  uint16_t pci_subsystem_device;
95  char businfo[16];
96 
97  const char *model;
98  const char *driver_version;
99  const char *fw_version;
100 
101  const char *desc;
102 
103  ocs_hal_t hal;
105  struct iscsi_api_s *iscsi_api;
106 
107  ocs_domain_t *domain; /*>> pointer to first (physical) domain (also on domain_list) */
108  uint32_t domain_instance_count; /*>> domain instance count */
109  ocs_sli_port_t sport[OCS_MAX_SPORTS];
110 
116  uint32_t max_sge_size;
117  uint32_t post_sgl_config;
118  uint32_t num_scsi_ios;
121 
122  /* Driver command line parameters */
123  uint32_t num_tgts;
124  uint32_t global_ramdisc;
125  char local_ip[64];
126  char local_subnet[64];
127  char gateway[64];
128  uint32_t tcp_window_size;
130  uint32_t num_cxns;
131 
134  ocs_atomic_t io_alloc_failed_count; /**< used to track how often IO pool is empty */
135  ocs_list_t io_pending_list; /**< list of IOs waiting for HAL resources
136  ** lock: ocs_driver_lock()
137  ** link: ocs_io_t->io_pending_link
138  */
139  ocs_atomic_t io_total_alloc; /**< count of totals IOS allocated */
140  ocs_atomic_t io_total_free; /**< count of totals IOS free'd */
141  ocs_atomic_t io_total_pending; /**< count of totals IOS that were pended */
142  ocs_atomic_t io_active_count; /**< count of active IOS */
143  ocs_atomic_t io_pending_count; /**< count of pending IOS */
144  ocs_atomic_t io_pending_recursing; /**< non-zero if ocs_scsi_check_pending is executing */
145 
146  uint32_t target_io_timer_sec; /**< target IO timer not supported in iSCSI */
147  uint8_t tgt_wqe_timer;
149 };
150 
151 #define ocs_is_initiator_enabled() (ocs->enable_ini)
152 #define ocs_is_target_enabled() (ocs->enable_tgt)
153 
154 static inline void
156 {
157  ocs_rlock_init(ocs, &ocs->lock, "ocsdevicelock");
158 }
159 static inline void
161 {
162  ocs_rlock_free(&ocs->lock);
163 }
164 static inline int32_t
166 {
167  return ocs_rlock_try(&ocs->lock);
168 }
169 static inline void
170 ocs_device_lock(ocs_t *ocs)
171 {
172  ocs_rlock_acquire(&ocs->lock);
173 }
174 static inline void
175 ocs_device_unlock(ocs_t *ocs)
176 {
177  ocs_rlock_release(&ocs->lock);
178 }
179 
180 extern ocs_t *ocs_get_instance(uint32_t index);
181 extern int32_t ocs_get_bus_dev_func(ocs_t *ocs, uint8_t* bus, uint8_t* dev, uint8_t* func);
182 extern int32_t ocs_device_ioctl(ocs_t *ocs, unsigned int cmd, unsigned long arg);
183 
184 static inline ocs_io_t *
185 ocs_io_alloc(ocs_t *ocs)
186 {
187  return ocs_io_pool_io_alloc(ocs->io_pool);
188 }
189 
190 static inline void
191 ocs_io_free(ocs_t *ocs, ocs_io_t *io)
192 {
193  ocs_io_pool_io_free(ocs->io_pool, io);
194 }
195 
196 extern void ocs_stop_event_processing(ocs_os_t *ocs_os);
197 extern int32_t ocs_start_event_processing(ocs_os_t *ocs_os);
198 
199 #include "ocs_xport.h"
200 #include "ocs_scsi.h"
201 #include "ocs_domain.h"
202 #include "ocs_sport.h"
203 #include "ocs_cxn.h"
204 #include "ocs_io.h"
205 
206 #endif // __OCS_DRV_ISCSI_H__
struct iscsi_api_s * iscsi_api
ocs_mgmt_functions_t * ini_mgmt_functions
Definition: ocs_drv_fc.h:82
uint32_t tcp_window_size
char * hal_war_version
Definition: ocs_drv_fc.h:78
target private ocs structure
Definition: ocs_scsi_tgt.h:51
ocs_drv_t drv_ocs
Definition: ocs_drv_fc.h:66
const char * model
Definition: ocs_drv_fc.h:95
bool enable_sgl_chaining
int32_t ocs_device_ioctl(ocs_t *ocs, unsigned int cmd, unsigned long arg)
ocs driver ioctl method
Definition: ocs_ioctl.c:57
ocs_t * ocs_get_instance(uint32_t index)
Returns a pointer to the ocs structure given the instance index.
Definition: ocs_driver.c:141
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_domain_t * domain
Definition: ocs_drv_fc.h:101
uint8_t tcp_window_scale
uint32_t cmd_err_inject
Definition: ocs_drv_fc.h:84
uint16_t pci_vendor
Definition: ocs_drv_fc.h:89
char businfo[OCS_DISPLAY_BUS_INFO_LENGTH]
Definition: ocs_drv_fc.h:93
ocs_sli_port_t sport[OCS_MAX_SPORTS]
ocs_list_t domain_list
Definition: ocs_drv_fc.h:63
uint32_t instance_index
Definition: ocs_drv_fc.h:88
ocs_rlock_t lock
Definition: ocs_drv_fc.h:62
uint32_t num_tgts
ocs_err_injection_e err_injection
Definition: ocs_drv_fc.h:83
uint32_t max_isr_time_msec
Definition: ocs_drv_fc.h:77
uint16_t pci_subsystem_device
Definition: ocs_drv_fc.h:92
uint32_t num_cxns
ocs_pm_context_t pm_context
Definition: ocs_drv_fc.h:79
ocs_textbuf_t ddump_saved
Definition: ocs_drv_fc.h:167
int logmask
Definition: ocs_drv_fc.h:76
HAL object.
Definition: ocs_hal.h:724
bool enable_ini
Definition: ocs_drv_fc.h:71
time_t delay_value_msec
Definition: ocs_drv_fc.h:85
uint32_t max_sge_size
uint32_t target_io_timer_sec
Definition: ocs_drv_fc.h:144
uint32_t global_ramdisc
ocs_atomic_t io_total_pending
ocs_err_injection_e
ocs_mgmt_functions_t * tgt_mgmt_functions
Definition: ocs_drv_fc.h:81
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
ocs_os_t ocs_os
Definition: ocs_drv_fc.h:60
int32_t ocs_start_event_processing(ocs_os_t *ocs_os)
ocs_atomic_t io_active_count
bool require_chap
ocs_scsi_tgt_t tgt_ocs
Definition: ocs_drv_fc.h:67
char local_subnet[64]
ocs_atomic_t io_total_free
Definition: ocs.h:53
static int32_t ocs_device_lock_try(ocs_t *ocs)
uint32_t num_scsi_ios
iSCSI object
Definition: ocs_iscsi.h:293
A structure used to contain all data related to an adapter for this driver.
Definition: ocs_drv_fc.h:58
char iqn_suffix[OCS_MAX_ISCSI_NAME]
uint32_t max_cxns_per_session
ocs_io_pool_t * io_pool
Definition: ocs_drv_fc.h:64
int ctrlmask
Definition: ocs_drv_fc.h:75
ocs_xport_t * xport
Definition: ocs_drv_fc.h:70
static void ocs_device_lock_init(ocs_t *ocs)
uint16_t pci_device
Definition: ocs_drv_fc.h:90
uint8_t tgt_wqe_timer
Definition: ocs_drv_fc.h:149
const char * driver_version
Definition: ocs_drv_fc.h:96
bool enable_hdr_digest
ocs_atomic_t io_pending_count
char display_name[OCS_DISPLAY_NAME_LENGTH]
Definition: ocs_drv_fc.h:61
static void ocs_device_unlock(ocs_t *ocs)
const char * fw_version
Definition: ocs_drv_fc.h:97
ocs_atomic_t io_total_alloc
char gateway[64]
ocs_list_t io_pending_list
uint32_t post_sgl_config
uint32_t domain_instance_count
Definition: ocs_drv_fc.h:102
char iqn_prefix[OCS_MAX_ISCSI_NAME]
ocs_scsi_ini_t ini_ocs
Definition: ocs_drv_fc.h:68
void ocs_stop_event_processing(ocs_os_t *ocs_os)
ocs_atomic_t io_pending_recursing
int32_t ocs_get_bus_dev_func(ocs_t *ocs, uint8_t *bus, uint8_t *dev, uint8_t *func)
static void ocs_io_free(ocs_t *ocs, ocs_io_t *io)
ocs_atomic_t io_alloc_failed_count
#define OCS_MAX_SPORTS
Definition: ocs_drv_iscsi.h:57
uint16_t pci_subsystem_vendor
Definition: ocs_drv_fc.h:91
ocs_xport_e ocs_xport
Definition: ocs_drv_fc.h:69
#define OCS_MAX_ISCSI_NAME
Definition: ocs_common.h:240
ocs_xport_e
Definition: ocs_common.h:45
ocs_hal_t hal
Definition: ocs_drv_fc.h:99
bool enable_tgt
Definition: ocs_drv_fc.h:72
ocs_iscsi_t iscsi
static ocs_io_t * ocs_io_alloc(ocs_t *ocs)
bool enable_jumbo_frame
bool enable_immediate_data
char local_ip[64]
ocs_ramlog_t * ramlog
Definition: ocs_drv_fc.h:65
bool enable_data_digest
const char * desc
Definition: ocs_drv_fc.h:87
static void ocs_device_lock(ocs_t *ocs)
static void ocs_device_lock_free(ocs_t *ocs)
ocs_mgmt_functions_t * mgmt_functions
Definition: ocs_drv_fc.h:80
#define OCS_DISPLAY_NAME_LENGTH
Definition: ocs_common.h:49