qla2x00.c

来自「这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自」· C语言 代码 · 共 2,417 行 · 第 1/5 页

C
2,417 行
字号
STATIC void qla2300_dump_isp(scsi_qla_host_t *ha),qla2x00_dump_word(uint8_t *, uint32_t, uint32_t);#endif#if  NO_LONG_DELAYSSTATIC void qla2x00_sleep_done (struct semaphore * sem);#endifuint8_t qla2x00_allocate_sp_pool( scsi_qla_host_t *ha);void qla2x00_free_sp_pool(scsi_qla_host_t *ha );STATIC srb_t * qla2x00_get_new_sp (scsi_qla_host_t *ha);STATIC uint8_t qla2x00_check_tgt_status(scsi_qla_host_t *ha, Scsi_Cmnd *cmd);STATIC uint8_t qla2x00_check_port_status(scsi_qla_host_t *ha,		fc_port_t *fcport);STATIC void qla2x00_mark_device_lost(scsi_qla_host_t *ha, fc_port_t *fcport);STATIC void qla2x00_mark_all_devices_lost( scsi_qla_host_t *ha );STATIC inline void qla2x00_delete_from_done_queue(scsi_qla_host_t *, srb_t *); STATIC int __qla2x00_marker(scsi_qla_host_t *, uint16_t, uint16_t, uint8_t);static inline int qla2x00_marker(scsi_qla_host_t *ha,		uint16_t loop_id,		uint16_t lun,		uint8_t type){	int ret;	unsigned long flags = 0;	spin_lock_irqsave(&ha->hardware_lock, flags);	ret = __qla2x00_marker(ha, loop_id, lun, type);	spin_unlock_irqrestore(&ha->hardware_lock, flags);	return (ret);}/* Debug print buffer */char          debug_buff[LINESIZE*3];/** insmod needs to find the variable and make it point to something*/static char *ql2xdevconf = NULL;static int ql2xretrycount = 20;static int qla2xenbinq = 1;static int max_srbs = MAX_SRBS;#if defined(ISP2200) || defined(ISP2300)static int ql2xlogintimeout = 20;static int qlport_down_retry = 0;#endifstatic int ql2xmaxqdepth = 0;static int displayConfig = 0;#if MPIO_SUPPORTstatic int ConfigRequired = 0;static int recoveryTime = MAX_RECOVERYTIME;static int failbackTime = MAX_FAILBACKTIME;#endif	/* end of MPIO_SUPPORT */#if defined(MODULE)static char *ql2xopts = NULL;/* insmod qla2100 ql2xopts=verbose" */MODULE_PARM(ql2xopts, "s");MODULE_PARM_DESC(ql2xopts,		"Additional driver options.");MODULE_PARM(ql2xmaxqdepth, "i");MODULE_PARM_DESC(ql2xmaxqdepth,		"Maximum queue depth to report for target devices.");#if defined(ISP2200) || defined(ISP2300)MODULE_PARM(ql2xlogintimeout,"i");MODULE_PARM_DESC(ql2xlogintimeout,		"Login timeout value in seconds.");MODULE_PARM(qlport_down_retry,"i");MODULE_PARM_DESC(qlport_down_retry,		"Maximum number of command retries to a port that returns"		"a PORT-DOWN status.");#endifMODULE_PARM(max_srbs,"i");MODULE_PARM_DESC(max_srbs,		"Maximum number of simultaneous commands allowed for an HBA.");MODULE_PARM(displayConfig, "i");MODULE_PARM_DESC(displayConfig,		"If 1 then display the configuration used in "		"/etc/modules.conf.");#if MPIO_SUPPORTMODULE_PARM(ConfigRequired, "i");MODULE_PARM_DESC(ConfigRequired,		"If 1, then only configured devices passed in through the"		"ql2xopts parameter will be presented to the OS");MODULE_PARM(recoveryTime, "i");MODULE_PARM_DESC(recoveryTime,		"Recovery time in seconds before a target device is sent I/O "		"after a failback is performed.");MODULE_PARM(failbackTime, "i");MODULE_PARM_DESC(failbackTime,		"Delay in seconds before a failback is performed.");#endifMODULE_AUTHOR("QLogic Corporation");#if defined(MODULE_LICENSE)	 MODULE_LICENSE("GPL");#endif/** Just in case someone uses commas to separate items on the insmod* command line, we define a dummy buffer here to avoid having insmod* write wild stuff into our code segment*/static char dummy_buffer[60] =		"Please don't add commas in your insmod command!!\n";#endif#include "listops.h"#include "qla_fo.cfg"#if QLA2100_LIPTESTstatic int qla2x00_lip = 0;#endif#include <linux/ioctl.h>#include <scsi/scsi_ioctl.h>/* multi-OS QLOGIC IOCTL definition file */#include "exioct.h"#if QLA_SCSI_VENDOR_DIR/* Include routine to set direction for vendor specific commands */#include "qla_vendor.c"#endif/************************************************************************ We use the Scsi_Pointer structure that's included with each command* SCSI_Cmnd as a scratchpad. ** SCp is defined as follows:*  - SCp.ptr  -- > pointer to the SRB*  - SCp.this_residual  -- > HBA completion status for ioctl code. ** Cmnd->host_scribble --> Used to hold the hba actived handle (1..255).***********************************************************************/#define	CMD_SP(Cmnd)		((Cmnd)->SCp.ptr)#define CMD_COMPL_STATUS(Cmnd)  ((Cmnd)->SCp.this_residual)#define	CMD_HANDLE(Cmnd)	((Cmnd)->host_scribble)/* Additional fields used by ioctl passthru */#define CMD_RESID_LEN(Cmnd)     ((Cmnd)->SCp.buffers_residual)#define CMD_SCSI_STATUS(Cmnd)   ((Cmnd)->SCp.Status)#define CMD_ACTUAL_SNSLEN(Cmnd) ((Cmnd)->SCp.Message)#define CMD_ENTRY_STATUS(Cmnd)  ((Cmnd)->SCp.have_data_in)/* * Other SCS__Cmnd members we only reference */#define	CMD_XFRLEN(Cmnd)	(Cmnd)->request_bufflen#define	CMD_CDBLEN(Cmnd)	(Cmnd)->cmd_len#define	CMD_CDBP(Cmnd)		(Cmnd)->cmnd#define	CMD_SNSP(Cmnd)		(Cmnd)->sense_buffer#define	CMD_SNSLEN(Cmnd)	(sizeof (Cmnd)->sense_buffer)#define	CMD_RESULT(Cmnd)	((Cmnd)->result)#define	CMD_TIMEOUT(Cmnd)	((Cmnd)->timeout_per_command)#include "qla_debug.h"uint8_t copyright[48] = "Copyright 1999-2002, Qlogic Corporation";/****************************************************************************//*  LINUX -  Loadable Module Functions.                                     *//****************************************************************************//*****************************************//*   ISP Boards supported by this driver *//*****************************************/#define QLA2X00_VENDOR_ID   0x1077#define QLA2100_DEVICE_ID   0x2100#define QLA2200_DEVICE_ID   0x2200#define QLA2200A_DEVICE_ID  0x2200A#define QLA2300_DEVICE_ID   0x2300#define QLA2312_DEVICE_ID   0x2312#define QLA2200A_RISC_ROM_VER  4#define FPM_2300            6#define FPM_2310            7#if defined(ISP2100)#define NUM_OF_ISP_DEVICES  2static struct pci_device_id qla2100_pci_tbl[] ={	{QLA2X00_VENDOR_ID, QLA2100_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},	{0,},};MODULE_DEVICE_TABLE(pci, qla2100_pci_tbl);#endif#if defined(ISP2200)#define NUM_OF_ISP_DEVICES  2static struct pci_device_id qla2200_pci_tbl[] ={	{QLA2X00_VENDOR_ID, QLA2200_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},	{0,},};MODULE_DEVICE_TABLE(pci, qla2200_pci_tbl);#endif#if defined(ISP2300)#define NUM_OF_ISP_DEVICES  3static struct pci_device_id qla2300_pci_tbl[] ={	{QLA2X00_VENDOR_ID, QLA2300_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},	{QLA2X00_VENDOR_ID, QLA2312_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},	{0,},};MODULE_DEVICE_TABLE(pci, qla2300_pci_tbl);#endiftypedef struct _qlaboards{        unsigned char   bdName[9];       /* Board ID String             */        unsigned long   device_id;       /* Device ID                   */        int   numPorts;                  /* number of loops on adapter  */        unsigned short   *fwcode;        /* pointer to FW array         */        unsigned long    *fwlen;         /* number of words in array    */        unsigned short   *fwstart;       /* start address for F/W       */        unsigned char   *fwver;          /* Ptr to F/W version array    */}qla_boards_t;/* * NOTE: Check the Product ID of the Chip during chip diagnostics *       whenever support for new ISP is added.  */static struct _qlaboards   QLBoardTbl_fc[NUM_OF_ISP_DEVICES] ={	/* Name ,  Board PCI Device ID,         Number of ports */#if defined(ISP2300)	{"QLA2312 ", QLA2312_DEVICE_ID,           MAX_BUSES,#if defined(FC_IP_SUPPORT)		&fw2300ip_code01[0], (unsigned long *)&fw2300ip_length01,		&fw2300ip_addr01, &fw2300ip_version_str[0]	},#else		&fw2300tp_code01[0], (unsigned long *)&fw2300tp_length01,		&fw2300tp_addr01, &fw2300tp_version_str[0]	},#endif	{"QLA2300 ", QLA2300_DEVICE_ID,           MAX_BUSES,#if defined(FC_IP_SUPPORT)		&fw2300ip_code01[0], (unsigned long *)&fw2300ip_length01,		&fw2300ip_addr01, &fw2300ip_version_str[0]	},#else		&fw2300tp_code01[0], (unsigned long *)&fw2300tp_length01,		&fw2300tp_addr01, &fw2300tp_version_str[0]	},#endif#endif#if defined(ISP2200)	{"QLA2200 ", QLA2200_DEVICE_ID,           MAX_BUSES,#if defined(FC_IP_SUPPORT)		&fw2200ip_code01[0], (unsigned long *)&fw2200ip_length01,		&fw2200ip_addr01, &fw2200ip_version_str[0]	},#else		&fw2200tp_code01[0], (unsigned long *)&fw2200tp_length01,		&fw2200tp_addr01, &fw2200tp_version_str[0]	},#endif#endif#if defined(ISP2100)	{"QLA2100 ", QLA2100_DEVICE_ID,           MAX_BUSES,		&fw2100tp_code01[0], (unsigned long *)&fw2100tp_length01,		&fw2100tp_addr01, &fw2100tp_version_str[0]	},#endif	{"        ",                 0,           0}};/** Stat info for all adpaters*/static struct _qla2100stats  {        unsigned long   mboxtout;            /* mailbox timeouts */        unsigned long   mboxerr;             /* mailbox errors */        unsigned long   ispAbort;            /* ISP aborts */        unsigned long   debugNo;        unsigned long   loop_resync;        unsigned long   outarray_full;        unsigned long   retry_q_cnt;        scsi_qla_host_t *irqhba;}qla2x00_stats;/* * Declare our global semaphores */#if defined(ISP2100)DECLARE_MUTEX_LOCKED(qla2100_detect_sem);#endif#if defined(ISP2200)DECLARE_MUTEX_LOCKED(qla2200_detect_sem);#endif#if defined(ISP2300)DECLARE_MUTEX_LOCKED(qla2300_detect_sem);#endif/** Command line options*/static unsigned long qla2x00_verbose = 1L;static unsigned long qla2x00_quiet   = 0L;static unsigned long qla2x00_reinit = 0L;static unsigned long qla2x00_req_dmp = 0L;#if QL_TRACE_MEMORYextern unsigned long mem_trace[1000];extern unsigned long mem_id[1000];int	mem_trace_ptr = 0;#endif/* Enable for failover */#if MPIO_SUPPORTstatic unsigned long qla2x00_failover = 1L;#elsestatic unsigned long qla2x00_failover = 0L;#endif	/* end of MPIO_SUPPORT *//* * List of host adapters */static scsi_qla_host_t *qla2x00_hostlist = NULL;#if defined(QLA2100_PROFILE)static int qla2x00_buffer_size = 0;static char *qla2x00_buffer = NULL;#endifSTATIC int qla2x00_retryq_dmp = 0;              /* dump retry queue */#include <linux/ioctl.h>#include <scsi/scsi_ioctl.h>#include <asm/uaccess.h>/**************************************************************************   qla2x00_set_info** Description:*   Set parameters for the driver from the /proc filesystem.** Returns:*************************************************************************/intqla2x00_set_info(char *buffer, int length, struct Scsi_Host *HBAptr){	return (-ENOSYS);  /* Currently this is a no-op */}#include "qla_mbx.c"#include "qla2x00_ioctl.c"#if defined(INTAPI)#include "qla_inioct.c"#endif/************************************************************************** qla2x00_proc_info** Description:*   Return information to handle /proc support for the driver.** inout : decides on the direction of the dataflow and the meaning of the*         variables* buffer: If inout==FALSE data is being written to it else read from it*         (ptrs to a page buffer)* *start: If inout==FALSE start of the valid data in the buffer* offset: If inout==FALSE offset from the beginning of the imaginary file*         from which we start writing into the buffer* length: If inout==FALSE max number of bytes to be written into the buffer*         else number of bytes in the buffer* Returns:*************************************************************************/#define	PROC_BUF	(&qla2x00_buffer[len])intqla2x00_proc_info(char *buffer, char **start, off_t offset,	          int length, int hostno, int inout){#if QLA2100_PROFILE	struct Scsi_Host *host;	int             i;	int             len = 0;	int             size = 0;	os_lun_t	*up;	qla_boards_t    *bdp;	scsi_qla_host_t *ha;	uint32_t        t, l;	uint32_t        tmp_sn;	unsigned long   *flags;	struct list_head *list, *temp;	unsigned long    cpu_flags;	uint8_t	*loop_state;#if REQ_TRACE	Scsi_Cmnd       *cp;	srb_t           *sp;#endif	DEBUG3(printk(KERN_INFO			"Entering proc_info buff_in=%p, offset=0x%lx, "			"length=0x%x\n", buffer, offset, length);)		host = NULL;	/* Find the host that was specified */	for (ha=qla2x00_hostlist; (ha != NULL) && ha->host->host_no != hostno;			ha=ha->next) {		continue;	}	/* if host wasn't found then exit */	if (!ha) {		size = sprintf(buffer,				"Can't find adapter for host number %d\n", 				hostno);		if (size > length) {			return (size);		} else {			return (0);		}	}	host = ha->host;	if (inout == TRUE) /* Has data been written to the file? */	{		printk("qla2x00_proc: has data been written to the file. \n");		return (qla2x00_set_info(buffer, length, host));	}	/*	 * if our old buffer is the right size use it otherwise	 * allocate a new one.	 */	size = 4096 * 5;  /* get a page */	if( qla2x00_buffer_size != size ) {		/* deallocate this buffer and get a new one */		if( qla2x00_buffer != NULL ) {			kfree(qla2x00_buffer);			qla2x00_buffer_size = 0;		}		qla2x00_buffer = kmalloc(size, GFP_KERNEL);	}	if( qla2x00_buffer == NULL ) {		size = sprintf(buffer, "qla2100 - kmalloc error at line %d\n",				__LINE__);		return size;	}	/* save the size of our buffer */	qla2x00_buffer_size = size;	/* start building the print buffer */	bdp = &QLBoardTbl_fc[ha->devnum];	size =  sprintf(PROC_BUF,			"QLogic PCI to Fibre Channel Host Adapter for "#if defined(ISP2100)			"ISP2100:\n"#endif#if defined(ISP2200)			"ISP22xx:\n"#endif#if defined(ISP2300)			"ISP23xx:\n"#endif			"        Firmware version: %2d.%02d.%02d, "			"Driver version %s\n",			bdp->fwver[0], bdp->fwver[1], bdp->fwver[2], 

⌨️ 快捷键说明

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