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

📄 iscsi_target.h

📁 iscsi源代码 UNH的progect 有initiator端和target端的源码
💻 H
字号:
/*	target/iscsi_target.h	vi: set autoindent tabstop=8 shiftwidth=8 :	header file for the iSCSI Target*//*	Copyright (C) 2001-2003 InterOperability Lab (IOL)					University of New Hampshier (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	_ISCSI_TARGET_H#define	_ISCSI_TARGET_H#include "scsi_target.h"#include <linux/proc_fs.h>#include "../common/iscsi_common.h"#include "../common/debug.h"#include "../common/my_memory.h"#include "../common/range.h"#include "../common/crc.h"#include "../common/tcp_utilities.h"/* chap and srp support - CHONG */#include "../security/misc/misc_func.h"#include "../security/chap/chap.h"#include "../security/srp/srp.h"#include "../common/text_param.h"#include "../common/target_negotiate.h"#include "iscsi_portal_group.h"struct data_list{	__u32 offset;	__u32 length;	char *buffer;	struct data_list *next;};/* values for "state" in struct iscsi_cmnd */#define ISCSI_CMND_RECEIVED			1#define ISCSI_NEW_CMND				2#define ISCSI_BUFFER_RDY			3#define ISCSI_DONE				4#define ISCSI_SENT				5#define ISCSI_DEQUEUE				6#define ISCSI_ALL_R2TS_SENT			7#define ISCSI_IMMEDIATE_DATA_IN			8#define ISCSI_UNSOLICITED_DATA_IN		9#define ISCSI_DATA_IN				10#define ISCSI_MGT_FN_DONE			11#define ISCSI_SEND_TEXT_RESPONSE		12#define ISCSI_LOGOUT				13#define ISCSI_PING				14#define ISCSI_QUEUE_CMND			15#define ISCSI_QUEUE_CMND_RDY			16#define ISCSI_QUEUE_OTHER			17#define ISCSI_NOPIN_SENT			18#define ISCSI_RESEND_STATUS			19#define ISCSI_ASK_FOR_MORE_TEXT			20#define ISCSI_AWAIT_MORE_TEXT			21#define ISCSI_BLOCKED_SENDING_TEXT		22/* stores everything related to a SCSI command received */struct iscsi_cmnd{  /* next: pointer to the next command in the list */  struct iscsi_cmnd	*next;  /* conn: connection on which this command was received */  struct iscsi_conn	*conn;  /* session: session on which this command was received */  struct iscsi_session	*session;  /* unsolicited_data_sem: to control receiving immediate data */  struct semaphore    	unsolicited_data_sem;  /* state: execution state of the command */  __u8			state;  /* response: task_mgt_function response */  __u8			response;  /* flag for errorRecovery of r2t */  __u8 			recovery_r2t;  /* flags from command pdu */  __u8			command_flags;  /* ping_data: data get from nopout and send for nopin */  char			*ping_data;  /* in_progress_buffer: accumulated data during text negotiations */  char			*in_progress_buffer;  /* cmnd: cmnd corresponding to this struct */  Target_Scsi_Cmnd	*cmnd;  /* message: message corresponding to this struct */  Target_Scsi_Message 	*message;  /* immediate_data_present: */  __u8    		immediate_data_present;  /* unsolicited_data_present: */  __u8    		unsolicited_data_present;  /* Data PDU re-transmission on Data SNACK - SAI */  __u8                  retransmit_flg;  /* opcode_byte: command's opcode byte (including I bit) */  __u8                  opcode_byte;  /* data_length: total number of bytes of data to be transferred by command */  __u32			data_length;  /* first_burst_size: data associated with the command */  __u32			first_burst_len;  /* max_burst_size: data associated with one R2T */  __u32			next_burst_len;  /* data_done: number of bytes of data transferred so far in a command */  __u32			data_done;  /* r2t_data_total: total amount of data to be solicited by r2ts */  int			r2t_data_total;  /* r2t_data: data_length_left for the next r2t -- can go negative! */  int			r2t_data;  /* scatter_list_offset:when processing a WRITE command, is byte offset in   *			 current sg list item of where to start storing next   *			 data byte from a DataOut pdu if pdus, seqs are in order   *			 when processing a READ command, is byte offset in   *			 current sg list iemt of where to start sending next   *			 data byte in a DataOut pdu if pdus, seqs are in order   */  __u32           	scatter_list_offset;  /* scatter_entry_count:when processing a WRITE command, is index into   *			 current sg list of item of where to start storing next   *			 data byte from a DataOut pdu if pdus, seqs are in order   *			 when processing a READ command, is byte offset in   *			 current sg list item of where to start sending next   *			 data byte in a DataOut pdu if pdus, seqs are in order   */  __u32           	scatter_list_count;  /* init_task_tag: Initiator Tag */  __u32			init_task_tag;  /* target_xfer_tag: Target Assigned Tag */  __u32			target_xfer_tag;  /* ref_task_tag: Referenced Task Tag used when aborting tasks*/  __u32           	ref_task_tag;  /* ref_cmd_sn: Referenced command sn used when aborting command*/  __u32           	ref_cmd_sn;  /* ref_function: Referenced function for task management */  __u32			ref_function;  /* ref_task_lun: Referenced Task lun used when aborting luns*/  __u64           	ref_task_lun;  /* lun and cdb: as their name mean */  __u64   lun;  __u8    cdb[16];	  /* cmd_sn of this command and stat_sn of this command response */  __u32			cmd_sn;  __u32			stat_sn;  __u32			cmd_sn_increment;   /* used by SCSI Command pdus only */  /* Command WIDE COUNTERS: data_sn and r2t_sn */  __u32			data_sn;  __u32			r2t_sn;  __u32			outstanding_r2t;  /* for out-of-order sequence and DataOut PDUs */  struct order_range      seq_range_list;  struct order_range      pdu_range_list;        /* for out-of-order command */  __u8			 hdr[ISCSI_HDR_LEN];  struct data_list	*unsolicited_data_head;  struct data_list	*unsolicited_data_tail;  /* Added r2t cookie details - SAI */  struct iscsi_cookie	*first_r2t_cookie;  struct iscsi_cookie	*last_r2t_cookie;  /* queue out-of-order data pdus - SAI */  struct iscsi_cookie	*first_data_q;  struct iscsi_cookie	*last_data_q;  /* Added timestamp for r2t retransmissions - SAI */  int		timestamp;  /* Store the previously sent data_sn, used when retransmit_flg set */  __u32		prev_data_sn;  /* Store the retransmission limits for data_sn set by a SNACK,   * used when retransmit_flg set */  __u32		startsn, endsn;};extern struct iscsi_global *devdata;int	iscsi_detect		(Scsi_Target_Template*);int	iscsi_release		(Scsi_Target_Device*);int	iscsi_xmit_response	(Target_Scsi_Cmnd*);int	iscsi_rdy_to_xfer	(Target_Scsi_Cmnd*);int 	iscsi_proc_info		(char *, char **, off_t, int, int, int);void 	iscsi_task_mgt_fn_done 	(Target_Scsi_Message *msg);int	iscsi_server_thread (void*);int	iscsi_rx_thread	(void*);int	iscsi_tx_thread (void*);    #define PDU_SENSE_LENGTH_SIZE 2#define SENSE_STRUCTURE_SIZE 18/* * executed only by the rx thread, in spite of the tx in the name! * iscsi_tx_reject: this function transmits a reject to the Initiator * the attached 48-byte data segment is the header of the rejected PDU * OUTPUT: 0 if everything is okay, < 0 if there is trouble */intiscsi_tx_rjt(struct iscsi_conn *conn, __u8 *bad_hdr, __u8 reason);/* * executed only by the rx thread. * Allocates new reject item, fills it in with header of rejected pdu, * and enqueues it for tx thread on reject_list of this connection. */intenqueue_reject(struct iscsi_conn *conn, __u8 reason);/* * find_iovec_needed: this function returns the number of iovecs that * are needed to receive some data * INPUT: amount of data needed, pointer to scattergather list (from the * 	  point where the data is to start for this round, offset within * 	  the first scattergather element - in case it was not used up * 	  completely * OUTPUT: number of iovectors needed, else < 0 if there is trouble */int __attribute__ ((no_instrument_function))find_iovec_needed (__u32 data_len, 	struct scatterlist *st_list, __u32 offset);/* * fill_iovec: This function fills in a given iovec structure so as to * reflect a given scattergather list upto the length that is required * No checks are made on the length on the iovec given except that it * needs to be greater than the size needed. Also, the scatterlist is * also not checked. The integer offset upon return reflects the posn of * the offset in the last scatterlist that was used for this function * INPUT: struct iovec, no. of iovecs, scatterlist, ptr to offset within * 	  the first element, and the total length required * OUTPUT: how many st_list elements are used, < 0 if there is trouble */int __attribute__ ((no_instrument_function))fill_iovec (struct iovec *iov, int i, int niov,        struct scatterlist *st_list, int *offset, __u32 data);/* * iscsi_rx_data: will receive a fixed amount of data. * INPUT: struct iscsi_conn (what connection), struct iovec, number of iovecs, * total amount of data in bytes * OUTPUT: int total bytes read if everything is okay * 	       < 0 if trouble */int iscsi_rx_data (struct iscsi_conn *conn, struct iovec *iov, int niov, int data);/* * iscsi_tx_data: will transmit a fixed amount of data. * INPUT: struct iscsi_conn (what connection), struct iovec, number of iovecs, * total amount of data in bytes, * OUTPUT: int total bytes read if everything is okay * 	       < 0 if trouble */int iscsi_tx_data (struct iscsi_conn *conn, struct iovec *iov, int niov, int data);				#endif

⌨️ 快捷键说明

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