Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_drv_fc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2018, 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_FC_H__)
40 #define __OCS_DRV_FC_H__
41 
42 #define OCS_INCLUDE_FC
43 
44 #include "ocs_os.h"
45 #include "ocs_debug.h"
46 #include "ocs_fc_config.h"
47 #include "ocs_common.h"
48 #include "ocs_hal.h"
49 #include "ocs_io.h"
50 #include "ocs_pm.h"
51 #include "ocs_xport.h"
52 #if defined(ENABLE_FABRIC_EMULATION)
53 #include "ocs_femul.h"
54 #endif
55 #include "ocs_stats.h"
56 #include "ocs_gendump.h"
57 
58 struct ocs_s {
59 
60  ocs_os_t ocs_os;
62  ocs_rlock_t lock; /*>> Device wide lock */
63  ocs_list_t domain_list; /*>> linked list of virtual fabric objects */
64  ocs_io_pool_t *io_pool; /**< pointer to IO pool */
65  ocs_ramlog_t *ramlog;
70  ocs_xport_t *xport; /*>> Pointer to transport object */
71  bool enable_ini;
72  bool enable_tgt;
74  uint8_t fc_type;
75  int ctrlmask;
76  int logmask;
77  uint32_t max_isr_time_msec; /*>> Maximum ISR time */
79  ocs_pm_context_t pm_context; /*<< power management context */
83  ocs_err_injection_e err_injection; /**< for error injection testing */
84  uint32_t cmd_err_inject; /**< specific cmd to inject error into */
85  time_t delay_value_msec; /**< for injecting delays */
86 
87  const char *desc;
88  uint32_t instance_index;
89  uint16_t pci_vendor;
90  uint16_t pci_device;
93  char businfo[OCS_DISPLAY_BUS_INFO_LENGTH];
94 
95  const char *model;
96  const char *driver_version;
97  const char *fw_version;
98 
100 
101  ocs_domain_t *domain; /*>> pointer to first (physical) domain (also on domain_list) */
102  uint32_t domain_instance_count; /*>> domain instance count */
103  void (*domain_list_empty_cb)(ocs_t *ocs, void *arg); /*>> domain list empty callback */
104  void *domain_list_empty_cb_arg; /*>> domain list empty callback argument */
105  ocs_lock_t domain_list_empty_cb_lock; /* lock for domain list empty cb */
107 
111  uint32_t num_vports;
112  uint32_t hal_bounce;
113  uint32_t rq_threads;
116  uint32_t rr_quanta;
117  char *filter_def;
119 
121 
122  /*
123  * tgt_rscn_delay - delay in kicking off RSCN processing (nameserver queries)
124  * after receiving an RSCN on the target. This prevents thrashing of nameserver
125  * requests due to a huge burst of RSCNs received in a short period of time
126  * Note: this is only valid when target RSCN handling is enabled -- see ctrlmask.
127  */
128  time_t tgt_rscn_delay_msec; /*>> minimum target RSCN delay */
129 
130  /*
131  * tgt_rscn_period - determines maximum frequency when processing back-to-back
132  * RSCNs; e.g. if this value is 30, there will never be any more than 1 RSCN
133  * handling per 30s window. This prevents initiators on a faulty link generating
134  * many RSCN from causing the target to continually query the nameserver. Note:
135  * this is only valid when target RSCN handling is enabled
136  */
137  time_t tgt_rscn_period_msec; /*>> minimum target RSCN period */
138 
139  /*
140  * Target IO timer value:
141  * Zero: target command timeout disabled.
142  * Non-zero: Timeout value, in seconds, for target commands
143  */
145 
146  /*
147  * FCP_TRECEIVE64_WQE timer value, in seconds.
148  */
149  uint8_t tgt_wqe_timer;
150 
151  int speed;
152  int topology;
155  bool enable_hlm; /*>> high login mode is enabled */
156  bool enable_dpp; /*>> DPP Mode enabled */
157  uint32_t hlm_group_size; /*>> RPI count for high login mode */
158  char *wwn_bump;
159  uint32_t nodedb_mask; /*>> Node debugging mask */
160  bool cfg_suppress_rsp; /*>> Config Suppress Response feature */
161 
162  bool esoc;
166 
168 
169  uint8_t domain_shutdown_timedout; /* Track shutdown timeout for userspace drivers */
171  uint8_t disable_fec;
172  uint8_t enable_fw_ag_rsp; /* Enable firmware path to send auto good response.
173  This will force the auto-response parameter field
174  to zero */
175  uint8_t enable_bbcr;
177  const char *sliport_pause_errors;
178 #ifdef OCS_USPACE_SPDK
179  bool dont_linkup;
180 #endif
181 };
182 
183 #define ocs_is_fc_initiator_enabled() (ocs->enable_ini)
184 #define ocs_is_fc_target_enabled() (ocs->enable_tgt)
185 
186 static inline void
188 {
189  ocs_rlock_init(ocs, &ocs->lock, "ocsdevicelock");
190 }
191 static inline void
193 {
194  ocs_rlock_free(&ocs->lock);
195 }
196 static inline int32_t
198 {
199  return ocs_rlock_try(&ocs->lock);
200 }
201 static inline int32_t
202 ocs_device_lock_try_timeout(ocs_t *ocs, uint32_t timeout_ms, uint8_t retries)
203 {
204  uint8_t i;
205  bool lock_acquired = FALSE;
206 
207  for (i = 0; i < retries; i++) {
208  if (ocs_rlock_try_timeout(&ocs->lock, timeout_ms)) {
209  lock_acquired = TRUE;
210  break;
211  }
212  ocs_log_info(ocs, "device lock timeout. Retrying(%d) attempts\n", (i + 1));
213  }
214 
215  return lock_acquired;
216 }
217 static inline void
218 ocs_device_lock(ocs_t *ocs)
219 {
220  ocs_rlock_acquire(&ocs->lock);
221 }
222 static inline void
223 ocs_device_unlock(ocs_t *ocs)
224 {
225  ocs_rlock_release(&ocs->lock);
226 }
227 
228 extern ocs_t *ocs_get_instance(uint32_t index);
229 extern int32_t ocs_get_bus_dev_func(ocs_t *ocs, uint8_t* bus, uint8_t* dev, uint8_t* func);
230 
231 static inline ocs_io_t *
232 ocs_io_alloc(ocs_t *ocs)
233 {
234  return ocs_io_pool_io_alloc(ocs->xport->io_pool);
235 }
236 
237 static inline void
238 ocs_io_free(ocs_t *ocs, ocs_io_t *io)
239 {
240  ocs_io_pool_io_free(ocs->xport->io_pool, io);
241 }
242 
243 static inline bool
244 ocs_bbcr_enabled(ocs_t *ocs)
245 {
246  /* FW should be capable & module param must be set */
247  return (ocs->hal.sli.config.enable_bbcr && ocs->enable_bbcr);
248 }
249 
250 extern void ocs_stop_event_processing(ocs_os_t *ocs_os);
251 extern int32_t ocs_start_event_processing(ocs_os_t *ocs_os);
252 
253 #include "ocs_domain.h"
254 #include "ocs_sport.h"
255 #include "ocs_node.h"
256 #include "ocs_io.h"
257 #include "ocs_unsol.h"
258 #include "ocs_scsi.h"
259 
260 #include "ocs_ioctl.h"
261 #include "ocs_elxu.h"
262 
263 
264 #endif // __OCS_DRV_FC_H__
uint32_t num_vports
Definition: ocs_drv_fc.h:111
uint8_t enable_fw_ag_rsp
Definition: ocs_drv_fc.h:172
void(* domain_list_empty_cb)(ocs_t *ocs, void *arg)
Definition: ocs_drv_fc.h:103
ocs_mgmt_functions_t * ini_mgmt_functions
Definition: ocs_drv_fc.h:82
char * hal_war_version
Definition: ocs_drv_fc.h:78
uint32_t hlm_group_size
Definition: ocs_drv_fc.h:157
ocs_lock_t domain_list_empty_cb_lock
Definition: ocs_drv_fc.h:105
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
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
uint32_t rr_quanta
Definition: ocs_drv_fc.h:116
uint32_t cmd_err_inject
Definition: ocs_drv_fc.h:84
void * domain_list_empty_cb_arg
Definition: ocs_drv_fc.h:104
uint8_t enable_auto_recovery
Definition: ocs_drv_fc.h:164
uint16_t pci_vendor
Definition: ocs_drv_fc.h:89
uint8_t fc_type
Definition: ocs_drv_fc.h:74
char businfo[OCS_DISPLAY_BUS_INFO_LENGTH]
Definition: ocs_drv_fc.h:93
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
ocs_err_injection_e err_injection
Definition: ocs_drv_fc.h:83
uint32_t max_isr_time_msec
Definition: ocs_drv_fc.h:77
static void ocs_device_lock_init(ocs_t *ocs)
Definition: ocs_drv_fc.h:187
uint16_t pci_subsystem_device
Definition: ocs_drv_fc.h:92
ocs_pm_context_t pm_context
Definition: ocs_drv_fc.h:79
ocs_textbuf_t ddump_saved
Definition: ocs_drv_fc.h:167
uint32_t hal_bounce
Definition: ocs_drv_fc.h:112
uint8_t disable_fec
Definition: ocs_drv_fc.h:171
int logmask
Definition: ocs_drv_fc.h:76
bool cfg_suppress_rsp
Definition: ocs_drv_fc.h:160
static void ocs_device_lock(ocs_t *ocs)
Definition: ocs_drv_fc.h:218
static void ocs_device_lock_free(ocs_t *ocs)
Definition: ocs_drv_fc.h:192
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
char * wwn_bump
Definition: ocs_drv_fc.h:158
uint32_t target_io_timer_sec
Definition: ocs_drv_fc.h:144
int topology
Definition: ocs_drv_fc.h:152
uint8_t sliport_healthcheck
Definition: ocs_drv_fc.h:170
ocs_err_injection_e
uint8_t enable_bbcr
Definition: ocs_drv_fc.h:175
int speed
Definition: ocs_drv_fc.h:151
int num_scsi_ios
Definition: ocs_drv_fc.h:154
ocs_mgmt_functions_t * tgt_mgmt_functions
Definition: ocs_drv_fc.h:81
bool external_loopback
Definition: ocs_drv_fc.h:110
int ethernet_license
Definition: ocs_drv_fc.h:153
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
uint32_t max_remote_nodes
Definition: ocs_drv_fc.h:118
int32_t ocs_start_event_processing(ocs_os_t *ocs_os)
bool enable_nvme_tgt
Definition: ocs_drv_fc.h:73
ocs_scsi_tgt_t tgt_ocs
Definition: ocs_drv_fc.h:67
static void ocs_device_unlock(ocs_t *ocs)
Definition: ocs_drv_fc.h:223
uint32_t rq_selection_policy
Definition: ocs_drv_fc.h:114
uint8_t domain_shutdown_timedout
Definition: ocs_drv_fc.h:169
uint16_t watchdog_timeout
Definition: ocs_drv_fc.h:176
struct ocs_fw_dump fw_dump
Definition: ocs_drv_fc.h:165
Definition: ocs.h:53
static int32_t ocs_device_lock_try(ocs_t *ocs)
Definition: ocs_drv_fc.h:197
A structure used to contain all data related to an adapter for this driver.
Definition: ocs_drv_fc.h:58
bool enable_hlm
Definition: ocs_drv_fc.h:155
char * filter_def
Definition: ocs_drv_fc.h:117
ocs_io_pool_t * io_pool
Definition: ocs_drv_fc.h:64
int ctrlmask
Definition: ocs_drv_fc.h:75
bool esoc
Definition: ocs_drv_fc.h:162
ocs_xport_t * xport
Definition: ocs_drv_fc.h:70
bool soft_wwn_enable
Definition: ocs_drv_fc.h:120
uint16_t pci_device
Definition: ocs_drv_fc.h:90
time_t tgt_rscn_period_msec
Definition: ocs_drv_fc.h:137
uint8_t tgt_wqe_timer
Definition: ocs_drv_fc.h:149
const char * driver_version
Definition: ocs_drv_fc.h:96
char display_name[OCS_DISPLAY_NAME_LENGTH]
Definition: ocs_drv_fc.h:61
uint32_t cq_process_limit
Definition: ocs_drv_fc.h:115
const char * fw_version
Definition: ocs_drv_fc.h:97
uint32_t rq_threads
Definition: ocs_drv_fc.h:113
int32_t holdoff_link_online
Definition: ocs_drv_fc.h:108
uint32_t nodedb_mask
Definition: ocs_drv_fc.h:159
static bool ocs_bbcr_enabled(ocs_t *ocs)
Definition: ocs_drv_fc.h:244
uint32_t domain_instance_count
Definition: ocs_drv_fc.h:102
ocs_scsi_ini_t ini_ocs
Definition: ocs_drv_fc.h:68
bool enable_dpp
Definition: ocs_drv_fc.h:156
void ocs_stop_event_processing(ocs_os_t *ocs_os)
time_t tgt_rscn_delay_msec
Definition: ocs_drv_fc.h:128
int32_t ocs_get_bus_dev_func(ocs_t *ocs, uint8_t *bus, uint8_t *dev, uint8_t *func)
ocs_sem_t domain_list_empty_cb_sem
Definition: ocs_drv_fc.h:106
uint16_t pci_subsystem_vendor
Definition: ocs_drv_fc.h:91
uint8_t ocs_req_fw_upgrade
Definition: ocs_drv_fc.h:163
ocs_xport_e ocs_xport
Definition: ocs_drv_fc.h:69
ocs_xport_e
Definition: ocs_common.h:45
static void ocs_io_free(ocs_t *ocs, ocs_io_t *io)
Definition: ocs_drv_fc.h:238
ocs_hal_t hal
Definition: ocs_drv_fc.h:99
bool enable_tgt
Definition: ocs_drv_fc.h:72
static int32_t ocs_device_lock_try_timeout(ocs_t *ocs, uint32_t timeout_ms, uint8_t retries)
Definition: ocs_drv_fc.h:202
ocs_ramlog_t * ramlog
Definition: ocs_drv_fc.h:65
bool explicit_buffer_list
Definition: ocs_drv_fc.h:109
const char * desc
Definition: ocs_drv_fc.h:87
static ocs_io_t * ocs_io_alloc(ocs_t *ocs)
Definition: ocs_drv_fc.h:232
ocs_mgmt_functions_t * mgmt_functions
Definition: ocs_drv_fc.h:80
#define OCS_DISPLAY_NAME_LENGTH
Definition: ocs_common.h:49
const char * sliport_pause_errors
Definition: ocs_drv_fc.h:177