162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * This file is in the public domain.
362306a36Sopenharmony_ci */
462306a36Sopenharmony_ci#ifndef	_SCSI_SCSI_IU_H
562306a36Sopenharmony_ci#define _SCSI_SCSI_IU_H 1
662306a36Sopenharmony_ci
762306a36Sopenharmony_cistruct scsi_status_iu_header
862306a36Sopenharmony_ci{
962306a36Sopenharmony_ci	u_int8_t reserved[2];
1062306a36Sopenharmony_ci	u_int8_t flags;
1162306a36Sopenharmony_ci#define	SIU_SNSVALID 0x2
1262306a36Sopenharmony_ci#define	SIU_RSPVALID 0x1
1362306a36Sopenharmony_ci	u_int8_t status;
1462306a36Sopenharmony_ci	u_int8_t sense_length[4];
1562306a36Sopenharmony_ci	u_int8_t pkt_failures_length[4];
1662306a36Sopenharmony_ci	u_int8_t pkt_failures[1];
1762306a36Sopenharmony_ci};
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#define SIU_PKTFAIL_OFFSET(siu) 12
2062306a36Sopenharmony_ci#define SIU_PKTFAIL_CODE(siu) (scsi_4btoul((siu)->pkt_failures) & 0xFF)
2162306a36Sopenharmony_ci#define		SIU_PFC_NONE			0
2262306a36Sopenharmony_ci#define		SIU_PFC_CIU_FIELDS_INVALID	2
2362306a36Sopenharmony_ci#define		SIU_PFC_TMF_NOT_SUPPORTED	4
2462306a36Sopenharmony_ci#define		SIU_PFC_TMF_FAILED		5
2562306a36Sopenharmony_ci#define		SIU_PFC_INVALID_TYPE_CODE	6
2662306a36Sopenharmony_ci#define		SIU_PFC_ILLEGAL_REQUEST		7
2762306a36Sopenharmony_ci#define SIU_SENSE_OFFSET(siu)				\
2862306a36Sopenharmony_ci    (12 + (((siu)->flags & SIU_RSPVALID)		\
2962306a36Sopenharmony_ci	? scsi_4btoul((siu)->pkt_failures_length)	\
3062306a36Sopenharmony_ci	: 0))
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci#define	SIU_TASKMGMT_NONE		0x00
3362306a36Sopenharmony_ci#define	SIU_TASKMGMT_ABORT_TASK		0x01
3462306a36Sopenharmony_ci#define	SIU_TASKMGMT_ABORT_TASK_SET	0x02
3562306a36Sopenharmony_ci#define	SIU_TASKMGMT_CLEAR_TASK_SET	0x04
3662306a36Sopenharmony_ci#define	SIU_TASKMGMT_LUN_RESET		0x08
3762306a36Sopenharmony_ci#define	SIU_TASKMGMT_TARGET_RESET	0x20
3862306a36Sopenharmony_ci#define	SIU_TASKMGMT_CLEAR_ACA		0x40
3962306a36Sopenharmony_ci#endif /*_SCSI_SCSI_IU_H*/
40