18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * ibmvfc.h -- driver for IBM Power Virtual Fibre Channel Adapter 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Written By: Brian King <brking@linux.vnet.ibm.com>, IBM Corporation 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (C) IBM Corporation, 2008 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef _IBMVFC_H 118c2ecf20Sopenharmony_ci#define _IBMVFC_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/list.h> 148c2ecf20Sopenharmony_ci#include <linux/types.h> 158c2ecf20Sopenharmony_ci#include <scsi/viosrp.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define IBMVFC_NAME "ibmvfc" 188c2ecf20Sopenharmony_ci#define IBMVFC_DRIVER_VERSION "1.0.11" 198c2ecf20Sopenharmony_ci#define IBMVFC_DRIVER_DATE "(April 12, 2013)" 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define IBMVFC_DEFAULT_TIMEOUT 60 228c2ecf20Sopenharmony_ci#define IBMVFC_ADISC_CANCEL_TIMEOUT 45 238c2ecf20Sopenharmony_ci#define IBMVFC_ADISC_TIMEOUT 15 248c2ecf20Sopenharmony_ci#define IBMVFC_ADISC_PLUS_CANCEL_TIMEOUT \ 258c2ecf20Sopenharmony_ci (IBMVFC_ADISC_TIMEOUT + IBMVFC_ADISC_CANCEL_TIMEOUT) 268c2ecf20Sopenharmony_ci#define IBMVFC_INIT_TIMEOUT 120 278c2ecf20Sopenharmony_ci#define IBMVFC_ABORT_TIMEOUT 8 288c2ecf20Sopenharmony_ci#define IBMVFC_ABORT_WAIT_TIMEOUT 40 298c2ecf20Sopenharmony_ci#define IBMVFC_MAX_REQUESTS_DEFAULT 100 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define IBMVFC_DEBUG 0 328c2ecf20Sopenharmony_ci#define IBMVFC_MAX_TARGETS 1024 338c2ecf20Sopenharmony_ci#define IBMVFC_MAX_LUN 0xffffffff 348c2ecf20Sopenharmony_ci#define IBMVFC_MAX_SECTORS 0xffffu 358c2ecf20Sopenharmony_ci#define IBMVFC_MAX_DISC_THREADS 4 368c2ecf20Sopenharmony_ci#define IBMVFC_TGT_MEMPOOL_SZ 64 378c2ecf20Sopenharmony_ci#define IBMVFC_MAX_CMDS_PER_LUN 64 388c2ecf20Sopenharmony_ci#define IBMVFC_MAX_HOST_INIT_RETRIES 6 398c2ecf20Sopenharmony_ci#define IBMVFC_MAX_TGT_INIT_RETRIES 3 408c2ecf20Sopenharmony_ci#define IBMVFC_DEV_LOSS_TMO (5 * 60) 418c2ecf20Sopenharmony_ci#define IBMVFC_DEFAULT_LOG_LEVEL 2 428c2ecf20Sopenharmony_ci#define IBMVFC_MAX_CDB_LEN 16 438c2ecf20Sopenharmony_ci#define IBMVFC_CLS3_ERROR 0 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* 468c2ecf20Sopenharmony_ci * Ensure we have resources for ERP and initialization: 478c2ecf20Sopenharmony_ci * 1 for ERP 488c2ecf20Sopenharmony_ci * 1 for initialization 498c2ecf20Sopenharmony_ci * 1 for NPIV Logout 508c2ecf20Sopenharmony_ci * 2 for BSG passthru 518c2ecf20Sopenharmony_ci * 2 for each discovery thread 528c2ecf20Sopenharmony_ci */ 538c2ecf20Sopenharmony_ci#define IBMVFC_NUM_INTERNAL_REQ (1 + 1 + 1 + 2 + (disc_threads * 2)) 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define IBMVFC_MAD_SUCCESS 0x00 568c2ecf20Sopenharmony_ci#define IBMVFC_MAD_NOT_SUPPORTED 0xF1 578c2ecf20Sopenharmony_ci#define IBMVFC_MAD_FAILED 0xF7 588c2ecf20Sopenharmony_ci#define IBMVFC_MAD_DRIVER_FAILED 0xEE 598c2ecf20Sopenharmony_ci#define IBMVFC_MAD_CRQ_ERROR 0xEF 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cienum ibmvfc_crq_valid { 628c2ecf20Sopenharmony_ci IBMVFC_CRQ_CMD_RSP = 0x80, 638c2ecf20Sopenharmony_ci IBMVFC_CRQ_INIT_RSP = 0xC0, 648c2ecf20Sopenharmony_ci IBMVFC_CRQ_XPORT_EVENT = 0xFF, 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cienum ibmvfc_crq_init_msg { 688c2ecf20Sopenharmony_ci IBMVFC_CRQ_INIT = 0x01, 698c2ecf20Sopenharmony_ci IBMVFC_CRQ_INIT_COMPLETE = 0x02, 708c2ecf20Sopenharmony_ci}; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_cienum ibmvfc_crq_xport_evts { 738c2ecf20Sopenharmony_ci IBMVFC_PARTNER_FAILED = 0x01, 748c2ecf20Sopenharmony_ci IBMVFC_PARTNER_DEREGISTER = 0x02, 758c2ecf20Sopenharmony_ci IBMVFC_PARTITION_MIGRATED = 0x06, 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cienum ibmvfc_cmd_status_flags { 798c2ecf20Sopenharmony_ci IBMVFC_FABRIC_MAPPED = 0x0001, 808c2ecf20Sopenharmony_ci IBMVFC_VIOS_FAILURE = 0x0002, 818c2ecf20Sopenharmony_ci IBMVFC_FC_FAILURE = 0x0004, 828c2ecf20Sopenharmony_ci IBMVFC_FC_SCSI_ERROR = 0x0008, 838c2ecf20Sopenharmony_ci IBMVFC_HW_EVENT_LOGGED = 0x0010, 848c2ecf20Sopenharmony_ci IBMVFC_VIOS_LOGGED = 0x0020, 858c2ecf20Sopenharmony_ci}; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_cienum ibmvfc_fabric_mapped_errors { 888c2ecf20Sopenharmony_ci IBMVFC_UNABLE_TO_ESTABLISH = 0x0001, 898c2ecf20Sopenharmony_ci IBMVFC_XPORT_FAULT = 0x0002, 908c2ecf20Sopenharmony_ci IBMVFC_CMD_TIMEOUT = 0x0003, 918c2ecf20Sopenharmony_ci IBMVFC_ENETDOWN = 0x0004, 928c2ecf20Sopenharmony_ci IBMVFC_HW_FAILURE = 0x0005, 938c2ecf20Sopenharmony_ci IBMVFC_LINK_DOWN_ERR = 0x0006, 948c2ecf20Sopenharmony_ci IBMVFC_LINK_DEAD_ERR = 0x0007, 958c2ecf20Sopenharmony_ci IBMVFC_UNABLE_TO_REGISTER = 0x0008, 968c2ecf20Sopenharmony_ci IBMVFC_XPORT_BUSY = 0x000A, 978c2ecf20Sopenharmony_ci IBMVFC_XPORT_DEAD = 0x000B, 988c2ecf20Sopenharmony_ci IBMVFC_CONFIG_ERROR = 0x000C, 998c2ecf20Sopenharmony_ci IBMVFC_NAME_SERVER_FAIL = 0x000D, 1008c2ecf20Sopenharmony_ci IBMVFC_LINK_HALTED = 0x000E, 1018c2ecf20Sopenharmony_ci IBMVFC_XPORT_GENERAL = 0x8000, 1028c2ecf20Sopenharmony_ci}; 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cienum ibmvfc_vios_errors { 1058c2ecf20Sopenharmony_ci IBMVFC_CRQ_FAILURE = 0x0001, 1068c2ecf20Sopenharmony_ci IBMVFC_SW_FAILURE = 0x0002, 1078c2ecf20Sopenharmony_ci IBMVFC_INVALID_PARAMETER = 0x0003, 1088c2ecf20Sopenharmony_ci IBMVFC_MISSING_PARAMETER = 0x0004, 1098c2ecf20Sopenharmony_ci IBMVFC_HOST_IO_BUS = 0x0005, 1108c2ecf20Sopenharmony_ci IBMVFC_TRANS_CANCELLED = 0x0006, 1118c2ecf20Sopenharmony_ci IBMVFC_TRANS_CANCELLED_IMPLICIT = 0x0007, 1128c2ecf20Sopenharmony_ci IBMVFC_INSUFFICIENT_RESOURCE = 0x0008, 1138c2ecf20Sopenharmony_ci IBMVFC_PLOGI_REQUIRED = 0x0010, 1148c2ecf20Sopenharmony_ci IBMVFC_COMMAND_FAILED = 0x8000, 1158c2ecf20Sopenharmony_ci}; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_cienum ibmvfc_mad_types { 1188c2ecf20Sopenharmony_ci IBMVFC_NPIV_LOGIN = 0x0001, 1198c2ecf20Sopenharmony_ci IBMVFC_DISC_TARGETS = 0x0002, 1208c2ecf20Sopenharmony_ci IBMVFC_PORT_LOGIN = 0x0004, 1218c2ecf20Sopenharmony_ci IBMVFC_PROCESS_LOGIN = 0x0008, 1228c2ecf20Sopenharmony_ci IBMVFC_QUERY_TARGET = 0x0010, 1238c2ecf20Sopenharmony_ci IBMVFC_MOVE_LOGIN = 0x0020, 1248c2ecf20Sopenharmony_ci IBMVFC_IMPLICIT_LOGOUT = 0x0040, 1258c2ecf20Sopenharmony_ci IBMVFC_PASSTHRU = 0x0200, 1268c2ecf20Sopenharmony_ci IBMVFC_TMF_MAD = 0x0100, 1278c2ecf20Sopenharmony_ci IBMVFC_NPIV_LOGOUT = 0x0800, 1288c2ecf20Sopenharmony_ci IBMVFC_CHANNEL_ENQUIRY = 0x1000, 1298c2ecf20Sopenharmony_ci IBMVFC_CHANNEL_SETUP = 0x2000, 1308c2ecf20Sopenharmony_ci IBMVFC_CONNECTION_INFO = 0x4000, 1318c2ecf20Sopenharmony_ci}; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_cistruct ibmvfc_mad_common { 1348c2ecf20Sopenharmony_ci __be32 version; 1358c2ecf20Sopenharmony_ci __be32 reserved; 1368c2ecf20Sopenharmony_ci __be32 opcode; 1378c2ecf20Sopenharmony_ci __be16 status; 1388c2ecf20Sopenharmony_ci __be16 length; 1398c2ecf20Sopenharmony_ci __be64 tag; 1408c2ecf20Sopenharmony_ci} __packed __aligned(8); 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_cistruct ibmvfc_npiv_login_mad { 1438c2ecf20Sopenharmony_ci struct ibmvfc_mad_common common; 1448c2ecf20Sopenharmony_ci struct srp_direct_buf buffer; 1458c2ecf20Sopenharmony_ci} __packed __aligned(8); 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_cistruct ibmvfc_npiv_logout_mad { 1488c2ecf20Sopenharmony_ci struct ibmvfc_mad_common common; 1498c2ecf20Sopenharmony_ci} __packed __aligned(8); 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci#define IBMVFC_MAX_NAME 256 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_cistruct ibmvfc_npiv_login { 1548c2ecf20Sopenharmony_ci __be32 ostype; 1558c2ecf20Sopenharmony_ci#define IBMVFC_OS_LINUX 0x02 1568c2ecf20Sopenharmony_ci __be32 pad; 1578c2ecf20Sopenharmony_ci __be64 max_dma_len; 1588c2ecf20Sopenharmony_ci __be32 max_payload; 1598c2ecf20Sopenharmony_ci __be32 max_response; 1608c2ecf20Sopenharmony_ci __be32 partition_num; 1618c2ecf20Sopenharmony_ci __be32 vfc_frame_version; 1628c2ecf20Sopenharmony_ci __be16 fcp_version; 1638c2ecf20Sopenharmony_ci __be16 flags; 1648c2ecf20Sopenharmony_ci#define IBMVFC_CLIENT_MIGRATED 0x01 1658c2ecf20Sopenharmony_ci#define IBMVFC_FLUSH_ON_HALT 0x02 1668c2ecf20Sopenharmony_ci __be32 max_cmds; 1678c2ecf20Sopenharmony_ci __be64 capabilities; 1688c2ecf20Sopenharmony_ci#define IBMVFC_CAN_MIGRATE 0x01 1698c2ecf20Sopenharmony_ci#define IBMVFC_CAN_USE_CHANNELS 0x02 1708c2ecf20Sopenharmony_ci#define IBMVFC_CAN_HANDLE_FPIN 0x04 1718c2ecf20Sopenharmony_ci __be64 node_name; 1728c2ecf20Sopenharmony_ci struct srp_direct_buf async; 1738c2ecf20Sopenharmony_ci u8 partition_name[IBMVFC_MAX_NAME]; 1748c2ecf20Sopenharmony_ci u8 device_name[IBMVFC_MAX_NAME]; 1758c2ecf20Sopenharmony_ci u8 drc_name[IBMVFC_MAX_NAME]; 1768c2ecf20Sopenharmony_ci __be64 reserved2[2]; 1778c2ecf20Sopenharmony_ci} __packed __aligned(8); 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_cistruct ibmvfc_common_svc_parms { 1808c2ecf20Sopenharmony_ci __be16 fcph_version; 1818c2ecf20Sopenharmony_ci __be16 b2b_credit; 1828c2ecf20Sopenharmony_ci __be16 features; 1838c2ecf20Sopenharmony_ci __be16 bb_rcv_sz; /* upper nibble is BB_SC_N */ 1848c2ecf20Sopenharmony_ci __be32 ratov; 1858c2ecf20Sopenharmony_ci __be32 edtov; 1868c2ecf20Sopenharmony_ci} __packed __aligned(4); 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_cistruct ibmvfc_service_parms { 1898c2ecf20Sopenharmony_ci struct ibmvfc_common_svc_parms common; 1908c2ecf20Sopenharmony_ci u8 port_name[8]; 1918c2ecf20Sopenharmony_ci u8 node_name[8]; 1928c2ecf20Sopenharmony_ci __be32 class1_parms[4]; 1938c2ecf20Sopenharmony_ci __be32 class2_parms[4]; 1948c2ecf20Sopenharmony_ci __be32 class3_parms[4]; 1958c2ecf20Sopenharmony_ci __be32 obsolete[4]; 1968c2ecf20Sopenharmony_ci __be32 vendor_version[4]; 1978c2ecf20Sopenharmony_ci __be32 services_avail[2]; 1988c2ecf20Sopenharmony_ci __be32 ext_len; 1998c2ecf20Sopenharmony_ci __be32 reserved[30]; 2008c2ecf20Sopenharmony_ci __be32 clk_sync_qos[2]; 2018c2ecf20Sopenharmony_ci __be32 reserved2; 2028c2ecf20Sopenharmony_ci} __packed __aligned(4); 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_cistruct ibmvfc_npiv_login_resp { 2058c2ecf20Sopenharmony_ci __be32 version; 2068c2ecf20Sopenharmony_ci __be16 status; 2078c2ecf20Sopenharmony_ci __be16 error; 2088c2ecf20Sopenharmony_ci __be32 flags; 2098c2ecf20Sopenharmony_ci#define IBMVFC_NATIVE_FC 0x01 2108c2ecf20Sopenharmony_ci __be32 reserved; 2118c2ecf20Sopenharmony_ci __be64 capabilities; 2128c2ecf20Sopenharmony_ci#define IBMVFC_CAN_FLUSH_ON_HALT 0x08 2138c2ecf20Sopenharmony_ci#define IBMVFC_CAN_SUPPRESS_ABTS 0x10 2148c2ecf20Sopenharmony_ci#define IBMVFC_CAN_SUPPORT_CHANNELS 0x20 2158c2ecf20Sopenharmony_ci __be32 max_cmds; 2168c2ecf20Sopenharmony_ci __be32 scsi_id_sz; 2178c2ecf20Sopenharmony_ci __be64 max_dma_len; 2188c2ecf20Sopenharmony_ci __be64 scsi_id; 2198c2ecf20Sopenharmony_ci __be64 port_name; 2208c2ecf20Sopenharmony_ci __be64 node_name; 2218c2ecf20Sopenharmony_ci __be64 link_speed; 2228c2ecf20Sopenharmony_ci u8 partition_name[IBMVFC_MAX_NAME]; 2238c2ecf20Sopenharmony_ci u8 device_name[IBMVFC_MAX_NAME]; 2248c2ecf20Sopenharmony_ci u8 port_loc_code[IBMVFC_MAX_NAME]; 2258c2ecf20Sopenharmony_ci u8 drc_name[IBMVFC_MAX_NAME]; 2268c2ecf20Sopenharmony_ci struct ibmvfc_service_parms service_parms; 2278c2ecf20Sopenharmony_ci __be64 reserved2; 2288c2ecf20Sopenharmony_ci} __packed __aligned(8); 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ciunion ibmvfc_npiv_login_data { 2318c2ecf20Sopenharmony_ci struct ibmvfc_npiv_login login; 2328c2ecf20Sopenharmony_ci struct ibmvfc_npiv_login_resp resp; 2338c2ecf20Sopenharmony_ci} __packed __aligned(8); 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_cistruct ibmvfc_discover_targets_entry { 2368c2ecf20Sopenharmony_ci __be32 scsi_id; 2378c2ecf20Sopenharmony_ci __be32 pad; 2388c2ecf20Sopenharmony_ci __be64 wwpn; 2398c2ecf20Sopenharmony_ci#define IBMVFC_DISC_TGT_SCSI_ID_MASK 0x00ffffff 2408c2ecf20Sopenharmony_ci} __packed __aligned(8); 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_cistruct ibmvfc_discover_targets { 2438c2ecf20Sopenharmony_ci struct ibmvfc_mad_common common; 2448c2ecf20Sopenharmony_ci struct srp_direct_buf buffer; 2458c2ecf20Sopenharmony_ci __be32 flags; 2468c2ecf20Sopenharmony_ci#define IBMVFC_DISC_TGT_PORT_ID_WWPN_LIST 0x02 2478c2ecf20Sopenharmony_ci __be16 status; 2488c2ecf20Sopenharmony_ci __be16 error; 2498c2ecf20Sopenharmony_ci __be32 bufflen; 2508c2ecf20Sopenharmony_ci __be32 num_avail; 2518c2ecf20Sopenharmony_ci __be32 num_written; 2528c2ecf20Sopenharmony_ci __be64 reserved[2]; 2538c2ecf20Sopenharmony_ci} __packed __aligned(8); 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_cienum ibmvfc_fc_reason { 2568c2ecf20Sopenharmony_ci IBMVFC_INVALID_ELS_CMD_CODE = 0x01, 2578c2ecf20Sopenharmony_ci IBMVFC_INVALID_VERSION = 0x02, 2588c2ecf20Sopenharmony_ci IBMVFC_LOGICAL_ERROR = 0x03, 2598c2ecf20Sopenharmony_ci IBMVFC_INVALID_CT_IU_SIZE = 0x04, 2608c2ecf20Sopenharmony_ci IBMVFC_LOGICAL_BUSY = 0x05, 2618c2ecf20Sopenharmony_ci IBMVFC_PROTOCOL_ERROR = 0x07, 2628c2ecf20Sopenharmony_ci IBMVFC_UNABLE_TO_PERFORM_REQ = 0x09, 2638c2ecf20Sopenharmony_ci IBMVFC_CMD_NOT_SUPPORTED = 0x0B, 2648c2ecf20Sopenharmony_ci IBMVFC_SERVER_NOT_AVAIL = 0x0D, 2658c2ecf20Sopenharmony_ci IBMVFC_CMD_IN_PROGRESS = 0x0E, 2668c2ecf20Sopenharmony_ci IBMVFC_VENDOR_SPECIFIC = 0xFF, 2678c2ecf20Sopenharmony_ci}; 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_cienum ibmvfc_fc_type { 2708c2ecf20Sopenharmony_ci IBMVFC_FABRIC_REJECT = 0x01, 2718c2ecf20Sopenharmony_ci IBMVFC_PORT_REJECT = 0x02, 2728c2ecf20Sopenharmony_ci IBMVFC_LS_REJECT = 0x03, 2738c2ecf20Sopenharmony_ci IBMVFC_FABRIC_BUSY = 0x04, 2748c2ecf20Sopenharmony_ci IBMVFC_PORT_BUSY = 0x05, 2758c2ecf20Sopenharmony_ci IBMVFC_BASIC_REJECT = 0x06, 2768c2ecf20Sopenharmony_ci}; 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_cienum ibmvfc_gs_explain { 2798c2ecf20Sopenharmony_ci IBMVFC_PORT_NAME_NOT_REG = 0x02, 2808c2ecf20Sopenharmony_ci}; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_cistruct ibmvfc_port_login { 2838c2ecf20Sopenharmony_ci struct ibmvfc_mad_common common; 2848c2ecf20Sopenharmony_ci __be64 scsi_id; 2858c2ecf20Sopenharmony_ci __be16 reserved; 2868c2ecf20Sopenharmony_ci __be16 fc_service_class; 2878c2ecf20Sopenharmony_ci __be32 blksz; 2888c2ecf20Sopenharmony_ci __be32 hdr_per_blk; 2898c2ecf20Sopenharmony_ci __be16 status; 2908c2ecf20Sopenharmony_ci __be16 error; /* also fc_reason */ 2918c2ecf20Sopenharmony_ci __be16 fc_explain; 2928c2ecf20Sopenharmony_ci __be16 fc_type; 2938c2ecf20Sopenharmony_ci __be32 reserved2; 2948c2ecf20Sopenharmony_ci struct ibmvfc_service_parms service_parms; 2958c2ecf20Sopenharmony_ci struct ibmvfc_service_parms service_parms_change; 2968c2ecf20Sopenharmony_ci __be64 reserved3[2]; 2978c2ecf20Sopenharmony_ci} __packed __aligned(8); 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_cistruct ibmvfc_move_login { 3008c2ecf20Sopenharmony_ci struct ibmvfc_mad_common common; 3018c2ecf20Sopenharmony_ci __be64 old_scsi_id; 3028c2ecf20Sopenharmony_ci __be64 new_scsi_id; 3038c2ecf20Sopenharmony_ci __be64 wwpn; 3048c2ecf20Sopenharmony_ci __be64 node_name; 3058c2ecf20Sopenharmony_ci __be32 flags; 3068c2ecf20Sopenharmony_ci#define IBMVFC_MOVE_LOGIN_IMPLICIT_OLD_FAILED 0x01 3078c2ecf20Sopenharmony_ci#define IBMVFC_MOVE_LOGIN_IMPLICIT_NEW_FAILED 0x02 3088c2ecf20Sopenharmony_ci#define IBMVFC_MOVE_LOGIN_PORT_LOGIN_FAILED 0x04 3098c2ecf20Sopenharmony_ci __be32 reserved; 3108c2ecf20Sopenharmony_ci struct ibmvfc_service_parms service_parms; 3118c2ecf20Sopenharmony_ci struct ibmvfc_service_parms service_parms_change; 3128c2ecf20Sopenharmony_ci __be32 reserved2; 3138c2ecf20Sopenharmony_ci __be16 service_class; 3148c2ecf20Sopenharmony_ci __be16 vios_flags; 3158c2ecf20Sopenharmony_ci#define IBMVFC_MOVE_LOGIN_VF_NOT_SENT_ADAPTER 0x01 3168c2ecf20Sopenharmony_ci __be64 reserved3; 3178c2ecf20Sopenharmony_ci} __packed __aligned(8); 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_cistruct ibmvfc_prli_svc_parms { 3208c2ecf20Sopenharmony_ci u8 type; 3218c2ecf20Sopenharmony_ci#define IBMVFC_SCSI_FCP_TYPE 0x08 3228c2ecf20Sopenharmony_ci u8 type_ext; 3238c2ecf20Sopenharmony_ci __be16 flags; 3248c2ecf20Sopenharmony_ci#define IBMVFC_PRLI_ORIG_PA_VALID 0x8000 3258c2ecf20Sopenharmony_ci#define IBMVFC_PRLI_RESP_PA_VALID 0x4000 3268c2ecf20Sopenharmony_ci#define IBMVFC_PRLI_EST_IMG_PAIR 0x2000 3278c2ecf20Sopenharmony_ci __be32 orig_pa; 3288c2ecf20Sopenharmony_ci __be32 resp_pa; 3298c2ecf20Sopenharmony_ci __be32 service_parms; 3308c2ecf20Sopenharmony_ci#define IBMVFC_PRLI_TASK_RETRY 0x00000200 3318c2ecf20Sopenharmony_ci#define IBMVFC_PRLI_RETRY 0x00000100 3328c2ecf20Sopenharmony_ci#define IBMVFC_PRLI_DATA_OVERLAY 0x00000040 3338c2ecf20Sopenharmony_ci#define IBMVFC_PRLI_INITIATOR_FUNC 0x00000020 3348c2ecf20Sopenharmony_ci#define IBMVFC_PRLI_TARGET_FUNC 0x00000010 3358c2ecf20Sopenharmony_ci#define IBMVFC_PRLI_READ_FCP_XFER_RDY_DISABLED 0x00000002 3368c2ecf20Sopenharmony_ci#define IBMVFC_PRLI_WR_FCP_XFER_RDY_DISABLED 0x00000001 3378c2ecf20Sopenharmony_ci} __packed __aligned(4); 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_cistruct ibmvfc_process_login { 3408c2ecf20Sopenharmony_ci struct ibmvfc_mad_common common; 3418c2ecf20Sopenharmony_ci __be64 scsi_id; 3428c2ecf20Sopenharmony_ci struct ibmvfc_prli_svc_parms parms; 3438c2ecf20Sopenharmony_ci u8 reserved[48]; 3448c2ecf20Sopenharmony_ci __be16 status; 3458c2ecf20Sopenharmony_ci __be16 error; /* also fc_reason */ 3468c2ecf20Sopenharmony_ci __be32 reserved2; 3478c2ecf20Sopenharmony_ci __be64 reserved3[2]; 3488c2ecf20Sopenharmony_ci} __packed __aligned(8); 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_cistruct ibmvfc_query_tgt { 3518c2ecf20Sopenharmony_ci struct ibmvfc_mad_common common; 3528c2ecf20Sopenharmony_ci __be64 wwpn; 3538c2ecf20Sopenharmony_ci __be64 scsi_id; 3548c2ecf20Sopenharmony_ci __be16 status; 3558c2ecf20Sopenharmony_ci __be16 error; 3568c2ecf20Sopenharmony_ci __be16 fc_explain; 3578c2ecf20Sopenharmony_ci __be16 fc_type; 3588c2ecf20Sopenharmony_ci __be64 reserved[2]; 3598c2ecf20Sopenharmony_ci} __packed __aligned(8); 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_cistruct ibmvfc_implicit_logout { 3628c2ecf20Sopenharmony_ci struct ibmvfc_mad_common common; 3638c2ecf20Sopenharmony_ci __be64 old_scsi_id; 3648c2ecf20Sopenharmony_ci __be64 reserved[2]; 3658c2ecf20Sopenharmony_ci} __packed __aligned(8); 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_cistruct ibmvfc_tmf { 3688c2ecf20Sopenharmony_ci struct ibmvfc_mad_common common; 3698c2ecf20Sopenharmony_ci __be64 scsi_id; 3708c2ecf20Sopenharmony_ci struct scsi_lun lun; 3718c2ecf20Sopenharmony_ci __be32 flags; 3728c2ecf20Sopenharmony_ci#define IBMVFC_TMF_ABORT_TASK 0x02 3738c2ecf20Sopenharmony_ci#define IBMVFC_TMF_ABORT_TASK_SET 0x04 3748c2ecf20Sopenharmony_ci#define IBMVFC_TMF_LUN_RESET 0x10 3758c2ecf20Sopenharmony_ci#define IBMVFC_TMF_TGT_RESET 0x20 3768c2ecf20Sopenharmony_ci#define IBMVFC_TMF_LUA_VALID 0x40 3778c2ecf20Sopenharmony_ci#define IBMVFC_TMF_SUPPRESS_ABTS 0x80 3788c2ecf20Sopenharmony_ci __be32 cancel_key; 3798c2ecf20Sopenharmony_ci __be32 my_cancel_key; 3808c2ecf20Sopenharmony_ci __be32 pad; 3818c2ecf20Sopenharmony_ci __be64 reserved[2]; 3828c2ecf20Sopenharmony_ci} __packed __aligned(8); 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_cienum ibmvfc_fcp_rsp_info_codes { 3858c2ecf20Sopenharmony_ci RSP_NO_FAILURE = 0x00, 3868c2ecf20Sopenharmony_ci RSP_TMF_REJECTED = 0x04, 3878c2ecf20Sopenharmony_ci RSP_TMF_FAILED = 0x05, 3888c2ecf20Sopenharmony_ci RSP_TMF_INVALID_LUN = 0x09, 3898c2ecf20Sopenharmony_ci}; 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_cistruct ibmvfc_fcp_rsp_info { 3928c2ecf20Sopenharmony_ci u8 reserved[3]; 3938c2ecf20Sopenharmony_ci u8 rsp_code; 3948c2ecf20Sopenharmony_ci u8 reserved2[4]; 3958c2ecf20Sopenharmony_ci} __packed __aligned(2); 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_cienum ibmvfc_fcp_rsp_flags { 3988c2ecf20Sopenharmony_ci FCP_BIDI_RSP = 0x80, 3998c2ecf20Sopenharmony_ci FCP_BIDI_READ_RESID_UNDER = 0x40, 4008c2ecf20Sopenharmony_ci FCP_BIDI_READ_RESID_OVER = 0x20, 4018c2ecf20Sopenharmony_ci FCP_CONF_REQ = 0x10, 4028c2ecf20Sopenharmony_ci FCP_RESID_UNDER = 0x08, 4038c2ecf20Sopenharmony_ci FCP_RESID_OVER = 0x04, 4048c2ecf20Sopenharmony_ci FCP_SNS_LEN_VALID = 0x02, 4058c2ecf20Sopenharmony_ci FCP_RSP_LEN_VALID = 0x01, 4068c2ecf20Sopenharmony_ci}; 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_ciunion ibmvfc_fcp_rsp_data { 4098c2ecf20Sopenharmony_ci struct ibmvfc_fcp_rsp_info info; 4108c2ecf20Sopenharmony_ci u8 sense[SCSI_SENSE_BUFFERSIZE + sizeof(struct ibmvfc_fcp_rsp_info)]; 4118c2ecf20Sopenharmony_ci} __packed __aligned(8); 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_cistruct ibmvfc_fcp_rsp { 4148c2ecf20Sopenharmony_ci __be64 reserved; 4158c2ecf20Sopenharmony_ci __be16 retry_delay_timer; 4168c2ecf20Sopenharmony_ci u8 flags; 4178c2ecf20Sopenharmony_ci u8 scsi_status; 4188c2ecf20Sopenharmony_ci __be32 fcp_resid; 4198c2ecf20Sopenharmony_ci __be32 fcp_sense_len; 4208c2ecf20Sopenharmony_ci __be32 fcp_rsp_len; 4218c2ecf20Sopenharmony_ci union ibmvfc_fcp_rsp_data data; 4228c2ecf20Sopenharmony_ci} __packed __aligned(8); 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_cienum ibmvfc_cmd_flags { 4258c2ecf20Sopenharmony_ci IBMVFC_SCATTERLIST = 0x0001, 4268c2ecf20Sopenharmony_ci IBMVFC_NO_MEM_DESC = 0x0002, 4278c2ecf20Sopenharmony_ci IBMVFC_READ = 0x0004, 4288c2ecf20Sopenharmony_ci IBMVFC_WRITE = 0x0008, 4298c2ecf20Sopenharmony_ci IBMVFC_TMF = 0x0080, 4308c2ecf20Sopenharmony_ci IBMVFC_CLASS_3_ERR = 0x0100, 4318c2ecf20Sopenharmony_ci}; 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_cienum ibmvfc_fc_task_attr { 4348c2ecf20Sopenharmony_ci IBMVFC_SIMPLE_TASK = 0x00, 4358c2ecf20Sopenharmony_ci IBMVFC_HEAD_OF_QUEUE = 0x01, 4368c2ecf20Sopenharmony_ci IBMVFC_ORDERED_TASK = 0x02, 4378c2ecf20Sopenharmony_ci IBMVFC_ACA_TASK = 0x04, 4388c2ecf20Sopenharmony_ci}; 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_cienum ibmvfc_fc_tmf_flags { 4418c2ecf20Sopenharmony_ci IBMVFC_ABORT_TASK_SET = 0x02, 4428c2ecf20Sopenharmony_ci IBMVFC_LUN_RESET = 0x10, 4438c2ecf20Sopenharmony_ci IBMVFC_TARGET_RESET = 0x20, 4448c2ecf20Sopenharmony_ci}; 4458c2ecf20Sopenharmony_ci 4468c2ecf20Sopenharmony_cistruct ibmvfc_fcp_cmd_iu { 4478c2ecf20Sopenharmony_ci struct scsi_lun lun; 4488c2ecf20Sopenharmony_ci u8 crn; 4498c2ecf20Sopenharmony_ci u8 pri_task_attr; 4508c2ecf20Sopenharmony_ci u8 tmf_flags; 4518c2ecf20Sopenharmony_ci u8 add_cdb_len; 4528c2ecf20Sopenharmony_ci#define IBMVFC_RDDATA 0x02 4538c2ecf20Sopenharmony_ci#define IBMVFC_WRDATA 0x01 4548c2ecf20Sopenharmony_ci u8 cdb[IBMVFC_MAX_CDB_LEN]; 4558c2ecf20Sopenharmony_ci __be32 xfer_len; 4568c2ecf20Sopenharmony_ci} __packed __aligned(4); 4578c2ecf20Sopenharmony_ci 4588c2ecf20Sopenharmony_cistruct ibmvfc_cmd { 4598c2ecf20Sopenharmony_ci __be64 task_tag; 4608c2ecf20Sopenharmony_ci __be32 frame_type; 4618c2ecf20Sopenharmony_ci __be32 payload_len; 4628c2ecf20Sopenharmony_ci __be32 resp_len; 4638c2ecf20Sopenharmony_ci __be32 adapter_resid; 4648c2ecf20Sopenharmony_ci __be16 status; 4658c2ecf20Sopenharmony_ci __be16 error; 4668c2ecf20Sopenharmony_ci __be16 flags; 4678c2ecf20Sopenharmony_ci __be16 response_flags; 4688c2ecf20Sopenharmony_ci#define IBMVFC_ADAPTER_RESID_VALID 0x01 4698c2ecf20Sopenharmony_ci __be32 cancel_key; 4708c2ecf20Sopenharmony_ci __be32 exchange_id; 4718c2ecf20Sopenharmony_ci struct srp_direct_buf ext_func; 4728c2ecf20Sopenharmony_ci struct srp_direct_buf ioba; 4738c2ecf20Sopenharmony_ci struct srp_direct_buf resp; 4748c2ecf20Sopenharmony_ci __be64 correlation; 4758c2ecf20Sopenharmony_ci __be64 tgt_scsi_id; 4768c2ecf20Sopenharmony_ci __be64 tag; 4778c2ecf20Sopenharmony_ci __be64 reserved3[2]; 4788c2ecf20Sopenharmony_ci struct ibmvfc_fcp_cmd_iu iu; 4798c2ecf20Sopenharmony_ci struct ibmvfc_fcp_rsp rsp; 4808c2ecf20Sopenharmony_ci} __packed __aligned(8); 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_cistruct ibmvfc_passthru_fc_iu { 4838c2ecf20Sopenharmony_ci __be32 payload[7]; 4848c2ecf20Sopenharmony_ci#define IBMVFC_ADISC 0x52000000 4858c2ecf20Sopenharmony_ci __be32 response[7]; 4868c2ecf20Sopenharmony_ci}; 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_cistruct ibmvfc_passthru_iu { 4898c2ecf20Sopenharmony_ci __be64 task_tag; 4908c2ecf20Sopenharmony_ci __be32 cmd_len; 4918c2ecf20Sopenharmony_ci __be32 rsp_len; 4928c2ecf20Sopenharmony_ci __be16 status; 4938c2ecf20Sopenharmony_ci __be16 error; 4948c2ecf20Sopenharmony_ci __be32 flags; 4958c2ecf20Sopenharmony_ci#define IBMVFC_FC_ELS 0x01 4968c2ecf20Sopenharmony_ci#define IBMVFC_FC_CT_IU 0x02 4978c2ecf20Sopenharmony_ci __be32 cancel_key; 4988c2ecf20Sopenharmony_ci#define IBMVFC_PASSTHRU_CANCEL_KEY 0x80000000 4998c2ecf20Sopenharmony_ci#define IBMVFC_INTERNAL_CANCEL_KEY 0x80000001 5008c2ecf20Sopenharmony_ci __be32 reserved; 5018c2ecf20Sopenharmony_ci struct srp_direct_buf cmd; 5028c2ecf20Sopenharmony_ci struct srp_direct_buf rsp; 5038c2ecf20Sopenharmony_ci __be64 correlation; 5048c2ecf20Sopenharmony_ci __be64 scsi_id; 5058c2ecf20Sopenharmony_ci __be64 tag; 5068c2ecf20Sopenharmony_ci __be64 reserved2[2]; 5078c2ecf20Sopenharmony_ci} __packed __aligned(8); 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_cistruct ibmvfc_passthru_mad { 5108c2ecf20Sopenharmony_ci struct ibmvfc_mad_common common; 5118c2ecf20Sopenharmony_ci struct srp_direct_buf cmd_ioba; 5128c2ecf20Sopenharmony_ci struct ibmvfc_passthru_iu iu; 5138c2ecf20Sopenharmony_ci struct ibmvfc_passthru_fc_iu fc_iu; 5148c2ecf20Sopenharmony_ci} __packed __aligned(8); 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_cistruct ibmvfc_channel_enquiry { 5178c2ecf20Sopenharmony_ci struct ibmvfc_mad_common common; 5188c2ecf20Sopenharmony_ci __be32 flags; 5198c2ecf20Sopenharmony_ci#define IBMVFC_NO_CHANNELS_TO_CRQ_SUPPORT 0x01 5208c2ecf20Sopenharmony_ci#define IBMVFC_SUPPORT_VARIABLE_SUBQ_MSG 0x02 5218c2ecf20Sopenharmony_ci#define IBMVFC_NO_N_TO_M_CHANNELS_SUPPORT 0x04 5228c2ecf20Sopenharmony_ci __be32 num_scsi_subq_channels; 5238c2ecf20Sopenharmony_ci __be32 num_nvmeof_subq_channels; 5248c2ecf20Sopenharmony_ci __be32 num_scsi_vas_channels; 5258c2ecf20Sopenharmony_ci __be32 num_nvmeof_vas_channels; 5268c2ecf20Sopenharmony_ci} __packed __aligned(8); 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_cistruct ibmvfc_channel_setup_mad { 5298c2ecf20Sopenharmony_ci struct ibmvfc_mad_common common; 5308c2ecf20Sopenharmony_ci struct srp_direct_buf buffer; 5318c2ecf20Sopenharmony_ci} __packed __aligned(8); 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_ci#define IBMVFC_MAX_CHANNELS 502 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_cistruct ibmvfc_channel_setup { 5368c2ecf20Sopenharmony_ci __be32 flags; 5378c2ecf20Sopenharmony_ci#define IBMVFC_CANCEL_CHANNELS 0x01 5388c2ecf20Sopenharmony_ci#define IBMVFC_USE_BUFFER 0x02 5398c2ecf20Sopenharmony_ci#define IBMVFC_CHANNELS_CANCELED 0x04 5408c2ecf20Sopenharmony_ci __be32 reserved; 5418c2ecf20Sopenharmony_ci __be32 num_scsi_subq_channels; 5428c2ecf20Sopenharmony_ci __be32 num_nvmeof_subq_channels; 5438c2ecf20Sopenharmony_ci __be32 num_scsi_vas_channels; 5448c2ecf20Sopenharmony_ci __be32 num_nvmeof_vas_channels; 5458c2ecf20Sopenharmony_ci struct srp_direct_buf buffer; 5468c2ecf20Sopenharmony_ci __be64 reserved2[5]; 5478c2ecf20Sopenharmony_ci __be64 channel_handles[IBMVFC_MAX_CHANNELS]; 5488c2ecf20Sopenharmony_ci} __packed __aligned(8); 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_cistruct ibmvfc_connection_info { 5518c2ecf20Sopenharmony_ci struct ibmvfc_mad_common common; 5528c2ecf20Sopenharmony_ci __be64 information_bits; 5538c2ecf20Sopenharmony_ci#define IBMVFC_NO_FC_IO_CHANNEL 0x01 5548c2ecf20Sopenharmony_ci#define IBMVFC_NO_PHYP_VAS 0x02 5558c2ecf20Sopenharmony_ci#define IBMVFC_NO_PHYP_SUBQ 0x04 5568c2ecf20Sopenharmony_ci#define IBMVFC_PHYP_DEPRECATED_SUBQ 0x08 5578c2ecf20Sopenharmony_ci#define IBMVFC_PHYP_PRESERVED_SUBQ 0x10 5588c2ecf20Sopenharmony_ci#define IBMVFC_PHYP_FULL_SUBQ 0x20 5598c2ecf20Sopenharmony_ci __be64 reserved[16]; 5608c2ecf20Sopenharmony_ci} __packed __aligned(8); 5618c2ecf20Sopenharmony_ci 5628c2ecf20Sopenharmony_cistruct ibmvfc_trace_start_entry { 5638c2ecf20Sopenharmony_ci u32 xfer_len; 5648c2ecf20Sopenharmony_ci} __packed; 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_cistruct ibmvfc_trace_end_entry { 5678c2ecf20Sopenharmony_ci u16 status; 5688c2ecf20Sopenharmony_ci u16 error; 5698c2ecf20Sopenharmony_ci u8 fcp_rsp_flags; 5708c2ecf20Sopenharmony_ci u8 rsp_code; 5718c2ecf20Sopenharmony_ci u8 scsi_status; 5728c2ecf20Sopenharmony_ci u8 reserved; 5738c2ecf20Sopenharmony_ci} __packed; 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_cistruct ibmvfc_trace_entry { 5768c2ecf20Sopenharmony_ci struct ibmvfc_event *evt; 5778c2ecf20Sopenharmony_ci u32 time; 5788c2ecf20Sopenharmony_ci u32 scsi_id; 5798c2ecf20Sopenharmony_ci u32 lun; 5808c2ecf20Sopenharmony_ci u8 fmt; 5818c2ecf20Sopenharmony_ci u8 op_code; 5828c2ecf20Sopenharmony_ci u8 tmf_flags; 5838c2ecf20Sopenharmony_ci u8 type; 5848c2ecf20Sopenharmony_ci#define IBMVFC_TRC_START 0x00 5858c2ecf20Sopenharmony_ci#define IBMVFC_TRC_END 0xff 5868c2ecf20Sopenharmony_ci union { 5878c2ecf20Sopenharmony_ci struct ibmvfc_trace_start_entry start; 5888c2ecf20Sopenharmony_ci struct ibmvfc_trace_end_entry end; 5898c2ecf20Sopenharmony_ci } u; 5908c2ecf20Sopenharmony_ci} __packed __aligned(8); 5918c2ecf20Sopenharmony_ci 5928c2ecf20Sopenharmony_cienum ibmvfc_crq_formats { 5938c2ecf20Sopenharmony_ci IBMVFC_CMD_FORMAT = 0x01, 5948c2ecf20Sopenharmony_ci IBMVFC_ASYNC_EVENT = 0x02, 5958c2ecf20Sopenharmony_ci IBMVFC_MAD_FORMAT = 0x04, 5968c2ecf20Sopenharmony_ci}; 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_cienum ibmvfc_async_event { 5998c2ecf20Sopenharmony_ci IBMVFC_AE_ELS_PLOGI = 0x0001, 6008c2ecf20Sopenharmony_ci IBMVFC_AE_ELS_LOGO = 0x0002, 6018c2ecf20Sopenharmony_ci IBMVFC_AE_ELS_PRLO = 0x0004, 6028c2ecf20Sopenharmony_ci IBMVFC_AE_SCN_NPORT = 0x0008, 6038c2ecf20Sopenharmony_ci IBMVFC_AE_SCN_GROUP = 0x0010, 6048c2ecf20Sopenharmony_ci IBMVFC_AE_SCN_DOMAIN = 0x0020, 6058c2ecf20Sopenharmony_ci IBMVFC_AE_SCN_FABRIC = 0x0040, 6068c2ecf20Sopenharmony_ci IBMVFC_AE_LINK_UP = 0x0080, 6078c2ecf20Sopenharmony_ci IBMVFC_AE_LINK_DOWN = 0x0100, 6088c2ecf20Sopenharmony_ci IBMVFC_AE_LINK_DEAD = 0x0200, 6098c2ecf20Sopenharmony_ci IBMVFC_AE_HALT = 0x0400, 6108c2ecf20Sopenharmony_ci IBMVFC_AE_RESUME = 0x0800, 6118c2ecf20Sopenharmony_ci IBMVFC_AE_ADAPTER_FAILED = 0x1000, 6128c2ecf20Sopenharmony_ci IBMVFC_AE_FPIN = 0x2000, 6138c2ecf20Sopenharmony_ci}; 6148c2ecf20Sopenharmony_ci 6158c2ecf20Sopenharmony_cistruct ibmvfc_async_desc { 6168c2ecf20Sopenharmony_ci const char *desc; 6178c2ecf20Sopenharmony_ci enum ibmvfc_async_event ae; 6188c2ecf20Sopenharmony_ci int log_level; 6198c2ecf20Sopenharmony_ci}; 6208c2ecf20Sopenharmony_ci 6218c2ecf20Sopenharmony_cistruct ibmvfc_crq { 6228c2ecf20Sopenharmony_ci volatile u8 valid; 6238c2ecf20Sopenharmony_ci volatile u8 format; 6248c2ecf20Sopenharmony_ci u8 reserved[6]; 6258c2ecf20Sopenharmony_ci volatile __be64 ioba; 6268c2ecf20Sopenharmony_ci} __packed __aligned(8); 6278c2ecf20Sopenharmony_ci 6288c2ecf20Sopenharmony_cistruct ibmvfc_crq_queue { 6298c2ecf20Sopenharmony_ci struct ibmvfc_crq *msgs; 6308c2ecf20Sopenharmony_ci int size, cur; 6318c2ecf20Sopenharmony_ci dma_addr_t msg_token; 6328c2ecf20Sopenharmony_ci}; 6338c2ecf20Sopenharmony_ci 6348c2ecf20Sopenharmony_cienum ibmvfc_ae_link_state { 6358c2ecf20Sopenharmony_ci IBMVFC_AE_LS_LINK_UP = 0x01, 6368c2ecf20Sopenharmony_ci IBMVFC_AE_LS_LINK_BOUNCED = 0x02, 6378c2ecf20Sopenharmony_ci IBMVFC_AE_LS_LINK_DOWN = 0x04, 6388c2ecf20Sopenharmony_ci IBMVFC_AE_LS_LINK_DEAD = 0x08, 6398c2ecf20Sopenharmony_ci}; 6408c2ecf20Sopenharmony_ci 6418c2ecf20Sopenharmony_cienum ibmvfc_ae_fpin_status { 6428c2ecf20Sopenharmony_ci IBMVFC_AE_FPIN_LINK_CONGESTED = 0x1, 6438c2ecf20Sopenharmony_ci IBMVFC_AE_FPIN_PORT_CONGESTED = 0x2, 6448c2ecf20Sopenharmony_ci IBMVFC_AE_FPIN_PORT_CLEARED = 0x3, 6458c2ecf20Sopenharmony_ci IBMVFC_AE_FPIN_PORT_DEGRADED = 0x4, 6468c2ecf20Sopenharmony_ci}; 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_cistruct ibmvfc_async_crq { 6498c2ecf20Sopenharmony_ci volatile u8 valid; 6508c2ecf20Sopenharmony_ci u8 link_state; 6518c2ecf20Sopenharmony_ci u8 fpin_status; 6528c2ecf20Sopenharmony_ci u8 pad; 6538c2ecf20Sopenharmony_ci __be32 pad2; 6548c2ecf20Sopenharmony_ci volatile __be64 event; 6558c2ecf20Sopenharmony_ci volatile __be64 scsi_id; 6568c2ecf20Sopenharmony_ci volatile __be64 wwpn; 6578c2ecf20Sopenharmony_ci volatile __be64 node_name; 6588c2ecf20Sopenharmony_ci __be64 reserved; 6598c2ecf20Sopenharmony_ci} __packed __aligned(8); 6608c2ecf20Sopenharmony_ci 6618c2ecf20Sopenharmony_cistruct ibmvfc_async_crq_queue { 6628c2ecf20Sopenharmony_ci struct ibmvfc_async_crq *msgs; 6638c2ecf20Sopenharmony_ci int size, cur; 6648c2ecf20Sopenharmony_ci dma_addr_t msg_token; 6658c2ecf20Sopenharmony_ci}; 6668c2ecf20Sopenharmony_ci 6678c2ecf20Sopenharmony_ciunion ibmvfc_iu { 6688c2ecf20Sopenharmony_ci struct ibmvfc_mad_common mad_common; 6698c2ecf20Sopenharmony_ci struct ibmvfc_npiv_login_mad npiv_login; 6708c2ecf20Sopenharmony_ci struct ibmvfc_npiv_logout_mad npiv_logout; 6718c2ecf20Sopenharmony_ci struct ibmvfc_discover_targets discover_targets; 6728c2ecf20Sopenharmony_ci struct ibmvfc_port_login plogi; 6738c2ecf20Sopenharmony_ci struct ibmvfc_process_login prli; 6748c2ecf20Sopenharmony_ci struct ibmvfc_move_login move_login; 6758c2ecf20Sopenharmony_ci struct ibmvfc_query_tgt query_tgt; 6768c2ecf20Sopenharmony_ci struct ibmvfc_implicit_logout implicit_logout; 6778c2ecf20Sopenharmony_ci struct ibmvfc_tmf tmf; 6788c2ecf20Sopenharmony_ci struct ibmvfc_cmd cmd; 6798c2ecf20Sopenharmony_ci struct ibmvfc_passthru_mad passthru; 6808c2ecf20Sopenharmony_ci struct ibmvfc_channel_enquiry channel_enquiry; 6818c2ecf20Sopenharmony_ci struct ibmvfc_channel_setup_mad channel_setup; 6828c2ecf20Sopenharmony_ci struct ibmvfc_connection_info connection_info; 6838c2ecf20Sopenharmony_ci} __packed __aligned(8); 6848c2ecf20Sopenharmony_ci 6858c2ecf20Sopenharmony_cienum ibmvfc_target_action { 6868c2ecf20Sopenharmony_ci IBMVFC_TGT_ACTION_NONE = 0, 6878c2ecf20Sopenharmony_ci IBMVFC_TGT_ACTION_INIT, 6888c2ecf20Sopenharmony_ci IBMVFC_TGT_ACTION_INIT_WAIT, 6898c2ecf20Sopenharmony_ci IBMVFC_TGT_ACTION_LOGOUT_RPORT, 6908c2ecf20Sopenharmony_ci IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT, 6918c2ecf20Sopenharmony_ci IBMVFC_TGT_ACTION_DEL_RPORT, 6928c2ecf20Sopenharmony_ci IBMVFC_TGT_ACTION_DELETED_RPORT, 6938c2ecf20Sopenharmony_ci IBMVFC_TGT_ACTION_DEL_AND_LOGOUT_RPORT, 6948c2ecf20Sopenharmony_ci IBMVFC_TGT_ACTION_LOGOUT_DELETED_RPORT, 6958c2ecf20Sopenharmony_ci}; 6968c2ecf20Sopenharmony_ci 6978c2ecf20Sopenharmony_cistruct ibmvfc_target { 6988c2ecf20Sopenharmony_ci struct list_head queue; 6998c2ecf20Sopenharmony_ci struct ibmvfc_host *vhost; 7008c2ecf20Sopenharmony_ci u64 scsi_id; 7018c2ecf20Sopenharmony_ci u64 wwpn; 7028c2ecf20Sopenharmony_ci u64 old_scsi_id; 7038c2ecf20Sopenharmony_ci struct fc_rport *rport; 7048c2ecf20Sopenharmony_ci int target_id; 7058c2ecf20Sopenharmony_ci enum ibmvfc_target_action action; 7068c2ecf20Sopenharmony_ci int need_login; 7078c2ecf20Sopenharmony_ci int add_rport; 7088c2ecf20Sopenharmony_ci int init_retries; 7098c2ecf20Sopenharmony_ci int logo_rcvd; 7108c2ecf20Sopenharmony_ci u32 cancel_key; 7118c2ecf20Sopenharmony_ci struct ibmvfc_service_parms service_parms; 7128c2ecf20Sopenharmony_ci struct ibmvfc_service_parms service_parms_change; 7138c2ecf20Sopenharmony_ci struct fc_rport_identifiers ids; 7148c2ecf20Sopenharmony_ci void (*job_step) (struct ibmvfc_target *); 7158c2ecf20Sopenharmony_ci struct timer_list timer; 7168c2ecf20Sopenharmony_ci struct kref kref; 7178c2ecf20Sopenharmony_ci}; 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_ci/* a unit of work for the hosting partition */ 7208c2ecf20Sopenharmony_cistruct ibmvfc_event { 7218c2ecf20Sopenharmony_ci struct list_head queue; 7228c2ecf20Sopenharmony_ci struct ibmvfc_host *vhost; 7238c2ecf20Sopenharmony_ci struct ibmvfc_target *tgt; 7248c2ecf20Sopenharmony_ci struct scsi_cmnd *cmnd; 7258c2ecf20Sopenharmony_ci atomic_t free; 7268c2ecf20Sopenharmony_ci union ibmvfc_iu *xfer_iu; 7278c2ecf20Sopenharmony_ci void (*done) (struct ibmvfc_event *); 7288c2ecf20Sopenharmony_ci struct ibmvfc_crq crq; 7298c2ecf20Sopenharmony_ci union ibmvfc_iu iu; 7308c2ecf20Sopenharmony_ci union ibmvfc_iu *sync_iu; 7318c2ecf20Sopenharmony_ci struct srp_direct_buf *ext_list; 7328c2ecf20Sopenharmony_ci dma_addr_t ext_list_token; 7338c2ecf20Sopenharmony_ci struct completion comp; 7348c2ecf20Sopenharmony_ci struct completion *eh_comp; 7358c2ecf20Sopenharmony_ci struct timer_list timer; 7368c2ecf20Sopenharmony_ci}; 7378c2ecf20Sopenharmony_ci 7388c2ecf20Sopenharmony_ci/* a pool of event structs for use */ 7398c2ecf20Sopenharmony_cistruct ibmvfc_event_pool { 7408c2ecf20Sopenharmony_ci struct ibmvfc_event *events; 7418c2ecf20Sopenharmony_ci u32 size; 7428c2ecf20Sopenharmony_ci union ibmvfc_iu *iu_storage; 7438c2ecf20Sopenharmony_ci dma_addr_t iu_token; 7448c2ecf20Sopenharmony_ci}; 7458c2ecf20Sopenharmony_ci 7468c2ecf20Sopenharmony_cienum ibmvfc_host_action { 7478c2ecf20Sopenharmony_ci IBMVFC_HOST_ACTION_NONE = 0, 7488c2ecf20Sopenharmony_ci IBMVFC_HOST_ACTION_RESET, 7498c2ecf20Sopenharmony_ci IBMVFC_HOST_ACTION_REENABLE, 7508c2ecf20Sopenharmony_ci IBMVFC_HOST_ACTION_LOGO, 7518c2ecf20Sopenharmony_ci IBMVFC_HOST_ACTION_LOGO_WAIT, 7528c2ecf20Sopenharmony_ci IBMVFC_HOST_ACTION_INIT, 7538c2ecf20Sopenharmony_ci IBMVFC_HOST_ACTION_INIT_WAIT, 7548c2ecf20Sopenharmony_ci IBMVFC_HOST_ACTION_QUERY, 7558c2ecf20Sopenharmony_ci IBMVFC_HOST_ACTION_QUERY_TGTS, 7568c2ecf20Sopenharmony_ci IBMVFC_HOST_ACTION_TGT_DEL, 7578c2ecf20Sopenharmony_ci IBMVFC_HOST_ACTION_ALLOC_TGTS, 7588c2ecf20Sopenharmony_ci IBMVFC_HOST_ACTION_TGT_INIT, 7598c2ecf20Sopenharmony_ci IBMVFC_HOST_ACTION_TGT_DEL_FAILED, 7608c2ecf20Sopenharmony_ci}; 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_cienum ibmvfc_host_state { 7638c2ecf20Sopenharmony_ci IBMVFC_NO_CRQ = 0, 7648c2ecf20Sopenharmony_ci IBMVFC_INITIALIZING, 7658c2ecf20Sopenharmony_ci IBMVFC_ACTIVE, 7668c2ecf20Sopenharmony_ci IBMVFC_HALTED, 7678c2ecf20Sopenharmony_ci IBMVFC_LINK_DOWN, 7688c2ecf20Sopenharmony_ci IBMVFC_LINK_DEAD, 7698c2ecf20Sopenharmony_ci IBMVFC_HOST_OFFLINE, 7708c2ecf20Sopenharmony_ci}; 7718c2ecf20Sopenharmony_ci 7728c2ecf20Sopenharmony_cistruct ibmvfc_host { 7738c2ecf20Sopenharmony_ci char name[8]; 7748c2ecf20Sopenharmony_ci struct list_head queue; 7758c2ecf20Sopenharmony_ci struct Scsi_Host *host; 7768c2ecf20Sopenharmony_ci enum ibmvfc_host_state state; 7778c2ecf20Sopenharmony_ci enum ibmvfc_host_action action; 7788c2ecf20Sopenharmony_ci#define IBMVFC_NUM_TRACE_INDEX_BITS 8 7798c2ecf20Sopenharmony_ci#define IBMVFC_NUM_TRACE_ENTRIES (1 << IBMVFC_NUM_TRACE_INDEX_BITS) 7808c2ecf20Sopenharmony_ci#define IBMVFC_TRACE_SIZE (sizeof(struct ibmvfc_trace_entry) * IBMVFC_NUM_TRACE_ENTRIES) 7818c2ecf20Sopenharmony_ci struct ibmvfc_trace_entry *trace; 7828c2ecf20Sopenharmony_ci u32 trace_index:IBMVFC_NUM_TRACE_INDEX_BITS; 7838c2ecf20Sopenharmony_ci int num_targets; 7848c2ecf20Sopenharmony_ci struct list_head targets; 7858c2ecf20Sopenharmony_ci struct list_head sent; 7868c2ecf20Sopenharmony_ci struct list_head free; 7878c2ecf20Sopenharmony_ci struct device *dev; 7888c2ecf20Sopenharmony_ci struct ibmvfc_event_pool pool; 7898c2ecf20Sopenharmony_ci struct dma_pool *sg_pool; 7908c2ecf20Sopenharmony_ci mempool_t *tgt_pool; 7918c2ecf20Sopenharmony_ci struct ibmvfc_crq_queue crq; 7928c2ecf20Sopenharmony_ci struct ibmvfc_async_crq_queue async_crq; 7938c2ecf20Sopenharmony_ci struct ibmvfc_npiv_login login_info; 7948c2ecf20Sopenharmony_ci union ibmvfc_npiv_login_data *login_buf; 7958c2ecf20Sopenharmony_ci dma_addr_t login_buf_dma; 7968c2ecf20Sopenharmony_ci int disc_buf_sz; 7978c2ecf20Sopenharmony_ci int log_level; 7988c2ecf20Sopenharmony_ci struct ibmvfc_discover_targets_entry *disc_buf; 7998c2ecf20Sopenharmony_ci struct mutex passthru_mutex; 8008c2ecf20Sopenharmony_ci int task_set; 8018c2ecf20Sopenharmony_ci int init_retries; 8028c2ecf20Sopenharmony_ci int discovery_threads; 8038c2ecf20Sopenharmony_ci int abort_threads; 8048c2ecf20Sopenharmony_ci int client_migrated; 8058c2ecf20Sopenharmony_ci int reinit; 8068c2ecf20Sopenharmony_ci int delay_init; 8078c2ecf20Sopenharmony_ci int scan_complete; 8088c2ecf20Sopenharmony_ci int logged_in; 8098c2ecf20Sopenharmony_ci int aborting_passthru; 8108c2ecf20Sopenharmony_ci int events_to_log; 8118c2ecf20Sopenharmony_ci#define IBMVFC_AE_LINKUP 0x0001 8128c2ecf20Sopenharmony_ci#define IBMVFC_AE_LINKDOWN 0x0002 8138c2ecf20Sopenharmony_ci#define IBMVFC_AE_RSCN 0x0004 8148c2ecf20Sopenharmony_ci dma_addr_t disc_buf_dma; 8158c2ecf20Sopenharmony_ci unsigned int partition_number; 8168c2ecf20Sopenharmony_ci char partition_name[97]; 8178c2ecf20Sopenharmony_ci void (*job_step) (struct ibmvfc_host *); 8188c2ecf20Sopenharmony_ci struct task_struct *work_thread; 8198c2ecf20Sopenharmony_ci struct tasklet_struct tasklet; 8208c2ecf20Sopenharmony_ci struct work_struct rport_add_work_q; 8218c2ecf20Sopenharmony_ci wait_queue_head_t init_wait_q; 8228c2ecf20Sopenharmony_ci wait_queue_head_t work_wait_q; 8238c2ecf20Sopenharmony_ci}; 8248c2ecf20Sopenharmony_ci 8258c2ecf20Sopenharmony_ci#define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0) 8268c2ecf20Sopenharmony_ci 8278c2ecf20Sopenharmony_ci#define tgt_dbg(t, fmt, ...) \ 8288c2ecf20Sopenharmony_ci DBG_CMD(dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)) 8298c2ecf20Sopenharmony_ci 8308c2ecf20Sopenharmony_ci#define tgt_info(t, fmt, ...) \ 8318c2ecf20Sopenharmony_ci dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__) 8328c2ecf20Sopenharmony_ci 8338c2ecf20Sopenharmony_ci#define tgt_err(t, fmt, ...) \ 8348c2ecf20Sopenharmony_ci dev_err((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__) 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_ci#define tgt_log(t, level, fmt, ...) \ 8378c2ecf20Sopenharmony_ci do { \ 8388c2ecf20Sopenharmony_ci if ((t)->vhost->log_level >= level) \ 8398c2ecf20Sopenharmony_ci tgt_err(t, fmt, ##__VA_ARGS__); \ 8408c2ecf20Sopenharmony_ci } while (0) 8418c2ecf20Sopenharmony_ci 8428c2ecf20Sopenharmony_ci#define ibmvfc_dbg(vhost, ...) \ 8438c2ecf20Sopenharmony_ci DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__)) 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_ci#define ibmvfc_log(vhost, level, ...) \ 8468c2ecf20Sopenharmony_ci do { \ 8478c2ecf20Sopenharmony_ci if ((vhost)->log_level >= level) \ 8488c2ecf20Sopenharmony_ci dev_err((vhost)->dev, ##__VA_ARGS__); \ 8498c2ecf20Sopenharmony_ci } while (0) 8508c2ecf20Sopenharmony_ci 8518c2ecf20Sopenharmony_ci#define ENTER DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Entering %s\n", __func__)) 8528c2ecf20Sopenharmony_ci#define LEAVE DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Leaving %s\n", __func__)) 8538c2ecf20Sopenharmony_ci 8548c2ecf20Sopenharmony_ci#ifdef CONFIG_SCSI_IBMVFC_TRACE 8558c2ecf20Sopenharmony_ci#define ibmvfc_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr) 8568c2ecf20Sopenharmony_ci#define ibmvfc_remove_trace_file(kobj, attr) sysfs_remove_bin_file(kobj, attr) 8578c2ecf20Sopenharmony_ci#else 8588c2ecf20Sopenharmony_ci#define ibmvfc_create_trace_file(kobj, attr) 0 8598c2ecf20Sopenharmony_ci#define ibmvfc_remove_trace_file(kobj, attr) do { } while (0) 8608c2ecf20Sopenharmony_ci#endif 8618c2ecf20Sopenharmony_ci 8628c2ecf20Sopenharmony_ci#endif 863