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

📄 qla2x00.c

📁 QL2000卡的驱动程序,可以学习驱动的编程. 对于UNIX的I/O操作有帮助!
💻 C
📖 第 1 页 / 共 5 页
字号:
#define  MSW(x)          (uint16_t)((uint32_t)(x) >> 16)#define  LSW(x)          (uint16_t)(x)#define  MSB(x)          (uint8_t)((uint16_t)(x) >> 8)#define  LSB(x)          (uint8_t)(x)#if  BITS_PER_LONG <= 32#define  LS_64BITS(x) (uint32_t)(x)#define  MS_64BITS(x) (uint32_t)(0x0)#define  QL21_64BITS_3RDWD(x)   ((uint16_t) 0)#define  QL21_64BITS_4THWD(x)   ((uint16_t) 0)#else#define  LS_64BITS(x) (uint32_t)(0xffffffff & (x))#define  MS_64BITS(x) (uint32_t)(0xffffffff & ((x)>>32) )#define  QL21_64BITS_3RDWD(x)   ((uint16_t) (x >> 32) & 0xffff)#define  QL21_64BITS_4THWD(x)   ((uint16_t) (x >> 48) & 0xffff)#endif#define  OFFSET(w)   (((uint32_t) &w) & 0xFFFF)                  /* 256 byte offsets */#define  SCSI_BUS_32(scp)   ((scp)->channel)#define  SCSI_TCN_32(scp)    ((scp)->target)#define  SCSI_LUN_32(scp)    ((scp)->lun)/** TIMER MACROS*/#define  QLA2100_TIMER_LOCK(ap)   spin_lock_irqsave(&(ap)->retry_lock, cpu_flags);#define  QLA2100_TIMER_UNLOCK(ap) spin_unlock_irqrestore(&(ap)->retry_lock, cpu_flags);#define	WATCH_INTERVAL		1       /* number of seconds */#define	START_TIMER(f, h, w)	\{ \init_timer(&(h)->timer); \(h)->timer.expires = jiffies + w * HZ;\(h)->timer.data = (unsigned long) h; \(h)->timer.function = (void (*)(unsigned long))f; \(h)->flags.start_timer = FALSE; \add_timer(&(h)->timer); \(h)->timer_active = 1;\}#define	RESTART_TIMER(f, h, w)	\{ \(h)->timer.expires = jiffies + w * HZ;\(h)->flags.start_timer = FALSE; \add_timer(&(h)->timer); \}#define	STOP_TIMER(f, h)	\{ \del_timer(&(h)->timer); \(h)->timer_active = 0;\}#define NVRAM_DELAY() udelay(500) /* 2 microsecond delay */typedef unsigned long paddr32_t;/**  Qlogic Driver support Function Prototypes.*/static uint8_t  qla2100_register_with_Linux(scsi_qla_host_t *ha, uint8_t maxchannels);static void   qla2100_done(scsi_qla_host_t *, srb_t **, srb_t **),              qla2100_next(scsi_qla_host_t *, scsi_lu_t *);static void      qla2100_done_q_put(scsi_qla_host_t *, srb_t *, srb_t **, srb_t **), qla2100_putq_t(scsi_lu_t *, srb_t *), qla2100_removeq(scsi_lu_t *, srb_t *), qla2100_timer(scsi_qla_host_t *), qla2100_timeout_insert(scsi_qla_host_t *, srb_t *), qla2100_timeout_remove(scsi_qla_host_t *, srb_t *), *qla2100_alloc_phys(int, uint32_t *phy_addr);static uint8_t   qla2100_mem_alloc(scsi_qla_host_t *);static void qla2100_dump_regs(struct Scsi_Host *host);#if  STOP_ON_ERRORstatic void qla2100_panic(char *, struct Scsi_Host *host);#endifvoid qla2100_print_scsi_cmd(Scsi_Cmnd *cmd);static void qla2100_abort_queue_single(scsi_qla_host_t *,uint32_t,uint32_t,uint32_t,uint32_t);static int qla2100_return_status(scsi_qla_host_t *ha, sts_entry_t *sts, Scsi_Cmnd       *cp);static void qla2100_removeq(scsi_lu_t *q, srb_t *sp);static void qla2100_mem_free(scsi_qla_host_t *ha);void qla2100_do_dpc(void *p);static inline void qla2100_callback(scsi_qla_host_t *ha, srb_t *sp, uint8_t dec), qla2100_tgt_dealloc(scsi_qla_host_t *, tgt_t *), qla2100_lun_dealloc(scsi_lu_t *);static inline tgt_t     *qla2100_tgt_alloc(scsi_qla_host_t *);static inline scsi_lu_t *qla2100_lun_alloc(void);static inline void qla2100_enable_intrs(scsi_qla_host_t *);static inline void qla2100_disable_intrs(scsi_qla_host_t *);#if QLA2100_EXT_TIMEOUTstatic void qla2100_extend_timeout(Scsi_Cmnd *cmd, int timeout);#endifstatic int  qla2100_get_tokens(char *line, char **argv, int maxargs );static void qla2100_device_queue_depth(scsi_qla_host_t *p, Scsi_Device *device);/**  QLogic ISP2100 Hardware Support Function Prototypes.*/static  uint8_t  qla2100_initialize_adapter(scsi_qla_host_t *), qla2100_isp_firmware(scsi_qla_host_t *), qla2100_pci_config(scsi_qla_host_t *), qla2100_set_cache_line(scsi_qla_host_t *), qla2100_chip_diag(scsi_qla_host_t *), qla2100_setup_chip(scsi_qla_host_t *), qla2100_init_rings(scsi_qla_host_t *), qla2100_fw_ready(scsi_qla_host_t *), qla2100_nvram_config(scsi_qla_host_t *), qla2200_nvram_config(scsi_qla_host_t *), qla2100_mailbox_command(scsi_qla_host_t *, u_char, uint16_t *), qla2100_update_device_data(scsi_qla_host_t *, device_data_t *, u_char), qla2100_sns_device(scsi_qla_host_t *, u_char), qla2100_update_fc_db(scsi_qla_host_t *, u_char), qla2100_map_targets(scsi_qla_host_t *),#if USE_FLASH qla2100_get_database(scsi_qla_host_t *), qla2100_save_database(scsi_qla_host_t *), qla2100_program_flash_address(scsi_qla_host_t *, uint32_t, u_char), qla2100_erase_flash_sector(scsi_qla_host_t *, uint32_t), qla2100_poll_flash(scsi_qla_host_t *, uint32_t, u_char),#endif qla2100_loop_reset(scsi_qla_host_t *), qla2100_device_reset(scsi_qla_host_t *, uint32_t, uint32_t), qla2100_abort_device(scsi_qla_host_t *, uint32_t, uint32_t, uint32_t), qla2100_abort_command(scsi_qla_host_t *, srb_t *),#if  QLA2100_64BIT_SUPPORT qla2100_64bit_start_scsi(scsi_qla_host_t *, srb_t *),#endif  /* QLA2100_64BIT_SUPPORT */ qla2100_32bit_start_scsi(scsi_qla_host_t *, srb_t *), qla2100_abort_isp(scsi_qla_host_t *), qla2100_loop_resync(scsi_qla_host_t *); static uint8_t qla2100_cmd_wait(scsi_qla_host_t *ha);static void      qla2100_nv_write(scsi_qla_host_t *, uint16_t), qla2100_poll(scsi_qla_host_t *), qla2100_init_fc_db(scsi_qla_host_t *), qla2100_init_tgt_map(scsi_qla_host_t *),#if USE_FLASH qla2100_flash_enable(scsi_qla_host_t *), qla2100_flash_disable(scsi_qla_host_t *), qla2100_write_flash_byte(scsi_qla_host_t *, uint32_t, u_char),#endif qla2100_reset_adapter(scsi_qla_host_t *), qla2100_marker(scsi_qla_host_t *, uint32_t, uint32_t, uint32_t,u_char), qla2100_enable_lun(scsi_qla_host_t *),#if  QLA2100_64BIT_SUPPORT qla2100_64bit_continue_io(scsi_qla_host_t *, atio_entry_t *,uint32_t, paddr32_t *),#endif  /* QLA2100_64BIT_SUPPORT */ qla2100_isp_cmd(scsi_qla_host_t *), qla2100_isr(scsi_qla_host_t *, srb_t **, srb_t **), qla2100_rst_aen(scsi_qla_host_t *), qla2100_status_entry(scsi_qla_host_t *, sts_entry_t *, srb_t **,srb_t **), qla2100_error_entry(scsi_qla_host_t *, response_t *, srb_t **,srb_t **),  qla2100_restart_queues(scsi_qla_host_t *, uint8_t);void  qla2100_restart_watchdog_queue(scsi_qla_host_t *);static void qla2100_abort_queues(scsi_qla_host_t *, uint8_t);static uint16_t  qla2100_get_nvram_word(scsi_qla_host_t *, uint32_t), qla2100_nvram_request(scsi_qla_host_t *, uint32_t),#if USE_FLASH qla2100_read_flash_byte(scsi_qla_host_t *, uint32_t),#endif qla2100_debounce_register(volatile uint16_t *);static request_t *qla2100_req_pkt(scsi_qla_host_t *);static uint8_t          qla2100_update_config(scsi_qla_host_t *ha);static uint8_t qla2100_configure_hba(scsi_qla_host_t *ha);static uint8_t qla2100_configure_loop(scsi_qla_host_t *ha, uint8_t );static void qla2100_reset_chip(scsi_qla_host_t *ha);#if QL2100_TARGET_MODE_SUPPORTstatic qla2100_enable_lun(scsi_qla_host_t *, uint8_t, uint32_t), qla2100_notify_ack(scsi_qla_host_t *, notify_entry_t *), qla2100_immed_notify(scsi_qla_host_t *, notify_entry_t *), qla2100_accept_io(scsi_qla_host_t *, ctio_ret_entry_t *),#if  QLA2100_64BIT_SUPPORT qla2100_64bit_continue_io(scsi_qla_host_t *, atio_entry_t *, uint32_t,paddr32_t *),#endif qla2100_32bit_continue_io(scsi_qla_host_t *, atio_entry_t *, uint32_t,paddr32_t *), qla2100_atio_entry(scsi_qla_host_t *, atio_entry_t *), qla2100_notify_entry(scsi_qla_host_t *, notify_entry_t *),#endif  /* QLA2100_TARGET_MODE_SUPPORT */static uint8_t qla2100_sns_get_name( scsi_qla_host_t *ha, device_data_t *device, uint8_t flag );static void qla2100_display_fc_names(scsi_qla_host_t *ha);#if  STOP_ON_ERRORvoid ql2100_dump_requests(scsi_qla_host_t *ha);#endifstatic void qla2100_get_properties(scsi_qla_host_t *ha, char *string);static uint8_t qla2100_find_propname(scsi_qla_host_t *ha, char *propname, char *propstr, char *db);static int qla2100_get_prop_16chars(scsi_qla_host_t *ha, char *propname, char *propval, char *cmdline);static char	*qla2100_get_line(char *str, char *line);static void qla2100_check_fabric_devices(scsi_qla_host_t *ha);#ifdef FC_IP_SUPPORTstatic void *qla2x00_alloc_phys(int size, u_long *phy_addr);/* Entry points for IP network driver */int  qla2x00_ip_inquiry(uint16_t wAdapterNumber, BD_INQUIRY_DATA *pInquiryData);int  qla2x00_ip_enable(scsi_qla_host_t *ha, BD_ENABLE_DATA *pEnableData);void qla2x00_ip_disable(scsi_qla_host_t *ha);void qla2x00_add_buffers(scsi_qla_host_t *ha, uint16_t wBufferCount);int  qla2x00_send_packet(scsi_qla_host_t *ha, SEND_CB *pSendCB);static int qla2x00_ip_initialize(scsi_qla_host_t *ha);static int qla2x00_add_new_ip_device(scsi_qla_host_t *ha,uint16_t wLoopId,uint8_t *pPortId,uint8_t *pPortName,int bForceAdd);static int qla2x00_convert_to_arp(scsi_qla_host_t *ha, SEND_CB *pSendCB);static void qla2x00_free_ip_block(scsi_qla_host_t *ha,IP_DEVICE_BLOCK *pIpDevice);static int qla2x00_get_ip_loopid(scsi_qla_host_t *ha,uint8_t *pNodeName,uint8_t *pLoopId);static int qla2x00_send_farp_request(scsi_qla_host_t *ha,uint8_t *pPortName);static int qla2x00_register_ip_device(scsi_qla_host_t *ha);static int qla2x00_reserve_ip_block(scsi_qla_host_t *ha,PIP_DEVICE_BLOCK *pIpDevBlk);static int qla2x00_update_ip_device_data(scsi_qla_host_t *ha,device_data_t *pDeviceData);static int qla2x00_reserve_loopid(scsi_qla_host_t *ha, uint16_t *pLoopId);static void qla2x00_free_loopid(scsi_qla_host_t *ha, uint16_t wLoopId);static int qla2x00_login_public_device(scsi_qla_host_t *ha,uint16_t *pLoopId,uint8_t  *pPortID,uint16_t wOptions);static int qla2x00_logout_public_device(scsi_qla_host_t *ha,uint16_t wLoopId,uint16_t wOptions);#endifvoid qla2100_print_q_info(scsi_lu_t *q);#if  DEBUG_QLA2100#ifndef QL_DEBUG_ROUTINES#define QL_DEBUG_ROUTINES#endif#endif#ifdef QL_DEBUG_ROUTINES/**  Driver Debug Function Prototypes.*/static uint8_t  qla2100_getbyte(uint8_t *);static uint16_t qla2100_getword(uint16_t *);static uint32_t qla2100_getdword(uint32_t *);static void     qla2100_putbyte(uint8_t *, uint8_t), qla2100_putword(uint16_t *, uint16_t), qla2100_putdword(uint32_t *, uint32_t), qla2100_print(int8_t *), qla2100_output_number(uint32_t, uint8_t), qla2100_putc(int8_t), qla2100_dump_buffer(uint8_t *, uint32_t);static uint8_t ql_debug_print;#endif/* Debug print buffer */char          debug_buff[LINESIZE];#if DEBUG_QLA2100static uint8_t ql_debug_print = 1;#elseuint8_t ql_debug_print = 1;#endif/** insmod needs to find the variable and make it point to something*/static char *ql2xdevconf = NULL;#ifdef MODULEstatic char *ql2xopts = NULL;static int ql2xmaxqdepth = 0;#if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,18)/* insmod qla2100 ql2xopts=verbose" */MODULE_PARM(ql2xopts, "s");MODULE_PARM(ql2xmaxqdepth, "i");#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/** Macros to change names of OS remapping routines.*/#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)#define ioremap vremap#define iounmap vfree#endif/** This is the pointer to the /proc/scsi/qla2100 code.* access the driver.*/#if CONFIG_PROC_FS/* this definition is normally in proc_fs.h     PROC_SCSI_QL2100 */#define PROC_SCSI_QL2100  PROC_SCSI_QLOGICISPstruct proc_dir_entry proc_scsi_qla2100 = {PROC_SCSI_QL2100, 7, "qla2x00",S_IFDIR | S_IRUGO | S_IXUGO, 2,0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL};#endif#if QLA2100_PROFILEstatic int qla2100_buffer_size = 0;static char *qla2100_buffer = NULL;#endifstatic int qla2100_lip = 0;#if QLA_SCSI_VENDOR_DIR/* Include routine to set direction for vendor specific commands */#include "qlavendor.c"#endif /************************************************************************ We use the Scsi_Pointer structure that's included with each command* SCSI_Cmnd as a scratchpad for our SRB. This allows us to accept* an unlimited number of commands.** SCp will always point to the SRB structure (defined in qla2100.h).* It is defined as follows:*  - SCp.ptr  -- > pointer back to the cmd*  - SCp.this_residual --> used as forward pointer to next srb*  - SCp.buffer --> used as backward pointer to next srb*  - SCp.buffers_residual --> used as flags field*  - SCp.have_data_in --> not used*  - SCp.sent_command --> not used*  - SCp.phase --> not used***********************************************************************/#define	CMD_SP(Cmnd)		(&(Cmnd)->SCp)#define	CMD_XFRLEN(Cmnd)	(Cmnd)->request_bufflen#define	CMD_CDBLEN(Cmnd)	(Cmnd)->cmd_len#define	CMD_CDBP(Cmnd)		(Cmnd)->cmnd

⌨️ 快捷键说明

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