⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scsi_target.h

📁 iscsi源代码 UNH的progect 有initiator端和target端的源码
💻 H
📖 第 1 页 / 共 2 页
字号:
/*	target/scsi_target.h *//*	Copyright (C) 2001-2004 InterOperability Lab (IOL)				University of New Hampshire (UNH)				Durham, NH 03824	This program is free software; you can redistribute it and/or modify	it under the terms of the GNU General Public License as published by	the Free Software Foundation; either version 2, or (at your option)	any later version.	This program is distributed in the hope that it will be useful,	but WITHOUT ANY WARRANTY; without even the implied warranty of	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the	GNU General Public License for more details.	You should have received a copy of the GNU General Public License	along with this program; if not, write to the Free Software	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,	USA.	The name of IOL and/or UNH may not be used to endorse or promote	products derived from this software without specific prior	written permission.*/#ifndef _SCSI_TARGET_H#define _SCSI_TARGET_H#include <asm/uaccess.h>/* RDR */#ifndef K26#include <linux/blk.h>#endif#include <linux/version.h>#include <linux/blkdev.h>#include <linux/config.h>#include <linux/delay.h>#include <linux/dnotify.h>#include <linux/file.h>#include <linux/fs.h>#include <linux/in.h>#include <linux/init.h>#include <linux/ioport.h>#include <linux/kernel.h>#include <linux/module.h>#include <linux/pci.h>#include <linux/sched.h>#include <linux/smp_lock.h>#include <linux/spinlock.h>#include <linux/string.h>#include <linux/types.h>#include <linux/unistd.h>#include <scsi/sg.h>#include <scsi.h>#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 8)#include <hosts.h>#else#include <scsi/scsi_host.h>#endif#ifdef 	DEBUG_TARGET#define debugInit(x...)	printk (x) //printk (##x)#else#define	debugInit(x...)#endif/* MODES OF OPERATION *///#define MEMORYIO		/* for performance studies *//* Ming Zhang, mingz@ele.uri.edu *//* In the 2.6 kernel, you need to add EXPORT_SYMBOL(scsi_bus_type) * to /drivers/scsi/scsi_sysfs.c and recompile the kernel in order to * use DISKIO mode *///#define DISKIO		/* to a real disk */#define FILEIO		/* to a file on the system *///#define GENERICIO		/* when the scsi_do_req is not working */#define TRUST_CDB/* Magic Numbers */#define	BLOCKSIZE	512//#define	BLOCKSIZE	1024//#define	BLOCKSIZE	2048//#define	BLOCKSIZE	4096#define	TWOBYTE		16#define	BYTE		8#define	FILESIZE	(4096 * 1024)	/* file size in blocks */#define IO_SIGS		(sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGIO))#define	MAX_SENSE_DATA	16#define SHUTDOWN_SIGS	(sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGTERM))#define	TE_TRY		1#define	TE_TIMEOUT	10*HZ#define R_BIT		0x40#define W_BIT		0x20#define	MAX_LUNS	16#define	MAX_TARGETS	16/* undefined scsi opcode */#define	REPORT_LUNS	0xa0/* various possible states of commands - state in Target_Scsi_Cmnd */#define	ST_NEW_CMND	1 /* command just arrived */#define	ST_PROCESSING	2 /* sent off to process */#define	ST_PENDING	3 /* waiting to get data */#define	ST_TO_PROCESS	4 /* command ready to process */#define	ST_DONE		5 /* response to command received */#define	ST_DEQUEUE	6 /* front end done with command */#define	ST_XFERRED	7 /* notified front end of buffers */#define	ST_HANDED	8 /* command given to front end */#define	ST_PROCESSED	9 /* SIGIO has been received *//* values for abort code */#define	CMND_OPEN	0 /* Normal state of command */#define	CMND_ABORTED	1 /* ABORT received for this command */#define	CMND_RELEASED	2 /* No response needed for this cmnd *//* Values for management functions from * RFC 3720 Section 10.5.1 Function (field in TMF Request) * * N.B. These definitions are duplicated in common/iscsi_common.h * because they are needed in iSCSI but that common file cannot be * included in this file (scsi_target.h) */#define	TMF_ABORT_TASK			1	/*1000*/#define	TMF_ABORT_TASK_SET		2	/*1001*/#define	TMF_CLEAR_ACA			3	/*1002*/#define	TMF_CLEAR_TASK_SET		4	/*1003*/#define	TMF_LUN_RESET			5	/*1004*/#define	TMF_TARGET_WARM_RESET		6	/*1005*/#define TMF_TARGET_COLD_RESET		7#define TMF_TASK_REASSIGN		8/* command response lengths */#define	READ_CAP_LEN	8#define	ALLOC_LEN_6	4#define	ALLOC_LEN_10	7#define	LBA_POSN_10	2/* variable definitions */struct GTE;struct SC;struct SM;struct STD;struct STT;typedef struct SM {	/* next: pointer to the next message */	struct SM	*next;	/* prev: pointer to the previous message */	struct SM	*prev;	/* message: Task Management function received */	int		message;	/* device: device that received the Task Management function */	struct STD	*device;	/* value: value relevant to the function, if any */	void		*value;} Target_Scsi_Message;typedef struct SC {	/*	 * This will take different values depending on what the present	 * condition of the command is	 */	int		state;	/* abort_code: is this command aborted, released, or open */	int		abort_code;	/* id: id used to refer to the command */	int		id;	/* dev_id: device id - front end id that received the command */	__u64		dev_id;	/* device: struct corresponding to device - may not be needed */	struct STD	*device;	/* target_id: scsi id that received this command */	__u32		target_id;	 /* lun: which lun was supposed to get this command */	__u32		lun;	/* cmd: array for command until req is allocated */	unsigned char	cmd[MAX_COMMAND_SIZE];	/* len: length of the command received */	int		len;	/*	 * queue of Scsi commands	 */	/* link: thread to link this command onto the cmd_queue */	struct list_head link;	/* req: this is the SCSI request for the Scsi Command */	Scsi_Request	*req;#ifdef GENERICIO	/* sg: this is what Scsi generic will use to do I/O */	sg_io_hdr_t	*sg;	/* fd: "file descriptor" required for this command */	struct file	*fd;	/* blk_size: number of bytes in one block */	__u32		blk_size;#endif#ifdef FILEIO	/* fd: "file descriptor" required for this command */	struct file	*fd;#endif	/*	 ramesh@global.com	 added data length and flags fields. the values are	 get assigned from the pdu that is received	*/	int datalen;	int flags;} Target_Scsi_Cmnd;/* * Scsi_Target_Template: defines what functions the added front end will * have to provide in order to work with the Target mid-level. The * comments should make each field clearer. MUST HAVEs define functions that * I expect to be there in order to work. OPTIONAL says you have a choice. * Also, pay attention to the fact that a command is BLOCKING or NON-BLOCKING * Although I do not know the effect of this requirement on the code - it * most certainly is required for efficient functioning. */typedef struct STT{	/* private: */	/*	 * Do not bother to touch any one of these -- the only thing	 * that should have access to these is the mid-level - If you	 * change stuff here, I assume you know what you are doing :-)	 */	struct  STT *next;	/* next one in the list */	int	device_usage;	/* how many are using this Template */	/* public: */    /*

⌨️ 快捷键说明

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