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.
36 * OCS linux driver common include file
39 #if !defined(__OCS_DRV_FC_H__)
40 #define __OCS_DRV_FC_H__
42 #define OCS_INCLUDE_FC
45 #include "ocs_debug.h"
46 #include "ocs_common.h"
50 #include "ocs_xport.h"
51 #include "ocs_stats.h"
55 char display_name[OCS_DISPLAY_NAME_LENGTH];
56 ocs_rlock_t lock; /*>> Device wide lock */
57 ocs_list_t domain_list; /*>> linked list of virtual fabric objects */
58 ocs_io_pool_t *io_pool; /**< pointer to IO pool */
61 ocs_scsi_tgt_t tgt_ocs;
62 ocs_scsi_ini_t ini_ocs;
63 ocs_xport_e ocs_xport;
64 ocs_xport_t *xport; /*>> Pointer to transport object */
70 uint32_t max_isr_time_msec; /*>> Maximum ISR time */
72 ocs_pm_context_t pm_context; /*<< power management context */
73 ocs_mgmt_functions_t *mgmt_functions;
74 ocs_mgmt_functions_t *tgt_mgmt_functions;
75 ocs_mgmt_functions_t *ini_mgmt_functions;
76 ocs_err_injection_e err_injection; /**< for error injection testing */
77 uint32_t cmd_err_inject; /**< specific cmd to inject error into */
78 time_t delay_value_msec; /**< for injecting delays */
81 uint32_t instance_index;
84 uint16_t pci_subsystem_vendor;
85 uint16_t pci_subsystem_device;
86 char businfo[OCS_DISPLAY_BUS_INFO_LENGTH];
89 const char *driver_version;
90 const char *fw_version;
94 ocs_domain_t *domain; /*>> pointer to first (physical) domain (also on domain_list) */
95 uint32_t domain_instance_count; /*>> domain instance count */
96 void (*domain_list_empty_cb)(ocs_t *ocs, void *arg); /*>> domain list empty callback */
97 void *domain_list_empty_cb_arg; /*>> domain list empty callback argument */
99 bool explicit_buffer_list;
100 bool external_loopback;
104 uint32_t rq_selection_policy;
107 uint32_t max_remote_nodes;
109 bool soft_wwn_enable;
112 * tgt_rscn_delay - delay in kicking off RSCN processing (nameserver queries)
113 * after receiving an RSCN on the target. This prevents thrashing of nameserver
114 * requests due to a huge burst of RSCNs received in a short period of time
115 * Note: this is only valid when target RSCN handling is enabled -- see ctrlmask.
117 time_t tgt_rscn_delay_msec; /*>> minimum target RSCN delay */
120 * tgt_rscn_period - determines maximum frequency when processing back-to-back
121 * RSCNs; e.g. if this value is 30, there will never be any more than 1 RSCN
122 * handling per 30s window. This prevents initiators on a faulty link generating
123 * many RSCN from causing the target to continually query the nameserver. Note:
124 * this is only valid when target RSCN handling is enabled
126 time_t tgt_rscn_period_msec; /*>> minimum target RSCN period */
129 * Target IO timer value:
130 * Zero: target command timeout disabled.
131 * Non-zero: Timeout value, in seconds, for target commands
133 uint32_t target_io_timer_sec;
137 int ethernet_license;
139 bool enable_hlm; /*>> high login mode is enabled */
140 uint32_t hlm_group_size; /*>> RPI count for high login mode */
142 uint32_t nodedb_mask; /*>> Node debugging mask */
144 uint32_t auto_xfer_rdy_size; /*>> Maximum sized write to use auto xfer rdy */
146 uint8_t ocs_req_fw_upgrade;
148 ocs_textbuf_t ddump_saved;
152 #define ocs_is_fc_initiator_enabled() (ocs->enable_ini)
153 #define ocs_is_fc_target_enabled() (ocs->enable_tgt)
156 ocs_device_lock_init(ocs_t *ocs)
158 ocs_rlock_init(ocs, &ocs->lock, "ocsdevicelock");
161 ocs_device_lock_free(ocs_t *ocs)
163 ocs_rlock_free(&ocs->lock);
165 static inline int32_t
166 ocs_device_lock_try(ocs_t *ocs)
168 return ocs_rlock_try(&ocs->lock);
171 ocs_device_lock(ocs_t *ocs)
173 ocs_rlock_acquire(&ocs->lock);
176 ocs_device_unlock(ocs_t *ocs)
178 ocs_rlock_release(&ocs->lock);
181 extern ocs_t *ocs_get_instance(uint32_t index);
182 extern int32_t ocs_get_bus_dev_func(ocs_t *ocs, uint8_t* bus, uint8_t* dev, uint8_t* func);
184 static inline ocs_io_t *
185 ocs_io_alloc(ocs_t *ocs)
187 return ocs_io_pool_io_alloc(ocs->xport->io_pool);
191 ocs_io_free(ocs_t *ocs, ocs_io_t *io)
193 ocs_io_pool_io_free(ocs->xport->io_pool, io);
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);
199 #include "ocs_domain.h"
200 #include "ocs_sport.h"
201 #include "ocs_node.h"
203 #include "ocs_unsol.h"
204 #include "ocs_scsi.h"
206 #include "ocs_ioctl.h"
207 #include "ocs_elxu.h"