17836SJohn.Forte@Sun.COM /* 27836SJohn.Forte@Sun.COM * CDDL HEADER START 37836SJohn.Forte@Sun.COM * 47836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the 57836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License"). 67836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License. 77836SJohn.Forte@Sun.COM * 87836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing. 107836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions 117836SJohn.Forte@Sun.COM * and limitations under the License. 127836SJohn.Forte@Sun.COM * 137836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 147836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 167836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 177836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 187836SJohn.Forte@Sun.COM * 197836SJohn.Forte@Sun.COM * CDDL HEADER END 207836SJohn.Forte@Sun.COM */ 217836SJohn.Forte@Sun.COM /* 2212314SJames.Moore@Sun.COM * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 237836SJohn.Forte@Sun.COM */ 247836SJohn.Forte@Sun.COM #ifndef _FCT_H 257836SJohn.Forte@Sun.COM #define _FCT_H 267836SJohn.Forte@Sun.COM 277836SJohn.Forte@Sun.COM /* 287836SJohn.Forte@Sun.COM * Definitions for common FC Target. 297836SJohn.Forte@Sun.COM */ 307836SJohn.Forte@Sun.COM #include <sys/note.h> 317836SJohn.Forte@Sun.COM #include <sys/stmf_defines.h> 327836SJohn.Forte@Sun.COM #include <sys/fct_defines.h> 337836SJohn.Forte@Sun.COM #include <sys/portif.h> 347836SJohn.Forte@Sun.COM 357836SJohn.Forte@Sun.COM #ifdef __cplusplus 367836SJohn.Forte@Sun.COM extern "C" { 377836SJohn.Forte@Sun.COM #endif 387836SJohn.Forte@Sun.COM 397836SJohn.Forte@Sun.COM typedef enum fct_struct_id { 407836SJohn.Forte@Sun.COM FCT_STRUCT_LOCAL_PORT = 1, 417836SJohn.Forte@Sun.COM FCT_STRUCT_REMOTE_PORT, 427836SJohn.Forte@Sun.COM FCT_STRUCT_CMD_RCVD_ELS, 437836SJohn.Forte@Sun.COM FCT_STRUCT_CMD_SOL_ELS, 447836SJohn.Forte@Sun.COM FCT_STRUCT_CMD_SOL_CT, 457836SJohn.Forte@Sun.COM FCT_STRUCT_CMD_RCVD_ABTS, 467836SJohn.Forte@Sun.COM FCT_STRUCT_CMD_FCP_XCHG, 477836SJohn.Forte@Sun.COM FCT_STRUCT_DBUF_STORE, 487836SJohn.Forte@Sun.COM 497836SJohn.Forte@Sun.COM FCT_MAX_STRUCT_IDS 507836SJohn.Forte@Sun.COM } fct_struct_id_t; 517836SJohn.Forte@Sun.COM 527836SJohn.Forte@Sun.COM typedef struct fct_remote_port { 537836SJohn.Forte@Sun.COM void *rp_fct_private; 547836SJohn.Forte@Sun.COM void *rp_fca_private; 557836SJohn.Forte@Sun.COM 567836SJohn.Forte@Sun.COM struct fct_local_port *rp_port; 579578SSam.Cramer@Sun.COM char rp_nwwn_str[FC_WWN_BUFLEN]; 589578SSam.Cramer@Sun.COM char rp_pwwn_str[FC_WWN_BUFLEN]; 597836SJohn.Forte@Sun.COM uint8_t rp_nwwn[FC_WWN_LEN]; 607836SJohn.Forte@Sun.COM uint8_t rp_pwwn[FC_WWN_LEN]; 617836SJohn.Forte@Sun.COM uint32_t rp_id; /* 8 or 24 bit */ 627836SJohn.Forte@Sun.COM uint32_t rp_hard_address; 637836SJohn.Forte@Sun.COM uint16_t rp_handle; 647836SJohn.Forte@Sun.COM } fct_remote_port_t; 657836SJohn.Forte@Sun.COM 667836SJohn.Forte@Sun.COM #define FCT_HANDLE_NONE 0xffff 677836SJohn.Forte@Sun.COM 687836SJohn.Forte@Sun.COM typedef struct fct_cmd { 697836SJohn.Forte@Sun.COM void *cmd_fct_private; 707836SJohn.Forte@Sun.COM void *cmd_fca_private; 717836SJohn.Forte@Sun.COM void *cmd_specific; 727836SJohn.Forte@Sun.COM 737836SJohn.Forte@Sun.COM struct fct_local_port *cmd_port; 747836SJohn.Forte@Sun.COM 757836SJohn.Forte@Sun.COM /* During cmd porting this can be set to NULL */ 767836SJohn.Forte@Sun.COM struct fct_remote_port *cmd_rp; 777836SJohn.Forte@Sun.COM 787836SJohn.Forte@Sun.COM /* To link cmds together for handling things like ABTS. */ 797836SJohn.Forte@Sun.COM struct fct_cmd *cmd_link; 807836SJohn.Forte@Sun.COM uint8_t cmd_type; 817836SJohn.Forte@Sun.COM uint8_t cmd_rsvd1; 827836SJohn.Forte@Sun.COM 837836SJohn.Forte@Sun.COM /* During cmd posting this can be set to FCT_HANDLE_NONE */ 847836SJohn.Forte@Sun.COM uint16_t cmd_rp_handle; 857836SJohn.Forte@Sun.COM uint32_t cmd_handle; 867836SJohn.Forte@Sun.COM uint32_t cmd_rportid; 877836SJohn.Forte@Sun.COM uint32_t cmd_lportid; 887836SJohn.Forte@Sun.COM uint32_t cmd_rsvd2; 897836SJohn.Forte@Sun.COM uint16_t cmd_oxid; 907836SJohn.Forte@Sun.COM uint16_t cmd_rxid; 917836SJohn.Forte@Sun.COM fct_status_t cmd_comp_status; 927836SJohn.Forte@Sun.COM } fct_cmd_t; 937836SJohn.Forte@Sun.COM 947836SJohn.Forte@Sun.COM /* 957836SJohn.Forte@Sun.COM * fcmd_cmd_handle: Bit definitions. 967836SJohn.Forte@Sun.COM * 31 23 15 7 0 977836SJohn.Forte@Sun.COM * +--------------+------------+------------+------------+ 987836SJohn.Forte@Sun.COM * | V |uniq_cntr |fca specific| cmd slot index | 997836SJohn.Forte@Sun.COM * +--------------+------------+------------+------------+ 1007836SJohn.Forte@Sun.COM * V = handle valid. 1017836SJohn.Forte@Sun.COM */ 1027836SJohn.Forte@Sun.COM #define CMD_HANDLE_SLOT_INDEX(x) ((x) & 0xffff) 1037836SJohn.Forte@Sun.COM #define CMD_HANDLE_VALID(x) ((x) & 0x80000000) 1047836SJohn.Forte@Sun.COM 1057836SJohn.Forte@Sun.COM enum fct_cmd_types { 1067836SJohn.Forte@Sun.COM FCT_CMD_FCP_XCHG = 0x0001, 1077836SJohn.Forte@Sun.COM FCT_CMD_RCVD_ELS = 0x0002, 1087836SJohn.Forte@Sun.COM FCT_CMD_SOL_ELS = 0x0004, 1097836SJohn.Forte@Sun.COM FCT_CMD_RCVD_ABTS = 0x0008, 1107836SJohn.Forte@Sun.COM FCT_CMD_SOL_CT = 0x0010, 1117836SJohn.Forte@Sun.COM 1127836SJohn.Forte@Sun.COM FCT_CMD_TYPE_ALL = 0xffff 1137836SJohn.Forte@Sun.COM }; 1147836SJohn.Forte@Sun.COM 1157836SJohn.Forte@Sun.COM typedef struct fct_els { 1167836SJohn.Forte@Sun.COM uint16_t els_req_size; 1177836SJohn.Forte@Sun.COM uint16_t els_resp_size; 1187836SJohn.Forte@Sun.COM uint16_t els_req_alloc_size; 1197836SJohn.Forte@Sun.COM uint16_t els_resp_alloc_size; 1207836SJohn.Forte@Sun.COM uint8_t *els_req_payload; 1217836SJohn.Forte@Sun.COM uint8_t *els_resp_payload; 1227836SJohn.Forte@Sun.COM } fct_els_t; 1237836SJohn.Forte@Sun.COM 1247836SJohn.Forte@Sun.COM typedef struct fct_sol_ct { 1257836SJohn.Forte@Sun.COM uint16_t ct_req_size; 1267836SJohn.Forte@Sun.COM uint16_t ct_resp_size; 1277836SJohn.Forte@Sun.COM uint16_t ct_req_alloc_size; 1287836SJohn.Forte@Sun.COM uint16_t ct_resp_alloc_size; 1297836SJohn.Forte@Sun.COM uint8_t *ct_req_payload; 1307836SJohn.Forte@Sun.COM uint8_t *ct_resp_payload; 1317836SJohn.Forte@Sun.COM } fct_sol_ct_t; 1327836SJohn.Forte@Sun.COM 1337836SJohn.Forte@Sun.COM typedef struct fct_rcvd_abts { 1347836SJohn.Forte@Sun.COM uint8_t abts_resp_rctl; /* Can be BA_ACC or BA_RJT */ 1357836SJohn.Forte@Sun.COM uint8_t abts_state; 1367836SJohn.Forte@Sun.COM uint16_t rsvd; 1377836SJohn.Forte@Sun.COM uint8_t abts_resp_payload[12]; 1387836SJohn.Forte@Sun.COM } fct_rcvd_abts_t; 1397836SJohn.Forte@Sun.COM 1407836SJohn.Forte@Sun.COM /* 1417836SJohn.Forte@Sun.COM * abts state 1427836SJohn.Forte@Sun.COM */ 1437836SJohn.Forte@Sun.COM #define ABTS_STATE_RECEIVED 0 1447836SJohn.Forte@Sun.COM #define ABTS_STATE_RESPONDED 1 1457836SJohn.Forte@Sun.COM #define ABTS_STATE_COMPLETED 2 1467836SJohn.Forte@Sun.COM #define ABTS_STATE_ABORT_REQUESTED 3 1477836SJohn.Forte@Sun.COM #define ABTS_STATE_ABORT_COMPLETED 4 1487836SJohn.Forte@Sun.COM 1497836SJohn.Forte@Sun.COM #define FCHBA_MANUFACTURER_LEN 64 1507836SJohn.Forte@Sun.COM #define FCHBA_SERIAL_NUMBER_LEN 64 1517836SJohn.Forte@Sun.COM #define FCHBA_MODEL_LEN 256 1527836SJohn.Forte@Sun.COM #define FCHBA_MODEL_DESCRIPTION_LEN 256 1537836SJohn.Forte@Sun.COM #define FCHBA_HARDWARE_VERSION_LEN 256 1547836SJohn.Forte@Sun.COM #define FCHBA_DRIVER_VERSION_LEN 256 1557836SJohn.Forte@Sun.COM #define FCHBA_OPTION_ROM_VERSION_LEN 256 1567836SJohn.Forte@Sun.COM #define FCHBA_FIRMWARE_VERSION_LEN 256 1577836SJohn.Forte@Sun.COM #define FCHBA_DRIVER_NAME_LEN 256 1587836SJohn.Forte@Sun.COM #define FCHBA_SYMB_NAME_LEN 255 1597836SJohn.Forte@Sun.COM 160*12571SViswanathan.Kannappan@Sun.COM #define FCT_INFO_LEN 160 161*12571SViswanathan.Kannappan@Sun.COM #define FCT_TASKQ_NAME_LEN 24 162*12571SViswanathan.Kannappan@Sun.COM 16310088SAllan.Ou@Sun.COM #define FC_TGT_PORT_INFO_CMD (((uint32_t)'I') << 24) 16410088SAllan.Ou@Sun.COM #define FC_TGT_PORT_RLS FC_TGT_PORT_INFO_CMD + 0x1 16510088SAllan.Ou@Sun.COM 1667836SJohn.Forte@Sun.COM typedef struct fct_port_attrs { 1677836SJohn.Forte@Sun.COM char manufacturer[FCHBA_MANUFACTURER_LEN]; 1687836SJohn.Forte@Sun.COM char serial_number[FCHBA_SERIAL_NUMBER_LEN]; 1697836SJohn.Forte@Sun.COM char model[FCHBA_MODEL_LEN]; 1707836SJohn.Forte@Sun.COM char model_description[FCHBA_MODEL_DESCRIPTION_LEN]; 1717836SJohn.Forte@Sun.COM char hardware_version[FCHBA_HARDWARE_VERSION_LEN]; 1727836SJohn.Forte@Sun.COM char driver_version[FCHBA_DRIVER_VERSION_LEN]; 1737836SJohn.Forte@Sun.COM char option_rom_version[FCHBA_OPTION_ROM_VERSION_LEN]; 1747836SJohn.Forte@Sun.COM char firmware_version[FCHBA_FIRMWARE_VERSION_LEN]; 1757836SJohn.Forte@Sun.COM char driver_name[FCHBA_DRIVER_NAME_LEN]; 1767836SJohn.Forte@Sun.COM uint32_t vendor_specific_id; 1777836SJohn.Forte@Sun.COM uint32_t supported_cos; 1787836SJohn.Forte@Sun.COM uint32_t supported_speed; 1797836SJohn.Forte@Sun.COM uint32_t max_frame_size; 1807836SJohn.Forte@Sun.COM } fct_port_attrs_t; 1817836SJohn.Forte@Sun.COM 18210088SAllan.Ou@Sun.COM typedef struct fct_port_link_status { 18310088SAllan.Ou@Sun.COM uint32_t LinkFailureCount; 18410088SAllan.Ou@Sun.COM uint32_t LossOfSyncCount; 18510088SAllan.Ou@Sun.COM uint32_t LossOfSignalsCount; 18610088SAllan.Ou@Sun.COM uint32_t PrimitiveSeqProtocolErrorCount; 18710088SAllan.Ou@Sun.COM uint32_t InvalidTransmissionWordCount; 18810088SAllan.Ou@Sun.COM uint32_t InvalidCRCCount; 18910088SAllan.Ou@Sun.COM } fct_port_link_status_t; 19010088SAllan.Ou@Sun.COM 1917836SJohn.Forte@Sun.COM typedef struct fct_dbuf_store { 1927836SJohn.Forte@Sun.COM void *fds_fct_private; 1937836SJohn.Forte@Sun.COM void *fds_fca_private; 1947836SJohn.Forte@Sun.COM struct stmf_dbuf_store *fds_ds; 1957836SJohn.Forte@Sun.COM 1967836SJohn.Forte@Sun.COM stmf_data_buf_t *(*fds_alloc_data_buf)(struct fct_local_port *port, 1977836SJohn.Forte@Sun.COM uint32_t size, uint32_t *pminsize, uint32_t flags); 1987836SJohn.Forte@Sun.COM void (*fds_free_data_buf)(struct fct_dbuf_store *fds, 1997836SJohn.Forte@Sun.COM stmf_data_buf_t *dbuf); 20012314SJames.Moore@Sun.COM stmf_status_t (*fds_setup_dbuf)(struct fct_local_port *port, 20112314SJames.Moore@Sun.COM stmf_data_buf_t *dbuf, uint32_t flags); 20212314SJames.Moore@Sun.COM void (*fds_teardown_dbuf)(struct fct_dbuf_store *fds, 20312314SJames.Moore@Sun.COM stmf_data_buf_t *dbuf); 20412314SJames.Moore@Sun.COM 20512314SJames.Moore@Sun.COM uint32_t fds_max_sgl_xfer_len; 20612314SJames.Moore@Sun.COM uint32_t fds_copy_threshold; 2077836SJohn.Forte@Sun.COM } fct_dbuf_store_t; 2087836SJohn.Forte@Sun.COM 20910936SAllan.Ou@Sun.COM #define FCT_FCA_MODREV_1 1 21010936SAllan.Ou@Sun.COM 2117836SJohn.Forte@Sun.COM typedef struct fct_local_port { 2127836SJohn.Forte@Sun.COM void *port_fct_private; 2137836SJohn.Forte@Sun.COM void *port_fca_private; 2147836SJohn.Forte@Sun.COM stmf_local_port_t *port_lport; 2157836SJohn.Forte@Sun.COM 2169578SSam.Cramer@Sun.COM char port_nwwn_str[FC_WWN_BUFLEN]; 2179578SSam.Cramer@Sun.COM char port_pwwn_str[FC_WWN_BUFLEN]; 2187836SJohn.Forte@Sun.COM uint8_t port_nwwn[FC_WWN_LEN]; 2197836SJohn.Forte@Sun.COM uint8_t port_pwwn[FC_WWN_LEN]; 2207836SJohn.Forte@Sun.COM char *port_default_alias; 2217836SJohn.Forte@Sun.COM char *port_sym_node_name; 2227836SJohn.Forte@Sun.COM char *port_sym_port_name; 2237836SJohn.Forte@Sun.COM 2247836SJohn.Forte@Sun.COM stmf_port_provider_t *port_pp; 2257836SJohn.Forte@Sun.COM 2267836SJohn.Forte@Sun.COM uint32_t port_hard_address; 2277836SJohn.Forte@Sun.COM uint16_t port_max_logins; 2287836SJohn.Forte@Sun.COM uint16_t port_max_xchges; 2297836SJohn.Forte@Sun.COM uint32_t port_fca_fcp_cmd_size; 2307836SJohn.Forte@Sun.COM uint32_t port_fca_rp_private_size; 2317836SJohn.Forte@Sun.COM uint32_t port_fca_sol_els_private_size; 2327836SJohn.Forte@Sun.COM uint32_t port_fca_sol_ct_private_size; 2337836SJohn.Forte@Sun.COM 2347836SJohn.Forte@Sun.COM /* in milliseconds */ 2357836SJohn.Forte@Sun.COM uint32_t port_fca_abort_timeout; 2367836SJohn.Forte@Sun.COM 2377836SJohn.Forte@Sun.COM fct_dbuf_store_t *port_fds; 2387836SJohn.Forte@Sun.COM fct_status_t (*port_get_link_info)( 2397836SJohn.Forte@Sun.COM struct fct_local_port *port, struct fct_link_info *li); 2407836SJohn.Forte@Sun.COM fct_status_t (*port_register_remote_port)( 2417836SJohn.Forte@Sun.COM struct fct_local_port *port, struct fct_remote_port *rp, 2427836SJohn.Forte@Sun.COM struct fct_cmd *login_els); 2437836SJohn.Forte@Sun.COM fct_status_t (*port_deregister_remote_port)( 2447836SJohn.Forte@Sun.COM struct fct_local_port *port, struct fct_remote_port *rp); 2457836SJohn.Forte@Sun.COM fct_status_t (*port_send_cmd)(fct_cmd_t *cmd); 2467836SJohn.Forte@Sun.COM fct_status_t (*port_xfer_scsi_data)(fct_cmd_t *cmd, 2477836SJohn.Forte@Sun.COM stmf_data_buf_t *dbuf, uint32_t flags); 2487836SJohn.Forte@Sun.COM fct_status_t (*port_send_cmd_response)(fct_cmd_t *cmd, 2497836SJohn.Forte@Sun.COM uint32_t ioflags); 2507836SJohn.Forte@Sun.COM fct_status_t (*port_abort_cmd)(struct fct_local_port *port, 2517836SJohn.Forte@Sun.COM fct_cmd_t *cmd, uint32_t flags); 2527836SJohn.Forte@Sun.COM void (*port_ctl)(struct fct_local_port *port, 2537836SJohn.Forte@Sun.COM int cmd, void *arg); 2547836SJohn.Forte@Sun.COM fct_status_t (*port_flogi_xchg)(struct fct_local_port *port, 2557836SJohn.Forte@Sun.COM struct fct_flogi_xchg *fx); 2567836SJohn.Forte@Sun.COM void (*port_populate_hba_details)( 2577836SJohn.Forte@Sun.COM struct fct_local_port *port, struct fct_port_attrs *port_attrs); 25810088SAllan.Ou@Sun.COM fct_status_t (*port_info)(uint32_t cmd, 25910088SAllan.Ou@Sun.COM struct fct_local_port *port, void *arg, uint8_t *buf, 26010088SAllan.Ou@Sun.COM uint32_t *bufsizep); 26110936SAllan.Ou@Sun.COM int port_fca_version; 2627836SJohn.Forte@Sun.COM } fct_local_port_t; 2637836SJohn.Forte@Sun.COM 2647836SJohn.Forte@Sun.COM /* 2657836SJohn.Forte@Sun.COM * Common struct used during FLOGI exchange. 2667836SJohn.Forte@Sun.COM */ 2677836SJohn.Forte@Sun.COM typedef struct fct_flogi_xchg { 2687836SJohn.Forte@Sun.COM uint8_t fx_op; /* ELS_OP_FLOGI or ELS_OP_ACC/RJT */ 2697836SJohn.Forte@Sun.COM uint8_t fx_rjt_reason; 2707836SJohn.Forte@Sun.COM uint8_t fx_rjt_expl; 2717836SJohn.Forte@Sun.COM uint8_t fx_sec_timeout; /* Timeout in seconds */ 2727836SJohn.Forte@Sun.COM uint32_t fx_fport:1, /* 0=N_port, 1=F_port */ 2737836SJohn.Forte@Sun.COM rsvd2:31; 2747836SJohn.Forte@Sun.COM uint32_t fx_sid; /* 24 bit SID to use */ 2757836SJohn.Forte@Sun.COM uint32_t fx_did; /* 24 bit DID to use */ 2767836SJohn.Forte@Sun.COM uint8_t fx_pwwn[8]; 2777836SJohn.Forte@Sun.COM uint8_t fx_nwwn[8]; 2787836SJohn.Forte@Sun.COM } fct_flogi_xchg_t; 2797836SJohn.Forte@Sun.COM 2807836SJohn.Forte@Sun.COM typedef struct fct_link_info { 2817836SJohn.Forte@Sun.COM uint32_t portid; 2827836SJohn.Forte@Sun.COM uint8_t port_topology; 2837836SJohn.Forte@Sun.COM uint8_t port_speed; 2847836SJohn.Forte@Sun.COM 2857836SJohn.Forte@Sun.COM uint8_t rsvd:5, 2867836SJohn.Forte@Sun.COM 2877836SJohn.Forte@Sun.COM /* 2887836SJohn.Forte@Sun.COM * FCA sets this bit to indicate that fct does not need to do FLOGI 2897836SJohn.Forte@Sun.COM * because either FCA did the FLOGI or it determined that its a private 2907836SJohn.Forte@Sun.COM * loop. Setting this bit by FCA is optional. 2917836SJohn.Forte@Sun.COM */ 2927836SJohn.Forte@Sun.COM port_no_fct_flogi:1, 2937836SJohn.Forte@Sun.COM 2947836SJohn.Forte@Sun.COM /* FCA sets this bit to indicate that it did FLOGI */ 2957836SJohn.Forte@Sun.COM port_fca_flogi_done:1, 2967836SJohn.Forte@Sun.COM 2977836SJohn.Forte@Sun.COM /* FCT sets this bit to indicate that it did FLOGI */ 2987836SJohn.Forte@Sun.COM port_fct_flogi_done:1; 2997836SJohn.Forte@Sun.COM 3007836SJohn.Forte@Sun.COM uint8_t rsvd1; 3017836SJohn.Forte@Sun.COM 3027836SJohn.Forte@Sun.COM /* The fields below are only valid if someone did a successful flogi */ 3037836SJohn.Forte@Sun.COM uint8_t port_rnwwn[8]; 3047836SJohn.Forte@Sun.COM uint8_t port_rpwwn[8]; 3057836SJohn.Forte@Sun.COM } fct_link_info_t; 3067836SJohn.Forte@Sun.COM 30710088SAllan.Ou@Sun.COM typedef struct fct_port_stat { 30810088SAllan.Ou@Sun.COM kstat_named_t link_failure_cnt; 30910088SAllan.Ou@Sun.COM kstat_named_t loss_of_sync_cnt; 31010088SAllan.Ou@Sun.COM kstat_named_t loss_of_signals_cnt; 31110088SAllan.Ou@Sun.COM kstat_named_t prim_seq_protocol_err_cnt; 31210088SAllan.Ou@Sun.COM kstat_named_t invalid_tx_word_cnt; 31310088SAllan.Ou@Sun.COM kstat_named_t invalid_crc_cnt; 31410088SAllan.Ou@Sun.COM } fct_port_stat_t; 31510088SAllan.Ou@Sun.COM 3167836SJohn.Forte@Sun.COM /* 3177836SJohn.Forte@Sun.COM * port topology 3187836SJohn.Forte@Sun.COM */ 3197836SJohn.Forte@Sun.COM #define PORT_TOPOLOGY_UNKNOWN 0 3207836SJohn.Forte@Sun.COM #define PORT_TOPOLOGY_PT_TO_PT 1 3217836SJohn.Forte@Sun.COM #define PORT_TOPOLOGY_PRIVATE_LOOP 2 3227836SJohn.Forte@Sun.COM #define PORT_TOPOLOGY_PUBLIC_LOOP 6 3237836SJohn.Forte@Sun.COM #define PORT_TOPOLOGY_FABRIC_PT_TO_PT 5 3247836SJohn.Forte@Sun.COM #define PORT_TOPOLOGY_FABRIC_BIT 4 3257836SJohn.Forte@Sun.COM 3267836SJohn.Forte@Sun.COM #define PORT_FLOGI_DONE(li) (((li)->port_fca_flogi_done) || \ 3277836SJohn.Forte@Sun.COM ((li)->port_fct_flogi_done)) 3287836SJohn.Forte@Sun.COM 3297836SJohn.Forte@Sun.COM /* 3307836SJohn.Forte@Sun.COM * port speed 3317836SJohn.Forte@Sun.COM */ 3327836SJohn.Forte@Sun.COM #define PORT_SPEED_UNKNOWN 0 3337836SJohn.Forte@Sun.COM #define PORT_SPEED_1G 1 3347836SJohn.Forte@Sun.COM #define PORT_SPEED_2G 2 3357836SJohn.Forte@Sun.COM #define PORT_SPEED_4G 4 3367836SJohn.Forte@Sun.COM #define PORT_SPEED_8G 8 3379087SZhong.Wang@Sun.COM #define PORT_SPEED_10G 16 3387836SJohn.Forte@Sun.COM 3397836SJohn.Forte@Sun.COM /* 3407836SJohn.Forte@Sun.COM * Abort commands 3417836SJohn.Forte@Sun.COM */ 3427836SJohn.Forte@Sun.COM #define FCT_TERMINATE_CMD 1 3437836SJohn.Forte@Sun.COM 3447836SJohn.Forte@Sun.COM /* 3457836SJohn.Forte@Sun.COM * FCT port states. 3467836SJohn.Forte@Sun.COM */ 3477836SJohn.Forte@Sun.COM #define FCT_STATE_OFFLINE 0 3487836SJohn.Forte@Sun.COM #define FCT_STATE_ONLINING 1 3497836SJohn.Forte@Sun.COM #define FCT_STATE_ONLINE 2 3507836SJohn.Forte@Sun.COM #define FCT_STATE_OFFLINING 3 3517836SJohn.Forte@Sun.COM 3527836SJohn.Forte@Sun.COM /* 3537836SJohn.Forte@Sun.COM * fct ctl commands. These should not conflict with stmf ctl commands 3547836SJohn.Forte@Sun.COM */ 3557836SJohn.Forte@Sun.COM #define FCT_CMD_PORT_ONLINE (STMF_LPORT_CTL_CMDS | 0x01) 3567836SJohn.Forte@Sun.COM #define FCT_CMD_PORT_ONLINE_COMPLETE (STMF_LPORT_CTL_CMDS | 0x02) 3577836SJohn.Forte@Sun.COM #define FCT_CMD_PORT_OFFLINE (STMF_LPORT_CTL_CMDS | 0x03) 3587836SJohn.Forte@Sun.COM #define FCT_CMD_PORT_OFFLINE_COMPLETE (STMF_LPORT_CTL_CMDS | 0x04) 3597836SJohn.Forte@Sun.COM #define FCT_ACK_PORT_ONLINE_COMPLETE (STMF_LPORT_CTL_CMDS | 0x05) 3607836SJohn.Forte@Sun.COM #define FCT_ACK_PORT_OFFLINE_COMPLETE (STMF_LPORT_CTL_CMDS | 0x06) 36110275SReed.Liu@Sun.COM #define FCT_CMD_FORCE_LIP (STMF_LPORT_CTL_CMDS | 0x07) 3627836SJohn.Forte@Sun.COM 3637836SJohn.Forte@Sun.COM /* 3647836SJohn.Forte@Sun.COM * IO flags for cmd flow. 3657836SJohn.Forte@Sun.COM */ 3667836SJohn.Forte@Sun.COM #define FCT_IOF_FCA_DONE 0x10000 3677836SJohn.Forte@Sun.COM #define FCT_IOF_FORCE_FCA_DONE 0x20000 3687836SJohn.Forte@Sun.COM 3697836SJohn.Forte@Sun.COM /* 3707836SJohn.Forte@Sun.COM * Fill CTIU preample 3717836SJohn.Forte@Sun.COM */ 3727836SJohn.Forte@Sun.COM #ifdef lint 3737836SJohn.Forte@Sun.COM #define FCT_FILL_CTIU_PREAMPLE(x_payload, x_ctop) _NOTE(EMPTY) 3747836SJohn.Forte@Sun.COM #else 3757836SJohn.Forte@Sun.COM #define FCT_FILL_CTIU_PREAMPLE(x_payload, x_ctop) \ 3767836SJohn.Forte@Sun.COM do { \ 3777836SJohn.Forte@Sun.COM x_payload[0] = 0x02; \ 3787836SJohn.Forte@Sun.COM x_payload[4] = 0xFC; \ 3797836SJohn.Forte@Sun.COM x_payload[5] = 0x02; \ 3807836SJohn.Forte@Sun.COM x_payload[8] = 0xFF & (x_ctop >> 8); \ 3817836SJohn.Forte@Sun.COM x_payload[9] = 0xFF & (x_ctop); \ 3827836SJohn.Forte@Sun.COM } while (0) 3837836SJohn.Forte@Sun.COM #endif 3847836SJohn.Forte@Sun.COM 3857836SJohn.Forte@Sun.COM uint64_t fct_netbuf_to_value(uint8_t *buf, uint8_t nbytes); 3867836SJohn.Forte@Sun.COM void fct_value_to_netbuf(uint64_t value, uint8_t *buf, uint8_t nbytes); 3877836SJohn.Forte@Sun.COM void *fct_alloc(fct_struct_id_t struct_id, int additional_size, int flags); 3887836SJohn.Forte@Sun.COM void fct_free(void *ptr); 3897836SJohn.Forte@Sun.COM fct_cmd_t *fct_scsi_task_alloc(struct fct_local_port *port, 3907836SJohn.Forte@Sun.COM uint16_t rp_handle, uint32_t rportid, uint8_t *lun, 3917836SJohn.Forte@Sun.COM uint16_t cdb_length, uint16_t task_ext); 3927836SJohn.Forte@Sun.COM fct_status_t fct_register_local_port(fct_local_port_t *port); 3937836SJohn.Forte@Sun.COM fct_status_t fct_deregister_local_port(fct_local_port_t *port); 3947836SJohn.Forte@Sun.COM void fct_handle_event(fct_local_port_t *port, int event_id, 3957836SJohn.Forte@Sun.COM uint32_t event_flags, caddr_t arg); 3967836SJohn.Forte@Sun.COM void fct_post_rcvd_cmd(fct_cmd_t *cmd, stmf_data_buf_t *dbuf); 3977836SJohn.Forte@Sun.COM void fct_queue_cmd_for_termination(fct_cmd_t *cmd, fct_status_t s); 3987836SJohn.Forte@Sun.COM void fct_queue_scsi_task_for_termination(fct_cmd_t *cmd, fct_status_t s); 3997836SJohn.Forte@Sun.COM fct_cmd_t *fct_handle_to_cmd(fct_local_port_t *port, uint32_t fct_handle); 4007836SJohn.Forte@Sun.COM void fct_ctl(struct stmf_local_port *lport, int cmd, void *arg); 4017836SJohn.Forte@Sun.COM void fct_cmd_fca_aborted(fct_cmd_t *cmd, fct_status_t s, uint32_t ioflags); 4027836SJohn.Forte@Sun.COM uint16_t fct_get_rp_handle(fct_local_port_t *port, uint32_t rportid); 4037836SJohn.Forte@Sun.COM void fct_send_response_done(fct_cmd_t *cmd, fct_status_t s, uint32_t ioflags); 4047836SJohn.Forte@Sun.COM void fct_send_cmd_done(fct_cmd_t *cmd, fct_status_t s, uint32_t ioflags); 4057836SJohn.Forte@Sun.COM void fct_scsi_data_xfer_done(fct_cmd_t *cmd, stmf_data_buf_t *dbuf, 4067836SJohn.Forte@Sun.COM uint32_t ioflags); 4077836SJohn.Forte@Sun.COM fct_status_t fct_port_initialize(fct_local_port_t *port, uint32_t rflags, 4087836SJohn.Forte@Sun.COM char *additional_info); 4097836SJohn.Forte@Sun.COM fct_status_t fct_port_shutdown(fct_local_port_t *port, uint32_t rflags, 4107836SJohn.Forte@Sun.COM char *additional_info); 4117836SJohn.Forte@Sun.COM fct_status_t fct_handle_rcvd_flogi(fct_local_port_t *port, 4127836SJohn.Forte@Sun.COM fct_flogi_xchg_t *fx); 4137836SJohn.Forte@Sun.COM void fct_log_local_port_event(fct_local_port_t *port, char *subclass); 4147836SJohn.Forte@Sun.COM void fct_log_remote_port_event(fct_local_port_t *port, char *subclass, 4157836SJohn.Forte@Sun.COM uint8_t *rp_pwwn, uint32_t rp_id); 4169578SSam.Cramer@Sun.COM void fct_wwn_to_str(char *to_ptr, const uint8_t *from_ptr); 4177836SJohn.Forte@Sun.COM 4187836SJohn.Forte@Sun.COM #ifdef __cplusplus 4197836SJohn.Forte@Sun.COM } 4207836SJohn.Forte@Sun.COM #endif 4217836SJohn.Forte@Sun.COM 4227836SJohn.Forte@Sun.COM #endif /* _FCT_H */ 423