2 * Copyright (c) 2017 Broadcom. All rights reserved.
3 * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
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.
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.
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.
34 * OCS linux driver common include file
37 #if !defined(__OCS_DRV_FC_H__)
38 #define __OCS_DRV_FC_H__
40 #define OCS_INCLUDE_FC
43 #include "ocs_debug.h"
44 #include "ocs_common.h"
48 #include "ocs_xport.h"
49 #include "ocs_stats.h"
53 char display_name[OCS_DISPLAY_NAME_LENGTH];
54 ocs_rlock_t lock; /*>> Device wide lock */
55 ocs_list_t domain_list; /*>> linked list of virtual fabric objects */
56 ocs_io_pool_t *io_pool; /**< pointer to IO pool */
59 ocs_scsi_tgt_t tgt_ocs;
60 ocs_scsi_ini_t ini_ocs;
61 ocs_xport_e ocs_xport;
62 ocs_xport_t *xport; /*>> Pointer to transport object */
68 uint32_t max_isr_time_msec; /*>> Maximum ISR time */
70 ocs_pm_context_t pm_context; /*<< power management context */
71 ocs_mgmt_functions_t *mgmt_functions;
72 ocs_mgmt_functions_t *tgt_mgmt_functions;
73 ocs_mgmt_functions_t *ini_mgmt_functions;
74 ocs_err_injection_e err_injection; /**< for error injection testing */
75 uint32_t cmd_err_inject; /**< specific cmd to inject error into */
76 time_t delay_value_msec; /**< for injecting delays */
79 uint32_t instance_index;
82 uint16_t pci_subsystem_vendor;
83 uint16_t pci_subsystem_device;
84 char businfo[OCS_DISPLAY_BUS_INFO_LENGTH];
87 const char *driver_version;
88 const char *fw_version;
92 ocs_domain_t *domain; /*>> pointer to first (physical) domain (also on domain_list) */
93 uint32_t domain_instance_count; /*>> domain instance count */
94 void (*domain_list_empty_cb)(ocs_t *ocs, void *arg); /*>> domain list empty callback */
95 void *domain_list_empty_cb_arg; /*>> domain list empty callback argument */
97 bool explicit_buffer_list;
98 bool external_loopback;
102 uint32_t rq_selection_policy;
105 uint32_t max_remote_nodes;
107 bool soft_wwn_enable;
110 * tgt_rscn_delay - delay in kicking off RSCN processing (nameserver queries)
111 * after receiving an RSCN on the target. This prevents thrashing of nameserver
112 * requests due to a huge burst of RSCNs received in a short period of time
113 * Note: this is only valid when target RSCN handling is enabled -- see ctrlmask.
115 time_t tgt_rscn_delay_msec; /*>> minimum target RSCN delay */
118 * tgt_rscn_period - determines maximum frequency when processing back-to-back
119 * RSCNs; e.g. if this value is 30, there will never be any more than 1 RSCN
120 * handling per 30s window. This prevents initiators on a faulty link generating
121 * many RSCN from causing the target to continually query the nameserver. Note:
122 * this is only valid when target RSCN handling is enabled
124 time_t tgt_rscn_period_msec; /*>> minimum target RSCN period */
127 * Target IO timer value:
128 * Zero: target command timeout disabled.
129 * Non-zero: Timeout value, in seconds, for target commands
131 uint32_t target_io_timer_sec;
135 int ethernet_license;
137 bool enable_hlm; /*>> high login mode is enabled */
138 uint32_t hlm_group_size; /*>> RPI count for high login mode */
140 uint32_t nodedb_mask; /*>> Node debugging mask */
142 uint32_t auto_xfer_rdy_size; /*>> Maximum sized write to use auto xfer rdy */
144 uint8_t ocs_req_fw_upgrade;
146 ocs_textbuf_t ddump_saved;
150 #define ocs_is_fc_initiator_enabled() (ocs->enable_ini)
151 #define ocs_is_fc_target_enabled() (ocs->enable_tgt)
154 ocs_device_lock_init(ocs_t *ocs)
156 ocs_rlock_init(ocs, &ocs->lock, "ocsdevicelock");
159 ocs_device_lock_free(ocs_t *ocs)
161 ocs_rlock_free(&ocs->lock);
163 static inline int32_t
164 ocs_device_lock_try(ocs_t *ocs)
166 return ocs_rlock_try(&ocs->lock);
169 ocs_device_lock(ocs_t *ocs)
171 ocs_rlock_acquire(&ocs->lock);
174 ocs_device_unlock(ocs_t *ocs)
176 ocs_rlock_release(&ocs->lock);
179 extern ocs_t *ocs_get_instance(uint32_t index);
180 extern int32_t ocs_get_bus_dev_func(ocs_t *ocs, uint8_t* bus, uint8_t* dev, uint8_t* func);
182 static inline ocs_io_t *
183 ocs_io_alloc(ocs_t *ocs)
185 return ocs_io_pool_io_alloc(ocs->xport->io_pool);
189 ocs_io_free(ocs_t *ocs, ocs_io_t *io)
191 ocs_io_pool_io_free(ocs->xport->io_pool, io);
194 extern void ocs_stop_event_processing(ocs_os_t *ocs_os);
195 extern int32_t ocs_start_event_processing(ocs_os_t *ocs_os);
197 #include "ocs_domain.h"
198 #include "ocs_sport.h"
199 #include "ocs_node.h"
201 #include "ocs_unsol.h"
202 #include "ocs_scsi.h"
204 #include "ocs_ioctl.h"
205 #include "ocs_elxu.h"