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

📄 qla_def.h

📁 h内核
💻 H
📖 第 1 页 / 共 5 页
字号:
/*********************************************************************************                  QLOGIC LINUX SOFTWARE** QLogic ISP2x00 device driver for Linux 2.6.x* Copyright (C) 2003-2004 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.********************************************************************************/#ifndef __QLA_DEF_H#define __QLA_DEF_H#include <linux/kernel.h>#include <linux/init.h>#include <linux/types.h>#include <linux/module.h>#include <linux/list.h>#include <linux/pci.h>#include <linux/dma-mapping.h>#include <linux/sched.h>#include <linux/slab.h>#include <linux/dmapool.h>#include <linux/mempool.h>#include <linux/spinlock.h>#include <linux/completion.h>#include <asm/semaphore.h>#include <scsi/scsi.h>#include <scsi/scsi_host.h>#include <scsi/scsi_device.h>#include <scsi/scsi_cmnd.h>/* XXX(hch): move to pci_ids.h */#ifndef PCI_DEVICE_ID_QLOGIC_ISP2300#define PCI_DEVICE_ID_QLOGIC_ISP2300	0x2300#endif#ifndef PCI_DEVICE_ID_QLOGIC_ISP2312#define PCI_DEVICE_ID_QLOGIC_ISP2312	0x2312#endif#ifndef PCI_DEVICE_ID_QLOGIC_ISP2322#define PCI_DEVICE_ID_QLOGIC_ISP2322	0x2322#endif#ifndef PCI_DEVICE_ID_QLOGIC_ISP6312#define PCI_DEVICE_ID_QLOGIC_ISP6312	0x6312#endif#ifndef PCI_DEVICE_ID_QLOGIC_ISP6322#define PCI_DEVICE_ID_QLOGIC_ISP6322	0x6322#endif#if defined(CONFIG_SCSI_QLA21XX) || defined(CONFIG_SCSI_QLA21XX_MODULE)#define IS_QLA2100(ha)	((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2100)#else#define IS_QLA2100(ha)	0#endif#if defined(CONFIG_SCSI_QLA22XX) || defined(CONFIG_SCSI_QLA22XX_MODULE)#define IS_QLA2200(ha)	((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2200)#else#define IS_QLA2200(ha)	0#endif#if defined(CONFIG_SCSI_QLA2300) || defined(CONFIG_SCSI_QLA2300_MODULE)#define IS_QLA2300(ha)	((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2300)#define IS_QLA2312(ha)	((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2312)#else#define IS_QLA2300(ha)	0#define IS_QLA2312(ha)	0#endif#if defined(CONFIG_SCSI_QLA2322) || defined(CONFIG_SCSI_QLA2322_MODULE)#define IS_QLA2322(ha)	((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2322)#else#define IS_QLA2322(ha)	0#endif#if defined(CONFIG_SCSI_QLA6312) || defined(CONFIG_SCSI_QLA6312_MODULE)#define IS_QLA6312(ha)	((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP6312)#define IS_QLA6322(ha)	((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP6322)#else#define IS_QLA6312(ha)	0#define IS_QLA6322(ha)	0#endif#define IS_QLA23XX(ha)	(IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \    			 IS_QLA6312(ha) || IS_QLA6322(ha))/* * Only non-ISP2[12]00 have extended addressing support in the firmware. */#define HAS_EXTENDED_IDS(ha)	(!IS_QLA2100(ha) && !IS_QLA2200(ha))/* * We have MAILBOX_REGISTER_COUNT sized arrays in a few places, * but that's fine as we don't look at the last 24 ones for * ISP2100 HBAs. */#define MAILBOX_REGISTER_COUNT_2100	8#define MAILBOX_REGISTER_COUNT		32#define QLA2200A_RISC_ROM_VER	4#define FPM_2300		6#define FPM_2310		7#include "qla_settings.h"/*  * Data bit definitions */#define BIT_0	0x1#define BIT_1	0x2#define BIT_2	0x4#define BIT_3	0x8#define BIT_4	0x10#define BIT_5	0x20#define BIT_6	0x40#define BIT_7	0x80#define BIT_8	0x100#define BIT_9	0x200#define BIT_10	0x400#define BIT_11	0x800#define BIT_12	0x1000#define BIT_13	0x2000#define BIT_14	0x4000#define BIT_15	0x8000#define BIT_16	0x10000#define BIT_17	0x20000#define BIT_18	0x40000#define BIT_19	0x80000#define BIT_20	0x100000#define BIT_21	0x200000#define BIT_22	0x400000#define BIT_23	0x800000#define BIT_24	0x1000000#define BIT_25	0x2000000#define BIT_26	0x4000000#define BIT_27	0x8000000#define BIT_28	0x10000000#define BIT_29	0x20000000#define BIT_30	0x40000000#define BIT_31	0x80000000#define LSB(x)	((uint8_t)(x))#define MSB(x)	((uint8_t)((uint16_t)(x) >> 8))#define LSW(x)	((uint16_t)(x))#define MSW(x)	((uint16_t)((uint32_t)(x) >> 16))#define LSD(x)	((uint32_t)((uint64_t)(x)))#define MSD(x)	((uint32_t)((((uint64_t)(x)) >> 16) >> 16))/* * I/O register*/#define RD_REG_BYTE(addr)		readb(addr)#define RD_REG_WORD(addr)		readw(addr)#define RD_REG_DWORD(addr)		readl(addr)#define RD_REG_BYTE_RELAXED(addr)	readb_relaxed(addr)#define RD_REG_WORD_RELAXED(addr)	readw_relaxed(addr)#define RD_REG_DWORD_RELAXED(addr)	readl_relaxed(addr)#define WRT_REG_BYTE(addr, data)	writeb(data,addr)#define WRT_REG_WORD(addr, data)	writew(data,addr)#define WRT_REG_DWORD(addr, data)	writel(data,addr)/* * Fibre Channel device definitions. */#define WWN_SIZE		8	/* Size of WWPN, WWN & WWNN */#define MAX_FIBRE_DEVICES	512#define MAX_FIBRE_LUNS  	256#define	MAX_RSCN_COUNT		32#define	MAX_HOST_COUNT		16/* * Host adapter default definitions. */#define MAX_BUSES		1  /* We only have one bus today */#define MAX_TARGETS_2100	MAX_FIBRE_DEVICES#define MAX_TARGETS_2200	MAX_FIBRE_DEVICES#define MAX_TARGETS		MAX_FIBRE_DEVICES#define MIN_LUNS		8#define MAX_LUNS		MAX_FIBRE_LUNS#define MAX_CMDS_PER_LUN	255                                     /* * Fibre Channel device definitions. */#define SNS_LAST_LOOP_ID_2100	0xfe#define SNS_LAST_LOOP_ID_2300	0x7ff#define LAST_LOCAL_LOOP_ID	0x7d#define SNS_FL_PORT		0x7e#define FABRIC_CONTROLLER	0x7f#define SIMPLE_NAME_SERVER	0x80#define SNS_FIRST_LOOP_ID	0x81#define MANAGEMENT_SERVER	0xfe#define BROADCAST		0xff#define RESERVED_LOOP_ID(x)	((x > LAST_LOCAL_LOOP_ID && \				 x < SNS_FIRST_LOOP_ID) || \				 x == MANAGEMENT_SERVER || \				 x == BROADCAST)/* * Timeout timer counts in seconds */#define PORT_RETRY_TIME			2#define LOOP_DOWN_TIMEOUT		60#define LOOP_DOWN_TIME			255	/* 240 */#define	LOOP_DOWN_RESET			(LOOP_DOWN_TIME - 30)/* Maximum outstanding commands in ISP queues (1-65535) */#define MAX_OUTSTANDING_COMMANDS	1024/* ISP request and response entry counts (37-65535) */#define REQUEST_ENTRY_CNT_2100		128	/* Number of request entries. */#define REQUEST_ENTRY_CNT_2200		2048	/* Number of request entries. */#define REQUEST_ENTRY_CNT_2XXX_EXT_MEM	4096	/* Number of request entries. */#define RESPONSE_ENTRY_CNT_2100		64	/* Number of response entries.*/#define RESPONSE_ENTRY_CNT_2300		512	/* Number of response entries.*//* * SCSI Request Block  */typedef struct srb {	struct list_head list;	struct scsi_qla_host *ha;	/* HA the SP is queued on */	struct scsi_cmnd *cmd;		/* Linux SCSI command pkt */	struct timer_list timer;	/* Command timer */	atomic_t ref_count;	/* Reference count for this structure */				uint16_t flags;	/* Request state */	uint16_t state;	/* Target/LUN queue pointers. */	struct os_tgt *tgt_queue;	/* ptr to visible ha's target */	struct os_lun *lun_queue;	/* ptr to visible ha's lun */	struct fc_lun *fclun;		/* FC LUN context pointer. */	/* Timing counts. */	unsigned long e_start;		/* Start of extend timeout */	unsigned long r_start;		/* Start of request */	unsigned long u_start;		/* When sent to RISC */	unsigned long f_start;		/* When placed in FO queue*/	/* Single transfer DMA context */	dma_addr_t dma_handle;	uint32_t request_sense_length;	uint8_t *request_sense_ptr;	int ext_history;	/* Suspend delay */	int delay;	/* Raw completion info for use by failover ? */	uint8_t	fo_retry_cnt;		/* Retry count this request */	uint8_t	err_id;			/* error id */#define SRB_ERR_PORT	1		/* Request failed -- "port down" */#define SRB_ERR_LOOP	2		/* Request failed -- "loop down" */#define SRB_ERR_DEVICE	3		/* Request failed -- "device error" */#define SRB_ERR_OTHER	4	/* SRB magic number */	uint16_t magic;#define SRB_MAGIC       0x10CB} srb_t;/* * SRB flag definitions */#define SRB_TIMEOUT		BIT_0	/* Command timed out */#define SRB_DMA_VALID		BIT_1	/* Command sent to ISP */#define SRB_WATCHDOG		BIT_2	/* Command on watchdog list */#define SRB_ABORT_PENDING	BIT_3	/* Command abort sent to device */#define SRB_ABORTED		BIT_4	/* Command aborted command already */#define SRB_RETRY		BIT_5	/* Command needs retrying */#define SRB_GOT_SENSE		BIT_6	/* Command has sense data */#define SRB_FAILOVER		BIT_7	/* Command in failover state */#define SRB_BUSY		BIT_8	/* Command is in busy retry state */#define SRB_FO_CANCEL		BIT_9	/* Command don't need to do failover */#define SRB_IOCTL		BIT_10	/* IOCTL command. */#define SRB_TAPE		BIT_11	/* FCP2 (Tape) command. *//* * SRB state definitions */#define SRB_FREE_STATE		0	/*   returned back */#define SRB_PENDING_STATE	1	/*   queued in LUN Q */#define SRB_ACTIVE_STATE	2	/*   in Active Array */#define SRB_DONE_STATE		3	/*   queued in Done Queue */#define SRB_RETRY_STATE		4	/*   in Retry Queue */#define SRB_SUSPENDED_STATE	5	/*   in suspended state */#define SRB_NO_QUEUE_STATE	6	/*   is in between states */#define SRB_ACTIVE_TIMEOUT_STATE 7	/*   in Active Array but timed out */#define SRB_FAILOVER_STATE	8	/*   in Failover Queue */#define SRB_SCSI_RETRY_STATE	9	/*   in Scsi Retry Queue *//* * ISP I/O Register Set structure definitions. */typedef volatile struct {	volatile uint16_t flash_address; /* Flash BIOS address */	volatile uint16_t flash_data;	/* Flash BIOS data */	uint16_t unused_1[1];		/* Gap */	volatile uint16_t ctrl_status;	/* Control/Status */#define CSR_FLASH_64K_BANK	BIT_3	/* Flash upper 64K bank select */ #define CSR_FLASH_ENABLE	BIT_1	/* Flash BIOS Read/Write enable */#define CSR_ISP_SOFT_RESET	BIT_0	/* ISP soft reset */	volatile uint16_t ictrl;	/* Interrupt control */#define ICR_EN_INT		BIT_15	/* ISP enable interrupts. */#define ICR_EN_RISC		BIT_3	/* ISP enable RISC interrupts. */	volatile uint16_t istatus;	/* Interrupt status */#define ISR_RISC_INT		BIT_3	/* RISC interrupt */	volatile uint16_t semaphore;	/* Semaphore */	volatile uint16_t nvram;	/* NVRAM register. */#define NVR_DESELECT		0#define NVR_BUSY		BIT_15#define NVR_WRT_ENABLE		BIT_14	/* Write enable */#define NVR_PR_ENABLE		BIT_13	/* Protection register enable */#define NVR_DATA_IN		BIT_3#define NVR_DATA_OUT		BIT_2#define NVR_SELECT		BIT_1#define NVR_CLOCK		BIT_0	union {		struct {			volatile uint16_t mailbox0;			volatile uint16_t mailbox1;			volatile uint16_t mailbox2;			volatile uint16_t mailbox3;			volatile uint16_t mailbox4;			volatile uint16_t mailbox5;			volatile uint16_t mailbox6;			volatile uint16_t mailbox7;			uint16_t unused_2[59];		/* Gap */		} __attribute__((packed)) isp2100;		struct {							/* Request Queue */			volatile uint16_t req_q_in;	/*  In-Pointer */			volatile uint16_t req_q_out;	/*  Out-Pointer */							/* Response Queue */			volatile uint16_t rsp_q_in;	/*  In-Pointer */			volatile uint16_t rsp_q_out;	/*  Out-Pointer */						/* RISC to Host Status */			volatile uint32_t host_status;	#define HSR_RISC_INT		BIT_15	/* RISC interrupt */#define HSR_RISC_PAUSED		BIT_8	/* RISC Paused */					/* Host to Host Semaphore */			volatile uint16_t host_semaphore; 			uint16_t unused_3[17];		/* Gap */			volatile uint16_t mailbox0;			volatile uint16_t mailbox1;			volatile uint16_t mailbox2;			volatile uint16_t mailbox3;			volatile uint16_t mailbox4;			volatile uint16_t mailbox5;			volatile uint16_t mailbox6;			volatile uint16_t mailbox7;			volatile uint16_t mailbox8;			volatile uint16_t mailbox9;			volatile uint16_t mailbox10;			volatile uint16_t mailbox11;			volatile uint16_t mailbox12;			volatile uint16_t mailbox13;			volatile uint16_t mailbox14;			volatile uint16_t mailbox15;			volatile uint16_t mailbox16;			volatile uint16_t mailbox17;			volatile uint16_t mailbox18;			volatile uint16_t mailbox19;			volatile uint16_t mailbox20;			volatile uint16_t mailbox21;			volatile uint16_t mailbox22;			volatile uint16_t mailbox23;			volatile uint16_t mailbox24;			volatile uint16_t mailbox25;			volatile uint16_t mailbox26;			volatile uint16_t mailbox27;			volatile uint16_t mailbox28;			volatile uint16_t mailbox29;			volatile uint16_t mailbox30;			volatile uint16_t mailbox31;			volatile uint16_t fb_cmd;			uint16_t unused_4[10];		/* Gap */		} __attribute__((packed)) isp2300;	} u;	volatile uint16_t fpm_diag_config;	uint16_t unused_5[0x6];		/* Gap */	volatile uint16_t pcr;		/* Processor Control Register. */	uint16_t unused_6[0x5];		/* Gap */	volatile uint16_t mctr;		/* Memory Configuration and Timing. */	uint16_t unused_7[0x3];		/* Gap */	volatile uint16_t fb_cmd_2100;	/* Unused on 23XX */	uint16_t unused_8[0x3];		/* Gap */	volatile uint16_t hccr;		/* Host command & control register. */#define HCCR_HOST_INT		BIT_7	/* Host interrupt bit */#define HCCR_RISC_PAUSE		BIT_5	/* Pause mode bit */					/* HCCR commands */#define HCCR_RESET_RISC		0x1000	/* Reset RISC */#define HCCR_PAUSE_RISC		0x2000	/* Pause RISC */#define HCCR_RELEASE_RISC	0x3000	/* Release RISC from reset. */#define HCCR_SET_HOST_INT	0x5000	/* Set host interrupt */#define HCCR_CLR_HOST_INT	0x6000	/* Clear HOST interrupt */#define HCCR_CLR_RISC_INT	0x7000	/* Clear RISC interrupt */#define	HCCR_DISABLE_PARITY_PAUSE 0x4001 /* Disable parity error RISC pause. */#define HCCR_ENABLE_PARITY	0xA000	/* Enable PARITY interrupt */	uint16_t unused_9[5];		/* Gap */	volatile uint16_t gpiod;	/* GPIO Data register. */	volatile uint16_t gpioe;	/* GPIO Enable register. */#define GPIO_LED_MASK			0x00C0#define GPIO_LED_GREEN_OFF_AMBER_OFF	0x0000#define GPIO_LED_GREEN_ON_AMBER_OFF	0x0040#define GPIO_LED_GREEN_OFF_AMBER_ON	0x0080#define GPIO_LED_GREEN_ON_AMBER_ON	0x00C0	union {		struct {			uint16_t unused_10[8];		/* Gap */			volatile uint16_t mailbox8;			volatile uint16_t mailbox9;			volatile uint16_t mailbox10;			volatile uint16_t mailbox11;			volatile uint16_t mailbox12;

⌨️ 快捷键说明

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