1 /*- 2 * Copyright (c) 2017 Broadcom. All rights reserved. 3 * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. 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 * $FreeBSD$ 32 */ 33 34 /** 35 * @file 36 * OCS linux driver common include file 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_common.h" 47 #include "ocs_hw.h" 48 #include "ocs_io.h" 49 #include "ocs_pm.h" 50 #include "ocs_xport.h" 51 #include "ocs_stats.h" 52 53 struct ocs_s { 54 ocs_os_t ocs_os; 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 */ 59 ocs_ramlog_t *ramlog; 60 ocs_drv_t drv_ocs; 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 */ 65 bool enable_ini; 66 bool enable_tgt; 67 uint8_t fc_type; 68 int ctrlmask; 69 int logmask; 70 uint32_t max_isr_time_msec; /*>> Maximum ISR time */ 71 char *hw_war_version; 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 */ 79 80 const char *desc; 81 uint32_t instance_index; 82 uint16_t pci_vendor; 83 uint16_t pci_device; 84 uint16_t pci_subsystem_vendor; 85 uint16_t pci_subsystem_device; 86 char businfo[OCS_DISPLAY_BUS_INFO_LENGTH]; 87 88 const char *model; 89 const char *driver_version; 90 const char *fw_version; 91 92 ocs_hw_t hw; 93 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 */ 98 99 bool explicit_buffer_list; 100 bool external_loopback; 101 uint32_t num_vports; 102 uint32_t hw_bounce; 103 uint32_t rq_threads; 104 uint32_t rq_selection_policy; 105 uint32_t rr_quanta; 106 char *filter_def; 107 uint32_t max_remote_nodes; 108 109 bool soft_wwn_enable; 110 111 /* 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. 116 */ 117 time_t tgt_rscn_delay_msec; /*>> minimum target RSCN delay */ 118 119 /* 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 125 */ 126 time_t tgt_rscn_period_msec; /*>> minimum target RSCN period */ 127 128 /* 129 * Target IO timer value: 130 * Zero: target command timeout disabled. 131 * Non-zero: Timeout value, in seconds, for target commands 132 */ 133 uint32_t target_io_timer_sec; 134 135 int speed; 136 int topology; 137 int ethernet_license; 138 int num_scsi_ios; 139 bool enable_hlm; /*>> high login mode is enabled */ 140 uint32_t hlm_group_size; /*>> RPI count for high login mode */ 141 char *wwn_bump; 142 uint32_t nodedb_mask; /*>> Node debugging mask */ 143 144 uint32_t auto_xfer_rdy_size; /*>> Maximum sized write to use auto xfer rdy */ 145 bool esoc; 146 uint8_t ocs_req_fw_upgrade; 147 148 ocs_textbuf_t ddump_saved; 149 150 }; 151 152 #define ocs_is_fc_initiator_enabled() (ocs->enable_ini) 153 #define ocs_is_fc_target_enabled() (ocs->enable_tgt) 154 155 static inline void 156 ocs_device_lock_init(ocs_t *ocs) 157 { 158 ocs_rlock_init(ocs, &ocs->lock, "ocsdevicelock"); 159 } 160 static inline void 161 ocs_device_lock_free(ocs_t *ocs) 162 { 163 ocs_rlock_free(&ocs->lock); 164 } 165 static inline int32_t 166 ocs_device_lock_try(ocs_t *ocs) 167 { 168 return ocs_rlock_try(&ocs->lock); 169 } 170 static inline void 171 ocs_device_lock(ocs_t *ocs) 172 { 173 ocs_rlock_acquire(&ocs->lock); 174 } 175 static inline void 176 ocs_device_unlock(ocs_t *ocs) 177 { 178 ocs_rlock_release(&ocs->lock); 179 } 180 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); 183 184 static inline ocs_io_t * 185 ocs_io_alloc(ocs_t *ocs) 186 { 187 return ocs_io_pool_io_alloc(ocs->xport->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->xport->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_domain.h" 200 #include "ocs_sport.h" 201 #include "ocs_node.h" 202 #include "ocs_io.h" 203 #include "ocs_unsol.h" 204 #include "ocs_scsi.h" 205 206 #include "ocs_ioctl.h" 207 #include "ocs_elxu.h" 208 209 #endif 210