isp_stds.h revision 163899
160484Sobrien/* $FreeBSD: head/sys/dev/isp/isp_stds.h 163899 2006-11-02 03:21:32Z mjacob $ */
260484Sobrien/*-
360484Sobrien * Mailbox and Queue Entry Definitions for for Qlogic ISP SCSI adapters.
460484Sobrien *
560484Sobrien * Copyright (c) 1997-2006 by Matthew Jacob
677298Sobrien * All rights reserved.
777298Sobrien *
877298Sobrien * Redistribution and use in source and binary forms, with or without
960484Sobrien * modification, are permitted provided that the following conditions
1060484Sobrien * are met:
1160484Sobrien * 1. Redistributions of source code must retain the above copyright
1260484Sobrien *    notice immediately at the beginning of the file, without modification,
1360484Sobrien *    this list of conditions, and the following disclaimer.
1460484Sobrien * 2. The name of the author may not be used to endorse or promote products
1560484Sobrien *    derived from this software without specific prior written permission.
1660484Sobrien *
1760484Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1860484Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1977298Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2077298Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
2177298Sobrien * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2260484Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2360484Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2460484Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2560484Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2660484Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2760484Sobrien * SUCH DAMAGE.
2877298Sobrien *
2977298Sobrien */
3077298Sobrien/*
3160484Sobrien * Structures that derive directly from public standards.
3260484Sobrien */
3360484Sobrien#ifndef	_ISP_STDS_H
3460484Sobrien#define	_ISP_STDS_H
3560484Sobrien
3660484Sobrien/*
3760484Sobrien * FC Frame Header
3860484Sobrien *
3960484Sobrien * Source: dpANS-X3.xxx-199x, section 18 (AKA FC-PH-2)
4060484Sobrien *
4160484Sobrien */
4260484Sobrientypedef struct {
4360484Sobrien	uint8_t		r_ctl;
4460484Sobrien	uint8_t		d_id[3];
4560484Sobrien	uint8_t		cs_ctl;
4660484Sobrien	uint8_t		s_id[3];
4760484Sobrien	uint8_t		type;
4860484Sobrien	uint8_t		f_ctl;
4977298Sobrien	uint8_t		seq_id;
5077298Sobrien	uint8_t		df_ctl;
5177298Sobrien	uint16_t	seq_cnt;
5260484Sobrien	uint16_t	ox_id;
5360484Sobrien	uint16_t	rx_id;
5460484Sobrien	uint32_t	parameter;
5560484Sobrien} fc_hdr_t;
5660484Sobrien
5760484Sobrien/*
5860484Sobrien * FCP_CMND_IU Payload
5960484Sobrien *
6060484Sobrien * Source: NICTS T10, Project 1144D, Revision 07a, Section 9 (AKA fcp2-r07a)
6160484Sobrien *
6260484Sobrien * Notes:
6360484Sobrien *	When additional cdb length is defined in fcp_cmnd_alen_datadir,
6460484Sobrien * 	bits 2..7, the actual cdb length is 16 + ((fcp_cmnd_alen_datadir>>2)*4),
6560484Sobrien *	with the datalength following in MSB format just after.
6660484Sobrien */
6760484Sobrientypedef struct {
6860484Sobrien	uint8_t		fcp_cmnd_lun[8];
6960484Sobrien	uint8_t		fcp_cmnd_crn;
7077298Sobrien	uint8_t		fcp_cmnd_task_attribute;
7177298Sobrien	uint8_t		fcp_cmnd_task_management;
7277298Sobrien	uint8_t		fcp_cmnd_alen_datadir;
7360484Sobrien	union {
7460484Sobrien		struct {
7560484Sobrien			uint8_t		fcp_cmnd_cdb[16];
7660484Sobrien			uint32_t	fcp_cmnd_dl;
7760484Sobrien		} sf;
7860484Sobrien		struct {
7960484Sobrien			uint8_t		fcp_cmnd_cdb[1];
8060484Sobrien		} lf;
8160484Sobrien	} cdb_dl;
8260484Sobrien} fcp_cmnd_iu_t;
8360484Sobrien
8460484Sobrien
8560484Sobrien#define	FCP_CMND_TASK_ATTR_SIMPLE	0x00
8660484Sobrien#define	FCP_CMND_TASK_ATTR_HEAD		0x01
8760484Sobrien#define	FCP_CMND_TASK_ATTR_ORDERED	0x02
8860484Sobrien#define	FCP_CMND_TASK_ATTR_ACA		0x04
8960484Sobrien#define	FCP_CMND_TASK_ATTR_UNTAGGED	0x05
9060484Sobrien#define	FCP_CMND_TASK_ATTR_MASK		0x07
9160484Sobrien
9260484Sobrien#define	FCP_CMND_ADDTL_CDBLEN_SHIFT	2
9360484Sobrien
9460484Sobrien#define	FCP_CMND_DATA_WRITE		0x01
9560484Sobrien#define	FCP_CMND_DATA_READ		0x02
9660484Sobrien
9760484Sobrien#define	FCP_CMND_DATA_DIR_MASK		0x03
9860484Sobrien
9960484Sobrien#define	FCP_CMND_TMF_CLEAR_ACA		0x40
10060484Sobrien#define	FCP_CMND_TMF_TGT_RESET		0x20
10160484Sobrien#define	FCP_CMND_TMF_LUN_RESET		0x10
10260484Sobrien#define	FCP_CMND_TMF_CLEAR_TASK_SET	0x04
10360484Sobrien#define	FCP_CMND_TMF_ABORT_TASK_SET	0x02
10460484Sobrien
10560484Sobrien/*
10660484Sobrien * Basic CT IU Header
10760484Sobrien *
10860484Sobrien * Source: X3.288-199x Generic Services 2 Rev 5.3 (FC-GS-2) Section 4.3.1
10960484Sobrien */
11060484Sobrien
11160484Sobrientypedef struct {
11260484Sobrien	uint8_t		ct_revision;
11360484Sobrien	uint8_t		ct_in_id[3];
11460484Sobrien	uint8_t		ct_fcs_type;
11560484Sobrien	uint8_t		ct_fcs_subtype;
11660484Sobrien	uint8_t		ct_options;
11760484Sobrien	uint8_t		ct_reserved0;
11860484Sobrien	uint16_t	ct_cmd_resp;
11960484Sobrien	uint16_t	ct_bcnt_resid;
12060484Sobrien	uint8_t		ct_reserved1;
12160484Sobrien	uint8_t		ct_reason;
12260484Sobrien	uint8_t		ct_explanation;
12360484Sobrien	uint8_t		ct_vunique;
12460484Sobrien} ct_hdr_t;
12560484Sobrien#define	CT_REVISION		1
12660484Sobrien#define	CT_FC_TYPE_FC		0xFC
12760484Sobrien#define CT_FC_SUBTYPE_NS	0x02
12860484Sobrien
12960484Sobrien/*
13060484Sobrien * RFT_ID Requet CT_IU
13160484Sobrien *
13260484Sobrien * Source: INCITS xxx-200x Generic Services- 5 Rev 8.5 Section 5.2.5.30
13360484Sobrien */
13460484Sobrientypedef struct {
13560484Sobrien	ct_hdr_t	rftid_hdr;
13660484Sobrien	uint8_t		rftid_reserved;
13760484Sobrien	uint8_t		rftid_portid[3];
13860484Sobrien	uint32_t	rftid_fc4types[8];
13960484Sobrien} rft_id_t;
14060484Sobrien
14160484Sobrien
14260484Sobrien/* unconverted miscellany */
14360484Sobrien/*
14460484Sobrien * Basic FC Link Service defines
14560484Sobrien */
14660484Sobrien/*
14760484Sobrien * These are in the R_CTL field.
14860484Sobrien */
14960484Sobrien#define	ABTS			0x81
15060484Sobrien#define	BA_ACC			0x84	/* of ABORT SEQUENCE */
15160484Sobrien#define	BA_RJT			0x85	/* of ABORT SEQUENCE */
15260484Sobrien
15360484Sobrien/*
15460484Sobrien * Link Service Accept/Reject
15560484Sobrien */
15660484Sobrien#define	LS_ACC			0x8002
15760484Sobrien#define	LS_RJT			0x8001
15860484Sobrien
15960484Sobrien/*
16060484Sobrien * FC ELS Codes- bits 31-24 of the first payload word of an ELS frame.
16160484Sobrien */
16260484Sobrien#define	PLOGI			0x03
16360484Sobrien#define	FLOGI			0x04
16460484Sobrien#define	LOGO			0x05
16560484Sobrien#define	ABTX			0x06
16660484Sobrien#define	PRLI			0x20
16760484Sobrien#define	PRLO			0x21
16860484Sobrien#define	TPRLO			0x24
16960484Sobrien#define	RNC			0x53
17060484Sobrien
17160484Sobrien/*
17260484Sobrien * FC4 defines
17360484Sobrien */
17460484Sobrien#define	FC4_IP		5	/* ISO/EEC 8802-2 LLC/SNAP */
17560484Sobrien#define	FC4_SCSI	8	/* SCSI-3 via Fibre Channel Protocol (FCP) */
17660484Sobrien#define	FC4_FC_SVC	0x20	/* Fibre Channel Services */
17760484Sobrien
17860484Sobrien#ifndef	MSG_ABORT
17960484Sobrien#define	MSG_ABORT		0x06
18060484Sobrien#endif
18160484Sobrien#ifndef	MSG_BUS_DEV_RESET
18260484Sobrien#define	MSG_BUS_DEV_RESET	0x0c
18360484Sobrien#endif
18460484Sobrien#ifndef	MSG_ABORT_TAG
18560484Sobrien#define	MSG_ABORT_TAG		0x0d
18660484Sobrien#endif
18760484Sobrien#ifndef	MSG_CLEAR_QUEUE
18860484Sobrien#define	MSG_CLEAR_QUEUE		0x0e
18960484Sobrien#endif
19060484Sobrien#ifndef	MSG_REL_RECOVERY
19160484Sobrien#define	MSG_REL_RECOVERY	0x10
19260484Sobrien#endif
19360484Sobrien#ifndef	MSG_TERM_IO_PROC
19460484Sobrien#define	MSG_TERM_IO_PROC	0x11
19560484Sobrien#endif
19660484Sobrien#ifndef	MSG_LUN_RESET
19760484Sobrien#define	MSG_LUN_RESET		0x17
19860484Sobrien#endif
19960484Sobrien
20060484Sobrien#endif	/* _ISP_STDS_H */
20160484Sobrien