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 bsd driver common include file
39 #if !defined(__OCS_H__)
43 #include "ocs_utils.h"
51 #define DRV_NAME "ocs_fc"
53 STR_BE_MAJOR "." STR_BE_MINOR "." STR_BE_BUILD "." STR_BE_BRANCH
56 * @brief Interrupt context
58 typedef struct ocs_intr_ctx_s {
59 uint32_t vec; /** Zero based interrupt vector */
60 void *softc; /** software context for interrupt */
61 char name[64]; /** label for this context */
64 typedef struct ocs_fc_rport_db_s {
73 #define OCS_TGT_STATE_NONE 0 /* Empty DB slot */
74 #define OCS_TGT_STATE_VALID 1 /* Valid*/
75 #define OCS_TGT_STATE_LOST 2 /* LOST*/
77 typedef struct ocs_fcport_s {
80 struct cam_path *path;
84 ocs_fc_target_t tgt[OCS_MAX_TARGETS];
86 struct callout ldt; /* device lost timer */
89 ocs_tgt_resource_t targ_rsrc_wildcard;
90 ocs_tgt_resource_t targ_rsrc[OCS_MAX_LUN];
91 ocs_vport_spec_t *vport;
94 #define FCPORT(ocs, chan) (&((ocs_fcport *)(ocs)->fcports)[(chan)])
97 * @brief Driver's context
104 ocs_pci_reg_t reg[PCI_MAX_BAR];
106 uint32_t instance_index;
110 struct resource *irq;
113 ocs_intr_ctx_t intr_ctx;
116 bus_dma_tag_t dmat; /** Parent DMA tag */
117 bus_dma_tag_t buf_dmat;/** IO buffer DMA tag */
118 char display_name[OCS_DISPLAY_NAME_LENGTH];
121 uint16_t pci_subsystem_vendor;
122 uint16_t pci_subsystem_device;
124 const char *driver_version;
125 const char *fw_version;
130 ocs_rlock_t lock; /**< device wide lock */
132 ocs_xport_e ocs_xport;
133 ocs_xport_t *xport; /**< pointer to transport object */
134 ocs_domain_t *domain;
135 ocs_list_t domain_list;
136 uint32_t domain_instance_count;
137 void (*domain_list_empty_cb)(ocs_t *ocs, void *arg);
138 void *domain_list_empty_cb_arg;
144 uint8_t explicit_buffer_list;
145 uint8_t external_loopback;
146 uint8_t skip_hw_teardown;
149 int ethernet_license;
152 uint32_t hlm_group_size;
153 uint32_t max_isr_time_msec; /*>> Maximum ISR time */
154 uint32_t auto_xfer_rdy_size; /*>> Max sized write to use auto xfer rdy*/
157 char *hw_war_version;
159 uint32_t target_io_timer_sec;
162 uint8_t rq_selection_policy;
165 uint32_t max_remote_nodes;
168 * tgt_rscn_delay - delay in kicking off RSCN processing
169 * (nameserver queries) after receiving an RSCN on the target.
170 * This prevents thrashing of nameserver requests due to a huge burst of
171 * RSCNs received in a short period of time.
172 * Note: this is only valid when target RSCN handling is enabled -- see
175 time_t tgt_rscn_delay_msec; /*>> minimum target RSCN delay */
178 * tgt_rscn_period - determines maximum frequency when processing
179 * back-to-back RSCNs; e.g. if this value is 30, there will never be
180 * any more than 1 RSCN handling per 30s window. This prevents
181 * initiators on a faulty link generating many RSCN from causing the
182 * target to continually query the nameserver.
183 * Note: This is only valid when target RSCN handling is enabled
185 time_t tgt_rscn_period_msec; /*>> minimum target RSCN period */
187 uint32_t enable_task_set_full;
189 uint32_t io_high_watermark; /**< used to send task set full */
191 uint32_t config_tgt:1, /**< Configured to support target mode */
192 config_ini:1; /**< Configured to support initiator mode */
194 uint32_t nodedb_mask; /**< Node debugging mask */
201 ocs_ramlog_t *ramlog;
202 ocs_textbuf_t ddump_saved;
204 ocs_mgmt_functions_t *mgmt_functions;
205 ocs_mgmt_functions_t *tgt_mgmt_functions;
206 ocs_mgmt_functions_t *ini_mgmt_functions;
208 ocs_err_injection_e err_injection;
209 uint32_t cmd_err_inject;
210 time_t delay_value_msec;
215 struct cam_devq *devq;
222 ocs_device_lock_init(ocs_t *ocs)
224 ocs_rlock_init(ocs, &ocs->lock, "ocsdevicelock");
227 static inline int32_t
228 ocs_device_lock_try(ocs_t *ocs)
230 return ocs_rlock_try(&ocs->lock);
234 ocs_device_lock(ocs_t *ocs)
236 ocs_rlock_acquire(&ocs->lock);
240 ocs_device_unlock(ocs_t *ocs)
242 ocs_rlock_release(&ocs->lock);
246 ocs_device_lock_free(ocs_t *ocs)
248 ocs_rlock_free(&ocs->lock);
251 extern int32_t ocs_device_detach(ocs_t *ocs);
253 extern int32_t ocs_device_attach(ocs_t *ocs);
255 #define ocs_is_initiator_enabled() (ocs->enable_ini)
256 #define ocs_is_target_enabled() (ocs->enable_tgt)
258 #include "ocs_xport.h"
259 #include "ocs_domain.h"
260 #include "ocs_sport.h"
261 #include "ocs_node.h"
262 #include "ocs_unsol.h"
263 #include "ocs_scsi.h"
264 #include "ocs_ioctl.h"
266 static inline ocs_io_t *
267 ocs_io_alloc(ocs_t *ocs)
269 return ocs_io_pool_io_alloc(ocs->xport->io_pool);
273 ocs_io_free(ocs_t *ocs, ocs_io_t *io)
275 ocs_io_pool_io_free(ocs->xport->io_pool, io);
278 #endif /* __OCS_H__ */