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

📄 iscsi.h

📁 这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自测试~但就算用来做参考资料也是非常好的
💻 H
字号:
#ifndef ISCSI_H_#define ISCSI_H_/* * iSCSI driver for Linux * Copyright (C) 2001 Cisco Systems, Inc. * maintained by linux-iscsi@cisco.com * * 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 of the License, 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. * * See the file COPYING included with this distribution for more details. * * $Id: iscsi.h,v 1.37 2002/10/14 23:00:49 smferris Exp $  * * iscsi.h * *    include for iSCSI kernel module *  */#include "iscsiAuthClient.h"#include "iscsi-common.h"#include "iscsi-limits.h"#include "iscsi-task.h"#include "iscsi-session.h"#ifndef MIN# define MIN(x, y)               ((x) < (y)) ? (x) : (y)#endif#ifndef MAX# define MAX(x, y)               ((x) > (y)) ? (x) : (y)#endif/* we must use this now.  the older approach has been removed */#define USE_ISCSI_EH_STRATEGY 1#define ISCSI_EH_STRATEGY iscsi_eh_strategytypedef struct iscsi_hba {    struct iscsi_hba        *next;    struct Scsi_Host        *host;    unsigned int            host_no;    unsigned long           flags;    spinlock_t              session_lock;    struct iscsi_session    *session_list_head;    struct iscsi_session    *session_list_tail;     atomic_t                num_sessions;    spinlock_t              free_task_lock;    iscsi_task_collection_t free_tasks;    atomic_t                num_free_tasks;    atomic_t                num_used_tasks;    volatile unsigned long  last_kfree_check;    volatile unsigned int   min_free_tasks;} iscsi_hba_t;/* HBA flags */#define ISCSI_HBA_ACTIVE          0#define ISCSI_HBA_SHUTTING_DOWN   1#define ISCSI_HBA_IN_EH_STRATEGY  2/* driver entry points needed by the probing code */int iscsi_queue( Scsi_Cmnd *sc, void (*done)(Scsi_Cmnd *) );int iscsi_squash_cmnd(iscsi_session_t *session, Scsi_Cmnd *sc);/* run-time controllable logging */#define ISCSI_LOG_ERR   1#define ISCSI_LOG_SENSE 2#define ISCSI_LOG_INIT  3#define ISCSI_LOG_QUEUE 4#define ISCSI_LOG_ALLOC 5#define ISCSI_LOG_EH    6#define ISCSI_LOG_FLOW  7#define ISCSI_LOG_SMP   8#define ISCSI_LOG_LOGIN 9#define LOG_SET(flag) (1U << (flag))#define LOG_ENABLED(flag) (iscsi_log_settings & (1U << (flag)))extern volatile unsigned int iscsi_log_settings;#ifdef DEBUG/* compile in all the debug messages and tracing */# define DEBUG_ERROR  1# define DEBUG_TRACE  1# define DEBUG_INIT   1# define DEBUG_QUEUE  1# define DEBUG_FLOW   1# define DEBUG_ALLOC  1# define DEBUG_EH     1# define DEBUG_SMP    1#else/* leave out the tracing and most of the debug messages */# define DEBUG_ERROR  1# define DEBUG_TRACE  0# define DEBUG_INIT   0# define DEBUG_QUEUE  0# define DEBUG_FLOW   0# define DEBUG_ALLOC  0# define DEBUG_EH     1# define DEBUG_SMP    0#endif#if DEBUG_INIT#define DEBUG_INIT0(DI0) do { if (LOG_ENABLED(ISCSI_LOG_INIT)) printk(DI0); } while (0)#define DEBUG_INIT1(DI0,DI1) do { if (LOG_ENABLED(ISCSI_LOG_INIT)) printk(DI0,DI1); } while (0)#define DEBUG_INIT2(DI0,DI1,DI2) do { if (LOG_ENABLED(ISCSI_LOG_INIT)) printk(DI0,DI1,DI2); } while (0)#define DEBUG_INIT3(DI0,DI1,DI2,DI3) do { if (LOG_ENABLED(ISCSI_LOG_INIT)) printk(DI0,DI1,DI2,DI3); } while (0)#define DEBUG_INIT4(DI0,DI1,DI2,DI3,DI4) do { if (LOG_ENABLED(ISCSI_LOG_INIT)) printk(DI0,DI1,DI2,DI3,DI4); } while (0)#define DEBUG_INIT5(DI0,DI1,DI2,DI3,DI4,DI5) do { if (LOG_ENABLED(ISCSI_LOG_INIT)) printk(DI0,DI1,DI2,DI3,DI4,DI5); } while (0)#define DEBUG_INIT6(DI0,DI1,DI2,DI3,DI4,DI5,DI6) do { if (LOG_ENABLED(ISCSI_LOG_INIT)) printk(DI0,DI1,DI2,DI3,DI4,DI5,DI6); } while (0)#else#define DEBUG_INIT0(DI0) do { } while (0)#define DEBUG_INIT1(DI0,DI1) do { } while (0)#define DEBUG_INIT2(DI0,DI1,DI2) do { } while (0)#define DEBUG_INIT3(DI0,DI1,DI2,DI3) do { } while (0)#define DEBUG_INIT4(DI0,DI1,DI2,DI3,DI4) do { } while (0)#define DEBUG_INIT5(DI0,DI1,DI2,DI3,DI4,DI5) do { } while (0)#define DEBUG_INIT6(DI0,DI1,DI2,DI3,DI4,DI5,DI6) do { } while (0)#endif#if DEBUG_QUEUE#define DEBUG_QUEUE0(DE0) do { if (LOG_ENABLED(ISCSI_LOG_QUEUE)) printk(DE0); } while (0)#define DEBUG_QUEUE1(DE0,DE1) do { if (LOG_ENABLED(ISCSI_LOG_QUEUE)) printk(DE0,DE1); } while (0)#define DEBUG_QUEUE2(DE0,DE1,DE2) do { if (LOG_ENABLED(ISCSI_LOG_QUEUE)) printk(DE0,DE1,DE2); } while (0)#define DEBUG_QUEUE3(DE0,DE1,DE2,DE3) do { if (LOG_ENABLED(ISCSI_LOG_QUEUE)) printk(DE0,DE1,DE2,DE3); } while (0)#define DEBUG_QUEUE4(DE0,DE1,DE2,DE3,DE4) do { if (LOG_ENABLED(ISCSI_LOG_QUEUE)) printk(DE0,DE1,DE2,DE3,DE4); } while (0)#define DEBUG_QUEUE5(DE0,DE1,DE2,DE3,DE4,DE5) do { if (LOG_ENABLED(ISCSI_LOG_QUEUE)) printk(DE0,DE1,DE2,DE3,DE4,DE5); } while (0)#define DEBUG_QUEUE6(DF0,DF1,DF2,DF3,DF4,DF5,DF6) do { if (LOG_ENABLED(ISCSI_LOG_QUEUE)) printk(DF0,DF1,DF2,DF3,DF4,DF5,DF6); } while (0)#define DEBUG_QUEUE7(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7) do { if (LOG_ENABLED(ISCSI_LOG_QUEUE)) printk(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7); } while (0)#else#define DEBUG_QUEUE0(DE0) do { } while (0)#define DEBUG_QUEUE1(DE0,DE1) do { } while (0)#define DEBUG_QUEUE2(DE0,DE1,DE2) do { } while (0)#define DEBUG_QUEUE3(DE0,DE1,DE2,DE3) do { } while (0)#define DEBUG_QUEUE4(DE0,DE1,DE2,DE3,DE4) do { } while (0)#define DEBUG_QUEUE5(DE0,DE1,DE2,DE3,DE4,DE5) do { } while (0)#define DEBUG_QUEUE6(DF0,DF1,DF2,DF3,DF4,DF5,DF6) do { } while (0)#define DEBUG_QUEUE7(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7) do { } while (0)#endif#if DEBUG_FLOW#define DEBUG_FLOW0(DF0) do { if (LOG_ENABLED(ISCSI_LOG_FLOW)) printk(DF0); } while (0)#define DEBUG_FLOW1(DF0,DF1) do { if (LOG_ENABLED(ISCSI_LOG_FLOW)) printk(DF0,DF1); } while (0)#define DEBUG_FLOW2(DF0,DF1,DF2) do { if (LOG_ENABLED(ISCSI_LOG_FLOW)) printk(DF0,DF1,DF2); } while (0)#define DEBUG_FLOW3(DF0,DF1,DF2,DF3) do { if (LOG_ENABLED(ISCSI_LOG_FLOW)) printk(DF0,DF1,DF2,DF3); } while (0)#define DEBUG_FLOW4(DF0,DF1,DF2,DF3,DF4) do { if (LOG_ENABLED(ISCSI_LOG_FLOW)) printk(DF0,DF1,DF2,DF3,DF4); } while (0)#define DEBUG_FLOW5(DF0,DF1,DF2,DF3,DF4,DF5) do { if (LOG_ENABLED(ISCSI_LOG_FLOW)) printk(DF0,DF1,DF2,DF3,DF4,DF5); } while (0)#define DEBUG_FLOW6(DF0,DF1,DF2,DF3,DF4,DF5,DF6) do { if (LOG_ENABLED(ISCSI_LOG_FLOW)) printk(DF0,DF1,DF2,DF3,DF4,DF5,DF6); } while (0)#define DEBUG_FLOW7(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7) do { if (LOG_ENABLED(ISCSI_LOG_FLOW)) printk(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7); } while (0)#define DEBUG_FLOW8(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7,DF8) do { if (LOG_ENABLED(ISCSI_LOG_FLOW)) printk(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7,DF8); } while (0)#else#define DEBUG_FLOW0(DF0) do { } while (0)#define DEBUG_FLOW1(DF0,DF1) do { } while (0)#define DEBUG_FLOW2(DF0,DF1,DF2) do { } while (0)#define DEBUG_FLOW3(DF0,DF1,DF2,DF3) do { } while (0)#define DEBUG_FLOW4(DF0,DF1,DF2,DF3,DF4) do { } while (0)#define DEBUG_FLOW5(DF0,DF1,DF2,DF3,DF4,DF5) do { } while (0)#define DEBUG_FLOW6(DF0,DF1,DF2,DF3,DF4,DF5,DF6) do { } while (0)#define DEBUG_FLOW7(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7) do { } while (0)#define DEBUG_FLOW8(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7,DF8) do { } while (0)#endif#if DEBUG_ALLOC#define DEBUG_ALLOC0(DE0) do { if (LOG_ENABLED(ISCSI_LOG_ALLOC)) printk(DE0); } while (0)#define DEBUG_ALLOC1(DE0,DE1) do { if (LOG_ENABLED(ISCSI_LOG_ALLOC)) printk(DE0,DE1); } while (0)#define DEBUG_ALLOC2(DE0,DE1,DE2) do { if (LOG_ENABLED(ISCSI_LOG_ALLOC)) printk(DE0,DE1,DE2); } while (0)#define DEBUG_ALLOC3(DE0,DE1,DE2,DE3) do { if (LOG_ENABLED(ISCSI_LOG_ALLOC)) printk(DE0,DE1,DE2,DE3); } while (0)#define DEBUG_ALLOC4(DE0,DE1,DE2,DE3,DE4) do { if (LOG_ENABLED(ISCSI_LOG_ALLOC)) printk(DE0,DE1,DE2,DE3,DE4); } while (0)#define DEBUG_ALLOC5(DE0,DE1,DE2,DE3,DE4,DE5) do { if (LOG_ENABLED(ISCSI_LOG_ALLOC)) printk(DE0,DE1,DE2,DE3,DE4,DE5); } while (0)#define DEBUG_ALLOC6(DF0,DF1,DF2,DF3,DF4,DF5,DF6) do { if (LOG_ENABLED(ISCSI_LOG_ALLOC)) printk(DF0,DF1,DF2,DF3,DF4,DF5,DF6); } while (0)#else#define DEBUG_ALLOC0(DE0) do { } while (0)#define DEBUG_ALLOC1(DE0,DE1) do { } while (0)#define DEBUG_ALLOC2(DE0,DE1,DE2) do { } while (0)#define DEBUG_ALLOC3(DE0,DE1,DE2,DE3) do { } while (0)#define DEBUG_ALLOC4(DE0,DE1,DE2,DE3,DE4) do { } while (0)#define DEBUG_ALLOC5(DE0,DE1,DE2,DE3,DE4,DE5) do { } while (0)#define DEBUG_ALLOC6(DF0,DF1,DF2,DF3,DF4,DF5,DF6) do { } while (0)#endif#if DEBUG_SMP# define DEBUG_SMP0(DE0) do { if (LOG_ENABLED(ISCSI_LOG_SMP)) printk(DE0); } while (0)# define DEBUG_SMP1(DE0,DE1) do { if (LOG_ENABLED(ISCSI_LOG_SMP)) printk(DE0,DE1); } while (0)# define DEBUG_SMP2(DE0,DE1,DE2) do { if (LOG_ENABLED(ISCSI_LOG_SMP)) printk(DE0,DE1,DE2); } while (0)# define DEBUG_SMP3(DE0,DE1,DE2,DE3) do { if (LOG_ENABLED(ISCSI_LOG_SMP)) printk(DE0,DE1,DE2,DE3); } while (0)# define DEBUG_SMP4(DE0,DE1,DE2,DE3,DE4) do { if (LOG_ENABLED(ISCSI_LOG_SMP)) printk(DE0,DE1,DE2,DE3,DE4); } while (0)# define DEBUG_SMP5(DE0,DE1,DE2,DE3,DE4,DE5) do { if (LOG_ENABLED(ISCSI_LOG_SMP)) printk(DE0,DE1,DE2,DE3,DE4,DE5); } while (0)# define DEBUG_SMP6(DF0,DF1,DF2,DF3,DF4,DF5,DF6) do { if (LOG_ENABLED(ISCSI_LOG_SMP)) printk(DF0,DF1,DF2,DF3,DF4,DF5,DF6); } while (0)# define DEBUG_SMP7(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7) do { if (LOG_ENABLED(ISCSI_LOG_SMP)) printk(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7); } while (0)#else# define DEBUG_SMP0(DE0)# define DEBUG_SMP1(DE0,DE1)# define DEBUG_SMP2(DE0,DE1,DE2)# define DEBUG_SMP3(DE0,DE1,DE2,DE3)# define DEBUG_SMP4(DE0,DE1,DE2,DE3,DE4)# define DEBUG_SMP5(DE0,DE1,DE2,DE3,DE4,DE5)# define DEBUG_SMP6(DF0,DF1,DF2,DF3,DF4,DF5,DF6)# define DEBUG_SMP7(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7)#endif#if DEBUG_EH# define DEBUG_EH0(DE0) do { if (LOG_ENABLED(ISCSI_LOG_EH)) printk(DE0); } while (0)# define DEBUG_EH1(DE0,DE1) do { if (LOG_ENABLED(ISCSI_LOG_EH)) printk(DE0,DE1); } while (0)# define DEBUG_EH2(DE0,DE1,DE2) do { if (LOG_ENABLED(ISCSI_LOG_EH)) printk(DE0,DE1,DE2); } while (0)# define DEBUG_EH3(DE0,DE1,DE2,DE3) do { if (LOG_ENABLED(ISCSI_LOG_EH)) printk(DE0,DE1,DE2,DE3); } while (0)# define DEBUG_EH4(DE0,DE1,DE2,DE3,DE4) do { if (LOG_ENABLED(ISCSI_LOG_EH)) printk(DE0,DE1,DE2,DE3,DE4); } while (0)# define DEBUG_EH5(DE0,DE1,DE2,DE3,DE4,DE5) do { if (LOG_ENABLED(ISCSI_LOG_EH)) printk(DE0,DE1,DE2,DE3,DE4,DE5); } while (0)# define DEBUG_EH6(DF0,DF1,DF2,DF3,DF4,DF5,DF6) do { if (LOG_ENABLED(ISCSI_LOG_EH)) printk(DF0,DF1,DF2,DF3,DF4,DF5,DF6); } while (0)# define DEBUG_EH7(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7) do { if (LOG_ENABLED(ISCSI_LOG_EH)) printk(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7); } while (0)#else# define DEBUG_EH0(DE0) do { } while (0)# define DEBUG_EH1(DE0,DE1) do { } while (0)# define DEBUG_EH2(DE0,DE1,DE2) do { } while (0)# define DEBUG_EH3(DE0,DE1,DE2,DE3) do { } while (0)# define DEBUG_EH4(DE0,DE1,DE2,DE3,DE4) do { } while (0)# define DEBUG_EH5(DE0,DE1,DE2,DE3,DE4,DE5) do { } while (0)# define DEBUG_EH6(DF0,DF1,DF2,DF3,DF4,DF5,DF6) do { } while (0)# define DEBUG_EH7(DF0,DF1,DF2,DF3,DF4,DF5,DF6,DF7) do { } while (0)#endif#if DEBUG_ERROR#define DEBUG_ERR0(DE0) do { if (LOG_ENABLED(ISCSI_LOG_ERR)) printk(DE0); } while (0)#define DEBUG_ERR1(DE0,DE1) do { if (LOG_ENABLED(ISCSI_LOG_ERR)) printk(DE0,DE1); } while (0)#define DEBUG_ERR2(DE0,DE1,DE2) do { if (LOG_ENABLED(ISCSI_LOG_ERR)) printk(DE0,DE1,DE2); } while (0)#define DEBUG_ERR3(DE0,DE1,DE2,DE3) do { if (LOG_ENABLED(ISCSI_LOG_ERR)) printk(DE0,DE1,DE2,DE3); } while (0)#define DEBUG_ERR4(DE0,DE1,DE2,DE3,DE4) do { if (LOG_ENABLED(ISCSI_LOG_ERR)) printk(DE0,DE1,DE2,DE3,DE4); } while (0)#define DEBUG_ERR5(DE0,DE1,DE2,DE3,DE4,DE5) do { if (LOG_ENABLED(ISCSI_LOG_ERR)) printk(DE0,DE1,DE2,DE3,DE4,DE5); } while (0)#else#define DEBUG_ERR0(DE0) do { } while (0)#define DEBUG_ERR1(DE0,DE1) do { } while (0)#define DEBUG_ERR2(DE0,DE1,DE2) do { } while (0)#define DEBUG_ERR3(DE0,DE1,DE2,DE3) do { } while (0)#define DEBUG_ERR4(DE0,DE1,DE2,DE3,DE4) do { } while (0)#define DEBUG_ERR5(DE0,DE1,DE2,DE3,DE4,DE5) do { } while (0)#endif/* the Scsi_Cmnd's request_bufflen doesn't always match the actual amount of data * to be read or written.  Try to compensate by decoding the cdb. */extern unsigned int iscsi_expected_data_length(Scsi_Cmnd *sc);/* Scsi_cmnd->result */#define DRIVER_BYTE(byte)   ((byte) << 24)#define HOST_BYTE(byte)     ((byte) << 16) /* HBA codes */#define MSG_BYTE(byte)      ((byte) << 8)#define STATUS_BYTE(byte)   ((byte))  /* SCSI status *//* extract parts of the sense data from an (unsigned char *) to the beginning of sense data */#define SENSE_KEY(sensebuf) ((sensebuf)[2] & 0x0F)#define ASC(sensebuf)       ((sensebuf)[12])#define ASCQ(sensebuf)       ((sensebuf)[13])#endif

⌨️ 快捷键说明

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