1331766Sken/*- 2331766Sken * Copyright (c) 2017 Broadcom. All rights reserved. 3331766Sken * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. 4331766Sken * 5331766Sken * Redistribution and use in source and binary forms, with or without 6331766Sken * modification, are permitted provided that the following conditions are met: 7331766Sken * 8331766Sken * 1. Redistributions of source code must retain the above copyright notice, 9331766Sken * this list of conditions and the following disclaimer. 10331766Sken * 11331766Sken * 2. Redistributions in binary form must reproduce the above copyright notice, 12331766Sken * this list of conditions and the following disclaimer in the documentation 13331766Sken * and/or other materials provided with the distribution. 14331766Sken * 15331766Sken * 3. Neither the name of the copyright holder nor the names of its contributors 16331766Sken * may be used to endorse or promote products derived from this software 17331766Sken * without specific prior written permission. 18331766Sken * 19331766Sken * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20331766Sken * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21331766Sken * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22331766Sken * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 23331766Sken * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24331766Sken * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25331766Sken * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26331766Sken * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27331766Sken * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28331766Sken * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29331766Sken * POSSIBILITY OF SUCH DAMAGE. 30331766Sken * 31331766Sken * $FreeBSD: stable/11/sys/dev/ocs_fc/ocs_drv_fc.h 331766 2018-03-30 15:28:25Z ken $ 32331766Sken */ 33331766Sken 34331766Sken/** 35331766Sken * @file 36331766Sken * OCS linux driver common include file 37331766Sken */ 38331766Sken 39331766Sken 40331766Sken#if !defined(__OCS_DRV_FC_H__) 41331766Sken#define __OCS_DRV_FC_H__ 42331766Sken 43331766Sken#define OCS_INCLUDE_FC 44331766Sken 45331766Sken#include "ocs_os.h" 46331766Sken#include "ocs_debug.h" 47331766Sken#include "ocs_common.h" 48331766Sken#include "ocs_hw.h" 49331766Sken#include "ocs_io.h" 50331766Sken#include "ocs_pm.h" 51331766Sken#include "ocs_xport.h" 52331766Sken#include "ocs_stats.h" 53331766Sken 54331766Skenstruct ocs_s { 55331766Sken 56331766Sken ocs_os_t ocs_os; 57331766Sken char display_name[OCS_DISPLAY_NAME_LENGTH]; 58331766Sken ocs_rlock_t lock; /*>> Device wide lock */ 59331766Sken ocs_list_t domain_list; /*>> linked list of virtual fabric objects */ 60331766Sken ocs_io_pool_t *io_pool; /**< pointer to IO pool */ 61331766Sken ocs_ramlog_t *ramlog; 62331766Sken ocs_drv_t drv_ocs; 63331766Sken ocs_scsi_tgt_t tgt_ocs; 64331766Sken ocs_scsi_ini_t ini_ocs; 65331766Sken ocs_xport_e ocs_xport; 66331766Sken ocs_xport_t *xport; /*>> Pointer to transport object */ 67331766Sken bool enable_ini; 68331766Sken bool enable_tgt; 69331766Sken uint8_t fc_type; 70331766Sken int ctrlmask; 71331766Sken int logmask; 72331766Sken uint32_t max_isr_time_msec; /*>> Maximum ISR time */ 73331766Sken char *hw_war_version; 74331766Sken ocs_pm_context_t pm_context; /*<< power management context */ 75331766Sken ocs_mgmt_functions_t *mgmt_functions; 76331766Sken ocs_mgmt_functions_t *tgt_mgmt_functions; 77331766Sken ocs_mgmt_functions_t *ini_mgmt_functions; 78331766Sken ocs_err_injection_e err_injection; /**< for error injection testing */ 79331766Sken uint32_t cmd_err_inject; /**< specific cmd to inject error into */ 80331766Sken time_t delay_value_msec; /**< for injecting delays */ 81331766Sken 82331766Sken const char *desc; 83331766Sken uint32_t instance_index; 84331766Sken uint16_t pci_vendor; 85331766Sken uint16_t pci_device; 86331766Sken uint16_t pci_subsystem_vendor; 87331766Sken uint16_t pci_subsystem_device; 88331766Sken char businfo[OCS_DISPLAY_BUS_INFO_LENGTH]; 89331766Sken 90331766Sken const char *model; 91331766Sken const char *driver_version; 92331766Sken const char *fw_version; 93331766Sken 94331766Sken ocs_hw_t hw; 95331766Sken 96331766Sken ocs_domain_t *domain; /*>> pointer to first (physical) domain (also on domain_list) */ 97331766Sken uint32_t domain_instance_count; /*>> domain instance count */ 98331766Sken void (*domain_list_empty_cb)(ocs_t *ocs, void *arg); /*>> domain list empty callback */ 99331766Sken void *domain_list_empty_cb_arg; /*>> domain list empty callback argument */ 100331766Sken 101331766Sken bool explicit_buffer_list; 102331766Sken bool external_loopback; 103331766Sken uint32_t num_vports; 104331766Sken uint32_t hw_bounce; 105331766Sken uint32_t rq_threads; 106331766Sken uint32_t rq_selection_policy; 107331766Sken uint32_t rr_quanta; 108331766Sken char *filter_def; 109331766Sken uint32_t max_remote_nodes; 110331766Sken 111331766Sken bool soft_wwn_enable; 112331766Sken 113331766Sken /* 114331766Sken * tgt_rscn_delay - delay in kicking off RSCN processing (nameserver queries) 115331766Sken * after receiving an RSCN on the target. This prevents thrashing of nameserver 116331766Sken * requests due to a huge burst of RSCNs received in a short period of time 117331766Sken * Note: this is only valid when target RSCN handling is enabled -- see ctrlmask. 118331766Sken */ 119331766Sken time_t tgt_rscn_delay_msec; /*>> minimum target RSCN delay */ 120331766Sken 121331766Sken /* 122331766Sken * tgt_rscn_period - determines maximum frequency when processing back-to-back 123331766Sken * RSCNs; e.g. if this value is 30, there will never be any more than 1 RSCN 124331766Sken * handling per 30s window. This prevents initiators on a faulty link generating 125331766Sken * many RSCN from causing the target to continually query the nameserver. Note: 126331766Sken * this is only valid when target RSCN handling is enabled 127331766Sken */ 128331766Sken time_t tgt_rscn_period_msec; /*>> minimum target RSCN period */ 129331766Sken 130331766Sken /* 131331766Sken * Target IO timer value: 132331766Sken * Zero: target command timeout disabled. 133331766Sken * Non-zero: Timeout value, in seconds, for target commands 134331766Sken */ 135331766Sken uint32_t target_io_timer_sec; 136331766Sken 137331766Sken int speed; 138331766Sken int topology; 139331766Sken int ethernet_license; 140331766Sken int num_scsi_ios; 141331766Sken bool enable_hlm; /*>> high login mode is enabled */ 142331766Sken uint32_t hlm_group_size; /*>> RPI count for high login mode */ 143331766Sken char *wwn_bump; 144331766Sken uint32_t nodedb_mask; /*>> Node debugging mask */ 145331766Sken 146331766Sken uint32_t auto_xfer_rdy_size; /*>> Maximum sized write to use auto xfer rdy */ 147331766Sken bool esoc; 148331766Sken uint8_t ocs_req_fw_upgrade; 149331766Sken 150331766Sken ocs_textbuf_t ddump_saved; 151331766Sken 152331766Sken}; 153331766Sken 154331766Sken#define ocs_is_fc_initiator_enabled() (ocs->enable_ini) 155331766Sken#define ocs_is_fc_target_enabled() (ocs->enable_tgt) 156331766Sken 157331766Skenstatic inline void 158331766Skenocs_device_lock_init(ocs_t *ocs) 159331766Sken{ 160331766Sken ocs_rlock_init(ocs, &ocs->lock, "ocsdevicelock"); 161331766Sken} 162331766Skenstatic inline void 163331766Skenocs_device_lock_free(ocs_t *ocs) 164331766Sken{ 165331766Sken ocs_rlock_free(&ocs->lock); 166331766Sken} 167331766Skenstatic inline int32_t 168331766Skenocs_device_lock_try(ocs_t *ocs) 169331766Sken{ 170331766Sken return ocs_rlock_try(&ocs->lock); 171331766Sken} 172331766Skenstatic inline void 173331766Skenocs_device_lock(ocs_t *ocs) 174331766Sken{ 175331766Sken ocs_rlock_acquire(&ocs->lock); 176331766Sken} 177331766Skenstatic inline void 178331766Skenocs_device_unlock(ocs_t *ocs) 179331766Sken{ 180331766Sken ocs_rlock_release(&ocs->lock); 181331766Sken} 182331766Sken 183331766Skenextern ocs_t *ocs_get_instance(uint32_t index); 184331766Skenextern int32_t ocs_get_bus_dev_func(ocs_t *ocs, uint8_t* bus, uint8_t* dev, uint8_t* func); 185331766Sken 186331766Skenstatic inline ocs_io_t * 187331766Skenocs_io_alloc(ocs_t *ocs) 188331766Sken{ 189331766Sken return ocs_io_pool_io_alloc(ocs->xport->io_pool); 190331766Sken} 191331766Sken 192331766Skenstatic inline void 193331766Skenocs_io_free(ocs_t *ocs, ocs_io_t *io) 194331766Sken{ 195331766Sken ocs_io_pool_io_free(ocs->xport->io_pool, io); 196331766Sken} 197331766Sken 198331766Skenextern void ocs_stop_event_processing(ocs_os_t *ocs_os); 199331766Skenextern int32_t ocs_start_event_processing(ocs_os_t *ocs_os); 200331766Sken 201331766Sken#include "ocs_domain.h" 202331766Sken#include "ocs_sport.h" 203331766Sken#include "ocs_node.h" 204331766Sken#include "ocs_io.h" 205331766Sken#include "ocs_unsol.h" 206331766Sken#include "ocs_scsi.h" 207331766Sken 208331766Sken#include "ocs_ioctl.h" 209331766Sken#include "ocs_elxu.h" 210331766Sken 211331766Sken 212331766Sken#endif 213