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

📄 qla2x00.c

📁 QL2000卡的驱动程序,可以学习驱动的编程. 对于UNIX的I/O操作有帮助!
💻 C
📖 第 1 页 / 共 5 页
字号:
/**************************************************************************** * QLogic qla2x00 device driver for Linux 2.2.x (redhat 6.X). * Copyright (C) 2000 Qlogic Corporation  * (www.qlogic.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, 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. ****************************************************************************//****************************************************************************Revision History:    Rev. 2.23         July  19, 2000      BN QLogic	- Changed  all globals to static; for resolving limited          module loading symbol table size     Rev. 2.22         July  14, 2000      BN	- Updated 2100 FW to  1.19.10	- Updated 2200 FW to  2.01.14	- Move version to 2.22 for release to DVT    Rev. 2.19.8       July  11, 2000      DG    - Fixed 2100 issue of login retry when no fabric is attached.    Rev. 2.19.7       July  6, 2000      DG    - Set queue depth per lun to 16 instead of throttle which is a      port max queue size and added an option "ql2xmaxqdepth=xx"      to allow user to change queue depth. This prevents us from      exceeding the adapter's throttle size which causes requests      to sit in the input queue for long periods of time.    Rev. 2.19.6       June  28, 2000      DG    - GA release     - Fixed panic in putq_t routine when called from abort.    Rev. 2.19.5b7     June  27, 2000      DG    - Add logic to wait reset delay if no fabric devices are found.    Rev. 2.19.5b6     June  26, 2000      DG    - Fixed Fw ready issue.    - Clear sent flag in SRB, so we will abort commands in Lun      queue that were previously sent.    - Flush input queue when an isp_abort occurs.    Rev. 2.19.5b5     June  16, 2000      DG    - Fixed issue of not holding off request if multiple RSCN or      PORT updates occur while process the currect RSCN.    Rev. 2.19.5b4     June  16, 2000      DG    - Added lock for done_q to prevent losing requests in timer.    Rev. 2.19.5b3     June  16, 2000      DG    - Added routine to set the correct direction for vendor specific      commands. Set the new option "QLA_SCSI_VENDOR_DIR".    - Fixed issue of retrying continuously on a Missing SCSI device.    - Fixed multiple adapter issue. Only login into adapter node       once and never again.     - Change code not to use loop id 0 for Fabric nodes.     Rev. 2.19.5b2     June  15, 2000      DG    - Added code to reset port down count on good requests.    Rev. 2.19.5       June  8, 2000      DG    - Added code to display the connection type F, FL, or N.    - Reaarange code in DPC routine to put "retry login"      further  down in the routine and skip is loop is down.    - Check the returned status after GAN (qla2100_sns_device)      and retry on ISP TX timeout (0x4005).    Rev. 2.19.4       June  6, 2000      DG    - Fixed for panic that occurs when system is shutdown.    Rev. 2.19.3       June  5, 2000      DG    - Fixed retry logic for user configured targets.    Rev. 2.19.2       May  31, 2000      DG    - Remove spinlock in qla2100_timer.    - Change the jiffies timer to loop timer in fw_ready.     Rev. 2.19.1       May  6, 2000      DG    - Change risc code 2200 from 2.1.12 to 2.1.13 to correct issue      of getting mailbox timeouts.    - Change mailbox timer to get correct timeout.    - Added qla2100_cmd_wait to wait for outstanding commands to      complete before querying the name server after a LIP.      Rev. 2.19         May  6, 2000      DG    - Fixed mailbox timeout recovery logic.    Rev. 2.18         May  1, 2000      DG    - Changes from Fabric testing    Rev. 2.18b4       Apr 21, 2000      DG    - Fixed login retry count to retry count.    - If the loop is down for more than 4 minutes then restart       queues and reset adpater if enabled.    - In qla2100_queuecommand we no longer return new requests       immediately back to kernel when loop is down. This causes      SYSTEM to HANG when a lot of requests are outstanding. We       now put them in the done queue and let the DPC routine       return them to kernel.    - Fixed panic cause by changing the timeout value of new request      when the loop is down.     - Cleanup qla2100_next.    Rev. 2.18b3       Apr 18, 2000      DG    - After the GAN, check returned status in resp buffer.    Rev. 2.18b2       Apr 12, 2000      DG    - Added handling of firmware bug when we use connection mode      1 (P2P). The firmware tries to change to loop mode after      encountering some IO failures/resets.    - Added logic to reset all modules during a chip reset.    - After the GAN, if we lost devices or have a device that was       configured by the user then retry the login. This is a       work-a-round for Brocade switches. It sometimes does      not return all the devices in the port list.    Rev. 2.18b1     Apr 1, 2000      DG    - Added logic to ignore device types other than FL/F       from gan list. Mcdata switch returns a bogus port of      type 85 in the list.    - Added firmware 2.1.11 to fix issues with reusing loop ids.    Rev. 2.17       Mar 21, 2000      DG    - Fixed mailbox timeout timer.    - Added counters to record timeouts and aborts.    Rev. 2.16       Mar 8, 2000      DG    - Fixed Profiling code to reduced output of inactive devices.    - Fixed driver name in "/proc/scsi/qla2x00" instead of "qla".    - Fixed extended timeout value for loop down retries.    - Fixed code that search for target binding in command line to search      for all occurences instead of the first four.    - Disable the reinit of adapter when the LOOP is DOWN      for more than 4 minutes. It can be enabled with the command      line option "reinit_on_loopdown".    - Fixed issue of not setting HBA instance number before      calling HBA initialized.    Rev. 2.15       Feb 19, 2000      DG    - Fixed 2100 issue of driver not seeing storage when switch is connected      to loop.    Rev. 2.14       Feb 11, 2000      DG    - Added new logic to accept persistent binding information from the command line.    - Modified command parser to handle properties on the command line after      the regular options.    Rev. 2.13       Jan 27, 2000      TT    - Modify to use makefile parameter "IP=1" to enanle IP support.    - Fix SNS mailbox cmd parameter in qla2x00_register_ip_device.    - Reverse byte order on ha->port_id to match NT and fix compare bugs.    Rev. 2.12       Jan 26, 2000      TT+DG    - Updated Qlogic Linux sofware license.    - Added IP support for qla2xip driver.    - Fix host adapter structure initialization in qla2100_detect.    - Fix port name byte order in qla2100_update_fc_db.    - Fix the issue of not returning "NO_CONNECT" back to the user      when the loop is down after the loop down timer has expired.    - Added option QLA2100_EXT_TIMEOUT to extend timeout of each command.      default if OFF.    - Change device high water mark (hiwat) to execution throttle.    Rev. 2.11       Dec 8, 1999       DG    - Added Qlogic Linux sofware license.    Rev. 2.10       Oct 31, 1999      DG    - Fixed issue of not releasing requests if port is down (DPC issue).    - Ignore BIOS setting for MAX number of luns unless USE_BIOS_MAX_LUNS    is set.    Rev. 2.09       Oct 30, 1999      DG    - Fixed panic that occurs when a port is remove and init. The target    ID assigning code did not check for PORT_AVAILABLE.    Rev. 2.08       Oct 15, 1999      DG    - Fixed timeout logic for dealing with LIPs.    Rev. 2.07       Oct 14, 1999      DG    - Fixed the issue of /proc/scsi/qla displaying garbage.      qla2100_proc_info always returns zero.    Rev. 2.06       Oct 14, 1999      DG    - Fixed the issue of not setting the SCSI request sense bit in the      the driver_byte when the host_byte was good.    Rev. 2.05       Oct 12, 1999      DG    - Replace RISC code version 2.0.31 to 2.0.40 for QLA2200 Adapters.    - Added logic to always set the tag attribute byte, no matter if the      device has tags enabled or not. Some devices will check FCMND for      a tag attribute byte.    Rev. 2.04       Sept 30, 1999      DG    - Replace RISC code version 1.17.26 to 1.17.30 for QLA2100 Adapters.    - Replace RISC code version 2.0.27 to 2.0.31 for QLA2200 Adapters.    - Added option to use unique firmware array names. The latest      firmware source files already include unique array names.    - The firmware include file for 2100 have been change from isp_fw.h      to 2100ef.h    - The firmware include files for 2200 have been change from isp1_fw.h      to 2200ef.h    Rev. 2.03       Sept 16, 1999      DG    - Added option to use the portname instead of nodename to identify the port.    - Fixed timeout cause by multiple luns. Requests were setting in the input queue      because of a limited number of RISC requests queues.    Rev. 2.02       Sept 13, 1999      DG    - The code that wait for LIP was not functioning properly. Since some      devices take a long time to complete the LIP.    Rev. 2.01       Sept 9, 1999      DG    - Fixed system crash when mid-level issues a device reset that requires      aborting the LU_Q queues.    - Added handling for Overflow detection and FCP_STATUS errors.    - Cleanup code.    Rev. 2.00       Aug 27, 1999      DG      Changes to load as static driver linked with Redhat release 6.0      kernel (2.2.5).    - Moved the Linux SCSI host template.    - Moved the SCSI Driver Interface Prototypes.    - Fixed recovery logic for error code 0x28. The qla2100_timer routine      needed to purge the retry queue whenever the port timeout expires.    - Fixed issue of using the wrong timeout value for the      qla2100_timer routine.  The  2.2.x kernel uses a different      timeout mechmism to timeout commands. It now adds a seperate      timeout entry for each command instead of having its own list.    - Eliminate the mapping of target number and luns.    - Convert to the new PCI routines as part of kernel 2.2.5 changes.    - Removing interrupt disable/enable - not necessary with locks.    - Eliminate the spurious interrupts.    - Added logic to select the appropriate F/W depending on the board type      we are using 2100, 2100A or 2200.    Rev. 1.21       June 8, 1999      DG    - Added 2200 support.    Rev. 1.20       June 8, 1999      DG    Changes to support RedHat release 6.0 (kernel 2.2.5).    - Added SCSI exclusive access lock (io_request_lock) when accessing the adapter.    - Added the new LINUX interface template. Some new error handling routines have been      added to the template, but for now we will use the old ones.    Rev. 1.00       January 30, 1999  DG    -   Initial Release.*****************************************************************************//* static const char *version = "qla2100.c:v2.19.8 07/06/00 DG\n"; *//** Compile time Options:*            0 - Disable and 1 - Enable*/#define  QLA2100_64BIT_SUPPORT         0   /* 64-bit Support */#define  QL2100_TARGET_MODE_SUPPORT    0   /* Target mode support */#define  MEMORY_MAPPED_IO              0#define  DEBUG_QLA2100_INTR            0#define  USE_NVRAM_DEFAULTS	           0#define  DEBUG_PRINT_NVRAM             0#define  LOADING_RISC_ACTIVITY         0#define  AUTO_ESCALATE_RESET           0   /* Automatically escalate resets */#define  AUTO_ESCALATE_ABORT           0   /* Automatically escalate aborts */#define  STOP_ON_ERROR                 0   /* Stop on aborts and resets  */#define  STOP_ON_RESET                 0#define  STOP_ON_ABORT                 0#define  QLA2100_COMTRACE              0    /* One char tracing  */#define  DEBUG_QLA2100                 0    /* Debugging  */#define  WATCH_THREADS_SIZ             0    /* watch size of pending queue */#define  USE_PORTNAME                  1    /* option to use portnames to distinch with target we are talking too */#define  QLA2100_EXT_TIMEOUT           0    /* Extend the timeout for each command for 1 minute */#define  LUN_MASKING                   0#define  USE_FLASH                     0#define  QLA2100_PROFILE               1#define  QLA_SCSI_VENDOR_DIR		   0    /* Decode vendor specific op-codes for direction */#define QLA2100_LIPTEST    		0#define REQ_TRACE    		1#undef   TRACECODE                          /* include tracing code in watchdog routines */#define  CHECK_BINDING/** String arrays*/#define LINESIZE    80#define MAXARGS    26/** Include files*/#include <linux/config.h>#ifdef MODULE#include <linux/module.h>#endif#ifndef LINUX_VERSION_CODE#include <linux/version.h>#endif  /* LINUX_VERSION_CODE not defined */#define QLA2100_VERSION      "2.23"#include <stdarg.h>#include <asm/io.h>#include <asm/irq.h>#include <asm/segment.h>#include <asm/byteorder.h>#include <linux/types.h>#include <linux/string.h>#include <linux/errno.h>#include <linux/kernel.h>#include <linux/ioport.h>#include <linux/delay.h>#include <linux/timer.h>#include <linux/sched.h>#include <linux/pci.h>#include <linux/proc_fs.h>#include <linux/blk.h>#include <linux/tqueue.h>#include <linux/tasks.h>#include <linux/interrupt.h>#ifndef KERNEL_VERSION#  define KERNEL_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,95)# include <linux/bios32.h>#else#include <asm/spinlock.h>#define __KERNEL_SYSCALLS__#include <linux/unistd.h>#include <linux/smp_lock.h>#include <asm/system.h>#define SHUTDOWN_SIGS	(sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGTERM))#endif#include "sd.h"#include "scsi.h"#include "hosts.h"#ifdef FC_IP_SUPPORT#include <linux/skbuff.h>#include "qlcommon.h"#endif#include "qla2x00.h"#define UNIQUE_FW_NAME                 /* unique F/W array names */#ifdef UNIQUE_FW_NAME#include "ql2100_fw.h"                     /* ISP RISC code */#ifdef FC_IP_SUPPORT#include "ql2200ip_fw.h"                   /* ISP RISC 2200 code */#else#include "ql2200_fw.h"                     /* ISP RISC 2200 code */#endif#else#include "isp_fw.h"                     /* ISP RISC code */#include "isp1_fw.h"                     /* ISP RISC 2200 code */#endif#include <linux/stat.h>#include <linux/malloc.h>        /* for kmalloc() *//** These macros to assist programming*/#define  BZERO(ptr, amt)		memset((ptr), 0, amt)#define  BCOPY(src, dst, amt)	memcpy((dst), src, amt)#define  KMALLOC(siz)	kmalloc((siz), GFP_ATOMIC)#define  KMFREE(ip,siz)	kfree((ip))#define  SYS_DELAY(x)		udelay(x);barrier()#define  QLA2100_DELAY(sec)  mdelay(sec * HZ)#define  VIRT_TO_BUS(a) (unsigned int)virt_to_bus((void *)(a))#if  QLA2100_64BIT_SUPPORT#define  VIRT_TO_BUS_LOW(a) (unsigned int)(0xffffffff & virt_to_bus((void *)(a)))#define  VIRT_TO_BUS_HIGH(a) (unsigned int)(0xffffffff & (virt_to_bus((void *)(a))>>32))#else#define  VIRT_TO_BUS_LOW(a) (unsigned int)(0xffffffff & virt_to_bus((void *)(a)))#define  VIRT_TO_BUS_HIGH(a) (unsigned int)(0x0L)#endif  /* QLA2100_64BIT_SUPPORT */#define  CACHE_FLUSH(a) (RD_REG_WORD(a))#define  INVALID_HANDLE    (MAX_OUTSTANDING_COMMANDS+1)

⌨️ 快捷键说明

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