cam_ccb.h

来自「基于组件方式开发操作系统的OSKIT源代码」· C头文件 代码 · 共 837 行 · 第 1/2 页

H
837
字号
/* * Data structures and definitions for CAM Control Blocks (CCBs). * * Copyright (c) 1997, 1998 Justin T. Gibbs. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions, and the following disclaimer, *    without modification, immediately at the beginning of the file. * 2. The name of the author may not be used to endorse or promote products *    derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * *      $Id: cam_ccb.h,v 1.3.2.2 1999/05/07 00:43:02 ken Exp $ */#ifndef _CAM_CAM_CCB_H#define _CAM_CAM_CCB_H 1#include <sys/queue.h>#include <sys/cdefs.h>#ifndef KERNEL#include <sys/callout.h>#endif#include <cam/cam_debug.h>#include <cam/scsi/scsi_all.h>/* General allocation length definitions for CCB structures */#define	IOCDBLEN	CAM_MAX_CDBLEN	/* Space for CDB bytes/pointer */#define	VUHBALEN	14		/* Vendor Unique HBA length */#define	SIM_IDLEN	16		/* ASCII string len for SIM ID */#define	HBA_IDLEN	16		/* ASCII string len for HBA ID */#define	DEV_IDLEN	16		/* ASCII string len for device names */#define CCB_PERIPH_PRIV_SIZE 	2	/* size of peripheral private area */#define CCB_SIM_PRIV_SIZE 	2	/* size of sim private area *//* Struct definitions for CAM control blocks *//* Common CCB header *//* CAM CCB flags */typedef enum {	CAM_CDB_POINTER		= 0x00000001,/* The CDB field is a pointer    */	CAM_QUEUE_ENABLE	= 0x00000002,/* SIM queue actions are enabled */	CAM_CDB_LINKED		= 0x00000004,/* CCB contains a linked CDB     */	CAM_SCATTER_VALID	= 0x00000010,/* Scatter/gather list is valid  */	CAM_DIS_AUTOSENSE	= 0x00000020,/* Disable autosense feature     */	CAM_DIR_RESV		= 0x00000000,/* Data direction (00:reserved)  */	CAM_DIR_IN		= 0x00000040,/* Data direction (01:DATA IN)   */	CAM_DIR_OUT		= 0x00000080,/* Data direction (10:DATA OUT)  */	CAM_DIR_NONE		= 0x000000C0,/* Data direction (11:no data)   */	CAM_DIR_MASK		= 0x000000C0,/* Data direction Mask	      */	CAM_SOFT_RST_OP		= 0x00000100,/* Use Soft reset alternative    */	CAM_ENG_SYNC		= 0x00000200,/* Flush resid bytes on complete */	CAM_DEV_QFRZDIS		= 0x00000400,/* Disable DEV Q freezing	      */	CAM_DEV_QFREEZE		= 0x00000800,/* Freeze DEV Q on execution     */	CAM_HIGH_POWER		= 0x00001000,/* Command takes a lot of power  */	CAM_SENSE_PTR		= 0x00002000,/* Sense data is a pointer	      */	CAM_SENSE_PHYS		= 0x00004000,/* Sense pointer is physical addr*/	CAM_TAG_ACTION_VALID	= 0x00008000,/* Use the tag action in this ccb*/	CAM_PASS_ERR_RECOVER	= 0x00010000,/* Pass driver does err. recovery*/	CAM_DIS_DISCONNECT	= 0x00020000,/* Disable disconnect	      */	CAM_SG_LIST_PHYS	= 0x00040000,/* SG list has physical addrs.   */	CAM_MSG_BUF_PHYS	= 0x00080000,/* Message buffer ptr is physical*/	CAM_SNS_BUF_PHYS	= 0x00100000,/* Autosense data ptr is physical*/	CAM_DATA_PHYS		= 0x00200000,/* SG/Buffer data ptrs are phys. */	CAM_CDB_PHYS		= 0x00400000,/* CDB poiner is physical	      */	CAM_ENG_SGLIST		= 0x00800000,/* SG list is for the HBA engine *//* Phase cognizant mode flags */	CAM_DIS_AUTOSRP		= 0x01000000,/* Diable autosave/restore ptrs  */	CAM_DIS_AUTODISC	= 0x02000000,/* Disable auto disconnect	      */	CAM_TGT_CCB_AVAIL	= 0x04000000,/* Target CCB available	      */	CAM_TGT_PHASE_MODE	= 0x08000000,/* The SIM runs in phase mode    */	CAM_MSGB_VALID		= 0x20000000,/* Message buffer valid	      */	CAM_STATUS_VALID	= 0x40000000,/* Status buffer valid	      */	CAM_DATAB_VALID		= 0x80000000,/* Data buffer valid	      */	/* Host target Mode flags */	CAM_TERM_IO		= 0x20000000,/* Terminate I/O Message sup.    */	CAM_DISCONNECT		= 0x40000000,/* Disconnects are mandatory     */	CAM_SEND_STATUS		= 0x80000000,/* Send status after data phase  */} ccb_flags;/* XPT Opcodes for xpt_action */typedef enum {/* Function code flags are bits greater than 0xff */	XPT_FC_QUEUED		= 0x100,				/* Non-immediate function code */	XPT_FC_USER_CCB		= 0x200,	XPT_FC_XPT_ONLY		= 0x400,				/* Only for the transport layer device *//* Common function commands: 0x00->0x0F */	XPT_NOOP 		= 0x00,				/* Execute Nothing */	XPT_SCSI_IO		= 0x01 | XPT_FC_QUEUED,				/* Execute the requested I/O operation */	XPT_GDEV_TYPE		= 0x02,				/* Get type information for specified device */	XPT_GDEVLIST		= 0x03,				/* Get a list of peripheral devices */	XPT_PATH_INQ		= 0x04,				/* Path routing inquiry */	XPT_REL_SIMQ		= 0x05,				/* Release a frozen SIM queue */	XPT_SASYNC_CB		= 0x06,				/* Set Asynchronous Callback Parameters */	XPT_SDEV_TYPE		= 0x07,				/* Set device type information */	XPT_SCAN_BUS		= 0x08 | XPT_FC_QUEUED | XPT_FC_USER_CCB				       | XPT_FC_XPT_ONLY,				/* (Re)Scan the SCSI Bus */	XPT_DEV_MATCH		= 0x09 | XPT_FC_XPT_ONLY,				/* Get EDT entries matching the given pattern */	XPT_DEBUG		= 0x0a,				/* Turn on debugging for a bus, target or lun *//* SCSI Control Functions: 0x10->0x1F */	XPT_ABORT		= 0x10,				/* Abort the specified CCB */	XPT_RESET_BUS		= 0x11 | XPT_FC_XPT_ONLY,				/* Reset the specified SCSI bus */	XPT_RESET_DEV		= 0x12,				/* Bus Device Reset the specified SCSI device */	XPT_TERM_IO		= 0x13,				/* Terminate the I/O process */	XPT_SCAN_LUN		= 0x14 | XPT_FC_QUEUED | XPT_FC_USER_CCB				       | XPT_FC_XPT_ONLY,				/* Scan Logical Unit */	XPT_GET_TRAN_SETTINGS	= 0x15,				/*				 * Get default/user transfer settings				 * for the target				 */	XPT_SET_TRAN_SETTINGS	= 0x16,				/*				 * Set transfer rate/width				 * negotiation settings				 */	XPT_CALC_GEOMETRY	= 0x17,				/*				 * Calculate the geometry parameters for				 * a device give the sector size and				 * volume size.				 *//* HBA engine commands 0x20->0x2F */	XPT_ENG_INQ		= 0x20 | XPT_FC_XPT_ONLY,				/* HBA engine feature inquiry */	XPT_ENG_EXEC		= 0x21 | XPT_FC_QUEUED | XPT_FC_XPT_ONLY,				/* HBA execute engine request *//* Target mode commands: 0x30->0x3F */	XPT_EN_LUN		= 0x30,				/* Enable LUN as a target */	XPT_TARGET_IO		= 0x31 | XPT_FC_QUEUED,				/* Execute target I/O request */	XPT_ACCEPT_TARGET_IO	= 0x32 | XPT_FC_QUEUED | XPT_FC_USER_CCB,				/* Accept Host Target Mode CDB */	XPT_CONT_TARGET_IO	= 0x33 | XPT_FC_QUEUED,				/* Continue Host Target I/O Connection */	XPT_IMMED_NOTIFY	= 0x34 | XPT_FC_QUEUED | XPT_FC_USER_CCB,				/* Notify Host Target driver of event */	XPT_NOTIFY_ACK		= 0x35,				/* Acknowledgement of event *//* Vendor Unique codes: 0x80->0x8F */	XPT_VUNIQUE		= 0x80} xpt_opcode;#define XPT_FC_GROUP_MASK		0xF0#define XPT_FC_GROUP(op) ((op) & XPT_FC_GROUP_MASK)#define XPT_FC_GROUP_COMMON		0x00#define XPT_FC_GROUP_SCSI_CONTROL	0x10#define XPT_FC_GROUP_HBA_ENGINE	0x20#define XPT_FC_GROUP_TMODE		0x30#define XPT_FC_GROUP_VENDOR_UNIQUE	0x80typedef union {	LIST_ENTRY(ccb_hdr) le;	SLIST_ENTRY(ccb_hdr) sle;	TAILQ_ENTRY(ccb_hdr) tqe;	STAILQ_ENTRY(ccb_hdr) stqe;} camq_entry;typedef union {	void		*ptr;	u_long		field;	u_int8_t	bytes[sizeof(void *) > sizeof(u_long)			      ? sizeof(void *) : sizeof(u_long)];} ccb_priv_entry;typedef union {	ccb_priv_entry	entries[CCB_PERIPH_PRIV_SIZE];	u_int8_t	bytes[CCB_PERIPH_PRIV_SIZE * sizeof(ccb_priv_entry)];} ccb_ppriv_area;typedef union {	ccb_priv_entry	entries[CCB_SIM_PRIV_SIZE];	u_int8_t	bytes[CCB_SIM_PRIV_SIZE * sizeof(ccb_priv_entry)];} ccb_spriv_area;struct ccb_hdr {	cam_pinfo	pinfo;	/* Info for priority scheduling */	camq_entry	xpt_links;	/* For chaining in the XPT layer */		camq_entry	sim_links;	/* For chaining in the SIM layer */		camq_entry	periph_links;/* For chaining in the type driver */	u_int32_t	retry_count;	                        /* Callback on completion function */	void		(*cbfcnp)(struct cam_periph *, union ccb *);	xpt_opcode	func_code;	/* XPT function code */	u_int32_t	status;	/* Status returned by CAM subsystem */				/* Compiled path for this ccb */	struct		cam_path *path;	path_id_t	path_id;	/* Path ID for the request */	target_id_t	target_id;	/* Target device ID */	lun_id_t	target_lun;	/* Target LUN number */	u_int32_t	flags;	ccb_ppriv_area	periph_priv;	ccb_spriv_area	sim_priv;	u_int32_t	timeout;	/* Timeout value */					/* Callout handle used for timeouts */	struct		callout_handle timeout_ch;};/* Get Device Information CCB */struct ccb_getdev {	struct	  ccb_hdr ccb_h;	struct	  scsi_inquiry_data inq_data;	u_int8_t  serial_num[252];	u_int8_t  serial_num_len;	u_int8_t  pd_type;	/* returned peripheral device type */	int	  dev_openings;	/* Space left for more work on device*/		int	  dev_active;	/* Transactions running on the device */	int	  devq_openings;/* Space left for more queued work */	int	  devq_queued;	/* Transactions queued to be sent */	int	  held;		/*				 * CCBs held by peripheral drivers				 * for this device				 */	int	  maxtags;	/*				 * Boundary conditions for number of				 * tagged operations				 */	int	  mintags;};typedef enum {	CAM_GDEVLIST_LAST_DEVICE,	CAM_GDEVLIST_LIST_CHANGED,	CAM_GDEVLIST_MORE_DEVS,	CAM_GDEVLIST_ERROR} ccb_getdevlist_status_e;struct ccb_getdevlist {	struct ccb_hdr		ccb_h;	char 			periph_name[DEV_IDLEN];	u_int32_t		unit_number;	unsigned int		generation;	u_int32_t		index;	ccb_getdevlist_status_e	status;};typedef enum {	PERIPH_MATCH_NONE	= 0x000,	PERIPH_MATCH_PATH	= 0x001,	PERIPH_MATCH_TARGET	= 0x002,	PERIPH_MATCH_LUN	= 0x004,	PERIPH_MATCH_NAME	= 0x008,	PERIPH_MATCH_UNIT	= 0x010,	PERIPH_MATCH_ANY	= 0x01f} periph_pattern_flags;struct periph_match_pattern {	char			periph_name[DEV_IDLEN];	u_int32_t		unit_number;	path_id_t		path_id;	target_id_t		target_id;	lun_id_t		target_lun;	periph_pattern_flags	flags;};typedef enum {	DEV_MATCH_NONE		= 0x000,	DEV_MATCH_PATH		= 0x001,	DEV_MATCH_TARGET	= 0x002,	DEV_MATCH_LUN		= 0x004,	DEV_MATCH_INQUIRY	= 0x008,	DEV_MATCH_ANY		= 0x00f} dev_pattern_flags;struct device_match_pattern {	path_id_t				path_id;	target_id_t				target_id;	lun_id_t				target_lun;	struct scsi_static_inquiry_pattern	inq_pat;	dev_pattern_flags			flags;};typedef enum {	BUS_MATCH_NONE		= 0x000,	BUS_MATCH_PATH		= 0x001,	BUS_MATCH_NAME		= 0x002,	BUS_MATCH_UNIT		= 0x004,	BUS_MATCH_BUS_ID	= 0x008,	BUS_MATCH_ANY		= 0x00f} bus_pattern_flags;struct bus_match_pattern {	path_id_t		path_id;	char			dev_name[DEV_IDLEN];	u_int32_t		unit_number;	u_int32_t		bus_id;	bus_pattern_flags	flags;};union match_pattern {	struct periph_match_pattern	periph_pattern;	struct device_match_pattern	device_pattern;	struct bus_match_pattern	bus_pattern;};typedef enum {	DEV_MATCH_PERIPH,	DEV_MATCH_DEVICE,	DEV_MATCH_BUS} dev_match_type;struct dev_match_pattern {	dev_match_type		type;	union match_pattern	pattern;};struct periph_match_result {	char			periph_name[DEV_IDLEN];	u_int32_t		unit_number;	path_id_t		path_id;	target_id_t		target_id;	lun_id_t		target_lun;};typedef enum {	DEV_RESULT_NOFLAG		= 0x00,	DEV_RESULT_UNCONFIGURED		= 0x01} dev_result_flags;struct device_match_result {	path_id_t			path_id;	target_id_t			target_id;	lun_id_t			target_lun;	struct scsi_inquiry_data	inq_data;	dev_result_flags		flags;};struct bus_match_result {	path_id_t	path_id;	char		dev_name[DEV_IDLEN];	u_int32_t	unit_number;	u_int32_t	bus_id;};union match_result {	struct periph_match_result	periph_result;	struct device_match_result	device_result;	struct bus_match_result		bus_result;};struct dev_match_result {	dev_match_type		type;	union match_result	result;};typedef enum {	CAM_DEV_MATCH_LAST,	CAM_DEV_MATCH_MORE,	CAM_DEV_MATCH_LIST_CHANGED,	CAM_DEV_MATCH_SIZE_ERROR,	CAM_DEV_MATCH_ERROR} ccb_dev_match_status;typedef enum {	CAM_DEV_POS_NONE	= 0x000,	CAM_DEV_POS_BUS		= 0x001,	CAM_DEV_POS_TARGET	= 0x002,	CAM_DEV_POS_DEVICE	= 0x004,	CAM_DEV_POS_PERIPH	= 0x008,	CAM_DEV_POS_PDPTR	= 0x010,	CAM_DEV_POS_TYPEMASK	= 0xf00,	CAM_DEV_POS_EDT		= 0x100,	CAM_DEV_POS_PDRV	= 0x200} dev_pos_type;struct ccb_dm_cookie {	void 	*bus;	void	*target;		void	*device;	void	*periph;	void	*pdrv;};struct ccb_dev_position {	u_int			generations[4];#define	CAM_BUS_GENERATION	0x00#define CAM_TARGET_GENERATION	0x01#define CAM_DEV_GENERATION	0x02

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?