📄 iscsi_initiator.h
字号:
/* initiator/iscsi_initiator.h * * vi: set autoindent tabstop=8 shiftwidth=8 : * * This file contains all the required header files, struct * definitions and constants for iscsi initiator code. * * 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 _ISCSI_INITIATOR_H#define _ISCSI_INITIATOR_H/* RDR */#ifndef K26#include <linux/blk.h>#endif#include <linux/version.h>#include <linux/blkdev.h>#include <linux/kernel.h>#include <linux/ctype.h>#include <linux/string.h>#include <linux/ioport.h>#include <linux/sched.h>#include <linux/types.h>#include <linux/pci.h>#include <linux/delay.h>#include <linux/unistd.h>#include <linux/smp_lock.h>#include <linux/in.h>#include <linux/inet.h>#include <net/sock.h>#include <asm/uaccess.h>#include <linux/init.h>#include <scsi.h>/* Ming Zhang, mingz@ele.uri.edu */#ifdef K26#include <scsi/scsi_device.h>#include <scsi/scsi_cmnd.h>#include <scsi/scsi.h>#else#include <sd.h>#endif#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 8)#include <hosts.h>#else#include <scsi/scsi_host.h>#endif#include <linux/module.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/initiator_negotiate.h"/* * the name of our module (driver, HBA) (OUR_NAME) * is built dynamically during the build phase */#include "version.h"/* number of seconds to wait for a task management response to an abort */#define ABORT_TIMEOUT (5 * HZ)/* maximum number of iov slots iscsi_initiator can set up for I/O */#define MAX_IOV_SLOTS 68/* maximum number of commands scsi midlevel can queue for 1 lun */#define MAX_COMMANDS_PER_LUN 8/* maximum number of targets this iscsi_initiator host will register for */#define MAX_TARGET_IDS 10/* maximum number of luns each target can handle */#define MAX_LUNS 8/* maximum number of bytes we will accept in a scsi cdb */#define MAX_CDB_LEN 16/* Multiple connections Round Robin Scheduling Scheme - SAI */#define CONN_SCHED_RR 1#define CONN_SCHED_LUN 2/* Add Maximum Connections allowed per session - SAI */#define MAX_CONNECTIONS 20/* Default (initial) settings for initiator's 6-byte ISID * RFC 3720 Section 10.12.5 ISID */#define DEFAULT_ISID_TYPE 2 /* random */#define DEFAULT_ISID_NUMBER 0x123456 /* 24-bit B&C */#define DEFAULT_ISID_QUALIFIER 0x789a /* 16-bit D *//* Holds pointer to private data part of Scsi_Host structure. * This is set up once, by iscsi_detect() * which is called when the initiator module is loaded. */extern struct iscsi_hostdata *global_hostdata;/* Holds pointer to the registered Scsi_Host. */extern struct Scsi_Host *global_host;#ifdef UNH_LOCK_DEBUG/* generate debugging code for UNH locks */#if !defined(CONFIG_SMP)/* generate debugging code for UNH locks on uniprocessors */typedef struct unh_lock_type { int lock; int line; void *flags; } unh_lock_t;#define UNH_LOCK_TYPE unh_lock_t#define UNH_LOCK_UNLOCKED (unh_lock_t) { 0, 0, 0 }#define UNH_LOCK(l, f) do { \ local_irq_save(f); \ if ((l)->lock != 0) { \ printk("%s:%d: LOCK value %d should be 0!\n",\ __FUNCTION__, __LINE__, (l)->lock); \ printk("last LOCK line %d\n", (l)->line); \ } \ if ((l)->flags) { \ printk("%s:%d: non-zero flags %p\n", \ __FUNCTION__, __LINE__, (l)->flags); \ printk("last LOCK line %d\n", (l)->line); \ } \ (l)->lock += 1; \ (l)->line = __LINE__; \ (l)->flags = &f; \ } while(0)#define UNH_UNLOCK(l,f) do { (l)->lock -= 1; \ if ((l)->lock != 0) { \ printk("%s:%d: UNLOCK value %d should be 0!\n",\ __FUNCTION__, __LINE__, (l)->lock); \ printk("last LOCK line %d\n", (l)->line); \ } \ if ((l)->flags != &f) { \ printk("%s:%d flags %p expected %p\n", \ __FUNCTION__, __LINE__, &(f), (l)->flags); \ printk("last LOCK line %d\n", (l)->line); \ } \ (l)->flags = 0; \ local_irq_restore(f); \ } while(0)#else/* generate debugging code for UNH locks on multiprocessors */typedef struct unh_lock_type { spinlock_t lock; int line; void * flags; } unh_lock_t;#define UNH_LOCK_TYPE unh_lock_t#define UNH_LOCK_UNLOCKED (unh_lock_t) { {1}, 0, 0 }#define UNH_LOCK(l,f) do { if(TRACE_TEST(TRACE_SEM)) { \ printk("%s:%d: Try %p\n", \ __FUNCTION__, __LINE__, (l)); \ spin_lock_irqsave(&(l)->lock,f); \ printk("%s:%d: Got %p\n", \ __FUNCTION__, __LINE__, (l)); \ } else { \ spin_lock_irqsave(&(l)->lock,f); \ } \ if ((l)->flags) { \ printk("%s:%d: non-zero flags %p\n", \ __FUNCTION__, __LINE__, (l)->flags); \ printk("%s last LOCK line %d\n", \ current->comm, (l)->line); \ spin_unlock_irqrestore (&(l)->lock,f); \ BUG(); \ } \ (l)->line = __LINE__; \ (l)->flags = &f; \ } while(0)#define UNH_UNLOCK(l,f) do { \ if(TRACE_TEST(TRACE_SEM)) { \ printk("%s:%d: Out %p\n", \ __FUNCTION__, __LINE__, l); \ } \ if ((l)->flags != &(f)) { \ printk("%s:%d flags %p expected %p\n", \ __FUNCTION__, __LINE__, &(f), (l)->flags); \ printk("%s last LOCK line %d\n", \ current->comm, (l)->line); \ spin_unlock_irqrestore (&(l)->lock,f); \ BUG(); \ } \ (l)->flags = 0; \ spin_unlock_irqrestore (&(l)->lock,f); \ } while(0)#endif#else/* do NOT generate debugging code for UNH locks */#define UNH_LOCK_TYPE spinlock_t#define UNH_LOCK_UNLOCKED SPIN_LOCK_UNLOCKED#define UNH_LOCK(l,f) spin_lock_irqsave(l,f)#define UNH_UNLOCK(l,f) spin_unlock_irqrestore (l,f)#endif/* Used for all access to the shared structures global_host and during * the operation of any single thread to prevent things from * disappearing from under the thread. */extern UNH_LOCK_TYPE host_data_lock;/* values for the session_state field of the session structure */enum session_states { SESSION_NOT_PRESENT, /* set in build_session_skeleton() as initial value */ SESSION_LOGGED_IN, /* set in iscsi_initiator_login() after a successful return from initiator_parameter_negotiate() */ SESSION_FULL_FEATURE_PHASE, /* set in create_session() after a successful return from init_session() where tx and rx threads for first connection in session are confirmed to be up ok */ SESSION_LOGGED_OUT, /* set in rx_logout_rsp() after receiving a successful logout response to a request of type LOGOUT_CLOSE_SESSION */ SESSION_CLOSED /* set at end of iscsi_initiator_rx_thread() by first rx thread to detect SESSION_LOGGED_OUT, or by the only rx thread in a discovery session */};/* values for the connection_state field of the connection structure */enum connection_states { CONNECTION_NOT_PRESENT, /* set in build_session_skeleton() as initial value. Also set in close_connection(), and init_connection() after connection is closed */ CONNECTION_CONNECTED, /* set in init_connection() after socket has been connected ok */ CONNECTION_LOGGED_IN, /* set in iscsi_initiator_login() after successful return from initiator_parameter_negotiate(), so login phase has completed ok */ CONNECTION_FULL_FEATURE_PHASE, /* set in init_connection() after rx thread for connection is confirmed to be up ok */ CONNECTION_RECOVERING, /* set in deal_with_connrec() after Time2Wait expires */ CONNECTION_LOGGED_OUT, /* set in rx_logout_rsp() after a successful logout response has been received to a request of type LOGOUT_CLOSE_CONNECTION */ CONNECTION_DISCONNECTED /* set at end of iscsi_initiator_rx_thread() after rx thread shuts down */};/* values for the cmd_error_state field of the command structure */enum cmd_error_states { CMD_OK_SO_FAR, /* no errors yet */ CMD_NEEDS_SNACK, /* need to send snack when remaining data ins stop arriving */ CMD_USING_SNACK /* when receiving data ins in response to a snack */};#define WHITE_SPACE " \t\v\f\n\r"/* Holds information extracted from a real or implied R2T from target. * Used by initiator to control sending DataOut PDUs to target.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -