110365e5aSMatt Jacob /* $FreeBSD$ */ 210365e5aSMatt Jacob /*- 32df76c16SMatt Jacob * Copyright (c) 1997-2009 by Matthew Jacob 410365e5aSMatt Jacob * All rights reserved. 510365e5aSMatt Jacob * 610365e5aSMatt Jacob * Redistribution and use in source and binary forms, with or without 710365e5aSMatt Jacob * modification, are permitted provided that the following conditions 810365e5aSMatt Jacob * are met: 910365e5aSMatt Jacob * 10e48b2487SMatt Jacob * 1. Redistributions of source code must retain the above copyright 11e48b2487SMatt Jacob * notice, this list of conditions and the following disclaimer. 12e48b2487SMatt Jacob * 2. Redistributions in binary form must reproduce the above copyright 13e48b2487SMatt Jacob * notice, this list of conditions and the following disclaimer in the 14e48b2487SMatt Jacob * documentation and/or other materials provided with the distribution. 15e48b2487SMatt Jacob * 16e48b2487SMatt Jacob * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1710365e5aSMatt Jacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1810365e5aSMatt Jacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19e48b2487SMatt Jacob * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 20e48b2487SMatt Jacob * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2110365e5aSMatt Jacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2210365e5aSMatt Jacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2310365e5aSMatt Jacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2410365e5aSMatt Jacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2510365e5aSMatt Jacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2610365e5aSMatt Jacob * SUCH DAMAGE. 272df76c16SMatt Jacob * 2810365e5aSMatt Jacob */ 2910365e5aSMatt Jacob /* 3010365e5aSMatt Jacob * Structures that derive directly from public standards. 3110365e5aSMatt Jacob */ 3210365e5aSMatt Jacob #ifndef _ISP_STDS_H 3310365e5aSMatt Jacob #define _ISP_STDS_H 3410365e5aSMatt Jacob 3510365e5aSMatt Jacob /* 3610365e5aSMatt Jacob * FC Frame Header 3710365e5aSMatt Jacob * 3810365e5aSMatt Jacob * Source: dpANS-X3.xxx-199x, section 18 (AKA FC-PH-2) 3910365e5aSMatt Jacob * 4010365e5aSMatt Jacob */ 4110365e5aSMatt Jacob typedef struct { 4210365e5aSMatt Jacob uint8_t r_ctl; 4310365e5aSMatt Jacob uint8_t d_id[3]; 4410365e5aSMatt Jacob uint8_t cs_ctl; 4510365e5aSMatt Jacob uint8_t s_id[3]; 4610365e5aSMatt Jacob uint8_t type; 472df76c16SMatt Jacob uint8_t f_ctl[3]; 4810365e5aSMatt Jacob uint8_t seq_id; 4910365e5aSMatt Jacob uint8_t df_ctl; 5010365e5aSMatt Jacob uint16_t seq_cnt; 5110365e5aSMatt Jacob uint16_t ox_id; 5210365e5aSMatt Jacob uint16_t rx_id; 5310365e5aSMatt Jacob uint32_t parameter; 5410365e5aSMatt Jacob } fc_hdr_t; 5510365e5aSMatt Jacob 5610365e5aSMatt Jacob /* 5710365e5aSMatt Jacob * FCP_CMND_IU Payload 5810365e5aSMatt Jacob * 5910365e5aSMatt Jacob * Source: NICTS T10, Project 1144D, Revision 07a, Section 9 (AKA fcp2-r07a) 6010365e5aSMatt Jacob * 6110365e5aSMatt Jacob * Notes: 6210365e5aSMatt Jacob * When additional cdb length is defined in fcp_cmnd_alen_datadir, 6310365e5aSMatt Jacob * bits 2..7, the actual cdb length is 16 + ((fcp_cmnd_alen_datadir>>2)*4), 6410365e5aSMatt Jacob * with the datalength following in MSB format just after. 6510365e5aSMatt Jacob */ 6610365e5aSMatt Jacob typedef struct { 6710365e5aSMatt Jacob uint8_t fcp_cmnd_lun[8]; 6810365e5aSMatt Jacob uint8_t fcp_cmnd_crn; 6910365e5aSMatt Jacob uint8_t fcp_cmnd_task_attribute; 7010365e5aSMatt Jacob uint8_t fcp_cmnd_task_management; 7110365e5aSMatt Jacob uint8_t fcp_cmnd_alen_datadir; 7210365e5aSMatt Jacob union { 7310365e5aSMatt Jacob struct { 7410365e5aSMatt Jacob uint8_t fcp_cmnd_cdb[16]; 7510365e5aSMatt Jacob uint32_t fcp_cmnd_dl; 7610365e5aSMatt Jacob } sf; 7710365e5aSMatt Jacob struct { 7810365e5aSMatt Jacob uint8_t fcp_cmnd_cdb[1]; 7910365e5aSMatt Jacob } lf; 8010365e5aSMatt Jacob } cdb_dl; 8110365e5aSMatt Jacob } fcp_cmnd_iu_t; 8210365e5aSMatt Jacob 8310365e5aSMatt Jacob 8410365e5aSMatt Jacob #define FCP_CMND_TASK_ATTR_SIMPLE 0x00 8510365e5aSMatt Jacob #define FCP_CMND_TASK_ATTR_HEAD 0x01 8610365e5aSMatt Jacob #define FCP_CMND_TASK_ATTR_ORDERED 0x02 8710365e5aSMatt Jacob #define FCP_CMND_TASK_ATTR_ACA 0x04 8810365e5aSMatt Jacob #define FCP_CMND_TASK_ATTR_UNTAGGED 0x05 8910365e5aSMatt Jacob #define FCP_CMND_TASK_ATTR_MASK 0x07 9010365e5aSMatt Jacob 9110365e5aSMatt Jacob #define FCP_CMND_ADDTL_CDBLEN_SHIFT 2 9210365e5aSMatt Jacob 9310365e5aSMatt Jacob #define FCP_CMND_DATA_WRITE 0x01 9410365e5aSMatt Jacob #define FCP_CMND_DATA_READ 0x02 9510365e5aSMatt Jacob 9610365e5aSMatt Jacob #define FCP_CMND_DATA_DIR_MASK 0x03 9710365e5aSMatt Jacob 9810365e5aSMatt Jacob #define FCP_CMND_TMF_CLEAR_ACA 0x40 9910365e5aSMatt Jacob #define FCP_CMND_TMF_TGT_RESET 0x20 10010365e5aSMatt Jacob #define FCP_CMND_TMF_LUN_RESET 0x10 10110365e5aSMatt Jacob #define FCP_CMND_TMF_CLEAR_TASK_SET 0x04 10210365e5aSMatt Jacob #define FCP_CMND_TMF_ABORT_TASK_SET 0x02 10310365e5aSMatt Jacob 10410365e5aSMatt Jacob /* 10510365e5aSMatt Jacob * Basic CT IU Header 10610365e5aSMatt Jacob * 10710365e5aSMatt Jacob * Source: X3.288-199x Generic Services 2 Rev 5.3 (FC-GS-2) Section 4.3.1 10810365e5aSMatt Jacob */ 10910365e5aSMatt Jacob 11010365e5aSMatt Jacob typedef struct { 11110365e5aSMatt Jacob uint8_t ct_revision; 11210365e5aSMatt Jacob uint8_t ct_in_id[3]; 11310365e5aSMatt Jacob uint8_t ct_fcs_type; 11410365e5aSMatt Jacob uint8_t ct_fcs_subtype; 11510365e5aSMatt Jacob uint8_t ct_options; 11610365e5aSMatt Jacob uint8_t ct_reserved0; 11710365e5aSMatt Jacob uint16_t ct_cmd_resp; 11810365e5aSMatt Jacob uint16_t ct_bcnt_resid; 11910365e5aSMatt Jacob uint8_t ct_reserved1; 12010365e5aSMatt Jacob uint8_t ct_reason; 12110365e5aSMatt Jacob uint8_t ct_explanation; 12210365e5aSMatt Jacob uint8_t ct_vunique; 12310365e5aSMatt Jacob } ct_hdr_t; 12410365e5aSMatt Jacob #define CT_REVISION 1 12510365e5aSMatt Jacob #define CT_FC_TYPE_FC 0xFC 12610365e5aSMatt Jacob #define CT_FC_SUBTYPE_NS 0x02 12710365e5aSMatt Jacob 12810365e5aSMatt Jacob /* 12910365e5aSMatt Jacob * RFT_ID Requet CT_IU 13010365e5aSMatt Jacob * 131f7c631bcSMatt Jacob * Source: NCITS xxx-200x Generic Services- 5 Rev 8.5 Section 5.2.5.30 13210365e5aSMatt Jacob */ 13310365e5aSMatt Jacob typedef struct { 13410365e5aSMatt Jacob ct_hdr_t rftid_hdr; 13510365e5aSMatt Jacob uint8_t rftid_reserved; 13610365e5aSMatt Jacob uint8_t rftid_portid[3]; 13710365e5aSMatt Jacob uint32_t rftid_fc4types[8]; 13810365e5aSMatt Jacob } rft_id_t; 13910365e5aSMatt Jacob 140f7c631bcSMatt Jacob /* 1412df76c16SMatt Jacob * FCP Response IU Bits of interest 1422df76c16SMatt Jacob * Source: NCITS T10, Project 1144D, Revision 08 (aka FCP2r08) 1432df76c16SMatt Jacob */ 1442df76c16SMatt Jacob #define FCP_CONF_REQ 0x10 1452df76c16SMatt Jacob #define FCP_RESID_UNDERFLOW 0x08 1462df76c16SMatt Jacob #define FCP_RESID_OVERFLOW 0x04 1472df76c16SMatt Jacob #define FCP_SNSLEN_VALID 0x02 1482df76c16SMatt Jacob #define FCP_RSPLEN_VALID 0x01 1492df76c16SMatt Jacob 1502df76c16SMatt Jacob /* 151f7c631bcSMatt Jacob * FCP Response Code Definitions 1522df76c16SMatt Jacob * Source: NCITS T10, Project 1144D, Revision 08 (aka FCP2r08) 153f7c631bcSMatt Jacob */ 154f7c631bcSMatt Jacob #define FCP_RSPNS_CODE_OFFSET 3 155f7c631bcSMatt Jacob 156f7c631bcSMatt Jacob #define FCP_RSPNS_TMF_DONE 0 157f7c631bcSMatt Jacob #define FCP_RSPNS_DLBRSTX 1 158f7c631bcSMatt Jacob #define FCP_RSPNS_BADCMND 2 159f7c631bcSMatt Jacob #define FCP_RSPNS_EROFS 3 160f7c631bcSMatt Jacob #define FCP_RSPNS_TMF_REJECT 4 161f7c631bcSMatt Jacob #define FCP_RSPNS_TMF_FAILED 5 162f7c631bcSMatt Jacob 16310365e5aSMatt Jacob 16410365e5aSMatt Jacob /* unconverted miscellany */ 16510365e5aSMatt Jacob /* 16610365e5aSMatt Jacob * Basic FC Link Service defines 16710365e5aSMatt Jacob */ 16810365e5aSMatt Jacob /* 16910365e5aSMatt Jacob * These are in the R_CTL field. 17010365e5aSMatt Jacob */ 17110365e5aSMatt Jacob #define ABTS 0x81 17210365e5aSMatt Jacob #define BA_ACC 0x84 /* of ABORT SEQUENCE */ 17310365e5aSMatt Jacob #define BA_RJT 0x85 /* of ABORT SEQUENCE */ 17410365e5aSMatt Jacob 17510365e5aSMatt Jacob /* 17610365e5aSMatt Jacob * Link Service Accept/Reject 17710365e5aSMatt Jacob */ 17810365e5aSMatt Jacob #define LS_ACC 0x8002 17910365e5aSMatt Jacob #define LS_RJT 0x8001 18010365e5aSMatt Jacob 18110365e5aSMatt Jacob /* 18210365e5aSMatt Jacob * FC ELS Codes- bits 31-24 of the first payload word of an ELS frame. 18310365e5aSMatt Jacob */ 18410365e5aSMatt Jacob #define PLOGI 0x03 18510365e5aSMatt Jacob #define FLOGI 0x04 18610365e5aSMatt Jacob #define LOGO 0x05 18710365e5aSMatt Jacob #define ABTX 0x06 18810365e5aSMatt Jacob #define PRLI 0x20 18910365e5aSMatt Jacob #define PRLO 0x21 1902df76c16SMatt Jacob #define SCN 0x22 19110365e5aSMatt Jacob #define TPRLO 0x24 1922df76c16SMatt Jacob #define PDISC 0x50 1932df76c16SMatt Jacob #define ADISC 0x52 19410365e5aSMatt Jacob #define RNC 0x53 19510365e5aSMatt Jacob 19610365e5aSMatt Jacob /* 19710365e5aSMatt Jacob * FC4 defines 19810365e5aSMatt Jacob */ 19910365e5aSMatt Jacob #define FC4_IP 5 /* ISO/EEC 8802-2 LLC/SNAP */ 20010365e5aSMatt Jacob #define FC4_SCSI 8 /* SCSI-3 via Fibre Channel Protocol (FCP) */ 20110365e5aSMatt Jacob #define FC4_FC_SVC 0x20 /* Fibre Channel Services */ 20210365e5aSMatt Jacob 20310365e5aSMatt Jacob #ifndef MSG_ABORT 20410365e5aSMatt Jacob #define MSG_ABORT 0x06 20510365e5aSMatt Jacob #endif 20610365e5aSMatt Jacob #ifndef MSG_BUS_DEV_RESET 20710365e5aSMatt Jacob #define MSG_BUS_DEV_RESET 0x0c 20810365e5aSMatt Jacob #endif 20910365e5aSMatt Jacob #ifndef MSG_ABORT_TAG 21010365e5aSMatt Jacob #define MSG_ABORT_TAG 0x0d 21110365e5aSMatt Jacob #endif 21210365e5aSMatt Jacob #ifndef MSG_CLEAR_QUEUE 21310365e5aSMatt Jacob #define MSG_CLEAR_QUEUE 0x0e 21410365e5aSMatt Jacob #endif 21510365e5aSMatt Jacob #ifndef MSG_REL_RECOVERY 21610365e5aSMatt Jacob #define MSG_REL_RECOVERY 0x10 21710365e5aSMatt Jacob #endif 21810365e5aSMatt Jacob #ifndef MSG_TERM_IO_PROC 21910365e5aSMatt Jacob #define MSG_TERM_IO_PROC 0x11 22010365e5aSMatt Jacob #endif 22110365e5aSMatt Jacob #ifndef MSG_LUN_RESET 22210365e5aSMatt Jacob #define MSG_LUN_RESET 0x17 22310365e5aSMatt Jacob #endif 22410365e5aSMatt Jacob 22510365e5aSMatt Jacob #endif /* _ISP_STDS_H */ 226