18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * QLogic iSCSI HBA Driver 48c2ecf20Sopenharmony_ci * Copyright (c) 2003-2013 QLogic Corporation 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef __QL4_DEF_H 88c2ecf20Sopenharmony_ci#define __QL4_DEF_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/kernel.h> 118c2ecf20Sopenharmony_ci#include <linux/init.h> 128c2ecf20Sopenharmony_ci#include <linux/types.h> 138c2ecf20Sopenharmony_ci#include <linux/module.h> 148c2ecf20Sopenharmony_ci#include <linux/list.h> 158c2ecf20Sopenharmony_ci#include <linux/pci.h> 168c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h> 178c2ecf20Sopenharmony_ci#include <linux/sched.h> 188c2ecf20Sopenharmony_ci#include <linux/slab.h> 198c2ecf20Sopenharmony_ci#include <linux/dmapool.h> 208c2ecf20Sopenharmony_ci#include <linux/mempool.h> 218c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 228c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 238c2ecf20Sopenharmony_ci#include <linux/delay.h> 248c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 258c2ecf20Sopenharmony_ci#include <linux/mutex.h> 268c2ecf20Sopenharmony_ci#include <linux/aer.h> 278c2ecf20Sopenharmony_ci#include <linux/bsg-lib.h> 288c2ecf20Sopenharmony_ci#include <linux/vmalloc.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#include <net/tcp.h> 318c2ecf20Sopenharmony_ci#include <scsi/scsi.h> 328c2ecf20Sopenharmony_ci#include <scsi/scsi_host.h> 338c2ecf20Sopenharmony_ci#include <scsi/scsi_device.h> 348c2ecf20Sopenharmony_ci#include <scsi/scsi_cmnd.h> 358c2ecf20Sopenharmony_ci#include <scsi/scsi_transport.h> 368c2ecf20Sopenharmony_ci#include <scsi/scsi_transport_iscsi.h> 378c2ecf20Sopenharmony_ci#include <scsi/scsi_bsg_iscsi.h> 388c2ecf20Sopenharmony_ci#include <scsi/scsi_netlink.h> 398c2ecf20Sopenharmony_ci#include <scsi/libiscsi.h> 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#include "ql4_dbg.h" 428c2ecf20Sopenharmony_ci#include "ql4_nx.h" 438c2ecf20Sopenharmony_ci#include "ql4_fw.h" 448c2ecf20Sopenharmony_ci#include "ql4_nvram.h" 458c2ecf20Sopenharmony_ci#include "ql4_83xx.h" 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#ifndef PCI_DEVICE_ID_QLOGIC_ISP4010 488c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP4010 0x4010 498c2ecf20Sopenharmony_ci#endif 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#ifndef PCI_DEVICE_ID_QLOGIC_ISP4022 528c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP4022 0x4022 538c2ecf20Sopenharmony_ci#endif 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#ifndef PCI_DEVICE_ID_QLOGIC_ISP4032 568c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP4032 0x4032 578c2ecf20Sopenharmony_ci#endif 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#ifndef PCI_DEVICE_ID_QLOGIC_ISP8022 608c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP8022 0x8022 618c2ecf20Sopenharmony_ci#endif 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#ifndef PCI_DEVICE_ID_QLOGIC_ISP8324 648c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP8324 0x8032 658c2ecf20Sopenharmony_ci#endif 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#ifndef PCI_DEVICE_ID_QLOGIC_ISP8042 688c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_QLOGIC_ISP8042 0x8042 698c2ecf20Sopenharmony_ci#endif 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#define ISP4XXX_PCI_FN_1 0x1 728c2ecf20Sopenharmony_ci#define ISP4XXX_PCI_FN_2 0x3 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#define QLA_SUCCESS 0 758c2ecf20Sopenharmony_ci#define QLA_ERROR 1 768c2ecf20Sopenharmony_ci#define STATUS(status) status == QLA_ERROR ? "FAILED" : "SUCCEEDED" 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/* 798c2ecf20Sopenharmony_ci * Data bit definitions 808c2ecf20Sopenharmony_ci */ 818c2ecf20Sopenharmony_ci#define BIT_0 0x1 828c2ecf20Sopenharmony_ci#define BIT_1 0x2 838c2ecf20Sopenharmony_ci#define BIT_2 0x4 848c2ecf20Sopenharmony_ci#define BIT_3 0x8 858c2ecf20Sopenharmony_ci#define BIT_4 0x10 868c2ecf20Sopenharmony_ci#define BIT_5 0x20 878c2ecf20Sopenharmony_ci#define BIT_6 0x40 888c2ecf20Sopenharmony_ci#define BIT_7 0x80 898c2ecf20Sopenharmony_ci#define BIT_8 0x100 908c2ecf20Sopenharmony_ci#define BIT_9 0x200 918c2ecf20Sopenharmony_ci#define BIT_10 0x400 928c2ecf20Sopenharmony_ci#define BIT_11 0x800 938c2ecf20Sopenharmony_ci#define BIT_12 0x1000 948c2ecf20Sopenharmony_ci#define BIT_13 0x2000 958c2ecf20Sopenharmony_ci#define BIT_14 0x4000 968c2ecf20Sopenharmony_ci#define BIT_15 0x8000 978c2ecf20Sopenharmony_ci#define BIT_16 0x10000 988c2ecf20Sopenharmony_ci#define BIT_17 0x20000 998c2ecf20Sopenharmony_ci#define BIT_18 0x40000 1008c2ecf20Sopenharmony_ci#define BIT_19 0x80000 1018c2ecf20Sopenharmony_ci#define BIT_20 0x100000 1028c2ecf20Sopenharmony_ci#define BIT_21 0x200000 1038c2ecf20Sopenharmony_ci#define BIT_22 0x400000 1048c2ecf20Sopenharmony_ci#define BIT_23 0x800000 1058c2ecf20Sopenharmony_ci#define BIT_24 0x1000000 1068c2ecf20Sopenharmony_ci#define BIT_25 0x2000000 1078c2ecf20Sopenharmony_ci#define BIT_26 0x4000000 1088c2ecf20Sopenharmony_ci#define BIT_27 0x8000000 1098c2ecf20Sopenharmony_ci#define BIT_28 0x10000000 1108c2ecf20Sopenharmony_ci#define BIT_29 0x20000000 1118c2ecf20Sopenharmony_ci#define BIT_30 0x40000000 1128c2ecf20Sopenharmony_ci#define BIT_31 0x80000000 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci/** 1158c2ecf20Sopenharmony_ci * Macros to help code, maintain, etc. 1168c2ecf20Sopenharmony_ci **/ 1178c2ecf20Sopenharmony_ci#define ql4_printk(level, ha, format, arg...) \ 1188c2ecf20Sopenharmony_ci dev_printk(level , &((ha)->pdev->dev) , format , ## arg) 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci/* 1228c2ecf20Sopenharmony_ci * Host adapter default definitions 1238c2ecf20Sopenharmony_ci ***********************************/ 1248c2ecf20Sopenharmony_ci#define MAX_HBAS 16 1258c2ecf20Sopenharmony_ci#define MAX_BUSES 1 1268c2ecf20Sopenharmony_ci#define MAX_TARGETS MAX_DEV_DB_ENTRIES 1278c2ecf20Sopenharmony_ci#define MAX_LUNS 0xffff 1288c2ecf20Sopenharmony_ci#define MAX_AEN_ENTRIES MAX_DEV_DB_ENTRIES 1298c2ecf20Sopenharmony_ci#define MAX_DDB_ENTRIES MAX_DEV_DB_ENTRIES 1308c2ecf20Sopenharmony_ci#define MAX_PDU_ENTRIES 32 1318c2ecf20Sopenharmony_ci#define INVALID_ENTRY 0xFFFF 1328c2ecf20Sopenharmony_ci#define MAX_CMDS_TO_RISC 1024 1338c2ecf20Sopenharmony_ci#define MAX_SRBS MAX_CMDS_TO_RISC 1348c2ecf20Sopenharmony_ci#define MBOX_AEN_REG_COUNT 8 1358c2ecf20Sopenharmony_ci#define MAX_INIT_RETRIES 5 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci/* 1388c2ecf20Sopenharmony_ci * Buffer sizes 1398c2ecf20Sopenharmony_ci */ 1408c2ecf20Sopenharmony_ci#define REQUEST_QUEUE_DEPTH MAX_CMDS_TO_RISC 1418c2ecf20Sopenharmony_ci#define RESPONSE_QUEUE_DEPTH 64 1428c2ecf20Sopenharmony_ci#define QUEUE_SIZE 64 1438c2ecf20Sopenharmony_ci#define DMA_BUFFER_SIZE 512 1448c2ecf20Sopenharmony_ci#define IOCB_HIWAT_CUSHION 4 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci/* 1478c2ecf20Sopenharmony_ci * Misc 1488c2ecf20Sopenharmony_ci */ 1498c2ecf20Sopenharmony_ci#define MAC_ADDR_LEN 6 /* in bytes */ 1508c2ecf20Sopenharmony_ci#define IP_ADDR_LEN 4 /* in bytes */ 1518c2ecf20Sopenharmony_ci#define IPv6_ADDR_LEN 16 /* IPv6 address size */ 1528c2ecf20Sopenharmony_ci#define DRIVER_NAME "qla4xxx" 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci#define MAX_LINKED_CMDS_PER_LUN 3 1558c2ecf20Sopenharmony_ci#define MAX_REQS_SERVICED_PER_INTR 1 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci#define ISCSI_IPADDR_SIZE 4 /* IP address size */ 1588c2ecf20Sopenharmony_ci#define ISCSI_ALIAS_SIZE 32 /* ISCSI Alias name size */ 1598c2ecf20Sopenharmony_ci#define ISCSI_NAME_SIZE 0xE0 /* ISCSI Name size */ 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci#define QL4_SESS_RECOVERY_TMO 120 /* iSCSI session */ 1628c2ecf20Sopenharmony_ci /* recovery timeout */ 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci#define LSDW(x) ((u32)((u64)(x))) 1658c2ecf20Sopenharmony_ci#define MSDW(x) ((u32)((((u64)(x)) >> 16) >> 16)) 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci#define DEV_DB_NON_PERSISTENT 0 1688c2ecf20Sopenharmony_ci#define DEV_DB_PERSISTENT 1 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci#define QL4_ISP_REG_DISCONNECT 0xffffffffU 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci#define COPY_ISID(dst_isid, src_isid) { \ 1738c2ecf20Sopenharmony_ci int i, j; \ 1748c2ecf20Sopenharmony_ci for (i = 0, j = ISID_SIZE - 1; i < ISID_SIZE;) \ 1758c2ecf20Sopenharmony_ci dst_isid[i++] = src_isid[j--]; \ 1768c2ecf20Sopenharmony_ci} 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci#define SET_BITVAL(o, n, v) { \ 1798c2ecf20Sopenharmony_ci if (o) \ 1808c2ecf20Sopenharmony_ci n |= v; \ 1818c2ecf20Sopenharmony_ci else \ 1828c2ecf20Sopenharmony_ci n &= ~v; \ 1838c2ecf20Sopenharmony_ci} 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci#define OP_STATE(o, f, p) { \ 1868c2ecf20Sopenharmony_ci p = (o & f) ? "enable" : "disable"; \ 1878c2ecf20Sopenharmony_ci} 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci/* 1908c2ecf20Sopenharmony_ci * Retry & Timeout Values 1918c2ecf20Sopenharmony_ci */ 1928c2ecf20Sopenharmony_ci#define MBOX_TOV 60 1938c2ecf20Sopenharmony_ci#define SOFT_RESET_TOV 30 1948c2ecf20Sopenharmony_ci#define RESET_INTR_TOV 3 1958c2ecf20Sopenharmony_ci#define SEMAPHORE_TOV 10 1968c2ecf20Sopenharmony_ci#define ADAPTER_INIT_TOV 30 1978c2ecf20Sopenharmony_ci#define ADAPTER_RESET_TOV 180 1988c2ecf20Sopenharmony_ci#define EXTEND_CMD_TOV 60 1998c2ecf20Sopenharmony_ci#define WAIT_CMD_TOV 5 2008c2ecf20Sopenharmony_ci#define EH_WAIT_CMD_TOV 120 2018c2ecf20Sopenharmony_ci#define FIRMWARE_UP_TOV 60 2028c2ecf20Sopenharmony_ci#define RESET_FIRMWARE_TOV 30 2038c2ecf20Sopenharmony_ci#define LOGOUT_TOV 10 2048c2ecf20Sopenharmony_ci#define IOCB_TOV_MARGIN 10 2058c2ecf20Sopenharmony_ci#define RELOGIN_TOV 18 2068c2ecf20Sopenharmony_ci#define ISNS_DEREG_TOV 5 2078c2ecf20Sopenharmony_ci#define HBA_ONLINE_TOV 30 2088c2ecf20Sopenharmony_ci#define DISABLE_ACB_TOV 30 2098c2ecf20Sopenharmony_ci#define IP_CONFIG_TOV 30 2108c2ecf20Sopenharmony_ci#define LOGIN_TOV 12 2118c2ecf20Sopenharmony_ci#define BOOT_LOGIN_RESP_TOV 60 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci#define MAX_RESET_HA_RETRIES 2 2148c2ecf20Sopenharmony_ci#define FW_ALIVE_WAIT_TOV 3 2158c2ecf20Sopenharmony_ci#define IDC_EXTEND_TOV 8 2168c2ecf20Sopenharmony_ci#define IDC_COMP_TOV 5 2178c2ecf20Sopenharmony_ci#define LINK_UP_COMP_TOV 30 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci#define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr) 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci/* 2228c2ecf20Sopenharmony_ci * SCSI Request Block structure (srb) that is placed 2238c2ecf20Sopenharmony_ci * on cmd->SCp location of every I/O [We have 22 bytes available] 2248c2ecf20Sopenharmony_ci */ 2258c2ecf20Sopenharmony_cistruct srb { 2268c2ecf20Sopenharmony_ci struct list_head list; /* (8) */ 2278c2ecf20Sopenharmony_ci struct scsi_qla_host *ha; /* HA the SP is queued on */ 2288c2ecf20Sopenharmony_ci struct ddb_entry *ddb; 2298c2ecf20Sopenharmony_ci uint16_t flags; /* (1) Status flags. */ 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci#define SRB_DMA_VALID BIT_3 /* DMA Buffer mapped. */ 2328c2ecf20Sopenharmony_ci#define SRB_GOT_SENSE BIT_4 /* sense data received. */ 2338c2ecf20Sopenharmony_ci uint8_t state; /* (1) Status flags. */ 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci#define SRB_NO_QUEUE_STATE 0 /* Request is in between states */ 2368c2ecf20Sopenharmony_ci#define SRB_FREE_STATE 1 2378c2ecf20Sopenharmony_ci#define SRB_ACTIVE_STATE 3 2388c2ecf20Sopenharmony_ci#define SRB_ACTIVE_TIMEOUT_STATE 4 2398c2ecf20Sopenharmony_ci#define SRB_SUSPENDED_STATE 7 /* Request in suspended state */ 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci struct scsi_cmnd *cmd; /* (4) SCSI command block */ 2428c2ecf20Sopenharmony_ci dma_addr_t dma_handle; /* (4) for unmap of single transfers */ 2438c2ecf20Sopenharmony_ci struct kref srb_ref; /* reference count for this srb */ 2448c2ecf20Sopenharmony_ci uint8_t err_id; /* error id */ 2458c2ecf20Sopenharmony_ci#define SRB_ERR_PORT 1 /* Request failed because "port down" */ 2468c2ecf20Sopenharmony_ci#define SRB_ERR_LOOP 2 /* Request failed because "loop down" */ 2478c2ecf20Sopenharmony_ci#define SRB_ERR_DEVICE 3 /* Request failed because "device error" */ 2488c2ecf20Sopenharmony_ci#define SRB_ERR_OTHER 4 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci uint16_t reserved; 2518c2ecf20Sopenharmony_ci uint16_t iocb_tov; 2528c2ecf20Sopenharmony_ci uint16_t iocb_cnt; /* Number of used iocbs */ 2538c2ecf20Sopenharmony_ci uint16_t cc_stat; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci /* Used for extended sense / status continuation */ 2568c2ecf20Sopenharmony_ci uint8_t *req_sense_ptr; 2578c2ecf20Sopenharmony_ci uint16_t req_sense_len; 2588c2ecf20Sopenharmony_ci uint16_t reserved2; 2598c2ecf20Sopenharmony_ci}; 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci/* Mailbox request block structure */ 2628c2ecf20Sopenharmony_cistruct mrb { 2638c2ecf20Sopenharmony_ci struct scsi_qla_host *ha; 2648c2ecf20Sopenharmony_ci struct mbox_cmd_iocb *mbox; 2658c2ecf20Sopenharmony_ci uint32_t mbox_cmd; 2668c2ecf20Sopenharmony_ci uint16_t iocb_cnt; /* Number of used iocbs */ 2678c2ecf20Sopenharmony_ci uint32_t pid; 2688c2ecf20Sopenharmony_ci}; 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci/* 2718c2ecf20Sopenharmony_ci * Asynchronous Event Queue structure 2728c2ecf20Sopenharmony_ci */ 2738c2ecf20Sopenharmony_cistruct aen { 2748c2ecf20Sopenharmony_ci uint32_t mbox_sts[MBOX_AEN_REG_COUNT]; 2758c2ecf20Sopenharmony_ci}; 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_cistruct ql4_aen_log { 2788c2ecf20Sopenharmony_ci int count; 2798c2ecf20Sopenharmony_ci struct aen entry[MAX_AEN_ENTRIES]; 2808c2ecf20Sopenharmony_ci}; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci/* 2838c2ecf20Sopenharmony_ci * Device Database (DDB) structure 2848c2ecf20Sopenharmony_ci */ 2858c2ecf20Sopenharmony_cistruct ddb_entry { 2868c2ecf20Sopenharmony_ci struct scsi_qla_host *ha; 2878c2ecf20Sopenharmony_ci struct iscsi_cls_session *sess; 2888c2ecf20Sopenharmony_ci struct iscsi_cls_conn *conn; 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci uint16_t fw_ddb_index; /* DDB firmware index */ 2918c2ecf20Sopenharmony_ci uint32_t fw_ddb_device_state; /* F/W Device State -- see ql4_fw.h */ 2928c2ecf20Sopenharmony_ci uint16_t ddb_type; 2938c2ecf20Sopenharmony_ci#define FLASH_DDB 0x01 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci struct dev_db_entry fw_ddb_entry; 2968c2ecf20Sopenharmony_ci int (*unblock_sess)(struct iscsi_cls_session *cls_session); 2978c2ecf20Sopenharmony_ci int (*ddb_change)(struct scsi_qla_host *ha, uint32_t fw_ddb_index, 2988c2ecf20Sopenharmony_ci struct ddb_entry *ddb_entry, uint32_t state); 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci /* Driver Re-login */ 3018c2ecf20Sopenharmony_ci unsigned long flags; /* DDB Flags */ 3028c2ecf20Sopenharmony_ci#define DDB_CONN_CLOSE_FAILURE 0 /* 0x00000001 */ 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci uint16_t default_relogin_timeout; /* Max time to wait for 3058c2ecf20Sopenharmony_ci * relogin to complete */ 3068c2ecf20Sopenharmony_ci atomic_t retry_relogin_timer; /* Min Time between relogins 3078c2ecf20Sopenharmony_ci * (4000 only) */ 3088c2ecf20Sopenharmony_ci atomic_t relogin_timer; /* Max Time to wait for 3098c2ecf20Sopenharmony_ci * relogin to complete */ 3108c2ecf20Sopenharmony_ci atomic_t relogin_retry_count; /* Num of times relogin has been 3118c2ecf20Sopenharmony_ci * retried */ 3128c2ecf20Sopenharmony_ci uint32_t default_time2wait; /* Default Min time between 3138c2ecf20Sopenharmony_ci * relogins (+aens) */ 3148c2ecf20Sopenharmony_ci uint16_t chap_tbl_idx; 3158c2ecf20Sopenharmony_ci}; 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_cistruct qla_ddb_index { 3188c2ecf20Sopenharmony_ci struct list_head list; 3198c2ecf20Sopenharmony_ci uint16_t fw_ddb_idx; 3208c2ecf20Sopenharmony_ci uint16_t flash_ddb_idx; 3218c2ecf20Sopenharmony_ci struct dev_db_entry fw_ddb; 3228c2ecf20Sopenharmony_ci uint8_t flash_isid[6]; 3238c2ecf20Sopenharmony_ci}; 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci#define DDB_IPADDR_LEN 64 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_cistruct ql4_tuple_ddb { 3288c2ecf20Sopenharmony_ci int port; 3298c2ecf20Sopenharmony_ci int tpgt; 3308c2ecf20Sopenharmony_ci char ip_addr[DDB_IPADDR_LEN]; 3318c2ecf20Sopenharmony_ci char iscsi_name[ISCSI_NAME_SIZE]; 3328c2ecf20Sopenharmony_ci uint16_t options; 3338c2ecf20Sopenharmony_ci#define DDB_OPT_IPV6 0x0e0e 3348c2ecf20Sopenharmony_ci#define DDB_OPT_IPV4 0x0f0f 3358c2ecf20Sopenharmony_ci uint8_t isid[6]; 3368c2ecf20Sopenharmony_ci}; 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_ci/* 3398c2ecf20Sopenharmony_ci * DDB states. 3408c2ecf20Sopenharmony_ci */ 3418c2ecf20Sopenharmony_ci#define DDB_STATE_DEAD 0 /* We can no longer talk to 3428c2ecf20Sopenharmony_ci * this device */ 3438c2ecf20Sopenharmony_ci#define DDB_STATE_ONLINE 1 /* Device ready to accept 3448c2ecf20Sopenharmony_ci * commands */ 3458c2ecf20Sopenharmony_ci#define DDB_STATE_MISSING 2 /* Device logged off, trying 3468c2ecf20Sopenharmony_ci * to re-login */ 3478c2ecf20Sopenharmony_ci 3488c2ecf20Sopenharmony_ci/* 3498c2ecf20Sopenharmony_ci * DDB flags. 3508c2ecf20Sopenharmony_ci */ 3518c2ecf20Sopenharmony_ci#define DF_RELOGIN 0 /* Relogin to device */ 3528c2ecf20Sopenharmony_ci#define DF_BOOT_TGT 1 /* Boot target entry */ 3538c2ecf20Sopenharmony_ci#define DF_ISNS_DISCOVERED 2 /* Device was discovered via iSNS */ 3548c2ecf20Sopenharmony_ci#define DF_FO_MASKED 3 3558c2ecf20Sopenharmony_ci#define DF_DISABLE_RELOGIN 4 /* Disable relogin to device */ 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_cienum qla4_work_type { 3588c2ecf20Sopenharmony_ci QLA4_EVENT_AEN, 3598c2ecf20Sopenharmony_ci QLA4_EVENT_PING_STATUS, 3608c2ecf20Sopenharmony_ci}; 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_cistruct qla4_work_evt { 3638c2ecf20Sopenharmony_ci struct list_head list; 3648c2ecf20Sopenharmony_ci enum qla4_work_type type; 3658c2ecf20Sopenharmony_ci union { 3668c2ecf20Sopenharmony_ci struct { 3678c2ecf20Sopenharmony_ci enum iscsi_host_event_code code; 3688c2ecf20Sopenharmony_ci uint32_t data_size; 3698c2ecf20Sopenharmony_ci uint8_t data[0]; 3708c2ecf20Sopenharmony_ci } aen; 3718c2ecf20Sopenharmony_ci struct { 3728c2ecf20Sopenharmony_ci uint32_t status; 3738c2ecf20Sopenharmony_ci uint32_t pid; 3748c2ecf20Sopenharmony_ci uint32_t data_size; 3758c2ecf20Sopenharmony_ci uint8_t data[0]; 3768c2ecf20Sopenharmony_ci } ping; 3778c2ecf20Sopenharmony_ci } u; 3788c2ecf20Sopenharmony_ci}; 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_cistruct ql82xx_hw_data { 3818c2ecf20Sopenharmony_ci /* Offsets for flash/nvram access (set to ~0 if not used). */ 3828c2ecf20Sopenharmony_ci uint32_t flash_conf_off; 3838c2ecf20Sopenharmony_ci uint32_t flash_data_off; 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ci uint32_t fdt_wrt_disable; 3868c2ecf20Sopenharmony_ci uint32_t fdt_erase_cmd; 3878c2ecf20Sopenharmony_ci uint32_t fdt_block_size; 3888c2ecf20Sopenharmony_ci uint32_t fdt_unprotect_sec_cmd; 3898c2ecf20Sopenharmony_ci uint32_t fdt_protect_sec_cmd; 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci uint32_t flt_region_flt; 3928c2ecf20Sopenharmony_ci uint32_t flt_region_fdt; 3938c2ecf20Sopenharmony_ci uint32_t flt_region_boot; 3948c2ecf20Sopenharmony_ci uint32_t flt_region_bootload; 3958c2ecf20Sopenharmony_ci uint32_t flt_region_fw; 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci uint32_t flt_iscsi_param; 3988c2ecf20Sopenharmony_ci uint32_t flt_region_chap; 3998c2ecf20Sopenharmony_ci uint32_t flt_chap_size; 4008c2ecf20Sopenharmony_ci uint32_t flt_region_ddb; 4018c2ecf20Sopenharmony_ci uint32_t flt_ddb_size; 4028c2ecf20Sopenharmony_ci}; 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_cistruct qla4_8xxx_legacy_intr_set { 4058c2ecf20Sopenharmony_ci uint32_t int_vec_bit; 4068c2ecf20Sopenharmony_ci uint32_t tgt_status_reg; 4078c2ecf20Sopenharmony_ci uint32_t tgt_mask_reg; 4088c2ecf20Sopenharmony_ci uint32_t pci_int_reg; 4098c2ecf20Sopenharmony_ci}; 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci/* MSI-X Support */ 4128c2ecf20Sopenharmony_ci#define QLA_MSIX_ENTRIES 2 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci/* 4158c2ecf20Sopenharmony_ci * ISP Operations 4168c2ecf20Sopenharmony_ci */ 4178c2ecf20Sopenharmony_cistruct isp_operations { 4188c2ecf20Sopenharmony_ci int (*iospace_config) (struct scsi_qla_host *ha); 4198c2ecf20Sopenharmony_ci void (*pci_config) (struct scsi_qla_host *); 4208c2ecf20Sopenharmony_ci void (*disable_intrs) (struct scsi_qla_host *); 4218c2ecf20Sopenharmony_ci void (*enable_intrs) (struct scsi_qla_host *); 4228c2ecf20Sopenharmony_ci int (*start_firmware) (struct scsi_qla_host *); 4238c2ecf20Sopenharmony_ci int (*restart_firmware) (struct scsi_qla_host *); 4248c2ecf20Sopenharmony_ci irqreturn_t (*intr_handler) (int , void *); 4258c2ecf20Sopenharmony_ci void (*interrupt_service_routine) (struct scsi_qla_host *, uint32_t); 4268c2ecf20Sopenharmony_ci int (*need_reset) (struct scsi_qla_host *); 4278c2ecf20Sopenharmony_ci int (*reset_chip) (struct scsi_qla_host *); 4288c2ecf20Sopenharmony_ci int (*reset_firmware) (struct scsi_qla_host *); 4298c2ecf20Sopenharmony_ci void (*queue_iocb) (struct scsi_qla_host *); 4308c2ecf20Sopenharmony_ci void (*complete_iocb) (struct scsi_qla_host *); 4318c2ecf20Sopenharmony_ci uint16_t (*rd_shdw_req_q_out) (struct scsi_qla_host *); 4328c2ecf20Sopenharmony_ci uint16_t (*rd_shdw_rsp_q_in) (struct scsi_qla_host *); 4338c2ecf20Sopenharmony_ci int (*get_sys_info) (struct scsi_qla_host *); 4348c2ecf20Sopenharmony_ci uint32_t (*rd_reg_direct) (struct scsi_qla_host *, ulong); 4358c2ecf20Sopenharmony_ci void (*wr_reg_direct) (struct scsi_qla_host *, ulong, uint32_t); 4368c2ecf20Sopenharmony_ci int (*rd_reg_indirect) (struct scsi_qla_host *, uint32_t, uint32_t *); 4378c2ecf20Sopenharmony_ci int (*wr_reg_indirect) (struct scsi_qla_host *, uint32_t, uint32_t); 4388c2ecf20Sopenharmony_ci int (*idc_lock) (struct scsi_qla_host *); 4398c2ecf20Sopenharmony_ci void (*idc_unlock) (struct scsi_qla_host *); 4408c2ecf20Sopenharmony_ci void (*rom_lock_recovery) (struct scsi_qla_host *); 4418c2ecf20Sopenharmony_ci void (*queue_mailbox_command) (struct scsi_qla_host *, uint32_t *, int); 4428c2ecf20Sopenharmony_ci void (*process_mailbox_interrupt) (struct scsi_qla_host *, int); 4438c2ecf20Sopenharmony_ci}; 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_cistruct ql4_mdump_size_table { 4468c2ecf20Sopenharmony_ci uint32_t size; 4478c2ecf20Sopenharmony_ci uint32_t size_cmask_02; 4488c2ecf20Sopenharmony_ci uint32_t size_cmask_04; 4498c2ecf20Sopenharmony_ci uint32_t size_cmask_08; 4508c2ecf20Sopenharmony_ci uint32_t size_cmask_10; 4518c2ecf20Sopenharmony_ci uint32_t size_cmask_FF; 4528c2ecf20Sopenharmony_ci uint32_t version; 4538c2ecf20Sopenharmony_ci}; 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci/*qla4xxx ipaddress configuration details */ 4568c2ecf20Sopenharmony_cistruct ipaddress_config { 4578c2ecf20Sopenharmony_ci uint16_t ipv4_options; 4588c2ecf20Sopenharmony_ci uint16_t tcp_options; 4598c2ecf20Sopenharmony_ci uint16_t ipv4_vlan_tag; 4608c2ecf20Sopenharmony_ci uint8_t ipv4_addr_state; 4618c2ecf20Sopenharmony_ci uint8_t ip_address[IP_ADDR_LEN]; 4628c2ecf20Sopenharmony_ci uint8_t subnet_mask[IP_ADDR_LEN]; 4638c2ecf20Sopenharmony_ci uint8_t gateway[IP_ADDR_LEN]; 4648c2ecf20Sopenharmony_ci uint32_t ipv6_options; 4658c2ecf20Sopenharmony_ci uint32_t ipv6_addl_options; 4668c2ecf20Sopenharmony_ci uint8_t ipv6_link_local_state; 4678c2ecf20Sopenharmony_ci uint8_t ipv6_addr0_state; 4688c2ecf20Sopenharmony_ci uint8_t ipv6_addr1_state; 4698c2ecf20Sopenharmony_ci uint8_t ipv6_default_router_state; 4708c2ecf20Sopenharmony_ci uint16_t ipv6_vlan_tag; 4718c2ecf20Sopenharmony_ci struct in6_addr ipv6_link_local_addr; 4728c2ecf20Sopenharmony_ci struct in6_addr ipv6_addr0; 4738c2ecf20Sopenharmony_ci struct in6_addr ipv6_addr1; 4748c2ecf20Sopenharmony_ci struct in6_addr ipv6_default_router_addr; 4758c2ecf20Sopenharmony_ci uint16_t eth_mtu_size; 4768c2ecf20Sopenharmony_ci uint16_t ipv4_port; 4778c2ecf20Sopenharmony_ci uint16_t ipv6_port; 4788c2ecf20Sopenharmony_ci uint8_t control; 4798c2ecf20Sopenharmony_ci uint16_t ipv6_tcp_options; 4808c2ecf20Sopenharmony_ci uint8_t tcp_wsf; 4818c2ecf20Sopenharmony_ci uint8_t ipv6_tcp_wsf; 4828c2ecf20Sopenharmony_ci uint8_t ipv4_tos; 4838c2ecf20Sopenharmony_ci uint8_t ipv4_cache_id; 4848c2ecf20Sopenharmony_ci uint8_t ipv6_cache_id; 4858c2ecf20Sopenharmony_ci uint8_t ipv4_alt_cid_len; 4868c2ecf20Sopenharmony_ci uint8_t ipv4_alt_cid[11]; 4878c2ecf20Sopenharmony_ci uint8_t ipv4_vid_len; 4888c2ecf20Sopenharmony_ci uint8_t ipv4_vid[11]; 4898c2ecf20Sopenharmony_ci uint8_t ipv4_ttl; 4908c2ecf20Sopenharmony_ci uint16_t ipv6_flow_lbl; 4918c2ecf20Sopenharmony_ci uint8_t ipv6_traffic_class; 4928c2ecf20Sopenharmony_ci uint8_t ipv6_hop_limit; 4938c2ecf20Sopenharmony_ci uint32_t ipv6_nd_reach_time; 4948c2ecf20Sopenharmony_ci uint32_t ipv6_nd_rexmit_timer; 4958c2ecf20Sopenharmony_ci uint32_t ipv6_nd_stale_timeout; 4968c2ecf20Sopenharmony_ci uint8_t ipv6_dup_addr_detect_count; 4978c2ecf20Sopenharmony_ci uint32_t ipv6_gw_advrt_mtu; 4988c2ecf20Sopenharmony_ci uint16_t def_timeout; 4998c2ecf20Sopenharmony_ci uint8_t abort_timer; 5008c2ecf20Sopenharmony_ci uint16_t iscsi_options; 5018c2ecf20Sopenharmony_ci uint16_t iscsi_max_pdu_size; 5028c2ecf20Sopenharmony_ci uint16_t iscsi_first_burst_len; 5038c2ecf20Sopenharmony_ci uint16_t iscsi_max_outstnd_r2t; 5048c2ecf20Sopenharmony_ci uint16_t iscsi_max_burst_len; 5058c2ecf20Sopenharmony_ci uint8_t iscsi_name[224]; 5068c2ecf20Sopenharmony_ci}; 5078c2ecf20Sopenharmony_ci 5088c2ecf20Sopenharmony_ci#define QL4_CHAP_MAX_NAME_LEN 256 5098c2ecf20Sopenharmony_ci#define QL4_CHAP_MAX_SECRET_LEN 100 5108c2ecf20Sopenharmony_ci#define LOCAL_CHAP 0 5118c2ecf20Sopenharmony_ci#define BIDI_CHAP 1 5128c2ecf20Sopenharmony_ci 5138c2ecf20Sopenharmony_cistruct ql4_chap_format { 5148c2ecf20Sopenharmony_ci u8 intr_chap_name[QL4_CHAP_MAX_NAME_LEN]; 5158c2ecf20Sopenharmony_ci u8 intr_secret[QL4_CHAP_MAX_SECRET_LEN]; 5168c2ecf20Sopenharmony_ci u8 target_chap_name[QL4_CHAP_MAX_NAME_LEN]; 5178c2ecf20Sopenharmony_ci u8 target_secret[QL4_CHAP_MAX_SECRET_LEN]; 5188c2ecf20Sopenharmony_ci u16 intr_chap_name_length; 5198c2ecf20Sopenharmony_ci u16 intr_secret_length; 5208c2ecf20Sopenharmony_ci u16 target_chap_name_length; 5218c2ecf20Sopenharmony_ci u16 target_secret_length; 5228c2ecf20Sopenharmony_ci}; 5238c2ecf20Sopenharmony_ci 5248c2ecf20Sopenharmony_cistruct ip_address_format { 5258c2ecf20Sopenharmony_ci u8 ip_type; 5268c2ecf20Sopenharmony_ci u8 ip_address[16]; 5278c2ecf20Sopenharmony_ci}; 5288c2ecf20Sopenharmony_ci 5298c2ecf20Sopenharmony_cistruct ql4_conn_info { 5308c2ecf20Sopenharmony_ci u16 dest_port; 5318c2ecf20Sopenharmony_ci struct ip_address_format dest_ipaddr; 5328c2ecf20Sopenharmony_ci struct ql4_chap_format chap; 5338c2ecf20Sopenharmony_ci}; 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_cistruct ql4_boot_session_info { 5368c2ecf20Sopenharmony_ci u8 target_name[224]; 5378c2ecf20Sopenharmony_ci struct ql4_conn_info conn_list[1]; 5388c2ecf20Sopenharmony_ci}; 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_cistruct ql4_boot_tgt_info { 5418c2ecf20Sopenharmony_ci struct ql4_boot_session_info boot_pri_sess; 5428c2ecf20Sopenharmony_ci struct ql4_boot_session_info boot_sec_sess; 5438c2ecf20Sopenharmony_ci}; 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_ci/* 5468c2ecf20Sopenharmony_ci * Linux Host Adapter structure 5478c2ecf20Sopenharmony_ci */ 5488c2ecf20Sopenharmony_cistruct scsi_qla_host { 5498c2ecf20Sopenharmony_ci /* Linux adapter configuration data */ 5508c2ecf20Sopenharmony_ci unsigned long flags; 5518c2ecf20Sopenharmony_ci 5528c2ecf20Sopenharmony_ci#define AF_ONLINE 0 /* 0x00000001 */ 5538c2ecf20Sopenharmony_ci#define AF_INIT_DONE 1 /* 0x00000002 */ 5548c2ecf20Sopenharmony_ci#define AF_MBOX_COMMAND 2 /* 0x00000004 */ 5558c2ecf20Sopenharmony_ci#define AF_MBOX_COMMAND_DONE 3 /* 0x00000008 */ 5568c2ecf20Sopenharmony_ci#define AF_ST_DISCOVERY_IN_PROGRESS 4 /* 0x00000010 */ 5578c2ecf20Sopenharmony_ci#define AF_INTERRUPTS_ON 6 /* 0x00000040 */ 5588c2ecf20Sopenharmony_ci#define AF_GET_CRASH_RECORD 7 /* 0x00000080 */ 5598c2ecf20Sopenharmony_ci#define AF_LINK_UP 8 /* 0x00000100 */ 5608c2ecf20Sopenharmony_ci#define AF_LOOPBACK 9 /* 0x00000200 */ 5618c2ecf20Sopenharmony_ci#define AF_IRQ_ATTACHED 10 /* 0x00000400 */ 5628c2ecf20Sopenharmony_ci#define AF_DISABLE_ACB_COMPLETE 11 /* 0x00000800 */ 5638c2ecf20Sopenharmony_ci#define AF_HA_REMOVAL 12 /* 0x00001000 */ 5648c2ecf20Sopenharmony_ci#define AF_MBOX_COMMAND_NOPOLL 18 /* 0x00040000 */ 5658c2ecf20Sopenharmony_ci#define AF_FW_RECOVERY 19 /* 0x00080000 */ 5668c2ecf20Sopenharmony_ci#define AF_EEH_BUSY 20 /* 0x00100000 */ 5678c2ecf20Sopenharmony_ci#define AF_PCI_CHANNEL_IO_PERM_FAILURE 21 /* 0x00200000 */ 5688c2ecf20Sopenharmony_ci#define AF_BUILD_DDB_LIST 22 /* 0x00400000 */ 5698c2ecf20Sopenharmony_ci#define AF_82XX_FW_DUMPED 24 /* 0x01000000 */ 5708c2ecf20Sopenharmony_ci#define AF_8XXX_RST_OWNER 25 /* 0x02000000 */ 5718c2ecf20Sopenharmony_ci#define AF_82XX_DUMP_READING 26 /* 0x04000000 */ 5728c2ecf20Sopenharmony_ci#define AF_83XX_IOCB_INTR_ON 28 /* 0x10000000 */ 5738c2ecf20Sopenharmony_ci#define AF_83XX_MBOX_INTR_ON 29 /* 0x20000000 */ 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci unsigned long dpc_flags; 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ci#define DPC_RESET_HA 1 /* 0x00000002 */ 5788c2ecf20Sopenharmony_ci#define DPC_RETRY_RESET_HA 2 /* 0x00000004 */ 5798c2ecf20Sopenharmony_ci#define DPC_RELOGIN_DEVICE 3 /* 0x00000008 */ 5808c2ecf20Sopenharmony_ci#define DPC_RESET_HA_FW_CONTEXT 4 /* 0x00000010 */ 5818c2ecf20Sopenharmony_ci#define DPC_RESET_HA_INTR 5 /* 0x00000020 */ 5828c2ecf20Sopenharmony_ci#define DPC_ISNS_RESTART 7 /* 0x00000080 */ 5838c2ecf20Sopenharmony_ci#define DPC_AEN 9 /* 0x00000200 */ 5848c2ecf20Sopenharmony_ci#define DPC_GET_DHCP_IP_ADDR 15 /* 0x00008000 */ 5858c2ecf20Sopenharmony_ci#define DPC_LINK_CHANGED 18 /* 0x00040000 */ 5868c2ecf20Sopenharmony_ci#define DPC_RESET_ACTIVE 20 /* 0x00100000 */ 5878c2ecf20Sopenharmony_ci#define DPC_HA_UNRECOVERABLE 21 /* 0x00200000 ISP-82xx only*/ 5888c2ecf20Sopenharmony_ci#define DPC_HA_NEED_QUIESCENT 22 /* 0x00400000 ISP-82xx only*/ 5898c2ecf20Sopenharmony_ci#define DPC_POST_IDC_ACK 23 /* 0x00800000 */ 5908c2ecf20Sopenharmony_ci#define DPC_RESTORE_ACB 24 /* 0x01000000 */ 5918c2ecf20Sopenharmony_ci#define DPC_SYSFS_DDB_EXPORT 25 /* 0x02000000 */ 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ci struct Scsi_Host *host; /* pointer to host data */ 5948c2ecf20Sopenharmony_ci uint32_t tot_ddbs; 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci uint16_t iocb_cnt; 5978c2ecf20Sopenharmony_ci uint16_t iocb_hiwat; 5988c2ecf20Sopenharmony_ci 5998c2ecf20Sopenharmony_ci /* SRB cache. */ 6008c2ecf20Sopenharmony_ci#define SRB_MIN_REQ 128 6018c2ecf20Sopenharmony_ci mempool_t *srb_mempool; 6028c2ecf20Sopenharmony_ci 6038c2ecf20Sopenharmony_ci /* pci information */ 6048c2ecf20Sopenharmony_ci struct pci_dev *pdev; 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci struct isp_reg __iomem *reg; /* Base I/O address */ 6078c2ecf20Sopenharmony_ci unsigned long pio_address; 6088c2ecf20Sopenharmony_ci unsigned long pio_length; 6098c2ecf20Sopenharmony_ci#define MIN_IOBASE_LEN 0x100 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci uint16_t req_q_count; 6128c2ecf20Sopenharmony_ci 6138c2ecf20Sopenharmony_ci unsigned long host_no; 6148c2ecf20Sopenharmony_ci 6158c2ecf20Sopenharmony_ci /* NVRAM registers */ 6168c2ecf20Sopenharmony_ci struct eeprom_data *nvram; 6178c2ecf20Sopenharmony_ci spinlock_t hardware_lock ____cacheline_aligned; 6188c2ecf20Sopenharmony_ci uint32_t eeprom_cmd_data; 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_ci /* Counters for general statistics */ 6218c2ecf20Sopenharmony_ci uint64_t isr_count; 6228c2ecf20Sopenharmony_ci uint64_t adapter_error_count; 6238c2ecf20Sopenharmony_ci uint64_t device_error_count; 6248c2ecf20Sopenharmony_ci uint64_t total_io_count; 6258c2ecf20Sopenharmony_ci uint64_t total_mbytes_xferred; 6268c2ecf20Sopenharmony_ci uint64_t link_failure_count; 6278c2ecf20Sopenharmony_ci uint64_t invalid_crc_count; 6288c2ecf20Sopenharmony_ci uint32_t bytes_xfered; 6298c2ecf20Sopenharmony_ci uint32_t spurious_int_count; 6308c2ecf20Sopenharmony_ci uint32_t aborted_io_count; 6318c2ecf20Sopenharmony_ci uint32_t io_timeout_count; 6328c2ecf20Sopenharmony_ci uint32_t mailbox_timeout_count; 6338c2ecf20Sopenharmony_ci uint32_t seconds_since_last_intr; 6348c2ecf20Sopenharmony_ci uint32_t seconds_since_last_heartbeat; 6358c2ecf20Sopenharmony_ci uint32_t mac_index; 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ci /* Info Needed for Management App */ 6388c2ecf20Sopenharmony_ci /* --- From GetFwVersion --- */ 6398c2ecf20Sopenharmony_ci uint32_t firmware_version[2]; 6408c2ecf20Sopenharmony_ci uint32_t patch_number; 6418c2ecf20Sopenharmony_ci uint32_t build_number; 6428c2ecf20Sopenharmony_ci uint32_t board_id; 6438c2ecf20Sopenharmony_ci 6448c2ecf20Sopenharmony_ci /* --- From Init_FW --- */ 6458c2ecf20Sopenharmony_ci /* init_cb_t *init_cb; */ 6468c2ecf20Sopenharmony_ci uint16_t firmware_options; 6478c2ecf20Sopenharmony_ci uint8_t alias[32]; 6488c2ecf20Sopenharmony_ci uint8_t name_string[256]; 6498c2ecf20Sopenharmony_ci uint8_t heartbeat_interval; 6508c2ecf20Sopenharmony_ci 6518c2ecf20Sopenharmony_ci /* --- From FlashSysInfo --- */ 6528c2ecf20Sopenharmony_ci uint8_t my_mac[MAC_ADDR_LEN]; 6538c2ecf20Sopenharmony_ci uint8_t serial_number[16]; 6548c2ecf20Sopenharmony_ci uint16_t port_num; 6558c2ecf20Sopenharmony_ci /* --- From GetFwState --- */ 6568c2ecf20Sopenharmony_ci uint32_t firmware_state; 6578c2ecf20Sopenharmony_ci uint32_t addl_fw_state; 6588c2ecf20Sopenharmony_ci 6598c2ecf20Sopenharmony_ci /* Linux kernel thread */ 6608c2ecf20Sopenharmony_ci struct workqueue_struct *dpc_thread; 6618c2ecf20Sopenharmony_ci struct work_struct dpc_work; 6628c2ecf20Sopenharmony_ci 6638c2ecf20Sopenharmony_ci /* Linux timer thread */ 6648c2ecf20Sopenharmony_ci struct timer_list timer; 6658c2ecf20Sopenharmony_ci uint32_t timer_active; 6668c2ecf20Sopenharmony_ci 6678c2ecf20Sopenharmony_ci /* Recovery Timers */ 6688c2ecf20Sopenharmony_ci atomic_t check_relogin_timeouts; 6698c2ecf20Sopenharmony_ci uint32_t retry_reset_ha_cnt; 6708c2ecf20Sopenharmony_ci uint32_t isp_reset_timer; /* reset test timer */ 6718c2ecf20Sopenharmony_ci uint32_t nic_reset_timer; /* simulated nic reset test timer */ 6728c2ecf20Sopenharmony_ci int eh_start; 6738c2ecf20Sopenharmony_ci struct list_head free_srb_q; 6748c2ecf20Sopenharmony_ci uint16_t free_srb_q_count; 6758c2ecf20Sopenharmony_ci uint16_t num_srbs_allocated; 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_ci /* DMA Memory Block */ 6788c2ecf20Sopenharmony_ci void *queues; 6798c2ecf20Sopenharmony_ci dma_addr_t queues_dma; 6808c2ecf20Sopenharmony_ci unsigned long queues_len; 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_ci#define MEM_ALIGN_VALUE \ 6838c2ecf20Sopenharmony_ci ((max(REQUEST_QUEUE_DEPTH, RESPONSE_QUEUE_DEPTH)) * \ 6848c2ecf20Sopenharmony_ci sizeof(struct queue_entry)) 6858c2ecf20Sopenharmony_ci /* request and response queue variables */ 6868c2ecf20Sopenharmony_ci dma_addr_t request_dma; 6878c2ecf20Sopenharmony_ci struct queue_entry *request_ring; 6888c2ecf20Sopenharmony_ci struct queue_entry *request_ptr; 6898c2ecf20Sopenharmony_ci dma_addr_t response_dma; 6908c2ecf20Sopenharmony_ci struct queue_entry *response_ring; 6918c2ecf20Sopenharmony_ci struct queue_entry *response_ptr; 6928c2ecf20Sopenharmony_ci dma_addr_t shadow_regs_dma; 6938c2ecf20Sopenharmony_ci struct shadow_regs *shadow_regs; 6948c2ecf20Sopenharmony_ci uint16_t request_in; /* Current indexes. */ 6958c2ecf20Sopenharmony_ci uint16_t request_out; 6968c2ecf20Sopenharmony_ci uint16_t response_in; 6978c2ecf20Sopenharmony_ci uint16_t response_out; 6988c2ecf20Sopenharmony_ci 6998c2ecf20Sopenharmony_ci /* aen queue variables */ 7008c2ecf20Sopenharmony_ci uint16_t aen_q_count; /* Number of available aen_q entries */ 7018c2ecf20Sopenharmony_ci uint16_t aen_in; /* Current indexes */ 7028c2ecf20Sopenharmony_ci uint16_t aen_out; 7038c2ecf20Sopenharmony_ci struct aen aen_q[MAX_AEN_ENTRIES]; 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_ci struct ql4_aen_log aen_log;/* tracks all aens */ 7068c2ecf20Sopenharmony_ci 7078c2ecf20Sopenharmony_ci /* This mutex protects several threads to do mailbox commands 7088c2ecf20Sopenharmony_ci * concurrently. 7098c2ecf20Sopenharmony_ci */ 7108c2ecf20Sopenharmony_ci struct mutex mbox_sem; 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci /* temporary mailbox status registers */ 7138c2ecf20Sopenharmony_ci volatile uint8_t mbox_status_count; 7148c2ecf20Sopenharmony_ci volatile uint32_t mbox_status[MBOX_REG_COUNT]; 7158c2ecf20Sopenharmony_ci 7168c2ecf20Sopenharmony_ci /* FW ddb index map */ 7178c2ecf20Sopenharmony_ci struct ddb_entry *fw_ddb_index_map[MAX_DDB_ENTRIES]; 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_ci /* Saved srb for status continuation entry processing */ 7208c2ecf20Sopenharmony_ci struct srb *status_srb; 7218c2ecf20Sopenharmony_ci 7228c2ecf20Sopenharmony_ci uint8_t acb_version; 7238c2ecf20Sopenharmony_ci 7248c2ecf20Sopenharmony_ci /* qla82xx specific fields */ 7258c2ecf20Sopenharmony_ci struct device_reg_82xx __iomem *qla4_82xx_reg; /* Base I/O address */ 7268c2ecf20Sopenharmony_ci unsigned long nx_pcibase; /* Base I/O address */ 7278c2ecf20Sopenharmony_ci uint8_t *nx_db_rd_ptr; /* Doorbell read pointer */ 7288c2ecf20Sopenharmony_ci unsigned long nx_db_wr_ptr; /* Door bell write pointer */ 7298c2ecf20Sopenharmony_ci unsigned long first_page_group_start; 7308c2ecf20Sopenharmony_ci unsigned long first_page_group_end; 7318c2ecf20Sopenharmony_ci 7328c2ecf20Sopenharmony_ci uint32_t crb_win; 7338c2ecf20Sopenharmony_ci uint32_t curr_window; 7348c2ecf20Sopenharmony_ci uint32_t ddr_mn_window; 7358c2ecf20Sopenharmony_ci unsigned long mn_win_crb; 7368c2ecf20Sopenharmony_ci unsigned long ms_win_crb; 7378c2ecf20Sopenharmony_ci int qdr_sn_window; 7388c2ecf20Sopenharmony_ci rwlock_t hw_lock; 7398c2ecf20Sopenharmony_ci uint16_t func_num; 7408c2ecf20Sopenharmony_ci int link_width; 7418c2ecf20Sopenharmony_ci 7428c2ecf20Sopenharmony_ci struct qla4_8xxx_legacy_intr_set nx_legacy_intr; 7438c2ecf20Sopenharmony_ci u32 nx_crb_mask; 7448c2ecf20Sopenharmony_ci 7458c2ecf20Sopenharmony_ci uint8_t revision_id; 7468c2ecf20Sopenharmony_ci uint32_t fw_heartbeat_counter; 7478c2ecf20Sopenharmony_ci 7488c2ecf20Sopenharmony_ci struct isp_operations *isp_ops; 7498c2ecf20Sopenharmony_ci struct ql82xx_hw_data hw; 7508c2ecf20Sopenharmony_ci 7518c2ecf20Sopenharmony_ci uint32_t nx_dev_init_timeout; 7528c2ecf20Sopenharmony_ci uint32_t nx_reset_timeout; 7538c2ecf20Sopenharmony_ci void *fw_dump; 7548c2ecf20Sopenharmony_ci uint32_t fw_dump_size; 7558c2ecf20Sopenharmony_ci uint32_t fw_dump_capture_mask; 7568c2ecf20Sopenharmony_ci void *fw_dump_tmplt_hdr; 7578c2ecf20Sopenharmony_ci uint32_t fw_dump_tmplt_size; 7588c2ecf20Sopenharmony_ci uint32_t fw_dump_skip_size; 7598c2ecf20Sopenharmony_ci 7608c2ecf20Sopenharmony_ci struct completion mbx_intr_comp; 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_ci struct ipaddress_config ip_config; 7638c2ecf20Sopenharmony_ci struct iscsi_iface *iface_ipv4; 7648c2ecf20Sopenharmony_ci struct iscsi_iface *iface_ipv6_0; 7658c2ecf20Sopenharmony_ci struct iscsi_iface *iface_ipv6_1; 7668c2ecf20Sopenharmony_ci 7678c2ecf20Sopenharmony_ci /* --- From About Firmware --- */ 7688c2ecf20Sopenharmony_ci struct about_fw_info fw_info; 7698c2ecf20Sopenharmony_ci uint32_t fw_uptime_secs; /* seconds elapsed since fw bootup */ 7708c2ecf20Sopenharmony_ci uint32_t fw_uptime_msecs; /* milliseconds beyond elapsed seconds */ 7718c2ecf20Sopenharmony_ci uint16_t def_timeout; /* Default login timeout */ 7728c2ecf20Sopenharmony_ci 7738c2ecf20Sopenharmony_ci uint32_t flash_state; 7748c2ecf20Sopenharmony_ci#define QLFLASH_WAITING 0 7758c2ecf20Sopenharmony_ci#define QLFLASH_READING 1 7768c2ecf20Sopenharmony_ci#define QLFLASH_WRITING 2 7778c2ecf20Sopenharmony_ci struct dma_pool *chap_dma_pool; 7788c2ecf20Sopenharmony_ci uint8_t *chap_list; /* CHAP table cache */ 7798c2ecf20Sopenharmony_ci struct mutex chap_sem; 7808c2ecf20Sopenharmony_ci 7818c2ecf20Sopenharmony_ci#define CHAP_DMA_BLOCK_SIZE 512 7828c2ecf20Sopenharmony_ci struct workqueue_struct *task_wq; 7838c2ecf20Sopenharmony_ci unsigned long ddb_idx_map[MAX_DDB_ENTRIES / BITS_PER_LONG]; 7848c2ecf20Sopenharmony_ci#define SYSFS_FLAG_FW_SEL_BOOT 2 7858c2ecf20Sopenharmony_ci struct iscsi_boot_kset *boot_kset; 7868c2ecf20Sopenharmony_ci struct ql4_boot_tgt_info boot_tgt; 7878c2ecf20Sopenharmony_ci uint16_t phy_port_num; 7888c2ecf20Sopenharmony_ci uint16_t phy_port_cnt; 7898c2ecf20Sopenharmony_ci uint16_t iscsi_pci_func_cnt; 7908c2ecf20Sopenharmony_ci uint8_t model_name[16]; 7918c2ecf20Sopenharmony_ci struct completion disable_acb_comp; 7928c2ecf20Sopenharmony_ci struct dma_pool *fw_ddb_dma_pool; 7938c2ecf20Sopenharmony_ci#define DDB_DMA_BLOCK_SIZE 512 7948c2ecf20Sopenharmony_ci uint16_t pri_ddb_idx; 7958c2ecf20Sopenharmony_ci uint16_t sec_ddb_idx; 7968c2ecf20Sopenharmony_ci int is_reset; 7978c2ecf20Sopenharmony_ci uint16_t temperature; 7988c2ecf20Sopenharmony_ci 7998c2ecf20Sopenharmony_ci /* event work list */ 8008c2ecf20Sopenharmony_ci struct list_head work_list; 8018c2ecf20Sopenharmony_ci spinlock_t work_lock; 8028c2ecf20Sopenharmony_ci 8038c2ecf20Sopenharmony_ci /* mbox iocb */ 8048c2ecf20Sopenharmony_ci#define MAX_MRB 128 8058c2ecf20Sopenharmony_ci struct mrb *active_mrb_array[MAX_MRB]; 8068c2ecf20Sopenharmony_ci uint32_t mrb_index; 8078c2ecf20Sopenharmony_ci 8088c2ecf20Sopenharmony_ci uint32_t *reg_tbl; 8098c2ecf20Sopenharmony_ci struct qla4_83xx_reset_template reset_tmplt; 8108c2ecf20Sopenharmony_ci struct device_reg_83xx __iomem *qla4_83xx_reg; /* Base I/O address 8118c2ecf20Sopenharmony_ci for ISP8324 and 8128c2ecf20Sopenharmony_ci and ISP8042 */ 8138c2ecf20Sopenharmony_ci uint32_t pf_bit; 8148c2ecf20Sopenharmony_ci struct qla4_83xx_idc_information idc_info; 8158c2ecf20Sopenharmony_ci struct addr_ctrl_blk *saved_acb; 8168c2ecf20Sopenharmony_ci int notify_idc_comp; 8178c2ecf20Sopenharmony_ci int notify_link_up_comp; 8188c2ecf20Sopenharmony_ci int idc_extend_tmo; 8198c2ecf20Sopenharmony_ci struct completion idc_comp; 8208c2ecf20Sopenharmony_ci struct completion link_up_comp; 8218c2ecf20Sopenharmony_ci}; 8228c2ecf20Sopenharmony_ci 8238c2ecf20Sopenharmony_cistruct ql4_task_data { 8248c2ecf20Sopenharmony_ci struct scsi_qla_host *ha; 8258c2ecf20Sopenharmony_ci uint8_t iocb_req_cnt; 8268c2ecf20Sopenharmony_ci dma_addr_t data_dma; 8278c2ecf20Sopenharmony_ci void *req_buffer; 8288c2ecf20Sopenharmony_ci dma_addr_t req_dma; 8298c2ecf20Sopenharmony_ci uint32_t req_len; 8308c2ecf20Sopenharmony_ci void *resp_buffer; 8318c2ecf20Sopenharmony_ci dma_addr_t resp_dma; 8328c2ecf20Sopenharmony_ci uint32_t resp_len; 8338c2ecf20Sopenharmony_ci struct iscsi_task *task; 8348c2ecf20Sopenharmony_ci struct passthru_status sts; 8358c2ecf20Sopenharmony_ci struct work_struct task_work; 8368c2ecf20Sopenharmony_ci}; 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_cistruct qla_endpoint { 8398c2ecf20Sopenharmony_ci struct Scsi_Host *host; 8408c2ecf20Sopenharmony_ci struct sockaddr_storage dst_addr; 8418c2ecf20Sopenharmony_ci}; 8428c2ecf20Sopenharmony_ci 8438c2ecf20Sopenharmony_cistruct qla_conn { 8448c2ecf20Sopenharmony_ci struct qla_endpoint *qla_ep; 8458c2ecf20Sopenharmony_ci}; 8468c2ecf20Sopenharmony_ci 8478c2ecf20Sopenharmony_cistatic inline int is_ipv4_enabled(struct scsi_qla_host *ha) 8488c2ecf20Sopenharmony_ci{ 8498c2ecf20Sopenharmony_ci return ((ha->ip_config.ipv4_options & IPOPT_IPV4_PROTOCOL_ENABLE) != 0); 8508c2ecf20Sopenharmony_ci} 8518c2ecf20Sopenharmony_ci 8528c2ecf20Sopenharmony_cistatic inline int is_ipv6_enabled(struct scsi_qla_host *ha) 8538c2ecf20Sopenharmony_ci{ 8548c2ecf20Sopenharmony_ci return ((ha->ip_config.ipv6_options & 8558c2ecf20Sopenharmony_ci IPV6_OPT_IPV6_PROTOCOL_ENABLE) != 0); 8568c2ecf20Sopenharmony_ci} 8578c2ecf20Sopenharmony_ci 8588c2ecf20Sopenharmony_cistatic inline int is_qla4010(struct scsi_qla_host *ha) 8598c2ecf20Sopenharmony_ci{ 8608c2ecf20Sopenharmony_ci return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4010; 8618c2ecf20Sopenharmony_ci} 8628c2ecf20Sopenharmony_ci 8638c2ecf20Sopenharmony_cistatic inline int is_qla4022(struct scsi_qla_host *ha) 8648c2ecf20Sopenharmony_ci{ 8658c2ecf20Sopenharmony_ci return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4022; 8668c2ecf20Sopenharmony_ci} 8678c2ecf20Sopenharmony_ci 8688c2ecf20Sopenharmony_cistatic inline int is_qla4032(struct scsi_qla_host *ha) 8698c2ecf20Sopenharmony_ci{ 8708c2ecf20Sopenharmony_ci return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4032; 8718c2ecf20Sopenharmony_ci} 8728c2ecf20Sopenharmony_ci 8738c2ecf20Sopenharmony_cistatic inline int is_qla40XX(struct scsi_qla_host *ha) 8748c2ecf20Sopenharmony_ci{ 8758c2ecf20Sopenharmony_ci return is_qla4032(ha) || is_qla4022(ha) || is_qla4010(ha); 8768c2ecf20Sopenharmony_ci} 8778c2ecf20Sopenharmony_ci 8788c2ecf20Sopenharmony_cistatic inline int is_qla8022(struct scsi_qla_host *ha) 8798c2ecf20Sopenharmony_ci{ 8808c2ecf20Sopenharmony_ci return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8022; 8818c2ecf20Sopenharmony_ci} 8828c2ecf20Sopenharmony_ci 8838c2ecf20Sopenharmony_cistatic inline int is_qla8032(struct scsi_qla_host *ha) 8848c2ecf20Sopenharmony_ci{ 8858c2ecf20Sopenharmony_ci return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8324; 8868c2ecf20Sopenharmony_ci} 8878c2ecf20Sopenharmony_ci 8888c2ecf20Sopenharmony_cistatic inline int is_qla8042(struct scsi_qla_host *ha) 8898c2ecf20Sopenharmony_ci{ 8908c2ecf20Sopenharmony_ci return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8042; 8918c2ecf20Sopenharmony_ci} 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_cistatic inline int is_qla80XX(struct scsi_qla_host *ha) 8948c2ecf20Sopenharmony_ci{ 8958c2ecf20Sopenharmony_ci return is_qla8022(ha) || is_qla8032(ha) || is_qla8042(ha); 8968c2ecf20Sopenharmony_ci} 8978c2ecf20Sopenharmony_ci 8988c2ecf20Sopenharmony_cistatic inline int is_aer_supported(struct scsi_qla_host *ha) 8998c2ecf20Sopenharmony_ci{ 9008c2ecf20Sopenharmony_ci return ((ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8022) || 9018c2ecf20Sopenharmony_ci (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8324) || 9028c2ecf20Sopenharmony_ci (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8042)); 9038c2ecf20Sopenharmony_ci} 9048c2ecf20Sopenharmony_ci 9058c2ecf20Sopenharmony_cistatic inline int adapter_up(struct scsi_qla_host *ha) 9068c2ecf20Sopenharmony_ci{ 9078c2ecf20Sopenharmony_ci return (test_bit(AF_ONLINE, &ha->flags) != 0) && 9088c2ecf20Sopenharmony_ci (test_bit(AF_LINK_UP, &ha->flags) != 0) && 9098c2ecf20Sopenharmony_ci (!test_bit(AF_LOOPBACK, &ha->flags)); 9108c2ecf20Sopenharmony_ci} 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_cistatic inline struct scsi_qla_host* to_qla_host(struct Scsi_Host *shost) 9138c2ecf20Sopenharmony_ci{ 9148c2ecf20Sopenharmony_ci return (struct scsi_qla_host *)iscsi_host_priv(shost); 9158c2ecf20Sopenharmony_ci} 9168c2ecf20Sopenharmony_ci 9178c2ecf20Sopenharmony_cistatic inline void __iomem* isp_semaphore(struct scsi_qla_host *ha) 9188c2ecf20Sopenharmony_ci{ 9198c2ecf20Sopenharmony_ci return (is_qla4010(ha) ? 9208c2ecf20Sopenharmony_ci &ha->reg->u1.isp4010.nvram : 9218c2ecf20Sopenharmony_ci &ha->reg->u1.isp4022.semaphore); 9228c2ecf20Sopenharmony_ci} 9238c2ecf20Sopenharmony_ci 9248c2ecf20Sopenharmony_cistatic inline void __iomem* isp_nvram(struct scsi_qla_host *ha) 9258c2ecf20Sopenharmony_ci{ 9268c2ecf20Sopenharmony_ci return (is_qla4010(ha) ? 9278c2ecf20Sopenharmony_ci &ha->reg->u1.isp4010.nvram : 9288c2ecf20Sopenharmony_ci &ha->reg->u1.isp4022.nvram); 9298c2ecf20Sopenharmony_ci} 9308c2ecf20Sopenharmony_ci 9318c2ecf20Sopenharmony_cistatic inline void __iomem* isp_ext_hw_conf(struct scsi_qla_host *ha) 9328c2ecf20Sopenharmony_ci{ 9338c2ecf20Sopenharmony_ci return (is_qla4010(ha) ? 9348c2ecf20Sopenharmony_ci &ha->reg->u2.isp4010.ext_hw_conf : 9358c2ecf20Sopenharmony_ci &ha->reg->u2.isp4022.p0.ext_hw_conf); 9368c2ecf20Sopenharmony_ci} 9378c2ecf20Sopenharmony_ci 9388c2ecf20Sopenharmony_cistatic inline void __iomem* isp_port_status(struct scsi_qla_host *ha) 9398c2ecf20Sopenharmony_ci{ 9408c2ecf20Sopenharmony_ci return (is_qla4010(ha) ? 9418c2ecf20Sopenharmony_ci &ha->reg->u2.isp4010.port_status : 9428c2ecf20Sopenharmony_ci &ha->reg->u2.isp4022.p0.port_status); 9438c2ecf20Sopenharmony_ci} 9448c2ecf20Sopenharmony_ci 9458c2ecf20Sopenharmony_cistatic inline void __iomem* isp_port_ctrl(struct scsi_qla_host *ha) 9468c2ecf20Sopenharmony_ci{ 9478c2ecf20Sopenharmony_ci return (is_qla4010(ha) ? 9488c2ecf20Sopenharmony_ci &ha->reg->u2.isp4010.port_ctrl : 9498c2ecf20Sopenharmony_ci &ha->reg->u2.isp4022.p0.port_ctrl); 9508c2ecf20Sopenharmony_ci} 9518c2ecf20Sopenharmony_ci 9528c2ecf20Sopenharmony_cistatic inline void __iomem* isp_port_error_status(struct scsi_qla_host *ha) 9538c2ecf20Sopenharmony_ci{ 9548c2ecf20Sopenharmony_ci return (is_qla4010(ha) ? 9558c2ecf20Sopenharmony_ci &ha->reg->u2.isp4010.port_err_status : 9568c2ecf20Sopenharmony_ci &ha->reg->u2.isp4022.p0.port_err_status); 9578c2ecf20Sopenharmony_ci} 9588c2ecf20Sopenharmony_ci 9598c2ecf20Sopenharmony_cistatic inline void __iomem * isp_gp_out(struct scsi_qla_host *ha) 9608c2ecf20Sopenharmony_ci{ 9618c2ecf20Sopenharmony_ci return (is_qla4010(ha) ? 9628c2ecf20Sopenharmony_ci &ha->reg->u2.isp4010.gp_out : 9638c2ecf20Sopenharmony_ci &ha->reg->u2.isp4022.p0.gp_out); 9648c2ecf20Sopenharmony_ci} 9658c2ecf20Sopenharmony_ci 9668c2ecf20Sopenharmony_cistatic inline int eeprom_ext_hw_conf_offset(struct scsi_qla_host *ha) 9678c2ecf20Sopenharmony_ci{ 9688c2ecf20Sopenharmony_ci return (is_qla4010(ha) ? 9698c2ecf20Sopenharmony_ci offsetof(struct eeprom_data, isp4010.ext_hw_conf) / 2 : 9708c2ecf20Sopenharmony_ci offsetof(struct eeprom_data, isp4022.ext_hw_conf) / 2); 9718c2ecf20Sopenharmony_ci} 9728c2ecf20Sopenharmony_ci 9738c2ecf20Sopenharmony_ciint ql4xxx_sem_spinlock(struct scsi_qla_host * ha, u32 sem_mask, u32 sem_bits); 9748c2ecf20Sopenharmony_civoid ql4xxx_sem_unlock(struct scsi_qla_host * ha, u32 sem_mask); 9758c2ecf20Sopenharmony_ciint ql4xxx_sem_lock(struct scsi_qla_host * ha, u32 sem_mask, u32 sem_bits); 9768c2ecf20Sopenharmony_ci 9778c2ecf20Sopenharmony_cistatic inline int ql4xxx_lock_flash(struct scsi_qla_host *a) 9788c2ecf20Sopenharmony_ci{ 9798c2ecf20Sopenharmony_ci if (is_qla4010(a)) 9808c2ecf20Sopenharmony_ci return ql4xxx_sem_spinlock(a, QL4010_FLASH_SEM_MASK, 9818c2ecf20Sopenharmony_ci QL4010_FLASH_SEM_BITS); 9828c2ecf20Sopenharmony_ci else 9838c2ecf20Sopenharmony_ci return ql4xxx_sem_spinlock(a, QL4022_FLASH_SEM_MASK, 9848c2ecf20Sopenharmony_ci (QL4022_RESOURCE_BITS_BASE_CODE | 9858c2ecf20Sopenharmony_ci (a->mac_index)) << 13); 9868c2ecf20Sopenharmony_ci} 9878c2ecf20Sopenharmony_ci 9888c2ecf20Sopenharmony_cistatic inline void ql4xxx_unlock_flash(struct scsi_qla_host *a) 9898c2ecf20Sopenharmony_ci{ 9908c2ecf20Sopenharmony_ci if (is_qla4010(a)) 9918c2ecf20Sopenharmony_ci ql4xxx_sem_unlock(a, QL4010_FLASH_SEM_MASK); 9928c2ecf20Sopenharmony_ci else 9938c2ecf20Sopenharmony_ci ql4xxx_sem_unlock(a, QL4022_FLASH_SEM_MASK); 9948c2ecf20Sopenharmony_ci} 9958c2ecf20Sopenharmony_ci 9968c2ecf20Sopenharmony_cistatic inline int ql4xxx_lock_nvram(struct scsi_qla_host *a) 9978c2ecf20Sopenharmony_ci{ 9988c2ecf20Sopenharmony_ci if (is_qla4010(a)) 9998c2ecf20Sopenharmony_ci return ql4xxx_sem_spinlock(a, QL4010_NVRAM_SEM_MASK, 10008c2ecf20Sopenharmony_ci QL4010_NVRAM_SEM_BITS); 10018c2ecf20Sopenharmony_ci else 10028c2ecf20Sopenharmony_ci return ql4xxx_sem_spinlock(a, QL4022_NVRAM_SEM_MASK, 10038c2ecf20Sopenharmony_ci (QL4022_RESOURCE_BITS_BASE_CODE | 10048c2ecf20Sopenharmony_ci (a->mac_index)) << 10); 10058c2ecf20Sopenharmony_ci} 10068c2ecf20Sopenharmony_ci 10078c2ecf20Sopenharmony_cistatic inline void ql4xxx_unlock_nvram(struct scsi_qla_host *a) 10088c2ecf20Sopenharmony_ci{ 10098c2ecf20Sopenharmony_ci if (is_qla4010(a)) 10108c2ecf20Sopenharmony_ci ql4xxx_sem_unlock(a, QL4010_NVRAM_SEM_MASK); 10118c2ecf20Sopenharmony_ci else 10128c2ecf20Sopenharmony_ci ql4xxx_sem_unlock(a, QL4022_NVRAM_SEM_MASK); 10138c2ecf20Sopenharmony_ci} 10148c2ecf20Sopenharmony_ci 10158c2ecf20Sopenharmony_cistatic inline int ql4xxx_lock_drvr(struct scsi_qla_host *a) 10168c2ecf20Sopenharmony_ci{ 10178c2ecf20Sopenharmony_ci if (is_qla4010(a)) 10188c2ecf20Sopenharmony_ci return ql4xxx_sem_lock(a, QL4010_DRVR_SEM_MASK, 10198c2ecf20Sopenharmony_ci QL4010_DRVR_SEM_BITS); 10208c2ecf20Sopenharmony_ci else 10218c2ecf20Sopenharmony_ci return ql4xxx_sem_lock(a, QL4022_DRVR_SEM_MASK, 10228c2ecf20Sopenharmony_ci (QL4022_RESOURCE_BITS_BASE_CODE | 10238c2ecf20Sopenharmony_ci (a->mac_index)) << 1); 10248c2ecf20Sopenharmony_ci} 10258c2ecf20Sopenharmony_ci 10268c2ecf20Sopenharmony_cistatic inline void ql4xxx_unlock_drvr(struct scsi_qla_host *a) 10278c2ecf20Sopenharmony_ci{ 10288c2ecf20Sopenharmony_ci if (is_qla4010(a)) 10298c2ecf20Sopenharmony_ci ql4xxx_sem_unlock(a, QL4010_DRVR_SEM_MASK); 10308c2ecf20Sopenharmony_ci else 10318c2ecf20Sopenharmony_ci ql4xxx_sem_unlock(a, QL4022_DRVR_SEM_MASK); 10328c2ecf20Sopenharmony_ci} 10338c2ecf20Sopenharmony_ci 10348c2ecf20Sopenharmony_cistatic inline int ql4xxx_reset_active(struct scsi_qla_host *ha) 10358c2ecf20Sopenharmony_ci{ 10368c2ecf20Sopenharmony_ci return test_bit(DPC_RESET_ACTIVE, &ha->dpc_flags) || 10378c2ecf20Sopenharmony_ci test_bit(DPC_RESET_HA, &ha->dpc_flags) || 10388c2ecf20Sopenharmony_ci test_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags) || 10398c2ecf20Sopenharmony_ci test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) || 10408c2ecf20Sopenharmony_ci test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags) || 10418c2ecf20Sopenharmony_ci test_bit(DPC_HA_UNRECOVERABLE, &ha->dpc_flags); 10428c2ecf20Sopenharmony_ci 10438c2ecf20Sopenharmony_ci} 10448c2ecf20Sopenharmony_ci 10458c2ecf20Sopenharmony_cistatic inline int qla4_8xxx_rd_direct(struct scsi_qla_host *ha, 10468c2ecf20Sopenharmony_ci const uint32_t crb_reg) 10478c2ecf20Sopenharmony_ci{ 10488c2ecf20Sopenharmony_ci return ha->isp_ops->rd_reg_direct(ha, ha->reg_tbl[crb_reg]); 10498c2ecf20Sopenharmony_ci} 10508c2ecf20Sopenharmony_ci 10518c2ecf20Sopenharmony_cistatic inline void qla4_8xxx_wr_direct(struct scsi_qla_host *ha, 10528c2ecf20Sopenharmony_ci const uint32_t crb_reg, 10538c2ecf20Sopenharmony_ci const uint32_t value) 10548c2ecf20Sopenharmony_ci{ 10558c2ecf20Sopenharmony_ci ha->isp_ops->wr_reg_direct(ha, ha->reg_tbl[crb_reg], value); 10568c2ecf20Sopenharmony_ci} 10578c2ecf20Sopenharmony_ci 10588c2ecf20Sopenharmony_ci/*---------------------------------------------------------------------------*/ 10598c2ecf20Sopenharmony_ci 10608c2ecf20Sopenharmony_ci/* Defines for qla4xxx_initialize_adapter() and qla4xxx_recover_adapter() */ 10618c2ecf20Sopenharmony_ci 10628c2ecf20Sopenharmony_ci#define INIT_ADAPTER 0 10638c2ecf20Sopenharmony_ci#define RESET_ADAPTER 1 10648c2ecf20Sopenharmony_ci 10658c2ecf20Sopenharmony_ci#define PRESERVE_DDB_LIST 0 10668c2ecf20Sopenharmony_ci#define REBUILD_DDB_LIST 1 10678c2ecf20Sopenharmony_ci 10688c2ecf20Sopenharmony_ci/* Defines for process_aen() */ 10698c2ecf20Sopenharmony_ci#define PROCESS_ALL_AENS 0 10708c2ecf20Sopenharmony_ci#define FLUSH_DDB_CHANGED_AENS 1 10718c2ecf20Sopenharmony_ci 10728c2ecf20Sopenharmony_ci/* Defines for udev events */ 10738c2ecf20Sopenharmony_ci#define QL4_UEVENT_CODE_FW_DUMP 0 10748c2ecf20Sopenharmony_ci 10758c2ecf20Sopenharmony_ci#endif /*_QLA4XXX_H */ 1076